@shipfox/api-workflows 8.0.0 → 9.0.2

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 (55) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +94 -0
  3. package/dist/core/agent-tools.d.ts +3 -1
  4. package/dist/core/agent-tools.d.ts.map +1 -1
  5. package/dist/core/agent-tools.js.map +1 -1
  6. package/dist/core/errors.d.ts +0 -4
  7. package/dist/core/errors.d.ts.map +1 -1
  8. package/dist/core/errors.js +0 -6
  9. package/dist/core/errors.js.map +1 -1
  10. package/dist/core/job-execution.d.ts +0 -2
  11. package/dist/core/job-execution.d.ts.map +1 -1
  12. package/dist/core/job-execution.js +3 -7
  13. package/dist/core/job-execution.js.map +1 -1
  14. package/dist/db/workflow-runs/job-executions.d.ts +0 -5
  15. package/dist/db/workflow-runs/job-executions.d.ts.map +1 -1
  16. package/dist/db/workflow-runs/job-executions.js +0 -7
  17. package/dist/db/workflow-runs/job-executions.js.map +1 -1
  18. package/dist/db/workflow-runs.d.ts +1 -1
  19. package/dist/db/workflow-runs.d.ts.map +1 -1
  20. package/dist/db/workflow-runs.js +1 -1
  21. package/dist/db/workflow-runs.js.map +1 -1
  22. package/dist/index.js +2 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/presentation/routes/next-step.d.ts.map +1 -1
  25. package/dist/presentation/routes/next-step.js +11 -8
  26. package/dist/presentation/routes/next-step.js.map +1 -1
  27. package/dist/tsconfig.test.tsbuildinfo +1 -1
  28. package/package.json +34 -28
  29. package/src/core/agent-tool-capability-warning.test.ts +25 -55
  30. package/src/core/agent-tools.ts +7 -5
  31. package/src/core/errors.ts +0 -7
  32. package/src/core/job-execution.ts +3 -10
  33. package/src/core/run-workflow.test.ts +20 -55
  34. package/src/core/step-config/materialize-job-execution-steps.test.ts +1 -2
  35. package/src/core/step-config/materialize-workflow-model.test.ts +11 -23
  36. package/src/db/workflow-runs/job-executions.ts +0 -21
  37. package/src/db/workflow-runs/run-create.test.ts +31 -33
  38. package/src/db/workflow-runs.ts +0 -1
  39. package/src/index.ts +1 -1
  40. package/src/presentation/dto/checkout-token.test.ts +7 -1
  41. package/src/presentation/routes/agent-runtime-config.test.ts +38 -97
  42. package/src/presentation/routes/next-step.test.ts +18 -12
  43. package/src/presentation/routes/next-step.ts +9 -5
  44. package/test/factories/workflow-model.ts +3 -1
  45. package/test/fixtures/active-lease-token.ts +5 -32
  46. package/test/fixtures/agent-inter-module.ts +3 -2
  47. package/test/fixtures/runners-inter-module.ts +40 -48
  48. package/test/globalSetup.ts +0 -38
  49. package/test/setup.ts +2 -0
  50. package/tsconfig.build.tsbuildinfo +1 -1
  51. package/dist/db/runner-lease-table.d.ts +0 -469
  52. package/dist/db/runner-lease-table.d.ts.map +0 -1
  53. package/dist/db/runner-lease-table.js +0 -43
  54. package/dist/db/runner-lease-table.js.map +0 -1
  55. package/src/db/runner-lease-table.ts +0 -39
@@ -1,6 +1,6 @@
1
1
  $ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
2
- Successfully compiled: 116 files with swc (743.53ms)
3
- 2026-07-22T14:54:18.249Z [INFO] asset workflow-bundle-21a9ae8beb3cb55dabc1.js 3.31 MiB [emitted] [immutable] (name: main)
2
+ Successfully compiled: 115 files with swc (683.49ms)
3
+ 2026-07-24T15:39:02.862Z [INFO] asset workflow-bundle-21a9ae8beb3cb55dabc1.js 3.31 MiB [emitted] [immutable] (name: main)
4
4
  orphan modules 33.5 KiB [orphan] 21 modules
5
5
  runtime modules 1.13 KiB 5 modules
6
6
  modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
@@ -16,6 +16,6 @@ optional modules 30 bytes [optional]
16
16
  __temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
17
17
  __temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
18
18
  ../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
19
- webpack 5.107.2 compiled successfully in 7970 ms
20
- 2026-07-22T14:54:18.278Z [INFO] Workflow bundle created { size: '3.31MB' }
19
+ webpack 5.107.2 compiled successfully in 6309 ms
20
+ 2026-07-24T15:39:02.873Z [INFO] Workflow bundle created { size: '3.31MB' }
21
21
  /home/runner/work/shipfox/shipfox/libs/api/workflows/dist/temporal/workflows/index.js: 3470576 bytes
package/CHANGELOG.md CHANGED
@@ -1,5 +1,99 @@
1
1
  # @shipfox/api-workflows
2
2
 
3
+ ## 9.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4b85404: Adds versioned architecture identity to participating package artifacts during publication.
8
+ - Updated dependencies [4b85404]
9
+ - @shipfox/annotations-dto@9.0.2
10
+ - @shipfox/api-agent-dto@9.0.2
11
+ - @shipfox/api-auth-context@9.0.2
12
+ - @shipfox/api-auth-dto@9.0.2
13
+ - @shipfox/api-definitions-dto@9.0.2
14
+ - @shipfox/api-integration-core-dto@9.0.2
15
+ - @shipfox/api-projects-dto@9.0.2
16
+ - @shipfox/api-runners-dto@9.0.2
17
+ - @shipfox/api-secrets-dto@9.0.2
18
+ - @shipfox/api-workflows-dto@9.0.2
19
+ - @shipfox/expression@1.1.5
20
+ - @shipfox/inter-module@0.2.2
21
+ - @shipfox/node-drizzle@0.3.4
22
+ - @shipfox/node-error-monitoring@0.2.2
23
+ - @shipfox/node-fastify@0.3.2
24
+ - @shipfox/node-module@1.0.1
25
+ - @shipfox/node-opentelemetry@0.6.2
26
+ - @shipfox/node-outbox@0.2.6
27
+ - @shipfox/node-postgres@0.4.4
28
+ - @shipfox/node-temporal@0.4.2
29
+ - @shipfox/runner-labels@0.1.3
30
+ - @shipfox/workflow-document@2.1.3
31
+
32
+ ## 9.0.1
33
+
34
+ ### Patch Changes
35
+
36
+ - 475ce59: Republishes all public packages after restoring release authorization.
37
+ - a041e25: Moves lease-state validation behind the Runners inter-module boundary.
38
+ - Updated dependencies [8436596]
39
+ - Updated dependencies [475ce59]
40
+ - Updated dependencies [154e03f]
41
+ - @shipfox/api-secrets-dto@9.0.1
42
+ - @shipfox/runner-labels@0.1.2
43
+ - @shipfox/expression@1.1.4
44
+ - @shipfox/workflow-document@2.1.2
45
+ - @shipfox/annotations-dto@9.0.1
46
+ - @shipfox/api-agent-dto@9.0.1
47
+ - @shipfox/api-auth-context@9.0.1
48
+ - @shipfox/api-auth-dto@9.0.1
49
+ - @shipfox/api-definitions-dto@9.0.1
50
+ - @shipfox/api-integration-core-dto@9.0.1
51
+ - @shipfox/api-projects-dto@9.0.1
52
+ - @shipfox/api-runners-dto@9.0.1
53
+ - @shipfox/api-workflows-dto@9.0.1
54
+ - @shipfox/inter-module@0.2.1
55
+ - @shipfox/node-drizzle@0.3.3
56
+ - @shipfox/node-error-monitoring@0.2.1
57
+ - @shipfox/node-fastify@0.3.1
58
+ - @shipfox/node-module@1.0.0
59
+ - @shipfox/node-opentelemetry@0.6.1
60
+ - @shipfox/node-outbox@0.2.5
61
+ - @shipfox/node-postgres@0.4.3
62
+ - @shipfox/node-temporal@0.4.1
63
+
64
+ ## 9.0.0
65
+
66
+ ### Patch Changes
67
+
68
+ - 074e7b3: Decouples workflow test fixtures from peer API implementations.
69
+ - 46aa52f: Closes remaining API package-boundary exceptions and moves model-provider policy behind the Agent implementation boundary.
70
+ - a9f9c57: Decouples Definitions and Workflows tests from peer implementation packages and databases.
71
+ - Updated dependencies [46aa52f]
72
+ - Updated dependencies [02974d6]
73
+ - Updated dependencies [4a6d124]
74
+ - @shipfox/api-agent-dto@9.0.0
75
+ - @shipfox/api-integration-core-dto@9.0.0
76
+ - @shipfox/api-secrets-dto@9.0.0
77
+ - @shipfox/api-auth-context@9.0.0
78
+ - @shipfox/annotations-dto@6.0.0
79
+ - @shipfox/api-auth-dto@7.1.0
80
+ - @shipfox/api-definitions-dto@6.0.0
81
+ - @shipfox/api-projects-dto@8.0.0
82
+ - @shipfox/api-runners-dto@7.0.1
83
+ - @shipfox/api-workflows-dto@9.0.0
84
+ - @shipfox/inter-module@0.2.0
85
+ - @shipfox/runner-labels@0.1.1
86
+ - @shipfox/expression@1.1.3
87
+ - @shipfox/node-drizzle@0.3.2
88
+ - @shipfox/node-error-monitoring@0.2.0
89
+ - @shipfox/node-fastify@0.3.0
90
+ - @shipfox/node-module@0.5.0
91
+ - @shipfox/node-opentelemetry@0.6.0
92
+ - @shipfox/node-outbox@0.2.4
93
+ - @shipfox/node-postgres@0.4.2
94
+ - @shipfox/node-temporal@0.4.0
95
+ - @shipfox/workflow-document@2.1.1
96
+
3
97
  ## 8.0.0
4
98
 
5
99
  ### Patch Changes
@@ -1,6 +1,5 @@
1
1
  import type { MaterializedAgentIntegrationConfigDto } from '@shipfox/api-agent-dto';
2
2
  import type { WorkflowModel } from '@shipfox/api-definitions-dto';
3
- import type { AgentToolCatalogEntry, IntegrationProviderKind } from '@shipfox/api-integration-core-dto';
4
3
  import type { IntegrationsModuleClient } from '@shipfox/api-integration-core-dto/inter-module';
5
4
  import type { ProjectsModuleClient } from '@shipfox/api-projects-dto/inter-module';
6
5
  type WorkflowModelJob = WorkflowModel['jobs'][number];
@@ -8,6 +7,9 @@ type WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {
8
7
  kind: 'agent';
9
8
  }>;
10
9
  type WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];
10
+ type IntegrationsAgentToolsContext = Awaited<ReturnType<IntegrationsModuleClient['getAgentToolsContext']>>;
11
+ export type AgentToolCatalogEntry = IntegrationsAgentToolsContext['catalogs'][number]['tools'][number];
12
+ type IntegrationProviderKind = IntegrationsAgentToolsContext['catalogs'][number]['provider'];
11
13
  type AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;
