toolpack-sdk 1.2.0 → 1.4.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.cts CHANGED
@@ -1,5 +1,149 @@
1
1
  import { EventEmitter } from 'events';
2
2
 
3
+ /**
4
+ * Core type definitions for the Tool Calling System.
5
+ */
6
+ interface ToolParameterProperty {
7
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer';
8
+ description?: string;
9
+ enum?: string[];
10
+ default?: any;
11
+ items?: ToolParameterProperty;
12
+ properties?: Record<string, ToolParameterProperty>;
13
+ additionalProperties?: ToolParameterProperty | boolean;
14
+ required?: string[];
15
+ }
16
+ interface ToolParameters {
17
+ type: 'object';
18
+ properties: Record<string, ToolParameterProperty>;
19
+ required?: string[];
20
+ }
21
+ interface ToolContext {
22
+ /** Absolute path to the workspace/project root */
23
+ workspaceRoot: string;
24
+ /** Tool-specific config from toolpack.config.json additionalConfigurations */
25
+ config: Record<string, any>;
26
+ /** Scoped logger — writes to toolpack-sdk.log */
27
+ log: (message: string) => void;
28
+ }
29
+ type ConfirmationLevel$1 = 'high' | 'medium';
30
+ interface ToolConfirmation {
31
+ level: ConfirmationLevel$1;
32
+ reason: string;
33
+ showArgs?: string[];
34
+ }
35
+ interface ToolDefinition {
36
+ name: string;
37
+ displayName: string;
38
+ description: string;
39
+ parameters: ToolParameters;
40
+ category: string;
41
+ execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<string>;
42
+ /**
43
+ * Whether this tool should be cached after discovery via tool.search.
44
+ * If false, the tool must be re-discovered each time it's needed.
45
+ * Default: true
46
+ */
47
+ cacheable?: boolean;
48
+ /**
49
+ * Human-in-the-loop confirmation configuration.
50
+ * If set, the tool will require user confirmation before execution.
51
+ * Note: Only effective when onToolConfirm callback is provided to AIClient.
52
+ */
53
+ confirmation?: ToolConfirmation;
54
+ }
55
+ /**
56
+ * Schema-only version of ToolDefinition (no execute function).
57
+ * Used for serialization and sending to AI providers.
58
+ */
59
+ interface ToolSchema {
60
+ name: string;
61
+ displayName: string;
62
+ description: string;
63
+ parameters: ToolParameters;
64
+ category: string;
65
+ /**
66
+ * Whether this tool should be cached after discovery via tool.search.
67
+ * If false, the tool must be re-discovered each time it's needed.
68
+ * Default: true
69
+ */
70
+ cacheable?: boolean;
71
+ }
72
+ interface ToolProjectManifest {
73
+ key: string;
74
+ name: string;
75
+ displayName: string;
76
+ version: string;
77
+ description: string;
78
+ author?: string;
79
+ repository?: string;
80
+ tools: string[];
81
+ category: string;
82
+ }
83
+ interface ToolProjectDependencies {
84
+ [packageName: string]: string;
85
+ }
86
+ interface ToolProject {
87
+ manifest: ToolProjectManifest;
88
+ tools: ToolDefinition[];
89
+ dependencies?: ToolProjectDependencies;
90
+ }
91
+ interface ToolCall {
92
+ id: string;
93
+ name: string;
94
+ arguments: Record<string, any>;
95
+ }
96
+ interface ToolResult {
97
+ tool_call_id: string;
98
+ name: string;
99
+ result: string;
100
+ error?: string;
101
+ }
102
+ interface ToolCategory {
103
+ name: string;
104
+ description: string;
105
+ tools: string[];
106
+ }
107
+ /**
108
+ * @deprecated This interface is deprecated and will be removed in a future version.
109
+ */
110
+ interface IntelligentToolDetectionConfig {
111
+ enabled: boolean;
112
+ maxFollowUpMessages: number;
113
+ }
114
+ /**
115
+ * Tool Search Configuration (Anthropic-style on-demand tool discovery)
116
+ */
117
+ interface ToolSearchConfig {
118
+ enabled: boolean;
119
+ alwaysLoadedTools: string[];
120
+ alwaysLoadedCategories: string[];
121
+ searchResultLimit: number;
122
+ cacheDiscoveredTools: boolean;
123
+ }
124
+ interface ToolsConfig {
125
+ enabled: boolean;
126
+ autoExecute: boolean;
127
+ maxToolRounds: number;
128
+ toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
129
+ resultMaxChars?: number;
130
+ /**
131
+ * @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
132
+ */
133
+ intelligentToolDetection?: IntelligentToolDetectionConfig;
134
+ enabledTools: string[];
135
+ enabledToolCategories: string[];
136
+ toolSearch?: ToolSearchConfig;
137
+ additionalConfigurations?: {
138
+ [key: string]: any;
139
+ };
140
+ }
141
+ /**
142
+ * Default Tool Search Configuration
143
+ */
144
+ declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
145
+ declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
146
+
3
147
  type Role = 'system' | 'user' | 'assistant' | 'tool';
