antpath 0.2.1 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +55 -40
  2. package/dist/_shared/cleanup-policy.d.ts +8 -0
  3. package/dist/_shared/cleanup-policy.js +24 -0
  4. package/dist/_shared/config.d.ts +47 -0
  5. package/dist/_shared/config.js +150 -0
  6. package/dist/_shared/dev-stack.d.ts +19 -0
  7. package/dist/_shared/dev-stack.js +105 -0
  8. package/dist/_shared/errors.d.ts +8 -0
  9. package/dist/_shared/errors.js +18 -0
  10. package/dist/_shared/http.d.ts +20 -0
  11. package/dist/_shared/http.js +94 -0
  12. package/dist/_shared/index.d.ts +17 -0
  13. package/dist/_shared/index.js +20 -0
  14. package/dist/{providers → _shared}/known-events.d.ts +10 -10
  15. package/dist/{providers → _shared}/known-events.js +9 -9
  16. package/dist/_shared/operations.d.ts +19 -0
  17. package/dist/_shared/operations.js +42 -0
  18. package/dist/_shared/proxy-protocol.d.ts +148 -0
  19. package/dist/_shared/proxy-protocol.js +113 -0
  20. package/dist/_shared/proxy-validation.d.ts +19 -0
  21. package/dist/_shared/proxy-validation.js +51 -0
  22. package/dist/_shared/runtime-types.d.ts +90 -0
  23. package/dist/_shared/runtime-types.js +2 -0
  24. package/dist/{errors.d.ts → _shared/sdk-errors.d.ts} +10 -1
  25. package/dist/{errors.js → _shared/sdk-errors.js} +15 -2
  26. package/dist/{utils/secrets.js → _shared/sdk-secrets.js} +1 -1
  27. package/dist/_shared/secrets.d.ts +7 -0
  28. package/dist/_shared/secrets.js +20 -0
  29. package/dist/_shared/status.d.ts +8 -0
  30. package/dist/_shared/status.js +46 -0
  31. package/dist/_shared/submission.d.ts +142 -0
  32. package/dist/_shared/submission.js +681 -0
  33. package/dist/{template → _shared/template}/compiler.js +3 -3
  34. package/dist/{template/index.d.ts → _shared/template/helpers.d.ts} +0 -2
  35. package/dist/{template/index.js → _shared/template/helpers.js} +1 -2
  36. package/dist/_shared/template/index.d.ts +4 -0
  37. package/dist/_shared/template/index.js +4 -0
  38. package/dist/_shared/template/mapper.d.ts +11 -0
  39. package/dist/_shared/template/mapper.js +70 -0
  40. package/dist/cli.mjs +1234 -64
  41. package/dist/cli.mjs.sha256 +1 -1
  42. package/dist/client.d.ts +93 -8
  43. package/dist/client.js +192 -30
  44. package/dist/client.js.map +1 -1
  45. package/dist/index.d.ts +16 -10
  46. package/dist/index.js +16 -7
  47. package/dist/index.js.map +1 -1
  48. package/docs/cleanup.md +7 -4
  49. package/docs/credentials.md +12 -12
  50. package/docs/events.md +19 -82
  51. package/docs/outputs.md +15 -4
  52. package/docs/quickstart.md +42 -5
  53. package/docs/skills.md +1 -1
  54. package/docs/templates.md +1 -1
  55. package/docs/testing.md +11 -8
  56. package/examples/mcp-static-bearer.ts +14 -9
  57. package/examples/quickstart.ts +8 -6
  58. package/package.json +4 -5
  59. package/references/implementation-plan.md +1 -1
  60. package/dist/credentials.d.ts +0 -3
  61. package/dist/credentials.js +0 -56
  62. package/dist/credentials.js.map +0 -1
  63. package/dist/errors.js.map +0 -1
  64. package/dist/files/downloader.d.ts +0 -3
  65. package/dist/files/downloader.js +0 -43
  66. package/dist/files/downloader.js.map +0 -1
  67. package/dist/platform/client.d.ts +0 -204
  68. package/dist/platform/client.js +0 -203
  69. package/dist/platform/client.js.map +0 -1
  70. package/dist/platform/index.d.ts +0 -1
  71. package/dist/platform/index.js +0 -2
  72. package/dist/platform/index.js.map +0 -1
  73. package/dist/providers/anthropic/provider.d.ts +0 -36
  74. package/dist/providers/anthropic/provider.js +0 -380
  75. package/dist/providers/anthropic/provider.js.map +0 -1
  76. package/dist/providers/known-events.js.map +0 -1
  77. package/dist/providers/types.d.ts +0 -42
  78. package/dist/providers/types.js.map +0 -1
  79. package/dist/run/controller.d.ts +0 -30
  80. package/dist/run/controller.js +0 -314
  81. package/dist/run/controller.js.map +0 -1
  82. package/dist/skills/packager.d.ts +0 -11
  83. package/dist/skills/packager.js +0 -76
  84. package/dist/skills/packager.js.map +0 -1
  85. package/dist/template/compiler.js.map +0 -1
  86. package/dist/template/index.js.map +0 -1
  87. package/dist/template/types.js +0 -2
  88. package/dist/template/types.js.map +0 -1
  89. package/dist/types.d.ts +0 -149
  90. package/dist/types.js +0 -2
  91. package/dist/types.js.map +0 -1
  92. package/dist/utils/events.d.ts +0 -27
  93. package/dist/utils/events.js +0 -120
  94. package/dist/utils/events.js.map +0 -1
  95. package/dist/utils/paths.d.ts +0 -3
  96. package/dist/utils/paths.js +0 -27
  97. package/dist/utils/paths.js.map +0 -1
  98. package/dist/utils/secrets.js.map +0 -1
  99. package/dist/utils/stable.js.map +0 -1
  100. /package/dist/{utils/secrets.d.ts → _shared/sdk-secrets.d.ts} +0 -0
  101. /package/dist/{utils → _shared}/stable.d.ts +0 -0
  102. /package/dist/{utils → _shared}/stable.js +0 -0
  103. /package/dist/{template → _shared/template}/compiler.d.ts +0 -0
  104. /package/dist/{template → _shared/template}/types.d.ts +0 -0
  105. /package/dist/{providers → _shared/template}/types.js +0 -0
