@sapiom/agent-core 0.6.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +246 -0
  2. package/LICENSE +21 -0
  3. package/dist/cjs/__tests__/execution-detail.wire.fixture.json +101 -0
  4. package/dist/cjs/__tests__/execution-projection.preseam.fixture.json +37 -0
  5. package/dist/cjs/__tests__/execution-projection.with-cost.fixture.json +60 -0
  6. package/dist/cjs/bundle.d.ts +5 -0
  7. package/dist/cjs/bundle.js +134 -0
  8. package/dist/cjs/check.d.ts +10 -0
  9. package/dist/cjs/check.js +154 -0
  10. package/dist/cjs/client.d.ts +21 -0
  11. package/dist/cjs/client.js +108 -0
  12. package/dist/cjs/clone.d.ts +17 -0
  13. package/dist/cjs/clone.js +71 -0
  14. package/dist/cjs/config.d.ts +16 -0
  15. package/dist/cjs/config.js +40 -0
  16. package/dist/cjs/decode.d.ts +4 -0
  17. package/dist/cjs/decode.js +172 -0
  18. package/dist/cjs/deploy.d.ts +12 -0
  19. package/dist/cjs/deploy.js +67 -0
  20. package/dist/cjs/errors.d.ts +15 -0
  21. package/dist/cjs/errors.js +23 -0
  22. package/dist/cjs/git.d.ts +12 -0
  23. package/dist/cjs/git.js +76 -0
  24. package/dist/cjs/index.d.ts +41 -0
  25. package/dist/cjs/index.js +72 -0
  26. package/dist/cjs/inspect.d.ts +40 -0
  27. package/dist/cjs/inspect.js +99 -0
  28. package/dist/cjs/link.d.ts +15 -0
  29. package/dist/cjs/link.js +19 -0
  30. package/dist/cjs/local/dispatcher.d.ts +37 -0
  31. package/dist/cjs/local/dispatcher.js +149 -0
  32. package/dist/cjs/local/load.d.ts +6 -0
  33. package/dist/cjs/local/load.js +102 -0
  34. package/dist/cjs/local/run-local.d.ts +32 -0
  35. package/dist/cjs/local/run-local.js +95 -0
  36. package/dist/cjs/local/stubs.d.ts +8 -0
  37. package/dist/cjs/local/stubs.js +35 -0
  38. package/dist/cjs/run.d.ts +11 -0
  39. package/dist/cjs/run.js +29 -0
  40. package/dist/cjs/scaffold.d.ts +24 -0
  41. package/dist/cjs/scaffold.js +190 -0
  42. package/dist/cjs/schedule.d.ts +67 -0
  43. package/dist/cjs/schedule.js +33 -0
  44. package/dist/cjs/signal.d.ts +12 -0
  45. package/dist/cjs/signal.js +24 -0
  46. package/dist/cjs/types.d.ts +99 -0
  47. package/dist/cjs/types.js +11 -0
  48. package/dist/cjs/watch.d.ts +10 -0
  49. package/dist/cjs/watch.js +101 -0
  50. package/dist/esm/__tests__/execution-detail.wire.fixture.json +101 -0
  51. package/dist/esm/__tests__/execution-projection.preseam.fixture.json +37 -0
  52. package/dist/esm/__tests__/execution-projection.with-cost.fixture.json +60 -0
  53. package/dist/esm/bundle.d.ts +5 -0
  54. package/dist/esm/bundle.js +95 -0
  55. package/dist/esm/check.d.ts +10 -0
  56. package/dist/esm/check.js +115 -0
  57. package/dist/esm/client.d.ts +21 -0
  58. package/dist/esm/client.js +103 -0
  59. package/dist/esm/clone.d.ts +17 -0
  60. package/dist/esm/clone.js +65 -0
  61. package/dist/esm/config.d.ts +16 -0
  62. package/dist/esm/config.js +31 -0
  63. package/dist/esm/decode.d.ts +4 -0
  64. package/dist/esm/decode.js +167 -0
  65. package/dist/esm/deploy.d.ts +12 -0
  66. package/dist/esm/deploy.js +61 -0
  67. package/dist/esm/errors.d.ts +15 -0
  68. package/dist/esm/errors.js +19 -0
  69. package/dist/esm/git.d.ts +12 -0
  70. package/dist/esm/git.js +69 -0
  71. package/dist/esm/index.d.ts +41 -0
  72. package/dist/esm/index.js +21 -0
  73. package/dist/esm/inspect.d.ts +40 -0
  74. package/dist/esm/inspect.js +92 -0
  75. package/dist/esm/link.d.ts +15 -0
  76. package/dist/esm/link.js +16 -0
  77. package/dist/esm/local/dispatcher.d.ts +37 -0
  78. package/dist/esm/local/dispatcher.js +145 -0
  79. package/dist/esm/local/load.d.ts +6 -0
  80. package/dist/esm/local/load.js +63 -0
  81. package/dist/esm/local/run-local.d.ts +32 -0
  82. package/dist/esm/local/run-local.js +87 -0
  83. package/dist/esm/local/stubs.d.ts +8 -0
  84. package/dist/esm/local/stubs.js +31 -0
  85. package/dist/esm/package.json +1 -0
  86. package/dist/esm/run.d.ts +11 -0
  87. package/dist/esm/run.js +25 -0
  88. package/dist/esm/scaffold.d.ts +24 -0
  89. package/dist/esm/scaffold.js +179 -0
  90. package/dist/esm/schedule.d.ts +67 -0
  91. package/dist/esm/schedule.js +26 -0
  92. package/dist/esm/signal.d.ts +12 -0
  93. package/dist/esm/signal.js +20 -0
  94. package/dist/esm/types.d.ts +99 -0
  95. package/dist/esm/types.js +8 -0
  96. package/dist/esm/watch.d.ts +10 -0
  97. package/dist/esm/watch.js +96 -0
  98. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  99. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  100. package/package.json +73 -0
  101. package/templates/coding-pause/AGENTS.md +48 -0
  102. package/templates/coding-pause/CLAUDE.md +7 -0
  103. package/templates/coding-pause/README.md +53 -0
  104. package/templates/coding-pause/_gitignore +3 -0
  105. package/templates/coding-pause/index.ts +109 -0
  106. package/templates/coding-pause/package.json +21 -0
  107. package/templates/coding-pause/tsconfig.json +12 -0
  108. package/templates/default/AGENTS.md +48 -0
  109. package/templates/default/CLAUDE.md +7 -0
  110. package/templates/default/README.md +30 -0
  111. package/templates/default/_gitignore +3 -0
  112. package/templates/default/index.ts +26 -0
  113. package/templates/default/package.json +21 -0
  114. package/templates/default/tsconfig.json +12 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,246 @@
