@capxul/mcp 4.1.0 → 4.1.1

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 +143 -49
  2. package/package.json +2 -2
package/dist/main.mjs CHANGED
@@ -4907,7 +4907,20 @@ const QuickPayExternalAddressAcknowledgedProps = Schema.Struct({
4907
4907
  external_address_acknowledged: Schema.Literal(true),
4908
4908
  organization_id: OptionalOrgId
4909
4909
  });
4910
- const DepositInitiatedProps = Schema.Struct({ ...TelemetryEnvelopeProps });
4910
+ const DepositInitiatedProps = Schema.Struct({
4911
+ ...TelemetryEnvelopeProps,
4912
+ scope_kind: Schema.optional(Schema.Literals(["account", "organization"])),
4913
+ account_kind: Schema.optional(Schema.Literals(["personalSafe", "orgTreasury"])),
4914
+ chain_id: Schema.optional(Schema.Number),
4915
+ network: Schema.optional(Schema.Literal("base-sepolia")),
4916
+ organization_id: OptionalOrgId,
4917
+ $groups: Schema.optional(Schema.Struct({ organization: OptionalOrgId })),
4918
+ actor_id: OptionalString,
4919
+ actor_kind: Schema.optional(Schema.Literal("authenticated")),
4920
+ distinct_id: OptionalString,
4921
+ trace_id: OptionalString,
4922
+ span_id: OptionalString
4923
+ });
4911
4924
  const DepositSettledProps = Schema.Struct({
4912
4925
  ...TelemetryEnvelopeProps,
4913
4926
  chain_id: Schema.Number,
@@ -10320,6 +10333,23 @@ function observationOnlyControls(controls) {
10320
10333
  const { signal: _signal, timeoutMs: _timeoutMs, deadlineMs: _deadlineMs, ...observation } = controls ?? {};
10321
10334
  return copyInvocationObservation(controls, observation);
10322
10335
  }
10336
+ /** Project only SDK-owned facts. A caller Organization hint is not authority. */
10337
+ function verifiedOperationFields(attributes) {
10338
+ const domain = {};
10339
+ const organizationId = attributes.get("verified_organization_id");
10340
+ if (typeof organizationId === "string" && safeEngineeringIdentifier(organizationId) !== void 0) domain.organization_id = organizationId;
10341
+ for (const [key, allowed] of [
10342
+ ["scope_kind", ["account", "organization"]],
10343
+ ["account_kind", ["personalSafe", "orgTreasury"]],
10344
+ ["network", ["base-sepolia"]]
10345
+ ]) {
10346
+ const value = attributes.get(key);
10347
+ if (typeof value === "string" && allowed.some((candidate) => candidate === value)) domain[key] = value;
10348
+ }
10349
+ const chainId = attributes.get("chain_id");
10350
+ if (typeof chainId === "number" && Number.isSafeInteger(chainId) && chainId > 0) domain.chain_id = chainId;
10351
+ return domain;
10352
+ }
10323
10353
  /** Observe a public Effect that already uses the canonical CapxulError channel. */
10324
10354
  async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.runtime.port, runPromise = Effect.runPromise) {
10325
10355
  const invocation = readInvocationObservation(controls);
@@ -10348,8 +10378,10 @@ async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.r
10348
10378
  const error = Exit.isFailure(exit) ? Cause.squash(exit.cause) : void 0;
10349
10379
  const failure = error instanceof CapxulError ? error : void 0;
10350
10380
  const outcome = Exit.isSuccess(exit) ? "succeeded" : failure?.code === "CANCELLED" ? "cancelled" : failure !== void 0 && EXPECTED_OPERATION_OUTCOMES.has(failure.code) ? "refused" : "failed";
10381
+ const span = yield* Effect.currentSpan.pipe(Effect.orDie);
10351
10382
  const completion = {
10352
10383
  ...fields,
10384
+ ...verifiedOperationFields(span.attributes),
10353
10385
  duration_ms,
10354
10386
  outcome,
10355
10387
  ...failure === void 0 ? {} : { failure_code: failure.code },
@@ -11527,7 +11559,7 @@ const moneyExecutionContract = {
11527
11559
  };
11528
11560
  //#endregion
11529
11561
  //#region ../../packages/sdk/package.json
11530
- var version$1 = "4.1.0";
11562
+ var version$1 = "4.1.1";
11531
11563
  //#endregion
11532
11564
  //#region ../../packages/sdk/src/telemetry/exception-projection.ts
11533
11565
  /** Fixed fallback for failures that have no safe message. */
@@ -12034,11 +12066,50 @@ function emitAccountBalanceFailed(telemetry, error) {
12034
12066
  }
12035
12067
  });
12036
12068
  }
