toolpack-sdk 1.4.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -104,13 +104,6 @@ interface ToolCategory {
104
104
  description: string;
105
105
  tools: string[];
106
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
107
  /**
115
108
  * Tool Search Configuration (Anthropic-style on-demand tool discovery)
116
109
  */
@@ -127,10 +120,6 @@ interface ToolsConfig {
127
120
  maxToolRounds: number;
128
121
  toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
129
122
  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
123
  enabledTools: string[];
135
124
  enabledToolCategories: string[];
136
125
  toolSearch?: ToolSearchConfig;
@@ -221,6 +210,16 @@ interface ToolCallRequest {
221
210
  type: 'function';
222
211
  function: ToolCallFunction;
223
212
  }
213
+ interface RequestToolDefinition {
214
+ name: string;
215
+ displayName: string;
216
+ description: string;
217
+ parameters: Record<string, any>;
218
+ category: string;
219
+ execute: (args: Record<string, any>) => Promise<any>;
220
+ cacheable?: boolean;
221
+ confirmation?: ToolConfirmation;
222
+ }
224
223
  interface ToolCallResult {
225
224
  id: string;
226
225
  name: string;
@@ -237,11 +236,19 @@ interface CompletionRequest {
237
236
  response_format?: 'text' | 'json_object';
238
237
  stream?: boolean;
239
238
  tools?: ToolCallRequest[];
239
+ requestTools?: RequestToolDefinition[];
240
240
  tool_choice?: 'auto' | 'none' | 'required';
241
241
  /** AbortSignal to cancel the request */
242
242
  signal?: AbortSignal;
243
243
  /** Multimodal media handling options */
244
244
  mediaOptions?: MediaOptions;
245
+ /**
246
+ * Per-request hard cap on tool-call rounds.
247
+ * When set, overrides ToolsConfig.maxToolRounds and bypasses the query
248
+ * classifier adjustment for this specific request.
249
+ * Useful for agents that should only ever make one tool call (e.g. routers).
250
+ */
251
+ maxToolRounds?: number;
245
252
  }
246
253
  interface Usage {
247
254
  prompt_tokens: number;
@@ -391,6 +398,59 @@ interface ProviderInfo {
391
398
  /** Available models from this provider */
392
399
  models: ProviderModelInfo[];
393
400
  }
401
+ /**
402
+ * Strategy for handling context window limit scenarios
403
+ */
404
+ type ContextWindowStrategy = 'prune' | 'summarize' | 'fail';
405
+ /**
406
+ * Configuration for automatic context window management
407
+ */
408
+ interface ContextWindowConfig {
409
+ /** Master switch for context window management. Default: true */
410
+ enabled?: boolean;
411
+ /** Strategy when context limit is approached or exceeded. Default: 'prune' */
412
+ strategy?: ContextWindowStrategy;
413
+ /**
414
+ * Percentage of context window to trigger pruning/summarization.
415
+ * When current tokens exceed this percentage, cleanup is initiated.
416
+ * Default: 85
417
+ */
418
+ pruneThreshold?: number;
419
+ /**
420
+ * Optional maximum message history length as fallback limit.
421
+ * Useful for caps independent of token counting.
422
+ * When set, removes messages when count exceeds this.
423
+ */
424
+ maxMessageHistoryLength?: number;
425
+ /**
426
+ * Model to use for conversation summarization (if strategy is 'summarize').
427
+ * If omitted, uses the same model as the current request.
428
+ * Example: 'gpt-4.1-mini' for faster/cheaper summaries
429
+ */
430
+ summarizerModel?: string;
431
+ /**
432
+ * Whether to always retain system messages (never prune them).
433
+ * Default: true
434
+ */
435
+ retainSystemMessages?: boolean;
436
+ /**
437
+ * Percentage buffer above actual maxOutputTokens to reserve for safety.
438
+ * Default: 1.15 (15% buffer)
439
+ */
440
+ outputTokenBuffer?: number;
441
+ }
442
+ /**
443
+ * Tracks context window state per conversation for monitoring
444
+ */
445
+ interface ContextWindowState {
446
+ conversationId?: string;
447
+ estimatedTokens: number;
448
+ lastUpdated: number;
449
+ pruneCount: number;
450
+ lastPrunedAt?: number;
451
+ warningsSent: number;
452
+ summarizationCount: number;
453
+ }
394
454
 
395
455
  declare class SDKError extends Error {
396
456
  code: string;
@@ -422,6 +482,109 @@ declare class TimeoutError extends SDKError {
422
482
  phase?: string | undefined;
423
483
  constructor(message: string, phase?: string | undefined, cause?: any);
424
484
  }
485
+ /**
486
+ * Thrown when a conversation exceeds the configured context window limit
487
+ * and cannot be recovered through pruning or summarization
488
+ */
489
+ declare class ContextWindowExceededError extends SDKError {
490
+ conversationId: string;
491
+ currentTokens: number;
492
+ contextWindowLimit: number;
493
+ strategy: 'prune' | 'summarize' | 'fail';
494
+ constructor(message: string, conversationId: string, currentTokens: number, contextWindowLimit: number, strategy: 'prune' | 'summarize' | 'fail', cause?: any);
495
+ /**
496
+ * Get the number of tokens over the limit
497
+ */
498
+ getOverageTokens(): number;
499
+ /**
500
+ * Get the percentage of the context window being used
501
+ */
502
+ getUsagePercentage(): number;
503
+ /**
504
+ * Get a detailed error report
505
+ */
506
+ getDetailedReport(): string;
507
+ }
508
+ /**
509
+ * Thrown when there is insufficient context remaining to process a request
510
+ * after pruning or summarization, even though tokens are within limits
511
+ */
512
+ declare class InsufficientContextError extends SDKError {
513
+ conversationId: string;
514
+ requiredTokens: number;
515
+ availableTokens: number;
516
+ minimumRequiredTokens: number;
517
+ constructor(message: string, conversationId: string, requiredTokens: number, availableTokens: number, minimumRequiredTokens: number, cause?: any);
518
+ /**
519
+ * Get the token deficit
520
+ */
521
+ getDeficit(): number;
522
+ /**
523
+ * Whether the deficit could be recovered by adjusting the strategy
524
+ */
525
+ isRecoverable(): boolean;
526
+ /**
527
+ * Get a detailed error report
528
+ */
529
+ getDetailedReport(): string;
530
+ }
531
+ /**
532
+ * Thrown when summarization fails or produces inadequate results
533
+ */
534
+ declare class SummarizationError extends SDKError {
535
+ conversationId: string;
536
+ messageCount: number;
537
+ failureReason: 'provider_error' | 'invalid_response' | 'insufficient_tokens' | 'invalid_quality' | 'unknown';
538
+ summaryAttempt?: string | undefined;
539
+ constructor(message: string, conversationId: string, messageCount: number, failureReason: 'provider_error' | 'invalid_response' | 'insufficient_tokens' | 'invalid_quality' | 'unknown', summaryAttempt?: string | undefined, cause?: any);
540
+ /**
541
+ * Whether the error is retryable
542
+ */
543
+ isRetryable(): boolean;
544
+ /**
545
+ * Get suggested recovery action
546
+ */
547
+ getSuggestedRecovery(): string;
548
+ /**
549
+ * Get a detailed error report
550
+ */
551
+ getDetailedReport(): string;
552
+ }
553
+ /**
554
+ * Thrown when context window configuration is invalid
555
+ */
556
+ declare class ContextWindowConfigError extends SDKError {
557
+ configField: string;
558
+ providedValue: any;
559
+ constraint: string;
560
+ constructor(message: string, configField: string, providedValue: any, constraint: string, cause?: any);
561
+ /**
562
+ * Get a detailed error report
563
+ */
564
+ getDetailedReport(): string;
565
+ }
566
+ /**
567
+ * Thrown when a state operation is performed on a non-existent conversation
568
+ */
569
+ declare class ConversationNotFoundError extends SDKError {
570
+ conversationId: string;
571
+ constructor(message: string, conversationId: string, cause?: any);
572
+ }
573
+ /**
574
+ * Utility function to check if an error is context window related
575
+ */
576
+ declare function isContextWindowError(error: any): error is SDKError & {
577
+ code: string;
578
+ };
579
+ /**
580
+ * Utility function to handle context window errors
581
+ */
582
+ declare function handleContextWindowError(error: SDKError, _conversationId?: string): {
583
+ shouldRetry: boolean;
584
+ shouldFallback: boolean;
585
+ action: 'prune' | 'summarize' | 'fail' | 'none';
586
+ message: string;
587
+ };
425
588
 
426
589
  declare abstract class ProviderAdapter {
427
590
  /**
@@ -473,6 +636,13 @@ declare abstract class ProviderAdapter {
473
636
  * @throws InvalidRequestError if not supported by this provider.
474
637
  */
475
638
  deleteFile(_fileId: string): Promise<void>;
639
+ /**
640
+ * Estimates the number of tokens for the given messages and model.
641
+ * @param _messages The messages to count.
642
+ * @param _model The model to count for.
643
+ * @returns The number of tokens or null if not supported.
644
+ */
645
+ countTokens(_messages: Message[], _model: string): Promise<number | null>;
476
646
  }
477
647
 
478
648
  /**
@@ -650,24 +820,6 @@ interface WorkflowConfig {
650
820
  /** Maximum number of steps allowed in a plan. Default: 20 */
651
821
  maxSteps?: number;
652
822
  };
653
- /**
654
- * Step-based execution configuration.
655
- * If enabled, tasks are broken into steps and executed sequentially.
656
- */
657
- steps?: {
658
- /** Enable step-based execution. Default: false */
659
- enabled: boolean;
660
- /** Retry failed steps. Default: true */
661
- retryOnFailure?: boolean;
662
- /** Maximum retry attempts per step. Default: 3 */
663
- maxRetries?: number;
664
- /** Allow adding/modifying steps during execution. Default: true */
665
- allowDynamicSteps?: boolean;
666
- /** Maximum total steps (including dynamic). Default: 50 */
667
- maxTotalSteps?: number;
668
- /** Custom step execution prompt. Default: uses built-in STEP_EXECUTION_PROMPT */
669
- stepPrompt?: string;
670
- };
671
823
  /**
672
824
  * Progress reporting configuration.
673
825
  */
@@ -677,13 +829,6 @@ interface WorkflowConfig {
677
829
  /** Report estimated completion percentage. Default: true */
678
830
  reportPercentage?: boolean;
679
831
  };
680
- /**
681
- * Failure handling configuration.
682
- */
683
- onFailure?: {
684
- /** Strategy when a step fails after all retries. Default: 'abort' */
685
- strategy: 'abort' | 'skip' | 'ask_user';
686
- };
687
832
  /**
688
833
  * Query complexity routing configuration.
689
834
  * Routes simple queries to faster execution paths based on query classification.
@@ -698,7 +843,7 @@ interface WorkflowConfig {
698
843
  };
699
844
  }
700
845
  /**
701
- * Default workflow config (direct execution, no planning/steps).
846
+ * Default workflow config (direct execution, no planning).
702
847
  */
703
848
  declare const DEFAULT_WORKFLOW_CONFIG: WorkflowConfig;
704
849
  interface WorkflowEvents {
@@ -708,23 +853,50 @@ interface WorkflowEvents {
708
853
  'workflow:plan_decision': (plan: Plan, approved: boolean) => void;
709
854
  /** Emitted when plan execution starts */
710
855
  'workflow:started': (plan: Plan) => void;
711
- /** Emitted when a step starts */
712
- 'workflow:step_start': (step: PlanStep, plan: Plan) => void;
713
- /** Emitted when a step completes successfully */
714
- 'workflow:step_complete': (step: PlanStep, plan: Plan) => void;
715
- /** Emitted when a step fails */
716
- 'workflow:step_failed': (step: PlanStep, error: Error, plan: Plan) => void;
717
- /** Emitted when a step is retried */
718
- 'workflow:step_retry': (step: PlanStep, attempt: number, plan: Plan) => void;
719
- /** Emitted when a new step is dynamically added */
720
- 'workflow:step_added': (step: PlanStep, plan: Plan) => void;
721
856
  /** Emitted for progress updates */
722
857
  'workflow:progress': (progress: WorkflowProgress) => void;
858
+ /** Emitted when context window usage is high (approaching limit) */
859
+ 'workflow:context_warning': (event: ContextWindowWarningEvent) => void;
860
+ /** Emitted when context window would be exceeded */
861
+ 'workflow:context_exceeded': (event: ContextWindowExceededEvent) => void;
862
+ /** Emitted when messages are pruned to recover context */
863
+ 'workflow:context_pruned': (event: ContextPrunedEvent) => void;
864
+ /** Emitted when conversation is summarized for context recovery */
865
+ 'workflow:conversation_summarized': (event: ConversationSummarizedEvent) => void;
723
866
  /** Emitted when workflow completes */
724
867
  'workflow:completed': (plan: Plan, result: WorkflowResult) => void;
725
868
  /** Emitted when workflow fails */
726
869
  'workflow:failed': (plan: Plan, error: Error) => void;
727
870
  }
871
+ interface ContextWindowWarningEvent {
872
+ currentTokens: number;
873
+ contextWindow: number;
874
+ percentage: number;
875
+ model: string;
876
+ conversationId?: string;
877
+ }
878
+ interface ContextWindowExceededEvent {
879
+ currentTokens: number;
880
+ contextWindow: number;
881
+ maxOutputTokens: number;
882
+ model: string;
883
+ strategy: 'prune' | 'summarize' | 'fail';
884
+ conversationId?: string;
885
+ }
886
+ interface ContextPrunedEvent {
887
+ removed: number;
888
+ tokensReclaimed: number;
889
+ newTotal: number;
890
+ conversationId?: string;
891
+ beforeCount: number;
892
+ afterCount: number;
893
+ }
894
+ interface ConversationSummarizedEvent {
895
+ summarized: number;
896
+ summaryTokens: number;
897
+ tokensSaved: number;
898
+ conversationId?: string;
899
+ }
728
900
  interface WorkflowProgress {
729
901
  planId: string;
730
902
  currentStep: number;
@@ -879,6 +1051,8 @@ interface ToolpackConfig {
879
1051
  };
880
1052
  /** Human-in-the-loop configuration for tool confirmation */
881
1053
  hitl?: HitlConfig;
1054
+ /** Context window management configuration for automatic conversation pruning/summarization */
1055
+ contextWindow?: ContextWindowConfig;
882
1056
  }
883
1057
  declare function getToolpackConfig(configPath?: string): ToolpackConfig;
884
1058
  declare function reloadToolpackConfig(): void;
@@ -964,6 +1138,8 @@ interface AIClientConfig {
964
1138
  onToolConfirm?: OnToolConfirmCallback;
965
1139
  /** Optional conversation ID for tracking context */
966
1140
  conversationId?: string;
1141
+ /** Context window management configuration */
1142
+ contextWindowConfig?: ContextWindowConfig;
967
1143
  }
968
1144
  declare class AIClient extends EventEmitter {
969
1145
  private providers;
@@ -982,7 +1158,17 @@ declare class AIClient extends EventEmitter {
982
1158
  private onToolConfirm?;
983
1159
  private currentRound;
984
1160
  private conversationId?;
1161
+ private contextWindowConfig?;
1162
+ private contextWindowStateManager?;
1163
+ private providerModelCache;
985
1164
  constructor(config: AIClientConfig);
1165
+ private getConversationId;
1166
+ private getModelInfo;
1167
+ private countRequestTokens;
1168
+ private pruneConversation;
1169
+ private pruneToMaxMessageHistory;
1170
+ private summarizeConversation;
1171
+ private enforceContextWindow;
986
1172
  /**
987
1173
  * Check if a tool should bypass confirmation based on HITL config.
988
1174
  * Returns true if the tool should execute without confirmation.
@@ -1072,6 +1258,13 @@ declare class AIClient extends EventEmitter {
1072
1258
  * Applies mode-based tool filtering when an active mode is set.
1073
1259
  */
1074
1260
  private enrichRequestWithTools;
1261
+ private buildRequestToolMap;
1262
+ private requestToolToSchema;
1263
+ private mergeSchemas;
1264
+ private schemasToToolCallRequests;
1265
+ private mergeToolCallRequests;
1266
+ private injectRequestToolGuidance;
1267
+ private stripRequestTools;
1075
1268
  /**
1076
1269
  * Filter tool schemas based on mode permissions.
1077
1270
  * blockedTools/blockedToolCategories always take precedence.
@@ -1114,6 +1307,12 @@ declare class AIClient extends EventEmitter {
1114
1307
  */
1115
1308
  private executeToolSearch;
1116
1309
  private wrapError;
1310
+ /**
1311
+ * Truncate a tool result to fit within the remaining round budget.
1312
+ * Instead of silently dropping the output, include as much content as possible
1313
+ * and append an actionable hint so the LLM can retry with a narrower query.
1314
+ */
1315
+ private budgetTruncate;
1117
1316
  }
1118
1317
 
1119
1318
  declare class AnthropicAdapter extends ProviderAdapter {
@@ -1152,6 +1351,43 @@ declare class AnthropicAdapter extends ProviderAdapter {
1152
1351
  private handleError;
1153
1352
  }
1154
1353
 
1354
+ interface VertexAIConfig {
1355
+ /** GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT or VERTEX_AI_PROJECT env vars. */
1356
+ projectId?: string;
1357
+ /** GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION or VERTEX_AI_LOCATION env vars. */
1358
+ location?: string;
1359
+ /**
1360
+ * Optional Google Auth options.
1361
+ * When omitted, Application Default Credentials (ADC) are used automatically.
1362
+ * Set GOOGLE_APPLICATION_CREDENTIALS env var to point to a service account JSON file.
1363
+ */
1364
+ googleAuthOptions?: {
1365
+ /** Path to a service account key JSON file. */
1366
+ keyFilename?: string;
1367
+ /** Inline service account credentials object. */
1368
+ credentials?: Record<string, unknown>;
1369
+ };
1370
+ }
1371
+ declare class VertexAIAdapter extends ProviderAdapter {
1372
+ private vertexAI;
1373
+ private readonly location;
1374
+ constructor(config?: VertexAIConfig);
1375
+ getDisplayName(): string;
1376
+ getModels(): Promise<ProviderModelInfo[]>;
1377
+ generate(request: CompletionRequest): Promise<CompletionResponse>;
1378
+ stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
1379
+ embed(_request: EmbeddingRequest): Promise<EmbeddingResponse>;
1380
+ private buildModel;
1381
+ private formatHistory;
1382
+ private contentToParts;
1383
+ private parseResponse;
1384
+ private extractSystemInstruction;
1385
+ private sanitizeToolName;
1386
+ private restoreToolName;
1387
+ private sanitizeSchema;
1388
+ private handleError;
1389
+ }
1390
+
1155
1391
  declare class GeminiAdapter extends ProviderAdapter {
1156
1392
  private genAI;
1157
1393
  constructor(apiKey: string);
@@ -1351,6 +1587,24 @@ declare class OpenAIAdapter extends ProviderAdapter {
1351
1587
  private handleError;
1352
1588
  }
1353
1589
 
1590
+ interface OpenRouterOptions {
1591
+ siteUrl?: string;
1592
+ siteName?: string;
1593
+ }
1594
+ declare class OpenRouterAdapter extends OpenAIAdapter {
1595
+ name: string;
1596
+ private readonly _apiKey;
1597
+ constructor(apiKey: string, options?: OpenRouterOptions);
1598
+ getDisplayName(): string;
1599
+ supportsFileUpload(): boolean;
1600
+ generate(request: CompletionRequest): Promise<CompletionResponse>;
1601
+ stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
1602
+ private normalizeRequest;
1603
+ getModels(): Promise<ProviderModelInfo[]>;
1604
+ private mapModel;
1605
+ private deriveCostTier;
1606
+ }
1607
+
1354
1608
  declare function getMimeType(filePath: string): string;
1355
1609
  declare function isDataUri(url: string): boolean;
1356
1610
  declare function parseDataUri(dataUri: string): {
@@ -1793,6 +2047,14 @@ declare const fsReplaceInFileTool: ToolDefinition;
1793
2047
 
1794
2048
  declare const fsTreeTool: ToolDefinition;
1795
2049
 
2050
+ declare const fsGlobTool: ToolDefinition;
2051
+
2052
+ declare const fsDeleteDirTool: ToolDefinition;
2053
+
2054
+ declare const fsBatchReadTool: ToolDefinition;
2055
+
2056
+ declare const fsBatchWriteTool: ToolDefinition;
2057
+
1796
2058
  declare const fsToolsProject: ToolProject;
1797
2059
 
1798
2060
  declare const execRunTool: ToolDefinition;
@@ -1833,6 +2095,26 @@ declare const httpDownloadTool: ToolDefinition;
1833
2095
 
1834
2096
  declare const httpToolsProject: ToolProject;
1835
2097
 
2098
+ declare const githubGraphqlExecuteTool: ToolDefinition;
2099
+
2100
+ declare const githubContentsGetTextTool: ToolDefinition;
2101
+
2102
+ declare const githubPrReviewThreadsListTool: ToolDefinition;
2103
+
2104
+ declare const githubPrReviewThreadsResolveTool: ToolDefinition;
2105
+
2106
+ declare const githubPrReviewCommentsReplyTool: ToolDefinition;
2107
+
2108
+ declare const githubPrDiffGetTool: ToolDefinition;
2109
+
2110
+ declare const githubPrFilesListTool: ToolDefinition;
2111
+
2112
+ declare const githubPrReviewsSubmitTool: ToolDefinition;
2113
+
2114
+ declare const githubIssuesCommentsCreateTool: ToolDefinition;
2115
+
2116
+ declare const githubToolsProject: ToolProject;
2117
+
1836
2118
  declare const webFetchTool: ToolDefinition;
1837
2119
 
1838
2120
  declare const webSearchTool: ToolDefinition;
@@ -1841,6 +2123,16 @@ declare const webScrapeTool: ToolDefinition;
1841
2123
 
1842
2124
  declare const webExtractLinksTool: ToolDefinition;
1843
2125
 
2126
+ declare const webMapTool: ToolDefinition;
2127
+
2128
+ declare const webMetadataTool: ToolDefinition;
2129
+
2130
+ declare const webSitemapTool: ToolDefinition;
2131
+
2132
+ declare const webFeedTool: ToolDefinition;
2133
+
2134
+ declare const webScreenshotTool: ToolDefinition;
2135
+
1844
2136
  declare const webToolsProject: ToolProject;
1845
2137
 
1846
2138
  declare const codingFindSymbolTool: ToolDefinition;
@@ -1849,6 +2141,24 @@ declare const codingGetSymbolsTool: ToolDefinition;
1849
2141
 
1850
2142
  declare const codingGetImportsTool: ToolDefinition;
1851
2143
 
2144
+ declare const codingFindReferencesTool: ToolDefinition;
2145
+
2146
+ declare const codingGoToDefinitionTool: ToolDefinition;
2147
+
2148
+ declare const codingMultiFileEditTool: ToolDefinition;
2149
+
2150
+ declare const codingRefactorRenameTool: ToolDefinition;
2151
+
2152
+ declare const codingGetOutlineTool: ToolDefinition;
2153
+
2154
+ declare const codingGetDiagnosticsTool: ToolDefinition;
2155
+
2156
+ declare const codingGetExportsTool: ToolDefinition;
2157
+
2158
+ declare const codingExtractFunctionTool: ToolDefinition;
2159
+
2160
+ declare const codingGetCallHierarchyTool: ToolDefinition;
2161
+
1852
2162
  declare const codingToolsProject: ToolProject;
1853
2163
 
1854
2164
  declare const gitStatusTool: ToolDefinition;
@@ -1869,6 +2179,8 @@ declare const gitBranchCreateTool: ToolDefinition;
1869
2179
 
1870
2180
  declare const gitCheckoutTool: ToolDefinition;
1871
2181
 
2182
+ declare const gitCloneTool: ToolDefinition;
2183
+
1872
2184
  declare const gitToolsProject: ToolProject;
1873
2185
 
1874
2186
  declare const diffCreateTool: ToolDefinition;
@@ -1917,6 +2229,56 @@ declare const k8sWaitForDeploymentTool: ToolDefinition;
1917
2229
 
1918
2230
  declare const k8sToolsProject: ToolProject;
1919
2231
 
2232
+ declare const slackChatPostMessageTool: ToolDefinition;
2233
+
2234
+ declare const slackChatPostEphemeralTool: ToolDefinition;
2235
+
2236
+ declare const slackReactionsAddTool: ToolDefinition;
2237
+
2238
+ declare const slackConversationsHistoryTool: ToolDefinition;
2239
+
2240
+ declare const slackConversationsRepliesTool: ToolDefinition;
2241
+
2242
+ declare const slackAuthTestTool: ToolDefinition;
2243
+
2244
+ declare const slackToolsProject: ToolProject;
2245
+
2246
+ type SkillSection = 'description' | 'triggers' | 'instructions' | 'examples' | 'metadata' | 'all';
2247
+ type SkillValidationMode = 'fail' | 'warn';
2248
+ interface Skill {
2249
+ name: string;
2250
+ title: string;
2251
+ version?: string;
2252
+ tags: string[];
2253
+ category?: string;
2254
+ filePath: string;
2255
+ description: string;
2256
+ triggers: string[];
2257
+ instructions: string;
2258
+ examples?: string;
2259
+ lastModified: number;
2260
+ }
2261
+ interface SkillInterceptorOptions {
2262
+ dir?: string;
2263
+ maxSkills?: number;
2264
+ minScore?: number;
2265
+ onValidationError?: SkillValidationMode;
2266
+ }
2267
+ interface SkillToolsOptions {
2268
+ /** Skills directory. Default: '.toolpack/skills' */
2269
+ dir?: string;
2270
+ }
2271
+
2272
+ /**
2273
+ * Creates a ToolProject with 4 skill management tools: create, read, update, list.
2274
+ *
2275
+ * @example
2276
+ * ```ts
2277
+ * const skillTools = createSkillTools({ dir: '.toolpack/skills' });
2278
+ * ```
2279
+ */
2280
+ declare function createSkillTools(options?: SkillToolsOptions): ToolProject;
2281
+
1920
2282
  /**
1921
2283
  * Central registry for AI agent modes (built-in + custom).
1922
2284
  * Handles registration, lookup, cycling, and defaults.
@@ -2013,11 +2375,6 @@ declare function createMode(config: {
2013
2375
  enabled: boolean;
2014
2376
  requireApproval?: boolean;
2015
2377
  };
2016
- steps?: {
2017
- enabled: boolean;
2018
- retryOnFailure?: boolean;
2019
- allowDynamicSteps?: boolean;
2020
- };
2021
2378
  progress?: {
2022
2379
  enabled: boolean;
2023
2380
  };
@@ -2041,6 +2398,15 @@ declare const AGENT_MODE: ModeConfig;
2041
2398
  * Ideal for general Q&A, research, and online assistance.
2042
2399
  */
2043
2400
  declare const CHAT_MODE: ModeConfig;
2401
+ /**
2402
+ * Built-in mode: Coding
2403
+ *
2404
+ * Optimized for software development tasks. Uses concise step outputs with
2405
+ * minimal conversational text. Each step produces focused technical output,
2406
+ * and only the final step provides a summary of execution. Ideal for coding,
2407
+ refactoring, debugging, and file manipulation tasks where brevity matters.
2408
+ */
2409
+ declare const CODING_MODE: ModeConfig;
2044
2410
  /**
2045
2411
  * All built-in modes.
2046
2412
  *
@@ -2067,39 +2433,10 @@ declare class Planner {
2067
2433
  private createFallbackPlan;
2068
2434
  }
2069
2435
 
2070
- declare class StepExecutor {
2071
- private client;
2072
- private config?;
2073
- constructor(client: AIClient, config?: WorkflowConfig['steps']);
2074
- /**
2075
- * Executes a single step of the plan using the full tool loop.
2076
- */
2077
- executeStep(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): Promise<NonNullable<PlanStep['result']>>;
2078
- /**
2079
- * Stream a single step execution, yielding chunks as they come.
2080
- */
2081
- streamStep(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): AsyncGenerator<CompletionChunk>;
2082
- /**
2083
- * Build a context-aware request for a specific step, including previous step results
2084
- * as conversation history so the AI knows what work was already done.
2085
- */
2086
- private buildStepRequest;
2087
- /**
2088
- * Optional: Check if the AI wants to add steps dynamically based on what just happened.
2089
- */
2090
- checkForDynamicSteps(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): Promise<PlanStep[]>;
2091
- /**
2092
- * Normalize step description for duplicate detection.
2093
- * Strips common variations to catch semantically similar steps.
2094
- */
2095
- private normalizeStepDescription;
2096
- }
2097
-
2098
2436
  declare class WorkflowExecutor extends EventEmitter {
2099
2437
  private client;
2100
2438
  private config;
2101
2439
  private planner;
2102
- private stepExecutor;
2103
2440
  private queryClassifier;
2104
2441
  private pendingApprovals;
2105
2442
  constructor(client: AIClient, config: WorkflowConfig, queryClassifier?: QueryClassifier);
@@ -2118,6 +2455,10 @@ declare class WorkflowExecutor extends EventEmitter {
2118
2455
  private shouldRouteSimpleQuery;
2119
2456
  /**
2120
2457
  * Execute a request using the configured workflow.
2458
+ *
2459
+ * Modes:
2460
+ * - Direct: no planning — single generate() call
2461
+ * - Plan-direct: planning generates a roadmap, then executes in one generate() call
2121
2462
  */
2122
2463
  execute(request: CompletionRequest, providerName?: string): Promise<WorkflowResult>;
2123
2464
  /**
@@ -2129,39 +2470,31 @@ declare class WorkflowExecutor extends EventEmitter {
2129
2470
  */
2130
2471
  private createPlan;
2131
2472
  /**
2132
- * Execute plan step by step using the StepExecutor.
2133
- */
2134
- private executeStepByStep;
2135
- /**
2136
- * Planning without steps — execute plan as single generate call.
2473
+ * Planning without steps — inject plan as context prefix and execute in one generate() call.
2474
+ * The LLM sees its own roadmap and uses it to guide tool usage and sequencing.
2137
2475
  */
2138
2476
  private executePlanDirect;
2139
2477
  /**
2140
- * Emit a progress event using StepTracker.
2478
+ * Emit a progress event.
2479
+ * @param percentageOverride - Optional fixed percentage (0–100). Use for plan-direct
2480
+ * mode where steps complete atomically and intermediate step-level progress is unavailable.
2141
2481
  */
2142
2482
  private emitProgress;
2143
2483
  /**
2144
2484
  * Compute metrics for the plan.
2145
2485
  */
2146
2486
  private computeMetrics;
2147
- /**
2148
- * Summarize the entire plan execution.
2149
- */
2150
- private summarizePlanResult;
2151
- /**
2152
- * Extract the final output from the plan.
2153
- * For plans with synthesis step: returns last step output.
2154
- * For plans without synthesis: concatenates all step outputs.
2155
- */
2156
- private extractFinalOutput;
2157
- /**
2158
- * Extract the full response metadata from the last completed step.
2159
- */
2160
- private extractFinalResponse;
2161
2487
  /**
2162
2488
  * Create a dummy plan for internal representation when no plan is generated.
2163
2489
  */
2164
2490
  private createDummyPlan;
2491
+ /**
2492
+ * Inject plan context as a system message.
2493
+ * If the request already has a leading system message (e.g., a mode system prompt),
2494
+ * merge the plan context into it to avoid sending multiple system messages to providers
2495
+ * that don't support or handle them inconsistently.
2496
+ */
2497
+ private injectPlanContext;
2165
2498
  /**
2166
2499
  * Execute a request using the configured workflow, yielding chunks as they come.
2167
2500
  * This is the streaming equivalent of execute().
@@ -2172,11 +2505,8 @@ declare class WorkflowExecutor extends EventEmitter {
2172
2505
  */
2173
2506
  private streamDirect;
2174
2507
  /**
2175
- * Stream plan execution step by step.
2176
- */
2177
- private streamStepByStep;
2178
- /**
2179
- * Stream plan execution as a single request (planning without steps).
2508
+ * Stream plan execution as a single request (plan-direct).
2509
+ * Injects the plan as a system prefix so the LLM uses it as its own roadmap.
2180
2510
  */
2181
2511
  private streamPlanDirect;
2182
2512
  /**
@@ -2198,19 +2528,16 @@ declare class WorkflowExecutor extends EventEmitter {
2198
2528
  * Full detailed planning for general autonomous tasks.
2199
2529
  */
2200
2530
  declare const AGENT_PLANNING_PROMPT = "\nYou are a planning assistant. Given a user request, create a detailed step-by-step plan.\n\nRules:\n1. Break the task into clear, actionable steps\n2. Each step should be independently executable WITHOUT requiring additional user input\n3. Order steps by dependencies (what must happen first)\n4. Be specific about what each step will accomplish\n5. Estimate which tools will be needed for each step\n6. If the user's request is ambiguous, make reasonable assumptions and proceed - do NOT create steps that ask for clarification\n7. Steps should produce concrete outputs, not ask questions or wait for user input\n8. ALWAYS include at least one step, even for simple questions. For simple factual questions, create a single step like \"Provide the answer to [question]\"\n9. When a step uses information gathered by a previous step, set \"dependsOn\" to that step's number and phrase the description as \"Using the [data] from step N, [do something]\" instead of gathering it again\n10. For plans with MORE than 2 steps, the final step must synthesize the workflow's results into a concise deliverable, avoiding redundant word-for-word repetition of earlier step outputs. For plans with 1-2 steps, no synthesis step is needed.\n11. The exact result MUST be valid JSON matching this schema:\n{\n \"summary\": \"Brief description of the overall goal\",\n \"steps\": [\n {\n \"number\": 1,\n \"description\": \"What this step does\",\n \"expectedTools\": [\"tool.name\"],\n \"dependsOn\": []\n }\n ]\n}\n";
2201
- /**
2202
- * Agent step execution prompt.
2203
- * Standard execution with detailed instructions.
2204
- */
2205
- declare const AGENT_STEP_PROMPT = "\nYou are executing step {stepNumber} of a plan.\n\nPlan summary: {planSummary}\n\nCurrent step: {stepDescription}\n\nPrevious steps completed:\n{previousStepsResults}\n\nExecute this step now. Use the available tools as needed to accomplish this specific step.\nMake reasonable assumptions if any details are ambiguous - do NOT ask the user for clarification or additional input.\nProduce concrete results based on the information available.\nIf you cannot complete this step, explain why.\n\nIMPORTANT: Your response should be written as if you are directly answering the user.\nDo NOT mention steps, plans, workflow details, or internal process in your response.\nDo NOT say things like \"Step 1 is complete\" or \"proceeding to the next step\".\nJust provide the actual answer or result naturally.\n";
2206
2531
  /**
2207
2532
  * Default workflow configuration.
2208
- * Direct execution with no planning or steps.
2533
+ * Direct execution with no planning.
2209
2534
  */
2210
2535
  declare const DEFAULT_WORKFLOW: WorkflowConfig;
2211
2536
  /**
2212
2537
  * Agent workflow configuration.
2213
- * Full planning and step execution with dynamic steps disabled.
2538
+ * Plan-direct: planning phase generates a structured roadmap, then executes in a single
2539
+ * generate() call with full tool parallelism. Simpler queries bypass planning via
2540
+ * complexity routing.
2214
2541
  */
2215
2542
  declare const AGENT_WORKFLOW: WorkflowConfig;
2216
2543
  /**
@@ -2218,22 +2545,35 @@ declare const AGENT_WORKFLOW: WorkflowConfig;
2218
2545
  * Minimal rules focused on actionable code changes.
2219
2546
  */
2220
2547
  declare const CODING_PLANNING_PROMPT = "\nCreate a step-by-step plan for this coding task.\n\nRules:\n1. Break into actionable steps using tools (read/write files, search code)\n2. Each step executes independently without user input\n3. Order by dependencies\n4. Individual steps: be concise and technical. No conversational filler.\n5. For >2 steps, final step summarizes changes with conversational explanation\n6. Output valid JSON: {\"summary\": \"...\", \"steps\": [{...}]}\n\nJSON Schema:\n{\n \"summary\": \"Brief description of the overall goal\",\n \"steps\": [\n {\n \"number\": 1,\n \"description\": \"What this step does\",\n \"expectedTools\": [\"tool.name\"],\n \"dependsOn\": []\n }\n ]\n}\n";
2221
- /**
2222
- * Concise step execution prompt for coding tasks.
2223
- * No meta-commentary, focused on tool usage.
2224
- */
2225
- declare const CODING_STEP_PROMPT = "\nExecute step {stepNumber}: {stepDescription}\n\nPlan: {planSummary}\n\nPrevious: {previousStepsResults}\n\nUse tools. Be concise. Show code changes clearly.\nNo meta-commentary about steps or workflow.\n";
2226
2548
  /**
2227
2549
  * Coding workflow configuration.
2228
- * Concise prompts optimized for software development tasks.
2550
+ * Plan-direct: planning phase generates a structured roadmap using concise coding-focused prompts,
2551
+ * then executes in a single generate() call with full tool parallelism.
2229
2552
  */
2230
2553
  declare const CODING_WORKFLOW: WorkflowConfig;
2231
2554
  /**
2232
2555
  * Chat workflow configuration.
2233
- * No planning or steps - direct conversational responses.
2556
+ * Direct conversational responses no planning.
2234
2557
  */
2235
2558
  declare const CHAT_WORKFLOW: WorkflowConfig;
2236
2559
 
2560
+ type ToolpackNextFunction = (request?: CompletionRequest) => Promise<CompletionResponse>;
2561
+ /**
2562
+ * An interceptor that wraps each `generate()` call.
2563
+ *
2564
+ * It is a callable with an optional `init()` hook. When `init()` is present,
2565
+ * `Toolpack.init()` calls it once during startup — before any message is
2566
+ * processed — so interceptors can validate config, warm caches, or fail fast
2567
+ * on bad state (e.g. invalid skill files) rather than failing on the first request.
2568
+ *
2569
+ * Plain arrow functions without `init` are fully compatible with this type.
2570
+ */
2571
+ type ToolpackInterceptor = {
2572
+ (request: CompletionRequest, next: ToolpackNextFunction): Promise<CompletionResponse>;
2573
+ /** Optional startup hook called once by `Toolpack.init()`. */
2574
+ init?(): Promise<void>;
2575
+ };
2576
+
2237
2577
  interface ProviderOptions {
2238
2578
  /**
2239
2579
  * API key for the provider.
@@ -2246,6 +2586,19 @@ interface ProviderOptions {
2246
2586
  model?: string;
2247
2587
  /** Base URL override (for OpenAI-compatible endpoints or custom Ollama host) */
2248
2588
  baseUrl?: string;
2589
+ /** OpenRouter only: your site URL for the leaderboard/attribution header */
2590
+ siteUrl?: string;
2591
+ /** OpenRouter only: your site name for the leaderboard/attribution header */
2592
+ siteName?: string;
2593
+ /** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
2594
+ projectId?: string;
2595
+ /** Vertex AI only: GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION / VERTEX_AI_LOCATION env vars. */
2596
+ location?: string;
2597
+ /** Vertex AI only: optional Google Auth options (keyFilename or credentials). When omitted, ADC is used. */
2598
+ googleAuthOptions?: {
2599
+ keyFilename?: string;
2600
+ credentials?: Record<string, unknown>;
2601
+ };
2249
2602
  }
2250
2603
  interface ToolpackInitConfig {
2251
2604
  /** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
@@ -2257,8 +2610,19 @@ interface ToolpackInitConfig {
2257
2610
  apiKey?: string;
2258
2611
  /** Model name for the single provider */
2259
2612
  model?: string;
2613
+ /** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
2614
+ projectId?: string;
2615
+ /** Vertex AI only: GCP region. Defaults to 'us-central1'. */
2616
+ location?: string;
2617
+ /** Vertex AI only: optional Google Auth options. When omitted, ADC is used automatically. */
2618
+ googleAuthOptions?: {
2619
+ keyFilename?: string;
2620
+ credentials?: Record<string, unknown>;
2621
+ };
2260
2622
  /** Load built-in tools (fs, http, etc.)? Default: false */
2261
2623
  tools?: boolean;
2624
+ /** Context window management configuration for automatic conversation pruning/summarization */
2625
+ contextWindow?: ContextWindowConfig;
2262
2626
  /** Custom tool projects to load in addition to built-ins */
2263
2627
  customTools?: ToolProject[];
2264
2628
  /** Multi-provider config (overrides single provider settings) */
@@ -2288,12 +2652,13 @@ interface ToolpackInitConfig {
2288
2652
  mcp?: McpToolsConfig;
2289
2653
  /**
2290
2654
  * Optional Knowledge instance for RAG (Retrieval-Augmented Generation).
2291
- * When provided, the knowledge base will be registered as a tool that the AI can use to search documentation.
2655
+ * When provided, knowledge_search and knowledge_add tools are automatically available
2656
+ * as request-scoped tools that the AI can use to retrieve and store information.
2292
2657
  * Can be null if initialization fails - will be gracefully skipped.
2293
2658
  *
2294
2659
  * Accepts any object with a `toTool()` method (e.g. `Knowledge` from `@toolpack-sdk/knowledge`).
2295
2660
  */
2296
- knowledge?: KnowledgeInstance | null;
2661
+ knowledge?: KnowledgeInstance | KnowledgeInstance[] | null;
2297
2662
  /**
2298
2663
  * Human-in-the-loop configuration for tool confirmation.
2299
2664
  * Default: 'all' when onToolConfirm is provided, 'off' otherwise.
@@ -2310,6 +2675,15 @@ interface ToolpackInitConfig {
2310
2675
  }) => Promise<ConfirmationDecision>;
2311
2676
  /** Optional conversation ID for tracking context across confirmations */
2312
2677
  conversationId?: string;
2678
+ /**
2679
+ * Optional interceptors that wrap each `generate()` call in the direct execution path.
2680
+ * Each interceptor receives the full CompletionRequest and a `next()` function.
2681
+ * Interceptors run in order (first in array runs outermost).
2682
+ *
2683
+ * Note: interceptors apply to `generate()` only, not `stream()`.
2684
+ * The workflow execution path (when a mode has planning enabled) is also unaffected.
2685
+ */
2686
+ interceptors?: ToolpackInterceptor[];
2313
2687
  }
2314
2688
  /**
2315
2689
  * Duck-typed interface for Knowledge instances to avoid circular dependency
@@ -2340,6 +2714,7 @@ interface KnowledgeInstance {
2340
2714
  }>;
2341
2715
  }) => Promise<any>;
2342
2716
  };
2717
+ add(content: string, metadata?: Record<string, unknown>): Promise<string>;
2343
2718
  query(text: string, options?: Record<string, unknown>): Promise<any[]>;
2344
2719
  stop(): Promise<void>;
2345
2720
  }
@@ -2348,9 +2723,13 @@ declare class Toolpack extends EventEmitter {
2348
2723
  private activeProviderName;
2349
2724
  private modeRegistry;
2350
2725
  private workflowExecutor;
2726
+ private knowledgeLayers;
2351
2727
  customProviderNames: Set<string>;
2352
2728
  private mcpToolProject;
2729
+ private _interceptors;
2353
2730
  private constructor();
2731
+ private buildKnowledgeRequestTools;
2732
+ private prepareRequest;
2354
2733
  /**
2355
2734
  * Initialize the Toolpack SDK.
2356
2735
  *
@@ -2363,6 +2742,7 @@ declare class Toolpack extends EventEmitter {
2363
2742
  */
2364
2743
  private static createProvider;
2365
2744
  generate(request: CompletionRequest | string, providerName?: string): Promise<CompletionResponse>;
2745
+ private _buildInterceptorChain;
2366
2746
  stream(request: CompletionRequest, providerName?: string): AsyncGenerator<CompletionChunk>;
2367
2747
  embed(request: EmbeddingRequest, providerName?: string): Promise<EmbeddingResponse>;
2368
2748
  /**
@@ -2433,6 +2813,183 @@ declare class Toolpack extends EventEmitter {
2433
2813
  private forwardWorkflowEvents;
2434
2814
  }
2435
2815
 
2816
+ /**
2817
+ * A participant in a conversation — a human user, another agent, or the
2818
+ * system itself. Stored alongside each `StoredMessage` so the prompt
2819
+ * assembler can reconstruct who said what without extra lookups.
2820
+ */
2821
+ interface Participant {
2822
+ /** Coarse participant kind */
2823
+ kind: 'system' | 'user' | 'agent';
2824
+ /** Stable identifier for this participant (platform-specific id or agent name) */
2825
+ id: string;
2826
+ /** Human-readable display name, resolved lazily. Falls back to `id` if unset. */
2827
+ displayName?: string;
2828
+ /** For `kind: 'agent'` only: an optional role label for rendering */
2829
+ agentType?: string;
2830
+ /** Optional free-form metadata (e.g. platform-specific profile info) */
2831
+ metadata?: Record<string, unknown>;
2832
+ }
2833
+
2834
+ /**
2835
+ * Coarse scope of a stored message.
2836
+ *
2837
+ * - `thread` — a reply inside a specific thread (Slack thread, email thread)
2838
+ * - `channel` — top-level message in a channel / group chat
2839
+ * - `dm` — direct / private message between two participants
2840
+ */
2841
+ type ConversationScope = 'thread' | 'channel' | 'dm';
2842
+ /**
2843
+ * A single stored message in conversation history.
2844
+ *
2845
+ * This is the canonical storage shape. It is deliberately richer than
2846
+ * the LLM's role-based format — the prompt assembler projects it into
2847
+ * whatever the provider expects at render time.
2848
+ */
2849
+ interface StoredMessage {
2850
+ /** Stable, unique message id. Used for dedup at capture time. */
2851
+ id: string;
2852
+ /**
2853
+ * Conversation key. Identifies the thread / DM / channel this message
2854
+ * belongs to.
2855
+ */
2856
+ conversationId: string;
2857
+ /** Who sent this message. */
2858
+ participant: Participant;
2859
+ /** Plain-text content of the message. */
2860
+ content: string;
2861
+ /** ISO 8601 timestamp of when the message was received/sent. */
2862
+ timestamp: string;
2863
+ /** Coarse scope used by the assembler to filter by context type. */
2864
+ scope: ConversationScope;
2865
+ metadata?: {
2866
+ /** Platform channel type, e.g. 'im' for Slack DMs, 'private' for Telegram DMs. */
2867
+ channelType?: string;
2868
+ /** Thread timestamp / id within a channel (e.g. Slack thread_ts). */
2869
+ threadId?: string;
2870
+ /** Platform-specific message id for dedup and linking. */
2871
+ messageId?: string;
2872
+ /** Participant ids explicitly @-mentioned in this message. */
2873
+ mentions?: string[];
2874
+ /** Whether this message is a rolling summary replacing older turns. */
2875
+ isSummary?: boolean;
2876
+ /** Human-readable channel or group name (e.g. '#general', 'Project Kore'). */
2877
+ channelName?: string;
2878
+ /** Platform-specific channel identifier (e.g. Slack 'C12345', Telegram chat id). */
2879
+ channelId?: string;
2880
+ };
2881
+ }
2882
+ /** Options for retrieving messages from the store. */
2883
+ interface GetOptions {
2884
+ /** Filter to a specific scope within the conversation. */
2885
+ scope?: ConversationScope;
2886
+ /** Only return messages at or after this ISO timestamp. */
2887
+ sinceTimestamp?: string;
2888
+ /** Maximum number of messages to return (most recent N). */
2889
+ limit?: number;
2890
+ /**
2891
+ * When set, only return messages whose `participant.id` is in this set.
2892
+ * Used by the assembler's addressed-only mode.
2893
+ */
2894
+ participantIds?: string[];
2895
+ }
2896
+ /** Options for the conversation search tool. */
2897
+ interface ConversationSearchOptions {
2898
+ /** Maximum number of results to return. Default: 10. */
2899
+ limit?: number;
2900
+ /**
2901
+ * Rough token cap for total search results.
2902
+ * The store truncates content to fit within this budget.
2903
+ * Default: 2000.
2904
+ */
2905
+ tokenCap?: number;
2906
+ }
2907
+ /** Options for the prompt assembler (used by toolpack-agents). */
2908
+ interface AssemblerOptions {
2909
+ scope?: ConversationScope;
2910
+ addressedOnlyMode?: boolean;
2911
+ tokenBudget?: number;
2912
+ rollingSummaryThreshold?: number;
2913
+ timeWindowMinutes?: number;
2914
+ maxTurnsToLoad?: number;
2915
+ agentAliases?: string[];
2916
+ }
2917
+ /** A single message entry in the assembled prompt, ready to send to the LLM. */
2918
+ interface PromptMessage {
2919
+ role: 'system' | 'user' | 'assistant';
2920
+ content: string;
2921
+ }
2922
+ /** The output of the prompt assembler. */
2923
+ interface AssembledPrompt {
2924
+ messages: PromptMessage[];
2925
+ estimatedTokens: number;
2926
+ turnsLoaded: number;
2927
+ hasSummary: boolean;
2928
+ }
2929
+ /**
2930
+ * Interface for conversation history storage.
2931
+ *
2932
+ * Implementations must be:
2933
+ * - **Append-only safe**: `append()` must be idempotent on duplicate `id`.
2934
+ * - **Ordered**: `get()` returns messages in ascending timestamp order.
2935
+ * - **Scope-aware**: `get()` must respect `options.scope` when provided.
2936
+ */
2937
+ interface ConversationStore {
2938
+ append(message: StoredMessage): Promise<void>;
2939
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2940
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2941
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2942
+ }
2943
+
2944
+ interface InMemoryConversationStoreConfig {
2945
+ /** Maximum conversations to keep in memory. Default: 500. */
2946
+ maxConversations?: number;
2947
+ /** Maximum messages per conversation. Default: 500. */
2948
+ maxMessagesPerConversation?: number;
2949
+ }
2950
+ /**
2951
+ * In-memory implementation of `ConversationStore`.
2952
+ *
2953
+ * Good for single-process deployments, local development, and tests.
2954
+ * Memory is bounded by `maxConversations × maxMessagesPerConversation`.
2955
+ *
2956
+ * **Not suitable for multi-process or serverless deployments** — each
2957
+ * process has its own isolated store. For those environments, implement
2958
+ * `ConversationStore` against a shared database.
2959
+ */
2960
+ declare class InMemoryConversationStore implements ConversationStore {
2961
+ private readonly lru;
2962
+ private readonly maxMessagesPerConversation;
2963
+ constructor(config?: InMemoryConversationStoreConfig);
2964
+ append(message: StoredMessage): Promise<void>;
2965
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2966
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2967
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2968
+ clearConversation(conversationId: string): void;
2969
+ get conversationCount(): number;
2970
+ }
2971
+
2972
+ interface SQLiteConversationStoreConfig {
2973
+ dbPath?: string;
2974
+ maxMessagesPerConversation?: number;
2975
+ enableWAL?: boolean;
2976
+ useFTS?: boolean;
2977
+ }
2978
+ declare class SQLiteConversationStore implements ConversationStore {
2979
+ private readonly db;
2980
+ private readonly maxMessagesPerConversation;
2981
+ private readonly useFTS;
2982
+ constructor(config?: SQLiteConversationStoreConfig);
2983
+ private initSchema;
2984
+ append(message: StoredMessage): Promise<void>;
2985
+ get(conversationId: string, options?: GetOptions): Promise<StoredMessage[]>;
2986
+ search(conversationId: string, query: string, options?: ConversationSearchOptions): Promise<StoredMessage[]>;
2987
+ deleteMessages(conversationId: string, ids: string[]): Promise<void>;
2988
+ clearConversation(conversationId: string): void;
2989
+ private rowToMessage;
2990
+ close(): void;
2991
+ }
2992
+
2436
2993
  declare const TOOLPACK_DIR_NAME = ".toolpack";
2437
2994
  declare const CONFIG_DIR_NAME = "config";
2438
2995
  declare const CONFIG_FILE_NAME = "toolpack.config.json";
@@ -2494,6 +3051,254 @@ declare function getRuntimeConfigStatus(workspacePath?: string): RuntimeConfigSt
2494
3051
  */
2495
3052
  declare function initializeGlobalConfigIfFirstRun(workspacePath?: string): void;
2496
3053
 
3054
+ /**
3055
+ * Token Counting Utilities
3056
+ *
3057
+ * Provider-specific token counting for accurate context window management.
3058
+ * Supports OpenAI (js-tiktoken), Anthropic, Gemini, and Ollama with fallback estimation.
3059
+ */
3060
+
3061
+ declare function estimateTokenCount(messages: Message[]): number;
3062
+ declare function countTokens(messages: Message[], model: string, provider: string): Promise<number>;
3063
+ /**
3064
+ * Calculate if a request would exceed the context window given available space
3065
+ */
3066
+ declare function wouldExceedContextWindow(currentTokens: number, contextWindow: number, maxOutputTokens: number): boolean;
3067
+ /**
3068
+ * Calculate percentage of context window used
3069
+ */
3070
+ declare function getContextWindowPercentage(currentTokens: number, contextWindow: number): number;
3071
+ /**
3072
+ * Get safe reserve tokens for output (accounting for overhead)
3073
+ */
3074
+ declare function getSafeOutputReserve(maxOutputTokens: number, bufferPercentage?: number): number;
3075
+
3076
+ /**
3077
+ * Message Pruning Utilities
3078
+ *
3079
+ * Implements strategies for removing messages from conversation history
3080
+ * to stay within context window limits.
3081
+ */
3082
+
3083
+ interface PruneResult {
3084
+ removed: number;
3085
+ tokensReclaimed: number;
3086
+ newTotal: number;
3087
+ pruneInfo: {
3088
+ beforeCount: number;
3089
+ afterCount: number;
3090
+ removedMessages: Message[];
3091
+ };
3092
+ }
3093
+ /**
3094
+ * Remove oldest messages to reclaim tokens
3095
+ *
3096
+ * Strategy: Remove oldest user/assistant pairs first, keeping system messages always.
3097
+ * When an assistant message with tool_calls is removed, its paired tool result messages
3098
+ * are also removed to prevent orphaned tool results that providers reject.
3099
+ */
3100
+ declare function pruneMessages(messages: Message[], targetTokens: number, retainSystemMessages?: boolean): PruneResult;
3101
+ /**
3102
+ * Truncate messages that exceed context window
3103
+ */
3104
+ declare function truncateMessage(message: Message, maxTokens: number): Message;
3105
+ /**
3106
+ * Group messages by type for analysis
3107
+ */
3108
+ declare function groupMessagesByRole(messages: Message[]): Record<string, Message[]>;
3109
+ /**
3110
+ * Get summary stats about messages
3111
+ */
3112
+ declare function getMessageStats(messages: Message[]): {
3113
+ totalMessages: number;
3114
+ totalTokens: number;
3115
+ byRole: Record<string, number>;
3116
+ largestMessageTokens: number;
3117
+ };
3118
+
3119
+ /**
3120
+ * Options for summarizing messages
3121
+ */
3122
+ interface SummarizationOptions {
3123
+ /** Model to use for summarization (e.g., 'gpt-4-turbo') */
3124
+ model: string;
3125
+ /** Maximum tokens for summary (default: 500) */
3126
+ maxSummaryTokens?: number;
3127
+ /** Whether to preserve exact message boundaries or create coherent summary (default: false) */
3128
+ preserveExactMessages?: boolean;
3129
+ /** Custom summarization prompt template */
3130
+ summaryPrompt?: string;
3131
+ /** Custom format for summary marker in message history */
3132
+ summaryMarkerFormat?: string;
3133
+ }
3134
+ /**
3135
+ * Result of a summarization operation
3136
+ */
3137
+ interface SummarizationResult {
3138
+ /** Summary content */
3139
+ summary: string;
3140
+ /** Number of messages that were summarized */
3141
+ messageCount: number;
3142
+ /** Approximate tokens in original messages */
3143
+ originalTokens: number;
3144
+ /** Approximate tokens in summary */
3145
+ summaryTokens: number;
3146
+ /** Number of tokens saved */
3147
+ tokensSaved: number;
3148
+ /** Timestamp of summarization */
3149
+ timestamp: Date;
3150
+ }
3151
+ /**
3152
+ * Generates a default summarization prompt for the given messages
3153
+ */
3154
+ declare function generateSummarizationPrompt(messages: Message[], userPrompt?: string): string;
3155
+ /**
3156
+ * Creates a system message containing the conversation summary
3157
+ */
3158
+ declare function createSummarySystemMessage(summary: string, originalMessageCount: number): Message;
3159
+ /**
3160
+ * Extracts key information from messages for summarization
3161
+ */
3162
+ declare function extractConversationKeypoints(messages: Message[]): {
3163
+ topics: string[];
3164
+ decisions: string[];
3165
+ userGoals: string[];
3166
+ context: string;
3167
+ };
3168
+ /**
3169
+ * Estimates tokens in a summary (rough estimation)
3170
+ */
3171
+ declare function estimateSummaryTokens(summaryText: string): number;
3172
+ /**
3173
+ * Validates that a summarization result is sensible
3174
+ */
3175
+ declare function validateSummarizationResult(result: SummarizationResult): {
3176
+ valid: boolean;
3177
+ issues: string[];
3178
+ };
3179
+ /**
3180
+ * Prepares messages for summarization by the LLM
3181
+ * Returns the messages that should be sent to the summarizer model
3182
+ */
3183
+ declare function prepareSummarizationRequest(messagesToSummarize: Message[], options: SummarizationOptions): Message[];
3184
+ /**
3185
+ * Parses the summarization response from the LLM
3186
+ */
3187
+ declare function parseSummarizationResponse(response: string, originalMessages: Message[], originalTokenCount: number): SummarizationResult;
3188
+ /**
3189
+ * Builds a new message array with summarized history
3190
+ */
3191
+ declare function buildSummarizedHistory(systemMessages: Message[], summarizedContent: SummarizationResult, recentMessages: Message[]): Message[];
3192
+ /**
3193
+ * Creates a detailed summarization report
3194
+ */
3195
+ declare function createSummarizationReport(result: SummarizationResult, beforeMessageCount: number, afterMessageCount: number): string;
3196
+ /**
3197
+ * Merges multiple summarization results into one
3198
+ */
3199
+ declare function mergeSummarizationResults(results: SummarizationResult[]): SummarizationResult;
3200
+
3201
+ /**
3202
+ * Manages per-conversation context window state
3203
+ * Tracks token usage, pruning operations, and summarization events
3204
+ */
3205
+ declare class ContextWindowStateManager {
3206
+ private states;
3207
+ private config;
3208
+ private maxTokens;
3209
+ constructor(config: ContextWindowConfig);
3210
+ /**
3211
+ * Gets or creates state for a conversation
3212
+ */
3213
+ getOrCreateState(conversationId: string): ContextWindowState;
3214
+ /**
3215
+ * Updates token count for a conversation
3216
+ */
3217
+ updateTokenCount(conversationId: string, tokens: number): ContextWindowState;
3218
+ /**
3219
+ * Increments pruning operation counter
3220
+ */
3221
+ recordPruneOperation(conversationId: string, tokensRecovered: number): ContextWindowState;
3222
+ /**
3223
+ * Increments warning count
3224
+ */
3225
+ recordWarning(conversationId: string): ContextWindowState;
3226
+ /**
3227
+ * Increments summarization count
3228
+ */
3229
+ recordSummarization(conversationId: string, tokensSaved: number): ContextWindowState;
3230
+ /**
3231
+ * Gets the current state for a conversation
3232
+ */
3233
+ getState(conversationId: string): ContextWindowState | undefined;
3234
+ /**
3235
+ * Gets all tracked conversation states
3236
+ */
3237
+ getAllStates(): ContextWindowState[];
3238
+ /**
3239
+ * Deletes state for a conversation
3240
+ */
3241
+ deleteState(conversationId: string): boolean;
3242
+ /**
3243
+ * Clears all states
3244
+ */
3245
+ clearAllStates(): void;
3246
+ /**
3247
+ * Gets statistics for a conversation
3248
+ */
3249
+ getStatistics(conversationId: string): {
3250
+ conversationId: string;
3251
+ currentTokens: number;
3252
+ pruneCount: number;
3253
+ summarizationCount: number;
3254
+ warningsSent: number;
3255
+ lastActivity: Date | undefined;
3256
+ contextWindowPercentage: number;
3257
+ } | null;
3258
+ /**
3259
+ * Gets conversations exceeding a threshold
3260
+ */
3261
+ getExceedingThreshold(threshold?: number): ContextWindowState[];
3262
+ /**
3263
+ * Gets conversations at risk (approaching threshold)
3264
+ */
3265
+ getAtRiskConversations(riskPercentage?: number): ContextWindowState[];
3266
+ /**
3267
+ * Generates a report of all conversation states
3268
+ */
3269
+ generateReport(): string;
3270
+ /**
3271
+ * Exports state as JSON for persistence
3272
+ */
3273
+ export(): Record<string, ContextWindowState>;
3274
+ /**
3275
+ * Imports state from JSON
3276
+ */
3277
+ import(data: Record<string, ContextWindowState>): void;
3278
+ /**
3279
+ * Prunes old conversations (no activity in specified time)
3280
+ */
3281
+ pruneInactiveConversations(inactivityMinutes?: number): string[];
3282
+ /**
3283
+ * Gets memory usage of the state manager
3284
+ */
3285
+ getMemoryUsage(): {
3286
+ conversationCount: number;
3287
+ approximateByteSize: number;
3288
+ };
3289
+ /**
3290
+ * Validates state integrity
3291
+ */
3292
+ validateIntegrity(): {
3293
+ isValid: boolean;
3294
+ issues: string[];
3295
+ };
3296
+ }
3297
+ /**
3298
+ * Creates a new ContextWindowStateManager with the given config
3299
+ */
3300
+ declare function createContextWindowStateManager(config: ContextWindowConfig): ContextWindowStateManager;
3301
+
2497
3302
  interface JsonRpcRequest {
2498
3303
  jsonrpc: '2.0';
2499
3304
  id: number | string;
@@ -2525,4 +3330,6 @@ interface McpServerCapabilities {
2525
3330
  prompts?: Record<string, any>;
2526
3331
  }
2527
3332
 
2528
- export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_STEP_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, type AddBypassRuleOptions, AnthropicAdapter, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, type BypassRuleType, 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, type ConfirmationDecision, type ConfirmationLevel$1 as ConfirmationLevel, 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 HitlConfig, 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, type OnToolConfirmCallback, 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 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, 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, k8sApplyManifestTool, k8sDeleteResourceTool, k8sDescribeTool, k8sGetConfigMapTool, k8sGetLogsTool, k8sGetNamespacesTool, k8sListDeploymentsTool, k8sListPodsTool, k8sListServicesTool, k8sSwitchContextTool, k8sToolsProject, k8sWaitForDeploymentTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, readFileAsBase64, reloadToolpackConfig, removeBypassRule, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject };
3333
+ declare function createSkillInterceptor(options?: SkillInterceptorOptions): ToolpackInterceptor;
3334
+
3335
+ export { AGENT_MODE, AGENT_PLANNING_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_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, 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 Skill, type SkillInterceptorOptions, type SkillSection, type SkillToolsOptions, type SkillValidationMode, type SlmModelEntry, 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 ToolpackInterceptor, type ToolpackNextFunction, type ToolsConfig, type Usage, VertexAIAdapter, type VertexAIConfig, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, addBypassRule, buildSummarizedHistory, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingExtractFunctionTool, codingFindReferencesTool, codingFindSymbolTool, codingGetCallHierarchyTool, codingGetDiagnosticsTool, codingGetExportsTool, codingGetImportsTool, codingGetOutlineTool, codingGetSymbolsTool, codingGoToDefinitionTool, codingMultiFileEditTool, codingRefactorRenameTool, codingToolsProject, countTokens, createContextWindowStateManager, createMcpToolProject, createMode, createSkillInterceptor, createSkillTools, 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, fsBatchReadTool, fsBatchWriteTool, fsCopyTool, fsCreateDirTool, fsDeleteDirTool, fsDeleteFileTool, fsExistsTool, fsGlobTool, 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, gitCloneTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, githubContentsGetTextTool, githubGraphqlExecuteTool, githubIssuesCommentsCreateTool, 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, slackAuthTestTool, slackChatPostEphemeralTool, slackChatPostMessageTool, slackConversationsHistoryTool, slackConversationsRepliesTool, slackReactionsAddTool, slackToolsProject, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, truncateMessage, validateSummarizationResult, webExtractLinksTool, webFeedTool, webFetchTool, webMapTool, webMetadataTool, webScrapeTool, webScreenshotTool, webSearchTool, webSitemapTool, webToolsProject, wouldExceedContextWindow };