@auipage/core 0.1.0-alpha.0 → 0.1.0-alpha.2

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.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 页面侧(前端)工具定义
3
+ */
4
+ import type {
5
+ MaybePromise,
6
+ ToolCallStatus,
7
+ ToolDescription,
8
+ ToolExecutor
9
+ } from "@auipage/types";
10
+
11
+ /** render 收到的数据:入参、execute 的执行结果与状态,以及工具事件上的其它字段 */
12
+ export interface ToolRenderData {
13
+ /** 模型解析出的入参 */
14
+ args: Record<string, unknown>;
15
+ /** execute 的执行结果(异常时为错误对象) */
16
+ result: unknown;
17
+ /** execute 的执行状态 */
18
+ status: ToolCallStatus;
19
+ [key: string]: unknown;
20
+ }
21
+
22
+ /**
23
+ * UI 交互函数:execute 完成后调用,可在页面上完成弹窗、表单补充等交互;
24
+ * 其返回值(可 Promise)才是最终回传给模型的结果。
25
+ */
26
+ export type ToolRender = (data: ToolRenderData) => MaybePromise<unknown>;
27
+
28
+ /**
29
+ * 注册到 AuiPage 的工具。
30
+ * execute / render 均可缺省,但缺省 execute 的工具只有在
31
+ * @auipage/agent 的 CreateTool 前后端桥接场景下才能正常工作。
32
+ */
33
+ export interface Tool {
34
+ description: ToolDescription;
35
+ execute?: ToolExecutor;
36
+ render?: ToolRender;
37
+ }
38
+
39
+ /** defineTool 的平铺入参 */
40
+ export interface DefineToolOptions {
41
+ /** 工具名,对应 description.function.name */
42
+ name: string;
43
+ /** 给模型看的功能描述 */
44
+ description: string;
45
+ /** 入参 JSON Schema */
46
+ parameters: Record<string, unknown>;
47
+ /** 页面侧执行函数 */
48
+ execute?: ToolExecutor;
49
+ /** UI 交互函数 */
50
+ render?: ToolRender;
51
+ }