12037
- function emitDepositInitiated(telemetry) {
12038
- return emitMoneyTelemetry(telemetry, {
12039
- name: "deposit_initiated",
12040
- props: {}
12041
- });
12069
+ /** A successful authorized instruction read, not an incoming transfer. */
12070
+ function emitDepositInitiated(telemetry, instructions, source, verifiedOrganizationId) {
12071
+ return Effect.gen(function* () {
12072
+ const organizationId = safeEngineeringIdentifier(verifiedOrganizationId);
12073
+ const fields = {
12074
+ scope_kind: organizationId === void 0 ? "account" : "organization",
12075
+ account_kind: organizationId === void 0 ? "personalSafe" : "orgTreasury",
12076
+ ...Number.isSafeInteger(instructions.chainId) && instructions.chainId > 0 ? { chain_id: instructions.chainId } : {},
12077
+ ...instructions.network === "base-sepolia" ? { network: instructions.network } : {},
12078
+ ...organizationId === void 0 ? {} : { verified_organization_id: organizationId }
12079
+ };
12080
+ yield* Effect.annotateCurrentSpan(fields);
12081
+ if (telemetry === void 0) return;
12082
+ const span = yield* Effect.currentSpan;
12083
+ const snapshot = readInvocationObservation(source);
12084
+ const { organizationId: _hint, ...context } = snapshot?.context ?? {};
12085
+ const event = {
12086
+ name: "deposit_initiated",
12087
+ props: {
12088
+ scope_kind: fields.scope_kind,
12089
+ account_kind: fields.account_kind,
12090
+ ...fields.chain_id === void 0 ? {} : { chain_id: fields.chain_id },
12091
+ ...fields.network === void 0 ? {} : { network: fields.network },
12092
+ $groups: organizationId === void 0 ? {} : { organization: organizationId },
12093
+ ...safeEngineeringIdentifier(snapshot?.actorId) === void 0 ? {} : {
12094
+ actor_id: snapshot.actorId,
12095
+ actor_kind: "authenticated",
12096
+ distinct_id: snapshot.actorId
12097
+ },
12098
+ trace_id: span.traceId,
12099
+ span_id: span.spanId,
12100
+ ...organizationId === void 0 ? {} : { organization_id: organizationId }
12101
+ }
12102
+ };
12103
+ yield* telemetry.emit(snapshot === void 0 ? event : attachInvocationObservation(event, {
12104
+ active: snapshot.active,
12105
+ ...snapshot?.actorId === void 0 ? {} : { actorId: snapshot.actorId },
12106
+ context: {
12107
+ ...context,
12108
+ ...organizationId === void 0 ? {} : { organizationId },
12109
+ traceparent: `00-${span.traceId}-${span.spanId}-01`
12110
+ }
12111
+ }));
12112
+ }).pipe(Effect.catchCause(() => Effect.void));
12042
12113
  }
12043
12114
  function emitPaymentInitiated(telemetry, input) {
12044
12115
  return emitMoneyTelemetry(telemetry, {
@@ -12654,7 +12725,10 @@ function makeFinancialOpsMethods(deps) {
12654
12725
  return {
12655
12726
  me: {
12656
12727
  get: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.me.get, () => deps.convexCall.query(fns.me, {})),
12657
- depositInstructions: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.me.depositInstructions, () => deps.convexCall.query(fns.depositInstructions, {}).pipe(Effect.tap(() => Effect.promise(() => emitDepositInitiated(deps.telemetry)))))
12728
+ depositInstructions: (options) => {
12729
+ const controls = deps.invocationControls?.(options) ?? options;
12730
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.depositInstructions, copyInvocationObservation(controls, {}))).pipe(Effect.tap((instructions) => emitDepositInitiated(deps.telemetry, instructions, controls))), controls, CAPXUL_OPERATIONS.me.depositInstructions, deps.runPromise);
12731
+ }
12658
12732
  },
12659
12733
  targets: { resolve: async (reference, options) => {
12660
12734
  const recipient = normalizeTargetForBackend(reference, "reference");
@@ -12662,43 +12736,57 @@ function makeFinancialOpsMethods(deps) {
12662
12736
  return mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.recipient.resolve, () => deps.convexCall.query(fns.resolveRecipient, { recipient: recipient.value })), resolvedTargetFromResolution);
12663
12737
  } },
