@workflow/world-local 5.0.0-beta.10 → 5.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/config.d.ts +17 -5
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +18 -13
  4. package/dist/config.js.map +1 -1
  5. package/dist/fs.d.ts +102 -2
  6. package/dist/fs.d.ts.map +1 -1
  7. package/dist/fs.js +291 -24
  8. package/dist/fs.js.map +1 -1
  9. package/dist/index.d.ts +15 -2
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +82 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/init.d.ts +91 -0
  14. package/dist/init.d.ts.map +1 -0
  15. package/dist/init.js +268 -0
  16. package/dist/init.js.map +1 -0
  17. package/dist/instrumentObject.d.ts +8 -0
  18. package/dist/instrumentObject.d.ts.map +1 -0
  19. package/dist/instrumentObject.js +66 -0
  20. package/dist/instrumentObject.js.map +1 -0
  21. package/dist/queue.d.ts +8 -1
  22. package/dist/queue.d.ts.map +1 -1
  23. package/dist/queue.js +164 -53
  24. package/dist/queue.js.map +1 -1
  25. package/dist/storage/events-storage.d.ts +7 -0
  26. package/dist/storage/events-storage.d.ts.map +1 -0
  27. package/dist/storage/events-storage.js +760 -0
  28. package/dist/storage/events-storage.js.map +1 -0
  29. package/dist/storage/filters.d.ts +22 -0
  30. package/dist/storage/filters.d.ts.map +1 -0
  31. package/dist/storage/filters.js +33 -0
  32. package/dist/storage/filters.js.map +1 -0
  33. package/dist/storage/helpers.d.ts +18 -0
  34. package/dist/storage/helpers.d.ts.map +1 -0
  35. package/dist/storage/helpers.js +44 -0
  36. package/dist/storage/helpers.js.map +1 -0
  37. package/dist/storage/hooks-storage.d.ts +12 -0
  38. package/dist/storage/hooks-storage.d.ts.map +1 -0
  39. package/dist/storage/hooks-storage.js +93 -0
  40. package/dist/storage/hooks-storage.js.map +1 -0
  41. package/dist/storage/index.d.ts +12 -0
  42. package/dist/storage/index.d.ts.map +1 -0
  43. package/dist/storage/index.js +32 -0
  44. package/dist/storage/index.js.map +1 -0
  45. package/dist/storage/legacy.d.ts +13 -0
  46. package/dist/storage/legacy.d.ts.map +1 -0
  47. package/dist/storage/legacy.js +77 -0
  48. package/dist/storage/legacy.js.map +1 -0
  49. package/dist/storage/runs-storage.d.ts +7 -0
  50. package/dist/storage/runs-storage.d.ts.map +1 -0
  51. package/dist/storage/runs-storage.js +59 -0
  52. package/dist/storage/runs-storage.js.map +1 -0
  53. package/dist/storage/steps-storage.d.ts +7 -0
  54. package/dist/storage/steps-storage.d.ts.map +1 -0
  55. package/dist/storage/steps-storage.js +52 -0
  56. package/dist/storage/steps-storage.js.map +1 -0
  57. package/dist/storage.d.ts +9 -2
  58. package/dist/storage.d.ts.map +1 -1
  59. package/dist/storage.js +8 -455
  60. package/dist/storage.js.map +1 -1
  61. package/dist/streamer.d.ts +4 -2
  62. package/dist/streamer.d.ts.map +1 -1
  63. package/dist/streamer.js +456 -104
  64. package/dist/streamer.js.map +1 -1
  65. package/dist/telemetry.d.ts +28 -0
  66. package/dist/telemetry.d.ts.map +1 -0
  67. package/dist/telemetry.js +71 -0
  68. package/dist/telemetry.js.map +1 -0
  69. package/dist/test-helpers.d.ts +54 -0
  70. package/dist/test-helpers.d.ts.map +1 -0
  71. package/dist/test-helpers.js +118 -0
  72. package/dist/test-helpers.js.map +1 -0
  73. package/dist/util.js.map +1 -1
  74. package/package.json +12 -11
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events-storage.js","sourceRoot":"","sources":["../../src/storage/events-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAW1B,OAAO,EACL,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AW;gBACnB,oCAAoC;gBACpC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,KAAK,aAAa;gBACxD,2DAA2D;gBAC3D,mDAAmD;gBACnD,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,SAAS,IAAI,KAAK;gBAChD,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK;gBAC/B,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM;gBACjC,YAAY,EAAE,kBAAkB,CAAC,MAAM,CAAC;gBACxC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO;aAChC,CAAC,CAAC;YAEH,yDAAyD;YACzD,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;gBAC3B,OAAO;oBACL,GAAG,MAAM;oBACT,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9B,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,CACvC;iBACF,CAAC;YACJ,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport {\n EntityConflictError,\n HookNotFoundError,\n RunExpiredError,\n RunNotSupportedError,\n TooEarlyError,\n WorkflowWorldError,\n} from '@workflow/errors';\nimport type {\n Event,\n EventResult,\n Hook,\n SerializedData,\n Step,\n Storage,\n Wait,\n WorkflowRun,\n} from '@workflow/world';\nimport {\n EventSchema,\n HookSchema,\n isLegacySpecVersion,\n requiresNewerWorld,\n SPEC_VERSION_CURRENT,\n StepSchema,\n validateUlidTimestamp,\n WaitSchema,\n WorkflowRunSchema,\n} from '@workflow/world';\nimport { DEFAULT_RESOLVE_DATA_OPTION } from '../config.js';\nimport {\n assertSafeEntityId,\n deleteJSON,\n jsonReplacer,\n listJSONFiles,\n paginatedFileSystemQuery,\n readJSONWithFallback,\n resolveWithinBase,\n taggedPath,\n writeExclusive,\n writeJSON,\n} from '../fs.js';\nimport { stripEventDataRefs } from './filters.js';\nimport { getObjectCreatedAt, hashToken, monotonicUlid } from './helpers.js';\nimport { deleteAllHooksForRun } from './hooks-storage.js';\nimport { handleLegacyEvent } from './legacy.js';\n\n/**\n * Helper function to delete all waits associated with a workflow run.\n * Called when a run reaches a terminal state.\n */\nasync function deleteAllWaitsForRun(\n basedir: string,\n runId: string\n): Promise<void> {\n const waitsDir = path.join(basedir, 'waits');\n const files = await listJSONFiles(waitsDir);\n\n for (const file of files) {\n // fileIds may contain tag suffixes (e.g., \"wrun_ABC-corrId.vitest-0\")\n // but startsWith still matches correctly since the tag is a suffix.\n if (file.startsWith(`${runId}-`)) {\n const waitPath = path.join(waitsDir, `${file}.json`);\n await deleteJSON(waitPath);\n }\n }\n}\n\n/**\n * Creates the events storage implementation using the filesystem.\n * Implements the Storage['events'] interface with create, list, and listByCorrelationId operations.\n */\nexport function createEventsStorage(\n basedir: string,\n tag?: string\n): Storage['events'] {\n return {\n async create(runId, data, params): Promise<EventResult> {\n const eventId = `evnt_${monotonicUlid()}`;\n const now = new Date();\n\n // Validate request-supplied IDs before they're concatenated into\n // filesystem paths. This is the primary defense against path traversal\n // attacks where a client supplies runId / correlationId values like\n // \"../../../package\" to read or write files outside the storage root.\n if (runId != null && runId !== '') {\n assertSafeEntityId('runId', runId);\n }\n if (\n 'correlationId' in data &&\n typeof data.correlationId === 'string' &&\n data.correlationId.length > 0\n ) {\n assertSafeEntityId('correlationId', data.correlationId);\n }\n\n // For run_created events, use client-provided runId or generate one server-side\n let effectiveRunId: string;\n if (data.eventType === 'run_created' && (!runId || runId === '')) {\n effectiveRunId = `wrun_${monotonicUlid()}`;\n } else if (!runId) {\n throw new Error('runId is required for non-run_created events');\n } else {\n effectiveRunId = runId;\n }\n\n // Validate client-provided runId timestamp is within acceptable threshold\n if (data.eventType === 'run_created' && runId && runId !== '') {\n const validationError = validateUlidTimestamp(effectiveRunId, 'wrun_');\n if (validationError) {\n throw new WorkflowWorldError(validationError);\n }\n }\n\n // specVersion is always sent by the runtime, but we provide a fallback for safety\n const effectiveSpecVersion = data.specVersion ?? SPEC_VERSION_CURRENT;\n\n // Helper to check if run is in terminal state\n const isRunTerminal = (status: string) =>\n ['completed', 'failed', 'cancelled'].includes(status);\n\n // Helper to check if step is in terminal state\n const isStepTerminal = (status: string) =>\n ['completed', 'failed', 'cancelled'].includes(status);\n\n // Get current run state for validation (if not creating a new run)\n // Skip run validation for step_completed and step_retrying - they only operate\n // on running steps, and running steps are always allowed to modify regardless\n // of run state. This optimization saves filesystem reads per step event.\n let currentRun: WorkflowRun | null = null;\n const skipRunValidationEvents = ['step_completed', 'step_retrying'];\n if (\n data.eventType !== 'run_created' &&\n !skipRunValidationEvents.includes(data.eventType)\n ) {\n currentRun = await readJSONWithFallback(\n basedir,\n 'runs',\n effectiveRunId,\n WorkflowRunSchema,\n tag\n );\n\n // Resilient start: run_started on non-existent run with eventData\n // creates the run first, so the queue can bootstrap a run that\n // failed to create during start().\n if (\n data.eventType === 'run_started' &&\n !currentRun &&\n 'eventData' in data &&\n data.eventData\n ) {\n const runInputData = data.eventData as {\n deploymentId?: string;\n workflowName?: string;\n input?: any;\n executionContext?: Record<string, any>;\n };\n if (\n runInputData.deploymentId &&\n runInputData.workflowName &&\n runInputData.input !== undefined\n ) {\n // Atomically try to create the run entity. writeExclusive\n // uses O_CREAT|O_EXCL so only the first writer wins,\n // preventing a TOCTOU race where a concurrent run_created\n // from start() could overwrite a run that was already\n // transitioned to 'running'.\n const createdRun: WorkflowRun = {\n runId: effectiveRunId,\n deploymentId: runInputData.deploymentId,\n status: 'pending',\n workflowName: runInputData.workflowName,\n specVersion: effectiveSpecVersion,\n executionContext: runInputData.executionContext,\n input: runInputData.input,\n output: undefined,\n error: undefined,\n startedAt: undefined,\n completedAt: undefined,\n createdAt: now,\n updatedAt: now,\n };\n const runPath = taggedPath(basedir, 'runs', effectiveRunId, tag);\n const created = await writeExclusive(\n runPath,\n JSON.stringify(createdRun, jsonReplacer)\n );\n\n if (created) {\n // We created the run — also write the run_created event.\n const runCreatedEventId = `evnt_${monotonicUlid()}`;\n const runCreatedEvent: Event = {\n eventType: 'run_created',\n runId: effectiveRunId,\n eventId: runCreatedEventId,\n createdAt: now,\n specVersion: effectiveSpecVersion,\n eventData: {\n deploymentId: runInputData.deploymentId,\n workflowName: runInputData.workflowName,\n input: runInputData.input,\n executionContext: runInputData.executionContext,\n },\n };\n const createdCompositeKey = `${effectiveRunId}-${runCreatedEventId}`;\n await writeJSON(\n taggedPath(basedir, 'events', createdCompositeKey, tag),\n runCreatedEvent\n );\n currentRun = createdRun;\n } else {\n // Run already exists (concurrent run_created won the\n // race). Re-read it so downstream logic sees the real state.\n currentRun = await readJSONWithFallback(\n basedir,\n 'runs',\n effectiveRunId,\n WorkflowRunSchema,\n tag\n );\n }\n }\n }\n }\n\n // ============================================================\n // VERSION COMPATIBILITY: Check run spec version\n // ============================================================\n // For events that have fetched the run, check version compatibility.\n // Skip for run_created (no existing run) and runtime events (step_completed, step_retrying).\n if (currentRun) {\n // Check if run requires a newer world version\n if (requiresNewerWorld(currentRun.specVersion)) {\n throw new RunNotSupportedError(\n currentRun.specVersion!,\n SPEC_VERSION_CURRENT\n );\n }\n\n // Route to legacy handler for pre-event-sourcing runs\n if (isLegacySpecVersion(currentRun.specVersion)) {\n return handleLegacyEvent(\n basedir,\n effectiveRunId,\n data,\n currentRun,\n params\n );\n }\n }\n\n // ============================================================\n // VALIDATION: Terminal state and event ordering checks\n // ============================================================\n\n // Run terminal state validation\n if (currentRun && isRunTerminal(currentRun.status)) {\n const runTerminalEvents = [\n 'run_started',\n 'run_completed',\n 'run_failed',\n ];\n\n // Idempotent operation: run_cancelled on already cancelled run is allowed\n if (\n data.eventType === 'run_cancelled' &&\n currentRun.status === 'cancelled'\n ) {\n // Return existing state (idempotent)\n const event: Event = {\n ...data,\n runId: effectiveRunId,\n eventId,\n createdAt: now,\n specVersion: effectiveSpecVersion,\n };\n const compositeKey = `${effectiveRunId}-${eventId}`;\n await writeJSON(\n taggedPath(basedir, 'events', compositeKey, tag),\n event\n );\n const resolveData =\n params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n return {\n event: stripEventDataRefs(event, resolveData),\n run: currentRun,\n };\n }\n\n // For run_started on terminal runs, use RunExpiredError so the\n // runtime knows to exit without retrying.\n if (data.eventType === 'run_started') {\n throw new RunExpiredError(\n `Workflow run \"${effectiveRunId}\" is already in terminal state \"${currentRun.status}\"`\n );\n }\n\n // Other run state transitions are not allowed on terminal runs\n if (\n runTerminalEvents.includes(data.eventType) ||\n data.eventType === 'run_cancelled'\n ) {\n throw new EntityConflictError(\n `Cannot transition run from terminal state \"${currentRun.status}\"`\n );\n }\n\n // Creating new entities on terminal runs is not allowed\n if (\n data.eventType === 'step_created' ||\n data.eventType === 'hook_created' ||\n data.eventType === 'wait_created'\n ) {\n throw new EntityConflictError(\n `Cannot create new entities on run in terminal state \"${currentRun.status}\"`\n );\n }\n }\n\n // Step-related event validation (ordering and terminal state)\n // Store existingStep so we can reuse it later (avoid double read)\n let validatedStep: Step | null = null;\n const stepEvents = [\n 'step_started',\n 'step_completed',\n 'step_failed',\n 'step_retrying',\n ];\n if (stepEvents.includes(data.eventType) && data.correlationId) {\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n validatedStep = await readJSONWithFallback(\n basedir,\n 'steps',\n stepCompositeKey,\n StepSchema,\n tag\n );\n\n // Event ordering: step must exist before these events\n if (!validatedStep) {\n throw new WorkflowWorldError(\n `Step \"${data.correlationId}\" not found`\n );\n }\n\n // Step terminal state validation\n if (isStepTerminal(validatedStep.status)) {\n throw new EntityConflictError(\n `Cannot modify step in terminal state \"${validatedStep.status}\"`\n );\n }\n\n // On terminal runs: only allow completing/failing in-progress steps\n if (currentRun && isRunTerminal(currentRun.status)) {\n if (validatedStep.status !== 'running') {\n throw new RunExpiredError(\n `Cannot modify non-running step on run in terminal state \"${currentRun.status}\"`\n );\n }\n }\n }\n\n // Hook-related event validation (ordering)\n const hookEventsRequiringExistence = ['hook_disposed', 'hook_received'];\n if (\n hookEventsRequiringExistence.includes(data.eventType) &&\n data.correlationId\n ) {\n const existingHook = await readJSONWithFallback(\n basedir,\n 'hooks',\n data.correlationId,\n HookSchema,\n tag\n );\n\n if (!existingHook) {\n throw new HookNotFoundError(data.correlationId);\n }\n }\n const event: Event = {\n ...data,\n runId: effectiveRunId,\n eventId,\n createdAt: now,\n specVersion: effectiveSpecVersion,\n };\n // Strip eventData from run_started — it belongs on run_created only.\n if (data.eventType === 'run_started' && 'eventData' in event) {\n delete (event as any).eventData;\n }\n\n // Track entity created/updated for EventResult\n let run: WorkflowRun | undefined;\n let step: Step | undefined;\n let hook: Hook | undefined;\n let wait: Wait | undefined;\n\n // Create/update entity based on event type (event-sourced architecture)\n // Run lifecycle events\n if (data.eventType === 'run_created' && 'eventData' in data) {\n const runData = data.eventData as {\n deploymentId: string;\n workflowName: string;\n input: SerializedData;\n executionContext?: Record<string, any>;\n };\n run = {\n runId: effectiveRunId,\n deploymentId: runData.deploymentId,\n status: 'pending',\n workflowName: runData.workflowName,\n // Propagate specVersion from the event to the run entity\n specVersion: effectiveSpecVersion,\n executionContext: runData.executionContext,\n input: runData.input,\n output: undefined,\n error: undefined,\n startedAt: undefined,\n completedAt: undefined,\n createdAt: now,\n updatedAt: now,\n };\n // Use writeExclusive (O_CREAT|O_EXCL) to atomically create the\n // run entity file. This prevents a TOCTOU race with the resilient\n // start path (run_started on non-existent run) that could result\n // in duplicate run_created events in the event log.\n const runPath = taggedPath(basedir, 'runs', effectiveRunId, tag);\n const created = await writeExclusive(\n runPath,\n JSON.stringify(run, jsonReplacer, 2)\n );\n if (!created) {\n throw new EntityConflictError(\n `Workflow run \"${effectiveRunId}\" already exists`\n );\n }\n } else if (data.eventType === 'run_started') {\n // Reuse currentRun from validation (already read above)\n if (currentRun) {\n // If already running, return the run without inserting a\n // duplicate event. This makes run_started idempotent for\n // concurrent invocations. We omit preloaded events here\n // because this is a rare race-condition path — the runtime\n // falls back to getAllWorkflowRunEvents().\n if (currentRun.status === 'running') {\n return { run: currentRun };\n }\n\n run = {\n runId: currentRun.runId,\n deploymentId: currentRun.deploymentId,\n workflowName: currentRun.workflowName,\n specVersion: currentRun.specVersion,\n executionContext: currentRun.executionContext,\n input: currentRun.input,\n createdAt: currentRun.createdAt,\n expiredAt: currentRun.expiredAt,\n status: 'running',\n output: undefined,\n error: undefined,\n completedAt: undefined,\n startedAt: currentRun.startedAt ?? now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'runs', effectiveRunId, tag),\n run,\n { overwrite: true }\n );\n }\n } else if (data.eventType === 'run_completed' && 'eventData' in data) {\n const completedData = data.eventData as { output?: any };\n // Reuse currentRun from validation (already read above)\n if (currentRun) {\n run = {\n runId: currentRun.runId,\n deploymentId: currentRun.deploymentId,\n workflowName: currentRun.workflowName,\n specVersion: currentRun.specVersion,\n executionContext: currentRun.executionContext,\n input: currentRun.input,\n createdAt: currentRun.createdAt,\n expiredAt: currentRun.expiredAt,\n startedAt: currentRun.startedAt,\n status: 'completed',\n output: completedData.output,\n error: undefined,\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'runs', effectiveRunId, tag),\n run,\n { overwrite: true }\n );\n await Promise.all([\n deleteAllHooksForRun(basedir, effectiveRunId),\n deleteAllWaitsForRun(basedir, effectiveRunId),\n ]);\n }\n } else if (data.eventType === 'run_failed' && 'eventData' in data) {\n const failedData = data.eventData as {\n error: any;\n errorCode?: string;\n };\n // Reuse currentRun from validation (already read above)\n if (currentRun) {\n run = {\n runId: currentRun.runId,\n deploymentId: currentRun.deploymentId,\n workflowName: currentRun.workflowName,\n specVersion: currentRun.specVersion,\n executionContext: currentRun.executionContext,\n input: currentRun.input,\n createdAt: currentRun.createdAt,\n expiredAt: currentRun.expiredAt,\n startedAt: currentRun.startedAt,\n status: 'failed',\n output: undefined,\n error: {\n message:\n typeof failedData.error === 'string'\n ? failedData.error\n : (failedData.error?.message ?? 'Unknown error'),\n stack: failedData.error?.stack,\n code: failedData.errorCode,\n },\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'runs', effectiveRunId, tag),\n run,\n { overwrite: true }\n );\n await Promise.all([\n deleteAllHooksForRun(basedir, effectiveRunId),\n deleteAllWaitsForRun(basedir, effectiveRunId),\n ]);\n }\n } else if (data.eventType === 'run_cancelled') {\n // Reuse currentRun from validation (already read above)\n if (currentRun) {\n run = {\n runId: currentRun.runId,\n deploymentId: currentRun.deploymentId,\n workflowName: currentRun.workflowName,\n specVersion: currentRun.specVersion,\n executionContext: currentRun.executionContext,\n input: currentRun.input,\n createdAt: currentRun.createdAt,\n expiredAt: currentRun.expiredAt,\n startedAt: currentRun.startedAt,\n status: 'cancelled',\n output: undefined,\n error: undefined,\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'runs', effectiveRunId, tag),\n run,\n { overwrite: true }\n );\n await Promise.all([\n deleteAllHooksForRun(basedir, effectiveRunId),\n deleteAllWaitsForRun(basedir, effectiveRunId),\n ]);\n }\n } else if (\n // Step lifecycle events\n data.eventType === 'step_created' &&\n 'eventData' in data\n ) {\n // step_created: Creates step entity with status 'pending', attempt=0, createdAt set\n const stepData = data.eventData as {\n stepName: string;\n input: any;\n };\n step = {\n runId: effectiveRunId,\n stepId: data.correlationId,\n stepName: stepData.stepName,\n status: 'pending',\n input: stepData.input,\n output: undefined,\n error: undefined,\n attempt: 0,\n startedAt: undefined,\n completedAt: undefined,\n createdAt: now,\n updatedAt: now,\n // Propagate specVersion from the event to the step entity\n specVersion: effectiveSpecVersion,\n };\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n await writeJSON(\n taggedPath(basedir, 'steps', stepCompositeKey, tag),\n step\n );\n } else if (data.eventType === 'step_started') {\n // step_started: Increments attempt, sets status to 'running'\n // Sets startedAt only on the first start (not updated on retries)\n // Reuse validatedStep from validation (already read above)\n if (validatedStep) {\n // Check if retryAfter timestamp hasn't been reached yet\n if (\n validatedStep.retryAfter &&\n validatedStep.retryAfter.getTime() > Date.now()\n ) {\n throw new TooEarlyError(\n `Cannot start step \"${data.correlationId}\": retryAfter timestamp has not been reached yet`,\n {\n retryAfter: Math.ceil(\n (validatedStep.retryAfter.getTime() - Date.now()) / 1000\n ),\n }\n );\n }\n\n // Best-effort guard: re-read the step entity to check if it\n // reached terminal state between the validation read and now.\n // This narrows the TOCTOU window but does not fully eliminate it\n // (the local world is single-process / dev-only; the postgres\n // world uses SQL-level atomic guards for production).\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n const freshStep = await readJSONWithFallback(\n basedir,\n 'steps',\n stepCompositeKey,\n StepSchema,\n tag\n );\n if (freshStep && isStepTerminal(freshStep.status)) {\n throw new EntityConflictError(\n `Cannot modify step in terminal state \"${freshStep.status}\"`\n );\n }\n\n step = {\n ...validatedStep,\n status: 'running',\n // Only set startedAt on the first start\n startedAt: validatedStep.startedAt ?? now,\n // Increment attempt counter on every start\n attempt: validatedStep.attempt + 1,\n // Clear retryAfter now that the step has started\n retryAfter: undefined,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'steps', stepCompositeKey, tag),\n step,\n { overwrite: true }\n );\n }\n } else if (data.eventType === 'step_completed' && 'eventData' in data) {\n // step_completed: Terminal state with output\n // Uses writeExclusive on a lock file to atomically prevent concurrent\n // invocations from both completing the same step (TOCTOU race).\n const completedData = data.eventData as { result: any };\n if (validatedStep) {\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n const lockName = tag\n ? `${stepCompositeKey}.terminal.${tag}`\n : `${stepCompositeKey}.terminal`;\n const terminalLockPath = resolveWithinBase(\n basedir,\n '.locks',\n 'steps',\n lockName\n );\n const claimed = await writeExclusive(terminalLockPath, '');\n if (!claimed) {\n throw new EntityConflictError(\n 'Cannot modify step in terminal state'\n );\n }\n step = {\n ...validatedStep,\n status: 'completed',\n output: completedData.result,\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'steps', stepCompositeKey, tag),\n step,\n { overwrite: true }\n );\n }\n } else if (data.eventType === 'step_failed' && 'eventData' in data) {\n // step_failed: Terminal state with error\n // Uses writeExclusive on a lock file to atomically prevent concurrent\n // invocations from both failing the same step (TOCTOU race).\n const failedData = data.eventData as {\n error: any;\n stack?: string;\n };\n if (validatedStep) {\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n const lockName = tag\n ? `${stepCompositeKey}.terminal.${tag}`\n : `${stepCompositeKey}.terminal`;\n const terminalLockPath = resolveWithinBase(\n basedir,\n '.locks',\n 'steps',\n lockName\n );\n const claimed = await writeExclusive(terminalLockPath, '');\n if (!claimed) {\n throw new EntityConflictError(\n 'Cannot modify step in terminal state'\n );\n }\n const error = {\n message:\n typeof failedData.error === 'string'\n ? failedData.error\n : (failedData.error?.message ?? 'Unknown error'),\n stack: failedData.stack,\n };\n step = {\n ...validatedStep,\n status: 'failed',\n error,\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'steps', stepCompositeKey, tag),\n step,\n { overwrite: true }\n );\n }\n } else if (data.eventType === 'step_retrying' && 'eventData' in data) {\n // step_retrying: Sets status back to 'pending', records error\n // Reuse validatedStep from validation (already read above)\n const retryData = data.eventData as {\n error: any;\n stack?: string;\n retryAfter?: Date;\n };\n if (validatedStep) {\n const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n step = {\n ...validatedStep,\n status: 'pending',\n error: {\n message:\n typeof retryData.error === 'string'\n ? retryData.error\n : (retryData.error?.message ?? 'Unknown error'),\n stack: retryData.stack,\n },\n retryAfter: retryData.retryAfter,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'steps', stepCompositeKey, tag),\n step,\n { overwrite: true }\n );\n }\n } else if (\n // Hook lifecycle events\n data.eventType === 'hook_created' &&\n 'eventData' in data\n ) {\n const hookData = data.eventData as {\n token: string;\n metadata?: any;\n isWebhook?: boolean;\n };\n\n // Atomically claim the token using an exclusive-create constraint file.\n // This avoids the TOCTOU race of the previous read-all-then-check approach.\n const constraintPath = path.join(\n basedir,\n 'hooks',\n 'tokens',\n `${hashToken(hookData.token)}.json`\n );\n const tokenClaimed = await writeExclusive(\n constraintPath,\n JSON.stringify({\n token: hookData.token,\n hookId: data.correlationId,\n runId: effectiveRunId,\n })\n );\n\n if (!tokenClaimed) {\n // Create hook_conflict event instead of hook_created\n // This allows the workflow to continue and fail gracefully when the hook is awaited\n const conflictEvent: Event = {\n eventType: 'hook_conflict',\n correlationId: data.correlationId,\n eventData: {\n token: hookData.token,\n },\n runId: effectiveRunId,\n eventId,\n createdAt: now,\n specVersion: effectiveSpecVersion,\n };\n\n // Store the conflict event\n const compositeKey = `${effectiveRunId}-${eventId}`;\n await writeJSON(\n taggedPath(basedir, 'events', compositeKey, tag),\n conflictEvent\n );\n\n const resolveData =\n params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n const filteredEvent = stripEventDataRefs(conflictEvent, resolveData);\n\n // Return EventResult with conflict event (no hook entity created)\n return {\n event: filteredEvent,\n run,\n step,\n hook: undefined,\n };\n }\n\n hook = {\n runId: effectiveRunId,\n hookId: data.correlationId,\n token: hookData.token,\n metadata: hookData.metadata,\n ownerId: 'local-owner',\n projectId: 'local-project',\n environment: 'local',\n createdAt: now,\n // Propagate specVersion from the event to the hook entity\n specVersion: effectiveSpecVersion,\n isWebhook: hookData.isWebhook ?? false,\n };\n await writeJSON(\n taggedPath(basedir, 'hooks', data.correlationId, tag),\n hook\n );\n } else if (data.eventType === 'hook_disposed') {\n // hook_disposed: Deletes hook entity, rejects duplicates.\n // Uses writeExclusive on a lock file to atomically prevent concurrent\n // invocations from both disposing the same hook (TOCTOU race).\n const hookLockName = tag\n ? `${data.correlationId}.disposed.${tag}`\n : `${data.correlationId}.disposed`;\n const lockPath = resolveWithinBase(\n basedir,\n '.locks',\n 'hooks',\n hookLockName\n );\n const claimed = await writeExclusive(lockPath, '');\n if (!claimed) {\n throw new EntityConflictError(\n `Hook \"${data.correlationId}\" already disposed`\n );\n }\n // Read the hook to get its token before deleting\n const hookPath = taggedPath(basedir, 'hooks', data.correlationId, tag);\n const existingHook = await readJSONWithFallback(\n basedir,\n 'hooks',\n data.correlationId,\n HookSchema,\n tag\n );\n if (existingHook) {\n // Delete the token constraint file to free up the token for reuse\n const disposedConstraintPath = path.join(\n basedir,\n 'hooks',\n 'tokens',\n `${hashToken(existingHook.token)}.json`\n );\n await deleteJSON(disposedConstraintPath);\n }\n await deleteJSON(hookPath);\n } else if (data.eventType === 'wait_created' && 'eventData' in data) {\n // wait_created: Creates wait entity with status 'waiting'\n const waitData = data.eventData as {\n resumeAt?: Date;\n };\n const waitCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n const existingWait = await readJSONWithFallback(\n basedir,\n 'waits',\n waitCompositeKey,\n WaitSchema,\n tag\n );\n if (existingWait) {\n throw new EntityConflictError(\n `Wait \"${data.correlationId}\" already exists`\n );\n }\n wait = {\n waitId: waitCompositeKey,\n runId: effectiveRunId,\n status: 'waiting',\n resumeAt: waitData.resumeAt,\n completedAt: undefined,\n createdAt: now,\n updatedAt: now,\n specVersion: effectiveSpecVersion,\n };\n await writeJSON(\n taggedPath(basedir, 'waits', waitCompositeKey, tag),\n wait\n );\n } else if (data.eventType === 'wait_completed') {\n // wait_completed: Transitions wait to 'completed', rejects duplicates.\n // Uses writeExclusive on a lock file to atomically prevent concurrent\n // invocations from both completing the same wait (TOCTOU race).\n const waitCompositeKey = `${effectiveRunId}-${data.correlationId}`;\n const waitLockName = tag\n ? `${waitCompositeKey}.completed.${tag}`\n : `${waitCompositeKey}.completed`;\n const lockPath = resolveWithinBase(\n basedir,\n '.locks',\n 'waits',\n waitLockName\n );\n const claimed = await writeExclusive(lockPath, '');\n if (!claimed) {\n throw new EntityConflictError(\n `Wait \"${data.correlationId}\" already completed`\n );\n }\n const existingWait = await readJSONWithFallback(\n basedir,\n 'waits',\n waitCompositeKey,\n WaitSchema,\n tag\n );\n if (!existingWait) {\n // Clean up the lock file we just claimed — the wait doesn't exist\n await fs.unlink(lockPath).catch(() => {});\n throw new WorkflowWorldError(\n `Wait \"${data.correlationId}\" not found`\n );\n }\n // The lock file (writeExclusive above) already prevents concurrent\n // completions — no additional status check needed.\n wait = {\n ...existingWait,\n status: 'completed',\n completedAt: now,\n updatedAt: now,\n };\n await writeJSON(\n taggedPath(basedir, 'waits', waitCompositeKey, tag),\n wait,\n { overwrite: true }\n );\n }\n // Note: hook_received events are stored in the event log but don't\n // modify the Hook entity (which doesn't have a payload field)\n\n // Store event using composite key {runId}-{eventId}\n const compositeKey = `${effectiveRunId}-${eventId}`;\n await writeJSON(taggedPath(basedir, 'events', compositeKey, tag), event);\n\n const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n const filteredEvent = stripEventDataRefs(event, resolveData);\n\n // For run_started: include all events so the runtime can skip\n // the initial events.list call and reduce TTFB.\n let events: Event[] | undefined;\n if (data.eventType === 'run_started' && run) {\n const allEvents = await paginatedFileSystemQuery({\n directory: path.join(basedir, 'events'),\n schema: EventSchema,\n filePrefix: `${effectiveRunId}-`,\n sortOrder: 'asc',\n getCreatedAt: getObjectCreatedAt('evnt'),\n getId: (e) => e.eventId,\n });\n events = allEvents.data;\n }\n\n // Return EventResult with event and any created/updated entity\n return {\n event: filteredEvent,\n run,\n step,\n hook,\n wait,\n events,\n };\n },\n\n async get(runId, eventId, params) {\n assertSafeEntityId('runId', runId);\n assertSafeEntityId('eventId', eventId);\n const compositeKey = `${runId}-${eventId}`;\n const event = await readJSONWithFallback(\n basedir,\n 'events',\n compositeKey,\n EventSchema,\n tag\n );\n if (!event) {\n throw new Error(`Event ${eventId} in run ${runId} not found`);\n }\n const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n return stripEventDataRefs(event, resolveData);\n },\n\n async list(params) {\n const { runId } = params;\n assertSafeEntityId('runId', runId);\n const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n const result = await paginatedFileSystemQuery({\n directory: path.join(basedir, 'events'),\n schema: EventSchema,\n filePrefix: `${runId}-`,\n // Events in chronological order (oldest first) by default,\n // different from the default for other list calls.\n sortOrder: params.pagination?.sortOrder ?? 'asc',\n limit: params.pagination?.limit,\n cursor: params.pagination?.cursor,\n getCreatedAt: getObjectCreatedAt('evnt'),\n getId: (event) => event.eventId,\n });\n\n // If resolveData is \"none\", remove eventData from events\n if (resolveData === 'none') {\n return {\n ...result,\n data: result.data.map((event) =>\n stripEventDataRefs(event, resolveData)\n ),\n };\n }\n\n return result;\n },\n\n async listByCorrelationId(params) {\n const correlationId = params.correlationId;\n assertSafeEntityId('correlationId', correlationId);\n const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n const result = await paginatedFileSystemQuery({\n directory: path.join(basedir, 'events'),\n schema: EventSchema,\n // No filePrefix - search all events\n filter: (event) => event.correlationId === correlationId,\n // Events in chronological order (oldest first) by default,\n // different from the default for other list calls.\n sortOrder: params.pagination?.sortOrder ?? 'asc',\n limit: params.pagination?.limit,\n cursor: params.pagination?.cursor,\n getCreatedAt: getObjectCreatedAt('evnt'),\n getId: (event) => event.eventId,\n });\n\n // If resolveData is \"none\", remove eventData from events\n if (resolveData === 'none') {\n return {\n ...result,\n data: result.data.map((event) =>\n stripEventDataRefs(event, resolveData)\n ),\n };\n }\n\n return result;\n },\n };\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import type { Hook, Step, StepWithoutData, WorkflowRun, WorkflowRunWithoutData } from '@workflow/world';
2
+ export { stripEventDataRefs } from '@workflow/world';
3
+ /**
4
+ * Filter run data based on resolveData setting.
5
+ * When resolveData is 'none', strips input/output to reduce payload size.
6
+ */
7
+ export declare function filterRunData(run: WorkflowRun, resolveData: 'none'): WorkflowRunWithoutData;
8
+ export declare function filterRunData(run: WorkflowRun, resolveData: 'all'): WorkflowRun;
9
+ export declare function filterRunData(run: WorkflowRun, resolveData: 'none' | 'all'): WorkflowRun | WorkflowRunWithoutData;
10
+ /**
11
+ * Filter step data based on resolveData setting.
12
+ * When resolveData is 'none', strips input/output to reduce payload size.
13
+ */
14
+ export declare function filterStepData(step: Step, resolveData: 'none'): StepWithoutData;
15
+ export declare function filterStepData(step: Step, resolveData: 'all'): Step;
16
+ export declare function filterStepData(step: Step, resolveData: 'none' | 'all'): Step | StepWithoutData;
17
+ /**
18
+ * Filter hook data based on resolveData setting.
19
+ * When resolveData is 'none', strips metadata to reduce payload size.
20
+ */
21
+ export declare function filterHookData(hook: Hook, resolveData: 'none' | 'all'): Hook;
22
+ //# sourceMappingURL=filters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../src/storage/filters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,IAAI,EACJ,eAAe,EACf,WAAW,EACX,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,GAClB,sBAAsB,CAAC;AAC1B,wBAAgB,aAAa,CAC3B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,KAAK,GACjB,WAAW,CAAC;AACf,wBAAgB,aAAa,CAC3B,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,GAAG,KAAK,GAC1B,WAAW,GAAG,sBAAsB,CAAC;AAexC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAClB,eAAe,CAAC;AACnB,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;AACrE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,GAAG,KAAK,GAC1B,IAAI,GAAG,eAAe,CAAC;AAe1B;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAM5E"}
@@ -0,0 +1,33 @@
1
+ export { stripEventDataRefs } from '@workflow/world';
2
+ export function filterRunData(run, resolveData) {
3
+ if (resolveData === 'none') {
4
+ return {
5
+ ...run,
6
+ input: undefined,
7
+ output: undefined,
8
+ };
9
+ }
10
+ return run;
11
+ }
12
+ export function filterStepData(step, resolveData) {
13
+ if (resolveData === 'none') {
14
+ return {
15
+ ...step,
16
+ input: undefined,
17
+ output: undefined,
18
+ };
19
+ }
20
+ return step;
21
+ }
22
+ /**
23
+ * Filter hook data based on resolveData setting.
24
+ * When resolveData is 'none', strips metadata to reduce payload size.
25
+ */
26
+ export function filterHookData(hook, resolveData) {
27
+ if (resolveData === 'none') {
28
+ const { metadata: _metadata, ...rest } = hook;
29
+ return rest;
30
+ }
31
+ return hook;
32
+ }
33
+ //# sourceMappingURL=filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/storage/filters.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAkBrD,MAAM,UAAU,aAAa,CAC3B,GAAgB,EAChB,WAA2B;IAE3B,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO;YACL,GAAG,GAAG;YACN,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;SACQ,CAAC;IAC9B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAeD,MAAM,UAAU,cAAc,CAC5B,IAAU,EACV,WAA2B;IAE3B,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO;YACL,GAAG,IAAI;YACP,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;SACC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,IAAU,EAAE,WAA2B;IACpE,IAAI,WAAW,KAAK,MAAM,EAAE,CAAC;QAC3B,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAW,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type {\n Hook,\n Step,\n StepWithoutData,\n WorkflowRun,\n WorkflowRunWithoutData,\n} from '@workflow/world';\n\nexport { stripEventDataRefs } from '@workflow/world';\n\n/**\n * Filter run data based on resolveData setting.\n * When resolveData is 'none', strips input/output to reduce payload size.\n */\nexport function filterRunData(\n run: WorkflowRun,\n resolveData: 'none'\n): WorkflowRunWithoutData;\nexport function filterRunData(\n run: WorkflowRun,\n resolveData: 'all'\n): WorkflowRun;\nexport function filterRunData(\n run: WorkflowRun,\n resolveData: 'none' | 'all'\n): WorkflowRun | WorkflowRunWithoutData;\nexport function filterRunData(\n run: WorkflowRun,\n resolveData: 'none' | 'all'\n): WorkflowRun | WorkflowRunWithoutData {\n if (resolveData === 'none') {\n return {\n ...run,\n input: undefined,\n output: undefined,\n } as WorkflowRunWithoutData;\n }\n return run;\n}\n\n/**\n * Filter step data based on resolveData setting.\n * When resolveData is 'none', strips input/output to reduce payload size.\n */\nexport function filterStepData(\n step: Step,\n resolveData: 'none'\n): StepWithoutData;\nexport function filterStepData(step: Step, resolveData: 'all'): Step;\nexport function filterStepData(\n step: Step,\n resolveData: 'none' | 'all'\n): Step | StepWithoutData;\nexport function filterStepData(\n step: Step,\n resolveData: 'none' | 'all'\n): Step | StepWithoutData {\n if (resolveData === 'none') {\n return {\n ...step,\n input: undefined,\n output: undefined,\n } as StepWithoutData;\n }\n return step;\n}\n\n/**\n * Filter hook data based on resolveData setting.\n * When resolveData is 'none', strips metadata to reduce payload size.\n */\nexport function filterHookData(hook: Hook, resolveData: 'none' | 'all'): Hook {\n if (resolveData === 'none') {\n const { metadata: _metadata, ...rest } = hook as any;\n return rest;\n }\n return hook;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Hash a hook token to produce a filesystem-safe constraint filename.
3
+ */
4
+ export declare function hashToken(token: string): string;
5
+ /**
6
+ * Create a monotonic ULID factory that ensures ULIDs are always increasing
7
+ * even when generated within the same millisecond.
8
+ */
9
+ export declare const monotonicUlid: import("ulid").ULIDFactory;
10
+ /**
11
+ * Creates a function to extract createdAt date from a filename based on ULID.
12
+ * Used for efficient pagination without reading file contents.
13
+ *
14
+ * @param idPrefix - The prefix to strip from filenames (e.g., 'wrun', 'evnt', 'step')
15
+ * @returns A function that extracts Date from filename, or null if not extractable
16
+ */
17
+ export declare const getObjectCreatedAt: (idPrefix: string) => (filename: string) => Date | null;
18
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/storage/helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,4BAAwC,CAAC;AAEnE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC5B,UAAU,MAAM,MAChB,UAAU,MAAM,KAAG,IAAI,GAAG,IAyB1B,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { monotonicFactory } from 'ulid';
3
+ import { stripTag, ulidToDate } from '../fs.js';
4
+ /**
5
+ * Hash a hook token to produce a filesystem-safe constraint filename.
6
+ */
7
+ export function hashToken(token) {
8
+ return createHash('sha256').update(token).digest('hex');
9
+ }
10
+ /**
11
+ * Create a monotonic ULID factory that ensures ULIDs are always increasing
12
+ * even when generated within the same millisecond.
13
+ */
14
+ export const monotonicUlid = monotonicFactory(() => Math.random());
15
+ /**
16
+ * Creates a function to extract createdAt date from a filename based on ULID.
17
+ * Used for efficient pagination without reading file contents.
18
+ *
19
+ * @param idPrefix - The prefix to strip from filenames (e.g., 'wrun', 'evnt', 'step')
20
+ * @returns A function that extracts Date from filename, or null if not extractable
21
+ */
22
+ export const getObjectCreatedAt = (idPrefix) => (filename) => {
23
+ // Strip tag suffix before ULID extraction
24
+ // e.g., "wrun_ABC.vitest-0.json" → "wrun_ABC.json"
25
+ const cleanName = stripTag(filename.replace(/\.json$/, '')) + '.json';
26
+ const replaceRegex = new RegExp(`^${idPrefix}_`, 'g');
27
+ const dashIndex = cleanName.indexOf('-');
28
+ if (dashIndex === -1) {
29
+ // No dash - extract ULID from the filename (e.g., wrun_ULID.json, evnt_ULID.json)
30
+ const ulid = cleanName.replace(/\.json$/, '').replace(replaceRegex, '');
31
+ return ulidToDate(ulid);
32
+ }
33
+ // For composite keys like {runId}-{stepId}, extract from the appropriate part
34
+ if (idPrefix === 'step') {
35
+ // Steps use sequential IDs (step_0, step_1, etc.) - no timestamp in filename.
36
+ // Return null to skip filename-based optimization and defer to JSON-based filtering.
37
+ return null;
38
+ }
39
+ // For events: wrun_ULID-evnt_ULID.json - extract from the eventId part
40
+ const id = cleanName.substring(dashIndex + 1).replace(/\.json$/, '');
41
+ const ulid = id.replace(replaceRegex, '');
42
+ return ulidToDate(ulid);
43
+ };
44
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/storage/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhD;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,Q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;AAC1B,CAAC,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\nimport { monotonicFactory } from 'ulid';\nimport { stripTag, ulidToDate } from '../fs.js';\n\n/**\n * Hash a hook token to produce a filesystem-safe constraint filename.\n */\nexport function hashToken(token: string): string {\n return createHash('sha256').update(token).digest('hex');\n}\n\n/**\n * Create a monotonic ULID factory that ensures ULIDs are always increasing\n * even when generated within the same millisecond.\n */\nexport const monotonicUlid = monotonicFactory(() => Math.random());\n\n/**\n * Creates a function to extract createdAt date from a filename based on ULID.\n * Used for efficient pagination without reading file contents.\n *\n * @param idPrefix - The prefix to strip from filenames (e.g., 'wrun', 'evnt', 'step')\n * @returns A function that extracts Date from filename, or null if not extractable\n */\nexport const getObjectCreatedAt =\n (idPrefix: string) =>\n (filename: string): Date | null => {\n // Strip tag suffix before ULID extraction\n // e.g., \"wrun_ABC.vitest-0.json\" → \"wrun_ABC.json\"\n const cleanName = stripTag(filename.replace(/\\.json$/, '')) + '.json';\n\n const replaceRegex = new RegExp(`^${idPrefix}_`, 'g');\n const dashIndex = cleanName.indexOf('-');\n\n if (dashIndex === -1) {\n // No dash - extract ULID from the filename (e.g., wrun_ULID.json, evnt_ULID.json)\n const ulid = cleanName.replace(/\\.json$/, '').replace(replaceRegex, '');\n return ulidToDate(ulid);\n }\n\n // For composite keys like {runId}-{stepId}, extract from the appropriate part\n if (idPrefix === 'step') {\n // Steps use sequential IDs (step_0, step_1, etc.) - no timestamp in filename.\n // Return null to skip filename-based optimization and defer to JSON-based filtering.\n return null;\n }\n\n // For events: wrun_ULID-evnt_ULID.json - extract from the eventId part\n const id = cleanName.substring(dashIndex + 1).replace(/\\.json$/, '');\n const ulid = id.replace(replaceRegex, '');\n return ulidToDate(ulid);\n };\n"]}
@@ -0,0 +1,12 @@
1
+ import type { Storage } from '@workflow/world';
2
+ /**
3
+ * Creates a hooks storage implementation using the filesystem.
4
+ * Implements the Storage['hooks'] interface with hook CRUD operations.
5
+ */
6
+ export declare function createHooksStorage(basedir: string, tag?: string): Storage['hooks'];
7
+ /**
8
+ * Helper function to delete all hooks associated with a workflow run.
9
+ * Called when a run reaches a terminal state.
10
+ */
11
+ export declare function deleteAllHooksForRun(basedir: string, runId: string): Promise<void>;
12
+ //# sourceMappingURL=hooks-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks-storage.d.ts","sourceRoot":"","sources":["../../src/storage/hooks-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,OAAO,EACR,MAAM,iBAAiB,CAAC;AAczB;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAiFlB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAkBf"}
@@ -0,0 +1,93 @@
1
+ import path from 'node:path';
2
+ import { HookNotFoundError } from '@workflow/errors';
3
+ import { HookSchema } from '@workflow/world';
4
+ import { DEFAULT_RESOLVE_DATA_OPTION } from '../config.js';
5
+ import { assertSafeEntityId, deleteJSON, listJSONFiles, paginatedFileSystemQuery, readJSON, readJSONWithFallback, } from '../fs.js';
6
+ import { filterHookData } from './filters.js';
7
+ import { hashToken } from './helpers.js';
8
+ /**
9
+ * Creates a hooks storage implementation using the filesystem.
10
+ * Implements the Storage['hooks'] interface with hook CRUD operations.
11
+ */
12
+ export function createHooksStorage(basedir, tag) {
13
+ // Helper function to find a hook by token (shared between getByToken)
14
+ async function findHookByToken(token) {
15
+ const hooksDir = path.join(basedir, 'hooks');
16
+ const files = await listJSONFiles(hooksDir);
17
+ for (const file of files) {
18
+ const hookPath = path.join(hooksDir, `${file}.json`);
19
+ const hook = await readJSON(hookPath, HookSchema);
20
+ if (hook && hook.token === token) {
21
+ return { ...hook, isWebhook: hook.isWebhook ?? true };
22
+ }
23
+ }
24
+ return null;
25
+ }
26
+ async function get(hookId, params) {
27
+ assertSafeEntityId('hookId', hookId);
28
+ const hook = await readJSONWithFallback(basedir, 'hooks', hookId, HookSchema, tag);
29
+ if (!hook) {
30
+ throw new HookNotFoundError(hookId);
31
+ }
32
+ const resolveData = params?.resolveData || DEFAULT_RESOLVE_DATA_OPTION;
33
+ return filterHookData({ ...hook, isWebhook: hook.isWebhook ?? true }, resolveData);
34
+ }
35
+ async function getByToken(token) {
36
+ const hook = await findHookByToken(token);
37
+ if (!hook) {
38
+ throw new HookNotFoundError(token);
39
+ }
40
+ return hook;
41
+ }
42
+ async function list(params) {
43
+ const hooksDir = path.join(basedir, 'hooks');
44
+ const resolveData = params.resolveData || DEFAULT_RESOLVE_DATA_OPTION;
45
+ const result = await paginatedFileSystemQuery({
46
+ directory: hooksDir,
47
+ schema: HookSchema,
48
+ sortOrder: params.pagination?.sortOrder ?? 'asc',
49
+ limit: params.pagination?.limit,
50
+ cursor: params.pagination?.cursor,
51
+ filePrefix: undefined, // Hooks don't have ULIDs, so we can't optimize by filename
52
+ filter: (hook) => {
53
+ // Filter by runId if provided
54
+ if (params.runId && hook.runId !== params.runId) {
55
+ return false;
56
+ }
57
+ return true;
58
+ },
59
+ getCreatedAt: () => {
60
+ // Hook files don't have ULID timestamps in filename, so return null
61
+ // to skip the filename-based optimization and defer to JSON-based
62
+ // cursor filtering which uses the actual createdAt from the file.
63
+ return null;
64
+ },
65
+ getId: (hook) => hook.hookId,
66
+ });
67
+ // Transform the data after pagination
68
+ return {
69
+ ...result,
70
+ data: result.data.map((hook) => filterHookData(hook, resolveData)),
71
+ };
72
+ }
73
+ return { get, getByToken, list };
74
+ }
75
+ /**
76
+ * Helper function to delete all hooks associated with a workflow run.
77
+ * Called when a run reaches a terminal state.
78
+ */
79
+ export async function deleteAllHooksForRun(basedir, runId) {
80
+ const hooksDir = path.join(basedir, 'hooks');
81
+ const files = await listJSONFiles(hooksDir);
82
+ for (const file of files) {
83
+ const hookPath = path.join(hooksDir, `${file}.json`);
84
+ const hook = await readJSON(hookPath, HookSchema);
85
+ if (hook && hook.runId === runId) {
86
+ // Delete the token constraint file to free up the token
87
+ const constraintPath = path.join(hooksDir, 'tokens', `${hashToken(hook.token)}.json`);
88
+ await deleteJSON(constraintPath);
89
+ await deleteJSON(hookPath);
90
+ }
91
+ }
92
+ }
93
+ //# sourceMappingURL=hooks-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks-storage.js","sourceRoot":"","sources":["../../src/storage/hooks-storage.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,QAAQ,EACR,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,GAAY;IAEZ,sEAAsE;IACtE,KAAK,UAAU,eAAe,CAAC,KAAa;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7C,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,CAAC,CAAC;QAE5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,OAAO,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;YAClD,IAAI,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AM,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC;YACjC,wDAAwD;YACxD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC9B,QAAQ,EACR,QAAQ,EACR,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAChC,CAAC;YACF,MAAM,UAAU,CAAC,cAAc,CAAC,CAAC;YACjC,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import path from 'node:path';\nimport { HookNotFoundError } from '@workflow/errors';\nimport type {\n GetHookParams,\n Hook,\n ListHooksParams,\n PaginatedResponse,\n Storage,\n} from '@workflow/world';\nimport { HookSchema } from '@workflow/world';\nimport { DEFAULT_RESOLVE_DATA_OPTION } from '../config.js';\nimport {\n assertSafeEntityId,\n deleteJSON,\n listJSONFiles,\n paginatedFileSystemQuery,\n readJSON,\n readJSONWithFallback,\n} from '../fs.js';\nimport { filterHookData } from './filters.js';\nimport { hashToken } from './helpers.js';\n\n/**\n * Creates a hooks storage implementation using the filesystem.\n * Implements the Storage['hooks'] interface with hook CRUD operations.\n */\nexport function createHooksStorage(\n basedir: string,\n tag?: string\n): Storage['hooks'] {\n // Helper function to find a hook by token (shared between getByToken)\n async function findHookByToken(token: string): Promise<Hook | null> {\n const hooksDir = path.join(basedir, 'hooks');\n const files = await listJSONFiles(hooksDir);\n\n for (const file of files) {\n const hookPath = path.join(hooksDir, `${file}.json`);\n const hook = await readJSON(hookPath, HookSchema);\n if (hook && hook.token === token) {\n return { ...hook, isWebhook: hook.isWebhook ?? true };\n }\n }\n\n return null;\n }\n\n async function get(hookId: string, params?: GetHookParams): Promise<Hook> {\n assertSafeEntityId('hookId', hookId);\n const hook = await readJSONWithFallback(\n basedir,\n 'hooks',\n hookId,\n HookSchema,\n tag\n );\n if (!hook) {\n throw new HookNotFoundError(hookId);\n }\n const resolveData = params?.resolveData || DEFAULT_RESOLVE_DATA_OPTION;\n return filterHookData(\n { ...hook, isWebhook: hook.isWebhook ?? true },\n resolveData\n );\n }\n\n async function getByToken(token: string): Promise<Hook> {\n const hook = await findHookByToken(token);\n if (!hook) {\n throw new HookNotFoundError(token);\n }\n return hook;\n }\n\n async function list(\n params: ListHooksParams\n ): Promise<PaginatedResponse<Hook>> {\n const hooksDir = path.join(basedir, 'hooks');\n const resolveData = params.resolveData || DEFAULT_RESOLVE_DATA_OPTION;\n\n const result = await paginatedFileSystemQuery({\n directory: hooksDir,\n schema: HookSchema,\n sortOrder: params.pagination?.sortOrder ?? 'asc',\n limit: params.pagination?.limit,\n cursor: params.pagination?.cursor,\n filePrefix: undefined, // Hooks don't have ULIDs, so we can't optimize by filename\n filter: (hook) => {\n // Filter by runId if provided\n if (params.runId && hook.runId !== params.runId) {\n return false;\n }\n return true;\n },\n getCreatedAt: () => {\n // Hook files don't have ULID timestamps in filename, so return null\n // to skip the filename-based optimization and defer to JSON-based\n // cursor filtering which uses the actual createdAt from the file.\n return null;\n },\n getId: (hook) => hook.hookId,\n });\n\n // Transform the data after pagination\n return {\n ...result,\n data: result.data.map((hook) => filterHookData(hook, resolveData)),\n };\n }\n\n return { get, getByToken, list };\n}\n\n/**\n * Helper function to delete all hooks associated with a workflow run.\n * Called when a run reaches a terminal state.\n */\nexport async function deleteAllHooksForRun(\n basedir: string,\n runId: string\n): Promise<void> {\n const hooksDir = path.join(basedir, 'hooks');\n const files = await listJSONFiles(hooksDir);\n\n for (const file of files) {\n const hookPath = path.join(hooksDir, `${file}.json`);\n const hook = await readJSON(hookPath, HookSchema);\n if (hook && hook.runId === runId) {\n // Delete the token constraint file to free up the token\n const constraintPath = path.join(\n hooksDir,\n 'tokens',\n `${hashToken(hook.token)}.json`\n );\n await deleteJSON(constraintPath);\n await deleteJSON(hookPath);\n }\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import type { Storage } from '@workflow/world';
2
+ /**
3
+ * Creates a complete storage implementation using the filesystem.
4
+ * This is the main entry point that composes all storage implementations.
5
+ *
6
+ * All storage methods are instrumented with tracing spans for observability.
7
+ *
8
+ * @param basedir - The base directory for storing workflow data
9
+ * @returns A complete Storage implementation with tracing
10
+ */
11
+ export declare function createStorage(basedir: string, tag?: string): Storage;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAO/C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAiBpE"}
@@ -0,0 +1,32 @@
1
+ import { instrumentObject } from '../instrumentObject.js';
2
+ import { createEventsStorage } from './events-storage.js';
3
+ import { createHooksStorage } from './hooks-storage.js';
4
+ import { createRunsStorage } from './runs-storage.js';
5
+ import { createStepsStorage } from './steps-storage.js';
6
+ /**
7
+ * Creates a complete storage implementation using the filesystem.
8
+ * This is the main entry point that composes all storage implementations.
9
+ *
10
+ * All storage methods are instrumented with tracing spans for observability.
11
+ *
12
+ * @param basedir - The base directory for storing workflow data
13
+ * @returns A complete Storage implementation with tracing
14
+ */
15
+ export function createStorage(basedir, tag) {
16
+ // Create raw storage implementations
17
+ const storage = {
18
+ runs: createRunsStorage(basedir, tag),
19
+ steps: createStepsStorage(basedir, tag),
20
+ events: createEventsStorage(basedir, tag),
21
+ hooks: createHooksStorage(basedir, tag),
22
+ };
23
+ // Instrument all storage methods with tracing
24
+ // NOTE: Span names are lowercase per OTEL semantic conventions
25
+ return {
26
+ runs: instrumentObject('world.runs', storage.runs),
27
+ steps: instrumentObject('world.steps', storage.steps),
28
+ events: instrumentObject('world.events', storage.events),
29
+ hooks: instrumentObject('world.hooks', storage.hooks),
30
+ };
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,GAAY;IACzD,qCAAqC;IACrC,MAAM,OAAO,GAAY;QACvB,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC;QACrC,KAAK,EAAE,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC;QACvC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC;QACzC,KAAK,EAAE,kBAAkB,CAAC,OAAO,EAAE,GAAG,CAAC;KACxC,CAAC;IAEF,8CAA8C;IAC9C,+DAA+D;IAC/D,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC;QAClD,KAAK,EAAE,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC;QACrD,MAAM,EAAE,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC;QACxD,KAAK,EAAE,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC;KACtD,CAAC;AACJ,CAAC","sourcesContent":["import type { Storage } from '@workflow/world';\nimport { instrumentObject } from '../instrumentObject.js';\nimport { createEventsStorage } from './events-storage.js';\nimport { createHooksStorage } from './hooks-storage.js';\nimport { createRunsStorage } from './runs-storage.js';\nimport { createStepsStorage } from './steps-storage.js';\n\n/**\n * Creates a complete storage implementation using the filesystem.\n * This is the main entry point that composes all storage implementations.\n *\n * All storage methods are instrumented with tracing spans for observability.\n *\n * @param basedir - The base directory for storing workflow data\n * @returns A complete Storage implementation with tracing\n */\nexport function createStorage(basedir: string, tag?: string): Storage {\n // Create raw storage implementations\n const storage: Storage = {\n runs: createRunsStorage(basedir, tag),\n steps: createStepsStorage(basedir, tag),\n events: createEventsStorage(basedir, tag),\n hooks: createHooksStorage(basedir, tag),\n };\n\n // Instrument all storage methods with tracing\n // NOTE: Span names are lowercase per OTEL semantic conventions\n return {\n runs: instrumentObject('world.runs', storage.runs),\n steps: instrumentObject('world.steps', storage.steps),\n events: instrumentObject('world.events', storage.events),\n hooks: instrumentObject('world.hooks', storage.hooks),\n };\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { EventResult, WorkflowRun } from '@workflow/world';
2
+ /**
3
+ * Handle events for legacy runs (pre-event-sourcing, specVersion < 2).
4
+ * Legacy runs use different behavior:
5
+ * - run_cancelled: Skip event storage, directly update run
6
+ * - wait_completed: Store event only (no entity mutation)
7
+ * - hook_received: Store event only (hooks exist via old system, no entity mutation)
8
+ * - Other events: Throw error (not supported for legacy runs)
9
+ */
10
+ export declare function handleLegacyEvent(basedir: string, runId: string, data: any, currentRun: WorkflowRun, params?: {
11
+ resolveData?: 'none' | 'all';
12
+ }): Promise<EventResult>;
13
+ //# sourceMappingURL=legacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.d.ts","sourceRoot":"","sources":["../../src/storage/legacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQvE;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,GAAG,EACT,UAAU,EAAE,WAAW,EACvB,MAAM,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,GACxC,OAAO,CAAC,WAAW,CAAC,CAuEtB"}
@@ -0,0 +1,77 @@
1
+ import { SPEC_VERSION_CURRENT } from '@workflow/world';
2
+ import { DEFAULT_RESOLVE_DATA_OPTION } from '../config.js';
3
+ import { assertSafeEntityId, resolveWithinBase, writeJSON } from '../fs.js';
4
+ import { filterRunData, stripEventDataRefs } from './filters.js';
5
+ import { monotonicUlid } from './helpers.js';
6
+ import { deleteAllHooksForRun } from './hooks-storage.js';
7
+ /**
8
+ * Handle events for legacy runs (pre-event-sourcing, specVersion < 2).
9
+ * Legacy runs use different behavior:
10
+ * - run_cancelled: Skip event storage, directly update run
11
+ * - wait_completed: Store event only (no entity mutation)
12
+ * - hook_received: Store event only (hooks exist via old system, no entity mutation)
13
+ * - Other events: Throw error (not supported for legacy runs)
14
+ */
15
+ export async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
16
+ // Defense in depth: events.create already validates runId before routing
17
+ // here, but handleLegacyEvent is exported and its signature doesn't
18
+ // document that invariant. Validating locally keeps the guarantee in this
19
+ // file.
20
+ assertSafeEntityId('runId', runId);
21
+ const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
22
+ switch (data.eventType) {
23
+ case 'run_cancelled': {
24
+ // Legacy: Skip event storage, directly update run to cancelled
25
+ const now = new Date();
26
+ const run = {
27
+ runId: currentRun.runId,
28
+ deploymentId: currentRun.deploymentId,
29
+ workflowName: currentRun.workflowName,
30
+ specVersion: currentRun.specVersion,
31
+ executionContext: currentRun.executionContext,
32
+ input: currentRun.input,
33
+ createdAt: currentRun.createdAt,
34
+ expiredAt: currentRun.expiredAt,
35
+ startedAt: currentRun.startedAt,
36
+ status: 'cancelled',
37
+ output: undefined,
38
+ error: undefined,
39
+ completedAt: now,
40
+ updatedAt: now,
41
+ };
42
+ const runPath = resolveWithinBase(basedir, 'runs', `${runId}.json`);
43
+ await writeJSON(runPath, run, { overwrite: true });
44
+ await deleteAllHooksForRun(basedir, runId);
45
+ // Return without event (legacy behavior skips event storage)
46
+ // Type assertion: EventResult expects WorkflowRun, filterRunData may return WorkflowRunWithoutData
47
+ return {
48
+ event: undefined,
49
+ run: filterRunData(run, resolveData),
50
+ };
51
+ }
52
+ case 'wait_completed':
53
+ case 'hook_received': {
54
+ // Legacy: Store event only (no entity mutation)
55
+ // - wait_completed: for replay purposes
56
+ // - hook_received: hooks exist via old system, just record the event
57
+ const eventId = `evnt_${monotonicUlid()}`;
58
+ const now = new Date();
59
+ const event = {
60
+ ...data,
61
+ runId,
62
+ eventId,
63
+ createdAt: now,
64
+ specVersion: SPEC_VERSION_CURRENT,
65
+ };
66
+ const compositeKey = `${runId}-${eventId}`;
67
+ const eventPath = resolveWithinBase(basedir, 'events', `${compositeKey}.json`);
68
+ await writeJSON(eventPath, event);
69
+ return { event: stripEventDataRefs(event, resolveData) };
70
+ }
71
+ default:
72
+ throw new Error(`Event type '${data.eventType}' not supported for legacy runs ` +
73
+ `(specVersion: ${currentRun.specVersion || 'undefined'}). ` +
74
+ `Please upgrade 'workflow' package.`);
75
+ }
76
+ }
77
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sourceRoot":"","sources":["../../src/storage/legacy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAe,EACf,KAAa,EACb,IAAS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AAC;QAED,KAAK,gBAAgB,CAAC;QACtB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,gDAAgD;YAChD,wCAAwC;YACxC,qEAAqE;YACrE,MAAM,OAAO,GAAG,QAAQ,aAAa,EAAE,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,KAAK,GAAU;gBACnB,GAAG,IAAI;gBACP,KAAK;gBACL,OAAO;gBACP,SAAS,EAAE,GAAG;gBACd,WAAW,EAAE,oBAAoB;aAClC,CAAC;YACF,MAAM,YAAY,GAAG,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC;YAC3C,MAAM,SAAS,GAAG,iBAAiB,CACjC,OAAO,EACP,QAAQ,EACR,GAAG,YAAY,OAAO,CACvB,CAAC;YACF,MAAM,SAAS,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAClC,OAAO,EAAE,KAAK,EAAE,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC;QAC3D,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,CAAC,SAAS,kCAAkC;gBAC7D,iBAAiB,UAAU,CAAC,WAAW,IAAI,WAAW,KAAK;gBAC3D,oCAAoC,CACvC,CAAC;IACN,CAAC;AACH,CAAC","sourcesContent":["import type { Event, EventResult, WorkflowRun } from '@workflow/world';\nimport { SPEC_VERSION_CURRENT } from '@workflow/world';\nimport { DEFAULT_RESOLVE_DATA_OPTION } from '../config.js';\nimport { assertSafeEntityId, resolveWithinBase, writeJSON } from '../fs.js';\nimport { filterRunData, stripEventDataRefs } from './filters.js';\nimport { monotonicUlid } from './helpers.js';\nimport { deleteAllHooksForRun } from './hooks-storage.js';\n\n/**\n * Handle events for legacy runs (pre-event-sourcing, specVersion < 2).\n * Legacy runs use different behavior:\n * - run_cancelled: Skip event storage, directly update run\n * - wait_completed: Store event only (no entity mutation)\n * - hook_received: Store event only (hooks exist via old system, no entity mutation)\n * - Other events: Throw error (not supported for legacy runs)\n */\nexport async function handleLegacyEvent(\n basedir: string,\n runId: string,\n data: any,\n currentRun: WorkflowRun,\n params?: { resolveData?: 'none' | 'all' }\n): Promise<EventResult> {\n // Defense in depth: events.create already validates runId before routing\n // here, but handleLegacyEvent is exported and its signature doesn't\n // document that invariant. Validating locally keeps the guarantee in this\n // file.\n assertSafeEntityId('runId', runId);\n\n const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;\n\n switch (data.eventType) {\n case 'run_cancelled': {\n // Legacy: Skip event storage, directly update run to cancelled\n const now = new Date();\n const run: WorkflowRun = {\n runId: currentRun.runId,\n deploymentId: currentRun.deploymentId,\n workflowName: currentRun.workflowName,\n specVersion: currentRun.specVersion,\n executionContext: currentRun.executionContext,\n input: currentRun.input,\n createdAt: currentRun.createdAt,\n expiredAt: currentRun.expiredAt,\n startedAt: currentRun.startedAt,\n status: 'cancelled',\n output: undefined,\n error: undefined,\n completedAt: now,\n updatedAt: now,\n };\n const runPath = resolveWithinBase(basedir, 'runs', `${runId}.json`);\n await writeJSON(runPath, run, { overwrite: true });\n await deleteAllHooksForRun(basedir, runId);\n // Return without event (legacy behavior skips event storage)\n // Type assertion: EventResult expects WorkflowRun, filterRunData may return WorkflowRunWithoutData\n return {\n event: undefined,\n run: filterRunData(run, resolveData) as WorkflowRun,\n };\n }\n\n case 'wait_completed':\n case 'hook_received': {\n // Legacy: Store event only (no entity mutation)\n // - wait_completed: for replay purposes\n // - hook_received: hooks exist via old system, just record the event\n const eventId = `evnt_${monotonicUlid()}`;\n const now = new Date();\n const event: Event = {\n ...data,\n runId,\n eventId,\n createdAt: now,\n specVersion: SPEC_VERSION_CURRENT,\n };\n const compositeKey = `${runId}-${eventId}`;\n const eventPath = resolveWithinBase(\n basedir,\n 'events',\n `${compositeKey}.json`\n );\n await writeJSON(eventPath, event);\n return { event: stripEventDataRefs(event, resolveData) };\n }\n\n default:\n throw new Error(\n `Event type '${data.eventType}' not supported for legacy runs ` +\n `(specVersion: ${currentRun.specVersion || 'undefined'}). ` +\n `Please upgrade 'workflow' package.`\n );\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Storage } from '@workflow/world';
2
+ /**
3
+ * Creates the runs storage implementation using the filesystem.
4
+ * Implements the Storage['runs'] interface with get and list operations.
5
+ */
6
+ export declare function createRunsStorage(basedir: string, tag?: string): Storage['runs'];
7
+ //# sourceMappingURL=runs-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs-storage.d.ts","sourceRoot":"","sources":["../../src/storage/runs-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,iBAAiB,CAAC;AAWvE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CAyDjB"}