@nuvin/agent-core 0.0.0-rc.3 → 0.0.0-rc.4
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/VERSION +2 -2
- package/dist/agent/index.d.ts +27 -525
- package/dist/agent/index.js +1 -1
- package/dist/chunk-G2FR4UGO.js +1 -1
- package/dist/chunk-LXQDGX4K.js +1 -1
- package/dist/chunk-NYZR4XKO.js +1 -1
- package/dist/chunk-VFTQW5WK.js +1 -1
- package/dist/chunk-X7VAACWY.js +1 -1
- package/dist/formats/index.d.ts +23 -319
- package/dist/formats/index.js +1 -1
- package/dist/models/index.d.ts +330 -634
- package/dist/models/index.js +1 -1
- package/dist/shared/index.d.ts +14 -709
- package/dist/shared/index.js +1 -1
- package/dist/tools/index.d.ts +518 -969
- package/dist/tools/index.js +1 -1
- package/package.json +4 -1
package/dist/VERSION
CHANGED
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,528 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { R as RunTurnDeps, M as Message, A as AgentOptions, a as AgentInput, b as AgentSendOptions, T as TurnResult, E as ExtensionRegistry, c as TurnInput } from '../types-QPBW5jHO.js';
|
|
2
|
+
export { d as TurnState } from '../types-QPBW5jHO.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
declare class Agent {
|
|
5
|
+
readonly deps: RunTurnDeps;
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
private _systemPrompt;
|
|
8
|
+
messages: Message[];
|
|
9
|
+
readonly defaultMessage?: Message;
|
|
10
|
+
turnIndex: number;
|
|
11
|
+
constructor(options?: AgentOptions);
|
|
12
|
+
get systemPrompt(): string;
|
|
13
|
+
setTools(tools?: AgentOptions["tools"]): void;
|
|
14
|
+
setSystemPrompt(systemPrompt: string, options?: {
|
|
15
|
+
resetMessages?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
/**
|
|
18
|
+
* Replace the chat model used for subsequent turns. Existing conversation
|
|
19
|
+
* state is preserved; the next call to {@link send} uses the new model.
|
|
20
|
+
* Useful for runtime model switching (e.g. via a `/model` slash command).
|
|
21
|
+
*/
|
|
22
|
+
setChatModel(chatModel: RunTurnDeps["chatModel"]): void;
|
|
23
|
+
send(input?: AgentInput | undefined, options?: AgentSendOptions): Promise<TurnResult>;
|
|
6
24
|
}
|
|
7
|
-
export type JsonValue = JsonObject | JsonPrimitive | JsonValue[];
|
|
8
|
-
export interface JsonSchemaString {
|
|
9
|
-
type: "string";
|
|
10
|
-
}
|
|
11
|
-
export interface JsonSchemaNumber {
|
|
12
|
-
type: "number";
|
|
13
|
-
}
|
|
14
|
-
export interface JsonSchemaBoolean {
|
|
15
|
-
type: "boolean";
|
|
16
|
-
}
|
|
17
|
-
export interface JsonSchemaArray<TItem extends JsonSchema = JsonSchema> {
|
|
18
|
-
type: "array";
|
|
19
|
-
items: TItem;
|
|
20
|
-
}
|
|
21
|
-
export interface JsonSchemaObject<TProperties extends Record<string, JsonSchema> = Record<string, JsonSchema>, TRequired extends readonly string[] | undefined = readonly string[] | undefined> {
|
|
22
|
-
type: "object";
|
|
23
|
-
properties: TProperties;
|
|
24
|
-
required?: TRequired;
|
|
25
|
-
}
|
|
26
|
-
export type JsonSchema = JsonSchemaArray | JsonSchemaBoolean | JsonSchemaNumber | JsonSchemaObject | JsonSchemaString;
|
|
27
|
-
export interface TextBlock {
|
|
28
|
-
type: "text";
|
|
29
|
-
text: string;
|
|
30
|
-
}
|
|
31
|
-
export type ImageMediaType = "image/gif" | "image/jpeg" | "image/png" | "image/webp";
|
|
32
|
-
export interface ImageBlock {
|
|
33
|
-
type: "image";
|
|
34
|
-
source: {
|
|
35
|
-
type: "base64";
|
|
36
|
-
media_type: ImageMediaType;
|
|
37
|
-
data: string;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export type ToolResultContentBlock = ImageBlock | TextBlock;
|
|
41
|
-
export type ToolResultContent = string | ToolResultContentBlock[];
|
|
42
|
-
export interface AnthropicThinkingBlock {
|
|
43
|
-
type: "anthropic_thinking";
|
|
44
|
-
thinking: string;
|
|
45
|
-
signature: string;
|
|
46
|
-
}
|
|
47
|
-
export interface AnthropicRedactedThinkingBlock {
|
|
48
|
-
type: "anthropic_redacted_thinking";
|
|
49
|
-
data: string;
|
|
50
|
-
}
|
|
51
|
-
export interface OpenAiReasoningSummaryText {
|
|
52
|
-
type: "summary_text";
|
|
53
|
-
text: string;
|
|
54
|
-
}
|
|
55
|
-
export interface OpenAiReasoningBlock {
|
|
56
|
-
type: "openai_reasoning";
|
|
57
|
-
encryptedContent?: string;
|
|
58
|
-
id?: string;
|
|
59
|
-
summary: OpenAiReasoningSummaryText[];
|
|
60
|
-
text?: string;
|
|
61
|
-
}
|
|
62
|
-
export interface ToolUseBlock {
|
|
63
|
-
type: "tool_use";
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
input: JsonValue;
|
|
67
|
-
}
|
|
68
|
-
export interface ToolResultBlock {
|
|
69
|
-
type: "tool_result";
|
|
70
|
-
tool_use_id: string;
|
|
71
|
-
content: ToolResultContent;
|
|
72
|
-
is_error: boolean;
|
|
73
|
-
}
|
|
74
|
-
export interface AnthropicThinkingWireBlock {
|
|
75
|
-
type: "thinking";
|
|
76
|
-
thinking: string;
|
|
77
|
-
signature: string;
|
|
78
|
-
}
|
|
79
|
-
export interface AnthropicRedactedThinkingWireBlock {
|
|
80
|
-
type: "redacted_thinking";
|
|
81
|
-
data: string;
|
|
82
|
-
}
|
|
83
|
-
export type AnthropicAssistantContentBlock = AnthropicRedactedThinkingWireBlock | AnthropicThinkingWireBlock | TextBlock | ToolUseBlock;
|
|
84
|
-
export type ReasoningVisibility = "continuity-only" | "user-visible";
|
|
85
|
-
export type AutoReasoningEffort = "low" | "medium" | "high";
|
|
86
|
-
export interface AutoReasoningConfig {
|
|
87
|
-
effort: AutoReasoningEffort;
|
|
88
|
-
}
|
|
89
|
-
export type AnthropicThinkingDisplay = "omitted" | "summarized";
|
|
90
|
-
export type AnthropicThinkingEffort = "low" | "medium" | "high";
|
|
91
|
-
export interface AnthropicEnabledThinkingConfig {
|
|
92
|
-
type: "enabled";
|
|
93
|
-
budgetTokens: number;
|
|
94
|
-
display?: AnthropicThinkingDisplay;
|
|
95
|
-
interleaved?: boolean;
|
|
96
|
-
}
|
|
97
|
-
export interface AnthropicAdaptiveThinkingConfig {
|
|
98
|
-
type: "adaptive";
|
|
99
|
-
display?: AnthropicThinkingDisplay;
|
|
100
|
-
effort?: AnthropicThinkingEffort;
|
|
101
|
-
interleaved?: boolean;
|
|
102
|
-
}
|
|
103
|
-
export interface AnthropicDisabledThinkingConfig {
|
|
104
|
-
type: "disabled";
|
|
105
|
-
}
|
|
106
|
-
export type AnthropicThinkingConfig = AnthropicAdaptiveThinkingConfig | AnthropicDisabledThinkingConfig | AnthropicEnabledThinkingConfig;
|
|
107
|
-
export type OpenAiReasoningEffort = "high" | "low" | "medium" | "minimal" | "none" | "xhigh";
|
|
108
|
-
export type OpenAiReasoningSummary = "auto" | "concise" | "detailed";
|
|
109
|
-
export interface OpenAiReasoningConfig {
|
|
110
|
-
effort?: OpenAiReasoningEffort;
|
|
111
|
-
includeEncryptedContent?: boolean;
|
|
112
|
-
summary?: OpenAiReasoningSummary;
|
|
113
|
-
}
|
|
114
|
-
export interface ReasoningConfig {
|
|
115
|
-
auto?: AutoReasoningConfig;
|
|
116
|
-
anthropic?: AnthropicThinkingConfig;
|
|
117
|
-
openai?: OpenAiReasoningConfig;
|
|
118
|
-
visibility?: ReasoningVisibility;
|
|
119
|
-
}
|
|
120
|
-
export interface MessageProviderState {
|
|
121
|
-
anthropicAssistantContent?: AnthropicAssistantContentBlock[];
|
|
122
|
-
openaiResponsesOutput?: OpenAiResponsesOutputItem[];
|
|
123
|
-
openaiResponsesResponseId?: string;
|
|
124
|
-
}
|
|
125
|
-
export type AssistantContentBlock = AnthropicRedactedThinkingBlock | AnthropicThinkingBlock | OpenAiReasoningBlock | TextBlock | ToolUseBlock;
|
|
126
|
-
export type ContentBlock = AssistantContentBlock | ToolResultBlock;
|
|
127
|
-
export type ContentInput = ContentBlock[] | string | null | undefined;
|
|
128
|
-
export type MessageRole = "assistant" | "user";
|
|
129
|
-
export type SystemInput = TextBlock[] | string | null | undefined;
|
|
130
|
-
export interface Message {
|
|
131
|
-
id?: string;
|
|
132
|
-
role: MessageRole;
|
|
133
|
-
content: ContentBlock[];
|
|
134
|
-
providerState?: MessageProviderState;
|
|
135
|
-
}
|
|
136
|
-
export interface IdentifiedMessage extends Message {
|
|
137
|
-
id: string;
|
|
138
|
-
}
|
|
139
|
-
export interface MessageInput {
|
|
140
|
-
id?: string;
|
|
141
|
-
role: MessageRole;
|
|
142
|
-
content?: ContentInput;
|
|
143
|
-
providerState?: MessageProviderState;
|
|
144
|
-
}
|
|
145
|
-
export interface ToolSchema {
|
|
146
|
-
name: string;
|
|
147
|
-
description: string;
|
|
148
|
-
input_schema: JsonSchemaObject;
|
|
149
|
-
}
|
|
150
|
-
export interface ChatRequest {
|
|
151
|
-
model: string;
|
|
152
|
-
maxTokens: number;
|
|
153
|
-
reasoning?: ReasoningConfig;
|
|
154
|
-
system: TextBlock[];
|
|
155
|
-
messages: Message[];
|
|
156
|
-
tools: ToolSchema[];
|
|
157
|
-
metadata: {
|
|
158
|
-
sessionId: string;
|
|
159
|
-
turnId: string;
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
export interface ChatResponse {
|
|
163
|
-
id: string;
|
|
164
|
-
content: AssistantContentBlock[];
|
|
165
|
-
stopReason: "end_turn" | "tool_use";
|
|
166
|
-
usage: {
|
|
167
|
-
inputTokens: number;
|
|
168
|
-
outputTokens: number;
|
|
169
|
-
reasoningTokens?: number;
|
|
170
|
-
};
|
|
171
|
-
providerState?: MessageProviderState;
|
|
172
|
-
}
|
|
173
|
-
export interface ContentDeltaChunk {
|
|
174
|
-
type: "content_delta";
|
|
175
|
-
index?: number;
|
|
176
|
-
text?: string;
|
|
177
|
-
}
|
|
178
|
-
export interface ToolUseDeltaChunk {
|
|
179
|
-
type: "tool_use_delta";
|
|
180
|
-
id: string;
|
|
181
|
-
index: number;
|
|
182
|
-
inputDelta?: string;
|
|
183
|
-
name?: string;
|
|
184
|
-
}
|
|
185
|
-
export interface AnthropicThinkingDeltaChunk {
|
|
186
|
-
type: "anthropic_thinking_delta";
|
|
187
|
-
index: number;
|
|
188
|
-
thinking: string;
|
|
189
|
-
}
|
|
190
|
-
export interface OpenAiReasoningDeltaChunk {
|
|
191
|
-
type: "openai_reasoning_delta";
|
|
192
|
-
contentIndex: number;
|
|
193
|
-
delta: string;
|
|
194
|
-
itemId: string;
|
|
195
|
-
outputIndex: number;
|
|
196
|
-
}
|
|
197
|
-
export interface OpenAiReasoningSummaryDeltaChunk {
|
|
198
|
-
type: "openai_reasoning_summary_delta";
|
|
199
|
-
delta: string;
|
|
200
|
-
itemId: string;
|
|
201
|
-
outputIndex: number;
|
|
202
|
-
summaryIndex: number;
|
|
203
|
-
}
|
|
204
|
-
export interface ChatResponseChunk {
|
|
205
|
-
type: "anthropic_signature_delta" | "anthropic_thinking_delta" | "content_delta" | "done" | "openai_reasoning_delta" | "openai_reasoning_summary_delta" | "tool_use_delta";
|
|
206
|
-
contentIndex?: number;
|
|
207
|
-
delta?: string;
|
|
208
|
-
index?: number;
|
|
209
|
-
itemId?: string;
|
|
210
|
-
outputIndex?: number;
|
|
211
|
-
signature?: string;
|
|
212
|
-
summaryIndex?: number;
|
|
213
|
-
text?: string;
|
|
214
|
-
thinking?: string;
|
|
215
|
-
inputDelta?: string;
|
|
216
|
-
name?: string;
|
|
217
|
-
id?: string;
|
|
218
|
-
response?: ChatResponse;
|
|
219
|
-
}
|
|
220
|
-
export interface ModelLimits {
|
|
221
|
-
contextWindow?: number;
|
|
222
|
-
maxOutput?: number;
|
|
223
|
-
}
|
|
224
|
-
export interface ModelInfo {
|
|
225
|
-
id: string;
|
|
226
|
-
name: string;
|
|
227
|
-
limits?: ModelLimits;
|
|
228
|
-
supportedEndpoints?: string[];
|
|
229
|
-
}
|
|
230
|
-
export interface ToolResultMeta {
|
|
231
|
-
truncated?: boolean;
|
|
232
|
-
originalBytes?: number;
|
|
233
|
-
transforms: string[];
|
|
234
|
-
}
|
|
235
|
-
export interface ToolResultChunk {
|
|
236
|
-
output: string;
|
|
237
|
-
structured: JsonObject;
|
|
238
|
-
content?: ToolResultContent;
|
|
239
|
-
}
|
|
240
|
-
export interface ToolOutputEnvelope {
|
|
241
|
-
output: string;
|
|
242
|
-
structured?: JsonObject;
|
|
243
|
-
content?: ToolResultContent;
|
|
244
|
-
}
|
|
245
|
-
export interface ToolResult {
|
|
246
|
-
callId: string;
|
|
247
|
-
toolName: string;
|
|
248
|
-
status: "error" | "ok";
|
|
249
|
-
output: string;
|
|
250
|
-
structured: JsonObject;
|
|
251
|
-
content?: ToolResultContent;
|
|
252
|
-
chunks: ToolResultChunk[];
|
|
253
|
-
meta: ToolResultMeta;
|
|
254
|
-
}
|
|
255
|
-
export interface TurnInput {
|
|
256
|
-
sessionId: string;
|
|
257
|
-
turnId: string;
|
|
258
|
-
streaming?: boolean;
|
|
259
|
-
signal?: AbortSignal;
|
|
260
|
-
system?: SystemInput;
|
|
261
|
-
messages?: MessageInput[];
|
|
262
|
-
message: MessageInput;
|
|
263
|
-
}
|
|
264
|
-
export interface TurnState {
|
|
265
|
-
sessionId: string;
|
|
266
|
-
turnId: string;
|
|
267
|
-
system: TextBlock[];
|
|
268
|
-
messages: Message[];
|
|
269
|
-
lastResponse?: ChatResponse;
|
|
270
|
-
toolResults: ToolResult[];
|
|
271
|
-
finalMessage?: IdentifiedMessage;
|
|
272
|
-
}
|
|
273
|
-
export type TurnResultStatus = "completed" | "aborted";
|
|
274
|
-
export interface TurnResult {
|
|
275
|
-
status: TurnResultStatus;
|
|
276
|
-
finalMessage?: IdentifiedMessage;
|
|
277
|
-
state: TurnState;
|
|
278
|
-
}
|
|
279
|
-
export interface ModelExecutionOptions {
|
|
280
|
-
signal?: AbortSignal;
|
|
281
|
-
}
|
|
282
|
-
export interface EngineChatModel {
|
|
283
|
-
model: string;
|
|
284
|
-
maxTokens?: number;
|
|
285
|
-
complete(request: ChatRequest, options?: ModelExecutionOptions): Promise<ChatResponse>;
|
|
286
|
-
stream?(request: ChatRequest, options?: ModelExecutionOptions): AsyncIterable<ChatResponseChunk>;
|
|
287
|
-
getModels?(signal?: AbortSignal): Promise<ModelInfo[]>;
|
|
288
|
-
}
|
|
289
|
-
export interface AgentEventContext {
|
|
290
|
-
sessionId: string;
|
|
291
|
-
turnId: string;
|
|
292
|
-
state: TurnState;
|
|
293
|
-
}
|
|
294
|
-
export interface ToolExecutionContext extends AgentEventContext {
|
|
295
|
-
signal: AbortSignal;
|
|
296
|
-
toolCallId?: string;
|
|
297
|
-
}
|
|
298
|
-
export interface ToolRuntimeStartedEvent {
|
|
299
|
-
type: "tool_started";
|
|
300
|
-
toolCall: ToolUseBlock;
|
|
301
|
-
}
|
|
302
|
-
export interface ToolRuntimeOutputChunkEvent {
|
|
303
|
-
type: "tool_output_chunk";
|
|
304
|
-
toolCall: ToolUseBlock;
|
|
305
|
-
chunk: ToolResultChunk;
|
|
306
|
-
}
|
|
307
|
-
export interface ToolRuntimeCompletedEvent {
|
|
308
|
-
type: "tool_completed";
|
|
309
|
-
toolCall: ToolUseBlock;
|
|
310
|
-
result: ToolResult;
|
|
311
|
-
}
|
|
312
|
-
export interface ToolRuntimeRejectedEvent {
|
|
313
|
-
type: "tool_rejected";
|
|
314
|
-
toolCall: ToolUseBlock;
|
|
315
|
-
result: ToolResult;
|
|
316
|
-
}
|
|
317
|
-
export type ToolRuntimeEvent = ToolRuntimeOutputChunkEvent | ToolRuntimeCompletedEvent | ToolRuntimeRejectedEvent | ToolRuntimeStartedEvent;
|
|
318
|
-
export interface AgentUserMessageEvent {
|
|
319
|
-
type: "user_message";
|
|
320
|
-
message: Message;
|
|
321
|
-
}
|
|
322
|
-
export interface AgentModelRequestEvent {
|
|
323
|
-
type: "model_request";
|
|
324
|
-
request: ChatRequest;
|
|
325
|
-
}
|
|
326
|
-
export interface AgentModelResponseEvent {
|
|
327
|
-
type: "model_response";
|
|
328
|
-
response: ChatResponse;
|
|
329
|
-
}
|
|
330
|
-
export interface AgentAssistantMessageEvent {
|
|
331
|
-
type: "assistant_message";
|
|
332
|
-
message: IdentifiedMessage;
|
|
333
|
-
}
|
|
334
|
-
export interface AgentAssistantChunkEvent {
|
|
335
|
-
type: "assistant_chunk";
|
|
336
|
-
index: number;
|
|
337
|
-
messageId: string;
|
|
338
|
-
chunk: ContentDeltaChunk;
|
|
339
|
-
}
|
|
340
|
-
export interface AgentToolUseMessageEvent {
|
|
341
|
-
type: "tool_use_message";
|
|
342
|
-
message: IdentifiedMessage;
|
|
343
|
-
}
|
|
344
|
-
export interface AgentToolUseChunkEvent {
|
|
345
|
-
type: "tool_use_chunk";
|
|
346
|
-
index: number;
|
|
347
|
-
messageId: string;
|
|
348
|
-
chunk: ToolUseDeltaChunk;
|
|
349
|
-
}
|
|
350
|
-
export interface AgentReasoningMessageEvent {
|
|
351
|
-
type: "reasoning_message";
|
|
352
|
-
message: IdentifiedMessage;
|
|
353
|
-
}
|
|
354
|
-
export interface AgentReasoningChunkEvent {
|
|
355
|
-
type: "reasoning_chunk";
|
|
356
|
-
index: number;
|
|
357
|
-
messageId: string;
|
|
358
|
-
chunk: AnthropicThinkingDeltaChunk | OpenAiReasoningDeltaChunk | OpenAiReasoningSummaryDeltaChunk;
|
|
359
|
-
text: string;
|
|
360
|
-
}
|
|
361
|
-
export interface AgentToolCallEvent {
|
|
362
|
-
type: "tool_call";
|
|
363
|
-
toolCall: ToolUseBlock;
|
|
364
|
-
}
|
|
365
|
-
export interface AgentToolResultEvent {
|
|
366
|
-
type: "tool_result";
|
|
367
|
-
result: ToolResult;
|
|
368
|
-
}
|
|
369
|
-
export interface AgentToolResultMessageEvent {
|
|
370
|
-
type: "tool_result_message";
|
|
371
|
-
message: Message;
|
|
372
|
-
}
|
|
373
|
-
export interface AgentFinalMessageEvent {
|
|
374
|
-
type: "final_message";
|
|
375
|
-
message: IdentifiedMessage;
|
|
376
|
-
}
|
|
377
|
-
export interface AgentTurnCompleteEvent {
|
|
378
|
-
type: "turn_complete";
|
|
379
|
-
state: TurnState;
|
|
380
|
-
}
|
|
381
|
-
export type AgentLifecycleEvent = AgentAssistantChunkEvent | AgentAssistantMessageEvent | AgentFinalMessageEvent | AgentModelRequestEvent | AgentModelResponseEvent | AgentReasoningChunkEvent | AgentReasoningMessageEvent | AgentToolCallEvent | AgentToolUseChunkEvent | AgentToolUseMessageEvent | AgentToolResultEvent | AgentToolResultMessageEvent | AgentTurnCompleteEvent | AgentUserMessageEvent;
|
|
382
|
-
export type AgentEvent = AgentLifecycleEvent | ToolRuntimeEvent;
|
|
383
|
-
export type ToolRuntimeDispatchDecision = {
|
|
384
|
-
action: "reject";
|
|
385
|
-
reason?: string;
|
|
386
|
-
} | {
|
|
387
|
-
action: "run";
|
|
388
|
-
};
|
|
389
|
-
export type ToolRuntimeToolCallHandler = (toolCall: ToolUseBlock, ctx: ToolExecutionContext) => Promise<ToolRuntimeDispatchDecision | undefined> | ToolRuntimeDispatchDecision | undefined;
|
|
390
|
-
export type AgentEventHandler = (event: AgentEvent, ctx: AgentEventContext) => Promise<void> | void;
|
|
391
|
-
export interface ToolRuntime {
|
|
392
|
-
listToolSchemas(): ToolSchema[];
|
|
393
|
-
setTools(tools: AnyToolDefinition[]): void;
|
|
394
|
-
executeCalls(toolCalls: ToolUseBlock[], ctx: ToolExecutionContext): Promise<ToolResult[]>;
|
|
395
|
-
execute(toolCall: ToolUseBlock, ctx: ToolExecutionContext): Promise<ToolResult>;
|
|
396
|
-
}
|
|
397
|
-
export type ToolOutputValue = JsonValue | ToolOutputEnvelope;
|
|
398
|
-
export type ToolGenerator<TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined> = AsyncGenerator<TYield, TReturn, void>;
|
|
399
|
-
export interface ToolDefinition<TInput extends JsonObject = JsonObject, TYield extends ToolOutputValue = ToolOutputValue, TReturn extends ToolOutputValue | undefined = ToolOutputValue | undefined, TSchema extends JsonSchemaObject = JsonSchemaObject> {
|
|
400
|
-
name: string;
|
|
401
|
-
description: string;
|
|
402
|
-
inputSchema: TSchema;
|
|
403
|
-
execute(input: TInput, ctx: ToolExecutionContext): ToolGenerator<TYield, TReturn>;
|
|
404
|
-
}
|
|
405
|
-
export type AnyToolDefinition = ToolDefinition<JsonObject, ToolOutputValue, ToolOutputValue | undefined, JsonSchemaObject>;
|
|
406
|
-
export type Stage = "afterModelResponse" | "afterToolResult" | "afterTurnComplete" | "beforeAssistantAppend" | "beforeFinalOutput" | "beforeModelRequest" | "beforeToolExecution" | "beforeToolResultAppend" | "onUserMessage";
|
|
407
|
-
export interface PayloadByStage {
|
|
408
|
-
onUserMessage: Message;
|
|
409
|
-
beforeModelRequest: ChatRequest;
|
|
410
|
-
afterModelResponse: ChatResponse;
|
|
411
|
-
beforeToolExecution: ToolUseBlock;
|
|
412
|
-
afterToolResult: ToolResult;
|
|
413
|
-
beforeAssistantAppend: Message;
|
|
414
|
-
beforeFinalOutput: Message;
|
|
415
|
-
beforeToolResultAppend: Message;
|
|
416
|
-
afterTurnComplete: TurnState;
|
|
417
|
-
}
|
|
418
|
-
export interface ExtensionContext {
|
|
419
|
-
state: TurnState;
|
|
420
|
-
}
|
|
421
|
-
type Transformer$1<S extends Stage> = (payload: PayloadByStage[S], ctx: ExtensionContext) => PayloadByStage[S] | Promise<PayloadByStage[S]>;
|
|
422
|
-
export type Observer<S extends Stage> = (payload: PayloadByStage[S], ctx: ExtensionContext) => Promise<void> | void;
|
|
423
|
-
export interface TransformerExtensionRegistration<S extends Stage = Stage> {
|
|
424
|
-
id: string;
|
|
425
|
-
stage: S;
|
|
426
|
-
kind: "transformer";
|
|
427
|
-
order: number;
|
|
428
|
-
enabled: boolean;
|
|
429
|
-
run: Transformer$1<S>;
|
|
430
|
-
}
|
|
431
|
-
export interface ObserverExtensionRegistration<S extends Stage = Stage> {
|
|
432
|
-
id: string;
|
|
433
|
-
stage: S;
|
|
434
|
-
kind: "observer";
|
|
435
|
-
order: number;
|
|
436
|
-
enabled: boolean;
|
|
437
|
-
run: Observer<S>;
|
|
438
|
-
}
|
|
439
|
-
export type ExtensionRegistration<S extends Stage = Stage> = ObserverExtensionRegistration<S> | TransformerExtensionRegistration<S>;
|
|
440
|
-
export type AnyExtensionRegistration = {
|
|
441
|
-
[S in Stage]: ExtensionRegistration<S>;
|
|
442
|
-
}[Stage];
|
|
443
|
-
export interface ExtensionRegistry {
|
|
444
|
-
register(extension: AnyExtensionRegistration): void;
|
|
445
|
-
runTransformers<S extends Stage>(stage: S, payload: PayloadByStage[S], ctx: ExtensionContext): Promise<PayloadByStage[S]>;
|
|
446
|
-
runObservers<S extends Stage>(stage: S, payload: PayloadByStage[S], ctx: ExtensionContext): Promise<void>;
|
|
447
|
-
}
|
|
448
|
-
export interface RunTurnDeps {
|
|
449
|
-
registry: ExtensionRegistry;
|
|
450
|
-
chatModel: EngineChatModel;
|
|
451
|
-
toolRuntime: ToolRuntime;
|
|
452
|
-
onEvent?: AgentEventHandler;
|
|
453
|
-
}
|
|
454
|
-
export type AgentInput = MessageInput | string;
|
|
455
|
-
export interface AgentSendOptions {
|
|
456
|
-
streaming?: boolean;
|
|
457
|
-
signal?: AbortSignal;
|
|
458
|
-
}
|
|
459
|
-
export interface AgentOptions {
|
|
460
|
-
sessionId?: string;
|
|
461
|
-
systemPrompt?: string;
|
|
462
|
-
messages?: MessageInput[];
|
|
463
|
-
message?: AgentInput;
|
|
464
|
-
onEvent?: AgentEventHandler;
|
|
465
|
-
onToolCall?: ToolRuntimeToolCallHandler;
|
|
466
|
-
registry?: ExtensionRegistry;
|
|
467
|
-
extensions?: AnyExtensionRegistration[];
|
|
468
|
-
chatModel?: EngineChatModel;
|
|
469
|
-
tools?: AnyToolDefinition[];
|
|
470
|
-
}
|
|
471
|
-
export interface OpenAiFunctionCall {
|
|
472
|
-
type: "function_call";
|
|
473
|
-
call_id: string;
|
|
474
|
-
name: string;
|
|
475
|
-
arguments: string;
|
|
476
|
-
}
|
|
477
|
-
export interface OpenAiOutputTextPart {
|
|
478
|
-
type: "output_text";
|
|
479
|
-
text: string;
|
|
480
|
-
}
|
|
481
|
-
export interface OpenAiRefusalPart {
|
|
482
|
-
type: "refusal";
|
|
483
|
-
refusal: string;
|
|
484
|
-
}
|
|
485
|
-
export interface OpenAiOutputMessage {
|
|
486
|
-
type: "message";
|
|
487
|
-
content?: Array<OpenAiOutputTextPart | OpenAiRefusalPart>;
|
|
488
|
-
role?: string;
|
|
489
|
-
status?: string;
|
|
490
|
-
}
|
|
491
|
-
export interface OpenAiReasoningOutputItem {
|
|
492
|
-
type: "reasoning";
|
|
493
|
-
content?: Array<{
|
|
494
|
-
text?: string;
|
|
495
|
-
type?: string;
|
|
496
|
-
}>;
|
|
497
|
-
encrypted_content?: string;
|
|
498
|
-
id?: string;
|
|
499
|
-
status?: string;
|
|
500
|
-
summary?: OpenAiReasoningSummaryText[];
|
|
501
|
-
text?: string;
|
|
502
|
-
}
|
|
503
|
-
export type OpenAiResponsesOutputItem = JsonObject | OpenAiFunctionCall | OpenAiOutputMessage | OpenAiReasoningOutputItem;
|
|
504
|
-
export declare class Agent {
|
|
505
|
-
readonly deps: RunTurnDeps;
|
|
506
|
-
readonly sessionId: string;
|
|
507
|
-
private _systemPrompt;
|
|
508
|
-
messages: Message[];
|
|
509
|
-
readonly defaultMessage?: Message;
|
|
510
|
-
turnIndex: number;
|
|
511
|
-
constructor(options?: AgentOptions);
|
|
512
|
-
get systemPrompt(): string;
|
|
513
|
-
setTools(tools?: AgentOptions["tools"]): void;
|
|
514
|
-
setSystemPrompt(systemPrompt: string, options?: {
|
|
515
|
-
resetMessages?: boolean;
|
|
516
|
-
}): void;
|
|
517
|
-
/**
|
|
518
|
-
* Replace the chat model used for subsequent turns. Existing conversation
|
|
519
|
-
* state is preserved; the next call to {@link send} uses the new model.
|
|
520
|
-
* Useful for runtime model switching (e.g. via a `/model` slash command).
|
|
521
|
-
*/
|
|
522
|
-
setChatModel(chatModel: RunTurnDeps["chatModel"]): void;
|
|
523
|
-
send(input?: AgentInput | undefined, options?: AgentSendOptions): Promise<TurnResult>;
|
|
524
|
-
}
|
|
525
|
-
export declare function createExtensionRegistry(): ExtensionRegistry;
|
|
526
|
-
export declare function runTurn(input: TurnInput, deps: RunTurnDeps): Promise<TurnResult>;
|
|
527
25
|
|
|
528
|
-
|
|
26
|
+
declare function createExtensionRegistry(): ExtensionRegistry;
|
|
27
|
+
|
|
28
|
+
declare function runTurn(input: TurnInput, deps: RunTurnDeps): Promise<TurnResult>;
|
|
29
|
+
|
|
30
|
+
export { Agent, AgentInput, AgentOptions, AgentSendOptions, ExtensionRegistry, RunTurnDeps, TurnInput, TurnResult, createExtensionRegistry, runTurn };
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x29ad58,_0x357f24){var _0x6adfbf={_0x573771:0x11d,_0x11ec8f:0xa8,_0x4b04de:0xab,_0x4e7df6:0xad,_0x38ae06:0xb0,_0x4e3774:0xa9,_0xe48d42:0xaa,_0x11fc21:0xac,_0x593091:0xab,_0x38a18f:0x117,_0x35bed1:0x11b,_0x5034b5:0x120,_0x2339eb:0x116,_0x1f91e0:0x11a,_0x55fd8b:0x119},_0x8c2310={_0x4b6cb7:0x22c},_0x498926={_0x51ec47:0x1ba};function _0xfc9f7e(_0x184583,_0x23c375,_0x5ea11b,_0x1d482e){return _0x50b5(_0x5ea11b- -_0x498926._0x51ec47,_0x23c375);}var _0x51cb65=_0x29ad58();function _0xe3f93b(_0x47fc39,_0x40f3b0,_0x7fbe3f,_0x500849){return _0x50b5(_0x500849- -_0x8c2310._0x4b6cb7,_0x40f3b0);}while(!![]){try{var _0x34a47c=parseInt(_0xe3f93b(-0x120,-0x123,-_0x6adfbf._0x573771,-0x121))/0x1*(parseInt(_0xfc9f7e(-_0x6adfbf._0x11ec8f,-0xa8,-_0x6adfbf._0x4b04de,-_0x6adfbf._0x4e7df6))/0x2)+-parseInt(_0xfc9f7e(-0xa9,-0xa8,-0xa6,-0xa4))/0x3+parseInt(_0xfc9f7e(-_0x6adfbf._0x38ae06,-_0x6adfbf._0x4e3774,-_0x6adfbf._0xe48d42,-0xa5))/0x4*(parseInt(_0xfc9f7e(-0xa7,-0xb0,-_0x6adfbf._0x11fc21,-_0x6adfbf._0x593091))/0x5)+-parseInt(_0xfc9f7e(-0xac,-_0x6adfbf._0x11ec8f,-0xa8,-0xa2))/0x6*(-parseInt(_0xe3f93b(-0x116,-0x11a,-0x119,-_0x6adfbf._0x38a18f))/0x7)+parseInt(_0xe3f93b(-_0x6adfbf._0x35bed1,-_0x6adfbf._0x5034b5,-0x11f,-0x120))/0x8*(parseInt(_0xe3f93b(-_0x6adfbf._0x2339eb,-_0x6adfbf._0x1f91e0,-_0x6adfbf._0x573771,-_0x6adfbf._0x35bed1))/0x9)+parseInt(_0xe3f93b(-_0x6adfbf._0x573771,-0x120,-0x121,-0x11f))/0xa+-parseInt(_0xe3f93b(-0x11a,-0x11d,-0x11e,-_0x6adfbf._0x55fd8b))/0xb;if(_0x34a47c===_0x357f24)break;else _0x51cb65['push'](_0x51cb65['shift']());}catch(_0x1a6e41){_0x51cb65['push'](_0x51cb65['shift']());}}}(_0x49f0,0x5dac0));import{Agent,createExtensionRegistry,runTurn}from'../chunk-VFTQW5WK.js';import'../chunk-G2FR4UGO.js';import'../chunk-X7VAACWY.js';function _0x49f0(){var _0x21b9ae=['mvfYq0vQCa','mteXmdy2ngH3B3flvW','mteYmtqXmeHQBfbJAW','nwrzC3Hjza','mti1ndK2ne53EuTHCa','mtC0mZeXnKLmr2jMwG','mtH4rMXXu3C','mZy0mdaZoev2ugDWAG','mtaZnJi0mJLtDLvUs04','mJiWmJa2nKz0EwfyEq','n01pD0LprW'];_0x49f0=function(){return _0x21b9ae;};return _0x49f0();}function _0x50b5(_0x2d0492,_0x470721){_0x2d0492=_0x2d0492-0x10b;var _0x49f071=_0x49f0();var _0x50b514=_0x49f071[_0x2d0492];if(_0x50b5['xeiTxJ']===undefined){var _0x5b293d=function(_0x508237){var _0x1933d7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x1e10ff='',_0x56ad1f='';for(var _0x214bcb=0x0,_0x4ac3dc,_0x556221,_0x40f0dd=0x0;_0x556221=_0x508237['charAt'](_0x40f0dd++);~_0x556221&&(_0x4ac3dc=_0x214bcb%0x4?_0x4ac3dc*0x40+_0x556221:_0x556221,_0x214bcb++%0x4)?_0x1e10ff+=String['fromCharCode'](0xff&_0x4ac3dc>>(-0x2*_0x214bcb&0x6)):0x0){_0x556221=_0x1933d7['indexOf'](_0x556221);}for(var _0x36a7fc=0x0,_0x3c57f7=_0x1e10ff['length'];_0x36a7fc<_0x3c57f7;_0x36a7fc++){_0x56ad1f+='%'+('00'+_0x1e10ff['charCodeAt'](_0x36a7fc)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x56ad1f);};_0x50b5['RXwvFy']=_0x5b293d,_0x50b5['qbJjmC']={},_0x50b5['xeiTxJ']=!![];}var _0x99703d=_0x49f071[0x0],_0x57fb53=_0x2d0492+_0x99703d,_0x2802f4=_0x50b5['qbJjmC'][_0x57fb53];return!_0x2802f4?(_0x50b514=_0x50b5['RXwvFy'](_0x50b514),_0x50b5['qbJjmC'][_0x57fb53]=_0x50b514):_0x50b514=_0x2802f4,_0x50b514;}export{Agent,createExtensionRegistry,runTurn};
|