@capxul/sdk 4.0.0 → 4.0.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.
@@ -1,5 +1,5 @@
1
1
  import { $ as CapxulError, A as toAuthUserId, C as WEI_RE, D as toAddress, E as toAccountId, G as toPayrollRunId, H as toOrgId, I as toEmail, M as toChainId, N as toCountryCode, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, S as SUPPORTED_CURRENCY_CODES, U as toPartyId, W as toPayrollGroupId, _ as deriveCapxulSafeAddress, at as boundedResponseHeaders, b as BYTES32_RE, ct as decodeChainCause, dt as isFailureMode, et as EXPECTED_OPERATION_OUTCOMES, ft as revertSummaryText, it as FAILURE_MODES$1, j as toBudgetId, lt as failureFingerprint, mt as redactSecrets, n as InMemoryAuthCacheAdapter, nt as isCapxulError, ot as chainCauseProperties, p as orgRoleKeyForLabel, pt as containsSensitiveMaterial, q as toRoleKey, r as BrowserAuthCacheAdapter, rt as CHAIN_UPSTREAMS, st as chainEvidenceLabel, tt as Errors, ut as isChainUpstream, v as validateHandle, w as ZERO_BYTES32, x as EVM_ADDRESS_RE$1, y as APP_ID_RE } from "./clock-C2AUlq1V.mjs";
2
- import { Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, SchemaParser, Scope } from "effect";
2
+ import { Cause, Clock, Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, SchemaParser, Scope } from "effect";
3
3
  import { formatUnits, keccak256, parseUnits, recoverAddress, toBytes } from "viem";
4
4
  import { makeFunctionReference } from "convex/server";
5
5
  //#region src/domain/identity/model.ts
