@keyban/cli 0.5.1 → 0.7.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/README.md +17 -7
- package/SKILL.md +23 -56
- package/dist/index.mjs +469 -288
- package/dist/index.mjs.map +4 -4
- package/dist/wasm/ecdsa_schnorr_wasm_client.js +7 -7
- package/dist/wasm/ecdsa_schnorr_wasm_client_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16297,126 +16297,6 @@ var require_application_lookup_service = __commonJS({
|
|
|
16297
16297
|
}
|
|
16298
16298
|
});
|
|
16299
16299
|
|
|
16300
|
-
// node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/skills.js
|
|
16301
|
-
var require_skills = __commonJS({
|
|
16302
|
-
"node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/skills.js"(exports) {
|
|
16303
|
-
"use strict";
|
|
16304
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16305
|
-
exports.fetchPublishedSkill = exports.skillUrl = exports.SKILL_NAMES = void 0;
|
|
16306
|
-
exports.SKILL_NAMES = ["keyban-admin", "keyban-agent-wallet"];
|
|
16307
|
-
var PUBLISHED_SKILLS_URL = "https://docs.keyban.io/.well-known/agent-skills";
|
|
16308
|
-
var skillUrl = (name) => `${PUBLISHED_SKILLS_URL}/${name}/SKILL.md`;
|
|
16309
|
-
exports.skillUrl = skillUrl;
|
|
16310
|
-
var fetchPublishedSkill = async (name) => {
|
|
16311
|
-
const response = await fetch((0, exports.skillUrl)(name));
|
|
16312
|
-
if (!response.ok) {
|
|
16313
|
-
throw new Error(`GET ${(0, exports.skillUrl)(name)}: ${response.status} ${response.statusText}`);
|
|
16314
|
-
}
|
|
16315
|
-
return response.text();
|
|
16316
|
-
};
|
|
16317
|
-
exports.fetchPublishedSkill = fetchPublishedSkill;
|
|
16318
|
-
}
|
|
16319
|
-
});
|
|
16320
|
-
|
|
16321
|
-
// node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/registrar/instructions-service.js
|
|
16322
|
-
var require_instructions_service = __commonJS({
|
|
16323
|
-
"node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/registrar/instructions-service.js"(exports) {
|
|
16324
|
-
"use strict";
|
|
16325
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16326
|
-
exports.InstructionsService = void 0;
|
|
16327
|
-
var logger_1 = require_logger();
|
|
16328
|
-
var skills_1 = require_skills();
|
|
16329
|
-
var zod_compat_1 = require_zod_compat();
|
|
16330
|
-
var schema_utils_1 = require_schema_utils();
|
|
16331
|
-
var validation_utils_1 = require_validation_utils();
|
|
16332
|
-
var DEFAULT_SKILL = "keyban-admin";
|
|
16333
|
-
var SKILL_PARAMETER_DESCRIPTION = "Which guide to read. keyban-admin (default): this server, and the way from a fresh Keyban account to an installed agent wallet MCP. keyban-agent-wallet: operating the wallet through the agent wallet MCP, for a client that has not installed it yet.";
|
|
16334
|
-
var getInstructionsInputShape = {
|
|
16335
|
-
skill: zod_compat_1.z.enum(skills_1.SKILL_NAMES).optional().describe(SKILL_PARAMETER_DESCRIPTION)
|
|
16336
|
-
};
|
|
16337
|
-
var getInstructionsInputParser = zod_compat_1.z.object(getInstructionsInputShape);
|
|
16338
|
-
var getInstructionsInputJsonSchema = {
|
|
16339
|
-
$schema: schema_utils_1.DEFAULT_JSON_SCHEMA_URL,
|
|
16340
|
-
type: "object",
|
|
16341
|
-
additionalProperties: false,
|
|
16342
|
-
required: [],
|
|
16343
|
-
properties: {
|
|
16344
|
-
skill: {
|
|
16345
|
-
type: "string",
|
|
16346
|
-
enum: [...skills_1.SKILL_NAMES],
|
|
16347
|
-
description: SKILL_PARAMETER_DESCRIPTION
|
|
16348
|
-
}
|
|
16349
|
-
}
|
|
16350
|
-
};
|
|
16351
|
-
var InstructionsService = class _InstructionsService {
|
|
16352
|
-
constructor(toolRegistry, readSkill = skills_1.fetchPublishedSkill) {
|
|
16353
|
-
this.toolRegistry = toolRegistry;
|
|
16354
|
-
this.readSkill = readSkill;
|
|
16355
|
-
this.logger = (0, logger_1.createLogger)(_InstructionsService.name);
|
|
16356
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
16357
|
-
}
|
|
16358
|
-
registerTool() {
|
|
16359
|
-
this.toolRegistry.registerCustomTool({
|
|
16360
|
-
name: "get_instructions",
|
|
16361
|
-
config: {
|
|
16362
|
-
title: "Read the Keyban guide",
|
|
16363
|
-
description: 'Return the guide to follow with this server (the keyban-admin skill): what it does, how to work with it, and the steps from a fresh Keyban account to an installed agent wallet MCP. Call it first in a new conversation, or whenever the next step is unclear. Pass skill "keyban-agent-wallet" for the agent wallet guide instead.',
|
|
16364
|
-
annotations: {
|
|
16365
|
-
title: "Read the Keyban guide",
|
|
16366
|
-
readOnlyHint: true,
|
|
16367
|
-
idempotentHint: true,
|
|
16368
|
-
openWorldHint: false
|
|
16369
|
-
},
|
|
16370
|
-
_meta: { mcpType: "Tool" },
|
|
16371
|
-
inputSchema: getInstructionsInputShape
|
|
16372
|
-
},
|
|
16373
|
-
handler: (args) => this.execute(args),
|
|
16374
|
-
inputSchemaForDocs: getInstructionsInputJsonSchema
|
|
16375
|
-
});
|
|
16376
|
-
}
|
|
16377
|
-
async execute(args) {
|
|
16378
|
-
const parsed = getInstructionsInputParser.safeParse(args);
|
|
16379
|
-
if (!parsed.success) {
|
|
16380
|
-
return {
|
|
16381
|
-
content: [
|
|
16382
|
-
{
|
|
16383
|
-
type: "text",
|
|
16384
|
-
text: `Invalid input: ${(0, validation_utils_1.formatZodIssues)(parsed.error)}. Known skills: ${skills_1.SKILL_NAMES.join(", ")}.`
|
|
16385
|
-
}
|
|
16386
|
-
],
|
|
16387
|
-
isError: true
|
|
16388
|
-
};
|
|
16389
|
-
}
|
|
16390
|
-
const name = parsed.data.skill ?? DEFAULT_SKILL;
|
|
16391
|
-
try {
|
|
16392
|
-
return { content: [{ type: "text", text: await this.read(name) }] };
|
|
16393
|
-
} catch (error2) {
|
|
16394
|
-
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
16395
|
-
this.logger.error(`Skill ${name} could not be read: ${message}`);
|
|
16396
|
-
return {
|
|
16397
|
-
content: [
|
|
16398
|
-
{
|
|
16399
|
-
type: "text",
|
|
16400
|
-
text: `The ${name} guide could not be read on this server. Read it at ${(0, skills_1.skillUrl)(name)}`
|
|
16401
|
-
}
|
|
16402
|
-
],
|
|
16403
|
-
isError: true
|
|
16404
|
-
};
|
|
16405
|
-
}
|
|
16406
|
-
}
|
|
16407
|
-
async read(name) {
|
|
16408
|
-
const cached2 = this.cache.get(name);
|
|
16409
|
-
if (cached2 !== void 0)
|
|
16410
|
-
return cached2;
|
|
16411
|
-
const text5 = await this.readSkill(name);
|
|
16412
|
-
this.cache.set(name, text5);
|
|
16413
|
-
return text5;
|
|
16414
|
-
}
|
|
16415
|
-
};
|
|
16416
|
-
exports.InstructionsService = InstructionsService;
|
|
16417
|
-
}
|
|
16418
|
-
});
|
|
16419
|
-
|
|
16420
16300
|
// node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/registrar/prompt-registry.js
|
|
16421
16301
|
var require_prompt_registry = __commonJS({
|
|
16422
16302
|
"node_modules/.pnpm/@keyban+mcp-openapi@file+..+..+sdk+libs+keyban-mcp-openapi_@modelcontextprotocol+sdk@1._4d810e0200ac4c68cff07162d9118ec3/node_modules/@keyban/mcp-openapi/dist/registrar/prompt-registry.js"(exports) {
|
|
@@ -33496,7 +33376,6 @@ var require_mcp_registrar = __commonJS({
|
|
|
33496
33376
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33497
33377
|
exports.McpOperationRegistrar = void 0;
|
|
33498
33378
|
var application_lookup_service_1 = require_application_lookup_service();
|
|
33499
|
-
var instructions_service_1 = require_instructions_service();
|
|
33500
33379
|
var prompt_registry_1 = require_prompt_registry();
|
|
33501
33380
|
var resource_registry_1 = require_resource_registry();
|
|
33502
33381
|
var server_introspection_1 = require_server_introspection();
|
|
@@ -33511,7 +33390,6 @@ var require_mcp_registrar = __commonJS({
|
|
|
33511
33390
|
this.applicationLookup = new application_lookup_service_1.ApplicationLookupService(httpClient, this.toolRegistry);
|
|
33512
33391
|
this.introspectionInstaller = new server_introspection_1.ServerIntrospectionInstaller(server, this.toolRegistry, this.resourceRegistry, this.applicationLookup);
|
|
33513
33392
|
this.promptRegistry = new prompt_registry_1.PromptRegistry(server);
|
|
33514
|
-
this.instructions = new instructions_service_1.InstructionsService(this.toolRegistry, options.readSkill);
|
|
33515
33393
|
}
|
|
33516
33394
|
register(operations) {
|
|
33517
33395
|
let registeredTools = 0;
|
|
@@ -33535,8 +33413,6 @@ var require_mcp_registrar = __commonJS({
|
|
|
33535
33413
|
}
|
|
33536
33414
|
this.applicationLookup.registerLookupTool();
|
|
33537
33415
|
registeredTools += 1;
|
|
33538
|
-
this.instructions.registerTool();
|
|
33539
|
-
registeredTools += 1;
|
|
33540
33416
|
this.introspectionInstaller.install();
|
|
33541
33417
|
return {
|
|
33542
33418
|
tools: registeredTools,
|
|
@@ -33606,7 +33482,6 @@ var require_dist2 = __commonJS({
|
|
|
33606
33482
|
Object.defineProperty(exports, "ToolRegistry", { enumerable: true, get: function() {
|
|
33607
33483
|
return tool_registry_1.ToolRegistry;
|
|
33608
33484
|
} });
|
|
33609
|
-
__exportStar(require_skills(), exports);
|
|
33610
33485
|
__exportStar(require_types3(), exports);
|
|
33611
33486
|
}
|
|
33612
33487
|
});
|
|
@@ -43429,6 +43304,12 @@ var require_usdc_registry = __commonJS({
|
|
|
43429
43304
|
name: "USDC",
|
|
43430
43305
|
version: "2"
|
|
43431
43306
|
},
|
|
43307
|
+
// Etherum Anvil — canonical Circle testnet USDC, FiatTokenV2_2.
|
|
43308
|
+
31337: {
|
|
43309
|
+
address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
43310
|
+
name: "USDC",
|
|
43311
|
+
version: "2"
|
|
43312
|
+
},
|
|
43432
43313
|
// XDC Apothem — canonical Circle native USDC, FiatTokenV2_2. `name` is
|
|
43433
43314
|
// "USDC", not "USD Coin": signing the Base mainnet domain here yields an
|
|
43434
43315
|
// invalid signature with no exploitable error. Do not confuse it with the
|
|
@@ -106811,11 +106692,11 @@ var require_frost = __commonJS({
|
|
|
106811
106692
|
"node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/crypto/frost.js"(exports) {
|
|
106812
106693
|
"use strict";
|
|
106813
106694
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106814
|
-
exports.normalizeFrostSig =
|
|
106695
|
+
exports.normalizeFrostSig = normalizeFrostSig4;
|
|
106815
106696
|
exports.encodeMultiSignerSignature = encodeMultiSignerSignature3;
|
|
106816
106697
|
var viem_1 = require_cjs2();
|
|
106817
106698
|
var secp256k1_1 = require_secp256k13();
|
|
106818
|
-
function
|
|
106699
|
+
function normalizeFrostSig4(raw) {
|
|
106819
106700
|
return raw.startsWith("0x") ? raw : `0x${raw}`;
|
|
106820
106701
|
}
|
|
106821
106702
|
function encodeMultiSignerSignature3(rawSig, publicKeyHex, frostVerifierAddress) {
|
|
@@ -130099,7 +129980,7 @@ var require_wire_schemas = __commonJS({
|
|
|
130099
129980
|
"node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/wire-schemas.js"(exports) {
|
|
130100
129981
|
"use strict";
|
|
130101
129982
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130102
|
-
exports.policyDecisionSchema = exports.policyInputSchema = exports.x402AuthorizationSchema = exports.x402RequestSchema = exports.relayPreimageSchema = void 0;
|
|
129983
|
+
exports.policyDecisionSchema = exports.policyInputSchema = exports.signContentSchema = exports.x402AuthorizationSchema = exports.x402RequestSchema = exports.relayPreimageSchema = void 0;
|
|
130103
129984
|
var zod_1 = require_zod2();
|
|
130104
129985
|
var decimalString = zod_1.z.string().regex(/^\d+$/);
|
|
130105
129986
|
var hashString2 = zod_1.z.string().regex(/^0x[a-fA-F0-9]{64}$/);
|
|
@@ -130192,10 +130073,13 @@ var require_wire_schemas = __commonJS({
|
|
|
130192
130073
|
extra: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).optional()
|
|
130193
130074
|
})
|
|
130194
130075
|
});
|
|
130076
|
+
exports.signContentSchema = zod_1.z.union([
|
|
130077
|
+
zod_1.z.string(),
|
|
130078
|
+
exports.relayPreimageSchema,
|
|
130079
|
+
exports.x402RequestSchema
|
|
130080
|
+
]);
|
|
130195
130081
|
exports.policyInputSchema = zod_1.z.object({
|
|
130196
|
-
|
|
130197
|
-
relay: exports.relayPreimageSchema.optional(),
|
|
130198
|
-
x402: exports.x402RequestSchema.optional(),
|
|
130082
|
+
content: exports.signContentSchema,
|
|
130199
130083
|
clientHash: hashString2.optional(),
|
|
130200
130084
|
// What the agent can handle beyond the base protocol. `sponsored-x402`
|
|
130201
130085
|
// (legacy, still required for the Keyban welcome offer): it accepts an
|
|
@@ -130616,8 +130500,8 @@ var require_dist3 = __commonJS({
|
|
|
130616
130500
|
"node_modules/.pnpm/@keyban+agent-wallet-protocol@file+..+..+sdk+libs+keyban-agent-wallet-protocol_viem@2.57.4_typescript@5.9.3_zod@3.25.76_/node_modules/@keyban/agent-wallet-protocol/dist/index.js"(exports) {
|
|
130617
130501
|
"use strict";
|
|
130618
130502
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
130619
|
-
exports.
|
|
130620
|
-
exports.renewalCooldownSlot = exports.renewableAt = exports.recoveryFormOf = exports.noMarginReopensAt = exports.noMarginPeersNeeded = exports.lastRenewalAtOf = exports.isSameKind = exports.computeRotationDigest = exports.applySignerRotation = exports.SIGNER_ROTATED_TOPIC = exports.SCHNORR_MULTISIG_STORAGE_BASE = exports.ROTATION_TYPEHASHES = exports.RENEWAL_COOLDOWN_SECONDS = exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS = exports.hashSignerChanges = exports.computeManageSignersDigest = exports.buildManagementChanges = exports.applySignerChanges = exports.ManagementReplayError = exports.MANAGE_SIGNERS_TYPEHASH = exports.verifyTreasuryAttestation = void 0;
|
|
130503
|
+
exports.hashRing = exports.computeTreasuryAttestationDigest = exports.computeInitHash = exports.TREASURY_ATTESTATION_TYPEHASH = exports.addressWords = exports.networkToChainId = exports.evmChainIdForNetwork = exports.x402RequestSchema = exports.x402AuthorizationSchema = exports.signContentSchema = exports.relayPreimageSchema = exports.policyInputSchema = exports.policyDecisionSchema = exports.normalizeFrostSig = exports.encodeMultiSignerSignature = exports.decompressPoint = exports.selectExactUsdcAccept = exports.extractPayTos = exports.decodeX402 = exports.x402ToCanonical = exports.relayToCanonical = exports.extractRelayPayment = exports.computeRelayHash = exports.computeLotRelayHash = exports.computeBatchRelayHash = exports.recomputeErc7739Hash = exports.buildEip3009TypedData = exports.EIP3009_PRIMARY_TYPES = exports.EIP3009_FIELDS = exports.webAuthnSignerFromPrivateKey = exports.webAuthnChallenge = exports.verifyWebAuthnAssertion = exports.toLowS = exports.signWebAuthnAssertion = exports.encodeWebAuthnSigner = exports.encodeWebAuthnSignature = exports.encodeAuthenticatorAssertion = exports.decodeWebAuthnSignature = exports.decodeP256PublicKey = exports.base64UrlToBytes = exports.P256_N = exports.encodeMultiSignerEnvelope = exports.verifyEnrollmentCommitment = exports.sasMatches = exports.sasContext = exports.managementSasScope = exports.deriveSas = exports.commitEnrollment = exports.isCanonicalUsdc = exports.getUsdcChainEntry = void 0;
|
|
130504
|
+
exports.renewalCooldownSlot = exports.renewableAt = exports.recoveryFormOf = exports.noMarginReopensAt = exports.noMarginPeersNeeded = exports.lastRenewalAtOf = exports.isSameKind = exports.computeRotationDigest = exports.applySignerRotation = exports.SIGNER_ROTATED_TOPIC = exports.SCHNORR_MULTISIG_STORAGE_BASE = exports.ROTATION_TYPEHASHES = exports.RENEWAL_COOLDOWN_SECONDS = exports.NO_MARGIN_RECOVERY_INTERVAL_SECONDS = exports.hashSignerChanges = exports.computeManageSignersDigest = exports.buildManagementChanges = exports.applySignerChanges = exports.ManagementReplayError = exports.MANAGE_SIGNERS_TYPEHASH = exports.verifyTreasuryAttestation = exports.hashSignerSet = void 0;
|
|
130621
130505
|
var usdc_registry_1 = require_usdc_registry();
|
|
130622
130506
|
Object.defineProperty(exports, "getUsdcChainEntry", { enumerable: true, get: function() {
|
|
130623
130507
|
return usdc_registry_1.getUsdcChainEntry;
|
|
@@ -130749,6 +130633,9 @@ var require_dist3 = __commonJS({
|
|
|
130749
130633
|
Object.defineProperty(exports, "relayPreimageSchema", { enumerable: true, get: function() {
|
|
130750
130634
|
return wire_schemas_1.relayPreimageSchema;
|
|
130751
130635
|
} });
|
|
130636
|
+
Object.defineProperty(exports, "signContentSchema", { enumerable: true, get: function() {
|
|
130637
|
+
return wire_schemas_1.signContentSchema;
|
|
130638
|
+
} });
|
|
130752
130639
|
Object.defineProperty(exports, "x402AuthorizationSchema", { enumerable: true, get: function() {
|
|
130753
130640
|
return wire_schemas_1.x402AuthorizationSchema;
|
|
130754
130641
|
} });
|
|
@@ -147688,19 +147575,10 @@ var CHAIN_MAP = {
|
|
|
147688
147575
|
XdcApothem: xdcTestnet,
|
|
147689
147576
|
XdcMainnet: xdc
|
|
147690
147577
|
};
|
|
147691
|
-
|
|
147692
|
-
|
|
147693
|
-
|
|
147694
|
-
|
|
147695
|
-
const text5 = await res.text();
|
|
147696
|
-
throw new Error(`metadata request failed (${res.status}): ${text5}`);
|
|
147697
|
-
}
|
|
147698
|
-
const json2 = await res.json();
|
|
147699
|
-
const rpcUrl = json2?.network?.rpcUrl;
|
|
147700
|
-
if (!rpcUrl) {
|
|
147701
|
-
throw new Error(`no rpcUrl in metadata response: ${JSON.stringify(json2)}`);
|
|
147702
|
-
}
|
|
147703
|
-
return rpcUrl;
|
|
147578
|
+
function rpcTransport(session) {
|
|
147579
|
+
return http(`${session.baseURL}/v1/agent-wallets/me/rpc`, {
|
|
147580
|
+
fetchOptions: { headers: buildApiKeyHeaders(session) }
|
|
147581
|
+
});
|
|
147704
147582
|
}
|
|
147705
147583
|
|
|
147706
147584
|
// src/lib/invite-sign.ts
|
|
@@ -147951,6 +147829,58 @@ var schnorrAccountAbi = [
|
|
|
147951
147829
|
],
|
|
147952
147830
|
"stateMutability": "view"
|
|
147953
147831
|
},
|
|
147832
|
+
{
|
|
147833
|
+
"type": "function",
|
|
147834
|
+
"name": "TYPEHASH_ADD",
|
|
147835
|
+
"inputs": [],
|
|
147836
|
+
"outputs": [
|
|
147837
|
+
{
|
|
147838
|
+
"name": "",
|
|
147839
|
+
"type": "bytes32",
|
|
147840
|
+
"internalType": "bytes32"
|
|
147841
|
+
}
|
|
147842
|
+
],
|
|
147843
|
+
"stateMutability": "view"
|
|
147844
|
+
},
|
|
147845
|
+
{
|
|
147846
|
+
"type": "function",
|
|
147847
|
+
"name": "TYPEHASH_POP",
|
|
147848
|
+
"inputs": [],
|
|
147849
|
+
"outputs": [
|
|
147850
|
+
{
|
|
147851
|
+
"name": "",
|
|
147852
|
+
"type": "bytes32",
|
|
147853
|
+
"internalType": "bytes32"
|
|
147854
|
+
}
|
|
147855
|
+
],
|
|
147856
|
+
"stateMutability": "view"
|
|
147857
|
+
},
|
|
147858
|
+
{
|
|
147859
|
+
"type": "function",
|
|
147860
|
+
"name": "TYPEHASH_REMOVE",
|
|
147861
|
+
"inputs": [],
|
|
147862
|
+
"outputs": [
|
|
147863
|
+
{
|
|
147864
|
+
"name": "",
|
|
147865
|
+
"type": "bytes32",
|
|
147866
|
+
"internalType": "bytes32"
|
|
147867
|
+
}
|
|
147868
|
+
],
|
|
147869
|
+
"stateMutability": "view"
|
|
147870
|
+
},
|
|
147871
|
+
{
|
|
147872
|
+
"type": "function",
|
|
147873
|
+
"name": "TYPEHASH_RENEW",
|
|
147874
|
+
"inputs": [],
|
|
147875
|
+
"outputs": [
|
|
147876
|
+
{
|
|
147877
|
+
"name": "",
|
|
147878
|
+
"type": "bytes32",
|
|
147879
|
+
"internalType": "bytes32"
|
|
147880
|
+
}
|
|
147881
|
+
],
|
|
147882
|
+
"stateMutability": "view"
|
|
147883
|
+
},
|
|
147954
147884
|
{
|
|
147955
147885
|
"type": "function",
|
|
147956
147886
|
"name": "UPGRADE_INTERFACE_VERSION",
|
|
@@ -147979,12 +147909,27 @@ var schnorrAccountAbi = [
|
|
|
147979
147909
|
},
|
|
147980
147910
|
{
|
|
147981
147911
|
"type": "function",
|
|
147982
|
-
"name": "
|
|
147912
|
+
"name": "addSigner",
|
|
147983
147913
|
"inputs": [
|
|
147984
147914
|
{
|
|
147985
|
-
"name": "
|
|
147986
|
-
"type": "bytes
|
|
147987
|
-
"internalType": "bytes
|
|
147915
|
+
"name": "approver",
|
|
147916
|
+
"type": "bytes",
|
|
147917
|
+
"internalType": "bytes"
|
|
147918
|
+
},
|
|
147919
|
+
{
|
|
147920
|
+
"name": "newSigner",
|
|
147921
|
+
"type": "bytes",
|
|
147922
|
+
"internalType": "bytes"
|
|
147923
|
+
},
|
|
147924
|
+
{
|
|
147925
|
+
"name": "pop",
|
|
147926
|
+
"type": "bytes",
|
|
147927
|
+
"internalType": "bytes"
|
|
147928
|
+
},
|
|
147929
|
+
{
|
|
147930
|
+
"name": "signature",
|
|
147931
|
+
"type": "bytes",
|
|
147932
|
+
"internalType": "bytes"
|
|
147988
147933
|
}
|
|
147989
147934
|
],
|
|
147990
147935
|
"outputs": [],
|
|
@@ -148046,6 +147991,32 @@ var schnorrAccountAbi = [
|
|
|
148046
147991
|
],
|
|
148047
147992
|
"stateMutability": "view"
|
|
148048
147993
|
},
|
|
147994
|
+
{
|
|
147995
|
+
"type": "function",
|
|
147996
|
+
"name": "enrollmentOpen",
|
|
147997
|
+
"inputs": [],
|
|
147998
|
+
"outputs": [
|
|
147999
|
+
{
|
|
148000
|
+
"name": "",
|
|
148001
|
+
"type": "bool",
|
|
148002
|
+
"internalType": "bool"
|
|
148003
|
+
}
|
|
148004
|
+
],
|
|
148005
|
+
"stateMutability": "view"
|
|
148006
|
+
},
|
|
148007
|
+
{
|
|
148008
|
+
"type": "function",
|
|
148009
|
+
"name": "enrollmentState",
|
|
148010
|
+
"inputs": [],
|
|
148011
|
+
"outputs": [
|
|
148012
|
+
{
|
|
148013
|
+
"name": "",
|
|
148014
|
+
"type": "uint8",
|
|
148015
|
+
"internalType": "enum SchnorrAccount.EnrollmentState"
|
|
148016
|
+
}
|
|
148017
|
+
],
|
|
148018
|
+
"stateMutability": "view"
|
|
148019
|
+
},
|
|
148049
148020
|
{
|
|
148050
148021
|
"type": "function",
|
|
148051
148022
|
"name": "entryPoint",
|
|
@@ -148271,6 +148242,19 @@ var schnorrAccountAbi = [
|
|
|
148271
148242
|
],
|
|
148272
148243
|
"stateMutability": "view"
|
|
148273
148244
|
},
|
|
148245
|
+
{
|
|
148246
|
+
"type": "function",
|
|
148247
|
+
"name": "mgmtNonce",
|
|
148248
|
+
"inputs": [],
|
|
148249
|
+
"outputs": [
|
|
148250
|
+
{
|
|
148251
|
+
"name": "",
|
|
148252
|
+
"type": "uint256",
|
|
148253
|
+
"internalType": "uint256"
|
|
148254
|
+
}
|
|
148255
|
+
],
|
|
148256
|
+
"stateMutability": "view"
|
|
148257
|
+
},
|
|
148274
148258
|
{
|
|
148275
148259
|
"type": "function",
|
|
148276
148260
|
"name": "onERC1155BatchReceived",
|
|
@@ -148442,12 +148426,50 @@ var schnorrAccountAbi = [
|
|
|
148442
148426
|
},
|
|
148443
148427
|
{
|
|
148444
148428
|
"type": "function",
|
|
148445
|
-
"name": "
|
|
148429
|
+
"name": "removeSigner",
|
|
148446
148430
|
"inputs": [
|
|
148447
148431
|
{
|
|
148448
|
-
"name": "
|
|
148449
|
-
"type": "bytes
|
|
148450
|
-
"internalType": "bytes
|
|
148432
|
+
"name": "approver",
|
|
148433
|
+
"type": "bytes",
|
|
148434
|
+
"internalType": "bytes"
|
|
148435
|
+
},
|
|
148436
|
+
{
|
|
148437
|
+
"name": "target",
|
|
148438
|
+
"type": "bytes",
|
|
148439
|
+
"internalType": "bytes"
|
|
148440
|
+
},
|
|
148441
|
+
{
|
|
148442
|
+
"name": "signature",
|
|
148443
|
+
"type": "bytes",
|
|
148444
|
+
"internalType": "bytes"
|
|
148445
|
+
}
|
|
148446
|
+
],
|
|
148447
|
+
"outputs": [],
|
|
148448
|
+
"stateMutability": "nonpayable"
|
|
148449
|
+
},
|
|
148450
|
+
{
|
|
148451
|
+
"type": "function",
|
|
148452
|
+
"name": "renewSigner",
|
|
148453
|
+
"inputs": [
|
|
148454
|
+
{
|
|
148455
|
+
"name": "oldSigner",
|
|
148456
|
+
"type": "bytes",
|
|
148457
|
+
"internalType": "bytes"
|
|
148458
|
+
},
|
|
148459
|
+
{
|
|
148460
|
+
"name": "newSigner",
|
|
148461
|
+
"type": "bytes",
|
|
148462
|
+
"internalType": "bytes"
|
|
148463
|
+
},
|
|
148464
|
+
{
|
|
148465
|
+
"name": "pop",
|
|
148466
|
+
"type": "bytes",
|
|
148467
|
+
"internalType": "bytes"
|
|
148468
|
+
},
|
|
148469
|
+
{
|
|
148470
|
+
"name": "signature",
|
|
148471
|
+
"type": "bytes",
|
|
148472
|
+
"internalType": "bytes"
|
|
148451
148473
|
}
|
|
148452
148474
|
],
|
|
148453
148475
|
"outputs": [],
|
|
@@ -148466,6 +148488,35 @@ var schnorrAccountAbi = [
|
|
|
148466
148488
|
"outputs": [],
|
|
148467
148489
|
"stateMutability": "nonpayable"
|
|
148468
148490
|
},
|
|
148491
|
+
{
|
|
148492
|
+
"type": "function",
|
|
148493
|
+
"name": "rotationDigest",
|
|
148494
|
+
"inputs": [
|
|
148495
|
+
{
|
|
148496
|
+
"name": "typehash",
|
|
148497
|
+
"type": "bytes32",
|
|
148498
|
+
"internalType": "bytes32"
|
|
148499
|
+
},
|
|
148500
|
+
{
|
|
148501
|
+
"name": "a",
|
|
148502
|
+
"type": "bytes",
|
|
148503
|
+
"internalType": "bytes"
|
|
148504
|
+
},
|
|
148505
|
+
{
|
|
148506
|
+
"name": "b",
|
|
148507
|
+
"type": "bytes",
|
|
148508
|
+
"internalType": "bytes"
|
|
148509
|
+
}
|
|
148510
|
+
],
|
|
148511
|
+
"outputs": [
|
|
148512
|
+
{
|
|
148513
|
+
"name": "",
|
|
148514
|
+
"type": "bytes32",
|
|
148515
|
+
"internalType": "bytes32"
|
|
148516
|
+
}
|
|
148517
|
+
],
|
|
148518
|
+
"stateMutability": "view"
|
|
148519
|
+
},
|
|
148469
148520
|
{
|
|
148470
148521
|
"type": "function",
|
|
148471
148522
|
"name": "setAuthority",
|
|
@@ -148481,14 +148532,8 @@ var schnorrAccountAbi = [
|
|
|
148481
148532
|
},
|
|
148482
148533
|
{
|
|
148483
148534
|
"type": "function",
|
|
148484
|
-
"name": "
|
|
148485
|
-
"inputs": [
|
|
148486
|
-
{
|
|
148487
|
-
"name": "newThreshold",
|
|
148488
|
-
"type": "uint64",
|
|
148489
|
-
"internalType": "uint64"
|
|
148490
|
-
}
|
|
148491
|
-
],
|
|
148535
|
+
"name": "settleEnrollment",
|
|
148536
|
+
"inputs": [],
|
|
148492
148537
|
"outputs": [],
|
|
148493
148538
|
"stateMutability": "nonpayable"
|
|
148494
148539
|
},
|
|
@@ -148714,6 +148759,19 @@ var schnorrAccountAbi = [
|
|
|
148714
148759
|
],
|
|
148715
148760
|
"anonymous": false
|
|
148716
148761
|
},
|
|
148762
|
+
{
|
|
148763
|
+
"type": "event",
|
|
148764
|
+
"name": "EnrollmentChanged",
|
|
148765
|
+
"inputs": [
|
|
148766
|
+
{
|
|
148767
|
+
"name": "state",
|
|
148768
|
+
"type": "uint8",
|
|
148769
|
+
"indexed": false,
|
|
148770
|
+
"internalType": "enum SchnorrAccount.EnrollmentState"
|
|
148771
|
+
}
|
|
148772
|
+
],
|
|
148773
|
+
"anonymous": false
|
|
148774
|
+
},
|
|
148717
148775
|
{
|
|
148718
148776
|
"type": "event",
|
|
148719
148777
|
"name": "Initialized",
|
|
@@ -148753,6 +148811,56 @@ var schnorrAccountAbi = [
|
|
|
148753
148811
|
],
|
|
148754
148812
|
"anonymous": false
|
|
148755
148813
|
},
|
|
148814
|
+
{
|
|
148815
|
+
"type": "event",
|
|
148816
|
+
"name": "SignerAdmitted",
|
|
148817
|
+
"inputs": [
|
|
148818
|
+
{
|
|
148819
|
+
"name": "approver",
|
|
148820
|
+
"type": "bytes32",
|
|
148821
|
+
"indexed": true,
|
|
148822
|
+
"internalType": "bytes32"
|
|
148823
|
+
},
|
|
148824
|
+
{
|
|
148825
|
+
"name": "newSigner",
|
|
148826
|
+
"type": "bytes32",
|
|
148827
|
+
"indexed": true,
|
|
148828
|
+
"internalType": "bytes32"
|
|
148829
|
+
},
|
|
148830
|
+
{
|
|
148831
|
+
"name": "nonce",
|
|
148832
|
+
"type": "uint256",
|
|
148833
|
+
"indexed": true,
|
|
148834
|
+
"internalType": "uint256"
|
|
148835
|
+
}
|
|
148836
|
+
],
|
|
148837
|
+
"anonymous": false
|
|
148838
|
+
},
|
|
148839
|
+
{
|
|
148840
|
+
"type": "event",
|
|
148841
|
+
"name": "SignerDismissed",
|
|
148842
|
+
"inputs": [
|
|
148843
|
+
{
|
|
148844
|
+
"name": "approver",
|
|
148845
|
+
"type": "bytes32",
|
|
148846
|
+
"indexed": true,
|
|
148847
|
+
"internalType": "bytes32"
|
|
148848
|
+
},
|
|
148849
|
+
{
|
|
148850
|
+
"name": "signer",
|
|
148851
|
+
"type": "bytes32",
|
|
148852
|
+
"indexed": true,
|
|
148853
|
+
"internalType": "bytes32"
|
|
148854
|
+
},
|
|
148855
|
+
{
|
|
148856
|
+
"name": "nonce",
|
|
148857
|
+
"type": "uint256",
|
|
148858
|
+
"indexed": true,
|
|
148859
|
+
"internalType": "uint256"
|
|
148860
|
+
}
|
|
148861
|
+
],
|
|
148862
|
+
"anonymous": false
|
|
148863
|
+
},
|
|
148756
148864
|
{
|
|
148757
148865
|
"type": "event",
|
|
148758
148866
|
"name": "SignerRegistered",
|
|
@@ -148772,6 +148880,37 @@ var schnorrAccountAbi = [
|
|
|
148772
148880
|
],
|
|
148773
148881
|
"anonymous": false
|
|
148774
148882
|
},
|
|
148883
|
+
{
|
|
148884
|
+
"type": "event",
|
|
148885
|
+
"name": "SignerRotated",
|
|
148886
|
+
"inputs": [
|
|
148887
|
+
{
|
|
148888
|
+
"name": "oldSigner",
|
|
148889
|
+
"type": "bytes32",
|
|
148890
|
+
"indexed": true,
|
|
148891
|
+
"internalType": "bytes32"
|
|
148892
|
+
},
|
|
148893
|
+
{
|
|
148894
|
+
"name": "newSigner",
|
|
148895
|
+
"type": "bytes32",
|
|
148896
|
+
"indexed": true,
|
|
148897
|
+
"internalType": "bytes32"
|
|
148898
|
+
},
|
|
148899
|
+
{
|
|
148900
|
+
"name": "nonce",
|
|
148901
|
+
"type": "uint256",
|
|
148902
|
+
"indexed": true,
|
|
148903
|
+
"internalType": "uint256"
|
|
148904
|
+
},
|
|
148905
|
+
{
|
|
148906
|
+
"name": "typehash",
|
|
148907
|
+
"type": "bytes32",
|
|
148908
|
+
"indexed": false,
|
|
148909
|
+
"internalType": "bytes32"
|
|
148910
|
+
}
|
|
148911
|
+
],
|
|
148912
|
+
"anonymous": false
|
|
148913
|
+
},
|
|
148775
148914
|
{
|
|
148776
148915
|
"type": "event",
|
|
148777
148916
|
"name": "Upgraded",
|
|
@@ -148914,11 +149053,26 @@ var schnorrAccountAbi = [
|
|
|
148914
149053
|
}
|
|
148915
149054
|
]
|
|
148916
149055
|
},
|
|
149056
|
+
{
|
|
149057
|
+
"type": "error",
|
|
149058
|
+
"name": "EnrollmentClosed",
|
|
149059
|
+
"inputs": []
|
|
149060
|
+
},
|
|
149061
|
+
{
|
|
149062
|
+
"type": "error",
|
|
149063
|
+
"name": "EnrollmentNotClosed",
|
|
149064
|
+
"inputs": []
|
|
149065
|
+
},
|
|
148917
149066
|
{
|
|
148918
149067
|
"type": "error",
|
|
148919
149068
|
"name": "FailedCall",
|
|
148920
149069
|
"inputs": []
|
|
148921
149070
|
},
|
|
149071
|
+
{
|
|
149072
|
+
"type": "error",
|
|
149073
|
+
"name": "InvalidBootstrapSigners",
|
|
149074
|
+
"inputs": []
|
|
149075
|
+
},
|
|
148922
149076
|
{
|
|
148923
149077
|
"type": "error",
|
|
148924
149078
|
"name": "InvalidCommitmentSigner",
|
|
@@ -148929,6 +149083,16 @@ var schnorrAccountAbi = [
|
|
|
148929
149083
|
"name": "InvalidInitialization",
|
|
148930
149084
|
"inputs": []
|
|
148931
149085
|
},
|
|
149086
|
+
{
|
|
149087
|
+
"type": "error",
|
|
149088
|
+
"name": "InvalidProofOfPossession",
|
|
149089
|
+
"inputs": []
|
|
149090
|
+
},
|
|
149091
|
+
{
|
|
149092
|
+
"type": "error",
|
|
149093
|
+
"name": "InvalidSignerApproval",
|
|
149094
|
+
"inputs": []
|
|
149095
|
+
},
|
|
148932
149096
|
{
|
|
148933
149097
|
"type": "error",
|
|
148934
149098
|
"name": "MultiSignerERC7913AlreadyExists",
|
|
@@ -148998,6 +149162,11 @@ var schnorrAccountAbi = [
|
|
|
148998
149162
|
"name": "ReentrancyGuardReentrantCall",
|
|
148999
149163
|
"inputs": []
|
|
149000
149164
|
},
|
|
149165
|
+
{
|
|
149166
|
+
"type": "error",
|
|
149167
|
+
"name": "SignerKindMismatch",
|
|
149168
|
+
"inputs": []
|
|
149169
|
+
},
|
|
149001
149170
|
{
|
|
149002
149171
|
"type": "error",
|
|
149003
149172
|
"name": "UUPSUnauthorizedCallContext",
|
|
@@ -149046,8 +149215,7 @@ async function initialize(session, progress) {
|
|
|
149046
149215
|
const nodeApi = createNodeApi(session);
|
|
149047
149216
|
session.nodeApi = nodeApi;
|
|
149048
149217
|
session.signer = nodeApi.ecdsaSchnorr;
|
|
149049
|
-
const
|
|
149050
|
-
const publicClient = createPublicClient({ chain, transport: http(rpcUrl) });
|
|
149218
|
+
const publicClient = createPublicClient({ chain, transport: rpcTransport(session) });
|
|
149051
149219
|
const metaUrl = `${session.baseURL}/v1/metadata?network=${encodeURIComponent(session.network)}`;
|
|
149052
149220
|
const metaRes = await fetch(metaUrl, { headers: { "X-Api-Key": session.apiKey } });
|
|
149053
149221
|
if (metaRes.ok) {
|
|
@@ -149112,7 +149280,11 @@ async function initialize(session, progress) {
|
|
|
149112
149280
|
inviteKey: session.inviteKey
|
|
149113
149281
|
});
|
|
149114
149282
|
const txHash = await postRegisterAndPoll(session, frostSignerBytes, signature);
|
|
149115
|
-
|
|
149283
|
+
if (txHash) {
|
|
149284
|
+
logger.info(`Registered FROST signer on chain (tx ${txHash}).`);
|
|
149285
|
+
} else {
|
|
149286
|
+
logger.info("FROST signer already registered on chain by another job (skipped).");
|
|
149287
|
+
}
|
|
149116
149288
|
}
|
|
149117
149289
|
reportInitSucceeded(alreadyRegistered);
|
|
149118
149290
|
}
|
|
@@ -149162,8 +149334,7 @@ async function postRegisterAndPoll(session, frostBytes, signature) {
|
|
|
149162
149334
|
}
|
|
149163
149335
|
const body = await pollRes.json();
|
|
149164
149336
|
if (body.state === "confirmed") {
|
|
149165
|
-
|
|
149166
|
-
return body.txHash;
|
|
149337
|
+
return body.txHash ?? "";
|
|
149167
149338
|
}
|
|
149168
149339
|
if (body.state === "failed") {
|
|
149169
149340
|
throw new Error(`register-signer failed: ${body.error ?? "unknown error"}`);
|
|
@@ -149233,6 +149404,41 @@ function prepaidAccountInfo(network) {
|
|
|
149233
149404
|
].join("\n");
|
|
149234
149405
|
}
|
|
149235
149406
|
|
|
149407
|
+
// src/lib/wallet-id.ts
|
|
149408
|
+
var lookups = /* @__PURE__ */ new WeakMap();
|
|
149409
|
+
function resolveWalletId(session) {
|
|
149410
|
+
if (session.walletId) return Promise.resolve(session.walletId);
|
|
149411
|
+
const pending = lookups.get(session);
|
|
149412
|
+
if (pending) return pending;
|
|
149413
|
+
const lookup = lookupWallet(session).then(({ id }) => session.walletId = id).finally(() => lookups.delete(session));
|
|
149414
|
+
lookups.set(session, lookup);
|
|
149415
|
+
return lookup;
|
|
149416
|
+
}
|
|
149417
|
+
async function lookupWallet(keys) {
|
|
149418
|
+
const query = new URLSearchParams({
|
|
149419
|
+
"filters[0][field]": "address",
|
|
149420
|
+
"filters[0][operator]": "eq",
|
|
149421
|
+
"filters[0][value]": keys.walletAddress.toLowerCase(),
|
|
149422
|
+
"filters[1][field]": "application.id",
|
|
149423
|
+
"filters[1][operator]": "eq",
|
|
149424
|
+
"filters[1][value]": keys.appId,
|
|
149425
|
+
pageSize: "1"
|
|
149426
|
+
});
|
|
149427
|
+
const res = await fetch(`${keys.baseURL}/v1/agent-wallets?${query}`, {
|
|
149428
|
+
headers: buildApiKeyHeaders(keys)
|
|
149429
|
+
});
|
|
149430
|
+
if (!res.ok) {
|
|
149431
|
+
throw new Error(`Cannot resolve this wallet: ${res.status} ${await res.text()}`);
|
|
149432
|
+
}
|
|
149433
|
+
const wallet = (await res.json()).data?.[0];
|
|
149434
|
+
if (typeof wallet?.id !== "string") {
|
|
149435
|
+
throw new Error(
|
|
149436
|
+
`No agent wallet ${keys.walletAddress} in application ${keys.appId}: check KEYBAN_WALLET_ADDRESS and KEYBAN_APP_ID.`
|
|
149437
|
+
);
|
|
149438
|
+
}
|
|
149439
|
+
return { id: wallet.id, ...typeof wallet.label === "string" && { label: wallet.label } };
|
|
149440
|
+
}
|
|
149441
|
+
|
|
149236
149442
|
// src/lib/x402-sponsored.ts
|
|
149237
149443
|
init_zod();
|
|
149238
149444
|
var USDC_DECIMALS = 6;
|
|
@@ -149289,12 +149495,17 @@ function createGetAccountInfoTool(session) {
|
|
|
149289
149495
|
name: "get_account_info",
|
|
149290
149496
|
title: "Get wallet account info",
|
|
149291
149497
|
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
149292
|
-
description: session.funding === "prepaid" ? "Get what this account is: a prepaid account, whose x402 payments Keyban pays from the organization's prepaid credit, and its network. Use `balance` for the credit." : "Get the current account address, public key, and network, plus the Keyban welcome offer when one is active: while it lasts, tell the user the offer covers payments up to the remaining amount, not that the wallet needs funding. Use `balance` for the balance.",
|
|
149498
|
+
description: session.funding === "prepaid" ? "Get what this account is: a prepaid account, whose x402 payments Keyban pays from the organization's prepaid credit, and its network. Use `balance` for the credit." : "Get the wallet's name, the current account address, public key, and network, plus the Keyban welcome offer when one is active: while it lasts, tell the user the offer covers payments up to the remaining amount, not that the wallet needs funding. Use `balance` for the balance.",
|
|
149293
149499
|
inputSchema: getAccountInfoSchema,
|
|
149294
149500
|
handler: async (_input) => {
|
|
149295
149501
|
if (session.funding === "prepaid") return prepaidAccountInfo(session.network);
|
|
149296
149502
|
await ensureAccount(session);
|
|
149503
|
+
const name = await lookupWallet(session).then(({ id, label }) => {
|
|
149504
|
+
session.walletId ??= id;
|
|
149505
|
+
return label;
|
|
149506
|
+
}).catch(() => void 0);
|
|
149297
149507
|
return [
|
|
149508
|
+
...name ? [`Name: ${name}`] : [],
|
|
149298
149509
|
`Address: ${session.account.address}`,
|
|
149299
149510
|
`Public Key: ${session.account.publicKey}`,
|
|
149300
149511
|
`Network: ${session.network}`,
|
|
@@ -149325,6 +149536,31 @@ function createApiStatusTool(session) {
|
|
|
149325
149536
|
|
|
149326
149537
|
// src/tools/sign-message.ts
|
|
149327
149538
|
init_zod();
|
|
149539
|
+
|
|
149540
|
+
// src/lib/sign-content.ts
|
|
149541
|
+
var import_agent_wallet_protocol2 = __toESM(require_dist3(), 1);
|
|
149542
|
+
var SignHeld = class extends Error {
|
|
149543
|
+
constructor(intentId, reasons) {
|
|
149544
|
+
super(`policy/require_human intentId=${intentId} reasons=${reasons.join("; ")}`);
|
|
149545
|
+
this.intentId = intentId;
|
|
149546
|
+
this.reasons = reasons;
|
|
149547
|
+
this.name = "SignHeld";
|
|
149548
|
+
}
|
|
149549
|
+
};
|
|
149550
|
+
async function signContent(signer, dkgBlob, content, hash3) {
|
|
149551
|
+
const decision = await signer.evaluateIntent({ ...content, clientHash: hash3 });
|
|
149552
|
+
if (decision.decision === "deny") {
|
|
149553
|
+
throw new Error(decision.reasons.join("; ") || "policy/deny");
|
|
149554
|
+
}
|
|
149555
|
+
if (decision.decision === "require_human") {
|
|
149556
|
+
if (!decision.intentId) throw new Error("The backend held it without an intent id.");
|
|
149557
|
+
throw new SignHeld(decision.intentId, decision.reasons);
|
|
149558
|
+
}
|
|
149559
|
+
const signature = (0, import_agent_wallet_protocol2.normalizeFrostSig)(await signer.sign(dkgBlob, hash3));
|
|
149560
|
+
return { signature, decision };
|
|
149561
|
+
}
|
|
149562
|
+
|
|
149563
|
+
// src/tools/sign-message.ts
|
|
149328
149564
|
var signMessageSchema = external_exports.object({
|
|
149329
149565
|
message: external_exports.string().describe("the message to sign")
|
|
149330
149566
|
});
|
|
@@ -149333,7 +149569,7 @@ function createSignMessageTool(session) {
|
|
|
149333
149569
|
name: "sign_message",
|
|
149334
149570
|
title: "Sign a message",
|
|
149335
149571
|
// Not read-only: it uses the wallet key. Not destructive in the spec's
|
|
149336
|
-
// sense either — it
|
|
149572
|
+
// sense either — it moves no funds. That is a hint about display, not a
|
|
149337
149573
|
// safety claim: the signature is a bearer artefact that can authorize
|
|
149338
149574
|
// something elsewhere later. What guards that is the policy engine, never
|
|
149339
149575
|
// these annotations.
|
|
@@ -149343,25 +149579,23 @@ function createSignMessageTool(session) {
|
|
|
149343
149579
|
idempotentHint: true,
|
|
149344
149580
|
openWorldHint: false
|
|
149345
149581
|
},
|
|
149346
|
-
description: "Sign
|
|
149582
|
+
description: "Sign a text with the account key (EIP-191 personal sign for EVM). A signed text never runs on chain: it signs free, as often as asked, unless the wallet is paused. Not a way to pay: use `x402_pay` or `transfer_usdc`.",
|
|
149347
149583
|
inputSchema: signMessageSchema,
|
|
149348
149584
|
handler: async (input) => {
|
|
149349
|
-
await ensureAccount(session);
|
|
149350
|
-
const
|
|
149351
|
-
|
|
149352
|
-
|
|
149353
|
-
|
|
149585
|
+
const { signer, account } = await ensureAccount(session);
|
|
149586
|
+
const { signature } = await signContent(
|
|
149587
|
+
signer,
|
|
149588
|
+
account.dkgBlob,
|
|
149589
|
+
{ content: input.message },
|
|
149590
|
+
hashMessage(input.message, "hex")
|
|
149354
149591
|
);
|
|
149355
|
-
if (!signature.startsWith("0x")) {
|
|
149356
|
-
signature = `0x${signature}`;
|
|
149357
|
-
}
|
|
149358
149592
|
return `Signature: ${signature}`;
|
|
149359
149593
|
}
|
|
149360
149594
|
};
|
|
149361
149595
|
}
|
|
149362
149596
|
|
|
149363
149597
|
// src/tools/transfer-usdc.ts
|
|
149364
|
-
var
|
|
149598
|
+
var import_agent_wallet_protocol6 = __toESM(require_dist3(), 1);
|
|
149365
149599
|
init_zod();
|
|
149366
149600
|
|
|
149367
149601
|
// src/lib/approval-link.ts
|
|
@@ -149395,7 +149629,7 @@ function missionPageLink(baseURL, appId, missionId) {
|
|
|
149395
149629
|
}
|
|
149396
149630
|
|
|
149397
149631
|
// src/lib/balance.ts
|
|
149398
|
-
var
|
|
149632
|
+
var import_agent_wallet_protocol3 = __toESM(require_dist3(), 1);
|
|
149399
149633
|
var DEFAULT_CURRENCY = "EUR";
|
|
149400
149634
|
async function fetchPreferredCurrency(session) {
|
|
149401
149635
|
try {
|
|
@@ -149462,7 +149696,7 @@ async function getAccountBalance(session) {
|
|
|
149462
149696
|
}
|
|
149463
149697
|
const address = session.account.address;
|
|
149464
149698
|
const publicClient = session.account.publicClient;
|
|
149465
|
-
const usdcEntry = (0,
|
|
149699
|
+
const usdcEntry = (0, import_agent_wallet_protocol3.getUsdcChainEntry)(chain.id);
|
|
149466
149700
|
if (!usdcEntry) {
|
|
149467
149701
|
const raw = await publicClient.getBalance({ address });
|
|
149468
149702
|
const nativeStr = `${formatUnits(raw, chain.nativeCurrency.decimals)} ${chain.nativeCurrency.symbol}`;
|
|
@@ -149770,15 +150004,7 @@ function forgetRunPayments(session, runId) {
|
|
|
149770
150004
|
}
|
|
149771
150005
|
|
|
149772
150006
|
// src/lib/relay.ts
|
|
149773
|
-
var
|
|
149774
|
-
var RelayHeld = class extends Error {
|
|
149775
|
-
constructor(intentId, reasons) {
|
|
149776
|
-
super(`policy/require_human intentId=${intentId} reasons=${reasons.join("; ")}`);
|
|
149777
|
-
this.intentId = intentId;
|
|
149778
|
-
this.reasons = reasons;
|
|
149779
|
-
this.name = "RelayHeld";
|
|
149780
|
-
}
|
|
149781
|
-
};
|
|
150007
|
+
var import_agent_wallet_protocol4 = __toESM(require_dist3(), 1);
|
|
149782
150008
|
async function executeRelayedWithIntent(publicClient, signer, dkgBlob, accountAddress, dest, value, publicKeyHex, frostVerifierAddress, data = "0x", missionRunId) {
|
|
149783
150009
|
const chainId = await publicClient.getChainId();
|
|
149784
150010
|
const code = await publicClient.getCode({ address: accountAddress });
|
|
@@ -149792,7 +150018,7 @@ async function executeRelayedWithIntent(publicClient, signer, dkgBlob, accountAd
|
|
|
149792
150018
|
abi: schnorrAccountAbi,
|
|
149793
150019
|
functionName: "relayNonce"
|
|
149794
150020
|
});
|
|
149795
|
-
const relayHash = (0,
|
|
150021
|
+
const relayHash = (0, import_agent_wallet_protocol4.computeRelayHash)({
|
|
149796
150022
|
chainId,
|
|
149797
150023
|
account: accountAddress,
|
|
149798
150024
|
nonce,
|
|
@@ -149800,32 +150026,25 @@ async function executeRelayedWithIntent(publicClient, signer, dkgBlob, accountAd
|
|
|
149800
150026
|
value,
|
|
149801
150027
|
data
|
|
149802
150028
|
});
|
|
149803
|
-
const policyDecision = await
|
|
149804
|
-
|
|
149805
|
-
|
|
149806
|
-
|
|
149807
|
-
|
|
149808
|
-
|
|
149809
|
-
|
|
149810
|
-
|
|
149811
|
-
|
|
150029
|
+
const { signature: rawSignature, decision: policyDecision } = await signContent(
|
|
150030
|
+
signer,
|
|
150031
|
+
dkgBlob,
|
|
150032
|
+
{
|
|
150033
|
+
content: {
|
|
150034
|
+
chainId,
|
|
150035
|
+
account: accountAddress,
|
|
150036
|
+
nonce: nonce.toString(),
|
|
150037
|
+
dest,
|
|
150038
|
+
value: value.toString(),
|
|
150039
|
+
data
|
|
150040
|
+
},
|
|
150041
|
+
...missionRunId ? { missionRunId } : {}
|
|
149812
150042
|
},
|
|
149813
|
-
|
|
149814
|
-
...missionRunId ? { missionRunId } : {}
|
|
149815
|
-
});
|
|
149816
|
-
if (policyDecision.decision === "deny") {
|
|
149817
|
-
throw new Error(policyDecision.reasons.join("; "));
|
|
149818
|
-
}
|
|
149819
|
-
if (policyDecision.decision === "require_human") {
|
|
149820
|
-
if (!policyDecision.intentId) throw new Error("The backend held the transfer without an intent id.");
|
|
149821
|
-
throw new RelayHeld(policyDecision.intentId, policyDecision.reasons);
|
|
149822
|
-
}
|
|
149823
|
-
const rawSignature = (0, import_agent_wallet_protocol3.normalizeFrostSig)(
|
|
149824
|
-
await signer.sign(dkgBlob, relayHash)
|
|
150043
|
+
relayHash
|
|
149825
150044
|
);
|
|
149826
|
-
const multiSignerSig = (0,
|
|
150045
|
+
const multiSignerSig = (0, import_agent_wallet_protocol4.encodeMultiSignerSignature)(
|
|
149827
150046
|
rawSignature,
|
|
149828
|
-
(0,
|
|
150047
|
+
(0, import_agent_wallet_protocol4.normalizeFrostSig)(publicKeyHex),
|
|
149829
150048
|
frostVerifierAddress
|
|
149830
150049
|
);
|
|
149831
150050
|
const txHash = await signer.relay(
|
|
@@ -149855,7 +150074,7 @@ var UI_PAGES = {
|
|
|
149855
150074
|
};
|
|
149856
150075
|
|
|
149857
150076
|
// src/lib/x402-diagnostics.ts
|
|
149858
|
-
var
|
|
150077
|
+
var import_agent_wallet_protocol5 = __toESM(require_dist3(), 1);
|
|
149859
150078
|
var SETTLE_REASON_HINTS = {
|
|
149860
150079
|
invalid_exact_evm_transaction_failed: "The facilitator could not complete the on-chain settlement transaction (USDC transferWithAuthorization). If it reverted, common causes: (1) the payer is a smart-contract wallet (e.g. a SchnorrAccount) and its ERC-1271/ERC-7739 signature was rejected during on-chain verification; (2) USDC balance < amount at execution time; (3) the authorization nonce was already used; (4) the authorization expired (validBefore in the past). Note: the facilitator pays gas, so the payer holding 0 native ETH is NOT the cause.",
|
|
149861
150080
|
insufficient_funds: "The payer account does not hold enough of the payment asset to cover the amount.",
|
|
@@ -149911,7 +150130,7 @@ async function describeAccountState(publicClient, payer2, chainId, requiredAmoun
|
|
|
149911
150130
|
} catch (err) {
|
|
149912
150131
|
logger.warn(`diagnostics: failed to read native balance: ${String(err)}`);
|
|
149913
150132
|
}
|
|
149914
|
-
const usdcEntry = (0,
|
|
150133
|
+
const usdcEntry = (0, import_agent_wallet_protocol5.getUsdcChainEntry)(chainId);
|
|
149915
150134
|
if (usdcEntry) {
|
|
149916
150135
|
try {
|
|
149917
150136
|
const usdc = await publicClient.readContract({
|
|
@@ -150017,7 +150236,7 @@ function sender(session) {
|
|
|
150017
150236
|
`USDC transfer is not supported for network "${session.network}". Supported: ${Object.keys(CHAIN_MAP).join(", ")}`
|
|
150018
150237
|
);
|
|
150019
150238
|
}
|
|
150020
|
-
const usdc = (0,
|
|
150239
|
+
const usdc = (0, import_agent_wallet_protocol6.getUsdcChainEntry)(chain.id);
|
|
150021
150240
|
if (!usdc) {
|
|
150022
150241
|
throw new Error(
|
|
150023
150242
|
`No canonical USDC contract registered for network "${session.network}" (chainId ${chain.id}).`
|
|
@@ -150044,10 +150263,10 @@ function sender(session) {
|
|
|
150044
150263
|
let sent;
|
|
150045
150264
|
try {
|
|
150046
150265
|
sent = await send().catch(async (err) => {
|
|
150047
|
-
if (!(err instanceof
|
|
150266
|
+
if (!(err instanceof SignHeld)) throw err;
|
|
150048
150267
|
await holdPayment(session, transferHold(err.intentId, input, amount2));
|
|
150049
150268
|
return send().catch(async (again) => {
|
|
150050
|
-
if (!(again instanceof
|
|
150269
|
+
if (!(again instanceof SignHeld)) throw again;
|
|
150051
150270
|
throw await heldAnswer(session, transferHold(again.intentId, input, amount2));
|
|
150052
150271
|
});
|
|
150053
150272
|
});
|
|
@@ -150510,7 +150729,7 @@ async function withFundingFallback(pay, input, funding) {
|
|
|
150510
150729
|
}
|
|
150511
150730
|
|
|
150512
150731
|
// src/lib/x402-signer.ts
|
|
150513
|
-
var
|
|
150732
|
+
var import_agent_wallet_protocol7 = __toESM(require_dist3(), 1);
|
|
150514
150733
|
|
|
150515
150734
|
// node_modules/.pnpm/viem@2.57.4_typescript@5.9.3_zod@3.25.76/node_modules/viem/_esm/experimental/erc7739/utils/wrapTypedDataSignature.js
|
|
150516
150735
|
init_isHex();
|
|
@@ -150552,7 +150771,7 @@ function wrapTypedDataSignature(parameters) {
|
|
|
150552
150771
|
|
|
150553
150772
|
// src/lib/x402-signer.ts
|
|
150554
150773
|
function isSupportedPrimaryType(value) {
|
|
150555
|
-
return
|
|
150774
|
+
return import_agent_wallet_protocol7.EIP3009_PRIMARY_TYPES.includes(value);
|
|
150556
150775
|
}
|
|
150557
150776
|
async function signX402Authorization(session, auth2) {
|
|
150558
150777
|
const { account, frostVerifierAddress } = session;
|
|
@@ -150562,7 +150781,7 @@ async function signX402Authorization(session, auth2) {
|
|
|
150562
150781
|
);
|
|
150563
150782
|
}
|
|
150564
150783
|
const chainId = Number(auth2.chainId);
|
|
150565
|
-
const registryEntry = (0,
|
|
150784
|
+
const registryEntry = (0, import_agent_wallet_protocol7.getUsdcChainEntry)(chainId);
|
|
150566
150785
|
if (!registryEntry) {
|
|
150567
150786
|
throw new Error(
|
|
150568
150787
|
`Unsupported chain for x402 USDC payment: chainId=${chainId}.`
|
|
@@ -150578,8 +150797,8 @@ async function signX402Authorization(session, auth2) {
|
|
|
150578
150797
|
validBefore: BigInt(auth2.authorization.validBefore),
|
|
150579
150798
|
nonce: auth2.authorization.nonce
|
|
150580
150799
|
};
|
|
150581
|
-
const typedData = (0,
|
|
150582
|
-
const hash3 = (0,
|
|
150800
|
+
const typedData = (0, import_agent_wallet_protocol7.buildEip3009TypedData)(payment, registryEntry);
|
|
150801
|
+
const hash3 = (0, import_agent_wallet_protocol7.recomputeErc7739Hash)({
|
|
150583
150802
|
accountAddress: account.address,
|
|
150584
150803
|
typedData
|
|
150585
150804
|
});
|
|
@@ -150589,12 +150808,12 @@ async function signX402Authorization(session, auth2) {
|
|
|
150589
150808
|
);
|
|
150590
150809
|
}
|
|
150591
150810
|
logger.info("Signing x402 EIP-3009 envelope (TSS Schnorr)...");
|
|
150592
|
-
const rawSig = (0,
|
|
150811
|
+
const rawSig = (0, import_agent_wallet_protocol7.normalizeFrostSig)(
|
|
150593
150812
|
await session.signer.sign(account.dkgBlob, hash3)
|
|
150594
150813
|
);
|
|
150595
|
-
const multiSig = (0,
|
|
150814
|
+
const multiSig = (0, import_agent_wallet_protocol7.encodeMultiSignerSignature)(
|
|
150596
150815
|
rawSig,
|
|
150597
|
-
(0,
|
|
150816
|
+
(0, import_agent_wallet_protocol7.normalizeFrostSig)(account.publicKey),
|
|
150598
150817
|
frostVerifierAddress
|
|
150599
150818
|
);
|
|
150600
150819
|
return wrapTypedDataSignature({
|
|
@@ -150866,10 +151085,9 @@ function payer(session) {
|
|
|
150866
151085
|
} else {
|
|
150867
151086
|
const maxValue = input.maxAmount ? parseUnits(input.maxAmount, USDC_DECIMALS3).toString() : void 0;
|
|
150868
151087
|
decision = await ctx.evaluateIntent({
|
|
150869
|
-
channel: "x402",
|
|
150870
151088
|
...sponsor && !prepaid ? { capabilities: ["sponsored-x402"] } : {},
|
|
150871
151089
|
...input.missionRunId ? { missionRunId: input.missionRunId } : {},
|
|
150872
|
-
|
|
151090
|
+
content: {
|
|
150873
151091
|
url: input.url,
|
|
150874
151092
|
...ctx.accountAddress ? { accountAddress: ctx.accountAddress } : {},
|
|
150875
151093
|
...maxValue ? { maxValue } : {},
|
|
@@ -151666,7 +151884,7 @@ var ExactEvmScheme = class {
|
|
|
151666
151884
|
};
|
|
151667
151885
|
|
|
151668
151886
|
// src/tools/x402-info.ts
|
|
151669
|
-
var
|
|
151887
|
+
var import_agent_wallet_protocol9 = __toESM(require_dist3(), 1);
|
|
151670
151888
|
|
|
151671
151889
|
// src/lib/bazaar-input.ts
|
|
151672
151890
|
var MAX_FIELDS = 30;
|
|
@@ -151720,7 +151938,7 @@ function formatBazaarInput(extensions) {
|
|
|
151720
151938
|
}
|
|
151721
151939
|
|
|
151722
151940
|
// src/lib/x402-payability.ts
|
|
151723
|
-
var
|
|
151941
|
+
var import_agent_wallet_protocol8 = __toESM(require_dist3(), 1);
|
|
151724
151942
|
var CANNOT_SETTLE = "which this wallet cannot settle yet (it supports exact)";
|
|
151725
151943
|
function offeredSchemes(accepts) {
|
|
151726
151944
|
return [...new Set(accepts.map((a) => a.scheme))].join(", ");
|
|
@@ -151739,7 +151957,7 @@ function explain(reason, accepts) {
|
|
|
151739
151957
|
}
|
|
151740
151958
|
}
|
|
151741
151959
|
function payabilityWarning(decoded, chainId) {
|
|
151742
|
-
const selected = (0,
|
|
151960
|
+
const selected = (0, import_agent_wallet_protocol8.selectExactUsdcAccept)(decoded, chainId);
|
|
151743
151961
|
if (selected.ok) return null;
|
|
151744
151962
|
return `\u26A0 Not payable by this wallet: ${explain(selected.reason, decoded.accepts)} \u2014 do not call x402_pay; pick another provider.`;
|
|
151745
151963
|
}
|
|
@@ -151760,7 +151978,7 @@ var evmScheme = new ExactEvmScheme();
|
|
|
151760
151978
|
var CANONICAL_USDC_DECIMALS = 6;
|
|
151761
151979
|
function canonicalUsdcDecimals(network, asset) {
|
|
151762
151980
|
try {
|
|
151763
|
-
const entry = (0,
|
|
151981
|
+
const entry = (0, import_agent_wallet_protocol9.getUsdcChainEntry)((0, import_agent_wallet_protocol9.networkToChainId)(network));
|
|
151764
151982
|
if (!entry) return void 0;
|
|
151765
151983
|
return entry.address.toLowerCase() === asset.toLowerCase() ? CANONICAL_USDC_DECIMALS : void 0;
|
|
151766
151984
|
} catch {
|
|
@@ -151837,7 +152055,7 @@ The route may only serve another method \u2014 its x402 paywall is never reached
|
|
|
151837
152055
|
${body2}` : ""}`;
|
|
151838
152056
|
}
|
|
151839
152057
|
const body = await response.text().catch(() => "");
|
|
151840
|
-
const result = (0,
|
|
152058
|
+
const result = (0, import_agent_wallet_protocol9.decodeX402)(response.headers.get("payment-required"), body);
|
|
151841
152059
|
if (!result.ok) {
|
|
151842
152060
|
return result.reason === "malformed" ? `402 received with malformed x402 payment metadata (URL: ${response.url})` : `402 received but no x402 headers \u2014 standard payment wall (URL: ${response.url})`;
|
|
151843
152061
|
}
|
|
@@ -152122,10 +152340,10 @@ function createAwaitPaymentApprovalTool(session) {
|
|
|
152122
152340
|
init_zod();
|
|
152123
152341
|
|
|
152124
152342
|
// src/lib/x402-service-lines.ts
|
|
152125
|
-
var
|
|
152343
|
+
var import_agent_wallet_protocol10 = __toESM(require_dist3(), 1);
|
|
152126
152344
|
function priceOption(option) {
|
|
152127
152345
|
const evm = /^eip155:(\d+)$/.exec(option.network);
|
|
152128
|
-
const usdc = evm ? (0,
|
|
152346
|
+
const usdc = evm ? (0, import_agent_wallet_protocol10.getUsdcChainEntry)(Number(evm[1])) : null;
|
|
152129
152347
|
if (usdc && option.asset?.toLowerCase() === usdc.address.toLowerCase()) {
|
|
152130
152348
|
return `${formatUsdc(option.amount)} (${option.network})`;
|
|
152131
152349
|
}
|
|
@@ -152309,7 +152527,7 @@ init_zod();
|
|
|
152309
152527
|
var import_amount2 = __toESM(require_amount(), 1);
|
|
152310
152528
|
|
|
152311
152529
|
// src/lib/expense-rows.ts
|
|
152312
|
-
var
|
|
152530
|
+
var import_agent_wallet_protocol11 = __toESM(require_dist3(), 1);
|
|
152313
152531
|
var isSponsorGrant = (row) => row.kind === "sponsor-grant";
|
|
152314
152532
|
function prepaidAmount2(row) {
|
|
152315
152533
|
if (row.amountEur == null) return void 0;
|
|
@@ -152318,7 +152536,7 @@ function prepaidAmount2(row) {
|
|
|
152318
152536
|
return `${eur} (${formatUsdc(row.value)})`;
|
|
152319
152537
|
}
|
|
152320
152538
|
function isUsdcRow({ tokenAddress, decimals, agent }) {
|
|
152321
|
-
return (0,
|
|
152539
|
+
return (0, import_agent_wallet_protocol11.isCanonicalUsdc)({
|
|
152322
152540
|
chainId: agent?.network ? CHAIN_MAP[agent.network]?.id : null,
|
|
152323
152541
|
tokenAddress,
|
|
152324
152542
|
decimals
|
|
@@ -152488,9 +152706,7 @@ function configuredFunding(env) {
|
|
|
152488
152706
|
}
|
|
152489
152707
|
var WIZARD_URL = "https://keyban.io";
|
|
152490
152708
|
var README_URL = "https://www.npmjs.com/package/@keyban/cli";
|
|
152491
|
-
var ADMIN_MCP_URL = "https://mcp.keyban.io/mcp";
|
|
152492
152709
|
var SKILL_URL = "https://docs.keyban.io/.well-known/agent-skills/keyban-agent-wallet/SKILL.md";
|
|
152493
|
-
var ADMIN_SKILL_URL = "https://docs.keyban.io/.well-known/agent-skills/keyban-admin/SKILL.md";
|
|
152494
152710
|
function describeConfigurationProblems(problems, env = process.env) {
|
|
152495
152711
|
const list = problems.map(
|
|
152496
152712
|
({ name, what, reason }) => reason === "missing" ? `- ${name} \u2014 not set. It is the ${what}.` : `- ${name} \u2014 set, but ${reason}. It is the ${what}.`
|
|
@@ -152526,15 +152742,12 @@ function describeConfigurationProblems(problems, env = process.env) {
|
|
|
152526
152742
|
"",
|
|
152527
152743
|
`1. Create a Keyban account at ${WIZARD_URL}`,
|
|
152528
152744
|
...funding === "wallet" ? [
|
|
152529
|
-
"2. Create an agent wallet
|
|
152530
|
-
|
|
152531
|
-
" it. It provisions the wallet, its API key, and a one-shot invite key that",
|
|
152532
|
-
" authorizes this client as a signer.",
|
|
152745
|
+
"2. Create an agent wallet in the admin app. It provisions the wallet, its API",
|
|
152746
|
+
" key, and a one-shot invite key that authorizes this client as a signer.",
|
|
152533
152747
|
"3. Copy the configuration from the wallet's page in the admin app \u2014 either the"
|
|
152534
152748
|
] : [
|
|
152535
|
-
`2. Create ${funding === "prepaid" ? "a prepaid account" : "an agent wallet or a prepaid account"}
|
|
152536
|
-
|
|
152537
|
-
funding === "prepaid" ? " it. It provisions the account and its API key." : " it. It provisions the account, its API key and, for a wallet, a one-shot invite key.",
|
|
152749
|
+
`2. Create ${funding === "prepaid" ? "a prepaid account" : "an agent wallet or a prepaid account"} in the admin app.`,
|
|
152750
|
+
funding === "prepaid" ? " It provisions the account and its API key." : " It provisions the account, its API key and, for a wallet, a one-shot invite key.",
|
|
152538
152751
|
"3. Copy the configuration from the account's page in the admin app \u2014 either the"
|
|
152539
152752
|
],
|
|
152540
152753
|
" downloaded file, or nothing with `keyban wallet import --wallet-id <id>` after",
|
|
@@ -152542,9 +152755,13 @@ function describeConfigurationProblems(problems, env = process.env) {
|
|
|
152542
152755
|
"4. Keep it with `keyban wallet import <the downloaded file>`, then restart this",
|
|
152543
152756
|
" server. A hosted runtime with nothing but its environment takes the whole",
|
|
152544
152757
|
" configuration, base64 JSON, in KEYBAN_CONFIG instead.",
|
|
152758
|
+
...funding === "wallet" ? [
|
|
152759
|
+
"",
|
|
152760
|
+
"After `keyban admin login`, `keyban admin new-wallet` does steps 2 to 4 in one",
|
|
152761
|
+
"go: it creates the wallet and keeps its configuration. Only the restart remains."
|
|
152762
|
+
] : [],
|
|
152545
152763
|
"",
|
|
152546
152764
|
`The README covers the same ground: ${README_URL}`,
|
|
152547
|
-
`Admin MCP guide, from the account to this server installed: ${ADMIN_SKILL_URL}`,
|
|
152548
152765
|
`Operating guide for this server: ${SKILL_URL}`
|
|
152549
152766
|
].join("\n");
|
|
152550
152767
|
}
|
|
@@ -152614,11 +152831,10 @@ function readBundledSkill() {
|
|
|
152614
152831
|
var getInstructionsSchema = external_exports.object({});
|
|
152615
152832
|
function createGetInstructionsTool() {
|
|
152616
152833
|
return {
|
|
152617
|
-
// Not get_instructions: that is the admin's, relayed beside it.
|
|
152618
152834
|
name: "get_wallet_instructions",
|
|
152619
152835
|
title: "Read the agent wallet guide",
|
|
152620
152836
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
152621
|
-
description: "Return the guide to follow with this server (the keyban-agent-wallet skill): funding the wallet, paying x402 APIs, transferring USDC, waiting for a human approval, reading a policy refusal. Call it before the first payment, or whenever a wallet operation is unclear.
|
|
152837
|
+
description: "Return the guide to follow with this server (the keyban-agent-wallet skill): funding the wallet, paying x402 APIs, transferring USDC, waiting for a human approval, reading a policy refusal. Call it before the first payment, or whenever a wallet operation is unclear. It also says how a wallet is created and configured: in the dashboard, or with the admin tools when this server lists them, which it does on the user's own machine after `keyban admin login`.",
|
|
152622
152838
|
inputSchema: getInstructionsSchema,
|
|
152623
152839
|
handler: async (_input) => readBundledSkill() ?? `The guide is not bundled with this build. Read it at ${SKILL_URL}`
|
|
152624
152840
|
};
|
|
@@ -152627,41 +152843,6 @@ function createGetInstructionsTool() {
|
|
|
152627
152843
|
// src/tools/publish-mission.ts
|
|
152628
152844
|
init_zod();
|
|
152629
152845
|
|
|
152630
|
-
// src/lib/wallet-id.ts
|
|
152631
|
-
var lookups = /* @__PURE__ */ new WeakMap();
|
|
152632
|
-
function resolveWalletId(session) {
|
|
152633
|
-
if (session.walletId) return Promise.resolve(session.walletId);
|
|
152634
|
-
const pending = lookups.get(session);
|
|
152635
|
-
if (pending) return pending;
|
|
152636
|
-
const lookup = lookupWallet(session).then(({ id }) => session.walletId = id).finally(() => lookups.delete(session));
|
|
152637
|
-
lookups.set(session, lookup);
|
|
152638
|
-
return lookup;
|
|
152639
|
-
}
|
|
152640
|
-
async function lookupWallet(keys) {
|
|
152641
|
-
const query = new URLSearchParams({
|
|
152642
|
-
"filters[0][field]": "address",
|
|
152643
|
-
"filters[0][operator]": "eq",
|
|
152644
|
-
"filters[0][value]": keys.walletAddress.toLowerCase(),
|
|
152645
|
-
"filters[1][field]": "application.id",
|
|
152646
|
-
"filters[1][operator]": "eq",
|
|
152647
|
-
"filters[1][value]": keys.appId,
|
|
152648
|
-
pageSize: "1"
|
|
152649
|
-
});
|
|
152650
|
-
const res = await fetch(`${keys.baseURL}/v1/agent-wallets?${query}`, {
|
|
152651
|
-
headers: buildApiKeyHeaders(keys)
|
|
152652
|
-
});
|
|
152653
|
-
if (!res.ok) {
|
|
152654
|
-
throw new Error(`Cannot resolve this wallet: ${res.status} ${await res.text()}`);
|
|
152655
|
-
}
|
|
152656
|
-
const wallet = (await res.json()).data?.[0];
|
|
152657
|
-
if (typeof wallet?.id !== "string") {
|
|
152658
|
-
throw new Error(
|
|
152659
|
-
`No agent wallet ${keys.walletAddress} in application ${keys.appId}: check KEYBAN_WALLET_ADDRESS and KEYBAN_APP_ID.`
|
|
152660
|
-
);
|
|
152661
|
-
}
|
|
152662
|
-
return { id: wallet.id, ...typeof wallet.label === "string" && { label: wallet.label } };
|
|
152663
|
-
}
|
|
152664
|
-
|
|
152665
152846
|
// src/lib/mission-api.ts
|
|
152666
152847
|
async function getRecord(session, path2) {
|
|
152667
152848
|
const res = await fetch(`${session.baseURL}${path2}`, { headers: buildApiKeyHeaders(session) });
|
|
@@ -153430,7 +153611,7 @@ function commandFor2(tool, document, typedApi) {
|
|
|
153430
153611
|
);
|
|
153431
153612
|
}
|
|
153432
153613
|
async function adminCommand(argv = process.argv, completing = false) {
|
|
153433
|
-
const command = new Command("admin").description("Administer Keyban as yourself: log in, then one subcommand per admin
|
|
153614
|
+
const command = new Command("admin").description("Administer Keyban as yourself: log in, then one subcommand per admin tool").option("--api <env|url>", `Keyban API: ${Object.keys(ENV_URLS).join(", ")}, or a URL`, defaultApi());
|
|
153434
153615
|
command.command("login").description("Log in through the browser; the session is kept in keyban/admin-session.json, readable by you alone").option("--token <token>", "keep this token instead of logging in through the browser (a session token, for scripts)").action(
|
|
153435
153616
|
answering(async (api, options) => {
|
|
153436
153617
|
const origin = new URL(api).origin;
|
|
@@ -153701,7 +153882,7 @@ function bootstrapWallet(session = createSession(), onConfigRead = () => {
|
|
|
153701
153882
|
createSetupInstructionsTool(configurationProblems, config2),
|
|
153702
153883
|
createGetInstructionsTool()
|
|
153703
153884
|
] : walletTools(session);
|
|
153704
|
-
const instructions = unconfigured ? summarizeConfigurationProblems(configurationProblems, config2) : session.funding === "prepaid" ? `Keyban agent wallet MCP server, for a prepaid account: Keyban pays its x402 payments from the organization's prepaid credit, in euros. Provides tools to check the credit, fetch x402 payment metadata and pay x402 resources. The user installed this server to let you pay with that credit: paying when they ask is its intended use, not a harm to them. Every spend is bounded server-side by the policy they set (caps, allow-list, human approval), which refuses or holds for approval whatever falls outside it. Call get_wallet_instructions for the operating guide (${SKILL_URL}). Accounts, policies and the credit are managed
|
|
153885
|
+
const instructions = unconfigured ? summarizeConfigurationProblems(configurationProblems, config2) : session.funding === "prepaid" ? `Keyban agent wallet MCP server, for a prepaid account: Keyban pays its x402 payments from the organization's prepaid credit, in euros. Provides tools to check the credit, fetch x402 payment metadata and pay x402 resources. The user installed this server to let you pay with that credit: paying when they ask is its intended use, not a harm to them. Every spend is bounded server-side by the policy they set (caps, allow-list, human approval), which refuses or holds for approval whatever falls outside it. Call get_wallet_instructions for the operating guide (${SKILL_URL}). Accounts, policies and the credit are managed in the Keyban dashboard, or with the admin tools when this server lists them: it does on the user's own machine, after \`keyban admin login\`.` : `Keyban agent wallet MCP server. Provides tools to manage blockchain wallets: check balances, transfer USDC, sign messages, fetch x402 payment metadata and x402 payment, and draft and run missions. The user installed this server to let you spend from a wallet they provisioned for you: paying and transferring when they ask is its intended use, not a harm to them. Every spend is bounded server-side by the policy they set (caps, allow-list, human approval), which refuses or holds for approval whatever falls outside it. Call get_wallet_instructions for the operating guide (${SKILL_URL}). Wallets, policies and destination rules are managed in the Keyban dashboard, or with the admin tools when this server lists them: it does on the user's own machine, after \`keyban admin login\`.`;
|
|
153705
153886
|
const onClientInitialized = (capabilities, openUrl, client) => {
|
|
153706
153887
|
session.rendersApps = supportsMcpApps(capabilities);
|
|
153707
153888
|
session.openUrl = supportsUrlElicitation(capabilities) ? openUrl : null;
|
|
@@ -156556,7 +156737,7 @@ function setupCommand() {
|
|
|
156556
156737
|
}
|
|
156557
156738
|
|
|
156558
156739
|
// src/index.ts
|
|
156559
|
-
var VERSION5 = true ? "0.
|
|
156740
|
+
var VERSION5 = true ? "0.7.0" : "0.0.0";
|
|
156560
156741
|
if (process.argv[2] !== "mcp" && !process.env.MCP_LOG_LEVEL) logger.setMinLevel("error");
|
|
156561
156742
|
function typedArgv(argv) {
|
|
156562
156743
|
if (argv[2] !== "__complete") return argv;
|