antpath 0.10.15 → 0.11.4

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 (75) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +16 -8
  3. package/dist/_shared/blueprint.d.ts +93 -108
  4. package/dist/_shared/blueprint.js +144 -78
  5. package/dist/_shared/cleanup-policy.d.ts +2 -2
  6. package/dist/_shared/cleanup-policy.js +2 -5
  7. package/dist/_shared/http.d.ts +2 -2
  8. package/dist/_shared/index.d.ts +5 -1
  9. package/dist/_shared/index.js +5 -1
  10. package/dist/_shared/mcp-proxy-url.d.ts +55 -0
  11. package/dist/_shared/mcp-proxy-url.js +65 -0
  12. package/dist/_shared/operations.d.ts +7 -8
  13. package/dist/_shared/operations.js +14 -20
  14. package/dist/_shared/provider-proxy-url.d.ts +64 -0
  15. package/dist/_shared/provider-proxy-url.js +73 -0
  16. package/dist/_shared/proxy-validation.d.ts +1 -1
  17. package/dist/_shared/proxy-validation.js +2 -2
  18. package/dist/_shared/run-unit.d.ts +23 -36
  19. package/dist/_shared/run-unit.js +30 -46
  20. package/dist/_shared/runner-event.d.ts +120 -0
  21. package/dist/_shared/runner-event.js +193 -0
  22. package/dist/_shared/runner-job.d.ts +159 -0
  23. package/dist/_shared/runner-job.js +54 -0
  24. package/dist/_shared/runtime-manifest.d.ts +191 -0
  25. package/dist/_shared/runtime-manifest.js +221 -0
  26. package/dist/_shared/runtime-types.d.ts +7 -16
  27. package/dist/_shared/stable.d.ts +15 -10
  28. package/dist/_shared/stable.js +15 -10
  29. package/dist/_shared/submission.d.ts +221 -73
  30. package/dist/_shared/submission.js +442 -212
  31. package/dist/_shared/telemetry.d.ts +2 -2
  32. package/dist/_shared/telemetry.js +2 -2
  33. package/dist/_shared/template/index.d.ts +0 -1
  34. package/dist/_shared/template/index.js +0 -1
  35. package/dist/agents-md.d.ts +25 -67
  36. package/dist/agents-md.js +35 -121
  37. package/dist/agents-md.js.map +1 -1
  38. package/dist/asset-upload.d.ts +34 -0
  39. package/dist/asset-upload.js +34 -0
  40. package/dist/asset-upload.js.map +1 -1
  41. package/dist/blueprint.d.ts +3 -3
  42. package/dist/bundle.d.ts +2 -2
  43. package/dist/bundle.js +1 -1
  44. package/dist/cli.mjs +191 -100
  45. package/dist/cli.mjs.sha256 +1 -1
  46. package/dist/client.d.ts +56 -19
  47. package/dist/client.js +147 -125
  48. package/dist/client.js.map +1 -1
  49. package/dist/file.d.ts +28 -94
  50. package/dist/file.js +35 -175
  51. package/dist/file.js.map +1 -1
  52. package/dist/index.d.ts +5 -5
  53. package/dist/index.js +4 -0
  54. package/dist/index.js.map +1 -1
  55. package/dist/mcp-server.d.ts +10 -2
  56. package/dist/mcp-server.js +17 -2
  57. package/dist/mcp-server.js.map +1 -1
  58. package/dist/skill.d.ts +44 -214
  59. package/dist/skill.js +50 -284
  60. package/dist/skill.js.map +1 -1
  61. package/dist/version.d.ts +1 -1
  62. package/dist/version.js +1 -1
  63. package/dist/version.js.map +1 -1
  64. package/docs/cleanup.md +1 -1
  65. package/docs/credentials.md +2 -2
  66. package/docs/events.md +8 -8
  67. package/docs/outputs.md +2 -0
  68. package/docs/quickstart.md +18 -2
  69. package/docs/skills.md +1 -3
  70. package/docs/templates.md +6 -5
  71. package/package.json +3 -2
  72. package/dist/_shared/secrets.d.ts +0 -7
  73. package/dist/_shared/secrets.js +0 -20
  74. package/dist/_shared/template/mapper.d.ts +0 -11
  75. package/dist/_shared/template/mapper.js +0 -70
