toolpack-sdk 1.3.0 → 2.0.0-alpha.1

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
@@ -1,5 +1,149 @@
1
1
  import { EventEmitter } from 'events';
2
2
 
3
+ /**
4
+ * Core type definitions for the Tool Calling System.
5
+ */
6
+ interface ToolParameterProperty {
7
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer';
8
+ description?: string;
9
+ enum?: string[];
10
+ default?: any;
11
+ items?: ToolParameterProperty;
12
+ properties?: Record<string, ToolParameterProperty>;
13
+ additionalProperties?: ToolParameterProperty | boolean;
14
+ required?: string[];
15
+ }
16
+ interface ToolParameters {
17
+ type: 'object';
18
+ properties: Record<string, ToolParameterProperty>;
19
+ required?: string[];
20
+ }
21
+ interface ToolContext {
22
+ /** Absolute path to the workspace/project root */
23
+ workspaceRoot: string;
24
+ /** Tool-specific config from toolpack.config.json additionalConfigurations */
25
+ config: Record<string, any>;
26
+ /** Scoped logger — writes to toolpack-sdk.log */
27
+ log: (message: string) => void;
28
+ }
29
+ type ConfirmationLevel$1 = 'high' | 'medium';
30
+ interface ToolConfirmation {
31
+ level: ConfirmationLevel$1;
32
+ reason: string;
33
+ showArgs?: string[];
34
+ }
35
+ interface ToolDefinition {
36
+ name: string;
37
+ displayName: string;
38
+ description: string;
39
+ parameters: ToolParameters;
40
+ category: string;
41
+ execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<string>;
42
+ /**
43
+ * Whether this tool should be cached after discovery via tool.search.
44
+ * If false, the tool must be re-discovered each time it's needed.
45
+ * Default: true
46
+ */
47
+ cacheable?: boolean;
48
+ /**
49
+ * Human-in-the-loop confirmation configuration.
50
+ * If set, the tool will require user confirmation before execution.
51
+ * Note: Only effective when onToolConfirm callback is provided to AIClient.
52
+ */
53
+ confirmation?: ToolConfirmation;
54
+ }
55
+ /**
56
+ * Schema-only version of ToolDefinition (no execute function).
57
+ * Used for serialization and sending to AI providers.
58
+ */
59
+ interface ToolSchema {
60
+ name: string;
61
+ displayName: string;
62
+ description: string;
63
+ parameters: ToolParameters;
64
+ category: string;
65
+ /**
66
+ * Whether this tool should be cached after discovery via tool.search.
67
+ * If false, the tool must be re-discovered each time it's needed.
68
+ * Default: true
69
+ */
70
+ cacheable?: boolean;
71
+ }
72
+ interface ToolProjectManifest {
73
+ key: string;
74
+ name: string;
75
+ displayName: string;
76
+ version: string;
77
+ description: string;
78
+ author?: string;
79
+ repository?: string;
80
+ tools: string[];
81
+ category: string;
82
+ }
83
+ interface ToolProjectDependencies {
84
+ [packageName: string]: string;
85
+ }
86
+ interface ToolProject {
87
+ manifest: ToolProjectManifest;
88
+ tools: ToolDefinition[];
89
+ dependencies?: ToolProjectDependencies;
90
+ }
91
+ interface ToolCall {
92
+ id: string;
93
+ name: string;
94
+ arguments: Record<string, any>;
95
+ }
96
+ interface ToolResult {
97
+ tool_call_id: string;
98
+ name: string;
99
+ result: string;
100
+ error?: string;
101
+ }
102
+ interface ToolCategory {
103
+ name: string;
104
+ description: string;
105
+ tools: string[];
106
+ }
107
+ /**
108
+ * @deprecated This interface is deprecated and will be removed in a future version.
109
+ */
110
+ interface IntelligentToolDetectionConfig {
111
+ enabled: boolean;
112
+ maxFollowUpMessages: number;
113
+ }
114
+ /**
115
+ * Tool Search Configuration (Anthropic-style on-demand tool discovery)
116
+ */
117
+ interface ToolSearchConfig {
118
+ enabled: boolean;
119
+ alwaysLoadedTools: string[];
120
+ alwaysLoadedCategories: string[];
121
+ searchResultLimit: number;
122
+ cacheDiscoveredTools: boolean;
123
+ }
124
+ interface ToolsConfig {
125
+ enabled: boolean;
126
+ autoExecute: boolean;
127
+ maxToolRounds: number;
128
+ toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
129
+ resultMaxChars?: number;
130
+ /**
131
+ * @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
132
+ */
133
+ intelligentToolDetection?: IntelligentToolDetectionConfig;
134
+ enabledTools: string[];
135
+ enabledToolCategories: string[];
136
+ toolSearch?: ToolSearchConfig;
137
+ additionalConfigurations?: {
138
+ [key: string]: any;
139
+ };
140
+ }
141
+ /**
142
+ * Default Tool Search Configuration
143
+ */
144
+ declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
145
+ declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
146
+
3
147
  type Role = 'system' | 'user' | 'assistant' | 'tool';
