@vorim/sdk 2.2.0 → 2.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/dist/integrations/anthropic.cjs +199 -0
- package/dist/integrations/anthropic.cjs.map +1 -0
- package/dist/integrations/anthropic.d.cts +183 -0
- package/dist/integrations/anthropic.d.ts +183 -0
- package/dist/integrations/anthropic.js +172 -0
- package/dist/integrations/anthropic.js.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/anthropic.ts
|
|
21
|
+
var anthropic_exports = {};
|
|
22
|
+
__export(anthropic_exports, {
|
|
23
|
+
VorimToolRegistry: () => VorimToolRegistry,
|
|
24
|
+
createVorimClaudeAgent: () => createVorimClaudeAgent,
|
|
25
|
+
runAgentLoop: () => runAgentLoop
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(anthropic_exports);
|
|
28
|
+
var VorimToolRegistry = class {
|
|
29
|
+
vorim;
|
|
30
|
+
agentId;
|
|
31
|
+
defaultPermission;
|
|
32
|
+
asyncAudit;
|
|
33
|
+
tools = /* @__PURE__ */ new Map();
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this.vorim = config.vorim;
|
|
36
|
+
this.agentId = config.agentId;
|
|
37
|
+
this.defaultPermission = config.defaultPermission ?? "agent:execute";
|
|
38
|
+
this.asyncAudit = config.asyncAudit ?? true;
|
|
39
|
+
}
|
|
40
|
+
/** Register a tool. */
|
|
41
|
+
add(definition) {
|
|
42
|
+
this.tools.set(definition.name, definition);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/** Register multiple tools. */
|
|
46
|
+
addAll(definitions) {
|
|
47
|
+
for (const def of definitions) this.add(def);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/** Convert registered tools to Anthropic's tool format. */
|
|
51
|
+
toAnthropicTools() {
|
|
52
|
+
return [...this.tools.values()].map((t) => ({
|
|
53
|
+
name: t.name,
|
|
54
|
+
description: t.description,
|
|
55
|
+
input_schema: t.input_schema
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Execute tool_use blocks from a Claude message response.
|
|
60
|
+
* Each call is checked against Vorim permissions and audited.
|
|
61
|
+
* Returns an array of tool_result blocks ready to send back to Claude.
|
|
62
|
+
*/
|
|
63
|
+
async executeToolUseBlocks(toolUseBlocks) {
|
|
64
|
+
return Promise.all(
|
|
65
|
+
toolUseBlocks.map((block) => this.executeSingleBlock(block))
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
async executeSingleBlock(block) {
|
|
69
|
+
const definition = this.tools.get(block.name);
|
|
70
|
+
if (!definition) {
|
|
71
|
+
return {
|
|
72
|
+
type: "tool_result",
|
|
73
|
+
tool_use_id: block.id,
|
|
74
|
+
content: JSON.stringify({ error: `Unknown tool: ${block.name}` }),
|
|
75
|
+
is_error: true
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const scope = definition.permission ?? this.defaultPermission;
|
|
79
|
+
const { allowed, reason } = await this.vorim.check(this.agentId, scope);
|
|
80
|
+
if (!allowed) {
|
|
81
|
+
const event = {
|
|
82
|
+
agent_id: this.agentId,
|
|
83
|
+
event_type: "tool_call",
|
|
84
|
+
action: block.name,
|
|
85
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
86
|
+
permission: scope,
|
|
87
|
+
result: "denied",
|
|
88
|
+
metadata: { reason, framework: "anthropic" }
|
|
89
|
+
};
|
|
90
|
+
this.emitAudit(event);
|
|
91
|
+
return {
|
|
92
|
+
type: "tool_result",
|
|
93
|
+
tool_use_id: block.id,
|
|
94
|
+
content: JSON.stringify({ error: `Permission denied: ${scope}${reason ? ` \u2014 ${reason}` : ""}` }),
|
|
95
|
+
is_error: true
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
const start = Date.now();
|
|
99
|
+
try {
|
|
100
|
+
const result = await definition.execute(block.input);
|
|
101
|
+
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
102
|
+
const event = {
|
|
103
|
+
agent_id: this.agentId,
|
|
104
|
+
event_type: "tool_call",
|
|
105
|
+
action: block.name,
|
|
106
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
107
|
+
permission: scope,
|
|
108
|
+
result: "success",
|
|
109
|
+
latency_ms: Date.now() - start,
|
|
110
|
+
metadata: { framework: "anthropic" }
|
|
111
|
+
};
|
|
112
|
+
this.emitAudit(event);
|
|
113
|
+
return { type: "tool_result", tool_use_id: block.id, content };
|
|
114
|
+
} catch (err) {
|
|
115
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
116
|
+
const event = {
|
|
117
|
+
agent_id: this.agentId,
|
|
118
|
+
event_type: "tool_call",
|
|
119
|
+
action: block.name,
|
|
120
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
121
|
+
permission: scope,
|
|
122
|
+
result: "error",
|
|
123
|
+
latency_ms: Date.now() - start,
|
|
124
|
+
error_code: err instanceof Error ? err.name : "UNKNOWN",
|
|
125
|
+
metadata: { error: errMsg, framework: "anthropic" }
|
|
126
|
+
};
|
|
127
|
+
this.emitAudit(event);
|
|
128
|
+
return {
|
|
129
|
+
type: "tool_result",
|
|
130
|
+
tool_use_id: block.id,
|
|
131
|
+
content: JSON.stringify({ error: errMsg }),
|
|
132
|
+
is_error: true
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
emitAudit(event) {
|
|
137
|
+
this.vorim.emit(event).catch(() => {
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
async function runAgentLoop(config) {
|
|
142
|
+
const {
|
|
143
|
+
anthropic,
|
|
144
|
+
model = "claude-sonnet-4-20250514",
|
|
145
|
+
systemPrompt,
|
|
146
|
+
maxIterations = 10,
|
|
147
|
+
maxTokens = 1024,
|
|
148
|
+
registry,
|
|
149
|
+
userMessage
|
|
150
|
+
} = config;
|
|
151
|
+
const tools = registry.toAnthropicTools();
|
|
152
|
+
const messages = [{ role: "user", content: userMessage }];
|
|
153
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
154
|
+
const response = await anthropic.messages.create({
|
|
155
|
+
model,
|
|
156
|
+
max_tokens: maxTokens,
|
|
157
|
+
...systemPrompt ? { system: systemPrompt } : {},
|
|
158
|
+
messages,
|
|
159
|
+
...tools.length > 0 ? { tools } : {}
|
|
160
|
+
});
|
|
161
|
+
if (response.stop_reason === "end_turn" || response.stop_reason !== "tool_use") {
|
|
162
|
+
const textBlocks = response.content.filter((b) => b.type === "text");
|
|
163
|
+
return textBlocks.map((b) => b.text).join("") || "";
|
|
164
|
+
}
|
|
165
|
+
const toolUseBlocks = response.content.filter((b) => b.type === "tool_use");
|
|
166
|
+
const toolResults = await registry.executeToolUseBlocks(toolUseBlocks);
|
|
167
|
+
messages.push({ role: "assistant", content: response.content });
|
|
168
|
+
messages.push({ role: "user", content: toolResults });
|
|
169
|
+
}
|
|
170
|
+
return "";
|
|
171
|
+
}
|
|
172
|
+
async function createVorimClaudeAgent(config) {
|
|
173
|
+
const { vorim, name, description, capabilities, scopes, tools } = config;
|
|
174
|
+
const registration = await vorim.register({
|
|
175
|
+
name,
|
|
176
|
+
description,
|
|
177
|
+
capabilities,
|
|
178
|
+
scopes
|
|
179
|
+
});
|
|
180
|
+
const agentId = registration.agent.agent_id;
|
|
181
|
+
const registry = new VorimToolRegistry({ vorim, agentId });
|
|
182
|
+
registry.addAll(tools);
|
|
183
|
+
return {
|
|
184
|
+
agentId,
|
|
185
|
+
registration,
|
|
186
|
+
registry,
|
|
187
|
+
privateKey: registration.private_key
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function truncate(str, max) {
|
|
191
|
+
return str.length > max ? str.slice(0, max) + "\u2026" : str;
|
|
192
|
+
}
|
|
193
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
+
0 && (module.exports = {
|
|
195
|
+
VorimToolRegistry,
|
|
196
|
+
createVorimClaudeAgent,
|
|
197
|
+
runAgentLoop
|
|
198
|
+
});
|
|
199
|
+
//# sourceMappingURL=anthropic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/anthropic.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — Anthropic/Claude Integration\n// Wraps Anthropic tool use with Vorim permission checks, audit trails,\n// and agent identity. Works with the Anthropic Node.js SDK (messages API\n// with tool use).\n//\n// Peer dependency: @anthropic-ai/sdk >=0.30.0\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope, AuditEventInput } from '../types.js';\n\n// ─── Re-declared Anthropic types (peer dependency — not bundled) ──────────\n\ninterface AnthropicTool {\n name: string;\n description: string;\n input_schema: Record<string, unknown>;\n}\n\ninterface ToolUseBlock {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n}\n\ninterface ToolResultBlock {\n type: 'tool_result';\n tool_use_id: string;\n content: string;\n is_error?: boolean;\n}\n\n// ─── Configuration ────────────────────────────────────────────────────────\n\nexport interface VorimToolDefinition<TArgs = Record<string, unknown>, TResult = unknown> {\n /** Tool name (must match the tool name sent to Claude). */\n name: string;\n /** Description shown to Claude. */\n description: string;\n /** JSON Schema for the tool's input. */\n input_schema: Record<string, unknown>;\n /** The function to execute when the tool is called. */\n execute: (args: TArgs) => Promise<TResult>;\n /** Vorim permission scope required. @default 'agent:execute' */\n permission?: PermissionScope;\n}\n\nexport interface VorimAnthropicConfig {\n /** Vorim SDK instance. */\n vorim: VorimSDK;\n /** The Vorim agent_id. */\n agentId: string;\n /** Default permission scope for tools without an explicit one. @default 'agent:execute' */\n defaultPermission?: PermissionScope;\n /** Whether to emit audit events asynchronously (fire-and-forget). @default true */\n asyncAudit?: boolean;\n}\n\n// ─── Tool Registry ────────────────────────────────────────────────────────\n\n/**\n * Manages a set of tools with Vorim permission checks and audit logging.\n * Converts tools to Anthropic's tool format and handles execution of\n * tool_use blocks from Claude's response.\n *\n * @example\n * ```ts\n * import Anthropic from \"@anthropic-ai/sdk\";\n * import createVorim from \"@vorim/sdk\";\n * import { VorimToolRegistry } from \"@vorim/sdk/integrations/anthropic\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n * const anthropic = new Anthropic();\n *\n * const registry = new VorimToolRegistry({\n * vorim,\n * agentId: \"agid_acme_a1b2c3d4\",\n * });\n *\n * registry.add({\n * name: \"search_docs\",\n * description: \"Search internal documents\",\n * input_schema: {\n * type: \"object\",\n * properties: { query: { type: \"string\" } },\n * required: [\"query\"],\n * },\n * execute: async ({ query }) => searchDocs(query),\n * permission: \"agent:read\",\n * });\n *\n * const response = await anthropic.messages.create({\n * model: \"claude-sonnet-4-20250514\",\n * max_tokens: 1024,\n * messages,\n * tools: registry.toAnthropicTools(),\n * });\n *\n * // Execute tool_use blocks from response\n * const toolResults = await registry.executeToolUseBlocks(\n * response.content.filter(b => b.type === \"tool_use\")\n * );\n * ```\n */\nexport class VorimToolRegistry {\n private vorim: VorimSDK;\n private agentId: string;\n private defaultPermission: PermissionScope;\n private asyncAudit: boolean;\n private tools = new Map<string, VorimToolDefinition>();\n\n constructor(config: VorimAnthropicConfig) {\n this.vorim = config.vorim;\n this.agentId = config.agentId;\n this.defaultPermission = config.defaultPermission ?? 'agent:execute';\n this.asyncAudit = config.asyncAudit ?? true;\n }\n\n /** Register a tool. */\n add<TArgs, TResult>(definition: VorimToolDefinition<TArgs, TResult>): this {\n this.tools.set(definition.name, definition as VorimToolDefinition);\n return this;\n }\n\n /** Register multiple tools. */\n addAll(definitions: VorimToolDefinition[]): this {\n for (const def of definitions) this.add(def);\n return this;\n }\n\n /** Convert registered tools to Anthropic's tool format. */\n toAnthropicTools(): AnthropicTool[] {\n return [...this.tools.values()].map(t => ({\n name: t.name,\n description: t.description,\n input_schema: t.input_schema,\n }));\n }\n\n /**\n * Execute tool_use blocks from a Claude message response.\n * Each call is checked against Vorim permissions and audited.\n * Returns an array of tool_result blocks ready to send back to Claude.\n */\n async executeToolUseBlocks(toolUseBlocks: ToolUseBlock[]): Promise<ToolResultBlock[]> {\n return Promise.all(\n toolUseBlocks.map(block => this.executeSingleBlock(block)),\n );\n }\n\n private async executeSingleBlock(block: ToolUseBlock): Promise<ToolResultBlock> {\n const definition = this.tools.get(block.name);\n\n if (!definition) {\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: `Unknown tool: ${block.name}` }),\n is_error: true,\n };\n }\n\n const scope = definition.permission ?? this.defaultPermission;\n\n // 1. Permission check\n const { allowed, reason } = await this.vorim.check(this.agentId, scope);\n\n if (!allowed) {\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'denied',\n metadata: { reason, framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: `Permission denied: ${scope}${reason ? ` — ${reason}` : ''}` }),\n is_error: true,\n };\n }\n\n // 2. Execute\n const start = Date.now();\n try {\n const result = await definition.execute(block.input as any);\n const content = typeof result === 'string' ? result : JSON.stringify(result);\n\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'success',\n latency_ms: Date.now() - start,\n metadata: { framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return { type: 'tool_result', tool_use_id: block.id, content };\n } catch (err) {\n const errMsg = err instanceof Error ? err.message : String(err);\n\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'error',\n latency_ms: Date.now() - start,\n error_code: err instanceof Error ? err.name : 'UNKNOWN',\n metadata: { error: errMsg, framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: errMsg }),\n is_error: true,\n };\n }\n }\n\n private emitAudit(event: AuditEventInput): void {\n this.vorim.emit(event).catch(() => {});\n }\n}\n\n// ─── Agent Loop ───────────────────────────────────────────────────────────\n\n/** Minimal Anthropic client interface (avoids importing the full SDK). */\ninterface AnthropicClient {\n messages: {\n create(params: any): Promise<any>;\n };\n}\n\nexport interface VorimAgentLoopConfig extends VorimAnthropicConfig {\n /** Anthropic client instance. */\n anthropic: AnthropicClient;\n /** Model to use. @default 'claude-sonnet-4-20250514' */\n model?: string;\n /** System prompt for the agent. */\n systemPrompt?: string;\n /** Maximum tool-use iterations before stopping. @default 10 */\n maxIterations?: number;\n /** Max tokens per response. @default 1024 */\n maxTokens?: number;\n}\n\n/**\n * Runs a complete agent loop with Claude tool use, Vorim\n * permission enforcement, and audit logging.\n *\n * @example\n * ```ts\n * import Anthropic from \"@anthropic-ai/sdk\";\n * import createVorim from \"@vorim/sdk\";\n * import { runAgentLoop, VorimToolRegistry } from \"@vorim/sdk/integrations/anthropic\";\n *\n * const registry = new VorimToolRegistry({ vorim, agentId });\n * registry.add({ name: \"search\", ... });\n *\n * const response = await runAgentLoop({\n * vorim,\n * agentId,\n * anthropic: new Anthropic(),\n * model: \"claude-sonnet-4-20250514\",\n * systemPrompt: \"You are a helpful assistant.\",\n * registry,\n * userMessage: \"Find docs about onboarding\",\n * });\n * ```\n */\nexport async function runAgentLoop(\n config: VorimAgentLoopConfig & {\n registry: VorimToolRegistry;\n userMessage: string;\n },\n): Promise<string> {\n const {\n anthropic,\n model = 'claude-sonnet-4-20250514',\n systemPrompt,\n maxIterations = 10,\n maxTokens = 1024,\n registry,\n userMessage,\n } = config;\n\n const tools = registry.toAnthropicTools();\n const messages: any[] = [{ role: 'user', content: userMessage }];\n\n for (let i = 0; i < maxIterations; i++) {\n const response = await anthropic.messages.create({\n model,\n max_tokens: maxTokens,\n ...(systemPrompt ? { system: systemPrompt } : {}),\n messages,\n ...(tools.length > 0 ? { tools } : {}),\n });\n\n // If stop_reason is \"end_turn\" — Claude is done\n if (response.stop_reason === 'end_turn' || response.stop_reason !== 'tool_use') {\n const textBlocks = response.content.filter((b: any) => b.type === 'text');\n return textBlocks.map((b: any) => b.text).join('') || '';\n }\n\n // Extract tool_use blocks and execute\n const toolUseBlocks = response.content.filter((b: any) => b.type === 'tool_use');\n const toolResults = await registry.executeToolUseBlocks(toolUseBlocks);\n\n // Append assistant response and tool results to conversation\n messages.push({ role: 'assistant', content: response.content });\n messages.push({ role: 'user', content: toolResults });\n }\n\n return '';\n}\n\n// ─── Agent Registration Helper ───────────────────────────────────────────\n\n/**\n * Registers a new agent with Vorim and returns a ready-to-use tool registry\n * configured for Anthropic/Claude.\n *\n * @example\n * ```ts\n * const { agentId, registry } = await createVorimClaudeAgent({\n * vorim,\n * name: \"claude-assistant\",\n * capabilities: [\"search\", \"calculate\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * tools: [searchTool, calcTool],\n * });\n * ```\n */\nexport async function createVorimClaudeAgent(config: {\n vorim: VorimSDK;\n name: string;\n description?: string;\n capabilities: string[];\n scopes: PermissionScope[];\n tools: VorimToolDefinition[];\n}) {\n const { vorim, name, description, capabilities, scopes, tools } = config;\n\n const registration = await vorim.register({\n name,\n description,\n capabilities,\n scopes,\n });\n\n const agentId = registration.agent.agent_id;\n const registry = new VorimToolRegistry({ vorim, agentId });\n registry.addAll(tools);\n\n return {\n agentId,\n registration,\n registry,\n privateKey: registration.private_key,\n };\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────\n\nfunction truncate(str: string, max: number): string {\n return str.length > max ? str.slice(0, max) + '…' : str;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0GO,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,oBAAI,IAAiC;AAAA,EAErD,YAAY,QAA8B;AACxC,SAAK,QAAQ,OAAO;AACpB,SAAK,UAAU,OAAO;AACtB,SAAK,oBAAoB,OAAO,qBAAqB;AACrD,SAAK,aAAa,OAAO,cAAc;AAAA,EACzC;AAAA;AAAA,EAGA,IAAoB,YAAuD;AACzE,SAAK,MAAM,IAAI,WAAW,MAAM,UAAiC;AACjE,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,aAA0C;AAC/C,eAAW,OAAO,YAAa,MAAK,IAAI,GAAG;AAC3C,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,mBAAoC;AAClC,WAAO,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,QAAM;AAAA,MACxC,MAAM,EAAE;AAAA,MACR,aAAa,EAAE;AAAA,MACf,cAAc,EAAE;AAAA,IAClB,EAAE;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,qBAAqB,eAA2D;AACpF,WAAO,QAAQ;AAAA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ationResult } from '../index.cjs';
|
|
2
|
+
|
|
3
|
+
interface AnthropicTool {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface ToolUseBlock {
|
|
9
|
+
type: 'tool_use';
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
input: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface ToolResultBlock {
|
|
15
|
+
type: 'tool_result';
|
|
16
|
+
tool_use_id: string;
|
|
17
|
+
content: string;
|
|
18
|
+
is_error?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface VorimToolDefinition<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
21
|
+
/** Tool name (must match the tool name sent to Claude). */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Description shown to Claude. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema for the tool's input. */
|
|
26
|
+
input_schema: Record<string, unknown>;
|
|
27
|
+
/** The function to execute when the tool is called. */
|
|
28
|
+
execute: (args: TArgs) => Promise<TResult>;
|
|
29
|
+
/** Vorim permission scope required. @default 'agent:execute' */
|
|
30
|
+
permission?: PermissionScope;
|
|
31
|
+
}
|
|
32
|
+
interface VorimAnthropicConfig {
|
|
33
|
+
/** Vorim SDK instance. */
|
|
34
|
+
vorim: VorimSDK;
|
|
35
|
+
/** The Vorim agent_id. */
|
|
36
|
+
agentId: string;
|
|
37
|
+
/** Default permission scope for tools without an explicit one. @default 'agent:execute' */
|
|
38
|
+
defaultPermission?: PermissionScope;
|
|
39
|
+
/** Whether to emit audit events asynchronously (fire-and-forget). @default true */
|
|
40
|
+
asyncAudit?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Manages a set of tools with Vorim permission checks and audit logging.
|
|
44
|
+
* Converts tools to Anthropic's tool format and handles execution of
|
|
45
|
+
* tool_use blocks from Claude's response.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
50
|
+
* import createVorim from "@vorim/sdk";
|
|
51
|
+
* import { VorimToolRegistry } from "@vorim/sdk/integrations/anthropic";
|
|
52
|
+
*
|
|
53
|
+
* const vorim = createVorim({ apiKey: "agid_sk_live_..." });
|
|
54
|
+
* const anthropic = new Anthropic();
|
|
55
|
+
*
|
|
56
|
+
* const registry = new VorimToolRegistry({
|
|
57
|
+
* vorim,
|
|
58
|
+
* agentId: "agid_acme_a1b2c3d4",
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* registry.add({
|
|
62
|
+
* name: "search_docs",
|
|
63
|
+
* description: "Search internal documents",
|
|
64
|
+
* input_schema: {
|
|
65
|
+
* type: "object",
|
|
66
|
+
* properties: { query: { type: "string" } },
|
|
67
|
+
* required: ["query"],
|
|
68
|
+
* },
|
|
69
|
+
* execute: async ({ query }) => searchDocs(query),
|
|
70
|
+
* permission: "agent:read",
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const response = await anthropic.messages.create({
|
|
74
|
+
* model: "claude-sonnet-4-20250514",
|
|
75
|
+
* max_tokens: 1024,
|
|
76
|
+
* messages,
|
|
77
|
+
* tools: registry.toAnthropicTools(),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Execute tool_use blocks from response
|
|
81
|
+
* const toolResults = await registry.executeToolUseBlocks(
|
|
82
|
+
* response.content.filter(b => b.type === "tool_use")
|
|
83
|
+
* );
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare class VorimToolRegistry {
|
|
87
|
+
private vorim;
|
|
88
|
+
private agentId;
|
|
89
|
+
private defaultPermission;
|
|
90
|
+
private asyncAudit;
|
|
91
|
+
private tools;
|
|
92
|
+
constructor(config: VorimAnthropicConfig);
|
|
93
|
+
/** Register a tool. */
|
|
94
|
+
add<TArgs, TResult>(definition: VorimToolDefinition<TArgs, TResult>): this;
|
|
95
|
+
/** Register multiple tools. */
|
|
96
|
+
addAll(definitions: VorimToolDefinition[]): this;
|
|
97
|
+
/** Convert registered tools to Anthropic's tool format. */
|
|
98
|
+
toAnthropicTools(): AnthropicTool[];
|
|
99
|
+
/**
|
|
100
|
+
* Execute tool_use blocks from a Claude message response.
|
|
101
|
+
* Each call is checked against Vorim permissions and audited.
|
|
102
|
+
* Returns an array of tool_result blocks ready to send back to Claude.
|
|
103
|
+
*/
|
|
104
|
+
executeToolUseBlocks(toolUseBlocks: ToolUseBlock[]): Promise<ToolResultBlock[]>;
|
|
105
|
+
private executeSingleBlock;
|
|
106
|
+
private emitAudit;
|
|
107
|
+
}
|
|
108
|
+
/** Minimal Anthropic client interface (avoids importing the full SDK). */
|
|
109
|
+
interface AnthropicClient {
|
|
110
|
+
messages: {
|
|
111
|
+
create(params: any): Promise<any>;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
interface VorimAgentLoopConfig extends VorimAnthropicConfig {
|
|
115
|
+
/** Anthropic client instance. */
|
|
116
|
+
anthropic: AnthropicClient;
|
|
117
|
+
/** Model to use. @default 'claude-sonnet-4-20250514' */
|
|
118
|
+
model?: string;
|
|
119
|
+
/** System prompt for the agent. */
|
|
120
|
+
systemPrompt?: string;
|
|
121
|
+
/** Maximum tool-use iterations before stopping. @default 10 */
|
|
122
|
+
maxIterations?: number;
|
|
123
|
+
/** Max tokens per response. @default 1024 */
|
|
124
|
+
maxTokens?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Runs a complete agent loop with Claude tool use, Vorim
|
|
128
|
+
* permission enforcement, and audit logging.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
133
|
+
* import createVorim from "@vorim/sdk";
|
|
134
|
+
* import { runAgentLoop, VorimToolRegistry } from "@vorim/sdk/integrations/anthropic";
|
|
135
|
+
*
|
|
136
|
+
* const registry = new VorimToolRegistry({ vorim, agentId });
|
|
137
|
+
* registry.add({ name: "search", ... });
|
|
138
|
+
*
|
|
139
|
+
* const response = await runAgentLoop({
|
|
140
|
+
* vorim,
|
|
141
|
+
* agentId,
|
|
142
|
+
* anthropic: new Anthropic(),
|
|
143
|
+
* model: "claude-sonnet-4-20250514",
|
|
144
|
+
* systemPrompt: "You are a helpful assistant.",
|
|
145
|
+
* registry,
|
|
146
|
+
* userMessage: "Find docs about onboarding",
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare function runAgentLoop(config: VorimAgentLoopConfig & {
|
|
151
|
+
registry: VorimToolRegistry;
|
|
152
|
+
userMessage: string;
|
|
153
|
+
}): Promise<string>;
|
|
154
|
+
/**
|
|
155
|
+
* Registers a new agent with Vorim and returns a ready-to-use tool registry
|
|
156
|
+
* configured for Anthropic/Claude.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const { agentId, registry } = await createVorimClaudeAgent({
|
|
161
|
+
* vorim,
|
|
162
|
+
* name: "claude-assistant",
|
|
163
|
+
* capabilities: ["search", "calculate"],
|
|
164
|
+
* scopes: ["agent:read", "agent:execute"],
|
|
165
|
+
* tools: [searchTool, calcTool],
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare function createVorimClaudeAgent(config: {
|
|
170
|
+
vorim: VorimSDK;
|
|
171
|
+
name: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
capabilities: string[];
|
|
174
|
+
scopes: PermissionScope[];
|
|
175
|
+
tools: VorimToolDefinition[];
|
|
176
|
+
}): Promise<{
|
|
177
|
+
agentId: string;
|
|
178
|
+
registration: AgentRegistrationResult;
|
|
179
|
+
registry: VorimToolRegistry;
|
|
180
|
+
privateKey: string;
|
|
181
|
+
}>;
|
|
182
|
+
|
|
183
|
+
export { type VorimAgentLoopConfig, type VorimAnthropicConfig, type VorimToolDefinition, VorimToolRegistry, createVorimClaudeAgent, runAgentLoop };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { VorimSDK, PermissionScope, AgentRegistrationResult } from '../index.js';
|
|
2
|
+
|
|
3
|
+
interface AnthropicTool {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
input_schema: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface ToolUseBlock {
|
|
9
|
+
type: 'tool_use';
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
input: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface ToolResultBlock {
|
|
15
|
+
type: 'tool_result';
|
|
16
|
+
tool_use_id: string;
|
|
17
|
+
content: string;
|
|
18
|
+
is_error?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface VorimToolDefinition<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
21
|
+
/** Tool name (must match the tool name sent to Claude). */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Description shown to Claude. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema for the tool's input. */
|
|
26
|
+
input_schema: Record<string, unknown>;
|
|
27
|
+
/** The function to execute when the tool is called. */
|
|
28
|
+
execute: (args: TArgs) => Promise<TResult>;
|
|
29
|
+
/** Vorim permission scope required. @default 'agent:execute' */
|
|
30
|
+
permission?: PermissionScope;
|
|
31
|
+
}
|
|
32
|
+
interface VorimAnthropicConfig {
|
|
33
|
+
/** Vorim SDK instance. */
|
|
34
|
+
vorim: VorimSDK;
|
|
35
|
+
/** The Vorim agent_id. */
|
|
36
|
+
agentId: string;
|
|
37
|
+
/** Default permission scope for tools without an explicit one. @default 'agent:execute' */
|
|
38
|
+
defaultPermission?: PermissionScope;
|
|
39
|
+
/** Whether to emit audit events asynchronously (fire-and-forget). @default true */
|
|
40
|
+
asyncAudit?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Manages a set of tools with Vorim permission checks and audit logging.
|
|
44
|
+
* Converts tools to Anthropic's tool format and handles execution of
|
|
45
|
+
* tool_use blocks from Claude's response.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
50
|
+
* import createVorim from "@vorim/sdk";
|
|
51
|
+
* import { VorimToolRegistry } from "@vorim/sdk/integrations/anthropic";
|
|
52
|
+
*
|
|
53
|
+
* const vorim = createVorim({ apiKey: "agid_sk_live_..." });
|
|
54
|
+
* const anthropic = new Anthropic();
|
|
55
|
+
*
|
|
56
|
+
* const registry = new VorimToolRegistry({
|
|
57
|
+
* vorim,
|
|
58
|
+
* agentId: "agid_acme_a1b2c3d4",
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* registry.add({
|
|
62
|
+
* name: "search_docs",
|
|
63
|
+
* description: "Search internal documents",
|
|
64
|
+
* input_schema: {
|
|
65
|
+
* type: "object",
|
|
66
|
+
* properties: { query: { type: "string" } },
|
|
67
|
+
* required: ["query"],
|
|
68
|
+
* },
|
|
69
|
+
* execute: async ({ query }) => searchDocs(query),
|
|
70
|
+
* permission: "agent:read",
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const response = await anthropic.messages.create({
|
|
74
|
+
* model: "claude-sonnet-4-20250514",
|
|
75
|
+
* max_tokens: 1024,
|
|
76
|
+
* messages,
|
|
77
|
+
* tools: registry.toAnthropicTools(),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Execute tool_use blocks from response
|
|
81
|
+
* const toolResults = await registry.executeToolUseBlocks(
|
|
82
|
+
* response.content.filter(b => b.type === "tool_use")
|
|
83
|
+
* );
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare class VorimToolRegistry {
|
|
87
|
+
private vorim;
|
|
88
|
+
private agentId;
|
|
89
|
+
private defaultPermission;
|
|
90
|
+
private asyncAudit;
|
|
91
|
+
private tools;
|
|
92
|
+
constructor(config: VorimAnthropicConfig);
|
|
93
|
+
/** Register a tool. */
|
|
94
|
+
add<TArgs, TResult>(definition: VorimToolDefinition<TArgs, TResult>): this;
|
|
95
|
+
/** Register multiple tools. */
|
|
96
|
+
addAll(definitions: VorimToolDefinition[]): this;
|
|
97
|
+
/** Convert registered tools to Anthropic's tool format. */
|
|
98
|
+
toAnthropicTools(): AnthropicTool[];
|
|
99
|
+
/**
|
|
100
|
+
* Execute tool_use blocks from a Claude message response.
|
|
101
|
+
* Each call is checked against Vorim permissions and audited.
|
|
102
|
+
* Returns an array of tool_result blocks ready to send back to Claude.
|
|
103
|
+
*/
|
|
104
|
+
executeToolUseBlocks(toolUseBlocks: ToolUseBlock[]): Promise<ToolResultBlock[]>;
|
|
105
|
+
private executeSingleBlock;
|
|
106
|
+
private emitAudit;
|
|
107
|
+
}
|
|
108
|
+
/** Minimal Anthropic client interface (avoids importing the full SDK). */
|
|
109
|
+
interface AnthropicClient {
|
|
110
|
+
messages: {
|
|
111
|
+
create(params: any): Promise<any>;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
interface VorimAgentLoopConfig extends VorimAnthropicConfig {
|
|
115
|
+
/** Anthropic client instance. */
|
|
116
|
+
anthropic: AnthropicClient;
|
|
117
|
+
/** Model to use. @default 'claude-sonnet-4-20250514' */
|
|
118
|
+
model?: string;
|
|
119
|
+
/** System prompt for the agent. */
|
|
120
|
+
systemPrompt?: string;
|
|
121
|
+
/** Maximum tool-use iterations before stopping. @default 10 */
|
|
122
|
+
maxIterations?: number;
|
|
123
|
+
/** Max tokens per response. @default 1024 */
|
|
124
|
+
maxTokens?: number;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Runs a complete agent loop with Claude tool use, Vorim
|
|
128
|
+
* permission enforcement, and audit logging.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import Anthropic from "@anthropic-ai/sdk";
|
|
133
|
+
* import createVorim from "@vorim/sdk";
|
|
134
|
+
* import { runAgentLoop, VorimToolRegistry } from "@vorim/sdk/integrations/anthropic";
|
|
135
|
+
*
|
|
136
|
+
* const registry = new VorimToolRegistry({ vorim, agentId });
|
|
137
|
+
* registry.add({ name: "search", ... });
|
|
138
|
+
*
|
|
139
|
+
* const response = await runAgentLoop({
|
|
140
|
+
* vorim,
|
|
141
|
+
* agentId,
|
|
142
|
+
* anthropic: new Anthropic(),
|
|
143
|
+
* model: "claude-sonnet-4-20250514",
|
|
144
|
+
* systemPrompt: "You are a helpful assistant.",
|
|
145
|
+
* registry,
|
|
146
|
+
* userMessage: "Find docs about onboarding",
|
|
147
|
+
* });
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
declare function runAgentLoop(config: VorimAgentLoopConfig & {
|
|
151
|
+
registry: VorimToolRegistry;
|
|
152
|
+
userMessage: string;
|
|
153
|
+
}): Promise<string>;
|
|
154
|
+
/**
|
|
155
|
+
* Registers a new agent with Vorim and returns a ready-to-use tool registry
|
|
156
|
+
* configured for Anthropic/Claude.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const { agentId, registry } = await createVorimClaudeAgent({
|
|
161
|
+
* vorim,
|
|
162
|
+
* name: "claude-assistant",
|
|
163
|
+
* capabilities: ["search", "calculate"],
|
|
164
|
+
* scopes: ["agent:read", "agent:execute"],
|
|
165
|
+
* tools: [searchTool, calcTool],
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
declare function createVorimClaudeAgent(config: {
|
|
170
|
+
vorim: VorimSDK;
|
|
171
|
+
name: string;
|
|
172
|
+
description?: string;
|
|
173
|
+
capabilities: string[];
|
|
174
|
+
scopes: PermissionScope[];
|
|
175
|
+
tools: VorimToolDefinition[];
|
|
176
|
+
}): Promise<{
|
|
177
|
+
agentId: string;
|
|
178
|
+
registration: AgentRegistrationResult;
|
|
179
|
+
registry: VorimToolRegistry;
|
|
180
|
+
privateKey: string;
|
|
181
|
+
}>;
|
|
182
|
+
|
|
183
|
+
export { type VorimAgentLoopConfig, type VorimAnthropicConfig, type VorimToolDefinition, VorimToolRegistry, createVorimClaudeAgent, runAgentLoop };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/integrations/anthropic.ts
|
|
2
|
+
var VorimToolRegistry = class {
|
|
3
|
+
vorim;
|
|
4
|
+
agentId;
|
|
5
|
+
defaultPermission;
|
|
6
|
+
asyncAudit;
|
|
7
|
+
tools = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.vorim = config.vorim;
|
|
10
|
+
this.agentId = config.agentId;
|
|
11
|
+
this.defaultPermission = config.defaultPermission ?? "agent:execute";
|
|
12
|
+
this.asyncAudit = config.asyncAudit ?? true;
|
|
13
|
+
}
|
|
14
|
+
/** Register a tool. */
|
|
15
|
+
add(definition) {
|
|
16
|
+
this.tools.set(definition.name, definition);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
/** Register multiple tools. */
|
|
20
|
+
addAll(definitions) {
|
|
21
|
+
for (const def of definitions) this.add(def);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
/** Convert registered tools to Anthropic's tool format. */
|
|
25
|
+
toAnthropicTools() {
|
|
26
|
+
return [...this.tools.values()].map((t) => ({
|
|
27
|
+
name: t.name,
|
|
28
|
+
description: t.description,
|
|
29
|
+
input_schema: t.input_schema
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Execute tool_use blocks from a Claude message response.
|
|
34
|
+
* Each call is checked against Vorim permissions and audited.
|
|
35
|
+
* Returns an array of tool_result blocks ready to send back to Claude.
|
|
36
|
+
*/
|
|
37
|
+
async executeToolUseBlocks(toolUseBlocks) {
|
|
38
|
+
return Promise.all(
|
|
39
|
+
toolUseBlocks.map((block) => this.executeSingleBlock(block))
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
async executeSingleBlock(block) {
|
|
43
|
+
const definition = this.tools.get(block.name);
|
|
44
|
+
if (!definition) {
|
|
45
|
+
return {
|
|
46
|
+
type: "tool_result",
|
|
47
|
+
tool_use_id: block.id,
|
|
48
|
+
content: JSON.stringify({ error: `Unknown tool: ${block.name}` }),
|
|
49
|
+
is_error: true
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const scope = definition.permission ?? this.defaultPermission;
|
|
53
|
+
const { allowed, reason } = await this.vorim.check(this.agentId, scope);
|
|
54
|
+
if (!allowed) {
|
|
55
|
+
const event = {
|
|
56
|
+
agent_id: this.agentId,
|
|
57
|
+
event_type: "tool_call",
|
|
58
|
+
action: block.name,
|
|
59
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
60
|
+
permission: scope,
|
|
61
|
+
result: "denied",
|
|
62
|
+
metadata: { reason, framework: "anthropic" }
|
|
63
|
+
};
|
|
64
|
+
this.emitAudit(event);
|
|
65
|
+
return {
|
|
66
|
+
type: "tool_result",
|
|
67
|
+
tool_use_id: block.id,
|
|
68
|
+
content: JSON.stringify({ error: `Permission denied: ${scope}${reason ? ` \u2014 ${reason}` : ""}` }),
|
|
69
|
+
is_error: true
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const start = Date.now();
|
|
73
|
+
try {
|
|
74
|
+
const result = await definition.execute(block.input);
|
|
75
|
+
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
76
|
+
const event = {
|
|
77
|
+
agent_id: this.agentId,
|
|
78
|
+
event_type: "tool_call",
|
|
79
|
+
action: block.name,
|
|
80
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
81
|
+
permission: scope,
|
|
82
|
+
result: "success",
|
|
83
|
+
latency_ms: Date.now() - start,
|
|
84
|
+
metadata: { framework: "anthropic" }
|
|
85
|
+
};
|
|
86
|
+
this.emitAudit(event);
|
|
87
|
+
return { type: "tool_result", tool_use_id: block.id, content };
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
90
|
+
const event = {
|
|
91
|
+
agent_id: this.agentId,
|
|
92
|
+
event_type: "tool_call",
|
|
93
|
+
action: block.name,
|
|
94
|
+
resource: truncate(JSON.stringify(block.input), 500),
|
|
95
|
+
permission: scope,
|
|
96
|
+
result: "error",
|
|
97
|
+
latency_ms: Date.now() - start,
|
|
98
|
+
error_code: err instanceof Error ? err.name : "UNKNOWN",
|
|
99
|
+
metadata: { error: errMsg, framework: "anthropic" }
|
|
100
|
+
};
|
|
101
|
+
this.emitAudit(event);
|
|
102
|
+
return {
|
|
103
|
+
type: "tool_result",
|
|
104
|
+
tool_use_id: block.id,
|
|
105
|
+
content: JSON.stringify({ error: errMsg }),
|
|
106
|
+
is_error: true
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
emitAudit(event) {
|
|
111
|
+
this.vorim.emit(event).catch(() => {
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
async function runAgentLoop(config) {
|
|
116
|
+
const {
|
|
117
|
+
anthropic,
|
|
118
|
+
model = "claude-sonnet-4-20250514",
|
|
119
|
+
systemPrompt,
|
|
120
|
+
maxIterations = 10,
|
|
121
|
+
maxTokens = 1024,
|
|
122
|
+
registry,
|
|
123
|
+
userMessage
|
|
124
|
+
} = config;
|
|
125
|
+
const tools = registry.toAnthropicTools();
|
|
126
|
+
const messages = [{ role: "user", content: userMessage }];
|
|
127
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
128
|
+
const response = await anthropic.messages.create({
|
|
129
|
+
model,
|
|
130
|
+
max_tokens: maxTokens,
|
|
131
|
+
...systemPrompt ? { system: systemPrompt } : {},
|
|
132
|
+
messages,
|
|
133
|
+
...tools.length > 0 ? { tools } : {}
|
|
134
|
+
});
|
|
135
|
+
if (response.stop_reason === "end_turn" || response.stop_reason !== "tool_use") {
|
|
136
|
+
const textBlocks = response.content.filter((b) => b.type === "text");
|
|
137
|
+
return textBlocks.map((b) => b.text).join("") || "";
|
|
138
|
+
}
|
|
139
|
+
const toolUseBlocks = response.content.filter((b) => b.type === "tool_use");
|
|
140
|
+
const toolResults = await registry.executeToolUseBlocks(toolUseBlocks);
|
|
141
|
+
messages.push({ role: "assistant", content: response.content });
|
|
142
|
+
messages.push({ role: "user", content: toolResults });
|
|
143
|
+
}
|
|
144
|
+
return "";
|
|
145
|
+
}
|
|
146
|
+
async function createVorimClaudeAgent(config) {
|
|
147
|
+
const { vorim, name, description, capabilities, scopes, tools } = config;
|
|
148
|
+
const registration = await vorim.register({
|
|
149
|
+
name,
|
|
150
|
+
description,
|
|
151
|
+
capabilities,
|
|
152
|
+
scopes
|
|
153
|
+
});
|
|
154
|
+
const agentId = registration.agent.agent_id;
|
|
155
|
+
const registry = new VorimToolRegistry({ vorim, agentId });
|
|
156
|
+
registry.addAll(tools);
|
|
157
|
+
return {
|
|
158
|
+
agentId,
|
|
159
|
+
registration,
|
|
160
|
+
registry,
|
|
161
|
+
privateKey: registration.private_key
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function truncate(str, max) {
|
|
165
|
+
return str.length > max ? str.slice(0, max) + "\u2026" : str;
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
VorimToolRegistry,
|
|
169
|
+
createVorimClaudeAgent,
|
|
170
|
+
runAgentLoop
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=anthropic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/integrations/anthropic.ts"],"sourcesContent":["// ============================================================================\n// VORIM SDK — Anthropic/Claude Integration\n// Wraps Anthropic tool use with Vorim permission checks, audit trails,\n// and agent identity. Works with the Anthropic Node.js SDK (messages API\n// with tool use).\n//\n// Peer dependency: @anthropic-ai/sdk >=0.30.0\n// ============================================================================\n\nimport type { VorimSDK } from '../index.js';\nimport type { PermissionScope, AuditEventInput } from '../types.js';\n\n// ─── Re-declared Anthropic types (peer dependency — not bundled) ──────────\n\ninterface AnthropicTool {\n name: string;\n description: string;\n input_schema: Record<string, unknown>;\n}\n\ninterface ToolUseBlock {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n}\n\ninterface ToolResultBlock {\n type: 'tool_result';\n tool_use_id: string;\n content: string;\n is_error?: boolean;\n}\n\n// ─── Configuration ────────────────────────────────────────────────────────\n\nexport interface VorimToolDefinition<TArgs = Record<string, unknown>, TResult = unknown> {\n /** Tool name (must match the tool name sent to Claude). */\n name: string;\n /** Description shown to Claude. */\n description: string;\n /** JSON Schema for the tool's input. */\n input_schema: Record<string, unknown>;\n /** The function to execute when the tool is called. */\n execute: (args: TArgs) => Promise<TResult>;\n /** Vorim permission scope required. @default 'agent:execute' */\n permission?: PermissionScope;\n}\n\nexport interface VorimAnthropicConfig {\n /** Vorim SDK instance. */\n vorim: VorimSDK;\n /** The Vorim agent_id. */\n agentId: string;\n /** Default permission scope for tools without an explicit one. @default 'agent:execute' */\n defaultPermission?: PermissionScope;\n /** Whether to emit audit events asynchronously (fire-and-forget). @default true */\n asyncAudit?: boolean;\n}\n\n// ─── Tool Registry ────────────────────────────────────────────────────────\n\n/**\n * Manages a set of tools with Vorim permission checks and audit logging.\n * Converts tools to Anthropic's tool format and handles execution of\n * tool_use blocks from Claude's response.\n *\n * @example\n * ```ts\n * import Anthropic from \"@anthropic-ai/sdk\";\n * import createVorim from \"@vorim/sdk\";\n * import { VorimToolRegistry } from \"@vorim/sdk/integrations/anthropic\";\n *\n * const vorim = createVorim({ apiKey: \"agid_sk_live_...\" });\n * const anthropic = new Anthropic();\n *\n * const registry = new VorimToolRegistry({\n * vorim,\n * agentId: \"agid_acme_a1b2c3d4\",\n * });\n *\n * registry.add({\n * name: \"search_docs\",\n * description: \"Search internal documents\",\n * input_schema: {\n * type: \"object\",\n * properties: { query: { type: \"string\" } },\n * required: [\"query\"],\n * },\n * execute: async ({ query }) => searchDocs(query),\n * permission: \"agent:read\",\n * });\n *\n * const response = await anthropic.messages.create({\n * model: \"claude-sonnet-4-20250514\",\n * max_tokens: 1024,\n * messages,\n * tools: registry.toAnthropicTools(),\n * });\n *\n * // Execute tool_use blocks from response\n * const toolResults = await registry.executeToolUseBlocks(\n * response.content.filter(b => b.type === \"tool_use\")\n * );\n * ```\n */\nexport class VorimToolRegistry {\n private vorim: VorimSDK;\n private agentId: string;\n private defaultPermission: PermissionScope;\n private asyncAudit: boolean;\n private tools = new Map<string, VorimToolDefinition>();\n\n constructor(config: VorimAnthropicConfig) {\n this.vorim = config.vorim;\n this.agentId = config.agentId;\n this.defaultPermission = config.defaultPermission ?? 'agent:execute';\n this.asyncAudit = config.asyncAudit ?? true;\n }\n\n /** Register a tool. */\n add<TArgs, TResult>(definition: VorimToolDefinition<TArgs, TResult>): this {\n this.tools.set(definition.name, definition as VorimToolDefinition);\n return this;\n }\n\n /** Register multiple tools. */\n addAll(definitions: VorimToolDefinition[]): this {\n for (const def of definitions) this.add(def);\n return this;\n }\n\n /** Convert registered tools to Anthropic's tool format. */\n toAnthropicTools(): AnthropicTool[] {\n return [...this.tools.values()].map(t => ({\n name: t.name,\n description: t.description,\n input_schema: t.input_schema,\n }));\n }\n\n /**\n * Execute tool_use blocks from a Claude message response.\n * Each call is checked against Vorim permissions and audited.\n * Returns an array of tool_result blocks ready to send back to Claude.\n */\n async executeToolUseBlocks(toolUseBlocks: ToolUseBlock[]): Promise<ToolResultBlock[]> {\n return Promise.all(\n toolUseBlocks.map(block => this.executeSingleBlock(block)),\n );\n }\n\n private async executeSingleBlock(block: ToolUseBlock): Promise<ToolResultBlock> {\n const definition = this.tools.get(block.name);\n\n if (!definition) {\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: `Unknown tool: ${block.name}` }),\n is_error: true,\n };\n }\n\n const scope = definition.permission ?? this.defaultPermission;\n\n // 1. Permission check\n const { allowed, reason } = await this.vorim.check(this.agentId, scope);\n\n if (!allowed) {\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'denied',\n metadata: { reason, framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: `Permission denied: ${scope}${reason ? ` — ${reason}` : ''}` }),\n is_error: true,\n };\n }\n\n // 2. Execute\n const start = Date.now();\n try {\n const result = await definition.execute(block.input as any);\n const content = typeof result === 'string' ? result : JSON.stringify(result);\n\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'success',\n latency_ms: Date.now() - start,\n metadata: { framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return { type: 'tool_result', tool_use_id: block.id, content };\n } catch (err) {\n const errMsg = err instanceof Error ? err.message : String(err);\n\n const event: AuditEventInput = {\n agent_id: this.agentId,\n event_type: 'tool_call',\n action: block.name,\n resource: truncate(JSON.stringify(block.input), 500),\n permission: scope,\n result: 'error',\n latency_ms: Date.now() - start,\n error_code: err instanceof Error ? err.name : 'UNKNOWN',\n metadata: { error: errMsg, framework: 'anthropic' },\n };\n this.emitAudit(event);\n\n return {\n type: 'tool_result',\n tool_use_id: block.id,\n content: JSON.stringify({ error: errMsg }),\n is_error: true,\n };\n }\n }\n\n private emitAudit(event: AuditEventInput): void {\n this.vorim.emit(event).catch(() => {});\n }\n}\n\n// ─── Agent Loop ───────────────────────────────────────────────────────────\n\n/** Minimal Anthropic client interface (avoids importing the full SDK). */\ninterface AnthropicClient {\n messages: {\n create(params: any): Promise<any>;\n };\n}\n\nexport interface VorimAgentLoopConfig extends VorimAnthropicConfig {\n /** Anthropic client instance. */\n anthropic: AnthropicClient;\n /** Model to use. @default 'claude-sonnet-4-20250514' */\n model?: string;\n /** System prompt for the agent. */\n systemPrompt?: string;\n /** Maximum tool-use iterations before stopping. @default 10 */\n maxIterations?: number;\n /** Max tokens per response. @default 1024 */\n maxTokens?: number;\n}\n\n/**\n * Runs a complete agent loop with Claude tool use, Vorim\n * permission enforcement, and audit logging.\n *\n * @example\n * ```ts\n * import Anthropic from \"@anthropic-ai/sdk\";\n * import createVorim from \"@vorim/sdk\";\n * import { runAgentLoop, VorimToolRegistry } from \"@vorim/sdk/integrations/anthropic\";\n *\n * const registry = new VorimToolRegistry({ vorim, agentId });\n * registry.add({ name: \"search\", ... });\n *\n * const response = await runAgentLoop({\n * vorim,\n * agentId,\n * anthropic: new Anthropic(),\n * model: \"claude-sonnet-4-20250514\",\n * systemPrompt: \"You are a helpful assistant.\",\n * registry,\n * userMessage: \"Find docs about onboarding\",\n * });\n * ```\n */\nexport async function runAgentLoop(\n config: VorimAgentLoopConfig & {\n registry: VorimToolRegistry;\n userMessage: string;\n },\n): Promise<string> {\n const {\n anthropic,\n model = 'claude-sonnet-4-20250514',\n systemPrompt,\n maxIterations = 10,\n maxTokens = 1024,\n registry,\n userMessage,\n } = config;\n\n const tools = registry.toAnthropicTools();\n const messages: any[] = [{ role: 'user', content: userMessage }];\n\n for (let i = 0; i < maxIterations; i++) {\n const response = await anthropic.messages.create({\n model,\n max_tokens: maxTokens,\n ...(systemPrompt ? { system: systemPrompt } : {}),\n messages,\n ...(tools.length > 0 ? { tools } : {}),\n });\n\n // If stop_reason is \"end_turn\" — Claude is done\n if (response.stop_reason === 'end_turn' || response.stop_reason !== 'tool_use') {\n const textBlocks = response.content.filter((b: any) => b.type === 'text');\n return textBlocks.map((b: any) => b.text).join('') || '';\n }\n\n // Extract tool_use blocks and execute\n const toolUseBlocks = response.content.filter((b: any) => b.type === 'tool_use');\n const toolResults = await registry.executeToolUseBlocks(toolUseBlocks);\n\n // Append assistant response and tool results to conversation\n messages.push({ role: 'assistant', content: response.content });\n messages.push({ role: 'user', content: toolResults });\n }\n\n return '';\n}\n\n// ─── Agent Registration Helper ───────────────────────────────────────────\n\n/**\n * Registers a new agent with Vorim and returns a ready-to-use tool registry\n * configured for Anthropic/Claude.\n *\n * @example\n * ```ts\n * const { agentId, registry } = await createVorimClaudeAgent({\n * vorim,\n * name: \"claude-assistant\",\n * capabilities: [\"search\", \"calculate\"],\n * scopes: [\"agent:read\", \"agent:execute\"],\n * tools: [searchTool, calcTool],\n * });\n * ```\n */\nexport async function createVorimClaudeAgent(config: {\n vorim: VorimSDK;\n name: string;\n description?: string;\n capabilities: string[];\n scopes: PermissionScope[];\n tools: VorimToolDefinition[];\n}) {\n const { vorim, name, description, capabilities, scopes, tools } = config;\n\n const registration = await vorim.register({\n name,\n description,\n capabilities,\n scopes,\n });\n\n const agentId = registration.agent.agent_id;\n const registry = new VorimToolRegistry({ vorim, agentId });\n registry.addAll(tools);\n\n return {\n agentId,\n registration,\n registry,\n privateKey: registration.private_key,\n };\n}\n\n// ─── Helpers ──────────────────────────────────────────────────────────────\n\nfunction truncate(str: string, max: number): string {\n return str.length > max ? str.slice(0, max) + '…' : str;\n}\n"],"mappings":";AA0GO,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,oBAAI,IAAiC;AAAA,EAErD,YAAY,QAA8B;AACxC,SAAK,QAAQ,OAAO;AACpB,SAAK,UAAU,OAAO;AACtB,SAAK,oBAAoB,OAAO,qBAAqB;AACrD,SAAK,aAAa,OAAO,cAAc;AAAA,EACzC;AAAA;AAAA,EAGA,IAAoB,YAAuD;AACzE,SAAK,MAAM,IAAI,WAAW,MAAM,UAAiC;AACjE,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,aAA0C;AAC/C,eAAW,OAAO,YAAa,MAAK,IAAI,GAAG;AAC3C,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,mBAAoC;AAClC,WAAO,CAAC,GAAG,KAAK,MAAM,OAAO,CAAC,EAAE,IAAI,QAAM;AAAA,MACxC,MAAM,EAAE;AAAA,MACR,aAAa,EAAE;AAAA,MACf,cAAc,EAAE;AAAA,IAClB,EAAE;AAAA,EACJ;AAAA;AAAA;A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","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vorim/sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Official TypeScript SDK for Vorim AI — AI Agent Identity, Permissions & Audit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -56,6 +56,16 @@
|
|
|
56
56
|
"types": "./dist/integrations/llamaindex.d.cts",
|
|
57
57
|
"default": "./dist/integrations/llamaindex.cjs"
|
|
58
58
|
}
|
|
59
|
+
},
|
|
60
|
+
"./integrations/anthropic": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/integrations/anthropic.d.ts",
|
|
63
|
+
"default": "./dist/integrations/anthropic.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/integrations/anthropic.d.cts",
|
|
67
|
+
"default": "./dist/integrations/anthropic.cjs"
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
},
|
|
61
71
|
"files": [
|