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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Toolpack SDK
2
2
 
3
- A unified TypeScript/Node.js SDK for building AI-powered applications with multiple providers, 97 built-in tools, a workflow engine, and a flexible mode system — all through a single API.
3
+ A unified TypeScript/Node.js SDK for building AI-powered applications with multiple providers, 100+ built-in tools, a workflow engine, and a flexible mode system — all through a single API.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/toolpack-sdk.svg)](https://www.npmjs.com/package/toolpack-sdk)
6
6
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -14,27 +14,29 @@ A unified TypeScript/Node.js SDK for building AI-powered applications with multi
14
14
  - **Type-Safe** — Comprehensive TypeScript types throughout
15
15
  - **Multimodal** — Text and image inputs (vision) across all providers
16
16
  - **Embeddings** — Vector generation for RAG applications (OpenAI, Gemini, Ollama)
17
- - **Workflow Engine** — AI-driven planning and step-by-step task execution with progress events
17
+ - **Workflow Engine** — AI-driven planning with plan-direct execution and parallel tool orchestration
18
18
  - **Mode System** — Built-in Agent and Chat modes, plus `createMode()` for custom modes with tool filtering
19
19
  - **HITL Confirmation** — Human-in-the-loop approval for high-risk operations with configurable bypass rules
20
20
  - **Custom Providers** — Bring your own provider by implementing the `ProviderAdapter` interface
21
- - **97 Built-in Tools** across 12 categories:
21
+ - **101 Built-in Tools** across 14 categories (including 4 skill-tools and 2 mcp-tools):
22
22
  - **MCP Tool Server Integration** — dynamically bridge external Model Context Protocol servers into Toolpack as first-class tools via `createMcpToolProject()` and `disconnectMcpToolProject()`.
23
23
 
24
24
  | Category | Tools | Description |
25
25
  |----------|-------|-------------|
26
26
  | **`fs-tools`** | 18 | File system operations — read, write, search, tree, glob, batch read/write, etc. |
27
27
  | **`coding-tools`** | 12 | Code analysis — AST parsing, go to definition, find references, rename symbols, extract function |
28
- | **`git-tools`** | 9 | Version control — status, diff, log, blame, branch, commit, checkout |
28
+ | **`git-tools`** | 10 | Version control — status, diff, log, blame, branch, commit, checkout, clone |
29
29
  | **`db-tools`** | 7 | Database operations — query, schema, tables, count, insert, update, delete (SQLite, PostgreSQL, MySQL) |
30
30
  | **`exec-tools`** | 6 | Command execution — run, run shell, background processes, kill, read output |
31
31
  | **`http-tools`** | 5 | HTTP requests — GET, POST, PUT, DELETE, download |
32
32
  | **`web-tools`** | 9 | Web interaction — fetch, search (Tavily/Brave/DuckDuckGo), scrape, extract links, map, metadata, sitemap, feed, screenshot |
33
33
  | **`system-tools`** | 5 | System info — env vars, cwd, disk usage, system info, set env |
34
34
  | **`github-tools`** | 9 | GitHub operations — PR reviews, review threads, file diffs, issue comments, GraphQL, repo contents |
35
+ | **`slack-tools`** | 6 | Slack messaging — post messages, ephemeral messages, channel history, thread replies, reactions |
35
36
  | **`diff-tools`** | 3 | Patch operations — create, apply, and preview diffs |
36
37
  | **`cloud-tools`** | 3 | Deployments — deploy, status, list (via Netlify) |
37
38
  | **`k8s-tools`** | 11 | Kubernetes cluster inspection and management via kubectl |
39
+ | **`skill-tools`** | 4 | Skill management — skill.create, skill.read, skill.update, skill.list |
38
40
  | **`mcp-tools`** | 2 | MCP integration — createMcpToolProject, disconnectMcpToolProject |
39
41
 
40
42
  ## Quick Start
@@ -61,7 +63,7 @@ const sdk = await Toolpack.init({
61
63
  anthropic: {}, // Reads ANTHROPIC_API_KEY from env
62
64
  },
63
65
  defaultProvider: 'openai',
64
- tools: true, // Load all 97 built-in tools
66
+ tools: true, // Load all 100+ built-in tools
65
67
  defaultMode: 'agent', // Agent mode with workflow engine
66
68
  });