@@ -508,6 +508,7 @@ const CAPXUL_OPERATIONS = {
508
508
  createOrganization: "identity.CreateOrganization",
509
509
  ensureAccount: "identity.EnsureAccount",
510
510
  leaveOrganization: "identity.LeaveOrganization",
511
+ loadByAuthUserId: "identity.loadByAuthUserId",
511
512
  loadCurrent: "identity.loadCurrent",
512
513
  orgAt: "identity.OrgAt",
513
514
  orgFailed: "identity.OrgFailed",
@@ -658,7 +659,8 @@ const CAPXUL_OPERATIONS = {
658
659
  organizationPayments: {
659
660
  pay: "organizationPayments.pay",
660
661
  payBatch: "organizationPayments.payBatch",
661
- prepareExecution: "organizationPayments.prepareExecution"
662
+ prepareExecution: "organizationPayments.prepareExecution",
663
+ retry: "organizationPayments.retry"
662
664
  },
663
665
  organizationSetup: { getProofReceipt: "organizationSetup.getProofReceipt" },
664
666
  organizations: { detectAndAcceptPendingInvitations: "orgs.detectAndAcceptPendingInvitations" },
@@ -673,6 +675,7 @@ const CAPXUL_OPERATIONS = {
673
675
  prepareExecution: "payments.prepareExecution",
674
676
  prepareLifecycleExecution: "payments.prepareLifecycleExecution",
675
677
  redirect: "payments.redirect",
678
+ retry: "payments.retry",
676
679
  submitCommandExecution: "payments.submitCommandExecution",
677
680
  submitExecution: "payments.submitExecution"
678
681
  },
@@ -754,6 +757,7 @@ const CAPXUL_OPERATIONS = {
754
757
  smartAccount: {
755
758
  claim: "smartAccount.claim",
756
759
  confirmDeployment: "smartAccount.confirmDeployment",
760
+ loadByAuthUserId: "smartAccount.loadByAuthUserId",
757
761
  loadCurrent: "smartAccount.loadCurrent",
758
762
  provision: "smartAccount.provision"
759
763
  },
@@ -3497,9 +3501,10 @@ const INVOCATION_OBSERVATION = Symbol("capxul.invocation-observation");
3497
3501
  const FAILURE_INVOCATION_SNAPSHOT = Symbol("capxul.failure-invocation-snapshot");
3498
3502
  /** @internal Attach one immutable, non-wire invocation snapshot to an SDK-owned object. */
3499
3503
  function attachInvocationObservation(target, source) {
3500
- const snapshot = Object.freeze(source.context === void 0 ? { active: source.active } : {
3504
+ const snapshot = Object.freeze({
3501
3505
  active: source.active,
3502
- context: Object.freeze({ ...source.context })
3506
+ ...source.actorId === void 0 ? {} : { actorId: source.actorId },
3507
+ ...source.context === void 0 ? {} : { context: Object.freeze({ ...source.context }) }
3503
3508
  });
3504
3509
  Object.defineProperty(target, INVOCATION_OBSERVATION, {
3505
3510
  configurable: false,
@@ -3751,10 +3756,10 @@ const logIdentityTransition = (record) => (record.outcome === "applied" ? Effect
3751
3756
  //#region src/domain/machine/shell.ts
3752
3757
  const INVOCATION_PARENT_SPAN = Symbol("@capxul/sdk/identity-invocation-parent-span");
3753
3758
  function carryInvocationParentSpan(controls, parent) {
3754
- return {
3759
+ return copyInvocationObservation(controls, {
3755
3760
  ...controls,
3756
3761
  [INVOCATION_PARENT_SPAN]: parent
3757
- };
3762
+ });
3758
3763
  }
3759
3764
  function withInvocationParentSpan(effect, controls) {
3760
3765
  const parent = controls?.[INVOCATION_PARENT_SPAN];
@@ -4105,13 +4110,13 @@ async function toCapxulResult(program, layer) {
4105
4110
  * with `{ publicError }` rather than a bare `CapxulError`, so the wrapper is
4106
4111
  * unwrapped here — once — instead of at every call site.
4107
4112
  */
4108
- async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise) {
4109
- if (signal?.aborted === true) return {
4113
+ async function runIfActive(signal, operation, effect, runPromise = Effect.runPromise, observe) {
4114
+ if (signal?.aborted === true && observe === void 0) return {
4110
4115
  ok: false,
4111
4116
  error: Errors.cancelled({ operation })
4112
4117
  };
4113
- const program = effect().pipe(Effect.mapError((error) => error.publicError));
4114
- return runProgram(signal === void 0 ? program : Effect.raceFirst(program, Effect.callback((resume) => {
4118
+ const program = signal?.aborted === true ? Effect.fail(Errors.cancelled({ operation })) : Effect.suspend(effect).pipe(Effect.mapError((error) => error.publicError));
4119
+ const controlled = signal === void 0 ? program : Effect.raceFirst(program, Effect.callback((resume) => {
4115
4120
  if (signal.aborted) {
4116
4121
  resume(Effect.fail(Errors.cancelled({ operation })));
4117
4122
  return Effect.void;
@@ -4119,7 +4124,8 @@ async function runIfActive(signal, operation, effect, runPromise = Effect.runPro
4119
4124
  const onAbort = () => resume(Effect.fail(Errors.cancelled({ operation })));
4120
4125
  signal.addEventListener("abort", onAbort, { once: true });
4121
4126
  return Effect.sync(() => signal.removeEventListener("abort", onAbort));
4122
- })), runPromise);
4127
+ }));
4128
+ return runProgram(observe === void 0 ? controlled : observe(controlled), runPromise);
4123
4129
  }
4124
4130
  //#endregion
4125
4131
  //#region src/surface/_shared/effect-actor-bridge.ts
@@ -4170,22 +4176,52 @@ async function runPortEffect(effect, controls, operation = CAPXUL_OPERATIONS.run
4170
4176
  orElse: () => Effect.fail({ publicError: Errors.providerTimeout("sdk", operation, timeoutMs) })
4171
4177
  }))).pipe(Effect.mapError((failure) => failure.publicError)), controls, operation, runPromise);
4172
4178
  }
4179
+ /** Keep observation metadata while the compound operation owns cancellation. */
4180
+ function observationOnlyControls(controls) {
4181
+ const { signal: _signal, timeoutMs: _timeoutMs, deadlineMs: _deadlineMs, ...observation } = controls ?? {};
4182
+ return copyInvocationObservation(controls, observation);
4183
+ }
4173
4184
  /** Observe a public Effect that already uses the canonical CapxulError channel. */
4174
4185
  async function runCapxulEffect(effect, controls, operation = CAPXUL_OPERATIONS.runtime.port, runPromise = Effect.runPromise) {
4175
4186
  const invocation = readInvocationObservation(controls);
4176
- const correlationId = safeEngineeringIdentifier(controls?.correlation_id ?? invocation?.context?.correlationId);
4177
- const observed = effect.pipe(Effect.tap(() => Effect.annotateCurrentSpan({ outcome: "succeeded" })), Effect.tapError((error) => {
4178
- const mode = error.mode ?? error.details?.failure_mode;
4179
- return Effect.annotateCurrentSpan({
4180
- outcome: portFailureOutcome(error.code),
4181
- failure_code: error.code,
4182
- ...typeof mode === "string" ? { mode } : {}
4183
- });
4184
- }), Effect.tapDefect(() => Effect.annotateCurrentSpan({
4185
- outcome: "failed",
4186
- failure_code: "UNKNOWN"
4187
- })), Effect.withSpan(`identity.port.${operation}`), Effect.annotateSpans(correlationId === void 0 ? {} : { correlation_id: correlationId }));
4188
- return runIfActive(controls?.signal, operation, () => withInvocationParentSpan(observed, controls).pipe(Effect.mapError((publicError) => ({ publicError }))), runPromise);
4187
+ const correlationId = safeEngineeringIdentifier(invocation?.context?.correlationId ?? controls?.correlation_id);
4188
+ const context = invocation?.active === false ? void 0 : sanitizeObservationContext(invocation?.context);
4189
+ const fields = {
4190
+ operation,
4191
+ ...correlationId === void 0 ? {} : { correlation_id: correlationId },
4192
+ ...context?.sessionId === void 0 ? {} : {
4193
+ session_id: context.sessionId,
4194
+ sessionId: context.sessionId
4195
+ },
4196
+ ...context?.journeyId === void 0 ? {} : { journey_id: context.journeyId },
4197
+ ...context?.release === void 0 ? {} : { release: context.release },
4198
+ ...context?.application === void 0 ? {} : { application: context.application },
4199
+ ...safeEngineeringIdentifier(invocation?.actorId) === void 0 ? {} : {
4200
+ actor_id: invocation.actorId,
4201
+ actor_kind: "authenticated",
4202
+ posthogDistinctId: invocation.actorId
4203
+ }
4204
+ };
4205
+ const result = await runIfActive(controls?.signal, operation, () => effect.pipe(Effect.mapError((publicError) => ({ publicError }))), runPromise, (program) => withInvocationParentSpan(Effect.gen(function* () {
4206
+ const startedAt = yield* Clock.currentTimeMillis;
4207
+ const exit = yield* Effect.exit(program.pipe(Effect.catchDefect((cause) => Effect.fail(Errors.unknown(cause)))));
4208
+ const duration_ms = (yield* Clock.currentTimeMillis) - startedAt;
4209
+ const error = Exit.isFailure(exit) ? Cause.squash(exit.cause) : void 0;
4210
+ const failure = error instanceof CapxulError ? error : void 0;
4211
+ const outcome = Exit.isSuccess(exit) ? "succeeded" : failure?.code === "CANCELLED" ? "cancelled" : failure !== void 0 && EXPECTED_OPERATION_OUTCOMES.has(failure.code) ? "refused" : "failed";
4212
+ const completion = {
4213
+ ...fields,
4214
+ duration_ms,
4215
+ outcome,
4216
+ ...failure === void 0 ? {} : { failure_code: failure.code },
4217
+ ...typeof failure?.mode === "string" ? { mode: failure.mode } : {},
4218
+ ...failure?.mode === void 0 && typeof failure?.details?.failure_mode === "string" ? { mode: failure.details.failure_mode } : {}
4219
+ };
4220
+ yield* Effect.annotateCurrentSpan(completion).pipe(Effect.catchCause(() => Effect.void));
4221
+ yield* (outcome === "failed" ? Effect.logError("capxul_sdk_operation") : Effect.logInfo("capxul_sdk_operation")).pipe(Effect.annotateLogs(completion), Effect.catchCause(() => Effect.void));
4222
+ return yield* Exit.isSuccess(exit) ? Effect.succeed(exit.value) : Effect.failCause(exit.cause);
4223
+ }).pipe(Effect.withSpan(operation)), controls));
4224
+ return !result.ok && invocation !== void 0 ? markFailureInvocationSnapshot(result, invocation) : result;
4189
4225
  }
4190
4226
  /** Map machine-internal failure state onto the public SDK error vocabulary. */
4191
4227
  function publicIdentityFailure(failure) {
@@ -4399,76 +4435,110 @@ function makeActorRelationshipMethods(deps) {
4399
4435
  const fns = actorScopeContract;
4400
4436
  return {
4401
4437
  addressBook: {
4402
- list: (input, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.list, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.list, () => convexCall.query(fns.addressBookList, {
4403
- actor,
4404
- ...input?.includeHidden === void 0 ? {} : { includeHidden: input.includeHidden }
4405
- })), (entries) => entries.map(mapAddressBookEntry)),
4406
- get: (entryId, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.get, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.get, () => convexCall.query(fns.addressBookGet, {
4407
- actor,
4408
- partyId: entryId
4409
- })), (entry) => entry === null ? null : mapAddressBookEntry(entry)),
4410
- add: async (input, options) => {
4438
+ list: (input, options) => {
4439
+ const controls = deps.invocationControls?.(options) ?? options;
4440
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.list, Effect.suspend(() => convexCall.query(fns.addressBookList, copyInvocationObservation(controls, {
4441
+ actor,
4442
+ ...input?.includeHidden === void 0 ? {} : { includeHidden: input.includeHidden }
4443
+ }))), (entries) => entries.map(mapAddressBookEntry)), controls, CAPXUL_OPERATIONS.addressBook.list, deps.runPromise);
4444
+ },
4445
+ get: (entryId, options) => {
4446
+ const controls = deps.invocationControls?.(options) ?? options;
4447
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.get, Effect.suspend(() => convexCall.query(fns.addressBookGet, copyInvocationObservation(controls, {
4448
+ actor,
4449
+ partyId: entryId
4450
+ }))), (entry) => entry === null ? null : mapAddressBookEntry(entry)), controls, CAPXUL_OPERATIONS.addressBook.get, deps.runPromise);
4451
+ },
4452
+ add: (input, options) => {
4453
+ const controls = deps.invocationControls?.(options) ?? options;
4411
4454
  const ref = normalizeRefForBackend$1(input.ref, "ref");
4412
- if (!ref.ok) return ref;
4413
- return mapOk$1(CAPXUL_OPERATIONS.addressBook.add, await awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.add, () => convexCall.mutation(fns.addressBookAdd, {
4455
+ if (!ref.ok) return runCapxulEffect(Effect.fail(ref.error), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
4456
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.add, Effect.suspend(() => convexCall.mutation(fns.addressBookAdd, copyInvocationObservation(controls, {
4414
4457
  actor,
4415
4458
  ref: ref.value,
4416
4459
  ...input.label === void 0 ? {} : { label: input.label }
4417
- })), mapAddressBookEntry);
4460
+ }))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.add, deps.runPromise);
4461
+ },
4462
+ hide: (entryId, options) => {
4463
+ const controls = deps.invocationControls?.(options) ?? options;
4464
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.hide, Effect.suspend(() => convexCall.mutation(fns.addressBookHide, copyInvocationObservation(controls, {
4465
+ actor,
4466
+ partyId: entryId
4467
+ }))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.hide, deps.runPromise);
4468
+ },
4469
+ unhide: (entryId, options) => {
4470
+ const controls = deps.invocationControls?.(options) ?? options;
4471
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.unhide, Effect.suspend(() => convexCall.mutation(fns.addressBookUnhide, copyInvocationObservation(controls, {
4472
+ actor,
4473
+ partyId: entryId
4474
+ }))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.unhide, deps.runPromise);
4418
4475
  },
4419
- hide: (entryId, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.hide, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.hide, () => convexCall.mutation(fns.addressBookHide, {
4420
- actor,
4421
- partyId: entryId
4422
- })), mapAddressBookEntry),
4423
- unhide: (entryId, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.unhide, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.unhide, () => convexCall.mutation(fns.addressBookUnhide, {
4424
- actor,
4425
- partyId: entryId
4426
- })), mapAddressBookEntry),
4427
- label: (input, options) => mapOk$1(CAPXUL_OPERATIONS.addressBook.label, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.addressBook.label, () => convexCall.mutation(fns.addressBookLabel, {
4428
- actor,
4429
- partyId: input.entryId,
4430
- label: input.label
4431
- })), mapAddressBookEntry)
4476
+ label: (input, options) => {
4477
+ const controls = deps.invocationControls?.(options) ?? options;
4478
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.addressBook.label, Effect.suspend(() => convexCall.mutation(fns.addressBookLabel, copyInvocationObservation(controls, {
4479
+ actor,
4480
+ partyId: input.entryId,
4481
+ label: input.label
4482
+ }))), mapAddressBookEntry), controls, CAPXUL_OPERATIONS.addressBook.label, deps.runPromise);
4483
+ }
4432
4484
  },
4433
4485
  requests: {
4434
- issue: async (input, options) => {
4486
+ issue: (input, options) => {
4487
+ const controls = deps.invocationControls?.(options) ?? options;
4435
4488
  const payer = normalizeRefForBackend$1(input.payer, "payer");
4436
- if (!payer.ok) return payer;
4437
- return mapOk$1(CAPXUL_OPERATIONS.requests.issue, await awaitableConvex(options?.signal, CAPXUL_OPERATIONS.requests.issue, () => convexCall.mutation(fns.requestsIssue, {
4489
+ if (!payer.ok) return runCapxulEffect(Effect.fail(payer.error), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
4490
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.issue, Effect.suspend(() => convexCall.mutation(fns.requestsIssue, copyInvocationObservation(controls, {
4438
4491
  actor,
4439
4492
  payer: payer.value,
4440
4493
  amount: input.amount,
4441
4494
  reference: input.reference,
4442
4495
  ...input.memo === void 0 ? {} : { memo: input.memo },
4443
4496
  ...input.expiresAt === void 0 ? {} : { expiresAt: input.expiresAt }
4444
- })), (request) => mapActorRequest(request, input.payer));
4497
+ }))), (request) => mapActorRequest(request, input.payer)), controls, CAPXUL_OPERATIONS.requests.issue, deps.runPromise);
4498
+ },
4499
+ list: (options) => {
4500
+ const controls = deps.invocationControls?.(options) ?? options;
4501
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.list, Effect.suspend(() => convexCall.query(fns.requestsList, copyInvocationObservation(controls, { actor }))), (requests) => requests.map((request) => mapActorRequest(request))), controls, CAPXUL_OPERATIONS.requests.list, deps.runPromise);
4445
4502
  },
4446
- list: (options) => mapOk$1(CAPXUL_OPERATIONS.requests.list, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.requests.list, () => convexCall.query(fns.requestsList, { actor })), (requests) => requests.map((request) => mapActorRequest(request))),
4447
- get: (requestId, options) => mapOk$1(CAPXUL_OPERATIONS.requests.get, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.requests.get, () => convexCall.query(fns.requestsGet, {
4448
- actor,
4449
- paymentRequestId: requestId
4450
- })), (request) => request === null ? null : mapActorRequest(request)),
4451
- cancel: (requestId, options) => mapOk$1(CAPXUL_OPERATIONS.requests.cancel, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.requests.cancel, () => convexCall.mutation(fns.requestsCancel, {
4452
- actor,
4453
- paymentRequestId: requestId
4454
- })), (request) => mapActorRequest(request))
4503
+ get: (requestId, options) => {
4504
+ const controls = deps.invocationControls?.(options) ?? options;
4505
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.get, Effect.suspend(() => convexCall.query(fns.requestsGet, copyInvocationObservation(controls, {
4506
+ actor,
4507
+ paymentRequestId: requestId
4508
+ }))), (request) => request === null ? null : mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.get, deps.runPromise);
4509
+ },
4510
+ cancel: (requestId, options) => {
4511
+ const controls = deps.invocationControls?.(options) ?? options;
4512
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.requests.cancel, Effect.suspend(() => convexCall.mutation(fns.requestsCancel, copyInvocationObservation(controls, {
4513
+ actor,
4514
+ paymentRequestId: requestId
4515
+ }))), (request) => mapActorRequest(request)), controls, CAPXUL_OPERATIONS.requests.cancel, deps.runPromise);
4516
+ }
4455
4517
  },
