@tinyweb_dev/agent-framework-chat-ui 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinRenderers.d.ts","sourceRoot":"","sources":["../../../src/components/tool/builtinRenderers.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"builtinRenderers.d.ts","sourceRoot":"","sources":["../../../src/components/tool/builtinRenderers.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAA;AAuhBpE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAAE,YAAY,EAW9C,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -608,7 +608,8 @@ var LABELS = {
|
|
|
608
608
|
image_describe: { icon: "\u{1F5BC}\uFE0F", verb: "\u0110ang m\xF4 t\u1EA3 \u1EA3nh" },
|
|
609
609
|
image_edit: { icon: "\u270F\uFE0F", verb: "\u0110ang ch\u1EC9nh s\u1EEDa \u1EA3nh" },
|
|
610
610
|
file_read: { icon: "\u{1F4C2}", verb: "\u0110ang \u0111\u1ECDc file" },
|
|
611
|
-
file_write: { icon: "\u{1F4BE}", verb: "\u0110ang l\u01B0u file" }
|
|
611
|
+
file_write: { icon: "\u{1F4BE}", verb: "\u0110ang l\u01B0u file" },
|
|
612
|
+
update_todo_list: { icon: "\u2705", verb: "\u0110ang c\u1EADp nh\u1EADt todo list" }
|
|
612
613
|
};
|
|
613
614
|
var friendlyToolLabel = (toolName) => {
|
|
614
615
|
const hit = LABELS[toolName];
|
|
@@ -1154,6 +1155,87 @@ var renderWebFetch = (ctx) => {
|
|
|
1154
1155
|
}
|
|
1155
1156
|
);
|
|
1156
1157
|
};
|
|
1158
|
+
var asTodoStatus = (v) => {
|
|
1159
|
+
if (v === "completed" || v === "in_progress" || v === "pending") return v;
|
|
1160
|
+
return "pending";
|
|
1161
|
+
};
|
|
1162
|
+
var todoIcon = (status) => {
|
|
1163
|
+
if (status === "completed") return "\u2713";
|
|
1164
|
+
if (status === "in_progress") return "\u2192";
|
|
1165
|
+
return "\u25A1";
|
|
1166
|
+
};
|
|
1167
|
+
var parseTodosFromResult = (result, raw) => {
|
|
1168
|
+
const fromRecord = (v) => {
|
|
1169
|
+
if (!isRecord(v)) return null;
|
|
1170
|
+
const arr = asArray(v.todos);
|
|
1171
|
+
if (!arr || arr.length === 0) return null;
|
|
1172
|
+
const rows = [];
|
|
1173
|
+
for (const item of arr) {
|
|
1174
|
+
if (!isRecord(item)) continue;
|
|
1175
|
+
const content = asString(item.content);
|
|
1176
|
+
if (!content) continue;
|
|
1177
|
+
rows.push({
|
|
1178
|
+
id: asString(item.id),
|
|
1179
|
+
content,
|
|
1180
|
+
status: asTodoStatus(item.status)
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
return rows.length > 0 ? rows : null;
|
|
1184
|
+
};
|
|
1185
|
+
const fromResult = fromRecord(result);
|
|
1186
|
+
if (fromResult) return fromResult;
|
|
1187
|
+
if (isRecord(raw) && isRecord(raw.input)) {
|
|
1188
|
+
const inputTodos = raw.input.todos;
|
|
1189
|
+
if (typeof inputTodos === "string") {
|
|
1190
|
+
const lines = inputTodos.replace(/\\n/g, "\n").split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
1191
|
+
const rows = [];
|
|
1192
|
+
for (const line of lines) {
|
|
1193
|
+
const m = line.match(/^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/);
|
|
1194
|
+
if (!m) continue;
|
|
1195
|
+
const mark = m[1];
|
|
1196
|
+
let status = "pending";
|
|
1197
|
+
if (mark === "x" || mark === "X") status = "completed";
|
|
1198
|
+
else if (mark === "-" || mark === "~") status = "in_progress";
|
|
1199
|
+
rows.push({ content: m[2], status });
|
|
1200
|
+
}
|
|
1201
|
+
return rows.length > 0 ? rows : null;
|
|
1202
|
+
}
|
|
1203
|
+
return fromRecord(raw.input);
|
|
1204
|
+
}
|
|
1205
|
+
return null;
|
|
1206
|
+
};
|
|
1207
|
+
var renderUpdateTodoList = (ctx) => {
|
|
1208
|
+
const todos = parseTodosFromResult(ctx.result, ctx.raw);
|
|
1209
|
+
if (!todos) return null;
|
|
1210
|
+
const total = todos.length;
|
|
1211
|
+
const completed = todos.filter((t) => t.status === "completed").length;
|
|
1212
|
+
const allDone = completed === total && total > 0;
|
|
1213
|
+
const inProgress = todos.find((t) => t.status === "in_progress");
|
|
1214
|
+
const nextOpen = todos.find((t) => t.status !== "completed");
|
|
1215
|
+
const focus = inProgress ?? nextOpen;
|
|
1216
|
+
const subtitle = allDone ? `Ho\xE0n th\xE0nh ${completed}/${total}` : focus ? focus.content : `${completed}/${total}`;
|
|
1217
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1218
|
+
ToolCard,
|
|
1219
|
+
{
|
|
1220
|
+
icon: "\u2705",
|
|
1221
|
+
title: "Todo list",
|
|
1222
|
+
subtitle,
|
|
1223
|
+
source: `${completed}/${total}`,
|
|
1224
|
+
jsonText: safeStringify(ctx.result),
|
|
1225
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "tool-todo-list", "data-todo-list": true, children: todos.map((todo, idx) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1226
|
+
"li",
|
|
1227
|
+
{
|
|
1228
|
+
className: `tool-todo-item tool-todo-${todo.status}`,
|
|
1229
|
+
children: [
|
|
1230
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tool-todo-icon", "aria-hidden": "true", children: todoIcon(todo.status) }),
|
|
1231
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "tool-todo-content", children: todo.content })
|
|
1232
|
+
]
|
|
1233
|
+
},
|
|
1234
|
+
todo.id ?? `${todo.content}-${idx}`
|
|
1235
|
+
)) })
|
|
1236
|
+
}
|
|
1237
|
+
);
|
|
1238
|
+
};
|
|
1157
1239
|
var renderDisplayResponse = (ctx) => {
|
|
1158
1240
|
const message = isRecord(ctx.result) && asString(ctx.result.response) || isRecord(ctx.raw) && isRecord(ctx.raw.input) && asString(ctx.raw.input.response);
|
|
1159
1241
|
if (!message) return null;
|
|
@@ -1175,6 +1257,7 @@ var defaultToolRenderers = [
|
|
|
1175
1257
|
byName(["perplexity_search"], renderPerplexity),
|
|
1176
1258
|
byName(["web_search"], renderWebSearch),
|
|
1177
1259
|
byName(["web_fetch"], renderWebFetch),
|
|
1260
|
+
byName(["update_todo_list"], renderUpdateTodoList),
|
|
1178
1261
|
byName(["display_response"], renderDisplayResponse)
|
|
1179
1262
|
];
|
|
1180
1263
|
var COLLAPSE_LINES = 20;
|