@agent-compose/sdk 0.6.0 → 0.8.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 (126) hide show
  1. package/README.md +66 -39
  2. package/dist/agent/__tests__/runtime-json-schema.test.d.ts +10 -0
  3. package/dist/agent/agent-context.d.ts +21 -1
  4. package/dist/agent/agent-loop.d.ts +24 -1
  5. package/dist/client.d.ts +338 -534
  6. package/dist/directives.d.ts +112 -0
  7. package/dist/display.d.ts +242 -0
  8. package/dist/errors.d.ts +24 -1
  9. package/dist/index.d.ts +34 -13
  10. package/dist/index.js +2984 -861
  11. package/dist/pause/wrappers.d.ts +31 -9
  12. package/dist/processors/ask-human.d.ts +30 -0
  13. package/dist/processors/ask-human.test.d.ts +1 -0
  14. package/dist/processors/index.d.ts +1 -0
  15. package/dist/runtimes/_acp-client.d.ts +46 -1
  16. package/dist/runtimes/_cli-agent.d.ts +58 -4
  17. package/dist/runtimes/_jsonl-guard.d.ts +103 -0
  18. package/dist/runtimes/amp.d.ts +2 -2
  19. package/dist/runtimes/claude-code.d.ts +59 -0
  20. package/dist/runtimes/claude-code.test.d.ts +14 -0
  21. package/dist/runtimes/claude.d.ts +16 -0
  22. package/dist/runtimes/claude.test.d.ts +8 -0
  23. package/dist/runtimes/codex.d.ts +9 -3
  24. package/dist/runtimes/cursor.d.ts +9 -0
  25. package/dist/runtimes/droid.d.ts +9 -0
  26. package/dist/runtimes/jsonl-guard.test.d.ts +19 -0
  27. package/dist/runtimes/openai-desktop.js +2922 -861
  28. package/dist/runtimes/opencode.d.ts +25 -0
  29. package/dist/runtimes/vercel.js +22 -1
  30. package/dist/sandbox/devbox.d.ts +42 -0
  31. package/dist/sandbox/exec-stream.d.ts +14 -0
  32. package/dist/sandbox/network-policy.d.ts +100 -0
  33. package/dist/sandbox/provider-def.d.ts +79 -0
  34. package/dist/sandbox/providers/desktop.d.ts +10 -0
  35. package/dist/sandbox/providers/e2b.d.ts +17 -0
  36. package/dist/sandbox/providers/local.d.ts +11 -0
  37. package/dist/sandbox/providers/vercel.d.ts +18 -0
  38. package/dist/sandbox/registry.d.ts +45 -0
  39. package/dist/sandbox/sizes.d.ts +68 -0
  40. package/dist/sandbox.d.ts +24 -299
  41. package/dist/step-invocation/__tests__/foreground-recovery.test.d.ts +1 -0
  42. package/dist/step-invocation/invoker.d.ts +24 -1
  43. package/dist/step-invocation/protocol.d.ts +13 -0
  44. package/dist/types/api-compliance.d.ts +71 -0
  45. package/dist/types/api-conversations.d.ts +492 -0
  46. package/dist/types/api-factory.d.ts +309 -0
  47. package/dist/types/api-projects.d.ts +131 -0
  48. package/dist/types/api-runs.d.ts +377 -0
  49. package/dist/types/api-scopes.d.ts +102 -0
  50. package/dist/types/conversation-stream.d.ts +191 -0
  51. package/dist/types/execution-context.d.ts +12 -2
  52. package/dist/types/protocol.d.ts +30 -1
  53. package/dist/types/sandbox-environment.d.ts +8 -5
  54. package/dist/types/sandbox.d.ts +79 -0
  55. package/dist/types/workflow-metadata.d.ts +33 -8
  56. package/dist/types/workflow-plan.d.ts +10 -0
  57. package/dist/types/workflow.d.ts +18 -193
  58. package/dist/utils/bundler.d.ts +12 -1
  59. package/dist/utils/errors.d.ts +9 -1
  60. package/dist/workflow-steps/index.d.ts +1 -1
  61. package/dist/workflow-steps/observability.d.ts +8 -1
  62. package/dist/workflow-steps/runner.d.ts +3 -3
  63. package/dist/workflow-steps/step.d.ts +15 -1
  64. package/dist/workflow-steps/types.d.ts +19 -5
  65. package/dist/workflow-steps/workflow.d.ts +22 -1
  66. package/dist/workflows/engine.d.ts +3 -2
  67. package/dist/workflows/invoke-child.d.ts +2 -2
  68. package/package.json +1 -1
  69. package/src/agent/agent-context.ts +206 -16
  70. package/src/agent/agent-loop.ts +40 -4
  71. package/src/agent/run-agent.ts +9 -1
  72. package/src/client.ts +909 -621
  73. package/src/directives.ts +184 -0
  74. package/src/display.ts +788 -0
  75. package/src/errors.ts +39 -0
  76. package/src/index.ts +117 -10
  77. package/src/pause/wrappers.ts +44 -9
  78. package/src/processors/ask-human.ts +136 -0
  79. package/src/processors/index.ts +5 -0
  80. package/src/runtimes/_acp-client.ts +72 -3
  81. package/src/runtimes/_cli-agent.ts +171 -38
  82. package/src/runtimes/_jsonl-guard.ts +219 -0
  83. package/src/runtimes/claude-code.ts +246 -0
  84. package/src/runtimes/claude.ts +32 -2
  85. package/src/runtimes/codex.ts +55 -3
  86. package/src/runtimes/cursor.ts +59 -0
  87. package/src/runtimes/droid.ts +63 -0
  88. package/src/runtimes/openai-desktop.ts +59 -14
  89. package/src/runtimes/opencode.ts +61 -0
  90. package/src/sandbox/devbox.ts +48 -0
  91. package/src/sandbox/exec-stream.ts +48 -0
  92. package/src/sandbox/network-policy.ts +181 -0
  93. package/src/sandbox/provider-def.ts +94 -0
  94. package/src/sandbox/providers/desktop.ts +57 -0
  95. package/src/sandbox/providers/e2b.ts +354 -0
  96. package/src/sandbox/providers/local.ts +106 -0
  97. package/src/sandbox/providers/vercel.ts +331 -0
  98. package/src/sandbox/registry.ts +198 -0
  99. package/src/sandbox/sizes.ts +95 -0
  100. package/src/sandbox.ts +59 -1263
  101. package/src/step-invocation/invoker.ts +319 -34
  102. package/src/step-invocation/protocol.ts +19 -0
  103. package/src/types/api-compliance.ts +79 -0
  104. package/src/types/api-conversations.ts +522 -0
  105. package/src/types/api-factory.ts +336 -0
  106. package/src/types/api-projects.ts +140 -0
  107. package/src/types/api-runs.ts +412 -0
  108. package/src/types/api-scopes.ts +102 -0
  109. package/src/types/conversation-stream.ts +231 -0
  110. package/src/types/execution-context.ts +10 -2
  111. package/src/types/protocol.ts +33 -0
  112. package/src/types/sandbox-environment.ts +28 -9
  113. package/src/types/sandbox.ts +78 -0
  114. package/src/types/workflow-metadata.ts +35 -8
  115. package/src/types/workflow-plan.ts +11 -0
  116. package/src/types/workflow.ts +25 -280
  117. package/src/utils/bundler.ts +32 -5
  118. package/src/utils/errors.ts +34 -2
  119. package/src/workflow-steps/index.ts +1 -0
  120. package/src/workflow-steps/observability.ts +19 -8
  121. package/src/workflow-steps/runner.ts +4 -4
  122. package/src/workflow-steps/step.ts +49 -1
  123. package/src/workflow-steps/types.ts +20 -5
  124. package/src/workflow-steps/workflow.ts +22 -1
  125. package/src/workflows/engine.ts +3 -2
  126. package/src/workflows/invoke-child.ts +2 -2
