toolpack-sdk 2.0.0-alpha.1 → 2.1.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
@@ -104,13 +104,6 @@ interface ToolCategory {
104
104
  description: string;
105
105
  tools: string[];
106
106
  }
107
- /**
108
- * @deprecated This interface is deprecated and will be removed in a future version.
109
- */
110
- interface IntelligentToolDetectionConfig {
111
- enabled: boolean;
112
- maxFollowUpMessages: number;
113
- }
114
107
  /**
115
108
  * Tool Search Configuration (Anthropic-style on-demand tool discovery)
116
109
  */
@@ -127,10 +120,6 @@ interface ToolsConfig {
127
120
  maxToolRounds: number;
128
121
  toolChoicePolicy?: 'auto' | 'required' | 'required_for_actions';
129
122
  resultMaxChars?: number;
130
- /**
131
- * @deprecated This feature is deprecated and will be removed in a future version. Use `toolSearch` instead.
132
- */
133
- intelligentToolDetection?: IntelligentToolDetectionConfig;
134
123
  enabledTools: string[];
135
124
  enabledToolCategories: string[];
136
125
  toolSearch?: ToolSearchConfig;
@@ -253,6 +242,13 @@ interface CompletionRequest {
253
242
  signal?: AbortSignal;
254
243
  /** Multimodal media handling options */
255
244
  mediaOptions?: MediaOptions;
245
+ /**
246
+ * Per-request hard cap on tool-call rounds.
247
+ * When set, overrides ToolsConfig.maxToolRounds and bypasses the query
248
+ * classifier adjustment for this specific request.
249
+ * Useful for agents that should only ever make one tool call (e.g. routers).
250
+ */
251
+ maxToolRounds?: number;
256
252
  }
257
253
  interface Usage {
258
254
  prompt_tokens: number;
@@ -824,24 +820,6 @@ interface WorkflowConfig {
824
820
  /** Maximum number of steps allowed in a plan. Default: 20 */
825
821
  maxSteps?: number;
826
822
  };
827
- /**
828
- * Step-based execution configuration.
829
- * If enabled, tasks are broken into steps and executed sequentially.
830
- */
831
- steps?: {
832
- /** Enable step-based execution. Default: false */
833
- enabled: boolean;
834
- /** Retry failed steps. Default: true */
835
- retryOnFailure?: boolean;
836
- /** Maximum retry attempts per step. Default: 3 */
837
- maxRetries?: number;
838
- /** Allow adding/modifying steps during execution. Default: true */
839
- allowDynamicSteps?: boolean;
840
- /** Maximum total steps (including dynamic). Default: 50 */
841
- maxTotalSteps?: number;
842
- /** Custom step execution prompt. Default: uses built-in STEP_EXECUTION_PROMPT */
843
- stepPrompt?: string;
844
- };
845
823
  /**
846
824
  * Progress reporting configuration.
847
825
  */
@@ -851,13 +829,6 @@ interface WorkflowConfig {
851
829
  /** Report estimated completion percentage. Default: true */
852
830
  reportPercentage?: boolean;
853
831
  };
854
- /**
855
- * Failure handling configuration.
856
- */
857
- onFailure?: {
858
- /** Strategy when a step fails after all retries. Default: 'abort' */
859
- strategy: 'abort' | 'skip' | 'ask_user';
860
- };
861
832
  /**
862
833
  * Query complexity routing configuration.
863
834
  * Routes simple queries to faster execution paths based on query classification.
@@ -872,7 +843,7 @@ interface WorkflowConfig {
872
843
  };
873
844
  }
874
845
  /**
875
- * Default workflow config (direct execution, no planning/steps).
846
+ * Default workflow config (direct execution, no planning).
876
847
  */
877
848
  declare const DEFAULT_WORKFLOW_CONFIG: WorkflowConfig;
878
849
  interface WorkflowEvents {
@@ -882,16 +853,6 @@ interface WorkflowEvents {
882
853
  'workflow:plan_decision': (plan: Plan, approved: boolean) => void;
883
854
  /** Emitted when plan execution starts */
884
855
  'workflow:started': (plan: Plan) => void;
885
- /** Emitted when a step starts */
886
- 'workflow:step_start': (step: PlanStep, plan: Plan) => void;
887
- /** Emitted when a step completes successfully */
888
- 'workflow:step_complete': (step: PlanStep, plan: Plan) => void;
889
- /** Emitted when a step fails */
890
- 'workflow:step_failed': (step: PlanStep, error: Error, plan: Plan) => void;
891
- /** Emitted when a step is retried */
892
- 'workflow:step_retry': (step: PlanStep, attempt: number, plan: Plan) => void;
893
- /** Emitted when a new step is dynamically added */
894
- 'workflow:step_added': (step: PlanStep, plan: Plan) => void;
895
856
  /** Emitted for progress updates */
896
857
  'workflow:progress': (progress: WorkflowProgress) => void;
897
858
  /** Emitted when context window usage is high (approaching limit) */
@@ -1030,6 +991,15 @@ interface ModeConfig {
1030
991
  * Shorthand for "no tool calls at all".
1031
992
  */
1032
993
  blockAllTools: boolean;
994
+ /**
995
+ * Response format constraint for all requests in this mode.
996
+ * - 'json_object': instructs the model to return valid JSON as its text content.
997
+ * Useful for evaluator/parser agents whose final response must be machine-readable.
998
+ * Tool-call rounds are unaffected — the model still returns functionCall parts
999
+ * normally; the format only applies to text content.
1000
+ * - 'text' (default): plain text, no constraint.
1001
+ */
1002
+ response_format?: 'text' | 'json_object';
1033
1003
  }
1034
1004
  /**
1035
1005
  * A lightweight reference to a mode, used in tool-blocked hints.
@@ -1346,6 +1316,12 @@ declare class AIClient extends EventEmitter {
1346
1316
  */
1347
1317
  private executeToolSearch;
1348
1318
  private wrapError;
1319
+ /**
1320
+ * Truncate a tool result to fit within the remaining round budget.
1321
+ * Instead of silently dropping the output, include as much content as possible
1322
+ * and append an actionable hint so the LLM can retry with a narrower query.
1323
+ */
1324
+ private budgetTruncate;
1349
1325
  }
1350
1326
 
1351
1327
  declare class AnthropicAdapter extends ProviderAdapter {
@@ -1384,6 +1360,43 @@ declare class AnthropicAdapter extends ProviderAdapter {
1384
1360
  private handleError;
1385
1361
  }
1386
1362
 
1363
+ interface VertexAIConfig {
1364
+ /** GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT or VERTEX_AI_PROJECT env vars. */
1365
+ projectId?: string;
1366
+ /** GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION or VERTEX_AI_LOCATION env vars. */
1367
+ location?: string;
1368
+ /**
1369
+ * Optional Google Auth options.
1370
+ * When omitted, Application Default Credentials (ADC) are used automatically.
1371
+ * Set GOOGLE_APPLICATION_CREDENTIALS env var to point to a service account JSON file.
1372
+ */
1373
+ googleAuthOptions?: {
1374
+ /** Path to a service account key JSON file. */
1375
+ keyFilename?: string;
1376
+ /** Inline service account credentials object. */
1377
+ credentials?: Record<string, unknown>;
1378
+ };
1379
+ }
1380
+ declare class VertexAIAdapter extends ProviderAdapter {
1381
+ private ai;
1382
+ private readonly location;
1383
+ constructor(config?: VertexAIConfig);
1384
+ getDisplayName(): string;
1385
+ getModels(): Promise<ProviderModelInfo[]>;
1386
+ generate(request: CompletionRequest): Promise<CompletionResponse>;
1387
+ stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
1388
+ embed(_request: EmbeddingRequest): Promise<EmbeddingResponse>;
1389
+ private buildRequestParams;
1390
+ private formatHistory;
1391
+ private contentToParts;
1392
+ private parseResponse;
1393
+ private extractSystemInstruction;
1394
+ private sanitizeToolName;
1395
+ private restoreToolName;
1396
+ private sanitizeSchema;
1397
+ private handleError;
1398
+ }
1399
+
1387
1400
  declare class GeminiAdapter extends ProviderAdapter {
1388
1401
  private genAI;
1389
1402
  constructor(apiKey: string);
@@ -2043,6 +2056,14 @@ declare const fsReplaceInFileTool: ToolDefinition;
2043
2056
 
2044
2057
  declare const fsTreeTool: ToolDefinition;
2045
2058
 
2059
+ declare const fsGlobTool: ToolDefinition;
2060
+
2061
+ declare const fsDeleteDirTool: ToolDefinition;
2062
+
2063
+ declare const fsBatchReadTool: ToolDefinition;
2064
+
2065
+ declare const fsBatchWriteTool: ToolDefinition;
2066
+
2046
2067
  declare const fsToolsProject: ToolProject;
2047
2068
 
2048
2069
  declare const execRunTool: ToolDefinition;
@@ -2099,6 +2120,8 @@ declare const githubPrFilesListTool: ToolDefinition;
2099
2120
 
2100
2121
  declare const githubPrReviewsSubmitTool: ToolDefinition;
2101
2122
 
2123
+ declare const githubIssuesCommentsCreateTool: ToolDefinition;
2124
+
2102
2125
  declare const githubToolsProject: ToolProject;
2103
2126
 
2104
2127
  declare const webFetchTool: ToolDefinition;
@@ -2109,6 +2132,16 @@ declare const webScrapeTool: ToolDefinition;
2109
2132
 
2110
2133
  declare const webExtractLinksTool: ToolDefinition;
2111
2134
 
2135
+ declare const webMapTool: ToolDefinition;
2136
+
2137
+ declare const webMetadataTool: ToolDefinition;
2138
+
2139
+ declare const webSitemapTool: ToolDefinition;
2140
+
2141
+ declare const webFeedTool: ToolDefinition;
2142
+
2143
+ declare const webScreenshotTool: ToolDefinition;
2144
+
2112
2145
  declare const webToolsProject: ToolProject;
2113
2146
 
2114
2147
  declare const codingFindSymbolTool: ToolDefinition;
@@ -2117,6 +2150,24 @@ declare const codingGetSymbolsTool: ToolDefinition;
2117
2150
 
2118
2151
  declare const codingGetImportsTool: ToolDefinition;
2119
2152
 
2153
+ declare const codingFindReferencesTool: ToolDefinition;
2154
+
2155
+ declare const codingGoToDefinitionTool: ToolDefinition;
2156
+
2157
+ declare const codingMultiFileEditTool: ToolDefinition;
2158
+
2159
+ declare const codingRefactorRenameTool: ToolDefinition;
2160
+
2161
+ declare const codingGetOutlineTool: ToolDefinition;
2162
+
2163
+ declare const codingGetDiagnosticsTool: ToolDefinition;
2164
+
2165
+ declare const codingGetExportsTool: ToolDefinition;
2166
+
2167
+ declare const codingExtractFunctionTool: ToolDefinition;
2168
+
2169
+ declare const codingGetCallHierarchyTool: ToolDefinition;
2170
+
2120
2171
  declare const codingToolsProject: ToolProject;
2121
2172
 
2122
2173
  declare const gitStatusTool: ToolDefinition;
@@ -2137,6 +2188,8 @@ declare const gitBranchCreateTool: ToolDefinition;
2137
2188
 
2138
2189
  declare const gitCheckoutTool: ToolDefinition;
2139
2190
 
2191
+ declare const gitCloneTool: ToolDefinition;
2192
+
2140
2193
  declare const gitToolsProject: ToolProject;
2141
2194
 
2142
2195
  declare const diffCreateTool: ToolDefinition;
@@ -2185,6 +2238,56 @@ declare const k8sWaitForDeploymentTool: ToolDefinition;
2185
2238
 
2186
2239
  declare const k8sToolsProject: ToolProject;
2187
2240
 
2241
+ declare const slackChatPostMessageTool: ToolDefinition;
2242
+
2243
+ declare const slackChatPostEphemeralTool: ToolDefinition;
2244
+
2245
+ declare const slackReactionsAddTool: ToolDefinition;
2246
+
2247
+ declare const slackConversationsHistoryTool: ToolDefinition;
2248
+
2249
+ declare const slackConversationsRepliesTool: ToolDefinition;
2250
+
2251
+ declare const slackAuthTestTool: ToolDefinition;
2252
+
2253
+ declare const slackToolsProject: ToolProject;
2254
+
2255
+ type SkillSection = 'description' | 'triggers' | 'instructions' | 'examples' | 'metadata' | 'all';
2256
+ type SkillValidationMode = 'fail' | 'warn';
2257
+ interface Skill {
2258
+ name: string;
2259
+ title: string;
2260
+ version?: string;
2261
+ tags: string[];
2262
+ category?: string;
2263
+ filePath: string;
2264
+ description: string;
2265
+ triggers: string[];
2266
+ instructions: string;
2267
+ examples?: string;
2268
+ lastModified: number;
2269
+ }
2270
+ interface SkillInterceptorOptions {
2271
+ dir?: string;
2272
+ maxSkills?: number;
2273
+ minScore?: number;
2274
+ onValidationError?: SkillValidationMode;
2275
+ }
2276
+ interface SkillToolsOptions {
2277
+ /** Skills directory. Default: '.toolpack/skills' */
2278
+ dir?: string;
2279
+ }
2280
+
2281
+ /**
2282
+ * Creates a ToolProject with 4 skill management tools: create, read, update, list.
2283
+ *
2284
+ * @example
2285
+ * ```ts
2286
+ * const skillTools = createSkillTools({ dir: '.toolpack/skills' });
2287
+ * ```
2288
+ */
2289
+ declare function createSkillTools(options?: SkillToolsOptions): ToolProject;
2290
+
2188
2291
  /**
2189
2292
  * Central registry for AI agent modes (built-in + custom).
2190
2293
  * Handles registration, lookup, cycling, and defaults.
@@ -2269,6 +2372,11 @@ declare function createMode(config: {
2269
2372
  blockedTools?: string[];
2270
2373
  /** If true, no tools at all (pure conversation). Default: false. */
2271
2374
  blockAllTools?: boolean;
2375
+ /**
2376
+ * Response format for all requests in this mode.
2377
+ * Use 'json_object' for evaluator/parser agents that must return valid JSON.
2378
+ */
2379
+ response_format?: 'text' | 'json_object';
2272
2380
  /** Base context configuration. Controls working directory and tool category injection. */
2273
2381
  baseContext?: {
2274
2382
  includeWorkingDirectory?: boolean;
@@ -2281,11 +2389,6 @@ declare function createMode(config: {
2281
2389
  enabled: boolean;
2282
2390
  requireApproval?: boolean;
2283
2391
  };
2284
- steps?: {
2285
- enabled: boolean;
2286
- retryOnFailure?: boolean;
2287
- allowDynamicSteps?: boolean;
2288
- };
2289
2392
  progress?: {
2290
2393
  enabled: boolean;
2291
2394
  };
@@ -2344,39 +2447,10 @@ declare class Planner {
2344
2447
  private createFallbackPlan;
2345
2448
  }
2346
2449
 
2347
- declare class StepExecutor {
2348
- private client;
2349
- private config?;
2350
- constructor(client: AIClient, config?: WorkflowConfig['steps']);
2351
- /**
2352
- * Executes a single step of the plan using the full tool loop.
2353
- */
2354
- executeStep(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): Promise<NonNullable<PlanStep['result']>>;
2355
- /**
2356
- * Stream a single step execution, yielding chunks as they come.
2357
- */
2358
- streamStep(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): AsyncGenerator<CompletionChunk>;
2359
- /**
2360
- * Build a context-aware request for a specific step, including previous step results
2361
- * as conversation history so the AI knows what work was already done.
2362
- */
2363
- private buildStepRequest;
2364
- /**
2365
- * Optional: Check if the AI wants to add steps dynamically based on what just happened.
2366
- */
2367
- checkForDynamicSteps(step: PlanStep, plan: Plan, baseRequest: CompletionRequest, providerName?: string): Promise<PlanStep[]>;
2368
- /**
2369
- * Normalize step description for duplicate detection.
2370
- * Strips common variations to catch semantically similar steps.
2371
- */
2372
- private normalizeStepDescription;
2373
- }
2374
-
2375
2450
  declare class WorkflowExecutor extends EventEmitter {
2376
2451
  private client;
2377
2452
  private config;
2378
2453
  private planner;
2379
- private stepExecutor;
2380
2454
  private queryClassifier;
2381
2455
  private pendingApprovals;
2382
2456
  constructor(client: AIClient, config: WorkflowConfig, queryClassifier?: QueryClassifier);
@@ -2395,6 +2469,10 @@ declare class WorkflowExecutor extends EventEmitter {
2395
2469
  private shouldRouteSimpleQuery;
2396
2470
  /**
2397
2471
  * Execute a request using the configured workflow.
2472
+ *
2473
+ * Modes:
2474
+ * - Direct: no planning — single generate() call
2475
+ * - Plan-direct: planning generates a roadmap, then executes in one generate() call
2398
2476
  */
2399
2477
  execute(request: CompletionRequest, providerName?: string): Promise<WorkflowResult>;
2400
2478
  /**
@@ -2406,39 +2484,31 @@ declare class WorkflowExecutor extends EventEmitter {
2406
2484
  */
2407
2485
  private createPlan;
2408
2486
  /**
2409
- * Execute plan step by step using the StepExecutor.
2410
- */
2411
- private executeStepByStep;
2412
- /**
2413
- * Planning without steps — execute plan as single generate call.
2487
+ * Planning without steps — inject plan as context prefix and execute in one generate() call.
2488
+ * The LLM sees its own roadmap and uses it to guide tool usage and sequencing.
2414
2489
  */
2415
2490
  private executePlanDirect;
2416
2491
  /**
2417
- * Emit a progress event using StepTracker.
2492
+ * Emit a progress event.
2493
+ * @param percentageOverride - Optional fixed percentage (0–100). Use for plan-direct
2494
+ * mode where steps complete atomically and intermediate step-level progress is unavailable.
2418
2495
  */
2419
2496
  private emitProgress;
2420
2497
  /**
2421
2498
  * Compute metrics for the plan.
2422
2499
  */
2423
2500
  private computeMetrics;
2424
- /**
2425
- * Summarize the entire plan execution.
2426
- */
2427
- private summarizePlanResult;
2428
- /**
2429
- * Extract the final output from the plan.
2430
- * For plans with synthesis step: returns last step output.
2431
- * For plans without synthesis: concatenates all step outputs.
2432
- */
2433
- private extractFinalOutput;
2434
- /**
2435
- * Extract the full response metadata from the last completed step.
2436
- */
2437
- private extractFinalResponse;
2438
2501
  /**
2439
2502
  * Create a dummy plan for internal representation when no plan is generated.
2440
2503
  */
2441
2504
  private createDummyPlan;
2505
+ /**
2506
+ * Inject plan context as a system message.
2507
+ * If the request already has a leading system message (e.g., a mode system prompt),
2508
+ * merge the plan context into it to avoid sending multiple system messages to providers
2509
+ * that don't support or handle them inconsistently.
2510
+ */
2511
+ private injectPlanContext;
2442
2512
  /**
2443
2513
  * Execute a request using the configured workflow, yielding chunks as they come.
2444
2514
  * This is the streaming equivalent of execute().
@@ -2449,11 +2519,8 @@ declare class WorkflowExecutor extends EventEmitter {
2449
2519
  */
2450
2520
  private streamDirect;
2451
2521
  /**
2452
- * Stream plan execution step by step.
2453
- */
2454
- private streamStepByStep;
2455
- /**
2456
- * Stream plan execution as a single request (planning without steps).
2522
+ * Stream plan execution as a single request (plan-direct).
2523
+ * Injects the plan as a system prefix so the LLM uses it as its own roadmap.
2457
2524
  */
2458
2525
  private streamPlanDirect;
2459
2526
  /**
@@ -2475,19 +2542,16 @@ declare class WorkflowExecutor extends EventEmitter {
2475
2542
  * Full detailed planning for general autonomous tasks.
2476
2543
  */
2477
2544
  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";
2478
- /**
2479
- * Agent step execution prompt.
2480
- * Standard execution with detailed instructions.
2481
- */
2482
- 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";
2483
2545
  /**
2484
2546
  * Default workflow configuration.
2485
- * Direct execution with no planning or steps.
2547
+ * Direct execution with no planning.
2486
2548
  */
2487
2549
  declare const DEFAULT_WORKFLOW: WorkflowConfig;
2488
2550
  /**
2489
2551
  * Agent workflow configuration.
2490
- * Full planning and step execution with dynamic steps disabled.
2552
+ * Plan-direct: planning phase generates a structured roadmap, then executes in a single
2553
+ * generate() call with full tool parallelism. Simpler queries bypass planning via
2554
+ * complexity routing.
2491
2555
  */
2492
2556
  declare const AGENT_WORKFLOW: WorkflowConfig;
2493
2557
  /**
@@ -2495,22 +2559,35 @@ declare const AGENT_WORKFLOW: WorkflowConfig;
2495
2559
  * Minimal rules focused on actionable code changes.
2496
2560
  */
2497
2561
  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";
2498
- /**
2499
- * Concise step execution prompt for coding tasks.
2500
- * No meta-commentary, focused on tool usage.
2501
- */
2502
- 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";
2503
2562
  /**
2504
2563
  * Coding workflow configuration.
2505
- * Concise prompts optimized for software development tasks.
2564
+ * Plan-direct: planning phase generates a structured roadmap using concise coding-focused prompts,
2565
+ * then executes in a single generate() call with full tool parallelism.
2506
2566
  */
2507
2567
  declare const CODING_WORKFLOW: WorkflowConfig;
2508
2568
  /**
2509
2569
  * Chat workflow configuration.
2510
- * No planning or steps - direct conversational responses.
2570
+ * Direct conversational responses no planning.
2511
2571
  */
2512
2572
  declare const CHAT_WORKFLOW: WorkflowConfig;
2513
2573
 
2574
+ type ToolpackNextFunction = (request?: CompletionRequest) => Promise<CompletionResponse>;
2575
+ /**
2576
+ * An interceptor that wraps each `generate()` call.
2577
+ *
2578
+ * It is a callable with an optional `init()` hook. When `init()` is present,
2579
+ * `Toolpack.init()` calls it once during startup — before any message is
2580
+ * processed — so interceptors can validate config, warm caches, or fail fast
2581
+ * on bad state (e.g. invalid skill files) rather than failing on the first request.
2582
+ *
2583
+ * Plain arrow functions without `init` are fully compatible with this type.
2584
+ */
2585
+ type ToolpackInterceptor = {
2586
+ (request: CompletionRequest, next: ToolpackNextFunction): Promise<CompletionResponse>;
2587
+ /** Optional startup hook called once by `Toolpack.init()`. */
2588
+ init?(): Promise<void>;
2589
+ };
2590
+
2514
2591
  interface ProviderOptions {
2515
2592
  /**
2516
2593
  * API key for the provider.
@@ -2527,6 +2604,15 @@ interface ProviderOptions {
2527
2604
  siteUrl?: string;
2528
2605
  /** OpenRouter only: your site name for the leaderboard/attribution header */
2529
2606
  siteName?: string;
2607
+ /** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
2608
+ projectId?: string;
2609
+ /** Vertex AI only: GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION / VERTEX_AI_LOCATION env vars. */
2610
+ location?: string;
2611
+ /** Vertex AI only: optional Google Auth options (keyFilename or credentials). When omitted, ADC is used. */
2612
+ googleAuthOptions?: {
2613
+ keyFilename?: string;
2614
+ credentials?: Record<string, unknown>;
2615
+ };
2530
2616
  }
2531
2617
  interface ToolpackInitConfig {
2532
2618
  /** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
@@ -2538,6 +2624,15 @@ interface ToolpackInitConfig {
2538
2624
  apiKey?: string;
2539
2625
  /** Model name for the single provider */
2540
2626
  model?: string;
2627
+ /** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
2628
+ projectId?: string;
2629
+ /** Vertex AI only: GCP region. Defaults to 'us-central1'. */
2630
+ location?: string;
2631
+ /** Vertex AI only: optional Google Auth options. When omitted, ADC is used automatically. */
2632
+ googleAuthOptions?: {
2633
+ keyFilename?: string;
2634
+ credentials?: Record<string, unknown>;
2635
+ };
2541
2636
  /** Load built-in tools (fs, http, etc.)? Default: false */
2542
2637
  tools?: boolean;
2543
2638
  /** Context window management configuration for automatic conversation pruning/summarization */
@@ -2594,6 +2689,15 @@ interface ToolpackInitConfig {
2594
2689
  }) => Promise<ConfirmationDecision>;
2595
2690
  /** Optional conversation ID for tracking context across confirmations */
2596
2691
  conversationId?: string;
2692
+ /**
2693
+ * Optional interceptors that wrap each `generate()` call in the direct execution path.
2694
+ * Each interceptor receives the full CompletionRequest and a `next()` function.
2695
+ * Interceptors run in order (first in array runs outermost).
2696
+ *
2697
+ * Note: interceptors apply to `generate()` only, not `stream()`.
2698
+ * The workflow execution path (when a mode has planning enabled) is also unaffected.
2699
+ */
2700
+ interceptors?: ToolpackInterceptor[];
2597
2701
  }
2598
2702
  /**
2599
2703
  * Duck-typed interface for Knowledge instances to avoid circular dependency
@@ -2636,6 +2740,7 @@ declare class Toolpack extends EventEmitter {
2636
2740
  private knowledgeLayers;
2637
2741
  customProviderNames: Set<string>;
2638
2742
  private mcpToolProject;
2743
+ private _interceptors;
2639
2744
  private constructor();
2640
2745
  private buildKnowledgeRequestTools;
2641
2746
  private prepareRequest;
@@ -2651,6 +2756,7 @@ declare class Toolpack extends EventEmitter {
2651
2756
  */
2652
2757
  private static createProvider;
2653
2758
  generate(request: CompletionRequest | string, providerName?: string): Promise<CompletionResponse>;
2759
+ private _buildInterceptorChain;
2654
2760
  stream(request: CompletionRequest, providerName?: string): AsyncGenerator<CompletionChunk>;
2655
2761
  embed(request: EmbeddingRequest, providerName?: string): Promise<EmbeddingResponse>;
2656
2762
  /**
@@ -3238,4 +3344,6 @@ interface McpServerCapabilities {
3238
3344
  prompts?: Record<string, any>;
3239
3345
  }
3240
3346
 
3241
- export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_STEP_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, type AddBypassRuleOptions, AnthropicAdapter, type AssembledPrompt, type AssemblerOptions, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, type BypassRuleType, CHAT_MODE, CHAT_WORKFLOW, CODING_MODE, CODING_PLANNING_PROMPT, CODING_STEP_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, type ConfirmationDecision, type ConfirmationLevel$1 as ConfirmationLevel, ConnectionError, type ContextPrunedEvent, type ContextWindowConfig, ContextWindowConfigError, ContextWindowExceededError, type ContextWindowExceededEvent, type ContextWindowState, ContextWindowStateManager, type ContextWindowStrategy, type ContextWindowWarningEvent, ConversationNotFoundError, type ConversationScope, type ConversationSearchOptions, type ConversationStore, type ConversationSummarizedEvent, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type GetOptions, type HitlConfig, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, InMemoryConversationStore, type InMemoryConversationStoreConfig, InsufficientContextError, type IntelligentToolDetectionConfig, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, type OnToolConfirmCallback, OpenAIAdapter, OpenRouterAdapter, type OpenRouterOptions, PageError, type Participant, type Plan, type PlanStep, Planner, type PromptMessage, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, type PruneResult, RateLimitError, type RequestToolDefinition, type Role, type RuntimeConfigStatus, SDKError, SQLiteConversationStore, type SQLiteConversationStoreConfig, type SearchHistoryEntry, type SearchOptions, type SearchResult, type SlmModelEntry, StepExecutor, type StoredMessage, SummarizationError, type SummarizationOptions, type SummarizationResult, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolConfirmation, type ToolConfirmationRequestedEvent, type ToolConfirmationResolvedEvent, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolsConfig, type Usage, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, addBypassRule, buildSummarizedHistory, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingFindSymbolTool, codingGetImportsTool, codingGetSymbolsTool, codingToolsProject, countTokens, createContextWindowStateManager, createMcpToolProject, createMode, createSummarizationReport, createSummarySystemMessage, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, estimateSummaryTokens, estimateTokenCount, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, extractConversationKeypoints, fetchUrlAsBase64, fsAppendFileTool, fsCopyTool, fsCreateDirTool, fsDeleteFileTool, fsExistsTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateSummarizationPrompt, generateToolCategoriesPrompt, getContextWindowPercentage, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMessageStats, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getSafeOutputReserve, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, githubContentsGetTextTool, githubGraphqlExecuteTool, githubPrDiffGetTool, githubPrFilesListTool, githubPrReviewCommentsReplyTool, githubPrReviewThreadsListTool, githubPrReviewThreadsResolveTool, githubPrReviewsSubmitTool, githubToolsProject, groupMessagesByRole, handleContextWindowError, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isContextWindowError, isDataUri, isRegisteredSlm, isToolSearchTool, k8sApplyManifestTool, k8sDeleteResourceTool, k8sDescribeTool, k8sGetConfigMapTool, k8sGetLogsTool, k8sGetNamespacesTool, k8sListDeploymentsTool, k8sListPodsTool, k8sListServicesTool, k8sSwitchContextTool, k8sToolsProject, k8sWaitForDeploymentTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, mergeSummarizationResults, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, parseSummarizationResponse, prepareSummarizationRequest, pruneMessages, readFileAsBase64, reloadToolpackConfig, removeBypassRule, saveToolsConfig, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, truncateMessage, validateSummarizationResult, webExtractLinksTool, webFetchTool, webScrapeTool, webSearchTool, webToolsProject, wouldExceedContextWindow };
3347
+ declare function createSkillInterceptor(options?: SkillInterceptorOptions): ToolpackInterceptor;
3348
+
3349
+ export { AGENT_MODE, AGENT_PLANNING_PROMPT, AGENT_WORKFLOW, AIClient, type AIClientConfig, type AddBypassRuleOptions, AnthropicAdapter, type AssembledPrompt, type AssemblerOptions, AuthenticationError, BM25SearchEngine, BUILT_IN_MODES, type BypassRuleType, CHAT_MODE, CHAT_WORKFLOW, CODING_MODE, CODING_PLANNING_PROMPT, CODING_WORKFLOW, CONFIG_DIR_NAME, CONFIG_FILE_NAME, type CompletionChunk, type CompletionOptions, type CompletionRequest, type CompletionResponse, type ConfirmationDecision, type ConfirmationLevel$1 as ConfirmationLevel, ConnectionError, type ContextPrunedEvent, type ContextWindowConfig, ContextWindowConfigError, ContextWindowExceededError, type ContextWindowExceededEvent, type ContextWindowState, ContextWindowStateManager, type ContextWindowStrategy, type ContextWindowWarningEvent, ConversationNotFoundError, type ConversationScope, type ConversationSearchOptions, type ConversationStore, type ConversationSummarizedEvent, DEFAULT_MODE_NAME, DEFAULT_TOOLS_CONFIG, DEFAULT_TOOL_SEARCH_CONFIG, DEFAULT_WORKFLOW, DEFAULT_WORKFLOW_CONFIG, type EmbeddingRequest, type EmbeddingResponse, type FileUploadRequest, type FileUploadResponse, GeminiAdapter, type GetOptions, type HitlConfig, type ImageDataPart, type ImageFilePart, type ImagePart, type ImageUrlPart, InMemoryConversationStore, type InMemoryConversationStoreConfig, InsufficientContextError, InvalidRequestError, type JsonRpcRequest, type JsonRpcResponse, type KnowledgeInstance, McpClient, type McpClientConfig, McpConnectionError, type McpServerCapabilities, type McpServerConfig, McpTimeoutError, type McpTool, McpToolManager, type McpToolsConfig, type MediaOptions, type MediaUploadStrategy, type Message, type MessageContent, type ModeBlockedHint, type ModeConfig, ModeRegistry, OllamaAdapter, type OllamaAdapterConfig, type OllamaModelInfo, OllamaProvider, type OllamaProviderEntry, type OnToolConfirmCallback, OpenAIAdapter, OpenRouterAdapter, type OpenRouterOptions, PageError, type Participant, type Plan, type PlanStep, Planner, type PromptMessage, ProviderAdapter, type ProviderConfig, ProviderError, type ProviderInfo, type ProviderModelInfo, type ProviderOptions, type PruneResult, RateLimitError, type RequestToolDefinition, type Role, type RuntimeConfigStatus, SDKError, SQLiteConversationStore, type SQLiteConversationStoreConfig, type SearchHistoryEntry, type SearchOptions, type SearchResult, type Skill, type SkillInterceptorOptions, type SkillSection, type SkillToolsOptions, type SkillValidationMode, type SlmModelEntry, type StoredMessage, SummarizationError, type SummarizationOptions, type SummarizationResult, TOOLPACK_DIR_NAME, TOOL_SEARCH_NAME, type TextPart, TimeoutError, type ToolCall, type ToolCallFunction, type ToolCallMessage, type ToolCallRequest, type ToolCallResult, type ToolCategory, type ToolConfirmation, type ToolConfirmationRequestedEvent, type ToolConfirmationResolvedEvent, type ToolContext, type ToolDefinition, ToolDiscoveryCache, type ToolLogEvent, type ToolParameterProperty, type ToolParameters, type ToolProgressEvent, type ToolProject, type ToolProjectDependencies, type ToolProjectManifest, ToolRegistry, type ToolResult, ToolRouter, type ToolSchema, type ToolSearchConfig, Toolpack, type ToolpackConfig, type ToolpackInitConfig, type ToolpackInterceptor, type ToolpackNextFunction, type ToolsConfig, type Usage, VertexAIAdapter, type VertexAIConfig, type WorkflowConfig, type WorkflowEvents, WorkflowExecutor, type WorkflowProgress, type WorkflowResult, addBypassRule, buildSummarizedHistory, cloudDeployTool, cloudListTool, cloudStatusTool, cloudToolsProject, codingExtractFunctionTool, codingFindReferencesTool, codingFindSymbolTool, codingGetCallHierarchyTool, codingGetDiagnosticsTool, codingGetExportsTool, codingGetImportsTool, codingGetOutlineTool, codingGetSymbolsTool, codingGoToDefinitionTool, codingMultiFileEditTool, codingRefactorRenameTool, codingToolsProject, countTokens, createContextWindowStateManager, createMcpToolProject, createMode, createSkillInterceptor, createSkillTools, createSummarizationReport, createSummarySystemMessage, createToolProject, dbCountTool, dbDeleteTool, dbInsertTool, dbQueryTool, dbSchemaTool, dbTablesTool, dbToolsProject, dbUpdateTool, diffApplyTool, diffCreateTool, diffPreviewTool, diffToolsProject, disconnectMcpToolProject, ensureGlobalConfigDir, ensureLocalConfigDir, estimateSummaryTokens, estimateTokenCount, execKillTool, execListProcessesTool, execReadOutputTool, execRunBackgroundTool, execRunShellTool, execRunTool, execToolsProject, extractConversationKeypoints, fetchUrlAsBase64, fsAppendFileTool, fsBatchReadTool, fsBatchWriteTool, fsCopyTool, fsCreateDirTool, fsDeleteDirTool, fsDeleteFileTool, fsExistsTool, fsGlobTool, fsListDirTool, fsMoveTool, fsReadFileRangeTool, fsReadFileTool, fsReplaceInFileTool, fsSearchTool, fsStatTool, fsToolsProject, fsTreeTool, fsWriteFileTool, generateSummarizationPrompt, generateToolCategoriesPrompt, getContextWindowPercentage, getDefaultSlmModel, getGlobalConfigDir, getGlobalConfigPath, getGlobalToolpackDir, getLocalConfigDir, getLocalConfigPath, getLocalToolpackDir, getMessageStats, getMimeType, getOllamaBaseUrl, getOllamaProviderEntries, getRegisteredSlmModels, getRuntimeConfigStatus, getSafeOutputReserve, getToolSearchSchema, getToolpackConfig, getUserHomeDir, gitAddTool, gitBlameTool, gitBranchCreateTool, gitBranchListTool, gitCheckoutTool, gitCloneTool, gitCommitTool, gitDiffTool, gitLogTool, gitStatusTool, gitToolsProject, githubContentsGetTextTool, githubGraphqlExecuteTool, githubIssuesCommentsCreateTool, githubPrDiffGetTool, githubPrFilesListTool, githubPrReviewCommentsReplyTool, githubPrReviewThreadsListTool, githubPrReviewThreadsResolveTool, githubPrReviewsSubmitTool, githubToolsProject, groupMessagesByRole, handleContextWindowError, httpDeleteTool, httpDownloadTool, httpGetTool, httpPostTool, httpPutTool, httpToolsProject, initializeGlobalConfigIfFirstRun, isContextWindowError, isDataUri, isRegisteredSlm, isToolSearchTool, k8sApplyManifestTool, k8sDeleteResourceTool, k8sDescribeTool, k8sGetConfigMapTool, k8sGetLogsTool, k8sGetNamespacesTool, k8sListDeploymentsTool, k8sListPodsTool, k8sListServicesTool, k8sSwitchContextTool, k8sToolsProject, k8sWaitForDeploymentTool, loadFullConfig, loadRuntimeConfig, loadToolsConfig, mergeSummarizationResults, normalizeImagePart, ollamaRequest, ollamaStream, parseDataUri, parseSummarizationResponse, prepareSummarizationRequest, pruneMessages, readFileAsBase64, reloadToolpackConfig, removeBypassRule, saveToolsConfig, slackAuthTestTool, slackChatPostEphemeralTool, slackChatPostMessageTool, slackConversationsHistoryTool, slackConversationsRepliesTool, slackReactionsAddTool, slackToolsProject, systemCwdTool, systemDiskUsageTool, systemEnvTool, systemInfoTool, systemSetEnvTool, systemToolsProject, toDataUri, toolSearchDefinition, truncateMessage, validateSummarizationResult, webExtractLinksTool, webFeedTool, webFetchTool, webMapTool, webMetadataTool, webScrapeTool, webScreenshotTool, webSearchTool, webSitemapTool, webToolsProject, wouldExceedContextWindow };