@capxul/mcp 1.0.0-alpha.21 → 1.0.0-alpha.22

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 +156 -39
  2. package/package.json +6 -6
package/dist/main.mjs CHANGED
@@ -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.21";
235
+ var version$1 = "1.0.0-alpha.22";
236
236
  //#endregion
237
237
  //#region src/tool-result.ts
238
238
  function okResult(structured) {
@@ -5342,7 +5342,7 @@ async function recoverRawDigestSigner(input) {
5342
5342
  }
5343
5343
  //#endregion
5344
5344
  //#region ../../packages/sdk/package.json
5345
- var version = "1.0.0-alpha.21";
5345
+ var version = "1.0.0-alpha.22";
5346
5346
  //#endregion
5347
5347
  //#region ../../packages/sdk/src/ports/auth-client.ts
5348
5348
  var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
@@ -6886,6 +6886,8 @@ function brandProfile(raw) {
6886
6886
  country: raw.country === null ? null : toCountryCode(raw.country),
6887
6887
  onboarded: raw.onboarded ?? false,
6888
6888
  withdrawalAddress: raw.withdrawalAddress === null || raw.withdrawalAddress === void 0 ? null : toAddress(raw.withdrawalAddress),
6889
+ username: raw.username ?? null,
6890
+ imageUrl: raw.imageUrl ?? null,
6889
6891
  kycTier: toKycTier(raw.kycTier),
6890
6892
  createdAt: toEpochMs(raw.createdAt),
6891
6893
  updatedAt: toEpochMs(raw.updatedAt)
@@ -7215,7 +7217,10 @@ function brandOrgView(wire, treasury, viewerRole) {
7215
7217
  handle: wire.slug,
7216
7218
  safeAddress: toAddress(wire.safeAddress.toLowerCase()),
7217
7219
  role: viewerRole,
7218
- treasury
7220
+ treasury,
7221
+ bio: wire.bio ?? null,
7222
+ size: wire.size ?? null,
7223
+ logoUrl: wire.logoUrl ?? null
7219
7224
  };
7220
7225
  }
7221
7226
  /**
@@ -9733,14 +9738,29 @@ const loadIdentityProgram = Effect.gen(function* () {
9733
9738
  });
9734
9739
  //#endregion
9735
9740
  //#region ../../packages/sdk/src/client/identity.ts
9741
+ const usernameAvailableQuery = makeFunctionReference("identity/queries:usernameAvailable");
9736
9742
  function makeIdentityMethods(deps) {
9737
- return { async loadCurrent(options) {
9738
- if (options?.signal?.aborted) return {
9739
- ok: false,
9740
- error: Errors.cancelled({ operation: "identity.loadCurrent" })
9741
- };
9742
- return toCapxulResult(loadIdentityProgram, identityDepsLayer(deps));
9743
- } };
9743
+ const convexCall = deps.convexCall;
9744
+ return {
9745
+ async loadCurrent(options) {
9746
+ if (options?.signal?.aborted) return {
9747
+ ok: false,
9748
+ error: Errors.cancelled({ operation: "identity.loadCurrent" })
9749
+ };
9750
+ return toCapxulResult(loadIdentityProgram, identityDepsLayer(deps));
9751
+ },
9752
+ async usernameAvailable(username, options) {
9753
+ if (options?.signal?.aborted) return {
9754
+ ok: false,
9755
+ error: Errors.cancelled({ operation: "identity.usernameAvailable" })
9756
+ };
9757
+ if (convexCall === void 0) return {
9758
+ ok: false,
9759
+ error: Errors.notImplemented("identity", "usernameAvailable")
9760
+ };
9761
+ return runPortEffect(convexCall.query(usernameAvailableQuery, { username }));
9762
+ }
9763
+ };
9744
9764
  }
9745
9765
  //#endregion
9746
9766
  //#region ../../packages/sdk/src/client/_shared/money-telemetry.ts
@@ -10072,32 +10092,36 @@ function makeFinancialOpsMethods(deps) {
10072
10092
  } },
10073
10093
  destinations: {
10074
10094
  add: async (input, options) => {
10075
- const ref = normalizeDestinationInputRef(input, "target");
10076
- if (!ref.ok) return {
10095
+ const scope = normalizeDestinationInputScope(input, "target");
10096
+ if (!scope.ok) return {
10077
10097
  ok: false,
10078
- error: ref.error
10098
+ error: scope.error
10079
10099
  };
10080
- if (ref.value === void 0) return {
10100
+ const scopeValue = scope.value;
10101
+ if (scopeValue === void 0) return {
10081
10102
  ok: false,
10082
- error: Errors.invalidInput("target", "required for destinations.add")
10103
+ error: Errors.invalidInput("target", DESTINATION_SCOPE_MESSAGE)
10083
10104
  };
10105
+ const backendActor = actorReferenceToBackend(input.actor);
10084
10106
  return mapOk$1(await runIfActive(options?.signal, "destinations.add", () => deps.convexCall.mutation(fns.addDestination, {
10085
- ...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
10086
- ref: ref.value,
10107
+ ...backendActor === void 0 ? {} : { actor: backendActor },
10108
+ ...isSelfTarget(scopeValue) ? { self: true } : { ref: scopeValue },
10087
10109
  kind: destinationKindToBackend(input.kind),
10088
10110
  ...input.label === void 0 ? {} : { label: input.label },
10089
10111
  payload: input.payload
10090
10112
  })), destinationFromBackend);
10091
10113
  },
10092
10114
  list: async (input, options) => {
10093
- const ref = normalizeDestinationInputRef(input, "target");
10094
- if (!ref.ok) return {
10115
+ const scope = normalizeDestinationInputScope(input, "target");
10116
+ if (!scope.ok) return {
10095
10117
  ok: false,
10096
- error: ref.error
10118
+ error: scope.error
10097
10119
  };
10120
+ const scopeValue = scope.value;
10098
10121
  return mapOk$1(await runIfActive(options?.signal, "destinations.list", () => deps.convexCall.query(fns.listDestinations, {
10099
10122
  ...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
10100
- ...ref.value === void 0 ? {} : { ref: ref.value }
10123
+ ...scopeValue !== void 0 && isSelfTarget(scopeValue) ? { self: true } : {},
10124
+ ...scopeValue !== void 0 && !isSelfTarget(scopeValue) ? { ref: scopeValue } : {}
10101
10125
  })), (destinations) => destinations.map(destinationFromBackend).filter((destination) => input.kind === void 0 || destination.kind === input.kind));
10102
10126
  },
10103
10127
  remove: (input, options) => runIfActive(options?.signal, "destinations.remove", () => deps.convexCall.mutation(fns.removeDestination, {
@@ -10372,8 +10396,28 @@ function normalizeTargetForBackend(reference, field) {
10372
10396
  const ref = refFromTargetReference(reference, field);
10373
10397
  return ref.ok ? normalizeRefForBackend(ref.value, field) : ref;
10374
10398
  }
10375
- function normalizeDestinationInputRef(input, field) {
10376
- if (input.target !== void 0) return normalizeTargetForBackend(input.target, field);
10399
+ const DESTINATION_SCOPE_MESSAGE = "provide exactly one of target or ref; use target: { self: true } for your own destination";
10400
+ /** #1063: detect the `{ self: true }` variant of a destination target. */
10401
+ function isSelfTarget(value) {
10402
+ return "self" in value;
10403
+ }
10404
+ /**
10405
+ * #1063: resolve the public `target`/`ref` pair — `SelfTarget` for the actor's
10406
+ * own destination, a `BackendRef` for a counterparty, `undefined` when unscoped.
10407
+ */
10408
+ function normalizeDestinationInputScope(input, field) {
10409
+ const target = input.target;
10410
+ if (target !== void 0 && isSelfTarget(target)) {
10411
+ if (input.ref !== void 0) return {
10412
+ ok: false,
10413
+ error: Errors.invalidInput(field, DESTINATION_SCOPE_MESSAGE)
10414
+ };
10415
+ return {
10416
+ ok: true,
10417
+ value: target
10418
+ };
10419
+ }
10420
+ if (target !== void 0) return normalizeTargetForBackend(target, field);
10377
10421
  if (input.ref !== void 0) return normalizeDestinationRefForBackend(input.ref, "ref");
10378
10422
  return {
10379
10423
  ok: true,
@@ -10469,7 +10513,8 @@ function destinationRailFromBackend(destination) {
10469
10513
  function destinationFromBackend(destination) {
10470
10514
  return {
10471
10515
  ...destination,
10472
- target: targetReferenceFromBackendRef(destination.ref),
10516
+ target: destination.ref === null ? null : targetReferenceFromBackendRef(destination.ref),
10517
+ ownerScope: destination.ownerScope ?? "counterparty",
10473
10518
  kind: destinationKindFromBackend(destination.kind),
10474
10519
  rail: destinationRailFromBackend(destination)
10475
10520
  };
@@ -10556,6 +10601,7 @@ function mapOk$1(result, f) {
10556
10601
  throw cause;
10557
10602
  }
10558
10603
  }
10604
+ /** Internal signal-aware Effect→CapxulResult bridge, shared with `media.ts`. */
10559
10605
  async function runIfActive(signal, operation, effect) {
10560
10606
  if (signal?.aborted === true) return {
10561
10607
  ok: false,
@@ -10572,6 +10618,51 @@ async function runIfActive(signal, operation, effect) {
10572
10618
  };
10573
10619
  }
10574
10620
  //#endregion
10621
+ //#region ../../packages/sdk/src/client/media.ts
10622
+ const generateUploadUrlFn = makeFunctionReference("media:generateUploadUrl");
10623
+ const setProfileImageFn = makeFunctionReference("media:setProfileImage");
10624
+ const setOrgLogoFn = makeFunctionReference("media:setOrgLogo");
10625
+ function makeMediaMethods(deps) {
10626
+ const fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
10627
+ return {
10628
+ async uploadImage(blob, options) {
10629
+ const url = await runIfActive(options?.signal, "media.uploadImage", () => deps.convexCall.mutation(generateUploadUrlFn, {}));
10630
+ if (!url.ok) return url;
10631
+ try {
10632
+ const response = await fetchImpl(url.value.uploadUrl, {
10633
+ method: "POST",
10634
+ headers: { "Content-Type": blob.type },
10635
+ body: blob,
10636
+ ...options?.signal === void 0 ? {} : { signal: options.signal }
10637
+ });
10638
+ if (!response.ok) return {
10639
+ ok: false,
10640
+ error: Errors.providerError("convex-storage", "uploadImage", `upload failed with status ${response.status}`)
10641
+ };
10642
+ const parsed = await response.json();
10643
+ if (typeof parsed.storageId !== "string" || parsed.storageId.length === 0) return {
10644
+ ok: false,
10645
+ error: Errors.providerError("convex-storage", "uploadImage", "upload response carried no storageId")
10646
+ };
10647
+ return {
10648
+ ok: true,
10649
+ value: { storageId: parsed.storageId }
10650
+ };
10651
+ } catch (cause) {
10652
+ return {
10653
+ ok: false,
10654
+ error: Errors.providerError("convex-storage", "uploadImage", cause)
10655
+ };
10656
+ }
10657
+ },
10658
+ setProfileImage: (input, options) => runIfActive(options?.signal, "media.setProfileImage", () => deps.convexCall.mutation(setProfileImageFn, { storageId: input.storageId })),
10659
+ setOrgLogo: (input, options) => runIfActive(options?.signal, "media.setOrgLogo", () => deps.convexCall.mutation(setOrgLogoFn, {
10660
+ orgId: input.orgId,
10661
+ storageId: input.storageId
10662
+ }))
10663
+ };
10664
+ }
10665
+ //#endregion
10575
10666
  //#region ../../packages/sdk/src/client/sub-accounts-deps.ts
10576
10667
  var SubAccountsDepsTag = class extends Context.Tag("@capxul/sdk/SubAccountsDeps")() {};
10577
10668
  function subAccountsDepsLayer(deps) {
@@ -10864,7 +10955,10 @@ function hermeticOrgView(input) {
10864
10955
  handle: input.handle,
10865
10956
  safeAddress: toAddress(placeholder),
10866
10957
  role: "Owner",
10867
- treasury: zeroTreasury(orgId)
10958
+ treasury: zeroTreasury(orgId),
10959
+ bio: null,
10960
+ size: null,
10961
+ logoUrl: null
10868
10962
  };
10869
10963
  }
10870
10964
  function moneyFromConfig(input) {
@@ -11288,7 +11382,8 @@ function validateOrganizationLifecycleScope(orgId, lifecycle) {
11288
11382
  };
11289
11383
  }
11290
11384
  /** Advance only the steps still required by one durable Organization lane. */
11291
- async function advanceOrganizationSetup(setup, orgId, initial, signal, observationSource) {
11385
+ async function advanceOrganizationSetup(setup, orgId, initial, context) {
11386
+ const { signal, observationSource } = context ?? {};
11292
11387
  const scopedInitial = validateOrganizationLifecycleScope(orgId, initial);
11293
11388
  if (!scopedInitial.ok) return scopedInitial;
11294
11389
  let lifecycle = scopedInitial.value;
@@ -11424,7 +11519,10 @@ function makeOrgMethods(deps) {
11424
11519
  ...options?.signal === void 0 ? {} : { signal: options.signal }
11425
11520
  }));
11426
11521
  if (!retried.ok) return retried;
11427
- return advanceOrganizationSetup(setup, orgId, retried.value, options?.signal, options);
11522
+ return advanceOrganizationSetup(setup, orgId, retried.value, {
11523
+ signal: options?.signal,
11524
+ observationSource: options
11525
+ });
11428
11526
  },
11429
11527
  profile: {
11430
11528
  get(_options) {
@@ -11662,7 +11760,8 @@ async function runCompletePersonalOnboarding(ops, input) {
11662
11760
  email: session.email,
11663
11761
  displayName: validated.value.displayName,
11664
11762
  country: validated.value.country,
11665
- ...validated.value.withdrawalAddress === void 0 ? {} : { withdrawalAddress: validated.value.withdrawalAddress }
11763
+ ...validated.value.withdrawalAddress === void 0 ? {} : { withdrawalAddress: validated.value.withdrawalAddress },
11764
+ ...validated.value.username === void 0 ? {} : { username: validated.value.username }
11666
11765
  });
11667
11766
  if (!written.ok) return fail(written.error);
11668
11767
  const provisioned = await ops.triggerProvisioning();
@@ -11687,7 +11786,8 @@ async function runCompleteOrganizationOnboarding(ops, input, options) {
11687
11786
  email: session.email,
11688
11787
  displayName: validated.value.profile.displayName,
11689
11788
  country: validated.value.profile.country,
11690
- ...validated.value.profile.withdrawalAddress === void 0 ? {} : { withdrawalAddress: validated.value.profile.withdrawalAddress }
11789
+ ...validated.value.profile.withdrawalAddress === void 0 ? {} : { withdrawalAddress: validated.value.profile.withdrawalAddress },
11790
+ ...validated.value.profile.username === void 0 ? {} : { username: validated.value.profile.username }
11691
11791
  });
11692
11792
  if (!written.ok) return fail(written.error);
11693
11793
  const founderAccount = await ops.ensureFounderAccountReady(input);
@@ -11696,10 +11796,15 @@ async function runCompleteOrganizationOnboarding(ops, input, options) {
11696
11796
  const started = await setup.startOrResume(copyInvocationObservation(input, {
11697
11797
  name: validated.value.organization.name,
11698
11798
  handle: validated.value.organization.handle,
11699
- country: validated.value.organization.country
11799
+ country: validated.value.organization.country,
11800
+ ...validated.value.organization.bio === void 0 ? {} : { bio: validated.value.organization.bio },
11801
+ ...validated.value.organization.size === void 0 ? {} : { size: validated.value.organization.size }
11700
11802
  }));
11701
11803
  if (!started.ok) return fail(started.error);
11702
- const lifecycle = await advanceOrganizationSetup(setup, started.value.orgId, started.value.lifecycle, options?.signal, input);
11804
+ const lifecycle = await advanceOrganizationSetup(setup, started.value.orgId, started.value.lifecycle, {
11805
+ signal: options?.signal,
11806
+ observationSource: input
11807
+ });
11703
11808
  if (!lifecycle.ok) {
11704
11809
  const error = lifecycle.error;
11705
11810
  return fail(new CapxulError(error.code, error.message, {
@@ -11742,7 +11847,9 @@ function validateOrganizationInput(input) {
11742
11847
  organization: {
11743
11848
  name: name.value,
11744
11849
  handle: handle.value,
11745
- country: country.value
11850
+ country: country.value,
11851
+ ...input.organization.bio === void 0 ? {} : { bio: input.organization.bio },
11852
+ ...input.organization.size === void 0 ? {} : { size: input.organization.size }
11746
11853
  }
11747
11854
  }
11748
11855
  };
@@ -11752,20 +11859,27 @@ function validateProfileInput(input) {
11752
11859
  if (!displayName.ok) return displayName;
11753
11860
  const country = parseCountry(input.country, "profile.country");
11754
11861
  if (!country.ok) return country;
11862
+ let username;
11863
+ if (input.username !== void 0) {
11864
+ const parsed = requireNonEmpty(input.username, "profile.username");
11865
+ if (!parsed.ok) return parsed;
11866
+ username = parsed.value;
11867
+ }
11868
+ const base = {
11869
+ displayName: displayName.value,
11870
+ country: country.value,
11871
+ ...username === void 0 ? {} : { username }
11872
+ };
11755
11873
  if (input.withdrawalAddress === void 0) return {
11756
11874
  ok: true,
11757
- value: {
11758
- displayName: displayName.value,
11759
- country: country.value
11760
- }
11875
+ value: base
11761
11876
  };
11762
11877
  const withdrawalAddress = parseAddress(input.withdrawalAddress, "profile.withdrawalAddress");
11763
11878
  if (!withdrawalAddress.ok) return withdrawalAddress;
11764
11879
  return {
11765
11880
  ok: true,
11766
11881
  value: {
11767
- displayName: displayName.value,
11768
- country: country.value,
11882
+ ...base,
11769
11883
  withdrawalAddress: withdrawalAddress.value
11770
11884
  }
11771
11885
  };
@@ -12004,8 +12118,10 @@ function assembleCapxulClient(input) {
12004
12118
  });
12005
12119
  const identity = makeIdentityMethods({
12006
12120
  identityPort: input.ports.identity,
12007
- actor
12121
+ actor,
12122
+ convexCall: input.ports.convexCall
12008
12123
  });
12124
+ const media = makeMediaMethods({ convexCall: input.ports.convexCall });
12009
12125
  const accounts = makeAccountsMethods({
12010
12126
  accountReadPort: input.ports.accountRead,
12011
12127
  chainId: input.bootstrap.chainId,
@@ -12081,6 +12197,7 @@ function assembleCapxulClient(input) {
12081
12197
  paymentDocuments: financialOps.paymentDocuments,
12082
12198
  paymentRequests: financialOps.paymentRequests,
12083
12199
  workbench: financialOps.workbench,
12200
+ media,
12084
12201
  subAccounts,
12085
12202
  createOrg: orgMethods.createOrg,
12086
12203
  orgs: orgMethods.orgs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.22",
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": [
@@ -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.5",
55
+ "@capxul/backend": "0.1.0-alpha.6",
56
56
  "@capxul/config": "0.1.0-alpha.3",
57
57
  "@capxul/errors": "0.0.1-alpha.0",
58
- "@capxul/observability": "0.1.0-alpha.1",
59
- "@capxul/sdk": "1.0.0-alpha.21",
60
- "@capxul/types": "0.1.0-alpha.1",
61
- "@capxul/wire": "0.1.0-alpha.3"
58
+ "@capxul/observability": "0.1.0-alpha.2",
59
+ "@capxul/sdk": "1.0.0-alpha.22",
60
+ "@capxul/types": "0.1.0-alpha.2",
61
+ "@capxul/wire": "0.1.0-alpha.4"
62
62
  },
63
63
  "scripts": {
64
64
  "dev": "vp exec tsx src/main.ts serve",