@nuvin/nuvin-core 1.5.1 → 1.6.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/dist/index.d.ts CHANGED
@@ -54,12 +54,14 @@ type SpecialistAgentResult = {
54
54
  result: string;
55
55
  metadata: {
56
56
  agentId: string;
57
+ agentName: string;
57
58
  tokensUsed?: number;
58
59
  toolCallsExecuted: number;
59
60
  executionTimeMs: number;
60
61
  conversationHistory?: Message[];
61
62
  events?: AgentEvent[];
62
63
  errorMessage?: string;
64
+ metrics?: MetricsSnapshot;
63
65
  };
64
66
  };
65
67
  /**
@@ -193,6 +195,220 @@ declare class AgentRegistry {
193
195
  exists(agentId: string): boolean;
194
196
  }
195
197
 
198
+ /**
199
+ * Type definitions for tool call arguments/parameters
200
+ * These types represent the parameters passed to each tool
201
+ *
202
+ * These are useful for:
203
+ * - Type-safe tool call argument parsing
204
+ * - UI rendering of tool calls with proper parameter display
205
+ * - Validation of tool inputs
206
+ */
207
+ type BashToolArgs = {
208
+ cmd: string;
209
+ cwd?: string;
210
+ timeoutMs?: number;
211
+ description?: string;
212
+ };
213
+ type FileReadArgs = {
214
+ path: string;
215
+ lineStart?: number;
216
+ lineEnd?: number;
217
+ description?: string;
218
+ };
219
+ type FileEditArgs = {
220
+ file_path: string;
221
+ old_text: string;
222
+ new_text: string;
223
+ dry_run?: boolean;
224
+ description?: string;
225
+ };
226
+ type FileNewArgs = {
227
+ file_path: string;
228
+ content: string;
229
+ description?: string;
230
+ };
231
+ type DirLsArgs = {
232
+ path?: string;
233
+ limit?: number;
234
+ description?: string;
235
+ };
236
+ type WebSearchArgs = {
237
+ query: string;
238
+ count?: number;
239
+ offset?: number;
240
+ domains?: string[];
241
+ recencyDays?: number;
242
+ lang?: string;
243
+ region?: string;
244
+ safe?: boolean;
245
+ type?: 'web' | 'images';
246
+ hydrateMeta?: boolean;
247
+ description?: string;
248
+ };
249
+ type WebFetchArgs = {
250
+ url: string;
251
+ description?: string;
252
+ };
253
+ type TodoWriteArgs = {
254
+ todos: Array<{
255
+ id: string;
256
+ content: string;
257
+ status: 'pending' | 'in_progress' | 'completed';
258
+ priority: 'high' | 'medium' | 'low';
259
+ createdAt?: string;
260
+ }>;
261
+ description?: string;
262
+ };
263
+ type AssignTaskArgs = {
264
+ agent: string;
265
+ task: string;
266
+ description: string;
267
+ };
268
+ type ToolArguments = BashToolArgs | FileReadArgs | FileEditArgs | FileNewArgs | DirLsArgs | WebSearchArgs | WebFetchArgs | TodoWriteArgs | AssignTaskArgs;
269
+ /**
270
+ * Type guard to safely parse tool arguments
271
+ */
272
+ declare function parseToolArguments(args: string | unknown): ToolArguments;
273
+ /**
274
+ * Type guards for specific tool arguments
275
+ */
276
+ declare function isBashToolArgs(args: ToolArguments): args is BashToolArgs;
277
+ declare function isFileReadArgs(args: ToolArguments): args is FileReadArgs;
278
+ declare function isFileEditArgs(args: ToolArguments): args is FileEditArgs;
279
+ declare function isFileNewArgs(args: ToolArguments): args is FileNewArgs;
280
+ declare function isTodoWriteArgs(args: ToolArguments): args is TodoWriteArgs;
281
+ declare function isAssignTaskArgs(args: ToolArguments): args is AssignTaskArgs;
282
+ declare function isWebSearchArgs(args: ToolArguments): args is WebSearchArgs;
283
+ declare function isWebFetchArgs(args: ToolArguments): args is WebFetchArgs;
284
+ declare function isDirLsArgs(args: ToolArguments): args is DirLsArgs;
285
+ type ToolParameterMap = {
286
+ bash_tool: BashToolArgs;
287
+ file_read: FileReadArgs;
288
+ file_edit: FileEditArgs;
289
+ file_new: FileNewArgs;
290
+ dir_ls: DirLsArgs;
291
+ web_search: WebSearchArgs;
292
+ web_fetch: WebFetchArgs;
293
+ todo_write: TodoWriteArgs;
294
+ assign_task: AssignTaskArgs;
295
+ };
296
+ type ToolName = keyof ToolParameterMap;
297
+ type TypedToolInvocation<T extends ToolName = ToolName> = {
298
+ id: string;
299
+ name: T;
300
+ parameters: ToolParameterMap[T];
301
+ };
302
+
303
+ type FileMetadata = {
304
+ path: string;
305
+ created?: string;
306
+ modified?: string;
307
+ size?: number;
308
+ };
309
+ type LineRangeMetadata = {
310
+ lineStart: number;
311
+ lineEnd: number;
312
+ linesTotal?: number;
313
+ };
314
+ type CommandMetadata = {
315
+ cwd?: string;
316
+ code?: number | null;
317
+ signal?: string | null;
318
+ timedOut?: boolean;
319
+ };
320
+ type ErrorMetadata = {
321
+ errorReason?: ErrorReason;
322
+ code?: string | number;
323
+ stackTrace?: string;
324
+ retryable?: boolean;
325
+ };
326
+ type DelegationMetadata = {
327
+ agentId: string;
328
+ agentName: string;
329
+ delegationDepth: number;
330
+ status: 'success' | 'error' | 'timeout';
331
+ executionTimeMs: number;
332
+ toolCallsExecuted: number;
333
+ tokensUsed?: number;
334
+ metrics?: MetricsSnapshot;
335
+ taskDescription: string;
336
+ provider?: string;
337
+ model?: string;
338
+ conversationHistoryLength?: number;
339
+ eventsEmitted?: number;
340
+ };
341
+
342
+ type BashToolMetadata = CommandMetadata & {
343
+ stdout?: string;
344
+ stderr?: string;
345
+ stripped?: boolean;
346
+ };
347
+ type FileReadMetadata = FileMetadata & {
348
+ lineRange?: LineRangeMetadata;
349
+ encoding?: string;
350
+ bomStripped?: boolean;
351
+ };
352
+ type FileEditMetadata = FileMetadata & {
353
+ changesMade?: {
354
+ linesAdded: number;
355
+ linesRemoved: number;
356
+ bytesChanged: number;
357
+ };
358
+ backup?: {
359
+ path: string;
360
+ created: string;
361
+ };
362
+ };
363
+ type FileNewMetadata = FileMetadata & {
364
+ overwritten?: boolean;
365
+ };
366
+ type DirLsMetadata = {
367
+ path: string;
368
+ totalEntries?: number;
369
+ entriesReturned?: number;
370
+ truncated?: boolean;
371
+ };
372
+ type WebSearchMetadata = {
373
+ query: string;
374
+ totalResults?: number;
375
+ resultsReturned: number;
376
+ searchTime?: number;
377
+ provider?: string;
378
+ };
379
+ type WebFetchMetadata = {
380
+ url: string;
381
+ statusCode?: number;
382
+ contentType?: string;
383
+ contentLength?: number;
384
+ fetchTime?: number;
385
+ markdown?: boolean;
386
+ };
387
+ type TodoWriteMetadata = {
388
+ todosWritten: number;
389
+ conversationId?: string;
390
+ };
391
+ type AssignTaskMetadata = DelegationMetadata;
392
+ type ToolErrorMetadata = {
393
+ errorReason?: ErrorReason;
394
+ path?: string;
395
+ agentId?: string;
396
+ code?: string | number;
397
+ stackTrace?: string;
398
+ retryable?: boolean;
399
+ };
400
+ type ToolMetadataMap = {
401
+ bash_tool: BashToolMetadata;
402
+ file_read: FileReadMetadata;
403
+ file_edit: FileEditMetadata;
404
+ file_new: FileNewMetadata;
405
+ dir_ls: DirLsMetadata;
406
+ web_search: WebSearchMetadata;
407
+ web_fetch: WebFetchMetadata;
408
+ todo_write: TodoWriteMetadata;
409
+ assign_task: AssignTaskMetadata;
410
+ };
411
+
196
412
  type ToolCall = {
197
413
  id: string;
198
414
  type: 'function';
@@ -366,6 +582,42 @@ type ToolDefinition = {
366
582
  };
367
583
  };