12664
12738
  destinations: {
12665
- add: async (input, options) => {
12666
- const scope = normalizeDestinationInputScope(input, "target");
12667
- if (!scope.ok) return {
12668
- ok: false,
12669
- error: scope.error
12670
- };
12671
- const scopeValue = scope.value;
12672
- if (scopeValue === void 0) return {
12673
- ok: false,
12674
- error: Errors.invalidInput("target", DESTINATION_SCOPE_MESSAGE)
12739
+ add: (input, options) => {
12740
+ const controls = deps.invocationControls?.(options) ?? options;
12741
+ const actor = actorReferenceToBackend(input.actor);
12742
+ const verifiedScope = {
12743
+ scope_kind: actor?.kind === "org" ? "organization" : "account",
12744
+ ...actor?.kind === "org" ? { verified_organization_id: actor.orgId } : {}
12675
12745
  };
12676
- const backendActor = actorReferenceToBackend(input.actor);
12677
- return mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.destinations.add, () => deps.convexCall.mutation(fns.addDestination, {
12678
- ...backendActor === void 0 ? {} : { actor: backendActor },
12679
- ...isSelfTarget(scopeValue) ? { self: true } : { ref: scopeValue },
12680
- kind: destinationKindToBackend(input.kind),
12681
- ...input.label === void 0 ? {} : { label: input.label },
12682
- payload: input.payload
12683
- })), destinationFromBackend);
12746
+ return runPortEffect(Effect.suspend(() => {
12747
+ const scope = normalizeDestinationInputScope(input, "target");
12748
+ if (!scope.ok) return Effect.fail({ publicError: scope.error });
12749
+ const scopeValue = scope.value;
12750
+ if (scopeValue === void 0) return Effect.fail({ publicError: Errors.invalidInput("target", DESTINATION_SCOPE_MESSAGE) });
12751
+ return deps.convexCall.mutation(fns.addDestination, copyInvocationObservation(controls, {
12752
+ ...actor === void 0 ? {} : { actor },
12753
+ ...isSelfTarget(scopeValue) ? { self: true } : { ref: scopeValue },
12754
+ kind: destinationKindToBackend(input.kind),
12755
+ ...input.label === void 0 ? {} : { label: input.label },
12756
+ payload: input.payload
12757
+ })).pipe(Effect.map(destinationFromBackend), Effect.tap(() => Effect.annotateCurrentSpan(verifiedScope)));
12758
+ }), controls, CAPXUL_OPERATIONS.destinations.add, deps.runPromise);
12684
12759
  },
12685
- list: async (input, options) => {
12686
- const scope = normalizeDestinationInputScope(input, "target");
12687
- if (!scope.ok) return {
12688
- ok: false,
12689
- error: scope.error
12760
+ list: (input, options) => {
12761
+ const controls = deps.invocationControls?.(options) ?? options;
12762
+ const actor = actorReferenceToBackend(input.actor);
12763
+ const verifiedScope = {
12764
+ scope_kind: actor?.kind === "org" ? "organization" : "account",
12765
+ ...actor?.kind === "org" ? { verified_organization_id: actor.orgId } : {}
12690
12766
  };
12691
- const scopeValue = scope.value;
12692
- return mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.destinations.list, () => deps.convexCall.query(fns.listDestinations, {
12693
- ...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
12694
- ...scopeValue !== void 0 && isSelfTarget(scopeValue) ? { self: true } : {},
12695
- ...scopeValue !== void 0 && !isSelfTarget(scopeValue) ? { ref: scopeValue } : {}
12696
- })), (destinations) => destinations.map(destinationFromBackend).filter((destination) => input.kind === void 0 || destination.kind === input.kind));
12767
+ return runPortEffect(Effect.suspend(() => {
12768
+ const scope = normalizeDestinationInputScope(input, "target");
12769
+ if (!scope.ok) return Effect.fail({ publicError: scope.error });
12770
+ const scopeValue = scope.value;
12771
+ return deps.convexCall.query(fns.listDestinations, copyInvocationObservation(controls, {
12772
+ ...actor === void 0 ? {} : { actor },
12773
+ ...scopeValue !== void 0 && isSelfTarget(scopeValue) ? { self: true } : {},
12774
+ ...scopeValue !== void 0 && !isSelfTarget(scopeValue) ? { ref: scopeValue } : {}
12775
+ })).pipe(Effect.map((destinations) => destinations.map(destinationFromBackend).filter((destination) => input.kind === void 0 || destination.kind === input.kind)), Effect.tap(() => Effect.annotateCurrentSpan(verifiedScope)));
12776
+ }), controls, CAPXUL_OPERATIONS.destinations.list, deps.runPromise);
12697
12777
  },
12698
- remove: (input, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.destinations.remove, () => deps.convexCall.mutation(fns.removeDestination, {
12699
- ...input.actor === void 0 ? {} : { actor: actorReferenceToBackend(input.actor) },
12700
- destinationId: input.destinationId
12701
- }))
12778
+ remove: (input, options) => {
12779
+ const controls = deps.invocationControls?.(options) ?? options;
12780
+ const actor = actorReferenceToBackend(input.actor);
12781
+ const verifiedScope = {
12782
+ scope_kind: actor?.kind === "org" ? "organization" : "account",
12783
+ ...actor?.kind === "org" ? { verified_organization_id: actor.orgId } : {}
12784
+ };
12785
+ return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(fns.removeDestination, copyInvocationObservation(controls, {
12786
+ ...actor === void 0 ? {} : { actor },
12787
+ destinationId: input.destinationId
12788
+ })).pipe(Effect.tap(() => Effect.annotateCurrentSpan(verifiedScope)))), controls, CAPXUL_OPERATIONS.destinations.remove, deps.runPromise);
12789
+ }
12702
12790
  },