4456
4518
  inbox: {
4457
- list: (options) => mapOk$1(CAPXUL_OPERATIONS.inbox.list, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.inbox.list, () => convexCall.query(fns.inboxList, { actor })), (items) => items.map(mapInboxItem)),
4458
- approve: async (input, options) => {
4459
- const result = await awaitableConvex(options?.signal, CAPXUL_OPERATIONS.inbox.approve, () => convexCall.mutation(fns.inboxApprove, {
4519
+ list: (options) => {
4520
+ const controls = deps.invocationControls?.(options) ?? options;
4521
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.inbox.list, Effect.suspend(() => convexCall.query(fns.inboxList, copyInvocationObservation(controls, { actor }))), (items) => items.map(mapInboxItem)), controls, CAPXUL_OPERATIONS.inbox.list, deps.runPromise);
4522
+ },
4523
+ approve: (input, options) => {
4524
+ const controls = deps.invocationControls?.(options) ?? options;
4525
+ return runPortEffect(Effect.suspend(() => convexCall.mutation(fns.inboxApprove, copyInvocationObservation(controls, {
4460
4526
  actor,
4461
4527
  paymentRequestId: input.requestId,
4462
4528
  ...input.timing === void 0 ? {} : { timing: input.timing },
4463
4529
  ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
4464
- }));
4465
- if (!result.ok) return result;
4466
- return mapApprovedInboxPayment(result.value, input);
4530
+ }))).pipe(Effect.flatMap((prepared) => {
4531
+ const result = mapApprovedInboxPayment(prepared, input);
4532
+ return result.ok ? Effect.succeed(result.value) : Effect.fail({ publicError: result.error });
4533
+ })), controls, CAPXUL_OPERATIONS.inbox.approve, deps.runPromise);
4467
4534
  },
4468
- decline: (requestId, options) => mapOk$1(CAPXUL_OPERATIONS.inbox.decline, awaitableConvex(options?.signal, CAPXUL_OPERATIONS.inbox.decline, () => convexCall.mutation(fns.inboxDecline, {
4469
- actor,
4470
- paymentRequestId: requestId
4471
- })), mapInboxItem)
4535
+ decline: (requestId, options) => {
4536
+ const controls = deps.invocationControls?.(options) ?? options;
4537
+ return runPortEffect(mapReply(CAPXUL_OPERATIONS.inbox.decline, Effect.suspend(() => convexCall.mutation(fns.inboxDecline, copyInvocationObservation(controls, {
4538
+ actor,
4539
+ paymentRequestId: requestId
4540
+ }))), mapInboxItem), controls, CAPXUL_OPERATIONS.inbox.decline, deps.runPromise);
4541
+ }
4472
4542
  },
4473
4543
  profile: {
4474
4544
  get: (options) => {
@@ -4545,22 +4615,12 @@ function missingConvexCall(operation) {
4545
4615
  * promise and the caller's `if (!result.ok)` never runs (ADR-0023: errors are
4546
4616
  * values, and a code crosses the seam).
4547
4617
  */
4548
- async function mapOk$1(operation, resultOrPromise, f) {
4549
- const result = await resultOrPromise;
4550
- if (!result.ok) return result;
4551
- try {
4552
- return {
4553
- ok: true,
4554
- value: f(result.value)
4555
- };
4556
- } catch (cause) {
4557
- return {
4558
- ok: false,
4559
- error: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause)
4560
- };
4561
- }
4618
+ function mapReply(operation, program, project) {
4619
+ return program.pipe(Effect.flatMap((value) => Effect.try({
4620
+ try: () => project(value),
4621
+ catch: (cause) => ({ publicError: cause instanceof CapxulError ? cause : Errors.providerError("convex", operation, cause) })
4622
+ })));
4562
4623
  }
4563
- const awaitableConvex = runIfActive;
4564
4624
  const ADDRESS_BOOK_RELATIONSHIPS = [
4565
4625
  "paid",
4566
4626
  "paidBy",
@@ -4928,6 +4988,8 @@ function makeAccountMethods(deps) {
4928
4988
  return {
4929
4989
  methods: {
4930
4990
  ...makeActorRelationshipMethods({
4991
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
4992
+ ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
4931
4993
  actor: { kind: "account" },
4932
4994
  ...deps.convexCall === void 0 ? {} : { convexCall: deps.convexCall },
4933
4995
  ...deps.profileMethods === void 0 ? {} : { accountProfileMethods: deps.profileMethods }
@@ -4981,7 +5043,7 @@ const moneyExecutionContract = {
4981
5043
  };
4982
5044
  //#endregion
4983
5045
  //#region package.json
4984
- var version = "4.0.0";
5046
+ var version = "4.0.1";
4985
5047
  //#endregion
4986
5048
  //#region src/telemetry/exception-projection.ts
4987
5049
  /** Fixed fallback for failures that have no safe message. */
@@ -5037,7 +5099,16 @@ function postHogFailureObservation(policy, fixedSnapshot) {
5037
5099
  const directSnapshot = callStartSnapshot === void 0 ? policy.snapshot() : void 0;
5038
5100
  if (!(callStartSnapshot?.active ?? directSnapshot?.active) || policy.client === null || policy.client === void 0) return;
5039
5101
  const safeFailure = sanitizeFailureObservation(failure);
5040
- return [safeFailure, postHogProperties(safeFailure, callStartSnapshot?.context ?? directSnapshot?.context)];
5102
+ const directContext = callStartSnapshot?.context ?? directSnapshot?.context;
5103
+ const actorId = callStartSnapshot?.actorId;
5104
+ return [safeFailure, {
5105
+ ...postHogProperties(safeFailure, directContext),
5106
+ ...actorId !== void 0 && /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u.test(actorId) ? {
5107
+ actor_id: actorId,
5108
+ actor_kind: "authenticated",
5109
+ distinct_id: actorId
5110
+ } : {}
5111
+ }];
5041
5112
  };
5042
5113
  const captureOperationFailure = (failure) => {
5043
5114
  const prepared = prepare(failure);
@@ -5142,7 +5213,8 @@ function observeSdkClient(client, adapter, snapshot) {
5142
5213
  };
5143
5214
  const processOutput = (output, path, invocation) => {
5144
5215
  if (isFailedResult(output)) {
5145
- report(adapter, "operation", path.join("."), output.error, invocation);
5216
+ const captured = readFailureInvocationSnapshot(output);
5217
+ report(adapter, "operation", path.join("."), output.error, captured ?? invocation, void 0, captured !== void 0);
5146
5218
  return output;
5147
5219
  }
5148
5220
  if (isCapxulResult(output)) return output;
@@ -5174,7 +5246,7 @@ function reportedByMachine(cause) {
5174
5246
  }
5175
5247
  return false;
5176
5248
  }
5177
- function report(adapter, kind, operation, cause, invocation, origin) {
5249
+ function report(adapter, kind, operation, cause, invocation, origin, authoritativeSnapshot = false) {
5178
5250
  if (origin === "machine") {
5179
5251
  let link = cause;
5180
5252
  for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
@@ -5186,7 +5258,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
5186
5258
  const kindName = normalizeErrorKind(errorKind(cause));
5187
5259
  const context = sanitizeObservationContext({
5188
5260
  ...invocation.context,
5189
- ...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
5261
+ ...!authoritativeSnapshot && isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
5190
5262
  });
5191
5263
  const detail = failureDetail(cause);
5192
5264
  const evidence = failureEvidence(cause);
@@ -5200,6 +5272,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
5200
5272
  ...evidence
5201
5273
  }, {
5202
5274
  active: invocation.active,
5275
+ ...invocation.actorId === void 0 ? {} : { actorId: invocation.actorId },
5203
5276
  ...context === void 0 ? {} : { context }
5204
5277
  });
5205
5278
  try {
@@ -5728,17 +5801,17 @@ async function fingerprintPaymentIntent(intent) {
5728
5801
  function matchesIntent(expected) {
5729
5802
  return async (request) => await fingerprintPaymentIntent(request) === await fingerprintPaymentIntent(expected);
5730
5803
  }
5731
- async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed) {
5804
+ async function abandonPrepared$1(deps, executionId, closePayment, reason, result, onPreparedClosed, controls) {
5732
5805
  if (!closePayment) return result;
5733
- const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => deps.convexCall.action(deps.functions.abandonPaymentExecution, { input: {
5806
+ const abandoned = await runIfActive(void 0, CAPXUL_OPERATIONS.moneyExecution.abandonPaymentExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.abandonPaymentExecution, copyInvocationObservation(controls, { input: {
5734
5807
  executionId,
5735
5808
  reason
5736
- } }));
5809
+ } }))), controls), deps.runPromise);
5737
5810
  if (!abandoned.ok) return abandoned;
5738
5811
  if (abandoned.value) onPreparedClosed?.();
5739
5812
  return result;
5740
5813
  }
5741
- async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal) {
5814
+ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls) {
5742
5815
  if (isAborted$2(signal)) return {
5743
5816
  ok: false,
5744
5817
  error: Errors.cancelled({ operation: "payments" })
@@ -5762,16 +5835,16 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
5762
5835
  if (!await isExpectedRequest(prepared.value.request)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "prepared_mismatch", {
5763
5836
  ok: false,
5764
5837
  error: Errors.invalidInput("payment", "prepared command mismatch")
5765
- }, onPreparedClosed);
5838
+ }, onPreparedClosed, controls);
5766
5839
  const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
5767
5840
  if (prepared.value.chainId !== deps.chainId || prepared.value.signerAddress.toLowerCase() !== signerAddress.toLowerCase() || prepared.value.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase()) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "prepared_mismatch", {
5768
5841
  ok: false,
5769
5842
  error: Errors.invalidInput("payment", "prepared authority mismatch")
5770
- }, onPreparedClosed);
5843
+ }, onPreparedClosed, controls);
5771
5844
  if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
5772
5845
  ok: false,
5773
5846
  error: Errors.cancelled({ operation: "payments" })
5774
- }, onPreparedClosed);
5847
+ }, onPreparedClosed, controls);
5775
5848
  if (prepared.value.emitPaymentInitiated && "items" in prepared.value.request) for (const [index, item] of prepared.value.request.items.entries()) {
5776
5849
  const paymentId = prepared.value.paymentIds[index];
5777
5850
  const recipient = prepared.value.recipientObservations[index];
@@ -5792,28 +5865,28 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
5792
5865
  return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "signer_rejected", {
5793
5866
  ok: false,
5794
5867
  error: signerFailure(deps.signer.source, "signUserOpHash", cause)
5795
- }, onPreparedClosed);
5868
+ }, onPreparedClosed, controls);
5796
5869
  }
