@claudexor/core 3.0.4 → 3.1.1
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/answer-assembly.d.ts +17 -1
- package/dist/answer-assembly.d.ts.map +1 -1
- package/dist/answer-assembly.js +36 -10
- package/dist/answer-assembly.js.map +1 -1
- package/dist/effort.d.ts +54 -12
- package/dist/effort.d.ts.map +1 -1
- package/dist/effort.js +60 -39
- package/dist/effort.js.map +1 -1
- package/dist/env-scope.d.ts +1 -1
- package/dist/env-scope.d.ts.map +1 -1
- package/dist/env-scope.js +2 -2
- package/dist/env-scope.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -1
- package/dist/inactivity.d.ts +7 -14
- package/dist/inactivity.d.ts.map +1 -1
- package/dist/inactivity.js +97 -10
- package/dist/inactivity.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/native/claudexor-process-identity +0 -0
- package/dist/proc.d.ts +53 -0
- package/dist/proc.d.ts.map +1 -1
- package/dist/proc.js +150 -42
- package/dist/proc.js.map +1 -1
- package/dist/process-identity.d.ts.map +1 -1
- package/dist/process-identity.js +17 -7
- package/dist/process-identity.js.map +1 -1
- package/dist/process-tree.d.ts +116 -0
- package/dist/process-tree.d.ts.map +1 -0
- package/dist/process-tree.js +258 -0
- package/dist/process-tree.js.map +1 -0
- package/dist/runloop.d.ts +5 -0
- package/dist/runloop.d.ts.map +1 -1
- package/dist/runloop.js +41 -0
- package/dist/runloop.js.map +1 -1
- package/dist/runtime-env.d.ts +57 -3
- package/dist/runtime-env.d.ts.map +1 -1
- package/dist/runtime-env.js +187 -10
- package/dist/runtime-env.js.map +1 -1
- package/package.json +3 -3
|
@@ -7,6 +7,17 @@
|
|
|
7
7
|
export declare class AnswerAssembly {
|
|
8
8
|
private readonly parts;
|
|
9
9
|
private finalText?;
|
|
10
|
+
/**
|
|
11
|
+
* MACHINE-truth final, decoupled from the DISPLAY final (codex #19816 /
|
|
12
|
+
* QA-009). A codex constrained WorkReport route pre-unwraps its final
|
|
13
|
+
* message's DISPLAY text to the `output` (so the answer bubble + the app's
|
|
14
|
+
* twin-removal see the unwrapped output, not raw JSON) and carries the raw
|
|
15
|
+
* `{work_report, output}` envelope on `payload.work_report_envelope`. The
|
|
16
|
+
* orchestrator un-nests machine truth via `machineText()`, so the display
|
|
17
|
+
* unwrap never breaks the envelope parse; adapters that leave the raw envelope
|
|
18
|
+
* IN the final text (claude) never set this, so `machineText()` === `text()`.
|
|
19
|
+
*/
|
|
20
|
+
private machineFinalText?;
|
|
10
21
|
/** Feed one already-sanitized harness event; non-answer events are ignored. */
|
|
11
22
|
observe(ev: {
|
|
12
23
|
type: string;
|
|
@@ -16,7 +27,12 @@ export declare class AnswerAssembly {
|
|
|
16
27
|
}): void;
|
|
17
28
|
/** Whether a typed final answer has been accepted. */
|
|
18
29
|
hasFinal(): boolean;
|
|
19
|
-
/** The assembled answer: the typed final verbatim, else joined
|
|
30
|
+
/** The assembled answer for DISPLAY: the typed final verbatim, else joined
|
|
31
|
+
* narration. For codex constrained routes this is the UNWRAPPED output. */
|
|
20
32
|
text(): string;
|
|
33
|
+
/** The assembled answer for MACHINE consumption (the WorkReport un-nest): the
|
|
34
|
+
* raw envelope when the adapter pre-unwrapped the display copy, else identical
|
|
35
|
+
* to `text()`. The orchestrator passes THIS to `unwrapWorkReportEnvelope`. */
|
|
36
|
+
machineText(): string;
|
|
21
37
|
}
|
|
22
38
|
//# sourceMappingURL=answer-assembly.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer-assembly.d.ts","sourceRoot":"","sources":["../src/answer-assembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,SAAS,CAAC,CAAS;
|
|
1
|
+
{"version":3,"file":"answer-assembly.d.ts","sourceRoot":"","sources":["../src/answer-assembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAElC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,GAAG,IAAI;IAyBR,sDAAsD;IACtD,QAAQ,IAAI,OAAO;IAInB;+EAC2E;IAC3E,IAAI,IAAI,MAAM;IAId;;kFAE8E;IAC9E,WAAW,IAAI,MAAM;CAGtB"}
|
package/dist/answer-assembly.js
CHANGED
|
@@ -7,9 +7,20 @@
|
|
|
7
7
|
export class AnswerAssembly {
|
|
8
8
|
parts = [];
|
|
9
9
|
finalText;
|
|
10
|
+
/**
|
|
11
|
+
* MACHINE-truth final, decoupled from the DISPLAY final (codex #19816 /
|
|
12
|
+
* QA-009). A codex constrained WorkReport route pre-unwraps its final
|
|
13
|
+
* message's DISPLAY text to the `output` (so the answer bubble + the app's
|
|
14
|
+
* twin-removal see the unwrapped output, not raw JSON) and carries the raw
|
|
15
|
+
* `{work_report, output}` envelope on `payload.work_report_envelope`. The
|
|
16
|
+
* orchestrator un-nests machine truth via `machineText()`, so the display
|
|
17
|
+
* unwrap never breaks the envelope parse; adapters that leave the raw envelope
|
|
18
|
+
* IN the final text (claude) never set this, so `machineText()` === `text()`.
|
|
19
|
+
*/
|
|
20
|
+
machineFinalText;
|
|
10
21
|
/** Feed one already-sanitized harness event; non-answer events are ignored. */
|
|
11
22
|
observe(ev) {
|
|
12
|
-
if (ev.type !== "message"
|
|
23
|
+
if (ev.type !== "message")
|
|
13
24
|
return;
|
|
14
25
|
if (ev.payload?.["auth_switched"] === true)
|
|
15
26
|
return;
|
|
@@ -18,25 +29,40 @@ export class AnswerAssembly {
|
|
|
18
29
|
if (ev.payload?.["delta"] === true)
|
|
19
30
|
return;
|
|
20
31
|
if (ev.final === true) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
const raw = ev.payload?.["work_report_envelope"];
|
|
33
|
+
const machine = typeof raw === "string" ? raw : undefined;
|
|
34
|
+
const display = ev.text ?? "";
|
|
35
|
+
// A whitespace-only DISPLAY final is NOT an answer and must never erase an
|
|
36
|
+
// earlier real final (review sol #3) — UNLESS it carries machine truth. A
|
|
37
|
+
// codex constrained route legitimately finalizes `output:""` (all its work
|
|
38
|
+
// lived in the work_report): keep the RAW envelope so the orchestrator
|
|
39
|
+
// still un-nests work_state/outcome, with an empty display. Otherwise the
|
|
40
|
+
// accepted final is kept VERBATIM (the documented contract) — no trimming.
|
|
41
|
+
if (display.trim().length === 0 && machine === undefined)
|
|
25
42
|
return;
|
|
26
|
-
this.finalText =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pushUniqueText(this.parts, ev.text);
|
|
43
|
+
this.finalText = display;
|
|
44
|
+
this.machineFinalText = machine;
|
|
45
|
+
return;
|
|
30
46
|
}
|
|
47
|
+
if (!ev.text)
|
|
48
|
+
return;
|
|
49
|
+
pushUniqueText(this.parts, ev.text);
|
|
31
50
|
}
|
|
32
51
|
/** Whether a typed final answer has been accepted. */
|
|
33
52
|
hasFinal() {
|
|
34
53
|
return this.finalText !== undefined;
|
|
35
54
|
}
|
|
36
|
-
/** The assembled answer: the typed final verbatim, else joined
|
|
55
|
+
/** The assembled answer for DISPLAY: the typed final verbatim, else joined
|
|
56
|
+
* narration. For codex constrained routes this is the UNWRAPPED output. */
|
|
37
57
|
text() {
|
|
38
58
|
return this.finalText ?? this.parts.join("\n").trim();
|
|
39
59
|
}
|
|
60
|
+
/** The assembled answer for MACHINE consumption (the WorkReport un-nest): the
|
|
61
|
+
* raw envelope when the adapter pre-unwrapped the display copy, else identical
|
|
62
|
+
* to `text()`. The orchestrator passes THIS to `unwrapWorkReportEnvelope`. */
|
|
63
|
+
machineText() {
|
|
64
|
+
return this.machineFinalText ?? this.text();
|
|
65
|
+
}
|
|
40
66
|
}
|
|
41
67
|
/**
|
|
42
68
|
* Deduplicate the known "final result repeats the last streamed message" shape
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer-assembly.js","sourceRoot":"","sources":["../src/answer-assembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACR,KAAK,GAAa,EAAE,CAAC;IAC9B,SAAS,CAAU;
|
|
1
|
+
{"version":3,"file":"answer-assembly.js","sourceRoot":"","sources":["../src/answer-assembly.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACR,KAAK,GAAa,EAAE,CAAC;IAC9B,SAAS,CAAU;IAC3B;;;;;;;;;OASG;IACK,gBAAgB,CAAU;IAElC,+EAA+E;IAC/E,OAAO,CAAC,EAKP;QACC,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO;QAClC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,KAAK,IAAI;YAAE,OAAO;QACnD,qEAAqE;QACrE,+DAA+D;QAC/D,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,IAAI;YAAE,OAAO;QAC3C,IAAI,EAAE,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,sBAAsB,CAAC,CAAC;YACjD,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,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/dist/effort.d.ts
CHANGED
|
@@ -1,18 +1,60 @@
|
|
|
1
1
|
import type { EffortHint } from "@claudexor/schema";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Effort resolution against VENDOR-ordered ladders. There is no static rank
|
|
4
|
+
* table anywhere in this repo: a level's rank is its position in the ladder the
|
|
5
|
+
* vendor itself advertised (a model's own ordered list, or the harness's merged
|
|
6
|
+
* ladder — `mergeEffortLadders` in the schema package). Ranking is NOT
|
|
7
|
+
* permission: what a run may actually use is whatever the resolved (harness,
|
|
8
|
+
* model) ADVERTISES, so a level newer than this repo passes through untouched
|
|
9
|
+
* the moment the vendor ships it.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Outcome of resolving a requested effort against an advertised vocabulary.
|
|
13
|
+
* `rejected` carries actionable text naming what IS advertised — an unknown
|
|
14
|
+
* level is never silently downgraded into something we merely guessed at.
|
|
15
|
+
*/
|
|
16
|
+
export type EffortCheck = {
|
|
17
|
+
status: "ok";
|
|
18
|
+
effort: EffortHint | null;
|
|
19
|
+
clamped: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
status: "rejected";
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolve a requested reasoning-effort level against the levels a specific
|
|
26
|
+
* (harness, model) advertises. THE single owner of effort semantics; every
|
|
27
|
+
* surface (adapters, settings writes, preflight) resolves through it.
|
|
5
28
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
*
|
|
29
|
+
* `advertised` is what the resolved target accepts (the model's own ordered
|
|
30
|
+
* list, or the harness ladder when the model recorded none). `ladder` is the
|
|
31
|
+
* rank authority for clamping: the harness's MERGED vendor order, so a level
|
|
32
|
+
* one sibling model advertises can clamp onto what THIS model accepts (`ultra`
|
|
33
|
+
* on gpt-5.4 → `xhigh`, because the merged codex ladder places `ultra` above
|
|
34
|
+
* it). It defaults to `advertised` itself — the degenerate case where nothing
|
|
35
|
+
* beyond the target's own order is known, including a harness whose models'
|
|
36
|
+
* orders CONTRADICT each other: pass `advertised` there, which makes
|
|
37
|
+
* cross-model clamping impossible by construction and refuses instead of
|
|
38
|
+
* inventing an order.
|
|
13
39
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
40
|
+
* - nothing requested → ok, no effort (pass no flag).
|
|
41
|
+
* - `advertised` empty → ok, no effort: effort is not a tunable surface here, so
|
|
42
|
+
* the caller discloses it as ignored (INV-105) instead of clamping to a guess.
|
|
43
|
+
* - requested IS advertised → PASS THROUGH VERBATIM. This is what makes a
|
|
44
|
+
* future vendor level work with no Claudexor change.
|
|
45
|
+
* - requested is not advertised but the LADDER places it → CLAMP to the nearest
|
|
46
|
+
* advertised level by ladder position (ties resolve to the cheaper one).
|
|
47
|
+
* - requested is unknown to the ladder too → REJECT, naming the advertised
|
|
48
|
+
* set. We cannot place it, so any "nearest" would be invented.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveEffort(requested: EffortHint | null | undefined, advertised: readonly EffortHint[], ladder?: readonly EffortHint[]): EffortCheck;
|
|
51
|
+
/**
|
|
52
|
+
* Map a requested effort onto a level the resolved (harness, model) accepts, or
|
|
53
|
+
* null when none should be sent. Thin translational wrapper over `resolveEffort`
|
|
54
|
+
* for arg builders, which must never emit a level the vendor would reject: a
|
|
55
|
+
* rejection yields null (send NO flag, keep the vendor default) rather than a
|
|
56
|
+
* fabricated downgrade. Surfaces that can talk back to the user call
|
|
57
|
+
* `resolveEffort` and report its `message`.
|
|
16
58
|
*/
|
|
17
|
-
export declare function normalizeEffort(requested: EffortHint | null | undefined,
|
|
59
|
+
export declare function normalizeEffort(requested: EffortHint | null | undefined, advertised: readonly EffortHint[], ladder?: readonly EffortHint[]): EffortHint | null;
|
|
18
60
|
//# sourceMappingURL=effort.d.ts.map
|
package/dist/effort.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effort.d.ts","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"effort.d.ts","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;GAQG;AAEH;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7D;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACxC,UAAU,EAAE,SAAS,UAAU,EAAE,EACjC,MAAM,GAAE,SAAS,UAAU,EAAe,GACzC,WAAW,CAkCb;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACxC,UAAU,EAAE,SAAS,UAAU,EAAE,EACjC,MAAM,GAAE,SAAS,UAAU,EAAe,GACzC,UAAU,GAAG,IAAI,CAGnB"}
|
package/dist/effort.js
CHANGED
|
@@ -1,50 +1,71 @@
|
|
|
1
|
-
import { EffortHint as EffortHintSchema } from "@claudexor/schema";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* the enum is automatically ranked and every adapter clamps it with no code
|
|
7
|
-
* change. An EffortHint's RANK is its index here; the normalizer below clamps any
|
|
8
|
-
* requested level onto the nearest level a given adapter actually supports.
|
|
9
|
-
*/
|
|
10
|
-
const EFFORT_LADDER = EffortHintSchema.options;
|
|
11
|
-
function rank(level) {
|
|
12
|
-
return EFFORT_LADDER.indexOf(level);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Map a requested reasoning-effort hint onto the nearest level a harness
|
|
16
|
-
* actually supports.
|
|
2
|
+
* Resolve a requested reasoning-effort level against the levels a specific
|
|
3
|
+
* (harness, model) advertises. THE single owner of effort semantics; every
|
|
4
|
+
* surface (adapters, settings writes, preflight) resolves through it.
|
|
17
5
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* -
|
|
23
|
-
*
|
|
24
|
-
*
|
|
6
|
+
* `advertised` is what the resolved target accepts (the model's own ordered
|
|
7
|
+
* list, or the harness ladder when the model recorded none). `ladder` is the
|
|
8
|
+
* rank authority for clamping: the harness's MERGED vendor order, so a level
|
|
9
|
+
* one sibling model advertises can clamp onto what THIS model accepts (`ultra`
|
|
10
|
+
* on gpt-5.4 → `xhigh`, because the merged codex ladder places `ultra` above
|
|
11
|
+
* it). It defaults to `advertised` itself — the degenerate case where nothing
|
|
12
|
+
* beyond the target's own order is known, including a harness whose models'
|
|
13
|
+
* orders CONTRADICT each other: pass `advertised` there, which makes
|
|
14
|
+
* cross-model clamping impossible by construction and refuses instead of
|
|
15
|
+
* inventing an order.
|
|
25
16
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
17
|
+
* - nothing requested → ok, no effort (pass no flag).
|
|
18
|
+
* - `advertised` empty → ok, no effort: effort is not a tunable surface here, so
|
|
19
|
+
* the caller discloses it as ignored (INV-105) instead of clamping to a guess.
|
|
20
|
+
* - requested IS advertised → PASS THROUGH VERBATIM. This is what makes a
|
|
21
|
+
* future vendor level work with no Claudexor change.
|
|
22
|
+
* - requested is not advertised but the LADDER places it → CLAMP to the nearest
|
|
23
|
+
* advertised level by ladder position (ties resolve to the cheaper one).
|
|
24
|
+
* - requested is unknown to the ladder too → REJECT, naming the advertised
|
|
25
|
+
* set. We cannot place it, so any "nearest" would be invented.
|
|
28
26
|
*/
|
|
29
|
-
export function
|
|
30
|
-
if (requested === null || requested === undefined)
|
|
31
|
-
return null;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
export function resolveEffort(requested, advertised, ladder = advertised) {
|
|
28
|
+
if (requested === null || requested === undefined) {
|
|
29
|
+
return { status: "ok", effort: null, clamped: false };
|
|
30
|
+
}
|
|
31
|
+
if (advertised.length === 0)
|
|
32
|
+
return { status: "ok", effort: null, clamped: false };
|
|
33
|
+
if (advertised.includes(requested))
|
|
34
|
+
return { status: "ok", effort: requested, clamped: false };
|
|
35
|
+
const want = ladder.indexOf(requested);
|
|
36
|
+
// Only levels the ladder places can host a clamp; a level outside the ladder
|
|
37
|
+
// is a valid TARGET only through the exact-match branch above.
|
|
38
|
+
const rankable = advertised.filter((level) => ladder.indexOf(level) >= 0);
|
|
39
|
+
if (want < 0 || rankable.length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
status: "rejected",
|
|
42
|
+
message: `effort "${requested}" is not advertised here and the advertised ladder cannot place it ` +
|
|
43
|
+
`(advertised: ${advertised.join(", ")})`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
let best = rankable[0];
|
|
47
|
+
let bestDistance = Math.abs(ladder.indexOf(best) - want);
|
|
48
|
+
for (const level of rankable.slice(1)) {
|
|
49
|
+
const distance = Math.abs(ladder.indexOf(level) - want);
|
|
50
|
+
// Strictly-closer wins; on a tie keep the LOWER-positioned (cheaper) candidate.
|
|
42
51
|
if (distance < bestDistance ||
|
|
43
|
-
(distance === bestDistance &&
|
|
52
|
+
(distance === bestDistance && ladder.indexOf(level) < ladder.indexOf(best))) {
|
|
44
53
|
best = level;
|
|
45
54
|
bestDistance = distance;
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
|
-
return best;
|
|
57
|
+
return { status: "ok", effort: best, clamped: true };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Map a requested effort onto a level the resolved (harness, model) accepts, or
|
|
61
|
+
* null when none should be sent. Thin translational wrapper over `resolveEffort`
|
|
62
|
+
* for arg builders, which must never emit a level the vendor would reject: a
|
|
63
|
+
* rejection yields null (send NO flag, keep the vendor default) rather than a
|
|
64
|
+
* fabricated downgrade. Surfaces that can talk back to the user call
|
|
65
|
+
* `resolveEffort` and report its `message`.
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeEffort(requested, advertised, ladder = advertised) {
|
|
68
|
+
const check = resolveEffort(requested, advertised, ladder);
|
|
69
|
+
return check.status === "ok" ? check.effort : null;
|
|
49
70
|
}
|
|
50
71
|
//# sourceMappingURL=effort.js.map
|
package/dist/effort.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effort.js","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effort.js","sourceRoot":"","sources":["../src/effort.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,aAAa,CAC3B,SAAwC,EACxC,UAAiC,EACjC,SAAgC,UAAU;IAE1C,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAClD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACxD,CAAC;IACD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACnF,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SA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C;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAwC,EACxC,UAAiC,EACjC,SAAgC,UAAU;IAE1C,MAAM,KAAK,GAAG,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC"}
|
package/dist/env-scope.d.ts
CHANGED
|
@@ -34,5 +34,5 @@ export declare const CLEAN_ENV_ALLOWLIST: readonly string[];
|
|
|
34
34
|
* allowlist (agent isolation). The adapter's `spec.env` overrides + the
|
|
35
35
|
* providerScrubEnv patch are applied ON TOP of this by the spawn layer.
|
|
36
36
|
*/
|
|
37
|
-
export declare function composeBaseEnv(inheritance: "mirror_native" | "clean", source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
37
|
+
export declare function composeBaseEnv(inheritance: "mirror_native" | "clean", source?: NodeJS.ProcessEnv, execPath?: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
38
38
|
//# sourceMappingURL=env-scope.d.ts.map
|
package/dist/env-scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-scope.d.ts","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA4DhD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAoChD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,GAAG,OAAO,EACtC,MAAM,GAAE,MAAM,CAAC,UAAwB,
|
|
1
|
+
{"version":3,"file":"env-scope.d.ts","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA4DhD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAoChD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,GAAG,OAAO,EACtC,MAAM,GAAE,MAAM,CAAC,UAAwB,EACvC,QAAQ,GAAE,MAAyB,EACnC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAAC,UAAU,CASnB"}
|
package/dist/env-scope.js
CHANGED
|
@@ -139,8 +139,8 @@ export const CLEAN_ENV_ALLOWLIST = [
|
|
|
139
139
|
* allowlist (agent isolation). The adapter's `spec.env` overrides + the
|
|
140
140
|
* providerScrubEnv patch are applied ON TOP of this by the spawn layer.
|
|
141
141
|
*/
|
|
142
|
-
export function composeBaseEnv(inheritance, source = process.env) {
|
|
143
|
-
const normalizedSource = harnessRuntimeEnv(source);
|
|
142
|
+
export function composeBaseEnv(inheritance, source = process.env, execPath = process.execPath, platform = process.platform) {
|
|
143
|
+
const normalizedSource = harnessRuntimeEnv(source, execPath, platform);
|
|
144
144
|
if (inheritance !== "clean")
|
|
145
145
|
return normalizedSource;
|
|
146
146
|
const out = {};
|
package/dist/env-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-scope.js","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;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,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,UAAU;IACV,8EAA8E;IAC9E,WAAW;IACX,SAAS;IACT,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;IACf,YAAY,EAAE,wCAAwC;IACtD,4EAA4E;IAC5E,gFAAgF;IAChF,qFAAqF;IACrF,YAAY;IACZ,aAAa;IACb,WAAW;IACX,UAAU;IACV,YAAY;IACZ,aAAa;IACb,WAAW;IACX,UAAU;IACV,qBAAqB;IACrB,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,gBAAgB;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAsC,EACtC,SAA4B,OAAO,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"env-scope.js","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,eAAe;IACf,gBAAgB;IAChB,mBAAmB;IACnB,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,yBAAyB;IACzB,qBAAqB;IACrB,mBAAmB;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,gBAAgB;IAChB,yBAAyB;IACzB,yBAAyB;IACzB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,6BAA6B;IAC7B,2BAA2B;IAC3B,8BAA8B;IAC9B,4BAA4B;IAC5B,4BAA4B;IAC5B,6BAA6B;IAC7B,2DAA2D;IAC3D,mBAAmB;IACnB,uBAAuB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qBAAqB;IACrB,eAAe;IACf,cAAc;IACd,oBAAoB;IACpB,gBAAgB;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,WAAsC,EACtC,SAA4B,OAAO,CAAC,GAAG,EACvC,WAAmB,OAAO,CAAC,QAAQ,EACnC,WAA4B,OAAO,CAAC,QAAQ;IAE5C,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACvE,IAAI,WAAW,KAAK,OAAO;QAAE,OAAO,gBAAgB,CAAC;IACrD,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -13,4 +13,15 @@ export declare class ContextOverflowError extends ClaudexorError {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class WorkspaceError extends ClaudexorError {
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The Claudexor delegation belt (D32) cannot be made operational for this run:
|
|
18
|
+
* no `cli.js` entry that hosts `mcp serve-belt` exists next to the launching
|
|
19
|
+
* process OR this module. Emitting the belt descriptor anyway would spawn
|
|
20
|
+
* `node <missing cli.js> mcp serve-belt`, which MODULE_NOT_FOUNDs inside the
|
|
21
|
+
* harness — the belt reports `failed`, the harness silently answers from its
|
|
22
|
+
* own native subagent, and the run terminalizes a false success (QA-024). We
|
|
23
|
+
* refuse TYPED at preflight instead, naming the probed entry and the remedy.
|
|
24
|
+
*/
|
|
25
|
+
export declare class DelegationBeltUnavailableError extends ClaudexorError {
|
|
26
|
+
}
|
|
16
27
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,qBAAa,uBAAwB,SAAQ,cAAc;CAAG;AAC9D,qBAAa,oBAAqB,SAAQ,cAAc;CAAG;AAC3D,qBAAa,cAAe,SAAQ,cAAc;CAAG"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI3D;AAED,qBAAa,uBAAwB,SAAQ,cAAc;CAAG;AAC9D,qBAAa,oBAAqB,SAAQ,cAAc;CAAG;AAC3D,qBAAa,cAAe,SAAQ,cAAc;CAAG;AAErD;;;;;;;;GAQG;AACH,qBAAa,8BAA+B,SAAQ,cAAc;CAAG"}
|
package/dist/errors.js
CHANGED
|
@@ -14,4 +14,15 @@ export class ContextOverflowError extends ClaudexorError {
|
|
|
14
14
|
}
|
|
15
15
|
export class WorkspaceError extends ClaudexorError {
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The Claudexor delegation belt (D32) cannot be made operational for this run:
|
|
19
|
+
* no `cli.js` entry that hosts `mcp serve-belt` exists next to the launching
|
|
20
|
+
* process OR this module. Emitting the belt descriptor anyway would spawn
|
|
21
|
+
* `node <missing cli.js> mcp serve-belt`, which MODULE_NOT_FOUNDs inside the
|
|
22
|
+
* harness — the belt reports `failed`, the harness silently answers from its
|
|
23
|
+
* own native subagent, and the run terminalizes a false success (QA-024). We
|
|
24
|
+
* refuse TYPED at preflight instead, naming the probed entry and the remedy.
|
|
25
|
+
*/
|
|
26
|
+
export class DelegationBeltUnavailableError extends ClaudexorError {
|
|
27
|
+
}
|
|
17
28
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,cAAc;CAAG;AAC9D,MAAM,OAAO,oBAAqB,SAAQ,cAAc;CAAG;AAC3D,MAAM,OAAO,cAAe,SAAQ,cAAc;CAAG"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,cAAc;CAAG;AAC9D,MAAM,OAAO,oBAAqB,SAAQ,cAAc;CAAG;AAC3D,MAAM,OAAO,cAAe,SAAQ,cAAc;CAAG;AAErD;;;;;;;;GAQG;AACH,MAAM,OAAO,8BAA+B,SAAQ,cAAc;CAAG"}
|
package/dist/inactivity.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inactivity watchdog for harness event streams: a wedged vendor CLI
|
|
3
|
-
* that stops emitting events would otherwise park the run in `running`
|
|
4
|
-
* forever — only reviewers had a timeout. The combinator pumps the source
|
|
5
|
-
* iterator and re-arms a timer on EVERY event; when the window elapses with
|
|
6
|
-
* no event, `onTimeout` fires exactly once (the caller aborts its per-attempt
|
|
7
|
-
* controller, which kills the process group through the existing abort
|
|
8
|
-
* plumbing) and the pump stops waiting for the source.
|
|
9
|
-
*
|
|
10
|
-
* This is an INACTIVITY window, not a wall-clock cap: long runs are fine as
|
|
11
|
-
* long as they keep talking. Distinct from cancellation by construction —
|
|
12
|
-
* the caller decides what the timeout means (typed harness_timeout failure),
|
|
13
|
-
* and a user cancel still routes through the run signal.
|
|
14
|
-
*/
|
|
15
1
|
export declare class HarnessInactivityTimeoutError extends Error {
|
|
16
2
|
readonly timeoutMs: number;
|
|
17
3
|
constructor(timeoutMs: number);
|
|
@@ -27,5 +13,12 @@ export declare function withInactivityWatchdog<T>(source: AsyncIterable<T>, opts
|
|
|
27
13
|
* and the interaction channel enforces its own answer-wait budget.
|
|
28
14
|
*/
|
|
29
15
|
isSuspended?: () => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* How long to drain the aborted source's cleanup after a timeout (or await
|
|
18
|
+
* iterator.return on an early caller break) before giving up. MUST exceed
|
|
19
|
+
* the source's process-reap deadline so its typed termination_unconfirmed
|
|
20
|
+
* terminal fact surfaces; defaults to {@link REAP_PROOF_DEADLINE_MS}.
|
|
21
|
+
*/
|
|
22
|
+
cleanupDeadlineMs?: number;
|
|
30
23
|
}): AsyncIterable<T>;
|
|
31
24
|
//# sourceMappingURL=inactivity.d.ts.map
|
package/dist/inactivity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inactivity.d.ts","sourceRoot":"","sources":["../src/inactivity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inactivity.d.ts","sourceRoot":"","sources":["../src/inactivity.ts"],"names":[],"mappings":"AA4BA,qBAAa,6BAA8B,SAAQ,KAAK;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAQvC;AAED,wBAAuB,sBAAsB,CAAC,CAAC,EAC7C,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC;IAC5B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACA,aAAa,CAAC,CAAC,CAAC,CA8FlB"}
|
package/dist/inactivity.js
CHANGED
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
* the caller decides what the timeout means (typed harness_timeout failure),
|
|
13
13
|
* and a user cancel still routes through the run signal.
|
|
14
14
|
*/
|
|
15
|
+
/** QA-027: how long to await the source's cleanup after an inactivity timeout
|
|
16
|
+
* (or an early caller break) before the watchdog gives up and lets the terminal
|
|
17
|
+
* proceed anyway. This MUST exceed spawnProcess's own whole-tree death-proof
|
|
18
|
+
* deadline (`cancelDeadlineMs`, default `cancelKillDelayMs + 4000` = 5000ms) so
|
|
19
|
+
* the underlying runCliHarness reap runs to completion and its typed
|
|
20
|
+
* `termination_unconfirmed` terminal fact (14e958a3) is emitted through the
|
|
21
|
+
* stream. The previous 2000ms grace was SHORTER than the reap deadline, so on an
|
|
22
|
+
* inactivity timeout the caller could terminalize BEFORE death was proven and
|
|
23
|
+
* the unconfirmed-death disclosure was dropped (runCliHarness wires no
|
|
24
|
+
* `onTerminationUnconfirmed` callback, the only channel an early
|
|
25
|
+
* iterator.return leaves). A pathological in-memory source still cannot park the
|
|
26
|
+
* run past this bound. Overridable per-call for deterministic tests. */
|
|
27
|
+
const REAP_PROOF_DEADLINE_MS = 8000;
|
|
15
28
|
export class HarnessInactivityTimeoutError extends Error {
|
|
16
29
|
timeoutMs;
|
|
17
30
|
constructor(timeoutMs) {
|
|
@@ -27,6 +40,7 @@ export async function* withInactivityWatchdog(source, opts) {
|
|
|
27
40
|
let timer = null;
|
|
28
41
|
let timedOut = false;
|
|
29
42
|
let wake = null;
|
|
43
|
+
const cleanupDeadlineMs = opts.cleanupDeadlineMs ?? REAP_PROOF_DEADLINE_MS;
|
|
30
44
|
const arm = () => {
|
|
31
45
|
if (timer)
|
|
32
46
|
clearTimeout(timer);
|
|
@@ -43,35 +57,108 @@ export async function* withInactivityWatchdog(source, opts) {
|
|
|
43
57
|
// else on the event loop, and an unref'd watchdog would let node exit 0
|
|
44
58
|
// mid-run instead of firing the timeout.
|
|
45
59
|
};
|
|
60
|
+
// Hold the in-flight next() across the race so a timeout NEVER orphans it: the
|
|
61
|
+
// very next value the source produces (the source reacting to the abort with
|
|
62
|
+
// its terminal death-proof events) must be consumed by the drain, not silently
|
|
63
|
+
// eaten by an abandoned pending promise from this loop.
|
|
64
|
+
let pending = null;
|
|
46
65
|
try {
|
|
47
66
|
arm();
|
|
48
67
|
for (;;) {
|
|
68
|
+
if (!pending)
|
|
69
|
+
pending = iterator.next();
|
|
49
70
|
// Race the next event against the watchdog firing: after onTimeout()
|
|
50
71
|
// aborts the child, the source SHOULD end on its own, but a stuck
|
|
51
72
|
// iterator must not keep the run parked — the sentinel wakes the pump.
|
|
52
|
-
const
|
|
53
|
-
|
|
73
|
+
const raced = await Promise.race([
|
|
74
|
+
pending.then((result) => ({
|
|
75
|
+
kind: "next",
|
|
76
|
+
result,
|
|
77
|
+
})),
|
|
54
78
|
new Promise((resolve) => {
|
|
55
|
-
wake = () => resolve("timeout");
|
|
79
|
+
wake = () => resolve({ kind: "timeout" });
|
|
56
80
|
if (timedOut)
|
|
57
|
-
resolve("timeout");
|
|
81
|
+
resolve({ kind: "timeout" });
|
|
58
82
|
}),
|
|
59
83
|
]);
|
|
60
|
-
if (
|
|
84
|
+
if (raced.kind === "timeout" || timedOut) {
|
|
85
|
+
// Inactivity fired. onTimeout() already aborted the child. Do NOT throw
|
|
86
|
+
// and terminalize yet: DRAIN the aborted source to its process-reap
|
|
87
|
+
// deadline so the underlying spawnProcess whole-tree death proof runs
|
|
88
|
+
// and its typed `termination_unconfirmed` terminal fact (14e958a3) is
|
|
89
|
+
// emitted THROUGH the stream — instead of being cut off by an early
|
|
90
|
+
// iterator.return whose only disclosure channel (spawnProcess's
|
|
91
|
+
// `onTerminationUnconfirmed` callback) runCliHarness never wires up.
|
|
92
|
+
// The still-pending next() is handed to the drain so the FIRST terminal
|
|
93
|
+
// event is not lost; yielding the drained events lets the caller see the
|
|
94
|
+
// unconfirmed-death error/terminal before it terminalizes on the throw.
|
|
95
|
+
yield* drainAfterTimeout(iterator, pending, cleanupDeadlineMs);
|
|
61
96
|
throw new HarnessInactivityTimeoutError(opts.timeoutMs);
|
|
62
97
|
}
|
|
63
|
-
|
|
98
|
+
pending = null;
|
|
99
|
+
if (raced.result.done)
|
|
64
100
|
return;
|
|
65
101
|
arm();
|
|
66
|
-
yield
|
|
102
|
+
yield raced.result.value;
|
|
67
103
|
}
|
|
68
104
|
}
|
|
69
105
|
finally {
|
|
70
106
|
if (timer)
|
|
71
107
|
clearTimeout(timer);
|
|
72
|
-
//
|
|
73
|
-
// finally -> requestCancel
|
|
74
|
-
|
|
108
|
+
// AWAIT the source's cleanup (QA-027): iterator.return() drives
|
|
109
|
+
// spawnProcess's finally -> requestCancel, i.e. the process teardown. It
|
|
110
|
+
// used to be fire-and-forgotten, so the agent loop could break on abort and
|
|
111
|
+
// the run could reach its `cancelled` terminal BEFORE the child was proven
|
|
112
|
+
// dead. Awaiting makes the terminal strictly follow the death proof.
|
|
113
|
+
//
|
|
114
|
+
// Bound the wait by the SAME reap deadline the drain uses (not a shorter
|
|
115
|
+
// grace): a cooperative spawnProcess-backed stream resolves return() as soon
|
|
116
|
+
// as the reap settles, so the terminal follows the death proof in the real
|
|
117
|
+
// path; a pathological in-memory source suspended in an UNRELATED await must
|
|
118
|
+
// never park the terminal past the reap's own deadline. (After a timeout the
|
|
119
|
+
// drain above already ran the source to completion, so this return() is then
|
|
120
|
+
// a fast no-op.)
|
|
121
|
+
const ret = iterator.return?.(undefined);
|
|
122
|
+
if (ret) {
|
|
123
|
+
await Promise.race([
|
|
124
|
+
Promise.resolve(ret).then(() => undefined, () => undefined),
|
|
125
|
+
new Promise((resolve) => {
|
|
126
|
+
const grace = setTimeout(resolve, cleanupDeadlineMs);
|
|
127
|
+
grace.unref?.();
|
|
128
|
+
}),
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* After an inactivity timeout aborted the child, pump the source to completion
|
|
135
|
+
* so its own teardown/death-proof events (the typed `termination_unconfirmed`
|
|
136
|
+
* terminal fact and terminal `completed`) surface through the stream, bounded by
|
|
137
|
+
* the process-reap deadline so a source that cannot prove death still cannot
|
|
138
|
+
* park the run. The inactivity timer is NOT re-armed here — the source is being
|
|
139
|
+
* torn down, and a second timeout would race the reap it is waiting on.
|
|
140
|
+
*/
|
|
141
|
+
async function* drainAfterTimeout(iterator, pending, deadlineMs) {
|
|
142
|
+
const deadline = new Promise((resolve) => {
|
|
143
|
+
const t = setTimeout(() => resolve("deadline"), Math.max(1, deadlineMs));
|
|
144
|
+
t.unref?.();
|
|
145
|
+
});
|
|
146
|
+
// Start from the loop's still-in-flight next() (the abort-reaction event),
|
|
147
|
+
// then keep pumping until the source ends or the reap deadline elapses.
|
|
148
|
+
let cur = pending;
|
|
149
|
+
for (;;) {
|
|
150
|
+
const drained = await Promise.race([
|
|
151
|
+
cur.then((result) => ({ kind: "next", result })),
|
|
152
|
+
deadline,
|
|
153
|
+
]);
|
|
154
|
+
// Source could not prove death within the reap deadline — give up draining;
|
|
155
|
+
// the outer `finally` runs iterator.return() (also bounded) as a last resort.
|
|
156
|
+
if (drained === "deadline")
|
|
157
|
+
return;
|
|
158
|
+
if (drained.result.done)
|
|
159
|
+
return;
|
|
160
|
+
yield drained.result.value;
|
|
161
|
+
cur = iterator.next();
|
|
75
162
|
}
|
|
76
163
|
}
|
|
77
164
|
//# sourceMappingURL=inactivity.js.map
|
package/dist/inactivity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inactivity.js","sourceRoot":"","sources":["../src/inactivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACjC;IAArB,YAAqB,SAAiB;QACpC,KAAK,CACH,kCAAkC,SAAS,4BAA4B;YACrE,6DAA6D;YAC7D,gFAAgF,CACnF,CAAC;QALiB,cAAS,GAAT,SAAS,CAAQ;QAMpC,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,sBAAsB,CAC3C,MAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"inactivity.js","sourceRoot":"","sources":["../src/inactivity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH;;;;;;;;;;;wEAWwE;AACxE,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACjC;IAArB,YAAqB,SAAiB;QACpC,KAAK,CACH,kCAAkC,SAAS,4BAA4B;YACrE,6DAA6D;YAC7D,gFAAgF,CACnF,CAAC;QALiB,cAAS,GAAT,SAAS,CAAQ;QAMpC,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,sBAAsB,CAC3C,MAAwB,EACxB,IAkBC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;IAChD,IAAI,KAAK,GAAyC,IAAI,CAAC;IACvD,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAwB,IAAI,CAAC;IACrC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