toolpack-sdk 1.2.0 → 1.3.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 +130 -9
- package/dist/index.cjs +141 -105
- package/dist/index.d.cts +106 -12
- package/dist/index.d.ts +106 -12
- package/dist/index.js +140 -104
- package/package.json +1 -1
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,
|
|
3
|
+
A unified TypeScript/Node.js SDK for building AI-powered applications with multiple providers, 79 built-in tools, a workflow engine, and a flexible mode system — all through a single API.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/toolpack-sdk)
|
|
6
6
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
@@ -17,7 +17,7 @@ A unified TypeScript/Node.js SDK for building AI-powered applications with multi
|
|
|
17
17
|
- **Workflow Engine** — AI-driven planning and step-by-step task execution with progress events
|
|
18
18
|
- **Mode System** — Built-in Agent and Chat modes, plus `createMode()` for custom modes with tool filtering
|
|
19
19
|
- **Custom Providers** — Bring your own provider by implementing the `ProviderAdapter` interface
|
|
20
|
-
- **
|
|
20
|
+
- **79 Built-in Tools** across 10 categories:
|
|
21
21
|
- **MCP Tool Server Integration** — dynamically bridge external Model Context Protocol servers into Toolpack as first-class tools via `createMcpToolProject()` and `disconnectMcpToolProject()`.
|
|
22
22
|
|
|
23
23
|
| Category | Tools | Description |
|
|
@@ -32,6 +32,7 @@ A unified TypeScript/Node.js SDK for building AI-powered applications with multi
|
|
|
32
32
|
| **`system-tools`** | 5 | System info — env vars, cwd, disk usage, system info, set env |
|
|
33
33
|
| **`diff-tools`** | 3 | Patch operations — create, apply, and preview diffs |
|
|
34
34
|
| **`cloud-tools`** | 3 | Deployments — deploy, status, list (via Netlify) |
|
|
35
|
+
| **`mcp-tools`** | 2 | MCP integration — createMcpToolProject, disconnectMcpToolProject |
|
|
35
36
|
|
|
36
37
|
## Quick Start
|
|
37
38
|
|
|
@@ -57,7 +58,7 @@ const sdk = await Toolpack.init({
|
|
|
57
58
|
anthropic: {}, // Reads ANTHROPIC_API_KEY from env
|
|
58
59
|
},
|
|
59
60
|
defaultProvider: 'openai',
|
|
60
|
-
tools: true, // Load all
|
|
61
|
+
tools: true, // Load all 79 built-in tools
|
|
61
62
|
defaultMode: 'agent', // Agent mode with workflow engine
|
|
62
63
|
});
|
|
63
64
|
|
|
@@ -229,13 +230,14 @@ const reasoningModels = allModels.filter(m => m.reasoningTier);
|
|
|
229
230
|
|
|
230
231
|
## Modes
|
|
231
232
|
|
|
232
|
-
Modes control AI behavior by setting a system prompt, filtering available tools, and configuring the workflow engine. The SDK ships with
|
|
233
|
+
Modes control AI behavior by setting a system prompt, filtering available tools, and configuring the workflow engine. The SDK ships with three built-in modes and supports unlimited custom modes.
|
|
233
234
|
|
|
234
235
|
### Built-in Modes
|
|
235
236
|
|
|
236
237
|
| Mode | Tools | Workflow | Description |
|
|
237
238
|
|------|-------|----------|-------------|
|
|
238
239
|
| **Agent** | All tools | Planning + step execution + dynamic steps | Full autonomous access — read, write, execute, browse |
|
|
240
|
+
| **Coding** | All tools | Concise planning + step execution | Optimized for coding tasks — minimal text, file operations |
|
|
239
241
|
| **Chat** | Web/HTTP only | Direct execution (no planning) | Conversational assistant with web access |
|
|
240
242
|
|
|
241
243
|
### Custom Modes
|
|
@@ -402,11 +404,88 @@ interface WorkflowConfig {
|
|
|
402
404
|
};
|
|
403
405
|
|
|
404
406
|
onFailure?: {
|
|
405
|
-
strategy: 'abort' | 'skip' | 'ask_user'
|
|
407
|
+
strategy: 'abort' | 'skip' | 'ask_user';
|
|
406
408
|
};
|
|
407
409
|
}
|
|
408
410
|
```
|
|
409
411
|
|
|
412
|
+
### Custom Workflow Presets
|
|
413
|
+
|
|
414
|
+
The SDK provides built-in workflow presets for common use cases:
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
import { DEFAULT_WORKFLOW, AGENT_WORKFLOW, CODING_WORKFLOW, CHAT_WORKFLOW } from 'toolpack-sdk';
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
| Preset | Planning | Steps | Description |
|
|
421
|
+
|--------|----------|-------|-------------|
|
|
422
|
+
| `DEFAULT_WORKFLOW` | Disabled | Disabled | Direct execution, no planning |
|
|
423
|
+
| `AGENT_WORKFLOW` | Enabled (detailed) | Enabled | Full autonomous agent with 11 planning rules |
|
|
424
|
+
| `CODING_WORKFLOW` | Enabled (concise) | Enabled | Minimal prompts optimized for coding tasks |
|
|
425
|
+
| `CHAT_WORKFLOW` | Disabled | Disabled | Simple conversational mode |
|
|
426
|
+
|
|
427
|
+
### Creating Custom Workflows
|
|
428
|
+
|
|
429
|
+
Define custom workflows by extending presets or creating from scratch:
|
|
430
|
+
|
|
431
|
+
```typescript
|
|
432
|
+
import { WorkflowConfig, AGENT_WORKFLOW } from 'toolpack-sdk';
|
|
433
|
+
|
|
434
|
+
// Extend an existing preset
|
|
435
|
+
const DOC_WORKFLOW: WorkflowConfig = {
|
|
436
|
+
...AGENT_WORKFLOW,
|
|
437
|
+
name: 'Documentation',
|
|
438
|
+
planning: {
|
|
439
|
+
enabled: true,
|
|
440
|
+
planningPrompt: `Create a documentation plan.
|
|
441
|
+
|
|
442
|
+
Rules:
|
|
443
|
+
1. Read existing code files first
|
|
444
|
+
2. Identify public APIs needing documentation
|
|
445
|
+
3. Generate docs in consistent format
|
|
446
|
+
4. Output JSON: {"summary": "...", "steps": [...]}`,
|
|
447
|
+
},
|
|
448
|
+
steps: {
|
|
449
|
+
...AGENT_WORKFLOW.steps,
|
|
450
|
+
stepPrompt: `Execute step {stepNumber}: {stepDescription}
|
|
451
|
+
|
|
452
|
+
Analyze code and write clear documentation.
|
|
453
|
+
Focus on: purpose, parameters, return values, examples.
|
|
454
|
+
|
|
455
|
+
Previous: {previousStepsResults}`,
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// Use in a custom mode
|
|
460
|
+
import { createMode } from 'toolpack-sdk';
|
|
461
|
+
|
|
462
|
+
const docMode = createMode({
|
|
463
|
+
name: 'docs',
|
|
464
|
+
displayName: 'Documentation',
|
|
465
|
+
systemPrompt: 'Documentation assistant. Generate clear API docs.',
|
|
466
|
+
workflow: DOC_WORKFLOW,
|
|
467
|
+
allowedToolCategories: ['filesystem', 'coding'],
|
|
468
|
+
});
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Step Prompt Template Variables
|
|
472
|
+
|
|
473
|
+
When using custom `stepPrompt`, these variables are automatically substituted:
|
|
474
|
+
|
|
475
|
+
| Variable | Description |
|
|
476
|
+
|----------|-------------|
|
|
477
|
+
| `{stepNumber}` | Current step number (1-indexed) |
|
|
478
|
+
| `{planSummary}` | Summary of the overall plan |
|
|
479
|
+
| `{stepDescription}` | Description of the current step |
|
|
480
|
+
| `{previousStepsResults}` | Output from completed steps (truncated to 2000 chars) |
|
|
481
|
+
|
|
482
|
+
### Workflow Prompt Tips
|
|
483
|
+
|
|
484
|
+
- **Keep planning prompts concise** — LLMs perform better with 5-7 clear rules
|
|
485
|
+
- **Use JSON schema examples** — Include the exact expected output format
|
|
486
|
+
- **Avoid meta-commentary in step prompts** — The AI should just execute, not discuss
|
|
487
|
+
- **Leverage previous results** — The `{previousStepsResults}` variable provides context
|
|
488
|
+
|
|
410
489
|
## Tool Call Events
|
|
411
490
|
|
|
412
491
|
The SDK emits events for tool execution, useful for building tool activity logs:
|
|
@@ -429,7 +508,7 @@ client.on('tool:failed', (event) => { /* ... */ });
|
|
|
429
508
|
|
|
430
509
|
## Custom Tools
|
|
431
510
|
|
|
432
|
-
In addition to the
|
|
511
|
+
In addition to the 79 built-in tools, you can create and register your own custom tool projects using `createToolProject()`:
|
|
433
512
|
|
|
434
513
|
```typescript
|
|
435
514
|
import { Toolpack, createToolProject } from 'toolpack-sdk';
|
|
@@ -485,6 +564,48 @@ const sdk = await Toolpack.init({
|
|
|
485
564
|
| `tools` | ToolDefinition[] | ✓ | Array of tool definitions |
|
|
486
565
|
| `dependencies` | Record<string, string> | | npm dependencies (validated at load) |
|
|
487
566
|
|
|
567
|
+
## Knowledge & RAG (Retrieval-Augmented Generation)
|
|
568
|
+
|
|
569
|
+
For AI applications that need to search and reference documentation, use the companion `@toolpack-sdk/knowledge` package:
|
|
570
|
+
|
|
571
|
+
```bash
|
|
572
|
+
npm install @toolpack-sdk/knowledge
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### Quick Start
|
|
576
|
+
|
|
577
|
+
```typescript
|
|
578
|
+
import { Knowledge, MemoryProvider, MarkdownSource, OllamaEmbedder } from '@toolpack-sdk/knowledge';
|
|
579
|
+
import { Toolpack } from 'toolpack-sdk';
|
|
580
|
+
|
|
581
|
+
// Create a knowledge base from markdown files
|
|
582
|
+
const kb = await Knowledge.create({
|
|
583
|
+
provider: new MemoryProvider(),
|
|
584
|
+
sources: [new MarkdownSource('./docs/**/*.md')],
|
|
585
|
+
embedder: new OllamaEmbedder({ model: 'nomic-embed-text' }),
|
|
586
|
+
description: 'Search this for setup and configuration questions.',
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
// Integrate with Toolpack SDK
|
|
590
|
+
const toolpack = await Toolpack.init({
|
|
591
|
+
provider: 'openai',
|
|
592
|
+
knowledge: kb, // Registered as knowledge_search tool
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
// The AI can now search your documentation
|
|
596
|
+
const response = await toolpack.chat('How do I configure authentication?');
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
### Features
|
|
600
|
+
|
|
601
|
+
- **Multiple Providers**: In-memory (`MemoryProvider`) or persistent SQLite (`PersistentKnowledgeProvider`)
|
|
602
|
+
- **Multiple Embedders**: OpenAI, Ollama (local), or custom embedders
|
|
603
|
+
- **Multiple Sources**: Markdown, JSON, SQLite ingestion
|
|
604
|
+
- **Progress Events**: Track embedding progress with `onEmbeddingProgress`
|
|
605
|
+
- **Metadata Filtering**: Query with filters like `{ hasCode: true, category: 'api' }`
|
|
606
|
+
|
|
607
|
+
See the [Knowledge package README](../toolpack-knowledge/README.md) for full documentation.
|
|
608
|
+
|
|
488
609
|
## Multimodal Support
|
|
489
610
|
|
|
490
611
|
The SDK supports multimodal inputs (text + images) across all vision-capable providers. Images can be provided in three formats:
|
|
@@ -807,7 +928,7 @@ toolpack-sdk/
|
|
|
807
928
|
│ │ └── ollama/ # Ollama adapter + provider (auto-discovery)
|
|
808
929
|
│ ├── modes/ # Mode system (Agent, Chat, createMode)
|
|
809
930
|
│ ├── workflows/ # Workflow engine (planner, step executor, progress)
|
|
810
|
-
│ ├── tools/ #
|
|
931
|
+
│ ├── tools/ # 79 built-in tools + registry + router + BM25 search
|
|
811
932
|
│ │ ├── fs-tools/ # File system (18 tools)
|
|
812
933
|
│ │ ├── coding-tools/ # Code analysis (12 tools)
|
|
813
934
|
│ │ ├── git-tools/ # Git operations (9 tools)
|
|
@@ -833,9 +954,9 @@ toolpack-sdk/
|
|
|
833
954
|
**Current Version:** 0.1.0
|
|
834
955
|
|
|
835
956
|
- ✓ **4 Built-in Providers** — OpenAI, Anthropic, Gemini, Ollama (+ custom provider API)
|
|
836
|
-
- ✓ **
|
|
957
|
+
- ✓ **79 Built-in Tools** — fs, exec, git, diff, web, coding, db, cloud, http, system
|
|
837
958
|
- ✓ **Workflow Engine** — AI-driven planning, step execution, retries, dynamic steps, progress events
|
|
838
|
-
- ✓ **Mode System** — Agent, Chat, and custom modes via `createMode()` with `blockAllTools` support
|
|
959
|
+
- ✓ **Mode System** — Agent, Coding, Chat, and custom modes via `createMode()` with `blockAllTools` support
|
|
839
960
|
- ✓ **Tool Search** — BM25-based on-demand tool discovery for large tool libraries
|
|
840
961
|
- ✓ **545 Tests** passing across 81 test files
|
|
841
962
|
|