@aexhq/sdk 0.46.5-canary → 0.50.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/LICENSE +201 -0
- package/NOTICE +38 -0
- package/README.md +23 -31
- package/dist/client/aex.d.ts +33 -0
- package/dist/client/aex.js +98 -0
- package/dist/client/aex.js.map +1 -0
- package/dist/client/credentials.d.ts +25 -0
- package/dist/client/credentials.js +97 -0
- package/dist/client/credentials.js.map +1 -0
- package/dist/client/routing.d.ts +7 -0
- package/dist/client/routing.js +29 -0
- package/dist/client/routing.js.map +1 -0
- package/dist/downloads/download.d.ts +25 -0
- package/dist/downloads/download.js +53 -0
- package/dist/downloads/download.js.map +1 -0
- package/dist/generated/errors.d.ts +12 -0
- package/dist/generated/errors.js +81 -0
- package/dist/generated/errors.js.map +1 -0
- package/dist/generated/resources.d.ts +730 -0
- package/dist/generated/resources.js +606 -0
- package/dist/generated/resources.js.map +1 -0
- package/dist/generated/routes.d.ts +42 -0
- package/dist/generated/routes.js +2101 -0
- package/dist/generated/routes.js.map +1 -0
- package/dist/index.d.ts +20 -50
- package/dist/index.js +11 -62
- package/dist/index.js.map +1 -1
- package/dist/observations/stream.d.ts +1 -0
- package/dist/observations/stream.js +18 -0
- package/dist/observations/stream.js.map +1 -0
- package/dist/transport/errors.d.ts +60 -0
- package/dist/transport/errors.js +107 -0
- package/dist/transport/errors.js.map +1 -0
- package/dist/transport/pagination.d.ts +8 -0
- package/dist/transport/pagination.js +34 -0
- package/dist/transport/pagination.js.map +1 -0
- package/dist/transport/retry.d.ts +21 -0
- package/dist/transport/retry.js +37 -0
- package/dist/transport/retry.js.map +1 -0
- package/dist/transport/transport.d.ts +25 -0
- package/dist/transport/transport.js +28 -0
- package/dist/transport/transport.js.map +1 -0
- package/package.json +63 -30
- package/dist/_contracts/account-operations.d.ts +0 -101
- package/dist/_contracts/account-operations.js +0 -242
- package/dist/_contracts/account-types.d.ts +0 -461
- package/dist/_contracts/account-types.js +0 -1
- package/dist/_contracts/api-key.d.ts +0 -61
- package/dist/_contracts/api-key.js +0 -101
- package/dist/_contracts/api-routes.d.ts +0 -20
- package/dist/_contracts/api-routes.js +0 -109
- package/dist/_contracts/archive-limits.d.ts +0 -3
- package/dist/_contracts/archive-limits.js +0 -23
- package/dist/_contracts/asset-authoring.d.ts +0 -22
- package/dist/_contracts/asset-authoring.js +0 -106
- package/dist/_contracts/asset-bundle.d.ts +0 -64
- package/dist/_contracts/asset-bundle.js +0 -263
- package/dist/_contracts/asset-upload-helper.d.ts +0 -31
- package/dist/_contracts/asset-upload-helper.js +0 -84
- package/dist/_contracts/billing-admission.d.ts +0 -29
- package/dist/_contracts/billing-admission.js +0 -28
- package/dist/_contracts/bundle-manifest.d.ts +0 -89
- package/dist/_contracts/bundle-manifest.js +0 -158
- package/dist/_contracts/canonical-sha256.d.ts +0 -8
- package/dist/_contracts/canonical-sha256.js +0 -8
- package/dist/_contracts/connection-ticket.d.ts +0 -22
- package/dist/_contracts/connection-ticket.js +0 -54
- package/dist/_contracts/continuation-event.d.ts +0 -31
- package/dist/_contracts/continuation-event.js +0 -6
- package/dist/_contracts/contract-parse-error.d.ts +0 -12
- package/dist/_contracts/contract-parse-error.js +0 -51
- package/dist/_contracts/error-codes.d.ts +0 -26
- package/dist/_contracts/error-codes.js +0 -116
- package/dist/_contracts/error-factory.d.ts +0 -32
- package/dist/_contracts/error-factory.js +0 -174
- package/dist/_contracts/event-envelope.d.ts +0 -471
- package/dist/_contracts/event-envelope.js +0 -501
- package/dist/_contracts/event-stream-client.d.ts +0 -122
- package/dist/_contracts/event-stream-client.js +0 -445
- package/dist/_contracts/event-view.d.ts +0 -44
- package/dist/_contracts/event-view.js +0 -69
- package/dist/_contracts/failure-class.d.ts +0 -29
- package/dist/_contracts/failure-class.js +0 -73
- package/dist/_contracts/http.d.ts +0 -135
- package/dist/_contracts/http.js +0 -434
- package/dist/_contracts/ids.d.ts +0 -66
- package/dist/_contracts/ids.js +0 -119
- package/dist/_contracts/index.d.ts +0 -42
- package/dist/_contracts/index.js +0 -52
- package/dist/_contracts/internal.d.ts +0 -55
- package/dist/_contracts/internal.js +0 -113
- package/dist/_contracts/models.d.ts +0 -30
- package/dist/_contracts/models.js +0 -28
- package/dist/_contracts/operation-core.d.ts +0 -36
- package/dist/_contracts/operation-core.js +0 -70
- package/dist/_contracts/operations.d.ts +0 -218
- package/dist/_contracts/operations.js +0 -1496
- package/dist/_contracts/otlp-projection.d.ts +0 -78
- package/dist/_contracts/otlp-projection.js +0 -171
- package/dist/_contracts/post-hook.d.ts +0 -31
- package/dist/_contracts/post-hook.js +0 -61
- package/dist/_contracts/provider-fault.d.ts +0 -34
- package/dist/_contracts/provider-fault.js +0 -68
- package/dist/_contracts/retry-core.d.ts +0 -29
- package/dist/_contracts/retry-core.js +0 -79
- package/dist/_contracts/runner-event.d.ts +0 -117
- package/dist/_contracts/runner-event.js +0 -172
- package/dist/_contracts/runtime-kind.d.ts +0 -60
- package/dist/_contracts/runtime-kind.js +0 -70
- package/dist/_contracts/runtime-manifest.d.ts +0 -121
- package/dist/_contracts/runtime-manifest.js +0 -83
- package/dist/_contracts/runtime-security-profile.d.ts +0 -26
- package/dist/_contracts/runtime-security-profile.js +0 -73
- package/dist/_contracts/runtime-sizes.d.ts +0 -104
- package/dist/_contracts/runtime-sizes.js +0 -111
- package/dist/_contracts/runtime-types.d.ts +0 -618
- package/dist/_contracts/runtime-types.js +0 -58
- package/dist/_contracts/schemas/asset-bundle.d.ts +0 -70
- package/dist/_contracts/schemas/asset-bundle.js +0 -107
- package/dist/_contracts/schemas/asset-ref.d.ts +0 -61
- package/dist/_contracts/schemas/asset-ref.js +0 -118
- package/dist/_contracts/schemas/bundle-manifest.d.ts +0 -66
- package/dist/_contracts/schemas/bundle-manifest.js +0 -77
- package/dist/_contracts/schemas/index.d.ts +0 -32
- package/dist/_contracts/schemas/index.js +0 -30
- package/dist/_contracts/schemas/mcp-server.d.ts +0 -99
- package/dist/_contracts/schemas/mcp-server.js +0 -209
- package/dist/_contracts/schemas/models.d.ts +0 -29
- package/dist/_contracts/schemas/models.js +0 -51
- package/dist/_contracts/schemas/numeric.d.ts +0 -18
- package/dist/_contracts/schemas/numeric.js +0 -28
- package/dist/_contracts/schemas/post-hook.d.ts +0 -45
- package/dist/_contracts/schemas/post-hook.js +0 -68
- package/dist/_contracts/schemas/response-assets.d.ts +0 -75
- package/dist/_contracts/schemas/response-assets.js +0 -81
- package/dist/_contracts/schemas/response-billing.d.ts +0 -208
- package/dist/_contracts/schemas/response-billing.js +0 -139
- package/dist/_contracts/schemas/response-common.d.ts +0 -132
- package/dist/_contracts/schemas/response-common.js +0 -162
- package/dist/_contracts/schemas/response-identity.d.ts +0 -648
- package/dist/_contracts/schemas/response-identity.js +0 -131
- package/dist/_contracts/schemas/response-mcp-servers.d.ts +0 -51
- package/dist/_contracts/schemas/response-mcp-servers.js +0 -32
- package/dist/_contracts/schemas/response-secrets.d.ts +0 -50
- package/dist/_contracts/schemas/response-secrets.js +0 -32
- package/dist/_contracts/schemas/response-sessions-internal.d.ts +0 -200
- package/dist/_contracts/schemas/response-sessions-internal.js +0 -142
- package/dist/_contracts/schemas/response-sessions.d.ts +0 -1598
- package/dist/_contracts/schemas/response-sessions.js +0 -377
- package/dist/_contracts/schemas/response-webhooks.d.ts +0 -76
- package/dist/_contracts/schemas/response-webhooks.js +0 -42
- package/dist/_contracts/schemas/response-workspace.d.ts +0 -225
- package/dist/_contracts/schemas/response-workspace.js +0 -99
- package/dist/_contracts/schemas/runtime-kind.d.ts +0 -31
- package/dist/_contracts/schemas/runtime-kind.js +0 -29
- package/dist/_contracts/schemas/runtime-security-profile.d.ts +0 -28
- package/dist/_contracts/schemas/runtime-security-profile.js +0 -26
- package/dist/_contracts/schemas/runtime-sizes.d.ts +0 -70
- package/dist/_contracts/schemas/runtime-sizes.js +0 -127
- package/dist/_contracts/schemas/session-limits.d.ts +0 -34
- package/dist/_contracts/schemas/session-limits.js +0 -39
- package/dist/_contracts/schemas/session-machine.d.ts +0 -23
- package/dist/_contracts/schemas/session-machine.js +0 -24
- package/dist/_contracts/schemas/session-request-config.d.ts +0 -58
- package/dist/_contracts/schemas/session-request-config.js +0 -134
- package/dist/_contracts/schemas/session-webhook.d.ts +0 -11
- package/dist/_contracts/schemas/session-webhook.js +0 -38
- package/dist/_contracts/schemas/side-effect-audit.d.ts +0 -98
- package/dist/_contracts/schemas/side-effect-audit.js +0 -102
- package/dist/_contracts/schemas/submission-assets.d.ts +0 -117
- package/dist/_contracts/schemas/submission-assets.js +0 -147
- package/dist/_contracts/schemas/submission-body.d.ts +0 -251
- package/dist/_contracts/schemas/submission-body.js +0 -378
- package/dist/_contracts/schemas/submission-environment.d.ts +0 -79
- package/dist/_contracts/schemas/submission-environment.js +0 -179
- package/dist/_contracts/schemas/submission-request.d.ts +0 -158
- package/dist/_contracts/schemas/submission-request.js +0 -49
- package/dist/_contracts/schemas/submission-secrets.d.ts +0 -47
- package/dist/_contracts/schemas/submission-secrets.js +0 -108
- package/dist/_contracts/schemas/wire.d.ts +0 -118
- package/dist/_contracts/schemas/wire.js +0 -171
- package/dist/_contracts/schemas/workspace-resources.d.ts +0 -50
- package/dist/_contracts/schemas/workspace-resources.js +0 -87
- package/dist/_contracts/sdk-errors.d.ts +0 -212
- package/dist/_contracts/sdk-errors.js +0 -313
- package/dist/_contracts/sdk-secrets.d.ts +0 -67
- package/dist/_contracts/sdk-secrets.js +0 -427
- package/dist/_contracts/session-archive.d.ts +0 -16
- package/dist/_contracts/session-archive.js +0 -92
- package/dist/_contracts/session-artifacts.d.ts +0 -189
- package/dist/_contracts/session-artifacts.js +0 -264
- package/dist/_contracts/session-config.d.ts +0 -373
- package/dist/_contracts/session-config.js +0 -562
- package/dist/_contracts/session-cost-types.d.ts +0 -211
- package/dist/_contracts/session-cost-types.js +0 -69
- package/dist/_contracts/session-cost.d.ts +0 -8
- package/dist/_contracts/session-cost.js +0 -582
- package/dist/_contracts/session-custody.d.ts +0 -165
- package/dist/_contracts/session-custody.js +0 -345
- package/dist/_contracts/session-file-query.d.ts +0 -14
- package/dist/_contracts/session-file-query.js +0 -178
- package/dist/_contracts/session-record.d.ts +0 -112
- package/dist/_contracts/session-record.js +0 -165
- package/dist/_contracts/session-retention.d.ts +0 -201
- package/dist/_contracts/session-retention.js +0 -450
- package/dist/_contracts/side-effect-audit.d.ts +0 -126
- package/dist/_contracts/side-effect-audit.js +0 -520
- package/dist/_contracts/sse.d.ts +0 -74
- package/dist/_contracts/sse.js +0 -227
- package/dist/_contracts/stable.d.ts +0 -45
- package/dist/_contracts/stable.js +0 -62
- package/dist/_contracts/status.d.ts +0 -25
- package/dist/_contracts/status.js +0 -57
- package/dist/_contracts/submission-limits.d.ts +0 -61
- package/dist/_contracts/submission-limits.js +0 -60
- package/dist/_contracts/submission.d.ts +0 -547
- package/dist/_contracts/submission.js +0 -812
- package/dist/_contracts/suggest.d.ts +0 -15
- package/dist/_contracts/suggest.js +0 -53
- package/dist/_contracts/testing/response-bindings.d.ts +0 -45
- package/dist/_contracts/testing/response-bindings.js +0 -256
- package/dist/_contracts/testing/wire-conformance-entry.d.ts +0 -10
- package/dist/_contracts/testing/wire-conformance-entry.js +0 -8
- package/dist/_contracts/testing/wire-conformance.d.ts +0 -169
- package/dist/_contracts/testing/wire-conformance.js +0 -276
- package/dist/_contracts/turn-trace.d.ts +0 -28
- package/dist/_contracts/turn-trace.js +0 -1
- package/dist/_contracts/unknown-field-error.d.ts +0 -13
- package/dist/_contracts/unknown-field-error.js +0 -21
- package/dist/_contracts/value-guards.d.ts +0 -20
- package/dist/_contracts/value-guards.js +0 -34
- package/dist/_contracts/webhook-verify.d.ts +0 -34
- package/dist/_contracts/webhook-verify.js +0 -93
- package/dist/_contracts/wire-observer.d.ts +0 -49
- package/dist/_contracts/wire-observer.js +0 -34
- package/dist/_contracts/workflow-status.d.ts +0 -7
- package/dist/_contracts/workflow-status.js +0 -43
- package/dist/_contracts/workspace-resources.d.ts +0 -98
- package/dist/_contracts/workspace-resources.js +0 -39
- package/dist/archive-limits.d.ts +0 -1
- package/dist/archive-limits.js +0 -2
- package/dist/archive-limits.js.map +0 -1
- package/dist/asset-upload.d.ts +0 -47
- package/dist/asset-upload.js +0 -269
- package/dist/asset-upload.js.map +0 -1
- package/dist/bundle.d.ts +0 -9
- package/dist/bundle.js +0 -20
- package/dist/bundle.js.map +0 -1
- package/dist/canonical-zip.d.ts +0 -68
- package/dist/canonical-zip.js +0 -355
- package/dist/canonical-zip.js.map +0 -1
- package/dist/cli.mjs +0 -12048
- package/dist/cli.mjs.sha256 +0 -1
- package/dist/client-types.d.ts +0 -192
- package/dist/client-types.js +0 -2
- package/dist/client-types.js.map +0 -1
- package/dist/client.d.ts +0 -464
- package/dist/client.js +0 -1207
- package/dist/client.js.map +0 -1
- package/dist/event-projection.d.ts +0 -22
- package/dist/event-projection.js +0 -380
- package/dist/event-projection.js.map +0 -1
- package/dist/fetch-archive.d.ts +0 -16
- package/dist/fetch-archive.js +0 -252
- package/dist/fetch-archive.js.map +0 -1
- package/dist/file.d.ts +0 -96
- package/dist/file.js +0 -272
- package/dist/file.js.map +0 -1
- package/dist/instructions.d.ts +0 -20
- package/dist/instructions.js +0 -40
- package/dist/instructions.js.map +0 -1
- package/dist/legacy-session-provider-fault.d.ts +0 -7
- package/dist/legacy-session-provider-fault.js +0 -38
- package/dist/legacy-session-provider-fault.js.map +0 -1
- package/dist/mcp-server.d.ts +0 -84
- package/dist/mcp-server.js +0 -117
- package/dist/mcp-server.js.map +0 -1
- package/dist/node-fs.d.ts +0 -29
- package/dist/node-fs.js +0 -19
- package/dist/node-fs.js.map +0 -1
- package/dist/node-walk.d.ts +0 -69
- package/dist/node-walk.js +0 -151
- package/dist/node-walk.js.map +0 -1
- package/dist/path-basename.d.ts +0 -5
- package/dist/path-basename.js +0 -9
- package/dist/path-basename.js.map +0 -1
- package/dist/retry.d.ts +0 -70
- package/dist/retry.js +0 -155
- package/dist/retry.js.map +0 -1
- package/dist/secret.d.ts +0 -65
- package/dist/secret.js +0 -110
- package/dist/secret.js.map +0 -1
- package/dist/session-validate.d.ts +0 -100
- package/dist/session-validate.js +0 -303
- package/dist/session-validate.js.map +0 -1
- package/dist/skill.d.ts +0 -99
- package/dist/skill.js +0 -169
- package/dist/skill.js.map +0 -1
- package/dist/submission-wire.d.ts +0 -13
- package/dist/submission-wire.js +0 -69
- package/dist/submission-wire.js.map +0 -1
- package/dist/tool.d.ts +0 -41
- package/dist/tool.js +0 -76
- package/dist/tool.js.map +0 -1
- package/dist/version.d.ts +0 -9
- package/dist/version.js +0 -10
- package/dist/version.js.map +0 -1
- package/docs/authentication.md +0 -125
- package/docs/billing.md +0 -164
- package/docs/cleanup.md +0 -27
- package/docs/concepts/agent-tools.md +0 -47
- package/docs/concepts/composition.md +0 -60
- package/docs/concepts/providers-and-runtimes.md +0 -121
- package/docs/concepts/sessions.md +0 -51
- package/docs/concepts/subagents.md +0 -35
- package/docs/credentials.md +0 -116
- package/docs/defaults.md +0 -51
- package/docs/errors.md +0 -258
- package/docs/events.md +0 -143
- package/docs/files.md +0 -130
- package/docs/limits-and-quotas.md +0 -114
- package/docs/limits.md +0 -51
- package/docs/mcp.md +0 -47
- package/docs/networking.md +0 -114
- package/docs/provider-runtime-capabilities.md +0 -32
- package/docs/public-surface.json +0 -73
- package/docs/quickstart.md +0 -135
- package/docs/release.md +0 -44
- package/docs/retries.md +0 -108
- package/docs/secrets.md +0 -141
- package/docs/session-config.md +0 -51
- package/docs/session-record.md +0 -58
- package/docs/skills.md +0 -65
- package/docs/telemetry.md +0 -66
- package/docs/testing.md +0 -35
- package/docs/vision-skills.md +0 -94
- package/docs/webhooks.md +0 -143
package/dist/_contracts/ids.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The identifier authority for every aex entity.
|
|
3
|
-
*
|
|
4
|
-
* One module declares the format, mints the value, and exports the parser.
|
|
5
|
-
* Every other site — database CHECK constraint, HTTP handler, dashboard URL,
|
|
6
|
-
* log line, span attribute, test fixture — imports from here.
|
|
7
|
-
*
|
|
8
|
-
* An identifier has exactly ONE string form: `<prefix>_<32 lowercase hex>`. It
|
|
9
|
-
* is the same bytes in Aurora, in the API response, in the dashboard URL, in
|
|
10
|
-
* the log line, and in the telemetry attribute. There is deliberately no
|
|
11
|
-
* normalizer and no coercer: a value that must be reshaped to be compared has
|
|
12
|
-
* already drifted, so `assertId` throws instead.
|
|
13
|
-
*
|
|
14
|
-
* This module is isomorphic — `crypto.getRandomValues` only, no `node:crypto`,
|
|
15
|
-
* no `Buffer` — because `@aexhq/contracts` ships to browser and edge runtimes and
|
|
16
|
-
* declares no runtime dependency beyond `fflate`. The token pepper and its HMAC
|
|
17
|
-
* stay private in `@aexhq/contract-core`; nothing secret lives here.
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Every identifier kind and its wire prefix. A new entity kind is a new entry
|
|
21
|
-
* here, never a new generator.
|
|
22
|
-
*/
|
|
23
|
-
export const ID_PREFIXES = {
|
|
24
|
-
workspace: "wsp",
|
|
25
|
-
session: "ses",
|
|
26
|
-
resource: "wres",
|
|
27
|
-
mcp: "mcp",
|
|
28
|
-
secret: "sec",
|
|
29
|
-
org: "org",
|
|
30
|
-
team: "team",
|
|
31
|
-
user: "usr",
|
|
32
|
-
apiKey: "key",
|
|
33
|
-
idempotency: "idem"
|
|
34
|
-
};
|
|
35
|
-
export const ID_KINDS = Object.keys(ID_PREFIXES);
|
|
36
|
-
/**
|
|
37
|
-
* The ONE shape source. Every regex, every SQL CHECK, and every JSON-Schema
|
|
38
|
-
* `pattern` in this workspace is derived from this string — see
|
|
39
|
-
* `idPatternSource` and `platform/scripts/validate/id-format-parity.test.ts`,
|
|
40
|
-
* which fails the build on any hand-written `^<prefix>_` literal elsewhere.
|
|
41
|
-
*/
|
|
42
|
-
const ID_BODY_PATTERN = "[0-9a-f]{32}";
|
|
43
|
-
/** 16 random bytes rendered as 32 lowercase hex characters. */
|
|
44
|
-
const ID_BYTES = 16;
|
|
45
|
-
const PATTERN_CACHE = new Map();
|
|
46
|
-
/** The regex source for one kind, e.g. `^wsp_[0-9a-f]{32}$`. */
|
|
47
|
-
export function idPatternSource(kind) {
|
|
48
|
-
return `^${ID_PREFIXES[kind]}_${ID_BODY_PATTERN}$`;
|
|
49
|
-
}
|
|
50
|
-
/** The compiled anchored pattern for one kind. Case-sensitive by design. */
|
|
51
|
-
export function idPattern(kind) {
|
|
52
|
-
const cached = PATTERN_CACHE.get(kind);
|
|
53
|
-
if (cached)
|
|
54
|
-
return cached;
|
|
55
|
-
const compiled = new RegExp(idPatternSource(kind));
|
|
56
|
-
PATTERN_CACHE.set(kind, compiled);
|
|
57
|
-
return compiled;
|
|
58
|
-
}
|
|
59
|
-
const HEX_DIGITS = "0123456789abcdef";
|
|
60
|
-
function toHex(bytes) {
|
|
61
|
-
let out = "";
|
|
62
|
-
for (const byte of bytes) {
|
|
63
|
-
out += HEX_DIGITS[byte >> 4] + HEX_DIGITS[byte & 0x0f];
|
|
64
|
-
}
|
|
65
|
-
return out;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Mint a fresh identifier of `kind`.
|
|
69
|
-
*
|
|
70
|
-
* Fails loudly when no CSPRNG is reachable rather than degrading to
|
|
71
|
-
* `Math.random`: a guessable workspace or session id is a tenancy boundary
|
|
72
|
-
* failure, not a portability inconvenience.
|
|
73
|
-
*/
|
|
74
|
-
export function newId(kind) {
|
|
75
|
-
const prefix = ID_PREFIXES[kind];
|
|
76
|
-
if (prefix === undefined) {
|
|
77
|
-
throw new Error(`newId: unknown id kind "${String(kind)}" (add it to ID_PREFIXES)`);
|
|
78
|
-
}
|
|
79
|
-
const source = globalThis.crypto;
|
|
80
|
-
if (typeof source?.getRandomValues !== "function") {
|
|
81
|
-
throw new Error("newId: crypto.getRandomValues is unavailable; cannot mint an identifier");
|
|
82
|
-
}
|
|
83
|
-
return `${prefix}_${toHex(source.getRandomValues(new Uint8Array(ID_BYTES)))}`;
|
|
84
|
-
}
|
|
85
|
-
/** True when `value` is a well-formed identifier of exactly `kind`. */
|
|
86
|
-
export function isId(kind, value) {
|
|
87
|
-
return typeof value === "string" && idPattern(kind).test(value);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Narrow `value` to an identifier of `kind`, or throw.
|
|
91
|
-
*
|
|
92
|
-
* The message names the kind, the expected shape, and the value it got, because
|
|
93
|
-
* the caller's next action is to find whichever layer produced the wrong form.
|
|
94
|
-
*/
|
|
95
|
-
export function assertId(kind, value, label) {
|
|
96
|
-
if (isId(kind, value))
|
|
97
|
-
return value;
|
|
98
|
-
const what = label ?? `${kind} id`;
|
|
99
|
-
const got = typeof value === "string" ? JSON.stringify(value) : `<${typeof value}>`;
|
|
100
|
-
throw new Error(`${what} must match ${idPatternSource(kind)}, got ${got}`);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The kind `value` belongs to, or `undefined`. Used by generic surfaces (audit
|
|
104
|
-
* rows, error messages) that accept several kinds; a call site that knows the
|
|
105
|
-
* kind must use {@link assertId} instead.
|
|
106
|
-
*/
|
|
107
|
-
export function idKindOf(value) {
|
|
108
|
-
if (typeof value !== "string")
|
|
109
|
-
return undefined;
|
|
110
|
-
const underscore = value.indexOf("_");
|
|
111
|
-
if (underscore <= 0)
|
|
112
|
-
return undefined;
|
|
113
|
-
const prefix = value.slice(0, underscore);
|
|
114
|
-
for (const kind of ID_KINDS) {
|
|
115
|
-
if (ID_PREFIXES[kind] === prefix)
|
|
116
|
-
return isId(kind, value) ? kind : undefined;
|
|
117
|
-
}
|
|
118
|
-
return undefined;
|
|
119
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export * from "./provider-fault.js";
|
|
2
|
-
export * from "./models.js";
|
|
3
|
-
export { SESSION_LIFECYCLE_STATUSES, SESSION_STATUSES, SESSION_TERMINAL_OUTCOMES, isTerminalSessionStatus } from "./status.js";
|
|
4
|
-
export type { SessionLifecycleStatus, SessionStatus, SessionTerminalOutcome } from "./status.js";
|
|
5
|
-
export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, RESPONSE_FORMAT_KINDS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, crossValidateSecretEnvAndValues, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseSessionLimits, parseSessionWebhook, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
|
|
6
|
-
export type { ApprovalGate, BuiltinToolName, JsonPrimitive, JsonValue, OutputMode, PlatformEnvironment, PlatformEnvironmentInput, PlatformInlineSecrets, PlatformInjectionConfig, PlatformMcpServerSecret, PlatformNetworking, PlatformFileCaptureConfig, PlatformPackage, PlatformPackageEcosystem, PlatformPackageInput, PlatformSecretEnvEntry, PlatformSubmission, ResponseFormat, ResponseFormatKind, SessionLimits, ProviderName, SessionWebhookSpec } from "./submission.js";
|
|
7
|
-
export * from "./runtime-sizes.js";
|
|
8
|
-
export * from "./runtime-kind.js";
|
|
9
|
-
export * from "./runner-event.js";
|
|
10
|
-
export * from "./failure-class.js";
|
|
11
|
-
export * from "./event-envelope.js";
|
|
12
|
-
export * from "./otlp-projection.js";
|
|
13
|
-
export * from "./event-view.js";
|
|
14
|
-
export { filterStream, mapStream, streamCoordinatorEvents } from "./event-stream-client.js";
|
|
15
|
-
export type { CoordinatorStreamOptions, TimerPort, WebSocketFactory, WebSocketLike } from "./event-stream-client.js";
|
|
16
|
-
export type { AssistantTextEntry, TurnTrace, ToolCallResult, ToolCallTrace } from "./turn-trace.js";
|
|
17
|
-
export * from "./runtime-manifest.js";
|
|
18
|
-
export * from "./session-record.js";
|
|
19
|
-
export * from "./session-cost.js";
|
|
20
|
-
export { AEX_DEFAULT_BASE_URL, AEX_DEV_BASE_URL, PLANE_BASE_URLS } from "./stable.js";
|
|
21
|
-
export { SecretString, containsSecretLikeValue, createRedactingStream, redactSecrets, redactString } from "./sdk-secrets.js";
|
|
22
|
-
export * from "./sdk-errors.js";
|
|
23
|
-
export * from "./canonical-sha256.js";
|
|
24
|
-
export * from "./session-config.js";
|
|
25
|
-
export * from "./bundle-manifest.js";
|
|
26
|
-
export * from "./billing-admission.js";
|
|
27
|
-
export * from "./runtime-types.js";
|
|
28
|
-
export * from "./account-types.js";
|
|
29
|
-
export * from "./webhook-verify.js";
|
|
30
|
-
export * from "./http.js";
|
|
31
|
-
export * from "./session-artifacts.js";
|
|
32
|
-
export * from "./workspace-resources.js";
|
|
33
|
-
export * from "./sse.js";
|
|
34
|
-
export * from "./error-codes.js";
|
|
35
|
-
export * from "./error-factory.js";
|
|
36
|
-
export * from "./suggest.js";
|
|
37
|
-
export * from "./ids.js";
|
|
38
|
-
export * from "./api-key.js";
|
|
39
|
-
export { CONTRACT_PARSE_ERROR, isContractParseError } from "./contract-parse-error.js";
|
|
40
|
-
export type { ContractParseError } from "./contract-parse-error.js";
|
|
41
|
-
export * from "./schemas/index.js";
|
|
42
|
-
export * from "./api-routes.js";
|
package/dist/_contracts/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export * from "./provider-fault.js";
|
|
2
|
-
export * from "./models.js";
|
|
3
|
-
export { SESSION_LIFECYCLE_STATUSES, SESSION_STATUSES, SESSION_TERMINAL_OUTCOMES, isTerminalSessionStatus } from "./status.js";
|
|
4
|
-
export { AEX_RESERVED_ENV_PREFIX, BUILTIN_TOOL_NAMES, BuiltinTools, DEFAULT_BUILTIN_TOOLS, DEFAULT_OUTPUT_MODE, ENV_VARS_MAX_ENTRIES, ENV_VARS_MAX_TOTAL_BYTES, ENV_VARS_MAX_VALUE_BYTES, OUTPUT_MODES, PLATFORM_PACKAGE_ECOSYSTEMS, RESPONSE_FORMAT_KINDS, SECRETS_KEY, SECRET_ENV_NAME_PATTERN, SECRET_HANDLE_PATTERN, SKILLS_TOOL_DEFINITION, SKILLS_TOOL_NAME, crossValidateSecretEnvAndValues, packageInstallString, parseApprovalGate, parseInlineSecrets, parseResponseFormat, parseSessionLimits, parseSessionWebhook, parseSubmission, resolveBuiltinToolNames } from "./submission.js";
|
|
5
|
-
export * from "./runtime-sizes.js";
|
|
6
|
-
export * from "./runtime-kind.js";
|
|
7
|
-
export * from "./runner-event.js";
|
|
8
|
-
export * from "./failure-class.js";
|
|
9
|
-
export * from "./event-envelope.js";
|
|
10
|
-
export * from "./otlp-projection.js";
|
|
11
|
-
export * from "./event-view.js";
|
|
12
|
-
export { filterStream, mapStream, streamCoordinatorEvents } from "./event-stream-client.js";
|
|
13
|
-
export * from "./runtime-manifest.js";
|
|
14
|
-
export * from "./session-record.js";
|
|
15
|
-
export * from "./session-cost.js";
|
|
16
|
-
export { AEX_DEFAULT_BASE_URL, AEX_DEV_BASE_URL, PLANE_BASE_URLS } from "./stable.js";
|
|
17
|
-
export { SecretString, containsSecretLikeValue, createRedactingStream, redactSecrets, redactString } from "./sdk-secrets.js";
|
|
18
|
-
export * from "./sdk-errors.js";
|
|
19
|
-
export * from "./canonical-sha256.js";
|
|
20
|
-
export * from "./session-config.js";
|
|
21
|
-
export * from "./bundle-manifest.js";
|
|
22
|
-
// The admission vocabulary is a LEAF: `runtime-types` (whoami), `account-types`
|
|
23
|
-
// (the billing summary) and both response schemas read it, so none of them owns
|
|
24
|
-
// it. Same shape as `runtime-kind` / `runtime-sizes`.
|
|
25
|
-
export * from "./billing-admission.js";
|
|
26
|
-
export * from "./runtime-types.js";
|
|
27
|
-
// Split out of `runtime-types.js` and re-exported here so the account /
|
|
28
|
-
// workspace-management record types keep the exact root-barrel surface they had
|
|
29
|
-
// when the two families shared one file.
|
|
30
|
-
export * from "./account-types.js";
|
|
31
|
-
export * from "./webhook-verify.js";
|
|
32
|
-
export * from "./http.js";
|
|
33
|
-
export * from "./session-artifacts.js";
|
|
34
|
-
export * from "./workspace-resources.js";
|
|
35
|
-
export * from "./sse.js";
|
|
36
|
-
// The single canonical event surface: the `is*` guards live on `AexEvent`
|
|
37
|
-
// (`event-envelope.js`) and as METHODS on `AexEventView` (`event-view.js`).
|
|
38
|
-
// The loose `TurnEvent` type and its free-function guard mirror (`event-guards.js`)
|
|
39
|
-
// are RETIRED — there is exactly one event shape.
|
|
40
|
-
export * from "./error-codes.js";
|
|
41
|
-
export * from "./error-factory.js";
|
|
42
|
-
export * from "./suggest.js";
|
|
43
|
-
export * from "./ids.js";
|
|
44
|
-
export * from "./api-key.js";
|
|
45
|
-
export { CONTRACT_PARSE_ERROR, isContractParseError } from "./contract-parse-error.js";
|
|
46
|
-
export * from "./schemas/index.js";
|
|
47
|
-
// The data-plane route table. Declared here rather than in the platform so the
|
|
48
|
-
// spec generator, the platform dispatcher and any future non-TypeScript SDK all
|
|
49
|
-
// read one statement of the HTTP surface. A subpath export is not available:
|
|
50
|
-
// public-contracts-snapshot.mjs pins the code entrypoints to a fixed set, and
|
|
51
|
-
// this is not one of them.
|
|
52
|
-
export * from "./api-routes.js";
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { type AssetFetch, type AssetUploadRetryOptions } from "./asset-upload-helper.js";
|
|
2
|
-
export * from "./connection-ticket.js";
|
|
3
|
-
export * from "./continuation-event.js";
|
|
4
|
-
export { CONTRACT_PARSE_ERROR, isContractParseError } from "./contract-parse-error.js";
|
|
5
|
-
export type { ContractParseError } from "./contract-parse-error.js";
|
|
6
|
-
export * from "./archive-limits.js";
|
|
7
|
-
export * from "./asset-authoring.js";
|
|
8
|
-
export * from "./asset-bundle.js";
|
|
9
|
-
export * from "./models.js";
|
|
10
|
-
export * as operations from "./operations.js";
|
|
11
|
-
export * from "./post-hook.js";
|
|
12
|
-
export * from "./retry-core.js";
|
|
13
|
-
export * from "./runtime-security-profile.js";
|
|
14
|
-
export * from "./sdk-secrets.js";
|
|
15
|
-
export * from "./session-custody.js";
|
|
16
|
-
export * from "./session-retention.js";
|
|
17
|
-
export * from "./side-effect-audit.js";
|
|
18
|
-
export * from "./stable.js";
|
|
19
|
-
export * from "./status.js";
|
|
20
|
-
export * from "./submission.js";
|
|
21
|
-
export * from "./unknown-field-error.js";
|
|
22
|
-
export * from "./workflow-status.js";
|
|
23
|
-
export { hasRunTerminalType } from "./event-stream-client.js";
|
|
24
|
-
export type { RunTerminalTypeEvent } from "./event-stream-client.js";
|
|
25
|
-
export { directUploadNetworkError, directUploadResponseError, isRetryableUploadError, isRetryableUploadStatus, putDirectUploadWithRetry, sanitizeUploadText } from "./asset-upload-helper.js";
|
|
26
|
-
export type { AssetFetch, AssetUploadResponse, AssetUploadRetryOptions, AssetUploadSleep } from "./asset-upload-helper.js";
|
|
27
|
-
/**
|
|
28
|
-
* Subset of `HttpClient` needed by the asset uploader. Defined structurally so
|
|
29
|
-
* SDK and CLI tests can supply thin stubs without dragging in the full client.
|
|
30
|
-
*/
|
|
31
|
-
export interface AssetsHttpClient {
|
|
32
|
-
request<T>(path: string, init?: RequestInit, query?: Record<string, string>): Promise<T>;
|
|
33
|
-
}
|
|
34
|
-
export interface UploadAssetArgs {
|
|
35
|
-
readonly http: AssetsHttpClient;
|
|
36
|
-
readonly bytes: Uint8Array;
|
|
37
|
-
/** `sha256:<hex>` - the canonical content hash declared on the wire. */
|
|
38
|
-
readonly hash: string;
|
|
39
|
-
readonly contentType?: string;
|
|
40
|
-
readonly fetch?: AssetFetch;
|
|
41
|
-
readonly retry?: AssetUploadRetryOptions;
|
|
42
|
-
}
|
|
43
|
-
export interface UploadedAsset {
|
|
44
|
-
readonly assetId: string;
|
|
45
|
-
readonly contentHash: string;
|
|
46
|
-
readonly sizeBytes: number;
|
|
47
|
-
readonly contentType: string;
|
|
48
|
-
/** true if identical bytes were already present (dedup hit). */
|
|
49
|
-
readonly exists: boolean;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Upload `bytes` to the hosted API's content-addressable asset store via the
|
|
53
|
-
* direct-to-storage presign flow shared by SDK and CLI callers.
|
|
54
|
-
*/
|
|
55
|
-
export declare function uploadAsset(args: UploadAssetArgs): Promise<UploadedAsset>;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { putDirectUploadWithRetry } from "./asset-upload-helper.js";
|
|
2
|
-
import { assertArchiveCompressedSize } from "./archive-limits.js";
|
|
3
|
-
// Workspace-internal entry point. Re-exports submission building blocks and
|
|
4
|
-
// hosts small shared helpers so public packages can avoid hand-mirroring
|
|
5
|
-
// behavior. NOT part of the public `@aexhq/contracts` surface; do NOT add this
|
|
6
|
-
// to the package `index`. Consumers reach it via the explicit
|
|
7
|
-
// `@aexhq/contracts/internal` subpath.
|
|
8
|
-
export * from "./connection-ticket.js";
|
|
9
|
-
export * from "./continuation-event.js";
|
|
10
|
-
export { CONTRACT_PARSE_ERROR, isContractParseError } from "./contract-parse-error.js";
|
|
11
|
-
export * from "./archive-limits.js";
|
|
12
|
-
export * from "./asset-authoring.js";
|
|
13
|
-
export * from "./asset-bundle.js";
|
|
14
|
-
export * from "./models.js";
|
|
15
|
-
export * as operations from "./operations.js";
|
|
16
|
-
export * from "./post-hook.js";
|
|
17
|
-
export * from "./retry-core.js";
|
|
18
|
-
export * from "./runtime-security-profile.js";
|
|
19
|
-
export * from "./sdk-secrets.js";
|
|
20
|
-
export * from "./session-custody.js";
|
|
21
|
-
export * from "./session-retention.js";
|
|
22
|
-
export * from "./side-effect-audit.js";
|
|
23
|
-
export * from "./stable.js";
|
|
24
|
-
export * from "./status.js";
|
|
25
|
-
export * from "./submission.js";
|
|
26
|
-
export * from "./unknown-field-error.js";
|
|
27
|
-
export * from "./workflow-status.js";
|
|
28
|
-
export { hasRunTerminalType } from "./event-stream-client.js";
|
|
29
|
-
export { directUploadNetworkError, directUploadResponseError, isRetryableUploadError, isRetryableUploadStatus, putDirectUploadWithRetry, sanitizeUploadText } from "./asset-upload-helper.js";
|
|
30
|
-
/**
|
|
31
|
-
* Upload `bytes` to the hosted API's content-addressable asset store via the
|
|
32
|
-
* direct-to-storage presign flow shared by SDK and CLI callers.
|
|
33
|
-
*/
|
|
34
|
-
export async function uploadAsset(args) {
|
|
35
|
-
assertArchiveCompressedSize(args.bytes.byteLength, "uploadAsset");
|
|
36
|
-
const expected = args.hash.startsWith("sha256:") ? args.hash.slice("sha256:".length) : args.hash;
|
|
37
|
-
const actual = await computeSha256Hex(args.bytes);
|
|
38
|
-
if (actual !== expected) {
|
|
39
|
-
throw new Error(`uploadAsset: client-side hash mismatch: computed sha256:${actual} ` +
|
|
40
|
-
`but caller declared ${args.hash}. Aborting to avoid uploading corrupted data.`);
|
|
41
|
-
}
|
|
42
|
-
const contentHashHeader = `sha256:${actual}`;
|
|
43
|
-
const contentType = args.contentType ?? "application/zip";
|
|
44
|
-
const presign = await args.http.request("/api/assets/presign", {
|
|
45
|
-
method: "POST",
|
|
46
|
-
headers: {
|
|
47
|
-
"content-type": "application/json",
|
|
48
|
-
"Idempotency-Key": `asset-presign:${actual}`
|
|
49
|
-
},
|
|
50
|
-
body: JSON.stringify({ hash: contentHashHeader, sizeBytes: args.bytes.byteLength, contentType })
|
|
51
|
-
});
|
|
52
|
-
if (presign.exists) {
|
|
53
|
-
const contentHash = presign.contentHash ?? contentHashHeader;
|
|
54
|
-
return {
|
|
55
|
-
assetId: presign.assetId ?? assetIdFromContentHash(contentHash),
|
|
56
|
-
contentHash,
|
|
57
|
-
sizeBytes: presign.sizeBytes ?? args.bytes.byteLength,
|
|
58
|
-
contentType: presign.contentType ?? contentType,
|
|
59
|
-
exists: true
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (!presign.uploadUrl) {
|
|
63
|
-
throw new Error("uploadAsset: presign returned no uploadUrl and exists:false");
|
|
64
|
-
}
|
|
65
|
-
const doFetch = args.fetch ?? globalThis.fetch;
|
|
66
|
-
const putHeaders = {
|
|
67
|
-
"content-type": contentType,
|
|
68
|
-
...(presign.requiredHeaders ?? {})
|
|
69
|
-
};
|
|
70
|
-
await putDirectUploadWithRetry(doFetch, presign.uploadUrl, {
|
|
71
|
-
method: "PUT",
|
|
72
|
-
headers: putHeaders,
|
|
73
|
-
body: args.bytes
|
|
74
|
-
}, args.retry);
|
|
75
|
-
const fin = await args.http.request("/api/assets/finalize", {
|
|
76
|
-
method: "POST",
|
|
77
|
-
headers: {
|
|
78
|
-
"content-type": "application/json",
|
|
79
|
-
"Idempotency-Key": `asset-finalize:${actual}`
|
|
80
|
-
},
|
|
81
|
-
body: JSON.stringify({ hash: contentHashHeader, sizeBytes: args.bytes.byteLength })
|
|
82
|
-
});
|
|
83
|
-
const contentHash = fin.contentHash ?? presign.contentHash ?? contentHashHeader;
|
|
84
|
-
return {
|
|
85
|
-
assetId: fin.assetId ?? presign.assetId ?? assetIdFromContentHash(contentHash),
|
|
86
|
-
contentHash,
|
|
87
|
-
sizeBytes: fin.sizeBytes ?? args.bytes.byteLength,
|
|
88
|
-
contentType: fin.contentType ?? presign.contentType ?? contentType,
|
|
89
|
-
exists: false
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
async function computeSha256Hex(bytes) {
|
|
93
|
-
const subtle = globalThis.crypto?.subtle;
|
|
94
|
-
if (!subtle) {
|
|
95
|
-
throw new Error("uploadAsset: globalThis.crypto.subtle is not available; " +
|
|
96
|
-
"Bun, Node 18+, or a Web-Crypto-capable runtime is required");
|
|
97
|
-
}
|
|
98
|
-
const digest = await subtle.digest("SHA-256", bytes);
|
|
99
|
-
return bufferToHex(digest);
|
|
100
|
-
}
|
|
101
|
-
function assetIdFromContentHash(contentHash) {
|
|
102
|
-
const hex = contentHash.startsWith("sha256:") ? contentHash.slice("sha256:".length) : contentHash;
|
|
103
|
-
return `asset_${hex}`;
|
|
104
|
-
}
|
|
105
|
-
function bufferToHex(buffer) {
|
|
106
|
-
const view = new Uint8Array(buffer);
|
|
107
|
-
let out = "";
|
|
108
|
-
for (let i = 0; i < view.length; i++) {
|
|
109
|
-
const byte = view[i];
|
|
110
|
-
out += byte.toString(16).padStart(2, "0");
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
113
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { MODEL_SLUG_PATTERN } from "./schemas/models.js";
|
|
2
|
-
/**
|
|
3
|
-
* Public model ids are plain **Vercel AI Gateway `creator/model` slug strings**.
|
|
4
|
-
*
|
|
5
|
-
* There is no closed model set and no provider concept: a customer names any
|
|
6
|
-
* slug the managed gateway catalog serves (e.g. `anthropic/claude-haiku-4-5`,
|
|
7
|
-
* `deepseek/deepseek-v4-flash`) and the platform routes it through the single
|
|
8
|
-
* managed gateway key. Adding a catalog model is a ZERO-code change — the slug
|
|
9
|
-
* just works. The boundary validation is purely structural (see
|
|
10
|
-
* {@link parseModelSlug}); an unknown-but-well-formed slug is allowed through so
|
|
11
|
-
* a slightly-old client can still run a newly-launched model (the gateway
|
|
12
|
-
* arbitrates at submit time).
|
|
13
|
-
*/
|
|
14
|
-
export type ModelName = string;
|
|
15
|
-
/**
|
|
16
|
-
* Structural gateway model-slug shape: a lowercase `creator`, a `/`, then the
|
|
17
|
-
* model segment. Matches Vercel AI Gateway `creator/model` slugs
|
|
18
|
-
* (e.g. `anthropic/claude-sonnet-4-6`, `openai/gpt-4.1`, `x-ai/grok-2`).
|
|
19
|
-
*/
|
|
20
|
-
export { MODEL_SLUG_PATTERN };
|
|
21
|
-
/** True when `input` is a structurally valid `creator/model` gateway slug. */
|
|
22
|
-
export declare function isModelSlug(input: unknown): input is string;
|
|
23
|
-
/**
|
|
24
|
-
* Validate a public model id as a gateway `creator/model` slug string. This is
|
|
25
|
-
* a boundary shape gate ONLY — it does not consult a catalog, so a well-formed
|
|
26
|
-
* slug the running client does not recognize is accepted (the gateway rejects a
|
|
27
|
-
* truly-absent model at submit time). Throws a {@link import("./contract-parse-error.js").ContractParseError}
|
|
28
|
-
* with `field` context on a malformed value.
|
|
29
|
-
*/
|
|
30
|
-
export declare function parseModelSlug(input: unknown, field?: string): string;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { rethrowContractParseError } from "./contract-parse-error.js";
|
|
2
|
-
import { MODEL_SLUG_PATTERN, modelSlugSchema } from "./schemas/models.js";
|
|
3
|
-
import { parseWire } from "./schemas/wire.js";
|
|
4
|
-
/**
|
|
5
|
-
* Structural gateway model-slug shape: a lowercase `creator`, a `/`, then the
|
|
6
|
-
* model segment. Matches Vercel AI Gateway `creator/model` slugs
|
|
7
|
-
* (e.g. `anthropic/claude-sonnet-4-6`, `openai/gpt-4.1`, `x-ai/grok-2`).
|
|
8
|
-
*/
|
|
9
|
-
export { MODEL_SLUG_PATTERN };
|
|
10
|
-
/** True when `input` is a structurally valid `creator/model` gateway slug. */
|
|
11
|
-
export function isModelSlug(input) {
|
|
12
|
-
return typeof input === "string" && MODEL_SLUG_PATTERN.test(input);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Validate a public model id as a gateway `creator/model` slug string. This is
|
|
16
|
-
* a boundary shape gate ONLY — it does not consult a catalog, so a well-formed
|
|
17
|
-
* slug the running client does not recognize is accepted (the gateway rejects a
|
|
18
|
-
* truly-absent model at submit time). Throws a {@link import("./contract-parse-error.js").ContractParseError}
|
|
19
|
-
* with `field` context on a malformed value.
|
|
20
|
-
*/
|
|
21
|
-
export function parseModelSlug(input, field = "submission.model") {
|
|
22
|
-
try {
|
|
23
|
-
return parseWire(modelSlugSchema(field), input);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
rethrowContractParseError(error, "parseModelSlug");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SessionConfigValidationError } from "./sdk-errors.js";
|
|
2
|
-
export interface IdempotencyOptions {
|
|
3
|
-
readonly idempotencyKey?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const IDEMPOTENCY_KEY_MAX_LENGTH = 255;
|
|
6
|
-
/**
|
|
7
|
-
* The factory for every public client-side session config rejection.
|
|
8
|
-
*
|
|
9
|
-
* PACKAGE-private, not public: `operations.ts` and `account-operations.ts`
|
|
10
|
-
* import it, and neither re-exports it, so it stays off the `operations`
|
|
11
|
-
* namespace exactly as it was when it was a `function` local to `operations.ts`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function configError(field: string, message: string): SessionConfigValidationError;
|
|
14
|
-
/**
|
|
15
|
-
* Resolve a caller-supplied idempotency key to the value that ships on the
|
|
16
|
-
* request. FAIL-FAST: an empty or whitespace-only key THROWS
|
|
17
|
-
* {@link SessionConfigValidationError} — a footgun that silently disabled dedup
|
|
18
|
-
* (`?? generate()` kept `''`, then a downstream truthy header-drop shipped no
|
|
19
|
-
* `Idempotency-Key`). An absent key generates a fresh one; a real key is
|
|
20
|
-
* returned verbatim. The single choke point every send/create/run entry uses.
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveIdempotencyKey(key?: string): string;
|
|
23
|
-
/**
|
|
24
|
-
* Derive the first-message identity from a session-create identity without
|
|
25
|
-
* crossing the hosted 255-character header limit. Short keys retain the
|
|
26
|
-
* readable `<createKey>:message` form; long keys use a deterministic digest.
|
|
27
|
-
*/
|
|
28
|
-
export declare function deriveMessageIdempotencyKey(createKey: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Fail-closed idempotency header builder. An EMPTY string throws (defense in
|
|
31
|
-
* depth alongside {@link resolveIdempotencyKey}) rather than silently dropping
|
|
32
|
-
* the header and proceeding non-idempotent; an absent key yields no header.
|
|
33
|
-
*
|
|
34
|
-
* Package-private on the same terms as {@link configError}.
|
|
35
|
-
*/
|
|
36
|
-
export declare function idempotencyHeaders(options?: IdempotencyOptions): HeadersInit | undefined;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The two primitives every client operation module needs, and the only two that
|
|
3
|
-
* would otherwise have to be duplicated or imported across a cycle: the
|
|
4
|
-
* client-side config-rejection factory, and the idempotency-key policy.
|
|
5
|
-
*
|
|
6
|
-
* A LEAF on purpose. It imports `ids.js` and `sdk-errors.js` and nothing else,
|
|
7
|
-
* so `operations.ts` and `account-operations.ts` can each depend on it without
|
|
8
|
-
* depending on each other. The public names below are re-exported from
|
|
9
|
-
* `operations.ts`, which is where callers have always found them.
|
|
10
|
-
*/
|
|
11
|
-
import { createHash } from "node:crypto";
|
|
12
|
-
import { newId } from "./ids.js";
|
|
13
|
-
import { SessionConfigValidationError } from "./sdk-errors.js";
|
|
14
|
-
export const IDEMPOTENCY_KEY_MAX_LENGTH = 255;
|
|
15
|
-
const MESSAGE_IDEMPOTENCY_SUFFIX = ":message";
|
|
16
|
-
/**
|
|
17
|
-
* The factory for every public client-side session config rejection.
|
|
18
|
-
*
|
|
19
|
-
* PACKAGE-private, not public: `operations.ts` and `account-operations.ts`
|
|
20
|
-
* import it, and neither re-exports it, so it stays off the `operations`
|
|
21
|
-
* namespace exactly as it was when it was a `function` local to `operations.ts`.
|
|
22
|
-
*/
|
|
23
|
-
export function configError(field, message) {
|
|
24
|
-
return new SessionConfigValidationError(message, { field });
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Resolve a caller-supplied idempotency key to the value that ships on the
|
|
28
|
-
* request. FAIL-FAST: an empty or whitespace-only key THROWS
|
|
29
|
-
* {@link SessionConfigValidationError} — a footgun that silently disabled dedup
|
|
30
|
-
* (`?? generate()` kept `''`, then a downstream truthy header-drop shipped no
|
|
31
|
-
* `Idempotency-Key`). An absent key generates a fresh one; a real key is
|
|
32
|
-
* returned verbatim. The single choke point every send/create/run entry uses.
|
|
33
|
-
*/
|
|
34
|
-
export function resolveIdempotencyKey(key) {
|
|
35
|
-
if (key === undefined) {
|
|
36
|
-
return newId("idempotency");
|
|
37
|
-
}
|
|
38
|
-
if (typeof key !== "string" || key.trim().length === 0) {
|
|
39
|
-
throw configError("idempotencyKey", "idempotencyKey must be a non-empty, non-whitespace string");
|
|
40
|
-
}
|
|
41
|
-
if (key.length > IDEMPOTENCY_KEY_MAX_LENGTH) {
|
|
42
|
-
throw configError("idempotencyKey", `idempotencyKey must be at most ${IDEMPOTENCY_KEY_MAX_LENGTH} characters`);
|
|
43
|
-
}
|
|
44
|
-
return key;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Derive the first-message identity from a session-create identity without
|
|
48
|
-
* crossing the hosted 255-character header limit. Short keys retain the
|
|
49
|
-
* readable `<createKey>:message` form; long keys use a deterministic digest.
|
|
50
|
-
*/
|
|
51
|
-
export function deriveMessageIdempotencyKey(createKey) {
|
|
52
|
-
const validated = resolveIdempotencyKey(createKey);
|
|
53
|
-
const readable = `${validated}${MESSAGE_IDEMPOTENCY_SUFFIX}`;
|
|
54
|
-
if (readable.length <= IDEMPOTENCY_KEY_MAX_LENGTH)
|
|
55
|
-
return readable;
|
|
56
|
-
const digest = createHash("sha256").update(validated, "utf8").digest("hex");
|
|
57
|
-
return `aex-message-sha256-${digest}`;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Fail-closed idempotency header builder. An EMPTY string throws (defense in
|
|
61
|
-
* depth alongside {@link resolveIdempotencyKey}) rather than silently dropping
|
|
62
|
-
* the header and proceeding non-idempotent; an absent key yields no header.
|
|
63
|
-
*
|
|
64
|
-
* Package-private on the same terms as {@link configError}.
|
|
65
|
-
*/
|
|
66
|
-
export function idempotencyHeaders(options) {
|
|
67
|
-
if (options?.idempotencyKey === undefined)
|
|
68
|
-
return undefined;
|
|
69
|
-
return { "Idempotency-Key": resolveIdempotencyKey(options.idempotencyKey) };
|
|
70
|
-
}
|