@tangle-network/sandbox 1.0.21 → 1.0.23
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/agent/index.d.ts +4 -4
- package/dist/agent/index.js +5 -5
- package/dist/agent/preview.d.ts +1 -1
- package/dist/agent/preview.js +3 -3
- package/dist/{agent-run-outcome-I1nMkkrz.d.ts → agent-run-outcome-DQjHjmTQ.d.ts} +2 -2
- package/dist/{api-request-EseiF9B1.js → api-request-DNrodWdz.js} +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{browser-interactive-control-controller-Bt1vcu9c.js → browser-interactive-control-controller-EhML8YjF.js} +186 -2131
- package/dist/{browser-interactive-control-controller-CVnME80O.d.ts → browser-interactive-control-controller-i9JtmJDf.d.ts} +1 -1
- package/dist/{chunked-upload-Df_5Q2x8.js → chunked-upload-KRWmiJsw.js} +1 -1
- package/dist/{chunked-upload-file-Dtm1GBkE.js → chunked-upload-file-DPSyrGUb.js} +2 -2
- package/dist/cli-auth-bundle-V7sPQYej.js +1594 -0
- package/dist/{client-DEvdnu0z.d.ts → client-1bgxaNQD.d.ts} +5 -5
- package/dist/{client-HMGk7nNW.js → client-DC1Q6oJb.js} +11 -11
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/{collaboration-BTGTf3We.js → collaboration-DPukGUcF.js} +1 -1
- package/dist/{core-DvYE_89H.js → core-0iCiDt_5.js} +5 -5
- package/dist/core.d.ts +6 -6
- package/dist/core.js +5 -5
- package/dist/{direct-http2-B0ra_xhU.js → direct-http2-C0H7zN9h.js} +1 -1
- package/dist/{errors-ZmDrrk4f.js → errors-BUPIDjn4.js} +1 -1
- package/dist/{sha2-BUPMvGTk.js → harness-DkCl2wJv.js} +417 -1
- package/dist/{index-C3GQDkDm.d.ts → index-vcweImuL.d.ts} +6 -6
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/intelligence/index.js +2 -2
- package/dist/interactive-control.d.ts +1 -1
- package/dist/interactive-control.js +1 -1
- package/dist/{interactive-controller-Bf8yrdzR.d.ts → interactive-controller-B16SZKZt.d.ts} +3 -3
- package/dist/{interactive-controller-BkfV4Cs_.js → interactive-controller-kZk52Eff.js} +19 -21
- package/dist/lib/prepared-evidence.js +1 -1
- package/dist/lib/prepared-process.js +1 -1
- package/dist/{lines-BqZOl_io.js → lines-BnAWHGX3.js} +1 -1
- package/dist/{lines-CA1IbRzE.d.ts → lines-BxCEZUkf.d.ts} +1 -1
- package/dist/lines.d.ts +1 -1
- package/dist/lines.js +1 -1
- package/dist/{local-cli-auth-DzovETOu.js → local-cli-auth-CJuKPr1j.js} +1 -1
- package/dist/{mcp-local-BcRLN_Ic.js → mcp-local-C88efQL3.js} +1 -1
- package/dist/{prepared-evidence-CuUh_mz6.js → prepared-evidence-DC-M4WEF.js} +1 -1
- package/dist/{preview-DQs0Zh9L.d.ts → preview-QcwZWgzk.d.ts} +3 -3
- package/dist/{profile-schema-CT3hB1mG.js → profile-schema-1WmjXjE9.js} +23 -12
- package/dist/{public-templates-COGktcNu.d.ts → public-templates-GNIKn_wg.d.ts} +2 -2
- package/dist/public-templates.d.ts +1 -1
- package/dist/public-templates.js +1 -1
- package/dist/{raw-evidence-archive-CqarcYcp.js → raw-evidence-archive-Bc-OdA_Q.js} +1 -1
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +5 -5
- package/dist/{sandbox-BAhF5QaX.js → sandbox-Qn9ScVvS.js} +46 -48
- package/dist/{secp256k1-CZWrpqxW.js → secp256k1-BGtA1PsN.js} +1 -1
- package/dist/select-seat-command.d.ts +1 -1
- package/dist/select-seat-command.js +1 -1
- package/dist/session-gateway/index.js +3 -3
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-CwfZovBM.js → tangle-DOwUAne4.js} +4 -4
- package/dist/{terminal-stream-types-DwXQzUbH.d.ts → terminal-stream-types-BM5J4lt0.d.ts} +155 -769
- package/dist/{types-BF8se4_x.d.ts → types-MYaFNkH5.d.ts} +7 -7
- package/package.json +8 -8
- package/dist/cli-auth-bundle-KtV88h1f.js +0 -2597
- package/dist/harness-BD_OISom.js +0 -201
- package/dist/harness-DWL2MM4q.js +0 -418
- /package/dist/{abort-signal-jU-SEjLT.js → abort-signal-CDxyloxz.js} +0 -0
- /package/dist/{cli-auth-bundle-MskLEgtA.d.ts → cli-auth-bundle-CFZx0muA.d.ts} +0 -0
- /package/dist/{index-Dqcr9p97.d.ts → index-DnZdhFs2.d.ts} +0 -0
- /package/dist/{index-Dslyq85a.d.ts → index-rbeL2Rct.d.ts} +0 -0
- /package/dist/{keep-alive-fetch-C2DX2_rG.js → keep-alive-fetch-BbSFbRCd.js} +0 -0
- /package/dist/{prepared-process-LjBfQnZ5.js → prepared-process-BQUSksTH.js} +0 -0
- /package/dist/{preview-operations-BvgwYaoL.js → preview-operations-D2fXB_dc.js} +0 -0
- /package/dist/{response-rewrap-MBztoTLx.js → response-rewrap-CpNkboDX.js} +0 -0
- /package/dist/{retry-after-header-BZbs5rig.js → retry-after-header-DUdCC0KJ.js} +0 -0
- /package/dist/{sidecar-proxy-error-Dty4zmN7.js → sidecar-proxy-error-5DpLmHeN.js} +0 -0
- /package/dist/{sse-parser-CJ52bhG3.js → sse-parser-CKkE9zWy.js} +0 -0
- /package/dist/{utils-vaFoyyiO.js → utils-CoawKwX_.js} +0 -0
|
@@ -1,1952 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as awaitWithAbort } from "./abort-signal-jU-SEjLT.js";
|
|
1
|
+
import { C as boundedIdentifierSchema, D as isBoundedEventContentJson, E as boundedStringSchema, S as boundedEventContentStringSchema, T as boundedJsonSchema, b as boundedEventContentJsonSchema, g as sha256DigestSchema, h as omitTopLevelDigest, m as looksLikeCredential, n as REASONING_EFFORTS, o as canonicalCandidateDigest, p as isWellFormedUnicode, s as canonicalCandidateJson, t as harnessTypeSchema, u as isCanonicalJsonValue, v as CONTRACT_MAX_ARRAY_LENGTH, w as boundedJsonRecordSchema, x as boundedEventContentRecordSchema, y as CONTRACT_MAX_STRING_LENGTH } from "./harness-DkCl2wJv.js";
|
|
2
|
+
import { t as awaitWithAbort } from "./abort-signal-CDxyloxz.js";
|
|
4
3
|
import { z } from "zod";
|
|
5
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@
|
|
6
|
-
/** Limits applied before a value is hashed, copied, or sent to a provider. */
|
|
7
|
-
const CONTRACT_MAX_STRING_LENGTH = 16384;
|
|
8
|
-
/** Maximum length of one canonical confidential-attestation quote. */
|
|
9
|
-
const CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH = 32768;
|
|
10
|
-
const CONTRACT_MAX_ARRAY_LENGTH = 1024;
|
|
11
|
-
const CONTRACT_MAX_JSON_BYTES = 1048576;
|
|
12
|
-
const boundedStringSchema = z.string().max(CONTRACT_MAX_STRING_LENGTH);
|
|
13
|
-
z.string().max(CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH);
|
|
14
|
-
const boundedIdentifierSchema = boundedStringSchema.min(1).max(512).refine((value) => value.trim() === value, "identifier cannot have outer whitespace");
|
|
15
|
-
/**
|
|
16
|
-
* Validate JSON without asking Zod to recursively copy an attacker-sized
|
|
17
|
-
* value. This is intentionally iterative so depth and collection limits are
|
|
18
|
-
* checked before canonical serialization.
|
|
19
|
-
*/
|
|
20
|
-
function isBoundedJsonValue(value) {
|
|
21
|
-
const pending = [{
|
|
22
|
-
value,
|
|
23
|
-
depth: 0
|
|
24
|
-
}];
|
|
25
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
26
|
-
let nodes = 0;
|
|
27
|
-
while (pending.length > 0) {
|
|
28
|
-
const item = pending.pop();
|
|
29
|
-
if (!item) continue;
|
|
30
|
-
nodes += 1;
|
|
31
|
-
if (nodes > 8192) return false;
|
|
32
|
-
const current = item.value;
|
|
33
|
-
if (item.leave) {
|
|
34
|
-
ancestors.delete(current);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (current === void 0) return false;
|
|
38
|
-
if (current === null || typeof current === "boolean") continue;
|
|
39
|
-
if (typeof current === "string") {
|
|
40
|
-
if (current.length > 16384) return false;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (typeof current === "number") {
|
|
44
|
-
if (!Number.isFinite(current)) return false;
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (typeof current !== "object" || item.depth >= 16) return false;
|
|
48
|
-
if (ancestors.has(current)) return false;
|
|
49
|
-
ancestors.add(current);
|
|
50
|
-
pending.push({
|
|
51
|
-
value: current,
|
|
52
|
-
depth: item.depth,
|
|
53
|
-
leave: true
|
|
54
|
-
});
|
|
55
|
-
if (Array.isArray(current)) {
|
|
56
|
-
if (current.length > 1024) return false;
|
|
57
|
-
for (const entry of current) pending.push({
|
|
58
|
-
value: entry,
|
|
59
|
-
depth: item.depth + 1
|
|
60
|
-
});
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const prototype = Object.getPrototypeOf(current);
|
|
64
|
-
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
65
|
-
const keys = Object.keys(current);
|
|
66
|
-
if (keys.length > 256) return false;
|
|
67
|
-
for (const key of keys) {
|
|
68
|
-
if (key.length > 512) return false;
|
|
69
|
-
pending.push({
|
|
70
|
-
value: current[key],
|
|
71
|
-
depth: item.depth + 1
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
/** Exact serialized JSON UTF-8 byte count for one string scalar. */
|
|
78
|
-
function serializedJsonStringBytes(value) {
|
|
79
|
-
let bytes = 2;
|
|
80
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
81
|
-
const code = value.charCodeAt(index);
|
|
82
|
-
if (code === 34 || code === 92 || code === 8 || code === 12 || code === 10 || code === 13 || code === 9) bytes += 2;
|
|
83
|
-
else if (code < 32) bytes += 6;
|
|
84
|
-
else if (code >= 55296 && code <= 56319 && index + 1 < value.length) {
|
|
85
|
-
const next = value.charCodeAt(index + 1);
|
|
86
|
-
if (next >= 56320 && next <= 57343) {
|
|
87
|
-
bytes += 4;
|
|
88
|
-
index += 1;
|
|
89
|
-
} else bytes += 6;
|
|
90
|
-
} else if (code >= 55296 && code <= 57343) bytes += 6;
|
|
91
|
-
else if (code < 128) bytes += 1;
|
|
92
|
-
else if (code < 2048) bytes += 2;
|
|
93
|
-
else bytes += 3;
|
|
94
|
-
if (bytes > 1048576) return bytes;
|
|
95
|
-
}
|
|
96
|
-
return bytes;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Validate provider event and terminal content. Unlike ordinary metadata,
|
|
100
|
-
* content may contain a single large transcript or tool result. It remains
|
|
101
|
-
* finite, plain JSON with the normal structural limits, and its complete JSON
|
|
102
|
-
* representation is capped exactly by UTF-8 bytes.
|
|
103
|
-
*/
|
|
104
|
-
function isBoundedEventContentJson(value, { omitUndefinedObjectFields = false } = {}) {
|
|
105
|
-
const pending = [{
|
|
106
|
-
value,
|
|
107
|
-
depth: 0
|
|
108
|
-
}];
|
|
109
|
-
const ancestors = /* @__PURE__ */ new Set();
|
|
110
|
-
let nodes = 0;
|
|
111
|
-
let bytes = 0;
|
|
112
|
-
const addBytes = (additional) => {
|
|
113
|
-
bytes += additional;
|
|
114
|
-
return bytes <= CONTRACT_MAX_JSON_BYTES;
|
|
115
|
-
};
|
|
116
|
-
while (pending.length > 0) {
|
|
117
|
-
const item = pending.pop();
|
|
118
|
-
if (!item) continue;
|
|
119
|
-
const current = item.value;
|
|
120
|
-
if (current === void 0 && item.omitUndefined === true) continue;
|
|
121
|
-
nodes += 1;
|
|
122
|
-
if (nodes > 8192) return false;
|
|
123
|
-
if (item.leave) {
|
|
124
|
-
ancestors.delete(current);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (current === null) {
|
|
128
|
-
if (!addBytes(4)) return false;
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (typeof current === "boolean") {
|
|
132
|
-
if (!addBytes(current ? 4 : 5)) return false;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (typeof current === "string") {
|
|
136
|
-
if (!addBytes(serializedJsonStringBytes(current))) return false;
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (typeof current === "number") {
|
|
140
|
-
if (!Number.isFinite(current)) return false;
|
|
141
|
-
if (!addBytes(JSON.stringify(current).length)) return false;
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (typeof current !== "object" || item.depth >= 16) return false;
|
|
145
|
-
if (ancestors.has(current)) return false;
|
|
146
|
-
ancestors.add(current);
|
|
147
|
-
pending.push({
|
|
148
|
-
value: current,
|
|
149
|
-
depth: item.depth,
|
|
150
|
-
leave: true
|
|
151
|
-
});
|
|
152
|
-
if (Array.isArray(current)) {
|
|
153
|
-
if (current.length > 1024) return false;
|
|
154
|
-
if (!addBytes(2 + Math.max(current.length - 1, 0))) return false;
|
|
155
|
-
const prototype = Object.getPrototypeOf(current);
|
|
156
|
-
if (prototype !== Array.prototype && prototype !== null) return false;
|
|
157
|
-
const entryKeys = Reflect.ownKeys(current).filter((key) => key !== "length");
|
|
158
|
-
if (entryKeys.length !== current.length) return false;
|
|
159
|
-
if (entryKeys.some((key) => {
|
|
160
|
-
if (typeof key !== "string" || !/^(?:0|[1-9][0-9]*)$/u.test(key)) return true;
|
|
161
|
-
const index = Number(key);
|
|
162
|
-
return !Number.isSafeInteger(index) || index < 0 || index >= current.length || index >= 4294967295;
|
|
163
|
-
})) return false;
|
|
164
|
-
for (const key of entryKeys) {
|
|
165
|
-
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
166
|
-
if (descriptor === void 0 || !descriptor.enumerable || !("value" in descriptor)) return false;
|
|
167
|
-
pending.push({
|
|
168
|
-
value: descriptor.value,
|
|
169
|
-
depth: item.depth + 1
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
const prototype = Object.getPrototypeOf(current);
|
|
175
|
-
if (prototype !== Object.prototype && prototype !== null) return false;
|
|
176
|
-
const entries = [];
|
|
177
|
-
for (const key of Reflect.ownKeys(current)) {
|
|
178
|
-
if (typeof key !== "string" || key.length > 512) return false;
|
|
179
|
-
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
180
|
-
if (descriptor === void 0 || !descriptor.enumerable || !("value" in descriptor)) return false;
|
|
181
|
-
if (descriptor.value === void 0 && omitUndefinedObjectFields) continue;
|
|
182
|
-
entries.push([key, descriptor]);
|
|
183
|
-
if (entries.length > 256) return false;
|
|
184
|
-
}
|
|
185
|
-
if (!addBytes(2 + Math.max(entries.length - 1, 0))) return false;
|
|
186
|
-
for (const [key, descriptor] of entries) {
|
|
187
|
-
if (!addBytes(serializedJsonStringBytes(key) + 1)) return false;
|
|
188
|
-
pending.push({
|
|
189
|
-
value: descriptor.value,
|
|
190
|
-
depth: item.depth + 1,
|
|
191
|
-
omitUndefined: omitUndefinedObjectFields
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return true;
|
|
196
|
-
}
|
|
197
|
-
const boundedJsonSchema = z.custom(isBoundedJsonValue, { message: "value exceeds the contract bounds or is not finite JSON" });
|
|
198
|
-
const boundedJsonRecordSchema = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value) && isBoundedJsonValue(value), { message: "metadata exceeds the contract bounds or is not a JSON object" });
|
|
199
|
-
/** One provider event payload or terminal response, bounded as serialized UTF-8 JSON. */
|
|
200
|
-
const boundedEventContentJsonSchema = z.custom(isBoundedEventContentJson, { message: "event content exceeds its serialized byte bound or is not finite JSON" });
|
|
201
|
-
const boundedEventContentRecordSchema = z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value) && isBoundedEventContentJson(value), { message: "event content exceeds its serialized byte bound or is not a JSON object" });
|
|
202
|
-
const boundedEventContentStringSchema = z.custom((value) => typeof value === "string" && isBoundedEventContentJson(value), { message: "event content exceeds its serialized byte bound or is not a string" });
|
|
203
|
-
//#endregion
|
|
204
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/native-session-event.js
|
|
205
|
-
/**
|
|
206
|
-
* Private adapter observation of a provider conversation or resume identity.
|
|
207
|
-
* The adapter must obtain this ID from its bound provider process or API.
|
|
208
|
-
* Caller keys, execution IDs, storage paths, and public session updates are not evidence.
|
|
209
|
-
* The execution owner binds this observation to its own execution and session.
|
|
210
|
-
* Public SSE and user-visible event streams must exclude this control event.
|
|
211
|
-
* An observation establishes identity only, not native artifact completeness.
|
|
212
|
-
*/
|
|
213
|
-
const NativeSessionObservedEventSchema$1 = z.object({
|
|
214
|
-
type: z.literal("native.session.observed"),
|
|
215
|
-
provider: z.string().regex(/^[a-z][a-z0-9-]{0,127}$/),
|
|
216
|
-
nativeSessionId: z.string().min(1).max(512).regex(/^\S+$/u)
|
|
217
|
-
}).strict();
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/environment-observation.js
|
|
220
|
-
const ObservationProvenanceSchema$1 = z.strictObject({
|
|
221
|
-
origin: z.enum([
|
|
222
|
-
"measured",
|
|
223
|
-
"reported",
|
|
224
|
-
"estimated"
|
|
225
|
-
]),
|
|
226
|
-
observedAt: z.iso.datetime().max(64),
|
|
227
|
-
source: boundedIdentifierSchema.optional()
|
|
228
|
-
});
|
|
229
|
-
/** Build a freshness-tagged observation schema around one value schema. */
|
|
230
|
-
function observationOf$1(value) {
|
|
231
|
-
return z.discriminatedUnion("state", [
|
|
232
|
-
z.strictObject({
|
|
233
|
-
state: z.literal("known"),
|
|
234
|
-
value,
|
|
235
|
-
provenance: ObservationProvenanceSchema$1
|
|
236
|
-
}),
|
|
237
|
-
z.strictObject({
|
|
238
|
-
state: z.literal("stale"),
|
|
239
|
-
value,
|
|
240
|
-
provenance: ObservationProvenanceSchema$1,
|
|
241
|
-
reason: boundedStringSchema.min(1)
|
|
242
|
-
}),
|
|
243
|
-
z.strictObject({
|
|
244
|
-
state: z.literal("unavailable"),
|
|
245
|
-
reason: boundedStringSchema.min(1)
|
|
246
|
-
}),
|
|
247
|
-
z.strictObject({
|
|
248
|
-
state: z.literal("redacted"),
|
|
249
|
-
reason: boundedStringSchema.min(1)
|
|
250
|
-
}),
|
|
251
|
-
z.strictObject({ state: z.literal("unknown") })
|
|
252
|
-
]);
|
|
253
|
-
}
|
|
254
|
-
const nonNegativeNumberSchema$1 = z.number().finite().nonnegative();
|
|
255
|
-
const ProviderIdentitySchema$1 = z.strictObject({
|
|
256
|
-
provider: boundedIdentifierSchema,
|
|
257
|
-
environmentId: boundedIdentifierSchema,
|
|
258
|
-
sessionId: boundedIdentifierSchema.optional(),
|
|
259
|
-
backend: boundedIdentifierSchema.optional()
|
|
260
|
-
});
|
|
261
|
-
const AgentEnvironmentStatusSchema$1 = z.enum([
|
|
262
|
-
"pending",
|
|
263
|
-
"provisioning",
|
|
264
|
-
"running",
|
|
265
|
-
"stopped",
|
|
266
|
-
"failed",
|
|
267
|
-
"expired",
|
|
268
|
-
"unknown"
|
|
269
|
-
]);
|
|
270
|
-
/** Lifecycle, cleanup, continuity, and persistence of one environment. */
|
|
271
|
-
const EnvironmentLifecycleSchema$1 = z.strictObject({
|
|
272
|
-
status: AgentEnvironmentStatusSchema$1,
|
|
273
|
-
cleanup: z.strictObject({
|
|
274
|
-
policy: z.enum([
|
|
275
|
-
"manual",
|
|
276
|
-
"idle",
|
|
277
|
-
"scheduled",
|
|
278
|
-
"on-exit"
|
|
279
|
-
]).optional(),
|
|
280
|
-
scheduledAt: z.iso.datetime().max(64).optional(),
|
|
281
|
-
confirmed: z.boolean().optional()
|
|
282
|
-
}).optional(),
|
|
283
|
-
continuity: z.strictObject({
|
|
284
|
-
resumable: z.boolean(),
|
|
285
|
-
mode: z.enum([
|
|
286
|
-
"native",
|
|
287
|
-
"replayed",
|
|
288
|
-
"none"
|
|
289
|
-
]).optional()
|
|
290
|
-
}).optional(),
|
|
291
|
-
persistence: z.strictObject({
|
|
292
|
-
durable: z.boolean(),
|
|
293
|
-
scope: z.enum([
|
|
294
|
-
"ephemeral",
|
|
295
|
-
"session",
|
|
296
|
-
"durable"
|
|
297
|
-
]).optional()
|
|
298
|
-
}).optional()
|
|
299
|
-
});
|
|
300
|
-
/**
|
|
301
|
-
* Credential-free network location. There is no field for a user, password,
|
|
302
|
-
* token, or other secret, and the host and scheme reject embedded credentials.
|
|
303
|
-
*/
|
|
304
|
-
const SafeEndpointSchema$1 = z.strictObject({
|
|
305
|
-
scheme: boundedIdentifierSchema.optional(),
|
|
306
|
-
host: boundedIdentifierSchema,
|
|
307
|
-
port: z.number().int().min(1).max(65535).optional(),
|
|
308
|
-
region: boundedIdentifierSchema.optional()
|
|
309
|
-
}).superRefine((endpoint, refinement) => {
|
|
310
|
-
if (/[@/\s]|:\/\//.test(endpoint.host)) refinement.addIssue({
|
|
311
|
-
code: "custom",
|
|
312
|
-
path: ["host"],
|
|
313
|
-
message: "endpoint host must not carry credentials, a scheme, or a path"
|
|
314
|
-
});
|
|
315
|
-
if (endpoint.scheme !== void 0 && /[@:/\s]/.test(endpoint.scheme)) refinement.addIssue({
|
|
316
|
-
code: "custom",
|
|
317
|
-
path: ["scheme"],
|
|
318
|
-
message: "endpoint scheme must be a bare protocol name"
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
/** Requested or effective compute shape, including an optional accelerator. */
|
|
322
|
-
const ResourceProfileSchema$1 = z.strictObject({
|
|
323
|
-
cpu: z.number().finite().positive().optional(),
|
|
324
|
-
memoryMb: z.number().int().positive().optional(),
|
|
325
|
-
diskMb: z.number().int().positive().optional(),
|
|
326
|
-
accelerator: z.strictObject({
|
|
327
|
-
kind: boundedIdentifierSchema,
|
|
328
|
-
count: z.number().int().positive(),
|
|
329
|
-
memoryMb: z.number().int().positive().optional()
|
|
330
|
-
}).optional()
|
|
331
|
-
});
|
|
332
|
-
/** A point-in-time or peak resource sample. */
|
|
333
|
-
const ResourceUseSampleSchema$1 = z.strictObject({
|
|
334
|
-
cpu: nonNegativeNumberSchema$1.optional(),
|
|
335
|
-
memoryMb: nonNegativeNumberSchema$1.optional(),
|
|
336
|
-
diskMb: nonNegativeNumberSchema$1.optional(),
|
|
337
|
-
acceleratorMemoryMb: nonNegativeNumberSchema$1.optional()
|
|
338
|
-
});
|
|
339
|
-
/** Where an environment was requested or verified to run. */
|
|
340
|
-
const PlacementDescriptorSchema$1 = z.strictObject({
|
|
341
|
-
kind: z.enum([
|
|
342
|
-
"local",
|
|
343
|
-
"sandbox",
|
|
344
|
-
"fleet",
|
|
345
|
-
"provider"
|
|
346
|
-
]),
|
|
347
|
-
sandboxId: boundedIdentifierSchema.optional(),
|
|
348
|
-
fleetId: boundedIdentifierSchema.optional(),
|
|
349
|
-
machineId: boundedIdentifierSchema.optional(),
|
|
350
|
-
region: boundedIdentifierSchema.optional()
|
|
351
|
-
});
|
|
352
|
-
/**
|
|
353
|
-
* Token usage and cost for one execution. Bound to the shared {@link TokenUsage}
|
|
354
|
-
* type so a change to the canonical shape is caught here.
|
|
355
|
-
*/
|
|
356
|
-
const ModelUsageSchema$1 = z.strictObject({
|
|
357
|
-
inputTokens: z.number().int().nonnegative(),
|
|
358
|
-
outputTokens: z.number().int().nonnegative(),
|
|
359
|
-
totalTokens: z.number().int().nonnegative().optional(),
|
|
360
|
-
cacheReadInputTokens: z.number().int().nonnegative().optional(),
|
|
361
|
-
cacheCreationInputTokens: z.number().int().nonnegative().optional(),
|
|
362
|
-
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
363
|
-
cost: z.number().finite().nonnegative().optional()
|
|
364
|
-
});
|
|
365
|
-
/** Provider compute cost charged for one environment. */
|
|
366
|
-
const ComputeBillingSchema$1 = z.strictObject({
|
|
367
|
-
amount: nonNegativeNumberSchema$1,
|
|
368
|
-
currency: boundedIdentifierSchema
|
|
369
|
-
});
|
|
370
|
-
/** Account plan, credits, quota, and billing period. */
|
|
371
|
-
const AccountUsageSchema$1 = z.strictObject({
|
|
372
|
-
plan: observationOf$1(boundedIdentifierSchema).optional(),
|
|
373
|
-
credits: observationOf$1(z.strictObject({
|
|
374
|
-
remaining: nonNegativeNumberSchema$1,
|
|
375
|
-
unit: boundedIdentifierSchema
|
|
376
|
-
})).optional(),
|
|
377
|
-
quota: observationOf$1(z.strictObject({
|
|
378
|
-
limit: nonNegativeNumberSchema$1,
|
|
379
|
-
used: nonNegativeNumberSchema$1,
|
|
380
|
-
remaining: nonNegativeNumberSchema$1,
|
|
381
|
-
unit: boundedIdentifierSchema
|
|
382
|
-
})).optional(),
|
|
383
|
-
period: observationOf$1(z.strictObject({
|
|
384
|
-
start: z.iso.datetime().max(64),
|
|
385
|
-
end: z.iso.datetime().max(64)
|
|
386
|
-
})).optional()
|
|
387
|
-
});
|
|
388
|
-
z.strictObject({
|
|
389
|
-
subject: ProviderIdentitySchema$1,
|
|
390
|
-
capturedAt: z.iso.datetime().max(64),
|
|
391
|
-
identity: observationOf$1(ProviderIdentitySchema$1).optional(),
|
|
392
|
-
lifecycle: observationOf$1(EnvironmentLifecycleSchema$1).optional(),
|
|
393
|
-
endpoint: observationOf$1(SafeEndpointSchema$1).optional(),
|
|
394
|
-
placement: z.strictObject({
|
|
395
|
-
requested: PlacementDescriptorSchema$1.optional(),
|
|
396
|
-
verified: observationOf$1(PlacementDescriptorSchema$1).optional()
|
|
397
|
-
}).optional(),
|
|
398
|
-
resources: z.strictObject({
|
|
399
|
-
requested: ResourceProfileSchema$1.optional(),
|
|
400
|
-
effective: observationOf$1(ResourceProfileSchema$1).optional()
|
|
401
|
-
}).optional(),
|
|
402
|
-
resourceUse: z.strictObject({
|
|
403
|
-
current: observationOf$1(ResourceUseSampleSchema$1).optional(),
|
|
404
|
-
peak: observationOf$1(ResourceUseSampleSchema$1).optional()
|
|
405
|
-
}).optional(),
|
|
406
|
-
modelUsage: observationOf$1(ModelUsageSchema$1).optional(),
|
|
407
|
-
computeBilling: observationOf$1(ComputeBillingSchema$1).optional(),
|
|
408
|
-
accountUsage: AccountUsageSchema$1.optional()
|
|
409
|
-
});
|
|
410
|
-
//#endregion
|
|
411
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-fields.js
|
|
412
|
-
/**
|
|
413
|
-
* Field names whose own-key form collides with object internals. A record
|
|
414
|
-
* parser drops a raw `__proto__` key through the legacy prototype setter before
|
|
415
|
-
* a key schema runs, so every schema and validator over interaction data
|
|
416
|
-
* rejects these names against one owner rather than a private copy.
|
|
417
|
-
*/
|
|
418
|
-
const RESERVED_INTERACTION_FIELD_NAMES$1 = new Set([
|
|
419
|
-
"__proto__",
|
|
420
|
-
"constructor",
|
|
421
|
-
"prototype"
|
|
422
|
-
]);
|
|
423
|
-
const InteractionFieldNameSchema$1 = boundedIdentifierSchema.refine((value) => !RESERVED_INTERACTION_FIELD_NAMES$1.has(value), "interaction field name is reserved");
|
|
424
|
-
const FieldBase$1 = {
|
|
425
|
-
/** Stable key the answer is returned under in `InteractionResponse.data`. */
|
|
426
|
-
name: InteractionFieldNameSchema$1,
|
|
427
|
-
/** Human-readable label for the form control. */
|
|
428
|
-
label: boundedStringSchema.min(1),
|
|
429
|
-
/** Whether the answer must supply this field to be `accepted`. */
|
|
430
|
-
required: z.boolean().optional()
|
|
431
|
-
};
|
|
432
|
-
const InteractionFieldSchema$1 = z.discriminatedUnion("type", [
|
|
433
|
-
z.strictObject({
|
|
434
|
-
...FieldBase$1,
|
|
435
|
-
type: z.literal("text"),
|
|
436
|
-
multiline: z.boolean().optional(),
|
|
437
|
-
placeholder: boundedStringSchema.optional(),
|
|
438
|
-
/** Maximum answer length chosen by the request author. */
|
|
439
|
-
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH).optional(),
|
|
440
|
-
default: boundedStringSchema.optional()
|
|
441
|
-
}),
|
|
442
|
-
z.strictObject({
|
|
443
|
-
...FieldBase$1,
|
|
444
|
-
type: z.literal("number"),
|
|
445
|
-
min: z.number().finite().optional(),
|
|
446
|
-
max: z.number().finite().optional(),
|
|
447
|
-
default: z.number().finite().optional()
|
|
448
|
-
}),
|
|
449
|
-
z.strictObject({
|
|
450
|
-
...FieldBase$1,
|
|
451
|
-
type: z.literal("boolean"),
|
|
452
|
-
default: z.boolean().optional()
|
|
453
|
-
}),
|
|
454
|
-
z.strictObject({
|
|
455
|
-
...FieldBase$1,
|
|
456
|
-
type: z.literal("select"),
|
|
457
|
-
options: z.array(z.strictObject({
|
|
458
|
-
value: boundedIdentifierSchema,
|
|
459
|
-
label: boundedStringSchema.min(1),
|
|
460
|
-
description: boundedStringSchema.optional()
|
|
461
|
-
})).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
462
|
-
/** When true the user may pick more than one option. */
|
|
463
|
-
multi: z.boolean().optional(),
|
|
464
|
-
/**
|
|
465
|
-
* When true the answer may contain write-in values outside `options`
|
|
466
|
-
* (e.g. a rendered "Other…" choice carrying the user's own text).
|
|
467
|
-
* Write-ins must still be non-empty strings.
|
|
468
|
-
*/
|
|
469
|
-
allowCustom: z.boolean().optional(),
|
|
470
|
-
default: z.array(boundedIdentifierSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional()
|
|
471
|
-
}),
|
|
472
|
-
z.strictObject({
|
|
473
|
-
...FieldBase$1,
|
|
474
|
-
type: z.literal("secret"),
|
|
475
|
-
placeholder: boundedStringSchema.optional(),
|
|
476
|
-
/** Maximum answer length chosen by the request author. */
|
|
477
|
-
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH).optional()
|
|
478
|
-
})
|
|
479
|
-
]).superRefine((field, context) => {
|
|
480
|
-
if (field.type === "text" && field.default !== void 0 && field.maxLength !== void 0 && field.default.length > field.maxLength) {
|
|
481
|
-
context.addIssue({
|
|
482
|
-
code: "custom",
|
|
483
|
-
path: ["default"],
|
|
484
|
-
message: "text field default exceeds maxLength"
|
|
485
|
-
});
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
if (field.type === "number") {
|
|
489
|
-
if (field.min !== void 0 && field.max !== void 0 && field.min > field.max) context.addIssue({
|
|
490
|
-
code: "custom",
|
|
491
|
-
path: ["max"],
|
|
492
|
-
message: "number field max must be greater than or equal to min"
|
|
493
|
-
});
|
|
494
|
-
if (field.default !== void 0 && field.min !== void 0 && field.default < field.min) context.addIssue({
|
|
495
|
-
code: "custom",
|
|
496
|
-
path: ["default"],
|
|
497
|
-
message: "number field default must be greater than or equal to min"
|
|
498
|
-
});
|
|
499
|
-
if (field.default !== void 0 && field.max !== void 0 && field.default > field.max) context.addIssue({
|
|
500
|
-
code: "custom",
|
|
501
|
-
path: ["default"],
|
|
502
|
-
message: "number field default must be less than or equal to max"
|
|
503
|
-
});
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
if (field.type !== "select") return;
|
|
507
|
-
const optionValues = field.options.map((option) => option.value);
|
|
508
|
-
if (new Set(optionValues).size !== optionValues.length) context.addIssue({
|
|
509
|
-
code: "custom",
|
|
510
|
-
path: ["options"],
|
|
511
|
-
message: "select option values must be unique"
|
|
512
|
-
});
|
|
513
|
-
if (field.default === void 0) return;
|
|
514
|
-
if (new Set(field.default).size !== field.default.length) context.addIssue({
|
|
515
|
-
code: "custom",
|
|
516
|
-
path: ["default"],
|
|
517
|
-
message: "select default values must be unique"
|
|
518
|
-
});
|
|
519
|
-
if (!field.multi && field.default.length > 1) context.addIssue({
|
|
520
|
-
code: "custom",
|
|
521
|
-
path: ["default"],
|
|
522
|
-
message: "single-select default may contain at most one value"
|
|
523
|
-
});
|
|
524
|
-
if (field.required && field.default.length === 0) context.addIssue({
|
|
525
|
-
code: "custom",
|
|
526
|
-
path: ["default"],
|
|
527
|
-
message: "required select default must contain a value"
|
|
528
|
-
});
|
|
529
|
-
const allowed = new Set(optionValues);
|
|
530
|
-
for (const value of field.default) {
|
|
531
|
-
if (allowed.has(value)) continue;
|
|
532
|
-
if (field.allowCustom === true && value.trim().length > 0) continue;
|
|
533
|
-
context.addIssue({
|
|
534
|
-
code: "custom",
|
|
535
|
-
path: ["default"],
|
|
536
|
-
message: `select default contains unknown option "${value}"`
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
const InteractionAnswerSpecSchema$1 = z.strictObject({ fields: z.array(InteractionFieldSchema$1).max(CONTRACT_MAX_ARRAY_LENGTH) }).superRefine((spec, context) => {
|
|
541
|
-
const names = spec.fields.map((field) => field.name);
|
|
542
|
-
if (new Set(names).size !== names.length) context.addIssue({
|
|
543
|
-
code: "custom",
|
|
544
|
-
path: ["fields"],
|
|
545
|
-
message: "interaction field names must be unique"
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
const InteractionFieldTypeSchema$1 = z.enum([
|
|
549
|
-
"text",
|
|
550
|
-
"number",
|
|
551
|
-
"boolean",
|
|
552
|
-
"select",
|
|
553
|
-
"secret"
|
|
554
|
-
]);
|
|
555
|
-
/** Scope at which an accepted answer may be reused by an explicit policy. */
|
|
556
|
-
const InteractionResponseScopeSchema$1 = z.enum([
|
|
557
|
-
"interaction",
|
|
558
|
-
"session",
|
|
559
|
-
"persistent"
|
|
560
|
-
]);
|
|
561
|
-
z.strictObject({
|
|
562
|
-
kinds: z.array(boundedIdentifierSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
563
|
-
answerFieldTypes: z.array(InteractionFieldTypeSchema$1).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
564
|
-
responseScopes: z.array(InteractionResponseScopeSchema$1).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
565
|
-
secretAnswers: z.boolean(),
|
|
566
|
-
concurrentRequests: z.boolean(),
|
|
567
|
-
replay: z.boolean(),
|
|
568
|
-
responseIdempotency: z.boolean()
|
|
569
|
-
}).superRefine((capabilities, context) => {
|
|
570
|
-
if (capabilities.answerFieldTypes.includes("secret") !== capabilities.secretAnswers) context.addIssue({
|
|
571
|
-
code: "custom",
|
|
572
|
-
path: ["secretAnswers"],
|
|
573
|
-
message: "secretAnswers must agree with the secret answer field capability"
|
|
574
|
-
});
|
|
575
|
-
if (new Set(capabilities.kinds).size !== capabilities.kinds.length) context.addIssue({
|
|
576
|
-
code: "custom",
|
|
577
|
-
path: ["kinds"],
|
|
578
|
-
message: "interaction kinds must be unique"
|
|
579
|
-
});
|
|
580
|
-
if (new Set(capabilities.answerFieldTypes).size !== capabilities.answerFieldTypes.length) context.addIssue({
|
|
581
|
-
code: "custom",
|
|
582
|
-
path: ["answerFieldTypes"],
|
|
583
|
-
message: "interaction answer field types must be unique"
|
|
584
|
-
});
|
|
585
|
-
if (new Set(capabilities.responseScopes).size !== capabilities.responseScopes.length) context.addIssue({
|
|
586
|
-
code: "custom",
|
|
587
|
-
path: ["responseScopes"],
|
|
588
|
-
message: "interaction response scopes must be unique"
|
|
589
|
-
});
|
|
590
|
-
});
|
|
591
|
-
//#endregion
|
|
592
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-data.js
|
|
593
|
-
const InteractionSecretReferenceSchema$1 = z.strictObject({
|
|
594
|
-
kind: z.literal("secret_handle"),
|
|
595
|
-
handleId: boundedIdentifierSchema,
|
|
596
|
-
oneUse: z.literal(true)
|
|
597
|
-
});
|
|
598
|
-
const InteractionDataValueSchema$1 = z.union([
|
|
599
|
-
boundedStringSchema,
|
|
600
|
-
z.number().finite(),
|
|
601
|
-
z.boolean(),
|
|
602
|
-
z.array(boundedStringSchema).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
603
|
-
InteractionSecretReferenceSchema$1
|
|
604
|
-
]);
|
|
605
|
-
/** Field values keyed by InteractionField.name. */
|
|
606
|
-
const InteractionDataSchema$1 = z.unknown().superRefine((value, refinement) => {
|
|
607
|
-
if (value === null || typeof value !== "object") return;
|
|
608
|
-
for (const key of Object.getOwnPropertyNames(value)) if (RESERVED_INTERACTION_FIELD_NAMES$1.has(key)) refinement.addIssue({
|
|
609
|
-
code: "custom",
|
|
610
|
-
message: `interaction field name "${key}" is reserved`
|
|
611
|
-
});
|
|
612
|
-
}).pipe(z.record(InteractionFieldNameSchema$1, InteractionDataValueSchema$1).superRefine((data, refinement) => {
|
|
613
|
-
if (Object.keys(data).length > 256) refinement.addIssue({
|
|
614
|
-
code: "custom",
|
|
615
|
-
message: "interaction data has too many fields"
|
|
616
|
-
});
|
|
617
|
-
})).transform((data) => {
|
|
618
|
-
const safe = Object.create(null);
|
|
619
|
-
for (const key of Object.keys(data)) safe[key] = data[key];
|
|
620
|
-
return safe;
|
|
621
|
-
});
|
|
622
|
-
const InteractionResolutionSchema$1 = z.discriminatedUnion("outcome", [
|
|
623
|
-
z.strictObject({
|
|
624
|
-
outcome: z.literal("accepted"),
|
|
625
|
-
data: InteractionDataSchema$1.optional()
|
|
626
|
-
}),
|
|
627
|
-
z.strictObject({
|
|
628
|
-
outcome: z.literal("declined"),
|
|
629
|
-
data: InteractionDataSchema$1.optional()
|
|
630
|
-
}),
|
|
631
|
-
z.strictObject({
|
|
632
|
-
outcome: z.literal("cancelled"),
|
|
633
|
-
data: InteractionDataSchema$1.optional()
|
|
634
|
-
})
|
|
635
|
-
]);
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-permissions.js
|
|
638
|
-
const InteractionKind$1 = {
|
|
639
|
-
/** Agent asks the user to answer/choose. Answer = the chosen field values. */
|
|
640
|
-
Question: "question",
|
|
641
|
-
/** Agent requests approval to run a tool/command. Answer = a `PermissionGrant`. */
|
|
642
|
-
Permission: "permission",
|
|
643
|
-
/** Agent shares a plan/todo list for review/approval. */
|
|
644
|
-
Plan: "plan"
|
|
645
|
-
};
|
|
646
|
-
const wellKnownInteractionKinds$1 = new Set(Object.values(InteractionKind$1));
|
|
647
|
-
const requestedInteractionKindSchema$1 = boundedIdentifierSchema.refine((value) => wellKnownInteractionKinds$1.has(value) || value.includes(".") && !value.startsWith(".") && !value.endsWith(".") && !value.includes(".."), "custom interaction kind must be namespaced");
|
|
648
|
-
z.record(requestedInteractionKindSchema$1, z.boolean()).superRefine((value, context) => {
|
|
649
|
-
if (Object.keys(value).length > 256) context.addIssue({
|
|
650
|
-
code: z.ZodIssueCode.custom,
|
|
651
|
-
message: `interaction posture exceeds 256 kinds`
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
/** Field name carrying the grant on a `permission` interaction's response. */
|
|
655
|
-
const PERMISSION_GRANT_FIELD$1 = "grant";
|
|
656
|
-
/** Graduated permission decision — the value of the `grant` field. */
|
|
657
|
-
const PermissionGrantSchema$1 = z.enum([
|
|
658
|
-
"allow_once",
|
|
659
|
-
"allow_session",
|
|
660
|
-
"allow_always",
|
|
661
|
-
"deny"
|
|
662
|
-
]);
|
|
663
|
-
//#endregion
|
|
664
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-answer-validation.js
|
|
665
|
-
/**
|
|
666
|
-
* Validate an accepted answer against its spec. Used by the broker before a
|
|
667
|
-
* response reaches the adapter, so malformed answers are rejected centrally.
|
|
668
|
-
*/
|
|
669
|
-
function validateInteractionAnswer$1(spec, data) {
|
|
670
|
-
const errors = [];
|
|
671
|
-
const parsedSpec = InteractionAnswerSpecSchema$1.safeParse(spec);
|
|
672
|
-
if (!parsedSpec.success) return {
|
|
673
|
-
ok: false,
|
|
674
|
-
errors: parsedSpec.error.issues.map((issue) => issue.message)
|
|
675
|
-
};
|
|
676
|
-
if (data !== void 0 && (!data || typeof data !== "object" || Array.isArray(data))) return {
|
|
677
|
-
ok: false,
|
|
678
|
-
errors: ["interaction data must be an object"]
|
|
679
|
-
};
|
|
680
|
-
const d = data ?? Object.create(null);
|
|
681
|
-
const prototype = Object.getPrototypeOf(d);
|
|
682
|
-
if (prototype !== Object.prototype && prototype !== null) return {
|
|
683
|
-
ok: false,
|
|
684
|
-
errors: ["interaction data must be a plain object"]
|
|
685
|
-
};
|
|
686
|
-
if (Object.keys(d).length > 256) return {
|
|
687
|
-
ok: false,
|
|
688
|
-
errors: ["interaction data has too many fields"]
|
|
689
|
-
};
|
|
690
|
-
const exactSpec = parsedSpec.data;
|
|
691
|
-
const knownFields = new Set(exactSpec.fields.map((field) => field.name));
|
|
692
|
-
for (const fieldName of Object.keys(d)) {
|
|
693
|
-
if (fieldName.length > 512) {
|
|
694
|
-
errors.push(`unknown field "${fieldName}"`);
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
const rawValue = d[fieldName];
|
|
698
|
-
if (typeof rawValue === "string" && rawValue.length > 16384) errors.push(`field "${fieldName}" exceeds the contract string bound`);
|
|
699
|
-
else if (Array.isArray(rawValue)) {
|
|
700
|
-
if (rawValue.length > 1024) errors.push(`field "${fieldName}" has too many values`);
|
|
701
|
-
for (const entry of rawValue) if (typeof entry !== "string" || entry.length > 16384) {
|
|
702
|
-
errors.push(`field "${fieldName}" contains an invalid bounded value`);
|
|
703
|
-
break;
|
|
704
|
-
}
|
|
705
|
-
} else if (rawValue && typeof rawValue === "object") {
|
|
706
|
-
const valuePrototype = Object.getPrototypeOf(rawValue);
|
|
707
|
-
if (valuePrototype !== Object.prototype && valuePrototype !== null || Object.keys(rawValue).length > 3) errors.push(`field "${fieldName}" contains an invalid object value`);
|
|
708
|
-
}
|
|
709
|
-
if (!knownFields.has(fieldName)) errors.push(`unknown field "${fieldName}"`);
|
|
710
|
-
}
|
|
711
|
-
for (const field of exactSpec.fields) {
|
|
712
|
-
const hasValue = Object.hasOwn(d, field.name);
|
|
713
|
-
const v = hasValue ? d[field.name] : void 0;
|
|
714
|
-
if (!(hasValue && v !== void 0 && v !== null && !(typeof v === "string" && v === ""))) {
|
|
715
|
-
if (field.required) errors.push(`missing required field "${field.name}"`);
|
|
716
|
-
continue;
|
|
717
|
-
}
|
|
718
|
-
switch (field.type) {
|
|
719
|
-
case "text":
|
|
720
|
-
if (typeof v !== "string") errors.push(`field "${field.name}" must be a string`);
|
|
721
|
-
else if (field.maxLength !== void 0 && v.length > field.maxLength) errors.push(`field "${field.name}" exceeds maxLength ${field.maxLength}`);
|
|
722
|
-
break;
|
|
723
|
-
case "secret": {
|
|
724
|
-
const isHandle = typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 3 && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null) && Object.hasOwn(v, "kind") && Object.hasOwn(v, "handleId") && Object.hasOwn(v, "oneUse") && v.kind === "secret_handle" && v.oneUse === true && boundedIdentifierSchema.safeParse(v.handleId).success;
|
|
725
|
-
if (typeof v !== "string" && !isHandle) errors.push(`field "${field.name}" must be a string or one-use secret handle`);
|
|
726
|
-
else if (typeof v === "string" && field.maxLength !== void 0 && v.length > field.maxLength) errors.push(`field "${field.name}" exceeds maxLength ${field.maxLength}`);
|
|
727
|
-
break;
|
|
728
|
-
}
|
|
729
|
-
case "number":
|
|
730
|
-
if (typeof v !== "number" || !Number.isFinite(v)) errors.push(`field "${field.name}" must be a finite number`);
|
|
731
|
-
else {
|
|
732
|
-
if (field.min !== void 0 && v < field.min) errors.push(`field "${field.name}" below min ${field.min}`);
|
|
733
|
-
if (field.max !== void 0 && v > field.max) errors.push(`field "${field.name}" above max ${field.max}`);
|
|
734
|
-
}
|
|
735
|
-
break;
|
|
736
|
-
case "boolean":
|
|
737
|
-
if (typeof v !== "boolean") errors.push(`field "${field.name}" must be a boolean`);
|
|
738
|
-
break;
|
|
739
|
-
case "select": {
|
|
740
|
-
if (!Array.isArray(v)) {
|
|
741
|
-
errors.push(`field "${field.name}" must be an array of option values`);
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
744
|
-
if (v.length > 1024) {
|
|
745
|
-
errors.push(`field "${field.name}" has too many option values`);
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
if (!field.multi && v.length > 1) errors.push(`field "${field.name}" accepts a single value`);
|
|
749
|
-
if (field.required && v.length === 0) errors.push(`field "${field.name}" requires a selection`);
|
|
750
|
-
const allowed = new Set(field.options.map((o) => o.value));
|
|
751
|
-
for (const choice of v) {
|
|
752
|
-
if (allowed.has(choice)) continue;
|
|
753
|
-
if (field.allowCustom === true) {
|
|
754
|
-
if (typeof choice !== "string" || choice.trim() === "") errors.push(`field "${field.name}" has blank write-in value`);
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
errors.push(`field "${field.name}" has invalid option "${choice}"`);
|
|
758
|
-
}
|
|
759
|
-
break;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
return errors.length === 0 ? { ok: true } : {
|
|
764
|
-
ok: false,
|
|
765
|
-
errors
|
|
766
|
-
};
|
|
767
|
-
}
|
|
768
|
-
//#endregion
|
|
769
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-resolution-validation.js
|
|
770
|
-
/**
|
|
771
|
-
* A declined or cancelled resolution submits no answer, so any secret-typed
|
|
772
|
-
* field it carries can only be leakage into a transport that retains it.
|
|
773
|
-
*/
|
|
774
|
-
function secretFieldErrors$1(spec, resolution) {
|
|
775
|
-
const secretFields = new Set(spec.fields.filter((field) => field.type === "secret").map((field) => field.name));
|
|
776
|
-
return Object.keys(resolution.data ?? {}).filter((fieldName) => secretFields.has(fieldName)).map((fieldName) => `field "${fieldName}" is secret and cannot ride a ${resolution.outcome} resolution`);
|
|
777
|
-
}
|
|
778
|
-
function validateResolutionForRequest$1(request, resolution) {
|
|
779
|
-
if (resolution.outcome !== "accepted") {
|
|
780
|
-
const errors = secretFieldErrors$1(request.answerSpec, resolution);
|
|
781
|
-
if (Object.keys(resolution.data ?? {}).length > 0) errors.push(`a ${resolution.outcome} resolution cannot carry answer fields`);
|
|
782
|
-
return errors;
|
|
783
|
-
}
|
|
784
|
-
const validation = validateInteractionAnswer$1(request.answerSpec, resolution.data);
|
|
785
|
-
const errors = validation.ok ? [] : [...validation.errors];
|
|
786
|
-
if (request.kind !== InteractionKind$1.Permission) return errors;
|
|
787
|
-
const grant = resolution.data?.[PERMISSION_GRANT_FIELD$1];
|
|
788
|
-
if (!Array.isArray(grant) || grant.length !== 1) {
|
|
789
|
-
errors.push("permission response must select exactly one \"grant\" value");
|
|
790
|
-
return errors;
|
|
791
|
-
}
|
|
792
|
-
const parsedGrant = PermissionGrantSchema$1.safeParse(grant[0]);
|
|
793
|
-
if (!parsedGrant.success) {
|
|
794
|
-
errors.push(`permission response has invalid grant "${String(grant[0])}"`);
|
|
795
|
-
return errors;
|
|
796
|
-
}
|
|
797
|
-
if (parsedGrant.data === "deny") return errors;
|
|
798
|
-
if (!new Set(request.responseScopes ?? ["interaction"]).has({
|
|
799
|
-
allow_once: "interaction",
|
|
800
|
-
allow_session: "session",
|
|
801
|
-
allow_always: "persistent",
|
|
802
|
-
deny: "interaction"
|
|
803
|
-
}[parsedGrant.data])) errors.push(`permission grant "${parsedGrant.data}" exceeds the request's response scopes`);
|
|
804
|
-
return errors;
|
|
805
|
-
}
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/interaction-envelope.js
|
|
808
|
-
const interactionOutcomeValues$1 = [
|
|
809
|
-
"accepted",
|
|
810
|
-
"declined",
|
|
811
|
-
"cancelled"
|
|
812
|
-
];
|
|
813
|
-
const InteractionSubjectSchema$1 = z.discriminatedUnion("type", [
|
|
814
|
-
z.strictObject({
|
|
815
|
-
type: z.literal("tool"),
|
|
816
|
-
toolName: boundedIdentifierSchema,
|
|
817
|
-
input: boundedJsonSchema.optional()
|
|
818
|
-
}),
|
|
819
|
-
z.strictObject({
|
|
820
|
-
type: z.literal("command"),
|
|
821
|
-
command: boundedStringSchema
|
|
822
|
-
}),
|
|
823
|
-
z.strictObject({
|
|
824
|
-
type: z.literal("file"),
|
|
825
|
-
path: boundedStringSchema,
|
|
826
|
-
preview: boundedStringSchema.optional()
|
|
827
|
-
}),
|
|
828
|
-
z.strictObject({
|
|
829
|
-
type: z.literal("resource"),
|
|
830
|
-
uri: boundedStringSchema
|
|
831
|
-
})
|
|
832
|
-
]);
|
|
833
|
-
const InteractionOutcomeSchema$1 = z.enum(interactionOutcomeValues$1);
|
|
834
|
-
const InteractionRequestBindingSchema$1 = z.strictObject({
|
|
835
|
-
runId: boundedIdentifierSchema,
|
|
836
|
-
provider: boundedIdentifierSchema,
|
|
837
|
-
environmentId: boundedIdentifierSchema,
|
|
838
|
-
sessionId: boundedIdentifierSchema,
|
|
839
|
-
executionId: boundedIdentifierSchema,
|
|
840
|
-
interactionId: boundedIdentifierSchema
|
|
841
|
-
});
|
|
842
|
-
InteractionRequestBindingSchema$1.omit({ interactionId: true });
|
|
843
|
-
/** Binding carried by a response command and acknowledgement. */
|
|
844
|
-
const InteractionBindingSchema$1 = z.strictObject({
|
|
845
|
-
...InteractionRequestBindingSchema$1.shape,
|
|
846
|
-
requestDigest: sha256DigestSchema
|
|
847
|
-
});
|
|
848
|
-
const InteractionRequestMaterialSchema$1 = z.strictObject({
|
|
849
|
-
id: boundedIdentifierSchema,
|
|
850
|
-
kind: boundedIdentifierSchema,
|
|
851
|
-
title: boundedStringSchema.min(1),
|
|
852
|
-
body: boundedStringSchema.optional(),
|
|
853
|
-
subject: InteractionSubjectSchema$1.optional(),
|
|
854
|
-
answerSpec: InteractionAnswerSpecSchema$1,
|
|
855
|
-
responseScopes: z.array(InteractionResponseScopeSchema$1).min(1).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
856
|
-
allowedOutcomes: z.array(InteractionOutcomeSchema$1).min(1).max(interactionOutcomeValues$1.length).optional(),
|
|
857
|
-
default: InteractionResolutionSchema$1.optional(),
|
|
858
|
-
timeoutMs: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
859
|
-
onTimeout: z.enum([
|
|
860
|
-
"default",
|
|
861
|
-
"fail",
|
|
862
|
-
"wait"
|
|
863
|
-
]).optional(),
|
|
864
|
-
binding: InteractionRequestBindingSchema$1
|
|
865
|
-
});
|
|
866
|
-
function interactionRequestDigest$1(request) {
|
|
867
|
-
const parsed = InteractionRequestMaterialSchema$1.parse(request);
|
|
868
|
-
rejectSecretDefaultValues$1(parsed);
|
|
869
|
-
return canonicalCandidateDigest(parsed);
|
|
870
|
-
}
|
|
871
|
-
function rejectSecretDefaultValues$1(request) {
|
|
872
|
-
const secretFields = new Set(request.answerSpec.fields.filter((field) => field.type === "secret").map((field) => field.name));
|
|
873
|
-
for (const fieldName of Object.keys(request.default?.data ?? {})) if (secretFields.has(fieldName)) throw new Error("secret answers cannot be embedded in interaction defaults");
|
|
874
|
-
}
|
|
875
|
-
const InteractionRequestSchema$1 = z.strictObject({
|
|
876
|
-
...InteractionRequestMaterialSchema$1.shape,
|
|
877
|
-
requestDigest: sha256DigestSchema
|
|
878
|
-
}).superRefine((request, context) => {
|
|
879
|
-
if (request.binding.interactionId !== request.id) context.addIssue({
|
|
880
|
-
code: "custom",
|
|
881
|
-
path: ["binding", "interactionId"],
|
|
882
|
-
message: "interaction binding must name the request id"
|
|
883
|
-
});
|
|
884
|
-
if (request.responseScopes && new Set(request.responseScopes).size !== request.responseScopes.length) context.addIssue({
|
|
885
|
-
code: "custom",
|
|
886
|
-
path: ["responseScopes"],
|
|
887
|
-
message: "interaction response scopes must be unique"
|
|
888
|
-
});
|
|
889
|
-
if (request.allowedOutcomes && new Set(request.allowedOutcomes).size !== request.allowedOutcomes.length) context.addIssue({
|
|
890
|
-
code: "custom",
|
|
891
|
-
path: ["allowedOutcomes"],
|
|
892
|
-
message: "interaction outcomes must be unique"
|
|
893
|
-
});
|
|
894
|
-
if (request.onTimeout === "default" && request.default === void 0) context.addIssue({
|
|
895
|
-
code: "custom",
|
|
896
|
-
path: ["default"],
|
|
897
|
-
message: "onTimeout=default requires a default resolution"
|
|
898
|
-
});
|
|
899
|
-
if (request.default && request.allowedOutcomes && !request.allowedOutcomes.includes(request.default.outcome)) context.addIssue({
|
|
900
|
-
code: "custom",
|
|
901
|
-
path: ["default", "outcome"],
|
|
902
|
-
message: "default outcome is not allowed by the request"
|
|
903
|
-
});
|
|
904
|
-
if (request.default) {
|
|
905
|
-
for (const error of validateResolutionForRequest$1(request, request.default)) context.addIssue({
|
|
906
|
-
code: "custom",
|
|
907
|
-
path: ["default"],
|
|
908
|
-
message: error
|
|
909
|
-
});
|
|
910
|
-
const secretFields = new Set(request.answerSpec.fields.filter((field) => field.type === "secret").map((field) => field.name));
|
|
911
|
-
for (const fieldName of Object.keys(request.default.data ?? {})) {
|
|
912
|
-
if (!secretFields.has(fieldName)) continue;
|
|
913
|
-
context.addIssue({
|
|
914
|
-
code: "custom",
|
|
915
|
-
path: [
|
|
916
|
-
"default",
|
|
917
|
-
"data",
|
|
918
|
-
fieldName
|
|
919
|
-
],
|
|
920
|
-
message: "secret answers cannot be embedded in interaction defaults"
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
const { requestDigest: _digest, ...material } = request;
|
|
925
|
-
if (!Object.keys(request.default?.data ?? {}).some((fieldName) => request.answerSpec.fields.some((field) => field.type === "secret" && field.name === fieldName))) {
|
|
926
|
-
if (request.requestDigest !== interactionRequestDigest$1(material)) context.addIssue({
|
|
927
|
-
code: "custom",
|
|
928
|
-
path: ["requestDigest"],
|
|
929
|
-
message: "interaction request digest does not match its content"
|
|
930
|
-
});
|
|
931
|
-
}
|
|
932
|
-
});
|
|
933
|
-
const InteractionResponseSchema$1 = z.discriminatedUnion("outcome", [
|
|
934
|
-
z.strictObject({
|
|
935
|
-
id: boundedIdentifierSchema,
|
|
936
|
-
outcome: z.literal("accepted"),
|
|
937
|
-
data: InteractionDataSchema$1.optional()
|
|
938
|
-
}),
|
|
939
|
-
z.strictObject({
|
|
940
|
-
id: boundedIdentifierSchema,
|
|
941
|
-
outcome: z.literal("declined"),
|
|
942
|
-
data: InteractionDataSchema$1.optional()
|
|
943
|
-
}),
|
|
944
|
-
z.strictObject({
|
|
945
|
-
id: boundedIdentifierSchema,
|
|
946
|
-
outcome: z.literal("cancelled"),
|
|
947
|
-
data: InteractionDataSchema$1.optional()
|
|
948
|
-
})
|
|
949
|
-
]);
|
|
950
|
-
/** Digest the exact binding and response carried by a retryable command. */
|
|
951
|
-
function interactionResponseCommandDigest$1(material) {
|
|
952
|
-
return canonicalCandidateDigest({
|
|
953
|
-
binding: InteractionBindingSchema$1.parse(material.binding),
|
|
954
|
-
response: InteractionResponseSchema$1.parse(material.response)
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
z.strictObject({
|
|
958
|
-
operationId: boundedIdentifierSchema,
|
|
959
|
-
binding: InteractionBindingSchema$1,
|
|
960
|
-
commandDigest: sha256DigestSchema,
|
|
961
|
-
response: InteractionResponseSchema$1
|
|
962
|
-
}).superRefine((command, context) => {
|
|
963
|
-
if (command.binding.interactionId !== command.response.id) context.addIssue({
|
|
964
|
-
code: "custom",
|
|
965
|
-
path: ["response", "id"],
|
|
966
|
-
message: "response id must match the bound interaction id"
|
|
967
|
-
});
|
|
968
|
-
if (command.commandDigest !== interactionResponseCommandDigest$1({
|
|
969
|
-
binding: command.binding,
|
|
970
|
-
response: command.response
|
|
971
|
-
})) context.addIssue({
|
|
972
|
-
code: "custom",
|
|
973
|
-
path: ["commandDigest"],
|
|
974
|
-
message: "interaction response command digest does not match its content"
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
const InteractionAcknowledgementStatusSchema$1 = z.enum([
|
|
978
|
-
"accepted",
|
|
979
|
-
"already_resolved_same",
|
|
980
|
-
"already_resolved_different",
|
|
981
|
-
"expired",
|
|
982
|
-
"cancelled",
|
|
983
|
-
"unknown_interaction",
|
|
984
|
-
"unknown_run",
|
|
985
|
-
"binding_mismatch",
|
|
986
|
-
"invalid_response",
|
|
987
|
-
"transport_failure"
|
|
988
|
-
]);
|
|
989
|
-
z.strictObject({
|
|
990
|
-
operationId: boundedIdentifierSchema,
|
|
991
|
-
binding: InteractionBindingSchema$1,
|
|
992
|
-
commandDigest: sha256DigestSchema,
|
|
993
|
-
status: InteractionAcknowledgementStatusSchema$1,
|
|
994
|
-
message: boundedStringSchema.min(1).optional(),
|
|
995
|
-
retryable: z.boolean().optional()
|
|
996
|
-
}).superRefine((acknowledgement, context) => {
|
|
997
|
-
if (["invalid_response", "transport_failure"].includes(acknowledgement.status) && acknowledgement.message === void 0) context.addIssue({
|
|
998
|
-
code: "custom",
|
|
999
|
-
path: ["message"],
|
|
1000
|
-
message: `${acknowledgement.status} must include a message`
|
|
1001
|
-
});
|
|
1002
|
-
if (acknowledgement.status === "transport_failure" && acknowledgement.retryable === void 0) context.addIssue({
|
|
1003
|
-
code: "custom",
|
|
1004
|
-
path: ["retryable"],
|
|
1005
|
-
message: "transport_failure must state whether retry is safe"
|
|
1006
|
-
});
|
|
1007
|
-
});
|
|
1008
|
-
//#endregion
|
|
1009
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/plan.js
|
|
1010
|
-
/**
|
|
1011
|
-
* Credential-free provider correlation committed with the plan. This union is
|
|
1012
|
-
* deliberately closed: adding plan support for another harness requires an
|
|
1013
|
-
* explicit resume contract instead of smuggling opaque metadata through.
|
|
1014
|
-
*/
|
|
1015
|
-
const PlanProviderStateSchema$1 = z.discriminatedUnion("kind", [
|
|
1016
|
-
z.object({
|
|
1017
|
-
kind: z.literal("claude-code"),
|
|
1018
|
-
version: z.literal(1),
|
|
1019
|
-
nativeSessionId: z.string().min(1)
|
|
1020
|
-
}).strict(),
|
|
1021
|
-
z.object({
|
|
1022
|
-
kind: z.literal("codex"),
|
|
1023
|
-
version: z.literal(1),
|
|
1024
|
-
threadId: z.string().min(1)
|
|
1025
|
-
}).strict(),
|
|
1026
|
-
z.object({
|
|
1027
|
-
kind: z.literal("opencode"),
|
|
1028
|
-
version: z.literal(1)
|
|
1029
|
-
}).strict()
|
|
1030
|
-
]);
|
|
1031
|
-
/**
|
|
1032
|
-
* A plan committed by the runtime before the planning turn is allowed to end.
|
|
1033
|
-
* The full body is part of the contract so consumers never reconstruct it from
|
|
1034
|
-
* rendered chat text.
|
|
1035
|
-
*/
|
|
1036
|
-
const DurablePlanSchema$1 = z.object({
|
|
1037
|
-
id: z.string().min(1),
|
|
1038
|
-
revision: z.number().int().positive(),
|
|
1039
|
-
title: z.string().trim().min(1).optional(),
|
|
1040
|
-
body: z.string().trim().min(1),
|
|
1041
|
-
submittedAt: z.string().datetime({ offset: true })
|
|
1042
|
-
}).strict();
|
|
1043
|
-
z.object({
|
|
1044
|
-
title: z.string().trim().min(1).optional(),
|
|
1045
|
-
body: z.string().trim().min(1),
|
|
1046
|
-
/** Stable provider tool-call identity reused when a lost acknowledgement retries. */
|
|
1047
|
-
sourceToolCallId: z.string().min(1),
|
|
1048
|
-
/** Credential-free correlation required to resume the deferred turn. */
|
|
1049
|
-
providerState: PlanProviderStateSchema$1
|
|
1050
|
-
}).strict();
|
|
1051
|
-
/** The human verdict that starts the next turn. */
|
|
1052
|
-
const PlanDecisionSchema$1 = z.discriminatedUnion("outcome", [z.object({ outcome: z.literal("approved") }).strict(), z.object({
|
|
1053
|
-
outcome: z.literal("rejected"),
|
|
1054
|
-
feedback: z.string().trim().min(1)
|
|
1055
|
-
}).strict()]);
|
|
1056
|
-
z.object({
|
|
1057
|
-
version: z.literal(1),
|
|
1058
|
-
plan: DurablePlanSchema$1,
|
|
1059
|
-
sourceToolCallId: z.string().min(1),
|
|
1060
|
-
decision: PlanDecisionSchema$1,
|
|
1061
|
-
/** Exact payload previously committed with the plan submission. */
|
|
1062
|
-
providerState: PlanProviderStateSchema$1
|
|
1063
|
-
}).strict();
|
|
1064
|
-
z.discriminatedUnion("type", [z.object({ type: z.literal("completed") }).strict(), z.object({
|
|
1065
|
-
type: z.literal("awaiting_plan_decision"),
|
|
1066
|
-
plan: DurablePlanSchema$1
|
|
1067
|
-
}).strict()]);
|
|
1068
|
-
//#endregion
|
|
1069
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/runtime-control.js
|
|
1070
|
-
const stableIdSchema$1 = boundedIdentifierSchema;
|
|
1071
|
-
const AgentExactRunControlRefSchema$1 = z.strictObject({
|
|
1072
|
-
runId: stableIdSchema$1,
|
|
1073
|
-
provider: stableIdSchema$1,
|
|
1074
|
-
environmentId: stableIdSchema$1,
|
|
1075
|
-
sessionId: stableIdSchema$1.optional(),
|
|
1076
|
-
executionId: stableIdSchema$1.optional(),
|
|
1077
|
-
requestDigest: sha256DigestSchema.optional()
|
|
1078
|
-
}).extend({
|
|
1079
|
-
sessionId: stableIdSchema$1,
|
|
1080
|
-
executionId: stableIdSchema$1,
|
|
1081
|
-
requestDigest: sha256DigestSchema
|
|
1082
|
-
});
|
|
1083
|
-
function agentRunCancellationRequestDigest$1(request) {
|
|
1084
|
-
const parsed = AgentRunCancellationRequestMaterialSchema$1.parse(request);
|
|
1085
|
-
return canonicalCandidateDigest({
|
|
1086
|
-
operationId: parsed.operationId,
|
|
1087
|
-
run: parsed.run,
|
|
1088
|
-
...parsed.reason === void 0 ? {} : { reason: parsed.reason }
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
const AgentRunCancellationRequestMaterialSchema$1 = z.strictObject({
|
|
1092
|
-
operationId: stableIdSchema$1,
|
|
1093
|
-
run: AgentExactRunControlRefSchema$1,
|
|
1094
|
-
reason: boundedStringSchema.min(1).max(2048).optional()
|
|
1095
|
-
});
|
|
1096
|
-
z.strictObject({
|
|
1097
|
-
...AgentRunCancellationRequestMaterialSchema$1.shape,
|
|
1098
|
-
requestDigest: sha256DigestSchema
|
|
1099
|
-
}).superRefine((request, refinement) => {
|
|
1100
|
-
const { requestDigest: _requestDigest, ...material } = request;
|
|
1101
|
-
if (request.requestDigest !== agentRunCancellationRequestDigest$1(material)) refinement.addIssue({
|
|
1102
|
-
code: "custom",
|
|
1103
|
-
path: ["requestDigest"],
|
|
1104
|
-
message: "run cancellation request digest does not match its content"
|
|
1105
|
-
});
|
|
1106
|
-
});
|
|
1107
|
-
z.strictObject({
|
|
1108
|
-
operationId: stableIdSchema$1,
|
|
1109
|
-
requestDigest: sha256DigestSchema,
|
|
1110
|
-
run: AgentExactRunControlRefSchema$1,
|
|
1111
|
-
status: z.enum([
|
|
1112
|
-
"accepted",
|
|
1113
|
-
"replayed",
|
|
1114
|
-
"conflict",
|
|
1115
|
-
"unknown"
|
|
1116
|
-
]),
|
|
1117
|
-
effect: z.enum([
|
|
1118
|
-
"cancel_requested",
|
|
1119
|
-
"cancelled",
|
|
1120
|
-
"not_live",
|
|
1121
|
-
"unknown"
|
|
1122
|
-
]),
|
|
1123
|
-
message: boundedStringSchema.min(1).optional(),
|
|
1124
|
-
retryable: z.boolean().optional(),
|
|
1125
|
-
existingRequestDigest: sha256DigestSchema.optional()
|
|
1126
|
-
}).superRefine((acknowledgement, refinement) => {
|
|
1127
|
-
const known = acknowledgement.effect !== "unknown";
|
|
1128
|
-
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && !known || (acknowledgement.status === "conflict" || acknowledgement.status === "unknown") && known) refinement.addIssue({
|
|
1129
|
-
code: "custom",
|
|
1130
|
-
path: ["effect"],
|
|
1131
|
-
message: "cancellation status and effect certainty do not agree"
|
|
1132
|
-
});
|
|
1133
|
-
if (acknowledgement.status === "conflict" && acknowledgement.existingRequestDigest === void 0) refinement.addIssue({
|
|
1134
|
-
code: "custom",
|
|
1135
|
-
path: ["existingRequestDigest"],
|
|
1136
|
-
message: "a cancellation conflict must include the existing digest"
|
|
1137
|
-
});
|
|
1138
|
-
if (acknowledgement.status === "conflict" && acknowledgement.existingRequestDigest === acknowledgement.requestDigest) refinement.addIssue({
|
|
1139
|
-
code: "custom",
|
|
1140
|
-
path: ["existingRequestDigest"],
|
|
1141
|
-
message: "a cancellation conflict must identify a different request"
|
|
1142
|
-
});
|
|
1143
|
-
if (acknowledgement.status !== "conflict" && acknowledgement.existingRequestDigest !== void 0) refinement.addIssue({
|
|
1144
|
-
code: "custom",
|
|
1145
|
-
path: ["existingRequestDigest"],
|
|
1146
|
-
message: "only a cancellation conflict may include an existing digest"
|
|
1147
|
-
});
|
|
1148
|
-
if (acknowledgement.status === "unknown" && (acknowledgement.message === void 0 || acknowledgement.retryable !== false)) refinement.addIssue({
|
|
1149
|
-
code: "custom",
|
|
1150
|
-
path: ["retryable"],
|
|
1151
|
-
message: "an unknown cancellation outcome must be explicit and non-repeatable"
|
|
1152
|
-
});
|
|
1153
|
-
});
|
|
1154
|
-
const unknownRecordSchema$1 = boundedJsonRecordSchema;
|
|
1155
|
-
const partBase$1 = {
|
|
1156
|
-
id: stableIdSchema$1,
|
|
1157
|
-
sessionID: stableIdSchema$1,
|
|
1158
|
-
messageID: stableIdSchema$1
|
|
1159
|
-
};
|
|
1160
|
-
const toolTimeSchema$1 = z.strictObject({
|
|
1161
|
-
start: z.number().finite(),
|
|
1162
|
-
end: z.number().finite().optional()
|
|
1163
|
-
});
|
|
1164
|
-
const toolStateSchema$1 = z.discriminatedUnion("status", [
|
|
1165
|
-
z.strictObject({
|
|
1166
|
-
status: z.literal("pending"),
|
|
1167
|
-
input: boundedEventContentRecordSchema,
|
|
1168
|
-
raw: boundedEventContentStringSchema.optional()
|
|
1169
|
-
}),
|
|
1170
|
-
z.strictObject({
|
|
1171
|
-
status: z.literal("running"),
|
|
1172
|
-
input: boundedEventContentRecordSchema,
|
|
1173
|
-
title: boundedStringSchema.optional(),
|
|
1174
|
-
metadata: unknownRecordSchema$1.optional(),
|
|
1175
|
-
time: z.strictObject({ start: z.number().finite() }).optional()
|
|
1176
|
-
}),
|
|
1177
|
-
z.strictObject({
|
|
1178
|
-
status: z.literal("completed"),
|
|
1179
|
-
input: boundedEventContentRecordSchema,
|
|
1180
|
-
output: boundedEventContentJsonSchema,
|
|
1181
|
-
title: boundedStringSchema.optional(),
|
|
1182
|
-
metadata: unknownRecordSchema$1.optional(),
|
|
1183
|
-
time: z.strictObject({
|
|
1184
|
-
start: z.number().finite(),
|
|
1185
|
-
end: z.number().finite()
|
|
1186
|
-
}).optional()
|
|
1187
|
-
}),
|
|
1188
|
-
z.strictObject({
|
|
1189
|
-
status: z.enum(["error", "failed"]),
|
|
1190
|
-
input: boundedEventContentRecordSchema,
|
|
1191
|
-
error: boundedStringSchema.optional(),
|
|
1192
|
-
output: boundedEventContentJsonSchema.optional(),
|
|
1193
|
-
metadata: unknownRecordSchema$1.optional(),
|
|
1194
|
-
time: toolTimeSchema$1.optional()
|
|
1195
|
-
})
|
|
1196
|
-
]);
|
|
1197
|
-
const partSchema$1 = z.discriminatedUnion("type", [
|
|
1198
|
-
z.strictObject({
|
|
1199
|
-
...partBase$1,
|
|
1200
|
-
type: z.literal("text"),
|
|
1201
|
-
text: boundedEventContentStringSchema
|
|
1202
|
-
}),
|
|
1203
|
-
z.strictObject({
|
|
1204
|
-
...partBase$1,
|
|
1205
|
-
type: z.literal("tool"),
|
|
1206
|
-
callID: stableIdSchema$1.optional(),
|
|
1207
|
-
tool: stableIdSchema$1,
|
|
1208
|
-
state: toolStateSchema$1,
|
|
1209
|
-
metadata: unknownRecordSchema$1.optional()
|
|
1210
|
-
}),
|
|
1211
|
-
z.strictObject({
|
|
1212
|
-
...partBase$1,
|
|
1213
|
-
type: z.literal("reasoning"),
|
|
1214
|
-
text: boundedEventContentStringSchema
|
|
1215
|
-
}),
|
|
1216
|
-
z.strictObject({
|
|
1217
|
-
...partBase$1,
|
|
1218
|
-
type: z.literal("file"),
|
|
1219
|
-
filename: boundedStringSchema.optional(),
|
|
1220
|
-
mediaType: boundedStringSchema.optional(),
|
|
1221
|
-
url: boundedStringSchema.optional()
|
|
1222
|
-
}),
|
|
1223
|
-
z.strictObject({
|
|
1224
|
-
...partBase$1,
|
|
1225
|
-
type: z.literal("subtask"),
|
|
1226
|
-
prompt: boundedEventContentStringSchema,
|
|
1227
|
-
description: boundedStringSchema,
|
|
1228
|
-
agent: stableIdSchema$1
|
|
1229
|
-
})
|
|
1230
|
-
]);
|
|
1231
|
-
const TERMINAL_CHILD_TASK_STATUSES$1 = new Set([
|
|
1232
|
-
"completed",
|
|
1233
|
-
"failed",
|
|
1234
|
-
"cancelled"
|
|
1235
|
-
]);
|
|
1236
|
-
const epochMillisecondsSchema$1 = z.number().finite().nonnegative();
|
|
1237
|
-
/**
|
|
1238
|
-
* Provider-native child task lifecycle. Identity comes only from `childId`,
|
|
1239
|
-
* `parentChildId`, and `sourceEventId`; `raw` is opaque and bounded. A provider
|
|
1240
|
-
* without a stable `childId` emits no `child-task` event.
|
|
1241
|
-
*/
|
|
1242
|
-
const ChildTaskEventSchema$1 = z.strictObject({
|
|
1243
|
-
type: z.literal("child-task"),
|
|
1244
|
-
childId: stableIdSchema$1,
|
|
1245
|
-
parentChildId: stableIdSchema$1.optional(),
|
|
1246
|
-
status: z.enum([
|
|
1247
|
-
"started",
|
|
1248
|
-
"running",
|
|
1249
|
-
"completed",
|
|
1250
|
-
"failed",
|
|
1251
|
-
"cancelled"
|
|
1252
|
-
]),
|
|
1253
|
-
title: boundedStringSchema.optional(),
|
|
1254
|
-
time: z.strictObject({
|
|
1255
|
-
started: epochMillisecondsSchema$1,
|
|
1256
|
-
updated: epochMillisecondsSchema$1,
|
|
1257
|
-
ended: epochMillisecondsSchema$1.optional()
|
|
1258
|
-
}),
|
|
1259
|
-
runner: stableIdSchema$1.optional(),
|
|
1260
|
-
model: stableIdSchema$1.optional(),
|
|
1261
|
-
usage: ModelUsageSchema$1.optional(),
|
|
1262
|
-
terminalReason: boundedStringSchema.optional(),
|
|
1263
|
-
sourceEventId: stableIdSchema$1,
|
|
1264
|
-
raw: boundedJsonRecordSchema.optional()
|
|
1265
|
-
}).superRefine((event, refinement) => {
|
|
1266
|
-
const terminal = TERMINAL_CHILD_TASK_STATUSES$1.has(event.status);
|
|
1267
|
-
if (!terminal && event.time.ended !== void 0) refinement.addIssue({
|
|
1268
|
-
code: "custom",
|
|
1269
|
-
path: ["time", "ended"],
|
|
1270
|
-
message: "only a terminal child task status may carry an end time"
|
|
1271
|
-
});
|
|
1272
|
-
if (!terminal && event.terminalReason !== void 0) refinement.addIssue({
|
|
1273
|
-
code: "custom",
|
|
1274
|
-
path: ["terminalReason"],
|
|
1275
|
-
message: "only a terminal child task status may carry a terminal reason"
|
|
1276
|
-
});
|
|
1277
|
-
if (event.time.updated < event.time.started) refinement.addIssue({
|
|
1278
|
-
code: "custom",
|
|
1279
|
-
path: ["time", "updated"],
|
|
1280
|
-
message: "a child task update time cannot precede its start time"
|
|
1281
|
-
});
|
|
1282
|
-
if (event.time.ended !== void 0 && event.time.ended < event.time.started) refinement.addIssue({
|
|
1283
|
-
code: "custom",
|
|
1284
|
-
path: ["time", "ended"],
|
|
1285
|
-
message: "a child task end time cannot precede its start time"
|
|
1286
|
-
});
|
|
1287
|
-
if (event.parentChildId === event.childId) refinement.addIssue({
|
|
1288
|
-
code: "custom",
|
|
1289
|
-
path: ["parentChildId"],
|
|
1290
|
-
message: "a child task cannot be its own parent"
|
|
1291
|
-
});
|
|
1292
|
-
});
|
|
1293
|
-
const CanonicalStreamEventSchema$1 = z.discriminatedUnion("type", [
|
|
1294
|
-
z.strictObject({
|
|
1295
|
-
type: z.literal("message.part.updated"),
|
|
1296
|
-
part: partSchema$1,
|
|
1297
|
-
delta: boundedEventContentStringSchema.optional()
|
|
1298
|
-
}),
|
|
1299
|
-
z.strictObject({
|
|
1300
|
-
type: z.literal("tool-heartbeat"),
|
|
1301
|
-
toolName: stableIdSchema$1,
|
|
1302
|
-
partId: stableIdSchema$1,
|
|
1303
|
-
elapsedMs: z.number().finite().nonnegative()
|
|
1304
|
-
}),
|
|
1305
|
-
z.strictObject({
|
|
1306
|
-
type: z.literal("tool-slow"),
|
|
1307
|
-
toolName: stableIdSchema$1,
|
|
1308
|
-
partId: stableIdSchema$1,
|
|
1309
|
-
elapsedMs: z.number().finite().nonnegative(),
|
|
1310
|
-
thresholdMs: z.number().finite().nonnegative()
|
|
1311
|
-
}),
|
|
1312
|
-
z.strictObject({
|
|
1313
|
-
type: z.literal("model-processing"),
|
|
1314
|
-
phase: z.enum([
|
|
1315
|
-
"tool-result",
|
|
1316
|
-
"generating",
|
|
1317
|
-
"thinking"
|
|
1318
|
-
]),
|
|
1319
|
-
toolName: stableIdSchema$1.optional(),
|
|
1320
|
-
elapsedMs: z.number().finite().nonnegative().optional()
|
|
1321
|
-
}),
|
|
1322
|
-
z.strictObject({
|
|
1323
|
-
type: z.literal("status"),
|
|
1324
|
-
status: z.enum([
|
|
1325
|
-
"started",
|
|
1326
|
-
"processing",
|
|
1327
|
-
"completed",
|
|
1328
|
-
"failed",
|
|
1329
|
-
"cancelled"
|
|
1330
|
-
]),
|
|
1331
|
-
detail: boundedStringSchema.optional()
|
|
1332
|
-
}),
|
|
1333
|
-
z.strictObject({
|
|
1334
|
-
type: z.literal("warning"),
|
|
1335
|
-
code: stableIdSchema$1,
|
|
1336
|
-
message: boundedStringSchema
|
|
1337
|
-
}),
|
|
1338
|
-
z.strictObject({
|
|
1339
|
-
type: z.literal("raw"),
|
|
1340
|
-
backend: stableIdSchema$1,
|
|
1341
|
-
event: boundedEventContentJsonSchema
|
|
1342
|
-
}),
|
|
1343
|
-
NativeSessionObservedEventSchema$1,
|
|
1344
|
-
z.strictObject({
|
|
1345
|
-
type: z.literal("session.updated"),
|
|
1346
|
-
sessionId: stableIdSchema$1,
|
|
1347
|
-
title: boundedStringSchema.optional(),
|
|
1348
|
-
time: z.strictObject({
|
|
1349
|
-
created: z.number().finite().optional(),
|
|
1350
|
-
updated: z.number().finite().optional()
|
|
1351
|
-
}).optional()
|
|
1352
|
-
}),
|
|
1353
|
-
z.strictObject({
|
|
1354
|
-
type: z.literal("interaction"),
|
|
1355
|
-
request: InteractionRequestSchema$1
|
|
1356
|
-
}),
|
|
1357
|
-
z.strictObject({
|
|
1358
|
-
type: z.literal("interaction.cancel"),
|
|
1359
|
-
id: stableIdSchema$1,
|
|
1360
|
-
reason: boundedStringSchema.optional()
|
|
1361
|
-
}),
|
|
1362
|
-
z.strictObject({
|
|
1363
|
-
type: z.literal("plan.submitted"),
|
|
1364
|
-
plan: DurablePlanSchema$1
|
|
1365
|
-
}),
|
|
1366
|
-
ChildTaskEventSchema$1
|
|
1367
|
-
]).superRefine((event, refinement) => {
|
|
1368
|
-
if (!isBoundedEventContentJson(event, { omitUndefinedObjectFields: true })) refinement.addIssue({
|
|
1369
|
-
code: "custom",
|
|
1370
|
-
message: "canonical stream event exceeds its serialized byte bound"
|
|
1371
|
-
});
|
|
1372
|
-
});
|
|
1373
|
-
z.strictObject({
|
|
1374
|
-
runId: stableIdSchema$1,
|
|
1375
|
-
eventId: stableIdSchema$1,
|
|
1376
|
-
sequence: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
1377
|
-
cursor: stableIdSchema$1.optional(),
|
|
1378
|
-
occurredAt: z.iso.datetime().max(64).optional(),
|
|
1379
|
-
receivedAt: z.iso.datetime().max(64),
|
|
1380
|
-
event: CanonicalStreamEventSchema$1
|
|
1381
|
-
});
|
|
1382
|
-
//#endregion
|
|
1383
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/agent-profile-materialization.js
|
|
1384
|
-
/**
|
|
1385
|
-
* The canonical AgentProfile leaves that can affect one execution.
|
|
1386
|
-
*
|
|
1387
|
-
* Compound parents such as `model`, `prompt`, and `resources` are deliberately
|
|
1388
|
-
* absent. A producer must report the exact requested leaf instead of claiming
|
|
1389
|
-
* a parent while silently dropping one of its children. `systemPrompt` and
|
|
1390
|
-
* `appendSystemPrompt` are separate leaves for the same reason: a backend that
|
|
1391
|
-
* can only add text must report the requested replacement as unsatisfied rather
|
|
1392
|
-
* than acknowledge it.
|
|
1393
|
-
*/
|
|
1394
|
-
const AGENT_PROFILE_MATERIALIZATION_AXES$1 = [
|
|
1395
|
-
"name",
|
|
1396
|
-
"description",
|
|
1397
|
-
"version",
|
|
1398
|
-
"tags",
|
|
1399
|
-
"systemPrompt",
|
|
1400
|
-
"appendSystemPrompt",
|
|
1401
|
-
"instructions",
|
|
1402
|
-
"modelDefault",
|
|
1403
|
-
"modelSmall",
|
|
1404
|
-
"modelProvider",
|
|
1405
|
-
"modelReasoningEffort",
|
|
1406
|
-
"modelMaxVisibleOutputTokens",
|
|
1407
|
-
"modelMaxReasoningTokens",
|
|
1408
|
-
"modelMaxTotalOutputTokens",
|
|
1409
|
-
"modelMetadata",
|
|
1410
|
-
"harness",
|
|
1411
|
-
"seats",
|
|
1412
|
-
"permissions",
|
|
1413
|
-
"tools",
|
|
1414
|
-
"mcp",
|
|
1415
|
-
"connections",
|
|
1416
|
-
"subagents",
|
|
1417
|
-
"files",
|
|
1418
|
-
"resourceTools",
|
|
1419
|
-
"skills",
|
|
1420
|
-
"resourceAgents",
|
|
1421
|
-
"commands",
|
|
1422
|
-
"resourceInstructions",
|
|
1423
|
-
"resourceFailOnError",
|
|
1424
|
-
"hooks",
|
|
1425
|
-
"modes",
|
|
1426
|
-
"confidential",
|
|
1427
|
-
"metadata",
|
|
1428
|
-
"extensions"
|
|
1429
|
-
];
|
|
1430
|
-
[...Object.entries({
|
|
1431
|
-
default: "modelDefault",
|
|
1432
|
-
small: "modelSmall",
|
|
1433
|
-
provider: "modelProvider",
|
|
1434
|
-
reasoningEffort: "modelReasoningEffort",
|
|
1435
|
-
maxVisibleOutputTokens: "modelMaxVisibleOutputTokens",
|
|
1436
|
-
maxReasoningTokens: "modelMaxReasoningTokens",
|
|
1437
|
-
maxTotalOutputTokens: "modelMaxTotalOutputTokens",
|
|
1438
|
-
metadata: "modelMetadata"
|
|
1439
|
-
}).map(([property, axis]) => ({
|
|
1440
|
-
axis,
|
|
1441
|
-
rootPath: `/model/${property}`,
|
|
1442
|
-
value: (profile) => profile.model?.[property]
|
|
1443
|
-
}))];
|
|
1444
|
-
//#endregion
|
|
1445
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/agent-workspace-source-snapshot.js
|
|
1446
|
-
const controlCharacterPattern$1 = /[\u0000-\u001f\u007f]/;
|
|
1447
|
-
/** Shared public identifier used by workspace lifecycle contracts. */
|
|
1448
|
-
const agentWorkspacePublicIdentifierSchema$1 = z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isWellFormedUnicode(value) && !controlCharacterPattern$1.test(value) && !looksLikeCredential(value), "public workspace identity cannot carry credential-like material");
|
|
1449
|
-
const agentWorkspaceSourceSnapshotPolicySchema$1 = z.strictObject({
|
|
1450
|
-
kind: z.literal("provider-declared"),
|
|
1451
|
-
name: agentWorkspacePublicIdentifierSchema$1,
|
|
1452
|
-
version: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
1453
|
-
digest: sha256DigestSchema
|
|
1454
|
-
});
|
|
1455
|
-
//#endregion
|
|
1456
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/agent-execution-preparation-receipt.js
|
|
1457
|
-
const nonBlankStringSchema$1 = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
|
|
1458
|
-
const publicMechanismIdentifierSchema$1 = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/, "mechanism must be a public identifier, not launch arguments").refine((value) => !looksLikeCredential(value), "mechanism cannot carry credential-like material");
|
|
1459
|
-
const publicLifecycleIdentifierSchema$1 = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._~:/+-]{0,499}$/, "lifecycle identity must be a public identifier").refine((value) => !looksLikeCredential(value), "lifecycle identity cannot carry credential-like material");
|
|
1460
|
-
const publicReasonSchema$1 = nonBlankStringSchema$1.max(4e3).refine((value) => !looksLikeCredential(value), "reason cannot carry credential-like material");
|
|
1461
|
-
const jsonPointerSchema$1 = z.string().refine(isCanonicalJsonPointer$1, "path must be a canonical RFC 6901 JSON Pointer");
|
|
1462
|
-
const agentExecutionPreparationAxisResultSchema$1 = z.strictObject({
|
|
1463
|
-
axis: z.enum(AGENT_PROFILE_MATERIALIZATION_AXES$1),
|
|
1464
|
-
disposition: z.enum([
|
|
1465
|
-
"behavior",
|
|
1466
|
-
"control",
|
|
1467
|
-
"overridden",
|
|
1468
|
-
"unsupported"
|
|
1469
|
-
]),
|
|
1470
|
-
owner: z.enum(["runtime", "executor"]),
|
|
1471
|
-
mechanism: publicMechanismIdentifierSchema$1,
|
|
1472
|
-
evidenceDigest: sha256DigestSchema.optional(),
|
|
1473
|
-
path: jsonPointerSchema$1.optional(),
|
|
1474
|
-
reason: publicReasonSchema$1.optional()
|
|
1475
|
-
}).superRefine((result, context) => {
|
|
1476
|
-
const requiresReason = result.disposition === "overridden" || result.disposition === "unsupported";
|
|
1477
|
-
if (requiresReason && result.reason === void 0) context.addIssue({
|
|
1478
|
-
code: "custom",
|
|
1479
|
-
path: ["reason"],
|
|
1480
|
-
message: `${result.disposition} profile coverage requires a reason`
|
|
1481
|
-
});
|
|
1482
|
-
if (!requiresReason && result.reason !== void 0) context.addIssue({
|
|
1483
|
-
code: "custom",
|
|
1484
|
-
path: ["reason"],
|
|
1485
|
-
message: `${result.disposition} profile coverage cannot carry an override reason`
|
|
1486
|
-
});
|
|
1487
|
-
});
|
|
1488
|
-
const reasoningEffortSchema$1 = z.enum(REASONING_EFFORTS);
|
|
1489
|
-
const agentExecutionPreparationReasoningEffortSchema$1 = z.strictObject({
|
|
1490
|
-
requested: reasoningEffortSchema$1,
|
|
1491
|
-
resolved: reasoningEffortSchema$1.optional(),
|
|
1492
|
-
fidelity: z.enum([
|
|
1493
|
-
"exact",
|
|
1494
|
-
"clamped",
|
|
1495
|
-
"unsupported"
|
|
1496
|
-
])
|
|
1497
|
-
}).superRefine((effort, context) => {
|
|
1498
|
-
if (effort.fidelity === "unsupported") {
|
|
1499
|
-
if (effort.resolved !== void 0) context.addIssue({
|
|
1500
|
-
code: "custom",
|
|
1501
|
-
path: ["resolved"],
|
|
1502
|
-
message: "unsupported reasoning effort cannot claim a resolved value"
|
|
1503
|
-
});
|
|
1504
|
-
return;
|
|
1505
|
-
}
|
|
1506
|
-
if (effort.resolved === void 0) {
|
|
1507
|
-
context.addIssue({
|
|
1508
|
-
code: "custom",
|
|
1509
|
-
path: ["resolved"],
|
|
1510
|
-
message: `${effort.fidelity} reasoning fidelity requires a resolved value`
|
|
1511
|
-
});
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
if (effort.fidelity === "exact" && effort.resolved !== effort.requested) context.addIssue({
|
|
1515
|
-
code: "custom",
|
|
1516
|
-
path: ["resolved"],
|
|
1517
|
-
message: "exact reasoning fidelity must preserve the requested effort"
|
|
1518
|
-
});
|
|
1519
|
-
if (effort.fidelity === "clamped") {
|
|
1520
|
-
if (effort.resolved === effort.requested) context.addIssue({
|
|
1521
|
-
code: "custom",
|
|
1522
|
-
path: ["resolved"],
|
|
1523
|
-
message: "clamped reasoning fidelity must change the requested effort"
|
|
1524
|
-
});
|
|
1525
|
-
else if (!isDownwardReasoningClamp$1(effort.requested, effort.resolved)) context.addIssue({
|
|
1526
|
-
code: "custom",
|
|
1527
|
-
path: ["resolved"],
|
|
1528
|
-
message: "reasoning effort may clamp down but must never increase"
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
const agentExecutionPreparationReceiptSchema$1 = z.strictObject({
|
|
1533
|
-
kind: z.literal("agent-execution-preparation"),
|
|
1534
|
-
schemaVersion: z.literal(1),
|
|
1535
|
-
preparationId: nonBlankStringSchema$1.max(500),
|
|
1536
|
-
requestDigest: sha256DigestSchema,
|
|
1537
|
-
authoredProfileDigest: sha256DigestSchema,
|
|
1538
|
-
effectiveProfileDigest: sha256DigestSchema,
|
|
1539
|
-
backend: nonBlankStringSchema$1.max(200),
|
|
1540
|
-
harness: harnessTypeSchema,
|
|
1541
|
-
harnessVersion: nonBlankStringSchema$1.max(200),
|
|
1542
|
-
resolvedModel: z.strictObject({
|
|
1543
|
-
requested: z.string().max(500),
|
|
1544
|
-
resolved: nonBlankStringSchema$1.max(500),
|
|
1545
|
-
provider: z.string().max(200).optional(),
|
|
1546
|
-
reasoningEffort: agentExecutionPreparationReasoningEffortSchema$1.optional()
|
|
1547
|
-
}),
|
|
1548
|
-
workspace: z.strictObject({
|
|
1549
|
-
leaseId: publicLifecycleIdentifierSchema$1,
|
|
1550
|
-
provider: publicLifecycleIdentifierSchema$1,
|
|
1551
|
-
identityDigest: sha256DigestSchema,
|
|
1552
|
-
isolation: z.enum(["per-run", "shared"]),
|
|
1553
|
-
sourceSnapshotDigest: sha256DigestSchema,
|
|
1554
|
-
sourceSnapshotPolicy: agentWorkspaceSourceSnapshotPolicySchema$1,
|
|
1555
|
-
preparedWorkspaceDigest: sha256DigestSchema,
|
|
1556
|
-
profileActivationDigest: sha256DigestSchema
|
|
1557
|
-
}),
|
|
1558
|
-
axisResults: z.array(agentExecutionPreparationAxisResultSchema$1),
|
|
1559
|
-
executionPlanDigest: sha256DigestSchema,
|
|
1560
|
-
materializer: z.strictObject({
|
|
1561
|
-
name: nonBlankStringSchema$1.max(200),
|
|
1562
|
-
version: nonBlankStringSchema$1.max(200)
|
|
1563
|
-
}),
|
|
1564
|
-
expiresAtMs: z.number().int().positive().safe(),
|
|
1565
|
-
digest: sha256DigestSchema
|
|
1566
|
-
}).superRefine((receipt, context) => {
|
|
1567
|
-
const seen = /* @__PURE__ */ new Map();
|
|
1568
|
-
for (const [index, result] of receipt.axisResults.entries()) {
|
|
1569
|
-
const key = agentExecutionPreparationAxisResultKey$1(result.axis, result.path);
|
|
1570
|
-
const previous = seen.get(key);
|
|
1571
|
-
if (previous !== void 0) context.addIssue({
|
|
1572
|
-
code: "custom",
|
|
1573
|
-
path: ["axisResults", index],
|
|
1574
|
-
message: agentExecutionPreparationAxisResultsEqual$1(previous, result) ? "duplicate profile axis/path result" : "conflicting profile axis/path results"
|
|
1575
|
-
});
|
|
1576
|
-
else seen.set(key, result);
|
|
1577
|
-
if (index > 0 && compareAgentExecutionPreparationAxisResults$1(receipt.axisResults[index - 1], result) >= 0) context.addIssue({
|
|
1578
|
-
code: "custom",
|
|
1579
|
-
path: ["axisResults", index],
|
|
1580
|
-
message: "profile axis/path results must be canonically sorted"
|
|
1581
|
-
});
|
|
1582
|
-
}
|
|
1583
|
-
if (!isCanonicalJsonValue(receipt)) context.addIssue({
|
|
1584
|
-
code: "custom",
|
|
1585
|
-
message: "execution preparation receipt must contain only RFC 8785 JSON values"
|
|
1586
|
-
});
|
|
1587
|
-
else if (canonicalCandidateDigest(omitTopLevelDigest(receipt)) !== receipt.digest) context.addIssue({
|
|
1588
|
-
code: "custom",
|
|
1589
|
-
path: ["digest"],
|
|
1590
|
-
message: "execution preparation receipt digest is invalid"
|
|
1591
|
-
});
|
|
1592
|
-
});
|
|
1593
|
-
/** @internal Canonical identity for one preparation axis and path. */
|
|
1594
|
-
function agentExecutionPreparationAxisResultKey$1(axis, path) {
|
|
1595
|
-
return `${axis}\u0000${path ?? ""}`;
|
|
1596
|
-
}
|
|
1597
|
-
/** @internal Exact public equality for preparation axis rows. */
|
|
1598
|
-
function agentExecutionPreparationAxisResultsEqual$1(left, right) {
|
|
1599
|
-
try {
|
|
1600
|
-
return canonicalCandidateJson(left) === canonicalCandidateJson(right);
|
|
1601
|
-
} catch {
|
|
1602
|
-
return false;
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
const AXIS_ORDER$1 = new Map(AGENT_PROFILE_MATERIALIZATION_AXES$1.map((axis, index) => [axis, index]));
|
|
1606
|
-
/** @internal Canonical order for preparation axis rows. */
|
|
1607
|
-
function compareAgentExecutionPreparationAxisResults$1(left, right) {
|
|
1608
|
-
const axisDifference = (AXIS_ORDER$1.get(left.axis) ?? Number.MAX_SAFE_INTEGER) - (AXIS_ORDER$1.get(right.axis) ?? Number.MAX_SAFE_INTEGER);
|
|
1609
|
-
if (axisDifference !== 0) return axisDifference;
|
|
1610
|
-
const leftPath = left.path ?? "";
|
|
1611
|
-
const rightPath = right.path ?? "";
|
|
1612
|
-
return leftPath < rightPath ? -1 : leftPath > rightPath ? 1 : 0;
|
|
1613
|
-
}
|
|
1614
|
-
function isCanonicalJsonPointer$1(value) {
|
|
1615
|
-
if (!value.startsWith("/") || !isWellFormedUnicode(value)) return false;
|
|
1616
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
1617
|
-
if (value[index] !== "~") continue;
|
|
1618
|
-
const escape = value[index + 1];
|
|
1619
|
-
if (escape !== "0" && escape !== "1") return false;
|
|
1620
|
-
index += 1;
|
|
1621
|
-
}
|
|
1622
|
-
return true;
|
|
1623
|
-
}
|
|
1624
|
-
function isDownwardReasoningClamp$1(requested, resolved) {
|
|
1625
|
-
return REASONING_EFFORTS.indexOf(resolved) < REASONING_EFFORTS.indexOf(requested);
|
|
1626
|
-
}
|
|
1627
|
-
const agentInteractiveDimensionSchema$1 = z.number().int().positive().max(1e4);
|
|
1628
|
-
//#endregion
|
|
1629
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@4.0.0/node_modules/@tangle-network/agent-interface/dist/environment-interactive-control.js
|
|
1630
|
-
/**
|
|
1631
|
-
* Durable identity of one coding-agent TUI.
|
|
1632
|
-
*
|
|
1633
|
-
* This reference identifies the exact admitted run and preparation receipt.
|
|
1634
|
-
* It is not a generic shell id and cannot be used to create another process.
|
|
1635
|
-
*/
|
|
1636
|
-
const AgentInteractiveSessionRefSchema$1 = z.strictObject({
|
|
1637
|
-
run: AgentExactRunControlRefSchema$1,
|
|
1638
|
-
/** Canonical executor receipt containing the effective route and its proof. */
|
|
1639
|
-
preparationReceipt: agentExecutionPreparationReceiptSchema$1,
|
|
1640
|
-
/** Provider-issued identity of this exact process incarnation. */
|
|
1641
|
-
incarnationId: boundedIdentifierSchema,
|
|
1642
|
-
startedAt: z.iso.datetime().max(64)
|
|
1643
|
-
});
|
|
1644
|
-
/**
|
|
1645
|
-
* Provider-issued write authority for one exact interactive process.
|
|
1646
|
-
*
|
|
1647
|
-
* Expiry blocks mutations but does not kill the coding process. A coordinator
|
|
1648
|
-
* can issue a new compare-and-swap claim after expiry. The provider's PTY owner
|
|
1649
|
-
* lease remains the separate process-cleanup authority.
|
|
1650
|
-
*/
|
|
1651
|
-
const AgentInteractiveSessionControlClaimSchema$1 = z.strictObject({
|
|
1652
|
-
/** Canonical identity of the process ref this authority can mutate. */
|
|
1653
|
-
refDigest: sha256DigestSchema,
|
|
1654
|
-
/** Provider generation. A recovered coordinator must obtain a greater value. */
|
|
1655
|
-
generation: z.number().int().positive().safe(),
|
|
1656
|
-
/** Provider lease identity for this generation. */
|
|
1657
|
-
leaseId: boundedIdentifierSchema,
|
|
1658
|
-
/** Stable identity of the coordinator holding this lease. */
|
|
1659
|
-
holderId: boundedIdentifierSchema,
|
|
1660
|
-
expiresAt: z.iso.datetime().max(64)
|
|
1661
|
-
});
|
|
1662
|
-
const AgentInteractiveSessionControlClaimRequestMaterialSchema$1 = z.strictObject({
|
|
1663
|
-
operationId: boundedIdentifierSchema,
|
|
1664
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1665
|
-
holderId: boundedIdentifierSchema,
|
|
1666
|
-
expectedGeneration: z.number().int().nonnegative().safe()
|
|
1667
|
-
});
|
|
1668
|
-
function agentInteractiveSessionControlClaimRequestDigest$1(value) {
|
|
1669
|
-
const parsed = AgentInteractiveSessionControlClaimRequestMaterialSchema$1.parse(value);
|
|
1670
|
-
return canonicalCandidateDigest({
|
|
1671
|
-
kind: "agent-interactive-session-control-claim.v1",
|
|
1672
|
-
operationId: parsed.operationId,
|
|
1673
|
-
ref: parsed.ref,
|
|
1674
|
-
holderId: parsed.holderId,
|
|
1675
|
-
expectedGeneration: parsed.expectedGeneration
|
|
1676
|
-
});
|
|
1677
|
-
}
|
|
1678
|
-
z.strictObject({
|
|
1679
|
-
...AgentInteractiveSessionControlClaimRequestMaterialSchema$1.shape,
|
|
1680
|
-
requestDigest: sha256DigestSchema
|
|
1681
|
-
}).superRefine((request, refinement) => {
|
|
1682
|
-
const { requestDigest: _requestDigest, ...material } = request;
|
|
1683
|
-
if (request.requestDigest !== agentInteractiveSessionControlClaimRequestDigest$1(material)) refinement.addIssue({
|
|
1684
|
-
code: "custom",
|
|
1685
|
-
path: ["requestDigest"],
|
|
1686
|
-
message: "interactive session control claim request digest does not match its content"
|
|
1687
|
-
});
|
|
1688
|
-
});
|
|
1689
|
-
const AgentInteractiveSessionControlClaimAcknowledgementSchema$1 = z.strictObject({
|
|
1690
|
-
operationId: boundedIdentifierSchema,
|
|
1691
|
-
requestDigest: sha256DigestSchema,
|
|
1692
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1693
|
-
status: z.enum([
|
|
1694
|
-
"accepted",
|
|
1695
|
-
"replayed",
|
|
1696
|
-
"conflict",
|
|
1697
|
-
"unknown"
|
|
1698
|
-
]),
|
|
1699
|
-
control: AgentInteractiveSessionControlClaimSchema$1.optional(),
|
|
1700
|
-
conflictReason: z.enum(["generation_mismatch", "operation_reuse"]).optional(),
|
|
1701
|
-
currentGeneration: z.number().int().nonnegative().safe().optional(),
|
|
1702
|
-
existingRequestDigest: sha256DigestSchema.optional(),
|
|
1703
|
-
message: boundedStringSchema.min(1).optional(),
|
|
1704
|
-
retryable: z.boolean().optional()
|
|
1705
|
-
}).superRefine((acknowledgement, refinement) => {
|
|
1706
|
-
const hasControl = acknowledgement.control !== void 0;
|
|
1707
|
-
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && !hasControl) refinement.addIssue({
|
|
1708
|
-
code: "custom",
|
|
1709
|
-
path: ["control"],
|
|
1710
|
-
message: "an accepted control claim must return its provider claim"
|
|
1711
|
-
});
|
|
1712
|
-
if (acknowledgement.status !== "accepted" && acknowledgement.status !== "replayed" && hasControl) refinement.addIssue({
|
|
1713
|
-
code: "custom",
|
|
1714
|
-
path: ["control"],
|
|
1715
|
-
message: "only an accepted or replayed claim may return control"
|
|
1716
|
-
});
|
|
1717
|
-
if (acknowledgement.status === "conflict" && acknowledgement.conflictReason === void 0) refinement.addIssue({
|
|
1718
|
-
code: "custom",
|
|
1719
|
-
path: ["conflictReason"],
|
|
1720
|
-
message: "a control claim conflict must distinguish generation mismatch from operation reuse"
|
|
1721
|
-
});
|
|
1722
|
-
if (acknowledgement.status !== "conflict" && acknowledgement.conflictReason !== void 0) refinement.addIssue({
|
|
1723
|
-
code: "custom",
|
|
1724
|
-
path: ["conflictReason"],
|
|
1725
|
-
message: "only a control claim conflict may report a conflict reason"
|
|
1726
|
-
});
|
|
1727
|
-
if (hasControl && !agentInteractiveSessionControlClaimMatchesRef$1(acknowledgement.ref, acknowledgement.control)) refinement.addIssue({
|
|
1728
|
-
code: "custom",
|
|
1729
|
-
path: ["control", "refDigest"],
|
|
1730
|
-
message: "interactive control claim acknowledgement does not match its process ref"
|
|
1731
|
-
});
|
|
1732
|
-
if (acknowledgement.status === "conflict" && acknowledgement.currentGeneration === void 0) refinement.addIssue({
|
|
1733
|
-
code: "custom",
|
|
1734
|
-
path: ["currentGeneration"],
|
|
1735
|
-
message: "a control claim conflict must report the current generation"
|
|
1736
|
-
});
|
|
1737
|
-
if (acknowledgement.conflictReason === "generation_mismatch" && acknowledgement.existingRequestDigest !== void 0) refinement.addIssue({
|
|
1738
|
-
code: "custom",
|
|
1739
|
-
path: ["existingRequestDigest"],
|
|
1740
|
-
message: "a generation mismatch must not be reported as operation reuse"
|
|
1741
|
-
});
|
|
1742
|
-
if (acknowledgement.conflictReason === "operation_reuse" && acknowledgement.existingRequestDigest === void 0) refinement.addIssue({
|
|
1743
|
-
code: "custom",
|
|
1744
|
-
path: ["existingRequestDigest"],
|
|
1745
|
-
message: "operation reuse must report the digest already stored for this operation"
|
|
1746
|
-
});
|
|
1747
|
-
if (acknowledgement.status === "conflict" && acknowledgement.existingRequestDigest === acknowledgement.requestDigest) refinement.addIssue({
|
|
1748
|
-
code: "custom",
|
|
1749
|
-
path: ["existingRequestDigest"],
|
|
1750
|
-
message: "a control claim conflict must identify different request material"
|
|
1751
|
-
});
|
|
1752
|
-
if (acknowledgement.status !== "conflict" && (acknowledgement.currentGeneration !== void 0 || acknowledgement.existingRequestDigest !== void 0)) refinement.addIssue({
|
|
1753
|
-
code: "custom",
|
|
1754
|
-
path: ["currentGeneration"],
|
|
1755
|
-
message: "only a control claim conflict may report existing generation state"
|
|
1756
|
-
});
|
|
1757
|
-
if (acknowledgement.status === "unknown" && (acknowledgement.message === void 0 || acknowledgement.retryable !== true)) refinement.addIssue({
|
|
1758
|
-
code: "custom",
|
|
1759
|
-
path: ["retryable"],
|
|
1760
|
-
message: "an unknown control claim outcome must explicitly permit safe same-operation retry"
|
|
1761
|
-
});
|
|
1762
|
-
});
|
|
1763
|
-
/** Bind a provider-issued control claim to the exact process it can mutate. */
|
|
1764
|
-
function agentInteractiveSessionControlClaimMatchesRef$1(ref, claim) {
|
|
1765
|
-
const parsedRef = AgentInteractiveSessionRefSchema$1.safeParse(ref);
|
|
1766
|
-
const parsedClaim = AgentInteractiveSessionControlClaimSchema$1.safeParse(claim);
|
|
1767
|
-
return parsedRef.success && parsedClaim.success && parsedClaim.data.refDigest === canonicalCandidateDigest(parsedRef.data);
|
|
1768
|
-
}
|
|
1769
|
-
z.strictObject({
|
|
1770
|
-
/** Required because the returned terminal permits input and resize. */
|
|
1771
|
-
control: AgentInteractiveSessionControlClaimSchema$1,
|
|
1772
|
-
cols: agentInteractiveDimensionSchema$1.optional(),
|
|
1773
|
-
rows: agentInteractiveDimensionSchema$1.optional()
|
|
1774
|
-
});
|
|
1775
|
-
/** Provider-observed lifecycle of one native coding-agent TUI. */
|
|
1776
|
-
const AgentInteractiveSessionStatusSchema$1 = z.discriminatedUnion("state", [
|
|
1777
|
-
z.strictObject({
|
|
1778
|
-
state: z.literal("running"),
|
|
1779
|
-
ref: AgentInteractiveSessionRefSchema$1
|
|
1780
|
-
}),
|
|
1781
|
-
z.strictObject({
|
|
1782
|
-
state: z.literal("exited"),
|
|
1783
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1784
|
-
endedAt: z.iso.datetime().max(64),
|
|
1785
|
-
reason: z.enum([
|
|
1786
|
-
"exited",
|
|
1787
|
-
"stopped",
|
|
1788
|
-
"lost"
|
|
1789
|
-
]),
|
|
1790
|
-
exitCode: z.number().int().optional(),
|
|
1791
|
-
exitSignal: boundedStringSchema.min(1).optional()
|
|
1792
|
-
}),
|
|
1793
|
-
z.strictObject({
|
|
1794
|
-
state: z.literal("unknown"),
|
|
1795
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1796
|
-
message: boundedStringSchema.min(1),
|
|
1797
|
-
retryable: z.boolean()
|
|
1798
|
-
})
|
|
1799
|
-
]);
|
|
1800
|
-
const AgentInteractiveSessionStopCommandMaterialSchema$1 = z.strictObject({
|
|
1801
|
-
operationId: boundedIdentifierSchema,
|
|
1802
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1803
|
-
control: AgentInteractiveSessionControlClaimSchema$1
|
|
1804
|
-
}).superRefine((command, refinement) => {
|
|
1805
|
-
if (!agentInteractiveSessionControlClaimMatchesRef$1(command.ref, command.control)) refinement.addIssue({
|
|
1806
|
-
code: "custom",
|
|
1807
|
-
path: ["control", "refDigest"],
|
|
1808
|
-
message: "interactive stop control claim does not match its process ref"
|
|
1809
|
-
});
|
|
1810
|
-
});
|
|
1811
|
-
function agentInteractiveSessionStopRequestDigest$1(value) {
|
|
1812
|
-
const parsed = AgentInteractiveSessionStopCommandMaterialSchema$1.parse(value);
|
|
1813
|
-
return canonicalCandidateDigest({
|
|
1814
|
-
kind: "agent-interactive-session-stop.v1",
|
|
1815
|
-
operationId: parsed.operationId,
|
|
1816
|
-
ref: parsed.ref,
|
|
1817
|
-
control: parsed.control
|
|
1818
|
-
});
|
|
1819
|
-
}
|
|
1820
|
-
z.strictObject({
|
|
1821
|
-
...AgentInteractiveSessionStopCommandMaterialSchema$1.shape,
|
|
1822
|
-
requestDigest: sha256DigestSchema
|
|
1823
|
-
}).superRefine((command, refinement) => {
|
|
1824
|
-
const { requestDigest: _requestDigest, ...material } = command;
|
|
1825
|
-
if (command.requestDigest !== agentInteractiveSessionStopRequestDigest$1(material)) refinement.addIssue({
|
|
1826
|
-
code: "custom",
|
|
1827
|
-
path: ["requestDigest"],
|
|
1828
|
-
message: "interactive stop request digest does not match its content"
|
|
1829
|
-
});
|
|
1830
|
-
});
|
|
1831
|
-
const AgentInteractiveSessionStopAcknowledgementSchema$1 = z.strictObject({
|
|
1832
|
-
operationId: boundedIdentifierSchema,
|
|
1833
|
-
requestDigest: sha256DigestSchema,
|
|
1834
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1835
|
-
control: AgentInteractiveSessionControlClaimSchema$1,
|
|
1836
|
-
status: z.enum([
|
|
1837
|
-
"accepted",
|
|
1838
|
-
"replayed",
|
|
1839
|
-
"conflict",
|
|
1840
|
-
"unknown"
|
|
1841
|
-
]),
|
|
1842
|
-
effect: z.enum([
|
|
1843
|
-
"stop_requested",
|
|
1844
|
-
"stopped",
|
|
1845
|
-
"not_live",
|
|
1846
|
-
"unknown"
|
|
1847
|
-
]),
|
|
1848
|
-
message: boundedStringSchema.min(1).optional(),
|
|
1849
|
-
retryable: z.boolean().optional(),
|
|
1850
|
-
existingRequestDigest: sha256DigestSchema.optional()
|
|
1851
|
-
}).superRefine((acknowledgement, refinement) => {
|
|
1852
|
-
if (!agentInteractiveSessionControlClaimMatchesRef$1(acknowledgement.ref, acknowledgement.control)) refinement.addIssue({
|
|
1853
|
-
code: "custom",
|
|
1854
|
-
path: ["control", "refDigest"],
|
|
1855
|
-
message: "interactive stop acknowledgement control does not match its process ref"
|
|
1856
|
-
});
|
|
1857
|
-
const known = acknowledgement.effect !== "unknown";
|
|
1858
|
-
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && !known || (acknowledgement.status === "conflict" || acknowledgement.status === "unknown") && known) refinement.addIssue({
|
|
1859
|
-
code: "custom",
|
|
1860
|
-
path: ["effect"],
|
|
1861
|
-
message: "interactive stop status and effect certainty do not agree"
|
|
1862
|
-
});
|
|
1863
|
-
if (acknowledgement.status === "conflict" && (acknowledgement.existingRequestDigest === void 0 || acknowledgement.existingRequestDigest === acknowledgement.requestDigest)) refinement.addIssue({
|
|
1864
|
-
code: "custom",
|
|
1865
|
-
path: ["existingRequestDigest"],
|
|
1866
|
-
message: "an interactive stop conflict must identify a different existing request"
|
|
1867
|
-
});
|
|
1868
|
-
if (acknowledgement.status !== "conflict" && acknowledgement.existingRequestDigest !== void 0) refinement.addIssue({
|
|
1869
|
-
code: "custom",
|
|
1870
|
-
path: ["existingRequestDigest"],
|
|
1871
|
-
message: "only an interactive stop conflict may include an existing digest"
|
|
1872
|
-
});
|
|
1873
|
-
if (acknowledgement.status === "unknown" && (acknowledgement.message === void 0 || acknowledgement.retryable !== true)) refinement.addIssue({
|
|
1874
|
-
code: "custom",
|
|
1875
|
-
path: ["retryable"],
|
|
1876
|
-
message: "an unknown interactive stop outcome must explicitly permit safe same-operation retry"
|
|
1877
|
-
});
|
|
1878
|
-
});
|
|
1879
|
-
const AgentInteractiveSessionPromptCommandMaterialSchema$1 = z.strictObject({
|
|
1880
|
-
operationId: boundedIdentifierSchema,
|
|
1881
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1882
|
-
control: AgentInteractiveSessionControlClaimSchema$1,
|
|
1883
|
-
prompt: boundedEventContentStringSchema.refine((value) => value.length >= 1, { message: "interactive prompt must not be empty" })
|
|
1884
|
-
}).superRefine((command, refinement) => {
|
|
1885
|
-
if (!agentInteractiveSessionControlClaimMatchesRef$1(command.ref, command.control)) refinement.addIssue({
|
|
1886
|
-
code: "custom",
|
|
1887
|
-
path: ["control", "refDigest"],
|
|
1888
|
-
message: "interactive prompt control claim does not match its process ref"
|
|
1889
|
-
});
|
|
1890
|
-
});
|
|
1891
|
-
function agentInteractiveSessionPromptRequestDigest$1(value) {
|
|
1892
|
-
const parsed = AgentInteractiveSessionPromptCommandMaterialSchema$1.parse(value);
|
|
1893
|
-
return canonicalCandidateDigest({
|
|
1894
|
-
kind: "agent-interactive-session-prompt.v1",
|
|
1895
|
-
operationId: parsed.operationId,
|
|
1896
|
-
ref: parsed.ref,
|
|
1897
|
-
control: parsed.control,
|
|
1898
|
-
prompt: parsed.prompt
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
1901
|
-
z.strictObject({
|
|
1902
|
-
...AgentInteractiveSessionPromptCommandMaterialSchema$1.shape,
|
|
1903
|
-
requestDigest: sha256DigestSchema
|
|
1904
|
-
}).superRefine((command, refinement) => {
|
|
1905
|
-
const { requestDigest: _requestDigest, ...material } = command;
|
|
1906
|
-
if (command.requestDigest !== agentInteractiveSessionPromptRequestDigest$1(material)) refinement.addIssue({
|
|
1907
|
-
code: "custom",
|
|
1908
|
-
path: ["requestDigest"],
|
|
1909
|
-
message: "interactive session prompt request digest does not match its content"
|
|
1910
|
-
});
|
|
1911
|
-
});
|
|
1912
|
-
const AgentInteractiveSessionPromptAcknowledgementSchema$1 = z.strictObject({
|
|
1913
|
-
operationId: boundedIdentifierSchema,
|
|
1914
|
-
requestDigest: sha256DigestSchema,
|
|
1915
|
-
ref: AgentInteractiveSessionRefSchema$1,
|
|
1916
|
-
control: AgentInteractiveSessionControlClaimSchema$1,
|
|
1917
|
-
status: z.enum([
|
|
1918
|
-
"accepted",
|
|
1919
|
-
"replayed",
|
|
1920
|
-
"conflict",
|
|
1921
|
-
"unknown"
|
|
1922
|
-
]),
|
|
1923
|
-
message: boundedStringSchema.min(1).optional(),
|
|
1924
|
-
retryable: z.boolean().optional(),
|
|
1925
|
-
existingRequestDigest: sha256DigestSchema.optional()
|
|
1926
|
-
}).superRefine((acknowledgement, refinement) => {
|
|
1927
|
-
if (!agentInteractiveSessionControlClaimMatchesRef$1(acknowledgement.ref, acknowledgement.control)) refinement.addIssue({
|
|
1928
|
-
code: "custom",
|
|
1929
|
-
path: ["control", "refDigest"],
|
|
1930
|
-
message: "interactive prompt acknowledgement control claim does not match its process ref"
|
|
1931
|
-
});
|
|
1932
|
-
if (acknowledgement.status === "conflict" && (acknowledgement.existingRequestDigest === void 0 || acknowledgement.existingRequestDigest === acknowledgement.requestDigest)) refinement.addIssue({
|
|
1933
|
-
code: "custom",
|
|
1934
|
-
path: ["existingRequestDigest"],
|
|
1935
|
-
message: "an interactive prompt conflict must identify a different existing request"
|
|
1936
|
-
});
|
|
1937
|
-
if (acknowledgement.status !== "conflict" && acknowledgement.existingRequestDigest !== void 0) refinement.addIssue({
|
|
1938
|
-
code: "custom",
|
|
1939
|
-
path: ["existingRequestDigest"],
|
|
1940
|
-
message: "only an interactive prompt conflict may include an existing digest"
|
|
1941
|
-
});
|
|
1942
|
-
if (acknowledgement.status === "unknown" && (acknowledgement.message === void 0 || acknowledgement.retryable !== true)) refinement.addIssue({
|
|
1943
|
-
code: "custom",
|
|
1944
|
-
path: ["retryable"],
|
|
1945
|
-
message: "an unknown interactive prompt outcome must explicitly permit safe same-operation retry"
|
|
1946
|
-
});
|
|
1947
|
-
});
|
|
1948
|
-
//#endregion
|
|
1949
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.8.1/node_modules/@tangle-network/agent-interface/dist/native-session-event.js
|
|
4
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/native-session-event.js
|
|
1950
5
|
/**
|
|
1951
6
|
* Private adapter observation of a provider conversation or resume identity.
|
|
1952
7
|
* The adapter must obtain this ID from its bound provider process or API.
|
|
@@ -1961,7 +16,7 @@ const NativeSessionObservedEventSchema = z.object({
|
|
|
1961
16
|
nativeSessionId: z.string().min(1).max(512).regex(/^\S+$/u)
|
|
1962
17
|
}).strict();
|
|
1963
18
|
//#endregion
|
|
1964
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
19
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/environment-observation.js
|
|
1965
20
|
const ObservationProvenanceSchema = z.strictObject({
|
|
1966
21
|
origin: z.enum([
|
|
1967
22
|
"measured",
|
|
@@ -1969,7 +24,7 @@ const ObservationProvenanceSchema = z.strictObject({
|
|
|
1969
24
|
"estimated"
|
|
1970
25
|
]),
|
|
1971
26
|
observedAt: z.iso.datetime().max(64),
|
|
1972
|
-
source: boundedIdentifierSchema
|
|
27
|
+
source: boundedIdentifierSchema.optional()
|
|
1973
28
|
});
|
|
1974
29
|
/** Build a freshness-tagged observation schema around one value schema. */
|
|
1975
30
|
function observationOf(value) {
|
|
@@ -1983,25 +38,25 @@ function observationOf(value) {
|
|
|
1983
38
|
state: z.literal("stale"),
|
|
1984
39
|
value,
|
|
1985
40
|
provenance: ObservationProvenanceSchema,
|
|
1986
|
-
reason: boundedStringSchema
|
|
41
|
+
reason: boundedStringSchema.min(1)
|
|
1987
42
|
}),
|
|
1988
43
|
z.strictObject({
|
|
1989
44
|
state: z.literal("unavailable"),
|
|
1990
|
-
reason: boundedStringSchema
|
|
45
|
+
reason: boundedStringSchema.min(1)
|
|
1991
46
|
}),
|
|
1992
47
|
z.strictObject({
|
|
1993
48
|
state: z.literal("redacted"),
|
|
1994
|
-
reason: boundedStringSchema
|
|
49
|
+
reason: boundedStringSchema.min(1)
|
|
1995
50
|
}),
|
|
1996
51
|
z.strictObject({ state: z.literal("unknown") })
|
|
1997
52
|
]);
|
|
1998
53
|
}
|
|
1999
54
|
const nonNegativeNumberSchema = z.number().finite().nonnegative();
|
|
2000
55
|
const ProviderIdentitySchema = z.strictObject({
|
|
2001
|
-
provider: boundedIdentifierSchema
|
|
2002
|
-
environmentId: boundedIdentifierSchema
|
|
2003
|
-
sessionId: boundedIdentifierSchema
|
|
2004
|
-
backend: boundedIdentifierSchema
|
|
56
|
+
provider: boundedIdentifierSchema,
|
|
57
|
+
environmentId: boundedIdentifierSchema,
|
|
58
|
+
sessionId: boundedIdentifierSchema.optional(),
|
|
59
|
+
backend: boundedIdentifierSchema.optional()
|
|
2005
60
|
});
|
|
2006
61
|
const AgentEnvironmentStatusSchema = z.enum([
|
|
2007
62
|
"pending",
|
|
@@ -2047,10 +102,10 @@ const EnvironmentLifecycleSchema = z.strictObject({
|
|
|
2047
102
|
* token, or other secret, and the host and scheme reject embedded credentials.
|
|
2048
103
|
*/
|
|
2049
104
|
const SafeEndpointSchema = z.strictObject({
|
|
2050
|
-
scheme: boundedIdentifierSchema
|
|
2051
|
-
host: boundedIdentifierSchema
|
|
105
|
+
scheme: boundedIdentifierSchema.optional(),
|
|
106
|
+
host: boundedIdentifierSchema,
|
|
2052
107
|
port: z.number().int().min(1).max(65535).optional(),
|
|
2053
|
-
region: boundedIdentifierSchema
|
|
108
|
+
region: boundedIdentifierSchema.optional()
|
|
2054
109
|
}).superRefine((endpoint, refinement) => {
|
|
2055
110
|
if (/[@/\s]|:\/\//.test(endpoint.host)) refinement.addIssue({
|
|
2056
111
|
code: "custom",
|
|
@@ -2069,7 +124,7 @@ const ResourceProfileSchema = z.strictObject({
|
|
|
2069
124
|
memoryMb: z.number().int().positive().optional(),
|
|
2070
125
|
diskMb: z.number().int().positive().optional(),
|
|
2071
126
|
accelerator: z.strictObject({
|
|
2072
|
-
kind: boundedIdentifierSchema
|
|
127
|
+
kind: boundedIdentifierSchema,
|
|
2073
128
|
count: z.number().int().positive(),
|
|
2074
129
|
memoryMb: z.number().int().positive().optional()
|
|
2075
130
|
}).optional()
|
|
@@ -2089,10 +144,10 @@ const PlacementDescriptorSchema = z.strictObject({
|
|
|
2089
144
|
"fleet",
|
|
2090
145
|
"provider"
|
|
2091
146
|
]),
|
|
2092
|
-
sandboxId: boundedIdentifierSchema
|
|
2093
|
-
fleetId: boundedIdentifierSchema
|
|
2094
|
-
machineId: boundedIdentifierSchema
|
|
2095
|
-
region: boundedIdentifierSchema
|
|
147
|
+
sandboxId: boundedIdentifierSchema.optional(),
|
|
148
|
+
fleetId: boundedIdentifierSchema.optional(),
|
|
149
|
+
machineId: boundedIdentifierSchema.optional(),
|
|
150
|
+
region: boundedIdentifierSchema.optional()
|
|
2096
151
|
});
|
|
2097
152
|
/**
|
|
2098
153
|
* Token usage and cost for one execution. Bound to the shared {@link TokenUsage}
|
|
@@ -2110,20 +165,20 @@ const ModelUsageSchema = z.strictObject({
|
|
|
2110
165
|
/** Provider compute cost charged for one environment. */
|
|
2111
166
|
const ComputeBillingSchema = z.strictObject({
|
|
2112
167
|
amount: nonNegativeNumberSchema,
|
|
2113
|
-
currency: boundedIdentifierSchema
|
|
168
|
+
currency: boundedIdentifierSchema
|
|
2114
169
|
});
|
|
2115
170
|
/** Account plan, credits, quota, and billing period. */
|
|
2116
171
|
const AccountUsageSchema = z.strictObject({
|
|
2117
|
-
plan: observationOf(boundedIdentifierSchema
|
|
172
|
+
plan: observationOf(boundedIdentifierSchema).optional(),
|
|
2118
173
|
credits: observationOf(z.strictObject({
|
|
2119
174
|
remaining: nonNegativeNumberSchema,
|
|
2120
|
-
unit: boundedIdentifierSchema
|
|
175
|
+
unit: boundedIdentifierSchema
|
|
2121
176
|
})).optional(),
|
|
2122
177
|
quota: observationOf(z.strictObject({
|
|
2123
178
|
limit: nonNegativeNumberSchema,
|
|
2124
179
|
used: nonNegativeNumberSchema,
|
|
2125
180
|
remaining: nonNegativeNumberSchema,
|
|
2126
|
-
unit: boundedIdentifierSchema
|
|
181
|
+
unit: boundedIdentifierSchema
|
|
2127
182
|
})).optional(),
|
|
2128
183
|
period: observationOf(z.strictObject({
|
|
2129
184
|
start: z.iso.datetime().max(64),
|
|
@@ -2153,7 +208,7 @@ z.strictObject({
|
|
|
2153
208
|
accountUsage: AccountUsageSchema.optional()
|
|
2154
209
|
});
|
|
2155
210
|
//#endregion
|
|
2156
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
211
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-fields.js
|
|
2157
212
|
/**
|
|
2158
213
|
* Field names whose own-key form collides with object internals. A record
|
|
2159
214
|
* parser drops a raw `__proto__` key through the legacy prototype setter before
|
|
@@ -2165,12 +220,12 @@ const RESERVED_INTERACTION_FIELD_NAMES = new Set([
|
|
|
2165
220
|
"constructor",
|
|
2166
221
|
"prototype"
|
|
2167
222
|
]);
|
|
2168
|
-
const InteractionFieldNameSchema = boundedIdentifierSchema
|
|
223
|
+
const InteractionFieldNameSchema = boundedIdentifierSchema.refine((value) => !RESERVED_INTERACTION_FIELD_NAMES.has(value), "interaction field name is reserved");
|
|
2169
224
|
const FieldBase = {
|
|
2170
225
|
/** Stable key the answer is returned under in `InteractionResponse.data`. */
|
|
2171
226
|
name: InteractionFieldNameSchema,
|
|
2172
227
|
/** Human-readable label for the form control. */
|
|
2173
|
-
label: boundedStringSchema
|
|
228
|
+
label: boundedStringSchema.min(1),
|
|
2174
229
|
/** Whether the answer must supply this field to be `accepted`. */
|
|
2175
230
|
required: z.boolean().optional()
|
|
2176
231
|
};
|
|
@@ -2179,10 +234,10 @@ const InteractionFieldSchema = z.discriminatedUnion("type", [
|
|
|
2179
234
|
...FieldBase,
|
|
2180
235
|
type: z.literal("text"),
|
|
2181
236
|
multiline: z.boolean().optional(),
|
|
2182
|
-
placeholder: boundedStringSchema
|
|
237
|
+
placeholder: boundedStringSchema.optional(),
|
|
2183
238
|
/** Maximum answer length chosen by the request author. */
|
|
2184
|
-
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH
|
|
2185
|
-
default: boundedStringSchema
|
|
239
|
+
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH).optional(),
|
|
240
|
+
default: boundedStringSchema.optional()
|
|
2186
241
|
}),
|
|
2187
242
|
z.strictObject({
|
|
2188
243
|
...FieldBase,
|
|
@@ -2200,10 +255,10 @@ const InteractionFieldSchema = z.discriminatedUnion("type", [
|
|
|
2200
255
|
...FieldBase,
|
|
2201
256
|
type: z.literal("select"),
|
|
2202
257
|
options: z.array(z.strictObject({
|
|
2203
|
-
value: boundedIdentifierSchema
|
|
2204
|
-
label: boundedStringSchema
|
|
2205
|
-
description: boundedStringSchema
|
|
2206
|
-
})).min(1).max(CONTRACT_MAX_ARRAY_LENGTH
|
|
258
|
+
value: boundedIdentifierSchema,
|
|
259
|
+
label: boundedStringSchema.min(1),
|
|
260
|
+
description: boundedStringSchema.optional()
|
|
261
|
+
})).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
2207
262
|
/** When true the user may pick more than one option. */
|
|
2208
263
|
multi: z.boolean().optional(),
|
|
2209
264
|
/**
|
|
@@ -2212,14 +267,14 @@ const InteractionFieldSchema = z.discriminatedUnion("type", [
|
|
|
2212
267
|
* Write-ins must still be non-empty strings.
|
|
2213
268
|
*/
|
|
2214
269
|
allowCustom: z.boolean().optional(),
|
|
2215
|
-
default: z.array(boundedIdentifierSchema
|
|
270
|
+
default: z.array(boundedIdentifierSchema).max(CONTRACT_MAX_ARRAY_LENGTH).optional()
|
|
2216
271
|
}),
|
|
2217
272
|
z.strictObject({
|
|
2218
273
|
...FieldBase,
|
|
2219
274
|
type: z.literal("secret"),
|
|
2220
|
-
placeholder: boundedStringSchema
|
|
275
|
+
placeholder: boundedStringSchema.optional(),
|
|
2221
276
|
/** Maximum answer length chosen by the request author. */
|
|
2222
|
-
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH
|
|
277
|
+
maxLength: z.number().int().positive().max(CONTRACT_MAX_STRING_LENGTH).optional()
|
|
2223
278
|
})
|
|
2224
279
|
]).superRefine((field, context) => {
|
|
2225
280
|
if (field.type === "text" && field.default !== void 0 && field.maxLength !== void 0 && field.default.length > field.maxLength) {
|
|
@@ -2282,7 +337,7 @@ const InteractionFieldSchema = z.discriminatedUnion("type", [
|
|
|
2282
337
|
});
|
|
2283
338
|
}
|
|
2284
339
|
});
|
|
2285
|
-
const InteractionAnswerSpecSchema = z.strictObject({ fields: z.array(InteractionFieldSchema).max(CONTRACT_MAX_ARRAY_LENGTH
|
|
340
|
+
const InteractionAnswerSpecSchema = z.strictObject({ fields: z.array(InteractionFieldSchema).max(CONTRACT_MAX_ARRAY_LENGTH) }).superRefine((spec, context) => {
|
|
2286
341
|
const names = spec.fields.map((field) => field.name);
|
|
2287
342
|
if (new Set(names).size !== names.length) context.addIssue({
|
|
2288
343
|
code: "custom",
|
|
@@ -2304,9 +359,9 @@ const InteractionResponseScopeSchema = z.enum([
|
|
|
2304
359
|
"persistent"
|
|
2305
360
|
]);
|
|
2306
361
|
z.strictObject({
|
|
2307
|
-
kinds: z.array(boundedIdentifierSchema
|
|
2308
|
-
answerFieldTypes: z.array(InteractionFieldTypeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH
|
|
2309
|
-
responseScopes: z.array(InteractionResponseScopeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH
|
|
362
|
+
kinds: z.array(boundedIdentifierSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
363
|
+
answerFieldTypes: z.array(InteractionFieldTypeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
364
|
+
responseScopes: z.array(InteractionResponseScopeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
2310
365
|
secretAnswers: z.boolean(),
|
|
2311
366
|
concurrentRequests: z.boolean(),
|
|
2312
367
|
replay: z.boolean(),
|
|
@@ -2334,17 +389,17 @@ z.strictObject({
|
|
|
2334
389
|
});
|
|
2335
390
|
});
|
|
2336
391
|
//#endregion
|
|
2337
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
392
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-data.js
|
|
2338
393
|
const InteractionSecretReferenceSchema = z.strictObject({
|
|
2339
394
|
kind: z.literal("secret_handle"),
|
|
2340
|
-
handleId: boundedIdentifierSchema
|
|
395
|
+
handleId: boundedIdentifierSchema,
|
|
2341
396
|
oneUse: z.literal(true)
|
|
2342
397
|
});
|
|
2343
398
|
const InteractionDataValueSchema = z.union([
|
|
2344
|
-
boundedStringSchema
|
|
399
|
+
boundedStringSchema,
|
|
2345
400
|
z.number().finite(),
|
|
2346
401
|
z.boolean(),
|
|
2347
|
-
z.array(boundedStringSchema
|
|
402
|
+
z.array(boundedStringSchema).max(CONTRACT_MAX_ARRAY_LENGTH),
|
|
2348
403
|
InteractionSecretReferenceSchema
|
|
2349
404
|
]);
|
|
2350
405
|
/** Field values keyed by InteractionField.name. */
|
|
@@ -2379,7 +434,7 @@ const InteractionResolutionSchema = z.discriminatedUnion("outcome", [
|
|
|
2379
434
|
})
|
|
2380
435
|
]);
|
|
2381
436
|
//#endregion
|
|
2382
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
437
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-permissions.js
|
|
2383
438
|
const InteractionKind = {
|
|
2384
439
|
/** Agent asks the user to answer/choose. Answer = the chosen field values. */
|
|
2385
440
|
Question: "question",
|
|
@@ -2389,7 +444,7 @@ const InteractionKind = {
|
|
|
2389
444
|
Plan: "plan"
|
|
2390
445
|
};
|
|
2391
446
|
const wellKnownInteractionKinds = new Set(Object.values(InteractionKind));
|
|
2392
|
-
const requestedInteractionKindSchema = boundedIdentifierSchema
|
|
447
|
+
const requestedInteractionKindSchema = boundedIdentifierSchema.refine((value) => wellKnownInteractionKinds.has(value) || value.includes(".") && !value.startsWith(".") && !value.endsWith(".") && !value.includes(".."), "custom interaction kind must be namespaced");
|
|
2393
448
|
z.record(requestedInteractionKindSchema, z.boolean()).superRefine((value, context) => {
|
|
2394
449
|
if (Object.keys(value).length > 256) context.addIssue({
|
|
2395
450
|
code: z.ZodIssueCode.custom,
|
|
@@ -2406,7 +461,7 @@ const PermissionGrantSchema = z.enum([
|
|
|
2406
461
|
"deny"
|
|
2407
462
|
]);
|
|
2408
463
|
//#endregion
|
|
2409
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
464
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-answer-validation.js
|
|
2410
465
|
/**
|
|
2411
466
|
* Validate an accepted answer against its spec. Used by the broker before a
|
|
2412
467
|
* response reaches the adapter, so malformed answers are rejected centrally.
|
|
@@ -2466,7 +521,7 @@ function validateInteractionAnswer(spec, data) {
|
|
|
2466
521
|
else if (field.maxLength !== void 0 && v.length > field.maxLength) errors.push(`field "${field.name}" exceeds maxLength ${field.maxLength}`);
|
|
2467
522
|
break;
|
|
2468
523
|
case "secret": {
|
|
2469
|
-
const isHandle = typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 3 && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null) && Object.hasOwn(v, "kind") && Object.hasOwn(v, "handleId") && Object.hasOwn(v, "oneUse") && v.kind === "secret_handle" && v.oneUse === true && boundedIdentifierSchema
|
|
524
|
+
const isHandle = typeof v === "object" && v !== null && !Array.isArray(v) && Object.keys(v).length === 3 && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null) && Object.hasOwn(v, "kind") && Object.hasOwn(v, "handleId") && Object.hasOwn(v, "oneUse") && v.kind === "secret_handle" && v.oneUse === true && boundedIdentifierSchema.safeParse(v.handleId).success;
|
|
2470
525
|
if (typeof v !== "string" && !isHandle) errors.push(`field "${field.name}" must be a string or one-use secret handle`);
|
|
2471
526
|
else if (typeof v === "string" && field.maxLength !== void 0 && v.length > field.maxLength) errors.push(`field "${field.name}" exceeds maxLength ${field.maxLength}`);
|
|
2472
527
|
break;
|
|
@@ -2511,7 +566,7 @@ function validateInteractionAnswer(spec, data) {
|
|
|
2511
566
|
};
|
|
2512
567
|
}
|
|
2513
568
|
//#endregion
|
|
2514
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
569
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-resolution-validation.js
|
|
2515
570
|
/**
|
|
2516
571
|
* A declined or cancelled resolution submits no answer, so any secret-typed
|
|
2517
572
|
* field it carries can only be leakage into a transport that retains it.
|
|
@@ -2549,7 +604,7 @@ function validateResolutionForRequest(request, resolution) {
|
|
|
2549
604
|
return errors;
|
|
2550
605
|
}
|
|
2551
606
|
//#endregion
|
|
2552
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
607
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/interaction-envelope.js
|
|
2553
608
|
const interactionOutcomeValues = [
|
|
2554
609
|
"accepted",
|
|
2555
610
|
"declined",
|
|
@@ -2558,46 +613,46 @@ const interactionOutcomeValues = [
|
|
|
2558
613
|
const InteractionSubjectSchema = z.discriminatedUnion("type", [
|
|
2559
614
|
z.strictObject({
|
|
2560
615
|
type: z.literal("tool"),
|
|
2561
|
-
toolName: boundedIdentifierSchema
|
|
2562
|
-
input: boundedJsonSchema
|
|
616
|
+
toolName: boundedIdentifierSchema,
|
|
617
|
+
input: boundedJsonSchema.optional()
|
|
2563
618
|
}),
|
|
2564
619
|
z.strictObject({
|
|
2565
620
|
type: z.literal("command"),
|
|
2566
|
-
command: boundedStringSchema
|
|
621
|
+
command: boundedStringSchema
|
|
2567
622
|
}),
|
|
2568
623
|
z.strictObject({
|
|
2569
624
|
type: z.literal("file"),
|
|
2570
|
-
path: boundedStringSchema
|
|
2571
|
-
preview: boundedStringSchema
|
|
625
|
+
path: boundedStringSchema,
|
|
626
|
+
preview: boundedStringSchema.optional()
|
|
2572
627
|
}),
|
|
2573
628
|
z.strictObject({
|
|
2574
629
|
type: z.literal("resource"),
|
|
2575
|
-
uri: boundedStringSchema
|
|
630
|
+
uri: boundedStringSchema
|
|
2576
631
|
})
|
|
2577
632
|
]);
|
|
2578
633
|
const InteractionOutcomeSchema = z.enum(interactionOutcomeValues);
|
|
2579
634
|
const InteractionRequestBindingSchema = z.strictObject({
|
|
2580
|
-
runId: boundedIdentifierSchema
|
|
2581
|
-
provider: boundedIdentifierSchema
|
|
2582
|
-
environmentId: boundedIdentifierSchema
|
|
2583
|
-
sessionId: boundedIdentifierSchema
|
|
2584
|
-
executionId: boundedIdentifierSchema
|
|
2585
|
-
interactionId: boundedIdentifierSchema
|
|
635
|
+
runId: boundedIdentifierSchema,
|
|
636
|
+
provider: boundedIdentifierSchema,
|
|
637
|
+
environmentId: boundedIdentifierSchema,
|
|
638
|
+
sessionId: boundedIdentifierSchema,
|
|
639
|
+
executionId: boundedIdentifierSchema,
|
|
640
|
+
interactionId: boundedIdentifierSchema
|
|
2586
641
|
});
|
|
2587
642
|
InteractionRequestBindingSchema.omit({ interactionId: true });
|
|
2588
643
|
/** Binding carried by a response command and acknowledgement. */
|
|
2589
644
|
const InteractionBindingSchema = z.strictObject({
|
|
2590
645
|
...InteractionRequestBindingSchema.shape,
|
|
2591
|
-
requestDigest: sha256DigestSchema
|
|
646
|
+
requestDigest: sha256DigestSchema
|
|
2592
647
|
});
|
|
2593
648
|
const InteractionRequestMaterialSchema = z.strictObject({
|
|
2594
|
-
id: boundedIdentifierSchema
|
|
2595
|
-
kind: boundedIdentifierSchema
|
|
2596
|
-
title: boundedStringSchema
|
|
2597
|
-
body: boundedStringSchema
|
|
649
|
+
id: boundedIdentifierSchema,
|
|
650
|
+
kind: boundedIdentifierSchema,
|
|
651
|
+
title: boundedStringSchema.min(1),
|
|
652
|
+
body: boundedStringSchema.optional(),
|
|
2598
653
|
subject: InteractionSubjectSchema.optional(),
|
|
2599
654
|
answerSpec: InteractionAnswerSpecSchema,
|
|
2600
|
-
responseScopes: z.array(InteractionResponseScopeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH
|
|
655
|
+
responseScopes: z.array(InteractionResponseScopeSchema).min(1).max(CONTRACT_MAX_ARRAY_LENGTH).optional(),
|
|
2601
656
|
allowedOutcomes: z.array(InteractionOutcomeSchema).min(1).max(interactionOutcomeValues.length).optional(),
|
|
2602
657
|
default: InteractionResolutionSchema.optional(),
|
|
2603
658
|
timeoutMs: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
@@ -2611,7 +666,7 @@ const InteractionRequestMaterialSchema = z.strictObject({
|
|
|
2611
666
|
function interactionRequestDigest(request) {
|
|
2612
667
|
const parsed = InteractionRequestMaterialSchema.parse(request);
|
|
2613
668
|
rejectSecretDefaultValues(parsed);
|
|
2614
|
-
return canonicalCandidateDigest
|
|
669
|
+
return canonicalCandidateDigest(parsed);
|
|
2615
670
|
}
|
|
2616
671
|
function rejectSecretDefaultValues(request) {
|
|
2617
672
|
const secretFields = new Set(request.answerSpec.fields.filter((field) => field.type === "secret").map((field) => field.name));
|
|
@@ -2619,7 +674,7 @@ function rejectSecretDefaultValues(request) {
|
|
|
2619
674
|
}
|
|
2620
675
|
const InteractionRequestSchema = z.strictObject({
|
|
2621
676
|
...InteractionRequestMaterialSchema.shape,
|
|
2622
|
-
requestDigest: sha256DigestSchema
|
|
677
|
+
requestDigest: sha256DigestSchema
|
|
2623
678
|
}).superRefine((request, context) => {
|
|
2624
679
|
if (request.binding.interactionId !== request.id) context.addIssue({
|
|
2625
680
|
code: "custom",
|
|
@@ -2677,33 +732,33 @@ const InteractionRequestSchema = z.strictObject({
|
|
|
2677
732
|
});
|
|
2678
733
|
const InteractionResponseSchema = z.discriminatedUnion("outcome", [
|
|
2679
734
|
z.strictObject({
|
|
2680
|
-
id: boundedIdentifierSchema
|
|
735
|
+
id: boundedIdentifierSchema,
|
|
2681
736
|
outcome: z.literal("accepted"),
|
|
2682
737
|
data: InteractionDataSchema.optional()
|
|
2683
738
|
}),
|
|
2684
739
|
z.strictObject({
|
|
2685
|
-
id: boundedIdentifierSchema
|
|
740
|
+
id: boundedIdentifierSchema,
|
|
2686
741
|
outcome: z.literal("declined"),
|
|
2687
742
|
data: InteractionDataSchema.optional()
|
|
2688
743
|
}),
|
|
2689
744
|
z.strictObject({
|
|
2690
|
-
id: boundedIdentifierSchema
|
|
745
|
+
id: boundedIdentifierSchema,
|
|
2691
746
|
outcome: z.literal("cancelled"),
|
|
2692
747
|
data: InteractionDataSchema.optional()
|
|
2693
748
|
})
|
|
2694
749
|
]);
|
|
2695
750
|
/** Digest the exact binding and response carried by a retryable command. */
|
|
2696
751
|
function interactionResponseCommandDigest(material) {
|
|
2697
|
-
return canonicalCandidateDigest
|
|
752
|
+
return canonicalCandidateDigest({
|
|
2698
753
|
binding: InteractionBindingSchema.parse(material.binding),
|
|
2699
754
|
response: InteractionResponseSchema.parse(material.response)
|
|
2700
755
|
});
|
|
2701
756
|
}
|
|
2702
757
|
/** Retryable command sent to an environment or retained session. */
|
|
2703
758
|
const InteractionResponseCommandSchema = z.strictObject({
|
|
2704
|
-
operationId: boundedIdentifierSchema
|
|
759
|
+
operationId: boundedIdentifierSchema,
|
|
2705
760
|
binding: InteractionBindingSchema,
|
|
2706
|
-
commandDigest: sha256DigestSchema
|
|
761
|
+
commandDigest: sha256DigestSchema,
|
|
2707
762
|
response: InteractionResponseSchema
|
|
2708
763
|
}).superRefine((command, context) => {
|
|
2709
764
|
if (command.binding.interactionId !== command.response.id) context.addIssue({
|
|
@@ -2734,11 +789,11 @@ const InteractionAcknowledgementStatusSchema = z.enum([
|
|
|
2734
789
|
]);
|
|
2735
790
|
/** Durable result of one interaction response operation. */
|
|
2736
791
|
const InteractionAcknowledgementSchema = z.strictObject({
|
|
2737
|
-
operationId: boundedIdentifierSchema
|
|
792
|
+
operationId: boundedIdentifierSchema,
|
|
2738
793
|
binding: InteractionBindingSchema,
|
|
2739
|
-
commandDigest: sha256DigestSchema
|
|
794
|
+
commandDigest: sha256DigestSchema,
|
|
2740
795
|
status: InteractionAcknowledgementStatusSchema,
|
|
2741
|
-
message: boundedStringSchema
|
|
796
|
+
message: boundedStringSchema.min(1).optional(),
|
|
2742
797
|
retryable: z.boolean().optional()
|
|
2743
798
|
}).superRefine((acknowledgement, context) => {
|
|
2744
799
|
if (["invalid_response", "transport_failure"].includes(acknowledgement.status) && acknowledgement.message === void 0) context.addIssue({
|
|
@@ -2753,7 +808,7 @@ const InteractionAcknowledgementSchema = z.strictObject({
|
|
|
2753
808
|
});
|
|
2754
809
|
});
|
|
2755
810
|
//#endregion
|
|
2756
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
811
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/plan.js
|
|
2757
812
|
/**
|
|
2758
813
|
* Credential-free provider correlation committed with the plan. This union is
|
|
2759
814
|
* deliberately closed: adding plan support for another harness requires an
|
|
@@ -2818,19 +873,19 @@ const AgentExecutionOutcomeSchema = z.discriminatedUnion("type", [z.object({ typ
|
|
|
2818
873
|
plan: DurablePlanSchema
|
|
2819
874
|
}).strict()]);
|
|
2820
875
|
//#endregion
|
|
2821
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
2822
|
-
const stableIdSchema = boundedIdentifierSchema
|
|
876
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/runtime-control.js
|
|
877
|
+
const stableIdSchema = boundedIdentifierSchema;
|
|
2823
878
|
const AgentExactRunControlRefSchema = z.strictObject({
|
|
2824
879
|
runId: stableIdSchema,
|
|
2825
880
|
provider: stableIdSchema,
|
|
2826
881
|
environmentId: stableIdSchema,
|
|
2827
882
|
sessionId: stableIdSchema.optional(),
|
|
2828
883
|
executionId: stableIdSchema.optional(),
|
|
2829
|
-
requestDigest: sha256DigestSchema
|
|
884
|
+
requestDigest: sha256DigestSchema.optional()
|
|
2830
885
|
}).extend({
|
|
2831
886
|
sessionId: stableIdSchema,
|
|
2832
887
|
executionId: stableIdSchema,
|
|
2833
|
-
requestDigest: sha256DigestSchema
|
|
888
|
+
requestDigest: sha256DigestSchema
|
|
2834
889
|
});
|
|
2835
890
|
/**
|
|
2836
891
|
* Whether two references name the same run.
|
|
@@ -2841,11 +896,11 @@ const AgentExactRunControlRefSchema = z.strictObject({
|
|
|
2841
896
|
* enumerated must not read as one run.
|
|
2842
897
|
*/
|
|
2843
898
|
function sameAgentRunControlRef(left, right) {
|
|
2844
|
-
return canonicalCandidateDigest
|
|
899
|
+
return canonicalCandidateDigest(left) === canonicalCandidateDigest(right);
|
|
2845
900
|
}
|
|
2846
901
|
function agentRunCancellationRequestDigest(request) {
|
|
2847
902
|
const parsed = AgentRunCancellationRequestMaterialSchema.parse(request);
|
|
2848
|
-
return canonicalCandidateDigest
|
|
903
|
+
return canonicalCandidateDigest({
|
|
2849
904
|
operationId: parsed.operationId,
|
|
2850
905
|
run: parsed.run,
|
|
2851
906
|
...parsed.reason === void 0 ? {} : { reason: parsed.reason }
|
|
@@ -2854,11 +909,11 @@ function agentRunCancellationRequestDigest(request) {
|
|
|
2854
909
|
const AgentRunCancellationRequestMaterialSchema = z.strictObject({
|
|
2855
910
|
operationId: stableIdSchema,
|
|
2856
911
|
run: AgentExactRunControlRefSchema,
|
|
2857
|
-
reason: boundedStringSchema
|
|
912
|
+
reason: boundedStringSchema.min(1).max(2048).optional()
|
|
2858
913
|
});
|
|
2859
914
|
const AgentRunCancellationRequestSchema = z.strictObject({
|
|
2860
915
|
...AgentRunCancellationRequestMaterialSchema.shape,
|
|
2861
|
-
requestDigest: sha256DigestSchema
|
|
916
|
+
requestDigest: sha256DigestSchema
|
|
2862
917
|
}).superRefine((request, refinement) => {
|
|
2863
918
|
const { requestDigest: _requestDigest, ...material } = request;
|
|
2864
919
|
if (request.requestDigest !== agentRunCancellationRequestDigest(material)) refinement.addIssue({
|
|
@@ -2869,7 +924,7 @@ const AgentRunCancellationRequestSchema = z.strictObject({
|
|
|
2869
924
|
});
|
|
2870
925
|
const AgentRunCancellationAcknowledgementSchema = z.strictObject({
|
|
2871
926
|
operationId: stableIdSchema,
|
|
2872
|
-
requestDigest: sha256DigestSchema
|
|
927
|
+
requestDigest: sha256DigestSchema,
|
|
2873
928
|
run: AgentExactRunControlRefSchema,
|
|
2874
929
|
status: z.enum([
|
|
2875
930
|
"accepted",
|
|
@@ -2883,9 +938,9 @@ const AgentRunCancellationAcknowledgementSchema = z.strictObject({
|
|
|
2883
938
|
"not_live",
|
|
2884
939
|
"unknown"
|
|
2885
940
|
]),
|
|
2886
|
-
message: boundedStringSchema
|
|
941
|
+
message: boundedStringSchema.min(1).optional(),
|
|
2887
942
|
retryable: z.boolean().optional(),
|
|
2888
|
-
existingRequestDigest: sha256DigestSchema
|
|
943
|
+
existingRequestDigest: sha256DigestSchema.optional()
|
|
2889
944
|
}).superRefine((acknowledgement, refinement) => {
|
|
2890
945
|
const known = acknowledgement.effect !== "unknown";
|
|
2891
946
|
if ((acknowledgement.status === "accepted" || acknowledgement.status === "replayed") && !known || (acknowledgement.status === "conflict" || acknowledgement.status === "unknown") && known) refinement.addIssue({
|
|
@@ -2920,7 +975,7 @@ function agentRunCancellationAcknowledgementMatchesRequest(request, acknowledgem
|
|
|
2920
975
|
if (!exactRequest.success || !exactAcknowledgement.success) return false;
|
|
2921
976
|
return exactAcknowledgement.data.operationId === exactRequest.data.operationId && exactAcknowledgement.data.requestDigest === exactRequest.data.requestDigest && sameAgentRunControlRef(exactAcknowledgement.data.run, exactRequest.data.run);
|
|
2922
977
|
}
|
|
2923
|
-
const unknownRecordSchema = boundedJsonRecordSchema
|
|
978
|
+
const unknownRecordSchema = boundedJsonRecordSchema;
|
|
2924
979
|
const partBase = {
|
|
2925
980
|
id: stableIdSchema,
|
|
2926
981
|
sessionID: stableIdSchema,
|
|
@@ -2933,21 +988,21 @@ const toolTimeSchema = z.strictObject({
|
|
|
2933
988
|
const toolStateSchema = z.discriminatedUnion("status", [
|
|
2934
989
|
z.strictObject({
|
|
2935
990
|
status: z.literal("pending"),
|
|
2936
|
-
input: boundedEventContentRecordSchema
|
|
2937
|
-
raw: boundedEventContentStringSchema
|
|
991
|
+
input: boundedEventContentRecordSchema,
|
|
992
|
+
raw: boundedEventContentStringSchema.optional()
|
|
2938
993
|
}),
|
|
2939
994
|
z.strictObject({
|
|
2940
995
|
status: z.literal("running"),
|
|
2941
|
-
input: boundedEventContentRecordSchema
|
|
2942
|
-
title: boundedStringSchema
|
|
996
|
+
input: boundedEventContentRecordSchema,
|
|
997
|
+
title: boundedStringSchema.optional(),
|
|
2943
998
|
metadata: unknownRecordSchema.optional(),
|
|
2944
999
|
time: z.strictObject({ start: z.number().finite() }).optional()
|
|
2945
1000
|
}),
|
|
2946
1001
|
z.strictObject({
|
|
2947
1002
|
status: z.literal("completed"),
|
|
2948
|
-
input: boundedEventContentRecordSchema
|
|
2949
|
-
output: boundedEventContentJsonSchema
|
|
2950
|
-
title: boundedStringSchema
|
|
1003
|
+
input: boundedEventContentRecordSchema,
|
|
1004
|
+
output: boundedEventContentJsonSchema,
|
|
1005
|
+
title: boundedStringSchema.optional(),
|
|
2951
1006
|
metadata: unknownRecordSchema.optional(),
|
|
2952
1007
|
time: z.strictObject({
|
|
2953
1008
|
start: z.number().finite(),
|
|
@@ -2956,9 +1011,9 @@ const toolStateSchema = z.discriminatedUnion("status", [
|
|
|
2956
1011
|
}),
|
|
2957
1012
|
z.strictObject({
|
|
2958
1013
|
status: z.enum(["error", "failed"]),
|
|
2959
|
-
input: boundedEventContentRecordSchema
|
|
2960
|
-
error: boundedStringSchema
|
|
2961
|
-
output: boundedEventContentJsonSchema
|
|
1014
|
+
input: boundedEventContentRecordSchema,
|
|
1015
|
+
error: boundedStringSchema.optional(),
|
|
1016
|
+
output: boundedEventContentJsonSchema.optional(),
|
|
2962
1017
|
metadata: unknownRecordSchema.optional(),
|
|
2963
1018
|
time: toolTimeSchema.optional()
|
|
2964
1019
|
})
|
|
@@ -2967,7 +1022,7 @@ const partSchema = z.discriminatedUnion("type", [
|
|
|
2967
1022
|
z.strictObject({
|
|
2968
1023
|
...partBase,
|
|
2969
1024
|
type: z.literal("text"),
|
|
2970
|
-
text: boundedEventContentStringSchema
|
|
1025
|
+
text: boundedEventContentStringSchema
|
|
2971
1026
|
}),
|
|
2972
1027
|
z.strictObject({
|
|
2973
1028
|
...partBase,
|
|
@@ -2980,20 +1035,20 @@ const partSchema = z.discriminatedUnion("type", [
|
|
|
2980
1035
|
z.strictObject({
|
|
2981
1036
|
...partBase,
|
|
2982
1037
|
type: z.literal("reasoning"),
|
|
2983
|
-
text: boundedEventContentStringSchema
|
|
1038
|
+
text: boundedEventContentStringSchema
|
|
2984
1039
|
}),
|
|
2985
1040
|
z.strictObject({
|
|
2986
1041
|
...partBase,
|
|
2987
1042
|
type: z.literal("file"),
|
|
2988
|
-
filename: boundedStringSchema
|
|
2989
|
-
mediaType: boundedStringSchema
|
|
2990
|
-
url: boundedStringSchema
|
|
1043
|
+
filename: boundedStringSchema.optional(),
|
|
1044
|
+
mediaType: boundedStringSchema.optional(),
|
|
1045
|
+
url: boundedStringSchema.optional()
|
|
2991
1046
|
}),
|
|
2992
1047
|
z.strictObject({
|
|
2993
1048
|
...partBase,
|
|
2994
1049
|
type: z.literal("subtask"),
|
|
2995
|
-
prompt: boundedEventContentStringSchema
|
|
2996
|
-
description: boundedStringSchema
|
|
1050
|
+
prompt: boundedEventContentStringSchema,
|
|
1051
|
+
description: boundedStringSchema,
|
|
2997
1052
|
agent: stableIdSchema
|
|
2998
1053
|
})
|
|
2999
1054
|
]);
|
|
@@ -3019,7 +1074,7 @@ const ChildTaskEventSchema = z.strictObject({
|
|
|
3019
1074
|
"failed",
|
|
3020
1075
|
"cancelled"
|
|
3021
1076
|
]),
|
|
3022
|
-
title: boundedStringSchema
|
|
1077
|
+
title: boundedStringSchema.optional(),
|
|
3023
1078
|
time: z.strictObject({
|
|
3024
1079
|
started: epochMillisecondsSchema,
|
|
3025
1080
|
updated: epochMillisecondsSchema,
|
|
@@ -3028,9 +1083,9 @@ const ChildTaskEventSchema = z.strictObject({
|
|
|
3028
1083
|
runner: stableIdSchema.optional(),
|
|
3029
1084
|
model: stableIdSchema.optional(),
|
|
3030
1085
|
usage: ModelUsageSchema.optional(),
|
|
3031
|
-
terminalReason: boundedStringSchema
|
|
1086
|
+
terminalReason: boundedStringSchema.optional(),
|
|
3032
1087
|
sourceEventId: stableIdSchema,
|
|
3033
|
-
raw: boundedJsonRecordSchema
|
|
1088
|
+
raw: boundedJsonRecordSchema.optional()
|
|
3034
1089
|
}).superRefine((event, refinement) => {
|
|
3035
1090
|
const terminal = TERMINAL_CHILD_TASK_STATUSES.has(event.status);
|
|
3036
1091
|
if (!terminal && event.time.ended !== void 0) refinement.addIssue({
|
|
@@ -3063,7 +1118,7 @@ const CanonicalStreamEventSchema = z.discriminatedUnion("type", [
|
|
|
3063
1118
|
z.strictObject({
|
|
3064
1119
|
type: z.literal("message.part.updated"),
|
|
3065
1120
|
part: partSchema,
|
|
3066
|
-
delta: boundedEventContentStringSchema
|
|
1121
|
+
delta: boundedEventContentStringSchema.optional()
|
|
3067
1122
|
}),
|
|
3068
1123
|
z.strictObject({
|
|
3069
1124
|
type: z.literal("tool-heartbeat"),
|
|
@@ -3097,23 +1152,23 @@ const CanonicalStreamEventSchema = z.discriminatedUnion("type", [
|
|
|
3097
1152
|
"failed",
|
|
3098
1153
|
"cancelled"
|
|
3099
1154
|
]),
|
|
3100
|
-
detail: boundedStringSchema
|
|
1155
|
+
detail: boundedStringSchema.optional()
|
|
3101
1156
|
}),
|
|
3102
1157
|
z.strictObject({
|
|
3103
1158
|
type: z.literal("warning"),
|
|
3104
1159
|
code: stableIdSchema,
|
|
3105
|
-
message: boundedStringSchema
|
|
1160
|
+
message: boundedStringSchema
|
|
3106
1161
|
}),
|
|
3107
1162
|
z.strictObject({
|
|
3108
1163
|
type: z.literal("raw"),
|
|
3109
1164
|
backend: stableIdSchema,
|
|
3110
|
-
event: boundedEventContentJsonSchema
|
|
1165
|
+
event: boundedEventContentJsonSchema
|
|
3111
1166
|
}),
|
|
3112
1167
|
NativeSessionObservedEventSchema,
|
|
3113
1168
|
z.strictObject({
|
|
3114
1169
|
type: z.literal("session.updated"),
|
|
3115
1170
|
sessionId: stableIdSchema,
|
|
3116
|
-
title: boundedStringSchema
|
|
1171
|
+
title: boundedStringSchema.optional(),
|
|
3117
1172
|
time: z.strictObject({
|
|
3118
1173
|
created: z.number().finite().optional(),
|
|
3119
1174
|
updated: z.number().finite().optional()
|
|
@@ -3126,7 +1181,7 @@ const CanonicalStreamEventSchema = z.discriminatedUnion("type", [
|
|
|
3126
1181
|
z.strictObject({
|
|
3127
1182
|
type: z.literal("interaction.cancel"),
|
|
3128
1183
|
id: stableIdSchema,
|
|
3129
|
-
reason: boundedStringSchema
|
|
1184
|
+
reason: boundedStringSchema.optional()
|
|
3130
1185
|
}),
|
|
3131
1186
|
z.strictObject({
|
|
3132
1187
|
type: z.literal("plan.submitted"),
|
|
@@ -3134,7 +1189,7 @@ const CanonicalStreamEventSchema = z.discriminatedUnion("type", [
|
|
|
3134
1189
|
}),
|
|
3135
1190
|
ChildTaskEventSchema
|
|
3136
1191
|
]).superRefine((event, refinement) => {
|
|
3137
|
-
if (!isBoundedEventContentJson
|
|
1192
|
+
if (!isBoundedEventContentJson(event, { omitUndefinedObjectFields: true })) refinement.addIssue({
|
|
3138
1193
|
code: "custom",
|
|
3139
1194
|
message: "canonical stream event exceeds its serialized byte bound"
|
|
3140
1195
|
});
|
|
@@ -3149,18 +1204,18 @@ z.strictObject({
|
|
|
3149
1204
|
event: CanonicalStreamEventSchema
|
|
3150
1205
|
});
|
|
3151
1206
|
//#endregion
|
|
3152
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
1207
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/agent-workspace-source-snapshot.js
|
|
3153
1208
|
const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
|
|
3154
1209
|
/** Shared public identifier used by workspace lifecycle contracts. */
|
|
3155
|
-
const agentWorkspacePublicIdentifierSchema = z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isWellFormedUnicode
|
|
1210
|
+
const agentWorkspacePublicIdentifierSchema = z.string().min(1).max(500).refine((value) => value.trim().length > 0 && isWellFormedUnicode(value) && !controlCharacterPattern.test(value) && !looksLikeCredential(value), "public workspace identity cannot carry credential-like material");
|
|
3156
1211
|
const agentWorkspaceSourceSnapshotPolicySchema = z.strictObject({
|
|
3157
1212
|
kind: z.literal("provider-declared"),
|
|
3158
1213
|
name: agentWorkspacePublicIdentifierSchema,
|
|
3159
1214
|
version: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
3160
|
-
digest: sha256DigestSchema
|
|
1215
|
+
digest: sha256DigestSchema
|
|
3161
1216
|
});
|
|
3162
1217
|
//#endregion
|
|
3163
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
1218
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/agent-profile-materialization.js
|
|
3164
1219
|
/**
|
|
3165
1220
|
* The canonical AgentProfile leaves that can affect one execution.
|
|
3166
1221
|
*
|
|
@@ -3224,11 +1279,11 @@ const AGENT_PROFILE_MATERIALIZATION_AXES = [
|
|
|
3224
1279
|
value: (profile) => profile.model?.[property]
|
|
3225
1280
|
}))];
|
|
3226
1281
|
//#endregion
|
|
3227
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
1282
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/agent-execution-preparation-receipt.js
|
|
3228
1283
|
const nonBlankStringSchema = z.string().refine((value) => value.trim().length > 0, "value cannot be blank");
|
|
3229
|
-
const publicMechanismIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/, "mechanism must be a public identifier, not launch arguments").refine((value) => !looksLikeCredential
|
|
3230
|
-
const publicLifecycleIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._~:/+-]{0,499}$/, "lifecycle identity must be a public identifier").refine((value) => !looksLikeCredential
|
|
3231
|
-
const publicReasonSchema = nonBlankStringSchema.max(4e3).refine((value) => !looksLikeCredential
|
|
1284
|
+
const publicMechanismIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/, "mechanism must be a public identifier, not launch arguments").refine((value) => !looksLikeCredential(value), "mechanism cannot carry credential-like material");
|
|
1285
|
+
const publicLifecycleIdentifierSchema = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9._~:/+-]{0,499}$/, "lifecycle identity must be a public identifier").refine((value) => !looksLikeCredential(value), "lifecycle identity cannot carry credential-like material");
|
|
1286
|
+
const publicReasonSchema = nonBlankStringSchema.max(4e3).refine((value) => !looksLikeCredential(value), "reason cannot carry credential-like material");
|
|
3232
1287
|
const jsonPointerSchema = z.string().refine(isCanonicalJsonPointer, "path must be a canonical RFC 6901 JSON Pointer");
|
|
3233
1288
|
const agentExecutionPreparationAxisResultSchema = z.strictObject({
|
|
3234
1289
|
axis: z.enum(AGENT_PROFILE_MATERIALIZATION_AXES),
|
|
@@ -3240,7 +1295,7 @@ const agentExecutionPreparationAxisResultSchema = z.strictObject({
|
|
|
3240
1295
|
]),
|
|
3241
1296
|
owner: z.enum(["runtime", "executor"]),
|
|
3242
1297
|
mechanism: publicMechanismIdentifierSchema,
|
|
3243
|
-
evidenceDigest: sha256DigestSchema
|
|
1298
|
+
evidenceDigest: sha256DigestSchema.optional(),
|
|
3244
1299
|
path: jsonPointerSchema.optional(),
|
|
3245
1300
|
reason: publicReasonSchema.optional()
|
|
3246
1301
|
}).superRefine((result, context) => {
|
|
@@ -3256,7 +1311,7 @@ const agentExecutionPreparationAxisResultSchema = z.strictObject({
|
|
|
3256
1311
|
message: `${result.disposition} profile coverage cannot carry an override reason`
|
|
3257
1312
|
});
|
|
3258
1313
|
});
|
|
3259
|
-
const reasoningEffortSchema = z.enum(REASONING_EFFORTS
|
|
1314
|
+
const reasoningEffortSchema = z.enum(REASONING_EFFORTS);
|
|
3260
1315
|
const agentExecutionPreparationReasoningEffortSchema = z.strictObject({
|
|
3261
1316
|
requested: reasoningEffortSchema,
|
|
3262
1317
|
resolved: reasoningEffortSchema.optional(),
|
|
@@ -3304,11 +1359,11 @@ const agentExecutionPreparationReceiptSchema = z.strictObject({
|
|
|
3304
1359
|
kind: z.literal("agent-execution-preparation"),
|
|
3305
1360
|
schemaVersion: z.literal(1),
|
|
3306
1361
|
preparationId: nonBlankStringSchema.max(500),
|
|
3307
|
-
requestDigest: sha256DigestSchema
|
|
3308
|
-
authoredProfileDigest: sha256DigestSchema
|
|
3309
|
-
effectiveProfileDigest: sha256DigestSchema
|
|
1362
|
+
requestDigest: sha256DigestSchema,
|
|
1363
|
+
authoredProfileDigest: sha256DigestSchema,
|
|
1364
|
+
effectiveProfileDigest: sha256DigestSchema,
|
|
3310
1365
|
backend: nonBlankStringSchema.max(200),
|
|
3311
|
-
harness: harnessTypeSchema
|
|
1366
|
+
harness: harnessTypeSchema,
|
|
3312
1367
|
harnessVersion: nonBlankStringSchema.max(200),
|
|
3313
1368
|
resolvedModel: z.strictObject({
|
|
3314
1369
|
requested: z.string().max(500),
|
|
@@ -3319,21 +1374,21 @@ const agentExecutionPreparationReceiptSchema = z.strictObject({
|
|
|
3319
1374
|
workspace: z.strictObject({
|
|
3320
1375
|
leaseId: publicLifecycleIdentifierSchema,
|
|
3321
1376
|
provider: publicLifecycleIdentifierSchema,
|
|
3322
|
-
identityDigest: sha256DigestSchema
|
|
1377
|
+
identityDigest: sha256DigestSchema,
|
|
3323
1378
|
isolation: z.enum(["per-run", "shared"]),
|
|
3324
|
-
sourceSnapshotDigest: sha256DigestSchema
|
|
1379
|
+
sourceSnapshotDigest: sha256DigestSchema,
|
|
3325
1380
|
sourceSnapshotPolicy: agentWorkspaceSourceSnapshotPolicySchema,
|
|
3326
|
-
preparedWorkspaceDigest: sha256DigestSchema
|
|
3327
|
-
profileActivationDigest: sha256DigestSchema
|
|
1381
|
+
preparedWorkspaceDigest: sha256DigestSchema,
|
|
1382
|
+
profileActivationDigest: sha256DigestSchema
|
|
3328
1383
|
}),
|
|
3329
1384
|
axisResults: z.array(agentExecutionPreparationAxisResultSchema),
|
|
3330
|
-
executionPlanDigest: sha256DigestSchema
|
|
1385
|
+
executionPlanDigest: sha256DigestSchema,
|
|
3331
1386
|
materializer: z.strictObject({
|
|
3332
1387
|
name: nonBlankStringSchema.max(200),
|
|
3333
1388
|
version: nonBlankStringSchema.max(200)
|
|
3334
1389
|
}),
|
|
3335
1390
|
expiresAtMs: z.number().int().positive().safe(),
|
|
3336
|
-
digest: sha256DigestSchema
|
|
1391
|
+
digest: sha256DigestSchema
|
|
3337
1392
|
}).superRefine((receipt, context) => {
|
|
3338
1393
|
const seen = /* @__PURE__ */ new Map();
|
|
3339
1394
|
for (const [index, result] of receipt.axisResults.entries()) {
|
|
@@ -3351,11 +1406,11 @@ const agentExecutionPreparationReceiptSchema = z.strictObject({
|
|
|
3351
1406
|
message: "profile axis/path results must be canonically sorted"
|
|
3352
1407
|
});
|
|
3353
1408
|
}
|
|
3354
|
-
if (!isCanonicalJsonValue
|
|
1409
|
+
if (!isCanonicalJsonValue(receipt)) context.addIssue({
|
|
3355
1410
|
code: "custom",
|
|
3356
1411
|
message: "execution preparation receipt must contain only RFC 8785 JSON values"
|
|
3357
1412
|
});
|
|
3358
|
-
else if (canonicalCandidateDigest
|
|
1413
|
+
else if (canonicalCandidateDigest(omitTopLevelDigest(receipt)) !== receipt.digest) context.addIssue({
|
|
3359
1414
|
code: "custom",
|
|
3360
1415
|
path: ["digest"],
|
|
3361
1416
|
message: "execution preparation receipt digest is invalid"
|
|
@@ -3368,7 +1423,7 @@ function agentExecutionPreparationAxisResultKey(axis, path) {
|
|
|
3368
1423
|
/** @internal Exact public equality for preparation axis rows. */
|
|
3369
1424
|
function agentExecutionPreparationAxisResultsEqual(left, right) {
|
|
3370
1425
|
try {
|
|
3371
|
-
return canonicalCandidateJson
|
|
1426
|
+
return canonicalCandidateJson(left) === canonicalCandidateJson(right);
|
|
3372
1427
|
} catch {
|
|
3373
1428
|
return false;
|
|
3374
1429
|
}
|
|
@@ -3383,7 +1438,7 @@ function compareAgentExecutionPreparationAxisResults(left, right) {
|
|
|
3383
1438
|
return leftPath < rightPath ? -1 : leftPath > rightPath ? 1 : 0;
|
|
3384
1439
|
}
|
|
3385
1440
|
function isCanonicalJsonPointer(value) {
|
|
3386
|
-
if (!value.startsWith("/") || !isWellFormedUnicode
|
|
1441
|
+
if (!value.startsWith("/") || !isWellFormedUnicode(value)) return false;
|
|
3387
1442
|
for (let index = 0; index < value.length; index += 1) {
|
|
3388
1443
|
if (value[index] !== "~") continue;
|
|
3389
1444
|
const escape = value[index + 1];
|
|
@@ -3393,7 +1448,7 @@ function isCanonicalJsonPointer(value) {
|
|
|
3393
1448
|
return true;
|
|
3394
1449
|
}
|
|
3395
1450
|
function isDownwardReasoningClamp(requested, resolved) {
|
|
3396
|
-
return REASONING_EFFORTS
|
|
1451
|
+
return REASONING_EFFORTS.indexOf(resolved) < REASONING_EFFORTS.indexOf(requested);
|
|
3397
1452
|
}
|
|
3398
1453
|
const agentInteractiveDimensionSchema = z.number().int().positive().max(1e4);
|
|
3399
1454
|
/** @internal Compare every coordinate of two exact run references. */
|
|
@@ -3401,7 +1456,7 @@ function sameAgentExactRun(left, right) {
|
|
|
3401
1456
|
return left.runId === right.runId && left.provider === right.provider && left.environmentId === right.environmentId && left.sessionId === right.sessionId && left.executionId === right.executionId && left.requestDigest === right.requestDigest;
|
|
3402
1457
|
}
|
|
3403
1458
|
//#endregion
|
|
3404
|
-
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.
|
|
1459
|
+
//#region ../../../node_modules/.pnpm/@tangle-network+agent-interface@5.9.0/node_modules/@tangle-network/agent-interface/dist/environment-interactive-control.js
|
|
3405
1460
|
/**
|
|
3406
1461
|
* Durable identity of one coding-agent TUI.
|
|
3407
1462
|
*
|
|
@@ -3413,7 +1468,7 @@ const AgentInteractiveSessionRefSchema = z.strictObject({
|
|
|
3413
1468
|
/** Canonical executor receipt containing the effective route and its proof. */
|
|
3414
1469
|
preparationReceipt: agentExecutionPreparationReceiptSchema,
|
|
3415
1470
|
/** Provider-issued identity of this exact process incarnation. */
|
|
3416
|
-
incarnationId: boundedIdentifierSchema
|
|
1471
|
+
incarnationId: boundedIdentifierSchema,
|
|
3417
1472
|
startedAt: z.iso.datetime().max(64)
|
|
3418
1473
|
});
|
|
3419
1474
|
/**
|
|
@@ -3425,24 +1480,24 @@ const AgentInteractiveSessionRefSchema = z.strictObject({
|
|
|
3425
1480
|
*/
|
|
3426
1481
|
const AgentInteractiveSessionControlClaimSchema = z.strictObject({
|
|
3427
1482
|
/** Canonical identity of the process ref this authority can mutate. */
|
|
3428
|
-
refDigest: sha256DigestSchema
|
|
1483
|
+
refDigest: sha256DigestSchema,
|
|
3429
1484
|
/** Provider generation. A recovered coordinator must obtain a greater value. */
|
|
3430
1485
|
generation: z.number().int().positive().safe(),
|
|
3431
1486
|
/** Provider lease identity for this generation. */
|
|
3432
|
-
leaseId: boundedIdentifierSchema
|
|
1487
|
+
leaseId: boundedIdentifierSchema,
|
|
3433
1488
|
/** Stable identity of the coordinator holding this lease. */
|
|
3434
|
-
holderId: boundedIdentifierSchema
|
|
1489
|
+
holderId: boundedIdentifierSchema,
|
|
3435
1490
|
expiresAt: z.iso.datetime().max(64)
|
|
3436
1491
|
});
|
|
3437
1492
|
const AgentInteractiveSessionControlClaimRequestMaterialSchema = z.strictObject({
|
|
3438
|
-
operationId: boundedIdentifierSchema
|
|
1493
|
+
operationId: boundedIdentifierSchema,
|
|
3439
1494
|
ref: AgentInteractiveSessionRefSchema,
|
|
3440
|
-
holderId: boundedIdentifierSchema
|
|
1495
|
+
holderId: boundedIdentifierSchema,
|
|
3441
1496
|
expectedGeneration: z.number().int().nonnegative().safe()
|
|
3442
1497
|
});
|
|
3443
1498
|
function agentInteractiveSessionControlClaimRequestDigest(value) {
|
|
3444
1499
|
const parsed = AgentInteractiveSessionControlClaimRequestMaterialSchema.parse(value);
|
|
3445
|
-
return canonicalCandidateDigest
|
|
1500
|
+
return canonicalCandidateDigest({
|
|
3446
1501
|
kind: "agent-interactive-session-control-claim.v1",
|
|
3447
1502
|
operationId: parsed.operationId,
|
|
3448
1503
|
ref: parsed.ref,
|
|
@@ -3452,7 +1507,7 @@ function agentInteractiveSessionControlClaimRequestDigest(value) {
|
|
|
3452
1507
|
}
|
|
3453
1508
|
const AgentInteractiveSessionControlClaimRequestSchema = z.strictObject({
|
|
3454
1509
|
...AgentInteractiveSessionControlClaimRequestMaterialSchema.shape,
|
|
3455
|
-
requestDigest: sha256DigestSchema
|
|
1510
|
+
requestDigest: sha256DigestSchema
|
|
3456
1511
|
}).superRefine((request, refinement) => {
|
|
3457
1512
|
const { requestDigest: _requestDigest, ...material } = request;
|
|
3458
1513
|
if (request.requestDigest !== agentInteractiveSessionControlClaimRequestDigest(material)) refinement.addIssue({
|
|
@@ -3462,8 +1517,8 @@ const AgentInteractiveSessionControlClaimRequestSchema = z.strictObject({
|
|
|
3462
1517
|
});
|
|
3463
1518
|
});
|
|
3464
1519
|
const AgentInteractiveSessionControlClaimAcknowledgementSchema = z.strictObject({
|
|
3465
|
-
operationId: boundedIdentifierSchema
|
|
3466
|
-
requestDigest: sha256DigestSchema
|
|
1520
|
+
operationId: boundedIdentifierSchema,
|
|
1521
|
+
requestDigest: sha256DigestSchema,
|
|
3467
1522
|
ref: AgentInteractiveSessionRefSchema,
|
|
3468
1523
|
status: z.enum([
|
|
3469
1524
|
"accepted",
|
|
@@ -3474,8 +1529,8 @@ const AgentInteractiveSessionControlClaimAcknowledgementSchema = z.strictObject(
|
|
|
3474
1529
|
control: AgentInteractiveSessionControlClaimSchema.optional(),
|
|
3475
1530
|
conflictReason: z.enum(["generation_mismatch", "operation_reuse"]).optional(),
|
|
3476
1531
|
currentGeneration: z.number().int().nonnegative().safe().optional(),
|
|
3477
|
-
existingRequestDigest: sha256DigestSchema
|
|
3478
|
-
message: boundedStringSchema
|
|
1532
|
+
existingRequestDigest: sha256DigestSchema.optional(),
|
|
1533
|
+
message: boundedStringSchema.min(1).optional(),
|
|
3479
1534
|
retryable: z.boolean().optional()
|
|
3480
1535
|
}).superRefine((acknowledgement, refinement) => {
|
|
3481
1536
|
const hasControl = acknowledgement.control !== void 0;
|
|
@@ -3539,13 +1594,13 @@ function agentInteractiveSessionControlClaimAcknowledgementMatchesRequest(reques
|
|
|
3539
1594
|
const exactRequest = AgentInteractiveSessionControlClaimRequestSchema.safeParse(request);
|
|
3540
1595
|
const exactAcknowledgement = AgentInteractiveSessionControlClaimAcknowledgementSchema.safeParse(acknowledgement);
|
|
3541
1596
|
if (!exactRequest.success || !exactAcknowledgement.success) return false;
|
|
3542
|
-
return exactAcknowledgement.data.operationId === exactRequest.data.operationId && exactAcknowledgement.data.requestDigest === exactRequest.data.requestDigest && canonicalCandidateDigest
|
|
1597
|
+
return exactAcknowledgement.data.operationId === exactRequest.data.operationId && exactAcknowledgement.data.requestDigest === exactRequest.data.requestDigest && canonicalCandidateDigest(exactAcknowledgement.data.ref) === canonicalCandidateDigest(exactRequest.data.ref);
|
|
3543
1598
|
}
|
|
3544
1599
|
/** Bind a provider-issued control claim to the exact process it can mutate. */
|
|
3545
1600
|
function agentInteractiveSessionControlClaimMatchesRef(ref, claim) {
|
|
3546
1601
|
const parsedRef = AgentInteractiveSessionRefSchema.safeParse(ref);
|
|
3547
1602
|
const parsedClaim = AgentInteractiveSessionControlClaimSchema.safeParse(claim);
|
|
3548
|
-
return parsedRef.success && parsedClaim.success && parsedClaim.data.refDigest === canonicalCandidateDigest
|
|
1603
|
+
return parsedRef.success && parsedClaim.success && parsedClaim.data.refDigest === canonicalCandidateDigest(parsedRef.data);
|
|
3549
1604
|
}
|
|
3550
1605
|
/** Compare two claims for one process without making a provider state claim. */
|
|
3551
1606
|
function agentInteractiveSessionControlClaimIsNewer(candidate, current) {
|
|
@@ -3576,17 +1631,17 @@ const AgentInteractiveSessionStatusSchema = z.discriminatedUnion("state", [
|
|
|
3576
1631
|
"lost"
|
|
3577
1632
|
]),
|
|
3578
1633
|
exitCode: z.number().int().optional(),
|
|
3579
|
-
exitSignal: boundedStringSchema
|
|
1634
|
+
exitSignal: boundedStringSchema.min(1).optional()
|
|
3580
1635
|
}),
|
|
3581
1636
|
z.strictObject({
|
|
3582
1637
|
state: z.literal("unknown"),
|
|
3583
1638
|
ref: AgentInteractiveSessionRefSchema,
|
|
3584
|
-
message: boundedStringSchema
|
|
1639
|
+
message: boundedStringSchema.min(1),
|
|
3585
1640
|
retryable: z.boolean()
|
|
3586
1641
|
})
|
|
3587
1642
|
]);
|
|
3588
1643
|
const AgentInteractiveSessionStopCommandMaterialSchema = z.strictObject({
|
|
3589
|
-
operationId: boundedIdentifierSchema
|
|
1644
|
+
operationId: boundedIdentifierSchema,
|
|
3590
1645
|
ref: AgentInteractiveSessionRefSchema,
|
|
3591
1646
|
control: AgentInteractiveSessionControlClaimSchema
|
|
3592
1647
|
}).superRefine((command, refinement) => {
|
|
@@ -3598,7 +1653,7 @@ const AgentInteractiveSessionStopCommandMaterialSchema = z.strictObject({
|
|
|
3598
1653
|
});
|
|
3599
1654
|
function agentInteractiveSessionStopRequestDigest(value) {
|
|
3600
1655
|
const parsed = AgentInteractiveSessionStopCommandMaterialSchema.parse(value);
|
|
3601
|
-
return canonicalCandidateDigest
|
|
1656
|
+
return canonicalCandidateDigest({
|
|
3602
1657
|
kind: "agent-interactive-session-stop.v1",
|
|
3603
1658
|
operationId: parsed.operationId,
|
|
3604
1659
|
ref: parsed.ref,
|
|
@@ -3607,7 +1662,7 @@ function agentInteractiveSessionStopRequestDigest(value) {
|
|
|
3607
1662
|
}
|
|
3608
1663
|
const AgentInteractiveSessionStopCommandSchema = z.strictObject({
|
|
3609
1664
|
...AgentInteractiveSessionStopCommandMaterialSchema.shape,
|
|
3610
|
-
requestDigest: sha256DigestSchema
|
|
1665
|
+
requestDigest: sha256DigestSchema
|
|
3611
1666
|
}).superRefine((command, refinement) => {
|
|
3612
1667
|
const { requestDigest: _requestDigest, ...material } = command;
|
|
3613
1668
|
if (command.requestDigest !== agentInteractiveSessionStopRequestDigest(material)) refinement.addIssue({
|
|
@@ -3617,8 +1672,8 @@ const AgentInteractiveSessionStopCommandSchema = z.strictObject({
|
|
|
3617
1672
|
});
|
|
3618
1673
|
});
|
|
3619
1674
|
const AgentInteractiveSessionStopAcknowledgementSchema = z.strictObject({
|
|
3620
|
-
operationId: boundedIdentifierSchema
|
|
3621
|
-
requestDigest: sha256DigestSchema
|
|
1675
|
+
operationId: boundedIdentifierSchema,
|
|
1676
|
+
requestDigest: sha256DigestSchema,
|
|
3622
1677
|
ref: AgentInteractiveSessionRefSchema,
|
|
3623
1678
|
control: AgentInteractiveSessionControlClaimSchema,
|
|
3624
1679
|
status: z.enum([
|
|
@@ -3633,9 +1688,9 @@ const AgentInteractiveSessionStopAcknowledgementSchema = z.strictObject({
|
|
|
3633
1688
|
"not_live",
|
|
3634
1689
|
"unknown"
|
|
3635
1690
|
]),
|
|
3636
|
-
message: boundedStringSchema
|
|
1691
|
+
message: boundedStringSchema.min(1).optional(),
|
|
3637
1692
|
retryable: z.boolean().optional(),
|
|
3638
|
-
existingRequestDigest: sha256DigestSchema
|
|
1693
|
+
existingRequestDigest: sha256DigestSchema.optional()
|
|
3639
1694
|
}).superRefine((acknowledgement, refinement) => {
|
|
3640
1695
|
if (!agentInteractiveSessionControlClaimMatchesRef(acknowledgement.ref, acknowledgement.control)) refinement.addIssue({
|
|
3641
1696
|
code: "custom",
|
|
@@ -3668,13 +1723,13 @@ function agentInteractiveSessionStopAcknowledgementMatchesCommand(command, ackno
|
|
|
3668
1723
|
const exactCommand = AgentInteractiveSessionStopCommandSchema.safeParse(command);
|
|
3669
1724
|
const exactAcknowledgement = AgentInteractiveSessionStopAcknowledgementSchema.safeParse(acknowledgement);
|
|
3670
1725
|
if (!exactCommand.success || !exactAcknowledgement.success) return false;
|
|
3671
|
-
return exactAcknowledgement.data.operationId === exactCommand.data.operationId && exactAcknowledgement.data.requestDigest === exactCommand.data.requestDigest && canonicalCandidateDigest
|
|
1726
|
+
return exactAcknowledgement.data.operationId === exactCommand.data.operationId && exactAcknowledgement.data.requestDigest === exactCommand.data.requestDigest && canonicalCandidateDigest(exactAcknowledgement.data.ref) === canonicalCandidateDigest(exactCommand.data.ref) && canonicalCandidateDigest(exactAcknowledgement.data.control) === canonicalCandidateDigest(exactCommand.data.control);
|
|
3672
1727
|
}
|
|
3673
1728
|
const AgentInteractiveSessionPromptCommandMaterialSchema = z.strictObject({
|
|
3674
|
-
operationId: boundedIdentifierSchema
|
|
1729
|
+
operationId: boundedIdentifierSchema,
|
|
3675
1730
|
ref: AgentInteractiveSessionRefSchema,
|
|
3676
1731
|
control: AgentInteractiveSessionControlClaimSchema,
|
|
3677
|
-
prompt: boundedEventContentStringSchema
|
|
1732
|
+
prompt: boundedEventContentStringSchema.refine((value) => value.length >= 1, { message: "interactive prompt must not be empty" })
|
|
3678
1733
|
}).superRefine((command, refinement) => {
|
|
3679
1734
|
if (!agentInteractiveSessionControlClaimMatchesRef(command.ref, command.control)) refinement.addIssue({
|
|
3680
1735
|
code: "custom",
|
|
@@ -3684,7 +1739,7 @@ const AgentInteractiveSessionPromptCommandMaterialSchema = z.strictObject({
|
|
|
3684
1739
|
});
|
|
3685
1740
|
function agentInteractiveSessionPromptRequestDigest(value) {
|
|
3686
1741
|
const parsed = AgentInteractiveSessionPromptCommandMaterialSchema.parse(value);
|
|
3687
|
-
return canonicalCandidateDigest
|
|
1742
|
+
return canonicalCandidateDigest({
|
|
3688
1743
|
kind: "agent-interactive-session-prompt.v1",
|
|
3689
1744
|
operationId: parsed.operationId,
|
|
3690
1745
|
ref: parsed.ref,
|
|
@@ -3694,7 +1749,7 @@ function agentInteractiveSessionPromptRequestDigest(value) {
|
|
|
3694
1749
|
}
|
|
3695
1750
|
const AgentInteractiveSessionPromptCommandSchema = z.strictObject({
|
|
3696
1751
|
...AgentInteractiveSessionPromptCommandMaterialSchema.shape,
|
|
3697
|
-
requestDigest: sha256DigestSchema
|
|
1752
|
+
requestDigest: sha256DigestSchema
|
|
3698
1753
|
}).superRefine((command, refinement) => {
|
|
3699
1754
|
const { requestDigest: _requestDigest, ...material } = command;
|
|
3700
1755
|
if (command.requestDigest !== agentInteractiveSessionPromptRequestDigest(material)) refinement.addIssue({
|
|
@@ -3704,8 +1759,8 @@ const AgentInteractiveSessionPromptCommandSchema = z.strictObject({
|
|
|
3704
1759
|
});
|
|
3705
1760
|
});
|
|
3706
1761
|
const AgentInteractiveSessionPromptAcknowledgementSchema = z.strictObject({
|
|
3707
|
-
operationId: boundedIdentifierSchema
|
|
3708
|
-
requestDigest: sha256DigestSchema
|
|
1762
|
+
operationId: boundedIdentifierSchema,
|
|
1763
|
+
requestDigest: sha256DigestSchema,
|
|
3709
1764
|
ref: AgentInteractiveSessionRefSchema,
|
|
3710
1765
|
control: AgentInteractiveSessionControlClaimSchema,
|
|
3711
1766
|
status: z.enum([
|
|
@@ -3714,9 +1769,9 @@ const AgentInteractiveSessionPromptAcknowledgementSchema = z.strictObject({
|
|
|
3714
1769
|
"conflict",
|
|
3715
1770
|
"unknown"
|
|
3716
1771
|
]),
|
|
3717
|
-
message: boundedStringSchema
|
|
1772
|
+
message: boundedStringSchema.min(1).optional(),
|
|
3718
1773
|
retryable: z.boolean().optional(),
|
|
3719
|
-
existingRequestDigest: sha256DigestSchema
|
|
1774
|
+
existingRequestDigest: sha256DigestSchema.optional()
|
|
3720
1775
|
}).superRefine((acknowledgement, refinement) => {
|
|
3721
1776
|
if (!agentInteractiveSessionControlClaimMatchesRef(acknowledgement.ref, acknowledgement.control)) refinement.addIssue({
|
|
3722
1777
|
code: "custom",
|
|
@@ -3743,7 +1798,7 @@ function agentInteractiveSessionPromptAcknowledgementMatchesCommand(command, ack
|
|
|
3743
1798
|
const exactCommand = AgentInteractiveSessionPromptCommandSchema.safeParse(command);
|
|
3744
1799
|
const exactAcknowledgement = AgentInteractiveSessionPromptAcknowledgementSchema.safeParse(acknowledgement);
|
|
3745
1800
|
if (!exactCommand.success || !exactAcknowledgement.success) return false;
|
|
3746
|
-
return exactAcknowledgement.data.operationId === exactCommand.data.operationId && exactAcknowledgement.data.requestDigest === exactCommand.data.requestDigest && canonicalCandidateDigest
|
|
1801
|
+
return exactAcknowledgement.data.operationId === exactCommand.data.operationId && exactAcknowledgement.data.requestDigest === exactCommand.data.requestDigest && canonicalCandidateDigest(exactAcknowledgement.data.ref) === canonicalCandidateDigest(exactCommand.data.ref) && canonicalCandidateDigest(exactAcknowledgement.data.control) === canonicalCandidateDigest(exactCommand.data.control);
|
|
3747
1802
|
}
|
|
3748
1803
|
/** Prove that a status belongs to the handle that requested it. */
|
|
3749
1804
|
function agentInteractiveSessionStatusMatchesRef(ref, status) {
|
|
@@ -3757,15 +1812,15 @@ function agentInteractiveSessionStatusMatchesRef(ref, status) {
|
|
|
3757
1812
|
//#region ../../../packages/runtime-contracts/dist/interactive-session-control-http.js
|
|
3758
1813
|
const interactiveSessionStatusResponseSchema = z.object({
|
|
3759
1814
|
success: z.literal(true),
|
|
3760
|
-
data: z.object({ status: AgentInteractiveSessionStatusSchema
|
|
1815
|
+
data: z.object({ status: AgentInteractiveSessionStatusSchema }).strict()
|
|
3761
1816
|
}).strict();
|
|
3762
1817
|
const interactiveSessionControlClaimResponseSchema = z.object({
|
|
3763
1818
|
success: z.literal(true),
|
|
3764
|
-
data: AgentInteractiveSessionControlClaimAcknowledgementSchema
|
|
1819
|
+
data: AgentInteractiveSessionControlClaimAcknowledgementSchema
|
|
3765
1820
|
}).strict();
|
|
3766
1821
|
const interactiveSessionControlReleaseBodySchema = z.object({
|
|
3767
|
-
ref: AgentInteractiveSessionRefSchema
|
|
3768
|
-
control: AgentInteractiveSessionControlClaimSchema
|
|
1822
|
+
ref: AgentInteractiveSessionRefSchema,
|
|
1823
|
+
control: AgentInteractiveSessionControlClaimSchema
|
|
3769
1824
|
}).strict();
|
|
3770
1825
|
const interactiveSessionControlReleaseResponseSchema = z.object({
|
|
3771
1826
|
success: z.literal(true),
|
|
@@ -3776,8 +1831,8 @@ const interactiveSessionControlReleaseResponseSchema = z.object({
|
|
|
3776
1831
|
]) }).strict()
|
|
3777
1832
|
}).strict();
|
|
3778
1833
|
z.object({
|
|
3779
|
-
ref: AgentInteractiveSessionRefSchema
|
|
3780
|
-
control: AgentInteractiveSessionControlClaimSchema
|
|
1834
|
+
ref: AgentInteractiveSessionRefSchema,
|
|
1835
|
+
control: AgentInteractiveSessionControlClaimSchema
|
|
3781
1836
|
}).strict();
|
|
3782
1837
|
const interactiveSessionControlValidationResponseSchema = z.object({
|
|
3783
1838
|
success: z.literal(true),
|
|
@@ -4042,4 +2097,4 @@ function browserInteractiveControlHolderId(environmentId, sessionId, incarnation
|
|
|
4042
2097
|
}
|
|
4043
2098
|
}
|
|
4044
2099
|
//#endregion
|
|
4045
|
-
export {
|
|
2100
|
+
export { agentInteractiveSessionStatusMatchesRef as A, PlanContinuationSchema as B, AgentInteractiveSessionStopAcknowledgementSchema as C, agentInteractiveSessionControlClaimMatchesRef as D, agentInteractiveSessionControlClaimIsNewer as E, AgentRunCancellationAcknowledgementSchema as F, InteractionResponseSchema as G, InteractionBindingSchema as H, AgentRunCancellationRequestSchema as I, agentRunCancellationAcknowledgementMatchesRequest as L, agentInteractiveDimensionSchema as M, sameAgentExactRun as N, agentInteractiveSessionPromptAcknowledgementMatchesCommand as O, AgentExactRunControlRefSchema as P, AgentExecutionOutcomeSchema as R, AgentInteractiveSessionStatusSchema as S, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest as T, InteractionRequestSchema as U, InteractionAcknowledgementSchema as V, InteractionResponseCommandSchema as W, AgentInteractiveSessionControlClaimRequestSchema as _, INTERACTIVE_CONTROL_CLEANUP_TIMEOUT_MS as a, AgentInteractiveSessionPromptCommandSchema as b, assertInteractiveSessionRef as c, interactiveSessionControlClaimResponseSchema as d, interactiveSessionControlReleaseResponseSchema as f, AgentInteractiveSessionControlClaimAcknowledgementSchema as g, AgentInteractiveSessionAttachSchema as h, createBrowserInteractiveSessionControlTransport as i, agentInteractiveSessionStopAcknowledgementMatchesCommand as j, agentInteractiveSessionPromptRequestDigest as k, createInteractiveControlHolderId as l, interactiveSessionStatusResponseSchema as m, browserInteractiveControlHolderId as n, InteractiveSessionControlController as o, interactiveSessionControlValidationResponseSchema as p, browserInteractiveTerminalEndpoint as r, InteractiveSessionNotRunningError as s, BrowserInteractiveSessionControlController as t, interactiveSessionIdentityDigest as u, AgentInteractiveSessionControlClaimSchema as v, AgentInteractiveSessionStopCommandSchema as w, AgentInteractiveSessionRefSchema as x, AgentInteractiveSessionPromptAcknowledgementSchema as y, DurablePlanSchema as z };
|