@xingular/harness 1.1.1 → 1.3.1-unstable.0
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/CHANGELOG.md +48 -0
- package/README.md +36 -28
- package/dist/cli.js +10837 -6159
- package/dist/sdk/accounts/accounts.d.ts +27 -3
- package/dist/sdk/accounts/accounts.js +78 -24
- package/dist/sdk/accounts/secrets.d.ts +12 -0
- package/dist/sdk/accounts/secrets.js +114 -7
- package/dist/sdk/accounts/store.d.ts +26 -1
- package/dist/sdk/accounts/store.js +1 -1
- package/dist/sdk/agents/builtin.js +18 -4
- package/dist/sdk/agents/planResearch.d.ts +27 -0
- package/dist/sdk/agents/planResearch.js +82 -0
- package/dist/sdk/agents/profiles.d.ts +5 -1
- package/dist/sdk/agents/profiles.js +21 -5
- package/dist/sdk/annotations/pageScript.js +349 -48
- package/dist/sdk/annotations/part.js +34 -23
- package/dist/sdk/annotations/store.d.ts +7 -0
- package/dist/sdk/annotations/store.js +13 -5
- package/dist/sdk/browser/backend.d.ts +16 -0
- package/dist/sdk/browser/backend.js +17 -0
- package/dist/sdk/browser/contracts.d.ts +19 -0
- package/dist/sdk/browser/contracts.js +116 -0
- package/dist/sdk/browser/tools.d.ts +1 -4
- package/dist/sdk/browser/tools.js +14 -91
- package/dist/sdk/capabilities/runSnapshot.js +10 -4
- package/dist/sdk/cli.js +5 -4
- package/dist/sdk/commands/list.d.ts +3 -0
- package/dist/sdk/commands/list.js +75 -0
- package/dist/sdk/commands/registry.d.ts +258 -0
- package/dist/sdk/commands/registry.js +48 -0
- package/dist/sdk/commands/routes.d.ts +16 -0
- package/dist/sdk/commands/routes.js +33 -0
- package/dist/sdk/core/commandBudget.d.ts +23 -0
- package/dist/sdk/core/commandBudget.js +57 -0
- package/dist/sdk/core/index.js +17 -1
- package/dist/sdk/core/interactiveProfile.d.ts +46 -0
- package/dist/sdk/core/interactiveProfile.js +143 -0
- package/dist/sdk/core/shell.d.ts +20 -0
- package/dist/sdk/core/shell.js +73 -0
- package/dist/sdk/core/workspace.d.ts +13 -0
- package/dist/sdk/core/workspace.js +88 -0
- package/dist/sdk/core/workspaceBashTool.d.ts +20 -0
- package/dist/sdk/core/workspaceBashTool.js +50 -0
- package/dist/sdk/core/workspaceSandbox.d.ts +41 -0
- package/dist/sdk/core/workspaceSandbox.js +360 -0
- package/dist/sdk/core/workspaceWriteOperations.d.ts +33 -0
- package/dist/sdk/core/workspaceWriteOperations.js +224 -0
- package/dist/sdk/doctor/checks.js +71 -12
- package/dist/sdk/doctor/types.d.ts +2 -2
- package/dist/sdk/harness.d.ts +7 -0
- package/dist/sdk/harness.js +42 -2
- package/dist/sdk/hub/hub.js +5 -3
- package/dist/sdk/index.d.ts +8 -3
- package/dist/sdk/index.js +4 -1
- package/dist/sdk/pi/runtime.d.ts +2 -1
- package/dist/sdk/pi/runtime.js +2 -2
- package/dist/sdk/plugins/builtin.js +32 -15
- package/dist/sdk/plugins/builtinRegistry.d.ts +10 -3
- package/dist/sdk/plugins/builtinRegistry.js +30 -8
- package/dist/sdk/plugins/catalogue.js +2 -1
- package/dist/sdk/plugins/commandPrefix.d.ts +8 -0
- package/dist/sdk/plugins/commandPrefix.js +21 -0
- package/dist/sdk/plugins/firstParty.d.ts +1 -1
- package/dist/sdk/plugins/firstParty.js +8 -2
- package/dist/sdk/plugins/install.d.ts +6 -2
- package/dist/sdk/plugins/install.js +29 -5
- package/dist/sdk/plugins/inventory.js +6 -5
- package/dist/sdk/plugins/manifest.d.ts +2 -0
- package/dist/sdk/plugins/manifest.js +2 -1
- package/dist/sdk/plugins/surfaces.d.ts +5 -0
- package/dist/sdk/plugins/surfaces.js +11 -0
- package/dist/sdk/plugins/types.d.ts +15 -0
- package/dist/sdk/prompt/compile.d.ts +14 -0
- package/dist/sdk/prompt/compile.js +65 -31
- package/dist/sdk/prompt/standard.d.ts +17 -0
- package/dist/sdk/prompt/standard.js +21 -0
- package/dist/sdk/server/methods.js +22 -2
- package/dist/sdk/server/remote.js +36 -11
- package/dist/sdk/sessions/compactionCheckpoint.d.ts +11 -0
- package/dist/sdk/sessions/compactionCheckpoint.js +79 -0
- package/dist/sdk/sessions/continuation.d.ts +7 -2
- package/dist/sdk/sessions/continuation.js +11 -6
- package/dist/sdk/sessions/contracts.d.ts +190 -4
- package/dist/sdk/sessions/contracts.js +71 -8
- package/dist/sdk/sessions/control.d.ts +72 -0
- package/dist/sdk/sessions/control.js +158 -0
- package/dist/sdk/sessions/initialBash.d.ts +7 -0
- package/dist/sdk/sessions/initialBash.js +7 -0
- package/dist/sdk/sessions/planMode.d.ts +14 -3
- package/dist/sdk/sessions/planMode.js +74 -17
- package/dist/sdk/sessions/registry.d.ts +1 -1
- package/dist/sdk/sessions/registry.js +2 -2
- package/dist/sdk/sessions/runStore.d.ts +14 -0
- package/dist/sdk/sessions/runStore.js +38 -1
- package/dist/sdk/sessions/runner.d.ts +40 -2
- package/dist/sdk/sessions/runner.js +161 -13
- package/dist/sdk/sessions/sessions.d.ts +23 -3
- package/dist/sdk/sessions/sessions.js +225 -22
- package/dist/sdk/sessions/subagentService.d.ts +24 -0
- package/dist/sdk/sessions/subagentService.js +225 -26
- package/dist/sdk/sessions/subagents.d.ts +10 -1
- package/dist/sdk/sessions/subagents.js +4 -0
- package/dist/sdk/sessions/workSlice.d.ts +106 -0
- package/dist/sdk/sessions/workSlice.js +329 -0
- package/dist/sdk/sessions/workspaceBoundary.d.ts +15 -0
- package/dist/sdk/sessions/workspaceBoundary.js +46 -0
- package/dist/sdk/terminal/browserControl.js +2 -1
- package/dist/sdk/terminal/controller.d.ts +31 -3
- package/dist/sdk/terminal/controller.js +81 -29
- package/dist/sdk/terminal/opentui/ansi.d.ts +25 -0
- package/dist/sdk/terminal/opentui/ansi.js +192 -0
- package/dist/sdk/terminal/opentui/model.d.ts +163 -0
- package/dist/sdk/terminal/opentui/model.js +482 -0
- package/dist/sdk/terminal/opentui/subagentsWidget.d.ts +3 -3
- package/dist/sdk/terminal/opentui/subagentsWidget.js +7 -5
- package/dist/sdk/terminal/opentui/theme.d.ts +43 -0
- package/dist/sdk/terminal/opentui/theme.js +88 -0
- package/dist/sdk/terminal/piExtension.d.ts +6 -1
- package/dist/sdk/terminal/piExtension.js +177 -63
- package/dist/sdk/terminal/standalone.d.ts +7 -0
- package/dist/sdk/terminal/standalone.js +72 -13
- package/dist/sdk/terminal/subagentMonitor.d.ts +28 -6
- package/dist/sdk/terminal/subagentMonitor.js +61 -9
- package/dist/sdk/terminal/terminals.d.ts +26 -2
- package/dist/sdk/terminal/terminals.js +325 -43
- package/dist/sdk/terminal/trajectory.d.ts +6 -1
- package/dist/sdk/terminal/trajectory.js +8 -0
- package/dist/sdk/terminal/tui/annotateCommand.d.ts +1 -1
- package/dist/sdk/terminal/tui/annotateCommand.js +3 -3
- package/dist/sdk/terminal/tui/chrome.d.ts +4 -0
- package/dist/sdk/terminal/tui/chrome.js +13 -0
- package/dist/sdk/terminal/tui/commandPages.d.ts +3 -1
- package/dist/sdk/terminal/tui/commandPages.js +17 -4
- package/dist/sdk/terminal/tui/commands.d.ts +6 -0
- package/dist/sdk/terminal/tui/commands.js +213 -124
- package/dist/sdk/terminal/tui/list.d.ts +14 -1
- package/dist/sdk/terminal/tui/list.js +96 -14
- package/dist/sdk/terminal/tui/pageOverlay.js +21 -5
- package/dist/sdk/terminal/tui/pages/annotatePage.d.ts +1 -1
- package/dist/sdk/terminal/tui/pages/browserPage.js +5 -4
- package/dist/sdk/terminal/tui/pages/hubPage.d.ts +14 -1
- package/dist/sdk/terminal/tui/pages/hubPage.js +192 -28
- package/dist/sdk/terminal/tui/pages/notesPage.d.ts +5 -5
- package/dist/sdk/terminal/tui/pages/notesPage.js +18 -18
- package/dist/sdk/terminal/tui/pages/pluginsPage.d.ts +8 -6
- package/dist/sdk/terminal/tui/pages/pluginsPage.js +206 -28
- package/dist/sdk/terminal/tui/pages/subagentsPage.d.ts +1 -0
- package/dist/sdk/terminal/tui/pages/subagentsPage.js +104 -19
- package/dist/sdk/terminal/tui/pages/usagePage.d.ts +43 -0
- package/dist/sdk/terminal/tui/pages/usagePage.js +370 -0
- package/dist/sdk/terminal/tui/piAdapter.d.ts +1 -2
- package/dist/sdk/terminal/tui/piAdapter.js +3 -5
- package/dist/sdk/terminal/tui/pluginCommands.d.ts +2 -0
- package/dist/sdk/terminal/tui/pluginCommands.js +13 -9
- package/dist/sdk/terminal/tui/runtime.js +23 -3
- package/dist/sdk/terminal/tui/sessionPicker.d.ts +40 -0
- package/dist/sdk/terminal/tui/sessionPicker.js +141 -0
- package/dist/sdk/tools/checkpoint.d.ts +27 -0
- package/dist/sdk/tools/checkpoint.js +154 -0
- package/dist/sdk/tools/getCapabilities.d.ts +31 -0
- package/dist/sdk/tools/getCapabilities.js +34 -0
- package/dist/sdk/tools/sessionName.d.ts +2 -0
- package/dist/sdk/tools/sessionName.js +5 -3
- package/dist/sdk/tools/spawnSubagent.js +11 -8
- package/dist/sdk/tools/todo.d.ts +15 -0
- package/dist/sdk/tools/todo.js +64 -0
- package/dist/sdk/usage/analytics.d.ts +20 -0
- package/dist/sdk/usage/analytics.js +151 -0
- package/dist/sdk/usage/ledger.d.ts +38 -0
- package/dist/sdk/usage/ledger.js +142 -0
- package/dist/sdk/usage/limits/adapters.d.ts +11 -0
- package/dist/sdk/usage/limits/adapters.js +349 -0
- package/dist/sdk/usage/limits/capture.d.ts +8 -0
- package/dist/sdk/usage/limits/capture.js +47 -0
- package/dist/sdk/usage/limits/http.d.ts +12 -0
- package/dist/sdk/usage/limits/http.js +51 -0
- package/dist/sdk/usage/limits/normalize.d.ts +15 -0
- package/dist/sdk/usage/limits/normalize.js +211 -0
- package/dist/sdk/usage/limits/service.d.ts +30 -0
- package/dist/sdk/usage/limits/service.js +176 -0
- package/dist/sdk/usage/limits/types.d.ts +65 -0
- package/dist/sdk/usage/limits/types.js +1 -0
- package/dist/sdk/usage/serverMethods.d.ts +3 -0
- package/dist/sdk/usage/serverMethods.js +22 -0
- package/dist/sdk/usage/service.d.ts +32 -0
- package/dist/sdk/usage/service.js +66 -0
- package/dist/sdk/usage/settings.d.ts +7 -0
- package/dist/sdk/usage/settings.js +28 -0
- package/dist/sdk/usage/types.d.ts +60 -0
- package/dist/sdk/usage/types.js +4 -0
- package/dist/terminal-opentui.js +9204 -4812
- package/dist/terminal-pi.js +1848 -272
- package/docs/architecture/00-overview.md +1 -1
- package/docs/architecture/01-extension-points.md +1 -1
- package/docs/architecture/02-sessions-and-runs.md +169 -36
- package/docs/architecture/04-prompt.md +55 -15
- package/docs/architecture/06-plugins-and-capabilities.md +36 -15
- package/docs/architecture/07-tools-and-gate.md +131 -25
- package/docs/architecture/08-memory-and-history.md +4 -2
- package/docs/architecture/09-accounts-and-connectors.md +39 -3
- package/docs/architecture/10-server-protocol.md +71 -9
- package/docs/architecture/11-terminal.md +148 -60
- package/docs/architecture/12-storage.md +30 -2
- package/docs/architecture/13-world-tools.md +22 -1
- package/docs/architecture/14-surfaces-and-parity.md +58 -8
- package/docs/architecture/README.md +20 -17
- package/docs/architecture/proposals/PROP-0006-run-checklist.md +2 -0
- package/docs/architecture/proposals/PROP-0017-page-annotations.md +6 -2
- package/docs/architecture/proposals/PROP-0018-annotation-queue-and-app-targets.md +1 -1
- package/docs/architecture/proposals/PROP-0031-plugin-command-owner-namespaces.md +54 -0
- package/docs/architecture/proposals/PROP-0032-planning-quality.md +196 -0
- package/docs/architecture/proposals/PROP-0033-compaction-plan-checkpoints.md +75 -0
- package/docs/architecture/proposals/PROP-0034-conversation-fast-mode.md +120 -0
- package/docs/architecture/proposals/PROP-0035-retain-subagent-status.md +47 -0
- package/docs/architecture/proposals/PROP-0036-first-class-harness-commands.md +59 -0
- package/docs/architecture/proposals/PROP-0037-workspace-write-boundary.md +63 -0
- package/docs/architecture/proposals/PROP-0038-annotate-open-shadow-roots.md +73 -0
- package/docs/architecture/proposals/PROP-0039-workspace-boundary-hardening.md +139 -0
- package/docs/architecture/proposals/PROP-0040-one-launch-path.md +87 -0
- package/docs/architecture/proposals/PROP-0041-bounded-work-slices.md +258 -0
- package/docs/architecture/proposals/PROP-0042-usage-and-provider-limits.md +127 -0
- package/docs/architecture/proposals/PROP-0043-read-only-plan-bash.md +74 -0
- package/docs/architecture/proposals/PROP-0044-work-slice-defaults.md +93 -0
- package/docs/architecture/proposals/PROP-0045-rename-checklist-to-todo.md +132 -0
- package/docs/architecture/proposals/PROP-0046-progress-aware-stall-guards.md +82 -0
- package/docs/architecture/proposals/PROP-0047-plugins-hub-separation.md +122 -0
- package/docs/architecture/proposals/README.md +24 -6
- package/docs/decisions/ADR-0001-owned-terminal.md +1 -1
- package/docs/decisions/ADR-0021-required-command-namespaces.md +1 -1
- package/docs/decisions/ADR-0031-plugin-command-owner-namespaces.md +37 -0
- package/docs/decisions/ADR-0032-compaction-run-checkpoints.md +33 -0
- package/docs/decisions/ADR-0033-plan-mode-research-delegation.md +47 -0
- package/docs/decisions/ADR-0034-first-class-harness-terminal-commands.md +25 -0
- package/docs/decisions/ADR-0035-one-launch-path.md +40 -0
- package/docs/decisions/ADR-0036-workspace-write-operation-boundary.md +54 -0
- package/docs/decisions/ADR-0037-usage-ledger-and-provider-limits.md +44 -0
- package/docs/decisions/ADR-0038-plan-bash-os-read-only.md +29 -0
- package/docs/decisions/ADR-0039-progress-aware-stall-guards.md +39 -0
- package/docs/decisions/ADR-0040-architecture-change-workflow.md +31 -0
- package/docs/decisions/ADR-0041-plugins-hub-separation.md +41 -0
- package/docs/decisions/ADR-0042-windows-shell-without-sandbox.md +40 -0
- package/docs/decisions/ADR-0043-parents-continue-stopped-subagents.md +49 -0
- package/docs/doctor.md +14 -1
- package/docs/experiments/EXP-0003-performance-audit/data/session-runtime-replication.json +420 -0
- package/docs/experiments/EXP-0003-performance-audit/data/session-runtime.json +420 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-compact.json +376 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-history.json +422 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-question.json +95 -0
- package/docs/experiments/EXP-0003-performance-audit/data/terminal-wide.json +1036 -0
- package/docs/experiments/EXP-0003-performance-audit/plan.md +109 -0
- package/docs/experiments/EXP-0003-performance-audit/results.md +151 -0
- package/docs/handoff-2026-10-25-app-parity-and-solo-tabs.md +202 -0
- package/docs/parity.md +83 -27
- package/docs/releases/1.1.1.md +28 -0
- package/docs/releases/1.2.0.md +49 -0
- package/docs/releases/1.3.0.md +21 -0
- package/docs/releases/4.0.0.md +10 -9
- package/docs/releases/README.md +35 -30
- package/docs/study/00-index.md +3 -0
- package/docs/study/STUDY-0003-long-horizon-runs.md +210 -0
- package/docs/terminal-tui.md +162 -82
- package/package.json +4 -3
- package/dist/sdk/tools/checklist.d.ts +0 -9
- package/dist/sdk/tools/checklist.js +0 -54
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { usagePayloadSchema } from "../sessions/contracts.js";
|
|
2
|
+
/** The main agent's row: the parent run itself, shown by name rather than by a profile. */
|
|
3
|
+
export const MAIN_PROFILE = { name: 'main', color: 'main' };
|
|
1
4
|
export const ACTIVE_SUBAGENT_STATUSES = new Set(['queued', 'running', 'waiting_for_approval', 'waiting_for_input']);
|
|
2
5
|
export function terminalSubagentDuration(activity, now = Date.now()) {
|
|
3
6
|
const start = Date.parse(activity.startedAt);
|
|
@@ -41,7 +44,7 @@ function stringOf(value) {
|
|
|
41
44
|
function latestTool(tools) {
|
|
42
45
|
return [...tools.values()].sort((left, right) => right.sequence - left.sequence)[0]?.text;
|
|
43
46
|
}
|
|
44
|
-
/** Volatile, read-only activity projection for the
|
|
47
|
+
/** Volatile, read-only activity projection for the latest terminal parent run. */
|
|
45
48
|
export class SubagentMonitor {
|
|
46
49
|
parentRunId = null;
|
|
47
50
|
activities = new Map();
|
|
@@ -49,8 +52,11 @@ export class SubagentMonitor {
|
|
|
49
52
|
this.parentRunId = parentRunId;
|
|
50
53
|
this.activities.clear();
|
|
51
54
|
}
|
|
55
|
+
/** Folds one event of the tracked parent (`main`) or one of its descendants; `null` seeds the row. */
|
|
52
56
|
observe(parentRunId, run, event) {
|
|
53
|
-
if (this.parentRunId !== parentRunId
|
|
57
|
+
if (this.parentRunId !== parentRunId)
|
|
58
|
+
return;
|
|
59
|
+
if ((run.relation === 'main') !== (run.id === parentRunId))
|
|
54
60
|
return;
|
|
55
61
|
const row = this.activities.get(run.id) ?? {
|
|
56
62
|
id: run.id,
|
|
@@ -62,21 +68,34 @@ export class SubagentMonitor {
|
|
|
62
68
|
startedAt: run.startedAt,
|
|
63
69
|
endedAt: run.endedAt,
|
|
64
70
|
activity: statusActivity(run.status),
|
|
65
|
-
|
|
71
|
+
todo: null,
|
|
66
72
|
profile: run.profile ?? null,
|
|
73
|
+
accountLabel: run.accountLabel ?? null,
|
|
74
|
+
model: run.model ?? null,
|
|
75
|
+
effort: run.effort ?? null,
|
|
76
|
+
usage: null,
|
|
67
77
|
tools: new Map(),
|
|
68
78
|
lastTool: null
|
|
69
79
|
};
|
|
70
80
|
row.parentRunId = run.parentRunId;
|
|
71
81
|
if (run.profile !== undefined)
|
|
72
82
|
row.profile = run.profile;
|
|
83
|
+
if (run.accountLabel !== undefined)
|
|
84
|
+
row.accountLabel = run.accountLabel;
|
|
85
|
+
if (run.model !== undefined && !row.usage?.model)
|
|
86
|
+
row.model = run.model;
|
|
87
|
+
if (run.effort !== undefined)
|
|
88
|
+
row.effort = run.effort;
|
|
73
89
|
row.title = run.title;
|
|
74
90
|
row.goal = run.goal;
|
|
75
91
|
row.status = run.status;
|
|
76
92
|
row.startedAt = run.startedAt;
|
|
77
93
|
row.endedAt = run.endedAt;
|
|
78
|
-
const payload = payloadOf(event);
|
|
79
|
-
if (event
|
|
94
|
+
const payload = event ? payloadOf(event) : {};
|
|
95
|
+
if (!event) {
|
|
96
|
+
// A seeded row keeps what it already folded.
|
|
97
|
+
}
|
|
98
|
+
else if (event.type === 'tool.started') {
|
|
80
99
|
const toolCallId = stringOf(payload.toolCallId);
|
|
81
100
|
const name = stringOf(payload.name) ?? 'Tool';
|
|
82
101
|
if (toolCallId)
|
|
@@ -94,22 +113,55 @@ export class SubagentMonitor {
|
|
|
94
113
|
row.lastTool = null;
|
|
95
114
|
row.activity = 'Responding';
|
|
96
115
|
}
|
|
97
|
-
else if (event.type === '
|
|
116
|
+
else if (event.type === 'usage.updated') {
|
|
117
|
+
const parsed = usagePayloadSchema.safeParse(payload);
|
|
118
|
+
if (parsed.success) {
|
|
119
|
+
const usage = parsed.data;
|
|
120
|
+
row.usage = {
|
|
121
|
+
...(usage.provider === undefined ? {} : { provider: usage.provider }),
|
|
122
|
+
...(usage.model === undefined ? {} : { model: usage.model }),
|
|
123
|
+
...(usage.inputTokens === undefined ? {} : { inputTokens: usage.inputTokens }),
|
|
124
|
+
...(usage.outputTokens === undefined ? {} : { outputTokens: usage.outputTokens }),
|
|
125
|
+
...(usage.cacheReadTokens === undefined ? {} : { cacheReadTokens: usage.cacheReadTokens }),
|
|
126
|
+
...(usage.cacheWriteTokens === undefined ? {} : { cacheWriteTokens: usage.cacheWriteTokens }),
|
|
127
|
+
...(usage.reasoningTokens === undefined ? {} : { reasoningTokens: usage.reasoningTokens }),
|
|
128
|
+
...(usage.costUsd === undefined ? {} : { costUsd: usage.costUsd }),
|
|
129
|
+
...(usage.costSource === undefined ? {} : { costSource: usage.costSource }),
|
|
130
|
+
...(usage.requests === undefined ? {} : { requests: usage.requests }),
|
|
131
|
+
...(usage.contextTokens === undefined ? {} : { contextTokens: usage.contextTokens }),
|
|
132
|
+
...(usage.contextWindow === undefined ? {} : { contextWindow: usage.contextWindow })
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else if (event.type === 'todo.updated' || event.type === 'checklist.updated') {
|
|
98
137
|
const items = Array.isArray(payload.items) ? payload.items : [];
|
|
99
|
-
row.
|
|
138
|
+
row.todo = items.length ? { done: items.filter(item => item?.status === 'completed').length, total: items.length } : null;
|
|
100
139
|
}
|
|
101
140
|
if (run.status !== 'running')
|
|
102
141
|
row.tools.clear();
|
|
103
142
|
row.activity = run.status === 'running'
|
|
104
|
-
? latestTool(row.tools) ?? row.lastTool?.text ?? (event
|
|
143
|
+
? latestTool(row.tools) ?? row.lastTool?.text ?? (event?.type === 'message.delta' || (!event && row.activity === 'Responding') ? 'Responding' : 'Working')
|
|
105
144
|
: statusActivity(run.status);
|
|
106
145
|
this.activities.set(run.id, row);
|
|
107
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Rebuilds the rows of a parent run that is no longer live, such as the latest one of a reopened
|
|
149
|
+
* conversation, by folding each run's saved events. Rows keep their final status.
|
|
150
|
+
*/
|
|
151
|
+
restore(parentRunId, runs) {
|
|
152
|
+
this.begin(parentRunId);
|
|
153
|
+
for (const { run, events } of runs) {
|
|
154
|
+
this.observe(parentRunId, run, null);
|
|
155
|
+
for (const event of events)
|
|
156
|
+
this.observe(parentRunId, run, event);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** The main row first, then children in start order. */
|
|
108
160
|
snapshot(parentRunId) {
|
|
109
161
|
if (this.parentRunId !== parentRunId)
|
|
110
162
|
return [];
|
|
111
163
|
return [...this.activities.values()]
|
|
112
|
-
.sort((left, right) => left.startedAt.localeCompare(right.startedAt) || left.id.localeCompare(right.id))
|
|
164
|
+
.sort((left, right) => Number(right.relation === 'main') - Number(left.relation === 'main') || left.startedAt.localeCompare(right.startedAt) || left.id.localeCompare(right.id))
|
|
113
165
|
.map(({ tools: _tools, lastTool: _lastTool, ...activity }) => activity);
|
|
114
166
|
}
|
|
115
167
|
clear(parentRunId) {
|
|
@@ -22,6 +22,8 @@ import type { World } from "../world/world.js";
|
|
|
22
22
|
import type { Worktrees } from "../worktrees/service.js";
|
|
23
23
|
import type { AnnotationCapture } from "../annotations/capture.js";
|
|
24
24
|
import type { NoteDeliveries } from "../annotations/delivery.js";
|
|
25
|
+
import type { Usage } from "../usage/service.js";
|
|
26
|
+
import type { UsageLimits } from "../usage/limits/service.js";
|
|
25
27
|
/** The files a terminal session needs on disk, outside this process. */
|
|
26
28
|
export interface TerminalAssets {
|
|
27
29
|
/** The Node binary that runs the commands. */
|
|
@@ -103,6 +105,10 @@ export interface TerminalsOptions {
|
|
|
103
105
|
noteCapture?: AnnotationCapture;
|
|
104
106
|
/** Page notes on their way to a session (PROP-0018). */
|
|
105
107
|
pageNotes?: NoteDeliveries;
|
|
108
|
+
/** Usage analytics over the derived ledger (`/usage:analysis`). */
|
|
109
|
+
usage?: Usage;
|
|
110
|
+
/** Provider plan windows, balances and rate limits (`/usage:limit`). */
|
|
111
|
+
usageLimits?: UsageLimits;
|
|
106
112
|
}
|
|
107
113
|
/** What `/plugins` in a terminal can do. Each takes the session's folder, account and project. */
|
|
108
114
|
export interface PluginControl {
|
|
@@ -144,13 +150,27 @@ export declare class Terminals {
|
|
|
144
150
|
/** Each child's profile name and colour, looked up once per child run. */
|
|
145
151
|
private readonly childProfiles;
|
|
146
152
|
private subagentProfile;
|
|
153
|
+
/** Account, model and effort for a monitor row, from the run record. */
|
|
154
|
+
private monitorRuntime;
|
|
155
|
+
/**
|
|
156
|
+
* Shows the reopened conversation's latest parent run again: the last owner on its native branch
|
|
157
|
+
* that ran in this folder, with every descendant flat, as each ended.
|
|
158
|
+
*/
|
|
159
|
+
private hydrateMonitor;
|
|
147
160
|
constructor(options: TerminalsOptions);
|
|
148
161
|
/** The commands a terminal session finds on PATH. Rewritten only when they change. */
|
|
149
162
|
private ensureCommands;
|
|
150
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* The harness's own History, Wiki and skill tools, then the broker's, then the world tools whose
|
|
165
|
+
* plugins are on for this session: the same tools a structured session has (INV-PAR-1).
|
|
166
|
+
*/
|
|
151
167
|
private tools;
|
|
168
|
+
private readonly ownNames;
|
|
169
|
+
private ownTools;
|
|
152
170
|
/** The world tools a new session will have, named in its instructions. */
|
|
153
171
|
private worldToolNames;
|
|
172
|
+
/** The harness's own History, Wiki and skill tools a new session will have. */
|
|
173
|
+
private ownToolNames;
|
|
154
174
|
/** Whether a world tool's plugin is switched on for a session's folder, account and project. */
|
|
155
175
|
private worldOn;
|
|
156
176
|
private appsCall;
|
|
@@ -169,7 +189,9 @@ export declare class Terminals {
|
|
|
169
189
|
private agentsCall;
|
|
170
190
|
/** `/worktree`: the managed worktrees of the repository this session works in. */
|
|
171
191
|
private worktreesCall;
|
|
172
|
-
/** `/
|
|
192
|
+
/** `/usage:analysis` and `/usage:limit`: usage for this session's own account, project or session. */
|
|
193
|
+
private usageCall;
|
|
194
|
+
/** `/annotate:notes` and `/annotate:`: Web annotations and their visible capture browser. */
|
|
173
195
|
private annotationsCall;
|
|
174
196
|
/** The account a session asked to switch to. Taken once, after its Pi process has ended and before `dispose`. */
|
|
175
197
|
takeRelaunch(sessionId: string): TerminalRelaunch | null;
|
|
@@ -179,6 +201,8 @@ export declare class Terminals {
|
|
|
179
201
|
/** The run a native turn reports into: the one reserved by `send`, or a new one for what the person typed. */
|
|
180
202
|
private begin;
|
|
181
203
|
private decide;
|
|
204
|
+
private workspaceEscape;
|
|
205
|
+
private workspaceBoundaryBypass;
|
|
182
206
|
private subagentsCall;
|
|
183
207
|
private componentsCall;
|
|
184
208
|
private trajectoryCall;
|