@agent-compose/sdk 0.2.4 → 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.
- package/README.md +31 -19
- package/dist/client.d.ts +83 -26
- package/dist/index.d.ts +3 -2
- package/dist/index.js +89 -18
- package/dist/runtimes/openai-desktop.js +89 -18
- package/dist/types/sandbox-environment.d.ts +23 -14
- package/dist/types/sandbox.d.ts +6 -1
- package/dist/types/workflow-metadata.d.ts +72 -8
- package/dist/types/workflow.d.ts +23 -19
- package/dist/utils/bundler.d.ts +12 -7
- package/dist/workflow-steps/workflow.d.ts +4 -2
- package/package.json +1 -1
- package/src/client.ts +124 -30
- package/src/index.ts +9 -1
- package/src/sandbox.ts +5 -1
- package/src/types/sandbox-environment.ts +25 -15
- package/src/types/sandbox.ts +6 -2
- package/src/types/workflow-metadata.ts +77 -12
- package/src/types/workflow.ts +23 -19
- package/src/utils/bundler.ts +87 -12
- package/src/workflow-steps/workflow.ts +4 -2
- package/src/workflows/invoke-child.ts +1 -1
|
@@ -481,14 +481,18 @@ function extractMetadata(source) {
|
|
|
481
481
|
out.networkPolicy = freezeMetadataValue(source.networkPolicy);
|
|
482
482
|
if (source.placeholders !== undefined)
|
|
483
483
|
out.placeholders = Object.freeze({ ...source.placeholders });
|
|
484
|
-
if (source.
|
|
485
|
-
out.
|
|
486
|
-
if (source.
|
|
487
|
-
out.
|
|
484
|
+
if (source.inputSchema !== undefined)
|
|
485
|
+
out.inputSchema = freezeMetadataValue(source.inputSchema);
|
|
486
|
+
if (source.outputSchema !== undefined)
|
|
487
|
+
out.outputSchema = freezeMetadataValue(source.outputSchema);
|
|
488
|
+
if (source.snapshots !== undefined)
|
|
489
|
+
out.snapshots = Object.freeze({ ...source.snapshots });
|
|
488
490
|
if (source.processors !== undefined)
|
|
489
491
|
out.processors = Object.freeze([...source.processors]);
|
|
490
492
|
if (source.memory !== undefined)
|
|
491
|
-
out.memory =
|
|
493
|
+
out.memory = source.memory;
|
|
494
|
+
if (source.postRunHooks !== undefined)
|
|
495
|
+
out.postRunHooks = Object.freeze([...source.postRunHooks]);
|
|
492
496
|
return Object.freeze(out);
|
|
493
497
|
}
|
|
494
498
|
function freezeMetadataValue(value) {
|
|
@@ -583,7 +587,8 @@ function defineSandboxEnvironment(env) {
|
|
|
583
587
|
throw new Error(`defineSandboxEnvironment(${env.name}): 'setup' must be a function`);
|
|
584
588
|
}
|
|
585
589
|
return defineWorkflow({
|
|
586
|
-
|
|
590
|
+
snapshots: env.snapshots ?? { saveLatest: true },
|
|
591
|
+
memory: env.memory ?? false,
|
|
587
592
|
run: async (_ctx, sandbox) => env.setup(sandbox)
|
|
588
593
|
});
|
|
589
594
|
}
|
|
@@ -695,12 +700,18 @@ function templatePath(factorySlug, ...rest) {
|
|
|
695
700
|
const tail = rest.length > 0 ? "/" + rest.map(encodeURIComponent).join("/") : "";
|
|
696
701
|
return `/api/v1/factories/${encodeURIComponent(factorySlug)}/templates${tail}`;
|
|
697
702
|
}
|
|
703
|
+
var PUBLIC_API_HOST = "https://api.agentcompose.ai";
|
|
698
704
|
|
|
699
705
|
class AgentComposeClient {
|
|
700
706
|
fetch;
|
|
701
707
|
baseUrl;
|
|
702
708
|
apiKey;
|
|
703
|
-
constructor(
|
|
709
|
+
constructor(options = {}) {
|
|
710
|
+
const apiKey = options.apiKey ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_API_KEY : undefined) ?? "";
|
|
711
|
+
if (!apiKey) {
|
|
712
|
+
throw new Error("AgentComposeClient: `apiKey` is required. Pass it as `{ apiKey }` " + "or set the AGENT_COMPOSE_API_KEY env var.");
|
|
713
|
+
}
|
|
714
|
+
const baseUrl = options.baseUrl ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_URL : undefined) ?? PUBLIC_API_HOST;
|
|
704
715
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
705
716
|
this.apiKey = apiKey;
|
|
706
717
|
this.fetch = ofetch.create({
|
|
@@ -723,10 +734,11 @@ class AgentComposeClient {
|
|
|
723
734
|
method: "POST",
|
|
724
735
|
body: {
|
|
725
736
|
input,
|
|
726
|
-
...opts?.
|
|
727
|
-
...opts?.saveSnapshot !== undefined ? { saveSnapshot: opts.saveSnapshot } : {},
|
|
737
|
+
...opts?.snapshots !== undefined ? { snapshots: opts.snapshots } : {},
|
|
728
738
|
...opts?.networkPolicy !== undefined ? { networkPolicy: opts.networkPolicy } : {},
|
|
729
739
|
...opts?.placeholders !== undefined ? { placeholders: opts.placeholders } : {},
|
|
740
|
+
...opts?.memory !== undefined ? { memory: opts.memory } : {},
|
|
741
|
+
...opts?.postRunHooks !== undefined ? { postRunHooks: opts.postRunHooks } : {},
|
|
730
742
|
...parentRunId ? { parentRunId } : {},
|
|
731
743
|
...opts?.agentId ? { agentId: opts.agentId } : {}
|
|
732
744
|
}
|
|
@@ -747,16 +759,29 @@ class AgentComposeClient {
|
|
|
747
759
|
throw new AgentComposeError(504, `invokeAndWait: run ${runId} did not settle within ${timeoutMs}ms`);
|
|
748
760
|
}
|
|
749
761
|
async listSnapshots(opts) {
|
|
762
|
+
const body = await this.listSnapshotsPage(opts);
|
|
763
|
+
return body.data;
|
|
764
|
+
}
|
|
765
|
+
async listSnapshotsPage(opts) {
|
|
766
|
+
const factorySlug = opts?.factorySlug ?? DEFAULT_FACTORY;
|
|
750
767
|
const q2 = new URLSearchParams;
|
|
751
768
|
if (opts?.workflow)
|
|
752
769
|
q2.set("workflow", opts.workflow);
|
|
753
770
|
if (opts?.limit != null)
|
|
754
771
|
q2.set("limit", String(opts.limit));
|
|
755
|
-
|
|
756
|
-
|
|
772
|
+
if (opts?.before)
|
|
773
|
+
q2.set("before", opts.before);
|
|
774
|
+
return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/snapshots${q2.toString() ? `?${q2}` : ""}`);
|
|
757
775
|
}
|
|
758
776
|
deleteSnapshot(runId) {
|
|
759
|
-
return this.fetch(`/api/v1/workflows/${runId}/snapshot`, { method: "DELETE" });
|
|
777
|
+
return this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshot`, { method: "DELETE" });
|
|
778
|
+
}
|
|
779
|
+
async listRunSnapshots(runId) {
|
|
780
|
+
const body = await this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshots`);
|
|
781
|
+
return body.data;
|
|
782
|
+
}
|
|
783
|
+
deleteRunSnapshot(runId, snapshotId) {
|
|
784
|
+
return this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/snapshots/${encodeURIComponent(snapshotId)}`, { method: "DELETE" });
|
|
760
785
|
}
|
|
761
786
|
getStatus(runId) {
|
|
762
787
|
return this.fetch(`/api/v1/workflows/${runId}/status`);
|
|
@@ -946,7 +971,7 @@ async function extractFromBundle(source, label, pick) {
|
|
|
946
971
|
return;
|
|
947
972
|
}
|
|
948
973
|
}
|
|
949
|
-
var DEFINE_WORKFLOW_CALLEE = /^defineWorkflow\d*$/;
|
|
974
|
+
var DEFINE_WORKFLOW_CALLEE = /^(?:defineWorkflow|defineSandboxEnvironment)\d*$/;
|
|
950
975
|
function isDefineWorkflowCall(node) {
|
|
951
976
|
if (node.callee.type === "Identifier") {
|
|
952
977
|
return DEFINE_WORKFLOW_CALLEE.test(node.callee.name);
|
|
@@ -1017,17 +1042,59 @@ async function bundleWorkflow(workflowPath, overrides) {
|
|
|
1017
1042
|
sourceHash: sha256(source),
|
|
1018
1043
|
bundlerVersion: BUNDLER_VERSION
|
|
1019
1044
|
};
|
|
1045
|
+
const inputSchema = extractIOSchema(workflow.input);
|
|
1046
|
+
const outputSchema = extractIOSchema(workflow.output);
|
|
1020
1047
|
return {
|
|
1021
1048
|
source,
|
|
1022
1049
|
manifest,
|
|
1023
1050
|
workflowPlan: plan,
|
|
1024
1051
|
networkPolicy: overrides?.networkPolicy ?? metadata.networkPolicy,
|
|
1025
1052
|
placeholders: overrides?.placeholders ?? metadata.placeholders,
|
|
1026
|
-
...
|
|
1027
|
-
...
|
|
1028
|
-
...metadata.
|
|
1053
|
+
...inputSchema !== undefined ? { inputSchema } : {},
|
|
1054
|
+
...outputSchema !== undefined ? { outputSchema } : {},
|
|
1055
|
+
...metadata.snapshots !== undefined ? { snapshots: metadata.snapshots } : {},
|
|
1056
|
+
...metadata.memory !== undefined ? { memory: metadata.memory } : {},
|
|
1057
|
+
...metadata.postRunHooks !== undefined ? { postRunHooks: metadata.postRunHooks } : {}
|
|
1029
1058
|
};
|
|
1030
1059
|
}
|
|
1060
|
+
function extractIOSchema(zodSchema) {
|
|
1061
|
+
let json;
|
|
1062
|
+
try {
|
|
1063
|
+
const z3 = __require("zod");
|
|
1064
|
+
if (!z3.toJSONSchema)
|
|
1065
|
+
return;
|
|
1066
|
+
json = z3.toJSONSchema(zodSchema);
|
|
1067
|
+
} catch {
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
if (!json || typeof json !== "object")
|
|
1071
|
+
return;
|
|
1072
|
+
if (Object.keys(json).filter((k) => k !== "$schema").length === 0)
|
|
1073
|
+
return;
|
|
1074
|
+
const out = {};
|
|
1075
|
+
if (json.type !== undefined)
|
|
1076
|
+
out.type = json.type;
|
|
1077
|
+
if (json.description !== undefined)
|
|
1078
|
+
out.description = String(json.description);
|
|
1079
|
+
if (json.properties && typeof json.properties === "object") {
|
|
1080
|
+
const props = {};
|
|
1081
|
+
for (const [key, raw] of Object.entries(json.properties)) {
|
|
1082
|
+
if (raw && typeof raw === "object") {
|
|
1083
|
+
const r = raw;
|
|
1084
|
+
props[key] = {};
|
|
1085
|
+
if (r.type !== undefined)
|
|
1086
|
+
props[key].type = r.type;
|
|
1087
|
+
if (r.description !== undefined)
|
|
1088
|
+
props[key].description = String(r.description);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (Object.keys(props).length > 0)
|
|
1092
|
+
out.properties = props;
|
|
1093
|
+
}
|
|
1094
|
+
if (Array.isArray(json.required))
|
|
1095
|
+
out.required = json.required.map(String);
|
|
1096
|
+
return out;
|
|
1097
|
+
}
|
|
1031
1098
|
// src/utils/schemas.ts
|
|
1032
1099
|
import { z as z3 } from "zod";
|
|
1033
1100
|
var AgentStatusSchema = z3.object({
|
|
@@ -1544,7 +1611,11 @@ function makeVercelSandboxProvider(sb, globalEnvs) {
|
|
|
1544
1611
|
},
|
|
1545
1612
|
async snapshot() {
|
|
1546
1613
|
const res = await sb.snapshot({ expiration: 0 });
|
|
1547
|
-
|
|
1614
|
+
const sizeBytes = typeof res.sizeBytes === "number" ? res.sizeBytes : undefined;
|
|
1615
|
+
return {
|
|
1616
|
+
snapshotId: res.snapshotId,
|
|
1617
|
+
...sizeBytes !== undefined ? { sizeBytes } : {}
|
|
1618
|
+
};
|
|
1548
1619
|
}
|
|
1549
1620
|
};
|
|
1550
1621
|
}
|
|
@@ -2049,7 +2120,7 @@ function buildInvokeChild(runId, opts = {}) {
|
|
|
2049
2120
|
if (!baseUrl || !apiKey) {
|
|
2050
2121
|
throw new Error("ctx.invokeChild requires AGENT_COMPOSE_URL and AGENT_COMPOSE_API_KEY");
|
|
2051
2122
|
}
|
|
2052
|
-
childClient = new AgentComposeClient(
|
|
2123
|
+
childClient = new AgentComposeClient({ apiKey, baseUrl });
|
|
2053
2124
|
return childClient;
|
|
2054
2125
|
};
|
|
2055
2126
|
return (name, input, childOpts) => getChildClient().invokeAndWait(name, input, {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A sandbox environment is a workflow whose job is to leave its VM in a
|
|
3
3
|
* configured state, then snapshot it so other workflows can boot from that
|
|
4
|
-
* state. Capture is **opt-in**: the wrapper below sets
|
|
5
|
-
* by default (opt out with
|
|
6
|
-
* effects).
|
|
4
|
+
* state. Capture is **opt-in**: the wrapper below sets
|
|
5
|
+
* `snapshots: { saveLatest: true }` by default (opt out with
|
|
6
|
+
* `saveLatest: false` if you only want side effects).
|
|
7
7
|
*
|
|
8
|
-
* Once captured, reference the snapshot from another workflow's
|
|
9
|
-
* field by
|
|
8
|
+
* Once captured, reference the snapshot from another workflow's
|
|
9
|
+
* `snapshots.bootFrom` field by provider snapshot id:
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* snapshot: "my-setup@v1" // version-scoped recency
|
|
13
|
-
* snapshot: "<run-uuid>" // pinned to an exact run
|
|
11
|
+
* snapshots: { bootFrom: { snapshotId: "snap_..." } }
|
|
14
12
|
*
|
|
15
13
|
* `defineSandboxEnvironment` is sugar over `defineWorkflow` — it makes the
|
|
16
14
|
* setup recipe read like an imperative script by supplying the local
|
|
@@ -20,7 +18,7 @@
|
|
|
20
18
|
* 1. Author a setup file with `defineSandboxEnvironment`.
|
|
21
19
|
* 2. `agentc register setup.ts --build` — registers and invokes once to
|
|
22
20
|
* capture the snapshot.
|
|
23
|
-
* 3. Other workflows declare `
|
|
21
|
+
* 3. Other workflows declare `snapshots: { bootFrom: { snapshotId } }`.
|
|
24
22
|
* 4. `agentc snapshot list` / `delete` to manage the Vercel storage bill.
|
|
25
23
|
*
|
|
26
24
|
* @example
|
|
@@ -37,16 +35,27 @@
|
|
|
37
35
|
*/
|
|
38
36
|
import type { SandboxProvider } from "./sandbox.js";
|
|
39
37
|
import type { Workflow } from "../workflow-steps/types.js";
|
|
38
|
+
import type { SnapshotConfig } from "./workflow-metadata.js";
|
|
40
39
|
export interface SandboxEnvironmentDefinition {
|
|
41
40
|
name: string;
|
|
42
41
|
description?: string;
|
|
43
42
|
setup: (sb: SandboxProvider) => Promise<void>;
|
|
44
|
-
/** Override the sugar's `
|
|
45
|
-
* out of snapshot capture (rarely
|
|
46
|
-
*
|
|
47
|
-
|
|
43
|
+
/** Override the sugar's `{ saveLatest: true }` default. Set
|
|
44
|
+
* `{ saveLatest: false }` to opt out of snapshot capture (rarely
|
|
45
|
+
* useful — an env with no snapshot can't be referenced as a
|
|
46
|
+
* `bootFrom` on another workflow). */
|
|
47
|
+
snapshots?: SnapshotConfig;
|
|
48
|
+
/** Override the sugar's `memory: false` default. Setup workflows
|
|
49
|
+
* don't typically benefit from memory extraction; opt in explicitly
|
|
50
|
+
* when they do. */
|
|
51
|
+
memory?: boolean;
|
|
48
52
|
}
|
|
49
53
|
/** Sugar over `defineWorkflow` for setup-only workflows that exist to
|
|
50
54
|
* capture a snapshot. The workflow takes no meaningful input and returns
|
|
51
|
-
* nothing — its value is the side effect on the sandbox VM.
|
|
55
|
+
* nothing — its value is the side effect on the sandbox VM.
|
|
56
|
+
*
|
|
57
|
+
* Defaults `memory: false` because sandbox environments emit setup
|
|
58
|
+
* output (npm installs, command exit codes) rather than agent traces
|
|
59
|
+
* worth memorising. Authors can opt in explicitly via `env.memory:
|
|
60
|
+
* true` if their environment somehow does want extraction. */
|
|
52
61
|
export declare function defineSandboxEnvironment(env: SandboxEnvironmentDefinition): Workflow<Record<string, unknown>, void>;
|
package/dist/types/sandbox.d.ts
CHANGED
|
@@ -29,9 +29,14 @@ export interface SandboxProvider {
|
|
|
29
29
|
/** Capture the running sandbox's state as a reusable snapshot. Vercel
|
|
30
30
|
* supports it natively; E2B's model is Dockerfile-based and doesn't map
|
|
31
31
|
* cleanly — `undefined` on providers that don't. Used by the server's
|
|
32
|
-
* `--build` flow to stamp the snapshot id on the workflow row.
|
|
32
|
+
* `--build` flow to stamp the snapshot id on the workflow row.
|
|
33
|
+
*
|
|
34
|
+
* `sizeBytes` is the on-disk footprint reported by the provider. May
|
|
35
|
+
* be omitted when the provider doesn't expose it; the server stores
|
|
36
|
+
* `null` for missing values rather than estimating. */
|
|
33
37
|
snapshot?(): Promise<{
|
|
34
38
|
snapshotId: string;
|
|
39
|
+
sizeBytes?: number;
|
|
35
40
|
}>;
|
|
36
41
|
}
|
|
37
42
|
/** Stateless provider-level snapshot deletion — no live sandbox needed,
|
|
@@ -18,19 +18,83 @@ import type { Processor } from "../processors/processor.js";
|
|
|
18
18
|
* The bundler reads these from the default export at registration time
|
|
19
19
|
* and forwards them to the server's POST /api/v1/templates payload.
|
|
20
20
|
*/
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
export type WorkflowMemoryConfig =
|
|
25
|
-
|
|
21
|
+
/** Whether the built-in Workflow Memory extractor should run after this
|
|
22
|
+
* workflow completes. Boolean toggle — custom post-run workflows live
|
|
23
|
+
* in the separate `postRunHooks` array on `WorkflowMetadata`. */
|
|
24
|
+
export type WorkflowMemoryConfig = boolean;
|
|
25
|
+
/** Where a run boots from. The snapshot id is the unit of identity —
|
|
26
|
+
* each captured snapshot already records the workflow + version it
|
|
27
|
+
* came from on the snapshot row, so there's no separate "latest of
|
|
28
|
+
* workflow X" resolution at dispatch time. Operators pick a snapshot
|
|
29
|
+
* from the dashboard snapshot list (or `agentc snapshot list`) and
|
|
30
|
+
* paste the id here.
|
|
31
|
+
*
|
|
32
|
+
* Omit `bootFrom` entirely to boot a fresh base sandbox. */
|
|
33
|
+
export type BootSnapshot = {
|
|
34
|
+
snapshotId: string;
|
|
26
35
|
};
|
|
36
|
+
/** Snapshot configuration — boot source plus capture knobs. One object
|
|
37
|
+
* per workflow / per invocation; collapsing boot + capture under a
|
|
38
|
+
* single key reads as "all snapshot config lives here." */
|
|
39
|
+
export interface SnapshotConfig {
|
|
40
|
+
/** Where the runner restores from at run start. Structured (workflow
|
|
41
|
+
* ref or snapshot id) so the intent is explicit at the call site. */
|
|
42
|
+
bootFrom?: BootSnapshot;
|
|
43
|
+
/** Capture the sandbox state on terminal success. The latest pointer
|
|
44
|
+
* on `workflow_runs.vercel_snapshot_id` always tracks the most
|
|
45
|
+
* recent capture; without `retainSteps`, prior captures are deleted
|
|
46
|
+
* as new ones land — constant storage cost. */
|
|
47
|
+
saveLatest?: boolean;
|
|
48
|
+
/** Only meaningful with `saveLatest: true`. Retain every step's
|
|
49
|
+
* snapshot in `run_step_snapshots` so a future dispatch can boot
|
|
50
|
+
* from a specific step's checkpoint via its `snapshotId`. Cost
|
|
51
|
+
* scales linearly with step count. */
|
|
52
|
+
retainSteps?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** JSON-Schema-shaped description captured by the bundler from a
|
|
55
|
+
* workflow's `input` or `output` zod schema. Carried in template
|
|
56
|
+
* metadata so the dashboard can render typed input forms + output
|
|
57
|
+
* type tables. */
|
|
58
|
+
export interface IOSchema {
|
|
59
|
+
/** JSON Schema `type` keyword, when single-valued. Omitted for unions / unknowns. */
|
|
60
|
+
type?: string | string[];
|
|
61
|
+
/** Free-form description pulled from `.describe(...)` on the root. */
|
|
62
|
+
description?: string;
|
|
63
|
+
/** Object-shape: one entry per property. */
|
|
64
|
+
properties?: Record<string, {
|
|
65
|
+
type?: string | string[];
|
|
66
|
+
description?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Required property names — relevant only when `type === "object"`. */
|
|
69
|
+
required?: string[];
|
|
70
|
+
}
|
|
71
|
+
/** Alias kept for backwards source-compatibility with the original
|
|
72
|
+
* output-only release. New code should prefer `IOSchema`. */
|
|
73
|
+
export type OutputSchema = IOSchema;
|
|
27
74
|
export interface WorkflowMetadata {
|
|
28
75
|
networkPolicy?: SandboxNetworkPolicy;
|
|
29
76
|
placeholders?: Record<string, string>;
|
|
30
|
-
|
|
31
|
-
|
|
77
|
+
/** Input schema captured at bundle time from the workflow's
|
|
78
|
+
* declared `input` zod schema. Step-form workflows populate this
|
|
79
|
+
* automatically; run-form workflows (no explicit input schema —
|
|
80
|
+
* defaults to `z.unknown()`) leave it undefined. */
|
|
81
|
+
inputSchema?: IOSchema;
|
|
82
|
+
/** Output schema captured at bundle time from the workflow's
|
|
83
|
+
* declared `output` zod schema. Step-form workflows populate this
|
|
84
|
+
* automatically; run-form workflows whose `run()` returns
|
|
85
|
+
* arbitrarily-typed values leave it undefined. */
|
|
86
|
+
outputSchema?: IOSchema;
|
|
87
|
+
/** All snapshot config — boot source + capture mode. */
|
|
88
|
+
snapshots?: SnapshotConfig;
|
|
32
89
|
processors?: readonly Processor[];
|
|
33
|
-
memory
|
|
90
|
+
/** Run the built-in memory extractor after this workflow completes.
|
|
91
|
+
* Opt-in; defaults to false when omitted. */
|
|
92
|
+
memory?: boolean;
|
|
93
|
+
/** Ordered list of workflow names that run after this workflow
|
|
94
|
+
* completes. The runtime dispatches them in declaration order; the
|
|
95
|
+
* built-in memory extractor (when `memory: true`) runs as a separate
|
|
96
|
+
* hook alongside whatever's declared here. */
|
|
97
|
+
postRunHooks?: readonly string[];
|
|
34
98
|
}
|
|
35
99
|
/**
|
|
36
100
|
* Pull the server-readable declarations off a source object (run-form
|
package/dist/types/workflow.d.ts
CHANGED
|
@@ -25,8 +25,8 @@ export type { WorkflowMetadata } from "./workflow-metadata.js";
|
|
|
25
25
|
export interface AgentEventSink {
|
|
26
26
|
emit(event: AgentLifecycleEvent): void | Promise<void>;
|
|
27
27
|
}
|
|
28
|
-
import type { WorkflowMemoryConfig } from "./workflow-metadata.js";
|
|
29
|
-
export type { WorkflowMemoryConfig };
|
|
28
|
+
import type { WorkflowMemoryConfig, SnapshotConfig, BootSnapshot, IOSchema, OutputSchema } from "./workflow-metadata.js";
|
|
29
|
+
export type { WorkflowMemoryConfig, SnapshotConfig, BootSnapshot, IOSchema, OutputSchema };
|
|
30
30
|
/** Turn/iteration budget for `agent(opts)`. Re-exported here so authors
|
|
31
31
|
* can type per-invoke budget overrides they pass as workflow input. */
|
|
32
32
|
export interface AgentBudget {
|
|
@@ -69,21 +69,21 @@ export type WorkflowFn<TOutput = unknown, TInput extends Record<string, unknown>
|
|
|
69
69
|
export interface WorkflowDefinition<TOutput = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> {
|
|
70
70
|
run: WorkflowFn<TOutput, TInput>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* `
|
|
84
|
-
* `
|
|
72
|
+
* All snapshot config — boot source plus capture mode.
|
|
73
|
+
*
|
|
74
|
+
* `snapshots.bootFrom`: the runner restores from this exact provider
|
|
75
|
+
* snapshot id at run start. Omit to boot a fresh sandbox.
|
|
76
|
+
*
|
|
77
|
+
* `snapshots.saveLatest`: `true` captures one snapshot after each
|
|
78
|
+
* successful step (latest-only — prior is freed).
|
|
79
|
+
* `{ saveLatest: true, retainSteps: true }` keeps every step's
|
|
80
|
+
* snapshot for fork / replay / time-travel.
|
|
81
|
+
*
|
|
82
|
+
* Snapshots are long-lived (never auto-expire). List + delete via
|
|
83
|
+
* `agentc snapshot list/delete`. Per-invocation
|
|
84
|
+
* `invoke({ snapshots })` overrides this default.
|
|
85
85
|
*/
|
|
86
|
-
|
|
86
|
+
snapshots?: SnapshotConfig;
|
|
87
87
|
/**
|
|
88
88
|
* Outbound network policy for the runner sandbox.
|
|
89
89
|
* Use "*": [] to allow all traffic while still injecting headers for specific domains.
|
|
@@ -120,10 +120,14 @@ export interface WorkflowDefinition<TOutput = unknown, TInput extends Record<str
|
|
|
120
120
|
* }
|
|
121
121
|
*/
|
|
122
122
|
placeholders?: Record<string, string>;
|
|
123
|
-
/**
|
|
124
|
-
*
|
|
125
|
-
* custom memory workflow once custom extractors are supported. */
|
|
123
|
+
/** Run the built-in memory extractor after this workflow completes.
|
|
124
|
+
* Opt-in; defaults to false when omitted. */
|
|
126
125
|
memory?: WorkflowMemoryConfig;
|
|
126
|
+
/** Ordered list of workflow names to dispatch as post-hooks after
|
|
127
|
+
* this workflow completes. Each hook receives the source run's
|
|
128
|
+
* context. The memory extractor (when `memory: true`) runs as an
|
|
129
|
+
* additional hook alongside these. */
|
|
130
|
+
postRunHooks?: readonly string[];
|
|
127
131
|
}
|
|
128
132
|
/**
|
|
129
133
|
* Declare a workflow. Two forms; both return a `Workflow` whose
|
package/dist/utils/bundler.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* this function returns alongside the bundled bytes, and cross-checks the
|
|
20
20
|
* manifest's `sourceHash` against the source it received.
|
|
21
21
|
*/
|
|
22
|
-
import type { WorkflowMemoryConfig } from "../types/workflow.js";
|
|
22
|
+
import type { WorkflowMemoryConfig, SnapshotConfig } from "../types/workflow.js";
|
|
23
23
|
import type { SandboxNetworkPolicy } from "../sandbox.js";
|
|
24
24
|
import { type WorkflowPlan } from "../types/workflow-plan.js";
|
|
25
25
|
/** Bumped when the manifest contract changes in a way the server should
|
|
@@ -51,15 +51,20 @@ export interface BundledWorkflow {
|
|
|
51
51
|
manifest: WorkflowManifest;
|
|
52
52
|
networkPolicy?: SandboxNetworkPolicy;
|
|
53
53
|
placeholders?: Record<string, string>;
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
snapshot?: string;
|
|
58
|
-
/** Default capture-on-success flag from the workflow definition. */
|
|
59
|
-
saveSnapshot?: boolean;
|
|
54
|
+
/** Snapshot config from the workflow definition — `bootFrom` (where to
|
|
55
|
+
* restore at run start), `save`, `retain`. */
|
|
56
|
+
snapshots?: SnapshotConfig;
|
|
60
57
|
workflowPlan: WorkflowPlan;
|
|
61
58
|
/** Workflow Memory extractor config. */
|
|
62
59
|
memory?: WorkflowMemoryConfig;
|
|
60
|
+
/** Ordered post-hook workflow names declared on the workflow. */
|
|
61
|
+
postRunHooks?: readonly string[];
|
|
62
|
+
/** Compact JSON-Schema-shaped description of the workflow's input
|
|
63
|
+
* type. Extracted from the workflow's declared `input` zod schema
|
|
64
|
+
* at bundle time; undefined when the schema is `z.unknown()`. */
|
|
65
|
+
inputSchema?: import("../types/workflow-metadata.js").IOSchema;
|
|
66
|
+
/** Same for the workflow's output zod schema. */
|
|
67
|
+
outputSchema?: import("../types/workflow-metadata.js").IOSchema;
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
70
|
* Parse the bundled source and assert the default export is a CallExpression
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import type { z } from "zod";
|
|
22
22
|
import type { Step, Workflow } from "./types.js";
|
|
23
|
+
import type { SnapshotConfig, WorkflowMemoryConfig } from "../types/workflow-metadata.js";
|
|
23
24
|
import type { SandboxNetworkPolicy } from "../sandbox.js";
|
|
24
25
|
import type { Processor } from "../processors/processor.js";
|
|
25
26
|
export interface WorkflowBuilder<TInput, TCurrent> {
|
|
@@ -41,8 +42,9 @@ export interface StepWorkflowDefinition<TInput, TOutput> {
|
|
|
41
42
|
output: z.ZodType<TOutput>;
|
|
42
43
|
networkPolicy?: SandboxNetworkPolicy;
|
|
43
44
|
placeholders?: Record<string, string>;
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
snapshots?: SnapshotConfig;
|
|
46
|
+
memory?: WorkflowMemoryConfig;
|
|
47
|
+
postRunHooks?: readonly string[];
|
|
46
48
|
processors?: readonly Processor[];
|
|
47
49
|
}
|
|
48
50
|
export declare function createStepWorkflow<TInput, TOutput>(opts: StepWorkflowDefinition<TInput, TOutput>): WorkflowBuilder<TInput, TInput>;
|
package/package.json
CHANGED