@inf-monkeys-tech/monkeys-design 1.0.16 → 1.0.17
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/components/agent-workbench/index.d.mts +36 -4
- package/dist/components/agent-workbench/index.d.ts +36 -4
- package/dist/components/agent-workbench/index.js +167 -1
- package/dist/components/agent-workbench/index.js.map +1 -1
- package/dist/components/agent-workbench/index.mjs +167 -2
- package/dist/components/agent-workbench/index.mjs.map +1 -1
- package/dist/{details-model-f2034b78b458.d.mts → details-model-235bb3448dca.d.mts} +2 -1
- package/dist/{details-model-f2034b78b458.d.ts → details-model-235bb3448dca.d.ts} +2 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1452,6 +1452,7 @@ function RunStatus({
|
|
|
1452
1452
|
}
|
|
1453
1453
|
function AgentWorkbenchActivity({
|
|
1454
1454
|
viewModel,
|
|
1455
|
+
ariaLabel,
|
|
1455
1456
|
hiddenToolCallIds,
|
|
1456
1457
|
hideReasoning = false,
|
|
1457
1458
|
hideStoppedRun = false,
|
|
@@ -1479,7 +1480,7 @@ function AgentWorkbenchActivity({
|
|
|
1479
1480
|
"section",
|
|
1480
1481
|
{
|
|
1481
1482
|
className: cn2("space-y-3", classNames?.root, className),
|
|
1482
|
-
"aria-label": messages.label,
|
|
1483
|
+
"aria-label": ariaLabel ?? messages.label,
|
|
1483
1484
|
"data-agent-workbench-mode": activity.mode,
|
|
1484
1485
|
"data-agent-workbench-status": activity.status,
|
|
1485
1486
|
children: [
|
|
@@ -2185,7 +2186,171 @@ function AgentWorkbenchTaskDetails({
|
|
|
2185
2186
|
}
|
|
2186
2187
|
);
|
|
2187
2188
|
}
|
|
2189
|
+
function materializeMessages(events) {
|
|
2190
|
+
const messages = /* @__PURE__ */ new Map();
|
|
2191
|
+
for (const event of events) {
|
|
2192
|
+
if (event.eventType !== "message") continue;
|
|
2193
|
+
const current = messages.get(event.payload.messageId);
|
|
2194
|
+
const parts = event.payload.operation === "replace" ? event.payload.parts : [...current?.parts ?? [], ...event.payload.parts];
|
|
2195
|
+
messages.set(event.payload.messageId, {
|
|
2196
|
+
id: event.payload.messageId,
|
|
2197
|
+
role: event.payload.role,
|
|
2198
|
+
parts,
|
|
2199
|
+
sequence: event.sequence
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
return [...messages.values()];
|
|
2203
|
+
}
|
|
2204
|
+
function logicalActivityKey(event) {
|
|
2205
|
+
switch (event.eventType) {
|
|
2206
|
+
case "reasoning":
|
|
2207
|
+
return `reasoning:${event.payload.reasoningId}`;
|
|
2208
|
+
case "plan":
|
|
2209
|
+
return `plan:${event.payload.planId}`;
|
|
2210
|
+
case "task":
|
|
2211
|
+
return `task:${event.payload.taskId}`;
|
|
2212
|
+
case "tool":
|
|
2213
|
+
return `tool:${event.payload.toolCallId}`;
|
|
2214
|
+
case "approval":
|
|
2215
|
+
return `approval:${event.payload.approvalId}`;
|
|
2216
|
+
case "artifact":
|
|
2217
|
+
return `artifact:${event.payload.artifactId}`;
|
|
2218
|
+
case "usage":
|
|
2219
|
+
return "usage";
|
|
2220
|
+
case "status":
|
|
2221
|
+
return "status";
|
|
2222
|
+
default:
|
|
2223
|
+
return void 0;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
function createThreadEntries(viewModel) {
|
|
2227
|
+
const messages = materializeMessages(viewModel.events).map((message) => ({
|
|
2228
|
+
type: "message",
|
|
2229
|
+
sequence: message.sequence,
|
|
2230
|
+
message
|
|
2231
|
+
}));
|
|
2232
|
+
const activity = /* @__PURE__ */ new Map();
|
|
2233
|
+
for (const event of viewModel.events) {
|
|
2234
|
+
const key = logicalActivityKey(event);
|
|
2235
|
+
if (key) activity.set(key, event);
|
|
2236
|
+
}
|
|
2237
|
+
return [
|
|
2238
|
+
...messages,
|
|
2239
|
+
...viewModel.events.filter((event) => event.eventType === "error").map((event) => ({ type: "error", sequence: event.sequence, event })),
|
|
2240
|
+
...[...activity.values()].map((event) => ({
|
|
2241
|
+
type: "activity",
|
|
2242
|
+
sequence: event.sequence,
|
|
2243
|
+
event
|
|
2244
|
+
}))
|
|
2245
|
+
].sort((left, right) => left.sequence - right.sequence);
|
|
2246
|
+
}
|
|
2247
|
+
function partText(part) {
|
|
2248
|
+
if (typeof part === "string") return part;
|
|
2249
|
+
if (!part || typeof part !== "object" || Array.isArray(part)) return String(part ?? "");
|
|
2250
|
+
const record = part;
|
|
2251
|
+
if (typeof record.text === "string") return record.text;
|
|
2252
|
+
if (typeof record.name === "string") return record.name;
|
|
2253
|
+
return JSON.stringify(record, null, 2);
|
|
2254
|
+
}
|
|
2255
|
+
function DefaultMessageContent({ message }) {
|
|
2256
|
+
const content = message.parts.map(partText).filter(Boolean).join("");
|
|
2257
|
+
return /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap break-words", children: content });
|
|
2258
|
+
}
|
|
2259
|
+
function singleEventViewModel(viewModel, event) {
|
|
2260
|
+
return {
|
|
2261
|
+
...viewModel,
|
|
2262
|
+
events: [event],
|
|
2263
|
+
lastSequence: event.sequence
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
function AgentWorkbenchThread({
|
|
2267
|
+
viewModel,
|
|
2268
|
+
loading = false,
|
|
2269
|
+
emptyTitle,
|
|
2270
|
+
emptyDescription,
|
|
2271
|
+
autoScroll = true,
|
|
2272
|
+
className,
|
|
2273
|
+
classNames,
|
|
2274
|
+
renderMessageContent,
|
|
2275
|
+
onApprovalDecision,
|
|
2276
|
+
onArtifactOpen
|
|
2277
|
+
}) {
|
|
2278
|
+
const messages = useMonkeysLocaleMessages().agentWorkbench;
|
|
2279
|
+
const scrollRef = useRef(null);
|
|
2280
|
+
const entries = useMemo(
|
|
2281
|
+
() => viewModel ? createThreadEntries(viewModel) : [],
|
|
2282
|
+
[viewModel]
|
|
2283
|
+
);
|
|
2284
|
+
useEffect(() => {
|
|
2285
|
+
if (!autoScroll || !viewModel) return;
|
|
2286
|
+
const element = scrollRef.current;
|
|
2287
|
+
if (element) element.scrollTop = element.scrollHeight;
|
|
2288
|
+
}, [autoScroll, viewModel?.lastSequence, viewModel?.sessionId]);
|
|
2289
|
+
return /* @__PURE__ */ jsx(
|
|
2290
|
+
"div",
|
|
2291
|
+
{
|
|
2292
|
+
ref: scrollRef,
|
|
2293
|
+
role: "log",
|
|
2294
|
+
"aria-label": messages.label,
|
|
2295
|
+
className: cn2("min-h-0 flex-1 overflow-y-auto bg-background", classNames?.root, className),
|
|
2296
|
+
children: loading && entries.length === 0 ? /* @__PURE__ */ jsxs("div", { className: cn2("flex min-h-48 items-center justify-center gap-2 text-sm text-muted-foreground", classNames?.loading), role: "status", children: [
|
|
2297
|
+
/* @__PURE__ */ jsx("span", { className: "size-4 animate-spin rounded-full border-2 border-muted-foreground/30 border-t-muted-foreground", "aria-hidden": "true" }),
|
|
2298
|
+
/* @__PURE__ */ jsx("span", { children: messages.navigation.loading })
|
|
2299
|
+
] }) : entries.length === 0 ? /* @__PURE__ */ jsxs("div", { className: cn2("flex min-h-48 flex-col items-center justify-center px-6 text-center", classNames?.empty), children: [
|
|
2300
|
+
emptyTitle ? /* @__PURE__ */ jsx("h2", { className: "text-base font-semibold text-foreground", children: emptyTitle }) : null,
|
|
2301
|
+
emptyDescription ? /* @__PURE__ */ jsx("p", { className: "mt-1 max-w-lg text-sm text-muted-foreground", children: emptyDescription }) : null
|
|
2302
|
+
] }) : /* @__PURE__ */ jsx("div", { className: cn2("mx-auto flex w-full max-w-4xl flex-col gap-4 px-4 py-6 sm:px-6", classNames?.list), children: entries.map((entry) => {
|
|
2303
|
+
if (entry.type === "error") {
|
|
2304
|
+
return /* @__PURE__ */ jsx(
|
|
2305
|
+
"div",
|
|
2306
|
+
{
|
|
2307
|
+
role: "alert",
|
|
2308
|
+
className: cn2("rounded-lg border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive-text", classNames?.activity),
|
|
2309
|
+
children: entry.event.payload.message
|
|
2310
|
+
},
|
|
2311
|
+
`error:${entry.event.eventId}`
|
|
2312
|
+
);
|
|
2313
|
+
}
|
|
2314
|
+
if (entry.type === "activity") {
|
|
2315
|
+
return /* @__PURE__ */ jsx(
|
|
2316
|
+
AgentWorkbenchActivity,
|
|
2317
|
+
{
|
|
2318
|
+
viewModel: singleEventViewModel(viewModel, entry.event),
|
|
2319
|
+
ariaLabel: `${messages.label} ${entry.sequence + 1}`,
|
|
2320
|
+
className: classNames?.activity,
|
|
2321
|
+
onApprovalDecision,
|
|
2322
|
+
onArtifactOpen
|
|
2323
|
+
},
|
|
2324
|
+
`activity:${entry.event.eventId}`
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
const { message } = entry;
|
|
2328
|
+
const isUser = message.role === "user";
|
|
2329
|
+
const isSystem = message.role === "system";
|
|
2330
|
+
if (isSystem) {
|
|
2331
|
+
return /* @__PURE__ */ jsx("div", { className: cn2("text-center text-xs text-muted-foreground", classNames?.message), children: renderMessageContent?.(message) ?? /* @__PURE__ */ jsx(DefaultMessageContent, { message }) }, message.id);
|
|
2332
|
+
}
|
|
2333
|
+
return /* @__PURE__ */ jsxs(
|
|
2334
|
+
"article",
|
|
2335
|
+
{
|
|
2336
|
+
className: cn2("flex items-start gap-3", isUser && "flex-row-reverse", classNames?.message),
|
|
2337
|
+
"data-message-role": message.role,
|
|
2338
|
+
children: [
|
|
2339
|
+
/* @__PURE__ */ jsx("span", { className: cn2("flex size-8 shrink-0 items-center justify-center rounded-full", isUser ? "bg-primary text-primary-foreground" : "bg-muted text-foreground"), "aria-hidden": "true", children: /* @__PURE__ */ jsx("span", { className: "size-2 rounded-full bg-current" }) }),
|
|
2340
|
+
/* @__PURE__ */ jsx("div", { className: cn2(
|
|
2341
|
+
"min-w-0 max-w-[85%] rounded-2xl px-4 py-2.5 text-sm leading-6",
|
|
2342
|
+
isUser ? "bg-primary text-primary-foreground" : "bg-card text-card-foreground",
|
|
2343
|
+
classNames?.messageContent
|
|
2344
|
+
), children: renderMessageContent?.(message) ?? /* @__PURE__ */ jsx(DefaultMessageContent, { message }) })
|
|
2345
|
+
]
|
|
2346
|
+
},
|
|
2347
|
+
message.id
|
|
2348
|
+
);
|
|
2349
|
+
}) })
|
|
2350
|
+
}
|
|
2351
|
+
);
|
|
2352
|
+
}
|
|
2188
2353
|
|
|
2189
|
-
export { AgentWorkbenchActivity, AgentWorkbenchComposer, AgentWorkbenchSidebar, AgentWorkbenchTaskDetails, AgentWorkbenchTool, createAgentWorkbenchActivityModel, createAgentWorkbenchDetailsModel };
|
|
2354
|
+
export { AgentWorkbenchActivity, AgentWorkbenchComposer, AgentWorkbenchSidebar, AgentWorkbenchTaskDetails, AgentWorkbenchThread, AgentWorkbenchTool, createAgentWorkbenchActivityModel, createAgentWorkbenchDetailsModel };
|
|
2190
2355
|
//# sourceMappingURL=index.mjs.map
|
|
2191
2356
|
//# sourceMappingURL=index.mjs.map
|