toolpack-sdk 3.0.0 → 3.2.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
@@ -19,7 +19,7 @@ The TypeScript SDK for building production AI agents — 100+ built-in tools, 8
19
19
  - **Rules** — Always-on behavioral constraints loaded from Markdown files, auto-discovered per mode and globally via `rulesDir`
20
20
  - **HITL Confirmation** — Human-in-the-loop approval for high-risk operations with configurable bypass rules
21
21
  - **Extensible at Every Layer** — Every built-in component is a plug-in point: custom tools (`ToolDefinition`), custom channels (`BaseChannel`), custom provider adapters (`ProviderAdapter`), custom agents (`BaseAgent`), custom modes (`createMode()`), and custom interceptors — all using the same interfaces as the built-ins
22
- - **100+ Built-in Tools** across 12 categories:
22
+ - **100+ Built-in Tools** across 15 categories:
23
23
  - **MCP Client & Server** — consume external MCP servers via `createMcpToolProject()`, or expose Toolpack as an MCP server via `sdk.startMcpServer()` with static/JWT/custom auth, search mode, and agent exposure.
24
24
 
25
25
  | Category | Tools | Description |
@@ -505,7 +505,7 @@ client.on('tool:failed', (event) => { /* ... */ });
505
505
 
506
506
  ## Custom Tools
507
507
 
508
- In addition to the 100+ built-in tools, you can create and register your own custom tool projects using `createToolProject()`:
508
+ In addition to the 100+ built-in tools, you can create and register your own custom tool projects using `createToolProject()`. Built-in tool categories used for mode filtering include `filesystem`, `coding`, `version-control`, `http`, `web`, `github`, `slack`, `execution`, `system`, and others — there is no combined `network` category.
509
509
 
510
510
  ```typescript
511
511
  import { Toolpack, createToolProject } from 'toolpack-sdk';
@@ -540,6 +540,7 @@ const myToolProject = createToolProject({
540
540
  });
541
541
 
542
542
  // Attach custom tools to a mode — scoped to that agent, not global.
543
+ // To replace built-ins by name at init time, pass toolOverrides: [myToolProject].
543
544
  const sdk = await Toolpack.init({
544
545
  provider: 'openai',
545
546
  tools: true,
@@ -554,6 +555,9 @@ const result = await sdk.generate({
554
555
  model: 'gpt-4.1',
555
556
  mode: { ...sdk.getMode()!, customTools: [...myToolProject.tools] },
556
557
  });
558
+
559
+ // Option C: load projects at runtime (rebuilds the tool search index once)
560
+ await sdk.loadToolProjects([myToolProject]);
557
561
  ```
558
562
 
559
563
  ### Tool Project Structure
@@ -606,30 +610,24 @@ const response = await toolpack.chat('How do I configure authentication?');
606
610
 
607
611
  - **Multiple Providers**: In-memory (`MemoryProvider`) or persistent SQLite (`PersistentKnowledgeProvider`)
608
612
  - **Multiple Embedders**: OpenAI, Ollama (local), or custom embedders
609
- - **Multiple Sources**: Markdown, JSON, SQLite ingestion
613
+ - **Multiple Sources**: Markdown, text, web, API, JSON, SQLite, and more
610
614
  - **Progress Events**: Track embedding progress with `onEmbeddingProgress`
611
615
  - **Metadata Filtering**: Query with filters like `{ hasCode: true, category: 'api' }`
616
+ - **Incremental updates**: `ingest()`, `delete()`, and `deleteWhere()` for per-item lifecycle
612
617
 
613
- See the [Knowledge package README](./packages/toolpack-knowledge/README.md) for full documentation.
618
+ See the [Knowledge package README](../toolpack-knowledge/README.md) for full documentation.
614
619
 
615
620
  ## Skills
616
621
 
617
- 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.
622
+ The skills system lets you define **reusable behavioral instructions** in `.skill.md` files and expose them to the agent via LLM-callable tools.
618
623
 
619
624
  ### Quick Start
