noumen 0.1.0 → 0.3.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.
Files changed (127) hide show
  1. package/README.md +846 -51
  2. package/dist/a2a/index.d.ts +148 -0
  3. package/dist/a2a/index.js +579 -0
  4. package/dist/a2a/index.js.map +1 -0
  5. package/dist/acp/index.d.ts +129 -0
  6. package/dist/acp/index.js +498 -0
  7. package/dist/acp/index.js.map +1 -0
  8. package/dist/agent-1nFVUP9E.d.ts +1332 -0
  9. package/dist/cache-DsRqxx6v.d.ts +38 -0
  10. package/dist/chunk-3HEYCV26.js +10 -0
  11. package/dist/chunk-3HEYCV26.js.map +1 -0
  12. package/dist/chunk-3SK5GCI6.js +75 -0
  13. package/dist/chunk-3SK5GCI6.js.map +1 -0
  14. package/dist/chunk-42PHHZUA.js +132 -0
  15. package/dist/chunk-42PHHZUA.js.map +1 -0
  16. package/dist/chunk-4HW6LN6D.js +10365 -0
  17. package/dist/chunk-4HW6LN6D.js.map +1 -0
  18. package/dist/chunk-4SQA2UCV.js +26 -0
  19. package/dist/chunk-4SQA2UCV.js.map +1 -0
  20. package/dist/chunk-5GEX6ZSB.js +179 -0
  21. package/dist/chunk-5GEX6ZSB.js.map +1 -0
  22. package/dist/chunk-5JN4SPI7.js +94 -0
  23. package/dist/chunk-5JN4SPI7.js.map +1 -0
  24. package/dist/chunk-AMYIJSAZ.js +57 -0
  25. package/dist/chunk-AMYIJSAZ.js.map +1 -0
  26. package/dist/chunk-BZSFUEWM.js +43 -0
  27. package/dist/chunk-BZSFUEWM.js.map +1 -0
  28. package/dist/chunk-CS6WNDCF.js +171 -0
  29. package/dist/chunk-CS6WNDCF.js.map +1 -0
  30. package/dist/chunk-D43BWEZA.js +346 -0
  31. package/dist/chunk-D43BWEZA.js.map +1 -0
  32. package/dist/chunk-DGUM43GV.js +11 -0
  33. package/dist/chunk-DGUM43GV.js.map +1 -0
  34. package/dist/chunk-EKOGVTBT.js +472 -0
  35. package/dist/chunk-EKOGVTBT.js.map +1 -0
  36. package/dist/chunk-HEQQQGK5.js +131 -0
  37. package/dist/chunk-HEQQQGK5.js.map +1 -0
  38. package/dist/chunk-HL6JCRZJ.js +3112 -0
  39. package/dist/chunk-HL6JCRZJ.js.map +1 -0
  40. package/dist/chunk-JACGEMTF.js +43 -0
  41. package/dist/chunk-JACGEMTF.js.map +1 -0
  42. package/dist/chunk-JX7CLUCV.js +21 -0
  43. package/dist/chunk-JX7CLUCV.js.map +1 -0
  44. package/dist/chunk-KXDB56YW.js +39 -0
  45. package/dist/chunk-KXDB56YW.js.map +1 -0
  46. package/dist/chunk-L3L3FG5T.js +16 -0
  47. package/dist/chunk-L3L3FG5T.js.map +1 -0
  48. package/dist/chunk-OGXNFXFA.js +196 -0
  49. package/dist/chunk-OGXNFXFA.js.map +1 -0
  50. package/dist/chunk-UVSSQBDY.js +192 -0
  51. package/dist/chunk-UVSSQBDY.js.map +1 -0
  52. package/dist/chunk-Y45R3PQL.js +684 -0
  53. package/dist/chunk-Y45R3PQL.js.map +1 -0
  54. package/dist/cli/index.d.ts +1 -0
  55. package/dist/cli/index.js +874 -0
  56. package/dist/cli/index.js.map +1 -0
  57. package/dist/client/index.d.ts +64 -0
  58. package/dist/client/index.js +409 -0
  59. package/dist/client/index.js.map +1 -0
  60. package/dist/client-CRRO2376.js +10 -0
  61. package/dist/client-CRRO2376.js.map +1 -0
  62. package/dist/headless-FFU2DESQ.js +142 -0
  63. package/dist/headless-FFU2DESQ.js.map +1 -0
  64. package/dist/history-snip-64GYP4ZL.js +12 -0
  65. package/dist/history-snip-64GYP4ZL.js.map +1 -0
  66. package/dist/index.d.ts +1459 -422
  67. package/dist/index.js +398 -1757
  68. package/dist/index.js.map +1 -1
  69. package/dist/jsonrpc/index.d.ts +54 -0
  70. package/dist/jsonrpc/index.js +34 -0
  71. package/dist/jsonrpc/index.js.map +1 -0
  72. package/dist/lsp/index.d.ts +36 -0
  73. package/dist/lsp/index.js +16 -0
  74. package/dist/lsp/index.js.map +1 -0
  75. package/dist/lsp-PS3BWIHC.js +8 -0
  76. package/dist/lsp-PS3BWIHC.js.map +1 -0
  77. package/dist/manager-DLXK63XC.js +8 -0
  78. package/dist/manager-DLXK63XC.js.map +1 -0
  79. package/dist/mcp/index.d.ts +111 -0
  80. package/dist/mcp/index.js +105 -0
  81. package/dist/mcp/index.js.map +1 -0
  82. package/dist/mcp-auth-AEI2R4ZC.js +9 -0
  83. package/dist/mcp-auth-AEI2R4ZC.js.map +1 -0
  84. package/dist/provider-factory-KCLIF34X.js +20 -0
  85. package/dist/provider-factory-KCLIF34X.js.map +1 -0
  86. package/dist/providers/anthropic.d.ts +19 -0
  87. package/dist/providers/anthropic.js +35 -0
  88. package/dist/providers/anthropic.js.map +1 -0
  89. package/dist/providers/bedrock.d.ts +39 -0
  90. package/dist/providers/bedrock.js +56 -0
  91. package/dist/providers/bedrock.js.map +1 -0
  92. package/dist/providers/gemini.d.ts +17 -0
  93. package/dist/providers/gemini.js +262 -0
  94. package/dist/providers/gemini.js.map +1 -0
  95. package/dist/providers/ollama.d.ts +13 -0
  96. package/dist/providers/ollama.js +20 -0
  97. package/dist/providers/ollama.js.map +1 -0
  98. package/dist/providers/openai.d.ts +21 -0
  99. package/dist/providers/openai.js +9 -0
  100. package/dist/providers/openai.js.map +1 -0
  101. package/dist/providers/openrouter.d.ts +16 -0
  102. package/dist/providers/openrouter.js +24 -0
  103. package/dist/providers/openrouter.js.map +1 -0
  104. package/dist/providers/vertex.d.ts +42 -0
  105. package/dist/providers/vertex.js +67 -0
  106. package/dist/providers/vertex.js.map +1 -0
  107. package/dist/render-GRN4ZSSW.js +14 -0
  108. package/dist/render-GRN4ZSSW.js.map +1 -0
  109. package/dist/resolve-4JA2BBDA.js +14 -0
  110. package/dist/resolve-4JA2BBDA.js.map +1 -0
  111. package/dist/server/index.d.ts +143 -0
  112. package/dist/server/index.js +695 -0
  113. package/dist/server/index.js.map +1 -0
  114. package/dist/server-CHMxuWKq.d.ts +96 -0
  115. package/dist/spinner-OJNR6NFO.js +8 -0
  116. package/dist/spinner-OJNR6NFO.js.map +1 -0
  117. package/dist/types-2kTLUCnD.d.ts +107 -0
  118. package/dist/types-CD0rUKKT.d.ts +109 -0
  119. package/dist/types-LrU4LRmX.d.ts +575 -0
  120. package/dist/types-NIyVwQ4h.d.ts +109 -0
  121. package/dist/types-QwfylltH.d.ts +71 -0
  122. package/dist/types-RPKUTu1k.d.ts +645 -0
  123. package/dist/uuid-RVN2T26F.js +8 -0
  124. package/dist/uuid-RVN2T26F.js.map +1 -0
  125. package/dist/zod-7YXKWYMC.js +12 -0
  126. package/dist/zod-7YXKWYMC.js.map +1 -0
  127. package/package.json +141 -7