5797
5870
  if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
5798
5871
  ok: false,
5799
5872
  error: Errors.cancelled({ operation: "payments" })
5800
- }, onPreparedClosed);
5801
- return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, { input: {
5873
+ }, onPreparedClosed, controls);
5874
+ return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitCommandExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.submitPaymentCommandExecution, copyInvocationObservation(controls, { input: {
5802
5875
  executionId: prepared.value.executionId,
5803
5876
  signature
5804
- } }));
5877
+ } }))), controls), deps.runPromise);
5805
5878
  }
5806
- function executePaymentLifecycle(deps, intent, signal) {
5807
- return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, { input: {
5879
+ function executePaymentLifecycle(deps, intent, signal, controls) {
5880
+ return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.payments.prepareLifecycleExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, copyInvocationObservation(controls, { input: {
5808
5881
  signerAddress,
5809
5882
  intent
5810
- } })), matchesIntent(intent), false, void 0, signal);
5883
+ } }))), controls), deps.runPromise), matchesIntent(intent), false, void 0, signal, controls);
5811
5884
  }
5812
- function executeOrganizationPayment(deps, input, signal, onPreparedClosed) {
5813
- return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, { input: {
5885
+ function executeOrganizationPayment(deps, input, signal, onPreparedClosed, controls) {
5886
+ return executePrepared(deps, (signerAddress) => runIfActive(signal, CAPXUL_OPERATIONS.organizationPayments.prepareExecution, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, copyInvocationObservation(controls, { input: {
5814
5887
  ...input,
5815
5888
  signerAddress
5816
- } })), matchesIntent(input), true, onPreparedClosed, signal);
5889
+ } }))), controls), deps.runPromise), matchesIntent(input), true, onPreparedClosed, signal, controls);
5817
5890
  }
5818
5891
  //#endregion
5819
5892
  //#region src/surface/payment-execution.ts
@@ -6252,51 +6325,52 @@ function makeFinancialOpsMethods(deps) {
6252
6325
  chainId: deps.chainId,
6253
6326
  convexCall: deps.convexCall,
6254
6327
  functions: executionFns,
6255
- signer: deps.signer
6256
- }
6257
- };
6258
- const runLifecycle = async (intent, signal) => {
6259
- const execution = lifecycleDependencies();
6260
- if (!execution.ok) return execution;
6261
- try {
6262
- const submitted = await executePaymentLifecycle(execution.value, intent, signal);
6263
- if (!submitted.ok) return submitted;
6264
- const payments = submitted.value.payments;
6265
- const payment = payments[0];
6266
- if (payment === void 0 || payments.length !== 1) return {
6267
- ok: false,
6268
- error: Errors.unknown()
6269
- };
6270
- return {
6271
- ok: true,
6272
- value: normalizePaymentTiming(payment)
6273
- };
6274
- } catch (cause) {
6275
- return {
6276
- ok: false,
6277
- error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
6278
- };
6279
- }
6280
- };
6281
- const retryPayment = async (paymentId, signal) => {
6282
- const execution = lifecycleDependencies();
6283
- if (!execution.ok) return execution;
6284
- try {
6285
- const submitted = await executePaymentLifecycle(execution.value, {
6286
- kind: "retry",
6287
- paymentId
6288
- }, signal);
6289
- return submitted.ok ? {
6290
- ok: true,
6291
- value: submitted.value.payments.map((payment) => normalizePaymentTiming(payment))
6292
- } : submitted;
6293
- } catch (cause) {
6294
- return {
6295
- ok: false,
6296
- error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
6297
- };
6328
+ signer: deps.signer,
6329
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise }
6298
6330
  }
6299
6331
  };
6332
+ const runLifecycle = (intent, controls, operation) => runCapxulEffect(Effect.gen(function* () {
6333
+ const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
6334
+ const result = yield* Effect.tryPromise({
6335
+ try: async () => {
6336
+ const execution = lifecycleDependencies();
6337
+ if (!execution.ok) return execution;
6338
+ const submitted = await executePaymentLifecycle(execution.value, intent, controls?.signal, captured);
6339
+ if (!submitted.ok) return submitted;
6340
+ const payments = submitted.value.payments;
6341
+ const payment = payments[0];
6342
+ if (payment === void 0 || payments.length !== 1) return {
6343
+ ok: false,
6344
+ error: Errors.unknown()
6345
+ };
6346
+ return {
6347
+ ok: true,
6348
+ value: normalizePaymentTiming(payment)
6349
+ };
6350
+ },
6351
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
6352
+ });
6353
+ return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
6354
+ }), observationOnlyControls(controls), operation, deps.runPromise);
6355
+ const retryPayment = (paymentId, controls) => runCapxulEffect(Effect.gen(function* () {
6356
+ const captured = carryInvocationParentSpan(controls, yield* Effect.currentSpan.pipe(Effect.orDie));
6357
+ const result = yield* Effect.tryPromise({
6358
+ try: async () => {
6359
+ const execution = lifecycleDependencies();
6360
+ if (!execution.ok) return execution;
6361
+ const submitted = await executePaymentLifecycle(execution.value, {
6362
+ kind: "retry",
6363
+ paymentId
6364
+ }, controls?.signal, captured);
6365
+ return submitted.ok ? {
6366
+ ok: true,
6367
+ value: submitted.value.payments.map((payment) => normalizePaymentTiming(payment))
6368
+ } : submitted;
6369
+ },
6370
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
6371
+ });
6372
+ return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
6373
+ }), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.retry, deps.runPromise);
6300
6374
  return {
6301
6375
  me: {
6302
6376
  get: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.me.get, () => deps.convexCall.query(fns.me, {})),
@@ -6348,58 +6422,64 @@ function makeFinancialOpsMethods(deps) {
6348
6422
  },
6349
6423
  payments: {
6350
6424
  pay,
6351
- retry: (paymentId, options) => retryPayment(paymentId, options?.signal),
6425
+ retry: (paymentId, options) => retryPayment(paymentId, deps.invocationControls?.(options) ?? options),
6352
6426
  createCommitment: (input, options) => pay(input, options),
6353
6427
  claim: (paymentId, options) => runLifecycle({
6354
6428
  kind: "claim",
6355
6429
  paymentId
6356
- }, options?.signal),
6430
+ }, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.claim),
6357
6431
  list: async (options) => mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.payments.list, () => deps.convexCall.query(fns.listPayments, {})), (payments) => payments.map(normalizePaymentTiming)),
