@synergenius/flow-weaver-pack-weaver 0.9.199 → 0.9.201
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/ai-chat-provider.js +5 -5
- package/dist/ai-chat-provider.js.map +1 -1
- package/dist/bot/acceptance-merge.d.ts +21 -0
- package/dist/bot/acceptance-merge.d.ts.map +1 -0
- package/dist/bot/acceptance-merge.js +46 -0
- package/dist/bot/acceptance-merge.js.map +1 -0
- package/dist/bot/ai-client.d.ts +14 -2
- package/dist/bot/ai-client.d.ts.map +1 -1
- package/dist/bot/ai-client.js +71 -24
- package/dist/bot/ai-client.js.map +1 -1
- package/dist/bot/assistant-tools.js +3 -3
- package/dist/bot/assistant-tools.js.map +1 -1
- package/dist/bot/audit-logger.d.ts.map +1 -1
- package/dist/bot/audit-logger.js +34 -14
- package/dist/bot/audit-logger.js.map +1 -1
- package/dist/bot/audit-trail.d.ts +67 -0
- package/dist/bot/audit-trail.d.ts.map +1 -0
- package/dist/bot/audit-trail.js +153 -0
- package/dist/bot/audit-trail.js.map +1 -0
- package/dist/bot/behavior-defaults.d.ts +1 -1
- package/dist/bot/behavior-defaults.d.ts.map +1 -1
- package/dist/bot/behavior-defaults.js +7 -3
- package/dist/bot/behavior-defaults.js.map +1 -1
- package/dist/bot/capability-registry.d.ts +9 -0
- package/dist/bot/capability-registry.d.ts.map +1 -1
- package/dist/bot/capability-registry.js +81 -27
- package/dist/bot/capability-registry.js.map +1 -1
- package/dist/bot/capability-types.d.ts +10 -0
- package/dist/bot/capability-types.d.ts.map +1 -1
- package/dist/bot/cli-provider.d.ts.map +1 -1
- package/dist/bot/cli-provider.js +8 -7
- package/dist/bot/cli-provider.js.map +1 -1
- package/dist/bot/preflight.d.ts +48 -0
- package/dist/bot/preflight.d.ts.map +1 -0
- package/dist/bot/preflight.js +247 -0
- package/dist/bot/preflight.js.map +1 -0
- package/dist/bot/provider-shim.d.ts +74 -0
- package/dist/bot/provider-shim.d.ts.map +1 -0
- package/dist/bot/provider-shim.js +176 -0
- package/dist/bot/provider-shim.js.map +1 -0
- package/dist/bot/runner.d.ts +2 -0
- package/dist/bot/runner.d.ts.map +1 -1
- package/dist/bot/runner.js +60 -17
- package/dist/bot/runner.js.map +1 -1
- package/dist/bot/step-executor.d.ts.map +1 -1
- package/dist/bot/step-executor.js +72 -115
- package/dist/bot/step-executor.js.map +1 -1
- package/dist/bot/swarm-controller.d.ts +2 -0
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +92 -20
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-create-handler.d.ts +37 -0
- package/dist/bot/task-create-handler.d.ts.map +1 -0
- package/dist/bot/task-create-handler.js +124 -0
- package/dist/bot/task-create-handler.js.map +1 -0
- package/dist/bot/task-store.d.ts +1 -0
- package/dist/bot/task-store.d.ts.map +1 -1
- package/dist/bot/task-store.js +67 -0
- package/dist/bot/task-store.js.map +1 -1
- package/dist/bot/types.d.ts +1 -1
- package/dist/bot/types.d.ts.map +1 -1
- package/dist/bot/weaver-tools.d.ts.map +1 -1
- package/dist/bot/weaver-tools.js +7 -39
- package/dist/bot/weaver-tools.js.map +1 -1
- package/dist/node-types/agent-execute.d.ts +25 -8
- package/dist/node-types/agent-execute.d.ts.map +1 -1
- package/dist/node-types/agent-execute.js +89 -23
- package/dist/node-types/agent-execute.js.map +1 -1
- package/dist/node-types/bot-report.d.ts.map +1 -1
- package/dist/node-types/bot-report.js +24 -3
- package/dist/node-types/bot-report.js.map +1 -1
- package/dist/node-types/plan-task.d.ts +8 -17
- package/dist/node-types/plan-task.d.ts.map +1 -1
- package/dist/node-types/plan-task.js +217 -256
- package/dist/node-types/plan-task.js.map +1 -1
- package/dist/node-types/review-result.js +8 -6
- package/dist/node-types/review-result.js.map +1 -1
- package/dist/palindrome.d.ts +9 -0
- package/dist/palindrome.d.ts.map +1 -0
- package/dist/palindrome.js +14 -0
- package/dist/palindrome.js.map +1 -0
- package/dist/ui/approval-card.js +91 -82
- package/dist/ui/bot-activity.js +73 -56
- package/dist/ui/bot-config.js +48 -31
- package/dist/ui/bot-dashboard.js +52 -36
- package/dist/ui/bot-panel.js +230 -228
- package/dist/ui/bot-slot-card.js +100 -90
- package/dist/ui/bot-status.js +37 -15
- package/dist/ui/budget-bar.js +57 -31
- package/dist/ui/capability-editor.js +447 -378
- package/dist/ui/chat-task-result.js +78 -71
- package/dist/ui/decision-log.js +68 -81
- package/dist/ui/genesis-block.js +86 -95
- package/dist/ui/instance-stream-view.js +722 -0
- package/dist/ui/profile-card.js +96 -221
- package/dist/ui/profile-editor.js +532 -575
- package/dist/ui/settings-section.js +41 -45
- package/dist/ui/swarm-controls.js +212 -135
- package/dist/ui/swarm-dashboard.js +3992 -2715
- package/dist/ui/task-detail-view.js +415 -521
- package/dist/ui/task-editor.js +339 -390
- package/dist/ui/task-pool-list.js +60 -55
- package/dist/workflows/src/palindrome.d.ts +11 -0
- package/dist/workflows/src/palindrome.d.ts.map +1 -0
- package/dist/workflows/src/palindrome.js +16 -0
- package/dist/workflows/src/palindrome.js.map +1 -0
- package/dist/workflows/tests/palindrome.test.d.ts +2 -0
- package/dist/workflows/tests/palindrome.test.d.ts.map +1 -0
- package/dist/workflows/tests/palindrome.test.js +41 -0
- package/dist/workflows/tests/palindrome.test.js.map +1 -0
- package/dist/workflows/weaver-bot-batch.js +1 -1
- package/dist/workflows/weaver-bot-batch.js.map +1 -1
- package/dist/workflows/weaver-bot.js +1 -1
- package/dist/workflows/weaver-bot.js.map +1 -1
- package/flowweaver.manifest.json +1 -1
- package/package.json +8 -2
- package/src/ai-chat-provider.ts +5 -5
- package/src/bot/acceptance-merge.ts +62 -0
- package/src/bot/ai-client.ts +77 -21
- package/src/bot/assistant-tools.ts +3 -3
- package/src/bot/audit-logger.ts +42 -14
- package/src/bot/audit-trail.ts +211 -0
- package/src/bot/behavior-defaults.ts +7 -2
- package/src/bot/capability-registry.ts +84 -28
- package/src/bot/capability-types.ts +11 -0
- package/src/bot/cli-provider.ts +8 -7
- package/src/bot/preflight.ts +285 -0
- package/src/bot/provider-shim.ts +218 -0
- package/src/bot/runner.ts +68 -20
- package/src/bot/step-executor.ts +69 -127
- package/src/bot/swarm-controller.ts +94 -20
- package/src/bot/task-create-handler.ts +164 -0
- package/src/bot/task-store.ts +83 -0
- package/src/bot/types.ts +4 -1
- package/src/bot/weaver-tools.ts +7 -45
- package/src/node-types/agent-execute.ts +102 -16
- package/src/node-types/bot-report.ts +24 -3
- package/src/node-types/plan-task.ts +238 -280
- package/src/node-types/review-result.ts +8 -6
- package/src/palindrome.ts +14 -0
- package/src/ui/approval-card.tsx +78 -62
- package/src/ui/bot-activity.tsx +12 -10
- package/src/ui/bot-config.tsx +12 -10
- package/src/ui/bot-dashboard.tsx +13 -11
- package/src/ui/bot-panel.tsx +189 -171
- package/src/ui/bot-slot-card.tsx +125 -70
- package/src/ui/bot-status.tsx +4 -4
- package/src/ui/budget-bar.tsx +86 -25
- package/src/ui/capability-editor.tsx +392 -257
- package/src/ui/chat-task-result.tsx +81 -78
- package/src/ui/decision-log.tsx +76 -73
- package/src/ui/genesis-block.tsx +91 -61
- package/src/ui/instance-stream-view.tsx +861 -0
- package/src/ui/profile-card.tsx +195 -168
- package/src/ui/profile-editor.tsx +453 -370
- package/src/ui/settings-section.tsx +46 -39
- package/src/ui/swarm-controls.tsx +252 -123
- package/src/ui/swarm-dashboard.tsx +999 -466
- package/src/ui/task-detail-view.tsx +485 -428
- package/src/ui/task-editor.tsx +329 -271
- package/src/ui/task-pool-list.tsx +68 -62
- package/src/workflows/src/palindrome.ts +16 -0
- package/src/workflows/tests/palindrome.test.ts +49 -0
- package/src/workflows/weaver-bot-batch.ts +1 -1
- package/src/workflows/weaver-bot.ts +1 -1
- package/dist/ui/bot-constants.d.ts +0 -14
- package/dist/ui/bot-constants.d.ts.map +0 -1
- package/dist/ui/bot-constants.js +0 -189
- package/dist/ui/bot-constants.js.map +0 -1
- package/dist/ui/steer-api.d.ts +0 -7
- package/dist/ui/steer-api.d.ts.map +0 -1
- package/dist/ui/steer-api.js +0 -11
- package/dist/ui/steer-api.js.map +0 -1
- package/dist/ui/trace-to-timeline.d.ts +0 -91
- package/dist/ui/trace-to-timeline.d.ts.map +0 -1
- package/dist/ui/trace-to-timeline.js +0 -116
- package/dist/ui/trace-to-timeline.js.map +0 -1
- package/dist/ui/use-stream-timeline.d.ts +0 -50
- package/dist/ui/use-stream-timeline.d.ts.map +0 -1
- package/dist/ui/use-stream-timeline.js +0 -245
- package/dist/ui/use-stream-timeline.js.map +0 -1
|
@@ -0,0 +1,722 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/ui/instance-stream-view.tsx
|
|
21
|
+
var instance_stream_view_exports = {};
|
|
22
|
+
__export(instance_stream_view_exports, {
|
|
23
|
+
InstanceStreamView: () => InstanceStreamView,
|
|
24
|
+
default: () => instance_stream_view_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(instance_stream_view_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_plugin_ui_kit = require("@fw/plugin-ui-kit");
|
|
29
|
+
|
|
30
|
+
// src/ui/trace-to-timeline.ts
|
|
31
|
+
function traceToTimeline(run) {
|
|
32
|
+
const entries = [];
|
|
33
|
+
let idCounter = 0;
|
|
34
|
+
const meta = run.nodeMeta ?? {};
|
|
35
|
+
if (run.trace && run.trace.length > 0) {
|
|
36
|
+
const nodeStarts = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const event of run.trace) {
|
|
38
|
+
if (event.type === "node-start") {
|
|
39
|
+
nodeStarts.set(event.nodeId, event);
|
|
40
|
+
} else if (event.type === "node-complete" || event.type === "node-error") {
|
|
41
|
+
const start = nodeStarts.get(event.nodeId);
|
|
42
|
+
const duration = event.durationMs ?? (start ? event.timestamp - start.timestamp : void 0);
|
|
43
|
+
const nm = meta[event.nodeId] ?? (event.nodeType ? meta[event.nodeType] : void 0);
|
|
44
|
+
entries.push({
|
|
45
|
+
id: `trace-${idCounter++}`,
|
|
46
|
+
timestamp: new Date(event.timestamp),
|
|
47
|
+
type: event.type === "node-complete" ? "node-completed" : "node-failed",
|
|
48
|
+
nodeId: event.nodeId,
|
|
49
|
+
label: nm?.label ?? event.nodeType ?? event.nodeId,
|
|
50
|
+
detail: event.error,
|
|
51
|
+
duration,
|
|
52
|
+
color: nm?.color,
|
|
53
|
+
icon: nm?.icon,
|
|
54
|
+
outputs: event.outputs && event.outputs.length > 0 ? event.outputs : void 0
|
|
55
|
+
});
|
|
56
|
+
nodeStarts.delete(event.nodeId);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const [nodeId, event] of nodeStarts) {
|
|
60
|
+
const nm = meta[nodeId] ?? (event.nodeType ? meta[event.nodeType] : void 0);
|
|
61
|
+
entries.push({
|
|
62
|
+
id: `trace-${idCounter++}`,
|
|
63
|
+
timestamp: new Date(event.timestamp),
|
|
64
|
+
type: "node-started",
|
|
65
|
+
nodeId,
|
|
66
|
+
label: nm?.label ?? event.nodeType ?? nodeId,
|
|
67
|
+
color: nm?.color,
|
|
68
|
+
icon: nm?.icon
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
} else if (run.stepLog && run.stepLog.length > 0) {
|
|
72
|
+
for (const step of run.stepLog) {
|
|
73
|
+
const type = step.status === "ok" ? "node-completed" : step.status === "error" ? "node-failed" : "node-completed";
|
|
74
|
+
entries.push({
|
|
75
|
+
id: `step-${idCounter++}`,
|
|
76
|
+
timestamp: new Date(run.startedAt ?? Date.now()),
|
|
77
|
+
type,
|
|
78
|
+
label: step.step,
|
|
79
|
+
detail: step.detail,
|
|
80
|
+
icon: step.status === "ok" ? "success" : step.status === "error" ? "error" : "warning"
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (run.outcome === "failed" || run.outcome === "error") {
|
|
85
|
+
let errorDetail = "";
|
|
86
|
+
if (run.auditTrail) {
|
|
87
|
+
for (const a of run.auditTrail) {
|
|
88
|
+
if (a.type === "step-complete" && a.data) {
|
|
89
|
+
const errors = a.data.errors;
|
|
90
|
+
if (errors && errors.length > 0) {
|
|
91
|
+
errorDetail = errors.map((e) => e.length > 120 ? e.slice(0, 117) + "..." : e).join("\n");
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!errorDetail && run.summary) {
|
|
98
|
+
const parts = run.summary.split("|").map((p) => p.trim());
|
|
99
|
+
const outcomePart = parts.find((p) => p.startsWith("Outcome:"));
|
|
100
|
+
const summaryPart = parts.find((p) => p.startsWith("Summary:"));
|
|
101
|
+
errorDetail = summaryPart?.replace("Summary:", "").trim() ?? outcomePart ?? run.summary;
|
|
102
|
+
}
|
|
103
|
+
entries.push({
|
|
104
|
+
id: `result-${idCounter++}`,
|
|
105
|
+
timestamp: new Date(run.finishedAt ?? run.startedAt ?? Date.now()),
|
|
106
|
+
type: "task-failed",
|
|
107
|
+
label: "Task failed",
|
|
108
|
+
detail: errorDetail || "Unknown failure",
|
|
109
|
+
icon: "error"
|
|
110
|
+
});
|
|
111
|
+
} else if (run.outcome === "completed" && run.success) {
|
|
112
|
+
entries.push({
|
|
113
|
+
id: `result-${idCounter++}`,
|
|
114
|
+
timestamp: new Date(run.finishedAt ?? run.startedAt ?? Date.now()),
|
|
115
|
+
type: "task-completed",
|
|
116
|
+
label: "Task completed",
|
|
117
|
+
detail: run.summary?.includes("|") ? run.summary.split("|").find((p) => p.trim().startsWith("Summary:"))?.replace("Summary:", "").trim() : void 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
entries.sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime());
|
|
121
|
+
return entries;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/ui/instance-stream-view.tsx
|
|
125
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
126
|
+
function buildConversation(events) {
|
|
127
|
+
const blocks = [];
|
|
128
|
+
let thinkingBuf = "";
|
|
129
|
+
let textBuf = "";
|
|
130
|
+
let lastType = "";
|
|
131
|
+
const toolMap = /* @__PURE__ */ new Map();
|
|
132
|
+
const flushThinking = (streaming) => {
|
|
133
|
+
if (thinkingBuf) {
|
|
134
|
+
blocks.push({ kind: "thinking", content: thinkingBuf, streaming });
|
|
135
|
+
thinkingBuf = "";
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const flushText = (streaming) => {
|
|
139
|
+
if (textBuf) {
|
|
140
|
+
blocks.push({ kind: "text", content: textBuf, streaming });
|
|
141
|
+
textBuf = "";
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
for (let i = 0; i < events.length; i++) {
|
|
145
|
+
const e = events[i];
|
|
146
|
+
const d = e.data ?? {};
|
|
147
|
+
const isLast = i === events.length - 1;
|
|
148
|
+
switch (e.type) {
|
|
149
|
+
case "thinking_delta":
|
|
150
|
+
if (lastType !== "thinking_delta") flushText(false);
|
|
151
|
+
thinkingBuf += d.text ?? "";
|
|
152
|
+
lastType = "thinking_delta";
|
|
153
|
+
if (isLast) flushThinking(true);
|
|
154
|
+
break;
|
|
155
|
+
case "thinking_done":
|
|
156
|
+
flushThinking(false);
|
|
157
|
+
lastType = "thinking_done";
|
|
158
|
+
break;
|
|
159
|
+
case "text_delta":
|
|
160
|
+
if (lastType === "thinking_delta") flushThinking(false);
|
|
161
|
+
textBuf += d.text ?? "";
|
|
162
|
+
lastType = "text_delta";
|
|
163
|
+
if (isLast) flushText(true);
|
|
164
|
+
break;
|
|
165
|
+
case "tool_use_start": {
|
|
166
|
+
flushThinking(false);
|
|
167
|
+
flushText(false);
|
|
168
|
+
const toolId = d.id ?? `tool-${i}`;
|
|
169
|
+
const idx = blocks.length;
|
|
170
|
+
toolMap.set(toolId, idx);
|
|
171
|
+
blocks.push({
|
|
172
|
+
kind: "tool_call",
|
|
173
|
+
id: toolId,
|
|
174
|
+
name: d.name ?? "unknown",
|
|
175
|
+
status: "running"
|
|
176
|
+
});
|
|
177
|
+
lastType = "tool_use_start";
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case "tool_result": {
|
|
181
|
+
const toolId = d.id ?? "";
|
|
182
|
+
const idx = toolMap.get(toolId);
|
|
183
|
+
if (idx != null && blocks[idx]?.kind === "tool_call") {
|
|
184
|
+
const block = blocks[idx];
|
|
185
|
+
block.status = d.isError ? "error" : "completed";
|
|
186
|
+
block.result = d.result ?? "";
|
|
187
|
+
block.isError = d.isError ?? false;
|
|
188
|
+
}
|
|
189
|
+
lastType = "tool_result";
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case "bot-started":
|
|
193
|
+
blocks.push({
|
|
194
|
+
kind: "status",
|
|
195
|
+
label: "Task started",
|
|
196
|
+
variant: "started",
|
|
197
|
+
detail: d.instruction ?? void 0
|
|
198
|
+
});
|
|
199
|
+
lastType = "bot-started";
|
|
200
|
+
break;
|
|
201
|
+
case "bot-completed":
|
|
202
|
+
flushThinking(false);
|
|
203
|
+
flushText(false);
|
|
204
|
+
blocks.push({
|
|
205
|
+
kind: "status",
|
|
206
|
+
label: d.success ? "Task completed" : "Task finished",
|
|
207
|
+
variant: "completed",
|
|
208
|
+
detail: d.report ?? d.summary ?? void 0
|
|
209
|
+
});
|
|
210
|
+
lastType = "bot-completed";
|
|
211
|
+
break;
|
|
212
|
+
case "bot-failed":
|
|
213
|
+
flushThinking(false);
|
|
214
|
+
flushText(false);
|
|
215
|
+
blocks.push({
|
|
216
|
+
kind: "status",
|
|
217
|
+
label: "Task failed",
|
|
218
|
+
variant: "failed",
|
|
219
|
+
detail: d.error ?? void 0
|
|
220
|
+
});
|
|
221
|
+
lastType = "bot-failed";
|
|
222
|
+
break;
|
|
223
|
+
// ── Swarm/workflow-level events (emitted by runner + swarm-controller) ──
|
|
224
|
+
case "task-claimed":
|
|
225
|
+
blocks.push({
|
|
226
|
+
kind: "status",
|
|
227
|
+
label: `Task claimed by ${d.profileId ?? "bot"}`,
|
|
228
|
+
variant: "started"
|
|
229
|
+
});
|
|
230
|
+
lastType = "task-claimed";
|
|
231
|
+
break;
|
|
232
|
+
case "task-done":
|
|
233
|
+
flushThinking(false);
|
|
234
|
+
flushText(false);
|
|
235
|
+
blocks.push({
|
|
236
|
+
kind: "status",
|
|
237
|
+
label: d.outcome === "completed" ? "Task completed" : `Task ${d.outcome ?? "done"}`,
|
|
238
|
+
variant: d.outcome === "completed" ? "completed" : "failed"
|
|
239
|
+
});
|
|
240
|
+
lastType = "task-done";
|
|
241
|
+
break;
|
|
242
|
+
case "task-run-error":
|
|
243
|
+
flushThinking(false);
|
|
244
|
+
flushText(false);
|
|
245
|
+
blocks.push({
|
|
246
|
+
kind: "status",
|
|
247
|
+
label: "Run error",
|
|
248
|
+
variant: "failed",
|
|
249
|
+
detail: d.error ?? void 0
|
|
250
|
+
});
|
|
251
|
+
lastType = "task-run-error";
|
|
252
|
+
break;
|
|
253
|
+
// Workflow node events — shown as tool-call-like blocks when no
|
|
254
|
+
// conversation-level events are available (non-CLI providers)
|
|
255
|
+
case "node-start": {
|
|
256
|
+
flushThinking(false);
|
|
257
|
+
flushText(false);
|
|
258
|
+
const nodeId = d.nodeId ?? `node-${i}`;
|
|
259
|
+
const idx = blocks.length;
|
|
260
|
+
toolMap.set(`node:${nodeId}`, idx);
|
|
261
|
+
blocks.push({
|
|
262
|
+
kind: "tool_call",
|
|
263
|
+
id: `node:${nodeId}`,
|
|
264
|
+
name: d.label ?? d.nodeType ?? nodeId,
|
|
265
|
+
status: "running"
|
|
266
|
+
});
|
|
267
|
+
lastType = "node-start";
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case "node-complete": {
|
|
271
|
+
const nodeId = d.nodeId ?? "";
|
|
272
|
+
const idx = toolMap.get(`node:${nodeId}`);
|
|
273
|
+
if (idx != null && blocks[idx]?.kind === "tool_call") {
|
|
274
|
+
const block = blocks[idx];
|
|
275
|
+
block.status = "completed";
|
|
276
|
+
const dur = d.durationMs;
|
|
277
|
+
block.result = dur ? `Completed in ${dur}ms` : "Completed";
|
|
278
|
+
}
|
|
279
|
+
lastType = "node-complete";
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case "node-error": {
|
|
283
|
+
const nodeId = d.nodeId ?? "";
|
|
284
|
+
const idx = toolMap.get(`node:${nodeId}`);
|
|
285
|
+
if (idx != null && blocks[idx]?.kind === "tool_call") {
|
|
286
|
+
const block = blocks[idx];
|
|
287
|
+
block.status = "error";
|
|
288
|
+
block.result = d.error ?? "Failed";
|
|
289
|
+
block.isError = true;
|
|
290
|
+
}
|
|
291
|
+
lastType = "node-error";
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
default:
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (thinkingBuf) flushThinking(true);
|
|
299
|
+
if (textBuf) flushText(true);
|
|
300
|
+
return blocks;
|
|
301
|
+
}
|
|
302
|
+
var STREAM_STATUS_MAP = {
|
|
303
|
+
waiting: "pending",
|
|
304
|
+
connected: "running",
|
|
305
|
+
ended: "completed",
|
|
306
|
+
error: "failed"
|
|
307
|
+
};
|
|
308
|
+
var STREAM_DEFAULT_MSG = {
|
|
309
|
+
waiting: "Waiting for bot",
|
|
310
|
+
connected: "Connected",
|
|
311
|
+
ended: "End of stream",
|
|
312
|
+
error: "Connection lost"
|
|
313
|
+
};
|
|
314
|
+
function StreamIndicator({ state, message }) {
|
|
315
|
+
const label = message ?? STREAM_DEFAULT_MSG[state];
|
|
316
|
+
if (state === "ended") {
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "compact", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Divider, { label }) });
|
|
318
|
+
}
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "default", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-center-nowrap-6", children: [
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
321
|
+
import_plugin_ui_kit.StatusIcon,
|
|
322
|
+
{
|
|
323
|
+
status: STREAM_STATUS_MAP[state],
|
|
324
|
+
size: "xs",
|
|
325
|
+
pulsing: state === "waiting" || state === "connected"
|
|
326
|
+
}
|
|
327
|
+
),
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
329
|
+
import_plugin_ui_kit.Typography,
|
|
330
|
+
{
|
|
331
|
+
variant: "smallCaption-regular",
|
|
332
|
+
color: state === "error" ? "color-status-negative" : "color-text-subtle",
|
|
333
|
+
children: label
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
] }) });
|
|
337
|
+
}
|
|
338
|
+
var TYPEWRITER = {
|
|
339
|
+
charsPerTick: 2,
|
|
340
|
+
intervalMs: 20,
|
|
341
|
+
cursor: "\u258F",
|
|
342
|
+
maxToolResultLen: 500
|
|
343
|
+
};
|
|
344
|
+
function useConversationTypewriter(blocks) {
|
|
345
|
+
const [activeIdx, setActiveIdx] = (0, import_react.useState)(0);
|
|
346
|
+
const [charPos, setCharPos] = (0, import_react.useState)(0);
|
|
347
|
+
const activeIdxRef = (0, import_react.useRef)(0);
|
|
348
|
+
const charPosRef = (0, import_react.useRef)(0);
|
|
349
|
+
activeIdxRef.current = activeIdx;
|
|
350
|
+
charPosRef.current = charPos;
|
|
351
|
+
const getBlockLen = (0, import_react.useCallback)((block) => {
|
|
352
|
+
switch (block.kind) {
|
|
353
|
+
case "thinking":
|
|
354
|
+
return block.content.length;
|
|
355
|
+
case "text":
|
|
356
|
+
return block.content.length;
|
|
357
|
+
case "tool_call": {
|
|
358
|
+
if (block.status === "running") return 0;
|
|
359
|
+
const display = block.result ?? "";
|
|
360
|
+
return Math.min(display.length, TYPEWRITER.maxToolResultLen);
|
|
361
|
+
}
|
|
362
|
+
case "status":
|
|
363
|
+
return (block.detail ?? "").length;
|
|
364
|
+
default:
|
|
365
|
+
return 0;
|
|
366
|
+
}
|
|
367
|
+
}, []);
|
|
368
|
+
(0, import_react.useEffect)(() => {
|
|
369
|
+
const timer = setInterval(() => {
|
|
370
|
+
const idx = activeIdxRef.current;
|
|
371
|
+
if (idx >= blocks.length) return;
|
|
372
|
+
const block = blocks[idx];
|
|
373
|
+
const targetLen = getBlockLen(block);
|
|
374
|
+
if (block.kind === "tool_call" && block.status === "running") return;
|
|
375
|
+
if (targetLen === 0 && block.kind !== "tool_call") {
|
|
376
|
+
setActiveIdx(idx + 1);
|
|
377
|
+
setCharPos(0);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const pos = charPosRef.current;
|
|
381
|
+
if (pos >= targetLen) {
|
|
382
|
+
if (block.kind === "thinking" && block.streaming) return;
|
|
383
|
+
if (block.kind === "text" && block.streaming) return;
|
|
384
|
+
setActiveIdx(idx + 1);
|
|
385
|
+
setCharPos(0);
|
|
386
|
+
} else {
|
|
387
|
+
const speed = 1;
|
|
388
|
+
const chars = Math.max(1, Math.round(TYPEWRITER.charsPerTick * speed));
|
|
389
|
+
setCharPos(Math.min(pos + chars, targetLen));
|
|
390
|
+
}
|
|
391
|
+
}, TYPEWRITER.intervalMs);
|
|
392
|
+
return () => clearInterval(timer);
|
|
393
|
+
}, [blocks, getBlockLen]);
|
|
394
|
+
(0, import_react.useEffect)(() => {
|
|
395
|
+
const idx = activeIdx;
|
|
396
|
+
if (idx < blocks.length) {
|
|
397
|
+
const block = blocks[idx];
|
|
398
|
+
const targetLen = getBlockLen(block);
|
|
399
|
+
if (targetLen === 0 || charPos >= targetLen) {
|
|
400
|
+
const isStreaming = (block.kind === "thinking" || block.kind === "text") && block.streaming;
|
|
401
|
+
if (!isStreaming && idx < blocks.length - 1) {
|
|
402
|
+
setActiveIdx(idx + 1);
|
|
403
|
+
setCharPos(0);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}, [blocks.length]);
|
|
408
|
+
return { activeIdx, charPos, getBlockLen };
|
|
409
|
+
}
|
|
410
|
+
function RevealedMarkdown({ content, revealedLen, showCursor }) {
|
|
411
|
+
const visibleText = content.slice(0, revealedLen);
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Flex, { inline: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.MarkdownContent, { content: visibleText + (showCursor ? TYPEWRITER.cursor : "") }) });
|
|
413
|
+
}
|
|
414
|
+
function RevealedToolResult({ result, revealedLen, isError }) {
|
|
415
|
+
const display = result.length > TYPEWRITER.maxToolResultLen ? result.slice(0, TYPEWRITER.maxToolResultLen) + "..." : result;
|
|
416
|
+
const visibleText = display.slice(0, revealedLen);
|
|
417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
418
|
+
import_plugin_ui_kit.Section,
|
|
419
|
+
{
|
|
420
|
+
padding: "compact",
|
|
421
|
+
background: "surface",
|
|
422
|
+
border: isError ? "none" : "top",
|
|
423
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
424
|
+
import_plugin_ui_kit.Typography,
|
|
425
|
+
{
|
|
426
|
+
variant: "smallCaption-regular",
|
|
427
|
+
color: isError ? "color-status-negative" : "color-text-medium",
|
|
428
|
+
mono: true,
|
|
429
|
+
children: visibleText || "\u200B"
|
|
430
|
+
}
|
|
431
|
+
)
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
function formatToolName(name) {
|
|
436
|
+
return name.replace(/^fw_/, "").replace(/_/g, " ");
|
|
437
|
+
}
|
|
438
|
+
function InstanceStreamView({
|
|
439
|
+
instanceId,
|
|
440
|
+
profileId,
|
|
441
|
+
profileName,
|
|
442
|
+
profileIcon,
|
|
443
|
+
profileColor,
|
|
444
|
+
currentRunId,
|
|
445
|
+
currentTaskId,
|
|
446
|
+
onBack
|
|
447
|
+
}) {
|
|
448
|
+
const ctx = (0, import_plugin_ui_kit.usePackWorkspace)();
|
|
449
|
+
const { callTool } = ctx;
|
|
450
|
+
const [showRedirect, setShowRedirect] = (0, import_react.useState)(false);
|
|
451
|
+
const [openTasks, setOpenTasks] = (0, import_react.useState)([]);
|
|
452
|
+
const [redirecting, setRedirecting] = (0, import_react.useState)(false);
|
|
453
|
+
const [task, setTask] = (0, import_react.useState)(null);
|
|
454
|
+
(0, import_react.useEffect)(() => {
|
|
455
|
+
if (!currentTaskId) return;
|
|
456
|
+
callTool("fw_weaver_task_get", { id: currentTaskId }).then((raw) => {
|
|
457
|
+
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
458
|
+
const t = data?.task ?? data;
|
|
459
|
+
if (t && typeof t === "object") setTask(t);
|
|
460
|
+
}).catch(() => {
|
|
461
|
+
});
|
|
462
|
+
}, [callTool, currentTaskId]);
|
|
463
|
+
const [history, setHistory] = (0, import_react.useState)([]);
|
|
464
|
+
(0, import_react.useEffect)(() => {
|
|
465
|
+
callTool("fw_weaver_history", { instanceId, limit: 10 }).then((raw) => {
|
|
466
|
+
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
467
|
+
if (Array.isArray(data)) {
|
|
468
|
+
setHistory(data.map((r) => {
|
|
469
|
+
const costObj = r.cost && typeof r.cost === "object" ? r.cost : void 0;
|
|
470
|
+
return { ...r, costDetail: costObj, cost: costObj?.totalCost ?? r.cost };
|
|
471
|
+
}));
|
|
472
|
+
}
|
|
473
|
+
}).catch(() => {
|
|
474
|
+
});
|
|
475
|
+
}, [callTool, instanceId]);
|
|
476
|
+
const stream = ctx.createEventStream();
|
|
477
|
+
const isLive = !!currentRunId;
|
|
478
|
+
(0, import_react.useEffect)(() => {
|
|
479
|
+
if (!isLive || !currentRunId) return;
|
|
480
|
+
stream.start(ctx.packId, "fw_weaver_events", currentRunId);
|
|
481
|
+
return () => stream.stop();
|
|
482
|
+
}, [isLive, currentRunId, ctx.packId]);
|
|
483
|
+
const conversation = (0, import_react.useMemo)(
|
|
484
|
+
() => buildConversation(stream.events),
|
|
485
|
+
[stream.events]
|
|
486
|
+
);
|
|
487
|
+
const { activeIdx, charPos, getBlockLen } = useConversationTypewriter(conversation);
|
|
488
|
+
const scrollRef = (0, import_react.useRef)(null);
|
|
489
|
+
(0, import_react.useEffect)(() => {
|
|
490
|
+
const el = scrollRef.current;
|
|
491
|
+
if (el) el.scrollTop = el.scrollHeight;
|
|
492
|
+
}, [conversation.length, stream.events.length]);
|
|
493
|
+
const [thinkingExpanded, setThinkingExpanded] = (0, import_react.useState)({});
|
|
494
|
+
const [expandedRunId, setExpandedRunId] = (0, import_react.useState)(null);
|
|
495
|
+
const runItems = (0, import_react.useMemo)(() => {
|
|
496
|
+
return history.map((run) => ({
|
|
497
|
+
run,
|
|
498
|
+
runTimeline: traceToTimeline(run)
|
|
499
|
+
}));
|
|
500
|
+
}, [history]);
|
|
501
|
+
function extractInstruction(run) {
|
|
502
|
+
if (run.instruction) {
|
|
503
|
+
const titleMatch = run.instruction.match(/^##\s*Task:\s*(.+)/m);
|
|
504
|
+
if (titleMatch) return titleMatch[1].trim().slice(0, 120);
|
|
505
|
+
return run.instruction.split("\n")[0].trim().slice(0, 120);
|
|
506
|
+
}
|
|
507
|
+
return run.summary?.slice(0, 120) ?? task?.title ?? "Bot run";
|
|
508
|
+
}
|
|
509
|
+
const statusIcon = isLive ? "running" : "pending";
|
|
510
|
+
const statusLabel = isLive ? "Executing" : "Idle";
|
|
511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-0", fill: true, children: [
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "default", border: "bottom", shrink: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-6", children: [
|
|
513
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Flex, { variant: "row-center-space-between-nowrap-8", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "row-center-start-nowrap-8", children: [
|
|
514
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.IconButton, { icon: "back", size: "xs", variant: "clear", onClick: onBack }),
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
516
|
+
import_plugin_ui_kit.Icon,
|
|
517
|
+
{
|
|
518
|
+
name: profileIcon || "smartToy",
|
|
519
|
+
size: 16,
|
|
520
|
+
color: profileColor || "color-text-medium"
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-thick", color: "color-text-high", children: profileName || profileId }),
|
|
524
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.StatusIcon, { status: statusIcon, size: "sm" }),
|
|
525
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
526
|
+
import_plugin_ui_kit.Typography,
|
|
527
|
+
{
|
|
528
|
+
variant: "smallCaption-regular",
|
|
529
|
+
color: isLive ? "color-brand-main" : "color-text-subtle",
|
|
530
|
+
children: statusLabel
|
|
531
|
+
}
|
|
532
|
+
),
|
|
533
|
+
isLive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
534
|
+
import_plugin_ui_kit.IconButton,
|
|
535
|
+
{
|
|
536
|
+
icon: "swapHoriz",
|
|
537
|
+
size: "xs",
|
|
538
|
+
variant: "clear",
|
|
539
|
+
title: "Redirect to another task",
|
|
540
|
+
onClick: () => {
|
|
541
|
+
if (showRedirect) {
|
|
542
|
+
setShowRedirect(false);
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
callTool("fw_weaver_task_list", { status: "open" }).then((raw) => {
|
|
546
|
+
const data = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
547
|
+
if (Array.isArray(data)) setOpenTasks(data.filter((t) => !t.isParent && t.id !== currentTaskId));
|
|
548
|
+
}).catch(() => {
|
|
549
|
+
});
|
|
550
|
+
setShowRedirect(true);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
)
|
|
554
|
+
] }) }),
|
|
555
|
+
task && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-2", children: [
|
|
556
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-text-medium", children: task.title }),
|
|
557
|
+
task.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", children: task.description.length > 200 ? task.description.slice(0, 197) + "..." : task.description })
|
|
558
|
+
] }),
|
|
559
|
+
!isLive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StreamIndicator, { state: "ended", message: "No active run \u2014 instance is idle" })
|
|
560
|
+
] }) }),
|
|
561
|
+
showRedirect && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "compact", border: "bottom", shrink: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-8", children: [
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.SectionTitle, { size: "xs", children: "Redirect to Task" }),
|
|
563
|
+
openTasks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
564
|
+
import_plugin_ui_kit.Table,
|
|
565
|
+
{
|
|
566
|
+
size: "compact",
|
|
567
|
+
getRowKey: (row) => row.id,
|
|
568
|
+
onRowClick: async (row) => {
|
|
569
|
+
setRedirecting(true);
|
|
570
|
+
try {
|
|
571
|
+
await callTool("fw_weaver_steer", { botId: instanceId, command: "redirect", payload: row.id });
|
|
572
|
+
(0, import_plugin_ui_kit.toast)(`Redirected to "${row.title}"`, { type: "success" });
|
|
573
|
+
setShowRedirect(false);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
(0, import_plugin_ui_kit.toast)(err instanceof Error ? err.message : "Failed to redirect", { type: "error" });
|
|
576
|
+
}
|
|
577
|
+
setRedirecting(false);
|
|
578
|
+
},
|
|
579
|
+
columns: [
|
|
580
|
+
{ key: "title", header: "Task" },
|
|
581
|
+
{ key: "priority", header: "P", width: "30px", align: "center" }
|
|
582
|
+
],
|
|
583
|
+
data: openTasks
|
|
584
|
+
}
|
|
585
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", children: "No open tasks" }),
|
|
586
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Button, { size: "xs", variant: "clear", color: "secondary", onClick: () => setShowRedirect(false), children: "Cancel" })
|
|
587
|
+
] }) }),
|
|
588
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.ScrollArea, { ref: scrollRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Section, { padding: "default", children: [
|
|
589
|
+
isLive && conversation.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-8", marginBottom: "default", children: conversation.map((block, i) => {
|
|
590
|
+
const isDone = i < activeIdx;
|
|
591
|
+
const isActive = i === activeIdx;
|
|
592
|
+
const isFuture = i > activeIdx;
|
|
593
|
+
if (isFuture) return null;
|
|
594
|
+
const revealedLen = isDone ? getBlockLen(block) : isActive ? charPos : 0;
|
|
595
|
+
const showCursor = isActive && revealedLen < getBlockLen(block);
|
|
596
|
+
const inner = (() => {
|
|
597
|
+
switch (block.kind) {
|
|
598
|
+
case "thinking": {
|
|
599
|
+
const isExpanded = thinkingExpanded[i] ?? (isActive || block.streaming);
|
|
600
|
+
const fullContent = block.content;
|
|
601
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
602
|
+
import_plugin_ui_kit.CollapsibleBlock,
|
|
603
|
+
{
|
|
604
|
+
status: "thinking",
|
|
605
|
+
label: isActive || block.streaming ? "Thinking..." : "Thought",
|
|
606
|
+
expanded: isExpanded,
|
|
607
|
+
onToggle: () => setThinkingExpanded((prev) => ({ ...prev, [i]: !isExpanded })),
|
|
608
|
+
children: fullContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "compact", background: "surface", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
609
|
+
RevealedMarkdown,
|
|
610
|
+
{
|
|
611
|
+
content: fullContent,
|
|
612
|
+
revealedLen,
|
|
613
|
+
showCursor
|
|
614
|
+
}
|
|
615
|
+
) }) : void 0
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
case "text":
|
|
620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "minimal", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
621
|
+
RevealedMarkdown,
|
|
622
|
+
{
|
|
623
|
+
content: block.content,
|
|
624
|
+
revealedLen,
|
|
625
|
+
showCursor
|
|
626
|
+
}
|
|
627
|
+
) });
|
|
628
|
+
case "tool_call": {
|
|
629
|
+
const hasResult = !!block.result;
|
|
630
|
+
const isRunning = block.status === "running";
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
632
|
+
import_plugin_ui_kit.CollapsibleBlock,
|
|
633
|
+
{
|
|
634
|
+
status: block.status,
|
|
635
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "caption-regular", color: "color-text-high", mono: true, children: formatToolName(block.name) }),
|
|
636
|
+
headerSuffix: isRunning ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", children: "running..." }) : block.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-status-negative", children: "failed" }) : null,
|
|
637
|
+
expanded: true,
|
|
638
|
+
canExpand: hasResult,
|
|
639
|
+
onToggle: () => {
|
|
640
|
+
},
|
|
641
|
+
children: [
|
|
642
|
+
isRunning && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "compact", background: "surface", border: "top", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Typography, { variant: "smallCaption-regular", color: "color-text-subtle", mono: true, children: "..." }) }),
|
|
643
|
+
hasResult && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
644
|
+
RevealedToolResult,
|
|
645
|
+
{
|
|
646
|
+
result: block.result,
|
|
647
|
+
revealedLen,
|
|
648
|
+
isError: block.isError
|
|
649
|
+
}
|
|
650
|
+
)
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
case "status": {
|
|
656
|
+
const statusMap = { started: "running", completed: "completed", failed: "error" };
|
|
657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
658
|
+
import_plugin_ui_kit.CollapsibleBlock,
|
|
659
|
+
{
|
|
660
|
+
status: statusMap[block.variant] ?? "running",
|
|
661
|
+
label: block.label,
|
|
662
|
+
expanded: !!(block.detail && (isDone || revealedLen > 0)),
|
|
663
|
+
canExpand: !!block.detail,
|
|
664
|
+
onToggle: () => {
|
|
665
|
+
},
|
|
666
|
+
children: block.detail && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.Section, { padding: "compact", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
667
|
+
RevealedMarkdown,
|
|
668
|
+
{
|
|
669
|
+
content: block.detail,
|
|
670
|
+
revealedLen,
|
|
671
|
+
showCursor
|
|
672
|
+
}
|
|
673
|
+
) })
|
|
674
|
+
}
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
default:
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
})();
|
|
681
|
+
if (!inner) return null;
|
|
682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.FadeIn, { visible: true, duration: 0.3, slide: 8, children: inner }, `block-${i}`);
|
|
683
|
+
}) }),
|
|
684
|
+
isLive && conversation.length === 0 && stream.isStreaming && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StreamIndicator, { state: "waiting" }),
|
|
685
|
+
isLive && stream.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StreamIndicator, { state: "error", message: stream.error }),
|
|
686
|
+
isLive && stream.isDone && conversation.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StreamIndicator, { state: "ended" }),
|
|
687
|
+
runItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_plugin_ui_kit.Flex, { variant: "column-stretch-start-nowrap-4", children: [
|
|
688
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_plugin_ui_kit.SectionTitle, { size: "xs", children: `History (${runItems.length})` }),
|
|
689
|
+
runItems.map(({ run, runTimeline }) => {
|
|
690
|
+
const runId = run.id;
|
|
691
|
+
const isExpanded = expandedRunId === runId;
|
|
692
|
+
const isSuccess = run.outcome === "completed" || run.success === true;
|
|
693
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
694
|
+
import_plugin_ui_kit.TaskBlock,
|
|
695
|
+
{
|
|
696
|
+
state: isSuccess ? "completed" : "failed",
|
|
697
|
+
instruction: extractInstruction(run),
|
|
698
|
+
timeline: runTimeline,
|
|
699
|
+
report: run.report ?? null,
|
|
700
|
+
cost: typeof run.cost === "number" ? run.cost : run.costDetail?.totalCost ?? null,
|
|
701
|
+
plan: run.plan,
|
|
702
|
+
startedAt: run.startedAt,
|
|
703
|
+
durationMs: run.durationMs ?? run.duration,
|
|
704
|
+
expanded: isExpanded,
|
|
705
|
+
onToggleExpand: () => setExpandedRunId((prev) => prev === runId ? null : runId)
|
|
706
|
+
},
|
|
707
|
+
`run-${runId}`
|
|
708
|
+
);
|
|
709
|
+
})
|
|
710
|
+
] }),
|
|
711
|
+
!isLive && runItems.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
712
|
+
import_plugin_ui_kit.EmptyState,
|
|
713
|
+
{
|
|
714
|
+
icon: "smartToy",
|
|
715
|
+
message: "No execution history",
|
|
716
|
+
description: "This instance has no runs yet."
|
|
717
|
+
}
|
|
718
|
+
)
|
|
719
|
+
] }) })
|
|
720
|
+
] });
|
|
721
|
+
}
|
|
722
|
+
var instance_stream_view_default = InstanceStreamView;
|