d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import { createLogger } from '@sim/logger'
|
|
import { generateId } from '@sim/utils/id'
|
|
import type { RequestTraceV1Outcome as RequestTraceOutcome } from '@/lib/copilot/generated/request-trace-v1'
|
|
import {
|
|
RequestTraceV1Outcome,
|
|
RequestTraceV1SpanStatus,
|
|
} from '@/lib/copilot/generated/request-trace-v1'
|
|
import { CopilotTransport } from '@/lib/copilot/generated/trace-attribute-values-v1'
|
|
import type { CopilotLifecycleOptions } from '@/lib/copilot/request/lifecycle/run'
|
|
import { runCopilotLifecycle } from '@/lib/copilot/request/lifecycle/run'
|
|
import { withCopilotOtelContext } from '@/lib/copilot/request/otel'
|
|
import { TraceCollector } from '@/lib/copilot/request/trace'
|
|
import type { OrchestratorResult } from '@/lib/copilot/request/types'
|
|
|
|
const logger = createLogger('CopilotHeadlessLifecycle')
|
|
|
|
export async function runHeadlessCopilotLifecycle(
|
|
requestPayload: Record<string, unknown>,
|
|
options: CopilotLifecycleOptions
|
|
): Promise<OrchestratorResult> {
|
|
const simRequestId =
|
|
typeof options.simRequestId === 'string' && options.simRequestId.length > 0
|
|
? options.simRequestId
|
|
: typeof requestPayload.messageId === 'string' && requestPayload.messageId.length > 0
|
|
? requestPayload.messageId
|
|
: generateId()
|
|
const trace = new TraceCollector()
|
|
const requestSpan = trace.startSpan('Headless Sim Agent Request', 'request', {
|
|
route: options.goRoute,
|
|
workflowId: options.workflowId,
|
|
workspaceId: options.workspaceId,
|
|
chatId: options.chatId,
|
|
})
|
|
|
|
let result: OrchestratorResult | undefined
|
|
let outcome: RequestTraceOutcome = RequestTraceV1Outcome.error
|
|
|
|
return withCopilotOtelContext(
|
|
{
|
|
requestId: simRequestId,
|
|
route: options.goRoute,
|
|
chatId: options.chatId,
|
|
workflowId: options.workflowId,
|
|
executionId: options.executionId,
|
|
runId: options.runId,
|
|
transport: CopilotTransport.Headless,
|
|
},
|
|
async (otelContext) => {
|
|
try {
|
|
result = await runCopilotLifecycle(requestPayload, {
|
|
...options,
|
|
trace,
|
|
simRequestId,
|
|
otelContext,
|
|
})
|
|
outcome = result.success
|
|
? RequestTraceV1Outcome.success
|
|
: options.abortSignal?.aborted || result.cancelled
|
|
? RequestTraceV1Outcome.cancelled
|
|
: RequestTraceV1Outcome.error
|
|
return result
|
|
} catch (error) {
|
|
outcome = options.abortSignal?.aborted
|
|
? RequestTraceV1Outcome.cancelled
|
|
: RequestTraceV1Outcome.error
|
|
throw error
|
|
} finally {
|
|
trace.endSpan(
|
|
requestSpan,
|
|
outcome === RequestTraceV1Outcome.success
|
|
? RequestTraceV1SpanStatus.ok
|
|
: outcome === RequestTraceV1Outcome.cancelled
|
|
? RequestTraceV1SpanStatus.cancelled
|
|
: RequestTraceV1SpanStatus.error
|
|
)
|
|
}
|
|
}
|
|
)
|
|
}
|