@agent-vm/agent-portal-sdk 0.0.147 → 0.0.149
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/contract-fixtures/portable-contracts/approval/managed-google-challenge.fixture.json +66 -0
- package/contract-fixtures/portable-contracts/discovery/describe-result.fixture.json +5 -1
- package/contract-fixtures/portable-contracts/discovery/google-describe-duplicate-availability.fixture.json +103 -0
- package/contract-fixtures/portable-contracts/discovery/google-describe-duplicate-requirements.fixture.json +83 -0
- package/contract-fixtures/portable-contracts/discovery/google-describe-unverified-ready.fixture.json +78 -0
- package/contract-fixtures/portable-contracts/discovery/google-describe-valid.fixture.json +144 -0
- package/contract-fixtures/portable-contracts/discovery/google-list-duplicate-availability.fixture.json +109 -0
- package/contract-fixtures/portable-contracts/discovery/google-list-duplicate-requirements.fixture.json +89 -0
- package/contract-fixtures/portable-contracts/discovery/google-list-unverified-ready.fixture.json +84 -0
- package/contract-fixtures/portable-contracts/discovery/google-list-valid.fixture.json +156 -0
- package/contract-fixtures/portable-contracts/discovery/google-search-duplicate-availability.fixture.json +108 -0
- package/contract-fixtures/portable-contracts/discovery/google-search-duplicate-requirements.fixture.json +88 -0
- package/contract-fixtures/portable-contracts/discovery/google-search-unverified-ready.fixture.json +83 -0
- package/contract-fixtures/portable-contracts/discovery/google-search-valid.fixture.json +154 -0
- package/contract-fixtures/portable-contracts/discovery/list-result.fixture.json +5 -1
- package/contract-fixtures/portable-contracts/discovery/search-result.fixture.json +5 -1
- package/contract-fixtures/portable-contracts/files/attachment-cleaned-result.fixture.json +16 -0
- package/contract-fixtures/portable-contracts/files/attachment-parent-path-rejected.fixture.json +17 -0
- package/contract-fixtures/portable-contracts/files/attachment-public-request.fixture.json +26 -0
- package/contract-fixtures/portable-contracts/files/attachment-public-result.fixture.json +26 -0
- package/contract-fixtures/portable-contracts/files/attachment-recipient-rejected.fixture.json +19 -0
- package/contract-fixtures/portable-contracts/files/attachment-settle-request.fixture.json +20 -0
- package/contract-fixtures/portable-contracts/files/attachment-stage-request.fixture.json +26 -0
- package/contract-fixtures/portable-contracts/files/attachment-staged-result.fixture.json +24 -0
- package/contract-fixtures/portable-contracts/files/file-list-request.fixture.json +14 -0
- package/contract-fixtures/portable-contracts/files/file-listed-result.fixture.json +21 -0
- package/contract-fixtures/portable-contracts/files/file-materialized-result.fixture.json +17 -0
- package/contract-fixtures/portable-contracts/files/file-request-root-rejected.fixture.json +15 -0
- package/contract-fixtures/portable-contracts/files/file-result-payload-rejected.fixture.json +18 -0
- package/contract-fixtures/portable-contracts/outcomes/completed-file-delivery-partial.fixture.json +84 -0
- package/contract-fixtures/portable-contracts/outcomes/invalid-retryable-file-delivery.fixture.json +40 -0
- package/dist/approval-surface/index.d.ts +1 -1
- package/dist/approval-surface/index.js +1 -1
- package/dist/{approval-surface-Cqk_hAtN.js → approval-surface-CfbAG-81.js} +4 -4
- package/dist/{approval-surface-Cqk_hAtN.js.map → approval-surface-CfbAG-81.js.map} +1 -1
- package/dist/artifact-surface/index.js +1 -1
- package/dist/{artifact-surface-CHEu4tDd.js → artifact-surface-Db5KQOA0.js} +2 -2
- package/dist/{artifact-surface-CHEu4tDd.js.map → artifact-surface-Db5KQOA0.js.map} +1 -1
- package/dist/capability-description-surface/index.d.ts +2 -2
- package/dist/capability-description-surface/index.js +3 -3
- package/dist/capability-description-surface-DKZLjpG4.js +2 -0
- package/dist/{capability-descriptor-schema-v9tj7yKr.js → capability-descriptor-schema-5evBt6Hl.js} +39 -3
- package/dist/capability-descriptor-schema-5evBt6Hl.js.map +1 -0
- package/dist/cli/tool-portal.js +5 -5
- package/dist/contracts/index.js +1 -1
- package/dist/{contracts-X9wWs2lP.js → contracts-K6l783Yb.js} +5 -5
- package/dist/{contracts-X9wWs2lP.js.map → contracts-K6l783Yb.js.map} +1 -1
- package/dist/gateway-runtime-client/index.d.ts +5 -3
- package/dist/gateway-runtime-client/index.d.ts.map +1 -1
- package/dist/gateway-runtime-client/index.js +13 -6
- package/dist/gateway-runtime-client/index.js.map +1 -1
- package/dist/{index-DV6xiWeS.d.ts → index-BSG2bf1j.d.ts} +3 -3
- package/dist/{index-DV6xiWeS.d.ts.map → index-BSG2bf1j.d.ts.map} +1 -1
- package/dist/{index-ciLRJYVb.d.ts → index-Ba_G25p_.d.ts} +37 -37
- package/dist/{index-ciLRJYVb.d.ts.map → index-Ba_G25p_.d.ts.map} +1 -1
- package/dist/index-ByBEiqZp.d.ts +388 -0
- package/dist/index-ByBEiqZp.d.ts.map +1 -0
- package/dist/{index-D4UDHMft.d.ts → index-C5NsqQls.d.ts} +31 -9
- package/dist/index-C5NsqQls.d.ts.map +1 -0
- package/dist/{index-3aVlpTwE.d.ts → index-C8gs_YWX.d.ts} +134 -18
- package/dist/{index-3aVlpTwE.d.ts.map → index-C8gs_YWX.d.ts.map} +1 -1
- package/dist/{index-C-QFWaH5.d.ts → index-E3B9TETl.d.ts} +11 -1
- package/dist/index-E3B9TETl.d.ts.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +15 -15
- package/dist/{json-value-schema-Br5M7d7X.js → json-value-schema-rxMrw9uZ.js} +2 -2
- package/dist/{json-value-schema-Br5M7d7X.js.map → json-value-schema-rxMrw9uZ.js.map} +1 -1
- package/dist/{namespace-discovery-schema-DwbJHVLu.js → namespace-discovery-schema-BBWRZZnD.js} +2 -2
- package/dist/{namespace-discovery-schema-DwbJHVLu.js.map → namespace-discovery-schema-BBWRZZnD.js.map} +1 -1
- package/dist/portable-contracts/index.d.ts +1 -1
- package/dist/portable-contracts/index.js +2 -2
- package/dist/{portable-contracts-BJEMMNwI.js → portable-contracts-D7axGgu1.js} +75 -15
- package/dist/portable-contracts-D7axGgu1.js.map +1 -0
- package/dist/{portable-refinement-authoring-C1Q92x2G.js → portable-refinement-authoring-oFICWLOo.js} +16 -2
- package/dist/portable-refinement-authoring-oFICWLOo.js.map +1 -0
- package/dist/{portal-call-request-schema-Cl0kTLaX.js → portal-call-request-schema-B1dbBjmW.js} +4 -4
- package/dist/{portal-call-request-schema-Cl0kTLaX.js.map → portal-call-request-schema-B1dbBjmW.js.map} +1 -1
- package/dist/{portal-call-result-schema-CFnKfcvZ.d.ts → portal-call-result-schema-CjfCOa84.d.ts} +1561 -313
- package/dist/portal-call-result-schema-CjfCOa84.d.ts.map +1 -0
- package/dist/{portal-call-result-schema-B25_rzZZ.js → portal-call-result-schema-DVJ6FyTz.js} +24 -8
- package/dist/portal-call-result-schema-DVJ6FyTz.js.map +1 -0
- package/dist/portal-call-surface/index.d.ts +3 -3
- package/dist/portal-call-surface/index.js +4 -4
- package/dist/portal-call-surface-BPVX-rjw.js +175 -0
- package/dist/portal-call-surface-BPVX-rjw.js.map +1 -0
- package/dist/portal-event-surface/index.d.ts +1 -1
- package/dist/portal-event-surface/index.js +1 -1
- package/dist/{portal-event-surface-Bp3rXsBz.js → portal-event-surface-Z76kra2a.js} +2 -2
- package/dist/{portal-event-surface-Bp3rXsBz.js.map → portal-event-surface-Z76kra2a.js.map} +1 -1
- package/dist/{request-id-schema-Hq_6lSFV.js → request-id-schema-DQ84TX-D.js} +2 -2
- package/dist/{request-id-schema-Hq_6lSFV.js.map → request-id-schema-DQ84TX-D.js.map} +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/tool-portal-mcp-client/index.d.ts +1 -1
- package/dist/tool-portal-mcp-client/index.js +1 -1
- package/dist/tool-portal-mcp-client/node-tool-portal-mcp-transport.d.ts +1 -1
- package/dist/{tool-portal-mcp-client-DZoloMod.js → tool-portal-mcp-client-DSDLoZ5e.js} +5 -5
- package/dist/{tool-portal-mcp-client-DZoloMod.js.map → tool-portal-mcp-client-DSDLoZ5e.js.map} +1 -1
- package/package.json +3 -2
- package/portable-contract-schema-manifest.json +1868 -79
- package/dist/capability-description-surface-CplIb93y.js +0 -2
- package/dist/capability-descriptor-schema-v9tj7yKr.js.map +0 -1
- package/dist/index-C-QFWaH5.d.ts.map +0 -1
- package/dist/index-D4UDHMft.d.ts.map +0 -1
- package/dist/index-m4Mlc5zK.d.ts +0 -142
- package/dist/index-m4Mlc5zK.d.ts.map +0 -1
- package/dist/portable-contracts-BJEMMNwI.js.map +0 -1
- package/dist/portable-refinement-authoring-C1Q92x2G.js.map +0 -1
- package/dist/portal-call-result-schema-B25_rzZZ.js.map +0 -1
- package/dist/portal-call-result-schema-CFnKfcvZ.d.ts.map +0 -1
- package/dist/portal-call-surface-qykVz_8k.js +0 -84
- package/dist/portal-call-surface-qykVz_8k.js.map +0 -1
|
@@ -1,15 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as PORTABLE_REFINEMENT_IDENTITIES, n as registerPortableExternalRefinement, t as portableRefinementIdentityForCheck } from "./portable-refinement-authoring-oFICWLOo.js";
|
|
2
2
|
import { t as ArtifactReferenceSchema } from "./artifact-reference-schema-CiEjxYPd.js";
|
|
3
|
-
import { o as JsonValueSchema } from "./json-value-schema-
|
|
4
|
-
import { C as PortalSearchResultSchema, b as PortalListResultSchema, f as PortalCallItemResultSchema, g as PortalDescribeResultSchema, p as PortalCallResultSchema } from "./portal-call-result-schema-
|
|
5
|
-
import { i as GatewayApprovalPresentationRequestSchema, n as GatewayApprovalDecisionRequestSchema, r as GatewayApprovalDecisionResultSchema, t as ApprovalPresentationOutcomeSchema } from "./approval-surface-
|
|
6
|
-
import { a as PortalArtifactReadRequestSchema, o as PortalArtifactReadResultSchema } from "./artifact-surface-
|
|
7
|
-
import { dt as SandboxOperationIdentitySchema, f as ManagedAgentProjectionSchema, mt as SandboxRetainedResultLookupResultSchema, n as GatewayRuntimeAttachmentMetadataSchema, pt as SandboxRetainedResultLookupRequestSchema, s as GatewayRuntimeTrustedInvocationContextSchema, t as SANDBOX_METHOD_CONTRACTS, ut as SandboxOperationControlResultSchema } from "./contracts-
|
|
8
|
-
import { r as PortalCallRequestSchema } from "./portal-call-request-schema-
|
|
9
|
-
import {
|
|
10
|
-
import { o as PortalProgressEventSchema } from "./portal-event-surface-
|
|
3
|
+
import { o as JsonValueSchema } from "./json-value-schema-rxMrw9uZ.js";
|
|
4
|
+
import { C as PortalSearchResultSchema, b as PortalListResultSchema, f as PortalCallItemResultSchema, g as PortalDescribeResultSchema, p as PortalCallResultSchema } from "./portal-call-result-schema-DVJ6FyTz.js";
|
|
5
|
+
import { i as GatewayApprovalPresentationRequestSchema, n as GatewayApprovalDecisionRequestSchema, r as GatewayApprovalDecisionResultSchema, t as ApprovalPresentationOutcomeSchema } from "./approval-surface-CfbAG-81.js";
|
|
6
|
+
import { a as PortalArtifactReadRequestSchema, o as PortalArtifactReadResultSchema } from "./artifact-surface-Db5KQOA0.js";
|
|
7
|
+
import { dt as SandboxOperationIdentitySchema, f as ManagedAgentProjectionSchema, mt as SandboxRetainedResultLookupResultSchema, n as GatewayRuntimeAttachmentMetadataSchema, pt as SandboxRetainedResultLookupRequestSchema, s as GatewayRuntimeTrustedInvocationContextSchema, t as SANDBOX_METHOD_CONTRACTS, ut as SandboxOperationControlResultSchema } from "./contracts-K6l783Yb.js";
|
|
8
|
+
import { r as PortalCallRequestSchema } from "./portal-call-request-schema-B1dbBjmW.js";
|
|
9
|
+
import { c as PortalSearchRequestSchema, f as PortalDescribeRequestSchema, i as PortalAttachmentResultSchema, n as PortalFileResultSchema, r as PortalAttachmentRequestSchema, t as PortalFileRequestSchema, u as PortalListRequestSchema } from "./portal-call-surface-BPVX-rjw.js";
|
|
10
|
+
import { o as PortalProgressEventSchema } from "./portal-event-surface-Z76kra2a.js";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
+
import { oauthAccountToolOptionSchema, oauthToolAvailabilitySchema, oauthToolRequirementSchema } from "@agent-vm/oauth-broker-contracts";
|
|
12
13
|
//#region src/portable-contracts/portable-contract-runtime.ts
|
|
14
|
+
registerPortableExternalRefinement({
|
|
15
|
+
schema: oauthToolRequirementSchema.shape.operations,
|
|
16
|
+
refinementIdentity: "portal.google.discovery-policy"
|
|
17
|
+
});
|
|
18
|
+
registerPortableExternalRefinement({
|
|
19
|
+
schema: oauthAccountToolOptionSchema,
|
|
20
|
+
refinementIdentity: "portal.google.discovery-policy"
|
|
21
|
+
});
|
|
22
|
+
registerPortableExternalRefinement({
|
|
23
|
+
schema: oauthToolAvailabilitySchema,
|
|
24
|
+
refinementIdentity: "portal.google.discovery-policy"
|
|
25
|
+
});
|
|
13
26
|
const PORTABLE_CONTRACT_PROTOCOL_VERSION = 1;
|
|
14
27
|
function isUnknownRecord(value) {
|
|
15
28
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -76,6 +89,12 @@ function encodeCanonicalJson(value) {
|
|
|
76
89
|
return encodedValue;
|
|
77
90
|
}
|
|
78
91
|
function mapPortableIssue(props) {
|
|
92
|
+
if ([
|
|
93
|
+
"portal.file.request",
|
|
94
|
+
"portal.file.result",
|
|
95
|
+
"portal.attachment.request",
|
|
96
|
+
"portal.attachment.result"
|
|
97
|
+
].includes(props.schemaId)) return "portable.schema.invalid-union";
|
|
79
98
|
if (props.schemaId === "portal.call.item-result") {
|
|
80
99
|
const firstPathSegment = props.issue.path?.[0];
|
|
81
100
|
if (firstPathSegment === "outcome" || firstPathSegment === "operationId" || firstPathSegment === "owningGeneration") return "portal.result.outcome-algebra";
|
|
@@ -86,6 +105,7 @@ function mapPortableIssue(props) {
|
|
|
86
105
|
if (props.issue.code === "invalid_format" && "format" in props.issue && props.issue.format === "starts_with") return "portable.string.pattern";
|
|
87
106
|
if (props.issue.code === "too_big" && props.issue.origin === "number") return "portable.number.above-maximum";
|
|
88
107
|
if (props.issue.code === "custom") {
|
|
108
|
+
if (props.issue.message.startsWith("Google operation") || props.issue.message.startsWith("Usable account activity")) return "portal.google.discovery-policy";
|
|
89
109
|
if (props.issue.message.includes("decoded canonical base64 content")) return "sandbox.binary-chunk.byte-length-mismatch";
|
|
90
110
|
if (props.issue.message.includes("duplicate variable name")) return "sandbox.environment-variable.duplicate-name";
|
|
91
111
|
if (props.issue.message.includes("duplicate configured agent id")) return "gateway.attachment.duplicate-agent-id";
|
|
@@ -98,6 +118,16 @@ function mapPortableIssue(props) {
|
|
|
98
118
|
}
|
|
99
119
|
return `portable.zod.${props.issue.code}`;
|
|
100
120
|
}
|
|
121
|
+
function mapPortableIssues(props) {
|
|
122
|
+
if (props.schemaId === "portal.call.item-result" && props.issue.code === "invalid_union" && props.issue.path.length === 0 && isUnknownRecord(props.input)) {
|
|
123
|
+
const selected = props.issue.errors.filter((issues) => !issues.some((issue) => issue.path[0] === "status")).toSorted((left, right) => left.length - right.length)[0];
|
|
124
|
+
if (selected !== void 0 && selected.length > 0) return selected.map((issue) => mapPortableIssue({
|
|
125
|
+
...props,
|
|
126
|
+
issue
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
return [mapPortableIssue(props)];
|
|
130
|
+
}
|
|
101
131
|
function createPortableContractAdapter(props) {
|
|
102
132
|
return { parse: (input) => {
|
|
103
133
|
if (containsUnsafeInteger(input)) return {
|
|
@@ -111,7 +141,7 @@ function createPortableContractAdapter(props) {
|
|
|
111
141
|
parseSucceeded: parsed.success
|
|
112
142
|
}) ?? props.definition.refinementIdentities).toSorted((leftIdentity, rightIdentity) => leftIdentity.localeCompare(rightIdentity));
|
|
113
143
|
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.
|
|
144
|
+
errorCodes: props.schemaId === "portal.call.item-result" && isUnknownRecord(input) && callItemHasStatusShapeConflict(input) ? ["portal.result.status-shape"] : [...new Set(parsed.error.issues.flatMap((issue) => mapPortableIssues({
|
|
115
145
|
input,
|
|
116
146
|
issue,
|
|
117
147
|
schemaId: props.schemaId
|
|
@@ -127,7 +157,9 @@ function createPortableContractAdapter(props) {
|
|
|
127
157
|
} };
|
|
128
158
|
}
|
|
129
159
|
function callItemHasStatusShapeConflict(input) {
|
|
130
|
-
|
|
160
|
+
const outcome = input["outcome"];
|
|
161
|
+
const completedDelivery = isUnknownRecord(outcome) && outcome["kind"] === "completed" && outcome["completion"] === "failed" && outcome["certainty"] === "proven" && outcome["retryClass"] === "forbidden" && typeof input["operationId"] === "string" && input["operationId"].length > 0 && typeof input["owningGeneration"] === "string" && input["owningGeneration"].length > 0;
|
|
162
|
+
return input["status"] === "ok" && "error" in input || input["status"] === "error" && "value" in input && !completedDelivery;
|
|
131
163
|
}
|
|
132
164
|
const portableContractDefinitions = {
|
|
133
165
|
"portal.artifact.read-request": {
|
|
@@ -164,6 +196,22 @@ const portableContractDefinitions = {
|
|
|
164
196
|
},
|
|
165
197
|
schema: PortalCallRequestSchema
|
|
166
198
|
},
|
|
199
|
+
"portal.file.request": {
|
|
200
|
+
refinementIdentities: [],
|
|
201
|
+
schema: PortalFileRequestSchema
|
|
202
|
+
},
|
|
203
|
+
"portal.file.result": {
|
|
204
|
+
refinementIdentities: [],
|
|
205
|
+
schema: PortalFileResultSchema
|
|
206
|
+
},
|
|
207
|
+
"portal.attachment.request": {
|
|
208
|
+
refinementIdentities: [],
|
|
209
|
+
schema: PortalAttachmentRequestSchema
|
|
210
|
+
},
|
|
211
|
+
"portal.attachment.result": {
|
|
212
|
+
refinementIdentities: [],
|
|
213
|
+
schema: PortalAttachmentResultSchema
|
|
214
|
+
},
|
|
167
215
|
"portal.call.result": {
|
|
168
216
|
refinementIdentities: [
|
|
169
217
|
"portal.request-id.not-reserved",
|
|
@@ -181,7 +229,11 @@ const portableContractDefinitions = {
|
|
|
181
229
|
schema: PortalDescribeRequestSchema
|
|
182
230
|
},
|
|
183
231
|
"portal.describe.result": {
|
|
184
|
-
refinementIdentities: [
|
|
232
|
+
refinementIdentities: [
|
|
233
|
+
"portal.request-id.not-reserved",
|
|
234
|
+
"portal.result.aggregate-status",
|
|
235
|
+
"portal.google.discovery-policy"
|
|
236
|
+
],
|
|
185
237
|
schema: PortalDescribeResultSchema
|
|
186
238
|
},
|
|
187
239
|
"portal.json-value": {
|
|
@@ -200,7 +252,11 @@ const portableContractDefinitions = {
|
|
|
200
252
|
schema: PortalListRequestSchema
|
|
201
253
|
},
|
|
202
254
|
"portal.list.result": {
|
|
203
|
-
refinementIdentities: [
|
|
255
|
+
refinementIdentities: [
|
|
256
|
+
"portal.request-id.not-reserved",
|
|
257
|
+
"portal.result.aggregate-status",
|
|
258
|
+
"portal.google.discovery-policy"
|
|
259
|
+
],
|
|
204
260
|
schema: PortalListResultSchema
|
|
205
261
|
},
|
|
206
262
|
"portal.progress.event": {
|
|
@@ -217,7 +273,11 @@ const portableContractDefinitions = {
|
|
|
217
273
|
schema: PortalSearchRequestSchema
|
|
218
274
|
},
|
|
219
275
|
"portal.search.result": {
|
|
220
|
-
refinementIdentities: [
|
|
276
|
+
refinementIdentities: [
|
|
277
|
+
"portal.request-id.not-reserved",
|
|
278
|
+
"portal.result.aggregate-status",
|
|
279
|
+
"portal.google.discovery-policy"
|
|
280
|
+
],
|
|
221
281
|
schema: PortalSearchResultSchema
|
|
222
282
|
}
|
|
223
283
|
};
|
|
@@ -339,4 +399,4 @@ const PORTABLE_CONTRACT_ADAPTERS = Object.fromEntries(Object.entries(allPortable
|
|
|
339
399
|
//#endregion
|
|
340
400
|
export { encodeCanonicalJson as a, createPortableContractSchemaManifest as i, PORTABLE_CONTRACT_PROTOCOL_VERSION as n, assertPortableContractSchemaIsExportable as r, PORTABLE_CONTRACT_ADAPTERS as t };
|
|
341
401
|
|
|
342
|
-
//# sourceMappingURL=portable-contracts-
|
|
402
|
+
//# sourceMappingURL=portable-contracts-D7axGgu1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-contracts-D7axGgu1.js","names":[],"sources":["../src/portable-contracts/portable-contract-runtime.ts"],"sourcesContent":["import {\n\toauthToolRequirementSchema,\n\toauthAccountToolOptionSchema,\n\toauthToolAvailabilitySchema,\n} from '@agent-vm/oauth-broker-contracts';\nimport { z } from 'zod';\n\nimport {\n\tApprovalPresentationOutcomeSchema,\n\tGatewayApprovalDecisionRequestSchema,\n\tGatewayApprovalDecisionResultSchema,\n\tGatewayApprovalPresentationRequestSchema,\n} from '../approval-surface/index.js';\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\tPortalFileRequestSchema,\n\tPortalFileResultSchema,\n\tPortalAttachmentRequestSchema,\n\tPortalAttachmentResultSchema,\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 {\n\tportableRefinementIdentityForCheck,\n\tregisterPortableExternalRefinement,\n} 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\nregisterPortableExternalRefinement({\n\tschema: oauthToolRequirementSchema.shape.operations,\n\trefinementIdentity: 'portal.google.discovery-policy',\n});\nregisterPortableExternalRefinement({\n\tschema: oauthAccountToolOptionSchema,\n\trefinementIdentity: 'portal.google.discovery-policy',\n});\nregisterPortableExternalRefinement({\n\tschema: oauthToolAvailabilitySchema,\n\trefinementIdentity: 'portal.google.discovery-policy',\n});\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\t// The generated JSON-schema reader reports failure of these outer unions as\n\t// one shape error; keep TS diagnostics identical without relaxing either schema.\n\tif (\n\t\t[\n\t\t\t'portal.file.request',\n\t\t\t'portal.file.result',\n\t\t\t'portal.attachment.request',\n\t\t\t'portal.attachment.result',\n\t\t].includes(props.schemaId)\n\t)\n\t\treturn 'portable.schema.invalid-union';\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 (\n\t\t\tprops.issue.message.startsWith('Google operation') ||\n\t\t\tprops.issue.message.startsWith('Usable account activity')\n\t\t)\n\t\t\treturn 'portal.google.discovery-policy';\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('Managed Agent Projection Tool Portal namespaces')) {\n\t\t\treturn 'gateway.managed-agent-projection.namespaces';\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 mapPortableIssues(props: {\n\treadonly input: unknown;\n\treadonly issue: z.core.$ZodIssue;\n\treadonly schemaId: string;\n}): readonly string[] {\n\tif (\n\t\tprops.schemaId === 'portal.call.item-result' &&\n\t\tprops.issue.code === 'invalid_union' &&\n\t\tprops.issue.path.length === 0 &&\n\t\tisUnknownRecord(props.input)\n\t) {\n\t\t// Completed delivery errors share a status with ordinary errors. Preserve\n\t\t// field-level error codes from the closest matching status branch.\n\t\tconst matchingBranches = props.issue.errors.filter(\n\t\t\t(issues) => !issues.some((issue) => issue.path[0] === 'status'),\n\t\t);\n\t\tconst selected = matchingBranches.toSorted((left, right) => left.length - right.length)[0];\n\t\tif (selected !== undefined && selected.length > 0) {\n\t\t\treturn selected.map((issue) => mapPortableIssue({ ...props, issue }));\n\t\t}\n\t}\n\treturn [mapPortableIssue(props)];\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.flatMap((issue) =>\n\t\t\t\t\t\t\t\t\t\tmapPortableIssues({ 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\tconst outcome = input['outcome'];\n\tconst completedDelivery =\n\t\tisUnknownRecord(outcome) &&\n\t\toutcome['kind'] === 'completed' &&\n\t\toutcome['completion'] === 'failed' &&\n\t\toutcome['certainty'] === 'proven' &&\n\t\toutcome['retryClass'] === 'forbidden' &&\n\t\ttypeof input['operationId'] === 'string' &&\n\t\tinput['operationId'].length > 0 &&\n\t\ttypeof input['owningGeneration'] === 'string' &&\n\t\tinput['owningGeneration'].length > 0;\n\treturn (\n\t\t(input['status'] === 'ok' && 'error' in input) ||\n\t\t(input['status'] === 'error' && 'value' in input && !completedDelivery)\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.file.request': { refinementIdentities: [], schema: PortalFileRequestSchema },\n\t'portal.file.result': { refinementIdentities: [], schema: PortalFileResultSchema },\n\t'portal.attachment.request': { refinementIdentities: [], schema: PortalAttachmentRequestSchema },\n\t'portal.attachment.result': { refinementIdentities: [], schema: PortalAttachmentResultSchema },\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: [\n\t\t\t'portal.request-id.not-reserved',\n\t\t\t'portal.result.aggregate-status',\n\t\t\t'portal.google.discovery-policy',\n\t\t],\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: [\n\t\t\t'portal.request-id.not-reserved',\n\t\t\t'portal.result.aggregate-status',\n\t\t\t'portal.google.discovery-policy',\n\t\t],\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: [\n\t\t\t'portal.request-id.not-reserved',\n\t\t\t'portal.result.aggregate-status',\n\t\t\t'portal.google.discovery-policy',\n\t\t],\n\t\tschema: PortalSearchResultSchema,\n\t},\n} as const satisfies Readonly<Record<string, PortableContractDefinition>>;\n\nconst canonicalGatewayContractDefinitions = {\n\t'gateway.approval.decision-request': {\n\t\trefinementIdentities: [],\n\t\tschema: GatewayApprovalDecisionRequestSchema,\n\t},\n\t'gateway.approval.decision-result': {\n\t\trefinementIdentities: [],\n\t\tschema: GatewayApprovalDecisionResultSchema,\n\t},\n\t'gateway.approval.presentation-outcome': {\n\t\trefinementIdentities: [],\n\t\tschema: ApprovalPresentationOutcomeSchema,\n\t},\n\t'gateway.approval.presentation-request': {\n\t\trefinementIdentities: ['gateway.approval.arguments-preview.utf8-bytes'],\n\t\tschema: GatewayApprovalPresentationRequestSchema,\n\t},\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\t\t'gateway.managed-agent-projection.namespaces',\n\t\t\t'portal.namespace-discovery.summary-code-points',\n\t\t],\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":";;;;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wC;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"}
|
package/dist/{portable-refinement-authoring-C1Q92x2G.js → portable-refinement-authoring-oFICWLOo.js}
RENAMED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
//#region src/portable-contracts/portable-refinement-descriptors.ts
|
|
2
2
|
const PORTABLE_REFINEMENT_DESCRIPTORS = [
|
|
3
|
+
{
|
|
4
|
+
identity: "portal.google.discovery-policy",
|
|
5
|
+
description: "Google discovery has unique operation identities and never advertises ready access with unauthenticated account metadata.",
|
|
6
|
+
errorCode: "portal.google.discovery-policy",
|
|
7
|
+
kind: "cross-field-validation",
|
|
8
|
+
operation: { kind: "google-discovery-policy" }
|
|
9
|
+
},
|
|
3
10
|
{
|
|
4
11
|
description: "Artifact reads default omitted truncation state to false.",
|
|
5
12
|
identity: "portal.artifact-read.default-truncated",
|
|
@@ -223,7 +230,14 @@ function withPortableSuperRefinement(props) {
|
|
|
223
230
|
function portableRefinementIdentityForCheck(check) {
|
|
224
231
|
return portableRefinementIdentityByCheck.get(check);
|
|
225
232
|
}
|
|
233
|
+
/** Register one explicitly reviewed lower-layer check without introducing an SDK dependency cycle. */
|
|
234
|
+
function registerPortableExternalRefinement(props) {
|
|
235
|
+
if (!portableRefinementIdentities.has(props.refinementIdentity)) throw new Error("External portable refinement is not registered.");
|
|
236
|
+
const checks = (props.schema._zod.def.checks ?? []).filter((check) => check._zod.def.check === "custom");
|
|
237
|
+
if (checks.length !== 1 || checks[0] === void 0) throw new Error("External portable refinement must identify exactly one custom check.");
|
|
238
|
+
portableRefinementIdentityByCheck.set(checks[0], props.refinementIdentity);
|
|
239
|
+
}
|
|
226
240
|
//#endregion
|
|
227
|
-
export { PORTABLE_REFINEMENT_IDENTITIES as i,
|
|
241
|
+
export { PORTABLE_REFINEMENT_IDENTITIES as a, PORTABLE_REFINEMENT_DESCRIPTORS as i, registerPortableExternalRefinement as n, withPortableSuperRefinement as r, portableRefinementIdentityForCheck as t };
|
|
228
242
|
|
|
229
|
-
//# sourceMappingURL=portable-refinement-authoring-
|
|
243
|
+
//# sourceMappingURL=portable-refinement-authoring-oFICWLOo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-refinement-authoring-oFICWLOo.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| { readonly kind: 'google-discovery-policy' }\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: 'maximum-code-points';\n\t\t\treadonly maximum: number;\n\t }\n\t| {\n\t\t\treadonly fieldNames: readonly string[];\n\t\t\treadonly kind: 'maximum-utf8-bytes';\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| {\n\t\t\treadonly fieldName: string;\n\t\t\treadonly kind: 'sorted-unique-object-field-items';\n\t\t\treadonly path: string;\n\t }\n\t| { readonly kind: 'sorted-unique-string-items'; readonly path: string }\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\tidentity: 'portal.google.discovery-policy',\n\t\tdescription:\n\t\t\t'Google discovery has unique operation identities and never advertises ready access with unauthenticated account metadata.',\n\t\terrorCode: 'portal.google.discovery-policy',\n\t\tkind: 'cross-field-validation',\n\t\toperation: { kind: 'google-discovery-policy' },\n\t},\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 approval argument previews remain inside the portable UTF-8 byte bound.',\n\t\terrorCode: 'gateway.approval.arguments-preview.above-maximum',\n\t\tidentity: 'gateway.approval.arguments-preview.utf8-bytes',\n\t\tkind: 'structural-validation',\n\t\toperation: { fieldNames: ['argumentsPreview'], kind: 'maximum-utf8-bytes', maximum: 4_096 },\n\t},\n\t{\n\t\tdescription:\n\t\t\t'Namespace discovery summaries remain inside the portable Unicode code-point bound.',\n\t\terrorCode: 'portal.namespace-discovery.summary-above-maximum',\n\t\tidentity: 'portal.namespace-discovery.summary-code-points',\n\t\tkind: 'structural-validation',\n\t\toperation: { fieldNames: ['summary'], kind: 'maximum-code-points', maximum: 500 },\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: 'Managed Agent Projection namespaces must be sorted and unique by namespace.',\n\t\terrorCode: 'gateway.managed-agent-projection.namespaces',\n\t\tidentity: 'gateway.managed-agent-projection.namespaces',\n\t\tkind: 'cross-field-validation',\n\t\toperation: {\n\t\t\tfieldName: 'namespace',\n\t\t\tkind: 'sorted-unique-object-field-items',\n\t\t\tpath: 'toolPortalNamespaces',\n\t\t},\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\n/** Register one explicitly reviewed lower-layer check without introducing an SDK dependency cycle. */\nexport function registerPortableExternalRefinement(props: {\n\treadonly schema: z.ZodType;\n\treadonly refinementIdentity: string;\n}): void {\n\tif (!portableRefinementIdentities.has(props.refinementIdentity))\n\t\tthrow new Error('External portable refinement is not registered.');\n\t// oxlint-disable-next-line no-underscore-dangle -- The same Zod core check identity used by the normal authoring helper.\n\tconst checks = (props.schema._zod.def.checks ?? []).filter(\n\t\t(check) => check._zod.def.check === 'custom',\n\t);\n\tif (checks.length !== 1 || checks[0] === undefined)\n\t\tthrow new Error('External portable refinement must identify exactly one custom check.');\n\tportableRefinementIdentityByCheck.set(checks[0], props.refinementIdentity);\n}\n"],"mappings":";AAwEA,MAAa,kCAAkC;CAC9C;EACC,UAAU;EACV,aACC;EACD,WAAW;EACX,MAAM;EACN,WAAW,EAAE,MAAM,2BAA2B;EAC9C;CACD;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,WAAW;GAAE,iBAAiB,CAAC,SAAS,WAAW;GAAE,WAAW;GAAM,MAAM;GAAgB;EAC5F;CACD;EACC,aAAa;EACb,UAAU;EACV,MAAM;EACN,WAAW;GACV,MAAM;GACN,QAAQ;IACP,iCAAiC;IACjC,8BAA8B;IAC9B,uCAAuC;IACvC,0BAA0B;IAC1B;GACD;EACD;CACD;EACC,aAAa;EACb,UAAU;EACV,MAAM;EACN,WAAW;GACV,MAAM;GACN,mBAAmB;GACnB,sBAAsB;GACt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Y,MAAM,mBAAmB;CAC3E,OAAO;;AAGR,SAAgB,mCAAmC,OAAmC;CACrF,OAAO,kCAAkC,IAAI,MAAM;;;AAIpD,SAAgB,mCAAmC,OAG1C;CACR,IAAI,CAAC,6BAA6B,IAAI,MAAM,mBAAmB,EAC9D,MAAM,IAAI,MAAM,kDAAkD;CAEnE,MAAM,UAAU,MAAM,OAAO,KAAK,IAAI,UAAU,EAAE,EAAE,QAClD,UAAU,MAAM,KAAK,IAAI,UAAU,SACpC;CACD,IAAI,OAAO,WAAW,KAAK,OAAO,OAAO,KAAA,GACxC,MAAM,IAAI,MAAM,uEAAuE;CACxF,kCAAkC,IAAI,OAAO,IAAI,MAAM,mBAAmB"}
|
package/dist/{portal-call-request-schema-Cl0kTLaX.js → portal-call-request-schema-B1dbBjmW.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as RequestIdSchema } from "./request-id-schema-
|
|
3
|
-
import { i as JsonObjectSchema } from "./json-value-schema-
|
|
1
|
+
import { r as withPortableSuperRefinement } from "./portable-refinement-authoring-oFICWLOo.js";
|
|
2
|
+
import { n as RequestIdSchema } from "./request-id-schema-DQ84TX-D.js";
|
|
3
|
+
import { i as JsonObjectSchema } from "./json-value-schema-rxMrw9uZ.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
//#region src/portal-call-surface/models/portal-batch-id-refinement.ts
|
|
6
6
|
function addDuplicateItemIdIssues(items, context) {
|
|
@@ -38,4 +38,4 @@ const PortalCallRequestSchema = withPortableSuperRefinement({
|
|
|
38
38
|
//#endregion
|
|
39
39
|
export { addDuplicateItemIdIssues as i, PortalCallItemRequestSchema as n, PortalCallRequestSchema as r, PortalBatchMaxItems as t };
|
|
40
40
|
|
|
41
|
-
//# sourceMappingURL=portal-call-request-schema-
|
|
41
|
+
//# sourceMappingURL=portal-call-request-schema-B1dbBjmW.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal-call-request-schema-
|
|
1
|
+
{"version":3,"file":"portal-call-request-schema-B1dbBjmW.js","names":[],"sources":["../src/portal-call-surface/models/portal-batch-id-refinement.ts","../src/portal-call-surface/models/portal-call-request-schema.ts"],"sourcesContent":["import type { z } from 'zod';\n\nexport interface PortalBatchItemWithId {\n\treadonly id: string;\n}\n\nexport function addDuplicateItemIdIssues(\n\titems: readonly PortalBatchItemWithId[],\n\tcontext: z.RefinementCtx,\n): void {\n\tconst seenIds = new Set<string>();\n\tconst duplicateIds = new Set<string>();\n\tfor (const item of items) {\n\t\tif (seenIds.has(item.id)) {\n\t\t\tduplicateIds.add(item.id);\n\t\t}\n\t\tseenIds.add(item.id);\n\t}\n\tfor (const duplicateId of [...duplicateIds].toSorted()) {\n\t\tcontext.addIssue({\n\t\t\tcode: 'custom',\n\t\t\tmessage: `Duplicate portal item id \"${duplicateId}\".`,\n\t\t\tpath: ['id'],\n\t\t});\n\t}\n}\n","import { z } from 'zod';\n\nimport { JsonObjectSchema } from '../../contract-primitives/models/json-value-schema.js';\nimport { RequestIdSchema } from '../../contract-primitives/models/request-id-schema.js';\nimport { withPortableSuperRefinement } from '../../portable-contracts/portable-refinement-authoring.js';\nimport { addDuplicateItemIdIssues } from './portal-batch-id-refinement.js';\n\nexport const PortalBatchMaxItems = 50;\n\nexport const PortalCallItemRequestSchema = z\n\t.object({\n\t\targuments: JsonObjectSchema,\n\t\tid: RequestIdSchema,\n\t\tnamespace: z.string().min(1),\n\t\tname: z.string().min(1),\n\t})\n\t.strict();\n\nexport const PortalCallRequestSchema = withPortableSuperRefinement({\n\trefinement: (request, context) => {\n\t\taddDuplicateItemIdIssues(request.calls, context);\n\t},\n\trefinementIdentity: 'portal.batch.unique-item-ids',\n\tschema: z\n\t\t.object({\n\t\t\tcalls: z.array(PortalCallItemRequestSchema).min(1).max(PortalBatchMaxItems),\n\t\t\trequestId: RequestIdSchema.optional(),\n\t\t})\n\t\t.strict(),\n});\n\nexport type PortalCallRequest = z.infer<typeof PortalCallRequestSchema>;\n"],"mappings":";;;;;AAMA,SAAgB,yBACf,OACA,SACO;CACP,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,+BAAe,IAAI,KAAa;CACtC,KAAK,MAAM,QAAQ,OAAO;EACzB,IAAI,QAAQ,IAAI,KAAK,GAAG,EACvB,aAAa,IAAI,KAAK,GAAG;EAE1B,QAAQ,IAAI,KAAK,GAAG;;CAErB,KAAK,MAAM,eAAe,CAAC,GAAG,aAAa,CAAC,UAAU,EACrD,QAAQ,SAAS;EAChB,MAAM;EACN,SAAS,6BAA6B,YAAY;EAClD,MAAM,CAAC,KAAK;EACZ,CAAC;;;;AChBJ,MAAa,sBAAsB;AAEnC,MAAa,8BAA8B,EACzC,OAAO;CACP,WAAW;CACX,IAAI;CACJ,WAAW,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC5B,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,CAAC,CACD,QAAQ;AAEV,MAAa,0BAA0B,4BAA4B;CAClE,aAAa,SAAS,YAAY;EACjC,yBAAyB,QAAQ,OAAO,QAAQ;;CAEjD,oBAAoB;CACpB,QAAQ,EACN,OAAO;EACP,OAAO,EAAE,MAAM,4BAA4B,CAAC,IAAI,EAAE,CAAC,IAAA,GAAwB;EAC3E,WAAW,gBAAgB,UAAU;EACrC,CAAC,CACD,QAAQ;CACV,CAAC"}
|