6358
6432
  get: async (paymentId, options) => mapOk(await runIfActive(options?.signal, CAPXUL_OPERATIONS.payments.get, () => deps.convexCall.query(fns.getPayment, { paymentId })), (payment) => payment === null ? null : normalizePaymentTiming(payment)),
6359
6433
  cancel: (paymentId, options) => runLifecycle({
6360
6434
  kind: "cancel",
6361
6435
  paymentId
6362
- }, options?.signal),
6436
+ }, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.cancel),
6363
6437
  redirect: async (input, options) => {
6438
+ const controls = deps.invocationControls?.(options) ?? options;
6364
6439
  const recipient = normalizeTargetForBackend(input.to, "to");
6365
- if (!recipient.ok) return recipient;
6440
+ if (!recipient.ok) return runCapxulEffect(Effect.fail(recipient.error), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.redirect, deps.runPromise);
6366
6441
  return runLifecycle({
6367
6442
  kind: "redirect",
6368
6443
  paymentId: input.paymentId,
6369
6444
  recipient: recipient.value
6370
- }, options?.signal);
6445
+ }, controls, CAPXUL_OPERATIONS.payments.redirect);
6371
6446
  }
6372
6447
  },
6373
6448
  activity: {
6374
- list: (params, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.activity.list, () => deps.convexCall.query(fns.activityList, { input: {
6375
- ...activityActorField(params?.actor),
6376
- ...params?.cursor === void 0 ? {} : { cursor: params.cursor },
6377
- ...params?.limit === void 0 ? {} : { limit: params.limit },
6378
- ...params?.range === void 0 ? {} : { range: params.range },
6379
- ...params?.filter === void 0 ? {} : { filter: params.filter }
6380
- } })),
6381
- summary: (params, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.activity.summary, () => deps.convexCall.query(fns.activitySummary, { input: {
6382
- ...activityActorField(params?.actor),
6383
- ...params?.window === void 0 ? {} : { window: params.window }
6384
- } })),
6449
+ list: (params, options) => {
6450
+ const controls = deps.invocationControls?.(options) ?? options;
6451
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityList, copyInvocationObservation(controls, { input: {
6452
+ ...activityActorField(params?.actor),
6453
+ ...params?.cursor === void 0 ? {} : { cursor: params.cursor },
6454
+ ...params?.limit === void 0 ? {} : { limit: params.limit },
6455
+ ...params?.range === void 0 ? {} : { range: params.range },
6456
+ ...params?.filter === void 0 ? {} : { filter: params.filter }
6457
+ } }))), controls, CAPXUL_OPERATIONS.activity.list, deps.runPromise);
6458
+ },
6459
+ summary: (params, options) => {
6460
+ const controls = deps.invocationControls?.(options) ?? options;
6461
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activitySummary, copyInvocationObservation(controls, { input: {
6462
+ ...activityActorField(params?.actor),
6463
+ ...params?.window === void 0 ? {} : { window: params.window }
6464
+ } }))), controls, CAPXUL_OPERATIONS.activity.summary, deps.runPromise);
6465
+ },
6385
6466
  get: (reference, options) => {
6467
+ const controls = deps.invocationControls?.(options) ?? options;
6386
6468
  const actor = actorReferenceToBackend(options?.actor);
6387
- return runIfActive(options?.signal, CAPXUL_OPERATIONS.activity.get, () => deps.convexCall.query(fns.activityGet, {
6469
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.activityGet, copyInvocationObservation(controls, {
6388
6470
  input: {
6389
6471
  kind: reference.kind,
6390
6472
  id: reference.id,
6391
6473
  ...reference.kind === "payment" ? activityActorField(reference.actor) : {}
6392
6474
  },
6393
6475
  ...actor === void 0 ? {} : { actor }
6394
- }).pipe(Effect.map(normalizeActivityDetail)));
6476
+ }))).pipe(Effect.map(normalizeActivityDetail)), controls, CAPXUL_OPERATIONS.activity.get, deps.runPromise);
6395
6477
  },
6396
6478
  annotate: (input, options) => {
6397
- if (input.actor !== void 0 && input.reference.kind === "payment" && input.reference.actor !== void 0 && !sameActor(input.actor, input.reference.actor)) return Promise.resolve({
6398
- ok: false,
6399
- error: Errors.invalidInput("reference.actor", "must match the annotation actor")
6400
- });
6479
+ const controls = deps.invocationControls?.(options) ?? options;
6480
+ if (input.actor !== void 0 && input.reference.kind === "payment" && input.reference.actor !== void 0 && !sameActor(input.actor, input.reference.actor)) return runCapxulEffect(Effect.fail(Errors.invalidInput("reference.actor", "must match the annotation actor")), controls, CAPXUL_OPERATIONS.activity.annotate, deps.runPromise);
6401
6481
  const referenceActor = input.reference.kind === "payment" ? activityActorField(input.reference.actor).actor : void 0;
6402
- return runIfActive(options?.signal, CAPXUL_OPERATIONS.activity.annotate, () => deps.convexCall.mutation(fns.activityAnnotate, { input: {
6482
+ return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(fns.activityAnnotate, copyInvocationObservation(controls, { input: {
6403
6483
  ...activityActorField(input.actor),
6404
6484
  reference: input.reference.kind === "payment" && referenceActor !== void 0 ? {
6405
6485
  kind: "payment",
@@ -6412,7 +6492,7 @@ function makeFinancialOpsMethods(deps) {
6412
6492
  ...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
6413
6493
  ...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
6414
6494
  ...input.memo === void 0 ? {} : { memo: input.memo }
6415
- } }));
6495
+ } }))), controls, CAPXUL_OPERATIONS.activity.annotate, deps.runPromise);
6416
6496
  }
6417
6497
  },
6418
6498
  offramp: {
@@ -6438,8 +6518,14 @@ function makeFinancialOpsMethods(deps) {
6438
6518
  }
6439
6519
  },
6440
6520
  paymentDocuments: {
6441
- verify: (documentHash, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.paymentDocuments.verify, () => deps.convexCall.query(fns.verifyPaymentDocument, { documentHash })),
6442
- render: (documentHash, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.paymentDocuments.render, () => deps.convexCall.query(fns.renderStoredDocument, { documentHash }))
6521
+ verify: (documentHash, options) => {
6522
+ const controls = deps.invocationControls?.(options) ?? options;
6523
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.verifyPaymentDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.verify, deps.runPromise);
6524
+ },
6525
+ render: (documentHash, options) => {
6526
+ const controls = deps.invocationControls?.(options) ?? options;
6527
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(fns.renderStoredDocument, copyInvocationObservation(controls, { documentHash }))), controls, CAPXUL_OPERATIONS.paymentDocuments.render, deps.runPromise);
6528
+ }
6443
6529
  }
6444
6530
  };
6445
6531
  }
@@ -8336,13 +8422,14 @@ function executionDependencies$1(input) {
8336
8422
  convexCall: input.convexCall,
8337
8423
  functions: moneyExecutionContract,
8338
8424
  signer: input.signer,
8425
+ ...input.runPromise === void 0 ? {} : { runPromise: input.runPromise },
8339
8426
  ...input.telemetry === void 0 ? {} : { telemetry: input.telemetry }
8340
8427
  };
8341
8428
  }
8342
8429
  function makeOrganizationPaymentsMethods(deps, orgId) {
8343
8430
  const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
8344
8431
  const inFlightOrganizationPayments = /* @__PURE__ */ new Map();
8345
- const execute = async (input, signal, operation = "organization-pay-batch") => {
8432
+ const execute = async (input, signal, operation = "organization-pay-batch", controls) => {
8346
8433
  if (signal?.aborted === true) return {
8347
8434
  ok: false,
8348
8435
  error: Errors.cancelled({ operation })
@@ -8375,7 +8462,7 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
8375
8462
  requestKey: requestKey.key,
8376
8463
  items: input.items,
8377
8464
  ...input.lineage === void 0 ? {} : { lineage: input.lineage }
8378
- }, controller.signal, () => requestState.resolved = true);
8465
+ }, controller.signal, () => requestState.resolved = true, controls);
8379
8466
  flight = {
8380
8467
  controller,
8381
8468
  promise: submission,
@@ -8424,41 +8511,73 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
8424
8511
  return normalized;
8425
8512
  };