67
69
 
@@ -79,7 +81,7 @@ for await (const chunk of sdk.stream({
79
81
 
80
82
  // Switch providers on the fly
81
83
  const anthropicResponse = await sdk.generate({
82
- model: 'claude-sonnet-4-20250514',
84
+ model: 'your-model',
83
85
  messages: [{ role: 'user', content: 'Hello from Anthropic!' }],
84
86
  }, 'anthropic');
85
87
  ```
@@ -105,7 +107,7 @@ const sdk = await Toolpack.init({
105
107
  });
106
108
 
107
109
  const podsResponse = await sdk.generate({
108
- model: 'gpt-4o',
110
+ model: 'your-model',
109
111
  messages: [
110
112
  {
111
113
  role: 'user',
@@ -116,7 +118,7 @@ const podsResponse = await sdk.generate({
116
118
  console.log(podsResponse.content);
117
119
 
118
120
  const applyResponse = await sdk.generate({
119
- model: 'gpt-4o',
121
+ model: 'your-model',
120
122
  messages: [
121
123
  {
122
124
  role: 'user',
@@ -279,8 +281,8 @@ Modes control AI behavior by setting a system prompt, filtering available tools,
279
281
 
280
282
  | Mode | Tools | Workflow | Description |
281
283
  |------|-------|----------|-------------|
282
- | **Agent** | All tools | Planning + step execution + dynamic steps | Full autonomous access — read, write, execute, browse |
283
- | **Coding** | All tools | Concise planning + step execution | Optimized for coding tasks — minimal text, file operations |
284
+ | **Agent** | All tools | Plan-direct execution | Full autonomous access — read, write, execute, browse |
285
+ | **Coding** | All tools | Plan-direct execution | Optimized for coding tasks — minimal text, file operations |
284
286
  | **Chat** | Web/HTTP only | Direct execution (no planning) | Conversational assistant with web access |
285
287
 
286
288
  ### Custom Modes
@@ -301,7 +303,6 @@ const reviewMode = createMode({
301
303
  },
302
304
  workflow: {
303
305
  planning: { enabled: true },
304
- steps: { enabled: true, retryOnFailure: true },
305
306
  progress: { enabled: true },
306
307
  },
307
308
  });
@@ -341,19 +342,17 @@ sdk.cycleMode(); // Cycles through all registered modes
341
342
  | `blockedTools` | string[] | `[]` | Specific tools to block. Overrides allowed |
342
343
  | `blockAllTools` | boolean | `false` | If `true`, disables all tools (pure conversation) |
343
344
  | `baseContext` | object/false | `undefined` | Controls working directory and tool category injection |
344
- | `workflow` | WorkflowConfig | `undefined` | Planning, step execution, and progress configuration |
345
+ | `workflow` | WorkflowConfig | `undefined` | Planning, execution mode, and progress configuration |
345
346
 
346
347
  ## Workflow Engine
347
348
 
348
- The workflow engine enables AI agents to plan and execute complex tasks step-by-step, with progress tracking, retries, and dynamic step additions.
349
+ The workflow engine enables AI agents to plan and execute complex tasks with parallel tool orchestration.
349
350
 
350
351
  ### How It Works
351
352
 
352
- 1. **Planning** — The AI generates a structured step-by-step plan from the user's request
353
- 2. **Execution** — Each step is executed sequentially with tool access
354
- 3. **Dynamic Steps** — New steps can be added during execution based on results
355
- 4. **Retries** — Failed steps are retried automatically (configurable)
356
- 5. **Progress** — Events are emitted at each stage for UI integration
353
+ 1. **Planning** — The AI generates a structured plan from the user's request
354
+ 2. **Execution** — The plan is injected as context and executed in a single call with parallel tool orchestration
355
+ 3. **Progress** — Events are emitted at each stage for UI integration
357
356
 
358
357
  ### Using the Workflow
359
358
 
@@ -364,7 +363,7 @@ const sdk = await Toolpack.init({
364
363
  defaultMode: 'agent', // Agent mode has workflow enabled
365
364
  });
366
365
 
367
- // Complex tasks are automatically planned and executed step-by-step
366
+ // Complex tasks are automatically planned (plan-direct) with parallel tool execution
368
367
  const result = await sdk.generate('Build me a REST API with user authentication');
369
368
 
370
369
  // Or stream the response
@@ -386,35 +385,18 @@ const executor = sdk.getWorkflowExecutor();
386
385
  // Progress updates (ideal for status bars / shimmer text)
387
386
  executor.on('workflow:progress', (progress) => {
388
387
  // progress.status: 'planning' | 'awaiting_approval' | 'executing' | 'completed' | 'failed'
389
- // progress.currentStep, progress.totalSteps, progress.percentage
390
- // progress.currentStepDescription — includes retry info if retrying
391
- console.log(`[${progress.percentage}%] Step ${progress.currentStep}/${progress.totalSteps}: ${progress.currentStepDescription}`);
388
+ // progress.percentage, progress.currentStepDescription
389
+ console.log(`[${progress.percentage}%] ${progress.currentStepDescription}`);
392
390
  });
393
391
 
394
- // Step lifecycle
395
- executor.on('workflow:step_start', (step, plan) => {
396
- console.log(`Starting: ${step.description}`);
397
- });
398
-
399
- executor.on('workflow:step_complete', (step, plan) => {
400
- console.log(`Completed: ${step.description}`);
401
- });
402
-
403
- executor.on('workflow:step_failed', (step, error, plan) => {
404
- console.log(`Failed: ${step.description} — ${error.message}`);
405
- });
406
-
407
- executor.on('workflow:step_retry', (step, attempt, plan) => {
408
- console.log(`Retrying: ${step.description} (attempt ${attempt})`);
409
- });
410
-
411
- executor.on('workflow:step_added', (step, plan) => {
412
- console.log(`Dynamic step added: ${step.description}`);
392
+ // Plan created
393
+ executor.on('workflow:plan_created', (plan) => {
394
+ console.log('Plan:', plan.steps.map(s => s.description));
413
395
  });
414
396
 
415
397
  // Workflow completion
416
398
  executor.on('workflow:completed', (plan, result) => {
417
- console.log(`Done! ${result.metrics.stepsCompleted} steps in ${result.metrics.totalDuration}ms`);
399
+ console.log(`Done in ${result.metrics.totalDuration}ms`);
418
400
  });
419
401
 
420
402
  executor.on('workflow:failed', (plan, error) => {
@@ -433,22 +415,10 @@ interface WorkflowConfig {
433
415
  maxSteps?: number; // Max steps in a plan (default: 20)
434
416
  };
435
417
 
436
- steps?: {
437
- enabled: boolean; // Enable step-by-step execution
438
- retryOnFailure?: boolean; // Retry failed steps (default: true)
439
- maxRetries?: number; // Max retries per step (default: 3)
440
- allowDynamicSteps?: boolean; // Allow adding steps during execution
441
- maxTotalSteps?: number; // Max total steps including dynamic (default: 50)
442
- };
443
-
444
418
  progress?: {
445
419
  enabled: boolean; // Emit progress events (default: true)
446
420
  reportPercentage?: boolean; // Include completion percentage
447
421
  };
448
-
449
- onFailure?: {
450
- strategy: 'abort' | 'skip' | 'ask_user';
451
- };
452
422
  }
453
423
  ```
454
424
 
@@ -460,12 +430,12 @@ The SDK provides built-in workflow presets for common use cases:
460
430
  import { DEFAULT_WORKFLOW, AGENT_WORKFLOW, CODING_WORKFLOW, CHAT_WORKFLOW } from 'toolpack-sdk';
461
431
  ```
462
432
 
463
- | Preset | Planning | Steps | Description |
464
- |--------|----------|-------|-------------|
465
- | `DEFAULT_WORKFLOW` | Disabled | Disabled | Direct execution, no planning |
466
- | `AGENT_WORKFLOW` | Enabled (detailed) | Enabled | Full autonomous agent with 11 planning rules |
467
- | `CODING_WORKFLOW` | Enabled (concise) | Enabled | Minimal prompts optimized for coding tasks |
468
- | `CHAT_WORKFLOW` | Disabled | Disabled | Simple conversational mode |
433
+ | Preset | Planning | Description |
434
+ |--------|----------|-------------|
435
+ | `DEFAULT_WORKFLOW` | Disabled | Direct execution, no planning |
436
+ | `AGENT_WORKFLOW` | Enabled (detailed) | Full autonomous agent with plan-direct execution |
437
+ | `CODING_WORKFLOW` | Enabled (concise) | Minimal prompts optimized for coding tasks |
438
+ | `CHAT_WORKFLOW` | Disabled | Simple conversational mode |
469
439
 
470
440
  ### Creating Custom Workflows
471
441
 
@@ -488,15 +458,6 @@ Rules:
488
458
  3. Generate docs in consistent format
489
459
  4. Output JSON: {"summary": "...", "steps": [...]}`,
490
460
  },
491
- steps: {
492
- ...AGENT_WORKFLOW.steps,
493
- stepPrompt: `Execute step {stepNumber}: {stepDescription}
494
-
495
- Analyze code and write clear documentation.
496
- Focus on: purpose, parameters, return values, examples.
497
-
498
- Previous: {previousStepsResults}`,
499
- },
500
461
  };
501
462
 
502
463
  // Use in a custom mode
@@ -511,23 +472,11 @@ const docMode = createMode({
511
472
  });
512
473
  ```
513
474
 
514
- ### Step Prompt Template Variables
515
-
516
- When using custom `stepPrompt`, these variables are automatically substituted:
517
-
518
- | Variable | Description |
519
- |----------|-------------|
520
- | `{stepNumber}` | Current step number (1-indexed) |
521
- | `{planSummary}` | Summary of the overall plan |
522
- | `{stepDescription}` | Description of the current step |
523
- | `{previousStepsResults}` | Output from completed steps (truncated to 2000 chars) |
524
-
525
475
  ### Workflow Prompt Tips
526
476
 
527
477
  - **Keep planning prompts concise** — LLMs perform better with 5-7 clear rules
528
478
  - **Use JSON schema examples** — Include the exact expected output format
529
- - **Avoid meta-commentary in step prompts** — The AI should just execute, not discuss
530
- - **Leverage previous results** — The `{previousStepsResults}` variable provides context
479
+ - **Keep prompts task-oriented** — The AI should execute, not discuss
531
480
 
532
481
  ## Tool Call Events
533
482
 
@@ -551,7 +500,7 @@ client.on('tool:failed', (event) => { /* ... */ });
551
500
 
552
501
  ## Custom Tools
553
502
 
554
- In addition to the 97 built-in tools, you can create and register your own custom tool projects using `createToolProject()`:
503
+ In addition to the 100+ built-in tools, you can create and register your own custom tool projects using `createToolProject()`:
555
504
 
556
505
  ```typescript
557
506
  import { Toolpack, createToolProject } from 'toolpack-sdk';
@@ -647,7 +596,75 @@ const response = await toolpack.chat('How do I configure authentication?');
647
596
  - **Progress Events**: Track embedding progress with `onEmbeddingProgress`
648
597
  - **Metadata Filtering**: Query with filters like `{ hasCode: true, category: 'api' }`
649
598
 
650
- See the [Knowledge package README](../toolpack-knowledge/README.md) for full documentation.
599
+ See the [Knowledge package README](./packages/toolpack-knowledge/README.md) for full documentation.
600
+
601
+ ## Skills
602
+
603
+ The skills system lets you define **reusable behavioral instructions** in `.skill.md` files and automatically inject them into requests based on message relevance — no agent code changes required.
604
+
605
+ ### Quick Start
606
+
607
+ ```typescript
608
+ import { Toolpack, createSkillInterceptor, createSkillTools } from 'toolpack-sdk';
609
+
610
+ const toolpack = await Toolpack.init({
611
+ provider: 'anthropic',
612
+ interceptors: [
613
+ createSkillInterceptor({ dir: '.toolpack/skills', maxSkills: 3, minScore: 0.3 }),
614
+ ],
615
+ customTools: [
616
+ createSkillTools({ dir: '.toolpack/skills' }),
617
+ ],
618
+ });
619
+ ```
620
+
621
+ Create a skill file at `.toolpack/skills/code-review.skill.md`:
622
+
623
+ ```markdown
624
+ ---
625
+ name: code-review
626
+ title: Code Review
627
+ version: 1.0.0
628
+ tags: ["coding", "quality"]
629
+ updated: 2026-01-15T10:00:00.000Z
630
+ ---
631
+
632
+ ## Description
633
+
634
+ Guides the agent through a structured code review process.
635
+
636
+ ## Triggers
637
+
638
+ - "review this code"
639
+ - "check my pull request"
640
+ - "code review"
641
+
642
+ ## Instructions
643
+
644
+ When reviewing code:
645
+ 1. Check for security vulnerabilities first
646
+ 2. Verify test coverage exists
647
+ 3. Flag naming inconsistencies
648
+ 4. Be constructive — suggest improvements, not just problems
649
+ ```
650
+
651
+ When a user sends "review this PR", the interceptor automatically injects the `## Instructions` block before the LLM sees the message.
652
+
653
+ ### How It Works
654
+
655
+ - **`createSkillInterceptor`** — An SDK interceptor that runs BM25 search on every user message and prepends matching skill instructions as a `<skill-instructions>` block. Validates all files at `Toolpack.init()` time.
656
+ - **`createSkillTools`** — Four LLM-callable tools (`skill.create`, `skill.read`, `skill.update`, `skill.list`) for managing the skill library at runtime.
657
+
658
+ ### `createSkillInterceptor` Options
659
+
660
+ | Option | Type | Default | Description |
661
+ |--------|------|---------|-------------|
662
+ | `dir` | string | `.toolpack/skills` | Path to the skill files directory |
663
+ | `maxSkills` | number | `3` | Maximum number of skills injected per message |
664
+ | `minScore` | number | `0.3` | BM25 relevance threshold |
665
+ | `onValidationError` | `'fail'` \| `'warn'` | `'fail'` | How to handle invalid skill files at startup |
666
+
667
+ See the [Skills guide](https://toolpacksdk.com/guides/skills) and [Skill Tools reference](https://toolpacksdk.com/tools/skills) for full documentation.
651
668
 
652
669
  ## AI Agents (@toolpack-sdk/agents)
653
670
 
@@ -968,7 +985,7 @@ class FintechResearchAgent extends ResearchAgent {
968
985
  systemPrompt = `You are a research agent focused on fintech.
969
986
  Always cite sources and flag regulatory implications.`;
970
987
  provider = 'anthropic';
971
- model = 'claude-sonnet-4-20250514';
988
+ model = 'your-model';
972
989
 
973
990
  async onComplete(result) {
974
991
  // Store research in knowledge base
@@ -996,7 +1013,7 @@ class FintechResearchAgent extends ResearchAgent {
996
1013
  - ✅ **Type-Safe** — Full TypeScript support
997
1014
  - ✅ **199 Tests Passing** — Production-ready
998
1015
 
999
- See the [Agents package README](../toolpack-agents/README.md) for full documentation.
1016
+ See the [Agents package README](./packages/toolpack-agents/README.md) for full documentation.
1000
1017
 
1001
1018
  ## Multimodal Support
1002
1019
 
@@ -1474,19 +1491,22 @@ toolpack-sdk/
1474
1491
  │ │ ├── openrouter/ # OpenRouter adapter (OpenAI-compatible, dynamic model discovery)
1475
1492
  │ │ └── ollama/ # Ollama adapter + provider (auto-discovery)
1476
1493
  │ ├── modes/ # Mode system (Agent, Chat, createMode)
1477
- │ ├── workflows/ # Workflow engine (planner, step executor, progress)
1478
- │ ├── tools/ # 97 built-in tools + registry + router + BM25 search
1494
+ │ ├── workflows/ # Workflow engine (planner, executor, progress)
1495
+ │ ├── tools/ # 100+ built-in tools + registry + router + BM25 search
1479
1496
  │ │ ├── fs-tools/ # File system (18 tools)
1480
1497
  │ │ ├── coding-tools/ # Code analysis (12 tools)
1481
- │ │ ├── git-tools/ # Git operations (9 tools)
1482
- │ │ ├── db-tools/ # Database operations (6 tools)
1498
+ │ │ ├── git-tools/ # Git operations (10 tools)
1499
+ │ │ ├── db-tools/ # Database operations (7 tools)
1483
1500
  │ │ ├── exec-tools/ # Command execution (6 tools)
1484
1501
  │ │ ├── http-tools/ # HTTP requests (5 tools)
1485
- │ │ ├── web-tools/ # Web interaction (5 tools)
1502
+ │ │ ├── web-tools/ # Web interaction (9 tools)
1486
1503
  │ │ ├── system-tools/ # System info (5 tools)
1504
+ │ │ ├── github-tools/ # GitHub API (9 tools)
1505
+ │ │ ├── slack-tools/ # Slack messaging (6 tools)
1487
1506
  │ │ ├── diff-tools/ # Patch operations (3 tools)
1488
1507
  │ │ ├── cloud-tools/ # Deployments (3 tools)
1489
1508
  │ │ ├── k8s-tools/ # Kubernetes management (11 tools)
1509
+ │ │ ├── skill-tools/ # Skill management (4 tools)
1490
1510
  │ │ ├── registry.ts # Tool registry and loading
1491
1511
  │ │ ├── router.ts # Tool routing and filtering
1492
1512
  │ │ └── search/ # BM25 tool discovery engine (internal)
@@ -1502,8 +1522,8 @@ toolpack-sdk/
1502
1522
  **Current Version:** 0.1.0
1503
1523
 
1504
1524
  - ✓ **5 Built-in Providers** — OpenAI, Anthropic, Gemini, Ollama, OpenRouter (+ custom provider API)
1505
- - ✓ **90 Built-in Tools** — fs, exec, git, diff, web, coding, db, cloud, http, system, Kubernetes
1506
- - ✓ **Workflow Engine** — AI-driven planning, step execution, retries, dynamic steps, progress events
1525
+ - ✓ **100+ Built-in Tools** — fs, exec, git, diff, web, coding, db, cloud, http, system, Kubernetes, GitHub, Slack, Skills
1526
+ - ✓ **Workflow Engine** — AI-driven planning, plan-direct execution, parallel tool orchestration, progress events
1507
1527
  - ✓ **Mode System** — Agent, Coding, Chat, and custom modes via `createMode()` with `blockAllTools` support
1508
1528
  - ✓ **Tool Search** — BM25-based on-demand tool discovery for large tool libraries
1509
1529
  - ✓ **545 Tests** passing across 81 test files