zcode-app-cli 3.14.3-27 → 3.14.4-29
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.md +18 -0
- package/bin/zcode.js +2 -0
- package/package.json +2 -2
- package/vendor/cli-config.cjs +560 -0
- package/vendor/extraction.json +14 -4
- package/vendor/node_modules/@zcode/tui/dist/index.js +535 -37
- package/vendor/packages/node-repl-host/dist/mcp/server.js +1 -1
- package/vendor/zcode.cjs +5 -5
- package/zcode-runtime.lock.json +3 -3
|
@@ -162650,6 +162650,9 @@ var InputQueue = class {
|
|
|
162650
162650
|
pendingResolutions = /* @__PURE__ */ new Map();
|
|
162651
162651
|
completedTurnIds = /* @__PURE__ */ new Set();
|
|
162652
162652
|
autoSendEnabled = true;
|
|
162653
|
+
pausedByUser = false;
|
|
162654
|
+
nextId = 1;
|
|
162655
|
+
ids = /* @__PURE__ */ new WeakMap();
|
|
162653
162656
|
constructor(callbacks) {
|
|
162654
162657
|
this.callbacks = callbacks;
|
|
162655
162658
|
}
|
|
@@ -162675,6 +162678,43 @@ var InputQueue = class {
|
|
|
162675
162678
|
hasFollowUps() {
|
|
162676
162679
|
return this.queuedFollowUps.length > 0;
|
|
162677
162680
|
}
|
|
162681
|
+
entries() {
|
|
162682
|
+
return this.queuedFollowUps.map((submission) => {
|
|
162683
|
+
let id = this.ids.get(submission);
|
|
162684
|
+
if (id === void 0) {
|
|
162685
|
+
id = this.nextId++;
|
|
162686
|
+
this.ids.set(submission, id);
|
|
162687
|
+
}
|
|
162688
|
+
return {
|
|
162689
|
+
id,
|
|
162690
|
+
displayInput: submission.displayInput,
|
|
162691
|
+
editable: !submission.pendingInputIds?.length
|
|
162692
|
+
};
|
|
162693
|
+
});
|
|
162694
|
+
}
|
|
162695
|
+
remove(id) {
|
|
162696
|
+
const index = this.queuedFollowUps.findIndex((submission) => this.ids.get(submission) === id);
|
|
162697
|
+
if (index < 0 || this.queuedFollowUps[index]?.pendingInputIds?.length) return void 0;
|
|
162698
|
+
const [submission] = this.queuedFollowUps.splice(index, 1);
|
|
162699
|
+
this.syncView();
|
|
162700
|
+
return submission;
|
|
162701
|
+
}
|
|
162702
|
+
move(id, offset) {
|
|
162703
|
+
const index = this.queuedFollowUps.findIndex((submission) => this.ids.get(submission) === id);
|
|
162704
|
+
const next = index + offset;
|
|
162705
|
+
if (index < 0 || next < 0 || next >= this.queuedFollowUps.length) return false;
|
|
162706
|
+
if (this.queuedFollowUps[index]?.pendingInputIds?.length || this.queuedFollowUps[next]?.pendingInputIds?.length) return false;
|
|
162707
|
+
[this.queuedFollowUps[index], this.queuedFollowUps[next]] = [this.queuedFollowUps[next], this.queuedFollowUps[index]];
|
|
162708
|
+
this.syncView();
|
|
162709
|
+
return true;
|
|
162710
|
+
}
|
|
162711
|
+
get paused() {
|
|
162712
|
+
return this.pausedByUser;
|
|
162713
|
+
}
|
|
162714
|
+
set paused(value) {
|
|
162715
|
+
this.pausedByUser = value;
|
|
162716
|
+
this.syncView();
|
|
162717
|
+
}
|
|
162678
162718
|
hasPendingSteers() {
|
|
162679
162719
|
return this.pendingSteers.length > 0;
|
|
162680
162720
|
}
|
|
@@ -162682,7 +162722,7 @@ var InputQueue = class {
|
|
|
162682
162722
|
return this.pendingSteers.flatMap(({ admitted, pendingInputId }) => admitted && pendingInputId ? [pendingInputId] : []);
|
|
162683
162723
|
}
|
|
162684
162724
|
get autoSend() {
|
|
162685
|
-
return this.autoSendEnabled;
|
|
162725
|
+
return this.autoSendEnabled && !this.pausedByUser;
|
|
162686
162726
|
}
|
|
162687
162727
|
set autoSend(value) {
|
|
162688
162728
|
this.autoSendEnabled = value;
|
|
@@ -162852,7 +162892,8 @@ var InputQueue = class {
|
|
|
162852
162892
|
syncView() {
|
|
162853
162893
|
this.callbacks.onStateChanged({
|
|
162854
162894
|
pendingSteers: this.pendingSteers.map(({ submission }) => submission.displayInput),
|
|
162855
|
-
queuedInputs: this.queuedFollowUps.map((submission) => submission.displayInput)
|
|
162895
|
+
queuedInputs: this.queuedFollowUps.map((submission) => submission.displayInput),
|
|
162896
|
+
...this.pausedByUser ? { paused: true } : {}
|
|
162856
162897
|
});
|
|
162857
162898
|
}
|
|
162858
162899
|
};
|
|
@@ -162869,12 +162910,14 @@ var QueuedInputView = class {
|
|
|
162869
162910
|
theme;
|
|
162870
162911
|
pendingSteers = [];
|
|
162871
162912
|
queuedInputs = [];
|
|
162913
|
+
paused = false;
|
|
162872
162914
|
constructor(theme) {
|
|
162873
162915
|
this.theme = theme;
|
|
162874
162916
|
}
|
|
162875
162917
|
setState(state) {
|
|
162876
162918
|
this.pendingSteers = state.pendingSteers.map(oneLine$1).filter(Boolean);
|
|
162877
162919
|
this.queuedInputs = state.queuedInputs.map(oneLine$1).filter(Boolean);
|
|
162920
|
+
this.paused = state.paused === true;
|
|
162878
162921
|
}
|
|
162879
162922
|
render(width) {
|
|
162880
162923
|
if (this.pendingSteers.length === 0 && this.queuedInputs.length === 0) return [];
|
|
@@ -162897,7 +162940,7 @@ var QueuedInputView = class {
|
|
|
162897
162940
|
const hidden = Math.max(0, this.queuedInputs.length - maxVisibleInputs);
|
|
162898
162941
|
const visible = this.queuedInputs.slice(-3);
|
|
162899
162942
|
const summary = `${this.queuedInputs.length} ${this.queuedInputs.length === 1 ? "input" : "inputs"}`;
|
|
162900
|
-
lines.push(` ${this.theme.bold("Queued next turn")} ${this.theme.muted(`· ${summary}`)}`, ...visible.map((input) => ` ${this.theme.muted("↳")} ${this.theme.bold(input)}`));
|
|
162943
|
+
lines.push(` ${this.theme.bold(this.paused ? "Queue paused" : "Queued next turn")} ${this.theme.muted(`· ${summary}`)}`, ...visible.map((input) => ` ${this.theme.muted("↳")} ${this.theme.bold(input)}`));
|
|
162901
162944
|
if (hidden > 0) lines.splice(sectionStart + 1, 0, this.theme.muted(` … ${hidden} earlier`));
|
|
162902
162945
|
lines.push(firstFitting([
|
|
162903
162946
|
" Alt+Up / Shift+Left edit last",
|
|
@@ -163156,29 +163199,33 @@ function normalizeRuntimeProjection(value) {
|
|
|
163156
163199
|
} : void 0
|
|
163157
163200
|
};
|
|
163158
163201
|
}
|
|
163159
|
-
/**
|
|
163160
|
-
function
|
|
163161
|
-
const usage = projection?.contextUsage;
|
|
163162
|
-
if (!projection || !usage) return projection;
|
|
163202
|
+
/** Retain token statistics only; tool output and message bodies stay in storage. */
|
|
163203
|
+
function contextCacheUsage(messages) {
|
|
163163
163204
|
const trend = extractContextCacheTrend(messages);
|
|
163164
|
-
if (trend.wholeTree.requests === 0) return
|
|
163205
|
+
if (trend.wholeTree.requests === 0) return void 0;
|
|
163165
163206
|
const latest = trend.turns.findLast((turn) => turn.inputTokens !== void 0);
|
|
163166
163207
|
const summary = trend.wholeTree;
|
|
163208
|
+
return {
|
|
163209
|
+
inputTokens: latest?.inputTokens,
|
|
163210
|
+
cacheReadTokens: latest?.cacheReadTokens,
|
|
163211
|
+
cacheWriteTokens: latest?.cacheWriteTokens,
|
|
163212
|
+
latestHitRate: latest?.hitRate,
|
|
163213
|
+
hitRate: summary.hitRate,
|
|
163214
|
+
hitRateRequestCount: summary.requests,
|
|
163215
|
+
totalInputTokens: summary.inputTokens,
|
|
163216
|
+
totalCacheReadTokens: summary.cacheReadTokens,
|
|
163217
|
+
totalCacheWriteTokens: summary.cacheWriteTokens
|
|
163218
|
+
};
|
|
163219
|
+
}
|
|
163220
|
+
function mergeProjectionContextSummary(projection, cache) {
|
|
163221
|
+
if (!projection?.contextUsage || !cache) return projection;
|
|
163167
163222
|
return {
|
|
163168
163223
|
...projection,
|
|
163169
163224
|
contextUsage: {
|
|
163170
|
-
...
|
|
163225
|
+
...projection.contextUsage,
|
|
163171
163226
|
cache: {
|
|
163172
|
-
...
|
|
163173
|
-
|
|
163174
|
-
cacheReadTokens: latest?.cacheReadTokens ?? usage.cache?.cacheReadTokens,
|
|
163175
|
-
cacheWriteTokens: latest?.cacheWriteTokens ?? usage.cache?.cacheWriteTokens,
|
|
163176
|
-
latestHitRate: latest?.hitRate ?? usage.cache?.latestHitRate,
|
|
163177
|
-
hitRate: summary.hitRate ?? usage.cache?.hitRate,
|
|
163178
|
-
hitRateRequestCount: summary.requests,
|
|
163179
|
-
totalInputTokens: summary.inputTokens,
|
|
163180
|
-
totalCacheReadTokens: summary.cacheReadTokens,
|
|
163181
|
-
totalCacheWriteTokens: summary.cacheWriteTokens
|
|
163227
|
+
...projection.contextUsage.cache,
|
|
163228
|
+
...Object.fromEntries(Object.entries(cache).filter(([, value]) => value !== void 0))
|
|
163182
163229
|
}
|
|
163183
163230
|
}
|
|
163184
163231
|
};
|
|
@@ -163274,6 +163321,172 @@ var RuntimeActivityView = class {
|
|
|
163274
163321
|
}
|
|
163275
163322
|
};
|
|
163276
163323
|
//#endregion
|
|
163324
|
+
//#region packages/zcode-tui/src/dynamic-workflows.ts
|
|
163325
|
+
const maximumRuns = 20;
|
|
163326
|
+
const maximumBufferedEvents = 2e3;
|
|
163327
|
+
var DynamicWorkflows = class {
|
|
163328
|
+
adapter;
|
|
163329
|
+
state;
|
|
163330
|
+
summaries = [];
|
|
163331
|
+
epoch = 0;
|
|
163332
|
+
loading;
|
|
163333
|
+
buffered = [];
|
|
163334
|
+
watermarks = /* @__PURE__ */ new Map();
|
|
163335
|
+
lastEvents = /* @__PURE__ */ new Map();
|
|
163336
|
+
incomplete = false;
|
|
163337
|
+
error;
|
|
163338
|
+
constructor(adapter) {
|
|
163339
|
+
this.adapter = adapter;
|
|
163340
|
+
}
|
|
163341
|
+
reset() {
|
|
163342
|
+
this.epoch++;
|
|
163343
|
+
this.state = void 0;
|
|
163344
|
+
this.summaries = [];
|
|
163345
|
+
this.loading = void 0;
|
|
163346
|
+
this.buffered = [];
|
|
163347
|
+
this.watermarks.clear();
|
|
163348
|
+
this.lastEvents.clear();
|
|
163349
|
+
this.error = void 0;
|
|
163350
|
+
this.incomplete = false;
|
|
163351
|
+
}
|
|
163352
|
+
runs() {
|
|
163353
|
+
const runs = isRecord(this.state) && Array.isArray(this.state.runs) ? this.state.runs.filter(isRecord) : [];
|
|
163354
|
+
const byId = new Map(runs.map((run) => [run.runId, run]));
|
|
163355
|
+
return [...this.summaries.map((summary) => {
|
|
163356
|
+
const run = byId.get(summary.runId);
|
|
163357
|
+
byId.delete(summary.runId);
|
|
163358
|
+
return run ? {
|
|
163359
|
+
...run,
|
|
163360
|
+
label: summary.label,
|
|
163361
|
+
updatedAt: summary.updatedAt
|
|
163362
|
+
} : summary;
|
|
163363
|
+
}), ...byId.values()].slice(0, maximumRuns).map((run) => this.incomplete ? {
|
|
163364
|
+
...run,
|
|
163365
|
+
progressIncomplete: true
|
|
163366
|
+
} : run);
|
|
163367
|
+
}
|
|
163368
|
+
accept(event) {
|
|
163369
|
+
if (!isRecord(event) || typeof event.runId !== "string" || typeof event.eventType !== "string") return false;
|
|
163370
|
+
if (this.loading) {
|
|
163371
|
+
if (this.buffered.length < maximumBufferedEvents) this.buffered.push(event);
|
|
163372
|
+
else {
|
|
163373
|
+
this.incomplete = true;
|
|
163374
|
+
this.error = "Some workflow progress was omitted. Live runs cannot be fully replayed in this process; use /dwf list for runtime status.";
|
|
163375
|
+
}
|
|
163376
|
+
return false;
|
|
163377
|
+
}
|
|
163378
|
+
return this.apply(event);
|
|
163379
|
+
}
|
|
163380
|
+
apply(event) {
|
|
163381
|
+
if (!this.adapter.reduceWorkflowRuns) return false;
|
|
163382
|
+
const id = String(event.runId);
|
|
163383
|
+
const sequence = typeof event.sequence === "number" ? event.sequence : void 0;
|
|
163384
|
+
const watermark = this.watermarks.get(id) ?? -1;
|
|
163385
|
+
const fingerprint = JSON.stringify(event);
|
|
163386
|
+
if (sequence !== void 0 && (sequence < watermark || sequence === watermark && this.lastEvents.get(id) === fingerprint)) return false;
|
|
163387
|
+
try {
|
|
163388
|
+
const state = this.adapter.reduceWorkflowRuns(this.state, event);
|
|
163389
|
+
if (sequence !== void 0) this.watermarks.set(id, sequence);
|
|
163390
|
+
this.lastEvents.set(id, fingerprint);
|
|
163391
|
+
if (!state) return false;
|
|
163392
|
+
this.state = state;
|
|
163393
|
+
if (isRecord(state) && Array.isArray(state.runs)) {
|
|
163394
|
+
const ids = new Set(state.runs.filter(isRecord).map((run) => String(run.runId)));
|
|
163395
|
+
for (const key of this.watermarks.keys()) if (!ids.has(key)) {
|
|
163396
|
+
this.watermarks.delete(key);
|
|
163397
|
+
this.lastEvents.delete(key);
|
|
163398
|
+
}
|
|
163399
|
+
}
|
|
163400
|
+
return true;
|
|
163401
|
+
} catch (error) {
|
|
163402
|
+
this.error = `Workflow progress could not be read: ${error instanceof Error ? error.message : String(error)}`;
|
|
163403
|
+
return false;
|
|
163404
|
+
}
|
|
163405
|
+
}
|
|
163406
|
+
hydrate() {
|
|
163407
|
+
if (this.loading) return this.loading;
|
|
163408
|
+
const epoch = this.epoch;
|
|
163409
|
+
if (!this.incomplete) this.error = void 0;
|
|
163410
|
+
const operation = Promise.resolve().then(async () => {
|
|
163411
|
+
const results = await Promise.allSettled([this.adapter.replayWorkflowRuns?.({ excludeRunIds: /* @__PURE__ */ new Set() }), this.adapter.listWorkflowRuns?.()]);
|
|
163412
|
+
if (epoch !== this.epoch) return;
|
|
163413
|
+
const [replay, summaries] = results;
|
|
163414
|
+
if (replay.status === "fulfilled" && Array.isArray(replay.value)) {
|
|
163415
|
+
for (const event of replay.value) if (isRecord(event)) this.apply(event);
|
|
163416
|
+
}
|
|
163417
|
+
if (summaries.status === "fulfilled" && Array.isArray(summaries.value)) this.summaries = summaries.value.filter((value) => isRecord(value) && typeof value.runId === "string").slice(0, maximumRuns);
|
|
163418
|
+
for (const result of results) if (result.status === "rejected") this.error = `Workflow history could not be loaded: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}. Run /workflows to retry.`;
|
|
163419
|
+
}).finally(() => {
|
|
163420
|
+
if (epoch !== this.epoch) return;
|
|
163421
|
+
this.loading = void 0;
|
|
163422
|
+
for (const event of this.buffered) this.apply(event);
|
|
163423
|
+
this.buffered = [];
|
|
163424
|
+
});
|
|
163425
|
+
this.loading = operation;
|
|
163426
|
+
return operation;
|
|
163427
|
+
}
|
|
163428
|
+
};
|
|
163429
|
+
function safe(value) {
|
|
163430
|
+
return sanitizeTerminalText(typeof value === "string" ? value : "", { preserveSgr: false }).slice(0, 2e3);
|
|
163431
|
+
}
|
|
163432
|
+
function workflowRunDetail(run) {
|
|
163433
|
+
const nodes = Array.isArray(run.nodes) ? run.nodes.filter(isRecord) : void 0;
|
|
163434
|
+
const actors = Array.isArray(run.actors) ? run.actors.filter(isRecord) : [];
|
|
163435
|
+
const artifacts = Array.isArray(run.artifacts) ? run.artifacts.filter(isRecord) : [];
|
|
163436
|
+
const usage = isRecord(run.usage) ? run.usage : void 0;
|
|
163437
|
+
const lines = [safe(run.label) || safe(run.runId), `Status: ${safe(run.status) || "unknown"}${run.stopReason ? ` · ${safe(run.stopReason)}` : ""}`];
|
|
163438
|
+
if (run.progressIncomplete === true) lines.push("Progress is incomplete. Use /dwf list for runtime status.");
|
|
163439
|
+
if (nodes) lines.push(`Steps: ${nodes.filter((node) => node.phase === "settled").length}/${nodes.length} observed steps settled`);
|
|
163440
|
+
if (typeof usage?.spentTokens === "number") lines.push(`Tokens: ${usage.spentTokens.toLocaleString()}`);
|
|
163441
|
+
if (run.resumable === true) lines.push("This run can be resumed.");
|
|
163442
|
+
if (actors.length) lines.push("", "Agents", ...actors.slice(0, 12).map((actor) => `${safe(actor.name) || safe(actor.sessionId) || "Agent"} · ${safe(actor.status)}`));
|
|
163443
|
+
if (artifacts.length) lines.push("", "Artifacts", ...artifacts.slice(0, 12).map((artifact) => safe(artifact.title) || safe(artifact.artifactId) || safe(artifact.id)));
|
|
163444
|
+
if (asString(run.error)) lines.push("", `Error: ${safe(run.error)}`);
|
|
163445
|
+
if (asString(run.resultPreview)) lines.push("", safe(run.resultPreview));
|
|
163446
|
+
return lines.join("\n");
|
|
163447
|
+
}
|
|
163448
|
+
//#endregion
|
|
163449
|
+
//#region packages/zcode-tui/src/runtime-context-cache.ts
|
|
163450
|
+
/** A session-scoped, invalidatable summary of persisted request usage. */
|
|
163451
|
+
var RuntimeContextCache = class {
|
|
163452
|
+
sessionId;
|
|
163453
|
+
revision = 0;
|
|
163454
|
+
loadedRevision = -1;
|
|
163455
|
+
usage;
|
|
163456
|
+
pending;
|
|
163457
|
+
invalidate() {
|
|
163458
|
+
this.revision++;
|
|
163459
|
+
}
|
|
163460
|
+
reset() {
|
|
163461
|
+
this.invalidate();
|
|
163462
|
+
this.usage = void 0;
|
|
163463
|
+
this.loadedRevision = -1;
|
|
163464
|
+
this.pending = void 0;
|
|
163465
|
+
}
|
|
163466
|
+
async read(sessionId, loadMessages) {
|
|
163467
|
+
if (sessionId !== this.sessionId) {
|
|
163468
|
+
this.reset();
|
|
163469
|
+
this.sessionId = sessionId;
|
|
163470
|
+
}
|
|
163471
|
+
if (this.loadedRevision === this.revision) return this.usage;
|
|
163472
|
+
if (this.pending?.revision === this.revision) return this.pending.promise;
|
|
163473
|
+
const revision = this.revision;
|
|
163474
|
+
const promise = Promise.resolve().then(loadMessages).then((messages) => {
|
|
163475
|
+
if (revision !== this.revision) return void 0;
|
|
163476
|
+
this.usage = contextCacheUsage(messages);
|
|
163477
|
+
this.loadedRevision = revision;
|
|
163478
|
+
return this.usage;
|
|
163479
|
+
}).finally(() => {
|
|
163480
|
+
if (this.pending?.revision === revision) this.pending = void 0;
|
|
163481
|
+
});
|
|
163482
|
+
this.pending = {
|
|
163483
|
+
revision,
|
|
163484
|
+
promise
|
|
163485
|
+
};
|
|
163486
|
+
return promise;
|
|
163487
|
+
}
|
|
163488
|
+
};
|
|
163489
|
+
//#endregion
|
|
163277
163490
|
//#region packages/zcode-tui/src/runtime-poll.ts
|
|
163278
163491
|
const ACTIVE_RUNTIME_POLL_INTERVAL_MS = 1e3;
|
|
163279
163492
|
const IDLE_RUNTIME_POLL_INTERVAL_MS = 5e3;
|
|
@@ -163290,6 +163503,28 @@ function runtimeRefreshNeeded(event) {
|
|
|
163290
163503
|
if (event.type === "part.delta") return false;
|
|
163291
163504
|
return event.kind !== "text_delta" && event.kind !== "reasoning_delta" && event.kind !== "tool_input_delta";
|
|
163292
163505
|
}
|
|
163506
|
+
const contextChangeEvents = /* @__PURE__ */ new Set([
|
|
163507
|
+
"model_complete",
|
|
163508
|
+
"model.complete",
|
|
163509
|
+
"turn_complete",
|
|
163510
|
+
"turn.completed",
|
|
163511
|
+
"turn_error",
|
|
163512
|
+
"turn.failed",
|
|
163513
|
+
"session_created",
|
|
163514
|
+
"session_resumed",
|
|
163515
|
+
"session_forked",
|
|
163516
|
+
"session_compacted",
|
|
163517
|
+
"compact_boundary",
|
|
163518
|
+
"rewind_triggered",
|
|
163519
|
+
"rewind.triggered"
|
|
163520
|
+
]);
|
|
163521
|
+
function runtimeContextRefreshNeeded(event) {
|
|
163522
|
+
return event.type !== void 0 && contextChangeEvents.has(event.type);
|
|
163523
|
+
}
|
|
163524
|
+
/** Polling also notices completed work from runtimes without session events. */
|
|
163525
|
+
function runtimeContextChanged(current, next) {
|
|
163526
|
+
return current?.sessionId !== next?.sessionId || current?.turnCount !== next?.turnCount || current?.totalTokenCount !== next?.totalTokenCount || current?.contextUsage?.used !== next?.contextUsage?.used;
|
|
163527
|
+
}
|
|
163293
163528
|
//#endregion
|
|
163294
163529
|
//#region packages/zcode-tui/src/selection-command.ts
|
|
163295
163530
|
const apiKeyLoginPattern = /^(\/login\s+(?:zai|bigmodel)-coding-plan-api-key)(?:\s+([\s\S]*))?$/iu;
|
|
@@ -166065,6 +166300,9 @@ var ZCodeTui = class {
|
|
|
166065
166300
|
turnWork = new TurnWorkTracker();
|
|
166066
166301
|
backgroundCoordinatorMessageIds = /* @__PURE__ */ new Set();
|
|
166067
166302
|
workflowPanel;
|
|
166303
|
+
dynamicWorkflows;
|
|
166304
|
+
dynamicWorkflowView;
|
|
166305
|
+
selectedDynamicWorkflow;
|
|
166068
166306
|
workflowView;
|
|
166069
166307
|
workflowRefreshInFlight = false;
|
|
166070
166308
|
permissionRequests = new PermissionRequestQueue();
|
|
@@ -166099,6 +166337,7 @@ var ZCodeTui = class {
|
|
|
166099
166337
|
usageRefreshInFlight = false;
|
|
166100
166338
|
usageRefreshPending = false;
|
|
166101
166339
|
runtimeProjection;
|
|
166340
|
+
runtimeContextCache = new RuntimeContextCache();
|
|
166102
166341
|
todos = [];
|
|
166103
166342
|
todoGroups = [];
|
|
166104
166343
|
runtimeRefreshInFlight = false;
|
|
@@ -166112,6 +166351,7 @@ var ZCodeTui = class {
|
|
|
166112
166351
|
removeStreamErrorGuards;
|
|
166113
166352
|
constructor(options) {
|
|
166114
166353
|
this.options = options;
|
|
166354
|
+
this.dynamicWorkflows = new DynamicWorkflows(options);
|
|
166115
166355
|
this.animateTurnTimer = turnTimerAnimationEnabled();
|
|
166116
166356
|
this.colorsEnabled = !options.noColor && !process.env.NO_COLOR;
|
|
166117
166357
|
this.themePreference = themePreference(options.theme);
|
|
@@ -166244,6 +166484,7 @@ var ZCodeTui = class {
|
|
|
166244
166484
|
if (this.options.subscribeSessionEvents) this.unsubscribeSession = this.options.subscribeSessionEvents((event) => {
|
|
166245
166485
|
this.onSessionEvent(event);
|
|
166246
166486
|
}) ?? void 0;
|
|
166487
|
+
this.dynamicWorkflows.hydrate().then(() => this.renderDynamicWorkflow());
|
|
166247
166488
|
if (this.options.subscribeWorkflowEvents) this.unsubscribeWorkflow = this.options.subscribeWorkflowEvents((event) => {
|
|
166248
166489
|
this.debugEvent("workflow", event);
|
|
166249
166490
|
this.refreshWorkflowFromEvent();
|
|
@@ -166684,6 +166925,23 @@ var ZCodeTui = class {
|
|
|
166684
166925
|
name: "activity",
|
|
166685
166926
|
description: "Inspect every active tool and open task"
|
|
166686
166927
|
},
|
|
166928
|
+
{
|
|
166929
|
+
name: "queue",
|
|
166930
|
+
description: "Manage queued drafts",
|
|
166931
|
+
argumentHint: "[pause|resume]"
|
|
166932
|
+
},
|
|
166933
|
+
{
|
|
166934
|
+
name: "edit-message",
|
|
166935
|
+
description: "Restore an earlier question for editing"
|
|
166936
|
+
},
|
|
166937
|
+
{
|
|
166938
|
+
name: "retry",
|
|
166939
|
+
description: "Retry an earlier question from a conversation rewind"
|
|
166940
|
+
},
|
|
166941
|
+
{
|
|
166942
|
+
name: "workflows",
|
|
166943
|
+
description: "Inspect workflow progress, results and recovery"
|
|
166944
|
+
},
|
|
166687
166945
|
{
|
|
166688
166946
|
name: "tasks",
|
|
166689
166947
|
description: "Inspect, message or recover background tasks",
|
|
@@ -166808,7 +167066,7 @@ var ZCodeTui = class {
|
|
|
166808
167066
|
this.switchModel();
|
|
166809
167067
|
return { consume: true };
|
|
166810
167068
|
}
|
|
166811
|
-
if (matchesKey(data, "tab") && this.turnAbortController && Boolean(this.editor.getText().trim()) && !this.editor.isShowingAutocomplete()) {
|
|
167069
|
+
if (matchesKey(data, "tab") && (this.turnAbortController || this.inputQueue.paused) && Boolean(this.editor.getText().trim()) && !this.editor.isShowingAutocomplete()) {
|
|
166812
167070
|
this.queueCurrentEditorInput();
|
|
166813
167071
|
return { consume: true };
|
|
166814
167072
|
}
|
|
@@ -166896,6 +167154,7 @@ var ZCodeTui = class {
|
|
|
166896
167154
|
if (input === "/cls") {
|
|
166897
167155
|
this.clearTranscriptProjection();
|
|
166898
167156
|
this.workflowView = void 0;
|
|
167157
|
+
this.dynamicWorkflowView = void 0;
|
|
166899
167158
|
this.ui.requestRender(true);
|
|
166900
167159
|
return;
|
|
166901
167160
|
}
|
|
@@ -166928,6 +167187,25 @@ var ZCodeTui = class {
|
|
|
166928
167187
|
await this.showActivityDetails();
|
|
166929
167188
|
return;
|
|
166930
167189
|
}
|
|
167190
|
+
if (input === "/queue" || input === "/queue list") {
|
|
167191
|
+
await this.manageInputQueue();
|
|
167192
|
+
return;
|
|
167193
|
+
}
|
|
167194
|
+
if (input === "/queue pause" || input === "/queue resume") {
|
|
167195
|
+
this.inputQueue.paused = input === "/queue pause";
|
|
167196
|
+
if (!this.inputQueue.paused) this.inputQueue.resetAutoSend();
|
|
167197
|
+
this.addNotice(this.inputQueue.paused ? "Queue paused. Use /queue resume to continue." : "Queue resumed.", "muted");
|
|
167198
|
+
this.drainInputAfterBackgroundHandoff();
|
|
167199
|
+
return;
|
|
167200
|
+
}
|
|
167201
|
+
if (input === "/edit-message" || input === "/retry") {
|
|
167202
|
+
await this.editOrRetryMessage(input === "/retry");
|
|
167203
|
+
return;
|
|
167204
|
+
}
|
|
167205
|
+
if ((input === "/workflows" || input === "/workflows list") && this.options.listWorkflowRuns) {
|
|
167206
|
+
await this.showDynamicWorkflows();
|
|
167207
|
+
return;
|
|
167208
|
+
}
|
|
166931
167209
|
if (input === "/tasks" || input === "/tasks list") {
|
|
166932
167210
|
await this.showBackgroundTasks();
|
|
166933
167211
|
return;
|
|
@@ -167040,7 +167318,7 @@ var ZCodeTui = class {
|
|
|
167040
167318
|
});
|
|
167041
167319
|
return true;
|
|
167042
167320
|
}
|
|
167043
|
-
const attachments = !steering && !input.startsWith("/") ? [...this.pendingAttachments] : [];
|
|
167321
|
+
const attachments = !queuedSubmission && !steering && !input.startsWith("/") ? [...this.pendingAttachments] : [];
|
|
167044
167322
|
if (steering && !this.options.sendInput) {
|
|
167045
167323
|
this.inputQueue.queueFollowUp({
|
|
167046
167324
|
...submission,
|
|
@@ -167323,7 +167601,12 @@ var ZCodeTui = class {
|
|
|
167323
167601
|
}
|
|
167324
167602
|
async handleResult(result, renderResponse = true, settingTarget) {
|
|
167325
167603
|
if (!isRecord(result)) return;
|
|
167604
|
+
this.runtimeContextCache.invalidate();
|
|
167326
167605
|
if (result.resetSessionProjection === true) {
|
|
167606
|
+
this.dynamicWorkflows.reset();
|
|
167607
|
+
this.dynamicWorkflowView = void 0;
|
|
167608
|
+
this.selectedDynamicWorkflow = void 0;
|
|
167609
|
+
this.runtimeContextCache.reset();
|
|
167327
167610
|
this.executionStateRevision++;
|
|
167328
167611
|
this.clearTranscriptProjection();
|
|
167329
167612
|
this.workflowView = void 0;
|
|
@@ -167373,13 +167656,17 @@ var ZCodeTui = class {
|
|
|
167373
167656
|
this.updateMetadata();
|
|
167374
167657
|
this.ui.requestRender();
|
|
167375
167658
|
if (this.sessionModelIssue) await this.recoverSessionModel();
|
|
167659
|
+
this.dynamicWorkflows.hydrate().then(() => this.renderDynamicWorkflow());
|
|
167376
167660
|
}
|
|
167661
|
+
this.scheduleRuntimeRefresh(0);
|
|
167377
167662
|
}
|
|
167378
167663
|
onEvent(value, turnEpoch) {
|
|
167379
167664
|
this.debugEvent("session", value);
|
|
167380
167665
|
if (turnEpoch !== void 0 && turnEpoch !== this.activeTurnEpoch) return;
|
|
167381
167666
|
const event = normalizeEvent(value);
|
|
167382
167667
|
if (!event || this.isForeignSessionEvent(event)) return;
|
|
167668
|
+
if (runtimeContextRefreshNeeded(event)) this.runtimeContextCache.invalidate();
|
|
167669
|
+
if (this.handleDynamicWorkflowEvent(value, event.type)) return;
|
|
167383
167670
|
const taskScoped = this.backgroundTaskEvents.isTaskScoped(event);
|
|
167384
167671
|
this.applyBackgroundTaskEvent(event);
|
|
167385
167672
|
if (!taskScoped && event.kind && toolLifecycleEventKinds.has(event.kind)) this.turnHadWorkActivity = true;
|
|
@@ -167523,11 +167810,88 @@ var ZCodeTui = class {
|
|
|
167523
167810
|
this.debugEvent("session-subscription", value);
|
|
167524
167811
|
const event = normalizeEvent(value);
|
|
167525
167812
|
if (!event || this.isForeignSessionEvent(event)) return;
|
|
167813
|
+
if (runtimeContextRefreshNeeded(event)) this.runtimeContextCache.invalidate();
|
|
167814
|
+
if (this.handleDynamicWorkflowEvent(value, event.type)) return;
|
|
167526
167815
|
this.applyBackgroundTaskEvent(event);
|
|
167527
|
-
this.scheduleRuntimeRefresh();
|
|
167816
|
+
if (runtimeRefreshNeeded(event)) this.scheduleRuntimeRefresh();
|
|
167528
167817
|
}
|
|
167529
167818
|
isForeignSessionEvent(event) {
|
|
167530
|
-
|
|
167819
|
+
const sessionId = this.options.getMainSessionId?.() ?? this.sessionId;
|
|
167820
|
+
return Boolean(sessionId && event.sessionId && event.sessionId !== sessionId);
|
|
167821
|
+
}
|
|
167822
|
+
handleDynamicWorkflowEvent(value, type) {
|
|
167823
|
+
if (type !== "dynamic_workflow_run_progress" || !isRecord(value)) return false;
|
|
167824
|
+
if (this.dynamicWorkflows.accept(value.payload)) this.renderDynamicWorkflow();
|
|
167825
|
+
return true;
|
|
167826
|
+
}
|
|
167827
|
+
renderDynamicWorkflow() {
|
|
167828
|
+
if (!this.dynamicWorkflowView || !this.selectedDynamicWorkflow) return;
|
|
167829
|
+
const run = this.dynamicWorkflows.runs().find((run) => run.runId === this.selectedDynamicWorkflow);
|
|
167830
|
+
if (run) this.dynamicWorkflowView.setText(workflowRunDetail(run));
|
|
167831
|
+
this.ui.requestRender();
|
|
167832
|
+
}
|
|
167833
|
+
async showDynamicWorkflows() {
|
|
167834
|
+
if (!this.options.listWorkflowRuns) {
|
|
167835
|
+
this.addNotice("Workflow inspection is unavailable in this runtime.", "warning");
|
|
167836
|
+
return;
|
|
167837
|
+
}
|
|
167838
|
+
await this.dynamicWorkflows.hydrate();
|
|
167839
|
+
if (this.dynamicWorkflows.error) this.addNotice(this.dynamicWorkflows.error, "warning");
|
|
167840
|
+
const runs = this.dynamicWorkflows.runs();
|
|
167841
|
+
if (runs.length === 0) {
|
|
167842
|
+
this.addNotice("No workflow runs in this session.", "muted");
|
|
167843
|
+
return;
|
|
167844
|
+
}
|
|
167845
|
+
const choice = await this.showChoice({
|
|
167846
|
+
title: "Workflow runs",
|
|
167847
|
+
prompt: "Select a run to inspect its progress and results.",
|
|
167848
|
+
items: runs.map((run) => ({
|
|
167849
|
+
value: String(run.runId),
|
|
167850
|
+
label: asString(run.label) || String(run.runId),
|
|
167851
|
+
description: [run.status, run.resumable === true ? "resumable" : void 0].filter(Boolean).join(" · ")
|
|
167852
|
+
}))
|
|
167853
|
+
});
|
|
167854
|
+
if (!choice) return;
|
|
167855
|
+
this.selectedDynamicWorkflow = choice.value;
|
|
167856
|
+
const run = this.dynamicWorkflows.runs().find((run) => run.runId === choice.value);
|
|
167857
|
+
if (!run) {
|
|
167858
|
+
this.addNotice("This run is no longer in the current workflow list. Open /workflows again.", "muted");
|
|
167859
|
+
return;
|
|
167860
|
+
}
|
|
167861
|
+
this.dynamicWorkflowView = new Text(workflowRunDetail(run), 1, 0);
|
|
167862
|
+
this.transcript.addBlock(this.dynamicWorkflowView);
|
|
167863
|
+
this.ui.requestRender();
|
|
167864
|
+
const action = await this.showChoice({
|
|
167865
|
+
title: "Workflow actions",
|
|
167866
|
+
prompt: "Progress remains visible in the transcript.",
|
|
167867
|
+
items: [
|
|
167868
|
+
{
|
|
167869
|
+
value: "close",
|
|
167870
|
+
label: "Back to prompt"
|
|
167871
|
+
},
|
|
167872
|
+
...["pending", "running"].includes(String(run.status)) ? [{
|
|
167873
|
+
value: "cancel",
|
|
167874
|
+
label: "Stop workflow"
|
|
167875
|
+
}] : [],
|
|
167876
|
+
...run.resumable === true ? [{
|
|
167877
|
+
value: "resume",
|
|
167878
|
+
label: "Resume workflow"
|
|
167879
|
+
}] : []
|
|
167880
|
+
]
|
|
167881
|
+
});
|
|
167882
|
+
if (!action || action.value === "close") return;
|
|
167883
|
+
if (!/^[A-Za-z0-9_.:-]+$/u.test(choice.value)) {
|
|
167884
|
+
this.addNotice("This workflow ID cannot be passed to the runtime command.", "error");
|
|
167885
|
+
return;
|
|
167886
|
+
}
|
|
167887
|
+
try {
|
|
167888
|
+
const result = await this.options.submitPrompt(`/dwf ${action.value} ${choice.value}`, {});
|
|
167889
|
+
await this.handleResult(result);
|
|
167890
|
+
await this.dynamicWorkflows.hydrate();
|
|
167891
|
+
this.renderDynamicWorkflow();
|
|
167892
|
+
} catch (error) {
|
|
167893
|
+
this.addNotice(error instanceof Error ? error.message : String(error), "error");
|
|
167894
|
+
}
|
|
167531
167895
|
}
|
|
167532
167896
|
isBackgroundCoordinatorReasoning(event) {
|
|
167533
167897
|
if (!event.messageId || !this.backgroundCoordinatorMessageIds.has(event.messageId)) return false;
|
|
@@ -168274,10 +168638,147 @@ var ZCodeTui = class {
|
|
|
168274
168638
|
queueCurrentEditorInput() {
|
|
168275
168639
|
const input = this.editor.getText().trim();
|
|
168276
168640
|
if (!input) return;
|
|
168641
|
+
if (this.pendingAttachments.length > 0) {
|
|
168642
|
+
this.addNotice("Send or remove pending images before queueing a text draft.", "warning");
|
|
168643
|
+
return;
|
|
168644
|
+
}
|
|
168277
168645
|
this.editor.setText("");
|
|
168278
168646
|
this.inputQueue.queueFollowUp(protectSubmission(input));
|
|
168279
168647
|
}
|
|
168648
|
+
async manageInputQueue() {
|
|
168649
|
+
const wasPaused = this.inputQueue.paused;
|
|
168650
|
+
this.inputQueue.paused = true;
|
|
168651
|
+
try {
|
|
168652
|
+
while (true) {
|
|
168653
|
+
const entries = this.inputQueue.entries();
|
|
168654
|
+
if (!entries.length) {
|
|
168655
|
+
this.addNotice("No queued inputs.", "muted");
|
|
168656
|
+
return;
|
|
168657
|
+
}
|
|
168658
|
+
const selected = await this.showChoice({
|
|
168659
|
+
title: "Queued inputs",
|
|
168660
|
+
prompt: "Select a draft. Sending pauses while this panel is open.",
|
|
168661
|
+
items: entries.map((entry) => ({
|
|
168662
|
+
value: String(entry.id),
|
|
168663
|
+
label: entry.displayInput,
|
|
168664
|
+
description: entry.editable ? "Editable draft" : "Accepted by runtime · cannot edit here"
|
|
168665
|
+
}))
|
|
168666
|
+
});
|
|
168667
|
+
if (!selected) return;
|
|
168668
|
+
const entry = entries.find((entry) => String(entry.id) === selected.value);
|
|
168669
|
+
if (!entry?.editable) {
|
|
168670
|
+
this.addNotice("This input is already owned by the runtime.", "warning");
|
|
168671
|
+
continue;
|
|
168672
|
+
}
|
|
168673
|
+
const action = await this.showChoice({
|
|
168674
|
+
title: "Queued draft",
|
|
168675
|
+
prompt: "Choose an action.",
|
|
168676
|
+
items: [
|
|
168677
|
+
{
|
|
168678
|
+
value: "edit",
|
|
168679
|
+
label: "Move to editor"
|
|
168680
|
+
},
|
|
168681
|
+
{
|
|
168682
|
+
value: "up",
|
|
168683
|
+
label: "Move earlier"
|
|
168684
|
+
},
|
|
168685
|
+
{
|
|
168686
|
+
value: "down",
|
|
168687
|
+
label: "Move later"
|
|
168688
|
+
},
|
|
168689
|
+
{
|
|
168690
|
+
value: "delete",
|
|
168691
|
+
label: "Delete draft"
|
|
168692
|
+
},
|
|
168693
|
+
{
|
|
168694
|
+
value: "back",
|
|
168695
|
+
label: "Back"
|
|
168696
|
+
}
|
|
168697
|
+
]
|
|
168698
|
+
});
|
|
168699
|
+
if (!action || action.value === "back") continue;
|
|
168700
|
+
if (action.value === "edit" && (this.editor.getText().trim() || this.pendingAttachments.length > 0)) {
|
|
168701
|
+
this.addNotice("Save or clear the current draft before editing a queued input.", "warning");
|
|
168702
|
+
return;
|
|
168703
|
+
}
|
|
168704
|
+
if (action.value === "up" || action.value === "down") {
|
|
168705
|
+
if (!this.inputQueue.move(entry.id, action.value === "up" ? -1 : 1)) this.addNotice("The draft cannot move further in that direction.", "muted");
|
|
168706
|
+
} else {
|
|
168707
|
+
const removed = this.inputQueue.remove(entry.id);
|
|
168708
|
+
if (!removed) {
|
|
168709
|
+
this.addNotice("The queued input changed. Select it again.", "warning");
|
|
168710
|
+
continue;
|
|
168711
|
+
}
|
|
168712
|
+
if (action.value === "edit") {
|
|
168713
|
+
this.editor.setText(removed.input);
|
|
168714
|
+
this.focusEditor();
|
|
168715
|
+
return;
|
|
168716
|
+
}
|
|
168717
|
+
}
|
|
168718
|
+
}
|
|
168719
|
+
} finally {
|
|
168720
|
+
this.inputQueue.paused = wasPaused;
|
|
168721
|
+
this.drainInputAfterBackgroundHandoff();
|
|
168722
|
+
}
|
|
168723
|
+
}
|
|
168724
|
+
async editOrRetryMessage(retry) {
|
|
168725
|
+
if (this.activeSubmissions > 0 || this.backgroundTaskEvents.hasActiveHandoffs()) {
|
|
168726
|
+
this.addNotice("Wait for the active turn before changing conversation history.", "warning");
|
|
168727
|
+
return;
|
|
168728
|
+
}
|
|
168729
|
+
if (this.editor.getText().trim() || this.pendingAttachments.length > 0) {
|
|
168730
|
+
this.addNotice("Save or clear the current draft before changing conversation history.", "warning");
|
|
168731
|
+
return;
|
|
168732
|
+
}
|
|
168733
|
+
if (!this.options.loadSessionTranscript) {
|
|
168734
|
+
this.addNotice("Message history is unavailable in this runtime.", "warning");
|
|
168735
|
+
return;
|
|
168736
|
+
}
|
|
168737
|
+
try {
|
|
168738
|
+
const targets = rewindTargets(await this.options.loadSessionTranscript());
|
|
168739
|
+
if (!targets.length) {
|
|
168740
|
+
this.addNotice("No earlier questions to select.", "muted");
|
|
168741
|
+
return;
|
|
168742
|
+
}
|
|
168743
|
+
const selected = await this.showChoice({
|
|
168744
|
+
title: retry ? "Retry a question" : "Edit an earlier question",
|
|
168745
|
+
prompt: "Select the question to return to.",
|
|
168746
|
+
items: targets.map((target) => ({
|
|
168747
|
+
value: target.messageId,
|
|
168748
|
+
label: rewindTargetLabel(target.text)
|
|
168749
|
+
}))
|
|
168750
|
+
});
|
|
168751
|
+
const target = targets.find((target) => target.messageId === selected?.value);
|
|
168752
|
+
if (!target) return;
|
|
168753
|
+
if ((await this.showChoice({
|
|
168754
|
+
title: retry ? "Retry this question?" : "Edit this question?",
|
|
168755
|
+
prompt: "Later conversation turns will be removed. Workspace files stay as they are. " + (retry ? "Only question text will be sent again; original images are not included." : "Only question text is restored; reattach any images before sending."),
|
|
168756
|
+
items: [{
|
|
168757
|
+
value: "cancel",
|
|
168758
|
+
label: "Cancel"
|
|
168759
|
+
}, {
|
|
168760
|
+
value: "confirm",
|
|
168761
|
+
label: retry ? "Rewind and send again" : "Rewind and move to editor"
|
|
168762
|
+
}]
|
|
168763
|
+
}))?.value !== "confirm") return;
|
|
168764
|
+
if (this.activeSubmissions > 0 || this.backgroundTaskEvents.hasActiveHandoffs()) {
|
|
168765
|
+
this.addNotice("The conversation became active. Wait for it to finish and select the question again.", "warning");
|
|
168766
|
+
return;
|
|
168767
|
+
}
|
|
168768
|
+
await this.applyConversationRewind(target, "conversation");
|
|
168769
|
+
if (retry) {
|
|
168770
|
+
this.editor.setText("");
|
|
168771
|
+
await this.submit(target.text);
|
|
168772
|
+
}
|
|
168773
|
+
} catch (error) {
|
|
168774
|
+
this.addNotice(error instanceof Error ? error.message : String(error), "error");
|
|
168775
|
+
}
|
|
168776
|
+
}
|
|
168280
168777
|
editLatestQueuedFollowUp() {
|
|
168778
|
+
if (this.pendingAttachments.length > 0) {
|
|
168779
|
+
this.addNotice("Send or remove pending images before restoring a queued draft.", "warning");
|
|
168780
|
+
return;
|
|
168781
|
+
}
|
|
168281
168782
|
const submission = this.inputQueue.editLatestFollowUp();
|
|
168282
168783
|
if (!submission) return;
|
|
168283
168784
|
this.editor.setText(submission.input);
|
|
@@ -170098,12 +170599,6 @@ var ZCodeTui = class {
|
|
|
170098
170599
|
priority: 20
|
|
170099
170600
|
});
|
|
170100
170601
|
}
|
|
170101
|
-
const backgroundCount = this.runtimeProjection?.backgroundJobs.filter(isActiveBackgroundJob).length ?? 0;
|
|
170102
|
-
if (backgroundCount > 0) fields.push({
|
|
170103
|
-
text: this.theme.accent(`${backgroundCount} in background`),
|
|
170104
|
-
compactText: this.theme.accent(`bg ${backgroundCount}`),
|
|
170105
|
-
priority: 80
|
|
170106
|
-
});
|
|
170107
170602
|
const search = this.transcript.searchStatus();
|
|
170108
170603
|
if (search) fields.push({
|
|
170109
170604
|
text: this.theme.accent(`find ${search.current}/${search.total}: ${search.query}`),
|
|
@@ -170159,7 +170654,8 @@ var ZCodeTui = class {
|
|
|
170159
170654
|
if (this.turnStartedAt !== void 0) this.turnElapsedMilliseconds = Math.max(0, performance.now() - this.turnStartedAt);
|
|
170160
170655
|
const showElapsed = this.turnStartedAt !== void 0 || !this.activity && this.turnTimingVisible;
|
|
170161
170656
|
const text = turnStatusText(this.activity, this.turnElapsedMilliseconds, showElapsed, this.turnStartedAt !== void 0 && this.animateTurnTimer, this.turnStartedAt === void 0 && this.turnTimingVisible) ?? "";
|
|
170162
|
-
const
|
|
170657
|
+
const backgroundCount = this.runtimeProjection?.backgroundJobs.filter(isActiveBackgroundJob).length ?? 0;
|
|
170658
|
+
const left = [text ? this.activity ? this.theme.accent(text) : this.theme.muted(text) : "", backgroundCount > 0 ? this.theme.accent(`${backgroundCount} in background`) : ""].filter(Boolean).join(this.theme.muted(" · "));
|
|
170163
170659
|
const goalText = goalStatusText(this.goal);
|
|
170164
170660
|
const goalLabel = goalStatusLabel(this.goal);
|
|
170165
170661
|
const goalStyle = this.goal?.status === "complete" ? this.theme.success : this.goal?.status === "paused" || this.goal?.status === "budget_limited" ? this.theme.warning : this.theme.accent;
|
|
@@ -170211,7 +170707,7 @@ var ZCodeTui = class {
|
|
|
170211
170707
|
totalTokens: projection.totalTokenCount,
|
|
170212
170708
|
turnCount: projection.turnCount
|
|
170213
170709
|
}, Boolean(this.options.readSessionUsage));
|
|
170214
|
-
this.
|
|
170710
|
+
this.updateTurnStatus(false);
|
|
170215
170711
|
}
|
|
170216
170712
|
/**
|
|
170217
170713
|
* Surface tasks the persisted background-agent restore bridge re-registered.
|
|
@@ -170261,11 +170757,7 @@ var ZCodeTui = class {
|
|
|
170261
170757
|
do {
|
|
170262
170758
|
this.runtimeRefreshPending = false;
|
|
170263
170759
|
const executionStateRevision = this.executionStateRevision;
|
|
170264
|
-
const [projectionResult, todosResult
|
|
170265
|
-
this.options.readRuntimeProjection?.(),
|
|
170266
|
-
this.options.readTodos?.(),
|
|
170267
|
-
this.options.readRuntimeProjection && this.options.loadSessionContextMessages ? this.options.loadSessionContextMessages() : Promise.resolve(void 0)
|
|
170268
|
-
]);
|
|
170760
|
+
const [projectionResult, todosResult] = await Promise.allSettled([this.options.readRuntimeProjection?.(), this.options.readTodos?.()]);
|
|
170269
170761
|
if (executionStateRevision !== this.executionStateRevision) {
|
|
170270
170762
|
this.runtimeRefreshPending = true;
|
|
170271
170763
|
continue;
|
|
@@ -170277,7 +170769,13 @@ var ZCodeTui = class {
|
|
|
170277
170769
|
};
|
|
170278
170770
|
if (projectionResult.status === "fulfilled" && projectionResult.value !== void 0) {
|
|
170279
170771
|
const projection = normalizeRuntimeProjection(projectionResult.value);
|
|
170280
|
-
|
|
170772
|
+
if (runtimeContextChanged(this.runtimeProjection, projection)) this.runtimeContextCache.invalidate();
|
|
170773
|
+
const cache = this.options.loadSessionContextMessages ? await this.runtimeContextCache.read(projection?.sessionId ?? this.sessionId, this.options.loadSessionContextMessages).catch(() => void 0) : void 0;
|
|
170774
|
+
if (executionStateRevision !== this.executionStateRevision) {
|
|
170775
|
+
this.runtimeRefreshPending = true;
|
|
170776
|
+
continue;
|
|
170777
|
+
}
|
|
170778
|
+
next.projection = mergeProjectionContextSummary(projection, cache) ?? next.projection;
|
|
170281
170779
|
if (isRecord(projectionResult.value) && Array.isArray(projectionResult.value.todoGroups)) next.todoGroups = normalizeTodoGroups(projectionResult.value);
|
|
170282
170780
|
}
|
|
170283
170781
|
if (todosResult.status === "fulfilled" && todosResult.value !== void 0) next.todos = normalizeTodos(todosResult.value);
|