@sepveneto/dnde-agent 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SepVeneto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,32 @@
1
+ import type { FunctionTool } from '@openai/agents';
2
+ import { z } from 'zod';
3
+ import type { ToolApprovalHandler } from './context';
4
+ export type CapabilitySchema = z.ZodType;
5
+ export interface CapabilityContext {
6
+ onApproval?: ToolApprovalHandler;
7
+ signal?: AbortSignal;
8
+ state?: Record<string, unknown>;
9
+ }
10
+ export interface ToolApprovalOptions {
11
+ message?: (input: any) => string;
12
+ onApprove?: (input: any) => void;
13
+ onReject?: (input: any) => void;
14
+ }
15
+ export interface CapabilityDefinition<TInput = unknown, TOutput = unknown> {
16
+ name: string;
17
+ description: string;
18
+ inputSchema?: CapabilitySchema;
19
+ outputSchema?: CapabilitySchema;
20
+ needsApproval?: boolean | ((input: TInput) => boolean | Promise<boolean>);
21
+ approval?: ToolApprovalOptions;
22
+ execute(input: TInput, context: CapabilityContext): Promise<TOutput> | TOutput;
23
+ }
24
+ export interface Capability<TInput = unknown, TOutput = unknown> extends CapabilityDefinition<TInput, TOutput> {
25
+ kind: 'capability';
26
+ }
27
+ export declare function defineCapability<TInput, TOutput>(definition: CapabilityDefinition<TInput, TOutput>): Capability<TInput, TOutput>;
28
+ /** Capability -> OpenAI Agents SDK FunctionTool(V2 的 Capability Adapter)。 */
29
+ export declare function createCapabilityTool(capability: Capability<any, any>): FunctionTool<any, any, any>;
30
+ /** 工作流 Step 里直接调用能力时使用,统一处理审批。 */
31
+ export declare function invokeCapability<TInput = unknown, TOutput = unknown>(capability: Capability<TInput, TOutput>, input: TInput, context?: CapabilityContext): Promise<TOutput>;
32
+ //# sourceMappingURL=capability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/agent/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAc,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEhE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,OAAO,CAAA;AAExC,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAA;IAChC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAA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iBAAsB,GAC9B,OAAO,CAAC,OAAO,CAAC,CAMlB"}
@@ -0,0 +1,6 @@
1
+ import { Agent } from '@openai/agents';
2
+ import type { Capability } from './capability';
3
+ export declare function createCapabilityAgent(options: {
4
+ capabilities: Capability<any, any>[];
5
+ }): Agent<any, any>;
6
+ //# sourceMappingURL=capabilityAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilityAgent.d.ts","sourceRoot":"","sources":["../../src/agent/capabilityAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAc9C,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAAE,YAAY,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAQxG"}
@@ -0,0 +1,15 @@
1
+ import type { FunctionTool } from '@openai/agents';
2
+ import type { Capability } from './capability';
3
+ /** 注册业务能力,并返回对应的 Agent Tool(同名覆盖)。 */
4
+ export declare function registerCapability(capability: Capability): FunctionTool;
5
+ /** 取消注册;返回是否真的移除了一个能力。 */
6
+ export declare function unregisterCapability(name: string): boolean;
7
+ /** 当前注册的能力名列表。 */
8
+ export declare function listCapabilities(): string[];
9
+ /** 取出已注册能力;传 `names` 时按给定顺序返回其中存在的能力。 */
10
+ export declare function getRegisteredCapabilities(names?: string[]): Capability[];
11
+ /** 把已注册能力统一包装成 Agent Tool。 */
12
+ export declare function getRegisteredCapabilityTools(names?: string[]): FunctionTool[];
13
+ /** 清空注册表(测试或热更新时用)。 */
14
+ export declare function clearCapabilities(): void;
15
+ //# sourceMappingURL=capabilityRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilityRegistry.d.ts","sourceRoot":"","sources":["../../src/agent/capabilityRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAW9C,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAIvE;AAED,0BAA0B;AAC1B,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,kBAAkB;AAClB,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED,yCAAyC;AACzC,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CASxE;AAED,8BAA8B;AAC9B,wBAAgB,4BAA4B,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,YAAY,EAAE,CAE7E;AAED,uBAAuB;AACvB,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
@@ -0,0 +1,17 @@
1
+ export interface ToolApprovalRequest {
2
+ callId: string;
3
+ name: string;
4
+ args: unknown;
5
+ message: string;
6
+ }
7
+ export type ToolApprovalHandler = (request: ToolApprovalRequest) => boolean | Promise<boolean>;
8
+ /** 平台注入给 Agent / Tool 的运行时上下文。 */
9
+ export interface AppContext {
10
+ /** 运行时共享状态(组件列表、编辑器状态等)。 */
11
+ state: Record<string, unknown>;
12
+ /** 业务侧自己的数据。 */
13
+ business?: unknown;
14
+ onApproval?: ToolApprovalHandler;
15
+ signal?: AbortSignal;
16
+ }
17
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/agent/context.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,mBAAmB,KACzB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/B,kCAAkC;AAClC,MAAM,WAAW,UAAU;IACzB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,mBAAmB,CAAA;IAChC,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB"}
@@ -0,0 +1,30 @@
1
+ import OpenAI from 'openai';
2
+ import type { Agent, Model, RunResult, RunStreamEvent, Session, StreamedRunResult } from '@openai/agents';
3
+ export interface ModelConfig {
4
+ baseURL?: string;
5
+ apiKey?: string;
6
+ model?: string;
7
+ }
8
+ export declare function configureModel(next: ModelConfig): void;
9
+ export declare function getModelConfig(): Required<ModelConfig>;
10
+ export declare function getModelName(): string;
11
+ /** 测试用:注入 mock 的 OpenAI client。 */
12
+ export declare function setMockClient(mock: OpenAI): void;
13
+ /**
14
+ * 返回一个 Agents SDK 的 Model 适配器。
15
+ *
16
+ * 模型接口调用保持原来的方式:直接走 `openai` 的 `chat.completions`(服务器代理 baseURL);
17
+ * Agent Loop / Tool Calling / Session / Context 等其它能力全部由 OpenAI Agents SDK 提供。
18
+ */
19
+ export declare function getModel(): Model;
20
+ export interface RunAgentOptions<TContext = unknown> {
21
+ context?: TContext;
22
+ session?: Session;
23
+ maxTurns?: number | null;
24
+ }
25
+ /** 非流式执行(SDK 内部负责 Agent Loop / Tool Calling / Session)。 */
26
+ export declare function runAgent<TContext, TAgent extends Agent<any, any>>(agent: TAgent, input: string, options?: RunAgentOptions<TContext>): Promise<RunResult<TContext, TAgent>>;
27
+ /** 流式执行,并逐个抛出 SDK 的流式事件。 */
28
+ export declare function runAgentStreamed<TContext, TAgent extends Agent<any, any>>(agent: TAgent, input: string, options?: RunAgentOptions<TContext>): Promise<StreamedRunResult<TContext, TAgent>>;
29
+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SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EAC7E,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAe,CAAC,QAAQ,CAAM,GACtC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAO9C;AAED,YAAY,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { Agent } from '@openai/agents';
2
+ import type { Capability } from './capability';
3
+ export declare function createEditAgent(options: {
4
+ capabilities: Capability<any, any>[];
5
+ }): Agent<any, any>;
6
+ //# sourceMappingURL=editAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editAgent.d.ts","sourceRoot":"","sources":["../../src/agent/editAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAyB9C,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,YAAY,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAQlG"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export interface StructuredExtractOptions {
3
+ instructions: string;
4
+ schema: z.ZodType;
5
+ input: string;
6
+ }
7
+ export declare function structuredExtract(options: StructuredExtractOptions): Promise<unknown>;
8
+ export declare function parseJson(text: string): unknown;
9
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/agent/extract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,MAAM,WAAW,wBAAwB;IACvC,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAS3F;AAsDD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAoB/C"}
@@ -0,0 +1,22 @@
1
+ import { Agent } from '@openai/agents';
2
+ import { z } from 'zod';
3
+ import type { Capability } from './capability';
4
+ import type { Workflow } from './workflow';
5
+ export type FlowType = 'initialize' | 'edit' | 'capability';
6
+ export interface FlowClassification {
7
+ flow: FlowType;
8
+ input?: string;
9
+ note?: string;
10
+ }
11
+ export declare const flowOutputSchema: z.ZodObject<{
12
+ flow: z.ZodEnum<{
13
+ capability: "capability";
14
+ initialize: "initialize";
15
+ edit: "edit";
16
+ }>;
17
+ }, z.core.$strip>;
18
+ export declare function createFlowAgent(options: {
19
+ workflows: Workflow[];
20
+ capabilities: Capability<any, any>[];
21
+ }): Agent<any, any>;
22
+ //# sourceMappingURL=flowAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowAgent.d.ts","sourceRoot":"","sources":["../../src/agent/flowAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,MAAM,GAAG,YAAY,CAAA;AAE3D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,gBAAgB;;;;;;iBAE3B,CAAA;AAgBF,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,YAAY,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;CACrC,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAsBlB"}
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ export interface AddComponentIR {
3
+ type: 'add-component';
4
+ widget: string;
5
+ items: Array<Record<string, any>>;
6
+ }
7
+ export interface DeleteComponentIR {
8
+ type: 'delete-component';
9
+ target: string;
10
+ }
11
+ export interface UpdateComponentIR {
12
+ type: 'update-component';
13
+ target: string;
14
+ changes: Record<string, any>;
15
+ }
16
+ export interface MoveComponentIR {
17
+ type: 'move-component';
18
+ target: string;
19
+ before?: string;
20
+ after?: string;
21
+ }
22
+ export type EditIR = AddComponentIR | DeleteComponentIR | UpdateComponentIR | MoveComponentIR;
23
+ export interface LayoutWidgetItem {
24
+ widget: string;
25
+ items: Array<{
26
+ category: string;
27
+ id: any;
28
+ }>;
29
+ }
30
+ export type LayoutIR = LayoutWidgetItem[];
31
+ /** 标准化后的布局元素:业务数据统一成 { kind, items: [{ name, id }] }。 */
32
+ export interface NormalizedElementItem {
33
+ name: string;
34
+ id: number;
35
+ }
36
+ export interface NormalizedElement {
37
+ kind: string;
38
+ items: NormalizedElementItem[];
39
+ }
40
+ export type NormalizedElements = NormalizedElement[];
41
+ export declare const layoutIrSchema: z.ZodObject<{
42
+ layout: z.ZodArray<z.ZodObject<{
43
+ widget: z.ZodString;
44
+ items: z.ZodArray<z.ZodObject<{
45
+ category: z.ZodString;
46
+ id: z.ZodAny;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>>;
49
+ }, z.core.$strip>;
50
+ export declare const editIrSchema: z.ZodObject<{
51
+ edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
52
+ type: z.ZodLiteral<"add-component">;
53
+ widget: z.ZodString;
54
+ items: z.ZodArray<z.ZodAny>;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ type: z.ZodLiteral<"delete-component">;
57
+ target: z.ZodString;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ type: z.ZodLiteral<"update-component">;
60
+ target: z.ZodString;
61
+ changes: z.ZodRecord<z.ZodString, z.ZodAny>;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ type: z.ZodLiteral<"move-component">;
64
+ target: z.ZodString;
65
+ before: z.ZodOptional<z.ZodString>;
66
+ after: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strip>], "type">>;
68
+ }, z.core.$strip>;
69
+ //# sourceMappingURL=ir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../src/agent/ir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,kBAAkB,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,kBAAkB,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,CAAA;AAE7F,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,GAAG,CAAA;KAAE,CAAC,CAAA;CAC5C;AAED,MAAM,MAAM,QAAQ,GAAG,gBAAgB,EAAE,CAAA;AAEzC,yDAAyD;AACzD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,qBAAqB,EAAE,CAAA;CAC/B;AAED,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,EAAE,CAAA;AAGpD,eAAO,MAAM,cAAc;;;;;;;;iBAYzB,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;iBAyBvB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { Agent } from '@openai/agents';
2
+ import type { LayoutIR, NormalizedElements } from './ir';
3
+ export interface LayoutWidgetDescriptor {
4
+ typeId: string;
5
+ description: string;
6
+ layout?: Record<string, any>;
7
+ }
8
+ export declare function createLayoutAgent(): Agent<any, any>;
9
+ export interface GenerateLayoutIROptions {
10
+ elements: NormalizedElements;
11
+ widgets: LayoutWidgetDescriptor[];
12
+ }
13
+ export declare function generateLayoutIR(options: GenerateLayoutIROptions): Promise<LayoutIR>;
14
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/agent/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAGxD,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC7B;AAmBD,wBAAgB,iBAAiB,IAAI,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAOnD;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,OAAO,EAAE,sBAAsB,EAAE,CAAA;CAClC;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAO1F"}
@@ -0,0 +1,70 @@
1
+ import type { Agent } from '@openai/agents';
2
+ import type { Capability } from './capability';
3
+ import type { ToolApprovalHandler } from './context';
4
+ import type { FlowType } from './flowAgent';
5
+ import type { EditIR, LayoutIR } from './ir';
6
+ import { WorkflowRuntime } from './workflow';
7
+ import type { Workflow, WorkflowEvent, WorkflowRunResult } from './workflow';
8
+ export type AgentRuntimeEvent = {
9
+ type: 'text-delta';
10
+ text: string;
11
+ } | {
12
+ type: 'tool-call';
13
+ callId: string;
14
+ name: string;
15
+ args: unknown;
16
+ } | {
17
+ type: 'tool-result';
18
+ callId: string;
19
+ name: string;
20
+ result?: unknown;
21
+ error?: string;
22
+ } | {
23
+ type: 'agent-updated';
24
+ agent: string;
25
+ } | WorkflowEvent;
26
+ export interface AgentRuntimeResult {
27
+ flow: FlowType;
28
+ text?: string;
29
+ layout?: LayoutIR;
30
+ edits?: EditIR[];
31
+ capability?: {
32
+ name: string;
33
+ result: unknown;
34
+ };
35
+ workflow?: WorkflowRunResult;
36
+ }
37
+ export interface AgentRuntimeOptions {
38
+ capabilities?: Capability<any, any>[];
39
+ workflows?: Workflow[];
40
+ context?: () => Record<string, unknown>;
41
+ extractLayout?: (output: unknown) => LayoutIR | undefined;
42
+ }
43
+ export interface AgentRuntimeHooks {
44
+ onEvent?: (event: AgentRuntimeEvent) => void;
45
+ onApproval?: ToolApprovalHandler;
46
+ }
47
+ /**
48
+ * 编辑器平台提供的 Agent Runtime。
49
+ *
50
+ * Agent Loop / Tool Calling / Session / Context 全部由 OpenAI Agents SDK 提供;
51
+ * 模型接口调用走原来的 chat.completions(服务器代理),见 core/sdk.ts。
52
+ */
53
+ export declare class AgentRuntime {
54
+ flowAgent: Agent<any, any>;
55
+ editAgent: Agent<any, any>;
56
+ capabilityAgent: Agent<any, any>;
57
+ workflowRuntime: WorkflowRuntime;
58
+ private readonly capabilities;
59
+ private readonly workflows;
60
+ private readonly options;
61
+ private readonly flowSession;
62
+ constructor(options?: AgentRuntimeOptions);
63
+ run(input: string, hooks?: AgentRuntimeHooks): Promise<AgentRuntimeResult>;
64
+ reset(): Promise<void>;
65
+ private runInitialize;
66
+ private runEdit;
67
+ private runCapability;
68
+ }
69
+ export declare function createAgentRuntime(options?: AgentRuntimeOptions): AgentRuntime;
70
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/agent/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,gBAAgB,CAAA;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAc,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAKhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAI5C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE5E,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;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AAC,CAAA;IAChC,eAAe,EAAE,eAAe,CAAA;IAEvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwB;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;gBAE/B,OAAO,GAAE,mBAAwB;IAWvC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkC9E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAId,aAAa;YA4Bb,OAAO;YA0BP,aAAa;CA2B5B;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CAElF"}
@@ -0,0 +1,35 @@
1
+ export type MessagePart = {
2
+ type: 'text';
3
+ text: string;
4
+ } | {
5
+ type: 'action';
6
+ action: unknown;
7
+ result?: unknown;
8
+ } | {
9
+ type: 'tool-call';
10
+ call: unknown;
11
+ result?: unknown;
12
+ }
13
+ /** 运行时的一个步骤标题(第几轮、阶段名) */
14
+ | {
15
+ type: 'step';
16
+ label: string;
17
+ }
18
+ /** 需要人工确认的工具:展示审批请求与用户决策 */
19
+ | {
20
+ type: 'approval';
21
+ call: unknown;
22
+ decision?: 'approved' | 'rejected';
23
+ }
24
+ /** 模型原始输出,方便对着 Prompt / response_format 排查;label 标出这一轮走的通道 */
25
+ | {
26
+ type: 'raw';
27
+ text: string;
28
+ label?: string;
29
+ };
30
+ export interface ThreadMessage {
31
+ id: string;
32
+ role: 'user' | 'copilot';
33
+ parts: MessagePart[];
34
+ }
35
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/agent/type.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE;AAC1D,0BAA0B;GACtB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACnC,4BAA4B;GACxB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;CAAE;AAC3E,8DAA8D;GAC1D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB"}
@@ -0,0 +1,7 @@
1
+ import { Agent, AgentConfiguration, AgentOutputType } from "@openai/agents";
2
+ type AgentOptions<TContext = unknown, TOutput extends AgentOutputType = "text"> = Omit<AgentConfiguration<TContext, TOutput>, 'model'>;
3
+ export declare function createAgent<TContext = unknown, TOutput extends AgentOutputType = "text">(options: Partial<AgentOptions<TContext, TOutput>> & {
4
+ name: string;
5
+ }): Agent<TContext, TOutput>;
6
+ export {};
7
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../../src/agent/utils/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE5E,KAAK,YAAY,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,SAAS,eAAe,GAAG,MAAM,IAC5E,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;AAEtD,wBAAgB,WAAW,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,SAAS,eAAe,GAAG,MAAM,EACtF,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GACnE,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAK1B"}
@@ -0,0 +1,94 @@
1
+ import type { ToolApprovalHandler } from './context';
2
+ export type WorkflowEvent = {
3
+ type: 'workflow-start';
4
+ workflow: string;
5
+ } | {
6
+ type: 'step-start';
7
+ workflow: string;
8
+ step: string;
9
+ index: number;
10
+ } | {
11
+ type: 'step-complete';
12
+ workflow: string;
13
+ step: string;
14
+ index: number;
15
+ output?: unknown;
16
+ } | {
17
+ type: 'step-retry';
18
+ workflow: string;
19
+ step: string;
20
+ index: number;
21
+ attempt: number;
22
+ error: string;
23
+ } | {
24
+ type: 'step-error';
25
+ workflow: string;
26
+ step: string;
27
+ index: number;
28
+ error: string;
29
+ } | {
30
+ type: 'workflow-complete';
31
+ workflow: string;
32
+ output?: unknown;
33
+ } | {
34
+ type: 'workflow-abort';
35
+ workflow: string;
36
+ };
37
+ export interface WorkflowContext {
38
+ /** 上一步的输出(或初始输入)。 */
39
+ input: unknown;
40
+ /** 跨步骤共享状态,业务侧可读写。 */
41
+ state: Record<string, unknown>;
42
+ signal?: AbortSignal;
43
+ onEvent?: (event: WorkflowEvent) => void;
44
+ /** 审批处理器:step 内通过 invokeCapability 调用需要确认的能力时使用。 */
45
+ onApproval?: ToolApprovalHandler;
46
+ }
47
+ export interface StepResult {
48
+ output?: unknown;
49
+ }
50
+ export interface WorkflowStep {
51
+ name: string;
52
+ /** 失败后的重试次数(默认 0)。 */
53
+ retry?: number;
54
+ execute(context: WorkflowContext): Promise<unknown | StepResult>;
55
+ }
56
+ export interface WorkflowDefinition {
57
+ name: string;
58
+ description?: string;
59
+ steps: WorkflowStep[];
60
+ }
61
+ export interface Workflow extends WorkflowDefinition {
62
+ kind: 'workflow';
63
+ }
64
+ /** 定义业务流程。Workflow 只是可执行流程定义,不属于编辑器业务逻辑。 */
65
+ export declare function defineWorkflow(definition: WorkflowDefinition): Workflow;
66
+ export type WorkflowStatus = 'completed' | 'failed' | 'aborted';
67
+ export interface WorkflowRunResult {
68
+ workflow: string;
69
+ status: WorkflowStatus;
70
+ state: Record<string, unknown>;
71
+ output?: unknown;
72
+ error?: string;
73
+ logs: WorkflowEvent[];
74
+ }
75
+ export interface WorkflowRunOptions {
76
+ signal?: AbortSignal;
77
+ onEvent?: (event: WorkflowEvent) => void;
78
+ onApproval?: ToolApprovalHandler;
79
+ /** 恢复执行:从第几个 step 继续(0-based)。 */
80
+ resumeFrom?: number;
81
+ /** 恢复执行:带入已有 state。 */
82
+ state?: Record<string, unknown>;
83
+ }
84
+ /**
85
+ * Workflow Runtime:只负责执行业务侧传入的 Workflow。
86
+ *
87
+ * 提供顺序执行、上下文传递、异常处理、中断、恢复、日志、执行状态和重试,
88
+ * 但不理解任何具体业务语义。
89
+ */
90
+ export declare class WorkflowRuntime {
91
+ run(workflow: Workflow, input: unknown, options?: WorkflowRunOptions): Promise<WorkflowRunResult>;
92
+ private executeStep;
93
+ }
94
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/agent/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEpD,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,YAAY,CAAC;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8Cf,WAAW;CAoC1B"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Agent 的 web component 出口。
3
+ *
4
+ * 把库入口暴露的 `MpdAgent` 包装成一个原生自定义元素 `<dnd-agent>`:
5
+ *
6
+ * ```ts
7
+ * import '@sepveneto/dnde-agent/element' // 注册 <dnd-agent>
8
+ * // 或
9
+ * import { registerAgentElement } from '@sepveneto/dnde-agent/element'
10
+ * registerAgentElement('my-agent')
11
+ * ```
12
+ *
13
+ * 注意:库入口 `@sepveneto/dnde-agent` 是纯方法/类型导出,不会注册自定义元素;
14
+ * 需要 `<dnd-agent>` 时走本入口(或显式调用 `registerAgentElement`)。
15
+ */
16
+ import type { VueElementConstructor } from 'vue';
17
+ export * from './index';
18
+ /**
19
+ * 取自定义元素类(第一次调用时才创建,避免在 SSR / Node 里 import 报错)。
20
+ */
21
+ export declare function getAgentElement(): VueElementConstructor;
22
+ /**
23
+ * 注册 `<dnd-agent>`;重复注册同一个标签名会被忽略。
24
+ * 返回真正注册的标签名,非浏览器环境返回 undefined。
25
+ */
26
+ export declare function registerAgentElement(tagName?: string): string | undefined;
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'dnd-agent': HTMLElement;
30
+ }
31
+ }
32
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,KAAK,CAAA;AAIhD,cAAc,SAAS,CAAA;AAMvB;;GAEG;AACH,wBAAgB,eAAe,IAAI,qBAAqB,CAKvD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,MAAyB,GAAG,MAAM,GAAG,SAAS,CAU3F;AAKD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,WAAW,CAAA;KACzB;CACF"}
@@ -0,0 +1,17 @@
1
+ import { defineCustomElement as t } from "vue";
2
+ import { MpdAgent as o } from "@sepveneto/dnde-agent";
3
+ export * from "@sepveneto/dnde-agent";
4
+ const i = "dnd-agent";
5
+ let n;
6
+ function r() {
7
+ return n || (n = t(o)), n;
8
+ }
9
+ function m(e = i) {
10
+ if (!(typeof window == "undefined" || !window.customElements))
11
+ return window.customElements.get(e) || window.customElements.define(e, r()), e;
12
+ }
13
+ m();
14
+ export {
15
+ r as getAgentElement,
16
+ m as registerAgentElement
17
+ };
@@ -0,0 +1,25 @@
1
+ export declare const MpdAgent: import("vue").DefineComponent<Record<string, unknown>, Record<string, unknown>, any>;
2
+ export { Agent, MemorySession, Runner, run, tool, } from '@openai/agents';
3
+ export type { FunctionTool, RunContext, RunResult, Session, Tool, } from '@openai/agents';
4
+ export { configureModel, getModel, getModelConfig, getModelName, runAgent, runAgentStreamed, setMockClient, } from './agent/core/sdk';
5
+ export type { ModelConfig, RunAgentOptions } from './agent/core/sdk';
6
+ export type { AppContext, ToolApprovalHandler, ToolApprovalRequest, } from './agent/context';
7
+ export type { Capability, CapabilityContext, CapabilityDefinition, CapabilitySchema, ToolApprovalOptions, } from './agent/capability';
8
+ export { createCapabilityTool, defineCapability, invokeCapability, } from './agent/capability';
9
+ export { clearCapabilities, getRegisteredCapabilities, getRegisteredCapabilityTools, listCapabilities, registerCapability, unregisterCapability, } from './agent/capabilityRegistry';
10
+ export type { StepResult, Workflow, WorkflowContext, WorkflowDefinition, WorkflowEvent, WorkflowRunOptions, WorkflowRunResult, WorkflowStatus, WorkflowStep, } from './agent/workflow';
11
+ export { defineWorkflow, WorkflowRuntime } from './agent/workflow';
12
+ export type { AddComponentIR, DeleteComponentIR, EditIR, LayoutIR, LayoutWidgetItem, MoveComponentIR, NormalizedElement, NormalizedElementItem, NormalizedElements, UpdateComponentIR, } from './agent/ir';
13
+ export { editIrSchema, layoutIrSchema } from './agent/ir';
14
+ export type { FlowClassification, FlowType } from './agent/flowAgent';
15
+ export { createFlowAgent, flowOutputSchema } from './agent/flowAgent';
16
+ export { createEditAgent } from './agent/editAgent';
17
+ export { createCapabilityAgent } from './agent/capabilityAgent';
18
+ export type { LayoutWidgetDescriptor } from './agent/layout';
19
+ export { createLayoutAgent, generateLayoutIR } from './agent/layout';
20
+ export type { AgentRuntimeEvent, AgentRuntimeHooks, AgentRuntimeOptions, AgentRuntimeResult, } from './agent/runtime';
21
+ export { AgentRuntime, createAgentRuntime } from './agent/runtime';
22
+ export type { StructuredExtractOptions } from './agent/extract';
23
+ export { parseJson, structuredExtract } from './agent/extract';
24
+ export * from './agent/utils/helper';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ,sFAAU,CAAA;AAG/B,OAAO,EACL,KAAK,EACL,aAAa,EACb,MAAM,EACN,GAAG,EACH,IAAI,GACL,MAAM,gBAAgB,CAAA;AAEvB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,OAAO,EACP,IAAI,GACL,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACL,cAAc,EACd,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGpE,YAAY,EACV,UAAU,EACV,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AAGxB,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,4BAA4B,EAC5B,g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