Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions packages/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
14 changes: 4 additions & 10 deletions packages/core/src/lib/runtime.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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[] = [];
Expand Down
46 changes: 5 additions & 41 deletions packages/core/src/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,9 @@ export class WorkflowRuntime {
input: request.input,
});

const state: Record<string, unknown> = { ...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<string, unknown> = { ...request.input };
const retryState: Record<string, unknown> = {};
const results: StepResult[] = [];

await publishEvent(
this.infra,
Expand All @@ -128,11 +99,6 @@ export class WorkflowRuntime {
}),
);


const state: Record<string, unknown> = { ...request.input };
const retryState: Record<string, unknown> = {};
const results: StepResult[] = [];

try {
for (const [index, step] of request.workflow.steps.entries()) {
await withRuntimeSpan(
Expand All @@ -157,6 +123,7 @@ export class WorkflowRuntime {
traceId,
executionId,
workflowId: request.workflow.id,
tenantId: request.workflow.tenantId,
parentSpanId: workflowSpanId,
step,
state,
Expand Down Expand Up @@ -303,6 +270,7 @@ export class WorkflowRuntime {
const result = await this.runStep(
args.step,
args.state,
args.tenantId,
args.correlationId,
attempt,
);
Expand Down Expand Up @@ -365,12 +333,8 @@ export class WorkflowRuntime {
private async runStep(
step: WorkflowStep,
state: Record<string, unknown>,

tenantId: string,
correlationId: string,
): Promise<StepResult> {

correlationId: string,
attempt: number,
): Promise<Omit<StepResult, 'attempts' | 'retry'>> {

Expand Down