@castari/sdk 0.0.1 → 0.0.2

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/dist/server.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { type Options } from '@anthropic-ai/claude-agent-sdk';
1
+ import { tool, type Options } from '@anthropic-ai/claude-agent-sdk';
2
2
  export type CastariServerOptions = Partial<Options> & {
3
3
  port?: number;
4
+ tools?: ReturnType<typeof tool>[];
4
5
  };
5
6
  export declare function serve(options?: CastariServerOptions): Promise<void>;
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@ import { randomBytes } from 'crypto';
2
2
  import { mkdir } from 'fs/promises';
3
3
  import { homedir } from 'os';
4
4
  import { join } from 'path';
5
- import { query, } from '@anthropic-ai/claude-agent-sdk';
5
+ import { query, createSdkMcpServer, } from '@anthropic-ai/claude-agent-sdk';
6
6
  import { CONNECTION_TOKEN_TTL_MS, SERVER_PORT, WORKSPACE_DIR_NAME, } from './const';
7
7
  import { handleMessage } from './message-handler';
8
8
  const workspaceDirectory = process.env.CASTARI_WORKSPACE || join(homedir(), WORKSPACE_DIR_NAME);
@@ -68,6 +68,19 @@ async function* generateMessages() {
68
68
  // Process messages from the SDK and send to WebSocket client
69
69
  async function processMessages(initialOptions) {
70
70
  try {
71
+ // Handle custom tools by creating an SDK MCP server
72
+ let mcpServers = initialOptions.mcpServers || {};
73
+ if (initialOptions.tools && initialOptions.tools.length > 0) {
74
+ const sdkServer = createSdkMcpServer({
75
+ name: 'castari-agent',
76
+ version: '1.0.0',
77
+ tools: initialOptions.tools,
78
+ });
79
+ mcpServers = {
80
+ ...mcpServers,
81
+ 'castari-agent': sdkServer,
82
+ };
83
+ }
71
84
  const options = {
72
85
  settingSources: ['local'],
73
86
  cwd: workspaceDirectory,
@@ -87,6 +100,7 @@ async function processMessages(initialOptions) {
87
100
  }
88
101
  },
89
102
  ...initialOptions, // Merge initial options (tools, systemPrompt, etc.)
103
+ mcpServers, // Override mcpServers with our injected one
90
104
  ...queryConfig, // Merge dynamic config from /config endpoint (overrides initial)
91
105
  ...(queryConfig.anthropicApiKey || process.env.ANTHROPIC_API_KEY
92
106
  ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@castari/sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",