@balchemyai/agent-sdk 0.1.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.
Files changed (78) hide show
  1. package/README.md +282 -0
  2. package/dist/agent-loop/agent-loop.d.ts +54 -0
  3. package/dist/agent-loop/agent-loop.d.ts.map +1 -0
  4. package/dist/agent-loop/agent-loop.js +328 -0
  5. package/dist/agent-loop/agent-loop.js.map +1 -0
  6. package/dist/agent-loop/decision-handler.d.ts +37 -0
  7. package/dist/agent-loop/decision-handler.d.ts.map +1 -0
  8. package/dist/agent-loop/decision-handler.js +91 -0
  9. package/dist/agent-loop/decision-handler.js.map +1 -0
  10. package/dist/agent-loop/llm-adapters/anthropic.d.ts +10 -0
  11. package/dist/agent-loop/llm-adapters/anthropic.d.ts.map +1 -0
  12. package/dist/agent-loop/llm-adapters/anthropic.js +60 -0
  13. package/dist/agent-loop/llm-adapters/anthropic.js.map +1 -0
  14. package/dist/agent-loop/llm-adapters/openai.d.ts +11 -0
  15. package/dist/agent-loop/llm-adapters/openai.d.ts.map +1 -0
  16. package/dist/agent-loop/llm-adapters/openai.js +54 -0
  17. package/dist/agent-loop/llm-adapters/openai.js.map +1 -0
  18. package/dist/agent-loop/llm-cost-tracker.d.ts +21 -0
  19. package/dist/agent-loop/llm-cost-tracker.d.ts.map +1 -0
  20. package/dist/agent-loop/llm-cost-tracker.js +63 -0
  21. package/dist/agent-loop/llm-cost-tracker.js.map +1 -0
  22. package/dist/agent-loop/model-router.d.ts +35 -0
  23. package/dist/agent-loop/model-router.d.ts.map +1 -0
  24. package/dist/agent-loop/model-router.js +55 -0
  25. package/dist/agent-loop/model-router.js.map +1 -0
  26. package/dist/agent-loop/telemetry-reporter.d.ts +60 -0
  27. package/dist/agent-loop/telemetry-reporter.d.ts.map +1 -0
  28. package/dist/agent-loop/telemetry-reporter.js +78 -0
  29. package/dist/agent-loop/telemetry-reporter.js.map +1 -0
  30. package/dist/agent-loop/types.d.ts +125 -0
  31. package/dist/agent-loop/types.d.ts.map +1 -0
  32. package/dist/agent-loop/types.js +10 -0
  33. package/dist/agent-loop/types.js.map +1 -0
  34. package/dist/agent-loop/webhook-receiver.d.ts +22 -0
  35. package/dist/agent-loop/webhook-receiver.d.ts.map +1 -0
  36. package/dist/agent-loop/webhook-receiver.js +145 -0
  37. package/dist/agent-loop/webhook-receiver.js.map +1 -0
  38. package/dist/auth/onboarding.d.ts +12 -0
  39. package/dist/auth/onboarding.d.ts.map +1 -0
  40. package/dist/auth/onboarding.js +51 -0
  41. package/dist/auth/onboarding.js.map +1 -0
  42. package/dist/auth/token-store.d.ts +44 -0
  43. package/dist/auth/token-store.d.ts.map +1 -0
  44. package/dist/auth/token-store.js +67 -0
  45. package/dist/auth/token-store.js.map +1 -0
  46. package/dist/client/http-client.d.ts +22 -0
  47. package/dist/client/http-client.d.ts.map +1 -0
  48. package/dist/client/http-client.js +127 -0
  49. package/dist/client/http-client.js.map +1 -0
  50. package/dist/errors/agent-sdk-error.d.ts +13 -0
  51. package/dist/errors/agent-sdk-error.d.ts.map +1 -0
  52. package/dist/errors/agent-sdk-error.js +17 -0
  53. package/dist/errors/agent-sdk-error.js.map +1 -0
  54. package/dist/errors/error-codes.d.ts +2 -0
  55. package/dist/errors/error-codes.d.ts.map +1 -0
  56. package/dist/errors/error-codes.js +3 -0
  57. package/dist/errors/error-codes.js.map +1 -0
  58. package/dist/index.d.ts +34 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +63 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/mcp/mcp-client.d.ts +184 -0
  63. package/dist/mcp/mcp-client.d.ts.map +1 -0
  64. package/dist/mcp/mcp-client.js +469 -0
  65. package/dist/mcp/mcp-client.js.map +1 -0
  66. package/dist/streaming/sse-event-stream.d.ts +58 -0
  67. package/dist/streaming/sse-event-stream.d.ts.map +1 -0
  68. package/dist/streaming/sse-event-stream.js +263 -0
  69. package/dist/streaming/sse-event-stream.js.map +1 -0
  70. package/dist/types.d.ts +151 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +3 -0
  73. package/dist/types.js.map +1 -0
  74. package/dist/utils/retry.d.ts +30 -0
  75. package/dist/utils/retry.d.ts.map +1 -0
  76. package/dist/utils/retry.js +85 -0
  77. package/dist/utils/retry.js.map +1 -0
  78. package/package.json +68 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpClient = void 0;