@@ -5,58 +5,124 @@ export type JsonValue = JsonPrimitive | JsonValue[] | {
5
5
  readonly [key: string]: JsonValue;
6
6
  };
7
7
  /**
8
- * Networking + runtime-package snapshot carried alongside the template
9
- * so the worker can deep-clone and mutate it per run (e.g. injecting
10
- * the proxy hostname into `allowed_hosts` or the `node` runtime into
8
+ * Networking + runtime-package snapshot carried inside a flat submission
9
+ * so the worker can deep-clone and mutate it per run (e.g. injecting the
10
+ * proxy hostname into `allowed_hosts` or the `node` runtime into
11
11
  * `packages`) without sharing state across concurrent runs.
12
12
  *
13
- * Today this is consumed only by the worker's `templateFromSnapshot`
14
- * reconstruction. The shape stays intentionally narrow: only fields
15
- * the worker can act on land here; freeform extensions belong in
16
- * `metadata`.
13
+ * `envVars` is the customer-controlled key/value bag delivered into the
14
+ * container via the mounted `RUNTIME.env` / `RUNTIME.json` files (the
15
+ * Anthropic session API does NOT expose a process env-vars knob today
16
+ * — verified by reading the `/v1/environments` config shape). The same
17
+ * keys become `__KEY__` substitution targets in agent-facing markdown
18
+ * inside skill / agentsmd / file bundles. Antpath-set runtime keys use
19
+ * the reserved `ANTPATH_*` prefix; customer keys MUST NOT collide with
20
+ * that prefix.
17
21
  */
