@redplanethq/corebrain 2.8.5 → 2.8.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/dist/assets/assets/AppIcon.icns +0 -0
- package/dist/commands/coding/read.d.ts +0 -4
- package/dist/commands/coding/read.d.ts.map +1 -1
- package/dist/commands/coding/read.js +15 -25
- package/dist/commands/coding/read.js.map +1 -1
- package/dist/commands/gateway/start.d.ts.map +1 -1
- package/dist/commands/gateway/start.js +32 -2
- package/dist/commands/gateway/start.js.map +1 -1
- package/dist/server/tools/coding-tools.d.ts.map +1 -1
- package/dist/server/tools/coding-tools.js +52 -30
- package/dist/server/tools/coding-tools.js.map +1 -1
- package/dist/tui/chat.d.ts.map +1 -1
- package/dist/tui/chat.js +278 -91
- package/dist/tui/chat.js.map +1 -1
- package/dist/tui/components/approval-bar.d.ts +14 -0
- package/dist/tui/components/approval-bar.d.ts.map +1 -0
- package/dist/tui/components/approval-bar.js +32 -0
- package/dist/tui/components/approval-bar.js.map +1 -0
- package/dist/tui/components/approval-panel.d.ts +31 -0
- package/dist/tui/components/approval-panel.d.ts.map +1 -0
- package/dist/tui/components/approval-panel.js +184 -0
- package/dist/tui/components/approval-panel.js.map +1 -0
- package/dist/tui/components/dashboard-view.d.ts +20 -0
- package/dist/tui/components/dashboard-view.d.ts.map +1 -0
- package/dist/tui/components/dashboard-view.js +147 -0
- package/dist/tui/components/dashboard-view.js.map +1 -0
- package/dist/tui/components/status-line.d.ts +18 -0
- package/dist/tui/components/status-line.d.ts.map +1 -0
- package/dist/tui/components/status-line.js +47 -0
- package/dist/tui/components/status-line.js.map +1 -0
- package/dist/tui/components/tool-call-item.d.ts +26 -0
- package/dist/tui/components/tool-call-item.d.ts.map +1 -1
- package/dist/tui/components/tool-call-item.js +53 -3
- package/dist/tui/components/tool-call-item.js.map +1 -1
- package/dist/tui/components/widgets-view.d.ts +33 -0
- package/dist/tui/components/widgets-view.d.ts.map +1 -0
- package/dist/tui/components/widgets-view.js +270 -0
- package/dist/tui/components/widgets-view.js.map +1 -0
- package/dist/tui/hooks/use-conversation.d.ts +4 -0
- package/dist/tui/hooks/use-conversation.d.ts.map +1 -1
- package/dist/tui/hooks/use-conversation.js +316 -109
- package/dist/tui/hooks/use-conversation.js.map +1 -1
- package/dist/tui/utils/avatar.d.ts +27 -0
- package/dist/tui/utils/avatar.d.ts.map +1 -0
- package/dist/tui/utils/avatar.js +96 -0
- package/dist/tui/utils/avatar.js.map +1 -0
- package/dist/tui/utils/bundle-loader.d.ts +3 -0
- package/dist/tui/utils/bundle-loader.d.ts.map +1 -0
- package/dist/tui/utils/bundle-loader.js +49 -0
- package/dist/tui/utils/bundle-loader.js.map +1 -0
- package/dist/tui/utils/integration-loader.d.ts +14 -0
- package/dist/tui/utils/integration-loader.d.ts.map +1 -0
- package/dist/tui/utils/integration-loader.js +6 -0
- package/dist/tui/utils/integration-loader.js.map +1 -0
- package/dist/tui/utils/stream.d.ts +43 -5
- package/dist/tui/utils/stream.d.ts.map +1 -1
- package/dist/tui/utils/stream.js +85 -24
- package/dist/tui/utils/stream.js.map +1 -1
- package/dist/tui/utils/widget-loader.d.ts +20 -0
- package/dist/tui/utils/widget-loader.d.ts.map +1 -0
- package/dist/tui/utils/widget-loader.js +6 -0
- package/dist/tui/utils/widget-loader.js.map +1 -0
- package/dist/types/config.d.ts +12 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/coding-agents/claude-code.d.ts +3 -1
- package/dist/utils/coding-agents/claude-code.d.ts.map +1 -1
- package/dist/utils/coding-agents/claude-code.js +35 -0
- package/dist/utils/coding-agents/claude-code.js.map +1 -1
- package/dist/utils/coding-agents/codex.d.ts +3 -1
- package/dist/utils/coding-agents/codex.d.ts.map +1 -1
- package/dist/utils/coding-agents/codex.js +40 -0
- package/dist/utils/coding-agents/codex.js.map +1 -1
- package/dist/utils/coding-agents/index.d.ts +6 -3
- package/dist/utils/coding-agents/index.d.ts.map +1 -1
- package/dist/utils/coding-agents/index.js +13 -2
- package/dist/utils/coding-agents/index.js.map +1 -1
- package/dist/utils/coding-agents/types.d.ts +14 -0
- package/dist/utils/coding-agents/types.d.ts.map +1 -1
- package/dist/utils/coding-agents/types.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Component } from '@mariozechner/pi-tui';
|
|
2
|
+
export interface PendingApproval {
|
|
3
|
+
approvalId: string;
|
|
4
|
+
toolCallId: string;
|
|
5
|
+
toolName: string;
|
|
6
|
+
input?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare class ApprovalPanel implements Component {
|
|
9
|
+
private pendingApprovals;
|
|
10
|
+
private selectedOption;
|
|
11
|
+
private accountFrontendMap;
|
|
12
|
+
private requestRender;
|
|
13
|
+
private toolUIComp;
|
|
14
|
+
/** Called with (approved, acceptAll) when user confirms */
|
|
15
|
+
onSelect?: (approved: boolean, acceptAll: boolean) => void;
|
|
16
|
+
constructor(accountFrontendMap: Map<string, string>, requestRender: () => void);
|
|
17
|
+
addApproval(approval: PendingApproval): void;
|
|
18
|
+
get count(): number;
|
|
19
|
+
private tryLoadToolUI;
|
|
20
|
+
/** Move selection up */
|
|
21
|
+
moveUp(): void;
|
|
22
|
+
/** Move selection down */
|
|
23
|
+
moveDown(): void;
|
|
24
|
+
/** Shift+Tab → jump straight to "Yes, allow all" */
|
|
25
|
+
selectAllowAll(): void;
|
|
26
|
+
/** Confirm current selection, or pass explicit index */
|
|
27
|
+
confirm(optionIndex?: number): void;
|
|
28
|
+
render(width: number): string[];
|
|
29
|
+
invalidate(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=approval-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-panel.d.ts","sourceRoot":"","sources":["../../../src/tui/components/approval-panel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAKpD,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAsBD,qBAAa,aAAc,YAAW,SAAS;IAC9C,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,UAAU,CAA0B;IAE5C,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;gBAG1D,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,aAAa,EAAE,MAAM,IAAI;IAM1B,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAO5C,IAAI,KAAK,IAAI,MAAM,CAElB;YAEa,aAAa;IAwC3B,wBAAwB;IACxB,MAAM,IAAI,IAAI;IAId,0BAA0B;IAC1B,QAAQ,IAAI,IAAI;IAIhB,oDAAoD;IACpD,cAAc,IAAI,IAAI;IAItB,wDAAwD;IACxD,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI;IAWnC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAkE/B,UAAU,IAAI,IAAI;CAGlB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { truncateToWidth } from '@mariozechner/pi-tui';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { getToolDisplayName } from '../utils/tool-names.js';
|
|
4
|
+
import { loadIntegrationBundle } from '../utils/integration-loader.js';
|
|
5
|
+
const toTitleCase = (s) => s
|
|
6
|
+
.split('_')
|
|
7
|
+
.map((w, i) => (i === 0 ? w.charAt(0).toUpperCase() + w.slice(1) : w))
|
|
8
|
+
.join(' ');
|
|
9
|
+
function resolveDisplayName(toolName, input) {
|
|
10
|
+
if (toolName === 'execute_integration_action' && typeof input?.action === 'string') {
|
|
11
|
+
return toTitleCase(input.action);
|
|
12
|
+
}
|
|
13
|
+
return getToolDisplayName(toolName);
|
|
14
|
+
}
|
|
15
|
+
// 0 = Yes, 1 = Yes allow all, 2 = No
|
|
16
|
+
const OPTIONS = [
|
|
17
|
+
{ label: 'Yes' },
|
|
18
|
+
{ label: 'Yes, allow all during this session', hint: '(shift+tab)' },
|
|
19
|
+
{ label: 'No' },
|
|
20
|
+
];
|
|
21
|
+
export class ApprovalPanel {
|
|
22
|
+
pendingApprovals = [];
|
|
23
|
+
selectedOption = 0; // 0=Yes, 1=Yes allow all, 2=No
|
|
24
|
+
accountFrontendMap;
|
|
25
|
+
requestRender;
|
|
26
|
+
toolUIComp = null;
|
|
27
|
+
/** Called with (approved, acceptAll) when user confirms */
|
|
28
|
+
onSelect;
|
|
29
|
+
constructor(accountFrontendMap, requestRender) {
|
|
30
|
+
this.accountFrontendMap = accountFrontendMap;
|
|
31
|
+
this.requestRender = requestRender;
|
|
32
|
+
}
|
|
33
|
+
addApproval(approval) {
|
|
34
|
+
this.pendingApprovals.push(approval);
|
|
35
|
+
if (this.pendingApprovals.length === 1) {
|
|
36
|
+
void this.tryLoadToolUI(approval);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get count() {
|
|
40
|
+
return this.pendingApprovals.length;
|
|
41
|
+
}
|
|
42
|
+
async tryLoadToolUI(approval) {
|
|
43
|
+
if (approval.toolName !== 'execute_integration_action')
|
|
44
|
+
return;
|
|
45
|
+
const accountId = typeof approval.input?.accountId === 'string' ? approval.input.accountId : undefined;
|
|
46
|
+
if (!accountId)
|
|
47
|
+
return;
|
|
48
|
+
const frontendUrl = this.accountFrontendMap.get(accountId);
|
|
49
|
+
if (!frontendUrl)
|
|
50
|
+
return;
|
|
51
|
+
try {
|
|
52
|
+
const { toolUI } = await loadIntegrationBundle(frontendUrl);
|
|
53
|
+
const effectiveAction = typeof approval.input?.action === 'string' ? approval.input.action : null;
|
|
54
|
+
if (!toolUI || !effectiveAction || !toolUI.supported_tools.includes(effectiveAction))
|
|
55
|
+
return;
|
|
56
|
+
let inputParameters = {};
|
|
57
|
+
try {
|
|
58
|
+
inputParameters = JSON.parse(approval.input?.parameters);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// use empty object
|
|
62
|
+
}
|
|
63
|
+
const comp = await toolUI.render(effectiveAction, inputParameters, null, { placement: 'tui' }, () => this.confirm(), () => this.confirm(2));
|
|
64
|
+
if (comp && typeof comp.render === 'function') {
|
|
65
|
+
this.toolUIComp = comp;
|
|
66
|
+
this.requestRender();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// fall through to generic display
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Move selection up */
|
|
74
|
+
moveUp() {
|
|
75
|
+
this.selectedOption = (this.selectedOption + OPTIONS.length - 1) % OPTIONS.length;
|
|
76
|
+
}
|
|
77
|
+
/** Move selection down */
|
|
78
|
+
moveDown() {
|
|
79
|
+
this.selectedOption = (this.selectedOption + 1) % OPTIONS.length;
|
|
80
|
+
}
|
|
81
|
+
/** Shift+Tab → jump straight to "Yes, allow all" */
|
|
82
|
+
selectAllowAll() {
|
|
83
|
+
this.selectedOption = 1;
|
|
84
|
+
}
|
|
85
|
+
/** Confirm current selection, or pass explicit index */
|
|
86
|
+
confirm(optionIndex) {
|
|
87
|
+
const idx = optionIndex ?? this.selectedOption;
|
|
88
|
+
if (idx === 0) {
|
|
89
|
+
this.onSelect?.(true, false);
|
|
90
|
+
}
|
|
91
|
+
else if (idx === 1) {
|
|
92
|
+
this.onSelect?.(true, true);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.onSelect?.(false, false);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
render(width) {
|
|
99
|
+
const lines = [];
|
|
100
|
+
const active = this.pendingApprovals[0];
|
|
101
|
+
const n = this.pendingApprovals.length;
|
|
102
|
+
if (!active)
|
|
103
|
+
return lines;
|
|
104
|
+
const displayName = resolveDisplayName(active.toolName, active.input);
|
|
105
|
+
// ── Title (bold tool name) ────────────────────────────────────────────
|
|
106
|
+
lines.push(truncateToWidth(chalk.bold.white(displayName), width));
|
|
107
|
+
// Sub-title: queued count if >1
|
|
108
|
+
if (n > 1) {
|
|
109
|
+
const queued = this.pendingApprovals
|
|
110
|
+
.slice(1)
|
|
111
|
+
.map(a => resolveDisplayName(a.toolName, a.input))
|
|
112
|
+
.join(', ');
|
|
113
|
+
lines.push(truncateToWidth(chalk.dim(`+${n - 1} queued: ${queued}`), width));
|
|
114
|
+
}
|
|
115
|
+
lines.push('');
|
|
116
|
+
// ── Content: toolUI or args preview ──────────────────────────────────
|
|
117
|
+
if (this.toolUIComp) {
|
|
118
|
+
for (const line of this.toolUIComp.render(width)) {
|
|
119
|
+
lines.push(line);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
const argsToShow = buildArgsPreview(active.toolName, active.input);
|
|
124
|
+
if (argsToShow) {
|
|
125
|
+
const argLines = argsToShow.split('\n');
|
|
126
|
+
for (const line of argLines) {
|
|
127
|
+
lines.push(truncateToWidth(chalk.dim(line), width));
|
|
128
|
+
}
|
|
129
|
+
lines.push('');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// ── Question ─────────────────────────────────────────────────────────
|
|
133
|
+
lines.push(truncateToWidth(`Do you want to run ${chalk.bold(displayName)}?`, width));
|
|
134
|
+
// ── Options ──────────────────────────────────────────────────────────
|
|
135
|
+
for (let i = 0; i < OPTIONS.length; i++) {
|
|
136
|
+
const opt = OPTIONS[i];
|
|
137
|
+
const isSelected = i === this.selectedOption;
|
|
138
|
+
const arrow = isSelected ? chalk.green('\u203a') : ' ';
|
|
139
|
+
const num = chalk.dim(`${i + 1}.`);
|
|
140
|
+
const label = isSelected ? chalk.green(opt.label) : opt.label;
|
|
141
|
+
const hint = 'hint' in opt ? chalk.dim(` ${opt.hint}`) : '';
|
|
142
|
+
lines.push(truncateToWidth(`${arrow} ${num} ${label}${hint}`, width));
|
|
143
|
+
}
|
|
144
|
+
lines.push('');
|
|
145
|
+
lines.push(truncateToWidth(chalk.dim('Esc to cancel \xb7 \u2191\u2193 to navigate \xb7 enter to confirm'), width));
|
|
146
|
+
return lines;
|
|
147
|
+
}
|
|
148
|
+
invalidate() {
|
|
149
|
+
this.toolUIComp?.invalidate?.();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Build a concise args preview string for the active tool
|
|
153
|
+
function buildArgsPreview(toolName, input) {
|
|
154
|
+
if (!input)
|
|
155
|
+
return null;
|
|
156
|
+
// For integration actions, show the parsed parameters
|
|
157
|
+
if (toolName === 'execute_integration_action') {
|
|
158
|
+
const params = {};
|
|
159
|
+
if (typeof input.action === 'string')
|
|
160
|
+
params.action = input.action;
|
|
161
|
+
if (typeof input.parameters === 'string') {
|
|
162
|
+
try {
|
|
163
|
+
const parsed = JSON.parse(input.parameters);
|
|
164
|
+
Object.assign(params, parsed);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// keep raw
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (Object.keys(params).length === 0)
|
|
171
|
+
return null;
|
|
172
|
+
return JSON.stringify(params, null, 2);
|
|
173
|
+
}
|
|
174
|
+
// Generic: show full input, max 10 lines
|
|
175
|
+
const keys = Object.keys(input);
|
|
176
|
+
if (keys.length === 0)
|
|
177
|
+
return null;
|
|
178
|
+
const lines = JSON.stringify(input, null, 2).split('\n');
|
|
179
|
+
if (lines.length > 10) {
|
|
180
|
+
return lines.slice(0, 10).join('\n') + `\n… +${lines.length - 10} more lines`;
|
|
181
|
+
}
|
|
182
|
+
return lines.join('\n');
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=approval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C,UAAU,CAA4B,CAAC;gBACvE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACR,WAAW;YACZ,CAAC;QACF,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAClD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,yCAAyC;IACzC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,KAAK,CAAC,MAAM,GAAG,EAAE,aAAa,CAAC;IAC/E,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component, TUI } from '@mariozechner/pi-tui';
|
|
2
|
+
export declare class DashboardView implements Component {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
private apiKey;
|
|
5
|
+
private tui;
|
|
6
|
+
private onRender;
|
|
7
|
+
private container;
|
|
8
|
+
private headerText;
|
|
9
|
+
private bodyContainer;
|
|
10
|
+
private bodyChildren;
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
constructor(baseUrl: string, apiKey: string, tui: TUI, onRender: () => void);
|
|
13
|
+
private addToBody;
|
|
14
|
+
private load;
|
|
15
|
+
private loadAndRenderWidget;
|
|
16
|
+
handleInput(data: string): void;
|
|
17
|
+
render(width: number): string[];
|
|
18
|
+
invalidate(): void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=dashboard-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-view.d.ts","sourceRoot":"","sources":["../../../src/tui/components/dashboard-view.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAE,GAAG,EAAC,MAAM,sBAAsB,CAAC;AAgDzD,qBAAa,aAAc,YAAW,SAAS;IAS7C,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ;IAXjB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,UAAU,CAAO;IACzB,OAAO,CAAC,aAAa,CAAY;IACjC,OAAO,CAAC,YAAY,CAAmB;IAEvC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;gBAGb,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,IAAI;IAkB7B,OAAO,CAAC,SAAS;YAKH,IAAI;YAuBJ,mBAAmB;IA+EjC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAM/B,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI/B,UAAU,IAAI,IAAI;CAGlB"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Text, Spacer, Container, Loader, matchesKey, Key } from '@mariozechner/pi-tui';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { loadWidgetBundle } from '../utils/widget-loader.js';
|
|
4
|
+
import { getPreferences } from '../../config/preferences.js';
|
|
5
|
+
/** Wraps a pi-tui Component in a unicode border box */
|
|
6
|
+
class BoxedComponent {
|
|
7
|
+
inner;
|
|
8
|
+
title;
|
|
9
|
+
constructor(inner, title) {
|
|
10
|
+
this.inner = inner;
|
|
11
|
+
this.title = title;
|
|
12
|
+
}
|
|
13
|
+
render(width) {
|
|
14
|
+
const innerWidth = Math.max(0, width - 4);
|
|
15
|
+
const innerLines = this.inner.render(innerWidth);
|
|
16
|
+
const titleStr = ` ${this.title} `;
|
|
17
|
+
const topFill = Math.max(0, width - 4 - titleStr.length);
|
|
18
|
+
const top = '┌─' + titleStr + '─'.repeat(topFill) + '─┐';
|
|
19
|
+
const bottom = '└' + '─'.repeat(width - 2) + '┘';
|
|
20
|
+
const lines = [top];
|
|
21
|
+
for (const line of innerLines) {
|
|
22
|
+
// strip ANSI to measure visible length
|
|
23
|
+
const visible = line.replace(/\x1b\[[0-9;]*m/g, '');
|
|
24
|
+
const pad = Math.max(0, innerWidth - visible.length);
|
|
25
|
+
lines.push('│ ' + line + ' '.repeat(pad) + ' │');
|
|
26
|
+
}
|
|
27
|
+
lines.push(bottom);
|
|
28
|
+
return lines;
|
|
29
|
+
}
|
|
30
|
+
handleInput(data) {
|
|
31
|
+
this.inner.handleInput?.(data);
|
|
32
|
+
}
|
|
33
|
+
invalidate() {
|
|
34
|
+
this.inner.invalidate?.();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class DashboardView {
|
|
38
|
+
baseUrl;
|
|
39
|
+
apiKey;
|
|
40
|
+
tui;
|
|
41
|
+
onRender;
|
|
42
|
+
container;
|
|
43
|
+
headerText;
|
|
44
|
+
bodyContainer;
|
|
45
|
+
bodyChildren = [];
|
|
46
|
+
onCancel;
|
|
47
|
+
constructor(baseUrl, apiKey, tui, onRender) {
|
|
48
|
+
this.baseUrl = baseUrl;
|
|
49
|
+
this.apiKey = apiKey;
|
|
50
|
+
this.tui = tui;
|
|
51
|
+
this.onRender = onRender;
|
|
52
|
+
this.container = new Container();
|
|
53
|
+
this.headerText = new Text(chalk.bold('Dashboard') + chalk.dim(' Esc close'), 1, 0);
|
|
54
|
+
this.bodyContainer = new Container();
|
|
55
|
+
this.container.addChild(new Spacer(1));
|
|
56
|
+
this.container.addChild(this.headerText);
|
|
57
|
+
this.container.addChild(new Spacer(1));
|
|
58
|
+
this.container.addChild(this.bodyContainer);
|
|
59
|
+
this.load();
|
|
60
|
+
}
|
|
61
|
+
addToBody(child) {
|
|
62
|
+
this.bodyChildren.push(child);
|
|
63
|
+
this.bodyContainer.addChild(child);
|
|
64
|
+
}
|
|
65
|
+
async load() {
|
|
66
|
+
const prefs = getPreferences();
|
|
67
|
+
const overviewWidgets = prefs.widgets?.overview ?? [];
|
|
68
|
+
if (overviewWidgets.length === 0) {
|
|
69
|
+
this.addToBody(new Text(chalk.dim('No overview widgets configured. Use /widgets to select widgets.'), 1, 0));
|
|
70
|
+
this.onRender();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
for (const config of overviewWidgets) {
|
|
74
|
+
await this.loadAndRenderWidget(config);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async loadAndRenderWidget(config) {
|
|
78
|
+
const spinner = new Loader(this.tui, s => chalk.cyan(s), s => chalk.dim(s), `Loading ${config.widgetName}...`);
|
|
79
|
+
spinner.start();
|
|
80
|
+
this.addToBody(spinner);
|
|
81
|
+
this.onRender();
|
|
82
|
+
try {
|
|
83
|
+
const mod = await loadWidgetBundle(config.frontendUrl);
|
|
84
|
+
const bundleWidgets = mod.widgets;
|
|
85
|
+
const widget = bundleWidgets.find(w => w.slug === config.widgetSlug);
|
|
86
|
+
spinner.stop();
|
|
87
|
+
try {
|
|
88
|
+
this.bodyContainer.removeChild(spinner);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
/* ignore */
|
|
92
|
+
}
|
|
93
|
+
this.bodyChildren = this.bodyChildren.filter(c => c !== spinner);
|
|
94
|
+
if (!widget) {
|
|
95
|
+
this.addToBody(new Text(chalk.dim(`Widget "${config.widgetSlug}" not found in bundle`), 0, 1));
|
|
96
|
+
this.onRender();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const ctx = {
|
|
100
|
+
placement: 'tui',
|
|
101
|
+
pat: this.apiKey,
|
|
102
|
+
accounts: [
|
|
103
|
+
{
|
|
104
|
+
id: config.accountId,
|
|
105
|
+
slug: config.accountSlug,
|
|
106
|
+
name: config.accountName,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
baseUrl: this.baseUrl,
|
|
110
|
+
requestRender: this.onRender,
|
|
111
|
+
};
|
|
112
|
+
const component = (await widget.render(ctx));
|
|
113
|
+
if (component && typeof component.render === 'function') {
|
|
114
|
+
const boxed = new BoxedComponent(component, config.widgetName);
|
|
115
|
+
this.addToBody(boxed);
|
|
116
|
+
this.addToBody(new Spacer(1));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
spinner.stop();
|
|
121
|
+
try {
|
|
122
|
+
this.bodyContainer.removeChild(spinner);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
/* ignore */
|
|
126
|
+
}
|
|
127
|
+
this.bodyChildren = this.bodyChildren.filter(c => c !== spinner);
|
|
128
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
129
|
+
this.addToBody(new Text(chalk.dim(`─ ${config.widgetName} `) +
|
|
130
|
+
chalk.red('Error: ') +
|
|
131
|
+
chalk.dim(msg), 0, 1));
|
|
132
|
+
}
|
|
133
|
+
this.onRender();
|
|
134
|
+
}
|
|
135
|
+
handleInput(data) {
|
|
136
|
+
if (matchesKey(data, Key.escape)) {
|
|
137
|
+
this.onCancel?.();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
render(width) {
|
|
141
|
+
return this.container.render(width);
|
|
142
|
+
}
|
|
143
|
+
invalidate() {
|
|
144
|
+
this.container.invalidate?.();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=dashboard-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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;IACF,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,UAAU;QACT,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC;IAC/B,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Component } from '@mariozechner/pi-tui';
|
|
2
|
+
/**
|
|
3
|
+
* Single-row status bar rendered below the editor.
|
|
4
|
+
* Left side: incognito badge (when active).
|
|
5
|
+
* Right side: first line of the below-input widget (when loaded).
|
|
6
|
+
* Returns [] when neither is active (no visible space consumed).
|
|
7
|
+
*/
|
|
8
|
+
export declare class StatusLine implements Component {
|
|
9
|
+
private _incognito;
|
|
10
|
+
private _acceptAll;
|
|
11
|
+
private _widget;
|
|
12
|
+
setIncognito(val: boolean): void;
|
|
13
|
+
setAcceptAll(val: boolean): void;
|
|
14
|
+
setWidget(widget: Component | null): void;
|
|
15
|
+
render(width: number): string[];
|
|
16
|
+
invalidate(): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=status-line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-line.d.ts","sourceRoot":"","sources":["../../../src/tui/components/status-line.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAGpD;;;;;GAKG;AACH,qBAAa,UAAW,YAAW,SAAS;IAC3C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAA0B;IAEzC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIhC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI;IAIhC,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAIzC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAwB/B,UAAU,IAAI,IAAI;CAGlB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { visibleWidth, truncateToWidth } from '@mariozechner/pi-tui';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
/**
|
|
4
|
+
* Single-row status bar rendered below the editor.
|
|
5
|
+
* Left side: incognito badge (when active).
|
|
6
|
+
* Right side: first line of the below-input widget (when loaded).
|
|
7
|
+
* Returns [] when neither is active (no visible space consumed).
|
|
8
|
+
*/
|
|
9
|
+
export class StatusLine {
|
|
10
|
+
_incognito = false;
|
|
11
|
+
_acceptAll = false;
|
|
12
|
+
_widget = null;
|
|
13
|
+
setIncognito(val) {
|
|
14
|
+
this._incognito = val;
|
|
15
|
+
}
|
|
16
|
+
setAcceptAll(val) {
|
|
17
|
+
this._acceptAll = val;
|
|
18
|
+
}
|
|
19
|
+
setWidget(widget) {
|
|
20
|
+
this._widget = widget;
|
|
21
|
+
}
|
|
22
|
+
render(width) {
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (this._incognito) {
|
|
25
|
+
parts.push(chalk.bgHex('#3a2a00').hex('#ffcc44')(' ⊘ incognito '));
|
|
26
|
+
}
|
|
27
|
+
if (this._acceptAll) {
|
|
28
|
+
parts.push(chalk.bgHex('#1a3a1a').hex('#44cc44')(' ✓ accept all '));
|
|
29
|
+
}
|
|
30
|
+
const left = parts.join(' ');
|
|
31
|
+
let right = '';
|
|
32
|
+
if (this._widget) {
|
|
33
|
+
const lines = this._widget.render(width);
|
|
34
|
+
right = lines[0] ?? '';
|
|
35
|
+
}
|
|
36
|
+
if (!left && !right)
|
|
37
|
+
return [];
|
|
38
|
+
const leftW = visibleWidth(left);
|
|
39
|
+
const rightW = visibleWidth(right);
|
|
40
|
+
const gap = Math.max(1, width - leftW - rightW);
|
|
41
|
+
return [truncateToWidth(left + ' '.repeat(gap) + right, width)];
|
|
42
|
+
}
|
|
43
|
+
invalidate() {
|
|
44
|
+
this._widget?.invalidate?.();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=status-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-line.js","sourceRoot":"","sources":["../../../src/tui/components/status-line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAEnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACd,UAAU,GAAG,KAAK,CAAC;IACnB,UAAU,GAAG,KAAK,CAAC;IACnB,OAAO,GAAqB,IAAI,CAAC;IAEzC,YAAY,CAAC,GAAY;QACxB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;IACvB,CAAC;IAED,YAAY,CAAC,GAAY;QACxB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;IACvB,CAAC;IAED,SAAS,CAAC,MAAwB;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE7B,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,EAAE,CAAC;QAE/B,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC;QAChD,OAAO,CAAC,eAAe,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,UAAU;QACT,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -13,8 +13,34 @@ export declare class ToolCallItem implements Component {
|
|
|
13
13
|
constructor(toolName: string);
|
|
14
14
|
appendArgsDelta(delta: string): void;
|
|
15
15
|
setArgs(args: Record<string, unknown>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Mark known children done by their call IDs.
|
|
18
|
+
* Used when data-tool-agent events have toolCalls:[] but toolResults with results
|
|
19
|
+
* for children that were registered in an earlier snapshot (post-approval pattern).
|
|
20
|
+
*/
|
|
21
|
+
markChildrenDoneByIds(resultMap: Map<string, unknown>): void;
|
|
16
22
|
/** Called on each tool-output-available — updates nested children in real-time */
|
|
17
23
|
updateFromOutputParts(parts: OutputPart[]): void;
|
|
24
|
+
/**
|
|
25
|
+
* Returns not-done children — these are nested tools still waiting
|
|
26
|
+
* (in-progress or approval-requested) at the time of an approval event.
|
|
27
|
+
* Mirrors webapp's findPendingApprovals expansion of agent-take_action.
|
|
28
|
+
*/
|
|
29
|
+
getPendingChildren(): Array<{
|
|
30
|
+
toolName: string;
|
|
31
|
+
displayName: string;
|
|
32
|
+
input: Record<string, unknown>;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* TUI equivalent of webapp's cachedNestedPartsRef lookup.
|
|
36
|
+
* Resumed streams send only toolResults, so this resolves a Mastra call ID
|
|
37
|
+
* (e.g. "call k23...") to the child that was cached from the first stream.
|
|
38
|
+
*/
|
|
39
|
+
getChildInfo(callId: string): {
|
|
40
|
+
toolName: string;
|
|
41
|
+
input: Record<string, unknown>;
|
|
42
|
+
} | undefined;
|
|
43
|
+
parsedArgs(): Record<string, unknown>;
|
|
18
44
|
addChild(child: ToolCallItem): void;
|
|
19
45
|
setDone(result?: unknown): void;
|
|
20
46
|
toggleExpand(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-item.d.ts","sourceRoot":"","sources":["../../../src/tui/components/tool-call-item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAGpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-call-item.d.ts","sourceRoot":"","sources":["../../../src/tui/components/tool-call-item.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAGpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AA4DnD,qBAAa,YAAa,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,UAAU,CAAc;IAGhC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,gBAAgB,CAAmC;IACpD,UAAU,UAAS;IACnB,MAAM,UAAS;gBAEV,QAAQ,EAAE,MAAM;IAK5B,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAK5C;;;;OAIG;IACH,qBAAqB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAU5D,kFAAkF;IAClF,qBAAqB,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI;IAsChD;;;;OAIG;IACH,kBAAkB,IAAI,KAAK,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAC,CAAC;IAUpG;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAC,GAAG,SAAS;IAM5F,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQrC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAInC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAW/B,YAAY,IAAI,IAAI;IAIpB,UAAU,IAAI,IAAI;IAElB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI/B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;CAoH/C"}
|
|
@@ -14,11 +14,14 @@ function toResultString(value) {
|
|
|
14
14
|
return String(value);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
function toSingleLine(str) {
|
|
18
|
+
return str.replace(/[\r\n\t]+/g, ' ').trim();
|
|
19
|
+
}
|
|
17
20
|
function argSummaryFromInput(input, raw) {
|
|
18
21
|
if (input) {
|
|
19
22
|
try {
|
|
20
23
|
const firstVal = Object.values(input)[0];
|
|
21
|
-
const str = typeof firstVal === 'string' ? firstVal : JSON.stringify(firstVal ?? '');
|
|
24
|
+
const str = toSingleLine(typeof firstVal === 'string' ? firstVal : JSON.stringify(firstVal ?? ''));
|
|
22
25
|
return str.length > 60 ? str.slice(0, 60) + '\u2026' : str;
|
|
23
26
|
}
|
|
24
27
|
catch { }
|
|
@@ -26,11 +29,11 @@ function argSummaryFromInput(input, raw) {
|
|
|
26
29
|
try {
|
|
27
30
|
const parsed = JSON.parse(raw);
|
|
28
31
|
const firstVal = Object.values(parsed)[0];
|
|
29
|
-
const str = typeof firstVal === 'string' ? firstVal : JSON.stringify(firstVal ?? '');
|
|
32
|
+
const str = toSingleLine(typeof firstVal === 'string' ? firstVal : JSON.stringify(firstVal ?? ''));
|
|
30
33
|
return str.length > 60 ? str.slice(0, 60) + '\u2026' : str;
|
|
31
34
|
}
|
|
32
35
|
catch {
|
|
33
|
-
return raw.slice(0, 60);
|
|
36
|
+
return toSingleLine(raw).slice(0, 60);
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
const toTitleCase = (s) => s
|
|
@@ -69,6 +72,20 @@ export class ToolCallItem {
|
|
|
69
72
|
this.args = JSON.stringify(args);
|
|
70
73
|
this.displayName = resolveDisplayName(this.toolName, args);
|
|
71
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Mark known children done by their call IDs.
|
|
77
|
+
* Used when data-tool-agent events have toolCalls:[] but toolResults with results
|
|
78
|
+
* for children that were registered in an earlier snapshot (post-approval pattern).
|
|
79
|
+
*/
|
|
80
|
+
markChildrenDoneByIds(resultMap) {
|
|
81
|
+
for (const [callId, result] of resultMap) {
|
|
82
|
+
const child = this.childrenByCallId.get(callId);
|
|
83
|
+
if (child && !child.isDone) {
|
|
84
|
+
child.isDone = true;
|
|
85
|
+
child.result = toResultString(result);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
72
89
|
/** Called on each tool-output-available — updates nested children in real-time */
|
|
73
90
|
updateFromOutputParts(parts) {
|
|
74
91
|
for (const part of parts) {
|
|
@@ -101,6 +118,39 @@ export class ToolCallItem {
|
|
|
101
118
|
}
|
|
102
119
|
}
|
|
103
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Returns not-done children — these are nested tools still waiting
|
|
123
|
+
* (in-progress or approval-requested) at the time of an approval event.
|
|
124
|
+
* Mirrors webapp's findPendingApprovals expansion of agent-take_action.
|
|
125
|
+
*/
|
|
126
|
+
getPendingChildren() {
|
|
127
|
+
return this.children
|
|
128
|
+
.filter(c => !c.isDone)
|
|
129
|
+
.map(c => ({
|
|
130
|
+
toolName: c.toolName,
|
|
131
|
+
displayName: c.displayName,
|
|
132
|
+
input: c.parsedArgs(),
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* TUI equivalent of webapp's cachedNestedPartsRef lookup.
|
|
137
|
+
* Resumed streams send only toolResults, so this resolves a Mastra call ID
|
|
138
|
+
* (e.g. "call k23...") to the child that was cached from the first stream.
|
|
139
|
+
*/
|
|
140
|
+
getChildInfo(callId) {
|
|
141
|
+
const child = this.childrenByCallId.get(callId);
|
|
142
|
+
if (!child)
|
|
143
|
+
return undefined;
|
|
144
|
+
return { toolName: child.toolName, input: child.parsedArgs() };
|
|
145
|
+
}
|
|
146
|
+
parsedArgs() {
|
|
147
|
+
try {
|
|
148
|
+
return JSON.parse(this.args);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
104
154
|
addChild(child) {
|
|
105
155
|
this.children.push(child);
|
|
106
156
|
}
|