toolpack-sdk 1.4.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.cts CHANGED
@@ -221,6 +221,16 @@ interface ToolCallRequest {
221
221
  type: 'function';
222
222
  function: ToolCallFunction;
223
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
+ }
224
234
  interface ToolCallResult {
225
235
  id: string;
226
236
  name: string;
@@ -237,6 +247,7 @@ interface CompletionRequest {
237
247
  response_format?: 'text' | 'json_object';
238
248
  stream?: boolean;
239
249
  tools?: ToolCallRequest[];
250
+ requestTools?: RequestToolDefinition[];
240
251
  tool_choice?: 'auto' | 'none' | 'required';
241
252
  /** AbortSignal to cancel the request */
242
253
  signal?: AbortSignal;
@@ -391,6 +402,59 @@ interface ProviderInfo {
391
402
  /** Available models from this provider */
392
403
  models: ProviderModelInfo[];
393
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
+ }
394
458
 
395
459
  declare class SDKError extends Error {
396
460
  code: string;
@@ -422,6 +486,109 @@ declare class TimeoutError extends SDKError {
422
486
  phase?: string | undefined;
423
487
  constructor(message: string, phase?: string | undefined, cause?: any);
424
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
+ };
425
592
 
426
593
  declare abstract class ProviderAdapter {
427
594
  /**
@@ -473,6 +640,13 @@ declare abstract class ProviderAdapter {
473
640
  * @throws InvalidRequestError if not supported by this provider.
474
641
  */
475
642
  deleteFile(_fileId: string): Promise<void>;
643
+ /**
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.
648
+ */
649
+ countTokens(_messages: Message[], _model: string): Promise<number | null>;
476
650
  }
477
651
 
478
652
  /**
@@ -720,11 +894,48 @@ interface WorkflowEvents {
720
894
  'workflow:step_added': (step: PlanStep, plan: Plan) => void;
721
895
  /** Emitted for progress updates */
722
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;
723
905
  /** Emitted when workflow completes */
724
906
  'workflow:completed': (plan: Plan, result: WorkflowResult) => void;
725
907
  /** Emitted when workflow fails */
726
908
  'workflow:failed': (plan: Plan, error: Error) => void;
727
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
+ }
728
939
  interface WorkflowProgress {
729
940
  planId: string;
730
941
  currentStep: number;
@@ -879,6 +1090,8 @@ interface ToolpackConfig {
879
1090
  };
880
1091
  /** Human-in-the-loop configuration for tool confirmation */
881
1092
  hitl?: HitlConfig;
1093
+ /** Context window management configuration for automatic conversation pruning/summarization */
1094
+ contextWindow?: ContextWindowConfig;
882
1095
  }
883
1096
  declare function getToolpackConfig(configPath?: string): ToolpackConfig;
884
1097
  declare function reloadToolpackConfig(): void;
@@ -964,6 +1177,8 @@ interface AIClientConfig {
964
1177
  onToolConfirm?: OnToolConfirmCallback;
965
1178
  /** Optional conversation ID for tracking context */
966
1179
  conversationId?: string;
1180
+ /** Context window management configuration */
1181
+ contextWindowConfig?: ContextWindowConfig;
967
1182
  }
968
1183
  declare class AIClient extends EventEmitter {
969
1184
  private providers;
@@ -982,7 +1197,17 @@ declare class AIClient extends EventEmitter {
982
1197
  private onToolConfirm?;
983
1198
  private currentRound;
984
1199
  private conversationId?;
1200
+ private contextWindowConfig?;
1201
+ private contextWindowStateManager?;
1202
+ private providerModelCache;
985
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;
986
1211
  /**
987
1212
  * Check if a tool should bypass confirmation based on HITL config.
988
1213
  * Returns true if the tool should execute without confirmation.
@@ -1072,6 +1297,13 @@ declare class AIClient extends EventEmitter {
1072
1297
  * Applies mode-based tool filtering when an active mode is set.
1073
1298
  */
1074
1299
  private enrichRequestWithTools;
1300
+ private buildRequestToolMap;
1301
+ private requestToolToSchema;
1302
+ private mergeSchemas;
1303
+ private schemasToToolCallRequests;
1304
+ private mergeToolCallRequests;
1305
+ private injectRequestToolGuidance;
1306
+ private stripRequestTools;
1075
1307
  /**
1076
1308
  * Filter tool schemas based on mode permissions.
1077
1309
  * blockedTools/blockedToolCategories always take precedence.
@@ -1351,6 +1583,24 @@ declare class OpenAIAdapter extends ProviderAdapter {
1351
1583
  private handleError;
1352
1584
  }
1353
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
+
1354
1604
  declare function getMimeType(filePath: string): string;
1355
1605
  declare function isDataUri(url: string): boolean;
1356
1606
  declare function parseDataUri(dataUri: string): {
@@ -1833,6 +2083,24 @@ declare const httpDownloadTool: ToolDefinition;
1833
2083
 
1834
2084
  declare const httpToolsProject: ToolProject;
1835
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
+
1836
2104
  declare const webFetchTool: ToolDefinition;
1837
2105
 
1838
2106
  declare const webSearchTool: ToolDefinition;
@@ -2041,6 +2309,15 @@ declare const AGENT_MODE: ModeConfig;
2041
2309
  * Ideal for general Q&A, research, and online assistance.
2042
2310
  */
2043
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;
2044
2321
  /**
2045
2322
  * All built-in modes.
2046
2323
  *
@@ -2246,6 +2523,10 @@ interface ProviderOptions {
2246
2523
  model?: string;
2247
2524
  /** Base URL override (for OpenAI-compatible endpoints or custom Ollama host) */
2248
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;
2249
2530
  }
2250
2531
  interface ToolpackInitConfig {
2251
2532
  /** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
@@ -2259,6 +2540,8 @@ interface ToolpackInitConfig {
2259
2540
  model?: string;
2260
2541
  /** Load built-in tools (fs, http, etc.)? Default: false */
2261
2542
  tools?: boolean;
2543
+ /** Context window management configuration for automatic conversation pruning/summarization */
2544
+ contextWindow?: ContextWindowConfig;
2262
2545
  /** Custom tool projects to load in addition to built-ins */
2263
2546
  customTools?: ToolProject[];
2264
2547
  /** Multi-provider config (overrides single provider settings) */
@@ -2288,12 +2571,13 @@ interface ToolpackInitConfig {
2288
2571
  mcp?: McpToolsConfig;
2289
2572
  /**
2290
2573
  * 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.
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.
2292
2576
  * Can be null if initialization fails - will be gracefully skipped.
2293
2577
  *
2294
2578
  * Accepts any object with a `toTool()` method (e.g. `Knowledge` from `@toolpack-sdk/knowledge`).
2295
2579
  */
2296
- knowledge?: KnowledgeInstance | null;
2580
+ knowledge?: KnowledgeInstance | KnowledgeInstance[] | null;
2297
2581
  /**
2298
2582
  * Human-in-the-loop configuration for tool confirmation.
2299
2583
  * Default: 'all' when onToolConfirm is provided, 'off' otherwise.
@@ -2340,6 +2624,7 @@ interface KnowledgeInstance {
2340
2624
  }>;
2341
2625
  }) => Promise<any>;
2342
2626
  };
2627
+ add(content: string, metadata?: Record<string, unknown>): Promise<string>;
2343
2628
  query(text: string, options?: Record<string, unknown>): Promise<any[]>;
2344
2629
  stop(): Promise<void>;
2345
2630
  }
@@ -2348,9 +2633,12 @@ declare class Toolpack extends EventEmitter {
2348
2633
  private activeProviderName;
2349
2634
  private modeRegistry;
2350
2635
  private workflowExecutor;
2636
+ private knowledgeLayers;
2351
2637
  customProviderNames: Set<string>;
2352
2638
  private mcpToolProject;
2353
2639
  private constructor();
2640
+ private buildKnowledgeRequestTools;
2641
+ private prepareRequest;
2354
2642
  /**
2355
2643
  * Initialize the Toolpack SDK.
2356
2644
  *
@@ -2433,6 +2721,183 @@ declare class Toolpack extends EventEmitter {
2433
2721
  private forwardWorkflowEvents;
2434
2722
  }
2435
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
+
2436
2901
  declare const TOOLPACK_DIR_NAME = ".toolpack";
2437
2902
  declare const CONFIG_DIR_NAME = "config";
2438
2903
  declare const CONFIG_FILE_NAME = "toolpack.config.json";
@@ -2494,6 +2959,254 @@ declare function getRuntimeConfigStatus(workspacePath?: string): RuntimeConfigSt
2494
2959
  */
2495
2960
  declare function initializeGlobalConfigIfFirstRun(workspacePath?: string): void;
2496
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
+
2497
3210
  interface JsonRpcRequest {
2498
3211
  jsonrpc: '2.0';
2499
3212
  id: number | string;
@@ -2525,4 +3238,4 @@ interface McpServerCapabilities {
2525
3238
  prompts?: Record<string, any>;
2526
3239
  }
2527
3240
 
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 };
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 };