620
625
 
621
626
  ```typescript
622
- import { Toolpack, createSkillInterceptor, createSkillTools } from 'toolpack-sdk';
627
+ import { createSkillTools } from 'toolpack-sdk';
623
628
 
624
629
  const skillTools = createSkillTools({ dir: '.toolpack/skills' });
625
630
 
626
- const toolpack = await Toolpack.init({
627
- provider: 'anthropic',
628
- interceptors: [
629
- createSkillInterceptor({ dir: '.toolpack/skills', maxSkills: 3, minScore: 0.3 }),
630
- ],
631
- });
632
-
633
631
  // Attach skill tools per agent via ModeConfig.customTools:
634
632
  // agent.mode = { ...agentMode, customTools: [...skillTools.tools] };
635
633
  ```
@@ -664,21 +662,9 @@ When reviewing code:
664
662
  4. Be constructive — suggest improvements, not just problems
665
663
  ```
666
664
 
667
- When a user sends "review this PR", the interceptor automatically injects the `## Instructions` block before the LLM sees the message.
668
-
669
665
  ### How It Works
670
666
 
671
- - **`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.
672
- - **`createSkillTools`** — Four LLM-callable tools (`skill.create`, `skill.read`, `skill.update`, `skill.list`) for managing the skill library at runtime.
673
-
674
- ### `createSkillInterceptor` Options
675
-
676
- | Option | Type | Default | Description |
677
- |--------|------|---------|-------------|
678
- | `dir` | string | `.toolpack/skills` | Path to the skill files directory |
679
- | `maxSkills` | number | `3` | Maximum number of skills injected per message |
680
- | `minScore` | number | `0.3` | BM25 relevance threshold |
681
- | `onValidationError` | `'fail'` \| `'warn'` | `'fail'` | How to handle invalid skill files at startup |
667
+ **`createSkillTools`** registers four LLM-callable tools (`skill.create`, `skill.read`, `skill.update`, `skill.list`) for managing the skill library at runtime. The agent calls `skill.read` to load instructions on demand skills are never auto-injected.
682
668
 
683
669
  See the [Skills guide](https://toolpacksdk.com/guides/skills) and [Skill Tools reference](https://toolpacksdk.com/tools/skills) for full documentation.
684
670
 
@@ -1020,7 +1006,7 @@ class FintechResearchAgent extends ResearchAgent {
1020
1006
 
1021
1007
  ### Features
1022
1008
 
1023
- - ✅ **7 Built-in Channels** — Slack, Telegram, Discord, Email, SMS, Webhook, Scheduled
1009
+ - ✅ **8 Built-in Channels** — Slack, Telegram, Discord, Email, SMS, Webhook, Scheduled, Chat
1024
1010
  - ✅ **4 Built-in Agents** — Research, Coding, Data, Browser
1025
1011
  - ✅ **Event-Driven** — Full lifecycle events for monitoring
1026
1012
  - ✅ **Knowledge Integration** — Conversation memory and RAG
@@ -1033,10 +1019,10 @@ See the [Agents package README](./packages/toolpack-agents/README.md) for full d
1033
1019
 
1034
1020
  ## Multimodal Support
1035
1021
 
1036
- The SDK supports multimodal inputs (text + images) across all vision-capable providers. Images can be provided in three formats:
1022
+ The SDK supports multimodal inputs (text + images + files) across all vision-capable providers. Images can be provided in three formats:
1037
1023
 
1038
1024
  ```typescript
1039
- import { Toolpack, ImageFilePart, ImageDataPart, ImageUrlPart } from 'toolpack-sdk';
1025
+ import { Toolpack, ImageFilePart, ImageDataPart, ImageUrlPart, FilePart } from 'toolpack-sdk';
1040
1026
 
1041
1027
  const sdk = await Toolpack.init({ provider: 'openai' });
1042
1028
 
@@ -1071,6 +1057,30 @@ const response = await sdk.generate({
1071
1057
  });
