@agent-vm/agent-portal-sdk 0.0.120 → 0.0.122
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/dist/adapter-boundary/index.d.ts +2 -0
- package/dist/adapter-boundary/index.js +2 -0
- package/dist/adapter-boundary-BIagsTUH.js +29 -0
- package/dist/adapter-boundary-BIagsTUH.js.map +1 -0
- package/dist/approval-surface/index.d.ts +2 -0
- package/dist/approval-surface/index.js +2 -0
- package/dist/approval-surface-en5VAY5h.js +20 -0
- package/dist/approval-surface-en5VAY5h.js.map +1 -0
- package/dist/artifact-reference-schema-CiEjxYPd.js +13 -0
- package/dist/artifact-reference-schema-CiEjxYPd.js.map +1 -0
- package/dist/artifact-surface/index.d.ts +2 -0
- package/dist/artifact-surface/index.js +3 -0
- package/dist/artifact-surface-BstQxq6b.js +65 -0
- package/dist/artifact-surface-BstQxq6b.js.map +1 -0
- package/dist/capability-description-surface/index.d.ts +2 -0
- package/dist/capability-description-surface/index.js +3 -0
- package/dist/capability-description-surface-BdzknTKT.js +2 -0
- package/dist/capability-descriptor-schema-zRnfGjBc.js +86 -0
- package/dist/capability-descriptor-schema-zRnfGjBc.js.map +1 -0
- package/dist/cli/tool-portal.d.ts +1 -0
- package/dist/cli/tool-portal.js +207 -0
- package/dist/cli/tool-portal.js.map +1 -0
- package/dist/contracts/index.d.ts +2 -0
- package/dist/contracts/index.js +2 -0
- package/dist/contracts-RgGW0RX2.js +611 -0
- package/dist/contracts-RgGW0RX2.js.map +1 -0
- package/dist/gateway-runtime-client/index.d.ts +385 -0
- package/dist/gateway-runtime-client/index.d.ts.map +1 -0
- package/dist/gateway-runtime-client/index.js +1439 -0
- package/dist/gateway-runtime-client/index.js.map +1 -0
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.d.ts +1 -0
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.js +125 -0
- package/dist/gateway-runtime-local-exec/gateway-runtime-local-exec-helper.js.map +1 -0
- package/dist/gateway-runtime-local-exec/index.d.ts +54 -0
- package/dist/gateway-runtime-local-exec/index.d.ts.map +1 -0
- package/dist/gateway-runtime-local-exec/index.js +2 -0
- package/dist/gateway-runtime-local-exec-transport-B1hy2A3Q.js +427 -0
- package/dist/gateway-runtime-local-exec-transport-B1hy2A3Q.js.map +1 -0
- package/dist/index-B5hgm1KH.d.ts +84 -0
- package/dist/index-B5hgm1KH.d.ts.map +1 -0
- package/dist/index-BWE2_BcN.d.ts +64 -0
- package/dist/index-BWE2_BcN.d.ts.map +1 -0
- package/dist/index-BmH68K78.d.ts +41 -0
- package/dist/index-BmH68K78.d.ts.map +1 -0
- package/dist/index-ByAhyVbI.d.ts +142 -0
- package/dist/index-ByAhyVbI.d.ts.map +1 -0
- package/dist/index-C-NPMMvc.d.ts +2396 -0
- package/dist/index-C-NPMMvc.d.ts.map +1 -0
- package/dist/index-DKBSYuxW.d.ts +239 -0
- package/dist/index-DKBSYuxW.d.ts.map +1 -0
- package/dist/index-Dj4galCJ.d.ts +17 -0
- package/dist/index-Dj4galCJ.d.ts.map +1 -0
- package/dist/index-Dxoz-ORl.d.ts +229 -0
- package/dist/index-Dxoz-ORl.d.ts.map +1 -0
- package/dist/index-v8suC0qe.d.ts +69 -0
- package/dist/index-v8suC0qe.d.ts.map +1 -0
- package/dist/index-yeFGRMdv.d.ts +152 -0
- package/dist/index-yeFGRMdv.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +16 -0
- package/dist/json-value-schema-M87sjwWL.d.ts +18 -0
- package/dist/json-value-schema-M87sjwWL.d.ts.map +1 -0
- package/dist/json-value-schema-hdPkabRZ.js +29 -0
- package/dist/json-value-schema-hdPkabRZ.js.map +1 -0
- package/dist/node-tool-portal-mcp-transport-Cl2VKbLY.js +156 -0
- package/dist/node-tool-portal-mcp-transport-Cl2VKbLY.js.map +1 -0
- package/dist/portable-contracts/index.d.ts +2 -0
- package/dist/portable-contracts/index.js +3 -0
- package/dist/portable-contracts-Bca33zVa.js +326 -0
- package/dist/portable-contracts-Bca33zVa.js.map +1 -0
- package/dist/portable-refinement-authoring-ZSmR-amG.js +196 -0
- package/dist/portable-refinement-authoring-ZSmR-amG.js.map +1 -0
- package/dist/portal-call-request-schema-Cp6CMGs9.js +41 -0
- package/dist/portal-call-request-schema-Cp6CMGs9.js.map +1 -0
- package/dist/portal-call-result-schema-ByxHRCEN.js +158 -0
- package/dist/portal-call-result-schema-ByxHRCEN.js.map +1 -0
- package/dist/portal-call-result-schema-wSCaz3mC.d.ts +1485 -0
- package/dist/portal-call-result-schema-wSCaz3mC.d.ts.map +1 -0
- package/dist/portal-call-surface/index.d.ts +3 -0
- package/dist/portal-call-surface/index.js +5 -0
- package/dist/portal-call-surface-DjZVquFt.js +83 -0
- package/dist/portal-call-surface-DjZVquFt.js.map +1 -0
- package/dist/portal-error-schema-CQHgoFq4.js +71 -0
- package/dist/portal-error-schema-CQHgoFq4.js.map +1 -0
- package/dist/portal-event-surface/index.d.ts +2 -0
- package/dist/portal-event-surface/index.js +3 -0
- package/dist/portal-event-surface-CdScrgoN.js +51 -0
- package/dist/portal-event-surface-CdScrgoN.js.map +1 -0
- package/dist/testing/index.d.ts +19 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +36 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tool-portal-mcp-client/index.d.ts +2 -0
- package/dist/tool-portal-mcp-client/index.js +2 -0
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.d.ts +17 -0
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.d.ts.map +1 -0
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.js +2 -0
- package/dist/tool-portal-mcp-client-DwJF-48Y.js +90 -0
- package/dist/tool-portal-mcp-client-DwJF-48Y.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { i as PORTABLE_REFINEMENT_IDENTITIES, t as portableRefinementIdentityForCheck } from "./portable-refinement-authoring-ZSmR-amG.js";
|
|
2
|
+
import "./portal-error-schema-CQHgoFq4.js";
|
|
3
|
+
import { t as ArtifactReferenceSchema } from "./artifact-reference-schema-CiEjxYPd.js";
|
|
4
|
+
import "./capability-descriptor-schema-zRnfGjBc.js";
|
|
5
|
+
import { o as JsonValueSchema } from "./json-value-schema-hdPkabRZ.js";
|
|
6
|
+
import { d as PortalListResultSchema, i as PortalCallResultSchema, m as PortalSearchResultSchema, r as PortalCallItemResultSchema, s as PortalDescribeResultSchema } from "./portal-call-result-schema-ByxHRCEN.js";
|
|
7
|
+
import { a as PortalArtifactReadRequestSchema, o as PortalArtifactReadResultSchema } from "./artifact-surface-BstQxq6b.js";
|
|
8
|
+
import { f as ManagedAgentProjectionSchema, ft as SandboxRetainedResultLookupRequestSchema, lt as SandboxOperationControlResultSchema, n as GatewayRuntimeAttachmentMetadataSchema, pt as SandboxRetainedResultLookupResultSchema, s as GatewayRuntimeTrustedInvocationContextSchema, t as SANDBOX_METHOD_CONTRACTS, ut as SandboxOperationIdentitySchema } from "./contracts-RgGW0RX2.js";
|
|
9
|
+
import { r as PortalCallRequestSchema } from "./portal-call-request-schema-Cp6CMGs9.js";
|
|
10
|
+
import { a as PortalListRequestSchema, r as PortalSearchRequestSchema, s as PortalDescribeRequestSchema } from "./portal-call-surface-DjZVquFt.js";
|
|
11
|
+
import { o as PortalProgressEventSchema } from "./portal-event-surface-CdScrgoN.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
//#region src/portable-contracts/portable-contract-runtime.ts
|
|
14
|
+
const PORTABLE_CONTRACT_PROTOCOL_VERSION = 1;
|
|
15
|
+
function isUnknownRecord(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function isZodSchema(value) {
|
|
19
|
+
return isUnknownRecord(value) && isUnknownRecord(value["_zod"]) && "def" in value["_zod"];
|
|
20
|
+
}
|
|
21
|
+
function containsUnsafeInteger(value) {
|
|
22
|
+
if (typeof value === "number") return Number.isInteger(value) && !Number.isSafeInteger(value);
|
|
23
|
+
if (Array.isArray(value)) return value.some((item) => containsUnsafeInteger(item));
|
|
24
|
+
if (isUnknownRecord(value)) return Object.values(value).some((childValue) => containsUnsafeInteger(childValue));
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
function inspectPortableSchemaNode(props) {
|
|
28
|
+
if (typeof props.node !== "object" && typeof props.node !== "function" || props.node === null) return;
|
|
29
|
+
if (props.visited.has(props.node)) return;
|
|
30
|
+
props.visited.add(props.node);
|
|
31
|
+
if (isZodSchema(props.node)) {
|
|
32
|
+
const definition = props.node._zod.def;
|
|
33
|
+
if (isUnknownRecord(definition) && definition["type"] === "transform") throw new Error(`Portable schema ${props.schemaId} contains an anonymous or unregistered transform.`);
|
|
34
|
+
if (isUnknownRecord(definition) && Array.isArray(definition["checks"])) {
|
|
35
|
+
for (const check of definition["checks"]) if (isUnknownRecord(check) && isUnknownRecord(check["_zod"]) && isUnknownRecord(check["_zod"]["def"]) && check["_zod"]["def"]["check"] === "custom") {
|
|
36
|
+
if (portableRefinementIdentityForCheck(check) !== void 0) continue;
|
|
37
|
+
throw new Error(`Portable schema ${props.schemaId} contains an anonymous or unregistered refinement.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
inspectPortableSchemaNode({
|
|
41
|
+
node: definition,
|
|
42
|
+
schemaId: props.schemaId,
|
|
43
|
+
visited: props.visited
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (Array.isArray(props.node)) {
|
|
48
|
+
for (const child of props.node) inspectPortableSchemaNode({
|
|
49
|
+
node: child,
|
|
50
|
+
schemaId: props.schemaId,
|
|
51
|
+
visited: props.visited
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const child of Object.values(props.node)) inspectPortableSchemaNode({
|
|
56
|
+
node: child,
|
|
57
|
+
schemaId: props.schemaId,
|
|
58
|
+
visited: props.visited
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function assertPortableContractSchemaIsExportable(props) {
|
|
62
|
+
inspectPortableSchemaNode({
|
|
63
|
+
node: props.schema,
|
|
64
|
+
schemaId: props.schemaId,
|
|
65
|
+
visited: /* @__PURE__ */ new Set()
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function normalizeCanonicalJsonValue(value) {
|
|
69
|
+
if (typeof value === "number") return Object.is(value, -0) ? 0 : value;
|
|
70
|
+
if (Array.isArray(value)) return value.map((item) => normalizeCanonicalJsonValue(item));
|
|
71
|
+
if (isUnknownRecord(value)) return Object.fromEntries(Object.entries(value).toSorted(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([key, childValue]) => [key, normalizeCanonicalJsonValue(childValue)]));
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
function encodeCanonicalJson(value) {
|
|
75
|
+
const encodedValue = JSON.stringify(normalizeCanonicalJsonValue(value));
|
|
76
|
+
if (encodedValue === void 0) throw new Error("Canonical JSON input must be JSON-serializable.");
|
|
77
|
+
return encodedValue;
|
|
78
|
+
}
|
|
79
|
+
function mapPortableIssue(props) {
|
|
80
|
+
if (props.schemaId === "portal.call.item-result") {
|
|
81
|
+
const firstPathSegment = props.issue.path?.[0];
|
|
82
|
+
if (firstPathSegment === "outcome" || firstPathSegment === "operationId" || firstPathSegment === "owningGeneration") return "portal.result.outcome-algebra";
|
|
83
|
+
if (props.issue.code === "unrecognized_keys" || props.issue.code === "invalid_union") return "portal.result.status-shape";
|
|
84
|
+
}
|
|
85
|
+
if (props.issue.code === "unrecognized_keys") return "portable.object.unknown-field";
|
|
86
|
+
if (props.issue.code === "invalid_type" && props.issue.path?.length === 1 && isUnknownRecord(props.input) && typeof props.issue.path[0] === "string" && !(props.issue.path[0] in props.input)) return "portable.object.missing-field";
|
|
87
|
+
if (props.issue.code === "invalid_format" && "format" in props.issue && props.issue.format === "starts_with") return "portable.string.pattern";
|
|
88
|
+
if (props.issue.code === "too_big" && props.issue.origin === "number") return "portable.number.above-maximum";
|
|
89
|
+
if (props.issue.code === "custom") {
|
|
90
|
+
if (props.issue.message.includes("decoded canonical base64 content")) return "sandbox.binary-chunk.byte-length-mismatch";
|
|
91
|
+
if (props.issue.message.includes("duplicate variable name")) return "sandbox.environment-variable.duplicate-name";
|
|
92
|
+
if (props.issue.message.includes("duplicate configured agent id")) return "gateway.attachment.duplicate-agent-id";
|
|
93
|
+
if (props.issue.message.includes("server-selected work root")) return "sandbox.path.not-work-relative";
|
|
94
|
+
if (props.issue.message.startsWith("Duplicate portal item id")) return "portal.batch.unique-item-ids";
|
|
95
|
+
if (props.issue.message.includes("reserved object property name")) return "portal.request-id.not-reserved";
|
|
96
|
+
if (props.issue.message.includes("maximum number of entries")) return "portable.object.above-maximum";
|
|
97
|
+
if (props.issue.message.includes("ok must match item statuses")) return "portal.result.aggregate-status";
|
|
98
|
+
}
|
|
99
|
+
return `portable.zod.${props.issue.code}`;
|
|
100
|
+
}
|
|
101
|
+
function createPortableContractAdapter(props) {
|
|
102
|
+
return { parse: (input) => {
|
|
103
|
+
if (containsUnsafeInteger(input)) return {
|
|
104
|
+
errorCodes: ["portable.number.unsafe-integer"],
|
|
105
|
+
kind: "rejected",
|
|
106
|
+
refinementIdentities: [...new Set([...props.definition.refinementIdentities, "portal.number.safe-integer"])].toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity))
|
|
107
|
+
};
|
|
108
|
+
const parsed = props.definition.schema.safeParse(input);
|
|
109
|
+
const refinementIdentities = (props.definition.resolveRefinementIdentities?.({
|
|
110
|
+
input,
|
|
111
|
+
parseSucceeded: parsed.success
|
|
112
|
+
}) ?? props.definition.refinementIdentities).toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity));
|
|
113
|
+
if (!parsed.success) return {
|
|
114
|
+
errorCodes: props.schemaId === "portal.call.item-result" && isUnknownRecord(input) && callItemHasStatusShapeConflict(input) ? ["portal.result.status-shape"] : [...new Set(parsed.error.issues.map((issue) => mapPortableIssue({
|
|
115
|
+
input,
|
|
116
|
+
issue,
|
|
117
|
+
schemaId: props.schemaId
|
|
118
|
+
})))].toSorted((leftCode, rightCode) => leftCode.localeCompare(rightCode)),
|
|
119
|
+
kind: "rejected",
|
|
120
|
+
refinementIdentities
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
kind: "accepted",
|
|
124
|
+
normalized: normalizeCanonicalJsonValue(parsed.data),
|
|
125
|
+
refinementIdentities
|
|
126
|
+
};
|
|
127
|
+
} };
|
|
128
|
+
}
|
|
129
|
+
function callItemHasStatusShapeConflict(input) {
|
|
130
|
+
return input["status"] === "ok" && "error" in input || input["status"] === "error" && "value" in input;
|
|
131
|
+
}
|
|
132
|
+
const portableContractDefinitions = {
|
|
133
|
+
"portal.artifact.read-request": {
|
|
134
|
+
refinementIdentities: [],
|
|
135
|
+
schema: PortalArtifactReadRequestSchema
|
|
136
|
+
},
|
|
137
|
+
"portal.artifact.read-result": {
|
|
138
|
+
refinementIdentities: ["portal.artifact-read.default-truncated"],
|
|
139
|
+
schema: PortalArtifactReadResultSchema
|
|
140
|
+
},
|
|
141
|
+
"portal.artifact.reference": {
|
|
142
|
+
refinementIdentities: [],
|
|
143
|
+
schema: ArtifactReferenceSchema
|
|
144
|
+
},
|
|
145
|
+
"portal.call.item-result": {
|
|
146
|
+
refinementIdentities: ["portal.request-id.not-reserved", "portal.result.outcome-algebra"],
|
|
147
|
+
resolveRefinementIdentities: ({ input }) => {
|
|
148
|
+
return isUnknownRecord(input) && !callItemHasStatusShapeConflict(input) && ("outcome" in input || !("operationId" in input)) ? ["portal.request-id.not-reserved", "portal.result.outcome-algebra"] : ["portal.request-id.not-reserved"];
|
|
149
|
+
},
|
|
150
|
+
schema: PortalCallItemResultSchema
|
|
151
|
+
},
|
|
152
|
+
"portal.call.request": {
|
|
153
|
+
refinementIdentities: [
|
|
154
|
+
"portal.batch.unique-item-ids",
|
|
155
|
+
"portal.json.canonical",
|
|
156
|
+
"portal.request-id.not-reserved"
|
|
157
|
+
],
|
|
158
|
+
resolveRefinementIdentities: ({ parseSucceeded }) => {
|
|
159
|
+
return parseSucceeded ? [
|
|
160
|
+
"portal.batch.unique-item-ids",
|
|
161
|
+
"portal.json.canonical",
|
|
162
|
+
"portal.request-id.not-reserved"
|
|
163
|
+
] : ["portal.batch.unique-item-ids", "portal.request-id.not-reserved"];
|
|
164
|
+
},
|
|
165
|
+
schema: PortalCallRequestSchema
|
|
166
|
+
},
|
|
167
|
+
"portal.call.result": {
|
|
168
|
+
refinementIdentities: [
|
|
169
|
+
"portal.request-id.not-reserved",
|
|
170
|
+
"portal.result.aggregate-status",
|
|
171
|
+
"portal.result.outcome-algebra"
|
|
172
|
+
],
|
|
173
|
+
schema: PortalCallResultSchema
|
|
174
|
+
},
|
|
175
|
+
"portal.describe.request": {
|
|
176
|
+
refinementIdentities: [
|
|
177
|
+
"portal.batch.unique-item-ids",
|
|
178
|
+
"portal.describe.default-includes",
|
|
179
|
+
"portal.request-id.not-reserved"
|
|
180
|
+
],
|
|
181
|
+
schema: PortalDescribeRequestSchema
|
|
182
|
+
},
|
|
183
|
+
"portal.describe.result": {
|
|
184
|
+
refinementIdentities: ["portal.request-id.not-reserved", "portal.result.aggregate-status"],
|
|
185
|
+
schema: PortalDescribeResultSchema
|
|
186
|
+
},
|
|
187
|
+
"portal.json-value": {
|
|
188
|
+
refinementIdentities: ["portal.json.canonical", "portal.json.max-object-entries"],
|
|
189
|
+
resolveRefinementIdentities: ({ input }) => {
|
|
190
|
+
return isUnknownRecord(input) && Object.keys(input).length > 1e3 ? ["portal.json.canonical", "portal.json.max-object-entries"] : ["portal.json.canonical"];
|
|
191
|
+
},
|
|
192
|
+
schema: JsonValueSchema
|
|
193
|
+
},
|
|
194
|
+
"portal.list.request": {
|
|
195
|
+
refinementIdentities: [
|
|
196
|
+
"portal.batch.unique-item-ids",
|
|
197
|
+
"portal.list.default-limit",
|
|
198
|
+
"portal.request-id.not-reserved"
|
|
199
|
+
],
|
|
200
|
+
schema: PortalListRequestSchema
|
|
201
|
+
},
|
|
202
|
+
"portal.list.result": {
|
|
203
|
+
refinementIdentities: ["portal.request-id.not-reserved", "portal.result.aggregate-status"],
|
|
204
|
+
schema: PortalListResultSchema
|
|
205
|
+
},
|
|
206
|
+
"portal.progress.event": {
|
|
207
|
+
refinementIdentities: ["portal.request-id.not-reserved"],
|
|
208
|
+
schema: PortalProgressEventSchema
|
|
209
|
+
},
|
|
210
|
+
"portal.search.request": {
|
|
211
|
+
refinementIdentities: [
|
|
212
|
+
"portal.batch.unique-item-ids",
|
|
213
|
+
"portal.request-id.not-reserved",
|
|
214
|
+
"portal.search.default-limit",
|
|
215
|
+
"portal.search.default-schema-detail"
|
|
216
|
+
],
|
|
217
|
+
schema: PortalSearchRequestSchema
|
|
218
|
+
},
|
|
219
|
+
"portal.search.result": {
|
|
220
|
+
refinementIdentities: ["portal.request-id.not-reserved", "portal.result.aggregate-status"],
|
|
221
|
+
schema: PortalSearchResultSchema
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const canonicalGatewayContractDefinitions = {
|
|
225
|
+
"gateway.attachment.metadata": {
|
|
226
|
+
refinementIdentities: ["gateway.attachment.unique-agent-ids"],
|
|
227
|
+
schema: GatewayRuntimeAttachmentMetadataSchema
|
|
228
|
+
},
|
|
229
|
+
"gateway.managed-agent-projection": {
|
|
230
|
+
refinementIdentities: [],
|
|
231
|
+
schema: ManagedAgentProjectionSchema
|
|
232
|
+
},
|
|
233
|
+
"gateway.trusted-invocation-context": {
|
|
234
|
+
refinementIdentities: [],
|
|
235
|
+
schema: GatewayRuntimeTrustedInvocationContextSchema
|
|
236
|
+
},
|
|
237
|
+
"sandbox.operation.control-result": {
|
|
238
|
+
refinementIdentities: ["portal.result.outcome-algebra"],
|
|
239
|
+
schema: SandboxOperationControlResultSchema
|
|
240
|
+
},
|
|
241
|
+
"sandbox.operation.identity": {
|
|
242
|
+
refinementIdentities: [],
|
|
243
|
+
schema: SandboxOperationIdentitySchema
|
|
244
|
+
},
|
|
245
|
+
"sandbox.retained-result.lookup-request": {
|
|
246
|
+
refinementIdentities: [],
|
|
247
|
+
schema: SandboxRetainedResultLookupRequestSchema
|
|
248
|
+
},
|
|
249
|
+
"sandbox.retained-result.lookup-result": {
|
|
250
|
+
refinementIdentities: ["portal.result.outcome-algebra"],
|
|
251
|
+
schema: SandboxRetainedResultLookupResultSchema
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function resolveSandboxMethodPortableContractMetadata(props) {
|
|
255
|
+
if (props.method === "sandbox.retained-result.lookup") return {
|
|
256
|
+
requestRefinementIdentities: [...props.sharedRefinementIdentities, ...props.requestOnlyRefinementIdentities],
|
|
257
|
+
requestSchemaId: "sandbox.retained-result.lookup-request",
|
|
258
|
+
resultRefinementIdentities: [...props.sharedRefinementIdentities, "portal.result.outcome-algebra"],
|
|
259
|
+
resultSchemaId: "sandbox.retained-result.lookup-result"
|
|
260
|
+
};
|
|
261
|
+
return {
|
|
262
|
+
requestRefinementIdentities: [...props.sharedRefinementIdentities, ...props.requestOnlyRefinementIdentities],
|
|
263
|
+
requestSchemaId: `${props.method}.request`,
|
|
264
|
+
resultRefinementIdentities: props.sharedRefinementIdentities,
|
|
265
|
+
resultSchemaId: `${props.method}.result`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function createSandboxMethodContractDefinitions() {
|
|
269
|
+
const contractDefinitions = {};
|
|
270
|
+
for (const [method, contracts] of Object.entries(SANDBOX_METHOD_CONTRACTS)) {
|
|
271
|
+
const refinementIdentities = method.startsWith("sandbox.environment.") ? ["sandbox.path.work-relative"] : [];
|
|
272
|
+
const requestOnlyRefinementIdentities = method === "sandbox.exec.start" || method === "sandbox.process.start" ? ["sandbox.environment-variable.unique-names"] : [];
|
|
273
|
+
if ([
|
|
274
|
+
"sandbox.fs.read",
|
|
275
|
+
"sandbox.fs.write",
|
|
276
|
+
"sandbox.process.logs",
|
|
277
|
+
"sandbox.stream.read",
|
|
278
|
+
"sandbox.stream.write"
|
|
279
|
+
].includes(method)) refinementIdentities.push("sandbox.binary-chunk.byte-length");
|
|
280
|
+
const metadata = resolveSandboxMethodPortableContractMetadata({
|
|
281
|
+
method,
|
|
282
|
+
requestOnlyRefinementIdentities,
|
|
283
|
+
sharedRefinementIdentities: refinementIdentities
|
|
284
|
+
});
|
|
285
|
+
contractDefinitions[metadata.requestSchemaId] = {
|
|
286
|
+
refinementIdentities: metadata.requestRefinementIdentities,
|
|
287
|
+
schema: contracts.request
|
|
288
|
+
};
|
|
289
|
+
contractDefinitions[metadata.resultSchemaId] = {
|
|
290
|
+
refinementIdentities: metadata.resultRefinementIdentities,
|
|
291
|
+
schema: contracts.result
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
return contractDefinitions;
|
|
295
|
+
}
|
|
296
|
+
const sandboxMethodContractDefinitions = createSandboxMethodContractDefinitions();
|
|
297
|
+
const allPortableContractDefinitions = {
|
|
298
|
+
...portableContractDefinitions,
|
|
299
|
+
...canonicalGatewayContractDefinitions,
|
|
300
|
+
...sandboxMethodContractDefinitions
|
|
301
|
+
};
|
|
302
|
+
for (const [schemaId, definition] of Object.entries(allPortableContractDefinitions)) assertPortableContractSchemaIsExportable({
|
|
303
|
+
schema: definition.schema,
|
|
304
|
+
schemaId
|
|
305
|
+
});
|
|
306
|
+
function createPortableContractSchemaManifest() {
|
|
307
|
+
return {
|
|
308
|
+
protocolVersion: 1,
|
|
309
|
+
refinements: PORTABLE_REFINEMENT_IDENTITIES,
|
|
310
|
+
schemas: Object.fromEntries(Object.entries(allPortableContractDefinitions).map(([schemaId, definition]) => [schemaId, {
|
|
311
|
+
jsonSchema: z.toJSONSchema(definition.schema, {
|
|
312
|
+
io: "input",
|
|
313
|
+
unrepresentable: "any"
|
|
314
|
+
}),
|
|
315
|
+
refinementIdentities: definition.refinementIdentities.toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity))
|
|
316
|
+
}]))
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const PORTABLE_CONTRACT_ADAPTERS = Object.fromEntries(Object.entries(allPortableContractDefinitions).map(([schemaId, definition]) => [schemaId, createPortableContractAdapter({
|
|
320
|
+
definition,
|
|
321
|
+
schemaId
|
|
322
|
+
})]));
|
|
323
|
+
//#endregion
|
|
324
|
+
export { encodeCanonicalJson as a, createPortableContractSchemaManifest as i, PORTABLE_CONTRACT_PROTOCOL_VERSION as n, assertPortableContractSchemaIsExportable as r, PORTABLE_CONTRACT_ADAPTERS as t };
|
|
325
|
+
|
|
326
|
+
//# sourceMappingURL=portable-contracts-Bca33zVa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-contracts-Bca33zVa.js","names":[],"sources":["../src/portable-contracts/portable-contract-runtime.ts"],"sourcesContent":["import { z } from 'zod';\n\nimport {\n\tArtifactReferenceSchema,\n\tPortalArtifactReadRequestSchema,\n\tPortalArtifactReadResultSchema,\n} from '../artifact-surface/index.js';\nimport { JsonValueSchema } from '../contract-primitives/index.js';\nimport {\n\tGatewayRuntimeAttachmentMetadataSchema,\n\tGatewayRuntimeTrustedInvocationContextSchema,\n\tManagedAgentProjectionSchema,\n\tSANDBOX_METHOD_CONTRACTS,\n\tSandboxOperationControlResultSchema,\n\tSandboxOperationIdentitySchema,\n\tSandboxRetainedResultLookupRequestSchema,\n\tSandboxRetainedResultLookupResultSchema,\n} from '../contracts/index.js';\nimport {\n\tPortalCallItemResultSchema,\n\tPortalCallRequestSchema,\n\tPortalCallResultSchema,\n\tPortalDescribeRequestSchema,\n\tPortalDescribeResultSchema,\n\tPortalListRequestSchema,\n\tPortalListResultSchema,\n\tPortalSearchRequestSchema,\n\tPortalSearchResultSchema,\n} from '../portal-call-surface/index.js';\nimport { PortalProgressEventSchema } from '../portal-event-surface/index.js';\nimport { portableRefinementIdentityForCheck } from './portable-refinement-authoring.js';\nimport { PORTABLE_REFINEMENT_IDENTITIES } from './portable-refinement-descriptors.js';\nexport {\n\tPORTABLE_REFINEMENT_DESCRIPTORS,\n\tPORTABLE_REFINEMENT_IDENTITIES,\n} from './portable-refinement-descriptors.js';\n\ninterface PortableAcceptedContractParseResult {\n\treadonly kind: 'accepted';\n\treadonly normalized: unknown;\n\treadonly refinementIdentities: readonly string[];\n}\n\ninterface PortableRejectedContractParseResult {\n\treadonly errorCodes: readonly string[];\n\treadonly kind: 'rejected';\n\treadonly refinementIdentities: readonly string[];\n}\n\nexport type PortableContractParseResult =\n\t| PortableAcceptedContractParseResult\n\t| PortableRejectedContractParseResult;\n\nexport interface PortableContractAdapter {\n\treadonly parse: (input: unknown) => PortableContractParseResult;\n}\n\nexport const PORTABLE_CONTRACT_PROTOCOL_VERSION = 1;\n\ninterface PortableContractDefinition {\n\treadonly refinementIdentities: readonly string[];\n\treadonly resolveRefinementIdentities?: (props: {\n\t\treadonly input: unknown;\n\t\treadonly parseSucceeded: boolean;\n\t}) => readonly string[];\n\treadonly schema: z.ZodType;\n}\n\ninterface PortableSchemaExportabilityProps {\n\treadonly schema: z.ZodType;\n\treadonly schemaId: string;\n}\n\nfunction isUnknownRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isZodSchema(value: unknown): value is z.ZodType {\n\treturn isUnknownRecord(value) && isUnknownRecord(value['_zod']) && 'def' in value['_zod'];\n}\n\nfunction containsUnsafeInteger(value: unknown): boolean {\n\tif (typeof value === 'number') return Number.isInteger(value) && !Number.isSafeInteger(value);\n\tif (Array.isArray(value)) return value.some((item) => containsUnsafeInteger(item));\n\tif (isUnknownRecord(value)) {\n\t\treturn Object.values(value).some((childValue) => containsUnsafeInteger(childValue));\n\t}\n\treturn false;\n}\n\nfunction inspectPortableSchemaNode(props: {\n\treadonly node: unknown;\n\treadonly schemaId: string;\n\treadonly visited: Set<object>;\n}): void {\n\tif ((typeof props.node !== 'object' && typeof props.node !== 'function') || props.node === null) {\n\t\treturn;\n\t}\n\tif (props.visited.has(props.node)) {\n\t\treturn;\n\t}\n\tprops.visited.add(props.node);\n\n\tif (isZodSchema(props.node)) {\n\t\t// oxlint-disable-next-line no-underscore-dangle -- Zod v4 core definitions are required for the portable-authoring structural guard.\n\t\tconst definition: unknown = props.node._zod.def;\n\t\tif (isUnknownRecord(definition) && definition['type'] === 'transform') {\n\t\t\tthrow new Error(\n\t\t\t\t`Portable schema ${props.schemaId} contains an anonymous or unregistered transform.`,\n\t\t\t);\n\t\t}\n\t\tif (isUnknownRecord(definition) && Array.isArray(definition['checks'])) {\n\t\t\tfor (const check of definition['checks']) {\n\t\t\t\tif (\n\t\t\t\t\tisUnknownRecord(check) &&\n\t\t\t\t\tisUnknownRecord(check['_zod']) &&\n\t\t\t\t\tisUnknownRecord(check['_zod']['def']) &&\n\t\t\t\t\tcheck['_zod']['def']['check'] === 'custom'\n\t\t\t\t) {\n\t\t\t\t\tif (portableRefinementIdentityForCheck(check) !== undefined) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Portable schema ${props.schemaId} contains an anonymous or unregistered refinement.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tinspectPortableSchemaNode({\n\t\t\tnode: definition,\n\t\t\tschemaId: props.schemaId,\n\t\t\tvisited: props.visited,\n\t\t});\n\t\treturn;\n\t}\n\n\tif (Array.isArray(props.node)) {\n\t\tfor (const child of props.node) {\n\t\t\tinspectPortableSchemaNode({ node: child, schemaId: props.schemaId, visited: props.visited });\n\t\t}\n\t\treturn;\n\t}\n\n\tfor (const child of Object.values(props.node)) {\n\t\tinspectPortableSchemaNode({ node: child, schemaId: props.schemaId, visited: props.visited });\n\t}\n}\n\nexport function assertPortableContractSchemaIsExportable(\n\tprops: PortableSchemaExportabilityProps,\n): void {\n\tinspectPortableSchemaNode({ node: props.schema, schemaId: props.schemaId, visited: new Set() });\n}\n\nfunction normalizeCanonicalJsonValue(value: unknown): unknown {\n\tif (typeof value === 'number') {\n\t\treturn Object.is(value, -0) ? 0 : value;\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn value.map((item) => normalizeCanonicalJsonValue(item));\n\t}\n\tif (isUnknownRecord(value)) {\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value)\n\t\t\t\t.toSorted(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey))\n\t\t\t\t.map(([key, childValue]) => [key, normalizeCanonicalJsonValue(childValue)]),\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function encodeCanonicalJson(value: unknown): string {\n\tconst encodedValue = JSON.stringify(normalizeCanonicalJsonValue(value));\n\tif (encodedValue === undefined) {\n\t\tthrow new Error('Canonical JSON input must be JSON-serializable.');\n\t}\n\treturn encodedValue;\n}\n\nfunction mapPortableIssue(props: {\n\treadonly input: unknown;\n\treadonly issue: z.core.$ZodIssue;\n\treadonly schemaId: string;\n}): string {\n\tif (props.schemaId === 'portal.call.item-result') {\n\t\tconst firstPathSegment = props.issue.path?.[0];\n\t\tif (\n\t\t\tfirstPathSegment === 'outcome' ||\n\t\t\tfirstPathSegment === 'operationId' ||\n\t\t\tfirstPathSegment === 'owningGeneration'\n\t\t) {\n\t\t\treturn 'portal.result.outcome-algebra';\n\t\t}\n\t\tif (props.issue.code === 'unrecognized_keys' || props.issue.code === 'invalid_union') {\n\t\t\treturn 'portal.result.status-shape';\n\t\t}\n\t}\n\n\tif (props.issue.code === 'unrecognized_keys') {\n\t\treturn 'portable.object.unknown-field';\n\t}\n\tif (\n\t\tprops.issue.code === 'invalid_type' &&\n\t\tprops.issue.path?.length === 1 &&\n\t\tisUnknownRecord(props.input) &&\n\t\ttypeof props.issue.path[0] === 'string' &&\n\t\t!(props.issue.path[0] in props.input)\n\t) {\n\t\treturn 'portable.object.missing-field';\n\t}\n\tif (\n\t\tprops.issue.code === 'invalid_format' &&\n\t\t'format' in props.issue &&\n\t\tprops.issue.format === 'starts_with'\n\t) {\n\t\treturn 'portable.string.pattern';\n\t}\n\tif (props.issue.code === 'too_big' && props.issue.origin === 'number') {\n\t\treturn 'portable.number.above-maximum';\n\t}\n\tif (props.issue.code === 'custom') {\n\t\tif (props.issue.message.includes('decoded canonical base64 content')) {\n\t\t\treturn 'sandbox.binary-chunk.byte-length-mismatch';\n\t\t}\n\t\tif (props.issue.message.includes('duplicate variable name')) {\n\t\t\treturn 'sandbox.environment-variable.duplicate-name';\n\t\t}\n\t\tif (props.issue.message.includes('duplicate configured agent id')) {\n\t\t\treturn 'gateway.attachment.duplicate-agent-id';\n\t\t}\n\t\tif (props.issue.message.includes('server-selected work root')) {\n\t\t\treturn 'sandbox.path.not-work-relative';\n\t\t}\n\t\tif (props.issue.message.startsWith('Duplicate portal item id')) {\n\t\t\treturn 'portal.batch.unique-item-ids';\n\t\t}\n\t\tif (props.issue.message.includes('reserved object property name')) {\n\t\t\treturn 'portal.request-id.not-reserved';\n\t\t}\n\t\tif (props.issue.message.includes('maximum number of entries')) {\n\t\t\treturn 'portable.object.above-maximum';\n\t\t}\n\t\tif (props.issue.message.includes('ok must match item statuses')) {\n\t\t\treturn 'portal.result.aggregate-status';\n\t\t}\n\t}\n\treturn `portable.zod.${props.issue.code}`;\n}\n\nfunction createPortableContractAdapter(props: {\n\treadonly definition: PortableContractDefinition;\n\treadonly schemaId: string;\n}): PortableContractAdapter {\n\treturn {\n\t\tparse: (input): PortableContractParseResult => {\n\t\t\tif (containsUnsafeInteger(input)) {\n\t\t\t\treturn {\n\t\t\t\t\terrorCodes: ['portable.number.unsafe-integer'],\n\t\t\t\t\tkind: 'rejected',\n\t\t\t\t\trefinementIdentities: [\n\t\t\t\t\t\t...new Set([...props.definition.refinementIdentities, 'portal.number.safe-integer']),\n\t\t\t\t\t].toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity)),\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst parsed = props.definition.schema.safeParse(input);\n\t\t\tconst refinementIdentities = (\n\t\t\t\tprops.definition.resolveRefinementIdentities?.({\n\t\t\t\t\tinput,\n\t\t\t\t\tparseSucceeded: parsed.success,\n\t\t\t\t}) ?? props.definition.refinementIdentities\n\t\t\t).toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity));\n\t\t\tif (!parsed.success) {\n\t\t\t\tconst errorCodes =\n\t\t\t\t\tprops.schemaId === 'portal.call.item-result' &&\n\t\t\t\t\tisUnknownRecord(input) &&\n\t\t\t\t\tcallItemHasStatusShapeConflict(input)\n\t\t\t\t\t\t? ['portal.result.status-shape']\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\t...new Set(\n\t\t\t\t\t\t\t\t\tparsed.error.issues.map((issue) =>\n\t\t\t\t\t\t\t\t\t\tmapPortableIssue({ input, issue, schemaId: props.schemaId }),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t].toSorted((leftCode, rightCode) => leftCode.localeCompare(rightCode));\n\t\t\t\treturn {\n\t\t\t\t\terrorCodes,\n\t\t\t\t\tkind: 'rejected',\n\t\t\t\t\trefinementIdentities,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: 'accepted',\n\t\t\t\tnormalized: normalizeCanonicalJsonValue(parsed.data),\n\t\t\t\trefinementIdentities,\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction callItemHasStatusShapeConflict(input: Record<string, unknown>): boolean {\n\treturn (\n\t\t(input['status'] === 'ok' && 'error' in input) ||\n\t\t(input['status'] === 'error' && 'value' in input)\n\t);\n}\n\nconst portableContractDefinitions = {\n\t'portal.artifact.read-request': {\n\t\trefinementIdentities: [],\n\t\tschema: PortalArtifactReadRequestSchema,\n\t},\n\t'portal.artifact.read-result': {\n\t\trefinementIdentities: ['portal.artifact-read.default-truncated'],\n\t\tschema: PortalArtifactReadResultSchema,\n\t},\n\t'portal.artifact.reference': {\n\t\trefinementIdentities: [],\n\t\tschema: ArtifactReferenceSchema,\n\t},\n\t'portal.call.item-result': {\n\t\trefinementIdentities: ['portal.request-id.not-reserved', 'portal.result.outcome-algebra'],\n\t\tresolveRefinementIdentities: ({ input }): readonly string[] => {\n\t\t\treturn isUnknownRecord(input) &&\n\t\t\t\t!callItemHasStatusShapeConflict(input) &&\n\t\t\t\t('outcome' in input || !('operationId' in input))\n\t\t\t\t? ['portal.request-id.not-reserved', 'portal.result.outcome-algebra']\n\t\t\t\t: ['portal.request-id.not-reserved'];\n\t\t},\n\t\tschema: PortalCallItemResultSchema,\n\t},\n\t'portal.call.request': {\n\t\trefinementIdentities: [\n\t\t\t'portal.batch.unique-item-ids',\n\t\t\t'portal.json.canonical',\n\t\t\t'portal.request-id.not-reserved',\n\t\t],\n\t\tresolveRefinementIdentities: ({ parseSucceeded }): readonly string[] => {\n\t\t\treturn parseSucceeded\n\t\t\t\t? [\n\t\t\t\t\t\t'portal.batch.unique-item-ids',\n\t\t\t\t\t\t'portal.json.canonical',\n\t\t\t\t\t\t'portal.request-id.not-reserved',\n\t\t\t\t\t]\n\t\t\t\t: ['portal.batch.unique-item-ids', 'portal.request-id.not-reserved'];\n\t\t},\n\t\tschema: PortalCallRequestSchema,\n\t},\n\t'portal.call.result': {\n\t\trefinementIdentities: [\n\t\t\t'portal.request-id.not-reserved',\n\t\t\t'portal.result.aggregate-status',\n\t\t\t'portal.result.outcome-algebra',\n\t\t],\n\t\tschema: PortalCallResultSchema,\n\t},\n\t'portal.describe.request': {\n\t\trefinementIdentities: [\n\t\t\t'portal.batch.unique-item-ids',\n\t\t\t'portal.describe.default-includes',\n\t\t\t'portal.request-id.not-reserved',\n\t\t],\n\t\tschema: PortalDescribeRequestSchema,\n\t},\n\t'portal.describe.result': {\n\t\trefinementIdentities: ['portal.request-id.not-reserved', 'portal.result.aggregate-status'],\n\t\tschema: PortalDescribeResultSchema,\n\t},\n\t'portal.json-value': {\n\t\trefinementIdentities: ['portal.json.canonical', 'portal.json.max-object-entries'],\n\t\tresolveRefinementIdentities: ({ input }): readonly string[] => {\n\t\t\treturn isUnknownRecord(input) && Object.keys(input).length > 1_000\n\t\t\t\t? ['portal.json.canonical', 'portal.json.max-object-entries']\n\t\t\t\t: ['portal.json.canonical'];\n\t\t},\n\t\tschema: JsonValueSchema,\n\t},\n\t'portal.list.request': {\n\t\trefinementIdentities: [\n\t\t\t'portal.batch.unique-item-ids',\n\t\t\t'portal.list.default-limit',\n\t\t\t'portal.request-id.not-reserved',\n\t\t],\n\t\tschema: PortalListRequestSchema,\n\t},\n\t'portal.list.result': {\n\t\trefinementIdentities: ['portal.request-id.not-reserved', 'portal.result.aggregate-status'],\n\t\tschema: PortalListResultSchema,\n\t},\n\t'portal.progress.event': {\n\t\trefinementIdentities: ['portal.request-id.not-reserved'],\n\t\tschema: PortalProgressEventSchema,\n\t},\n\t'portal.search.request': {\n\t\trefinementIdentities: [\n\t\t\t'portal.batch.unique-item-ids',\n\t\t\t'portal.request-id.not-reserved',\n\t\t\t'portal.search.default-limit',\n\t\t\t'portal.search.default-schema-detail',\n\t\t],\n\t\tschema: PortalSearchRequestSchema,\n\t},\n\t'portal.search.result': {\n\t\trefinementIdentities: ['portal.request-id.not-reserved', 'portal.result.aggregate-status'],\n\t\tschema: PortalSearchResultSchema,\n\t},\n} as const satisfies Readonly<Record<string, PortableContractDefinition>>;\n\nconst canonicalGatewayContractDefinitions = {\n\t'gateway.attachment.metadata': {\n\t\trefinementIdentities: ['gateway.attachment.unique-agent-ids'],\n\t\tschema: GatewayRuntimeAttachmentMetadataSchema,\n\t},\n\t'gateway.managed-agent-projection': {\n\t\trefinementIdentities: [],\n\t\tschema: ManagedAgentProjectionSchema,\n\t},\n\t'gateway.trusted-invocation-context': {\n\t\trefinementIdentities: [],\n\t\tschema: GatewayRuntimeTrustedInvocationContextSchema,\n\t},\n\t'sandbox.operation.control-result': {\n\t\trefinementIdentities: ['portal.result.outcome-algebra'],\n\t\tschema: SandboxOperationControlResultSchema,\n\t},\n\t'sandbox.operation.identity': {\n\t\trefinementIdentities: [],\n\t\tschema: SandboxOperationIdentitySchema,\n\t},\n\t'sandbox.retained-result.lookup-request': {\n\t\trefinementIdentities: [],\n\t\tschema: SandboxRetainedResultLookupRequestSchema,\n\t},\n\t'sandbox.retained-result.lookup-result': {\n\t\trefinementIdentities: ['portal.result.outcome-algebra'],\n\t\tschema: SandboxRetainedResultLookupResultSchema,\n\t},\n} as const satisfies Readonly<Record<string, PortableContractDefinition>>;\n\ninterface SandboxMethodPortableContractMetadata {\n\treadonly requestRefinementIdentities: readonly string[];\n\treadonly requestSchemaId: string;\n\treadonly resultRefinementIdentities: readonly string[];\n\treadonly resultSchemaId: string;\n}\n\nfunction resolveSandboxMethodPortableContractMetadata(props: {\n\treadonly method: string;\n\treadonly requestOnlyRefinementIdentities: readonly string[];\n\treadonly sharedRefinementIdentities: readonly string[];\n}): SandboxMethodPortableContractMetadata {\n\tif (props.method === 'sandbox.retained-result.lookup') {\n\t\treturn {\n\t\t\trequestRefinementIdentities: [\n\t\t\t\t...props.sharedRefinementIdentities,\n\t\t\t\t...props.requestOnlyRefinementIdentities,\n\t\t\t],\n\t\t\trequestSchemaId: 'sandbox.retained-result.lookup-request',\n\t\t\tresultRefinementIdentities: [\n\t\t\t\t...props.sharedRefinementIdentities,\n\t\t\t\t'portal.result.outcome-algebra',\n\t\t\t],\n\t\t\tresultSchemaId: 'sandbox.retained-result.lookup-result',\n\t\t};\n\t}\n\treturn {\n\t\trequestRefinementIdentities: [\n\t\t\t...props.sharedRefinementIdentities,\n\t\t\t...props.requestOnlyRefinementIdentities,\n\t\t],\n\t\trequestSchemaId: `${props.method}.request`,\n\t\tresultRefinementIdentities: props.sharedRefinementIdentities,\n\t\tresultSchemaId: `${props.method}.result`,\n\t};\n}\n\nfunction createSandboxMethodContractDefinitions(): Readonly<\n\tRecord<string, PortableContractDefinition>\n> {\n\tconst contractDefinitions: Record<string, PortableContractDefinition> = {};\n\tfor (const [method, contracts] of Object.entries(SANDBOX_METHOD_CONTRACTS)) {\n\t\tconst refinementIdentities: string[] = method.startsWith('sandbox.environment.')\n\t\t\t? ['sandbox.path.work-relative']\n\t\t\t: [];\n\t\tconst requestOnlyRefinementIdentities =\n\t\t\tmethod === 'sandbox.exec.start' || method === 'sandbox.process.start'\n\t\t\t\t? ['sandbox.environment-variable.unique-names']\n\t\t\t\t: [];\n\t\tif (\n\t\t\t[\n\t\t\t\t'sandbox.fs.read',\n\t\t\t\t'sandbox.fs.write',\n\t\t\t\t'sandbox.process.logs',\n\t\t\t\t'sandbox.stream.read',\n\t\t\t\t'sandbox.stream.write',\n\t\t\t].includes(method)\n\t\t) {\n\t\t\trefinementIdentities.push('sandbox.binary-chunk.byte-length');\n\t\t}\n\t\tconst metadata = resolveSandboxMethodPortableContractMetadata({\n\t\t\tmethod,\n\t\t\trequestOnlyRefinementIdentities,\n\t\t\tsharedRefinementIdentities: refinementIdentities,\n\t\t});\n\t\tcontractDefinitions[metadata.requestSchemaId] = {\n\t\t\trefinementIdentities: metadata.requestRefinementIdentities,\n\t\t\tschema: contracts.request,\n\t\t};\n\t\tcontractDefinitions[metadata.resultSchemaId] = {\n\t\t\trefinementIdentities: metadata.resultRefinementIdentities,\n\t\t\tschema: contracts.result,\n\t\t};\n\t}\n\treturn contractDefinitions;\n}\n\nconst sandboxMethodContractDefinitions = createSandboxMethodContractDefinitions();\n\nconst allPortableContractDefinitions: Readonly<Record<string, PortableContractDefinition>> = {\n\t...portableContractDefinitions,\n\t...canonicalGatewayContractDefinitions,\n\t...sandboxMethodContractDefinitions,\n};\n\nfor (const [schemaId, definition] of Object.entries(allPortableContractDefinitions)) {\n\tassertPortableContractSchemaIsExportable({ schema: definition.schema, schemaId });\n}\n\nexport function createPortableContractSchemaManifest(): Readonly<Record<string, unknown>> {\n\treturn {\n\t\tprotocolVersion: PORTABLE_CONTRACT_PROTOCOL_VERSION,\n\t\trefinements: PORTABLE_REFINEMENT_IDENTITIES,\n\t\tschemas: Object.fromEntries(\n\t\t\tObject.entries(allPortableContractDefinitions).map(([schemaId, definition]) => [\n\t\t\t\tschemaId,\n\t\t\t\t{\n\t\t\t\t\tjsonSchema: z.toJSONSchema(definition.schema, {\n\t\t\t\t\t\tio: 'input',\n\t\t\t\t\t\tunrepresentable: 'any',\n\t\t\t\t\t}),\n\t\t\t\t\trefinementIdentities: definition.refinementIdentities.toSorted(\n\t\t\t\t\t\t(leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t]),\n\t\t),\n\t};\n}\n\nexport const PORTABLE_CONTRACT_ADAPTERS = Object.fromEntries(\n\tObject.entries(allPortableContractDefinitions).map(([schemaId, definition]) => [\n\t\tschemaId,\n\t\tcreatePortableContractAdapter({ definition, schemaId }),\n\t]),\n) satisfies Readonly<Record<string, PortableContractAdapter>>;\n"],"mappings":";;;;;;;;;;;;;AAyDA,MAAa,qCAAqC;AAgBlD,SAAS,gBAAgB,OAAkD;CAC1E,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG5E,SAAS,YAAY,OAAoC;CACxD,OAAO,gBAAgB,MAAM,IAAI,gBAAgB,MAAM,QAAQ,IAAI,SAAS,MAAM;;AAGnF,SAAS,sBAAsB,OAAyB;CACvD,IAAI,OAAO,UAAU,UAAU,OAAO,OAAO,UAAU,MAAM,IAAI,CAAC,OAAO,cAAc,MAAM;CAC7F,IAAI,MAAM,QAAQ,MAAM,EAAE,OAAO,MAAM,MAAM,SAAS,sBAAsB,KAAK,CAAC;CAClF,IAAI,gBAAgB,MAAM,EACzB,OAAO,OAAO,OAAO,MAAM,CAAC,MAAM,eAAe,sBAAsB,WAAW,CAAC;CAEpF,OAAO;;AAGR,SAAS,0BAA0B,OAI1B;CACR,IAAK,OAAO,MAAM,SAAS,YAAY,OAAO,MAAM,SAAS,cAAe,MAAM,SAAS,MAC1F;CAED,IAAI,MA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AAM,WAAW,6CAA6C;GAC7D;GACA;GACA,4BAA4B;GAC5B,CAAC;EACF,oBAAoB,SAAS,mBAAmB;GAC/C,sBAAsB,SAAS;GAC/B,QAAQ,UAAU;GAClB;EACD,oBAAoB,SAAS,kBAAkB;GAC9C,sBAAsB,SAAS;GAC/B,QAAQ,UAAU;GAClB;;CAEF,OAAO;;AAGR,MAAM,mCAAmC,wCAAwC;AAEjF,MAAM,iCAAuF;CAC5F,GAAG;CACH,GAAG;CACH,GAAG;CACH;AAED,KAAK,MAAM,CAAC,UAAU,eAAe,OAAO,QAAQ,+BAA+B,EAClF,yCAAyC;CAAE,QAAQ,WAAW;CAAQ;CAAU,CAAC;AAGlF,SAAgB,uCAA0E;CACzF,OAAO;EACN,iBAAA;EACA,aAAa;EACb,SAAS,OAAO,YACf,OAAO,QAAQ,+BAA+B,CAAC,KAAK,CAAC,UAAU,gBAAgB,CAC9E,UACA;GACC,YAAY,EAAE,aAAa,WAAW,QAAQ;IAC7C,IAAI;IACJ,iBAAiB;IACjB,CAAC;GACF,sBAAsB,WAAW,qBAAqB,UACpD,cAAc,kBAAkB,aAAa,cAAc,cAAc,CAC1E;GACD,CACD,CAAC,CACF;EACD;;AAGF,MAAa,6BAA6B,OAAO,YAChD,OAAO,QAAQ,+BAA+B,CAAC,KAAK,CAAC,UAAU,gBAAgB,CAC9E,UACA,8BAA8B;CAAE;CAAY;CAAU,CAAC,CACvD,CAAC,CACF"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//#region src/portable-contracts/portable-refinement-descriptors.ts
|
|
2
|
+
const PORTABLE_REFINEMENT_DESCRIPTORS = [
|
|
3
|
+
{
|
|
4
|
+
description: "Artifact reads default omitted truncation state to false.",
|
|
5
|
+
identity: "portal.artifact-read.default-truncated",
|
|
6
|
+
kind: "default",
|
|
7
|
+
operation: {
|
|
8
|
+
kind: "default-values",
|
|
9
|
+
values: { "/truncated": false }
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
description: "Every item id in one portal batch must be unique.",
|
|
14
|
+
errorCode: "portal.batch.unique-item-ids",
|
|
15
|
+
identity: "portal.batch.unique-item-ids",
|
|
16
|
+
kind: "cross-field-validation",
|
|
17
|
+
operation: {
|
|
18
|
+
collectionPaths: ["calls", "requests"],
|
|
19
|
+
fieldName: "id",
|
|
20
|
+
kind: "unique-field"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
description: "Describe requests apply the portable inclusion defaults.",
|
|
25
|
+
identity: "portal.describe.default-includes",
|
|
26
|
+
kind: "default",
|
|
27
|
+
operation: {
|
|
28
|
+
kind: "default-values",
|
|
29
|
+
values: {
|
|
30
|
+
"/requests/*/includeJsonSchema": true,
|
|
31
|
+
"/requests/*/includeRelated": true,
|
|
32
|
+
"/requests/*/includeTypescriptHelper": false,
|
|
33
|
+
"/requests/*/includeZod": false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
description: "JSON values use sorted object keys and normalize negative zero.",
|
|
39
|
+
identity: "portal.json.canonical",
|
|
40
|
+
kind: "canonical-normalization",
|
|
41
|
+
operation: {
|
|
42
|
+
kind: "canonical-json",
|
|
43
|
+
maximumArrayItems: 1e3,
|
|
44
|
+
maximumObjectEntries: 1e3,
|
|
45
|
+
maximumObjectKeyCharacters: 256,
|
|
46
|
+
maximumStringCharacters: 64 * 1024
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
description: "JSON objects cannot contain more than one thousand entries.",
|
|
51
|
+
errorCode: "portable.object.above-maximum",
|
|
52
|
+
identity: "portal.json.max-object-entries",
|
|
53
|
+
kind: "structural-validation",
|
|
54
|
+
operation: {
|
|
55
|
+
kind: "maximum-object-entries",
|
|
56
|
+
maximum: 1e3
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
description: "List requests default omitted limits to twenty items.",
|
|
61
|
+
identity: "portal.list.default-limit",
|
|
62
|
+
kind: "default",
|
|
63
|
+
operation: {
|
|
64
|
+
kind: "default-values",
|
|
65
|
+
values: { "/requests/*/limit": 20 }
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
description: "Portable integer values remain inside the interoperable safe-integer range.",
|
|
70
|
+
errorCode: "portable.number.unsafe-integer",
|
|
71
|
+
identity: "portal.number.safe-integer",
|
|
72
|
+
kind: "structural-validation",
|
|
73
|
+
operation: {
|
|
74
|
+
kind: "safe-integer",
|
|
75
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
76
|
+
minimum: Number.MIN_SAFE_INTEGER
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
description: "Portal request ids cannot use reserved object property names.",
|
|
81
|
+
errorCode: "portal.request-id.not-reserved",
|
|
82
|
+
identity: "portal.request-id.not-reserved",
|
|
83
|
+
kind: "structural-validation",
|
|
84
|
+
operation: {
|
|
85
|
+
fieldNames: ["id", "requestId"],
|
|
86
|
+
kind: "reject-reserved-values",
|
|
87
|
+
values: [
|
|
88
|
+
"__proto__",
|
|
89
|
+
"constructor",
|
|
90
|
+
"prototype"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
description: "Aggregate success must equal the success of every result item.",
|
|
96
|
+
errorCode: "portal.result.aggregate-status",
|
|
97
|
+
identity: "portal.result.aggregate-status",
|
|
98
|
+
kind: "cross-field-validation",
|
|
99
|
+
operation: {
|
|
100
|
+
itemsField: "items",
|
|
101
|
+
kind: "aggregate-status",
|
|
102
|
+
okField: "ok"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
description: "Call results use the normative terminal outcome algebra.",
|
|
107
|
+
errorCode: "portal.result.outcome-algebra",
|
|
108
|
+
identity: "portal.result.outcome-algebra",
|
|
109
|
+
kind: "structural-validation",
|
|
110
|
+
operation: { kind: "terminal-outcome-algebra" }
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
description: "Search requests default omitted limits to ten items.",
|
|
114
|
+
identity: "portal.search.default-limit",
|
|
115
|
+
kind: "default",
|
|
116
|
+
operation: {
|
|
117
|
+
kind: "default-values",
|
|
118
|
+
values: { "/requests/*/limit": 10 }
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
description: "Search requests default omitted schema detail to summary.",
|
|
123
|
+
identity: "portal.search.default-schema-detail",
|
|
124
|
+
kind: "default",
|
|
125
|
+
operation: {
|
|
126
|
+
kind: "default-values",
|
|
127
|
+
values: { "/requests/*/schemaDetail": "summary" }
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
description: "Gateway attachment metadata cannot repeat an admitted agent identity.",
|
|
132
|
+
errorCode: "gateway.attachment.duplicate-agent-id",
|
|
133
|
+
identity: "gateway.attachment.unique-agent-ids",
|
|
134
|
+
kind: "cross-field-validation",
|
|
135
|
+
operation: {
|
|
136
|
+
kind: "unique-string-items",
|
|
137
|
+
path: "configuredAgentIds"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
description: "Binary chunk byte length equals the decoded canonical base64 payload length.",
|
|
142
|
+
errorCode: "sandbox.binary-chunk.byte-length-mismatch",
|
|
143
|
+
identity: "sandbox.binary-chunk.byte-length",
|
|
144
|
+
kind: "cross-field-validation",
|
|
145
|
+
operation: { kind: "decoded-base64-byte-length" }
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
description: "Direct Sandbox environment variable names must be unique.",
|
|
149
|
+
errorCode: "sandbox.environment-variable.duplicate-name",
|
|
150
|
+
identity: "sandbox.environment-variable.unique-names",
|
|
151
|
+
kind: "cross-field-validation",
|
|
152
|
+
operation: {
|
|
153
|
+
collectionPaths: ["environmentVariables"],
|
|
154
|
+
fieldName: "name",
|
|
155
|
+
kind: "unique-field"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
description: "Sandbox paths are relative to the server-selected work root.",
|
|
160
|
+
errorCode: "sandbox.path.not-work-relative",
|
|
161
|
+
identity: "sandbox.path.work-relative",
|
|
162
|
+
kind: "structural-validation",
|
|
163
|
+
operation: {
|
|
164
|
+
fieldNames: [
|
|
165
|
+
"destinationPath",
|
|
166
|
+
"logicalCwd",
|
|
167
|
+
"path",
|
|
168
|
+
"sourcePath"
|
|
169
|
+
],
|
|
170
|
+
kind: "work-relative-path"
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
const PORTABLE_REFINEMENT_IDENTITIES = PORTABLE_REFINEMENT_DESCRIPTORS.map((descriptor) => descriptor.identity).toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity));
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/portable-contracts/portable-refinement-authoring.ts
|
|
177
|
+
const portableRefinementIdentities = new Set(PORTABLE_REFINEMENT_DESCRIPTORS.map((descriptor) => descriptor.identity));
|
|
178
|
+
const portableRefinementIdentityByCheck = /* @__PURE__ */ new WeakMap();
|
|
179
|
+
function withPortableSuperRefinement(props) {
|
|
180
|
+
if (!portableRefinementIdentities.has(props.refinementIdentity)) throw new Error(`Portable refinement ${props.refinementIdentity} is not registered.`);
|
|
181
|
+
const existingChecks = new Set(props.schema._zod.def.checks ?? []);
|
|
182
|
+
const refinedSchema = props.schema.superRefine(props.refinement);
|
|
183
|
+
const addedChecks = (refinedSchema._zod.def.checks ?? []).filter((check) => !existingChecks.has(check));
|
|
184
|
+
if (addedChecks.length !== 1) throw new Error(`Portable refinement ${props.refinementIdentity} must add exactly one Zod check.`);
|
|
185
|
+
const addedCheck = addedChecks[0];
|
|
186
|
+
if (addedCheck === void 0) throw new Error(`Portable refinement ${props.refinementIdentity} added no Zod check.`);
|
|
187
|
+
portableRefinementIdentityByCheck.set(addedCheck, props.refinementIdentity);
|
|
188
|
+
return refinedSchema;
|
|
189
|
+
}
|
|
190
|
+
function portableRefinementIdentityForCheck(check) {
|
|
191
|
+
return portableRefinementIdentityByCheck.get(check);
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { PORTABLE_REFINEMENT_IDENTITIES as i, withPortableSuperRefinement as n, PORTABLE_REFINEMENT_DESCRIPTORS as r, portableRefinementIdentityForCheck as t };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=portable-refinement-authoring-ZSmR-amG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-refinement-authoring-ZSmR-amG.js","names":[],"sources":["../src/portable-contracts/portable-refinement-descriptors.ts","../src/portable-contracts/portable-refinement-authoring.ts"],"sourcesContent":["export type PortableRefinementKind =\n\t| 'canonical-normalization'\n\t| 'cross-field-validation'\n\t| 'default'\n\t| 'structural-validation';\n\nexport type PortableRefinementOperation =\n\t| {\n\t\t\treadonly kind: 'aggregate-status';\n\t\t\treadonly itemsField: string;\n\t\t\treadonly okField: string;\n\t }\n\t| { readonly kind: 'decoded-base64-byte-length' }\n\t| {\n\t\t\treadonly collectionPaths: readonly string[];\n\t\t\treadonly fieldName: string;\n\t\t\treadonly kind: 'unique-field';\n\t }\n\t| {\n\t\t\treadonly kind: 'default-values';\n\t\t\treadonly values: Readonly<Record<string, boolean | number | string>>;\n\t }\n\t| {\n\t\t\treadonly kind: 'canonical-json';\n\t\t\treadonly maximumArrayItems: number;\n\t\t\treadonly maximumObjectEntries: number;\n\t\t\treadonly maximumObjectKeyCharacters: number;\n\t\t\treadonly maximumStringCharacters: number;\n\t }\n\t| {\n\t\t\treadonly kind: 'maximum-object-entries';\n\t\t\treadonly maximum: number;\n\t }\n\t| {\n\t\t\treadonly fieldNames: readonly string[];\n\t\t\treadonly kind: 'reject-reserved-values';\n\t\t\treadonly values: readonly string[];\n\t }\n\t| {\n\t\t\treadonly kind: 'safe-integer';\n\t\t\treadonly maximum: number;\n\t\t\treadonly minimum: number;\n\t }\n\t| { readonly kind: 'terminal-outcome-algebra' }\n\t| { readonly kind: 'unique-string-items'; readonly path: string }\n\t| { readonly fieldNames: readonly string[]; readonly kind: 'work-relative-path' };\n\nexport interface PortableRefinementDescriptor {\n\treadonly description: string;\n\treadonly errorCode?: string;\n\treadonly identity: string;\n\treadonly kind: PortableRefinementKind;\n\treadonly operation: PortableRefinementOperation;\n}\n\nexport const PORTABLE_REFINEMENT_DESCRIPTORS = [\n\t{\n\t\tdescription: 'Artifact reads default omitted truncation state to false.',\n\t\tidentity: 'portal.artifact-read.default-truncated',\n\t\tkind: 'default',\n\t\toperation: { kind: 'default-values', values: { '/truncated': false } },\n\t},\n\t{\n\t\tdescription: 'Every item id in one portal batch must be unique.',\n\t\terrorCode: 'portal.batch.unique-item-ids',\n\t\tidentity: 'portal.batch.unique-item-ids',\n\t\tkind: 'cross-field-validation',\n\t\toperation: { collectionPaths: ['calls', 'requests'], fieldName: 'id', kind: 'unique-field' },\n\t},\n\t{\n\t\tdescription: 'Describe requests apply the portable inclusion defaults.',\n\t\tidentity: 'portal.describe.default-includes',\n\t\tkind: 'default',\n\t\toperation: {\n\t\t\tkind: 'default-values',\n\t\t\tvalues: {\n\t\t\t\t'/requests/*/includeJsonSchema': true,\n\t\t\t\t'/requests/*/includeRelated': true,\n\t\t\t\t'/requests/*/includeTypescriptHelper': false,\n\t\t\t\t'/requests/*/includeZod': false,\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdescription: 'JSON values use sorted object keys and normalize negative zero.',\n\t\tidentity: 'portal.json.canonical',\n\t\tkind: 'canonical-normalization',\n\t\toperation: {\n\t\t\tkind: 'canonical-json',\n\t\t\tmaximumArrayItems: 1_000,\n\t\t\tmaximumObjectEntries: 1_000,\n\t\t\tmaximumObjectKeyCharacters: 256,\n\t\t\tmaximumStringCharacters: 64 * 1_024,\n\t\t},\n\t},\n\t{\n\t\tdescription: 'JSON objects cannot contain more than one thousand entries.',\n\t\terrorCode: 'portable.object.above-maximum',\n\t\tidentity: 'portal.json.max-object-entries',\n\t\tkind: 'structural-validation',\n\t\toperation: { kind: 'maximum-object-entries', maximum: 1_000 },\n\t},\n\t{\n\t\tdescription: 'List requests default omitted limits to twenty items.',\n\t\tidentity: 'portal.list.default-limit',\n\t\tkind: 'default',\n\t\toperation: { kind: 'default-values', values: { '/requests/*/limit': 20 } },\n\t},\n\t{\n\t\tdescription: 'Portable integer values remain inside the interoperable safe-integer range.',\n\t\terrorCode: 'portable.number.unsafe-integer',\n\t\tidentity: 'portal.number.safe-integer',\n\t\tkind: 'structural-validation',\n\t\toperation: {\n\t\t\tkind: 'safe-integer',\n\t\t\tmaximum: Number.MAX_SAFE_INTEGER,\n\t\t\tminimum: Number.MIN_SAFE_INTEGER,\n\t\t},\n\t},\n\t{\n\t\tdescription: 'Portal request ids cannot use reserved object property names.',\n\t\terrorCode: 'portal.request-id.not-reserved',\n\t\tidentity: 'portal.request-id.not-reserved',\n\t\tkind: 'structural-validation',\n\t\toperation: {\n\t\t\tfieldNames: ['id', 'requestId'],\n\t\t\tkind: 'reject-reserved-values',\n\t\t\tvalues: ['__proto__', 'constructor', 'prototype'],\n\t\t},\n\t},\n\t{\n\t\tdescription: 'Aggregate success must equal the success of every result item.',\n\t\terrorCode: 'portal.result.aggregate-status',\n\t\tidentity: 'portal.result.aggregate-status',\n\t\tkind: 'cross-field-validation',\n\t\toperation: { itemsField: 'items', kind: 'aggregate-status', okField: 'ok' },\n\t},\n\t{\n\t\tdescription: 'Call results use the normative terminal outcome algebra.',\n\t\terrorCode: 'portal.result.outcome-algebra',\n\t\tidentity: 'portal.result.outcome-algebra',\n\t\tkind: 'structural-validation',\n\t\toperation: { kind: 'terminal-outcome-algebra' },\n\t},\n\t{\n\t\tdescription: 'Search requests default omitted limits to ten items.',\n\t\tidentity: 'portal.search.default-limit',\n\t\tkind: 'default',\n\t\toperation: { kind: 'default-values', values: { '/requests/*/limit': 10 } },\n\t},\n\t{\n\t\tdescription: 'Search requests default omitted schema detail to summary.',\n\t\tidentity: 'portal.search.default-schema-detail',\n\t\tkind: 'default',\n\t\toperation: {\n\t\t\tkind: 'default-values',\n\t\t\tvalues: { '/requests/*/schemaDetail': 'summary' },\n\t\t},\n\t},\n\t{\n\t\tdescription: 'Gateway attachment metadata cannot repeat an admitted agent identity.',\n\t\terrorCode: 'gateway.attachment.duplicate-agent-id',\n\t\tidentity: 'gateway.attachment.unique-agent-ids',\n\t\tkind: 'cross-field-validation',\n\t\toperation: { kind: 'unique-string-items', path: 'configuredAgentIds' },\n\t},\n\t{\n\t\tdescription: 'Binary chunk byte length equals the decoded canonical base64 payload length.',\n\t\terrorCode: 'sandbox.binary-chunk.byte-length-mismatch',\n\t\tidentity: 'sandbox.binary-chunk.byte-length',\n\t\tkind: 'cross-field-validation',\n\t\toperation: { kind: 'decoded-base64-byte-length' },\n\t},\n\t{\n\t\tdescription: 'Direct Sandbox environment variable names must be unique.',\n\t\terrorCode: 'sandbox.environment-variable.duplicate-name',\n\t\tidentity: 'sandbox.environment-variable.unique-names',\n\t\tkind: 'cross-field-validation',\n\t\toperation: {\n\t\t\tcollectionPaths: ['environmentVariables'],\n\t\t\tfieldName: 'name',\n\t\t\tkind: 'unique-field',\n\t\t},\n\t},\n\t{\n\t\tdescription: 'Sandbox paths are relative to the server-selected work root.',\n\t\terrorCode: 'sandbox.path.not-work-relative',\n\t\tidentity: 'sandbox.path.work-relative',\n\t\tkind: 'structural-validation',\n\t\toperation: {\n\t\t\tfieldNames: ['destinationPath', 'logicalCwd', 'path', 'sourcePath'],\n\t\t\tkind: 'work-relative-path',\n\t\t},\n\t},\n] as const satisfies readonly PortableRefinementDescriptor[];\n\nexport const PORTABLE_REFINEMENT_IDENTITIES: readonly string[] =\n\tPORTABLE_REFINEMENT_DESCRIPTORS.map((descriptor) => descriptor.identity).toSorted(\n\t\t(leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity),\n\t);\n","import type { z } from 'zod';\n\nimport { PORTABLE_REFINEMENT_DESCRIPTORS } from './portable-refinement-descriptors.js';\n\nconst portableRefinementIdentities: ReadonlySet<string> = new Set(\n\tPORTABLE_REFINEMENT_DESCRIPTORS.map((descriptor) => descriptor.identity),\n);\nconst portableRefinementIdentityByCheck = new WeakMap<object, string>();\n\nexport interface PortableSuperRefinementProps<TSchema extends z.ZodType> {\n\treadonly refinement: (value: z.output<TSchema>, context: z.RefinementCtx) => void;\n\treadonly refinementIdentity: string;\n\treadonly schema: TSchema;\n}\n\nexport function withPortableSuperRefinement<TSchema extends z.ZodType>(\n\tprops: PortableSuperRefinementProps<TSchema>,\n): TSchema {\n\tif (!portableRefinementIdentities.has(props.refinementIdentity)) {\n\t\tthrow new Error(`Portable refinement ${props.refinementIdentity} is not registered.`);\n\t}\n\t// oxlint-disable-next-line no-underscore-dangle -- Zod v4 exposes schema definitions through its library-author core contract.\n\tconst existingChecks = new Set(props.schema._zod.def.checks ?? []);\n\tconst refinedSchema = props.schema.superRefine(props.refinement);\n\t// oxlint-disable-next-line no-underscore-dangle -- Match the one check added by the named authoring helper.\n\tconst addedChecks = (refinedSchema._zod.def.checks ?? []).filter(\n\t\t(check) => !existingChecks.has(check),\n\t);\n\tif (addedChecks.length !== 1) {\n\t\tthrow new Error(\n\t\t\t`Portable refinement ${props.refinementIdentity} must add exactly one Zod check.`,\n\t\t);\n\t}\n\tconst addedCheck = addedChecks[0];\n\tif (addedCheck === undefined) {\n\t\tthrow new Error(`Portable refinement ${props.refinementIdentity} added no Zod check.`);\n\t}\n\tportableRefinementIdentityByCheck.set(addedCheck, props.refinementIdentity);\n\treturn refinedSchema;\n}\n\nexport function portableRefinementIdentityForCheck(check: object): string | undefined {\n\treturn portableRefinementIdentityByCheck.get(check);\n}\n"],"mappings":";AAuDA,MAAa,kCAAkC;CAC9C;EACC,aAAa;EACb,UAAU;EACV,MAAM;EACN,WAAW;GAAE,MAAM;GAAkB,QAAQ,EAAE,cAAc,OAAO;GAAE;EACtE;CACD;EACC,aAAa;EACb,WAAW;EACX,UAAU;EACV,MAAM;EACN,WAA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R,SAAgB,mCAAmC,OAAmC;CACrF,OAAO,kCAAkC,IAAI,MAAM"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as withPortableSuperRefinement } from "./portable-refinement-authoring-ZSmR-amG.js";
|
|
2
|
+
import { o as RequestIdSchema } from "./portal-error-schema-CQHgoFq4.js";
|
|
3
|
+
import { i as JsonObjectSchema } from "./json-value-schema-hdPkabRZ.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/portal-call-surface/models/portal-batch-id-refinement.ts
|
|
6
|
+
function addDuplicateItemIdIssues(items, context) {
|
|
7
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
8
|
+
const duplicateIds = /* @__PURE__ */ new Set();
|
|
9
|
+
for (const item of items) {
|
|
10
|
+
if (seenIds.has(item.id)) duplicateIds.add(item.id);
|
|
11
|
+
seenIds.add(item.id);
|
|
12
|
+
}
|
|
13
|
+
for (const duplicateId of [...duplicateIds].toSorted()) context.addIssue({
|
|
14
|
+
code: "custom",
|
|
15
|
+
message: `Duplicate portal item id "${duplicateId}".`,
|
|
16
|
+
path: ["id"]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/portal-call-surface/models/portal-call-request-schema.ts
|
|
21
|
+
const PortalBatchMaxItems = 50;
|
|
22
|
+
const PortalCallItemRequestSchema = z.object({
|
|
23
|
+
arguments: JsonObjectSchema,
|
|
24
|
+
id: RequestIdSchema,
|
|
25
|
+
namespace: z.string().min(1),
|
|
26
|
+
name: z.string().min(1)
|
|
27
|
+
}).strict();
|
|
28
|
+
const PortalCallRequestSchema = withPortableSuperRefinement({
|
|
29
|
+
refinement: (request, context) => {
|
|
30
|
+
addDuplicateItemIdIssues(request.calls, context);
|
|
31
|
+
},
|
|
32
|
+
refinementIdentity: "portal.batch.unique-item-ids",
|
|
33
|
+
schema: z.object({
|
|
34
|
+
calls: z.array(PortalCallItemRequestSchema).min(1).max(50),
|
|
35
|
+
requestId: RequestIdSchema.optional()
|
|
36
|
+
}).strict()
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { addDuplicateItemIdIssues as i, PortalCallItemRequestSchema as n, PortalCallRequestSchema as r, PortalBatchMaxItems as t };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=portal-call-request-schema-Cp6CMGs9.js.map
|