@tangle-network/sandbox 0.30.1 → 0.30.2-develop.20260820122029.869ebfa
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/README.md +1 -0
- package/dist/abort-signal-si1WMfJb.js +31 -0
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +3 -3
- package/dist/agent-run-outcome-CM7xD7Mg.d.ts +27 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/browser-interactive-control-controller-B476gcui.d.ts +96 -0
- package/dist/browser-interactive-control-controller-wXQ7W5pT.js +276 -0
- package/dist/{client-Bg9vBEfL.js → client-BfnJ44gF.js} +29 -6
- package/dist/{client-DRV5bzRc.d.ts → client-Do_HS671.d.ts} +28 -3
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/core.d.ts +4 -4
- package/dist/core.js +2 -2
- package/dist/{index-ldDRk8Jh.d.ts → index-ebsVOlUc.d.ts} +2 -2
- package/dist/index.d.ts +11 -8
- package/dist/index.js +7 -6
- package/dist/interactive-control.d.ts +2 -0
- package/dist/interactive-control.js +2 -0
- package/dist/openai/index.d.ts +24 -2
- package/dist/openai/index.js +147 -67
- package/dist/{runtime-api-CK-4S7oA.js → runtime-api-B0tx7NJM.js} +389 -7
- package/dist/runtime.d.ts +4 -3
- package/dist/runtime.js +3 -2
- package/dist/{sandbox-4F9CNqdR.js → sandbox-AUHcCJe1.js} +1435 -784
- package/dist/{sandbox-B49ZGQv7.d.ts → sandbox-Cr-4qzaA.d.ts} +139 -194
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +1 -1
- package/dist/{tangle-CHpXtqlI.js → tangle-iDk_s8vt.js} +1 -1
- package/dist/terminal-stream-4KNJ6SmL.d.ts +256 -0
- package/dist/{types-Qn3x7R8O.d.ts → types-BwYLVqxX.d.ts} +24 -256
- package/package.json +9 -4
- /package/dist/{collaboration-COCXdRrk.js → collaboration-DQD9kCdN.js} +0 -0
- /package/dist/{errors-Bdy5jXzc.d.ts → errors-CQOvGddH.d.ts} +0 -0
- /package/dist/{index-DtRFVx5U.d.ts → index-Bq_z_u6A.d.ts} +0 -0
- /package/dist/{index-Cp1KYanB.d.ts → index-CMLW3u5K.d.ts} +0 -0
- /package/dist/{local-cli-auth-D4u7fsnH.js → local-cli-auth-CJmSpTjk.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a as NetworkError, c as QuotaError, f as TimeoutError, l as SandboxError, m as parseErrorResponse, n as CapabilityError, p as ValidationError, u as ServerError } from "./errors-C6kn-3zt.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as combineAbortSignals } from "./abort-signal-si1WMfJb.js";
|
|
3
|
+
import { AgentExactRunControlRefSchema, AgentExecutionOutcomeSchema, DurablePlanSchema, InteractionRequestSchema, agentProfileSchema, harnessTypeSchema } from "@tangle-network/agent-interface";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
//#region ../../../packages/runtime-contracts/dist/backend-types.js
|
|
5
6
|
/**
|
|
@@ -57,6 +58,392 @@ function parseBackendType(value) {
|
|
|
57
58
|
return value;
|
|
58
59
|
}
|
|
59
60
|
//#endregion
|
|
61
|
+
//#region src/agent-run-outcome-inspection.ts
|
|
62
|
+
const HUB_APPROVAL_REQUIRED = "HUB_APPROVAL_REQUIRED";
|
|
63
|
+
const MAX_SERIALIZED_TOOL_VALUE_BYTES = 4 * 1024 * 1024;
|
|
64
|
+
function parseInteraction(value) {
|
|
65
|
+
const parsed = InteractionRequestSchema.safeParse(value);
|
|
66
|
+
return parsed.success ? parsed.data : void 0;
|
|
67
|
+
}
|
|
68
|
+
function parsePlan(value) {
|
|
69
|
+
const parsed = DurablePlanSchema.safeParse(value);
|
|
70
|
+
return parsed.success ? parsed.data : void 0;
|
|
71
|
+
}
|
|
72
|
+
function parseToolInvocations(value) {
|
|
73
|
+
if (!Array.isArray(value)) return void 0;
|
|
74
|
+
const result = [];
|
|
75
|
+
for (const entry of value) {
|
|
76
|
+
const tool = plainRecord(entry);
|
|
77
|
+
const toolName = readString(tool?.toolName);
|
|
78
|
+
if (!tool || !toolName || tool.isError !== void 0 && typeof tool.isError !== "boolean") return;
|
|
79
|
+
const invocation = { toolName };
|
|
80
|
+
const input = tool.input ?? tool.arguments;
|
|
81
|
+
if (input !== void 0) {
|
|
82
|
+
const copied = copyJsonValue(input);
|
|
83
|
+
if (!copied.success) return void 0;
|
|
84
|
+
invocation.input = copied.value;
|
|
85
|
+
}
|
|
86
|
+
if (tool.result !== void 0) {
|
|
87
|
+
const copied = copyJsonValue(tool.result);
|
|
88
|
+
if (!copied.success) return void 0;
|
|
89
|
+
invocation.result = copied.value;
|
|
90
|
+
}
|
|
91
|
+
if (typeof tool.isError === "boolean") invocation.isError = tool.isError;
|
|
92
|
+
result.push(invocation);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function inspectToolOutcomes(toolInvocations) {
|
|
97
|
+
let approval;
|
|
98
|
+
for (const tool of toolInvocations ?? []) {
|
|
99
|
+
if (tool.isError !== true) continue;
|
|
100
|
+
const inspection = inspectToolResult(tool.result);
|
|
101
|
+
if (!inspection.approvalCode) continue;
|
|
102
|
+
if (approval) return { malformed: true };
|
|
103
|
+
approval = { message: inspection.message ?? "Hub action requires approval" };
|
|
104
|
+
if (inspection.approvalId) approval.approvalId = inspection.approvalId;
|
|
105
|
+
if (inspection.connectionId) approval.connectionId = inspection.connectionId;
|
|
106
|
+
}
|
|
107
|
+
const result = { malformed: false };
|
|
108
|
+
if (approval) result.approval = approval;
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
function inspectToolResult(value) {
|
|
112
|
+
let root = value;
|
|
113
|
+
if (typeof value === "string") try {
|
|
114
|
+
root = JSON.parse(value);
|
|
115
|
+
} catch {
|
|
116
|
+
return { approvalCode: false };
|
|
117
|
+
}
|
|
118
|
+
const record = plainRecord(root);
|
|
119
|
+
if (!record) return { approvalCode: false };
|
|
120
|
+
const structuredContent = plainRecord(record.structuredContent);
|
|
121
|
+
const envelope = record.code === HUB_APPROVAL_REQUIRED ? record : structuredContent?.code === HUB_APPROVAL_REQUIRED ? structuredContent : void 0;
|
|
122
|
+
if (!envelope) return { approvalCode: false };
|
|
123
|
+
const approval = plainRecord(plainRecord(envelope.details)?.approval) ?? plainRecord(envelope.approval);
|
|
124
|
+
const result = { approvalCode: true };
|
|
125
|
+
const message = readString(envelope.message);
|
|
126
|
+
const approvalId = readString(approval?.id);
|
|
127
|
+
const connectionId = readString(approval?.connectionId);
|
|
128
|
+
if (message) result.message = message;
|
|
129
|
+
if (approvalId) result.approvalId = approvalId;
|
|
130
|
+
if (connectionId) result.connectionId = connectionId;
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
/** Copy a provider value into a bounded JSON-only value safe for public output. */
|
|
134
|
+
function copyJsonValue(value) {
|
|
135
|
+
try {
|
|
136
|
+
const serialized = JSON.stringify(value);
|
|
137
|
+
if (serialized === void 0 || new TextEncoder().encode(serialized).byteLength > MAX_SERIALIZED_TOOL_VALUE_BYTES) return { success: false };
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
value: JSON.parse(serialized)
|
|
141
|
+
};
|
|
142
|
+
} catch {
|
|
143
|
+
return { success: false };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function questionFromInteraction(request) {
|
|
147
|
+
return {
|
|
148
|
+
questionId: request.id,
|
|
149
|
+
questions: request.answerSpec.fields.map((field) => field.type === "select" ? {
|
|
150
|
+
question: field.label,
|
|
151
|
+
options: field.options.map((option) => {
|
|
152
|
+
const value = { label: option.label };
|
|
153
|
+
if (option.description) value.description = option.description;
|
|
154
|
+
return value;
|
|
155
|
+
}),
|
|
156
|
+
multiSelect: field.multi === true
|
|
157
|
+
} : { question: field.label })
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function normalizeStatus(value) {
|
|
161
|
+
return readString(value)?.toLowerCase().replaceAll("-", "_");
|
|
162
|
+
}
|
|
163
|
+
function readString(value) {
|
|
164
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
165
|
+
}
|
|
166
|
+
function readError(value) {
|
|
167
|
+
if (!value) return void 0;
|
|
168
|
+
const direct = readString(value.error);
|
|
169
|
+
if (direct) return direct;
|
|
170
|
+
return readString(plainRecord(value.error)?.message) ?? readString(value.message);
|
|
171
|
+
}
|
|
172
|
+
function plainRecord(value) {
|
|
173
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
//#region src/agent-run-outcome.ts
|
|
177
|
+
const FAILURE_STATUSES = new Set([
|
|
178
|
+
"canceled",
|
|
179
|
+
"cancelled",
|
|
180
|
+
"error",
|
|
181
|
+
"errored",
|
|
182
|
+
"failed",
|
|
183
|
+
"failure",
|
|
184
|
+
"timed_out",
|
|
185
|
+
"timeout"
|
|
186
|
+
]);
|
|
187
|
+
const SUCCESS_STATUSES = new Set([
|
|
188
|
+
"completed",
|
|
189
|
+
"done",
|
|
190
|
+
"ok",
|
|
191
|
+
"success"
|
|
192
|
+
]);
|
|
193
|
+
const WAIT_STATUSES = new Map([
|
|
194
|
+
["awaiting_interaction", "interaction"],
|
|
195
|
+
["awaiting_plan_decision", "plan"],
|
|
196
|
+
["awaiting_question", "question"],
|
|
197
|
+
["blocked_on_approval", "approval"]
|
|
198
|
+
]);
|
|
199
|
+
/** Track one run and settle its outcome only after its event stream ends. */
|
|
200
|
+
function createAgentRunOutcomeTracker() {
|
|
201
|
+
const state = createOutcomeState();
|
|
202
|
+
let result;
|
|
203
|
+
return {
|
|
204
|
+
observe(event) {
|
|
205
|
+
if (result) throw new Error("Agent run outcome tracker is already finished");
|
|
206
|
+
observeEvent(state, event);
|
|
207
|
+
},
|
|
208
|
+
finish() {
|
|
209
|
+
result ??= settleOutcome(state);
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** Settle a complete in-memory event sequence with the streaming tracker. */
|
|
215
|
+
function deriveAgentRunOutcome(events) {
|
|
216
|
+
const tracker = createAgentRunOutcomeTracker();
|
|
217
|
+
for (const event of events) tracker.observe(event);
|
|
218
|
+
return tracker.finish();
|
|
219
|
+
}
|
|
220
|
+
/** Settle one completed result record without treating live result frames as terminal. */
|
|
221
|
+
function deriveAgentResultOutcome(result) {
|
|
222
|
+
const state = createOutcomeState();
|
|
223
|
+
observeOutcomeFrame(state, "result", result, true);
|
|
224
|
+
return settleOutcome(state);
|
|
225
|
+
}
|
|
226
|
+
function createOutcomeState() {
|
|
227
|
+
return {
|
|
228
|
+
terminalReached: false,
|
|
229
|
+
terminalStatuses: /* @__PURE__ */ new Set(),
|
|
230
|
+
malformed: false
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function observeEvent(state, event) {
|
|
234
|
+
try {
|
|
235
|
+
if (!event || typeof event !== "object") {
|
|
236
|
+
state.malformed = true;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const type = typeof event.type === "string" ? event.type : "";
|
|
240
|
+
const data = plainRecord(event.data);
|
|
241
|
+
if (!type || !data) {
|
|
242
|
+
state.malformed = true;
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (type === "error") {
|
|
246
|
+
state.runError ??= readError(data) ?? "Agent execution failed";
|
|
247
|
+
state.runErrorCode ??= readString(data.code);
|
|
248
|
+
}
|
|
249
|
+
if (type === "interaction") observeInteraction(state, data);
|
|
250
|
+
if (type === "interaction.cancel") observeInteractionCancel(state, data);
|
|
251
|
+
if (type === "plan.submitted") observePlan(state, data);
|
|
252
|
+
if (type === "result") observeOutcomeFrame(state, type, data, false);
|
|
253
|
+
if (type === "done") observeOutcomeFrame(state, type, data, true);
|
|
254
|
+
} catch {
|
|
255
|
+
state.malformed = true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function observeInteraction(state, data) {
|
|
259
|
+
const request = parseInteraction(data.request);
|
|
260
|
+
if (!request) {
|
|
261
|
+
state.malformed = true;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
retainInteraction(state, request);
|
|
265
|
+
}
|
|
266
|
+
function observeInteractionCancel(state, data) {
|
|
267
|
+
const id = readString(data.id);
|
|
268
|
+
if (!id) {
|
|
269
|
+
state.malformed = true;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (state.interaction?.id === id) state.interaction = void 0;
|
|
273
|
+
}
|
|
274
|
+
function observePlan(state, data) {
|
|
275
|
+
const plan = parsePlan(data.plan);
|
|
276
|
+
if (!plan) {
|
|
277
|
+
state.malformed = true;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
retainPlan(state, plan);
|
|
281
|
+
}
|
|
282
|
+
function observeOutcomeFrame(state, type, data, terminal) {
|
|
283
|
+
if (terminal) state.terminalReached = true;
|
|
284
|
+
if (data.success !== void 0 && typeof data.success !== "boolean") state.malformed = true;
|
|
285
|
+
if (typeof data.success === "boolean") {
|
|
286
|
+
if (state.terminalSuccess !== void 0 && state.terminalSuccess !== data.success) state.malformed = true;
|
|
287
|
+
state.terminalSuccess = data.success;
|
|
288
|
+
}
|
|
289
|
+
if (type === "done" || data.outcome !== void 0) {
|
|
290
|
+
if (!AgentExecutionOutcomeSchema.safeParse(data.outcome).success) state.malformed = true;
|
|
291
|
+
}
|
|
292
|
+
const outcome = plainRecord(data.outcome);
|
|
293
|
+
const nestedResult = plainRecord(data.result);
|
|
294
|
+
for (const value of [
|
|
295
|
+
data.status,
|
|
296
|
+
outcome?.type,
|
|
297
|
+
outcome?.status,
|
|
298
|
+
nestedResult?.status
|
|
299
|
+
]) {
|
|
300
|
+
if (value === void 0) continue;
|
|
301
|
+
const status = normalizeStatus(value);
|
|
302
|
+
if (status) state.terminalStatuses.add(status);
|
|
303
|
+
else state.malformed = true;
|
|
304
|
+
}
|
|
305
|
+
state.terminalError ??= readError(data) ?? readError(outcome) ?? readError(nestedResult);
|
|
306
|
+
state.terminalErrorCode ??= readString(data.errorCode) ?? readString(data.code) ?? readString(outcome?.errorCode) ?? readString(outcome?.code) ?? readString(nestedResult?.errorCode) ?? readString(nestedResult?.code);
|
|
307
|
+
const interactionCandidate = data.interaction ?? nestedResult?.interaction;
|
|
308
|
+
if (interactionCandidate !== void 0) {
|
|
309
|
+
const interaction = parseInteraction(interactionCandidate);
|
|
310
|
+
if (interaction) retainInteraction(state, interaction);
|
|
311
|
+
else state.malformed = true;
|
|
312
|
+
}
|
|
313
|
+
const planCandidate = data.plan ?? (outcome?.type === "awaiting_plan_decision" ? outcome.plan : void 0) ?? (nestedResult?.status === "awaiting_plan_decision" ? nestedResult.plan : void 0);
|
|
314
|
+
if (planCandidate !== void 0) {
|
|
315
|
+
const plan = parsePlan(planCandidate);
|
|
316
|
+
if (plan) retainPlan(state, plan);
|
|
317
|
+
else state.malformed = true;
|
|
318
|
+
}
|
|
319
|
+
const invocationCandidate = data.toolInvocations ?? nestedResult?.toolInvocations;
|
|
320
|
+
if (invocationCandidate !== void 0) {
|
|
321
|
+
const invocations = parseToolInvocations(invocationCandidate);
|
|
322
|
+
if (invocations) retainToolInvocations(state, invocations);
|
|
323
|
+
else state.malformed = true;
|
|
324
|
+
}
|
|
325
|
+
const toolOutcome = inspectToolOutcomes(state.toolInvocations);
|
|
326
|
+
if (toolOutcome.malformed) state.malformed = true;
|
|
327
|
+
state.approval = toolOutcome.approval;
|
|
328
|
+
}
|
|
329
|
+
function settleOutcome(state) {
|
|
330
|
+
const common = outcomeDetails(state);
|
|
331
|
+
if (state.runError) return failed(state.runError, state.runErrorCode, common);
|
|
332
|
+
const statusGroups = classifyStatuses(state.terminalStatuses);
|
|
333
|
+
if (statusGroups.failure) return failed(state.terminalError ?? `Agent execution ended with status ${statusGroups.failure}`, state.terminalErrorCode, common);
|
|
334
|
+
if (!state.terminalReached) return failed("Agent stream ended without a terminal event", void 0, common);
|
|
335
|
+
if (state.malformed || statusGroups.unknown || statusGroups.conflicting) return failed("Agent terminal outcome is malformed", void 0, common);
|
|
336
|
+
const wait = selectWait(state);
|
|
337
|
+
if (wait.error) return failed(wait.error, void 0, common);
|
|
338
|
+
if (statusGroups.wait && statusGroups.wait !== wait.kind) return failed("Agent terminal wait does not match its response request", void 0, common);
|
|
339
|
+
if (state.terminalSuccess === false && !wait.kind) return failed(state.terminalError ?? "Agent execution failed", state.terminalErrorCode, common);
|
|
340
|
+
if (state.terminalError && !statusGroups.wait) return failed(state.terminalError, state.terminalErrorCode, common);
|
|
341
|
+
if (wait.kind) return waitingOutcome(wait.kind, state, common);
|
|
342
|
+
return {
|
|
343
|
+
success: true,
|
|
344
|
+
status: "success",
|
|
345
|
+
...common
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
function classifyStatuses(statuses) {
|
|
349
|
+
let failure;
|
|
350
|
+
let wait;
|
|
351
|
+
let success = false;
|
|
352
|
+
let unknown = false;
|
|
353
|
+
let conflicting = false;
|
|
354
|
+
for (const status of statuses) if (FAILURE_STATUSES.has(status)) failure ??= status;
|
|
355
|
+
else if (SUCCESS_STATUSES.has(status)) success = true;
|
|
356
|
+
else if (WAIT_STATUSES.has(status)) {
|
|
357
|
+
const next = WAIT_STATUSES.get(status);
|
|
358
|
+
if (!next) continue;
|
|
359
|
+
if (wait && wait !== next) conflicting = true;
|
|
360
|
+
wait = next;
|
|
361
|
+
} else unknown = true;
|
|
362
|
+
if (failure && (wait || success)) conflicting = true;
|
|
363
|
+
return {
|
|
364
|
+
failure,
|
|
365
|
+
wait,
|
|
366
|
+
success,
|
|
367
|
+
unknown,
|
|
368
|
+
conflicting
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function selectWait(state) {
|
|
372
|
+
const kinds = [];
|
|
373
|
+
if (state.plan) kinds.push("plan");
|
|
374
|
+
if (state.approval) kinds.push("approval");
|
|
375
|
+
if (state.interaction) kinds.push(state.interaction.kind === "question" ? "question" : "interaction");
|
|
376
|
+
if (kinds.length > 1) return { error: "Agent terminal outcome contains conflicting response requests" };
|
|
377
|
+
return { kind: kinds[0] };
|
|
378
|
+
}
|
|
379
|
+
function waitingOutcome(kind, state, common) {
|
|
380
|
+
if (kind === "plan") return {
|
|
381
|
+
success: false,
|
|
382
|
+
status: "awaiting_plan_decision",
|
|
383
|
+
error: "Agent is awaiting a durable plan decision",
|
|
384
|
+
...common
|
|
385
|
+
};
|
|
386
|
+
if (kind === "approval") return {
|
|
387
|
+
success: false,
|
|
388
|
+
status: "blocked_on_approval",
|
|
389
|
+
error: state.approval?.message ?? "Agent is awaiting approval",
|
|
390
|
+
...common
|
|
391
|
+
};
|
|
392
|
+
if (kind === "question") return {
|
|
393
|
+
success: false,
|
|
394
|
+
status: "awaiting_question",
|
|
395
|
+
error: "Agent is awaiting an answer",
|
|
396
|
+
...common
|
|
397
|
+
};
|
|
398
|
+
return {
|
|
399
|
+
success: false,
|
|
400
|
+
status: "awaiting_interaction",
|
|
401
|
+
error: "Agent is awaiting a response",
|
|
402
|
+
...common
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function outcomeDetails(state) {
|
|
406
|
+
const question = state.interaction?.kind === "question" ? questionFromInteraction(state.interaction) : void 0;
|
|
407
|
+
const details = {};
|
|
408
|
+
if (state.toolInvocations) details.toolInvocations = state.toolInvocations;
|
|
409
|
+
if (state.approval) details.approval = state.approval;
|
|
410
|
+
if (state.interaction) details.interaction = state.interaction;
|
|
411
|
+
if (question) details.question = question;
|
|
412
|
+
if (state.plan) details.plan = state.plan;
|
|
413
|
+
return details;
|
|
414
|
+
}
|
|
415
|
+
function failed(error, errorCode, common) {
|
|
416
|
+
const outcome = {
|
|
417
|
+
success: false,
|
|
418
|
+
status: "failed",
|
|
419
|
+
error,
|
|
420
|
+
...common
|
|
421
|
+
};
|
|
422
|
+
if (errorCode) outcome.errorCode = errorCode;
|
|
423
|
+
return outcome;
|
|
424
|
+
}
|
|
425
|
+
function retainPlan(state, plan) {
|
|
426
|
+
if (state.plan && (state.plan.id !== plan.id || state.plan.revision !== plan.revision || state.plan.title !== plan.title || state.plan.body !== plan.body || state.plan.submittedAt !== plan.submittedAt)) {
|
|
427
|
+
state.malformed = true;
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
state.plan = plan;
|
|
431
|
+
}
|
|
432
|
+
function retainInteraction(state, interaction) {
|
|
433
|
+
if (state.interaction && state.interaction.requestDigest !== interaction.requestDigest) {
|
|
434
|
+
state.malformed = true;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
state.interaction = interaction;
|
|
438
|
+
}
|
|
439
|
+
function retainToolInvocations(state, invocations) {
|
|
440
|
+
if (state.toolInvocations && JSON.stringify(state.toolInvocations) !== JSON.stringify(invocations)) {
|
|
441
|
+
state.malformed = true;
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
state.toolInvocations = invocations;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
60
447
|
//#region src/backend-config.ts
|
|
61
448
|
function assertCurrentBackendType(value, field = "backend.type") {
|
|
62
449
|
const parsed = backendTypeSchema.safeParse(value);
|
|
@@ -137,11 +524,6 @@ function encodePromptForWire(message) {
|
|
|
137
524
|
} : part);
|
|
138
525
|
}
|
|
139
526
|
//#endregion
|
|
140
|
-
//#region src/lib/abort-signal.ts
|
|
141
|
-
function combineAbortSignals(signals) {
|
|
142
|
-
return AbortSignal.any(signals);
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
527
|
//#region ../../../packages/runtime-contracts/dist/file-limits.js
|
|
146
528
|
const MEBIBYTE$1 = 1024 * 1024;
|
|
147
529
|
10 * MEBIBYTE$1;
|
|
@@ -825,4 +1207,4 @@ function normalizeSessionInfo(raw) {
|
|
|
825
1207
|
};
|
|
826
1208
|
}
|
|
827
1209
|
//#endregion
|
|
828
|
-
export { uploadChunked as a,
|
|
1210
|
+
export { parseBackendType as _, uploadChunked as a, encodePromptForWire as c, assertCurrentBackendType as d, normalizeRuntimeBackendConfig as f, backendTypeSchema as g, deriveAgentRunOutcome as h, sessionHeaders as i, encodeTextForWire as l, deriveAgentResultOutcome as m, normalizeSessionInfo as n, SANDBOX_PROXY_REQUEST_MAX_BYTES as o, createAgentRunOutcomeTracker as p, appendSessionIdQuery as r, FILE_DECODED_WRITE_MAX_BYTES as s, SandboxRuntimeApi as t, applyRequestedModel as u };
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-
|
|
1
|
+
import { C as ChunkedUploadResult, Fi as TaskSessionCommitResult, Gn as RenameOptions, Kr as SandboxRuntimeHealth, L as CreateSessionOptions, Li as TaskSessionInfo, O as CommitTaskSessionOptions, Pi as TaskSessionChanges, Qr as SandboxTerminalRequestOptions, R as CreateTaskSessionOptions, S as ChunkedUploadOptions, St as FileWriteResult, Vr as SandboxPortBinding, Xr as SandboxTerminalInfo, Yi as UploadProgress, Yr as SandboxTerminalCreateOptions, Zr as SandboxTerminalManager, bt as FileUsageOptions, di as SentSessionMessage, dt as FileReadBatchOptions, ea as WriteFileOptions, ft as FileReadBatchResult, gi as SessionInfo, ht as FileRenameResult, li as SendSessionMessageOptions, sn as ListMessagesOptions, ui as SendSessionMessageRequest, vt as FileTreeOptions, xt as FileUsageResult, yi as SessionMessage, yt as FileTreeResult } from "./types-BwYLVqxX.js";
|
|
2
|
+
import { a as NetworkError, c as QuotaError, d as SandboxFailureDetail, f as ServerError, h as ValidationError, i as FileWriteConflictError, l as SandboxError, m as TimeoutError, n as CapabilityError, o as NotFoundError, p as StateError, s as PartialFailureError, t as AuthError, u as SandboxErrorJson } from "./errors-CQOvGddH.js";
|
|
3
|
+
import { a as deriveAgentRunOutcome, i as deriveAgentResultOutcome, n as AgentRunOutcomeTracker, r as createAgentRunOutcomeTracker, t as AgentRunOutcome } from "./agent-run-outcome-CM7xD7Mg.js";
|
|
3
4
|
|
|
4
5
|
//#region src/lib/chunked-upload.d.ts
|
|
5
6
|
/** The transport a caller wires this module to — {@link SandboxInstance.runtimeFetch}
|
|
@@ -103,4 +104,4 @@ declare class SandboxRuntimeClient extends SandboxRuntimeApi {
|
|
|
103
104
|
}
|
|
104
105
|
declare function createSandboxRuntimeClient(config: SandboxRuntimeClientConfig): SandboxRuntimeClient;
|
|
105
106
|
//#endregion
|
|
106
|
-
export { AuthError, CapabilityError, type ChunkedUploadOptions, type ChunkedUploadResult, type ChunkedUploadTransport, type FileReadBatchOptions, type FileReadBatchResult, type FileRenameResult, type FileTreeOptions, type FileTreeResult, FileWriteConflictError, type FileWriteResult, type ListMessagesOptions, NetworkError, NotFoundError, PartialFailureError, QuotaError, type RenameOptions, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, SandboxRuntimeClient, type SandboxRuntimeClientConfig, type SandboxRuntimeHealth, type SandboxTerminalCreateOptions, type SandboxTerminalInfo, type SandboxTerminalManager, type SandboxTerminalRequestOptions, ServerError, type SessionMessage, StateError, TimeoutError, type UploadProgress, ValidationError, type WriteFileOptions, createSandboxRuntimeClient, uploadChunked };
|
|
107
|
+
export { type AgentRunOutcome, type AgentRunOutcomeTracker, AuthError, CapabilityError, type ChunkedUploadOptions, type ChunkedUploadResult, type ChunkedUploadTransport, type FileReadBatchOptions, type FileReadBatchResult, type FileRenameResult, type FileTreeOptions, type FileTreeResult, FileWriteConflictError, type FileWriteResult, type ListMessagesOptions, NetworkError, NotFoundError, PartialFailureError, QuotaError, type RenameOptions, SandboxError, type SandboxErrorJson, type SandboxFailureDetail, SandboxRuntimeClient, type SandboxRuntimeClientConfig, type SandboxRuntimeHealth, type SandboxTerminalCreateOptions, type SandboxTerminalInfo, type SandboxTerminalManager, type SandboxTerminalRequestOptions, ServerError, type SessionMessage, StateError, TimeoutError, type UploadProgress, ValidationError, type WriteFileOptions, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, uploadChunked };
|
package/dist/runtime.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as uploadChunked,
|
|
1
|
+
import { a as uploadChunked, h as deriveAgentRunOutcome, m as deriveAgentResultOutcome, p as createAgentRunOutcomeTracker, t as SandboxRuntimeApi } from "./runtime-api-B0tx7NJM.js";
|
|
2
2
|
import { a as NetworkError, c as QuotaError, d as StateError, f as TimeoutError, i as FileWriteConflictError, l as SandboxError, n as CapabilityError, o as NotFoundError, p as ValidationError, s as PartialFailureError, t as AuthError, u as ServerError } from "./errors-C6kn-3zt.js";
|
|
3
|
+
import { n as combineAbortSignals } from "./abort-signal-si1WMfJb.js";
|
|
3
4
|
//#region src/runtime-client.ts
|
|
4
5
|
const DEFAULT_RUNTIME_TIMEOUT_MS = 3e4;
|
|
5
6
|
function requireToken(token) {
|
|
@@ -80,4 +81,4 @@ function createSandboxRuntimeClient(config) {
|
|
|
80
81
|
return new SandboxRuntimeClient(config);
|
|
81
82
|
}
|
|
82
83
|
//#endregion
|
|
83
|
-
export { AuthError, CapabilityError, FileWriteConflictError, NetworkError, NotFoundError, PartialFailureError, QuotaError, SandboxError, SandboxRuntimeClient, ServerError, StateError, TimeoutError, ValidationError, createSandboxRuntimeClient, uploadChunked };
|
|
84
|
+
export { AuthError, CapabilityError, FileWriteConflictError, NetworkError, NotFoundError, PartialFailureError, QuotaError, SandboxError, SandboxRuntimeClient, ServerError, StateError, TimeoutError, ValidationError, createAgentRunOutcomeTracker, createSandboxRuntimeClient, deriveAgentResultOutcome, deriveAgentRunOutcome, uploadChunked };
|