@capxul/mcp 2.3.2 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.mjs +272 -134
  2. package/package.json +4 -4
package/dist/main.mjs CHANGED
@@ -240,7 +240,7 @@ function normalizeEmail(email) {
240
240
  }
241
241
  //#endregion
242
242
  //#region package.json
243
- var version$2 = "2.3.2";
243
+ var version$2 = "2.4.0";
244
244
  //#endregion
245
245
  //#region ../../packages/errors/src/errors.ts
246
246
  const CAPXUL_ERROR_CODES = [
@@ -2554,7 +2554,8 @@ const EngineeringTelemetryBootstrapPolicy = Schema.Struct({
2554
2554
  capxulEnv: Schema.Union([
2555
2555
  Schema.Literal("development"),
2556
2556
  Schema.Literal("staging"),
2557
- Schema.Literal("production")
2557
+ Schema.Literal("production"),
2558
+ Schema.Literal("local")
2558
2559
  ])
2559
2560
  });
2560
2561
  /**
@@ -2645,7 +2646,8 @@ const CAPXUL_FUNCTIONS = {
2645
2646
  "movement/activity": {
2646
2647
  annotate: "movement/activity:annotate",
2647
2648
  get: "movement/activity:get",
2648
- list: "movement/activity:list"
2649
+ list: "movement/activity:list",
2650
+ summary: "movement/activity:summary"
2649
2651
  },
2650
2652
  "moneyExecution/actions": {
2651
2653
  preparePermissionExecution: "moneyExecution/actions:preparePermissionExecution",
@@ -5812,6 +5814,31 @@ const transition = (state, event, config = DEFAULT_CONFIG) => {
5812
5814
  };
5813
5815
  const PRIVATE_TAGS = new Set(PRIVATE_EVENT_TAGS);
5814
5816
  const isPrivate = (event) => PRIVATE_TAGS.has(event._tag);
5817
+ Object.freeze({
5818
+ terminal: false,
5819
+ outcome: null,
5820
+ needsAction: false
5821
+ });
5822
+ Object.freeze({
5823
+ terminal: false,
5824
+ outcome: null,
5825
+ needsAction: true
5826
+ });
5827
+ Object.freeze({
5828
+ terminal: true,
5829
+ outcome: "good",
5830
+ needsAction: false
5831
+ });
5832
+ Object.freeze({
5833
+ terminal: true,
5834
+ outcome: "bad",
5835
+ needsAction: false
5836
+ });
5837
+ Object.freeze({
5838
+ terminal: true,
5839
+ outcome: "neutral",
5840
+ needsAction: false
5841
+ });
5815
5842
  //#endregion
5816
5843
  //#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
5817
5844
  async function emitProvisioningTelemetry(telemetry, smartAccount) {
@@ -7154,7 +7181,7 @@ function mapActorRequest(request, payer) {
7154
7181
  ...resolvedPayer === void 0 ? {} : { payer: resolvedPayer },
7155
7182
  amount: request.amount,
7156
7183
  reference: request.reference,
7157
- status: mapActorRequestStatus(request.status),
7184
+ status: request.status,
7158
7185
  expiresAt: request.expiresAt ?? null
7159
7186
  };
7160
7187
  }
@@ -7212,28 +7239,17 @@ function mapApprovedInboxPayment(command, input) {
7212
7239
  };
7213
7240
  }
7214
7241
  }
7215
- function mapActorRequestStatus(status) {
7242
+ function mapInboxStatus(status) {
7216
7243
  switch (status) {
7217
7244
  case "draft":
7218
7245
  case "sent":
7219
- case "viewed":
7246
+ case "viewed": return "open";
7247
+ case "pending_settlement": return "approved";
7220
7248
  case "paid":
7221
- case "pending_settlement":
7222
- case "declined":
7223
- case "cancelled":
7224
- case "expired": return status;
7225
- default: return "sent";
7226
- }
7227
- }
7228
- function mapInboxStatus(status) {
7229
- switch (status) {
7230
- case "approved":
7231
7249
  case "declined":
7232
- case "paid":
7233
7250
  case "cancelled":
7234
7251
  case "expired": return status;
7235
- case "pending_settlement": return "approved";
7236
- default: return "open";
7252
+ default: throw Errors.invalidInput("status", "unknown request status");
7237
7253
  }
7238
7254
  }
7239
7255
  function normalizeRefForBackend$1(ref, field) {
@@ -7552,6 +7568,7 @@ const financialOpsContract = {
7552
7568
  listPayments: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].listPayments),
7553
7569
  getPayment: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].getPayment),
7554
7570
  activityList: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].list),
7571
+ activitySummary: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].summary),
7555
7572
  activityGet: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].get),
7556
7573
  activityAnnotate: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].annotate),
7557
7574
  verifyPaymentDocument: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].verifyPaymentDocument),
@@ -7803,6 +7820,40 @@ function actorReferenceToBackend(actor) {
7803
7820
  case "org": return actor;
7804
7821
  }
7805
7822
  }
7823
+ /**
7824
+ * The activity backend gives its actor a different name than the other
7825
+ * financialOps functions: `{kind: "organization", orgId}`, and not
7826
+ * `{kind: "org", orgId}`. Thus it does not use `actorReferenceToBackend`.
7827
+ *
7828
+ * The `personal` case sends NO actor. This is correct, and it does not lose
7829
+ * data. `requireActivityActor` uses the signed-in Account when the actor is
7830
+ * absent, and `canReadActor` refuses all other account identifiers
7831
+ * (`packages/backend/convex/movement/activityAuth.ts`). Thus "personal" and
7832
+ * "absent" both name the one Account that an SDK caller can read. The SDK does
7833
+ * not hold an account identifier to send.
7834
+ *
7835
+ * The `switch` is exhaustive. A new `ActorReference` variant is a compile error
7836
+ * here. The conditional expression that this function replaced removed each
7837
+ * value that was not an organization.
7838
+ */
7839
+ function activityActorField(actor) {
7840
+ if (actor === void 0) return {};
7841
+ switch (actor.kind) {
7842
+ case "personal": return {};
7843
+ case "organization": return { actor: {
7844
+ kind: "organization",
7845
+ orgId: actor.organizationId
7846
+ } };
7847
+ }
7848
+ }
7849
+ /** An absent actor and a `personal` actor both name the signed-in Account. */
7850
+ function actorScopeKey(actor) {
7851
+ return actor === void 0 || actor.kind === "personal" ? "personal" : `org:${actor.organizationId}`;
7852
+ }
7853
+ /** Two actor references name the same scope. */
7854
+ function sameActor(left, right) {
7855
+ return actorScopeKey(left) === actorScopeKey(right);
7856
+ }
7806
7857
  const memoryPaymentRequestKeys = /* @__PURE__ */ new Map();
7807
7858
  const paymentAttemptReleases = /* @__PURE__ */ new Set();
7808
7859
  let paymentAttemptPagehideInstalled = false;
@@ -8233,31 +8284,48 @@ function makeFinancialOpsMethods(deps) {
8233
8284
  },
8234
8285
  activity: {
8235
8286
  list: (params, options) => runIfActive(options?.signal, "activity.list", () => deps.convexCall.query(fns.activityList, { input: {
8236
- ...params?.actor?.kind === "organization" ? { actor: {
8237
- kind: "organization",
8238
- orgId: params.actor.organizationId
8239
- } } : {},
8287
+ ...activityActorField(params?.actor),
8240
8288
  ...params?.cursor === void 0 ? {} : { cursor: params.cursor },
8241
- ...params?.limit === void 0 ? {} : { limit: params.limit }
8289
+ ...params?.limit === void 0 ? {} : { limit: params.limit },
8290
+ ...params?.range === void 0 ? {} : { range: params.range },
8291
+ ...params?.filter === void 0 ? {} : { filter: params.filter }
8242
8292
  } })),
8243
- get: (reference, options) => runIfActive(options?.signal, "activity.get", () => deps.convexCall.query(fns.activityGet, { input: {
8244
- kind: reference.kind,
8245
- id: reference.id,
8246
- ...reference.kind === "payment" && reference.actor?.kind === "organization" ? { actor: {
8247
- kind: "organization",
8248
- orgId: reference.actor.organizationId
8249
- } } : {}
8293
+ summary: (params, options) => runIfActive(options?.signal, "activity.summary", () => deps.convexCall.query(fns.activitySummary, { input: {
8294
+ ...activityActorField(params?.actor),
8295
+ ...params?.window === void 0 ? {} : { window: params.window }
8250
8296
  } })),
8251
- annotate: (input, options) => runIfActive(options?.signal, "activity.annotate", () => deps.convexCall.mutation(fns.activityAnnotate, { input: {
8252
- ...input.actor?.kind === "organization" ? { actor: {
8253
- kind: "organization",
8254
- orgId: input.actor.organizationId
8255
- } } : {},
8256
- movementId: input.movementId,
8257
- ...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
8258
- ...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
8259
- ...input.memo === void 0 ? {} : { memo: input.memo }
8260
- } }))
8297
+ get: (reference, options) => {
8298
+ const actor = actorReferenceToBackend(options?.actor);
8299
+ return runIfActive(options?.signal, "activity.get", () => deps.convexCall.query(fns.activityGet, {
8300
+ input: {
8301
+ kind: reference.kind,
8302
+ id: reference.id,
8303
+ ...reference.kind === "payment" ? activityActorField(reference.actor) : {}
8304
+ },
8305
+ ...actor === void 0 ? {} : { actor }
8306
+ }));
8307
+ },
8308
+ annotate: (input, options) => {
8309
+ if (input.actor !== void 0 && input.reference.kind === "payment" && input.reference.actor !== void 0 && !sameActor(input.actor, input.reference.actor)) return Promise.resolve({
8310
+ ok: false,
8311
+ error: Errors.invalidInput("reference.actor", "must match the annotation actor")
8312
+ });
8313
+ const referenceActor = input.reference.kind === "payment" ? activityActorField(input.reference.actor).actor : void 0;
8314
+ return runIfActive(options?.signal, "activity.annotate", () => deps.convexCall.mutation(fns.activityAnnotate, { input: {
8315
+ ...activityActorField(input.actor),
8316
+ reference: input.reference.kind === "payment" && referenceActor !== void 0 ? {
8317
+ kind: "payment",
8318
+ id: input.reference.id,
8319
+ actor: referenceActor
8320
+ } : {
8321
+ kind: input.reference.kind,
8322
+ id: input.reference.id
8323
+ },
8324
+ ...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
8325
+ ...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
8326
+ ...input.memo === void 0 ? {} : { memo: input.memo }
8327
+ } }));
8328
+ }
8261
8329
  },
8262
8330
  offramp: {
8263
8331
  quote: (input, options) => {
@@ -8748,9 +8816,15 @@ async function recoverRawDigestSigner(input) {
8748
8816
  }
8749
8817
  //#endregion
8750
8818
  //#region ../../packages/sdk/package.json
8751
- var version = "2.3.2";
8819
+ var version = "2.4.0";
8752
8820
  //#endregion
8753
8821
  //#region ../../packages/observability/src/engineering.ts
8822
+ const ENGINEERING_CAPXUL_ENVS = [
8823
+ "development",
8824
+ "staging",
8825
+ "production",
8826
+ "local"
8827
+ ];
8754
8828
  const SAFE_TRACED_HEADER_NAMES = [
8755
8829
  "content-length",
8756
8830
  "content-type",
@@ -8773,11 +8847,7 @@ const postHogOtlpEndpoints = (host) => {
8773
8847
  traces: `${base}/i/v1/traces`
8774
8848
  };
8775
8849
  };
8776
- const ENGINEERING_CAPXUL_ENVS = new Set([
8777
- "development",
8778
- "staging",
8779
- "production"
8780
- ]);
8850
+ const ENGINEERING_CAPXUL_ENV_SET = new Set(ENGINEERING_CAPXUL_ENVS);
8781
8851
  const ENGINEERING_PRODUCERS = new Set(["browser", "server"]);
8782
8852
  const PUBLIC_POSTHOG_AUTHORIZATION = /^Bearer phc_[A-Za-z0-9_-]{1,191}$/u;
8783
8853
  const SAFE_RESOURCE_VALUE = /^[A-Za-z0-9][A-Za-z0-9._+@/-]{0,127}$/u;
@@ -8789,7 +8859,7 @@ const validateEngineeringTelemetryConfig = (config) => {
8789
8859
  throw new TypeError("engineering telemetry host must be an absolute HTTPS URL");
8790
8860
  }
8791
8861
  if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0 || url.pathname !== "/" || url.search.length > 0 || url.hash.length > 0 || !(url.hostname === "posthog.com" || url.hostname.endsWith(".posthog.com"))) throw new TypeError("engineering telemetry host must be a credential-free HTTPS origin");
8792
- if (!ENGINEERING_CAPXUL_ENVS.has(config.capxulEnv)) throw new TypeError("engineering telemetry capxulEnv is not canonical");
8862
+ if (!ENGINEERING_CAPXUL_ENV_SET.has(config.capxulEnv)) throw new TypeError("engineering telemetry capxulEnv is not canonical");
8793
8863
  if (!ENGINEERING_PRODUCERS.has(config.producer)) throw new TypeError("engineering telemetry producer is not canonical");
8794
8864
  if (!SAFE_RESOURCE_VALUE.test(config.sdkVersion)) throw new TypeError("engineering telemetry sdkVersion must be a bounded safe value");
8795
8865
  if (config.serviceName !== void 0 && !SAFE_RESOURCE_VALUE.test(config.serviceName)) throw new TypeError("engineering telemetry serviceName must be a bounded safe value");
@@ -13631,7 +13701,8 @@ const TelemetryEnvelopeProps = {
13631
13701
  "development",
13632
13702
  "staging",
13633
13703
  "production",
13634
- "unknown"
13704
+ "unknown",
13705
+ "local"
13635
13706
  ]),
13636
13707
  producer: Schema.Literals([
13637
13708
  "server",
@@ -39088,13 +39159,74 @@ const organizationPaymentExecutionUnavailable = () => Promise.resolve({
39088
39159
  //#region ../../packages/sdk/src/contract/holdings.ts
39089
39160
  const holdingsContract = { current: makeFunctionReference(CAPXUL_FUNCTIONS["holdings/actions"].current) };
39090
39161
  //#endregion
39162
+ //#region ../../packages/sdk/src/domain/money/primary-holding.ts
39163
+ const CURRENCY_BY_TOKEN_SYMBOL = new Map([["USDX", toCurrencyCode("USD")]]);
39164
+ /**
39165
+ * The designated display asset: the payable row holding the most money, or
39166
+ * `null` when no row is payable.
39167
+ *
39168
+ * A `HoldingRow` (`packages/wire/src/money.ts`) is a RAW CHAIN ROW, and three
39169
+ * of its shapes cannot become a `Holding`. Each is SKIPPED rather than
39170
+ * reported, because a row nobody can render is not a failure of the read:
39171
+ *
39172
+ * - no `decimals` — the raw balance cannot be lifted into major units;
39173
+ * - no `symbol` — the asset cannot be named;
39174
+ * - a symbol that stands for no supported `CurrencyCode` — the balance
39175
+ * cannot be stated as `Money` without inventing a currency for it.
39176
+ *
39177
+ * This replaces the app's hand pick in `formatCurrentHoldingsBalance`
39178
+ * (`dashboard-formatters.ts`): a `.find()` over a hardcoded `["USDX","USDC"]`
39179
+ * list falling back to `rows[0]`. Ties keep the earlier row, so the same
39180
+ * snapshot always yields the same answer.
39181
+ */
39182
+ function primaryHolding(rows) {
39183
+ let primary = null;
39184
+ for (const row of rows) {
39185
+ const holding = toHolding(row);
39186
+ if (holding === null) continue;
39187
+ if (primary === null || compareDecimal(holding.available.value, primary.available.value) > 0) primary = holding;
39188
+ }
39189
+ return primary;
39190
+ }
39191
+ function toHolding(row) {
39192
+ if (row.symbol === void 0 || row.decimals === void 0) return null;
39193
+ const currency = currencyForTokenSymbol(row.symbol);
39194
+ if (currency === null) return null;
39195
+ return {
39196
+ id: row.assetKind === "native" ? "native" : row.tokenAddress.toLowerCase(),
39197
+ symbol: row.symbol,
39198
+ available: fromWei(row.rawBalance, row.decimals, currency)
39199
+ };
39200
+ }
39201
+ function currencyForTokenSymbol(symbol) {
39202
+ return CURRENCY_BY_TOKEN_SYMBOL.get(symbol.toUpperCase()) ?? null;
39203
+ }
39204
+ /**
39205
+ * Order two non-negative major-unit decimal strings without converting either
39206
+ * to a JavaScript number. Rows carry different `decimals`, so the raw integers
39207
+ * are not comparable: 1999999999 at 9 decimals is LESS than 2000000 at 6.
39208
+ */
39209
+ function compareDecimal(first, second) {
39210
+ const [firstWhole = "0", firstFraction = ""] = first.split(".");
39211
+ const [secondWhole = "0", secondFraction = ""] = second.split(".");
39212
+ const width = Math.max(firstFraction.length, secondFraction.length);
39213
+ const firstScaled = BigInt(firstWhole + firstFraction.padEnd(width, "0"));
39214
+ const secondScaled = BigInt(secondWhole + secondFraction.padEnd(width, "0"));
39215
+ if (firstScaled === secondScaled) return 0;
39216
+ return firstScaled < secondScaled ? -1 : 1;
39217
+ }
39218
+ //#endregion
39091
39219
  //#region ../../packages/sdk/src/surface/holdings.ts
39092
39220
  function makeHoldingsMethods(deps) {
39093
39221
  const functions = deps.functions ?? holdingsContract;
39094
- return { current: (input, options) => runIfActive(options?.signal, "holdings.current", () => deps.convexCall.action(functions.current, input?.actor?.kind === "organization" ? { actor: {
39222
+ const read = (operation, actor, signal, pick) => runIfActive(signal, operation, () => deps.convexCall.action(functions.current, actor?.kind === "organization" ? { actor: {
39095
39223
  kind: "organization",
39096
- orgId: input.actor.organizationId
39097
- } } : {})) };
39224
+ orgId: actor.organizationId
39225
+ } } : {}).pipe(Effect.map(pick)));
39226
+ return {
39227
+ current: (input, options) => read("holdings.current", input?.actor, options?.signal, (snapshot) => snapshot),
39228
+ primary: (input, options) => read("holdings.primary", input?.actor, options?.signal, (snapshot) => primaryHolding(snapshot.rows))
39229
+ };
39098
39230
  }
39099
39231
  //#endregion
39100
39232
  //#region ../../packages/sdk/src/ports/auth-cache.ts
@@ -42575,50 +42707,59 @@ const BUNDLER_RPC_METHODS = new Set([
42575
42707
  "pm_getPaymasterStubData",
42576
42708
  "pm_getPaymasterData"
42577
42709
  ]);
42578
- function providerFor(method) {
42579
- return BUNDLER_RPC_METHODS.has(method) ? "account-abstraction" : "alchemy";
42710
+ function rpcProviderRole(chainId, method) {
42711
+ if (BUNDLER_RPC_METHODS.has(method)) return "account-abstraction";
42712
+ if (chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) && optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") !== void 0) return "chain-evidence";
42713
+ return "chain-rpc";
42580
42714
  }
42581
42715
  function accountAbstractionUrl(chainId) {
42582
42716
  if (chainId !== 84532) throw Errors.invalidInput("chainId", `owned account-abstraction rail supports Base Sepolia; got ${String(chainId)}`);
42583
42717
  return requireEnvOrThrow("BASE_SEPOLIA_BUNDLER_RPC_URL");
42584
42718
  }
42585
- function rethrowProvider(method) {
42719
+ function rpcProviderError(operation, cause, chainId) {
42720
+ const method = operation.split(" ", 1)[0] ?? operation;
42721
+ return Errors.providerError(rpcProviderRole(chainId, method), operation, cause);
42722
+ }
42723
+ function rethrowProvider(chainId, method) {
42586
42724
  return (e) => {
42587
- throw Errors.providerError(providerFor(method), method, e);
42725
+ throw rpcProviderError(method, e, chainId);
42588
42726
  };
42589
42727
  }
42590
- function parseAlchemyQuantity(value, operation, field) {
42728
+ function parseRpcQuantity(value, operation, field, chainId) {
42591
42729
  try {
42592
42730
  return BigInt(value);
42593
42731
  } catch (cause) {
42594
- throw Errors.providerError("alchemy", `${operation} ${field}`, `invalid ${field} ${value} (${String(cause)})`);
42732
+ throw rpcProviderError(`${operation} ${field}`, `invalid ${field} ${value} (${String(cause)})`, chainId);
42595
42733
  }
42596
42734
  }
42597
- function providerValue(value, pattern, operation, field) {
42598
- if (typeof value !== "string" || !pattern.test(value)) throw Errors.providerError(providerFor(operation), operation, `invalid ${field}`);
42735
+ function providerValue(value, pattern, operation, field, chainId) {
42736
+ if (typeof value !== "string" || !pattern.test(value)) throw rpcProviderError(operation, `invalid ${field}`, chainId);
42599
42737
  return value.toLowerCase();
42600
42738
  }
42601
- function providerAddress(value, operation, field) {
42602
- return providerValue(value, ADDRESS_HEX, operation, field);
42739
+ function providerAddress(value, operation, field, chainId) {
42740
+ return providerValue(value, ADDRESS_HEX, operation, field, chainId);
42603
42741
  }
42604
- function providerBytes32(value, operation, field) {
42605
- return providerValue(value, BYTES32_HEX, operation, field);
42742
+ function providerBytes32(value, operation, field, chainId) {
42743
+ return providerValue(value, BYTES32_HEX, operation, field, chainId);
42606
42744
  }
42607
- function providerData(value, operation, field) {
42608
- return providerValue(value, EVEN_DATA_HEX, operation, field);
42745
+ function providerData(value, operation, field, chainId) {
42746
+ if (typeof value !== "string" || !EVEN_DATA_HEX.test(value)) throw rpcProviderError(operation, `invalid ${field}`, chainId);
42747
+ return value.toLowerCase();
42609
42748
  }
42749
+ /** The standard public Base node endpoints. Each one is overridable by env. */
42750
+ const BASE_SEPOLIA_NODE_RPC_URL = "https://sepolia.base.org";
42751
+ const BASE_MAINNET_NODE_RPC_URL = "https://mainnet.base.org";
42610
42752
  /**
42611
42753
  * Construct the node RPC URL for a given chain. Account-abstraction methods
42612
42754
  * use the separate owned gateway URL.
42755
+ *
42756
+ * The default is the standard public Base endpoint. An operator points a chain
42757
+ * at a different node with `BASE_SEPOLIA_RPC_URL` or `BASE_MAINNET_RPC_URL`.
42613
42758
  */
42614
- function alchemyUrl(chainId) {
42759
+ function nodeRpcUrl(chainId) {
42615
42760
  switch (chainId) {
42616
- case 84532: {
42617
- const baseSepoliaRpcUrl = optionalEnv("BASE_SEPOLIA_RPC_URL");
42618
- if (baseSepoliaRpcUrl !== void 0) return baseSepoliaRpcUrl.replace(/\/+$/, "");
42619
- return `https://base-sepolia.g.alchemy.com/v2/${requireEnvOrThrow("ALCHEMY_API_KEY")}`;
42620
- }
42621
- case 8453: return `https://base-mainnet.g.alchemy.com/v2/${requireEnvOrThrow("ALCHEMY_API_KEY")}`;
42761
+ case 84532: return (optionalEnv("BASE_SEPOLIA_RPC_URL") ?? BASE_SEPOLIA_NODE_RPC_URL).replace(/\/+$/, "");
42762
+ case 8453: return (optionalEnv("BASE_MAINNET_RPC_URL") ?? BASE_MAINNET_NODE_RPC_URL).replace(/\/+$/, "");
42622
42763
  default: throw Errors.invalidInput("chainId", `unsupported chainId ${String(chainId)}`);
42623
42764
  }
42624
42765
  }
@@ -42632,16 +42773,16 @@ function isValidJsonRpcEnvelope(value) {
42632
42773
  function isValidJsonRpcError(value) {
42633
42774
  return isRecord(value) && typeof value.code === "number" && Number.isInteger(value.code) && typeof value.message === "string";
42634
42775
  }
42635
- var DefinitiveUserOperationRpcRejection = class extends Error {
42776
+ var DefinitiveBundlerJsonRpcRejection = class extends Error {
42636
42777
  constructor() {
42637
- super("The bundler returned an explicit JSON-RPC rejection");
42638
- this.name = "DefinitiveUserOperationRpcRejection";
42778
+ super("Bundler returned an explicit JSON-RPC rejection");
42779
+ this.name = "DefinitiveBundlerJsonRpcRejection";
42639
42780
  }
42640
42781
  };
42641
42782
  async function alchemyRpc(chainId, method, params, timeoutMs, externalSignal) {
42642
42783
  const bundlerUrl = BUNDLER_RPC_METHODS.has(method) ? accountAbstractionUrl(chainId) : void 0;
42643
42784
  const evidenceUrl = chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) ? optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") : void 0;
42644
- const url = bundlerUrl?.replace(/\/+$/u, "") ?? evidenceUrl?.replace(/\/+$/u, "") ?? alchemyUrl(chainId);
42785
+ const url = bundlerUrl?.replace(/\/+$/u, "") ?? evidenceUrl?.replace(/\/+$/u, "") ?? nodeRpcUrl(chainId);
42645
42786
  const timeoutSignal = timeoutMs === void 0 ? void 0 : AbortSignal.timeout(timeoutMs);
42646
42787
  const signal = externalSignal === void 0 ? timeoutSignal : timeoutSignal === void 0 ? externalSignal : AbortSignal.any([externalSignal, timeoutSignal]);
42647
42788
  const res = await fetch(url, {
@@ -42654,47 +42795,47 @@ async function alchemyRpc(chainId, method, params, timeoutMs, externalSignal) {
42654
42795
  params
42655
42796
  }),
42656
42797
  ...signal === void 0 ? {} : { signal }
42657
- }).catch(rethrowProvider(method));
42798
+ }).catch(rethrowProvider(chainId, method));
42658
42799
  if (!res.ok) {
42659
42800
  const body = await res.text().catch(() => "<no body>");
42660
- throw Errors.providerError(providerFor(method), `${method} ${res.status}`, body);
42801
+ throw rpcProviderError(`${method} ${res.status}`, body, chainId);
42661
42802
  }
42662
42803
  let json;
42663
42804
  try {
42664
42805
  json = await res.json();
42665
42806
  } catch (cause) {
42666
- throw Errors.providerError(providerFor(method), `${method} json`, cause);
42807
+ throw rpcProviderError(`${method} json`, cause, chainId);
42667
42808
  }
42668
- if (!isValidJsonRpcEnvelope(json)) throw Errors.providerError(providerFor(method), method, "malformed JSON-RPC envelope");
42809
+ if (!isValidJsonRpcEnvelope(json)) throw rpcProviderError(method, "malformed JSON-RPC envelope", chainId);
42669
42810
  if (json.error !== void 0) {
42670
- if (!isValidJsonRpcError(json.error)) throw Errors.providerError(providerFor(method), method, "malformed JSON-RPC error");
42671
- throw Errors.providerError(providerFor(method), method, method === "eth_sendUserOperation" ? new DefinitiveUserOperationRpcRejection() : json.error.message);
42811
+ if (!isValidJsonRpcError(json.error)) throw rpcProviderError(method, "malformed JSON-RPC error", chainId);
42812
+ throw rpcProviderError(method, method === "eth_sendUserOperation" ? new DefinitiveBundlerJsonRpcRejection() : json.error.message, chainId);
42672
42813
  }
42673
- if (json.result === void 0) throw Errors.providerError(providerFor(method), method, "missing result");
42814
+ if (json.result === void 0) throw rpcProviderError(method, "missing result", chainId);
42674
42815
  return json.result;
42675
42816
  }
42676
- function parseReceiptLogs(raw) {
42817
+ function parseReceiptLogs(raw, chainId) {
42677
42818
  if (raw === void 0 || raw === null) return [];
42678
- if (!Array.isArray(raw)) throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", "logs is not an array");
42819
+ if (!Array.isArray(raw)) throw rpcProviderError("eth_getUserOperationReceipt", "logs is not an array", chainId);
42679
42820
  return raw.map((entry) => {
42680
- if (typeof entry !== "object" || entry === null || typeof entry.address !== "string" || !Array.isArray(entry.topics) || typeof entry.data !== "string") throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", `malformed receipt log: ${JSON.stringify(entry)}`);
42821
+ if (typeof entry !== "object" || entry === null || typeof entry.address !== "string" || !Array.isArray(entry.topics) || typeof entry.data !== "string") throw rpcProviderError("eth_getUserOperationReceipt", `malformed receipt log: ${JSON.stringify(entry)}`, chainId);
42681
42822
  const log = entry;
42682
42823
  const operation = "eth_getUserOperationReceipt";
42683
- if (log.logIndex !== void 0 && typeof log.logIndex !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid logIndex");
42684
- if (log.blockNumber !== void 0 && typeof log.blockNumber !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid blockNumber");
42685
- if (log.blockHash !== void 0 && typeof log.blockHash !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid blockHash");
42686
- if (log.transactionHash !== void 0 && typeof log.transactionHash !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid transactionHash");
42687
- if (log.transactionIndex !== void 0 && typeof log.transactionIndex !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid transactionIndex");
42688
- if (log.removed !== void 0 && typeof log.removed !== "boolean") throw Errors.providerError(providerFor(operation), operation, "invalid removed");
42824
+ if (log.logIndex !== void 0 && typeof log.logIndex !== "string") throw rpcProviderError(operation, "invalid logIndex", chainId);
42825
+ if (log.blockNumber !== void 0 && typeof log.blockNumber !== "string") throw rpcProviderError(operation, "invalid blockNumber", chainId);
42826
+ if (log.blockHash !== void 0 && typeof log.blockHash !== "string") throw rpcProviderError(operation, "invalid blockHash", chainId);
42827
+ if (log.transactionHash !== void 0 && typeof log.transactionHash !== "string") throw rpcProviderError(operation, "invalid transactionHash", chainId);
42828
+ if (log.transactionIndex !== void 0 && typeof log.transactionIndex !== "string") throw rpcProviderError(operation, "invalid transactionIndex", chainId);
42829
+ if (log.removed !== void 0 && typeof log.removed !== "boolean") throw rpcProviderError(operation, "invalid removed", chainId);
42689
42830
  return {
42690
- address: providerAddress(log.address, operation, "log address"),
42691
- topics: log.topics.map((topic, index) => providerBytes32(topic, operation, `topic ${String(index)}`)),
42692
- data: providerData(log.data, operation, "log data"),
42693
- ...typeof log.logIndex === "string" ? { logIndex: hexToSafeInteger(log.logIndex, operation) } : {},
42694
- ...typeof log.blockNumber === "string" ? { blockNumber: hexToSafeInteger(log.blockNumber, operation) } : {},
42695
- ...typeof log.blockHash === "string" ? { blockHash: providerBytes32(log.blockHash, operation, "blockHash") } : {},
42696
- ...typeof log.transactionHash === "string" ? { transactionHash: providerBytes32(log.transactionHash, operation, "transactionHash") } : {},
42697
- ...typeof log.transactionIndex === "string" ? { transactionIndex: hexToSafeInteger(log.transactionIndex, operation) } : {},
42831
+ address: providerAddress(log.address, operation, "log address", chainId),
42832
+ topics: log.topics.map((topic, index) => providerBytes32(topic, operation, `topic ${String(index)}`, chainId)),
42833
+ data: providerData(log.data, operation, "log data", chainId),
42834
+ ...typeof log.logIndex === "string" ? { logIndex: hexToSafeInteger(log.logIndex, operation, chainId) } : {},
42835
+ ...typeof log.blockNumber === "string" ? { blockNumber: hexToSafeInteger(log.blockNumber, operation, chainId) } : {},
42836
+ ...typeof log.blockHash === "string" ? { blockHash: providerBytes32(log.blockHash, operation, "blockHash", chainId) } : {},
42837
+ ...typeof log.transactionHash === "string" ? { transactionHash: providerBytes32(log.transactionHash, operation, "transactionHash", chainId) } : {},
42838
+ ...typeof log.transactionIndex === "string" ? { transactionIndex: hexToSafeInteger(log.transactionIndex, operation, chainId) } : {},
42698
42839
  ...typeof log.removed === "boolean" ? { removed: log.removed } : {}
42699
42840
  };
42700
42841
  });
@@ -42702,17 +42843,17 @@ function parseReceiptLogs(raw) {
42702
42843
  async function fetchUserOperationReceipt(args) {
42703
42844
  const raw = await alchemyRpc(args.chainId, "eth_getUserOperationReceipt", [args.userOpHash]);
42704
42845
  if (raw === null) return null;
42705
- if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.blockHash !== "string" || typeof raw.receipt.transactionHash !== "string" || typeof raw.receipt.transactionIndex !== "string") throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`);
42846
+ if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.blockHash !== "string" || typeof raw.receipt.transactionHash !== "string" || typeof raw.receipt.transactionIndex !== "string") throw rpcProviderError("eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42706
42847
  return {
42707
- userOpHash: providerBytes32(raw.userOpHash, "eth_getUserOperationReceipt", "userOpHash"),
42708
- sender: providerAddress(raw.sender, "eth_getUserOperationReceipt", "sender"),
42848
+ userOpHash: providerBytes32(raw.userOpHash, "eth_getUserOperationReceipt", "userOpHash", args.chainId),
42849
+ sender: providerAddress(raw.sender, "eth_getUserOperationReceipt", "sender", args.chainId),
42709
42850
  success: raw.success,
42710
42851
  receipt: {
42711
- blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt"),
42712
- blockHash: providerBytes32(raw.receipt.blockHash, "eth_getUserOperationReceipt", "blockHash"),
42713
- transactionHash: providerBytes32(raw.receipt.transactionHash, "eth_getUserOperationReceipt", "transactionHash"),
42714
- transactionIndex: hexToSafeInteger(raw.receipt.transactionIndex, "eth_getUserOperationReceipt"),
42715
- logs: parseReceiptLogs(raw.logs)
42852
+ blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt", args.chainId),
42853
+ blockHash: providerBytes32(raw.receipt.blockHash, "eth_getUserOperationReceipt", "blockHash", args.chainId),
42854
+ transactionHash: providerBytes32(raw.receipt.transactionHash, "eth_getUserOperationReceipt", "transactionHash", args.chainId),
42855
+ transactionIndex: hexToSafeInteger(raw.receipt.transactionIndex, "eth_getUserOperationReceipt", args.chainId),
42856
+ logs: parseReceiptLogs(raw.logs, args.chainId)
42716
42857
  }
42717
42858
  };
42718
42859
  }
@@ -42721,16 +42862,16 @@ async function fetchUserOperationReceipt(args) {
42721
42862
  * `Errors.providerError` if the value exceeds `Number.MAX_SAFE_INTEGER`
42722
42863
  * (would silently round under `parseInt` per `.claude/rules/numeric-parsing.md`).
42723
42864
  */
42724
- function hexToSafeInteger(hex, op) {
42725
- if (typeof hex !== "string" || !QUANTITY_HEX.test(hex)) throw Errors.providerError(providerFor(op), op, `expected a canonical hex quantity, got ${String(hex)}`);
42865
+ function hexToSafeInteger(hex, op, chainId) {
42866
+ if (typeof hex !== "string" || !QUANTITY_HEX.test(hex)) throw rpcProviderError(op, `expected a canonical hex quantity, got ${String(hex)}`, chainId);
42726
42867
  let big;
42727
42868
  try {
42728
42869
  big = BigInt(hex);
42729
42870
  } catch (cause) {
42730
- throw Errors.providerError(providerFor(op), op, `invalid hex integer: ${hex} (${String(cause)})`);
42871
+ throw rpcProviderError(op, `invalid hex integer: ${hex} (${String(cause)})`, chainId);
42731
42872
  }
42732
42873
  const n = Number(big);
42733
- if (!Number.isSafeInteger(n)) throw Errors.providerError(providerFor(op), op, `hex value ${hex} exceeds MAX_SAFE_INTEGER`);
42874
+ if (!Number.isSafeInteger(n)) throw rpcProviderError(op, `hex value ${hex} exceeds MAX_SAFE_INTEGER`, chainId);
42734
42875
  return n;
42735
42876
  }
42736
42877
  /**
@@ -42751,8 +42892,8 @@ async function fetchCommitmentState(args) {
42751
42892
  to: CAPXUL_PAYMENTS_V2_ADDRESS,
42752
42893
  data
42753
42894
  }, "latest"]);
42754
- if (typeof raw !== "string" || !raw.startsWith("0x")) throw Errors.providerError("alchemy", "eth_call commitments", `unexpected shape: ${String(raw)}`);
42755
- if (raw === "0x") throw Errors.providerError("alchemy", "eth_call commitments", "empty commitments() return (0x)");
42895
+ if (typeof raw !== "string" || !raw.startsWith("0x")) throw rpcProviderError("eth_call commitments", `unexpected shape: ${String(raw)}`, args.chainId);
42896
+ if (raw === "0x") throw rpcProviderError("eth_call commitments", "empty commitments() return (0x)", args.chainId);
42756
42897
  let decoded;
42757
42898
  try {
42758
42899
  decoded = decodeFunctionResult({
@@ -42761,7 +42902,7 @@ async function fetchCommitmentState(args) {
42761
42902
  data: raw
42762
42903
  });
42763
42904
  } catch (cause) {
42764
- throw Errors.providerError("alchemy", "eth_call commitments", `decode failed: ${String(cause)}`);
42905
+ throw rpcProviderError("eth_call commitments", `decode failed: ${String(cause)}`, args.chainId);
42765
42906
  }
42766
42907
  const [settlementId, creator, recipient, token, totalAmount, claimed, startTime, cliffTime, endTime, kind, documentHash, cancelled] = decoded;
42767
42908
  return {
@@ -42810,31 +42951,28 @@ async function fetchEntryPointNonce(args) {
42810
42951
  try {
42811
42952
  return BigInt(result);
42812
42953
  } catch (cause) {
42813
- throw Errors.providerError("alchemy", "eth_call getNonce", `invalid nonce ${result} (${String(cause)})`);
42954
+ throw rpcProviderError("eth_call getNonce", `invalid nonce ${result} (${String(cause)})`, args.chainId);
42814
42955
  }
42815
42956
  }
42816
42957
  /** EIP-1559 max + priority fees with a 2x base-fee inclusion buffer. */
42817
42958
  async function fetchUserOperationFees(args) {
42818
- const priority = parseAlchemyQuantity(await alchemyRpc(args.chainId, "eth_maxPriorityFeePerGas", []), "eth_maxPriorityFeePerGas", "maxPriorityFeePerGas");
42959
+ const priority = parseRpcQuantity(await alchemyRpc(args.chainId, "eth_maxPriorityFeePerGas", []), "eth_maxPriorityFeePerGas", "maxPriorityFeePerGas", args.chainId);
42819
42960
  const block = await alchemyRpc(args.chainId, "eth_getBlockByNumber", ["latest", false]);
42820
- if (block.baseFeePerGas === void 0) {
42821
- const blockRef = block.number ?? block.hash ?? "<unknown>";
42822
- throw Errors.providerError("alchemy", "eth_getBlockByNumber baseFeePerGas", `missing baseFeePerGas in latest block ${blockRef}: ${JSON.stringify(block)}`);
42823
- }
42961
+ if (block.baseFeePerGas === void 0) throw rpcProviderError("eth_getBlockByNumber baseFeePerGas", `missing baseFeePerGas in latest block ${block.number ?? block.hash ?? "<unknown>"}: ${JSON.stringify(block)}`, args.chainId);
42824
42962
  return {
42825
- maxFeePerGas: parseAlchemyQuantity(block.baseFeePerGas, "eth_getBlockByNumber", "baseFeePerGas") * EIP1559_BASE_FEE_BUFFER_MULTIPLIER + priority,
42963
+ maxFeePerGas: parseRpcQuantity(block.baseFeePerGas, "eth_getBlockByNumber", "baseFeePerGas", args.chainId) * EIP1559_BASE_FEE_BUFFER_MULTIPLIER + priority,
42826
42964
  maxPriorityFeePerGas: priority
42827
42965
  };
42828
42966
  }
42829
42967
  async function estimateUserOperationGas(args) {
42830
42968
  const raw = await alchemyRpc(args.chainId, "eth_estimateUserOperationGas", [args.userOp, ENTRY_POINT_07_ADDRESS]);
42831
- if (typeof raw !== "object" || typeof raw.preVerificationGas !== "string" || typeof raw.verificationGasLimit !== "string" || typeof raw.callGasLimit !== "string") throw Errors.providerError("account-abstraction", "eth_estimateUserOperationGas", `unexpected shape: ${JSON.stringify(raw)}`);
42969
+ if (typeof raw !== "object" || typeof raw.preVerificationGas !== "string" || typeof raw.verificationGasLimit !== "string" || typeof raw.callGasLimit !== "string") throw rpcProviderError("eth_estimateUserOperationGas", `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42832
42970
  return raw;
42833
42971
  }
42834
- function optionalPaymasterHex(raw, method, field) {
42972
+ function optionalPaymasterHex(raw, method, field, chainId) {
42835
42973
  const value = raw[field];
42836
42974
  if (value === void 0) return void 0;
42837
- if (typeof value !== "string" || !isHex(value)) throw Errors.providerError("account-abstraction", method, `unexpected ${field}: expected hex string`);
42975
+ if (typeof value !== "string" || !isHex(value)) throw rpcProviderError(method, `unexpected ${field}: expected hex string`, chainId);
42838
42976
  return value;
42839
42977
  }
42840
42978
  function definedPaymasterFields(result) {
@@ -42852,12 +42990,12 @@ async function paymasterRpc(method, args) {
42852
42990
  toHex(args.chainId),
42853
42991
  {}
42854
42992
  ]);
42855
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw Errors.providerError("account-abstraction", method, `unexpected shape: ${JSON.stringify(raw)}`);
42993
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw rpcProviderError(method, `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42856
42994
  const result = raw;
42857
- const paymaster = optionalPaymasterHex(result, method, "paymaster");
42858
- const paymasterData = optionalPaymasterHex(result, method, "paymasterData");
42859
- const paymasterVerificationGasLimit = optionalPaymasterHex(result, method, "paymasterVerificationGasLimit");
42860
- const paymasterPostOpGasLimit = optionalPaymasterHex(result, method, "paymasterPostOpGasLimit");
42995
+ const paymaster = optionalPaymasterHex(result, method, "paymaster", args.chainId);
42996
+ const paymasterData = optionalPaymasterHex(result, method, "paymasterData", args.chainId);
42997
+ const paymasterVerificationGasLimit = optionalPaymasterHex(result, method, "paymasterVerificationGasLimit", args.chainId);
42998
+ const paymasterPostOpGasLimit = optionalPaymasterHex(result, method, "paymasterPostOpGasLimit", args.chainId);
42861
42999
  return {
42862
43000
  ...paymaster === void 0 ? {} : { paymaster },
42863
43001
  ...paymasterData === void 0 ? {} : { paymasterData },
@@ -42873,7 +43011,7 @@ function getPaymasterStubData(args) {
42873
43011
  function getPaymasterData(args) {
42874
43012
  return paymasterRpc("pm_getPaymasterData", args);
42875
43013
  }
42876
- /** Sponsor one Base Sepolia UserOperation through the owned ERC-7677 gateway. */
43014
+ /** Run the owned ERC-7677 sponsorship flow. */
42877
43015
  async function sponsorUserOperation(args) {
42878
43016
  let request = args.userOp;
42879
43017
  request = {
@@ -42904,7 +43042,7 @@ async function sponsorUserOperation(args) {
42904
43042
  userOp: request
42905
43043
  }))
42906
43044
  };
42907
- if (request.paymaster === void 0 || request.paymasterData === void 0) throw Errors.providerError("account-abstraction", "pm_getPaymasterData", "missing paymaster sponsorship");
43045
+ if (request.paymaster === void 0 || request.paymasterData === void 0) throw rpcProviderError("pm_getPaymasterData", "missing paymaster sponsorship", args.chainId);
42908
43046
  return {
42909
43047
  ...request,
42910
43048
  paymaster: request.paymaster,
@@ -42914,7 +43052,7 @@ async function sponsorUserOperation(args) {
42914
43052
  /** Submit the signed UserOperation through the bundler — returns the userOpHash. */
42915
43053
  async function sendUserOperation(args) {
42916
43054
  const hash = await alchemyRpc(args.chainId, "eth_sendUserOperation", [args.userOp, ENTRY_POINT_07_ADDRESS]);
42917
- if (typeof hash !== "string" || !TX_HASH_HEX.test(hash)) throw Errors.providerError("account-abstraction", "eth_sendUserOperation", `unexpected hash: ${String(hash)}; expected 0x-prefixed 32-byte hex`);
43055
+ if (typeof hash !== "string" || !TX_HASH_HEX.test(hash)) throw rpcProviderError("eth_sendUserOperation", `unexpected hash: ${String(hash)}; expected 0x-prefixed 32-byte hex`, args.chainId);
42918
43056
  return hash;
42919
43057
  }
42920
43058
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "2.3.2",
3
+ "version": "2.4.0",
4
4
  "private": false,
5
5
  "description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
6
6
  "keywords": [
@@ -47,12 +47,12 @@
47
47
  "typescript": "npm:@typescript/typescript6@6.0.2",
48
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
49
49
  "vite-plus": "0.1.23",
50
- "@capxul/backend": "0.2.5",
50
+ "@capxul/backend": "0.2.6",
51
51
  "@capxul/config": "0.2.0",
52
- "@capxul/sdk": "2.3.2",
52
+ "@capxul/sdk": "2.4.0",
53
53
  "@capxul/types": "0.2.0",
54
54
  "@capxul/typescript-config": "0.0.0",
55
- "@capxul/wire": "0.4.0"
55
+ "@capxul/wire": "0.5.0"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "vp exec tsx src/main.ts serve",