@shipfox/api-workflows 16.0.0 → 16.1.0
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.
- package/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +20 -0
- package/dist/core/agent-tools.js +8 -3
- package/dist/core/agent-tools.js.map +1 -1
- package/dist/core/entities/step.d.ts +1 -1
- package/dist/core/entities/step.d.ts.map +1 -1
- package/dist/core/entities/step.js +2 -1
- package/dist/core/entities/step.js.map +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js.map +1 -1
- package/dist/core/step-config/materialize-job-execution-steps.js +2 -0
- package/dist/core/step-config/materialize-job-execution-steps.js.map +1 -1
- package/dist/core/step-config/resolve-step-config.js +3 -1
- package/dist/core/step-config/resolve-step-config.js.map +1 -1
- package/dist/db/db.d.ts +8 -8
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema/steps.d.ts +2 -2
- package/dist/db/schema/workflow-run-attempts.d.ts +2 -2
- package/dist/db/workflow-runs/outbox.d.ts +1 -0
- package/dist/db/workflow-runs/outbox.d.ts.map +1 -1
- package/dist/db/workflow-runs/outbox.js +2 -1
- package/dist/db/workflow-runs/outbox.js.map +1 -1
- package/dist/db/workflow-runs/run-create.d.ts.map +1 -1
- package/dist/db/workflow-runs/run-create.js +49 -1
- package/dist/db/workflow-runs/run-create.js.map +1 -1
- package/dist/db/workflow-runs/steps.d.ts +6 -0
- package/dist/db/workflow-runs/steps.d.ts.map +1 -1
- package/dist/db/workflow-runs/steps.js +14 -0
- package/dist/db/workflow-runs/steps.js.map +1 -1
- package/dist/db/workflow-runs.d.ts +1 -1
- package/dist/db/workflow-runs.d.ts.map +1 -1
- package/dist/db/workflow-runs.js +1 -1
- package/dist/db/workflow-runs.js.map +1 -1
- package/dist/presentation/inter-module.d.ts.map +1 -1
- package/dist/presentation/inter-module.js +6 -1
- package/dist/presentation/inter-module.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/core/agent-tools.test.ts +85 -0
- package/src/core/agent-tools.ts +11 -3
- package/src/core/entities/step.ts +1 -1
- package/src/core/errors.ts +2 -0
- package/src/core/job-execution.test.ts +1 -0
- package/src/core/run-workflow.test.ts +4 -0
- package/src/core/step-config/materialize-job-execution-steps.ts +2 -0
- package/src/core/step-config/resolve-step-config.ts +4 -1
- package/src/db/index.ts +1 -0
- package/src/db/workflow-runs/outbox.ts +2 -0
- package/src/db/workflow-runs/run-create.test.ts +41 -0
- package/src/db/workflow-runs/run-create.ts +81 -3
- package/src/db/workflow-runs/steps.ts +19 -0
- package/src/db/workflow-runs.ts +1 -0
- package/src/presentation/inter-module.test.ts +26 -0
- package/src/presentation/inter-module.ts +9 -1
- package/src/presentation/routes/agent-runtime-config.test.ts +2 -0
- package/test/factories/workflow-model.ts +74 -2
- package/test/fixtures/agent-inter-module.ts +2 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
$ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
|
|
2
|
-
Successfully compiled: 123 files with swc (
|
|
3
|
-
2026-08-
|
|
2
|
+
Successfully compiled: 123 files with swc (791.27ms)
|
|
3
|
+
2026-08-25T09:56:17.502Z [INFO] asset workflow-bundle-4d88ac6c229f6c77759a.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
|
|
20
|
-
2026-08-
|
|
19
|
+
webpack 5.107.2 compiled successfully in 8503 ms
|
|
20
|
+
2026-08-25T09:56:17.537Z [INFO] Workflow bundle created { size: '3.31MB' }
|
|
21
21
|
/home/runner/work/shipfox/shipfox/libs/api/workflows/dist/temporal/workflows/index.js: 3469609 bytes
|
package/.turbo/turbo-type.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @shipfox/api-workflows
|
|
2
2
|
|
|
3
|
+
## 16.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d1fb0a3: Adds the agent session claim and carry-over inter-module methods (`claimSession`, `carryOverSessions`) with the session descriptor (`id`, `key`, `mode`, `segment`), so workflows can resume or fork a session and rerun attempts can carry sessions forward.
|
|
8
|
+
|
|
9
|
+
Session claims are released automatically on step-attempt and job termination, with a stale-claim reap cron as a backstop.
|
|
10
|
+
|
|
11
|
+
The previously required `jobLeaseTokenTtlSeconds` option on `createAgentModule` is removed; pass an optional `workflows` client to enable the job-terminated grace sweep.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 870523f: Adds the tool step model: a `kind: 'tool'` step in the `definitions-dto` step union (snapshot version 3) carrying `tool`, `connection`, `with`, `outputMappings`, and `templates`, with sync-time validation (`missing-connection-for-tool`, `integration-connection-not-found` / `-not-capable`, `unknown-integration-tool`, `tool-input-invalid`, `tool-input-unknown-key`). `@shipfox/api-workflows` and `@shipfox/api-workflows-dto` add the tool step to the run-graph step type union and its display name. The workflow document parser still rejects tool-step fields, so nothing is user-authorable yet.
|
|
16
|
+
- Updated dependencies [d1fb0a3]
|
|
17
|
+
- Updated dependencies [c1e5dfd]
|
|
18
|
+
- Updated dependencies [870523f]
|
|
19
|
+
- @shipfox/api-agent-dto@16.1.0
|
|
20
|
+
- @shipfox/api-workflows-dto@16.1.0
|
|
21
|
+
- @shipfox/api-definitions-dto@16.1.0
|
|
22
|
+
|
|
3
23
|
## 16.0.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/core/agent-tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AgentIntegrationMaterializationError } from './errors.js';
|
|
2
2
|
export async function loadAgentToolMaterializationContext(params) {
|
|
3
|
-
if (!
|
|
3
|
+
if (!hasIntegrationToolReferences(params.model, params.jobs)) return undefined;
|
|
4
4
|
if (params.projects === undefined) {
|
|
5
5
|
throw new AgentIntegrationMaterializationError('Project access is not configured');
|
|
6
6
|
}
|
|
@@ -293,9 +293,14 @@ function isPermissionScope(value) {
|
|
|
293
293
|
const candidate = value;
|
|
294
294
|
return typeof candidate.permission === 'string' && (candidate.access === 'read' || candidate.access === 'write');
|
|
295
295
|
}
|
|
296
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Model-level twin of `hasIntegrationToolReferences` in
|
|
298
|
+
* `libs/api/definitions/src/core/has-integration-tool-references.ts`, which
|
|
299
|
+
* runs the same criterion over the authored `WorkflowDocument` at sync time.
|
|
300
|
+
* Keep both in sync.
|
|
301
|
+
*/ function hasIntegrationToolReferences(model, jobs) {
|
|
297
302
|
if (model === null) return false;
|
|
298
|
-
return (jobs ?? model.jobs).some((job)=>job.steps.some((step)=>step.kind === 'agent' && step.integrations !== undefined));
|
|
303
|
+
return (jobs ?? model.jobs).some((job)=>job.steps.some((step)=>step.kind === 'tool' || step.kind === 'agent' && step.integrations !== undefined));
|
|
299
304
|
}
|
|
300
305
|
|
|
301
306
|
//# sourceMappingURL=agent-tools.js.map
|
|
@@ -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 {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,oCAAoC,QAAO,cAAc;AAgDjE,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,CAAC;QAACC,WAAWR,OAAOQ,SAAS;IAAA;IACnF,IAAIF,YAAY,MAAM;QACpB,MAAM,IAAIR,qCACR,CAAC,QAAQ,EAAEE,OAAOQ,SAAS,CAAC,qDAAqD,CAAC;IAEtF;IAEA,IAAIR,OAAOS,YAAY,KAAKL,WAAW;QACrC,MAAM,IAAIN,qCAAqC;IACjD;IACA,MAAMY,UAAU,MAAMV,OAAOS,YAAY,CAACE,oBAAoB,CAAC;QA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7C,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 (!hasIntegrationToolReferences(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\n/**\n * Model-level twin of `hasIntegrationToolReferences` in\n * `libs/api/definitions/src/core/has-integration-tool-references.ts`, which\n * runs the same criterion over the authored `WorkflowDocument` at sync time.\n * Keep both in sync.\n */\nfunction hasIntegrationToolReferences(\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(\n (step) => step.kind === 'tool' || (step.kind === 'agent' && step.integrations !== undefined),\n ),\n );\n}\n"],"names":["AgentIntegrationMaterializationError","loadAgentToolMaterializationContext","params","hasIntegrationToolReferences","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,oCAAoC,QAAO,cAAc;AAgDjE,OAAO,eAAeC,oCAAoCC,MAOzD;IACC,IAAI,CAACC,6BAA6BD,OAAOE,KAAK,EAAEF,OAAOG,IAAI,GAAG,OAAOC;IAErE,IAA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AOA;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;;;;;CAKC,GACD,SAAShG,6BACPC,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,CACZ,CAACpD,OAASA,KAAKC,IAAI,KAAK,UAAWD,KAAKC,IAAI,KAAK,WAAWD,KAAK3B,YAAY,KAAKL;AAGxF"}
|
|
@@ -3,7 +3,7 @@ import type { EvaluationTraceEntry, EvaluationTraceLimitEntry, ResolvedField, Wo
|
|
|
3
3
|
import type { Harness } from '@shipfox/workflow-document';
|
|
4
4
|
import type { InterpolationUnresolvableField } from '../errors.js';
|
|
5
5
|
export type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';
|
|
6
|
-
export declare const STEP_TYPES: readonly ['setup', 'run', 'agent', 'checkout'];
|
|
6
|
+
export declare const STEP_TYPES: readonly ['setup', 'run', 'agent', 'checkout', 'tool'];
|
|
7
7
|
export type StepType = (typeof STEP_TYPES)[number];
|
|
8
8
|
export declare const STEP_STATUS_REASONS: readonly ['default_gate_rejected', 'condition_rejected', 'condition_errored'];
|
|
9
9
|
export type StepStatusReason = (typeof STEP_STATUS_REASONS)[number];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/core/entities/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,qCAAqC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAElG,eAAO,MAAM,UAAU,YAAI,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../src/core/entities/step.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,qCAAqC,EACtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,yBAAyB,EACzB,aAAa,EACb,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,CAAC;AAElG,eAAO,MAAM,UAAU,YAAI,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAU,CAAC;AAEjF,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,eAAO,MAAM,mBAAmB,YAC9B,uBAAuB,EAC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;AAKD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvC,eAAe,EAAE,SAAS,6BAA6B,EAAE,GAAG,IAAI,CAAC;IACjE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACzC,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/entities/step.ts"],"sourcesContent":["import type {\n AgentIntegrationMcpServerConfigDto,\n MaterializedAgentIntegrationConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {\n EvaluationTraceEntry,\n EvaluationTraceLimitEntry,\n ResolvedField,\n WorkflowExpression,\n} from '@shipfox/expression';\nimport type {Harness} from '@shipfox/workflow-document';\nimport type {InterpolationUnresolvableField} from '../errors.js';\n\nexport type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';\n\nexport const STEP_TYPES = ['setup', 'run', 'agent', 'checkout'] as const;\n\nexport type StepType = (typeof STEP_TYPES)[number];\n\nexport const STEP_STATUS_REASONS = [\n 'default_gate_rejected',\n 'condition_rejected',\n 'condition_errored',\n] as const;\n\nexport type StepStatusReason = (typeof STEP_STATUS_REASONS)[number];\n\nconst STEP_STATUS_REASON_SET = new Set<StepStatusReason>(STEP_STATUS_REASONS);\n\nexport function toStepStatusReason(value: string | null): StepStatusReason | null {\n if (value === null) return null;\n return STEP_STATUS_REASON_SET.has(value as StepStatusReason) ? (value as StepStatusReason) : null;\n}\n\nexport type StepAttemptLogOutcome = 'drained' | 'abandoned';\n\n// A step_attempts row exists only once an attempt is dispatched, so it is never\n// 'pending' or 'skipped'.\nexport type StepAttemptStatus = Exclude<StepStatus, 'pending' | 'skipped'>;\n\nexport interface StepSourceLocation {\n startLine: number;\n endLine: number;\n}\n\n/**\n * Trace entry after a resolver-local expression trace is attached to workflow\n * storage.\n *\n * Step config traces are stored on step attempts with the resolved attempt\n * config; job-level traces are stored on the job or job-execution row whose\n * value/status they explain. Keep `field` as the authored field path that\n * produced the trace, not as a step-only enum.\n */\nexport type PersistedEvaluationTraceEntry =\n | (EvaluationTraceEntry & {\n readonly field: string;\n readonly envKey?: string;\n })\n | EvaluationTraceLimitEntry;\n\nexport interface StepConfigEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport interface StepConfigDispatchPlan {\n working_directory?: ResolvedField;\n run?: ResolvedField;\n env?: Readonly<Record<string, ResolvedField>>;\n checkout?: {\n project?: ResolvedField;\n connection?: ResolvedField;\n repository?: ResolvedField;\n ref?: ResolvedField;\n path?: ResolvedField;\n };\n agent?: {\n prompt?: ResolvedField;\n model?: ResolvedField;\n provider?: ResolvedField;\n harness?: Harness;\n thinking?: ResolvedField;\n tools?: readonly string[];\n integrations?: readonly MaterializedAgentIntegrationConfigDto[];\n mcpServers?: readonly AgentIntegrationMcpServerConfigDto[];\n };\n trace?: readonly (StepConfigEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface Step {\n id: string;\n jobExecutionId: string;\n key: string | null;\n name: string;\n sourceLocation: StepSourceLocation | null;\n status: StepStatus;\n statusReason: StepStatusReason | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n type: StepType;\n config: Record<string, unknown>;\n condition: WorkflowExpression | null;\n configPlan: StepConfigDispatchPlan | null;\n authoredConfig: Record<string, unknown> | null;\n error: Record<string, unknown> | null;\n position: number;\n version: number;\n // Execution-attempt identity for the current projection: which attempt the\n // status/output/error above reflect. Distinct from `version` (the optimistic\n // row counter). Starts at 1 and is bumped when a step is rewound.\n currentAttempt: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// Append-only execution history: one row per dispatched attempt of a step. The\n// current projection lives on `Step`; this is the audit trail and the\n// idempotency anchor (unique on (stepId, attempt)).\nexport interface StepAttempt {\n id: string;\n stepId: string;\n attempt: number;\n executionOrder: number;\n status: StepAttemptStatus;\n config: Record<string, unknown> | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n output: Record<string, unknown> | null;\n response: string | null;\n error: Record<string, unknown> | null;\n exitCode: number | null;\n gateResult: Record<string, unknown> | null;\n restartFeedback: string | null;\n logOutcome: StepAttemptLogOutcome | null;\n startedAt: Date;\n finishedAt: Date | null;\n createdAt: Date;\n}\n"],"names":["STEP_TYPES","STEP_STATUS_REASONS","STEP_STATUS_REASON_SET","Set","toStepStatusReason","value","has"],"mappings":"AAeA,OAAO,MAAMA,aAAa;IAAC;IAAS;IAAO;IAAS;
|
|
1
|
+
{"version":3,"sources":["../../../src/core/entities/step.ts"],"sourcesContent":["import type {\n AgentIntegrationMcpServerConfigDto,\n MaterializedAgentIntegrationConfigDto,\n} from '@shipfox/api-agent-dto';\nimport type {\n EvaluationTraceEntry,\n EvaluationTraceLimitEntry,\n ResolvedField,\n WorkflowExpression,\n} from '@shipfox/expression';\nimport type {Harness} from '@shipfox/workflow-document';\nimport type {InterpolationUnresolvableField} from '../errors.js';\n\nexport type StepStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'cancelled' | 'skipped';\n\nexport const STEP_TYPES = ['setup', 'run', 'agent', 'checkout', 'tool'] as const;\n\nexport type StepType = (typeof STEP_TYPES)[number];\n\nexport const STEP_STATUS_REASONS = [\n 'default_gate_rejected',\n 'condition_rejected',\n 'condition_errored',\n] as const;\n\nexport type StepStatusReason = (typeof STEP_STATUS_REASONS)[number];\n\nconst STEP_STATUS_REASON_SET = new Set<StepStatusReason>(STEP_STATUS_REASONS);\n\nexport function toStepStatusReason(value: string | null): StepStatusReason | null {\n if (value === null) return null;\n return STEP_STATUS_REASON_SET.has(value as StepStatusReason) ? (value as StepStatusReason) : null;\n}\n\nexport type StepAttemptLogOutcome = 'drained' | 'abandoned';\n\n// A step_attempts row exists only once an attempt is dispatched, so it is never\n// 'pending' or 'skipped'.\nexport type StepAttemptStatus = Exclude<StepStatus, 'pending' | 'skipped'>;\n\nexport interface StepSourceLocation {\n startLine: number;\n endLine: number;\n}\n\n/**\n * Trace entry after a resolver-local expression trace is attached to workflow\n * storage.\n *\n * Step config traces are stored on step attempts with the resolved attempt\n * config; job-level traces are stored on the job or job-execution row whose\n * value/status they explain. Keep `field` as the authored field path that\n * produced the trace, not as a step-only enum.\n */\nexport type PersistedEvaluationTraceEntry =\n | (EvaluationTraceEntry & {\n readonly field: string;\n readonly envKey?: string;\n })\n | EvaluationTraceLimitEntry;\n\nexport interface StepConfigEvaluationTraceEntry extends EvaluationTraceEntry {\n readonly field: InterpolationUnresolvableField;\n readonly envKey?: string;\n}\n\nexport interface StepConfigDispatchPlan {\n working_directory?: ResolvedField;\n run?: ResolvedField;\n env?: Readonly<Record<string, ResolvedField>>;\n checkout?: {\n project?: ResolvedField;\n connection?: ResolvedField;\n repository?: ResolvedField;\n ref?: ResolvedField;\n path?: ResolvedField;\n };\n agent?: {\n prompt?: ResolvedField;\n model?: ResolvedField;\n provider?: ResolvedField;\n harness?: Harness;\n thinking?: ResolvedField;\n tools?: readonly string[];\n integrations?: readonly MaterializedAgentIntegrationConfigDto[];\n mcpServers?: readonly AgentIntegrationMcpServerConfigDto[];\n };\n trace?: readonly (StepConfigEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface Step {\n id: string;\n jobExecutionId: string;\n key: string | null;\n name: string;\n sourceLocation: StepSourceLocation | null;\n status: StepStatus;\n statusReason: StepStatusReason | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n type: StepType;\n config: Record<string, unknown>;\n condition: WorkflowExpression | null;\n configPlan: StepConfigDispatchPlan | null;\n authoredConfig: Record<string, unknown> | null;\n error: Record<string, unknown> | null;\n position: number;\n version: number;\n // Execution-attempt identity for the current projection: which attempt the\n // status/output/error above reflect. Distinct from `version` (the optimistic\n // row counter). Starts at 1 and is bumped when a step is rewound.\n currentAttempt: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\n// Append-only execution history: one row per dispatched attempt of a step. The\n// current projection lives on `Step`; this is the audit trail and the\n// idempotency anchor (unique on (stepId, attempt)).\nexport interface StepAttempt {\n id: string;\n stepId: string;\n attempt: number;\n executionOrder: number;\n status: StepAttemptStatus;\n config: Record<string, unknown> | null;\n evaluationTrace: readonly PersistedEvaluationTraceEntry[] | null;\n output: Record<string, unknown> | null;\n response: string | null;\n error: Record<string, unknown> | null;\n exitCode: number | null;\n gateResult: Record<string, unknown> | null;\n restartFeedback: string | null;\n logOutcome: StepAttemptLogOutcome | null;\n startedAt: Date;\n finishedAt: Date | null;\n createdAt: Date;\n}\n"],"names":["STEP_TYPES","STEP_STATUS_REASONS","STEP_STATUS_REASON_SET","Set","toStepStatusReason","value","has"],"mappings":"AAeA,OAAO,MAAMA,aAAa;IAAC;IAAS;IAAO;IAAS;IAAY;CAAO,CAAU;AAIjF,OAAO,MAAMC,sBAAsB;IACjC;IACA;IACA;CACD,CAAU;AAIX,MAAMC,yBAAyB,IAAIC,IAAsBF;AAEzD,OAAO,SAASG,mBAAmBC,KAAoB;IACrD,IAAIA,UAAU,MAAM,OAAO;IAC3B,OAAOH,uBAAuBI,GAAG,CAACD,SAA8BA,QAA6B;AAC/F"}
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare class AgentConfigUnresolvableError extends Error {
|
|
|
33
33
|
export declare class AgentIntegrationMaterializationError extends Error {
|
|
34
34
|
constructor(message: string);
|
|
35
35
|
}
|
|
36
|
-
export type InterpolationUnresolvableField = 'run' | 'env' | 'agent.prompt' | 'agent.model' | 'agent.provider' | 'agent.thinking' | 'job.runner' | 'job.outputs' | 'job.execution_name' | 'workflow.run_name' | 'step.name' | 'step.working_directory' | 'step.feedback' | 'checkout.project' | 'checkout.connection' | 'checkout.repository' | 'checkout.ref' | 'checkout.path';
|
|
36
|
+
export type InterpolationUnresolvableField = 'run' | 'env' | 'agent.prompt' | 'agent.model' | 'agent.provider' | 'agent.thinking' | 'job.runner' | 'job.outputs' | 'job.execution_name' | 'workflow.run_name' | 'step.name' | 'step.working_directory' | 'step.feedback' | 'tool.with' | 'tool.outputs' | 'checkout.project' | 'checkout.connection' | 'checkout.repository' | 'checkout.ref' | 'checkout.path';
|
|
37
37
|
export declare class InterpolationUnresolvableError extends Error {
|
|
38
38
|
readonly definitionId: string;
|
|
39
39
|
readonly field: InterpolationUnresolvableField;
|
|
@@ -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,MAAM,4BAA4B,CAAC;AAElE,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,YAAY,YAAY,EAAE,MAAM,EAG/B;CACF;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,mBAAmB,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAKhE;CACF;AAED,qBAAa,uBAA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AM;IAChC,QAAQ,CAAC,cAAc,EAAE,MAAM;IAJjC,YACW,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,EAMhC;CACF"}
|
package/dist/core/errors.js.map
CHANGED
|
@@ -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 WorkspaceSuspendedError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace is suspended: ${workspaceId}`);\n this.name = 'WorkspaceSuspendedError';\n }\n}\n\nexport class WorkspaceDeletedError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace is deleted: ${workspaceId}`);\n this.name = 'WorkspaceDeletedError';\n }\n}\n\nexport class WorkspaceNotFoundError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace not found: ${workspaceId}`);\n this.name = 'WorkspaceNotFoundError';\n }\n}\n\nexport interface AgentConfigUnresolvableErrorOptions {\n readonly cause?: unknown;\n readonly message?: string;\n readonly code?: string;\n readonly managedProviderId?: string;\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n readonly code?: string | undefined;\n readonly managedProviderId?: string | undefined;\n\n constructor(\n readonly definitionId: string,\n options?: AgentConfigUnresolvableErrorOptions | undefined,\n ) {\n super(\n options?.message ?? `Agent configuration cannot be resolved for definition ${definitionId}`,\n options?.cause === undefined ? undefined : {cause: options.cause},\n );\n this.name = 'AgentConfigUnresolvableError';\n this.code = options?.code;\n this.managedProviderId = options?.managedProviderId;\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 | 'agent.thinking'\n | 'job.runner'\n | 'job.outputs'\n | 'job.execution_name'\n | 'workflow.run_name'\n | 'step.name'\n | 'step.working_directory'\n | 'step.feedback'\n | 'checkout.project'\n | 'checkout.connection'\n | 'checkout.repository'\n | 'checkout.ref'\n | 'checkout.path';\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(\n readonly labels: readonly string[],\n readonly requestedLabels: readonly string[] = labels,\n ) {\n const requestedSuffix =\n requestedLabels.join(', ') === labels.join(', ')\n ? ''\n : ` (requested: ${requestedLabels.join(', ')})`;\n super(`Job runner labels are invalid: ${labels.join(', ')}${requestedSuffix}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\nexport class JobOutputTooLargeError extends Error {\n readonly overshootBytes: number;\n\n constructor(\n readonly outputKey: string,\n readonly limitBytes: number,\n readonly measuredBytes: number,\n readonly scope: 'value' | 'total',\n ) {\n const overshootBytes = measuredBytes - limitBytes;\n super(\n scope === 'total'\n ? `Job outputs exceed the total size limit of ${limitBytes} bytes at \"${outputKey}\" ` +\n `(measured ${measuredBytes} bytes; overshoot ${overshootBytes} bytes).`\n : `Job output \"${outputKey}\" exceeds the per-value size limit of ${limitBytes} bytes ` +\n `(measured ${measuredBytes} bytes; overshoot ${overshootBytes} bytes).`,\n );\n this.name = 'JobOutputTooLargeError';\n this.overshootBytes = overshootBytes;\n }\n}\n\nexport class JobOutputTooManyEntriesError extends Error {\n constructor(\n readonly entryCount: number,\n readonly limitEntries: number,\n ) {\n super(`Job outputs cannot define more than ${limitEntries} entries (found ${entryCount})`);\n this.name = 'JobOutputTooManyEntriesError';\n }\n}\n\nexport class JobOutputNotJsonSafeError extends Error {\n constructor(\n readonly outputKey: string,\n readonly reason: string,\n ) {\n super(`Job output \"${outputKey}\" cannot be persisted as JSON: ${reason}`);\n this.name = 'JobOutputNotJsonSafeError';\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 checkout target cannot be resolved, so there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(target: {kind: 'project' | 'connection'; value: string}) {\n super(`Checkout intent unresolved: ${target.kind} ${target.value} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class CheckoutConfigInvalidError extends Error {\n constructor(readonly stepId: string) {\n super(`Checkout config is invalid for step ${stepId}`);\n this.name = 'CheckoutConfigInvalidError';\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","WorkspaceSuspendedError","workspaceId","WorkspaceDeletedError","WorkspaceNotFoundError","AgentConfigUnresolvableError","options","message","cause","undefined","code","managedProviderId","AgentIntegrationMaterializationError","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","field","source","envKey","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","labels","requestedLabels","requestedSuffix","join","JobOutputTooLargeError","outputKey","limitBytes","measuredBytes","scope","overshootBytes","JobOutputTooManyEntriesError","entryCount","limitEntries","JobOutputNotJsonSafeError","reason","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","target","kind","value","CheckoutConfigInvalidError","stepId","StepNotFoundError","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,gCAAgCN;IAC3C,Y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ACd;AACF;AAEA,OAAO,MAAM0D,4BAA4B5D;IACvC,YAAY0D,MAAc,EAAE7B,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAE6B,OAAO,QAAQ,EAAE7B,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAAC3B,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,iEAAiE;AACjE,OAAO,MAAM2D,8BAA8B7D;IACzC,YACE,AAAS0D,MAAc,EACvB,AAAS7B,KAAa,EACtB,AAASiC,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEL,OAAO,QAAQ,EAAE7B,MAAM,kBAAkB,EAAEiC,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGL,SAAAA,aACA7B,QAAAA,YACAiC,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAAC7D,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 WorkspaceSuspendedError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace is suspended: ${workspaceId}`);\n this.name = 'WorkspaceSuspendedError';\n }\n}\n\nexport class WorkspaceDeletedError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace is deleted: ${workspaceId}`);\n this.name = 'WorkspaceDeletedError';\n }\n}\n\nexport class WorkspaceNotFoundError extends Error {\n constructor(readonly workspaceId: string) {\n super(`Workspace not found: ${workspaceId}`);\n this.name = 'WorkspaceNotFoundError';\n }\n}\n\nexport interface AgentConfigUnresolvableErrorOptions {\n readonly cause?: unknown;\n readonly message?: string;\n readonly code?: string;\n readonly managedProviderId?: string;\n}\n\nexport class AgentConfigUnresolvableError extends Error {\n readonly code?: string | undefined;\n readonly managedProviderId?: string | undefined;\n\n constructor(\n readonly definitionId: string,\n options?: AgentConfigUnresolvableErrorOptions | undefined,\n ) {\n super(\n options?.message ?? `Agent configuration cannot be resolved for definition ${definitionId}`,\n options?.cause === undefined ? undefined : {cause: options.cause},\n );\n this.name = 'AgentConfigUnresolvableError';\n this.code = options?.code;\n this.managedProviderId = options?.managedProviderId;\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 | 'agent.thinking'\n | 'job.runner'\n | 'job.outputs'\n | 'job.execution_name'\n | 'workflow.run_name'\n | 'step.name'\n | 'step.working_directory'\n | 'step.feedback'\n | 'tool.with'\n | 'tool.outputs'\n | 'checkout.project'\n | 'checkout.connection'\n | 'checkout.repository'\n | 'checkout.ref'\n | 'checkout.path';\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(\n readonly labels: readonly string[],\n readonly requestedLabels: readonly string[] = labels,\n ) {\n const requestedSuffix =\n requestedLabels.join(', ') === labels.join(', ')\n ? ''\n : ` (requested: ${requestedLabels.join(', ')})`;\n super(`Job runner labels are invalid: ${labels.join(', ')}${requestedSuffix}`);\n this.name = 'InvalidJobRunnerLabelsError';\n }\n}\n\nexport class JobOutputTooLargeError extends Error {\n readonly overshootBytes: number;\n\n constructor(\n readonly outputKey: string,\n readonly limitBytes: number,\n readonly measuredBytes: number,\n readonly scope: 'value' | 'total',\n ) {\n const overshootBytes = measuredBytes - limitBytes;\n super(\n scope === 'total'\n ? `Job outputs exceed the total size limit of ${limitBytes} bytes at \"${outputKey}\" ` +\n `(measured ${measuredBytes} bytes; overshoot ${overshootBytes} bytes).`\n : `Job output \"${outputKey}\" exceeds the per-value size limit of ${limitBytes} bytes ` +\n `(measured ${measuredBytes} bytes; overshoot ${overshootBytes} bytes).`,\n );\n this.name = 'JobOutputTooLargeError';\n this.overshootBytes = overshootBytes;\n }\n}\n\nexport class JobOutputTooManyEntriesError extends Error {\n constructor(\n readonly entryCount: number,\n readonly limitEntries: number,\n ) {\n super(`Job outputs cannot define more than ${limitEntries} entries (found ${entryCount})`);\n this.name = 'JobOutputTooManyEntriesError';\n }\n}\n\nexport class JobOutputNotJsonSafeError extends Error {\n constructor(\n readonly outputKey: string,\n readonly reason: string,\n ) {\n super(`Job output \"${outputKey}\" cannot be persisted as JSON: ${reason}`);\n this.name = 'JobOutputNotJsonSafeError';\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 checkout target cannot be resolved, so there is nothing to check out.\nexport class CheckoutIntentUnresolvedError extends Error {\n constructor(target: {kind: 'project' | 'connection'; value: string}) {\n super(`Checkout intent unresolved: ${target.kind} ${target.value} not found`);\n this.name = 'CheckoutIntentUnresolvedError';\n }\n}\n\nexport class CheckoutConfigInvalidError extends Error {\n constructor(readonly stepId: string) {\n super(`Checkout config is invalid for step ${stepId}`);\n this.name = 'CheckoutConfigInvalidError';\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","WorkspaceSuspendedError","workspaceId","WorkspaceDeletedError","WorkspaceNotFoundError","AgentConfigUnresolvableError","options","message","cause","undefined","code","managedProviderId","AgentIntegrationMaterializationError","InterpolationUnresolvableError","params","interpolationUnresolvableMessage","field","source","envKey","envSuffix","isPermanentRunWorkflowError","error","InvalidJobRunnerLabelsError","JobNotFoundError","jobId","labels","requestedLabels","requestedSuffix","join","JobOutputTooLargeError","outputKey","limitBytes","measuredBytes","scope","overshootBytes","JobOutputTooManyEntriesError","entryCount","limitEntries","JobOutputNotJsonSafeError","reason","JobNotActiveError","status","WorkflowRunNotFoundError","workflowRunId","WorkflowRunNotCancellableError","SourceRunNotFoundError","RunNotTerminalError","NoFailedJobsError","CheckoutIntentUnresolvedError","target","kind","value","CheckoutConfigInvalidError","stepId","StepNotFoundError","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AAOE,KAAK,CAAC,UAAU,CAAC;QAC5E,IAAI,CAACtD,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMuD,mCAAmCzD;IAC9C,YAAY,AAAS0D,MAAc,CAAE;QACnC,KAAK,CAAC,CAAC,oCAAoC,EAAEA,QAAQ,QADlCA,SAAAA;QAEnB,IAAI,CAACxD,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAMyD,0BAA0B3D;IACrC,YAAY0D,MAAc,EAAE7B,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAE6B,OAAO,kBAAkB,EAAE7B,OAAO;QAChD,IAAI,CAAC3B,IAAI,GAAG;IACd;AACF;AAEA,OAAO,MAAM0D,4BAA4B5D;IACvC,YAAY0D,MAAc,EAAE7B,KAAa,CAAE;QACzC,KAAK,CAAC,CAAC,KAAK,EAAE6B,OAAO,QAAQ,EAAE7B,MAAM,0CAA0C,CAAC;QAChF,IAAI,CAAC3B,IAAI,GAAG;IACd;AACF;AAEA,0EAA0E;AAC1E,yEAAyE;AACzE,iEAAiE;AACjE,OAAO,MAAM2D,8BAA8B7D;IACzC,YACE,AAAS0D,MAAc,EACvB,AAAS7B,KAAa,EACtB,AAASiC,eAAuB,EAChC,AAASC,cAAsB,CAC/B;QACA,KAAK,CACH,CAAC,KAAK,EAAEL,OAAO,QAAQ,EAAE7B,MAAM,kBAAkB,EAAEiC,gBAAgB,0BAA0B,EAAEC,gBAAgB,QANxGL,SAAAA,aACA7B,QAAAA,YACAiC,kBAAAA,sBACAC,iBAAAA;QAKT,IAAI,CAAC7D,IAAI,GAAG;IACd;AACF"}
|
|
@@ -118,6 +118,8 @@ function stepDisplayName(step) {
|
|
|
118
118
|
return step.model === undefined ? firstLine(step.prompt) : `${step.model} · ${firstLine(step.prompt)}`;
|
|
119
119
|
case 'checkout':
|
|
120
120
|
return 'Checkout';
|
|
121
|
+
case 'tool':
|
|
122
|
+
return step.tool.method === undefined ? step.tool.id : `${step.tool.id}.${step.tool.method}`;
|
|
121
123
|
default:
|
|
122
124
|
return assertNever(step);
|
|
123
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/step-config/materialize-job-execution-steps.ts"],"sourcesContent":["import {DEFAULT_JOB_CHECKOUT, type WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {WorkflowExpression} from '@shipfox/expression';\nimport type {AgentDefaultsResolver} from '#core/agent-defaults.js';\nimport type {\n AgentToolMaterializationContext,\n AgentToolMaterializationSnapshot,\n} from '#core/agent-tools.js';\nimport type {StepConfigDispatchPlan} from '#core/entities/step.js';\nimport {resolveStepConfig, type WorkflowStepTemplateDiagnostic} from './resolve-step-config.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelStep = WorkflowModelJob['steps'][number];\ntype WorkflowSourceLocation = NonNullable<WorkflowModelStep['sourceLocation']>;\n\nconst FIRST_LINE_PATTERN = /\\r?\\n/;\n\nexport interface MaterializedWorkflowStep {\n readonly key: string | null;\n readonly name: string;\n readonly sourceLocation: WorkflowSourceLocation | null;\n readonly status: 'pending';\n readonly type: WorkflowModelStep['kind'] | 'setup';\n readonly config: Readonly<Record<string, unknown>>;\n readonly condition?: WorkflowExpression;\n readonly configPlan?: StepConfigDispatchPlan;\n readonly authoredConfig: Readonly<Record<string, unknown>> | null;\n readonly diagnostics?: readonly WorkflowStepTemplateDiagnostic[];\n readonly position: number;\n}\n\nexport interface MaterializeJobExecutionStepsParams {\n readonly model: WorkflowModel;\n readonly job: WorkflowModelJob;\n readonly context: WorkflowEvaluationContext;\n readonly resolveAgentDefaults?: AgentDefaultsResolver | undefined;\n readonly definitionId?: string | undefined;\n readonly agentToolContext?: AgentToolMaterializationContext | undefined;\n readonly agentToolSnapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}\n\n// Synthetic \"Set up job\" step prepended when a job execution's steps are materialized.\n// The runner prepares the workspace here; failures report through the normal step\n// protocol instead of hanging the job until the lease/timeout fires. Its config carries\n// checkout policy, never credential material.\nconst SETUP_STEP: Omit<MaterializedWorkflowStep, 'config'> = {\n key: null,\n name: 'Set up job',\n sourceLocation: null,\n status: 'pending',\n type: 'setup',\n authoredConfig: null,\n position: 0,\n};\n\nexport async function materializeJobExecutionSteps(\n params: MaterializeJobExecutionStepsParams,\n): Promise<readonly MaterializedWorkflowStep[]> {\n const {\n model,\n job,\n context,\n resolveAgentDefaults,\n definitionId = model.name,\n agentToolContext,\n agentToolSnapshot,\n } = params;\n\n return [\n setupStepForJob(job),\n ...(await Promise.all(\n job.steps.map(async (step, stepPosition) => {\n const stepContext = {\n ...context.values,\n job: {key: job.key, name: job.name ?? job.key},\n };\n const resolved = await resolveStepConfig({\n jobKey: job.key,\n step,\n workflowEnv: model.env,\n workflowEnvTemplates: model.templates?.env,\n jobEnv: job.env,\n jobEnvTemplates: job.templates?.env,\n context: stepContext,\n site: context.site,\n resolveAgentDefaults,\n definitionId,\n agentToolContext,\n agentToolSnapshot,\n });\n return {\n key: step.key ?? null,\n name: resolved.name ?? stepDisplayName(step),\n sourceLocation: step.sourceLocation ?? null,\n status: 'pending' as const,\n type: step.kind,\n config: materializedStepConfig({\n config: resolved.config,\n step,\n stepPosition,\n }),\n ...(step.if === undefined ? {} : {condition: step.if}),\n authoredConfig: resolved.authoredConfig,\n ...materializedConfigPlan(resolved.configPlan, resolved.trace),\n ...(resolved.diagnostics.length === 0 ? {} : {diagnostics: resolved.diagnostics}),\n position: stepPosition + 1,\n };\n }),\n )),\n ];\n}\n\nfunction setupStepForJob(job: WorkflowModelJob): MaterializedWorkflowStep {\n if (job.checkout === false || job.steps[0]?.kind === 'checkout') {\n return {...SETUP_STEP, config: {}};\n }\n\n const checkout = job.checkout ?? DEFAULT_JOB_CHECKOUT;\n\n return {\n ...SETUP_STEP,\n config: {\n checkout: {\n permissions: checkout.permissions,\n persist_credentials: checkout.persistCredentials,\n },\n },\n };\n}\n\nfunction materializedStepConfig(params: {\n readonly config: Readonly<Record<string, unknown>>;\n readonly step: WorkflowModelStep;\n readonly stepPosition: number;\n}): Readonly<Record<string, unknown>> {\n if (\n params.step.kind !== 'checkout' ||\n params.stepPosition !== 0 ||\n params.step.checkout.path !== undefined\n ) {\n return params.config;\n }\n\n const checkout = params.config.checkout;\n if (checkout === null || typeof checkout !== 'object' || Array.isArray(checkout)) {\n throw new Error('Checkout materialization config is missing an object');\n }\n\n return {...params.config, checkout: {...checkout, path: '.'}};\n}\n\nfunction materializedConfigPlan(\n configPlan: StepConfigDispatchPlan | null,\n trace: NonNullable<StepConfigDispatchPlan['trace']>,\n): {readonly configPlan?: StepConfigDispatchPlan} {\n if (configPlan === null && trace.length === 0) return {};\n return {configPlan: {...(configPlan ?? {}), ...(trace.length === 0 ? {} : {trace})}};\n}\n\nfunction stepDisplayName(step: WorkflowModelStep): string {\n const {kind} = step;\n switch (kind) {\n case 'run':\n return firstLine(step.command.value);\n case 'agent':\n return step.model === undefined\n ? firstLine(step.prompt)\n : `${step.model} · ${firstLine(step.prompt)}`;\n case 'checkout':\n return 'Checkout';\n default:\n return assertNever(step);\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(FIRST_LINE_PATTERN, 1)[0]?.trim() || value.trim();\n}\n\nfunction assertNever(value: never): never {\n throw new Error(`Unhandled workflow step kind: ${JSON.stringify(value)}`);\n}\n"],"names":["DEFAULT_JOB_CHECKOUT","resolveStepConfig","FIRST_LINE_PATTERN","SETUP_STEP","key","name","sourceLocation","status","type","authoredConfig","position","materializeJobExecutionSteps","params","model","job","context","resolveAgentDefaults","definitionId","agentToolContext","agentToolSnapshot","setupStepForJob","Promise","all","steps","map","step","stepPosition","stepContext","values","resolved","jobKey","workflowEnv","env","workflowEnvTemplates","templates","jobEnv","jobEnvTemplates","site","stepDisplayName","kind","config","materializedStepConfig","if","undefined","condition","materializedConfigPlan","configPlan","trace","diagnostics","length","checkout","permissions","persist_credentials","persistCredentials","path","Array","isArray","Error","firstLine","command","value","prompt","assertNever","split","trim","JSON","stringify"],"mappings":"AAAA,SAAQA,oBAAoB,QAA2B,+BAA+B;AAQtF,SAAQC,iBAAiB,QAA4C,2BAA2B;AAOhG,MAAMC,qBAAqB;AA0B3B,uFAAuF;AACvF,kFAAkF;AAClF,wFAAwF;AACxF,8CAA8C;AAC9C,MAAMC,aAAuD;IAC3DC,KAAK;IACLC,MAAM;IACNC,gBAAgB;IAChBC,QAAQ;IACRC,MAAM;IACNC,gBAAgB;IAChBC,UAAU;AACZ;AAEA,OAAO,eAAeC,6BACpBC,MAA0C;IAE1C,MAAM,EACJC,KAAK,EACLC,GAAG,EACHC,OAAO,EACPC,oBAAoB,EACpBC,eAAeJ,MAAMR,IAAI,EACzBa,gBAAgB,EAChBC,iBAAiB,EAClB,GAAGP;IAEJ,OAAO;QACLQ,gBAAgBN;WACZ,MAAMO,QAAQC,GAAG,CACnBR,IAAIS,KAAK,CAACC,GAAG,CAAC,OAAOC,MAAMC;YACzB,MAAMC,cAAc;gBAClB,GAAGZ,QAAQa,MAAM;gBACjBd,KAAK;oBAACV,KAAKU,IAAIV,GAAG;oBAAEC,MAAMS,IAAIT,IAAI,IAAIS,IAAIV,GAAG;gBAAA;YAC/C;YACA,MAAMyB,WAAW,MAAM5B,kBAAkB;gBACvC6B,QAAQhB,IAAIV,GAAG;gBACfqB;gBACAM,aAAalB,MAAMmB,GAAG;gBACtBC,sBAAsBpB,MAAMqB,SAAS,EAAEF;gBACvCG,QAAQrB,IAAIkB,GAAG;gBACfI,iBAAiBtB,IAAIoB,SAAS,EAAEF;gBAChCjB,SAASY;gBACTU,MAAMtB,QAAQsB,IAAI;gBAClBrB;gBACAC;gBACAC;gBACAC;YACF;YACA,OAAO;gBACLf,KAAKqB,KAAKrB,GAAG,IAAI;gBACjBC,MAAMwB,SAASxB,IAAI,IAAIiC,gBAAgBb;gBACvCnB,gBAAgBmB,KAAKnB,cAAc,IAAI;gBACvCC,QAAQ;gBACRC,MAAMiB,KA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,MAAM;QAAG;IAAC;AAC9D;AAEA,SAAST,uBACPC,UAAyC,EACzCC,KAAmD;IAEnD,IAAID,eAAe,QAAQC,MAAME,MAAM,KAAK,GAAG,OAAO,CAAC;IACvD,OAAO;QAACH,YAAY;YAAC,GAAIA,cAAc,CAAC,CAAC;YAAG,GAAIC,MAAME,MAAM,KAAK,IAAI,CAAC,IAAI;gBAACF;YAAK,CAAC;QAAC;IAAC;AACrF;AAEA,SAAST,gBAAgBb,IAAuB;IAC9C,MAAM,EAACc,IAAI,EAAC,GAAGd;IACf,OAAQc;QACN,KAAK;YACH,OAAOmB,UAAUjC,KAAKkC,OAAO,CAACC,KAAK;QACrC,KAAK;YACH,OAAOnC,KAAKZ,KAAK,KAAK8B,YAClBe,UAAUjC,KAAKoC,MAAM,IACrB,GAAGpC,KAAKZ,KAAK,CAAC,GAAG,EAAE6C,UAAUjC,KAAKoC,MAAM,GAAG;QACjD,KAAK;YACH,OAAO;QACT;YACE,OAAOC,YAAYrC;IACvB;AACF;AAEA,SAASiC,UAAUE,KAAa;IAC9B,OAAOA,MAAMG,KAAK,CAAC7D,oBAAoB,EAAE,CAAC,EAAE,EAAE8D,UAAUJ,MAAMI,IAAI;AACpE;AAEA,SAASF,YAAYF,KAAY;IAC/B,MAAM,IAAIH,MAAM,CAAC,8BAA8B,EAAEQ,KAAKC,SAAS,CAACN,QAAQ;AAC1E"}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/step-config/materialize-job-execution-steps.ts"],"sourcesContent":["import {DEFAULT_JOB_CHECKOUT, type WorkflowModel} from '@shipfox/api-definitions-dto';\nimport type {WorkflowExpression} from '@shipfox/expression';\nimport type {AgentDefaultsResolver} from '#core/agent-defaults.js';\nimport type {\n AgentToolMaterializationContext,\n AgentToolMaterializationSnapshot,\n} from '#core/agent-tools.js';\nimport type {StepConfigDispatchPlan} from '#core/entities/step.js';\nimport {resolveStepConfig, type WorkflowStepTemplateDiagnostic} from './resolve-step-config.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelStep = WorkflowModelJob['steps'][number];\ntype WorkflowSourceLocation = NonNullable<WorkflowModelStep['sourceLocation']>;\n\nconst FIRST_LINE_PATTERN = /\\r?\\n/;\n\nexport interface MaterializedWorkflowStep {\n readonly key: string | null;\n readonly name: string;\n readonly sourceLocation: WorkflowSourceLocation | null;\n readonly status: 'pending';\n readonly type: WorkflowModelStep['kind'] | 'setup';\n readonly config: Readonly<Record<string, unknown>>;\n readonly condition?: WorkflowExpression;\n readonly configPlan?: StepConfigDispatchPlan;\n readonly authoredConfig: Readonly<Record<string, unknown>> | null;\n readonly diagnostics?: readonly WorkflowStepTemplateDiagnostic[];\n readonly position: number;\n}\n\nexport interface MaterializeJobExecutionStepsParams {\n readonly model: WorkflowModel;\n readonly job: WorkflowModelJob;\n readonly context: WorkflowEvaluationContext;\n readonly resolveAgentDefaults?: AgentDefaultsResolver | undefined;\n readonly definitionId?: string | undefined;\n readonly agentToolContext?: AgentToolMaterializationContext | undefined;\n readonly agentToolSnapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}\n\n// Synthetic \"Set up job\" step prepended when a job execution's steps are materialized.\n// The runner prepares the workspace here; failures report through the normal step\n// protocol instead of hanging the job until the lease/timeout fires. Its config carries\n// checkout policy, never credential material.\nconst SETUP_STEP: Omit<MaterializedWorkflowStep, 'config'> = {\n key: null,\n name: 'Set up job',\n sourceLocation: null,\n status: 'pending',\n type: 'setup',\n authoredConfig: null,\n position: 0,\n};\n\nexport async function materializeJobExecutionSteps(\n params: MaterializeJobExecutionStepsParams,\n): Promise<readonly MaterializedWorkflowStep[]> {\n const {\n model,\n job,\n context,\n resolveAgentDefaults,\n definitionId = model.name,\n agentToolContext,\n agentToolSnapshot,\n } = params;\n\n return [\n setupStepForJob(job),\n ...(await Promise.all(\n job.steps.map(async (step, stepPosition) => {\n const stepContext = {\n ...context.values,\n job: {key: job.key, name: job.name ?? job.key},\n };\n const resolved = await resolveStepConfig({\n jobKey: job.key,\n step,\n workflowEnv: model.env,\n workflowEnvTemplates: model.templates?.env,\n jobEnv: job.env,\n jobEnvTemplates: job.templates?.env,\n context: stepContext,\n site: context.site,\n resolveAgentDefaults,\n definitionId,\n agentToolContext,\n agentToolSnapshot,\n });\n return {\n key: step.key ?? null,\n name: resolved.name ?? stepDisplayName(step),\n sourceLocation: step.sourceLocation ?? null,\n status: 'pending' as const,\n type: step.kind,\n config: materializedStepConfig({\n config: resolved.config,\n step,\n stepPosition,\n }),\n ...(step.if === undefined ? {} : {condition: step.if}),\n authoredConfig: resolved.authoredConfig,\n ...materializedConfigPlan(resolved.configPlan, resolved.trace),\n ...(resolved.diagnostics.length === 0 ? {} : {diagnostics: resolved.diagnostics}),\n position: stepPosition + 1,\n };\n }),\n )),\n ];\n}\n\nfunction setupStepForJob(job: WorkflowModelJob): MaterializedWorkflowStep {\n if (job.checkout === false || job.steps[0]?.kind === 'checkout') {\n return {...SETUP_STEP, config: {}};\n }\n\n const checkout = job.checkout ?? DEFAULT_JOB_CHECKOUT;\n\n return {\n ...SETUP_STEP,\n config: {\n checkout: {\n permissions: checkout.permissions,\n persist_credentials: checkout.persistCredentials,\n },\n },\n };\n}\n\nfunction materializedStepConfig(params: {\n readonly config: Readonly<Record<string, unknown>>;\n readonly step: WorkflowModelStep;\n readonly stepPosition: number;\n}): Readonly<Record<string, unknown>> {\n if (\n params.step.kind !== 'checkout' ||\n params.stepPosition !== 0 ||\n params.step.checkout.path !== undefined\n ) {\n return params.config;\n }\n\n const checkout = params.config.checkout;\n if (checkout === null || typeof checkout !== 'object' || Array.isArray(checkout)) {\n throw new Error('Checkout materialization config is missing an object');\n }\n\n return {...params.config, checkout: {...checkout, path: '.'}};\n}\n\nfunction materializedConfigPlan(\n configPlan: StepConfigDispatchPlan | null,\n trace: NonNullable<StepConfigDispatchPlan['trace']>,\n): {readonly configPlan?: StepConfigDispatchPlan} {\n if (configPlan === null && trace.length === 0) return {};\n return {configPlan: {...(configPlan ?? {}), ...(trace.length === 0 ? {} : {trace})}};\n}\n\nfunction stepDisplayName(step: WorkflowModelStep): string {\n const {kind} = step;\n switch (kind) {\n case 'run':\n return firstLine(step.command.value);\n case 'agent':\n return step.model === undefined\n ? firstLine(step.prompt)\n : `${step.model} · ${firstLine(step.prompt)}`;\n case 'checkout':\n return 'Checkout';\n case 'tool':\n return step.tool.method === undefined ? step.tool.id : `${step.tool.id}.${step.tool.method}`;\n default:\n return assertNever(step);\n }\n}\n\nfunction firstLine(value: string): string {\n return value.split(FIRST_LINE_PATTERN, 1)[0]?.trim() || value.trim();\n}\n\nfunction assertNever(value: never): never {\n throw new Error(`Unhandled workflow step kind: ${JSON.stringify(value)}`);\n}\n"],"names":["DEFAULT_JOB_CHECKOUT","resolveStepConfig","FIRST_LINE_PATTERN","SETUP_STEP","key","name","sourceLocation","status","type","authoredConfig","position","materializeJobExecutionSteps","params","model","job","context","resolveAgentDefaults","definitionId","agentToolContext","agentToolSnapshot","setupStepForJob","Promise","all","steps","map","step","stepPosition","stepContext","values","resolved","jobKey","workflowEnv","env","workflowEnvTemplates","templates","jobEnv","jobEnvTemplates","site","stepDisplayName","kind","config","materializedStepConfig","if","undefined","condition","materializedConfigPlan","configPlan","trace","diagnostics","length","checkout","permissions","persist_credentials","persistCredentials","path","Array","isArray","Error","firstLine","command","value","prompt","tool","method","id","assertNever","split","trim","JSON","stringify"],"mappings":"AAAA,SAAQA,oBAAoB,QAA2B,+BAA+B;AAQtF,SAAQC,iBAAiB,QAA4C,2BAA2B;AAOhG,MAAMC,qBAAqB;AA0B3B,uFAAuF;AACvF,kFAAkF;AAClF,wFAAwF;AACxF,8CAA8C;AAC9C,MAAMC,aAAuD;IAC3DC,KAAK;IACLC,MAAM;IACNC,gBAAgB;IAChBC,QAAQ;IACRC,MAAM;IACNC,gBAAgB;IAChBC,UAAU;AACZ;AAEA,OAAO,eAAeC,6BACpBC,MAA0C;IAE1C,MAAM,EACJC,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,KAAKkC,OAAO,CAACC,KAAK;QACrC,KAAK;YACH,OAAOnC,KAAKZ,KAAK,KAAK8B,YAClBe,UAAUjC,KAAKoC,MAAM,IACrB,GAAGpC,KAAKZ,KAAK,CAAC,GAAG,EAAE6C,UAAUjC,KAAKoC,MAAM,GAAG;QACjD,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAOpC,KAAKqC,IAAI,CAACC,MAAM,KAAKpB,YAAYlB,KAAKqC,IAAI,CAACE,EAAE,GAAG,GAAGvC,KAAKqC,IAAI,CAACE,EAAE,CAAC,CAAC,EAAEvC,KAAKqC,IAAI,CAACC,MAAM,EAAE;QAC9F;YACE,OAAOE,YAAYxC;IACvB;AACF;AAEA,SAASiC,UAAUE,KAAa;IAC9B,OAAOA,MAAMM,KAAK,CAAChE,oBAAoB,EAAE,CAAC,EAAE,EAAEiE,UAAUP,MAAMO,IAAI;AACpE;AAEA,SAASF,YAAYL,KAAY;IAC/B,MAAM,IAAIH,MAAM,CAAC,8BAA8B,EAAEW,KAAKC,SAAS,CAACT,QAAQ;AAC1E"}
|
|
@@ -108,7 +108,9 @@ async function buildStepConfig(params) {
|
|
|
108
108
|
}
|
|
109
109
|
function resolveWorkingDirectoryConfig(params) {
|
|
110
110
|
const value = params.step.workingDirectory;
|
|
111
|
-
|
|
111
|
+
// Tool steps have no working tree, so they never carry a working-directory
|
|
112
|
+
// template; the union narrows the remaining kinds to those that can.
|
|
113
|
+
const template = params.step.kind === 'tool' ? undefined : params.step.templates?.workingDirectory;
|
|
112
114
|
if (value === undefined) {
|
|
113
115
|
return {
|
|
114
116
|
config: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/step-config/resolve-step-config.ts"],"sourcesContent":["import type {WorkflowEnvTemplates, WorkflowModel} from '@shipfox/api-definitions-dto';\nimport {WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS} from '@shipfox/api-definitions-dto';\nimport {\n type AvailabilitySite,\n capTraceEntries,\n type EvaluationTraceLimitEntry,\n type WorkflowExpressionEvaluationContext,\n} from '@shipfox/expression';\nimport type {AgentDefaultsResolver} from '#core/agent-defaults.js';\nimport type {\n AgentToolMaterializationContext,\n AgentToolMaterializationSnapshot,\n} from '#core/agent-tools.js';\nimport type {StepConfigDispatchPlan} from '#core/entities/step.js';\nimport {resolveAgentStepConfig} from './agent.js';\nimport {\n freezeStepField,\n resolveStepField,\n type StepConfigField,\n type WorkflowStepEvaluationTraceEntry,\n type WorkflowStepTemplateDiagnostic,\n} from './fields.js';\nimport {resolveRunStepConfig, type StepConfigMode} from './run.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelStep = WorkflowModelJob['steps'][number];\ntype WorkflowModelRunStep = Extract<WorkflowModelStep, {kind: 'run'}>;\ntype WorkflowModelAgentStep = Extract<WorkflowModelStep, {kind: 'agent'}>;\ntype WorkflowModelCheckoutStep = Extract<WorkflowModelStep, {kind: 'checkout'}>;\n\nexport type {StepConfigField, WorkflowStepTemplateDiagnostic};\n\nexport interface ResolvedStepConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: StepConfigDispatchPlan | null;\n readonly authoredConfig: Record<string, unknown> | null;\n readonly name?: string;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly (WorkflowStepEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface ResolveStepConfigParams {\n readonly jobKey: string;\n readonly step: WorkflowModelStep;\n readonly workflowEnv: WorkflowModel['env'];\n readonly workflowEnvTemplates: WorkflowEnvTemplates | undefined;\n readonly jobEnv: WorkflowModelJob['env'];\n readonly jobEnvTemplates: WorkflowEnvTemplates | undefined;\n readonly context: WorkflowExpressionEvaluationContext;\n readonly site: AvailabilitySite;\n readonly resolveAgentDefaults?: AgentDefaultsResolver | undefined;\n readonly definitionId: string;\n readonly agentToolContext?: AgentToolMaterializationContext | undefined;\n readonly agentToolSnapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}\n\ntype BuildStepConfigParams = ResolveStepConfigParams & {readonly mode: StepConfigMode};\n\ninterface BuiltStepConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: StepConfigDispatchPlan | null;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\ninterface WorkingDirectoryConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: Pick<StepConfigDispatchPlan, 'working_directory'> | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\ninterface CheckoutConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: Pick<StepConfigDispatchPlan, 'checkout'> | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\nexport async function resolveStepConfig(\n params: ResolveStepConfigParams,\n): Promise<ResolvedStepConfig> {\n const context = evaluationContext(params);\n const effective = await buildStepConfig({...params, context, mode: 'effective'});\n const authoredConfig = effective.hasTemplates\n ? (await buildStepConfig({...params, context, mode: 'authored'})).config\n : null;\n const name = resolveStepName(params.step, context, params.definitionId);\n\n return {\n config: effective.config,\n configPlan: effective.configPlan,\n authoredConfig,\n ...(name.value === undefined || name.value === '' ? {} : {name: name.value}),\n diagnostics: [...effective.diagnostics, ...name.diagnostics],\n trace: capTraceEntries([...effective.trace, ...name.trace]),\n };\n}\n\nasync function buildStepConfig(\n params: Omit<BuildStepConfigParams, 'context'> & {readonly context: WorkflowEvaluationContext},\n): Promise<BuiltStepConfig> {\n const gate = gateConfigForStep(params.step);\n const outputs = outputsConfigForStep(params.step);\n const workingDirectory = resolveWorkingDirectoryConfig(params);\n const runStep = runStepOrNull(params.step);\n const isRunStep = runStep !== null;\n\n if (isRunStep) {\n const run = resolveRunStepConfig({...params, step: runStep});\n return {\n config: {...workingDirectory.config, ...run.config, ...gate, ...outputs},\n configPlan: mergeConfigPlans(run.configPlan, workingDirectory.configPlan),\n diagnostics: [...workingDirectory.diagnostics, ...run.diagnostics],\n trace: [...workingDirectory.trace, ...run.trace],\n hasTemplates: run.hasTemplates || workingDirectory.hasTemplates,\n };\n }\n\n const checkoutStep = checkoutStepOrNull(params.step);\n if (checkoutStep !== null) {\n const checkout = resolveCheckoutStepConfig({...params, step: checkoutStep});\n return {\n config: {\n ...checkout.config,\n ...gate,\n ...outputs,\n },\n configPlan: checkout.configPlan === undefined ? null : checkout.configPlan,\n diagnostics: checkout.diagnostics,\n trace: checkout.trace,\n hasTemplates: checkout.hasTemplates,\n };\n }\n\n const agentStep = agentStepOrNull(params.step);\n if (agentStep === null) throw new Error(`Unsupported workflow step kind: ${params.step.kind}`);\n\n const agent = await resolveAgentStepConfig({...params, step: agentStep});\n return {\n config: {...workingDirectory.config, ...agent.config, ...gate, ...outputs},\n configPlan: mergeConfigPlans(agent.configPlan, workingDirectory.configPlan),\n diagnostics: [...workingDirectory.diagnostics, ...agent.diagnostics],\n trace: [...workingDirectory.trace, ...agent.trace],\n hasTemplates: agent.hasTemplates || workingDirectory.hasTemplates,\n };\n}\n\nfunction resolveWorkingDirectoryConfig(\n params: Omit<BuildStepConfigParams, 'context'> & {readonly context: WorkflowEvaluationContext},\n): WorkingDirectoryConfig {\n const value = params.step.workingDirectory;\n const template = params.step.templates?.workingDirectory;\n if (value === undefined) {\n return {\n config: {},\n configPlan: undefined,\n diagnostics: [],\n trace: [],\n hasTemplates: template !== undefined,\n };\n }\n\n if (template === undefined || params.mode === 'authored') {\n return {\n config: {working_directory: value},\n configPlan: undefined,\n diagnostics: [],\n trace: [],\n hasTemplates: template !== undefined,\n };\n }\n\n const resolved = resolveStepField({\n field: 'step.working_directory',\n template: {segments: template},\n context: params.context,\n definitionId: params.definitionId,\n errorField: 'step.working_directory',\n });\n const trace = resolved.trace.map((entry) => ({\n ...entry,\n field: 'step.working_directory' as const,\n }));\n const diagnostics = resolved.diagnostics.map((diagnostic) => ({\n ...diagnostic,\n field: 'step.working_directory' as const,\n }));\n if (resolved.kind === 'residual') {\n return {\n config: {},\n configPlan: {working_directory: resolved.field},\n diagnostics,\n trace,\n hasTemplates: true,\n };\n }\n\n return {\n config: {working_directory: resolved.value},\n configPlan: undefined,\n diagnostics,\n trace,\n hasTemplates: true,\n };\n}\n\nfunction mergeConfigPlans(\n primary: StepConfigDispatchPlan | null,\n secondary: Pick<StepConfigDispatchPlan, 'working_directory'> | undefined,\n): StepConfigDispatchPlan | null {\n if (secondary === undefined) return primary;\n return {...(primary ?? {}), ...secondary};\n}\n\nfunction evaluationContext(params: {\n readonly context: WorkflowExpressionEvaluationContext;\n readonly site: AvailabilitySite;\n}): WorkflowEvaluationContext {\n return {site: params.site, values: params.context};\n}\n\nfunction runStepOrNull(step: WorkflowModelStep): WorkflowModelRunStep | null {\n const isRunStep = step.kind === 'run';\n return isRunStep ? step : null;\n}\n\nfunction agentStepOrNull(step: WorkflowModelStep): WorkflowModelAgentStep | null {\n const isAgentStep = step.kind === 'agent';\n return isAgentStep ? step : null;\n}\n\nfunction checkoutStepOrNull(step: WorkflowModelStep): WorkflowModelCheckoutStep | null {\n const isCheckoutStep = step.kind === 'checkout';\n return isCheckoutStep ? step : null;\n}\n\nfunction resolveCheckoutStepConfig(\n params: Omit<BuildStepConfigParams, 'context' | 'step'> & {\n readonly context: WorkflowEvaluationContext;\n readonly step: WorkflowModelCheckoutStep;\n },\n): CheckoutConfig {\n const checkout = params.step.checkout;\n const config: Record<string, unknown> = {\n fetch_depth: checkout.fetchDepth,\n permissions: checkout.permissions,\n persist_credentials: checkout.persistCredentials,\n ...(checkout.force === undefined ? {} : {force: checkout.force}),\n };\n const checkoutConfig: Record<string, unknown> = config;\n const checkoutPlan: NonNullable<StepConfigDispatchPlan['checkout']> = {};\n const diagnostics: WorkflowStepTemplateDiagnostic[] = [];\n const trace: WorkflowStepEvaluationTraceEntry[] = [];\n let hasTemplates = false;\n\n for (const [key, field] of WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS) {\n const template = checkout.templates?.[key];\n if (template !== undefined) hasTemplates = true;\n\n const value = checkout[key];\n if (value === undefined) continue;\n\n if (template === undefined || params.mode === 'authored') {\n checkoutConfig[key] = value;\n continue;\n }\n\n const resolved = resolveStepField({\n field,\n template: {segments: template},\n context: params.context,\n definitionId: params.definitionId,\n errorField: field,\n });\n trace.push(...resolved.trace.map((entry) => ({...entry, field})));\n diagnostics.push(...resolved.diagnostics.map((diagnostic) => ({...diagnostic, field})));\n\n if (resolved.kind === 'residual') {\n checkoutPlan[key] = resolved.field;\n } else {\n checkoutConfig[key] = resolved.value;\n }\n }\n\n return {\n config: {checkout: config},\n configPlan: Object.keys(checkoutPlan).length === 0 ? undefined : {checkout: checkoutPlan},\n diagnostics,\n trace,\n hasTemplates,\n };\n}\n\nfunction gateConfigForStep(step: WorkflowModelStep): Record<string, unknown> {\n const hasGate = step.gate !== undefined;\n return hasGate ? {gate: stepGateConfig(step.gate)} : {};\n}\n\nfunction outputsConfigForStep(step: WorkflowModelStep): Record<string, unknown> {\n const hasOutputs = step.outputs !== undefined;\n return hasOutputs ? {outputs: step.outputs} : {};\n}\n\nfunction resolveStepName(\n step: WorkflowModelStep,\n context: WorkflowEvaluationContext,\n definitionId: string,\n): {\n readonly value: string | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n} {\n const hasName = step.name !== undefined;\n if (!hasName) return {value: undefined, diagnostics: [], trace: []};\n\n const hasNameTemplate = step.templates?.name !== undefined;\n if (!hasNameTemplate) return {value: step.name, diagnostics: [], trace: []};\n\n const resolved = freezeStepField({\n field: 'step.name',\n template: {segments: step.templates.name},\n context,\n definitionId,\n errorField: 'step.name',\n });\n return {\n value: resolved.value,\n diagnostics: resolved.diagnostics.map((diagnostic) => ({...diagnostic, field: 'step.name'})),\n trace: resolved.trace.map((entry) => ({...entry, field: 'step.name'})),\n };\n}\n\nfunction stepGateConfig(gate: NonNullable<WorkflowModelStep['gate']>): Record<string, unknown> {\n const hasSuccess = gate.success !== undefined;\n const hasOnFailure = gate.onFailure !== undefined;\n const hasOnFailureFeedback = gate.onFailure?.feedback !== undefined;\n const hasOnFailureFeedbackTemplate = gate.onFailure?.feedbackTemplate !== undefined;\n\n return {\n ...(hasSuccess\n ? {\n success: {\n language: gate.success.language,\n check: gate.success.check,\n source: gate.success.source,\n },\n }\n : {}),\n ...(hasOnFailure\n ? {\n on_failure: {\n restart_from: gate.onFailure.restartFrom,\n ...(hasOnFailureFeedback ? {feedback: gate.onFailure.feedback} : {}),\n ...(hasOnFailureFeedbackTemplate\n ? {feedback_template: {segments: gate.onFailure.feedbackTemplate}}\n : {}),\n },\n }\n : {}),\n };\n}\n"],"names":["WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS","capTraceEntries","resolveAgentStepConfig","freezeStepField","resolveStepField","resolveRunStepConfig","resolveStepConfig","params","context","evaluationContext","effective","buildStepConfig","mode","authoredConfig","hasTemplates","config","name","resolveStepName","step","definitionId","configPlan","value","undefined","diagnostics","trace","gate","gateConfigForStep","outputs","outputsConfigForStep","workingDirectory","resolveWorkingDirectoryConfig","runStep","runStepOrNull","isRunStep","run","mergeConfigPlans","checkoutStep","checkoutStepOrNull","checkout","resolveCheckoutStepConfig","agentStep","agentStepOrNull","Error","kind","agent","template","templates","working_directory","resolved","field","segments","errorField","map","entry","diagnostic","primary","secondary","site","values","isAgentStep","isCheckoutStep","fetch_depth","fetchDepth","permissions","persist_credentials","persistCredentials","force","checkoutConfig","checkoutPlan","key","push","Object","keys","length","hasGate","stepGateConfig","hasOutputs","hasName","hasNameTemplate","hasSuccess","success","hasOnFailure","onFailure","hasOnFailureFeedback","feedback","hasOnFailureFeedbackTemplate","feedbackTemplate","language","check","source","on_failure","restart_from","restart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BAAuB;oBAACC,UAAU3D,KAAKyD,SAAS,CAACE,QAAQ;gBAAA,IAAI,CAAC,CAAC;gBACnE,GAAIC,+BACA;oBAACQ,mBAAmB;wBAAC3C,UAAUzB,KAAKyD,SAAS,CAACI,gBAAgB;oBAAA;gBAAC,IAC/D,CAAC,CAAC;YACR;QACF,IACA,CAAC,CAAC;IACR;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/core/step-config/resolve-step-config.ts"],"sourcesContent":["import type {WorkflowEnvTemplates, WorkflowModel} from '@shipfox/api-definitions-dto';\nimport {WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS} from '@shipfox/api-definitions-dto';\nimport {\n type AvailabilitySite,\n capTraceEntries,\n type EvaluationTraceLimitEntry,\n type WorkflowExpressionEvaluationContext,\n} from '@shipfox/expression';\nimport type {AgentDefaultsResolver} from '#core/agent-defaults.js';\nimport type {\n AgentToolMaterializationContext,\n AgentToolMaterializationSnapshot,\n} from '#core/agent-tools.js';\nimport type {StepConfigDispatchPlan} from '#core/entities/step.js';\nimport {resolveAgentStepConfig} from './agent.js';\nimport {\n freezeStepField,\n resolveStepField,\n type StepConfigField,\n type WorkflowStepEvaluationTraceEntry,\n type WorkflowStepTemplateDiagnostic,\n} from './fields.js';\nimport {resolveRunStepConfig, type StepConfigMode} from './run.js';\nimport type {WorkflowEvaluationContext} from './workflow-evaluation-context.js';\n\ntype WorkflowModelJob = WorkflowModel['jobs'][number];\ntype WorkflowModelStep = WorkflowModelJob['steps'][number];\ntype WorkflowModelRunStep = Extract<WorkflowModelStep, {kind: 'run'}>;\ntype WorkflowModelAgentStep = Extract<WorkflowModelStep, {kind: 'agent'}>;\ntype WorkflowModelCheckoutStep = Extract<WorkflowModelStep, {kind: 'checkout'}>;\n\nexport type {StepConfigField, WorkflowStepTemplateDiagnostic};\n\nexport interface ResolvedStepConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: StepConfigDispatchPlan | null;\n readonly authoredConfig: Record<string, unknown> | null;\n readonly name?: string;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly (WorkflowStepEvaluationTraceEntry | EvaluationTraceLimitEntry)[];\n}\n\nexport interface ResolveStepConfigParams {\n readonly jobKey: string;\n readonly step: WorkflowModelStep;\n readonly workflowEnv: WorkflowModel['env'];\n readonly workflowEnvTemplates: WorkflowEnvTemplates | undefined;\n readonly jobEnv: WorkflowModelJob['env'];\n readonly jobEnvTemplates: WorkflowEnvTemplates | undefined;\n readonly context: WorkflowExpressionEvaluationContext;\n readonly site: AvailabilitySite;\n readonly resolveAgentDefaults?: AgentDefaultsResolver | undefined;\n readonly definitionId: string;\n readonly agentToolContext?: AgentToolMaterializationContext | undefined;\n readonly agentToolSnapshot?: AgentToolMaterializationSnapshot | null | undefined;\n}\n\ntype BuildStepConfigParams = ResolveStepConfigParams & {readonly mode: StepConfigMode};\n\ninterface BuiltStepConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: StepConfigDispatchPlan | null;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\ninterface WorkingDirectoryConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: Pick<StepConfigDispatchPlan, 'working_directory'> | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\ninterface CheckoutConfig {\n readonly config: Record<string, unknown>;\n readonly configPlan: Pick<StepConfigDispatchPlan, 'checkout'> | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n readonly hasTemplates: boolean;\n}\n\nexport async function resolveStepConfig(\n params: ResolveStepConfigParams,\n): Promise<ResolvedStepConfig> {\n const context = evaluationContext(params);\n const effective = await buildStepConfig({...params, context, mode: 'effective'});\n const authoredConfig = effective.hasTemplates\n ? (await buildStepConfig({...params, context, mode: 'authored'})).config\n : null;\n const name = resolveStepName(params.step, context, params.definitionId);\n\n return {\n config: effective.config,\n configPlan: effective.configPlan,\n authoredConfig,\n ...(name.value === undefined || name.value === '' ? {} : {name: name.value}),\n diagnostics: [...effective.diagnostics, ...name.diagnostics],\n trace: capTraceEntries([...effective.trace, ...name.trace]),\n };\n}\n\nasync function buildStepConfig(\n params: Omit<BuildStepConfigParams, 'context'> & {readonly context: WorkflowEvaluationContext},\n): Promise<BuiltStepConfig> {\n const gate = gateConfigForStep(params.step);\n const outputs = outputsConfigForStep(params.step);\n const workingDirectory = resolveWorkingDirectoryConfig(params);\n const runStep = runStepOrNull(params.step);\n const isRunStep = runStep !== null;\n\n if (isRunStep) {\n const run = resolveRunStepConfig({...params, step: runStep});\n return {\n config: {...workingDirectory.config, ...run.config, ...gate, ...outputs},\n configPlan: mergeConfigPlans(run.configPlan, workingDirectory.configPlan),\n diagnostics: [...workingDirectory.diagnostics, ...run.diagnostics],\n trace: [...workingDirectory.trace, ...run.trace],\n hasTemplates: run.hasTemplates || workingDirectory.hasTemplates,\n };\n }\n\n const checkoutStep = checkoutStepOrNull(params.step);\n if (checkoutStep !== null) {\n const checkout = resolveCheckoutStepConfig({...params, step: checkoutStep});\n return {\n config: {\n ...checkout.config,\n ...gate,\n ...outputs,\n },\n configPlan: checkout.configPlan === undefined ? null : checkout.configPlan,\n diagnostics: checkout.diagnostics,\n trace: checkout.trace,\n hasTemplates: checkout.hasTemplates,\n };\n }\n\n const agentStep = agentStepOrNull(params.step);\n if (agentStep === null) throw new Error(`Unsupported workflow step kind: ${params.step.kind}`);\n\n const agent = await resolveAgentStepConfig({...params, step: agentStep});\n return {\n config: {...workingDirectory.config, ...agent.config, ...gate, ...outputs},\n configPlan: mergeConfigPlans(agent.configPlan, workingDirectory.configPlan),\n diagnostics: [...workingDirectory.diagnostics, ...agent.diagnostics],\n trace: [...workingDirectory.trace, ...agent.trace],\n hasTemplates: agent.hasTemplates || workingDirectory.hasTemplates,\n };\n}\n\nfunction resolveWorkingDirectoryConfig(\n params: Omit<BuildStepConfigParams, 'context'> & {readonly context: WorkflowEvaluationContext},\n): WorkingDirectoryConfig {\n const value = params.step.workingDirectory;\n // Tool steps have no working tree, so they never carry a working-directory\n // template; the union narrows the remaining kinds to those that can.\n const template =\n params.step.kind === 'tool' ? undefined : params.step.templates?.workingDirectory;\n if (value === undefined) {\n return {\n config: {},\n configPlan: undefined,\n diagnostics: [],\n trace: [],\n hasTemplates: template !== undefined,\n };\n }\n\n if (template === undefined || params.mode === 'authored') {\n return {\n config: {working_directory: value},\n configPlan: undefined,\n diagnostics: [],\n trace: [],\n hasTemplates: template !== undefined,\n };\n }\n\n const resolved = resolveStepField({\n field: 'step.working_directory',\n template: {segments: template},\n context: params.context,\n definitionId: params.definitionId,\n errorField: 'step.working_directory',\n });\n const trace = resolved.trace.map((entry) => ({\n ...entry,\n field: 'step.working_directory' as const,\n }));\n const diagnostics = resolved.diagnostics.map((diagnostic) => ({\n ...diagnostic,\n field: 'step.working_directory' as const,\n }));\n if (resolved.kind === 'residual') {\n return {\n config: {},\n configPlan: {working_directory: resolved.field},\n diagnostics,\n trace,\n hasTemplates: true,\n };\n }\n\n return {\n config: {working_directory: resolved.value},\n configPlan: undefined,\n diagnostics,\n trace,\n hasTemplates: true,\n };\n}\n\nfunction mergeConfigPlans(\n primary: StepConfigDispatchPlan | null,\n secondary: Pick<StepConfigDispatchPlan, 'working_directory'> | undefined,\n): StepConfigDispatchPlan | null {\n if (secondary === undefined) return primary;\n return {...(primary ?? {}), ...secondary};\n}\n\nfunction evaluationContext(params: {\n readonly context: WorkflowExpressionEvaluationContext;\n readonly site: AvailabilitySite;\n}): WorkflowEvaluationContext {\n return {site: params.site, values: params.context};\n}\n\nfunction runStepOrNull(step: WorkflowModelStep): WorkflowModelRunStep | null {\n const isRunStep = step.kind === 'run';\n return isRunStep ? step : null;\n}\n\nfunction agentStepOrNull(step: WorkflowModelStep): WorkflowModelAgentStep | null {\n const isAgentStep = step.kind === 'agent';\n return isAgentStep ? step : null;\n}\n\nfunction checkoutStepOrNull(step: WorkflowModelStep): WorkflowModelCheckoutStep | null {\n const isCheckoutStep = step.kind === 'checkout';\n return isCheckoutStep ? step : null;\n}\n\nfunction resolveCheckoutStepConfig(\n params: Omit<BuildStepConfigParams, 'context' | 'step'> & {\n readonly context: WorkflowEvaluationContext;\n readonly step: WorkflowModelCheckoutStep;\n },\n): CheckoutConfig {\n const checkout = params.step.checkout;\n const config: Record<string, unknown> = {\n fetch_depth: checkout.fetchDepth,\n permissions: checkout.permissions,\n persist_credentials: checkout.persistCredentials,\n ...(checkout.force === undefined ? {} : {force: checkout.force}),\n };\n const checkoutConfig: Record<string, unknown> = config;\n const checkoutPlan: NonNullable<StepConfigDispatchPlan['checkout']> = {};\n const diagnostics: WorkflowStepTemplateDiagnostic[] = [];\n const trace: WorkflowStepEvaluationTraceEntry[] = [];\n let hasTemplates = false;\n\n for (const [key, field] of WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS) {\n const template = checkout.templates?.[key];\n if (template !== undefined) hasTemplates = true;\n\n const value = checkout[key];\n if (value === undefined) continue;\n\n if (template === undefined || params.mode === 'authored') {\n checkoutConfig[key] = value;\n continue;\n }\n\n const resolved = resolveStepField({\n field,\n template: {segments: template},\n context: params.context,\n definitionId: params.definitionId,\n errorField: field,\n });\n trace.push(...resolved.trace.map((entry) => ({...entry, field})));\n diagnostics.push(...resolved.diagnostics.map((diagnostic) => ({...diagnostic, field})));\n\n if (resolved.kind === 'residual') {\n checkoutPlan[key] = resolved.field;\n } else {\n checkoutConfig[key] = resolved.value;\n }\n }\n\n return {\n config: {checkout: config},\n configPlan: Object.keys(checkoutPlan).length === 0 ? undefined : {checkout: checkoutPlan},\n diagnostics,\n trace,\n hasTemplates,\n };\n}\n\nfunction gateConfigForStep(step: WorkflowModelStep): Record<string, unknown> {\n const hasGate = step.gate !== undefined;\n return hasGate ? {gate: stepGateConfig(step.gate)} : {};\n}\n\nfunction outputsConfigForStep(step: WorkflowModelStep): Record<string, unknown> {\n const hasOutputs = step.outputs !== undefined;\n return hasOutputs ? {outputs: step.outputs} : {};\n}\n\nfunction resolveStepName(\n step: WorkflowModelStep,\n context: WorkflowEvaluationContext,\n definitionId: string,\n): {\n readonly value: string | undefined;\n readonly diagnostics: readonly WorkflowStepTemplateDiagnostic[];\n readonly trace: readonly WorkflowStepEvaluationTraceEntry[];\n} {\n const hasName = step.name !== undefined;\n if (!hasName) return {value: undefined, diagnostics: [], trace: []};\n\n const hasNameTemplate = step.templates?.name !== undefined;\n if (!hasNameTemplate) return {value: step.name, diagnostics: [], trace: []};\n\n const resolved = freezeStepField({\n field: 'step.name',\n template: {segments: step.templates.name},\n context,\n definitionId,\n errorField: 'step.name',\n });\n return {\n value: resolved.value,\n diagnostics: resolved.diagnostics.map((diagnostic) => ({...diagnostic, field: 'step.name'})),\n trace: resolved.trace.map((entry) => ({...entry, field: 'step.name'})),\n };\n}\n\nfunction stepGateConfig(gate: NonNullable<WorkflowModelStep['gate']>): Record<string, unknown> {\n const hasSuccess = gate.success !== undefined;\n const hasOnFailure = gate.onFailure !== undefined;\n const hasOnFailureFeedback = gate.onFailure?.feedback !== undefined;\n const hasOnFailureFeedbackTemplate = gate.onFailure?.feedbackTemplate !== undefined;\n\n return {\n ...(hasSuccess\n ? {\n success: {\n language: gate.success.language,\n check: gate.success.check,\n source: gate.success.source,\n },\n }\n : {}),\n ...(hasOnFailure\n ? {\n on_failure: {\n restart_from: gate.onFailure.restartFrom,\n ...(hasOnFailureFeedback ? {feedback: gate.onFailure.feedback} : {}),\n ...(hasOnFailureFeedbackTemplate\n ? {feedback_template: {segments: gate.onFailure.feedbackTemplate}}\n : {}),\n },\n }\n : {}),\n };\n}\n"],"names":["WORKFLOW_MODEL_CHECKOUT_TARGET_FIELDS","capTraceEntries","resolveAgentStepConfig","freezeStepField","resolveStepField","resolveRunStepConfig","resolveStepConfig","params","context","evaluationContext","effective","buildStepConfig","mode","authoredConfig","hasTemplates","config","name","resolveStepName","step","definitionId","configPlan","value","undefined","diagnostics","trace","gate","gateConfigForStep","outputs","outputsConfigForStep","workingDirectory","resolveWorkingDirectoryConfig","runStep","runStepOrNull","isRunStep","run","mergeConfigPlans","checkoutStep","checkoutStepOrNull","checkout","resolveCheckoutStepConfig","agentStep","agentStepOrNull","Error","kind","agent","template","templates","working_directory","resolved","field","segments","errorField","map","entry","diagnostic","primary","secondary","site","values","isAgentStep","isCheckoutStep","fetch_depth","fetchDepth","permissions","persist_credentials","persistCredentials","force","checkoutConfig","checkoutPlan","key","push","Object","keys","length","hasGate","stepGateConfig","hasOutputs","hasName","hasNameTemplate","hasSuccess","success","hasOnFailure","onFailure","hasOnFailureFeedback","feedback","hasOnFailureFeedbackTemplate","feedbackTemplate","language","check","source","on_failure","restart_from","restartFrom","feedback_template"],"mappings":"AACA,SAAQA,qCAAqC,QAAO,+BAA+B;AACnF,SAEEC,eAAe,QAGV,sBAAsB;AAO7B,SAAQC,sBAAsB,QAAO,aAAa;AAClD,SACEC,eAAe,EACfC,gBAAgB,QAIX,cAAc;AACrB,SAAQC,oBAAoB,QAA4B,WAAW;AA6DnE,OAAO,eAAeC,kBACpBC,MAA+B;IAE/B,MAAMC,UAAUC,kBAAkBF;IAClC,MAAMG,YAAY,MAAMC,gBAAgB;QAAC,GAAGJ,MAAM;QAAEC;QAASI,MAAM;IAAW;IAC9E,MAAMC,iBAAiBH,UAAUI,YAAY,GACzC,AAAC,CAAA,MAAMH,gBAAgB;QAAC,GAAGJ,MAAM;QAAEC;QAASI,MAAM;IAAU,EAAC,EAAGG,MAAM,GACtE;IACJ,MAAMC,OAAOC,gBAAgBV,OAAOW,IAAI,EAAEV,SAASD,OAAOY,YAAY;IAEtE,OAAO;QACLJ,QAAQL,UAAUK,MAAM;QACxBK,YAAYV,UAAUU,UAAU;QAChCP;QACA,GAAIG,KAAKK,KAAK,KAAKC,aAAaN,KAAKK,KAAK,KAAK,KAAK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