12
14
  type WorkspaceConnectionSnapshot = ReadonlyMap<string, {
13
15
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tools.d.ts","sourceRoot":"","sources":["../../src/core/agent-tools.ts"],"names":[],"mappings":"AAAA,OA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3E,QAAQ,CAAC,OAAO,EAAE,+BAA+B,GAAG,SAAS,CAAC;IAC9D,QAAQ,CAAC,QAAQ,CAAC,EAAE,gCAAgC,GAAG,IAAI,GAAG,SAAS,CAAC;CACzE,GAAG,qCAAqC,EAAE,GAAG,SAAS,CActD;AAED,wBAAgB,sCAAsC,CAAC,MAAM,EAAE;IAC7D,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,+BAA+B,GAAG,SAAS,CAAC;CAC/D,GAAG,gCAAgC,GAAG,IAAI,CAwB1C"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n MaterializedAgentIntegrationConfigDto,\n MaterializedAgentIntegrationToolConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {\n AgentToolCatalogEntry,\n AgentToolCatalogMethod,\n IntegrationProviderKind,\n} from '@shipfox/api-integration-core-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {AgentIntegrationMaterializationError} from './errors.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {kind: 'agent'}>;\ntype WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];\ntype AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;\ntype WorkspaceConnectionSnapshot = ReadonlyMap<\n string,\n {\n id: string;\n provider: IntegrationProviderKind;\n capabilities: readonly ('source_control' | 'agent_tools')[];\n }\n>;\n\nexport interface AgentToolMaterializationContext {\n readonly catalogs: AgentToolCatalogs;\n readonly workspaceConnectionSnapshot: WorkspaceConnectionSnapshot;\n readonly defaultConnection: {\n readonly id: string;\n readonly slug: string;\n readonly provider: IntegrationProviderKind;\n };\n}\n\nexport interface AgentToolMaterializationSnapshot {\n readonly steps: readonly AgentToolMaterializationSnapshotStep[];\n}\n\nexport interface AgentToolMaterializationSnapshotStep {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly MaterializedAgentIntegrationConfigDto[];\n}\n\ninterface SelectedToolState {\n readonly entry: AgentToolCatalogEntry;\n readonly methods: Map<string, AgentToolCatalogMethod>;\n selectedStandalone: boolean;\n}\n\nexport async function loadAgentToolMaterializationContext(params: {\n readonly model: WorkflowModel | null;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly integrations?: IntegrationsModuleClient | undefined;\n readonly projects?: ProjectsModuleClient | undefined;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n}): Promise<AgentToolMaterializationContext | undefined> {\n if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;\n\n if (params.projects === undefined) {\n throw new AgentIntegrationMaterializationError('Project access is not configured');\n }\n const {project} = await params.projects.getProjectById({projectId: params.projectId});\n if (project === null) {\n throw new AgentIntegrationMaterializationError(\n `Project ${params.projectId} was not found while materializing agent integrations`,\n );\n }\n\n if (params.integrations === undefined) {\n throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');\n }\n const context = await params.integrations.getAgentToolsContext({\n workspaceId: params.workspaceId,\n defaultConnectionId: project.sourceConnectionId,\n });\n const workspaceConnectionSnapshot = new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n );\n const defaultConnection = context.defaultConnection;\n if (defaultConnection === null) {\n throw new AgentIntegrationMaterializationError(\n `Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`,\n );\n }\n\n return {\n catalogs: new Map(context.catalogs.map(({provider, tools}) => [provider, tools])),\n workspaceConnectionSnapshot,\n defaultConnection: {\n id: defaultConnection.id,\n slug: defaultConnection.slug,\n provider: defaultConnection.provider,\n },\n };\n}\n\nexport function materializeAgentIntegrations(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly WorkflowModelStepIntegration[] | undefined;\n readonly context: AgentToolMaterializationContext | undefined;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): MaterializedAgentIntegrationConfigDto[] | undefined {\n const snapshot = findSnapshotStep(params);\n if (snapshot !== undefined) return snapshot.integrations.map(copyMaterializedIntegration);\n if (params.integrations === undefined) return undefined;\n if (params.context === undefined) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integrations require materialization context',\n );\n }\n const {context} = params;\n\n return params.integrations.map((integration) =>\n materializeAgentIntegration({integration, context}),\n );\n}\n\nexport function createAgentToolMaterializationSnapshot(params: {\n readonly model: WorkflowModel;\n readonly context: AgentToolMaterializationContext | undefined;\n}): AgentToolMaterializationSnapshot | null {\n if (params.context === undefined) return null;\n\n const steps = params.model.jobs.flatMap((job) =>\n job.steps.flatMap((step) => {\n if (step.kind !== 'agent' || step.integrations === undefined) return [];\n const integrations = materializeAgentIntegrations({\n jobKey: job.key,\n stepId: step.id,\n integrations: step.integrations,\n context: params.context,\n });\n if (integrations === undefined) return [];\n return [\n {\n jobKey: job.key,\n stepId: step.id,\n integrations,\n },\n ];\n }),\n );\n\n return steps.length === 0 ? null : {steps};\n}\n\nfunction findSnapshotStep(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): AgentToolMaterializationSnapshotStep | undefined {\n return params.snapshot?.steps.find(\n (step) => step.jobKey === params.jobKey && step.stepId === params.stepId,\n );\n}\n\nfunction materializeAgentIntegration(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): MaterializedAgentIntegrationConfigDto {\n const connection = resolveConnection(params);\n const catalog = params.context.catalogs.get(connection.provider);\n if (catalog === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration provider ${connection.provider} has no agent tool catalog`,\n );\n }\n\n const tools = selectTools({\n catalog,\n include: params.integration.include,\n exclude: params.integration.exclude ?? [],\n });\n const requiredScope = mergeRequiredScopes(tools.map((tool) => tool.requiredScope));\n\n return {\n connectionId: connection.id,\n connectionSlug: connection.slug,\n provider: connection.provider,\n requiredScope,\n tools,\n };\n}\n\nfunction copyMaterializedIntegration(\n integration: MaterializedAgentIntegrationConfigDto,\n): MaterializedAgentIntegrationConfigDto {\n return {\n ...integration,\n requiredScope: [...integration.requiredScope],\n tools: integration.tools.map((tool) => ({\n ...tool,\n requiredScope: [...tool.requiredScope],\n ...(tool.methods === undefined\n ? {}\n : {\n methods: tool.methods.map((method) => ({\n ...method,\n requiredScope: [...method.requiredScope],\n })),\n }),\n })),\n };\n}\n\nfunction resolveConnection(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): AgentToolMaterializationContext['defaultConnection'] {\n if (params.integration.connection === undefined) return params.context.defaultConnection;\n\n const connection = params.context.workspaceConnectionSnapshot.get(params.integration.connection);\n if (connection === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration connection ${params.integration.connection} was not found while materializing agent integrations`,\n );\n }\n return {\n id: connection.id,\n slug: params.integration.connection,\n provider: connection.provider,\n };\n}\n\nfunction selectTools(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly include: readonly string[];\n readonly exclude: readonly string[];\n}): MaterializedAgentIntegrationToolConfigDto[] {\n const selected = new Map<string, SelectedToolState>();\n\n for (const token of params.include) {\n applySelection({catalog: params.catalog, selected, token, mode: 'include'});\n }\n for (const token of params.exclude) {\n applySelection({catalog: params.catalog, selected, token, mode: 'exclude'});\n }\n\n const tools = params.catalog.flatMap((entry) => {\n const state = selected.get(entry.id);\n if (state === undefined) return [];\n return [materializedTool(state)];\n });\n if (tools.length === 0) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integration selection resolved to no tools',\n );\n }\n return tools;\n}\n\nfunction applySelection(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n}): void {\n if (params.token === '*') {\n for (const entry of params.catalog) applyEntrySelection(params, entry);\n return;\n }\n\n const match = findCatalogSelection(params.catalog, params.token);\n if (match === undefined) {\n throw new AgentIntegrationMaterializationError(`Unknown integration tool: ${params.token}`);\n }\n applyEntrySelection(params, match.entry, match.method);\n}\n\nfunction applyEntrySelection(\n params: {\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n },\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (params.mode === 'exclude') {\n excludeEntrySelection(params.selected, entry, method);\n return;\n }\n\n const state =\n params.selected.get(entry.id) ??\n ({entry, methods: new Map(), selectedStandalone: false} satisfies SelectedToolState);\n if (entry.methods === undefined) {\n state.selectedStandalone = true;\n } else if (method === undefined) {\n for (const candidate of entry.methods) state.methods.set(candidate.id, candidate);\n } else {\n state.methods.set(method.id, method);\n }\n params.selected.set(entry.id, state);\n}\n\nfunction excludeEntrySelection(\n selected: Map<string, SelectedToolState>,\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (method === undefined) {\n selected.delete(entry.id);\n return;\n }\n\n const state = selected.get(entry.id);\n if (state === undefined) return;\n state.methods.delete(method.id);\n if (!state.selectedStandalone && state.methods.size === 0) selected.delete(entry.id);\n}\n\nfunction findCatalogSelection(\n catalog: readonly AgentToolCatalogEntry[],\n token: string,\n):\n | {readonly entry: AgentToolCatalogEntry; readonly method?: AgentToolCatalogMethod | undefined}\n | undefined {\n const entry = catalog.find((candidate) => candidate.id === token);\n if (entry !== undefined) return {entry};\n\n const wildcardSuffix = '.*';\n if (token.endsWith(wildcardSuffix)) {\n const family = token.slice(0, -wildcardSuffix.length);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n return familyEntry === undefined ? undefined : {entry: familyEntry};\n }\n\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return undefined;\n const family = token.slice(0, dotIndex);\n const methodId = token.slice(dotIndex + 1);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n const method = familyEntry?.methods?.find((candidate) => candidate.id === methodId);\n if (familyEntry === undefined || method === undefined) return undefined;\n return {entry: familyEntry, method};\n}\n\nfunction materializedTool(state: SelectedToolState): MaterializedAgentIntegrationToolConfigDto {\n if (state.entry.methods === undefined) {\n return {\n id: state.entry.id,\n sensitivity: state.entry.sensitivity,\n sensitive: state.entry.sensitive,\n requiredScope: normalizeRequiredScope(state.entry.requiredScope),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n };\n }\n\n const methods = state.entry.methods\n .filter((method) => state.methods.has(method.id))\n .map((method) => ({\n id: method.id,\n token: `${state.entry.id}.${method.id}`,\n description: method.description,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n requiredScope: normalizeRequiredScope(method.requiredScope),\n }));\n\n return {\n id: state.entry.id,\n sensitivity: methods.some((method) => method.sensitivity === 'write') ? 'write' : 'read',\n sensitive: methods.some((method) => method.sensitive),\n requiredScope: mergeRequiredScopes(methods.map((method) => method.requiredScope)),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n methods,\n };\n}\n\nfunction mergeRequiredScopes(scopes: readonly unknown[]): unknown[] {\n const items = scopes.flatMap(normalizeRequiredScope);\n if (items.every(isPermissionScope)) {\n const byPermission = new Map<string, 'read' | 'write'>();\n for (const item of items) {\n const existing = byPermission.get(item.permission);\n if (existing === 'write') continue;\n byPermission.set(item.permission, item.access);\n }\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n }\n\n const deduped = new Map<string, unknown>();\n for (const item of items) deduped.set(JSON.stringify(item), item);\n return [...deduped.values()];\n}\n\nfunction normalizeRequiredScope(scope: unknown): unknown[] {\n return Array.isArray(scope) ? [...scope] : [scope];\n}\n\nfunction isPermissionScope(\n value: unknown,\n): value is {permission: string; access: 'read' | 'write'} {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {permission?: unknown; access?: unknown};\n return (\n typeof candidate.permission === 'string' &&\n (candidate.access === 'read' || candidate.access === 'write')\n );\n}\n\nfunction modelHasAgentStepIntegrations(\n model: WorkflowModel | null,\n jobs: readonly WorkflowModelJob[] | undefined,\n): boolean {\n if (model === null) return false;\n return (jobs ?? model.jobs).some((job) =>\n job.steps.some((step) => step.kind === 'agent' && step.integrations !== undefined),\n );\n}\n"],"names":["AgentIntegrationMaterializationError","loadAgentToolMaterializationContext","params","modelHasAgentStepIntegrations","model","jobs","undefined","projects","project","getProjectById","projectId","integrations","context","getAgentToolsContext","workspaceId","defaultConnectionId","sourceConnectionId","workspaceConnectionSnapshot","Map","workspaceConnections","map","slug","connection","defaultConnection","catalogs","provider","tools","id","materializeAgentIntegrations","snapshot","findSnapshotStep","copyMaterializedIntegration","integration","materializeAgentIntegration","createAgentToolMaterializationSnapshot","steps","flatMap","job","step","kind","jobKey","key","stepId","length","find","resolveConnection","catalog","get","selectTools","include","exclude","requiredScope","mergeRequiredScopes","tool","connectionId","connectionSlug","methods","method","selected","token","applySelection","mode","entry","state","materializedTool","applyEntrySelection","match","findCatalogSelection","excludeEntrySelection","selectedStandalone","candidate","set","delete","size","wildcardSuffix","endsWith","family","slice","familyEntry","dotIndex","indexOf","methodId","sensitivity","sensitive","normalizeRequiredScope","inputSchema","outputSchema","filter","has","description","some","scopes","items","every","isPermissionScope","byPermission","item","existing","permission","access","entries","deduped","JSON","stringify","values","scope","Array","isArray","value"],"mappings":"AAYA,SAAQA,oCAAoC,QAAO,cAAc;AAyCjE,OAAO,eAAeC,oCAAoCC,MAOzD;IACC,IAAI,CAACC,8BAA8BD,OAAOE,KAAK,EAAEF,OAAOG,IAAI,GAAG,OAAOC;IAEtE,IAAIJ,OAAOK,QAAQ,KAAKD,WAAW;QACjC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAM,EAACQ,OAAO,EAAC,GAAG,MAAMN,OAAOK,QAAQ,CAACE,cAAc,CA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G;QAACA;KAAM;AACpD;AAEA,SAASX,kBACPc,KAAc;IAEd,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMtC,YAAYsC;IAClB,OACE,OAAOtC,UAAU4B,UAAU,KAAK,YAC/B5B,CAAAA,UAAU6B,MAAM,KAAK,UAAU7B,UAAU6B,MAAM,KAAK,OAAM;AAE/D;AAEA,SAAShG,8BACPC,KAA2B,EAC3BC,IAA6C;IAE7C,IAAID,UAAU,MAAM,OAAO;IAC3B,OAAO,AAACC,CAAAA,QAAQD,MAAMC,IAAI,AAAD,EAAGqF,IAAI,CAAC,CAACrD,MAChCA,IAAIF,KAAK,CAACuD,IAAI,CAAC,CAACpD,OAASA,KAAKC,IAAI,KAAK,WAAWD,KAAK3B,YAAY,KAAKL;AAE5E"}
1
+ {"version":3,"sources":["../../src/core/agent-tools.ts"],"sourcesContent":["import type {\n MaterializedAgentIntegrationConfigDto,\n MaterializedAgentIntegrationToolConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {IntegrationsModuleClient} from '@shipfox/api-integration-core-dto/inter-module';\nimport type {ProjectsModuleClient} from '@shipfox/api-projects-dto/inter-module';\nimport {AgentIntegrationMaterializationError} from './errors.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelAgentStep = Extract<WorkflowModelJob['steps'][number], {kind: 'agent'}>;\ntype WorkflowModelStepIntegration = NonNullable<WorkflowModelAgentStep['integrations']>[number];\ntype IntegrationsAgentToolsContext = Awaited<\n ReturnType<IntegrationsModuleClient['getAgentToolsContext']>\n>;\nexport type AgentToolCatalogEntry =\n IntegrationsAgentToolsContext['catalogs'][number]['tools'][number];\ntype AgentToolCatalogMethod = NonNullable<AgentToolCatalogEntry['methods']>[number];\ntype IntegrationProviderKind = IntegrationsAgentToolsContext['catalogs'][number]['provider'];\ntype AgentToolCatalogs = ReadonlyMap<IntegrationProviderKind, readonly AgentToolCatalogEntry[]>;\ntype WorkspaceConnectionSnapshot = ReadonlyMap<\n string,\n {\n id: string;\n provider: IntegrationProviderKind;\n capabilities: readonly ('source_control' | 'agent_tools')[];\n }\n>;\n\nexport interface AgentToolMaterializationContext {\n readonly catalogs: AgentToolCatalogs;\n readonly workspaceConnectionSnapshot: WorkspaceConnectionSnapshot;\n readonly defaultConnection: {\n readonly id: string;\n readonly slug: string;\n readonly provider: IntegrationProviderKind;\n };\n}\n\nexport interface AgentToolMaterializationSnapshot {\n readonly steps: readonly AgentToolMaterializationSnapshotStep[];\n}\n\nexport interface AgentToolMaterializationSnapshotStep {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly MaterializedAgentIntegrationConfigDto[];\n}\n\ninterface SelectedToolState {\n readonly entry: AgentToolCatalogEntry;\n readonly methods: Map<string, AgentToolCatalogMethod>;\n selectedStandalone: boolean;\n}\n\nexport async function loadAgentToolMaterializationContext(params: {\n readonly model: WorkflowModel | null;\n readonly workspaceId: string;\n readonly projectId: string;\n readonly integrations?: IntegrationsModuleClient | undefined;\n readonly projects?: ProjectsModuleClient | undefined;\n readonly jobs?: readonly WorkflowModelJob[] | undefined;\n}): Promise<AgentToolMaterializationContext | undefined> {\n if (!modelHasAgentStepIntegrations(params.model, params.jobs)) return undefined;\n\n if (params.projects === undefined) {\n throw new AgentIntegrationMaterializationError('Project access is not configured');\n }\n const {project} = await params.projects.getProjectById({projectId: params.projectId});\n if (project === null) {\n throw new AgentIntegrationMaterializationError(\n `Project ${params.projectId} was not found while materializing agent integrations`,\n );\n }\n\n if (params.integrations === undefined) {\n throw new AgentIntegrationMaterializationError('Agent tool materialization is not configured');\n }\n const context = await params.integrations.getAgentToolsContext({\n workspaceId: params.workspaceId,\n defaultConnectionId: project.sourceConnectionId,\n });\n const workspaceConnectionSnapshot = new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n );\n const defaultConnection = context.defaultConnection;\n if (defaultConnection === null) {\n throw new AgentIntegrationMaterializationError(\n `Source connection ${project.sourceConnectionId} was not found while materializing agent integrations`,\n );\n }\n\n return {\n catalogs: new Map(context.catalogs.map(({provider, tools}) => [provider, tools])),\n workspaceConnectionSnapshot,\n defaultConnection: {\n id: defaultConnection.id,\n slug: defaultConnection.slug,\n provider: defaultConnection.provider,\n },\n };\n}\n\nexport function materializeAgentIntegrations(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly integrations: readonly WorkflowModelStepIntegration[] | undefined;\n readonly context: AgentToolMaterializationContext | undefined;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): MaterializedAgentIntegrationConfigDto[] | undefined {\n const snapshot = findSnapshotStep(params);\n if (snapshot !== undefined) return snapshot.integrations.map(copyMaterializedIntegration);\n if (params.integrations === undefined) return undefined;\n if (params.context === undefined) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integrations require materialization context',\n );\n }\n const {context} = params;\n\n return params.integrations.map((integration) =>\n materializeAgentIntegration({integration, context}),\n );\n}\n\nexport function createAgentToolMaterializationSnapshot(params: {\n readonly model: WorkflowModel;\n readonly context: AgentToolMaterializationContext | undefined;\n}): AgentToolMaterializationSnapshot | null {\n if (params.context === undefined) return null;\n\n const steps = params.model.jobs.flatMap((job) =>\n job.steps.flatMap((step) => {\n if (step.kind !== 'agent' || step.integrations === undefined) return [];\n const integrations = materializeAgentIntegrations({\n jobKey: job.key,\n stepId: step.id,\n integrations: step.integrations,\n context: params.context,\n });\n if (integrations === undefined) return [];\n return [\n {\n jobKey: job.key,\n stepId: step.id,\n integrations,\n },\n ];\n }),\n );\n\n return steps.length === 0 ? null : {steps};\n}\n\nfunction findSnapshotStep(params: {\n readonly jobKey: string;\n readonly stepId: string;\n readonly snapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}): AgentToolMaterializationSnapshotStep | undefined {\n return params.snapshot?.steps.find(\n (step) => step.jobKey === params.jobKey && step.stepId === params.stepId,\n );\n}\n\nfunction materializeAgentIntegration(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): MaterializedAgentIntegrationConfigDto {\n const connection = resolveConnection(params);\n const catalog = params.context.catalogs.get(connection.provider);\n if (catalog === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration provider ${connection.provider} has no agent tool catalog`,\n );\n }\n\n const tools = selectTools({\n catalog,\n include: params.integration.include,\n exclude: params.integration.exclude ?? [],\n });\n const requiredScope = mergeRequiredScopes(tools.map((tool) => tool.requiredScope));\n\n return {\n connectionId: connection.id,\n connectionSlug: connection.slug,\n provider: connection.provider,\n requiredScope,\n tools,\n };\n}\n\nfunction copyMaterializedIntegration(\n integration: MaterializedAgentIntegrationConfigDto,\n): MaterializedAgentIntegrationConfigDto {\n return {\n ...integration,\n requiredScope: [...integration.requiredScope],\n tools: integration.tools.map((tool) => ({\n ...tool,\n requiredScope: [...tool.requiredScope],\n ...(tool.methods === undefined\n ? {}\n : {\n methods: tool.methods.map((method) => ({\n ...method,\n requiredScope: [...method.requiredScope],\n })),\n }),\n })),\n };\n}\n\nfunction resolveConnection(params: {\n readonly integration: WorkflowModelStepIntegration;\n readonly context: AgentToolMaterializationContext;\n}): AgentToolMaterializationContext['defaultConnection'] {\n if (params.integration.connection === undefined) return params.context.defaultConnection;\n\n const connection = params.context.workspaceConnectionSnapshot.get(params.integration.connection);\n if (connection === undefined) {\n throw new AgentIntegrationMaterializationError(\n `Integration connection ${params.integration.connection} was not found while materializing agent integrations`,\n );\n }\n return {\n id: connection.id,\n slug: params.integration.connection,\n provider: connection.provider,\n };\n}\n\nfunction selectTools(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly include: readonly string[];\n readonly exclude: readonly string[];\n}): MaterializedAgentIntegrationToolConfigDto[] {\n const selected = new Map<string, SelectedToolState>();\n\n for (const token of params.include) {\n applySelection({catalog: params.catalog, selected, token, mode: 'include'});\n }\n for (const token of params.exclude) {\n applySelection({catalog: params.catalog, selected, token, mode: 'exclude'});\n }\n\n const tools = params.catalog.flatMap((entry) => {\n const state = selected.get(entry.id);\n if (state === undefined) return [];\n return [materializedTool(state)];\n });\n if (tools.length === 0) {\n throw new AgentIntegrationMaterializationError(\n 'Agent integration selection resolved to no tools',\n );\n }\n return tools;\n}\n\nfunction applySelection(params: {\n readonly catalog: readonly AgentToolCatalogEntry[];\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n}): void {\n if (params.token === '*') {\n for (const entry of params.catalog) applyEntrySelection(params, entry);\n return;\n }\n\n const match = findCatalogSelection(params.catalog, params.token);\n if (match === undefined) {\n throw new AgentIntegrationMaterializationError(`Unknown integration tool: ${params.token}`);\n }\n applyEntrySelection(params, match.entry, match.method);\n}\n\nfunction applyEntrySelection(\n params: {\n readonly selected: Map<string, SelectedToolState>;\n readonly token: string;\n readonly mode: 'include' | 'exclude';\n },\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (params.mode === 'exclude') {\n excludeEntrySelection(params.selected, entry, method);\n return;\n }\n\n const state =\n params.selected.get(entry.id) ??\n ({entry, methods: new Map(), selectedStandalone: false} satisfies SelectedToolState);\n if (entry.methods === undefined) {\n state.selectedStandalone = true;\n } else if (method === undefined) {\n for (const candidate of entry.methods) state.methods.set(candidate.id, candidate);\n } else {\n state.methods.set(method.id, method);\n }\n params.selected.set(entry.id, state);\n}\n\nfunction excludeEntrySelection(\n selected: Map<string, SelectedToolState>,\n entry: AgentToolCatalogEntry,\n method?: AgentToolCatalogMethod | undefined,\n): void {\n if (method === undefined) {\n selected.delete(entry.id);\n return;\n }\n\n const state = selected.get(entry.id);\n if (state === undefined) return;\n state.methods.delete(method.id);\n if (!state.selectedStandalone && state.methods.size === 0) selected.delete(entry.id);\n}\n\nfunction findCatalogSelection(\n catalog: readonly AgentToolCatalogEntry[],\n token: string,\n):\n | {readonly entry: AgentToolCatalogEntry; readonly method?: AgentToolCatalogMethod | undefined}\n | undefined {\n const entry = catalog.find((candidate) => candidate.id === token);\n if (entry !== undefined) return {entry};\n\n const wildcardSuffix = '.*';\n if (token.endsWith(wildcardSuffix)) {\n const family = token.slice(0, -wildcardSuffix.length);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n return familyEntry === undefined ? undefined : {entry: familyEntry};\n }\n\n const dotIndex = token.indexOf('.');\n if (dotIndex < 1) return undefined;\n const family = token.slice(0, dotIndex);\n const methodId = token.slice(dotIndex + 1);\n const familyEntry = catalog.find((candidate) => candidate.id === family);\n const method = familyEntry?.methods?.find((candidate) => candidate.id === methodId);\n if (familyEntry === undefined || method === undefined) return undefined;\n return {entry: familyEntry, method};\n}\n\nfunction materializedTool(state: SelectedToolState): MaterializedAgentIntegrationToolConfigDto {\n if (state.entry.methods === undefined) {\n return {\n id: state.entry.id,\n sensitivity: state.entry.sensitivity,\n sensitive: state.entry.sensitive,\n requiredScope: normalizeRequiredScope(state.entry.requiredScope),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n };\n }\n\n const methods = state.entry.methods\n .filter((method) => state.methods.has(method.id))\n .map((method) => ({\n id: method.id,\n token: `${state.entry.id}.${method.id}`,\n description: method.description,\n sensitivity: method.sensitivity,\n sensitive: method.sensitive,\n requiredScope: normalizeRequiredScope(method.requiredScope),\n }));\n\n return {\n id: state.entry.id,\n sensitivity: methods.some((method) => method.sensitivity === 'write') ? 'write' : 'read',\n sensitive: methods.some((method) => method.sensitive),\n requiredScope: mergeRequiredScopes(methods.map((method) => method.requiredScope)),\n inputSchema: state.entry.inputSchema,\n ...(state.entry.outputSchema === undefined ? {} : {outputSchema: state.entry.outputSchema}),\n methods,\n };\n}\n\nfunction mergeRequiredScopes(scopes: readonly unknown[]): unknown[] {\n const items = scopes.flatMap(normalizeRequiredScope);\n if (items.every(isPermissionScope)) {\n const byPermission = new Map<string, 'read' | 'write'>();\n for (const item of items) {\n const existing = byPermission.get(item.permission);\n if (existing === 'write') continue;\n byPermission.set(item.permission, item.access);\n }\n return [...byPermission.entries()].map(([permission, access]) => ({permission, access}));\n }\n\n const deduped = new Map<string, unknown>();\n for (const item of items) deduped.set(JSON.stringify(item), item);\n return [...deduped.values()];\n}\n\nfunction normalizeRequiredScope(scope: unknown): unknown[] {\n return Array.isArray(scope) ? [...scope] : [scope];\n}\n\nfunction isPermissionScope(\n value: unknown,\n): value is {permission: string; access: 'read' | 'write'} {\n if (typeof value !== 'object' || value === null) return false;\n const candidate = value as {permission?: unknown; access?: unknown};\n return (\n typeof candidate.permission === 'string' &&\n (candidate.access === 'read' || candidate.access === 'write')\n );\n}\n\nfunction modelHasAgentStepIntegrations(\n model: WorkflowModel | null,\n jobs: readonly WorkflowModelJob[] | undefined,\n): boolean {\n if (model === null) return false;\n return (jobs ?? model.jobs).some((job) =>\n job.steps.some((step) => step.kind === 'agent' && step.integrations !== undefined),\n );\n}\n"],"names":["AgentIntegrationMaterializationError","loadAgentToolMaterializationContext","params","modelHasAgentStepIntegrations","model","jobs","undefined","projects","project","getProjectById","projectId","integrations","context","getAgentToolsContext","workspaceId","defaultConnectionId","sourceConnectionId","workspaceConnectionSnapshot","Map","workspaceConnections","map","slug","connection","defaultConnection","catalogs","provider","tools","id","materializeAgentIntegrations","snapshot","findSnapshotStep","copyMaterializedIntegration","integration","materializeAgentIntegration","createAgentToolMaterializationSnapshot","steps","flatMap","job","step","kind","jobKey","key","stepId","length","find","resolveConnection","catalog","get","selectTools","include","exclude","requiredScope","mergeRequiredScopes","tool","connectionId","connectionSlug","methods","method","selected","token","applySelection","mode","entry","state","materializedTool","applyEntrySelection","match","findCatalogSelection","excludeEntrySelection","selectedStandalone","candidate","set","delete","size","wildcardSuffix","endsWith","family","slice","familyEntry","dotIndex","indexOf","methodId","sensitivity","sensitive","normalizeRequiredScope","inputSchema","outputSchema","filter","has","description","some","scopes","items","every","isPermissionScope","byPermission","item","existing","permission","access","entries","deduped","JSON","stringify","values","scope","Array","isArray","value"],"mappings":"AAOA,SAAQA,oCAA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AACD;gBAAYC;YAAM,CAAA;IACvF;IAEA,MAAME,UAAU,IAAInF;IACpB,KAAK,MAAM8E,QAAQJ,MAAOS,QAAQ9B,GAAG,CAAC+B,KAAKC,SAAS,CAACP,OAAOA;IAC5D,OAAO;WAAIK,QAAQG,MAAM;KAAG;AAC9B;AAEA,SAASpB,uBAAuBqB,KAAc;IAC5C,OAAOC,MAAMC,OAAO,CAACF,SAAS;WAAIA;KAAM,GAAG;QAACA;KAAM;AACpD;AAEA,SAASX,kBACPc,KAAc;IAEd,IAAI,OAAOA,UAAU,YAAYA,UAAU,MAAM,OAAO;IACxD,MAAMtC,YAAYsC;IAClB,OACE,OAAOtC,UAAU4B,UAAU,KAAK,YAC/B5B,CAAAA,UAAU6B,MAAM,KAAK,UAAU7B,UAAU6B,MAAM,KAAK,OAAM;AAE/D;AAEA,SAAShG,8BACPC,KAA2B,EAC3BC,IAA6C;IAE7C,IAAID,UAAU,MAAM,OAAO;IAC3B,OAAO,AAACC,CAAAA,QAAQD,MAAMC,IAAI,AAAD,EAAGqF,IAAI,CAAC,CAACrD,MAChCA,IAAIF,KAAK,CAACuD,IAAI,CAAC,CAACpD,OAASA,KAAKC,IAAI,KAAK,WAAWD,KAAK3B,YAAY,KAAKL;AAE5E"}
@@ -36,10 +36,6 @@ export declare function isPermanentRunWorkflowError(error: unknown): boolean;
36
36
  export declare class JobNotFoundError extends Error {
37
37
  constructor(jobId: string);
38
38
  }
