unfazed 0.5.0 → 0.6.1

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 (92) hide show
  1. package/README.md +399 -6
  2. package/dist/cli/login.d.ts +129 -0
  3. package/dist/cli/login.js +596 -0
  4. package/dist/cli/login.js.map +1 -0
  5. package/dist/cli/workflow.d.ts +31 -0
  6. package/dist/cli/workflow.js +157 -0
  7. package/dist/cli/workflow.js.map +1 -0
  8. package/dist/cli.d.ts +2 -0
  9. package/dist/cli.js +173 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/client.d.ts +26 -5
  12. package/dist/client.js +93 -48
  13. package/dist/client.js.map +1 -1
  14. package/dist/credentials.d.ts +123 -0
  15. package/dist/credentials.js +317 -0
  16. package/dist/credentials.js.map +1 -0
  17. package/dist/errors.d.ts +25 -0
  18. package/dist/errors.js +25 -0
  19. package/dist/errors.js.map +1 -1
  20. package/dist/index.d.ts +32 -1
  21. package/dist/index.js +32 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/remote/app.d.ts +18 -0
  24. package/dist/remote/app.js +77 -0
  25. package/dist/remote/app.js.map +1 -0
  26. package/dist/remote/documents.d.ts +175 -0
  27. package/dist/remote/documents.js +122 -0
  28. package/dist/remote/documents.js.map +1 -0
  29. package/dist/remote/values.d.ts +67 -0
  30. package/dist/remote/values.js +156 -0
  31. package/dist/remote/values.js.map +1 -0
  32. package/dist/remote/world.d.ts +50 -0
  33. package/dist/remote/world.js +628 -0
  34. package/dist/remote/world.js.map +1 -0
  35. package/dist/unfazed.d.ts +1 -1
  36. package/dist/unfazed.js +1 -1
  37. package/dist/unfazed.js.map +1 -1
  38. package/dist/workflow/config.d.ts +23 -0
  39. package/dist/workflow/config.js +48 -0
  40. package/dist/workflow/config.js.map +1 -0
  41. package/dist/workflow/errors.d.ts +33 -0
  42. package/dist/workflow/errors.js +16 -0
  43. package/dist/workflow/errors.js.map +1 -0
  44. package/dist/workflow/index.d.ts +30 -0
  45. package/dist/workflow/index.js +23 -0
  46. package/dist/workflow/index.js.map +1 -0
  47. package/dist/workflow/inspect-render.d.ts +93 -0
  48. package/dist/workflow/inspect-render.js +302 -0
  49. package/dist/workflow/inspect-render.js.map +1 -0
  50. package/dist/workflow/inspect.d.ts +52 -0
  51. package/dist/workflow/inspect.js +879 -0
  52. package/dist/workflow/inspect.js.map +1 -0
  53. package/dist/workflow/migration-files.d.ts +13 -0
  54. package/dist/workflow/migration-files.js +52 -0
  55. package/dist/workflow/migration-files.js.map +1 -0
  56. package/dist/workflow/migration-types.d.ts +19 -0
  57. package/dist/workflow/migration-types.js +8 -0
  58. package/dist/workflow/migration-types.js.map +1 -0
  59. package/dist/workflow/migrations.d.ts +12 -0
  60. package/dist/workflow/migrations.generated.d.ts +2 -0
  61. package/dist/workflow/migrations.generated.js +34 -0
  62. package/dist/workflow/migrations.generated.js.map +1 -0
  63. package/dist/workflow/migrations.js +94 -0
  64. package/dist/workflow/migrations.js.map +1 -0
  65. package/dist/workflow/nitro-flow-guard.d.ts +4 -0
  66. package/dist/workflow/nitro-flow-guard.js +19 -0
  67. package/dist/workflow/nitro-flow-guard.js.map +1 -0
  68. package/dist/workflow/nitro-inspect.d.ts +3 -0
  69. package/dist/workflow/nitro-inspect.js +19 -0
  70. package/dist/workflow/nitro-inspect.js.map +1 -0
  71. package/dist/workflow/nitro-plugin.d.ts +1 -0
  72. package/dist/workflow/nitro-plugin.js +13 -0
  73. package/dist/workflow/nitro-plugin.js.map +1 -0
  74. package/dist/workflow/nitro.d.ts +70 -0
  75. package/dist/workflow/nitro.js +213 -0
  76. package/dist/workflow/nitro.js.map +1 -0
  77. package/dist/workflow/public-url.d.ts +27 -0
  78. package/dist/workflow/public-url.js +45 -0
  79. package/dist/workflow/public-url.js.map +1 -0
  80. package/dist/workflow/queue.d.ts +128 -0
  81. package/dist/workflow/queue.js +375 -0
  82. package/dist/workflow/queue.js.map +1 -0
  83. package/dist/workflow/state.d.ts +25 -0
  84. package/dist/workflow/state.js +15 -0
  85. package/dist/workflow/state.js.map +1 -0
  86. package/dist/workflow/transport.d.ts +12 -0
  87. package/dist/workflow/transport.js +29 -0
  88. package/dist/workflow/transport.js.map +1 -0
  89. package/dist/workflow/world.d.ts +123 -0
  90. package/dist/workflow/world.js +375 -0
  91. package/dist/workflow/world.js.map +1 -0
  92. package/package.json +79 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/workflow/inspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAEL,qBAAqB,EAErB,2BAA2B,EAE3B,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACjI,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,WAAW,EAGX,OAAO,EACP,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE1E,iHAAiH;AACjH,MAAM,CAAC,MAAM,iBAAiB,GAAG,6CAA6C,CAAC;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAyB1C,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,CAAC;AACnC,4EAA4E;AAC5E,MAAM,iBAAiB,GAAG,GAAG,GAAG,IAAI,CAAC;AACrC,MAAM,cAAc,GAAG,EAAE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AAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,6CAA6C;QACnE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;YACpD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACpC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,EAAE,CAAC;gBACtC,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,2BAA2B,cAAc,QAAQ,CAAC,CAAC;YAC3F,CAAC;YACD,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;QACxE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,cAAc;gBAAE,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACnG,OAAO,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACzD,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * The workflow inspection route: what the unfazed dashboard and MCP read runs,\n * steps, events and streams through, and wake or cancel a run with (guest\n * contract v1, unfazed docs/workflow-inspect.md).\n *\n * Everything is read through the app's own World (`getWorld()`), so it works\n * on a cold start and holds no database connection after the request; actions\n * go through the SDK's own `getRun(id).wakeUp()` / `.cancel()`. Payloads are\n * hydrated with `workflow/observability`. Only the platform calls it: it\n * answers 401 to anything without `X-Unfz-Queue-Token` equal to\n * `UNFZ_STATE_TOKEN`, and public ingress strips that header.\n */\nimport { Buffer } from \"node:buffer\";\nimport {\n type Event,\n getEventDataRefFields,\n type Hook,\n isTerminalWorkflowRunStatus,\n type Step,\n stripEventDataRefs,\n type World,\n type WorkflowRun,\n} from \"@workflow/world\";\nimport { hydrateData, hydrateResourceIO, observabilityRevivers, parseStepName, parseWorkflowName } from \"workflow/observability\";\nimport { VERSION } from \"../client.js\";\nimport { envValue, type WorkflowEnv } from \"./config.js\";\nimport {\n cutUtf8,\n displayText,\n eventInfo,\n failedValue,\n type InspectError,\n type InspectValue,\n isoTime,\n redactWebhookTokens,\n renderError,\n renderValue,\n stepInputDisplay,\n utf8Length,\n} from \"./inspect-render.js\";\nimport { DELIVERY_HEADERS, describe, verifyQueueToken } from \"./queue.js\";\n\n/** Where `unfazed/workflow/nitro` mounts the route; other frameworks mount {@link createInspectHandler} here. */\nexport const INSPECT_BASE_PATH = \"/.well-known/workflow/v1/unfazed/inspect/v1\";\nexport const INSPECT_CONTRACT_VERSION = 1;\n\n/** The slice of Workflow SDK's `Run` the actions use (`getRun(id)` from `workflow/api`). */\nexport interface InspectRunHandle {\n wakeUp(options?: { correlationIds?: string[] }): Promise<{ stoppedCount: number }>;\n cancel(options?: { cancelReason?: string }): Promise<void>;\n}\n\nexport interface InspectHandlerOptions {\n /** The World to read. Default: Workflow SDK's `getWorld()`, the World installed with `setWorld()`. */\n getWorld?: () => World | Promise<World>;\n /** Default: Workflow SDK's `getRun()` (`workflow/api`). */\n getRun?: (runId: string) => InspectRunHandle;\n /** The token the platform sends. Default: `UNFZ_STATE_TOKEN`, read per request. */\n stateToken?: string;\n /** Where `UNFZ_STATE_TOKEN` is read from. Default: `process.env`. */\n env?: WorkflowEnv;\n /** The build's workflow machine names (`workflow//./src/x//name`), for `info`. Default: none. */\n workflows?: readonly string[];\n /** The Workflow SDK version the app was built with, for `info`. Default: `\"unknown\"`. */\n workflowVersion?: string;\n /** How long a request may take before it answers with an error. Default 19 s (the contract allows 20). */\n timeoutMs?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Limits of the contract.\n// ---------------------------------------------------------------------------\n\nconst MAX_BODY_BYTES = 1024 * 1024;\n/** Lists shrink their page (fewer items, `has_more`) to stay under this. */\nconst PAGE_BUDGET_BYTES = 900 * 1024;\nconst MAX_POST_BYTES = 16 * 1024;\nconst MAX_ERROR_MESSAGE_BYTES = 1024;\nconst IO_CAP_BYTES = 16 * 1024;\nconst EVENT_DATA_CAP_BYTES = 64 * 1024;\nconst CHUNK_TEXT_CAP_BYTES = 8 * 1024;\nconst RUN_PAGE_STEPS = 200;\nconst RUN_PAGE_MAX_EVENTS = 10_000;\nconst RUN_PAGE_MAX_STREAMS = 50;\nconst RUN_PAGE_STREAM_INFOS = 20;\n/** A run page keeps the latest 500 waits and hooks; `waits_truncated` / `hooks_truncated` say when there were more. */\nconst RUN_PAGE_MAX_WAITS = 500;\nconst RUN_PAGE_MAX_HOOKS = 500;\nconst STEP_PAGE_EVENTS = 200;\nconst EVENTS_PAGE_SIZE = 500;\nconst RUN_STATUSES = [\"pending\", \"running\", \"completed\", \"failed\", \"cancelled\"] as const;\n\nconst ID_PATTERN = /^[A-Za-z0-9_.:-]{1,256}$/;\nconst CURSOR_PATTERN = /^[\\x21-\\x7e]{1,1024}$/;\n// biome-ignore lint/suspicious/noControlCharactersInRegex: the contract refuses control characters\nconst CONTROL_CHARACTERS = /[\\u0000-\\u001f\\u007f-\\u009f]/;\n\n// ---------------------------------------------------------------------------\n// Errors and responses.\n// ---------------------------------------------------------------------------\n\ntype ErrorCode =\n | \"invalid_request\"\n | \"unauthorized\"\n | \"not_found\"\n | \"method_not_allowed\"\n | \"run_terminal\"\n | \"internal\"\n | \"world_unavailable\";\n\nclass InspectFailure extends Error {\n constructor(\n readonly status: number,\n readonly code: ErrorCode,\n message: string,\n ) {\n super(message);\n }\n}\n\nconst invalid = (message: string) => new InspectFailure(400, \"invalid_request\", message);\nconst notFound = (message: string) => new InspectFailure(404, \"not_found\", message);\n\nconst RESPONSE_HEADERS = { \"content-type\": \"application/json\", \"cache-control\": \"no-store\" } as const;\n\nfunction respond(status: number, body: unknown, headers: Record<string, string> = {}): Response {\n return new Response(JSON.stringify(body), { status, headers: { ...RESPONSE_HEADERS, ...headers } });\n}\n\nfunction errorResponse(status: number, code: ErrorCode, message: string, headers?: Record<string, string>): Response {\n return respond(status, { error: code, message: cutUtf8(redactWebhookTokens(message), MAX_ERROR_MESSAGE_BYTES).text }, headers);\n}\n\n// ---------------------------------------------------------------------------\n// Request parsing and validation.\n// ---------------------------------------------------------------------------\n\ntype Params = Record<string, string>;\ntype Rule = (value: string, name: string) => void;\n\nconst idRule: Rule = (value, name) => {\n if (!ID_PATTERN.test(value)) throw invalid(`${name} must be 1 to 256 bytes of [A-Za-z0-9_.:-]`);\n};\nconst textRule: Rule = (value, name) => {\n const bytes = utf8Length(value);\n if (bytes < 1 || bytes > 1024 || CONTROL_CHARACTERS.test(value)) {\n throw invalid(`${name} must be 1 to 1024 bytes of UTF-8 without control characters`);\n }\n};\nconst cursorRule: Rule = (value, name) => {\n if (!CURSOR_PATTERN.test(value)) throw invalid(`${name} must be 1 to 1024 bytes of visible ASCII`);\n};\nconst limitRule =\n (max: number): Rule =>\n (value, name) => {\n if (!/^\\d{1,6}$/.test(value) || Number(value) < 1 || Number(value) > max) {\n throw invalid(`${name} must be a decimal integer from 1 to ${max}`);\n }\n };\nconst statusRule: Rule = (value, name) => {\n for (const word of value.split(\",\")) {\n if (!(RUN_STATUSES as readonly string[]).includes(word)) {\n throw invalid(`${name} must be a comma-separated subset of ${RUN_STATUSES.join(\", \")}`);\n }\n }\n};\nconst orderRule: Rule = (value, name) => {\n if (value !== \"asc\" && value !== \"desc\") throw invalid(`${name} must be asc or desc`);\n};\n\n/** The query, refusing unknown, repeated and missing parameters. */\nfunction parseQuery(url: URL, rules: Record<string, Rule>, required: readonly string[]): Params {\n const params: Params = {};\n for (const [name, value] of url.searchParams) {\n const rule = rules[name];\n if (!rule) throw invalid(`unknown parameter ${JSON.stringify(name)}`);\n if (name in params) throw invalid(`parameter ${name} is repeated`);\n rule(value, name);\n params[name] = value;\n }\n for (const name of required) if (!(name in params)) throw invalid(`missing parameter ${name}`);\n return params;\n}\n\nasync function readBody(req: Request): Promise<Record<string, unknown>> {\n const type = req.headers.get(\"content-type\") ?? \"\";\n if (!/^application\\/json\\s*(;|$)/i.test(type)) throw invalid(\"the body must be application/json\");\n const declared = Number(req.headers.get(\"content-length\") ?? \"0\");\n if (declared > MAX_POST_BYTES) throw invalid(`the body may be at most ${MAX_POST_BYTES} bytes`);\n const chunks: Uint8Array[] = [];\n let size = 0;\n if (req.body) {\n const reader = req.body.getReader();\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n size += value.byteLength;\n if (size > MAX_POST_BYTES) {\n await reader.cancel().catch(() => {});\n throw invalid(`the body may be at most ${MAX_POST_BYTES} bytes`);\n }\n chunks.push(value);\n }\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(Buffer.concat(chunks).toString(\"utf8\"));\n } catch {\n throw invalid(\"the body is not valid JSON\");\n }\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) throw invalid(\"the body must be a JSON object\");\n return parsed as Record<string, unknown>;\n}\n\nfunction checkFields(body: Record<string, unknown>, allowed: readonly string[]): void {\n for (const key of Object.keys(body)) {\n if (!allowed.includes(key)) throw invalid(`unknown field ${JSON.stringify(key)}`);\n }\n}\n\nfunction bodyId(body: Record<string, unknown>, name: string): string {\n const value = body[name];\n if (typeof value !== \"string\") throw invalid(`${name} must be a string`);\n idRule(value, name);\n return value;\n}\n\n// ---------------------------------------------------------------------------\n// Shapes of the contract.\n// ---------------------------------------------------------------------------\n\ninterface RunSummary {\n run_id: string;\n workflow_name: string;\n display_name: string;\n module: string;\n status: string;\n deployment_id: string;\n created_at: string | null;\n started_at: string | null;\n completed_at: string | null;\n updated_at: string | null;\n expired_at: string | null;\n error_code: string | null;\n attributes: Record<string, string>;\n}\n\ninterface StepSummary {\n step_id: string;\n step_name: string;\n display_name: string;\n module: string;\n status: string;\n attempt: number;\n created_at: string | null;\n started_at: string | null;\n completed_at: string | null;\n updated_at: string | null;\n retry_after: string | null;\n}\n\ninterface InspectEvent {\n event_id: string;\n event_type: string;\n correlation_id: string | null;\n created_at: string | null;\n info: Record<string, unknown>;\n info_truncated: boolean;\n}\n\ninterface Wait {\n correlation_id: string;\n status: \"waiting\" | \"completed\";\n created_at: string | null;\n resume_at: string | null;\n completed_at: string | null;\n}\n\ninterface InspectHook {\n hook_id: string;\n kind: \"webhook\" | \"system\" | \"hook\";\n status: \"active\" | \"disposed\";\n created_at: string | null;\n received_count: number;\n last_received_at: string | null;\n disposed_at: string | null;\n}\n\ntype RunWithoutData = Omit<WorkflowRun, \"input\" | \"output\">;\n\nfunction names(parsed: { shortName: string; moduleSpecifier: string } | null, raw: string) {\n return { display_name: parsed?.shortName || raw, module: parsed?.moduleSpecifier ?? \"\" };\n}\n\nfunction runSummary(run: RunWithoutData): RunSummary {\n const { display_name, module } = names(parseWorkflowName(run.workflowName), run.workflowName);\n return {\n run_id: run.runId,\n workflow_name: run.workflowName,\n display_name,\n module,\n status: run.status,\n deployment_id: run.deploymentId,\n created_at: isoTime(run.createdAt),\n started_at: isoTime(run.startedAt),\n completed_at: isoTime(run.completedAt),\n updated_at: isoTime(run.updatedAt),\n expired_at: isoTime(run.expiredAt),\n error_code: run.errorCode ?? null,\n attributes: Object.fromEntries(\n Object.entries(run.attributes ?? {}).map(([k, v]) => [redactWebhookTokens(k), redactWebhookTokens(String(v))]),\n ),\n };\n}\n\nfunction stepSummary(step: Omit<Step, \"input\" | \"output\">): StepSummary {\n const { display_name, module } = names(parseStepName(step.stepName), step.stepName);\n return {\n step_id: step.stepId,\n step_name: step.stepName,\n display_name,\n module,\n status: step.status,\n attempt: step.attempt,\n created_at: isoTime(step.createdAt),\n started_at: isoTime(step.startedAt),\n completed_at: isoTime(step.completedAt),\n updated_at: isoTime(step.updatedAt),\n retry_after: isoTime(step.retryAfter),\n };\n}\n\nfunction inspectEvent(event: Event): InspectEvent {\n const stripped = stripEventDataRefs(event, \"none\") as Event & { eventData?: unknown };\n const { info, truncated } = eventInfo(stripped.eventData);\n return {\n event_id: event.eventId,\n event_type: event.eventType,\n correlation_id: event.correlationId ?? null,\n created_at: isoTime(event.createdAt),\n info,\n info_truncated: truncated,\n };\n}\n\nconst pageCursor = (page: { cursor?: string | null; hasMore: boolean }) =>\n page.hasMore && page.cursor ? page.cursor : null;\n\n// ---------------------------------------------------------------------------\n// Hydration.\n// ---------------------------------------------------------------------------\n\ntype Revivers = Record<string, (value: never) => unknown>;\nlet reviversPromise: Promise<Revivers> | undefined;\n\n/**\n * The revivers payloads are hydrated with: Workflow SDK's common revivers\n * (`Date`, `Map`, `Error`, typed arrays, … — without them devalue refuses any\n * payload holding one), display objects for `Request`/`Response`, then\n * `observabilityRevivers` (streams, runs, class instances and step functions\n * as display objects), the set Workflow SDK's own CLI inspector layers.\n */\nfunction revivers(): Promise<Revivers> {\n reviversPromise ??= (async () => {\n let common: Revivers = {};\n try {\n const serialization = (await import(\"@workflow/core/serialization\")) as {\n getCommonRevivers?: (global?: Record<string, unknown>) => Revivers;\n };\n common = serialization.getCommonRevivers?.(globalThis as unknown as Record<string, unknown>) ?? {};\n } catch (error) {\n console.warn(\n `[unfazed/workflow] inspection: Workflow SDK's common revivers are unavailable (${describe(error)}); ` +\n \"payloads holding a Date, Map, Error, … will show as unreadable\",\n );\n }\n const display =\n (kind: string) =>\n (value: Record<string, unknown>): Record<string, unknown> => {\n const out: Record<string, unknown> = { $type: kind };\n for (const key of [\"method\", \"url\", \"status\", \"statusText\", \"headers\", \"body\", \"redirected\"]) {\n if (key in value) out[key] = key === \"headers\" ? headersObject(value[key]) : value[key];\n }\n return out;\n };\n return {\n ...common,\n Request: display(\"Request\"),\n Response: display(\"Response\"),\n ...(observabilityRevivers as Revivers),\n } as Revivers;\n })();\n return reviversPromise;\n}\n\nfunction headersObject(value: unknown): unknown {\n if (Array.isArray(value)) return Object.fromEntries(value.filter((e) => Array.isArray(e) && e.length === 2));\n return value;\n}\n\n/**\n * A hydrated field and, when it could not be hydrated, why:\n * `hydrateResourceIO` leaves a field it cannot read untouched, so a field that\n * comes back as the same serialized value is hydrated again to get the reason.\n */\nfunction hydratedField(raw: unknown, hydrated: unknown, rev: Revivers): { value: unknown; failure?: unknown } {\n if (raw === undefined || raw === null) return { value: undefined };\n if (hydrated === raw && (raw instanceof Uint8Array || Array.isArray(raw))) {\n try {\n return { value: hydrateData(raw, rev as never) };\n } catch (error) {\n return { value: undefined, failure: error };\n }\n }\n return { value: hydrated };\n}\n\nfunction valueOf(field: { value: unknown; failure?: unknown }, cap: number, secrets?: string[]): InspectValue | null {\n if (field.failure !== undefined) return failedValue(field.failure, cap);\n return renderValue(field.value, cap, secrets ? { secrets, dropTokenKeys: true } : {});\n}\n\n// ---------------------------------------------------------------------------\n// Stream chunks.\n// ---------------------------------------------------------------------------\n\nconst FRAME_FORMATS = new Set([\"devl\", \"gzip\", \"zstd\"]);\n\n/** The chunk's length-prefixed frames as Workflow SDK's stream writer writes them, or undefined. */\nfunction sdkFrames(data: Uint8Array): Uint8Array[] | undefined {\n const frames: Uint8Array[] = [];\n let offset = 0;\n const view = new DataView(data.buffer, data.byteOffset, data.byteLength);\n while (offset < data.byteLength) {\n if (offset + 8 > data.byteLength) return undefined;\n const length = view.getUint32(offset, false);\n if (length < 4 || offset + 4 + length > data.byteLength) return undefined;\n const frame = data.subarray(offset + 4, offset + 4 + length);\n if (!FRAME_FORMATS.has(String.fromCharCode(frame[0]!, frame[1]!, frame[2]!, frame[3]!))) return undefined;\n frames.push(frame);\n offset += 4 + length;\n }\n return frames.length > 0 ? frames : undefined;\n}\n\n/**\n * One chunk as `{index, bytes, encoding, text, truncated}`: `json` when it is\n * Workflow SDK frames (what `getWritable()` writes), rendered as a Value; a\n * frame holding bytes (a byte stream's chunk) shows those bytes, as `utf8`\n * when they are text, else `base64`; anything else is the raw chunk, `utf8`\n * when it is valid UTF-8, else `base64`. `bytes` is always the raw length.\n */\nfunction renderChunk(index: number, data: Uint8Array, rev: Revivers) {\n const frames = sdkFrames(data);\n if (frames) {\n try {\n const values = frames.map((frame) => hydrateData(frame, rev as never));\n // Encrypted frames come back as the very bytes given: not readable here.\n if (!values.some((value, i) => value === frames[i])) {\n if (values.length === 1 && values[0] instanceof Uint8Array) return rawChunk(index, data.byteLength, values[0]);\n const cut = cutUtf8(displayText(values.length === 1 ? values[0] : values), CHUNK_TEXT_CAP_BYTES);\n return { index, bytes: data.byteLength, encoding: \"json\", text: cut.text, truncated: cut.truncated };\n }\n } catch {\n // not the SDK's framing after all\n }\n }\n return rawChunk(index, data.byteLength, data);\n}\n\nfunction rawChunk(index: number, bytes: number, data: Uint8Array) {\n try {\n // Redacted before the cut, so a token can never survive half-cut.\n const text = redactWebhookTokens(new TextDecoder(\"utf-8\", { fatal: true }).decode(data));\n const cut = cutUtf8(text, CHUNK_TEXT_CAP_BYTES);\n return { index, bytes, encoding: \"utf8\", text: cut.text, truncated: cut.truncated };\n } catch {\n // Not text, but a webhook URL may still sit in it as ASCII: redact it in\n // the bytes (latin1 maps each byte to one character and back).\n const latin1 = Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString(\"latin1\");\n const redacted = redactWebhookTokens(latin1);\n const base64 = (redacted === latin1 ? Buffer.from(data.buffer, data.byteOffset, data.byteLength) : Buffer.from(redacted, \"latin1\")).toString(\"base64\");\n const truncated = base64.length > CHUNK_TEXT_CAP_BYTES;\n return { index, bytes, encoding: \"base64\", text: truncated ? base64.slice(0, CHUNK_TEXT_CAP_BYTES) : base64, truncated };\n }\n}\n\n// ---------------------------------------------------------------------------\n// World errors.\n// ---------------------------------------------------------------------------\n\nfunction isNotFound(error: unknown): boolean {\n for (let e: unknown = error, depth = 0; e instanceof Error && depth < 4; e = (e as { cause?: unknown }).cause, depth++) {\n if (e.name === \"WorkflowRunNotFoundError\" || e.name === \"HookNotFoundError\") return true;\n if ((e as { status?: unknown }).status === 404) return true;\n if (e.name === \"WorkflowWorldError\" && /\\bnot found\\b/i.test(e.message)) return true;\n }\n return false;\n}\n\nasync function orNotFound<T>(call: Promise<T>, message: string): Promise<T> {\n try {\n return await call;\n } catch (error) {\n if (isNotFound(error)) throw notFound(message);\n throw error;\n }\n}\n\n/** Shrinks a page until its answer fits the budget; World cursors stay the World's own. */\nasync function fitPage<T>(limit: number, fetchPage: (limit: number) => Promise<T>): Promise<T> {\n let size = limit;\n for (;;) {\n const answer = await fetchPage(size);\n if (size === 1 || utf8Length(JSON.stringify(answer)) <= PAGE_BUDGET_BYTES) return answer;\n size = Math.max(1, Math.floor(size / 2));\n }\n}\n\n// ---------------------------------------------------------------------------\n// Endpoints.\n// ---------------------------------------------------------------------------\n\ninterface Context {\n world: World;\n options: InspectHandlerOptions;\n getRun(runId: string): Promise<InspectRunHandle>;\n}\n\ntype Endpoint = {\n method: \"GET\" | \"POST\";\n rules?: Record<string, Rule>;\n required?: readonly string[];\n run(ctx: Context, input: { params: Params; body: Record<string, unknown> }): Promise<unknown>;\n};\n\nasync function assertRun(world: World, runId: string): Promise<RunWithoutData> {\n return orNotFound(world.runs.get(runId, { resolveData: \"none\" }), `no such run ${runId}`);\n}\n\nasync function scanEvents(world: World, runId: string): Promise<{ events: Event[]; complete: boolean }> {\n const events: Event[] = [];\n let cursor: string | undefined;\n for (;;) {\n const page = await world.events.list({\n runId,\n pagination: { limit: Math.min(EVENTS_PAGE_SIZE, RUN_PAGE_MAX_EVENTS - events.length), sortOrder: \"asc\", ...(cursor ? { cursor } : {}) },\n resolveData: \"none\",\n });\n events.push(...page.data);\n if (!page.hasMore || !page.cursor) return { events, complete: true };\n if (events.length >= RUN_PAGE_MAX_EVENTS) return { events, complete: false };\n cursor = page.cursor;\n }\n}\n\nfunction waitsOf(events: Event[]): { waits: Wait[]; truncated: boolean } {\n const waits = new Map<string, Wait>();\n for (const event of events) {\n const id = event.correlationId;\n if (!id) continue;\n const data = (event as { eventData?: Record<string, unknown> }).eventData;\n if (event.eventType === \"wait_created\") {\n waits.set(id, {\n correlation_id: id,\n status: \"waiting\",\n created_at: isoTime(event.createdAt),\n resume_at: isoTime(data?.resumeAt),\n completed_at: null,\n });\n } else if (event.eventType === \"wait_completed\") {\n const wait = waits.get(id);\n if (wait) {\n wait.status = \"completed\";\n wait.completed_at = isoTime(event.createdAt);\n }\n }\n }\n const all = [...waits.values()];\n return { waits: all.slice(-RUN_PAGE_MAX_WAITS), truncated: all.length > RUN_PAGE_MAX_WAITS };\n}\n\nfunction hooksOf(events: Event[], entities: Hook[]): { hooks: InspectHook[]; truncated: boolean } {\n const hooks = new Map<string, InspectHook & { isWebhook?: boolean; isSystem?: boolean }>();\n for (const event of events) {\n const id = event.correlationId;\n if (!id) continue;\n const data = (event as { eventData?: Record<string, unknown> }).eventData;\n if (event.eventType === \"hook_created\") {\n hooks.set(id, {\n hook_id: id,\n kind: \"hook\",\n status: \"active\",\n created_at: isoTime(event.createdAt),\n received_count: 0,\n last_received_at: null,\n disposed_at: null,\n ...(typeof data?.isWebhook === \"boolean\" ? { isWebhook: data.isWebhook } : {}),\n ...(typeof data?.isSystem === \"boolean\" ? { isSystem: data.isSystem } : {}),\n });\n continue;\n }\n const hook = hooks.get(id);\n if (!hook) continue;\n if (event.eventType === \"hook_received\") {\n hook.received_count++;\n hook.last_received_at = isoTime(event.createdAt);\n } else if (event.eventType === \"hook_disposed\") {\n hook.status = \"disposed\";\n hook.disposed_at = isoTime(event.createdAt);\n }\n }\n for (const entity of entities) {\n let hook = hooks.get(entity.hookId);\n if (!hook) {\n hook = {\n hook_id: entity.hookId,\n kind: \"hook\",\n status: \"active\",\n created_at: isoTime(entity.createdAt),\n received_count: 0,\n last_received_at: null,\n disposed_at: null,\n };\n hooks.set(entity.hookId, hook);\n }\n if (typeof entity.isWebhook === \"boolean\") hook.isWebhook = entity.isWebhook;\n if (typeof entity.isSystem === \"boolean\") hook.isSystem = entity.isSystem;\n }\n const all = [...hooks.values()].sort((a, b) => (a.created_at ?? \"\").localeCompare(b.created_at ?? \"\"));\n return {\n hooks: all.slice(-RUN_PAGE_MAX_HOOKS).map(({ isWebhook, isSystem, ...hook }) => ({\n ...hook,\n kind: isSystem ? \"system\" : isWebhook ? \"webhook\" : \"hook\",\n })),\n truncated: all.length > RUN_PAGE_MAX_HOOKS,\n };\n}\n\nconst ENDPOINTS: Record<string, Endpoint> = {\n info: {\n method: \"GET\",\n async run({ world, options }) {\n const workflows = [...new Set(options.workflows ?? [])].sort().map((name) => ({\n name,\n ...names(parseWorkflowName(name), name),\n }));\n return {\n version: INSPECT_CONTRACT_VERSION,\n package: `unfazed@${VERSION}`,\n workflow: options.workflowVersion || \"unknown\",\n spec_version: typeof world.specVersion === \"number\" ? world.specVersion : null,\n workflows,\n };\n },\n },\n\n runs: {\n method: \"GET\",\n rules: { status: statusRule, workflow_name: textRule, limit: limitRule(100), cursor: cursorRule },\n async run({ world }, { params }) {\n const status = params.status ? [...new Set(params.status.split(\",\"))] : undefined;\n return fitPage(Number(params.limit ?? 20), async (limit) => {\n const page = await world.runs.list({\n ...(status ? { status: status as WorkflowRun[\"status\"][] } : {}),\n ...(params.workflow_name ? { workflowName: params.workflow_name } : {}),\n pagination: { limit, sortOrder: \"desc\", ...(params.cursor ? { cursor: params.cursor } : {}) },\n resolveData: \"none\",\n });\n return { runs: page.data.map(runSummary), next_cursor: pageCursor(page), has_more: page.hasMore && pageCursor(page) !== null };\n });\n },\n },\n\n run: {\n method: \"GET\",\n rules: { run_id: idRule },\n required: [\"run_id\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const run = await orNotFound(world.runs.get(runId, { resolveData: \"all\" }), `no such run ${runId}`);\n const [steps, scan, hookEntities, streamNames] = await Promise.all([\n world.steps.list({ runId, pagination: { limit: RUN_PAGE_STEPS, sortOrder: \"asc\" }, resolveData: \"none\" }),\n scanEvents(world, runId),\n world.hooks.list({ runId, pagination: { limit: RUN_PAGE_MAX_HOOKS }, resolveData: \"none\" }),\n world.streams.list(runId),\n ]);\n const streams = streamNames.slice(0, RUN_PAGE_MAX_STREAMS);\n const infos = await Promise.all(\n streams.slice(0, RUN_PAGE_STREAM_INFOS).map((name) => world.streams.getInfo(runId, name).catch(() => undefined)),\n );\n const waits = waitsOf(scan.events);\n const hooks = hooksOf(scan.events, hookEntities.data);\n const rev = await revivers();\n const hydrated = hydrateResourceIO(run as WorkflowRun & { error?: unknown }, rev as never) as Record<string, unknown>;\n const raw = run as unknown as Record<string, unknown>;\n const errorField = hydratedField(raw.error, hydrated.error, rev);\n return {\n run: runSummary(run),\n input: valueOf(hydratedField(raw.input, hydrated.input, rev), IO_CAP_BYTES),\n output: valueOf(hydratedField(raw.output, hydrated.output, rev), IO_CAP_BYTES),\n error:\n run.status === \"failed\"\n ? renderError(errorField.value ?? null, run.errorCode ?? null, errorField.failure)\n : null,\n steps: steps.data.map(stepSummary),\n steps_next_cursor: pageCursor(steps),\n steps_has_more: steps.hasMore && pageCursor(steps) !== null,\n waits: waits.waits,\n waits_truncated: waits.truncated,\n hooks: hooks.hooks,\n hooks_truncated: hooks.truncated,\n streams: streams.map((name, i) => {\n const info = i < RUN_PAGE_STREAM_INFOS ? infos[i] : undefined;\n return { name, tail_index: info ? info.tailIndex : null, done: info ? info.done : null };\n }),\n events_scanned: scan.events.length,\n events_complete: scan.complete,\n };\n },\n },\n\n steps: {\n method: \"GET\",\n rules: { run_id: idRule, limit: limitRule(200), cursor: cursorRule },\n required: [\"run_id\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const [, answer] = await Promise.all([\n assertRun(world, runId),\n fitPage(Number(params.limit ?? 100), async (limit) => {\n const page = await world.steps.list({\n runId,\n pagination: { limit, sortOrder: \"asc\", ...(params.cursor ? { cursor: params.cursor } : {}) },\n resolveData: \"none\",\n });\n return { steps: page.data.map(stepSummary), next_cursor: pageCursor(page), has_more: page.hasMore && pageCursor(page) !== null };\n }),\n ]);\n return answer;\n },\n },\n\n step: {\n method: \"GET\",\n rules: { run_id: idRule, step_id: idRule },\n required: [\"run_id\", \"step_id\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const stepId = params.step_id!;\n const [step, events] = await Promise.all([\n orNotFound(world.steps.get(runId, stepId, { resolveData: \"all\" }), `no such step ${stepId} in run ${runId}`),\n world.events.listByCorrelationId({\n runId,\n correlationId: stepId,\n pagination: { limit: STEP_PAGE_EVENTS, sortOrder: \"asc\" },\n resolveData: \"none\",\n }),\n ]);\n const rev = await revivers();\n const hydrated = hydrateResourceIO(step, rev as never) as Record<string, unknown>;\n const raw = step as unknown as Record<string, unknown>;\n const errorField = hydratedField(raw.error, hydrated.error, rev);\n const input = hydratedField(raw.input, hydrated.input, rev);\n return {\n step: stepSummary(step),\n input: valueOf({ ...input, value: stepInputDisplay(input.value) }, IO_CAP_BYTES),\n output: valueOf(hydratedField(raw.output, hydrated.output, rev), IO_CAP_BYTES),\n error:\n raw.error === undefined || raw.error === null\n ? null\n : renderError(errorField.value ?? null, null, errorField.failure),\n events: events.data.map(inspectEvent),\n events_has_more: events.hasMore,\n };\n },\n },\n\n events: {\n method: \"GET\",\n rules: { run_id: idRule, correlation_id: idRule, order: orderRule, limit: limitRule(500), cursor: cursorRule },\n required: [\"run_id\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const sortOrder = (params.order ?? \"asc\") as \"asc\" | \"desc\";\n const [, answer] = await Promise.all([\n assertRun(world, runId),\n fitPage(Number(params.limit ?? 100), async (limit) => {\n const pagination = { limit, sortOrder, ...(params.cursor ? { cursor: params.cursor } : {}) };\n const page = params.correlation_id\n ? await world.events.listByCorrelationId({ runId, correlationId: params.correlation_id, pagination, resolveData: \"none\" })\n : await world.events.list({ runId, pagination, resolveData: \"none\" });\n return { events: page.data.map(inspectEvent), next_cursor: pageCursor(page), has_more: page.hasMore && pageCursor(page) !== null };\n }),\n ]);\n return answer;\n },\n },\n\n event: {\n method: \"GET\",\n rules: { run_id: idRule, event_id: idRule },\n required: [\"run_id\", \"event_id\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const eventId = params.event_id!;\n const event = await orNotFound(world.events.get(runId, eventId, { resolveData: \"all\" }), `no such event ${eventId} in run ${runId}`);\n const field = getEventDataRefFields(event.eventType).find((name) => {\n const data = (event as { eventData?: Record<string, unknown> }).eventData;\n return data !== undefined && data[name] !== undefined && data[name] !== null;\n });\n let data: InspectValue | null = null;\n if (field) {\n const [rev, secrets] = await Promise.all([revivers(), runHookTokens(world, runId, event)]);\n const raw = (event as { eventData: Record<string, unknown> }).eventData[field];\n const hydrated = (hydrateResourceIO(event as never, rev as never) as { eventData?: Record<string, unknown> }).eventData?.[field];\n const value = hydratedField(raw, hydrated, rev);\n // A step's input (step_created, step_started) shows as its arguments.\n if (field === \"input\" && event.eventType.startsWith(\"step_\")) value.value = stepInputDisplay(value.value);\n data = valueOf(value, EVENT_DATA_CAP_BYTES, secrets);\n }\n return { event: inspectEvent(event), data };\n },\n },\n\n stream: {\n method: \"GET\",\n rules: { run_id: idRule, name: textRule, limit: limitRule(200), cursor: cursorRule },\n required: [\"run_id\", \"name\"],\n async run({ world }, { params }) {\n const runId = params.run_id!;\n const name = params.name!;\n const [streamNames, info] = await Promise.all([\n orNotFound(world.streams.list(runId), `no such run ${runId}`),\n world.streams.getInfo(runId, name),\n ]);\n if (!streamNames.includes(name)) throw notFound(`no such stream ${JSON.stringify(name)} in run ${runId}`);\n const rev = await revivers();\n return fitPage(Number(params.limit ?? 50), async (limit) => {\n const page = await world.streams.getChunks(runId, name, { limit, ...(params.cursor ? { cursor: params.cursor } : {}) });\n return {\n name,\n chunks: page.data.map((chunk) => renderChunk(chunk.index, chunk.data, rev)),\n next_cursor: pageCursor(page),\n has_more: page.hasMore && pageCursor(page) !== null,\n done: info.done,\n tail_index: info.tailIndex,\n };\n });\n },\n },\n\n wake: {\n method: \"POST\",\n async run({ world, getRun }, { body }) {\n checkFields(body, [\"run_id\", \"correlation_ids\"]);\n const runId = bodyId(body, \"run_id\");\n let correlationIds: string[] | undefined;\n if (body.correlation_ids !== undefined) {\n const ids = body.correlation_ids;\n if (!Array.isArray(ids) || ids.length < 1 || ids.length > 100) {\n throw invalid(\"correlation_ids must be a list of 1 to 100 IDs\");\n }\n correlationIds = ids.map((id, i) => {\n if (typeof id !== \"string\") throw invalid(`correlation_ids[${i}] must be a string`);\n idRule(id, `correlation_ids[${i}]`);\n return id;\n });\n }\n const run = await assertRun(world, runId);\n if (isTerminalWorkflowRunStatus(run.status)) throw terminal(run);\n const handle = await getRun(runId);\n const result = await orNotFound(handle.wakeUp(correlationIds ? { correlationIds } : undefined), `no such run ${runId}`);\n return { stopped_count: result.stoppedCount };\n },\n },\n\n cancel: {\n method: \"POST\",\n async run({ world, getRun }, { body }) {\n checkFields(body, [\"run_id\", \"reason\"]);\n const runId = bodyId(body, \"run_id\");\n const reason = body.reason;\n // At most 512 characters (code points), as the platform counts them.\n if (reason !== undefined && (typeof reason !== \"string\" || Array.from(reason).length > 512)) {\n throw invalid(\"reason must be a string of at most 512 characters\");\n }\n const run = await assertRun(world, runId);\n if (isTerminalWorkflowRunStatus(run.status)) throw terminal(run);\n const handle = await getRun(runId);\n try {\n await handle.cancel(reason !== undefined ? { cancelReason: sdkCancelReason(reason) } : undefined);\n } catch (error) {\n // Lost a race with the run ending: say so rather than fail.\n const now = await world.runs.get(runId, { resolveData: \"none\" }).catch(() => undefined);\n if (now && isTerminalWorkflowRunStatus(now.status)) throw terminal(now);\n throw error;\n }\n return { run_id: runId, status: \"cancelled\" };\n },\n },\n};\n\n/**\n * The reason as Workflow SDK stores it: its schema takes at most 512 UTF-16\n * units, so a reason of 512 characters that holds astral-plane ones (emoji)\n * is cut on a character boundary to fit, rather than failing the cancel.\n */\nexport function sdkCancelReason(reason: string): string {\n if (reason.length <= 512) return reason;\n let out = \"\";\n for (const char of reason) {\n if (out.length + char.length > 512) break;\n out += char;\n }\n return out;\n}\n\nfunction terminal(run: { runId: string; status: string }): InspectFailure {\n return new InspectFailure(409, \"run_terminal\", `run ${run.runId} already ended (${run.status})`);\n}\n\n/**\n * Every hook token of the run, so none of them, nor a webhook URL built from\n * one, leaves in an event's data (a webhook's received `Request` carries its\n * URL, which holds the token): from the hook records and from every event\n * that names one (`hook_created`, `hook_received`, …), over the same 10 000\n * events the run page reads.\n */\nasync function runHookTokens(world: World, runId: string, event: Event): Promise<string[]> {\n const tokens = new Set<string>();\n const add = (e: unknown) => {\n const token = (e as { eventData?: { token?: unknown } } | undefined)?.eventData?.token;\n if (typeof token === \"string\" && token.length > 0) tokens.add(token);\n };\n add(event);\n const records = async () => {\n let cursor: string | undefined;\n for (let page = 0; page < 20; page++) {\n const hooks = await world.hooks.list({\n runId,\n pagination: { limit: RUN_PAGE_MAX_HOOKS, ...(cursor ? { cursor } : {}) },\n resolveData: \"none\",\n });\n for (const hook of hooks.data) if (typeof hook.token === \"string\" && hook.token.length > 0) tokens.add(hook.token);\n if (!hooks.hasMore || !hooks.cursor) return;\n cursor = hooks.cursor;\n }\n };\n const [, scan] = await Promise.all([records(), scanEvents(world, runId)]);\n for (const e of scan.events) add(e);\n return [...tokens];\n}\n\n// ---------------------------------------------------------------------------\n// The handler.\n// ---------------------------------------------------------------------------\n\n/**\n * Creates the inspection route's handler: `(request) => Response` for every\n * request under {@link INSPECT_BASE_PATH}.\n *\n * ```ts\n * // e.g. a catch-all route at /.well-known/workflow/v1/unfazed/inspect/v1/*\n * import { createInspectHandler } from \"unfazed/workflow\";\n * const inspect = createInspectHandler();\n * export const GET = inspect, POST = inspect;\n * ```\n *\n * `unfazed/workflow/nitro` mounts it for you.\n */\nexport function createInspectHandler(options: InspectHandlerOptions = {}): (request: Request) => Promise<Response> {\n const timeoutMs = options.timeoutMs ?? 19_000;\n const getWorld =\n options.getWorld ??\n (async () => {\n const runtime = (await import(\"workflow/runtime\")) as { getWorld(): World | Promise<World> };\n return runtime.getWorld();\n });\n const getRun = options.getRun\n ? async (runId: string) => options.getRun!(runId)\n : async (runId: string) => {\n const api = (await import(\"workflow/api\")) as unknown as { getRun(runId: string): InspectRunHandle };\n return api.getRun(runId);\n };\n\n return async (request) => {\n const expected = options.stateToken ?? envValue(options.env ?? process.env, \"UNFZ_STATE_TOKEN\")?.trim();\n if (!verifyQueueToken(expected || undefined, request.headers.get(DELIVERY_HEADERS.token))) {\n return errorResponse(401, \"unauthorized\", \"missing or invalid queue token\");\n }\n const url = new URL(request.url);\n const prefix = `${INSPECT_BASE_PATH}/`;\n const op = url.pathname.startsWith(prefix) ? url.pathname.slice(prefix.length) : \"\";\n const endpoint = Object.hasOwn(ENDPOINTS, op) ? ENDPOINTS[op] : undefined;\n if (!endpoint) return errorResponse(404, \"not_found\", `no inspection endpoint at ${url.pathname}`);\n if (request.method !== endpoint.method) {\n return errorResponse(405, \"method_not_allowed\", `${op} takes ${endpoint.method}`, { allow: endpoint.method });\n }\n\n let started = false;\n const work = (async () => {\n const params = parseQuery(url, endpoint.rules ?? {}, endpoint.required ?? []);\n const body = endpoint.method === \"POST\" ? await readBody(request) : {};\n let world: World;\n try {\n world = await getWorld();\n const ready = (world as { ready?: () => Promise<void> }).ready;\n if (typeof ready === \"function\") await ready.call(world);\n } catch (error) {\n throw new InspectFailure(503, \"world_unavailable\", describe(error));\n }\n started = true;\n return endpoint.run({ world, options, getRun }, { params, body });\n })();\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n const deadline = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n started\n ? new InspectFailure(500, \"internal\", `the World did not answer within ${Math.round(timeoutMs / 1000)} s`)\n : new InspectFailure(503, \"world_unavailable\", `the World is still starting after ${Math.round(timeoutMs / 1000)} s`),\n ),\n timeoutMs,\n );\n });\n work.catch(() => {}); // a late failure after the deadline answered\n try {\n const answer = await Promise.race([work, deadline]);\n const text = JSON.stringify(answer);\n if (utf8Length(text) > MAX_BODY_BYTES) {\n return errorResponse(500, \"internal\", `the answer would exceed ${MAX_BODY_BYTES} bytes`);\n }\n return new Response(text, { status: 200, headers: RESPONSE_HEADERS });\n } catch (error) {\n if (error instanceof InspectFailure) return errorResponse(error.status, error.code, error.message);\n return errorResponse(500, \"internal\", describe(error));\n } finally {\n clearTimeout(timer);\n }\n };\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { WorkflowMigrations } from "./migration-types.js";