8426
8513
  return {
8427
- retry: async (paymentId, options) => {
8428
- const execution = executionDependencies$1(deps);
8429
- if (execution === null) return {
8430
- ok: false,
8431
- error: Errors.notImplemented("organizationPayments", "executionComposition")
8432
- };
8433
- const result = await executePaymentLifecycle(execution, {
8434
- kind: "retry",
8435
- paymentId
8436
- }, options?.signal);
8437
- if (!result.ok) return result;
8438
- return {
8439
- ok: true,
8440
- value: result.value.payments.map((payment) => normalizePaymentTiming(payment))
8441
- };
8514
+ retry: (paymentId, options) => {
8515
+ const controls = deps.invocationControls?.(options) ?? options;
8516
+ return runCapxulEffect(Effect.gen(function* () {
8517
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
8518
+ const captured = carryInvocationParentSpan(controls, parent);
8519
+ const completed = yield* Effect.tryPromise({
8520
+ try: async () => {
8521
+ const execution = executionDependencies$1(deps);
8522
+ if (execution === null) return {
8523
+ ok: false,
8524
+ error: Errors.notImplemented("organizationPayments", "executionComposition")
8525
+ };
8526
+ const result = await executePaymentLifecycle(execution, {
8527
+ kind: "retry",
8528
+ paymentId
8529
+ }, controls?.signal, captured);
8530
+ if (!result.ok) return result;
8531
+ return {
8532
+ ok: true,
8533
+ value: result.value.payments.map((payment) => normalizePaymentTiming(payment))
8534
+ };
8535
+ },
8536
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
8537
+ });
8538
+ return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
8539
+ }), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.retry, deps.runPromise);
8442
8540
  },
8443
- pay: async (input, options) => {
8444
- const { permissionId, requestKey: providedRequestKey, lineage, ...item } = input;
8445
- const result = await execute({
8446
- permissionId,
8447
- ...providedRequestKey === void 0 ? {} : { requestKey: providedRequestKey },
8448
- items: [item],
8449
- ...lineage === void 0 ? {} : { lineage }
8450
- }, options?.signal, "organization-pay");
8451
- if (!result.ok) return result;
8452
- const payment = result.value[0];
8453
- return payment === void 0 ? {
8454
- ok: false,
8455
- error: Errors.unknown()
8456
- } : {
8457
- ok: true,
8458
- value: payment
8459
- };
8541
+ pay: (input, options) => {
8542
+ const controls = deps.invocationControls?.(options) ?? options;
8543
+ return runCapxulEffect(Effect.gen(function* () {
8544
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
8545
+ const captured = carryInvocationParentSpan(controls, parent);
8546
+ const completed = yield* Effect.tryPromise({
8547
+ try: async () => {
8548
+ const { permissionId, requestKey: providedRequestKey, lineage, ...item } = input;
8549
+ const result = await execute({
8550
+ permissionId,
8551
+ ...providedRequestKey === void 0 ? {} : { requestKey: providedRequestKey },
8552
+ items: [item],
8553
+ ...lineage === void 0 ? {} : { lineage }
8554
+ }, controls?.signal, "organization-pay", captured);
8555
+ if (!result.ok) return result;
8556
+ const payment = result.value[0];
8557
+ return payment === void 0 ? {
8558
+ ok: false,
8559
+ error: Errors.unknown()
8560
+ } : {
8561
+ ok: true,
8562
+ value: payment
8563
+ };
8564
+ },
8565
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
8566
+ });
8567
+ return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
8568
+ }), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.pay, deps.runPromise);
8460
8569
  },
8461
- payBatch: (input, options) => execute(input, options?.signal)
8570
+ payBatch: (input, options) => {
8571
+ const controls = deps.invocationControls?.(options) ?? options;
8572
+ return runCapxulEffect(Effect.gen(function* () {
8573
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
8574
+ const completed = yield* Effect.tryPromise({
8575
+ try: () => execute(input, controls?.signal, void 0, carryInvocationParentSpan(controls, parent)),
8576
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
8577
+ });
8578
+ return yield* completed.ok ? Effect.succeed(completed.value) : Effect.fail(completed.error);
8579
+ }), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.payBatch, deps.runPromise);
8580
+ }
8462
8581
  };
8463
8582
  }
8464
8583
  //#endregion
@@ -8555,12 +8674,14 @@ function executionDependencies(deps) {
8555
8674
  chainId: deps.chainId,
8556
8675
  convexCall: deps.convexCall,
8557
8676
  functions: moneyExecutionContract,
8677
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
8558
8678
  signer: deps.signer
8559
8679
  };
8560
8680
  }
8561
8681
  function makePayrollMethods(deps, orgId) {
8562
8682
  const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
8563
- async function authorize(input, signal) {
8683
+ async function authorize(input, controls) {
8684
+ const signal = controls?.signal;
8564
8685
  const execution = executionDependencies(deps);
8565
8686
  if (execution === null) return {
8566
8687
  ok: false,
@@ -8573,14 +8694,14 @@ function makePayrollMethods(deps, orgId) {
8573
8694
  let authorized;
8574
8695
  let preparedClosed = false;
8575
8696
  const submitted = await executePrepared(execution, async (signerAddress) => {
8576
- const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => deps.convexCall.action(payrollContract.authorizeRun, { input: {
8697
+ const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(payrollContract.authorizeRun, copyInvocationObservation(controls, { input: {
8577
8698
  orgId,
8578
8699
  permissionId: input.permissionId,
8579
8700
  requestKey: requestKey.key,
8580
8701
  signerAddress,
8581
8702
  period: input.period,
8582
8703
  items: input.items
8583
- } }));
8704
+ } }))), controls), deps.runPromise);
8584
8705
  if (!prepared.ok) return prepared;
8585
8706
  authorized = prepared.value.run;
8586
8707
  return {
@@ -8593,7 +8714,7 @@ function makePayrollMethods(deps, orgId) {
8593
8714
  requestKey: requestKey.key,
8594
8715
  runId: authorized.id,
8595
8716
  items: input.items
8596
- })(request), true, () => preparedClosed = true, signal);
8717
+ })(request), true, () => preparedClosed = true, signal, controls);
8597
8718
  try {
8598
8719
  await requestKey.finish(submitted.ok || preparedClosed);
8599
8720
  } catch {}
@@ -8607,35 +8728,48 @@ function makePayrollMethods(deps, orgId) {
8607
8728
  };
8608
8729
  }
8609
8730
  return {
8610
- runs: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.runs, () => Effect.map(deps.convexCall.query(payrollContract.runs, { orgId }), toPayrollRuns)),
8611
- authorizeRun: async (input, options) => {
8612
- if (options?.signal?.aborted === true) return {
8613
- ok: false,
8614
- error: Errors.cancelled({ operation: AUTHORIZE_RUN })
8615
- };
8616
- try {
8617
- return await authorize(input, options?.signal);
8618
- } catch (cause) {
8619
- return {
8620
- ok: false,
8621
- error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
8622
- };
8623
- }
8731
+ runs: (options) => {
8732
+ const controls = deps.invocationControls?.(options) ?? options;
8733
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.runs, copyInvocationObservation(controls, { orgId }))).pipe(Effect.map(toPayrollRuns)), controls, CAPXUL_OPERATIONS.payroll.runs, deps.runPromise);
8734
+ },
8735
+ authorizeRun: (input, options) => {
8736
+ const controls = deps.invocationControls?.(options) ?? options;
8737
+ return runCapxulEffect(Effect.gen(function* () {
8738
+ if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: AUTHORIZE_RUN }));
8739
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
8740
+ const result = yield* Effect.tryPromise({
8741
+ try: () => authorize(input, carryInvocationParentSpan(controls, parent)),
8742
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
8743
+ });
8744
+ return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
8745
+ }), observationOnlyControls(controls), AUTHORIZE_RUN, deps.runPromise);
8746
+ },
8747
+ terms: (options) => {
8748
+ const controls = deps.invocationControls?.(options) ?? options;
8749
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.terms, copyInvocationObservation(controls, { orgId }))), controls, CAPXUL_OPERATIONS.payroll.terms, deps.runPromise);
8624
8750
  },
8625
- terms: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.terms, () => deps.convexCall.query(payrollContract.terms, { orgId })),
8626
8751
  groups: {
8627
- list: (options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.groups.list, () => Effect.map(deps.convexCall.query(payrollContract.groups, { orgId }), (groups) => groups.map(toPayrollGroup))),
8628
- save: (input, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.groups.save, () => Effect.map(deps.convexCall.mutation(payrollContract.saveGroup, {
8629
- orgId,
8630
- ...input.id === void 0 ? {} : { id: String(input.id) },
8631
- name: input.name,
8632
- tone: input.tone,
8633
- members: input.members
8634
- }), toPayrollGroup)),
8635
- remove: (id, options) => runIfActive(options?.signal, CAPXUL_OPERATIONS.payroll.groups.remove, () => Effect.map(deps.convexCall.mutation(payrollContract.removeGroup, {
8636
- orgId,
8637
- id
8638
- }), () => void 0))
8752
+ list: (options) => {
8753
+ const controls = deps.invocationControls?.(options) ?? options;
8754
+ return runPortEffect(Effect.suspend(() => deps.convexCall.query(payrollContract.groups, copyInvocationObservation(controls, { orgId }))).pipe(Effect.map((groups) => groups.map(toPayrollGroup))), controls, CAPXUL_OPERATIONS.payroll.groups.list, deps.runPromise);
8755
+ },
8756
+ save: (input, options) => {
8757
+ const controls = deps.invocationControls?.(options) ?? options;
8758
+ return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.saveGroup, copyInvocationObservation(controls, {
8759
+ orgId,
8760
+ ...input.id === void 0 ? {} : { id: String(input.id) },
8761
+ name: input.name,
8762
+ tone: input.tone,
8763
+ members: input.members
8764
+ }))).pipe(Effect.map(toPayrollGroup)), controls, CAPXUL_OPERATIONS.payroll.groups.save, deps.runPromise);
8765
+ },
8766
+ remove: (id, options) => {
8767
+ const controls = deps.invocationControls?.(options) ?? options;
8768
+ return runPortEffect(Effect.suspend(() => deps.convexCall.mutation(payrollContract.removeGroup, copyInvocationObservation(controls, {
8769
+ orgId,
8770
+ id
8771
+ }))).pipe(Effect.asVoid), controls, CAPXUL_OPERATIONS.payroll.groups.remove, deps.runPromise);
8772
+ }
8639
8773
  }
8640
8774
  };
8641
8775
  }