368
584
  type ToolInvocation = {
585
+ id: string;
586
+ name: 'bash_tool';
587
+ parameters: BashToolArgs;
588
+ } | {
589
+ id: string;
590
+ name: 'file_read';
591
+ parameters: FileReadArgs;
592
+ } | {
593
+ id: string;
594
+ name: 'file_edit';
595
+ parameters: FileEditArgs;
596
+ } | {
597
+ id: string;
598
+ name: 'file_new';
599
+ parameters: FileNewArgs;
600
+ } | {
601
+ id: string;
602
+ name: 'dir_ls';
603
+ parameters: DirLsArgs;
604
+ } | {
605
+ id: string;
606
+ name: 'web_search';
607
+ parameters: WebSearchArgs;
608
+ } | {
609
+ id: string;
610
+ name: 'web_fetch';
611
+ parameters: WebFetchArgs;
612
+ } | {
613
+ id: string;
614
+ name: 'todo_write';
615
+ parameters: TodoWriteArgs;
616
+ } | {
617
+ id: string;
618
+ name: 'assign_task';
619
+ parameters: AssignTaskArgs;
620
+ } | {
369
621
  id: string;
370
622
  name: string;
371
623
  parameters: Record<string, unknown>;
@@ -383,14 +635,92 @@ declare enum ErrorReason {
383
635
  Unknown = "unknown"
384
636
  }
385
637
  type ToolExecutionResult = {
638
+ id: string;
639
+ name: 'bash_tool';
640
+ status: 'success';
641
+ type: 'text';
642
+ result: string;
643
+ metadata?: BashToolMetadata;
644
+ durationMs?: number;
645
+ } | {
646
+ id: string;
647
+ name: 'file_read';
648
+ status: 'success';
649
+ type: 'text';
650
+ result: string;
651
+ metadata?: FileReadMetadata;
652
+ durationMs?: number;
653
+ } | {
654
+ id: string;
655
+ name: 'file_edit';
656
+ status: 'success';
657
+ type: 'text';
658
+ result: string;
659
+ metadata?: FileEditMetadata;
660
+ durationMs?: number;
661
+ } | {
662
+ id: string;
663
+ name: 'file_new';
664
+ status: 'success';
665
+ type: 'text';
666
+ result: string;
667
+ metadata?: FileNewMetadata;
668
+ durationMs?: number;
669
+ } | {
670
+ id: string;
671
+ name: 'dir_ls';
672
+ status: 'success';
673
+ type: 'text';
674
+ result: string;
675
+ metadata?: DirLsMetadata;
676
+ durationMs?: number;
677
+ } | {
678
+ id: string;
679
+ name: 'web_search';
680
+ status: 'success';
681
+ type: 'json';
682
+ result: Record<string, unknown> | unknown[];
683
+ metadata?: WebSearchMetadata;
684
+ durationMs?: number;
685
+ } | {
686
+ id: string;
687
+ name: 'web_fetch';
688
+ status: 'success';
689
+ type: 'text';
690
+ result: string;
691
+ metadata?: WebFetchMetadata;
692
+ durationMs?: number;
693
+ } | {
694
+ id: string;
695
+ name: 'todo_write';
696
+ status: 'success';
697
+ type: 'text';
698
+ result: string;
699
+ metadata?: TodoWriteMetadata;
700
+ durationMs?: number;
701
+ } | {
702
+ id: string;
703
+ name: 'assign_task';
704
+ status: 'success';
705
+ type: 'text';
706
+ result: string;
707
+ metadata: AssignTaskMetadata;
708
+ durationMs?: number;
709
+ } | {
386
710
  id: string;
387
711
  name: string;
388
- status: 'success' | 'error';
712
+ status: 'success';
389
713
  type: 'text' | 'json';
390
- result: string | object;
391
- metadata?: Record<string, unknown> & {
392
- errorReason?: ErrorReason;
393
- };
714
+ result: string | Record<string, unknown> | unknown[];
715
+ metadata?: Record<string, unknown>;
716
+ durationMs?: number;
717
+ } | {
718
+ id: string;
719
+ name: string;
720
+ status: 'error';
721
+ type: 'text';
722
+ result: string;
723
+ metadata?: ToolErrorMetadata;
394
724
  durationMs?: number;
395
725
  };
396
726
  interface ToolPort {
@@ -484,6 +814,7 @@ type AgentConfig = {
484
814
  maxToolConcurrency?: number;
485
815
  requireToolApproval?: boolean;
486
816
  reasoningEffort?: string;
817
+ strictToolValidation?: boolean;
487
818
  };
488
819
  declare const MessageRoles: {
489
820
  readonly System: "system";
@@ -507,6 +838,7 @@ declare const AgentEventTypes: {
507
838
  readonly SubAgentToolCall: "sub_agent_tool_call";
508
839
  readonly SubAgentToolResult: "sub_agent_tool_result";
509
840
  readonly SubAgentCompleted: "sub_agent_completed";
841
+ readonly SubAgentMetrics: "sub_agent_metrics";
510
842
  };
511
843
  type ToolApprovalDecision = 'approve' | 'deny' | 'approve_all';
512
844
  type AgentEvent = {
@@ -609,6 +941,13 @@ type AgentEvent = {
609
941
  status: 'success' | 'error' | 'timeout';
610
942
  resultMessage: string;
611
943
  totalDurationMs: number;
944
+ } | {
945
+ type: typeof AgentEventTypes.SubAgentMetrics;
946
+ conversationId: string;
947
+ messageId: string;
948
+ agentId: string;
949
+ toolCallId: string;
950
+ metrics: MetricsSnapshot;
612
951
  };
613
952
  interface EventPort {
614
953
  emit(event: AgentEvent): void | Promise<void>;
@@ -932,7 +1271,26 @@ type TodoItem = {
932
1271
  updatedAt?: string;
933
1272
  };
934
1273
 
935
- type ExecResult = Omit<ToolExecutionResult, 'id' | 'name'>;
1274
+ type ExecResultSuccess = {
1275
+ status: 'success';
1276
+ type: 'text';
1277
+ result: string;
1278
+ metadata?: Record<string, unknown>;
1279
+ } | {
1280
+ status: 'success';
1281
+ type: 'json';
1282
+ result: Record<string, unknown> | unknown[];
1283
+ metadata?: Record<string, unknown>;
1284
+ };
1285
+ type ExecResultError = {
1286
+ status: 'error';
1287
+ type: 'text';
1288
+ result: string;
1289
+ metadata?: Record<string, unknown> & {
1290
+ errorReason?: ErrorReason;
1291
+ };
1292
+ };
1293
+ type ExecResult = ExecResultSuccess | ExecResultError;
936
1294
  type ToolExecutionContext = {
937
1295
  conversationId?: string;
938
1296
  agentId?: string;
@@ -943,11 +1301,11 @@ type ToolExecutionContext = {
943
1301
  eventPort?: EventPort;
944
1302
  signal?: AbortSignal;
945
1303
  } & Record<string, unknown>;
946
- interface FunctionTool<P = Record<string, unknown>, C = ToolExecutionContext> {
1304
+ interface FunctionTool<P = Record<string, unknown>, C = ToolExecutionContext, R extends ExecResult = ExecResult> {
947
1305
  name: string;
948
1306
  parameters: object;
949
1307
  definition(): ToolDefinition['function'];
950
- execute(params: P, context?: C): Promise<ExecResult> | ExecResult;
1308
+ execute(params: P, context?: C): Promise<R> | R;
951
1309
  }
952
1310
 
953
1311
  interface AgentCatalog {
@@ -1093,10 +1451,12 @@ declare class DefaultDelegationResultFormatter implements DelegationResultFormat
1093
1451
  summary: string;
1094
1452
  metadata: {
1095
1453
  agentId: string;
1454
+ agentName: string;
1096
1455
  status: "success" | "error" | "timeout";
1097
1456
  executionTimeMs: number;
1098
1457
  toolCallsExecuted: number;
1099
1458
  tokensUsed: number | undefined;
1459
+ metrics: MetricsSnapshot | undefined;
1100
1460
  };
1101
1461
  };
1102
1462
  formatError(error: unknown): string;
@@ -1167,7 +1527,23 @@ type BashParams = {
1167
1527
  cwd?: string;
1168
1528
  timeoutMs?: number;
1169
1529
  };
1170
- declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext> {
1530
+ type BashSuccessResult$1 = {
1531
+ status: 'success';
1532
+ type: 'text';
1533
+ result: string;
1534
+ metadata?: CommandMetadata & {
1535
+ stdout?: string;
1536
+ stderr?: string;
1537
+ stripped?: boolean;
1538
+ };
1539
+ };
1540
+ type BashErrorResult = ExecResultError & {
1541
+ metadata?: CommandMetadata & {
1542
+ errorReason?: ErrorReason;
1543
+ };
1544
+ };
1545
+ type BashResult = BashSuccessResult$1 | BashErrorResult;
1546
+ declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext, BashResult> {
1171
1547
  name: "bash_tool";
1172
1548
  parameters: {
1173
1549
  readonly type: "object";
@@ -1193,13 +1569,378 @@ declare class BashTool implements FunctionTool<BashParams, ToolExecutionContext>
1193
1569
  readonly required: readonly ["cmd"];
1194
1570
  };
1195
1571
  definition(): ToolDefinition['function'];
1196
- execute(p: BashParams, ctx?: ToolExecutionContext): Promise<ExecResult>;
1572
+ /**
1573
+ * Execute bash command with timeout protection
1574
+ *
1575
+ * @param p - Command parameters including cmd, cwd, and optional timeout
1576
+ * @param ctx - Execution context with optional abort signal
1577
+ * @returns Structured result with command output and execution metadata
1578
+ *
1579
+ * @example
1580
+ * ```typescript
1581
+ * const result = await bashTool.execute({ cmd: 'ls -la' });
1582
+ * if (result.status === 'success' && result.type === 'text') {
1583
+ * console.log(result.result); // command output
1584
+ * console.log(result.metadata?.code); // exit code
1585
+ * console.log(result.metadata?.cwd); // working directory
1586
+ * }
1587
+ * ```
1588
+ */
1589
+ execute(p: BashParams, ctx?: ToolExecutionContext): Promise<BashResult>;
1197
1590
  private execOnce;
1198
1591
  private defaultShell;
1199
1592
  private shellExists;
1200
1593
  private shellArgs;
1201
1594
  }
1202
1595
 
1596
+ type ParseResult<T = unknown> = {
1597
+ success: true;
1598
+ data: T;
1599
+ } | {
1600
+ success: false;
1601
+ error: string;
1602
+ };
1603
+ declare function parseJSON(jsonString: string): ParseResult<Record<string, unknown>>;
1604
+
1605
+ type ValidationResult<T = unknown> = {
1606
+ valid: true;
1607
+ data: T;
1608
+ } | {
1609
+ valid: false;
1610
+ errors: string[];
1611
+ };
1612
+ type ToolValidator<T extends ToolName> = (params: Record<string, unknown>) => ValidationResult<ToolParameterMap[T]>;
1613
+ declare const toolValidators: Partial<{
1614
+ [K in ToolName]: ToolValidator<K>;
1615
+ }>;
1616
+
1617
+ type ToolCallValidation = {
1618
+ valid: true;
1619
+ invocation: ToolInvocation;
1620
+ } | {
1621
+ valid: false;
1622
+ error: string;
1623
+ errorType: 'parse' | 'validation' | 'unknown';
1624
+ callId: string;
1625
+ toolName: string;
1626
+ rawArguments?: string;
1627
+ };
1628
+ declare function convertToolCall(toolCall: ToolCall, options?: {
1629
+ strict?: boolean;
1630
+ }): ToolCallValidation;
1631
+ declare function convertToolCalls(toolCalls: ToolCall[], options?: {
1632
+ strict?: boolean;
1633
+ throwOnError?: boolean;
1634
+ }): ToolInvocation[];
1635
+
1636
+ type FileReadParams = {
1637
+ path: string;
1638
+ lineStart?: number;
1639
+ lineEnd?: number;
1640
+ };
1641
+ type FileReadSuccessResult$1 = {
1642
+ status: 'success';
1643
+ type: 'text';
1644
+ result: string;
1645
+ metadata?: FileMetadata & {
1646
+ lineRange?: LineRangeMetadata;
1647
+ encoding?: string;
1648
+ bomStripped?: boolean;
1649
+ };
1650
+ };
1651
+ type FileReadErrorResult = ExecResultError & {
1652
+ metadata?: {
1653
+ path?: string;
1654
+ errorReason?: ErrorReason;
1655
+ };
1656
+ };
1657
+ type FileReadResult = FileReadSuccessResult$1 | FileReadErrorResult;
1658
+
1659
+ type FileEditSuccessResult$1 = {
1660
+ status: 'success';
1661
+ type: 'text';
1662
+ result: string;
1663
+ metadata: FileMetadata & {
1664
+ eol: 'lf' | 'crlf';
1665
+ oldTextLength: number;
1666
+ newTextLength: number;
1667
+ bytesWritten: number;
1668
+ beforeSha: string;
1669
+ afterSha: string;
1670
+ dryRun: boolean;
1671
+ lineNumbers: {
1672
+ oldStartLine: number;
1673
+ oldEndLine: number;
1674
+ newStartLine: number;
1675
+ newEndLine: number;
1676
+ oldLineCount: number;
1677
+ newLineCount: number;
1678
+ };
1679
+ noChange?: boolean;
1680
+ };
1681
+ };
1682
+ type FileEditResult = FileEditSuccessResult$1 | ExecResultError;
1683
+
1684
+ type FileNewParams = {
1685
+ file_path: string;
1686
+ content: string;
1687
+ };
1688
+ type FileNewSuccessResult$1 = {
1689
+ status: 'success';
1690
+ type: 'text';
1691
+ result: string;
1692
+ metadata: {
1693
+ file_path: string;
1694
+ bytes: number;
1695
+ created: string;
1696
+ overwritten?: boolean;
1697
+ };
1698
+ };
1699
+ type FileNewResult = FileNewSuccessResult$1 | ExecResultError;
1700
+
1701
+ type DirLsParams = {
1702
+ path?: string;
1703
+ limit?: number;
1704
+ };
1705
+ type DirEntry = {
1706
+ name: string;
1707
+ type: 'file' | 'directory' | 'symlink' | 'other';
1708
+ size?: number;
1709
+ mtime?: number;
1710
+ mode?: number;
1711
+ lineCount?: number;
1712
+ };
1713
+ type DirLsSuccessResult$1 = {
1714
+ status: 'success';
1715
+ type: 'json';
1716
+ result: {
1717
+ path: string;
1718
+ entries: DirEntry[];
1719
+ truncated: boolean;
1720
+ total: number;
1721
+ };
1722
+ metadata?: {
1723
+ limit: number;
1724
+ includeHidden: boolean;
1725
+ };
1726
+ };
1727
+ type DirLsResult = DirLsSuccessResult$1 | ExecResultError;
1728
+
1729
+ /**
1730
+ * WebSearchTool — Google Programmable Search Engine (CSE) ONLY
1731
+ * -----------------------------------------------------------------
1732
+ * - Requires env: GOOGLE_CSE_KEY, GOOGLE_CSE_CX
1733
+ * - Supports: count (1..50, paginated 10/req), offset (0-based), domains[] -> site:
1734
+ * recencyDays -> dateRestrict, lang (hl/lr), region (gl), safe, type: web|images
1735
+ * - No HTML scraping fallback. If keys are missing, returns an error.
1736
+ */
1737
+ interface WebSearchParams {
1738
+ query: string;
1739
+ count?: number;
1740
+ offset?: number;
1741
+ domains?: string[];
1742
+ recencyDays?: number;
1743
+ lang?: string;
1744
+ region?: string;
1745
+ safe?: boolean;
1746
+ type?: 'web' | 'images';
1747
+ hydrateMeta?: boolean;
1748
+ }
1749
+ interface WebSearchResult {
1750
+ title: string;
1751
+ url: string;
1752
+ snippet?: string;
1753
+ displayUrl?: string;
1754
+ favicon?: string;
1755
+ publishedAt?: string;
1756
+ source: {
1757
+ engine: 'google-cse';
1758
+ rank: number;
1759
+ };
1760
+ }
1761
+ type WebSearchSuccessResult$1 = {
1762
+ status: 'success';
1763
+ type: 'json';
1764
+ result: {
1765
+ engine: 'google-cse';
1766
+ count: number;
1767
+ items: WebSearchResult[];
1768
+ query: string;
1769
+ appliedFilters?: {
1770
+ domains?: string[];
1771
+ recencyDays?: number;
1772
+ lang?: string;
1773
+ region?: string;
1774
+ };
1775
+ };
1776
+ metadata?: {
1777
+ offset: number;
1778
+ totalRequested: number;
1779
+ hydrated: boolean;
1780
+ };
1781
+ };
1782
+ type WebSearchToolResult = WebSearchSuccessResult$1 | ExecResultError;
1783
+
1784
+ type WebFetchParams = {
1785
+ url: string;
1786
+ };
1787
+ type WebFetchSuccessResult$1 = {
1788
+ status: 'success';
1789
+ type: 'text';
1790
+ result: string;
1791
+ metadata: {
1792
+ url: string;
1793
+ contentType: string;
1794
+ statusCode: number;
1795
+ format: 'markdown' | 'json' | 'text';
1796
+ size: number;
1797
+ fetchedAt: string;
1798
+ };
1799
+ };
1800
+ type WebFetchResult = WebFetchSuccessResult$1 | ExecResultError;
1801
+
1802
+ type TodoWriteSuccessResult$1 = {
1803
+ status: 'success';
1804
+ type: 'text';
1805
+ result: string;
1806
+ metadata: {
1807
+ recentChanges: boolean;
1808
+ stats: {
1809
+ total: number;
1810
+ pending: number;
1811
+ inProgress: number;
1812
+ completed: number;
1813
+ };
1814
+ progress: string;
1815
+ allCompleted: boolean;
1816
+ conversationId: string;
1817
+ };
1818
+ };
1819
+ type TodoWriteResult = TodoWriteSuccessResult$1 | ExecResultError;
1820
+
1821
+ type AssignSuccessResult$1 = {
1822
+ status: 'success';
1823
+ type: 'text';
1824
+ result: string;
1825
+ metadata: DelegationMetadata;
1826
+ };
1827
+ type AssignErrorResult = ExecResultError & {
1828
+ metadata?: {
1829
+ agentId?: string;
1830
+ errorReason?: ErrorReason;
1831
+ delegationDepth?: number;
1832
+ policyDenied?: boolean;
1833
+ agentNotFound?: boolean;
1834
+ };
1835
+ };
1836
+ type AssignResult = AssignSuccessResult$1 | AssignErrorResult;
1837
+
1838
+ declare function isSuccess(result: ExecResult): result is ExecResultSuccess;
1839
+ declare function isError(result: ExecResult): result is ExecResultError;
1840
+ declare function isTextResult(result: ExecResult): result is Extract<ExecResult, {
1841
+ type: 'text';
1842
+ }>;
1843
+ declare function isJsonResult(result: ExecResult): result is Extract<ExecResult, {
1844
+ type: 'json';
1845
+ }>;
1846
+ declare function isSuccessText(result: ExecResult): result is Extract<ExecResultSuccess, {
1847
+ type: 'text';
1848
+ }>;
1849
+ declare function isSuccessJson(result: ExecResult): result is Extract<ExecResultSuccess, {
1850
+ type: 'json';
1851
+ }>;
1852
+
1853
+ type WithToolExecutionFields<T extends {
1854
+ status: string;
1855
+ type: string;
1856
+ result: unknown;
1857
+ metadata?: unknown;
1858
+ }> = Omit<T, 'metadata'> & {
1859
+ id: string;
1860
+ name: string;
1861
+ durationMs?: number;
1862
+ metadata: T['metadata'];
1863
+ };
1864
+ type BashSuccessResult = WithToolExecutionFields<BashSuccessResult$1>;
1865
+ type FileReadSuccessResult = WithToolExecutionFields<FileReadSuccessResult$1>;
1866
+ type FileEditSuccessResult = WithToolExecutionFields<FileEditSuccessResult$1>;
1867
+ type FileNewSuccessResult = WithToolExecutionFields<FileNewSuccessResult$1>;
1868
+ type DirLsSuccessResult = WithToolExecutionFields<DirLsSuccessResult$1>;
1869
+ type WebSearchSuccessResult = WithToolExecutionFields<WebSearchSuccessResult$1>;
1870
+ type WebFetchSuccessResult = WithToolExecutionFields<WebFetchSuccessResult$1>;
1871
+ type TodoWriteSuccessResult = WithToolExecutionFields<TodoWriteSuccessResult$1>;
1872
+ type AssignSuccessResult = WithToolExecutionFields<AssignSuccessResult$1>;
1873
+ declare function isBashResult(result: ToolExecutionResult): result is ToolExecutionResult;
1874
+ declare function isBashSuccess(result: ToolExecutionResult): result is BashSuccessResult;
1875
+ declare function isFileReadResult(result: ToolExecutionResult): result is ToolExecutionResult;
1876
+ declare function isFileReadSuccess(result: ToolExecutionResult): result is FileReadSuccessResult;
1877
+ declare function isFileEditResult(result: ToolExecutionResult): result is ToolExecutionResult;
1878
+ declare function isFileEditSuccess(result: ToolExecutionResult): result is FileEditSuccessResult;
1879
+ declare function isFileNewResult(result: ToolExecutionResult): result is ToolExecutionResult;
1880
+ declare function isFileNewSuccess(result: ToolExecutionResult): result is FileNewSuccessResult;
1881
+ declare function isDirLsResult(result: ToolExecutionResult): result is ToolExecutionResult;
1882
+ declare function isDirLsSuccess(result: ToolExecutionResult): result is DirLsSuccessResult;
1883
+ declare function isWebSearchResult(result: ToolExecutionResult): result is ToolExecutionResult;
1884
+ declare function isWebSearchSuccess(result: ToolExecutionResult): result is WebSearchSuccessResult;
1885
+ declare function isWebFetchResult(result: ToolExecutionResult): result is ToolExecutionResult;
1886
+ declare function isWebFetchSuccess(result: ToolExecutionResult): result is WebFetchSuccessResult;
1887
+ declare function isTodoWriteResult(result: ToolExecutionResult): result is ToolExecutionResult;
1888
+ declare function isTodoWriteSuccess(result: ToolExecutionResult): result is TodoWriteSuccessResult;
1889
+ declare function isAssignResult(result: ToolExecutionResult): result is ToolExecutionResult;
1890
+ declare function isAssignSuccess(result: ToolExecutionResult): result is AssignSuccessResult;
1891
+
1892
+ declare function okText<M extends Record<string, unknown> = Record<string, unknown>>(result: string, metadata: M): {
1893
+ status: 'success';
1894
+ type: 'text';
1895
+ result: string;
1896
+ metadata: M;
1897
+ };
1898
+ declare function okJson<T extends Record<string, unknown> | unknown[], M extends Record<string, unknown> = Record<string, unknown>>(result: T, metadata?: M): {
1899
+ status: 'success';
1900
+ type: 'json';
1901
+ result: T;
1902
+ metadata?: M;
1903
+ };
1904
+ declare function err(result: string, metadata?: Record<string, unknown>, errorReason?: ErrorReason): ExecResultError;
1905
+
1906
+ /**
1907
+ * Sub-agent related types
1908
+ * These types track the state and execution of delegated specialist agents
1909
+ */
1910
+
1911
+ /**
1912
+ * Represents a tool call made by a sub-agent during execution
1913
+ */
1914
+ type SubAgentToolCall = {
1915
+ id: string;
1916
+ name: string;
1917
+ arguments?: string;
1918
+ durationMs?: number;
1919
+ status?: 'success' | 'error';
1920
+ result?: string;
1921
+ metadata?: Record<string, unknown>;
1922
+ };
1923
+ /**
1924
+ * State tracking for a sub-agent execution
1925
+ * Used by UIs to display real-time sub-agent activity
1926
+ */
1927
+ type SubAgentState = {
1928
+ agentId: string;
1929
+ agentName: string;
1930
+ status: 'starting' | 'running' | 'completed';
1931
+ toolCalls: SubAgentToolCall[];
1932
+ resultMessage?: string;
1933
+ totalDurationMs?: number;
1934
+ finalStatus?: 'success' | 'error' | 'timeout';
1935
+ toolCallMessageId?: string;
1936
+ toolCallId?: string;
1937
+ metrics?: MetricsSnapshot;
1938
+ };
1939
+ /**
1940
+ * Parse tool call arguments from string to typed object
1941
+ */
1942
+ declare function parseSubAgentToolCallArguments(argsString?: string): Record<string, unknown>;
1943
+
1203
1944
  type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
1204
1945
  type LogFormat = 'json' | 'structured';
1205
1946
  type PersistOptions = {
@@ -1470,4 +2211,4 @@ declare function resolveBackspaces(s: string): string;
1470
2211
  declare function stripAnsiAndControls(s: string): string;
1471
2212
  declare function canonicalizeTerminalPaste(raw: string): string;
1472
2213
 
1473
- export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignParams, BashTool, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, ErrorReason, type FolderTreeOptions, GithubLLM, InMemoryMemory, InMemoryMetadata, InMemoryMetricsPort, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, type MetricsChangeHandler, type MetricsPort, type MetricsSnapshot, type ModelInfo, type ModelLimits, NoopMetricsPort, NoopReminders, type OrchestratorAwareToolPort, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, SystemClock, type ToolApprovalDecision, type ToolCall, type ToolExecutionResult, type ToolPort, ToolRegistry, type UsageData, type UserAttachment, type UserMessagePayload, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, createEmptySnapshot, createLLM, generateFolderTree, getAvailableProviders, getFallbackLimits, getProviderLabel, loadMCPConfig, normalizeModelInfo, normalizeModelLimits, normalizeNewlines, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels };
2214
+ export { AGENT_CREATOR_SYSTEM_PROMPT, type AgentAwareToolPort, type AgentCatalog, type AgentConfig, type AgentEvent, AgentEventTypes, AgentFilePersistence, AgentManager, AgentManagerCommandRunner, AgentOrchestrator, AgentRegistry, type AgentTemplate, AnthropicAISDKLLM, type AssignErrorResult, type AssignParams, type AssignResult, type AssignSuccessResult$1 as AssignSuccessResult, type AssignTaskArgs, type AssignTaskMetadata, type BashErrorResult, type BashParams, type BashResult, type BashSuccessResult$1 as BashSuccessResult, BashTool, type BashToolArgs, type BashToolMetadata, type CommandMetadata, type CompleteAgent, CompositeToolPort, type Conversation, ConversationContext, type ConversationMetadata, type ConversationSnapshot, ConversationStore, CoreMCPClient, DefaultDelegationPolicy, DefaultDelegationResultFormatter, DefaultDelegationService, DefaultSpecialistAgentFactory, type DelegationMetadata, type DelegationService, type DelegationServiceConfig, DelegationServiceFactory, type DirEntry, type DirLsArgs, type DirLsMetadata, type DirLsParams, type DirLsResult, type DirLsSuccessResult$1 as DirLsSuccessResult, type ErrorMetadata, ErrorReason, type ExecResult, type ExecResultError, type ExecResultSuccess, type FileEditArgs, type FileEditMetadata, type FileEditResult, type FileEditSuccessResult$1 as FileEditSuccessResult, type FileMetadata, type FileNewArgs, type FileNewMetadata, type FileNewParams, type FileNewResult, type FileNewSuccessResult$1 as FileNewSuccessResult, type FileReadArgs, type FileReadErrorResult, type FileReadMetadata, type FileReadParams, type FileReadResult, type FileReadSuccessResult$1 as FileReadSuccessResult, type FolderTreeOptions, type FunctionTool, GithubLLM, InMemoryMemory, InMemoryMetadata, InMemoryMetricsPort, JsonFileMemoryPersistence, type LLMConfig, LLMError, type LLMFactory, type LLMOptions, type LLMPort, LLMResolver, type LineRangeMetadata, type MCPConfig, type MCPServerConfig, MCPToolPort, type MemoryPort, MemoryPortMetadataAdapter, type Message, type MessageContent, type MessageContentPart, type MetadataPort, type MetricsChangeHandler, type MetricsPort, type MetricsSnapshot, type ModelInfo, type ModelLimits, NoopMetricsPort, NoopReminders, type OrchestratorAwareToolPort, type ParseResult, PersistedMemory, PersistingConsoleEventPort, RuntimeEnv, type SendMessageOptions, SimpleContextBuilder, SimpleCost, SimpleId, type SpecialistAgentConfig, type SpecialistAgentResult, type SubAgentState, type SubAgentToolCall, SystemClock, type TodoWriteArgs, type TodoWriteMetadata, type TodoWriteResult, type TodoWriteSuccessResult$1 as TodoWriteSuccessResult, type ToolApprovalDecision, type ToolArguments, type ToolCall, type ToolCallValidation, type ToolErrorMetadata, type ToolExecutionContext, type ToolExecutionResult, type ToolMetadataMap, type ToolName, type ToolParameterMap, type ToolPort, ToolRegistry, type ToolValidator, type TypedToolInvocation, type UsageData, type UserAttachment, type UserMessagePayload, type ValidationResult, type WebFetchArgs, type WebFetchMetadata, type WebFetchParams, type WebFetchResult, type WebFetchSuccessResult$1 as WebFetchSuccessResult, type WebSearchArgs, type WebSearchMetadata, type WebSearchParams, type WebSearchResult, type WebSearchSuccessResult$1 as WebSearchSuccessResult, type WebSearchToolResult, buildAgentCreationPrompt, buildInjectedSystem, canonicalizeTerminalPaste, convertToolCall, convertToolCalls, createEmptySnapshot, createLLM, err, generateFolderTree, getAvailableProviders, getFallbackLimits, getProviderLabel, isAssignResult, isAssignSuccess, isAssignTaskArgs, isBashResult, isBashSuccess, isBashToolArgs, isDirLsArgs, isDirLsResult, isDirLsSuccess, isError, isFileEditArgs, isFileEditResult, isFileEditSuccess, isFileNewArgs, isFileNewResult, isFileNewSuccess, isFileReadArgs, isFileReadResult, isFileReadSuccess, isJsonResult, isSuccess, isSuccessJson, isSuccessText, isTextResult, isTodoWriteArgs, isTodoWriteResult, isTodoWriteSuccess, isWebFetchArgs, isWebFetchResult, isWebFetchSuccess, isWebSearchArgs, isWebSearchResult, isWebSearchSuccess, loadMCPConfig, normalizeModelInfo, normalizeModelLimits, normalizeNewlines, okJson, okText, parseJSON, parseSubAgentToolCallArguments, parseToolArguments, renderTemplate, resolveBackspaces, resolveCarriageReturns, stripAnsiAndControls, supportsGetModels, toolValidators };