Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 46 additions & 6 deletions packages/toolpack-sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Toolpack SDK

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.
A unified TypeScript/Node.js SDK for building AI-powered applications with multiple providers, 90 built-in tools, a workflow engine, and a flexible mode system — all through a single API.

[![npm version](https://img.shields.io/npm/v/toolpack-sdk.svg)](https://www.npmjs.com/package/toolpack-sdk)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
Expand All @@ -18,7 +18,7 @@ A unified TypeScript/Node.js SDK for building AI-powered applications with multi
- **Mode System** — Built-in Agent and Chat modes, plus `createMode()` for custom modes with tool filtering
- **HITL Confirmation** — Human-in-the-loop approval for high-risk operations with configurable bypass rules
- **Custom Providers** — Bring your own provider by implementing the `ProviderAdapter` interface
- **79 Built-in Tools** across 10 categories:
- **90 Built-in Tools** across 11 categories:
- **MCP Tool Server Integration** — dynamically bridge external Model Context Protocol servers into Toolpack as first-class tools via `createMcpToolProject()` and `disconnectMcpToolProject()`.

| Category | Tools | Description |
Expand All @@ -33,6 +33,7 @@ A unified TypeScript/Node.js SDK for building AI-powered applications with multi
| **`system-tools`** | 5 | System info — env vars, cwd, disk usage, system info, set env |
| **`diff-tools`** | 3 | Patch operations — create, apply, and preview diffs |
| **`cloud-tools`** | 3 | Deployments — deploy, status, list (via Netlify) |
| **`k8s-tools`** | 11 | Kubernetes cluster inspection and management via kubectl |
| **`mcp-tools`** | 2 | MCP integration — createMcpToolProject, disconnectMcpToolProject |

## Quick Start
Expand All @@ -59,7 +60,7 @@ const sdk = await Toolpack.init({
anthropic: {}, // Reads ANTHROPIC_API_KEY from env
},
defaultProvider: 'openai',
tools: true, // Load all 79 built-in tools
tools: true, // Load all 90 built-in tools
defaultMode: 'agent', // Agent mode with workflow engine
});

Expand Down Expand Up @@ -91,6 +92,44 @@ const sdk = await Toolpack.init({
});
```

## Kubernetes Tools

Toolpack SDK now includes a dedicated Kubernetes tool category that exposes `kubectl`-backed operations when `tools: true` is enabled. Use these tools to inspect cluster state, fetch pod logs, apply manifests, and wait for rollout status.

```typescript
const sdk = await Toolpack.init({
provider: 'openai',
tools: true,
defaultMode: 'agent',
});

const podsResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'List pods in the default namespace using Kubernetes tools.',
},
],
});
console.log(podsResponse.content);

const applyResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'Apply the manifest at ./deploy/my-app.yaml to the staging namespace using Kubernetes tools.',
},
],
});
console.log(applyResponse.content);
```

> Requires `kubectl` installed and configured with a valid kubeconfig.

See `packages/toolpack-sdk/docs/examples/kubernetes-usage.ts` for a complete example.

## Providers

### Built-in Providers
Expand Down Expand Up @@ -509,7 +548,7 @@ client.on('tool:failed', (event) => { /* ... */ });

## Custom Tools

In addition to the 79 built-in tools, you can create and register your own custom tool projects using `createToolProject()`:
In addition to the 90 built-in tools, you can create and register your own custom tool projects using `createToolProject()`:

```typescript
import { Toolpack, createToolProject } from 'toolpack-sdk';
Expand Down Expand Up @@ -972,7 +1011,7 @@ toolpack-sdk/
│ │ └── ollama/ # Ollama adapter + provider (auto-discovery)
│ ├── modes/ # Mode system (Agent, Chat, createMode)
│ ├── workflows/ # Workflow engine (planner, step executor, progress)
│ ├── tools/ # 79 built-in tools + registry + router + BM25 search
│ ├── tools/ # 90 built-in tools + registry + router + BM25 search
│ │ ├── fs-tools/ # File system (18 tools)
│ │ ├── coding-tools/ # Code analysis (12 tools)
│ │ ├── git-tools/ # Git operations (9 tools)
Expand All @@ -983,6 +1022,7 @@ toolpack-sdk/
│ │ ├── system-tools/ # System info (5 tools)
│ │ ├── diff-tools/ # Patch operations (3 tools)
│ │ ├── cloud-tools/ # Deployments (3 tools)
│ │ ├── k8s-tools/ # Kubernetes management (11 tools)
│ │ ├── registry.ts # Tool registry and loading
│ │ ├── router.ts # Tool routing and filtering
│ │ └── search/ # BM25 tool discovery engine (internal)
Expand All @@ -998,7 +1038,7 @@ toolpack-sdk/
**Current Version:** 0.1.0