@@ -9084,6 +9218,8 @@ function makeOrgMethods(deps) {
9084
9218
  const convexCall = deps.convexCall;
9085
9219
  return {
9086
9220
  ...makeActorRelationshipMethods({
9221
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
9222
+ ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
9087
9223
  actor: {
9088
9224
  kind: "org",
9089
9225
  orgId: String(orgId)
@@ -9213,6 +9349,8 @@ function makeOrgMethods(deps) {
9213
9349
  }, String(orgId)),
9214
9350
  payments: convexCall === void 0 ? makeNotImplementedOrganizationPaymentsMethods() : makeOrganizationPaymentsMethods({
9215
9351
  convexCall,
9352
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
9353
+ ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
9216
9354
  ...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
9217
9355
  ...deps.actor === void 0 ? {} : { actor: deps.actor },
9218
9356
  ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
@@ -9221,6 +9359,8 @@ function makeOrgMethods(deps) {
9221
9359
  }, String(orgId)),
9222
9360
  payroll: convexCall === void 0 ? makeUnavailablePayrollMethods() : makePayrollMethods({
9223
9361
  convexCall,
9362
+ ...deps.runPromise === void 0 ? {} : { runPromise: deps.runPromise },
9363
+ ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls },
9224
9364
  ...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
9225
9365
  ...deps.actor === void 0 ? {} : { actor: deps.actor },
9226
9366
  ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
@@ -9522,6 +9662,8 @@ function assembleCapxulClient(input) {
9522
9662
  let detectPendingOrgInvitations;
9523
9663
  let kickProvisioning;
9524
9664
  const financialOps = makeFinancialOpsMethods({
9665
+ runPromise: effectRunner.runPromise,
9666
+ invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
9525
9667
  actor,
9526
9668
  chainId: input.bootstrap.chainId,
9527
9669
  convexCall: input.ports.convexCall,
@@ -9541,7 +9683,7 @@ function assembleCapxulClient(input) {
9541
9683
  profileMethods: financialOps.me,
9542
9684
  convexCall: input.ports.convexCall,
9543
9685
  runPromise: effectRunner.runPromise,
9544
- invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
9686
+ invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
9545
9687
  ...input.signer === void 0 ? {} : { signer: input.signer }
9546
9688
  });
9547
9689
  kickProvisioning = accountBundle.kickProvisioning;
@@ -9594,21 +9736,21 @@ function assembleCapxulClient(input) {
9594
9736
  convexCall: input.ports.convexCall,
9595
9737
  telemetry: input.ports.telemetry,
9596
9738
  runPromise: effectRunner.runPromise,
9597
- invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
9739
+ invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
9598
9740
  });
9599
9741
  const accounts = makeAccountsMethods({
9600
9742
  accountReadPort: input.ports.accountRead,
9601
9743
  chainId: input.bootstrap.chainId,
9602
9744
  telemetry: input.ports.telemetry,
9603
9745
  runPromise: effectRunner.runPromise,
9604
- invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls)
9746
+ invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId)
9605
9747
  });
9606
9748
  const orgMethods = makeOrgMethods({
9607
9749
  actor,
9608
9750
  chainId: input.bootstrap.chainId,
9609
9751
  telemetry: input.ports.telemetry,
9610
9752
  runPromise: effectRunner.runPromise,
9611
- invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls),
9753
+ invocationControls: (controls) => withHostObservationControls(observation.hostObservationSnapshot, controls, actor.authSession()?.authUserId),
9612
9754
  requestKeyScope: `${input.bootstrap.convexUrl}:${String(input.bootstrap.chainId)}`,
9613
9755
  ...selectedOrgPort === void 0 ? {} : { orgPort: selectedOrgPort },
9614
9756
  convexCall: input.ports.convexCall,
@@ -9759,7 +9901,7 @@ function transitionError(record) {
9759
9901
  }
9760
9902
  function withHostObservation(actor, snapshot) {
9761
9903
  if (snapshot === void 0) return actor;
9762
- const controls = (input) => withHostObservationControls(snapshot, input);
9904
+ const controls = (input) => withHostObservationControls(snapshot, input, actor.authSession()?.authUserId);
9763
9905
  return {
9764
9906
  ...actor,
9765
9907
  ask: (event, input) => actor.ask(event, controls(input)),
@@ -9767,10 +9909,14 @@ function withHostObservation(actor, snapshot) {
9767
9909
  restoreAuthSession: (session, input) => actor.restoreAuthSession(session, controls(input))
9768
9910
  };
9769
9911
  }
9770
- function withHostObservationControls(snapshot, input) {
9771
- const copied = { ...input };
9772
- const captured = snapshot?.();
9773
- return captured === void 0 ? copied : attachInvocationObservation(copied, captured);
9912
+ function withHostObservationControls(snapshot, input, actorId) {
9913
+ const previous = readInvocationObservation(input);
9914
+ if (previous !== void 0) return attachInvocationObservation({ ...input }, previous);
9915
+ const captured = snapshot?.() ?? { active: true };
9916
+ return attachInvocationObservation({ ...input }, {
9917
+ ...captured,
9918
+ ...actorId === void 0 ? {} : { actorId }
9919
+ });
9774
9920
  }
9775
9921
  //#endregion
9776
9922
  export { stampTelemetryEnvelope as $, safeExceptionLabel as A, resolveFailureMode as B, observeFailedResult as C, normalizeExceptionErrorKind as D, SDK_VERSION as E, causeChain as F, sanitizeObservationContext as G, readInvocationObservation as H, injectedWalletSigner as I, CAPXUL_FUNCTIONS as J, PAYMENT_DIRECTIONS as K, isSignerNotReadySignal as L, fromWei as M, isSettingUpLifecycle as N, normalizeExceptionOperation as O, formatTraceparent as P, redactTelemetryProps as Q, openfortSignerNotReadyCode as R, observationContextProps as S, EXCEPTION_MESSAGE as T, OBSERVATION_CONTEXT_HEADER as U, copyInvocationObservation as V, encodeObservationContextHeader as W, EngineeringTelemetryBootstrapPolicy as X, BootstrapEnvelope as Y, redactTelemetryEvent as Z, fingerprintPaymentIntent as _, AccountReadPortTag as a, isRestoring as at, failureDetail as b, retryIdempotentRead as c, IdentityPortTag as d, CAPXUL_OPERATIONS as et, identityErrorFromCapxul as f, bootstrapErrorFromCapxul as g, BootstrapPortTag as h, smartAccountErrorFromCapxul as i, isClaimed as it, version as j, projectSdkException as k, PRODUCT_INVOCATION as l, convexCallErrorFromCapxul as m, detectAuthCacheAdapter as n, normalizeCapxulOperation as nt, accountReadErrorFromCapxul as o, ConvexCallPortTag as p, PAYMENT_STATUSES as q, SmartAccountPortTag as r, destination as rt, TelemetryPortTag as s, assembleCapxulClient as t, isCapxulOperation as tt, wireChainId as u, toWei as v, postHogFailureObservation as w, failureEvidenceProps as x, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as y, signerFailure as z };
package/dist/index.d.mts CHANGED
@@ -125,6 +125,7 @@ declare const CAPXUL_OPERATIONS: {
125
125
  readonly createOrganization: "identity.CreateOrganization";
126
126
  readonly ensureAccount: "identity.EnsureAccount";
127
127
  readonly leaveOrganization: "identity.LeaveOrganization";
128
+ readonly loadByAuthUserId: "identity.loadByAuthUserId";
128
129
  readonly loadCurrent: "identity.loadCurrent";
129
130
  readonly orgAt: "identity.OrgAt";
130
131
  readonly orgFailed: "identity.OrgFailed";
@@ -282,6 +283,7 @@ declare const CAPXUL_OPERATIONS: {
282
283
  readonly pay: "organizationPayments.pay";
283
284
  readonly payBatch: "organizationPayments.payBatch";
284
285
  readonly prepareExecution: "organizationPayments.prepareExecution";
286
+ readonly retry: "organizationPayments.retry";
285
287
  };
286
288
  readonly organizationSetup: {
287
289
  readonly getProofReceipt: "organizationSetup.getProofReceipt";
@@ -300,6 +302,7 @@ declare const CAPXUL_OPERATIONS: {
300
302
  readonly prepareExecution: "payments.prepareExecution";
301
303
  readonly prepareLifecycleExecution: "payments.prepareLifecycleExecution";
302
304
  readonly redirect: "payments.redirect";
305
+ readonly retry: "payments.retry";
303
306
  readonly submitCommandExecution: "payments.submitCommandExecution";
304
307
  readonly submitExecution: "payments.submitExecution";
305
308
  };
@@ -383,6 +386,7 @@ declare const CAPXUL_OPERATIONS: {
383
386
  readonly smartAccount: {
384
387
  readonly claim: "smartAccount.claim";
385
388
  readonly confirmDeployment: "smartAccount.confirmDeployment";
389
+ readonly loadByAuthUserId: "smartAccount.loadByAuthUserId";
386
390
  readonly loadCurrent: "smartAccount.loadCurrent";
387
391
  readonly provision: "smartAccount.provision";
388
392
  };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as stampTelemetryEnvelope, A as safeExceptionLabel, B as resolveFailureMode, C as observeFailedResult, D as normalizeExceptionErrorKind, E as SDK_VERSION$1, F as causeChain, G as sanitizeObservationContext, H as readInvocationObservation, I as injectedWalletSigner, J as CAPXUL_FUNCTIONS, K as PAYMENT_DIRECTIONS, L as isSignerNotReadySignal, M as fromWei, N as isSettingUpLifecycle, O as normalizeExceptionOperation, P as formatTraceparent, Q as redactTelemetryProps, R as openfortSignerNotReadyCode, S as observationContextProps, T as EXCEPTION_MESSAGE, U as OBSERVATION_CONTEXT_HEADER, V as copyInvocationObservation, W as encodeObservationContextHeader, X as EngineeringTelemetryBootstrapPolicy, Y as BootstrapEnvelope, _ as fingerprintPaymentIntent, a as AccountReadPortTag, at as isRestoring, b as failureDetail, c as retryIdempotentRead, d as IdentityPortTag, et as CAPXUL_OPERATIONS, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, h as BootstrapPortTag, i as smartAccountErrorFromCapxul, it as isClaimed, j as version, k as projectSdkException, l as PRODUCT_INVOCATION, m as convexCallErrorFromCapxul, n as detectAuthCacheAdapter, nt as normalizeCapxulOperation, o as accountReadErrorFromCapxul, p as ConvexCallPortTag, q as PAYMENT_STATUSES, r as SmartAccountPortTag, rt as destination, s as TelemetryPortTag, t as assembleCapxulClient, tt as isCapxulOperation, u as wireChainId, v as toWei, w as postHogFailureObservation, x as failureEvidenceProps, y as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, z as signerFailure } from "./create-capxul-client-DyCEJZtD.mjs";
1
+ import { $ as stampTelemetryEnvelope, A as safeExceptionLabel, B as resolveFailureMode, C as observeFailedResult, D as normalizeExceptionErrorKind, E as SDK_VERSION$1, F as causeChain, G as sanitizeObservationContext, H as readInvocationObservation, I as injectedWalletSigner, J as CAPXUL_FUNCTIONS, K as PAYMENT_DIRECTIONS, L as isSignerNotReadySignal, M as fromWei, N as isSettingUpLifecycle, O as normalizeExceptionOperation, P as formatTraceparent, Q as redactTelemetryProps, R as openfortSignerNotReadyCode, S as observationContextProps, T as EXCEPTION_MESSAGE, U as OBSERVATION_CONTEXT_HEADER, V as copyInvocationObservation, W as encodeObservationContextHeader, X as EngineeringTelemetryBootstrapPolicy, Y as BootstrapEnvelope, _ as fingerprintPaymentIntent, a as AccountReadPortTag, at as isRestoring, b as failureDetail, c as retryIdempotentRead, d as IdentityPortTag, et as CAPXUL_OPERATIONS, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, h as BootstrapPortTag, i as smartAccountErrorFromCapxul, it as isClaimed, j as version, k as projectSdkException, l as PRODUCT_INVOCATION, m as convexCallErrorFromCapxul, n as detectAuthCacheAdapter, nt as normalizeCapxulOperation, o as accountReadErrorFromCapxul, p as ConvexCallPortTag, q as PAYMENT_STATUSES, r as SmartAccountPortTag, rt as destination, s as TelemetryPortTag, t as assembleCapxulClient, tt as isCapxulOperation, u as wireChainId, v as toWei, w as postHogFailureObservation, x as failureEvidenceProps, y as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, z as signerFailure } from "./create-capxul-client-5Bk0PS0R.mjs";
2
2
  import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, H as toOrgId, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, P as toCurrencyCode, Q as CAPXUL_ERROR_CODES, R as toEpochSeconds, T as currencySymbolFor, U as toPartyId, V as toKycTier, X as HANDLE_RE, Y as toTesterKind, Z as decodeConvexError, d as AuthClientError, f as AuthClientPortTag, g as BASE_SEPOLIA_CHAIN_ID, h as normalizeBindingEmail, it as FAILURE_MODES, l as ClockPortTag, m as CAPXUL_PAYMENTS_V2_ADDRESS, nt as isCapxulError, q as toRoleKey, rt as CHAIN_UPSTREAMS, s as AuthCachePortTag, tt as Errors, u as authClientPortFromPromiseAdapter, x as EVM_ADDRESS_RE, z as toHandle } from "./clock-C2AUlq1V.mjs";
3
3
  import { n as SystemClockLayer } from "./OAuthBearerAuthClient-BHvDR8_0.mjs";
4
4
  import { Cause, Context, Data, Duration, Effect, Exit, Layer, Result, Schedule, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
@@ -1594,6 +1594,7 @@ function makeConnectionId() {
1594
1594
  //#region src/adapters/convex-call/ConvexCallAdapter.ts
1595
1595
  /** Exact floor-first allowlist; every additional handler must migrate its validator first. */
1596
1596
  const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
1597
+ "payroll/actions:authorizeRun",
1597
1598
  "account/actions:readBalance",
1598
1599
  "holdings/actions:current",
1599
1600
  "smartAccount/actions:claim",
@@ -1611,12 +1612,36 @@ const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
1611
1612
  "moneyExecution/paymentCommandActions:submitPaymentCommandExecution"
1612
1613
  ]);
1613
1614
  const OBSERVED_CONVEX_QUERIES = /* @__PURE__ */ new Set([
1615
+ "movement/activity:list",
1616
+ "movement/activity:summary",
1617
+ "movement/activity:get",
1618
+ "financialOps/queries:verifyPaymentDocument",
1619
+ "financialOps/queries:renderStoredDocument",
1620
+ "financialOps/addressBook:list",
1621
+ "financialOps/addressBook:get",
1622
+ "financialOps/requestsInbox:list",
1623
+ "financialOps/requestsInbox:get",
1624
+ "financialOps/requestsInbox:inboxList",
1625
+ "payroll/queries:runs",
1626
+ "payroll/queries:groups",
1627
+ "payroll/queries:terms",
1614
1628
  "financialOps/queries:resolveRecipient",
1615
1629
  "identity/queries:loadByAuthUserId",
1616
1630
  "smartAccount/queries:loadByAuthUserId",
1617
1631
  "org/lifecycle:load"
1618
1632
  ]);
1619
1633
  const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
1634
+ "movement/activity:annotate",
1635
+ "financialOps/addressBook:add",
1636
+ "financialOps/addressBook:hide",
1637
+ "financialOps/addressBook:unhide",
1638
+ "financialOps/addressBook:label",
1639
+ "financialOps/requestsInbox:issue",
1640
+ "financialOps/requestsInbox:cancel",
1641
+ "financialOps/requestsInbox:approve",
1642
+ "financialOps/requestsInbox:decline",
1643
+ "payroll/mutations:saveGroup",
1644
+ "payroll/mutations:removeGroup",
1620
1645
  "identity/mutations:create",
1621
1646
  "identity/mutations:update",
1622
1647
  "identity/mutations:completeOnboarding",
@@ -1685,7 +1710,7 @@ var ConvexCallAdapter = class {
1685
1710
  const carriedContext = sanitizeObservationContext(args.observationContext);
1686
1711
  let hostContext;
1687
1712
  const invocationSnapshot = readInvocationObservation(args);
1688
- if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.context;
1713
+ if (invocationSnapshot !== void 0) hostContext = invocationSnapshot.active ? invocationSnapshot.context : void 0;
1689
1714
  else {
1690
1715
  const resolveContext = this.#observation?.resolveContext;
1691
1716
  if (resolveContext !== void 0) try {
@@ -1,4 +1,4 @@
1
- import { M as fromWei, Z as redactTelemetryEvent, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, i as smartAccountErrorFromCapxul, m as convexCallErrorFromCapxul, o as accountReadErrorFromCapxul, t as assembleCapxulClient, u as wireChainId, v as toWei } from "../create-capxul-client-DyCEJZtD.mjs";
1
+ import { M as fromWei, Z as redactTelemetryEvent, f as identityErrorFromCapxul, g as bootstrapErrorFromCapxul, i as smartAccountErrorFromCapxul, m as convexCallErrorFromCapxul, o as accountReadErrorFromCapxul, t as assembleCapxulClient, u as wireChainId, v as toWei } from "../create-capxul-client-5Bk0PS0R.mjs";
2
2
  import { $ as CapxulError, A as toAuthUserId, B as toJwtToken, D as toAddress, E as toAccountId, F as toDurationMs, I as toEmail, J as toSessionToken, K as toPublishableKey, L as toEpochMs, M as toChainId, N as toCountryCode, O as toAllowedOrigin, R as toEpochSeconds, V as toKycTier, _ as deriveCapxulSafeAddress, k as toAppId, n as InMemoryAuthCacheAdapter, t as readClockNow, tt as Errors, u as authClientPortFromPromiseAdapter, v as validateHandle, z as toHandle } from "../clock-C2AUlq1V.mjs";
3
3
  import { Effect, Result, Semaphore } from "effect";
4
4
  import { keccak256 } from "viem";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Xelmar-tech/infrastructure.git",
@@ -50,9 +50,9 @@
50
50
  "@capxul/config": "0.3.0",
51
51
  "@capxul/errors": "0.3.0",
52
52
  "@capxul/typescript-config": "0.0.0",
53
- "@capxul/observability": "4.0.0",
54
53
  "@capxul/wire": "0.7.0",
55
- "@capxul/types": "0.3.0"
54
+ "@capxul/types": "0.3.0",
55
+ "@capxul/observability": "4.0.1"
56
56
  },
57
57
  "_permissionlessPinReason": "permissionless.toSafeSmartAccount is pinned to 0.3.4 for live Safe deployment E2E. Counterfactual address fixtures captured 2026-05-17 in packages/backend/convex/_shared/__tests__/counterfactual.test.ts and packages/config/tests/safe.test.ts must be re-verified before upgrading.",
58
58
  "scripts": {