@@ -15,6 +15,7 @@ import type { z } from "zod";
15
15
  import type { BaseExecutionContext } from "../types/execution-context.js";
16
16
  import type { AgentEventSink } from "../types/workflow.js";
17
17
  import type { WorkflowMetadata } from "../types/workflow-metadata.js";
18
+ import type { StepObservability } from "./observability.js";
18
19
 
19
20
  /**
20
21
  * Per-step execution context. Threaded into every step's `execute(...)` so
@@ -62,6 +63,15 @@ export interface StepContext<TInput = unknown> extends BaseExecutionContext {
62
63
  agentEvents: AgentEventSink;
63
64
  }
64
65
 
66
+ /** One artifact a step promises to produce. `path` is workspace/drive-relative
67
+ * (e.g. "out/report.html"); the dashboard derives the format tag from the
68
+ * extension client-side — no `format` field here. */
69
+ export interface StepDeliverable {
70
+ path: string;
71
+ /** Optional one-line description of the artifact. */
72
+ description?: string;
73
+ }
74
+
65
75
  /**
66
76
  * Step definition — a single typed unit of work in a workflow chain.
67
77
  *
@@ -80,6 +90,11 @@ export interface Step<TInput, TOutput> {
80
90
  readonly output: z.ZodType<TOutput>;
81
91
  /** Step body. Receives a `StepContext<TInput>` and returns the typed output. */
