@oxagen/cli 3.0.1-791 → 3.0.1-793
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/oxagen.mjs +650 -148
- package/package.json +1 -1
package/oxagen.mjs
CHANGED
|
@@ -5369,7 +5369,13 @@ var init_envelope = __esm({
|
|
|
5369
5369
|
// (`assistant-session.ts` in @oxagen/agent), never a host. The body is
|
|
5370
5370
|
// opaque on the wire. Its strict schema is `loopDetectedBodySchema` in
|
|
5371
5371
|
// `loop-detected.ts`.
|
|
5372
|
-
"oxagen:loop_detected": external_exports.object({}).catchall(json)
|
|
5372
|
+
"oxagen:loop_detected": external_exports.object({}).catchall(json),
|
|
5373
|
+
// The hook daemon told a wrapped agent, once, that it kept making the same
|
|
5374
|
+
// call and getting the same result (#8572): the loop's kind, the frame of
|
|
5375
|
+
// the call that brought it to where it starts, and the hook whose answer
|
|
5376
|
+
// carried the notice. The body is opaque on the wire. Its strict schema is
|
|
5377
|
+
// `loopNoticeBodySchema` in `collector/loop-notice.ts`.
|
|
5378
|
+
"oxagen:loop_notice": external_exports.object({}).catchall(json)
|
|
5373
5379
|
};
|
|
5374
5380
|
TACHO_KINDS = Object.keys(KIND_BODIES);
|
|
5375
5381
|
agentIdentitySchema = external_exports.object({
|
|
@@ -14700,11 +14706,11 @@ function normalizeHook(raw, env, options) {
|
|
|
14700
14706
|
}
|
|
14701
14707
|
case "PostToolUse":
|
|
14702
14708
|
case "PostToolUseFailure": {
|
|
14703
|
-
const
|
|
14709
|
+
const failed5 = input.hook_event_name === "PostToolUseFailure";
|
|
14704
14710
|
const facts = toolFacts2(input, options.sessionUuid);
|
|
14705
14711
|
const body2 = {
|
|
14706
14712
|
...facts,
|
|
14707
|
-
tool_status:
|
|
14713
|
+
tool_status: failed5 ? "error" : "ok",
|
|
14708
14714
|
...input.duration_ms !== void 0 ? { tool_duration_ms: count(input.duration_ms) } : {}
|
|
14709
14715
|
};
|
|
14710
14716
|
if (input.tool_response !== void 0) {
|
|
@@ -14717,7 +14723,7 @@ function normalizeHook(raw, env, options) {
|
|
|
14717
14723
|
body2["tool_result_tokens_basis"] = "estimated";
|
|
14718
14724
|
}
|
|
14719
14725
|
let errorText4;
|
|
14720
|
-
if (
|
|
14726
|
+
if (failed5) {
|
|
14721
14727
|
const error2 = input.error ?? input["error_type"];
|
|
14722
14728
|
if (error2 !== void 0) {
|
|
14723
14729
|
errorText4 = typeof error2 === "string" ? error2 : JSON.stringify(error2);
|
|
@@ -14730,7 +14736,7 @@ function normalizeHook(raw, env, options) {
|
|
|
14730
14736
|
const drafts = [
|
|
14731
14737
|
draft("tool_call", body2, toolCallContent(input, errorText4))
|
|
14732
14738
|
];
|
|
14733
|
-
const effectFrame =
|
|
14739
|
+
const effectFrame = failed5 || facts["effect_id"] === void 0 ? void 0 : effectFrameKind(
|
|
14734
14740
|
facts["effect_kind"],
|
|
14735
14741
|
facts["tool_source"]
|
|
14736
14742
|
);
|
|
@@ -17676,11 +17682,11 @@ function completeCall(state, call2, exitCode, status2, mcpName) {
|
|
|
17676
17682
|
function toolCallDraft(frame2, record2, ts2) {
|
|
17677
17683
|
const output = frame2.output;
|
|
17678
17684
|
const outputText = output === void 0 ? void 0 : jcs(output);
|
|
17679
|
-
const
|
|
17685
|
+
const failed5 = frame2.status !== void 0 || frame2.exitCode !== void 0 && frame2.exitCode !== 0;
|
|
17680
17686
|
const body2 = {};
|
|
17681
17687
|
if (frame2.name !== void 0) body2["tool_name"] = frame2.name;
|
|
17682
17688
|
if (frame2.call !== void 0) body2["tool_use_id"] = frame2.call;
|
|
17683
|
-
body2["tool_status"] = frame2.status === "declined" ? "rejected" :
|
|
17689
|
+
body2["tool_status"] = frame2.status === "declined" ? "rejected" : failed5 ? "error" : "ok";
|
|
17684
17690
|
if (frame2.inputDigest !== void 0) {
|
|
17685
17691
|
body2["tool_input_digest"] = frame2.inputDigest;
|
|
17686
17692
|
body2["tool_input_bytes"] = frame2.inputBytes;
|
|
@@ -19967,18 +19973,18 @@ function normalizeTranscriptLine(line, fallbackTs, toolInputs) {
|
|
|
19967
19973
|
if (s(item?.["type"]) !== "tool_result") continue;
|
|
19968
19974
|
const toolUseResult = record2["toolUseResult"];
|
|
19969
19975
|
const toolUseId = s(item?.["tool_use_id"]);
|
|
19970
|
-
const
|
|
19976
|
+
const failed5 = b(item?.["is_error"]) === true;
|
|
19971
19977
|
const held = toolUseId !== void 0 ? toolInputs?.take(toolUseId) : void 0;
|
|
19972
19978
|
const input = held?.input;
|
|
19973
|
-
const error2 =
|
|
19974
|
-
const output = toolUseResult ?? (
|
|
19979
|
+
const error2 = failed5 ? resultText(item?.["content"]) : void 0;
|
|
19980
|
+
const output = toolUseResult ?? (failed5 ? void 0 : item?.["content"]);
|
|
19975
19981
|
const exitCode = error2 !== void 0 ? exitCodeOfErrorText(error2) : void 0;
|
|
19976
19982
|
drafts.push({
|
|
19977
19983
|
...draft(
|
|
19978
19984
|
"tool_call",
|
|
19979
19985
|
{
|
|
19980
19986
|
...defined({ tool_name: held?.name, tool_use_id: toolUseId }),
|
|
19981
|
-
tool_status:
|
|
19987
|
+
tool_status: failed5 ? "error" : "ok",
|
|
19982
19988
|
// The input's hash and size by the formula the hook uses, so
|
|
19983
19989
|
// a call only the transcript recorded can be compared with
|
|
19984
19990
|
// an identical call for loops and retries.
|
|
@@ -23719,14 +23725,14 @@ var init_transcript_tailer = __esm({
|
|
|
23719
23725
|
cursor.agents = { ...cursor.agents, [subagentId]: sub };
|
|
23720
23726
|
this.dirty = true;
|
|
23721
23727
|
}
|
|
23722
|
-
const { fed, failed:
|
|
23728
|
+
const { fed, failed: failed5 } = await this.advance(
|
|
23723
23729
|
session,
|
|
23724
23730
|
sub,
|
|
23725
23731
|
Number.POSITIVE_INFINITY,
|
|
23726
23732
|
IN_QUEUE,
|
|
23727
23733
|
subagentId
|
|
23728
23734
|
);
|
|
23729
|
-
if (
|
|
23735
|
+
if (failed5) {
|
|
23730
23736
|
this.options.log?.(
|
|
23731
23737
|
`subagent transcript ${sub.path} stays open after its SubagentStop: the read failed at ${sub.offset}`
|
|
23732
23738
|
);
|
|
@@ -24083,9 +24089,9 @@ var init_transcript_tailer = __esm({
|
|
|
24083
24089
|
return true;
|
|
24084
24090
|
};
|
|
24085
24091
|
const standsAt = (from) => applyStat() && sealer.current() && cursor.offset === from;
|
|
24086
|
-
const done = async (
|
|
24092
|
+
const done = async (failed5) => {
|
|
24087
24093
|
if (!statApplied) await sealer.run(applyStat);
|
|
24088
|
-
return { fed, failed:
|
|
24094
|
+
return { fed, failed: failed5, bytes };
|
|
24089
24095
|
};
|
|
24090
24096
|
let remaining = budget;
|
|
24091
24097
|
let offset = replaced ? 0 : at2;
|
|
@@ -28850,13 +28856,13 @@ async function issueStatic(harness, deps) {
|
|
|
28850
28856
|
}
|
|
28851
28857
|
async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
28852
28858
|
const restored = [];
|
|
28853
|
-
const
|
|
28859
|
+
const failed5 = [];
|
|
28854
28860
|
const warnings = [];
|
|
28855
28861
|
let custodyUnreadable = false;
|
|
28856
28862
|
const contract = deps.modelCredentials;
|
|
28857
28863
|
const store = deps.credentialStore;
|
|
28858
28864
|
if (contract === void 0)
|
|
28859
|
-
return { restored, failed:
|
|
28865
|
+
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
28860
28866
|
const helperCommand = deps.runtime.credentialHelperCommand;
|
|
28861
28867
|
const heldElsewhere = harnessesHeldElsewhere(deps.paths, deps.paths.dir);
|
|
28862
28868
|
for (const harness of MODEL_CREDENTIAL_HARNESSES) {
|
|
@@ -28888,7 +28894,7 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
28888
28894
|
if (unreadable !== void 0) {
|
|
28889
28895
|
custodyUnreadable = true;
|
|
28890
28896
|
if (mode === "passthrough") {
|
|
28891
|
-
|
|
28897
|
+
failed5.push(
|
|
28892
28898
|
`the ${provider} credential in custody cannot be read (${unreadable}); ${label} keeps its run token until the store is fixed`
|
|
28893
28899
|
);
|
|
28894
28900
|
continue;
|
|
@@ -28925,10 +28931,10 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
28925
28931
|
}
|
|
28926
28932
|
}
|
|
28927
28933
|
} catch (error2) {
|
|
28928
|
-
|
|
28934
|
+
failed5.push(error2 instanceof Error ? error2.message : String(error2));
|
|
28929
28935
|
}
|
|
28930
28936
|
}
|
|
28931
|
-
return { restored, failed:
|
|
28937
|
+
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
28932
28938
|
}
|
|
28933
28939
|
async function acquireSubscriptionToken(options, deps) {
|
|
28934
28940
|
const io = deps.subscriptionLogin;
|
|
@@ -29909,7 +29915,7 @@ import { readFileSync as readFileSync10 } from "node:fs";
|
|
|
29909
29915
|
import { dirname as dirname9, resolve as resolve3 } from "node:path";
|
|
29910
29916
|
import { fileURLToPath } from "node:url";
|
|
29911
29917
|
function readVersion() {
|
|
29912
|
-
if (true) return "3.0.1-
|
|
29918
|
+
if (true) return "3.0.1-793";
|
|
29913
29919
|
try {
|
|
29914
29920
|
const here = dirname9(fileURLToPath(import.meta.url));
|
|
29915
29921
|
const pkg = JSON.parse(
|
|
@@ -30228,10 +30234,10 @@ function claudeFacts(exec4, platform = process.platform, env = process.env, home
|
|
|
30228
30234
|
}
|
|
30229
30235
|
function settleOrThrow(harnessFiles) {
|
|
30230
30236
|
const outcomes = harnessFiles.settle();
|
|
30231
|
-
const
|
|
30232
|
-
if (
|
|
30237
|
+
const failed5 = outcomes.filter((outcome) => outcome.result === "failed");
|
|
30238
|
+
if (failed5.length > 0)
|
|
30233
30239
|
throw new Error(
|
|
30234
|
-
|
|
30240
|
+
failed5.map((outcome) => `${outcome.path} ${outcome.reason}`).join("; ")
|
|
30235
30241
|
);
|
|
30236
30242
|
return outcomes;
|
|
30237
30243
|
}
|
|
@@ -30921,9 +30927,9 @@ async function untrustCodexHooks(options) {
|
|
|
30921
30927
|
let problem;
|
|
30922
30928
|
ours.forEach((hook, index) => {
|
|
30923
30929
|
const answer = wrote.answers[index] ?? {};
|
|
30924
|
-
const
|
|
30925
|
-
if (
|
|
30926
|
-
else problem ??=
|
|
30930
|
+
const failed5 = answerProblem(answer, CONFIG_WRITE);
|
|
30931
|
+
if (failed5 === void 0) removed.push(hook.key);
|
|
30932
|
+
else problem ??= failed5;
|
|
30927
30933
|
});
|
|
30928
30934
|
return problem === void 0 ? { removed } : { removed, problem };
|
|
30929
30935
|
}
|
|
@@ -36020,8 +36026,8 @@ async function revokeAndMark(host, options, deps, warnings) {
|
|
|
36020
36026
|
}
|
|
36021
36027
|
async function restoreModelBaseUrlsFor(host, deps) {
|
|
36022
36028
|
const restored = [];
|
|
36023
|
-
const
|
|
36024
|
-
if (deps.modelBaseUrls === void 0) return { restored, failed:
|
|
36029
|
+
const failed5 = [];
|
|
36030
|
+
if (deps.modelBaseUrls === void 0) return { restored, failed: failed5 };
|
|
36025
36031
|
const stellaHome = dirname14(deps.paths.stellaToml);
|
|
36026
36032
|
const heldElsewhere = harnessesHeldElsewhere(deps.paths, deps.paths.dir);
|
|
36027
36033
|
for (const harness of MODEL_BASE_URL_HARNESSES) {
|
|
@@ -36050,10 +36056,10 @@ async function restoreModelBaseUrlsFor(host, deps) {
|
|
|
36050
36056
|
for (const entry2 of state.harnesses)
|
|
36051
36057
|
if (entry2.changed) restored.push(entry2.file);
|
|
36052
36058
|
} catch (error2) {
|
|
36053
|
-
|
|
36059
|
+
failed5.push(error2 instanceof Error ? error2.message : String(error2));
|
|
36054
36060
|
}
|
|
36055
36061
|
}
|
|
36056
|
-
return { restored, failed:
|
|
36062
|
+
return { restored, failed: failed5 };
|
|
36057
36063
|
}
|
|
36058
36064
|
async function disarmGateway(host, deps, warnings) {
|
|
36059
36065
|
const credentials2 = await restoreCredentials(host, deps, "passthrough");
|
|
@@ -36087,13 +36093,13 @@ async function stopGateway(host, deps, warnings) {
|
|
|
36087
36093
|
return true;
|
|
36088
36094
|
}
|
|
36089
36095
|
async function stripEnrollmentHooks(host, deps, settle4 = false) {
|
|
36090
|
-
const
|
|
36096
|
+
const failed5 = [];
|
|
36091
36097
|
const attempt = (path2, run3) => {
|
|
36092
36098
|
try {
|
|
36093
36099
|
run3();
|
|
36094
36100
|
} catch (error2) {
|
|
36095
36101
|
const reason3 = error2 instanceof Error ? error2.message : String(error2);
|
|
36096
|
-
|
|
36102
|
+
failed5.push(reason3.includes(path2) ? reason3 : `${path2}: ${reason3}`);
|
|
36097
36103
|
}
|
|
36098
36104
|
};
|
|
36099
36105
|
const heldElsewhere = harnessesHeldElsewhere(deps.paths, deps.paths.dir);
|
|
@@ -36218,11 +36224,11 @@ async function stripEnrollmentHooks(host, deps, settle4 = false) {
|
|
|
36218
36224
|
});
|
|
36219
36225
|
});
|
|
36220
36226
|
}
|
|
36221
|
-
if (settle4 &&
|
|
36227
|
+
if (settle4 && failed5.length === 0) {
|
|
36222
36228
|
try {
|
|
36223
36229
|
deps.settleHarnessFiles?.();
|
|
36224
36230
|
} catch (error2) {
|
|
36225
|
-
|
|
36231
|
+
failed5.push(
|
|
36226
36232
|
`restoring the original files: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
36227
36233
|
);
|
|
36228
36234
|
}
|
|
@@ -36237,7 +36243,7 @@ async function stripEnrollmentHooks(host, deps, settle4 = false) {
|
|
|
36237
36243
|
...stellaMcpChanged !== void 0 ? { stellaMcpChanged } : {},
|
|
36238
36244
|
claudeDesktopChanged,
|
|
36239
36245
|
...claudeCodeMcpChanged !== void 0 ? { claudeCodeMcpChanged } : {},
|
|
36240
|
-
failed:
|
|
36246
|
+
failed: failed5
|
|
36241
36247
|
};
|
|
36242
36248
|
}
|
|
36243
36249
|
async function unenroll(options, deps) {
|
|
@@ -36582,15 +36588,15 @@ async function unenrollLocked(options, deps) {
|
|
|
36582
36588
|
["pending session ends", deps.paths.pendingEnds, false]
|
|
36583
36589
|
];
|
|
36584
36590
|
const purged = parts.filter(([, path2, recursive]) => remove2(path2, recursive)).map(([name2]) => name2);
|
|
36585
|
-
let
|
|
36591
|
+
let failed5 = purged.length < parts.length;
|
|
36586
36592
|
if (!existsSync16(join24(deps.paths.dir, HARNESS_RECEIPTS)) && !remove2(join24(deps.paths.dir, HARNESS_BACKUPS), true))
|
|
36587
|
-
|
|
36593
|
+
failed5 = true;
|
|
36588
36594
|
const logShared = otherLiveAgents(deps.paths, deps.paths.dir).length > 0;
|
|
36589
36595
|
if (!logShared) {
|
|
36590
36596
|
if (remove2(deps.paths.log)) purged.push("the collector log");
|
|
36591
|
-
else
|
|
36597
|
+
else failed5 = true;
|
|
36592
36598
|
}
|
|
36593
|
-
const kept =
|
|
36599
|
+
const kept = failed5 ? "; the rest could not be removed" : "";
|
|
36594
36600
|
if (purged.length > 0) deps.out(` ${listOf2(purged)} purged${kept}`);
|
|
36595
36601
|
else deps.out(" nothing could be purged");
|
|
36596
36602
|
if (logShared)
|
|
@@ -44606,9 +44612,9 @@ function createWorkOrderAutostart(deps) {
|
|
|
44606
44612
|
);
|
|
44607
44613
|
}
|
|
44608
44614
|
async function endSend(id2, reason3) {
|
|
44609
|
-
const
|
|
44615
|
+
const failed5 = await refuseWorkOrder(deps.client, id2, reason3);
|
|
44610
44616
|
log(
|
|
44611
|
-
|
|
44617
|
+
failed5 === void 0 ? `work order ${id2} cannot start here and is removed: ${reason3}` : `work order ${id2} cannot start here and is removed: ${reason3} Oxagen was not told (${failed5}); a person can end the send in the app.`
|
|
44612
44618
|
);
|
|
44613
44619
|
await abandon(id2);
|
|
44614
44620
|
}
|
|
@@ -44767,9 +44773,9 @@ function createWorkOrderAutostart(deps) {
|
|
|
44767
44773
|
if (sessions.has(id2)) return;
|
|
44768
44774
|
const said = lastLogLine(logPath);
|
|
44769
44775
|
const reason3 = `${binary} ${exitPhrase(exit)} before it opened a run.${said !== void 0 ? ` Its last output: ${said}` : ""} The full output is in ${logPath} on this machine.`;
|
|
44770
|
-
const
|
|
44776
|
+
const failed5 = await refuseWorkOrder(deps.client, id2, reason3.slice(0, 512));
|
|
44771
44777
|
log(
|
|
44772
|
-
|
|
44778
|
+
failed5 === void 0 ? `work order ${id2}: ${reason3} Oxagen ended the send.` : `work order ${id2}: ${reason3} Oxagen kept the send (${failed5}).`
|
|
44773
44779
|
);
|
|
44774
44780
|
}
|
|
44775
44781
|
function watch2(id2, binary, workspace, exited) {
|
|
@@ -45240,10 +45246,10 @@ async function readPreexistingPaths(exec4, root, startedAtMs, copies) {
|
|
|
45240
45246
|
);
|
|
45241
45247
|
let room = copies === void 0 ? 0 : copies.capBytes - await copiedBytes(copies.dir);
|
|
45242
45248
|
const planned = present.sort(byPath).map((file) => {
|
|
45243
|
-
const
|
|
45244
|
-
const copied = copies !== void 0 &&
|
|
45249
|
+
const hashed2 = !(file.found.kind === "file" && file.found.size > MAX_HASHED_FILE_BYTES);
|
|
45250
|
+
const copied = copies !== void 0 && hashed2 && file.found.kind === "file" && file.found.size <= room;
|
|
45245
45251
|
if (copied) room -= file.found.size;
|
|
45246
|
-
return { ...file, hashed, copied };
|
|
45252
|
+
return { ...file, hashed: hashed2, copied };
|
|
45247
45253
|
});
|
|
45248
45254
|
await pooled(
|
|
45249
45255
|
planned.map((file) => async () => {
|
|
@@ -47147,7 +47153,137 @@ var init_subagent_meta = __esm({
|
|
|
47147
47153
|
});
|
|
47148
47154
|
|
|
47149
47155
|
// ../../packages/tacho/src/loops.ts
|
|
47150
|
-
|
|
47156
|
+
function isMcpTool(tool) {
|
|
47157
|
+
return tool.startsWith(MCP_TOOL_PREFIX) || tool.startsWith(CURSOR_MCP_TOOL_PREFIX);
|
|
47158
|
+
}
|
|
47159
|
+
function slotsOf(steps) {
|
|
47160
|
+
return steps.map((step) => "fileChanged" in step ? null : step);
|
|
47161
|
+
}
|
|
47162
|
+
function sameResult(a, b3) {
|
|
47163
|
+
return a.tool === b3.tool && a.inputHash === b3.inputHash && a.outputHash === b3.outputHash;
|
|
47164
|
+
}
|
|
47165
|
+
function sameFailure(a, b3) {
|
|
47166
|
+
return a.tool === b3.tool && a.inputHash === b3.inputHash && a.errorClass === b3.errorClass;
|
|
47167
|
+
}
|
|
47168
|
+
function hashed(c) {
|
|
47169
|
+
return c.inputHash !== "" && c.outputHash !== "";
|
|
47170
|
+
}
|
|
47171
|
+
function failed(c) {
|
|
47172
|
+
return c.inputHash !== "" && c.errorClass !== null && c.errorClass !== "";
|
|
47173
|
+
}
|
|
47174
|
+
function reaches(loop, length) {
|
|
47175
|
+
const calls = loop.positions.length;
|
|
47176
|
+
return "calls" in length ? calls >= length.calls : Math.floor(calls / loop.period) >= length.cycles;
|
|
47177
|
+
}
|
|
47178
|
+
function streaks(slots, kind, joins, matches2) {
|
|
47179
|
+
const out = [];
|
|
47180
|
+
let run3 = [];
|
|
47181
|
+
let positions = [];
|
|
47182
|
+
const close = () => {
|
|
47183
|
+
const first = run3[0];
|
|
47184
|
+
if (first !== void 0 && run3.length >= 2)
|
|
47185
|
+
out.push({ kind, positions, period: 1, tool: first.tool });
|
|
47186
|
+
run3 = [];
|
|
47187
|
+
positions = [];
|
|
47188
|
+
};
|
|
47189
|
+
slots.forEach((c, i2) => {
|
|
47190
|
+
if (c === null || !joins(c)) {
|
|
47191
|
+
close();
|
|
47192
|
+
return;
|
|
47193
|
+
}
|
|
47194
|
+
const last = run3.at(-1);
|
|
47195
|
+
if (last !== void 0 && !matches2(last, c)) close();
|
|
47196
|
+
run3.push(c);
|
|
47197
|
+
positions.push(i2);
|
|
47198
|
+
});
|
|
47199
|
+
close();
|
|
47200
|
+
return out;
|
|
47201
|
+
}
|
|
47202
|
+
function shortCycles(slots) {
|
|
47203
|
+
const out = [];
|
|
47204
|
+
const segments = [[]];
|
|
47205
|
+
slots.forEach((c, i2) => {
|
|
47206
|
+
if (c === null || !hashed(c)) segments.push([]);
|
|
47207
|
+
else segments.at(-1)?.push({ call: c, at: i2 });
|
|
47208
|
+
});
|
|
47209
|
+
for (const segment of segments) {
|
|
47210
|
+
const same = (k, period) => {
|
|
47211
|
+
const a = segment[k];
|
|
47212
|
+
const b3 = segment[k - period];
|
|
47213
|
+
return a !== void 0 && b3 !== void 0 && sameResult(a.call, b3.call);
|
|
47214
|
+
};
|
|
47215
|
+
for (let period = 2; period <= MAX_PERIOD; period += 1) {
|
|
47216
|
+
let k = period;
|
|
47217
|
+
while (k < segment.length) {
|
|
47218
|
+
if (!same(k, period)) {
|
|
47219
|
+
k += 1;
|
|
47220
|
+
continue;
|
|
47221
|
+
}
|
|
47222
|
+
const start = k - period;
|
|
47223
|
+
let end = k;
|
|
47224
|
+
while (same(end, period)) end += 1;
|
|
47225
|
+
const cycle2 = segment.slice(start, start + period).map((s2) => s2.call);
|
|
47226
|
+
const distinct = cycle2.every(
|
|
47227
|
+
(c, j) => cycle2.slice(j + 1).every((d) => !sameResult(c, d))
|
|
47228
|
+
);
|
|
47229
|
+
const first = cycle2[0];
|
|
47230
|
+
if (first !== void 0 && distinct && end - start >= 2 * period)
|
|
47231
|
+
out.push({
|
|
47232
|
+
kind: "short_cycle",
|
|
47233
|
+
positions: segment.slice(start, end).map((s2) => s2.at),
|
|
47234
|
+
period,
|
|
47235
|
+
tool: first.tool
|
|
47236
|
+
});
|
|
47237
|
+
k = end;
|
|
47238
|
+
}
|
|
47239
|
+
}
|
|
47240
|
+
}
|
|
47241
|
+
return out;
|
|
47242
|
+
}
|
|
47243
|
+
function stagnations(slots) {
|
|
47244
|
+
const out = [];
|
|
47245
|
+
const seen = /* @__PURE__ */ new Map();
|
|
47246
|
+
let run3 = [];
|
|
47247
|
+
let positions = [];
|
|
47248
|
+
const close = () => {
|
|
47249
|
+
const first = run3[0];
|
|
47250
|
+
const inputs = new Set(run3.map((c) => c.inputHash));
|
|
47251
|
+
if (first !== void 0 && run3.length >= 2 && inputs.size >= 2)
|
|
47252
|
+
out.push({ kind: "stagnation", positions, period: 1, tool: first.tool });
|
|
47253
|
+
run3 = [];
|
|
47254
|
+
positions = [];
|
|
47255
|
+
};
|
|
47256
|
+
slots.forEach((c, i2) => {
|
|
47257
|
+
if (c === null || !hashed(c)) {
|
|
47258
|
+
close();
|
|
47259
|
+
return;
|
|
47260
|
+
}
|
|
47261
|
+
const outputs = seen.get(c.tool) ?? /* @__PURE__ */ new Set();
|
|
47262
|
+
const repeated = outputs.has(c.outputHash);
|
|
47263
|
+
outputs.add(c.outputHash);
|
|
47264
|
+
seen.set(c.tool, outputs);
|
|
47265
|
+
if (c.mayWrite || isMcpTool(c.tool)) {
|
|
47266
|
+
close();
|
|
47267
|
+
return;
|
|
47268
|
+
}
|
|
47269
|
+
const first = run3[0];
|
|
47270
|
+
if (first !== void 0 && (first.tool !== c.tool || !repeated)) close();
|
|
47271
|
+
run3.push(c);
|
|
47272
|
+
positions.push(i2);
|
|
47273
|
+
});
|
|
47274
|
+
close();
|
|
47275
|
+
return out;
|
|
47276
|
+
}
|
|
47277
|
+
function findLoops(steps, threshold) {
|
|
47278
|
+
const slots = slotsOf(steps);
|
|
47279
|
+
return [
|
|
47280
|
+
...streaks(slots, "exact_repeat", hashed, sameResult),
|
|
47281
|
+
...streaks(slots, "failing_retry", failed, sameFailure),
|
|
47282
|
+
...shortCycles(slots),
|
|
47283
|
+
...stagnations(slots)
|
|
47284
|
+
].filter((loop) => reaches(loop, threshold[loop.kind])).sort((a, b3) => (a.positions[0] ?? 0) - (b3.positions[0] ?? 0));
|
|
47285
|
+
}
|
|
47286
|
+
var LOOP_START, MAX_PERIOD, MCP_TOOL_PREFIX, CURSOR_MCP_TOOL_PREFIX;
|
|
47151
47287
|
var init_loops = __esm({
|
|
47152
47288
|
"../../packages/tacho/src/loops.ts"() {
|
|
47153
47289
|
"use strict";
|
|
@@ -47157,6 +47293,9 @@ var init_loops = __esm({
|
|
|
47157
47293
|
short_cycle: { cycles: 3 },
|
|
47158
47294
|
stagnation: { calls: 6 }
|
|
47159
47295
|
};
|
|
47296
|
+
MAX_PERIOD = 3;
|
|
47297
|
+
MCP_TOOL_PREFIX = "mcp__";
|
|
47298
|
+
CURSOR_MCP_TOOL_PREFIX = "MCP:";
|
|
47160
47299
|
}
|
|
47161
47300
|
});
|
|
47162
47301
|
|
|
@@ -47407,6 +47546,203 @@ var init_reflection_ask = __esm({
|
|
|
47407
47546
|
}
|
|
47408
47547
|
});
|
|
47409
47548
|
|
|
47549
|
+
// ../../packages/tacho/src/collector/loop-notice.ts
|
|
47550
|
+
function chainOf(record2, chain) {
|
|
47551
|
+
let chains = states2.get(record2);
|
|
47552
|
+
if (chains === void 0) {
|
|
47553
|
+
chains = /* @__PURE__ */ new Map();
|
|
47554
|
+
states2.set(record2, chains);
|
|
47555
|
+
}
|
|
47556
|
+
const state = chains.get(chain) ?? {
|
|
47557
|
+
calls: [],
|
|
47558
|
+
noticed: /* @__PURE__ */ new Set(),
|
|
47559
|
+
held: void 0
|
|
47560
|
+
};
|
|
47561
|
+
chains.delete(chain);
|
|
47562
|
+
chains.set(chain, state);
|
|
47563
|
+
for (const oldest of chains.keys()) {
|
|
47564
|
+
if (chains.size <= LOOP_CHAINS_PER_SESSION) break;
|
|
47565
|
+
chains.delete(oldest);
|
|
47566
|
+
}
|
|
47567
|
+
return state;
|
|
47568
|
+
}
|
|
47569
|
+
function isNoticed(kind) {
|
|
47570
|
+
return NOTICED_LOOP_KINDS.some((noticed) => noticed === kind);
|
|
47571
|
+
}
|
|
47572
|
+
function callId(call2) {
|
|
47573
|
+
return `${call2.tool}\0${call2.inputHash}`;
|
|
47574
|
+
}
|
|
47575
|
+
function loopKey(loop, calls) {
|
|
47576
|
+
const at2 = (i2) => i2 === void 0 ? void 0 : calls[i2];
|
|
47577
|
+
const first = at2(loop.positions[0]);
|
|
47578
|
+
if (first === void 0) return loop.kind;
|
|
47579
|
+
if (loop.kind === "stagnation") return `stagnation${first.tool}`;
|
|
47580
|
+
if (loop.kind === "short_cycle") {
|
|
47581
|
+
const cycle2 = loop.positions.slice(0, loop.period).map((i2) => at2(i2)).filter((c) => c !== void 0).map(callId).sort();
|
|
47582
|
+
return `short_cycle${cycle2.join("")}`;
|
|
47583
|
+
}
|
|
47584
|
+
return `${loop.kind}${callId(first)}`;
|
|
47585
|
+
}
|
|
47586
|
+
function noticeOf(loop, calls, key, also) {
|
|
47587
|
+
const last = calls[calls.length - 1];
|
|
47588
|
+
const length = loop.positions.length;
|
|
47589
|
+
const next = calls[calls.length - loop.period];
|
|
47590
|
+
const labels = loop.positions.slice(0, loop.kind === "short_cycle" ? loop.period : 1).map((i2) => calls[i2]?.label).filter((label) => label !== void 0);
|
|
47591
|
+
return {
|
|
47592
|
+
kind: loop.kind,
|
|
47593
|
+
key,
|
|
47594
|
+
also,
|
|
47595
|
+
tool: loop.tool,
|
|
47596
|
+
labels: labels.length > 0 ? labels : [loop.tool],
|
|
47597
|
+
repeats: loop.kind === "short_cycle" ? Math.floor(length / loop.period) : length,
|
|
47598
|
+
callSeq: last?.seq,
|
|
47599
|
+
next: {
|
|
47600
|
+
tool: next?.tool ?? loop.tool,
|
|
47601
|
+
inputHash: loop.kind === "stagnation" ? null : next?.inputHash ?? null
|
|
47602
|
+
}
|
|
47603
|
+
};
|
|
47604
|
+
}
|
|
47605
|
+
function noteLoopCall(record2, chain, call2) {
|
|
47606
|
+
const state = chainOf(record2, chain);
|
|
47607
|
+
state.calls.push(call2);
|
|
47608
|
+
if (state.calls.length > LOOP_WINDOW_CALLS)
|
|
47609
|
+
state.calls.splice(0, state.calls.length - LOOP_WINDOW_CALLS);
|
|
47610
|
+
const newest = state.calls.length - 1;
|
|
47611
|
+
const live = findLoops(state.calls, LOOP_START).filter(
|
|
47612
|
+
(loop) => isNoticed(loop.kind) && loop.positions.at(-1) === newest
|
|
47613
|
+
).sort(
|
|
47614
|
+
(a, b3) => NOTICED_LOOP_KINDS.indexOf(a.kind) - NOTICED_LOOP_KINDS.indexOf(b3.kind)
|
|
47615
|
+
);
|
|
47616
|
+
const keys = live.map((loop) => loopKey(loop, state.calls));
|
|
47617
|
+
for (const [i2, loop] of live.entries()) {
|
|
47618
|
+
const key = keys[i2];
|
|
47619
|
+
if (key === void 0 || state.noticed.has(key)) continue;
|
|
47620
|
+
return noticeOf(
|
|
47621
|
+
loop,
|
|
47622
|
+
state.calls,
|
|
47623
|
+
key,
|
|
47624
|
+
keys.filter((other) => other !== key)
|
|
47625
|
+
);
|
|
47626
|
+
}
|
|
47627
|
+
return void 0;
|
|
47628
|
+
}
|
|
47629
|
+
function markLoopNoticed(record2, chain, notice) {
|
|
47630
|
+
const { noticed } = chainOf(record2, chain);
|
|
47631
|
+
for (const key of [notice.key, ...notice.also]) noticed.add(key);
|
|
47632
|
+
for (const oldest of noticed) {
|
|
47633
|
+
if (noticed.size <= NOTICED_PER_CHAIN) break;
|
|
47634
|
+
noticed.delete(oldest);
|
|
47635
|
+
}
|
|
47636
|
+
}
|
|
47637
|
+
function holdLoopNotice(record2, chain, notice) {
|
|
47638
|
+
if (notice.next.inputHash === null) return;
|
|
47639
|
+
chainOf(record2, chain).held = notice;
|
|
47640
|
+
}
|
|
47641
|
+
function takeHeldLoopNotice(record2, chain) {
|
|
47642
|
+
const chains = states2.get(record2);
|
|
47643
|
+
const state = chains?.get(chain);
|
|
47644
|
+
if (state === void 0) return void 0;
|
|
47645
|
+
const held = state.held;
|
|
47646
|
+
state.held = void 0;
|
|
47647
|
+
return held;
|
|
47648
|
+
}
|
|
47649
|
+
function nextCallRepeats(notice, tool, inputHash) {
|
|
47650
|
+
return tool === notice.next.tool && notice.next.inputHash !== null && inputHash === notice.next.inputHash;
|
|
47651
|
+
}
|
|
47652
|
+
function endLoopWindow(record2, chain) {
|
|
47653
|
+
const state = states2.get(record2)?.get(chain);
|
|
47654
|
+
if (state === void 0) return;
|
|
47655
|
+
state.calls = [];
|
|
47656
|
+
state.held = void 0;
|
|
47657
|
+
}
|
|
47658
|
+
function forgetLoopNotices(record2) {
|
|
47659
|
+
states2.delete(record2);
|
|
47660
|
+
}
|
|
47661
|
+
function loopCallFrom(body2, seq2, label) {
|
|
47662
|
+
const text6 = (key) => {
|
|
47663
|
+
const value = body2[key];
|
|
47664
|
+
return typeof value === "string" ? value : "";
|
|
47665
|
+
};
|
|
47666
|
+
const status2 = text6("tool_status");
|
|
47667
|
+
const failed5 = status2 === "error" || status2 === "rejected";
|
|
47668
|
+
const errorClass2 = text6("tool_error_class");
|
|
47669
|
+
const tool = text6("tool_name");
|
|
47670
|
+
const output = text6("tool_output_digest");
|
|
47671
|
+
return {
|
|
47672
|
+
tool,
|
|
47673
|
+
inputHash: text6("tool_input_digest"),
|
|
47674
|
+
outputHash: output === "" && failed5 ? text6("tool_error_message_digest") : output,
|
|
47675
|
+
errorClass: failed5 && errorClass2 !== "" ? errorClass2 : null,
|
|
47676
|
+
mayWrite: body2["tool_is_mutating"] !== false,
|
|
47677
|
+
seq: seq2,
|
|
47678
|
+
label: label ?? tool
|
|
47679
|
+
};
|
|
47680
|
+
}
|
|
47681
|
+
function clipTool2(name2) {
|
|
47682
|
+
return name2.length > TOOL_NAME_MAX_CHARS2 ? `${name2.slice(0, TOOL_NAME_MAX_CHARS2 - 3)}...` : name2;
|
|
47683
|
+
}
|
|
47684
|
+
function inOrder(tools) {
|
|
47685
|
+
const last = tools.at(-1) ?? "";
|
|
47686
|
+
if (tools.length <= 1) return last;
|
|
47687
|
+
const rest = tools.slice(0, -1).join(", ");
|
|
47688
|
+
return tools.length === 2 ? `${rest} then ${last}` : `${rest}, then ${last}`;
|
|
47689
|
+
}
|
|
47690
|
+
function loopNoticeText(notice) {
|
|
47691
|
+
const tools = notice.labels.map(clipTool2);
|
|
47692
|
+
const tool = tools[0] ?? clipTool2(notice.tool);
|
|
47693
|
+
if (notice.kind === "stagnation")
|
|
47694
|
+
return `Oxagen: you ran ${tool} ${notice.repeats} times with different inputs and got only results it had already returned. Change the approach before you run it again.`;
|
|
47695
|
+
if (notice.kind === "short_cycle")
|
|
47696
|
+
return `Oxagen: you ran ${inOrder(tools)} with the same inputs ${notice.repeats} times and got the same results each time. Change the input or the approach before you run them again.`;
|
|
47697
|
+
return `Oxagen: you ran ${tool} with the same input ${notice.repeats} times and got the same result each time. Change the input or the approach before you run it again.`;
|
|
47698
|
+
}
|
|
47699
|
+
function loopNoticeBody(notice, boundary) {
|
|
47700
|
+
return {
|
|
47701
|
+
loop_kind: notice.kind,
|
|
47702
|
+
repeats: notice.repeats,
|
|
47703
|
+
tool_name: clipTool2(notice.tool),
|
|
47704
|
+
boundary,
|
|
47705
|
+
...notice.callSeq !== void 0 ? { call_seq: notice.callSeq } : {}
|
|
47706
|
+
};
|
|
47707
|
+
}
|
|
47708
|
+
var NOTICED_LOOP_KINDS, LOOP_NOTICE_BOUNDARIES, LOOP_NOTICE_REASON_CODE, LOOP_REFUSAL_LEAD, LOOP_WINDOW_CALLS, LOOP_CHAINS_PER_SESSION, NOTICED_PER_CHAIN, TOOL_NAME_MAX_CHARS2, ROOT_CHAIN, states2, loopNoticeBodySchema;
|
|
47709
|
+
var init_loop_notice = __esm({
|
|
47710
|
+
"../../packages/tacho/src/collector/loop-notice.ts"() {
|
|
47711
|
+
"use strict";
|
|
47712
|
+
init_zod();
|
|
47713
|
+
init_loops();
|
|
47714
|
+
NOTICED_LOOP_KINDS = [
|
|
47715
|
+
"exact_repeat",
|
|
47716
|
+
"short_cycle",
|
|
47717
|
+
"stagnation"
|
|
47718
|
+
];
|
|
47719
|
+
LOOP_NOTICE_BOUNDARIES = [
|
|
47720
|
+
"PostToolUse",
|
|
47721
|
+
"PostToolUseFailure",
|
|
47722
|
+
"PreToolUse"
|
|
47723
|
+
];
|
|
47724
|
+
LOOP_NOTICE_REASON_CODE = "loop_notice";
|
|
47725
|
+
LOOP_REFUSAL_LEAD = "This call did not run. ";
|
|
47726
|
+
LOOP_WINDOW_CALLS = 32;
|
|
47727
|
+
LOOP_CHAINS_PER_SESSION = 16;
|
|
47728
|
+
NOTICED_PER_CHAIN = 64;
|
|
47729
|
+
TOOL_NAME_MAX_CHARS2 = 64;
|
|
47730
|
+
ROOT_CHAIN = "";
|
|
47731
|
+
states2 = /* @__PURE__ */ new WeakMap();
|
|
47732
|
+
loopNoticeBodySchema = external_exports.object({
|
|
47733
|
+
loop_kind: external_exports.enum(NOTICED_LOOP_KINDS),
|
|
47734
|
+
/** Calls for an exact repeat or a stagnation, full cycles for a short cycle. */
|
|
47735
|
+
repeats: external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
|
|
47736
|
+
/** The tool of the loop's first call, clipped as the notice prints it. */
|
|
47737
|
+
tool_name: external_exports.string().max(TOOL_NAME_MAX_CHARS2),
|
|
47738
|
+
/** The hook whose answer carried the notice to the agent. */
|
|
47739
|
+
boundary: external_exports.enum(LOOP_NOTICE_BOUNDARIES),
|
|
47740
|
+
/** The frame of the call that brought the loop to where it starts. Absent when the hook recorded no frame for it. */
|
|
47741
|
+
call_seq: external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER).optional()
|
|
47742
|
+
}).strict();
|
|
47743
|
+
}
|
|
47744
|
+
});
|
|
47745
|
+
|
|
47410
47746
|
// ../../packages/tacho/src/interjection.ts
|
|
47411
47747
|
var digest4, timestamp, count5, configVersion, workspaceSlug, interjectionKeySchema, INTERJECTION_RECEIPT_ID_PATTERN, INTERJECTION_QUESTION_MAX, INTERJECTION_PATHS, INTERJECTION_ANSWER_SOURCES, SKILLS_RESOLVED_REASONS, repoUnknownBodySchema, interjectLinkPathSchema, interjectCreatePathSchema, INTERJECT_PROVIDERS, interjectBodySchema, answerBodySchema, repoBoundBodySchema, workspaceCreatedBodySchema, skillsResolvedBodySchema, interjectionAnswerPayloadSchema;
|
|
47412
47748
|
var init_interjection = __esm({
|
|
@@ -47784,7 +48120,7 @@ function recalledToolName(seen) {
|
|
|
47784
48120
|
}
|
|
47785
48121
|
function noteRecallHints(record2, toolName4, toolInput2) {
|
|
47786
48122
|
const hints = hintsOf(record2);
|
|
47787
|
-
if (toolName4 !== void 0 && toolName4.length > 0 && toolName4.length <=
|
|
48123
|
+
if (toolName4 !== void 0 && toolName4.length > 0 && toolName4.length <= TOOL_NAME_MAX_CHARS3)
|
|
47788
48124
|
hints.tools = inFront(
|
|
47789
48125
|
hints.tools,
|
|
47790
48126
|
recalledToolName(toolName4),
|
|
@@ -47862,13 +48198,13 @@ function recallScope(record2) {
|
|
|
47862
48198
|
function forgetRecallHints(record2) {
|
|
47863
48199
|
delete record2.recallHints;
|
|
47864
48200
|
}
|
|
47865
|
-
var RECALL_TOOLS_KEPT, RECALL_PATHS_KEPT,
|
|
48201
|
+
var RECALL_TOOLS_KEPT, RECALL_PATHS_KEPT, TOOL_NAME_MAX_CHARS3, PATH_MAX_CHARS, PATH_KEYS, MCP_PREFIX3, REPOSITORY_RETRY_FIRST_MS, REPOSITORY_RETRY_MAX_MS;
|
|
47866
48202
|
var init_recall_hints = __esm({
|
|
47867
48203
|
"../../packages/tacho/src/collector/recall-hints.ts"() {
|
|
47868
48204
|
"use strict";
|
|
47869
48205
|
RECALL_TOOLS_KEPT = 32;
|
|
47870
48206
|
RECALL_PATHS_KEPT = 64;
|
|
47871
|
-
|
|
48207
|
+
TOOL_NAME_MAX_CHARS3 = 200;
|
|
47872
48208
|
PATH_MAX_CHARS = 512;
|
|
47873
48209
|
PATH_KEYS = ["file_path", "path", "notebook_path"];
|
|
47874
48210
|
MCP_PREFIX3 = "mcp__";
|
|
@@ -48164,6 +48500,89 @@ function drainMidTurn(input, record2, deps, events, replay, used = 0) {
|
|
|
48164
48500
|
if (continuation !== void 0) texts.push(continuation);
|
|
48165
48501
|
return texts;
|
|
48166
48502
|
}
|
|
48503
|
+
function loopChainOf(input) {
|
|
48504
|
+
return input.agent_id ?? ROOT_CHAIN;
|
|
48505
|
+
}
|
|
48506
|
+
function subagentOf(input) {
|
|
48507
|
+
if (input.agent_id === void 0) return void 0;
|
|
48508
|
+
return {
|
|
48509
|
+
subagent_id: input.agent_id,
|
|
48510
|
+
...input.agent_type !== void 0 ? { subagent_type: input.agent_type } : {}
|
|
48511
|
+
};
|
|
48512
|
+
}
|
|
48513
|
+
function loopNoticeStep(deps, step, run3) {
|
|
48514
|
+
try {
|
|
48515
|
+
return run3();
|
|
48516
|
+
} catch (error2) {
|
|
48517
|
+
deps.log?.(
|
|
48518
|
+
`loop notice: could not ${step}, so the hook answers without it: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
48519
|
+
);
|
|
48520
|
+
return void 0;
|
|
48521
|
+
}
|
|
48522
|
+
}
|
|
48523
|
+
function noteFinishedCall(input, record2, payload, env, sealed) {
|
|
48524
|
+
if (record2.harness === "stella" || input.tool_name === void 0)
|
|
48525
|
+
return void 0;
|
|
48526
|
+
const frame2 = sealed.find((event) => event.kind === "tool_call");
|
|
48527
|
+
const body2 = frame2 !== void 0 && isRecord(frame2.body) ? frame2.body : normalizeHook(payload, env, {
|
|
48528
|
+
sessionUuid: record2.recorder.sessionUuid
|
|
48529
|
+
}).find((draft) => draft.kind === "tool_call")?.body;
|
|
48530
|
+
if (body2 === void 0) return void 0;
|
|
48531
|
+
return noteLoopCall(
|
|
48532
|
+
record2,
|
|
48533
|
+
loopChainOf(input),
|
|
48534
|
+
loopCallFrom(body2, frame2?.seq, harnessToolNameOf(input))
|
|
48535
|
+
);
|
|
48536
|
+
}
|
|
48537
|
+
function sealLoopNotice(record2, input, notice, boundary, at2) {
|
|
48538
|
+
return record2.recorder.sealCollectorEventOn(
|
|
48539
|
+
subagentOf(input),
|
|
48540
|
+
void 0,
|
|
48541
|
+
"oxagen:loop_notice",
|
|
48542
|
+
loopNoticeBody(notice, boundary),
|
|
48543
|
+
{ ts: at2, hook_event_name: input.hook_event_name }
|
|
48544
|
+
);
|
|
48545
|
+
}
|
|
48546
|
+
function sendLoopNotice(input, record2, deps, events, replay, notice, at2) {
|
|
48547
|
+
if (notice === void 0 || replay !== void 0) return void 0;
|
|
48548
|
+
const boundary = input.hook_event_name;
|
|
48549
|
+
if (boundary !== "PostToolUse" && boundary !== "PostToolUseFailure")
|
|
48550
|
+
return void 0;
|
|
48551
|
+
if (!deliversMessages(record2.harness, boundary)) {
|
|
48552
|
+
if (record2.harness === "cursor")
|
|
48553
|
+
holdLoopNotice(record2, loopChainOf(input), notice);
|
|
48554
|
+
return void 0;
|
|
48555
|
+
}
|
|
48556
|
+
if (!answerInTime(deps, deps.now())) return void 0;
|
|
48557
|
+
events.push(...sealLoopNotice(record2, input, notice, boundary, at2));
|
|
48558
|
+
markLoopNoticed(record2, loopChainOf(input), notice);
|
|
48559
|
+
return loopNoticeText(notice);
|
|
48560
|
+
}
|
|
48561
|
+
function loopRefusal(input, record2, deps, events, replay, evaluation, call2, at2) {
|
|
48562
|
+
const chain = loopChainOf(input);
|
|
48563
|
+
const held = takeHeldLoopNotice(record2, chain);
|
|
48564
|
+
const tool = call2?.["tool_name"];
|
|
48565
|
+
const inputHash = call2?.["tool_input_digest"];
|
|
48566
|
+
if (held === void 0 || replay !== void 0 || evaluation.decision === "deny" || typeof tool !== "string" || !nextCallRepeats(
|
|
48567
|
+
held,
|
|
48568
|
+
tool,
|
|
48569
|
+
typeof inputHash === "string" ? inputHash : void 0
|
|
48570
|
+
) || !answerInTime(deps, deps.now()))
|
|
48571
|
+
return void 0;
|
|
48572
|
+
events.push(...sealLoopNotice(record2, input, held, "PreToolUse", at2));
|
|
48573
|
+
markLoopNoticed(record2, chain, held);
|
|
48574
|
+
const refused2 = {
|
|
48575
|
+
...evaluation,
|
|
48576
|
+
decision: "deny",
|
|
48577
|
+
evaluated: "deny",
|
|
48578
|
+
source: "bundle",
|
|
48579
|
+
reason_code: LOOP_NOTICE_REASON_CODE,
|
|
48580
|
+
reason: `${LOOP_REFUSAL_LEAD}${loopNoticeText(held)}`
|
|
48581
|
+
};
|
|
48582
|
+
delete refused2.rule;
|
|
48583
|
+
delete refused2.rules;
|
|
48584
|
+
return refused2;
|
|
48585
|
+
}
|
|
48167
48586
|
function noteHandedContext(record2, input, replay, text6, at2) {
|
|
48168
48587
|
if (replay !== void 0 || input.agent_id !== void 0) return;
|
|
48169
48588
|
if (text6.length === 0) return;
|
|
@@ -48671,7 +49090,10 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48671
49090
|
) : void 0;
|
|
48672
49091
|
if (block === void 0 && input.agent_id === void 0)
|
|
48673
49092
|
record2.control.resumeOwed = void 0;
|
|
48674
|
-
if (block === void 0)
|
|
49093
|
+
if (block === void 0) {
|
|
49094
|
+
notePrompt(record2, promptText(input));
|
|
49095
|
+
endLoopWindow(record2, loopChainOf(input));
|
|
49096
|
+
}
|
|
48675
49097
|
const handed = [
|
|
48676
49098
|
...delivered,
|
|
48677
49099
|
...recalled !== void 0 ? [recalled.text] : []
|
|
@@ -48767,10 +49189,6 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48767
49189
|
};
|
|
48768
49190
|
}
|
|
48769
49191
|
}
|
|
48770
|
-
if (evaluation.decision === "deny" && evaluation.source !== "human" && evaluation.reason_code !== INTERJECTION_OPEN)
|
|
48771
|
-
notePolicyDenial(record2, toolName4);
|
|
48772
|
-
const facts = policyFacts2(evaluation, currentView);
|
|
48773
|
-
const attrs2 = policyAttrs(evaluation, replay);
|
|
48774
49192
|
const toolDrafts = normalizeHook(payload, env, {
|
|
48775
49193
|
sessionUuid: record2.recorder.sessionUuid
|
|
48776
49194
|
});
|
|
@@ -48778,6 +49196,24 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48778
49196
|
(draft) => draft.kind === "tool_requested"
|
|
48779
49197
|
);
|
|
48780
49198
|
const toolBody = toolDraft?.body ?? {};
|
|
49199
|
+
evaluation = loopNoticeStep(
|
|
49200
|
+
deps,
|
|
49201
|
+
"refuse the repeated call",
|
|
49202
|
+
() => loopRefusal(
|
|
49203
|
+
input,
|
|
49204
|
+
record2,
|
|
49205
|
+
deps,
|
|
49206
|
+
events,
|
|
49207
|
+
replay,
|
|
49208
|
+
evaluation,
|
|
49209
|
+
toolDraft?.body,
|
|
49210
|
+
at2
|
|
49211
|
+
)
|
|
49212
|
+
) ?? evaluation;
|
|
49213
|
+
if (evaluation.decision === "deny" && evaluation.source !== "human" && evaluation.reason_code !== INTERJECTION_OPEN && evaluation.reason_code !== LOOP_NOTICE_REASON_CODE)
|
|
49214
|
+
notePolicyDenial(record2, toolName4);
|
|
49215
|
+
const facts = policyFacts2(evaluation, currentView);
|
|
49216
|
+
const attrs2 = policyAttrs(evaluation, replay);
|
|
48781
49217
|
events.push(
|
|
48782
49218
|
...record2.recorder.sealCollectorEventOn(
|
|
48783
49219
|
toolDraft?.subagent,
|
|
@@ -48903,7 +49339,13 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48903
49339
|
}
|
|
48904
49340
|
case "PostToolUse":
|
|
48905
49341
|
case "PostToolUseFailure": {
|
|
48906
|
-
|
|
49342
|
+
const sealed = record2.recorder.ingestHook(payload, env, at2, withReplay);
|
|
49343
|
+
events.push(...sealed);
|
|
49344
|
+
const loop = loopNoticeStep(
|
|
49345
|
+
deps,
|
|
49346
|
+
"note the call",
|
|
49347
|
+
() => noteFinishedCall(input, record2, payload, env, sealed)
|
|
49348
|
+
);
|
|
48907
49349
|
if (view.bundle.cedar !== void 0 && input.tool_name !== void 0)
|
|
48908
49350
|
notePolicyRunCall(record2, {
|
|
48909
49351
|
cedar: view.bundle.cedar,
|
|
@@ -48929,7 +49371,15 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48929
49371
|
}
|
|
48930
49372
|
if (operatorBlock(view, record2) !== void 0)
|
|
48931
49373
|
return { events, response: {}, record: record2 };
|
|
48932
|
-
const
|
|
49374
|
+
const notice = loopNoticeStep(
|
|
49375
|
+
deps,
|
|
49376
|
+
"send the notice",
|
|
49377
|
+
() => sendLoopNotice(input, record2, deps, events, replay, loop, at2)
|
|
49378
|
+
);
|
|
49379
|
+
const texts = [
|
|
49380
|
+
...drainMidTurn(input, record2, deps, events, replay, notice?.length),
|
|
49381
|
+
...notice !== void 0 ? [notice] : []
|
|
49382
|
+
];
|
|
48933
49383
|
noteHandedContext(record2, input, replay, texts.join(CONTEXT_JOINER), at2);
|
|
48934
49384
|
return {
|
|
48935
49385
|
events,
|
|
@@ -48945,6 +49395,11 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48945
49395
|
case "Stop":
|
|
48946
49396
|
case "StopFailure": {
|
|
48947
49397
|
events.push(...record2.recorder.ingestHook(payload, env, at2, withReplay));
|
|
49398
|
+
loopNoticeStep(
|
|
49399
|
+
deps,
|
|
49400
|
+
"drop the held notice",
|
|
49401
|
+
() => takeHeldLoopNotice(record2, loopChainOf(input))
|
|
49402
|
+
);
|
|
48948
49403
|
const block = operatorBlock(view, record2);
|
|
48949
49404
|
if (block !== void 0) {
|
|
48950
49405
|
if (block.code === "session_paused" && replay === void 0)
|
|
@@ -48981,6 +49436,7 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
|
|
|
48981
49436
|
deps.registry.seal(record2);
|
|
48982
49437
|
forgetRecallHints(record2);
|
|
48983
49438
|
forgetPolicyRun(record2);
|
|
49439
|
+
forgetLoopNotices(record2);
|
|
48984
49440
|
const harness2 = skillsHarness(record2);
|
|
48985
49441
|
if (deps.skills !== void 0 && harness2 !== void 0)
|
|
48986
49442
|
await deps.skills.remove(harness2, record2.harnessSessionId, env);
|
|
@@ -49085,6 +49541,7 @@ var init_hook_handler = __esm({
|
|
|
49085
49541
|
init_inventory();
|
|
49086
49542
|
init_subagent_meta();
|
|
49087
49543
|
init_reflection_ask();
|
|
49544
|
+
init_loop_notice();
|
|
49088
49545
|
init_interjection2();
|
|
49089
49546
|
init_recall_hints();
|
|
49090
49547
|
init_policy_run();
|
|
@@ -50614,7 +51071,7 @@ function fileStateStorage(path2, unparsed) {
|
|
|
50614
51071
|
save: (json2) => writeSensitiveFileAtomic(path2, json2)
|
|
50615
51072
|
};
|
|
50616
51073
|
}
|
|
50617
|
-
function stateSaver(storage,
|
|
51074
|
+
function stateSaver(storage, failed5) {
|
|
50618
51075
|
let lastFailure;
|
|
50619
51076
|
return (json2) => {
|
|
50620
51077
|
try {
|
|
@@ -50624,7 +51081,7 @@ function stateSaver(storage, failed4) {
|
|
|
50624
51081
|
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
50625
51082
|
if (detail === lastFailure) return;
|
|
50626
51083
|
lastFailure = detail;
|
|
50627
|
-
|
|
51084
|
+
failed5(detail);
|
|
50628
51085
|
}
|
|
50629
51086
|
};
|
|
50630
51087
|
}
|
|
@@ -51604,7 +52061,7 @@ function createMemoryRecall(deps) {
|
|
|
51604
52061
|
`memory recall: ${detail}; prompts go on without recalled memories`
|
|
51605
52062
|
)
|
|
51606
52063
|
);
|
|
51607
|
-
function
|
|
52064
|
+
function failed5(detail) {
|
|
51608
52065
|
failures.failed(detail);
|
|
51609
52066
|
return [];
|
|
51610
52067
|
}
|
|
@@ -51640,7 +52097,7 @@ function createMemoryRecall(deps) {
|
|
|
51640
52097
|
);
|
|
51641
52098
|
} catch (error2) {
|
|
51642
52099
|
if (signal.aborted) return [];
|
|
51643
|
-
return
|
|
52100
|
+
return failed5(`the control plane is unreachable (${reason2(error2)})`);
|
|
51644
52101
|
}
|
|
51645
52102
|
if (signal.aborted) return [];
|
|
51646
52103
|
if (answer.status === 404) {
|
|
@@ -51654,16 +52111,16 @@ function createMemoryRecall(deps) {
|
|
|
51654
52111
|
return [];
|
|
51655
52112
|
}
|
|
51656
52113
|
if (!answer.ok)
|
|
51657
|
-
return
|
|
52114
|
+
return failed5(`the control plane answered ${answer.status}`);
|
|
51658
52115
|
let json2;
|
|
51659
52116
|
try {
|
|
51660
52117
|
json2 = JSON.parse(answer.text);
|
|
51661
52118
|
} catch {
|
|
51662
|
-
return
|
|
52119
|
+
return failed5("the control plane's answer is not JSON");
|
|
51663
52120
|
}
|
|
51664
52121
|
const parsed2 = recallAnswerSchema.safeParse(json2);
|
|
51665
52122
|
if (!parsed2.success)
|
|
51666
|
-
return
|
|
52123
|
+
return failed5("the control plane's answer is not a list of memories");
|
|
51667
52124
|
failures.clear();
|
|
51668
52125
|
return parsed2.data.items.map(({ id: id2, statement }) => ({ id: id2, statement }));
|
|
51669
52126
|
}
|
|
@@ -51675,7 +52132,7 @@ function createMemoryRecall(deps) {
|
|
|
51675
52132
|
timer = setTimeout(() => {
|
|
51676
52133
|
controller.abort();
|
|
51677
52134
|
resolve29(
|
|
51678
|
-
|
|
52135
|
+
failed5(
|
|
51679
52136
|
`the control plane took longer than ${timeoutMs} ms to answer`
|
|
51680
52137
|
)
|
|
51681
52138
|
);
|
|
@@ -51683,7 +52140,7 @@ function createMemoryRecall(deps) {
|
|
|
51683
52140
|
});
|
|
51684
52141
|
try {
|
|
51685
52142
|
const answered = ask(request3, controller.signal).catch(
|
|
51686
|
-
(error2) =>
|
|
52143
|
+
(error2) => failed5(`the ask failed (${reason2(error2)})`)
|
|
51687
52144
|
);
|
|
51688
52145
|
return await Promise.race([answered, timedOut]);
|
|
51689
52146
|
} finally {
|
|
@@ -51841,11 +52298,11 @@ var init_memory_write = __esm({
|
|
|
51841
52298
|
import { watch as fsWatch } from "node:fs";
|
|
51842
52299
|
import { stat as fsStat } from "node:fs/promises";
|
|
51843
52300
|
import { basename as basename8, dirname as dirname25 } from "node:path";
|
|
51844
|
-
function nodeFolderWatch(folder, changed,
|
|
52301
|
+
function nodeFolderWatch(folder, changed, failed5) {
|
|
51845
52302
|
const watcher = fsWatch(folder, { persistent: false }, (_event, name2) => {
|
|
51846
52303
|
changed(typeof name2 === "string" ? name2 : void 0);
|
|
51847
52304
|
});
|
|
51848
|
-
watcher.on("error",
|
|
52305
|
+
watcher.on("error", failed5);
|
|
51849
52306
|
return { close: () => watcher.close() };
|
|
51850
52307
|
}
|
|
51851
52308
|
async function nodeStoreFileStat(path2) {
|
|
@@ -53154,7 +53611,7 @@ function linkError(refusal, detail) {
|
|
|
53154
53611
|
function unreachable(detail) {
|
|
53155
53612
|
return linkError(cloudUnreachable(), detail);
|
|
53156
53613
|
}
|
|
53157
|
-
function
|
|
53614
|
+
function failed2(error2, limit, signal) {
|
|
53158
53615
|
return limit.aborted && signal?.aborted !== true ? new CloudLinkTimeout(errorText2(error2)) : unreachable(errorText2(error2));
|
|
53159
53616
|
}
|
|
53160
53617
|
function statusRefusal(status2) {
|
|
@@ -53184,7 +53641,7 @@ function createCloudLink(options) {
|
|
|
53184
53641
|
signal: signal === void 0 ? limit : AbortSignal.any([signal, limit])
|
|
53185
53642
|
});
|
|
53186
53643
|
} catch (error2) {
|
|
53187
|
-
throw
|
|
53644
|
+
throw failed2(error2, limit, signal);
|
|
53188
53645
|
}
|
|
53189
53646
|
if (!response.ok)
|
|
53190
53647
|
throw linkError(
|
|
@@ -53194,7 +53651,7 @@ function createCloudLink(options) {
|
|
|
53194
53651
|
try {
|
|
53195
53652
|
return { status: response.status, text: await response.text() };
|
|
53196
53653
|
} catch (error2) {
|
|
53197
|
-
throw
|
|
53654
|
+
throw failed2(error2, limit, signal);
|
|
53198
53655
|
}
|
|
53199
53656
|
}
|
|
53200
53657
|
return {
|
|
@@ -53850,8 +54307,8 @@ import { StringDecoder } from "node:string_decoder";
|
|
|
53850
54307
|
async function withSession(options, work) {
|
|
53851
54308
|
const { server } = options.launch;
|
|
53852
54309
|
const maxLineChars = options.maxLineChars ?? DEFAULT_MAX_LINE_CHARS;
|
|
53853
|
-
const
|
|
53854
|
-
if (options.signal?.aborted === true) throw
|
|
54310
|
+
const failed5 = (reason3) => new LocalServerError(serverFailed(server, reason3));
|
|
54311
|
+
if (options.signal?.aborted === true) throw failed5(STOPPED);
|
|
53855
54312
|
let child;
|
|
53856
54313
|
try {
|
|
53857
54314
|
child = options.spawn(options.launch.command, [...options.launch.args], {
|
|
@@ -53860,7 +54317,7 @@ async function withSession(options, work) {
|
|
|
53860
54317
|
windowsHide: true
|
|
53861
54318
|
});
|
|
53862
54319
|
} catch (error2) {
|
|
53863
|
-
throw
|
|
54320
|
+
throw failed5(`it could not start (${errorText2(error2)})`);
|
|
53864
54321
|
}
|
|
53865
54322
|
const pending = /* @__PURE__ */ new Map();
|
|
53866
54323
|
const decoder4 = new StringDecoder("utf8");
|
|
@@ -53914,7 +54371,7 @@ async function withSession(options, work) {
|
|
|
53914
54371
|
ERROR_MESSAGE_CHARS
|
|
53915
54372
|
);
|
|
53916
54373
|
entry2.reject(
|
|
53917
|
-
|
|
54374
|
+
failed5(
|
|
53918
54375
|
`it answered ${entry2.method} with error ${String(error2.code)}: ${text6}`
|
|
53919
54376
|
)
|
|
53920
54377
|
);
|
|
@@ -53942,7 +54399,7 @@ async function withSession(options, work) {
|
|
|
53942
54399
|
}
|
|
53943
54400
|
buffer += text6.slice(start);
|
|
53944
54401
|
if (buffer.length > maxLineChars)
|
|
53945
|
-
fail3(
|
|
54402
|
+
fail3(failed5(`it wrote a line longer than ${maxLineChars} characters`));
|
|
53946
54403
|
});
|
|
53947
54404
|
child.stderr.on("data", (chunk) => {
|
|
53948
54405
|
stderrTail = (stderrTail + String(chunk)).slice(-STDERR_TAIL_CHARS2);
|
|
@@ -53950,21 +54407,21 @@ async function withSession(options, work) {
|
|
|
53950
54407
|
child.on("close", (code, signal) => {
|
|
53951
54408
|
exited = true;
|
|
53952
54409
|
const how = code === null ? `it stopped on signal ${String(signal)}` : `it exited with code ${code}`;
|
|
53953
|
-
fail3(
|
|
54410
|
+
fail3(failed5(withStderr(`${how} before it answered`)));
|
|
53954
54411
|
});
|
|
53955
54412
|
child.on(
|
|
53956
54413
|
"error",
|
|
53957
|
-
(error2) => fail3(
|
|
54414
|
+
(error2) => fail3(failed5(withStderr(`it could not start (${error2.message})`)))
|
|
53958
54415
|
);
|
|
53959
54416
|
child.stdin.on(
|
|
53960
54417
|
"error",
|
|
53961
|
-
(error2) => fail3(
|
|
54418
|
+
(error2) => fail3(failed5(withStderr(`its stdin closed (${error2.message})`)))
|
|
53962
54419
|
);
|
|
53963
54420
|
const timer = setTimeout(
|
|
53964
54421
|
() => fail3(new LocalServerError(deadlinePassed(server, options.deadlineMs))),
|
|
53965
54422
|
options.deadlineMs
|
|
53966
54423
|
);
|
|
53967
|
-
const onAbort = () => fail3(
|
|
54424
|
+
const onAbort = () => fail3(failed5(STOPPED));
|
|
53968
54425
|
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
53969
54426
|
function request3(method, params) {
|
|
53970
54427
|
if (failure4 !== void 0) return Promise.reject(failure4);
|
|
@@ -59414,7 +59871,7 @@ function createModelProxy(deps) {
|
|
|
59414
59871
|
familyPriced,
|
|
59415
59872
|
settledAt,
|
|
59416
59873
|
durationMs,
|
|
59417
|
-
failed:
|
|
59874
|
+
failed: failed5
|
|
59418
59875
|
}) => {
|
|
59419
59876
|
const responseText = responseBody.text();
|
|
59420
59877
|
const owner = record2 === void 0 ? void 0 : deps.registry.byUuid(record2.recorder.sessionUuid);
|
|
@@ -59442,7 +59899,7 @@ function createModelProxy(deps) {
|
|
|
59442
59899
|
ttftMs: firstByteAt !== void 0 ? Math.max(0, firstByteAt - startedAt) : void 0,
|
|
59443
59900
|
durationMs,
|
|
59444
59901
|
status: status2,
|
|
59445
|
-
failed:
|
|
59902
|
+
failed: failed5,
|
|
59446
59903
|
requestId
|
|
59447
59904
|
});
|
|
59448
59905
|
const sessionSighting = closed2 && record2 !== void 0 ? (owner ?? record2).recorder.judgeModelCallSealedElsewhere(callBody2) : void 0;
|
|
@@ -59610,13 +60067,13 @@ function createModelProxy(deps) {
|
|
|
59610
60067
|
});
|
|
59611
60068
|
if (heldError === void 0) upstream.pipe(res);
|
|
59612
60069
|
};
|
|
59613
|
-
const onError = (
|
|
59614
|
-
if (settled2 ||
|
|
60070
|
+
const onError = (failed5, error2) => {
|
|
60071
|
+
if (settled2 || failed5 !== upstreamReq) return;
|
|
59615
60072
|
if (abortReason !== void 0) {
|
|
59616
60073
|
settle4("interrupted");
|
|
59617
60074
|
return;
|
|
59618
60075
|
}
|
|
59619
|
-
if (!retried && status2 === void 0 &&
|
|
60076
|
+
if (!retried && status2 === void 0 && failed5.reusedSocket && error2.code === "ECONNRESET") {
|
|
59620
60077
|
retried = true;
|
|
59621
60078
|
deps.log(
|
|
59622
60079
|
`model proxy: ${target.host} reset a pooled connection, sending the call again on a new one session=${sessionKey}`
|
|
@@ -64010,6 +64467,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
64010
64467
|
acks.push(ack);
|
|
64011
64468
|
},
|
|
64012
64469
|
now,
|
|
64470
|
+
log,
|
|
64013
64471
|
// A hook that queued behind others, or behind a slow read, can be
|
|
64014
64472
|
// answered after the harness stopped waiting. Past this instant
|
|
64015
64473
|
// the handler leaves the session's messages queued, rather than
|
|
@@ -66449,15 +66907,15 @@ function messageOf4(error2) {
|
|
|
66449
66907
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
66450
66908
|
}
|
|
66451
66909
|
async function refuse2(client, id2, reason3, deps) {
|
|
66452
|
-
const
|
|
66453
|
-
if (
|
|
66910
|
+
const failed5 = await refuseWorkOrder(client, id2, reason3);
|
|
66911
|
+
if (failed5 === void 0) {
|
|
66454
66912
|
deps.err(
|
|
66455
66913
|
`${reason3} Oxagen has ended this send, and the work item can be sent again.`
|
|
66456
66914
|
);
|
|
66457
66915
|
return;
|
|
66458
66916
|
}
|
|
66459
66917
|
deps.err(reason3);
|
|
66460
|
-
deps.err(`Could not tell Oxagen that ${id2} cannot start: ${
|
|
66918
|
+
deps.err(`Could not tell Oxagen that ${id2} cannot start: ${failed5}`);
|
|
66461
66919
|
}
|
|
66462
66920
|
async function workStart(id2, deps) {
|
|
66463
66921
|
if (!WORK_ORDER_ID_PATTERN.test(id2)) {
|
|
@@ -71387,16 +71845,16 @@ function checkTurnLoopPairing(journal) {
|
|
|
71387
71845
|
for (const event of journal.events) {
|
|
71388
71846
|
switch (event.event) {
|
|
71389
71847
|
case "model_response": {
|
|
71390
|
-
for (const
|
|
71391
|
-
if (everRequested.has(
|
|
71848
|
+
for (const callId2 of event.tool_calls) {
|
|
71849
|
+
if (everRequested.has(callId2)) {
|
|
71392
71850
|
violations.push(
|
|
71393
|
-
`call id \`${
|
|
71851
|
+
`call id \`${callId2}\` requested again at seq ${event.seq}: call ids are unique per session`
|
|
71394
71852
|
);
|
|
71395
71853
|
continue;
|
|
71396
71854
|
}
|
|
71397
|
-
everRequested.add(
|
|
71855
|
+
everRequested.add(callId2);
|
|
71398
71856
|
totalRequested += 1;
|
|
71399
|
-
pending.set(
|
|
71857
|
+
pending.set(callId2, event.seq);
|
|
71400
71858
|
}
|
|
71401
71859
|
break;
|
|
71402
71860
|
}
|
|
@@ -71434,7 +71892,7 @@ function checkTurnLoopPairing(journal) {
|
|
|
71434
71892
|
}
|
|
71435
71893
|
case "prompt_assembled": {
|
|
71436
71894
|
if (pending.size > 0) {
|
|
71437
|
-
const dangling = [...pending.entries()].sort(([a], [b3]) => a < b3 ? -1 : a > b3 ? 1 : 0).map(([
|
|
71895
|
+
const dangling = [...pending.entries()].sort(([a], [b3]) => a < b3 ? -1 : a > b3 ? 1 : 0).map(([callId2, at2]) => `\`${callId2}\` (requested at seq ${at2})`);
|
|
71438
71896
|
violations.push(
|
|
71439
71897
|
`prompt assembled at seq ${event.seq} with ${dangling.length} unresolved tool call(s): ${dangling.join(", ")}`
|
|
71440
71898
|
);
|
|
@@ -72857,7 +73315,7 @@ var init_package = __esm({
|
|
|
72857
73315
|
"package.json"() {
|
|
72858
73316
|
package_default = {
|
|
72859
73317
|
name: "@oxagen/cli",
|
|
72860
|
-
version: "3.0.1-
|
|
73318
|
+
version: "3.0.1-793",
|
|
72861
73319
|
description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
72862
73320
|
type: "module",
|
|
72863
73321
|
main: "./dist/index.js",
|
|
@@ -86028,6 +86486,7 @@ __export(sandbox_attach_exports, {
|
|
|
86028
86486
|
DETACH_KEY: () => DETACH_KEY,
|
|
86029
86487
|
MAX_RECONNECTS: () => MAX_RECONNECTS,
|
|
86030
86488
|
MAX_START_WAITS: () => MAX_START_WAITS,
|
|
86489
|
+
TAKE_CONTROL_REASON: () => TAKE_CONTROL_REASON,
|
|
86031
86490
|
attachToRun: () => attachToRun,
|
|
86032
86491
|
parseRunTarget: () => parseRunTarget,
|
|
86033
86492
|
processIo: () => processIo,
|
|
@@ -86065,8 +86524,9 @@ function encodeInput(bytes) {
|
|
|
86065
86524
|
data: Buffer.from(bytes).toString("base64")
|
|
86066
86525
|
});
|
|
86067
86526
|
}
|
|
86068
|
-
async function terminalSession(relay, mode, runName, io, writer) {
|
|
86527
|
+
async function terminalSession(relay, mode, runName, io, writer, opts = {}) {
|
|
86069
86528
|
let token = relay.token;
|
|
86529
|
+
let granted = opts.paused !== true;
|
|
86070
86530
|
let lastSeq = null;
|
|
86071
86531
|
let current = null;
|
|
86072
86532
|
let detaching = false;
|
|
@@ -86093,14 +86553,14 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86093
86553
|
if (control) {
|
|
86094
86554
|
const at2 = chunk.indexOf(DETACH_KEY);
|
|
86095
86555
|
const head3 = at2 === -1 ? chunk : chunk.subarray(0, at2);
|
|
86096
|
-
if (head3.length > 0) send5(encodeInput(head3));
|
|
86556
|
+
if (head3.length > 0 && granted) send5(encodeInput(head3));
|
|
86097
86557
|
if (at2 !== -1) detach();
|
|
86098
86558
|
return;
|
|
86099
86559
|
}
|
|
86100
86560
|
if (chunk.includes(DETACH_KEY) || chunk.includes(CTRL_C)) detach();
|
|
86101
86561
|
};
|
|
86102
86562
|
const onResize = () => {
|
|
86103
|
-
if (!control) return;
|
|
86563
|
+
if (!control || !granted) return;
|
|
86104
86564
|
const { columns, rows } = io.stdout;
|
|
86105
86565
|
if (columns && rows) send5({ type: "resize", cols: columns, rows });
|
|
86106
86566
|
};
|
|
@@ -86138,6 +86598,16 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86138
86598
|
case "token":
|
|
86139
86599
|
token = message2.token;
|
|
86140
86600
|
break;
|
|
86601
|
+
case "control": {
|
|
86602
|
+
const next = message2.state === "granted";
|
|
86603
|
+
if (next === granted) break;
|
|
86604
|
+
granted = next;
|
|
86605
|
+
writer.writeErr(
|
|
86606
|
+
granted ? "The run is paused. Your keystrokes reach it now." : "The run resumed, so your keystrokes no longer reach it."
|
|
86607
|
+
);
|
|
86608
|
+
onResize();
|
|
86609
|
+
break;
|
|
86610
|
+
}
|
|
86141
86611
|
case "closed": {
|
|
86142
86612
|
const text6 = CLOSED_MESSAGE[message2.reason];
|
|
86143
86613
|
state.final = {
|
|
@@ -86204,7 +86674,12 @@ async function terminalSession(relay, mode, runName, io, writer) {
|
|
|
86204
86674
|
}
|
|
86205
86675
|
}
|
|
86206
86676
|
const result2 = state.final;
|
|
86207
|
-
if (detaching) {
|
|
86677
|
+
if (detaching && opts.paused === true) {
|
|
86678
|
+
writer.writeErr(
|
|
86679
|
+
`
|
|
86680
|
+
You left the terminal. The run stays paused until someone resumes it from its page in the app. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
|
|
86681
|
+
);
|
|
86682
|
+
} else if (detaching) {
|
|
86208
86683
|
writer.writeErr(
|
|
86209
86684
|
`
|
|
86210
86685
|
You left the terminal. The run keeps going. Open its terminal again with \`oxagen sandbox attach ${runName}\`.`
|
|
@@ -86267,12 +86742,35 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
|
|
|
86267
86742
|
);
|
|
86268
86743
|
return 1;
|
|
86269
86744
|
}
|
|
86745
|
+
const scope = { org, ws: workspace };
|
|
86270
86746
|
let relay;
|
|
86271
|
-
|
|
86747
|
+
let pauses = null;
|
|
86748
|
+
try {
|
|
86749
|
+
if (mode === "control") {
|
|
86750
|
+
const { run: detail } = await apiPostOrThrow("sandbox-runs/get", target, scope);
|
|
86751
|
+
if (!detail.interactive) {
|
|
86752
|
+
if (detail.runId === null) {
|
|
86753
|
+
writer.writeErr(
|
|
86754
|
+
"\u2717 This run has not recorded its first step, so it cannot pause yet. Pass --watch to read the screen."
|
|
86755
|
+
);
|
|
86756
|
+
return 1;
|
|
86757
|
+
}
|
|
86758
|
+
pauses = detail.runId;
|
|
86759
|
+
await apiPostOrThrow(
|
|
86760
|
+
"commands",
|
|
86761
|
+
{
|
|
86762
|
+
target: { kind: "run", id: pauses },
|
|
86763
|
+
command: "pause",
|
|
86764
|
+
reason: TAKE_CONTROL_REASON
|
|
86765
|
+
},
|
|
86766
|
+
scope
|
|
86767
|
+
);
|
|
86768
|
+
}
|
|
86769
|
+
}
|
|
86272
86770
|
relay = await openRelay(
|
|
86273
86771
|
target,
|
|
86274
86772
|
mode,
|
|
86275
|
-
|
|
86773
|
+
scope,
|
|
86276
86774
|
io,
|
|
86277
86775
|
writer,
|
|
86278
86776
|
opts.waitForStart === true
|
|
@@ -86282,15 +86780,17 @@ async function attachToRun(run3, opts, writer = stdoutWriter, io = processIo())
|
|
|
86282
86780
|
return 1;
|
|
86283
86781
|
}
|
|
86284
86782
|
writer.writeErr(
|
|
86285
|
-
mode === "
|
|
86783
|
+
mode === "watch" ? "Watching. Press Ctrl-] to stop watching." : pauses !== null ? "Pausing the run. Your keystrokes reach it once it reports the pause. Press Ctrl-] to detach." : "Connected. Press Ctrl-] to detach and leave the run going."
|
|
86286
86784
|
);
|
|
86287
|
-
return terminalSession(relay, mode, run3, io, writer
|
|
86785
|
+
return terminalSession(relay, mode, run3, io, writer, {
|
|
86786
|
+
paused: pauses !== null
|
|
86787
|
+
});
|
|
86288
86788
|
}
|
|
86289
86789
|
async function runAttach(run3, opts, writer = stdoutWriter) {
|
|
86290
86790
|
const code = await attachToRun(run3, opts, writer);
|
|
86291
86791
|
if (code !== 0) process.exitCode = code;
|
|
86292
86792
|
}
|
|
86293
|
-
var DETACH_KEY, CTRL_C, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
|
|
86793
|
+
var DETACH_KEY, CTRL_C, TAKE_CONTROL_REASON, MAX_RECONNECTS, MAX_START_WAITS, START_WAIT_MS, SOCKET_OPEN, FINAL_CLOSE, CLOSED_MESSAGE;
|
|
86294
86794
|
var init_sandbox_attach = __esm({
|
|
86295
86795
|
"src/commands/sandbox-attach.ts"() {
|
|
86296
86796
|
init_api();
|
|
@@ -86299,6 +86799,7 @@ var init_sandbox_attach = __esm({
|
|
|
86299
86799
|
init_sandbox_run();
|
|
86300
86800
|
DETACH_KEY = 29;
|
|
86301
86801
|
CTRL_C = 3;
|
|
86802
|
+
TAKE_CONTROL_REASON = "The operator took control of the run's terminal.";
|
|
86302
86803
|
MAX_RECONNECTS = 5;
|
|
86303
86804
|
MAX_START_WAITS = 60;
|
|
86304
86805
|
START_WAIT_MS = 2e3;
|
|
@@ -86309,6 +86810,7 @@ var init_sandbox_attach = __esm({
|
|
|
86309
86810
|
4401: "The terminal session expired. Run `oxagen sandbox attach` again.",
|
|
86310
86811
|
4403: "Only the operator who launched this run can stop it or open its terminal.",
|
|
86311
86812
|
4408: "The relay got no hello in time. Run `oxagen sandbox attach` again.",
|
|
86813
|
+
4409: "Another session has control of this run's terminal. Pass --watch to read the screen, or try again once that session hands control back.",
|
|
86312
86814
|
4410: "This terminal session has ended. Run `oxagen sandbox attach` to open a new one.",
|
|
86313
86815
|
4502: "The relay could not open the run's terminal. Try again in a moment."
|
|
86314
86816
|
};
|
|
@@ -92827,12 +93329,12 @@ async function workspaceConnect(argument, opts, writer = stdoutWriter, deps = {}
|
|
|
92827
93329
|
} else {
|
|
92828
93330
|
printConnect(ref, machineName, results, madeActive, writer);
|
|
92829
93331
|
}
|
|
92830
|
-
const
|
|
93332
|
+
const failed5 = results.filter(
|
|
92831
93333
|
(r) => r.status === "failed" || r.status === "refused"
|
|
92832
93334
|
);
|
|
92833
|
-
if (
|
|
93335
|
+
if (failed5.length > 0) {
|
|
92834
93336
|
out.error(
|
|
92835
|
-
`${
|
|
93337
|
+
`${failed5.length} of ${results.length} harnesses were not connected to ${ref}. The lines above say why.`,
|
|
92836
93338
|
"connect"
|
|
92837
93339
|
);
|
|
92838
93340
|
}
|
|
@@ -128614,13 +129116,13 @@ function oneOf2(value, allowed, flag2, writer) {
|
|
|
128614
129116
|
return value;
|
|
128615
129117
|
}
|
|
128616
129118
|
async function handleMemoryList(opts, writer = stdoutWriter) {
|
|
128617
|
-
const
|
|
128618
|
-
for (const state of
|
|
129119
|
+
const states3 = listOpt(opts.state);
|
|
129120
|
+
for (const state of states3)
|
|
128619
129121
|
oneOf2(state, WORKSPACE_MEMORY_STATES, "--state", writer);
|
|
128620
129122
|
const harness = oneOf2(opts.harness, HARNESSES2, "--harness", writer);
|
|
128621
129123
|
try {
|
|
128622
129124
|
const result2 = await listWorkspaceMemories({
|
|
128623
|
-
states:
|
|
129125
|
+
states: states3.length === 0 ? void 0 : states3,
|
|
128624
129126
|
harness,
|
|
128625
129127
|
agent: opts.agent,
|
|
128626
129128
|
repository: opts.repository,
|
|
@@ -129450,7 +129952,7 @@ GitHub connected. Fetching repositories...
|
|
|
129450
129952
|
)
|
|
129451
129953
|
);
|
|
129452
129954
|
const repos = [];
|
|
129453
|
-
let
|
|
129955
|
+
let failed5 = 0;
|
|
129454
129956
|
listed.forEach((result2, i2) => {
|
|
129455
129957
|
if (result2.status === "fulfilled") {
|
|
129456
129958
|
for (const r of result2.value.repositories) {
|
|
@@ -129458,13 +129960,13 @@ GitHub connected. Fetching repositories...
|
|
|
129458
129960
|
}
|
|
129459
129961
|
return;
|
|
129460
129962
|
}
|
|
129461
|
-
|
|
129963
|
+
failed5 += 1;
|
|
129462
129964
|
process.stdout.write(
|
|
129463
129965
|
` Could not list the repositories of ${installations[i2]?.accountLogin ?? "an installation"}: ${errorMessage3(result2.reason)}
|
|
129464
129966
|
`
|
|
129465
129967
|
);
|
|
129466
129968
|
});
|
|
129467
|
-
if (
|
|
129969
|
+
if (failed5 > 0) {
|
|
129468
129970
|
process.stdout.write(
|
|
129469
129971
|
` The link was not updated. Re-run \`oxagen init\` to try again.
|
|
129470
129972
|
`
|
|
@@ -152253,7 +152755,7 @@ async function read(response, call2, clock2, settings) {
|
|
|
152253
152755
|
if (next.value.done === true) break;
|
|
152254
152756
|
if (template.streaming === "unary" && items.length === 1) {
|
|
152255
152757
|
response.cancel();
|
|
152256
|
-
return
|
|
152758
|
+
return failed3(
|
|
152257
152759
|
internal(
|
|
152258
152760
|
`${template.method} is unary, but the upstream sent more than one response message.`
|
|
152259
152761
|
)
|
|
@@ -152265,7 +152767,7 @@ async function read(response, call2, clock2, settings) {
|
|
|
152265
152767
|
item = decodeResponse(call2.method, encoded);
|
|
152266
152768
|
} catch (error2) {
|
|
152267
152769
|
response.cancel();
|
|
152268
|
-
return
|
|
152770
|
+
return failed3(internal(messageOf5(error2)));
|
|
152269
152771
|
}
|
|
152270
152772
|
items.push(item);
|
|
152271
152773
|
if (template.streaming === "server") {
|
|
@@ -152293,7 +152795,7 @@ function fromStatus(status2, call2, items) {
|
|
|
152293
152795
|
return { ok: true, value: streamResult(items, false), ending };
|
|
152294
152796
|
const [value] = items;
|
|
152295
152797
|
if (value === void 0) {
|
|
152296
|
-
return
|
|
152798
|
+
return failed3(
|
|
152297
152799
|
internal(
|
|
152298
152800
|
`${call2.template.method} ended with OK and sent no response message.`
|
|
152299
152801
|
),
|
|
@@ -152306,7 +152808,7 @@ function fromStatus(status2, call2, items) {
|
|
|
152306
152808
|
const detail = status2.message === "" ? `The upstream returned ${name2} with no message.` : status2.message;
|
|
152307
152809
|
if (status2.code === STATUS_DEADLINE_EXCEEDED)
|
|
152308
152810
|
return deadlinePassed2(call2, items, detail, ending);
|
|
152309
|
-
return
|
|
152811
|
+
return failed3(
|
|
152310
152812
|
{ title: name2, detail, status: status2.code },
|
|
152311
152813
|
ending,
|
|
152312
152814
|
status2.code === STATUS_UNAVAILABLE && items.length === 0
|
|
@@ -152314,7 +152816,7 @@ function fromStatus(status2, call2, items) {
|
|
|
152314
152816
|
}
|
|
152315
152817
|
function transportFailure2(error2, call2, items) {
|
|
152316
152818
|
if (!(error2 instanceof TransportError)) {
|
|
152317
|
-
return
|
|
152819
|
+
return failed3({
|
|
152318
152820
|
title: "Transport error",
|
|
152319
152821
|
detail: messageOf5(error2),
|
|
152320
152822
|
status: void 0
|
|
@@ -152324,7 +152826,7 @@ function transportFailure2(error2, call2, items) {
|
|
|
152324
152826
|
case "timeout":
|
|
152325
152827
|
return deadlinePassed2(call2, items, error2.message);
|
|
152326
152828
|
case "not_sent":
|
|
152327
|
-
return
|
|
152829
|
+
return failed3(
|
|
152328
152830
|
{
|
|
152329
152831
|
title: statusName(STATUS_UNAVAILABLE),
|
|
152330
152832
|
detail: error2.message,
|
|
@@ -152334,7 +152836,7 @@ function transportFailure2(error2, call2, items) {
|
|
|
152334
152836
|
items.length === 0
|
|
152335
152837
|
);
|
|
152336
152838
|
default:
|
|
152337
|
-
return
|
|
152839
|
+
return failed3({
|
|
152338
152840
|
title: TRANSPORT_TITLES2[error2.code],
|
|
152339
152841
|
detail: error2.message,
|
|
152340
152842
|
status: void 0
|
|
@@ -152342,7 +152844,7 @@ function transportFailure2(error2, call2, items) {
|
|
|
152342
152844
|
}
|
|
152343
152845
|
}
|
|
152344
152846
|
function stopped(stop, call2, items) {
|
|
152345
|
-
if (stop === "cancelled") return
|
|
152847
|
+
if (stop === "cancelled") return failed3(CANCELLED2);
|
|
152346
152848
|
return deadlinePassed2(
|
|
152347
152849
|
call2,
|
|
152348
152850
|
items,
|
|
@@ -152358,7 +152860,7 @@ function deadlinePassed2(call2, items, detail, upstream) {
|
|
|
152358
152860
|
};
|
|
152359
152861
|
return { ok: true, value: streamResult(items, true), ending };
|
|
152360
152862
|
}
|
|
152361
|
-
return
|
|
152863
|
+
return failed3(
|
|
152362
152864
|
{
|
|
152363
152865
|
title: statusName(STATUS_DEADLINE_EXCEEDED),
|
|
152364
152866
|
detail,
|
|
@@ -152377,7 +152879,7 @@ function internal(detail) {
|
|
|
152377
152879
|
status: STATUS_INTERNAL
|
|
152378
152880
|
};
|
|
152379
152881
|
}
|
|
152380
|
-
function
|
|
152882
|
+
function failed3(error2, ending, retryable = false) {
|
|
152381
152883
|
return { ok: false, error: error2, retryable, ending };
|
|
152382
152884
|
}
|
|
152383
152885
|
function exchangesFor(call2, ending) {
|
|
@@ -153513,7 +154015,7 @@ var init_validate = __esm({
|
|
|
153513
154015
|
|
|
153514
154016
|
// ../../packages/mcp-studio/src/execute/call.ts
|
|
153515
154017
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
153516
|
-
function
|
|
154018
|
+
function failed4(text6, exchanges = []) {
|
|
153517
154019
|
return {
|
|
153518
154020
|
result: { content: [{ type: "text", text: text6 }], isError: true },
|
|
153519
154021
|
exchanges
|
|
@@ -153574,11 +154076,11 @@ function dispatch(senders, tool, args, context) {
|
|
|
153574
154076
|
}
|
|
153575
154077
|
async function executeCall(tool, args, environment, credentials2, transport, options = {}) {
|
|
153576
154078
|
const badArguments = inputRefusal(tool.definition.inputSchema, args);
|
|
153577
|
-
if (badArguments !== null) return
|
|
154079
|
+
if (badArguments !== null) return failed4(badArguments);
|
|
153578
154080
|
const { server, name: name2 } = environment;
|
|
153579
154081
|
const env = Object.hasOwn(server.environments, name2) ? server.environments[name2] : void 0;
|
|
153580
154082
|
if (env === void 0)
|
|
153581
|
-
return
|
|
154083
|
+
return failed4(
|
|
153582
154084
|
`The server ${server.name} has no environment named ${name2}.`
|
|
153583
154085
|
);
|
|
153584
154086
|
const shaping = tool.shaping;
|
|
@@ -153597,7 +154099,7 @@ async function executeCall(tool, args, environment, credentials2, transport, opt
|
|
|
153597
154099
|
signal
|
|
153598
154100
|
);
|
|
153599
154101
|
if (resolved.type === "missing")
|
|
153600
|
-
return
|
|
154102
|
+
return failed4(`${resolved.message}
|
|
153601
154103
|
${resolved.connect_url}`);
|
|
153602
154104
|
credential = resolved;
|
|
153603
154105
|
}
|
|
@@ -153647,7 +154149,7 @@ ${resolved.connect_url}`);
|
|
|
153647
154149
|
},
|
|
153648
154150
|
send5
|
|
153649
154151
|
);
|
|
153650
|
-
if (!paged.ok) return
|
|
154152
|
+
if (!paged.ok) return failed4(errorText3(paged.error), paged.exchanges);
|
|
153651
154153
|
value = paged.value;
|
|
153652
154154
|
exchanges = paged.exchanges;
|
|
153653
154155
|
const note = paged.paged === void 0 ? void 0 : pagingNote(paged.paged, { shaping });
|
|
@@ -153655,7 +154157,7 @@ ${resolved.connect_url}`);
|
|
|
153655
154157
|
} else {
|
|
153656
154158
|
const sent = await send5(upstream, shaping.deadline_ms);
|
|
153657
154159
|
exchanges = sent.exchanges ?? [];
|
|
153658
|
-
if (!sent.ok) return
|
|
154160
|
+
if (!sent.ok) return failed4(errorText3(sent.error), exchanges);
|
|
153659
154161
|
value = sent.value;
|
|
153660
154162
|
}
|
|
153661
154163
|
if (local || kind === "mcp") {
|
|
@@ -162558,7 +163060,7 @@ var require_subchannel = __commonJS({
|
|
|
162558
163060
|
}
|
|
162559
163061
|
return false;
|
|
162560
163062
|
}
|
|
162561
|
-
createCall(metadata, host, method, listener,
|
|
163063
|
+
createCall(metadata, host, method, listener, callId2) {
|
|
162562
163064
|
if (!this.transport) {
|
|
162563
163065
|
throw new Error("Cannot create call, subchannel not READY");
|
|
162564
163066
|
}
|
|
@@ -162578,7 +163080,7 @@ var require_subchannel = __commonJS({
|
|
|
162578
163080
|
} else {
|
|
162579
163081
|
statsTracker = {};
|
|
162580
163082
|
}
|
|
162581
|
-
return this.transport.createCall(metadata, host, method, listener, statsTracker,
|
|
163083
|
+
return this.transport.createCall(metadata, host, method, listener, statsTracker, callId2);
|
|
162582
163084
|
}
|
|
162583
163085
|
/**
|
|
162584
163086
|
* If the subchannel is currently IDLE, start connecting and switch to the
|
|
@@ -163339,13 +163841,13 @@ var require_subchannel_call = __commonJS({
|
|
|
163339
163841
|
};
|
|
163340
163842
|
}
|
|
163341
163843
|
var Http2SubchannelCall = class {
|
|
163342
|
-
constructor(http2Stream, callEventTracker, listener, transport,
|
|
163844
|
+
constructor(http2Stream, callEventTracker, listener, transport, callId2) {
|
|
163343
163845
|
var _a2;
|
|
163344
163846
|
this.http2Stream = http2Stream;
|
|
163345
163847
|
this.callEventTracker = callEventTracker;
|
|
163346
163848
|
this.listener = listener;
|
|
163347
163849
|
this.transport = transport;
|
|
163348
|
-
this.callId =
|
|
163850
|
+
this.callId = callId2;
|
|
163349
163851
|
this.isReadFilterPending = false;
|
|
163350
163852
|
this.isPushPending = false;
|
|
163351
163853
|
this.canPush = false;
|
|
@@ -164047,7 +164549,7 @@ var require_transport = __commonJS({
|
|
|
164047
164549
|
}
|
|
164048
164550
|
}
|
|
164049
164551
|
}
|
|
164050
|
-
createCall(metadata, host, method, listener, subchannelCallStatsTracker,
|
|
164552
|
+
createCall(metadata, host, method, listener, subchannelCallStatsTracker, callId2) {
|
|
164051
164553
|
const headers = metadata.toHttp2Headers();
|
|
164052
164554
|
headers[HTTP2_HEADER_AUTHORITY] = host;
|
|
164053
164555
|
headers[HTTP2_HEADER_USER_AGENT] = this.userAgent;
|
|
@@ -164121,7 +164623,7 @@ var require_transport = __commonJS({
|
|
|
164121
164623
|
}
|
|
164122
164624
|
};
|
|
164123
164625
|
}
|
|
164124
|
-
call2 = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this,
|
|
164626
|
+
call2 = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, callId2 !== null && callId2 !== void 0 ? callId2 : (0, call_number_1.getNextCallNumber)());
|
|
164125
164627
|
this.addActiveCall(call2);
|
|
164126
164628
|
return call2;
|
|
164127
164629
|
}
|
|
@@ -165016,36 +165518,36 @@ var require_retrying_call = __commonJS({
|
|
|
165016
165518
|
this.totalAllocated = 0;
|
|
165017
165519
|
this.allocatedPerCall = /* @__PURE__ */ new Map();
|
|
165018
165520
|
}
|
|
165019
|
-
allocate(size,
|
|
165521
|
+
allocate(size, callId2) {
|
|
165020
165522
|
var _a2;
|
|
165021
|
-
const currentPerCall = (_a2 = this.allocatedPerCall.get(
|
|
165523
|
+
const currentPerCall = (_a2 = this.allocatedPerCall.get(callId2)) !== null && _a2 !== void 0 ? _a2 : 0;
|
|
165022
165524
|
if (this.limitPerCall - currentPerCall < size || this.totalLimit - this.totalAllocated < size) {
|
|
165023
165525
|
return false;
|
|
165024
165526
|
}
|
|
165025
|
-
this.allocatedPerCall.set(
|
|
165527
|
+
this.allocatedPerCall.set(callId2, currentPerCall + size);
|
|
165026
165528
|
this.totalAllocated += size;
|
|
165027
165529
|
return true;
|
|
165028
165530
|
}
|
|
165029
|
-
free(size,
|
|
165531
|
+
free(size, callId2) {
|
|
165030
165532
|
var _a2;
|
|
165031
165533
|
if (this.totalAllocated < size) {
|
|
165032
|
-
throw new Error(`Invalid buffer allocation state: call ${
|
|
165534
|
+
throw new Error(`Invalid buffer allocation state: call ${callId2} freed ${size} > total allocated ${this.totalAllocated}`);
|
|
165033
165535
|
}
|
|
165034
165536
|
this.totalAllocated -= size;
|
|
165035
|
-
const currentPerCall = (_a2 = this.allocatedPerCall.get(
|
|
165537
|
+
const currentPerCall = (_a2 = this.allocatedPerCall.get(callId2)) !== null && _a2 !== void 0 ? _a2 : 0;
|
|
165036
165538
|
if (currentPerCall < size) {
|
|
165037
|
-
throw new Error(`Invalid buffer allocation state: call ${
|
|
165539
|
+
throw new Error(`Invalid buffer allocation state: call ${callId2} freed ${size} > allocated for call ${currentPerCall}`);
|
|
165038
165540
|
}
|
|
165039
|
-
this.allocatedPerCall.set(
|
|
165541
|
+
this.allocatedPerCall.set(callId2, currentPerCall - size);
|
|
165040
165542
|
}
|
|
165041
|
-
freeAll(
|
|
165543
|
+
freeAll(callId2) {
|
|
165042
165544
|
var _a2;
|
|
165043
|
-
const currentPerCall = (_a2 = this.allocatedPerCall.get(
|
|
165545
|
+
const currentPerCall = (_a2 = this.allocatedPerCall.get(callId2)) !== null && _a2 !== void 0 ? _a2 : 0;
|
|
165044
165546
|
if (this.totalAllocated < currentPerCall) {
|
|
165045
|
-
throw new Error(`Invalid buffer allocation state: call ${
|
|
165547
|
+
throw new Error(`Invalid buffer allocation state: call ${callId2} allocated ${currentPerCall} > total allocated ${this.totalAllocated}`);
|
|
165046
165548
|
}
|
|
165047
165549
|
this.totalAllocated -= currentPerCall;
|
|
165048
|
-
this.allocatedPerCall.delete(
|
|
165550
|
+
this.allocatedPerCall.delete(callId2);
|
|
165049
165551
|
}
|
|
165050
165552
|
};
|
|
165051
165553
|
exports.MessageBufferTracker = MessageBufferTracker;
|