toolpack-sdk 1.3.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/README.md +90 -6
- package/dist/index.cjs +135 -130
- package/dist/index.d.cts +339 -181
- package/dist/index.d.ts +339 -181
- package/dist/index.js +135 -130
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,149 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Core type definitions for the Tool Calling System.
|
|
5
|
+
*/
|
|
6
|
+
interface ToolParameterProperty {
|
|
7
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'integer';
|
|
8
|
+
description?: string;
|
|
9
|
+
enum?: string[];
|
|
10
|
+
default?: any;
|
|
11
|
+
items?: ToolParameterProperty;
|
|
12
|
+
properties?: Record<string, ToolParameterProperty>;
|
|
13
|
+
additionalProperties?: ToolParameterProperty | boolean;
|
|
14
|
+
required?: string[];
|
|
15
|
+
}
|
|
16
|
+
interface ToolParameters {
|
|
17
|
+
type: 'object';
|
|
18
|
+
properties: Record<string, ToolParameterProperty>;
|
|
19
|
+
required?: string[];
|
|
20
|
+
}
|
|
21
|
+
interface ToolContext {
|
|
22
|
+
/** Absolute path to the workspace/project root */
|
|
23
|
+
workspaceRoot: string;
|
|
24
|
+
/** Tool-specific config from toolpack.config.json additionalConfigurations */
|
|
25
|
+
config: Record<string, any>;
|
|
26
|
+
/** Scoped logger — writes to toolpack-sdk.log */
|
|
27
|
+
log: (message: string) => void;
|
|
28
|
+
}
|
|
29
|
+
type ConfirmationLevel$1 = 'high' | 'medium';
|
|
30
|
+
interface ToolConfirmation {
|
|
31
|
+
level: ConfirmationLevel$1;
|
|
32
|
+
reason: string;
|
|
33
|
+
showArgs?: string[];
|
|
34
|
+
}
|
|
35
|
+
interface ToolDefinition {
|
|
36
|
+
name: string;
|
|
37
|
+
displayName: string;
|
|
38
|
+
description: string;
|
|
39
|
+
parameters: ToolParameters;
|
|
40
|
+
category: string;
|
|
41
|
+
execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether this tool should be cached after discovery via tool.search.
|
|
44
|
+
* If false, the tool must be re-discovered each time it's needed.
|
|
45
|
+
* Default: true
|
|
46
|
+
*/
|
|
47
|
+
cacheable?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Human-in-the-loop confirmation configuration.
|
|
50
|
+
* If set, the tool will require user confirmation before execution.
|
|
51
|
+
* Note: Only effective when onToolConfirm callback is provided to AIClient.
|
|
52
|
+
*/
|
|
53
|
+
confirmation?: ToolConfirmation;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Schema-only version of ToolDefinition (no execute function).
|
|
57
|
+
* Used for serialization and sending to AI providers.
|
|
58
|
+
*/
|
|
59
|
+
interface ToolSchema {
|
|
60
|
+
name: string;
|
|
61
|
+
displayName: string;
|
|
62
|
+
description: string;
|
|
63
|
+
parameters: ToolParameters;
|
|
64
|
+
category: string;
|
|
65
|
+
/**
|
|
66
|
+
* Whether this tool should be cached after discovery via tool.search.
|
|
67
|
+
* If false, the tool must be re-discovered each time it's needed.
|
|
68
|
+
* Default: true
|
|
69
|
+
*/
|
|
70
|
+
cacheable?: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface ToolProjectManifest {
|
|
73
|
+
key: string;
|
|
74
|
+
name: string;
|
|
75
|
+
displayName: string;
|
|
76
|
+
version: string;
|
|
77
|
+
description: string;
|
|
78
|
+
author?: string;
|
|
79
|
+
repository?: string;
|
|
80
|
+
tools: string[];
|
|
81
|
+
category: string;
|
|
82
|
+
}
|
|
83
|
+
interface ToolProjectDependencies {
|
|
84
|
+
[packageName: string]: string;
|
|
85
|
+
}
|
|
86
|
+
interface ToolProject {
|
|
87
|
+
manifest: ToolProjectManifest;
|
|
88
|
+
tools: ToolDefinition[];
|
|
89
|
+
dependencies?: ToolProjectDependencies;
|
|
90
|
+
}
|
|
91
|
+
interface ToolCall {
|
|
92
|
+
id: string;
|
|
93
|
+
name: string;
|
|
94
|
+
arguments: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
interface ToolResult {
|
|
97
|
+
tool_call_id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
result: string;
|
|
100
|
+
error?: string;
|
|
101
|
+
}
|
|
102
|
+
interface ToolCategory {
|
|
103
|
+
name: string;
|
|
104
|
+
description: string;
|
|
105
|
+
tools: string[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated This interface is deprecated and will be removed in a future version.
|
|
109
|
+
*/
|
|
110
|
+
interface IntelligentToolDetectionConfig {
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
maxFollowUpMessages: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Tool Search Configuration (Anthropic-style on-demand tool discovery)
|
|
116
|
+
*/
|
|
117
|
+
interface ToolSearchConfig {
|
|
118
|
+
enabled: boolean;
|
|
119
|
+
alwaysLoadedTools: string[];
|
|
120
|
+
alwaysLoadedCategories: string[];
|
|
121
|
+
searchResultLimit: number;
|
|
122
|
+
cacheDiscoveredTools: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface ToolsConfig {
|
|
125
|
+
enabled: boolean;
|
|
126
|
+
autoExecute: boolean;
|
|
127
|
+
maxToolRounds: number;
|
|
128
|
+
toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
|
|
129
|
+
resultMaxChars?: number;
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
|
|
132
|
+
*/
|
|
133
|
+
intelligentToolDetection?: IntelligentToolDetectionConfig;
|
|
134
|
+
enabledTools: string[];
|
|
135
|
+
enabledToolCategories: string[];
|
|
136
|
+
toolSearch?: ToolSearchConfig;
|
|
137
|
+
additionalConfigurations?: {
|
|
138
|
+
[key: string]: any;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Default Tool Search Configuration
|
|
143
|
+
*/
|
|
144
|
+
declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
|
|
145
|
+
declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
|
|
146
|
+
|
|
3
147
|
type Role = 'system' | 'user' | 'assistant' | 'tool';
|
|
4
148
|
interface TextPart {
|
|
5
149
|
type: 'text';
|
|
@@ -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,
|
|
@@ -788,6 +828,102 @@ interface ModeBlockedHint {
|
|
|
788
828
|
suggestedMode: string;
|
|
789
829
|
}
|
|
790
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
|
+
|
|
791
927
|
/**
|
|
792
928
|
* Query Classifier for Tool Orchestration
|
|
793
929
|
*
|
|
@@ -822,6 +958,12 @@ interface AIClientConfig {
|
|
|
822
958
|
toolsConfig?: ToolsConfig;
|
|
823
959
|
systemPrompt?: string;
|
|
824
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;
|
|
825
967
|
}
|
|
826
968
|
declare class AIClient extends EventEmitter {
|
|
827
969
|
private providers;
|
|
@@ -836,7 +978,16 @@ declare class AIClient extends EventEmitter {
|
|
|
836
978
|
private overrideSystemPrompt?;
|
|
837
979
|
private disableBaseContext;
|
|
838
980
|
private toolResultMaxChars;
|
|
981
|
+
private hitlConfig?;
|
|
982
|
+
private onToolConfirm?;
|
|
983
|
+
private currentRound;
|
|
984
|
+
private conversationId?;
|
|
839
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;
|
|
840
991
|
/**
|
|
841
992
|
* Register a new provider instance.
|
|
842
993
|
*/
|
|
@@ -845,6 +996,15 @@ declare class AIClient extends EventEmitter {
|
|
|
845
996
|
* Get a provider by name, or the default if none specified.
|
|
846
997
|
*/
|
|
847
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;
|
|
848
1008
|
/**
|
|
849
1009
|
* Set the default provider for this client.
|
|
850
1010
|
*/
|
|
@@ -1022,53 +1182,6 @@ declare class GeminiAdapter extends ProviderAdapter {
|
|
|
1022
1182
|
private handleError;
|
|
1023
1183
|
}
|
|
1024
1184
|
|
|
1025
|
-
interface OllamaModelConfig {
|
|
1026
|
-
/** Model name as used by Ollama, e.g. 'llama3', 'phi3:mini' */
|
|
1027
|
-
model: string;
|
|
1028
|
-
/** Display label for the UI */
|
|
1029
|
-
label?: string;
|
|
1030
|
-
}
|
|
1031
|
-
interface ToolpackConfig {
|
|
1032
|
-
/** Optional override system prompt for the AIClient */
|
|
1033
|
-
systemPrompt?: string;
|
|
1034
|
-
/** @deprecated Use `baseContext: false` instead. Legacy: disable auto-injected base agent context. */
|
|
1035
|
-
disableBaseContext?: boolean;
|
|
1036
|
-
/** Base agent context configuration. `false` disables it entirely. */
|
|
1037
|
-
baseContext?: {
|
|
1038
|
-
includeWorkingDirectory?: boolean;
|
|
1039
|
-
includeToolCategories?: boolean;
|
|
1040
|
-
custom?: string;
|
|
1041
|
-
} | false;
|
|
1042
|
-
/** Optional system prompt overrides for specific modes */
|
|
1043
|
-
modeOverrides?: Record<string, Partial<ModeConfig>>;
|
|
1044
|
-
/** Ollama provider configuration */
|
|
1045
|
-
ollama?: {
|
|
1046
|
-
/** Base URL for the Ollama API. Default: http://localhost:11434 */
|
|
1047
|
-
baseUrl?: string;
|
|
1048
|
-
/** List of Ollama models available as providers */
|
|
1049
|
-
models?: OllamaModelConfig[];
|
|
1050
|
-
};
|
|
1051
|
-
/** Logging configuration. File logging is opt-in (disabled by default). */
|
|
1052
|
-
logging?: {
|
|
1053
|
-
/** Enable file logging. Default: false */
|
|
1054
|
-
enabled?: boolean;
|
|
1055
|
-
/** Log file path. Default: 'toolpack-sdk.log' in CWD */
|
|
1056
|
-
filePath?: string;
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
declare function getToolpackConfig(configPath?: string): ToolpackConfig;
|
|
1060
|
-
declare function reloadToolpackConfig(): void;
|
|
1061
|
-
interface OllamaProviderEntry {
|
|
1062
|
-
/** Provider type key, e.g. 'ollama-llama3' */
|
|
1063
|
-
type: string;
|
|
1064
|
-
/** Ollama model name, e.g. 'llama3' */
|
|
1065
|
-
model: string;
|
|
1066
|
-
/** Display label */
|
|
1067
|
-
label: string;
|
|
1068
|
-
}
|
|
1069
|
-
declare function getOllamaProviderEntries(configPath?: string): OllamaProviderEntry[];
|
|
1070
|
-
declare function getOllamaBaseUrl(configPath?: string): string;
|
|
1071
|
-
|
|
1072
1185
|
/**
|
|
1073
1186
|
* Ollama Adapter
|
|
1074
1187
|
*
|
|
@@ -1480,6 +1593,7 @@ declare class McpClient extends EventEmitter {
|
|
|
1480
1593
|
constructor(config: McpClientConfig);
|
|
1481
1594
|
/** Whether the client is currently connected */
|
|
1482
1595
|
get connected(): boolean;
|
|
1596
|
+
private initializeServer;
|
|
1483
1597
|
connect(): Promise<void>;
|
|
1484
1598
|
private attemptReconnect;
|
|
1485
1599
|
private handleData;
|
|
@@ -1533,6 +1647,7 @@ declare class McpToolManager {
|
|
|
1533
1647
|
private clients;
|
|
1534
1648
|
private serverConfigs;
|
|
1535
1649
|
private toolDefinitions;
|
|
1650
|
+
private toolOwners;
|
|
1536
1651
|
constructor(config: McpToolsConfig);
|
|
1537
1652
|
/**
|
|
1538
1653
|
* Connect to a single MCP server and discover its tools
|
|
@@ -1570,6 +1685,12 @@ declare class McpToolManager {
|
|
|
1570
1685
|
* Set up event handlers for an MCP client
|
|
1571
1686
|
*/
|
|
1572
1687
|
private setupClientEvents;
|
|
1688
|
+
private removeServerToolDefinitions;
|
|
1689
|
+
private discoverServerTools;
|
|
1690
|
+
private refreshServerTools;
|
|
1691
|
+
}
|
|
1692
|
+
interface McpToolProject extends ToolProject {
|
|
1693
|
+
mcpManager: McpToolManager;
|
|
1573
1694
|
}
|
|
1574
1695
|
/**
|
|
1575
1696
|
* Create an MCP tool project from server configurations
|
|
@@ -1600,11 +1721,11 @@ declare class McpToolManager {
|
|
|
1600
1721
|
* });
|
|
1601
1722
|
* ```
|
|
1602
1723
|
*/
|
|
1603
|
-
declare function createMcpToolProject(config: McpToolsConfig): Promise<
|
|
1724
|
+
declare function createMcpToolProject(config: McpToolsConfig): Promise<McpToolProject>;
|
|
1604
1725
|
/**
|
|
1605
1726
|
* Disconnect all MCP servers in a tool project
|
|
1606
1727
|
*/
|
|
1607
|
-
declare function disconnectMcpToolProject(project: ToolProject): Promise<void>;
|
|
1728
|
+
declare function disconnectMcpToolProject(project: ToolProject | McpToolProject): Promise<void>;
|
|
1608
1729
|
|
|
1609
1730
|
interface FullConfig {
|
|
1610
1731
|
tools?: Partial<ToolsConfig>;
|
|
@@ -1614,6 +1735,7 @@ interface FullConfig {
|
|
|
1614
1735
|
baseContext?: boolean;
|
|
1615
1736
|
modeOverrides?: Record<string, any>;
|
|
1616
1737
|
mcp?: McpToolsConfig;
|
|
1738
|
+
hitl?: HitlConfig;
|
|
1617
1739
|
}
|
|
1618
1740
|
/**
|
|
1619
1741
|
* Load the full config from toolpack.config.json.
|
|
@@ -1781,6 +1903,20 @@ declare const cloudListTool: ToolDefinition;
|
|
|
1781
1903
|
|
|
1782
1904
|
declare const cloudToolsProject: ToolProject;
|
|
1783
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
|
+
|
|
1784
1920
|
/**
|
|
1785
1921
|
* Central registry for AI agent modes (built-in + custom).
|
|
1786
1922
|
* Handles registration, lookup, cycling, and defaults.
|
|
@@ -2158,6 +2294,22 @@ interface ToolpackInitConfig {
|
|
|
2158
2294
|
* Accepts any object with a `toTool()` method (e.g. `Knowledge` from `@toolpack-sdk/knowledge`).
|
|
2159
2295
|
*/
|
|
2160
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;
|
|
2161
2313
|
}
|
|
2162
2314
|
/**
|
|
2163
2315
|
* Duck-typed interface for Knowledge instances to avoid circular dependency
|
|
@@ -2223,6 +2375,12 @@ declare class Toolpack extends EventEmitter {
|
|
|
2223
2375
|
* Useful for listening to tool progress events.
|
|
2224
2376
|
*/
|
|
2225
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;
|
|
2226
2384
|
/**
|
|
2227
2385
|
* Get the WorkflowExecutor instance.
|
|
2228
2386
|
* Useful for workflow events and approval flows.
|
|
@@ -2367,4 +2525,4 @@ interface McpServerCapabilities {
|
|
|
2367
2525
|
prompts?: Record<string, any>;
|
|
2368
2526
|
}
|
|
2369
2527
|
|
|
2370
|
-
export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_STEP_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, AnthropicAdapter, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, CHAT_MODE, CHAT_WORKFLOW, CODING_PLANNING_PROMPT, CODING_STEP_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, ConnectionError, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, type IntelligentToolDetectionConfig, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, OpenAIAdapter, PageError, type Plan, type PlanStep, Planner, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, RateLimitError, type Role, type RuntimeConfigStatus, SDKError, type SearchHistoryEntry, type SearchOptions, type SearchResult, type SlmModelEntry, StepExecutor, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolsConfig, type Usage, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingFindSymbolTool, codingGetImportsTool, codingGetSymbolsTool, codingToolsProject, createMcpToolProject, createMode, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, fetchUrlAsBase64, fsAppendFileTool, fsCopyTool, fsCreateDirTool, fsDeleteFileTool, fsExistsTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateToolCategoriesPrompt, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isDataUri, isRegisteredSlm, isToolSearchTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, readFileAsBase64, reloadToolpackConfig, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject };
|
|
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 };
|