82
92
  run(ctx: StepContext<TInput>): TOutput | Promise<TOutput>;
93
+ /** One plain sentence of what the step actually does — rendered on the
94
+ * dashboard workflow graph. ≤200 chars, no newlines. */
95
+ readonly summary?: string;
96
+ /** Files the step promises to produce. ≤8 entries. */
97
+ readonly deliverables?: readonly StepDeliverable[];
83
98
  }
84
99
 
85
100
  /**
@@ -90,14 +105,14 @@ export interface Step<TInput, TOutput> {
90
105
  * the step; undefined when no hooks were used.
91
106
  */
92
107
  export type StepRunResult<TOutput = unknown> =
93
- | { status: "completed"; output: TOutput; durationMs: number; observability?: import("./observability.js").StepObservability }
94
- | { status: "failed"; error: string; durationMs: number; observability?: import("./observability.js").StepObservability };
108
+ | { status: "completed"; output: TOutput; durationMs: number; observability?: StepObservability }
109
+ | { status: "failed"; error: string; durationMs: number; observability?: StepObservability };
95
110
 
96
111
  /**
97
112
  * Workflow — a list of typed steps plus the workflow's input/output
98
- * schemas plus its server-side metadata bag. Returned by `defineWorkflow(...)`
99
- * (run form) and `defineWorkflow(...).step(...)...build()` (step form).
100
- * Engine adapters consume this shape.
113
+ * schemas plus its server-side metadata bag. Returned by
114
+ * `defineWorkflow(...).step(...)...build()`. Engine adapters consume
115
+ * this shape.
101
116
  *
102
117
  * `input` validates the workflow input before the first step runs.
103
118
  * `output` validates the final step's output before the workflow
@@ -23,7 +23,7 @@ import type { z } from "zod";
23
23
  import type { Step, Workflow } from "./types.js";
24
24
  import { WORKFLOW_BRAND } from "./types.js";
25
25
  import { extractMetadata } from "../types/workflow-metadata.js";
26
- import type { SnapshotConfig, SandboxResources } from "../types/workflow-metadata.js";
26
+ import type { SnapshotConfig, SandboxResources, ConnectorRequirements, ConnectorOperationTag, InvokePolicy, DriveMergePolicy } from "../types/workflow-metadata.js";
27
27
  import type { SandboxNetworkPolicy } from "../sandbox.js";
28
28
  import type { Processor } from "../processors/processor.js";
29
29
 
@@ -55,7 +55,28 @@ export interface StepWorkflowDefinition<TInput, TOutput> {
55
55
  * and `provider` (`vercel` | `e2b`). Vercel maps `size` to vCPUs; E2B
56
56
  * sizing is template-defined. Omit → smallest SKU on the default provider. */
