@mrciphersmith/keryx 0.4.24 → 0.4.26
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/cli.js +303 -126
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -34020,7 +34020,7 @@ var package_default;
|
|
|
34020
34020
|
var init_package = __esm(() => {
|
|
34021
34021
|
package_default = {
|
|
34022
34022
|
name: "@mrciphersmith/keryx",
|
|
34023
|
-
version: "0.4.
|
|
34023
|
+
version: "0.4.26",
|
|
34024
34024
|
description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
34025
34025
|
private: false,
|
|
34026
34026
|
publishConfig: {
|
|
@@ -198972,6 +198972,10 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
198972
198972
|
return Math.max(1, room - 1 >= BUSY_FOOTER_MIN_HINT.length ? room - 1 : room);
|
|
198973
198973
|
};
|
|
198974
198974
|
let usageSource;
|
|
198975
|
+
const usageContent = (segments, suffix) => new otui.StyledText([
|
|
198976
|
+
...segments.map((segment) => segment.role === "muted" ? dimChunk(otui, segment.text) : roleChunk(otui, segment.role, segment.text)),
|
|
198977
|
+
...suffix !== undefined ? [dimChunk(otui, suffix)] : []
|
|
198978
|
+
]);
|
|
198975
198979
|
const paintBusyStatus = () => {
|
|
198976
198980
|
if (busy && liveStatus !== undefined) {
|
|
198977
198981
|
const frame = SPINNER[spinIdx % SPINNER.length] ?? "\u280B";
|
|
@@ -198985,7 +198989,7 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
198985
198989
|
}
|
|
198986
198990
|
if (!busy) {
|
|
198987
198991
|
const usageIdle = usageSource?.();
|
|
198988
|
-
footerLeft.content = otui.t`${dimChunk(otui,
|
|
198992
|
+
footerLeft.content = usageIdle !== undefined ? usageContent(usageIdle) : otui.t`${dimChunk(otui, opts.footerHint)}`;
|
|
198989
198993
|
footerRight.content = otui.t`${dimChunk(otui, status)}`;
|
|
198990
198994
|
return;
|
|
198991
198995
|
}
|
|
@@ -198993,7 +198997,7 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
198993
198997
|
const right = perm !== undefined && perm.length > 0 ? `mode ${perm}` : status;
|
|
198994
198998
|
footerRight.content = otui.t`${dimChunk(otui, right)}`;
|
|
198995
198999
|
const usageBusy = usageSource?.();
|
|
198996
|
-
footerLeft.content =
|
|
199000
|
+
footerLeft.content = usageBusy !== undefined ? usageContent(usageBusy, ` \xB7 ${BUSY_FOOTER_MIN_HINT}`) : otui.t`${dimChunk(otui, formatBusyFooter(busyFooterInfo, footerLeftBudget(right)))}`;
|
|
198997
199001
|
};
|
|
198998
199002
|
const onFooterResized = () => {
|
|
198999
199003
|
if (busy)
|
|
@@ -199086,13 +199090,13 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
199086
199090
|
textarea.focus();
|
|
199087
199091
|
syncComposerHeight();
|
|
199088
199092
|
const submitHandlers = new Set;
|
|
199089
|
-
const emitSubmit = (line) => {
|
|
199093
|
+
const emitSubmit = (line, draft = line) => {
|
|
199090
199094
|
if (line.length > 0) {
|
|
199091
199095
|
scroll.scrollTop = scroll.scrollHeight;
|
|
199092
199096
|
scroll.stickyScroll = true;
|
|
199093
199097
|
}
|
|
199094
199098
|
for (const handler of [...submitHandlers]) {
|
|
199095
|
-
handler(line);
|
|
199099
|
+
handler(line, draft);
|
|
199096
199100
|
}
|
|
199097
199101
|
};
|
|
199098
199102
|
menu.on(otui.SelectRenderableEvents.ITEM_SELECTED, () => {
|
|
@@ -199107,12 +199111,13 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
199107
199111
|
debugEvent("composer.submit-blocked", { reason: "overlay active", dockVisible: dock.visible, overlayDepth });
|
|
199108
199112
|
return;
|
|
199109
199113
|
}
|
|
199110
|
-
const
|
|
199114
|
+
const draft = input.value;
|
|
199115
|
+
const line = draft.trim();
|
|
199111
199116
|
debugEvent("composer.submit", { chars: line.length, slash: line.startsWith("/") });
|
|
199112
199117
|
input.value = "";
|
|
199113
199118
|
hideMenu();
|
|
199114
199119
|
syncComposerHeight();
|
|
199115
|
-
emitSubmit(line);
|
|
199120
|
+
emitSubmit(line, draft);
|
|
199116
199121
|
};
|
|
199117
199122
|
const unsubscribeMenuKeys = onKeypress2(r, (key) => {
|
|
199118
199123
|
if (!menu.visible || !menuNav || overlayActive()) {
|
|
@@ -199268,6 +199273,7 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
199268
199273
|
appliedTheme = theme;
|
|
199269
199274
|
};
|
|
199270
199275
|
const unsubTheme = onThemeChange((theme) => applyTheme(theme));
|
|
199276
|
+
let offEscapeInterrupt;
|
|
199271
199277
|
{
|
|
199272
199278
|
const run = currentDebugRun();
|
|
199273
199279
|
if (run !== undefined) {
|
|
@@ -199312,6 +199318,17 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
199312
199318
|
addOverlaySource,
|
|
199313
199319
|
keyboardOwnedElsewhere,
|
|
199314
199320
|
withOverlay,
|
|
199321
|
+
onEscapeInterrupt: (interrupt) => {
|
|
199322
|
+
offEscapeInterrupt?.();
|
|
199323
|
+
offEscapeInterrupt = onKeypress2(r, (key) => {
|
|
199324
|
+
if (key.name !== "escape" || key.ctrl || key.meta || key.defaultPrevented)
|
|
199325
|
+
return;
|
|
199326
|
+
if (overlayActive() || menu.visible && menuNav || !interrupt())
|
|
199327
|
+
return;
|
|
199328
|
+
key.preventDefault();
|
|
199329
|
+
key.stopPropagation();
|
|
199330
|
+
});
|
|
199331
|
+
},
|
|
199315
199332
|
showToast,
|
|
199316
199333
|
applyTheme,
|
|
199317
199334
|
startBusy,
|
|
@@ -199357,6 +199374,7 @@ async function createShellChrome(otui, renderer, opts) {
|
|
|
199357
199374
|
destroyModalHost(r);
|
|
199358
199375
|
clearBusyTimer();
|
|
199359
199376
|
clearToastTimer();
|
|
199377
|
+
offEscapeInterrupt?.();
|
|
199360
199378
|
unsubscribeMenuKeys();
|
|
199361
199379
|
unsubscribeSuggestionKeys();
|
|
199362
199380
|
try {
|
|
@@ -207641,19 +207659,28 @@ function formatActiveTime(ms) {
|
|
|
207641
207659
|
function formatCostUsd(cost) {
|
|
207642
207660
|
return `$${cost < 0.01 ? cost.toFixed(4) : cost.toFixed(2)}`;
|
|
207643
207661
|
}
|
|
207644
|
-
function
|
|
207645
|
-
const
|
|
207646
|
-
|
|
207647
|
-
|
|
207662
|
+
function totalsSegments(label, t) {
|
|
207663
|
+
const segments = [
|
|
207664
|
+
{ role: "muted", text: label },
|
|
207665
|
+
{ role: "accent", text: ` \u2191${compactTokens(t.tokensIn)}` },
|
|
207666
|
+
{ role: "ok", text: ` \u2193${compactTokens(t.tokensOut)}` }
|
|
207667
|
+
];
|
|
207668
|
+
if (t.cacheRead > 0 || t.cacheWrite > 0) {
|
|
207669
|
+
segments.push({ role: "muted", text: ` cache ${compactTokens(t.cacheRead)}/${compactTokens(t.cacheWrite)}` });
|
|
207670
|
+
}
|
|
207648
207671
|
if (t.costUsd !== undefined)
|
|
207649
|
-
|
|
207650
|
-
|
|
207651
|
-
return
|
|
207672
|
+
segments.push({ role: "attention", text: ` ${formatCostUsd(t.costUsd)}` });
|
|
207673
|
+
segments.push({ role: "text", text: ` ${formatActiveTime(t.activeMs)}` });
|
|
207674
|
+
return segments;
|
|
207652
207675
|
}
|
|
207653
|
-
function
|
|
207676
|
+
function usageFooterSegments(snap) {
|
|
207654
207677
|
if (!snap.turnRunning && snap.turns === 0)
|
|
207655
207678
|
return;
|
|
207656
|
-
return
|
|
207679
|
+
return [
|
|
207680
|
+
...totalsSegments("turn", snap.turn),
|
|
207681
|
+
{ role: "muted", text: " \xB7 " },
|
|
207682
|
+
...totalsSegments("session", snap.session)
|
|
207683
|
+
];
|
|
207657
207684
|
}
|
|
207658
207685
|
function formatUsageTable(snap) {
|
|
207659
207686
|
const cost = (c) => c !== undefined ? formatCostUsd(c) : "n/a";
|
|
@@ -207673,6 +207700,42 @@ function formatUsageTable(snap) {
|
|
|
207673
207700
|
`);
|
|
207674
207701
|
}
|
|
207675
207702
|
|
|
207703
|
+
// src/tui/turn-usage.ts
|
|
207704
|
+
function installTurnUsageSink(io) {
|
|
207705
|
+
const base = io.onUsage?.bind(io);
|
|
207706
|
+
let current;
|
|
207707
|
+
io.onUsage = (usage) => {
|
|
207708
|
+
base?.(usage);
|
|
207709
|
+
current?.(usage);
|
|
207710
|
+
};
|
|
207711
|
+
return {
|
|
207712
|
+
set: (sink) => {
|
|
207713
|
+
current = sink;
|
|
207714
|
+
},
|
|
207715
|
+
clear: (sink) => {
|
|
207716
|
+
if (current === sink)
|
|
207717
|
+
current = undefined;
|
|
207718
|
+
}
|
|
207719
|
+
};
|
|
207720
|
+
}
|
|
207721
|
+
function createTurnUsage(opts) {
|
|
207722
|
+
const totals = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 };
|
|
207723
|
+
return {
|
|
207724
|
+
totals,
|
|
207725
|
+
onUsage(usage) {
|
|
207726
|
+
totals.input += usage.inputTokens ?? 0;
|
|
207727
|
+
totals.output += usage.outputTokens ?? 0;
|
|
207728
|
+
totals.cacheRead += usage.cacheReadTokens ?? 0;
|
|
207729
|
+
totals.cacheWrite += usage.cacheWriteTokens ?? 0;
|
|
207730
|
+
const costUsd = opts.cost(totals);
|
|
207731
|
+
const tracker = opts.tracker();
|
|
207732
|
+
tracker.addUsage(usage);
|
|
207733
|
+
tracker.setTurnCost(costUsd);
|
|
207734
|
+
opts.onUpdate?.(totals, costUsd);
|
|
207735
|
+
}
|
|
207736
|
+
};
|
|
207737
|
+
}
|
|
207738
|
+
|
|
207676
207739
|
// src/tui/usage-tracker.ts
|
|
207677
207740
|
function createUsageTracker(opts = {}) {
|
|
207678
207741
|
const now = opts.now ?? Date.now;
|
|
@@ -278062,6 +278125,46 @@ async function pickWikiEnrichMode(otui, r, dock, plan, cwd) {
|
|
|
278062
278125
|
}));
|
|
278063
278126
|
return id === "drafts" || id === "force" || id === "cancel" ? id : "cancel";
|
|
278064
278127
|
}
|
|
278128
|
+
async function routeBusyMessage(otui, chrome, cwd, line, draft, deliver) {
|
|
278129
|
+
const chosen = await journaledPick(cwd, {
|
|
278130
|
+
source: DECISION_SOURCES.queueRoute,
|
|
278131
|
+
question: "The main agent is busy. Where should this message go?",
|
|
278132
|
+
recommendationReason: "The main queue keeps the message in the main history; a side answer is read-only.",
|
|
278133
|
+
cancelId: "cancel",
|
|
278134
|
+
options: [
|
|
278135
|
+
{ id: "main", label: "Main queue", description: "queue for the main agent; remove/edit/force later", recommended: true },
|
|
278136
|
+
{ id: "side", label: "Side-1", description: "read-only answer, outside main history (as before)" }
|
|
278137
|
+
]
|
|
278138
|
+
}, (options, dismissId) => {
|
|
278139
|
+
const reason = deliver.blockedReason?.();
|
|
278140
|
+
if (reason !== undefined) {
|
|
278141
|
+
chrome.showToast(reason);
|
|
278142
|
+
return Promise.resolve(dismissId);
|
|
278143
|
+
}
|
|
278144
|
+
return showComposerChoice(otui, chrome.renderer, chrome.dock, {
|
|
278145
|
+
title: "Main agent is busy",
|
|
278146
|
+
subtitle: line,
|
|
278147
|
+
options,
|
|
278148
|
+
cancelId: dismissId,
|
|
278149
|
+
enqueue: false,
|
|
278150
|
+
onBusy: () => chrome.showToast("Answer the open approval first, then resend.")
|
|
278151
|
+
});
|
|
278152
|
+
});
|
|
278153
|
+
const blocked = chosen === "main" || chosen === "side" ? deliver.blockedReason?.() : undefined;
|
|
278154
|
+
if (blocked === undefined && chosen === "main") {
|
|
278155
|
+
deliver.main();
|
|
278156
|
+
} else if (blocked === undefined && chosen === "side") {
|
|
278157
|
+
deliver.side();
|
|
278158
|
+
} else {
|
|
278159
|
+
if (blocked !== undefined)
|
|
278160
|
+
chrome.showToast(blocked);
|
|
278161
|
+
const currentDraft = chrome.input.value;
|
|
278162
|
+
chrome.input.value = currentDraft.length === 0 ? draft : `${draft}
|
|
278163
|
+
${currentDraft}`;
|
|
278164
|
+
if (!chrome.overlayActive())
|
|
278165
|
+
chrome.input.focus();
|
|
278166
|
+
}
|
|
278167
|
+
}
|
|
278065
278168
|
function createApprovalContextLoader(cwd) {
|
|
278066
278169
|
let port;
|
|
278067
278170
|
return async (command) => {
|
|
@@ -278083,8 +278186,7 @@ async function pickShellApproval(otui, r, dock, command, loadContext, destructiv
|
|
|
278083
278186
|
{
|
|
278084
278187
|
id: "once",
|
|
278085
278188
|
label: "Allow once",
|
|
278086
|
-
description: "Run only this time"
|
|
278087
|
-
recommended: true
|
|
278189
|
+
description: "Run only this time"
|
|
278088
278190
|
},
|
|
278089
278191
|
...canOfferExact ? [
|
|
278090
278192
|
{
|
|
@@ -278103,7 +278205,8 @@ async function pickShellApproval(otui, r, dock, command, loadContext, destructiv
|
|
|
278103
278205
|
{
|
|
278104
278206
|
id: "deny",
|
|
278105
278207
|
label: "Deny",
|
|
278106
|
-
description: "Do not run"
|
|
278208
|
+
description: "Do not run",
|
|
278209
|
+
recommended: true
|
|
278107
278210
|
}
|
|
278108
278211
|
];
|
|
278109
278212
|
const id = await showComposerChoice(otui, r, dock, {
|
|
@@ -279951,6 +280054,8 @@ async function launchTuiAgentShell(opts) {
|
|
|
279951
280054
|
}
|
|
279952
280055
|
});
|
|
279953
280056
|
const foregroundOperation = createForegroundOperationOwner();
|
|
280057
|
+
let sessionTransferInProgress = false;
|
|
280058
|
+
const sessionTransferNotice = "Session switch in progress. Try again when it finishes.";
|
|
279954
280059
|
const forceHandoff = createForegroundForceHandoff();
|
|
279955
280060
|
const sessionLease = createTuiLeaseHolder();
|
|
279956
280061
|
let ctrlCPress;
|
|
@@ -280086,7 +280191,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
280086
280191
|
const turnFooter = { tokensIn: 0, tokensOut: 0, costUsd: undefined };
|
|
280087
280192
|
let usageTracker = createUsageTracker();
|
|
280088
280193
|
let usageTurnOpen = false;
|
|
280089
|
-
chrome.setUsageSource(() =>
|
|
280194
|
+
chrome.setUsageSource(() => usageFooterSegments(usageTracker.snapshot()));
|
|
280090
280195
|
let contextTotal = 0;
|
|
280091
280196
|
const pushBusyFooter = () => {
|
|
280092
280197
|
if (!chrome.isBusy())
|
|
@@ -280745,6 +280850,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
280745
280850
|
lastUsage = usage;
|
|
280746
280851
|
recordedUsage?.(usage);
|
|
280747
280852
|
};
|
|
280853
|
+
const turnUsageSlot = installTurnUsageSink(io);
|
|
280748
280854
|
const blockIo = attachBlockIo(io, addBlock, {
|
|
280749
280855
|
onReasoningStart: () => {
|
|
280750
280856
|
setBusyPhase("thinking");
|
|
@@ -280813,7 +280919,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
280813
280919
|
paint: () => paintMainQueue(),
|
|
280814
280920
|
say: (text) => io.onSystem?.(text),
|
|
280815
280921
|
runLine: (line, origin, source) => runLine(line, origin, source),
|
|
280816
|
-
turnWorkInFlight: () => chrome.isBusy() || foregroundOperation.isActive || forceHandoff.isAwaitingSettlement,
|
|
280922
|
+
turnWorkInFlight: () => foregroundOperation.isDisposed || chrome.isBusy() || foregroundOperation.isActive || forceHandoff.isAwaitingSettlement,
|
|
280817
280923
|
onSettle: () => busWakeController?.onSettle(),
|
|
280818
280924
|
onDetachedFailure: (error) => {
|
|
280819
280925
|
const reason = error instanceof Error ? error.message : String(error);
|
|
@@ -281759,6 +281865,8 @@ async function launchTuiAgentShell(opts) {
|
|
|
281759
281865
|
let nextArchiveIndex = 0;
|
|
281760
281866
|
let refreshRewindSidebar = () => {};
|
|
281761
281867
|
let sessionPersistTimer;
|
|
281868
|
+
const sideQueue = [];
|
|
281869
|
+
let sideSessionAbort = new AbortController;
|
|
281762
281870
|
const bindSlateToLiveSession = () => {
|
|
281763
281871
|
slateSession = freshSlateSessionRef(liveSession.dir, sessionCwd);
|
|
281764
281872
|
executionPlanPanel.refresh();
|
|
@@ -281796,6 +281904,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
281796
281904
|
foregroundOperation.invalidateSession();
|
|
281797
281905
|
usageTracker = createUsageTracker();
|
|
281798
281906
|
usageTurnOpen = false;
|
|
281907
|
+
chrome.repaintStatus();
|
|
281799
281908
|
io.resetStream();
|
|
281800
281909
|
blockIo.resetReasoningLiveState();
|
|
281801
281910
|
const parked = forceHandoff.drainPending();
|
|
@@ -281812,7 +281921,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
281812
281921
|
sessionPersistTimer = undefined;
|
|
281813
281922
|
}
|
|
281814
281923
|
};
|
|
281815
|
-
const applyOpened = (opened
|
|
281924
|
+
const applyOpened = (opened) => {
|
|
281816
281925
|
if (opened.history.length > 0) {
|
|
281817
281926
|
splash?.removeIfShown();
|
|
281818
281927
|
}
|
|
@@ -281826,7 +281935,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
281826
281935
|
io.trustedMcpTools?.clear();
|
|
281827
281936
|
io.hcLaunchGrants?.clear();
|
|
281828
281937
|
resetOperatorDenials();
|
|
281829
|
-
history =
|
|
281938
|
+
history = opened.history;
|
|
281830
281939
|
archive = opened.archive.length > 0 ? [...opened.archive] : [...opened.history];
|
|
281831
281940
|
nextArchiveIndex = history.length;
|
|
281832
281941
|
refreshRewindSidebar();
|
|
@@ -281862,6 +281971,24 @@ async function launchTuiAgentShell(opts) {
|
|
|
281862
281971
|
model: currentSel.model
|
|
281863
281972
|
}));
|
|
281864
281973
|
const leaseState = leaseStateLookup(sessionCwd);
|
|
281974
|
+
const showSessionPreview = () => {
|
|
281975
|
+
const recentPrompts = history.filter((message) => message.role === "user").slice(-5);
|
|
281976
|
+
if (recentPrompts.length === 0)
|
|
281977
|
+
return;
|
|
281978
|
+
transcript.add(new otui.TextRenderable(r, {
|
|
281979
|
+
id: `sesspreview${uid++}`,
|
|
281980
|
+
content: otui.t`${dimChunk(otui, "Recent prompts")}`
|
|
281981
|
+
}));
|
|
281982
|
+
for (const message of recentPrompts) {
|
|
281983
|
+
const hc = hcHistoryEcho(message.content);
|
|
281984
|
+
const text = hc?.line ?? message.content;
|
|
281985
|
+
const preview = text.length > 100 ? `${text.slice(0, 97)}\u2026` : text;
|
|
281986
|
+
transcript.add(new otui.TextRenderable(r, {
|
|
281987
|
+
id: `sessu${uid++}`,
|
|
281988
|
+
content: otui.t`${dimChunk(otui, ` ${hc?.marker ?? "\u276F"} ${preview}`)}`
|
|
281989
|
+
}));
|
|
281990
|
+
}
|
|
281991
|
+
};
|
|
281865
281992
|
const showOpenedNotes = (opened) => {
|
|
281866
281993
|
if (opened.skipped !== undefined) {
|
|
281867
281994
|
transcript.add(new otui.TextRenderable(r, {
|
|
@@ -281883,15 +282010,7 @@ async function launchTuiAgentShell(opts) {
|
|
|
281883
282010
|
content: otui.t`${dimChunk(otui, `session ${shortSessionId(liveSession.summary.id)} \xB7 ${liveSession.summary.title} \xB7 ctx ${history.length} \xB7 archive ${archive.length}`)}`,
|
|
281884
282011
|
marginTop: 1
|
|
281885
282012
|
}));
|
|
281886
|
-
|
|
281887
|
-
const hc = hcHistoryEcho(m.content);
|
|
281888
|
-
const text = hc?.line ?? m.content;
|
|
281889
|
-
const t = text.length > 100 ? `${text.slice(0, 97)}\u2026` : text;
|
|
281890
|
-
transcript.add(new otui.TextRenderable(r, {
|
|
281891
|
-
id: `sessu${uid++}`,
|
|
281892
|
-
content: otui.t`${dimChunk(otui, ` ${hc?.marker ?? "\u276F"} ${t}`)}`
|
|
281893
|
-
}));
|
|
281894
|
-
}
|
|
282013
|
+
showSessionPreview();
|
|
281895
282014
|
}
|
|
281896
282015
|
};
|
|
281897
282016
|
let startupCancelled = false;
|
|
@@ -282231,6 +282350,10 @@ async function launchTuiAgentShell(opts) {
|
|
|
282231
282350
|
};
|
|
282232
282351
|
refreshRewindSidebar();
|
|
282233
282352
|
const resetSessionSurface = () => {
|
|
282353
|
+
sideQueue.length = 0;
|
|
282354
|
+
sideSessionAbort.abort();
|
|
282355
|
+
sideSessionAbort = new AbortController;
|
|
282356
|
+
splash?.removeIfShown();
|
|
282234
282357
|
nav.exit();
|
|
282235
282358
|
chrome.stopBusy();
|
|
282236
282359
|
io.resetStream();
|
|
@@ -282245,7 +282368,13 @@ async function launchTuiAgentShell(opts) {
|
|
|
282245
282368
|
usage.resetUsage();
|
|
282246
282369
|
};
|
|
282247
282370
|
const preservedOpen = async (signal, target = {}) => {
|
|
282248
|
-
|
|
282371
|
+
const assertCanSwitch = () => {
|
|
282372
|
+
assertSessionSwitchActive(signal, sessionLease.canPersist());
|
|
282373
|
+
if (chrome.isBusy() || foregroundOperation.isActive) {
|
|
282374
|
+
throw new Error("The main agent is busy. Wait for the turn to finish.");
|
|
282375
|
+
}
|
|
282376
|
+
};
|
|
282377
|
+
assertCanSwitch();
|
|
282249
282378
|
const opened = await switchPreservedSession(sessionLease.current, () => openLeasedSession({
|
|
282250
282379
|
cwd: sessionCwd,
|
|
282251
282380
|
...target,
|
|
@@ -282254,11 +282383,19 @@ async function launchTuiAgentShell(opts) {
|
|
|
282254
282383
|
}), async () => {
|
|
282255
282384
|
flushSessionCheckpoint();
|
|
282256
282385
|
await closeSlateSession(slateSession, mintTimestampAttemptId);
|
|
282257
|
-
|
|
282386
|
+
assertCanSwitch();
|
|
282258
282387
|
});
|
|
282259
282388
|
sessionLease.hold(opened.lease);
|
|
282260
282389
|
return opened;
|
|
282261
282390
|
};
|
|
282391
|
+
const withSessionTransfer = (action) => {
|
|
282392
|
+
sessionTransferInProgress = true;
|
|
282393
|
+
const work = action().finally(() => {
|
|
282394
|
+
sessionTransferInProgress = false;
|
|
282395
|
+
});
|
|
282396
|
+
turnLoop.drain.detach(work);
|
|
282397
|
+
return work;
|
|
282398
|
+
};
|
|
282262
282399
|
const startNewSession = async (signal, note) => {
|
|
282263
282400
|
let opened;
|
|
282264
282401
|
try {
|
|
@@ -282298,27 +282435,36 @@ Staying in the current session.
|
|
|
282298
282435
|
if (found === undefined) {
|
|
282299
282436
|
return;
|
|
282300
282437
|
}
|
|
282301
|
-
|
|
282302
|
-
|
|
282303
|
-
opened = await preservedOpen(signal, { resumeId: found.id });
|
|
282304
|
-
} catch (cause) {
|
|
282305
|
-
const hint = cause instanceof SessionLeasedError ? `To continue it in this shell, start one with: keryx shell -r ${shortSessionId(found.id)} --fork
|
|
282306
|
-
` : "";
|
|
282307
|
-
io.onSystem?.(`Could not resume ${shortSessionId(found.id)}: ${cause instanceof Error ? cause.message : String(cause)}
|
|
282308
|
-
` + hint + `Staying in the current session.
|
|
282438
|
+
if (found.id === liveSession.summary.id) {
|
|
282439
|
+
io.onSystem?.(`That session is already open.
|
|
282309
282440
|
`);
|
|
282310
282441
|
return;
|
|
282311
282442
|
}
|
|
282312
|
-
|
|
282313
|
-
|
|
282314
|
-
|
|
282315
|
-
|
|
282316
|
-
|
|
282317
|
-
|
|
282443
|
+
await withSessionTransfer(async () => {
|
|
282444
|
+
let opened;
|
|
282445
|
+
try {
|
|
282446
|
+
opened = await preservedOpen(signal, { resumeId: found.id });
|
|
282447
|
+
} catch (cause) {
|
|
282448
|
+
const hint = cause instanceof SessionLeasedError ? `To continue it in this shell, start one with: keryx shell -r ${shortSessionId(found.id)} --fork
|
|
282449
|
+
` : "";
|
|
282450
|
+
io.onSystem?.(`Could not resume ${shortSessionId(found.id)}: ${cause instanceof Error ? cause.message : String(cause)}
|
|
282451
|
+
` + hint + `Staying in the current session.
|
|
282318
282452
|
`);
|
|
282319
|
-
|
|
282320
|
-
|
|
282453
|
+
return;
|
|
282454
|
+
}
|
|
282455
|
+
resetSessionSurface();
|
|
282456
|
+
applyOpened(opened);
|
|
282457
|
+
bindSlateToLiveSession();
|
|
282458
|
+
refreshWorkspaceSidebar();
|
|
282459
|
+
paintSessionHeader();
|
|
282460
|
+
if (opened.archiveDegraded !== undefined) {
|
|
282461
|
+
io.onSystem?.(`Archive unavailable \u2014 resumed from the active context (${opened.archiveDegraded})
|
|
282462
|
+
`);
|
|
282463
|
+
}
|
|
282464
|
+
io.onSystem?.(`Resumed ${shortSessionId(liveSession.summary.id)} \xB7 ${liveSession.summary.title} (ctx ${history.length} \xB7 archive ${archive.length})
|
|
282321
282465
|
`);
|
|
282466
|
+
showSessionPreview();
|
|
282467
|
+
});
|
|
282322
282468
|
});
|
|
282323
282469
|
paintSessionHeader();
|
|
282324
282470
|
const inspectorKeys = { onKeypress: (handler) => onKeypress4(r, (key) => handler(key)) };
|
|
@@ -283156,7 +283302,6 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283156
283302
|
};
|
|
283157
283303
|
const SIDE_WORKER_ID = `${SIDE_WORKER_ID_PREFIX}1`;
|
|
283158
283304
|
const sideWorkerLabelText = sideWorkerLabel(1);
|
|
283159
|
-
const sideQueue = [];
|
|
283160
283305
|
let sideWorkerRunning = false;
|
|
283161
283306
|
let sideClearTimeout;
|
|
283162
283307
|
const showSideQueueStatus = () => {
|
|
@@ -283265,6 +283410,10 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283265
283410
|
const item = turnLoop.queue[index];
|
|
283266
283411
|
if (item === undefined)
|
|
283267
283412
|
return;
|
|
283413
|
+
if (sessionTransferInProgress) {
|
|
283414
|
+
chrome.showToast(sessionTransferNotice);
|
|
283415
|
+
return;
|
|
283416
|
+
}
|
|
283268
283417
|
if (leaseView()?.held() === true) {
|
|
283269
283418
|
io.onSystem?.(`\u25C7 held \u2014 q${index + 1} stays queued until the lease is released (see /bus).
|
|
283270
283419
|
`);
|
|
@@ -283276,7 +283425,7 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283276
283425
|
announce: (interrupted) => io.onSystem?.(interrupted ? `\u25C7 main turn interrupted \u2014 q${index + 1} will run next.
|
|
283277
283426
|
` : `\u25C7 q${index + 1} will run next.
|
|
283278
283427
|
`),
|
|
283279
|
-
isBusy: () => chrome.isBusy(),
|
|
283428
|
+
isBusy: () => chrome.isBusy() || sessionTransferInProgress,
|
|
283280
283429
|
resume: () => drainSites.onLeaseRelease(),
|
|
283281
283430
|
requeue: (items) => {
|
|
283282
283431
|
if (foregroundOperation.isDisposed)
|
|
@@ -283376,6 +283525,8 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283376
283525
|
break;
|
|
283377
283526
|
}
|
|
283378
283527
|
const currentQuestion = next.question;
|
|
283528
|
+
const sideSignal = sideSessionAbort.signal;
|
|
283529
|
+
const canPaintSide = () => !sideSignal.aborted && !destroyed;
|
|
283379
283530
|
sideWorkerRunning = true;
|
|
283380
283531
|
if (sideClearTimeout !== undefined) {
|
|
283381
283532
|
clearTimeout(sideClearTimeout);
|
|
@@ -283407,6 +283558,8 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283407
283558
|
let answer = "";
|
|
283408
283559
|
try {
|
|
283409
283560
|
const base = await opts.makeAgentDeps(currentSel, liveSlateSession, undefined);
|
|
283561
|
+
if (!canPaintSide())
|
|
283562
|
+
continue;
|
|
283410
283563
|
const tools = base.tools.filter(isToolAvailableToSideWorker);
|
|
283411
283564
|
const sideDeps = {
|
|
283412
283565
|
...base,
|
|
@@ -283424,6 +283577,8 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283424
283577
|
answer = text;
|
|
283425
283578
|
},
|
|
283426
283579
|
onToolCall: (name) => {
|
|
283580
|
+
if (!canPaintSide())
|
|
283581
|
+
return;
|
|
283427
283582
|
fleet.upsert({
|
|
283428
283583
|
id: SIDE_WORKER_ID,
|
|
283429
283584
|
label: sideWorkerLabelText,
|
|
@@ -283432,9 +283587,13 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283432
283587
|
});
|
|
283433
283588
|
},
|
|
283434
283589
|
onToolResult: () => {
|
|
283590
|
+
if (!canPaintSide())
|
|
283591
|
+
return;
|
|
283435
283592
|
fleet.upsert({ id: SIDE_WORKER_ID, label: sideWorkerLabelText, status: "running", detail: "waiting" });
|
|
283436
283593
|
},
|
|
283437
283594
|
onSystem: (text) => {
|
|
283595
|
+
if (!canPaintSide())
|
|
283596
|
+
return;
|
|
283438
283597
|
transcript.add(new otui.TextRenderable(r, {
|
|
283439
283598
|
id: `side-sys${uid++}`,
|
|
283440
283599
|
content: otui.t`${dimChunk(otui, text.trimEnd())}`
|
|
@@ -283442,7 +283601,9 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283442
283601
|
},
|
|
283443
283602
|
requestApproval: async () => false
|
|
283444
283603
|
};
|
|
283445
|
-
await runAgentTurn(sideIo, sideDeps, sideHistory, prompt);
|
|
283604
|
+
await runAgentTurn(sideIo, sideDeps, sideHistory, prompt, { signal: sideSignal });
|
|
283605
|
+
if (!canPaintSide())
|
|
283606
|
+
continue;
|
|
283446
283607
|
const body = answer.trim().length > 0 ? answer.trim() : "(no reply)";
|
|
283447
283608
|
appendUserEcho(otui, r, transcript, {
|
|
283448
283609
|
id: `side-a${uid++}`,
|
|
@@ -283458,6 +283619,8 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283458
283619
|
detail: "answered"
|
|
283459
283620
|
});
|
|
283460
283621
|
} catch (cause) {
|
|
283622
|
+
if (!canPaintSide())
|
|
283623
|
+
continue;
|
|
283461
283624
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
283462
283625
|
transcript.add(new otui.TextRenderable(r, {
|
|
283463
283626
|
id: `side-err${uid++}`,
|
|
@@ -283476,10 +283639,22 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283476
283639
|
})();
|
|
283477
283640
|
};
|
|
283478
283641
|
let consecutiveAutoWakes = 0;
|
|
283479
|
-
const runLine = (line, origin = "operator", source, skipSlashRouting = false) => {
|
|
283642
|
+
const runLine = (line, origin = "operator", source, skipSlashRouting = false, draft = line) => {
|
|
283480
283643
|
if (line.length === 0 && origin === "operator") {
|
|
283481
283644
|
return;
|
|
283482
283645
|
}
|
|
283646
|
+
if (sessionTransferInProgress && !(origin === "operator" && source !== "hub" && !skipSlashRouting && findAgentCommand(line, "agent")?.name === "/exit")) {
|
|
283647
|
+
if (source === undefined && (origin === "operator" || origin === "agent-message")) {
|
|
283648
|
+
const currentDraft = input.value;
|
|
283649
|
+
input.value = currentDraft.length === 0 ? draft : `${draft}
|
|
283650
|
+
${currentDraft}`;
|
|
283651
|
+
chrome.showToast(sessionTransferNotice);
|
|
283652
|
+
} else if (source === TG_SOURCE) {
|
|
283653
|
+
io.onSystem?.(`${sessionTransferNotice}
|
|
283654
|
+
`);
|
|
283655
|
+
}
|
|
283656
|
+
return;
|
|
283657
|
+
}
|
|
283483
283658
|
suggestionGate.cancel("new turn started");
|
|
283484
283659
|
const fromHub = source === "hub";
|
|
283485
283660
|
if (fromHub)
|
|
@@ -283748,37 +283923,14 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283748
283923
|
`);
|
|
283749
283924
|
return;
|
|
283750
283925
|
}
|
|
283751
|
-
|
|
283752
|
-
|
|
283753
|
-
|
|
283754
|
-
|
|
283755
|
-
question: "The main agent is busy. Where should this message go?",
|
|
283756
|
-
recommendationReason: "The main queue keeps the message in the main history; a side answer is read-only.",
|
|
283757
|
-
cancelId: "side",
|
|
283758
|
-
options: [
|
|
283759
|
-
{ id: "main", label: "Main queue", description: "queue for the main agent; remove/edit/force later", recommended: true },
|
|
283760
|
-
{ id: "side", label: "Side-1", description: "read-only answer, outside main history (as before)" }
|
|
283761
|
-
]
|
|
283762
|
-
}, (options, dismissId) => showComposerChoice(otui, r, chrome.dock, {
|
|
283763
|
-
title: "Main agent is busy",
|
|
283764
|
-
subtitle: line,
|
|
283765
|
-
options,
|
|
283766
|
-
cancelId: dismissId,
|
|
283767
|
-
enqueue: false,
|
|
283768
|
-
onBusy: () => {
|
|
283769
|
-
blockedByOpenDialog = true;
|
|
283770
|
-
chrome.showToast("Answer the open approval first, then resend.");
|
|
283771
|
-
}
|
|
283772
|
-
}));
|
|
283773
|
-
if (blockedByOpenDialog) {
|
|
283774
|
-
input.value = line;
|
|
283775
|
-
input.focus();
|
|
283776
|
-
return;
|
|
283777
|
-
}
|
|
283778
|
-
if (chosen === "main") {
|
|
283926
|
+
const recipientSession = sideSessionAbort.signal;
|
|
283927
|
+
routeBusyMessage(otui, chrome, sessionCwd, line, draft, {
|
|
283928
|
+
blockedReason: () => recipientSession.aborted ? "Session changed. Review the draft before sending it again." : sessionTransferInProgress ? sessionTransferNotice : undefined,
|
|
283929
|
+
main: () => {
|
|
283779
283930
|
turnLoop.enqueue(line, displayLine);
|
|
283780
|
-
turnLoop.drainAfterRecipientChoice(() => !destroyed && !chrome.isBusy() && !foregroundOperation.isActive && !forceHandoff.isAwaitingSettlement && leaseView()?.held() !== true);
|
|
283781
|
-
}
|
|
283931
|
+
turnLoop.drainAfterRecipientChoice(() => !destroyed && !sessionTransferInProgress && !chrome.isBusy() && !foregroundOperation.isActive && !forceHandoff.isAwaitingSettlement && leaseView()?.held() !== true);
|
|
283932
|
+
},
|
|
283933
|
+
side: () => {
|
|
283782
283934
|
appendUserEcho(otui, r, transcript, {
|
|
283783
283935
|
id: `side-q${uid++}`,
|
|
283784
283936
|
line: displayLine,
|
|
@@ -283787,7 +283939,7 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283787
283939
|
});
|
|
283788
283940
|
spawnSideWorker(line, displayLine);
|
|
283789
283941
|
}
|
|
283790
|
-
})
|
|
283942
|
+
});
|
|
283791
283943
|
return;
|
|
283792
283944
|
}
|
|
283793
283945
|
if (!skipSlashRouting && !agentShaped && line.startsWith("/")) {
|
|
@@ -283836,7 +283988,7 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283836
283988
|
return;
|
|
283837
283989
|
}
|
|
283838
283990
|
if (command.name === "/clear" || command.name === "/new") {
|
|
283839
|
-
sessionSwitches.run(async (
|
|
283991
|
+
sessionSwitches.run((signal) => withSessionTransfer(async () => {
|
|
283840
283992
|
if (!await startNewSession(signal)) {
|
|
283841
283993
|
return;
|
|
283842
283994
|
}
|
|
@@ -283848,7 +284000,7 @@ ${formatThemeList(getThemeId())}`);
|
|
|
283848
284000
|
deps.resetSubagentBudget?.();
|
|
283849
284001
|
io.onSystem?.(`New session ${shortSessionId(liveSession.summary.id)} (previous kept on disk \xB7 /resume)
|
|
283850
284002
|
`);
|
|
283851
|
-
});
|
|
284003
|
+
}));
|
|
283852
284004
|
return;
|
|
283853
284005
|
}
|
|
283854
284006
|
if (command.name === "/schedule") {
|
|
@@ -284638,31 +284790,25 @@ ${formatThemeList(getThemeId())}`);
|
|
|
284638
284790
|
}
|
|
284639
284791
|
prevOnSystem?.(text);
|
|
284640
284792
|
};
|
|
284641
|
-
|
|
284642
|
-
|
|
284643
|
-
|
|
284644
|
-
let turnCacheWriteTokens = 0;
|
|
284645
|
-
const prevOnUsageForCost = io.onUsage;
|
|
284646
|
-
io.onUsage = (usage) => {
|
|
284647
|
-
turnInputTokens += usage.inputTokens ?? 0;
|
|
284648
|
-
turnOutputTokens += usage.outputTokens ?? 0;
|
|
284649
|
-
turnCacheReadTokens += usage.cacheReadTokens ?? 0;
|
|
284650
|
-
turnCacheWriteTokens += usage.cacheWriteTokens ?? 0;
|
|
284651
|
-
turnFooter.tokensIn = turnInputTokens;
|
|
284652
|
-
turnFooter.tokensOut = turnOutputTokens;
|
|
284653
|
-
turnFooter.costUsd = estimateTurnCostUsd({
|
|
284793
|
+
const turnUsage = createTurnUsage({
|
|
284794
|
+
tracker: () => usageTracker,
|
|
284795
|
+
cost: (t) => estimateTurnCostUsd({
|
|
284654
284796
|
providerId: deps.providerId,
|
|
284655
284797
|
modelId: deps.modelId,
|
|
284656
|
-
inputTokens:
|
|
284657
|
-
outputTokens:
|
|
284658
|
-
cacheReadTokens:
|
|
284659
|
-
cacheWriteTokens:
|
|
284660
|
-
})
|
|
284661
|
-
|
|
284662
|
-
|
|
284663
|
-
|
|
284664
|
-
|
|
284665
|
-
|
|
284798
|
+
inputTokens: t.input,
|
|
284799
|
+
outputTokens: t.output,
|
|
284800
|
+
cacheReadTokens: t.cacheRead,
|
|
284801
|
+
cacheWriteTokens: t.cacheWrite
|
|
284802
|
+
}),
|
|
284803
|
+
onUpdate: (t, costUsd) => {
|
|
284804
|
+
turnFooter.tokensIn = t.input;
|
|
284805
|
+
turnFooter.tokensOut = t.output;
|
|
284806
|
+
turnFooter.costUsd = costUsd;
|
|
284807
|
+
pushBusyFooter();
|
|
284808
|
+
}
|
|
284809
|
+
});
|
|
284810
|
+
const turnUsageSink = (usage) => turnUsage.onUsage(usage);
|
|
284811
|
+
turnUsageSlot.set(turnUsageSink);
|
|
284666
284812
|
const suggestNextStep = async () => {
|
|
284667
284813
|
const { signal, isCurrent } = suggestionGate.start();
|
|
284668
284814
|
try {
|
|
@@ -284865,6 +285011,7 @@ ${line}` : frameSubmittedLine(line) : line;
|
|
|
284865
285011
|
...agentShaped ? { origin: "agent-message" } : origin === "operator" ? {} : { origin },
|
|
284866
285012
|
...slateSession !== undefined ? { slateSession, pruneArchive: true } : {}
|
|
284867
285013
|
})).finally(() => {
|
|
285014
|
+
turnUsageSlot.clear(turnUsageSink);
|
|
284868
285015
|
const accepted = settleForegroundOperation(foregroundOperation, operation);
|
|
284869
285016
|
if (!accepted) {
|
|
284870
285017
|
if (!foregroundOperation.isDisposed)
|
|
@@ -284900,10 +285047,10 @@ ${line}` : frameSubmittedLine(line) : line;
|
|
|
284900
285047
|
recordTurnTaskCostBestEffort({
|
|
284901
285048
|
providerId: deps.providerId,
|
|
284902
285049
|
modelId: deps.modelId,
|
|
284903
|
-
inputTokens:
|
|
284904
|
-
outputTokens:
|
|
284905
|
-
...
|
|
284906
|
-
...
|
|
285050
|
+
inputTokens: turnUsage.totals.input,
|
|
285051
|
+
outputTokens: turnUsage.totals.output,
|
|
285052
|
+
...turnUsage.totals.cacheRead > 0 ? { cacheReadTokens: turnUsage.totals.cacheRead } : {},
|
|
285053
|
+
...turnUsage.totals.cacheWrite > 0 ? { cacheWriteTokens: turnUsage.totals.cacheWrite } : {},
|
|
284907
285054
|
success: !turnFailed,
|
|
284908
285055
|
...turnCategory !== undefined ? { category: turnCategory } : {}
|
|
284909
285056
|
});
|
|
@@ -284925,7 +285072,7 @@ ${line}` : frameSubmittedLine(line) : line;
|
|
|
284925
285072
|
})();
|
|
284926
285073
|
};
|
|
284927
285074
|
deps.jobRegistry?.onCompletion(() => {
|
|
284928
|
-
const busy = chrome.isBusy() || foregroundOperation.isActive;
|
|
285075
|
+
const busy = sessionTransferInProgress || chrome.isBusy() || foregroundOperation.isActive;
|
|
284929
285076
|
const idle = !busy && turnLoop.queue.length === 0 && leaseView()?.held() !== true;
|
|
284930
285077
|
if (!idle) {
|
|
284931
285078
|
return;
|
|
@@ -285060,9 +285207,12 @@ Turn: ${chrome.isBusy() ? "running" : "idle"} \xB7 queue: ${turnLoop.queue.lengt
|
|
|
285060
285207
|
`);
|
|
285061
285208
|
});
|
|
285062
285209
|
}
|
|
285210
|
+
if (sessionTransferInProgress && name !== "/exit") {
|
|
285211
|
+
return { ok: false, output: sessionTransferNotice };
|
|
285212
|
+
}
|
|
285063
285213
|
return await captureShellOutput(() => runLine(line, "operator", TG_SOURCE));
|
|
285064
285214
|
};
|
|
285065
|
-
const shellIsBusy = () => chrome.isBusy() || foregroundOperation.isActive || forceHandoff.isAwaitingSettlement || turnLoop.queue.length > 0 || leaseView()?.held() === true;
|
|
285215
|
+
const shellIsBusy = () => sessionTransferInProgress || chrome.isBusy() || foregroundOperation.isActive || forceHandoff.isAwaitingSettlement || turnLoop.queue.length > 0 || leaseView()?.held() === true;
|
|
285066
285216
|
const hubShellBusy = () => shellIsBusy() || chrome.overlayActive() || turnLoop.drain.workInFlight();
|
|
285067
285217
|
const hubCommands = [
|
|
285068
285218
|
{ name: "help", description: "Show commands available in this connected shell" },
|
|
@@ -285148,7 +285298,7 @@ Turn: ${chrome.isBusy() ? "running" : "idle"} \xB7 queue: ${turnLoop.queue.lengt
|
|
|
285148
285298
|
isBusy: hubShellBusy,
|
|
285149
285299
|
turnId: currentHubTurn,
|
|
285150
285300
|
submit: (text) => {
|
|
285151
|
-
if (destroyed || !sessionLease.canPersist())
|
|
285301
|
+
if (destroyed || sessionTransferInProgress || !sessionLease.canPersist())
|
|
285152
285302
|
return false;
|
|
285153
285303
|
runLine(text, "operator", "hub");
|
|
285154
285304
|
return true;
|
|
@@ -285343,8 +285493,15 @@ ${formatUsageTable(usageTracker.snapshot())}`
|
|
|
285343
285493
|
onKeypress4(r, (key) => {
|
|
285344
285494
|
handleQueueNavKey(key);
|
|
285345
285495
|
});
|
|
285346
|
-
chrome.
|
|
285347
|
-
|
|
285496
|
+
chrome.onEscapeInterrupt(() => {
|
|
285497
|
+
if (!foregroundOperation.cancel("interrupted by Escape"))
|
|
285498
|
+
return false;
|
|
285499
|
+
io.onSystem?.(`\u25C7 main turn interrupted (Esc).
|
|
285500
|
+
`);
|
|
285501
|
+
return true;
|
|
285502
|
+
});
|
|
285503
|
+
chrome.onSubmit((line, draft) => {
|
|
285504
|
+
runLine(line, "operator", undefined, false, draft);
|
|
285348
285505
|
});
|
|
285349
285506
|
setChoicePasteSink(chrome.dock, (text, afterClose) => {
|
|
285350
285507
|
const line = text.trim();
|
|
@@ -285398,7 +285555,7 @@ ${formatUsageTable(usageTracker.snapshot())}`
|
|
|
285398
285555
|
`);
|
|
285399
285556
|
}
|
|
285400
285557
|
}
|
|
285401
|
-
var
|
|
285558
|
+
var SIDE_WORKER_DENIED_TOOL_NAMES, CUSTOM_PROVIDER_ADD_ID = "__add_custom_provider__", CUSTOM_ADD_ENTRY, REASONING_PREVIEW_THROTTLE_MS = 100, OPENAI_CACHED_INPUT_DISCOUNT = 0.5, ANTHROPIC_CACHE_READ_MULTIPLIER = 0.1, ANTHROPIC_CACHE_WRITE_MULTIPLIER = 1.25, PROVIDERS_TABS, PROVIDERS_FOOTERS, NO_KEY_ENTERED_TEXT = "no key entered", MODE_PICKER_DESCRIPTIONS;
|
|
285402
285559
|
var init_tui_shell = __esm(() => {
|
|
285403
285560
|
init_runtime_switch();
|
|
285404
285561
|
init_shell_startup_trace();
|
|
@@ -285623,6 +285780,7 @@ function createChatBridge(hooks = {}) {
|
|
|
285623
285780
|
let closed = false;
|
|
285624
285781
|
let turn = false;
|
|
285625
285782
|
let streaming = false;
|
|
285783
|
+
let interruptTurn;
|
|
285626
285784
|
let heldSeparator = false;
|
|
285627
285785
|
let waiting;
|
|
285628
285786
|
const deliver = (line) => {
|
|
@@ -285642,6 +285800,7 @@ function createChatBridge(hooks = {}) {
|
|
|
285642
285800
|
return;
|
|
285643
285801
|
}
|
|
285644
285802
|
closed = true;
|
|
285803
|
+
interruptTurn = undefined;
|
|
285645
285804
|
queue.length = 0;
|
|
285646
285805
|
const resolve = waiting;
|
|
285647
285806
|
waiting = undefined;
|
|
@@ -285653,6 +285812,7 @@ function createChatBridge(hooks = {}) {
|
|
|
285653
285812
|
if (turn) {
|
|
285654
285813
|
turn = false;
|
|
285655
285814
|
streaming = false;
|
|
285815
|
+
interruptTurn = undefined;
|
|
285656
285816
|
heldSeparator = false;
|
|
285657
285817
|
hooks.onTurnSettled?.();
|
|
285658
285818
|
}
|
|
@@ -285695,7 +285855,8 @@ function createChatBridge(hooks = {}) {
|
|
|
285695
285855
|
streaming = true;
|
|
285696
285856
|
hooks.onText?.(s);
|
|
285697
285857
|
},
|
|
285698
|
-
onTurnStart: () => {
|
|
285858
|
+
onTurnStart: (interrupt) => {
|
|
285859
|
+
interruptTurn = interrupt;
|
|
285699
285860
|
heldSeparator = false;
|
|
285700
285861
|
hooks.onTurnStart?.();
|
|
285701
285862
|
},
|
|
@@ -285730,6 +285891,14 @@ function createChatBridge(hooks = {}) {
|
|
|
285730
285891
|
return "accepted";
|
|
285731
285892
|
},
|
|
285732
285893
|
close,
|
|
285894
|
+
interruptTurn: () => {
|
|
285895
|
+
const interrupt = interruptTurn;
|
|
285896
|
+
if (interrupt === undefined)
|
|
285897
|
+
return false;
|
|
285898
|
+
interruptTurn = undefined;
|
|
285899
|
+
interrupt();
|
|
285900
|
+
return true;
|
|
285901
|
+
},
|
|
285733
285902
|
turnActive: () => turn,
|
|
285734
285903
|
pending: () => queue.length
|
|
285735
285904
|
};
|
|
@@ -285837,6 +286006,7 @@ async function mountChatShell(otui, renderer, opts) {
|
|
|
285837
286006
|
append(body.includes("[error]") ? otui.t`${roleChunk(otui, "error", body)}` : otui.t`${dimChunk(otui, body)}`);
|
|
285838
286007
|
}
|
|
285839
286008
|
});
|
|
286009
|
+
chrome.onEscapeInterrupt(bridge.interruptTurn);
|
|
285840
286010
|
const selectProviderModel = async (_io, pickOpts) => {
|
|
285841
286011
|
const picked = opts.pickSelection === undefined ? undefined : await chrome.withOverlay(() => opts.pickSelection?.(pickOpts) ?? Promise.resolve(undefined));
|
|
285842
286012
|
chrome.focusComposer();
|
|
@@ -287100,7 +287270,7 @@ Kept the current session.
|
|
|
287100
287270
|
const turn = { user: line, text: "", abort: new AbortController };
|
|
287101
287271
|
activeTurn = turn;
|
|
287102
287272
|
busWorking = true;
|
|
287103
|
-
io.onTurnStart?.();
|
|
287273
|
+
io.onTurnStart?.(() => turn.abort.abort());
|
|
287104
287274
|
try {
|
|
287105
287275
|
const streamOptions = {
|
|
287106
287276
|
attemptId: deps.idSeq(),
|
|
@@ -287108,7 +287278,7 @@ Kept the current session.
|
|
|
287108
287278
|
...modelParams.timeoutMs !== undefined ? { timeoutMs: modelParams.timeoutMs } : {}
|
|
287109
287279
|
};
|
|
287110
287280
|
for await (const event of provider.stream(request, streamOptions)) {
|
|
287111
|
-
if (closing)
|
|
287281
|
+
if (closing || turn.abort.signal.aborted)
|
|
287112
287282
|
break;
|
|
287113
287283
|
if (event.kind === "text_delta") {
|
|
287114
287284
|
const text = event.text ?? "";
|
|
@@ -287129,9 +287299,11 @@ Kept the current session.
|
|
|
287129
287299
|
} catch (cause) {
|
|
287130
287300
|
if (closing)
|
|
287131
287301
|
break;
|
|
287132
|
-
|
|
287302
|
+
if (!turn.abort.signal.aborted) {
|
|
287303
|
+
system(`
|
|
287133
287304
|
[error] ${cause instanceof Error ? cause.message : String(cause)}
|
|
287134
287305
|
`);
|
|
287306
|
+
}
|
|
287135
287307
|
errored = true;
|
|
287136
287308
|
}
|
|
287137
287309
|
if (closing)
|
|
@@ -287140,6 +287312,11 @@ Kept the current session.
|
|
|
287140
287312
|
if (accumulated.length > 0) {
|
|
287141
287313
|
io.onTurnEnd?.(accumulated);
|
|
287142
287314
|
}
|
|
287315
|
+
if (turn.abort.signal.aborted) {
|
|
287316
|
+
system(`\u25C7 chat turn interrupted (Esc).
|
|
287317
|
+
`);
|
|
287318
|
+
errored = true;
|
|
287319
|
+
}
|
|
287143
287320
|
if (!errored) {
|
|
287144
287321
|
history.push({ role: "assistant", content: accumulated, provenance: "model" });
|
|
287145
287322
|
archive.push({ role: "user", content: line, provenance: "project" });
|
|
@@ -302638,7 +302815,7 @@ var init_native_coverage_generated = __esm(() => {
|
|
|
302638
302815
|
registryDigest: "286041ef4394afd4de97b4da37e31ccb2728c485cd32488c737a2686c244fbca",
|
|
302639
302816
|
contractDigest: "43cd83cfbd494ce63e1f6c86a5a0c057a160f4a537d8119358e0f262412a96c9",
|
|
302640
302817
|
subjectCatalogueDigest: "819a324bfef3387bf464f5c78d4831751b03c9c4f3cb636471e2d8f4bd88d6cc",
|
|
302641
|
-
inventoryDigest: "
|
|
302818
|
+
inventoryDigest: "606915a0fb13e4815ba0a0291cff453c528fc59956affb8de02c6536492aaa77",
|
|
302642
302819
|
releaseReady: true,
|
|
302643
302820
|
counts: {
|
|
302644
302821
|
registeredCommands: 74,
|
|
@@ -302916,7 +303093,7 @@ var init_native_coverage_generated = __esm(() => {
|
|
|
302916
303093
|
"workspace.navigate"
|
|
302917
303094
|
],
|
|
302918
303095
|
otherBlockers: [],
|
|
302919
|
-
descriptorDigest: "
|
|
303096
|
+
descriptorDigest: "dc96bae8760ee44ae261de3fa26ad8da417a231018a9e15357407567dbf6707e"
|
|
302920
303097
|
};
|
|
302921
303098
|
});
|
|
302922
303099
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrciphersmith/keryx",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.26",
|
|
4
4
|
"description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|