@sepveneto/dnde-agent 0.1.16 → 0.2.0-beta.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/README.md +77 -0
- package/dist/{agent-JES391Lz.js → agent-BP3wmmgT.js} +1 -1
- package/dist/agents.d.ts +19 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/{index-gtAUVnBf.js → index-B_cPI3XS.js} +22677 -20328
- package/dist/index.d.ts +9 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -40
- package/dist/runtime.d.ts +31 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/tool.d.ts +30 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/types.d.ts +63 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +3 -4
- package/dist/agent/capability.d.ts +0 -32
- package/dist/agent/capability.d.ts.map +0 -1
- package/dist/agent/capabilityAgent.d.ts +0 -6
- package/dist/agent/capabilityAgent.d.ts.map +0 -1
- package/dist/agent/capabilityRegistry.d.ts +0 -15
- package/dist/agent/capabilityRegistry.d.ts.map +0 -1
- package/dist/agent/context.d.ts +0 -17
- package/dist/agent/context.d.ts.map +0 -1
- package/dist/agent/core/sdk.d.ts +0 -35
- package/dist/agent/core/sdk.d.ts.map +0 -1
- package/dist/agent/editAgent.d.ts +0 -6
- package/dist/agent/editAgent.d.ts.map +0 -1
- package/dist/agent/extract.d.ts +0 -9
- package/dist/agent/extract.d.ts.map +0 -1
- package/dist/agent/flowAgent.d.ts +0 -22
- package/dist/agent/flowAgent.d.ts.map +0 -1
- package/dist/agent/ir.d.ts +0 -92
- package/dist/agent/ir.d.ts.map +0 -1
- package/dist/agent/layout.d.ts +0 -14
- package/dist/agent/layout.d.ts.map +0 -1
- package/dist/agent/runtime.d.ts +0 -73
- package/dist/agent/runtime.d.ts.map +0 -1
- package/dist/agent/type.d.ts +0 -45
- package/dist/agent/type.d.ts.map +0 -1
- package/dist/agent/utils/helper.d.ts +0 -7
- package/dist/agent/utils/helper.d.ts.map +0 -1
- package/dist/agent/workflow.d.ts +0 -94
- package/dist/agent/workflow.d.ts.map +0 -1
- package/dist/composables/index.d.ts +0 -2
- package/dist/composables/index.d.ts.map +0 -1
- package/dist/composables/useFile.d.ts +0 -14
- package/dist/composables/useFile.d.ts.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# `@sepveneto/dnde-agent`
|
|
2
|
+
|
|
3
|
+
装修助手以一个独立自定义元素接入编辑器。Agent 实现来自
|
|
4
|
+
`llm-agent`:Agents SDK 负责 Agent Loop、工具调用、流式输出和会话历史;
|
|
5
|
+
本包只保留 Web Component 外壳、宿主 API 协议和业务工具适配。
|
|
6
|
+
|
|
7
|
+
## 接入
|
|
8
|
+
|
|
9
|
+
宿主提供编辑器 API、业务工具和运行时上下文:
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<dnd-agent
|
|
13
|
+
:api="agentApi"
|
|
14
|
+
:tools="businessTools"
|
|
15
|
+
:context="getContext"
|
|
16
|
+
></dnd-agent>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
直接导入元素入口会自动注册 `<dnd-agent>`:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import '@sepveneto/dnde-agent/element'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
也可以由编辑器在 `register({ agent })` 中按需注入:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
register({
|
|
29
|
+
remoteUrl,
|
|
30
|
+
agent: () => import('@sepveneto/dnde-agent/element'),
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 宿主 API
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
interface AgentHostApi {
|
|
38
|
+
model?: {
|
|
39
|
+
baseURL?: string
|
|
40
|
+
model?: string
|
|
41
|
+
apiMode?: 'responses' | 'chat_completions'
|
|
42
|
+
}
|
|
43
|
+
editor?: {
|
|
44
|
+
getCurrentEditor(): unknown | Promise<unknown>
|
|
45
|
+
getWidgets(): unknown | Promise<unknown>
|
|
46
|
+
operateEditor(operation: AgentEditorOperation): unknown | Promise<unknown>
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
默认带三个基于编辑器 API 的工具:`get_current_editor`、`get_widgets`、
|
|
52
|
+
`editor_operator`。写操作和历史不可逆操作应先取得用户确认。
|
|
53
|
+
|
|
54
|
+
## 业务工具
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { defineAgentTool } from '@sepveneto/dnde-agent'
|
|
58
|
+
import { z } from 'zod'
|
|
59
|
+
|
|
60
|
+
const queryOrder = defineAgentTool({
|
|
61
|
+
name: 'query_order',
|
|
62
|
+
description: '查询订单状态',
|
|
63
|
+
parameters: z.object({ id: z.string() }),
|
|
64
|
+
async execute({ id }, context) {
|
|
65
|
+
return fetch(`/api/orders/${id}`).then(response => response.json())
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
工具的 `execute` 在浏览器内运行,并可读取宿主通过 `context` 注入的只读上下文。
|
|
71
|
+
模型请求走兼容 OpenAI 的宿主代理/BFF,浏览器侧不保存真实密钥。
|
|
72
|
+
|
|
73
|
+
## UI
|
|
74
|
+
|
|
75
|
+
UI 保留原装修助手的悬浮按钮交互。展开后使用 `llm-agent` 的聊天视图:
|
|
76
|
+
空状态示例、Markdown、reasoning、工具调用、数据事件、流式文本、停止生成和历史记录,
|
|
77
|
+
全部位于 `dnd-agent` 的 Shadow DOM 内。
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var Q = (t, s, e) => s in t ? V(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
|
|
3
3
|
var a = (t, s, e) => Q(t, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
-
import { C as E, U as x, r as X, t as I, o as v, s as y, a as Z, w as A, i as q, e as ee, A as te, n as k, b as R, p as C, c as se, S as ie, d as ne, M as re, f as ae } from "./index-
|
|
4
|
+
import { C as E, U as x, r as X, t as I, o as v, s as y, a as Z, w as A, i as q, e as ee, A as te, n as k, b as R, p as C, c as se, S as ie, d as ne, M as re, f as ae } from "./index-B_cPI3XS.js";
|
|
5
5
|
function oe(t) {
|
|
6
6
|
return t ? !(typeof t == "object" && t && "constructor" in t && typeof t.constructor == "function" ? t.constructor.name : "").includes("ChatCompletions") : !0;
|
|
7
7
|
}
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AgentToolDefinition } from './tool';
|
|
2
|
+
import type { AgentHostApi } from './types';
|
|
3
|
+
import { Agent } from '@openai/agents';
|
|
4
|
+
export declare const DEFAULT_AGENT_MODEL = "qwen3.6-flash";
|
|
5
|
+
export declare const DEFAULT_AGENT_BFF_URL = "http://localhost:4000/v1";
|
|
6
|
+
export interface CreateAgentsOptions {
|
|
7
|
+
model?: string;
|
|
8
|
+
api: AgentHostApi;
|
|
9
|
+
tools?: AgentToolDefinition[];
|
|
10
|
+
getContext?: () => Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* llm-agent 的 Agent 定义已迁移到这里。业务工具通过 options.tools 注入,
|
|
14
|
+
* 编辑器能力通过 options.api 注入,Agent 本身不持有宿主状态。
|
|
15
|
+
*/
|
|
16
|
+
export declare function createAgents(options: CreateAgentsOptions): {
|
|
17
|
+
agent: Agent<any, "text">;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAQ,MAAM,gBAAgB,CAAA;AAG5C,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAClD,eAAO,MAAM,qBAAqB,6BAA6B,CAAA;AAE/D,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,YAAY,CAAA;IACjB,KAAK,CAAC,EAAE,mBAAmB,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC3C;AA4JD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;EA2BxD"}
|