4
148
  interface TextPart {
5
149
  type: 'text';
@@ -169,6 +313,33 @@ interface ToolLogEvent {
169
313
  status: 'success' | 'error';
170
314
  timestamp: number;
171
315
  }
316
+
317
+ type ConfirmationDecision = {
318
+ action: 'allow';
319
+ } | {
320
+ action: 'deny';
321
+ reason?: string;
322
+ } | {
323
+ action: 'modify';
324
+ args: Record<string, any>;
325
+ };
326
+ interface ToolConfirmationRequestedEvent {
327
+ tool: ToolDefinition;
328
+ args: Record<string, any>;
329
+ level: ConfirmationLevel$1;
330
+ reason: string;
331
+ }
332
+ interface ToolConfirmationResolvedEvent extends ToolConfirmationRequestedEvent {
333
+ decision: ConfirmationDecision;
334
+ }
335
+ /**
336
+ * Callback type for handling tool confirmation requests.
337
+ * Called before executing tools that have confirmation metadata set.
338
+ */
339
+ type OnToolConfirmCallback = (tool: ToolDefinition, args: Record<string, any>, context: {
340
+ roundNumber: number;
341
+ conversationId?: string;
342
+ }) => Promise<ConfirmationDecision>;
172
343
  /**
173
344
  * Information about a single model available from a provider.
174
345
  */
@@ -304,137 +475,6 @@ declare abstract class ProviderAdapter {
304
475
  deleteFile(_fileId: string): Promise<void>;
305
476
  }
306
477
 
307
- /**
308
- * Core type definitions for the Tool Calling System.
309
- */
310
- interface ToolParameterProperty {
311
- type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer';
312
- description?: string;
313
- enum?: string[];
314
- default?: any;
315
- items?: ToolParameterProperty;
316
- properties?: Record<string, ToolParameterProperty>;
317
- required?: string[];
318
- }
319
- interface ToolParameters {
320
- type: 'object';
321
- properties: Record<string, ToolParameterProperty>;
322
- required?: string[];
323
- }
324
- interface ToolContext {
325
- /** Absolute path to the workspace/project root */
326
- workspaceRoot: string;
327
- /** Tool-specific config from toolpack.config.json additionalConfigurations */
328
- config: Record<string, any>;
329
- /** Scoped logger — writes to toolpack-sdk.log */
330
- log: (message: string) => void;
331
- }
332
- interface ToolDefinition {
333
- name: string;
334
- displayName: string;
335
- description: string;
336
- parameters: ToolParameters;
337
- category: string;
338
- execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<string>;
339
- /**
340
- * Whether this tool should be cached after discovery via tool.search.
341
- * If false, the tool must be re-discovered each time it's needed.
342
- * Default: true
343
- */
344
- cacheable?: boolean;
345
- }
346
- /**
347
- * Schema-only version of ToolDefinition (no execute function).
348
- * Used for serialization and sending to AI providers.
349
- */
350
- interface ToolSchema {
351
- name: string;
352
- displayName: string;
353
- description: string;
354
- parameters: ToolParameters;
355
- category: string;
356
- /**
357
- * Whether this tool should be cached after discovery via tool.search.
358
- * If false, the tool must be re-discovered each time it's needed.
359
- * Default: true
360
- */
361
- cacheable?: boolean;
362
- }
363
- interface ToolProjectManifest {
364
- key: string;
365
- name: string;
366
- displayName: string;
367
- version: string;
368
- description: string;
369
- author?: string;
370
- repository?: string;
371
- tools: string[];
372
- category: string;
373
- }
374
- interface ToolProjectDependencies {
375
- [packageName: string]: string;
376
- }
377
- interface ToolProject {
378
- manifest: ToolProjectManifest;
379
- tools: ToolDefinition[];
380
- dependencies?: ToolProjectDependencies;
381
- }
382
- interface ToolCall {
383
- id: string;
384
- name: string;
385
- arguments: Record<string, any>;
386
- }
387
- interface ToolResult {
388
- tool_call_id: string;
389
- name: string;
390
- result: string;
391
- error?: string;
392
- }
393
- interface ToolCategory {
394
- name: string;
395
- description: string;
396
- tools: string[];
397
- }
398
- /**
399
- * @deprecated This interface is deprecated and will be removed in a future version.
400
- */
401
- interface IntelligentToolDetectionConfig {
402
- enabled: boolean;
403
- maxFollowUpMessages: number;
404
- }
405
- /**
406
- * Tool Search Configuration (Anthropic-style on-demand tool discovery)
407
- */
408
- interface ToolSearchConfig {
409
- enabled: boolean;
410
- alwaysLoadedTools: string[];
411
- alwaysLoadedCategories: string[];
412
- searchResultLimit: number;
413
- cacheDiscoveredTools: boolean;
414
- }
415
- interface ToolsConfig {
416
- enabled: boolean;
417
- autoExecute: boolean;
418
- maxToolRounds: number;
419
- toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
420
- resultMaxChars?: number;
421
- /**
422
- * @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
423
- */
424
- intelligentToolDetection?: IntelligentToolDetectionConfig;
425
- enabledTools: string[];
426
- enabledToolCategories: string[];
427
- toolSearch?: ToolSearchConfig;
428
- additionalConfigurations?: {
429
- [key: string]: any;
430
- };
431
- }
432
- /**
433
- * Default Tool Search Configuration
434
- */
435
- declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
436
- declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
437
-
438
478
  /**
439
479
  * Central registry for all tools (built-in + custom).
440
480
  * Handles registration, lookup, filtering by category, schema extraction,
@@ -592,6 +632,10 @@ interface Plan {
592
632
  }
593
633
 
594
634
  interface WorkflowConfig {
635
+ /**
636
+ * Workflow name for display purposes.
637
+ */
638
+ name?: string;
595
639
  /**
596
640
  * Planning phase configuration.
597
641
  * If enabled, AI generates a plan before executing.
@@ -621,6 +665,8 @@ interface WorkflowConfig {
621
665
  allowDynamicSteps?: boolean;
622
666
  /** Maximum total steps (including dynamic). Default: 50 */
623
667
  maxTotalSteps?: number;
668
+ /** Custom step execution prompt. Default: uses built-in STEP_EXECUTION_PROMPT */
669
+ stepPrompt?: string;
624
670
  };
