@almadar/agent 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 +72 -0
- package/dist/agent/index.d.ts +250 -0
- package/dist/agent/index.js +6038 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/api-types-BW_58thJ.d.ts +557 -0
- package/dist/event-transformer/index.d.ts +125 -0
- package/dist/event-transformer/index.js +350 -0
- package/dist/event-transformer/index.js.map +1 -0
- package/dist/firestore-checkpointer-DxbQ10ve.d.ts +184 -0
- package/dist/index.d.ts +742 -0
- package/dist/index.js +9392 -0
- package/dist/index.js.map +1 -0
- package/dist/orbital-subagent-BsQBhKzi.d.ts +1424 -0
- package/dist/persistence/index.d.ts +201 -0
- package/dist/persistence/index.js +489 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/prompts/index.d.ts +23 -0
- package/dist/prompts/index.js +126 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/tools/index.d.ts +2143 -0
- package/dist/tools/index.js +5783 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +170 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* DeepAgent API Types
|
|
5
|
+
*
|
|
6
|
+
* Request/response types for the skills-only DeepAgent API.
|
|
7
|
+
* All agent behavior is defined through skills - no custom prompts allowed.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extracted requirements schema - from analysis phase.
|
|
14
|
+
* Used to provide more precise generation guidance.
|
|
15
|
+
*/
|
|
16
|
+
declare const ExtractedRequirementsSchema: z.ZodObject<{
|
|
17
|
+
/** Entity names to create */
|
|
18
|
+
entities: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
19
|
+
/** State names that should exist */
|
|
20
|
+
states: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
21
|
+
/** Event/action names */
|
|
22
|
+
events: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
23
|
+
/** Business rules (become guards) */
|
|
24
|
+
guards: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
25
|
+
/** Page types needed */
|
|
26
|
+
pages: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
27
|
+
/** Notifications/side-effects */
|
|
28
|
+
effects: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
29
|
+
/** Raw requirement statements */
|
|
30
|
+
rawRequirements: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
entities: string[];
|
|
33
|
+
states: string[];
|
|
34
|
+
events: string[];
|
|
35
|
+
guards: string[];
|
|
36
|
+
pages: string[];
|
|
37
|
+
effects: string[];
|
|
38
|
+
rawRequirements: string[];
|
|
39
|
+
}, {
|
|
40
|
+
entities?: string[] | undefined;
|
|
41
|
+
states?: string[] | undefined;
|
|
42
|
+
events?: string[] | undefined;
|
|
43
|
+
guards?: string[] | undefined;
|
|
44
|
+
pages?: string[] | undefined;
|
|
45
|
+
effects?: string[] | undefined;
|
|
46
|
+
rawRequirements?: string[] | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
type ExtractedRequirementsInput = z.infer<typeof ExtractedRequirementsSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Generate request schema - skills only, no custom prompts.
|
|
51
|
+
*/
|
|
52
|
+
declare const GenerateRequestSchema: z.ZodObject<{
|
|
53
|
+
/** Required: The skill(s) to use for this generation */
|
|
54
|
+
skill: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>;
|
|
55
|
+
/** The user's task/message */
|
|
56
|
+
message: z.ZodString;
|
|
57
|
+
/** Optional: Thread ID for session continuity */
|
|
58
|
+
threadId: z.ZodOptional<z.ZodString>;
|
|
59
|
+
/** Optional: Workspace directory (defaults to temp dir) */
|
|
60
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
61
|
+
/** Optional: LLM provider */
|
|
62
|
+
provider: z.ZodOptional<z.ZodEnum<["anthropic", "openai", "deepseek"]>>;
|
|
63
|
+
/** Optional: Model name */
|
|
64
|
+
model: z.ZodOptional<z.ZodString>;
|
|
65
|
+
/** Optional: Disable human-in-the-loop interrupts (for eval/testing) */
|
|
66
|
+
noInterrupt: z.ZodOptional<z.ZodBoolean>;
|
|
67
|
+
/** Optional: App ID for persisting schema to Firestore */
|
|
68
|
+
appId: z.ZodOptional<z.ZodString>;
|
|
69
|
+
/** Optional: Extracted requirements from analysis phase (for orbital skill) */
|
|
70
|
+
requirements: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
/** Entity names to create */
|
|
72
|
+
entities: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
73
|
+
/** State names that should exist */
|
|
74
|
+
states: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
75
|
+
/** Event/action names */
|
|
76
|
+
events: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
77
|
+
/** Business rules (become guards) */
|
|
78
|
+
guards: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
79
|
+
/** Page types needed */
|
|
80
|
+
pages: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
81
|
+
/** Notifications/side-effects */
|
|
82
|
+
effects: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
83
|
+
/** Raw requirement statements */
|
|
84
|
+
rawRequirements: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
entities: string[];
|
|
87
|
+
states: string[];
|
|
88
|
+
events: string[];
|
|
89
|
+
guards: string[];
|
|
90
|
+
pages: string[];
|
|
91
|
+
effects: string[];
|
|
92
|
+
rawRequirements: string[];
|
|
93
|
+
}, {
|
|
94
|
+
entities?: string[] | undefined;
|
|
95
|
+
states?: string[] | undefined;
|
|
96
|
+
events?: string[] | undefined;
|
|
97
|
+
guards?: string[] | undefined;
|
|
98
|
+
pages?: string[] | undefined;
|
|
99
|
+
effects?: string[] | undefined;
|
|
100
|
+
rawRequirements?: string[] | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
/** Optional: GitHub integration configuration */
|
|
103
|
+
github: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
/** GitHub personal access token */
|
|
105
|
+
token: z.ZodString;
|
|
106
|
+
/** Repository owner (e.g., 'octocat') */
|
|
107
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
108
|
+
/** Repository name (e.g., 'hello-world') */
|
|
109
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, "strip", z.ZodTypeAny, {
|
|
111
|
+
token: string;
|
|
112
|
+
owner?: string | undefined;
|
|
113
|
+
repo?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
token: string;
|
|
116
|
+
owner?: string | undefined;
|
|
117
|
+
repo?: string | undefined;
|
|
118
|
+
}>>;
|
|
119
|
+
}, "strict", z.ZodTypeAny, {
|
|
120
|
+
message: string;
|
|
121
|
+
skill: string | string[];
|
|
122
|
+
threadId?: string | undefined;
|
|
123
|
+
workspace?: string | undefined;
|
|
124
|
+
provider?: "anthropic" | "openai" | "deepseek" | undefined;
|
|
125
|
+
model?: string | undefined;
|
|
126
|
+
noInterrupt?: boolean | undefined;
|
|
127
|
+
appId?: string | undefined;
|
|
128
|
+
requirements?: {
|
|
129
|
+
entities: string[];
|
|
130
|
+
states: string[];
|
|
131
|
+
events: string[];
|
|
132
|
+
guards: string[];
|
|
133
|
+
pages: string[];
|
|
134
|
+
effects: string[];
|
|
135
|
+
rawRequirements: string[];
|
|
136
|
+
} | undefined;
|
|
137
|
+
github?: {
|
|
138
|
+
token: string;
|
|
139
|
+
owner?: string | undefined;
|
|
140
|
+
repo?: string | undefined;
|
|
141
|
+
} | undefined;
|
|
142
|
+
}, {
|
|
143
|
+
message: string;
|
|
144
|
+
skill: string | string[];
|
|
145
|
+
threadId?: string | undefined;
|
|
146
|
+
workspace?: string | undefined;
|
|
147
|
+
provider?: "anthropic" | "openai" | "deepseek" | undefined;
|
|
148
|
+
model?: string | undefined;
|
|
149
|
+
noInterrupt?: boolean | undefined;
|
|
150
|
+
appId?: string | undefined;
|
|
151
|
+
requirements?: {
|
|
152
|
+
entities?: string[] | undefined;
|
|
153
|
+
states?: string[] | undefined;
|
|
154
|
+
events?: string[] | undefined;
|
|
155
|
+
guards?: string[] | undefined;
|
|
156
|
+
pages?: string[] | undefined;
|
|
157
|
+
effects?: string[] | undefined;
|
|
158
|
+
rawRequirements?: string[] | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
github?: {
|
|
161
|
+
token: string;
|
|
162
|
+
owner?: string | undefined;
|
|
163
|
+
repo?: string | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
type GenerateRequest = z.infer<typeof GenerateRequestSchema>;
|
|
167
|
+
/**
|
|
168
|
+
* Resume request schema - for resuming after interrupt.
|
|
169
|
+
*/
|
|
170
|
+
declare const ResumeRequestSchema: z.ZodObject<{
|
|
171
|
+
/** Required: Thread ID to resume */
|
|
172
|
+
threadId: z.ZodString;
|
|
173
|
+
/** Required: Decisions for pending interrupts */
|
|
174
|
+
decisions: z.ZodArray<z.ZodObject<{
|
|
175
|
+
type: z.ZodEnum<["approve", "edit", "reject"]>;
|
|
176
|
+
args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
177
|
+
}, "strip", z.ZodTypeAny, {
|
|
178
|
+
type: "approve" | "edit" | "reject";
|
|
179
|
+
args?: Record<string, unknown> | undefined;
|
|
180
|
+
}, {
|
|
181
|
+
type: "approve" | "edit" | "reject";
|
|
182
|
+
args?: Record<string, unknown> | undefined;
|
|
183
|
+
}>, "many">;
|
|
184
|
+
/** Optional: Approve all future actions */
|
|
185
|
+
approveAll: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
}, "strip", z.ZodTypeAny, {
|
|
187
|
+
threadId: string;
|
|
188
|
+
decisions: {
|
|
189
|
+
type: "approve" | "edit" | "reject";
|
|
190
|
+
args?: Record<string, unknown> | undefined;
|
|
191
|
+
}[];
|
|
192
|
+
approveAll?: boolean | undefined;
|
|
193
|
+
}, {
|
|
194
|
+
threadId: string;
|
|
195
|
+
decisions: {
|
|
196
|
+
type: "approve" | "edit" | "reject";
|
|
197
|
+
args?: Record<string, unknown> | undefined;
|
|
198
|
+
}[];
|
|
199
|
+
approveAll?: boolean | undefined;
|
|
200
|
+
}>;
|
|
201
|
+
type ResumeRequest = z.infer<typeof ResumeRequestSchema>;
|
|
202
|
+
/**
|
|
203
|
+
* Continue request schema - for multi-turn conversation.
|
|
204
|
+
*/
|
|
205
|
+
declare const ContinueRequestSchema: z.ZodObject<{
|
|
206
|
+
/** Required: Thread ID to continue */
|
|
207
|
+
threadId: z.ZodString;
|
|
208
|
+
/** Required: Follow-up message */
|
|
209
|
+
message: z.ZodString;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
message: string;
|
|
212
|
+
threadId: string;
|
|
213
|
+
}, {
|
|
214
|
+
message: string;
|
|
215
|
+
threadId: string;
|
|
216
|
+
}>;
|
|
217
|
+
type ContinueRequest = z.infer<typeof ContinueRequestSchema>;
|
|
218
|
+
/**
|
|
219
|
+
* All possible SSE event types.
|
|
220
|
+
*/
|
|
221
|
+
type SSEEventType = 'start' | 'message' | 'tool_call' | 'tool_result' | 'todo_update' | 'todo_detail' | 'file_operation' | 'schema_update' | 'generation_log' | 'subagent_event' | 'interrupt' | 'error' | 'complete' | 'cancelled' | 'app_created' | 'schema_phase_validated' | 'schema_phase_update' | 'orbital_added' | 'orbital_schema_complete' | 'changeset_recorded' | 'snapshot_created';
|
|
222
|
+
/**
|
|
223
|
+
* Base SSE event structure.
|
|
224
|
+
*/
|
|
225
|
+
interface SSEEventBase {
|
|
226
|
+
type: SSEEventType;
|
|
227
|
+
timestamp: number;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Start event - sent when streaming begins.
|
|
231
|
+
*/
|
|
232
|
+
interface StartEvent extends SSEEventBase {
|
|
233
|
+
type: 'start';
|
|
234
|
+
data: {
|
|
235
|
+
threadId: string;
|
|
236
|
+
skill: string;
|
|
237
|
+
workDir: string;
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Message event - agent text output.
|
|
242
|
+
*/
|
|
243
|
+
interface MessageEvent extends SSEEventBase {
|
|
244
|
+
type: 'message';
|
|
245
|
+
data: {
|
|
246
|
+
content: string;
|
|
247
|
+
role: 'assistant' | 'user' | 'system';
|
|
248
|
+
isComplete: boolean;
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Tool call event - when agent invokes a tool.
|
|
253
|
+
*/
|
|
254
|
+
interface ToolCallEvent extends SSEEventBase {
|
|
255
|
+
type: 'tool_call';
|
|
256
|
+
data: {
|
|
257
|
+
tool: string;
|
|
258
|
+
args: Record<string, unknown>;
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Tool result event - tool execution result.
|
|
263
|
+
*/
|
|
264
|
+
interface ToolResultEvent extends SSEEventBase {
|
|
265
|
+
type: 'tool_result';
|
|
266
|
+
data: {
|
|
267
|
+
tool: string;
|
|
268
|
+
result: unknown;
|
|
269
|
+
success: boolean;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Todo update event - task progress.
|
|
274
|
+
*/
|
|
275
|
+
interface TodoUpdateEvent extends SSEEventBase {
|
|
276
|
+
type: 'todo_update';
|
|
277
|
+
data: {
|
|
278
|
+
todos: Array<{
|
|
279
|
+
id: string;
|
|
280
|
+
task: string;
|
|
281
|
+
status: 'pending' | 'in_progress' | 'completed';
|
|
282
|
+
}>;
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Activity type for todo details.
|
|
287
|
+
*/
|
|
288
|
+
type TodoActivityType = 'thinking' | 'tool_call' | 'tool_result' | 'code_change';
|
|
289
|
+
/**
|
|
290
|
+
* Todo detail event - shows LLM activity for a specific todo.
|
|
291
|
+
*/
|
|
292
|
+
interface TodoDetailEvent extends SSEEventBase {
|
|
293
|
+
type: 'todo_detail';
|
|
294
|
+
data: {
|
|
295
|
+
todoId: string;
|
|
296
|
+
activityType: TodoActivityType;
|
|
297
|
+
content: string;
|
|
298
|
+
tool?: string;
|
|
299
|
+
args?: Record<string, unknown>;
|
|
300
|
+
success?: boolean;
|
|
301
|
+
filePath?: string;
|
|
302
|
+
diff?: string;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* File operation event.
|
|
307
|
+
*/
|
|
308
|
+
interface FileOperationEvent extends SSEEventBase {
|
|
309
|
+
type: 'file_operation';
|
|
310
|
+
data: {
|
|
311
|
+
operation: 'ls' | 'read_file' | 'write_file' | 'edit_file';
|
|
312
|
+
path: string;
|
|
313
|
+
success: boolean;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Schema update event.
|
|
318
|
+
*/
|
|
319
|
+
interface SchemaUpdateEvent extends SSEEventBase {
|
|
320
|
+
type: 'schema_update';
|
|
321
|
+
data: {
|
|
322
|
+
appId: string;
|
|
323
|
+
version: number;
|
|
324
|
+
schema: Record<string, unknown>;
|
|
325
|
+
isNew: boolean;
|
|
326
|
+
snapshotId?: string;
|
|
327
|
+
changesetId?: string;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Generation log event.
|
|
332
|
+
*/
|
|
333
|
+
interface GenerationLogEvent extends SSEEventBase {
|
|
334
|
+
type: 'generation_log';
|
|
335
|
+
data: {
|
|
336
|
+
level: 'info' | 'warn' | 'error' | 'debug';
|
|
337
|
+
message: string;
|
|
338
|
+
data?: Record<string, unknown>;
|
|
339
|
+
orbitalName?: string;
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Interrupt event - awaiting human decision.
|
|
344
|
+
*/
|
|
345
|
+
interface InterruptEvent extends SSEEventBase {
|
|
346
|
+
type: 'interrupt';
|
|
347
|
+
data: {
|
|
348
|
+
threadId: string;
|
|
349
|
+
actionRequests: Array<{
|
|
350
|
+
tool: string;
|
|
351
|
+
args: Record<string, unknown>;
|
|
352
|
+
allowedDecisions: ('approve' | 'edit' | 'reject')[];
|
|
353
|
+
description?: string;
|
|
354
|
+
}>;
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Error event.
|
|
359
|
+
*/
|
|
360
|
+
interface ErrorEvent extends SSEEventBase {
|
|
361
|
+
type: 'error';
|
|
362
|
+
data: {
|
|
363
|
+
error: string;
|
|
364
|
+
code?: string;
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Cancelled event.
|
|
369
|
+
*/
|
|
370
|
+
interface CancelledEvent extends SSEEventBase {
|
|
371
|
+
type: 'cancelled';
|
|
372
|
+
data: {
|
|
373
|
+
threadId: string;
|
|
374
|
+
message: string;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Complete event - when generation finishes.
|
|
379
|
+
*/
|
|
380
|
+
interface CompleteEvent extends SSEEventBase {
|
|
381
|
+
type: 'complete';
|
|
382
|
+
data: {
|
|
383
|
+
threadId: string;
|
|
384
|
+
skill: string;
|
|
385
|
+
workDir: string;
|
|
386
|
+
schemaGenerated: boolean;
|
|
387
|
+
appCompiled: boolean;
|
|
388
|
+
schema?: Record<string, unknown>;
|
|
389
|
+
appId?: string;
|
|
390
|
+
schemaPersisted?: boolean;
|
|
391
|
+
snapshotId?: string;
|
|
392
|
+
changesetId?: string;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Subagent event - forwards events from nested agent.
|
|
397
|
+
*/
|
|
398
|
+
interface SubagentEvent extends SSEEventBase {
|
|
399
|
+
type: 'subagent_event';
|
|
400
|
+
data: {
|
|
401
|
+
orbitalName: string;
|
|
402
|
+
orbitalIndex: number;
|
|
403
|
+
totalOrbitals: number;
|
|
404
|
+
event: {
|
|
405
|
+
type: Exclude<SSEEventType, 'subagent_event'>;
|
|
406
|
+
data: Record<string, unknown>;
|
|
407
|
+
timestamp: number;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* App created event.
|
|
413
|
+
*/
|
|
414
|
+
interface AppCreatedEvent extends SSEEventBase {
|
|
415
|
+
type: 'app_created';
|
|
416
|
+
data: {
|
|
417
|
+
appId: string;
|
|
418
|
+
name?: string;
|
|
419
|
+
orbitalCount?: number;
|
|
420
|
+
fromOrbitalPersistence?: boolean;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Schema phase validated event.
|
|
425
|
+
*/
|
|
426
|
+
interface SchemaPhaseValidatedEvent extends SSEEventBase {
|
|
427
|
+
type: 'schema_phase_validated';
|
|
428
|
+
data: {
|
|
429
|
+
appId: string;
|
|
430
|
+
success: boolean;
|
|
431
|
+
errors?: unknown[];
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Schema phase update event.
|
|
436
|
+
*/
|
|
437
|
+
interface SchemaPhaseUpdateEvent extends SSEEventBase {
|
|
438
|
+
type: 'schema_phase_update';
|
|
439
|
+
data: Record<string, unknown>;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Orbital added event.
|
|
443
|
+
*/
|
|
444
|
+
interface OrbitalAddedEvent extends SSEEventBase {
|
|
445
|
+
type: 'orbital_added';
|
|
446
|
+
data: {
|
|
447
|
+
appId: string;
|
|
448
|
+
orbitalName: string;
|
|
449
|
+
orbitalIndex: number;
|
|
450
|
+
totalOrbitals: number;
|
|
451
|
+
isNew?: boolean;
|
|
452
|
+
orbitalSchema?: Record<string, unknown>;
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Orbital schema complete event.
|
|
457
|
+
*/
|
|
458
|
+
interface OrbitalSchemaCompleteEvent extends SSEEventBase {
|
|
459
|
+
type: 'orbital_schema_complete';
|
|
460
|
+
data: {
|
|
461
|
+
appId: string;
|
|
462
|
+
totalOrbitals: number;
|
|
463
|
+
orbitalNames: string[];
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Changeset recorded event.
|
|
468
|
+
*/
|
|
469
|
+
interface ChangesetRecordedEvent extends SSEEventBase {
|
|
470
|
+
type: 'changeset_recorded';
|
|
471
|
+
data: {
|
|
472
|
+
appId: string;
|
|
473
|
+
changesetId: string;
|
|
474
|
+
version: number;
|
|
475
|
+
trackingMode: 'initial' | 'update';
|
|
476
|
+
summary: {
|
|
477
|
+
added: number;
|
|
478
|
+
modified: number;
|
|
479
|
+
removed: number;
|
|
480
|
+
};
|
|
481
|
+
source?: string;
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Snapshot created event.
|
|
486
|
+
*/
|
|
487
|
+
interface SnapshotCreatedEvent extends SSEEventBase {
|
|
488
|
+
type: 'snapshot_created';
|
|
489
|
+
data: {
|
|
490
|
+
appId: string;
|
|
491
|
+
snapshotId: string;
|
|
492
|
+
version: number;
|
|
493
|
+
reason: string;
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Union of all SSE event types.
|
|
498
|
+
*/
|
|
499
|
+
type SSEEvent = StartEvent | MessageEvent | ToolCallEvent | ToolResultEvent | TodoUpdateEvent | TodoDetailEvent | FileOperationEvent | SchemaUpdateEvent | GenerationLogEvent | SubagentEvent | InterruptEvent | ErrorEvent | CancelledEvent | CompleteEvent | AppCreatedEvent | SchemaPhaseValidatedEvent | SchemaPhaseUpdateEvent | OrbitalAddedEvent | OrbitalSchemaCompleteEvent | ChangesetRecordedEvent | SnapshotCreatedEvent;
|
|
500
|
+
/**
|
|
501
|
+
* Create an SSE event with timestamp.
|
|
502
|
+
*/
|
|
503
|
+
declare function createSSEEvent<T extends SSEEventType>(type: T, data: Extract<SSEEvent, {
|
|
504
|
+
type: T;
|
|
505
|
+
}>['data']): Extract<SSEEvent, {
|
|
506
|
+
type: T;
|
|
507
|
+
}>;
|
|
508
|
+
/**
|
|
509
|
+
* Format an SSE event for transmission.
|
|
510
|
+
*/
|
|
511
|
+
declare function formatSSEEvent(event: SSEEvent): string;
|
|
512
|
+
/**
|
|
513
|
+
* Parse an SSE event from a data string.
|
|
514
|
+
*/
|
|
515
|
+
declare function parseSSEEvent(data: string): SSEEvent;
|
|
516
|
+
/**
|
|
517
|
+
* Type guard for SSE start events.
|
|
518
|
+
*/
|
|
519
|
+
declare function isSSEStartEvent(event: SSEEvent): event is StartEvent;
|
|
520
|
+
/**
|
|
521
|
+
* Type guard for SSE message events.
|
|
522
|
+
*/
|
|
523
|
+
declare function isSSEMessageEvent(event: SSEEvent): event is MessageEvent;
|
|
524
|
+
/**
|
|
525
|
+
* Type guard for SSE interrupt events.
|
|
526
|
+
*/
|
|
527
|
+
declare function isSSEInterruptEvent(event: SSEEvent): event is InterruptEvent;
|
|
528
|
+
/**
|
|
529
|
+
* Type guard for SSE complete events.
|
|
530
|
+
*/
|
|
531
|
+
declare function isSSECompleteEvent(event: SSEEvent): event is CompleteEvent;
|
|
532
|
+
/**
|
|
533
|
+
* Type guard for SSE error events.
|
|
534
|
+
*/
|
|
535
|
+
declare function isSSEErrorEvent(event: SSEEvent): event is ErrorEvent;
|
|
536
|
+
/**
|
|
537
|
+
* Type guard for SSE tool call events.
|
|
538
|
+
*/
|
|
539
|
+
declare function isSSEToolCallEvent(event: SSEEvent): event is ToolCallEvent;
|
|
540
|
+
/**
|
|
541
|
+
* Type guard for SSE todo update events.
|
|
542
|
+
*/
|
|
543
|
+
declare function isSSETodoUpdateEvent(event: SSEEvent): event is TodoUpdateEvent;
|
|
544
|
+
/**
|
|
545
|
+
* Type guard for SSE todo detail events.
|
|
546
|
+
*/
|
|
547
|
+
declare function isSSETodoDetailEvent(event: SSEEvent): event is TodoDetailEvent;
|
|
548
|
+
/**
|
|
549
|
+
* Type guard for SSE subagent events.
|
|
550
|
+
*/
|
|
551
|
+
declare function isSSESubagentEvent(event: SSEEvent): event is SubagentEvent;
|
|
552
|
+
/**
|
|
553
|
+
* Type guard for SSE generation log events.
|
|
554
|
+
*/
|
|
555
|
+
declare function isSSEGenerationLogEvent(event: SSEEvent): event is GenerationLogEvent;
|
|
556
|
+
|
|
557
|
+
export { type CompleteEvent as C, type ErrorEvent as E, type GenerateRequest as G, type InterruptEvent as I, type MessageEvent as M, type ResumeRequest as R, type SSEEventType as S, type TodoUpdateEvent as T, type SSEEvent as a, type ContinueRequest as b, ContinueRequestSchema as c, type ExtractedRequirementsInput as d, ExtractedRequirementsSchema as e, GenerateRequestSchema as f, type GenerationLogEvent as g, ResumeRequestSchema as h, type StartEvent as i, type SubagentEvent as j, type ToolCallEvent as k, type ToolResultEvent as l, createSSEEvent as m, formatSSEEvent as n, isSSECompleteEvent as o, isSSEErrorEvent as p, isSSEGenerationLogEvent as q, isSSEInterruptEvent as r, isSSEMessageEvent as s, isSSEStartEvent as t, isSSESubagentEvent as u, isSSETodoDetailEvent as v, isSSETodoUpdateEvent as w, isSSEToolCallEvent as x, parseSSEEvent as y };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { a as SSEEvent } from '../api-types-BW_58thJ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Event Transformer for DeepAgent
|
|
6
|
+
*
|
|
7
|
+
* Transforms raw LangGraph/deepagents events into SSE events.
|
|
8
|
+
* Handles special events like todo updates and file operations.
|
|
9
|
+
*
|
|
10
|
+
* Supports both:
|
|
11
|
+
* - LangGraph event structures (event.tools, event.model_request)
|
|
12
|
+
* - Legacy flat event structures (event.todos, event.tool_call)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Raw agent event from LangGraph/deepagents.
|
|
17
|
+
*/
|
|
18
|
+
interface RawAgentEvent {
|
|
19
|
+
tools?: {
|
|
20
|
+
todos?: Array<{
|
|
21
|
+
content?: string;
|
|
22
|
+
task?: string;
|
|
23
|
+
status?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
}>;
|
|
26
|
+
messages?: Array<Record<string, unknown>>;
|
|
27
|
+
};
|
|
28
|
+
model_request?: {
|
|
29
|
+
messages?: Array<Record<string, unknown>>;
|
|
30
|
+
};
|
|
31
|
+
messages?: Array<{
|
|
32
|
+
role?: string;
|
|
33
|
+
content?: string;
|
|
34
|
+
}>;
|
|
35
|
+
tool_call?: {
|
|
36
|
+
name?: string;
|
|
37
|
+
args?: Record<string, unknown>;
|
|
38
|
+
};
|
|
39
|
+
toolCall?: {
|
|
40
|
+
name?: string;
|
|
41
|
+
args?: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
tool_result?: {
|
|
44
|
+
name?: string;
|
|
45
|
+
result?: unknown;
|
|
46
|
+
};
|
|
47
|
+
toolResult?: {
|
|
48
|
+
name?: string;
|
|
49
|
+
result?: unknown;
|
|
50
|
+
};
|
|
51
|
+
todos?: Array<{
|
|
52
|
+
id?: string;
|
|
53
|
+
task?: string;
|
|
54
|
+
status?: 'pending' | 'in_progress' | 'completed';
|
|
55
|
+
}>;
|
|
56
|
+
__interrupt__?: Array<{
|
|
57
|
+
value?: {
|
|
58
|
+
actionRequests?: Array<{
|
|
59
|
+
name?: string;
|
|
60
|
+
args?: Record<string, unknown>;
|
|
61
|
+
description?: string;
|
|
62
|
+
}>;
|
|
63
|
+
reviewConfigs?: Array<{
|
|
64
|
+
allowedDecisions?: string[];
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
action?: {
|
|
68
|
+
tool?: string;
|
|
69
|
+
toolInput?: Record<string, unknown>;
|
|
70
|
+
};
|
|
71
|
+
config?: {
|
|
72
|
+
allowedDecisions?: string[];
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Transform a raw agent event to SSE event(s).
|
|
79
|
+
*
|
|
80
|
+
* Handles both LangGraph nested structures and legacy flat structures.
|
|
81
|
+
* Returns an array for consistency with multi-event scenarios.
|
|
82
|
+
*
|
|
83
|
+
* @param event Raw agent event
|
|
84
|
+
* @param threadId Thread ID for context
|
|
85
|
+
* @returns Array of SSE events
|
|
86
|
+
*/
|
|
87
|
+
declare function transformAgentEvent(event: RawAgentEvent, threadId?: string): SSEEvent;
|
|
88
|
+
/**
|
|
89
|
+
* Transform a raw agent event to multiple SSE events.
|
|
90
|
+
* Use this when you need to handle all events from a single LangGraph event.
|
|
91
|
+
*/
|
|
92
|
+
declare function transformAgentEventMulti(event: RawAgentEvent, threadId?: string): SSEEvent[];
|
|
93
|
+
/**
|
|
94
|
+
* Check if an event contains an interrupt.
|
|
95
|
+
*/
|
|
96
|
+
declare function hasInterrupt(event: RawAgentEvent): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Extract interrupt data from an event.
|
|
99
|
+
*/
|
|
100
|
+
declare function extractInterruptData(event: RawAgentEvent, threadId: string): {
|
|
101
|
+
threadId: string;
|
|
102
|
+
actionRequests: Array<{
|
|
103
|
+
tool: string;
|
|
104
|
+
args: Record<string, unknown>;
|
|
105
|
+
allowedDecisions: ('approve' | 'edit' | 'reject')[];
|
|
106
|
+
description?: string;
|
|
107
|
+
}>;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Check if an event is a todo update.
|
|
111
|
+
*/
|
|
112
|
+
declare function isTodoUpdate(event: RawAgentEvent): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Check if an event is a file operation.
|
|
115
|
+
*/
|
|
116
|
+
declare function isFileOperation(event: RawAgentEvent): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Extract file operation details from an event.
|
|
119
|
+
*/
|
|
120
|
+
declare function extractFileOperation(event: RawAgentEvent): {
|
|
121
|
+
operation: string;
|
|
122
|
+
path: string;
|
|
123
|
+
} | null;
|
|
124
|
+
|
|
125
|
+
export { type RawAgentEvent, extractFileOperation, extractInterruptData, hasInterrupt, isFileOperation, isTodoUpdate, transformAgentEvent, transformAgentEventMulti };
|