4
148
  interface TextPart {
5
149
  type: 'text';
@@ -77,6 +221,16 @@ interface ToolCallRequest {
77
221
  type: 'function';
78
222
  function: ToolCallFunction;
79
223
  }
224
+ interface RequestToolDefinition {
225
+ name: string;
226
+ displayName: string;
227
+ description: string;
228
+ parameters: Record<string, any>;
229
+ category: string;
230
+ execute: (args: Record<string, any>) => Promise<any>;
231
+ cacheable?: boolean;
232
+ confirmation?: ToolConfirmation;
233
+ }
80
234
  interface ToolCallResult {
81
235
  id: string;
82
236
  name: string;
@@ -93,6 +247,7 @@ interface CompletionRequest {
93
247
  response_format?: 'text' | 'json_object';
94
248
  stream?: boolean;
95
249
  tools?: ToolCallRequest[];
250
+ requestTools?: RequestToolDefinition[];
96
251
  tool_choice?: 'auto' | 'none' | 'required';
97
252
  /** AbortSignal to cancel the request */
98
253
  signal?: AbortSignal;
@@ -169,6 +324,33 @@ interface ToolLogEvent {
169
324
  status: 'success' | 'error';
170
325
  timestamp: number;
171
326
  }
327
+
328
+ type ConfirmationDecision = {
329
+ action: 'allow';
330
+ } | {
331
+ action: 'deny';
332
+ reason?: string;
333
+ } | {
334
+ action: 'modify';
335
+ args: Record<string, any>;
336
+ };
337
+ interface ToolConfirmationRequestedEvent {
338
+ tool: ToolDefinition;
339
+ args: Record<string, any>;
340
+ level: ConfirmationLevel$1;
341
+ reason: string;
342
+ }
343
+ interface ToolConfirmationResolvedEvent extends ToolConfirmationRequestedEvent {
344
+ decision: ConfirmationDecision;
345
+ }
346
+ /**
347
+ * Callback type for handling tool confirmation requests.
348
+ * Called before executing tools that have confirmation metadata set.
349
+ */
350
+ type OnToolConfirmCallback = (tool: ToolDefinition, args: Record<string, any>, context: {
351
+ roundNumber: number;
352
+ conversationId?: string;
353
+ }) => Promise<ConfirmationDecision>;
172
354
  /**
173
355
  * Information about a single model available from a provider.
174
356
  */
@@ -220,6 +402,59 @@ interface ProviderInfo {
220
402
  /** Available models from this provider */
221
403
  models: ProviderModelInfo[];
222
404
  }
405
+ /**
406
+ * Strategy for handling context window limit scenarios
407
+ */
408
+ type ContextWindowStrategy = 'prune' | 'summarize' | 'fail';
409
+ /**
410
+ * Configuration for automatic context window management
411
+ */
412
+ interface ContextWindowConfig {
413
+ /** Master switch for context window management. Default: true */
414
+ enabled?: boolean;
415
+ /** Strategy when context limit is approached or exceeded. Default: 'prune' */
416
+ strategy?: ContextWindowStrategy;
417
+ /**
418
+ * Percentage of context window to trigger pruning/summarization.
419
+ * When current tokens exceed this percentage, cleanup is initiated.
420
+ * Default: 85
421
+ */
422
+ pruneThreshold?: number;
423
+ /**
424
+ * Optional maximum message history length as fallback limit.
425
+ * Useful for caps independent of token counting.
426
+ * When set, removes messages when count exceeds this.
427
+ */
428
+ maxMessageHistoryLength?: number;
429
+ /**
430
+ * Model to use for conversation summarization (if strategy is 'summarize').
431
+ * If omitted, uses the same model as the current request.
432
+ * Example: 'gpt-4.1-mini' for faster/cheaper summaries
433
+ */
434
+ summarizerModel?: string;
435
+ /**
436
+ * Whether to always retain system messages (never prune them).
437
+ * Default: true
438
+ */
439
+ retainSystemMessages?: boolean;
440
+ /**
441
+ * Percentage buffer above actual maxOutputTokens to reserve for safety.
442
+ * Default: 1.15 (15% buffer)
443
+ */
444
+ outputTokenBuffer?: number;
445
+ }
446
+ /**
447
+ * Tracks context window state per conversation for monitoring
448
+ */
449
+ interface ContextWindowState {
450
+ conversationId?: string;
451
+ estimatedTokens: number;
452
+ lastUpdated: number;
453
+ pruneCount: number;
454
+ lastPrunedAt?: number;
455
+ warningsSent: number;
456
+ summarizationCount: number;
457
+ }
223
458
 
224
459
  declare class SDKError extends Error {
225
460
  code: string;
@@ -251,6 +486,109 @@ declare class TimeoutError extends SDKError {
251
486
  phase?: string | undefined;
252
487
  constructor(message: string, phase?: string | undefined, cause?: any);
253
488
  }
489
+ /**
490
+ * Thrown when a conversation exceeds the configured context window limit
491
+ * and cannot be recovered through pruning or summarization
492
+ */
493
+ declare class ContextWindowExceededError extends SDKError {
494
+ conversationId: string;
495
+ currentTokens: number;
496
+ contextWindowLimit: number;
497
+ strategy: 'prune' | 'summarize' | 'fail';
498
+ constructor(message: string, conversationId: string, currentTokens: number, contextWindowLimit: number, strategy: 'prune' | 'summarize' | 'fail', cause?: any);
499
+ /**
500
+ * Get the number of tokens over the limit
501
+ */
502
+ getOverageTokens(): number;
503
+ /**
504
+ * Get the percentage of the context window being used
505
+ */
506
+ getUsagePercentage(): number;
507
+ /**
508
+ * Get a detailed error report
509
+ */
510
+ getDetailedReport(): string;
511
+ }
512
+ /**
513
+ * Thrown when there is insufficient context remaining to process a request
514
+ * after pruning or summarization, even though tokens are within limits
515
+ */
516
+ declare class InsufficientContextError extends SDKError {
517
+ conversationId: string;
518
+ requiredTokens: number;
519
+ availableTokens: number;
520
+ minimumRequiredTokens: number;
521
+ constructor(message: string, conversationId: string, requiredTokens: number, availableTokens: number, minimumRequiredTokens: number, cause?: any);
522
+ /**
523
+ * Get the token deficit
524
+ */
525
+ getDeficit(): number;
526
+ /**
527
+ * Whether the deficit could be recovered by adjusting the strategy
528
+ */
529
+ isRecoverable(): boolean;
530
+ /**
531
+ * Get a detailed error report
532
+ */
533
+ getDetailedReport(): string;
534
+ }
535
+ /**
536
+ * Thrown when summarization fails or produces inadequate results
537
+ */
538
+ declare class SummarizationError extends SDKError {
539
+ conversationId: string;
540
+ messageCount: number;
541
+ failureReason: 'provider_error' | 'invalid_response' | 'insufficient_tokens' | 'invalid_quality' | 'unknown';
542
+ summaryAttempt?: string | undefined;
543
+ constructor(message: string, conversationId: string, messageCount: number, failureReason: 'provider_error' | 'invalid_response' | 'insufficient_tokens' | 'invalid_quality' | 'unknown', summaryAttempt?: string | undefined, cause?: any);
544
+ /**
545
+ * Whether the error is retryable
546
+ */
547
+ isRetryable(): boolean;
548
+ /**
549
+ * Get suggested recovery action
550
+ */
551
+ getSuggestedRecovery(): string;
552
+ /**
553
+ * Get a detailed error report
554
+ */
555
+ getDetailedReport(): string;
556
+ }
557
+ /**
558
+ * Thrown when context window configuration is invalid
559
+ */
560
+ declare class ContextWindowConfigError extends SDKError {
561
+ configField: string;
562
+ providedValue: any;
563
+ constraint: string;
564
+ constructor(message: string, configField: string, providedValue: any, constraint: string, cause?: any);
565
+ /**
566
+ * Get a detailed error report
567
+ */
568
+ getDetailedReport(): string;
569
+ }
570
+ /**
571
+ * Thrown when a state operation is performed on a non-existent conversation
572
+ */
573
+ declare class ConversationNotFoundError extends SDKError {
574
+ conversationId: string;
575
+ constructor(message: string, conversationId: string, cause?: any);
576
+ }
577
+ /**
578
+ * Utility function to check if an error is context window related
579
+ */
580
+ declare function isContextWindowError(error: any): error is SDKError & {
581
+ code: string;
582
+ };
583
+ /**
584
+ * Utility function to handle context window errors
585
+ */
586
+ declare function handleContextWindowError(error: SDKError, _conversationId?: string): {
587
+ shouldRetry: boolean;
588
+ shouldFallback: boolean;
589
+ action: 'prune' | 'summarize' | 'fail' | 'none';
590
+ message: string;
591
+ };
254
592
 
255
593
  declare abstract class ProviderAdapter {
256
594
  /**
@@ -302,138 +640,14 @@ declare abstract class ProviderAdapter {
302
640
  * @throws InvalidRequestError if not supported by this provider.
303
641
  */
304
642
  deleteFile(_fileId: string): Promise<void>;
305
- }
306
-
307
- /**
308
- * Core type definitions for the Tool Calling System.
309
- */
310
- interface ToolParameterProperty {
311
- type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer';
312
- description?: string;
313
- enum?: string[];
314
- default?: any;
315
- items?: ToolParameterProperty;
316
- properties?: Record<string, ToolParameterProperty>;
317
- required?: string[];
318
- }
319
- interface ToolParameters {
320
- type: 'object';
321
- properties: Record<string, ToolParameterProperty>;
322
- required?: string[];
323
- }
324
- interface ToolContext {
325
- /** Absolute path to the workspace/project root */
326
- workspaceRoot: string;
327
- /** Tool-specific config from toolpack.config.json additionalConfigurations */
328
- config: Record<string, any>;
329
- /** Scoped logger — writes to toolpack-sdk.log */
330
- log: (message: string) => void;
331
- }
332
- interface ToolDefinition {
333
- name: string;
334
- displayName: string;
335
- description: string;
336
- parameters: ToolParameters;
337
- category: string;
338
- execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<string>;
339
643
  /**
340
- * Whether this tool should be cached after discovery via tool.search.
341
- * If false, the tool must be re-discovered each time it's needed.
342
- * Default: true
644
+ * Estimates the number of tokens for the given messages and model.
645
+ * @param _messages The messages to count.
646
+ * @param _model The model to count for.
647
+ * @returns The number of tokens or null if not supported.
343
648
  */
344
- cacheable?: boolean;
649
+ countTokens(_messages: Message[], _model: string): Promise<number | null>;
345
650
  }
346
- /**
347
- * Schema-only version of ToolDefinition (no execute function).
348
- * Used for serialization and sending to AI providers.
349
- */
350
- interface ToolSchema {
351
- name: string;
352
- displayName: string;
353
- description: string;
354
- parameters: ToolParameters;
355
- category: string;
356
- /**
357
- * Whether this tool should be cached after discovery via tool.search.
358
- * If false, the tool must be re-discovered each time it's needed.
359
- * Default: true
360
- */
361
- cacheable?: boolean;
362
- }
363
- interface ToolProjectManifest {
364
- key: string;
365
- name: string;
366
- displayName: string;
367
- version: string;
368
- description: string;
369
- author?: string;
370
- repository?: string;
371
- tools: string[];
372
- category: string;
373
- }
374
- interface ToolProjectDependencies {
375
- [packageName: string]: string;
376
- }
377
- interface ToolProject {
378
- manifest: ToolProjectManifest;
379
- tools: ToolDefinition[];
380
- dependencies?: ToolProjectDependencies;
381
- }
382
- interface ToolCall {
383
- id: string;
384
- name: string;
385
- arguments: Record<string, any>;
386
- }
387
- interface ToolResult {
388
- tool_call_id: string;
389
- name: string;
390
- result: string;
391
- error?: string;
392
- }
393
- interface ToolCategory {
394
- name: string;
395
- description: string;
396
- tools: string[];
397
- }
398
- /**
399
- * @deprecated This interface is deprecated and will be removed in a future version.
400
- */
401
- interface IntelligentToolDetectionConfig {
402
- enabled: boolean;
403
- maxFollowUpMessages: number;
404
- }
405
- /**
406
- * Tool Search Configuration (Anthropic-style on-demand tool discovery)
407
- */
408
- interface ToolSearchConfig {
409
- enabled: boolean;
410
- alwaysLoadedTools: string[];
411
- alwaysLoadedCategories: string[];
412
- searchResultLimit: number;
413
- cacheDiscoveredTools: boolean;
414
- }
415
- interface ToolsConfig {
416
- enabled: boolean;
417
- autoExecute: boolean;
418
- maxToolRounds: number;
419
- toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
420
- resultMaxChars?: number;
421
- /**
422
- * @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
423
- */
424
- intelligentToolDetection?: IntelligentToolDetectionConfig;
425
- enabledTools: string[];
426
- enabledToolCategories: string[];
427
- toolSearch?: ToolSearchConfig;
428
- additionalConfigurations?: {
429
- [key: string]: any;
430
- };
431
- }
432
- /**
433
- * Default Tool Search Configuration
434
- */
435
- declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
436
- declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
437
651
 
438
652
  /**
439
653
  * Central registry for all tools (built-in + custom).
@@ -680,11 +894,48 @@ interface WorkflowEvents {
680
894
  'workflow:step_added': (step: PlanStep, plan: Plan) => void;
681
895
  /** Emitted for progress updates */
682
896
  'workflow:progress': (progress: WorkflowProgress) => void;
897
+ /** Emitted when context window usage is high (approaching limit) */
898
+ 'workflow:context_warning': (event: ContextWindowWarningEvent) => void;
899
+ /** Emitted when context window would be exceeded */
900
+ 'workflow:context_exceeded': (event: ContextWindowExceededEvent) => void;
901
+ /** Emitted when messages are pruned to recover context */
902
+ 'workflow:context_pruned': (event: ContextPrunedEvent) => void;
903
+ /** Emitted when conversation is summarized for context recovery */
904
+ 'workflow:conversation_summarized': (event: ConversationSummarizedEvent) => void;
683
905
  /** Emitted when workflow completes */
684
906
  'workflow:completed': (plan: Plan, result: WorkflowResult) => void;
685
907
  /** Emitted when workflow fails */
686
908
  'workflow:failed': (plan: Plan, error: Error) => void;
687
909
  }
910
+ interface ContextWindowWarningEvent {
911
+ currentTokens: number;
912
+ contextWindow: number;
913
+ percentage: number;
914
+ model: string;
915
+ conversationId?: string;
916
+ }
917
+ interface ContextWindowExceededEvent {
918
+ currentTokens: number;
919
+ contextWindow: number;
920
+ maxOutputTokens: number;
921
+ model: string;
922
+ strategy: 'prune' | 'summarize' | 'fail';
923
+ conversationId?: string;
924
+ }
925
+ interface ContextPrunedEvent {
926
+ removed: number;
927
+ tokensReclaimed: number;
928
+ newTotal: number;
929
+ conversationId?: string;
930
+ beforeCount: number;
931
+ afterCount: number;
932
+ }
933
+ interface ConversationSummarizedEvent {
934
+ summarized: number;
935
+ summaryTokens: number;
936
+ tokensSaved: number;
937
+ conversationId?: string;
938
+ }
688
939
  interface WorkflowProgress {
689
940
  planId: string;
690
941
  currentStep: number;
@@ -781,12 +1032,110 @@ interface ModeConfig {
781
1032
  blockAllTools: boolean;
782
1033
  }
783
1034
  /**
784
- * A lightweight reference to a mode, used in tool-blocked hints.
1035
+ * A lightweight reference to a mode, used in tool-blocked hints.
1036
+ */
1037
+ interface ModeBlockedHint {
1038
+ blockedToolNames: string[];
1039
+ suggestedMode: string;
1040
+ }
1041
+
1042
+ type ConfirmationLevel = 'high' | 'medium';
1043
+ interface OllamaModelConfig {
1044
+ /** Model name as used by Ollama, e.g. 'llama3', 'phi3:mini' */
1045
+ model: string;
1046
+ /** Display label for the UI */
1047
+ label?: string;
1048
+ }
1049
+ interface HitlConfig {
1050
+ /** Master switch. Default: true */
1051
+ enabled?: boolean;
1052
+ /** Confirmation mode. Default: 'all' */
1053
+ confirmationMode?: 'off' | 'high-only' | 'all';
1054
+ /** Bypass rules for specific tools, categories, or risk levels */
1055
+ bypass?: {
1056
+ /** Tool keys to bypass (e.g. ["exec.run", "fs.delete_file"]) */
1057
+ tools?: string[];
1058
+ /** Categories to bypass (e.g. ["exec-tools"]) */
1059
+ categories?: string[];
1060
+ /** Risk levels to bypass (e.g. ["medium"]) */
1061
+ levels?: ConfirmationLevel[];
1062
+ };
1063
+ }
1064
+ interface ToolpackConfig {
1065
+ /** Optional override system prompt for the AIClient */
1066
+ systemPrompt?: string;
1067
+ /** @deprecated Use `baseContext: false` instead. Legacy: disable auto-injected base agent context. */
1068
+ disableBaseContext?: boolean;
1069
+ /** Base agent context configuration. `false` disables it entirely. */
1070
+ baseContext?: {
1071
+ includeWorkingDirectory?: boolean;
1072
+ includeToolCategories?: boolean;
1073
+ custom?: string;
1074
+ } | false;
1075
+ /** Optional system prompt overrides for specific modes */
1076
+ modeOverrides?: Record<string, Partial<ModeConfig>>;
1077
+ /** Ollama provider configuration */
1078
+ ollama?: {
1079
+ /** Base URL for the Ollama API. Default: http://localhost:11434 */
1080
+ baseUrl?: string;
1081
+ /** List of Ollama models available as providers */
1082
+ models?: OllamaModelConfig[];
1083
+ };
1084
+ /** Logging configuration. File logging is opt-in (disabled by default). */
1085
+ logging?: {
1086
+ /** Enable file logging. Default: false */
1087
+ enabled?: boolean;
1088
+ /** Log file path. Default: 'toolpack-sdk.log' in CWD */
1089
+ filePath?: string;
1090
+ };
1091
+ /** Human-in-the-loop configuration for tool confirmation */
1092
+ hitl?: HitlConfig;
1093
+ /** Context window management configuration for automatic conversation pruning/summarization */
1094
+ contextWindow?: ContextWindowConfig;
1095
+ }
1096
+ declare function getToolpackConfig(configPath?: string): ToolpackConfig;
1097
+ declare function reloadToolpackConfig(): void;
1098
+ interface OllamaProviderEntry {
1099
+ /** Provider type key, e.g. 'ollama-llama3' */
1100
+ type: string;
1101
+ /** Ollama model name, e.g. 'llama3' */
1102
+ model: string;
1103
+ /** Display label */
1104
+ label: string;
1105
+ }
1106
+ declare function getOllamaProviderEntries(configPath?: string): OllamaProviderEntry[];
1107
+ declare function getOllamaBaseUrl(configPath?: string): string;
1108
+ type BypassRuleType = 'tool' | 'category' | 'level';
1109
+ interface AddBypassRuleOptions {
1110
+ /** Type of bypass rule */
1111
+ type: BypassRuleType;
1112
+ /** Value to bypass (tool name, category, or level) */
1113
+ value: string;
1114
+ /** Optional config path. If not provided, uses local config or creates one */
1115
+ configPath?: string;
1116
+ }
1117
+ /**
1118
+ * Add a bypass rule to the HITL config and persist it to the config file.
1119
+ * This is useful for implementing "Allow Always" functionality.
1120
+ *
1121
+ * @example
1122
+ * // Bypass a specific tool
1123
+ * await addBypassRule({ type: 'tool', value: 'fs.write_file' });
1124
+ *
1125
+ * // Bypass all medium-risk tools
1126
+ * await addBypassRule({ type: 'level', value: 'medium' });
1127
+ *
1128
+ * // Bypass an entire category
1129
+ * await addBypassRule({ type: 'category', value: 'exec-tools' });
785
1130
  */
786
- interface ModeBlockedHint {
787
- blockedToolNames: string[];
788
- suggestedMode: string;
789
- }
1131
+ declare function addBypassRule(options: AddBypassRuleOptions): Promise<void>;
1132
+ /**
1133
+ * Remove a bypass rule from the HITL config.
1134
+ *
1135
+ * @example
1136
+ * await removeBypassRule({ type: 'tool', value: 'fs.write_file' });
1137
+ */
1138
+ declare function removeBypassRule(options: AddBypassRuleOptions): Promise<void>;
790
1139
 
791
1140
  /**
792
1141
  * Query Classifier for Tool Orchestration
@@ -822,6 +1171,14 @@ interface AIClientConfig {
822
1171
  toolsConfig?: ToolsConfig;
823
1172
  systemPrompt?: string;
824
1173
  disableBaseContext?: boolean;
1174
+ /** Human-in-the-loop configuration for tool confirmation */
1175
+ hitlConfig?: HitlConfig;
1176
+ /** Callback for handling tool confirmation requests */
1177
+ onToolConfirm?: OnToolConfirmCallback;
1178
+ /** Optional conversation ID for tracking context */
1179
+ conversationId?: string;
1180
+ /** Context window management configuration */
1181
+ contextWindowConfig?: ContextWindowConfig;
825
1182
  }
826
1183
  declare class AIClient extends EventEmitter {
827
1184
  private providers;
@@ -836,7 +1193,26 @@ declare class AIClient extends EventEmitter {
836
1193
  private overrideSystemPrompt?;
837
1194
  private disableBaseContext;
838
1195
  private toolResultMaxChars;
1196
+ private hitlConfig?;
1197
+ private onToolConfirm?;
1198
+ private currentRound;
1199
+ private conversationId?;
1200
+ private contextWindowConfig?;
1201
+ private contextWindowStateManager?;
1202
+ private providerModelCache;
839
1203
  constructor(config: AIClientConfig);
1204
+ private getConversationId;
1205
+ private getModelInfo;
1206
+ private countRequestTokens;
1207
+ private pruneConversation;
1208
+ private pruneToMaxMessageHistory;
1209
+ private summarizeConversation;
1210
+ private enforceContextWindow;
1211
+ /**
1212
+ * Check if a tool should bypass confirmation based on HITL config.
1213
+ * Returns true if the tool should execute without confirmation.
1214
+ */
1215
+ private isBypassed;
840
1216
  /**
841
1217
  * Register a new provider instance.
842
1218
  */
@@ -845,6 +1221,15 @@ declare class AIClient extends EventEmitter {
845
1221
  * Get a provider by name, or the default if none specified.
846
1222
  */
847
1223
  getProvider(name?: string): ProviderAdapter;
1224
+ /**
1225
+ * Update the HITL configuration dynamically.
1226
+ * This allows modifying bypass rules without restarting the client.
1227
+ */
1228
+ updateHitlConfig(config: HitlConfig): void;
1229
+ /**
1230
+ * Get the current HITL configuration.
1231
+ */
1232
+ getHitlConfig(): HitlConfig | undefined;
848
1233
  /**
849
1234
  * Set the default provider for this client.
850
1235
  */
@@ -912,6 +1297,13 @@ declare class AIClient extends EventEmitter {
912
1297
  * Applies mode-based tool filtering when an active mode is set.
913
1298
  */
914
1299
  private enrichRequestWithTools;
1300
+ private buildRequestToolMap;
1301
+ private requestToolToSchema;
1302
+ private mergeSchemas;
1303
+ private schemasToToolCallRequests;
1304
+ private mergeToolCallRequests;
1305
+ private injectRequestToolGuidance;
1306
+ private stripRequestTools;
915
1307
  /**
916
1308
  * Filter tool schemas based on mode permissions.
917
1309
  * blockedTools/blockedToolCategories always take precedence.
@@ -1022,53 +1414,6 @@ declare class GeminiAdapter extends ProviderAdapter {
1022
1414
  private handleError;
1023
1415
  }
1024
1416
 
1025
- interface OllamaModelConfig {
1026
- /** Model name as used by Ollama, e.g. 'llama3', 'phi3:mini' */
1027
- model: string;
1028
- /** Display label for the UI */
1029
- label?: string;
1030
- }
1031
- interface ToolpackConfig {
1032
- /** Optional override system prompt for the AIClient */
1033
- systemPrompt?: string;
1034
- /** @deprecated Use `baseContext: false` instead. Legacy: disable auto-injected base agent context. */
1035
- disableBaseContext?: boolean;
1036
- /** Base agent context configuration. `false` disables it entirely. */
1037
- baseContext?: {
1038
- includeWorkingDirectory?: boolean;
1039
- includeToolCategories?: boolean;
1040
- custom?: string;
1041
- } | false;
1042
- /** Optional system prompt overrides for specific modes */
1043
- modeOverrides?: Record<string, Partial<ModeConfig>>;
1044
- /** Ollama provider configuration */
1045
- ollama?: {
1046
- /** Base URL for the Ollama API. Default: http://localhost:11434 */
1047
- baseUrl?: string;
1048
- /** List of Ollama models available as providers */
1049
- models?: OllamaModelConfig[];
1050
- };
1051
- /** Logging configuration. File logging is opt-in (disabled by default). */
1052
- logging?: {
1053
- /** Enable file logging. Default: false */
1054
- enabled?: boolean;
1055
- /** Log file path. Default: 'toolpack-sdk.log' in CWD */
1056
- filePath?: string;
1057
- };
1058
- }
1059
- declare function getToolpackConfig(configPath?: string): ToolpackConfig;
1060
- declare function reloadToolpackConfig(): void;
1061
- interface OllamaProviderEntry {
1062
- /** Provider type key, e.g. 'ollama-llama3' */
1063
- type: string;
1064
- /** Ollama model name, e.g. 'llama3' */
1065
- model: string;
1066
- /** Display label */
1067
- label: string;
1068
- }
1069
- declare function getOllamaProviderEntries(configPath?: string): OllamaProviderEntry[];
1070
- declare function getOllamaBaseUrl(configPath?: string): string;
1071
-
1072
1417
  /**
1073
1418
  * Ollama Adapter
1074
1419
  *
@@ -1238,6 +1583,24 @@ declare class OpenAIAdapter extends ProviderAdapter {
1238
1583
  private handleError;
1239
1584
  }
1240
1585
 
1586
+ interface OpenRouterOptions {
1587
+ siteUrl?: string;
1588
+ siteName?: string;
1589
+ }
1590
+ declare class OpenRouterAdapter extends OpenAIAdapter {
1591
+ name: string;
1592
+ private readonly _apiKey;
1593
+ constructor(apiKey: string, options?: OpenRouterOptions);
1594
+ getDisplayName(): string;
1595
+ supportsFileUpload(): boolean;
1596
+ generate(request: CompletionRequest): Promise<CompletionResponse>;
1597
+ stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
1598
+ private normalizeRequest;
1599
+ getModels(): Promise<ProviderModelInfo[]>;
1600
+ private mapModel;
1601
+ private deriveCostTier;
1602
+ }
1603
+
1241
1604
  declare function getMimeType(filePath: string): string;
1242
1605
  declare function isDataUri(url: string): boolean;
1243
1606
  declare function parseDataUri(dataUri: string): {
@@ -1480,6 +1843,7 @@ declare class McpClient extends EventEmitter {
1480
1843
  constructor(config: McpClientConfig);
1481
1844
  /** Whether the client is currently connected */
1482
1845
  get connected(): boolean;
1846
+ private initializeServer;
1483
1847
  connect(): Promise<void>;
1484
1848
  private attemptReconnect;
1485
1849
  private handleData;
@@ -1533,6 +1897,7 @@ declare class McpToolManager {
1533
1897
  private clients;
1534
1898
  private serverConfigs;
1535
1899
  private toolDefinitions;
1900
+ private toolOwners;
1536
1901
  constructor(config: McpToolsConfig);
1537
1902
  /**
1538
1903
  * Connect to a single MCP server and discover its tools
@@ -1570,6 +1935,12 @@ declare class McpToolManager {
1570
1935
  * Set up event handlers for an MCP client
1571
1936
  */
1572
1937
  private setupClientEvents;
1938
+ private removeServerToolDefinitions;
1939
+ private discoverServerTools;
1940
+ private refreshServerTools;
1941
+ }
1942
+ interface McpToolProject extends ToolProject {
1943
+ mcpManager: McpToolManager;
1573
1944
  }
1574
1945
  /**
1575
1946
  * Create an MCP tool project from server configurations
@@ -1600,11 +1971,11 @@ declare class McpToolManager {
1600
1971
  * });
1601
1972
  * ```
1602
1973
  */
1603
- declare function createMcpToolProject(config: McpToolsConfig): Promise<ToolProject>;
1974
+ declare function createMcpToolProject(config: McpToolsConfig): Promise<McpToolProject>;
1604
1975
  /**
1605
1976
  * Disconnect all MCP servers in a tool project
1606
1977
  */
1607
- declare function disconnectMcpToolProject(project: ToolProject): Promise<void>;
1978
+ declare function disconnectMcpToolProject(project: ToolProject | McpToolProject): Promise<void>;
1608
1979
 
1609
1980
  interface FullConfig {
1610
1981
  tools?: Partial<ToolsConfig>;
@@ -1614,6 +1985,7 @@ interface FullConfig {
1614
1985
  baseContext?: boolean;
1615
1986
  modeOverrides?: Record<string, any>;
1616
1987
  mcp?: McpToolsConfig;
1988
+ hitl?: HitlConfig;
1617
1989
  }
1618
1990
  /**
1619
1991
  * Load the full config from toolpack.config.json.
@@ -1711,6 +2083,24 @@ declare const httpDownloadTool: ToolDefinition;
1711
2083
 
1712
2084
  declare const httpToolsProject: ToolProject;
1713
2085
 
2086
+ declare const githubGraphqlExecuteTool: ToolDefinition;
2087
+
2088
+ declare const githubContentsGetTextTool: ToolDefinition;
2089
+
2090
+ declare const githubPrReviewThreadsListTool: ToolDefinition;
2091
+
2092
+ declare const githubPrReviewThreadsResolveTool: ToolDefinition;
2093
+
2094
+ declare const githubPrReviewCommentsReplyTool: ToolDefinition;
2095
+
2096
+ declare const githubPrDiffGetTool: ToolDefinition;
2097
+
2098
+ declare const githubPrFilesListTool: ToolDefinition;
2099
+
2100
+ declare const githubPrReviewsSubmitTool: ToolDefinition;
2101
+
2102
+ declare const githubToolsProject: ToolProject;
2103
+
1714
2104
  declare const webFetchTool: ToolDefinition;
1715
2105
 
1716
2106
  declare const webSearchTool: ToolDefinition;
@@ -1781,6 +2171,20 @@ declare const cloudListTool: ToolDefinition;
1781
2171
 
1782
2172
  declare const cloudToolsProject: ToolProject;
1783
2173
 
2174
+ declare const k8sListPodsTool: ToolDefinition;
2175
+ declare const k8sDescribeTool: ToolDefinition;
2176
+ declare const k8sGetLogsTool: ToolDefinition;
2177
+ declare const k8sApplyManifestTool: ToolDefinition;
2178
+ declare const k8sDeleteResourceTool: ToolDefinition;
2179
+ declare const k8sListServicesTool: ToolDefinition;
2180
+ declare const k8sListDeploymentsTool: ToolDefinition;
2181
+ declare const k8sGetConfigMapTool: ToolDefinition;
2182
+ declare const k8sSwitchContextTool: ToolDefinition;
2183
+ declare const k8sGetNamespacesTool: ToolDefinition;
2184
+ declare const k8sWaitForDeploymentTool: ToolDefinition;
2185
+
2186
+ declare const k8sToolsProject: ToolProject;
2187
+
1784
2188
  /**
1785
2189
  * Central registry for AI agent modes (built-in + custom).
1786
2190
  * Handles registration, lookup, cycling, and defaults.
@@ -1905,6 +2309,15 @@ declare const AGENT_MODE: ModeConfig;
1905
2309
  * Ideal for general Q&A, research, and online assistance.
1906
2310
  */
1907
2311
  declare const CHAT_MODE: ModeConfig;
2312
+ /**
2313
+ * Built-in mode: Coding
2314
+ *
2315
+ * Optimized for software development tasks. Uses concise step outputs with
2316
+ * minimal conversational text. Each step produces focused technical output,
2317
+ * and only the final step provides a summary of execution. Ideal for coding,
2318
+ refactoring, debugging, and file manipulation tasks where brevity matters.
2319
+ */
2320
+ declare const CODING_MODE: ModeConfig;
1908
2321
  /**
1909
2322
  * All built-in modes.
1910
2323
  *
@@ -2110,6 +2523,10 @@ interface ProviderOptions {
2110
2523
  model?: string;
2111
2524
  /** Base URL override (for OpenAI-compatible endpoints or custom Ollama host) */
2112
2525
  baseUrl?: string;
2526
+ /** OpenRouter only: your site URL for the leaderboard/attribution header */
2527
+ siteUrl?: string;
2528
+ /** OpenRouter only: your site name for the leaderboard/attribution header */
2529
+ siteName?: string;
2113
2530
  }
2114
2531
  interface ToolpackInitConfig {
2115
2532
  /** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
@@ -2123,6 +2540,8 @@ interface ToolpackInitConfig {
2123
2540
  model?: string;
2124
2541
  /** Load built-in tools (fs, http, etc.)? Default: false */
2125
2542
  tools?: boolean;
2543
+ /** Context window management configuration for automatic conversation pruning/summarization */
2544
+ contextWindow?: ContextWindowConfig;
2126
2545
  /** Custom tool projects to load in addition to built-ins */
2127
2546
  customTools?: ToolProject[];
2128
2547
  /** Multi-provider config (overrides single provider settings) */
@@ -2152,12 +2571,29 @@ interface ToolpackInitConfig {
2152
2571
  mcp?: McpToolsConfig;
2153
2572
  /**
2154
2573
  * Optional Knowledge instance for RAG (Retrieval-Augmented Generation).
2155
- * When provided, the knowledge base will be registered as a tool that the AI can use to search documentation.
2574
+ * When provided, knowledge_search and knowledge_add tools are automatically available
2575
+ * as request-scoped tools that the AI can use to retrieve and store information.
2156
2576
  * Can be null if initialization fails - will be gracefully skipped.
2157
2577
  *
2158
2578
  * Accepts any object with a `toTool()` method (e.g. `Knowledge` from `@toolpack-sdk/knowledge`).
2159
2579
  */
2160
- knowledge?: KnowledgeInstance | null;
2580
+ knowledge?: KnowledgeInstance | KnowledgeInstance[] | null;
2581
+ /**
2582
+ * Human-in-the-loop configuration for tool confirmation.
2583
+ * Default: 'all' when onToolConfirm is provided, 'off' otherwise.
2584
+ */
2585
+ confirmationMode?: 'off' | 'high-only' | 'all';
2586
+ /**
2587
+ * Callback for handling tool confirmation requests.
2588
+ * Called before executing tools that have confirmation metadata set.
2589
+ * If not provided, HITL is disabled regardless of confirmationMode.
2590
+ */
2591
+ onToolConfirm?: (tool: ToolDefinition, args: Record<string, any>, context: {
2592
+ roundNumber: number;
2593
+ conversationId?: string;
2594
+ }) => Promise<ConfirmationDecision>;
2595
+ /** Optional conversation ID for tracking context across confirmations */
2596
+ conversationId?: string;
2161
2597
  }
2162
2598
  /**
2163
2599
  * Duck-typed interface for Knowledge instances to avoid circular dependency
@@ -2188,6 +2624,7 @@ interface KnowledgeInstance {
2188
2624
  }>;
2189
2625
  }) => Promise<any>;
2190
2626
  };
2627
+ add(content: string, metadata?: Record<string, unknown>): Promise<string>;
2191
2628
  query(text: string, options?: Record<string, unknown>): Promise<any[]>;
2192
2629
  stop(): Promise<void>;
2193
2630
  }
@@ -2196,9 +2633,12 @@ declare class Toolpack extends EventEmitter {
2196
2633
  private activeProviderName;
2197
2634
  private modeRegistry;
2198
2635
  private workflowExecutor;
2636
+ private knowledgeLayers;
2199
2637
  customProviderNames: Set<string>;
2200
2638
  private mcpToolProject;
2201
2639
  private constructor();
2640
+ private buildKnowledgeRequestTools;
2641
+ private prepareRequest;
2202
2642
  /**
2203
2643
  * Initialize the Toolpack SDK.
2204
2644
  *
@@ -2223,6 +2663,12 @@ declare class Toolpack extends EventEmitter {
2223
2663
  * Useful for listening to tool progress events.
2224
2664
  */
2225
2665
  getClient(): AIClient;
2666
+ /**
2667
+ * Reload configuration from the config file.
2668
+ * This updates the HITL config in the running instance.
2669
+ * Call this after modifying config (e.g., bypass rules) to apply changes immediately.
2670
+ */
2671
+ reloadConfig(configPath?: string): void;
2226
2672
  /**
2227
2673
  * Get the WorkflowExecutor instance.
2228
2674
  * Useful for workflow events and approval flows.
@@ -2275,6 +2721,183 @@ declare class Toolpack extends EventEmitter {
2275
2721
  private forwardWorkflowEvents;
2276
2722
  }
2277
2723
 
2724
+ /**
2725
+ * A participant in a conversation — a human user, another agent, or the
2726
+ * system itself. Stored alongside each `StoredMessage` so the prompt
2727
+ * assembler can reconstruct who said what without extra lookups.
2728
+ */
2729
+ interface Participant {
2730
+ /** Coarse participant kind */
2731
+ kind: 'system' | 'user' | 'agent';
2732
+ /** Stable identifier for this participant (platform-specific id or agent name) */
2733
+ id: string;
2734
+ /** Human-readable display name, resolved lazily. Falls back to `id` if unset. */
2735
+ displayName?: string;
2736
+ /** For `kind: 'agent'` only: an optional role label for rendering */
2737
+ agentType?: string;
2738
+ /** Optional free-form metadata (e.g. platform-specific profile info) */
2739
+ metadata?: Record<string, unknown>;
2740
+ }
2741
+
2742
+ /**
2743
+ * Coarse scope of a stored message.
2744
+ *
2745
+ * - `thread` — a reply inside a specific thread (Slack thread, email thread)
2746
+ * - `channel` — top-level message in a channel / group chat
2747
+ * - `dm` — direct / private message between two participants
2748
+ */
2749
+ type ConversationScope = 'thread' | 'channel' | 'dm';
2750
+ /**
2751
+ * A single stored message in conversation history.
2752
+ *
2753
+ * This is the canonical storage shape. It is deliberately richer than
2754
+ * the LLM's role-based format — the prompt assembler projects it into
2755
+ * whatever the provider expects at render time.
2756
+ */
2757
+ interface StoredMessage {
2758
+ /** Stable, unique message id. Used for dedup at capture time. */
2759
+ id: string;
2760
+ /**
2761
+ * Conversation key. Identifies the thread / DM / channel this message
2762
+ * belongs to.
2763
+ */
2764
+ conversationId: string;
2765
+ /** Who sent this message. */
2766
+ participant: Participant;
2767
+ /** Plain-text content of the message. */
2768
+ content: string;
2769
+ /** ISO 8601 timestamp of when the message was received/sent. */
2770
+ timestamp: string;
2771
+ /** Coarse scope used by the assembler to filter by context type. */
2772
+ scope: ConversationScope;
2773
+ metadata?: {
2774
+ /** Platform channel type, e.g. 'im' for Slack DMs, 'private' for Telegram DMs. */
2775
+ channelType?: string;
2776
+ /** Thread timestamp / id within a channel (e.g. Slack thread_ts). */
2777
+ threadId?: string;
2778
+ /** Platform-specific message id for dedup and linking. */
2779
+ messageId?: string;
2780
+ /** Participant ids explicitly @-mentioned in this message. */
2781
+ mentions?: string[];
2782
+ /** Whether this message is a rolling summary replacing older turns. */
2783
+ isSummary?: boolean;
2784
+ /** Human-readable channel or group name (e.g. '#general', 'Project Kore'). */
2785
+ channelName?: string;
2786
+ /** Platform-specific channel identifier (e.g. Slack 'C12345', Telegram chat id). */
2787
+ channelId?: string;
2788
+ };
2789
+ }
2790
+ /** Options for retrieving messages from the store. */
2791
+ interface GetOptions {
2792
+ /** Filter to a specific scope within the conversation. */
2793
+ scope?: ConversationScope;
2794
+ /** Only return messages at or after this ISO timestamp. */
2795
+ sinceTimestamp?: string;
2796
+ /** Maximum number of messages to return (most recent N). */
2797
+ limit?: number;
2798
+ /**
2799
+ * When set, only return messages whose `participant.id` is in this set.
2800
+ * Used by the assembler's addressed-only mode.
2801
+ */
2802
+ participantIds?: string[];
2803
+ }
2804
+ /** Options for the conversation search tool. */
2805
+ interface ConversationSearchOptions {
2806
+ /** Maximum number of results to return. Default: 10. */
2807
+ limit?: number;
2808
+ /**
2809
+ * Rough token cap for total search results.
2810
+ * The store truncates content to fit within this budget.
2811
+ * Default: 2000.
2812
+ */
2813
+ tokenCap?: number;
2814
+ }
2815
+ /** Options for the prompt assembler (used by toolpack-agents). */
2816
+ interface AssemblerOptions {
2817
+ scope?: ConversationScope;
2818
+ addressedOnlyMode?: boolean;
2819
+ tokenBudget?: number;
2820
+ rollingSummaryThreshold?: number;
2821
+ timeWindowMinutes?: number;
2822
+ maxTurnsToLoad?: number;
2823
+ agentAliases?: string[];
2824
+ }
2825
+ /** A single message entry in the assembled prompt, ready to send to the LLM. */
2826
+ interface PromptMessage {
2827
+ role: 'system' | 'user' | 'assistant';
2828
+ content: string;
2829
+ }
2830
+ /** The output of the prompt assembler. */
2831
+ interface AssembledPrompt {
2832
+ messages: PromptMessage[];
2833
+ estimatedTokens: number;
2834
+ turnsLoaded: number;
2835
+ hasSummary: boolean;
2836
+ }
2837
+ /**
2838
+ * Interface for conversation history storage.
2839
+ *
2840
+ * Implementations must be:
2841
+ * - **Append-only safe**: `append()` must be idempotent on duplicate `id`.
2842
+ * - **Ordered**: `get()` returns messages in ascending timestamp order.
2843
+ * - **Scope-aware**: `get()` must respect `options.scope` when provided.
2844
+ */
2845
+ interface ConversationStore {
2846
+ append(message: StoredMessage): Promise<void>;
2847
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2848
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2849
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2850
+ }
2851
+
2852
+ interface InMemoryConversationStoreConfig {
2853
+ /** Maximum conversations to keep in memory. Default: 500. */
2854
+ maxConversations?: number;
2855
+ /** Maximum messages per conversation. Default: 500. */
2856
+ maxMessagesPerConversation?: number;
2857
+ }
2858
+ /**
2859
+ * In-memory implementation of `ConversationStore`.
2860
+ *
2861
+ * Good for single-process deployments, local development, and tests.
2862
+ * Memory is bounded by `maxConversations × maxMessagesPerConversation`.
2863
+ *
2864
+ * **Not suitable for multi-process or serverless deployments** — each
2865
+ * process has its own isolated store. For those environments, implement
2866
+ * `ConversationStore` against a shared database.
2867
+ */
2868
+ declare class InMemoryConversationStore implements ConversationStore {
2869
+ private readonly lru;
2870
+ private readonly maxMessagesPerConversation;
2871
+ constructor(config?: InMemoryConversationStoreConfig);
2872
+ append(message: StoredMessage): Promise<void>;
2873
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2874
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2875
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2876
+ clearConversation(conversationId: string): void;
2877
+ get conversationCount(): number;
2878
+ }
2879
+
2880
+ interface SQLiteConversationStoreConfig {
2881
+ dbPath?: string;
2882
+ maxMessagesPerConversation?: number;
2883
+ enableWAL?: boolean;
2884
+ useFTS?: boolean;
2885
+ }
2886
+ declare class SQLiteConversationStore implements ConversationStore {
2887
+ private readonly db;
2888
+ private readonly maxMessagesPerConversation;
2889
+ private readonly useFTS;
2890
+ constructor(config?: SQLiteConversationStoreConfig);
2891
+ private initSchema;
2892
+ append(message: StoredMessage): Promise<void>;
2893
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2894
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2895
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2896
+ clearConversation(conversationId: string): void;
2897
+ private rowToMessage;
2898
+ close(): void;
2899
+ }
2900
+
2278
2901
  declare const TOOLPACK_DIR_NAME = ".toolpack";
2279
2902
  declare const CONFIG_DIR_NAME = "config";
2280
2903
  declare const CONFIG_FILE_NAME = "toolpack.config.json";
@@ -2336,6 +2959,254 @@ declare function getRuntimeConfigStatus(workspacePath?: string): RuntimeConfigSt
2336
2959
  */
2337
2960
  declare function initializeGlobalConfigIfFirstRun(workspacePath?: string): void;
2338
2961
 
2962
+ /**
2963
+ * Token Counting Utilities
2964
+ *
2965
+ * Provider-specific token counting for accurate context window management.
2966
+ * Supports OpenAI (js-tiktoken), Anthropic, Gemini, and Ollama with fallback estimation.
2967
+ */
2968
+
2969
+ declare function estimateTokenCount(messages: Message[]): number;
2970
+ declare function countTokens(messages: Message[], model: string, provider: string): Promise<number>;
2971
+ /**
2972
+ * Calculate if a request would exceed the context window given available space
2973
+ */
2974
+ declare function wouldExceedContextWindow(currentTokens: number, contextWindow: number, maxOutputTokens: number): boolean;
2975
+ /**
2976
+ * Calculate percentage of context window used
2977
+ */
2978
+ declare function getContextWindowPercentage(currentTokens: number, contextWindow: number): number;
2979
+ /**
2980
+ * Get safe reserve tokens for output (accounting for overhead)
2981
+ */
2982
+ declare function getSafeOutputReserve(maxOutputTokens: number, bufferPercentage?: number): number;
2983
+
2984
+ /**
2985
+ * Message Pruning Utilities
2986
+ *
2987
+ * Implements strategies for removing messages from conversation history
2988
+ * to stay within context window limits.
2989
+ */
2990
+
2991
+ interface PruneResult {
2992
+ removed: number;
2993
+ tokensReclaimed: number;
2994
+ newTotal: number;
2995
+ pruneInfo: {
2996
+ beforeCount: number;
2997
+ afterCount: number;
2998
+ removedMessages: Message[];
2999
+ };
3000
+ }
3001
+ /**
3002
+ * Remove oldest messages to reclaim tokens
3003
+ *
3004
+ * Strategy: Remove oldest user/assistant pairs first, keeping system messages always.
3005
+ * When an assistant message with tool_calls is removed, its paired tool result messages
3006
+ * are also removed to prevent orphaned tool results that providers reject.
3007
+ */
3008
+ declare function pruneMessages(messages: Message[], targetTokens: number, retainSystemMessages?: boolean): PruneResult;
3009
+ /**
3010
+ * Truncate messages that exceed context window
3011
+ */
3012
+ declare function truncateMessage(message: Message, maxTokens: number): Message;
3013
+ /**
3014
+ * Group messages by type for analysis
3015
+ */
3016
+ declare function groupMessagesByRole(messages: Message[]): Record<string, Message[]>;
3017
+ /**
3018
+ * Get summary stats about messages
3019
+ */
3020
+ declare function getMessageStats(messages: Message[]): {
3021
+ totalMessages: number;
3022
+ totalTokens: number;
3023
+ byRole: Record<string, number>;
3024
+ largestMessageTokens: number;
3025
+ };
3026
+
3027
+ /**
3028
+ * Options for summarizing messages
3029
+ */
3030
+ interface SummarizationOptions {
3031
+ /** Model to use for summarization (e.g., 'gpt-4-turbo') */
3032
+ model: string;
3033
+ /** Maximum tokens for summary (default: 500) */
3034
+ maxSummaryTokens?: number;
3035
+ /** Whether to preserve exact message boundaries or create coherent summary (default: false) */
3036
+ preserveExactMessages?: boolean;
3037
+ /** Custom summarization prompt template */
3038
+ summaryPrompt?: string;
3039
+ /** Custom format for summary marker in message history */
3040
+ summaryMarkerFormat?: string;
3041
+ }
3042
+ /**
3043
+ * Result of a summarization operation
3044
+ */
3045
+ interface SummarizationResult {
3046
+ /** Summary content */
3047
+ summary: string;
3048
+ /** Number of messages that were summarized */
3049
+ messageCount: number;
3050
+ /** Approximate tokens in original messages */
3051
+ originalTokens: number;
3052
+ /** Approximate tokens in summary */
3053
+ summaryTokens: number;
3054
+ /** Number of tokens saved */
3055
+ tokensSaved: number;
3056
+ /** Timestamp of summarization */
3057
+ timestamp: Date;
3058
+ }
3059
+ /**
3060
+ * Generates a default summarization prompt for the given messages
3061
+ */
3062
+ declare function generateSummarizationPrompt(messages: Message[], userPrompt?: string): string;
3063
+ /**
3064
+ * Creates a system message containing the conversation summary
3065
+ */
3066
+ declare function createSummarySystemMessage(summary: string, originalMessageCount: number): Message;
3067
+ /**
3068
+ * Extracts key information from messages for summarization
3069
+ */
3070
+ declare function extractConversationKeypoints(messages: Message[]): {
3071
+ topics: string[];
3072
+ decisions: string[];
3073
+ userGoals: string[];
3074
+ context: string;
3075
+ };
3076
+ /**
3077
+ * Estimates tokens in a summary (rough estimation)
3078
+ */
3079
+ declare function estimateSummaryTokens(summaryText: string): number;
3080
+ /**
3081
+ * Validates that a summarization result is sensible
3082
+ */
3083
+ declare function validateSummarizationResult(result: SummarizationResult): {
3084
+ valid: boolean;
3085
+ issues: string[];
3086
+ };
3087
+ /**
3088
+ * Prepares messages for summarization by the LLM
3089
+ * Returns the messages that should be sent to the summarizer model
3090
+ */
3091
+ declare function prepareSummarizationRequest(messagesToSummarize: Message[], options: SummarizationOptions): Message[];
3092
+ /**
3093
+ * Parses the summarization response from the LLM
3094
+ */
3095
+ declare function parseSummarizationResponse(response: string, originalMessages: Message[], originalTokenCount: number): SummarizationResult;
3096
+ /**
3097
+ * Builds a new message array with summarized history
3098
+ */
3099
+ declare function buildSummarizedHistory(systemMessages: Message[], summarizedContent: SummarizationResult, recentMessages: Message[]): Message[];
3100
+ /**
3101
+ * Creates a detailed summarization report
3102
+ */
3103
+ declare function createSummarizationReport(result: SummarizationResult, beforeMessageCount: number, afterMessageCount: number): string;
3104
+ /**
3105
+ * Merges multiple summarization results into one
3106
+ */
3107
+ declare function mergeSummarizationResults(results: SummarizationResult[]): SummarizationResult;
3108
+
3109
+ /**
3110
+ * Manages per-conversation context window state
3111
+ * Tracks token usage, pruning operations, and summarization events
3112
+ */
3113
+ declare class ContextWindowStateManager {
3114
+ private states;
3115
+ private config;
3116
+ private maxTokens;
3117
+ constructor(config: ContextWindowConfig);
3118
+ /**
3119
+ * Gets or creates state for a conversation
3120
+ */
3121
+ getOrCreateState(conversationId: string): ContextWindowState;
3122
+ /**
3123
+ * Updates token count for a conversation
3124
+ */
3125
+ updateTokenCount(conversationId: string, tokens: number): ContextWindowState;
3126
+ /**
3127
+ * Increments pruning operation counter
3128
+ */
3129
+ recordPruneOperation(conversationId: string, tokensRecovered: number): ContextWindowState;
3130
+ /**
3131
+ * Increments warning count
3132
+ */
3133
+ recordWarning(conversationId: string): ContextWindowState;
3134
+ /**
3135
+ * Increments summarization count
3136
+ */
3137
+ recordSummarization(conversationId: string, tokensSaved: number): ContextWindowState;
3138
+ /**
3139
+ * Gets the current state for a conversation
3140
+ */
3141
+ getState(conversationId: string): ContextWindowState | undefined;
3142
+ /**
3143
+ * Gets all tracked conversation states
3144
+ */
3145
+ getAllStates(): ContextWindowState[];
3146
+ /**
3147
+ * Deletes state for a conversation
3148
+ */
3149
+ deleteState(conversationId: string): boolean;
3150
+ /**
3151
+ * Clears all states
3152
+ */
3153
+ clearAllStates(): void;
3154
+ /**
3155
+ * Gets statistics for a conversation
3156
+ */
3157
+ getStatistics(conversationId: string): {
3158
+ conversationId: string;
3159
+ currentTokens: number;
3160
+ pruneCount: number;
3161
+ summarizationCount: number;
3162
+ warningsSent: number;
3163
+ lastActivity: Date | undefined;
3164
+ contextWindowPercentage: number;
3165
+ } | null;
3166
+ /**
3167
+ * Gets conversations exceeding a threshold
3168
+ */
3169
+ getExceedingThreshold(threshold?: number): ContextWindowState[];
3170
+ /**
3171
+ * Gets conversations at risk (approaching threshold)
3172
+ */
3173
+ getAtRiskConversations(riskPercentage?: number): ContextWindowState[];
3174
+ /**
3175
+ * Generates a report of all conversation states
3176
+ */
3177
+ generateReport(): string;
3178
+ /**
3179
+ * Exports state as JSON for persistence
3180
+ */
3181
+ export(): Record<string, ContextWindowState>;
3182
+ /**
3183
+ * Imports state from JSON
3184
+ */
3185
+ import(data: Record<string, ContextWindowState>): void;
3186
+ /**
3187
+ * Prunes old conversations (no activity in specified time)
3188
+ */
3189
+ pruneInactiveConversations(inactivityMinutes?: number): string[];
3190
+ /**
3191
+ * Gets memory usage of the state manager
3192
+ */
3193
+ getMemoryUsage(): {
3194
+ conversationCount: number;
3195
+ approximateByteSize: number;
3196
+ };
3197
+ /**
3198
+ * Validates state integrity
3199
+ */
3200
+ validateIntegrity(): {
3201
+ isValid: boolean;
3202
+ issues: string[];
3203
+ };
3204
+ }
3205
+ /**
3206
+ * Creates a new ContextWindowStateManager with the given config
3207
+ */
3208
+ declare function createContextWindowStateManager(config: ContextWindowConfig): ContextWindowStateManager;
3209
+
2339
3210
  interface JsonRpcRequest {
2340
3211
  jsonrpc: '2.0';
2341
3212
  id: number | string;
@@ -2367,4 +3238,4 @@ interface McpServerCapabilities {
2367
3238
  prompts?: Record<string, any>;
2368
3239
  }
2369
3240
 
2370
- export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_STEP_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, AnthropicAdapter, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, CHAT_MODE, CHAT_WORKFLOW, CODING_PLANNING_PROMPT, CODING_STEP_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, ConnectionError, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, type IntelligentToolDetectionConfig, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, OpenAIAdapter, PageError, type Plan, type PlanStep, Planner, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, RateLimitError, type Role, type RuntimeConfigStatus, SDKError, type SearchHistoryEntry, type SearchOptions, type SearchResult, type SlmModelEntry, StepExecutor, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolsConfig, type Usage, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingFindSymbolTool, codingGetImportsTool, codingGetSymbolsTool, codingToolsProject, createMcpToolProject, createMode, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, fetchUrlAsBase64, fsAppendFileTool, fsCopyTool, fsCreateDirTool, fsDeleteFileTool, fsExistsTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateToolCategoriesPrompt, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isDataUri, isRegisteredSlm, isToolSearchTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, readFileAsBase64, reloadToolpackConfig, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject };
3241
+ export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_STEP_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, type AddBypassRuleOptions, AnthropicAdapter, type AssembledPrompt, type AssemblerOptions, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, type BypassRuleType, CHAT_MODE, CHAT_WORKFLOW, CODING_MODE, CODING_PLANNING_PROMPT, CODING_STEP_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, type ConfirmationDecision, type ConfirmationLevel$1 as ConfirmationLevel, ConnectionError, type ContextPrunedEvent, type ContextWindowConfig, ContextWindowConfigError, ContextWindowExceededError, type ContextWindowExceededEvent, type ContextWindowState, ContextWindowStateManager, type ContextWindowStrategy, type ContextWindowWarningEvent, ConversationNotFoundError, type ConversationScope, type ConversationSearchOptions, type ConversationStore, type ConversationSummarizedEvent, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type GetOptions, type HitlConfig, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, InMemoryConversationStore, type InMemoryConversationStoreConfig, InsufficientContextError, type IntelligentToolDetectionConfig, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, type OnToolConfirmCallback, OpenAIAdapter, OpenRouterAdapter, type OpenRouterOptions, PageError, type Participant, type Plan, type PlanStep, Planner, type PromptMessage, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, type PruneResult, RateLimitError, type RequestToolDefinition, type Role, type RuntimeConfigStatus, SDKError, SQLiteConversationStore, type SQLiteConversationStoreConfig, type SearchHistoryEntry, type SearchOptions, type SearchResult, type SlmModelEntry, StepExecutor, type StoredMessage, SummarizationError, type SummarizationOptions, type SummarizationResult, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolConfirmation, type ToolConfirmationRequestedEvent, type ToolConfirmationResolvedEvent, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolsConfig, type Usage, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, addBypassRule, buildSummarizedHistory, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingFindSymbolTool, codingGetImportsTool, codingGetSymbolsTool, codingToolsProject, countTokens, createContextWindowStateManager, createMcpToolProject, createMode, createSummarizationReport, createSummarySystemMessage, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, estimateSummaryTokens, estimateTokenCount, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, extractConversationKeypoints, fetchUrlAsBase64, fsAppendFileTool, fsCopyTool, fsCreateDirTool, fsDeleteFileTool, fsExistsTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateSummarizationPrompt, generateToolCategoriesPrompt, getContextWindowPercentage, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMessageStats, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getSafeOutputReserve, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, githubContentsGetTextTool, githubGraphqlExecuteTool, githubPrDiffGetTool, githubPrFilesListTool, githubPrReviewCommentsReplyTool, githubPrReviewThreadsListTool, githubPrReviewThreadsResolveTool, githubPrReviewsSubmitTool, githubToolsProject, groupMessagesByRole, handleContextWindowError, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isContextWindowError, isDataUri, isRegisteredSlm, isToolSearchTool, k8sApplyManifestTool, k8sDeleteResourceTool, k8sDescribeTool, k8sGetConfigMapTool, k8sGetLogsTool, k8sGetNamespacesTool, k8sListDeploymentsTool, k8sListPodsTool, k8sListServicesTool, k8sSwitchContextTool, k8sToolsProject, k8sWaitForDeploymentTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, mergeSummarizationResults, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, parseSummarizationResponse, prepareSummarizationRequest, pruneMessages, readFileAsBase64, reloadToolpackConfig, removeBypassRule, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, truncateMessage, validateSummarizationResult, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject, wouldExceedContextWindow };