agent-lattice 0.9.12
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/README.md +652 -0
- package/dist/index.d.ts +529 -0
- package/dist/index.js +7 -0
- package/package.json +40 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
import type { DocumentBlockParam, ImageBlockParam, TextBlockParam } from "@anthropic-ai/sdk/resources/messages.mjs";
|
|
2
|
+
import type { OAuthClientProvider } from "@modelcontextprotocol/sdk/client/auth.js";
|
|
3
|
+
import { type StdioServerParameters } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
4
|
+
import { type StreamableHTTPClientTransportOptions } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
5
|
+
import type { RunEvent, RunTree, RunTreeConfig } from "langsmith/run_trees";
|
|
6
|
+
import { z } from "zod/v4";
|
|
7
|
+
export type TextBlock = TextBlockParam;
|
|
8
|
+
export type ImageBlock = ImageBlockParam;
|
|
9
|
+
export type DocumentBlock = DocumentBlockParam;
|
|
10
|
+
export type ToolUseBlock = {
|
|
11
|
+
type: "tool_use";
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
input: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
export type ToolResultBlock = {
|
|
17
|
+
type: "tool_result";
|
|
18
|
+
tool_use_id: string;
|
|
19
|
+
content: string | ContentBlock[];
|
|
20
|
+
is_error?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export type ContentBlock = TextBlock | ImageBlock | DocumentBlock | ToolUseBlock | ToolResultBlock;
|
|
23
|
+
export type AgentLikeEvent = SDKMessage | TeamRunnerMessage;
|
|
24
|
+
export type AgentLike = {
|
|
25
|
+
query(prompt: string | ContentBlock[], options?: QueryOptions): AsyncGenerator<AgentLikeEvent>;
|
|
26
|
+
prompt(prompt: string | ContentBlock[], options?: QueryOptions): Promise<SDKResultMessage>;
|
|
27
|
+
};
|
|
28
|
+
export type DelegateWaitMode = "result" | "accepted";
|
|
29
|
+
export type AgentRuntimeSource = {
|
|
30
|
+
kind: "root" | "team_member" | "agent";
|
|
31
|
+
name?: string;
|
|
32
|
+
team?: string;
|
|
33
|
+
member?: string;
|
|
34
|
+
mailbox?: string;
|
|
35
|
+
};
|
|
36
|
+
export type AgentRuntimeDelegateInput = {
|
|
37
|
+
name: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
agent: AgentLike;
|
|
40
|
+
task: string;
|
|
41
|
+
wait?: DelegateWaitMode;
|
|
42
|
+
targetMailboxId?: string;
|
|
43
|
+
workspaceGrants?: WorkspaceGrantInput[];
|
|
44
|
+
};
|
|
45
|
+
export type AgentRuntimeDelegateResult = {
|
|
46
|
+
status: "completed" | "accepted";
|
|
47
|
+
content: string;
|
|
48
|
+
request: TeamMessage;
|
|
49
|
+
reply?: TeamMessage;
|
|
50
|
+
result?: SDKResultMessage;
|
|
51
|
+
workspaceGrants?: WorkspaceGrant[];
|
|
52
|
+
};
|
|
53
|
+
export type WorkspaceAccess = "read" | "write" | "execute";
|
|
54
|
+
export type WorkspaceGrantInput = {
|
|
55
|
+
root: string;
|
|
56
|
+
access?: WorkspaceAccess[];
|
|
57
|
+
reason?: string;
|
|
58
|
+
expiresAt?: number;
|
|
59
|
+
};
|
|
60
|
+
export type WorkspaceGrant = WorkspaceGrantInput & {
|
|
61
|
+
kind: "workspace";
|
|
62
|
+
root: string;
|
|
63
|
+
access: WorkspaceAccess[];
|
|
64
|
+
grantor?: AgentRuntimeSource;
|
|
65
|
+
grantee?: AgentRuntimeSource;
|
|
66
|
+
workItemId?: string;
|
|
67
|
+
};
|
|
68
|
+
export type RuntimePermissions = {
|
|
69
|
+
workspaceGrants?: WorkspaceGrantInput[];
|
|
70
|
+
};
|
|
71
|
+
export type PermissionDenialReasonCode = "outside_allowed_roots" | "grant_not_authorized" | "expired_grant";
|
|
72
|
+
export type PermissionDenial = {
|
|
73
|
+
status: "permission_denied";
|
|
74
|
+
tool: string;
|
|
75
|
+
operation: WorkspaceAccess;
|
|
76
|
+
requestedPath?: string;
|
|
77
|
+
reasonCode: PermissionDenialReasonCode;
|
|
78
|
+
reason: string;
|
|
79
|
+
allowedRoots: string[];
|
|
80
|
+
suggestedNextStep: string;
|
|
81
|
+
};
|
|
82
|
+
export type AgentRuntimeContext = {
|
|
83
|
+
source: AgentRuntimeSource;
|
|
84
|
+
permissions: RuntimePermissions;
|
|
85
|
+
delegate(input: AgentRuntimeDelegateInput): Promise<AgentRuntimeDelegateResult>;
|
|
86
|
+
emit(message: TeamRunnerMessage): void;
|
|
87
|
+
};
|
|
88
|
+
export type ContextTraceEventType = "run_start" | "user_message" | "model_request" | "assistant_message" | "tool_use" | "tool_result" | "team_message" | "result" | "error";
|
|
89
|
+
export type ContextTraceEvent = {
|
|
90
|
+
version: 1;
|
|
91
|
+
timestamp: string;
|
|
92
|
+
session_id: string;
|
|
93
|
+
run_id: string;
|
|
94
|
+
parent_run_id?: string;
|
|
95
|
+
seq: number;
|
|
96
|
+
source: AgentRuntimeSource;
|
|
97
|
+
type: ContextTraceEventType;
|
|
98
|
+
data: Record<string, unknown>;
|
|
99
|
+
};
|
|
100
|
+
export type ContextTracer = {
|
|
101
|
+
failOnError?: boolean;
|
|
102
|
+
onEvent(event: ContextTraceEvent): Promise<void> | void;
|
|
103
|
+
flush?(): Promise<void>;
|
|
104
|
+
close?(): Promise<void>;
|
|
105
|
+
};
|
|
106
|
+
export type JsonlContextTracerOptions = {
|
|
107
|
+
path?: string;
|
|
108
|
+
dir?: string;
|
|
109
|
+
redact?: (event: ContextTraceEvent) => ContextTraceEvent | undefined;
|
|
110
|
+
failOnError?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type LangSmithKVMap = Record<string, unknown>;
|
|
113
|
+
export type LangSmithRunTreeConfig = RunTreeConfig;
|
|
114
|
+
export type LangSmithRunEvent = RunEvent;
|
|
115
|
+
export type LangSmithRunTreeLike = RunTree;
|
|
116
|
+
export type LangSmithRunTreeConstructor = new (config: LangSmithRunTreeConfig) => LangSmithRunTreeLike;
|
|
117
|
+
export type LangSmithWriteReplicaConfig = NonNullable<LangSmithRunTreeConfig["replicas"]>[number];
|
|
118
|
+
export type LangSmithContextTracerOptions = {
|
|
119
|
+
RunTree?: LangSmithRunTreeConstructor;
|
|
120
|
+
runTree?: (config: LangSmithRunTreeConfig) => LangSmithRunTreeLike;
|
|
121
|
+
projectName?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
apiUrl?: string;
|
|
124
|
+
apiKey?: string;
|
|
125
|
+
workspaceId?: string;
|
|
126
|
+
client?: LangSmithRunTreeConfig["client"];
|
|
127
|
+
tags?: string[];
|
|
128
|
+
metadata?: LangSmithKVMap;
|
|
129
|
+
redact?: (event: ContextTraceEvent) => ContextTraceEvent | undefined;
|
|
130
|
+
failOnError?: boolean;
|
|
131
|
+
};
|
|
132
|
+
export type ModelMessage = {
|
|
133
|
+
role: "user" | "assistant";
|
|
134
|
+
content: string | ContentBlock[];
|
|
135
|
+
};
|
|
136
|
+
export type AssistantModelMessage = {
|
|
137
|
+
role: "assistant";
|
|
138
|
+
content: ContentBlock[];
|
|
139
|
+
};
|
|
140
|
+
export type ModelToolDefinition = {
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
input_schema: Record<string, unknown>;
|
|
144
|
+
};
|
|
145
|
+
export type ModelRequest = {
|
|
146
|
+
model: string;
|
|
147
|
+
systemPrompt?: string;
|
|
148
|
+
maxTokens: number;
|
|
149
|
+
messages: ModelMessage[];
|
|
150
|
+
tools: ModelToolDefinition[];
|
|
151
|
+
stream: boolean;
|
|
152
|
+
onStreamEvent?: (event: Record<string, unknown>) => void;
|
|
153
|
+
signal?: AbortSignal;
|
|
154
|
+
};
|
|
155
|
+
export interface ModelClient {
|
|
156
|
+
createMessage(request: ModelRequest): Promise<AssistantModelMessage>;
|
|
157
|
+
}
|
|
158
|
+
export type ToolResult = {
|
|
159
|
+
content: string | ContentBlock[];
|
|
160
|
+
};
|
|
161
|
+
export type ToolHandler<TInput = unknown> = (input: TInput, context: {
|
|
162
|
+
signal?: AbortSignal;
|
|
163
|
+
toolUseId: string;
|
|
164
|
+
runtime?: AgentRuntimeContext;
|
|
165
|
+
permissions?: RuntimePermissions;
|
|
166
|
+
}) => Promise<ToolResult> | ToolResult;
|
|
167
|
+
export type ToolDefinition<TInput = unknown> = {
|
|
168
|
+
name: string;
|
|
169
|
+
description: string;
|
|
170
|
+
inputSchema: unknown;
|
|
171
|
+
jsonSchema: Record<string, unknown>;
|
|
172
|
+
parse(input: unknown): TInput;
|
|
173
|
+
handler: ToolHandler<TInput>;
|
|
174
|
+
};
|
|
175
|
+
export type SkillDefinition = {
|
|
176
|
+
name: string;
|
|
177
|
+
description: string;
|
|
178
|
+
instructions: string;
|
|
179
|
+
path?: string;
|
|
180
|
+
};
|
|
181
|
+
export type SkillInput = {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
instructions: string;
|
|
185
|
+
path?: string;
|
|
186
|
+
};
|
|
187
|
+
export type MCPContentBlock = {
|
|
188
|
+
type: "text";
|
|
189
|
+
text: string;
|
|
190
|
+
} | {
|
|
191
|
+
type: string;
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
};
|
|
194
|
+
export type MCPTool = {
|
|
195
|
+
name: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
inputSchema?: Record<string, unknown>;
|
|
198
|
+
};
|
|
199
|
+
export type MCPListToolsResult = {
|
|
200
|
+
tools: MCPTool[];
|
|
201
|
+
};
|
|
202
|
+
export type MCPCallToolResult = {
|
|
203
|
+
content?: MCPContentBlock[];
|
|
204
|
+
structuredContent?: unknown;
|
|
205
|
+
isError?: boolean;
|
|
206
|
+
};
|
|
207
|
+
export type MCPClient = {
|
|
208
|
+
listTools(): Promise<MCPListToolsResult>;
|
|
209
|
+
callTool(input: {
|
|
210
|
+
name: string;
|
|
211
|
+
arguments?: Record<string, unknown>;
|
|
212
|
+
}): Promise<MCPCallToolResult>;
|
|
213
|
+
};
|
|
214
|
+
export type MCPToolsOptions = {
|
|
215
|
+
namePrefix?: string;
|
|
216
|
+
};
|
|
217
|
+
export type MCPStdioServerOptions = MCPToolsOptions & {
|
|
218
|
+
clientName?: string;
|
|
219
|
+
clientVersion?: string;
|
|
220
|
+
};
|
|
221
|
+
export type MCPStdioConnection = {
|
|
222
|
+
client: MCPClient;
|
|
223
|
+
tools: Array<ToolDefinition<any>>;
|
|
224
|
+
close(): Promise<void>;
|
|
225
|
+
};
|
|
226
|
+
export type MCPStreamableHTTPServerOptions = MCPToolsOptions & {
|
|
227
|
+
clientName?: string;
|
|
228
|
+
clientVersion?: string;
|
|
229
|
+
authProvider?: OAuthClientProvider;
|
|
230
|
+
requestInit?: RequestInit;
|
|
231
|
+
fetch?: StreamableHTTPClientTransportOptions["fetch"];
|
|
232
|
+
reconnectionOptions?: StreamableHTTPClientTransportOptions["reconnectionOptions"];
|
|
233
|
+
sessionId?: string;
|
|
234
|
+
};
|
|
235
|
+
export type MCPStreamableHTTPConnection = MCPStdioConnection & {
|
|
236
|
+
finishAuth(authorizationCode: string): Promise<void>;
|
|
237
|
+
terminateSession(): Promise<void>;
|
|
238
|
+
sessionId: string | undefined;
|
|
239
|
+
};
|
|
240
|
+
export type TeamMemberRole = "lead" | "head" | "executor";
|
|
241
|
+
export type TeamMemberDefinition = {
|
|
242
|
+
name: string;
|
|
243
|
+
role: TeamMemberRole;
|
|
244
|
+
focus?: string;
|
|
245
|
+
agent: AgentLike;
|
|
246
|
+
mailboxId?: string;
|
|
247
|
+
};
|
|
248
|
+
export type TeamMemberInput = TeamMemberDefinition;
|
|
249
|
+
export type TeamMessageStatus = "pending" | "processing" | "done" | "failed" | "cancelled" | "read";
|
|
250
|
+
export type TeamMessageRole = "upstream_request" | "delegation" | "executor_result" | "downstream_reply" | "upstream_report" | "followup" | "message";
|
|
251
|
+
export type TeamMessage = {
|
|
252
|
+
id: string;
|
|
253
|
+
from: string;
|
|
254
|
+
to: string;
|
|
255
|
+
content: string;
|
|
256
|
+
status: TeamMessageStatus;
|
|
257
|
+
createdAt: number;
|
|
258
|
+
threadId: string;
|
|
259
|
+
parentMessageId?: string;
|
|
260
|
+
workItemId?: string;
|
|
261
|
+
workItemRole?: TeamMessageRole;
|
|
262
|
+
upstreamMessageId?: string;
|
|
263
|
+
metadata?: Record<string, unknown>;
|
|
264
|
+
};
|
|
265
|
+
export type TeamSendOptions = {
|
|
266
|
+
threadId?: string;
|
|
267
|
+
parentMessageId?: string;
|
|
268
|
+
workItemId?: string;
|
|
269
|
+
workItemRole?: TeamMessageRole;
|
|
270
|
+
upstreamMessageId?: string;
|
|
271
|
+
metadata?: Record<string, unknown>;
|
|
272
|
+
};
|
|
273
|
+
export type TeamMailbox = {
|
|
274
|
+
send(from: string, to: string, content: string, options?: TeamSendOptions): Promise<TeamMessage>;
|
|
275
|
+
inbox(mailboxId: string, options?: {
|
|
276
|
+
status?: TeamMessageStatus | "all";
|
|
277
|
+
}): Promise<TeamMessage[]>;
|
|
278
|
+
get(messageId: string): Promise<TeamMessage | undefined>;
|
|
279
|
+
claimNext(mailboxId: string): Promise<TeamMessage | undefined>;
|
|
280
|
+
updateStatus(messageId: string, status: TeamMessageStatus): Promise<boolean>;
|
|
281
|
+
};
|
|
282
|
+
export type SQLiteStatementLike = {
|
|
283
|
+
run(...params: unknown[]): unknown;
|
|
284
|
+
get(...params: unknown[]): unknown;
|
|
285
|
+
all(...params: unknown[]): unknown[];
|
|
286
|
+
};
|
|
287
|
+
export type SQLiteDatabaseLike = {
|
|
288
|
+
prepare(sql: string): SQLiteStatementLike;
|
|
289
|
+
exec?(sql: string): unknown;
|
|
290
|
+
};
|
|
291
|
+
export type SQLiteMailboxOptions = {
|
|
292
|
+
database: SQLiteDatabaseLike;
|
|
293
|
+
tableName?: string;
|
|
294
|
+
};
|
|
295
|
+
export type TeamOptions = {
|
|
296
|
+
name: string;
|
|
297
|
+
lead: Agent;
|
|
298
|
+
members: TeamMemberDefinition[];
|
|
299
|
+
mailbox?: TeamMailbox;
|
|
300
|
+
exposeLeadMailboxTools?: boolean;
|
|
301
|
+
};
|
|
302
|
+
export type Team = {
|
|
303
|
+
name: string;
|
|
304
|
+
lead: Agent;
|
|
305
|
+
members: TeamMemberDefinition[];
|
|
306
|
+
mailbox: TeamMailbox;
|
|
307
|
+
tools: Array<ToolDefinition<any>>;
|
|
308
|
+
memberTools: Record<string, Array<ToolDefinition<any>>>;
|
|
309
|
+
send(from: string, to: string, content: string, options?: TeamSendOptions): Promise<TeamMessage>;
|
|
310
|
+
drain(options?: TeamDrainOptions): Promise<TeamDrainResult>;
|
|
311
|
+
query(prompt: string | ContentBlock[], options?: QueryOptions): AsyncGenerator<TeamRunnerMessage>;
|
|
312
|
+
prompt(prompt: string | ContentBlock[], options?: QueryOptions): Promise<SDKResultMessage>;
|
|
313
|
+
};
|
|
314
|
+
export type TeamDrainOptions = {
|
|
315
|
+
maxRounds?: number;
|
|
316
|
+
maxMessages?: number;
|
|
317
|
+
signal?: AbortSignal;
|
|
318
|
+
};
|
|
319
|
+
export type TeamDrainResult = {
|
|
320
|
+
processed: number;
|
|
321
|
+
failed: number;
|
|
322
|
+
rounds: number;
|
|
323
|
+
};
|
|
324
|
+
export type TeamRunnerOptions = {
|
|
325
|
+
team?: Team;
|
|
326
|
+
root?: AgentLike;
|
|
327
|
+
mailbox?: TeamMailbox;
|
|
328
|
+
source?: AgentRuntimeSource;
|
|
329
|
+
maxDelegateDepth?: number;
|
|
330
|
+
};
|
|
331
|
+
export type TeamRunner = {
|
|
332
|
+
root: AgentLike;
|
|
333
|
+
mailbox: TeamMailbox;
|
|
334
|
+
query(prompt: string | ContentBlock[], options?: QueryOptions): AsyncGenerator<TeamRunnerMessage>;
|
|
335
|
+
prompt(prompt: string | ContentBlock[], options?: QueryOptions): Promise<SDKResultMessage>;
|
|
336
|
+
};
|
|
337
|
+
export type PermissionRequest = {
|
|
338
|
+
toolName: string;
|
|
339
|
+
input: Record<string, unknown>;
|
|
340
|
+
toolUseId: string;
|
|
341
|
+
};
|
|
342
|
+
export type PermissionDecision = {
|
|
343
|
+
behavior: "allow";
|
|
344
|
+
} | {
|
|
345
|
+
behavior: "deny";
|
|
346
|
+
message: string;
|
|
347
|
+
};
|
|
348
|
+
export type AgentWorkspaceOptions = string | {
|
|
349
|
+
cwd: string;
|
|
350
|
+
allowedDirectories?: string[];
|
|
351
|
+
bashTimeoutMs?: number;
|
|
352
|
+
};
|
|
353
|
+
export type AgentOptions = {
|
|
354
|
+
apiKey?: string;
|
|
355
|
+
baseURL?: string;
|
|
356
|
+
name?: string;
|
|
357
|
+
model: string;
|
|
358
|
+
systemPrompt?: string;
|
|
359
|
+
maxTokens?: number;
|
|
360
|
+
maxTurns?: number;
|
|
361
|
+
tools?: Array<ToolDefinition<any>>;
|
|
362
|
+
skills?: SkillDefinition[];
|
|
363
|
+
workspace?: AgentWorkspaceOptions;
|
|
364
|
+
permission?: (request: PermissionRequest) => Promise<PermissionDecision> | PermissionDecision;
|
|
365
|
+
modelClient?: ModelClient;
|
|
366
|
+
tracer?: ContextTracer;
|
|
367
|
+
};
|
|
368
|
+
export type AgentWorkspaceToolsOptions = {
|
|
369
|
+
cwd?: string;
|
|
370
|
+
allowedDirectories?: string[];
|
|
371
|
+
bashTimeoutMs?: number;
|
|
372
|
+
};
|
|
373
|
+
export type QueryOptions = {
|
|
374
|
+
stream?: boolean;
|
|
375
|
+
signal?: AbortSignal;
|
|
376
|
+
runtime?: AgentRuntimeContext;
|
|
377
|
+
permissions?: RuntimePermissions;
|
|
378
|
+
tracer?: ContextTracer;
|
|
379
|
+
};
|
|
380
|
+
export type SDKSystemInitMessage = {
|
|
381
|
+
type: "system";
|
|
382
|
+
subtype: "init";
|
|
383
|
+
model: string;
|
|
384
|
+
tools: string[];
|
|
385
|
+
session_id: string;
|
|
386
|
+
};
|
|
387
|
+
export type SDKAssistantMessage = {
|
|
388
|
+
type: "assistant";
|
|
389
|
+
message: AssistantModelMessage;
|
|
390
|
+
session_id: string;
|
|
391
|
+
};
|
|
392
|
+
export type SDKUserMessage = {
|
|
393
|
+
type: "user";
|
|
394
|
+
message: ModelMessage;
|
|
395
|
+
session_id: string;
|
|
396
|
+
tool_use_result?: string | ContentBlock[];
|
|
397
|
+
error?: Error;
|
|
398
|
+
};
|
|
399
|
+
export type SDKStreamEventMessage = {
|
|
400
|
+
type: "stream_event";
|
|
401
|
+
event: Record<string, unknown>;
|
|
402
|
+
session_id: string;
|
|
403
|
+
};
|
|
404
|
+
export type SDKResultMessage = {
|
|
405
|
+
type: "result";
|
|
406
|
+
subtype: "success" | "error" | "error_max_turns" | "error_abort";
|
|
407
|
+
is_error: boolean;
|
|
408
|
+
result: string;
|
|
409
|
+
session_id: string;
|
|
410
|
+
num_turns: number;
|
|
411
|
+
error?: Error;
|
|
412
|
+
};
|
|
413
|
+
export type SDKMessage = SDKSystemInitMessage | SDKStreamEventMessage | SDKAssistantMessage | SDKUserMessage | SDKResultMessage;
|
|
414
|
+
export type TeamRunnerSource = AgentRuntimeSource;
|
|
415
|
+
export type TeamRunnerTeamMessage = {
|
|
416
|
+
type: "team_message";
|
|
417
|
+
subtype: "sent" | "claimed" | "replied" | "followup" | "done" | "failed";
|
|
418
|
+
source: TeamRunnerSource;
|
|
419
|
+
mailbox: string;
|
|
420
|
+
message: TeamMessage;
|
|
421
|
+
};
|
|
422
|
+
export type TeamRunnerAgentMessage = {
|
|
423
|
+
type: "agent_message";
|
|
424
|
+
source: TeamRunnerSource;
|
|
425
|
+
message: SDKMessage;
|
|
426
|
+
};
|
|
427
|
+
export type TeamRunnerAgentLifecycleMessage = {
|
|
428
|
+
type: "team_agent";
|
|
429
|
+
subtype: "started" | "finished";
|
|
430
|
+
source: TeamRunnerSource;
|
|
431
|
+
};
|
|
432
|
+
export type TeamRunnerStreamEventMessage = {
|
|
433
|
+
type: "stream_event";
|
|
434
|
+
source: TeamRunnerSource;
|
|
435
|
+
event: Record<string, unknown>;
|
|
436
|
+
session_id: string;
|
|
437
|
+
};
|
|
438
|
+
export type TeamRunnerMessage = SDKMessage | TeamRunnerTeamMessage | TeamRunnerAgentMessage | TeamRunnerAgentLifecycleMessage | TeamRunnerStreamEventMessage;
|
|
439
|
+
export declare class AgentSDKError extends Error {
|
|
440
|
+
constructor(message: string, options?: {
|
|
441
|
+
cause?: unknown;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
export declare class APIError extends AgentSDKError {
|
|
445
|
+
}
|
|
446
|
+
export declare class ToolExecutionError extends AgentSDKError {
|
|
447
|
+
}
|
|
448
|
+
export declare class MaxTurnsError extends AgentSDKError {
|
|
449
|
+
}
|
|
450
|
+
export declare class AbortError extends AgentSDKError {
|
|
451
|
+
}
|
|
452
|
+
export declare class ToolPermissionDeniedError extends AgentSDKError {
|
|
453
|
+
readonly denial: PermissionDenial;
|
|
454
|
+
constructor(denial: PermissionDenial);
|
|
455
|
+
}
|
|
456
|
+
export declare function tool<TSchema>(name: string, description: string, inputSchema: TSchema, handler: ToolHandler<InferInput<TSchema>>): ToolDefinition<InferInput<TSchema>>;
|
|
457
|
+
export type DelegateToolOptions = {
|
|
458
|
+
wait?: DelegateWaitMode;
|
|
459
|
+
targetMailboxId?: string;
|
|
460
|
+
workspaceGrants?: WorkspaceGrantInput[];
|
|
461
|
+
};
|
|
462
|
+
export type AgentToolMode = "ask" | "handoff" | "observe";
|
|
463
|
+
export declare const agentToolInputSchema: z.ZodObject<{
|
|
464
|
+
mode: z.ZodEnum<{
|
|
465
|
+
ask: "ask";
|
|
466
|
+
handoff: "handoff";
|
|
467
|
+
observe: "observe";
|
|
468
|
+
}>;
|
|
469
|
+
task: z.ZodString;
|
|
470
|
+
expectedOutput: z.ZodOptional<z.ZodString>;
|
|
471
|
+
acceptanceCriteria: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
472
|
+
workspaceGrants: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
473
|
+
root: z.ZodString;
|
|
474
|
+
access: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
475
|
+
write: "write";
|
|
476
|
+
}>>>;
|
|
477
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
478
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
479
|
+
}, z.core.$strip>>>;
|
|
480
|
+
}, z.core.$strip>;
|
|
481
|
+
export type AgentToolInput = z.infer<typeof agentToolInputSchema>;
|
|
482
|
+
export type AgentToolOptions = {
|
|
483
|
+
description: string;
|
|
484
|
+
targetMailboxId?: string;
|
|
485
|
+
};
|
|
486
|
+
export declare function agentTool(name: string, agent: AgentLike, options: AgentToolOptions): ToolDefinition<AgentToolInput>;
|
|
487
|
+
export declare function delegateTool(name: string, description: string, agent: AgentLike, options?: DelegateToolOptions): ToolDefinition<{
|
|
488
|
+
task: string;
|
|
489
|
+
}>;
|
|
490
|
+
export declare function createAgent(options: AgentOptions): Agent;
|
|
491
|
+
export declare function createJsonlContextTracer(options: JsonlContextTracerOptions): ContextTracer;
|
|
492
|
+
export declare function createCompositeContextTracer(tracers: Array<ContextTracer | undefined | null>): ContextTracer;
|
|
493
|
+
export declare function createLangSmithContextTracer(options: LangSmithContextTracerOptions): ContextTracer;
|
|
494
|
+
export declare function skill(input: SkillInput): SkillDefinition;
|
|
495
|
+
export declare function loadSkill(path: string): Promise<SkillDefinition>;
|
|
496
|
+
export declare function createMCPTools(client: MCPClient, options?: MCPToolsOptions): Promise<Array<ToolDefinition<Record<string, unknown>>>>;
|
|
497
|
+
export declare function connectMCPStdioServer(server: StdioServerParameters, options?: MCPStdioServerOptions): Promise<MCPStdioConnection>;
|
|
498
|
+
export declare function connectMCPStreamableHTTPServer(url: string | URL, options?: MCPStreamableHTTPServerOptions): Promise<MCPStreamableHTTPConnection>;
|
|
499
|
+
export declare function teamMember(input: TeamMemberInput): TeamMemberDefinition;
|
|
500
|
+
export declare function createMemoryMailbox(): TeamMailbox;
|
|
501
|
+
export declare function createSQLiteMailbox(options: SQLiteMailboxOptions): TeamMailbox;
|
|
502
|
+
export declare function createTeam(options: TeamOptions): Team;
|
|
503
|
+
export declare function createTeamRunner(options: TeamRunnerOptions): TeamRunner;
|
|
504
|
+
export declare function createAgentWorkspaceTools(options?: AgentWorkspaceToolsOptions): Array<ToolDefinition<any>>;
|
|
505
|
+
export declare function query(params: AgentOptions & {
|
|
506
|
+
prompt: string;
|
|
507
|
+
stream?: boolean;
|
|
508
|
+
signal?: AbortSignal;
|
|
509
|
+
}): AsyncGenerator<SDKMessage>;
|
|
510
|
+
export declare class Agent {
|
|
511
|
+
private readonly options;
|
|
512
|
+
private readonly modelClient;
|
|
513
|
+
private readonly messages;
|
|
514
|
+
private readonly sessionId;
|
|
515
|
+
constructor(options: AgentOptions);
|
|
516
|
+
query(prompt: string | ContentBlock[], options?: QueryOptions): AsyncGenerator<SDKMessage>;
|
|
517
|
+
prompt(prompt: string | ContentBlock[], options?: QueryOptions): Promise<SDKResultMessage>;
|
|
518
|
+
addTools(tools: Array<ToolDefinition<any>>): void;
|
|
519
|
+
private initMessage;
|
|
520
|
+
private resultMessage;
|
|
521
|
+
private modelTools;
|
|
522
|
+
private messagesForModel;
|
|
523
|
+
private selectSkills;
|
|
524
|
+
private runTool;
|
|
525
|
+
}
|
|
526
|
+
type InferInput<TSchema> = TSchema extends {
|
|
527
|
+
parse(input: unknown): infer TInput;
|
|
528
|
+
} ? TInput : Record<string, unknown>;
|
|
529
|
+
export {};
|