39
- export declare class JobLeaseNotActiveError extends Error {
40
- readonly jobExecutionId: string;
41
- constructor(jobExecutionId: string);
42
- }
43
39
  export declare class InvalidJobRunnerLabelsError extends Error {
44
40
  readonly labels: readonly string[];
45
41
  constructor(labels: readonly string[]);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MA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AM;IACtB,QAAQ,CAAC,eAAe,EAAE,MAAM;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM;gBAHtB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM;CAOlC"}
@@ -51,12 +51,6 @@ export class JobNotFoundError extends Error {
51
51
  this.name = 'JobNotFoundError';
52
52
  }
53
53
  }
54
- export class JobLeaseNotActiveError extends Error {
55
- constructor(jobExecutionId){
56
- super(`Job lease is no longer active: ${jobExecutionId}`), this.jobExecutionId = jobExecutionId;
57
- this.name = 'JobLeaseNotActiveError';
58
- }
59
- }
60
54
  export class InvalidJobRunnerLabelsError extends Error {
61
55
  constructor(labels){
62
56
  super(`Job runner labels are invalid: ${labels.join(', ')}`), this.labels = labels;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import type {JobStatus} from './entities/job.js';\nimport type {WorkflowRunStatus} from './entities/workflow-run.js';\n\nexport class DefinitionNotFoundError extends Error {\n constructor(definitionId: string) {\n super(`Definition not found: ${definitionId}`);\n this.name = 'DefinitionNotFoundError';\n }\n}\n\nexport class ProjectMismatchError extends Error {\n constructor(definitionProjectId: string, requestProjectId: string) {\n super(\n `Definition belongs to project ${definitionProjectId}, but request targets project ${requestProjectId}`,\n );\n this.name = 'ProjectMismatchError';\n }\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n constructor(\n readonly definitionId: string,\n options?: ErrorOptions | undefined,\n ) {\n super(`Agent configuration cannot be resolved for definition ${definitionId}`, options);\n this.name = 'AgentConfigUnresolvableError';\n }\n}\n\nexport class AgentIntegrationMaterializationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AgentIntegrationMaterializationError';\n }\n}\n\nexport type InterpolationUnresolvableField =\n | 'run'\n | 'env'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'job.runner'\n | 'job.outputs'\n | 'job.name'\n | 'step.name'\n | 'step.feedback';\n\nexport class InterpolationUnresolvableError extends Error {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n\n constructor(\n readonly definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n readonly cause?: unknown;\n },\n ) {\n super(interpolationUnresolvableMessage(definitionId, params), {cause: params.cause});\n this.name = 'InterpolationUnresolvableError';\n this.field = params.field;\n this.source = params.source;\n if (params.envKey !== undefined) this.envKey = params.envKey;\n }\n}\n\nfunction interpolationUnresolvableMessage(\n definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n },\n): string {\n const envSuffix = params.envKey === undefined ? '' : ` (${params.envKey})`;\n return `Workflow interpolation cannot be resolved for definition ${definitionId}: ${params.field}${envSuffix} uses \\`${params.source}\\`. Use has(x) ? x : '' for optional references.`;\n}\n\n/**\n * True when a `runWorkflow` failure can never succeed on retry: the definition is gone or\n * the subscription points at the wrong project. Callers (e.g. the trigger dispatcher) use this\n * to skip a permanently-broken target instead of retrying it forever. Every other failure is\n * treated as transient so at-least-once delivery can converge.\n */\nexport function isPermanentRunWorkflowError(error: unknown): boolean {\n return (\n error instanceof DefinitionNotFoundError ||\n error instanceof ProjectMismatchError ||\n error instanceof AgentConfigUnresolvableError ||\n error instanceof AgentIntegrationMaterializationError ||\n error instanceof InterpolationUnresolvableError ||\n error instanceof InvalidJobRunnerLabelsError\n );\n}\n\nexport class JobNotFoundError extends Error {\n constructor(jobId: string) {\n super(`Job not found or has no steps: ${jobId}`);\n this.name = 'JobNotFoundError';\n }\n}\n\nexport class JobLeaseNotActiveError extends Error {\n constructor(readonly jobExecutionId: string) {\n super(`Job lease is no longer active: ${jobExecutionId}`);\n this.name = 'JobLeaseNotActiveError';\n }\n}\n\nexport class InvalidJobRunnerLabelsError extends Error {\n constructor(readonly labels: readonly string[]) {\n super(`Job runner labels are invalid: ${labels.join(', ')}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\n// The job named by a lease is terminal, so it must not exchange its lease for\n// fresh checkout credentials. Server state is the final gate, not the token.\nexport class JobNotActiveError extends Error {\n constructor(\n readonly jobId: string,\n readonly status: JobStatus,\n ) {\n super(`Job ${jobId} is ${status} and cannot mint checkout credentials`);\n this.name = 'JobNotActiveError';\n }\n}\n\nexport class WorkflowRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run not found: ${workflowRunId}`);\n this.name = 'WorkflowRunNotFoundError';\n }\n}\n\nexport class WorkflowRunNotCancellableError extends Error {\n constructor(\n readonly workflowRunId: string,\n readonly status: WorkflowRunStatus,\n ) {\n super(`Workflow run ${workflowRunId} is ${status} and cannot be cancelled`);\n this.name = 'WorkflowRunNotCancellableError';\n }\n}\n\nexport class SourceRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Source workflow run not found: ${workflowRunId}`);\n this.name = 'SourceRunNotFoundError';\n }\n}\n\nexport class RunNotTerminalError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run is not terminal: ${workflowRunId}`);\n this.name = 'RunNotTerminalError';\n }\n}\n\nexport class NoFailedJobsError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run has no failed or cancelled jobs to re-run: ${workflowRunId}`);\n this.name = 'NoFailedJobsError';\n }\n}\n\n// The run's project (and therefore its source repository) cannot be resolved, so\n// there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(projectId: string) {\n super(`Checkout intent unresolved: project ${projectId} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class StepNotFoundError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} not found in job ${jobId}`);\n this.name = 'StepNotFoundError';\n }\n}\n\nexport class StepNotRunningError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} in job ${jobId} is not running and cannot accept a result`);\n this.name = 'StepNotRunningError';\n }\n}\n\n// A report whose attempt is ahead of the step's current attempt. The host\n// allocates attempt numbers, so a runner can never report one it was not\n// dispatched — this is a protocol error, not an idempotent no-op.\nexport class StepAttemptAheadError extends Error {\n constructor(\n readonly stepId: string,\n readonly jobId: string,\n readonly reportedAttempt: number,\n readonly currentAttempt: number,\n ) {\n super(\n `Step ${stepId} in job ${jobId} reported attempt ${reportedAttempt} ahead of current attempt ${currentAttempt}`,\n );\n this.name = 'StepAttemptAheadError';\n }\n}\n"],"names":["DefinitionNotFoundError","Error","definitionId","name","ProjectMismatchError","definitionProjectId","requestProjectId","AgentConfigUnresolvableError","options","AgentIntegrationMaterializationError","message","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","cause","field","source","envKey","undefined","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","JobLeaseNotActiveError","jobExecutionId","labels","join","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","projectId","StepNotFoundError","stepId","StepNotRunningError","StepAttemptAheadError","reportedAttempt","currentAttempt"],"mappings":"AAGA,OAAO,MAAMA,gCAAgCC;IAC3C,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sBAAsB,EAAEA,cAAc;QAC7C,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,6BAA6BH;IACxC,YAAYI,mBAA2B,EAAEC,gBAAwB,CAAE;QACjE,KAAK,CACH,CAAC,8BAA8B,EAAED,oBAAoB,8BAA8B,EAAEC,kBAAkB;QAEzG,IAAI,CAACH,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMI,qCAAqCN;IAChD,YACE,AAASC,YAAoB,EAC7BM,OAAkC,CAClC;QACA,KAAK,CAAC,CAAC,sDAAsD,EAAEN,cAAc,EAAEM,eAHtEN,eAAAA;QAIT,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMM,6CAA6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AAI,CAAC7B,IAAI,GAAG;IACd;AACF;AAEA,iFAAiF;AACjF,iCAAiC;AACjC,OAAO,MAAMkC,sCAAsCpC;IACjD,YAAYqC,SAAiB,CAAE;QAC7B,KAAK,CAAC,CAAC,oCAAoC,EAAEA,UAAU,UAAU,CAAC;QAClE,IAAI,CAACnC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMoC,0BAA0BtC;IACrC,YAAYuC,MAAc,EAAEhB,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEgB,OAAO,kBAAkB,EAAEhB,OAAO;QAChD,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMsC,4BAA4BxC;IACvC,YAAYuC,MAAc,EAAEhB,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEgB,OAAO,QAAQ,EAAEhB,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,kEAAkE;AAClE,OAAO,MAAMuC,8BAA8BzC;IACzC,YACE,AAASuC,MAAc,EACvB,AAAShB,KAAa,EACtB,AAASmB,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEJ,OAAO,QAAQ,EAAEhB,MAAM,kBAAkB,EAAEmB,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGJ,SAAAA,aACAhB,QAAAA,YACAmB,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAACzC,IAAI,GAAG;IACd;AACF"}
1
+ {"version":3,"sources":["../../src/core/errors.ts"],"sourcesContent":["import type {JobStatus} from './entities/job.js';\nimport type {WorkflowRunStatus} from './entities/workflow-run.js';\n\nexport class DefinitionNotFoundError extends Error {\n constructor(definitionId: string) {\n super(`Definition not found: ${definitionId}`);\n this.name = 'DefinitionNotFoundError';\n }\n}\n\nexport class ProjectMismatchError extends Error {\n constructor(definitionProjectId: string, requestProjectId: string) {\n super(\n `Definition belongs to project ${definitionProjectId}, but request targets project ${requestProjectId}`,\n );\n this.name = 'ProjectMismatchError';\n }\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n constructor(\n readonly definitionId: string,\n options?: ErrorOptions | undefined,\n ) {\n super(`Agent configuration cannot be resolved for definition ${definitionId}`, options);\n this.name = 'AgentConfigUnresolvableError';\n }\n}\n\nexport class AgentIntegrationMaterializationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'AgentIntegrationMaterializationError';\n }\n}\n\nexport type InterpolationUnresolvableField =\n | 'run'\n | 'env'\n | 'agent.prompt'\n | 'agent.model'\n | 'agent.provider'\n | 'job.runner'\n | 'job.outputs'\n | 'job.name'\n | 'step.name'\n | 'step.feedback';\n\nexport class InterpolationUnresolvableError extends Error {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n\n constructor(\n readonly definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n readonly cause?: unknown;\n },\n ) {\n super(interpolationUnresolvableMessage(definitionId, params), {cause: params.cause});\n this.name = 'InterpolationUnresolvableError';\n this.field = params.field;\n this.source = params.source;\n if (params.envKey !== undefined) this.envKey = params.envKey;\n }\n}\n\nfunction interpolationUnresolvableMessage(\n definitionId: string,\n params: {\n readonly field: InterpolationUnresolvableField;\n readonly source: string;\n readonly envKey?: string;\n },\n): string {\n const envSuffix = params.envKey === undefined ? '' : ` (${params.envKey})`;\n return `Workflow interpolation cannot be resolved for definition ${definitionId}: ${params.field}${envSuffix} uses \\`${params.source}\\`. Use has(x) ? x : '' for optional references.`;\n}\n\n/**\n * True when a `runWorkflow` failure can never succeed on retry: the definition is gone or\n * the subscription points at the wrong project. Callers (e.g. the trigger dispatcher) use this\n * to skip a permanently-broken target instead of retrying it forever. Every other failure is\n * treated as transient so at-least-once delivery can converge.\n */\nexport function isPermanentRunWorkflowError(error: unknown): boolean {\n return (\n error instanceof DefinitionNotFoundError ||\n error instanceof ProjectMismatchError ||\n error instanceof AgentConfigUnresolvableError ||\n error instanceof AgentIntegrationMaterializationError ||\n error instanceof InterpolationUnresolvableError ||\n error instanceof InvalidJobRunnerLabelsError\n );\n}\n\nexport class JobNotFoundError extends Error {\n constructor(jobId: string) {\n super(`Job not found or has no steps: ${jobId}`);\n this.name = 'JobNotFoundError';\n }\n}\n\nexport class InvalidJobRunnerLabelsError extends Error {\n constructor(readonly labels: readonly string[]) {\n super(`Job runner labels are invalid: ${labels.join(', ')}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\n// The job named by a lease is terminal, so it must not exchange its lease for\n// fresh checkout credentials. Server state is the final gate, not the token.\nexport class JobNotActiveError extends Error {\n constructor(\n readonly jobId: string,\n readonly status: JobStatus,\n ) {\n super(`Job ${jobId} is ${status} and cannot mint checkout credentials`);\n this.name = 'JobNotActiveError';\n }\n}\n\nexport class WorkflowRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run not found: ${workflowRunId}`);\n this.name = 'WorkflowRunNotFoundError';\n }\n}\n\nexport class WorkflowRunNotCancellableError extends Error {\n constructor(\n readonly workflowRunId: string,\n readonly status: WorkflowRunStatus,\n ) {\n super(`Workflow run ${workflowRunId} is ${status} and cannot be cancelled`);\n this.name = 'WorkflowRunNotCancellableError';\n }\n}\n\nexport class SourceRunNotFoundError extends Error {\n constructor(workflowRunId: string) {\n super(`Source workflow run not found: ${workflowRunId}`);\n this.name = 'SourceRunNotFoundError';\n }\n}\n\nexport class RunNotTerminalError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run is not terminal: ${workflowRunId}`);\n this.name = 'RunNotTerminalError';\n }\n}\n\nexport class NoFailedJobsError extends Error {\n constructor(workflowRunId: string) {\n super(`Workflow run has no failed or cancelled jobs to re-run: ${workflowRunId}`);\n this.name = 'NoFailedJobsError';\n }\n}\n\n// The run's project (and therefore its source repository) cannot be resolved, so\n// there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(projectId: string) {\n super(`Checkout intent unresolved: project ${projectId} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class StepNotFoundError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} not found in job ${jobId}`);\n this.name = 'StepNotFoundError';\n }\n}\n\nexport class StepNotRunningError extends Error {\n constructor(stepId: string, jobId: string) {\n super(`Step ${stepId} in job ${jobId} is not running and cannot accept a result`);\n this.name = 'StepNotRunningError';\n }\n}\n\n// A report whose attempt is ahead of the step's current attempt. The host\n// allocates attempt numbers, so a runner can never report one it was not\n// dispatched — this is a protocol error, not an idempotent no-op.\nexport class StepAttemptAheadError extends Error {\n constructor(\n readonly stepId: string,\n readonly jobId: string,\n readonly reportedAttempt: number,\n readonly currentAttempt: number,\n ) {\n super(\n `Step ${stepId} in job ${jobId} reported attempt ${reportedAttempt} ahead of current attempt ${currentAttempt}`,\n );\n this.name = 'StepAttemptAheadError';\n }\n}\n"],"names":["DefinitionNotFoundError","Error","definitionId","name","ProjectMismatchError","definitionProjectId","requestProjectId","AgentConfigUnresolvableError","options","AgentIntegrationMaterializationError","message","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","cause","field","source","envKey","undefined","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","labels","join","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","projectId","StepNotFoundError","stepId","StepNotRunningError","StepAttemptAheadError","reportedAttempt","currentAttempt"],"mappings":"AAGA,OAAO,MAAMA,gCAAgCC;IAC3C,YAAYC,YAAoB,CAAE;QAChC,KAAK,CAAC,CAAC,sBAAsB,EAAEA,cAAc;QAC7C,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMC,6BAA6BH;IACxC,YAAYI,mBAA2B,EAAEC,gBAAwB,CAAE;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AI,CAAC3B,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAM+B,0BAA0BjC;IACrC,YAAY6B,aAAqB,CAAE;QACjC,KAAK,CAAC,CAAC,wDAAwD,EAAEA,eAAe;QAChF,IAAI,CAAC3B,IAAI,GAAG;IACd;AACF;AAEA,iFAAiF;AACjF,iCAAiC;AACjC,OAAO,MAAMgC,sCAAsClC;IACjD,YAAYmC,SAAiB,CAAE;QAC7B,KAAK,CAAC,CAAC,oCAAoC,EAAEA,UAAU,UAAU,CAAC;QAClE,IAAI,CAACjC,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMkC,0BAA0BpC;IACrC,YAAYqC,MAAc,EAAEd,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEc,OAAO,kBAAkB,EAAEd,OAAO;QAChD,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMoC,4BAA4BtC;IACvC,YAAYqC,MAAc,EAAEd,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAEc,OAAO,QAAQ,EAAEd,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAACrB,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,kEAAkE;AAClE,OAAO,MAAMqC,8BAA8BvC;IACzC,YACE,AAASqC,MAAc,EACvB,AAASd,KAAa,EACtB,AAASiB,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEJ,OAAO,QAAQ,EAAEd,MAAM,kBAAkB,EAAEiB,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGJ,SAAAA,aACAd,QAAAA,YACAiB,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAACvC,IAAI,GAAG;IACd;AACF"}
@@ -13,9 +13,7 @@ export type NextStep = {
13
13
  status: CompletionStatus;
14
14
  };
15
15
  export interface NextStepForLeasedJobExecutionParams {
16
- jobId: string;
17
16
  jobExecutionId: string;
18
- runnerSessionId: string;
19
17
  agent?: AgentInterModuleClient | undefined;
20
18
  }
21
19
  export declare function nextStepForLeasedJobExecution(params: NextStepForLeasedJobExecutionParams): Promise<NextStep>;
@@ -1 +1 @@
1
- {"version":3,"file":"job-execution.d.ts","sourceRoot":"","sources":["../../src/core/job-execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AA8B9D,OAAO,KAAK,EAAgC,IAAI,EAAmB,MAAM,oBAAoB,CAAC;AAa9F,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,4CAA4C,CAAC;AAcpD,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,sCAAsC,CAAC;AAElF,KAAK,gBAAgB,GAAG,uBAAuB,CAAC;AAUhD,MAAM,MAAM,QAAQ,GAChB;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAC,GAC/C;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAC,CAAC;AAqQ7C,MAAM,WAAW,mCAAmC;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;CAC5C;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,mCAAmC,GAC1C,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,sBAAsB,GAAG,SAAS,GACzC,OAAO,CAAC,QAAQ,CAAC,CAOnB;AAED,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MA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"}
@@ -1,10 +1,10 @@
1
1
  import { coerceStepOutputs, evaluatePlannedPredicateAtSite } from '@shipfox/expression';
2
2
  import { withTransaction } from '#db/db.js';
3
- import { countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getDirectDependencyJobContexts, getJobExecutionById, getLatestJobExecutionByJobId, getStepAttemptsByJobExecutionId, getStepsByJobExecutionIdForUpdate, insertRunningStepAttempt, lockActiveJobExecutionLeaseForUpdate, markStepRunning, markStepSkipped, settleJobFailed, writeJobStepsSettledOutbox } from '#db/workflow-runs.js';
3
+ import { countStepAttempts, dispatchStepWithCompletedConfig, finishStepAttempt, getDirectDependencyJobContexts, getJobExecutionById, getLatestJobExecutionByJobId, getStepAttemptsByJobExecutionId, getStepsByJobExecutionIdForUpdate, insertRunningStepAttempt, markStepRunning, markStepSkipped, settleJobFailed, writeJobStepsSettledOutbox } from '#db/workflow-runs.js';
4
4
  import { recordWorkflowJobExecutionStepsSettled, recordWorkflowStepRestartEnqueued } from '#metrics/instance.js';
5
5
  import { createAgentDefaultsResolver } from './agent-defaults.js';
6
6
  import { defaultStepConditionTrace, explicitConditionTrace } from './condition-trace.js';
7
- import { AgentConfigUnresolvableError, InterpolationUnresolvableError, JobLeaseNotActiveError, JobNotFoundError, StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from './errors.js';
7
+ import { AgentConfigUnresolvableError, InterpolationUnresolvableError, JobNotFoundError, StepAttemptAheadError, StepNotFoundError, StepNotRunningError } from './errors.js';
8
8
  import { assembleStepDispatchContext } from './step-config/assemble-run-context.js';
9
9
  import { completeStepDispatchConfig } from './step-config/complete-step-dispatch-config.js';
10
10
  import { applyStepTransition } from './step-transition/apply-step-transition.js';
@@ -234,11 +234,7 @@ function dispatchConfigError(error) {
234
234
  };
235
235
  }
236
236
  export function nextStepForLeasedJobExecution(params) {
237
- return withTransaction(async (tx)=>{
238
- const leaseIsActive = await lockActiveJobExecutionLeaseForUpdate(params, tx);
239
- if (!leaseIsActive) throw new JobLeaseNotActiveError(params.jobExecutionId);
240
- return nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent);
241
- });
237
+ return withTransaction((tx)=>nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent));
242
238
  }
243
239
  export function nextStepForJob(jobId, agent) {
244
240
  return withTransaction(async (tx)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/job-execution.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {LogOutcomeDto} from '@shipfox/api-workflows-dto';\nimport {\n coerceStepOutputs,\n evaluatePlannedPredicateAtSite,\n type StepOutputCoercionError,\n} from '@shipfox/expression';\nimport {type Tx, withTransaction} from '#db/db.js';\nimport {\n countStepAttempts,\n dispatchStepWithCompletedConfig,\n finishStepAttempt,\n getDirectDependencyJobContexts,\n getJobExecutionById,\n getLatestJobExecutionByJobId,\n getStepAttemptsByJobExecutionId,\n getStepsByJobExecutionIdForUpdate,\n insertRunningStepAttempt,\n lockActiveJobExecutionLeaseForUpdate,\n markStepRunning,\n markStepSkipped,\n settleJobFailed,\n writeJobStepsSettledOutbox,\n} from '#db/workflow-runs.js';\nimport {\n recordWorkflowJobExecutionStepsSettled,\n recordWorkflowStepRestartEnqueued,\n} from '#metrics/instance.js';\nimport {createAgentDefaultsResolver} from './agent-defaults.js';\nimport {defaultStepConditionTrace, explicitConditionTrace} from './condition-trace.js';\nimport type {JobExecution} from './entities/job-execution.js';\nimport type {PersistedEvaluationTraceEntry, Step, StepStatusReason} from './entities/step.js';\nimport {\n AgentConfigUnresolvableError,\n InterpolationUnresolvableError,\n JobLeaseNotActiveError,\n JobNotFoundError,\n StepAttemptAheadError,\n StepNotFoundError,\n StepNotRunningError,\n} from './errors.js';\nimport {assembleStepDispatchContext} from './step-config/assemble-run-context.js';\nimport {completeStepDispatchConfig} from './step-config/complete-step-dispatch-config.js';\nimport type {WorkflowEvaluationContext} from './step-config/workflow-evaluation-context.js';\nimport {\n applyStepTransition,\n type StepProgressionMetrics,\n type StepProgressionOutcome,\n} from './step-transition/apply-step-transition.js';\nimport {\n decideStepTransition,\n deriveCompletion,\n isTerminal,\n type StepTransitionDecision,\n} from './step-transition/decide-step-transition.js';\nimport {\n evaluateGate,\n evaluateGateFeedback,\n gateResultPayload,\n readStepGate,\n} from './step-transition/evaluate-gate.js';\nimport {readStepOutputs} from './step-transition/read-step-outputs.js';\nimport type {RuntimeCompletionStatus} from './workflow-scheduling/runtime-dag.js';\n\ntype CompletionStatus = RuntimeCompletionStatus;\n\ntype ReportedStepResult = {\n readonly status: 'succeeded' | 'failed';\n readonly error: Record<string, unknown> | null;\n readonly output: Record<string, unknown> | null;\n readonly response: string | null;\n readonly exitCode: number | null;\n};\n\nexport type NextStep =\n | {kind: 'step'; step: Step; dispatched: boolean}\n | {kind: 'done'; status: CompletionStatus};\n\ntype DispatchConfigError = InterpolationUnresolvableError | AgentConfigUnresolvableError;\n\ninterface PendingStepDispatchParams {\n readonly jobExecutionId: string;\n readonly pending: Step;\n readonly jobExecution: JobExecution;\n readonly context: WorkflowEvaluationContext;\n readonly tx: Tx;\n readonly agent?: AgentInterModuleClient | undefined;\n}\n\ninterface ResolvePendingStepParams {\n readonly jobExecutionId: string;\n readonly steps: Step[];\n readonly jobExecution: JobExecution;\n readonly attempts: Awaited<ReturnType<typeof getStepAttemptsByJobExecutionId>>;\n readonly jobs: Awaited<ReturnType<typeof getDirectDependencyJobContexts>>;\n readonly tx: Tx;\n readonly agent?: AgentInterModuleClient | undefined;\n}\n\ntype StepConditionOutcome =\n | {kind: 'run'}\n | {\n kind: 'skip';\n statusReason: StepStatusReason;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[];\n };\n\nasync function nextStepForJobExecutionInTransaction(\n jobExecutionId: string,\n tx: Tx,\n agent?: AgentInterModuleClient | undefined,\n): Promise<NextStep> {\n const steps = await getStepsByJobExecutionIdForUpdate(jobExecutionId, tx);\n const hasNoSteps = steps.length === 0;\n\n // An unknown or step-less execution has nothing to progress; rejecting it stops\n // a bad id from deriving a vacuous 'succeeded' completion below.\n if (hasNoSteps) throw new JobNotFoundError(jobExecutionId);\n\n // Re-deliver the in-flight step rather than advancing, so a retried pull\n // cannot skip a step.\n const running = steps.find((step) => step.status === 'running');\n const hasRunningStep = running !== undefined;\n if (hasRunningStep) return {kind: 'step', step: running, dispatched: false};\n\n const firstPending = steps.find((step) => step.status === 'pending');\n const hasPendingStep = firstPending !== undefined;\n if (!hasPendingStep) return {kind: 'done', status: deriveCompletion(steps)};\n\n const jobExecution = await getJobExecutionById(jobExecutionId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobExecutionId);\n\n const attempts = await getStepAttemptsByJobExecutionId(jobExecutionId, tx);\n const jobs = await getDirectDependencyJobContexts(jobExecution.jobId, tx);\n\n return resolveNextPendingStep({jobExecutionId, steps, jobExecution, attempts, jobs, tx, agent});\n}\n\nasync function resolveNextPendingStep({\n jobExecutionId,\n steps,\n jobExecution,\n attempts,\n jobs,\n tx,\n agent,\n}: ResolvePendingStepParams): Promise<NextStep> {\n let skippedAny = false;\n let currentSteps = steps;\n\n while (true) {\n const pending = currentSteps.find((step) => step.status === 'pending');\n if (pending === undefined) {\n const status = deriveCompletion(currentSteps);\n if (skippedAny) {\n await writeJobStepsSettledOutbox(tx, {\n jobId: jobExecution.jobId,\n jobExecutionId,\n status,\n });\n recordWorkflowJobExecutionStepsSettled(status);\n }\n return {kind: 'done', status};\n }\n\n const context = assembleStepDispatchContext({\n steps: currentSteps,\n attempts,\n targetStepId: pending.id,\n jobExecution,\n jobs,\n });\n const condition = evaluateStepCondition({step: pending, context});\n if (condition.kind === 'run') {\n return dispatchPendingStep({jobExecutionId, pending, jobExecution, context, tx, agent});\n }\n\n const skipped = await markStepSkipped(\n {\n jobExecutionId,\n stepId: pending.id,\n statusReason: condition.statusReason,\n evaluationTrace: condition.evaluationTrace,\n },\n tx,\n );\n const skippedStep = skipped ?? {\n ...pending,\n status: 'skipped' as const,\n statusReason: condition.statusReason,\n evaluationTrace: condition.evaluationTrace,\n error: null,\n };\n currentSteps = currentSteps.map((step) => (step.id === pending.id ? skippedStep : step));\n skippedAny = true;\n }\n}\n\nasync function dispatchPendingStep(params: PendingStepDispatchParams): Promise<NextStep> {\n const hasConfigPlan = params.pending.configPlan !== null;\n if (hasConfigPlan) return dispatchPendingStepWithConfigPlan(params);\n\n const marked = await markStepRunning(\n {jobExecutionId: params.jobExecutionId, stepId: params.pending.id},\n params.tx,\n );\n return {kind: 'step', step: marked ?? params.pending, dispatched: true};\n}\n\nasync function dispatchPendingStepWithConfigPlan({\n jobExecutionId,\n pending,\n jobExecution,\n context,\n tx,\n agent,\n}: PendingStepDispatchParams): Promise<NextStep> {\n try {\n const completed = await completeStepDispatchConfig({\n step: pending,\n context,\n resolveAgentDefaults: agent ? createAgentDefaultsResolver(agent, null) : undefined,\n definitionId: jobExecution.jobId,\n });\n const marked = await dispatchStepWithCompletedConfig(\n {\n jobExecutionId,\n stepId: pending.id,\n config: completed.config,\n evaluationTrace: completed.trace,\n },\n tx,\n );\n return {kind: 'step', step: marked ?? {...pending, config: completed.config}, dispatched: true};\n } catch (error) {\n const configError = toDispatchConfigError(error);\n const isConfigError = configError !== null;\n if (!isConfigError) throw error;\n\n const failureError = dispatchConfigError(configError);\n await insertRunningStepAttempt(\n {\n jobExecutionId,\n stepId: pending.id,\n attempt: pending.currentAttempt,\n },\n tx,\n );\n await finishStepAttempt(\n {\n stepId: pending.id,\n attempt: pending.currentAttempt,\n status: 'failed',\n error: failureError,\n logOutcome: 'abandoned',\n },\n tx,\n );\n const status = await settleJobFailed(tx, {\n jobId: jobExecution.jobId,\n jobExecutionId,\n failedStepId: pending.id,\n error: failureError,\n });\n if (status) recordWorkflowJobExecutionStepsSettled(status);\n return status === null\n ? nextStepForJobExecutionInTransaction(jobExecutionId, tx, agent)\n : {kind: 'done', status};\n }\n}\n\nfunction evaluateStepCondition(params: {\n readonly step: Step;\n readonly context: WorkflowEvaluationContext;\n}): StepConditionOutcome {\n const condition = params.step.condition;\n if (condition === null) {\n const execution = params.context.values.execution as {failed?: unknown} | undefined;\n return execution?.failed === true\n ? {\n kind: 'skip',\n statusReason: 'default_gate_rejected',\n evaluationTrace: defaultStepConditionTrace(),\n }\n : {kind: 'run'};\n }\n\n const outcome = evaluatePlannedPredicateAtSite({\n expression: condition,\n field: 'step.if',\n site: params.context.site,\n context: params.context.values,\n });\n const evaluationTrace = explicitConditionTrace({\n expression: condition,\n field: 'step.if',\n route: outcome.route,\n site: params.context.site,\n value: outcome.value,\n degraded: outcome.evaluationFailed,\n });\n if (outcome.evaluationFailed) {\n return {kind: 'skip', statusReason: 'condition_errored', evaluationTrace};\n }\n return outcome.value\n ? {kind: 'run'}\n : {kind: 'skip', statusReason: 'condition_rejected', evaluationTrace};\n}\n\nfunction toDispatchConfigError(error: unknown): DispatchConfigError | null {\n const isInterpolationError = error instanceof InterpolationUnresolvableError;\n if (isInterpolationError) return error;\n\n const isAgentConfigError = error instanceof AgentConfigUnresolvableError;\n if (isAgentConfigError) return error;\n\n return null;\n}\n\nfunction dispatchConfigError(error: DispatchConfigError): Record<string, unknown> {\n if (error instanceof InterpolationUnresolvableError) {\n return {\n message: error.message,\n reason: 'config_unresolvable',\n field: error.envKey === undefined ? error.field : `${error.field}.${error.envKey}`,\n source: error.source,\n };\n }\n\n return {\n message: error.message,\n reason: 'config_unresolvable',\n field: 'agent',\n source: 'agent',\n };\n}\n\nexport interface NextStepForLeasedJobExecutionParams {\n jobId: string;\n jobExecutionId: string;\n runnerSessionId: string;\n agent?: AgentInterModuleClient | undefined;\n}\n\nexport function nextStepForLeasedJobExecution(\n params: NextStepForLeasedJobExecutionParams,\n): Promise<NextStep> {\n return withTransaction(async (tx) => {\n const leaseIsActive = await lockActiveJobExecutionLeaseForUpdate(params, tx);\n if (!leaseIsActive) throw new JobLeaseNotActiveError(params.jobExecutionId);\n\n return nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent);\n });\n}\n\nexport function nextStepForJob(\n jobId: string,\n agent?: AgentInterModuleClient | undefined,\n): Promise<NextStep> {\n return withTransaction(async (tx) => {\n const jobExecution = await getLatestJobExecutionByJobId(jobId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobId);\n\n return nextStepForJobExecutionInTransaction(jobExecution.id, tx, agent);\n });\n}\n\nexport interface RecordStepResultParams {\n jobExecutionId: string;\n stepId: string;\n status: 'succeeded' | 'failed';\n error?: Record<string, unknown> | null;\n // Structured runner output feeds gate predicates and audit/history on the\n // attempt row; the current step projection keeps only status/error.\n output?: Record<string, unknown> | null;\n response?: string | null;\n exitCode?: number | null;\n // The attempt the runner was dispatched. Omitted = \"the step's current\n // attempt\" (back-compat for callers that don't track attempts yet).\n attempt?: number;\n logOutcome?: LogOutcomeDto;\n}\n\nexport type RecordStepResultOutcome = StepProgressionOutcome;\n\ninterface RecordStepResultTransactionResult {\n outcome: RecordStepResultOutcome;\n metrics: StepProgressionMetrics;\n}\n\nfunction outcomeFromSteps(steps: Step[]): RecordStepResultOutcome {\n return steps.every((step) => isTerminal(step.status))\n ? {jobFinished: true, status: deriveCompletion(steps)}\n : {jobFinished: false};\n}\n\nexport async function recordStepResult(\n params: RecordStepResultParams,\n): Promise<RecordStepResultOutcome> {\n const progression = await withTransaction<RecordStepResultTransactionResult>((tx) =>\n recordStepResultInTransaction(params, tx),\n );\n\n recordStepProgressionMetrics(progression.metrics);\n\n return progression.outcome;\n}\n\nasync function recordStepResultInTransaction(\n params: RecordStepResultParams,\n tx: Tx,\n): Promise<RecordStepResultTransactionResult> {\n const jobExecutionId = params.jobExecutionId;\n\n const jobExecution = await getJobExecutionById(jobExecutionId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobExecutionId);\n\n const steps = await getStepsByJobExecutionIdForUpdate(jobExecutionId, tx);\n const target = steps.find((step) => step.id === params.stepId);\n const hasTargetStep = target !== undefined;\n\n if (!hasTargetStep) throw new StepNotFoundError(params.stepId, jobExecutionId);\n\n const current = target.currentAttempt;\n const reported = params.attempt ?? current;\n const reportClassification = classifyReportedStep(target, reported, jobExecution.jobId);\n if (reportClassification instanceof Error) throw reportClassification;\n if (reportClassification === 'noop') return {outcome: outcomeFromSteps(steps), metrics: {}};\n\n // Migration/back-compat boundary: a running step may predate the\n // step_attempts table or have been marked running by legacy code. Create\n // the audit row just before finalization if dispatch did not already do it.\n await insertRunningStepAttempt(\n {\n jobExecutionId,\n stepId: params.stepId,\n attempt: current,\n config: target.config,\n },\n tx,\n );\n\n let result: ReportedStepResult = {\n status: params.status,\n error: params.error ?? null,\n output: params.output ?? null,\n response: params.response ?? null,\n exitCode: params.exitCode ?? null,\n };\n const outputCoercion = coerceReportedStepOutput(target.config, result);\n if (outputCoercion.kind === 'coerced') {\n result = {...result, output: outputCoercion.output};\n }\n if (outputCoercion.kind === 'failed') {\n result = {\n status: 'failed',\n error: outputInvalidError(outputCoercion.error),\n output: null,\n response: result.response,\n exitCode: result.exitCode,\n };\n }\n\n // Evaluate the gate (if any) at the service boundary — the only place the CEL\n // engine runs — and pass the precomputed outcome into the pure decision.\n const shouldEvaluateGate = outputCoercion.kind !== 'failed';\n const gate = shouldEvaluateGate ? readStepGate(target.config) : undefined;\n const gateOutcome = shouldEvaluateGate ? evaluateGate(gate, result) : {kind: 'no-gate' as const};\n const hasRestartPolicy = gate?.onFailure?.restartFrom !== undefined;\n // The restart cap is bounded on the gating step's OWN attempts, not its\n // current_attempt (which a rewind inflates for downstream steps).\n const gatingAttemptCount = hasRestartPolicy\n ? await countStepAttempts(params.stepId, tx)\n : undefined;\n const decision = decideStepTransition({\n steps,\n target,\n reportedAttempt: reported,\n result,\n gateOutcome,\n ...(gate?.onFailure ? {gateOnFailure: gate.onFailure} : {}),\n ...(gatingAttemptCount !== undefined ? {gatingAttemptCount} : {}),\n });\n const resolvedDecision = resolveRestartFeedback({\n decision,\n gate,\n result,\n definitionId: jobExecution.jobId,\n });\n\n return applyStepTransition(\n resolvedDecision,\n {\n jobId: jobExecution.jobId,\n jobExecutionId,\n result,\n logOutcome: params.logOutcome ?? 'drained',\n gateResult: gateResultPayload(gateOutcome, result.exitCode),\n },\n tx,\n );\n}\n\ntype OutputCoercionResult =\n | {kind: 'not-applicable'}\n | {kind: 'coerced'; output: Record<string, unknown>}\n | {kind: 'failed'; error: StepOutputCoercionError};\n\nexport type ReportedStepClassification = 'proceed' | 'noop' | Error;\n\nexport function classifyReportedStep(\n target: Step,\n reportedAttempt: number,\n jobId: string,\n): ReportedStepClassification {\n const currentAttempt = target.currentAttempt;\n if (reportedAttempt > currentAttempt) {\n return new StepAttemptAheadError(target.id, jobId, reportedAttempt, currentAttempt);\n }\n\n if (reportedAttempt < currentAttempt) return 'noop';\n if (isTerminal(target.status)) return 'noop';\n if (target.status === 'pending') return new StepNotRunningError(target.id, jobId);\n return 'proceed';\n}\n\nfunction coerceReportedStepOutput(\n config: Record<string, unknown>,\n result: ReportedStepResult,\n): OutputCoercionResult {\n if (result.status !== 'succeeded') return {kind: 'not-applicable'};\n\n const declarations = readStepOutputs(config);\n if (declarations === undefined) return {kind: 'not-applicable'};\n\n const coerced = coerceStepOutputs({declarations, output: result.output});\n if (!coerced.ok) return {kind: 'failed', error: coerced.error};\n return {kind: 'coerced', output: coerced.output};\n}\n\nfunction outputInvalidError(error: StepOutputCoercionError): Record<string, unknown> {\n return {\n message: error.message,\n reason: 'output_invalid',\n field: `outputs.${error.key}`,\n outputKey: error.key,\n issue: error.reason,\n ...(error.expectedType === undefined ? {} : {expectedType: error.expectedType}),\n ...(error.schemaError === undefined ? {} : {schemaError: error.schemaError}),\n };\n}\n\nfunction resolveRestartFeedback(params: {\n decision: StepTransitionDecision;\n gate: ReturnType<typeof readStepGate>;\n result: ReportedStepResult;\n definitionId: string;\n}): StepTransitionDecision {\n if (params.decision.kind !== 'restart-job-from-step') return params.decision;\n if (params.gate === undefined) return params.decision;\n\n try {\n return {\n ...params.decision,\n feedback: evaluateGateFeedback({\n gate: params.gate,\n result: params.result,\n definitionId: params.definitionId,\n }),\n };\n } catch (error) {\n if (error instanceof InterpolationUnresolvableError) {\n return {\n kind: 'fail-job',\n failedStepId: params.decision.failedStepId,\n attempt: params.decision.attempt,\n failureError: dispatchConfigError(error),\n };\n }\n throw error;\n }\n}\n\nfunction recordStepProgressionMetrics(metrics: StepProgressionMetrics): void {\n const settledStatus = metrics.jobStepsSettledStatus;\n const hasSettledStatus = settledStatus !== undefined;\n if (hasSettledStatus) recordWorkflowJobExecutionStepsSettled(settledStatus);\n\n const restartWasEnqueued = metrics.stepRestartEnqueued === true;\n if (restartWasEnqueued) recordWorkflowStepRestartEnqueued();\n}\n"],"names":["coerceStepOutputs","evaluatePlannedPredicateAtSite","withTransaction","countStepAttempts","dispatchStepWithCompletedConfig","finishStepAttempt","getDirectDependencyJobContexts","getJobExecutionById","getLatestJobExecutionByJobId","getStepAttemptsByJobExecutionId","getStepsByJobExecutionIdForUpdate","insertRunningStepAttempt","lockActiveJobExecutionLeaseForUpdate","markStepRunning","markStepSkipped","settleJobFailed","writeJobStepsSettledOutbox","recordWorkflowJobExecutionStepsSettled","recordWorkflowStepRestartEnqueued","createAgentDefaultsResolver","defaultStepConditionTrace","explicitConditionTrace","AgentConfigUnresolvableError","InterpolationUnresolvableError","JobLeaseNotActiveError","JobNotFoundError","StepAttemptAheadError","StepNotFoundError","StepNotRunningError","assembleStepDispatchContext","completeStepDispatchConfig","applyStepTransition","decideStepTransition","deriveCompletion","isTerminal","evaluateGate","evaluateGateFeedback","gateResultPayload","readStepGate","readStepOutputs","nextStepForJobExecutionInTransaction","jobExecutionId","tx","agent","steps","hasNoSteps","length","running","find","step","status","hasRunningStep","undefined","kind","dispatched","firstPending","hasPendingStep","jobExecution","attempts","jobs","jobId","resolveNextPendingStep","skippedAny","currentSteps","pending","context","targetStepId","id","condition","evaluateStepCondition","dispatchPendingStep","skipped","stepId","statusReason","evaluationTrace","skippedStep","error","map","params","hasConfigPlan","configPlan","dispatchPendingStepWithConfigPlan","marked","completed","resolveAgentDefaults","definitionId","config","trace","configError","toDispatchConfigError","isConfigError","failureError","dispatchConfigError","attempt","currentAttempt","logOutcome","failedStepId","execution","values","failed","outcome","expression","field","site","route","value","degraded","evaluationFailed","isInterpolationError","isAgentConfigError","message","reason","envKey","source","nextStepForLeasedJobExecution","leaseIsActive","nextStepForJob","outcomeFromSteps","every","jobFinished","recordStepResult","progression","recordStepResultInTransaction","recordStepProgressionMetrics","metrics","target","hasTargetStep","current","reported","reportClassification","classifyReportedStep","Error","result","output","response","exitCode","outputCoercion","coerceReportedStepOutput","outputInvalidError","shouldEvaluateGate","gate","gateOutcome","hasRestartPolicy","onFailure","restartFrom","gatingAttemptCount","decision","reportedAttempt","gateOnFailure","resolvedDecision","resolveRestartFeedback","gateResult","declarations","coerced","ok","key","outputKey","issue","expectedType","schemaError","feedback","settledStatus","jobStepsSettledStatus","hasSettledStatus","restartWasEnqueued","stepRestartEnqueued"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,8BAA8B,QAEzB,sBAAsB;AAC7B,SAAiBC,eAAe,QAAO,YAAY;AACnD,SACEC,iBAAiB,EACjBC,+BAA+B,EAC/BC,iBAAiB,EACjBC,8BAA8B,EAC9BC,mBAAmB,EACnBC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,iCAAiC,EACjCC,wBAAwB,EACxBC,oCAAoC,EACpCC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,0BAA0B,QACrB,uBAAuB;AAC9B,SACEC,sCAAsC,EACtCC,iCAAiC,QAC5B,uBAAuB;AAC9B,SAAQC,2BAA2B,QAAO,sBAAsB;AAChE,SAAQC,yBAAyB,EAAEC,sBAAsB,QAAO,uBAAuB;AAGvF,SACEC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,sBAAsB,EACtBC,gBAAgB,EAChBC,qBAAqB,EACrBC,iBAAiB,EACjBC,mBAAmB,QACd,cAAc;AACrB,SAAQC,2BAA2B,QAAO,wCAAwC;AAClF,SAAQC,0BAA0B,QAAO,iDAAiD;AAE1F,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B;gBAC7BwG,MAAM9D,OAAO8D,IAAI;gBACjBR,QAAQtD,OAAOsD,MAAM;gBACrB/C,cAAcP,OAAOO,YAAY;YACnC;QACF;IACF,EAAE,OAAOT,OAAO;QACd,IAAIA,iBAAiBrD,gCAAgC;YACnD,OAAO;gBACL8B,MAAM;gBACN2C,cAAclB,OAAOoE,QAAQ,CAAClD,YAAY;gBAC1CH,SAASf,OAAOoE,QAAQ,CAACrD,OAAO;gBAChCF,cAAcC,oBAAoBhB;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAAS+C,6BAA6BC,OAA+B;IACnE,MAAMqC,gBAAgBrC,QAAQsC,qBAAqB;IACnD,MAAMC,mBAAmBF,kBAAkB7G;IAC3C,IAAI+G,kBAAkBlJ,uCAAuCgJ;IAE7D,MAAMG,qBAAqBxC,QAAQyC,mBAAmB,KAAK;IAC3D,IAAID,oBAAoBlJ;AAC1B"}
1
+ {"version":3,"sources":["../../src/core/job-execution.ts"],"sourcesContent":["import type {AgentInterModuleClient} from '@shipfox/api-agent-dto/inter-module';\nimport type {LogOutcomeDto} from '@shipfox/api-workflows-dto';\nimport {\n coerceStepOutputs,\n evaluatePlannedPredicateAtSite,\n type StepOutputCoercionError,\n} from '@shipfox/expression';\nimport {type Tx, withTransaction} from '#db/db.js';\nimport {\n countStepAttempts,\n dispatchStepWithCompletedConfig,\n finishStepAttempt,\n getDirectDependencyJobContexts,\n getJobExecutionById,\n getLatestJobExecutionByJobId,\n getStepAttemptsByJobExecutionId,\n getStepsByJobExecutionIdForUpdate,\n insertRunningStepAttempt,\n markStepRunning,\n markStepSkipped,\n settleJobFailed,\n writeJobStepsSettledOutbox,\n} from '#db/workflow-runs.js';\nimport {\n recordWorkflowJobExecutionStepsSettled,\n recordWorkflowStepRestartEnqueued,\n} from '#metrics/instance.js';\nimport {createAgentDefaultsResolver} from './agent-defaults.js';\nimport {defaultStepConditionTrace, explicitConditionTrace} from './condition-trace.js';\nimport type {JobExecution} from './entities/job-execution.js';\nimport type {PersistedEvaluationTraceEntry, Step, StepStatusReason} from './entities/step.js';\nimport {\n AgentConfigUnresolvableError,\n InterpolationUnresolvableError,\n JobNotFoundError,\n StepAttemptAheadError,\n StepNotFoundError,\n StepNotRunningError,\n} from './errors.js';\nimport {assembleStepDispatchContext} from './step-config/assemble-run-context.js';\nimport {completeStepDispatchConfig} from './step-config/complete-step-dispatch-config.js';\nimport type {WorkflowEvaluationContext} from './step-config/workflow-evaluation-context.js';\nimport {\n applyStepTransition,\n type StepProgressionMetrics,\n type StepProgressionOutcome,\n} from './step-transition/apply-step-transition.js';\nimport {\n decideStepTransition,\n deriveCompletion,\n isTerminal,\n type StepTransitionDecision,\n} from './step-transition/decide-step-transition.js';\nimport {\n evaluateGate,\n evaluateGateFeedback,\n gateResultPayload,\n readStepGate,\n} from './step-transition/evaluate-gate.js';\nimport {readStepOutputs} from './step-transition/read-step-outputs.js';\nimport type {RuntimeCompletionStatus} from './workflow-scheduling/runtime-dag.js';\n\ntype CompletionStatus = RuntimeCompletionStatus;\n\ntype ReportedStepResult = {\n readonly status: 'succeeded' | 'failed';\n readonly error: Record<string, unknown> | null;\n readonly output: Record<string, unknown> | null;\n readonly response: string | null;\n readonly exitCode: number | null;\n};\n\nexport type NextStep =\n | {kind: 'step'; step: Step; dispatched: boolean}\n | {kind: 'done'; status: CompletionStatus};\n\ntype DispatchConfigError = InterpolationUnresolvableError | AgentConfigUnresolvableError;\n\ninterface PendingStepDispatchParams {\n readonly jobExecutionId: string;\n readonly pending: Step;\n readonly jobExecution: JobExecution;\n readonly context: WorkflowEvaluationContext;\n readonly tx: Tx;\n readonly agent?: AgentInterModuleClient | undefined;\n}\n\ninterface ResolvePendingStepParams {\n readonly jobExecutionId: string;\n readonly steps: Step[];\n readonly jobExecution: JobExecution;\n readonly attempts: Awaited<ReturnType<typeof getStepAttemptsByJobExecutionId>>;\n readonly jobs: Awaited<ReturnType<typeof getDirectDependencyJobContexts>>;\n readonly tx: Tx;\n readonly agent?: AgentInterModuleClient | undefined;\n}\n\ntype StepConditionOutcome =\n | {kind: 'run'}\n | {\n kind: 'skip';\n statusReason: StepStatusReason;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[];\n };\n\nasync function nextStepForJobExecutionInTransaction(\n jobExecutionId: string,\n tx: Tx,\n agent?: AgentInterModuleClient | undefined,\n): Promise<NextStep> {\n const steps = await getStepsByJobExecutionIdForUpdate(jobExecutionId, tx);\n const hasNoSteps = steps.length === 0;\n\n // An unknown or step-less execution has nothing to progress; rejecting it stops\n // a bad id from deriving a vacuous 'succeeded' completion below.\n if (hasNoSteps) throw new JobNotFoundError(jobExecutionId);\n\n // Re-deliver the in-flight step rather than advancing, so a retried pull\n // cannot skip a step.\n const running = steps.find((step) => step.status === 'running');\n const hasRunningStep = running !== undefined;\n if (hasRunningStep) return {kind: 'step', step: running, dispatched: false};\n\n const firstPending = steps.find((step) => step.status === 'pending');\n const hasPendingStep = firstPending !== undefined;\n if (!hasPendingStep) return {kind: 'done', status: deriveCompletion(steps)};\n\n const jobExecution = await getJobExecutionById(jobExecutionId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobExecutionId);\n\n const attempts = await getStepAttemptsByJobExecutionId(jobExecutionId, tx);\n const jobs = await getDirectDependencyJobContexts(jobExecution.jobId, tx);\n\n return resolveNextPendingStep({jobExecutionId, steps, jobExecution, attempts, jobs, tx, agent});\n}\n\nasync function resolveNextPendingStep({\n jobExecutionId,\n steps,\n jobExecution,\n attempts,\n jobs,\n tx,\n agent,\n}: ResolvePendingStepParams): Promise<NextStep> {\n let skippedAny = false;\n let currentSteps = steps;\n\n while (true) {\n const pending = currentSteps.find((step) => step.status === 'pending');\n if (pending === undefined) {\n const status = deriveCompletion(currentSteps);\n if (skippedAny) {\n await writeJobStepsSettledOutbox(tx, {\n jobId: jobExecution.jobId,\n jobExecutionId,\n status,\n });\n recordWorkflowJobExecutionStepsSettled(status);\n }\n return {kind: 'done', status};\n }\n\n const context = assembleStepDispatchContext({\n steps: currentSteps,\n attempts,\n targetStepId: pending.id,\n jobExecution,\n jobs,\n });\n const condition = evaluateStepCondition({step: pending, context});\n if (condition.kind === 'run') {\n return dispatchPendingStep({jobExecutionId, pending, jobExecution, context, tx, agent});\n }\n\n const skipped = await markStepSkipped(\n {\n jobExecutionId,\n stepId: pending.id,\n statusReason: condition.statusReason,\n evaluationTrace: condition.evaluationTrace,\n },\n tx,\n );\n const skippedStep = skipped ?? {\n ...pending,\n status: 'skipped' as const,\n statusReason: condition.statusReason,\n evaluationTrace: condition.evaluationTrace,\n error: null,\n };\n currentSteps = currentSteps.map((step) => (step.id === pending.id ? skippedStep : step));\n skippedAny = true;\n }\n}\n\nasync function dispatchPendingStep(params: PendingStepDispatchParams): Promise<NextStep> {\n const hasConfigPlan = params.pending.configPlan !== null;\n if (hasConfigPlan) return dispatchPendingStepWithConfigPlan(params);\n\n const marked = await markStepRunning(\n {jobExecutionId: params.jobExecutionId, stepId: params.pending.id},\n params.tx,\n );\n return {kind: 'step', step: marked ?? params.pending, dispatched: true};\n}\n\nasync function dispatchPendingStepWithConfigPlan({\n jobExecutionId,\n pending,\n jobExecution,\n context,\n tx,\n agent,\n}: PendingStepDispatchParams): Promise<NextStep> {\n try {\n const completed = await completeStepDispatchConfig({\n step: pending,\n context,\n resolveAgentDefaults: agent ? createAgentDefaultsResolver(agent, null) : undefined,\n definitionId: jobExecution.jobId,\n });\n const marked = await dispatchStepWithCompletedConfig(\n {\n jobExecutionId,\n stepId: pending.id,\n config: completed.config,\n evaluationTrace: completed.trace,\n },\n tx,\n );\n return {kind: 'step', step: marked ?? {...pending, config: completed.config}, dispatched: true};\n } catch (error) {\n const configError = toDispatchConfigError(error);\n const isConfigError = configError !== null;\n if (!isConfigError) throw error;\n\n const failureError = dispatchConfigError(configError);\n await insertRunningStepAttempt(\n {\n jobExecutionId,\n stepId: pending.id,\n attempt: pending.currentAttempt,\n },\n tx,\n );\n await finishStepAttempt(\n {\n stepId: pending.id,\n attempt: pending.currentAttempt,\n status: 'failed',\n error: failureError,\n logOutcome: 'abandoned',\n },\n tx,\n );\n const status = await settleJobFailed(tx, {\n jobId: jobExecution.jobId,\n jobExecutionId,\n failedStepId: pending.id,\n error: failureError,\n });\n if (status) recordWorkflowJobExecutionStepsSettled(status);\n return status === null\n ? nextStepForJobExecutionInTransaction(jobExecutionId, tx, agent)\n : {kind: 'done', status};\n }\n}\n\nfunction evaluateStepCondition(params: {\n readonly step: Step;\n readonly context: WorkflowEvaluationContext;\n}): StepConditionOutcome {\n const condition = params.step.condition;\n if (condition === null) {\n const execution = params.context.values.execution as {failed?: unknown} | undefined;\n return execution?.failed === true\n ? {\n kind: 'skip',\n statusReason: 'default_gate_rejected',\n evaluationTrace: defaultStepConditionTrace(),\n }\n : {kind: 'run'};\n }\n\n const outcome = evaluatePlannedPredicateAtSite({\n expression: condition,\n field: 'step.if',\n site: params.context.site,\n context: params.context.values,\n });\n const evaluationTrace = explicitConditionTrace({\n expression: condition,\n field: 'step.if',\n route: outcome.route,\n site: params.context.site,\n value: outcome.value,\n degraded: outcome.evaluationFailed,\n });\n if (outcome.evaluationFailed) {\n return {kind: 'skip', statusReason: 'condition_errored', evaluationTrace};\n }\n return outcome.value\n ? {kind: 'run'}\n : {kind: 'skip', statusReason: 'condition_rejected', evaluationTrace};\n}\n\nfunction toDispatchConfigError(error: unknown): DispatchConfigError | null {\n const isInterpolationError = error instanceof InterpolationUnresolvableError;\n if (isInterpolationError) return error;\n\n const isAgentConfigError = error instanceof AgentConfigUnresolvableError;\n if (isAgentConfigError) return error;\n\n return null;\n}\n\nfunction dispatchConfigError(error: DispatchConfigError): Record<string, unknown> {\n if (error instanceof InterpolationUnresolvableError) {\n return {\n message: error.message,\n reason: 'config_unresolvable',\n field: error.envKey === undefined ? error.field : `${error.field}.${error.envKey}`,\n source: error.source,\n };\n }\n\n return {\n message: error.message,\n reason: 'config_unresolvable',\n field: 'agent',\n source: 'agent',\n };\n}\n\nexport interface NextStepForLeasedJobExecutionParams {\n jobExecutionId: string;\n agent?: AgentInterModuleClient | undefined;\n}\n\nexport function nextStepForLeasedJobExecution(\n params: NextStepForLeasedJobExecutionParams,\n): Promise<NextStep> {\n return withTransaction((tx) =>\n nextStepForJobExecutionInTransaction(params.jobExecutionId, tx, params.agent),\n );\n}\n\nexport function nextStepForJob(\n jobId: string,\n agent?: AgentInterModuleClient | undefined,\n): Promise<NextStep> {\n return withTransaction(async (tx) => {\n const jobExecution = await getLatestJobExecutionByJobId(jobId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobId);\n\n return nextStepForJobExecutionInTransaction(jobExecution.id, tx, agent);\n });\n}\n\nexport interface RecordStepResultParams {\n jobExecutionId: string;\n stepId: string;\n status: 'succeeded' | 'failed';\n error?: Record<string, unknown> | null;\n // Structured runner output feeds gate predicates and audit/history on the\n // attempt row; the current step projection keeps only status/error.\n output?: Record<string, unknown> | null;\n response?: string | null;\n exitCode?: number | null;\n // The attempt the runner was dispatched. Omitted = \"the step's current\n // attempt\" (back-compat for callers that don't track attempts yet).\n attempt?: number;\n logOutcome?: LogOutcomeDto;\n}\n\nexport type RecordStepResultOutcome = StepProgressionOutcome;\n\ninterface RecordStepResultTransactionResult {\n outcome: RecordStepResultOutcome;\n metrics: StepProgressionMetrics;\n}\n\nfunction outcomeFromSteps(steps: Step[]): RecordStepResultOutcome {\n return steps.every((step) => isTerminal(step.status))\n ? {jobFinished: true, status: deriveCompletion(steps)}\n : {jobFinished: false};\n}\n\nexport async function recordStepResult(\n params: RecordStepResultParams,\n): Promise<RecordStepResultOutcome> {\n const progression = await withTransaction<RecordStepResultTransactionResult>((tx) =>\n recordStepResultInTransaction(params, tx),\n );\n\n recordStepProgressionMetrics(progression.metrics);\n\n return progression.outcome;\n}\n\nasync function recordStepResultInTransaction(\n params: RecordStepResultParams,\n tx: Tx,\n): Promise<RecordStepResultTransactionResult> {\n const jobExecutionId = params.jobExecutionId;\n\n const jobExecution = await getJobExecutionById(jobExecutionId, tx);\n if (!jobExecution) throw new JobNotFoundError(jobExecutionId);\n\n const steps = await getStepsByJobExecutionIdForUpdate(jobExecutionId, tx);\n const target = steps.find((step) => step.id === params.stepId);\n const hasTargetStep = target !== undefined;\n\n if (!hasTargetStep) throw new StepNotFoundError(params.stepId, jobExecutionId);\n\n const current = target.currentAttempt;\n const reported = params.attempt ?? current;\n const reportClassification = classifyReportedStep(target, reported, jobExecution.jobId);\n if (reportClassification instanceof Error) throw reportClassification;\n if (reportClassification === 'noop') return {outcome: outcomeFromSteps(steps), metrics: {}};\n\n // Migration/back-compat boundary: a running step may predate the\n // step_attempts table or have been marked running by legacy code. Create\n // the audit row just before finalization if dispatch did not already do it.\n await insertRunningStepAttempt(\n {\n jobExecutionId,\n stepId: params.stepId,\n attempt: current,\n config: target.config,\n },\n tx,\n );\n\n let result: ReportedStepResult = {\n status: params.status,\n error: params.error ?? null,\n output: params.output ?? null,\n response: params.response ?? null,\n exitCode: params.exitCode ?? null,\n };\n const outputCoercion = coerceReportedStepOutput(target.config, result);\n if (outputCoercion.kind === 'coerced') {\n result = {...result, output: outputCoercion.output};\n }\n if (outputCoercion.kind === 'failed') {\n result = {\n status: 'failed',\n error: outputInvalidError(outputCoercion.error),\n output: null,\n response: result.response,\n exitCode: result.exitCode,\n };\n }\n\n // Evaluate the gate (if any) at the service boundary — the only place the CEL\n // engine runs — and pass the precomputed outcome into the pure decision.\n const shouldEvaluateGate = outputCoercion.kind !== 'failed';\n const gate = shouldEvaluateGate ? readStepGate(target.config) : undefined;\n const gateOutcome = shouldEvaluateGate ? evaluateGate(gate, result) : {kind: 'no-gate' as const};\n const hasRestartPolicy = gate?.onFailure?.restartFrom !== undefined;\n // The restart cap is bounded on the gating step's OWN attempts, not its\n // current_attempt (which a rewind inflates for downstream steps).\n const gatingAttemptCount = hasRestartPolicy\n ? await countStepAttempts(params.stepId, tx)\n : undefined;\n const decision = decideStepTransition({\n steps,\n target,\n reportedAttempt: reported,\n result,\n gateOutcome,\n ...(gate?.onFailure ? {gateOnFailure: gate.onFailure} : {}),\n ...(gatingAttemptCount !== undefined ? {gatingAttemptCount} : {}),\n });\n const resolvedDecision = resolveRestartFeedback({\n decision,\n gate,\n result,\n definitionId: jobExecution.jobId,\n });\n\n return applyStepTransition(\n resolvedDecision,\n {\n jobId: jobExecution.jobId,\n jobExecutionId,\n result,\n logOutcome: params.logOutcome ?? 'drained',\n gateResult: gateResultPayload(gateOutcome, result.exitCode),\n },\n tx,\n );\n}\n\ntype OutputCoercionResult =\n | {kind: 'not-applicable'}\n | {kind: 'coerced'; output: Record<string, unknown>}\n | {kind: 'failed'; error: StepOutputCoercionError};\n\nexport type ReportedStepClassification = 'proceed' | 'noop' | Error;\n\nexport function classifyReportedStep(\n target: Step,\n reportedAttempt: number,\n jobId: string,\n): ReportedStepClassification {\n const currentAttempt = target.currentAttempt;\n if (reportedAttempt > currentAttempt) {\n return new StepAttemptAheadError(target.id, jobId, reportedAttempt, currentAttempt);\n }\n\n if (reportedAttempt < currentAttempt) return 'noop';\n if (isTerminal(target.status)) return 'noop';\n if (target.status === 'pending') return new StepNotRunningError(target.id, jobId);\n return 'proceed';\n}\n\nfunction coerceReportedStepOutput(\n config: Record<string, unknown>,\n result: ReportedStepResult,\n): OutputCoercionResult {\n if (result.status !== 'succeeded') return {kind: 'not-applicable'};\n\n const declarations = readStepOutputs(config);\n if (declarations === undefined) return {kind: 'not-applicable'};\n\n const coerced = coerceStepOutputs({declarations, output: result.output});\n if (!coerced.ok) return {kind: 'failed', error: coerced.error};\n return {kind: 'coerced', output: coerced.output};\n}\n\nfunction outputInvalidError(error: StepOutputCoercionError): Record<string, unknown> {\n return {\n message: error.message,\n reason: 'output_invalid',\n field: `outputs.${error.key}`,\n outputKey: error.key,\n issue: error.reason,\n ...(error.expectedType === undefined ? {} : {expectedType: error.expectedType}),\n ...(error.schemaError === undefined ? {} : {schemaError: error.schemaError}),\n };\n}\n\nfunction resolveRestartFeedback(params: {\n decision: StepTransitionDecision;\n gate: ReturnType<typeof readStepGate>;\n result: ReportedStepResult;\n definitionId: string;\n}): StepTransitionDecision {\n if (params.decision.kind !== 'restart-job-from-step') return params.decision;\n if (params.gate === undefined) return params.decision;\n\n try {\n return {\n ...params.decision,\n feedback: evaluateGateFeedback({\n gate: params.gate,\n result: params.result,\n definitionId: params.definitionId,\n }),\n };\n } catch (error) {\n if (error instanceof InterpolationUnresolvableError) {\n return {\n kind: 'fail-job',\n failedStepId: params.decision.failedStepId,\n attempt: params.decision.attempt,\n failureError: dispatchConfigError(error),\n };\n }\n throw error;\n }\n}\n\nfunction recordStepProgressionMetrics(metrics: StepProgressionMetrics): void {\n const settledStatus = metrics.jobStepsSettledStatus;\n const hasSettledStatus = settledStatus !== undefined;\n if (hasSettledStatus) recordWorkflowJobExecutionStepsSettled(settledStatus);\n\n const restartWasEnqueued = metrics.stepRestartEnqueued === true;\n if (restartWasEnqueued) recordWorkflowStepRestartEnqueued();\n}\n"],"names":["coerceStepOutputs","evaluatePlannedPredicateAtSite","withTransaction","countStepAttempts","dispatchStepWithCompletedConfig","finishStepAttempt","getDirectDependencyJobContexts","getJobExecutionById","getLatestJobExecutionByJobId","getStepAttemptsByJobExecutionId","getStepsByJobExecutionIdForUpdate","insertRunningStepAttempt","markStepRunning","markStepSkipped","settleJobFailed","writeJobStepsSettledOutbox","recordWorkflowJobExecutionStepsSettled","recordWorkflowStepRestartEnqueued","createAgentDefaultsResolver","defaultStepConditionTrace","explicitConditionTrace","AgentConfigUnresolvableError","InterpolationUnresolvableError","JobNotFoundError","StepAttemptAheadError","StepNotFoundError","StepNotRunningError","assembleStepDispatchContext","completeStepDispatchConfig","applyStepTransition","decideStepTransition","deriveCompletion","isTerminal","evaluateGate","evaluateGateFeedback","gateResultPayload","readStepGate","readStepOutputs","nextStepForJobExecutionInTransaction","jobExecutionId","tx","agent","steps","hasNoSteps","length","running","find","step","status","hasRunningStep","undefined","kind","dispatched","firstPending","hasPendingStep","jobExecution","attempts","jobs","jobId","resolveNextPendingStep","skippedAny","currentSteps","pending","context","targetStepId","id","condition","evaluateStepCondition","dispatchPendingStep","skipped","stepId","statusReason","evaluationTrace","skippedStep","error","map","params","hasConfigPlan","configPlan","dispatchPendingStepWithConfigPlan","marked","completed","resolveAgentDefaults","definitionId","config","trace","configError","toDispatchConfigError","isConfigError","failureError","dispatchConfigError","attempt","currentAttempt","logOutcome","failedStepId","execution","values","failed","outcome","expression","field","site","route","value","degraded","evaluationFailed","isInterpolationError","isAgentConfigError","message","reason","envKey","source","nextStepForLeasedJobExecution","nextStepForJob","outcomeFromSteps","every","jobFinished","recordStepResult","progression","recordStepResultInTransaction","recordStepProgressionMetrics","metrics","target","hasTargetStep","current","reported","reportClassification","classifyReportedStep","Error","result","output","response","exitCode","outputCoercion","coerceReportedStepOutput","outputInvalidError","shouldEvaluateGate","gate","gateOutcome","hasRestartPolicy","onFailure","restartFrom","gatingAttemptCount","decision","reportedAttempt","gateOnFailure","resolvedDecision","resolveRestartFeedback","gateResult","declarations","coerced","ok","key","outputKey","issue","expectedType","schemaError","feedback","settledStatus","jobStepsSettledStatus","hasSettledStatus","restartWasEnqueued","stepRestartEnqueued"],"mappings":"AAEA,SACEA,iBAAiB,EACjBC,8BAA8B,QAEzB,sBAAsB;AAC7B,SAAiBC,eAAe,QAAO,YAAY;AACnD,SACEC,iBAAiB,EACjBC,+BAA+B,EAC/BC,iBAAiB,EACjBC,8BAA8B,EAC9BC,mBAAmB,EACnBC,4BAA4B,EAC5BC,+BAA+B,EAC/BC,iCAAiC,EACjCC,wBAAwB,EACxBC,eAAe,EACfC,eAAe,EACfC,eAAe,EACfC,0BAA0B,QACrB,uBAAuB;AAC9B,SACEC,sCAAsC,EACtCC,iCAAiC,QAC5B,uBAAuB;AAC9B,SAAQC,2BAA2B,QAAO,sBAAsB;AAChE,SAAQC,yBAAyB,EAAEC,sBAAsB,QAAO,uBAAuB;AAGvF,SACEC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,gBAAgB,EAChBC,qBAAqB,EACrBC,iBAAiB,EACj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6D,IAAI;gBACjBR,QAAQrD,OAAOqD,MAAM;gBACrB9C,cAAcP,OAAOO,YAAY;YACnC;QACF;IACF,EAAE,OAAOT,OAAO;QACd,IAAIA,iBAAiBpD,gCAAgC;YACnD,OAAO;gBACL6B,MAAM;gBACN2C,cAAclB,OAAOmE,QAAQ,CAACjD,YAAY;gBAC1CH,SAASf,OAAOmE,QAAQ,CAACpD,OAAO;gBAChCF,cAAcC,oBAAoBhB;YACpC;QACF;QACA,MAAMA;IACR;AACF;AAEA,SAAS8C,6BAA6BC,OAA+B;IACnE,MAAMqC,gBAAgBrC,QAAQsC,qBAAqB;IACnD,MAAMC,mBAAmBF,kBAAkB5G;IAC3C,IAAI8G,kBAAkBhJ,uCAAuC8I;IAE7D,MAAMG,qBAAqBxC,QAAQyC,mBAAmB,KAAK;IAC3D,IAAID,oBAAoBhJ;AAC1B"}
@@ -3,11 +3,6 @@ import type { JobStatusReason } from '#core/entities/job.js';
3
3
  import type { JobExecution, JobExecutionStatus } from '#core/entities/job-execution.js';
4
4
  import type { RuntimeCompletionStatus } from '#core/workflow-scheduling/runtime-dag.js';
5
5
  import { type Tx } from '../db.js';
6
- export declare function lockActiveJobExecutionLeaseForUpdate(params: {
7
- jobId: string;
8
- jobExecutionId: string;
9
- runnerSessionId: string;
10
- }, tx: Tx): Promise<boolean>;
11
6
  export declare function getJobExecutionById(id: string, tx?: Tx): Promise<JobExecution | undefined>;
12
7
  export declare function getJobExecutionsByWorkflowRunAttemptId(workflowRunAttemptId: string): Promise<JobExecution[]>;
13
8
  export declare function getJobExecutionsByJobId(jobId: string): Promise<JobExecution[]>;