@sapiom/tools 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sapiom/tools
2
2
 
3
+ ## 0.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d45ec6: Document the `orchestrations` capability: add it to the README's Capabilities table + intro, and add a per-capability `src/orchestrations/README.md` (run a deployed orchestration, or dispatch one from a step and pause on its result).
8
+
3
9
  ## 0.6.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @sapiom/tools
2
2
 
3
- A typed TypeScript client for Sapiom capabilities — sandboxes, git repositories, coding agents, file storage, and content generation — authenticated to your tenant.
3
+ A typed TypeScript client for Sapiom capabilities — sandboxes, git repositories, coding agents, file storage, content generation, and orchestrations — authenticated to your tenant.
4
4
 
5
5
  These are the same capabilities your Sapiom agents call as tools; this package makes them callable directly from your own code.
6
6
 
@@ -72,6 +72,7 @@ Each capability is a namespace, importable from the barrel or its own subpath (e
72
72
  | `agent` | Coding agents (LLM execution) | [src/agent](./src/agent/README.md) |
73
73
  | `fileStorage` | Tenant-scoped object storage (presigned URLs) | [src/file-storage](./src/file-storage/README.md) |
74
74
  | `contentGeneration` | Media generation (images; video/audio soon), with optional `storage` | [src/content-generation](./src/content-generation/README.md) |
75
+ | `orchestrations` | Run a deployed orchestration, or dispatch one from a step and await its result | [src/orchestrations](./src/orchestrations/README.md) |
75
76
 
76
77
  ## Composing capabilities
77
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapiom/tools",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Typed client for Sapiom capabilities (sandboxes, repositories, agent, file storage, …) — the same tools your agents call over MCP, callable from your code, auth'd to your tenant.",
5
5
  "license": "MIT",
6
6
  "author": "Sapiom",
@@ -0,0 +1,50 @@
1
+ # orchestrations
2
+
3
+ Run a deployed orchestration and await its result — or, from inside a step, dispatch one and pause until it finishes. An orchestration is addressed by its **slug** (its stable handle).
4
+
5
+ ```ts
6
+ import { orchestrations } from "@sapiom/tools";
7
+
8
+ // Standalone: run a deployed orchestration and wait for its result.
9
+ const result = await orchestrations.run({ definition: "enrich-lead", input: { id } });
10
+ if (result.status === "completed") {
11
+ // result.output
12
+ }
13
+ ```
14
+
15
+ From inside a step, dispatch another orchestration and suspend until it finishes — the step you name in `resumeStep` receives the typed result as its input:
16
+
17
+ ```ts
18
+ import { orchestrations } from "@sapiom/tools";
19
+ import { defineStep, pauseUntilSignal } from "@sapiom/orchestration";
20
+
21
+ const enrich = defineStep({
22
+ name: "enrich",
23
+ pause: { signal: orchestrations.ORCHESTRATIONS_RESULT_SIGNAL, resumeStep: "use-result" },
24
+ async run(input, ctx) {
25
+ const child = await orchestrations.launch({ definition: "enrich-lead", input });
26
+ return pauseUntilSignal(child, { resumeStep: "use-result" });
27
+ },
28
+ });
29
+
30
+ const useResult = defineStep({
31
+ name: "use-result",
32
+ terminal: true,
33
+ async run(result: orchestrations.OrchestrationRunResultPayload, ctx) {
34
+ if (result.status === "failed") {
35
+ // result.error — failure is data you branch on, not a thrown exception
36
+ }
37
+ // result.output (when completed)
38
+ },
39
+ });
40
+ ```
41
+
42
+ ## Things to know
43
+
44
+ - **`run` blocks; `launch` returns a pausable handle.** `run` polls until the run reaches a terminal state and returns its result — use it for standalone, inline calls. `launch` returns immediately with a handle you hand to `pauseUntilSignal(handle, { resumeStep })` to suspend the step until the run finishes. Don't use `run` to pause a step — it returns a result, not a handle.
45
+
46
+ - **Failure is data, not an exception.** The result is discriminated on `status` (`"completed" | "failed"`). A failed run resumes your step with `status: "failed"` and an `error` to branch on — it does not throw. Validate an incoming payload with `orchestrations.orchestrationResultSchema.parse(value)` if you want a runtime check.
47
+
48
+ - **Addressed by slug.** `definition` is the deployed orchestration's slug — its stable handle. `input` is passed to its entry step.
49
+
50
+ - **`idempotencyKey` deduplicates.** Repeating a launch with the same key returns the existing run instead of starting a new one.