diff --git a/packages/contracts/src/index.ts b/packages/contracts/src/index.ts index a946a08..08846dc 100644 --- a/packages/contracts/src/index.ts +++ b/packages/contracts/src/index.ts @@ -73,16 +73,6 @@ export const traceSpanSchema = z.object({ kind: z.enum(['workflow', 'agent', 'tool', 'llm', 'queue', 'memory', 'trigger', 'retry', 'replay']), - kind: z.enum([ - 'workflow', - 'agent', - 'tool', - 'llm', - 'queue', - 'retry', - 'replay', - ]), - status: z.enum(['ok', 'error', 'running']), startedAt: z.string(), endedAt: z.string().nullable(), diff --git a/packages/core/src/lib/config.ts b/packages/core/src/lib/config.ts index 200d310..28629c6 100644 --- a/packages/core/src/lib/config.ts +++ b/packages/core/src/lib/config.ts @@ -30,9 +30,7 @@ const envSchema = z.object({ API_KEY: z.string().default('pulsestack-local-api-key'), TENANT_ID: z.string().default('local'), PLUGIN_DIR: z.string().default('./plugins'), -issue-30-auth-disabled-false AUTH_DISABLED: booleanEnv.default(true), - AUTH_DISABLED: z.coerce.boolean().default(true), OTEL_TRACING_ENABLED: z.coerce.boolean().default(false), OTEL_SERVICE_NAME: z.string().default(''), OTEL_TRACES_EXPORTER: z.enum(['none', 'console']).default('none'), diff --git a/packages/core/src/lib/runtime.test.ts b/packages/core/src/lib/runtime.test.ts index f169521..85f31d5 100644 --- a/packages/core/src/lib/runtime.test.ts +++ b/packages/core/src/lib/runtime.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from 'vitest'; -import type { EventEnvelope, WorkflowDefinition } from '@pulsestack/contracts'; +import type { EventEnvelope, ExecutionSnapshot, TraceSpan, WorkflowDefinition } from '@pulsestack/contracts'; +import type { PulseInfra } from './infra.js'; import { WorkflowRuntime } from './runtime.js'; class RuntimeInfraMock { @@ -43,15 +44,8 @@ describe('WorkflowRuntime', () => { ); expect(tenantEvents.length).toBeGreaterThan(0); expect(tenantEvents.every((event) => event.tenantId === workflow.tenantId)).toBe(true); - -import type { - EventEnvelope, - ExecutionSnapshot, - TraceSpan, -} from '@pulsestack/contracts'; -import { describe, expect, it } from 'vitest'; -import type { PulseInfra } from './infra.js'; -import { WorkflowRuntime } from './runtime.js'; + }); + }); function createRuntimeHarness() { const events: EventEnvelope[] = []; diff --git a/packages/core/src/lib/runtime.ts b/packages/core/src/lib/runtime.ts index e2bceda..1cd27c4 100644 --- a/packages/core/src/lib/runtime.ts +++ b/packages/core/src/lib/runtime.ts @@ -78,38 +78,9 @@ export class WorkflowRuntime { input: request.input, }); - const state: Record = { ...request.input }; - const results: StepResult[] = []; - - for (const [index, step] of request.workflow.steps.entries()) { - const span = await this.startSpan({ - traceId, - executionId, - workflowId: request.workflow.id, - tenantId: request.workflow.tenantId, - step, - state, - }); - - const result = await this.runStep(step, state, request.workflow.tenantId, request.workflow.correlationId); - Object.assign(state, { [step.id]: result.output }); - results.push(result); - - await this.snapshot({ - id: createId('snap'), - executionId, - workflowId: request.workflow.id, - sequence: index, - state: structuredClone(state), - sideEffects: [ - { - type: step.kind, - key: step.id, - response: result.output, - }, - ], - createdAt: new Date().toISOString(), - }); + const state: Record = { ...request.input }; + const retryState: Record = {}; + const results: StepResult[] = []; await publishEvent( this.infra, @@ -128,11 +99,6 @@ export class WorkflowRuntime { }), ); - - const state: Record = { ...request.input }; - const retryState: Record = {}; - const results: StepResult[] = []; - try { for (const [index, step] of request.workflow.steps.entries()) { await withRuntimeSpan( @@ -157,6 +123,7 @@ export class WorkflowRuntime { traceId, executionId, workflowId: request.workflow.id, + tenantId: request.workflow.tenantId, parentSpanId: workflowSpanId, step, state, @@ -303,6 +270,7 @@ export class WorkflowRuntime { const result = await this.runStep( args.step, args.state, + args.tenantId, args.correlationId, attempt, ); @@ -365,12 +333,8 @@ export class WorkflowRuntime { private async runStep( step: WorkflowStep, state: Record, - tenantId: string, correlationId: string, - ): Promise { - - correlationId: string, attempt: number, ): Promise> {