@agenticc/core 1.0.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 +21 -0
- package/README.md +370 -0
- package/README.zh-CN.md +372 -0
- package/dist/audit/index.d.ts +9 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +9 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/logger.d.ts +211 -0
- package/dist/audit/logger.d.ts.map +1 -0
- package/dist/audit/logger.js +268 -0
- package/dist/audit/logger.js.map +1 -0
- package/dist/audit/query.d.ts +164 -0
- package/dist/audit/query.d.ts.map +1 -0
- package/dist/audit/query.js +250 -0
- package/dist/audit/query.js.map +1 -0
- package/dist/conversation/context-builder.d.ts +119 -0
- package/dist/conversation/context-builder.d.ts.map +1 -0
- package/dist/conversation/context-builder.js +252 -0
- package/dist/conversation/context-builder.js.map +1 -0
- package/dist/conversation/index.d.ts +10 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +10 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/message-store.d.ts +231 -0
- package/dist/conversation/message-store.d.ts.map +1 -0
- package/dist/conversation/message-store.js +404 -0
- package/dist/conversation/message-store.js.map +1 -0
- package/dist/conversation/session.d.ts +201 -0
- package/dist/conversation/session.d.ts.map +1 -0
- package/dist/conversation/session.js +285 -0
- package/dist/conversation/session.js.map +1 -0
- package/dist/core/agent.d.ts +277 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +674 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/agentic-loop.d.ts +98 -0
- package/dist/core/agentic-loop.d.ts.map +1 -0
- package/dist/core/agentic-loop.js +496 -0
- package/dist/core/agentic-loop.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +14 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/intent-parser.d.ts +101 -0
- package/dist/core/intent-parser.d.ts.map +1 -0
- package/dist/core/intent-parser.js +221 -0
- package/dist/core/intent-parser.js.map +1 -0
- package/dist/core/plan-generator.d.ts +133 -0
- package/dist/core/plan-generator.d.ts.map +1 -0
- package/dist/core/plan-generator.js +294 -0
- package/dist/core/plan-generator.js.map +1 -0
- package/dist/core/plugin-manager.d.ts +120 -0
- package/dist/core/plugin-manager.d.ts.map +1 -0
- package/dist/core/plugin-manager.js +369 -0
- package/dist/core/plugin-manager.js.map +1 -0
- package/dist/core/response-handler.d.ts +141 -0
- package/dist/core/response-handler.d.ts.map +1 -0
- package/dist/core/response-handler.js +384 -0
- package/dist/core/response-handler.js.map +1 -0
- package/dist/core/tool-executor.d.ts +143 -0
- package/dist/core/tool-executor.d.ts.map +1 -0
- package/dist/core/tool-executor.js +354 -0
- package/dist/core/tool-executor.js.map +1 -0
- package/dist/core/tool-registry.d.ts +133 -0
- package/dist/core/tool-registry.d.ts.map +1 -0
- package/dist/core/tool-registry.js +252 -0
- package/dist/core/tool-registry.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge/chunker.d.ts +78 -0
- package/dist/knowledge/chunker.d.ts.map +1 -0
- package/dist/knowledge/chunker.js +233 -0
- package/dist/knowledge/chunker.js.map +1 -0
- package/dist/knowledge/embedder.d.ts +93 -0
- package/dist/knowledge/embedder.d.ts.map +1 -0
- package/dist/knowledge/embedder.js +205 -0
- package/dist/knowledge/embedder.js.map +1 -0
- package/dist/knowledge/index.d.ts +10 -0
- package/dist/knowledge/index.d.ts.map +1 -0
- package/dist/knowledge/index.js +11 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/knowledge/loaders/index.d.ts +10 -0
- package/dist/knowledge/loaders/index.d.ts.map +1 -0
- package/dist/knowledge/loaders/index.js +10 -0
- package/dist/knowledge/loaders/index.js.map +1 -0
- package/dist/knowledge/loaders/markdown.d.ts +88 -0
- package/dist/knowledge/loaders/markdown.d.ts.map +1 -0
- package/dist/knowledge/loaders/markdown.js +205 -0
- package/dist/knowledge/loaders/markdown.js.map +1 -0
- package/dist/knowledge/loaders/yaml.d.ts +112 -0
- package/dist/knowledge/loaders/yaml.d.ts.map +1 -0
- package/dist/knowledge/loaders/yaml.js +368 -0
- package/dist/knowledge/loaders/yaml.js.map +1 -0
- package/dist/knowledge/retriever.d.ts +144 -0
- package/dist/knowledge/retriever.d.ts.map +1 -0
- package/dist/knowledge/retriever.js +399 -0
- package/dist/knowledge/retriever.js.map +1 -0
- package/dist/knowledge/store.d.ts +146 -0
- package/dist/knowledge/store.d.ts.map +1 -0
- package/dist/knowledge/store.js +420 -0
- package/dist/knowledge/store.js.map +1 -0
- package/dist/llm/adapter.d.ts +194 -0
- package/dist/llm/adapter.d.ts.map +1 -0
- package/dist/llm/adapter.js +42 -0
- package/dist/llm/adapter.js.map +1 -0
- package/dist/llm/adapters/anyrouter.d.ts +84 -0
- package/dist/llm/adapters/anyrouter.d.ts.map +1 -0
- package/dist/llm/adapters/anyrouter.js +372 -0
- package/dist/llm/adapters/anyrouter.js.map +1 -0
- package/dist/llm/adapters/claude.d.ts +66 -0
- package/dist/llm/adapters/claude.d.ts.map +1 -0
- package/dist/llm/adapters/claude.js +323 -0
- package/dist/llm/adapters/claude.js.map +1 -0
- package/dist/llm/adapters/index.d.ts +12 -0
- package/dist/llm/adapters/index.d.ts.map +1 -0
- package/dist/llm/adapters/index.js +12 -0
- package/dist/llm/adapters/index.js.map +1 -0
- package/dist/llm/adapters/mimo.d.ts +85 -0
- package/dist/llm/adapters/mimo.d.ts.map +1 -0
- package/dist/llm/adapters/mimo.js +316 -0
- package/dist/llm/adapters/mimo.js.map +1 -0
- package/dist/llm/adapters/openai.d.ts +53 -0
- package/dist/llm/adapters/openai.d.ts.map +1 -0
- package/dist/llm/adapters/openai.js +293 -0
- package/dist/llm/adapters/openai.js.map +1 -0
- package/dist/llm/adapters/qwen.d.ts +53 -0
- package/dist/llm/adapters/qwen.d.ts.map +1 -0
- package/dist/llm/adapters/qwen.js +299 -0
- package/dist/llm/adapters/qwen.js.map +1 -0
- package/dist/llm/adapters/siliconflow.d.ts +69 -0
- package/dist/llm/adapters/siliconflow.d.ts.map +1 -0
- package/dist/llm/adapters/siliconflow.js +331 -0
- package/dist/llm/adapters/siliconflow.js.map +1 -0
- package/dist/llm/index.d.ts +9 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +12 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/manager.d.ts +97 -0
- package/dist/llm/manager.d.ts.map +1 -0
- package/dist/llm/manager.js +337 -0
- package/dist/llm/manager.js.map +1 -0
- package/dist/test-utils/arbitraries.d.ts +230 -0
- package/dist/test-utils/arbitraries.d.ts.map +1 -0
- package/dist/test-utils/arbitraries.js +280 -0
- package/dist/test-utils/arbitraries.js.map +1 -0
- package/dist/test-utils/cleanup.d.ts +184 -0
- package/dist/test-utils/cleanup.d.ts.map +1 -0
- package/dist/test-utils/cleanup.js +282 -0
- package/dist/test-utils/cleanup.js.map +1 -0
- package/dist/test-utils/config.d.ts +80 -0
- package/dist/test-utils/config.d.ts.map +1 -0
- package/dist/test-utils/config.js +94 -0
- package/dist/test-utils/config.js.map +1 -0
- package/dist/test-utils/index.d.ts +10 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +36 -0
- package/dist/test-utils/index.js.map +1 -0
- package/dist/test-utils/mocks.d.ts +170 -0
- package/dist/test-utils/mocks.d.ts.map +1 -0
- package/dist/test-utils/mocks.js +281 -0
- package/dist/test-utils/mocks.js.map +1 -0
- package/dist/types/config.d.ts +170 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +120 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/knowledge.d.ts +95 -0
- package/dist/types/knowledge.d.ts.map +1 -0
- package/dist/types/knowledge.js +7 -0
- package/dist/types/knowledge.js.map +1 -0
- package/dist/types/loop.d.ts +148 -0
- package/dist/types/loop.d.ts.map +1 -0
- package/dist/types/loop.js +16 -0
- package/dist/types/loop.js.map +1 -0
- package/dist/types/plugin.d.ts +137 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +15 -0
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/response.d.ts +186 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +99 -0
- package/dist/types/response.js.map +1 -0
- package/dist/types/streaming.d.ts +478 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +483 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/tool.d.ts +118 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/tool.js +42 -0
- package/dist/types/tool.js.map +1 -0
- package/dist/utils/error.d.ts +22 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +36 -0
- package/dist/utils/error.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Response Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the different types of responses the Agent can return.
|
|
5
|
+
* Each response type represents a different interaction pattern with the user.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* All possible response types
|
|
9
|
+
*/
|
|
10
|
+
export declare const RESPONSE_TYPES: readonly ["execute", "clarify", "knowledge_request", "confirm", "options"];
|
|
11
|
+
/**
|
|
12
|
+
* Response type literal union
|
|
13
|
+
*/
|
|
14
|
+
export type ResponseType = (typeof RESPONSE_TYPES)[number];
|
|
15
|
+
/**
|
|
16
|
+
* Execute Response - Agent has completed an action
|
|
17
|
+
*
|
|
18
|
+
* Returned when the Agent has sufficient knowledge and confidence
|
|
19
|
+
* to execute the requested action.
|
|
20
|
+
*/
|
|
21
|
+
export interface ExecuteResponse {
|
|
22
|
+
type: 'execute';
|
|
23
|
+
/** Human-readable result message */
|
|
24
|
+
message: string;
|
|
25
|
+
/** Optional structured data from the execution */
|
|
26
|
+
data?: unknown;
|
|
27
|
+
/** Tool calls that were made during execution */
|
|
28
|
+
toolCalls?: ToolCallRecord[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Record of a tool call made during execution
|
|
32
|
+
*/
|
|
33
|
+
export interface ToolCallRecord {
|
|
34
|
+
toolName: string;
|
|
35
|
+
arguments: Record<string, unknown>;
|
|
36
|
+
result: {
|
|
37
|
+
success: boolean;
|
|
38
|
+
content: string;
|
|
39
|
+
data?: unknown;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Clarify Response - Agent needs more information
|
|
44
|
+
*
|
|
45
|
+
* Returned when the user's request is ambiguous and the Agent
|
|
46
|
+
* needs clarification before proceeding.
|
|
47
|
+
*/
|
|
48
|
+
export interface ClarifyResponse {
|
|
49
|
+
type: 'clarify';
|
|
50
|
+
/** Explanation of why clarification is needed */
|
|
51
|
+
message: string;
|
|
52
|
+
/** Specific questions to ask the user */
|
|
53
|
+
questions: string[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Knowledge Request Response - Agent lacks required knowledge
|
|
57
|
+
*
|
|
58
|
+
* Returned when the Agent doesn't have sufficient knowledge
|
|
59
|
+
* to complete the request and needs the user to provide information.
|
|
60
|
+
*/
|
|
61
|
+
export interface KnowledgeRequestResponse {
|
|
62
|
+
type: 'knowledge_request';
|
|
63
|
+
/** Explanation of what knowledge is missing */
|
|
64
|
+
message: string;
|
|
65
|
+
/** Details about the missing knowledge */
|
|
66
|
+
missing: {
|
|
67
|
+
/** Topic area that's missing */
|
|
68
|
+
topic: string;
|
|
69
|
+
/** Description of what information is needed */
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
/** Options for how the user can provide the knowledge */
|
|
73
|
+
options: KnowledgeOption[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for providing knowledge to the Agent
|
|
77
|
+
*/
|
|
78
|
+
export interface KnowledgeOption {
|
|
79
|
+
/** Unique identifier for this option */
|
|
80
|
+
id: string;
|
|
81
|
+
/** Type of knowledge input */
|
|
82
|
+
type: 'provide_text' | 'upload_file' | 'provide_url' | 'skip' | 'try_anyway';
|
|
83
|
+
/** Human-readable label for the option */
|
|
84
|
+
label: string;
|
|
85
|
+
/** Optional description of what this option does */
|
|
86
|
+
description?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Confirm Response - Agent needs user confirmation
|
|
90
|
+
*
|
|
91
|
+
* Returned when the Agent is about to perform a high-risk operation
|
|
92
|
+
* and needs explicit user confirmation.
|
|
93
|
+
*/
|
|
94
|
+
export interface ConfirmResponse {
|
|
95
|
+
type: 'confirm';
|
|
96
|
+
/** Explanation of what action will be taken */
|
|
97
|
+
message: string;
|
|
98
|
+
/** Details of the action to be confirmed */
|
|
99
|
+
action: {
|
|
100
|
+
/** Type of action (e.g., 'update', 'delete', 'create') */
|
|
101
|
+
type: string;
|
|
102
|
+
/** Target of the action (e.g., file path, entity name) */
|
|
103
|
+
target: string;
|
|
104
|
+
/** Parameters for the action */
|
|
105
|
+
params: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
/** Risk level of the operation */
|
|
108
|
+
risk: 'low' | 'medium' | 'high';
|
|
109
|
+
/** Optional preview of the changes */
|
|
110
|
+
preview?: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Options Response - Agent presents choices to user
|
|
114
|
+
*
|
|
115
|
+
* Returned when multiple valid options exist and the Agent
|
|
116
|
+
* needs the user to make a selection.
|
|
117
|
+
*/
|
|
118
|
+
export interface OptionsResponse {
|
|
119
|
+
type: 'options';
|
|
120
|
+
/** Explanation of why options are being presented */
|
|
121
|
+
message: string;
|
|
122
|
+
/** Available options for the user to choose from */
|
|
123
|
+
options: SelectableOption[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A selectable option in an Options response
|
|
127
|
+
*/
|
|
128
|
+
export interface SelectableOption {
|
|
129
|
+
/** Unique identifier for this option */
|
|
130
|
+
id: string;
|
|
131
|
+
/** Human-readable label */
|
|
132
|
+
label: string;
|
|
133
|
+
/** Detailed description of what this option does */
|
|
134
|
+
description: string;
|
|
135
|
+
/** Optional metadata for the option */
|
|
136
|
+
metadata?: Record<string, unknown>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Union type of all possible Agent responses
|
|
140
|
+
*/
|
|
141
|
+
export type AgentResponse = ExecuteResponse | ClarifyResponse | KnowledgeRequestResponse | ConfirmResponse | OptionsResponse;
|
|
142
|
+
/**
|
|
143
|
+
* Type guard to check if a response is an ExecuteResponse
|
|
144
|
+
*/
|
|
145
|
+
export declare function isExecuteResponse(response: AgentResponse): response is ExecuteResponse;
|
|
146
|
+
/**
|
|
147
|
+
* Type guard to check if a response is a ClarifyResponse
|
|
148
|
+
*/
|
|
149
|
+
export declare function isClarifyResponse(response: AgentResponse): response is ClarifyResponse;
|
|
150
|
+
/**
|
|
151
|
+
* Type guard to check if a response is a KnowledgeRequestResponse
|
|
152
|
+
*/
|
|
153
|
+
export declare function isKnowledgeRequestResponse(response: AgentResponse): response is KnowledgeRequestResponse;
|
|
154
|
+
/**
|
|
155
|
+
* Type guard to check if a response is a ConfirmResponse
|
|
156
|
+
*/
|
|
157
|
+
export declare function isConfirmResponse(response: AgentResponse): response is ConfirmResponse;
|
|
158
|
+
/**
|
|
159
|
+
* Type guard to check if a response is an OptionsResponse
|
|
160
|
+
*/
|
|
161
|
+
export declare function isOptionsResponse(response: AgentResponse): response is OptionsResponse;
|
|
162
|
+
/**
|
|
163
|
+
* Validates that a response object has a valid response type
|
|
164
|
+
*/
|
|
165
|
+
export declare function isValidResponseType(type: unknown): type is ResponseType;
|
|
166
|
+
/**
|
|
167
|
+
* Creates an ExecuteResponse
|
|
168
|
+
*/
|
|
169
|
+
export declare function createExecuteResponse(message: string, data?: unknown, toolCalls?: ToolCallRecord[]): ExecuteResponse;
|
|
170
|
+
/**
|
|
171
|
+
* Creates a ClarifyResponse
|
|
172
|
+
*/
|
|
173
|
+
export declare function createClarifyResponse(message: string, questions: string[]): ClarifyResponse;
|
|
174
|
+
/**
|
|
175
|
+
* Creates a KnowledgeRequestResponse
|
|
176
|
+
*/
|
|
177
|
+
export declare function createKnowledgeRequestResponse(message: string, topic: string, description: string, options?: KnowledgeOption[]): KnowledgeRequestResponse;
|
|
178
|
+
/**
|
|
179
|
+
* Creates a ConfirmResponse
|
|
180
|
+
*/
|
|
181
|
+
export declare function createConfirmResponse(message: string, actionType: string, target: string, params: Record<string, unknown>, risk: 'low' | 'medium' | 'high', preview?: string): ConfirmResponse;
|
|
182
|
+
/**
|
|
183
|
+
* Creates an OptionsResponse
|
|
184
|
+
*/
|
|
185
|
+
export declare function createOptionsResponse(message: string, options: SelectableOption[]): OptionsResponse;
|
|
186
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,4EAMjB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,SAAS,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,C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ACd,SAAS,CAAC,EAAE,cAAc,EAAE,GAC3B,eAAe,CAEjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,eAAe,CAE3F;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,eAAe,EAAE,GAC1B,wBAAwB,CAY1B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,EAC/B,OAAO,CAAC,EAAE,MAAM,GACf,eAAe,CAQjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,EAAE,GAC1B,eAAe,CAEjB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Response Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the different types of responses the Agent can return.
|
|
5
|
+
* Each response type represents a different interaction pattern with the user.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* All possible response types
|
|
9
|
+
*/
|
|
10
|
+
export const RESPONSE_TYPES = [
|
|
11
|
+
'execute',
|
|
12
|
+
'clarify',
|
|
13
|
+
'knowledge_request',
|
|
14
|
+
'confirm',
|
|
15
|
+
'options',
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to check if a response is an ExecuteResponse
|
|
19
|
+
*/
|
|
20
|
+
export function isExecuteResponse(response) {
|
|
21
|
+
return response.type === 'execute';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Type guard to check if a response is a ClarifyResponse
|
|
25
|
+
*/
|
|
26
|
+
export function isClarifyResponse(response) {
|
|
27
|
+
return response.type === 'clarify';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if a response is a KnowledgeRequestResponse
|
|
31
|
+
*/
|
|
32
|
+
export function isKnowledgeRequestResponse(response) {
|
|
33
|
+
return response.type === 'knowledge_request';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if a response is a ConfirmResponse
|
|
37
|
+
*/
|
|
38
|
+
export function isConfirmResponse(response) {
|
|
39
|
+
return response.type === 'confirm';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Type guard to check if a response is an OptionsResponse
|
|
43
|
+
*/
|
|
44
|
+
export function isOptionsResponse(response) {
|
|
45
|
+
return response.type === 'options';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validates that a response object has a valid response type
|
|
49
|
+
*/
|
|
50
|
+
export function isValidResponseType(type) {
|
|
51
|
+
return typeof type === 'string' && RESPONSE_TYPES.includes(type);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates an ExecuteResponse
|
|
55
|
+
*/
|
|
56
|
+
export function createExecuteResponse(message, data, toolCalls) {
|
|
57
|
+
return { type: 'execute', message, data, toolCalls };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a ClarifyResponse
|
|
61
|
+
*/
|
|
62
|
+
export function createClarifyResponse(message, questions) {
|
|
63
|
+
return { type: 'clarify', message, questions };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a KnowledgeRequestResponse
|
|
67
|
+
*/
|
|
68
|
+
export function createKnowledgeRequestResponse(message, topic, description, options) {
|
|
69
|
+
const defaultOptions = [
|
|
70
|
+
{ id: 'provide_text', type: 'provide_text', label: '提供文本信息' },
|
|
71
|
+
{ id: 'skip', type: 'skip', label: '跳过此步骤' },
|
|
72
|
+
{ id: 'try_anyway', type: 'try_anyway', label: '尝试继续' },
|
|
73
|
+
];
|
|
74
|
+
return {
|
|
75
|
+
type: 'knowledge_request',
|
|
76
|
+
message,
|
|
77
|
+
missing: { topic, description },
|
|
78
|
+
options: options ?? defaultOptions,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a ConfirmResponse
|
|
83
|
+
*/
|
|
84
|
+
export function createConfirmResponse(message, actionType, target, params, risk, preview) {
|
|
85
|
+
return {
|
|
86
|
+
type: 'confirm',
|
|
87
|
+
message,
|
|
88
|
+
action: { type: actionType, target, params },
|
|
89
|
+
risk,
|
|
90
|
+
preview,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates an OptionsResponse
|
|
95
|
+
*/
|
|
96
|
+
export function createOptionsResponse(message, options) {
|
|
97
|
+
return { type: 'options', message, options };
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/types/response.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,SAAS;IACT,mBAAmB;IACnB,SAAS;IACT,SAAS;CACD,CAAC;AAoJX;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAuB;IAEvB,OAAO,QAAQ,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,OA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