@@ -56,4 +56,4 @@ export function containsSecretLikeValue(input) {
56
56
  function isSecretKey(key) {
57
57
  return /(?:api[_-]?key|authorization|token|secret|password|credential)/i.test(key);
58
58
  }
59
- //# sourceMappingURL=secrets.js.map
59
+ //# sourceMappingURL=sdk-secrets.js.map
@@ -0,0 +1,7 @@
1
+ export interface RedactedSecret {
2
+ expose(): string;
3
+ toJSON(): string;
4
+ toString(): string;
5
+ }
6
+ export declare function redactedSecret(value: string): RedactedSecret;
7
+ export declare function redactKnownSecrets(input: string, secrets: readonly RedactedSecret[]): string;
@@ -0,0 +1,20 @@
1
+ const REDACTED = "[secret]";
2
+ export function redactedSecret(value) {
3
+ if (value.length === 0) {
4
+ throw new Error("Secret value must not be empty");
5
+ }
6
+ return Object.freeze({
7
+ expose: () => value,
8
+ toJSON: () => REDACTED,
9
+ toString: () => REDACTED
10
+ });
11
+ }
12
+ export function redactKnownSecrets(input, secrets) {
13
+ let output = input;
14
+ const longestFirst = [...secrets].sort((a, b) => b.expose().length - a.expose().length);
15
+ for (const secret of longestFirst) {
16
+ output = output.split(secret.expose()).join(REDACTED);
17
+ }
18
+ return output;
19
+ }
20
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1,8 @@
1
+ export declare const RUN_STATUSES: readonly ["queued", "claiming", "provisioning", "session_created", "dispatched", "provider_running", "provider_idle", "provider_rescheduled", "cancelling", "capturing_outputs", "cleaning_up", "succeeded", "failed", "timed_out", "cancelled", "cleanup_failed", "pending_delete", "deleted"];
2
+ export type RunStatus = typeof RUN_STATUSES[number];
3
+ export type RunStatusKind = "active" | "terminal";
4
+ export declare const TERMINAL_RUN_STATUSES: readonly ["succeeded", "failed", "timed_out", "cancelled", "cleanup_failed", "pending_delete", "deleted"];
5
+ export declare function isTerminalRunStatus(status: RunStatus): boolean;
6
+ export declare function getRunStatusKind(status: RunStatus): RunStatusKind;
7
+ export declare const CLEANUP_STATUSES: readonly ["not_started", "pending", "running", "succeeded", "failed_retryable", "failed_terminal", "skipped"];
8
+ export type CleanupStatus = typeof CLEANUP_STATUSES[number];
@@ -0,0 +1,46 @@
1
+ export const RUN_STATUSES = [
2
+ "queued",
3
+ "claiming",
4
+ "provisioning",
5
+ "session_created",
6
+ "dispatched",
7
+ "provider_running",
8
+ "provider_idle",
9
+ "provider_rescheduled",
10
+ "cancelling",
11
+ "capturing_outputs",
12
+ "cleaning_up",
13
+ "succeeded",
14
+ "failed",
15
+ "timed_out",
16
+ "cancelled",
17
+ "cleanup_failed",
18
+ "pending_delete",
19
+ "deleted"
20
+ ];
21
+ export const TERMINAL_RUN_STATUSES = [
22
+ "succeeded",
23
+ "failed",
24
+ "timed_out",
25
+ "cancelled",
26
+ "cleanup_failed",
27
+ "pending_delete",
28
+ "deleted"
29
+ ];
30
+ const terminalRunStatuses = new Set(TERMINAL_RUN_STATUSES);
31
+ export function isTerminalRunStatus(status) {
32
+ return terminalRunStatuses.has(status);
33
+ }
34
+ export function getRunStatusKind(status) {
35
+ return isTerminalRunStatus(status) ? "terminal" : "active";
36
+ }
37
+ export const CLEANUP_STATUSES = [
38
+ "not_started",
39
+ "pending",
40
+ "running",
41
+ "succeeded",
42
+ "failed_retryable",
43
+ "failed_terminal",
44
+ "skipped"
45
+ ];
46
+ //# sourceMappingURL=status.js.map
@@ -0,0 +1,142 @@
1
+ import { type ProxyAuthShape, type ProxyMethod, type ProxyResponseMode } from "./proxy-protocol.js";
2
+ export type JsonPrimitive = string | number | boolean | null;
3
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
4
+ readonly [key: string]: JsonValue;
5
+ };
6
+ /**
7
+ * Networking + runtime-package snapshot carried alongside the template
8
+ * so the worker can deep-clone and mutate it per run (e.g. injecting
9
+ * the proxy hostname into `allowed_hosts` or the `node` runtime into
10
+ * `packages`) without sharing state across concurrent runs.
11
+ *
12
+ * Today this is consumed only by the worker's `templateFromSnapshot`
13
+ * reconstruction. The shape stays intentionally narrow: only fields
14
+ * the worker can act on land here; freeform extensions belong in
15
+ * `metadata`.
16
+ */
17
+ export interface PlatformTemplateEnvironment {
18
+ readonly networking?: PlatformTemplateNetworking;
19
+ readonly packages?: readonly PlatformTemplatePackage[];
20
+ }
21
+ export interface PlatformTemplateNetworking {
22
+ readonly mode: "limited" | "open";
23
+ /** Lowercase host names. The worker always appends the proxy host. */
24
+ readonly allowedHosts?: readonly string[];
25
+ }
26
+ export interface PlatformTemplatePackage {
27
+ readonly name: string;
28
+ readonly version?: string;
29
+ }
30
+ export interface PlatformTemplateSubmission {
31
+ readonly name: string;
32
+ readonly model: string;
33
+ readonly templateHash: string;
34
+ readonly system?: string;
35
+ readonly messages: readonly string[];
36
+ readonly metadata?: Record<string, JsonValue>;
37
+ readonly environment?: PlatformTemplateEnvironment;
38
+ }
39
+ export type PlatformClaudeSessionCleanup = "retain" | "delete";
40
+ export type PlatformSessionCleanup = "retain" | "delete";
41
+ export interface PlatformCleanupPolicy {
42
+ readonly session?: PlatformSessionCleanup;
43
+ /** @deprecated use `session` instead. Accepted for one release for back-compat. */
44
+ readonly claudeSession?: PlatformClaudeSessionCleanup;
45
+ }
46
+ export interface PlatformAnthropicSecrets {
47
+ readonly apiKey: string;
48
+ readonly baseUrl?: string;
49
+ }
50
+ export interface PlatformMcpServerSecret {
51
+ readonly name: string;
52
+ readonly url: string;
53
+ readonly headers?: Record<string, string>;
54
+ }
55
+ export interface PlatformSkillReference {
56
+ readonly skillId: string;
57
+ readonly version?: string;
58
+ }
59
+ /**
60
+ * Per-run auth value for a declared proxy endpoint. The `name` must
61
+ * match a `proxyEndpoints[i].name` in the same submission, and `value`'s
62
+ * shape must match that endpoint's `authShape.type`. The cross-validation
63
+ * lives in `parseRunSubmissionRequest`.
64
+ */
65
+ export interface PlatformProxyEndpointAuth {
66
+ readonly name: string;
67
+ readonly value: PlatformProxyAuthValue;
68
+ }
69
+ export type PlatformProxyAuthValue = {
70
+ readonly type: "bearer";
71
+ readonly token: string;
72
+ } | {
73
+ readonly type: "basic";
74
+ readonly username: string;
75
+ readonly password: string;
76
+ } | {
77
+ readonly type: "header";
78
+ readonly value: string;
79
+ } | {
80
+ readonly type: "query";
81
+ readonly value: string;
82
+ };
83
+ export interface PlatformInlineSecrets {
84
+ readonly anthropic: PlatformAnthropicSecrets;
85
+ readonly mcpServers?: readonly PlatformMcpServerSecret[];
86
+ readonly skills?: readonly PlatformSkillReference[];
87
+ readonly proxyEndpointAuth?: readonly PlatformProxyEndpointAuth[];
88
+ }
89
+ /**
90
+ * Per-run named HTTP proxy endpoint. The `authShape` describes how the
91
+ * upstream expects auth; the actual value is supplied separately via
92
+ * `secrets.proxyEndpointAuth`. The auth value never enters the
93
+ * container — the BFF proxy injects it on outbound calls.
94
+ *
95
+ * Caps and allow-lists below are intentionally pessimistic by default
96
+ * so a misconfigured endpoint can't accidentally permit a wide attack
97
+ * surface; raise per endpoint if needed.
98
+ */
99
+ export interface PlatformProxyEndpoint {
100
+ readonly name: string;
101
+ readonly baseUrl: string;
102
+ readonly authShape: ProxyAuthShape;
103
+ readonly allowMethods: readonly ProxyMethod[];
104
+ readonly allowPathPrefixes: readonly string[];
105
+ readonly allowHeaders?: readonly string[];
106
+ readonly responseMode?: ProxyResponseMode;
107
+ readonly maxRequestBytes?: number;
108
+ readonly maxResponseBytes?: number;
109
+ readonly timeoutMs?: number;
110
+ readonly perCallBudget?: number;
111
+ readonly responseByteBudget?: number;
112
+ }
113
+ export interface PlatformRunSubmissionRequest {
114
+ readonly workspaceId: string;
115
+ readonly idempotencyKey: string;
116
+ readonly template: PlatformTemplateSubmission;
117
+ readonly variables?: Record<string, JsonValue>;
118
+ readonly cleanup?: PlatformCleanupPolicy;
119
+ readonly secrets: PlatformInlineSecrets;
120
+ /**
121
+ * Declared HTTP endpoints reachable via the antpath managed proxy
122
+ * during this run. Empty array (or omitted) → no proxy surface is
123
+ * provisioned; the CLI's `/antpath/index.json` shows `endpoints: []`
124
+ * and the `/antpath/run-token` mount is omitted.
125
+ */
126
+ readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
127
+ }
128
+ /**
129
+ * Default caps for a proxy endpoint when the submission doesn't specify
130
+ * one. Conservative on purpose. Operators can override the platform-
131
+ * wide ceiling through env vars (see `references/environment-variables.md`).
132
+ */
133
+ export declare const PROXY_ENDPOINT_DEFAULTS: {
134
+ readonly allowHeaders: readonly string[];
135
+ readonly responseMode: ProxyResponseMode;
136
+ readonly maxRequestBytes: number;
137
+ readonly maxResponseBytes: number;
138
+ readonly timeoutMs: 10000;
139
+ readonly perCallBudget: 60;
140
+ readonly responseByteBudget: number;
141
+ };
142
+ export declare function parseRunSubmissionRequest(input: unknown): PlatformRunSubmissionRequest;