2
+ /**
3
+ * Reads the drizzle migrations shipped in an installed `@workflow/world-postgres`
4
+ * (its `src/drizzle/migrations`, the folder its `bootstrap` CLI applies), given
5
+ * any file inside that package, typically its resolved entry point.
6
+ *
7
+ * Returns `undefined` when the package cannot be found that way. Used at build
8
+ * time only: by `scripts/embed-migrations.ts` for the copy this package ships,
9
+ * and by the Nitro module for the copy matching the app's own install.
10
+ */
11
+ export declare function readWorldPostgresMigrations(fileInPackage: string): Promise<WorkflowMigrations | undefined>;
12
+ /** The version of the installed package `name`, given any file inside it. */
13
+ export declare function readPackageVersion(fileInPackage: string, name: string): Promise<string | undefined>;
@@ -0,0 +1,52 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ const PACKAGE_NAME = "@workflow/world-postgres";
4
+ /**
5
+ * Reads the drizzle migrations shipped in an installed `@workflow/world-postgres`
6
+ * (its `src/drizzle/migrations`, the folder its `bootstrap` CLI applies), given
7
+ * any file inside that package, typically its resolved entry point.
8
+ *
9
+ * Returns `undefined` when the package cannot be found that way. Used at build
10
+ * time only: by `scripts/embed-migrations.ts` for the copy this package ships,
11
+ * and by the Nitro module for the copy matching the app's own install.
12
+ */
13
+ export async function readWorldPostgresMigrations(fileInPackage) {
14
+ const root = await findPackageRoot(fileInPackage, PACKAGE_NAME);
15
+ if (!root)
16
+ return undefined;
17
+ const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
18
+ const folder = join(root, "src", "drizzle", "migrations");
19
+ const journalText = await readFile(join(folder, "meta", "_journal.json"), "utf8");
20
+ const journal = JSON.parse(journalText);
21
+ const files = {};
22
+ for (const { tag } of journal.entries) {
23
+ files[`${tag}.sql`] = await readFile(join(folder, `${tag}.sql`), "utf8");
24
+ }
25
+ return { version: pkg.version, journal: journalText, files };
26
+ }
27
+ /** The version of the installed package `name`, given any file inside it. */
28
+ export async function readPackageVersion(fileInPackage, name) {
29
+ const root = await findPackageRoot(fileInPackage, name);
30
+ if (!root)
31
+ return undefined;
32
+ const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
33
+ return typeof pkg.version === "string" ? pkg.version : undefined;
34
+ }
35
+ async function findPackageRoot(start, name) {
36
+ let dir = dirname(start);
37
+ for (;;) {
38
+ try {
39
+ const pkg = JSON.parse(await readFile(join(dir, "package.json"), "utf8"));
40
+ if (pkg.name === name)
41
+ return dir;
42
+ }
43
+ catch {
44
+ // no package.json here; keep walking up
45
+ }
46
+ const parent = dirname(dir);
47
+ if (parent === dir)
48
+ return undefined;
49
+ dir = parent;
50
+ }
51
+ }
52
+ //# sourceMappingURL=migration-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-files.js","sourceRoot":"","sources":["../../src/workflow/migration-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAMhD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,aAAqB;IAErB,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAChE,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAwB,CAAC;IAClG,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MA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G,CAAC,IAAI,KAAK,IAAI;gBAAE,OAAO,GAAG,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,wCAAwC;QAC1C,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { WorkflowMigrations } from \"./migration-types.js\";\n\nconst PACKAGE_NAME = \"@workflow/world-postgres\";\n\ninterface Journal {\n entries: { tag: string }[];\n}\n\n/**\n * Reads the drizzle migrations shipped in an installed `@workflow/world-postgres`\n * (its `src/drizzle/migrations`, the folder its `bootstrap` CLI applies), given\n * any file inside that package, typically its resolved entry point.\n *\n * Returns `undefined` when the package cannot be found that way. Used at build\n * time only: by `scripts/embed-migrations.ts` for the copy this package ships,\n * and by the Nitro module for the copy matching the app's own install.\n */\nexport async function readWorldPostgresMigrations(\n fileInPackage: string,\n): Promise<WorkflowMigrations | undefined> {\n const root = await findPackageRoot(fileInPackage, PACKAGE_NAME);\n if (!root) return undefined;\n const pkg = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\")) as { version: string };\n const folder = join(root, \"src\", \"drizzle\", \"migrations\");\n const journalText = await readFile(join(folder, \"meta\", \"_journal.json\"), \"utf8\");\n const journal = JSON.parse(journalText) as Journal;\n const files: Record<string, string> = {};\n for (const { tag } of journal.entries) {\n files[`${tag}.sql`] = await readFile(join(folder, `${tag}.sql`), \"utf8\");\n }\n return { version: pkg.version, journal: journalText, files };\n}\n\n/** The version of the installed package `name`, given any file inside it. */\nexport async function readPackageVersion(fileInPackage: string, name: string): Promise<string | undefined> {\n const root = await findPackageRoot(fileInPackage, name);\n if (!root) return undefined;\n const pkg = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\")) as { version?: unknown };\n return typeof pkg.version === \"string\" ? pkg.version : undefined;\n}\n\nasync function findPackageRoot(start: string, name: string): Promise<string | undefined> {\n let dir = dirname(start);\n for (;;) {\n try {\n const pkg = JSON.parse(await readFile(join(dir, \"package.json\"), \"utf8\")) as { name?: string };\n if (pkg.name === name) return dir;\n } catch {\n // no package.json here; keep walking up\n }\n const parent = dirname(dir);\n if (parent === dir) return undefined;\n dir = parent;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The upstream `@workflow/world-postgres` drizzle migrations, verbatim: the
3
+ * journal text and every `<tag>.sql` it lists.
4
+ */
5
+ export interface WorkflowMigrations {
6
+ /** The `@workflow/world-postgres` version they were read from. */
7
+ version: string;
8
+ /** `meta/_journal.json`, verbatim. */
9
+ journal: string;
10
+ /** `<tag>.sql` → file text, verbatim. */
11
+ files: Record<string, string>;
12
+ }
13
+ /**
14
+ * The drizzle bookkeeping table the upstream `bootstrap` CLI uses. Sharing it
15
+ * means a database bootstrapped by that CLI is recognised here, and the CLI
16
+ * recognises one migrated here.
17
+ */
18
+ export declare const MIGRATIONS_TABLE = "workflow_migrations";
19
+ export declare const MIGRATIONS_SCHEMA = "workflow_drizzle";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The drizzle bookkeeping table the upstream `bootstrap` CLI uses. Sharing it
3
+ * means a database bootstrapped by that CLI is recognised here, and the CLI
4
+ * recognises one migrated here.
5
+ */
6
+ export const MIGRATIONS_TABLE = "workflow_migrations";
7
+ export const MIGRATIONS_SCHEMA = "workflow_drizzle";
8
+ //# sourceMappingURL=migration-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-types.js","sourceRoot":"","sources":["../../src/workflow/migration-types.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC","sourcesContent":["/**\n * The upstream `@workflow/world-postgres` drizzle migrations, verbatim: the\n * journal text and every `<tag>.sql` it lists.\n */\nexport interface WorkflowMigrations {\n /** The `@workflow/world-postgres` version they were read from. */\n version: string;\n /** `meta/_journal.json`, verbatim. */\n journal: string;\n /** `<tag>.sql` → file text, verbatim. */\n files: Record<string, string>;\n}\n\n/**\n * The drizzle bookkeeping table the upstream `bootstrap` CLI uses. Sharing it\n * means a database bootstrapped by that CLI is recognised here, and the CLI\n * recognises one migrated here.\n */\nexport const MIGRATIONS_TABLE = \"workflow_migrations\";\nexport const MIGRATIONS_SCHEMA = \"workflow_drizzle\";\n"]}
@@ -0,0 +1,12 @@
1
+ import type { Pool } from "pg";
2
+ import { type WorkflowMigrations } from "./migration-types.js";
3
+ /**
4
+ * Applies the migrations with drizzle's own migrator, exactly as the upstream
5
+ * `bootstrap` CLI does, from a temporary folder (the migrator reads files).
6
+ * Idempotent: applied migrations are skipped by the migrator's own journal.
7
+ *
8
+ * Runs on every cold start, so the common case, a database that already has
9
+ * the newest migration, costs one query and touches neither the lock nor the
10
+ * file system.
11
+ */
12
+ export declare function applyMigrations(pool: Pool, migrations: WorkflowMigrations): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { WorkflowMigrations } from "./migration-types.js";
2
+ export declare const embeddedMigrations: WorkflowMigrations;
@@ -0,0 +1,34 @@
1
+ export const embeddedMigrations = {
2
+ "version": "5.0.4",
3
+ "journal": "{\n \"version\": \"7\",\n \"dialect\": \"postgresql\",\n \"entries\": [\n {\n \"idx\": 0,\n \"version\": \"7\",\n \"when\": 1762873019948,\n \"tag\": \"0000_cultured_the_anarchist\",\n \"breakpoints\": true\n },\n {\n \"idx\": 1,\n \"version\": \"7\",\n \"when\": 1763903867386,\n \"tag\": \"0001_tricky_sersi\",\n \"breakpoints\": true\n },\n {\n \"idx\": 2,\n \"version\": \"7\",\n \"when\": 1764815363008,\n \"tag\": \"0002_add_expired_at\",\n \"breakpoints\": true\n },\n {\n \"idx\": 3,\n \"version\": \"7\",\n \"when\": 1765900000000,\n \"tag\": \"0003_add_stream_run_id\",\n \"breakpoints\": true\n },\n {\n \"idx\": 4,\n \"version\": \"7\",\n \"when\": 1765900000001,\n \"tag\": \"0004_remove_run_pause_status\",\n \"breakpoints\": true\n },\n {\n \"idx\": 5,\n \"version\": \"7\",\n \"when\": 1767723210726,\n \"tag\": \"0005_add_spec_version\",\n \"breakpoints\": true\n },\n {\n \"idx\": 6,\n \"version\": \"7\",\n \"when\": 1768500000000,\n \"tag\": \"0006_add_error_cbor\",\n \"breakpoints\": true\n },\n {\n \"idx\": 7,\n \"version\": \"7\",\n \"when\": 1769500000000,\n \"tag\": \"0007_add_waits_table\",\n \"breakpoints\": true\n },\n {\n \"idx\": 8,\n \"version\": \"7\",\n \"when\": 1770000000000,\n \"tag\": \"0008_migrate_pgboss_to_graphile\",\n \"breakpoints\": true\n },\n {\n \"idx\": 9,\n \"version\": \"7\",\n \"when\": 1770500000000,\n \"tag\": \"0009_add_is_webhook\",\n \"breakpoints\": true\n },\n {\n \"idx\": 10,\n \"version\": \"7\",\n \"when\": 1771000000000,\n \"tag\": \"0010_add_events_entity_creation_unique_index\",\n \"breakpoints\": true\n },\n {\n \"idx\": 11,\n \"version\": \"7\",\n \"when\": 1771500000000,\n \"tag\": \"0011_add_error_code\",\n \"breakpoints\": true\n },\n {\n \"idx\": 12,\n \"version\": \"7\",\n \"when\": 1775600000000,\n \"tag\": \"0012_add_is_system\",\n \"breakpoints\": true\n },\n {\n \"idx\": 13,\n \"version\": \"7\",\n \"when\": 1779609600000,\n \"tag\": \"0013_add_attributes\",\n \"breakpoints\": true\n },\n {\n \"idx\": 14,\n \"version\": \"7\",\n \"when\": 1780185600000,\n \"tag\": \"0014_add_attr_set_event_unique_index\",\n \"breakpoints\": true\n },\n {\n \"idx\": 15,\n \"version\": \"7\",\n \"when\": 1782691200000,\n \"tag\": \"0015_move_enums_to_workflow_schema\",\n \"breakpoints\": true\n },\n {\n \"idx\": 16,\n \"version\": \"7\",\n \"when\": 1784937600000,\n \"tag\": \"0016_add_encryption_public_key\",\n \"breakpoints\": true\n },\n {\n \"idx\": 17,\n \"version\": \"7\",\n \"when\": 1785283200000,\n \"tag\": \"0017_add_hook_resume_context\",\n \"breakpoints\": true\n },\n {\n \"idx\": 18,\n \"version\": \"7\",\n \"when\": 1785619990000,\n \"tag\": \"0018_add_hook_token_retention\",\n \"breakpoints\": true\n },\n {\n \"idx\": 19,\n \"version\": \"7\",\n \"when\": 1786060800000,\n \"tag\": \"0019_add_event_slots\",\n \"breakpoints\": true\n },\n {\n \"idx\": 20,\n \"version\": \"7\",\n \"when\": 1789430400000,\n \"tag\": \"0020_add_invocations\",\n \"breakpoints\": true\n },\n {\n \"idx\": 21,\n \"version\": \"7\",\n \"when\": 1789516800000,\n \"tag\": \"0021_invocation_identity_retention\",\n \"breakpoints\": true\n },\n {\n \"idx\": 22,\n \"version\": \"7\",\n \"when\": 1789603200000,\n \"tag\": \"0022_invocation_outcomes\",\n \"breakpoints\": true\n },\n {\n \"idx\": 23,\n \"version\": \"7\",\n \"when\": 1789689600000,\n \"tag\": \"0023_add_hook_claimed_from\",\n \"breakpoints\": true\n },\n {\n \"idx\": 24,\n \"version\": \"7\",\n \"when\": 1789776000000,\n \"tag\": \"0024_add_dynamic_workflow_code\",\n \"breakpoints\": true\n },\n {\n \"idx\": 25,\n \"version\": \"7\",\n \"when\": 1789862400000,\n \"tag\": \"0025_add_snapshots_table\",\n \"breakpoints\": true\n },\n {\n \"idx\": 26,\n \"version\": \"7\",\n \"when\": 1789948800000,\n \"tag\": \"0026_add_seq_in_band\",\n \"breakpoints\": true\n }\n ]\n}\n",
4
+ "files": {
5
+ "0000_cultured_the_anarchist.sql": "CREATE SCHEMA \"workflow\";\n--> statement-breakpoint\nDO $$ BEGIN\n CREATE TYPE \"public\".\"step_status\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');\nEXCEPTION\n WHEN duplicate_object THEN null;\nEND $$;\n--> statement-breakpoint\nDO $$ BEGIN\n CREATE TYPE \"public\".\"status\" AS ENUM('pending', 'running', 'completed', 'failed', 'paused', 'cancelled');\nEXCEPTION\n WHEN duplicate_object THEN null;\nEND $$;\n--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_events\" (\n\t\"id\" varchar PRIMARY KEY NOT NULL,\n\t\"type\" varchar NOT NULL,\n\t\"correlation_id\" varchar,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"run_id\" varchar NOT NULL,\n\t\"payload\" jsonb\n);\n--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_hooks\" (\n\t\"run_id\" varchar NOT NULL,\n\t\"hook_id\" varchar PRIMARY KEY NOT NULL,\n\t\"token\" varchar NOT NULL,\n\t\"owner_id\" varchar NOT NULL,\n\t\"project_id\" varchar NOT NULL,\n\t\"environment\" varchar NOT NULL,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"metadata\" jsonb\n);\n--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_runs\" (\n\t\"id\" varchar PRIMARY KEY NOT NULL,\n\t\"output\" jsonb,\n\t\"deployment_id\" varchar NOT NULL,\n\t\"status\" \"status\" NOT NULL,\n\t\"name\" varchar NOT NULL,\n\t\"execution_context\" jsonb,\n\t\"input\" jsonb NOT NULL,\n\t\"error\" text,\n\t\"error_code\" varchar,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp DEFAULT now() NOT NULL,\n\t\"completed_at\" timestamp,\n\t\"started_at\" timestamp\n);\n--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_steps\" (\n\t\"run_id\" varchar NOT NULL,\n\t\"step_id\" varchar PRIMARY KEY NOT NULL,\n\t\"step_name\" varchar NOT NULL,\n\t\"status\" \"step_status\" NOT NULL,\n\t\"input\" jsonb NOT NULL,\n\t\"output\" jsonb,\n\t\"error\" text,\n\t\"error_code\" varchar,\n\t\"attempt\" integer NOT NULL,\n\t\"started_at\" timestamp,\n\t\"completed_at\" timestamp,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp DEFAULT now() NOT NULL,\n\t\"retry_after\" timestamp\n);\n--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_stream_chunks\" (\n\t\"id\" varchar NOT NULL,\n\t\"stream_id\" varchar NOT NULL,\n\t\"data\" \"bytea\" NOT NULL,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"eof\" boolean NOT NULL,\n\tCONSTRAINT \"workflow_stream_chunks_stream_id_id_pk\" PRIMARY KEY(\"stream_id\",\"id\")\n);\n--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_events_run_id_index\" ON \"workflow\".\"workflow_events\" USING btree (\"run_id\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_events_correlation_id_index\" ON \"workflow\".\"workflow_events\" USING btree (\"correlation_id\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_hooks_run_id_index\" ON \"workflow\".\"workflow_hooks\" USING btree (\"run_id\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_hooks_token_index\" ON \"workflow\".\"workflow_hooks\" USING btree (\"token\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_runs_name_index\" ON \"workflow\".\"workflow_runs\" USING btree (\"name\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_runs_status_index\" ON \"workflow\".\"workflow_runs\" USING btree (\"status\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_steps_run_id_index\" ON \"workflow\".\"workflow_steps\" USING btree (\"run_id\");--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_steps_status_index\" ON \"workflow\".\"workflow_steps\" USING btree (\"status\");\n",
6
+ "0001_tricky_sersi.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ALTER COLUMN \"input\" DROP NOT NULL;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" ALTER COLUMN \"input\" DROP NOT NULL;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_events\" ADD COLUMN \"payload_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"metadata_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"output_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"execution_context_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"input_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" ADD COLUMN \"input_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" ADD COLUMN \"output_cbor\" \"bytea\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" DROP COLUMN \"error_code\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" DROP COLUMN \"error_code\";",
7
+ "0002_add_expired_at.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"expired_at\" timestamp;\n\n",
8
+ "0003_add_stream_run_id.sql": "ALTER TABLE \"workflow\".\"workflow_stream_chunks\" ADD COLUMN \"run_id\" varchar;--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_stream_chunks_run_id_index\" ON \"workflow\".\"workflow_stream_chunks\" USING btree (\"run_id\");\n\n",
9
+ "0004_remove_run_pause_status.sql": "-- Update any paused runs to cancelled\nUPDATE \"workflow\".\"workflow_runs\" SET \"status\" = 'cancelled' WHERE \"status\" = 'paused';\n--> statement-breakpoint\n-- Create new enum type without 'paused'\nCREATE TYPE \"public\".\"status_new\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');\n--> statement-breakpoint\n-- Alter column to use new type\nALTER TABLE \"workflow\".\"workflow_runs\" ALTER COLUMN \"status\" TYPE \"public\".\"status_new\" USING \"status\"::text::\"public\".\"status_new\";\n--> statement-breakpoint\n-- Drop old enum type\nDROP TYPE \"public\".\"status\";\n--> statement-breakpoint\n-- Rename new enum type to original name\nALTER TYPE \"public\".\"status_new\" RENAME TO \"status\";\n",
10
+ "0005_add_spec_version.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ALTER COLUMN \"status\" SET DATA TYPE text;--> statement-breakpoint\nDROP TYPE \"public\".\"status\";--> statement-breakpoint\nCREATE TYPE \"public\".\"status\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" ALTER COLUMN \"status\" SET DATA TYPE \"public\".\"status\" USING \"status\"::\"public\".\"status\";--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"spec_version\" varchar;",
11
+ "0006_add_error_cbor.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"error_cbor\" bytea;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" ADD COLUMN \"error_cbor\" bytea;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_steps\" ADD COLUMN \"spec_version\" integer;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"spec_version\" integer;--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_events\" ADD COLUMN \"spec_version\" integer;\n",
12
+ "0007_add_waits_table.sql": "CREATE TYPE \"public\".\"wait_status\" AS ENUM('waiting', 'completed');--> statement-breakpoint\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_waits\" (\n\t\"wait_id\" varchar PRIMARY KEY NOT NULL,\n\t\"run_id\" varchar NOT NULL,\n\t\"status\" \"wait_status\" NOT NULL,\n\t\"resume_at\" timestamp,\n\t\"completed_at\" timestamp,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL,\n\t\"updated_at\" timestamp DEFAULT now() NOT NULL,\n\t\"spec_version\" integer\n);\n--> statement-breakpoint\nCREATE INDEX IF NOT EXISTS \"workflow_waits_run_id_index\" ON \"workflow\".\"workflow_waits\" USING btree (\"run_id\");\n",
13
+ "0008_migrate_pgboss_to_graphile.sql": "-- Migrate pending pg-boss jobs to a staging table before dropping the pgboss schema.\n-- The application code will re-enqueue these jobs into graphile-worker on first start.\nDO $$\nBEGIN\n IF EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'pgboss') THEN\n CREATE TABLE IF NOT EXISTS \"workflow\".\"_pgboss_pending_jobs\" (\n name text NOT NULL,\n data jsonb,\n singleton_key text,\n retry_limit integer\n );\n\n INSERT INTO \"workflow\".\"_pgboss_pending_jobs\" (name, data, singleton_key, retry_limit)\n SELECT name, data, singleton_key, retry_limit\n FROM pgboss.job\n WHERE state IN ('created', 'retry');\n\n DROP SCHEMA pgboss CASCADE;\n END IF;\nEND $$;\n",
14
+ "0009_add_is_webhook.sql": "ALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"is_webhook\" boolean DEFAULT true;",
15
+ "0010_add_events_entity_creation_unique_index.sql": "-- Enforce uniqueness of (run_id, correlation_id, event_type) for the\n-- entity-creating events (step_created, hook_created, wait_created).\n--\n-- Without this constraint, two concurrent runtime invocations producing\n-- identical correlationIds (e.g. the snapshot runtime's deterministic\n-- ULIDs across replays of the same resumption) can both insert events,\n-- causing duplicate step/hook/wait events in the log. The unique\n-- violation is caught in events.create and surfaced as\n-- EntityConflictError, which the runtime already handles as a dedup\n-- signal.\n--\n-- Existing installations may already contain duplicate\n-- (run_id, correlation_id, type) rows for these event types — the\n-- previous storage behavior allowed them through. Deduplicate before\n-- creating the unique partial index, otherwise the CREATE UNIQUE INDEX\n-- statement would fail at migration time. We keep the earliest-inserted\n-- row for each (run_id, correlation_id, type) tuple (lowest ctid) and\n-- drop the rest. The duplicates that this removes are exactly the rows\n-- that would have been rejected as `EntityConflictError` had the unique\n-- index existed when they were inserted.\nWITH \"ranked_workflow_events\" AS (\n\tSELECT\n\t\tctid,\n\t\tROW_NUMBER() OVER (\n\t\t\tPARTITION BY \"run_id\", \"correlation_id\", \"type\"\n\t\t\tORDER BY ctid\n\t\t) AS \"row_num\"\n\tFROM \"workflow\".\"workflow_events\"\n\tWHERE \"type\" IN ('step_created', 'hook_created', 'wait_created')\n)\nDELETE FROM \"workflow\".\"workflow_events\"\nWHERE ctid IN (\n\tSELECT ctid\n\tFROM \"ranked_workflow_events\"\n\tWHERE \"row_num\" > 1\n);\n\nCREATE UNIQUE INDEX IF NOT EXISTS \"workflow_events_entity_creation_unique\"\n\tON \"workflow\".\"workflow_events\" (\"run_id\", \"correlation_id\", \"type\")\n\tWHERE \"type\" IN ('step_created', 'hook_created', 'wait_created');\n",
16
+ "0011_add_error_code.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"error_code\" varchar;\n",
17
+ "0012_add_is_system.sql": "ALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"is_system\" boolean DEFAULT false;\n",
18
+ "0013_add_attributes.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"attributes\" jsonb DEFAULT '{}'::jsonb NOT NULL;\n",
19
+ "0014_add_attr_set_event_unique_index.sql": "DROP INDEX IF EXISTS \"workflow\".\"workflow_events_entity_creation_unique\";\n\nCREATE UNIQUE INDEX IF NOT EXISTS \"workflow_events_entity_creation_unique\"\n\tON \"workflow\".\"workflow_events\" (\"run_id\", \"correlation_id\", \"type\")\n\tWHERE \"type\" IN ('step_created', 'hook_created', 'wait_created', 'attr_set');\n",
20
+ "0015_move_enums_to_workflow_schema.sql": "DO $$\nDECLARE\n enum_name text;\n public_enum regtype;\n workflow_enum regtype;\n is_used_by_workflow_columns boolean;\n has_dependents_outside_workflow_tables boolean;\nBEGIN\n FOREACH enum_name IN ARRAY ARRAY['status', 'step_status', 'wait_status'] LOOP\n public_enum := to_regtype(format('public.%I', enum_name));\n workflow_enum := to_regtype(format('workflow.%I', enum_name));\n\n -- Nothing to migrate when the legacy public enum does not exist, or when\n -- the enum has already been moved to the workflow schema.\n IF public_enum IS NULL OR workflow_enum IS NOT NULL THEN\n CONTINUE;\n END IF;\n\n -- Only move enums that are actually used by workflow table columns.\n -- pg_depend has an index on referenced objects, so this lookup is based\n -- on the enum type OID instead of scanning user data or workflow rows.\n SELECT EXISTS (\n SELECT 1\n FROM pg_depend dependency\n JOIN pg_class dependent_table\n ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid\n JOIN pg_namespace dependent_table_schema\n ON dependent_table_schema.oid = dependent_table.relnamespace\n WHERE dependency.refclassid = 'pg_type'::regclass\n AND dependency.refobjid = public_enum::oid\n AND dependency.objsubid > 0\n AND dependency.deptype != 'i'\n AND dependent_table_schema.nspname = 'workflow'\n ) INTO is_used_by_workflow_columns;\n\n IF NOT is_used_by_workflow_columns THEN\n CONTINUE;\n END IF;\n\n /*\n pg_depend is Postgres' dependency graph.\n\n We use it here as a safety check before moving the enum object itself.\n A normal workflow-owned enum has only workflow table-column dependents,\n so ALTER TYPE ... SET SCHEMA is a fast metadata change.\n\n If anything outside workflow tables also depends on this enum, moving it\n would silently rename that user's public enum to workflow.<enum_name>.\n In that case, leave the enum in public, warn, and continue so this cleanup\n migration does not block later migrations.\n */\n SELECT EXISTS (\n SELECT 1\n FROM pg_depend dependency\n LEFT JOIN pg_class dependent_table\n ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid\n LEFT JOIN pg_namespace dependent_table_schema\n ON dependent_table_schema.oid = dependent_table.relnamespace\n WHERE dependency.refclassid = 'pg_type'::regclass\n AND dependency.refobjid = public_enum::oid\n AND dependency.deptype != 'i'\n AND NOT (\n dependency.classid = 'pg_class'::regclass\n AND dependent_table_schema.nspname = 'workflow'\n )\n ) INTO has_dependents_outside_workflow_tables;\n\n IF has_dependents_outside_workflow_tables THEN\n RAISE WARNING 'Skipping move of public.% to workflow schema because objects outside workflow tables depend on it', enum_name;\n CONTINUE;\n END IF;\n\n EXECUTE format('ALTER TYPE public.%I SET SCHEMA workflow', enum_name);\n END LOOP;\nEND $$;\n",
21
+ "0016_add_encryption_public_key.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"encryption_public_key\" varchar;\n",
22
+ "0017_add_hook_resume_context.sql": "ALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"resume_context\" bytea;\n",
23
+ "0018_add_hook_token_retention.sql": "ALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"token_retention_until\" timestamp with time zone;\n",
24
+ "0019_add_event_slots.sql": "-- Event ids become per-run slot positions (`evnt_` + a zero-padded decimal),\n-- so an id is only unique together with its run. Runs created before this keep\n-- their globally-unique ULIDs, which the composite key also admits.\n--\n-- LOCKING. Replacing a primary key takes ACCESS EXCLUSIVE on\n-- `workflow.workflow_events`, which blocks reads as well as writes, and the\n-- migrator runs every pending migration in one transaction, so the lock is held\n-- until all of them commit. Building the new key's index under that lock is the\n-- part that grows with the table. On an empty or modest table this is\n-- instantaneous and needs no thought.\n--\n-- On a large existing table, build the index first, outside the migrator, and\n-- this migration adopts it instead of building its own:\n--\n-- CREATE UNIQUE INDEX CONCURRENTLY \"workflow_events_run_id_id_idx\"\n-- ON \"workflow\".\"workflow_events\" (\"run_id\", \"id\");\n--\n-- `CONCURRENTLY` cannot appear in this file: Postgres rejects it inside a\n-- transaction block. Run it by hand, confirm the index came out valid, then\n-- migrate. The branch below picks it up, and the exclusive lock then covers\n-- only a catalog update rather than a full build. Adopting an index renames it\n-- to the constraint's name, so it ends up as `workflow_events_run_id_id_pk`\n-- either way and the two paths leave the same schema behind.\n-- Bound the wait for that lock. A pending ACCESS EXCLUSIVE queues ahead of\n-- every lock request that arrives after it, so waiting on one long-running\n-- reader stalls all traffic to the table for as long as the wait lasts. Ten\n-- seconds of that is a blip; an unbounded wait is an outage. Failing instead\n-- leaves the migration unapplied and retryable. Raise it by hand for a\n-- maintenance window.\n--\n-- `SET LOCAL` lasts for the transaction, and the migrator runs every pending\n-- migration in one, so a migration that follows this one in the same batch\n-- inherits the timeout.\nSET LOCAL lock_timeout = '10s';--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_events\" DROP CONSTRAINT \"workflow_events_pkey\";--> statement-breakpoint\nDO $$\nBEGIN\n IF EXISTS (\n SELECT 1\n FROM pg_class c\n JOIN pg_namespace n ON n.oid = c.relnamespace\n JOIN pg_index i ON i.indexrelid = c.oid\n WHERE n.nspname = 'workflow'\n AND c.relname = 'workflow_events_run_id_id_idx'\n AND c.relkind = 'i'\n AND i.indisunique\n AND i.indisvalid\n ) THEN\n ALTER TABLE \"workflow\".\"workflow_events\"\n ADD CONSTRAINT \"workflow_events_run_id_id_pk\"\n PRIMARY KEY USING INDEX \"workflow_events_run_id_id_idx\";\n ELSE\n -- A `CREATE UNIQUE INDEX CONCURRENTLY` that failed leaves an index of this\n -- name behind marked invalid. The branch above rejects it, and the key\n -- built here is a different index under a different name, so without this\n -- the invalid one would survive the migration: never used by a plan, still\n -- maintained on every insert. Dropping it also makes a second attempt at\n -- the concurrent build possible without a manual cleanup first.\n DROP INDEX IF EXISTS \"workflow\".\"workflow_events_run_id_id_idx\";\n ALTER TABLE \"workflow\".\"workflow_events\"\n ADD CONSTRAINT \"workflow_events_run_id_id_pk\" PRIMARY KEY (\"run_id\",\"id\");\n END IF;\nEND $$;--> statement-breakpoint\n-- Redundant once the primary key leads with `run_id`: that index serves every\n-- by-run lookup and range scan this one did, so keeping it only costs a second\n-- write per event on the table's hottest path.\nDROP INDEX IF EXISTS \"workflow\".\"workflow_events_run_id_index\";--> statement-breakpoint\n-- One row per slot-numbered run. Its absence is the \"this run predates slots\"\n-- signal, so no backfill: existing runs stay on ULIDs for the rest of their\n-- lives. A marker only: positions are allocated by the insert that occupies\n-- them, read from the event log itself.\nCREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_event_slots\" (\n\t\"run_id\" varchar PRIMARY KEY NOT NULL\n);\n",
25
+ "0020_add_invocations.sql": "CREATE TABLE \"workflow\".\"workflow_invocations\" (\n \"sequence\" bigserial NOT NULL,\n \"run_id\" varchar NOT NULL,\n \"request_id\" varchar NOT NULL,\n \"payload\" bytea NOT NULL,\n \"fingerprint\" varchar NOT NULL,\n \"result\" bytea,\n \"created_at\" timestamp DEFAULT now() NOT NULL,\n \"responded_at\" timestamp,\n PRIMARY KEY (\"run_id\", \"request_id\")\n);\n--> statement-breakpoint\nCREATE INDEX \"workflow_invocations_pending\" ON \"workflow\".\"workflow_invocations\" (\"run_id\", \"sequence\") WHERE \"responded_at\" IS NULL;\n",
26
+ "0021_invocation_identity_retention.sql": "ALTER TABLE \"workflow\".\"workflow_events\" ADD COLUMN \"resume_id\" varchar;\n--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_events\" ADD COLUMN \"resume_payload_digest\" varchar;\n--> statement-breakpoint\nCREATE UNIQUE INDEX \"workflow_events_hook_resume_unique\" ON \"workflow\".\"workflow_events\" (\"run_id\", \"resume_id\") WHERE \"type\" = 'hook_received' AND \"resume_id\" IS NOT NULL;\n--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_invocations\" ALTER COLUMN \"payload\" DROP NOT NULL;\n--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_invocations\" ALTER COLUMN \"fingerprint\" DROP NOT NULL;\n--> statement-breakpoint\nALTER TABLE \"workflow\".\"workflow_invocations\" ADD COLUMN \"expired_at\" timestamp;\n--> statement-breakpoint\nUPDATE \"workflow\".\"workflow_invocations\" AS invocation\nSET \"payload\" = NULL, \"result\" = NULL, \"fingerprint\" = NULL,\n \"expired_at\" = coalesce(invocation.expired_at, run.expired_at, now())\nFROM \"workflow\".\"workflow_runs\" AS run\nWHERE invocation.run_id = run.id\n AND (run.expired_at IS NOT NULL OR\n (run.status IN ('completed', 'failed', 'cancelled') AND run.attributes -> '$retention' = '\"0\"'::jsonb));\n",
27
+ "0022_invocation_outcomes.sql": "-- Distinguish arbitrary legacy return values from versioned outcome envelopes.\nALTER TABLE \"workflow\".\"workflow_invocations\"\n ADD COLUMN IF NOT EXISTS \"result_version\" integer NOT NULL DEFAULT 0;\n",
28
+ "0023_add_hook_claimed_from.sql": "ALTER TABLE \"workflow\".\"workflow_hooks\" ADD COLUMN \"claimed_from\" bytea;\n",
29
+ "0024_add_dynamic_workflow_code.sql": "ALTER TABLE \"workflow\".\"workflow_runs\" ADD COLUMN \"dynamic_workflow_code_cbor\" bytea;\n",
30
+ "0025_add_snapshots_table.sql": "CREATE TABLE IF NOT EXISTS \"workflow\".\"workflow_snapshots\" (\n\t\"run_id\" varchar PRIMARY KEY NOT NULL,\n\t\"data\" \"bytea\" NOT NULL,\n\t\"events_cursor\" varchar,\n\t\"created_at\" timestamp DEFAULT now() NOT NULL\n);\n",
31
+ "0026_add_seq_in_band.sql": "-- The in-band writer fence for single-orchestrator runs: how many positions\n-- the run's orchestrator writes have been accepted for, `run_created`\n-- included. Every existing run starts at 1, the value a run with no fenced\n-- write has; only single-orchestrator runs ever advance it.\nALTER TABLE \"workflow\".\"workflow_event_slots\" ADD COLUMN IF NOT EXISTS \"seq_in_band\" integer DEFAULT 1 NOT NULL;\n"
32
+ }
33
+ };
34
+ //# sourceMappingURL=migrations.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.generated.js","sourceRoot":"","sources":["../../src/workflow/migrations.generated.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,kBAAkB,GAAuB;IACpD,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,4jJAA4jJ;IACvkJ,OAAO,EAAE;QACP,iCAAiC,EAAE,uqHAAuqH;QAC1sH,uBAAuB,EAAE,qnCAAqnC;QAC9oC,yBAAyB,EAAE,qFAAqF;QAChH,4BAA4B,EAAE,yPAAyP;QACvR,kCAAkC,EAAE,6tBAA6tB;QACjwB,2BAA2B,EAAE,kiBAAkiB;QAC/jB,yBAAyB,EAAE,ofAAof;QAC/gB,0BAA0B,EAAE,4mBAA4mB;QACxoB,qCAAqC,EAAE,0tBAA0tB;QACjwB,yBAAyB,EAAE,6FAA6F;QACxH,kDAAkD,EAAE,m0DAAm0D;QACv3D,yBAAyB,EAAE,iFAAiF;QAC5G,wBAAwB,EAAE,+FAA+F;QACzH,yBAAyB,EAAE,4GAA4G;QACvI,0CAA0C,EAAE,sUAAsU;QAClX,wCAAwC,EAAE,+iGAA+iG;QACzlG,oCAAoC,EAAE,4FAA4F;QAClI,kCAAkC,EAAE,oFAAoF;QACxH,mCAAmC,EAAE,8GAA8G;QACnJ,0BAA0B,EAAE,+/HAA+/H;QAC3hI,0BAA0B,EAAE,yiBAAyiB;QACrkB,wCAAwC,EAAE,4sCAA4sC;QACtvC,8BAA8B,EAAE,iNAAiN;QACjP,gCAAgC,EAAE,kFAAkF;QACpH,oCAAoC,EAAE,+FAA+F;QACrI,8BAA8B,EAAE,qOAAqO;QACrQ,0BAA0B,EAAE,2ZAA2Z;KACxb;CACF,CAAC","sourcesContent":["// GENERATED by scripts/embed-migrations.ts from @workflow/world-postgres@5.0.4.\n// Do not edit: run `bun run embed-migrations` after bumping the devDependency.\nimport type { WorkflowMigrations } from \"./migration-types.js\";\n\nexport const embeddedMigrations: WorkflowMigrations = {\n \"version\": \"5.0.4\",\n \"journal\": \"{\\n \\\"version\\\": \\\"7\\\",\\n \\\"dialect\\\": \\\"postgresql\\\",\\n \\\"entries\\\": [\\n {\\n \\\"idx\\\": 0,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1762873019948,\\n \\\"tag\\\": \\\"0000_cultured_the_anarchist\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 1,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1763903867386,\\n \\\"tag\\\": \\\"0001_tricky_sersi\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 2,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1764815363008,\\n \\\"tag\\\": \\\"0002_add_expired_at\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 3,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1765900000000,\\n \\\"tag\\\": \\\"0003_add_stream_run_id\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 4,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1765900000001,\\n \\\"tag\\\": \\\"0004_remove_run_pause_status\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 5,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1767723210726,\\n \\\"tag\\\": \\\"0005_add_spec_version\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 6,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1768500000000,\\n \\\"tag\\\": \\\"0006_add_error_cbor\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 7,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1769500000000,\\n \\\"tag\\\": \\\"0007_add_waits_table\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 8,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1770000000000,\\n \\\"tag\\\": \\\"0008_migrate_pgboss_to_graphile\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 9,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1770500000000,\\n \\\"tag\\\": \\\"0009_add_is_webhook\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 10,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1771000000000,\\n \\\"tag\\\": \\\"0010_add_events_entity_creation_unique_index\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 11,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1771500000000,\\n \\\"tag\\\": \\\"0011_add_error_code\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 12,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1775600000000,\\n \\\"tag\\\": \\\"0012_add_is_system\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 13,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1779609600000,\\n \\\"tag\\\": \\\"0013_add_attributes\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 14,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1780185600000,\\n \\\"tag\\\": \\\"0014_add_attr_set_event_unique_index\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 15,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1782691200000,\\n \\\"tag\\\": \\\"0015_move_enums_to_workflow_schema\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 16,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1784937600000,\\n \\\"tag\\\": \\\"0016_add_encryption_public_key\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 17,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1785283200000,\\n \\\"tag\\\": \\\"0017_add_hook_resume_context\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 18,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1785619990000,\\n \\\"tag\\\": \\\"0018_add_hook_token_retention\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 19,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1786060800000,\\n \\\"tag\\\": \\\"0019_add_event_slots\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 20,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789430400000,\\n \\\"tag\\\": \\\"0020_add_invocations\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 21,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789516800000,\\n \\\"tag\\\": \\\"0021_invocation_identity_retention\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 22,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789603200000,\\n \\\"tag\\\": \\\"0022_invocation_outcomes\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 23,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789689600000,\\n \\\"tag\\\": \\\"0023_add_hook_claimed_from\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 24,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789776000000,\\n \\\"tag\\\": \\\"0024_add_dynamic_workflow_code\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 25,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789862400000,\\n \\\"tag\\\": \\\"0025_add_snapshots_table\\\",\\n \\\"breakpoints\\\": true\\n },\\n {\\n \\\"idx\\\": 26,\\n \\\"version\\\": \\\"7\\\",\\n \\\"when\\\": 1789948800000,\\n \\\"tag\\\": \\\"0026_add_seq_in_band\\\",\\n \\\"breakpoints\\\": true\\n }\\n ]\\n}\\n\",\n \"files\": {\n \"0000_cultured_the_anarchist.sql\": \"CREATE SCHEMA \\\"workflow\\\";\\n--> statement-breakpoint\\nDO $$ BEGIN\\n CREATE TYPE \\\"public\\\".\\\"step_status\\\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n--> statement-breakpoint\\nDO $$ BEGIN\\n CREATE TYPE \\\"public\\\".\\\"status\\\" AS ENUM('pending', 'running', 'completed', 'failed', 'paused', 'cancelled');\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_events\\\" (\\n\\t\\\"id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"type\\\" varchar NOT NULL,\\n\\t\\\"correlation_id\\\" varchar,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"run_id\\\" varchar NOT NULL,\\n\\t\\\"payload\\\" jsonb\\n);\\n--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_hooks\\\" (\\n\\t\\\"run_id\\\" varchar NOT NULL,\\n\\t\\\"hook_id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"token\\\" varchar NOT NULL,\\n\\t\\\"owner_id\\\" varchar NOT NULL,\\n\\t\\\"project_id\\\" varchar NOT NULL,\\n\\t\\\"environment\\\" varchar NOT NULL,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"metadata\\\" jsonb\\n);\\n--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_runs\\\" (\\n\\t\\\"id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"output\\\" jsonb,\\n\\t\\\"deployment_id\\\" varchar NOT NULL,\\n\\t\\\"status\\\" \\\"status\\\" NOT NULL,\\n\\t\\\"name\\\" varchar NOT NULL,\\n\\t\\\"execution_context\\\" jsonb,\\n\\t\\\"input\\\" jsonb NOT NULL,\\n\\t\\\"error\\\" text,\\n\\t\\\"error_code\\\" varchar,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"updated_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"completed_at\\\" timestamp,\\n\\t\\\"started_at\\\" timestamp\\n);\\n--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_steps\\\" (\\n\\t\\\"run_id\\\" varchar NOT NULL,\\n\\t\\\"step_id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"step_name\\\" varchar NOT NULL,\\n\\t\\\"status\\\" \\\"step_status\\\" NOT NULL,\\n\\t\\\"input\\\" jsonb NOT NULL,\\n\\t\\\"output\\\" jsonb,\\n\\t\\\"error\\\" text,\\n\\t\\\"error_code\\\" varchar,\\n\\t\\\"attempt\\\" integer NOT NULL,\\n\\t\\\"started_at\\\" timestamp,\\n\\t\\\"completed_at\\\" timestamp,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"updated_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"retry_after\\\" timestamp\\n);\\n--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_stream_chunks\\\" (\\n\\t\\\"id\\\" varchar NOT NULL,\\n\\t\\\"stream_id\\\" varchar NOT NULL,\\n\\t\\\"data\\\" \\\"bytea\\\" NOT NULL,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"eof\\\" boolean NOT NULL,\\n\\tCONSTRAINT \\\"workflow_stream_chunks_stream_id_id_pk\\\" PRIMARY KEY(\\\"stream_id\\\",\\\"id\\\")\\n);\\n--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_events_run_id_index\\\" ON \\\"workflow\\\".\\\"workflow_events\\\" USING btree (\\\"run_id\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_events_correlation_id_index\\\" ON \\\"workflow\\\".\\\"workflow_events\\\" USING btree (\\\"correlation_id\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_hooks_run_id_index\\\" ON \\\"workflow\\\".\\\"workflow_hooks\\\" USING btree (\\\"run_id\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_hooks_token_index\\\" ON \\\"workflow\\\".\\\"workflow_hooks\\\" USING btree (\\\"token\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_runs_name_index\\\" ON \\\"workflow\\\".\\\"workflow_runs\\\" USING btree (\\\"name\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_runs_status_index\\\" ON \\\"workflow\\\".\\\"workflow_runs\\\" USING btree (\\\"status\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_steps_run_id_index\\\" ON \\\"workflow\\\".\\\"workflow_steps\\\" USING btree (\\\"run_id\\\");--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_steps_status_index\\\" ON \\\"workflow\\\".\\\"workflow_steps\\\" USING btree (\\\"status\\\");\\n\",\n \"0001_tricky_sersi.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ALTER COLUMN \\\"input\\\" DROP NOT NULL;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" ALTER COLUMN \\\"input\\\" DROP NOT NULL;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\" ADD COLUMN \\\"payload_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"metadata_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"output_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"execution_context_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"input_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" ADD COLUMN \\\"input_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" ADD COLUMN \\\"output_cbor\\\" \\\"bytea\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" DROP COLUMN \\\"error_code\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" DROP COLUMN \\\"error_code\\\";\",\n \"0002_add_expired_at.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"expired_at\\\" timestamp;\\n\\n\",\n \"0003_add_stream_run_id.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_stream_chunks\\\" ADD COLUMN \\\"run_id\\\" varchar;--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_stream_chunks_run_id_index\\\" ON \\\"workflow\\\".\\\"workflow_stream_chunks\\\" USING btree (\\\"run_id\\\");\\n\\n\",\n \"0004_remove_run_pause_status.sql\": \"-- Update any paused runs to cancelled\\nUPDATE \\\"workflow\\\".\\\"workflow_runs\\\" SET \\\"status\\\" = 'cancelled' WHERE \\\"status\\\" = 'paused';\\n--> statement-breakpoint\\n-- Create new enum type without 'paused'\\nCREATE TYPE \\\"public\\\".\\\"status_new\\\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');\\n--> statement-breakpoint\\n-- Alter column to use new type\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ALTER COLUMN \\\"status\\\" TYPE \\\"public\\\".\\\"status_new\\\" USING \\\"status\\\"::text::\\\"public\\\".\\\"status_new\\\";\\n--> statement-breakpoint\\n-- Drop old enum type\\nDROP TYPE \\\"public\\\".\\\"status\\\";\\n--> statement-breakpoint\\n-- Rename new enum type to original name\\nALTER TYPE \\\"public\\\".\\\"status_new\\\" RENAME TO \\\"status\\\";\\n\",\n \"0005_add_spec_version.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ALTER COLUMN \\\"status\\\" SET DATA TYPE text;--> statement-breakpoint\\nDROP TYPE \\\"public\\\".\\\"status\\\";--> statement-breakpoint\\nCREATE TYPE \\\"public\\\".\\\"status\\\" AS ENUM('pending', 'running', 'completed', 'failed', 'cancelled');--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ALTER COLUMN \\\"status\\\" SET DATA TYPE \\\"public\\\".\\\"status\\\" USING \\\"status\\\"::\\\"public\\\".\\\"status\\\";--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"spec_version\\\" varchar;\",\n \"0006_add_error_cbor.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"error_cbor\\\" bytea;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" ADD COLUMN \\\"error_cbor\\\" bytea;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_steps\\\" ADD COLUMN \\\"spec_version\\\" integer;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"spec_version\\\" integer;--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\" ADD COLUMN \\\"spec_version\\\" integer;\\n\",\n \"0007_add_waits_table.sql\": \"CREATE TYPE \\\"public\\\".\\\"wait_status\\\" AS ENUM('waiting', 'completed');--> statement-breakpoint\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_waits\\\" (\\n\\t\\\"wait_id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"run_id\\\" varchar NOT NULL,\\n\\t\\\"status\\\" \\\"wait_status\\\" NOT NULL,\\n\\t\\\"resume_at\\\" timestamp,\\n\\t\\\"completed_at\\\" timestamp,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"updated_at\\\" timestamp DEFAULT now() NOT NULL,\\n\\t\\\"spec_version\\\" integer\\n);\\n--> statement-breakpoint\\nCREATE INDEX IF NOT EXISTS \\\"workflow_waits_run_id_index\\\" ON \\\"workflow\\\".\\\"workflow_waits\\\" USING btree (\\\"run_id\\\");\\n\",\n \"0008_migrate_pgboss_to_graphile.sql\": \"-- Migrate pending pg-boss jobs to a staging table before dropping the pgboss schema.\\n-- The application code will re-enqueue these jobs into graphile-worker on first start.\\nDO $$\\nBEGIN\\n IF EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'pgboss') THEN\\n CREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"_pgboss_pending_jobs\\\" (\\n name text NOT NULL,\\n data jsonb,\\n singleton_key text,\\n retry_limit integer\\n );\\n\\n INSERT INTO \\\"workflow\\\".\\\"_pgboss_pending_jobs\\\" (name, data, singleton_key, retry_limit)\\n SELECT name, data, singleton_key, retry_limit\\n FROM pgboss.job\\n WHERE state IN ('created', 'retry');\\n\\n DROP SCHEMA pgboss CASCADE;\\n END IF;\\nEND $$;\\n\",\n \"0009_add_is_webhook.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"is_webhook\\\" boolean DEFAULT true;\",\n \"0010_add_events_entity_creation_unique_index.sql\": \"-- Enforce uniqueness of (run_id, correlation_id, event_type) for the\\n-- entity-creating events (step_created, hook_created, wait_created).\\n--\\n-- Without this constraint, two concurrent runtime invocations producing\\n-- identical correlationIds (e.g. the snapshot runtime's deterministic\\n-- ULIDs across replays of the same resumption) can both insert events,\\n-- causing duplicate step/hook/wait events in the log. The unique\\n-- violation is caught in events.create and surfaced as\\n-- EntityConflictError, which the runtime already handles as a dedup\\n-- signal.\\n--\\n-- Existing installations may already contain duplicate\\n-- (run_id, correlation_id, type) rows for these event types — the\\n-- previous storage behavior allowed them through. Deduplicate before\\n-- creating the unique partial index, otherwise the CREATE UNIQUE INDEX\\n-- statement would fail at migration time. We keep the earliest-inserted\\n-- row for each (run_id, correlation_id, type) tuple (lowest ctid) and\\n-- drop the rest. The duplicates that this removes are exactly the rows\\n-- that would have been rejected as `EntityConflictError` had the unique\\n-- index existed when they were inserted.\\nWITH \\\"ranked_workflow_events\\\" AS (\\n\\tSELECT\\n\\t\\tctid,\\n\\t\\tROW_NUMBER() OVER (\\n\\t\\t\\tPARTITION BY \\\"run_id\\\", \\\"correlation_id\\\", \\\"type\\\"\\n\\t\\t\\tORDER BY ctid\\n\\t\\t) AS \\\"row_num\\\"\\n\\tFROM \\\"workflow\\\".\\\"workflow_events\\\"\\n\\tWHERE \\\"type\\\" IN ('step_created', 'hook_created', 'wait_created')\\n)\\nDELETE FROM \\\"workflow\\\".\\\"workflow_events\\\"\\nWHERE ctid IN (\\n\\tSELECT ctid\\n\\tFROM \\\"ranked_workflow_events\\\"\\n\\tWHERE \\\"row_num\\\" > 1\\n);\\n\\nCREATE UNIQUE INDEX IF NOT EXISTS \\\"workflow_events_entity_creation_unique\\\"\\n\\tON \\\"workflow\\\".\\\"workflow_events\\\" (\\\"run_id\\\", \\\"correlation_id\\\", \\\"type\\\")\\n\\tWHERE \\\"type\\\" IN ('step_created', 'hook_created', 'wait_created');\\n\",\n \"0011_add_error_code.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"error_code\\\" varchar;\\n\",\n \"0012_add_is_system.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"is_system\\\" boolean DEFAULT false;\\n\",\n \"0013_add_attributes.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"attributes\\\" jsonb DEFAULT '{}'::jsonb NOT NULL;\\n\",\n \"0014_add_attr_set_event_unique_index.sql\": \"DROP INDEX IF EXISTS \\\"workflow\\\".\\\"workflow_events_entity_creation_unique\\\";\\n\\nCREATE UNIQUE INDEX IF NOT EXISTS \\\"workflow_events_entity_creation_unique\\\"\\n\\tON \\\"workflow\\\".\\\"workflow_events\\\" (\\\"run_id\\\", \\\"correlation_id\\\", \\\"type\\\")\\n\\tWHERE \\\"type\\\" IN ('step_created', 'hook_created', 'wait_created', 'attr_set');\\n\",\n \"0015_move_enums_to_workflow_schema.sql\": \"DO $$\\nDECLARE\\n enum_name text;\\n public_enum regtype;\\n workflow_enum regtype;\\n is_used_by_workflow_columns boolean;\\n has_dependents_outside_workflow_tables boolean;\\nBEGIN\\n FOREACH enum_name IN ARRAY ARRAY['status', 'step_status', 'wait_status'] LOOP\\n public_enum := to_regtype(format('public.%I', enum_name));\\n workflow_enum := to_regtype(format('workflow.%I', enum_name));\\n\\n -- Nothing to migrate when the legacy public enum does not exist, or when\\n -- the enum has already been moved to the workflow schema.\\n IF public_enum IS NULL OR workflow_enum IS NOT NULL THEN\\n CONTINUE;\\n END IF;\\n\\n -- Only move enums that are actually used by workflow table columns.\\n -- pg_depend has an index on referenced objects, so this lookup is based\\n -- on the enum type OID instead of scanning user data or workflow rows.\\n SELECT EXISTS (\\n SELECT 1\\n FROM pg_depend dependency\\n JOIN pg_class dependent_table\\n ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid\\n JOIN pg_namespace dependent_table_schema\\n ON dependent_table_schema.oid = dependent_table.relnamespace\\n WHERE dependency.refclassid = 'pg_type'::regclass\\n AND dependency.refobjid = public_enum::oid\\n AND dependency.objsubid > 0\\n AND dependency.deptype != 'i'\\n AND dependent_table_schema.nspname = 'workflow'\\n ) INTO is_used_by_workflow_columns;\\n\\n IF NOT is_used_by_workflow_columns THEN\\n CONTINUE;\\n END IF;\\n\\n /*\\n pg_depend is Postgres' dependency graph.\\n\\n We use it here as a safety check before moving the enum object itself.\\n A normal workflow-owned enum has only workflow table-column dependents,\\n so ALTER TYPE ... SET SCHEMA is a fast metadata change.\\n\\n If anything outside workflow tables also depends on this enum, moving it\\n would silently rename that user's public enum to workflow.<enum_name>.\\n In that case, leave the enum in public, warn, and continue so this cleanup\\n migration does not block later migrations.\\n */\\n SELECT EXISTS (\\n SELECT 1\\n FROM pg_depend dependency\\n LEFT JOIN pg_class dependent_table\\n ON dependency.classid = 'pg_class'::regclass AND dependency.objid = dependent_table.oid\\n LEFT JOIN pg_namespace dependent_table_schema\\n ON dependent_table_schema.oid = dependent_table.relnamespace\\n WHERE dependency.refclassid = 'pg_type'::regclass\\n AND dependency.refobjid = public_enum::oid\\n AND dependency.deptype != 'i'\\n AND NOT (\\n dependency.classid = 'pg_class'::regclass\\n AND dependent_table_schema.nspname = 'workflow'\\n )\\n ) INTO has_dependents_outside_workflow_tables;\\n\\n IF has_dependents_outside_workflow_tables THEN\\n RAISE WARNING 'Skipping move of public.% to workflow schema because objects outside workflow tables depend on it', enum_name;\\n CONTINUE;\\n END IF;\\n\\n EXECUTE format('ALTER TYPE public.%I SET SCHEMA workflow', enum_name);\\n END LOOP;\\nEND $$;\\n\",\n \"0016_add_encryption_public_key.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"encryption_public_key\\\" varchar;\\n\",\n \"0017_add_hook_resume_context.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"resume_context\\\" bytea;\\n\",\n \"0018_add_hook_token_retention.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"token_retention_until\\\" timestamp with time zone;\\n\",\n \"0019_add_event_slots.sql\": \"-- Event ids become per-run slot positions (`evnt_` + a zero-padded decimal),\\n-- so an id is only unique together with its run. Runs created before this keep\\n-- their globally-unique ULIDs, which the composite key also admits.\\n--\\n-- LOCKING. Replacing a primary key takes ACCESS EXCLUSIVE on\\n-- `workflow.workflow_events`, which blocks reads as well as writes, and the\\n-- migrator runs every pending migration in one transaction, so the lock is held\\n-- until all of them commit. Building the new key's index under that lock is the\\n-- part that grows with the table. On an empty or modest table this is\\n-- instantaneous and needs no thought.\\n--\\n-- On a large existing table, build the index first, outside the migrator, and\\n-- this migration adopts it instead of building its own:\\n--\\n-- CREATE UNIQUE INDEX CONCURRENTLY \\\"workflow_events_run_id_id_idx\\\"\\n-- ON \\\"workflow\\\".\\\"workflow_events\\\" (\\\"run_id\\\", \\\"id\\\");\\n--\\n-- `CONCURRENTLY` cannot appear in this file: Postgres rejects it inside a\\n-- transaction block. Run it by hand, confirm the index came out valid, then\\n-- migrate. The branch below picks it up, and the exclusive lock then covers\\n-- only a catalog update rather than a full build. Adopting an index renames it\\n-- to the constraint's name, so it ends up as `workflow_events_run_id_id_pk`\\n-- either way and the two paths leave the same schema behind.\\n-- Bound the wait for that lock. A pending ACCESS EXCLUSIVE queues ahead of\\n-- every lock request that arrives after it, so waiting on one long-running\\n-- reader stalls all traffic to the table for as long as the wait lasts. Ten\\n-- seconds of that is a blip; an unbounded wait is an outage. Failing instead\\n-- leaves the migration unapplied and retryable. Raise it by hand for a\\n-- maintenance window.\\n--\\n-- `SET LOCAL` lasts for the transaction, and the migrator runs every pending\\n-- migration in one, so a migration that follows this one in the same batch\\n-- inherits the timeout.\\nSET LOCAL lock_timeout = '10s';--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\" DROP CONSTRAINT \\\"workflow_events_pkey\\\";--> statement-breakpoint\\nDO $$\\nBEGIN\\n IF EXISTS (\\n SELECT 1\\n FROM pg_class c\\n JOIN pg_namespace n ON n.oid = c.relnamespace\\n JOIN pg_index i ON i.indexrelid = c.oid\\n WHERE n.nspname = 'workflow'\\n AND c.relname = 'workflow_events_run_id_id_idx'\\n AND c.relkind = 'i'\\n AND i.indisunique\\n AND i.indisvalid\\n ) THEN\\n ALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\"\\n ADD CONSTRAINT \\\"workflow_events_run_id_id_pk\\\"\\n PRIMARY KEY USING INDEX \\\"workflow_events_run_id_id_idx\\\";\\n ELSE\\n -- A `CREATE UNIQUE INDEX CONCURRENTLY` that failed leaves an index of this\\n -- name behind marked invalid. The branch above rejects it, and the key\\n -- built here is a different index under a different name, so without this\\n -- the invalid one would survive the migration: never used by a plan, still\\n -- maintained on every insert. Dropping it also makes a second attempt at\\n -- the concurrent build possible without a manual cleanup first.\\n DROP INDEX IF EXISTS \\\"workflow\\\".\\\"workflow_events_run_id_id_idx\\\";\\n ALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\"\\n ADD CONSTRAINT \\\"workflow_events_run_id_id_pk\\\" PRIMARY KEY (\\\"run_id\\\",\\\"id\\\");\\n END IF;\\nEND $$;--> statement-breakpoint\\n-- Redundant once the primary key leads with `run_id`: that index serves every\\n-- by-run lookup and range scan this one did, so keeping it only costs a second\\n-- write per event on the table's hottest path.\\nDROP INDEX IF EXISTS \\\"workflow\\\".\\\"workflow_events_run_id_index\\\";--> statement-breakpoint\\n-- One row per slot-numbered run. Its absence is the \\\"this run predates slots\\\"\\n-- signal, so no backfill: existing runs stay on ULIDs for the rest of their\\n-- lives. A marker only: positions are allocated by the insert that occupies\\n-- them, read from the event log itself.\\nCREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_event_slots\\\" (\\n\\t\\\"run_id\\\" varchar PRIMARY KEY NOT NULL\\n);\\n\",\n \"0020_add_invocations.sql\": \"CREATE TABLE \\\"workflow\\\".\\\"workflow_invocations\\\" (\\n \\\"sequence\\\" bigserial NOT NULL,\\n \\\"run_id\\\" varchar NOT NULL,\\n \\\"request_id\\\" varchar NOT NULL,\\n \\\"payload\\\" bytea NOT NULL,\\n \\\"fingerprint\\\" varchar NOT NULL,\\n \\\"result\\\" bytea,\\n \\\"created_at\\\" timestamp DEFAULT now() NOT NULL,\\n \\\"responded_at\\\" timestamp,\\n PRIMARY KEY (\\\"run_id\\\", \\\"request_id\\\")\\n);\\n--> statement-breakpoint\\nCREATE INDEX \\\"workflow_invocations_pending\\\" ON \\\"workflow\\\".\\\"workflow_invocations\\\" (\\\"run_id\\\", \\\"sequence\\\") WHERE \\\"responded_at\\\" IS NULL;\\n\",\n \"0021_invocation_identity_retention.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\" ADD COLUMN \\\"resume_id\\\" varchar;\\n--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_events\\\" ADD COLUMN \\\"resume_payload_digest\\\" varchar;\\n--> statement-breakpoint\\nCREATE UNIQUE INDEX \\\"workflow_events_hook_resume_unique\\\" ON \\\"workflow\\\".\\\"workflow_events\\\" (\\\"run_id\\\", \\\"resume_id\\\") WHERE \\\"type\\\" = 'hook_received' AND \\\"resume_id\\\" IS NOT NULL;\\n--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_invocations\\\" ALTER COLUMN \\\"payload\\\" DROP NOT NULL;\\n--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_invocations\\\" ALTER COLUMN \\\"fingerprint\\\" DROP NOT NULL;\\n--> statement-breakpoint\\nALTER TABLE \\\"workflow\\\".\\\"workflow_invocations\\\" ADD COLUMN \\\"expired_at\\\" timestamp;\\n--> statement-breakpoint\\nUPDATE \\\"workflow\\\".\\\"workflow_invocations\\\" AS invocation\\nSET \\\"payload\\\" = NULL, \\\"result\\\" = NULL, \\\"fingerprint\\\" = NULL,\\n \\\"expired_at\\\" = coalesce(invocation.expired_at, run.expired_at, now())\\nFROM \\\"workflow\\\".\\\"workflow_runs\\\" AS run\\nWHERE invocation.run_id = run.id\\n AND (run.expired_at IS NOT NULL OR\\n (run.status IN ('completed', 'failed', 'cancelled') AND run.attributes -> '$retention' = '\\\"0\\\"'::jsonb));\\n\",\n \"0022_invocation_outcomes.sql\": \"-- Distinguish arbitrary legacy return values from versioned outcome envelopes.\\nALTER TABLE \\\"workflow\\\".\\\"workflow_invocations\\\"\\n ADD COLUMN IF NOT EXISTS \\\"result_version\\\" integer NOT NULL DEFAULT 0;\\n\",\n \"0023_add_hook_claimed_from.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_hooks\\\" ADD COLUMN \\\"claimed_from\\\" bytea;\\n\",\n \"0024_add_dynamic_workflow_code.sql\": \"ALTER TABLE \\\"workflow\\\".\\\"workflow_runs\\\" ADD COLUMN \\\"dynamic_workflow_code_cbor\\\" bytea;\\n\",\n \"0025_add_snapshots_table.sql\": \"CREATE TABLE IF NOT EXISTS \\\"workflow\\\".\\\"workflow_snapshots\\\" (\\n\\t\\\"run_id\\\" varchar PRIMARY KEY NOT NULL,\\n\\t\\\"data\\\" \\\"bytea\\\" NOT NULL,\\n\\t\\\"events_cursor\\\" varchar,\\n\\t\\\"created_at\\\" timestamp DEFAULT now() NOT NULL\\n);\\n\",\n \"0026_add_seq_in_band.sql\": \"-- The in-band writer fence for single-orchestrator runs: how many positions\\n-- the run's orchestrator writes have been accepted for, `run_created`\\n-- included. Every existing run starts at 1, the value a run with no fenced\\n-- write has; only single-orchestrator runs ever advance it.\\nALTER TABLE \\\"workflow\\\".\\\"workflow_event_slots\\\" ADD COLUMN IF NOT EXISTS \\\"seq_in_band\\\" integer DEFAULT 1 NOT NULL;\\n\"\n }\n};\n"]}