@aexhq/sdk 0.46.4-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
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema for the session-submission REQUEST envelope — the outermost object a
|
|
3
|
-
* platform adapter hands {@link parseSessionSubmissionRequest}: workspace and
|
|
4
|
-
* idempotency identity, the submission brief itself, the runtime dials, and the
|
|
5
|
-
* vaulted `secrets` side-channel.
|
|
6
|
-
*
|
|
7
|
-
* Every member mounts the schema that already owns its vocabulary, so the
|
|
8
|
-
* envelope is one parse rather than a key gate followed by ten. What stays on
|
|
9
|
-
* the parser below is what a schema cannot state: the duration string is
|
|
10
|
-
* DECODED to milliseconds and bounded there, the vaulted bundle and the brief
|
|
11
|
-
* are cross-checked against each other, and the credential-named-field sweep
|
|
12
|
-
* runs over the parsed value.
|
|
13
|
-
*
|
|
14
|
-
* Declaration order is the permitted-key order reported on an unknown field, and
|
|
15
|
-
* `test/allowed-keys-parser-golden.test.ts` pins the resulting sentence.
|
|
16
|
-
*
|
|
17
|
-
* The wire path is `submission`, not `request`: the envelope has always reported
|
|
18
|
-
* itself under that name (`submission.workspaceId is not an allowed field`).
|
|
19
|
-
* `timeout` is the wire duration string; the parsed request carries `timeoutMs`,
|
|
20
|
-
* so the two never appear in the same shape.
|
|
21
|
-
*/
|
|
22
|
-
import * as z from "zod/mini";
|
|
23
|
-
/** Wire shape of the submission request envelope. */
|
|
24
|
-
export declare const SessionSubmissionRequestSchema: z.ZodMiniObject<{
|
|
25
|
-
workspaceId: z.ZodMiniString<string>;
|
|
26
|
-
idempotencyKey: z.ZodMiniString<string>;
|
|
27
|
-
submission: z.ZodMiniObject<{
|
|
28
|
-
model: z.ZodMiniString<string>;
|
|
29
|
-
system: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
30
|
-
prompt: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniArray<z.ZodMiniUnknown>]>;
|
|
31
|
-
assets: z.ZodMiniObject<{
|
|
32
|
-
files: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
33
|
-
name: z.ZodMiniString<string>;
|
|
34
|
-
mountPath: z.ZodMiniString<string>;
|
|
35
|
-
kind: z.ZodMiniLiteral<"file">;
|
|
36
|
-
resourceId: z.ZodMiniString<string>;
|
|
37
|
-
version: z.ZodMiniNumber<number>;
|
|
38
|
-
assetId: z.ZodMiniString<string>;
|
|
39
|
-
contentHash: z.ZodMiniString<string>;
|
|
40
|
-
}, z.core.$strict>>>;
|
|
41
|
-
skills: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
42
|
-
name: z.ZodMiniString<string>;
|
|
43
|
-
description: z.ZodMiniString<string>;
|
|
44
|
-
kind: z.ZodMiniLiteral<"skill">;
|
|
45
|
-
resourceId: z.ZodMiniString<string>;
|
|
46
|
-
version: z.ZodMiniNumber<number>;
|
|
47
|
-
assetId: z.ZodMiniString<string>;
|
|
48
|
-
contentHash: z.ZodMiniString<string>;
|
|
49
|
-
}, z.core.$strict>>>;
|
|
50
|
-
tools: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
51
|
-
name: z.ZodMiniString<string>;
|
|
52
|
-
description: z.ZodMiniString<string>;
|
|
53
|
-
input_schema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
54
|
-
entry: z.ZodMiniString<string>;
|
|
55
|
-
kind: z.ZodMiniLiteral<"tool">;
|
|
56
|
-
resourceId: z.ZodMiniString<string>;
|
|
57
|
-
version: z.ZodMiniNumber<number>;
|
|
58
|
-
assetId: z.ZodMiniString<string>;
|
|
59
|
-
contentHash: z.ZodMiniString<string>;
|
|
60
|
-
}, z.core.$strict>>>;
|
|
61
|
-
instructions: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
62
|
-
name: z.ZodMiniString<string>;
|
|
63
|
-
kind: z.ZodMiniLiteral<"instruction">;
|
|
64
|
-
resourceId: z.ZodMiniString<string>;
|
|
65
|
-
version: z.ZodMiniNumber<number>;
|
|
66
|
-
assetId: z.ZodMiniString<string>;
|
|
67
|
-
contentHash: z.ZodMiniString<string>;
|
|
68
|
-
}, z.core.$strict>>>;
|
|
69
|
-
}, z.core.$strict>;
|
|
70
|
-
mcpServers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
71
|
-
secretEnv: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>>;
|
|
72
|
-
environment: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
73
|
-
networking: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
74
|
-
mode: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
75
|
-
limited: "limited";
|
|
76
|
-
open: "open";
|
|
77
|
-
}>>;
|
|
78
|
-
allowedHosts: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
79
|
-
}, z.core.$strict>>;
|
|
80
|
-
packages: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
81
|
-
name: z.ZodMiniString<string>;
|
|
82
|
-
version: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
83
|
-
}, z.core.$strict>>>;
|
|
84
|
-
envVars: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
85
|
-
}, z.core.$strict>>;
|
|
86
|
-
securityProfile: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
87
|
-
strict: "strict";
|
|
88
|
-
standard: "standard";
|
|
89
|
-
developer: "developer";
|
|
90
|
-
}>>>;
|
|
91
|
-
metadata: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
92
|
-
fileCapture: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniObject<{
|
|
93
|
-
allowedDirs: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
94
|
-
deniedDirs: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
95
|
-
captureTimeoutMs: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
96
|
-
maxFileBytes: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
97
|
-
maxTotalBytes: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
98
|
-
maxFiles: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
99
|
-
}, z.core.$strict>>>;
|
|
100
|
-
builtinTools: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniUnion<readonly [z.ZodMiniLiteral<"default">, z.ZodMiniLiteral<"none">, z.ZodMiniArray<z.ZodMiniUnknown>]>>>;
|
|
101
|
-
outputMode: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniEnum<{
|
|
102
|
-
buffered: "buffered";
|
|
103
|
-
stream: "stream";
|
|
104
|
-
}>>>;
|
|
105
|
-
responseFormat: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
106
|
-
kind: z.ZodMiniLiteral<"text">;
|
|
107
|
-
}, z.core.$strict>, z.ZodMiniObject<{
|
|
108
|
-
kind: z.ZodMiniLiteral<"json_schema">;
|
|
109
|
-
schema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
110
|
-
strict: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
111
|
-
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
112
|
-
}, z.core.$strict>], "kind">>>;
|
|
113
|
-
approvalGate: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniObject<{
|
|
114
|
-
tools: z.ZodMiniArray<z.ZodMiniString<string>>;
|
|
115
|
-
}, z.core.$strict>>>;
|
|
116
|
-
platform: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniObject<{
|
|
117
|
-
systemPrompt: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
118
|
-
default: "default";
|
|
119
|
-
off: "off";
|
|
120
|
-
}>>;
|
|
121
|
-
}, z.core.$strict>>>;
|
|
122
|
-
}, z.core.$strict>;
|
|
123
|
-
runtimeSize: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
124
|
-
"0.25cpu-1gb": "0.25cpu-1gb";
|
|
125
|
-
"0.5cpu-4gb": "0.5cpu-4gb";
|
|
126
|
-
"1cpu-6gb": "1cpu-6gb";
|
|
127
|
-
"2cpu-8gb": "2cpu-8gb";
|
|
128
|
-
"4cpu-12gb": "4cpu-12gb";
|
|
129
|
-
}>>;
|
|
130
|
-
runtimeKind: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
131
|
-
container: "container";
|
|
132
|
-
spot_container: "spot_container";
|
|
133
|
-
lambda: "lambda";
|
|
134
|
-
}>>;
|
|
135
|
-
timeout: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
136
|
-
webhook: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
137
|
-
url: z.ZodMiniString<string>;
|
|
138
|
-
}, z.core.$strict>>;
|
|
139
|
-
limits: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
140
|
-
maxConcurrentChildSessions: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
141
|
-
maxSubagentDepth: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
142
|
-
maxSpendUsd: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
143
|
-
maxTurns: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
144
|
-
maxStepsPerTurn: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
145
|
-
}, z.core.$strict>>;
|
|
146
|
-
machine: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
147
|
-
spot: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
148
|
-
}, z.core.$strict>>;
|
|
149
|
-
secrets: z.ZodMiniOptional<z.ZodMiniNullable<z.ZodMiniObject<{
|
|
150
|
-
mcpServers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
151
|
-
name: z.ZodMiniString<string>;
|
|
152
|
-
url: z.ZodMiniString<string>;
|
|
153
|
-
headers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
154
|
-
}, z.core.$strict>>>;
|
|
155
|
-
envSecrets: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
156
|
-
}, z.core.$strict>>>;
|
|
157
|
-
}, z.core.$strict>;
|
|
158
|
-
export type SessionSubmissionRequestWire = z.infer<typeof SessionSubmissionRequestSchema>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schema for the session-submission REQUEST envelope — the outermost object a
|
|
3
|
-
* platform adapter hands {@link parseSessionSubmissionRequest}: workspace and
|
|
4
|
-
* idempotency identity, the submission brief itself, the runtime dials, and the
|
|
5
|
-
* vaulted `secrets` side-channel.
|
|
6
|
-
*
|
|
7
|
-
* Every member mounts the schema that already owns its vocabulary, so the
|
|
8
|
-
* envelope is one parse rather than a key gate followed by ten. What stays on
|
|
9
|
-
* the parser below is what a schema cannot state: the duration string is
|
|
10
|
-
* DECODED to milliseconds and bounded there, the vaulted bundle and the brief
|
|
11
|
-
* are cross-checked against each other, and the credential-named-field sweep
|
|
12
|
-
* runs over the parsed value.
|
|
13
|
-
*
|
|
14
|
-
* Declaration order is the permitted-key order reported on an unknown field, and
|
|
15
|
-
* `test/allowed-keys-parser-golden.test.ts` pins the resulting sentence.
|
|
16
|
-
*
|
|
17
|
-
* The wire path is `submission`, not `request`: the envelope has always reported
|
|
18
|
-
* itself under that name (`submission.workspaceId is not an allowed field`).
|
|
19
|
-
* `timeout` is the wire duration string; the parsed request carries `timeoutMs`,
|
|
20
|
-
* so the two never appear in the same shape.
|
|
21
|
-
*/
|
|
22
|
-
import * as z from "zod/mini";
|
|
23
|
-
import { RuntimeKindSchema } from "./runtime-kind.js";
|
|
24
|
-
import { RuntimeSizeSchema, SessionTimeoutSchema } from "./runtime-sizes.js";
|
|
25
|
-
import { SessionLimitsSchema } from "./session-limits.js";
|
|
26
|
-
import { SessionMachineSchema } from "./session-machine.js";
|
|
27
|
-
import { SessionWebhookSchema } from "./session-webhook.js";
|
|
28
|
-
import { SubmissionSchema } from "./submission-body.js";
|
|
29
|
-
import { InlineSecretsSchema } from "./submission-secrets.js";
|
|
30
|
-
import { nonEmptyString, wireObject } from "./wire.js";
|
|
31
|
-
const REQUEST = "submission";
|
|
32
|
-
/** Wire shape of the submission request envelope. */
|
|
33
|
-
export const SessionSubmissionRequestSchema = wireObject(REQUEST, {
|
|
34
|
-
workspaceId: nonEmptyString("workspaceId"),
|
|
35
|
-
idempotencyKey: nonEmptyString("idempotencyKey"),
|
|
36
|
-
submission: SubmissionSchema,
|
|
37
|
-
runtimeSize: z.optional(RuntimeSizeSchema),
|
|
38
|
-
runtimeKind: z.optional(RuntimeKindSchema),
|
|
39
|
-
// A string here, a bounded millisecond deadline after `parseSessionTimeout`
|
|
40
|
-
// decodes it: `"90m"` and `"5400000"` are the same deadline and only the
|
|
41
|
-
// decoded value can be judged against the accepted window.
|
|
42
|
-
timeout: z.optional(SessionTimeoutSchema),
|
|
43
|
-
webhook: z.optional(SessionWebhookSchema),
|
|
44
|
-
limits: z.optional(SessionLimitsSchema),
|
|
45
|
-
machine: z.optional(SessionMachineSchema),
|
|
46
|
-
// Absent or null collapses to an empty bundle: under managed gateway keys a
|
|
47
|
-
// run needs no provider key, so an empty bundle is always admissible.
|
|
48
|
-
secrets: z.optional(z.nullable(InlineSecretsSchema))
|
|
49
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schemas for the `secrets` channel — the half of a submission that is vaulted,
|
|
3
|
-
* excluded from the idempotency hash, and never echoed back.
|
|
4
|
-
*
|
|
5
|
-
* Mounted under {@link InlineSecretsSchema}; nested schemas anchor their message
|
|
6
|
-
* paths on `secrets` for the reason documented in `submission-environment.ts`.
|
|
7
|
-
*/
|
|
8
|
-
import * as z from "zod/mini";
|
|
9
|
-
/**
|
|
10
|
-
* The array owns the per-entry field messages as well as the duplicate check.
|
|
11
|
-
*
|
|
12
|
-
* Both need the entry's INDEX — `secrets.mcpServers[0].name` — and a check
|
|
13
|
-
* running on the element schema cannot see where in the array it sits: the
|
|
14
|
-
* low-level parse payload carries the value and the issue list, not a path. The
|
|
15
|
-
* element schema keeps what it can state on its own (shape and the allow-list);
|
|
16
|
-
* anything that has to name its position is stated here.
|
|
17
|
-
*/
|
|
18
|
-
export declare const McpServerSecretsSchema: z.ZodMiniArray<z.ZodMiniObject<{
|
|
19
|
-
name: z.ZodMiniString<string>;
|
|
20
|
-
url: z.ZodMiniString<string>;
|
|
21
|
-
headers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
22
|
-
}, z.core.$strict>>;
|
|
23
|
-
/**
|
|
24
|
-
* `envSecrets` as a map of env var name to value.
|
|
25
|
-
*
|
|
26
|
-
* One ordered check for the same reason as `envVars`: the key-name rule and the
|
|
27
|
-
* value rule have distinct messages and the key rule must win.
|
|
28
|
-
*/
|
|
29
|
-
export declare const EnvSecretsSchema: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
30
|
-
/**
|
|
31
|
-
* The inline secrets bundle.
|
|
32
|
-
*
|
|
33
|
-
* A key in the platform-internal namespace gets its own message. The generic
|
|
34
|
-
* unknown-field error still wins when it comes first in the caller's object —
|
|
35
|
-
* `unrecognized_keys` reports keys in input order and only the first is named,
|
|
36
|
-
* which is the precedence the parser had and the golden tests pin.
|
|
37
|
-
*/
|
|
38
|
-
export declare const InlineSecretsSchema: z.ZodMiniObject<{
|
|
39
|
-
mcpServers: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniObject<{
|
|
40
|
-
name: z.ZodMiniString<string>;
|
|
41
|
-
url: z.ZodMiniString<string>;
|
|
42
|
-
headers: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
43
|
-
}, z.core.$strict>>>;
|
|
44
|
-
envSecrets: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>>;
|
|
45
|
-
}, z.core.$strict>;
|
|
46
|
-
/** An empty map carries no secrets, so it is dropped rather than landed empty. */
|
|
47
|
-
export declare function normalizeEnvSecrets(envSecrets: Record<string, unknown> | undefined): Readonly<Record<string, string>> | undefined;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Schemas for the `secrets` channel — the half of a submission that is vaulted,
|
|
3
|
-
* excluded from the idempotency hash, and never echoed back.
|
|
4
|
-
*
|
|
5
|
-
* Mounted under {@link InlineSecretsSchema}; nested schemas anchor their message
|
|
6
|
-
* paths on `secrets` for the reason documented in `submission-environment.ts`.
|
|
7
|
-
*/
|
|
8
|
-
import * as z from "zod/mini";
|
|
9
|
-
import { PLATFORM_INTERNAL_SECRET_PREFIX, SECRET_ENV_NAME_PATTERN } from "../submission-limits.js";
|
|
10
|
-
import { UnknownFieldError } from "../unknown-field-error.js";
|
|
11
|
-
import { indexedPath, wireObject, wirePath } from "./wire.js";
|
|
12
|
-
const SECRETS = "secrets";
|
|
13
|
-
const MCP_SERVERS = `${SECRETS}.mcpServers`;
|
|
14
|
-
const McpServerSecretSchema = wireObject(
|
|
15
|
-
// Depth-proof: the bundle is also mounted under the request envelope, and a
|
|
16
|
-
// path folded from the whole reported position would double the segment
|
|
17
|
-
// there. See `indexedPath`.
|
|
18
|
-
indexedPath(MCP_SERVERS), {
|
|
19
|
-
name: z.string(),
|
|
20
|
-
url: z.string(),
|
|
21
|
-
headers: z.optional(z.record(z.string(), z.string()))
|
|
22
|
-
}, {
|
|
23
|
-
unknownKey: (path, key) => `${path}.${key} is not an allowed field; permitted: name, url, headers`
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* The array owns the per-entry field messages as well as the duplicate check.
|
|
27
|
-
*
|
|
28
|
-
* Both need the entry's INDEX — `secrets.mcpServers[0].name` — and a check
|
|
29
|
-
* running on the element schema cannot see where in the array it sits: the
|
|
30
|
-
* low-level parse payload carries the value and the issue list, not a path. The
|
|
31
|
-
* element schema keeps what it can state on its own (shape and the allow-list);
|
|
32
|
-
* anything that has to name its position is stated here.
|
|
33
|
-
*/
|
|
34
|
-
export const McpServerSecretsSchema = z
|
|
35
|
-
.array(McpServerSecretSchema, { error: `${MCP_SERVERS} must be an array` })
|
|
36
|
-
.check(z.check((payload) => {
|
|
37
|
-
const entries = payload.value;
|
|
38
|
-
const reject = (message) => {
|
|
39
|
-
payload.issues.push({ code: "custom", message, input: payload.value });
|
|
40
|
-
};
|
|
41
|
-
const seen = new Set();
|
|
42
|
-
for (const [index, entry] of entries.entries()) {
|
|
43
|
-
const base = wirePath(MCP_SERVERS, [index]);
|
|
44
|
-
if (typeof entry.name !== "string" || entry.name.length === 0) {
|
|
45
|
-
reject(`${base}.name must be a non-empty string`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (typeof entry.url !== "string" || entry.url.length === 0) {
|
|
49
|
-
reject(`${base}.url must be a non-empty string`);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (seen.has(entry.name)) {
|
|
53
|
-
reject(`${MCP_SERVERS} duplicate name: ${entry.name}`);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
seen.add(entry.name);
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
/**
|
|
60
|
-
* `envSecrets` as a map of env var name to value.
|
|
61
|
-
*
|
|
62
|
-
* One ordered check for the same reason as `envVars`: the key-name rule and the
|
|
63
|
-
* value rule have distinct messages and the key rule must win.
|
|
64
|
-
*/
|
|
65
|
-
export const EnvSecretsSchema = z
|
|
66
|
-
.record(z.string(), z.unknown(), { error: `${SECRETS}.envSecrets must be an object` })
|
|
67
|
-
.check(z.check((payload) => {
|
|
68
|
-
const reject = (message) => {
|
|
69
|
-
payload.issues.push({ code: "custom", message, input: payload.value });
|
|
70
|
-
};
|
|
71
|
-
for (const [envName, entry] of Object.entries(payload.value)) {
|
|
72
|
-
if (!SECRET_ENV_NAME_PATTERN.test(envName)) {
|
|
73
|
-
reject(`${SECRETS}.envSecrets key "${envName}" must be a valid env var name matching ${SECRET_ENV_NAME_PATTERN.source}`);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (typeof entry !== "string" || entry.length === 0) {
|
|
77
|
-
reject(`${SECRETS}.envSecrets.${envName} must be a non-empty string`);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}));
|
|
82
|
-
/**
|
|
83
|
-
* The inline secrets bundle.
|
|
84
|
-
*
|
|
85
|
-
* A key in the platform-internal namespace gets its own message. The generic
|
|
86
|
-
* unknown-field error still wins when it comes first in the caller's object —
|
|
87
|
-
* `unrecognized_keys` reports keys in input order and only the first is named,
|
|
88
|
-
* which is the precedence the parser had and the golden tests pin.
|
|
89
|
-
*/
|
|
90
|
-
export const InlineSecretsSchema = wireObject(SECRETS, {
|
|
91
|
-
mcpServers: z.optional(McpServerSecretsSchema),
|
|
92
|
-
envSecrets: z.optional(EnvSecretsSchema)
|
|
93
|
-
}, {
|
|
94
|
-
// Returns an Error instance, not a string: callers get `objectPath`,
|
|
95
|
-
// `unknownKey` and the ordered `permittedKeys` as structured fields. The
|
|
96
|
-
// reserved-namespace case deliberately returns a plain Error — it is not an
|
|
97
|
-
// unknown field, it is a field the caller may not set.
|
|
98
|
-
unknownKey: (path, key, permitted) => key.startsWith(PLATFORM_INTERNAL_SECRET_PREFIX)
|
|
99
|
-
? new Error(`${path}.${key} uses the platform-internal ${PLATFORM_INTERNAL_SECRET_PREFIX} namespace and may not be set by callers`)
|
|
100
|
-
: new UnknownFieldError(path, key, permitted)
|
|
101
|
-
});
|
|
102
|
-
/** An empty map carries no secrets, so it is dropped rather than landed empty. */
|
|
103
|
-
export function normalizeEnvSecrets(envSecrets) {
|
|
104
|
-
if (envSecrets === undefined || Object.keys(envSecrets).length === 0) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
return { ...envSecrets };
|
|
108
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared machinery for schema-backed wire parsing.
|
|
3
|
-
*
|
|
4
|
-
* Every module in this directory imports **only `zod/mini`**. The published SDK
|
|
5
|
-
* inlines this package, and full Zod's method-chained API defeats tree-shaking
|
|
6
|
-
* (measured: 63.7 KB gzip for a trivial schema, against 4.3 KB for the same
|
|
7
|
-
* schema in mini). Build-time tooling that needs the classic surface — the
|
|
8
|
-
* OpenAPI generator — imports full `zod` off these same schema objects, which is
|
|
9
|
-
* sound because both entrypoints construct the same core classes.
|
|
10
|
-
*
|
|
11
|
-
* The house parser idiom this replaces paired a hand-written allow-list with
|
|
12
|
-
* `defineAllowedKeys<T>()`, a compile-time proof that the runtime list named
|
|
13
|
-
* every key of the TypeScript interface and no others. That proof is not
|
|
14
|
-
* preserved here so much as made unnecessary: the schema *is* the type, so
|
|
15
|
-
* {@link wireObject} reads the ordered permitted list off the shape it was
|
|
16
|
-
* built from and there is no second list to disagree with the first.
|
|
17
|
-
*/
|
|
18
|
-
import * as z from "zod/mini";
|
|
19
|
-
/**
|
|
20
|
-
* Wording for the two diagnostics a strict wire object raises on its own
|
|
21
|
-
* behalf. Families differ ("is not an allowed field; permitted: …" against "is
|
|
22
|
-
* not allowed; permitted: …" against "contains unexpected field: …"), so each
|
|
23
|
-
* supplies the text it already emits. The ordered key list handed to
|
|
24
|
-
* {@link WireObjectText.unknownKey} always comes from the schema shape.
|
|
25
|
-
*/
|
|
26
|
-
export interface WireObjectText {
|
|
27
|
-
/** Raised when the input is not an object at all. */
|
|
28
|
-
readonly notObject: (path: string) => string;
|
|
29
|
-
/**
|
|
30
|
-
* Raised for the first key the shape does not declare.
|
|
31
|
-
*
|
|
32
|
-
* Return an `Error` instance rather than a string to keep a structured
|
|
33
|
-
* diagnostic — `UnknownFieldError` carries `objectPath`, `unknownKey` and the
|
|
34
|
-
* ordered `permittedKeys` as fields. Zod's message channel is strings only, so
|
|
35
|
-
* {@link parseWire} re-invokes this to recover the instance at the throw site;
|
|
36
|
-
* implementations must therefore be pure. Only applies at the root of the
|
|
37
|
-
* parsed schema; a nested unknown key surfaces as its message alone.
|
|
38
|
-
*/
|
|
39
|
-
readonly unknownKey: (path: string, key: string, permitted: readonly string[]) => string | Error;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Render a wire path from a base and the position Zod reports an issue at:
|
|
43
|
-
* `submission.environment.packages` + `[0]` -> `submission.environment.packages[0]`.
|
|
44
|
-
*
|
|
45
|
-
* Array indices render as `[0]` and object keys as `.name`, matching the paths
|
|
46
|
-
* the hand-written parsers interpolate into their messages.
|
|
47
|
-
*/
|
|
48
|
-
export declare function wirePath(base: string, issuePath: readonly PropertyKey[]): string;
|
|
49
|
-
/**
|
|
50
|
-
* The wire path of an object that sits at an INDEXED position in a list —
|
|
51
|
-
* `secrets.mcpServers[2]`, `submission.assets.files[0]` — derived from where
|
|
52
|
-
* Zod reports the issue rather than from the whole reported position.
|
|
53
|
-
*
|
|
54
|
-
* Prefer this over {@link wirePath} for anything mounted inside an array.
|
|
55
|
-
* Zod reports a position relative to the schema the parse STARTED at, so a
|
|
56
|
-
* schema that renders its own path by folding the whole issue path is only
|
|
57
|
-
* correct at one mount depth: parse the same object one level lower and the
|
|
58
|
-
* segment doubles (`submission.environment.environment.packages[0]`). The
|
|
59
|
-
* element's own diagnostics — not-an-object and rejected-key — always report at
|
|
60
|
-
* the element's position, so the element INDEX is the last segment whatever
|
|
61
|
-
* sits above it, and reading just that segment makes the message depth-proof.
|
|
62
|
-
*/
|
|
63
|
-
export declare function indexedPath(base: string): (issuePath: readonly PropertyKey[]) => string;
|
|
64
|
-
/**
|
|
65
|
-
* The path of a FIELD on an element at an indexed position:
|
|
66
|
-
* `submission.assets.files[0].mountPath`.
|
|
67
|
-
*
|
|
68
|
-
* Depth-proof for the same reason as {@link indexedPath}, reading the last two
|
|
69
|
-
* segments — the element index and the field name — off the reported position.
|
|
70
|
-
*/
|
|
71
|
-
export declare function indexedFieldPath(base: string, issuePath: readonly PropertyKey[] | undefined): string;
|
|
72
|
-
/** The last segment of a reported position — a record key, or an array index. */
|
|
73
|
-
export declare function lastSegment(issuePath: readonly PropertyKey[] | undefined): string;
|
|
74
|
-
/**
|
|
75
|
-
* A required, non-empty string reported under `path`.
|
|
76
|
-
*
|
|
77
|
-
* The type failure and the emptiness failure share one message because the
|
|
78
|
-
* `requireString(value, path)` ladder this replaces collapsed them, and `abort`
|
|
79
|
-
* keeps the second from firing on a value that never cleared the first.
|
|
80
|
-
*/
|
|
81
|
-
export declare function nonEmptyString(path: string): z.ZodMiniString<string>;
|
|
82
|
-
/**
|
|
83
|
-
* A strict object schema that reports unknown keys and non-object input in the
|
|
84
|
-
* caller's own words.
|
|
85
|
-
*
|
|
86
|
-
* `path` is the wire path the surrounding parser reports errors under
|
|
87
|
-
* (`"webhook"`, `"submission.environment"`), not a schema name. Pass a function
|
|
88
|
-
* when the object sits inside an array and the path carries an index — it
|
|
89
|
-
* receives the issue's position, which {@link wirePath} renders.
|
|
90
|
-
*/
|
|
91
|
-
export declare function wireObject<Shape extends z.core.$ZodLooseShape>(path: string | ((issuePath: readonly PropertyKey[]) => string), shape: Shape, text?: Partial<WireObjectText>): z.ZodMiniObject<Shape, z.core.$strict>;
|
|
92
|
-
/**
|
|
93
|
-
* Map a failed parse onto the package's error surface: a plain `Error` carrying
|
|
94
|
-
* the message the schema declared.
|
|
95
|
-
*
|
|
96
|
-
* Deliberately not a `ZodError`. Callers wrap parsers in `withContractParseError`,
|
|
97
|
-
* which brands the thrown error with non-enumerable metadata and asserts the
|
|
98
|
-
* error has no enumerable own keys of its own; a `ZodError` carries `issues`
|
|
99
|
-
* and would break that contract as well as leak the schema library into a
|
|
100
|
-
* public error shape.
|
|
101
|
-
*/
|
|
102
|
-
export declare function errorFromZod(error: z.core.$ZodError): Error;
|
|
103
|
-
/**
|
|
104
|
-
* Drop explicit `undefined` from optional properties.
|
|
105
|
-
*
|
|
106
|
-
* `z.infer` of an optional field yields `field?: T | undefined`, which under
|
|
107
|
-
* `exactOptionalPropertyTypes` is NOT assignable to the package's `field?: T`
|
|
108
|
-
* interfaces — an inferred value may carry the key with an `undefined` value,
|
|
109
|
-
* and those interfaces promise it is either absent or a `T`.
|
|
110
|
-
*
|
|
111
|
-
* A `normalize*()` function is where that promise is actually kept, since it is
|
|
112
|
-
* the step that drops absent fields, so it is where this type belongs.
|
|
113
|
-
*/
|
|
114
|
-
export type Present<T> = {
|
|
115
|
-
[K in keyof T]?: Exclude<T[K], undefined>;
|
|
116
|
-
};
|
|
117
|
-
/** Parse `input` against `schema`, throwing the family's own error text on failure. */
|
|
118
|
-
export declare function parseWire<Schema extends z.core.$ZodType>(schema: Schema, input: unknown): z.infer<Schema>;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared machinery for schema-backed wire parsing.
|
|
3
|
-
*
|
|
4
|
-
* Every module in this directory imports **only `zod/mini`**. The published SDK
|
|
5
|
-
* inlines this package, and full Zod's method-chained API defeats tree-shaking
|
|
6
|
-
* (measured: 63.7 KB gzip for a trivial schema, against 4.3 KB for the same
|
|
7
|
-
* schema in mini). Build-time tooling that needs the classic surface — the
|
|
8
|
-
* OpenAPI generator — imports full `zod` off these same schema objects, which is
|
|
9
|
-
* sound because both entrypoints construct the same core classes.
|
|
10
|
-
*
|
|
11
|
-
* The house parser idiom this replaces paired a hand-written allow-list with
|
|
12
|
-
* `defineAllowedKeys<T>()`, a compile-time proof that the runtime list named
|
|
13
|
-
* every key of the TypeScript interface and no others. That proof is not
|
|
14
|
-
* preserved here so much as made unnecessary: the schema *is* the type, so
|
|
15
|
-
* {@link wireObject} reads the ordered permitted list off the shape it was
|
|
16
|
-
* built from and there is no second list to disagree with the first.
|
|
17
|
-
*/
|
|
18
|
-
import * as z from "zod/mini";
|
|
19
|
-
const defaultText = {
|
|
20
|
-
notObject: (path) => `${path} must be an object`,
|
|
21
|
-
unknownKey: (path, key, permitted) => `${path}.${key} is not an allowed field; permitted: ${permitted.join(", ")}`
|
|
22
|
-
};
|
|
23
|
-
const wireObjectMeta = new WeakMap();
|
|
24
|
-
/**
|
|
25
|
-
* Render a wire path from a base and the position Zod reports an issue at:
|
|
26
|
-
* `submission.environment.packages` + `[0]` -> `submission.environment.packages[0]`.
|
|
27
|
-
*
|
|
28
|
-
* Array indices render as `[0]` and object keys as `.name`, matching the paths
|
|
29
|
-
* the hand-written parsers interpolate into their messages.
|
|
30
|
-
*/
|
|
31
|
-
export function wirePath(base, issuePath) {
|
|
32
|
-
return issuePath.reduce((rendered, segment) => typeof segment === "number" ? `${rendered}[${segment}]` : `${rendered}.${String(segment)}`, base);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* The wire path of an object that sits at an INDEXED position in a list —
|
|
36
|
-
* `secrets.mcpServers[2]`, `submission.assets.files[0]` — derived from where
|
|
37
|
-
* Zod reports the issue rather than from the whole reported position.
|
|
38
|
-
*
|
|
39
|
-
* Prefer this over {@link wirePath} for anything mounted inside an array.
|
|
40
|
-
* Zod reports a position relative to the schema the parse STARTED at, so a
|
|
41
|
-
* schema that renders its own path by folding the whole issue path is only
|
|
42
|
-
* correct at one mount depth: parse the same object one level lower and the
|
|
43
|
-
* segment doubles (`submission.environment.environment.packages[0]`). The
|
|
44
|
-
* element's own diagnostics — not-an-object and rejected-key — always report at
|
|
45
|
-
* the element's position, so the element INDEX is the last segment whatever
|
|
46
|
-
* sits above it, and reading just that segment makes the message depth-proof.
|
|
47
|
-
*/
|
|
48
|
-
export function indexedPath(base) {
|
|
49
|
-
return (issuePath) => `${base}[${String(issuePath[issuePath.length - 1] ?? 0)}]`;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* The path of a FIELD on an element at an indexed position:
|
|
53
|
-
* `submission.assets.files[0].mountPath`.
|
|
54
|
-
*
|
|
55
|
-
* Depth-proof for the same reason as {@link indexedPath}, reading the last two
|
|
56
|
-
* segments — the element index and the field name — off the reported position.
|
|
57
|
-
*/
|
|
58
|
-
export function indexedFieldPath(base, issuePath) {
|
|
59
|
-
const path = issuePath ?? [];
|
|
60
|
-
return `${base}[${String(path[path.length - 2] ?? 0)}].${String(path[path.length - 1] ?? "")}`;
|
|
61
|
-
}
|
|
62
|
-
/** The last segment of a reported position — a record key, or an array index. */
|
|
63
|
-
export function lastSegment(issuePath) {
|
|
64
|
-
const segment = issuePath?.[issuePath.length - 1];
|
|
65
|
-
return segment === undefined ? "" : String(segment);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* A required, non-empty string reported under `path`.
|
|
69
|
-
*
|
|
70
|
-
* The type failure and the emptiness failure share one message because the
|
|
71
|
-
* `requireString(value, path)` ladder this replaces collapsed them, and `abort`
|
|
72
|
-
* keeps the second from firing on a value that never cleared the first.
|
|
73
|
-
*/
|
|
74
|
-
export function nonEmptyString(path) {
|
|
75
|
-
const message = `${path} must be a non-empty string`;
|
|
76
|
-
return z.string({ error: message }).check(z.minLength(1, { error: message, abort: true }));
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A strict object schema that reports unknown keys and non-object input in the
|
|
80
|
-
* caller's own words.
|
|
81
|
-
*
|
|
82
|
-
* `path` is the wire path the surrounding parser reports errors under
|
|
83
|
-
* (`"webhook"`, `"submission.environment"`), not a schema name. Pass a function
|
|
84
|
-
* when the object sits inside an array and the path carries an index — it
|
|
85
|
-
* receives the issue's position, which {@link wirePath} renders.
|
|
86
|
-
*/
|
|
87
|
-
export function wireObject(path, shape, text = {}) {
|
|
88
|
-
const permitted = Object.freeze(Object.keys(shape));
|
|
89
|
-
const notObject = text.notObject ?? defaultText.notObject;
|
|
90
|
-
const unknownKey = text.unknownKey ?? defaultText.unknownKey;
|
|
91
|
-
const resolvePath = typeof path === "string" ? () => path : (issuePath) => path(issuePath);
|
|
92
|
-
const schema = z.strictObject(shape, {
|
|
93
|
-
error: (issue) => issue.code === "unrecognized_keys"
|
|
94
|
-
? messageOf(unknownKey(resolvePath(issue.path ?? []), issue.keys[0] ?? "", permitted))
|
|
95
|
-
: notObject(resolvePath(issue.path ?? []))
|
|
96
|
-
});
|
|
97
|
-
wireObjectMeta.set(schema, { resolvePath, permitted, unknownKey });
|
|
98
|
-
return schema;
|
|
99
|
-
}
|
|
100
|
-
function messageOf(text) {
|
|
101
|
-
return typeof text === "string" ? text : text.message;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* The issue a hand-written parser would have raised first.
|
|
105
|
-
*
|
|
106
|
-
* The parsers these schemas replace validate an object top-down — shape, then
|
|
107
|
-
* the allow-list, then each field in turn, recursing as they go — so the
|
|
108
|
-
* shallowest complaint surfaces and deeper ones never run. Zod collects every
|
|
109
|
-
* issue instead. Ordering by path depth, with a rejected key ahead of a field
|
|
110
|
-
* error at the same depth, reproduces the original traversal, which the
|
|
111
|
-
* error-precedence tests pin.
|
|
112
|
-
*/
|
|
113
|
-
function primaryIssue(issues) {
|
|
114
|
-
return [...issues].sort((left, right) => left.path.length - right.path.length || issueRank(left) - issueRank(right))[0];
|
|
115
|
-
}
|
|
116
|
-
function issueRank(issue) {
|
|
117
|
-
return issue.code === "unrecognized_keys" ? 0 : 1;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Map a failed parse onto the package's error surface: a plain `Error` carrying
|
|
121
|
-
* the message the schema declared.
|
|
122
|
-
*
|
|
123
|
-
* Deliberately not a `ZodError`. Callers wrap parsers in `withContractParseError`,
|
|
124
|
-
* which brands the thrown error with non-enumerable metadata and asserts the
|
|
125
|
-
* error has no enumerable own keys of its own; a `ZodError` carries `issues`
|
|
126
|
-
* and would break that contract as well as leak the schema library into a
|
|
127
|
-
* public error shape.
|
|
128
|
-
*/
|
|
129
|
-
export function errorFromZod(error) {
|
|
130
|
-
return new Error(primaryIssue(error.issues)?.message ?? "invalid input");
|
|
131
|
-
}
|
|
132
|
-
/** Parse `input` against `schema`, throwing the family's own error text on failure. */
|
|
133
|
-
export function parseWire(schema, input) {
|
|
134
|
-
const meta = wireObjectMeta.get(schema);
|
|
135
|
-
if (meta && input !== null && typeof input === "object" && !Array.isArray(input)) {
|
|
136
|
-
// Zod deliberately skips `__proto__` while collecting unknown keys so a
|
|
137
|
-
// plain-object output cannot have its prototype replaced. That safety
|
|
138
|
-
// rule must not turn an attacker-controlled field into an accepted field;
|
|
139
|
-
// recover the strict wire-object diagnostic before Zod sees the input.
|
|
140
|
-
const unknownKey = Object.keys(input).find((key) => !meta.permitted.includes(key));
|
|
141
|
-
if (unknownKey !== undefined) {
|
|
142
|
-
const diagnostic = meta.unknownKey(meta.resolvePath([]), unknownKey, meta.permitted);
|
|
143
|
-
throw typeof diagnostic === "string" ? new Error(diagnostic) : diagnostic;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const result = z.safeParse(schema, input);
|
|
147
|
-
if (!result.success) {
|
|
148
|
-
throw structuredError(schema, result.error) ?? errorFromZod(result.error);
|
|
149
|
-
}
|
|
150
|
-
return result.data;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Recover the family's own `Error` subclass for an unknown key at the root of
|
|
154
|
-
* this schema, when it declared one.
|
|
155
|
-
*
|
|
156
|
-
* Zod carries messages, not error instances, so the structured diagnostic has to
|
|
157
|
-
* be rebuilt here — this is the one place that holds both the schema and the
|
|
158
|
-
* failure.
|
|
159
|
-
*/
|
|
160
|
-
function structuredError(schema, error) {
|
|
161
|
-
const issue = primaryIssue(error.issues);
|
|
162
|
-
if (issue?.code !== "unrecognized_keys" || issue.path.length > 0) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
const meta = wireObjectMeta.get(schema);
|
|
166
|
-
if (!meta) {
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
const rebuilt = meta.unknownKey(meta.resolvePath(issue.path), issue.keys[0] ?? "", meta.permitted);
|
|
170
|
-
return typeof rebuilt === "string" ? undefined : rebuilt;
|
|
171
|
-
}
|