@capxul/mcp 1.0.0-alpha.18 → 1.0.0-alpha.19
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.
|
@@ -41,6 +41,22 @@ function alchemyUrl(chainId) {
|
|
|
41
41
|
default: throw Errors.invalidInput("chainId", `unsupported chainId ${String(chainId)}`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
function isValidJsonRpcEnvelope(value) {
|
|
48
|
+
if (!isRecord(value) || value.jsonrpc !== "2.0" || value.id !== 1) return false;
|
|
49
|
+
return Object.hasOwn(value, "result") !== Object.hasOwn(value, "error");
|
|
50
|
+
}
|
|
51
|
+
function isValidJsonRpcError(value) {
|
|
52
|
+
return isRecord(value) && typeof value.code === "number" && Number.isInteger(value.code) && typeof value.message === "string";
|
|
53
|
+
}
|
|
54
|
+
var DefinitiveAlchemyJsonRpcRejection = class extends Error {
|
|
55
|
+
constructor() {
|
|
56
|
+
super("Alchemy returned an explicit JSON-RPC rejection");
|
|
57
|
+
this.name = "DefinitiveAlchemyJsonRpcRejection";
|
|
58
|
+
}
|
|
59
|
+
};
|
|
44
60
|
async function alchemyRpc(chainId, method, params) {
|
|
45
61
|
const url = alchemyUrl(chainId);
|
|
46
62
|
const res = await fetch(url, {
|
|
@@ -63,7 +79,11 @@ async function alchemyRpc(chainId, method, params) {
|
|
|
63
79
|
} catch (cause) {
|
|
64
80
|
throw Errors.providerError("alchemy", `${method} json`, cause);
|
|
65
81
|
}
|
|
66
|
-
if (json
|
|
82
|
+
if (!isValidJsonRpcEnvelope(json)) throw Errors.providerError("alchemy", method, "malformed JSON-RPC envelope");
|
|
83
|
+
if (json.error !== void 0) {
|
|
84
|
+
if (!isValidJsonRpcError(json.error)) throw Errors.providerError("alchemy", method, "malformed JSON-RPC error");
|
|
85
|
+
throw Errors.providerError("alchemy", method, method === "eth_sendUserOperation" ? new DefinitiveAlchemyJsonRpcRejection() : json.error.message);
|
|
86
|
+
}
|
|
67
87
|
if (json.result === void 0) throw Errors.providerError("alchemy", method, "missing result");
|
|
68
88
|
return json.result;
|
|
69
89
|
}
|
package/dist/main.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { $ as buildCapxulCommitmentRedirectCallData, A as SAFE_MODULE_SETUP, C as BASE_SEPOLIA_CHAIN_ID, D as MULTI_SEND, F as deriveCapxulSafeAddress, H as safe4337StubSignature, K as ERC20_APPROVE_ABI, M as SAFE_PROXY_FACTORY, N as buildSafeMultiSendExecTransactionCall, O as SAFE_4337_MODULE, P as computeCapxulSafeSaltNonce, Q as buildCapxulCommitmentClaimCallData, R as packSafe4337OwnerSignature, S as normalizeBindingEmail, U as CAPXUL_PAYMENTS_ADDRESS, V as safe4337SafeOpDigest, Z as buildCapxulCommitmentCancelCallData, a as computeOrgRolesModuleAddress, at as buildOrgRoleSpendPersonalCallData, ct as isExactTransferTokenAllowed, dt as Errors, et as buildCapxulCreateCommitmentPersonalCallData, g as deriveCapxulOrgAddress, h as computeCapxulOrgSaltNonce, i as buildOrgRolesDeployCalls, it as buildOrgPersonalMultiCallData, k as SAFE_L2_SINGLETON, l as orgRoleKeyForLabel, lt as decodeConvexError, m as buildCapxulOrgInitializer, nt as buildCapxulPaymentsRoleBatchSpendCall, pt as isCapxulError, r as buildOrgRoleAssignmentCall, s as compileOrgRoleDefinitions, st as USDX_ADDRESS_BASE_SEPOLIA, tt as buildCapxulPaymentsPersonalSendCallData, u as orgRoleTemplateDefinitions, ut as CapxulError, y as DIRECT_BASE_ROUTE } from "./src-DM3bg5NZ.mjs";
|
|
3
|
-
import { a as fetchEntryPointNonce, c as fetchUserOperationReceipt, d as sendUserOperation, i as fetchCommitmentState, l as getPaymasterData, n as estimateUserOperationGas, o as fetchErc20Balance, s as fetchUserOperationFees, u as getPaymasterStubData } from "./alchemy-rpc-
|
|
3
|
+
import { a as fetchEntryPointNonce, c as fetchUserOperationReceipt, d as sendUserOperation, i as fetchCommitmentState, l as getPaymasterData, n as estimateUserOperationGas, o as fetchErc20Balance, s as fetchUserOperationFees, u as getPaymasterStubData } from "./alchemy-rpc-BORldDgR.mjs";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { createHash, randomBytes } from "node:crypto";
|
|
6
6
|
import { createServer } from "node:http";
|
|
@@ -232,7 +232,7 @@ function normalizeEmail(email) {
|
|
|
232
232
|
}
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region package.json
|
|
235
|
-
var version$1 = "1.0.0-alpha.
|
|
235
|
+
var version$1 = "1.0.0-alpha.19";
|
|
236
236
|
//#endregion
|
|
237
237
|
//#region src/tool-result.ts
|
|
238
238
|
function okResult(structured) {
|
|
@@ -5041,10 +5041,10 @@ function makeAccountMethods(deps) {
|
|
|
5041
5041
|
value: await lane.retryProvisioning()
|
|
5042
5042
|
};
|
|
5043
5043
|
};
|
|
5044
|
-
const reportAndReturn = (error) => {
|
|
5044
|
+
const reportAndReturn = (error, operation = "getLifecycle") => {
|
|
5045
5045
|
if (deps.telemetry) captureExceptionSync(deps.telemetry, error, {
|
|
5046
5046
|
layer: "account",
|
|
5047
|
-
operation
|
|
5047
|
+
operation
|
|
5048
5048
|
});
|
|
5049
5049
|
return {
|
|
5050
5050
|
ok: false,
|
|
@@ -5075,6 +5075,12 @@ function makeAccountMethods(deps) {
|
|
|
5075
5075
|
};
|
|
5076
5076
|
const getLifecycle = () => resolveLifecycle();
|
|
5077
5077
|
const retrySetup = async () => {
|
|
5078
|
+
const resetSession = deps.signer?.resetSession;
|
|
5079
|
+
if (typeof resetSession === "function") try {
|
|
5080
|
+
resetSession.call(deps.signer);
|
|
5081
|
+
} catch (cause) {
|
|
5082
|
+
return reportAndReturn(cause instanceof CapxulError ? cause : Errors.providerError("openfort", "resetSession", cause, { failure_mode: "unknown" }), "retrySetup");
|
|
5083
|
+
}
|
|
5078
5084
|
await lane.retryProvisioning();
|
|
5079
5085
|
return resolveLifecycle();
|
|
5080
5086
|
};
|
|
@@ -5268,7 +5274,7 @@ async function recoverRawDigestSigner(input) {
|
|
|
5268
5274
|
}
|
|
5269
5275
|
//#endregion
|
|
5270
5276
|
//#region ../../packages/sdk/package.json
|
|
5271
|
-
var version = "1.0.0-alpha.
|
|
5277
|
+
var version = "1.0.0-alpha.19";
|
|
5272
5278
|
//#endregion
|
|
5273
5279
|
//#region ../../packages/sdk/src/ports/auth-client.ts
|
|
5274
5280
|
var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
|
|
@@ -6585,24 +6591,6 @@ const envFields = {
|
|
|
6585
6591
|
"required": false,
|
|
6586
6592
|
"example": "development"
|
|
6587
6593
|
},
|
|
6588
|
-
AUTH_DEV_OTP: {
|
|
6589
|
-
"runtime": "server",
|
|
6590
|
-
"kind": "nonempty",
|
|
6591
|
-
"required": false,
|
|
6592
|
-
"example": "000000"
|
|
6593
|
-
},
|
|
6594
|
-
SENTRY_DSN: {
|
|
6595
|
-
"runtime": "server",
|
|
6596
|
-
"kind": "url",
|
|
6597
|
-
"required": false,
|
|
6598
|
-
"example": "https://public@example.ingest.sentry.io/1"
|
|
6599
|
-
},
|
|
6600
|
-
POSTHOG_API_KEY: {
|
|
6601
|
-
"runtime": "server",
|
|
6602
|
-
"kind": "nonempty",
|
|
6603
|
-
"required": false,
|
|
6604
|
-
"example": "phx_test"
|
|
6605
|
-
},
|
|
6606
6594
|
POSTHOG_PROJECT_TOKEN: {
|
|
6607
6595
|
"runtime": "server",
|
|
6608
6596
|
"kind": "nonempty",
|
|
@@ -6633,24 +6621,12 @@ const envFields = {
|
|
|
6633
6621
|
"required": false,
|
|
6634
6622
|
"example": "12345"
|
|
6635
6623
|
},
|
|
6636
|
-
POSTHOG_ENV_ID: {
|
|
6637
|
-
"runtime": "server",
|
|
6638
|
-
"kind": "nonempty",
|
|
6639
|
-
"required": false,
|
|
6640
|
-
"example": "12345"
|
|
6641
|
-
},
|
|
6642
6624
|
SENDER_EMAIL: {
|
|
6643
6625
|
"runtime": "server",
|
|
6644
6626
|
"kind": "email",
|
|
6645
6627
|
"required": false,
|
|
6646
6628
|
"example": "noreply@capxul.test"
|
|
6647
6629
|
},
|
|
6648
|
-
SHIELD_API_URL: {
|
|
6649
|
-
"runtime": "server",
|
|
6650
|
-
"kind": "url",
|
|
6651
|
-
"required": false,
|
|
6652
|
-
"example": "https://api.shield.test"
|
|
6653
|
-
},
|
|
6654
6630
|
ALCHEMY_API_KEY: {
|
|
6655
6631
|
"runtime": "server",
|
|
6656
6632
|
"kind": "nonempty",
|
|
@@ -6669,24 +6645,6 @@ const envFields = {
|
|
|
6669
6645
|
"required": true,
|
|
6670
6646
|
"example": "alchemy_hmac"
|
|
6671
6647
|
},
|
|
6672
|
-
ALCHEMY_AUTH_TOKEN: {
|
|
6673
|
-
"runtime": "server",
|
|
6674
|
-
"kind": "nonempty",
|
|
6675
|
-
"required": false,
|
|
6676
|
-
"example": "alchemy_auth"
|
|
6677
|
-
},
|
|
6678
|
-
ALCHEMY_WEBHOOK_ID: {
|
|
6679
|
-
"runtime": "server",
|
|
6680
|
-
"kind": "nonempty",
|
|
6681
|
-
"required": false,
|
|
6682
|
-
"example": "wh_123"
|
|
6683
|
-
},
|
|
6684
|
-
GOLDSKY_WEBHOOK_SECRET: {
|
|
6685
|
-
"runtime": "server",
|
|
6686
|
-
"kind": "nonempty",
|
|
6687
|
-
"required": false,
|
|
6688
|
-
"example": "goldsky_secret"
|
|
6689
|
-
},
|
|
6690
6648
|
DEPLOYER_PRIVATE_KEY: {
|
|
6691
6649
|
"runtime": "server",
|
|
6692
6650
|
"kind": "privateKey",
|
|
@@ -7406,6 +7364,7 @@ const DEFAULT_FUNCTIONS$1 = {
|
|
|
7406
7364
|
prepareFounderAccount: makeFunctionReference("org/actions:prepareFounderAccount"),
|
|
7407
7365
|
prepareBootstrap: makeFunctionReference("org/actions:prepareBootstrap"),
|
|
7408
7366
|
submitBootstrap: makeFunctionReference("org/actions:submitBootstrap"),
|
|
7367
|
+
resumeBootstrapSubmission: makeFunctionReference("org/actions:resumeBootstrapSubmission"),
|
|
7409
7368
|
confirmBootstrap: makeFunctionReference("org/actions:confirmBootstrap"),
|
|
7410
7369
|
recordFailure: makeFunctionReference("org/lifecycle:recordFailure"),
|
|
7411
7370
|
load: makeFunctionReference("org/lifecycle:load"),
|
|
@@ -7467,14 +7426,22 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
7467
7426
|
if (!submitted.ok) return submitted;
|
|
7468
7427
|
return parseLifecycle("submitBootstrap", submitted.value);
|
|
7469
7428
|
}
|
|
7429
|
+
resumeSubmittedBootstrap(input) {
|
|
7430
|
+
return this.#lifecycleAction("resumeBootstrapSubmission", input, () => this.#convex.action(this.#fns.resumeBootstrapSubmission, { orgId: input.orgId }));
|
|
7431
|
+
}
|
|
7470
7432
|
confirmSubmittedBootstrap(input) {
|
|
7471
7433
|
return this.#lifecycleAction("confirmBootstrap", input, () => this.#convex.action(this.#fns.confirmBootstrap, { orgId: input.orgId }));
|
|
7472
7434
|
}
|
|
7473
7435
|
async recordFailure(input) {
|
|
7436
|
+
const errorProvider = input.error.details?.provider;
|
|
7437
|
+
const errorOperation = input.error.details?.operation;
|
|
7474
7438
|
const result = await runCall("recordFailure", this.#convex.mutation(this.#fns.recordFailure, {
|
|
7475
7439
|
orgId: input.orgId,
|
|
7476
|
-
at: input.at,
|
|
7477
7440
|
errorCode: input.error.code,
|
|
7441
|
+
...typeof errorProvider === "string" && typeof errorOperation === "string" ? {
|
|
7442
|
+
errorProvider,
|
|
7443
|
+
errorOperation
|
|
7444
|
+
} : {},
|
|
7478
7445
|
retryable: input.retryable
|
|
7479
7446
|
}));
|
|
7480
7447
|
return result.ok ? parseLifecycle("recordFailure", result.value) : result;
|
|
@@ -7488,8 +7455,15 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
7488
7455
|
async retry(input) {
|
|
7489
7456
|
const cancelled = cancellation(input.signal);
|
|
7490
7457
|
if (cancelled !== void 0) return cancelled;
|
|
7458
|
+
const current = await this.loadLifecycle({ orgId: input.orgId });
|
|
7459
|
+
if (!current.ok) return current;
|
|
7460
|
+
if (current.value.status === "failed" && current.value.retryable && (current.value.at === "awaitingFounderAuthorization" || current.value.at === "submittingBootstrap")) {
|
|
7461
|
+
const reset = resetSignerSession(this.#signer);
|
|
7462
|
+
if (!reset.ok) return reset;
|
|
7463
|
+
}
|
|
7491
7464
|
const result = await runCall("retry", this.#convex.mutation(this.#fns.retry, { orgId: input.orgId }));
|
|
7492
|
-
|
|
7465
|
+
if (!result.ok) return result;
|
|
7466
|
+
return parseLifecycle("retry", result.value);
|
|
7493
7467
|
}
|
|
7494
7468
|
async #lifecycleAction(operation, input, call) {
|
|
7495
7469
|
const cancelled = cancellation(input.signal);
|
|
@@ -7501,6 +7475,22 @@ var ConvexOrganizationSetupAdapter = class {
|
|
|
7501
7475
|
return parseLifecycle(operation, result.value);
|
|
7502
7476
|
}
|
|
7503
7477
|
};
|
|
7478
|
+
function resetSignerSession(signer) {
|
|
7479
|
+
const resetSession = signer.resetSession;
|
|
7480
|
+
if (typeof resetSession !== "function") return {
|
|
7481
|
+
ok: true,
|
|
7482
|
+
value: void 0
|
|
7483
|
+
};
|
|
7484
|
+
try {
|
|
7485
|
+
resetSession.call(signer);
|
|
7486
|
+
return {
|
|
7487
|
+
ok: true,
|
|
7488
|
+
value: void 0
|
|
7489
|
+
};
|
|
7490
|
+
} catch (cause) {
|
|
7491
|
+
return fail$2(cause instanceof CapxulError ? cause : Errors.providerError("openfort", "resetSession", cause, { failure_mode: "unknown" }));
|
|
7492
|
+
}
|
|
7493
|
+
}
|
|
7504
7494
|
async function runCall(operation, effect) {
|
|
7505
7495
|
try {
|
|
7506
7496
|
const result = await Effect.runPromise(Effect.either(effect));
|
|
@@ -7527,7 +7517,7 @@ async function signerResult(operation, run) {
|
|
|
7527
7517
|
value: await run()
|
|
7528
7518
|
};
|
|
7529
7519
|
} catch (cause) {
|
|
7530
|
-
return fail$2(Errors.providerError("organization-signer", operation, cause));
|
|
7520
|
+
return fail$2(cause instanceof CapxulError ? cause : Errors.providerError("organization-signer", operation, cause));
|
|
7531
7521
|
}
|
|
7532
7522
|
}
|
|
7533
7523
|
function validatePreparedAuthorities(prepared, signerAddress) {
|
|
@@ -8449,6 +8439,9 @@ function transportErrorFromThrown(operation, request, cause) {
|
|
|
8449
8439
|
}
|
|
8450
8440
|
//#endregion
|
|
8451
8441
|
//#region ../../packages/sdk/src/openfort/create-openfort-browser-signer.ts
|
|
8442
|
+
function openfortProviderError(operation, cause) {
|
|
8443
|
+
return cause instanceof CapxulError ? cause : Errors.providerError("openfort", operation, cause, { failure_mode: "unknown" });
|
|
8444
|
+
}
|
|
8452
8445
|
/**
|
|
8453
8446
|
* True when the browser cannot perform Web Crypto — sandboxed iframes, headless
|
|
8454
8447
|
* agent browsers, or non-HTTPS origins. OpenFort's embedded-wallet `configure`
|
|
@@ -8517,21 +8510,39 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
8517
8510
|
return `${authBaseUrl}/encryption-session`;
|
|
8518
8511
|
}
|
|
8519
8512
|
async function fetchBetterAuthAccessToken() {
|
|
8520
|
-
|
|
8521
|
-
|
|
8513
|
+
try {
|
|
8514
|
+
const response = await fetch(betterAuthSessionUrl(), { credentials: "include" });
|
|
8515
|
+
if (!response.ok) {
|
|
8516
|
+
diagnostic?.trace("openfort.token", {
|
|
8517
|
+
ok: false,
|
|
8518
|
+
tokenPresent: false,
|
|
8519
|
+
httpStatus: response.status,
|
|
8520
|
+
failure_mode: "unknown"
|
|
8521
|
+
});
|
|
8522
|
+
return null;
|
|
8523
|
+
}
|
|
8524
|
+
const token = (await response.json()).session?.token?.trim();
|
|
8525
|
+
if (token === void 0 || token.length === 0) {
|
|
8526
|
+
diagnostic?.trace("openfort.token", {
|
|
8527
|
+
ok: false,
|
|
8528
|
+
tokenPresent: false,
|
|
8529
|
+
failure_mode: "unknown"
|
|
8530
|
+
});
|
|
8531
|
+
return null;
|
|
8532
|
+
}
|
|
8533
|
+
diagnostic?.trace("openfort.token", {
|
|
8534
|
+
ok: true,
|
|
8535
|
+
tokenPresent: true
|
|
8536
|
+
});
|
|
8537
|
+
return token;
|
|
8538
|
+
} catch (cause) {
|
|
8522
8539
|
diagnostic?.trace("openfort.token", {
|
|
8540
|
+
ok: false,
|
|
8523
8541
|
tokenPresent: false,
|
|
8524
|
-
|
|
8542
|
+
failure_mode: "unknown"
|
|
8525
8543
|
});
|
|
8526
|
-
|
|
8544
|
+
throw openfortProviderError("token", cause);
|
|
8527
8545
|
}
|
|
8528
|
-
const token = (await response.json()).session?.token?.trim();
|
|
8529
|
-
if (token === void 0 || token.length === 0) {
|
|
8530
|
-
diagnostic?.trace("openfort.token", { tokenPresent: false });
|
|
8531
|
-
return null;
|
|
8532
|
-
}
|
|
8533
|
-
diagnostic?.trace("openfort.token", { tokenPresent: true });
|
|
8534
|
-
return token;
|
|
8535
8546
|
}
|
|
8536
8547
|
const openfort = new Openfort({
|
|
8537
8548
|
baseConfiguration: { publishableKey: bootstrap.openfortPublishableKey },
|
|
@@ -8547,25 +8558,60 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
8547
8558
|
if (isInsecureBrowserContext()) failNoSecureContext();
|
|
8548
8559
|
await openfort.waitForInitialization();
|
|
8549
8560
|
const accessToken = await fetchBetterAuthAccessToken();
|
|
8550
|
-
if (accessToken === null) throw
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
+
if (accessToken === null) throw openfortProviderError("token", /* @__PURE__ */ new Error("Better Auth access token unavailable for Openfort"));
|
|
8562
|
+
let encryptionResponse;
|
|
8563
|
+
try {
|
|
8564
|
+
encryptionResponse = await fetch(encryptionSessionUrl(), {
|
|
8565
|
+
method: "POST",
|
|
8566
|
+
credentials: "include",
|
|
8567
|
+
headers: {
|
|
8568
|
+
Authorization: `Bearer ${accessToken}`,
|
|
8569
|
+
"Content-Type": "application/json"
|
|
8570
|
+
},
|
|
8571
|
+
body: JSON.stringify({})
|
|
8572
|
+
});
|
|
8573
|
+
} catch (cause) {
|
|
8574
|
+
diagnostic?.trace("openfort.encryptionSession", {
|
|
8575
|
+
ok: false,
|
|
8576
|
+
failure_mode: "unknown"
|
|
8577
|
+
});
|
|
8578
|
+
throw openfortProviderError("encryptionSession", cause);
|
|
8579
|
+
}
|
|
8561
8580
|
if (!encryptionResponse.ok) {
|
|
8562
|
-
|
|
8563
|
-
|
|
8581
|
+
diagnostic?.trace("openfort.encryptionSession", {
|
|
8582
|
+
ok: false,
|
|
8583
|
+
httpStatus: encryptionResponse.status,
|
|
8584
|
+
failure_mode: "unknown"
|
|
8585
|
+
});
|
|
8586
|
+
throw Errors.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error(`Openfort encryption session failed (${encryptionResponse.status})`), { failure_mode: "unknown" });
|
|
8587
|
+
}
|
|
8588
|
+
let encryptionBody;
|
|
8589
|
+
try {
|
|
8590
|
+
encryptionBody = await encryptionResponse.json();
|
|
8591
|
+
if (typeof encryptionBody.sessionId !== "string" || encryptionBody.sessionId.length === 0) throw new Error("Openfort encryption session response missing sessionId");
|
|
8592
|
+
} catch (cause) {
|
|
8593
|
+
diagnostic?.trace("openfort.encryptionSession", {
|
|
8594
|
+
ok: false,
|
|
8595
|
+
httpStatus: encryptionResponse.status,
|
|
8596
|
+
failure_mode: "unknown"
|
|
8597
|
+
});
|
|
8598
|
+
throw openfortProviderError("encryptionSession", cause);
|
|
8599
|
+
}
|
|
8600
|
+
diagnostic?.trace("openfort.encryptionSession", {
|
|
8601
|
+
ok: true,
|
|
8602
|
+
httpStatus: encryptionResponse.status
|
|
8603
|
+
});
|
|
8604
|
+
let embeddedState;
|
|
8605
|
+
try {
|
|
8606
|
+
embeddedState = await openfort.embeddedWallet.getEmbeddedState();
|
|
8607
|
+
diagnostic?.trace("openfort.embeddedState", { state: embeddedState });
|
|
8608
|
+
} catch (cause) {
|
|
8609
|
+
diagnostic?.trace("openfort.embeddedState", {
|
|
8610
|
+
ok: false,
|
|
8611
|
+
failure_mode: "unknown"
|
|
8612
|
+
});
|
|
8613
|
+
throw openfortProviderError("embeddedState", cause);
|
|
8564
8614
|
}
|
|
8565
|
-
const encryptionBody = await encryptionResponse.json();
|
|
8566
|
-
if (typeof encryptionBody.sessionId !== "string" || encryptionBody.sessionId.length === 0) throw Errors.providerError("openfort", "encryptionSession", /* @__PURE__ */ new Error("Openfort encryption session response missing sessionId"));
|
|
8567
|
-
const embeddedState = await openfort.embeddedWallet.getEmbeddedState();
|
|
8568
|
-
diagnostic?.trace("openfort.embeddedState", { state: embeddedState });
|
|
8569
8615
|
if (embeddedState !== EmbeddedState.READY) {
|
|
8570
8616
|
clearStaleOpenfortBrowserStorage(bootstrap.openfortPublishableKey);
|
|
8571
8617
|
diagnostic?.trace("openfort.storageCleared", { beforeConfigure: true });
|
|
@@ -8582,9 +8628,9 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
8582
8628
|
} catch (cause) {
|
|
8583
8629
|
diagnostic?.trace("openfort.configure", {
|
|
8584
8630
|
ok: false,
|
|
8585
|
-
|
|
8631
|
+
failure_mode: "unknown"
|
|
8586
8632
|
});
|
|
8587
|
-
throw cause;
|
|
8633
|
+
throw openfortProviderError("configure", cause);
|
|
8588
8634
|
}
|
|
8589
8635
|
}
|
|
8590
8636
|
try {
|
|
@@ -8593,9 +8639,9 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
8593
8639
|
} catch (cause) {
|
|
8594
8640
|
diagnostic?.trace("openfort.get", {
|
|
8595
8641
|
ok: false,
|
|
8596
|
-
|
|
8642
|
+
failure_mode: "unknown"
|
|
8597
8643
|
});
|
|
8598
|
-
throw cause;
|
|
8644
|
+
throw openfortProviderError("get", cause);
|
|
8599
8645
|
}
|
|
8600
8646
|
})();
|
|
8601
8647
|
}
|
|
@@ -8614,6 +8660,19 @@ function createOpenfortBrowserSignerFromBootstrap(bootstrap, options = {}) {
|
|
|
8614
8660
|
});
|
|
8615
8661
|
return {
|
|
8616
8662
|
...signer,
|
|
8663
|
+
getAddress: async () => {
|
|
8664
|
+
try {
|
|
8665
|
+
const address = await signer.getAddress();
|
|
8666
|
+
diagnostic?.trace("openfort.address", { ok: true });
|
|
8667
|
+
return address;
|
|
8668
|
+
} catch (cause) {
|
|
8669
|
+
diagnostic?.trace("openfort.address", {
|
|
8670
|
+
ok: false,
|
|
8671
|
+
failure_mode: "unknown"
|
|
8672
|
+
});
|
|
8673
|
+
throw openfortProviderError("getAddress", cause);
|
|
8674
|
+
}
|
|
8675
|
+
},
|
|
8617
8676
|
resetSession: () => {
|
|
8618
8677
|
walletReadyPromise = null;
|
|
8619
8678
|
clearStaleOpenfortBrowserStorage(bootstrap.openfortPublishableKey);
|
|
@@ -11120,16 +11179,17 @@ async function advanceOrganizationSetup(setup, orgId, initial, signal) {
|
|
|
11120
11179
|
value: lifecycle
|
|
11121
11180
|
};
|
|
11122
11181
|
const currentStep = lifecycle.step;
|
|
11123
|
-
if (signal?.aborted) {
|
|
11124
|
-
const cancelled = Errors.cancelled({ operation: "organization.setup" });
|
|
11125
|
-
return recordRetryableCancellation(setup, orgId, lifecycle.step, cancelled);
|
|
11126
|
-
}
|
|
11182
|
+
if (signal?.aborted) return recordSetupFailure(setup, orgId, Errors.cancelled({ operation: "organization.setup" }), true);
|
|
11127
11183
|
const stepInput = {
|
|
11128
11184
|
orgId,
|
|
11129
11185
|
...signal === void 0 ? {} : { signal }
|
|
11130
11186
|
};
|
|
11131
|
-
const next = lifecycle.step === "preparingFounderAccount" ? await setup.prepareFounderAccount(stepInput) : lifecycle.step === "awaitingFounderAuthorization"
|
|
11132
|
-
if (!next.ok)
|
|
11187
|
+
const next = lifecycle.step === "preparingFounderAccount" ? await setup.prepareFounderAccount(stepInput) : lifecycle.step === "awaitingFounderAuthorization" ? await setup.authorizeAndSubmitBootstrap(stepInput) : lifecycle.step === "submittingBootstrap" ? await setup.resumeSubmittedBootstrap(stepInput) : await setup.confirmSubmittedBootstrap(stepInput);
|
|
11188
|
+
if (!next.ok) {
|
|
11189
|
+
if (next.error.code === "CANCELLED") return recordSetupFailure(setup, orgId, next.error, true);
|
|
11190
|
+
if (next.error.code === "PROVIDER_ERROR") return recordSetupFailure(setup, orgId, next.error, isRetryableProviderFailure(next.error));
|
|
11191
|
+
return next;
|
|
11192
|
+
}
|
|
11133
11193
|
const scopedNext = validateOrganizationLifecycleScope(orgId, next.value);
|
|
11134
11194
|
if (!scopedNext.ok) return scopedNext;
|
|
11135
11195
|
lifecycle = scopedNext.value;
|
|
@@ -11152,17 +11212,20 @@ async function advanceOrganizationSetup(setup, orgId, initial, signal) {
|
|
|
11152
11212
|
]
|
|
11153
11213
|
}));
|
|
11154
11214
|
}
|
|
11155
|
-
async function
|
|
11215
|
+
async function recordSetupFailure(setup, orgId, error, retryable) {
|
|
11156
11216
|
const recorded = await setup.recordFailure({
|
|
11157
11217
|
orgId,
|
|
11158
|
-
|
|
11159
|
-
|
|
11160
|
-
retryable: true
|
|
11218
|
+
error,
|
|
11219
|
+
retryable
|
|
11161
11220
|
});
|
|
11162
11221
|
if (!recorded.ok) return recorded;
|
|
11163
11222
|
const scopedRecorded = validateOrganizationLifecycleScope(orgId, recorded.value);
|
|
11164
11223
|
if (!scopedRecorded.ok) return scopedRecorded;
|
|
11165
|
-
return fail$1(
|
|
11224
|
+
return fail$1(error);
|
|
11225
|
+
}
|
|
11226
|
+
function isRetryableProviderFailure(error) {
|
|
11227
|
+
const mode = error.details?.failure_mode;
|
|
11228
|
+
return mode !== "auth-origin-mismatch" && mode !== "app-env-allowlist" && mode !== "no-secure-context";
|
|
11166
11229
|
}
|
|
11167
11230
|
//#endregion
|
|
11168
11231
|
//#region ../../packages/sdk/src/client/org.ts
|
|
@@ -11513,7 +11576,18 @@ async function runCompleteOrganizationOnboarding(ops, input, options) {
|
|
|
11513
11576
|
});
|
|
11514
11577
|
if (!started.ok) return fail(started.error);
|
|
11515
11578
|
const lifecycle = await advanceOrganizationSetup(setup, started.value.orgId, started.value.lifecycle, options?.signal);
|
|
11516
|
-
if (!lifecycle.ok)
|
|
11579
|
+
if (!lifecycle.ok) {
|
|
11580
|
+
const error = lifecycle.error;
|
|
11581
|
+
return fail(new CapxulError(error.code, error.message, {
|
|
11582
|
+
cause: error.cause,
|
|
11583
|
+
details: {
|
|
11584
|
+
...error.details,
|
|
11585
|
+
orgId: started.value.orgId
|
|
11586
|
+
},
|
|
11587
|
+
...error.correlationId === void 0 ? {} : { correlationId: error.correlationId },
|
|
11588
|
+
...error.layer === void 0 ? {} : { layer: error.layer }
|
|
11589
|
+
}));
|
|
11590
|
+
}
|
|
11517
11591
|
return {
|
|
11518
11592
|
ok: true,
|
|
11519
11593
|
value: {
|
|
@@ -11745,6 +11819,7 @@ function detectAuthCacheAdapter() {
|
|
|
11745
11819
|
}
|
|
11746
11820
|
//#endregion
|
|
11747
11821
|
//#region ../../packages/sdk/src/client/create-capxul-client.ts
|
|
11822
|
+
const GET_ORGANIZATION_SETUP_PROOF_RECEIPT = makeFunctionReference("org/lifecycle:getProofReceipt");
|
|
11748
11823
|
function assembleCapxulClient(input) {
|
|
11749
11824
|
const authCache = input.authCache ?? detectAuthCacheAdapter();
|
|
11750
11825
|
const layer = Layer.mergeAll(Layer.succeed(AuthClientPortTag, input.ports.authClient), Layer.succeed(ClockPortTag, input.ports.clock), Layer.succeed(TelemetryPortTag, input.ports.telemetry));
|
|
@@ -11868,6 +11943,7 @@ function assembleCapxulClient(input) {
|
|
|
11868
11943
|
},
|
|
11869
11944
|
bootstrap: input.bootstrap,
|
|
11870
11945
|
accounts: { fund: accounts.fund },
|
|
11946
|
+
organizationSetup: { getProofReceipt: (orgId) => runPortEffect(input.ports.convexCall.query(GET_ORGANIZATION_SETUP_PROOF_RECEIPT, { orgId })) },
|
|
11871
11947
|
telemetry: input.ports.telemetry
|
|
11872
11948
|
}
|
|
11873
11949
|
};
|
|
@@ -15921,7 +15997,7 @@ async function executeCommitmentRedirect(input) {
|
|
|
15921
15997
|
*/
|
|
15922
15998
|
async function fetchCommitmentCreatedIdFromLogs(input) {
|
|
15923
15999
|
const { keccak256, toBytes } = await import("viem");
|
|
15924
|
-
const { fetchCommitmentCreatedLog } = await import("./alchemy-rpc-
|
|
16000
|
+
const { fetchCommitmentCreatedLog } = await import("./alchemy-rpc-BiJgkVvc.mjs");
|
|
15925
16001
|
const { CAPXUL_PAYMENTS_ADDRESS } = await import("./src-CIqRZpwl.mjs");
|
|
15926
16002
|
const topic0 = keccak256(toBytes("CommitmentCreated(uint256,address,address,address,uint256,uint48,uint48,uint48,bytes32,uint8)"));
|
|
15927
16003
|
const idTopic = (await fetchCommitmentCreatedLog({
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capxul/mcp",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Capxul MCP server — agent-facing financial-ops tools (auth, account readiness, balances, testnet faucet, payments) exposed over Streamable HTTP with OAuth bearer auth and a dev-mode custody gate.",
|
|
6
6
|
"keywords": [
|
|
7
|
+
"ai-agents",
|
|
7
8
|
"capxul",
|
|
9
|
+
"cli",
|
|
8
10
|
"mcp",
|
|
9
11
|
"model-context-protocol",
|
|
10
|
-
"ai-agents",
|
|
11
|
-
"web3",
|
|
12
|
-
"stablecoin",
|
|
13
12
|
"payments",
|
|
14
|
-
"
|
|
13
|
+
"stablecoin",
|
|
14
|
+
"web3"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://github.com/Xelmar-tech/infrastructure#readme",
|
|
17
17
|
"bugs": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"url": "git+https://github.com/Xelmar-tech/infrastructure.git",
|
|
25
25
|
"directory": "apps/mcp"
|
|
26
26
|
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"capxul-mcp": "./dist/main.mjs"
|
|
29
|
+
},
|
|
27
30
|
"files": [
|
|
28
31
|
"dist",
|
|
29
32
|
"package.json",
|
|
30
33
|
"README.md"
|
|
31
34
|
],
|
|
32
|
-
"bin": {
|
|
33
|
-
"capxul-mcp": "./dist/main.mjs"
|
|
34
|
-
},
|
|
35
35
|
"type": "module",
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"typescript": "5.9.2",
|
|
53
53
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
|
|
54
54
|
"vite-plus": "0.1.23",
|
|
55
|
-
"@capxul/backend": "0.1.0-alpha.
|
|
55
|
+
"@capxul/backend": "0.1.0-alpha.4",
|
|
56
56
|
"@capxul/config": "0.1.0-alpha.2",
|
|
57
|
-
"@capxul/sdk": "1.0.0-alpha.18",
|
|
58
|
-
"@capxul/types": "0.1.0-alpha.0",
|
|
59
|
-
"@capxul/wire": "0.1.0-alpha.2",
|
|
60
57
|
"@capxul/errors": "0.0.0",
|
|
61
|
-
"@capxul/observability": "0.1.0-alpha.0"
|
|
58
|
+
"@capxul/observability": "0.1.0-alpha.0",
|
|
59
|
+
"@capxul/sdk": "1.0.0-alpha.19",
|
|
60
|
+
"@capxul/types": "0.1.0-alpha.0",
|
|
61
|
+
"@capxul/wire": "0.1.0-alpha.2"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"dev": "vp exec tsx src/main.ts serve",
|