1
+ # @sapiom/orchestration-core
2
+
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cc1261e: Rename the composition SDK to **agents** and the coding/LLM capability to **models**.
8
+
9
+ **Breaking — the package names changed. Install the new names; the old ones are deprecated.**
10
+
11
+ - Packages: `@sapiom/orchestration` → `@sapiom/agent`, `@sapiom/orchestration-core` → `@sapiom/agent-core`, `@sapiom/orchestration-runtime` → `@sapiom/agent-runtime`. (`@sapiom/create-orchestration` is retired — scaffold with the CLI or the developer MCP.)
12
+ - API: `defineOrchestration` → `defineAgent`; `Orchestration*` types/errors → `Agent*`.
13
+ - `@sapiom/tools`: the `agent` capability namespace is now `models` (e.g. `sapiom.models.coding`); the `orchestrations` namespace is now `agents`.
14
+ - CLI: `sapiom orchestrations …` → `sapiom agents …`.
15
+ - Developer MCP tools: `sapiom_dev_orchestrations_*` → `sapiom_dev_agents_*`.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [cc1261e]
20
+ - @sapiom/agent@0.5.0
21
+ - @sapiom/agent-runtime@0.3.0
22
+ - @sapiom/tools@0.16.0
23
+
24
+ ## 0.5.0
25
+
26
+ ### Minor Changes
27
+
28
+ - f2f4fec: Bring `inspect()` / `listExecutions()` to REST `ExecutionProjection` parity (tree + per-node cost + trace refs), replacing the flat inspection shape.
29
+
30
+ **Breaking (return shapes):**
31
+
32
+ - `inspect(opts, client)` now resolves the decoded `ExecutionProjection` **directly** (previously `{ execution }`). It carries the dispatch tree (`traceRoot`/`traceParent`/`traceId`/`spanId`, `parentExecutionId`/`rootExecutionId`, typed `children`), per-step `spanId`/`events`/`dispatch`, and a structured `StepError` (`trace` is now a `StepErrorTrace` of source-mapped frames, not a string).
33
+ - `listExecutions(client)` now resolves `ExecutionRef[]` **directly** (previously `{ executions }`).
34
+ - The flat `ExecutionDetail` / `StepRecord` types are removed; import the new projection types (`ExecutionProjection`, `StepProjection`, `CostNode`, `ExecutionRef`, `DispatchRef`, `StepError`, `StepEvent`) instead.
35
+
36
+ **Cost is honest, never fabricated:** `cost` is `CostNode | null` at run and step granularity. The execution-detail read is cost-agnostic today (authoritative cost lives at `/executions/:id/spend`), so an absent cost decodes to `null`, not a misleading `$0`. `authorizedUsd`/`capturedUsd`/`settleState` are never collapsed when cost is present.
37
+
38
+ The engine must emit the corresponding fields (per-node cost, list lineage, named child edges) for the projection to be fully populated; until then `inspect()`/`listExecutions()` degrade honestly rather than throwing. SDK pins move in lockstep with the engine.
39
+
40
+ ## 0.4.5
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies [8fd3f71]
45
+ - @sapiom/tools@0.15.0
46
+ - @sapiom/orchestration@0.4.9
47
+
48
+ ## 0.4.4
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [aaf633c]
53
+ - @sapiom/tools@0.14.0
54
+ - @sapiom/orchestration@0.4.8
55
+
56
+ ## 0.4.3
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [cc2bde2]
61
+ - @sapiom/tools@0.13.0
62
+ - @sapiom/orchestration@0.4.7
63
+
64
+ ## 0.4.2
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [019ef30]
69
+ - @sapiom/tools@0.12.0
70
+ - @sapiom/orchestration@0.4.6
71
+
72
+ ## 0.4.1
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies [84e44e2]
77
+ - @sapiom/tools@0.11.0
78
+ - @sapiom/orchestration@0.4.5
79
+
80
+ ## 0.4.0
81
+
82
+ ### Minor Changes
83
+
84
+ - ae1df3c: Scaffold honors `npm_config_registry` / `@scope:registry` when resolving the
85
+ `@sapiom/*` versions to pin
86
+
87
+ Version resolution previously hardcoded the public npm registry, so a scaffold
88
+ always pinned public-npm `latest` even when the environment pointed at a
89
+ different registry. It now resolves `latest` from the same registry a plain
90
+ `npm install` would (a scoped `@<scope>:registry` wins over the global
91
+ `npm_config_registry`, which wins over the public default). When that registry
92
+ is non-default, the scaffolded project also gets a matching `.npmrc` so its
93
+ pinned versions are installable. This makes a local registry dev loop work
94
+ end-to-end with no manual pin edits; default scaffolds are unchanged.
95
+
96
+ ### Patch Changes
97
+
98
+ - a85e665: Add schedules: run a deployed orchestration on a recurring cron schedule or once at a set time.
99
+
100
+ - `@sapiom/orchestration-core`: `createSchedule`, `listSchedules`, `getSchedule`, `cancelSchedule`, and `previewCron`.
101
+ - `@sapiom/tools`: a `schedules` namespace (`create`, `list`, `get`, `cancel`).
102
+ - `@sapiom/cli`: `sapiom orchestrations schedule create | list | inspect | cancel | preview`.
103
+ - `@sapiom/mcp`: schedule tools — create, inspect (list/detail + recent fires), cancel, and cron preview.
104
+
105
+ - Updated dependencies [a85e665]
106
+ - @sapiom/tools@0.10.1
107
+
108
+ ## 0.3.8
109
+
110
+ ### Patch Changes
111
+
112
+ - Updated dependencies [6ebf569]
113
+ - @sapiom/tools@0.10.0
114
+ - @sapiom/orchestration@0.4.4
115
+
116
+ ## 0.3.7
117
+
118
+ ### Patch Changes
119
+
120
+ - 30bac1c: Improve the initial git + deploy experience for workflow authoring. Adds `bundleForDeploy` — a local, no-network bundler that inlines local/shared source and externalizes npm dependencies — and smooths first-time git init / deploy so a fresh workflow project deploys cleanly.
121
+
122
+ ```ts
123
+ import { bundleForDeploy } from "@sapiom/orchestration-core";
124
+
125
+ const bundle = await bundleForDeploy(/* … */);
126
+ ```
127
+
128
+ - Updated dependencies [30bac1c]
129
+ - Updated dependencies [30bac1c]
130
+ - Updated dependencies [0361fa7]
131
+ - @sapiom/tools@0.9.0
132
+ - @sapiom/orchestration@0.4.3
133
+
134
+ ## 0.3.6
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies [2b94dff]
139
+ - Updated dependencies [ac71754]
140
+ - Updated dependencies [f078ed5]
141
+ - @sapiom/tools@0.8.0
142
+ - @sapiom/orchestration@0.4.2
143
+
144
+ ## 0.3.5
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies [a3cc368]
149
+ - @sapiom/tools@0.7.0
150
+ - @sapiom/orchestration@0.4.1
151
+
152
+ ## 0.3.4
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies [56fd77d]
157
+ - @sapiom/orchestration@0.4.0
158
+ - @sapiom/orchestration-runtime@0.2.2
159
+
160
+ ## 0.3.3
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [f41ab95]
165
+ - @sapiom/orchestration@0.3.0
166
+ - @sapiom/orchestration-runtime@0.2.1
167
+
168
+ ## 0.3.2
169
+
170
+ ### Patch Changes
171
+
172
+ - b2c5612: Move the orchestration authoring SDK onto zod 4 via the bare `zod` import (no
173
+ more `zod/v4` subpath), so installing is just:
174
+
175
+ ```sh
176
+ npm install @sapiom/orchestration
177
+ ```
178
+
179
+ `zod` is now a regular dependency rather than a peer. Author your step schemas
180
+ with your own `import { z } from "zod"` as usual; a compatibility re-export
181
+ (`import { z } from "@sapiom/orchestration"`) is available for projects pinned
182
+ to an incompatible zod. Scaffolded projects now pin zod 4.
183
+
184
+ - Updated dependencies [b2c5612]
185
+ - Updated dependencies [b2c5612]
186
+ - @sapiom/orchestration@0.2.0
187
+ - @sapiom/orchestration-runtime@0.2.0
188
+ - @sapiom/tools@0.6.0
189
+
190
+ ## 0.3.1
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies [5c974b1]
195
+ - @sapiom/tools@0.5.0
196
+ - @sapiom/orchestration@0.1.9
197
+
198
+ ## 0.3.0
199
+
200
+ ### Minor Changes
201
+
202
+ - e17b2d1: `scaffold` now initializes a git repository with an initial commit, so a freshly scaffolded project is immediately deployable (deploy requires a repo with at least one commit). Best-effort: if `git` is unavailable the project is left uninitialized. `ScaffoldResult` gains `gitInitialized`.
203
+
204
+ Adds `waitForExecution` (and `isExecutionTerminal`) to poll an execution until it reaches a terminal state, settles on a pause that needs a signal, or a wait budget elapses — so callers don't hand-roll a poll loop. The `sapiom_dev_orchestrations_inspect` MCP tool gains opt-in `wait` / `maxWaitSeconds` options that use it and return `done` / `waiting` / `hint`; a non-blocking inspect of a still-running execution now also hints to use `wait`.
205
+
206
+ Fixes `sapiom_dev_orchestrations_link`: omitting `name` no longer sends an empty name (which the gateway rejected). It now defaults to the orchestration's name read from `index.ts` (matching `defineOrchestration({ name })`), and returns a clear error if no name is available.
207
+
208
+ ### Patch Changes
209
+
210
+ - e17b2d1: **BREAKING (`@sapiom/tools`):** align the coding-run resume payload with the shape a resumed step actually receives. `CodingResultPayload` now carries `executionEnvironment: { type, id } | null` instead of `sandbox: { name, workspaceRoot }`. Re-attach a resumed run's sandbox with `ctx.sapiom.sandboxes.attach(result.executionEnvironment.id)` (for a `blaxel_sandbox`).
211
+
212
+ Adds `codingResultSchema` (runtime validation of the resume payload), `toResumePayload`, `ExecutionEnvironmentRef`, and `EXECUTION_ENVIRONMENT_BLAXEL_SANDBOX`. The stub client now emits the same payload shape a resumed step receives, so a step written against the local loop runs identically once deployed.
213
+
214
+ The `coding-pause` template and its guidance are updated to the new shape.
215
+
216
+ - Updated dependencies [e17b2d1]
217
+ - @sapiom/tools@0.4.0
218
+ - @sapiom/orchestration@0.1.8
219
+
220
+ ## 0.2.0
221
+
222
+ ### Minor Changes
223
+
224
+ - 704c9ac: Make the local development loop (`run_local`) production-faithful and trustworthy for the dispatch/pause pattern (`agent.coding.launch` + `pauseUntilSignal`).
225
+
226
+ - Stub capability handles now survive JSON serialization, so a paused/resumed coding workflow runs end-to-end locally instead of failing with an opaque `'sandbox.toJSON' is not a method or field` error.
227
+ - The payload a paused step resumes with is delivered as plain JSON — the same shape production sends over the wire — so authors re-attach handles by name (`sandboxes.attach(...)`) locally exactly as they would in prod.
228
+ - `@sapiom/tools` exports `CodingResultPayload`: the shape a step resumed from `pauseUntilSignal(codingHandle, …)` receives, so resumed steps can be annotated instead of hand-rolling the type.
229
+ - Stubbing a handle-returning capability with plain JSON no longer strips the handle's instance methods (e.g. `repo.pushFromSandbox`), and `repositories.list` stubs are coerced and shape-checked.
230
+ - A dispatched `launch()` accepts the `agent.coding.launch` stub key as well as the shared `agent.coding.run` (ordered candidate resolution), so the stub key matching the call the author wrote takes effect.
231
+ - `run_local` now reports `unusedStubs` (a supplied key that matched no call) and `stubWarnings` (a key that matched but carried the wrong shape), surfacing stubs that silently didn't take effect; the MCP `run_local` also serializes its result defensively.
232
+ - New `coding-pause` scaffold template for the launch + pause + resume pattern, and AGENTS docs documenting the resume-input contract, list stub item shape, failure-branch stubbing, and step determinism under replay.
233
+
234
+ ### Patch Changes
235
+
236
+ - Updated dependencies [704c9ac]
237
+ - @sapiom/tools@0.3.0
238
+ - @sapiom/orchestration@0.1.7
239
+
240
+ ## 0.1.1
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [7f6859e]
245
+ - @sapiom/tools@0.2.0
246
+ - @sapiom/orchestration@0.1.6
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Sapiom
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,101 @@
1
+ {
2
+ "id": "exec_0001",
3
+ "name": "daily-digest",
4
+ "organizationId": "org_0001",
5
+ "tenantId": "tenant_0001",
6
+ "status": "failed",
7
+ "currentStep": "render",
8
+ "currentStepAttempt": 2,
9
+ "version": 3,
10
+ "definitionId": "def_0001",
11
+ "buildRunId": "build_0001",
12
+ "idempotencyKey": null,
13
+ "pausedSignalName": null,
14
+ "pausedSignalCorrelationId": null,
15
+ "pausedUntil": null,
16
+ "startedAt": "2026-01-01T00:00:00.000Z",
17
+ "finishedAt": "2026-01-01T00:02:30.000Z",
18
+ "input": { "topic": "weekly-summary" },
19
+ "sharedState": { "count": 2 },
20
+ "output": null,
21
+ "error": null,
22
+ "pausedStepInputSchema": null,
23
+ "pausedStepInputExample": null,
24
+ "repoFullName": "example-org/example-workflows",
25
+ "pinnedCommitSha": "0000000000000000000000000000000000000000",
26
+ "traceId": "trace_0001",
27
+ "traceRoot": "exec_0001",
28
+ "rootExecutionId": "exec_0001",
29
+ "traceParent": null,
30
+ "parentExecutionId": null,
31
+ "children": [
32
+ {
33
+ "executionId": "exec_0002",
34
+ "targetType": "agent",
35
+ "correlationId": "exec_0002",
36
+ "status": "resolved"
37
+ }
38
+ ],
39
+ "steps": [
40
+ {
41
+ "id": "step_0001",
42
+ "stepName": "gather",
43
+ "stepOrder": 0,
44
+ "attempt": 1,
45
+ "status": "completed",
46
+ "input": { "topic": "weekly-summary" },
47
+ "output": { "items": 12 },
48
+ "error": null,
49
+ "nextDirective": { "kind": "continue" },
50
+ "sharedStateAfter": { "count": 1 },
51
+ "logs": [{ "ts": "2026-01-01T00:00:05.000Z", "level": "info", "msg": "fetched 12 items" }],
52
+ "events": [
53
+ {
54
+ "sourceId": "run_0001",
55
+ "sequence": 1,
56
+ "kind": "tool_use",
57
+ "payload": { "tool": "web.search" },
58
+ "eventTs": "2026-01-01T00:00:10.000Z"
59
+ }
60
+ ],
61
+ "spanId": "span_0001",
62
+ "dispatch": null,
63
+ "startedAt": "2026-01-01T00:00:00.000Z",
64
+ "finishedAt": "2026-01-01T00:00:45.000Z"
65
+ },
66
+ {
67
+ "id": "step_0002",
68
+ "stepName": "render",
69
+ "stepOrder": 1,
70
+ "attempt": 2,
71
+ "status": "failed",
72
+ "input": { "items": 12 },
73
+ "output": null,
74
+ "error": {
75
+ "message": "template not found",
76
+ "trace": {
77
+ "frames": [
78
+ { "function": "render", "file": "src/steps/render.ts", "line": 12, "column": 11 },
79
+ { "function": "run", "file": "src/engine/runner.ts", "line": 88, "column": 5 }
80
+ ],
81
+ "sourceMapped": true,
82
+ "raw": "Error: template not found\n at render (dist/steps/render.mjs:8:9)"
83
+ },
84
+ "traceUnavailableReason": null
85
+ },
86
+ "nextDirective": null,
87
+ "sharedStateAfter": { "count": 2 },
88
+ "logs": null,
89
+ "events": [],
90
+ "spanId": "span_0002",
91
+ "dispatch": {
92
+ "targetId": "exec_0002",
93
+ "targetType": "agent",
94
+ "correlationId": "exec_0002",
95
+ "status": "resolved"
96
+ },
97
+ "startedAt": "2026-01-01T00:00:45.000Z",
98
+ "finishedAt": "2026-01-01T00:02:30.000Z"
99
+ }
100
+ ]
101
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "id": "exec_legacy_0001",
3
+ "name": "old-run",
4
+ "organizationId": "org_0001",
5
+ "tenantId": "tenant_0001",
6
+ "status": "completed",
7
+ "currentStep": null,
8
+ "currentStepAttempt": 1,
9
+ "version": 1,
10
+ "definitionId": null,
11
+ "buildRunId": null,
12
+ "idempotencyKey": null,
13
+ "pausedSignalName": null,
14
+ "pausedSignalCorrelationId": null,
15
+ "pausedUntil": null,
16
+ "startedAt": "2025-06-01T00:00:00.000Z",
17
+ "finishedAt": "2025-06-01T00:00:20.000Z",
18
+ "input": {},
19
+ "sharedState": {},
20
+ "output": { "ok": true },
21
+ "error": null,
22
+ "steps": [
23
+ {
24
+ "stepName": "run",
25
+ "stepOrder": 0,
26
+ "attempt": 1,
27
+ "status": "completed",
28
+ "input": {},
29
+ "output": { "ok": true },
30
+ "error": null,
31
+ "nextDirective": { "kind": "complete" },
32
+ "sharedStateAfter": {},
33
+ "startedAt": "2025-06-01T00:00:00.000Z",
34
+ "finishedAt": "2025-06-01T00:00:20.000Z"
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "id": "exec_0001",
3
+ "name": "daily-digest",
4
+ "organizationId": "org_0001",
5
+ "tenantId": "tenant_0001",
6
+ "status": "completed",
7
+ "currentStep": null,
8
+ "currentStepAttempt": 1,
9
+ "version": 3,
10
+ "definitionId": "def_0001",
11
+ "buildRunId": "build_0001",
12
+ "idempotencyKey": null,
13
+ "pausedSignalName": null,
14
+ "pausedSignalCorrelationId": null,
15
+ "pausedUntil": null,
16
+ "startedAt": "2026-01-01T00:00:00.000Z",
17
+ "finishedAt": "2026-01-01T00:02:30.000Z",
18
+ "input": { "topic": "weekly-summary" },
19
+ "sharedState": { "count": 2 },
20
+ "output": { "url": "https://example.com/report/exec_0001" },
21
+ "error": null,
22
+ "pausedStepInputSchema": null,
23
+ "pausedStepInputExample": null,
24
+ "traceId": "trace_0001",
25
+ "traceRoot": "exec_0001",
26
+ "rootExecutionId": "exec_0001",
27
+ "traceParent": null,
28
+ "parentExecutionId": null,
29
+ "children": [],
30
+ "cost": {
31
+ "authorizedUsd": "1.50",
32
+ "capturedUsd": "1.20",
33
+ "settleState": "settling"
34
+ },
35
+ "steps": [
36
+ {
37
+ "id": "step_0001",
38
+ "stepName": "gather",
39
+ "stepOrder": 0,
40
+ "attempt": 1,
41
+ "status": "completed",
42
+ "input": { "topic": "weekly-summary" },
43
+ "output": { "items": 12 },
44
+ "error": null,
45
+ "nextDirective": { "kind": "continue" },
46
+ "sharedStateAfter": { "count": 1 },
47
+ "logs": null,
48
+ "events": [],
49
+ "spanId": "span_0001",
50
+ "dispatch": null,
51
+ "cost": {
52
+ "authorizedUsd": "0.50",
53
+ "capturedUsd": "0.50",
54
+ "settleState": "final"
55
+ },
56
+ "startedAt": "2026-01-01T00:00:00.000Z",
57
+ "finishedAt": "2026-01-01T00:00:45.000Z"
58
+ }
59
+ ]
60
+ }
@@ -0,0 +1,5 @@
1
+ export interface DeployBundle {
2
+ code: string;
3
+ dependencies: Record<string, string>;
4
+ }
5
+ export declare function bundleForDeploy(sourceDir: string): Promise<DeployBundle>;
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.bundleForDeploy = bundleForDeploy;
40
+ const node_fs_1 = require("node:fs");
41
+ const node_module_1 = require("node:module");
42
+ const node_os_1 = require("node:os");
43
+ const node_path_1 = __importDefault(require("node:path"));
44
+ const esbuild = __importStar(require("esbuild"));
45
+ const errors_js_1 = require("./errors.js");
46
+ async function bundleForDeploy(sourceDir) {
47
+ const entryFile = node_path_1.default.join(sourceDir, 'index.ts');
48
+ if (!(0, node_fs_1.existsSync)(entryFile)) {
49
+ throw new errors_js_1.AgentOperationError({
50
+ code: 'NO_ENTRY',
51
+ message: `No index.ts found in ${sourceDir}.`,
52
+ hint: 'Run this from an agent project, or pass its directory.',
53
+ });
54
+ }
55
+ const tmp = (0, node_fs_1.mkdtempSync)(node_path_1.default.join((0, node_os_1.tmpdir)(), 'sapiom-deploy-bundle-'));
56
+ const outfile = node_path_1.default.join(tmp, 'index.js');
57
+ try {
58
+ let result;
59
+ try {
60
+ result = await esbuild.build({
61
+ entryPoints: [entryFile],
62
+ outfile,
63
+ bundle: true,
64
+ platform: 'node',
65
+ target: 'node20',
66
+ format: 'esm',
67
+ packages: 'external',
68
+ metafile: true,
69
+ logLevel: 'silent',
70
+ });
71
+ }
72
+ catch (err) {
73
+ throw new errors_js_1.AgentOperationError({
74
+ code: 'BUNDLE_FAILED',
75
+ message: 'Failed to bundle the agent for deploy.',
76
+ hint: err instanceof Error ? err.message : String(err),
77
+ });
78
+ }
79
+ const code = (0, node_fs_1.readFileSync)(outfile, 'utf8');
80
+ const externals = collectExternalPackages(result.metafile, outfile);
81
+ const dependencies = resolveInstalledVersions(sourceDir, externals);
82
+ return { code, dependencies };
83
+ }
84
+ finally {
85
+ (0, node_fs_1.rmSync)(tmp, { recursive: true, force: true });
86
+ }
87
+ }
88
+ function collectExternalPackages(metafile, outfile) {
89
+ const key = Object.keys(metafile.outputs).find((k) => node_path_1.default.resolve(k) === node_path_1.default.resolve(outfile));
90
+ const imports = key ? metafile.outputs[key].imports : [];
91
+ const names = new Set();
92
+ for (const imp of imports) {
93
+ if (!imp.external)
94
+ continue;
95
+ const name = packageNameOf(imp.path);
96
+ if (name && !(0, node_module_1.isBuiltin)(name))
97
+ names.add(name);
98
+ }
99
+ return [...names].sort();
100
+ }
101
+ function packageNameOf(importPath) {
102
+ if (importPath.startsWith('node:'))
103
+ return null;
104
+ const parts = importPath.split('/');
105
+ if (importPath.startsWith('@'))
106
+ return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : null;
107
+ return parts[0] || null;
108
+ }
109
+ function resolveInstalledVersions(sourceDir, packages) {
110
+ const deps = {};
111
+ for (const pkg of packages) {
112
+ deps[pkg] = readInstalledVersion(sourceDir, pkg) ?? 'latest';
113
+ }
114
+ return deps;
115
+ }
116
+ function readInstalledVersion(fromDir, pkg) {
117
+ let dir = node_path_1.default.resolve(fromDir);
118
+ while (true) {
119
+ const pkgJson = node_path_1.default.join(dir, 'node_modules', ...pkg.split('/'), 'package.json');
120
+ if ((0, node_fs_1.existsSync)(pkgJson)) {
121
+ try {
122
+ const version = JSON.parse((0, node_fs_1.readFileSync)(pkgJson, 'utf8')).version;
123
+ if (version)
124
+ return version;
125
+ }
126
+ catch {
127
+ }
128
+ }
129
+ const parent = node_path_1.default.dirname(dir);
130
+ if (parent === dir)
131
+ return null;
132
+ dir = parent;
133
+ }
134
+ }
@@ -0,0 +1,10 @@
1
+ export interface CheckOptions {
2
+ sourceDir: string;
3
+ }
4
+ export interface CheckResult {
5
+ name: string;
6
+ stepCount: number;
7
+ warnings: string[];
8
+ manifest: unknown;
9
+ }
10
+ export declare function check(opts: CheckOptions): Promise<CheckResult>;