toolpack-sdk 2.0.0-alpha.1 → 2.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 +113 -93
- package/dist/index.cjs +315 -224
- package/dist/index.d.cts +215 -121
- package/dist/index.d.ts +215 -121
- package/dist/index.js +315 -224
- package/package.json +6 -4
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
|
|
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) */
|
|
@@ -1346,6 +1307,12 @@ declare class AIClient extends EventEmitter {
|
|
|
1346
1307
|
*/
|
|
1347
1308
|
private executeToolSearch;
|
|
1348
1309
|
private wrapError;
|
|
1310
|
+
/**
|
|
1311
|
+
* Truncate a tool result to fit within the remaining round budget.
|
|
1312
|
+
* Instead of silently dropping the output, include as much content as possible
|
|
1313
|
+
* and append an actionable hint so the LLM can retry with a narrower query.
|
|
1314
|
+
*/
|
|
1315
|
+
private budgetTruncate;
|
|
1349
1316
|
}
|
|
1350
1317
|
|
|
1351
1318
|
declare class AnthropicAdapter extends ProviderAdapter {
|
|
@@ -1384,6 +1351,43 @@ declare class AnthropicAdapter extends ProviderAdapter {
|
|
|
1384
1351
|
private handleError;
|
|
1385
1352
|
}
|
|
1386
1353
|
|
|
1354
|
+
interface VertexAIConfig {
|
|
1355
|
+
/** GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT or VERTEX_AI_PROJECT env vars. */
|
|
1356
|
+
projectId?: string;
|
|
1357
|
+
/** GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION or VERTEX_AI_LOCATION env vars. */
|
|
1358
|
+
location?: string;
|
|
1359
|
+
/**
|
|
1360
|
+
* Optional Google Auth options.
|
|
1361
|
+
* When omitted, Application Default Credentials (ADC) are used automatically.
|
|
1362
|
+
* Set GOOGLE_APPLICATION_CREDENTIALS env var to point to a service account JSON file.
|
|
1363
|
+
*/
|
|
1364
|
+
googleAuthOptions?: {
|
|
1365
|
+
/** Path to a service account key JSON file. */
|
|
1366
|
+
keyFilename?: string;
|
|
1367
|
+
/** Inline service account credentials object. */
|
|
1368
|
+
credentials?: Record<string, unknown>;
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
declare class VertexAIAdapter extends ProviderAdapter {
|
|
1372
|
+
private vertexAI;
|
|
1373
|
+
private readonly location;
|
|
1374
|
+
constructor(config?: VertexAIConfig);
|
|
1375
|
+
getDisplayName(): string;
|
|
1376
|
+
getModels(): Promise<ProviderModelInfo[]>;
|
|
1377
|
+
generate(request: CompletionRequest): Promise<CompletionResponse>;
|
|
1378
|
+
stream(request: CompletionRequest): AsyncGenerator<CompletionChunk>;
|
|
1379
|
+
embed(_request: EmbeddingRequest): Promise<EmbeddingResponse>;
|
|
1380
|
+
private buildModel;
|
|
1381
|
+
private formatHistory;
|
|
1382
|
+
private contentToParts;
|
|
1383
|
+
private parseResponse;
|
|
1384
|
+
private extractSystemInstruction;
|
|
1385
|
+
private sanitizeToolName;
|
|
1386
|
+
private restoreToolName;
|
|
1387
|
+
private sanitizeSchema;
|
|
1388
|
+
private handleError;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1387
1391
|
declare class GeminiAdapter extends ProviderAdapter {
|
|
1388
1392
|
private genAI;
|
|
1389
1393
|
constructor(apiKey: string);
|
|
@@ -2043,6 +2047,14 @@ declare const fsReplaceInFileTool: ToolDefinition;
|
|
|
2043
2047
|
|
|
2044
2048
|
declare const fsTreeTool: ToolDefinition;
|
|
2045
2049
|
|
|
2050
|
+
declare const fsGlobTool: ToolDefinition;
|
|
2051
|
+
|
|
2052
|
+
declare const fsDeleteDirTool: ToolDefinition;
|
|
2053
|
+
|
|
2054
|
+
declare const fsBatchReadTool: ToolDefinition;
|
|
2055
|
+
|
|
2056
|
+
declare const fsBatchWriteTool: ToolDefinition;
|
|
2057
|
+
|
|
2046
2058
|
declare const fsToolsProject: ToolProject;
|
|
2047
2059
|
|
|
2048
2060
|
declare const execRunTool: ToolDefinition;
|
|
@@ -2099,6 +2111,8 @@ declare const githubPrFilesListTool: ToolDefinition;
|
|
|
2099
2111
|
|
|
2100
2112
|
declare const githubPrReviewsSubmitTool: ToolDefinition;
|
|
2101
2113
|
|
|
2114
|
+
declare const githubIssuesCommentsCreateTool: ToolDefinition;
|
|
2115
|
+
|
|
2102
2116
|
declare const githubToolsProject: ToolProject;
|
|
2103
2117
|
|
|
2104
2118
|
declare const webFetchTool: ToolDefinition;
|
|
@@ -2109,6 +2123,16 @@ declare const webScrapeTool: ToolDefinition;
|
|
|
2109
2123
|
|
|
2110
2124
|
declare const webExtractLinksTool: ToolDefinition;
|
|
2111
2125
|
|
|
2126
|
+
declare const webMapTool: ToolDefinition;
|
|
2127
|
+
|
|
2128
|
+
declare const webMetadataTool: ToolDefinition;
|
|
2129
|
+
|
|
2130
|
+
declare const webSitemapTool: ToolDefinition;
|
|
2131
|
+
|
|
2132
|
+
declare const webFeedTool: ToolDefinition;
|
|
2133
|
+
|
|
2134
|
+
declare const webScreenshotTool: ToolDefinition;
|
|
2135
|
+
|
|
2112
2136
|
declare const webToolsProject: ToolProject;
|
|
2113
2137
|
|
|
2114
2138
|
declare const codingFindSymbolTool: ToolDefinition;
|
|
@@ -2117,6 +2141,24 @@ declare const codingGetSymbolsTool: ToolDefinition;
|
|
|
2117
2141
|
|
|
2118
2142
|
declare const codingGetImportsTool: ToolDefinition;
|
|
2119
2143
|
|
|
2144
|
+
declare const codingFindReferencesTool: ToolDefinition;
|
|
2145
|
+
|
|
2146
|
+
declare const codingGoToDefinitionTool: ToolDefinition;
|
|
2147
|
+
|
|
2148
|
+
declare const codingMultiFileEditTool: ToolDefinition;
|
|
2149
|
+
|
|
2150
|
+
declare const codingRefactorRenameTool: ToolDefinition;
|
|
2151
|
+
|
|
2152
|
+
declare const codingGetOutlineTool: ToolDefinition;
|
|
2153
|
+
|
|
2154
|
+
declare const codingGetDiagnosticsTool: ToolDefinition;
|
|
2155
|
+
|
|
2156
|
+
declare const codingGetExportsTool: ToolDefinition;
|
|
2157
|
+
|
|
2158
|
+
declare const codingExtractFunctionTool: ToolDefinition;
|
|
2159
|
+
|
|
2160
|
+
declare const codingGetCallHierarchyTool: ToolDefinition;
|
|
2161
|
+
|
|
2120
2162
|
declare const codingToolsProject: ToolProject;
|
|
2121
2163
|
|
|
2122
2164
|
declare const gitStatusTool: ToolDefinition;
|
|
@@ -2137,6 +2179,8 @@ declare const gitBranchCreateTool: ToolDefinition;
|
|
|
2137
2179
|
|
|
2138
2180
|
declare const gitCheckoutTool: ToolDefinition;
|
|
2139
2181
|
|
|
2182
|
+
declare const gitCloneTool: ToolDefinition;
|
|
2183
|
+
|
|
2140
2184
|
declare const gitToolsProject: ToolProject;
|
|
2141
2185
|
|
|
2142
2186
|
declare const diffCreateTool: ToolDefinition;
|
|
@@ -2185,6 +2229,56 @@ declare const k8sWaitForDeploymentTool: ToolDefinition;
|
|
|
2185
2229
|
|
|
2186
2230
|
declare const k8sToolsProject: ToolProject;
|
|
2187
2231
|
|
|
2232
|
+
declare const slackChatPostMessageTool: ToolDefinition;
|
|
2233
|
+
|
|
2234
|
+
declare const slackChatPostEphemeralTool: ToolDefinition;
|
|
2235
|
+
|
|
2236
|
+
declare const slackReactionsAddTool: ToolDefinition;
|
|
2237
|
+
|
|
2238
|
+
declare const slackConversationsHistoryTool: ToolDefinition;
|
|
2239
|
+
|
|
2240
|
+
declare const slackConversationsRepliesTool: ToolDefinition;
|
|
2241
|
+
|
|
2242
|
+
declare const slackAuthTestTool: ToolDefinition;
|
|
2243
|
+
|
|
2244
|
+
declare const slackToolsProject: ToolProject;
|
|
2245
|
+
|
|
2246
|
+
type SkillSection = 'description' | 'triggers' | 'instructions' | 'examples' | 'metadata' | 'all';
|
|
2247
|
+
type SkillValidationMode = 'fail' | 'warn';
|
|
2248
|
+
interface Skill {
|
|
2249
|
+
name: string;
|
|
2250
|
+
title: string;
|
|
2251
|
+
version?: string;
|
|
2252
|
+
tags: string[];
|
|
2253
|
+
category?: string;
|
|
2254
|
+
filePath: string;
|
|
2255
|
+
description: string;
|
|
2256
|
+
triggers: string[];
|
|
2257
|
+
instructions: string;
|
|
2258
|
+
examples?: string;
|
|
2259
|
+
lastModified: number;
|
|
2260
|
+
}
|
|
2261
|
+
interface SkillInterceptorOptions {
|
|
2262
|
+
dir?: string;
|
|
2263
|
+
maxSkills?: number;
|
|
2264
|
+
minScore?: number;
|
|
2265
|
+
onValidationError?: SkillValidationMode;
|
|
2266
|
+
}
|
|
2267
|
+
interface SkillToolsOptions {
|
|
2268
|
+
/** Skills directory. Default: '.toolpack/skills' */
|
|
2269
|
+
dir?: string;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Creates a ToolProject with 4 skill management tools: create, read, update, list.
|
|
2274
|
+
*
|
|
2275
|
+
* @example
|
|
2276
|
+
* ```ts
|
|
2277
|
+
* const skillTools = createSkillTools({ dir: '.toolpack/skills' });
|
|
2278
|
+
* ```
|
|
2279
|
+
*/
|
|
2280
|
+
declare function createSkillTools(options?: SkillToolsOptions): ToolProject;
|
|
2281
|
+
|
|
2188
2282
|
/**
|
|
2189
2283
|
* Central registry for AI agent modes (built-in + custom).
|
|
2190
2284
|
* Handles registration, lookup, cycling, and defaults.
|
|
@@ -2281,11 +2375,6 @@ declare function createMode(config: {
|
|
|
2281
2375
|
enabled: boolean;
|
|
2282
2376
|
requireApproval?: boolean;
|
|
2283
2377
|
};
|
|
2284
|
-
steps?: {
|
|
2285
|
-
enabled: boolean;
|
|
2286
|
-
retryOnFailure?: boolean;
|
|
2287
|
-
allowDynamicSteps?: boolean;
|
|
2288
|
-
};
|
|
2289
2378
|
progress?: {
|
|
2290
2379
|
enabled: boolean;
|
|
2291
2380
|
};
|
|
@@ -2344,39 +2433,10 @@ declare class Planner {
|
|
|
2344
2433
|
private createFallbackPlan;
|
|
2345
2434
|
}
|
|
2346
2435
|
|
|
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
2436
|
declare class WorkflowExecutor extends EventEmitter {
|
|
2376
2437
|
private client;
|
|
2377
2438
|
private config;
|
|
2378
2439
|
private planner;
|
|
2379
|
-
private stepExecutor;
|
|
2380
2440
|
private queryClassifier;
|
|
2381
2441
|
private pendingApprovals;
|
|
2382
2442
|
constructor(client: AIClient, config: WorkflowConfig, queryClassifier?: QueryClassifier);
|
|
@@ -2395,6 +2455,10 @@ declare class WorkflowExecutor extends EventEmitter {
|
|
|
2395
2455
|
private shouldRouteSimpleQuery;
|
|
2396
2456
|
/**
|
|
2397
2457
|
* Execute a request using the configured workflow.
|
|
2458
|
+
*
|
|
2459
|
+
* Modes:
|
|
2460
|
+
* - Direct: no planning — single generate() call
|
|
2461
|
+
* - Plan-direct: planning generates a roadmap, then executes in one generate() call
|
|
2398
2462
|
*/
|
|
2399
2463
|
execute(request: CompletionRequest, providerName?: string): Promise<WorkflowResult>;
|
|
2400
2464
|
/**
|
|
@@ -2406,39 +2470,31 @@ declare class WorkflowExecutor extends EventEmitter {
|
|
|
2406
2470
|
*/
|
|
2407
2471
|
private createPlan;
|
|
2408
2472
|
/**
|
|
2409
|
-
*
|
|
2410
|
-
|
|
2411
|
-
private executeStepByStep;
|
|
2412
|
-
/**
|
|
2413
|
-
* Planning without steps — execute plan as single generate call.
|
|
2473
|
+
* Planning without steps — inject plan as context prefix and execute in one generate() call.
|
|
2474
|
+
* The LLM sees its own roadmap and uses it to guide tool usage and sequencing.
|
|
2414
2475
|
*/
|
|
2415
2476
|
private executePlanDirect;
|
|
2416
2477
|
/**
|
|
2417
|
-
* Emit a progress event
|
|
2478
|
+
* Emit a progress event.
|
|
2479
|
+
* @param percentageOverride - Optional fixed percentage (0–100). Use for plan-direct
|
|
2480
|
+
* mode where steps complete atomically and intermediate step-level progress is unavailable.
|
|
2418
2481
|
*/
|
|
2419
2482
|
private emitProgress;
|
|
2420
2483
|
/**
|
|
2421
2484
|
* Compute metrics for the plan.
|
|
2422
2485
|
*/
|
|
2423
2486
|
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
2487
|
/**
|
|
2439
2488
|
* Create a dummy plan for internal representation when no plan is generated.
|
|
2440
2489
|
*/
|
|
2441
2490
|
private createDummyPlan;
|
|
2491
|
+
/**
|
|
2492
|
+
* Inject plan context as a system message.
|
|
2493
|
+
* If the request already has a leading system message (e.g., a mode system prompt),
|
|
2494
|
+
* merge the plan context into it to avoid sending multiple system messages to providers
|
|
2495
|
+
* that don't support or handle them inconsistently.
|
|
2496
|
+
*/
|
|
2497
|
+
private injectPlanContext;
|
|
2442
2498
|
/**
|
|
2443
2499
|
* Execute a request using the configured workflow, yielding chunks as they come.
|
|
2444
2500
|
* This is the streaming equivalent of execute().
|
|
@@ -2449,11 +2505,8 @@ declare class WorkflowExecutor extends EventEmitter {
|
|
|
2449
2505
|
*/
|
|
2450
2506
|
private streamDirect;
|
|
2451
2507
|
/**
|
|
2452
|
-
* Stream plan execution
|
|
2453
|
-
|
|
2454
|
-
private streamStepByStep;
|
|
2455
|
-
/**
|
|
2456
|
-
* Stream plan execution as a single request (planning without steps).
|
|
2508
|
+
* Stream plan execution as a single request (plan-direct).
|
|
2509
|
+
* Injects the plan as a system prefix so the LLM uses it as its own roadmap.
|
|
2457
2510
|
*/
|
|
2458
2511
|
private streamPlanDirect;
|
|
2459
2512
|
/**
|
|
@@ -2475,19 +2528,16 @@ declare class WorkflowExecutor extends EventEmitter {
|
|
|
2475
2528
|
* Full detailed planning for general autonomous tasks.
|
|
2476
2529
|
*/
|
|
2477
2530
|
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
2531
|
/**
|
|
2484
2532
|
* Default workflow configuration.
|
|
2485
|
-
* Direct execution with no planning
|
|
2533
|
+
* Direct execution with no planning.
|
|
2486
2534
|
*/
|
|
2487
2535
|
declare const DEFAULT_WORKFLOW: WorkflowConfig;
|
|
2488
2536
|
/**
|
|
2489
2537
|
* Agent workflow configuration.
|
|
2490
|
-
*
|
|
2538
|
+
* Plan-direct: planning phase generates a structured roadmap, then executes in a single
|
|
2539
|
+
* generate() call with full tool parallelism. Simpler queries bypass planning via
|
|
2540
|
+
* complexity routing.
|
|
2491
2541
|
*/
|
|
2492
2542
|
declare const AGENT_WORKFLOW: WorkflowConfig;
|
|
2493
2543
|
/**
|
|
@@ -2495,22 +2545,35 @@ declare const AGENT_WORKFLOW: WorkflowConfig;
|
|
|
2495
2545
|
* Minimal rules focused on actionable code changes.
|
|
2496
2546
|
*/
|
|
2497
2547
|
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
2548
|
/**
|
|
2504
2549
|
* Coding workflow configuration.
|
|
2505
|
-
*
|
|
2550
|
+
* Plan-direct: planning phase generates a structured roadmap using concise coding-focused prompts,
|
|
2551
|
+
* then executes in a single generate() call with full tool parallelism.
|
|
2506
2552
|
*/
|
|
2507
2553
|
declare const CODING_WORKFLOW: WorkflowConfig;
|
|
2508
2554
|
/**
|
|
2509
2555
|
* Chat workflow configuration.
|
|
2510
|
-
*
|
|
2556
|
+
* Direct conversational responses — no planning.
|
|
2511
2557
|
*/
|
|
2512
2558
|
declare const CHAT_WORKFLOW: WorkflowConfig;
|
|
2513
2559
|
|
|
2560
|
+
type ToolpackNextFunction = (request?: CompletionRequest) => Promise<CompletionResponse>;
|
|
2561
|
+
/**
|
|
2562
|
+
* An interceptor that wraps each `generate()` call.
|
|
2563
|
+
*
|
|
2564
|
+
* It is a callable with an optional `init()` hook. When `init()` is present,
|
|
2565
|
+
* `Toolpack.init()` calls it once during startup — before any message is
|
|
2566
|
+
* processed — so interceptors can validate config, warm caches, or fail fast
|
|
2567
|
+
* on bad state (e.g. invalid skill files) rather than failing on the first request.
|
|
2568
|
+
*
|
|
2569
|
+
* Plain arrow functions without `init` are fully compatible with this type.
|
|
2570
|
+
*/
|
|
2571
|
+
type ToolpackInterceptor = {
|
|
2572
|
+
(request: CompletionRequest, next: ToolpackNextFunction): Promise<CompletionResponse>;
|
|
2573
|
+
/** Optional startup hook called once by `Toolpack.init()`. */
|
|
2574
|
+
init?(): Promise<void>;
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2514
2577
|
interface ProviderOptions {
|
|
2515
2578
|
/**
|
|
2516
2579
|
* API key for the provider.
|
|
@@ -2527,6 +2590,15 @@ interface ProviderOptions {
|
|
|
2527
2590
|
siteUrl?: string;
|
|
2528
2591
|
/** OpenRouter only: your site name for the leaderboard/attribution header */
|
|
2529
2592
|
siteName?: string;
|
|
2593
|
+
/** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
|
|
2594
|
+
projectId?: string;
|
|
2595
|
+
/** Vertex AI only: GCP region. Defaults to 'us-central1'. Falls back to TOOLPACK_VERTEXAI_LOCATION / VERTEX_AI_LOCATION env vars. */
|
|
2596
|
+
location?: string;
|
|
2597
|
+
/** Vertex AI only: optional Google Auth options (keyFilename or credentials). When omitted, ADC is used. */
|
|
2598
|
+
googleAuthOptions?: {
|
|
2599
|
+
keyFilename?: string;
|
|
2600
|
+
credentials?: Record<string, unknown>;
|
|
2601
|
+
};
|
|
2530
2602
|
}
|
|
2531
2603
|
interface ToolpackInitConfig {
|
|
2532
2604
|
/** Single provider shorthand (e.g. 'openai', 'anthropic', 'gemini') */
|
|
@@ -2538,6 +2610,15 @@ interface ToolpackInitConfig {
|
|
|
2538
2610
|
apiKey?: string;
|
|
2539
2611
|
/** Model name for the single provider */
|
|
2540
2612
|
model?: string;
|
|
2613
|
+
/** Vertex AI only: GCP project ID. Falls back to TOOLPACK_VERTEXAI_PROJECT / VERTEX_AI_PROJECT / GOOGLE_CLOUD_PROJECT env vars. */
|
|
2614
|
+
projectId?: string;
|
|
2615
|
+
/** Vertex AI only: GCP region. Defaults to 'us-central1'. */
|
|
2616
|
+
location?: string;
|
|
2617
|
+
/** Vertex AI only: optional Google Auth options. When omitted, ADC is used automatically. */
|
|
2618
|
+
googleAuthOptions?: {
|
|
2619
|
+
keyFilename?: string;
|
|
2620
|
+
credentials?: Record<string, unknown>;
|
|
2621
|
+
};
|
|
2541
2622
|
/** Load built-in tools (fs, http, etc.)? Default: false */
|
|
2542
2623
|
tools?: boolean;
|
|
2543
2624
|
/** Context window management configuration for automatic conversation pruning/summarization */
|
|
@@ -2594,6 +2675,15 @@ interface ToolpackInitConfig {
|
|
|
2594
2675
|
}) => Promise<ConfirmationDecision>;
|
|
2595
2676
|
/** Optional conversation ID for tracking context across confirmations */
|
|
2596
2677
|
conversationId?: string;
|
|
2678
|
+
/**
|
|
2679
|
+
* Optional interceptors that wrap each `generate()` call in the direct execution path.
|
|
2680
|
+
* Each interceptor receives the full CompletionRequest and a `next()` function.
|
|
2681
|
+
* Interceptors run in order (first in array runs outermost).
|
|
2682
|
+
*
|
|
2683
|
+
* Note: interceptors apply to `generate()` only, not `stream()`.
|
|
2684
|
+
* The workflow execution path (when a mode has planning enabled) is also unaffected.
|
|
2685
|
+
*/
|
|
2686
|
+
interceptors?: ToolpackInterceptor[];
|
|
2597
2687
|
}
|
|
2598
2688
|
/**
|
|
2599
2689
|
* Duck-typed interface for Knowledge instances to avoid circular dependency
|
|
@@ -2636,6 +2726,7 @@ declare class Toolpack extends EventEmitter {
|
|
|
2636
2726
|
private knowledgeLayers;
|
|
2637
2727
|
customProviderNames: Set<string>;
|
|
2638
2728
|
private mcpToolProject;
|
|
2729
|
+
private _interceptors;
|
|
2639
2730
|
private constructor();
|
|
2640
2731
|
private buildKnowledgeRequestTools;
|
|
2641
2732
|
private prepareRequest;
|
|
@@ -2651,6 +2742,7 @@ declare class Toolpack extends EventEmitter {
|
|
|
2651
2742
|
*/
|
|
2652
2743
|
private static createProvider;
|
|
2653
2744
|
generate(request: CompletionRequest | string, providerName?: string): Promise<CompletionResponse>;
|
|
2745
|
+
private _buildInterceptorChain;
|
|
2654
2746
|
stream(request: CompletionRequest, providerName?: string): AsyncGenerator<CompletionChunk>;
|
|
2655
2747
|
embed(request: EmbeddingRequest, providerName?: string): Promise<EmbeddingResponse>;
|
|
2656
2748
|
/**
|
|
@@ -3238,4 +3330,6 @@ interface McpServerCapabilities {
|
|
|
3238
3330
|
prompts?: Record<string, any>;
|
|
3239
3331
|
}
|
|
3240
3332
|
|
|
3241
|
-
|
|
3333
|
+
declare function createSkillInterceptor(options?: SkillInterceptorOptions): ToolpackInterceptor;
|
|
3334
|
+
|
|
3335
|
+
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 };
|