- ✓ **4 Built-in Providers** — OpenAI, Anthropic, Gemini, Ollama (+ custom provider API)
- ✓ **79 Built-in Tools** — fs, exec, git, diff, web, coding, db, cloud, http, system
- ✓ **90 Built-in Tools** — fs, exec, git, diff, web, coding, db, cloud, http, system, Kubernetes
- ✓ **Workflow Engine** — AI-driven planning, step execution, retries, dynamic steps, progress events
- ✓ **Mode System** — Agent, Coding, Chat, and custom modes via `createMode()` with `blockAllTools` support
- ✓ **Tool Search** — BM25-based on-demand tool discovery for large tool libraries
Expand Down
61 changes: 61 additions & 0 deletions packages/toolpack-sdk/docs/examples/kubernetes-usage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Toolpack } from 'toolpack-sdk';

async function runKubernetesExample() {
const sdk = await Toolpack.init({
provider: 'openai',
tools: true,
defaultMode: 'agent',
});

console.log('Listing pods in the default namespace...');
const podsResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'Use the Kubernetes tools to list pods in the default namespace and return the results.',
},
],
});
console.log(podsResponse.content);

console.log('Applying a manifest to staging...');
const applyResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'Apply the manifest at ./deploy/my-app.yaml to the staging namespace using Kubernetes tools.',
},
],
});
console.log(applyResponse.content);

console.log('Waiting for the deployment rollout...');
const rolloutResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'Wait for the my-app deployment rollout to complete in the staging namespace.',
},
],
});
console.log(rolloutResponse.content);

console.log('Fetching logs from the running pod...');
const logsResponse = await sdk.generate({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'Fetch the last 200 lines of logs from the pod my-app-12345 in the staging namespace.',
},
],
});
console.log(logsResponse.content);
}

