@sapiom/orchestration-core 0.1.1 → 0.3.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.
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "typecheck": "tsc --noEmit",
8
+ "format": "prettier --write \"**/*.ts\"",
9
+ "format:check": "prettier --check \"**/*.ts\""
10
+ },
11
+ "dependencies": {
12
+ "@sapiom/orchestration": "__ORCHESTRATION_VERSION__",
13
+ "@sapiom/tools": "__TOOLS_VERSION__",
14
+ "zod": "__ZOD_VERSION__"
15
+ },
16
+ "devDependencies": {
17
+ "@types/node": "^20.11.30",
18
+ "prettier": "^3.2.5",
19
+ "typescript": "^5.4.2"
20
+ }
21
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "esnext",
4
+ "moduleResolution": "bundler",
5
+ "target": "es2022",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "types": ["node"],
9
+ "noEmit": true
10
+ },
11
+ "include": ["**/*.ts"]
12
+ }
@@ -23,7 +23,26 @@ When you've made a coherent change and want to validate it — the same point yo
23
23
  `run_local` works with **no stubs** — capabilities return sensible defaults. Add an override only when a step's logic branches on a specific result (e.g. "if `repositories.list()` already contains my repo, skip create"). Put overrides in `.sapiom-dev/stubs.json` (committed and human-reviewable); `run_local` reads it automatically. Shape:
24
24
 
25
25
  ```jsonc
26
- { "version": 1, "steps": { "<stepName>": { "<capability.path>": <response> | [<response>, ...] } } }
26
+ { "version": 1, "steps": { "<stepName>": { "<capability.path>": <response> } } }
27
27
  ```
28
28
 
29
- Capability paths are namespace methods (`repositories.list`, `agent.coding.run`) or handle methods (`repository.pushFromSandbox`, `sandbox.exec`). A single value answers every call; an array is consumed one element per call.
29
+ - Capability paths are namespace methods (`repositories.list`, `repositories.create`, `agent.coding.run`) or handle methods, which use the **singular** handle type (`repository.pushFromSandbox`, `sandbox.exec`) not the plural namespace.
30
+ - `<response>` is returned **verbatim** — it is the value that call would return, so match its real shape. `repositories.list` takes the array `list()` returns: `[{ "slug": "...", "cloneUrl": "..." }]` (each element a repository — *not* `[[ … ]]`). `repositories.create`/`get`/`attach` take a single `{ "slug", "cloneUrl" }`.
31
+ - `run_local` reports **`unusedStubs`** (a key that matched no call — usually a typo or the plural/singular mistake) and **`stubWarnings`** (a key matched but the value was the wrong shape). A green run with either non-empty means a stub silently didn't take effect — check them.
32
+
33
+ ## Dispatched runs: pause & resume
34
+
35
+ A long-running capability (today the coding agent) is launched fire-and-forget and the workflow suspends until it finishes:
36
+
37
+ ```ts
38
+ const run = await ctx.sapiom.agent.coding.launch({ task, gitRepository: repo }); // returns a handle, not a result
39
+ return pauseUntilSignal(run, { resumeStep: "finalize" }); // suspend on the run's result signal
40
+ ```
41
+
42
+ - **The resumed step's `input` IS the run's result signal payload.** Annotate it with `CodingResultPayload` (from `@sapiom/tools`) — you don't have to hand-roll the shape.
43
+ - That payload crossed a wire boundary, so it carries **no live handles** — to act on the run's sandbox, re-attach one from **`executionEnvironment`** with `ctx.sapiom.sandboxes.attach(result.executionEnvironment.id)` (`executionEnvironment` is `null` when the run provisioned none, e.g. a launch failure). Anything else the resumed step needs, stash in `ctx.shared` before pausing.
44
+ - **To stub the resume payload** (e.g. to exercise the failure branch), override `agent.coding.run` *in the launching step* — that one value is both the `run()` result and the payload the paused step resumes with. `agent.coding.launch` is accepted there too.
45
+
46
+ ## Determinism
47
+
48
+ A step body runs **once** on the happy path; it re-runs only on retry (after a throw). Don't rely on a value being recomputed identically across a pause/resume — capture non-deterministic values (timestamps, ids) once and pass them forward via the `goto(...)` input or `ctx.shared`.