antpath 0.1.1 → 0.2.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 +40 -4
- package/dist/client.js +4 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/client.d.ts +138 -7
- package/dist/platform/client.js +98 -2
- package/dist/platform/client.js.map +1 -1
- package/dist/providers/known-events.d.ts +60 -0
- package/dist/providers/known-events.js +64 -0
- package/dist/providers/known-events.js.map +1 -0
- package/dist/run/controller.d.ts +4 -1
- package/dist/run/controller.js +103 -13
- package/dist/run/controller.js.map +1 -1
- package/dist/template/index.d.ts +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/utils/events.d.ts +21 -0
- package/dist/utils/events.js +97 -18
- package/dist/utils/events.js.map +1 -1
- package/docs/credentials.md +84 -2
- package/docs/events.md +129 -0
- package/docs/skills.md +2 -0
- package/package.json +1 -1
- package/references/architecture-decisions.md +110 -64
- package/references/implementation-plan.md +66 -44
package/README.md
CHANGED
|
@@ -6,12 +6,30 @@ title: antpath
|
|
|
6
6
|
|
|
7
7
|
antpath is a TypeScript-first SDK for running autonomous Claude Managed Agents sessions from code-defined, secret-free Templates.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Everything ships from a single import path:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {
|
|
13
|
+
AntpathClient, // direct in-process Claude runs (caller-held key)
|
|
14
|
+
AntpathPlatformClient, // submit durable runs to an antpath dashboard
|
|
15
|
+
defineTemplate,
|
|
16
|
+
string,
|
|
17
|
+
validateProxyAuth // helper for per-run proxy endpoint auth
|
|
18
|
+
} from "antpath";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
There is no `antpath/platform`, `antpath/proxy`, or other sub-path. The two
|
|
22
|
+
clients are distinct classes for distinct use cases but live behind the same
|
|
23
|
+
single agent-visible surface — see [Agent-first surface design](../../references/development-principles.md#agent-first-surface-design).
|
|
24
|
+
|
|
25
|
+
- **Direct (`AntpathClient`)** — runs Claude in your own process with a caller-held key. This README covers the direct surface.
|
|
26
|
+
- **Platform (`AntpathPlatformClient`)** — submits durable runs to an antpath dashboard. Every submission carries an inline `secrets` bundle (Anthropic key, optional MCP credentials, optional skill references, and optional per-run proxy endpoint auth); the dashboard vaults the bundle for the lifetime of one run and deletes it at cleanup. Per-run named secrets accessed through the managed HTTP proxy are declared via the `proxyEndpoints` submission field and authenticated via `secrets.proxyEndpointAuth` — see [Credentials](docs/credentials.md). The same npm package also ships the `antpath` CLI as its `bin` entry; the worker mounts that CLI at `/antpath/antpath` in every run for skills to invoke (`node /antpath/antpath proxy …`).
|
|
27
|
+
|
|
28
|
+
## MVP boundaries (direct SDK)
|
|
10
29
|
|
|
11
|
-
- SDK-only.
|
|
12
30
|
- Claude Managed Agents only.
|
|
13
|
-
- Caller-held provider key.
|
|
14
|
-
- No
|
|
31
|
+
- Caller-held provider key — the direct SDK never persists keys.
|
|
32
|
+
- No SDK-side storage of provider keys, MCP credentials, or output file contents.
|
|
15
33
|
- Manual cleanup by default.
|
|
16
34
|
|
|
17
35
|
## Quickstart
|
|
@@ -43,6 +61,23 @@ await handle.downloadOutputs("./outputs");
|
|
|
43
61
|
await handle.cleanup();
|
|
44
62
|
```
|
|
45
63
|
|
|
64
|
+
Observe events live by passing `onEvent` in `RunOptions`:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const handle = await client.run(template, {
|
|
68
|
+
onEvent: (event) => {
|
|
69
|
+
if (event.type === "provider.event") {
|
|
70
|
+
// event.event is a ProviderEvent (raw type stays `unknown`).
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
await handle.wait();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
By the time `wait()` returns, every `onEvent` invocation triggered before
|
|
78
|
+
terminal status has settled. See [Events](docs/events.md) for the full
|
|
79
|
+
contract and a list of typed helpers.
|
|
80
|
+
|
|
46
81
|
## Test commands
|
|
47
82
|
|
|
48
83
|
```text
|
|
@@ -61,6 +96,7 @@ Unit tests are deterministic and may use fakes or sanitized recorded snapshots.
|
|
|
61
96
|
- [MCP](docs/mcp.md)
|
|
62
97
|
- [Skills](docs/skills.md)
|
|
63
98
|
- [Outputs](docs/outputs.md)
|
|
99
|
+
- [Events](docs/events.md)
|
|
64
100
|
- [Cleanup](docs/cleanup.md)
|
|
65
101
|
- [Testing](docs/testing.md)
|
|
66
102
|
- [Release](docs/release.md)
|
package/dist/client.js
CHANGED
|
@@ -27,7 +27,10 @@ export class AntpathClient {
|
|
|
27
27
|
cleanupPolicy: options.cleanupPolicy ?? this.#cleanupPolicy,
|
|
28
28
|
timeoutMs: options.timeoutMs,
|
|
29
29
|
signal: options.signal,
|
|
30
|
-
logger: options.logger
|
|
30
|
+
logger: options.logger,
|
|
31
|
+
onEvent: options.onEvent,
|
|
32
|
+
onEventAbortOnError: options.onEventAbortOnError ?? false,
|
|
33
|
+
sessionResources: options.sessionResources ?? []
|
|
31
34
|
});
|
|
32
35
|
await controller.start();
|
|
33
36
|
return controller;
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAWzD,MAAM,OAAO,aAAa;IACf,SAAS,CAAuB;IAChC,cAAc,CAAgB;IAEvC,YAAY,OAA6B;QACvC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpC,CAAC;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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { AntpathClient } from "./client.js";
|
|
2
|
-
export { AntpathPlatformClient, PlatformApiError } from "./platform/index.js";
|
|
2
|
+
export { AntpathPlatformClient, PlatformApiError, validateProxyAuth, buildPlatformAllowedHosts, resetDefaultSecretsDeprecationWarning } from "./platform/index.js";
|
|
3
|
+
export type { PlatformEvent, PlatformOutput, PlatformRun, SignedOutputLink, PlatformInlineSecrets, PlatformRunSubmissionRequest, PlatformProxyEndpoint, PlatformProxyEndpointAuth, PlatformProxyAuthShape, PlatformProxyMethod, PlatformProxyResponseMode, AntpathPlatformClientOptions } from "./platform/index.js";
|
|
3
4
|
export { AnthropicManagedAgentsProvider } from "./providers/anthropic/provider.js";
|
|
4
5
|
export type { ManagedAgentProvider, ProviderSkillRef, SessionResourceInput, UploadFileInput } from "./providers/types.js";
|
|
5
|
-
export
|
|
6
|
-
export { compileTemplate, defineTemplate, requiredOAuthAccessToken, requiredStaticBearer, string, type TemplateDefinition, type TemplateVariableDefinition } from "./template/index.js";
|
|
7
|
-
export type { CleanupPolicy, CleanupResult, CredentialInput, DownloadOutputsOptions, DownloadOutputsResult, Logger, OutputManifest, ProviderEvent, ProviderFile, ProviderResourceIds, RunEvent, RunHandle, RunOptions, RunResult, RunStatus, UsageSummary } from "./types.js";
|
|
6
|
+
export { isAgentEvent, isAgentCustomToolUse, isAgentMcpToolResult, isAgentMcpToolUse, isAgentMessage, isAgentThinking, isAgentToolResult, isAgentToolUse, isSessionError, isSessionEvent, isSessionStatusIdle, isSessionStatusRescheduled, isSessionStatusRunning, isSessionStatusTerminated, isSpanEvent, isUserEvent, isUserMessage } from "./providers/known-events.js";
|
|
7
|
+
export { compileTemplate, defineTemplate, requiredOAuthAccessToken, requiredStaticBearer, string, type EnvironmentDefinition, type ResolvedTemplate, type TemplateDefinition, type TemplateVariableDefinition } from "./template/index.js";
|
|
8
|
+
export type { CleanupPolicy, CleanupResult, CredentialInput, DownloadOutputsOptions, DownloadOutputsResult, Logger, OutputManifest, ProviderEvent, ProviderFile, ProviderResourceIds, RunEvent, RunEventHandler, RunHandle, RunOptions, RunResult, RunStatus, SessionResourceUpload, UsageSummary } from "./types.js";
|
|
8
9
|
export { SecretString, redactSecrets } from "./utils/secrets.js";
|
|
9
10
|
export { AntpathError, CleanupError, CredentialValidationError, ProviderError, RunStateError, TemplateValidationError } from "./errors.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AntpathClient } from "./client.js";
|
|
2
|
-
export { AntpathPlatformClient, PlatformApiError } from "./platform/index.js";
|
|
2
|
+
export { AntpathPlatformClient, PlatformApiError, validateProxyAuth, buildPlatformAllowedHosts, resetDefaultSecretsDeprecationWarning } from "./platform/index.js";
|
|
3
3
|
export { AnthropicManagedAgentsProvider } from "./providers/anthropic/provider.js";
|
|
4
|
+
export { isAgentEvent, isAgentCustomToolUse, isAgentMcpToolResult, isAgentMcpToolUse, isAgentMessage, isAgentThinking, isAgentToolResult, isAgentToolUse, isSessionError, isSessionEvent, isSessionStatusIdle, isSessionStatusRescheduled, isSessionStatusRunning, isSessionStatusTerminated, isSpanEvent, isUserEvent, isUserMessage } from "./providers/known-events.js";
|
|
4
5
|
export { compileTemplate, defineTemplate, requiredOAuthAccessToken, requiredStaticBearer, string } from "./template/index.js";
|
|
5
6
|
export { SecretString, redactSecrets } from "./utils/secrets.js";
|
|
6
7
|
export { AntpathError, CleanupError, CredentialValidationError, ProviderError, RunStateError, TemplateValidationError } from "./errors.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,yBAAyB,EACzB,qCAAqC,EACtC,MAAM,qBAAqB,CAAC;AAe7B,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,eAAe,EACf,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,MAAM,EAKP,MAAM,qBAAqB,CAAC;AAqB7B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,yBAAyB,EACzB,aAAa,EACb,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAC"}
|
|
@@ -11,28 +11,124 @@ export interface PlatformTemplateSubmission {
|
|
|
11
11
|
readonly messages: readonly string[];
|
|
12
12
|
readonly metadata?: Record<string, PlatformJsonValue>;
|
|
13
13
|
}
|
|
14
|
-
export interface PlatformOutputPolicy {
|
|
15
|
-
readonly capture: boolean;
|
|
16
|
-
readonly globs?: readonly string[];
|
|
17
|
-
}
|
|
18
14
|
export type PlatformClaudeSessionCleanup = "retain" | "delete";
|
|
19
15
|
export interface PlatformCleanupPolicy {
|
|
16
|
+
readonly session?: PlatformClaudeSessionCleanup;
|
|
20
17
|
readonly claudeSession?: PlatformClaudeSessionCleanup;
|
|
21
18
|
}
|
|
19
|
+
export interface PlatformAnthropicSecrets {
|
|
20
|
+
readonly apiKey: string;
|
|
21
|
+
readonly baseUrl?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PlatformMcpServerSecret {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly url: string;
|
|
26
|
+
readonly headers?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
export interface PlatformSkillReference {
|
|
29
|
+
readonly skillId: string;
|
|
30
|
+
readonly version?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface PlatformInlineSecrets {
|
|
33
|
+
readonly anthropic: PlatformAnthropicSecrets;
|
|
34
|
+
readonly mcpServers?: readonly PlatformMcpServerSecret[];
|
|
35
|
+
readonly skills?: readonly PlatformSkillReference[];
|
|
36
|
+
/**
|
|
37
|
+
* Auth values for proxy endpoints declared at the top level of the
|
|
38
|
+
* submission. Each entry's `name` must match a declared
|
|
39
|
+
* `proxyEndpoints[i].name` and its `value.type` must match the
|
|
40
|
+
* declared `authShape.type`. Validate eagerly with
|
|
41
|
+
* {@link validateProxyAuth}.
|
|
42
|
+
*/
|
|
43
|
+
readonly proxyEndpointAuth?: readonly PlatformProxyEndpointAuth[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Structural description of how the upstream endpoint expects auth.
|
|
47
|
+
* The actual value lives in {@link PlatformProxyEndpointAuth.value} and
|
|
48
|
+
* is supplied separately so it never enters the idempotency hash.
|
|
49
|
+
*/
|
|
50
|
+
export type PlatformProxyAuthShape = {
|
|
51
|
+
readonly type: "bearer";
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "basic";
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "header";
|
|
56
|
+
readonly name: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly type: "query";
|
|
59
|
+
readonly name: string;
|
|
60
|
+
};
|
|
61
|
+
export type PlatformProxyMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
62
|
+
export type PlatformProxyResponseMode = "full" | "status_only" | "headers_only";
|
|
63
|
+
export interface PlatformProxyEndpoint {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
readonly baseUrl: string;
|
|
66
|
+
readonly authShape: PlatformProxyAuthShape;
|
|
67
|
+
readonly allowMethods: readonly PlatformProxyMethod[];
|
|
68
|
+
readonly allowPathPrefixes: readonly string[];
|
|
69
|
+
readonly allowHeaders?: readonly string[];
|
|
70
|
+
readonly responseMode?: PlatformProxyResponseMode;
|
|
71
|
+
readonly maxRequestBytes?: number;
|
|
72
|
+
readonly maxResponseBytes?: number;
|
|
73
|
+
readonly timeoutMs?: number;
|
|
74
|
+
readonly perCallBudget?: number;
|
|
75
|
+
readonly responseByteBudget?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface PlatformProxyEndpointAuth {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly value: {
|
|
80
|
+
readonly type: "bearer";
|
|
81
|
+
readonly token: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: "basic";
|
|
84
|
+
readonly username: string;
|
|
85
|
+
readonly password: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly type: "header";
|
|
88
|
+
readonly value: string;
|
|
89
|
+
} | {
|
|
90
|
+
readonly type: "query";
|
|
91
|
+
readonly value: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Submission shape accepted by `AntpathPlatformClient.submitRun`. The `secrets`
|
|
96
|
+
* block may be omitted at the call site if a client-level default was provided
|
|
97
|
+
* to the constructor; the merged value is always sent on the wire.
|
|
98
|
+
*/
|
|
22
99
|
export interface PlatformRunSubmissionRequest {
|
|
23
100
|
readonly workspaceId: string;
|
|
24
|
-
readonly providerConnectionId: string;
|
|
25
101
|
readonly idempotencyKey: string;
|
|
26
102
|
readonly template: PlatformTemplateSubmission;
|
|
27
103
|
readonly variables?: Record<string, PlatformJsonValue>;
|
|
28
|
-
readonly credentialReferences?: Record<string, string>;
|
|
29
|
-
readonly output?: PlatformOutputPolicy;
|
|
30
104
|
readonly cleanup?: PlatformCleanupPolicy;
|
|
105
|
+
readonly secrets?: PlatformInlineSecrets;
|
|
106
|
+
/**
|
|
107
|
+
* HTTP endpoints reachable via the antpath managed proxy during this
|
|
108
|
+
* run. Each entry declares the policy (URL, allow lists, caps); the
|
|
109
|
+
* corresponding auth value goes in
|
|
110
|
+
* `secrets.proxyEndpointAuth[i]` with a matching `name`.
|
|
111
|
+
*
|
|
112
|
+
* Empty / omitted → no proxy surface is provisioned (the in-container
|
|
113
|
+
* `/antpath/index.json` reports `endpoints: []`).
|
|
114
|
+
*/
|
|
115
|
+
readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
|
|
31
116
|
}
|
|
32
117
|
export interface AntpathPlatformClientOptions {
|
|
33
118
|
readonly baseUrl: string;
|
|
34
119
|
readonly apiToken: string;
|
|
35
120
|
readonly fetch?: FetchLike;
|
|
121
|
+
/**
|
|
122
|
+
* Optional default secrets applied to every submission that does not
|
|
123
|
+
* override the `secrets` block per-call.
|
|
124
|
+
*
|
|
125
|
+
* @deprecated The agent-first invariant requires every secret-bearing
|
|
126
|
+
* field to be visible at the call site. Pass `secrets` explicitly on
|
|
127
|
+
* each `submitRun` call instead; this option will be removed in a
|
|
128
|
+
* future release. See
|
|
129
|
+
* `references/development-principles.md` (Agent-first surface design).
|
|
130
|
+
*/
|
|
131
|
+
readonly defaultSecrets?: PlatformInlineSecrets;
|
|
36
132
|
}
|
|
37
133
|
export interface PlatformRun {
|
|
38
134
|
readonly id: string;
|
|
@@ -60,6 +156,7 @@ export declare class AntpathPlatformClient {
|
|
|
60
156
|
private readonly baseUrl;
|
|
61
157
|
private readonly apiToken;
|
|
62
158
|
private readonly fetchImpl;
|
|
159
|
+
private readonly defaultSecrets?;
|
|
63
160
|
constructor(options: AntpathPlatformClientOptions);
|
|
64
161
|
submitRun(request: PlatformRunSubmissionRequest): Promise<PlatformRun>;
|
|
65
162
|
getRun(workspaceId: string, runId: string): Promise<PlatformRun>;
|
|
@@ -70,4 +167,38 @@ export declare class AntpathPlatformClient {
|
|
|
70
167
|
deleteRun(workspaceId: string, runId: string): Promise<void>;
|
|
71
168
|
private request;
|
|
72
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Test-only: reset the "warn once" guard for the `defaultSecrets`
|
|
172
|
+
* deprecation message. Production code should not call this.
|
|
173
|
+
*
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export declare function resetDefaultSecretsDeprecationWarning(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Cross-validate a `proxyEndpoints` policy list against a
|
|
179
|
+
* `secrets.proxyEndpointAuth` value list. Throws on the first
|
|
180
|
+
* mismatch with an actionable, field-named error message.
|
|
181
|
+
*
|
|
182
|
+
* Mirrors the BFF's authoritative validator so misconfigured
|
|
183
|
+
* submissions fail fast in the SDK before going over the wire. Use it
|
|
184
|
+
* directly in tests or wrappers — `submitRun` already invokes it when
|
|
185
|
+
* `proxyEndpoints` is non-empty.
|
|
186
|
+
*/
|
|
187
|
+
export declare function validateProxyAuth(endpoints: readonly PlatformProxyEndpoint[], auth: readonly PlatformProxyEndpointAuth[] | undefined): void;
|
|
188
|
+
/**
|
|
189
|
+
* Build an `allowedHosts` list for `environment.network` that includes
|
|
190
|
+
* the antpath proxy host (and optionally Anthropic's MCP host) when
|
|
191
|
+
* the caller is hand-rolling networking. The worker auto-injects the
|
|
192
|
+
* proxy host server-side when proxy endpoints are declared; use this
|
|
193
|
+
* helper when you also want client-side template validation parity
|
|
194
|
+
* (e.g. to assert at build time that a `limited` config can reach the
|
|
195
|
+
* surfaces you intended).
|
|
196
|
+
*
|
|
197
|
+
* The proxy host is derived from the dashboard URL. Pass the same
|
|
198
|
+
* value you used for the `AntpathPlatformClient` `baseUrl`.
|
|
199
|
+
*/
|
|
200
|
+
export declare function buildPlatformAllowedHosts(input: {
|
|
201
|
+
readonly dashboardBaseUrl: string;
|
|
202
|
+
readonly extraHosts?: readonly string[];
|
|
203
|
+
}): readonly string[];
|
|
73
204
|
export {};
|
package/dist/platform/client.js
CHANGED
|
@@ -12,10 +12,11 @@ export class AntpathPlatformClient {
|
|
|
12
12
|
baseUrl;
|
|
13
13
|
apiToken;
|
|
14
14
|
fetchImpl;
|
|
15
|
+
defaultSecrets;
|
|
15
16
|
constructor(options) {
|
|
16
17
|
const record = options;
|
|
17
18
|
if ("anthropicApiKey" in record || "providerApiKey" in record) {
|
|
18
|
-
throw new Error("Platform client does not accept provider keys");
|
|
19
|
+
throw new Error("Platform client does not accept provider keys at the client root — pass them inside `defaultSecrets.anthropic` or per-call `secrets.anthropic`");
|
|
19
20
|
}
|
|
20
21
|
if (!options.apiToken) {
|
|
21
22
|
throw new Error("apiToken is required");
|
|
@@ -23,11 +24,26 @@ export class AntpathPlatformClient {
|
|
|
23
24
|
this.baseUrl = new URL(options.baseUrl.endsWith("/") ? options.baseUrl : `${options.baseUrl}/`);
|
|
24
25
|
this.apiToken = options.apiToken;
|
|
25
26
|
this.fetchImpl = options.fetch ?? fetch;
|
|
27
|
+
if (options.defaultSecrets) {
|
|
28
|
+
this.defaultSecrets = options.defaultSecrets;
|
|
29
|
+
emitDefaultSecretsDeprecationWarning();
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
async submitRun(request) {
|
|
33
|
+
const secrets = request.secrets ?? this.defaultSecrets;
|
|
34
|
+
if (!secrets) {
|
|
35
|
+
throw new Error("submitRun requires `secrets` either per-call or via `defaultSecrets` on the client");
|
|
36
|
+
}
|
|
37
|
+
if (request.proxyEndpoints && request.proxyEndpoints.length > 0) {
|
|
38
|
+
// Catch the most common mistake at submission time so the error
|
|
39
|
+
// doesn't only surface deep inside the BFF parser. The BFF still
|
|
40
|
+
// performs the same cross-validation authoritatively.
|
|
41
|
+
validateProxyAuth(request.proxyEndpoints, secrets.proxyEndpointAuth);
|
|
42
|
+
}
|
|
43
|
+
const payload = { ...request, secrets };
|
|
28
44
|
return this.request("/api/runs", {
|
|
29
45
|
method: "POST",
|
|
30
|
-
body: JSON.stringify(
|
|
46
|
+
body: JSON.stringify(payload)
|
|
31
47
|
});
|
|
32
48
|
}
|
|
33
49
|
async getRun(workspaceId, runId) {
|
|
@@ -104,4 +120,84 @@ function extractErrorMessage(body) {
|
|
|
104
120
|
function hasRun(input) {
|
|
105
121
|
return Boolean(input && typeof input === "object" && "run" in input);
|
|
106
122
|
}
|
|
123
|
+
let defaultSecretsWarned = false;
|
|
124
|
+
function emitDefaultSecretsDeprecationWarning() {
|
|
125
|
+
// Emit once per process to avoid log spam in long-running apps that
|
|
126
|
+
// construct many clients (e.g. one per workspace). Tests that need
|
|
127
|
+
// to observe the warning can reset the flag via
|
|
128
|
+
// {@link resetDefaultSecretsDeprecationWarning}.
|
|
129
|
+
if (defaultSecretsWarned)
|
|
130
|
+
return;
|
|
131
|
+
defaultSecretsWarned = true;
|
|
132
|
+
console.warn("[antpath] AntpathPlatformClientOptions.defaultSecrets is deprecated and will be removed in a future release. " +
|
|
133
|
+
"Pass `secrets` explicitly on every submitRun call so the active credentials are visible to the agent reading the call site.");
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Test-only: reset the "warn once" guard for the `defaultSecrets`
|
|
137
|
+
* deprecation message. Production code should not call this.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
export function resetDefaultSecretsDeprecationWarning() {
|
|
142
|
+
defaultSecretsWarned = false;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Cross-validate a `proxyEndpoints` policy list against a
|
|
146
|
+
* `secrets.proxyEndpointAuth` value list. Throws on the first
|
|
147
|
+
* mismatch with an actionable, field-named error message.
|
|
148
|
+
*
|
|
149
|
+
* Mirrors the BFF's authoritative validator so misconfigured
|
|
150
|
+
* submissions fail fast in the SDK before going over the wire. Use it
|
|
151
|
+
* directly in tests or wrappers — `submitRun` already invokes it when
|
|
152
|
+
* `proxyEndpoints` is non-empty.
|
|
153
|
+
*/
|
|
154
|
+
export function validateProxyAuth(endpoints, auth) {
|
|
155
|
+
const authList = auth ?? [];
|
|
156
|
+
const endpointNames = new Set(endpoints.map((e) => e.name));
|
|
157
|
+
const authNames = new Set();
|
|
158
|
+
for (const entry of authList) {
|
|
159
|
+
if (authNames.has(entry.name)) {
|
|
160
|
+
throw new Error(`secrets.proxyEndpointAuth contains duplicate name '${entry.name}'`);
|
|
161
|
+
}
|
|
162
|
+
authNames.add(entry.name);
|
|
163
|
+
if (!endpointNames.has(entry.name)) {
|
|
164
|
+
throw new Error(`secrets.proxyEndpointAuth[].name='${entry.name}' has no matching proxyEndpoints[].name`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
for (const endpoint of endpoints) {
|
|
168
|
+
const match = authList.find((a) => a.name === endpoint.name);
|
|
169
|
+
if (!match) {
|
|
170
|
+
throw new Error(`proxyEndpoints[].name='${endpoint.name}' is missing a matching secrets.proxyEndpointAuth entry`);
|
|
171
|
+
}
|
|
172
|
+
if (match.value.type !== endpoint.authShape.type) {
|
|
173
|
+
throw new Error(`secrets.proxyEndpointAuth[name='${endpoint.name}'].value.type='${match.value.type}' does not match proxyEndpoints[name='${endpoint.name}'].authShape.type='${endpoint.authShape.type}'`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Build an `allowedHosts` list for `environment.network` that includes
|
|
179
|
+
* the antpath proxy host (and optionally Anthropic's MCP host) when
|
|
180
|
+
* the caller is hand-rolling networking. The worker auto-injects the
|
|
181
|
+
* proxy host server-side when proxy endpoints are declared; use this
|
|
182
|
+
* helper when you also want client-side template validation parity
|
|
183
|
+
* (e.g. to assert at build time that a `limited` config can reach the
|
|
184
|
+
* surfaces you intended).
|
|
185
|
+
*
|
|
186
|
+
* The proxy host is derived from the dashboard URL. Pass the same
|
|
187
|
+
* value you used for the `AntpathPlatformClient` `baseUrl`.
|
|
188
|
+
*/
|
|
189
|
+
export function buildPlatformAllowedHosts(input) {
|
|
190
|
+
const result = [];
|
|
191
|
+
try {
|
|
192
|
+
result.push(new URL(input.dashboardBaseUrl).host);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
throw new Error("buildPlatformAllowedHosts: dashboardBaseUrl must be an absolute URL");
|
|
196
|
+
}
|
|
197
|
+
for (const host of input.extraHosts ?? []) {
|
|
198
|
+
if (!result.includes(host))
|
|
199
|
+
result.push(host);
|
|
200
|
+
}
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
107
203
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/platform/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/platform/client.ts"],"names":[],"mappings":"AA0JA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,MAAM,CAAS;IACf,OAAO,CAAU;IAE1B,YAAY,MAAc,EAAE,OAAe,EAAE,OAAgB;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,qBAAqB;IACf,OAAO,CAAM;IACb,QAAQ,CAAS;IACjB,SAAS,CAAY;IACrB,cAAc,CAAyB;IAExD,YAAY,OAAqC;QAC/C,MAAM,MAAM,GAAG,OAA6C,CAAC;QAC7D,IAAI,iBAAiB,IAAI,MAAM,IAAI,gBAAgB,IAAI,MAAM,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,gJAAgJ,CAAC,CAAC;QACpK,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CA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IAAI,KAAK,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACb,mCAAmC,QAAQ,CAAC,IAAI,kBAAkB,KAAK,CAAC,KAAK,CAAC,IAAI,yCAAyC,QAAQ,CAAC,IAAI,sBAAsB,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,CACzL,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAGzC;IACC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACzF,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ProviderEvent } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Type guards that narrow a `ProviderEvent` by the documented Claude Managed
|
|
4
|
+
* Agents event `type` strings. These do not assert anything about the event
|
|
5
|
+
* payload shape beyond the `type` field — payload contents are passed through
|
|
6
|
+
* verbatim from the provider and may evolve.
|
|
7
|
+
*
|
|
8
|
+
* Reference: https://platform.claude.com/docs/en/managed-agents/events-and-streaming.md
|
|
9
|
+
*/
|
|
10
|
+
export declare function isAgentEvent<E extends ProviderEvent>(event: E): event is E & {
|
|
11
|
+
type: `agent.${string}`;
|
|
12
|
+
};
|
|
13
|
+
export declare function isUserEvent<E extends ProviderEvent>(event: E): event is E & {
|
|
14
|
+
type: `user.${string}`;
|
|
15
|
+
};
|
|
16
|
+
export declare function isSessionEvent<E extends ProviderEvent>(event: E): event is E & {
|
|
17
|
+
type: `session.${string}`;
|
|
18
|
+
};
|
|
19
|
+
export declare function isSpanEvent<E extends ProviderEvent>(event: E): event is E & {
|
|
20
|
+
type: `span.${string}`;
|
|
21
|
+
};
|
|
22
|
+
export declare function isAgentMessage<E extends ProviderEvent>(event: E): event is E & {
|
|
23
|
+
type: "agent.message";
|
|
24
|
+
};
|
|
25
|
+
export declare function isAgentThinking<E extends ProviderEvent>(event: E): event is E & {
|
|
26
|
+
type: "agent.thinking";
|
|
27
|
+
};
|
|
28
|
+
export declare function isAgentToolUse<E extends ProviderEvent>(event: E): event is E & {
|
|
29
|
+
type: "agent.tool_use";
|
|
30
|
+
};
|
|
31
|
+
export declare function isAgentToolResult<E extends ProviderEvent>(event: E): event is E & {
|
|
32
|
+
type: "agent.tool_result";
|
|
33
|
+
};
|
|
34
|
+
export declare function isAgentMcpToolUse<E extends ProviderEvent>(event: E): event is E & {
|
|
35
|
+
type: "agent.mcp_tool_use";
|
|
36
|
+
};
|
|
37
|
+
export declare function isAgentMcpToolResult<E extends ProviderEvent>(event: E): event is E & {
|
|
38
|
+
type: "agent.mcp_tool_result";
|
|
39
|
+
};
|
|
40
|
+
export declare function isAgentCustomToolUse<E extends ProviderEvent>(event: E): event is E & {
|
|
41
|
+
type: "agent.custom_tool_use";
|
|
42
|
+
};
|
|
43
|
+
export declare function isUserMessage<E extends ProviderEvent>(event: E): event is E & {
|
|
44
|
+
type: "user.message";
|
|
45
|
+
};
|
|
46
|
+
export declare function isSessionStatusRunning<E extends ProviderEvent>(event: E): event is E & {
|
|
47
|
+
type: "session.status_running";
|
|
48
|
+
};
|
|
49
|
+
export declare function isSessionStatusIdle<E extends ProviderEvent>(event: E): event is E & {
|
|
50
|
+
type: "session.status_idle";
|
|
51
|
+
};
|
|
52
|
+
export declare function isSessionStatusRescheduled<E extends ProviderEvent>(event: E): event is E & {
|
|
53
|
+
type: "session.status_rescheduled";
|
|
54
|
+
};
|
|
55
|
+
export declare function isSessionStatusTerminated<E extends ProviderEvent>(event: E): event is E & {
|
|
56
|
+
type: "session.status_terminated";
|
|
57
|
+
};
|
|
58
|
+
export declare function isSessionError<E extends ProviderEvent>(event: E): event is E & {
|
|
59
|
+
type: "session.error";
|
|
60
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guards that narrow a `ProviderEvent` by the documented Claude Managed
|
|
3
|
+
* Agents event `type` strings. These do not assert anything about the event
|
|
4
|
+
* payload shape beyond the `type` field — payload contents are passed through
|
|
5
|
+
* verbatim from the provider and may evolve.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://platform.claude.com/docs/en/managed-agents/events-and-streaming.md
|
|
8
|
+
*/
|
|
9
|
+
// Prefix groupers — documented `{domain}.{action}` convention.
|
|
10
|
+
export function isAgentEvent(event) {
|
|
11
|
+
return typeof event.type === "string" && event.type.startsWith("agent.");
|
|
12
|
+
}
|
|
13
|
+
export function isUserEvent(event) {
|
|
14
|
+
return typeof event.type === "string" && event.type.startsWith("user.");
|
|
15
|
+
}
|
|
16
|
+
export function isSessionEvent(event) {
|
|
17
|
+
return typeof event.type === "string" && event.type.startsWith("session.");
|
|
18
|
+
}
|
|
19
|
+
export function isSpanEvent(event) {
|
|
20
|
+
return typeof event.type === "string" && event.type.startsWith("span.");
|
|
21
|
+
}
|
|
22
|
+
// Agent events.
|
|
23
|
+
export function isAgentMessage(event) {
|
|
24
|
+
return event.type === "agent.message";
|
|
25
|
+
}
|
|
26
|
+
export function isAgentThinking(event) {
|
|
27
|
+
return event.type === "agent.thinking";
|
|
28
|
+
}
|
|
29
|
+
export function isAgentToolUse(event) {
|
|
30
|
+
return event.type === "agent.tool_use";
|
|
31
|
+
}
|
|
32
|
+
export function isAgentToolResult(event) {
|
|
33
|
+
return event.type === "agent.tool_result";
|
|
34
|
+
}
|
|
35
|
+
export function isAgentMcpToolUse(event) {
|
|
36
|
+
return event.type === "agent.mcp_tool_use";
|
|
37
|
+
}
|
|
38
|
+
export function isAgentMcpToolResult(event) {
|
|
39
|
+
return event.type === "agent.mcp_tool_result";
|
|
40
|
+
}
|
|
41
|
+
export function isAgentCustomToolUse(event) {
|
|
42
|
+
return event.type === "agent.custom_tool_use";
|
|
43
|
+
}
|
|
44
|
+
// User events.
|
|
45
|
+
export function isUserMessage(event) {
|
|
46
|
+
return event.type === "user.message";
|
|
47
|
+
}
|
|
48
|
+
// Session events.
|
|
49
|
+
export function isSessionStatusRunning(event) {
|
|
50
|
+
return event.type === "session.status_running";
|
|
51
|
+
}
|
|
52
|
+
export function isSessionStatusIdle(event) {
|
|
53
|
+
return event.type === "session.status_idle";
|
|
54
|
+
}
|
|
55
|
+
export function isSessionStatusRescheduled(event) {
|
|
56
|
+
return event.type === "session.status_rescheduled";
|
|
57
|
+
}
|
|
58
|
+
export function isSessionStatusTerminated(event) {
|
|
59
|
+
return event.type === "session.status_terminated";
|
|
60
|
+
}
|
|
61
|
+
export function isSessionError(event) {
|
|
62
|
+
return event.type === "session.error";
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=known-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"known-events.js","sourceRoot":"","sources":["../../src/providers/known-events.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,+DAA+D;AAE/D,MAAM,UAAU,YAAY,CAA0B,KAAQ;IAC5D,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,WAAW,CAA0B,KAAQ;IAC3D,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CA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IACtE,OAAO,KAAK,CAAC,IAAI,KAAK,wBAAwB,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAA0B,KAAQ;IACnE,OAAO,KAAK,CAAC,IAAI,KAAK,qBAAqB,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,0BAA0B,CAA0B,KAAQ;IAC1E,OAAO,KAAK,CAAC,IAAI,KAAK,4BAA4B,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAA0B,KAAQ;IACzE,OAAO,KAAK,CAAC,IAAI,KAAK,2BAA2B,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,cAAc,CAA0B,KAAQ;IAC9D,OAAO,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;AACxC,CAAC"}
|
package/dist/run/controller.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ManagedAgentProvider } from "../providers/types.js";
|
|
2
2
|
import type { ResolvedTemplate } from "../template/compiler.js";
|
|
3
|
-
import type { CleanupPolicy, CleanupResult, CredentialInput, DownloadOutputsOptions, DownloadOutputsResult, Logger, ProviderFile, RunEvent, RunResult, RunStatus, UsageSummary } from "../types.js";
|
|
3
|
+
import type { CleanupPolicy, CleanupResult, CredentialInput, DownloadOutputsOptions, DownloadOutputsResult, Logger, ProviderFile, RunEvent, RunEventHandler, RunResult, RunStatus, SessionResourceUpload, UsageSummary } from "../types.js";
|
|
4
4
|
export interface RunControllerOptions {
|
|
5
5
|
provider: ManagedAgentProvider;
|
|
6
6
|
template: ResolvedTemplate;
|
|
@@ -9,6 +9,9 @@ export interface RunControllerOptions {
|
|
|
9
9
|
timeoutMs?: number | undefined;
|
|
10
10
|
signal?: AbortSignal | undefined;
|
|
11
11
|
logger?: Logger | undefined;
|
|
12
|
+
onEvent?: RunEventHandler | undefined;
|
|
13
|
+
onEventAbortOnError?: boolean | undefined;
|
|
14
|
+
sessionResources?: readonly SessionResourceUpload[] | undefined;
|
|
12
15
|
}
|
|
13
16
|
export declare class RunController {
|
|
14
17
|
#private;
|