runKubernetesExample().catch((error) => {
console.error('Kubernetes example failed:', error);
});
2 changes: 1 addition & 1 deletion packages/toolpack-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "toolpack-sdk",
"version": "1.3.0",
"description": "Unified TypeScript SDK for AI providers (OpenAI, Anthropic, Gemini, Ollama) with 72 built-in tools, workflow engine, and mode system for building AI-powered applications",
"description": "Unified TypeScript SDK for AI providers (OpenAI, Anthropic, Gemini, Ollama) with 90 built-in tools, workflow engine, and mode system for building AI-powered applications",
"engines": {
"node": ">=20"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/toolpack-sdk/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,13 @@ export {
cloudDeployTool, cloudStatusTool, cloudListTool,
} from './cloud-tools/index.js';

export {
k8sToolsProject,
k8sListPodsTool, k8sDescribeTool, k8sGetLogsTool,
k8sApplyManifestTool, k8sDeleteResourceTool, k8sListServicesTool,
k8sListDeploymentsTool, k8sGetConfigMapTool,
k8sSwitchContextTool, k8sGetNamespacesTool, k8sWaitForDeploymentTool,
} from './k8s-tools/index.js';

export{ McpToolManager,createMcpToolProject,disconnectMcpToolProject } from './mcp-tools/index.js';
export type { McpToolsConfig, McpServerConfig } from './mcp-tools/index.js';
65 changes: 65 additions & 0 deletions packages/toolpack-sdk/src/tools/k8s-tools/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { expect, test, describe } from 'vitest';
import { k8sToolsProject } from './index.js';
import {
k8sListPodsTool,
k8sDescribeTool,
k8sGetLogsTool,
k8sApplyManifestTool,
k8sDeleteResourceTool,
k8sListServicesTool,
k8sListDeploymentsTool,
k8sGetConfigMapTool,
k8sSwitchContextTool,
k8sGetNamespacesTool,
k8sWaitForDeploymentTool,
} from './tools.js';

describe('k8s-tools', () => {
const expectedToolNames = [
'k8s.list_pods',
'k8s.describe',
'k8s.get_logs',
'k8s.apply_manifest',
'k8s.delete_resource',
'k8s.list_services',
'k8s.list_deployments',
'k8s.get_config_map',
'k8s.switch_context',
'k8s.get_namespaces',
'k8s.wait_for_deployment',
];

test('exports the expected Kubernetes tool names', () => {
expect(k8sToolsProject.manifest.tools).toEqual(expectedToolNames);
});

test('exports tool definitions with execute functions', () => {
const tools = [
k8sListPodsTool,
k8sDescribeTool,
k8sGetLogsTool,
k8sApplyManifestTool,
k8sDeleteResourceTool,
k8sListServicesTool,
k8sListDeploymentsTool,
k8sGetConfigMapTool,
k8sSwitchContextTool,
k8sGetNamespacesTool,
k8sWaitForDeploymentTool,
];

tools.forEach((tool) => {
expect(tool).toHaveProperty('execute');
expect(typeof tool.execute).toBe('function');
});
});

test('k8s tools expose JSON output and dry-run schema options', () => {
expect(k8sListPodsTool.parameters.properties).toHaveProperty('output');
expect(k8sListDeploymentsTool.parameters.properties).toHaveProperty('output');
expect(k8sListServicesTool.parameters.properties).toHaveProperty('output');
expect(k8sGetNamespacesTool.parameters.properties).toHaveProperty('output');
expect(k8sApplyManifestTool.parameters.properties).toHaveProperty('dryRun');
expect(k8sDeleteResourceTool.parameters.properties).toHaveProperty('dryRun');
});
});
66 changes: 66 additions & 0 deletions packages/toolpack-sdk/src/tools/k8s-tools/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import type { ToolProject } from '../types.js';
import {
k8sApplyManifestTool,
k8sDeleteResourceTool,
k8sDescribeTool,
k8sGetConfigMapTool,
k8sGetLogsTool,
k8sGetNamespacesTool,
k8sListDeploymentsTool,
k8sListPodsTool,
k8sListServicesTool,
k8sSwitchContextTool,
k8sWaitForDeploymentTool,
} from './tools.js';

export {
k8sListPodsTool,
k8sDescribeTool,
k8sGetLogsTool,
k8sApplyManifestTool,
k8sDeleteResourceTool,
k8sListServicesTool,
k8sListDeploymentsTool,
k8sGetConfigMapTool,
k8sSwitchContextTool,
k8sGetNamespacesTool,
k8sWaitForDeploymentTool,
};

export const k8sToolsProject: ToolProject = {
manifest: {
key: 'k8s',
name: 'k8s-tools',
displayName: 'Kubernetes',
version: '1.0.0',
description: 'Kubernetes command and cluster inspection tools for working with kubectl and manifests.',
author: 'toolpack-sdk',
tools: [
'k8s.list_pods',
'k8s.describe',
'k8s.get_logs',
'k8s.apply_manifest',
'k8s.delete_resource',
'k8s.list_services',
'k8s.list_deployments',
'k8s.get_config_map',
'k8s.switch_context',
'k8s.get_namespaces',
'k8s.wait_for_deployment',
],
category: 'kubernetes',
},
tools: [
k8sListPodsTool,
k8sDescribeTool,
k8sGetLogsTool,
k8sApplyManifestTool,
k8sDeleteResourceTool,
k8sListServicesTool,
k8sListDeploymentsTool,
k8sGetConfigMapTool,
k8sSwitchContextTool,
k8sGetNamespacesTool,
k8sWaitForDeploymentTool,
],
};
Loading
Loading