poe-code 3.0.225 → 3.0.226
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/agent.d.ts +352 -0
- package/dist/agent.js +16713 -0
- package/dist/agent.js.map +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +236 -215
- package/dist/index.js.map +4 -4
- package/package.json +5 -1
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
export type ToolResultTextPart = {
|
|
2
|
+
type: "text";
|
|
3
|
+
text: string;
|
|
4
|
+
};
|
|
5
|
+
export type ToolResultImagePart = {
|
|
6
|
+
type: "image";
|
|
7
|
+
mimeType: string;
|
|
8
|
+
data: string;
|
|
9
|
+
};
|
|
10
|
+
export type ToolResultErrorPart = {
|
|
11
|
+
type: "error";
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
retriable: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type ToolResultPart = ToolResultTextPart | ToolResultImagePart | ToolResultErrorPart;
|
|
17
|
+
export type ToolResult = string | ToolResultPart | ToolResultPart[];
|
|
18
|
+
export type SpawnMode = "yolo" | "edit" | "read";
|
|
19
|
+
export type ChatMessage = {
|
|
20
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
21
|
+
content: string | ToolResultPart[];
|
|
22
|
+
reasoning_content?: string;
|
|
23
|
+
reasoning?: string;
|
|
24
|
+
thinking?: Array<{
|
|
25
|
+
text: string;
|
|
26
|
+
signature?: string;
|
|
27
|
+
}>;
|
|
28
|
+
redacted_thinking?: Array<{
|
|
29
|
+
data: string;
|
|
30
|
+
}>;
|
|
31
|
+
reasoning_details?: unknown[];
|
|
32
|
+
name?: string;
|
|
33
|
+
toolCallId?: string;
|
|
34
|
+
tool_calls?: Array<{
|
|
35
|
+
id: string;
|
|
36
|
+
type: "function";
|
|
37
|
+
function: {
|
|
38
|
+
name: string;
|
|
39
|
+
arguments: string;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
export type AcpModelRequestMessage = Omit<ChatMessage, "toolCallId"> & {
|
|
44
|
+
tool_call_id?: string;
|
|
45
|
+
};
|
|
46
|
+
export type ToolCallRecord = {
|
|
47
|
+
intentId: string;
|
|
48
|
+
tool: string;
|
|
49
|
+
args: unknown;
|
|
50
|
+
status: "success" | "error";
|
|
51
|
+
result?: unknown;
|
|
52
|
+
error?: string;
|
|
53
|
+
};
|
|
54
|
+
export type RunResult = {
|
|
55
|
+
output: string;
|
|
56
|
+
stdout: string;
|
|
57
|
+
summary?: string;
|
|
58
|
+
messages: ChatMessage[];
|
|
59
|
+
toolCalls: ToolCallRecord[];
|
|
60
|
+
usage?: UsageInfo;
|
|
61
|
+
logFile?: string;
|
|
62
|
+
exitCode: number;
|
|
63
|
+
stderr: string;
|
|
64
|
+
};
|
|
65
|
+
export type UsageInfo = {
|
|
66
|
+
inputTokens: number;
|
|
67
|
+
outputTokens: number;
|
|
68
|
+
cachedTokens: number;
|
|
69
|
+
cacheCreationTokens: number;
|
|
70
|
+
};
|
|
71
|
+
export type ForkResult = {
|
|
72
|
+
output: string;
|
|
73
|
+
messages: ChatMessage[];
|
|
74
|
+
};
|
|
75
|
+
export type ToolContext = {
|
|
76
|
+
fork(prompt: string): Promise<ForkResult>;
|
|
77
|
+
spawn(prompt: string): Promise<{
|
|
78
|
+
output: string;
|
|
79
|
+
messages: ChatMessage[];
|
|
80
|
+
}>;
|
|
81
|
+
signal: AbortSignal;
|
|
82
|
+
notify?(notification: {
|
|
83
|
+
event: string;
|
|
84
|
+
message?: string;
|
|
85
|
+
data?: unknown;
|
|
86
|
+
}): void | Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
export type ToolEvent = {
|
|
89
|
+
type: "message.delta";
|
|
90
|
+
content: string;
|
|
91
|
+
} | {
|
|
92
|
+
type: "progress";
|
|
93
|
+
message: string;
|
|
94
|
+
};
|
|
95
|
+
export type Tool = {
|
|
96
|
+
name: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
inputSchema?: unknown;
|
|
99
|
+
visibility?: "model" | "skill" | "internal";
|
|
100
|
+
policy?: {
|
|
101
|
+
read: boolean;
|
|
102
|
+
edit: boolean;
|
|
103
|
+
validate?(args: unknown, mode: SpawnMode): string | void | Promise<string | void>;
|
|
104
|
+
};
|
|
105
|
+
call(args: unknown, context: ToolContext): ToolResult | Promise<ToolResult> | AsyncGenerator<ToolEvent, ToolResult, void>;
|
|
106
|
+
};
|
|
107
|
+
export type McpServerConfig = {
|
|
108
|
+
name: string;
|
|
109
|
+
command: string;
|
|
110
|
+
args?: string[];
|
|
111
|
+
env?: Record<string, string>;
|
|
112
|
+
timeout?: number;
|
|
113
|
+
visibility?: "model" | "skill";
|
|
114
|
+
};
|
|
115
|
+
export type McpServerMap = Record<string, Omit<McpServerConfig, "name" | "visibility">>;
|
|
116
|
+
export type PromptContext = {
|
|
117
|
+
baseSystemPrompt?: string;
|
|
118
|
+
system?: string;
|
|
119
|
+
userPrompt: string;
|
|
120
|
+
metadata?: Record<string, unknown>;
|
|
121
|
+
};
|
|
122
|
+
export type Logger = {
|
|
123
|
+
debug?(message: string, data?: unknown): void;
|
|
124
|
+
info?(message: string, data?: unknown): void;
|
|
125
|
+
warn?(message: string, data?: unknown): void;
|
|
126
|
+
error?(message: string, data?: unknown): void;
|
|
127
|
+
};
|
|
128
|
+
export type ProviderStreamEvent = {
|
|
129
|
+
type: "text";
|
|
130
|
+
text: string;
|
|
131
|
+
} | {
|
|
132
|
+
type: "thinking";
|
|
133
|
+
text: string;
|
|
134
|
+
signature?: string;
|
|
135
|
+
} | {
|
|
136
|
+
type: "redacted_thinking";
|
|
137
|
+
data: string;
|
|
138
|
+
} | {
|
|
139
|
+
type: "reasoning_details";
|
|
140
|
+
payload: unknown;
|
|
141
|
+
} | {
|
|
142
|
+
type: "tool_use_delta";
|
|
143
|
+
id: string;
|
|
144
|
+
name?: string;
|
|
145
|
+
argsDelta?: string;
|
|
146
|
+
} | {
|
|
147
|
+
type: "tool_use_complete";
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
args: unknown;
|
|
151
|
+
} | {
|
|
152
|
+
type: "tool_use_json_parse_error";
|
|
153
|
+
id: string;
|
|
154
|
+
raw: string;
|
|
155
|
+
error: string;
|
|
156
|
+
} | {
|
|
157
|
+
type: "usage";
|
|
158
|
+
inputTokens: number;
|
|
159
|
+
outputTokens: number;
|
|
160
|
+
cachedTokens: number;
|
|
161
|
+
cacheCreationTokens: number;
|
|
162
|
+
} | {
|
|
163
|
+
type: "stop";
|
|
164
|
+
reason: "end_turn" | "tool_use" | "max_tokens" | "error";
|
|
165
|
+
};
|
|
166
|
+
export type AcpModel = {
|
|
167
|
+
complete(request: {
|
|
168
|
+
messages: AcpModelRequestMessage[];
|
|
169
|
+
tools: Array<{
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
inputSchema?: unknown;
|
|
173
|
+
}>;
|
|
174
|
+
signal: AbortSignal;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
events: AsyncIterable<ProviderStreamEvent>;
|
|
177
|
+
}>;
|
|
178
|
+
};
|
|
179
|
+
export type ProviderContext = {
|
|
180
|
+
fetch: typeof fetch;
|
|
181
|
+
signal?: AbortSignal;
|
|
182
|
+
logger?: Logger;
|
|
183
|
+
options: unknown;
|
|
184
|
+
};
|
|
185
|
+
export type Provider = {
|
|
186
|
+
name: string;
|
|
187
|
+
supports(modelId: string): boolean;
|
|
188
|
+
createModel(modelId: string, context: ProviderContext): AcpModel | Promise<AcpModel>;
|
|
189
|
+
};
|
|
190
|
+
export type ToolUseContext = {
|
|
191
|
+
tool: string;
|
|
192
|
+
args: unknown;
|
|
193
|
+
intentId: string;
|
|
194
|
+
result?: unknown;
|
|
195
|
+
error?: string;
|
|
196
|
+
session: Map<string, unknown>;
|
|
197
|
+
messages: ChatMessage[];
|
|
198
|
+
signal: AbortSignal;
|
|
199
|
+
};
|
|
200
|
+
export type SessionStartContext = {
|
|
201
|
+
session: Map<string, unknown>;
|
|
202
|
+
messages: ChatMessage[];
|
|
203
|
+
signal: AbortSignal;
|
|
204
|
+
};
|
|
205
|
+
export type UserPromptSubmitContext = {
|
|
206
|
+
prompt: string;
|
|
207
|
+
messages: ChatMessage[];
|
|
208
|
+
signal: AbortSignal;
|
|
209
|
+
};
|
|
210
|
+
export type IterationContext = {
|
|
211
|
+
iterationNumber: number;
|
|
212
|
+
tokenCount: number;
|
|
213
|
+
messages: ChatMessage[];
|
|
214
|
+
signal: AbortSignal;
|
|
215
|
+
fork(prompt: string): Promise<ForkResult>;
|
|
216
|
+
complete(messages: ChatMessage[]): Promise<string>;
|
|
217
|
+
};
|
|
218
|
+
export type PreCompactionContext = {
|
|
219
|
+
tokenCount: number;
|
|
220
|
+
force: boolean;
|
|
221
|
+
messages: ChatMessage[];
|
|
222
|
+
signal: AbortSignal;
|
|
223
|
+
};
|
|
224
|
+
export type PostCompactionContext = {
|
|
225
|
+
tokenCount: number;
|
|
226
|
+
summary: string;
|
|
227
|
+
droppedMessages: ChatMessage[];
|
|
228
|
+
messages: ChatMessage[];
|
|
229
|
+
signal: AbortSignal;
|
|
230
|
+
};
|
|
231
|
+
export type NotificationContext = {
|
|
232
|
+
event: string;
|
|
233
|
+
message?: string;
|
|
234
|
+
data?: unknown;
|
|
235
|
+
messages: ChatMessage[];
|
|
236
|
+
signal: AbortSignal;
|
|
237
|
+
};
|
|
238
|
+
export type StopContext = {
|
|
239
|
+
status: "completed" | "error";
|
|
240
|
+
output?: string;
|
|
241
|
+
error?: Error;
|
|
242
|
+
toolCalls: ToolCallRecord[];
|
|
243
|
+
messages: ChatMessage[];
|
|
244
|
+
signal: AbortSignal;
|
|
245
|
+
};
|
|
246
|
+
export type HookDecision = "skip" | "abort" | {
|
|
247
|
+
reject: string;
|
|
248
|
+
} | void;
|
|
249
|
+
export type PluginApi = {
|
|
250
|
+
addTool(tool: Tool): void;
|
|
251
|
+
addMcp(config: McpServerConfig): void;
|
|
252
|
+
getTool(name: string): Tool | undefined;
|
|
253
|
+
};
|
|
254
|
+
export type AgentPlugin = {
|
|
255
|
+
name: string;
|
|
256
|
+
tools?: Tool[];
|
|
257
|
+
providers?: Provider[];
|
|
258
|
+
prompt?(context: PromptContext): PromptContext | Promise<PromptContext>;
|
|
259
|
+
hooks?: {
|
|
260
|
+
sessionStart?(context: SessionStartContext): HookDecision | Promise<HookDecision>;
|
|
261
|
+
userPromptSubmit?(context: UserPromptSubmitContext): HookDecision | Promise<HookDecision>;
|
|
262
|
+
preToolUse?(context: ToolUseContext): HookDecision | Promise<HookDecision>;
|
|
263
|
+
postToolUse?(context: ToolUseContext): HookDecision | Promise<HookDecision>;
|
|
264
|
+
preIteration?(context: IterationContext): HookDecision | Promise<HookDecision>;
|
|
265
|
+
postIteration?(context: IterationContext): HookDecision | Promise<HookDecision>;
|
|
266
|
+
preCompaction?(context: PreCompactionContext): HookDecision | Promise<HookDecision>;
|
|
267
|
+
postCompaction?(context: PostCompactionContext): HookDecision | Promise<HookDecision>;
|
|
268
|
+
notification?(context: NotificationContext): HookDecision | Promise<HookDecision>;
|
|
269
|
+
stop?(context: StopContext): HookDecision | Promise<HookDecision>;
|
|
270
|
+
};
|
|
271
|
+
setup?(api: PluginApi): void | Promise<void>;
|
|
272
|
+
dispose?(): void | Promise<void>;
|
|
273
|
+
};
|
|
274
|
+
export type AcpEvent = {
|
|
275
|
+
type: "message.delta";
|
|
276
|
+
content: string;
|
|
277
|
+
} | {
|
|
278
|
+
type: "tool.intent";
|
|
279
|
+
intentId: string;
|
|
280
|
+
tool: string;
|
|
281
|
+
args: unknown;
|
|
282
|
+
} | {
|
|
283
|
+
type: "tool.result";
|
|
284
|
+
intentId: string;
|
|
285
|
+
result: unknown;
|
|
286
|
+
} | {
|
|
287
|
+
type: "tool.error";
|
|
288
|
+
intentId: string;
|
|
289
|
+
error: string;
|
|
290
|
+
} | {
|
|
291
|
+
type: "progress";
|
|
292
|
+
message: string;
|
|
293
|
+
} | {
|
|
294
|
+
type: "usage";
|
|
295
|
+
usage: UsageInfo;
|
|
296
|
+
} | {
|
|
297
|
+
type: "session.complete";
|
|
298
|
+
result: RunResult;
|
|
299
|
+
} | {
|
|
300
|
+
type: "session.error";
|
|
301
|
+
error: Error;
|
|
302
|
+
};
|
|
303
|
+
export type AgentRunOptions = {
|
|
304
|
+
signal?: AbortSignal;
|
|
305
|
+
resume?: RunResult;
|
|
306
|
+
skills?: string[];
|
|
307
|
+
maxIterations?: number;
|
|
308
|
+
apiKey?: string;
|
|
309
|
+
baseUrl?: string;
|
|
310
|
+
fetch?: typeof fetch;
|
|
311
|
+
cwd?: string;
|
|
312
|
+
baseSystemPrompt?: string;
|
|
313
|
+
acpModel?: AcpModel;
|
|
314
|
+
onStdout?: (chunk: string) => void;
|
|
315
|
+
logPath?: string;
|
|
316
|
+
};
|
|
317
|
+
export type AgentSession = {
|
|
318
|
+
events: AsyncIterable<AcpEvent>;
|
|
319
|
+
acknowledge(intentId: string, result: {
|
|
320
|
+
status: "success" | "error";
|
|
321
|
+
result: unknown;
|
|
322
|
+
}): void;
|
|
323
|
+
dispose(): Promise<void>;
|
|
324
|
+
};
|
|
325
|
+
export type AgentBuilder = {
|
|
326
|
+
model(model: string): AgentBuilder;
|
|
327
|
+
use(plugin: AgentPlugin): AgentBuilder;
|
|
328
|
+
tools(...tools: Tool[]): AgentBuilder;
|
|
329
|
+
mcp(configs: McpServerMap): AgentBuilder;
|
|
330
|
+
mcp(...configs: McpServerConfig[]): AgentBuilder;
|
|
331
|
+
acp(prompt: string, options?: AgentRunOptions): Promise<AgentSession>;
|
|
332
|
+
run(prompt: string, options?: AgentRunOptions): Promise<RunResult>;
|
|
333
|
+
stream(prompt: string, options?: AgentRunOptions): AsyncIterable<AcpEvent>;
|
|
334
|
+
};
|
|
335
|
+
export type OpenaiProviderPluginOptions = {
|
|
336
|
+
baseUrl?: string;
|
|
337
|
+
apiKey?: string;
|
|
338
|
+
organization?: string;
|
|
339
|
+
defaultHeaders?: Record<string, string>;
|
|
340
|
+
timeout?: number;
|
|
341
|
+
maxRetries?: number;
|
|
342
|
+
};
|
|
343
|
+
export type OpenaiResponsesPluginOptions = OpenaiProviderPluginOptions & {
|
|
344
|
+
project?: string;
|
|
345
|
+
reasoningEffort?: "minimal" | "low" | "medium" | "high";
|
|
346
|
+
reasoningSummary?: "auto" | "concise" | "detailed";
|
|
347
|
+
include?: string[];
|
|
348
|
+
};
|
|
349
|
+
export declare const agent: () => AgentBuilder;
|
|
350
|
+
export declare const openaiChatCompletionsPlugin: (options?: OpenaiProviderPluginOptions) => AgentPlugin;
|
|
351
|
+
export declare const openaiResponsesPlugin: (options?: OpenaiResponsesPluginOptions) => AgentPlugin;
|
|
352
|
+
export declare const systemPromptPlugin: () => AgentPlugin;
|