@xmoon76/dsh-pi-tui 0.5.7 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +64 -26
- package/README.md +64 -26
- package/cordis.patch.yml +13 -0
- package/dist/acp-stdio.mjs +151 -0
- package/dist/{bootstrap-C9nl6e13.mjs → bootstrap-CVyHGQDX.mjs} +22330 -6888
- package/dist/browser-CDUSHIIr.mjs +76 -0
- package/dist/builtins.mjs +2 -2
- package/dist/{client-bootstrap-CGezi85O.mjs → client-bootstrap-4UoeVIHE.mjs} +2407 -1830
- package/dist/client-runtime-BHBlVUf5.mjs +1376 -0
- package/dist/{daemon-launcher-H_1r5Cqs.mjs → daemon-launcher-DxIgjBHW.mjs} +1551 -57
- package/dist/daemon-launcher.d.mts +85 -14
- package/dist/daemon-launcher.mjs +2 -2
- package/dist/diagnostics-Db5iVcuJ.mjs +123 -0
- package/dist/{entry-control-jBfKn1qO.mjs → entry-control-BDLZgg4m.mjs} +1 -1
- package/dist/{extensions-6a5vvJUT.mjs → extensions-Dx7ncPNA.mjs} +1 -4
- package/dist/extensions.mjs +1 -1
- package/dist/handoff-BjoEy3f8.mjs +106 -0
- package/dist/history-search-limits-Cx2UvRC2.mjs +16 -0
- package/dist/history-search-remote-BHuoellG.mjs +113 -0
- package/dist/history-search-remote-BzXdvrxk.mjs +26 -0
- package/dist/history-search-seat-BcHJTpeB.mjs +639 -0
- package/dist/history-search-seat-rZcq0XV6.mjs +639 -0
- package/dist/{host-bootstrap-MVxks641.mjs → host-bootstrap-BfnufpnW.mjs} +37 -72
- package/dist/{host-foundation-probe-DK7n5jDu.mjs → host-foundation-probe-DlD8-N_Q.mjs} +2 -2
- package/dist/host-runtime.mjs +5611 -290
- package/dist/index.d.mts +13 -6
- package/dist/index.mjs +22766 -6893
- package/dist/installed-dsh-BjUiJSwR.mjs +142 -0
- package/dist/interaction-port-D1Yv9zgu.mjs +45 -0
- package/dist/local-acp-control-CC5z4Xbq.mjs +304 -0
- package/dist/local-acp-endpoint-D1jYdJdv.mjs +41 -0
- package/dist/local-acp-listener-Cmgb5M0H.mjs +9493 -0
- package/dist/local-acp-status-B_25Q6kU.mjs +101 -0
- package/dist/local-client.mjs +719 -93
- package/dist/local-daemon-control-BFJAC8Kg.mjs +2199 -0
- package/dist/local-daemon-control-Bm3imctD.mjs +2101 -0
- package/dist/{local-discovery-BPZw1wEd.mjs → local-discovery-BMhaGIiJ.mjs} +254 -544
- package/dist/{local-discovery-BMoNXZjJ.mjs → local-discovery-Ba7_-NNC.mjs} +1 -1
- package/dist/{local-discovery-Bq3jLAn1.mjs → local-discovery-QSbFpjK2.mjs} +301 -544
- package/dist/local-host.mjs +970 -501
- package/dist/local-profile-daemon-admin-otpm69R6.mjs +469 -0
- package/dist/{local-scope-DEuGAy8l.mjs → local-scope-5DEKA_lW.mjs} +1075 -31
- package/dist/{local-transport-X4ZCe2uE.mjs → local-transport-DeWmdZ5E.mjs} +14 -3
- package/dist/{local-web-control-DKWtXIkr.mjs → local-web-control-Dny93N-r.mjs} +10 -7
- package/dist/{local-workspace-object-D06GL0UO.mjs → local-workspace-object-D0RVQt8U.mjs} +33 -9
- package/dist/model-selection-CYlqg2DV.mjs +83 -0
- package/dist/native-client-domains-Dg4srzYt.mjs +2 -0
- package/dist/native-client.d.mts +735 -0
- package/dist/native-client.mjs +3534 -0
- package/dist/{open-CmOBxSjN.mjs → open-QQva8-ar.mjs} +24 -20
- package/dist/{pi-tui-remote-contribution-Do8ECrUy.mjs → pi-tui-remote-contribution-565wiLWp.mjs} +741 -150
- package/dist/preferences.mjs +1 -1
- package/dist/{profile-preferences-migration-CThz4rHH.mjs → profile-preferences-migration-CNOWIdnr.mjs} +1 -1
- package/dist/{profile-preferences-migration-BfUGdPZx.mjs → profile-preferences-migration-IrnXcJWK.mjs} +10 -8
- package/dist/{prompt-sections-DXmjB58H.mjs → prompt-sections-Bi-9_Gr_.mjs} +28 -10
- package/dist/{prompt-sections-DUKmWb8g.mjs → prompt-sections-DFS1dqsY.mjs} +342 -56
- package/dist/{dist-BFgC-5tL.mjs → recall-scope-9Nuoto_i.mjs} +353 -1
- package/dist/rolldown-runtime-8H4AJuhK.mjs +14 -0
- package/dist/schema-CCLvDa7Q.mjs +177 -0
- package/dist/{schema-qE_P09zJ.mjs → schema-t97l3aK8.mjs} +56 -3
- package/dist/{session-DC0XQr5O.mjs → session-Cs8iLCEx.mjs} +784 -342
- package/dist/{session-Cihe8PPS.mjs → session-EBRZF6Ow.mjs} +783 -341
- package/dist/session-create-facts-CkfG5DpQ.mjs +20 -0
- package/dist/{startup-CarQxWwi.d.mts → startup-Dti3Udne.d.mts} +30 -3
- package/dist/{startup-CARqn3kV.mjs → startup-UtFQSDe_.mjs} +90 -15
- package/dist/startup.d.mts +2 -2
- package/dist/startup.mjs +1 -1
- package/dist/task-read-remote-DRtkXDrZ.mjs +1083 -0
- package/dist/{terminal-progress-source-D4DHyXDo.mjs → terminal-progress-source-VsczdXA-.mjs} +610 -335
- package/dist/{transcript-view-a7cROAaI.mjs → transcript-view-B6vCnukn.mjs} +2284 -1166
- package/dist/{transcript-view-hvNVkPtv.mjs → transcript-view-DSSdE2vK.mjs} +2191 -765
- package/dist/write-failure-xNKczXH7.mjs +189 -0
- package/package.json +25 -8
- package/dist/local-acp-listener-CNkguN5-.mjs +0 -2566
- package/dist/local-daemon-control-Bg9s2aYi.mjs +0 -1424
- package/dist/local-daemon-control-Cu_4FIdd.mjs +0 -1585
- package/dist/local-profile-daemon-admin-AXgVH-6y.mjs +0 -91
- package/dist/preset-BcWqOtY7.mjs +0 -46
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as rankPathCandidates, I as reattachDisplayBase, L as resolvePathQuery, M as discoverForQuery, N as escapeFinderRegex, P as createBoundedFinderCandidateCollector, R as separatorOfRaw, j as createFinderRecordStream } from "./prompt-sections-DFS1dqsY.mjs";
|
|
2
2
|
import { i as StepUsageAccumulator, s as totalTokens } from "./performance-view-CfGvLZyD.mjs";
|
|
3
3
|
import { C as chartHumanText, E as chartValueRows, I as humanFacingVisualResult, L as isVisualToolName, M as CHART_TOOL_NAME, N as PRESENT_VISUAL_TOOL_NAME, P as SVG_TOOL_NAME, c as visualParts, g as svgDetailRows, u as visualPartsFromText, w as chartProjection, x as chartDisplayTitle } from "./runtime-status-v-FTnWcD.mjs";
|
|
4
|
-
import { Et as resolveCommandFooterFallback, I as CombinedAutocompleteProvider, Tt as parseFooterLayout, _t as sliceByColumn, bt as visibleWidth, rt as fuzzyFilter, wt as isFooterLayout, xt as wrapTextWithAnsi, yt as truncateToWidth } from "./extensions-
|
|
4
|
+
import { Et as resolveCommandFooterFallback, I as CombinedAutocompleteProvider, Tt as parseFooterLayout, _t as sliceByColumn, bt as visibleWidth, rt as fuzzyFilter, wt as isFooterLayout, xt as wrapTextWithAnsi, yt as truncateToWidth } from "./extensions-Dx7ncPNA.mjs";
|
|
5
|
+
import { Q as shortSessionId } from "./daemon-launcher-DxIgjBHW.mjs";
|
|
5
6
|
import { accessSync, appendFileSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
6
7
|
import { homedir } from "node:os";
|
|
7
8
|
import { delimiter, dirname, join } from "node:path";
|
|
@@ -12,8 +13,8 @@ import { ToolCallId, expandAssistantStream } from "@deepseek-ai/dsh-llm";
|
|
|
12
13
|
import { open, readdir, stat } from "node:fs/promises";
|
|
13
14
|
import { formatFileMention } from "@deepseek-ai/dsh-file-reference/grammar";
|
|
14
15
|
import { spawn } from "node:child_process";
|
|
15
|
-
import { Chalk } from "chalk";
|
|
16
16
|
import { Marked } from "marked";
|
|
17
|
+
import { Chalk } from "chalk";
|
|
17
18
|
import { html, ui } from "@stencil-hq/tern";
|
|
18
19
|
//#region src/client/history/store.ts
|
|
19
20
|
/**
|
|
@@ -340,6 +341,25 @@ function classifyTranscriptMessage(message) {
|
|
|
340
341
|
}
|
|
341
342
|
}
|
|
342
343
|
/**
|
|
344
|
+
* The ONE internal numeric model-turn reader shared by transcript consumers:
|
|
345
|
+
* the row's admitted semantic-turn ownership, or `undefined` when the row
|
|
346
|
+
* owns none (a command, a window summary, or a compaction that never proved a
|
|
347
|
+
* numeric owner). A standalone compaction is a real transcript row that
|
|
348
|
+
* belongs to NO model turn — never `0`, never a placement anchor. This is
|
|
349
|
+
* SEMANTIC ownership; the fold's presentation placement (`TranscriptFolder`
|
|
350
|
+
* `placementAnchorOf`) is a separate fact and must never be promoted here.
|
|
351
|
+
*
|
|
352
|
+
* Already-narrowed accesses on tool/system/assistant/user rows keep their
|
|
353
|
+
* definite `turn`; this helper exists for the generic row readers (window,
|
|
354
|
+
* grouping, Focus projection, search navigation) whose union includes the
|
|
355
|
+
* optional-turn compaction row.
|
|
356
|
+
*/
|
|
357
|
+
function transcriptTurnOf(message) {
|
|
358
|
+
if (!("turn" in message)) return void 0;
|
|
359
|
+
const turn = message.turn;
|
|
360
|
+
return typeof turn === "number" ? turn : void 0;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
343
363
|
* Whether a system row is an injected context boundary that Focus keeps
|
|
344
364
|
* visible when its Thought is collapsed. The fold's authoritative `context`
|
|
345
365
|
* marker intentionally covers unknown/future injection producers too.
|
|
@@ -493,7 +513,9 @@ function isTranscriptContextForm(value) {
|
|
|
493
513
|
* relay/notice sender, and the inject/recall role. This is the SINGLE
|
|
494
514
|
* parser of raw context sources; the fold and every projection consume its
|
|
495
515
|
* result. An absent/unknown form stays undefined — the caller must present
|
|
496
|
-
* the row as standalone generic Context.
|
|
516
|
+
* the row as standalone generic Context. `formDeclared` preserves the raw
|
|
517
|
+
* PRESENCE of the member (even an unknown or non-string value) so eligibility
|
|
518
|
+
* can distinguish "no form declared" from "declared but not understood".
|
|
497
519
|
* @param source - the logged user/message source, exactly as recorded.
|
|
498
520
|
*/
|
|
499
521
|
function contextPresentation(source) {
|
|
@@ -502,11 +524,19 @@ function contextPresentation(source) {
|
|
|
502
524
|
if (record === null) return { role };
|
|
503
525
|
const kind = readString(record, "kind");
|
|
504
526
|
const form = record["form"];
|
|
527
|
+
const formDeclared = Object.hasOwn(record, "form");
|
|
505
528
|
const senderSessionId = readString(record, "senderSessionId");
|
|
529
|
+
const entries = record["entries"];
|
|
530
|
+
const completeCatalogUpdate = kind === "skill-catalog" && form === "catalog" && record["update"] === true && !Object.hasOwn(record, "incomplete") && Array.isArray(entries) && entries.every((entry) => {
|
|
531
|
+
const item = asRecord(entry);
|
|
532
|
+
return item !== null && readString(item, "name") !== null && typeof item["description"] === "string";
|
|
533
|
+
});
|
|
506
534
|
return {
|
|
507
535
|
...isTranscriptContextForm(form) ? { form } : {},
|
|
536
|
+
...formDeclared ? { formDeclared: true } : {},
|
|
508
537
|
...kind === null ? {} : { sourceKind: kind },
|
|
509
538
|
...senderSessionId === null ? {} : { senderSessionId },
|
|
539
|
+
...completeCatalogUpdate ? { completeCatalogUpdate: true } : {},
|
|
510
540
|
role
|
|
511
541
|
};
|
|
512
542
|
}
|
|
@@ -530,6 +560,22 @@ function isAmbientContext(message) {
|
|
|
530
560
|
return isSurfacedContext(message) && form !== void 0 && AMBIENT_CONTEXT_FORMS.includes(form);
|
|
531
561
|
}
|
|
532
562
|
/**
|
|
563
|
+
* Whether one row is an image-bearing `ptc-mode` injected Context row.
|
|
564
|
+
*
|
|
565
|
+
* This is a STRUCTURED MEDIA question only: surfaced Context + the exact
|
|
566
|
+
* producer source kind `ptc-mode` + at least one real `image` ContentBlock.
|
|
567
|
+
* It deliberately says nothing about same-turn delivery/carriage (that is the
|
|
568
|
+
* separate `sameTurnNextStep` presentation flag), nothing about producer
|
|
569
|
+
* intent subtypes (none exist yet) and never parses the flat text. The
|
|
570
|
+
* producer's text-only Spill Context and its environment-reset Context are
|
|
571
|
+
* therefore never image-bearing rows.
|
|
572
|
+
*/
|
|
573
|
+
function isPtcImageContext(message) {
|
|
574
|
+
if (!isSurfacedContext(message)) return false;
|
|
575
|
+
if (message.contextPresentation?.sourceKind !== "ptc-mode") return false;
|
|
576
|
+
return message.content !== void 0 && message.content.some((block) => block.type === "image");
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
533
579
|
* The card-header icon SEMANTIC for one context injection, keyed by source
|
|
534
580
|
* kind so a reader can tell an instruction file from a skill catalog or a
|
|
535
581
|
* recalled session at a glance (the Web renders one browse icon for all of
|
|
@@ -583,8 +629,9 @@ function recentTurnThreshold(messages, recentTurns, kinds) {
|
|
|
583
629
|
if (recentTurns <= 0) return Number.POSITIVE_INFINITY;
|
|
584
630
|
const turns = /* @__PURE__ */ new Set();
|
|
585
631
|
for (const message of messages) {
|
|
586
|
-
|
|
587
|
-
if (
|
|
632
|
+
const turn = transcriptTurnOf(message);
|
|
633
|
+
if (turn === void 0) continue;
|
|
634
|
+
if (kinds === void 0 || kinds.includes(message.kind)) turns.add(turn);
|
|
588
635
|
}
|
|
589
636
|
const sorted = [...turns].sort((a, b) => b - a);
|
|
590
637
|
if (sorted.length <= recentTurns) return 0;
|
|
@@ -1293,12 +1340,18 @@ function windowMessages(messages, maxTurns, endTurn) {
|
|
|
1293
1340
|
if (maxTurns <= 0) return [...messages];
|
|
1294
1341
|
if (endTurn !== void 0) {
|
|
1295
1342
|
const turns = /* @__PURE__ */ new Set();
|
|
1296
|
-
for (const message of messages)
|
|
1343
|
+
for (const message of messages) {
|
|
1344
|
+
const turn = transcriptTurnOf(message);
|
|
1345
|
+
if (turn !== void 0) turns.add(turn);
|
|
1346
|
+
}
|
|
1297
1347
|
const sorted = [...turns].sort((a, b) => b - a);
|
|
1298
1348
|
const anchor = sorted.indexOf(endTurn);
|
|
1299
1349
|
if (anchor === -1) return windowMessages(messages, maxTurns);
|
|
1300
1350
|
const windowTurns = new Set(sorted.slice(anchor, anchor + maxTurns));
|
|
1301
|
-
const kept = messages.filter((message) =>
|
|
1351
|
+
const kept = messages.filter((message) => {
|
|
1352
|
+
const turn = transcriptTurnOf(message);
|
|
1353
|
+
return turn === void 0 || windowTurns.has(turn);
|
|
1354
|
+
});
|
|
1302
1355
|
const newerTurns = new Set(sorted.slice(0, anchor));
|
|
1303
1356
|
const oldTurns = new Set(sorted.slice(anchor + maxTurns));
|
|
1304
1357
|
if (newerTurns.size === 0 && oldTurns.size === 0) return kept;
|
|
@@ -1318,10 +1371,11 @@ function windowMessages(messages, maxTurns, endTurn) {
|
|
|
1318
1371
|
let oldTools = 0;
|
|
1319
1372
|
let oldCount = 0;
|
|
1320
1373
|
for (const message of messages) {
|
|
1321
|
-
|
|
1374
|
+
const turn = transcriptTurnOf(message);
|
|
1375
|
+
if (turn !== void 0 && turn < boundary) {
|
|
1322
1376
|
oldCount += 1;
|
|
1323
1377
|
if (message.kind === "tool") oldTools += 1;
|
|
1324
|
-
oldTurns.add(
|
|
1378
|
+
oldTurns.add(turn);
|
|
1325
1379
|
continue;
|
|
1326
1380
|
}
|
|
1327
1381
|
kept.push(message);
|
|
@@ -1447,6 +1501,16 @@ function assistantLatestStepOf(activity) {
|
|
|
1447
1501
|
}
|
|
1448
1502
|
/** Whether an Assistant crossed an admitted human-steer boundary and is
|
|
1449
1503
|
* therefore a persistent conversation answer rather than Focus process. */
|
|
1504
|
+
/** Whether the exact Assistant row's step has authoritative continuation
|
|
1505
|
+
* evidence in the Fold: a real tool/call or step boundary after its
|
|
1506
|
+
* settlement, or a later output that confirmed its streaming candidate. The
|
|
1507
|
+
* Focus projection holds a latest-step settled Assistant back as the pending
|
|
1508
|
+
* final ONLY when this fact is absent; presentation row kind/order never
|
|
1509
|
+
* answers that question. */
|
|
1510
|
+
function assistantStepIntermediateOf(activity, message) {
|
|
1511
|
+
const step = assistantStepOf(message);
|
|
1512
|
+
return step !== void 0 && activity.intermediateAssistantSteps.has(step);
|
|
1513
|
+
}
|
|
1450
1514
|
function assistantCommittedBeforeSteer(activity, message) {
|
|
1451
1515
|
if (message.kind !== "assistant") return false;
|
|
1452
1516
|
const step = assistantStepOf(message);
|
|
@@ -1829,9 +1893,15 @@ function assistantEntryHasInterruptionEvidence(entry) {
|
|
|
1829
1893
|
* the shared {@link WorkflowProjection} owns the projection itself. */
|
|
1830
1894
|
var TranscriptFolder = class TranscriptFolder {
|
|
1831
1895
|
items = [];
|
|
1832
|
-
/**
|
|
1896
|
+
/** The observed valid positional prefix of the durable next-step queue,
|
|
1897
|
+
* awaiting a claim, cancellation or replacement. A fragment that cannot
|
|
1898
|
+
* address this prefix exactly discards it (fail open); JS splice clamping is
|
|
1899
|
+
* never positional evidence. */
|
|
1833
1900
|
pendingNextSteps = [];
|
|
1834
|
-
/**
|
|
1901
|
+
/** Unconsumed positive claim candidates: removed from next-step by an
|
|
1902
|
+
* official full-drain claim in this same open turn, awaiting the actual
|
|
1903
|
+
* `user/message` append. Retired at the owning turn's step/turn end and when
|
|
1904
|
+
* a newer open turn is accepted. */
|
|
1835
1905
|
claimedNextStepTurns = /* @__PURE__ */ new Map();
|
|
1836
1906
|
/** The assistant message object per (turn, step); streaming text lands in place. */
|
|
1837
1907
|
assistantEntries = /* @__PURE__ */ new Map();
|
|
@@ -1964,21 +2034,15 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
1964
2034
|
* turn 0 itself is a perfectly legal first turn (an in-turn-0 command
|
|
1965
2035
|
* anchored to 0 must NOT be re-anchored away by turn 1). */
|
|
1966
2036
|
seenAcceptedTurnStart = false;
|
|
1967
|
-
/** The placement-anchor AUTHORITY for
|
|
1968
|
-
*
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
*
|
|
1972
|
-
*
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
* `/compact` is the compaction card, so its window/search placement must
|
|
1977
|
-
* inherit the command's anchor (a pre-turn or replayed manual compaction
|
|
1978
|
-
* would otherwise keep the legacy `currentTurn` and anchor the wrong
|
|
1979
|
-
* bounded window). Written at fuse time; re-anchored with the leading
|
|
1980
|
-
* prefix exactly like the command sidecar. */
|
|
1981
|
-
manualCompactionPlacementTurns = /* @__PURE__ */ new WeakMap();
|
|
2037
|
+
/** The placement-anchor AUTHORITY for standalone rows (plan §4.3): one
|
|
2038
|
+
* anchor per command object, per compaction WITHOUT an admitted numeric
|
|
2039
|
+
* model-turn owner, and per successfully fused compaction representative.
|
|
2040
|
+
* Written at append time and re-anchored with the leading prefix. Search
|
|
2041
|
+
* navigation, the fast indexed window's physical ranges and the
|
|
2042
|
+
* non-monotonic defensive window all derive placement from this ONE sidecar
|
|
2043
|
+
* — never a semantic `turn` on the row, never a second dedicated map, and
|
|
2044
|
+
* never the reverse (an anchor is not ownership). */
|
|
2045
|
+
standalonePlacementTurns = /* @__PURE__ */ new WeakMap();
|
|
1982
2046
|
/** Manual-compaction correlation legs (post-PR166 plan §7): bounded direct
|
|
1983
2047
|
* lookups so `command/done.sourceEventSeq` and compaction
|
|
1984
2048
|
* `sourceCommandId` never scan history. */
|
|
@@ -2156,6 +2220,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2156
2220
|
tools: /* @__PURE__ */ new Map(),
|
|
2157
2221
|
thinkingTail: "",
|
|
2158
2222
|
confirmedSteps: /* @__PURE__ */ new Set(),
|
|
2223
|
+
intermediateAssistantSteps: /* @__PURE__ */ new Set(),
|
|
2159
2224
|
settledSteps: /* @__PURE__ */ new Set(),
|
|
2160
2225
|
firstVisibleAssistantTimes: /* @__PURE__ */ new Map(),
|
|
2161
2226
|
committedAnswerSteps: /* @__PURE__ */ new Set(),
|
|
@@ -2391,6 +2456,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2391
2456
|
activity.messageConfirmed = text === "" ? void 0 : text.slice(-TranscriptFolder.MESSAGE_TAIL_CAP);
|
|
2392
2457
|
activity.messageConfirmedStep = candidate.step;
|
|
2393
2458
|
activity.confirmedSteps.add(candidate.step);
|
|
2459
|
+
activity.intermediateAssistantSteps.add(candidate.step);
|
|
2394
2460
|
activity.messageCandidate = void 0;
|
|
2395
2461
|
}
|
|
2396
2462
|
/** Commit the exact previous text-only answer once its next step admits a
|
|
@@ -2449,72 +2515,77 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2449
2515
|
this.turnValueSet.add(turn);
|
|
2450
2516
|
}
|
|
2451
2517
|
/** The FIRST REAL model turn (turn/start) adopts the leading standalone
|
|
2452
|
-
* prefix (pre-turn commands
|
|
2453
|
-
* the first turn value, so an
|
|
2454
|
-
* first turn reveals them (the raw
|
|
2455
|
-
*
|
|
2456
|
-
*
|
|
2457
|
-
*
|
|
2518
|
+
* prefix (pre-turn commands AND pre-turn standalone compactions): their
|
|
2519
|
+
* anchors — 0 until now — re-anchor to the first accepted turn value, so an
|
|
2520
|
+
* anchored search window that contains the first turn reveals them (the raw
|
|
2521
|
+
* prefix itself renders from index 0). Only a REAL turn/start adopts the
|
|
2522
|
+
* prefix. A fused representative is skipped: its command was already
|
|
2523
|
+
* re-anchored through the ONE hand-over path, so the command stays the only
|
|
2524
|
+
* independent anchor authority regardless of fusion order. */
|
|
2458
2525
|
adoptLeadingAnchors(turn) {
|
|
2459
2526
|
if (this.seenAcceptedTurnStart) return;
|
|
2460
2527
|
this.seenAcceptedTurnStart = true;
|
|
2461
2528
|
if (this.pendingAnchorEntries.length === 0) return;
|
|
2462
2529
|
for (const index of this.pendingAnchorEntries) {
|
|
2463
2530
|
const item = this.items[index];
|
|
2464
|
-
if (item
|
|
2531
|
+
if (item === void 0) continue;
|
|
2532
|
+
if (item.kind === "compaction" && item.sourceCommand !== void 0) continue;
|
|
2533
|
+
if (item.kind === "command" || item.kind === "compaction") this.setPlacementAnchor(item, index, turn);
|
|
2465
2534
|
}
|
|
2466
2535
|
this.pendingAnchorEntries.length = 0;
|
|
2467
2536
|
}
|
|
2468
|
-
/** The PRESENTATION placement anchor of one
|
|
2469
|
-
*
|
|
2470
|
-
* still has no turn (re-anchored by {@link
|
|
2471
|
-
* drives window/search navigation ONLY — it is never stored on
|
|
2472
|
-
* a semantic `turn
|
|
2537
|
+
/** The PRESENTATION placement anchor of one standalone row: the turn
|
|
2538
|
+
* currently open, else the latest registered log-order turn, else 0 while
|
|
2539
|
+
* the log still has no turn (re-anchored by {@link adoptLeadingAnchors}).
|
|
2540
|
+
* This anchor drives window/search navigation ONLY — it is never stored on
|
|
2541
|
+
* the row as a semantic `turn`, and a numeric owner never consumes it. */
|
|
2473
2542
|
placementAnchorTurn() {
|
|
2474
2543
|
if (this.openTurn !== void 0) return this.openTurn;
|
|
2475
2544
|
return this.turnValues.length > 0 ? this.turnValues[this.turnValues.length - 1] : 0;
|
|
2476
2545
|
}
|
|
2477
|
-
/** Write one
|
|
2478
|
-
* fused manual-compaction
|
|
2479
|
-
* so its sidecar and search entry
|
|
2546
|
+
/** Write one standalone row's placement anchor and hand a COMMAND's anchor
|
|
2547
|
+
* over to an already fused manual-compaction representative: the card is
|
|
2548
|
+
* the VISIBLE owner, so its sidecar and search entry follow the same
|
|
2549
|
+
* anchor. This is the ONE write path — the anchor is never inferred back
|
|
2550
|
+
* into semantic ownership. */
|
|
2480
2551
|
setPlacementAnchor(message, index, turn) {
|
|
2481
|
-
this.
|
|
2552
|
+
this.standalonePlacementTurns.set(message, turn);
|
|
2482
2553
|
const entry = this.searchEntries[index];
|
|
2483
2554
|
if (entry !== void 0) entry.turn = turn;
|
|
2555
|
+
if (message.kind !== "command") return;
|
|
2484
2556
|
const owner = this.compactionOwnerByCommandId.get(message.commandId);
|
|
2485
2557
|
if (owner === void 0) return;
|
|
2486
2558
|
const compaction = this.items[owner];
|
|
2487
2559
|
if (compaction !== void 0 && compaction.kind === "compaction") {
|
|
2488
|
-
this.
|
|
2560
|
+
this.standalonePlacementTurns.set(compaction, turn);
|
|
2489
2561
|
const ownerEntry = this.searchEntries[owner];
|
|
2490
2562
|
if (ownerEntry !== void 0) ownerEntry.turn = turn;
|
|
2491
2563
|
}
|
|
2492
2564
|
}
|
|
2493
|
-
/** The placement anchor of one
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
* anchor. */
|
|
2565
|
+
/** The placement anchor of one standalone row from the shared authority
|
|
2566
|
+
* sidecar (undefined for numeric-turn-owned rows): a plain command, a
|
|
2567
|
+
* compaction with no admitted numeric owner, or a fused representative
|
|
2568
|
+
* inheriting its command's anchor. Never semantic ownership. */
|
|
2497
2569
|
placementAnchorOf(message) {
|
|
2498
|
-
|
|
2499
|
-
if (message.kind === "compaction" && message.sourceCommand !== void 0) return this.manualCompactionPlacementTurns.get(message);
|
|
2570
|
+
return this.standalonePlacementTurns.get(message);
|
|
2500
2571
|
}
|
|
2501
2572
|
/** Append one folded message, maintaining the window projections. Returns
|
|
2502
2573
|
* the raw item index (the stable search identity). */
|
|
2503
2574
|
appendItem(message) {
|
|
2504
2575
|
this.items.push(message);
|
|
2505
2576
|
const index = this.items.length - 1;
|
|
2577
|
+
if (message.kind === "command") setTranscriptTiming(message, pointTiming(message.time));
|
|
2506
2578
|
const corpus = transcriptSearchCorpus(message);
|
|
2507
|
-
const
|
|
2508
|
-
const anchorTurn =
|
|
2509
|
-
if (!ownsTurn && message.kind === "command") this.commandPlacementTurns.set(message, anchorTurn);
|
|
2579
|
+
const turn = transcriptTurnOf(message);
|
|
2580
|
+
const anchorTurn = turn ?? this.placementAnchorTurn();
|
|
2510
2581
|
this.searchEntries.push({
|
|
2511
2582
|
turn: anchorTurn,
|
|
2512
2583
|
normalizedText: corpus.normalizedText,
|
|
2513
2584
|
spans: corpus.spans
|
|
2514
2585
|
});
|
|
2515
|
-
if (
|
|
2586
|
+
if (turn === void 0 && (message.kind === "command" || message.kind === "compaction")) this.setPlacementAnchor(message, index, anchorTurn);
|
|
2587
|
+
if (turn === void 0 && !this.seenAcceptedTurnStart) this.pendingAnchorEntries.push(index);
|
|
2516
2588
|
this.searchRevisionCounter += 1;
|
|
2517
|
-
const turn = ownsTurn ? message.turn : void 0;
|
|
2518
2589
|
if (turn !== void 0) {
|
|
2519
2590
|
if (this.turnValues.length === 0) this.appendTurnIndex(turn);
|
|
2520
2591
|
else if (this.turnsMonotonic) {
|
|
@@ -2569,7 +2640,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2569
2640
|
if (group !== void 0 && this.representativeOf(index) !== index) continue;
|
|
2570
2641
|
const card = group ?? this.items[index];
|
|
2571
2642
|
if (card === void 0) continue;
|
|
2572
|
-
|
|
2643
|
+
const cardTurn = transcriptTurnOf(card);
|
|
2644
|
+
if (cardTurn !== void 0 && !(card.kind === "compaction" && card.sourceCommand !== void 0)) entry.turn = cardTurn;
|
|
2573
2645
|
const corpus = transcriptSearchCorpus(card);
|
|
2574
2646
|
entry.normalizedText = corpus.normalizedText;
|
|
2575
2647
|
entry.spans = corpus.spans;
|
|
@@ -2726,7 +2798,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2726
2798
|
continue;
|
|
2727
2799
|
}
|
|
2728
2800
|
const item = this.items[index];
|
|
2729
|
-
|
|
2801
|
+
const turn = item === void 0 ? void 0 : transcriptTurnOf(item);
|
|
2802
|
+
if (item !== void 0 && turn !== void 0 && this.isVisible(item)) this.addGroupedTurn(turn);
|
|
2730
2803
|
}
|
|
2731
2804
|
this.groupedTurnIndexDirty = false;
|
|
2732
2805
|
}
|
|
@@ -2913,7 +2986,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
2913
2986
|
flush();
|
|
2914
2987
|
runTurn = void 0;
|
|
2915
2988
|
if (item.kind === "tool" && absoluteCounts) this.groupedToolCount += 1;
|
|
2916
|
-
|
|
2989
|
+
const turn = transcriptTurnOf(item);
|
|
2990
|
+
if (turn !== void 0) this.addGroupedTurn(turn);
|
|
2917
2991
|
}
|
|
2918
2992
|
flush();
|
|
2919
2993
|
}
|
|
@@ -3054,7 +3128,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3054
3128
|
/** The turn value of one raw row, when it carries one. */
|
|
3055
3129
|
turnOfRaw(index) {
|
|
3056
3130
|
const item = this.items[index];
|
|
3057
|
-
return item
|
|
3131
|
+
return item === void 0 ? void 0 : transcriptTurnOf(item);
|
|
3058
3132
|
}
|
|
3059
3133
|
/** Re-group one LOCAL span from the display order: detach its existing groups,
|
|
3060
3134
|
* then rebuild the runs over the final display order (bounded by the span). */
|
|
@@ -3306,7 +3380,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3306
3380
|
if (members === void 0) return false;
|
|
3307
3381
|
const meta = this.groupMeta.get(previousGroup);
|
|
3308
3382
|
const firstMember = this.items[members[0]];
|
|
3309
|
-
const firstTurn = meta?.firstTurn ?? (firstMember
|
|
3383
|
+
const firstTurn = meta?.firstTurn ?? (firstMember === void 0 ? previous.turn : transcriptTurnOf(firstMember) ?? previous.turn);
|
|
3310
3384
|
const wasCross = meta?.spansTurns ?? this.crossTurn(members);
|
|
3311
3385
|
this.removeGroupedTurn(previousGroup.turn);
|
|
3312
3386
|
this.removeGroupedTurn(item.turn);
|
|
@@ -3370,10 +3444,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
3370
3444
|
crossTurn(members) {
|
|
3371
3445
|
if (members.length <= 1) return false;
|
|
3372
3446
|
const first = this.items[members[0]];
|
|
3373
|
-
const turn =
|
|
3447
|
+
const turn = transcriptTurnOf(first);
|
|
3374
3448
|
for (let i = 1; i < members.length; i += 1) {
|
|
3375
3449
|
const member = this.items[members[i]];
|
|
3376
|
-
if ((
|
|
3450
|
+
if (transcriptTurnOf(member) !== turn) return true;
|
|
3377
3451
|
}
|
|
3378
3452
|
return false;
|
|
3379
3453
|
}
|
|
@@ -4011,6 +4085,22 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4011
4085
|
isDeclaredToolCall(turn, step, callId) {
|
|
4012
4086
|
return this.declaredToolCallsByStep.get(stepKey(turn, step))?.has(callId) === true;
|
|
4013
4087
|
}
|
|
4088
|
+
/** Whether this step's durable evidence owns a same-step ACTUAL tool call
|
|
4089
|
+
* that the lane convergence places on the Assistant's FOLLOWING display side
|
|
4090
|
+
* (text-then-call). A cold fold can observe the call event BEFORE the
|
|
4091
|
+
* settlement; the existing lane relation is the display authority, and a
|
|
4092
|
+
* conformant raw row needs no relation. A call on the preceding side, a
|
|
4093
|
+
* requested-but-never-started call (no card) and an older-step call are not
|
|
4094
|
+
* continuation. */
|
|
4095
|
+
assistantStepHasFollowingActualCall(turn, step) {
|
|
4096
|
+
const declared = this.declaredToolCallsByStep.get(stepKey(turn, step));
|
|
4097
|
+
if (declared === void 0) return false;
|
|
4098
|
+
for (const callId of declared) {
|
|
4099
|
+
if (!this.toolCardIndexOf.has(toolCallKey(turn, step, callId))) continue;
|
|
4100
|
+
if (this.toolRowEvidence(turn, step, callId)?.position === "after") return true;
|
|
4101
|
+
}
|
|
4102
|
+
return false;
|
|
4103
|
+
}
|
|
4014
4104
|
/** Whether a proven Tool row already sits on the physical side its evidence
|
|
4015
4105
|
* asks for (so it keeps its own slot and needs no relation). */
|
|
4016
4106
|
toolRowIsConformant(evidence, anchorIndex) {
|
|
@@ -4597,7 +4687,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4597
4687
|
if (anchor !== void 0) anchoredRows.set(message, anchor);
|
|
4598
4688
|
else windowInput.push(message);
|
|
4599
4689
|
}
|
|
4600
|
-
const allTurns = [...new Set(windowInput.
|
|
4690
|
+
const allTurns = [...new Set(windowInput.map((message) => transcriptTurnOf(message)).filter((turn) => turn !== void 0))].sort((a, b) => a - b);
|
|
4601
4691
|
const windowed = windowMessages(windowInput, maxTurns, options.endTurn);
|
|
4602
4692
|
const sortedDesc = [...allTurns].sort((a, b) => b - a);
|
|
4603
4693
|
const anchorIndex = options.endTurn === void 0 ? -1 : sortedDesc.indexOf(options.endTurn);
|
|
@@ -4614,7 +4704,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4614
4704
|
if (windowedBody.has(message)) messages.push(message);
|
|
4615
4705
|
}
|
|
4616
4706
|
const visibleSet = /* @__PURE__ */ new Set();
|
|
4617
|
-
for (const message of messages)
|
|
4707
|
+
for (const message of messages) {
|
|
4708
|
+
const turn = transcriptTurnOf(message);
|
|
4709
|
+
if (turn !== void 0) visibleSet.add(turn);
|
|
4710
|
+
}
|
|
4618
4711
|
const visibleTurnValues = [...visibleSet].sort((a, b) => a - b);
|
|
4619
4712
|
const firstTurn = visibleTurnValues[0] ?? this.turnValues[range.start];
|
|
4620
4713
|
const lastTurn = visibleTurnValues[visibleTurnValues.length - 1] ?? this.turnValues[range.end];
|
|
@@ -4642,7 +4735,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4642
4735
|
}
|
|
4643
4736
|
if (leading.length > 0) projected.messages = [...leading, ...projected.messages];
|
|
4644
4737
|
}
|
|
4645
|
-
const visibleTurns = projected.messages.
|
|
4738
|
+
const visibleTurns = projected.messages.map((message) => transcriptTurnOf(message)).filter((turn) => turn !== void 0);
|
|
4646
4739
|
const firstTurn = visibleTurns[0] ?? this.turnValues[range.start];
|
|
4647
4740
|
const lastTurn = visibleTurns[visibleTurns.length - 1] ?? this.turnValues[range.end];
|
|
4648
4741
|
const facts = this.crossTurnGroups > 0 ? this.groupedTurnFacts(this.turnValues[range.start], this.turnValues[range.end]) : void 0;
|
|
@@ -4933,17 +5026,19 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
4933
5026
|
const compactionId = typeof data.compactionId === "string" ? data.compactionId : void 0;
|
|
4934
5027
|
let index = compactionId === void 0 ? void 0 : this.compacting.get(compactionId);
|
|
4935
5028
|
if (index === void 0) {
|
|
5029
|
+
const ownerTurn = kind === "compaction/start" || kind === "compaction/end" ? compactionOwnerTurnOf(data.turn) : void 0;
|
|
4936
5030
|
const created = {
|
|
4937
5031
|
kind: "compaction",
|
|
4938
|
-
turn: this.currentTurn,
|
|
4939
5032
|
text: "",
|
|
4940
5033
|
items: 0,
|
|
4941
5034
|
tokens: 0,
|
|
4942
|
-
running: true
|
|
5035
|
+
running: true,
|
|
5036
|
+
...ownerTurn === void 0 ? {} : { turn: ownerTurn }
|
|
4943
5037
|
};
|
|
4944
5038
|
this.appendItem(created);
|
|
4945
5039
|
index = this.items.length - 1;
|
|
4946
5040
|
setTranscriptTiming(created, pointTiming(event.time));
|
|
5041
|
+
if (ownerTurn !== void 0 && this.activityByTurn.get(ownerTurn)?.completed === true) markPostTurnReplayEvidence(created);
|
|
4947
5042
|
if (compactionId !== void 0) this.compacting.set(compactionId, index);
|
|
4948
5043
|
}
|
|
4949
5044
|
const entry = this.items[index];
|
|
@@ -5026,15 +5121,12 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5026
5121
|
compaction.sourceCommand = message;
|
|
5027
5122
|
this.fusedCommands.add(message);
|
|
5028
5123
|
this.compactionOwnerByCommandId.set(message.commandId, target);
|
|
5029
|
-
const
|
|
5124
|
+
const compactionPoint = transcriptTimingOf(compaction)?.startedAt;
|
|
5125
|
+
const commandPoint = transcriptTimingOf(message)?.startedAt;
|
|
5126
|
+
const earliestPoint = compactionPoint === void 0 ? commandPoint : commandPoint === void 0 ? compactionPoint : Math.min(compactionPoint, commandPoint);
|
|
5127
|
+
if (earliestPoint !== void 0) setTranscriptTiming(compaction, pointTiming(earliestPoint));
|
|
5128
|
+
const anchor = this.placementAnchorOf(message);
|
|
5030
5129
|
if (anchor !== void 0) this.setPlacementAnchor(message, index, anchor);
|
|
5031
|
-
const ghostIndex = this.turnValues.indexOf(compaction.turn);
|
|
5032
|
-
if (ghostIndex >= 0 && this.turnStarts[ghostIndex] === target && this.activityByTurn.get(compaction.turn)?.startedAt === void 0 && (ghostIndex + 1 >= this.turnStarts.length || this.turnStarts[ghostIndex + 1] === target + 1)) {
|
|
5033
|
-
this.turnValues.splice(ghostIndex, 1);
|
|
5034
|
-
this.turnStarts.splice(ghostIndex, 1);
|
|
5035
|
-
this.turnValueSet.delete(compaction.turn);
|
|
5036
|
-
this.removeGroupedTurn(compaction.turn);
|
|
5037
|
-
}
|
|
5038
5130
|
this.markSearchEntryDirty(target);
|
|
5039
5131
|
this.markSearchEntryDirty(index);
|
|
5040
5132
|
}
|
|
@@ -5106,15 +5198,25 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5106
5198
|
}
|
|
5107
5199
|
if (kind === "agent/inbox/spliced") {
|
|
5108
5200
|
const data = event.data;
|
|
5109
|
-
const
|
|
5201
|
+
const insertedSource = data.inserted;
|
|
5202
|
+
const inserted = Array.isArray(insertedSource) ? insertedSource.map((message) => ({
|
|
5110
5203
|
id: message.id,
|
|
5111
5204
|
insertionTurn: this.openTurn,
|
|
5112
5205
|
insertionTime: event.time
|
|
5113
|
-
}));
|
|
5114
|
-
|
|
5115
|
-
if (
|
|
5116
|
-
|
|
5117
|
-
|
|
5206
|
+
})) : [];
|
|
5207
|
+
const validInserted = Array.isArray(insertedSource) && inserted.every((identity) => typeof identity.id === "string" && identity.id !== "");
|
|
5208
|
+
if (validInserted) for (const { id } of inserted) this.claimedNextStepTurns.delete(id);
|
|
5209
|
+
if (data.target !== "next-step") return;
|
|
5210
|
+
const removedCount = data.removedCount ?? 0;
|
|
5211
|
+
if (!(validInserted && Number.isSafeInteger(data.start) && data.start >= 0 && Number.isSafeInteger(removedCount) && removedCount >= 0 && data.start <= this.pendingNextSteps.length && data.start + removedCount <= this.pendingNextSteps.length)) {
|
|
5212
|
+
this.pendingNextSteps.length = 0;
|
|
5213
|
+
this.claimedNextStepTurns.clear();
|
|
5214
|
+
return;
|
|
5215
|
+
}
|
|
5216
|
+
const priorObservedLength = this.pendingNextSteps.length;
|
|
5217
|
+
const removed = this.pendingNextSteps.splice(data.start, removedCount, ...inserted);
|
|
5218
|
+
if (!(data.start === 0 && removedCount > 0 && removedCount === priorObservedLength && inserted.length === 0 && data.outcome === void 0)) return;
|
|
5219
|
+
for (const identity of removed) if (identity.insertionTurn !== void 0 && identity.insertionTurn === this.openTurn) this.claimedNextStepTurns.set(identity.id, identity);
|
|
5118
5220
|
return;
|
|
5119
5221
|
}
|
|
5120
5222
|
if (kind === "compaction/start" || kind === "compaction/summary" || kind === "compaction/end" || kind === "session/end-seed") {
|
|
@@ -5170,6 +5272,11 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5170
5272
|
}
|
|
5171
5273
|
}
|
|
5172
5274
|
this.usage.onStepStart(event.data.turn, event.data.step);
|
|
5275
|
+
const latestSettled = activity.lastAssistantStep;
|
|
5276
|
+
if (latestSettled !== void 0 && event.data.step > latestSettled && activity.settledSteps.has(latestSettled) && !activity.intermediateAssistantSteps.has(latestSettled)) {
|
|
5277
|
+
activity.intermediateAssistantSteps.add(latestSettled);
|
|
5278
|
+
activity.revision += 1;
|
|
5279
|
+
}
|
|
5173
5280
|
const candidate = activity.messageCandidate;
|
|
5174
5281
|
if (candidate !== void 0 && candidate.step < event.data.step) {
|
|
5175
5282
|
this.confirmMessageCandidate(activity);
|
|
@@ -5181,6 +5288,9 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5181
5288
|
case "step/end": {
|
|
5182
5289
|
const activity = this.activityFor(event.data.turn);
|
|
5183
5290
|
if (activity.completed) break;
|
|
5291
|
+
if (event.data.turn === this.openTurn) {
|
|
5292
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn === this.openTurn) this.claimedNextStepTurns.delete(identity.id);
|
|
5293
|
+
}
|
|
5184
5294
|
this.markAttemptEvidenceInterrupted(event.data.turn, event.data.step);
|
|
5185
5295
|
this.clearPreparingStartsForStep(event.data.turn, event.data.step);
|
|
5186
5296
|
this.usage.onStepEnd(event.data.turn, event.data.step);
|
|
@@ -5196,18 +5306,22 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5196
5306
|
this.adoptLeadingAnchors(event.data.turn);
|
|
5197
5307
|
activity.completed = false;
|
|
5198
5308
|
activity.reason = void 0;
|
|
5199
|
-
if (event.data.turn === this.currentTurn)
|
|
5309
|
+
if (event.data.turn === this.currentTurn) {
|
|
5310
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn !== event.data.turn) this.claimedNextStepTurns.delete(identity.id);
|
|
5311
|
+
this.openTurn = event.data.turn;
|
|
5312
|
+
}
|
|
5200
5313
|
activity.revision += 1;
|
|
5201
5314
|
break;
|
|
5202
5315
|
}
|
|
5203
5316
|
case "user/message": {
|
|
5204
5317
|
const claimedIdentity = this.claimedNextStepTurns.get(event.data.id);
|
|
5205
|
-
|
|
5206
|
-
const
|
|
5318
|
+
this.claimedNextStepTurns.delete(event.data.id);
|
|
5319
|
+
const openTurn = this.openTurn;
|
|
5320
|
+
const deliveredThisTurn = claimedIdentity !== void 0 && openTurn !== void 0 && claimedIdentity.insertionTurn === openTurn && this.currentTurn === openTurn;
|
|
5321
|
+
const isMidTurnSteer = deliveredThisTurn;
|
|
5207
5322
|
const blocks = event.data.content;
|
|
5208
5323
|
const text = textWithAttachmentMarkers(blocks);
|
|
5209
5324
|
const sourcePresentation = contextPresentation(event.data.source);
|
|
5210
|
-
const sameTurnNextStepDelivery = wasClaimedFromNextStep === true && claimedIdentity !== void 0 && claimedIdentity.insertionTurn === this.currentTurn && (sourcePresentation.sourceKind === "tool-jobs" && sourcePresentation.form === "notice" || sourcePresentation.sourceKind === "agent-message" && sourcePresentation.form === "relay" || sourcePresentation.sourceKind === "subagent-settled" && sourcePresentation.form === "notice");
|
|
5211
5325
|
if (sourcePresentation.sourceKind === "user") {
|
|
5212
5326
|
if (!userBlocksVisibleNow(blocks)) break;
|
|
5213
5327
|
const activity = this.activityFor(this.currentTurn);
|
|
@@ -5237,7 +5351,8 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5237
5351
|
...summary === null ? {} : { summary },
|
|
5238
5352
|
icon: contextIconSemantic(event.data.source),
|
|
5239
5353
|
context: true,
|
|
5240
|
-
|
|
5354
|
+
...sourcePresentation.sourceKind === "ptc-mode" && blocks.some((block) => block.type === "image") ? { content: blocks } : {},
|
|
5355
|
+
contextPresentation: deliveredThisTurn ? {
|
|
5241
5356
|
...sourcePresentation,
|
|
5242
5357
|
sameTurnNextStep: true
|
|
5243
5358
|
} : sourcePresentation
|
|
@@ -5308,8 +5423,10 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5308
5423
|
if (!alreadySettled) activity.assistantMessages += 1;
|
|
5309
5424
|
activity.settledSteps.add(event.data.step);
|
|
5310
5425
|
const staleForFocus = event.data.step < priorLast;
|
|
5426
|
+
if (!staleForFocus && this.assistantStepHasFollowingActualCall(event.data.turn, event.data.step)) activity.intermediateAssistantSteps.add(event.data.step);
|
|
5311
5427
|
if (!staleForFocus) activity.lastAssistantVisible = event.data.interrupted === true || assistantBlocksVisibleNow(messageBlocks);
|
|
5312
5428
|
activity.lastAssistantStep = Math.max(priorLast, event.data.step);
|
|
5429
|
+
if (priorLast !== void 0 && event.data.step > priorLast && activity.settledSteps.has(priorLast) && !activity.intermediateAssistantSteps.has(priorLast)) activity.intermediateAssistantSteps.add(priorLast);
|
|
5313
5430
|
if (staleForFocus) {
|
|
5314
5431
|
if (activity.messageConfirmedStep === event.data.step) activity.messageConfirmed = text === "" ? void 0 : text.slice(-TranscriptFolder.MESSAGE_TAIL_CAP);
|
|
5315
5432
|
} else {
|
|
@@ -5378,7 +5495,15 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5378
5495
|
status: "running"
|
|
5379
5496
|
};
|
|
5380
5497
|
}
|
|
5381
|
-
this.
|
|
5498
|
+
const provenPrecedingSameStepCall = (step) => event.data.step === step && this.toolRowEvidence(callTurn, event.data.step, key)?.position === "before";
|
|
5499
|
+
const candidate = activity.messageCandidate;
|
|
5500
|
+
if (candidate !== void 0) {
|
|
5501
|
+
if (event.data.step > candidate.step || event.data.step === candidate.step && !provenPrecedingSameStepCall(candidate.step)) this.confirmMessageCandidate(activity);
|
|
5502
|
+
} else {
|
|
5503
|
+
const latest = activity.lastAssistantStep;
|
|
5504
|
+
if (latest !== void 0 && event.data.step > latest && activity.settledSteps.has(latest) && !activity.intermediateAssistantSteps.has(latest)) activity.intermediateAssistantSteps.add(latest);
|
|
5505
|
+
else if (latest !== void 0 && event.data.step === latest && activity.settledSteps.has(latest) && !provenPrecedingSameStepCall(latest) && !activity.intermediateAssistantSteps.has(latest)) activity.intermediateAssistantSteps.add(latest);
|
|
5506
|
+
}
|
|
5382
5507
|
this.syncMessage(activity);
|
|
5383
5508
|
activity.revision += 1;
|
|
5384
5509
|
}
|
|
@@ -5496,6 +5621,7 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5496
5621
|
case "turn/end": {
|
|
5497
5622
|
const endTurn = event.data.turn;
|
|
5498
5623
|
if (this.openTurn === endTurn) this.openTurn = void 0;
|
|
5624
|
+
for (const identity of this.claimedNextStepTurns.values()) if (identity.insertionTurn === endTurn) this.claimedNextStepTurns.delete(identity.id);
|
|
5499
5625
|
const endActivity = this.activityFor(endTurn);
|
|
5500
5626
|
endActivity.pendingPreSteerAnswerStep = void 0;
|
|
5501
5627
|
if (endActivity.completed) break;
|
|
@@ -5645,6 +5771,14 @@ var TranscriptFolder = class TranscriptFolder {
|
|
|
5645
5771
|
}
|
|
5646
5772
|
}
|
|
5647
5773
|
};
|
|
5774
|
+
/** The official compaction lifecycle's admitted model-turn owner: a safe
|
|
5775
|
+
* non-negative integer from `compaction/start` or an end-only `compaction/end`.
|
|
5776
|
+
* The official `null` (standalone maintenance) and every missing/invalid value
|
|
5777
|
+
* admit NO numeric owner — never fall back to the fold's current/open turn.
|
|
5778
|
+
* Zero is a legal owner; this is a numeric test, never truthiness. */
|
|
5779
|
+
function compactionOwnerTurnOf(turn) {
|
|
5780
|
+
return typeof turn === "number" && Number.isSafeInteger(turn) && turn >= 0 ? turn : void 0;
|
|
5781
|
+
}
|
|
5648
5782
|
/** Validate and retain the official `command/done` outcome (post-PR166 plan
|
|
5649
5783
|
* §6): only a SUCCESS may carry the `sourceEventSeq` relationship, and the
|
|
5650
5784
|
* sequence must be a safe non-negative integer — anything malformed is
|
|
@@ -7526,193 +7660,6 @@ async function suggestPathArgument(argumentText, cwd, localFdPath = void 0) {
|
|
|
7526
7660
|
* AND get the matching `getArgumentCompletions` wiring. */
|
|
7527
7661
|
const FILE_ARGUMENT_COMMANDS = /* @__PURE__ */ new Set(["attach", "image"]);
|
|
7528
7662
|
//#endregion
|
|
7529
|
-
//#region src/tui/theme/runtime.ts
|
|
7530
|
-
/**
|
|
7531
|
-
* The live terminal palette + ANSI/TUI theme objects (TS8-E): the ONE owner
|
|
7532
|
-
* of the mutable current palette and of the chalk-backed style helpers,
|
|
7533
|
-
* searchable-picker/settings-list/editor/markdown themes and the host
|
|
7534
|
-
* markdown options. Every TUI renderer and every terminal-rendering
|
|
7535
|
-
* extension adapter (`extension/internal/component-compiler.ts`,
|
|
7536
|
-
* `slot-outlet.ts`) consumes this owner; the neutral palette vocabulary and
|
|
7537
|
-
* built-in palettes live in `domain/display/theme.ts`.
|
|
7538
|
-
* @module @xmoon76/dsh-pi-tui/tui/theme/runtime
|
|
7539
|
-
*/
|
|
7540
|
-
/** The active palette; style helpers read it on every call, so swapping is live. */
|
|
7541
|
-
let currentPalette = darkColors;
|
|
7542
|
-
/**
|
|
7543
|
-
* Switch the active palette; callers must invalidate rendered components.
|
|
7544
|
-
* `custom` uses the full palette in `customPalette`, or falls back to dark.
|
|
7545
|
-
* @param theme - the palette family.
|
|
7546
|
-
* @param custom - the resolved custom palette when `theme` is `custom`.
|
|
7547
|
-
*/
|
|
7548
|
-
function setTheme(theme, custom) {
|
|
7549
|
-
if (theme === "custom" && custom !== void 0) currentPalette = withSearchCurrentTokens(custom);
|
|
7550
|
-
else currentPalette = theme === "light" ? lightColors : darkColors;
|
|
7551
|
-
}
|
|
7552
|
-
const chalk = new Chalk({ level: 3 });
|
|
7553
|
-
const hex = (token) => chalk.hex(currentPalette[token] ?? currentPalette.text);
|
|
7554
|
-
/** Paint text with an explicit hex colour. Brand assets (the welcome whale
|
|
7555
|
-
* gradient) use a fixed ramp that is NOT a semantic token: it must not
|
|
7556
|
-
* follow the active palette, and custom themes do not override it. */
|
|
7557
|
-
const hexPaint = (hexValue, text) => chalk.hex(hexValue)(text);
|
|
7558
|
-
/** Style helpers by token name. The strong/dim/italic helpers accept an
|
|
7559
|
-
* optional TONE OVERRIDE (the footer layout's semantic tone override):
|
|
7560
|
-
* the override replaces the token, the style stays. */
|
|
7561
|
-
const color = {
|
|
7562
|
-
primary: (text) => hex("primary")(text),
|
|
7563
|
-
accent: (text) => hex("accent")(text),
|
|
7564
|
-
text: (text) => hex("text")(text),
|
|
7565
|
-
textStrong: (text, tone) => chalk.bold.hex(currentPalette[tone ?? "textStrong"] ?? currentPalette.textStrong)(text),
|
|
7566
|
-
textDim: (text, tone) => hex(tone ?? "textDim")(text),
|
|
7567
|
-
textMuted: (text) => hex("textMuted")(text),
|
|
7568
|
-
border: (text) => hex("border")(text),
|
|
7569
|
-
borderFocus: (text) => hex("borderFocus")(text),
|
|
7570
|
-
success: (text) => hex("success")(text),
|
|
7571
|
-
warning: (text) => hex("warning")(text),
|
|
7572
|
-
error: (text) => hex("error")(text),
|
|
7573
|
-
diffAdded: (text) => hex("diffAdded")(text),
|
|
7574
|
-
diffRemoved: (text) => hex("diffRemoved")(text),
|
|
7575
|
-
diffAddedStrong: (text) => chalk.bold.hex(currentPalette.diffAddedStrong)(text),
|
|
7576
|
-
diffRemovedStrong: (text) => chalk.bold.hex(currentPalette.diffRemovedStrong)(text),
|
|
7577
|
-
diffGutter: (text) => hex("diffGutter")(text),
|
|
7578
|
-
diffMeta: (text) => hex("diffMeta")(text),
|
|
7579
|
-
roleUser: (text) => hex("roleUser")(text),
|
|
7580
|
-
/** User-bubble background paint (dsh-web `--dsw-specific-bubble`
|
|
7581
|
-
* parity): the whole user row reads as a floating block. The token is
|
|
7582
|
-
* optional — an absent `roleUserBg` makes this an identity function. */
|
|
7583
|
-
roleUserBg: (text) => currentPalette.roleUserBg === void 0 ? text : chalk.bgHex(currentPalette.roleUserBg)(text),
|
|
7584
|
-
shellMode: (text) => hex("shellMode")(text),
|
|
7585
|
-
/** Ordinary visible transcript-search occurrence: explicit themed ink on a
|
|
7586
|
-
* yellow block, separate from the current occurrence. */
|
|
7587
|
-
searchMatch: (text) => chalk.hex(currentPalette.searchMatchFg ?? currentPalette.text).bgHex(currentPalette.searchMatchBg ?? currentPalette.warning)(text),
|
|
7588
|
-
/** The current card's REAL visible title/anchor when the exact source cells
|
|
7589
|
-
* cannot be proven. Same orange role as the current block but deliberately not
|
|
7590
|
-
* bold: the bold current style is reserved for a Full source-proven cell or
|
|
7591
|
-
* View's current mounted rendered occurrence. */
|
|
7592
|
-
searchCardAnchor: (text) => chalk.hex(currentPalette.searchCurrentFg ?? currentPalette.textStrong).bgHex(currentPalette.searchCurrentBg ?? currentPalette.primary)(text),
|
|
7593
|
-
/** The current search occurrence (Full source-proven, or View's current
|
|
7594
|
-
* mounted rendered occurrence): bold with an explicit themed
|
|
7595
|
-
* foreground AND background. NEVER the terminal's inverse attribute — a
|
|
7596
|
-
* palette that omits the tokens has them filled at apply time
|
|
7597
|
-
* ({@link withSearchCurrentTokens}), and this helper's own derivation stays
|
|
7598
|
-
* inside the palette. */
|
|
7599
|
-
searchCurrent: (text) => chalk.bold.hex(currentPalette.searchCurrentFg ?? currentPalette.textStrong).bgHex(currentPalette.searchCurrentBg ?? currentPalette.primary)(text),
|
|
7600
|
-
/** The LEGACY anchor-only ROW wash used when no visible card-anchor geometry
|
|
7601
|
-
* (header or first visible non-image text row) is available: it marks only the
|
|
7602
|
-
* owning row, never a proven occurrence, and ordinary query words on that row
|
|
7603
|
-
* keep their yellow block. A card with visible anchor geometry uses
|
|
7604
|
-
* {@link searchCardAnchor} instead. */
|
|
7605
|
-
searchAnchorBg: (text) => chalk.bgHex(currentPalette.searchAnchorBg ?? currentPalette.border)(text),
|
|
7606
|
-
/** Plain italics (kimi thinking parity); an optional tone override
|
|
7607
|
-
* colors the italic run. */
|
|
7608
|
-
italic: (text, tone) => tone === void 0 ? chalk.italic(text) : chalk.italic.hex(currentPalette[tone] ?? currentPalette.text)(text),
|
|
7609
|
-
/** Dim + italic for reasoning: intermediate thinking never reads like output. */
|
|
7610
|
-
textDimItalic: (text) => chalk.italic.hex(currentPalette.textDim)(text)
|
|
7611
|
-
};
|
|
7612
|
-
/** SearchablePicker palette from the semantic tokens (a structural
|
|
7613
|
-
* superset of the upstream SelectListTheme, so it still satisfies the
|
|
7614
|
-
* Editor's autocomplete theme slot). */
|
|
7615
|
-
const selectListTheme = {
|
|
7616
|
-
selectedPrefix: (text) => color.primary(text),
|
|
7617
|
-
selectedText: (text) => chalk.bold.hex(currentPalette.textStrong)(text),
|
|
7618
|
-
description: (text) => color.textDim(text),
|
|
7619
|
-
scrollInfo: (text) => color.textMuted(text),
|
|
7620
|
-
noMatch: (text) => color.textMuted(text),
|
|
7621
|
-
groupHeader: (text) => color.textDim(text)
|
|
7622
|
-
};
|
|
7623
|
-
/**
|
|
7624
|
-
* The readable half of a task/job state: the Title Case status WORD that
|
|
7625
|
-
* carries the shared `‣` marker (design language `docs/architecture/design-language.md`
|
|
7626
|
-
* §3.2 role 9 — colour is never the only signal, §3.3.3). The word is paired
|
|
7627
|
-
* with {@link taskStatusColor}'s token; the two must stay one vocabulary, so
|
|
7628
|
-
* this map lives beside the colour map (`docs/architecture/design-language.md` §10) and
|
|
7629
|
-
* is never forked.
|
|
7630
|
-
*
|
|
7631
|
-
* A status the map does not name is Title-cased verbatim: the surface may not
|
|
7632
|
-
* rename a real state it does not know, and a future wire status must still
|
|
7633
|
-
* paint a readable word.
|
|
7634
|
-
*/
|
|
7635
|
-
function taskStatusWord(status) {
|
|
7636
|
-
switch (status) {
|
|
7637
|
-
case "running": return "Running";
|
|
7638
|
-
case "stopping": return "Stopping";
|
|
7639
|
-
case "completed": return "Completed";
|
|
7640
|
-
case "failed": return "Failed";
|
|
7641
|
-
case "killed": return "Killed";
|
|
7642
|
-
case "timed_out": return "Timed out";
|
|
7643
|
-
case "lost": return "Lost";
|
|
7644
|
-
case "inactive": return "Inactive";
|
|
7645
|
-
case "awaiting answer": return "Awaiting answer";
|
|
7646
|
-
default: return status.charAt(0).toUpperCase() + status.slice(1);
|
|
7647
|
-
}
|
|
7648
|
-
}
|
|
7649
|
-
/**
|
|
7650
|
-
* Status-dot colour for a job status (dsh-web StateDot parity:
|
|
7651
|
-
* running = ongoing/primary, stopping/killed = warning, completed = done/dim,
|
|
7652
|
-
* failed/timed-out/lost = error). Unknown statuses fall back to the
|
|
7653
|
-
* muted token so a future wire status never crashes the renderer.
|
|
7654
|
-
*/
|
|
7655
|
-
function taskStatusColor(status) {
|
|
7656
|
-
switch (status) {
|
|
7657
|
-
case "running": return color.primary;
|
|
7658
|
-
case "stopping": return color.warning;
|
|
7659
|
-
case "completed": return color.textDim;
|
|
7660
|
-
case "failed":
|
|
7661
|
-
case "killed": return color.warning;
|
|
7662
|
-
case "timed_out":
|
|
7663
|
-
case "lost": return color.error;
|
|
7664
|
-
default: return color.textMuted;
|
|
7665
|
-
}
|
|
7666
|
-
}
|
|
7667
|
-
/**
|
|
7668
|
-
* SettingsList palette from the semantic tokens. A FUNCTION, not a
|
|
7669
|
-
* module-level constant: `cursor` is a pre-rendered ANSI string, so a
|
|
7670
|
-
* constant would freeze the cursor colour at module load and never follow
|
|
7671
|
-
* a live theme switch. Call it fresh for every overlay/settings open.
|
|
7672
|
-
*/
|
|
7673
|
-
function settingsListTheme() {
|
|
7674
|
-
return {
|
|
7675
|
-
label: (text, selected) => selected ? chalk.bold.hex(currentPalette.textStrong)(text) : color.text(text),
|
|
7676
|
-
value: (text, selected) => selected ? color.primary(text) : color.textDim(text),
|
|
7677
|
-
description: (text) => color.textDim(text),
|
|
7678
|
-
cursor: color.primary("> "),
|
|
7679
|
-
hint: (text) => color.textMuted(text)
|
|
7680
|
-
};
|
|
7681
|
-
}
|
|
7682
|
-
/** Editor palette: focused border uses the brand token. */
|
|
7683
|
-
const editorTheme = {
|
|
7684
|
-
borderColor: (text) => color.border(text),
|
|
7685
|
-
selectList: selectListTheme
|
|
7686
|
-
};
|
|
7687
|
-
/**
|
|
7688
|
-
* Markdown rendering options shared by EVERY host transcript renderer
|
|
7689
|
-
* (assistant cards, thinking blocks, plugin component compilation).
|
|
7690
|
-
* LaTeX-to-Unicode rendering is deliberately OFF (the kimi-host parity
|
|
7691
|
-
* choice): the Earendil 0.84.4 re-vendor introduced `renderLatex`
|
|
7692
|
-
* defaulting to true, which silently changed how `$...$`/`$$...$$`
|
|
7693
|
-
* segments in assistant output render. Keep the pre-re-vendor rendering;
|
|
7694
|
-
* revisit as an explicit setting if LaTeX output ever becomes a product
|
|
7695
|
-
* requirement.
|
|
7696
|
-
*/
|
|
7697
|
-
const HOST_MARKDOWN_OPTIONS = { renderLatex: false };
|
|
7698
|
-
/** Markdown palette for assistant messages. */
|
|
7699
|
-
const markdownTheme = {
|
|
7700
|
-
heading: (text) => chalk.bold.hex(currentPalette.textStrong)(text),
|
|
7701
|
-
link: (text) => color.primary(text),
|
|
7702
|
-
linkUrl: (text) => color.textMuted(text),
|
|
7703
|
-
code: (text) => color.primary(text),
|
|
7704
|
-
codeBlock: (text) => text,
|
|
7705
|
-
codeBlockBorder: (text) => color.textMuted(text),
|
|
7706
|
-
quote: (text) => color.textDim(text),
|
|
7707
|
-
quoteBorder: (text) => color.textDim(text),
|
|
7708
|
-
hr: (text) => color.border(text),
|
|
7709
|
-
listBullet: (text) => color.text(text.replace(/^-/, "•")),
|
|
7710
|
-
bold: (text) => chalk.bold(text),
|
|
7711
|
-
italic: (text) => chalk.italic(text),
|
|
7712
|
-
strikethrough: (text) => chalk.strikethrough(text),
|
|
7713
|
-
underline: (text) => chalk.underline(text)
|
|
7714
|
-
};
|
|
7715
|
-
//#endregion
|
|
7716
7663
|
//#region src/tui/presentation/terminal-text.ts
|
|
7717
7664
|
/**
|
|
7718
7665
|
* Untrusted-text projections for terminal-bound presentation.
|
|
@@ -8030,34 +7977,221 @@ function sanitizedPhysicalLine(text) {
|
|
|
8030
7977
|
return sanitizeDisplayText(text).replace(/[\t\r\n]+/g, " ");
|
|
8031
7978
|
}
|
|
8032
7979
|
//#endregion
|
|
8033
|
-
//#region src/tui/
|
|
8034
|
-
const IDENTITY_SEP = "\0";
|
|
8035
|
-
const PROVIDER_DEFAULT = `${IDENTITY_SEP}provider-default`;
|
|
8036
|
-
/** Full logical identity of a model row. Model ids are not globally unique. */
|
|
8037
|
-
function modelIdentity(providerId, modelId) {
|
|
8038
|
-
return `${providerId}${IDENTITY_SEP}${modelId}`;
|
|
8039
|
-
}
|
|
7980
|
+
//#region src/tui/theme/runtime.ts
|
|
8040
7981
|
/**
|
|
8041
|
-
*
|
|
8042
|
-
*
|
|
8043
|
-
*
|
|
7982
|
+
* The live terminal palette + ANSI/TUI theme objects (TS8-E): the ONE owner
|
|
7983
|
+
* of the mutable current palette and of the chalk-backed style helpers,
|
|
7984
|
+
* searchable-picker/settings-list/editor/markdown themes and the host
|
|
7985
|
+
* markdown options. Every TUI renderer and every terminal-rendering
|
|
7986
|
+
* extension adapter (`extension/internal/component-compiler.ts`,
|
|
7987
|
+
* `slot-outlet.ts`) consumes this owner; the neutral palette vocabulary and
|
|
7988
|
+
* built-in palettes live in `domain/display/theme.ts`.
|
|
7989
|
+
* @module @xmoon76/dsh-pi-tui/tui/theme/runtime
|
|
8044
7990
|
*/
|
|
8045
|
-
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
7991
|
+
/** The active palette; style helpers read it on every call, so swapping is live. */
|
|
7992
|
+
let currentPalette = darkColors;
|
|
7993
|
+
/**
|
|
7994
|
+
* Switch the active palette; callers must invalidate rendered components.
|
|
7995
|
+
* `custom` uses the full palette in `customPalette`, or falls back to dark.
|
|
7996
|
+
* @param theme - the palette family.
|
|
7997
|
+
* @param custom - the resolved custom palette when `theme` is `custom`.
|
|
7998
|
+
*/
|
|
7999
|
+
function setTheme(theme, custom) {
|
|
8000
|
+
if (theme === "custom" && custom !== void 0) currentPalette = withSearchCurrentTokens(custom);
|
|
8001
|
+
else currentPalette = theme === "light" ? lightColors : darkColors;
|
|
8002
|
+
}
|
|
8003
|
+
const chalk = new Chalk({ level: 3 });
|
|
8004
|
+
const hex = (token) => chalk.hex(currentPalette[token] ?? currentPalette.text);
|
|
8005
|
+
/** Paint text with an explicit hex colour. Brand assets (the welcome whale
|
|
8006
|
+
* gradient) use a fixed ramp that is NOT a semantic token: it must not
|
|
8007
|
+
* follow the active palette, and custom themes do not override it. */
|
|
8008
|
+
const hexPaint = (hexValue, text) => chalk.hex(hexValue)(text);
|
|
8009
|
+
/** Style helpers by token name. The strong/dim/italic helpers accept an
|
|
8010
|
+
* optional TONE OVERRIDE (the footer layout's semantic tone override):
|
|
8011
|
+
* the override replaces the token, the style stays. */
|
|
8012
|
+
const color = {
|
|
8013
|
+
primary: (text) => hex("primary")(text),
|
|
8014
|
+
accent: (text) => hex("accent")(text),
|
|
8015
|
+
text: (text) => hex("text")(text),
|
|
8016
|
+
textStrong: (text, tone) => chalk.bold.hex(currentPalette[tone ?? "textStrong"] ?? currentPalette.textStrong)(text),
|
|
8017
|
+
textDim: (text, tone) => hex(tone ?? "textDim")(text),
|
|
8018
|
+
textMuted: (text) => hex("textMuted")(text),
|
|
8019
|
+
border: (text) => hex("border")(text),
|
|
8020
|
+
borderFocus: (text) => hex("borderFocus")(text),
|
|
8021
|
+
success: (text) => hex("success")(text),
|
|
8022
|
+
warning: (text) => hex("warning")(text),
|
|
8023
|
+
error: (text) => hex("error")(text),
|
|
8024
|
+
diffAdded: (text) => hex("diffAdded")(text),
|
|
8025
|
+
diffRemoved: (text) => hex("diffRemoved")(text),
|
|
8026
|
+
diffAddedStrong: (text) => chalk.bold.hex(currentPalette.diffAddedStrong)(text),
|
|
8027
|
+
diffRemovedStrong: (text) => chalk.bold.hex(currentPalette.diffRemovedStrong)(text),
|
|
8028
|
+
diffGutter: (text) => hex("diffGutter")(text),
|
|
8029
|
+
diffMeta: (text) => hex("diffMeta")(text),
|
|
8030
|
+
roleUser: (text) => hex("roleUser")(text),
|
|
8031
|
+
/** User-bubble background paint (dsh-web `--dsw-specific-bubble`
|
|
8032
|
+
* parity): the whole user row reads as a floating block. The token is
|
|
8033
|
+
* optional — an absent `roleUserBg` makes this an identity function. */
|
|
8034
|
+
roleUserBg: (text) => currentPalette.roleUserBg === void 0 ? text : chalk.bgHex(currentPalette.roleUserBg)(text),
|
|
8035
|
+
shellMode: (text) => hex("shellMode")(text),
|
|
8036
|
+
/** Ordinary visible transcript-search occurrence: explicit themed ink on a
|
|
8037
|
+
* yellow block, separate from the current occurrence. */
|
|
8038
|
+
searchMatch: (text) => chalk.hex(currentPalette.searchMatchFg ?? currentPalette.text).bgHex(currentPalette.searchMatchBg ?? currentPalette.warning)(text),
|
|
8039
|
+
/** The current card's REAL visible title/anchor when the exact source cells
|
|
8040
|
+
* cannot be proven. Same orange role as the current block but deliberately not
|
|
8041
|
+
* bold: the bold current style is reserved for a Full source-proven cell or
|
|
8042
|
+
* View's current mounted rendered occurrence. */
|
|
8043
|
+
searchCardAnchor: (text) => chalk.hex(currentPalette.searchCurrentFg ?? currentPalette.textStrong).bgHex(currentPalette.searchCurrentBg ?? currentPalette.primary)(text),
|
|
8044
|
+
/** The current search occurrence (Full source-proven, or View's current
|
|
8045
|
+
* mounted rendered occurrence): bold with an explicit themed
|
|
8046
|
+
* foreground AND background. NEVER the terminal's inverse attribute — a
|
|
8047
|
+
* palette that omits the tokens has them filled at apply time
|
|
8048
|
+
* ({@link withSearchCurrentTokens}), and this helper's own derivation stays
|
|
8049
|
+
* inside the palette. */
|
|
8050
|
+
searchCurrent: (text) => chalk.bold.hex(currentPalette.searchCurrentFg ?? currentPalette.textStrong).bgHex(currentPalette.searchCurrentBg ?? currentPalette.primary)(text),
|
|
8051
|
+
/** The LEGACY anchor-only ROW wash used when no visible card-anchor geometry
|
|
8052
|
+
* (header or first visible non-image text row) is available: it marks only the
|
|
8053
|
+
* owning row, never a proven occurrence, and ordinary query words on that row
|
|
8054
|
+
* keep their yellow block. A card with visible anchor geometry uses
|
|
8055
|
+
* {@link searchCardAnchor} instead. */
|
|
8056
|
+
searchAnchorBg: (text) => chalk.bgHex(currentPalette.searchAnchorBg ?? currentPalette.border)(text),
|
|
8057
|
+
/** Plain italics (kimi thinking parity); an optional tone override
|
|
8058
|
+
* colors the italic run. */
|
|
8059
|
+
italic: (text, tone) => tone === void 0 ? chalk.italic(text) : chalk.italic.hex(currentPalette[tone] ?? currentPalette.text)(text),
|
|
8060
|
+
/** Dim + italic for reasoning: intermediate thinking never reads like output. */
|
|
8061
|
+
textDimItalic: (text) => chalk.italic.hex(currentPalette.textDim)(text)
|
|
8062
|
+
};
|
|
8063
|
+
/** SearchablePicker palette from the semantic tokens (a structural
|
|
8064
|
+
* superset of the upstream SelectListTheme, so it still satisfies the
|
|
8065
|
+
* Editor's autocomplete theme slot). */
|
|
8066
|
+
const selectListTheme = {
|
|
8067
|
+
selectedPrefix: (text) => color.primary(text),
|
|
8068
|
+
selectedText: (text) => chalk.bold.hex(currentPalette.textStrong)(text),
|
|
8069
|
+
description: (text) => color.textDim(text),
|
|
8070
|
+
scrollInfo: (text) => color.textMuted(text),
|
|
8071
|
+
noMatch: (text) => color.textMuted(text),
|
|
8072
|
+
groupHeader: (text) => color.textDim(text)
|
|
8073
|
+
};
|
|
8074
|
+
/**
|
|
8075
|
+
* The readable half of a task/job state: the Title Case status WORD that
|
|
8076
|
+
* carries the shared `‣` marker (design language `docs/architecture/design-language.md`
|
|
8077
|
+
* §3.2 role 9 — colour is never the only signal, §3.3.3). The word is paired
|
|
8078
|
+
* with {@link taskStatusColor}'s token; the two must stay one vocabulary, so
|
|
8079
|
+
* this map lives beside the colour map (`docs/architecture/design-language.md` §10) and
|
|
8080
|
+
* is never forked.
|
|
8081
|
+
*
|
|
8082
|
+
* A status the map does not name is Title-cased verbatim: the surface may not
|
|
8083
|
+
* rename a real state it does not know, and a future wire status must still
|
|
8084
|
+
* paint a readable word.
|
|
8085
|
+
*/
|
|
8086
|
+
function taskStatusWord(status) {
|
|
8087
|
+
switch (status) {
|
|
8088
|
+
case "running": return "Running";
|
|
8089
|
+
case "stopping": return "Stopping";
|
|
8090
|
+
case "completed": return "Completed";
|
|
8091
|
+
case "failed": return "Failed";
|
|
8092
|
+
case "killed": return "Killed";
|
|
8093
|
+
case "timed_out": return "Timed out";
|
|
8094
|
+
case "lost": return "Lost";
|
|
8095
|
+
case "inactive": return "Inactive";
|
|
8096
|
+
case "awaiting answer": return "Awaiting answer";
|
|
8097
|
+
default: return status.charAt(0).toUpperCase() + status.slice(1);
|
|
8098
|
+
}
|
|
8099
|
+
}
|
|
8100
|
+
/**
|
|
8101
|
+
* Status-dot colour for a job status (dsh-web StateDot parity:
|
|
8102
|
+
* running = ongoing/primary, stopping/killed = warning, completed = done/dim,
|
|
8103
|
+
* failed/timed-out/lost = error). Unknown statuses fall back to the
|
|
8104
|
+
* muted token so a future wire status never crashes the renderer.
|
|
8105
|
+
*/
|
|
8106
|
+
function taskStatusColor(status) {
|
|
8107
|
+
switch (status) {
|
|
8108
|
+
case "running": return color.primary;
|
|
8109
|
+
case "stopping": return color.warning;
|
|
8110
|
+
case "completed": return color.textDim;
|
|
8111
|
+
case "failed":
|
|
8112
|
+
case "killed": return color.warning;
|
|
8113
|
+
case "timed_out":
|
|
8114
|
+
case "lost": return color.error;
|
|
8115
|
+
default: return color.textMuted;
|
|
8116
|
+
}
|
|
8117
|
+
}
|
|
8118
|
+
/**
|
|
8119
|
+
* SettingsList palette from the semantic tokens. A FUNCTION, not a
|
|
8120
|
+
* module-level constant: `cursor` is a pre-rendered ANSI string, so a
|
|
8121
|
+
* constant would freeze the cursor colour at module load and never follow
|
|
8122
|
+
* a live theme switch. Call it fresh for every overlay/settings open.
|
|
8123
|
+
*/
|
|
8124
|
+
function settingsListTheme() {
|
|
8125
|
+
return {
|
|
8126
|
+
label: (text, selected) => selected ? chalk.bold.hex(currentPalette.textStrong)(text) : color.text(text),
|
|
8127
|
+
value: (text, selected) => selected ? color.primary(text) : color.textDim(text),
|
|
8128
|
+
description: (text) => color.textDim(text),
|
|
8129
|
+
cursor: color.primary("> "),
|
|
8130
|
+
hint: (text) => color.textMuted(text)
|
|
8131
|
+
};
|
|
8132
|
+
}
|
|
8133
|
+
/** Editor palette: focused border uses the brand token. */
|
|
8134
|
+
const editorTheme = {
|
|
8135
|
+
borderColor: (text) => color.border(text),
|
|
8136
|
+
selectList: selectListTheme
|
|
8137
|
+
};
|
|
8138
|
+
/**
|
|
8139
|
+
* Markdown rendering options shared by EVERY host transcript renderer
|
|
8140
|
+
* (assistant cards, thinking blocks, plugin component compilation).
|
|
8141
|
+
* LaTeX-to-Unicode rendering is deliberately OFF (the kimi-host parity
|
|
8142
|
+
* choice): the Earendil 0.84.4 re-vendor introduced `renderLatex`
|
|
8143
|
+
* defaulting to true, which silently changed how `$...$`/`$$...$$`
|
|
8144
|
+
* segments in assistant output render. Keep the pre-re-vendor rendering;
|
|
8145
|
+
* revisit as an explicit setting if LaTeX output ever becomes a product
|
|
8146
|
+
* requirement.
|
|
8147
|
+
*/
|
|
8148
|
+
const HOST_MARKDOWN_OPTIONS = { renderLatex: false };
|
|
8149
|
+
/** Markdown palette for assistant messages. */
|
|
8150
|
+
const markdownTheme = {
|
|
8151
|
+
heading: (text) => chalk.bold.hex(currentPalette.textStrong)(text),
|
|
8152
|
+
link: (text) => color.primary(text),
|
|
8153
|
+
linkUrl: (text) => color.textMuted(text),
|
|
8154
|
+
code: (text) => color.primary(text),
|
|
8155
|
+
codeBlock: (text) => text,
|
|
8156
|
+
codeBlockBorder: (text) => color.textMuted(text),
|
|
8157
|
+
quote: (text) => color.textDim(text),
|
|
8158
|
+
quoteBorder: (text) => color.textDim(text),
|
|
8159
|
+
hr: (text) => color.border(text),
|
|
8160
|
+
listBullet: (text) => color.text(text.replace(/^-/, "•")),
|
|
8161
|
+
bold: (text) => chalk.bold(text),
|
|
8162
|
+
italic: (text) => chalk.italic(text),
|
|
8163
|
+
strikethrough: (text) => chalk.strikethrough(text),
|
|
8164
|
+
underline: (text) => chalk.underline(text)
|
|
8165
|
+
};
|
|
8166
|
+
//#endregion
|
|
8167
|
+
//#region src/tui/pickers/model-directory.ts
|
|
8168
|
+
const IDENTITY_SEP = "\0";
|
|
8169
|
+
const PROVIDER_DEFAULT = `${IDENTITY_SEP}provider-default`;
|
|
8170
|
+
/** Full logical identity of a model row. Model ids are not globally unique. */
|
|
8171
|
+
function modelIdentity(providerId, modelId) {
|
|
8172
|
+
return `${providerId}${IDENTITY_SEP}${modelId}`;
|
|
8173
|
+
}
|
|
8174
|
+
/**
|
|
8175
|
+
* Project the Host directory into identity-complete presentation rows. Pure:
|
|
8176
|
+
* no terminal/component state, so the current/default/effort rules are unit
|
|
8177
|
+
* testable without a rendering snapshot.
|
|
8178
|
+
*/
|
|
8179
|
+
function projectModelDirectory(directory, current, sessionless) {
|
|
8180
|
+
const models = [];
|
|
8181
|
+
for (const group of directory.groups) for (const model of group.models) {
|
|
8182
|
+
const matchesConfigured = current !== void 0 && current.provider === group.id && current.model === model.id;
|
|
8183
|
+
const isCurrentModel = !sessionless && matchesConfigured;
|
|
8184
|
+
const isDefault = directory.default.provider === group.id && directory.default.model === model.id;
|
|
8185
|
+
models.push({
|
|
8186
|
+
providerId: group.id,
|
|
8187
|
+
providerName: group.name,
|
|
8188
|
+
modelId: model.id,
|
|
8189
|
+
modelName: model.name,
|
|
8190
|
+
efforts: model.reasoning?.efforts ?? [],
|
|
8191
|
+
...model.reasoning?.defaultEffort === void 0 ? {} : { defaultEffort: model.reasoning.defaultEffort },
|
|
8192
|
+
isCurrent: isCurrentModel,
|
|
8193
|
+
isDefault,
|
|
8194
|
+
...isCurrentModel && current?.reasoningEffort !== void 0 ? { currentEffort: current.reasoningEffort } : {},
|
|
8061
8195
|
...matchesConfigured && current?.reasoningEffort !== void 0 ? { configuredEffort: current.reasoningEffort } : {}
|
|
8062
8196
|
});
|
|
8063
8197
|
}
|
|
@@ -8095,6 +8229,139 @@ function initialEffortOf(row, choices) {
|
|
|
8095
8229
|
return advertised(row.configuredEffort) ?? advertised(row.defaultEffort) ?? choices[0].value;
|
|
8096
8230
|
}
|
|
8097
8231
|
//#endregion
|
|
8232
|
+
//#region src/tui/tsp/preset-guide-content.ts
|
|
8233
|
+
/** The official English Mode Guides of the four SHIPPED presets.
|
|
8234
|
+
*
|
|
8235
|
+
* The copy is a verbatim transcription of the official Web surface's curated
|
|
8236
|
+
* help, pinned to
|
|
8237
|
+
* `deepseek-ai/deepseek-harness@d743267388641bc76f17c45ce8b4c231aed1d32c`
|
|
8238
|
+
* `packages/client/ui-agent-preset/src/client/guide-locales.ts` (the `guideEn`
|
|
8239
|
+
* seat): the intro, the mode explanation and the usage examples, unchanged.
|
|
8240
|
+
* Refreshing the official wording means refreshing that pin — this module never
|
|
8241
|
+
* translates, rewrites or generates guide text of its own.
|
|
8242
|
+
*
|
|
8243
|
+
* Source license: the upstream repository is MIT (`Copyright (c) 2026
|
|
8244
|
+
* DeepSeek`); this transcription keeps the upstream wording and attributes the
|
|
8245
|
+
* source in this header rather than duplicating a license file, per the
|
|
8246
|
+
* repository's vendoring-attribution practice for small quoted excerpts.
|
|
8247
|
+
*
|
|
8248
|
+
* The Guide is READ-ONLY static content: it is not part of the live roster and
|
|
8249
|
+
* carries no business authority. A Custom declaration that reuses a shipped id
|
|
8250
|
+
* must never borrow an official Guide, so the lookup requires the caller's
|
|
8251
|
+
* ALREADY-DERIVED shipped classification instead of trusting the id alone.
|
|
8252
|
+
* @module tui/tsp/preset-guide-content
|
|
8253
|
+
*/
|
|
8254
|
+
/** The two Markdown sections the official Web dialog renders, in order. */
|
|
8255
|
+
const GUIDE_SECTION_HEADS = {
|
|
8256
|
+
modeDetails: "Mode details",
|
|
8257
|
+
howToUse: "How to use"
|
|
8258
|
+
};
|
|
8259
|
+
/** The four shipped presets' pinned official copy, keyed by shipped id. */
|
|
8260
|
+
const BUILT_IN_GUIDES = {
|
|
8261
|
+
standard: {
|
|
8262
|
+
intro: "Choose Standard mode when starting a new task. Describe what you want to accomplish, point to the relevant files, and explain how to check the result.",
|
|
8263
|
+
explanation: [
|
|
8264
|
+
"### How it works",
|
|
8265
|
+
"The agent calls tools directly to read and edit files, search, and run terminal commands. It includes Skills, planning, goals, subagents, workflows, and context compaction.",
|
|
8266
|
+
"### When to choose it",
|
|
8267
|
+
"Start here for everyday coding, file work, and research. Standard mode can also write scripts and process files in batches. PTC changes how tool calls are organized; it is not required for batch tasks."
|
|
8268
|
+
].join("\n\n"),
|
|
8269
|
+
usage: [
|
|
8270
|
+
"### Fix a bug",
|
|
8271
|
+
"> Find out why submitting the search form twice makes the results disappear. Fix it and run the relevant tests. Explain the cause and what changed.",
|
|
8272
|
+
"Expected output: a code change, the relevant test results, and an explanation of the cause.",
|
|
8273
|
+
"### Organize project notes",
|
|
8274
|
+
"> Read the Markdown notes in this project. Summarize the agreed decisions and open questions, with links to the source files.",
|
|
8275
|
+
"Expected output: a summary with references that you can check against the original notes."
|
|
8276
|
+
].join("\n\n")
|
|
8277
|
+
},
|
|
8278
|
+
ptc: {
|
|
8279
|
+
intro: "Choose PTC mode when starting a new task. Specify the input files, processing rules, and output format. The agent writes the code.",
|
|
8280
|
+
explanation: [
|
|
8281
|
+
"### How tools are called",
|
|
8282
|
+
"PTC means Programmatic Tool Calling. In this built-in preset, the agent uses run_code to write a TypeScript program that calls tools through a generated SDK. The program can use loops, conditions, error handling, and concurrent calls where appropriate.",
|
|
8283
|
+
"### What reaches the model",
|
|
8284
|
+
"Tool results first reach the program, which can filter and combine them. The model receives what the program prints or returns; image results are attached separately. Nested tool calls are still recorded and remain subject to tool permissions.",
|
|
8285
|
+
"### Compared with Standard mode",
|
|
8286
|
+
"Both modes can handle coding and batch tasks. Standard mode exposes individual tools directly; PTC organizes tool calls in code. The current PTC preset leaves the workflow tool disabled. Speed and token use depend on the task and how the program handles its results."
|
|
8287
|
+
].join("\n\n"),
|
|
8288
|
+
usage: [
|
|
8289
|
+
"### Check a set of configuration files",
|
|
8290
|
+
"> Check all JSON files in configs/. List missing required fields and invalid values against schema.json. Save a CSV with one row per issue. Include unreadable files in the report and keep checking the rest. Leave the original files unchanged.",
|
|
8291
|
+
"Expected output: an issue summary and a CSV report. The program can repeat the same checks, handle individual failures, and collect the results.",
|
|
8292
|
+
"### Summarize error logs",
|
|
8293
|
+
"> Analyze the log files in logs/. Group errors by service and error type. Show the ten most frequent groups and one example from each. Save the full counts to a CSV.",
|
|
8294
|
+
"Expected output: the top error groups and a complete count table. Intermediate data can be aggregated in the program before the summary reaches the model."
|
|
8295
|
+
].join("\n\n")
|
|
8296
|
+
},
|
|
8297
|
+
minimal: {
|
|
8298
|
+
intro: "Choose Minimal mode for a new task. For a comparison, hold the model, permissions, input, and starting workspace state constant across runs.",
|
|
8299
|
+
explanation: [
|
|
8300
|
+
"### What is included",
|
|
8301
|
+
"One persistent shell tool and a fixed system prompt. The built-in preset does not load Skills, planning, context compaction, or the standard runtime context.",
|
|
8302
|
+
"### When to choose it",
|
|
8303
|
+
"Use it as a baseline for experiments and comparisons. It can still read files and execute scripts through shell commands, but offers fewer built-in ways to manage a long task. Fewer tools does not necessarily make it easier for a beginner."
|
|
8304
|
+
].join("\n\n"),
|
|
8305
|
+
usage: [
|
|
8306
|
+
"### Compare performance on a small bug fix",
|
|
8307
|
+
"> Run the tests for this project, find the cause of the failure, and make the smallest fix. Run the relevant tests again and report the result.",
|
|
8308
|
+
"Run the same task separately in Standard and Minimal modes from the same starting state. Compare task completion, tool calls, and the resulting changes. Minimal mode performs the work through terminal commands."
|
|
8309
|
+
].join("\n\n")
|
|
8310
|
+
},
|
|
8311
|
+
cordis: {
|
|
8312
|
+
intro: "Choose Creator mode for a new task. Describe the capability you want, where it should appear, and how you will verify it.",
|
|
8313
|
+
explanation: [
|
|
8314
|
+
"### What you can create",
|
|
8315
|
+
"Creator mode includes the standard task tools plus runtime inspection, persistent plugin management, and guidance for authoring Cordis plugins and agent presets. It can create a plugin that adds a capability or UI, or a preset that combines tools and prompts for a particular job.",
|
|
8316
|
+
"### Plugins and modes",
|
|
8317
|
+
"A plugin adds capabilities to DSH, such as a tool, a service connection, or a UI entry. A mode is an agent preset that selects tools and defines how the agent works in a task. A plugin can be included in a custom preset.",
|
|
8318
|
+
"### How the result takes effect",
|
|
8319
|
+
"Ask the agent to install and verify the result, not just generate source code. A plugin may load immediately or require a restart, depending on what it changes. A newly created preset is selected when starting a new task."
|
|
8320
|
+
].join("\n\n"),
|
|
8321
|
+
usage: [
|
|
8322
|
+
"### Add a UI",
|
|
8323
|
+
"> Create a DSH plugin that adds a project notes entry to the sidebar. Let me browse the Markdown files in this workspace and preview a selected note. Install it and verify that the page opens.",
|
|
8324
|
+
"Expected output: an installed plugin with a working entry and preview page, plus any remaining activation steps.",
|
|
8325
|
+
"### Add a tool",
|
|
8326
|
+
"> Create a plugin with a tool that reads this project’s test report and summarizes the failed tests. Register it and verify it with a sample report.",
|
|
8327
|
+
"Expected output: a plugin with a callable tool and a verified sample call.",
|
|
8328
|
+
"### Create my own mode",
|
|
8329
|
+
"> Create a “Code review” mode based on Standard mode. Have it prioritize potential bugs and test gaps, cite file paths and lines, and ask before modifying files. Save it as a selectable preset.",
|
|
8330
|
+
"Expected output: a custom preset for new tasks. These review instructions guide the agent; permission settings determine which actions it can execute."
|
|
8331
|
+
].join("\n\n")
|
|
8332
|
+
}
|
|
8333
|
+
};
|
|
8334
|
+
/**
|
|
8335
|
+
* The complete read-only Markdown body of one shipped preset's Mode guide: the
|
|
8336
|
+
* two official sections the Web dialog shows, rendered as ONE continuous
|
|
8337
|
+
* scrolling body instead of behind a second layer of tabs or a modal.
|
|
8338
|
+
*/
|
|
8339
|
+
function copyMarkdown(copy) {
|
|
8340
|
+
return [
|
|
8341
|
+
`## ${GUIDE_SECTION_HEADS.modeDetails}`,
|
|
8342
|
+
copy.intro,
|
|
8343
|
+
copy.explanation,
|
|
8344
|
+
`## ${GUIDE_SECTION_HEADS.howToUse}`,
|
|
8345
|
+
copy.usage
|
|
8346
|
+
].join("\n\n");
|
|
8347
|
+
}
|
|
8348
|
+
/**
|
|
8349
|
+
* The official Mode guide of one row, or `undefined` when the row must not have
|
|
8350
|
+
* one.
|
|
8351
|
+
*
|
|
8352
|
+
* `builtIn` is the row's ALREADY-DERIVED shipped classification — the value
|
|
8353
|
+
* `isBuiltInPresetRow` produced from the raw roster DTO. It is checked FIRST and
|
|
8354
|
+
* on its own: the shipped-id table is consulted only for a row the official
|
|
8355
|
+
* classification really calls shipped, so a user declaration that happens to
|
|
8356
|
+
* reuse `standard`/`ptc`/`minimal`/`cordis` (and therefore publishes its own
|
|
8357
|
+
* `name`) keeps its own copy and never inherits an official Guide.
|
|
8358
|
+
*/
|
|
8359
|
+
function builtInGuide(row) {
|
|
8360
|
+
if (!row.builtIn) return void 0;
|
|
8361
|
+
const copy = BUILT_IN_GUIDES[row.id];
|
|
8362
|
+
return copy === void 0 ? void 0 : copyMarkdown(copy);
|
|
8363
|
+
}
|
|
8364
|
+
//#endregion
|
|
8098
8365
|
//#region src/tui/pickers/preset-display.ts
|
|
8099
8366
|
/** The shipped-preset display copy, shared by every preset picker surface.
|
|
8100
8367
|
*
|
|
@@ -8334,19 +8601,25 @@ const QUEUE_CHORDS = {
|
|
|
8334
8601
|
}
|
|
8335
8602
|
};
|
|
8336
8603
|
/**
|
|
8337
|
-
* The Session Workspace
|
|
8604
|
+
* The Session Workspace's FIXED local chords (PR2 tree cycle, PR3 Inspect).
|
|
8338
8605
|
*
|
|
8339
8606
|
* The fullscreen PiTUI tree is a per-surface COMPONENT contract, not a Host
|
|
8340
|
-
* command: Tab/Shift+Tab step between Workspace Folder titles and
|
|
8341
|
-
*
|
|
8342
|
-
* key-label authority means a footer
|
|
8343
|
-
* into two authorities — the same
|
|
8344
|
-
* fixed chords.
|
|
8345
|
-
*/
|
|
8346
|
-
const SESSION_WORKSPACE_CHORDS = {
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8607
|
+
* command: Tab/Shift+Tab step between Workspace Folder titles and F2 opens the
|
|
8608
|
+
* read-only Inspector, so none of them has a keymap action or remap. Keeping
|
|
8609
|
+
* the handler and painted label in this ONE key-label authority means a footer
|
|
8610
|
+
* hint and the admitted keys cannot drift into two authorities — the same
|
|
8611
|
+
* category as the History/Delivered-files fixed chords.
|
|
8612
|
+
*/
|
|
8613
|
+
const SESSION_WORKSPACE_CHORDS = {
|
|
8614
|
+
folderCycle: {
|
|
8615
|
+
keys: ["tab", "shift+tab"],
|
|
8616
|
+
label: "Tab/Shift+Tab"
|
|
8617
|
+
},
|
|
8618
|
+
inspect: {
|
|
8619
|
+
keys: ["f2"],
|
|
8620
|
+
label: "F2"
|
|
8621
|
+
}
|
|
8622
|
+
};
|
|
8350
8623
|
/** The display name of a bare (unmodified) key id. */
|
|
8351
8624
|
const BASE_KEY_LABELS = {
|
|
8352
8625
|
enter: "Enter",
|
|
@@ -8378,7 +8651,7 @@ function formatKeyId(key) {
|
|
|
8378
8651
|
else if (part === "shift") mods.push("Shift");
|
|
8379
8652
|
else if (part === "super") mods.push("Super");
|
|
8380
8653
|
else base = part;
|
|
8381
|
-
const baseLabel = BASE_KEY_LABELS[base] ?? (base.length === 1 ? base.toUpperCase() : base);
|
|
8654
|
+
const baseLabel = BASE_KEY_LABELS[base] ?? (base.length === 1 || /^f\d+$/u.test(base) ? base.toUpperCase() : base);
|
|
8382
8655
|
return [...mods, baseLabel].join("+");
|
|
8383
8656
|
}
|
|
8384
8657
|
/** Format a `<leader>X` sequence label (`<leader>t` → `Leader T`). */
|
|
@@ -8430,11 +8703,19 @@ const TSP_VISUAL_COPY_LABEL = formatKeyId(TSP_VISUAL_CHORDS.copy);
|
|
|
8430
8703
|
const JOB_LOCAL_KEYS = {
|
|
8431
8704
|
/** Switch between the Output and Command pages, in both directions. */
|
|
8432
8705
|
switchPage: "tab",
|
|
8706
|
+
/** Toggle the Output page's adaptive multi-line Command preview. */
|
|
8707
|
+
togglePreview: "f2",
|
|
8433
8708
|
/** Copy the current page's exact original. A BARE letter — the same key the
|
|
8434
8709
|
* Settings workspace's copy uses and the one the `[C]` affordance badges name —
|
|
8435
8710
|
* so the bar hint reads `c copy …` and badge and key agree (§4.1, §7.1). */
|
|
8436
8711
|
copy: "c"
|
|
8437
8712
|
};
|
|
8713
|
+
/** Fixed Job Find search-row keys (owned here so panels never hard-code chords). */
|
|
8714
|
+
const JOB_SEARCH_LOCAL_KEYS = {
|
|
8715
|
+
commit: "enter",
|
|
8716
|
+
next: "n",
|
|
8717
|
+
prev: "shift+n"
|
|
8718
|
+
};
|
|
8438
8719
|
/**
|
|
8439
8720
|
* The SVG Viewer's FIXED screen-local chords (PR2.5).
|
|
8440
8721
|
*
|
|
@@ -9927,97 +10208,95 @@ function renderWelcomeWhaleLines(variant) {
|
|
|
9927
10208
|
const colors = WELCOME_WHALE_COLORS;
|
|
9928
10209
|
return welcomeWhalePlainLines(variant).map((line, index) => hexPaint(colors[Math.min(index, colors.length - 1)], line));
|
|
9929
10210
|
}
|
|
9930
|
-
/** Strip the `session-`/`session_` prefix and keep the first 8 characters, like
|
|
9931
|
-
* the kimicode card's short id. */
|
|
9932
|
-
function shortSessionId(id) {
|
|
9933
|
-
return id.replace(/^session[-_]/i, "").slice(0, 8);
|
|
9934
|
-
}
|
|
9935
|
-
/** A canonical full Session id: the `session-`/`session_` prefix plus 32 hex
|
|
9936
|
-
* characters, optionally written as a hyphenated canonical UUID. A BARE UUID
|
|
9937
|
-
* is NOT a canonical Session id — it must match an official listed row. */
|
|
9938
|
-
const CANONICAL_SESSION_ID = /^session[-_](?:[0-9a-f]{32}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
9939
|
-
/** The CLI automatic-prefix rule: at least four ASCII hex digits after the
|
|
9940
|
-
* optional `session-`/`session_` prefix. Deliberately stricter than the
|
|
9941
|
-
* `/resume` matcher; the CLI must not auto-resume a word-like query. */
|
|
9942
|
-
const CLI_PREFIX = /^[0-9a-f]{4,}$/i;
|
|
9943
|
-
/** Whether `query` is a canonical full Session id that may be opened WITHOUT
|
|
9944
|
-
* a roster read (the explicit full-id launch contract). */
|
|
9945
|
-
function canonicalFullSessionId(query) {
|
|
9946
|
-
return CANONICAL_SESSION_ID.test(query);
|
|
9947
|
-
}
|
|
9948
|
-
/** The legal automatic prefix `query` carries, or undefined. The returned
|
|
9949
|
-
* value is the bare hex prefix (the leading Session prefix stripped). */
|
|
9950
|
-
function cliAutoPrefix(query) {
|
|
9951
|
-
const bare = query.replace(/^session[-_]/i, "");
|
|
9952
|
-
return CLI_PREFIX.test(bare) ? bare : void 0;
|
|
9953
|
-
}
|
|
9954
|
-
/**
|
|
9955
|
-
* Resolve one session row for a typed resume query. A full id wins over the
|
|
9956
|
-
* row order; otherwise only a UNIQUE non-empty prefix (the `session-` form or
|
|
9957
|
-
* the short id) is resolved. An ambiguous or missing prefix returns undefined
|
|
9958
|
-
* so the read owner seeds the same global Browser search instead of guessing.
|
|
9959
|
-
* @param rows - the listed main-session rows (never re-filtered here).
|
|
9960
|
-
* @param query - the resume query.
|
|
9961
|
-
* @returns the matching row, or undefined.
|
|
9962
|
-
*/
|
|
9963
|
-
function findSessionMatch(rows, query) {
|
|
9964
|
-
const exact = rows.find((row) => row.id === query);
|
|
9965
|
-
if (exact !== void 0) return exact;
|
|
9966
|
-
const bare = query.replace(/^session[-_]/i, "");
|
|
9967
|
-
if (bare === "") return void 0;
|
|
9968
|
-
let candidate;
|
|
9969
|
-
for (const row of rows) {
|
|
9970
|
-
if (!row.id.replace(/^session[-_]/i, "").startsWith(bare) && !shortSessionId(row.id).startsWith(bare)) continue;
|
|
9971
|
-
if (candidate !== void 0) return void 0;
|
|
9972
|
-
candidate = row;
|
|
9973
|
-
}
|
|
9974
|
-
return candidate;
|
|
9975
|
-
}
|
|
9976
|
-
/**
|
|
9977
|
-
* Resolve one CLI `--session` value before the Browser mounts: an exact
|
|
9978
|
-
* official row id first (including historical non-standard ids), then — only
|
|
9979
|
-
* for a legal CLI automatic prefix — the SAME unique-prefix primitive
|
|
9980
|
-
* `/resume` uses. An ambiguous, missing or word-like query returns undefined
|
|
9981
|
-
* so the startup Browser keeps it as one global search instead of guessing.
|
|
9982
|
-
* A subagent child is never an automatic main-Session selection.
|
|
9983
|
-
*/
|
|
9984
|
-
function chooseListedSession(rows, query) {
|
|
9985
|
-
if (query === "" || /^session[-_]$/i.test(query)) return void 0;
|
|
9986
|
-
const exact = rows.find((row) => row.id === query);
|
|
9987
|
-
if (exact !== void 0) return exact;
|
|
9988
|
-
if (cliAutoPrefix(query) === void 0) return void 0;
|
|
9989
|
-
return findSessionMatch(rows.filter((row) => row.origin !== "subagent"), query);
|
|
9990
|
-
}
|
|
9991
|
-
/** Canonicalize one user query for both metadata matching and Host search. */
|
|
9992
|
-
function sanitizeSessionSearchInput(value) {
|
|
9993
|
-
const trimmed = value.replace(/\0/g, "").trim();
|
|
9994
|
-
if (trimmed.length <= 500) return trimmed;
|
|
9995
|
-
const truncated = trimmed.slice(0, 500);
|
|
9996
|
-
const last = truncated.charCodeAt(499);
|
|
9997
|
-
return last >= 55296 && last <= 56319 ? truncated.slice(0, 499) : truncated;
|
|
9998
|
-
}
|
|
9999
|
-
/** Metadata-only membership; content membership belongs to SessionReader.search(). */
|
|
10000
|
-
function sessionRowMatchesQuery(row, query) {
|
|
10001
|
-
const needle = query.toLowerCase();
|
|
10002
|
-
return row.id.toLowerCase().includes(needle) || (row.title ?? "").toLowerCase().includes(needle) || (row.cwd ?? "").toLowerCase().includes(needle) || (row.preset ?? "").toLowerCase().includes(needle) || (row.workspace?.title ?? "").toLowerCase().includes(needle) || (row.workspace?.path ?? "").toLowerCase().includes(needle);
|
|
10003
|
-
}
|
|
10004
10211
|
//#endregion
|
|
10005
|
-
//#region src/
|
|
10006
|
-
/**
|
|
10007
|
-
*
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10212
|
+
//#region src/app/command/session-browser-presentation.ts
|
|
10213
|
+
/** Whether the Client-root eligibility proves THIS Client may answer the
|
|
10214
|
+
* pending candidate the Host reported for `sessionId`. */
|
|
10215
|
+
function classifyLiveEligibility(sessionId, eligibility) {
|
|
10216
|
+
const live = eligibility?.filter((entry) => entry.live && entry.sessionId === sessionId) ?? [];
|
|
10217
|
+
if (live.some((entry) => entry.kind === "approval")) return {
|
|
10218
|
+
pending: "approval",
|
|
10219
|
+
answerable: true
|
|
10220
|
+
};
|
|
10221
|
+
const questions = live.filter((entry) => entry.kind === "question");
|
|
10222
|
+
if (questions.length === 0) return {
|
|
10223
|
+
pending: "unknown",
|
|
10224
|
+
answerable: false
|
|
10225
|
+
};
|
|
10226
|
+
return {
|
|
10227
|
+
pending: questions.every((entry) => entry.subtype === "plan-review") ? "plan-review" : "question",
|
|
10228
|
+
answerable: true
|
|
10229
|
+
};
|
|
10230
|
+
}
|
|
10231
|
+
function classifyPending(activity, eligibility) {
|
|
10232
|
+
if (activity === void 0) return {
|
|
10233
|
+
pending: "unknown",
|
|
10234
|
+
answerable: false
|
|
10235
|
+
};
|
|
10236
|
+
const { attention, attentionSourceState, continuedQuestionCallIds } = activity;
|
|
10237
|
+
if (attentionSourceState === "known" && (attention === "question" || attention === "plan-review") && (continuedQuestionCallIds?.length ?? 0) > 0 && eligibility !== void 0) return {
|
|
10238
|
+
pending: "late-answer",
|
|
10239
|
+
answerable: true
|
|
10240
|
+
};
|
|
10241
|
+
if (attention === "none") return {
|
|
10242
|
+
pending: attentionSourceState === "known" ? "none" : attentionSourceState,
|
|
10243
|
+
answerable: false
|
|
10244
|
+
};
|
|
10245
|
+
if (attention === "unknown") return {
|
|
10246
|
+
pending: attentionSourceState === "known" ? "unknown" : attentionSourceState,
|
|
10247
|
+
answerable: false
|
|
10248
|
+
};
|
|
10249
|
+
return {
|
|
10250
|
+
pending: "unverified",
|
|
10251
|
+
answerable: false
|
|
10252
|
+
};
|
|
10253
|
+
}
|
|
10254
|
+
/** The ONE pure Session Browser admission/classification policy.
|
|
10255
|
+
*
|
|
10256
|
+
* `activity` must be the exact accepted sample for this row and roster
|
|
10257
|
+
* revision. Search deliberately does not use Activity: every known blank is
|
|
10258
|
+
* excluded from an ordinary query, while Browse retains a proved Needs/Working
|
|
10259
|
+
* row as a real active-session exception. */
|
|
10260
|
+
function classifySessionBrowserRow(row, activity, eligibility, status) {
|
|
10261
|
+
const exactActivity = activity?.sessionId === row.id ? activity : void 0;
|
|
10262
|
+
const exactStatus = status?.sessionId === row.id ? status : void 0;
|
|
10263
|
+
const live = classifyLiveEligibility(row.id, eligibility);
|
|
10264
|
+
const derived = classifyPending(exactActivity, eligibility);
|
|
10265
|
+
const pending = live.answerable ? live.pending : derived.pending;
|
|
10266
|
+
const answerable = live.answerable || derived.answerable;
|
|
10267
|
+
const childRunning = exactActivity?.runningChildren;
|
|
10268
|
+
const completionUnread = exactStatus?.completionUnread === true;
|
|
10269
|
+
const working = exactActivity?.running === true || (childRunning ?? 0) > 0;
|
|
10270
|
+
const normal = row.origin !== "subagent";
|
|
10271
|
+
return {
|
|
10272
|
+
priority: answerable ? "needs" : working ? "working" : completionUnread ? "unread" : "recent",
|
|
10273
|
+
pending,
|
|
10274
|
+
running: exactActivity?.running,
|
|
10275
|
+
childRunning,
|
|
10276
|
+
completionUnread,
|
|
10277
|
+
answerable,
|
|
10278
|
+
source: exactActivity?.attentionSourceState ?? "unknown",
|
|
10279
|
+
browseEligible: normal && (row.blank !== true || answerable || working),
|
|
10280
|
+
searchEligible: normal && row.blank !== true
|
|
10281
|
+
};
|
|
10282
|
+
}
|
|
10283
|
+
//#endregion
|
|
10284
|
+
//#region src/tui/pickers/sessions.ts
|
|
10285
|
+
/**
|
|
10286
|
+
* Session-picker support for `/sessions`: pure row assembly and
|
|
10287
|
+
* presentation. The row model mirrors the kimicode web session rail — a
|
|
10288
|
+
* short id, a relative age, an optional title, and a workspace group —
|
|
10289
|
+
* rendered as one line per session in the TUI picker.
|
|
10290
|
+
*
|
|
10291
|
+
* This module is PURE presentation: it never touches `$DSH_HOME`, never
|
|
10292
|
+
* stats or reads session logs, and never folds a title — Host-owned session
|
|
10293
|
+
* derived state (titles, presets) arrives through the `SessionReader`
|
|
10294
|
+
* projection port (`src/runtime/session-reader-port.ts`); the Direct
|
|
10295
|
+
* adapter in `src/runtime/direct/` owns the official DSH projection,
|
|
10296
|
+
* cache, and observation semantics.
|
|
10297
|
+
* @module @xmoon76/dsh-pi-tui/tui/pickers/sessions
|
|
10298
|
+
*/
|
|
10299
|
+
/** kimicode-style workspace key: the last two path segments, or a placeholder.
|
|
10021
10300
|
* The cwd is a Host/persistence boundary value — the group header is
|
|
10022
10301
|
* rendered straight to the terminal, so the output is sanitized here (the
|
|
10023
10302
|
* single group-derivation point covers the browse AND search views). */
|
|
@@ -10058,8 +10337,7 @@ function sanitizeTerminalText(value) {
|
|
|
10058
10337
|
function sessionBrowserErrorNotice(kind, message) {
|
|
10059
10338
|
const safe = sanitizeTerminalText(message).replace(/\s+\(raw log: .*\)$/u, "");
|
|
10060
10339
|
const unknownEvent = /contains event type "([^"]+)"/u.exec(safe)?.[1];
|
|
10061
|
-
|
|
10062
|
-
return truncateToWidth(text, 40, "…");
|
|
10340
|
+
return unknownEvent === void 0 ? `${kind === "search" ? "Search failed" : "Session details unavailable"}: ${safe}` : `unknown event ${unknownEvent}`;
|
|
10063
10341
|
}
|
|
10064
10342
|
//#endregion
|
|
10065
10343
|
//#region src/tui/icons.ts
|
|
@@ -12178,11 +12456,34 @@ function subagentJobViewHint(status, detail) {
|
|
|
12178
12456
|
}
|
|
12179
12457
|
//#endregion
|
|
12180
12458
|
//#region src/tui/presentation/session-workspace-view.ts
|
|
12459
|
+
/**
|
|
12460
|
+
* M5-U-D — the ONE pure projection of the fullscreen PiTUI Session Workspace.
|
|
12461
|
+
*
|
|
12462
|
+
* This module is UI-only: it imports no backend, adapter, Agent or transport,
|
|
12463
|
+
* performs no IO and holds no state. It answers three questions for the ONE
|
|
12464
|
+
* panel that paints them, from facts the panel already received:
|
|
12465
|
+
*
|
|
12466
|
+
* 1. which single group each listed main Session belongs to
|
|
12467
|
+
* (`Needs attention` → `Working` → `Recent`),
|
|
12468
|
+
* 2. which Sessions the current Workspace scope really lists,
|
|
12469
|
+
* 3. what the header may truthfully say about attention OUTSIDE that scope.
|
|
12470
|
+
*
|
|
12471
|
+
* Authority chain (all read-only, all already sampled by their owner):
|
|
12472
|
+
* `SessionReader.list()` is the ONLY roster; `SessionWorkspaceFactsPort.
|
|
12473
|
+
* readActivity()` is the ONLY activity sample; the Client-root forwarded
|
|
12474
|
+
* answer eligibility (G567) is the ONLY positive answerability proof. A reader
|
|
12475
|
+
* `attention` value alone is NEVER the permission to answer, so a pending
|
|
12476
|
+
* candidate this Client cannot prove it can answer is `unverified` — never a
|
|
12477
|
+
* Needs row and never a fabricated `No pending`.
|
|
12478
|
+
*
|
|
12479
|
+
* @module @xmoon76/dsh-pi-tui/tui/presentation/session-workspace-view
|
|
12480
|
+
*/
|
|
12181
12481
|
/** The ONE verbose pending wording shared by Peek/Details. */
|
|
12182
12482
|
const SESSION_PENDING_LABEL = {
|
|
12183
12483
|
question: "Question",
|
|
12184
12484
|
approval: "Approval",
|
|
12185
12485
|
"plan-review": "Plan review",
|
|
12486
|
+
"late-answer": "Late answer",
|
|
12186
12487
|
none: "No pending",
|
|
12187
12488
|
unknown: "Pending unknown",
|
|
12188
12489
|
unavailable: "Pending unavailable",
|
|
@@ -12196,13 +12497,23 @@ const SESSION_SOURCE_LABEL = {
|
|
|
12196
12497
|
unavailable: "unavailable",
|
|
12197
12498
|
denied: "denied"
|
|
12198
12499
|
};
|
|
12199
|
-
/** The ONE
|
|
12500
|
+
/** The ONE verbose row status wording shared by Peek/Details and the panels. */
|
|
12200
12501
|
function workspaceRowStatusLabel(fact) {
|
|
12201
|
-
if (fact.priority === "needs")
|
|
12202
|
-
|
|
12502
|
+
if (fact.priority === "needs") {
|
|
12503
|
+
const base = `Needs attention · ${SESSION_PENDING_LABEL[fact.pending]}`;
|
|
12504
|
+
return fact.running === true || (fact.childRunning ?? 0) > 0 ? `${base} · ${workspaceWorkingLabel(fact)}` : base;
|
|
12505
|
+
}
|
|
12506
|
+
if (fact.priority === "working") return workspaceWorkingLabel(fact);
|
|
12507
|
+
if (fact.priority === "unread") return "Completed · unread";
|
|
12203
12508
|
if (fact.pending === "unverified") return "Pending · not actionable here";
|
|
12204
12509
|
return "";
|
|
12205
12510
|
}
|
|
12511
|
+
/** The ONE compact working wording: `0` is never printed as a positive fact. */
|
|
12512
|
+
function workspaceWorkingLabel(fact) {
|
|
12513
|
+
const count = fact.childRunning;
|
|
12514
|
+
if (count === void 0 || count <= 0) return "Working";
|
|
12515
|
+
return `Working · ${count} running ${count === 1 ? "child" : "children"}`;
|
|
12516
|
+
}
|
|
12206
12517
|
/** Display title collisions by the shortest unique Host path tail. The ID is a
|
|
12207
12518
|
* final fallback only when Host paths themselves remain indistinguishable. */
|
|
12208
12519
|
function workspaceDisplayLabels(workspaces) {
|
|
@@ -12269,9 +12580,10 @@ function visibleWorkspaceBrowserRows(model, display, selectedSessionId, currentS
|
|
|
12269
12580
|
const facts = group.ids.map((id) => model.rowsById.get(id));
|
|
12270
12581
|
const needs = facts.filter((fact) => fact.priority === "needs").length;
|
|
12271
12582
|
const working = facts.filter((fact) => fact.priority === "working").length;
|
|
12583
|
+
const unread = facts.filter((fact) => fact.priority === "unread").length;
|
|
12272
12584
|
const current = group.workspaceId === model.currentWorkspaceId;
|
|
12273
12585
|
const next = group.workspaceId === model.nextCreateWorkspaceId;
|
|
12274
|
-
const defaultExpanded = current || next || needs + working > 0;
|
|
12586
|
+
const defaultExpanded = current || next || needs + working + unread > 0;
|
|
12275
12587
|
const expanded = display.expanded.get(group.workspaceId) ?? defaultExpanded;
|
|
12276
12588
|
const groupRows = [];
|
|
12277
12589
|
rows.push({
|
|
@@ -12283,6 +12595,7 @@ function visibleWorkspaceBrowserRows(model, display, selectedSessionId, currentS
|
|
|
12283
12595
|
total: group.ids.length,
|
|
12284
12596
|
needs,
|
|
12285
12597
|
working,
|
|
12598
|
+
unread,
|
|
12286
12599
|
expanded,
|
|
12287
12600
|
current,
|
|
12288
12601
|
next
|
|
@@ -12343,41 +12656,13 @@ function inScope(fact, scope, currentWorkspaceId, baselineProven) {
|
|
|
12343
12656
|
case "unassigned": return baselineProven && fact.membership.kind === "unassigned";
|
|
12344
12657
|
}
|
|
12345
12658
|
}
|
|
12346
|
-
/** Whether the Client-root eligibility proves THIS Client may answer the
|
|
12347
|
-
* pending candidate the Host reported for `sessionId`. */
|
|
12348
|
-
function provedAnswerable(fact, eligibility) {
|
|
12349
|
-
if (fact.attentionSourceState !== "known") return false;
|
|
12350
|
-
if (fact.attention === "approval") return eligibility?.some((entry) => entry.sessionId === fact.sessionId && entry.kind === "approval") === true;
|
|
12351
|
-
if (fact.attention !== "question" && fact.attention !== "plan-review") return false;
|
|
12352
|
-
if (eligibility?.some((entry) => entry.sessionId === fact.sessionId && entry.kind === "question") === true) return true;
|
|
12353
|
-
return eligibility !== void 0 && (fact.continuedQuestionCallIds?.length ?? 0) > 0;
|
|
12354
|
-
}
|
|
12355
|
-
function classifyPending(activity, eligibility) {
|
|
12356
|
-
if (activity === void 0) return {
|
|
12357
|
-
pending: "unknown",
|
|
12358
|
-
answerable: false
|
|
12359
|
-
};
|
|
12360
|
-
const { attention, attentionSourceState } = activity;
|
|
12361
|
-
if (attention === "none") return {
|
|
12362
|
-
pending: attentionSourceState === "known" ? "none" : attentionSourceState,
|
|
12363
|
-
answerable: false
|
|
12364
|
-
};
|
|
12365
|
-
if (attention === "unknown") return {
|
|
12366
|
-
pending: attentionSourceState === "known" ? "unknown" : attentionSourceState,
|
|
12367
|
-
answerable: false
|
|
12368
|
-
};
|
|
12369
|
-
const answerable = provedAnswerable(activity, eligibility);
|
|
12370
|
-
return {
|
|
12371
|
-
pending: answerable ? attention : "unverified",
|
|
12372
|
-
answerable
|
|
12373
|
-
};
|
|
12374
|
-
}
|
|
12375
12659
|
/** Build the ONE view of one frame. Every input is an official fact or the
|
|
12376
12660
|
* previous pure ordering; nothing here reads, writes or invents a Session. */
|
|
12377
12661
|
function buildSessionWorkspaceView(input) {
|
|
12378
12662
|
const roster = input.rows.filter((row) => row.origin !== "subagent");
|
|
12379
12663
|
const activityById = /* @__PURE__ */ new Map();
|
|
12380
12664
|
for (const activity of input.activity ?? []) activityById.set(activity.sessionId, activity);
|
|
12665
|
+
const statusById = input.status;
|
|
12381
12666
|
const currentWorkspaceId = currentWorkspaceOf(input.workspaces, input.currentSessionId);
|
|
12382
12667
|
const rosterIndex = /* @__PURE__ */ new Map();
|
|
12383
12668
|
roster.forEach((row, index) => {
|
|
@@ -12389,17 +12674,31 @@ function buildSessionWorkspaceView(input) {
|
|
|
12389
12674
|
});
|
|
12390
12675
|
const rowsById = /* @__PURE__ */ new Map();
|
|
12391
12676
|
const classified = [];
|
|
12677
|
+
/** Derived in the SAME classification pass, before the skip: a hidden quiet
|
|
12678
|
+
* current blank may only move its marker onto the existing New action of its
|
|
12679
|
+
* ONE proved official Workspace. It is never added back to the eligible
|
|
12680
|
+
* projection or the group ids. */
|
|
12681
|
+
let currentQuietBlankWorkspaceId;
|
|
12392
12682
|
for (const row of roster) {
|
|
12393
|
-
const
|
|
12394
|
-
|
|
12683
|
+
const classification = classifySessionBrowserRow(row, activityById.get(row.id), input.answerEligibility, statusById?.get(row.id));
|
|
12684
|
+
if (!classification.browseEligible) {
|
|
12685
|
+
if (row.id === input.currentSessionId && row.blank === true && input.workspaceBaselineProven) {
|
|
12686
|
+
const membership = workspaceMembershipOf(input.workspaces, row.id, true);
|
|
12687
|
+
if (membership.kind === "assigned") currentQuietBlankWorkspaceId = membership.workspaceIds[0];
|
|
12688
|
+
}
|
|
12689
|
+
continue;
|
|
12690
|
+
}
|
|
12395
12691
|
const fact = {
|
|
12396
12692
|
sessionId: row.id,
|
|
12397
|
-
priority:
|
|
12398
|
-
group:
|
|
12399
|
-
pending,
|
|
12400
|
-
running:
|
|
12401
|
-
|
|
12402
|
-
|
|
12693
|
+
priority: classification.priority,
|
|
12694
|
+
group: classification.priority,
|
|
12695
|
+
pending: classification.pending,
|
|
12696
|
+
running: classification.running,
|
|
12697
|
+
childRunning: classification.childRunning,
|
|
12698
|
+
completionUnread: classification.completionUnread,
|
|
12699
|
+
isCurrent: row.id === input.currentSessionId,
|
|
12700
|
+
answerable: classification.answerable,
|
|
12701
|
+
source: classification.source,
|
|
12403
12702
|
membership: workspaceMembershipOf(input.workspaces, row.id, input.workspaceBaselineProven)
|
|
12404
12703
|
};
|
|
12405
12704
|
rowsById.set(row.id, fact);
|
|
@@ -12410,6 +12709,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12410
12709
|
const priority = [
|
|
12411
12710
|
"needs",
|
|
12412
12711
|
"working",
|
|
12712
|
+
"unread",
|
|
12413
12713
|
"recent"
|
|
12414
12714
|
];
|
|
12415
12715
|
const byPriority = priority.indexOf(left.priority) - priority.indexOf(right.priority);
|
|
@@ -12428,6 +12728,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12428
12728
|
for (const kind of [
|
|
12429
12729
|
"needs",
|
|
12430
12730
|
"working",
|
|
12731
|
+
"unread",
|
|
12431
12732
|
"recent"
|
|
12432
12733
|
]) {
|
|
12433
12734
|
const ids = scoped.filter((fact) => fact.priority === kind).sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12435,9 +12736,10 @@ function buildSessionWorkspaceView(input) {
|
|
|
12435
12736
|
groups.push({
|
|
12436
12737
|
kind,
|
|
12437
12738
|
workspaceId: kind,
|
|
12438
|
-
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : "Recent",
|
|
12739
|
+
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : kind === "unread" ? "Completed · unread" : "Recent",
|
|
12439
12740
|
path: "",
|
|
12440
|
-
ids
|
|
12741
|
+
ids,
|
|
12742
|
+
unread: kind === "unread" ? ids.length : 0
|
|
12441
12743
|
});
|
|
12442
12744
|
listIds.push(...ids);
|
|
12443
12745
|
}
|
|
@@ -12447,6 +12749,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12447
12749
|
rowsById,
|
|
12448
12750
|
outsideAttention: { kind: "none" },
|
|
12449
12751
|
currentWorkspaceId,
|
|
12752
|
+
currentQuietBlankWorkspaceId,
|
|
12450
12753
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12451
12754
|
workspaceBaselineProven: input.workspaceBaselineProven
|
|
12452
12755
|
};
|
|
@@ -12458,6 +12761,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12458
12761
|
for (const kind of [
|
|
12459
12762
|
"needs",
|
|
12460
12763
|
"working",
|
|
12764
|
+
"unread",
|
|
12461
12765
|
"recent"
|
|
12462
12766
|
]) {
|
|
12463
12767
|
const ids = scoped.filter((fact) => fact.priority === kind).sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12465,9 +12769,10 @@ function buildSessionWorkspaceView(input) {
|
|
|
12465
12769
|
legacyGroups.push({
|
|
12466
12770
|
kind,
|
|
12467
12771
|
workspaceId: kind,
|
|
12468
|
-
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : "Recent",
|
|
12772
|
+
title: kind === "needs" ? "Needs attention" : kind === "working" ? "Working" : kind === "unread" ? "Completed · unread" : "Recent",
|
|
12469
12773
|
path: "",
|
|
12470
|
-
ids
|
|
12774
|
+
ids,
|
|
12775
|
+
unread: kind === "unread" ? ids.length : 0
|
|
12471
12776
|
});
|
|
12472
12777
|
legacyListIds.push(...ids);
|
|
12473
12778
|
}
|
|
@@ -12477,6 +12782,7 @@ function buildSessionWorkspaceView(input) {
|
|
|
12477
12782
|
rowsById,
|
|
12478
12783
|
outsideAttention: { kind: "none" },
|
|
12479
12784
|
currentWorkspaceId,
|
|
12785
|
+
currentQuietBlankWorkspaceId,
|
|
12480
12786
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12481
12787
|
workspaceBaselineProven: false
|
|
12482
12788
|
};
|
|
@@ -12490,7 +12796,8 @@ function buildSessionWorkspaceView(input) {
|
|
|
12490
12796
|
workspaceId: workspace.workspaceId,
|
|
12491
12797
|
title: workspace.title,
|
|
12492
12798
|
path: workspace.path,
|
|
12493
|
-
ids
|
|
12799
|
+
ids,
|
|
12800
|
+
unread: ids.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12494
12801
|
});
|
|
12495
12802
|
}
|
|
12496
12803
|
const ambiguous = classified.filter((fact) => fact.membership.kind === "ambiguous").sort(orderOf).map((fact) => fact.sessionId);
|
|
@@ -12499,13 +12806,15 @@ function buildSessionWorkspaceView(input) {
|
|
|
12499
12806
|
workspaceId: "ambiguous",
|
|
12500
12807
|
title: "Membership ambiguous",
|
|
12501
12808
|
path: "",
|
|
12502
|
-
ids: ambiguous
|
|
12809
|
+
ids: ambiguous,
|
|
12810
|
+
unread: ambiguous.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12503
12811
|
});
|
|
12504
12812
|
if (unassigned.length > 0) groups.push({
|
|
12505
12813
|
workspaceId: "unassigned",
|
|
12506
12814
|
title: "Unassigned",
|
|
12507
12815
|
path: "",
|
|
12508
|
-
ids: unassigned
|
|
12816
|
+
ids: unassigned,
|
|
12817
|
+
unread: unassigned.filter((id) => rowsById.get(id)?.priority === "unread").length
|
|
12509
12818
|
});
|
|
12510
12819
|
const priorityWorkspaceId = currentWorkspaceId ?? input.nextCreateWorkspaceId;
|
|
12511
12820
|
if (priorityWorkspaceId !== void 0) {
|
|
@@ -12536,11 +12845,517 @@ function buildSessionWorkspaceView(input) {
|
|
|
12536
12845
|
rowsById,
|
|
12537
12846
|
outsideAttention,
|
|
12538
12847
|
currentWorkspaceId,
|
|
12848
|
+
currentQuietBlankWorkspaceId,
|
|
12539
12849
|
nextCreateWorkspaceId: input.nextCreateWorkspaceId,
|
|
12540
12850
|
workspaceBaselineProven: input.workspaceBaselineProven
|
|
12541
12851
|
};
|
|
12542
12852
|
}
|
|
12543
12853
|
//#endregion
|
|
12854
|
+
//#region src/tui/presentation/session-inspector-view.ts
|
|
12855
|
+
/** The display token for an absent optional value: unknown, never zero. */
|
|
12856
|
+
const MISSING = "—";
|
|
12857
|
+
/** One display duration with a real unit. This is presentation only: the raw
|
|
12858
|
+
* millisecond values stay the Inspector DTO's authority. */
|
|
12859
|
+
function formatInspectorDuration(ms) {
|
|
12860
|
+
if (!Number.isFinite(ms) || ms < 0) return MISSING;
|
|
12861
|
+
if (ms < 1e3) return `${Math.round(ms)}ms`;
|
|
12862
|
+
const totalSeconds = Math.floor(ms / 1e3);
|
|
12863
|
+
const seconds = totalSeconds % 60;
|
|
12864
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
12865
|
+
if (totalMinutes < 1) {
|
|
12866
|
+
const text = (ms / 1e3).toFixed(1);
|
|
12867
|
+
return `${text.endsWith(".0") ? text.slice(0, -2) : text}s`;
|
|
12868
|
+
}
|
|
12869
|
+
if (totalMinutes < 60) return `${totalMinutes}m${String(seconds).padStart(2, "0")}s`;
|
|
12870
|
+
const minutes = totalMinutes % 60;
|
|
12871
|
+
return `${Math.floor(totalMinutes / 60)}h${String(minutes).padStart(2, "0")}m${String(seconds).padStart(2, "0")}s`;
|
|
12872
|
+
}
|
|
12873
|
+
/** One display rate with a real unit; absent samples stay unknown. */
|
|
12874
|
+
function formatInspectorRate(tokensPerSec) {
|
|
12875
|
+
if (tokensPerSec === void 0 || !Number.isFinite(tokensPerSec)) return MISSING;
|
|
12876
|
+
const text = tokensPerSec.toFixed(1);
|
|
12877
|
+
return `${text.endsWith(".0") ? text.slice(0, -2) : text} tok/s`;
|
|
12878
|
+
}
|
|
12879
|
+
/** Context occupancy: approximate percentage and/or used/window, independently
|
|
12880
|
+
* missing. The percentage is never painted without a legal denominator. */
|
|
12881
|
+
function contextValue(data) {
|
|
12882
|
+
const context = data.context;
|
|
12883
|
+
if (context === void 0) return MISSING;
|
|
12884
|
+
const parts = [];
|
|
12885
|
+
if (context.percent !== void 0) parts.push(`≈${context.percent}%`);
|
|
12886
|
+
if (context.usedTokens !== void 0) parts.push(context.windowTokens === void 0 ? `${formatTokens(context.usedTokens)} tokens` : `${formatTokens(context.usedTokens)} / ${formatTokens(context.windowTokens)}`);
|
|
12887
|
+
else if (context.windowTokens !== void 0) parts.push(`window ${formatTokens(context.windowTokens)}`);
|
|
12888
|
+
return parts.length === 0 ? MISSING : parts.join(" · ");
|
|
12889
|
+
}
|
|
12890
|
+
/** One official membership label from the proven Workspace facts, never from a
|
|
12891
|
+
* cwd. Unknown/unassigned/ambiguous keep their own truthful words. */
|
|
12892
|
+
function membershipValue(fact, workspaces, baselineProven) {
|
|
12893
|
+
if (fact === void 0 || !baselineProven) return "Unknown";
|
|
12894
|
+
switch (fact.membership.kind) {
|
|
12895
|
+
case "unknown": return "Unknown";
|
|
12896
|
+
case "unassigned": return "Unassigned";
|
|
12897
|
+
case "ambiguous": return `Ambiguous (${fact.membership.workspaceIds.map(sanitizedPhysicalLine).join(", ")})`;
|
|
12898
|
+
case "assigned": return fact.membership.workspaceIds.map((id) => {
|
|
12899
|
+
const workspace = workspaces.find((candidate) => candidate.workspaceId === id);
|
|
12900
|
+
if (workspace === void 0) return sanitizedPhysicalLine(id);
|
|
12901
|
+
const title = sanitizedPhysicalLine(workspace.title);
|
|
12902
|
+
const path = sanitizedPhysicalLine(workspace.path);
|
|
12903
|
+
return path === "" ? title : `${title} · ${path}`;
|
|
12904
|
+
}).join(" · ");
|
|
12905
|
+
}
|
|
12906
|
+
}
|
|
12907
|
+
/** The positive identity/state facts of one Session row. Only proven facts are
|
|
12908
|
+
* painted; `ing`/`live`/`current` never imply one another. */
|
|
12909
|
+
function stateParts(row, fact, currentSessionId) {
|
|
12910
|
+
const parts = [];
|
|
12911
|
+
if (row.id === currentSessionId) parts.push("Current");
|
|
12912
|
+
parts.push(row.live ? "Live" : "Persisted");
|
|
12913
|
+
if (fact !== void 0) {
|
|
12914
|
+
const status = workspaceRowStatusLabel(fact);
|
|
12915
|
+
if (status === "Pending · not actionable here") parts.push("Pending unverified");
|
|
12916
|
+
else if (status !== "") parts.push(status);
|
|
12917
|
+
}
|
|
12918
|
+
if (row.formatStatus === "migration-required") parts.push("Migration required");
|
|
12919
|
+
return parts;
|
|
12920
|
+
}
|
|
12921
|
+
/** The official goal objective/phase, with legal null kept as 'No goal'. */
|
|
12922
|
+
function goalFacts(data) {
|
|
12923
|
+
const goal = data.goal;
|
|
12924
|
+
if (goal === void 0) return [{
|
|
12925
|
+
label: "Goal",
|
|
12926
|
+
value: "Unknown"
|
|
12927
|
+
}, {
|
|
12928
|
+
label: "Goal phase",
|
|
12929
|
+
value: MISSING
|
|
12930
|
+
}];
|
|
12931
|
+
if (goal === null) return [{
|
|
12932
|
+
label: "Goal",
|
|
12933
|
+
value: "No goal"
|
|
12934
|
+
}, {
|
|
12935
|
+
label: "Goal phase",
|
|
12936
|
+
value: MISSING
|
|
12937
|
+
}];
|
|
12938
|
+
return [{
|
|
12939
|
+
label: "Goal",
|
|
12940
|
+
value: sanitizedPhysicalLine(goal.objective)
|
|
12941
|
+
}, {
|
|
12942
|
+
label: "Goal phase",
|
|
12943
|
+
value: goal.phase
|
|
12944
|
+
}];
|
|
12945
|
+
}
|
|
12946
|
+
/** The official TODO status counts, preserving legal null and unknown. */
|
|
12947
|
+
function todoFacts(data) {
|
|
12948
|
+
const todos = data.todos;
|
|
12949
|
+
if (todos === void 0) return [
|
|
12950
|
+
{
|
|
12951
|
+
label: "Pending",
|
|
12952
|
+
value: "Unknown"
|
|
12953
|
+
},
|
|
12954
|
+
{
|
|
12955
|
+
label: "In progress",
|
|
12956
|
+
value: "Unknown"
|
|
12957
|
+
},
|
|
12958
|
+
{
|
|
12959
|
+
label: "Completed",
|
|
12960
|
+
value: "Unknown"
|
|
12961
|
+
}
|
|
12962
|
+
];
|
|
12963
|
+
if (todos === null) return [
|
|
12964
|
+
{
|
|
12965
|
+
label: "Pending",
|
|
12966
|
+
value: "No todo record"
|
|
12967
|
+
},
|
|
12968
|
+
{
|
|
12969
|
+
label: "In progress",
|
|
12970
|
+
value: MISSING
|
|
12971
|
+
},
|
|
12972
|
+
{
|
|
12973
|
+
label: "Completed",
|
|
12974
|
+
value: MISSING
|
|
12975
|
+
}
|
|
12976
|
+
];
|
|
12977
|
+
return [
|
|
12978
|
+
{
|
|
12979
|
+
label: "Pending",
|
|
12980
|
+
value: String(todos.pending)
|
|
12981
|
+
},
|
|
12982
|
+
{
|
|
12983
|
+
label: "In progress",
|
|
12984
|
+
value: String(todos.inProgress)
|
|
12985
|
+
},
|
|
12986
|
+
{
|
|
12987
|
+
label: "Completed",
|
|
12988
|
+
value: String(todos.completed)
|
|
12989
|
+
}
|
|
12990
|
+
];
|
|
12991
|
+
}
|
|
12992
|
+
/** The complete display groups, in reading order. Roster/Activity/Workspace/
|
|
12993
|
+
* Lineage facts stay available while the exact cut is loading or failed; only
|
|
12994
|
+
* the cut-owned values become unknown. */
|
|
12995
|
+
function inspectorGroups(input, data) {
|
|
12996
|
+
const row = input.row;
|
|
12997
|
+
const fact = input.fact;
|
|
12998
|
+
const model = data?.model;
|
|
12999
|
+
const modelValue = model === void 0 ? MISSING : `${sanitizedPhysicalLine(model.provider)}/${sanitizedPhysicalLine(model.model)}`;
|
|
13000
|
+
const rosterPreset = row.preset === void 0 ? "Unknown" : `${sanitizedPhysicalLine(row.preset)} (roster)`;
|
|
13001
|
+
return [
|
|
13002
|
+
{
|
|
13003
|
+
id: "session",
|
|
13004
|
+
head: "Whole session",
|
|
13005
|
+
facts: [
|
|
13006
|
+
{
|
|
13007
|
+
label: "Model",
|
|
13008
|
+
value: modelValue
|
|
13009
|
+
},
|
|
13010
|
+
{
|
|
13011
|
+
label: "Effort",
|
|
13012
|
+
value: model?.reasoningEffort === void 0 ? MISSING : sanitizedPhysicalLine(model.reasoningEffort)
|
|
13013
|
+
},
|
|
13014
|
+
{
|
|
13015
|
+
label: "Preset",
|
|
13016
|
+
value: data?.preset === void 0 ? rosterPreset : sanitizedPhysicalLine(data.preset)
|
|
13017
|
+
},
|
|
13018
|
+
{
|
|
13019
|
+
label: "Context",
|
|
13020
|
+
value: data === void 0 ? MISSING : contextValue(data)
|
|
13021
|
+
}
|
|
13022
|
+
]
|
|
13023
|
+
},
|
|
13024
|
+
{
|
|
13025
|
+
id: "activity",
|
|
13026
|
+
head: "Activity",
|
|
13027
|
+
facts: [
|
|
13028
|
+
{
|
|
13029
|
+
label: "Turns",
|
|
13030
|
+
value: data?.stats === void 0 ? MISSING : String(data.stats.turns)
|
|
13031
|
+
},
|
|
13032
|
+
{
|
|
13033
|
+
label: "Steps",
|
|
13034
|
+
value: data?.stats === void 0 ? MISSING : String(data.stats.steps)
|
|
13035
|
+
},
|
|
13036
|
+
{
|
|
13037
|
+
label: "Running",
|
|
13038
|
+
value: fact?.running === true ? "Yes" : fact?.running === false ? "No" : "Unknown"
|
|
13039
|
+
},
|
|
13040
|
+
{
|
|
13041
|
+
label: "Pending",
|
|
13042
|
+
value: fact === void 0 ? "Unknown" : SESSION_PENDING_LABEL[fact.pending]
|
|
13043
|
+
},
|
|
13044
|
+
{
|
|
13045
|
+
label: "Source",
|
|
13046
|
+
value: fact === void 0 ? "unknown" : SESSION_SOURCE_LABEL[fact.source]
|
|
13047
|
+
}
|
|
13048
|
+
]
|
|
13049
|
+
},
|
|
13050
|
+
{
|
|
13051
|
+
id: "usage",
|
|
13052
|
+
head: "Token usage",
|
|
13053
|
+
facts: data?.usage === void 0 ? [
|
|
13054
|
+
{
|
|
13055
|
+
label: "Uncached input",
|
|
13056
|
+
value: MISSING
|
|
13057
|
+
},
|
|
13058
|
+
{
|
|
13059
|
+
label: "Output",
|
|
13060
|
+
value: MISSING
|
|
13061
|
+
},
|
|
13062
|
+
{
|
|
13063
|
+
label: "Cache read",
|
|
13064
|
+
value: MISSING
|
|
13065
|
+
},
|
|
13066
|
+
{
|
|
13067
|
+
label: "Cache write",
|
|
13068
|
+
value: MISSING
|
|
13069
|
+
},
|
|
13070
|
+
{
|
|
13071
|
+
label: "Total",
|
|
13072
|
+
value: MISSING
|
|
13073
|
+
},
|
|
13074
|
+
{
|
|
13075
|
+
label: "Cache hit",
|
|
13076
|
+
value: MISSING
|
|
13077
|
+
}
|
|
13078
|
+
] : [
|
|
13079
|
+
{
|
|
13080
|
+
label: "Uncached input",
|
|
13081
|
+
value: formatTokens(data.usage.uncachedInputTokens)
|
|
13082
|
+
},
|
|
13083
|
+
{
|
|
13084
|
+
label: "Output",
|
|
13085
|
+
value: formatTokens(data.usage.outputTokens)
|
|
13086
|
+
},
|
|
13087
|
+
{
|
|
13088
|
+
label: "Cache read",
|
|
13089
|
+
value: formatTokens(data.usage.cacheReadTokens)
|
|
13090
|
+
},
|
|
13091
|
+
{
|
|
13092
|
+
label: "Cache write",
|
|
13093
|
+
value: formatTokens(data.usage.cacheWriteTokens)
|
|
13094
|
+
},
|
|
13095
|
+
{
|
|
13096
|
+
label: "Total",
|
|
13097
|
+
value: formatTokens(data.usage.totalTokens)
|
|
13098
|
+
},
|
|
13099
|
+
{
|
|
13100
|
+
label: "Cache hit",
|
|
13101
|
+
value: data.usage.cacheHitPct === void 0 ? MISSING : `${data.usage.cacheHitPct.toFixed(1)}%`
|
|
13102
|
+
}
|
|
13103
|
+
]
|
|
13104
|
+
},
|
|
13105
|
+
{
|
|
13106
|
+
id: "performance",
|
|
13107
|
+
head: "Performance",
|
|
13108
|
+
facts: data?.stats === void 0 ? [
|
|
13109
|
+
{
|
|
13110
|
+
label: "LLM",
|
|
13111
|
+
value: MISSING
|
|
13112
|
+
},
|
|
13113
|
+
{
|
|
13114
|
+
label: "Tool",
|
|
13115
|
+
value: MISSING
|
|
13116
|
+
},
|
|
13117
|
+
{
|
|
13118
|
+
label: "Avg TTFT",
|
|
13119
|
+
value: MISSING
|
|
13120
|
+
},
|
|
13121
|
+
{
|
|
13122
|
+
label: "Decode",
|
|
13123
|
+
value: MISSING
|
|
13124
|
+
}
|
|
13125
|
+
] : [
|
|
13126
|
+
{
|
|
13127
|
+
label: "LLM",
|
|
13128
|
+
value: formatInspectorDuration(data.stats.llmMs)
|
|
13129
|
+
},
|
|
13130
|
+
{
|
|
13131
|
+
label: "Tool",
|
|
13132
|
+
value: formatInspectorDuration(data.stats.toolMs)
|
|
13133
|
+
},
|
|
13134
|
+
{
|
|
13135
|
+
label: "Avg TTFT",
|
|
13136
|
+
value: data.stats.avgTtftMs === void 0 ? MISSING : formatInspectorDuration(data.stats.avgTtftMs)
|
|
13137
|
+
},
|
|
13138
|
+
{
|
|
13139
|
+
label: "Decode",
|
|
13140
|
+
value: formatInspectorRate(data.stats.decodeTokensPerSec)
|
|
13141
|
+
}
|
|
13142
|
+
]
|
|
13143
|
+
},
|
|
13144
|
+
{
|
|
13145
|
+
id: "workspace",
|
|
13146
|
+
head: "Workspace & dates",
|
|
13147
|
+
facts: [
|
|
13148
|
+
{
|
|
13149
|
+
label: "Workspace",
|
|
13150
|
+
value: membershipValue(fact, input.workspaces, input.workspaceBaselineProven)
|
|
13151
|
+
},
|
|
13152
|
+
{
|
|
13153
|
+
label: "Created in",
|
|
13154
|
+
value: row.cwd === void 0 ? "Unknown" : sanitizedPhysicalLine(row.cwd)
|
|
13155
|
+
},
|
|
13156
|
+
{
|
|
13157
|
+
label: "Effective cwd",
|
|
13158
|
+
value: data?.effectiveCwd === void 0 ? "Unknown" : sanitizedPhysicalLine(data.effectiveCwd)
|
|
13159
|
+
},
|
|
13160
|
+
{
|
|
13161
|
+
label: "Created",
|
|
13162
|
+
value: row.createdAt === void 0 ? "Unknown" : new Date(row.createdAt).toISOString()
|
|
13163
|
+
},
|
|
13164
|
+
{
|
|
13165
|
+
label: "Updated",
|
|
13166
|
+
value: new Date(row.updatedAt).toISOString()
|
|
13167
|
+
}
|
|
13168
|
+
]
|
|
13169
|
+
},
|
|
13170
|
+
{
|
|
13171
|
+
id: "goal",
|
|
13172
|
+
head: "Goal & todo",
|
|
13173
|
+
facts: data === void 0 ? [
|
|
13174
|
+
{
|
|
13175
|
+
label: "Goal",
|
|
13176
|
+
value: "Unknown"
|
|
13177
|
+
},
|
|
13178
|
+
{
|
|
13179
|
+
label: "Goal phase",
|
|
13180
|
+
value: MISSING
|
|
13181
|
+
},
|
|
13182
|
+
{
|
|
13183
|
+
label: "Pending",
|
|
13184
|
+
value: "Unknown"
|
|
13185
|
+
},
|
|
13186
|
+
{
|
|
13187
|
+
label: "In progress",
|
|
13188
|
+
value: "Unknown"
|
|
13189
|
+
},
|
|
13190
|
+
{
|
|
13191
|
+
label: "Completed",
|
|
13192
|
+
value: "Unknown"
|
|
13193
|
+
}
|
|
13194
|
+
] : [...goalFacts(data), ...todoFacts(data)]
|
|
13195
|
+
},
|
|
13196
|
+
{
|
|
13197
|
+
id: "lineage",
|
|
13198
|
+
head: "Lineage",
|
|
13199
|
+
facts: [{
|
|
13200
|
+
label: "Parent session",
|
|
13201
|
+
value: row.parentSession === void 0 ? "No parent session" : sanitizedPhysicalLine(row.parentSession)
|
|
13202
|
+
}]
|
|
13203
|
+
},
|
|
13204
|
+
...input.excerpt?.snippet === void 0 ? [] : [{
|
|
13205
|
+
id: "excerpt",
|
|
13206
|
+
head: `Host search excerpt · ${input.excerpt.source}`,
|
|
13207
|
+
facts: [{
|
|
13208
|
+
label: "Matching content",
|
|
13209
|
+
value: sanitizedPhysicalLine(input.excerpt.snippet)
|
|
13210
|
+
}],
|
|
13211
|
+
prose: true
|
|
13212
|
+
}]
|
|
13213
|
+
];
|
|
13214
|
+
}
|
|
13215
|
+
/** The compact selected-preview groups. Only facts the current cut really
|
|
13216
|
+
* carries are listed; a missing goal/todo/parent/model adds no fake entry, and
|
|
13217
|
+
* the roster preset/parent hints stay visibly labelled. Relative freshness is
|
|
13218
|
+
* the row's own `Updated` line, so the compact view never repeats ISO time. */
|
|
13219
|
+
function summaryGroupsOf(input, data, row) {
|
|
13220
|
+
const groups = [];
|
|
13221
|
+
if (input.excerpt !== void 0) groups.push({
|
|
13222
|
+
id: "excerpt",
|
|
13223
|
+
head: `Match · ${input.excerpt.source}`,
|
|
13224
|
+
facts: input.excerpt.snippet === void 0 ? [] : [{
|
|
13225
|
+
label: "Matching content",
|
|
13226
|
+
value: sanitizedPhysicalLine(input.excerpt.snippet)
|
|
13227
|
+
}],
|
|
13228
|
+
prose: true
|
|
13229
|
+
});
|
|
13230
|
+
const modelFacts = [];
|
|
13231
|
+
if (data?.model !== void 0) {
|
|
13232
|
+
modelFacts.push({
|
|
13233
|
+
label: "Model",
|
|
13234
|
+
value: `${sanitizedPhysicalLine(data.model.provider)}/${sanitizedPhysicalLine(data.model.model)}`
|
|
13235
|
+
});
|
|
13236
|
+
if (data.model.reasoningEffort !== void 0) modelFacts.push({
|
|
13237
|
+
label: "Effort",
|
|
13238
|
+
value: sanitizedPhysicalLine(data.model.reasoningEffort)
|
|
13239
|
+
});
|
|
13240
|
+
}
|
|
13241
|
+
const preset = data?.preset !== void 0 ? sanitizedPhysicalLine(data.preset) : row.preset === void 0 ? void 0 : `${sanitizedPhysicalLine(row.preset)} (roster)`;
|
|
13242
|
+
if (preset !== void 0) modelFacts.push({
|
|
13243
|
+
label: "Preset",
|
|
13244
|
+
value: preset
|
|
13245
|
+
});
|
|
13246
|
+
if (data?.context !== void 0) {
|
|
13247
|
+
const context = contextValue(data);
|
|
13248
|
+
if (context !== MISSING) modelFacts.push({
|
|
13249
|
+
label: "Context",
|
|
13250
|
+
value: context
|
|
13251
|
+
});
|
|
13252
|
+
}
|
|
13253
|
+
if (modelFacts.length > 0) groups.push({
|
|
13254
|
+
id: "model-context",
|
|
13255
|
+
head: "Model & Context",
|
|
13256
|
+
facts: modelFacts
|
|
13257
|
+
});
|
|
13258
|
+
const activityFacts = [];
|
|
13259
|
+
if (data?.stats !== void 0) {
|
|
13260
|
+
activityFacts.push({
|
|
13261
|
+
label: "Turns",
|
|
13262
|
+
value: String(data.stats.turns)
|
|
13263
|
+
});
|
|
13264
|
+
activityFacts.push({
|
|
13265
|
+
label: "Steps",
|
|
13266
|
+
value: String(data.stats.steps)
|
|
13267
|
+
});
|
|
13268
|
+
}
|
|
13269
|
+
if (data?.goal !== null && data?.goal !== void 0) activityFacts.push({
|
|
13270
|
+
label: "Goal phase",
|
|
13271
|
+
value: sanitizedPhysicalLine(data.goal.phase)
|
|
13272
|
+
});
|
|
13273
|
+
if (data?.todos !== null && data?.todos !== void 0) {
|
|
13274
|
+
const total = data.todos.pending + data.todos.inProgress + data.todos.completed;
|
|
13275
|
+
activityFacts.push({
|
|
13276
|
+
label: "Todo",
|
|
13277
|
+
value: `${data.todos.completed}/${total}`
|
|
13278
|
+
});
|
|
13279
|
+
}
|
|
13280
|
+
if (row.parentSession !== void 0) activityFacts.push({
|
|
13281
|
+
label: "Parent",
|
|
13282
|
+
value: sanitizedPhysicalLine(shortSessionId(row.parentSession))
|
|
13283
|
+
});
|
|
13284
|
+
if (activityFacts.length > 0) groups.push({
|
|
13285
|
+
id: "activity-goal",
|
|
13286
|
+
head: "Activity & Goal",
|
|
13287
|
+
facts: activityFacts
|
|
13288
|
+
});
|
|
13289
|
+
const usageFacts = [];
|
|
13290
|
+
if (data?.usage !== void 0) {
|
|
13291
|
+
usageFacts.push({
|
|
13292
|
+
label: "Total",
|
|
13293
|
+
value: formatTokens(data.usage.totalTokens)
|
|
13294
|
+
});
|
|
13295
|
+
if (data.usage.cacheHitPct !== void 0) usageFacts.push({
|
|
13296
|
+
label: "Cache hit",
|
|
13297
|
+
value: `${data.usage.cacheHitPct.toFixed(1)}%`
|
|
13298
|
+
});
|
|
13299
|
+
usageFacts.push({
|
|
13300
|
+
label: "Output",
|
|
13301
|
+
value: formatTokens(data.usage.outputTokens)
|
|
13302
|
+
});
|
|
13303
|
+
}
|
|
13304
|
+
if (data?.stats !== void 0) usageFacts.push({
|
|
13305
|
+
label: "LLM",
|
|
13306
|
+
value: formatInspectorDuration(data.stats.llmMs)
|
|
13307
|
+
});
|
|
13308
|
+
if (usageFacts.length > 0) groups.push({
|
|
13309
|
+
id: "usage",
|
|
13310
|
+
head: "Usage",
|
|
13311
|
+
facts: usageFacts
|
|
13312
|
+
});
|
|
13313
|
+
return groups;
|
|
13314
|
+
}
|
|
13315
|
+
/** Build the ONE display projection of the selected Session's Inspector. */
|
|
13316
|
+
function buildSessionInspectorView(input) {
|
|
13317
|
+
const row = input.row;
|
|
13318
|
+
const inspector = input.inspector;
|
|
13319
|
+
const matching = inspector !== void 0 && inspector.sessionId === row.id && (inspector.state !== "ready" || inspector.data.sessionId === row.id) ? inspector : void 0;
|
|
13320
|
+
const rosterTitle = row.title === void 0 || row.title.trim() === "" ? void 0 : sanitizedPhysicalLine(row.title);
|
|
13321
|
+
const stateLabel = stateParts(row, input.fact, input.currentSessionId).join(" · ");
|
|
13322
|
+
const identityState = `${row.id === input.currentSessionId ? "Current session" : row.live ? "Live session" : "Persisted session"}${row.formatStatus === "migration-required" ? " · Migration required" : ""}`;
|
|
13323
|
+
const data = matching?.state === "ready" ? matching.data : void 0;
|
|
13324
|
+
const title = data?.title === void 0 ? rosterTitle ?? sanitizedPhysicalLine(shortSessionId(row.id)) : sanitizedPhysicalLine(data.title);
|
|
13325
|
+
const groups = inspectorGroups(input, data);
|
|
13326
|
+
const base = {
|
|
13327
|
+
sessionId: row.id,
|
|
13328
|
+
fullId: sanitizedPhysicalLine(row.id),
|
|
13329
|
+
shortId: sanitizedPhysicalLine(shortSessionId(row.id)),
|
|
13330
|
+
title,
|
|
13331
|
+
stateLabel,
|
|
13332
|
+
identityState,
|
|
13333
|
+
freshness: `Updated ${formatSessionAge(row.updatedAt)}`,
|
|
13334
|
+
summaryGroups: summaryGroupsOf(input, data, row)
|
|
13335
|
+
};
|
|
13336
|
+
if (matching === void 0 || matching.state === "loading") return {
|
|
13337
|
+
...base,
|
|
13338
|
+
state: "loading",
|
|
13339
|
+
notice: "Loading statistics…",
|
|
13340
|
+
groups
|
|
13341
|
+
};
|
|
13342
|
+
if (matching.state !== "ready") {
|
|
13343
|
+
const notice = matching.state === "unavailable" ? "Statistics unavailable" : matching.state === "denied" ? "Access denied" : matching.state === "migration-required" ? "Migration required" : `Statistics failed: ${sanitizedPhysicalLine(matching.message)}`;
|
|
13344
|
+
return {
|
|
13345
|
+
...base,
|
|
13346
|
+
state: matching.state,
|
|
13347
|
+
notice,
|
|
13348
|
+
groups
|
|
13349
|
+
};
|
|
13350
|
+
}
|
|
13351
|
+
return {
|
|
13352
|
+
...base,
|
|
13353
|
+
state: matching.refreshing ? "refreshing" : "ready",
|
|
13354
|
+
notice: matching.refreshing ? "Refreshing" : "",
|
|
13355
|
+
groups
|
|
13356
|
+
};
|
|
13357
|
+
}
|
|
13358
|
+
//#endregion
|
|
12544
13359
|
//#region src/domain/visual/presentation.ts
|
|
12545
13360
|
const presentations = /* @__PURE__ */ new WeakMap();
|
|
12546
13361
|
function sameKey(left, right) {
|
|
@@ -14238,29 +15053,378 @@ function shellCommandIsOpen(lines) {
|
|
|
14238
15053
|
index += 2;
|
|
14239
15054
|
continue;
|
|
14240
15055
|
}
|
|
14241
|
-
if (character === "<" && line[index + 1] === "<") {
|
|
14242
|
-
const parsed = heredocAt(line, index);
|
|
14243
|
-
if (parsed !== void 0) {
|
|
14244
|
-
declared.push(parsed);
|
|
15056
|
+
if (character === "<" && line[index + 1] === "<") {
|
|
15057
|
+
const parsed = heredocAt(line, index);
|
|
15058
|
+
if (parsed !== void 0) {
|
|
15059
|
+
declared.push(parsed);
|
|
15060
|
+
index += 2;
|
|
15061
|
+
continue;
|
|
15062
|
+
}
|
|
15063
|
+
}
|
|
15064
|
+
if (substitution > 0) {
|
|
15065
|
+
if (character === "(") substitution += 1;
|
|
15066
|
+
else if (character === ")") substitution -= 1;
|
|
15067
|
+
index += 1;
|
|
15068
|
+
continue;
|
|
15069
|
+
}
|
|
15070
|
+
if (brace > 0) {
|
|
15071
|
+
if (character === "{") brace += 1;
|
|
15072
|
+
else if (character === "}") brace -= 1;
|
|
15073
|
+
}
|
|
15074
|
+
index += 1;
|
|
15075
|
+
}
|
|
15076
|
+
if (!trailingContinuation && declared.length > 0) bodies.push(...declared.splice(0, declared.length));
|
|
15077
|
+
}
|
|
15078
|
+
return quote !== void 0 || backtick || substitution > 0 || brace > 0 || declared.length > 0 || bodies.length > 0 || trailingContinuation;
|
|
15079
|
+
}
|
|
15080
|
+
/**
|
|
15081
|
+
* The PowerShell literal-path adaptation. A PowerShell Host shell has no
|
|
15082
|
+
* command/variable candidate source in this version, so ONLY a clearly
|
|
15083
|
+
* delimited single-line literal path token may reach the Host path bridge.
|
|
15084
|
+
* Backslash is an ordinary filename character in PowerShell; a single-quoted
|
|
15085
|
+
* literal is always literal (`''` is one apostrophe); double-quoted content is
|
|
15086
|
+
* accepted only while it stays literal (no `$` interpolation and no backtick
|
|
15087
|
+
* escape anywhere in the token). Variable/subexpression/backtick/here-string/
|
|
15088
|
+
* mixed quoting and multi-line continuations yield no candidates at all.
|
|
15089
|
+
*/
|
|
15090
|
+
/** The finite quote classes recognized by PowerShell's parser
|
|
15091
|
+
* (`CharTraits.IsSingleQuote` / `IsDoubleQuote`). This adapter only lets an
|
|
15092
|
+
* ASCII quote DELIMIT a raw token; recognized smart single quotes may appear
|
|
15093
|
+
* as doubled literal content, exactly as the adapter itself emits them. */
|
|
15094
|
+
const POWERSHELL_SINGLE_QUOTE_CHARACTERS = /* @__PURE__ */ new Set([
|
|
15095
|
+
"'",
|
|
15096
|
+
"‘",
|
|
15097
|
+
"’",
|
|
15098
|
+
"‚",
|
|
15099
|
+
"‛"
|
|
15100
|
+
]);
|
|
15101
|
+
const POWERSHELL_DOUBLE_QUOTE_CHARACTERS = /* @__PURE__ */ new Set([
|
|
15102
|
+
"\"",
|
|
15103
|
+
"“",
|
|
15104
|
+
"”",
|
|
15105
|
+
"„"
|
|
15106
|
+
]);
|
|
15107
|
+
function isPowerShellSingleQuoteCharacter(character) {
|
|
15108
|
+
return character !== void 0 && POWERSHELL_SINGLE_QUOTE_CHARACTERS.has(character);
|
|
15109
|
+
}
|
|
15110
|
+
function isPowerShellDoubleQuoteCharacter(character) {
|
|
15111
|
+
return character !== void 0 && POWERSHELL_DOUBLE_QUOTE_CHARACTERS.has(character);
|
|
15112
|
+
}
|
|
15113
|
+
/** One bare PowerShell word delimiter; unquoted whitespace and PowerShell
|
|
15114
|
+
* control operators/commas end the word. */
|
|
15115
|
+
function isPowerShellWordDelimiter(character) {
|
|
15116
|
+
return character === " " || character === " " || character === "\n" || character === ";" || character === "|" || character === "&" || character === "(" || character === ")" || character === "{" || character === "}" || character === "<" || character === ">" || character === ",";
|
|
15117
|
+
}
|
|
15118
|
+
/** Find the closing ASCII quote after `from`, honoring a doubled quote of the
|
|
15119
|
+
* SAME recognized class. A single smart delimiter is returned as the close;
|
|
15120
|
+
* the caller refuses it because only an ASCII delimiter is unambiguous here. */
|
|
15121
|
+
function findPowerShellClosingQuote(line, from, quote) {
|
|
15122
|
+
for (let index = from; index < line.length; index += 1) {
|
|
15123
|
+
const character = line[index];
|
|
15124
|
+
if (quote === "'") {
|
|
15125
|
+
if (!isPowerShellSingleQuoteCharacter(character)) continue;
|
|
15126
|
+
if (line[index + 1] === character) {
|
|
15127
|
+
index += 1;
|
|
15128
|
+
continue;
|
|
15129
|
+
}
|
|
15130
|
+
return index;
|
|
15131
|
+
}
|
|
15132
|
+
if (character === "`") {
|
|
15133
|
+
index += 1;
|
|
15134
|
+
continue;
|
|
15135
|
+
}
|
|
15136
|
+
if (character === "\"") {
|
|
15137
|
+
if (line[index + 1] === "\"") {
|
|
15138
|
+
index += 1;
|
|
15139
|
+
continue;
|
|
15140
|
+
}
|
|
15141
|
+
return index;
|
|
15142
|
+
}
|
|
15143
|
+
if (isPowerShellDoubleQuoteCharacter(character)) return index;
|
|
15144
|
+
}
|
|
15145
|
+
return -1;
|
|
15146
|
+
}
|
|
15147
|
+
function powerShellWordRole(line, prefixLength, tokenStart) {
|
|
15148
|
+
let index = prefixLength;
|
|
15149
|
+
let firstWord = "";
|
|
15150
|
+
let priorWords = 0;
|
|
15151
|
+
let current = "";
|
|
15152
|
+
let started = false;
|
|
15153
|
+
let quote;
|
|
15154
|
+
let initialCall = false;
|
|
15155
|
+
const finish = () => {
|
|
15156
|
+
if (!started) return;
|
|
15157
|
+
priorWords += 1;
|
|
15158
|
+
if (firstWord === "") firstWord = current;
|
|
15159
|
+
current = "";
|
|
15160
|
+
started = false;
|
|
15161
|
+
};
|
|
15162
|
+
while (index < tokenStart) {
|
|
15163
|
+
const character = line[index];
|
|
15164
|
+
if (quote === "'") {
|
|
15165
|
+
if (isPowerShellSingleQuoteCharacter(character)) {
|
|
15166
|
+
if (line[index + 1] === character) {
|
|
15167
|
+
current += character;
|
|
15168
|
+
index += 2;
|
|
15169
|
+
continue;
|
|
15170
|
+
}
|
|
15171
|
+
if (character !== "'") return { kind: "unavailable" };
|
|
15172
|
+
quote = void 0;
|
|
15173
|
+
index += 1;
|
|
15174
|
+
continue;
|
|
15175
|
+
}
|
|
15176
|
+
current += character;
|
|
15177
|
+
index += 1;
|
|
15178
|
+
continue;
|
|
15179
|
+
}
|
|
15180
|
+
if (quote === "\"") {
|
|
15181
|
+
if (character === "`" || character === "$") return { kind: "unavailable" };
|
|
15182
|
+
if (character === "\"") {
|
|
15183
|
+
if (line[index + 1] === "\"") {
|
|
15184
|
+
current += "\"";
|
|
15185
|
+
index += 2;
|
|
15186
|
+
continue;
|
|
15187
|
+
}
|
|
15188
|
+
quote = void 0;
|
|
15189
|
+
index += 1;
|
|
15190
|
+
continue;
|
|
15191
|
+
}
|
|
15192
|
+
if (isPowerShellDoubleQuoteCharacter(character)) return { kind: "unavailable" };
|
|
15193
|
+
current += character;
|
|
15194
|
+
index += 1;
|
|
15195
|
+
continue;
|
|
15196
|
+
}
|
|
15197
|
+
if (character === " " || character === " " || character === "\n" || character === ",") {
|
|
15198
|
+
finish();
|
|
15199
|
+
index += 1;
|
|
15200
|
+
continue;
|
|
15201
|
+
}
|
|
15202
|
+
if (character === "&") {
|
|
15203
|
+
if (priorWords === 0 && !started && current === "" && !initialCall && (index + 1 === line.length || line[index + 1] === " " || line[index + 1] === " ")) {
|
|
15204
|
+
initialCall = true;
|
|
15205
|
+
index += 1;
|
|
15206
|
+
continue;
|
|
15207
|
+
}
|
|
15208
|
+
return { kind: "unavailable" };
|
|
15209
|
+
}
|
|
15210
|
+
if (character === ";" || character === "|" || character === "(" || character === ")" || character === "{" || character === "}" || character === "<" || character === ">") return { kind: "unavailable" };
|
|
15211
|
+
if (character === "'" || character === "\"") {
|
|
15212
|
+
if (started) return { kind: "unavailable" };
|
|
15213
|
+
started = true;
|
|
15214
|
+
quote = character;
|
|
15215
|
+
index += 1;
|
|
15216
|
+
continue;
|
|
15217
|
+
}
|
|
15218
|
+
if (isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) return { kind: "unavailable" };
|
|
15219
|
+
if (character === "`" || character === "$") return { kind: "unavailable" };
|
|
15220
|
+
if (!started && (character === "#" || line.startsWith("--%", index) || character === "@" || character === "[")) return { kind: "unavailable" };
|
|
15221
|
+
current += character;
|
|
15222
|
+
started = true;
|
|
15223
|
+
index += 1;
|
|
15224
|
+
}
|
|
15225
|
+
if (quote !== void 0) return { kind: "unavailable" };
|
|
15226
|
+
finish();
|
|
15227
|
+
if (initialCall && priorWords === 0) return { kind: "callArgument" };
|
|
15228
|
+
if (priorWords === 0) return { kind: "command" };
|
|
15229
|
+
return {
|
|
15230
|
+
kind: "argument",
|
|
15231
|
+
firstWord,
|
|
15232
|
+
priorWords
|
|
15233
|
+
};
|
|
15234
|
+
}
|
|
15235
|
+
function scanPowerShellWord(line, prefixLength, col) {
|
|
15236
|
+
let tokenStart = prefixLength;
|
|
15237
|
+
let value = "";
|
|
15238
|
+
let rawLength = 0;
|
|
15239
|
+
let quote;
|
|
15240
|
+
let startedQuoted = false;
|
|
15241
|
+
let closedQuote = false;
|
|
15242
|
+
let uncertain = false;
|
|
15243
|
+
let index = prefixLength;
|
|
15244
|
+
while (index < col) {
|
|
15245
|
+
const character = line[index];
|
|
15246
|
+
if (quote === "'") {
|
|
15247
|
+
if (isPowerShellSingleQuoteCharacter(character)) {
|
|
15248
|
+
if (line[index + 1] === character) {
|
|
15249
|
+
value += character;
|
|
15250
|
+
rawLength += 2;
|
|
15251
|
+
index += 2;
|
|
15252
|
+
continue;
|
|
15253
|
+
}
|
|
15254
|
+
quote = void 0;
|
|
15255
|
+
closedQuote = true;
|
|
15256
|
+
index += 1;
|
|
15257
|
+
continue;
|
|
15258
|
+
}
|
|
15259
|
+
value += character;
|
|
15260
|
+
rawLength += 1;
|
|
15261
|
+
index += 1;
|
|
15262
|
+
continue;
|
|
15263
|
+
}
|
|
15264
|
+
if (quote === "\"") {
|
|
15265
|
+
if (character === "\"") {
|
|
15266
|
+
if (line[index + 1] === "\"") {
|
|
15267
|
+
value += "\"";
|
|
15268
|
+
rawLength += 2;
|
|
14245
15269
|
index += 2;
|
|
14246
15270
|
continue;
|
|
14247
15271
|
}
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
if (character === "(") substitution += 1;
|
|
14251
|
-
else if (character === ")") substitution -= 1;
|
|
15272
|
+
quote = void 0;
|
|
15273
|
+
closedQuote = true;
|
|
14252
15274
|
index += 1;
|
|
14253
15275
|
continue;
|
|
14254
15276
|
}
|
|
14255
|
-
if (
|
|
14256
|
-
|
|
14257
|
-
|
|
15277
|
+
if (character === "`" || character === "$" || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15278
|
+
uncertain = true;
|
|
15279
|
+
break;
|
|
14258
15280
|
}
|
|
15281
|
+
value += character;
|
|
15282
|
+
rawLength += 1;
|
|
14259
15283
|
index += 1;
|
|
15284
|
+
continue;
|
|
14260
15285
|
}
|
|
14261
|
-
if (
|
|
15286
|
+
if (isPowerShellWordDelimiter(character)) {
|
|
15287
|
+
tokenStart = index + 1;
|
|
15288
|
+
value = "";
|
|
15289
|
+
rawLength = 0;
|
|
15290
|
+
quote = void 0;
|
|
15291
|
+
startedQuoted = false;
|
|
15292
|
+
closedQuote = false;
|
|
15293
|
+
index += 1;
|
|
15294
|
+
continue;
|
|
15295
|
+
}
|
|
15296
|
+
if (rawLength === 0) {
|
|
15297
|
+
if (character === "#") {
|
|
15298
|
+
uncertain = true;
|
|
15299
|
+
break;
|
|
15300
|
+
}
|
|
15301
|
+
if (character === "-" && line.startsWith("--%", index)) {
|
|
15302
|
+
uncertain = true;
|
|
15303
|
+
break;
|
|
15304
|
+
}
|
|
15305
|
+
}
|
|
15306
|
+
if (character === "'" || character === "\"") {
|
|
15307
|
+
if (rawLength > 0) {
|
|
15308
|
+
uncertain = true;
|
|
15309
|
+
break;
|
|
15310
|
+
}
|
|
15311
|
+
startedQuoted = true;
|
|
15312
|
+
quote = character;
|
|
15313
|
+
rawLength += 1;
|
|
15314
|
+
index += 1;
|
|
15315
|
+
continue;
|
|
15316
|
+
}
|
|
15317
|
+
if (isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15318
|
+
uncertain = true;
|
|
15319
|
+
break;
|
|
15320
|
+
}
|
|
15321
|
+
if (character === "`" || character === "$") {
|
|
15322
|
+
uncertain = true;
|
|
15323
|
+
break;
|
|
15324
|
+
}
|
|
15325
|
+
if ((character === "@" || character === "[") && rawLength === 0) {
|
|
15326
|
+
uncertain = true;
|
|
15327
|
+
break;
|
|
15328
|
+
}
|
|
15329
|
+
value += character;
|
|
15330
|
+
rawLength += 1;
|
|
15331
|
+
index += 1;
|
|
14262
15332
|
}
|
|
14263
|
-
|
|
15333
|
+
if (closedQuote && quote === void 0) uncertain = true;
|
|
15334
|
+
if (quote === "'" && isPowerShellSingleQuoteCharacter(line[col - 1]) && line[col - 1] === line[col]) uncertain = true;
|
|
15335
|
+
if (quote === "\"" && (line[col - 1] === "`" || line[col - 1] === "\"" && line[col] === "\"")) uncertain = true;
|
|
15336
|
+
let end = col;
|
|
15337
|
+
if (!uncertain) {
|
|
15338
|
+
if (quote !== void 0) {
|
|
15339
|
+
const closing = findPowerShellClosingQuote(line, col, quote);
|
|
15340
|
+
if (closing === -1) {
|
|
15341
|
+
end = line.length;
|
|
15342
|
+
if (quote === "\"" && /[`$]/u.test(line.slice(col))) uncertain = true;
|
|
15343
|
+
} else {
|
|
15344
|
+
if (quote === "'" && line[closing] !== "'") uncertain = true;
|
|
15345
|
+
if (quote === "\"" && line[closing] !== "\"") uncertain = true;
|
|
15346
|
+
const tail = line.slice(col, closing);
|
|
15347
|
+
if (quote === "\"" && /[`$]/u.test(tail)) uncertain = true;
|
|
15348
|
+
end = closing + 1;
|
|
15349
|
+
if (end < line.length && !isPowerShellWordDelimiter(line[end])) uncertain = true;
|
|
15350
|
+
}
|
|
15351
|
+
} else {
|
|
15352
|
+
let tailIndex = col;
|
|
15353
|
+
while (tailIndex < line.length) {
|
|
15354
|
+
const character = line[tailIndex];
|
|
15355
|
+
if (isPowerShellWordDelimiter(character)) break;
|
|
15356
|
+
if (character === "$" || character === "`" || character === "'" || character === "\"" || isPowerShellSingleQuoteCharacter(character) || isPowerShellDoubleQuoteCharacter(character)) {
|
|
15357
|
+
uncertain = true;
|
|
15358
|
+
break;
|
|
15359
|
+
}
|
|
15360
|
+
tailIndex += 1;
|
|
15361
|
+
}
|
|
15362
|
+
end = tailIndex;
|
|
15363
|
+
}
|
|
15364
|
+
}
|
|
15365
|
+
const closingQuoteAfterCursor = quote !== void 0 && findPowerShellClosingQuote(line, col, quote) !== -1;
|
|
15366
|
+
return {
|
|
15367
|
+
start: tokenStart,
|
|
15368
|
+
value,
|
|
15369
|
+
quote,
|
|
15370
|
+
closingQuoteAfterCursor,
|
|
15371
|
+
startedQuoted,
|
|
15372
|
+
uncertain,
|
|
15373
|
+
end
|
|
15374
|
+
};
|
|
15375
|
+
}
|
|
15376
|
+
/** Whether a decoded PowerShell token is a literal PATH word in its proven
|
|
15377
|
+
* role. A bare executable command position is never admitted; only an initial
|
|
15378
|
+
* `&` call argument or an ordinary argument may complete. */
|
|
15379
|
+
function isPowerShellPathValue(value, role, startedQuoted) {
|
|
15380
|
+
if (role === "command" || role === "unavailable") return false;
|
|
15381
|
+
if (value === "") return role === "argument";
|
|
15382
|
+
if (!startedQuoted && value.startsWith("-")) return false;
|
|
15383
|
+
const pathShape = value === "." || value === ".." || value.startsWith(".\\") || value.startsWith("./") || value.startsWith("..\\") || value.startsWith("../") || value.startsWith("~") || /^[A-Za-z]:[\\/]/u.test(value) || value.includes("\\") || value.includes("/");
|
|
15384
|
+
if (role === "callArgument") return startedQuoted || pathShape;
|
|
15385
|
+
return true;
|
|
15386
|
+
}
|
|
15387
|
+
/** Parse one PowerShell `!`/`!!` line for a literal path position. */
|
|
15388
|
+
function powershellCompletionContext(line, col) {
|
|
15389
|
+
if (!line.startsWith("!")) return void 0;
|
|
15390
|
+
const prefixLength = line.startsWith("!!") ? 2 : 1;
|
|
15391
|
+
if (col < prefixLength) return void 0;
|
|
15392
|
+
const scan = scanPowerShellWord(line, prefixLength, col);
|
|
15393
|
+
if (scan.uncertain) return void 0;
|
|
15394
|
+
if (scan.start === col && scan.end > col) return void 0;
|
|
15395
|
+
const role = powerShellWordRole(line, prefixLength, scan.start);
|
|
15396
|
+
if (role.kind === "unavailable") return void 0;
|
|
15397
|
+
if (!isPowerShellPathValue(scan.value, role.kind, scan.startedQuoted)) return void 0;
|
|
15398
|
+
if (role.kind === "argument" && /^git$/iu.test(role.firstWord) && role.priorWords === 1) return void 0;
|
|
15399
|
+
return {
|
|
15400
|
+
kind: "paths",
|
|
15401
|
+
prefix: line.slice(scan.start, col),
|
|
15402
|
+
priorWords: [],
|
|
15403
|
+
word: {
|
|
15404
|
+
valuePrefix: scan.value,
|
|
15405
|
+
quote: scan.quote,
|
|
15406
|
+
closingQuoteAfterCursor: scan.closingQuoteAfterCursor
|
|
15407
|
+
}
|
|
15408
|
+
};
|
|
15409
|
+
}
|
|
15410
|
+
/** The RAW range one PowerShell literal-path acceptance replaces: the whole
|
|
15411
|
+
* current token, including a closing quote after the cursor. */
|
|
15412
|
+
function powershellWordRange(line, prefixLength, col) {
|
|
15413
|
+
const scan = scanPowerShellWord(line, prefixLength, col);
|
|
15414
|
+
if (scan.uncertain) return void 0;
|
|
15415
|
+
if (scan.start === col && scan.end > col) return void 0;
|
|
15416
|
+
if (powerShellWordRole(line, prefixLength, scan.start).kind === "unavailable") return void 0;
|
|
15417
|
+
return {
|
|
15418
|
+
start: scan.start,
|
|
15419
|
+
end: scan.end
|
|
15420
|
+
};
|
|
15421
|
+
}
|
|
15422
|
+
/** Encode one literal path as a PowerShell single-quoted literal. Every
|
|
15423
|
+
* single-quote character in the official class is a delimiter; doubling the
|
|
15424
|
+
* ORIGINAL character makes it literal content. Double-quote class characters
|
|
15425
|
+
* are plain content inside this single-quoted literal. */
|
|
15426
|
+
function powershellPathLiteral(value) {
|
|
15427
|
+
return `'${value.replace(/['\u2018\u2019\u201A\u201B]/gu, (quote) => `${quote}${quote}`)}'`;
|
|
14264
15428
|
}
|
|
14265
15429
|
/** The RAW range a WHOLE-WORD acceptance replaces: the raw word start, and the
|
|
14266
15430
|
* raw word end. A closing quote the cursor is inside is part of the range (the
|
|
@@ -14390,7 +15554,7 @@ async function suggestShellCompletion(context, port, target, options) {
|
|
|
14390
15554
|
items: candidates.map((candidate) => {
|
|
14391
15555
|
const directory = candidate.endsWith("/") || candidate.endsWith("\\");
|
|
14392
15556
|
return {
|
|
14393
|
-
value: port.pathAuthority === "host" && context.word !== void 0 ? hostPathLiteral(candidate, context.word, directory) : candidate,
|
|
15557
|
+
value: port.pathAuthority === "host" && context.word !== void 0 ? port.pathLiteralDialect === "powershell" ? powershellPathLiteral(candidate) : hostPathLiteral(candidate, context.word, directory) : candidate,
|
|
14394
15558
|
label: candidate
|
|
14395
15559
|
};
|
|
14396
15560
|
}),
|
|
@@ -15091,17 +16255,21 @@ var MentionProvider = class {
|
|
|
15091
16255
|
const currentLine = lines[cursorLine] ?? "";
|
|
15092
16256
|
const textBeforeCursor = currentLine.slice(0, cursorCol);
|
|
15093
16257
|
const requestScope = this.scopeOf();
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
16258
|
+
const shellDialect = this.hostShellCompletion?.pathLiteralDialect ?? "bash";
|
|
16259
|
+
if (this.inputModeSource() !== "prompt" && cursorLine > 0) {
|
|
16260
|
+
if (shellDialect === "powershell" || shellCommandIsOpen(lines.slice(0, cursorLine))) {
|
|
16261
|
+
if (generation === this.requestGeneration) this.requestSnapshot = null;
|
|
16262
|
+
return null;
|
|
16263
|
+
}
|
|
15097
16264
|
}
|
|
15098
16265
|
const shellLine = this.virtualWireShellContext(lines, cursorLine, cursorCol) ?? {
|
|
15099
16266
|
line: currentLine,
|
|
15100
16267
|
cursorCol,
|
|
15101
16268
|
prefixLength: 0
|
|
15102
16269
|
};
|
|
15103
|
-
const shellContext = this.hostShellCompletion === void 0 ? void 0 : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
15104
|
-
|
|
16270
|
+
const shellContext = this.hostShellCompletion === void 0 ? void 0 : shellDialect === "powershell" ? powershellCompletionContext(shellLine.line, shellLine.cursorCol) : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
16271
|
+
const quietPowerShellArgument = shellDialect === "powershell" && shellContext?.kind === "paths" && shellContext.word?.valuePrefix === "" && options.force !== true;
|
|
16272
|
+
if (shellContext !== void 0 && !quietPowerShellArgument) {
|
|
15105
16273
|
const port = this.hostShellCompletion;
|
|
15106
16274
|
if (!(shellContext.kind === "paths" && port.pathAuthority === "client")) {
|
|
15107
16275
|
const suggestions = await suggestShellCompletion(shellContext, port, shellCompletionTargetOf(requestScope), options);
|
|
@@ -15142,7 +16310,7 @@ var MentionProvider = class {
|
|
|
15142
16310
|
const literalShellLine = textBeforeCursor.trimStart().startsWith("!");
|
|
15143
16311
|
if (semantic !== null || literalShellLine) {
|
|
15144
16312
|
const port = this.hostShellCompletion;
|
|
15145
|
-
if (port === void 0 || port.pathAuthority === "host") return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, null, false);
|
|
16313
|
+
if (port === void 0 || port.pathAuthority === "host" || port.pathLiteralDialect === "powershell") return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, null, false);
|
|
15146
16314
|
try {
|
|
15147
16315
|
const result = await this.inner.getSuggestions(lines, cursorLine, cursorCol, options);
|
|
15148
16316
|
return this.withRequestSnapshot(generation, requestScope, requestMode, requestLocalCwd, lines, cursorLine, cursorCol, result, false);
|
|
@@ -15394,7 +16562,8 @@ var MentionProvider = class {
|
|
|
15394
16562
|
cursorLine,
|
|
15395
16563
|
cursorCol
|
|
15396
16564
|
};
|
|
15397
|
-
const
|
|
16565
|
+
const shellDialect = this.hostShellCompletion?.pathLiteralDialect ?? "bash";
|
|
16566
|
+
const shellContext = shellDialect === "powershell" ? powershellCompletionContext(shellLine.line, shellLine.cursorCol) : shellCompletionContext(shellLine.line, shellLine.cursorCol);
|
|
15398
16567
|
const wholeWordShell = shellContext?.kind === "command" || shellContext?.kind === "subcommand";
|
|
15399
16568
|
const start = cursorCol - bodyPrefix.length;
|
|
15400
16569
|
if (!wholeWordShell && (start < 0 || currentLine.slice(start, cursorCol) !== bodyPrefix)) return {
|
|
@@ -15427,6 +16596,25 @@ var MentionProvider = class {
|
|
|
15427
16596
|
cursorLine,
|
|
15428
16597
|
cursorCol
|
|
15429
16598
|
};
|
|
16599
|
+
if (shellDialect === "powershell") {
|
|
16600
|
+
const scanPrefixLength = wire === null ? currentLine.startsWith("!!") ? 2 : 1 : wire.prefixLength;
|
|
16601
|
+
const range = powershellWordRange(shellLine.line, scanPrefixLength, shellLine.cursorCol);
|
|
16602
|
+
if (range === void 0) return {
|
|
16603
|
+
lines,
|
|
16604
|
+
cursorLine,
|
|
16605
|
+
cursorCol
|
|
16606
|
+
};
|
|
16607
|
+
const directory = item.label.endsWith("/") || item.label.endsWith("\\");
|
|
16608
|
+
const rawStart = range.start - shellLine.prefixLength;
|
|
16609
|
+
const rawEnd = range.end - shellLine.prefixLength;
|
|
16610
|
+
const newLines = [...lines];
|
|
16611
|
+
newLines[cursorLine] = `${currentLine.slice(0, rawStart)}${item.value}${currentLine.slice(rawEnd)}`;
|
|
16612
|
+
return {
|
|
16613
|
+
lines: newLines,
|
|
16614
|
+
cursorLine,
|
|
16615
|
+
cursorCol: rawStart + item.value.length - (directory ? 1 : 0)
|
|
16616
|
+
};
|
|
16617
|
+
}
|
|
15430
16618
|
const suffix = shellWordSuffix(shellLine.line, shellLine.cursorCol, shellContext.word?.quote);
|
|
15431
16619
|
const before = currentLine.slice(0, start);
|
|
15432
16620
|
const after = currentLine.slice(cursorCol + suffix.length);
|
|
@@ -15639,6 +16827,12 @@ function createInstalledAutocompleteProvider(options) {
|
|
|
15639
16827
|
/** Find the Assistant entry that owns the structural latest step. A late
|
|
15640
16828
|
* durable message can append after newer process evidence, so physical array
|
|
15641
16829
|
* order is not a reliable final-answer identity. */
|
|
16830
|
+
/**
|
|
16831
|
+
* The structural Assistant row owning one exact step (the LAST physical row for
|
|
16832
|
+
* that step). Physical position alone is not step identity: a late older-step
|
|
16833
|
+
* settlement can be appended after the latest-step row, so callers that need
|
|
16834
|
+
* the turn's latest candidate must select by step first.
|
|
16835
|
+
*/
|
|
15642
16836
|
function assistantForStep(group, step) {
|
|
15643
16837
|
for (let index = group.length - 1; index >= 0; index -= 1) {
|
|
15644
16838
|
const member = group[index];
|
|
@@ -16607,13 +17801,15 @@ function clusterAdjacentAmbientContext(messages) {
|
|
|
16607
17801
|
*
|
|
16608
17802
|
* A Work span may CARRY a foldable Context row as a structural part without
|
|
16609
17803
|
* making it Process: the row keeps its Context semantics, its source bytes and
|
|
16610
|
-
* its own disclosure, but no longer splits one turn's Activity/Thought.
|
|
17804
|
+
* its own disclosure, but no longer splits one turn's Activity/Thought. Seven
|
|
16611
17805
|
* narrow forms qualify: a `form:'snapshot'` singleton / snapshot-only raw
|
|
16612
|
-
* cluster, a `tool-jobs` Notice, an `agent-message` relay
|
|
16613
|
-
* `subagent-settled` Notice,
|
|
16614
|
-
* `
|
|
16615
|
-
* `
|
|
16616
|
-
*
|
|
17806
|
+
* cluster, a `tool-jobs` Notice, an `agent-message` relay, a
|
|
17807
|
+
* `subagent-settled` Notice, a `repeat-tool-reminder` Notice and an
|
|
17808
|
+
* image-bearing `ptc-mode` Context, each of the last five with durable
|
|
17809
|
+
* same-turn `next-step` delivery evidence, plus a complete `skill-catalog`
|
|
17810
|
+
* replacement that may only TRAIL an already-established same-turn Work. A
|
|
17811
|
+
* mixed `instructions`/`catalog`/`snapshot` cluster and every other
|
|
17812
|
+
* Notice/relay form stay independent Context boundaries.
|
|
16617
17813
|
*
|
|
16618
17814
|
* The projector is a single forward pass plus the linear ambient-clustering
|
|
16619
17815
|
* pass (O(n)); wrappers are freshly allocated each call, but their
|
|
@@ -16638,12 +17834,19 @@ function clusterAdjacentAmbientContext(messages) {
|
|
|
16638
17834
|
* {@link isFoldableSnapshotContext} inside {@link projectTranscriptStructure}.
|
|
16639
17835
|
*/
|
|
16640
17836
|
function isTranscriptWorkMember(message) {
|
|
16641
|
-
return
|
|
17837
|
+
return transcriptTurnOf(message) !== void 0 && classifyTranscriptMessage(message).class === "process" && !isSurfacedInteractionTool(message) && !isPostTurnReplayEvidence(message);
|
|
16642
17838
|
}
|
|
16643
17839
|
/** Whether one row is a producer-declared Snapshot Context row (the ONE
|
|
16644
|
-
* ambient form whose disclosure follows the surrounding Work/Thought).
|
|
17840
|
+
* ambient form whose disclosure follows the surrounding Work/Thought).
|
|
17841
|
+
*
|
|
17842
|
+
* A `ptc-mode` row that declares ANY form is malformed/foreign (the real PTC
|
|
17843
|
+
* producer omits `form`): it must never borrow the Snapshot carriage through a
|
|
17844
|
+
* forged/legacy `form:'snapshot'`. The structured-media predicate remains
|
|
17845
|
+
* form-neutral, so such rows still render their original blocks standalone. */
|
|
16645
17846
|
function isSnapshotContext(message) {
|
|
16646
|
-
|
|
17847
|
+
if (!isSurfacedContext(message) || contextFormOf(message) !== "snapshot") return false;
|
|
17848
|
+
const presentation = message.contextPresentation;
|
|
17849
|
+
return !(presentation?.sourceKind === "ptc-mode" && presentation.formDeclared === true);
|
|
16647
17850
|
}
|
|
16648
17851
|
/** Per-cluster memo of {@link isSnapshotOnlyCluster}: cluster wrappers are
|
|
16649
17852
|
* freshly allocated per projection pass but may be queried once per member by
|
|
@@ -16678,69 +17881,17 @@ function isFoldableSnapshotContext(message, clusterByMember) {
|
|
|
16678
17881
|
const cluster = clusterByMember.get(message);
|
|
16679
17882
|
return cluster === void 0 || isSnapshotOnlyCluster(cluster);
|
|
16680
17883
|
}
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
* same-turn `next-step` delivery evidence.
|
|
16684
|
-
*
|
|
16685
|
-
* This is a NARROW exception, never a generic notice rule: the producer-declared
|
|
16686
|
-
* `sourceKind === 'tool-jobs'` AND `form === 'notice'` are both required, plus
|
|
16687
|
-
* the fold's presentation-only `sameTurnNextStep` flag derived from the durable
|
|
16688
|
-
* `agent/inbox/spliced` insert/claim identity chain. A `next-turn` wakeup, a
|
|
16689
|
-
* foreign/legacy log, a different producer (including `subagent-settled`) or a
|
|
16690
|
-
* missing claim carries no flag and therefore stays an independent Context
|
|
16691
|
-
* boundary.
|
|
16692
|
-
*/
|
|
16693
|
-
function isWorkingToolJobsNotice(message) {
|
|
16694
|
-
if (!isSurfacedContext(message)) return false;
|
|
16695
|
-
const presentation = message.contextPresentation;
|
|
16696
|
-
return presentation !== void 0 && presentation.sameTurnNextStep === true && presentation.form === "notice" && presentation.sourceKind === "tool-jobs";
|
|
16697
|
-
}
|
|
16698
|
-
/**
|
|
16699
|
-
* Whether one row is a same-turn delivered Agent relay (`agent-message` +
|
|
16700
|
-
* `relay`) with durable next-step delivery evidence.
|
|
16701
|
-
*
|
|
16702
|
-
* This is the narrow sibling of {@link isWorkingToolJobsNotice}: the
|
|
16703
|
-
* producer-declared `sourceKind === 'agent-message'` AND `form === 'relay'`
|
|
16704
|
-
* are both required, plus the fold's presentation-only `sameTurnNextStep`
|
|
16705
|
-
* flag derived from the durable `agent/inbox/spliced` insert/claim identity
|
|
16706
|
-
* chain. A `next-turn` wakeup, a foreign/legacy log, a crossed source/form
|
|
16707
|
-
* pair or a missing claim carries no flag and therefore stays an independent
|
|
16708
|
-
* Context boundary.
|
|
16709
|
-
*/
|
|
16710
|
-
function isWorkingAgentRelay(message) {
|
|
16711
|
-
if (!isSurfacedContext(message)) return false;
|
|
16712
|
-
const presentation = message.contextPresentation;
|
|
16713
|
-
return presentation !== void 0 && presentation.sameTurnNextStep === true && presentation.sourceKind === "agent-message" && presentation.form === "relay";
|
|
16714
|
-
}
|
|
16715
|
-
/**
|
|
16716
|
-
* Whether one row is a same-turn delivered subagent settlement Notice
|
|
16717
|
-
* (`subagent-settled` + `notice`) with durable next-step delivery evidence.
|
|
16718
|
-
*
|
|
16719
|
-
* This is the narrow sibling of {@link isWorkingToolJobsNotice}: the
|
|
16720
|
-
* producer-declared `sourceKind === 'subagent-settled'` AND `form === 'notice'`
|
|
16721
|
-
* are both required, plus the fold's presentation-only `sameTurnNextStep` flag
|
|
16722
|
-
* derived from the durable `agent/inbox/spliced` insert/claim identity chain.
|
|
16723
|
-
* The settlement's textual outcome (`completed` / `error` / `aborted` / …) is
|
|
16724
|
-
* deliberately NOT inspected: every settlement that arrived through the same
|
|
16725
|
-
* proven delivery is carried the same way, and its raw body is never rewritten.
|
|
16726
|
-
* A `next-turn` wakeup, a foreign/legacy log, a crossed source/form pair or a
|
|
16727
|
-
* missing claim carries no flag and therefore stays an independent Context
|
|
16728
|
-
* boundary.
|
|
16729
|
-
*/
|
|
16730
|
-
function isWorkingSubagentSettledNotice(message) {
|
|
16731
|
-
if (!isSurfacedContext(message)) return false;
|
|
17884
|
+
function workContextCarriageOf(message, clusterByMember) {
|
|
17885
|
+
if (!isSurfacedContext(message)) return void 0;
|
|
16732
17886
|
const presentation = message.contextPresentation;
|
|
16733
|
-
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
*/
|
|
16742
|
-
function isFoldableWorkContext(message, clusterByMember) {
|
|
16743
|
-
return isFoldableSnapshotContext(message, clusterByMember) || isWorkingToolJobsNotice(message) || isWorkingAgentRelay(message) || isWorkingSubagentSettledNotice(message);
|
|
17887
|
+
if (isFoldableSnapshotContext(message, clusterByMember)) return "thought";
|
|
17888
|
+
if (presentation?.sameTurnNextStep === true) {
|
|
17889
|
+
const sourceKind = presentation.sourceKind;
|
|
17890
|
+
const form = presentation.form;
|
|
17891
|
+
if (sourceKind === "tool-jobs" && form === "notice") return "thought";
|
|
17892
|
+
if (sourceKind === "agent-message" && form === "relay" || sourceKind === "subagent-settled" && form === "notice" || sourceKind === "repeat-tool-reminder" && form === "notice" || sourceKind === "ptc-mode" && form === void 0 && presentation.formDeclared !== true && isPtcImageContext(message)) return "work";
|
|
17893
|
+
}
|
|
17894
|
+
if (presentation?.completeCatalogUpdate === true && clusterByMember.get(message) === void 0) return "trailing-work";
|
|
16744
17895
|
}
|
|
16745
17896
|
/**
|
|
16746
17897
|
* Segment one raw transcript window into canonical structural blocks.
|
|
@@ -16837,9 +17988,28 @@ function projectTranscriptStructure(messages) {
|
|
|
16837
17988
|
}], cluster.members, cluster.turn);
|
|
16838
17989
|
continue;
|
|
16839
17990
|
}
|
|
16840
|
-
if (
|
|
16841
|
-
|
|
16842
|
-
|
|
17991
|
+
if (isSurfacedContext(message)) {
|
|
17992
|
+
const carriage = workContextCarriageOf(message, clustering.byMember);
|
|
17993
|
+
if (carriage === "thought" || carriage === "work") {
|
|
17994
|
+
if (runMembers.length > 0) {
|
|
17995
|
+
if (runTurn === message.turn) {
|
|
17996
|
+
runParts.push({
|
|
17997
|
+
kind: "message",
|
|
17998
|
+
message
|
|
17999
|
+
});
|
|
18000
|
+
runMembers.push(message);
|
|
18001
|
+
continue;
|
|
18002
|
+
}
|
|
18003
|
+
flush();
|
|
18004
|
+
}
|
|
18005
|
+
pushPending([{
|
|
18006
|
+
kind: "message",
|
|
18007
|
+
message
|
|
18008
|
+
}], [message], message.turn);
|
|
18009
|
+
continue;
|
|
18010
|
+
}
|
|
18011
|
+
if (carriage === "trailing-work") {
|
|
18012
|
+
if (runMembers.length > 0 && runTurn === message.turn) {
|
|
16843
18013
|
runParts.push({
|
|
16844
18014
|
kind: "message",
|
|
16845
18015
|
message
|
|
@@ -16848,12 +18018,12 @@ function projectTranscriptStructure(messages) {
|
|
|
16848
18018
|
continue;
|
|
16849
18019
|
}
|
|
16850
18020
|
flush();
|
|
18021
|
+
out.push({
|
|
18022
|
+
kind: "message",
|
|
18023
|
+
message
|
|
18024
|
+
});
|
|
18025
|
+
continue;
|
|
16851
18026
|
}
|
|
16852
|
-
pushPending([{
|
|
16853
|
-
kind: "message",
|
|
16854
|
-
message
|
|
16855
|
-
}], [message], message.turn);
|
|
16856
|
-
continue;
|
|
16857
18027
|
}
|
|
16858
18028
|
if (isSurfacedInteractionTool(message)) {
|
|
16859
18029
|
flush();
|
|
@@ -16934,16 +18104,22 @@ function clusterByMemberOf(structure) {
|
|
|
16934
18104
|
/**
|
|
16935
18105
|
* Renderer-neutral Focus presentation projection.
|
|
16936
18106
|
*
|
|
16937
|
-
* The Focus projection over one windowed transcript (plan §12/§33):
|
|
16938
|
-
*
|
|
16939
|
-
*
|
|
16940
|
-
*
|
|
16941
|
-
*
|
|
16942
|
-
*
|
|
16943
|
-
*
|
|
16944
|
-
* A
|
|
16945
|
-
*
|
|
16946
|
-
*
|
|
18107
|
+
* The Focus projection over one windowed transcript (plan §12/§33): ONE logical
|
|
18108
|
+
* turn owns ONE Thought summary. The turn's primary presentation region is its
|
|
18109
|
+
* maximal run of eligible rows, bridged across a bounded run of standalone
|
|
18110
|
+
* control rows (a command, or a source-command-correlated manual compaction)
|
|
18111
|
+
* only when eligible same-turn evidence continues after that run. A turn with an
|
|
18112
|
+
* initial prompt is grouped as `user(s) -> FocusActivity`; a turn with only
|
|
18113
|
+
* same-turn steers starts with `FocusActivity` and keeps those steers in process
|
|
18114
|
+
* order. A turn woken by injected-context keeps that LEADING prefix at its
|
|
18115
|
+
* original foundation position before the Thought. Collapsed turns HIDE process
|
|
18116
|
+
* rows (a committed pre-steer answer is the explicit exception) and expanded
|
|
18117
|
+
* turns restore raw chronology with the final assistant held back. A foldable
|
|
18118
|
+
* Context row (producer-declared Snapshot, a `tool-jobs` Notice, an
|
|
18119
|
+
* `agent-message` relay, a `subagent-settled` Notice, a
|
|
18120
|
+
* `repeat-tool-reminder` Notice or an image-bearing `ptc-mode` Context with
|
|
18121
|
+
* durable same-turn next-step evidence) follows the same rule unless it shares
|
|
18122
|
+
* a raw-adjacent
|
|
16947
18123
|
* cluster with `instructions`/`catalog`: it joins the Thought instead of
|
|
16948
18124
|
* becoming turn foundation, while a mixed ambient cluster keeps its indivisible
|
|
16949
18125
|
* foundation position.
|
|
@@ -16964,15 +18140,75 @@ function clusterByMemberOf(structure) {
|
|
|
16964
18140
|
* collapsed Focus reorder would otherwise lift it above the turn's held-back
|
|
16965
18141
|
* final and invert the real chronology (`assistant final` → `Context
|
|
16966
18142
|
* compacted`). Treating turn-less rows as BOUNDARIES makes the projection
|
|
16967
|
-
* agree with the fold:
|
|
16968
|
-
*
|
|
16969
|
-
*
|
|
16970
|
-
*
|
|
18143
|
+
* agree with the fold: the Turn keeps its ONE summary, the command stays a
|
|
18144
|
+
* standalone control row (bridged only while eligible same-Turn evidence
|
|
18145
|
+
* continues), and any later disjoint region fails open in raw order instead of
|
|
18146
|
+
* minting a second Thought. All of those rows may belong to one model turn; the
|
|
18147
|
+
* semantic disclosure identity stays the turn number.
|
|
16971
18148
|
*/
|
|
16972
18149
|
function focusProjectionTurnOf(message) {
|
|
16973
18150
|
if (message.kind === "command") return void 0;
|
|
16974
18151
|
if (message.kind === "compaction" && message.sourceCommand !== void 0) return void 0;
|
|
16975
|
-
return
|
|
18152
|
+
return transcriptTurnOf(message);
|
|
18153
|
+
}
|
|
18154
|
+
/**
|
|
18155
|
+
* The settled latest-step Assistant that is still the PENDING final of an open
|
|
18156
|
+
* Turn, or undefined when it has authoritative continuation evidence (the Fold's
|
|
18157
|
+
* step/continuation fact), is committed, has display blocks, or is not settled.
|
|
18158
|
+
*/
|
|
18159
|
+
function focusPendingFinal(rows, activity) {
|
|
18160
|
+
if (activity === void 0 || activity.completed) return void 0;
|
|
18161
|
+
const latestStep = assistantLatestStepOf(activity);
|
|
18162
|
+
if (latestStep === void 0) return void 0;
|
|
18163
|
+
const latestAssistant = assistantForStep(rows, latestStep);
|
|
18164
|
+
if (latestAssistant === void 0 || !assistantStepSettledOf(activity, latestAssistant) || latestAssistant.displayBlocks !== void 0 || assistantCommittedBeforeSteer(activity, latestAssistant) || assistantStepIntermediateOf(activity, latestAssistant)) return void 0;
|
|
18165
|
+
return latestAssistant;
|
|
18166
|
+
}
|
|
18167
|
+
/** The turn's PRIMARY presentation region derived from the canonical raw
|
|
18168
|
+
* window: the same `focusPrimaryRegion` the projection emits. Used by the live
|
|
18169
|
+
* tail placement so a SUPPRESSED pending final still answers by region
|
|
18170
|
+
* membership, never by its own identity. */
|
|
18171
|
+
function focusPrimaryRegionOfTurn(messages, activities, turn) {
|
|
18172
|
+
const activity = activities.get(turn);
|
|
18173
|
+
const rows = focusRowsByTurn(messages).get(turn);
|
|
18174
|
+
if (activity === void 0 || rows === void 0) return void 0;
|
|
18175
|
+
const startMessage = messages.find((message) => focusProjectionTurnOf(message) === turn && !isPostTurnReplayEvidence(message));
|
|
18176
|
+
if (startMessage === void 0) return void 0;
|
|
18177
|
+
const start = messages.indexOf(startMessage);
|
|
18178
|
+
if (start < 0) return void 0;
|
|
18179
|
+
return focusPrimaryRegion(messages, start, turn, eligibleFinalAssistant(activity, rows));
|
|
18180
|
+
}
|
|
18181
|
+
/** Every message the ACTUAL all-expanded Focus projection can materialize on
|
|
18182
|
+
* the current preset: top-level rows plus members of a materialized Work span.
|
|
18183
|
+
* A suppressed pending/final row is absent; a Work emitted raw by a fail-open
|
|
18184
|
+
* region contributes no span. Search reveal/root grants use this so a
|
|
18185
|
+
* nonrecoverable hidden row mints no ancestor. */
|
|
18186
|
+
function focusMaterializedMessages(messages, activities) {
|
|
18187
|
+
const out = /* @__PURE__ */ new Set();
|
|
18188
|
+
for (const block of projectFocus(messages, activities, new Set(activities.keys()), true)) if (block.kind === "message") out.add(block.message);
|
|
18189
|
+
else if (block.kind === "work") for (const member of block.span.members) out.add(member);
|
|
18190
|
+
return out;
|
|
18191
|
+
}
|
|
18192
|
+
/**
|
|
18193
|
+
* The row a turn's expanded Focus holds back / emits as its final, per turn:
|
|
18194
|
+
* the qualified final once `turn/end` authoritatively qualifies it, otherwise
|
|
18195
|
+
* the still-pending latest-step Assistant. One rows pass; consumers use it to
|
|
18196
|
+
* recognize the final by IDENTITY instead of `assistant without containerPath`.
|
|
18197
|
+
*/
|
|
18198
|
+
function focusHeldBackFinalByTurn(messages, activities) {
|
|
18199
|
+
const out = /* @__PURE__ */ new Map();
|
|
18200
|
+
for (const [turn, rows] of focusRowsByTurn(messages)) {
|
|
18201
|
+
const activity = activities.get(turn);
|
|
18202
|
+
if (activity === void 0) continue;
|
|
18203
|
+
const final = eligibleFinalAssistant(activity, rows);
|
|
18204
|
+
if (final !== void 0) {
|
|
18205
|
+
out.set(turn, final.message);
|
|
18206
|
+
continue;
|
|
18207
|
+
}
|
|
18208
|
+
const pending = focusPendingFinal(rows, activity);
|
|
18209
|
+
if (pending !== void 0) out.set(turn, pending);
|
|
18210
|
+
}
|
|
18211
|
+
return out;
|
|
16976
18212
|
}
|
|
16977
18213
|
/**
|
|
16978
18214
|
* The Thought block for one turn: the caller-resolved TURN-LEVEL Action
|
|
@@ -17006,25 +18242,102 @@ const EMPTY_ACTION_STATS = {
|
|
|
17006
18242
|
types: /* @__PURE__ */ new Map()
|
|
17007
18243
|
};
|
|
17008
18244
|
/**
|
|
18245
|
+
* Whether one turn-less row is a standalone control-plane row the shared region
|
|
18246
|
+
* policy may bridge: a `kind:'command'` lifecycle, or a manual compaction card
|
|
18247
|
+
* already fused with the exact command that owns it (`sourceCommand`). No other
|
|
18248
|
+
* turn-less row is transparent — a window summary, a replay artifact and an
|
|
18249
|
+
* unrelated compaction boundary all end the region.
|
|
18250
|
+
*/
|
|
18251
|
+
function isFocusBridgeControlRow(message) {
|
|
18252
|
+
return message.kind === "command" || message.kind === "compaction" && message.sourceCommand !== void 0;
|
|
18253
|
+
}
|
|
18254
|
+
/**
|
|
18255
|
+
* Every eligible row of each projection turn, in window order. Post-turn replay
|
|
18256
|
+
* evidence is transcript evidence, NOT turn identity: it may neither open nor
|
|
18257
|
+
* join a Focus root, so it is omitted here and emitted standalone. One linear
|
|
18258
|
+
* pass; the final candidate and the bridge fences read these rows once.
|
|
18259
|
+
*/
|
|
18260
|
+
function focusRowsByTurn(messages) {
|
|
18261
|
+
const byTurn = /* @__PURE__ */ new Map();
|
|
18262
|
+
for (const message of messages) {
|
|
18263
|
+
const turn = focusProjectionTurnOf(message);
|
|
18264
|
+
if (turn === void 0 || isPostTurnReplayEvidence(message)) continue;
|
|
18265
|
+
const rows = byTurn.get(turn);
|
|
18266
|
+
if (rows === void 0) byTurn.set(turn, [message]);
|
|
18267
|
+
else rows.push(message);
|
|
18268
|
+
}
|
|
18269
|
+
return byTurn;
|
|
18270
|
+
}
|
|
18271
|
+
/**
|
|
18272
|
+
* Segment the primary presentation region of one logical Turn.
|
|
18273
|
+
*
|
|
18274
|
+
* The region starts at the turn's first eligible row and continues through its
|
|
18275
|
+
* remaining eligible rows in raw order. A bounded, maximal run of standalone
|
|
18276
|
+
* control rows is consumed INTO the region only when the same turn's eligible
|
|
18277
|
+
* evidence resumes after that run and the run has not crossed the turn's
|
|
18278
|
+
* qualified final. Otherwise the region ends there: the control rows and every
|
|
18279
|
+
* later row of that turn render independently (a command at the window tail is
|
|
18280
|
+
* simply not bridged yet). A different turn, any other turn-less boundary and a
|
|
18281
|
+
* replay-marked row are hard fences; the bounded lookahead never scans the rest
|
|
18282
|
+
* of the window per row, so the whole projection stays linear.
|
|
18283
|
+
* @param messages - the windowed transcript.
|
|
18284
|
+
* @param start - the region's first eligible row index.
|
|
18285
|
+
* @param turn - the logical Turn being segmented.
|
|
18286
|
+
* @param final - the Turn's qualified final, when it has one. A final that has
|
|
18287
|
+
* already appeared before a control run makes that run a hard chronology
|
|
18288
|
+
* fence (nothing may move across it).
|
|
18289
|
+
*/
|
|
18290
|
+
function focusPrimaryRegion(messages, start, turn, final) {
|
|
18291
|
+
const members = [messages[start]];
|
|
18292
|
+
let sawFinal = final !== void 0 && messages[start] === final.message;
|
|
18293
|
+
let index = start + 1;
|
|
18294
|
+
while (index < messages.length) {
|
|
18295
|
+
const next = messages[index];
|
|
18296
|
+
const nextTurn = focusProjectionTurnOf(next);
|
|
18297
|
+
if (nextTurn === turn) {
|
|
18298
|
+
if (isPostTurnReplayEvidence(next)) break;
|
|
18299
|
+
members.push(next);
|
|
18300
|
+
if (final !== void 0 && next === final.message) sawFinal = true;
|
|
18301
|
+
index += 1;
|
|
18302
|
+
continue;
|
|
18303
|
+
}
|
|
18304
|
+
if (nextTurn !== void 0 || !isFocusBridgeControlRow(next)) break;
|
|
18305
|
+
let runEnd = index;
|
|
18306
|
+
while (runEnd < messages.length) {
|
|
18307
|
+
const candidate = messages[runEnd];
|
|
18308
|
+
if (focusProjectionTurnOf(candidate) !== void 0 || !isFocusBridgeControlRow(candidate)) break;
|
|
18309
|
+
runEnd += 1;
|
|
18310
|
+
}
|
|
18311
|
+
const continuation = messages[runEnd];
|
|
18312
|
+
if (sawFinal || continuation === void 0 || focusProjectionTurnOf(continuation) !== turn || isPostTurnReplayEvidence(continuation)) break;
|
|
18313
|
+
for (let run = index; run < runEnd; run += 1) members.push(messages[run]);
|
|
18314
|
+
index = runEnd;
|
|
18315
|
+
}
|
|
18316
|
+
return {
|
|
18317
|
+
members,
|
|
18318
|
+
end: index
|
|
18319
|
+
};
|
|
18320
|
+
}
|
|
18321
|
+
/**
|
|
17009
18322
|
* One linear pass over the window: each turn's WHOLE-TURN action aggregate
|
|
17010
|
-
* (addendum v2 §18). Focus stats describe the
|
|
17011
|
-
*
|
|
17012
|
-
*
|
|
17013
|
-
*
|
|
17014
|
-
*
|
|
17015
|
-
*
|
|
17016
|
-
* unchanged window.
|
|
18323
|
+
* (addendum v2 §18). Focus stats describe the logical Turn, not its primary
|
|
18324
|
+
* presentation region: bridged control rows and a fail-open later region change
|
|
18325
|
+
* neither the aggregate nor its loaded-window scope, and the ONE summary always
|
|
18326
|
+
* reports the same turn-level number. A search reveal / disclosure state cannot
|
|
18327
|
+
* change it because none of them participate here. O(n) once per projection,
|
|
18328
|
+
* never a per-frame rescan of an unchanged window.
|
|
17017
18329
|
*/
|
|
17018
18330
|
function focusActionStatsByTurn(messages) {
|
|
17019
18331
|
const accumulators = /* @__PURE__ */ new Map();
|
|
17020
18332
|
for (const message of messages) {
|
|
17021
|
-
|
|
18333
|
+
const turn = transcriptTurnOf(message);
|
|
18334
|
+
if (turn === void 0) continue;
|
|
17022
18335
|
const source = compactActionSourceOf(message);
|
|
17023
18336
|
if (source === void 0) continue;
|
|
17024
|
-
let accumulator = accumulators.get(
|
|
18337
|
+
let accumulator = accumulators.get(turn);
|
|
17025
18338
|
if (accumulator === void 0) {
|
|
17026
18339
|
accumulator = newCompactActionStats();
|
|
17027
|
-
accumulators.set(
|
|
18340
|
+
accumulators.set(turn, accumulator);
|
|
17028
18341
|
}
|
|
17029
18342
|
addCompactActionStats(accumulator, source);
|
|
17030
18343
|
}
|
|
@@ -17038,8 +18351,8 @@ function focusActionStatsByTurn(messages) {
|
|
|
17038
18351
|
* renders an UNQUALIFIED durable mid-turn `form:'notice'` AFTER the Thought
|
|
17039
18352
|
* (visible process feedback, never inside the hidden Action candidate set),
|
|
17040
18353
|
* and hides ordinary Process inside the collapsed root. A proven Working
|
|
17041
|
-
* `tool-jobs` Notice, same-turn Agent relay
|
|
17042
|
-
* carried by that same Thought instead.
|
|
18354
|
+
* `tool-jobs` Notice, same-turn Agent relay, subagent settlement Notice or
|
|
18355
|
+
* repeat-tool-reminder Notice is carried by that same Thought instead.
|
|
17043
18356
|
* Expanded Focus restores the exact raw chronology.
|
|
17044
18357
|
*/
|
|
17045
18358
|
function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
@@ -17048,12 +18361,42 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17048
18361
|
message
|
|
17049
18362
|
}));
|
|
17050
18363
|
const actionStatsByTurn = focusActionStatsByTurn(messages);
|
|
18364
|
+
const rowsByTurn = focusRowsByTurn(messages);
|
|
18365
|
+
const finalByTurn = /* @__PURE__ */ new Map();
|
|
18366
|
+
const pendingByTurn = /* @__PURE__ */ new Map();
|
|
18367
|
+
for (const [turn, rows] of rowsByTurn) {
|
|
18368
|
+
const final = eligibleFinalAssistant(activities.get(turn), rows);
|
|
18369
|
+
if (final !== void 0) finalByTurn.set(turn, final);
|
|
18370
|
+
const pending = focusPendingFinal(rows, activities.get(turn));
|
|
18371
|
+
if (pending !== void 0) pendingByTurn.set(turn, pending);
|
|
18372
|
+
}
|
|
17051
18373
|
const out = [];
|
|
18374
|
+
const rootedTurns = /* @__PURE__ */ new Set();
|
|
17052
18375
|
let index = 0;
|
|
17053
18376
|
while (index < messages.length) {
|
|
17054
18377
|
const message = messages[index];
|
|
17055
18378
|
const turn = focusProjectionTurnOf(message);
|
|
17056
|
-
|
|
18379
|
+
const activity = turn === void 0 ? void 0 : activities.get(turn);
|
|
18380
|
+
if (turn === void 0 || activity === void 0 || isPostTurnReplayEvidence(message) || rootedTurns.has(turn)) {
|
|
18381
|
+
if (!isPostTurnReplayEvidence(message) && turn !== void 0 && activity !== void 0 && rootedTurns.has(turn)) {
|
|
18382
|
+
if (pendingByTurn.get(turn) === message) {
|
|
18383
|
+
index += 1;
|
|
18384
|
+
continue;
|
|
18385
|
+
}
|
|
18386
|
+
const qualified = finalByTurn.get(turn);
|
|
18387
|
+
if (qualified !== void 0 && qualified.message === message) {
|
|
18388
|
+
out.push(qualified.truncated ? {
|
|
18389
|
+
kind: "message",
|
|
18390
|
+
message,
|
|
18391
|
+
truncated: true
|
|
18392
|
+
} : {
|
|
18393
|
+
kind: "message",
|
|
18394
|
+
message
|
|
18395
|
+
});
|
|
18396
|
+
index += 1;
|
|
18397
|
+
continue;
|
|
18398
|
+
}
|
|
18399
|
+
}
|
|
17057
18400
|
out.push({
|
|
17058
18401
|
kind: "message",
|
|
17059
18402
|
message
|
|
@@ -17061,38 +18404,26 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17061
18404
|
index += 1;
|
|
17062
18405
|
continue;
|
|
17063
18406
|
}
|
|
17064
|
-
const
|
|
17065
|
-
index
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
|
|
17070
|
-
message: member
|
|
17071
|
-
});
|
|
17072
|
-
continue;
|
|
17073
|
-
}
|
|
18407
|
+
const final = finalByTurn.get(turn);
|
|
18408
|
+
const region = focusPrimaryRegion(messages, index, turn, final);
|
|
18409
|
+
index = region.end;
|
|
18410
|
+
rootedTurns.add(turn);
|
|
18411
|
+
const members = region.members;
|
|
18412
|
+
const regionFinal = final !== void 0 && members.includes(final.message) ? final : void 0;
|
|
17074
18413
|
const actionStats = actionStatsByTurn.get(turn) ?? EMPTY_ACTION_STATS;
|
|
17075
18414
|
const expanded = expandedTurns.has(turn);
|
|
17076
|
-
const
|
|
17077
|
-
const isCommittedAnswer = (member) =>
|
|
17078
|
-
let latestAssistantIndex = -1;
|
|
17079
|
-
for (let memberIndex = group.length - 1; memberIndex >= 0; memberIndex -= 1) if (group[memberIndex]?.kind === "assistant") {
|
|
17080
|
-
latestAssistantIndex = memberIndex;
|
|
17081
|
-
break;
|
|
17082
|
-
}
|
|
17083
|
-
const latestAssistant = latestAssistantIndex < 0 ? void 0 : group[latestAssistantIndex];
|
|
17084
|
-
const laterProcess = latestAssistantIndex < 0 ? false : group.slice(latestAssistantIndex + 1).some((member) => member.kind !== "user" && !isSurfacedContext(member));
|
|
17085
|
-
const pendingFinalAssistant = !activity.completed && latestAssistant?.kind === "assistant" && assistantStepOf(latestAssistant) === assistantLatestStepOf(activity) && assistantStepSettledOf(activity, latestAssistant) && latestAssistant.displayBlocks === void 0 && !isCommittedAnswer(latestAssistant) && !laterProcess ? latestAssistant : void 0;
|
|
18415
|
+
const rootOwner = members[0];
|
|
18416
|
+
const isCommittedAnswer = (member) => assistantCommittedBeforeSteer(activity, member);
|
|
17086
18417
|
if (expanded) {
|
|
17087
|
-
const
|
|
17088
|
-
const
|
|
17089
|
-
for (const member of group.slice(0, boundary)) out.push({
|
|
18418
|
+
const boundary = focusThoughtLeadBoundary(members);
|
|
18419
|
+
for (const member of members.slice(0, boundary)) out.push({
|
|
17090
18420
|
kind: "message",
|
|
17091
18421
|
message: member
|
|
17092
18422
|
});
|
|
17093
|
-
|
|
18423
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, void 0));
|
|
18424
|
+
const pendingFinalAssistant = pendingByTurn.get(turn);
|
|
17094
18425
|
const emitTailRow = (member) => {
|
|
17095
|
-
if (isFocusPersistentInputRow(member)) {
|
|
18426
|
+
if (isFocusPersistentInputRow(member) || isFocusBridgeControlRow(member)) {
|
|
17096
18427
|
out.push({
|
|
17097
18428
|
kind: "message",
|
|
17098
18429
|
message: member,
|
|
@@ -17100,7 +18431,7 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17100
18431
|
});
|
|
17101
18432
|
return;
|
|
17102
18433
|
}
|
|
17103
|
-
if (
|
|
18434
|
+
if (regionFinal !== void 0 && member === regionFinal.message) return;
|
|
17104
18435
|
if (member === pendingFinalAssistant) return;
|
|
17105
18436
|
if (isCommittedAnswer(member)) {
|
|
17106
18437
|
out.push({
|
|
@@ -17120,7 +18451,7 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17120
18451
|
focusPresentationOwner: rootOwner
|
|
17121
18452
|
});
|
|
17122
18453
|
};
|
|
17123
|
-
for (const block of focusExpandedTailStructure(
|
|
18454
|
+
for (const block of focusExpandedTailStructure(members, boundary)) if (block.kind === "work") out.push({
|
|
17124
18455
|
kind: "work",
|
|
17125
18456
|
span: block.span,
|
|
17126
18457
|
focusOwnerTurn: turn,
|
|
@@ -17128,75 +18459,79 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17128
18459
|
});
|
|
17129
18460
|
else if (block.kind === "context-cluster") for (const member of block.cluster.members) emitTailRow(member);
|
|
17130
18461
|
else emitTailRow(block.message);
|
|
17131
|
-
if (
|
|
18462
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
17132
18463
|
kind: "message",
|
|
17133
|
-
message:
|
|
18464
|
+
message: regionFinal.message,
|
|
17134
18465
|
truncated: true
|
|
17135
18466
|
} : {
|
|
17136
18467
|
kind: "message",
|
|
17137
|
-
message:
|
|
18468
|
+
message: regionFinal.message
|
|
17138
18469
|
});
|
|
17139
18470
|
continue;
|
|
17140
18471
|
}
|
|
17141
|
-
const leadBoundary = focusThoughtLeadBoundary(
|
|
18472
|
+
const leadBoundary = focusThoughtLeadBoundary(members);
|
|
17142
18473
|
const foldableSnapshots = {
|
|
17143
|
-
clusterByMember: clusterAdjacentAmbientContext(
|
|
17144
|
-
workByMember: workByMemberOf(projectTranscriptStructure(
|
|
17145
|
-
thoughtOwned:
|
|
18474
|
+
clusterByMember: clusterAdjacentAmbientContext(members).byMember,
|
|
18475
|
+
workByMember: workByMemberOf(projectTranscriptStructure(members)),
|
|
18476
|
+
thoughtOwned: true
|
|
17146
18477
|
};
|
|
17147
|
-
const firstCommittedIndex =
|
|
18478
|
+
const firstCommittedIndex = members.findIndex(isCommittedAnswer);
|
|
17148
18479
|
const hidden = [];
|
|
17149
18480
|
const preThought = [];
|
|
17150
18481
|
const postThought = [];
|
|
17151
|
-
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
18482
|
+
const preCommittedCompactions = [];
|
|
18483
|
+
if (firstCommittedIndex < 0) for (let memberIndex = 0; memberIndex < members.length; memberIndex += 1) {
|
|
18484
|
+
const member = members[memberIndex];
|
|
18485
|
+
if (isFocusBridgeControlRow(member)) {
|
|
18486
|
+
preThought.push(member);
|
|
18487
|
+
continue;
|
|
17157
18488
|
}
|
|
17158
|
-
|
|
17159
|
-
|
|
17160
|
-
|
|
17161
|
-
}
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
|
|
17165
|
-
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17170
|
-
|
|
17171
|
-
|
|
17172
|
-
|
|
17173
|
-
|
|
17174
|
-
|
|
17175
|
-
|
|
17176
|
-
|
|
17177
|
-
|
|
18489
|
+
if (member.kind === "compaction") {
|
|
18490
|
+
preCommittedCompactions.push(member);
|
|
18491
|
+
continue;
|
|
18492
|
+
}
|
|
18493
|
+
if (regionFinal !== void 0 && member === regionFinal.message) continue;
|
|
18494
|
+
const disposition = collapsedFocusRowDisposition(member, memberIndex, leadBoundary, foldableSnapshots);
|
|
18495
|
+
if (disposition === "hidden") hidden.push(member);
|
|
18496
|
+
else (disposition === "pre-thought" ? preThought : postThought).push(member);
|
|
18497
|
+
}
|
|
18498
|
+
else {
|
|
18499
|
+
const beforeCommitted = members.slice(0, firstCommittedIndex);
|
|
18500
|
+
for (let memberIndex = 0; memberIndex < beforeCommitted.length; memberIndex += 1) {
|
|
18501
|
+
const member = beforeCommitted[memberIndex];
|
|
18502
|
+
if (isFocusBridgeControlRow(member)) {
|
|
18503
|
+
preThought.push(member);
|
|
18504
|
+
continue;
|
|
18505
|
+
}
|
|
18506
|
+
if (member.kind === "compaction") {
|
|
18507
|
+
preCommittedCompactions.push(member);
|
|
18508
|
+
continue;
|
|
18509
|
+
}
|
|
18510
|
+
const disposition = collapsedFocusRowDisposition(member, memberIndex, leadBoundary, foldableSnapshots);
|
|
18511
|
+
if (disposition === "hidden") hidden.push(member);
|
|
18512
|
+
else (disposition === "pre-thought" ? preThought : postThought).push(member);
|
|
17178
18513
|
}
|
|
17179
18514
|
const postCommittedFoldableSnapshots = {
|
|
17180
18515
|
...foldableSnapshots,
|
|
17181
18516
|
thoughtOwned: false
|
|
17182
18517
|
};
|
|
17183
18518
|
const postCommitted = [];
|
|
17184
|
-
for (let
|
|
17185
|
-
const member =
|
|
17186
|
-
if (
|
|
17187
|
-
if (collapsedFocusRowDisposition(member,
|
|
18519
|
+
for (let memberIndex = firstCommittedIndex; memberIndex < members.length; memberIndex += 1) {
|
|
18520
|
+
const member = members[memberIndex];
|
|
18521
|
+
if (regionFinal !== void 0 && member === regionFinal.message) continue;
|
|
18522
|
+
if (collapsedFocusRowDisposition(member, memberIndex, leadBoundary, postCommittedFoldableSnapshots) !== "hidden" || isFocusBridgeControlRow(member) || member.kind === "compaction" || isCommittedAnswer(member)) postCommitted.push(member);
|
|
17188
18523
|
else hidden.push(member);
|
|
17189
18524
|
}
|
|
17190
18525
|
out.push(...preThought.map((member) => ({
|
|
17191
18526
|
kind: "message",
|
|
17192
18527
|
message: member
|
|
17193
18528
|
})));
|
|
17194
|
-
out.push(...focusActivityBlock(activity,
|
|
18529
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, hidden));
|
|
17195
18530
|
out.push(...postThought.map((member) => ({
|
|
17196
18531
|
kind: "message",
|
|
17197
18532
|
message: member
|
|
17198
18533
|
})));
|
|
17199
|
-
for (const member of
|
|
18534
|
+
for (const member of preCommittedCompactions) out.push({
|
|
17200
18535
|
kind: "message",
|
|
17201
18536
|
message: member
|
|
17202
18537
|
});
|
|
@@ -17204,32 +18539,91 @@ function projectFocus(messages, activities, expandedTurns, focusMode) {
|
|
|
17204
18539
|
kind: "message",
|
|
17205
18540
|
message: member
|
|
17206
18541
|
});
|
|
18542
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
18543
|
+
kind: "message",
|
|
18544
|
+
message: regionFinal.message,
|
|
18545
|
+
truncated: true
|
|
18546
|
+
} : {
|
|
18547
|
+
kind: "message",
|
|
18548
|
+
message: regionFinal.message
|
|
18549
|
+
});
|
|
18550
|
+
continue;
|
|
17207
18551
|
}
|
|
17208
|
-
|
|
18552
|
+
out.push(...preThought.map((member) => ({
|
|
18553
|
+
kind: "message",
|
|
18554
|
+
message: member
|
|
18555
|
+
})));
|
|
18556
|
+
out.push(...focusActivityBlock(activity, rootOwner, actionStats, hidden));
|
|
18557
|
+
out.push(...postThought.map((member) => ({
|
|
18558
|
+
kind: "message",
|
|
18559
|
+
message: member
|
|
18560
|
+
})));
|
|
18561
|
+
for (const member of preCommittedCompactions) out.push({
|
|
17209
18562
|
kind: "message",
|
|
17210
|
-
message:
|
|
18563
|
+
message: member
|
|
18564
|
+
});
|
|
18565
|
+
if (regionFinal !== void 0) out.push(regionFinal.truncated ? {
|
|
18566
|
+
kind: "message",
|
|
18567
|
+
message: regionFinal.message,
|
|
17211
18568
|
truncated: true
|
|
17212
18569
|
} : {
|
|
17213
18570
|
kind: "message",
|
|
17214
|
-
message:
|
|
18571
|
+
message: regionFinal.message
|
|
17215
18572
|
});
|
|
17216
18573
|
}
|
|
17217
18574
|
return out;
|
|
17218
18575
|
}
|
|
17219
18576
|
/**
|
|
17220
|
-
* The canonical structural blocks the expanded Focus TAIL consumes: one
|
|
17221
|
-
*
|
|
17222
|
-
*
|
|
17223
|
-
*
|
|
17224
|
-
*
|
|
18577
|
+
* The canonical structural blocks the expanded Focus TAIL consumes: one logical
|
|
18578
|
+
* Turn's primary presentation region from its Thought-lead boundary onward
|
|
18579
|
+
* (bridged control rows included at their raw positions). The held-back final is
|
|
18580
|
+
* included, so cluster membership is computed from exactly the raw adjacency the
|
|
18581
|
+
* window would give. `projectFocus` emits a canonical Work span as a nested
|
|
18582
|
+
* `work` block (F6); this exported seam lets the convergence oracle compare
|
|
17225
18583
|
* Work/cluster boundary IDENTITY (owner and member objects) instead of display
|
|
17226
18584
|
* strings (plan §25).
|
|
17227
|
-
* @param
|
|
17228
|
-
* @param boundary - the
|
|
17229
|
-
* Passed in so one expanded
|
|
18585
|
+
* @param region - one logical Turn's primary region members, in raw order.
|
|
18586
|
+
* @param boundary - the region's Thought-lead boundary
|
|
18587
|
+
* ({@link focusThoughtLeadBoundary}). Passed in so one expanded region
|
|
18588
|
+
* computes the boundary once.
|
|
17230
18589
|
*/
|
|
17231
|
-
function focusExpandedTailStructure(
|
|
17232
|
-
return projectTranscriptStructure(
|
|
18590
|
+
function focusExpandedTailStructure(region, boundary) {
|
|
18591
|
+
return projectTranscriptStructure(region.slice(boundary));
|
|
18592
|
+
}
|
|
18593
|
+
/**
|
|
18594
|
+
* The projected live-call owner at the RAW transcript tail: the ONE root of the
|
|
18595
|
+
* open Turn whose PRIMARY region actually reaches the tail, plus the exact
|
|
18596
|
+
* canonical Work when that Work owns the call. `undefined` when the tail is an
|
|
18597
|
+
* independent boundary (a turn-less command/window row, replay evidence, a
|
|
18598
|
+
* foreign/completed Turn) or belongs to a later fail-open region of the same
|
|
18599
|
+
* Turn.
|
|
18600
|
+
*
|
|
18601
|
+
* PiTui and TSP use this ONE placement. The authority is the ACTUAL expanded
|
|
18602
|
+
* projection (the region's emitted rows/Work), never "the numeric turn of the
|
|
18603
|
+
* canonical tail": a later disjoint region of the same open Turn is not the
|
|
18604
|
+
* root's region, so its rows may not adopt the live call.
|
|
18605
|
+
*/
|
|
18606
|
+
function focusLiveTailPlacement(messages, activities, expandedBlocks) {
|
|
18607
|
+
const expanded = expandedBlocks ?? projectFocus(messages, activities, new Set(activities.keys()), true);
|
|
18608
|
+
const openActivityOf = (turn) => {
|
|
18609
|
+
const block = expanded.find((candidate) => candidate.kind === "activity" && candidate.activity.turn === turn);
|
|
18610
|
+
return block?.kind === "activity" && !block.activity.completed ? block : void 0;
|
|
18611
|
+
};
|
|
18612
|
+
const trailing = projectTranscriptStructure(messages).at(-1);
|
|
18613
|
+
if (trailing === void 0) return void 0;
|
|
18614
|
+
const tailWork = trailing.kind === "work" ? trailing.span : void 0;
|
|
18615
|
+
const tailMessage = trailing.kind === "work" ? void 0 : trailing.kind === "message" ? trailing.message : trailing.kind === "context-cluster" ? trailing.cluster.members.at(-1) : void 0;
|
|
18616
|
+
const tailTurn = tailWork !== void 0 ? tailWork.turn : tailMessage !== void 0 && "turn" in tailMessage ? tailMessage.turn : void 0;
|
|
18617
|
+
if (tailTurn === void 0) return void 0;
|
|
18618
|
+
const activity = openActivityOf(tailTurn);
|
|
18619
|
+
if (activity === void 0) return void 0;
|
|
18620
|
+
if (tailWork !== void 0) return expanded.some((block) => block.kind === "work" && block.span.owner === tailWork.owner) ? {
|
|
18621
|
+
rootOwner: activity.owner,
|
|
18622
|
+
workOwner: tailWork.owner
|
|
18623
|
+
} : void 0;
|
|
18624
|
+
if (tailMessage === void 0) return void 0;
|
|
18625
|
+
const primary = focusPrimaryRegionOfTurn(messages, activities, tailTurn);
|
|
18626
|
+
return primary !== void 0 && primary.members.includes(tailMessage) ? { rootOwner: activity.owner } : void 0;
|
|
17233
18627
|
}
|
|
17234
18628
|
/** Rows that remain visible outside the collapsed Thought as persistent
|
|
17235
18629
|
* input/context boundaries. The semantic class stays Context for injected
|
|
@@ -17242,50 +18636,25 @@ function isFocusPersistentInputRow(message) {
|
|
|
17242
18636
|
}
|
|
17243
18637
|
function collapsedFocusRowDisposition(message, index, leadBoundary, foldableSnapshots) {
|
|
17244
18638
|
if (!isFocusPersistentInputRow(message)) return "hidden";
|
|
17245
|
-
if (foldableSnapshots.thoughtOwned && index >= leadBoundary
|
|
18639
|
+
if (foldableSnapshots.thoughtOwned && index >= leadBoundary) {
|
|
18640
|
+
const carriage = workContextCarriageOf(message, foldableSnapshots.clusterByMember);
|
|
18641
|
+
if (carriage === "thought" || (carriage === "work" || carriage === "trailing-work") && foldableSnapshots.workByMember.has(message)) return "hidden";
|
|
18642
|
+
}
|
|
17246
18643
|
if (index >= leadBoundary && isNoticeContext(message)) return "post-thought";
|
|
17247
18644
|
return "pre-thought";
|
|
17248
18645
|
}
|
|
17249
|
-
/**
|
|
17250
|
-
* One turn's maximal run of CONSECUTIVE same-turn rows starting at `start`.
|
|
17251
|
-
* A turn-less entry (window summary) may SPLIT a turn into separate runs, and
|
|
17252
|
-
* the projection folds each run independently — this helper is shared by the
|
|
17253
|
-
* projection and the collapsed visibility predicate so their index and
|
|
17254
|
-
* `focusThoughtLeadBoundary` math can never diverge on a non-monotonic window.
|
|
17255
|
-
* @param messages - the transcript window.
|
|
17256
|
-
* @param start - the run's first index.
|
|
17257
|
-
* @param turn - the run's turn number.
|
|
17258
|
-
*/
|
|
17259
|
-
/**
|
|
17260
|
-
* The consecutive rows of ONE Focus projection turn, starting at `start`.
|
|
17261
|
-
*
|
|
17262
|
-
* Exported so a caller that needs the Focus disposition of a SINGLE row can
|
|
17263
|
-
* project that turn's own group instead of the whole loaded history (the search
|
|
17264
|
-
* seat's ancestry probe). It is the SAME segmentation `projectFocus` walks, so
|
|
17265
|
-
* the slice and the full projection can never disagree.
|
|
17266
|
-
*/
|
|
17267
|
-
function consecutiveTurnGroup(messages, start, turn) {
|
|
17268
|
-
const group = [messages[start]];
|
|
17269
|
-
let index = start + 1;
|
|
17270
|
-
while (index < messages.length) {
|
|
17271
|
-
const next = messages[index];
|
|
17272
|
-
if (focusProjectionTurnOf(next) !== turn) break;
|
|
17273
|
-
group.push(next);
|
|
17274
|
-
index += 1;
|
|
17275
|
-
}
|
|
17276
|
-
return group;
|
|
17277
|
-
}
|
|
17278
18646
|
/** The Thought-lead boundary of one turn group: the prefix that stays above the
|
|
17279
18647
|
* Thought. It starts after the FIRST unmarked user row when one exists; a turn
|
|
17280
18648
|
* with no human user (an inject-woken / next-turn wakeup turn) starts at the
|
|
17281
18649
|
* group beginning. In both cases the boundary then consumes leading surfaced
|
|
17282
|
-
* Context rows that are NOT
|
|
17283
|
-
* `
|
|
17284
|
-
*
|
|
17285
|
-
*
|
|
17286
|
-
*
|
|
17287
|
-
*
|
|
17288
|
-
*
|
|
18650
|
+
* Context rows that are NOT Thought/Work carriage candidates (the wakeup cause,
|
|
18651
|
+
* `instructions`, an independent or not-yet-attachable `catalog`, an
|
|
18652
|
+
* unqualified notice or relay). The first carried Context row (`thought` or
|
|
18653
|
+
* `work`) ends the foundation and becomes Thought content — so a next-turn
|
|
18654
|
+
* wakeup notice stays visible while the Snapshot and same-turn deliveries that
|
|
18655
|
+
* arrive during the work fold with it. A `trailing-work` catalog (and an
|
|
18656
|
+
* independent catalog) remains foundation content until a real preceding Work
|
|
18657
|
+
* exists and it is actually carried. A mixed
|
|
17289
18658
|
* `instructions`/`catalog` + Snapshot cluster keeps its indivisible foundation
|
|
17290
18659
|
* position. `llm/retry`/max-token orchestration rows are not surfaced Context,
|
|
17291
18660
|
* so they never enter the prefix. Without steer metadata the first user remains
|
|
@@ -17297,7 +18666,8 @@ function focusThoughtLeadBoundary(group) {
|
|
|
17297
18666
|
while (true) {
|
|
17298
18667
|
const member = group[end];
|
|
17299
18668
|
if (member === void 0 || !isSurfacedContext(member)) break;
|
|
17300
|
-
|
|
18669
|
+
const carriage = workContextCarriageOf(member, clusterByMember);
|
|
18670
|
+
if (carriage === "thought" || carriage === "work") break;
|
|
17301
18671
|
end += 1;
|
|
17302
18672
|
}
|
|
17303
18673
|
return end;
|
|
@@ -17531,7 +18901,7 @@ function summarizeWorkSpan(span) {
|
|
|
17531
18901
|
* nothing; an equal-time following row, by contrast, is already visible and
|
|
17532
18902
|
* closes the Activity from the same instant (a point span hides its duration —
|
|
17533
18903
|
* a coarse clock must never leave it live). A following block with NO proven
|
|
17534
|
-
* time (a local
|
|
18904
|
+
* time (a Client-local shell card, a synthetic window summary) keeps the span out of
|
|
17535
18905
|
* the live tail without closing it. The lookup is an exact offline 2D
|
|
17536
18906
|
* dominance-min, so no ordering assumption about the Activities' starts is
|
|
17537
18907
|
* needed.
|
|
@@ -17540,15 +18910,15 @@ function summarizeWorkSpan(span) {
|
|
|
17540
18910
|
* end after its turn, so a row of a later turn can never lengthen an
|
|
17541
18911
|
* already-frozen Activity.
|
|
17542
18912
|
*
|
|
17543
|
-
* KNOWN LIMIT (
|
|
17544
|
-
*
|
|
17545
|
-
*
|
|
17546
|
-
* hydration
|
|
17547
|
-
*
|
|
17548
|
-
*
|
|
17549
|
-
*
|
|
17550
|
-
*
|
|
17551
|
-
*
|
|
18913
|
+
* KNOWN LIMIT: the canonical Work MEMBERSHIP (which Process rows share one
|
|
18914
|
+
* span) is decided by the display-order authority — `projectTranscriptStructure`
|
|
18915
|
+
* plus the fold's lane/read-group convergence — never by this clock. A cold
|
|
18916
|
+
* hydration materializes a settlement at its raw log position while the live
|
|
18917
|
+
* lane may have projected its first visible text earlier; the existing
|
|
18918
|
+
* convergence mechanism and its live/cold parity tests supply the qualified
|
|
18919
|
+
* order. This clock derives lifetimes from the rows that authority already
|
|
18920
|
+
* ordered; it never reorders membership and never fabricates a boundary from
|
|
18921
|
+
* an unqualified row position.
|
|
17552
18922
|
* @param structure - the canonical structural blocks for one window.
|
|
17553
18923
|
* @param turnActivities - the folded turn boundary facts of the SAME snapshot.
|
|
17554
18924
|
*/
|
|
@@ -17666,8 +19036,9 @@ function interactionBoundaryOf(span) {
|
|
|
17666
19036
|
/** The first ACTUALLY VISIBLE time of one non-Process boundary block: the
|
|
17667
19037
|
* earliest reliable sidecar start among the row(s) that carry the boundary.
|
|
17668
19038
|
* `undefined` means the block has no provable first-visible evidence (a
|
|
17669
|
-
* synthetic window summary,
|
|
17670
|
-
*
|
|
19039
|
+
* synthetic window summary, or a row the fold could not time) — the Activity
|
|
19040
|
+
* then stays open rather than freezing at a fabricated time. A real command
|
|
19041
|
+
* row carries its own point sidecar and therefore closes the Activity. */
|
|
17671
19042
|
function boundaryTimeOf(block) {
|
|
17672
19043
|
if (block.kind === "message") return transcriptTimingOf(block.message)?.startedAt;
|
|
17673
19044
|
if (block.kind === "context-cluster") {
|
|
@@ -19285,11 +20656,19 @@ function toolNode(message, key, options) {
|
|
|
19285
20656
|
}, ...body.args, ...children, ...body.result);
|
|
19286
20657
|
}
|
|
19287
20658
|
/**
|
|
19288
|
-
* The safe body of one injected Context row
|
|
19289
|
-
*
|
|
19290
|
-
*
|
|
19291
|
-
|
|
19292
|
-
|
|
20659
|
+
* The safe body of one injected Context row.
|
|
20660
|
+
*
|
|
20661
|
+
* An image-bearing `ptc-mode` Context renders its ORIGINAL structured content
|
|
20662
|
+
* through the same ordered body path User/Assistant messages use: text blocks
|
|
20663
|
+
* stay text and each image block becomes its identity line plus (when the pane
|
|
20664
|
+
* negotiated native images) the shared `ui.image` node. The flat text is not
|
|
20665
|
+
* painted beside it — it carries the same markers and would duplicate them.
|
|
20666
|
+
* Every other Context keeps the existing `systemContextBody` XML-envelope
|
|
20667
|
+
* treatment (never a raw `<system-reminder>` frame), with a body that is not an
|
|
20668
|
+
* envelope shown verbatim.
|
|
20669
|
+
*/
|
|
20670
|
+
function contextBodyNodes(message, options) {
|
|
20671
|
+
if (isPtcImageContext(message)) return bodyContentNodes(message.content, options);
|
|
19293
20672
|
const body = systemContextBody(message.text);
|
|
19294
20673
|
if (body === void 0) return [ui.md({
|
|
19295
20674
|
key: "body",
|
|
@@ -19301,7 +20680,7 @@ function contextBodyNodes(message) {
|
|
|
19301
20680
|
text: sanitizeDisplayText(body.join("\n"))
|
|
19302
20681
|
})];
|
|
19303
20682
|
}
|
|
19304
|
-
function contextMemberNode(message, key) {
|
|
20683
|
+
function contextMemberNode(message, key, options) {
|
|
19305
20684
|
const kind = contextPresentationKind(message);
|
|
19306
20685
|
const head = sanitizedPhysicalLine(message.label ?? contextFormOf(message) ?? "Context");
|
|
19307
20686
|
return ui.card({
|
|
@@ -19310,7 +20689,7 @@ function contextMemberNode(message, key) {
|
|
|
19310
20689
|
}, ui.badge({
|
|
19311
20690
|
key: "kind",
|
|
19312
20691
|
text: kind ?? "generic"
|
|
19313
|
-
}), ...contextBodyNodes(message));
|
|
20692
|
+
}), ...contextBodyNodes(message, options));
|
|
19314
20693
|
}
|
|
19315
20694
|
function contextClusterMemberNode(message, key, options) {
|
|
19316
20695
|
const kind = contextPresentationKind(message);
|
|
@@ -19324,14 +20703,14 @@ function contextClusterMemberNode(message, key, options) {
|
|
|
19324
20703
|
key: "identity",
|
|
19325
20704
|
text: head,
|
|
19326
20705
|
wrap: "none"
|
|
19327
|
-
}), ...contextBodyNodes(message));
|
|
20706
|
+
}), ...contextBodyNodes(message, options));
|
|
19328
20707
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19329
20708
|
return ui.section({
|
|
19330
20709
|
key,
|
|
19331
20710
|
head,
|
|
19332
20711
|
collapsible: true,
|
|
19333
20712
|
collapsed: !expanded
|
|
19334
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20713
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19335
20714
|
}
|
|
19336
20715
|
function canCollapseContextRow(message) {
|
|
19337
20716
|
const kind = contextPresentationKind(message);
|
|
@@ -19388,7 +20767,7 @@ function relayContextRowNode(message, key, options, allowDisclosure) {
|
|
|
19388
20767
|
if (!allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return ui.card({
|
|
19389
20768
|
key,
|
|
19390
20769
|
head: title
|
|
19391
|
-
}, ...contextBodyNodes(message));
|
|
20770
|
+
}, ...contextBodyNodes(message, options));
|
|
19392
20771
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19393
20772
|
const preview = relayHeadPreview(sanitizeDisplayText(message.text));
|
|
19394
20773
|
return ui.section({
|
|
@@ -19413,13 +20792,13 @@ function relayContextRowNode(message, key, options, allowDisclosure) {
|
|
|
19413
20792
|
})]),
|
|
19414
20793
|
collapsible: true,
|
|
19415
20794
|
collapsed: !expanded
|
|
19416
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20795
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19417
20796
|
}
|
|
19418
20797
|
function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
19419
20798
|
const disclosure = options.innerDisclosure;
|
|
19420
20799
|
const kind = contextPresentationKind(message);
|
|
19421
20800
|
if (message.context === true && kind === "relay") return relayContextRowNode(message, key, options, allowDisclosure);
|
|
19422
|
-
if (message.context !== true || !allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return contextMemberNode(message, key);
|
|
20801
|
+
if (message.context !== true || !allowDisclosure || disclosure === void 0 || !canCollapseContextRow(message)) return contextMemberNode(message, key, options);
|
|
19423
20802
|
const expanded = disclosure.expandedContextRowOwners.has(message);
|
|
19424
20803
|
if (kind === "notice") {
|
|
19425
20804
|
const title = message.label === void 0 || message.label === "" ? "Notice" : sanitizedPhysicalLine(message.label);
|
|
@@ -19439,7 +20818,7 @@ function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
|
19439
20818
|
})]),
|
|
19440
20819
|
collapsible: true,
|
|
19441
20820
|
collapsed: !expanded
|
|
19442
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20821
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19443
20822
|
}
|
|
19444
20823
|
const identity = kind === "recall" ? message.label === void 0 || message.label === "" ? "Session recall" : `Session recall · ${sanitizedPhysicalLine(message.label)}` : message.label ?? contextFormOf(message) ?? "Context";
|
|
19445
20824
|
return ui.section({
|
|
@@ -19447,7 +20826,7 @@ function contextRowNode(message, key, options, allowDisclosure = true) {
|
|
|
19447
20826
|
head: sanitizedPhysicalLine(identity),
|
|
19448
20827
|
collapsible: true,
|
|
19449
20828
|
collapsed: !expanded
|
|
19450
|
-
}, ...expanded ? contextBodyNodes(message) : []);
|
|
20829
|
+
}, ...expanded ? contextBodyNodes(message, options) : []);
|
|
19451
20830
|
}
|
|
19452
20831
|
function systemNode(message, key, options, allowDisclosure = true) {
|
|
19453
20832
|
if (message.context === true) return contextRowNode(message, key, options, allowDisclosure);
|
|
@@ -20095,7 +21474,8 @@ function imageRefIdsOf(message) {
|
|
|
20095
21474
|
if (message.displayBlocks !== void 0) {
|
|
20096
21475
|
for (const display of message.displayBlocks) if (display.kind === "content") pushBlocks([display.block]);
|
|
20097
21476
|
} else if (message.content !== void 0) pushBlocks(message.content);
|
|
20098
|
-
} else if (message.kind === "
|
|
21477
|
+
} else if (message.kind === "system") pushBlocks(message.content);
|
|
21478
|
+
else if (message.kind === "tool") visitRow(message);
|
|
20099
21479
|
imageRefIdsCache.set(message, {
|
|
20100
21480
|
display,
|
|
20101
21481
|
assistant,
|
|
@@ -20203,6 +21583,7 @@ function messageStampOf(message, key, options) {
|
|
|
20203
21583
|
break;
|
|
20204
21584
|
case "system":
|
|
20205
21585
|
parts.push(disclosureTokenOf(message, key, options));
|
|
21586
|
+
parts.push(imageTokensOf(message, options));
|
|
20206
21587
|
break;
|
|
20207
21588
|
case "command":
|
|
20208
21589
|
case "compaction":
|
|
@@ -20284,6 +21665,17 @@ function focusDuration(activity, options) {
|
|
|
20284
21665
|
const duration = formatCompactDuration(options.focusElapsedMs?.get(activity));
|
|
20285
21666
|
return duration === "0s" ? void 0 : duration;
|
|
20286
21667
|
}
|
|
21668
|
+
/** The bounded one-line collapsed Action body the Focus root head paints (and
|
|
21669
|
+
* the root stamp must follow): the SAME derivation for the head and the stamp,
|
|
21670
|
+
* never a content hash. */
|
|
21671
|
+
function focusRootActionBody(action, options) {
|
|
21672
|
+
if (action === void 0) return void 0;
|
|
21673
|
+
const body = compactActionBody(compactActionPresentation(action, {
|
|
21674
|
+
...options.toolPresenter === void 0 ? {} : { presenter: options.toolPresenter },
|
|
21675
|
+
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
21676
|
+
}));
|
|
21677
|
+
return body === void 0 ? void 0 : sanitizedPhysicalLine(body);
|
|
21678
|
+
}
|
|
20287
21679
|
function focusRootHead(slot, options) {
|
|
20288
21680
|
const phase = options.focusPhase ?? "working";
|
|
20289
21681
|
const duration = focusDuration(slot.activity, options);
|
|
@@ -20315,10 +21707,7 @@ function focusRootHead(slot, options) {
|
|
|
20315
21707
|
index: preview.index,
|
|
20316
21708
|
...preview.name === void 0 ? {} : { name: preview.name }
|
|
20317
21709
|
})));
|
|
20318
|
-
const action =
|
|
20319
|
-
...options.toolPresenter === void 0 ? {} : { presenter: options.toolPresenter },
|
|
20320
|
-
...options.cwd === void 0 ? {} : { cwd: options.cwd }
|
|
20321
|
-
}));
|
|
21710
|
+
const action = focusRootActionBody(slot.action, options);
|
|
20322
21711
|
if (preparing !== void 0 || action !== void 0) head.push(ui.text({
|
|
20323
21712
|
key: "action",
|
|
20324
21713
|
text: sanitizedPhysicalLine(`Action: ${preparing ?? action}`),
|
|
@@ -20397,7 +21786,7 @@ function focusNestedWorkDescriptor(span, keys, options, prefix, lifetime, prepar
|
|
|
20397
21786
|
materialize: () => focusNestedWorkNode(span, keys, options, prefix, lifetime, preparing)
|
|
20398
21787
|
};
|
|
20399
21788
|
}
|
|
20400
|
-
function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, preparingByWorkOwner, standalonePreparing, workLifetimes) {
|
|
21789
|
+
function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, preparingByWorkOwner, standalonePreparing, attachedPreparingRootOwner, workLifetimes) {
|
|
20401
21790
|
const slotsByOwner = /* @__PURE__ */ new Map();
|
|
20402
21791
|
const rootsWithWorkPreparing = /* @__PURE__ */ new Set();
|
|
20403
21792
|
const rows = [];
|
|
@@ -20438,11 +21827,20 @@ function focusMainBlocks(blocks, keys, options, prefix, preparingByRootOwner, pr
|
|
|
20438
21827
|
slot.children.push(focusNestedWorkDescriptor(block.span, keys, options, prefix, workLifetimes.get(block.span.owner), preparingByWorkOwner.get(block.span.owner) ?? []));
|
|
20439
21828
|
}
|
|
20440
21829
|
}
|
|
21830
|
+
const deferredStandalone = [];
|
|
20441
21831
|
for (const slot of slotsByOwner.values()) {
|
|
20442
21832
|
if (!slot.expanded || slot.preparing.length === 0 || rootsWithWorkPreparing.has(slot.owner)) continue;
|
|
20443
|
-
|
|
21833
|
+
if (attachedPreparingRootOwner === slot.owner) {
|
|
21834
|
+
slot.children.push(...slot.preparing.map((preview) => preparingDescriptor(preview, options.cwd, "")));
|
|
21835
|
+
continue;
|
|
21836
|
+
}
|
|
21837
|
+
deferredStandalone.push(...slot.preparing);
|
|
20444
21838
|
}
|
|
20445
|
-
return [
|
|
21839
|
+
return [
|
|
21840
|
+
...rows.map((row) => "draft" in row ? focusRootDescriptor(row, keys, options, prefix) : row),
|
|
21841
|
+
...standalonePreparing.map((preview) => preparingDescriptor(preview, options.cwd, prefix)),
|
|
21842
|
+
...deferredStandalone.map((preview) => preparingDescriptor(preview, options.cwd, prefix))
|
|
21843
|
+
];
|
|
20446
21844
|
}
|
|
20447
21845
|
/** The ONE Focus Activity root descriptor (canonical occurrence owner). */
|
|
20448
21846
|
function focusRootDescriptor(slot, keys, options, prefix) {
|
|
@@ -20459,6 +21857,9 @@ function focusRootDescriptor(slot, keys, options, prefix) {
|
|
|
20459
21857
|
];
|
|
20460
21858
|
for (const preview of slot.preparing) stamp.push(...preparingStampOf(preview, options.cwd));
|
|
20461
21859
|
for (const child of slot.children) stamp.push(...child.stamp);
|
|
21860
|
+
for (const part of compactActionStatParts(slot.actionStats)) stamp.push(sanitizedPhysicalLine(part));
|
|
21861
|
+
const actionBody = focusRootActionBody(slot.action, options);
|
|
21862
|
+
if (actionBody !== void 0) stamp.push(actionBody);
|
|
20462
21863
|
if (slot.action !== void 0) stamp.push(options.cwd ?? "");
|
|
20463
21864
|
return {
|
|
20464
21865
|
key,
|
|
@@ -20483,48 +21884,72 @@ function focusRootDescriptor(slot, keys, options, prefix) {
|
|
|
20483
21884
|
}
|
|
20484
21885
|
};
|
|
20485
21886
|
}
|
|
20486
|
-
/** Preparing belongs either to the exact canonical trailing Work owner, to
|
|
20487
|
-
*
|
|
21887
|
+
/** Preparing belongs either to the exact canonical trailing Work owner, to the
|
|
21888
|
+
* ONE open logical Turn whose region reaches the raw tail, or stays standalone.
|
|
21889
|
+
* A Turn whose collapsed summary still owns the Action slot while an independent
|
|
21890
|
+
* trailing control boundary sits outside its region is reported as a header-only
|
|
21891
|
+
* root: `attachedPreparingRootOwner` is then absent so an EXPANDED root renders
|
|
21892
|
+
* the live run standalone after that boundary instead of fabricating ancestry.
|
|
21893
|
+
*/
|
|
20488
21894
|
function focusPreparingPlacement(messages, blocks, options) {
|
|
20489
21895
|
const groups = groupPreparingPreviews(options.preparingPreviews ?? []);
|
|
20490
21896
|
if (groups.length === 0 || options.window?.hasNewer !== false) return {
|
|
20491
21897
|
byRootOwner: /* @__PURE__ */ new Map(),
|
|
20492
21898
|
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
20493
|
-
standalone: []
|
|
21899
|
+
standalone: [],
|
|
21900
|
+
attachedRootOwner: void 0
|
|
20494
21901
|
};
|
|
20495
21902
|
const activities = options.turnActivities ?? EMPTY_TURN_ACTIVITIES;
|
|
20496
21903
|
const expandedBlocks = projectFocus(messages, activities, new Set(activities.keys()), true);
|
|
20497
21904
|
const trailing = projectTranscriptStructure(messages).at(-1);
|
|
20498
|
-
|
|
20499
|
-
|
|
21905
|
+
const placement = focusLiveTailPlacement(messages, activities, expandedBlocks);
|
|
21906
|
+
const placementTurn = placement === void 0 || !("turn" in placement.rootOwner) ? void 0 : placement.rootOwner.turn;
|
|
21907
|
+
const rootOfTurn = (turn) => {
|
|
21908
|
+
const projected = expandedBlocks.find((block) => block.kind === "activity" && block.activity.turn === turn);
|
|
21909
|
+
return projected?.kind === "activity" ? projected.owner : void 0;
|
|
21910
|
+
};
|
|
21911
|
+
const standalone = () => ({
|
|
21912
|
+
byRootOwner: /* @__PURE__ */ new Map(),
|
|
21913
|
+
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
21914
|
+
standalone: groups.flatMap(([, previews]) => previews),
|
|
21915
|
+
attachedRootOwner: void 0
|
|
21916
|
+
});
|
|
21917
|
+
const selectionFor = (turn) => groups.find(([groupTurn]) => groupTurn === turn)?.[1] ?? [];
|
|
20500
21918
|
let turn;
|
|
21919
|
+
let workOwner;
|
|
21920
|
+
let attachedRootOwner;
|
|
20501
21921
|
if (trailing?.kind === "work") {
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20506
|
-
|
|
20507
|
-
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
}
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
|
|
21922
|
+
if (placement?.workOwner !== void 0 && placement.workOwner === trailing.span.owner) {
|
|
21923
|
+
turn = placementTurn;
|
|
21924
|
+
attachedRootOwner = placement.rootOwner;
|
|
21925
|
+
workOwner = placement.workOwner;
|
|
21926
|
+
}
|
|
21927
|
+
} else if (placement !== void 0) {
|
|
21928
|
+
turn = placementTurn;
|
|
21929
|
+
attachedRootOwner = placement.rootOwner;
|
|
21930
|
+
}
|
|
21931
|
+
if (turn === void 0) {
|
|
21932
|
+
const openPreviewTurn = groups.map(([groupTurn]) => groupTurn).filter((groupTurn) => activities.get(groupTurn)?.completed === false).at(-1);
|
|
21933
|
+
const rootOwner = openPreviewTurn === void 0 ? void 0 : rootOfTurn(openPreviewTurn);
|
|
21934
|
+
const selected = openPreviewTurn === void 0 ? [] : selectionFor(openPreviewTurn);
|
|
21935
|
+
if (rootOwner === void 0 || openPreviewTurn === void 0 || selected.length === 0 || !blocks.some((block) => block.kind === "activity" && block.owner === rootOwner)) return {
|
|
21936
|
+
...standalone(),
|
|
21937
|
+
standalone: [...groups.filter(([groupTurn]) => groupTurn !== openPreviewTurn).flatMap(([, previews]) => previews), ...selected]
|
|
21938
|
+
};
|
|
21939
|
+
return {
|
|
21940
|
+
byRootOwner: /* @__PURE__ */ new Map([[rootOwner, selected]]),
|
|
21941
|
+
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
21942
|
+
standalone: groups.filter(([groupTurn]) => groupTurn !== openPreviewTurn).flatMap(([, previews]) => previews),
|
|
21943
|
+
attachedRootOwner: void 0
|
|
21944
|
+
};
|
|
20517
21945
|
}
|
|
20518
|
-
if (
|
|
20519
|
-
|
|
20520
|
-
byWorkOwner: /* @__PURE__ */ new Map(),
|
|
20521
|
-
standalone: groups.flatMap(([, previews]) => previews)
|
|
20522
|
-
};
|
|
20523
|
-
const selected = groups.find(([groupTurn]) => groupTurn === turn)?.[1] ?? [];
|
|
21946
|
+
if (attachedRootOwner === void 0 || !blocks.some((block) => block.kind === "activity" && block.owner === attachedRootOwner)) return standalone();
|
|
21947
|
+
const selected = selectionFor(turn);
|
|
20524
21948
|
return {
|
|
20525
|
-
byRootOwner: selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[
|
|
21949
|
+
byRootOwner: selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[attachedRootOwner, selected]]),
|
|
20526
21950
|
byWorkOwner: workOwner === void 0 || selected.length === 0 ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Map([[workOwner, selected]]),
|
|
20527
|
-
standalone: groups.filter(([groupTurn]) => groupTurn !== turn).flatMap(([, previews]) => previews)
|
|
21951
|
+
standalone: groups.filter(([groupTurn]) => groupTurn !== turn).flatMap(([, previews]) => previews),
|
|
21952
|
+
attachedRootOwner
|
|
20528
21953
|
};
|
|
20529
21954
|
}
|
|
20530
21955
|
/** The members whose current transcript body is actually materialized. */
|
|
@@ -20696,9 +22121,10 @@ function settledFinalAssistantStats(messages, activities) {
|
|
|
20696
22121
|
if (activities === void 0) return EMPTY_ASSISTANT_STATS;
|
|
20697
22122
|
const rowsByTurn = /* @__PURE__ */ new Map();
|
|
20698
22123
|
for (const message of messages) {
|
|
20699
|
-
|
|
20700
|
-
|
|
20701
|
-
|
|
22124
|
+
const turn = transcriptTurnOf(message);
|
|
22125
|
+
if (turn === void 0) continue;
|
|
22126
|
+
const rows = rowsByTurn.get(turn);
|
|
22127
|
+
if (rows === void 0) rowsByTurn.set(turn, [message]);
|
|
20702
22128
|
else rows.push(message);
|
|
20703
22129
|
}
|
|
20704
22130
|
const result = /* @__PURE__ */ new Map();
|
|
@@ -20785,7 +22211,7 @@ function describeTranscriptMainBlocksForPreset(messages, keys, options) {
|
|
|
20785
22211
|
const focusBlocks = projectFocus(messages, options.turnActivities ?? EMPTY_TURN_ACTIVITIES, options.expandedFocusTurns ?? EMPTY_TURN_SET, true);
|
|
20786
22212
|
const workLifetimes = resolveWorkLifetimes(structure, options.turnActivities ?? EMPTY_TURN_ACTIVITIES);
|
|
20787
22213
|
const preparing = focusPreparingPlacement(messages, focusBlocks, options);
|
|
20788
|
-
return focusMainBlocks(focusBlocks, keys, renderOptions, prefix, preparing.byRootOwner, preparing.byWorkOwner, preparing.standalone, workLifetimes);
|
|
22214
|
+
return focusMainBlocks(focusBlocks, keys, renderOptions, prefix, preparing.byRootOwner, preparing.byWorkOwner, preparing.standalone, preparing.attachedRootOwner, workLifetimes);
|
|
20789
22215
|
}
|
|
20790
22216
|
return legacyMainBlocks(structure, keys, renderOptions, prefix, trailing, adopted, standalone);
|
|
20791
22217
|
}
|
|
@@ -20824,4 +22250,4 @@ const EMPTY_TURN_SET = /* @__PURE__ */ new Set();
|
|
|
20824
22250
|
const EMPTY_TURN_ACTIVITIES = /* @__PURE__ */ new Map();
|
|
20825
22251
|
const EMPTY_ASSISTANT_STATS = /* @__PURE__ */ new Map();
|
|
20826
22252
|
//#endregion
|
|
20827
|
-
export {
|
|
22253
|
+
export { advanceWorkflowDisclosureState as $, TSP_VISUAL_COPY_LABEL as $n, effectiveCustomCommandRefreshMs as $r, imageFoldedPreview as $t, summarizeWorkSpan as A, userBlocksVisibleNow as Ai, WELCOME_WHALE_WIDTH as An, suggestPathArgument as Ar, workspaceRowStatusLabel as At, workContextCarriageOf as B, shortCwd as Bn, createSessionScopeAuthority as Br, viewerAccessHint as Bt, proveCaretEdit as C, isSurfacedContext as Ci, iconLead as Cn, taskStatusWord as Cr, assistantVisualPresentationRevision as Ct, contextClusterSummaryParts as D, finalizedBlockFallbackText as Di, sessionBrowserErrorNotice as Dn, sanitizeDisplaySegment as Dr, buildSessionWorkspaceView as Dt, FocusTimingStore as E, latestLine as Ei, sanitizeTerminalText as En, sanitizeDisplayLog as Er, buildSessionInspectorView as Et, focusProjectionTurnOf as F, FooterCustomItemCatalog as Fn, queueManagerCommandResult as Fr, subagentJobTranscriptId as Ft, compactActionPresentation as G, QUEUE_CHORDS as Gn, TSP_FOOTER_NOTICES as Gr, compactToolExpandedLines as Gt, FocusActivityComponent as H, HISTORY_CHORDS as Hn, detectThemeFromBackground as Hr, GOAL_TOOL_NAMES as Ht, projectFocus as I, createBuiltinFooterRegistry as In, formatBytes as Ir, subagentJobViewHint as It, compactActionStatsSignature as J, SVG_VIEWER_SCROLL_LABEL as Jn, DEFAULT_CUSTOM_COMMAND_REFRESH_MS as Jr, foldedCallPreview as Jt, compactActionSignature as K, SESSION_WORKSPACE_CHORDS as Kn, resolveTspNativeFooterConfig as Kr, compactToolPresentation as Kt, clusterByMemberOf as L, modelItem as Ln, SessionOperationBarrier as Lr, taskRowLabel as Lt, focusHeldBackFinalByTurn as M, historyFilePath as Mi, renderWelcomeWhaleLines as Mn, clientPathQueryEnvironment as Mr, isTaskItemFailure as Mt, focusLiveTailPlacement as N, loadHistoryFile as Ni, welcomeWhaleGradientColors as Nn, QueueManagerController as Nr, projectTaskItems as Nt, activityClockOf as O, openOpaqueBlockFallbackText as Oi, workspaceKey as On, sanitizeDisplayText as Or, currentWorkspaceOf as Ot, focusMaterializedMessages as P, loadHistoryRecords as Pi, welcomeWhalePlainLines as Pn, attachmentCountLabel as Pr, rowGroup as Pt, createDisplayProjection as Q, TSP_VISUAL_CHORDS as Qn, customItemName as Qr, goalResultSummary as Qt, projectTranscriptStructure as R, tasksItem as Rn, TransitionInProgressError as Rr, taskRowSelectionDisposition as Rt, pastedBodySpan as S, isPtcImageContext as Si, iconFor as Sn, taskStatusColor as Sr, assistantVisualPresentation as St, isLocalShellCard as T, transcriptTurnOf as Ti, formatSessionAge as Tn, singlePhysicalLine as Tr, setAssistantVisualPresentation as Tt, compactActionStatParts as U, JOB_LOCAL_KEYS as Un, lightColors as Ur, askAnswersLines as Ut, contextPresentationKind as V, DELIVERED_FILES_CHORDS as Vn, darkColors as Vr, FOLDED_JSON_RESULT_TOOLS as Vt, formatCompactDuration as W, JOB_SEARCH_LOCAL_KEYS as Wn, withSearchCurrentTokens as Wr, askAnswersSummary as Wt, compactSlotLine as X, TSP_SEARCH_CHORD as Xn, customCommandConfigOf as Xr, genericRawInputLines as Xt, compactPreparingSummary as Y, TSP_CONTINUED_INSPECTION_LABEL as Yn, activeFooterItemIds as Yr, foldedResultSummaryFor as Yt, compactThinkSlotLine as Z, TSP_SEARCH_CHORD_LABEL as Zn, customItemId as Zr, goalResultLines as Zt, VISUAL_COPY_ROLE as _, rawSourceRangeForNormalizedMatch as _i, webCardLines as _n, editorTheme as _r, serializedDraftHasPayload as _t, dockDraftImageNodes as a, resolveTrustedFooterCommand as ai, parseWriteEnvelope as an, parseShellWords as ar, workflowRunViewAllVisible as at, publishedVisualTitle as b, workflowReadablePhase as bi, imageProtocolPreference as bn, setTheme as br, createHistoryRecallScope as bt, imageRefProblem as c, resolveUserLayerFooterMode as ci, resultTextLines as cn, builtInGuide as cr, createInstalledAutocompleteProvider as ct, visibleTranscriptMembers as d, assistantPresentationRevision as di, systemContextBody as dn, initialEffortOf as dr, isOpenQuotedToken as dt, effectiveCustomCommandTimeoutMs as ei, isCompactActionTool as en, TSP_VISUAL_SELECT_LABEL as er, effectiveWorkflowPhaseOpen as et, TSP_WORKFLOW_BROWSE_ACTION as f, assistantStepOf as fi, toolCardHeader as fn, modelIdentity as fr, splitQueryRemainder as ft, VISUAL_COPY_KEY as g, TranscriptWindowController as gi, toolTitle as gn, currentPalette as gr, serializeEditorInput as gt, VISUAL_COPY_ACTION as h, textOf as hi, toolSummaryKeys as hn, color as hr, editorModeFromHistoryEntry as ht, describeTranscriptMainBlocksForPreset as i, parseFooterCommandConfig as ii, parseSkillEnvelope as in, matchesKeyId as ir, workflowRunSummaryText as it, projectCompact as j, appendHistoryRecord as ji, pickWelcomeWhaleVariant as jn, ClientLocalDiscoveryDriver as jr, isTaskItemActive as jt, resolveWorkLifetimes as k, textWithAttachmentMarkers as ki, classifySessionBrowserRow as kn, FILE_ARGUMENT_COMMANDS as kr, visibleWorkspaceBrowserRows as kt, toolRowImageBlocks as l, MAX_COMMAND_TIMEOUT_MS as li, skillFoldedPreview as ln, PROVIDER_DEFAULT as lr, classifyFileCompletionContext as lt, transcriptCopyPayload as m, subCallDisplayStatus as mi, toolPresenterFrom as mn, HOST_MARKDOWN_OPTIONS as mr, extractInlineSkillPrefix as mt, TranscriptNodeKeys as n, parseFooterCustomItem as ni, parseImageEnvelope as nn, formatKeyId as nr, workflowCountsText as nt, imageDisplayName as o, resolveUserCommandItemActivationIds as oi, readFoldedPreview as on, isBuiltInPresetRow as or, workflowStatusCounts as ot, TRANSCRIPT_COPY_ACTION as p, childOwnEvents as pi, toolIconSemantic as pn, projectModelDirectory as pr, splitTokenRemainder as pt, compactActionSlotLine as q, SVG_VIEWER_CHORDS as qn, CUSTOM_FOOTER_ITEM_PREFIX as qr, firstLine as qt, describeTranscriptMainBlocks as r, parseFooterCustomItems as ri, parseReadEnvelopes as rn, formatLeaderSequence as rr, workflowPhasePresentations as rt, imageIdentityText as s, resolveUserCommandItemFallbackActivationIds as si, relativizeToCwd as sn, presetDisplayText as sr, eligibleFinalAssistant as st, MAX_IMAGE_BLOB_BYTES as t, executableCommandItemIds as ti, parseCallPreview as tn, formatHintKeys as tr, effectiveWorkflowRunOpen as tt, toolRowProjectsImages as u, TranscriptFolder as ui, subagentModelDisplay as un, effortChoicesOf as ur, stripAtQuotes as ut, VISUAL_FIGURE_KEY_PREFIX as v, transcriptSearchMatchKey as vi, writeFoldedPreview as vn, markdownTheme as vr, shellPrefixForMode as vt, candidateImagePathFromPaste as w, isSurfacedInteractionTool as wi, iconPrefix as wn, sanitizedPhysicalLine as wr, clearAssistantVisualPresentation as wt, PasteRangeTracker as x, recentTurnThreshold as xi, thinkingPreviewTail as xn, settingsListTheme as xr, planVisualPlacement as xt, VISUAL_FIGURE_ROLE as y, transcriptSearchSourceKey as yi, fileAttachmentSummary as yn, selectListTheme as yr, FileHistorySearchSource as yt, workByMemberOf as z, FooterItemRegistry as zn, SessionScopeSupersededError as zr, taskTreePrefix as zt };
|