18
- export interface PlatformTemplateEnvironment {
19
- readonly networking?: PlatformTemplateNetworking;
20
- readonly packages?: readonly PlatformTemplatePackage[];
22
+ export interface PlatformEnvironment {
23
+ readonly networking?: PlatformNetworking;
24
+ readonly packages?: readonly PlatformPackage[];
25
+ readonly envVars?: Readonly<Record<string, string>>;
21
26
  }
22
- export interface PlatformTemplateNetworking {
27
+ /**
28
+ * Reserved prefix for antpath-set runtime env vars (`ANTPATH_OUTPUTS`,
29
+ * `ANTPATH_CLI`, …). Customer `environment.envVars` keys carrying this
30
+ * prefix are rejected at submission parse time so platform-set values
31
+ * cannot be silently overwritten.
32
+ */
33
+ export declare const ANTPATH_RESERVED_ENV_PREFIX = "ANTPATH_";
34
+ /**
35
+ * Maximum number of `environment.envVars` entries accepted per
36
+ * submission. Picked to be generous for real customer config bags
37
+ * (the broll case ships a handful — `BROLL_STORE`, `BROLL_OUTPUTS`,
38
+ * `BROLL_MODE`, …) while still bounding the size of every RUNTIME
39
+ * file we mount into the container.
40
+ */
41
+ export declare const ENV_VARS_MAX_ENTRIES = 64;
42
+ /** Maximum byte length of a single `environment.envVars` value. */
43
+ export declare const ENV_VARS_MAX_VALUE_BYTES = 4096;
44
+ /** Maximum total byte length of all `environment.envVars` keys+values combined. */
45
+ export declare const ENV_VARS_MAX_TOTAL_BYTES = 65536;
46
+ export interface PlatformNetworking {
23
47
  readonly mode: "limited" | "open";
24
48
  /** Lowercase host names. The worker always appends the proxy host. */
25
49
  readonly allowedHosts?: readonly string[];
26
50
  }
27
- export interface PlatformTemplatePackage {
51
+ export interface PlatformPackage {
28
52
  readonly name: string;
29
53
  readonly version?: string;
30
54
  }
31
- export interface PlatformTemplateSubmission {
32
- readonly name: string;
33
- readonly model: string;
34
- readonly templateHash: string;
35
- readonly system?: string;
36
- readonly messages: readonly string[];
37
- readonly metadata?: Record<string, JsonValue>;
38
- readonly environment?: PlatformTemplateEnvironment;
39
- }
40
- export type PlatformClaudeSessionCleanup = "retain" | "delete";
41
55
  export type PlatformSessionCleanup = "retain" | "delete";
42
56
  export interface PlatformCleanupPolicy {
43
57
  readonly session?: PlatformSessionCleanup;
44
- /** @deprecated use `session` instead. Accepted for one release for back-compat. */
45
- readonly claudeSession?: PlatformClaudeSessionCleanup;
46
58
  }
47
59
  export interface PlatformAnthropicSecrets {
48
60
  readonly apiKey: string;
49
61
  readonly baseUrl?: string;
50
62
  }
63
+ export interface PlatformDeepseekSecrets {
64
+ readonly apiKey: string;
65
+ readonly baseUrl?: string;
66
+ }
67
+ export interface PlatformOpenAISecrets {
68
+ readonly apiKey: string;
69
+ readonly baseUrl?: string;
70
+ }
71
+ export interface PlatformGeminiSecrets {
72
+ readonly apiKey: string;
73
+ readonly baseUrl?: string;
74
+ }
75
+ export interface PlatformMistralSecrets {
76
+ readonly apiKey: string;
77
+ readonly baseUrl?: string;
78
+ }
79
+ /**
80
+ * Run-time provider selector. Antpath exposes one customer interface
81
+ * for every provider; the runtime that backs each provider is decided
82
+ * by {@link selectRuntime}.
83
+ *
84
+ * - `anthropic` — defaults to the Anthropic Native runtime (Anthropic
85
+ * Managed Agents API). Customers can opt into the
86
+ * Goose Managed runtime via `runtime: "managed"`.
87
+ * - `deepseek` | `openai` | `gemini` | `mistral` — only the Goose
88
+ * Managed runtime is supported (LiteLLM-gateway'd
89
+ * call into the upstream).
90
+ *
91
+ * See `references/platform-rebuild-2026.md`.
92
+ */
93
+ export declare const RUN_PROVIDERS: readonly ["anthropic", "deepseek", "openai", "gemini", "mistral"];
94
+ export type RunProvider = (typeof RUN_PROVIDERS)[number];
95
+ export declare const DEFAULT_RUN_PROVIDER: RunProvider;
96
+ /**
97
+ * Customer-facing runtime selector. Optional on the wire — absent means
98
+ * "let the dispatcher route based on provider" ({@link selectRuntime}).
99
+ *
100
+ * - `native` — Anthropic Native runtime. Only valid for
101
+ * `provider: "anthropic"`. Routes through Anthropic's
102
+ * Managed Agents API.
103
+ * - `managed` — Goose Managed runtime. The only option for
104
+ * non-Anthropic providers; also available as an opt-out
105
+ * for `provider: "anthropic"` when the customer wants
106
+ * cross-provider parity.
107
+ *
108
+ * Stored verbatim in `runs.runtime`. See
109
+ * `references/platform-rebuild-2026.md` (Runtime dispatcher logic).
110
+ */
111
+ export declare const RUNTIME_KINDS: readonly ["native", "managed"];
112
+ export type RuntimeKind = (typeof RUNTIME_KINDS)[number];
113
+ /**
114
+ * Providers whose runtime is implemented by Anthropic Native. Every
115
+ * other provider in {@link RUN_PROVIDERS} routes through Goose Managed.
116
+ * Kept as a constant so the dispatcher logic and the validation tests
117
+ * share one source of truth.
118
+ */
119
+ export declare const NATIVE_RUNTIME_PROVIDERS: readonly ["anthropic"];
120
+ export type NativeRuntimeProvider = (typeof NATIVE_RUNTIME_PROVIDERS)[number];
51
121
  export interface PlatformMcpServerSecret {
52
122
  readonly name: string;
53
123
  readonly url: string;
54
124
  readonly headers?: Record<string, string>;
55
125
  }
56
- export interface PlatformSkillReference {
57
- readonly skillId: string;
58
- readonly version?: string;
59
- }
60
126
  /**
61
127
  * Per-run auth value for a declared proxy endpoint. The `name` must
62
128
  * match a `proxyEndpoints[i].name` in the same submission, and `value`'s
@@ -81,10 +147,23 @@ export type PlatformProxyAuthValue = {
81
147
  readonly type: "query";
82
148
  readonly value: string;
83
149
  };
150
+ /**
151
+ * Per-run inline secrets bundle. Exactly one of `anthropic` | `deepseek`
152
+ * | `openai` | `gemini` | `mistral` is required, matching the run's
153
+ * `provider`; the cross-provider coupling is enforced in
154
+ * `parseRunSubmissionRequest` so the wire shape stays simple and
155
+ * individual provider keys remain optional in the type system.
156
+ * `mcpServers` and `proxyEndpointAuth` are cross-provider (an MCP
157
+ * credential is the same secret whether Anthropic or another model is
158
+ * driving the MCP client).
159
+ */
84
160
  export interface PlatformInlineSecrets {
85
- readonly anthropic: PlatformAnthropicSecrets;
161
+ readonly anthropic?: PlatformAnthropicSecrets;
162
+ readonly deepseek?: PlatformDeepseekSecrets;
163
+ readonly openai?: PlatformOpenAISecrets;
164
+ readonly gemini?: PlatformGeminiSecrets;
165
+ readonly mistral?: PlatformMistralSecrets;
86
166
  readonly mcpServers?: readonly PlatformMcpServerSecret[];
87
- readonly skills?: readonly PlatformSkillReference[];
88
167
  readonly proxyEndpointAuth?: readonly PlatformProxyEndpointAuth[];
89
168
  }
90
169
  /**
@@ -111,37 +190,6 @@ export interface PlatformProxyEndpoint {
111
190
  readonly perCallBudget?: number;
112
191
  readonly responseByteBudget?: number;
113
192
  }
114
- export interface PlatformRunSubmissionRequest {
115
- readonly workspaceId: string;
116
- readonly idempotencyKey: string;
117
- readonly template: PlatformTemplateSubmission;
118
- readonly variables?: Record<string, JsonValue>;
119
- readonly cleanup?: PlatformCleanupPolicy;
120
- readonly secrets: PlatformInlineSecrets;
121
- /**
122
- * Declared HTTP endpoints reachable via the antpath managed proxy
123
- * during this run. Empty array (or omitted) → no proxy surface is
124
- * provisioned; the per-run manifest the CLI reads
125
- * (`/mnt/session/uploads/antpath/index.json` in-container) shows
126
- * `endpoints: []` and the `run-token` mount is omitted.
127
- */
128
- readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
129
- }
130
- /**
131
- * Wire shape posted by the SDK and CLI. `workspaceId` is **omitted by
132
- * design** — token-authenticated clients never name the workspace
133
- * because it is derived from their API token on the server. The BFF
134
- * route resolves the workspace from the token and injects it before
135
- * calling `parseRunSubmissionRequest`. The dashboard UI (Auth.js user
136
- * principal, multi-workspace) is the only caller that supplies
137
- * `workspaceId` itself.
138
- *
139
- * See `references/development-principles.md` (Agent-first surface
140
- * design, Concrete rule 3).
141
- */
142
- export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "workspaceId"> & {
143
- readonly workspaceId?: string;
144
- };
145
193
  /**
146
194
  * Default caps for a proxy endpoint when the submission doesn't specify
147
195
  * one. Conservative on purpose. Operators can override the platform-
@@ -156,7 +204,6 @@ export declare const PROXY_ENDPOINT_DEFAULTS: {
156
204
  readonly perCallBudget: 60;
157
205
  readonly responseByteBudget: number;
158
206
  };
159
- export declare function parseRunSubmissionRequest(input: unknown): PlatformRunSubmissionRequest;
160
207
  /**
161
208
  * Wire-level submission posted to /api/runs in the flat surface. The
162
209
  * `prompt` is always an array internally so the worker, the audit log,
@@ -168,7 +215,7 @@ export declare function parseRunSubmissionRequest(input: unknown): PlatformRunSu
168
215
  * `skill_bundles.id` (validated by the BFF before acceptance and pinned
169
216
  * into `run_skill_snapshots`), provider refs pass through unchanged.
170
217
  */
171
- export interface PlatformFlatSubmission {
218
+ export interface PlatformSubmission {
172
219
  readonly model: string;
173
220
  readonly system?: string;
174
221
  readonly prompt: readonly string[];
@@ -176,7 +223,7 @@ export interface PlatformFlatSubmission {
176
223
  readonly agentsMd: readonly AgentsMdRef[];
177
224
  readonly files: readonly FileRef[];
178
225
  readonly mcpServers: readonly McpServerRef[];
179
- readonly environment?: PlatformTemplateEnvironment;
226
+ readonly environment?: PlatformEnvironment;
180
227
  readonly metadata?: Record<string, JsonValue>;
181
228
  /**
182
229
  * Opt-in container paths to capture as `output_objects` at session
@@ -199,23 +246,124 @@ export interface PlatformFlatSubmission {
199
246
  * the idempotency hash and the run snapshot.
200
247
  */
201
248
  readonly outputDirs?: readonly string[];
249
+ /**
250
+ * Optional override for the Goose builtin extensions enabled inside
251
+ * the runner container. Each entry is the bare name accepted by
252
+ * `goose run --with-builtin <NAME>` (see Goose v1.34.1's
253
+ * `crates/goose-cli/src/cli.rs` `with-builtin` flag). The platform
254
+ * default is `["developer"]` which gives the agent shell + write +
255
+ * edit + tree tools (bash, grep via shell, file read via shell or
256
+ * editor, file edit). To opt in to more tools (e.g. web search via
257
+ * the `computercontroller` extension), pass the full list. To opt
258
+ * out of all builtins (pure-MCP setup), pass an empty array.
259
+ *
260
+ * Validation:
261
+ * - Each entry matches /^[a-z][a-z0-9_-]{0,63}$/ (Goose builtin
262
+ * naming convention).
263
+ * - Max 16 entries.
264
+ * - Deduplicated.
265
+ *
266
+ * Anthropic Native runs ignore this field (they don't spawn Goose);
267
+ * the dispatcher accepts and persists it for snapshot fidelity but
268
+ * the Anthropic Native adapter never reads it.
269
+ */
270
+ readonly builtins?: readonly string[];
202
271
  }
203
- export interface PlatformFlatRunSubmissionRequest {
272
+ export interface PlatformRunSubmissionRequest {
204
273
  readonly workspaceId: string;
205
274
  readonly idempotencyKey: string;
206
- readonly submission: PlatformFlatSubmission;
275
+ /**
276
+ * Provider selector. Always populated after parsing — absent on the
277
+ * wire means {@link DEFAULT_RUN_PROVIDER}. The runtime selector
278
+ * ({@link selectRuntime}) decides which Workflow class the run is
279
+ * dispatched to. See `references/platform-rebuild-2026.md`.
280
+ */
281
+ readonly provider: RunProvider;
282
+ /**
283
+ * Customer's explicit runtime choice. `undefined` (the default) lets
284
+ * {@link selectRuntime} auto-route based on `provider`. When set,
285
+ * `parseRunSubmissionRequest` already verified that the choice is
286
+ * compatible with `provider`; the dispatcher still re-validates
287
+ * feature compatibility before enqueueing.
288
+ */
289
+ readonly runtime?: RuntimeKind;
290
+ readonly submission: PlatformSubmission;
207
291
  readonly cleanup?: PlatformCleanupPolicy;
208
292
  readonly secrets: PlatformInlineSecrets;
209
293
  readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
210
294
  }
211
295
  /**
212
- * Same `workspaceId is optional` rule as the template-path
213
- * `PlatformRunSubmissionInput`: token-authenticated clients leave it
214
- * out, the BFF route injects it from the token before invoking the
215
- * parser. Dashboard UI callers (Auth.js user principal) pass it
216
- * explicitly.
296
+ * Wire shape posted by the SDK and CLI. `workspaceId` is **omitted by
297
+ * design** token-authenticated clients never name the workspace
298
+ * because it is derived from their API token on the server. The BFF
299
+ * route resolves the workspace from the token and injects it before
300
+ * calling the parser. The dashboard UI (Auth.js user principal,
301
+ * multi-workspace) is the only caller that supplies `workspaceId`
302
+ * itself.
303
+ *
304
+ * `provider` is also optional on the wire — absent means
305
+ * {@link DEFAULT_RUN_PROVIDER} (`anthropic`). The parser fills it in
306
+ * before the value enters the run snapshot. See
307
+ * `references/development-principles.md` (Agent-first surface design,
308
+ * Concrete rule 3) and `references/deepseek-runtime-mcp-plan.md`.
217
309
  */
218
- export type PlatformFlatRunSubmissionInput = Omit<PlatformFlatRunSubmissionRequest, "workspaceId"> & {
310
+ export type PlatformRunSubmissionInput = Omit<PlatformRunSubmissionRequest, "workspaceId" | "provider" | "runtime"> & {
219
311
  readonly workspaceId?: string;
312
+ readonly provider?: RunProvider;
313
+ /**
314
+ * Optional runtime opt-out. Set `"managed"` to force the Goose
315
+ * Managed runtime (rejects features that only work natively).
316
+ * `"native"` is only valid when `provider === "anthropic"`.
317
+ * Absent = auto-route. See {@link selectRuntime}.
318
+ */
319
+ readonly runtime?: RuntimeKind;
220
320
  };
221
- export declare function parseFlatRunSubmissionRequest(input: unknown): PlatformFlatRunSubmissionRequest;
321
+ export declare function parseRunSubmissionRequest(input: unknown): PlatformRunSubmissionRequest;
322
+ /**
323
+ * Codes the dispatcher emits when a submission can't be served by the
324
+ * selected runtime. Surfaced both at parse time (cross-field shape
325
+ * mismatch) and at dispatch time (feature mismatch). Code values are
326
+ * stable so dashboard / SDK error rendering can branch on them.
327
+ */
328
+ export declare const RUNTIME_VALIDATION_CODES: readonly ["runtime_native_unsupported", "feature_runtime_mismatch"];
329
+ export type RuntimeValidationCode = (typeof RUNTIME_VALIDATION_CODES)[number];
330
+ /**
331
+ * Thrown by `parseRunSubmissionRequest` (wire-shape mismatch) and by
332
+ * `selectRuntime` (feature mismatch) when the submitted run cannot be
333
+ * served by the chosen runtime. The `code` field is part of the public
334
+ * contract — keep it stable when phrasings change.
335
+ */
336
+ export declare class RuntimeValidationError extends Error {
337
+ readonly code: RuntimeValidationCode;
338
+ constructor(code: RuntimeValidationCode, message: string);
339
+ }
340
+ /**
341
+ * Walk the parsed submission and collect every feature that **only**
342
+ * works on the Anthropic Native runtime. Today the only such feature
343
+ * is a provider built-in skill ref (`Skill.provider(...)` — the
344
+ * Anthropic Skills API is the resolver). Adding a new native-only
345
+ * feature means extending this function AND the matching error string
346
+ * in {@link selectRuntime}.
347
+ *
348
+ * Exported because Phase 5's runtime dispatcher route handler reuses
349
+ * it to format the API error body and the dashboard reuses it to point
350
+ * the user at the offending submission field.
351
+ */
352
+ export declare function collectNativeOnlyFeatures(req: PlatformRunSubmissionRequest): string[];
353
+ /**
354
+ * The runtime dispatcher. Pure function with no I/O — call it after
355
+ * `parseRunSubmissionRequest` to decide which Workflow class consumes
356
+ * the run.
357
+ *
358
+ * 1. If the customer set `runtime` explicitly, validate that choice
359
+ * against the submission's provider and feature set. Reject with
360
+ * a typed error on mismatch — no silent re-routing.
361
+ * 2. Otherwise auto-route: `provider: "anthropic"` → `"native"` (the
362
+ * cheapest + fastest path for Anthropic runs); everything else →
363
+ * `"managed"`.
364
+ *
365
+ * Returns the resolved {@link RuntimeKind}; the Workflow dispatcher
366
+ * (Phase 5) maps that 1:1 to the matching `WorkflowEntrypoint` class.
367
+ * See `references/platform-rebuild-2026.md` (Runtime dispatcher logic).
368
+ */
369
+ export declare function selectRuntime(req: PlatformRunSubmissionRequest): RuntimeKind;