4
+ const agent_sdk_error_1 = require("../errors/agent-sdk-error");
5
+ const retry_1 = require("../utils/retry");
6
+ class HttpClient {
7
+ baseUrl;
8
+ timeoutMs;
9
+ fetchFn;
10
+ retryOptions;
11
+ constructor(config) {
12
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
13
+ this.timeoutMs = config.timeoutMs;
14
+ this.fetchFn = config.fetchFn ?? fetch;
15
+ this.retryOptions = config.retry ?? { maxAttempts: 3 };
16
+ }
17
+ async get(path, headers) {
18
+ return (0, retry_1.withRetry)(() => this.request(path, { method: "GET", headers }), this.retryOptions);
19
+ }
20
+ async post(path, body, headers) {
21
+ return (0, retry_1.withRetry)(() => this.request(path, {
22
+ method: "POST",
23
+ headers,
24
+ body: JSON.stringify(body),
25
+ }), this.retryOptions);
26
+ }
27
+ async request(path, init) {
28
+ const controller = new AbortController();
29
+ const timeout = globalThis.setTimeout(() => controller.abort(), this.timeoutMs);
30
+ try {
31
+ const response = await this.fetchFn(`${this.baseUrl}${path}`, {
32
+ method: init.method,
33
+ headers: {
34
+ "Content-Type": "application/json",
35
+ ...(init.headers ?? {}),
36
+ },
37
+ body: init.body,
38
+ signal: controller.signal,
39
+ });
40
+ const parsed = await this.safeJsonParse(response);
41
+ if (!response.ok) {
42
+ throw this.mapHttpError(response.status, parsed);
43
+ }
44
+ const normalized = this.unwrapCanonicalEnvelope(path, response.status, parsed);
45
+ if (!normalized || typeof normalized !== "object") {
46
+ throw new agent_sdk_error_1.AgentSdkError({
47
+ code: "invalid_response",
48
+ message: `Unexpected response format from ${path}`,
49
+ status: response.status,
50
+ details: normalized,
51
+ });
52
+ }
53
+ return normalized;
54
+ }
55
+ catch (error) {
56
+ if (error instanceof agent_sdk_error_1.AgentSdkError) {
57
+ throw error;
58
+ }
59
+ const message = error instanceof Error ? error.message : "Unknown network error";
60
+ throw new agent_sdk_error_1.AgentSdkError({
61
+ code: "network_error",
62
+ message,
63
+ details: error,
64
+ });
65
+ }
66
+ finally {
67
+ globalThis.clearTimeout(timeout);
68
+ }
69
+ }
70
+ async safeJsonParse(response) {
71
+ const text = await response.text();
72
+ if (!text) {
73
+ return null;
74
+ }
75
+ try {
76
+ return JSON.parse(text);
77
+ }
78
+ catch {
79
+ return text;
80
+ }
81
+ }
82
+ unwrapCanonicalEnvelope(path, status, parsed) {
83
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
84
+ return parsed;
85
+ }
86
+ const record = parsed;
87
+ const hasSuccess = typeof record.success === "boolean";
88
+ if (!hasSuccess) {
89
+ return parsed;
90
+ }
91
+ const success = record.success;
92
+ if (!success) {
93
+ const details = Object.prototype.hasOwnProperty.call(record, "error")
94
+ ? record.error
95
+ : parsed;
96
+ throw new agent_sdk_error_1.AgentSdkError({
97
+ code: "execution_error",
98
+ status,
99
+ message: `Request failed for ${path}`,
100
+ details,
101
+ });
102
+ }
103
+ if (!Object.prototype.hasOwnProperty.call(record, "data")) {
104
+ return parsed;
105
+ }
106
+ return record.data;
107
+ }
108
+ mapHttpError(status, details) {
109
+ const code = status === 401 || status === 403
110
+ ? "provider_auth_error"
111
+ : status === 429
112
+ ? "rate_limit_error"
113
+ : status === 400
114
+ ? "policy_error"
115
+ : status >= 500
116
+ ? "execution_error"
117
+ : "auth_error";
118
+ return new agent_sdk_error_1.AgentSdkError({
119
+ code,
120
+ status,
121
+ message: `HTTP ${status}`,
122
+ details,
123
+ });
124
+ }
125
+ }
126
+ exports.HttpClient = HttpClient;
127
+ //# sourceMappingURL=http-client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vB,MAAM;gBACN,OAAO,EAAE,sBAAsB,IAAI,EAAE;gBACrC,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YAC1D,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAEO,YAAY,CAAC,MAAc,EAAE,OAAgB;QACnD,MAAM,IAAI,GACR,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG;YAC9B,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,MAAM,KAAK,GAAG;gBACd,CAAC,CAAC,kBAAkB;gBACpB,CAAC,CAAC,MAAM,KAAK,GAAG;oBACd,CAAC,CAAC,cAAc;oBAChB,CAAC,CAAC,MAAM,IAAI,GAAG;wBACb,CAAC,CAAC,iBAAiB;wBACnB,CAAC,CAAC,YAAY,CAAC;QAEzB,OAAO,IAAI,+BAAa,CAAC;YACvB,IAAI;YACJ,MAAM;YACN,OAAO,EAAE,QAAQ,MAAM,EAAE;YACzB,OAAO;SACR,CAAC,CAAC;IACL,CAAC;CACF;AAxJD,gCAwJC"}
@@ -0,0 +1,13 @@
1
+ import type { AgentSdkErrorCode } from "./error-codes";
2
+ export declare class AgentSdkError extends Error {
3
+ readonly code: AgentSdkErrorCode;
4
+ readonly status?: number;
5
+ readonly details?: unknown;
6
+ constructor(params: {
7
+ code: AgentSdkErrorCode;
8
+ message: string;
9
+ status?: number;
10
+ details?: unknown;
11
+ });
12
+ }
13
+ //# sourceMappingURL=agent-sdk-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-sdk-error.d.ts","sourceRoot":"","sources":["../../src/errors/agent-sdk-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEf,MAAM,EAAE;QAClB,IAAI,EAAE,iBAAiB,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;CAOF"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentSdkError = void 0;
4
+ class AgentSdkError extends Error {
5
+ code;
6
+ status;
7
+ details;
8
+ constructor(params) {
9
+ super(params.message);
10
+ this.name = "AgentSdkError";
11
+ this.code = params.code;
12
+ this.status = params.status;
13
+ this.details = params.details;
14
+ }
15
+ }
16
+ exports.AgentSdkError = AgentSdkError;
17
+ //# sourceMappingURL=agent-sdk-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-sdk-error.js","sourceRoot":"","sources":["../../src/errors/agent-sdk-error.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAoB;IACxB,MAAM,CAAU;IAChB,OAAO,CAAW;IAE3B,YAAY,MAKX;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC;CACF;AAjBD,sCAiBC"}
@@ -0,0 +1,2 @@
1
+ export type AgentSdkErrorCode = "auth_error" | "policy_error" | "rate_limit_error" | "provider_auth_error" | "network_error" | "execution_error" | "invalid_response" | "unknown_error";
2
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../src/errors/error-codes.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,qBAAqB,GACrB,eAAe,GACf,iBAAiB,GACjB,kBAAkB,GAClB,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=error-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../../src/errors/error-codes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { BalchemyMcpClient } from "./mcp/mcp-client";
2
+ import type { AgentSdkConfig, IdentityTokenRevokeResponse, IdentityTokenRevokeStatusInput, OnboardWithIdentityInput, OnboardWithSiweInput, OnboardingResponse, RevokeIdentityTokenInput, RequestSiweNonceInput, SiweNonceResponse } from "./types";
3
+ export type { AgentSdkConfig, AgentOnboardingMode, AgentScope, IdentityAccess, OnboardWithIdentityInput, OnboardWithSiweInput, OnboardingResponse, RevokeIdentityTokenInput, IdentityTokenRevokeStatusInput, IdentityTokenRevokeResponse, RequestSiweNonceInput, SiweNonceResponse, McpTool, McpListToolsResponse, McpCallToolResponse, AgentResponse, McpToolExtensions, McpToolWithMetadata, } from "./types";
4
+ export type { AgentSdkErrorCode } from "./errors/error-codes";
5
+ export { AgentSdkError } from "./errors/agent-sdk-error";
6
+ export { BalchemyMcpClient, connectMcp, getToolText, parseToolJson, isToolError } from "./mcp/mcp-client";
7
+ export type { AskBotArgs, TradeCommandArgs, AgentExecuteArgs, AgentResearchArgs, AgentConfigArgs, EvmQuoteArgs, EvmSwapArgs, McpBatchToolCallInput, McpBatchToolCallResult, McpHealthResponse, } from "./mcp/mcp-client";
8
+ export { SseEventStream } from "./streaming/sse-event-stream";
9
+ export type { SseEvent, SseStreamOptions } from "./streaming/sse-event-stream";
10
+ export type { StoredToken, TokenRefreshFn, TokenStoreOptions, } from "./auth/token-store";
11
+ export { TokenStore } from "./auth/token-store";
12
+ export { AgentLoop } from './agent-loop/agent-loop';
13
+ export { LlmCostTracker } from './agent-loop/llm-cost-tracker';
14
+ export { DecisionHandler } from './agent-loop/decision-handler';
15
+ export { WebhookReceiver } from './agent-loop/webhook-receiver';
16
+ export { OpenAiAdapter } from './agent-loop/llm-adapters/openai';
17
+ export { AnthropicAdapter } from './agent-loop/llm-adapters/anthropic';
18
+ export type { AgentLoopConfig, AgentStatus, AgentLoopStatus, AgentEvent, AgentDecision, LlmAdapter, LlmMessage, LlmResponse, LlmProvider, } from './agent-loop/types';
19
+ export declare class BalchemyAgentSdk {
20
+ private readonly onboarding;
21
+ constructor(config: AgentSdkConfig);
22
+ requestSiweNonce(input: RequestSiweNonceInput): Promise<SiweNonceResponse>;
23
+ onboardWithSiwe(input: OnboardWithSiweInput): Promise<OnboardingResponse>;
24
+ onboardWithIdentity(input: OnboardWithIdentityInput): Promise<OnboardingResponse>;
25
+ revokeIdentityToken(input: RevokeIdentityTokenInput): Promise<IdentityTokenRevokeResponse>;
26
+ getIdentityTokenRevokeStatus(input: IdentityTokenRevokeStatusInput): Promise<IdentityTokenRevokeResponse>;
27
+ connectMcp(params: {
28
+ endpoint: string;
29
+ apiKey: string;
30
+ timeoutMs?: number;
31
+ fetchFn?: typeof fetch;
32
+ }): BalchemyMcpClient;
33
+ }
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAc,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,2BAA2B,EAC3B,8BAA8B,EAC9B,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,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AE,MAAM,qCAAqC,CAAC;AACvE,YAAY,EACV,eAAe,EACf,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAwB;gBAEvC,MAAM,EAAE,cAAc;IAU5B,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI1E,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIzE,mBAAmB,CACvB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,kBAAkB,CAAC;IAIxB,mBAAmB,CACvB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,2BAA2B,CAAC;IAIjC,4BAA4B,CAChC,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,2BAA2B,CAAC;IAIvC,UAAU,CAAC,MAAM,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;KACxB,GAAG,iBAAiB;CAGtB"}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BalchemyAgentSdk = exports.AnthropicAdapter = exports.OpenAiAdapter = exports.WebhookReceiver = exports.DecisionHandler = exports.LlmCostTracker = exports.AgentLoop = exports.TokenStore = exports.SseEventStream = exports.isToolError = exports.parseToolJson = exports.getToolText = exports.connectMcp = exports.BalchemyMcpClient = exports.AgentSdkError = void 0;
4
+ const http_client_1 = require("./client/http-client");
5
+ const onboarding_1 = require("./auth/onboarding");
6
+ const mcp_client_1 = require("./mcp/mcp-client");
7
+ var agent_sdk_error_1 = require("./errors/agent-sdk-error");
8
+ Object.defineProperty(exports, "AgentSdkError", { enumerable: true, get: function () { return agent_sdk_error_1.AgentSdkError; } });
9
+ var mcp_client_2 = require("./mcp/mcp-client");
10
+ Object.defineProperty(exports, "BalchemyMcpClient", { enumerable: true, get: function () { return mcp_client_2.BalchemyMcpClient; } });
11
+ Object.defineProperty(exports, "connectMcp", { enumerable: true, get: function () { return mcp_client_2.connectMcp; } });
12
+ Object.defineProperty(exports, "getToolText", { enumerable: true, get: function () { return mcp_client_2.getToolText; } });
13
+ Object.defineProperty(exports, "parseToolJson", { enumerable: true, get: function () { return mcp_client_2.parseToolJson; } });
14
+ Object.defineProperty(exports, "isToolError", { enumerable: true, get: function () { return mcp_client_2.isToolError; } });
15
+ var sse_event_stream_1 = require("./streaming/sse-event-stream");
16
+ Object.defineProperty(exports, "SseEventStream", { enumerable: true, get: function () { return sse_event_stream_1.SseEventStream; } });
17
+ var token_store_1 = require("./auth/token-store");
18
+ Object.defineProperty(exports, "TokenStore", { enumerable: true, get: function () { return token_store_1.TokenStore; } });
19
+ // Agent Loop
20
+ var agent_loop_1 = require("./agent-loop/agent-loop");
21
+ Object.defineProperty(exports, "AgentLoop", { enumerable: true, get: function () { return agent_loop_1.AgentLoop; } });
22
+ var llm_cost_tracker_1 = require("./agent-loop/llm-cost-tracker");
23
+ Object.defineProperty(exports, "LlmCostTracker", { enumerable: true, get: function () { return llm_cost_tracker_1.LlmCostTracker; } });
24
+ var decision_handler_1 = require("./agent-loop/decision-handler");
25
+ Object.defineProperty(exports, "DecisionHandler", { enumerable: true, get: function () { return decision_handler_1.DecisionHandler; } });
26
+ var webhook_receiver_1 = require("./agent-loop/webhook-receiver");
27
+ Object.defineProperty(exports, "WebhookReceiver", { enumerable: true, get: function () { return webhook_receiver_1.WebhookReceiver; } });
28
+ var openai_1 = require("./agent-loop/llm-adapters/openai");
29
+ Object.defineProperty(exports, "OpenAiAdapter", { enumerable: true, get: function () { return openai_1.OpenAiAdapter; } });
30
+ var anthropic_1 = require("./agent-loop/llm-adapters/anthropic");
31
+ Object.defineProperty(exports, "AnthropicAdapter", { enumerable: true, get: function () { return anthropic_1.AnthropicAdapter; } });
32
+ class BalchemyAgentSdk {
33
+ onboarding;
34
+ constructor(config) {
35
+ const timeoutMs = config.timeoutMs ?? 15_000;
36
+ const http = new http_client_1.HttpClient({
37
+ baseUrl: config.apiBaseUrl,
38
+ timeoutMs,
39
+ fetchFn: config.fetchFn,
40
+ });
41
+ this.onboarding = new onboarding_1.AgentOnboardingClient(http);
42
+ }
43
+ async requestSiweNonce(input) {
44
+ return this.onboarding.requestSiweNonce(input);
45
+ }
46
+ async onboardWithSiwe(input) {
47
+ return this.onboarding.onboardWithSiwe(input);
48
+ }
49
+ async onboardWithIdentity(input) {
50
+ return this.onboarding.onboardWithIdentity(input);
51
+ }
52
+ async revokeIdentityToken(input) {
53
+ return this.onboarding.revokeIdentityToken(input);
54
+ }
55
+ async getIdentityTokenRevokeStatus(input) {
56
+ return this.onboarding.getIdentityTokenRevokeStatus(input);
57
+ }
58
+ connectMcp(params) {
59
+ return (0, mcp_client_1.connectMcp)(params);
60
+ }
61
+ }
62
+ exports.BalchemyAgentSdk = BalchemyAgentSdk;
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAClD,kDAA0D;AAC1D,iDAAiE;AAkCjE,4DAAyD;AAAhD,gHAAA,aAAa,OAAA;AACtB,+CAA0G;AAAjG,+GAAA,iBAAiB,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,yGAAA,WAAW,OAAA;AAa/E,iEAA8D;AAArD,kHAAA,cAAc,OAAA;AAOvB,kDAAgD;AAAvC,yGAAA,UAAU,OAAA;AAEnB,aAAa;AACb,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,kE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/CD,4CA+CC"}
@@ -0,0 +1,184 @@
1
+ import { AgentSdkError } from "../errors/agent-sdk-error";
2
+ import { type RetryOptions } from "../utils/retry";
3
+ import type { McpCallToolResponse, McpListToolsResponse } from "../types";
4
+ export type McpBatchToolCallInput = {
5
+ name: string;
6
+ arguments: Record<string, unknown>;
7
+ };
8
+ export type McpBatchToolCallResult = {
9
+ success: true;
10
+ name: string;
11
+ index: number;
12
+ result: McpCallToolResponse;
13
+ } | {
14
+ success: false;
15
+ name: string;
16
+ index: number;
17
+ error: AgentSdkError;
18
+ };
19
+ export type McpHealthResponse = {
20
+ ok: true;
21
+ publicId: string;
22
+ scope: "read" | "trade" | "manage";
23
+ };
24
+ export type McpClientConfig = {
25
+ endpoint: string;
26
+ apiKey: string;
27
+ timeoutMs?: number;
28
+ fetchFn?: typeof fetch;
29
+ /** Retry options. Default: 3 attempts with exponential backoff. */
30
+ retry?: RetryOptions;
31
+ };
32
+ /** Extract typed text from a tool call response. Returns empty string on error. */
33
+ export declare function getToolText(response: McpCallToolResponse): string;
34
+ /** Parse a tool call response text as JSON. Returns null if not valid JSON. */
35
+ export declare function parseToolJson<T = unknown>(response: McpCallToolResponse): T | null;
36
+ /** Returns true if the tool response indicates an error. */
37
+ export declare function isToolError(response: McpCallToolResponse): boolean;
38
+ export type AskBotArgs = {
39
+ message: string;
40
+ chat_id?: string;
41
+ };
42
+ export type TradeCommandArgs = {
43
+ message: string;
44
+ chat_id?: string;
45
+ recent_messages?: string[];
46
+ last_mentioned_ca?: string;
47
+ };
48
+ export type AgentExecuteArgs = {
49
+ instruction: string;
50
+ chat_id?: string;
51
+ metadata?: Record<string, unknown>;
52
+ };
53
+ export type AgentResearchArgs = {
54
+ query: string;
55
+ chain?: "solana" | "base" | "ethereum";
56
+ includeX?: boolean;
57
+ includeOnchain?: boolean;
58
+ includeDevWallets?: boolean;
59
+ includeHolders?: boolean;
60
+ maxPosts?: number;
61
+ };
62
+ export type AgentConfigArgs = {
63
+ operation: "get" | "update_trade_defaults" | "update_risk_policy";
64
+ defaults?: Record<string, unknown>;
65
+ policy?: Record<string, unknown>;
66
+ };
67
+ export type EvmQuoteArgs = {
68
+ chainId?: number;
69
+ sellToken: string;
70
+ buyToken: string;
71
+ sellAmount: string;
72
+ slippageBps?: number;
73
+ };
74
+ export type EvmSwapArgs = EvmQuoteArgs & {
75
+ submit?: boolean;
76
+ };
77
+ export type AgentSeedRequestArgs = {
78
+ chainId?: number;
79
+ walletAddress?: string;
80
+ };
81
+ export declare class BalchemyMcpClient {
82
+ private readonly endpoint;
83
+ private readonly apiKey;
84
+ private readonly timeoutMs;
85
+ private readonly fetchFn;
86
+ private readonly retryOptions;
87
+ constructor(config: McpClientConfig);
88
+ listTools(): Promise<McpListToolsResponse>;
89
+ callTool(name: string, argumentsPayload: Record<string, unknown>): Promise<McpCallToolResponse>;
90
+ /**
91
+ * Lightweight health check using the `/health` endpoint.
92
+ * Returns `true` if the API key is valid and MCP is enabled.
93
+ * Falls back to `listTools()` if the health endpoint returns 404
94
+ * (e.g. backend not yet upgraded).
95
+ */
96
+ ping(): Promise<boolean>;
97
+ /**
98
+ * Call the lightweight `/health` endpoint for this MCP principal.
99
+ * Throws `AgentSdkError` if unauthorized or not found.
100
+ */
101
+ healthCheck(): Promise<McpHealthResponse>;
102
+ /**
103
+ * Send multiple tool calls in a single JSON-RPC batch request.
104
+ *
105
+ * The MCP server processes the batch array and returns an array of
106
+ * responses in the same order. Each result is individually marked
107
+ * `success: true | false` — a single failed tool does not abort the batch.
108
+ *
109
+ * NOTE: JSON-RPC batch support requires backend MCP SDK >= 1.x.
110
+ * Use `callToolsParallel()` for automatic fallback on unsupported servers.
111
+ */
112
+ callToolsBatch(calls: McpBatchToolCallInput[]): Promise<McpBatchToolCallResult[]>;
113
+ /**
114
+ * Execute multiple tool calls with best-effort parallelism.
115
+ *
116
+ * Tries `callToolsBatch()` first (single HTTP round-trip). If the server
117
+ * returns a non-batch-compatible error, falls back to running individual
118
+ * `callTool()` calls in parallel via `Promise.allSettled`.
119
+ *
120
+ * The fallback path maps `PromiseSettledResult` to `McpBatchToolCallResult`
121
+ * so callers always get the same shape regardless of the path taken.
122
+ */
123
+ callToolsParallel(calls: McpBatchToolCallInput[]): Promise<McpBatchToolCallResult[]>;
124
+ /** Natural language query via ask_bot. Use `chat_id` to maintain conversation continuity. */
125
+ askBot(args: AskBotArgs): Promise<McpCallToolResponse>;
126
+ /** Direct NLP trade command (regex parser, bypasses LLM). For structured trades, prefer `agentExecute()`. */
127
+ tradeCommand(args: TradeCommandArgs): Promise<McpCallToolResponse>;
128
+ /** High-level agent execution endpoint. Returns structured envelope with intent/result/metadata. Preferred over `tradeCommand()` for programmatic use. */
129
+ agentExecute(args: AgentExecuteArgs): Promise<McpCallToolResponse>;
130
+ /** High-level agent research endpoint. */
131
+ agentResearch(args: AgentResearchArgs): Promise<McpCallToolResponse>;
132
+ /** High-level portfolio/state snapshot endpoint. */
133
+ agentPortfolio(): Promise<McpCallToolResponse>;
134
+ /** High-level runtime/auth status endpoint. */
135
+ agentStatus(): Promise<McpCallToolResponse>;
136
+ /** High-level agent config endpoint (get/update). */
137
+ agentConfig(args: AgentConfigArgs): Promise<McpCallToolResponse>;
138
+ /** EVM swap quote (read-only). */
139
+ evmQuote(args: EvmQuoteArgs): Promise<McpCallToolResponse>;
140
+ /**
141
+ * EVM swap execution.
142
+ * By default `submit=false` (pending order) — pass `submit: true` to execute on-chain.
143
+ */
144
+ evmSwap(args: EvmSwapArgs): Promise<McpCallToolResponse>;
145
+ /** Solana Jupiter swap quote (read-only). Requires `MCP_EXPOSE_GRANULAR_TOOLS=true`. */
146
+ solanaQuote(args: {
147
+ inputMint: string;
148
+ outputMint: string;
149
+ amount: string;
150
+ slippageBps?: number;
151
+ }): Promise<McpCallToolResponse>;
152
+ /**
153
+ * Solana Jupiter swap execution. Requires `MCP_EXPOSE_GRANULAR_TOOLS=true`.
154
+ * By default `submit=false` (pending order) — pass `submit: true` to execute on-chain.
155
+ */
156
+ solanaSwap(args: {
157
+ inputMint: string;
158
+ outputMint: string;
159
+ amount: string;
160
+ slippageBps?: number;
161
+ submit?: boolean;
162
+ }): Promise<McpCallToolResponse>;
163
+ /**
164
+ * Read an MCP resource by URI (JSON-RPC `resources/read`).
165
+ * Returns the raw contents array. Callers extract `.text` from the first item.
166
+ */
167
+ readResource(uri: string): Promise<{
168
+ uri: string;
169
+ mimeType?: string;
170
+ text?: string;
171
+ }[]>;
172
+ /**
173
+ * @deprecated Seed pool is disabled. Fund custodial wallet via dashboard or on-chain transfer.
174
+ * Kept for backward compatibility; always throws a deterministic SDK error.
175
+ */
176
+ requestSeed(args?: AgentSeedRequestArgs): Promise<McpCallToolResponse>;
177
+ private rpc;
178
+ private resolveRetryOptions;
179
+ private parseJsonRpc;
180
+ private extractSsePayload;
181
+ private isJsonRpcError;
182
+ }
183
+ export declare const connectMcp: (config: McpClientConfig) => BalchemyMcpClient;
184
+ //# sourceMappingURL=mcp-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAIlB,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B;IACE,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,mBAAmB,CAAC;CAC7B,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,IAAI,EAAE,MAAM,C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