12703
12791
  payments: {
12704
12792
  pay,
@@ -17623,6 +17711,8 @@ const OBSERVED_CONVEX_QUERIES = /* @__PURE__ */ new Set([
17623
17711
  "movement/activity:list",
17624
17712
  "movement/activity:summary",
17625
17713
  "movement/activity:get",
17714
+ "financialOps/queries:depositInstructions",
17715
+ "financialOps/destinations:list",
17626
17716
  "financialOps/queries:verifyPaymentDocument",
17627
17717
  "financialOps/queries:renderStoredDocument",
17628
17718
  "financialOps/addressBook:list",
@@ -17640,6 +17730,8 @@ const OBSERVED_CONVEX_QUERIES = /* @__PURE__ */ new Set([
17640
17730
  ]);
17641
17731
  const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
17642
17732
  "movement/activity:annotate",
17733
+ "financialOps/destinations:add",
17734
+ "financialOps/destinations:remove",
17643
17735
  "financialOps/addressBook:add",
17644
17736
  "financialOps/addressBook:hide",
17645
17737
  "financialOps/addressBook:unhide",
@@ -44163,7 +44255,7 @@ function readOrgDepositInstructionsProgram(orgId) {
44163
44255
  const deps = yield* OrgDepsTag;
44164
44256
  const org = findOrgById(yield* listOrgsProgram(), orgId);
44165
44257
  if (org === void 0) return yield* Effect.fail(orgNotFound(orgId));
44166
- return {
44258
+ const instructions = {
44167
44259
  accountKind: "orgTreasury",
44168
44260
  chainId: Number(deps.chainId ?? 84532),
44169
44261
  network: "base-sepolia",
@@ -44171,6 +44263,8 @@ function readOrgDepositInstructionsProgram(orgId) {
44171
44263
  address: String(org.safeAddress).toLowerCase(),
44172
44264
  label: "Capxul org treasury"
44173
44265
  };
44266
+ yield* emitDepositInitiated(deps.telemetry, instructions, deps.invocationSource, String(org.id));
44267
+ return instructions;
44174
44268
  });
44175
44269
  }
44176
44270
  function listRolesProgram(orgId) {
@@ -44405,12 +44499,12 @@ function makeOrgMethods(deps) {
44405
44499
  });
44406
44500
  return toCapxulResult(readOrgProfileProgram(orgId), layer);
44407
44501
  },
44408
- depositInstructions(_options) {
44409
- if (_options?.signal?.aborted) return Promise.resolve({
44410
- ok: false,
44411
- error: Errors.cancelled({ operation: CAPXUL_OPERATIONS.org.profile.depositInstructions })
44412
- });
44413
- return toCapxulResult(readOrgDepositInstructionsProgram(orgId), layer);
44502
+ depositInstructions(options) {
44503
+ const controls = deps.invocationControls?.(options) ?? options;
44504
+ return runCapxulEffect(readOrgDepositInstructionsProgram(orgId).pipe(Effect.provide(orgDepsLayer({
44505
+ ...orgDeps,
44506
+ ...controls === void 0 ? {} : { invocationSource: controls }
44507
+ }))), controls, CAPXUL_OPERATIONS.org.profile.depositInstructions, deps.runPromise);
44414
44508
  }
44415
44509
  },
44416
44510
  treasury(options) {
@@ -46559,7 +46653,7 @@ function stdioIdentity(env = process.env, options = {}) {
46559
46653
  }
46560
46654
  //#endregion
46561
46655
  //#region package.json
46562
- var version = "4.1.0";
46656
+ var version = "4.1.1";
46563
46657
  //#endregion
46564
46658
  //#region src/deps.ts
46565
46659
  const NO_IDENTITY = async () => void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
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": [
@@ -51,7 +51,7 @@
51
51
  "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
52
52
  "vite-plus": "0.3.0",
53
53
  "@capxul/config": "0.3.0",
54
- "@capxul/sdk": "4.1.0",
54
+ "@capxul/sdk": "4.1.1",
55
55
  "@capxul/typescript-config": "0.0.0"
56
56
  },
57
57
  "scripts": {