@aexhq/sdk 0.13.6

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 (112) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +160 -0
  3. package/dist/_contracts/connection-ticket.d.ts +21 -0
  4. package/dist/_contracts/connection-ticket.js +49 -0
  5. package/dist/_contracts/event-envelope.d.ts +276 -0
  6. package/dist/_contracts/event-envelope.js +324 -0
  7. package/dist/_contracts/event-stream-client.d.ts +47 -0
  8. package/dist/_contracts/event-stream-client.js +141 -0
  9. package/dist/_contracts/http.d.ts +35 -0
  10. package/dist/_contracts/http.js +114 -0
  11. package/dist/_contracts/index.d.ts +28 -0
  12. package/dist/_contracts/index.js +29 -0
  13. package/dist/_contracts/managed-key.d.ts +74 -0
  14. package/dist/_contracts/managed-key.js +110 -0
  15. package/dist/_contracts/operations.d.ts +237 -0
  16. package/dist/_contracts/operations.js +632 -0
  17. package/dist/_contracts/provider-support.d.ts +220 -0
  18. package/dist/_contracts/provider-support.js +90 -0
  19. package/dist/_contracts/proxy-protocol.d.ts +257 -0
  20. package/dist/_contracts/proxy-protocol.js +234 -0
  21. package/dist/_contracts/proxy-validation.d.ts +19 -0
  22. package/dist/_contracts/proxy-validation.js +51 -0
  23. package/dist/_contracts/run-artifacts.d.ts +47 -0
  24. package/dist/_contracts/run-artifacts.js +101 -0
  25. package/dist/_contracts/run-config.d.ts +304 -0
  26. package/dist/_contracts/run-config.js +659 -0
  27. package/dist/_contracts/run-cost.d.ts +125 -0
  28. package/dist/_contracts/run-cost.js +616 -0
  29. package/dist/_contracts/run-custody.d.ts +226 -0
  30. package/dist/_contracts/run-custody.js +465 -0
  31. package/dist/_contracts/run-record.d.ts +127 -0
  32. package/dist/_contracts/run-record.js +177 -0
  33. package/dist/_contracts/run-retention.d.ts +213 -0
  34. package/dist/_contracts/run-retention.js +484 -0
  35. package/dist/_contracts/run-unit.d.ts +194 -0
  36. package/dist/_contracts/run-unit.js +215 -0
  37. package/dist/_contracts/runner-event.d.ts +114 -0
  38. package/dist/_contracts/runner-event.js +187 -0
  39. package/dist/_contracts/runtime-manifest.d.ts +106 -0
  40. package/dist/_contracts/runtime-manifest.js +98 -0
  41. package/dist/_contracts/runtime-security-profile.d.ts +27 -0
  42. package/dist/_contracts/runtime-security-profile.js +82 -0
  43. package/dist/_contracts/runtime-sizes.d.ts +144 -0
  44. package/dist/_contracts/runtime-sizes.js +136 -0
  45. package/dist/_contracts/runtime-types.d.ts +212 -0
  46. package/dist/_contracts/runtime-types.js +2 -0
  47. package/dist/_contracts/sdk-errors.d.ts +34 -0
  48. package/dist/_contracts/sdk-errors.js +52 -0
  49. package/dist/_contracts/sdk-secrets.d.ts +31 -0
  50. package/dist/_contracts/sdk-secrets.js +220 -0
  51. package/dist/_contracts/side-effect-audit.d.ts +129 -0
  52. package/dist/_contracts/side-effect-audit.js +494 -0
  53. package/dist/_contracts/sse.d.ts +74 -0
  54. package/dist/_contracts/sse.js +0 -0
  55. package/dist/_contracts/stable.d.ts +26 -0
  56. package/dist/_contracts/stable.js +44 -0
  57. package/dist/_contracts/status.d.ts +19 -0
  58. package/dist/_contracts/status.js +61 -0
  59. package/dist/_contracts/submission.d.ts +383 -0
  60. package/dist/_contracts/submission.js +1380 -0
  61. package/dist/agents-md.d.ts +46 -0
  62. package/dist/agents-md.js +83 -0
  63. package/dist/agents-md.js.map +1 -0
  64. package/dist/asset-upload.d.ts +66 -0
  65. package/dist/asset-upload.js +168 -0
  66. package/dist/asset-upload.js.map +1 -0
  67. package/dist/bundle.d.ts +33 -0
  68. package/dist/bundle.js +89 -0
  69. package/dist/bundle.js.map +1 -0
  70. package/dist/cli.mjs +4140 -0
  71. package/dist/cli.mjs.sha256 +1 -0
  72. package/dist/client.d.ts +460 -0
  73. package/dist/client.js +857 -0
  74. package/dist/client.js.map +1 -0
  75. package/dist/fetch-archive.d.ts +16 -0
  76. package/dist/fetch-archive.js +170 -0
  77. package/dist/fetch-archive.js.map +1 -0
  78. package/dist/file.d.ts +57 -0
  79. package/dist/file.js +153 -0
  80. package/dist/file.js.map +1 -0
  81. package/dist/index.d.ts +30 -0
  82. package/dist/index.js +34 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/mcp-server.d.ts +84 -0
  85. package/dist/mcp-server.js +114 -0
  86. package/dist/mcp-server.js.map +1 -0
  87. package/dist/node-fs.d.ts +12 -0
  88. package/dist/node-fs.js +44 -0
  89. package/dist/node-fs.js.map +1 -0
  90. package/dist/proxy-endpoint.d.ts +131 -0
  91. package/dist/proxy-endpoint.js +147 -0
  92. package/dist/proxy-endpoint.js.map +1 -0
  93. package/dist/skill.d.ts +117 -0
  94. package/dist/skill.js +169 -0
  95. package/dist/skill.js.map +1 -0
  96. package/dist/version.d.ts +9 -0
  97. package/dist/version.js +10 -0
  98. package/dist/version.js.map +1 -0
  99. package/docs/cleanup.md +38 -0
  100. package/docs/credentials.md +153 -0
  101. package/docs/events.md +76 -0
  102. package/docs/mcp.md +47 -0
  103. package/docs/outputs.md +157 -0
  104. package/docs/product-boundaries.md +57 -0
  105. package/docs/provider-runtime-capabilities.md +103 -0
  106. package/docs/quickstart.md +110 -0
  107. package/docs/release.md +99 -0
  108. package/docs/run-config.md +53 -0
  109. package/docs/run-record.md +39 -0
  110. package/docs/skills.md +139 -0
  111. package/docs/testing.md +29 -0
  112. package/package.json +47 -0
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Run-request config and composition refs for the public SDK/CLI surface.
3
+ *
4
+ * Public composition concepts:
5
+ *
6
+ * - `SkillRef` is the wire-level reference to a skill — either an
7
+ * `skl_*` id pointing at a workspace-uploaded bundle, a
8
+ * `{vendor, skillId, version}` reference to a provider built-in, or
9
+ * a `{slot, name, contentHash}` reference to per-run bytes attached
10
+ * as a multipart part on the submitRun call (and torn down at run
11
+ * terminal). The three shapes are discriminated by `kind` so
12
+ * consumers branch mechanically and providers can never accidentally
13
+ * be looked up in `skill_bundles`. Transient refs do NOT round-trip
14
+ * through JSON (bytes can't be serialised back); `parseRunRequestConfig`
15
+ * therefore rejects them while the BFF multipart submission parser
16
+ * accepts them.
17
+ *
18
+ * - `McpServerRef` is the non-secret part of an MCP server declaration:
19
+ * `name` and `url`. Bearer / cookie / per-request headers travel in
20
+ * the run's vaulted `secrets.mcpServers` block keyed by the same
21
+ * `name`, and never enter the hashed submission payload or the
22
+ * run snapshot.
23
+ *
24
+ * - `RunRequestConfig` is the credential-free set of run parameters that
25
+ * can be persisted to disk (e.g. `aex run --config run.json`) or
26
+ * returned from ordinary application helper functions. It excludes
27
+ * `secrets`/`idempotencyKey`/`signal`; strings are already resolved at
28
+ * the call site before submission.
29
+ *
30
+ * - Skill bundle validation lives here so the SDK (zipping locally),
31
+ * hosted API (server-side unzip + manifest extraction) and runtime
32
+ * mount layer share a single source of truth for
33
+ * the limits, the path normaliser, and the manifest invariants. The
34
+ * DB CHECK constraints on `skill_bundles.manifest` mirror these.
35
+ *
36
+ * Keep this as the public source of truth for the SDK/CLI composition
37
+ * boundary.
38
+ */
39
+ import type { JsonValue, PlatformProxyEndpoint, PlatformEnvironment } from "./submission.js";
40
+ import type { RuntimeSize } from "./runtime-sizes.js";
41
+ /**
42
+ * Mirrors the server-side CHECK constraint
43
+ * `skill_bundles_id_format_chk = check (id ~ '^skl_[A-Za-z0-9_-]{8,128}$')`
44
+ * on persisted skill bundles. Keep the two in lockstep.
45
+ */
46
+ export declare const SKILL_ID_PATTERN: RegExp;
47
+ /**
48
+ * Human-readable, workspace-scoped name. Lowercase, kebab-friendly,
49
+ * 1..128 chars. The DB enforces the length bound via
50
+ * `skill_bundles_name_len_chk`; this regex tightens the SDK/CLI input
51
+ * surface so callers fail at the boundary rather than in the BFF.
52
+ */
53
+ export declare const SKILL_NAME_PATTERN: RegExp;
54
+ /**
55
+ * Hard caps applied at upload time. The SDK enforces these before
56
+ * computing the zip hash so a clearly-too-big bundle never wastes
57
+ * bytes-on-the-wire; the BFF re-enforces server-side because the SDK
58
+ * is untrusted. Numbers are deliberately conservative for the MVP and
59
+ * can be tuned later; keep this object as the single tuning point.
60
+ */
61
+ export declare const SKILL_BUNDLE_LIMITS: {
62
+ /** Compressed (.zip) ceiling. */
63
+ readonly maxCompressedBytes: number;
64
+ /** Sum of uncompressed file sizes. */
65
+ readonly maxDecompressedBytes: number;
66
+ /** Number of regular file entries (directories don't count). */
67
+ readonly maxFiles: 1000;
68
+ /** Maximum directory nesting depth — `a/b/c/d` has depth 4. */
69
+ readonly maxDepth: 16;
70
+ /** Single-entry path length cap. */
71
+ readonly maxPathLength: 512;
72
+ /** Stored file mode for ordinary files. */
73
+ readonly defaultFileMode: 420;
74
+ /** Stored directory mode. */
75
+ readonly defaultDirMode: 493;
76
+ };
77
+ export type SkillRef = ProviderSkillRef | AssetRef;
78
+ /**
79
+ * Storage-neutral uploaded asset reference. Runtime materialization resolves
80
+ * `assetId` privately; public callers never name object-store paths.
81
+ */
82
+ export interface AssetRef {
83
+ readonly kind: "asset";
84
+ readonly assetId: string;
85
+ readonly name: string;
86
+ readonly mountPath?: string;
87
+ }
88
+ export interface ProviderSkillRef {
89
+ readonly kind: "provider";
90
+ readonly vendor: "anthropic" | "custom";
91
+ readonly skillId: string;
92
+ readonly version?: string;
93
+ }
94
+ /** Content-hash format: `sha256:<64 lowercase hex>`. */
95
+ export declare const INLINE_CONTENT_HASH_PATTERN: RegExp;
96
+ export declare function isProviderSkillRef(ref: SkillRef): ref is ProviderSkillRef;
97
+ export declare function isAssetRef(ref: SkillRef | AgentsMdRef | FileRef): ref is AssetRef;
98
+ /**
99
+ * Asset ids are storage-neutral product ids. Current uploads derive the id from
100
+ * the content digest (`asset_<sha256hex>`), but callers must treat it as opaque.
101
+ */
102
+ export declare const ASSET_ID_PATTERN: RegExp;
103
+ export type AgentsMdRef = AssetRef;
104
+ export declare function isAgentsMdAssetRef(ref: AgentsMdRef): ref is AssetRef;
105
+ export type FileRef = AssetRef;
106
+ export declare function isFileAssetRef(ref: FileRef): ref is AssetRef;
107
+ /**
108
+ * Parse a `SkillRef` from untrusted input. Used by the BFF run parser
109
+ * and by the operations module when deserialising API responses. Only
110
+ * `kind: "asset"` and `kind: "provider"` are valid; all other historical
111
+ * wire shapes (including storage-specific refs) are rejected.
112
+ */
113
+ export declare function parseSkillRef(input: unknown, path: string): SkillRef;
114
+ /**
115
+ * Common parser for any `kind: "asset"` ref (skill / agentsMd / file).
116
+ */
117
+ export declare function parseAssetRefFields(record: Record<string, unknown>, path: string): AssetRef;
118
+ /**
119
+ * Manifest entry persisted in `skill_bundles.manifest` and
120
+ * `run_skill_snapshots.manifest`. `path` is forward-slash, relative,
121
+ * normalised. `mode` is the stored POSIX mode (sanitised, NOT the user's
122
+ * filesystem mode) — see `SKILL_BUNDLE_LIMITS.defaultFileMode`.
123
+ */
124
+ export interface SkillBundleEntry {
125
+ readonly path: string;
126
+ readonly size: number;
127
+ readonly mode: number;
128
+ }
129
+ export interface SkillBundleManifest {
130
+ readonly entries: readonly SkillBundleEntry[];
131
+ /** Total uncompressed bytes (sum of `entries[i].size`). */
132
+ readonly totalSize: number;
133
+ /** Number of file entries. Equals `entries.length` by construction. */
134
+ readonly fileCount: number;
135
+ }
136
+ export declare class SkillBundleValidationError extends Error {
137
+ constructor(message: string);
138
+ }
139
+ /**
140
+ * Reject input paths that try to escape the bundle root or smuggle
141
+ * platform-specific syntax. Returns the canonical forward-slash
142
+ * relative path; never returns paths starting or ending with `/`.
143
+ *
144
+ * Rejects:
145
+ * - empty strings and pure whitespace
146
+ * - absolute paths (`/foo`, `C:\foo`, `\\server\share`)
147
+ * - backslash separators (Windows)
148
+ * - `..` segments anywhere in the path
149
+ * - `.` segments anywhere except a leading bare `.`
150
+ * - paths whose length exceeds `SKILL_BUNDLE_LIMITS.maxPathLength`
151
+ * - paths whose depth exceeds `SKILL_BUNDLE_LIMITS.maxDepth`
152
+ * - NUL bytes
153
+ */
154
+ export declare function normaliseSkillBundlePath(input: string): string;
155
+ /**
156
+ * Validate one manifest entry: normalises the path, bounds the size,
157
+ * and sanitises the mode to one of {defaultFileMode, defaultDirMode}.
158
+ * The bundle is files-only, so any non-regular-file entry is rejected
159
+ * upstream by the caller (zip parser must skip symlinks, device files,
160
+ * etc. before reaching this function).
161
+ */
162
+ export declare function validateSkillBundleEntry(input: {
163
+ readonly path: string;
164
+ readonly size: number;
165
+ readonly mode?: number;
166
+ }): SkillBundleEntry;
167
+ /**
168
+ * Validate a full **skill bundle** manifest. Enforces:
169
+ * - entries is a non-empty array
170
+ * - `SKILL.md` exists at the bundle root (this is what makes a
171
+ * bundle a skill rather than a plain workspace file)
172
+ * - file count <= maxFiles
173
+ * - total uncompressed size <= maxDecompressedBytes
174
+ * - per-entry validation (see `validateSkillBundleEntry`)
175
+ * - no duplicate paths
176
+ *
177
+ * In this public surface, **skill** means "Claude Skill" — bundles without
178
+ * `SKILL.md` are not skills and must go
179
+ * through the `AgentsMd` or `File` upload concepts instead.
180
+ *
181
+ * Returns a canonical manifest with totals computed.
182
+ */
183
+ export declare function validateSkillBundleManifest(input: ReadonlyArray<{
184
+ readonly path: string;
185
+ readonly size: number;
186
+ readonly mode?: number;
187
+ }>): SkillBundleManifest;
188
+ /**
189
+ * Returns true when the manifest carries a `SKILL.md` entry at the
190
+ * bundle root. The presence of this file is Anthropic's
191
+ * skill-auto-discovery signal — bundles that have it are treated as
192
+ * Claude skills and mounted accordingly; bundles that don't are still
193
+ * usable agent context (AGENTS.md, settings files, folders of helper
194
+ * data) but the agent won't pick them up via the skills mechanism.
195
+ *
196
+ * The check is intentionally a separate, callable predicate (rather
197
+ * than baked into `validateSkillBundleManifest`) so the storage and
198
+ * the attach layers can remain independent.
199
+ */
200
+ export declare function hasSkillMdAtRoot(manifest: SkillBundleManifest): boolean;
201
+ /**
202
+ * Remote MCP transports Aex accepts. Both are over HTTP — `http`
203
+ * is the streamable-HTTP transport, `sse` is the event-stream
204
+ * transport. `stdio` is explicitly NOT a value here: local-process
205
+ * MCP is not implemented.
206
+ */
207
+ export declare const REMOTE_MCP_TRANSPORTS: readonly ["http", "sse"];
208
+ export type RemoteMcpTransport = (typeof REMOTE_MCP_TRANSPORTS)[number];
209
+ /**
210
+ * Canonical error string for any attempt to declare a stdio-shaped MCP
211
+ * server (`transport: "stdio"`, or a stdio-only field like `command` /
212
+ * `args` / `env`). Pinned in source so every surface — shared parser,
213
+ * SDK builder, CLI flag parser, dashboard form — surfaces the same
214
+ * message and a user can find it via grep.
215
+ */
216
+ export declare const REMOTE_MCP_STDIO_REJECTED_MESSAGE = "stdio MCP servers are not supported by Aex. Aex supports remote MCP servers over HTTP/SSE only.";
217
+ /**
218
+ * The non-secret half of an MCP server declaration. This is what enters
219
+ * the hashed submission, the run snapshot, and any audit log. `name`
220
+ * keys into `secrets.mcpServers` for the per-request headers.
221
+ *
222
+ * `transport` is optional on the wire — when omitted, the runtime is
223
+ * free to pick the default remote transport (`http`). When present, it
224
+ * MUST be one of {@link REMOTE_MCP_TRANSPORTS}; stdio is rejected at
225
+ * parse time.
226
+ */
227
+ export interface McpServerRef {
228
+ readonly name: string;
229
+ readonly url: string;
230
+ readonly transport?: RemoteMcpTransport;
231
+ }
232
+ export declare const MCP_SERVER_NAME_PATTERN: RegExp;
233
+ /**
234
+ * A run-config MCP entry. The user is free to supply headers inline; the SDK
235
+ * splits the call site cleanly at submission time so the Authorization (or
236
+ * other auth-bearing) header never enters the non-secret wire payload.
237
+ */
238
+ export interface RunConfigMcpServer extends McpServerRef {
239
+ readonly headers?: Readonly<Record<string, string>>;
240
+ }
241
+ export declare function parseMcpServerRef(input: unknown, path: string): McpServerRef;
242
+ /**
243
+ * Throw the canonical stdio-rejected error if the record carries any
244
+ * stdio-only marker (`transport: "stdio"`, `command`, `args`, `env`).
245
+ * Used by both the shared parser and the SDK `McpServer.remote`
246
+ * builder so every entry point surfaces the same message.
247
+ */
248
+ export declare function rejectStdioMcpShape(record: Record<string, unknown>): void;
249
+ /**
250
+ * Plain JSON accepted by `aex run --config <path>`. This is not a
251
+ * platform object; it is only the non-secret run parameters that the CLI folds
252
+ * into the normal `submitRun` request.
253
+ */
254
+ export interface RunRequestConfig {
255
+ readonly model: string;
256
+ readonly system?: string;
257
+ readonly prompt: string | readonly string[];
258
+ readonly skills?: readonly SkillRef[];
259
+ readonly mcpServers?: readonly RunConfigMcpServer[];
260
+ readonly environment?: PlatformEnvironment;
261
+ /** Managed runtime size preset (see {@link RuntimeSize}). */
262
+ readonly runtimeSize?: RuntimeSize;
263
+ /** Run deadline as a duration string (`"1h"`, `"30m"`); bounded [1m, 6h] server-side. */
264
+ readonly timeout?: string;
265
+ readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
266
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
267
+ }
268
+ /**
269
+ * Parse a run request config from JSON. Defensive — used by the host CLI to
270
+ * load `--config run.json`. Throws with the JSON path that failed so
271
+ * a user can fix their file. Headers are preserved here and split out
272
+ * later by the SDK normalisation step.
273
+ */
274
+ export declare function parseRunRequestConfig(input: unknown): RunRequestConfig;
275
+ /**
276
+ * Result of splitting a run config into the non-secret submission and the
277
+ * secret MCP-headers bundle. The SDK calls this just before posting to
278
+ * /api/runs: the `submission` half is what the BFF hashes for idempotency, the
279
+ * `mcpServerSecrets` half is what enters run-scoped custody.
280
+ *
281
+ * `prompt` is normalised to `readonly string[]` (single-string callers
282
+ * get wrapped in a length-1 array) so the wire payload, the worker, and
283
+ * the audit log don't have to re-handle two shapes.
284
+ */
285
+ export interface NormalisedRunRequestConfig {
286
+ readonly model: string;
287
+ readonly system?: string;
288
+ readonly prompt: readonly string[];
289
+ readonly skills: readonly SkillRef[];
290
+ readonly mcpServers: readonly McpServerRef[];
291
+ readonly environment?: PlatformEnvironment;
292
+ readonly proxyEndpoints?: readonly PlatformProxyEndpoint[];
293
+ readonly metadata?: Readonly<Record<string, JsonValue>>;
294
+ /**
295
+ * MCP servers whose run-config entry carried `headers`. Keyed by the `name`
296
+ * that appears in `mcpServers` so the BFF can pair them up.
297
+ */
298
+ readonly mcpServerSecrets: ReadonlyArray<{
299
+ readonly name: string;
300
+ readonly url: string;
301
+ readonly headers: Readonly<Record<string, string>>;
302
+ }>;
303
+ }
304
+ export declare function normaliseRunRequestConfig(config: RunRequestConfig): NormalisedRunRequestConfig;