swarmlord 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 +21 -0
- package/README.md +198 -0
- package/dist/index.cjs +670 -0
- package/dist/index.d.cts +615 -0
- package/dist/index.d.mts +615 -0
- package/dist/index.d.ts +615 -0
- package/dist/index.mjs +668 -0
- package/package.json +44 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
interface ClientOptions {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
}
|
|
5
|
+
type AgentName = "build" | "plan" | "explore" | "general" | (string & {});
|
|
6
|
+
interface AgentConfig {
|
|
7
|
+
name?: AgentName;
|
|
8
|
+
model?: string;
|
|
9
|
+
instructions?: string[];
|
|
10
|
+
permission?: PermissionConfig;
|
|
11
|
+
temperature?: number;
|
|
12
|
+
config?: Config;
|
|
13
|
+
}
|
|
14
|
+
type PermissionConfig = string | Record<string, string | Record<string, string>>;
|
|
15
|
+
interface Config {
|
|
16
|
+
model?: string;
|
|
17
|
+
small_model?: string;
|
|
18
|
+
default_agent?: string;
|
|
19
|
+
instructions?: string[];
|
|
20
|
+
permission?: PermissionConfig;
|
|
21
|
+
command?: Record<string, {
|
|
22
|
+
template: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
agent?: string;
|
|
25
|
+
model?: string;
|
|
26
|
+
subtask?: boolean;
|
|
27
|
+
}>;
|
|
28
|
+
compaction?: {
|
|
29
|
+
auto?: boolean;
|
|
30
|
+
prune?: boolean;
|
|
31
|
+
reserved?: number;
|
|
32
|
+
};
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
interface Tokens {
|
|
36
|
+
input: number;
|
|
37
|
+
output: number;
|
|
38
|
+
reasoning: number;
|
|
39
|
+
total?: number;
|
|
40
|
+
cache: {
|
|
41
|
+
read: number;
|
|
42
|
+
write: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
type SessionStatus = "idle" | "busy" | "compacting" | "error";
|
|
46
|
+
interface SessionInfo {
|
|
47
|
+
id: string;
|
|
48
|
+
title: string;
|
|
49
|
+
status: SessionStatus;
|
|
50
|
+
parentId?: string;
|
|
51
|
+
config?: string;
|
|
52
|
+
permission?: string;
|
|
53
|
+
timeCreated: number;
|
|
54
|
+
timeUpdated: number;
|
|
55
|
+
timeCompacting?: number;
|
|
56
|
+
}
|
|
57
|
+
interface SessionMetrics {
|
|
58
|
+
sessionId: string;
|
|
59
|
+
messages: number;
|
|
60
|
+
steps: number;
|
|
61
|
+
toolCalls: number;
|
|
62
|
+
toolUsage: Record<string, number>;
|
|
63
|
+
tokens: Tokens;
|
|
64
|
+
cost: number;
|
|
65
|
+
}
|
|
66
|
+
interface TodoItem {
|
|
67
|
+
sessionId: string;
|
|
68
|
+
content: string;
|
|
69
|
+
status: string;
|
|
70
|
+
priority: string;
|
|
71
|
+
position: number;
|
|
72
|
+
}
|
|
73
|
+
interface PartBase {
|
|
74
|
+
id: string;
|
|
75
|
+
sessionID: string;
|
|
76
|
+
messageID: string;
|
|
77
|
+
}
|
|
78
|
+
interface TextPart extends PartBase {
|
|
79
|
+
type: "text";
|
|
80
|
+
text: string;
|
|
81
|
+
synthetic?: boolean;
|
|
82
|
+
ignored?: boolean;
|
|
83
|
+
time?: {
|
|
84
|
+
start: number;
|
|
85
|
+
end?: number;
|
|
86
|
+
};
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
interface ReasoningPart extends PartBase {
|
|
90
|
+
type: "reasoning";
|
|
91
|
+
text: string;
|
|
92
|
+
time: {
|
|
93
|
+
start: number;
|
|
94
|
+
end?: number;
|
|
95
|
+
};
|
|
96
|
+
metadata?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
interface FilePart extends PartBase {
|
|
99
|
+
type: "file";
|
|
100
|
+
mime: string;
|
|
101
|
+
filename?: string;
|
|
102
|
+
url: string;
|
|
103
|
+
}
|
|
104
|
+
interface AgentPart extends PartBase {
|
|
105
|
+
type: "agent";
|
|
106
|
+
name: string;
|
|
107
|
+
}
|
|
108
|
+
interface CompactionPart extends PartBase {
|
|
109
|
+
type: "compaction";
|
|
110
|
+
auto: boolean;
|
|
111
|
+
}
|
|
112
|
+
interface SubtaskPart extends PartBase {
|
|
113
|
+
type: "subtask";
|
|
114
|
+
prompt: string;
|
|
115
|
+
description: string;
|
|
116
|
+
agent: string;
|
|
117
|
+
model?: {
|
|
118
|
+
providerID: string;
|
|
119
|
+
modelID: string;
|
|
120
|
+
};
|
|
121
|
+
command?: string;
|
|
122
|
+
}
|
|
123
|
+
interface RetryPart extends PartBase {
|
|
124
|
+
type: "retry";
|
|
125
|
+
attempt: number;
|
|
126
|
+
error: {
|
|
127
|
+
name: string;
|
|
128
|
+
data: Record<string, unknown>;
|
|
129
|
+
};
|
|
130
|
+
time: {
|
|
131
|
+
created: number;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
interface StepStartPart extends PartBase {
|
|
135
|
+
type: "step-start";
|
|
136
|
+
}
|
|
137
|
+
interface StepFinishPart extends PartBase {
|
|
138
|
+
type: "step-finish";
|
|
139
|
+
reason: string;
|
|
140
|
+
cost: number;
|
|
141
|
+
tokens: Tokens;
|
|
142
|
+
}
|
|
143
|
+
interface ToolStatePending {
|
|
144
|
+
status: "pending";
|
|
145
|
+
input: Record<string, unknown>;
|
|
146
|
+
raw: string;
|
|
147
|
+
}
|
|
148
|
+
interface ToolStateRunning {
|
|
149
|
+
status: "running";
|
|
150
|
+
input: Record<string, unknown>;
|
|
151
|
+
title?: string;
|
|
152
|
+
metadata?: Record<string, unknown>;
|
|
153
|
+
time: {
|
|
154
|
+
start: number;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
interface ToolStateCompleted {
|
|
158
|
+
status: "completed";
|
|
159
|
+
input: Record<string, unknown>;
|
|
160
|
+
output: string;
|
|
161
|
+
title: string;
|
|
162
|
+
metadata: Record<string, unknown>;
|
|
163
|
+
time: {
|
|
164
|
+
start: number;
|
|
165
|
+
end: number;
|
|
166
|
+
compacted?: number;
|
|
167
|
+
};
|
|
168
|
+
attachments?: FilePart[];
|
|
169
|
+
}
|
|
170
|
+
interface ToolStateError {
|
|
171
|
+
status: "error";
|
|
172
|
+
input: Record<string, unknown>;
|
|
173
|
+
error: string;
|
|
174
|
+
metadata?: Record<string, unknown>;
|
|
175
|
+
time: {
|
|
176
|
+
start: number;
|
|
177
|
+
end: number;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
|
|
181
|
+
interface ToolPart extends PartBase {
|
|
182
|
+
type: "tool";
|
|
183
|
+
callID: string;
|
|
184
|
+
tool: string;
|
|
185
|
+
state: ToolState;
|
|
186
|
+
metadata?: Record<string, unknown>;
|
|
187
|
+
}
|
|
188
|
+
type Part = TextPart | ReasoningPart | FilePart | AgentPart | CompactionPart | SubtaskPart | RetryPart | StepStartPart | StepFinishPart | ToolPart;
|
|
189
|
+
interface UserMessageInfo {
|
|
190
|
+
id: string;
|
|
191
|
+
sessionID: string;
|
|
192
|
+
role: "user";
|
|
193
|
+
time: {
|
|
194
|
+
created: number;
|
|
195
|
+
};
|
|
196
|
+
agent: string;
|
|
197
|
+
model: {
|
|
198
|
+
providerID: string;
|
|
199
|
+
modelID: string;
|
|
200
|
+
};
|
|
201
|
+
variant?: string;
|
|
202
|
+
}
|
|
203
|
+
interface AssistantMessageInfo {
|
|
204
|
+
id: string;
|
|
205
|
+
sessionID: string;
|
|
206
|
+
role: "assistant";
|
|
207
|
+
time: {
|
|
208
|
+
created: number;
|
|
209
|
+
completed?: number;
|
|
210
|
+
};
|
|
211
|
+
parentID: string;
|
|
212
|
+
modelID: string;
|
|
213
|
+
providerID: string;
|
|
214
|
+
agent: string;
|
|
215
|
+
path: {
|
|
216
|
+
cwd: string;
|
|
217
|
+
root: string;
|
|
218
|
+
};
|
|
219
|
+
cost: number;
|
|
220
|
+
tokens: Tokens;
|
|
221
|
+
error?: {
|
|
222
|
+
name: string;
|
|
223
|
+
data: Record<string, unknown>;
|
|
224
|
+
};
|
|
225
|
+
summary?: boolean;
|
|
226
|
+
variant?: string;
|
|
227
|
+
finish?: string;
|
|
228
|
+
}
|
|
229
|
+
type MessageInfo = UserMessageInfo | AssistantMessageInfo;
|
|
230
|
+
interface WithParts {
|
|
231
|
+
info: MessageInfo;
|
|
232
|
+
parts: Part[];
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated Use `Part` instead. Kept for backward compatibility.
|
|
236
|
+
*/
|
|
237
|
+
interface MessagePart {
|
|
238
|
+
id: string;
|
|
239
|
+
type: string;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
type TextInput = {
|
|
243
|
+
type: "text";
|
|
244
|
+
text: string;
|
|
245
|
+
};
|
|
246
|
+
type FileInput = {
|
|
247
|
+
type: "file";
|
|
248
|
+
url: string;
|
|
249
|
+
mime: string;
|
|
250
|
+
filename?: string;
|
|
251
|
+
};
|
|
252
|
+
type MessageInput = {
|
|
253
|
+
parts: Array<TextInput | FileInput>;
|
|
254
|
+
agent?: string;
|
|
255
|
+
model?: string;
|
|
256
|
+
config?: Config;
|
|
257
|
+
};
|
|
258
|
+
interface SendResult {
|
|
259
|
+
messageId: string;
|
|
260
|
+
text: string;
|
|
261
|
+
parts: Part[];
|
|
262
|
+
tokens?: Tokens;
|
|
263
|
+
cost?: number;
|
|
264
|
+
error?: {
|
|
265
|
+
name: string;
|
|
266
|
+
data: Record<string, unknown>;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
interface StreamCallbacks {
|
|
270
|
+
/** Fires the instant the SSE stream is established — before the first token or tool call. */
|
|
271
|
+
onConnect?: () => void;
|
|
272
|
+
onText?: (delta: string) => void;
|
|
273
|
+
onReasoning?: (delta: string) => void;
|
|
274
|
+
onToolStart?: (part: ToolPart) => void;
|
|
275
|
+
onToolComplete?: (part: ToolPart) => void;
|
|
276
|
+
onToolError?: (part: ToolPart, error: string) => void;
|
|
277
|
+
onStepFinish?: (tokens: Tokens, cost: number) => void;
|
|
278
|
+
onAttachment?: (file: FilePart) => void;
|
|
279
|
+
onPermission?: (req: PermissionRequest) => Promise<PermissionReply>;
|
|
280
|
+
onStatus?: (status: SessionStatus) => void;
|
|
281
|
+
onError?: (err: Error) => void;
|
|
282
|
+
}
|
|
283
|
+
interface PermissionRequest {
|
|
284
|
+
id: string;
|
|
285
|
+
sessionID: string;
|
|
286
|
+
permission: string;
|
|
287
|
+
patterns: string[];
|
|
288
|
+
metadata: Record<string, unknown>;
|
|
289
|
+
always: string[];
|
|
290
|
+
tool?: {
|
|
291
|
+
messageID: string;
|
|
292
|
+
callID: string;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
type PermissionReply = "once" | "always" | "reject";
|
|
296
|
+
type AgentEvent = {
|
|
297
|
+
type: "connect";
|
|
298
|
+
} | {
|
|
299
|
+
type: "text-delta";
|
|
300
|
+
delta: string;
|
|
301
|
+
} | {
|
|
302
|
+
type: "reasoning-delta";
|
|
303
|
+
delta: string;
|
|
304
|
+
} | {
|
|
305
|
+
type: "tool-start";
|
|
306
|
+
part: ToolPart;
|
|
307
|
+
} | {
|
|
308
|
+
type: "tool-complete";
|
|
309
|
+
part: ToolPart;
|
|
310
|
+
} | {
|
|
311
|
+
type: "tool-error";
|
|
312
|
+
part: ToolPart;
|
|
313
|
+
error: string;
|
|
314
|
+
} | {
|
|
315
|
+
type: "step-finish";
|
|
316
|
+
tokens: Tokens;
|
|
317
|
+
cost: number;
|
|
318
|
+
reason: string;
|
|
319
|
+
} | {
|
|
320
|
+
type: "attachment";
|
|
321
|
+
file: FilePart;
|
|
322
|
+
} | {
|
|
323
|
+
type: "permission-asked";
|
|
324
|
+
request: PermissionRequest;
|
|
325
|
+
} | {
|
|
326
|
+
type: "status-change";
|
|
327
|
+
status: SessionStatus;
|
|
328
|
+
} | {
|
|
329
|
+
type: "session-idle";
|
|
330
|
+
sessionId: string;
|
|
331
|
+
} | {
|
|
332
|
+
type: "error";
|
|
333
|
+
error: string;
|
|
334
|
+
} | {
|
|
335
|
+
type: "message-updated";
|
|
336
|
+
info: MessageInfo;
|
|
337
|
+
};
|
|
338
|
+
interface ProviderModel {
|
|
339
|
+
id: string;
|
|
340
|
+
providerID: string;
|
|
341
|
+
api: {
|
|
342
|
+
id: string;
|
|
343
|
+
url: string;
|
|
344
|
+
npm: string;
|
|
345
|
+
};
|
|
346
|
+
name: string;
|
|
347
|
+
family?: string;
|
|
348
|
+
capabilities: {
|
|
349
|
+
temperature: boolean;
|
|
350
|
+
reasoning: boolean;
|
|
351
|
+
attachment: boolean;
|
|
352
|
+
toolcall: boolean;
|
|
353
|
+
input: {
|
|
354
|
+
text: boolean;
|
|
355
|
+
audio: boolean;
|
|
356
|
+
image: boolean;
|
|
357
|
+
video: boolean;
|
|
358
|
+
pdf: boolean;
|
|
359
|
+
};
|
|
360
|
+
output: {
|
|
361
|
+
text: boolean;
|
|
362
|
+
audio: boolean;
|
|
363
|
+
image: boolean;
|
|
364
|
+
video: boolean;
|
|
365
|
+
pdf: boolean;
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
cost: {
|
|
369
|
+
input: number;
|
|
370
|
+
output: number;
|
|
371
|
+
cache: {
|
|
372
|
+
read: number;
|
|
373
|
+
write: number;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
limit: {
|
|
377
|
+
context: number;
|
|
378
|
+
input?: number;
|
|
379
|
+
output: number;
|
|
380
|
+
};
|
|
381
|
+
status: "alpha" | "beta" | "deprecated" | "active";
|
|
382
|
+
}
|
|
383
|
+
type TaskStatus = "accepted" | "busy" | "compacting" | "idle" | "error";
|
|
384
|
+
interface TaskResult {
|
|
385
|
+
sessionId: string;
|
|
386
|
+
status: "completed" | "error";
|
|
387
|
+
text: string;
|
|
388
|
+
messages: WithParts[];
|
|
389
|
+
tokens?: Tokens;
|
|
390
|
+
cost?: number;
|
|
391
|
+
}
|
|
392
|
+
interface ScheduleInfo {
|
|
393
|
+
id: string;
|
|
394
|
+
cron: string;
|
|
395
|
+
prompt: string;
|
|
396
|
+
model: string;
|
|
397
|
+
config: string | null;
|
|
398
|
+
enabled: number;
|
|
399
|
+
timeCreated: number;
|
|
400
|
+
}
|
|
401
|
+
interface CreateScheduleOpts {
|
|
402
|
+
cron: string;
|
|
403
|
+
prompt: string;
|
|
404
|
+
model?: string;
|
|
405
|
+
}
|
|
406
|
+
interface UpdateScheduleOpts {
|
|
407
|
+
cron?: string;
|
|
408
|
+
prompt?: string;
|
|
409
|
+
model?: string;
|
|
410
|
+
enabled?: boolean;
|
|
411
|
+
config?: Config;
|
|
412
|
+
}
|
|
413
|
+
type TriggerProviderName = "github" | "slack" | "linear" | "generic" | (string & {});
|
|
414
|
+
interface TriggerInfo {
|
|
415
|
+
id: string;
|
|
416
|
+
provider: string;
|
|
417
|
+
events: string | null;
|
|
418
|
+
agentName: string | null;
|
|
419
|
+
model: string | null;
|
|
420
|
+
promptTemplate: string;
|
|
421
|
+
providerConfig: string | null;
|
|
422
|
+
agentConfig: string | null;
|
|
423
|
+
webhookSecret: string;
|
|
424
|
+
webhookUrl: string;
|
|
425
|
+
enabled: number;
|
|
426
|
+
timeCreated: number;
|
|
427
|
+
}
|
|
428
|
+
interface OutputConfig {
|
|
429
|
+
provider: string;
|
|
430
|
+
action: string;
|
|
431
|
+
config: Record<string, string>;
|
|
432
|
+
template?: string;
|
|
433
|
+
}
|
|
434
|
+
interface CreateTriggerOpts {
|
|
435
|
+
provider: TriggerProviderName;
|
|
436
|
+
events?: string[];
|
|
437
|
+
promptTemplate: string;
|
|
438
|
+
model?: string;
|
|
439
|
+
providerConfig?: Record<string, unknown>;
|
|
440
|
+
outputs?: OutputConfig[];
|
|
441
|
+
}
|
|
442
|
+
interface UpdateTriggerOpts {
|
|
443
|
+
events?: string[];
|
|
444
|
+
promptTemplate?: string;
|
|
445
|
+
model?: string;
|
|
446
|
+
agent?: string;
|
|
447
|
+
providerConfig?: Record<string, unknown>;
|
|
448
|
+
agentConfig?: Record<string, unknown>;
|
|
449
|
+
outputs?: OutputConfig[];
|
|
450
|
+
enabled?: boolean;
|
|
451
|
+
}
|
|
452
|
+
interface ShellResult {
|
|
453
|
+
stdout: string;
|
|
454
|
+
stderr: string;
|
|
455
|
+
exitCode: number;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
interface SessionHandle {
|
|
459
|
+
readonly id: string;
|
|
460
|
+
/** Send a message and stream the response via callbacks. Resolves when the agent goes idle. */
|
|
461
|
+
send(input: string | MessageInput, callbacks?: StreamCallbacks): Promise<SendResult>;
|
|
462
|
+
/** Send a message and get back a typed async iterator of events. */
|
|
463
|
+
stream(input: string | MessageInput): AsyncIterable<AgentEvent>;
|
|
464
|
+
abort(): Promise<void>;
|
|
465
|
+
summarize(): Promise<void>;
|
|
466
|
+
revert(messageId: string): Promise<void>;
|
|
467
|
+
shell(command: string, opts?: {
|
|
468
|
+
timeout?: number;
|
|
469
|
+
cwd?: string;
|
|
470
|
+
}): Promise<ShellResult>;
|
|
471
|
+
getInfo(): Promise<SessionInfo>;
|
|
472
|
+
getMessages(): Promise<WithParts[]>;
|
|
473
|
+
getMetrics(): Promise<SessionMetrics>;
|
|
474
|
+
getTodos(): Promise<TodoItem[]>;
|
|
475
|
+
getFile(path: string): Promise<string>;
|
|
476
|
+
/** Get a file as raw bytes (for binary files like images). */
|
|
477
|
+
getFileBuffer(path: string): Promise<ArrayBuffer>;
|
|
478
|
+
getArtifact(key: string): Promise<string>;
|
|
479
|
+
/** Get an artifact as raw bytes. */
|
|
480
|
+
getArtifactBuffer(key: string): Promise<ArrayBuffer>;
|
|
481
|
+
update(opts: {
|
|
482
|
+
title?: string;
|
|
483
|
+
archived?: boolean;
|
|
484
|
+
}): Promise<void>;
|
|
485
|
+
delete(): Promise<void>;
|
|
486
|
+
runCommand(name: string, args?: Record<string, string>): Promise<string>;
|
|
487
|
+
replyToPermission(requestId: string, reply: "once" | "always" | "reject", message?: string): Promise<void>;
|
|
488
|
+
events(lastEventId?: number): Promise<ReadableStream<Uint8Array>>;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface TaskHandle {
|
|
492
|
+
/** The underlying session ID for this task */
|
|
493
|
+
readonly id: string;
|
|
494
|
+
/** Poll the task status once. */
|
|
495
|
+
poll(): Promise<TaskStatus>;
|
|
496
|
+
/** Block until the task completes or errors. Returns the final text output. */
|
|
497
|
+
result(opts?: {
|
|
498
|
+
timeoutMs?: number;
|
|
499
|
+
}): Promise<TaskResult>;
|
|
500
|
+
/** Cancel the running task. */
|
|
501
|
+
cancel(): Promise<void>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
interface ScheduleHandle {
|
|
505
|
+
/** The schedule ID */
|
|
506
|
+
readonly id: string;
|
|
507
|
+
/** Trigger the schedule immediately, returning a Task handle for the resulting run. */
|
|
508
|
+
trigger(): Promise<TaskHandle>;
|
|
509
|
+
/** Pause the schedule (disable cron). */
|
|
510
|
+
pause(): Promise<void>;
|
|
511
|
+
/** Resume the schedule (enable cron). */
|
|
512
|
+
resume(): Promise<void>;
|
|
513
|
+
/** Update the schedule configuration. */
|
|
514
|
+
update(opts: UpdateScheduleOpts): Promise<void>;
|
|
515
|
+
/** Delete the schedule permanently. */
|
|
516
|
+
delete(): Promise<void>;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
interface TriggerHandle {
|
|
520
|
+
/** The trigger ID */
|
|
521
|
+
readonly id: string;
|
|
522
|
+
/** The webhook URL to configure in the external service */
|
|
523
|
+
readonly webhookUrl: string;
|
|
524
|
+
/** The HMAC secret for signature validation (store this securely) */
|
|
525
|
+
readonly webhookSecret: string;
|
|
526
|
+
/** Pause the trigger (disable). */
|
|
527
|
+
pause(): Promise<void>;
|
|
528
|
+
/** Resume the trigger (enable). */
|
|
529
|
+
resume(): Promise<void>;
|
|
530
|
+
/** Update the trigger configuration. */
|
|
531
|
+
update(opts: UpdateTriggerOpts): Promise<void>;
|
|
532
|
+
/** Delete the trigger permanently. */
|
|
533
|
+
delete(): Promise<void>;
|
|
534
|
+
/** Get the latest trigger info from the server. */
|
|
535
|
+
getInfo(): Promise<TriggerInfo>;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
interface AgentHandle {
|
|
539
|
+
/** The agent configuration */
|
|
540
|
+
readonly config: AgentConfig;
|
|
541
|
+
/** Create a new interactive session with this agent. */
|
|
542
|
+
createSession(opts?: {
|
|
543
|
+
title?: string;
|
|
544
|
+
webhook?: string;
|
|
545
|
+
}): Promise<SessionHandle>;
|
|
546
|
+
/** Resume an existing session with this agent's config applied. */
|
|
547
|
+
session(id: string): SessionHandle;
|
|
548
|
+
/** Fork an existing session into a new one. */
|
|
549
|
+
forkSession(id: string): Promise<SessionHandle>;
|
|
550
|
+
/**
|
|
551
|
+
* Run a one-shot task. Fire-and-forget — returns a TaskHandle immediately.
|
|
552
|
+
* Use `await task.result()` to block until completion, or set a webhook.
|
|
553
|
+
*/
|
|
554
|
+
run(prompt: string, opts?: {
|
|
555
|
+
title?: string;
|
|
556
|
+
webhook?: string;
|
|
557
|
+
}): Promise<TaskHandle>;
|
|
558
|
+
/**
|
|
559
|
+
* Create a recurring schedule that runs this agent on a cron.
|
|
560
|
+
* Returns a ScheduleHandle for management and manual triggering.
|
|
561
|
+
*/
|
|
562
|
+
schedule(opts: CreateScheduleOpts): Promise<ScheduleHandle>;
|
|
563
|
+
/**
|
|
564
|
+
* Create an event-driven trigger from an external service (GitHub, Slack, Linear, etc.).
|
|
565
|
+
* Returns a TriggerHandle with the webhook URL to configure in the external service.
|
|
566
|
+
*/
|
|
567
|
+
trigger(opts: CreateTriggerOpts): Promise<TriggerHandle>;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
interface SwarmlordClient {
|
|
571
|
+
/**
|
|
572
|
+
* Create an agent handle. Everything flows from agents.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* const build = client.agent("build")
|
|
576
|
+
* const reviewer = client.agent({
|
|
577
|
+
* name: "build",
|
|
578
|
+
* model: "anthropic/claude-sonnet-4-20250514",
|
|
579
|
+
* instructions: ["Focus on security"],
|
|
580
|
+
* })
|
|
581
|
+
*/
|
|
582
|
+
agent(nameOrConfig: AgentName | AgentConfig): AgentHandle;
|
|
583
|
+
/** Resume an existing session by ID (without agent config). */
|
|
584
|
+
session(id: string): SessionHandle;
|
|
585
|
+
/** Resume a task handle by session ID. */
|
|
586
|
+
task(sessionId: string): TaskHandle;
|
|
587
|
+
/** Resume a schedule handle by ID. */
|
|
588
|
+
schedule(id: string): ScheduleHandle;
|
|
589
|
+
/** Resume a trigger handle by ID. */
|
|
590
|
+
trigger(id: string): TriggerHandle;
|
|
591
|
+
/** List all sessions for the authenticated user. */
|
|
592
|
+
listSessions(opts?: {
|
|
593
|
+
limit?: number;
|
|
594
|
+
archived?: boolean;
|
|
595
|
+
}): Promise<SessionInfo[]>;
|
|
596
|
+
/** List all schedules for the authenticated user. */
|
|
597
|
+
listSchedules(): Promise<ScheduleInfo[]>;
|
|
598
|
+
/** List all triggers for the authenticated user. */
|
|
599
|
+
listTriggers(): Promise<TriggerInfo[]>;
|
|
600
|
+
/** Get user-level config. */
|
|
601
|
+
getConfig(): Promise<Config>;
|
|
602
|
+
/** Merge-update user-level config. */
|
|
603
|
+
updateConfig(config: Partial<Config>): Promise<void>;
|
|
604
|
+
/** List available provider models (proxied from OpenRouter). */
|
|
605
|
+
listModels(): Promise<{
|
|
606
|
+
data: ProviderModel[];
|
|
607
|
+
}>;
|
|
608
|
+
}
|
|
609
|
+
type CreateClientOptions = Omit<ClientOptions, "baseUrl"> & {
|
|
610
|
+
baseUrl?: string;
|
|
611
|
+
};
|
|
612
|
+
declare function createClient(opts: CreateClientOptions): SwarmlordClient;
|
|
613
|
+
|
|
614
|
+
export { createClient };
|
|
615
|
+
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|