@balchemyai/agent-sdk 0.7.0 → 0.8.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 (33) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/README.md +2 -2
  3. package/dist/agent-loop/llm-adapters/openai.d.ts.map +1 -1
  4. package/dist/agent-loop/llm-adapters/openai.js +7 -1
  5. package/dist/agent-loop/llm-adapters/openai.js.map +1 -1
  6. package/dist/agent-loop/types.d.ts +3 -0
  7. package/dist/agent-loop/types.d.ts.map +1 -1
  8. package/dist/index.d.ts +10 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +44 -9
  11. package/dist/index.js.map +1 -1
  12. package/dist/local-runner/execution-build-client.d.ts +42 -5
  13. package/dist/local-runner/execution-build-client.d.ts.map +1 -1
  14. package/dist/local-runner/execution-build-client.js +53 -6
  15. package/dist/local-runner/execution-build-client.js.map +1 -1
  16. package/dist/local-runner/first-enable-ceiling-client.d.ts +74 -0
  17. package/dist/local-runner/first-enable-ceiling-client.d.ts.map +1 -0
  18. package/dist/local-runner/first-enable-ceiling-client.js +138 -0
  19. package/dist/local-runner/first-enable-ceiling-client.js.map +1 -0
  20. package/dist/local-runner/launchpad-client.d.ts +95 -0
  21. package/dist/local-runner/launchpad-client.d.ts.map +1 -0
  22. package/dist/local-runner/launchpad-client.js +284 -0
  23. package/dist/local-runner/launchpad-client.js.map +1 -0
  24. package/dist/local-runner/rpc-access-client.d.ts +76 -0
  25. package/dist/local-runner/rpc-access-client.d.ts.map +1 -0
  26. package/dist/local-runner/rpc-access-client.js +207 -0
  27. package/dist/local-runner/rpc-access-client.js.map +1 -0
  28. package/dist/local-runner/signals-client.d.ts +12 -1
  29. package/dist/local-runner/signals-client.d.ts.map +1 -1
  30. package/dist/local-runner/signals-client.js +41 -10
  31. package/dist/local-runner/signals-client.js.map +1 -1
  32. package/docs/DEPLOYMENT.md +1 -1
  33. package/package.json +1 -1
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunnerLaunchpadSubscriptionsClient = exports.RUNNER_LAUNCHPAD_ID = exports.RUNNER_LAUNCHPAD_MAX_SUBSCRIPTIONS = exports.RUNNER_LAUNCHPAD_REFUSALS = exports.RUNNER_LAUNCHPAD_STATUSES = void 0;
4
+ exports.canonicalRunnerLaunchpadIds = canonicalRunnerLaunchpadIds;
5
+ exports.validateRunnerLaunchpadCatalog = validateRunnerLaunchpadCatalog;
6
+ exports.fetchRunnerLaunchpadCatalog = fetchRunnerLaunchpadCatalog;
7
+ exports.runnerLaunchpadSubscriptionsRequestDigest = runnerLaunchpadSubscriptionsRequestDigest;
8
+ exports.validateRunnerLaunchpadSubscriptionsNonce = validateRunnerLaunchpadSubscriptionsNonce;
9
+ exports.runnerLaunchpadSubscriptionsNonceMessage = runnerLaunchpadSubscriptionsNonceMessage;
10
+ exports.validateRunnerLaunchpadSubscriptionsResponse = validateRunnerLaunchpadSubscriptionsResponse;
11
+ const agent_sdk_error_1 = require("../errors/agent-sdk-error");
12
+ const redaction_1 = require("../utils/redaction");
13
+ const runner_proof_transport_1 = require("./runner-proof-transport");
14
+ /** K4 launchpad signal sources (owner decision of 19 Nov 2026): a public catalog of Solana launchpads and the agent's runner-signed
15
+ * subscription (no wallet signature). Contract: BALCHEMY-FORENSIC-2026-10-04/m0m1/s5/prep/k4-launchpad-contract.md.
16
+ * - GET /api/nest/local-agents/launchpads: public, credential-free, closed response (version 1, chain solana).
17
+ * - POST /api/nest/local-agents/launchpad-subscriptions/{nonce,query}: the same runner proof as the signals route; `get` reads and
18
+ * `set` replaces the whole subscription (ids strictly ascending, at most 32; `[]` unsubscribes).
19
+ * A launchpad signal is a public launch observation, never a buy signal or execution authority. */
20
+ exports.RUNNER_LAUNCHPAD_STATUSES = ["live", "coming_soon"];
21
+ /** AgentSdkError.machineCode of a 400 whose closed `details.reason` names a refused launchpad. */
22
+ exports.RUNNER_LAUNCHPAD_REFUSALS = ["launchpad_unknown", "launchpad_not_live"];
23
+ exports.RUNNER_LAUNCHPAD_MAX_SUBSCRIPTIONS = 32;
24
+ /** Stable launchpad slug (backend LOCAL_AGENT_LAUNCHPAD_ID). */
25
+ exports.RUNNER_LAUNCHPAD_ID = /^[a-z][a-z0-9_]{1,31}$/;
26
+ const CATALOG_PATH = "/nest/local-agents/launchpads";
27
+ const PATH = "/nest/local-agents/launchpad-subscriptions";
28
+ const PURPOSE = "balchemy.local-agent.launchpad-subscriptions.query.v1";
29
+ const REQUEST_PURPOSE = "balchemy.local-agent.launchpad-subscriptions.request.v1";
30
+ const MAX_PAYLOAD_BYTES = 8192;
31
+ const MAX_CATALOG_BYTES = 64 * 1024;
32
+ const MAX_ENVELOPE_BYTES = 4096;
33
+ const MAX_FAILURE_BYTES = 8192;
34
+ const MAX_CATALOG_ENTRIES = 64;
35
+ const SOURCE_ID = /^src_[0-9a-f]{24}$/;
36
+ const SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
37
+ const invalid = (0, runner_proof_transport_1.invalidFor)("launchpad");
38
+ const cancelled = (0, runner_proof_transport_1.cancelledFor)("launchpad");
39
+ const exact = (0, runner_proof_transport_1.exactWith)(invalid);
40
+ const timestamp = (0, runner_proof_transport_1.timestampWith)(invalid);
41
+ function text(value, maximum) {
42
+ if (typeof value !== "string" || value.length < 1 || value.length > maximum || /[\u0000-\u001f\u007f]/.test(value))
43
+ invalid();
44
+ return value;
45
+ }
46
+ function strictArray(value, maximum) {
47
+ if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype || value.length > maximum
48
+ || Reflect.ownKeys(value).length !== value.length + 1 || Object.keys(value).length !== value.length
49
+ || Object.values(Object.getOwnPropertyDescriptors(value)).some((field) => !("value" in field)))
50
+ invalid();
51
+ return value;
52
+ }
53
+ /** Strictly ascending launchpad ids (plain code-unit order, as the server compares), at most 32. */
54
+ function launchpadIds(value) {
55
+ const ids = strictArray(value, exports.RUNNER_LAUNCHPAD_MAX_SUBSCRIPTIONS);
56
+ for (let index = 0; index < ids.length; index++) {
57
+ if (!(0, runner_proof_transport_1.matches)(ids[index], exports.RUNNER_LAUNCHPAD_ID) || (index > 0 && ids[index - 1] >= ids[index]))
58
+ invalid();
59
+ }
60
+ return [...ids];
61
+ }
62
+ /** Sorted unique ids in the server's order; refuses a malformed id or more than 32. */
63
+ function canonicalRunnerLaunchpadIds(ids) {
64
+ if (!Array.isArray(ids))
65
+ invalid();
66
+ return launchpadIds([...new Set(ids)].sort());
67
+ }
68
+ /** Closed catalog parser (version 1, chain solana, unique ids and source ids; a coming-soon entry may list no program ids). */
69
+ function validateRunnerLaunchpadCatalog(value) {
70
+ exact(value, ["version", "chain", "launchpads"]);
71
+ if (value.version !== 1 || value.chain !== "solana")
72
+ invalid();
73
+ const ids = new Set();
74
+ const sources = new Set();
75
+ const launchpads = strictArray(value.launchpads, MAX_CATALOG_ENTRIES).map((entry) => {
76
+ exact(entry, ["id", "name", "chain", "status", "sourceId", "programIds", "sourceNote"]);
77
+ if (!(0, runner_proof_transport_1.matches)(entry.id, exports.RUNNER_LAUNCHPAD_ID) || entry.chain !== "solana" || !(0, runner_proof_transport_1.matches)(entry.sourceId, SOURCE_ID)
78
+ || !exports.RUNNER_LAUNCHPAD_STATUSES.includes(entry.status) || ids.has(entry.id) || sources.has(entry.sourceId))
79
+ invalid();
80
+ const programIds = strictArray(entry.programIds, 8).map((item) => { if (!(0, runner_proof_transport_1.matches)(item, SOLANA_ADDRESS))
81
+ invalid(); return item; });
82
+ if (entry.status === "live" && programIds.length === 0)
83
+ invalid();
84
+ ids.add(entry.id);
85
+ sources.add(entry.sourceId);
86
+ return Object.freeze({ id: entry.id, name: text(entry.name, 64), chain: "solana", status: entry.status,
87
+ sourceId: entry.sourceId, programIds: Object.freeze(programIds), sourceNote: text(entry.sourceNote, 512) });
88
+ });
89
+ return Object.freeze({ version: 1, chain: "solana", launchpads: Object.freeze(launchpads) });
90
+ }
91
+ /** One bounded, credential-free, redirect-refusing read of the public catalog (the canonical success envelope is required). */
92
+ async function fetchRunnerLaunchpadCatalog(options, callerSignal) {
93
+ let origin;
94
+ try {
95
+ origin = new URL(options.frontendOrigin);
96
+ }
97
+ catch {
98
+ return invalid();
99
+ }
100
+ if (origin.origin !== options.frontendOrigin || origin.username || origin.password
101
+ || (origin.protocol !== "https:" && !(origin.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(origin.hostname))))
102
+ invalid();
103
+ const timeoutMs = options.timeoutMs ?? 10_000;
104
+ if (!(0, runner_proof_transport_1.positive)(timeoutMs) || timeoutMs > 30_000 || (options.fetchFn !== undefined && typeof options.fetchFn !== "function"))
105
+ invalid();
106
+ const scope = new AbortController();
107
+ const forward = () => scope.abort();
108
+ callerSignal?.addEventListener("abort", forward, { once: true });
109
+ if (callerSignal?.aborted)
110
+ scope.abort();
111
+ const deadline = setTimeout(forward, timeoutMs);
112
+ try {
113
+ const response = await (0, runner_proof_transport_1.waitFor)(() => (options.fetchFn ?? fetch)(`${origin.origin}/api${CATALOG_PATH}`, { method: "GET", signal: scope.signal,
114
+ credentials: "omit", redirect: "error", headers: { accept: "application/json", "Cache-Control": "no-store" } }), scope.signal, cancelled);
115
+ if (response.status !== 200 || response.redirected) {
116
+ await response.body?.cancel().catch(() => undefined);
117
+ throw new agent_sdk_error_1.AgentSdkError({ code: response.status === 429 ? "rate_limit_error" : "network_error", status: response.status,
118
+ message: "Local-agent launchpad catalog unavailable", details: { layer: "http_ingress", retryable: true } });
119
+ }
120
+ const body = await (0, runner_proof_transport_1.waitFor)(() => (0, redaction_1.readBoundedResponseText)(response, MAX_CATALOG_BYTES + MAX_ENVELOPE_BYTES, scope.signal), scope.signal, cancelled);
121
+ let decoded;
122
+ try {
123
+ decoded = JSON.parse(body);
124
+ }
125
+ catch {
126
+ return invalid();
127
+ }
128
+ exact(decoded, ["success", "data", "meta"], ["message"]);
129
+ if (decoded.success !== true)
130
+ invalid();
131
+ return validateRunnerLaunchpadCatalog(decoded.data);
132
+ }
133
+ catch (error) {
134
+ if (scope.signal.aborted)
135
+ throw cancelled();
136
+ if (error instanceof agent_sdk_error_1.AgentSdkError)
137
+ throw error;
138
+ return invalid();
139
+ }
140
+ finally {
141
+ clearTimeout(deadline);
142
+ callerSignal?.removeEventListener("abort", forward);
143
+ scope.abort();
144
+ }
145
+ }
146
+ function subscriptionsRequest(value) {
147
+ exact(value, ["kind"], ["launchpadIds"]);
148
+ if (value.kind === "get") {
149
+ exact(value, ["kind"]);
150
+ return Object.freeze({ kind: "get" });
151
+ }
152
+ exact(value, ["kind", "launchpadIds"]);
153
+ if (value.kind !== "set")
154
+ invalid();
155
+ return Object.freeze({ kind: "set", launchpadIds: Object.freeze(launchpadIds(value.launchpadIds)) });
156
+ }
157
+ /** SHA256(UTF8(JSON.stringify([REQUEST_PURPOSE, "get"]))) or SHA256(UTF8(JSON.stringify([REQUEST_PURPOSE, "set", launchpadIds]))). */
158
+ function runnerLaunchpadSubscriptionsRequestDigest(value) {
159
+ const checked = subscriptionsRequest(value);
160
+ return (0, runner_proof_transport_1.sha256)(checked.kind === "get" ? [REQUEST_PURPOSE, "get"] : [REQUEST_PURPOSE, "set", checked.launchpadIds]);
161
+ }
162
+ function expected(value) {
163
+ exact(value, [...runner_proof_transport_1.TARGET_KEYS, "epoch", "request"]);
164
+ if (!(0, runner_proof_transport_1.positive)(value.epoch))
165
+ invalid();
166
+ return Object.freeze({ ...(0, runner_proof_transport_1.pinTarget)((0, runner_proof_transport_1.targetPart)(value), invalid), epoch: value.epoch, request: subscriptionsRequest(value.request) });
167
+ }
168
+ function validateRunnerLaunchpadSubscriptionsNonce(value, expectedTarget, now = Date.now()) {
169
+ const pinned = expected(expectedTarget);
170
+ return (0, runner_proof_transport_1.validateProofNonce)(value, pinned, PURPOSE, "launchpad-subscriptions/query", runnerLaunchpadSubscriptionsRequestDigest(pinned.request), now, invalid);
171
+ }
172
+ function runnerLaunchpadSubscriptionsNonceMessage(value, expectedTarget, now = Date.now()) {
173
+ return (0, runner_proof_transport_1.proofNonceMessage)(validateRunnerLaunchpadSubscriptionsNonce(value, expectedTarget, now));
174
+ }
175
+ /** Closed response; a `set` must answer exactly the ids it asked for. */
176
+ function validateRunnerLaunchpadSubscriptionsResponse(value, expectedTarget, now = Date.now()) {
177
+ const pinned = expected(expectedTarget);
178
+ exact(value, ["version", "requestDigest", "agentId", "bindingDigest", "instanceId", "epoch", "completedAt", "subscription"]);
179
+ if (!Number.isFinite(now) || value.version !== 1 || value.requestDigest !== runnerLaunchpadSubscriptionsRequestDigest(pinned.request)
180
+ || value.agentId !== pinned.agentId || value.bindingDigest !== pinned.bindingDigest || value.instanceId !== pinned.instanceId
181
+ || value.epoch !== pinned.epoch || Math.abs(timestamp(value.completedAt) - now) > 5 * 60_000)
182
+ invalid();
183
+ exact(value.subscription, ["revision", "launchpadIds", "updatedAt"]);
184
+ const { revision, updatedAt } = value.subscription;
185
+ const ids = launchpadIds(value.subscription.launchpadIds);
186
+ if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < 0
187
+ || (revision === 0) !== (updatedAt === null) || (revision === 0 && ids.length > 0)
188
+ || (updatedAt !== null && timestamp(updatedAt) > timestamp(value.completedAt) + 5_000))
189
+ invalid();
190
+ if (pinned.request.kind === "set" && JSON.stringify(ids) !== JSON.stringify(pinned.request.launchpadIds))
191
+ invalid();
192
+ return Object.freeze({ version: 1, requestDigest: value.requestDigest, agentId: value.agentId,
193
+ bindingDigest: value.bindingDigest, instanceId: value.instanceId, epoch: value.epoch,
194
+ completedAt: value.completedAt, subscription: Object.freeze({ revision, launchpadIds: Object.freeze(ids), updatedAt: updatedAt }) });
195
+ }
196
+ /** The closed refusal of a 400 body (canonical `error.details.reason` or legacy `details.reason`), else undefined. */
197
+ function refusalReason(text) {
198
+ let body;
199
+ try {
200
+ body = JSON.parse(text);
201
+ }
202
+ catch {
203
+ return undefined;
204
+ }
205
+ const reason = (item) => item && typeof item === "object" && !Array.isArray(item)
206
+ ? item.details?.reason : undefined;
207
+ if (!body || typeof body !== "object" || Array.isArray(body))
208
+ return undefined;
209
+ const found = reason(body.error) ?? reason(body);
210
+ return exports.RUNNER_LAUNCHPAD_REFUSALS.includes(found) ? found : undefined;
211
+ }
212
+ /** Public runner route only; credential-free, redirect-refusing, one signed attempt per call. */
213
+ class RunnerLaunchpadSubscriptionsClient {
214
+ pinned;
215
+ signer;
216
+ timeoutMs;
217
+ transport;
218
+ constructor(config) {
219
+ exact(config, [...runner_proof_transport_1.TARGET_KEYS, "apiBaseUrl", "signer"], ["timeoutMs", "fetchFn"]);
220
+ this.pinned = (0, runner_proof_transport_1.pinTarget)((0, runner_proof_transport_1.targetPart)(config), invalid);
221
+ if (config.apiBaseUrl !== `${this.pinned.frontendOrigin}/api` || typeof config.signer !== "function"
222
+ || (config.fetchFn !== undefined && typeof config.fetchFn !== "function")
223
+ || (config.timeoutMs !== undefined && (!(0, runner_proof_transport_1.positive)(config.timeoutMs) || config.timeoutMs > 30_000)))
224
+ invalid();
225
+ this.signer = config.signer;
226
+ this.timeoutMs = config.timeoutMs ?? 15_000;
227
+ this.transport = config.fetchFn ?? fetch;
228
+ }
229
+ /** A refused launchpad (400 `launchpad_unknown` / `launchpad_not_live`) is an AgentSdkError whose machineCode is that reason in
230
+ * upper case (LAUNCHPAD_UNKNOWN / LAUNCHPAD_NOT_LIVE). */
231
+ async query(input, epoch, callerSignal) {
232
+ const operation = expected({ ...this.pinned, epoch, request: input });
233
+ if (callerSignal !== undefined && !(callerSignal instanceof AbortSignal))
234
+ invalid();
235
+ const scope = new AbortController();
236
+ const forward = () => scope.abort();
237
+ callerSignal?.addEventListener("abort", forward, { once: true });
238
+ if (callerSignal?.aborted)
239
+ scope.abort();
240
+ const deadline = setTimeout(forward, this.timeoutMs);
241
+ // Only a 400 body is inspected, for its closed reason; the bytes are handed on unchanged.
242
+ let refused;
243
+ const transport = async (url, init) => {
244
+ const response = await this.transport(url, init);
245
+ if (response.status !== 400)
246
+ return response;
247
+ const body = await (0, redaction_1.readBoundedResponseText)(response, MAX_FAILURE_BYTES, init?.signal ?? undefined);
248
+ refused = refusalReason(body);
249
+ return new Response(body, { status: response.status, statusText: response.statusText, headers: response.headers });
250
+ };
251
+ const http = (0, runner_proof_transport_1.proofHttpClient)(this.pinned.frontendOrigin, this.timeoutMs, transport, scope.signal, MAX_PAYLOAD_BYTES, invalid, cancelled);
252
+ try {
253
+ const data = await (0, runner_proof_transport_1.waitFor)(() => http.post(`${PATH}/nonce`, { agentId: operation.agentId, bindingDigest: operation.bindingDigest,
254
+ instanceId: operation.instanceId, epoch: operation.epoch, requestDigest: runnerLaunchpadSubscriptionsRequestDigest(operation.request) }, { kind: "side_effecting", operation: "local-agent:launchpad-subscriptions-nonce" }), scope.signal, cancelled);
255
+ const nonce = validateRunnerLaunchpadSubscriptionsNonce(data, operation);
256
+ const signature = await (0, runner_proof_transport_1.signWithin)(() => this.signer(nonce, operation), nonce.expiresAt, scope.signal, invalid, cancelled);
257
+ validateRunnerLaunchpadSubscriptionsNonce(nonce, operation);
258
+ if (!(0, runner_proof_transport_1.base64)(signature, 64))
259
+ invalid();
260
+ const body = operation.request.kind === "get" ? { kind: "get" } : { kind: "set", launchpadIds: [...operation.request.launchpadIds] };
261
+ const response = await (0, runner_proof_transport_1.waitFor)(() => http.post(`${PATH}/query`, { nonceId: nonce.nonceId, signature, epoch: operation.epoch, request: body }, { kind: "side_effecting", operation: "local-agent:launchpad-subscriptions-query" }), scope.signal, cancelled);
262
+ return validateRunnerLaunchpadSubscriptionsResponse(response, operation);
263
+ }
264
+ catch (error) {
265
+ if (scope.signal.aborted)
266
+ throw cancelled();
267
+ if (error instanceof agent_sdk_error_1.AgentSdkError && error.status === 400 && refused) {
268
+ // Machine codes are upper snake case (failure-metadata MACHINE_CODE_RE); the closed reason stays in details.reason.
269
+ throw new agent_sdk_error_1.AgentSdkError({ code: error.code, status: 400, message: "Local-agent launchpad refused",
270
+ details: { layer: "http_ingress", code: refused.toUpperCase(), reason: refused, retryable: false } });
271
+ }
272
+ if (error instanceof agent_sdk_error_1.AgentSdkError)
273
+ throw error;
274
+ return invalid();
275
+ }
276
+ finally {
277
+ clearTimeout(deadline);
278
+ callerSignal?.removeEventListener("abort", forward);
279
+ scope.abort();
280
+ }
281
+ }
282
+ }
283
+ exports.RunnerLaunchpadSubscriptionsClient = RunnerLaunchpadSubscriptionsClient;
284
+ //# sourceMappingURL=launchpad-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"launchpad-client.js","sourceRoot":"","sources":["../../src/local-runner/launchpad-client.ts"],"names":[],"mappings":";;;AA+EA,kEAGC;AAGD,wEAeC;AAGD,kEA6BC;AAUD,8FAGC;AAMD,8FAIC;AACD,4FAGC;AAED,oGAiBC;AAlLD,+DAA0D;AAC1D,kDAA6D;AAE7D,qEAE0D;AAE1D;;;;;mGAKmG;AACtF,QAAA,yBAAyB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAU,CAAC;AAwB1E,kGAAkG;AACrF,QAAA,yBAAyB,GAAG,CAAC,mBAAmB,EAAE,oBAAoB,CAAU,CAAC;AAEjF,QAAA,kCAAkC,GAAG,EAAE,CAAC;AACrD,gEAAgE;AACnD,QAAA,mBAAmB,GAAG,wBAAwB,CAAC;AAE5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AACrD,MAAM,IAAI,GAAG,4CAA4C,CAAC;AAC1D,MAAM,OAAO,GAAG,uDAAgE,CAAC;AACjF,MAAM,eAAe,GAAG,yDAAyD,CAAC;AAClF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AACpC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAC/B,MAAM,SAAS,GAAG,oBAAoB,CAAC;AACvC,MAAM,cAAc,GAAG,+BAA+B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OAAO,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC1G,CAAC;YACD,IAAI,KAAK,YAAY,+BAAa;gBAAE,MAAM,KAAK,CAAC;YAChD,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC;gBAAS,CAAC;YAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YAAC,YAAY,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC;IAC3G,CAAC;CACF;AArDD,gFAqDC"}
@@ -0,0 +1,76 @@
1
+ import type { RunnerRuntimeTarget } from "./runtime-client";
2
+ import { type RunnerProofNonce } from "./runner-proof-transport";
3
+ /** Owner decision of 17 Nov 2026: users are never asked for a Solana RPC. Balchemy provides two independent providers and the
4
+ * runner connects to both DIRECTLY. This client fetches the grant (POST /api/nest/local-agents/rpc-access/{nonce,grant}) with the
5
+ * same runner proof as the other runner routes. The grant holds live provider credentials: this module never logs them, and every
6
+ * error it raises is a fixed message without any URL, token or header value. The runner pins the provider hosts on its own. */
7
+ export type RunnerRpcAccessTarget = RunnerRuntimeTarget;
8
+ export declare const RUNNER_RPC_ACCESS_PROVIDERS: readonly ["alchemy", "helius", "quicknode", "triton", "syndica"];
9
+ export type RunnerRpcAccessProvider = typeof RUNNER_RPC_ACCESS_PROVIDERS[number];
10
+ export interface RunnerRpcBearerAuth {
11
+ readonly kind: "bearer";
12
+ readonly token: string;
13
+ readonly expiresAt: string;
14
+ }
15
+ export interface RunnerRpcHeaderAuth {
16
+ readonly kind: "header";
17
+ readonly name: string;
18
+ readonly value: string;
19
+ }
20
+ export interface RunnerRpcNoneAuth {
21
+ readonly kind: "none";
22
+ }
23
+ export interface RunnerRpcSourceA {
24
+ readonly id: "a";
25
+ readonly provider: RunnerRpcAccessProvider;
26
+ readonly url: string;
27
+ readonly auth: RunnerRpcBearerAuth | RunnerRpcNoneAuth;
28
+ }
29
+ export interface RunnerRpcSourceB {
30
+ readonly id: "b";
31
+ readonly provider: RunnerRpcAccessProvider;
32
+ readonly url: string;
33
+ readonly auth: RunnerRpcHeaderAuth | RunnerRpcNoneAuth;
34
+ }
35
+ /** Version 1, closed. Treat every URL and credential as a secret: never log, print, persist or send them to Balchemy. */
36
+ export interface RunnerRpcAccessGrant {
37
+ readonly version: 1;
38
+ readonly issuedAt: string;
39
+ readonly refreshAfter: string;
40
+ readonly sources: readonly [RunnerRpcSourceA, RunnerRpcSourceB];
41
+ }
42
+ export type RunnerRpcAccessExpectedTarget = RunnerRpcAccessTarget & {
43
+ epoch: number;
44
+ };
45
+ export type RunnerRpcAccessNonce = RunnerProofNonce<"balchemy.local-agent.rpc-access.v1">;
46
+ /** Runner key: sign only runnerRpcAccessNonceMessage after independently checking this context. Base64, 64 bytes. */
47
+ export type RunnerRpcAccessSigner = (nonce: Readonly<RunnerRpcAccessNonce>, expected: RunnerRpcAccessExpectedTarget) => string | Promise<string>;
48
+ export interface RunnerRpcAccessClientConfig extends RunnerRpcAccessTarget {
49
+ apiBaseUrl: string;
50
+ signer: RunnerRpcAccessSigner;
51
+ timeoutMs?: number;
52
+ fetchFn?: typeof fetch;
53
+ }
54
+ /** AgentSdkError.machineCode of a 503 whose reason is `rpc_access_unavailable`: Balchemy has not configured (or misconfigured) the
55
+ * provider credentials. Keep the current grant while it is valid and retry after 5 minutes or more. A 503 without that reason keeps
56
+ * the generic machine code (a transient dependency failure: retry with backoff). */
57
+ export declare const RUNNER_RPC_ACCESS_UNAVAILABLE = "RPC_ACCESS_UNAVAILABLE";
58
+ /** The fixed request digest: SHA256(UTF8(JSON.stringify(["balchemy.local-agent.rpc-access.request.v1", 1]))). */
59
+ export declare function runnerRpcAccessRequestDigest(): string;
60
+ export declare function validateRunnerRpcAccessNonce(value: unknown, expectedTarget: RunnerRpcAccessExpectedTarget, now?: number): RunnerRpcAccessNonce;
61
+ export declare function runnerRpcAccessNonceMessage(value: RunnerRpcAccessNonce, expectedTarget: RunnerRpcAccessExpectedTarget, now?: number): string;
62
+ /** Strict parser of grant version 1: exact keys at every level, https URLs, the closed provider set, two different providers,
63
+ * bearer only on source a, header only on source b, `none` on either. Any other version or shape is refused. Never logs. */
64
+ export declare function validateRunnerRpcAccessGrant(value: unknown, now?: number): RunnerRpcAccessGrant;
65
+ /** Public runner route only (POST /api/nest/local-agents/rpc-access/{nonce,grant}); credential-free, redirect-refusing. */
66
+ export declare class RunnerRpcAccessClient {
67
+ private readonly pinned;
68
+ private readonly signer;
69
+ private readonly timeoutMs;
70
+ private readonly transport;
71
+ constructor(config: RunnerRpcAccessClientConfig);
72
+ /** One signed attempt (nonce, signature, grant). A 503 `rpc_access_unavailable` is an AgentSdkError with machineCode
73
+ * RUNNER_RPC_ACCESS_UNAVAILABLE; a 429 carries `retryAfterSeconds` when the server sent Retry-After. */
74
+ grant(epoch: number, callerSignal?: AbortSignal): Promise<RunnerRpcAccessGrant>;
75
+ }
76
+ //# sourceMappingURL=rpc-access-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-access-client.d.ts","sourceRoot":"","sources":["../../src/local-runner/rpc-access-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAEL,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;+HAG+H;AAC/H,MAAM,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACxD,eAAO,MAAM,2BAA2B,kEAAmE,CAAC;AAC5G,MAAM,MAAM,uBAAuB,GAAG,OAAO,2BAA2B,CAAC,MAAM,CAAC,CAAC;AACjF,MAAM,WAAW,mBAAmB;IAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC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RPC_ACCESS_PROVIDERS = void 0;
4
+ exports.runnerRpcAccessRequestDigest = runnerRpcAccessRequestDigest;
5
+ exports.validateRunnerRpcAccessNonce = validateRunnerRpcAccessNonce;
6
+ exports.runnerRpcAccessNonceMessage = runnerRpcAccessNonceMessage;
7
+ exports.validateRunnerRpcAccessGrant = validateRunnerRpcAccessGrant;
8
+ const agent_sdk_error_1 = require("../errors/agent-sdk-error");
9
+ const redaction_1 = require("../utils/redaction");
10
+ const runner_proof_transport_1 = require("./runner-proof-transport");
11
+ exports.RUNNER_RPC_ACCESS_PROVIDERS = ["alchemy", "helius", "quicknode", "triton", "syndica"];
12
+ const PATH = "/nest/local-agents/rpc-access";
13
+ const PURPOSE = "balchemy.local-agent.rpc-access.v1";
14
+ const REQUEST_PURPOSE = "balchemy.local-agent.rpc-access.request.v1";
15
+ /** Two URLs (up to 2048 bytes each), a JWT and a header token fit well inside this. */
16
+ const MAX_PAYLOAD_BYTES = 12_288;
17
+ const MAX_URL_LENGTH = 2048;
18
+ const MAX_TOKEN_LENGTH = 4096;
19
+ /** A 503 body is read only to find its bounded reason. */
20
+ const MAX_FAILURE_BYTES = 8192;
21
+ /** `details.reason` of the configuration 503 (backend LOCAL_AGENT_RPC_ACCESS_UNAVAILABLE_REASON). */
22
+ const UNAVAILABLE_REASON = "rpc_access_unavailable";
23
+ /** AgentSdkError.machineCode of a 503 whose reason is `rpc_access_unavailable`: Balchemy has not configured (or misconfigured) the
24
+ * provider credentials. Keep the current grant while it is valid and retry after 5 minutes or more. A 503 without that reason keeps
25
+ * the generic machine code (a transient dependency failure: retry with backoff). */
26
+ exports.RUNNER_RPC_ACCESS_UNAVAILABLE = "RPC_ACCESS_UNAVAILABLE";
27
+ /** The grant's refresh point lies at most this far after its issue time (the backend uses 20 minutes). */
28
+ const MAX_REFRESH_WINDOW_MS = 60 * 60_000;
29
+ const JWS = /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/;
30
+ const HEADER_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
31
+ /** Header names the runner's HTTP client owns; a provider token must never override them. */
32
+ const RESERVED_HEADERS = ["authorization", "proxy-authorization", "host", "cookie", "content-type", "content-length",
33
+ "connection", "transfer-encoding", "accept", "accept-encoding", "user-agent", "cache-control"];
34
+ const TOKEN = /^[\x21-\x7e]{8,512}$/;
35
+ const invalid = (0, runner_proof_transport_1.invalidFor)("RPC access");
36
+ const cancelled = (0, runner_proof_transport_1.cancelledFor)("RPC access");
37
+ const exact = (0, runner_proof_transport_1.exactWith)(invalid);
38
+ const timestamp = (0, runner_proof_transport_1.timestampWith)(invalid);
39
+ /** The fixed request digest: SHA256(UTF8(JSON.stringify(["balchemy.local-agent.rpc-access.request.v1", 1]))). */
40
+ function runnerRpcAccessRequestDigest() { return (0, runner_proof_transport_1.sha256)([REQUEST_PURPOSE, 1]); }
41
+ function expected(value) {
42
+ exact(value, [...runner_proof_transport_1.TARGET_KEYS, "epoch"]);
43
+ if (!(0, runner_proof_transport_1.positive)(value.epoch))
44
+ invalid();
45
+ return Object.freeze({ ...(0, runner_proof_transport_1.pinTarget)((0, runner_proof_transport_1.targetPart)(value), invalid), epoch: value.epoch });
46
+ }
47
+ function validateRunnerRpcAccessNonce(value, expectedTarget, now = Date.now()) {
48
+ return (0, runner_proof_transport_1.validateProofNonce)(value, expected(expectedTarget), PURPOSE, "rpc-access/grant", runnerRpcAccessRequestDigest(), now, invalid);
49
+ }
50
+ function runnerRpcAccessNonceMessage(value, expectedTarget, now = Date.now()) {
51
+ return (0, runner_proof_transport_1.proofNonceMessage)(validateRunnerRpcAccessNonce(value, expectedTarget, now));
52
+ }
53
+ /** https only, no userinfo or fragment, no control or space characters; returned exactly as given (never re-serialized). */
54
+ function providerUrl(value) {
55
+ if (typeof value !== "string" || value.length < 9 || value.length > MAX_URL_LENGTH || /[\u0000- \u007f-\u009f]/.test(value))
56
+ invalid();
57
+ let url;
58
+ try {
59
+ url = new URL(value);
60
+ }
61
+ catch {
62
+ return invalid();
63
+ }
64
+ if (url.protocol !== "https:" || url.username || url.password || url.hash || !url.hostname || url.hostname.endsWith("."))
65
+ invalid();
66
+ return value;
67
+ }
68
+ function provider(value) {
69
+ if (typeof value !== "string" || !exports.RUNNER_RPC_ACCESS_PROVIDERS.includes(value))
70
+ invalid();
71
+ return value;
72
+ }
73
+ function auth(value, id, issuedAt) {
74
+ if (!value || typeof value !== "object" || Array.isArray(value))
75
+ invalid();
76
+ const kind = value.kind;
77
+ if (kind === "none") {
78
+ exact(value, ["kind"]);
79
+ return Object.freeze({ kind: "none" });
80
+ }
81
+ if (kind === "bearer" && id === "a") {
82
+ exact(value, ["kind", "token", "expiresAt"]);
83
+ if (typeof value.token !== "string" || value.token.length > MAX_TOKEN_LENGTH || !JWS.test(value.token))
84
+ invalid();
85
+ const expires = timestamp(value.expiresAt);
86
+ if (expires <= issuedAt)
87
+ invalid();
88
+ return Object.freeze({ kind: "bearer", token: value.token, expiresAt: value.expiresAt });
89
+ }
90
+ if (kind === "header" && id === "b") {
91
+ exact(value, ["kind", "name", "value"]);
92
+ if (!(0, runner_proof_transport_1.matches)(value.name, HEADER_NAME) || RESERVED_HEADERS.includes(value.name) || !(0, runner_proof_transport_1.matches)(value.value, TOKEN))
93
+ invalid();
94
+ return Object.freeze({ kind: "header", name: value.name, value: value.value });
95
+ }
96
+ return invalid();
97
+ }
98
+ /** Strict parser of grant version 1: exact keys at every level, https URLs, the closed provider set, two different providers,
99
+ * bearer only on source a, header only on source b, `none` on either. Any other version or shape is refused. Never logs. */
100
+ function validateRunnerRpcAccessGrant(value, now = Date.now()) {
101
+ exact(value, ["version", "issuedAt", "refreshAfter", "sources"]);
102
+ if (value.version !== 1 || !Array.isArray(value.sources) || value.sources.length !== 2 || !Number.isFinite(now))
103
+ invalid();
104
+ const issued = timestamp(value.issuedAt);
105
+ const refresh = timestamp(value.refreshAfter);
106
+ if (refresh <= issued || refresh - issued > MAX_REFRESH_WINDOW_MS || issued > now + 5 * 60_000)
107
+ invalid();
108
+ const parsed = value.sources.map((source, index) => {
109
+ const id = index === 0 ? "a" : "b";
110
+ exact(source, ["id", "provider", "url", "auth"]);
111
+ if (source.id !== id)
112
+ invalid();
113
+ return Object.freeze({ id, provider: provider(source.provider), url: providerUrl(source.url), auth: auth(source.auth, id, issued) });
114
+ });
115
+ const [a, b] = parsed;
116
+ if (a.provider === b.provider)
117
+ invalid();
118
+ if (new URL(a.url).hostname.toLowerCase() === new URL(b.url).hostname.toLowerCase())
119
+ invalid();
120
+ return Object.freeze({ version: 1, issuedAt: value.issuedAt, refreshAfter: value.refreshAfter, sources: Object.freeze([a, b]) });
121
+ }
122
+ /** `details.reason` of a 503 body (canonical `error.details.reason` or legacy `details.reason`) when it is the known one. */
123
+ function unavailableReason(text) {
124
+ let body;
125
+ try {
126
+ body = JSON.parse(text);
127
+ }
128
+ catch {
129
+ return false;
130
+ }
131
+ const reason = (item) => item && typeof item === "object" && !Array.isArray(item)
132
+ ? item.details?.reason : undefined;
133
+ if (!body || typeof body !== "object" || Array.isArray(body))
134
+ return false;
135
+ return (reason(body.error) ?? reason(body)) === UNAVAILABLE_REASON;
136
+ }
137
+ /** Public runner route only (POST /api/nest/local-agents/rpc-access/{nonce,grant}); credential-free, redirect-refusing. */
138
+ class RunnerRpcAccessClient {
139
+ pinned;
140
+ signer;
141
+ timeoutMs;
142
+ transport;
143
+ constructor(config) {
144
+ exact(config, [...runner_proof_transport_1.TARGET_KEYS, "apiBaseUrl", "signer"], ["timeoutMs", "fetchFn"]);
145
+ this.pinned = (0, runner_proof_transport_1.pinTarget)((0, runner_proof_transport_1.targetPart)(config), invalid);
146
+ if (config.apiBaseUrl !== `${this.pinned.frontendOrigin}/api` || typeof config.signer !== "function"
147
+ || (config.fetchFn !== undefined && typeof config.fetchFn !== "function")
148
+ || (config.timeoutMs !== undefined && (!(0, runner_proof_transport_1.positive)(config.timeoutMs) || config.timeoutMs > 30_000)))
149
+ invalid();
150
+ this.signer = config.signer;
151
+ this.timeoutMs = config.timeoutMs ?? 15_000;
152
+ this.transport = config.fetchFn ?? fetch;
153
+ }
154
+ /** One signed attempt (nonce, signature, grant). A 503 `rpc_access_unavailable` is an AgentSdkError with machineCode
155
+ * RUNNER_RPC_ACCESS_UNAVAILABLE; a 429 carries `retryAfterSeconds` when the server sent Retry-After. */
156
+ async grant(epoch, callerSignal) {
157
+ const operation = expected({ ...this.pinned, epoch });
158
+ if (callerSignal !== undefined && !(callerSignal instanceof AbortSignal))
159
+ invalid();
160
+ const scope = new AbortController();
161
+ const forward = () => scope.abort();
162
+ callerSignal?.addEventListener("abort", forward, { once: true });
163
+ if (callerSignal?.aborted)
164
+ scope.abort();
165
+ const deadline = setTimeout(forward, this.timeoutMs);
166
+ // Only a 503 body is inspected, for its closed reason; the bytes are handed on unchanged.
167
+ let notConfigured = false;
168
+ const transport = async (url, init) => {
169
+ const response = await this.transport(url, init);
170
+ if (response.status !== 503)
171
+ return response;
172
+ const text = await (0, redaction_1.readBoundedResponseText)(response, MAX_FAILURE_BYTES, init?.signal ?? undefined);
173
+ notConfigured = unavailableReason(text);
174
+ return new Response(text, { status: response.status, statusText: response.statusText, headers: response.headers });
175
+ };
176
+ const http = (0, runner_proof_transport_1.proofHttpClient)(this.pinned.frontendOrigin, this.timeoutMs, transport, scope.signal, MAX_PAYLOAD_BYTES, invalid, cancelled);
177
+ try {
178
+ const data = await (0, runner_proof_transport_1.waitFor)(() => http.post(`${PATH}/nonce`, { agentId: operation.agentId, bindingDigest: operation.bindingDigest,
179
+ instanceId: operation.instanceId, epoch: operation.epoch, requestDigest: runnerRpcAccessRequestDigest() }, { kind: "side_effecting", operation: "local-agent:rpc-access-nonce" }), scope.signal, cancelled);
180
+ const nonce = validateRunnerRpcAccessNonce(data, operation);
181
+ const signature = await (0, runner_proof_transport_1.signWithin)(() => this.signer(nonce, operation), nonce.expiresAt, scope.signal, invalid, cancelled);
182
+ validateRunnerRpcAccessNonce(nonce, operation);
183
+ if (!(0, runner_proof_transport_1.base64)(signature, 64))
184
+ invalid();
185
+ const response = await (0, runner_proof_transport_1.waitFor)(() => http.post(`${PATH}/grant`, { nonceId: nonce.nonceId, signature, epoch: operation.epoch }, { kind: "side_effecting", operation: "local-agent:rpc-access-grant" }), scope.signal, cancelled);
186
+ return validateRunnerRpcAccessGrant(response);
187
+ }
188
+ catch (error) {
189
+ if (scope.signal.aborted)
190
+ throw cancelled();
191
+ if (error instanceof agent_sdk_error_1.AgentSdkError && error.status === 503 && notConfigured) {
192
+ throw new agent_sdk_error_1.AgentSdkError({ code: error.code, status: 503, message: "Local-agent RPC access is not configured",
193
+ details: { layer: "http_ingress", code: exports.RUNNER_RPC_ACCESS_UNAVAILABLE, retryable: true } });
194
+ }
195
+ if (error instanceof agent_sdk_error_1.AgentSdkError)
196
+ throw error;
197
+ return invalid();
198
+ }
199
+ finally {
200
+ clearTimeout(deadline);
201
+ callerSignal?.removeEventListener("abort", forward);
202
+ scope.abort();
203
+ }
204
+ }
205
+ }
206
+ exports.RunnerRpcAccessClient = RunnerRpcAccessClient;
207
+ //# sourceMappingURL=rpc-access-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-access-client.js","sourceRoot":"","sources":["../../src/local-runner/rpc-access-client.ts"],"names":[],"mappings":";;;AA4DA,oEAA+F;AAM/F,oEAEC;AACD,kEAEC;AAgCD,oEAeC;AAtHD,+DAA0D;AAC1D,kDAA6D;AAE7D,qEAE0D;AAO7C,QAAA,2BAA2B,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAmB5G,MAAM,IAAI,GAAG,+BAA+B,CAAC;AAC7C,MAAM,OAAO,GAAG,oCAA6C,CAAC;AAC9D,MAAM,eAAe,GAAG,4CAA4C,CAAC;AACrE,uFAAuF;AACvF,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,gBAAgB,GAA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