@@ -0,0 +1,575 @@
1
+ /**
2
+ * USD cost per 1 million tokens for a given model.
3
+ */
4
+ interface ModelPricing {
5
+ inputTokens: number;
6
+ outputTokens: number;
7
+ cacheReadTokens?: number;
8
+ cacheWriteTokens?: number;
9
+ }
10
+ /**
11
+ * Token usage from a single API call, extending the base ChatCompletionUsage
12
+ * with cache and thinking token counts.
13
+ */
14
+ interface UsageRecord {
15
+ prompt_tokens: number;
16
+ completion_tokens: number;
17
+ total_tokens: number;
18
+ cache_read_tokens?: number;
19
+ cache_creation_tokens?: number;
20
+ thinking_tokens?: number;
21
+ }
22
+ /**
23
+ * Accumulated usage and cost for a single model.
24
+ */
25
+ interface ModelUsageSummary {
26
+ inputTokens: number;
27
+ outputTokens: number;
28
+ thinkingTokens: number;
29
+ cacheReadTokens: number;
30
+ cacheCreationTokens: number;
31
+ costUSD: number;
32
+ }
33
+ /**
34
+ * Complete cost summary across all models in the session.
35
+ */
36
+ interface CostSummary {
37
+ totalCostUSD: number;
38
+ totalInputTokens: number;
39
+ totalOutputTokens: number;
40
+ totalThinkingTokens: number;
41
+ totalCacheReadTokens: number;
42
+ totalCacheCreationTokens: number;
43
+ byModel: Record<string, ModelUsageSummary>;
44
+ duration: {
45
+ apiMs: number;
46
+ wallMs: number;
47
+ };
48
+ }
49
+
50
+ type UUID = string & {
51
+ readonly __brand: unique symbol;
52
+ };
53
+
54
+ type MemoryType = "user" | "project" | "feedback" | "reference";
55
+ interface MemoryEntry {
56
+ /** Short identifier used as the basis for the filename. */
57
+ name: string;
58
+ /** One-line summary of what this memory contains. */
59
+ description: string;
60
+ type: MemoryType;
61
+ /** Full markdown content of the memory (excluding frontmatter). */
62
+ content: string;
63
+ /** Relative path within the memory directory (e.g. `"user_prefs.md"`). */
64
+ path?: string;
65
+ updatedAt?: string;
66
+ }
67
+ interface MemoryProvider {
68
+ /** Load the MEMORY.md index content for system-prompt injection. */
69
+ loadIndex(): Promise<string>;
70
+ /** Load a single memory entry by its path within the memory directory. */
71
+ loadEntry(path: string): Promise<MemoryEntry | null>;
72
+ /** Write or update a memory entry and refresh the index. */
73
+ saveEntry(entry: MemoryEntry): Promise<void>;
74
+ /** Delete a memory entry and refresh the index. */
75
+ removeEntry(path: string): Promise<void>;
76
+ /** List all memory entries in the directory. */
77
+ listEntries(): Promise<MemoryEntry[]>;
78
+ /** Simple keyword search across entry names and content. */
79
+ search(query: string): Promise<MemoryEntry[]>;
80
+ }
81
+ interface MemoryConfig {
82
+ provider: MemoryProvider;
83
+ /** Run LLM-driven memory extraction after each turn (default: false). */
84
+ autoExtract?: boolean;
85
+ /** Maximum number of lines in the MEMORY.md index before truncation (default: 200). */
86
+ maxIndexLines?: number;
87
+ /** Inject the memory index into the system prompt (default: true). */
88
+ injectIntoSystemPrompt?: boolean;
89
+ }
90
+
91
+ /**
92
+ * File checkpointing types.
93
+ *
94
+ * Adapted from claude-code's fileHistory system. Key difference: all I/O
95
+ * routes through VirtualFs so checkpointing works in any sandbox (Docker,
96
+ * E2B, Sprites, local).
97
+ */
98
+ interface FileCheckpointBackup {
99
+ /** Backup filename under the session backup dir, or null if the file did not exist at this version. */
100
+ backupFileName: string | null;
101
+ version: number;
102
+ backupTime: string;
103
+ }
104
+ interface FileCheckpointSnapshot {
105
+ messageId: string;
106
+ /** Map of tracked file paths → their backup at this snapshot. */
107
+ trackedFileBackups: Record<string, FileCheckpointBackup>;
108
+ timestamp: string;
109
+ }
110
+ interface FileCheckpointState {
111
+ snapshots: FileCheckpointSnapshot[];
112
+ trackedFiles: Set<string>;
113
+ /**
114
+ * Monotonically-increasing counter incremented on every snapshot, even when
115
+ * old snapshots are evicted. Useful as an activity signal (snapshots.length
116
+ * plateaus once the cap is reached).
117
+ */
118
+ snapshotSequence: number;
119
+ }
120
+ interface CheckpointConfig {
121
+ enabled: boolean;
122
+ /** Maximum number of snapshots to retain before evicting oldest. Default: 100. */
123
+ maxSnapshots?: number;
124
+ /** Base directory for backup files. Default: ".noumen/checkpoints". */
125
+ backupDir?: string;
126
+ }
127
+ type DiffStats = {
128
+ filesChanged?: string[];
129
+ insertions: number;
130
+ deletions: number;
131
+ } | undefined;
132
+ declare function createCheckpointState(): FileCheckpointState;
133
+
134
+ interface TextContent {
135
+ type: "text";
136
+ text: string;
137
+ }
138
+ interface ImageContent {
139
+ type: "image";
140
+ /** base64-encoded image data */
141
+ data: string;
142
+ /** MIME type: "image/png", "image/jpeg", "image/gif", "image/webp" */
143
+ media_type: string;
144
+ }
145
+ interface ImageUrlContent {
146
+ type: "image_url";
147
+ /** URL pointing to an image */
148
+ url: string;
149
+ }
150
+ type ContentPart = TextContent | ImageContent | ImageUrlContent;
151
+ interface ToolCallContent {
152
+ id: string;
153
+ type: "function";
154
+ function: {
155
+ name: string;
156
+ arguments: string;
157
+ };
158
+ }
159
+ interface UserMessage {
160
+ role: "user";
161
+ content: string | ContentPart[];
162
+ }
163
+ interface AssistantMessage {
164
+ role: "assistant";
165
+ content: string | null;
166
+ tool_calls?: ToolCallContent[];
167
+ /** Accumulated thinking content for providers that support extended thinking (e.g. Anthropic). */
168
+ thinking_content?: string;
169
+ /** Thinking signature required by Anthropic to verify thinking blocks across turns. */
170
+ thinking_signature?: string;
171
+ /** Opaque data for Anthropic redacted_thinking blocks — must be echoed back verbatim. */
172
+ redacted_thinking_data?: string;
173
+ /**
174
+ * Internal turn identifier linking assistant chunks from the same provider
175
+ * response. Used by normalization to merge non-adjacent assistant messages
176
+ * that belong to the same logical turn (separated by tool result rows).
177
+ * Stripped before sending to providers.
178
+ */
179
+ _turnId?: string;
180
+ }
181
+ interface ToolResultMessage {
182
+ role: "tool";
183
+ tool_call_id: string;
184
+ content: string | ContentPart[];
185
+ /** When true, signals to the provider that this tool result is an error. */
186
+ isError?: boolean;
187
+ }
188
+ interface SystemMessage {
189
+ role: "system";
190
+ content: string;
191
+ }
192
+ type ChatMessage = UserMessage | AssistantMessage | ToolResultMessage | SystemMessage;
193
+ interface SerializedMessage {
194
+ uuid: UUID;
195
+ parentUuid: UUID | null;
196
+ sessionId: string;
197
+ timestamp: string;
198
+ message: ChatMessage;
199
+ }
200
+ interface MessageEntry {
201
+ type: "message";
202
+ uuid: UUID;
203
+ parentUuid: UUID | null;
204
+ sessionId: string;
205
+ timestamp: string;
206
+ message: ChatMessage;
207
+ }
208
+ interface CompactBoundaryEntry {
209
+ type: "compact-boundary";
210
+ uuid: UUID;
211
+ sessionId: string;
212
+ timestamp: string;
213
+ }
214
+ interface SummaryEntry {
215
+ type: "summary";
216
+ uuid: UUID;
217
+ parentUuid: UUID | null;
218
+ sessionId: string;
219
+ timestamp: string;
220
+ message: ChatMessage;
221
+ }
222
+ interface CustomTitleEntry {
223
+ type: "custom-title";
224
+ sessionId: string;
225
+ title: string;
226
+ timestamp: string;
227
+ }
228
+ interface MetadataEntry {
229
+ type: "metadata";
230
+ sessionId: string;
231
+ timestamp: string;
232
+ key: string;
233
+ value: unknown;
234
+ }
235
+ interface ToolResultOverflowEntry {
236
+ type: "tool-result-overflow";
237
+ sessionId: string;
238
+ timestamp: string;
239
+ toolCallId: string;
240
+ originalContent: string;
241
+ }
242
+ interface FileCheckpointEntry {
243
+ type: "file-checkpoint";
244
+ sessionId: string;
245
+ timestamp: string;
246
+ messageId: string;
247
+ snapshot: FileCheckpointSnapshot;
248
+ isSnapshotUpdate: boolean;
249
+ }
250
+ interface SnipBoundaryEntry {
251
+ type: "snip-boundary";
252
+ sessionId: string;
253
+ timestamp: string;
254
+ snipMetadata: {
255
+ removedUuids: string[];
256
+ };
257
+ }
258
+ interface ContentReplacementRecord {
259
+ toolUseId: string;
260
+ replacement: string;
261
+ }
262
+ interface ContentReplacementEntry {
263
+ type: "content-replacement";
264
+ sessionId: string;
265
+ timestamp: string;
266
+ replacements: ContentReplacementRecord[];
267
+ }
268
+ type Entry = MessageEntry | CompactBoundaryEntry | SummaryEntry | CustomTitleEntry | MetadataEntry | ToolResultOverflowEntry | FileCheckpointEntry | ContentReplacementEntry | SnipBoundaryEntry;
269
+ interface SessionInfo {
270
+ sessionId: string;
271
+ createdAt: string;
272
+ lastMessageAt: string;
273
+ title?: string;
274
+ messageCount: number;
275
+ }
276
+ interface ToolResult {
277
+ content: string | ContentPart[];
278
+ isError?: boolean;
279
+ }
280
+ type StreamEvent = {
281
+ type: "text_delta";
282
+ text: string;
283
+ } | {
284
+ type: "tool_use_start";
285
+ toolName: string;
286
+ toolUseId: string;
287
+ } | {
288
+ type: "tool_use_delta";
289
+ input: string;
290
+ } | {
291
+ type: "tool_result";
292
+ toolUseId: string;
293
+ toolName: string;
294
+ result: ToolResult;
295
+ } | {
296
+ type: "message_complete";
297
+ message: AssistantMessage;
298
+ } | {
299
+ type: "usage";
300
+ usage: ChatCompletionUsage;
301
+ model: string;
302
+ } | {
303
+ type: "turn_complete";
304
+ usage: ChatCompletionUsage;
305
+ model: string;
306
+ callCount: number;
307
+ } | {
308
+ type: "compact_start";
309
+ } | {
310
+ type: "compact_complete";
311
+ } | {
312
+ type: "microcompact_complete";
313
+ tokensFreed: number;
314
+ } | {
315
+ type: "tool_result_truncated";
316
+ toolCallId: string;
317
+ originalChars: number;
318
+ truncatedChars: number;
319
+ } | {
320
+ type: "error";
321
+ error: Error;
322
+ } | {
323
+ type: "permission_request";
324
+ toolName: string;
325
+ input: Record<string, unknown>;
326
+ message: string;
327
+ } | {
328
+ type: "permission_granted";
329
+ toolName: string;
330
+ input: Record<string, unknown>;
331
+ } | {
332
+ type: "permission_denied";
333
+ toolName: string;
334
+ input: Record<string, unknown>;
335
+ message: string;
336
+ } | {
337
+ type: "thinking_delta";
338
+ text: string;
339
+ } | {
340
+ type: "cost_update";
341
+ summary: CostSummary;
342
+ } | {
343
+ type: "retry_attempt";
344
+ attempt: number;
345
+ maxRetries: number;
346
+ delayMs: number;
347
+ error: Error;
348
+ } | {
349
+ type: "retry_exhausted";
350
+ attempts: number;
351
+ error: Error;
352
+ } | {
353
+ type: "model_switch";
354
+ from: string;
355
+ to: string;
356
+ } | {
357
+ type: "subagent_start";
358
+ toolUseId: string;
359
+ prompt: string;
360
+ } | {
361
+ type: "subagent_end";
362
+ toolUseId: string;
363
+ result: string;
364
+ } | {
365
+ type: "user_input_request";
366
+ toolUseId: string;
367
+ question: string;
368
+ } | {
369
+ type: "denial_limit_exceeded";
370
+ consecutiveDenials: number;
371
+ totalDenials: number;
372
+ } | {
373
+ type: "span_start";
374
+ name: string;
375
+ spanId: string;
376
+ } | {
377
+ type: "span_end";
378
+ name: string;
379
+ spanId: string;
380
+ durationMs: number;
381
+ error?: string;
382
+ } | {
383
+ type: "memory_update";
384
+ created: MemoryEntry[];
385
+ updated: MemoryEntry[];
386
+ deleted: string[];
387
+ } | {
388
+ type: "session_resumed";
389
+ sessionId: string;
390
+ messageCount: number;
391
+ } | {
392
+ type: "checkpoint_snapshot";
393
+ messageId: string;
394
+ } | {
395
+ type: "recovery_filtered";
396
+ filterName: string;
397
+ removedCount: number;
398
+ } | {
399
+ type: "interrupted_turn_detected";
400
+ kind: "interrupted_tool" | "interrupted_prompt";
401
+ } | {
402
+ type: "git_operation";
403
+ operation: "commit" | "push" | "pr_create" | "merge" | "rebase";
404
+ details: string;
405
+ } | {
406
+ type: "structured_output";
407
+ data: unknown;
408
+ schema: OutputFormat;
409
+ } | {
410
+ type: "max_turns_reached";
411
+ maxTurns: number;
412
+ turnCount: number;
413
+ } | {
414
+ type: "auto_compact_failed";
415
+ error: Error;
416
+ };
417
+ interface RunOptions {
418
+ signal?: AbortSignal;
419
+ /**
420
+ * Maximum number of model-to-tool turns before the loop terminates.
421
+ * When exceeded, the thread yields a `max_turns_reached` event and stops.
422
+ */
423
+ maxTurns?: number;
424
+ /**
425
+ * Constrain the model to produce structured output.
426
+ *
427
+ * In `"alongside_tools"` mode (default), the outputFormat is passed
428
+ * directly to the provider on every model call — the model may still
429
+ * use tools alongside its structured response.
430
+ *
431
+ * In `"final_response"` mode, a synthetic `StructuredOutput` tool is
432
+ * injected. The agent loop continues using tools normally until the
433
+ * model calls StructuredOutput with the schema-conforming data. This
434
+ * is the recommended mode when the agent needs to reason and use
435
+ * tools before producing the final structured answer.
436
+ */
437
+ outputFormat?: OutputFormat;
438
+ /**
439
+ * Controls how structured output interacts with the tool loop.
440
+ * - `"alongside_tools"` (default): pass outputFormat to the provider;
441
+ * the model response itself is structured JSON.
442
+ * - `"final_response"`: inject a synthetic StructuredOutput tool; the
443
+ * model calls it to signal completion with structured data.
444
+ */
445
+ structuredOutputMode?: "alongside_tools" | "final_response";
446
+ }
447
+
448
+ type ThinkingConfig = {
449
+ type: "enabled";
450
+ budgetTokens: number;
451
+ } | {
452
+ type: "disabled";
453
+ };
454
+
455
+ interface ToolParameterProperty {
456
+ type: string;
457
+ description?: string;
458
+ enum?: string[];
459
+ default?: unknown;
460
+ minimum?: number;
461
+ maximum?: number;
462
+ }
463
+ interface ToolDefinition {
464
+ type: "function";
465
+ function: {
466
+ name: string;
467
+ description: string;
468
+ parameters: {
469
+ type: "object";
470
+ properties: Record<string, ToolParameterProperty>;
471
+ required?: string[];
472
+ };
473
+ };
474
+ }
475
+ interface ChatStreamDelta {
476
+ role?: "assistant";
477
+ content?: string | null;
478
+ thinking_content?: string | null;
479
+ thinking_signature?: string | null;
480
+ /** Opaque data payload for Anthropic redacted_thinking blocks. */
481
+ redacted_thinking_data?: string | null;
482
+ tool_calls?: Array<{
483
+ index: number;
484
+ id?: string;
485
+ type?: "function";
486
+ function?: {
487
+ name?: string;
488
+ arguments?: string;
489
+ };
490
+ }>;
491
+ }
492
+ interface ChatStreamChoice {
493
+ index: number;
494
+ delta: ChatStreamDelta;
495
+ finish_reason: string | null;
496
+ }
497
+ interface ChatStreamChunk {
498
+ id: string;
499
+ choices: ChatStreamChoice[];
500
+ model: string;
501
+ usage?: {
502
+ prompt_tokens: number;
503
+ completion_tokens: number;
504
+ total_tokens: number;
505
+ cache_read_tokens?: number;
506
+ cache_creation_tokens?: number;
507
+ thinking_tokens?: number;
508
+ };
509
+ }
510
+ interface ChatCompletionUsage {
511
+ prompt_tokens: number;
512
+ completion_tokens: number;
513
+ total_tokens: number;
514
+ cache_read_tokens?: number;
515
+ cache_creation_tokens?: number;
516
+ thinking_tokens?: number;
517
+ }
518
+ /**
519
+ * Structured output format. When provided, the model is constrained to
520
+ * produce a response matching the given JSON schema.
521
+ *
522
+ * - `json_schema`: the model must produce JSON conforming to the given schema.
523
+ * - `json_object`: the model must produce valid JSON (no specific schema).
524
+ */
525
+ type OutputFormat = JsonSchemaOutputFormat | JsonObjectOutputFormat;
526
+ interface JsonSchemaOutputFormat {
527
+ type: "json_schema";
528
+ /** JSON Schema object describing the expected output shape. */
529
+ schema: Record<string, unknown>;
530
+ /** Optional name for the schema (required by some providers). */
531
+ name?: string;
532
+ /** When true, the provider enforces strict schema adherence. */
533
+ strict?: boolean;
534
+ }
535
+ interface JsonObjectOutputFormat {
536
+ type: "json_object";
537
+ }
538
+ interface ChatParams {
539
+ model: string;
540
+ messages: ChatMessage[];
541
+ tools?: ToolDefinition[];
542
+ max_tokens?: number;
543
+ system?: string;
544
+ temperature?: number;
545
+ thinking?: ThinkingConfig;
546
+ /** Constrain the model to produce structured output matching this schema. */
547
+ outputFormat?: OutputFormat;
548
+ /**
549
+ * When true, the provider should place the cache breakpoint on the
550
+ * second-to-last message instead of the last. Used by subagent forks
551
+ * to avoid writing fork-only tails into the shared prompt cache.
552
+ */
553
+ skipCacheWrite?: boolean;
554
+ /** Abort signal — providers should forward this to cancel in-flight HTTP requests. */
555
+ signal?: AbortSignal;
556
+ }
557
+ interface AIProvider {
558
+ chat(params: ChatParams): AsyncIterable<ChatStreamChunk>;
559
+ }
560
+ /**
561
+ * Extended error type that providers can throw to convey retry-relevant metadata.
562
+ * Consumers (like the retry engine) can inspect these fields without knowing
563
+ * provider-specific SDK error types.
564
+ */
565
+ declare class ChatStreamError extends Error {
566
+ status?: number;
567
+ retryAfter?: string;
568
+ constructor(message: string, opts?: {
569
+ status?: number;
570
+ retryAfter?: string;
571
+ cause?: unknown;
572
+ });
573
+ }
574
+
575
+ export { createCheckpointState as $, type AIProvider as A, type FileCheckpointBackup as B, type ChatParams as C, type DiffStats as D, type Entry as E, type FileCheckpointState as F, type FileCheckpointEntry as G, type ImageUrlContent as H, type ImageContent as I, type JsonSchemaOutputFormat as J, type JsonObjectOutputFormat as K, type MemoryType as L, type ModelPricing as M, type MessageEntry as N, type OutputFormat as O, type MetadataEntry as P, type SerializedMessage as Q, type RunOptions as R, type StreamEvent as S, type ToolDefinition as T, type UUID as U, type SnipBoundaryEntry as V, type SummaryEntry as W, type SystemMessage as X, type TextContent as Y, type ToolParameterProperty as Z, type UserMessage as _, type ChatStreamChunk as a, type ChatMessage as b, type CheckpointConfig as c, type FileCheckpointSnapshot as d, type ContentPart as e, type ContentReplacementRecord as f, type SessionInfo as g, type UsageRecord as h, type CostSummary as i, type ModelUsageSummary as j, type ChatCompletionUsage as k, type ThinkingConfig as l, type MemoryConfig as m, type ToolResult as n, type ToolCallContent as o, type MemoryProvider as p, type MemoryEntry as q, type AssistantMessage as r, type ToolResultMessage as s, type ToolResultOverflowEntry as t, type ChatStreamChoice as u, type ChatStreamDelta as v, ChatStreamError as w, type CompactBoundaryEntry as x, type ContentReplacementEntry as y, type CustomTitleEntry as z };
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Agent2Agent (A2A) protocol types per the Google A2A specification.
3
+ * https://google.github.io/A2A/specification/
4
+ */
5
+ interface AgentCard {
6
+ name: string;
7
+ description?: string;
8
+ url: string;
9
+ provider?: {
10
+ organization: string;
11
+ url?: string;
12
+ };
13
+ version: string;
14
+ capabilities?: {
15
+ streaming?: boolean;
16
+ pushNotifications?: boolean;
17
+ stateTransitionHistory?: boolean;
18
+ };
19
+ authentication?: {
20
+ schemes: string[];
21
+ credentials?: string;
22
+ };
23
+ defaultInputModes?: string[];
24
+ defaultOutputModes?: string[];
25
+ skills?: AgentSkill[];
26
+ }
27
+ interface AgentSkill {
28
+ id: string;
29
+ name: string;
30
+ description?: string;
31
+ tags?: string[];
32
+ examples?: string[];
33
+ inputModes?: string[];
34
+ outputModes?: string[];
35
+ }
36
+ type TaskStatus = "submitted" | "working" | "input-required" | "completed" | "failed" | "canceled";
37
+ interface Task {
38
+ id: string;
39
+ sessionId?: string;
40
+ status: TaskState;
41
+ history?: Message[];
42
+ artifacts?: Artifact[];
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ interface TaskState {
46
+ state: TaskStatus;
47
+ message?: Message;
48
+ timestamp?: string;
49
+ }
50
+ interface Message {
51
+ role: "user" | "agent";
52
+ parts: Part[];
53
+ metadata?: Record<string, unknown>;
54
+ }
55
+ type Part = TextPart | FilePart | DataPart;
56
+ interface TextPart {
57
+ type: "text";
58
+ text: string;
59
+ }
60
+ interface FilePart {
61
+ type: "file";
62
+ file: {
63
+ name?: string;
64
+ mimeType?: string;
65
+ bytes?: string;
66
+ uri?: string;
67
+ };
68
+ }
69
+ interface DataPart {
70
+ type: "data";
71
+ data: Record<string, unknown>;
72
+ }
73
+ interface Artifact {
74
+ name?: string;
75
+ description?: string;
76
+ parts: Part[];
77
+ index?: number;
78
+ append?: boolean;
79
+ lastChunk?: boolean;
80
+ metadata?: Record<string, unknown>;
81
+ }
82
+ interface TaskSendParams {
83
+ id?: string;
84
+ sessionId?: string;
85
+ message: Message;
86
+ metadata?: Record<string, unknown>;
87
+ }
88
+ interface TaskStatusUpdateEvent {
89
+ type: "status";
90
+ taskId: string;
91
+ status: TaskState;
92
+ final: boolean;
93
+ }
94
+ interface TaskArtifactUpdateEvent {
95
+ type: "artifact";
96
+ taskId: string;
97
+ artifact: Artifact;
98
+ }
99
+ type TaskStreamEvent = TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
100
+ declare const A2A_METHODS: {
101
+ readonly TASKS_SEND: "tasks/send";
102
+ readonly TASKS_SEND_SUBSCRIBE: "tasks/sendSubscribe";
103
+ readonly TASKS_GET: "tasks/get";
104
+ readonly TASKS_CANCEL: "tasks/cancel";
105
+ readonly TASKS_PUSH_NOTIFICATION: "tasks/pushNotification";
106
+ readonly TASKS_RESUBSCRIBE: "tasks/resubscribe";
107
+ };
108
+
109
+ export { type AgentSkill as A, type DataPart as D, type FilePart as F, type Message as M, type Part as P, type TaskSendParams as T, type AgentCard as a, type Task as b, type TaskStreamEvent as c, A2A_METHODS as d, type Artifact as e, type TaskState as f, type TaskStatus as g, type TextPart as h };