@tangle-network/agent-runtime 3.0.21 → 3.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/{activation-B4wO-9b4.js → activation-Dpu4VMIv.js} +2 -2
- package/dist/{activation-B4wO-9b4.js.map → activation-Dpu4VMIv.js.map} +1 -1
- package/dist/agent.js +3 -3
- package/dist/{coordination-manager-DlEk08FJ.js → coordination-manager-2WKCgKK1.js} +4 -4
- package/dist/{coordination-manager-DlEk08FJ.js.map → coordination-manager-2WKCgKK1.js.map} +1 -1
- package/dist/{delegate-BIQ-c7nF.js → delegate-Ck-bVGH9.js} +2 -2
- package/dist/{delegate-BIQ-c7nF.js.map → delegate-Ck-bVGH9.js.map} +1 -1
- package/dist/durable.js +6 -6
- package/dist/{graph-DBJi0DKS.js → graph-kUav_dxo.js} +5 -5
- package/dist/{graph-DBJi0DKS.js.map → graph-kUav_dxo.js.map} +1 -1
- package/dist/{improve-C0pULC3g.js → improve-DB37lfR0.js} +6 -6
- package/dist/{improve-C0pULC3g.js.map → improve-DB37lfR0.js.map} +1 -1
- package/dist/index.js +8 -8
- package/dist/intelligence.js +4 -4
- package/dist/kernel.js +11 -11
- package/dist/{loop-runner-_eBc40PI.js → loop-runner-HT5aeX5L.js} +2 -2
- package/dist/{loop-runner-_eBc40PI.js.map → loop-runner-HT5aeX5L.js.map} +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.js +5 -5
- package/dist/{provision-supervisor-btvnftdf.js → provision-supervisor-IZesCN4c.js} +4 -4
- package/dist/{provision-supervisor-btvnftdf.js.map → provision-supervisor-IZesCN4c.js.map} +1 -1
- package/dist/{run-cancellation-Hs7AFuX0.js → run-cancellation-Gzo6qxlB.js} +2 -2
- package/dist/{run-cancellation-Hs7AFuX0.js.map → run-cancellation-Gzo6qxlB.js.map} +1 -1
- package/dist/{runtime-CVUjetvL.js → runtime-D3Qd5KYv.js} +12 -12
- package/dist/{runtime-CVUjetvL.js.map → runtime-D3Qd5KYv.js.map} +1 -1
- package/dist/{scope-CB1FZOkK.js → scope-DdPWlFO4.js} +163 -199
- package/dist/scope-DdPWlFO4.js.map +1 -0
- package/dist/{search-executor-BZQRGTTw.js → search-executor-DLrVQJ4D.js} +3 -3
- package/dist/{search-executor-BZQRGTTw.js.map → search-executor-DLrVQJ4D.js.map} +1 -1
- package/dist/{server-BdqXdrJd.js → server-D2XdPLsz.js} +3 -3
- package/dist/{server-BdqXdrJd.js.map → server-D2XdPLsz.js.map} +1 -1
- package/dist/{structural-rollout-DE5ymCg4.js → structural-rollout-CfibXs4m.js} +3 -3
- package/dist/{structural-rollout-DE5ymCg4.js.map → structural-rollout-CfibXs4m.js.map} +1 -1
- package/dist/{supervise-9MPkgG8f.js → supervise-CRukjvni.js} +36 -112
- package/dist/supervise-CRukjvni.js.map +1 -0
- package/dist/{supervision-discovery-BIEJSD-c.js → supervision-discovery-B1TLSbWa.js} +2 -2
- package/dist/{supervision-discovery-BIEJSD-c.js.map → supervision-discovery-B1TLSbWa.js.map} +1 -1
- package/dist/{supervisor-OHBlhBoh.js → supervisor-NnjJHuaL.js} +127 -36
- package/dist/supervisor-NnjJHuaL.js.map +1 -0
- package/dist/testing.js +11 -11
- package/dist/{top-web-BYNStdNM.js → top-web-BIlf2fbe.js} +4 -4
- package/dist/{top-web-BYNStdNM.js.map → top-web-BIlf2fbe.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.js +2 -2
- package/package.json +1 -1
- package/dist/scope-CB1FZOkK.js.map +0 -1
- package/dist/supervise-9MPkgG8f.js.map +0 -1
- package/dist/supervisor-OHBlhBoh.js.map +0 -1
|
@@ -98,6 +98,147 @@ function promptPartFromInputPart(part) {
|
|
|
98
98
|
url: part.url
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
+
// src/runtime/supervise/abortable.ts
|
|
102
|
+
/** Provenance of an explicit cancellation, preserved through every abort link. */
|
|
103
|
+
var RunCancellationReason = class extends Error {
|
|
104
|
+
source;
|
|
105
|
+
operationId;
|
|
106
|
+
operator;
|
|
107
|
+
constructor(source, reason, operationId, operator) {
|
|
108
|
+
super(reason);
|
|
109
|
+
this.source = source;
|
|
110
|
+
this.operationId = operationId;
|
|
111
|
+
this.operator = operator;
|
|
112
|
+
this.name = "RunCancellationReason";
|
|
113
|
+
}
|
|
114
|
+
toString() {
|
|
115
|
+
return this.message;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* One abort race, and one abort cascade, for the supervision tree.
|
|
120
|
+
*
|
|
121
|
+
* Every layer that can be cancelled needs the same three things: the reason a signal
|
|
122
|
+
* carries, an `AbortError` built from it, and a settle-once race between the work and
|
|
123
|
+
* the signal. Written per layer, each drifts — a listener stops being removed on one
|
|
124
|
+
* path, a late resolution overwrites a cancellation that already won, or a cascade
|
|
125
|
+
* forwards no reason and renames every downstream death to the layer's own fallback.
|
|
126
|
+
*
|
|
127
|
+
* The fallback message is the only thing a layer supplies, so the error still names
|
|
128
|
+
* which layer cancelled.
|
|
129
|
+
*/
|
|
130
|
+
/**
|
|
131
|
+
* The reason a signal carries, or `fallback` when it states none.
|
|
132
|
+
*
|
|
133
|
+
* A cascade that drops the upstream reason turns every downstream death into its own generic
|
|
134
|
+
* message: the worker's `down` record then says nothing about WHY, which makes a whole class of
|
|
135
|
+
* child mortality undiagnosable from the journal alone.
|
|
136
|
+
*/
|
|
137
|
+
function abortReason(signal, fallback) {
|
|
138
|
+
const reason = signal.reason;
|
|
139
|
+
if (reason instanceof RunCancellationReason) return reason;
|
|
140
|
+
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
141
|
+
if (reason instanceof Error && reason.name !== "AbortError" && reason.message.length > 0) return reason.message;
|
|
142
|
+
return fallback;
|
|
143
|
+
}
|
|
144
|
+
/** An `AbortError` carrying the signal's own string reason, or `fallback` when it states none. */
|
|
145
|
+
function signalAbortError(signal, fallback) {
|
|
146
|
+
const reason = abortReason(signal, fallback);
|
|
147
|
+
const error = new Error(reason instanceof Error ? reason.message : typeof reason === "string" && reason.length > 0 ? reason : fallback);
|
|
148
|
+
error.name = "AbortError";
|
|
149
|
+
return error;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Cascade N abort signals into one downstream abort that fires when ANY of them does, carrying
|
|
153
|
+
* that signal's own reason ({@link abortReason}). Node-portable: `AbortSignal.any` needs >=20.3
|
|
154
|
+
* and the package floor is >=20, and it would drop the reason anyway.
|
|
155
|
+
*
|
|
156
|
+
* The one cascade every executor uses, so a reason forwarded here reaches every layer below.
|
|
157
|
+
*/
|
|
158
|
+
function linkAbort(...sources) {
|
|
159
|
+
const controller = new AbortController();
|
|
160
|
+
const listeners = [];
|
|
161
|
+
const release = () => {
|
|
162
|
+
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
163
|
+
listeners.length = 0;
|
|
164
|
+
};
|
|
165
|
+
const abort = (reason) => {
|
|
166
|
+
release();
|
|
167
|
+
controller.abort(reason);
|
|
168
|
+
};
|
|
169
|
+
const alreadyAborted = sources.find((source) => source.aborted);
|
|
170
|
+
if (alreadyAborted !== void 0) {
|
|
171
|
+
controller.abort(abortReason(alreadyAborted, "aborted by parent scope"));
|
|
172
|
+
return {
|
|
173
|
+
signal: controller.signal,
|
|
174
|
+
abort,
|
|
175
|
+
release
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
for (const source of sources) {
|
|
179
|
+
const onAbort = () => abort(abortReason(source, "aborted by parent scope"));
|
|
180
|
+
listeners.push({
|
|
181
|
+
source,
|
|
182
|
+
onAbort
|
|
183
|
+
});
|
|
184
|
+
source.addEventListener("abort", onAbort, { once: true });
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
signal: controller.signal,
|
|
188
|
+
abort,
|
|
189
|
+
release
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Settle `act()` against `signal`. The first outcome wins and the listener is always
|
|
194
|
+
* removed, so neither a late resolution nor a late abort can settle the promise twice.
|
|
195
|
+
* The losing promise stays observed, so a late rejection cannot surface as an unhandled
|
|
196
|
+
* process error.
|
|
197
|
+
*
|
|
198
|
+
* The abort rejection is deferred one microtask so a result the action had ALREADY
|
|
199
|
+
* produced still wins. It does not hand the race to a listener the action registers
|
|
200
|
+
* from inside `act()`: this function subscribes before it calls `act()`, so its own
|
|
201
|
+
* abort handler runs first and settles the promise. A caller that must let the action
|
|
202
|
+
* observe the abort itself has to hold a live promise and await that instead.
|
|
203
|
+
*
|
|
204
|
+
* A synchronous throw from `act()` propagates as the rejection, not as an abort.
|
|
205
|
+
*/
|
|
206
|
+
async function runAbortable(act, signal, fallback) {
|
|
207
|
+
const aborted = () => typeof fallback === "string" ? signalAbortError(signal, fallback) : fallback();
|
|
208
|
+
if (signal.aborted) throw aborted();
|
|
209
|
+
return await new Promise((resolve, reject) => {
|
|
210
|
+
let settled = false;
|
|
211
|
+
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
212
|
+
const onAbort = () => {
|
|
213
|
+
queueMicrotask(() => {
|
|
214
|
+
if (settled) return;
|
|
215
|
+
settled = true;
|
|
216
|
+
cleanup();
|
|
217
|
+
reject(aborted());
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
221
|
+
let work;
|
|
222
|
+
try {
|
|
223
|
+
work = Promise.resolve(act());
|
|
224
|
+
} catch (error) {
|
|
225
|
+
cleanup();
|
|
226
|
+
reject(error);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
work.then((value) => {
|
|
230
|
+
if (settled) return;
|
|
231
|
+
settled = true;
|
|
232
|
+
cleanup();
|
|
233
|
+
resolve(value);
|
|
234
|
+
}, (error) => {
|
|
235
|
+
if (settled) return;
|
|
236
|
+
settled = true;
|
|
237
|
+
cleanup();
|
|
238
|
+
reject(error);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
101
242
|
// src/runtime/retained-run-binding.ts
|
|
102
243
|
function exactSession(environment, controlRef) {
|
|
103
244
|
if (environment.id !== controlRef.environmentId || environment.provider !== controlRef.provider) throw new Error("provider reconstructed a different retained environment");
|
|
@@ -171,13 +312,7 @@ function cancellationRequest(controlRef, operationId, reason) {
|
|
|
171
312
|
}
|
|
172
313
|
async function exactSessionCancel(session, request, options) {
|
|
173
314
|
if (!session.cancelRun) throw new Error("provider session does not expose durable cancellation operations");
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
acknowledgement = await awaitAbortable$1(Promise.resolve().then(() => session.cancelRun(request, options)), options.signal);
|
|
177
|
-
} catch (error) {
|
|
178
|
-
if (error instanceof RetainedRunProviderContractError) throw error;
|
|
179
|
-
throw error;
|
|
180
|
-
}
|
|
315
|
+
const acknowledgement = await awaitAbortable$1(Promise.resolve().then(() => session.cancelRun(request, options)), options.signal);
|
|
181
316
|
let exactAcknowledgement;
|
|
182
317
|
try {
|
|
183
318
|
exactAcknowledgement = AgentRunCancellationAcknowledgementSchema.parse(acknowledgement);
|
|
@@ -192,34 +327,8 @@ function hasDurableCancel(session) {
|
|
|
192
327
|
}
|
|
193
328
|
async function awaitAbortable$1(work, signal) {
|
|
194
329
|
if (signal === void 0) return await work;
|
|
195
|
-
if (signal.aborted)
|
|
196
|
-
|
|
197
|
-
throw abortError(signal.reason);
|
|
198
|
-
}
|
|
199
|
-
return await new Promise((resolve, reject) => {
|
|
200
|
-
let settled = false;
|
|
201
|
-
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
202
|
-
const onAbort = () => {
|
|
203
|
-
queueMicrotask(() => {
|
|
204
|
-
if (settled) return;
|
|
205
|
-
settled = true;
|
|
206
|
-
cleanup();
|
|
207
|
-
reject(abortError(signal.reason));
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
211
|
-
Promise.resolve(work).then((value) => {
|
|
212
|
-
if (settled) return;
|
|
213
|
-
settled = true;
|
|
214
|
-
cleanup();
|
|
215
|
-
resolve(value);
|
|
216
|
-
}, (error) => {
|
|
217
|
-
if (settled) return;
|
|
218
|
-
settled = true;
|
|
219
|
-
cleanup();
|
|
220
|
-
reject(error);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
330
|
+
if (signal.aborted) Promise.resolve(work).catch(() => void 0);
|
|
331
|
+
return await runAbortable(() => Promise.resolve(work), signal, () => abortError(signal.reason));
|
|
223
332
|
}
|
|
224
333
|
async function exactSessionResult(session) {
|
|
225
334
|
return session.result();
|
|
@@ -2633,7 +2742,10 @@ const UNAVAILABLE_CODES = /* @__PURE__ */ new Set([
|
|
|
2633
2742
|
"provider_key_invalid",
|
|
2634
2743
|
"rate_limit_exceeded",
|
|
2635
2744
|
"rate_limit_error",
|
|
2636
|
-
"overloaded_error"
|
|
2745
|
+
"overloaded_error",
|
|
2746
|
+
"capacity_exhausted",
|
|
2747
|
+
"host_pressure",
|
|
2748
|
+
"provisioning_paused"
|
|
2637
2749
|
]);
|
|
2638
2750
|
/** 429 Too Many Requests, 503 Service Unavailable, and 529, which Anthropic uses for overload. */
|
|
2639
2751
|
const UNAVAILABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -2653,13 +2765,23 @@ function unavailableSignalInText(text) {
|
|
|
2653
2765
|
return status !== void 0 && UNAVAILABLE_STATUSES.has(Number(status)) ? `http-${status}` : void 0;
|
|
2654
2766
|
}
|
|
2655
2767
|
/**
|
|
2768
|
+
* Sandbox's 409 `NO_HOST_FITS_SHAPE` for a shape that fits its host's ceiling: no exceeded
|
|
2769
|
+
* dimension, only `its room is held placeable on <sku>`. It is sent by mistake for "no room now"
|
|
2770
|
+
* while new hosts cannot be planned, and the create lands within one autoscaler purchase. Four
|
|
2771
|
+
* nodes of Discovery run magnetar-rust-sandbox-20261101a went down on it. A shape over the ceiling
|
|
2772
|
+
* names the dimension it exceeds instead, and stays refused.
|
|
2773
|
+
*/
|
|
2774
|
+
const HELD_ROOM_REFUSAL = /\bits room is held placeable\b/u;
|
|
2775
|
+
/**
|
|
2656
2776
|
* The code or status that marks a failed turn outcome as an upstream capacity refusal, or
|
|
2657
|
-
* `undefined`. The outcome's own `errorCode` decides first
|
|
2658
|
-
* code or numeric status decided, because a harness CLI can
|
|
2777
|
+
* `undefined`. The outcome's own `errorCode` decides first, with Sandbox's held-room text beside its
|
|
2778
|
+
* code; other text is read only when no code or numeric status decided, because a harness CLI can
|
|
2779
|
+
* report the router's refusal as text.
|
|
2659
2780
|
*/
|
|
2660
2781
|
function unavailableSignalOfFailure(failure) {
|
|
2661
2782
|
const code = failure.errorCode?.toLowerCase();
|
|
2662
2783
|
if (code !== void 0 && UNAVAILABLE_CODES.has(code)) return code;
|
|
2784
|
+
if (code === "no_host_fits_shape" && HELD_ROOM_REFUSAL.test(failure.error)) return "host-room-held";
|
|
2663
2785
|
if (failure.statusCode !== void 0) return UNAVAILABLE_STATUSES.has(failure.statusCode) ? `http-${failure.statusCode}` : void 0;
|
|
2664
2786
|
return unavailableSignalInText(failure.error);
|
|
2665
2787
|
}
|
|
@@ -2947,7 +3069,6 @@ function prepareRetainedExecutor(factory, input) {
|
|
|
2947
3069
|
}
|
|
2948
3070
|
// src/runtime/failure-cause.ts
|
|
2949
3071
|
const MAX_CAUSE_CHARS = 2048;
|
|
2950
|
-
const MAX_CHAIN_STEPS = 12;
|
|
2951
3072
|
const MACHINE_CODE_PATTERN = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
|
|
2952
3073
|
/** @internal Canonical producer-supplied remediation, shared by transport and read models. */
|
|
2953
3074
|
const runtimeFailureRemediationSchema = z.object({
|
|
@@ -3024,23 +3145,6 @@ function read(value, key) {
|
|
|
3024
3145
|
return;
|
|
3025
3146
|
}
|
|
3026
3147
|
}
|
|
3027
|
-
/** Every object in a failure's cause chain and aggregate members, bounded and cycle-safe. */
|
|
3028
|
-
function chain(error) {
|
|
3029
|
-
const out = [];
|
|
3030
|
-
const queue = [error];
|
|
3031
|
-
while (queue.length > 0 && out.length < MAX_CHAIN_STEPS) {
|
|
3032
|
-
const value = queue.shift();
|
|
3033
|
-
if (typeof value !== "object" || value === null || out.includes(value)) continue;
|
|
3034
|
-
out.push(value);
|
|
3035
|
-
const members = read(value, "errors");
|
|
3036
|
-
if (Array.isArray(members)) {
|
|
3037
|
-
const limit = Math.min(members.length, MAX_CHAIN_STEPS);
|
|
3038
|
-
for (let index = 0; index < limit; index++) queue.push(read(members, String(index)));
|
|
3039
|
-
}
|
|
3040
|
-
queue.push(read(value, "cause"));
|
|
3041
|
-
}
|
|
3042
|
-
return out;
|
|
3043
|
-
}
|
|
3044
3148
|
const UNATTRIBUTED = {
|
|
3045
3149
|
code: "unknown",
|
|
3046
3150
|
owner: "unknown"
|
|
@@ -3132,7 +3236,7 @@ function runtimeFailureCause(error, context = {}) {
|
|
|
3132
3236
|
const cause = errMessage(error).slice(0, MAX_CAUSE_CHARS);
|
|
3133
3237
|
const caller = context.signal?.aborted ? "aborted" : context.deadlineExpired ? "deadline-exceeded" : void 0;
|
|
3134
3238
|
try {
|
|
3135
|
-
const links =
|
|
3239
|
+
const links = causeChain(error);
|
|
3136
3240
|
const providerCode = upstreamMachineCode(links);
|
|
3137
3241
|
const upstream = links.find((link) => link instanceof BackendTransportError && link.backend === "bridge" && link.status === 403 && link.upstreamCode === "subscription_required" && link.providerDispatch === "not_started");
|
|
3138
3242
|
const remedy = runtimeFailureRemediationSchema.readonly().safeParse(upstream?.remediation);
|
|
@@ -3655,146 +3759,6 @@ function providerAttemptEvidence(model) {
|
|
|
3655
3759
|
models
|
|
3656
3760
|
});
|
|
3657
3761
|
}
|
|
3658
|
-
// src/runtime/supervise/abortable.ts
|
|
3659
|
-
/** Provenance of an explicit cancellation, preserved through every abort link. */
|
|
3660
|
-
var RunCancellationReason = class extends Error {
|
|
3661
|
-
source;
|
|
3662
|
-
operationId;
|
|
3663
|
-
operator;
|
|
3664
|
-
constructor(source, reason, operationId, operator) {
|
|
3665
|
-
super(reason);
|
|
3666
|
-
this.source = source;
|
|
3667
|
-
this.operationId = operationId;
|
|
3668
|
-
this.operator = operator;
|
|
3669
|
-
this.name = "RunCancellationReason";
|
|
3670
|
-
}
|
|
3671
|
-
toString() {
|
|
3672
|
-
return this.message;
|
|
3673
|
-
}
|
|
3674
|
-
};
|
|
3675
|
-
/**
|
|
3676
|
-
* One abort race, and one abort cascade, for the supervision tree.
|
|
3677
|
-
*
|
|
3678
|
-
* Every layer that can be cancelled needs the same three things: the reason a signal
|
|
3679
|
-
* carries, an `AbortError` built from it, and a settle-once race between the work and
|
|
3680
|
-
* the signal. Written per layer, each drifts — a listener stops being removed on one
|
|
3681
|
-
* path, a late resolution overwrites a cancellation that already won, or a cascade
|
|
3682
|
-
* forwards no reason and renames every downstream death to the layer's own fallback.
|
|
3683
|
-
*
|
|
3684
|
-
* The fallback message is the only thing a layer supplies, so the error still names
|
|
3685
|
-
* which layer cancelled.
|
|
3686
|
-
*/
|
|
3687
|
-
/**
|
|
3688
|
-
* The reason a signal carries, or `fallback` when it states none.
|
|
3689
|
-
*
|
|
3690
|
-
* A cascade that drops the upstream reason turns every downstream death into its own generic
|
|
3691
|
-
* message: the worker's `down` record then says nothing about WHY, which makes a whole class of
|
|
3692
|
-
* child mortality undiagnosable from the journal alone.
|
|
3693
|
-
*/
|
|
3694
|
-
function abortReason(signal, fallback) {
|
|
3695
|
-
const reason = signal.reason;
|
|
3696
|
-
if (reason instanceof RunCancellationReason) return reason;
|
|
3697
|
-
if (typeof reason === "string" && reason.length > 0) return reason;
|
|
3698
|
-
if (reason instanceof Error && reason.name !== "AbortError" && reason.message.length > 0) return reason.message;
|
|
3699
|
-
return fallback;
|
|
3700
|
-
}
|
|
3701
|
-
/** An `AbortError` carrying the signal's own string reason, or `fallback` when it states none. */
|
|
3702
|
-
function signalAbortError(signal, fallback) {
|
|
3703
|
-
const reason = abortReason(signal, fallback);
|
|
3704
|
-
const error = new Error(reason instanceof Error ? reason.message : typeof reason === "string" && reason.length > 0 ? reason : fallback);
|
|
3705
|
-
error.name = "AbortError";
|
|
3706
|
-
return error;
|
|
3707
|
-
}
|
|
3708
|
-
/**
|
|
3709
|
-
* Cascade N abort signals into one downstream abort that fires when ANY of them does, carrying
|
|
3710
|
-
* that signal's own reason ({@link abortReason}). Node-portable: `AbortSignal.any` needs >=20.3
|
|
3711
|
-
* and the package floor is >=20, and it would drop the reason anyway.
|
|
3712
|
-
*
|
|
3713
|
-
* The one cascade every executor uses, so a reason forwarded here reaches every layer below.
|
|
3714
|
-
*/
|
|
3715
|
-
function linkAbort(...sources) {
|
|
3716
|
-
const controller = new AbortController();
|
|
3717
|
-
const listeners = [];
|
|
3718
|
-
const release = () => {
|
|
3719
|
-
for (const { source, onAbort } of listeners) source.removeEventListener("abort", onAbort);
|
|
3720
|
-
listeners.length = 0;
|
|
3721
|
-
};
|
|
3722
|
-
const abort = (reason) => {
|
|
3723
|
-
release();
|
|
3724
|
-
controller.abort(reason);
|
|
3725
|
-
};
|
|
3726
|
-
const alreadyAborted = sources.find((source) => source.aborted);
|
|
3727
|
-
if (alreadyAborted !== void 0) {
|
|
3728
|
-
controller.abort(abortReason(alreadyAborted, "aborted by parent scope"));
|
|
3729
|
-
return {
|
|
3730
|
-
signal: controller.signal,
|
|
3731
|
-
abort,
|
|
3732
|
-
release
|
|
3733
|
-
};
|
|
3734
|
-
}
|
|
3735
|
-
for (const source of sources) {
|
|
3736
|
-
const onAbort = () => abort(abortReason(source, "aborted by parent scope"));
|
|
3737
|
-
listeners.push({
|
|
3738
|
-
source,
|
|
3739
|
-
onAbort
|
|
3740
|
-
});
|
|
3741
|
-
source.addEventListener("abort", onAbort, { once: true });
|
|
3742
|
-
}
|
|
3743
|
-
return {
|
|
3744
|
-
signal: controller.signal,
|
|
3745
|
-
abort,
|
|
3746
|
-
release
|
|
3747
|
-
};
|
|
3748
|
-
}
|
|
3749
|
-
/**
|
|
3750
|
-
* Settle `act()` against `signal`. The first outcome wins and the listener is always
|
|
3751
|
-
* removed, so neither a late resolution nor a late abort can settle the promise twice.
|
|
3752
|
-
* The losing promise stays observed, so a late rejection cannot surface as an unhandled
|
|
3753
|
-
* process error.
|
|
3754
|
-
*
|
|
3755
|
-
* The abort rejection is deferred one microtask so a result the action had ALREADY
|
|
3756
|
-
* produced still wins. It does not hand the race to a listener the action registers
|
|
3757
|
-
* from inside `act()`: this function subscribes before it calls `act()`, so its own
|
|
3758
|
-
* abort handler runs first and settles the promise. A caller that must let the action
|
|
3759
|
-
* observe the abort itself has to hold a live promise and await that instead.
|
|
3760
|
-
*
|
|
3761
|
-
* A synchronous throw from `act()` propagates as the rejection, not as an abort.
|
|
3762
|
-
*/
|
|
3763
|
-
async function runAbortable(act, signal, fallback) {
|
|
3764
|
-
if (signal.aborted) throw signalAbortError(signal, fallback);
|
|
3765
|
-
return await new Promise((resolve, reject) => {
|
|
3766
|
-
let settled = false;
|
|
3767
|
-
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
3768
|
-
const onAbort = () => {
|
|
3769
|
-
queueMicrotask(() => {
|
|
3770
|
-
if (settled) return;
|
|
3771
|
-
settled = true;
|
|
3772
|
-
cleanup();
|
|
3773
|
-
reject(signalAbortError(signal, fallback));
|
|
3774
|
-
});
|
|
3775
|
-
};
|
|
3776
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
3777
|
-
let work;
|
|
3778
|
-
try {
|
|
3779
|
-
work = Promise.resolve(act());
|
|
3780
|
-
} catch (error) {
|
|
3781
|
-
cleanup();
|
|
3782
|
-
reject(error);
|
|
3783
|
-
return;
|
|
3784
|
-
}
|
|
3785
|
-
work.then((value) => {
|
|
3786
|
-
if (settled) return;
|
|
3787
|
-
settled = true;
|
|
3788
|
-
cleanup();
|
|
3789
|
-
resolve(value);
|
|
3790
|
-
}, (error) => {
|
|
3791
|
-
if (settled) return;
|
|
3792
|
-
settled = true;
|
|
3793
|
-
cleanup();
|
|
3794
|
-
reject(error);
|
|
3795
|
-
});
|
|
3796
|
-
});
|
|
3797
|
-
}
|
|
3798
3762
|
// src/runtime/supervise/seat-chain.ts
|
|
3799
3763
|
var SeatChainExhaustedError = class extends Error {
|
|
3800
3764
|
resumeAt;
|
|
@@ -16803,6 +16767,6 @@ async function recoverRetainedChildren(args, children, spawn, next) {
|
|
|
16803
16767
|
throw error;
|
|
16804
16768
|
}
|
|
16805
16769
|
}
|
|
16806
|
-
export { deriveNodeExecutionIdentity as $,
|
|
16770
|
+
export { deriveNodeExecutionIdentity as $, exactSession as $i, persistHarnessTranscript as $n, RetainedExecutionPendingError as $r, insideCursorNamespace as $t, nestedScopeSeamKey as A, sandboxLeafOutputFromEvents as Ai, workerTraceEnv as An, recordRuntimeOwnedProviderDispatchNotStarted as Ar, beginScopeRetainedOwnerDrive as At, beginScopeOwnerAttempt as B, extractLlmCallEvent as Bi, flatOtelSpan as Bn, unknownMaterializationReceipt as Br, retainedOwnerWorkspaceRetentionSeamKey as Bt, writeWorkerSteerAcknowledgement as C, newUsageTotals as Ci, nativeCopyDelayMs as Cn, inheritRuntimeOwnedExecutorAttestation as Cr, environmentReader as Ct, isTraceAnalysisStore as D, createSandboxToolPartState as Di, openSlotGroup as Dn, providerAttemptEvidence as Dr, prepareScopeRetainedOwnerTask as Dt, replaySpawnTree as E, assertValidBudget as Ei, createWorkerSlots as En, newExecutionAttemptId as Er, consumeScopeRetainedOwnerResult as Et, recoverRetainedInteractiveRun as F, extractTransportEventIdentity as Fi, buildLoopOtelSpans as Fn, runtimeOwnedExecutorMaterialization as Fr, scopeRetainedOwnerRestorePoint as Ft, scopeOwnerExecutorNodeContext as G, sandboxTerminalUsageField as Gi, sanitizeKnowledgeReadinessReport as Gn, runtimeFlowBrain as Gr, materializeTreeView as Gt, noteScopeOwnerPlannedExecution as H, notifySandboxEventObserver as Hi, loopEventToOtelSpan as Hn, executableAgentSpecSnapshot as Hr, scopeRetainedOwnerJournalRoot as Ht, startRetainedInteractiveRun as I, assertSandboxServedModel as Ii, buildLoopSpanNodes as In, runtimeOwnedExecutorProviderEvidence as Ir, noteScopeRetainedOwnerCoordination as It, providerVisibleProfile as J, parseCodexUsageRecord as Ji, captureBoundHarnessTranscript as Jn, runtimeFailureCauseSchema as Jr, nestedDriverTreeRoot as Jt, coordinationMcpAlias as K, sumSandboxUsage as Ki, sanitizeRuntimeStreamEvent as Kn, reportedFailureCause as Kr, attestNestedDriverTreeOwner as Kt, FileSpawnJournal as L, canonicalSandboxUsageMode as Li, buildRuntimeEventOtelSpans as Ln, runtimeOwnedPendingExecutorMaterialization as Lr, scopeRetainedOwnerCheckpointing as Lt, attachWorker as M, sandboxProgressEvents as Mi, createPropagatingTraceEmitter as Mn, recordRuntimeOwnedProviderModel as Mr, scopeRetainedOwnerTurnEnded as Mt, readWorkerInteractiveBinding as N, terminalTextFromSandboxEvent as Ni, mergeTraceEnv as Nn, runtimeOwnedDriveHarnessProviderEvidence as Nr, assertRetainedOwnerCoordinationRekey as Nt, parseWorkerToolTraceArtifact as O, mapSandboxEvent as Oi, resolveWorkerSlots as On, recordRuntimeOwnedDriveHarnessProviderEvidence as Or, scopeRetainedOwnerPriorSpend as Ot, reconnectRetainedInteractiveRun as P, canonicalStreamEventFromSandboxEvent as Pi, readTraceContextFromEnv as Pn, runtimeOwnedExecutorExecutionBinding as Pr, reconcileScopeRetainedOwnerEnvironment as Pt, assertRecursiveReservationPolicy as Q, awaitAbortable$1 as Qi, harnessTranscriptUnavailable as Qn, DISPATCH_NOT_ADMITTED_CODE as Qr, closesCursorSlot as Qt, appendSpawnEvents as R, createSandboxTurnEventCollector as Ri, createOpenInferenceFileExporter as Rn, runtimeOwnedScopeOwnerRuntime as Rr, bindScopeRetainedOwnerEnvironmentId as Rt, writeWorkerSteer as S, meterUsageEvent as Si, captureProviderWorkspaceSnapshot as Sn, finalizeRuntimeOwnedPendingExecutor as Sr, scopeRetainedOwnerResourceReader as St, sumSpendFromEvents as T, spendFromUsageTotals as Ti, workspaceCaptureReceipt as Tn, knownMaterializationReceipt as Tr, abandonScopeRetainedOwnerInvocation as Tt, recordScopeOwnerMaterialization as U, sameModelId as Ui, createRuntimeEventCollector as Un, isRuntimeFlowBrain as Ur, loadSpawnForest as Ut, finalizeScopeOwnerMaterialization as V, isSandboxTerminalEvent as Vi, generateSpanId as Vn, executableAgentProfileSnapshot as Vr, scopeRetainedOwnerContext as Vt, restoreScopeOwnerAcceptedExecution as W, sandboxEventServedBackend as Wi, createRuntimeStreamEventCollector as Wn, runtimeFlowAgent as Wr, ownedTreeRootSpawn as Wt, reenteredWorkers as X, RetainedRunProviderContractError as Xi, harnessTranscriptArtifact as Xn, runtimeProviderCode as Xr, encodeResultBlob as Xt, runtimeGraphMetadataKey as Y, recordValue as Yi, captureHarnessTranscript as Yn, runtimeFailureRemediationSchema as Yr, FileResultBlobStore as Yt, settledToIteration as Z, assertEventBinding as Zi, harnessTranscriptFromLines as Zn, settlementFailureCause as Zr, SpawnEventIndex as Zt, supervisorRunDir as _, executorFailure as _i, destroyInteractiveEnvironment as _n, attestRuntimeOwnedExecutor as _r, startScopeRecoveries as _t, readRootStream as a, runAbortable as aa, retainedExecutorSeamKey as ai, reconnectRetainedRun as an, DEFAULT_STALL_AFTER_MS as ar, hasRetriableTeardowns as at, workerInboxFileFromEventDir as b, isCredentialRefusal as bi, assertProviderWorkspaceRetentionPort as bn, authoredAgentIdentity as br, prepareScopeRetainedOwnerSeatSwitch as bt, cancelWorker as c, promptOptionsFromAgentTurnInput as ca, cappedDoublingMs as ci, startRetainedRunInEnvironment as cn, readWorkerProgress as cr, recordScopeOwnerBarrenPause as ct, legacySupervisorRunsRoot as d, unavailableResumeAt as di, offerInteractiveControl as dn, SeatChain as dr, registerNestedTeardownScope as dt, freezeControlRef as ea, TRANSPORT_ERROR_CODES as ei, verifyWorkspaceMarker as en, readHarnessTranscript as er, freeSlots as et, readWorkerCancelRequests as f, unavailableSignalOfFailure as fi, prepareInteractiveDelegation as fn, SeatChainExhaustedError as fr, releaseHeldEnvironments as ft, safeWorkerFile as g, contentRef as gi, verifyObserverRecords as gn, attestRuntimeOwnedDeferredExecutor as gr, settleManagerWork as gt, readWorkerSteerRequests as h, contentAddress as hi, observerRecordDigest as hn, subscriptionUsageLimitSignal as hr, retryUnconfirmedTeardowns as ht, nodeStreamFile as i, linkAbort as ia, retainedExecutorContext as ii, mintRetainedIdentity as in, retainHarnessTranscript as ir, closeScopeAdmission as it, interactiveAdmissionSeamKey as j, sandboxOutputMarker as ji, workerTraceHeaders as jn, recordRuntimeOwnedProviderIdentityConflict as jr, scopeRetainedOwnerSettled as jt, workerTraceAnalysisStore as k, mapSandboxToolEvent as ki, WORKER_TRACE_PROPAGATION as kn, recordRuntimeOwnedProviderAttemptStart as kr, scopeRetainedOwnerResult as kt, claimWorkerSteerDelivery as l, providerMessageText as la, jitteredMs as li, retainedCreateMaterial as ln, isLiveNodeStatus as lr, recordScopeOwnerDriverAttempt as lt, readWorkerSteerAcknowledgement as m, TRACE_SUMMARY_SCHEMA as mi, createFileObserverHooks as mn, seatExecutionProfile as mr, releaseRetainedEnvironments as mt, ROOT_STREAM_FILE as n, RunCancellationReason as na, isSchemaRejection as ni, stopRetainedNativeExecution as nn, readBoundHarnessSessions as nr, rollingDispatch as nt, readRootStreamReceipt as o, signalAbortError as oa, UNAVAILABLE_CODES as oi, recoverRetainedRun as on, createActivityLog as or, meterRuntimeOwnedAccounting as ot, readWorkerCancellation as p, TRACE_ROOT_SCHEMA as pi, FileObserverJournal as pn, authoredSeatStages as pr, releaseManagerEnvironment as pt, coordinationProfileToolPrefix as q, decodeHarnessUsage as qi, HARNESS_TRANSCRIPT_SETTLE_TIMEOUT_MS as qn, runtimeFailureCause as qr, driverRuntime as qt, createRootStreamSink as r, abortReason as ra, registerRetainedExecutorPreparation as ri, assertRetainedRunReplayMaterial as rn, resolveHarnessTranscriptCapture as rr, closeRetainedSlots as rt, appendWorkerControlEvent as s, promptFromAgentTurnInput as sa, UNAVAILABLE_STATUSES as si, startRetainedRun as sn, describeToolArgs as sr, meterRuntimeOwnedProviderAttempt as st, createScope as t, sameControlCoordinates as ta, isProvisioningRefusal as ti, describeRetainedNativeStops as tn, HARNESS_TRANSCRIPT_READ_LIMITS as tr, queueOf as tt, legacySupervisorRunDir as u, unavailablePauseMs as ui, acceptedInteractiveControl as un, isTerminalNodeStatus as ur, recordScopeOwnerPause as ut, supervisorRunsRoot as v, hashJson as vi, environmentGone as vn, attestRuntimeOwnedPendingExecutor as vr, unconfirmedTeardowns as vt, prepareScopeResume as w, spendFromUsageEvents as wi, openNativeMirror as wn, knownExecutionBindingReceipt as wr, resolveSpawnResourcePaths as wt, writeWorkerCancellation as x, createBudgetPool as xi, captureProviderLiveWorkspace as xn, authoredProfileDigest as xr, releaseScopeRetainedOwnerForSeatPause as xt, workerCancellationsDir as y, credentialCommandExit as yi, DEFAULT_NATIVE_CAPTURE_INTERVAL_MS as yn, attestRuntimeOwnedScopeOwner as yr, waitForScopeChildren as yt, spawnJournalRecordEvents as z, createSandboxUsageLedger as zi, createOtelExporter as zn, unknownExecutionBindingReceipt as zr, bindScopeRetainedOwnerProvider as zt };
|
|
16807
16771
|
|
|
16808
|
-
//# sourceMappingURL=scope-
|
|
16772
|
+
//# sourceMappingURL=scope-DdPWlFO4.js.map
|