@sepveneto/dnde-agent 0.1.8 → 0.1.10

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/index.js CHANGED
@@ -1,1140 +1,41 @@
1
- import { defineComponent as nt, shallowRef as xt, watch as q, ref as C, computed as bt, nextTick as ht, createElementBlock as b, openBlock as h, createElementVNode as _, createCommentVNode as $, normalizeClass as E, toDisplayString as v, Fragment as U, renderList as K, withDirectives as vt, vModelText as kt, reactive as St, createVNode as At } from "vue";
2
- import { tool as It, run as ot, Usage as Ct, Agent as J, MemorySession as jt } from "@openai/agents";
3
- import { Agent as ia, MemorySession as la, Runner as ca, run as pa, tool as ua } from "@openai/agents";
4
- import { z as g } from "zod";
5
- import Ot from "openai";
6
- function Ue(t) {
7
- return { kind: "capability", ...t };
8
- }
9
- function zt(t) {
10
- return t.inputSchema && t.inputSchema instanceof g.ZodObject ? t.inputSchema : g.object({ input: g.string().optional() });
11
- }
12
- function B(t) {
13
- return It({
14
- name: t.name,
15
- description: t.description,
16
- parameters: zt(t),
17
- strict: !0,
18
- async execute(e, a) {
19
- const o = a == null ? void 0 : a.context, r = {
20
- state: o == null ? void 0 : o.state,
21
- onApproval: o == null ? void 0 : o.onApproval,
22
- signal: o == null ? void 0 : o.signal
23
- };
24
- if (!await rt(t, e, r))
25
- return { ok: !1, rejected: !0, message: `用户不同意执行 ${t.name}` };
26
- try {
27
- return await t.execute(e, r);
28
- } catch (l) {
29
- return {
30
- ok: !1,
31
- error: l instanceof Error ? l.message : String(l)
32
- };
33
- }
34
- }
35
- });
36
- }
37
- let $t = 0;
38
- async function Pe(t, e, a = {}) {
39
- if (!await rt(t, e, a))
40
- throw new Error(`用户不同意执行 ${t.name}`);
41
- return await t.execute(e, a);
42
- }
43
- async function rt(t, e, a) {
44
- var l, c, m, d, f, u, y;
45
- if (!await Rt(t.needsApproval, e))
46
- return !0;
47
- const r = (m = (c = (l = t.approval) == null ? void 0 : l.message) == null ? void 0 : c.call(l, e)) != null ? m : `是否执行 ${t.name}?`, s = a.onApproval ? await a.onApproval({
48
- callId: `cap-${++$t}`,
49
- name: t.name,
50
- args: e,
51
- message: r
52
- }) : !1;
53
- return s ? (f = (d = t.approval) == null ? void 0 : d.onApprove) == null || f.call(d, e) : (y = (u = t.approval) == null ? void 0 : u.onReject) == null || y.call(u, e), s;
54
- }
55
- async function Rt(t, e) {
56
- return typeof t == "function" ? !!await t(e) : !!t;
57
- }
58
- const Tt = {
59
- baseURL: "http://localhost:4000/v1",
60
- apiKey: "test",
61
- model: "qwen-plus"
62
- };
63
- let R = { ...Tt }, P = st(R);
64
- function st(t) {
65
- return new Ot({
66
- baseURL: t.baseURL,
67
- apiKey: t.apiKey,
68
- dangerouslyAllowBrowser: !0
69
- });
70
- }
71
- function Be(t) {
72
- R = { ...R, ...t }, P = st(R);
73
- }
74
- function We() {
75
- return { ...R };
76
- }
77
- function Ke() {
78
- return R.model;
79
- }
80
- function Ve(t) {
81
- P = t;
82
- }
83
- function F() {
84
- return new Nt(R.model);
85
- }
86
- class Nt {
87
- constructor(e) {
88
- this.model = e;
89
- }
90
- async getResponse(e) {
91
- var f, u, y;
92
- const { messages: a, tools: o, responseFormat: r } = tt(e), s = await P.chat.completions.create({
93
- model: this.model,
94
- messages: a,
95
- temperature: 0,
96
- stream: !0,
97
- ...o ? { tools: o } : {},
98
- ...r ? { response_format: r } : {}
99
- }), { responseId: l, usage: c, text: m, functionCalls: d } = await Ft(s);
100
- return {
101
- output: et(l, m.join(""), d),
102
- responseId: l || "proxy-response",
103
- usage: new Ct({
104
- requests: 1,
105
- input_tokens: (f = c == null ? void 0 : c.prompt_tokens) != null ? f : 0,
106
- output_tokens: (u = c == null ? void 0 : c.completion_tokens) != null ? u : 0,
107
- total_tokens: (y = c == null ? void 0 : c.total_tokens) != null ? y : 0
108
- })
109
- };
110
- }
111
- async *getStreamedResponse(e) {
112
- var y, x, k, j, D, T, S, N, L;
113
- const { messages: a, tools: o, responseFormat: r } = tt(e), s = await P.chat.completions.create({
114
- model: this.model,
115
- messages: a,
116
- temperature: 0,
117
- stream: !0,
118
- ...o ? { tools: o } : {},
119
- ...r ? { response_format: r } : {}
120
- });
121
- let l = "", c;
122
- const m = [], d = [];
123
- let f = !1;
124
- for await (const O of s) {
125
- f || (f = !0, yield { type: "response_started" }), O.id && (l = O.id), O.usage && (c = O.usage);
126
- const I = (x = (y = O.choices) == null ? void 0 : y[0]) == null ? void 0 : x.delta;
127
- if (I) {
128
- I.content && (m.push(I.content), yield { type: "output_text_delta", delta: I.content });
129
- for (const A of (k = I.tool_calls) != null ? k : []) {
130
- const z = (j = A.index) != null ? j : 0;
131
- d[z] || (d[z] = { id: "", callId: "", name: "", arguments: "" }), A.id && (d[z].callId = A.id), (D = A.function) != null && D.name && (d[z].name += A.function.name), (T = A.function) != null && T.arguments && (d[z].arguments += A.function.arguments);
132
- }
133
- }
134
- }
135
- const u = et(l, m.join(""), d);
136
- yield {
137
- type: "response_done",
138
- response: {
139
- id: l || "proxy-response",
140
- usage: {
141
- inputTokens: (S = c == null ? void 0 : c.prompt_tokens) != null ? S : 0,
142
- outputTokens: (N = c == null ? void 0 : c.completion_tokens) != null ? N : 0,
143
- totalTokens: (L = c == null ? void 0 : c.total_tokens) != null ? L : 0,
144
- inputTokensDetails: {},
145
- outputTokensDetails: {}
146
- },
147
- output: u
148
- }
149
- };
150
- }
151
- }
152
- function tt(t) {
153
- const e = [];
154
- if (t.systemInstructions && e.push({ role: "system", content: t.systemInstructions }), typeof t.input == "string")
155
- e.push({ role: "user", content: t.input });
156
- else
157
- for (const r of t.input) {
158
- const s = Mt(r);
159
- s && e.push(s);
160
- }
161
- const a = t.tools.length ? t.tools.filter((r) => r.type === "function").map((r) => {
162
- const s = r;
163
- return {
164
- type: "function",
165
- function: {
166
- name: s.name,
167
- description: s.description,
168
- parameters: Jt(s.parameters)
169
- }
170
- };
171
- }) : void 0, o = a != null && a.length ? void 0 : Et(t.outputType);
172
- return { messages: e, tools: a, responseFormat: o };
173
- }
174
- function Et(t) {
175
- return t && typeof t == "object" && t.type === "json_schema" ? {
176
- type: "json_schema",
177
- json_schema: {
178
- name: t.name,
179
- strict: t.strict,
180
- schema: t.schema
181
- }
182
- } : { type: "json_object" };
183
- }
184
- function Mt(t) {
185
- if (t.type === "function_call")
186
- return {
187
- role: "assistant",
188
- content: null,
189
- tool_calls: [{
190
- id: t.callId,
191
- type: "function",
192
- function: { name: t.name, arguments: t.arguments }
193
- }]
194
- };
195
- if (t.type === "function_call_result")
196
- return { role: "tool", tool_call_id: t.callId, content: X(t.output) };
197
- if (t.role === "user" || t.role === "assistant" || t.role === "system" || t.type === "message")
198
- return { role: t.role, content: X(t.content) };
199
- }
200
- function X(t) {
201
- return t == null ? "" : typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => X(e)).join("") : typeof t == "object" ? typeof t.text == "string" ? t.text : typeof t.output == "string" ? t.output : typeof t.error == "string" ? t.error : JSON.stringify(t) : String(t);
202
- }
203
- function Jt(t) {
204
- if (!t || typeof t != "object")
205
- return t;
206
- const { $schema: e, ...a } = t;
207
- return a;
208
- }
209
- async function Ft(t) {
210
- var s, l, c, m, d, f;
211
- let e = "", a;
212
- const o = [], r = [];
213
- for await (const u of t) {
214
- u.id && (e = u.id), u.usage && (a = u.usage);
215
- const y = (l = (s = u.choices) == null ? void 0 : s[0]) == null ? void 0 : l.delta;
216
- if (y) {
217
- y.content && o.push(y.content);
218
- for (const x of (c = y.tool_calls) != null ? c : []) {
219
- const k = (m = x.index) != null ? m : 0;
220
- r[k] || (r[k] = { id: "", callId: "", name: "", arguments: "" }), x.id && (r[k].callId = x.id), (d = x.function) != null && d.name && (r[k].name += x.function.name), (f = x.function) != null && f.arguments && (r[k].arguments += x.function.arguments);
221
- }
222
- }
223
- }
224
- return { responseId: e, usage: a, text: o, functionCalls: r };
225
- }
226
- function et(t, e, a) {
227
- const o = [];
228
- e && o.push({
229
- id: t,
230
- type: "message",
231
- role: "assistant",
232
- status: "completed",
233
- content: [{ type: "output_text", text: e }]
234
- });
235
- for (const r of a.filter(Boolean))
236
- o.push({
237
- id: t,
238
- type: "function_call",
239
- callId: r.callId || t,
240
- name: r.name,
241
- arguments: r.arguments,
242
- status: "completed"
243
- });
244
- return o;
245
- }
246
- function it(t, e, a = {}) {
247
- return ot(t, e, {
248
- context: a.context,
249
- session: a.session,
250
- maxTurns: a.maxTurns
251
- });
252
- }
253
- async function V(t, e, a = {}) {
254
- return ot(t, e, {
255
- context: a.context,
256
- session: a.session,
257
- maxTurns: a.maxTurns,
258
- stream: !0
259
- });
260
- }
261
- const Dt = `
262
- 你是业务能力调用 Agent,用于开放式业务能力调用。
263
-
264
- 输入:用户输入、可用业务能力列表、当前上下文。
265
-
266
- 用户输入通常对应某个业务能力,你的职责是直接调用最相关的能力,而不是只做文字说明:
267
- 1. 优先根据用户输入选择并调用一个业务能力。
268
- 2. 根据该能力的描述与入参 schema 构造参数。
269
- 3. 除非确实没有任何能力相关,否则必须调用工具获取真实结果。
270
- `;
271
- function Lt(t) {
272
- return new J({
273
- name: "capability",
274
- model: F(),
275
- handoffDescription: "开放式业务能力调用:选择业务能力并构造参数。",
276
- instructions: Dt,
277
- tools: t.capabilities.map(B)
278
- });
279
- }
280
- const Ut = `
281
- 你是编辑器操作 Agent,负责对当前页面组件进行增删改移。
282
-
283
- 核心输入:
284
- - 用户输入
285
- - 当前编辑器状态(页面组件树、可选组件列表)
286
- - 可用业务能力
287
-
288
- 只输出一个 JSON 对象:{ "edits": [ ... ] },不要输出任何其它文字。
289
-
290
- edits 是数组,每个元素是一个编辑动作:
291
- - { "type": "add-component", "widget": "组件类型", "items": [...] }
292
- - { "type": "delete-component", "target": "要删除的组件" }
293
- - { "type": "update-component", "target": "要修改的组件", "changes": { ... } }
294
- - { "type": "move-component", "target": "要移动的组件", "before": "排在其前的组件", "after": "排在其后的组件" }
295
-
296
- 规则:
297
- 1. target / before / after 优先使用当前编辑器状态里能唯一定位的描述。
298
- 2. 只有当需要外部业务数据时才调用业务能力。
299
- 3. 如果用户输入无法映射为明确的编辑动作,输出 { "edits": [] }。
300
- `;
301
- function Pt(t) {
302
- return new J({
303
- name: "edit",
304
- model: F(),
305
- handoffDescription: "编辑当前页面:对组件执行增删改移等操作。",
306
- instructions: Ut,
307
- tools: t.capabilities.map(B)
308
- });
309
- }
310
- const Ye = g.object({
311
- flow: g.enum(["initialize", "edit", "capability"])
312
- }), Bt = `
313
- 你是顶层流程路由 Agent(Flow Agent)。
314
-
315
- 你的唯一职责是判断用户输入应该进入哪一种执行模式:
316
- - initialize:用户希望根据输入初始化 / 生成一个页面。输入可能是业务配置、业务数据或文档,进入业务侧 Workflow。
317
- - edit:用户希望修改当前编辑器里已有的页面内容。进入编辑器提供的 Edit Agent。
318
- - capability:用户输入是独立业务操作(例如查询、检查等),不涉及生成或修改页面。
319
-
320
- 结合下方“可用业务流程”和“可用业务能力”的描述来判断,不要执行具体业务流程,不要调用工具,不要编造数据。
321
-
322
- 只输出一个 JSON 对象,不要输出任何其它文字:
323
- { "flow": "initialize" | "edit" | "capability" }
324
- `;
325
- function Wt(t) {
326
- const e = t.workflows.map((r) => {
327
- var s;
328
- return `- ${r.name}:${(s = r.description) != null ? s : "无描述"}`;
329
- }).join(`
330
- `), a = t.capabilities.map((r) => `- ${r.name}:${r.description}`).join(`
331
- `), o = [
332
- "当前可用业务流程:",
333
- e || "(无)",
334
- "",
335
- "当前可用业务能力:",
336
- a || "(无)"
337
- ].join(`
338
- `);
339
- return new J({
340
- name: "flow",
341
- model: F(),
342
- handoffDescription: "判断用户输入应进入初始化、编辑还是能力调用。",
343
- instructions: `${Bt}
344
-
345
- ${o}`
346
- });
347
- }
348
- async function He(t) {
349
- var o;
350
- const e = new J({
351
- name: "structured-extract",
352
- model: F(),
353
- instructions: Kt(t)
354
- }), a = await it(e, t.input);
355
- return W(String((o = a.finalOutput) != null ? o : ""));
356
- }
357
- function Kt(t) {
358
- const e = Vt(t.schema);
359
- return [
360
- t.instructions,
361
- e ? `输出 JSON,结构示例(值请替换为真实数据):
362
- ${e}` : "",
363
- "只输出 JSON,不要输出任何其它文字。"
364
- ].filter(Boolean).join(`
365
-
366
- `);
367
- }
368
- function Vt(t) {
369
- var e;
370
- try {
371
- const a = (e = t.toJSONSchema) == null ? void 0 : e.call(t);
372
- return a ? JSON.stringify(Z(a)) : "";
373
- } catch (a) {
374
- return "";
375
- }
376
- }
377
- function Z(t) {
378
- var a;
379
- if (!t || typeof t != "object")
380
- return "字符串";
381
- let e = t.type;
382
- if (Array.isArray(e) && (e = e[0]), t.enum)
383
- return t.enum[0];
384
- if (e === "object") {
385
- const o = {};
386
- for (const [r, s] of Object.entries((a = t.properties) != null ? a : {}))
387
- o[r] = Z(s);
388
- return o;
389
- }
390
- return e === "array" ? [Z(t.items)] : e === "number" || e === "integer" ? 0 : e === "boolean" ? !0 : "字符串";
391
- }
392
- function W(t) {
393
- if (!t)
394
- return;
395
- const e = t.trim();
396
- try {
397
- return JSON.parse(e);
398
- } catch (a) {
399
- const o = e.match(/[\[{][\s\S]*[\]}]/);
400
- if (o)
401
- try {
402
- return JSON.parse(o[0]);
403
- } catch (r) {
404
- return t;
405
- }
406
- return t;
407
- }
408
- }
409
- const Yt = `
410
- 你是布局 IR 生成器。根据标准化元素和可用组件生成 Layout IR。
411
-
412
- 输入:
413
- - elements: [{ "kind": "分类", "items": [{ "name": "元素名", "id": 元素在该分类下的序号 }] }]
414
- - widgets: [{ "typeId", "description", "layout" }]
415
-
416
- 只输出一个 JSON 对象:
417
- { "layout": [{ "widget": "组件 typeId", "items": [{ "category": "元素的 kind", "id": 元素的 id }] }] }
418
-
419
- 硬性要求:
420
- 1. 必须覆盖 elements 中的所有元素,不得遗漏、合并或编造。
421
- 2. category 取元素的 kind,id 取元素自身的 id,一一对应。
422
- 3. 组件 typeId 必须从 widgets 里原样选取。
423
- 4. 少量元素优先低密度、大面积、一个元素一个组件;元素较多时才考虑高密度组件分组。
424
- `;
425
- function Ht() {
426
- return new J({
427
- name: "layout",
428
- model: F(),
429
- handoffDescription: "根据标准化元素与可用组件生成 Layout IR。",
430
- instructions: Yt
431
- });
432
- }
433
- async function Xt(t) {
434
- var s;
435
- const e = Ht(), a = JSON.stringify({ elements: t.elements, widgets: t.widgets }), o = await it(e, a), r = W(String((s = o.finalOutput) != null ? s : ""));
436
- return Array.isArray(r == null ? void 0 : r.layout) ? r.layout : [];
437
- }
438
- function Xe(t) {
439
- return {
440
- kind: "workflow",
441
- ...t
442
- };
443
- }
444
- class Zt {
445
- async run(e, a, o = {}) {
446
- var m, d, f;
447
- const r = [], s = { ...(m = o.state) != null ? m : {} }, l = (u) => {
448
- var y;
449
- r.push(u), (y = o.onEvent) == null || y.call(o, u);
450
- };
451
- l({ type: "workflow-start", workflow: e.name });
452
- let c = a;
453
- for (let u = (d = o.resumeFrom) != null ? d : 0; u < e.steps.length; u++) {
454
- if ((f = o.signal) != null && f.aborted)
455
- return l({ type: "workflow-abort", workflow: e.name }), { workflow: e.name, status: "aborted", state: s, logs: r };
456
- const y = e.steps[u];
457
- l({ type: "step-start", workflow: e.name, step: y.name, index: u });
458
- const x = {
459
- input: c,
460
- state: s,
461
- signal: o.signal,
462
- onEvent: o.onEvent,
463
- onApproval: o.onApproval
464
- };
465
- try {
466
- const k = await this.executeStep(y, x, l, e.name, u, o.signal);
467
- c = Gt(k), s[y.name] = c, l({ type: "step-complete", workflow: e.name, step: y.name, index: u, output: c });
468
- } catch (k) {
469
- const j = at(k);
470
- return l({ type: "step-error", workflow: e.name, step: y.name, index: u, error: j }), { workflow: e.name, status: "failed", state: s, error: j, logs: r };
471
- }
472
- }
473
- return l({ type: "workflow-complete", workflow: e.name, output: c }), { workflow: e.name, status: "completed", state: s, output: c, logs: r };
474
- }
475
- async executeStep(e, a, o, r, s, l) {
476
- var d;
477
- const c = Math.max(1, ((d = e.retry) != null ? d : 0) + 1);
478
- let m;
479
- for (let f = 1; f <= c; f++) {
480
- if (l != null && l.aborted)
481
- throw new DOMException("aborted", "AbortError");
482
- try {
483
- return await e.execute(a);
484
- } catch (u) {
485
- m = u, f < c && o({
486
- type: "step-retry",
487
- workflow: r,
488
- step: e.name,
489
- index: s,
490
- attempt: f,
491
- error: at(u)
492
- });
493
- }
494
- }
495
- throw m;
496
- }
497
- }
498
- function Gt(t) {
499
- return t && typeof t == "object" && "output" in t ? t.output : t;
500
- }
501
- function at(t) {
502
- return t instanceof Error ? t.message : String(t);
503
- }
504
- const Y = 8;
505
- class Qt {
506
- constructor(e = {}) {
507
- var a, o;
508
- this.capabilities = (a = e.capabilities) != null ? a : [], this.workflows = (o = e.workflows) != null ? o : [], this.options = e, this.flowAgent = Wt({ workflows: this.workflows, capabilities: this.capabilities }), this.editAgent = Pt({ capabilities: this.capabilities }), this.capabilityAgent = Lt({ capabilities: this.capabilities }), this.workflowRuntime = new Zt(), this.flowSession = new jt();
509
- }
510
- async run(e, a = {}) {
511
- var c, m, d, f;
512
- const o = {
513
- state: (d = (m = (c = this.options).context) == null ? void 0 : m.call(c)) != null ? d : {},
514
- onApproval: a.onApproval
515
- }, r = await V(this.flowAgent, e, {
516
- session: this.flowSession,
517
- context: o,
518
- maxTurns: Y
519
- });
520
- for await (const u of r) {
521
- const y = H(u);
522
- y && ((f = a.onEvent) == null || f.call(a, y));
523
- }
524
- const s = te(r.finalOutput, {
525
- hasWorkflow: this.workflows.length > 0,
526
- hasCapabilities: this.capabilities.length > 0
527
- }), l = e;
528
- return s.flow === "initialize" ? this.runInitialize(l, o, a) : s.flow === "edit" ? this.runEdit(l, o, a) : this.runCapability(l, o, a);
529
- }
530
- async reset() {
531
- await this.flowSession.clearSession();
532
- }
533
- async runInitialize(e, a, o) {
534
- var m, d, f, u;
535
- const r = (m = this.workflows.find((y) => y.name === "initialize")) != null ? m : this.workflows[0];
536
- if (!r)
537
- return { flow: "initialize", text: "没有注册初始化流程。" };
538
- const s = await this.workflowRuntime.run(r, e, {
539
- state: { ...a.state },
540
- onEvent: (y) => {
541
- var x;
542
- return (x = o.onEvent) == null ? void 0 : x.call(o, y);
543
- },
544
- onApproval: o.onApproval
545
- });
546
- if (s.status !== "completed")
547
- return { flow: "initialize", text: (d = s.error) != null ? d : "初始化流程未完成。", workflow: s };
548
- const l = (f = a.state.widgets) != null ? f : [];
549
- return { flow: "initialize", layout: this.options.extractLayout ? this.options.extractLayout(s.output) : await Xt({ elements: (u = s.output) != null ? u : [], widgets: l }), workflow: s };
550
- }
551
- async runEdit(e, a, o) {
552
- var m, d;
553
- const r = [
554
- `用户输入:${e}`,
555
- `当前编辑器状态:${JSON.stringify(a.state, null, 2)}`
556
- ].join(`
557
-
558
- `), s = await V(this.editAgent, r, {
559
- context: a,
560
- maxTurns: Y
561
- });
562
- for await (const f of s) {
563
- const u = H(f);
564
- u && ((m = o.onEvent) == null || m.call(o, u));
565
- }
566
- const l = W(String((d = s.finalOutput) != null ? d : "")), c = Array.isArray(l == null ? void 0 : l.edits) ? l.edits : [];
567
- return { flow: "edit", text: JSON.stringify(c), edits: c };
568
- }
569
- async runCapability(e, a, o) {
570
- var c, m;
571
- const r = [
572
- `用户输入:${e}`
573
- ].join(`
574
-
575
- `), s = await V(this.capabilityAgent, r, {
576
- context: a,
577
- maxTurns: Y
578
- });
579
- for await (const d of s) {
580
- const f = H(d);
581
- f && ((c = o.onEvent) == null || c.call(o, f));
582
- }
583
- const l = ee(s);
584
- return {
585
- flow: "capability",
586
- text: String((m = s.finalOutput) != null ? m : ""),
587
- capability: l ? { name: l.name, result: l.output } : void 0
588
- };
589
- }
590
- }
591
- function qt(t = {}) {
592
- return new Qt(t);
593
- }
594
- function te(t, e) {
595
- const a = typeof t == "string" ? t : JSON.stringify(t != null ? t : ""), o = W(a);
596
- if (o && typeof o == "object") {
597
- const r = o;
598
- if (r.flow === "initialize" || r.flow === "edit" || r.flow === "capability")
599
- return {
600
- flow: r.flow,
601
- input: typeof r.input == "string" ? r.input : void 0,
602
- note: typeof r.note == "string" ? r.note : void 0
603
- };
604
- }
605
- return e.hasWorkflow && /初始化|生成|创建|搭建|做一个|首页|布局/.test(a) ? { flow: "initialize" } : /删除|修改|移动|更新|添加|插入|调整|编辑|换|去掉|移除/.test(a) ? { flow: "edit" } : e.hasCapabilities ? { flow: "capability" } : { flow: "edit" };
606
- }
607
- function H(t) {
608
- var e, a, o, r;
609
- if (t.type === "raw_model_stream_event") {
610
- const s = t.data;
611
- return (s == null ? void 0 : s.type) === "output_text_delta" ? { type: "text-delta", text: s.delta } : void 0;
612
- }
613
- if (t.type === "run_item_stream_event") {
614
- if (t.name === "tool_called") {
615
- const s = (e = t.item.rawItem) != null ? e : {};
616
- return { type: "tool-call", callId: (a = s.callId) != null ? a : s.id, name: s.name, args: ae(s.arguments) };
617
- }
618
- if (t.name === "tool_output") {
619
- const s = t.item;
620
- return { type: "tool-result", callId: (o = s.rawItem) == null ? void 0 : o.callId, name: (r = s.rawItem) == null ? void 0 : r.name, result: s.output };
621
- }
622
- return;
623
- }
624
- if (t.type === "agent_updated_stream_event")
625
- return { type: "agent-updated", agent: t.agent.name };
626
- }
627
- function ee(t) {
628
- var a, o, r;
629
- const e = [];
630
- for (const s of (a = t.newItems) != null ? a : [])
631
- if (s.type === "tool_call_item") {
632
- const l = (o = s.rawItem) != null ? o : {};
633
- e.push({ name: (r = l.name) != null ? r : "", output: void 0 });
634
- } else if (s.type === "tool_call_output_item") {
635
- const l = e[e.length - 1];
636
- l && (l.output = s.output);
637
- }
638
- return e.find((s) => s.name);
639
- }
640
- function ae(t) {
641
- if (!t)
642
- return {};
643
- try {
644
- return JSON.parse(t);
645
- } catch (e) {
646
- return t;
647
- }
648
- }
649
- const ne = { class: "thread" }, oe = { class: "thread__header" }, re = { class: "thread__status" }, se = {
650
- key: 0,
651
- class: "thread__empty"
652
- }, ie = {
653
- key: 0,
654
- class: "message__step"
655
- }, le = {
656
- key: 1,
657
- class: "message__text"
658
- }, ce = {
659
- key: 0,
660
- class: "message__action-result"
661
- }, pe = { class: "flow__head" }, ue = { class: "flow__name" }, de = {
662
- key: 0,
663
- class: "flow__status flow__status--pending"
664
- }, fe = {
665
- key: 1,
666
- class: "flow__status"
667
- }, me = { class: "flow__row" }, ge = { class: "flow__code" }, ye = { class: "flow__row" }, _e = { class: "flow__code" }, we = {
668
- key: 0,
669
- class: "message__action-result"
670
- }, xe = {
671
- key: 1,
672
- class: "message__action-result message__action-result--pending"
673
- }, be = {
674
- key: 5,
675
- class: "message__raw"
676
- }, he = {
677
- key: 0,
678
- class: "thread__suggestions"
679
- }, ve = ["onClick"], ke = { key: 0 }, Se = {
680
- key: 1,
681
- class: "approval"
682
- }, Ae = { class: "approval__text" }, Ie = { class: "composer" }, Ce = ["disabled"], je = /* @__PURE__ */ nt({
683
- __name: "AssistantThread",
684
- props: {
685
- capabilities: { type: Array },
686
- workflows: { type: Array },
687
- context: { type: Function }
688
- },
689
- emits: ["init", "edit", "capability"],
690
- setup(t, { emit: e }) {
691
- const a = t, o = e;
692
- function r() {
693
- var n, i;
694
- return qt({
695
- capabilities: (n = a.capabilities) != null ? n : [],
696
- workflows: (i = a.workflows) != null ? i : [],
697
- context: () => {
698
- var w, p;
699
- return (p = (w = a.context) == null ? void 0 : w.call(a)) != null ? p : {};
700
- }
701
- });
702
- }
703
- const s = xt(r());
704
- q(
705
- () => [a.capabilities, a.workflows],
706
- () => {
707
- s.value = r();
708
- }
709
- );
710
- const l = C([]), c = C(!1), m = C(""), d = C(null), f = C([
711
- { title: "初始化页面", label: "initialize", prompt: "根据下面的配置生成一个页面" },
712
- { title: "修改页面", label: "edit", prompt: "删除页面里的一个组件" },
713
- { title: "业务能力", label: "capability", prompt: "查询一下某个数据的状态" }
714
- ]), u = C(null), y = bt(() => {
715
- var n, i;
716
- return (i = (n = u.value) == null ? void 0 : n.message) != null ? i : "";
717
- });
718
- let x = null;
719
- const k = (n) => {
720
- if (x) {
721
- const i = x;
722
- x = null, i(!1);
723
- }
724
- return u.value = n, new Promise((i) => {
725
- x = i;
726
- });
727
- };
728
- function j() {
729
- const n = x;
730
- x = null, u.value = null, n == null || n(!0);
731
- }
732
- function D() {
733
- const n = x;
734
- x = null, u.value = null, n == null || n(!1);
735
- }
736
- let T = null, S = null;
737
- const N = /* @__PURE__ */ new Map();
738
- function L(n) {
739
- var w;
740
- const i = T;
741
- if (i)
742
- switch (n.type) {
743
- case "text-delta":
744
- S || (S = { type: "text", text: "" }, i.parts.push(S)), S.text += n.text;
745
- break;
746
- case "agent-updated":
747
- S = null, i.parts.push({ type: "step", label: `Agent:${n.agent}` });
748
- break;
749
- case "tool-call":
750
- S = null, i.parts.push({
751
- type: "tool-call",
752
- call: { callId: n.callId, name: n.name, args: n.args }
753
- }), N.set(
754
- n.callId,
755
- i.parts[i.parts.length - 1]
756
- );
757
- break;
758
- case "tool-result": {
759
- const p = N.get(n.callId);
760
- p && (p.result = {
761
- ...gt(n),
762
- raw: (w = n.error) != null ? w : n.result
763
- });
764
- break;
765
- }
766
- case "workflow-start":
767
- S = null, i.parts.push({ type: "step", label: `开始流程:${n.workflow}` });
768
- break;
769
- case "step-start":
770
- S = null, i.parts.push({ type: "step", label: `步骤 ${n.index + 1}:${n.step}` });
771
- break;
772
- case "step-complete":
773
- break;
774
- case "step-retry":
775
- i.parts.push({ type: "text", text: `⚠️ ${n.step} 第 ${n.attempt} 次重试:${n.error}` });
776
- break;
777
- case "step-error":
778
- i.parts.push({ type: "text", text: `✕ ${n.step} 执行失败:${n.error}` });
779
- break;
780
- case "workflow-complete":
781
- i.parts.push({ type: "step", label: "流程完成" });
782
- break;
783
- case "workflow-abort":
784
- i.parts.push({ type: "text", text: "流程已中断" });
785
- break;
786
- }
787
- }
788
- async function O(n) {
789
- var w;
790
- l.value.push({
791
- id: I(),
792
- role: "user",
793
- parts: [{ type: "text", text: n }]
794
- });
795
- const i = St({
796
- id: I(),
797
- role: "copilot",
798
- parts: []
799
- });
800
- l.value.push(i), T = i, S = null, N.clear(), c.value = !0;
801
- try {
802
- const p = await s.value.run(n, {
803
- onEvent: L,
804
- onApproval: k
805
- });
806
- p.flow === "initialize" && p.layout ? o("init", { layout: p.layout }) : p.flow === "edit" ? o("edit", { edits: (w = p.edits) != null ? w : [] }) : p.flow === "capability" && p.capability && o("capability", p.capability);
807
- } catch (p) {
808
- i.parts.push({ type: "text", text: `⚠️ ${yt(p)}` });
809
- } finally {
810
- c.value = !1, T = null, S = null;
811
- }
812
- }
813
- q(
814
- l,
815
- () => {
816
- ht(() => {
817
- const n = d.value;
818
- n && (n.scrollTop = n.scrollHeight);
819
- });
820
- },
821
- { deep: !0 }
822
- );
823
- function I() {
824
- return Math.random().toString(36).slice(2, 10);
825
- }
826
- function A() {
827
- const n = m.value.trim();
828
- !n || c.value || (O(n), m.value = "");
829
- }
830
- function z(n) {
831
- c.value || (m.value = n, A());
832
- }
833
- function ct(n) {
834
- n.key === "Enter" && !n.shiftKey && (n.preventDefault(), A());
835
- }
836
- function pt(n) {
837
- const i = n;
838
- return i != null && i.capability ? `${i.capability}(${_t(i.args)})` : JSON.stringify(n);
839
- }
840
- function ut(n) {
841
- return n.message || `是否执行工具 ${n.name}?`;
842
- }
843
- function dt(n) {
844
- var i;
845
- return (i = n == null ? void 0 : n.name) != null ? i : "";
846
- }
847
- function ft(n) {
848
- return n == null ? void 0 : n.args;
849
- }
850
- function G(n) {
851
- return !!(n != null && n.ok);
852
- }
853
- function mt(n) {
854
- var w, p;
855
- const i = n;
856
- return (p = (w = i == null ? void 0 : i.raw) != null ? w : i == null ? void 0 : i.message) != null ? p : n;
857
- }
858
- function Q(n) {
859
- if (n == null)
860
- return "—";
861
- if (typeof n == "string")
862
- return n;
863
- try {
864
- return JSON.stringify(n, null, 2);
865
- } catch (i) {
866
- return String(n);
867
- }
868
- }
869
- function gt(n) {
870
- var w;
871
- if (n.error)
872
- return { ok: !1, message: n.error };
873
- if (typeof n.result == "string")
874
- return { ok: !0, message: n.result };
875
- const i = n.result;
876
- return { ok: !0, message: (w = i == null ? void 0 : i.message) != null ? w : JSON.stringify(n.result) };
877
- }
878
- function yt(n) {
879
- return n instanceof Error ? n.message : String(n);
880
- }
881
- function _t(n) {
882
- if (n === void 0)
883
- return "";
884
- const i = typeof n == "string" ? n : JSON.stringify(n);
885
- return i.length > 72 ? `${i.slice(0, 72)}…` : i;
886
- }
887
- return (n, i) => (h(), b("section", ne, [
888
- _("header", oe, [
889
- _("span", {
890
- class: E(["thread__dot", { "thread__dot--busy": c.value }])
891
- }, null, 2),
892
- i[1] || (i[1] = _("h3", null, "装修助手", -1)),
893
- _("span", re, v(c.value ? "正在生成…" : "在线"), 1)
894
- ]),
895
- _("div", {
896
- ref_key: "viewport",
897
- ref: d,
898
- class: "thread__viewport"
899
- }, [
900
- l.value.length ? $("", !0) : (h(), b("p", se, " 用一句话描述你的需求:初始化页面、修改页面内容,或直接调用业务能力。 ")),
901
- (h(!0), b(U, null, K(l.value, (w) => (h(), b("div", {
902
- key: w.id,
903
- class: E(["message", `message--${w.role}`])
904
- }, [
905
- (h(!0), b(U, null, K(w.parts, (p, wt) => (h(), b(U, { key: wt }, [
906
- p.type === "step" ? (h(), b("div", ie, v(p.label), 1)) : p.type === "text" && p.text ? (h(), b("p", le, v(p.text), 1)) : p.type === "action" ? (h(), b("p", {
907
- key: 2,
908
- class: E(["message__action", { "message__action--failed": p.result && !p.result.ok }])
909
- }, [
910
- _("code", null, v(pt(p.action)), 1),
911
- p.result ? (h(), b("span", ce, v(p.result.ok ? "✓" : "✕") + " " + v(p.result.message), 1)) : $("", !0)
912
- ], 2)) : p.type === "tool-call" ? (h(), b("div", {
913
- key: 3,
914
- class: E(["flow", { "flow--failed": p.result && !G(p.result) }])
915
- }, [
916
- _("div", pe, [
917
- i[2] || (i[2] = _("span", { class: "flow__badge" }, "工具", -1)),
918
- _("code", ue, v(dt(p.call)), 1),
919
- p.result ? (h(), b("span", fe, v(G(p.result) ? "✓ 完成" : "✕ 失败"), 1)) : (h(), b("span", de, "执行中…"))
920
- ]),
921
- _("div", me, [
922
- i[3] || (i[3] = _("span", { class: "flow__label" }, "输入", -1)),
923
- _("pre", ge, v(Q(ft(p.call))), 1)
924
- ]),
925
- _("div", ye, [
926
- i[4] || (i[4] = _("span", { class: "flow__label" }, "输出", -1)),
927
- _("pre", _e, v(p.result ? Q(mt(p.result)) : "等待输出…"), 1)
928
- ])
929
- ], 2)) : p.type === "approval" ? (h(), b("p", {
930
- key: 4,
931
- class: E(["message__action message__approval", { "message__action--failed": p.decision === "rejected" }])
932
- }, [
933
- _("code", null, v(ut(p.call)), 1),
934
- p.decision ? (h(), b("span", we, v(p.decision === "approved" ? "✓ 已同意" : "✕ 已拒绝"), 1)) : (h(), b("span", xe, "等待确认…"))
935
- ], 2)) : p.type === "raw" && p.text ? (h(), b("details", be, [
936
- _("summary", null, "模型原始输出" + v(p.label ? `(${p.label})` : ""), 1),
937
- _("pre", null, v(p.text), 1)
938
- ])) : $("", !0)
939
- ], 64))), 128))
940
- ], 2))), 128))
941
- ], 512),
942
- f.value.length ? (h(), b("div", he, [
943
- (h(!0), b(U, null, K(f.value, (w) => (h(), b("button", {
944
- key: w.prompt,
945
- type: "button",
946
- onClick: (p) => z(w.prompt)
947
- }, [
948
- _("b", null, v(w.title), 1),
949
- w.label ? (h(), b("span", ke, v(w.label), 1)) : $("", !0)
950
- ], 8, ve))), 128))
951
- ])) : $("", !0),
952
- u.value ? (h(), b("div", Se, [
953
- _("p", Ae, v(y.value), 1),
954
- _("div", { class: "approval__actions" }, [
955
- _("button", {
956
- type: "button",
957
- class: "approval__reject",
958
- onClick: D
959
- }, "不同意"),
960
- _("button", {
961
- type: "button",
962
- class: "approval__approve",
963
- onClick: j
964
- }, "同意")
965
- ])
966
- ])) : $("", !0),
967
- _("div", Ie, [
968
- vt(_("textarea", {
969
- "onUpdate:modelValue": i[0] || (i[0] = (w) => m.value = w),
970
- rows: "2",
971
- placeholder: "描述你的需求,例如:生成一个页面、删除一个组件、查询一个数据",
972
- onKeydown: ct
973
- }, null, 544), [
974
- [kt, m.value]
975
- ]),
976
- _("button", {
977
- type: "button",
978
- disabled: c.value || !m.value.trim(),
979
- onClick: A
980
- }, "发送", 8, Ce)
981
- ])
982
- ]));
983
- }
984
- }), Oe = '.thread[data-v-4687dca0]{display:flex;flex-direction:column;height:100%;min-height:520px;box-sizing:border-box;padding:18px 20px;background:#fff;border:1px solid #e5e7eb;border-radius:16px}.thread__header[data-v-4687dca0]{display:flex;align-items:center;gap:8px;padding-bottom:12px;border-bottom:1px solid #f3f4f6}.thread__header h3[data-v-4687dca0]{margin:0;font-size:15px}.thread__status[data-v-4687dca0]{margin-left:auto;font-size:12px;color:#9ca3af}.thread__dot[data-v-4687dca0]{width:8px;height:8px;border-radius:50%;background:#10b981}.thread__dot--busy[data-v-4687dca0]{background:#f59e0b}.thread__viewport[data-v-4687dca0]{flex:1;overflow-y:auto;padding:14px 2px;display:flex;flex-direction:column;gap:10px}.thread__empty[data-v-4687dca0]{margin:auto 0;color:#9ca3af;font-size:13px;line-height:1.7;text-align:center}.thread__error[data-v-4687dca0]{margin:0;padding:8px 10px;border-radius:10px;background:#fef2f2;color:#b91c1c;font-size:12.5px}.message[data-v-4687dca0]{display:flex;flex-direction:column;gap:6px;max-width:90%}.message--user[data-v-4687dca0]{align-self:flex-end;align-items:flex-end}.message--assistant[data-v-4687dca0]{align-self:flex-start;align-items:flex-start}.message__text[data-v-4687dca0]{margin:0;padding:9px 12px;border-radius:12px;font-size:13.5px;line-height:1.65;white-space:pre-wrap;overflow-wrap:anywhere;background:#f3f4f6;color:#1f2937}.message--user .message__text[data-v-4687dca0]{background:#4f46e5;color:#fff}.message__step[data-v-4687dca0]{display:flex;align-items:center;gap:8px;font-size:11px;font-weight:600;letter-spacing:.02em;color:#94a3b8}.message__step[data-v-4687dca0]:after{content:"";flex:1;height:1px;background:#eef2f7}.message__action[data-v-4687dca0]{display:flex;flex-direction:column;gap:2px;margin:0;padding:7px 10px;border-radius:10px;border:1px solid #dbeafe;background:#f8faff;font-size:12px;overflow-wrap:anywhere}.message__action code[data-v-4687dca0]{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:600;color:#2563eb}.message__action-result[data-v-4687dca0]{color:#059669}.message__action--failed[data-v-4687dca0]{border-color:#fecaca;background:#fef2f2}.message__action--failed .message__action-result[data-v-4687dca0]{color:#b91c1c}.message__action-result--pending[data-v-4687dca0]{color:#b45309}.message__approval[data-v-4687dca0]{border-color:#fde68a;background:#fffbeb}.message__approval code[data-v-4687dca0]{color:#b45309}.flow[data-v-4687dca0]{display:flex;flex-direction:column;gap:6px;margin:2px 0;padding:8px 10px;border-radius:10px;border:1px solid #e9d5ff;background:#faf5ff;font-size:12px}.flow--failed[data-v-4687dca0]{border-color:#fecaca;background:#fef2f2}.flow__head[data-v-4687dca0]{display:flex;align-items:center;gap:6px}.flow__badge[data-v-4687dca0]{padding:1px 6px;border-radius:6px;background:#ede9fe;color:#7c3aed;font-size:11px;font-weight:600}.flow__name[data-v-4687dca0]{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:600;color:#6d28d9}.flow__status[data-v-4687dca0]{margin-left:auto;color:#059669}.flow--failed .flow__status[data-v-4687dca0]{color:#b91c1c}.flow__status--pending[data-v-4687dca0]{color:#b45309}.flow__row[data-v-4687dca0]{display:flex;gap:8px}.flow__label[data-v-4687dca0]{flex-shrink:0;width:28px;color:#9ca3af;line-height:1.6}.flow__code[data-v-4687dca0]{flex:1;margin:0;padding:6px 8px;border-radius:8px;background:#111827;color:#d1fae5;font-size:11.5px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere;overflow:auto;max-height:220px}.message__raw[data-v-4687dca0]{font-size:12px;color:#6b7280}.message__raw summary[data-v-4687dca0]{cursor:pointer}.message__raw pre[data-v-4687dca0]{margin:6px 0 0;padding:10px;border-radius:10px;background:#111827;color:#d1fae5;font-size:11.5px;line-height:1.6;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere}.thread__suggestions[data-v-4687dca0]{display:flex;flex-wrap:wrap;gap:6px;padding:10px 0;border-top:1px solid #f3f4f6}.thread__suggestions button[data-v-4687dca0]{border:1px solid #e5e7eb;background:#fafafa;color:#4b5563;border-radius:999px;padding:5px 10px;font-size:12px;cursor:pointer}.thread__suggestions button[data-v-4687dca0]:hover{border-color:#c7d2fe;color:#4338ca}.approval[data-v-4687dca0]{margin-top:10px;padding:10px 12px;border-radius:12px;border:1px solid #fde68a;background:#fffbeb;display:flex;flex-direction:column;gap:8px}.approval__text[data-v-4687dca0]{margin:0;font-size:13px;line-height:1.6;color:#92400e}.approval__actions[data-v-4687dca0]{display:flex;justify-content:flex-end;gap:8px}.approval__actions button[data-v-4687dca0]{padding:6px 14px;border-radius:8px;border:1px solid transparent;font:inherit;font-size:13px;font-weight:600;cursor:pointer}.approval__reject[data-v-4687dca0]{background:#fff;border-color:#fcd34d;color:#92400e}.approval__approve[data-v-4687dca0]{background:#f59e0b;color:#fff}.composer[data-v-4687dca0]{display:flex;gap:8px;align-items:flex-end}.composer textarea[data-v-4687dca0]{flex:1;resize:none;padding:9px 11px;border:1px solid #d1d5db;border-radius:10px;font:inherit;font-size:13.5px;outline:none}.composer textarea[data-v-4687dca0]:focus{border-color:#6366f1;box-shadow:0 0 0 3px #6366f126}.composer button[data-v-4687dca0]{padding:9px 16px;border:none;border-radius:10px;background:#4f46e5;color:#fff;font:inherit;font-size:13.5px;font-weight:600;cursor:pointer}.composer button[data-v-4687dca0]:disabled{background:#c7d2fe;cursor:not-allowed}', lt = (t, e) => {
985
- const a = t.__vccOpts || t;
986
- for (const [o, r] of e)
987
- a[o] = r;
988
- return a;
989
- }, ze = /* @__PURE__ */ lt(je, [["styles", [Oe]], ["__scopeId", "data-v-4687dca0"]]), $e = { class: "assistant-root" }, Re = {
990
- key: 0,
991
- class: "assistant-panel"
992
- }, Te = /* @__PURE__ */ nt({
993
- __name: "Copilot",
994
- props: {
995
- capabilities: { type: Array },
996
- workflows: { type: Array },
997
- context: { type: Function }
998
- },
999
- emits: ["init", "edit", "capability"],
1000
- setup(t, { emit: e }) {
1001
- const a = t, o = e, r = C(!1), s = C(!1);
1002
- function l(d) {
1003
- o("init", d);
1004
- }
1005
- function c(d) {
1006
- o("edit", d);
1007
- }
1008
- function m(d) {
1009
- o("capability", d);
1010
- }
1011
- return (d, f) => (h(), b("div", $e, [
1012
- r.value ? (h(), b("section", Re, [
1013
- At(ze, {
1014
- capabilities: a.capabilities,
1015
- workflows: a.workflows,
1016
- context: a.context,
1017
- onInit: l,
1018
- onEdit: c,
1019
- onCapability: m
1020
- }, null, 8, ["capabilities", "workflows", "context"])
1021
- ])) : $("", !0),
1022
- _("button", {
1023
- class: "assistant-button",
1024
- type: "button",
1025
- onClick: f[0] || (f[0] = (u) => r.value = !r.value)
1026
- }, [
1027
- f[1] || (f[1] = _("span", null, "装修助手", -1)),
1028
- _("span", {
1029
- class: E(["dot", { ok: s.value }])
1030
- }, null, 2)
1031
- ])
1032
- ]));
1033
- }
1034
- }), Ne = ".assistant-root[data-v-e6a08530]{position:fixed;top:24px;bottom:24px;right:10px;z-index:20;display:flex;align-items:stretch;gap:12px;justify-content:flex-end}.assistant-button[data-v-e6a08530]{align-self:flex-end;display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:10px 18px;background:#1677ff;color:#fff;border:none;box-shadow:0 8px 20px #1677ff59;cursor:pointer;flex-shrink:0}.assistant-button .dot[data-v-e6a08530]{width:8px;height:8px;border-radius:50%;background:#ffccc7}.assistant-button .dot.ok[data-v-e6a08530]{background:#b7eb8f}.assistant-panel[data-v-e6a08530]{flex-shrink:0;min-height:0;width:400px;display:flex;flex-direction:column;background:#fff;border-radius:14px;box-shadow:0 16px 40px #00000029;overflow:hidden}", Ee = /* @__PURE__ */ lt(Te, [["styles", [Ne]], ["__scopeId", "data-v-e6a08530"]]), M = /* @__PURE__ */ new Map();
1035
- function Ze(t) {
1036
- const e = B(t);
1037
- return M.set(t.name, t), e;
1038
- }
1039
- function Ge(t) {
1040
- return M.delete(t);
1041
- }
1042
- function Qe() {
1043
- return [...M.keys()];
1044
- }
1045
- function Me(t) {
1046
- return t ? t.flatMap((e) => {
1047
- const a = M.get(e);
1048
- return a ? [a] : [];
1049
- }) : [...M.values()];
1050
- }
1051
- function qe(t) {
1052
- return Me(t).map(B);
1053
- }
1054
- function ta() {
1055
- M.clear();
1056
- }
1057
- const ea = g.object({
1058
- layout: g.array(
1059
- g.object({
1060
- widget: g.string().describe("组件类型"),
1061
- items: g.array(
1062
- g.object({
1063
- category: g.string().describe("元素分类"),
1064
- id: g.any().describe("元素索引")
1065
- })
1066
- )
1067
- })
1068
- )
1069
- }), aa = g.object({
1070
- edits: g.array(
1071
- g.discriminatedUnion("type", [
1072
- g.object({
1073
- type: g.literal("add-component"),
1074
- widget: g.string(),
1075
- items: g.array(g.any())
1076
- }),
1077
- g.object({
1078
- type: g.literal("delete-component"),
1079
- target: g.string()
1080
- }),
1081
- g.object({
1082
- type: g.literal("update-component"),
1083
- target: g.string(),
1084
- changes: g.record(g.string(), g.any())
1085
- }),
1086
- g.object({
1087
- type: g.literal("move-component"),
1088
- target: g.string(),
1089
- before: g.string().optional(),
1090
- after: g.string().optional()
1091
- })
1092
- ])
1093
- )
1094
- });
1095
- function na(t) {
1096
- return new J({
1097
- ...t,
1098
- model: F()
1099
- });
1100
- }
1101
- const oa = Ee;
1
+ import { c as t, Y as s, j as i, g as r, R as n, W as o, E as l, l as g, a0 as c, h as u, Z as p, T as d, z as m, Q as y, O as A, V as C, B as b, K as f, L as R, P as M, X as k, m as S, q as h, u as w, F as E, G as I, D as x, N as L, H as T, _ as W, I as v, k as F, v as J, x as N, y as O, $ as j, t as q, J as z } from "./index-CCVZJZ_4.js";
1102
2
  export {
1103
- ia as Agent,
1104
- Qt as AgentRuntime,
1105
- la as MemorySession,
1106
- oa as MpdAgent,
1107
- ca as Runner,
1108
- Zt as WorkflowRuntime,
1109
- ta as clearCapabilities,
1110
- Be as configureModel,
1111
- na as createAgent,
1112
- qt as createAgentRuntime,
1113
- Lt as createCapabilityAgent,
1114
- B as createCapabilityTool,
1115
- Pt as createEditAgent,
1116
- Wt as createFlowAgent,
1117
- Ht as createLayoutAgent,
1118
- Ue as defineCapability,
1119
- Xe as defineWorkflow,
1120
- aa as editIrSchema,
1121
- Ye as flowOutputSchema,
1122
- Xt as generateLayoutIR,
1123
- F as getModel,
1124
- We as getModelConfig,
1125
- Ke as getModelName,
1126
- Me as getRegisteredCapabilities,
1127
- qe as getRegisteredCapabilityTools,
1128
- Pe as invokeCapability,
1129
- ea as layoutIrSchema,
1130
- Qe as listCapabilities,
3
+ t as Agent,
4
+ s as AgentRuntime,
5
+ i as MemorySession,
6
+ r as MpdAgent,
7
+ n as Runner,
8
+ o as WorkflowRuntime,
9
+ l as clearCapabilities,
10
+ g as configureModel,
11
+ c as createAgent,
12
+ u as createAgentElement,
13
+ p as createAgentRuntime,
14
+ d as createCapabilityAgent,
15
+ m as createCapabilityTool,
16
+ y as createEditAgent,
17
+ A as createFlowAgent,
18
+ C as createLayoutAgent,
19
+ b as defineCapability,
20
+ f as defineWorkflow,
21
+ R as editIrSchema,
22
+ M as flowOutputSchema,
23
+ k as generateLayoutIR,
24
+ S as getModel,
25
+ h as getModelConfig,
26
+ w as getModelName,
27
+ E as getRegisteredCapabilities,
28
+ I as getRegisteredCapabilityTools,
29
+ x as invokeCapability,
30
+ L as layoutIrSchema,
31
+ T as listCapabilities,
1131
32
  W as parseJson,
1132
- Ze as registerCapability,
1133
- pa as run,
1134
- it as runAgent,
1135
- V as runAgentStreamed,
1136
- Ve as setMockClient,
1137
- He as structuredExtract,
1138
- ua as tool,
1139
- Ge as unregisterCapability
33
+ v as registerCapability,
34
+ F as run,
35
+ J as runAgent,
36
+ N as runAgentStreamed,
37
+ O as setMockClient,
38
+ j as structuredExtract,
39
+ q as tool,
40
+ z as unregisterCapability
1140
41
  };