@tinyweb_dev/agent-framework-chat-ui 0.3.0 → 0.4.1
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/tool/builtinRenderers.d.ts.map +1 -1
- package/dist/index.cjs +84 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +84 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +29 -0
- package/dist/util/tool-labels.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -586,7 +586,8 @@ var LABELS = {
|
|
|
586
586
|
image_describe: { icon: "\u{1F5BC}\uFE0F", verb: "\u0110ang m\xF4 t\u1EA3 \u1EA3nh" },
|
|
587
587
|
image_edit: { icon: "\u270F\uFE0F", verb: "\u0110ang ch\u1EC9nh s\u1EEDa \u1EA3nh" },
|
|
588
588
|
file_read: { icon: "\u{1F4C2}", verb: "\u0110ang \u0111\u1ECDc file" },
|
|
589
|
-
file_write: { icon: "\u{1F4BE}", verb: "\u0110ang l\u01B0u file" }
|
|
589
|
+
file_write: { icon: "\u{1F4BE}", verb: "\u0110ang l\u01B0u file" },
|
|
590
|
+
update_todo_list: { icon: "\u2705", verb: "\u0110ang c\u1EADp nh\u1EADt todo list" }
|
|
590
591
|
};
|
|
591
592
|
var friendlyToolLabel = (toolName) => {
|
|
592
593
|
const hit = LABELS[toolName];
|
|
@@ -1132,6 +1133,87 @@ var renderWebFetch = (ctx) => {
|
|
|
1132
1133
|
}
|
|
1133
1134
|
);
|
|
1134
1135
|
};
|
|
1136
|
+
var asTodoStatus = (v) => {
|
|
1137
|
+
if (v === "completed" || v === "in_progress" || v === "pending") return v;
|
|
1138
|
+
return "pending";
|
|
1139
|
+
};
|
|
1140
|
+
var todoIcon = (status) => {
|
|
1141
|
+
if (status === "completed") return "\u2713";
|
|
1142
|
+
if (status === "in_progress") return "\u2192";
|
|
1143
|
+
return "\u25A1";
|
|
1144
|
+
};
|
|
1145
|
+
var parseTodosFromResult = (result, raw) => {
|
|
1146
|
+
const fromRecord = (v) => {
|
|
1147
|
+
if (!isRecord(v)) return null;
|
|
1148
|
+
const arr = asArray(v.todos);
|
|
1149
|
+
if (!arr || arr.length === 0) return null;
|
|
1150
|
+
const rows = [];
|
|
1151
|
+
for (const item of arr) {
|
|
1152
|
+
if (!isRecord(item)) continue;
|
|
1153
|
+
const content = asString(item.content);
|
|
1154
|
+
if (!content) continue;
|
|
1155
|
+
rows.push({
|
|
1156
|
+
id: asString(item.id),
|
|
1157
|
+
content,
|
|
1158
|
+
status: asTodoStatus(item.status)
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
return rows.length > 0 ? rows : null;
|
|
1162
|
+
};
|
|
1163
|
+
const fromResult = fromRecord(result);
|
|
1164
|
+
if (fromResult) return fromResult;
|
|
1165
|
+
if (isRecord(raw) && isRecord(raw.input)) {
|
|
1166
|
+
const inputTodos = raw.input.todos;
|
|
1167
|
+
if (typeof inputTodos === "string") {
|
|
1168
|
+
const lines = inputTodos.replace(/\\n/g, "\n").split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
1169
|
+
const rows = [];
|
|
1170
|
+
for (const line of lines) {
|
|
1171
|
+
const m = line.match(/^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/);
|
|
1172
|
+
if (!m) continue;
|
|
1173
|
+
const mark = m[1];
|
|
1174
|
+
let status = "pending";
|
|
1175
|
+
if (mark === "x" || mark === "X") status = "completed";
|
|
1176
|
+
else if (mark === "-" || mark === "~") status = "in_progress";
|
|
1177
|
+
rows.push({ content: m[2], status });
|
|
1178
|
+
}
|
|
1179
|
+
return rows.length > 0 ? rows : null;
|
|
1180
|
+
}
|
|
1181
|
+
return fromRecord(raw.input);
|
|
1182
|
+
}
|
|
1183
|
+
return null;
|
|
1184
|
+
};
|
|
1185
|
+
var renderUpdateTodoList = (ctx) => {
|
|
1186
|
+
const todos = parseTodosFromResult(ctx.result, ctx.raw);
|
|
1187
|
+
if (!todos) return null;
|
|
1188
|
+
const total = todos.length;
|
|
1189
|
+
const completed = todos.filter((t) => t.status === "completed").length;
|
|
1190
|
+
const allDone = completed === total && total > 0;
|
|
1191
|
+
const inProgress = todos.find((t) => t.status === "in_progress");
|
|
1192
|
+
const nextOpen = todos.find((t) => t.status !== "completed");
|
|
1193
|
+
const focus = inProgress ?? nextOpen;
|
|
1194
|
+
const subtitle = allDone ? `Ho\xE0n th\xE0nh ${completed}/${total}` : focus ? focus.content : `${completed}/${total}`;
|
|
1195
|
+
return /* @__PURE__ */ jsx(
|
|
1196
|
+
ToolCard,
|
|
1197
|
+
{
|
|
1198
|
+
icon: "\u2705",
|
|
1199
|
+
title: "Todo list",
|
|
1200
|
+
subtitle,
|
|
1201
|
+
source: `${completed}/${total}`,
|
|
1202
|
+
jsonText: safeStringify(ctx.result),
|
|
1203
|
+
children: /* @__PURE__ */ jsx("ul", { className: "tool-todo-list", "data-todo-list": true, children: todos.map((todo, idx) => /* @__PURE__ */ jsxs(
|
|
1204
|
+
"li",
|
|
1205
|
+
{
|
|
1206
|
+
className: `tool-todo-item tool-todo-${todo.status}`,
|
|
1207
|
+
children: [
|
|
1208
|
+
/* @__PURE__ */ jsx("span", { className: "tool-todo-icon", "aria-hidden": "true", children: todoIcon(todo.status) }),
|
|
1209
|
+
/* @__PURE__ */ jsx("span", { className: "tool-todo-content", children: todo.content })
|
|
1210
|
+
]
|
|
1211
|
+
},
|
|
1212
|
+
todo.id ?? `${todo.content}-${idx}`
|
|
1213
|
+
)) })
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
};
|
|
1135
1217
|
var renderDisplayResponse = (ctx) => {
|
|
1136
1218
|
const message = isRecord(ctx.result) && asString(ctx.result.response) || isRecord(ctx.raw) && isRecord(ctx.raw.input) && asString(ctx.raw.input.response);
|
|
1137
1219
|
if (!message) return null;
|
|
@@ -1153,6 +1235,7 @@ var defaultToolRenderers = [
|
|
|
1153
1235
|
byName(["perplexity_search"], renderPerplexity),
|
|
1154
1236
|
byName(["web_search"], renderWebSearch),
|
|
1155
1237
|
byName(["web_fetch"], renderWebFetch),
|
|
1238
|
+
byName(["update_todo_list"], renderUpdateTodoList),
|
|
1156
1239
|
byName(["display_response"], renderDisplayResponse)
|
|
1157
1240
|
];
|
|
1158
1241
|
var COLLAPSE_LINES = 20;
|