625
671
  /**
626
672
  * Progress reporting configuration.
@@ -636,9 +682,19 @@ interface WorkflowConfig {
636
682
  */
637
683
  onFailure?: {
638
684
  /** Strategy when a step fails after all retries. Default: 'abort' */
639
- strategy: 'abort' | 'skip' | 'ask_user' | 'try_alternative';
640
- /** If 'try_alternative', allow AI to choose a different approach */
641
- allowAlternativePath?: boolean;
685
+ strategy: 'abort' | 'skip' | 'ask_user';
686
+ };
687
+ /**
688
+ * Query complexity routing configuration.
689
+ * Routes simple queries to faster execution paths based on query classification.
690
+ */
691
+ complexityRouting?: {
692
+ /** Enable complexity-based routing. Default: false (opt-in) */
693
+ enabled: boolean;
694
+ /** Routing strategy for simple queries. Default: 'single-step' */
695
+ strategy: 'single-step' | 'bypass' | 'disabled';
696
+ /** Confidence threshold for routing analytical queries. Default: 0.6 */
697
+ confidenceThreshold?: number;
642
698
  };
643
699
  }
644
700
  /**
@@ -772,6 +828,129 @@ interface ModeBlockedHint {
772
828
  suggestedMode: string;
773
829
  }
774
830
 
831
+ type ConfirmationLevel = 'high' | 'medium';
832
+ interface OllamaModelConfig {
833
+ /** Model name as used by Ollama, e.g. 'llama3', 'phi3:mini' */
834
+ model: string;
835
+ /** Display label for the UI */
836
+ label?: string;
837
+ }
838
+ interface HitlConfig {
839
+ /** Master switch. Default: true */
840
+ enabled?: boolean;
841
+ /** Confirmation mode. Default: 'all' */
842
+ confirmationMode?: 'off' | 'high-only' | 'all';
843
+ /** Bypass rules for specific tools, categories, or risk levels */
844
+ bypass?: {
845
+ /** Tool keys to bypass (e.g. ["exec.run", "fs.delete_file"]) */
846
+ tools?: string[];
847
+ /** Categories to bypass (e.g. ["exec-tools"]) */
848
+ categories?: string[];
849
+ /** Risk levels to bypass (e.g. ["medium"]) */
850
+ levels?: ConfirmationLevel[];
851
+ };
852
+ }
853
+ interface ToolpackConfig {
854
+ /** Optional override system prompt for the AIClient */
855
+ systemPrompt?: string;
856
+ /** @deprecated Use `baseContext: false` instead. Legacy: disable auto-injected base agent context. */
857
+ disableBaseContext?: boolean;
858
+ /** Base agent context configuration. `false` disables it entirely. */
859
+ baseContext?: {
860
+ includeWorkingDirectory?: boolean;
861
+ includeToolCategories?: boolean;
862
+ custom?: string;
863
+ } | false;
864
+ /** Optional system prompt overrides for specific modes */
865
+ modeOverrides?: Record<string, Partial<ModeConfig>>;
866
+ /** Ollama provider configuration */
867
+ ollama?: {
868
+ /** Base URL for the Ollama API. Default: http://localhost:11434 */
869
+ baseUrl?: string;
870
+ /** List of Ollama models available as providers */
871
+ models?: OllamaModelConfig[];
872
+ };
873
+ /** Logging configuration. File logging is opt-in (disabled by default). */
874
+ logging?: {
875
+ /** Enable file logging. Default: false */
876
+ enabled?: boolean;
877
+ /** Log file path. Default: 'toolpack-sdk.log' in CWD */
878
+ filePath?: string;
879
+ };
880
+ /** Human-in-the-loop configuration for tool confirmation */
881
+ hitl?: HitlConfig;
882
+ }
883
+ declare function getToolpackConfig(configPath?: string): ToolpackConfig;
884
+ declare function reloadToolpackConfig(): void;
885
+ interface OllamaProviderEntry {
886
+ /** Provider type key, e.g. 'ollama-llama3' */
887
+ type: string;
888
+ /** Ollama model name, e.g. 'llama3' */
889
+ model: string;
890
+ /** Display label */
891
+ label: string;
892
+ }
893
+ declare function getOllamaProviderEntries(configPath?: string): OllamaProviderEntry[];
894
+ declare function getOllamaBaseUrl(configPath?: string): string;
895
+ type BypassRuleType = 'tool' | 'category' | 'level';
896
+ interface AddBypassRuleOptions {
897
+ /** Type of bypass rule */
898
+ type: BypassRuleType;
899
+ /** Value to bypass (tool name, category, or level) */
900
+ value: string;
901
+ /** Optional config path. If not provided, uses local config or creates one */
902
+ configPath?: string;
903
+ }
904
+ /**
905
+ * Add a bypass rule to the HITL config and persist it to the config file.
906
+ * This is useful for implementing "Allow Always" functionality.
907
+ *
908
+ * @example
909
+ * // Bypass a specific tool
910
+ * await addBypassRule({ type: 'tool', value: 'fs.write_file' });
911
+ *
912
+ * // Bypass all medium-risk tools
913
+ * await addBypassRule({ type: 'level', value: 'medium' });
914
+ *
915
+ * // Bypass an entire category
916
+ * await addBypassRule({ type: 'category', value: 'exec-tools' });
917
+ */
918
+ declare function addBypassRule(options: AddBypassRuleOptions): Promise<void>;
919
+ /**
920
+ * Remove a bypass rule from the HITL config.
921
+ *
922
+ * @example
923
+ * await removeBypassRule({ type: 'tool', value: 'fs.write_file' });
924
+ */
925
+ declare function removeBypassRule(options: AddBypassRuleOptions): Promise<void>;
926
+
927
+ /**
928
+ * Query Classifier for Tool Orchestration
929
+ *
930
+ * Classifies user queries into analytical, action, or conversational types
931
+ * to optimize tool execution strategy (e.g., adjust maxToolRounds).
932
+ */
933
+ type QueryType = 'analytical' | 'action' | 'conversational';
934
+ interface QueryClassification {
935
+ type: QueryType;
936
+ confidence: number;
937
+ reasoning?: string;
938
+ }
939
+ declare class QueryClassifier {
940
+ private analyticalPatterns;
941
+ private actionPatterns;
942
+ /**
943
+ * Classify a user query based on pattern matching.
944
+ * Returns the query type and confidence score.
945
+ */
946
+ classify(userMessage: string): QueryClassification;
947
+ /**
948
+ * Get recommended maxToolRounds adjustment based on query type.
949
+ * Returns a multiplier or bonus rounds.
950
+ */
951
+ getToolRoundsAdjustment(classification: QueryClassification, baseRounds: number): number;
952
+ }
953
+
775
954
  interface AIClientConfig {
776
955
  providers: Record<string, ProviderAdapter>;
777
956
  defaultProvider?: string;
@@ -779,6 +958,12 @@ interface AIClientConfig {
779
958
  toolsConfig?: ToolsConfig;
780
959
  systemPrompt?: string;
781
960
  disableBaseContext?: boolean;
961
+ /** Human-in-the-loop configuration for tool confirmation */
962
+ hitlConfig?: HitlConfig;
963
+ /** Callback for handling tool confirmation requests */
964
+ onToolConfirm?: OnToolConfirmCallback;
965
+ /** Optional conversation ID for tracking context */
966
+ conversationId?: string;
782
967
  }
783
968
  declare class AIClient extends EventEmitter {
784
969
  private providers;
@@ -793,7 +978,16 @@ declare class AIClient extends EventEmitter {
793
978
  private overrideSystemPrompt?;
794
979
  private disableBaseContext;
795
980
  private toolResultMaxChars;
981
+ private hitlConfig?;
982
+ private onToolConfirm?;
983
+ private currentRound;
984
+ private conversationId?;
796
985
  constructor(config: AIClientConfig);
986
+ /**
987
+ * Check if a tool should bypass confirmation based on HITL config.
988
+ * Returns true if the tool should execute without confirmation.
989
+ */
990
+ private isBypassed;
797
991
  /**
798
992
  * Register a new provider instance.
799
993
  */
@@ -802,6 +996,15 @@ declare class AIClient extends EventEmitter {
802
996
  * Get a provider by name, or the default if none specified.
803
997
  */
804
998
  getProvider(name?: string): ProviderAdapter;
999
+ /**
1000
+ * Update the HITL configuration dynamically.
1001
+ * This allows modifying bypass rules without restarting the client.
1002
+ */
1003
+ updateHitlConfig(config: HitlConfig): void;
1004
+ /**
1005
+ * Get the current HITL configuration.
1006
+ */
1007
+ getHitlConfig(): HitlConfig | undefined;
805
1008
  /**
806
1009
  * Set the default provider for this client.
807
1010
  */
@@ -835,6 +1038,10 @@ declare class AIClient extends EventEmitter {
835
1038
  * Get the currently active mode.
836
1039
  */
837
1040
  getMode(): ModeConfig | null;
1041
+ /**
1042
+ * Get the query classifier instance.
1043
+ */
1044
+ getQueryClassifier(): QueryClassifier;
838
1045
  /**
839
1046
  * Re-index tools for BM25 search.
840
1047
  * Call this after adding/removing tools from the registry.
@@ -975,53 +1182,6 @@ declare class GeminiAdapter extends ProviderAdapter {
975
1182
  private handleError;
976
1183
  }
977
1184
 
978
- interface OllamaModelConfig {
979
- /** Model name as used by Ollama, e.g. 'llama3', 'phi3:mini' */
980
- model: string;
981
- /** Display label for the UI */
982
- label?: string;
983
- }
984
- interface ToolpackConfig {
985
- /** Optional override system prompt for the AIClient */
986
- systemPrompt?: string;
987
- /** @deprecated Use `baseContext: false` instead. Legacy: disable auto-injected base agent context. */
988
- disableBaseContext?: boolean;
989
- /** Base agent context configuration. `false` disables it entirely. */
990
- baseContext?: {
991
- includeWorkingDirectory?: boolean;
992
- includeToolCategories?: boolean;
993
- custom?: string;
994
- } | false;
995
- /** Optional system prompt overrides for specific modes */
996
- modeOverrides?: Record<string, Partial<ModeConfig>>;
997
- /** Ollama provider configuration */
998
- ollama?: {
999
- /** Base URL for the Ollama API. Default: http://localhost:11434 */
1000
- baseUrl?: string;
1001
- /** List of Ollama models available as providers */
1002
- models?: OllamaModelConfig[];
1003
- };
1004
- /** Logging configuration. File logging is opt-in (disabled by default). */
1005
- logging?: {
1006
- /** Enable file logging. Default: false */
1007
- enabled?: boolean;
1008
- /** Log file path. Default: 'toolpack-sdk.log' in CWD */
1009
- filePath?: string;
1010
- };
1011
- }
1012
- declare function getToolpackConfig(configPath?: string): ToolpackConfig;
1013
- declare function reloadToolpackConfig(): void;
1014
- interface OllamaProviderEntry {
1015
- /** Provider type key, e.g. 'ollama-llama3' */
1016
- type: string;
1017
- /** Ollama model name, e.g. 'llama3' */
1018
- model: string;
1019
- /** Display label */
1020
- label: string;
1021
- }
1022
- declare function getOllamaProviderEntries(configPath?: string): OllamaProviderEntry[];
1023
- declare function getOllamaBaseUrl(configPath?: string): string;
1024
-
1025
1185
  /**
1026
1186
  * Ollama Adapter
1027
1187
  *
@@ -1433,6 +1593,7 @@ declare class McpClient extends EventEmitter {
1433
1593
  constructor(config: McpClientConfig);
1434
1594
  /** Whether the client is currently connected */
1435
1595
  get connected(): boolean;
1596
+ private initializeServer;
1436
1597
  connect(): Promise<void>;
1437
1598
  private attemptReconnect;
1438
1599
  private handleData;
@@ -1486,6 +1647,7 @@ declare class McpToolManager {
1486
1647
  private clients;
1487
1648
  private serverConfigs;
1488
1649
  private toolDefinitions;
1650
+ private toolOwners;
1489
1651
  constructor(config: McpToolsConfig);
1490
1652
  /**
1491
1653
  * Connect to a single MCP server and discover its tools
@@ -1523,6 +1685,12 @@ declare class McpToolManager {
1523
1685
  * Set up event handlers for an MCP client
1524
1686
  */
1525
1687
  private setupClientEvents;
1688
+ private removeServerToolDefinitions;
1689
+ private discoverServerTools;
1690
+ private refreshServerTools;
1691
+ }
1692
+ interface McpToolProject extends ToolProject {
1693
+ mcpManager: McpToolManager;
1526
1694
  }
1527
1695
  /**
1528
1696
  * Create an MCP tool project from server configurations
@@ -1553,11 +1721,11 @@ declare class McpToolManager {
1553
1721
  * });
1554
1722
  * ```
1555
1723
  */
1556
- declare function createMcpToolProject(config: McpToolsConfig): Promise<ToolProject>;
1724
+ declare function createMcpToolProject(config: McpToolsConfig): Promise<McpToolProject>;
1557
1725
  /**
1558
1726
  * Disconnect all MCP servers in a tool project
1559
1727
  */
1560
- declare function disconnectMcpToolProject(project: ToolProject): Promise<void>;
1728
+ declare function disconnectMcpToolProject(project: ToolProject | McpToolProject): Promise<void>;
1561
1729
 
1562
1730
  interface FullConfig {
1563
1731
  tools?: Partial<ToolsConfig>;
@@ -1567,6 +1735,7 @@ interface FullConfig {
1567
1735
  baseContext?: boolean;
1568
1736
  modeOverrides?: Record<string, any>;
1569
1737
  mcp?: McpToolsConfig;
1738
+ hitl?: HitlConfig;
1570
1739
  }
1571
1740
  /**
1572
1741
  * Load the full config from toolpack.config.json.
@@ -1734,6 +1903,20 @@ declare const cloudListTool: ToolDefinition;
1734
1903
 
1735
1904
  declare const cloudToolsProject: ToolProject;
1736
1905
 
1906
+ declare const k8sListPodsTool: ToolDefinition;
1907
+ declare const k8sDescribeTool: ToolDefinition;
1908
+ declare const k8sGetLogsTool: ToolDefinition;
1909
+ declare const k8sApplyManifestTool: ToolDefinition;
1910
+ declare const k8sDeleteResourceTool: ToolDefinition;
1911
+ declare const k8sListServicesTool: ToolDefinition;
1912
+ declare const k8sListDeploymentsTool: ToolDefinition;
1913
+ declare const k8sGetConfigMapTool: ToolDefinition;
1914
+ declare const k8sSwitchContextTool: ToolDefinition;
1915
+ declare const k8sGetNamespacesTool: ToolDefinition;
1916
+ declare const k8sWaitForDeploymentTool: ToolDefinition;
1917
+
1918
+ declare const k8sToolsProject: ToolProject;
1919
+
1737
1920
  /**
1738
1921
  * Central registry for AI agent modes (built-in + custom).
1739
1922
  * Handles registration, lookup, cycling, and defaults.
@@ -1861,7 +2044,10 @@ declare const CHAT_MODE: ModeConfig;
1861
2044
  /**
1862
2045
  * All built-in modes.
1863
2046
  *
1864
- * Two modes: Agent (full access + workflow) and Chat (web access only)
2047
+ * Three modes:
2048
+ * - Agent (full access + workflow)
2049
+ * - Coding (concise, coding-focused workflow)
2050
+ * - Chat (web access only)
1865
2051
  */
1866
2052
  declare const BUILT_IN_MODES: readonly ModeConfig[];
1867
2053
  /**
@@ -1877,10 +2063,6 @@ declare class Planner {
1877
2063
  * Create a detailed step-by-step plan from the user's request.
1878
2064
  */
1879
2065
  createPlan(request: CompletionRequest, providerName?: string): Promise<Plan>;
1880
- /**
1881
- * Create a lightweight implicit plan when steps are enabled but planning phase is skipped.
1882
- */
1883
- createImplicitPlan(request: CompletionRequest, providerName?: string): Promise<Plan>;
1884
2066
  private parsePlan;
1885
2067
  private createFallbackPlan;
1886
2068
  }
@@ -1918,8 +2100,9 @@ declare class WorkflowExecutor extends EventEmitter {
1918
2100
  private config;
1919
2101
  private planner;
1920
2102
  private stepExecutor;
2103
+ private queryClassifier;
1921
2104
  private pendingApprovals;
1922
- constructor(client: AIClient, config: WorkflowConfig);
2105
+ constructor(client: AIClient, config: WorkflowConfig, queryClassifier?: QueryClassifier);
1923
2106
  /**
1924
2107
  * Get the active configuration.
1925
2108
  */
@@ -1928,6 +2111,11 @@ declare class WorkflowExecutor extends EventEmitter {
1928
2111
  * Update the configuration.
1929
2112
  */
1930
2113
  setConfig(config: WorkflowConfig): void;
2114
+ /**
2115
+ * Determine if a query should bypass full workflow and use direct execution.
2116
+ * Routes simple queries to single-step execution for performance optimization.
2117
+ */
2118
+ private shouldRouteSimpleQuery;
1931
2119
  /**
1932
2120
  * Execute a request using the configured workflow.
1933
2121
  */
@@ -1961,8 +2149,9 @@ declare class WorkflowExecutor extends EventEmitter {
1961
2149
  */
1962
2150
  private summarizePlanResult;
1963
2151
  /**
1964
- * Extract the final output from the last completed step.
1965
- * Returns the actual AI response instead of a workflow summary.
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.
1966
2155
  */
1967
2156
  private extractFinalOutput;
1968
2157
  /**
@@ -2004,6 +2193,47 @@ declare class WorkflowExecutor extends EventEmitter {
2004
2193
  rejectPlan(planId: string): void;
2005
2194
  }
2006
2195
 
2196
+ /**
2197
+ * Agent planning prompt.
2198
+ * Full detailed planning for general autonomous tasks.
2199
+ */
2200
+ 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
+ /**
2207
+ * Default workflow configuration.
2208
+ * Direct execution with no planning or steps.
2209
+ */
2210
+ declare const DEFAULT_WORKFLOW: WorkflowConfig;
2211
+ /**
2212
+ * Agent workflow configuration.
2213
+ * Full planning and step execution with dynamic steps disabled.
2214
+ */
2215
+ declare const AGENT_WORKFLOW: WorkflowConfig;
2216
+ /**
2217
+ * Concise planning prompt for coding tasks.
2218
+ * Minimal rules focused on actionable code changes.
2219
+ */
2220
+ 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
+ /**
2227
+ * Coding workflow configuration.
2228
+ * Concise prompts optimized for software development tasks.
2229
+ */
2230
+ declare const CODING_WORKFLOW: WorkflowConfig;
2231
+ /**
2232
+ * Chat workflow configuration.
2233
+ * No planning or steps - direct conversational responses.
2234
+ */
2235
+ declare const CHAT_WORKFLOW: WorkflowConfig;
2236
+
2007
2237
  interface ProviderOptions {
2008
2238
  /**
2009
2239
  * API key for the provider.
@@ -2064,6 +2294,22 @@ interface ToolpackInitConfig {
2064
2294
  * Accepts any object with a `toTool()` method (e.g. `Knowledge` from `@toolpack-sdk/knowledge`).
2065
2295
  */
2066
2296
  knowledge?: KnowledgeInstance | null;
2297
+ /**
2298
+ * Human-in-the-loop configuration for tool confirmation.
2299
+ * Default: 'all' when onToolConfirm is provided, 'off' otherwise.
2300
+ */
2301
+ confirmationMode?: 'off' | 'high-only' | 'all';
2302
+ /**
2303
+ * Callback for handling tool confirmation requests.
2304
+ * Called before executing tools that have confirmation metadata set.
2305
+ * If not provided, HITL is disabled regardless of confirmationMode.
2306
+ */
2307
+ onToolConfirm?: (tool: ToolDefinition, args: Record<string, any>, context: {
2308
+ roundNumber: number;
2309
+ conversationId?: string;
2310
+ }) => Promise<ConfirmationDecision>;
2311
+ /** Optional conversation ID for tracking context across confirmations */
2312
+ conversationId?: string;
2067
2313
  }
2068
2314
  /**
2069
2315
  * Duck-typed interface for Knowledge instances to avoid circular dependency
@@ -2129,6 +2375,12 @@ declare class Toolpack extends EventEmitter {
2129
2375
  * Useful for listening to tool progress events.
2130
2376
  */
2131
2377
  getClient(): AIClient;
2378
+ /**
2379
+ * Reload configuration from the config file.
2380
+ * This updates the HITL config in the running instance.
2381
+ * Call this after modifying config (e.g., bypass rules) to apply changes immediately.
2382
+ */
2383
+ reloadConfig(configPath?: string): void;
2132
2384
  /**
2133
2385
  * Get the WorkflowExecutor instance.
2134
2386
  * Useful for workflow events and approval flows.
@@ -2273,4 +2525,4 @@ interface McpServerCapabilities {
2273
2525
  prompts?: Record<string, any>;
2274
2526
  }
2275
2527
 
2276
- export { AGENT_MODE, AIClient, type AIClientConfig, AnthropicAdapter, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, CHAT_MODE, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, ConnectionError, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, type IntelligentToolDetectionConfig, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, OpenAIAdapter, PageError, type Plan, type PlanStep, Planner, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, RateLimitError, type Role, type RuntimeConfigStatus, SDKError, type SearchHistoryEntry, type SearchOptions, type SearchResult, type SlmModelEntry, StepExecutor, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolsConfig, type Usage, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingFindSymbolTool, codingGetImportsTool, codingGetSymbolsTool, codingToolsProject, createMcpToolProject, createMode, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, fetchUrlAsBase64, fsAppendFileTool, fsCopyTool, fsCreateDirTool, fsDeleteFileTool, fsExistsTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateToolCategoriesPrompt, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isDataUri, isRegisteredSlm, isToolSearchTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, readFileAsBase64, reloadToolpackConfig, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject };
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 };