toolpack-sdk 2.6.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -128
- package/dist/index.cjs +164 -158
- package/dist/index.d.cts +325 -98
- package/dist/index.d.ts +325 -98
- package/dist/index.js +161 -155
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChildProcess } from 'child_process';
|
|
1
2
|
import * as zod from 'zod';
|
|
2
3
|
import { EventEmitter } from 'events';
|
|
3
4
|
import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
@@ -171,93 +172,49 @@ interface WorkflowResult {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
175
|
+
* GitHub token resolution for toolpack github-tools.
|
|
176
|
+
*
|
|
177
|
+
* Resolution order (first match wins):
|
|
178
|
+
* 1. Explicit token passed by the caller (args.token)
|
|
179
|
+
* 2. GITHUB_PAT environment variable
|
|
180
|
+
* 3. GitHub App installation token — minted from GITHUB_APP_ID +
|
|
181
|
+
* GITHUB_APP_PRIVATE_KEY; installationId is looked up via the
|
|
182
|
+
* repo name when not supplied directly.
|
|
183
|
+
*
|
|
184
|
+
* Tokens are cached by installationId (50-minute TTL; GitHub tokens last 60).
|
|
177
185
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
description: string;
|
|
185
|
-
/**
|
|
186
|
-
* System prompt prepended to every request in this mode.
|
|
187
|
-
* Empty string means no system prompt injection (passthrough).
|
|
188
|
-
*/
|
|
189
|
-
systemPrompt: string;
|
|
190
|
-
/**
|
|
191
|
-
* Base agent context configuration for this mode.
|
|
192
|
-
* Controls whether working directory and tool categories are injected into system prompt.
|
|
193
|
-
*
|
|
194
|
-
* - undefined: Use global default behavior (include everything)
|
|
195
|
-
* - false: Disable base context entirely
|
|
196
|
-
* - object: Fine-grained control over what is included
|
|
197
|
-
*/
|
|
198
|
-
baseContext?: {
|
|
199
|
-
/** Include working directory in system prompt. Default: true */
|
|
200
|
-
includeWorkingDirectory?: boolean;
|
|
201
|
-
/** Include available tool categories. Default: true */
|
|
202
|
-
includeToolCategories?: boolean;
|
|
203
|
-
/** Custom base context string (overrides auto-generated). */
|
|
204
|
-
custom?: string;
|
|
205
|
-
} | false;
|
|
206
|
-
/** Workflow configuration controlling planning, steps, and progress. */
|
|
207
|
-
workflow?: WorkflowConfig;
|
|
208
|
-
/**
|
|
209
|
-
* Tool search configuration specific to this mode.
|
|
210
|
-
* Overrides or extends the global toolSearch config.
|
|
211
|
-
*/
|
|
212
|
-
toolSearch?: {
|
|
213
|
-
/** Enable/disable tool search for this mode */
|
|
214
|
-
enabled?: boolean;
|
|
215
|
-
/** Tools to always include (never defer) for this mode */
|
|
216
|
-
alwaysLoadedTools?: string[];
|
|
217
|
-
/** Categories to always include for this mode */
|
|
218
|
-
alwaysLoadedCategories?: string[];
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Tool categories allowed in this mode.
|
|
222
|
-
* Empty array means all categories are allowed (unless blocked).
|
|
223
|
-
*/
|
|
224
|
-
allowedToolCategories: string[];
|
|
225
|
-
/**
|
|
226
|
-
* Tool categories explicitly blocked in this mode.
|
|
227
|
-
* Takes precedence over allowedToolCategories.
|
|
228
|
-
*/
|
|
229
|
-
blockedToolCategories: string[];
|
|
230
|
-
/**
|
|
231
|
-
* Specific tool names allowed in this mode.
|
|
232
|
-
* Empty array means all tools are allowed (unless blocked).
|
|
233
|
-
*/
|
|
234
|
-
allowedTools: string[];
|
|
235
|
-
/**
|
|
236
|
-
* Specific tool names explicitly blocked in this mode.
|
|
237
|
-
* Takes precedence over allowedTools.
|
|
238
|
-
*/
|
|
239
|
-
blockedTools: string[];
|
|
240
|
-
/**
|
|
241
|
-
* If true, ALL tools are blocked regardless of other settings.
|
|
242
|
-
* Shorthand for "no tool calls at all".
|
|
243
|
-
*/
|
|
244
|
-
blockAllTools: boolean;
|
|
245
|
-
/**
|
|
246
|
-
* Response format constraint for all requests in this mode.
|
|
247
|
-
* - 'json_object': instructs the model to return valid JSON as its text content.
|
|
248
|
-
* Useful for evaluator/parser agents whose final response must be machine-readable.
|
|
249
|
-
* Tool-call rounds are unaffected — the model still returns functionCall parts
|
|
250
|
-
* normally; the format only applies to text content.
|
|
251
|
-
* - 'text' (default): plain text, no constraint.
|
|
252
|
-
*/
|
|
253
|
-
response_format?: 'text' | 'json_object';
|
|
186
|
+
declare class GithubTokenStore {
|
|
187
|
+
private tokenCache;
|
|
188
|
+
private installationIdCache;
|
|
189
|
+
resolve(repo?: string, explicitToken?: string, credentials?: ToolpackCredentials): Promise<string>;
|
|
190
|
+
private _lookupInstallationId;
|
|
191
|
+
private _mintInstallationToken;
|
|
254
192
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
193
|
+
|
|
194
|
+
interface ManagedProcess {
|
|
195
|
+
id: string;
|
|
196
|
+
command: string;
|
|
197
|
+
cwd?: string;
|
|
198
|
+
process: ChildProcess;
|
|
199
|
+
startedAt: string;
|
|
200
|
+
stdout: string;
|
|
201
|
+
stderr: string;
|
|
202
|
+
}
|
|
203
|
+
declare class ProcessRegistry {
|
|
204
|
+
private processes;
|
|
205
|
+
private nextId;
|
|
206
|
+
register(command: string, cwd: string | undefined, proc: ChildProcess): string;
|
|
207
|
+
get(id: string): ManagedProcess | undefined;
|
|
208
|
+
kill(id: string): boolean;
|
|
209
|
+
list(): {
|
|
210
|
+
id: string;
|
|
211
|
+
command: string;
|
|
212
|
+
cwd?: string;
|
|
213
|
+
startedAt: string;
|
|
214
|
+
alive: boolean;
|
|
215
|
+
pid: number | undefined;
|
|
216
|
+
}[];
|
|
217
|
+
remove(id: string): boolean;
|
|
261
218
|
}
|
|
262
219
|
|
|
263
220
|
/**
|
|
@@ -278,13 +235,38 @@ interface ToolParameters {
|
|
|
278
235
|
properties: Record<string, ToolParameterProperty>;
|
|
279
236
|
required?: string[];
|
|
280
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Per-tenant tool credentials passed via toolsConfig.additionalConfigurations.credentials.
|
|
240
|
+
* Each field is a programmatic override; tools fall back to the corresponding
|
|
241
|
+
* env var when the field is absent.
|
|
242
|
+
*/
|
|
243
|
+
interface ToolpackCredentials {
|
|
244
|
+
/** GitHub personal access token. Fallback: GITHUB_PAT */
|
|
245
|
+
githubPat?: string;
|
|
246
|
+
/** GitHub App ID. Fallback: GITHUB_APP_ID */
|
|
247
|
+
githubAppId?: string;
|
|
248
|
+
/** GitHub App private key (PEM). Fallback: GITHUB_APP_PRIVATE_KEY */
|
|
249
|
+
githubAppPrivateKey?: string;
|
|
250
|
+
/** Slack bot token. Fallback: TOOLPACK_SLACK_BOT_TOKEN */
|
|
251
|
+
slackBotToken?: string;
|
|
252
|
+
/** Netlify auth token. Fallback: NETLIFY_AUTH_TOKEN */
|
|
253
|
+
netlifyAuthToken?: string;
|
|
254
|
+
}
|
|
281
255
|
interface ToolContext {
|
|
282
256
|
/** Absolute path to the workspace/project root */
|
|
283
257
|
workspaceRoot: string;
|
|
284
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Tool-specific config from toolsConfig.additionalConfigurations.
|
|
260
|
+
* Includes credentials (ctx.config.credentials) and per-tool settings
|
|
261
|
+
* (ctx.config.gitClone, ctx.config.webSearch, etc.).
|
|
262
|
+
*/
|
|
285
263
|
config: Record<string, any>;
|
|
286
264
|
/** Scoped logger — writes to toolpack-sdk.log */
|
|
287
265
|
log: (message: string) => void;
|
|
266
|
+
/** Per-tenant background-process registry (exec-tools). */
|
|
267
|
+
processRegistry?: ProcessRegistry;
|
|
268
|
+
/** Per-tenant GitHub App installation-token cache (github-tools). */
|
|
269
|
+
githubTokenStore?: GithubTokenStore;
|
|
288
270
|
}
|
|
289
271
|
/**
|
|
290
272
|
* Hints about tool behaviour sent to MCP clients in tools/list.
|
|
@@ -443,6 +425,128 @@ interface ToolsConfig {
|
|
|
443
425
|
declare const DEFAULT_TOOL_SEARCH_CONFIG: ToolSearchConfig;
|
|
444
426
|
declare const DEFAULT_TOOLS_CONFIG: ToolsConfig;
|
|
445
427
|
|
|
428
|
+
/**
|
|
429
|
+
* Configuration for an AI agent mode.
|
|
430
|
+
* A mode shapes AI behavior by controlling which tools are available
|
|
431
|
+
* and injecting a persona-specific system prompt.
|
|
432
|
+
*/
|
|
433
|
+
interface ModeConfig {
|
|
434
|
+
/** Unique identifier for the mode (e.g., "all", "ask", "code") */
|
|
435
|
+
name: string;
|
|
436
|
+
/** Human-readable display name (e.g., "All", "Ask", "Code") */
|
|
437
|
+
displayName: string;
|
|
438
|
+
/** Short description for UI tooltips */
|
|
439
|
+
description: string;
|
|
440
|
+
/**
|
|
441
|
+
* System prompt prepended to every request in this mode.
|
|
442
|
+
* Empty string means no system prompt injection (passthrough).
|
|
443
|
+
*/
|
|
444
|
+
systemPrompt: string;
|
|
445
|
+
/**
|
|
446
|
+
* Base agent context configuration for this mode.
|
|
447
|
+
* Controls whether working directory and tool categories are injected into system prompt.
|
|
448
|
+
*
|
|
449
|
+
* - undefined: Use global default behavior (include everything)
|
|
450
|
+
* - false: Disable base context entirely
|
|
451
|
+
* - object: Fine-grained control over what is included
|
|
452
|
+
*/
|
|
453
|
+
baseContext?: {
|
|
454
|
+
/** Include working directory in system prompt. Default: true */
|
|
455
|
+
includeWorkingDirectory?: boolean;
|
|
456
|
+
/** Include available tool categories. Default: true */
|
|
457
|
+
includeToolCategories?: boolean;
|
|
458
|
+
/** Custom base context string (overrides auto-generated). */
|
|
459
|
+
custom?: string;
|
|
460
|
+
} | false;
|
|
461
|
+
/** Workflow configuration controlling planning, steps, and progress. */
|
|
462
|
+
workflow?: WorkflowConfig;
|
|
463
|
+
/**
|
|
464
|
+
* Tool search configuration specific to this mode.
|
|
465
|
+
* Overrides or extends the global toolSearch config.
|
|
466
|
+
*/
|
|
467
|
+
toolSearch?: {
|
|
468
|
+
/** Enable/disable tool search for this mode */
|
|
469
|
+
enabled?: boolean;
|
|
470
|
+
/** Tools to always include (never defer) for this mode */
|
|
471
|
+
alwaysLoadedTools?: string[];
|
|
472
|
+
/** Categories to always include for this mode */
|
|
473
|
+
alwaysLoadedCategories?: string[];
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Tool categories allowed in this mode.
|
|
477
|
+
* Empty array means all categories are allowed (unless blocked).
|
|
478
|
+
*/
|
|
479
|
+
allowedToolCategories: string[];
|
|
480
|
+
/**
|
|
481
|
+
* Tool categories explicitly blocked in this mode.
|
|
482
|
+
* Takes precedence over allowedToolCategories.
|
|
483
|
+
*/
|
|
484
|
+
blockedToolCategories: string[];
|
|
485
|
+
/**
|
|
486
|
+
* Specific tool names allowed in this mode.
|
|
487
|
+
* Empty array means all tools are allowed (unless blocked).
|
|
488
|
+
*/
|
|
489
|
+
allowedTools: string[];
|
|
490
|
+
/**
|
|
491
|
+
* Specific tool names explicitly blocked in this mode.
|
|
492
|
+
* Takes precedence over allowedTools.
|
|
493
|
+
*/
|
|
494
|
+
blockedTools: string[];
|
|
495
|
+
/**
|
|
496
|
+
* If true, ALL tools are blocked regardless of other settings.
|
|
497
|
+
* Shorthand for "no tool calls at all".
|
|
498
|
+
*/
|
|
499
|
+
blockAllTools: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Whether to auto-inject relevant skill content into the system prompt
|
|
502
|
+
* via BM25 matching of the user's message (skill interceptor).
|
|
503
|
+
* Default: false — opt-in only. Set to true to enable auto-injection.
|
|
504
|
+
*/
|
|
505
|
+
skillInterceptor?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Root directory for rule files.
|
|
508
|
+
* Auto-discovers:
|
|
509
|
+
* <rulesDir>/__global__/ → injected for all modes sharing this dir
|
|
510
|
+
* <rulesDir>/<mode-name>/ → injected for this mode only
|
|
511
|
+
* Defaults to '.toolpack/rules' if not set.
|
|
512
|
+
*/
|
|
513
|
+
rulesDir?: string;
|
|
514
|
+
/**
|
|
515
|
+
* When true, agent runs use provider.stream() instead of provider.generate().
|
|
516
|
+
* Keeps the TCP connection alive via incremental chunks, preventing NAT/proxy
|
|
517
|
+
* idle timeouts on long-running LLM calls (e.g. browser agent with large context).
|
|
518
|
+
*/
|
|
519
|
+
streaming?: boolean;
|
|
520
|
+
/**
|
|
521
|
+
* Response format constraint for all requests in this mode.
|
|
522
|
+
* - 'json_object': instructs the model to return valid JSON as its text content.
|
|
523
|
+
* Useful for evaluator/parser agents whose final response must be machine-readable.
|
|
524
|
+
* Tool-call rounds are unaffected — the model still returns functionCall parts
|
|
525
|
+
* normally; the format only applies to text content.
|
|
526
|
+
* - 'text' (default): plain text, no constraint.
|
|
527
|
+
*/
|
|
528
|
+
response_format?: 'text' | 'json_object';
|
|
529
|
+
/**
|
|
530
|
+
* Tools available only in this mode/agent.
|
|
531
|
+
* Resolved before the shared ToolRegistry — allows agent-specific tools
|
|
532
|
+
* without registering them globally.
|
|
533
|
+
*/
|
|
534
|
+
customTools?: ToolDefinition[];
|
|
535
|
+
/**
|
|
536
|
+
* Tool behavior overrides for this mode/agent.
|
|
537
|
+
* Merged over the Toolpack-level ToolsConfig at request time.
|
|
538
|
+
* Use for per-agent autoExecute, maxToolRounds, resultMaxChars, etc.
|
|
539
|
+
*/
|
|
540
|
+
toolsConfig?: Partial<ToolsConfig>;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* A lightweight reference to a mode, used in tool-blocked hints.
|
|
544
|
+
*/
|
|
545
|
+
interface ModeBlockedHint {
|
|
546
|
+
blockedToolNames: string[];
|
|
547
|
+
suggestedMode: string;
|
|
548
|
+
}
|
|
549
|
+
|
|
446
550
|
type Role = 'system' | 'user' | 'assistant' | 'tool';
|
|
447
551
|
interface TextPart {
|
|
448
552
|
type: 'text';
|
|
@@ -526,7 +630,8 @@ interface RequestToolDefinition {
|
|
|
526
630
|
description: string;
|
|
527
631
|
parameters: Record<string, any>;
|
|
528
632
|
category: string;
|
|
529
|
-
execute
|
|
633
|
+
/** Same optional `ctx` as ToolDefinition.execute — per-tenant credentials/runtime scoping. */
|
|
634
|
+
execute: (args: Record<string, any>, ctx?: ToolContext) => Promise<any>;
|
|
530
635
|
cacheable?: boolean;
|
|
531
636
|
confirmation?: ToolConfirmation;
|
|
532
637
|
}
|
|
@@ -990,6 +1095,27 @@ declare abstract class ProviderAdapter {
|
|
|
990
1095
|
countTokens(_messages: Message[], _model: string): Promise<number | null>;
|
|
991
1096
|
}
|
|
992
1097
|
|
|
1098
|
+
interface CloneEntry {
|
|
1099
|
+
cloneDir: string;
|
|
1100
|
+
repo: string;
|
|
1101
|
+
sha: string;
|
|
1102
|
+
sizeBytes: number;
|
|
1103
|
+
lastAccessedAt: number;
|
|
1104
|
+
}
|
|
1105
|
+
declare class CloneState {
|
|
1106
|
+
readonly registry: Map<string, CloneEntry>;
|
|
1107
|
+
readonly mutexes: Map<string, Promise<void>>;
|
|
1108
|
+
totalBytes: number;
|
|
1109
|
+
acquireMutex(repo: string): Promise<() => void>;
|
|
1110
|
+
evictIfNeeded(requiredBytes: number, maxBytes: number): Promise<void>;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
declare class ToolRuntimeContext {
|
|
1114
|
+
readonly processRegistry: ProcessRegistry;
|
|
1115
|
+
readonly cloneState: CloneState;
|
|
1116
|
+
readonly githubTokenStore: GithubTokenStore;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
993
1119
|
/**
|
|
994
1120
|
* Central registry for all tools (built-in + custom).
|
|
995
1121
|
* Handles registration, lookup, filtering by category, schema extraction,
|
|
@@ -999,6 +1125,8 @@ declare class ToolRegistry {
|
|
|
999
1125
|
private tools;
|
|
1000
1126
|
private projects;
|
|
1001
1127
|
private config;
|
|
1128
|
+
/** Scoped runtime state created by loadBuiltIn(). Undefined when built-in tools are not loaded. */
|
|
1129
|
+
runtimeContext?: ToolRuntimeContext;
|
|
1002
1130
|
/**
|
|
1003
1131
|
* Register a tool (built-in or custom).
|
|
1004
1132
|
*/
|
|
@@ -1151,7 +1279,11 @@ interface ToolpackConfig {
|
|
|
1151
1279
|
/** Context window management configuration for automatic conversation pruning/summarization */
|
|
1152
1280
|
contextWindow?: ContextWindowConfig;
|
|
1153
1281
|
}
|
|
1282
|
+
/**
|
|
1283
|
+
* @deprecated Pass config directly to Toolpack.init(). File-based config is no longer read by the SDK.
|
|
1284
|
+
*/
|
|
1154
1285
|
declare function getToolpackConfig(configPath?: string): ToolpackConfig;
|
|
1286
|
+
/** @deprecated No-op. The process-global config cache has been removed. */
|
|
1155
1287
|
declare function reloadToolpackConfig(): void;
|
|
1156
1288
|
interface OllamaProviderEntry {
|
|
1157
1289
|
/** Provider type key, e.g. 'ollama-llama3' */
|
|
@@ -1253,11 +1385,12 @@ declare class AIClient extends EventEmitter {
|
|
|
1253
1385
|
private toolResultMaxChars;
|
|
1254
1386
|
private hitlConfig?;
|
|
1255
1387
|
private onToolConfirm?;
|
|
1256
|
-
private currentRound;
|
|
1257
1388
|
private conversationId?;
|
|
1258
1389
|
private contextWindowConfig?;
|
|
1259
1390
|
private contextWindowStateManager?;
|
|
1260
1391
|
private providerModelCache;
|
|
1392
|
+
private ruleLoader;
|
|
1393
|
+
private requestSeq;
|
|
1261
1394
|
constructor(config: AIClientConfig);
|
|
1262
1395
|
private getConversationId;
|
|
1263
1396
|
private getModelInfo;
|
|
@@ -1360,6 +1493,7 @@ declare class AIClient extends EventEmitter {
|
|
|
1360
1493
|
* tool loop is immune to concurrent `setMode()` calls on this instance.
|
|
1361
1494
|
*/
|
|
1362
1495
|
private enrichRequestWithTools;
|
|
1496
|
+
private toolDefinitionsToSchemas;
|
|
1363
1497
|
private buildRequestToolMap;
|
|
1364
1498
|
private requestToolToSchema;
|
|
1365
1499
|
private mergeSchemas;
|
|
@@ -1377,6 +1511,7 @@ declare class AIClient extends EventEmitter {
|
|
|
1377
1511
|
* owns the mode registry) before reaching the client; if an unresolved
|
|
1378
1512
|
* name gets here, warn and fall back to the activeMode snapshot
|
|
1379
1513
|
*/
|
|
1514
|
+
private newRequestId;
|
|
1380
1515
|
private resolveRequestMode;
|
|
1381
1516
|
/**
|
|
1382
1517
|
* Filter tool schemas based on mode permissions.
|
|
@@ -1388,6 +1523,12 @@ declare class AIClient extends EventEmitter {
|
|
|
1388
1523
|
* For the "All" mode (empty systemPrompt), this is a no-op.
|
|
1389
1524
|
*/
|
|
1390
1525
|
private injectModeSystemPrompt;
|
|
1526
|
+
/**
|
|
1527
|
+
* Load and append rule content to the system prompt for the active mode.
|
|
1528
|
+
* Rules are always injected — appended after the mode system prompt so they
|
|
1529
|
+
* sit closest to the conversation (recency effect).
|
|
1530
|
+
*/
|
|
1531
|
+
private injectModeRules;
|
|
1391
1532
|
/**
|
|
1392
1533
|
* Inject the overriding system prompt (from AIClientConfig) into the request.
|
|
1393
1534
|
*/
|
|
@@ -1464,6 +1605,27 @@ declare class AnthropicAdapter extends ProviderAdapter {
|
|
|
1464
1605
|
private handleError;
|
|
1465
1606
|
}
|
|
1466
1607
|
|
|
1608
|
+
interface AnthropicVertexConfig {
|
|
1609
|
+
/** GCP project ID. Falls back to ANTHROPIC_VERTEX_PROJECT_ID / GOOGLE_CLOUD_PROJECT env vars. */
|
|
1610
|
+
projectId?: string;
|
|
1611
|
+
/** GCP region where Claude models are deployed. Defaults to 'us-east5'. */
|
|
1612
|
+
region?: string;
|
|
1613
|
+
}
|
|
1614
|
+
declare class AnthropicVertexAdapter extends ProviderAdapter {
|
|
1615
|
+
private client;
|
|
1616
|
+
constructor(config?: AnthropicVertexConfig);
|
|
1617
|
+
getDisplayName(): string;
|
|
1618
|
+
getModels(): Promise<ProviderModelInfo[]>;
|
|
1619
|
+
generate(request: CompletionRequest): Promise<CompletionResponse>;
|
|
1620
|
+
stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
|
|
1621
|
+
embed(_request: EmbeddingRequest): Promise<EmbeddingResponse>;
|
|
1622
|
+
private sanitizeToolName;
|
|
1623
|
+
private restoreToolName;
|
|
1624
|
+
private toAnthropicMessages;
|
|
1625
|
+
private mapFinishReason;
|
|
1626
|
+
private handleError;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1467
1629
|
interface VertexAIConfig {
|
|
1468
1630
|
/** GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT or VERTEX_AI_PROJECT env vars. */
|
|
1469
1631
|
projectId?: string;
|
|
@@ -1480,10 +1642,19 @@ interface VertexAIConfig {
|
|
|
1480
1642
|
/** Inline service account credentials object. */
|
|
1481
1643
|
credentials?: Record<string, unknown>;
|
|
1482
1644
|
};
|
|
1645
|
+
/**
|
|
1646
|
+
* Thinking token budget for Gemini 2.5+ models.
|
|
1647
|
+
* Set to 0 to disable thinking entirely.
|
|
1648
|
+
* Omit to use the model's default budget.
|
|
1649
|
+
*/
|
|
1650
|
+
thinkingBudget?: number;
|
|
1483
1651
|
}
|
|
1484
1652
|
declare class VertexAIAdapter extends ProviderAdapter {
|
|
1485
1653
|
private ai;
|
|
1486
1654
|
private readonly location;
|
|
1655
|
+
private readonly thinkingBudget?;
|
|
1656
|
+
private readonly rawContentCache;
|
|
1657
|
+
private static readonly RAW_CONTENT_CACHE_MAX;
|
|
1487
1658
|
constructor(config?: VertexAIConfig);
|
|
1488
1659
|
getDisplayName(): string;
|
|
1489
1660
|
getModels(): Promise<ProviderModelInfo[]>;
|
|
@@ -2107,11 +2278,13 @@ interface FullConfig {
|
|
|
2107
2278
|
/**
|
|
2108
2279
|
* Load the full config from toolpack.config.json.
|
|
2109
2280
|
* Returns the entire parsed config object.
|
|
2281
|
+
* @deprecated Pass config directly to Toolpack.init(). File-based config is no longer read by the SDK.
|
|
2110
2282
|
*/
|
|
2111
2283
|
declare function loadFullConfig(basePath?: string): FullConfig;
|
|
2112
2284
|
/**
|
|
2113
2285
|
* Load tools config from toolpack.config.json (tools section).
|
|
2114
2286
|
* Falls back to defaults if the file doesn't exist or tools section is missing.
|
|
2287
|
+
* @deprecated Pass toolsConfig directly to Toolpack.init(). File-based config is no longer read by the SDK.
|
|
2115
2288
|
*/
|
|
2116
2289
|
declare function loadToolsConfig(basePath?: string): ToolsConfig;
|
|
2117
2290
|
/**
|
|
@@ -2501,6 +2674,22 @@ declare function createMode(config: {
|
|
|
2501
2674
|
enabled: boolean;
|
|
2502
2675
|
};
|
|
2503
2676
|
};
|
|
2677
|
+
/**
|
|
2678
|
+
* Enable auto-injection of BM25-matched skill content into the system prompt.
|
|
2679
|
+
* Default: false — opt-in only.
|
|
2680
|
+
*/
|
|
2681
|
+
skillInterceptor?: boolean;
|
|
2682
|
+
/**
|
|
2683
|
+
* Root directory for rule files for this mode.
|
|
2684
|
+
* Auto-discovers __global__/ and <mode-name>/ subfolders within it.
|
|
2685
|
+
* Defaults to '.toolpack/rules' if not set.
|
|
2686
|
+
*/
|
|
2687
|
+
rulesDir?: string;
|
|
2688
|
+
/**
|
|
2689
|
+
* When true, agent runs use provider.stream() instead of provider.generate().
|
|
2690
|
+
* Prevents NAT/proxy idle timeouts on long-running LLM calls.
|
|
2691
|
+
*/
|
|
2692
|
+
streaming?: boolean;
|
|
2504
2693
|
}): ModeConfig;
|
|
2505
2694
|
|
|
2506
2695
|
/**
|
|
@@ -2679,6 +2868,18 @@ declare const CODING_WORKFLOW: WorkflowConfig;
|
|
|
2679
2868
|
*/
|
|
2680
2869
|
declare const CHAT_WORKFLOW: WorkflowConfig;
|
|
2681
2870
|
|
|
2871
|
+
type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
2872
|
+
interface LoggingConfig {
|
|
2873
|
+
/** Enable file logging. Default: false */
|
|
2874
|
+
enabled?: boolean;
|
|
2875
|
+
/** Log file path. Default: '<cwd>/toolpack-sdk.log' */
|
|
2876
|
+
filePath?: string;
|
|
2877
|
+
/** Log level. Default: 'info' */
|
|
2878
|
+
level?: LogLevel;
|
|
2879
|
+
/** Mirror log output to console (stderr for error/warn, stdout for others). Default: false */
|
|
2880
|
+
console?: boolean;
|
|
2881
|
+
}
|
|
2882
|
+
|
|
2682
2883
|
type ToolpackNextFunction = (request?: CompletionRequest) => Promise<CompletionResponse>;
|
|
2683
2884
|
/**
|
|
2684
2885
|
* An interceptor that wraps each `generate()` call.
|
|
@@ -2925,6 +3126,10 @@ interface ProviderOptions {
|
|
|
2925
3126
|
keyFilename?: string;
|
|
2926
3127
|
credentials?: Record<string, unknown>;
|
|
2927
3128
|
};
|
|
3129
|
+
/** Vertex AI only: thinking token budget for Gemini 2.5+ models. Set to 0 to disable thinking. */
|
|
3130
|
+
thinkingBudget?: number;
|
|
3131
|
+
/** Anthropic Vertex only: GCP region where Claude models are deployed. Defaults to 'us-east5'. */
|
|
3132
|
+
region?: string;
|
|
2928
3133
|
}
|
|
2929
3134
|
interface ToolpackInitConfig {
|
|
2930
3135
|
/** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
|
|
@@ -2945,12 +3150,19 @@ interface ToolpackInitConfig {
|
|
|
2945
3150
|
keyFilename?: string;
|
|
2946
3151
|
credentials?: Record<string, unknown>;
|
|
2947
3152
|
};
|
|
3153
|
+
/** Vertex AI only: thinking token budget for Gemini 2.5+ models. Set to 0 to disable thinking. */
|
|
3154
|
+
thinkingBudget?: number;
|
|
3155
|
+
/** Anthropic Vertex only: GCP region where Claude models are deployed. Defaults to 'us-east5'. */
|
|
3156
|
+
region?: string;
|
|
2948
3157
|
/** Load built-in tools (fs, http, etc.)? Default: false */
|
|
2949
3158
|
tools?: boolean;
|
|
2950
3159
|
/** Context window management configuration for automatic conversation pruning/summarization */
|
|
2951
3160
|
contextWindow?: ContextWindowConfig;
|
|
2952
|
-
/**
|
|
2953
|
-
|
|
3161
|
+
/**
|
|
3162
|
+
* Tool runtime configuration (autoExecute, maxToolRounds, additionalConfigurations, etc.).
|
|
3163
|
+
* Merged over DEFAULT_TOOLS_CONFIG. Use ModeConfig.toolsConfig for per-agent overrides.
|
|
3164
|
+
*/
|
|
3165
|
+
toolsConfig?: Partial<ToolsConfig>;
|
|
2954
3166
|
/** Multi-provider config (overrides single provider settings) */
|
|
2955
3167
|
providers?: Record<string, ProviderOptions>;
|
|
2956
3168
|
/** Default provider to use if multiple are configured */
|
|
@@ -2959,8 +3171,6 @@ interface ToolpackInitConfig {
|
|
|
2959
3171
|
customModes?: ModeConfig[];
|
|
2960
3172
|
/** Default mode to activate on init (default: 'default') */
|
|
2961
3173
|
defaultMode?: string;
|
|
2962
|
-
/** Optional system prompt overrides for specific modes */
|
|
2963
|
-
modeOverrides?: Record<string, Partial<ModeConfig>>;
|
|
2964
3174
|
/**
|
|
2965
3175
|
* Custom provider adapter instances.
|
|
2966
3176
|
* Can be:
|
|
@@ -2970,11 +3180,6 @@ interface ToolpackInitConfig {
|
|
|
2970
3180
|
customProviders?: ProviderAdapter[] | Record<string, ProviderAdapter>;
|
|
2971
3181
|
/** Disable base agent context injection (for testing or custom prompts) */
|
|
2972
3182
|
disableBaseContext?: boolean;
|
|
2973
|
-
/**
|
|
2974
|
-
* Optional path to a configuration file.
|
|
2975
|
-
* If provided, the SDK will load configuration from this path instead of the default toolpack.config.json in the current working directory.
|
|
2976
|
-
*/
|
|
2977
|
-
configPath?: string;
|
|
2978
3183
|
mcp?: McpToolsConfig;
|
|
2979
3184
|
/**
|
|
2980
3185
|
* Optional Knowledge instance for RAG (Retrieval-Augmented Generation).
|
|
@@ -3010,6 +3215,16 @@ interface ToolpackInitConfig {
|
|
|
3010
3215
|
* The workflow execution path (when a mode has planning enabled) is also unaffected.
|
|
3011
3216
|
*/
|
|
3012
3217
|
interceptors?: ToolpackInterceptor[];
|
|
3218
|
+
/**
|
|
3219
|
+
* Logging configuration. Takes precedence over any value in toolpack.config.json.
|
|
3220
|
+
* Env vars (TOOLPACK_SDK_LOG_ENABLED, TOOLPACK_SDK_LOG_FILE, etc.) still override this.
|
|
3221
|
+
*/
|
|
3222
|
+
logging?: LoggingConfig;
|
|
3223
|
+
/**
|
|
3224
|
+
* Human-in-the-loop configuration. Takes precedence over any value in toolpack.config.json.
|
|
3225
|
+
* Merged with confirmationMode and onToolConfirm — the most-specific setting wins.
|
|
3226
|
+
*/
|
|
3227
|
+
hitl?: HitlConfig;
|
|
3013
3228
|
}
|
|
3014
3229
|
/**
|
|
3015
3230
|
* Duck-typed interface for Knowledge instances to avoid circular dependency
|
|
@@ -3726,4 +3941,16 @@ interface McpServerCapabilities {
|
|
|
3726
3941
|
|
|
3727
3942
|
declare function createSkillInterceptor(options?: SkillInterceptorOptions): ToolpackInterceptor;
|
|
3728
3943
|
|
|
3729
|
-
|
|
3944
|
+
declare class RuleLoader {
|
|
3945
|
+
private readonly cacheTtlMs;
|
|
3946
|
+
private modeCache;
|
|
3947
|
+
constructor(cacheTtlMs?: number);
|
|
3948
|
+
loadForMode(modeName: string, rulesDir?: string): Promise<string>;
|
|
3949
|
+
/** Evict all cached entries — useful in tests or after a known rule file change. */
|
|
3950
|
+
clearCache(): void;
|
|
3951
|
+
private collectFromFolder;
|
|
3952
|
+
private collectRecursive;
|
|
3953
|
+
private readFile;
|
|
3954
|
+
}
|
|
3955
|
+
|
|
3956
|
+
export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, type AddBypassRuleOptions, AnthropicAdapter, AnthropicVertexAdapter, type AnthropicVertexConfig, type AssembledPrompt, type AssemblerOptions, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, type BypassRuleType, CHAT_MODE, CHAT_WORKFLOW, CODING_MODE, CODING_PLANNING_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, type ConfirmationDecision, type ConfirmationLevel$1 as ConfirmationLevel, ConnectionError, type ContextPrunedEvent, type ContextWindowConfig, ContextWindowConfigError, ContextWindowExceededError, type ContextWindowExceededEvent, type ContextWindowState, ContextWindowStateManager, type ContextWindowStrategy, type ContextWindowWarningEvent, ConversationNotFoundError, type ConversationScope, type ConversationSearchOptions, type ConversationStore, type ConversationSummarizedEvent, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type GetOptions, type HitlConfig, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, InMemoryConversationStore, type InMemoryConversationStoreConfig, InsufficientContextError, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, type McpAgentDefinition, type McpAuthConfig, McpClient, type McpClientConfig, McpConnectionError, type McpCustomAuthConfig, type McpJwtAuthConfig, type McpServerCapabilities, type McpServerConfig, type McpServerExposeConfig, type McpServerHandle, type McpStaticAuthConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type McpTransport, 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, RuleLoader, type RuntimeConfigStatus, SDKError, SQLiteConversationStore, type SQLiteConversationStoreConfig, type SearchHistoryEntry, type SearchOptions, type SearchResult, type Skill, type SkillInterceptorOptions, type SkillSection, type SkillToolsOptions, type SkillValidationMode, type SlmModelEntry, type StoredMessage, SummarizationError, type SummarizationOptions, type SummarizationResult, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolAnnotations, 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 ToolpackCredentials, type ToolpackInitConfig, type ToolpackInterceptor, type ToolpackMcpServerConfig, type ToolpackNextFunction, type ToolsConfig, type Usage, VertexAIAdapter, type VertexAIConfig, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, addBypassRule, buildSummarizedHistory, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingExtractFunctionTool, codingFindReferencesTool, codingFindSymbolTool, codingGetCallHierarchyTool, codingGetDiagnosticsTool, codingGetExportsTool, codingGetImportsTool, codingGetOutlineTool, codingGetSymbolsTool, codingGoToDefinitionTool, codingMultiFileEditTool, codingRefactorRenameTool, codingToolsProject, countTokens, createContextWindowStateManager, createMcpToolProject, createMode, createSkillInterceptor, createSkillTools, createSummarizationReport, createSummarySystemMessage, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, estimateSummaryTokens, estimateTokenCount, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunBlockingTool, execRunShellTool, execRunTool, execTailOutputTool, execToolsProject, extractConversationKeypoints, fetchUrlAsBase64, fsAppendFileTool, fsBatchReadTool, fsBatchWriteTool, fsCopyTool, fsCreateDirTool, fsDeleteDirTool, fsDeleteFileTool, fsExistsTool, fsGlobTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateSummarizationPrompt, generateToolCategoriesPrompt, getContextWindowPercentage, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMessageStats, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getSafeOutputReserve, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCloneTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, githubContentsGetTextTool, githubGraphqlExecuteTool, githubIssuesCommentsCreateTool, githubPrDiffGetTool, githubPrFilesListTool, githubPrReviewCommentsReplyTool, githubPrReviewThreadsListTool, githubPrReviewThreadsResolveTool, githubPrReviewsSubmitTool, githubToolsProject, groupMessagesByRole, handleContextWindowError, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isContextWindowError, isDataUri, isRegisteredSlm, isToolSearchTool, k8sApplyManifestTool, k8sDeleteResourceTool, k8sDescribeTool, k8sGetConfigMapTool, k8sGetLogsTool, k8sGetNamespacesTool, k8sListDeploymentsTool, k8sListPodsTool, k8sListServicesTool, k8sSwitchContextTool, k8sToolsProject, k8sWaitForDeploymentTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, mergeSummarizationResults, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, parseSummarizationResponse, prepareSummarizationRequest, pruneMessages, readFileAsBase64, reloadToolpackConfig, removeBypassRule, saveToolsConfig, slackAuthTestTool, slackChatPostEphemeralTool, slackChatPostMessageTool, slackConversationsHistoryTool, slackConversationsRepliesTool, slackReactionsAddTool, slackToolsProject, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, truncateMessage, validateSummarizationResult, webExtractLinksTool, webFeedTool, webFetchTool, webMapTool, webMetadataTool, webScrapeTool, webScreenshotTool, webSearchTool, webSitemapTool, webToolsProject, wouldExceedContextWindow };
|