Files
sim/apps/sim/trigger.config.ts
T
2c4d2091b8 feat(pi): add code review mode (#5577)
* feat(pi): add Cloud Code Review mode and rename Cloud to Cloud PR

Introduce a third Pi mode that reviews an existing GitHub PR in an E2B sandbox and posts a structured review with optional inline comments. Keep the stored cloud id for backward compatibility, extend github_create_pr_review for inline comments, and harden review submission against stale SHAs and invalid comment payloads.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore(pi): cleanup code

* address comments

* address mor

* address comments

* update

---------

Co-authored-by: Bill Leoutsakos <billleoutsakos@Bills-MacBook-Pro.local>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
2026-07-20 16:25:40 -07:00

92 lines
3.1 KiB
TypeScript

import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http'
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { resourceFromAttributes } from '@opentelemetry/resources'
import {
additionalFiles,
additionalPackages,
syncEnvVars,
} from '@trigger.dev/build/extensions/core'
import { defineConfig } from '@trigger.dev/sdk'
import { env } from './lib/core/config/env'
import { parseOtlpHeaders } from './lib/monitoring/otlp'
const grafanaEndpoint = env.GRAFANA_OTLP_ENDPOINT
const grafanaHeaders = env.GRAFANA_OTLP_HEADERS
const grafanaDeploymentEnvironment = env.GRAFANA_DEPLOYMENT_ENVIRONMENT
const grafanaConfigured = Boolean(grafanaEndpoint || grafanaHeaders || grafanaDeploymentEnvironment)
const grafanaFullyConfigured = Boolean(
grafanaEndpoint && grafanaHeaders && grafanaDeploymentEnvironment
)
if (grafanaConfigured && !grafanaFullyConfigured) {
throw new Error(
'Grafana OTLP telemetry is partially configured. Set GRAFANA_OTLP_ENDPOINT, GRAFANA_OTLP_HEADERS, and GRAFANA_DEPLOYMENT_ENVIRONMENT together, or leave all three unset.'
)
}
const grafanaTelemetry = grafanaFullyConfigured
? (() => {
const baseUrl = grafanaEndpoint!.replace(/\/+$/, '')
const headers = parseOtlpHeaders(grafanaHeaders!)
if (Object.keys(headers).length === 0) {
throw new Error(
'GRAFANA_OTLP_HEADERS is set but yielded no valid key=value pairs. Expected format: "key1=value1,key2=value2".'
)
}
const resource = resourceFromAttributes({
'deployment.environment.name': grafanaDeploymentEnvironment!,
})
return {
exporters: [new OTLPTraceExporter({ url: `${baseUrl}/v1/traces`, headers })],
logExporters: [new OTLPLogExporter({ url: `${baseUrl}/v1/logs`, headers })],
metricExporters: [new OTLPMetricExporter({ url: `${baseUrl}/v1/metrics`, headers })],
resource,
}
})()
: undefined
export default defineConfig({
project: env.TRIGGER_PROJECT_ID!,
runtime: 'node-22',
logLevel: 'log',
maxDuration: 5400,
retries: {
enabledInDev: false,
default: {
maxAttempts: 1,
},
},
dirs: ['./background'],
...(grafanaTelemetry ? { telemetry: grafanaTelemetry } : {}),
build: {
external: [
'isolated-vm',
'@earendil-works/pi-ai',
'@earendil-works/pi-coding-agent',
'cpu-features',
],
extensions: [
syncEnvVars(() => [{ name: 'DB_APP_NAME', value: 'sim-trigger' }]),
additionalFiles({
files: [
'./lib/execution/isolated-vm-worker.cjs',
'./lib/execution/sandbox/bundles/pptxgenjs.cjs',
'./lib/execution/sandbox/bundles/docx.cjs',
'./lib/execution/sandbox/bundles/pdf-lib.cjs',
],
}),
additionalPackages({
packages: [
'unpdf',
'isolated-vm',
'react-dom',
'@react-email/render',
'@earendil-works/pi-ai',
'@earendil-works/pi-coding-agent',
],
}),
],
},
})