@everestan/protocolbanks-agent-tools 0.0.0-stage → 0.1.1

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
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # @everestan/protocolbanks-agent-tools
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Tool definitions for the Protocol Banks Agent API — adapt once to the Vercel AI
4
+ SDK, LangChain, OpenAI or Anthropic.
5
+
6
+ ```bash
7
+ npm install @everestan/protocolbanks-sdk @everestan/protocolbanks-agent-tools
8
+ ```
9
+
10
+ ```ts
11
+ import { ProtocolBanks } from "@everestan/protocolbanks-sdk"
12
+ import { agentTools, toAnthropicTools, toOpenAIFunctions } from "@everestan/protocolbanks-agent-tools"
13
+
14
+ const pb = new ProtocolBanks({ apiKey: process.env.PB_KEY! })
15
+ const tools = agentTools(pb)
16
+ // agent_state · place_order · prepare_payment · prepare_swap · create_invoice
17
+ ```
18
+
19
+ - Parameters are plain **JSON Schema** (OpenAI and Anthropic accept them
20
+ directly via `toOpenAIFunctions()` / `toAnthropicTools()`; the Vercel AI SDK
21
+ accepts them through `jsonSchema()`; LangChain wraps them in Zod).
22
+ - Only `place_order` executes. The other four return something the agent signs
23
+ itself.
24
+ - Every tool returns the API envelope **and the HTTP status**. A `403` (key
25
+ policy) or `409` (guard) is returned, not thrown, and the descriptions tell
26
+ the model not to retry.
27
+
28
+ Full adapters (AI SDK, LangChain, OpenAI, Anthropic):
29
+ https://protocolbanks.com/docs/quickstart
30
+
31
+ ## License
32
+
33
+ GPL-3.0-only.
@@ -0,0 +1,47 @@
1
+ import { ProtocolBanks } from '@everestan/protocolbanks-sdk';
2
+
3
+ /**
4
+ * Framework-agnostic tool manifest for the Protocol Banks Agent API.
5
+ *
6
+ * The server enforces the policy, so these descriptions are written for a model:
7
+ * say what the tool does, what the refund path is, and never suggest retrying a
8
+ * refusal. Each tool returns the API envelope (never throws on 403/409) so the
9
+ * model sees the refusal and stops.
10
+ *
11
+ * Adapt once:
12
+ * - Vercel AI SDK / LangChain: wrap each definition in your framework's tool().
13
+ * - OpenAI / Anthropic: pass `toOpenAIFunctions()` / `toAnthropicTools()`.
14
+ * - MCP hosts: use the hosted MCP server instead (/mcp).
15
+ */
16
+
17
+ interface AgentToolSchema {
18
+ type: "object";
19
+ properties: Record<string, unknown>;
20
+ required?: string[];
21
+ additionalProperties?: boolean;
22
+ }
23
+ interface AgentToolDefinition {
24
+ name: string;
25
+ description: string;
26
+ /** JSON Schema — accepted by OpenAI functions, Anthropic tools, AI SDK and LangChain. */
27
+ parameters: AgentToolSchema;
28
+ execute: (args: Record<string, unknown>) => Promise<unknown>;
29
+ }
30
+ declare function agentTools(pb: ProtocolBanks): AgentToolDefinition[];
31
+ /** OpenAI Chat Completions / Responses function-calling format. */
32
+ declare function toOpenAIFunctions(tools: AgentToolDefinition[]): {
33
+ type: "function";
34
+ function: {
35
+ name: string;
36
+ description: string;
37
+ parameters: AgentToolSchema;
38
+ };
39
+ }[];
40
+ /** Anthropic Messages API tool format. */
41
+ declare function toAnthropicTools(tools: AgentToolDefinition[]): {
42
+ name: string;
43
+ description: string;
44
+ input_schema: AgentToolSchema;
45
+ }[];
46
+
47
+ export { type AgentToolDefinition, type AgentToolSchema, agentTools, toAnthropicTools, toOpenAIFunctions };
@@ -0,0 +1,47 @@
1
+ import { ProtocolBanks } from '@everestan/protocolbanks-sdk';
2
+
3
+ /**
4
+ * Framework-agnostic tool manifest for the Protocol Banks Agent API.
5
+ *
6
+ * The server enforces the policy, so these descriptions are written for a model:
7
+ * say what the tool does, what the refund path is, and never suggest retrying a
8
+ * refusal. Each tool returns the API envelope (never throws on 403/409) so the
9
+ * model sees the refusal and stops.
10
+ *
11
+ * Adapt once:
12
+ * - Vercel AI SDK / LangChain: wrap each definition in your framework's tool().
13
+ * - OpenAI / Anthropic: pass `toOpenAIFunctions()` / `toAnthropicTools()`.
14
+ * - MCP hosts: use the hosted MCP server instead (/mcp).
15
+ */
16
+
17
+ interface AgentToolSchema {
18
+ type: "object";
19
+ properties: Record<string, unknown>;
20
+ required?: string[];
21
+ additionalProperties?: boolean;
22
+ }
23
+ interface AgentToolDefinition {
24
+ name: string;
25
+ description: string;
26
+ /** JSON Schema — accepted by OpenAI functions, Anthropic tools, AI SDK and LangChain. */
27
+ parameters: AgentToolSchema;
28
+ execute: (args: Record<string, unknown>) => Promise<unknown>;
29
+ }
30
+ declare function agentTools(pb: ProtocolBanks): AgentToolDefinition[];
31
+ /** OpenAI Chat Completions / Responses function-calling format. */
32
+ declare function toOpenAIFunctions(tools: AgentToolDefinition[]): {
33
+ type: "function";
34
+ function: {
35
+ name: string;
36
+ description: string;
37
+ parameters: AgentToolSchema;
38
+ };
39
+ }[];
40
+ /** Anthropic Messages API tool format. */
41
+ declare function toAnthropicTools(tools: AgentToolDefinition[]): {
42
+ name: string;
43
+ description: string;
44
+ input_schema: AgentToolSchema;
45
+ }[];
46
+
47
+ export { type AgentToolDefinition, type AgentToolSchema, agentTools, toAnthropicTools, toOpenAIFunctions };
package/dist/index.js ADDED
@@ -0,0 +1,148 @@
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/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ agentTools: () => agentTools,
24
+ toAnthropicTools: () => toAnthropicTools,
25
+ toOpenAIFunctions: () => toOpenAIFunctions
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/tools.ts
30
+ var POLICY_NOTE = "The server enforces the key's policy (allowedOps, per-call cap, daily cap, coin allowlist). A 403 is a policy refusal and a 409 is a platform guard refusal; both are final for the request \u2014 do not retry unchanged.";
31
+ function agentTools(pb) {
32
+ return [
33
+ {
34
+ name: "agent_state",
35
+ description: "Read the trading account behind the API key: mode (paper or live), equity, open positions, recent activity, and the key's policy with what it still allows today (spentTodayUsd). Call this before trading to learn the caps.",
36
+ parameters: { type: "object", properties: {}, additionalProperties: false },
37
+ execute: () => pb.agent.state()
38
+ },
39
+ {
40
+ name: "place_order",
41
+ description: `Open one perpetual position on Hyperliquid. This is the only tool that moves money: it executes through the account's agent wallet, which has trading-only rights and can never withdraw. ${POLICY_NOTE} A sizeUsd above the platform position cap is clamped; one above the key's per-call cap is refused.`,
42
+ parameters: {
43
+ type: "object",
44
+ properties: {
45
+ coin: { type: "string", description: 'Market symbol, e.g. "BTC". Case-insensitive.' },
46
+ side: { type: "string", enum: ["long", "short"] },
47
+ sizeUsd: { type: "number", exclusiveMinimum: 0, description: "Order notional in USD." },
48
+ reason: { type: "string", description: "Signal label stored with the fill (max 120 chars)." }
49
+ },
50
+ required: ["coin", "side", "sizeUsd"],
51
+ additionalProperties: false
52
+ },
53
+ execute: (args) => pb.agent.order(args)
54
+ },
55
+ {
56
+ name: "prepare_payment",
57
+ description: `Validate a payment (EVM or Solana destination, token, amount) against the key's policy and return an intent the agent signs and submits itself. The platform holds no keys and never moves the funds. ${POLICY_NOTE}`,
58
+ parameters: {
59
+ type: "object",
60
+ properties: {
61
+ to: {
62
+ type: "string",
63
+ description: "EVM address (0x + 40 hex) or base58 Solana address."
64
+ },
65
+ amountUsd: { type: "number", exclusiveMinimum: 0 },
66
+ token: { type: "string", description: 'Token symbol, default "USDC".' },
67
+ chain: { type: "string", description: 'Chain name, default "base".' },
68
+ memo: { type: "string", description: "Optional memo (max 140 chars)." }
69
+ },
70
+ required: ["to", "amountUsd"],
71
+ additionalProperties: false
72
+ },
73
+ execute: (args) => pb.agent.pay(args)
74
+ },
75
+ {
76
+ name: "prepare_swap",
77
+ description: `Quote a swap against the key's policy and return the route plus the transaction the agent must sign. A quote is not metered (nothing is spent) and the platform never executes it. ${POLICY_NOTE}`,
78
+ parameters: {
79
+ type: "object",
80
+ properties: {
81
+ from: {
82
+ type: "object",
83
+ description: 'Source asset, e.g. { "symbol": "USDC", "blockchain": "base" }',
84
+ properties: {
85
+ symbol: { type: "string" },
86
+ blockchain: { type: "string" },
87
+ address: { type: ["string", "null"] }
88
+ },
89
+ required: ["symbol", "blockchain"]
90
+ },
91
+ to: {
92
+ type: "object",
93
+ description: 'Destination asset, e.g. { "symbol": "ETH", "blockchain": "base" }',
94
+ properties: {
95
+ symbol: { type: "string" },
96
+ blockchain: { type: "string" },
97
+ address: { type: ["string", "null"] }
98
+ },
99
+ required: ["symbol", "blockchain"]
100
+ },
101
+ amount: { type: "string", description: "Amount in token units, as a string." },
102
+ amountUsd: { type: "number", exclusiveMinimum: 0, description: "USD value of the swap." },
103
+ slippage: { type: "number", minimum: 0.1, maximum: 5, description: "Percent; clamped to 0.1\u20135." }
104
+ },
105
+ required: ["from", "to", "amount", "amountUsd"],
106
+ additionalProperties: false
107
+ },
108
+ execute: (args) => pb.agent.swap(args)
109
+ },
110
+ {
111
+ name: "create_invoice",
112
+ description: `Create a pending invoice for work performed and return a paymentLink to hand the payer. Moves no money and is not metered; the amount is still checked against the key's policy because an invoice is a payment request. ${POLICY_NOTE}`,
113
+ parameters: {
114
+ type: "object",
115
+ properties: {
116
+ to: { type: "string", description: "Payee address: EVM (0x\u2026), TRON (T\u2026) or Solana (base58)." },
117
+ amount: { type: "number", exclusiveMinimum: 0 },
118
+ token: { type: "string", description: 'Token symbol, default "USDC".' },
119
+ chain: { type: "string", description: "Defaults to TRON for a TRON payee, otherwise Ethereum." },
120
+ description: { type: "string", description: "What is being billed (max 200 chars)." },
121
+ expiresInHours: { type: "number", minimum: 1, maximum: 720, description: "Default 24." }
122
+ },
123
+ required: ["to", "amount"],
124
+ additionalProperties: false
125
+ },
126
+ execute: (args) => pb.agent.invoice(args)
127
+ }
128
+ ];
129
+ }
130
+ function toOpenAIFunctions(tools) {
131
+ return tools.map((tool) => ({
132
+ type: "function",
133
+ function: { name: tool.name, description: tool.description, parameters: tool.parameters }
134
+ }));
135
+ }
136
+ function toAnthropicTools(tools) {
137
+ return tools.map((tool) => ({
138
+ name: tool.name,
139
+ description: tool.description,
140
+ input_schema: tool.parameters
141
+ }));
142
+ }
143
+ // Annotate the CommonJS export names for ESM import in node:
144
+ 0 && (module.exports = {
145
+ agentTools,
146
+ toAnthropicTools,
147
+ toOpenAIFunctions
148
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,119 @@
1
+ // src/tools.ts
2
+ var POLICY_NOTE = "The server enforces the key's policy (allowedOps, per-call cap, daily cap, coin allowlist). A 403 is a policy refusal and a 409 is a platform guard refusal; both are final for the request \u2014 do not retry unchanged.";
3
+ function agentTools(pb) {
4
+ return [
5
+ {
6
+ name: "agent_state",
7
+ description: "Read the trading account behind the API key: mode (paper or live), equity, open positions, recent activity, and the key's policy with what it still allows today (spentTodayUsd). Call this before trading to learn the caps.",
8
+ parameters: { type: "object", properties: {}, additionalProperties: false },
9
+ execute: () => pb.agent.state()
10
+ },
11
+ {
12
+ name: "place_order",
13
+ description: `Open one perpetual position on Hyperliquid. This is the only tool that moves money: it executes through the account's agent wallet, which has trading-only rights and can never withdraw. ${POLICY_NOTE} A sizeUsd above the platform position cap is clamped; one above the key's per-call cap is refused.`,
14
+ parameters: {
15
+ type: "object",
16
+ properties: {
17
+ coin: { type: "string", description: 'Market symbol, e.g. "BTC". Case-insensitive.' },
18
+ side: { type: "string", enum: ["long", "short"] },
19
+ sizeUsd: { type: "number", exclusiveMinimum: 0, description: "Order notional in USD." },
20
+ reason: { type: "string", description: "Signal label stored with the fill (max 120 chars)." }
21
+ },
22
+ required: ["coin", "side", "sizeUsd"],
23
+ additionalProperties: false
24
+ },
25
+ execute: (args) => pb.agent.order(args)
26
+ },
27
+ {
28
+ name: "prepare_payment",
29
+ description: `Validate a payment (EVM or Solana destination, token, amount) against the key's policy and return an intent the agent signs and submits itself. The platform holds no keys and never moves the funds. ${POLICY_NOTE}`,
30
+ parameters: {
31
+ type: "object",
32
+ properties: {
33
+ to: {
34
+ type: "string",
35
+ description: "EVM address (0x + 40 hex) or base58 Solana address."
36
+ },
37
+ amountUsd: { type: "number", exclusiveMinimum: 0 },
38
+ token: { type: "string", description: 'Token symbol, default "USDC".' },
39
+ chain: { type: "string", description: 'Chain name, default "base".' },
40
+ memo: { type: "string", description: "Optional memo (max 140 chars)." }
41
+ },
42
+ required: ["to", "amountUsd"],
43
+ additionalProperties: false
44
+ },
45
+ execute: (args) => pb.agent.pay(args)
46
+ },
47
+ {
48
+ name: "prepare_swap",
49
+ description: `Quote a swap against the key's policy and return the route plus the transaction the agent must sign. A quote is not metered (nothing is spent) and the platform never executes it. ${POLICY_NOTE}`,
50
+ parameters: {
51
+ type: "object",
52
+ properties: {
53
+ from: {
54
+ type: "object",
55
+ description: 'Source asset, e.g. { "symbol": "USDC", "blockchain": "base" }',
56
+ properties: {
57
+ symbol: { type: "string" },
58
+ blockchain: { type: "string" },
59
+ address: { type: ["string", "null"] }
60
+ },
61
+ required: ["symbol", "blockchain"]
62
+ },
63
+ to: {
64
+ type: "object",
65
+ description: 'Destination asset, e.g. { "symbol": "ETH", "blockchain": "base" }',
66
+ properties: {
67
+ symbol: { type: "string" },
68
+ blockchain: { type: "string" },
69
+ address: { type: ["string", "null"] }
70
+ },
71
+ required: ["symbol", "blockchain"]
72
+ },
73
+ amount: { type: "string", description: "Amount in token units, as a string." },
74
+ amountUsd: { type: "number", exclusiveMinimum: 0, description: "USD value of the swap." },
75
+ slippage: { type: "number", minimum: 0.1, maximum: 5, description: "Percent; clamped to 0.1\u20135." }
76
+ },
77
+ required: ["from", "to", "amount", "amountUsd"],
78
+ additionalProperties: false
79
+ },
80
+ execute: (args) => pb.agent.swap(args)
81
+ },
82
+ {
83
+ name: "create_invoice",
84
+ description: `Create a pending invoice for work performed and return a paymentLink to hand the payer. Moves no money and is not metered; the amount is still checked against the key's policy because an invoice is a payment request. ${POLICY_NOTE}`,
85
+ parameters: {
86
+ type: "object",
87
+ properties: {
88
+ to: { type: "string", description: "Payee address: EVM (0x\u2026), TRON (T\u2026) or Solana (base58)." },
89
+ amount: { type: "number", exclusiveMinimum: 0 },
90
+ token: { type: "string", description: 'Token symbol, default "USDC".' },
91
+ chain: { type: "string", description: "Defaults to TRON for a TRON payee, otherwise Ethereum." },
92
+ description: { type: "string", description: "What is being billed (max 200 chars)." },
93
+ expiresInHours: { type: "number", minimum: 1, maximum: 720, description: "Default 24." }
94
+ },
95
+ required: ["to", "amount"],
96
+ additionalProperties: false
97
+ },
98
+ execute: (args) => pb.agent.invoice(args)
99
+ }
100
+ ];
101
+ }
102
+ function toOpenAIFunctions(tools) {
103
+ return tools.map((tool) => ({
104
+ type: "function",
105
+ function: { name: tool.name, description: tool.description, parameters: tool.parameters }
106
+ }));
107
+ }
108
+ function toAnthropicTools(tools) {
109
+ return tools.map((tool) => ({
110
+ name: tool.name,
111
+ description: tool.description,
112
+ input_schema: tool.parameters
113
+ }));
114
+ }
115
+ export {
116
+ agentTools,
117
+ toAnthropicTools,
118
+ toOpenAIFunctions
119
+ };
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@everestan/protocolbanks-agent-tools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Tool definitions for the Protocol Banks Agent API — adapt once to the Vercel AI SDK, LangChain, OpenAI or Anthropic",
5
+ "homepage": "https://protocolbanks.com/agent-api",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format cjs,esm --dts",
22
+ "lint": "tsc --noEmit"
23
+ },
24
+ "keywords": [
25
+ "ai-agents",
26
+ "tools",
27
+ "function-calling",
28
+ "langchain",
29
+ "vercel-ai-sdk",
30
+ "openai",
31
+ "anthropic",
32
+ "trading",
33
+ "hyperliquid",
34
+ "protocol-banks"
35
+ ],
36
+ "author": "Protocol Banks",
37
+ "license": "GPL-3.0-only",
38
+ "peerDependencies": {
39
+ "@everestan/protocolbanks-sdk": ">=0.2.0"
40
+ },
41
+ "devDependencies": {
42
+ "tsup": "^8.0.0",
43
+ "typescript": "^5.0.0",
44
+ "@types/node": "^22"
45
+ }
46
+ }