1072
1058
  ```
1073
1059
 
1060
+ ### File Attachments (Documents)
1061
+
1062
+ Use `FilePart` to attach non-image files such as PDFs. Pass a public or pre-signed URL and the MIME type:
1063
+
1064
+ ```typescript
1065
+ import { FilePart, FILE_LIMITS } from 'toolpack-sdk';
1066
+
1067
+ const doc: FilePart = {
1068
+ type: 'file',
1069
+ file: {
1070
+ url: 'https://example.com/report.pdf',
1071
+ mimeType: 'application/pdf',
1072
+ name: 'report.pdf', // optional
1073
+ size: 204800, // optional bytes, used for client-side limit checks
1074
+ },
1075
+ };
1076
+
1077
+ // FILE_LIMITS.image.maxBytes → 10 MB
1078
+ // FILE_LIMITS.document.maxBytes → 10 MB
1079
+ // FILE_LIMITS.document.maxPages → 20 pages
1080
+ ```
1081
+
1082
+ A data URI (`data:<mime>;base64,<data>`) is also accepted in `file.url` for inline embedding.
1083
+
1074
1084
  ### Provider Behavior
1075
1085
 
1076
1086
  | Provider | File Path | Base64 | URL |
@@ -1080,6 +1090,16 @@ const response = await sdk.generate({
1080
1090
  | Gemini | Converted to base64 | ✓ Native | Downloaded → base64 |
1081
1091
  | Ollama | Converted to base64 | ✓ Native | Downloaded → base64 |
1082
1092
 
1093
+ ### Provider Support for File Attachments (FilePart)
1094
+
1095
+ | Provider | URL | Inline base64 (`data:` URI) |
1096
+ |----------|-----|-----------------------------|
1097
+ | **Anthropic** | ✓ images and documents | ✓ auto-routed to `image` or `document` block |
1098
+ | **Anthropic Vertex** | ✓ | ✓ |
1099
+ | **Gemini** | ✓ (`fileData`) | ✓ (`inlineData`) |
1100
+ | **VertexAI** | ✓ (`fileData`) | ✓ (`inlineData`) |
1101
+ | **OpenAI** | ✓ images and documents | Images only (non-image base64 is dropped) |
1102
+
1083
1103
  ## Configuration
1084
1104
 
1085
1105
  ### Environment Variables
@@ -1225,12 +1245,12 @@ const sdk = await Toolpack.init({
1225
1245
  ```typescript
1226
1246
  import { Toolpack } from 'toolpack-sdk';
1227
1247
 
1228
- // ToolpackInitConfig — fields removed in v2.8:
1248
+ // ToolpackInitConfig — fields removed in v3.0.0:
1229
1249
  // customTools → use ModeConfig.customTools per agent instead
1230
1250
  // modeOverrides → configure modes directly via registerMode()
1231
1251
  // configPath → configuration is now passed inline to Toolpack.init()
1232
1252
  //
1233
- // Fields added in v2.8: logging, hitl, toolsConfig
1253
+ // Fields: logging, hitl, toolsConfig, toolOverrides (v3.1.0)
1234
1254
  const sdk = await Toolpack.init(config: ToolpackInitConfig): Promise<Toolpack>
1235
1255
 
1236
1256
  // Completions (routes through workflow engine if mode has workflow enabled)
@@ -1250,6 +1270,12 @@ sdk.getModes(): ModeConfig[]
1250
1270
  sdk.cycleMode(): ModeConfig
1251
1271
  sdk.registerMode(mode: ModeConfig): void
1252
1272
 
1273
+ // Tool projects
1274
+ await sdk.loadToolProject(project: ToolProject): Promise<void>
1275
+ await sdk.loadToolProjects(projects: ToolProject[]): Promise<void>
1276
+ sdk.searchTools(query: string, category?: string)
1277
+ sdk.getRegisteredToolNames(): string[]
1278
+
1253
1279
  // Internal access
1254
1280
  sdk.getClient(): AIClient
1255
1281
  sdk.getWorkflowExecutor(): WorkflowExecutor