57
57
  resources?: SandboxResources;
58
+ /** What happens to this workflow's drive branch when a run ends:
59
+ * `"auto"` (the default when omitted — today's behaviour) folds it into
60
+ * `main`; `"manual"` proposes a merge approval at the same terminus
61
+ * instead, leaving the branch durable until a human clicks approve. A
62
+ * cancelled run neither merges nor proposes under either policy. */
63
+ mergePolicy?: DriveMergePolicy;
58
64
  processors?: readonly Processor[];
65
+ /** Connector requirements (ADR-0007) — providers whose APIs this workflow
66
+ * calls. Dispatch resolves an authorized grant per provider and injects a
67
+ * fresh access token at the network layer. */
68
+ connectors?: ConnectorRequirements;
69
+ /** Marks this workflow as a catalogue OPERATION of a connector — e.g. the
70
+ * `create-issue` operation of the `github` connector. */
71
+ connectorOperation?: ConnectorOperationTag;
72
+ /** Tier-1 invoke ACL — who may dispatch this connector-brokering workflow.
73
+ * See `InvokePolicy`. */
74
+ invokePolicy?: InvokePolicy;
75
+ /** Internal — set by `defineSandboxEnvironment`, not by workflow authors.
76
+ * Marks the workflow as an environment build (base-env / agent-env) so the
77
+ * server skips mounting the shared factory drive for its runs (#13). See
78
+ * `WorkflowMetadata.environmentBuild`. */
79
+ environmentBuild?: boolean;
59
80
  }
60
81
 
61
82
  export function createStepWorkflow<TInput, TOutput>(
@@ -9,7 +9,8 @@
9
9
  * (platform problem) for the runner harness to surface upstream.
10
10
  */
11
11
 
12
- import type { WorkflowHooks, WorkflowCtx } from "../types/workflow.js";
12
+ import type { WorkflowHooks } from "../types/workflow.js";
13
+ import type { InvokeChild } from "../types/execution-context.js";
13
14
  import { makeLocalSandboxProvider } from "../sandbox.js";
14
15
  import { formatError } from "../utils/errors.js";
15
16
  import { RequestContext } from "../request-context/request-context.js";
@@ -94,7 +95,7 @@ export interface RunWorkflowOptions {
94
95
  /** Provider-specific child workflow invocation. Temporal/Inngest providers
95
96
  * inject their native child-workflow primitive; the LocalProvider injects
96
97
  * the public Agent Compose API client. */
97
- invokeChild?: WorkflowCtx["invokeChild"];
98
+ invokeChild?: InvokeChild;
98
99
  }
99
100
 
100
101
  export async function runWorkflow<TInput, TOutput>(
@@ -1,5 +1,5 @@
1
1
  import { AgentComposeClient } from "../client.js";
2
- import type { WorkflowCtx } from "../types/workflow.js";
2
+ import type { InvokeChild } from "../types/execution-context.js";
3
3
 
4
4
  /**
5
5
  * Build the public-API child workflow invoker used by legacy and sandboxed
@@ -9,7 +9,7 @@ import type { WorkflowCtx } from "../types/workflow.js";
9
9
  export function buildInvokeChild(
10
10
  runId: string,
11
11
  opts: { fallbackBaseUrl?: string; defaultFactorySlug?: string } = {},
12
- ): WorkflowCtx["invokeChild"] {
12
+ ): InvokeChild {
13
13
  let childClient: AgentComposeClient | null = null;
14
14
  const getChildClient = (): AgentComposeClient => {
15
15
  if (childClient) return childClient;