@capxul/sdk 2.4.0 → 2.5.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.
@@ -96,10 +96,12 @@ const Errors = {
96
96
  accountNotFound: (accountId) => new CapxulError("ACCOUNT_NOT_FOUND", accountId ? `Openfort account ${accountId} not found` : "Openfort account not found", accountId === void 0 ? void 0 : { details: { accountId } }),
97
97
  providerError: (provider, operation, cause, opts) => {
98
98
  const details = {
99
+ ...opts?.details,
99
100
  provider,
100
101
  operation
101
102
  };
102
103
  if (opts?.failure_mode) details.failure_mode = opts.failure_mode;
104
+ if (opts?.httpStatus !== void 0) details.httpStatus = opts.httpStatus;
103
105
  return new CapxulError("PROVIDER_ERROR", `Provider error: ${provider} ${operation}`, {
104
106
  cause,
105
107
  details
@@ -293,6 +295,12 @@ function toPartyId(raw) {
293
295
  function toBudgetId(raw) {
294
296
  return toNonEmptyStringBrand(raw, "budgetId");
295
297
  }
298
+ function toPayrollRunId(raw) {
299
+ return toNonEmptyStringBrand(raw, "payrollRunId");
300
+ }
301
+ function toPayrollGroupId(raw) {
302
+ return toNonEmptyStringBrand(raw, "payrollGroupId");
303
+ }
296
304
  function toOrgId(raw) {
297
305
  return toNonEmptyStringBrand(raw, "orgId");
298
306
  }
@@ -488,4 +496,4 @@ Layer.effect(AuthCachePortTag, Effect.sync(() => new InMemoryAuthCacheAdapter())
488
496
  cause
489
497
  }))));
490
498
  //#endregion
491
- export { toPartyId as A, toDurationMs as C, toJwtToken as D, toEpochSeconds as E, CAPXUL_ERROR_CODES as F, CapxulError as I, EXPECTED_OPERATION_OUTCOMES as L, toRoleKey as M, toSessionToken as N, toKycTier as O, decodeConvexError as P, Errors as R, toCurrencyCode as S, toEpochMs as T, toAppId as _, AuthCacheError as a, toChainId as b, BYTES32_RE as c, WEI_RE as d, ZERO_BYTES32 as f, toAllowedOrigin as g, toAddress as h, parseCachedJwt as i, toPublishableKey as j, toOrgId as k, EVM_ADDRESS_RE as l, toAccountId as m, BrowserAuthCacheAdapter as n, AuthCachePortTag as o, currencySymbolFor as p, parseAuthSession as r, APP_ID_RE as s, InMemoryAuthCacheAdapter as t, SUPPORTED_CURRENCY_CODES as u, toAuthUserId as v, toEmail as w, toCountryCode as x, toBudgetId as y, isCapxulError as z };
499
+ export { toPartyId as A, Errors as B, toDurationMs as C, toJwtToken as D, toEpochSeconds as E, toSessionToken as F, decodeConvexError as I, CAPXUL_ERROR_CODES as L, toPayrollRunId as M, toPublishableKey as N, toKycTier as O, toRoleKey as P, CapxulError as R, toCurrencyCode as S, toEpochMs as T, isCapxulError as V, toAppId as _, AuthCacheError as a, toChainId as b, BYTES32_RE as c, WEI_RE as d, ZERO_BYTES32 as f, toAllowedOrigin as g, toAddress as h, parseCachedJwt as i, toPayrollGroupId as j, toOrgId as k, EVM_ADDRESS_RE as l, toAccountId as m, BrowserAuthCacheAdapter as n, AuthCachePortTag as o, currencySymbolFor as p, parseAuthSession as r, APP_ID_RE as s, InMemoryAuthCacheAdapter as t, SUPPORTED_CURRENCY_CODES as u, toAuthUserId as v, toEmail as w, toCountryCode as x, toBudgetId as y, EXPECTED_OPERATION_OUTCOMES as z };
@@ -1,4 +1,4 @@
1
- import { A as toPartyId, I as CapxulError, L as EXPECTED_OPERATION_OUTCOMES, M as toRoleKey, R as Errors, S as toCurrencyCode, b as toChainId, c as BYTES32_RE, d as WEI_RE, f as ZERO_BYTES32, h as toAddress, k as toOrgId, l as EVM_ADDRESS_RE$1, m as toAccountId, n as BrowserAuthCacheAdapter, s as APP_ID_RE, t as InMemoryAuthCacheAdapter, u as SUPPORTED_CURRENCY_CODES, v as toAuthUserId, w as toEmail, x as toCountryCode, y as toBudgetId, z as isCapxulError } from "./InMemoryAuthCacheAdapter-qMpBOGb3.mjs";
1
+ import { A as toPartyId, B as Errors, M as toPayrollRunId, P as toRoleKey, R as CapxulError, S as toCurrencyCode, V as isCapxulError, b as toChainId, c as BYTES32_RE, d as WEI_RE, f as ZERO_BYTES32, h as toAddress, j as toPayrollGroupId, k as toOrgId, l as EVM_ADDRESS_RE$1, m as toAccountId, n as BrowserAuthCacheAdapter, s as APP_ID_RE, t as InMemoryAuthCacheAdapter, u as SUPPORTED_CURRENCY_CODES, v as toAuthUserId, w as toEmail, x as toCountryCode, y as toBudgetId, z as EXPECTED_OPERATION_OUTCOMES } from "./InMemoryAuthCacheAdapter-uOcqpqu8.mjs";
2
2
  import { concat, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getContractAddress, keccak256, padHex, parseUnits, recoverAddress, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature } from "viem";
3
3
  import { Context, Data, Deferred, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, Scope } from "effect";
4
4
  import { makeFunctionReference } from "convex/server";
@@ -1490,6 +1490,15 @@ const CAPXUL_FUNCTIONS = {
1490
1490
  resumeBootstrapSubmission: "org/actions:resumeBootstrapSubmission",
1491
1491
  submitBootstrap: "org/actions:submitBootstrap"
1492
1492
  },
1493
+ "payroll/actions": { authorizeRun: "payroll/actions:authorizeRun" },
1494
+ "payroll/mutations": {
1495
+ removeGroup: "payroll/mutations:removeGroup",
1496
+ saveGroup: "payroll/mutations:saveGroup"
1497
+ },
1498
+ "payroll/queries": {
1499
+ groups: "payroll/queries:groups",
1500
+ runs: "payroll/queries:runs"
1501
+ },
1493
1502
  "permission/actions": { verify: "permission/actions:verify" },
1494
1503
  "permission/mutations": { command: "permission/mutations:command" },
1495
1504
  "permission/queries": {
@@ -2683,7 +2692,7 @@ Schema.Struct({
2683
2692
  items: Schema.Array(OrganizationPaymentExecutionItemSchema),
2684
2693
  lineage: Schema.optional(PaymentCommandLineageSchema)
2685
2694
  });
2686
- Schema.Struct({
2695
+ const PreparedPaymentCommandExecutionSchema = Schema.Struct({
2687
2696
  executionId: MoneyExecutionIdSchema,
2688
2697
  commandId: PaymentCommandIdSchema,
2689
2698
  paymentIds: Schema.Array(PaymentIdSchema),
@@ -2776,6 +2785,69 @@ Schema.Struct({
2776
2785
  userOpHash: Bytes32Schema,
2777
2786
  value: PermissionResourceSchema
2778
2787
  });
2788
+ const PayrollRunStatusSchema = Schema.Literals([
2789
+ "draft",
2790
+ "authorized",
2791
+ "settled"
2792
+ ]);
2793
+ const PayrollRunIdSchema = Schema.String.pipe(Schema.refine((value) => /^payroll_run_[0-9a-f]{64}$/u.test(value), { message: "payrollRunId must be a payroll_run_ digest identifier" }));
2794
+ const SignedMinorUnitSchema = Schema.String.pipe(Schema.refine((value) => /^-?(0|[1-9][0-9]*)$/u.test(value), { message: "must be an integer minor-unit string" }));
2795
+ const MinorUnitSchema = Schema.String.pipe(Schema.refine((value) => /^(0|[1-9][0-9]*)$/u.test(value), { message: "must be a non-negative integer minor-unit string" }));
2796
+ const PayrollRunItemInputSchema = Schema.Struct({
2797
+ to: PaymentRef,
2798
+ partyId: nonEmpty("partyId"),
2799
+ gross: MinorUnitSchema,
2800
+ net: MinorUnitSchema,
2801
+ adjustments: Schema.Array(Schema.Struct({
2802
+ label: Schema.String,
2803
+ amount: SignedMinorUnitSchema
2804
+ }))
2805
+ });
2806
+ Schema.Struct({
2807
+ orgId: nonEmpty("orgId"),
2808
+ permissionId: PermissionIdSchema,
2809
+ requestKey: nonEmpty("requestKey"),
2810
+ signerAddress: AddressSchema$1,
2811
+ period: Schema.Struct({
2812
+ start: nonNegativeInteger("period.start"),
2813
+ end: nonNegativeInteger("period.end")
2814
+ }),
2815
+ items: Schema.Array(PayrollRunItemInputSchema)
2816
+ });
2817
+ const PayrollRunSchema = Schema.Struct({
2818
+ id: PayrollRunIdSchema,
2819
+ status: PayrollRunStatusSchema,
2820
+ periodStart: nonNegativeInteger("periodStart"),
2821
+ periodEnd: nonNegativeInteger("periodEnd"),
2822
+ total: FinancialOpsMoney,
2823
+ recipientCount: nonNegativeInteger("recipientCount")
2824
+ });
2825
+ Schema.Struct({
2826
+ runs: Schema.Array(PayrollRunSchema),
2827
+ settledThisMonth: FinancialOpsMoney
2828
+ });
2829
+ Schema.Struct({
2830
+ run: PayrollRunSchema,
2831
+ execution: PreparedPaymentCommandExecutionSchema
2832
+ });
2833
+ const PayrollGroupIdSchema = Schema.String.pipe(Schema.refine((value) => /^payroll_group_[0-9A-Z]{26}$/u.test(value), { message: "payrollGroupId must be a payroll_group_ ULID identifier" }));
2834
+ const PayrollGroupMemberSchema = Schema.Struct({
2835
+ partyId: PartyIdSchema,
2836
+ amount: Schema.String,
2837
+ currency: CurrencyCodeSchema$1
2838
+ });
2839
+ Schema.Struct({
2840
+ id: PayrollGroupIdSchema,
2841
+ name: nonEmpty("name"),
2842
+ tone: Schema.String,
2843
+ members: Schema.Array(PayrollGroupMemberSchema)
2844
+ });
2845
+ Schema.Struct({
2846
+ id: Schema.optional(PayrollGroupIdSchema),
2847
+ name: Schema.String,
2848
+ tone: Schema.String,
2849
+ members: Schema.Array(PayrollGroupMemberSchema)
2850
+ });
2779
2851
  `
2780
2852
  .capxul-doc{--ink:#1d1d1f;--muted:#6e6e73;--line:#e7e7ea;--accent:#0a7d4b;--bg:#fff;
2781
2853
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,sans-serif;
@@ -2830,6 +2902,9 @@ const SENSITIVE_MATERIAL_PATTERNS = [
2830
2902
  /eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/u,
2831
2903
  /(?:(?:sk|pk|rk)_(?:live|test)|(?:phc|phx|ghp|gho|ghu|ghs|ghr|whsec)_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza)[A-Za-z0-9_-]*/iu
2832
2904
  ];
2905
+ const RAW_PRIVATE_KEY_MASK = /(^|[^a-fA-F0-9])[a-fA-F0-9]{64}(?=$|[^a-fA-F0-9])/gu;
2906
+ const KNOWN_CREDENTIAL_MASK = /(?:(?:sk|pk|rk)_(?:live|test)|(?:phc|phx|ghp|gho|ghu|ghs|ghr|whsec)_|github_pat_|xox[baprs]-|AKIA[0-9A-Z]{16}|AIza)[A-Za-z0-9_-]*/giu;
2907
+ const LABELLED_SECRET_MASK = /\b(api[ _-]?key|access[ _-]?token|token|secret|password|passphrase|private[ _-]?key|authorization|cookie|signature|request[ _-]?body|credential|otp|one[ _-]?time[ _-]?(?:password|code)|verification[ _-]?code)\b\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu;
2833
2908
  /**
2834
2909
  * Reject: does the value carry any known secret material? Best effort — callers
2835
2910
  * drop the whole value on a match; a false negative is a leak, a false positive
@@ -2838,6 +2913,14 @@ const SENSITIVE_MATERIAL_PATTERNS = [
2838
2913
  function containsSensitiveMaterial(value) {
2839
2914
  return SENSITIVE_MATERIAL_PATTERNS.some((pattern) => pattern.test(value));
2840
2915
  }
2916
+ /**
2917
+ * Mask: return the value with every known secret rewritten to `[REDACTED]`,
2918
+ * preserving surrounding text. Used where a value must still be shown (log
2919
+ * lines, issue bodies) but must not carry live credentials.
2920
+ */
2921
+ function redactSecrets(value) {
2922
+ return value.replace(/\bBearer\s+[^\s,;]+/giu, "Bearer [REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/gu, "[REDACTED]").replace(/\b0x[a-fA-F0-9]{40,}\b/gu, "[REDACTED]").replace(RAW_PRIVATE_KEY_MASK, "$1[REDACTED]").replace(KNOWN_CREDENTIAL_MASK, "[REDACTED]").replace(LABELLED_SECRET_MASK, (_match, label) => `${label}=[REDACTED]`);
2923
+ }
2841
2924
  //#endregion
2842
2925
  //#region ../wire/src/observation-context.ts
2843
2926
  /** Single bounded HTTP carrier used before a Convex action envelope exists. */
@@ -3171,8 +3254,8 @@ var ActorFailure = class extends Error {
3171
3254
  event;
3172
3255
  details;
3173
3256
  _tag = "ActorFailure";
3174
- constructor(reason, machine, state, event, details) {
3175
- super(`${machine}:${state}:${event} ${reason}`);
3257
+ constructor(reason, machine, state, event, details, cause) {
3258
+ super(`${machine}:${state}:${event} ${reason}`, cause === void 0 ? void 0 : { cause });
3176
3259
  this.reason = reason;
3177
3260
  this.machine = machine;
3178
3261
  this.state = state;
@@ -3247,8 +3330,8 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
3247
3330
  defect(cause);
3248
3331
  }
3249
3332
  };
3250
- const makeFailure = (state, event, reason, details) => new ActorFailure(reason, spec.machine, spec.label(state), event._tag, details);
3251
- const nonApplied = (state, event, reason, outcome, env) => {
3333
+ const makeFailure = (state, event, reason, details, cause) => new ActorFailure(reason, spec.machine, spec.label(state), event._tag, details, cause);
3334
+ const nonApplied = (state, event, reason, outcome, env, failure) => {
3252
3335
  const slot = env.origin?.slot ?? spec.slot(event);
3253
3336
  return copyInvocationObservation(env.invocation, {
3254
3337
  machine: spec.machine,
@@ -3259,7 +3342,8 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
3259
3342
  outcome,
3260
3343
  duration_ms: duration(env.startedAt),
3261
3344
  ...withCarriage(env.invocation),
3262
- ...outcome === "refused" ? { refusal_code: reason } : { error_code: reason }
3345
+ ...outcome === "refused" ? { refusal_code: reason } : { error_code: reason },
3346
+ ...failure === void 0 ? {} : { failure }
3263
3347
  });
3264
3348
  };
3265
3349
  const applied = (from, to, event, slot, epoch, env) => copyInvocationObservation(env.invocation, {
@@ -3312,12 +3396,13 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
3312
3396
  slots.delete(env.origin.slot);
3313
3397
  defect(exit.defect);
3314
3398
  const event = { _tag: env.origin.event };
3315
- const failedState = yield* recoverFailure(state, env.origin, {
3399
+ const died = {
3316
3400
  code: "WORK_DIED",
3317
- message: "Identity work died"
3318
- });
3319
- yield* emit(nonApplied(failedState, event, "WORK_DIED", "failed", env));
3320
- yield* failReply(held.reply, makeFailure(failedState, event, "WORK_DIED"));
3401
+ message: exit.defect instanceof Error ? exit.defect.message : "Identity work died"
3402
+ };
3403
+ const failedState = yield* recoverFailure(state, env.origin, died);
3404
+ yield* emit(nonApplied(failedState, event, "WORK_DIED", "failed", env, died));
3405
+ yield* failReply(held.reply, makeFailure(failedState, event, "WORK_DIED", void 0, died));
3321
3406
  return;
3322
3407
  }
3323
3408
  if (exit.failure !== void 0) {
@@ -3325,9 +3410,9 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
3325
3410
  const outcome = exit.failure.code === "CANCELLED" ? "cancelled" : "failed";
3326
3411
  const event = { _tag: env.origin.event };
3327
3412
  const failedState = exit.failure === timeoutFailure || exit.failure === cancelledFailure ? yield* recoverFailure(state, env.origin, exit.failure) : state;
3328
- yield* emit(nonApplied(failedState, event, exit.failure.code, outcome, env));
3413
+ yield* emit(nonApplied(failedState, event, exit.failure.code, outcome, env, exit.failure));
3329
3414
  const details = exit.failure === timeoutFailure ? { reason: "timeout" } : void 0;
3330
- yield* failReply(held.reply, makeFailure(failedState, event, exit.failure.code, details));
3415
+ yield* failReply(held.reply, makeFailure(failedState, event, exit.failure.code, details, exit.failure.error ?? exit.failure));
3331
3416
  return;
3332
3417
  }
3333
3418
  yield* finish(env.origin, state);
@@ -4542,7 +4627,10 @@ function canonicalJson(value) {
4542
4627
  async function fingerprintPaymentIntent(intent) {
4543
4628
  return keccak256(toBytes(canonicalJson(intent)));
4544
4629
  }
4545
- async function executePrepared(deps, prepare, expectedRequest, signal) {
4630
+ function matchesIntent(expected) {
4631
+ return async (request) => await fingerprintPaymentIntent(request) === await fingerprintPaymentIntent(expected);
4632
+ }
4633
+ async function executePrepared(deps, prepare, isExpectedRequest, signal) {
4546
4634
  if (isAborted$1(signal)) return {
4547
4635
  ok: false,
4548
4636
  error: Errors.cancelled({ operation: "payments" })
@@ -4563,7 +4651,7 @@ async function executePrepared(deps, prepare, expectedRequest, signal) {
4563
4651
  }
4564
4652
  const prepared = await prepare(signerAddress);
4565
4653
  if (!prepared.ok) return prepared;
4566
- if (await fingerprintPaymentIntent(prepared.value.request) !== await fingerprintPaymentIntent(expectedRequest)) return {
4654
+ if (!await isExpectedRequest(prepared.value.request)) return {
4567
4655
  ok: false,
4568
4656
  error: Errors.invalidInput("payment", "prepared command mismatch")
4569
4657
  };
@@ -4598,13 +4686,13 @@ function executePaymentLifecycle(deps, intent, signal) {
4598
4686
  return executePrepared(deps, (signerAddress) => runIfActive(signal, "payments.prepareLifecycleExecution", () => deps.convexCall.action(deps.functions.preparePaymentLifecycleExecution, { input: {
4599
4687
  signerAddress,
4600
4688
  intent
4601
- } })), intent, signal);
4689
+ } })), matchesIntent(intent), signal);
4602
4690
  }
4603
4691
  function executeOrganizationPayment(deps, input, signal) {
4604
4692
  return executePrepared(deps, (signerAddress) => runIfActive(signal, "organizationPayments.prepareExecution", () => deps.convexCall.action(deps.functions.prepareOrganizationPaymentExecution, { input: {
4605
4693
  ...input,
4606
4694
  signerAddress
4607
- } })), input, signal);
4695
+ } })), matchesIntent(input), signal);
4608
4696
  }
4609
4697
  //#endregion
4610
4698
  //#region src/surface/money.ts
@@ -5453,7 +5541,7 @@ function mapOk(result, f) {
5453
5541
  }
5454
5542
  //#endregion
5455
5543
  //#region package.json
5456
- var version = "2.4.0";
5544
+ var version = "2.5.1";
5457
5545
  //#endregion
5458
5546
  //#region src/ports/auth-client.ts
5459
5547
  var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
@@ -7520,7 +7608,7 @@ function makePermissionMethods(deps, orgId) {
7520
7608
  }
7521
7609
  //#endregion
7522
7610
  //#region src/surface/organization-payments.ts
7523
- function executionDependencies(input) {
7611
+ function executionDependencies$1(input) {
7524
7612
  return input.actor === void 0 || input.chainId === void 0 || input.signer === void 0 ? null : {
7525
7613
  actor: input.actor,
7526
7614
  chainId: input.chainId,
@@ -7537,7 +7625,7 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
7537
7625
  ok: false,
7538
7626
  error: Errors.cancelled({ operation })
7539
7627
  };
7540
- const execution = executionDependencies(deps);
7628
+ const execution = executionDependencies$1(deps);
7541
7629
  if (execution === null) return {
7542
7630
  ok: false,
7543
7631
  error: Errors.notImplemented("organizationPayments", "executionComposition")
@@ -7632,6 +7720,197 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
7632
7720
  };
7633
7721
  }
7634
7722
  //#endregion
7723
+ //#region src/contract/payroll.ts
7724
+ const payrollContract = {
7725
+ authorizeRun: makeFunctionReference(CAPXUL_FUNCTIONS["payroll/actions"].authorizeRun),
7726
+ runs: makeFunctionReference(CAPXUL_FUNCTIONS["payroll/queries"].runs),
7727
+ groups: makeFunctionReference(CAPXUL_FUNCTIONS["payroll/queries"].groups),
7728
+ saveGroup: makeFunctionReference(CAPXUL_FUNCTIONS["payroll/mutations"].saveGroup),
7729
+ removeGroup: makeFunctionReference(CAPXUL_FUNCTIONS["payroll/mutations"].removeGroup)
7730
+ };
7731
+ //#endregion
7732
+ //#region src/surface/payroll.ts
7733
+ const AUTHORIZE_RUN = "payroll.authorizeRun";
7734
+ function toPayrollRun(wire) {
7735
+ return {
7736
+ id: toPayrollRunId(wire.id),
7737
+ status: wire.status,
7738
+ periodStart: wire.periodStart,
7739
+ periodEnd: wire.periodEnd,
7740
+ total: wire.total,
7741
+ recipientCount: wire.recipientCount
7742
+ };
7743
+ }
7744
+ function toPayrollRuns(wire) {
7745
+ return {
7746
+ runs: wire.runs.map(toPayrollRun),
7747
+ settledThisMonth: wire.settledThisMonth
7748
+ };
7749
+ }
7750
+ function toPayrollGroup(wire) {
7751
+ return {
7752
+ id: toPayrollGroupId(wire.id),
7753
+ name: wire.name,
7754
+ tone: wire.tone,
7755
+ members: wire.members.map((member) => ({
7756
+ partyId: member.partyId,
7757
+ amount: member.amount,
7758
+ currency: member.currency
7759
+ }))
7760
+ };
7761
+ }
7762
+ const MINOR_UNIT_INTEGER = /^-?\d+$/u;
7763
+ /**
7764
+ * One prepared `Money` counted in the minor units `net` is written in, or
7765
+ * `null` when the value is not a decimal number. `amount.value` is a DECIMAL
7766
+ * string (`"200"` at 6 decimals is 200000000 minor units), so comparing it to
7767
+ * `net` directly would compare two different units and pass nothing.
7768
+ */
7769
+ function minorUnits(amount) {
7770
+ const [whole = "", fraction = ""] = amount.value.split(".");
7771
+ if (!/^\d+$/u.test(whole) || !/^\d*$/u.test(fraction) || fraction.length > amount.decimals) return null;
7772
+ return BigInt(whole + fraction.padEnd(amount.decimals, "0"));
7773
+ }
7774
+ /**
7775
+ * One prepared item must pay the person this caller named, the amount this
7776
+ * caller set, under a payslip that attests to the same figures.
7777
+ *
7778
+ * `issuedAt` and `employerRef` are server facts the caller cannot contradict,
7779
+ * so they are not compared. Everything the caller DID supply is: the recipient
7780
+ * `Ref`, the transfer amount against `net`, and the payslip's employee, gross
7781
+ * and net. Adjustments are not in the signed command at all — the backend
7782
+ * enforces `gross + Σ adjustments === net` (ADR-0022 R8), and gross and net
7783
+ * being right is what the signer can prove here.
7784
+ */
7785
+ function isRunItem(prepared, item) {
7786
+ if (prepared === void 0) return false;
7787
+ const payslip = prepared.document;
7788
+ return canonicalJson(prepared.to) === canonicalJson(item.to) && prepared.paymentType === "payroll" && MINOR_UNIT_INTEGER.test(item.net) && minorUnits(prepared.amount) === BigInt(item.net) && payslip?.primaryType === "Payslip" && payslip.message.employeeRef === item.partyId && payslip.message.gross === item.gross && payslip.message.net === item.net;
7789
+ }
7790
+ /**
7791
+ * The batch the backend derived from a payroll intent must be the batch this
7792
+ * caller asked for, checked before the digest is signed.
7793
+ *
7794
+ * The payslip envelope on each item is server-built and carries the run row's
7795
+ * own `issuedAt`, so the batch cannot be fingerprinted against a local copy
7796
+ * (`matchesIntent` is unavailable here). What CAN be verified is every field
7797
+ * the caller supplied — the org, the Budget, the request key, and per item the
7798
+ * recipient, the amount and the payslip figures — plus the lineage binding the
7799
+ * batch to the run just written. A prepared command that pays a different
7800
+ * person, a different amount, from a different Budget, or under a different
7801
+ * run never reaches the signer.
7802
+ */
7803
+ function isRunBatch(input) {
7804
+ return (request) => {
7805
+ const batch = request;
7806
+ return Promise.resolve(batch.orgId === input.orgId && batch.permissionId === input.permissionId && batch.requestKey === input.requestKey && batch.lineage?.kind === "payroll" && batch.lineage.runId === input.runId && batch.items?.length === input.items.length && input.items.every((item, index) => isRunItem(batch.items?.[index], item)));
7807
+ };
7808
+ }
7809
+ function executionDependencies(deps) {
7810
+ return deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0 ? null : {
7811
+ actor: deps.actor,
7812
+ chainId: deps.chainId,
7813
+ convexCall: deps.convexCall,
7814
+ functions: moneyExecutionContract,
7815
+ signer: deps.signer
7816
+ };
7817
+ }
7818
+ function makePayrollMethods(deps, orgId) {
7819
+ const requestKeyScope = deps.requestKeyScope ?? `client-${crypto.randomUUID()}`;
7820
+ async function authorize(input, signal) {
7821
+ const execution = executionDependencies(deps);
7822
+ if (execution === null) return {
7823
+ ok: false,
7824
+ error: Errors.notImplemented("payroll", "executionComposition")
7825
+ };
7826
+ const requestKey = await paymentRequestKeyLifecycle(`${requestKeyScope}:${AUTHORIZE_RUN}`, {
7827
+ orgId,
7828
+ input
7829
+ }, input.requestKey);
7830
+ let authorized;
7831
+ const submitted = await executePrepared(execution, async (signerAddress) => {
7832
+ const prepared = await runIfActive(signal, AUTHORIZE_RUN, () => deps.convexCall.action(payrollContract.authorizeRun, { input: {
7833
+ orgId,
7834
+ permissionId: input.permissionId,
7835
+ requestKey: requestKey.key,
7836
+ signerAddress,
7837
+ period: input.period,
7838
+ items: input.items
7839
+ } }));
7840
+ if (!prepared.ok) return prepared;
7841
+ authorized = prepared.value.run;
7842
+ return {
7843
+ ok: true,
7844
+ value: prepared.value.execution
7845
+ };
7846
+ }, (request) => authorized === void 0 || authorized.periodStart !== input.period.start || authorized.periodEnd !== input.period.end ? Promise.resolve(false) : isRunBatch({
7847
+ orgId,
7848
+ permissionId: input.permissionId,
7849
+ requestKey: requestKey.key,
7850
+ runId: authorized.id,
7851
+ items: input.items
7852
+ })(request), signal);
7853
+ try {
7854
+ await requestKey.finish(submitted.ok);
7855
+ } catch {}
7856
+ if (!submitted.ok) return submitted;
7857
+ return authorized === void 0 ? {
7858
+ ok: false,
7859
+ error: Errors.unknown()
7860
+ } : {
7861
+ ok: true,
7862
+ value: toPayrollRun(authorized)
7863
+ };
7864
+ }
7865
+ return {
7866
+ runs: (options) => runIfActive(options?.signal, "payroll.runs", () => Effect.map(deps.convexCall.query(payrollContract.runs, { orgId }), toPayrollRuns)),
7867
+ authorizeRun: async (input, options) => {
7868
+ if (options?.signal?.aborted === true) return {
7869
+ ok: false,
7870
+ error: Errors.cancelled({ operation: AUTHORIZE_RUN })
7871
+ };
7872
+ try {
7873
+ return await authorize(input, options?.signal);
7874
+ } catch (cause) {
7875
+ return {
7876
+ ok: false,
7877
+ error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
7878
+ };
7879
+ }
7880
+ },
7881
+ groups: {
7882
+ list: (options) => runIfActive(options?.signal, "payroll.groups.list", () => Effect.map(deps.convexCall.query(payrollContract.groups, { orgId }), (groups) => groups.map(toPayrollGroup))),
7883
+ save: (input, options) => runIfActive(options?.signal, "payroll.groups.save", () => Effect.map(deps.convexCall.mutation(payrollContract.saveGroup, {
7884
+ orgId,
7885
+ ...input.id === void 0 ? {} : { id: String(input.id) },
7886
+ name: input.name,
7887
+ tone: input.tone,
7888
+ members: input.members
7889
+ }), toPayrollGroup)),
7890
+ remove: (id, options) => runIfActive(options?.signal, "payroll.groups.remove", () => Effect.map(deps.convexCall.mutation(payrollContract.removeGroup, {
7891
+ orgId,
7892
+ id
7893
+ }), () => void 0))
7894
+ }
7895
+ };
7896
+ }
7897
+ const payrollUnavailable = () => Promise.resolve({
7898
+ ok: false,
7899
+ error: Errors.notImplemented("payroll", "executionComposition")
7900
+ });
7901
+ /** The bundle an unconfigured client exposes — every verb refuses, none throws. */
7902
+ function makeUnavailablePayrollMethods() {
7903
+ return {
7904
+ runs: payrollUnavailable,
7905
+ authorizeRun: payrollUnavailable,
7906
+ groups: {
7907
+ list: payrollUnavailable,
7908
+ save: payrollUnavailable,
7909
+ remove: payrollUnavailable
7910
+ }
7911
+ };
7912
+ }
7913
+ //#endregion
7635
7914
  //#region src/surface/_shared/org-telemetry.ts
7636
7915
  /** Extract the domain from an email for telemetry (never the local part / PII). */
7637
7916
  function emailDomain$1(email) {
@@ -8169,6 +8448,13 @@ function makeOrgMethods(deps) {
8169
8448
  ...deps.actor === void 0 ? {} : { actor: deps.actor },
8170
8449
  ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
8171
8450
  ...deps.signer === void 0 ? {} : { signer: deps.signer }
8451
+ }, String(orgId)),
8452
+ payroll: convexCall === void 0 ? makeUnavailablePayrollMethods() : makePayrollMethods({
8453
+ convexCall,
8454
+ ...deps.requestKeyScope === void 0 ? {} : { requestKeyScope: deps.requestKeyScope },
8455
+ ...deps.actor === void 0 ? {} : { actor: deps.actor },
8456
+ ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
8457
+ ...deps.signer === void 0 ? {} : { signer: deps.signer }
8172
8458
  }, String(orgId))
8173
8459
  };
8174
8460
  }
@@ -8551,23 +8837,50 @@ function observeSdkClient(client, adapter, snapshot) {
8551
8837
  }
8552
8838
  }
8553
8839
  /** @internal Reports a factory-level typed failure without changing its identity. */
8554
- function observeFailedResult(result, adapter, operation) {
8555
- if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterSnapshot(adapter));
8840
+ function observeFailedResult(result, adapter, operation, origin) {
8841
+ if (adapter !== void 0 && isFailedResult(result)) report(adapter, "operation", operation, result.error, resolveAdapterSnapshot(adapter), origin);
8556
8842
  return result;
8557
8843
  }
8558
- function report(adapter, kind, operation, cause, invocation) {
8844
+ /**
8845
+ * One failure, one event. The identity machine reports a failed transition
8846
+ * first; when the same `CapxulError` then surfaces as a public method result
8847
+ * (directly or down its `cause` chain), the boundary drops that second report.
8848
+ * Only machine-reported errors are remembered, so a caller that reuses one
8849
+ * error object across unrelated public methods still sees every report.
8850
+ */
8851
+ const machineReportedCauses = /* @__PURE__ */ new WeakSet();
8852
+ function reportedByMachine(cause) {
8853
+ let link = cause;
8854
+ for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
8855
+ if (machineReportedCauses.has(link)) return true;
8856
+ link = link.cause;
8857
+ }
8858
+ return false;
8859
+ }
8860
+ function report(adapter, kind, operation, cause, invocation, origin) {
8861
+ if (origin === "machine") {
8862
+ let link = cause;
8863
+ for (let depth = 0; depth < 8 && typeof link === "object" && link !== null; depth++) {
8864
+ machineReportedCauses.add(link);
8865
+ link = link.cause;
8866
+ }
8867
+ } else if (reportedByMachine(cause)) return;
8559
8868
  const operationName = normalizeOperation(operation);
8560
8869
  const kindName = normalizeErrorKind(errorKind(cause));
8561
8870
  const context = sanitizeObservationContext({
8562
8871
  ...invocation.context,
8563
8872
  ...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
8564
8873
  });
8874
+ const detail = failureDetail(cause);
8875
+ const evidence = failureEvidence(cause);
8565
8876
  const failure = markFailureInvocationSnapshot({
8566
- exception: syntheticException(operationName, kindName),
8877
+ exception: syntheticException(operationName, kindName, evidence.message, evidence.stack),
8567
8878
  sdkVersion: SDK_VERSION,
8568
8879
  operation: operationName,
8569
8880
  errorKind: kindName,
8570
- ...context === void 0 ? {} : { context }
8881
+ ...context === void 0 ? {} : { context },
8882
+ ...detail === void 0 ? {} : { detail },
8883
+ ...evidence
8571
8884
  }, {
8572
8885
  active: invocation.active,
8573
8886
  ...context === void 0 ? {} : { context }
@@ -8630,19 +8943,24 @@ function postHogProperties(failure, context) {
8630
8943
  operation: failure.operation,
8631
8944
  error_kind: failure.errorKind,
8632
8945
  handled: true,
8946
+ ...failure.detail,
8947
+ ...failure.message === void 0 ? {} : { error_message: failure.message },
8948
+ ...failure.details === void 0 ? {} : { error_details: failure.details },
8949
+ ...failure.causeChain === void 0 ? {} : { error_cause: failure.causeChain.join(" <- ") },
8633
8950
  ...observationContextProps(merged)
8634
8951
  };
8635
8952
  }
8636
8953
  function postHogExceptionProperties(failure, properties) {
8637
8954
  const filename = `capxul-sdk-observation://boundary/${failure.operation}`;
8955
+ const message = failure.message ?? "Capxul SDK operation failed";
8638
8956
  return {
8639
8957
  ...properties,
8640
8958
  $exception_type: failure.errorKind,
8641
- $exception_message: EXCEPTION_MESSAGE,
8959
+ $exception_message: message,
8642
8960
  $exception_level: "error",
8643
8961
  $exception_list: [{
8644
8962
  type: failure.errorKind,
8645
- value: EXCEPTION_MESSAGE,
8963
+ value: message,
8646
8964
  mechanism: {
8647
8965
  type: "capxul_sdk_boundary",
8648
8966
  handled: true,
@@ -8658,10 +8976,77 @@ function postHogExceptionProperties(failure, properties) {
8658
8976
  colno: 1,
8659
8977
  in_app: true
8660
8978
  }]
8661
- }
8979
+ },
8980
+ ...failure.stack === void 0 ? {} : { stack: failure.stack }
8662
8981
  }]
8663
8982
  };
8664
8983
  }
8984
+ const MAX_EVIDENCE_TEXT = 4e3;
8985
+ const MAX_CAUSE_DEPTH = 8;
8986
+ function evidenceText(value) {
8987
+ if (typeof value !== "string" || value.length === 0) return void 0;
8988
+ return redactSecrets(value).slice(0, MAX_EVIDENCE_TEXT);
8989
+ }
8990
+ /** A field whose NAME says credential is masked whatever its value looks like. */
8991
+ const CREDENTIAL_FIELD_NAME = /(?:otp|pass(?:word|wd|phrase)?|token|secret|credential|api[_-]?key|private[_-]?key|authorization|cookie|session)/iu;
8992
+ /** Copy a details object into a JSON-safe shape with every string masked. */
8993
+ function evidenceValue(value, depth = 0) {
8994
+ if (typeof value === "string") return evidenceText(value);
8995
+ if (typeof value === "number" || typeof value === "boolean" || value === null) return value;
8996
+ if (typeof value === "bigint") return value.toString();
8997
+ if (value instanceof Error) return evidenceText(value.message);
8998
+ if (depth >= 4 || typeof value !== "object") return void 0;
8999
+ if (Array.isArray(value)) return value.slice(0, 50).map((item) => evidenceValue(item, depth + 1));
9000
+ const copy = {};
9001
+ for (const [key, nested] of Object.entries(value)) {
9002
+ if (CREDENTIAL_FIELD_NAME.test(key)) {
9003
+ copy[key] = "[REDACTED]";
9004
+ continue;
9005
+ }
9006
+ const safe = evidenceValue(nested, depth + 1);
9007
+ if (safe !== void 0) copy[key] = safe;
9008
+ }
9009
+ return copy;
9010
+ }
9011
+ /**
9012
+ * @internal The evidence in PostHog property shape, for product events that
9013
+ * name a failure (`bootstrap_failed`). Same keys as the `$exception` event.
9014
+ */
9015
+ function failureEvidenceProps(cause) {
9016
+ const evidence = failureEvidence(cause);
9017
+ return {
9018
+ ...evidence.message === void 0 ? {} : { error_message: evidence.message },
9019
+ ...evidence.details === void 0 ? {} : { error_details: evidence.details },
9020
+ ...evidence.causeChain === void 0 ? {} : { error_cause: evidence.causeChain.join(" <- ") }
9021
+ };
9022
+ }
9023
+ /** The real failure, masked for secrets only. Never throws. */
9024
+ function failureEvidence(cause) {
9025
+ try {
9026
+ const message = cause instanceof Error ? evidenceText(cause.message) : evidenceText(cause);
9027
+ const stack = cause instanceof Error ? evidenceText(cause.stack) : void 0;
9028
+ const details = isCapxulError(cause) && typeof cause.details === "object" && cause.details !== null ? evidenceValue(cause.details) : void 0;
9029
+ const causeChain = [];
9030
+ let previous = message;
9031
+ let link = cause instanceof Error ? cause.cause : void 0;
9032
+ for (let depth = 0; depth < MAX_CAUSE_DEPTH && link !== void 0 && link !== null; depth++) {
9033
+ const text = link instanceof Error ? evidenceText(link.message) : evidenceText(link);
9034
+ if (text !== void 0 && text !== previous) {
9035
+ causeChain.push(text);
9036
+ previous = text;
9037
+ }
9038
+ link = link instanceof Error ? link.cause : void 0;
9039
+ }
9040
+ return {
9041
+ ...message === void 0 ? {} : { message },
9042
+ ...details === void 0 || Object.keys(details).length === 0 ? {} : { details },
9043
+ ...causeChain.length === 0 ? {} : { causeChain },
9044
+ ...stack === void 0 ? {} : { stack }
9045
+ };
9046
+ } catch {
9047
+ return {};
9048
+ }
9049
+ }
8665
9050
  function errorKind(cause) {
8666
9051
  try {
8667
9052
  if (isCapxulError(cause)) return normalizeErrorKind(cause.code);
@@ -8675,14 +9060,61 @@ function sanitizeFailureObservation(failure) {
8675
9060
  const operation = normalizeOperation(failure.operation);
8676
9061
  const kind = normalizeErrorKind(failure.errorKind);
8677
9062
  const context = sanitizeObservationContext(failure.context);
9063
+ const detail = sanitizeFailureDetail(failure.detail);
9064
+ const message = evidenceText(failure.message);
9065
+ const stack = evidenceText(failure.stack);
9066
+ const details = typeof failure.details === "object" && failure.details !== null ? evidenceValue(failure.details) : void 0;
9067
+ const causeChain = Array.isArray(failure.causeChain) ? failure.causeChain.map(evidenceText).filter((text) => text !== void 0) : void 0;
8678
9068
  return {
8679
- exception: syntheticException(operation, kind),
9069
+ exception: syntheticException(operation, kind, message, stack),
8680
9070
  sdkVersion: normalizeSdkVersion(failure.sdkVersion),
8681
9071
  operation,
8682
9072
  errorKind: kind,
8683
- ...context === void 0 ? {} : { context }
9073
+ ...context === void 0 ? {} : { context },
9074
+ ...detail === void 0 ? {} : { detail },
9075
+ ...message === void 0 ? {} : { message },
9076
+ ...details === void 0 || Object.keys(details).length === 0 ? {} : { details },
9077
+ ...causeChain === void 0 || causeChain.length === 0 ? {} : { causeChain },
9078
+ ...stack === void 0 ? {} : { stack }
8684
9079
  };
8685
9080
  }
9081
+ /**
9082
+ * @internal Lift the enumerated discriminators off a `CapxulError` so a
9083
+ * boundary event says WHICH provider failed and HOW, not just `PROVIDER_ERROR`.
9084
+ * Shared by the failure boundary and the `bootstrap_failed` product event.
9085
+ */
9086
+ function failureDetail(cause) {
9087
+ if (!isCapxulError(cause)) return void 0;
9088
+ const details = cause.details;
9089
+ if (typeof details !== "object" || details === null) return void 0;
9090
+ const source = details;
9091
+ return sanitizeFailureDetail({
9092
+ provider: source.provider,
9093
+ provider_operation: source.operation,
9094
+ failure_mode: source.failure_mode,
9095
+ reason: source.reason,
9096
+ http_status: source.httpStatus
9097
+ });
9098
+ }
9099
+ function sanitizeFailureDetail(input) {
9100
+ if (typeof input !== "object" || input === null) return void 0;
9101
+ const source = input;
9102
+ const detail = {};
9103
+ for (const key of [
9104
+ "provider",
9105
+ "provider_operation",
9106
+ "failure_mode",
9107
+ "reason"
9108
+ ]) {
9109
+ const value = source[key];
9110
+ if (typeof value === "string" && ENUMERATED_DETAIL_RE.test(value)) detail[key] = value;
9111
+ }
9112
+ const status = source.http_status;
9113
+ if (typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599) detail.http_status = status;
9114
+ return Object.keys(detail).length === 0 ? void 0 : detail;
9115
+ }
9116
+ /** Enumerated codes only (`convex`, `no-secure-context`, `bootstrap-encode`); free text fails. */
9117
+ const ENUMERATED_DETAIL_RE = /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u;
8686
9118
  function normalizeSdkVersion(value) {
8687
9119
  return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9.+_-]{0,127}$/u.test(value) ? value : "unknown";
8688
9120
  }
@@ -8692,10 +9124,10 @@ function normalizeOperation(value) {
8692
9124
  function normalizeErrorKind(value) {
8693
9125
  return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_.-]{0,63}$/u.test(value) ? value : "Error";
8694
9126
  }
8695
- function syntheticException(operation, kind) {
8696
- const error = /* @__PURE__ */ new Error(EXCEPTION_MESSAGE);
9127
+ function syntheticException(operation, kind, message = EXCEPTION_MESSAGE, stack) {
9128
+ const error = new Error(message);
8697
9129
  error.name = kind;
8698
- error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)`;
9130
+ error.stack = `${kind}: ${error.message}\n at CapxulSdkBoundary.${operation} (capxul-sdk-observation://boundary/${operation}:1:1)` + (stack === void 0 ? "" : `\nCaused by: ${stack}`);
8699
9131
  return error;
8700
9132
  }
8701
9133
  function isPromiseLike(value) {
@@ -8900,10 +9332,19 @@ function assembleCapxulClient(input) {
8900
9332
  const unsubscribeProductTelemetry = actor.subscribeTransitions((record) => {
8901
9333
  effectRunner.runPromise(executeIdentityProductObservation(input.ports.telemetry, record, actor.snapshot())).catch(() => {});
8902
9334
  });
9335
+ const failureObservation = observation.failureObservation;
9336
+ const unsubscribeFailureObservation = failureObservation === void 0 ? () => {} : actor.subscribeTransitions((record) => {
9337
+ if (record.outcome !== "failed") return;
9338
+ observeFailedResult({
9339
+ ok: false,
9340
+ error: transitionError(record)
9341
+ }, failureObservation, `identity.${record.event}`, "machine");
9342
+ });
8903
9343
  let stopPromise = null;
8904
9344
  const stopActor = () => {
8905
9345
  if (stopPromise === null) {
8906
9346
  unsubscribeProductTelemetry();
9347
+ unsubscribeFailureObservation();
8907
9348
  stopPromise = effectRunner.runPromise(Scope.close(scope, Exit.void));
8908
9349
  }
8909
9350
  return stopPromise;
@@ -9088,6 +9529,30 @@ function assembleCapxulClient(input) {
9088
9529
  }
9089
9530
  }, observation.failureObservation, observation.hostObservationSnapshot);
9090
9531
  }
9532
+ function transitionError(record) {
9533
+ const failure = record.failure;
9534
+ if (failure?.error !== void 0) {
9535
+ const error = failure.error;
9536
+ if (record.correlation_id === void 0 || error.correlationId !== void 0) return error;
9537
+ return new CapxulError(error.code, error.message, {
9538
+ cause: error,
9539
+ correlationId: record.correlation_id,
9540
+ ...error.details === void 0 ? {} : { details: error.details },
9541
+ ...error.layer === void 0 ? {} : { layer: error.layer }
9542
+ });
9543
+ }
9544
+ return new CapxulError(record.error_code, failure?.message ?? "Identity work failed", {
9545
+ ...failure === void 0 ? {} : { cause: failure },
9546
+ details: {
9547
+ machine: record.machine,
9548
+ state: record.state,
9549
+ event: record.event,
9550
+ slot: record.slot,
9551
+ ...failure?.mode === void 0 ? {} : { failure_mode: failure.mode }
9552
+ },
9553
+ ...record.correlation_id === void 0 ? {} : { correlationId: record.correlation_id }
9554
+ });
9555
+ }
9091
9556
  function withHostObservation(actor, snapshot) {
9092
9557
  if (snapshot === void 0) return actor;
9093
9558
  const controls = (input) => {
@@ -9103,4 +9568,4 @@ function withHostObservation(actor, snapshot) {
9103
9568
  };
9104
9569
  }
9105
9570
  //#endregion
9106
- export { isClaimed as $, fingerprintPaymentIntent as A, OBSERVATION_CONTEXT_HEADER as B, ClockPortTag as C, AuthClientError as D, authClientPortFromPromiseAdapter as E, copyInvocationObservation as F, CAPXUL_FUNCTIONS as G, sanitizeObservationContext as H, readInvocationObservation as I, CAPXUL_PAYMENTS_V2_ADDRESS as J, BootstrapEnvelope as K, causeChain as L, fromWei as M, isSettingUpLifecycle as N, AuthClientPortTag as O, formatTraceparent as P, destination as Q, injectedWalletSigner as R, ClockError as S, bootstrapErrorFromCapxul as T, PAYMENT_DIRECTIONS as U, encodeObservationContextHeader as V, PAYMENT_STATUSES as W, BASE_SEPOLIA_CHAIN_ID as X, normalizeBindingEmail as Y, deriveCapxulSafeAddress as Z, wireChainId as _, observeFailedResult as a, ConvexCallPortTag as b, captureExceptionSync as c, TelemetryPortTag as d, isRestoring as et, redactTelemetryEvent as f, accountReadErrorFromCapxul as g, AccountReadPortTag as h, observationContextProps as i, toWei as j, version as k, detectAuthCacheAdapter as l, smartAccountErrorFromCapxul as m, postHogProductTelemetry as n, postHogFailureObservation as o, SmartAccountPortTag as p, EngineeringTelemetryBootstrapPolicy as q, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as r, captureException as s, assembleCapxulClient as t, PostHogTelemetryLayer as u, IdentityPortTag as v, BootstrapPortTag as w, convexCallErrorFromCapxul as x, identityErrorFromCapxul as y, signerFailure as z };
9571
+ export { deriveCapxulSafeAddress as $, AuthClientPortTag as A, injectedWalletSigner as B, convexCallErrorFromCapxul as C, bootstrapErrorFromCapxul as D, BootstrapPortTag as E, isSettingUpLifecycle as F, PAYMENT_DIRECTIONS as G, OBSERVATION_CONTEXT_HEADER as H, formatTraceparent as I, BootstrapEnvelope as J, PAYMENT_STATUSES as K, copyInvocationObservation as L, fingerprintPaymentIntent as M, toWei as N, authClientPortFromPromiseAdapter as O, fromWei as P, BASE_SEPOLIA_CHAIN_ID as Q, readInvocationObservation as R, ConvexCallPortTag as S, ClockPortTag as T, encodeObservationContextHeader as U, signerFailure as V, sanitizeObservationContext as W, CAPXUL_PAYMENTS_V2_ADDRESS as X, EngineeringTelemetryBootstrapPolicy as Y, normalizeBindingEmail as Z, AccountReadPortTag as _, failureEvidenceProps as a, IdentityPortTag as b, postHogFailureObservation as c, detectAuthCacheAdapter as d, destination as et, PostHogTelemetryLayer as f, smartAccountErrorFromCapxul as g, SmartAccountPortTag as h, failureDetail as i, version as j, AuthClientError as k, captureException as l, redactTelemetryEvent as m, postHogProductTelemetry as n, isRestoring as nt, observationContextProps as o, TelemetryPortTag as p, CAPXUL_FUNCTIONS as q, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as r, observeFailedResult as s, assembleCapxulClient as t, isClaimed as tt, captureExceptionSync as u, accountReadErrorFromCapxul as v, ClockError as w, identityErrorFromCapxul as x, wireChainId as y, causeChain as z };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as toCountryCode, B as OrgId, C as Address, N as CountryCode, O as AuthSession, Q as toAddress, S as AccountId, V as PartyId, a as SignerStatusStore, c as AccountProviderSource, d as eip1193AccountProvider, et as CAPXUL_ERROR_CODES, f as localPrivateKeyAccountProvider, g as SmartAccount, h as Session, i as SignerStatus, it as Errors, j as BudgetId, k as AuthUserId, l as AccountRequirement, m as Profile, n as CapxulSigner, nt as CapxulErrorCode, o as injectedWalletSigner, ot as FailureMode, p as CapxulResult, q as RoleKey, r as Eip1193RequestProvider, rt as CapxulErrorDetails, s as AccountProvider, st as isCapxulError, t as CapxulDigestSigner, tt as CapxulError, u as Eip1193Provider, x as Account, z as Money } from "./signer-BGTaqZqg.mjs";
2
- import { $ as AccountsMethods, $t as PaymentDocumentRef, A as OrgView, An as PAYMENT_STATUSES, At as Destination, B as OrganizationPaymentsMethods, Bn as IdentityState, Bt as MeMethods, C as DetectPendingOrgInvitationsResult, Cn as OrgSetupStep, Ct as ActivityRange, D as OrgMethods, Dn as SubmittedPermissionExecution, Dt as ActivitySummaryTotal, E as MemberView, En as Permission, Et as ActivitySummaryParams, F as RoleSpendCap, Ft as DestinationRail, G as PermissionOptions, Gn as isClaimed, Gt as OfframpQuoteInput, H as PermissionChangeInput, Hn as Readiness, Ht as MovementActivityEvidence, I as RoleView, In as TelemetryPort, It as DestinationRemoveInput, J as PermissionReadResult, Jn as InvocationControls, Jt as PayeesMethods, K as PermissionReplaceInput, Kn as isRestoring, Kt as OfframpStatus, L as OrganizationPaymentBatchInput, Ln as CAPXUL_PAYMENTS_V2_ADDRESS, Lt as DestinationsMethods, M as OrganizationAuditLogItem, Mn as RequestStatus, Mt as DestinationKind, N as ResendInviteTokenInput, Nt as DestinationListInput, O as OrgScopedMethods, On as InboxStatus, Ot as ActorReference, P as RoleDefinition, Pt as DestinationPayload, Q as OrgMeOptions, Qt as PaymentDocumentKind, R as OrganizationPaymentInput, Rn as Destination$1, Rt as FinancialOpsMethods, S as CreateOrgInput, Sn as OrgLifecycle, St as ActivityPage, T as MemberStatus, Tn as CurrentHoldings, Tt as ActivitySummary, U as PermissionCreateInput, Un as StateLabel, Ut as OfframpMethods, V as PermissionAssignInput, Vn as OrgLane, Vt as MeProfile, W as PermissionMethods, Wn as destination, Wt as OfframpQuote, X as OrgMe, Xt as PaymentActivityEvidence, Y as Budget, Yt as Payment, Z as OrgMeMethod, Zt as PaymentDirection, _ as SystemMethods, _n as AccountSetupStep, _t as ActivityFilter, a as SdkFailureObservation, an as PaymentTiming, at as ActorRequestIssueInput, b as CurrentUserContext, bn as SmartAccountMethods, bt as ActivityListParams, c as PostHogObservabilityOptions, cn as PaymentsPayInput, ct as AddressBookEntry, d as CreateCapxulClientInput, dn as Ref, dt as InboxApproveInput, en as PaymentDocumentRender, et as AccountMethods, f as IdentityProfileDetails, fn as ResolvedTarget, ft as InboxItem, g as Holding, gn as AccountLifecycle, gt as ActivityDetail, h as HoldingsMethods, hn as fingerprintPaymentIntent, ht as ActivityAnnotationInput, i as ObservationDelivery, in as PaymentStatus, it as ActorRequest, j as OrganizationAccount, jn as PaymentStatus$1, jt as DestinationAddInput, k as OrgTemplate, kn as PAYMENT_DIRECTIONS, kt as DepositInstructions, l as postHogObservability, ln as RecipientResolution, lt as AddressBookLabelInput, m as IdentityRuntimeSendResult, mn as TargetsMethods, mt as ActivityAnnotation, n as ObservationAdapter, nn as PaymentDocumentsMethods, nt as ActorProfileMethods, o as HostObservability, on as PaymentType, ot as ActorRequestsMethods, p as IdentityRuntime, pn as TargetReference, pt as InboxMethods, q as PermissionRevokeInput, qn as IdentityTransition, qt as Payee, r as ObservationContext, rn as PaymentMoney, rt as ActorRelationshipMethods, s as PostHogObservabilityClient, sn as PaymentsMethods, st as AddressBookAddInput, t as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, tn as PaymentDocumentVerification, tt as ActorProfile, u as CapxulClient, un as RecipientResolutionKind, ut as AddressBookMethods, v as SystemHealth, vn as isSettingUpLifecycle, vt as ActivityItem, w as InviteMemberInput, wn as ActorRef, wt as ActivityReference, x as CurrentUserMethods, xn as AuthMethods, xt as ActivityMethods, y as MediaMethods, yn as IdentityMethods, yt as ActivityKind, z as OrganizationPaymentItemInput, zn as IdentityEvent, zt as HandlesMethods } from "./observation-BfCkJY5z.mjs";
1
+ import { B as OrgId, C as Address, N as CountryCode, O as AuthSession, S as AccountId, U as PayrollGroupId, V as PartyId, W as PayrollRunId, Y as RoleKey, a as SignerStatusStore, at as CapxulErrorDetails, c as AccountProviderSource, ct as FailureMode, d as eip1193AccountProvider, et as toAddress, f as localPrivateKeyAccountProvider, g as SmartAccount, h as Session, i as SignerStatus, it as CapxulErrorCode, j as BudgetId, k as AuthUserId, l as AccountRequirement, lt as isCapxulError, m as Profile, n as CapxulSigner, nt as CAPXUL_ERROR_CODES, o as injectedWalletSigner, ot as Errors, p as CapxulResult, r as Eip1193RequestProvider, rt as CapxulError, s as AccountProvider, t as CapxulDigestSigner, tt as toCountryCode, u as Eip1193Provider, x as Account, z as Money } from "./signer-BSEG9xgN.mjs";
2
+ import { $ as PermissionChangeInput, $n as Readiness, $t as MovementActivityEvidence, A as OrgView, An as IdentityMethods, At as ActivityKind, B as PayrollGroupMember, Bn as PAYMENT_DIRECTIONS, Bt as DepositInstructions, C as DetectPendingOrgInvitationsResult, Cn as ResolvedTarget, Ct as InboxItem, D as OrgMethods, Dn as AccountLifecycle, Dt as ActivityDetail, E as MemberView, En as fingerprintPaymentIntent, Et as ActivityAnnotationInput, F as RoleSpendCap, Fn as ActorRef, Ft as ActivityReference, G as PayrollRunItemInput, Gt as DestinationPayload, H as PayrollMethods, Hn as PaymentStatus$1, Ht as DestinationAddInput, I as RoleView, In as CurrentHoldings, It as ActivitySummary, J as OrganizationPaymentBatchInput, Jn as CAPXUL_PAYMENTS_V2_ADDRESS, Jt as DestinationsMethods, K as PayrollRunStatus, Kt as DestinationRail, L as AuthorizeRunInput, Ln as Permission, Lt as ActivitySummaryParams, M as OrganizationAuditLogItem, Mn as AuthMethods, Mt as ActivityMethods, N as ResendInviteTokenInput, Nn as OrgLifecycle, Nt as ActivityPage, O as OrgScopedMethods, On as AccountSetupStep, Ot as ActivityFilter, P as RoleDefinition, Pn as OrgSetupStep, Pt as ActivityRange, Q as PermissionAssignInput, Qn as OrgLane, Qt as MeProfile, R as PayrollGroup, Rn as SubmittedPermissionExecution, Rt as ActivitySummaryTotal, S as CreateOrgInput, Sn as Ref, St as InboxApproveInput, T as MemberStatus, Tn as TargetsMethods, Tt as ActivityAnnotation, U as PayrollOptions, Un as RequestStatus, Ut as DestinationKind, V as PayrollGroupsMethods, Vn as PAYMENT_STATUSES, Vt as Destination, W as PayrollRun, Wt as DestinationListInput, X as OrganizationPaymentItemInput, Xn as IdentityEvent, Xt as HandlesMethods, Y as OrganizationPaymentInput, Yn as Destination$1, Yt as FinancialOpsMethods, Z as OrganizationPaymentsMethods, Zn as IdentityState, Zt as MeMethods, _ as SystemMethods, _n as PaymentType, _t as ActorRequestsMethods, a as SdkFailureObservation, an as PayeesMethods, ar as InvocationControls, at as PermissionReadResult, b as CurrentUserContext, bn as RecipientResolution, bt as AddressBookLabelInput, c as PostHogObservabilityOptions, cn as PaymentDirection, ct as OrgMeMethod, d as CreateCapxulClientInput, dn as PaymentDocumentRender, dt as AccountMethods, en as OfframpMethods, er as StateLabel, et as PermissionCreateInput, f as IdentityProfileDetails, fn as PaymentDocumentVerification, ft as ActorProfile, g as Holding, gn as PaymentTiming, gt as ActorRequestIssueInput, h as HoldingsMethods, hn as PaymentStatus, ht as ActorRequest, i as ObservationDelivery, in as Payee, ir as IdentityTransition, it as PermissionRevokeInput, j as OrganizationAccount, jn as SmartAccountMethods, jt as ActivityListParams, k as OrgTemplate, kn as isSettingUpLifecycle, kt as ActivityItem, l as postHogObservability, ln as PaymentDocumentKind, lt as OrgMeOptions, m as IdentityRuntimeSendResult, mn as PaymentMoney, mt as ActorRelationshipMethods, n as ObservationAdapter, nn as OfframpQuoteInput, nr as isClaimed, nt as PermissionOptions, o as HostObservability, on as Payment, ot as Budget, p as IdentityRuntime, pn as PaymentDocumentsMethods, pt as ActorProfileMethods, q as PayrollRuns, qn as TelemetryPort, qt as DestinationRemoveInput, r as ObservationContext, rn as OfframpStatus, rr as isRestoring, rt as PermissionReplaceInput, s as PostHogObservabilityClient, sn as PaymentActivityEvidence, st as OrgMe, t as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, tn as OfframpQuote, tr as destination, tt as PermissionMethods, u as CapxulClient, un as PaymentDocumentRef, ut as AccountsMethods, v as SystemHealth, vn as PaymentsMethods, vt as AddressBookAddInput, w as InviteMemberInput, wn as TargetReference, wt as InboxMethods, x as CurrentUserMethods, xn as RecipientResolutionKind, xt as AddressBookMethods, y as MediaMethods, yn as PaymentsPayInput, yt as AddressBookEntry, z as PayrollGroupInput, zn as InboxStatus, zt as ActorReference } from "./observation-BQ2VKWH5.mjs";
3
3
  import { Hex } from "viem";
4
4
  import { Context, Effect, Layer } from "effect";
5
5
  import { FunctionReference } from "convex/server";
@@ -203,4 +203,4 @@ declare function captureException(telemetry: TelemetryPort, error: unknown, cont
203
203
  */
204
204
  declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
205
205
  //#endregion
206
- export { type Account, type AccountId, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActivityAnnotation, type ActivityAnnotationInput, type ActivityDetail, type ActivityFilter, type ActivityItem, type ActivityKind, type ActivityListParams, type ActivityMethods, type ActivityPage, type ActivityPhase, type ActivityRange, type ActivityReference, type ActivitySummary, type ActivitySummaryParams, type ActivitySummaryTotal, type ActorProfile, type ActorProfileMethods, type ActorRef, type ActorReference, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AuthMethods, type AuthSession, type AuthUserId, type Budget, type BudgetId, CAPXUL_ERROR_CODES, CAPXUL_PAYMENTS_V2_ADDRESS, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, CapxulError, type CapxulErrorCode, type CapxulErrorDetails, type CapxulResult, type CapxulSigner, type CountryCode, type CreateCapxulClientInput, type CreateOrgInput, type CurrentHoldings, type CurrentUserContext, type CurrentUserMethods, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRail, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, Errors, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type Holding, type HoldingsMethods, type HostObservability, type Destination$1 as IdentityDestination, type IdentityEvent, type IdentityMethods, type IdentityProfileDetails, type IdentityRuntime, type IdentityRuntimeSendResult, type IdentityState, type IdentityTransition, type InboxApproveInput, type InboxItem, type InboxMethods, type InviteMemberInput, type InvocationControls, type MeMethods, type MeProfile, type MediaMethods, type MemberStatus, type MemberView, type Money, type MoneyParseError, type MoneyParseErrorReason, type MovementActivityEvidence, type ObservationAdapter, type ObservationContext, type ObservationDelivery, type OfframpMethods, type OfframpQuote, type OfframpQuoteInput, type OfframpStatus, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgId, type OrgLane, type OrgLifecycle, type OrgMe, type OrgMeMethod, type OrgMeOptions, type OrgMethods, type OrgScopedMethods, type OrgSetupStep, type OrgTemplate, type OrgView, type OrganizationAccount, type OrganizationAuditLogItem, type OrganizationPaymentBatchInput, type OrganizationPaymentInput, type OrganizationPaymentItemInput, type OrganizationPaymentsMethods, PAYMENT_DIRECTIONS, PAYMENT_STATUSES, type PartyId, type Payee, type PayeesMethods, type Payment, type PaymentActivityEvidence, type PaymentDirection, type PaymentDocumentKind, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentMoney, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type Permission, type PermissionAssignInput, type PermissionChangeInput, type PermissionCreateInput, type PermissionMethods, type PermissionOptions, type PermissionReadResult, type PermissionReplaceInput, type PermissionRevokeInput, type PostHogObservabilityClient, type PostHogObservabilityOptions, type Profile, type Readiness, type RecipientResolution, type RecipientResolutionKind, type Ref, type ResendInviteTokenInput, type ResolvedTarget, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type SdkFailureObservation, type Session, type SignerStatus, type SignerStatusStore, type SmartAccount, type SmartAccountMethods, type StateLabel, type SubmittedPermissionExecution, type SystemHealth, type SystemMethods, type TargetReference, type TargetsMethods, type TelemetryPort, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, fingerprintPaymentIntent, formatMoney, inboxPhase, injectedWalletSigner, isCapxulError, isClaimed, isMoneyParseError, isRestoring, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort, parseMoney, paymentPhase, postHogObservability, requestPhase, destination as resolveIdentityDestination, toCountryCode, toAddress as toEvmAddress };
206
+ export { type Account, type AccountId, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActivityAnnotation, type ActivityAnnotationInput, type ActivityDetail, type ActivityFilter, type ActivityItem, type ActivityKind, type ActivityListParams, type ActivityMethods, type ActivityPage, type ActivityPhase, type ActivityRange, type ActivityReference, type ActivitySummary, type ActivitySummaryParams, type ActivitySummaryTotal, type ActorProfile, type ActorProfileMethods, type ActorRef, type ActorReference, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AuthMethods, type AuthSession, type AuthUserId, type AuthorizeRunInput, type Budget, type BudgetId, CAPXUL_ERROR_CODES, CAPXUL_PAYMENTS_V2_ADDRESS, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, CapxulError, type CapxulErrorCode, type CapxulErrorDetails, type CapxulResult, type CapxulSigner, type CountryCode, type CreateCapxulClientInput, type CreateOrgInput, type CurrentHoldings, type CurrentUserContext, type CurrentUserMethods, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRail, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, Errors, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type Holding, type HoldingsMethods, type HostObservability, type Destination$1 as IdentityDestination, type IdentityEvent, type IdentityMethods, type IdentityProfileDetails, type IdentityRuntime, type IdentityRuntimeSendResult, type IdentityState, type IdentityTransition, type InboxApproveInput, type InboxItem, type InboxMethods, type InviteMemberInput, type InvocationControls, type MeMethods, type MeProfile, type MediaMethods, type MemberStatus, type MemberView, type Money, type MoneyParseError, type MoneyParseErrorReason, type MovementActivityEvidence, type ObservationAdapter, type ObservationContext, type ObservationDelivery, type OfframpMethods, type OfframpQuote, type OfframpQuoteInput, type OfframpStatus, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgId, type OrgLane, type OrgLifecycle, type OrgMe, type OrgMeMethod, type OrgMeOptions, type OrgMethods, type OrgScopedMethods, type OrgSetupStep, type OrgTemplate, type OrgView, type OrganizationAccount, type OrganizationAuditLogItem, type OrganizationPaymentBatchInput, type OrganizationPaymentInput, type OrganizationPaymentItemInput, type OrganizationPaymentsMethods, PAYMENT_DIRECTIONS, PAYMENT_STATUSES, type PartyId, type Payee, type PayeesMethods, type Payment, type PaymentActivityEvidence, type PaymentDirection, type PaymentDocumentKind, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentMoney, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PayrollGroup, type PayrollGroupId, type PayrollGroupInput, type PayrollGroupMember, type PayrollGroupsMethods, type PayrollMethods, type PayrollOptions, type PayrollRun, type PayrollRunId, type PayrollRunItemInput, type PayrollRunStatus, type PayrollRuns, type Permission, type PermissionAssignInput, type PermissionChangeInput, type PermissionCreateInput, type PermissionMethods, type PermissionOptions, type PermissionReadResult, type PermissionReplaceInput, type PermissionRevokeInput, type PostHogObservabilityClient, type PostHogObservabilityOptions, type Profile, type Readiness, type RecipientResolution, type RecipientResolutionKind, type Ref, type ResendInviteTokenInput, type ResolvedTarget, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type SdkFailureObservation, type Session, type SignerStatus, type SignerStatusStore, type SmartAccount, type SmartAccountMethods, type StateLabel, type SubmittedPermissionExecution, type SystemHealth, type SystemMethods, type TargetReference, type TargetsMethods, type TelemetryPort, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, fingerprintPaymentIntent, formatMoney, inboxPhase, injectedWalletSigner, isCapxulError, isClaimed, isMoneyParseError, isRestoring, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort, parseMoney, paymentPhase, postHogObservability, requestPhase, destination as resolveIdentityDestination, toCountryCode, toAddress as toEvmAddress };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { $ as isClaimed, A as fingerprintPaymentIntent, B as OBSERVATION_CONTEXT_HEADER, C as ClockPortTag, D as AuthClientError, E as authClientPortFromPromiseAdapter, F as copyInvocationObservation, G as CAPXUL_FUNCTIONS, H as sanitizeObservationContext, I as readInvocationObservation, J as CAPXUL_PAYMENTS_V2_ADDRESS, K as BootstrapEnvelope, L as causeChain, M as fromWei, N as isSettingUpLifecycle, O as AuthClientPortTag, P as formatTraceparent, Q as destination, R as injectedWalletSigner, S as ClockError, T as bootstrapErrorFromCapxul, U as PAYMENT_DIRECTIONS, V as encodeObservationContextHeader, W as PAYMENT_STATUSES, X as BASE_SEPOLIA_CHAIN_ID, Y as normalizeBindingEmail, _ as wireChainId, a as observeFailedResult, b as ConvexCallPortTag, c as captureExceptionSync, d as TelemetryPortTag, et as isRestoring, g as accountReadErrorFromCapxul, h as AccountReadPortTag, i as observationContextProps, j as toWei, k as version, l as detectAuthCacheAdapter, m as smartAccountErrorFromCapxul, n as postHogProductTelemetry, o as postHogFailureObservation, p as SmartAccountPortTag, q as EngineeringTelemetryBootstrapPolicy, r as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, s as captureException, t as assembleCapxulClient, u as PostHogTelemetryLayer, v as IdentityPortTag, w as BootstrapPortTag, x as convexCallErrorFromCapxul, y as identityErrorFromCapxul, z as signerFailure } from "./create-capxul-client-BrE6tLg6.mjs";
2
- import { C as toDurationMs, D as toJwtToken, E as toEpochSeconds, F as CAPXUL_ERROR_CODES, I as CapxulError, M as toRoleKey, N as toSessionToken, O as toKycTier, P as decodeConvexError, R as Errors, S as toCurrencyCode, T as toEpochMs, b as toChainId, g as toAllowedOrigin, h as toAddress, j as toPublishableKey, k as toOrgId, m as toAccountId, o as AuthCachePortTag, p as currencySymbolFor, v as toAuthUserId, w as toEmail, x as toCountryCode, z as isCapxulError } from "./InMemoryAuthCacheAdapter-qMpBOGb3.mjs";
1
+ import { A as AuthClientPortTag, B as injectedWalletSigner, C as convexCallErrorFromCapxul, D as bootstrapErrorFromCapxul, E as BootstrapPortTag, F as isSettingUpLifecycle, G as PAYMENT_DIRECTIONS, H as OBSERVATION_CONTEXT_HEADER, I as formatTraceparent, J as BootstrapEnvelope, K as PAYMENT_STATUSES, L as copyInvocationObservation, M as fingerprintPaymentIntent, N as toWei, O as authClientPortFromPromiseAdapter, P as fromWei, Q as BASE_SEPOLIA_CHAIN_ID, R as readInvocationObservation, S as ConvexCallPortTag, T as ClockPortTag, U as encodeObservationContextHeader, V as signerFailure, W as sanitizeObservationContext, X as CAPXUL_PAYMENTS_V2_ADDRESS, Y as EngineeringTelemetryBootstrapPolicy, Z as normalizeBindingEmail, _ as AccountReadPortTag, a as failureEvidenceProps, b as IdentityPortTag, c as postHogFailureObservation, d as detectAuthCacheAdapter, et as destination, f as PostHogTelemetryLayer, g as smartAccountErrorFromCapxul, h as SmartAccountPortTag, i as failureDetail, j as version, k as AuthClientError, l as captureException, n as postHogProductTelemetry, nt as isRestoring, o as observationContextProps, p as TelemetryPortTag, q as CAPXUL_FUNCTIONS, r as CAPXUL_SDK_EXPECTED_OUTCOME_EVENT, s as observeFailedResult, t as assembleCapxulClient, tt as isClaimed, u as captureExceptionSync, v as accountReadErrorFromCapxul, w as ClockError, x as identityErrorFromCapxul, y as wireChainId, z as causeChain } from "./create-capxul-client-B050H6SY.mjs";
2
+ import { B as Errors, C as toDurationMs, D as toJwtToken, E as toEpochSeconds, F as toSessionToken, I as decodeConvexError, L as CAPXUL_ERROR_CODES, N as toPublishableKey, O as toKycTier, P as toRoleKey, R as CapxulError, S as toCurrencyCode, T as toEpochMs, V as isCapxulError, b as toChainId, g as toAllowedOrigin, h as toAddress, k as toOrgId, m as toAccountId, o as AuthCachePortTag, p as currencySymbolFor, v as toAuthUserId, w as toEmail, x as toCountryCode } from "./InMemoryAuthCacheAdapter-uOcqpqu8.mjs";
3
3
  import { keccak256, recoverAddress, stringToHex } from "viem";
4
- import { Cause, Context, Data, Effect, Exit, Layer, Result, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
4
+ import { Cause, Context, Data, Duration, Effect, Exit, Layer, Result, Schedule, SchemaIssue, SchemaParser, Scope, Tracer } from "effect";
5
5
  import { getFunctionName, makeFunctionReference } from "convex/server";
6
6
  import { privateKeyToAccount } from "viem/accounts";
7
7
  import { FetchHttpClient, Headers, HttpClient } from "effect/unstable/http";
@@ -1266,6 +1266,33 @@ function BetterAuthNodeLayer(deps) {
1266
1266
  }
1267
1267
  //#endregion
1268
1268
  //#region src/adapters/bootstrap/HttpBootstrapAdapter.ts
1269
+ const DEFAULT_RETRY = {
1270
+ attempts: 2,
1271
+ baseDelayMs: 400
1272
+ };
1273
+ /** Request-side statuses a proxy or backend returns while momentarily unable to serve. */
1274
+ const TRANSIENT_HTTP_STATUSES = new Set([
1275
+ 408,
1276
+ 425,
1277
+ 429
1278
+ ]);
1279
+ /** Every 5xx is a server-side condition worth one more try; the client sent nothing wrong. */
1280
+ function isTransientHttpStatus(status) {
1281
+ return status >= 500 || TRANSIENT_HTTP_STATUSES.has(status);
1282
+ }
1283
+ /**
1284
+ * A transient HTTP status is worth one more try. The bootstrap call crosses
1285
+ * the host's own proxy before it reaches Convex, and every observed failure
1286
+ * of that hop cleared on a retry seconds later. A network rejection (offline,
1287
+ * DNS, CORS) is not retried: it does not clear in a second, and the caller
1288
+ * surfaces it as `NETWORK_ERROR` at once. Auth and input rejections are
1289
+ * deterministic and never retried.
1290
+ */
1291
+ function isTransientBootstrapFailure(error) {
1292
+ if (error.kind !== "provider") return false;
1293
+ const status = error.details?.httpStatus;
1294
+ return typeof status === "number" && isTransientHttpStatus(status);
1295
+ }
1269
1296
  async function safeText(res) {
1270
1297
  try {
1271
1298
  return await res.text();
@@ -1277,12 +1304,21 @@ var HttpBootstrapAdapter = class {
1277
1304
  bootstrapBaseUrl;
1278
1305
  fetchImpl;
1279
1306
  observation;
1307
+ retry;
1280
1308
  constructor(deps) {
1281
1309
  this.bootstrapBaseUrl = deps.bootstrapBaseUrl.replace(/\/$/, "");
1282
1310
  this.observation = deps.observation;
1311
+ this.retry = deps.retry ?? DEFAULT_RETRY;
1283
1312
  this.fetchImpl = deps.fetch ?? ((input, init) => globalThis.fetch(input, init));
1284
1313
  }
1285
1314
  resolve(input) {
1315
+ return this.attempt(input).pipe(Effect.retry({
1316
+ times: this.retry.attempts,
1317
+ while: isTransientBootstrapFailure,
1318
+ schedule: Schedule.exponential(Duration.millis(this.retry.baseDelayMs))
1319
+ }));
1320
+ }
1321
+ attempt(input) {
1286
1322
  return Effect.tryPromise({
1287
1323
  try: () => {
1288
1324
  const headers = {
@@ -1335,7 +1371,17 @@ var HttpBootstrapAdapter = class {
1335
1371
  return Effect.promise(() => safeText(res)).pipe(Effect.flatMap((body) => {
1336
1372
  if (res.status === 401 || body.startsWith("NOT_AUTHENTICATED")) return Effect.fail(bootstrapErrorFromCapxul("notAuthenticated", Errors.notAuthenticated()));
1337
1373
  if (res.status === 400 || body.startsWith("INVALID_INPUT")) return Effect.fail(bootstrapErrorFromCapxul("invalidInput", Errors.invalidInput("publishableKey", "rejected by bootstrap")));
1338
- return Effect.fail(bootstrapErrorFromCapxul("provider", Errors.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}`))));
1374
+ const responseBody = body.slice(0, 300);
1375
+ const edgeError = res.headers?.get?.("x-vercel-error") ?? void 0;
1376
+ const edgeRequestId = res.headers?.get?.("x-vercel-id") ?? void 0;
1377
+ return Effect.fail(bootstrapErrorFromCapxul("provider", Errors.providerError("convex", "bootstrap", /* @__PURE__ */ new Error(`HTTP ${res.status}${edgeError === void 0 ? "" : ` ${edgeError}`}`), {
1378
+ httpStatus: res.status,
1379
+ details: {
1380
+ ...responseBody.length === 0 ? {} : { responseBody },
1381
+ ...edgeError === void 0 ? {} : { edgeError },
1382
+ ...edgeRequestId === void 0 ? {} : { edgeRequestId }
1383
+ }
1384
+ })));
1339
1385
  }));
1340
1386
  }
1341
1387
  };
@@ -2794,7 +2840,9 @@ async function createProductionAdapters(input) {
2794
2840
  name: "bootstrap_failed",
2795
2841
  props: {
2796
2842
  ...bootstrapTelemetryEnvelope(input, resolvedInput.value),
2797
- reason: bootstrapResult.error.code
2843
+ reason: bootstrapResult.error.code,
2844
+ ...failureDetail(bootstrapResult.error),
2845
+ ...failureEvidenceProps(bootstrapResult.error)
2798
2846
  }
2799
2847
  });
2800
2848
  await closeScope().catch(() => void 0);
@@ -1,4 +1,4 @@
1
- import { O as AuthSession, _ as AuthCacheError, b as CachedJwt, n as CapxulSigner, v as AuthCachePort, y as AuthCachePortTag } from "../signer-BGTaqZqg.mjs";
1
+ import { O as AuthSession, _ as AuthCacheError, b as CachedJwt, n as CapxulSigner, v as AuthCachePort, y as AuthCachePortTag } from "../signer-BSEG9xgN.mjs";
2
2
  import { Hex } from "viem";
3
3
  import { Effect, FileSystem, Layer, Path } from "effect";
4
4
 
@@ -1,4 +1,4 @@
1
- import { a as AuthCacheError, h as toAddress, i as parseCachedJwt, n as BrowserAuthCacheAdapter, o as AuthCachePortTag, r as parseAuthSession, t as InMemoryAuthCacheAdapter } from "../InMemoryAuthCacheAdapter-qMpBOGb3.mjs";
1
+ import { a as AuthCacheError, h as toAddress, i as parseCachedJwt, n as BrowserAuthCacheAdapter, o as AuthCachePortTag, r as parseAuthSession, t as InMemoryAuthCacheAdapter } from "../InMemoryAuthCacheAdapter-uOcqpqu8.mjs";
2
2
  import { Effect, FileSystem, Layer, Path } from "effect";
3
3
  import { privateKeyToAccount } from "viem/accounts";
4
4
  import * as os from "node:os";
@@ -1,4 +1,4 @@
1
- import { A as BlockNumber, B as OrgId, C as Address$1, D as AppId, E as AnonymousDistinctId, F as DocumentHash, G as Profile, H as PaymentCommandId, I as DurationMs, J as SessionToken, K as PublishableKey, L as Email, M as ChainId, N as CountryCode, O as AuthSession, P as CurrencyCode, R as EpochMs, T as AllowedOrigin, U as PermissionAssignmentId, V as PartyId, W as PermissionId, X as TxHash, Y as SmartAccount, Z as WeiAmount, a as SignerStatusStore, at as Failure, b as CachedJwt, c as AccountProviderSource, g as SmartAccount$1, h as Session$1, j as BudgetId, k as AuthUserId, l as AccountRequirement, m as Profile$1, n as CapxulSigner, nt as CapxulErrorCode, ot as FailureMode, p as CapxulResult, q as RoleKey, rt as CapxulErrorDetails, tt as CapxulError, v as AuthCachePort, w as AllowanceKey, x as Account$1, z as Money } from "./signer-BGTaqZqg.mjs";
1
+ import { $ as WeiAmount, A as BlockNumber, B as OrgId, C as Address$1, D as AppId, E as AnonymousDistinctId, F as DocumentHash, G as PermissionAssignmentId, H as PaymentCommandId, I as DurationMs, J as PublishableKey, K as PermissionId, L as Email, M as ChainId, N as CountryCode, O as AuthSession, P as CurrencyCode, Q as TxHash, R as EpochMs, T as AllowedOrigin, U as PayrollGroupId, V as PartyId, W as PayrollRunId, X as SessionToken, Y as RoleKey, Z as SmartAccount, a as SignerStatusStore, at as CapxulErrorDetails, b as CachedJwt, c as AccountProviderSource, ct as FailureMode, g as SmartAccount$1, h as Session$1, it as CapxulErrorCode, j as BudgetId, k as AuthUserId, l as AccountRequirement, m as Profile$1, n as CapxulSigner, p as CapxulResult, q as Profile, rt as CapxulError, st as Failure, v as AuthCachePort, w as AllowanceKey, x as Account$1, z as Money } from "./signer-BSEG9xgN.mjs";
2
2
  import { Address, Hex } from "viem";
3
3
  import { Context, Effect, Layer, Schema, Scope, Tracer } from "effect";
4
4
  import { FunctionReference } from "convex/server";
@@ -38,7 +38,8 @@ type IdentityTransition = (RecordBase & {
38
38
  readonly outcome: "failed" | "cancelled";
39
39
  readonly state: string;
40
40
  readonly error_code: CapxulErrorCode;
41
- readonly refusal_code?: never;
41
+ readonly refusal_code?: never; /** The typed failure behind `error_code`, with its `CapxulError` when the port gave one. */
42
+ readonly failure?: Failure;
42
43
  });
43
44
  declare class ActorFailure<Reason extends CapxulErrorCode> extends Error {
44
45
  readonly reason: Reason;
@@ -47,7 +48,7 @@ declare class ActorFailure<Reason extends CapxulErrorCode> extends Error {
47
48
  readonly event: string;
48
49
  readonly details?: Readonly<Record<string, unknown>> | undefined;
49
50
  readonly _tag = "ActorFailure";
50
- constructor(reason: Reason, machine: string, state: string, event: string, details?: Readonly<Record<string, unknown>> | undefined);
51
+ constructor(reason: Reason, machine: string, state: string, event: string, details?: Readonly<Record<string, unknown>> | undefined, cause?: unknown);
51
52
  }
52
53
  interface Actor<S, Pub, Reason extends CapxulErrorCode> {
53
54
  readonly ask: (event: Pub, controls?: InvocationControls) => Effect.Effect<S, ActorFailure<Reason | CapxulErrorCode>>;
@@ -614,6 +615,8 @@ declare const SubmittedPermissionExecutionSchema: Schema.Struct<{
614
615
  }>>]>;
615
616
  }>;
616
617
  type SubmittedPermissionExecution = Schema.Schema.Type<typeof SubmittedPermissionExecutionSchema>;
618
+ declare const PayrollRunStatusSchema: Schema.Literals<readonly ["draft", "authorized", "settled"]>;
619
+ type PayrollRunStatus$1 = Schema.Schema.Type<typeof PayrollRunStatusSchema>;
617
620
  //#endregion
618
621
  //#region ../wire/src/observation-context.d.ts
619
622
  /**
@@ -2065,6 +2068,114 @@ interface OrganizationPaymentsMethods {
2065
2068
  }): Promise<CapxulResult<readonly Payment[]>>;
2066
2069
  }
2067
2070
  //#endregion
2071
+ //#region src/surface/payroll.d.ts
2072
+ /** ADR-0022 R9: where the run stands on the shipped command lifecycle. */
2073
+ type PayrollRunStatus = PayrollRunStatus$1;
2074
+ /** One authorized payroll run. `total` is the sum of its items' nets. */
2075
+ interface PayrollRun {
2076
+ readonly id: PayrollRunId;
2077
+ readonly status: PayrollRunStatus;
2078
+ /** Epoch milliseconds. An instant run has `periodStart === periodEnd`. */
2079
+ readonly periodStart: number;
2080
+ readonly periodEnd: number;
2081
+ readonly total: Money;
2082
+ readonly recipientCount: number;
2083
+ }
2084
+ /**
2085
+ * An organization's runs, newest first, with the month total beside them.
2086
+ *
2087
+ * The aggregate travels WITH the list because the backend computes it over
2088
+ * every settled run in the calendar month while the list is one page. A
2089
+ * consumer that summed `runs` would under-report an employer past the page.
2090
+ */
2091
+ interface PayrollRuns {
2092
+ readonly runs: readonly PayrollRun[];
2093
+ /** Σ net of the runs that SETTLED this calendar month — the "Paid This Month" fact. */
2094
+ readonly settledThisMonth: Money;
2095
+ }
2096
+ /**
2097
+ * One saved recipient on a group. `amount` is the employer's TYPED text, not
2098
+ * minor units: a group is a draft the run composer prefills, and the run
2099
+ * engine is the one place that parses an amount into money.
2100
+ */
2101
+ interface PayrollGroupMember {
2102
+ /** The recipient's `PartyId` — the stable id (ADR-0022 R1), never an email. */
2103
+ readonly partyId: string;
2104
+ readonly amount: string;
2105
+ readonly currency: CurrencyCode;
2106
+ }
2107
+ /** A saved roster the employer pays again. Server-held, so every member sees it. */
2108
+ interface PayrollGroup {
2109
+ readonly id: PayrollGroupId;
2110
+ readonly name: string;
2111
+ /** A stored display preference; the consumer narrows it to its own union. */
2112
+ readonly tone: string;
2113
+ readonly members: readonly PayrollGroupMember[];
2114
+ }
2115
+ /** `id` absent creates a group; `id` present replaces that group in place. */
2116
+ interface PayrollGroupInput {
2117
+ readonly id?: PayrollGroupId;
2118
+ readonly name: string;
2119
+ readonly tone: string;
2120
+ readonly members: readonly PayrollGroupMember[];
2121
+ }
2122
+ /**
2123
+ * One person on one run. `net` is what they are paid; `gross` plus every
2124
+ * adjustment must equal it (ADR-0022 R8) and the backend refuses a run where
2125
+ * it does not. Both are minor-unit strings; an adjustment is signed.
2126
+ */
2127
+ interface PayrollRunItemInput {
2128
+ /**
2129
+ * The recipient. An email `Ref` or a party `Ref` in v1 — the backend refuses
2130
+ * any other kind, because the recipient is what the party is DERIVED from.
2131
+ */
2132
+ readonly to: Ref$1;
2133
+ /**
2134
+ * The caller's ASSERTION of the party `to` resolves to, never the authority
2135
+ * for it. The backend resolves `to` — an email through the invite path's
2136
+ * person-party ensure, a party `Ref` through the same recipient resolution
2137
+ * the batch runs — and refuses the run when this id is not that party, so
2138
+ * the money, the `employed` edge and the payslip's employee can never name
2139
+ * three different people.
2140
+ */
2141
+ readonly partyId: string;
2142
+ readonly gross: string;
2143
+ readonly net: string;
2144
+ readonly adjustments: readonly {
2145
+ readonly label: string;
2146
+ readonly amount: string;
2147
+ }[];
2148
+ }
2149
+ interface AuthorizeRunInput {
2150
+ /** The Budget the run spends from. The caller selects it; nothing is picked for them. */
2151
+ readonly permissionId: string;
2152
+ /** Epoch milliseconds. An instant run passes `start === end` — the payslip renders the date. */
2153
+ readonly period: {
2154
+ readonly start: number;
2155
+ readonly end: number;
2156
+ };
2157
+ readonly items: readonly PayrollRunItemInput[];
2158
+ /**
2159
+ * Supply one to reuse a key minted elsewhere. Left absent, the shipped
2160
+ * fingerprint lifecycle derives it from this intent, so a retry of the same
2161
+ * run replays the SAME command instead of paying twice.
2162
+ */
2163
+ readonly requestKey?: string;
2164
+ }
2165
+ type PayrollOptions = {
2166
+ readonly signal?: AbortSignal;
2167
+ };
2168
+ interface PayrollGroupsMethods {
2169
+ list(options?: PayrollOptions): Promise<CapxulResult<readonly PayrollGroup[]>>;
2170
+ save(input: PayrollGroupInput, options?: PayrollOptions): Promise<CapxulResult<PayrollGroup>>;
2171
+ remove(id: PayrollGroupId, options?: PayrollOptions): Promise<CapxulResult<void>>;
2172
+ }
2173
+ interface PayrollMethods {
2174
+ runs(options?: PayrollOptions): Promise<CapxulResult<PayrollRuns>>;
2175
+ authorizeRun(input: AuthorizeRunInput, options?: PayrollOptions): Promise<CapxulResult<PayrollRun>>;
2176
+ readonly groups: PayrollGroupsMethods;
2177
+ }
2178
+ //#endregion
2068
2179
  //#region src/surface/org.d.ts
2069
2180
  /** The membership state for one Organization member. */
2070
2181
  type MemberStatus = "pending" | "pending_safe" | "pending_grant" | "active" | "revoked" | "expired";
@@ -2214,6 +2325,13 @@ interface OrgScopedMethods extends ActorRelationshipMethods {
2214
2325
  */
2215
2326
  readonly permissions: PermissionMethods;
2216
2327
  readonly payments: OrganizationPaymentsMethods;
2328
+ /**
2329
+ * Pay the team: the runs this Organization has authorized, the verb that
2330
+ * authorizes one, and the saved groups a run is composed from (#1452).
2331
+ * `authorizeRun` is a payment command like any other — same Budget gate,
2332
+ * same signature, same request-key idempotency.
2333
+ */
2334
+ readonly payroll: PayrollMethods;
2217
2335
  auditLog(options?: {
2218
2336
  readonly signal?: AbortSignal;
2219
2337
  }): Promise<CapxulResult<readonly OrganizationAuditLogItem[]>>;
@@ -2584,9 +2702,11 @@ declare function postHogObservability(client: PostHogObservabilityClient | null
2584
2702
  /** Host-owned correlation fields that are safe to attach to an SDK failure. */
2585
2703
  interface ObservationContext extends Omit<WireObservationContext, "applicationId"> {}
2586
2704
  /**
2587
- * The small, SDK-owned failure envelope delivered to observation adapters.
2588
- * Method arguments, response bodies, wallet payloads, and arbitrary error
2589
- * details are deliberately absent.
2705
+ * The SDK-owned failure envelope delivered to observation adapters. It carries
2706
+ * the real error message, the `CapxulError.details` object, the cause chain,
2707
+ * and the stack. Secret material (keys, tokens, bearer headers) is masked;
2708
+ * nothing else is withheld. Ruling 2026-09-01: an operator reading an issue
2709
+ * needs the actual failure, not a placeholder.
2590
2710
  */
2591
2711
  interface SdkFailureObservation {
2592
2712
  readonly exception: Error;
@@ -2595,6 +2715,30 @@ interface SdkFailureObservation {
2595
2715
  readonly errorKind: string;
2596
2716
  /** Invocation snapshot; failure correlation wins over later host state. */
2597
2717
  readonly context?: ObservationContext;
2718
+ /** Enumerated discriminators from `CapxulError.details`, in property shape. */
2719
+ readonly detail?: SdkFailureDetail;
2720
+ /** The error's own message, secrets masked. */
2721
+ readonly message?: string;
2722
+ /** The full `CapxulError.details` object, secrets masked, JSON-safe. */
2723
+ readonly details?: Readonly<Record<string, unknown>>;
2724
+ /** Messages down the `cause` chain, outermost first, secrets masked. */
2725
+ readonly causeChain?: readonly string[];
2726
+ /** The original stack when the error had one, secrets masked. */
2727
+ readonly stack?: string;
2728
+ }
2729
+ /**
2730
+ * The PII-safe subset of `CapxulError.details`, already in PostHog property
2731
+ * shape. `provider` + `provider_operation` name the failing dependency
2732
+ * (`convex bootstrap`, `openfort configure`), `failure_mode` / `reason` are
2733
+ * enumerated codes, `http_status` is the upstream status. Anything else on
2734
+ * `details` (ids, field names, free text) is dropped at the boundary.
2735
+ */
2736
+ interface SdkFailureDetail {
2737
+ readonly provider?: string;
2738
+ readonly provider_operation?: string;
2739
+ readonly failure_mode?: string;
2740
+ readonly reason?: string;
2741
+ readonly http_status?: number;
2598
2742
  }
2599
2743
  type ObservationDelivery = void | PromiseLike<void>;
2600
2744
  /**
@@ -2615,4 +2759,4 @@ interface ObservationAdapter {
2615
2759
  /** Stable PostHog event used for typed failures that are expected product outcomes. */
2616
2760
  declare const CAPXUL_SDK_EXPECTED_OUTCOME_EVENT = "capxul_sdk_expected_outcome";
2617
2761
  //#endregion
2618
- export { AccountsMethods as $, PaymentDocumentRef as $t, OrgView as A, PAYMENT_STATUSES as An, Destination as At, OrganizationPaymentsMethods as B, IdentityState as Bn, MeMethods as Bt, DetectPendingOrgInvitationsResult as C, OrgSetupStep as Cn, ActivityRange as Ct, OrgMethods as D, SubmittedPermissionExecution as Dn, ActivitySummaryTotal as Dt, MemberView as E, Permission as En, ActivitySummaryParams as Et, RoleSpendCap as F, TelemetryIdentifyInput as Fn, DestinationRail as Ft, PermissionOptions as G, isClaimed as Gn, OfframpQuoteInput as Gt, PermissionChangeInput as H, Readiness as Hn, MovementActivityEvidence as Ht, RoleView as I, TelemetryPort as In, DestinationRemoveInput as It, PermissionReadResult as J, InvocationControls as Jn, PayeesMethods as Jt, PermissionReplaceInput as K, isRestoring as Kn, OfframpStatus as Kt, OrganizationPaymentBatchInput as L, CAPXUL_PAYMENTS_V2_ADDRESS as Ln, DestinationsMethods as Lt, OrganizationAuditLogItem as M, RequestStatus as Mn, DestinationKind as Mt, ResendInviteTokenInput as N, TelemetryEvent as Nn, DestinationListInput as Nt, OrgScopedMethods as O, InboxStatus as On, ActorReference as Ot, RoleDefinition as P, TelemetryGroupInput as Pn, DestinationPayload as Pt, OrgMeOptions as Q, PaymentDocumentKind as Qt, OrganizationPaymentInput as R, Destination$1 as Rn, FinancialOpsMethods as Rt, CreateOrgInput as S, OrgLifecycle as Sn, ActivityPage as St, MemberStatus as T, CurrentHoldings as Tn, ActivitySummary as Tt, PermissionCreateInput as U, StateLabel as Un, OfframpMethods as Ut, PermissionAssignInput as V, OrgLane as Vn, MeProfile as Vt, PermissionMethods as W, destination as Wn, OfframpQuote as Wt, OrgMe as X, PaymentActivityEvidence as Xt, Budget as Y, Payment as Yt, OrgMeMethod as Z, PaymentDirection as Zt, SystemMethods as _, AccountSetupStep as _n, ActivityFilter as _t, SdkFailureObservation as a, PaymentTiming as an, ActorRequestIssueInput as at, CurrentUserContext as b, SmartAccountMethods as bn, ActivityListParams as bt, PostHogObservabilityOptions as c, PaymentsPayInput as cn, AddressBookEntry as ct, CreateCapxulClientInput as d, Ref$1 as dn, InboxApproveInput as dt, PaymentDocumentRender as en, AccountMethods as et, IdentityProfileDetails as f, ResolvedTarget as fn, InboxItem as ft, Holding as g, AccountLifecycle as gn, ActivityDetail as gt, HoldingsMethods as h, fingerprintPaymentIntent as hn, ActivityAnnotationInput as ht, ObservationDelivery as i, PaymentStatus as in, ActorRequest as it, OrganizationAccount as j, PaymentStatus$1 as jn, DestinationAddInput as jt, OrgTemplate as k, PAYMENT_DIRECTIONS as kn, DepositInstructions as kt, postHogObservability as l, RecipientResolution as ln, AddressBookLabelInput as lt, IdentityRuntimeSendResult as m, TargetsMethods as mn, ActivityAnnotation as mt, ObservationAdapter as n, PaymentDocumentsMethods as nn, ActorProfileMethods as nt, HostObservability as o, PaymentType as on, ActorRequestsMethods as ot, IdentityRuntime as p, TargetReference as pn, InboxMethods as pt, PermissionRevokeInput as q, IdentityTransition as qn, Payee as qt, ObservationContext as r, PaymentMoney as rn, ActorRelationshipMethods as rt, PostHogObservabilityClient as s, PaymentsMethods as sn, AddressBookAddInput as st, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as t, PaymentDocumentVerification as tn, ActorProfile as tt, CapxulClient as u, RecipientResolutionKind as un, AddressBookMethods as ut, SystemHealth as v, isSettingUpLifecycle as vn, ActivityItem as vt, InviteMemberInput as w, ActorRef as wn, ActivityReference as wt, CurrentUserMethods as x, AuthMethods as xn, ActivityMethods as xt, MediaMethods as y, IdentityMethods as yn, ActivityKind as yt, OrganizationPaymentItemInput as z, IdentityEvent as zn, HandlesMethods as zt };
2762
+ export { PermissionChangeInput as $, Readiness as $n, MovementActivityEvidence as $t, OrgView as A, IdentityMethods as An, ActivityKind as At, PayrollGroupMember as B, PAYMENT_DIRECTIONS as Bn, DepositInstructions as Bt, DetectPendingOrgInvitationsResult as C, ResolvedTarget as Cn, InboxItem as Ct, OrgMethods as D, AccountLifecycle as Dn, ActivityDetail as Dt, MemberView as E, fingerprintPaymentIntent as En, ActivityAnnotationInput as Et, RoleSpendCap as F, ActorRef as Fn, ActivityReference as Ft, PayrollRunItemInput as G, TelemetryGroupInput as Gn, DestinationPayload as Gt, PayrollMethods as H, PaymentStatus$1 as Hn, DestinationAddInput as Ht, RoleView as I, CurrentHoldings as In, ActivitySummary as It, OrganizationPaymentBatchInput as J, CAPXUL_PAYMENTS_V2_ADDRESS as Jn, DestinationsMethods as Jt, PayrollRunStatus as K, TelemetryIdentifyInput as Kn, DestinationRail as Kt, AuthorizeRunInput as L, Permission as Ln, ActivitySummaryParams as Lt, OrganizationAuditLogItem as M, AuthMethods as Mn, ActivityMethods as Mt, ResendInviteTokenInput as N, OrgLifecycle as Nn, ActivityPage as Nt, OrgScopedMethods as O, AccountSetupStep as On, ActivityFilter as Ot, RoleDefinition as P, OrgSetupStep as Pn, ActivityRange as Pt, PermissionAssignInput as Q, OrgLane as Qn, MeProfile as Qt, PayrollGroup as R, SubmittedPermissionExecution as Rn, ActivitySummaryTotal as Rt, CreateOrgInput as S, Ref$1 as Sn, InboxApproveInput as St, MemberStatus as T, TargetsMethods as Tn, ActivityAnnotation as Tt, PayrollOptions as U, RequestStatus as Un, DestinationKind as Ut, PayrollGroupsMethods as V, PAYMENT_STATUSES as Vn, Destination as Vt, PayrollRun as W, TelemetryEvent as Wn, DestinationListInput as Wt, OrganizationPaymentItemInput as X, IdentityEvent as Xn, HandlesMethods as Xt, OrganizationPaymentInput as Y, Destination$1 as Yn, FinancialOpsMethods as Yt, OrganizationPaymentsMethods as Z, IdentityState as Zn, MeMethods as Zt, SystemMethods as _, PaymentType as _n, ActorRequestsMethods as _t, SdkFailureObservation as a, PayeesMethods as an, InvocationControls as ar, PermissionReadResult as at, CurrentUserContext as b, RecipientResolution as bn, AddressBookLabelInput as bt, PostHogObservabilityOptions as c, PaymentDirection as cn, OrgMeMethod as ct, CreateCapxulClientInput as d, PaymentDocumentRender as dn, AccountMethods as dt, OfframpMethods as en, StateLabel as er, PermissionCreateInput as et, IdentityProfileDetails as f, PaymentDocumentVerification as fn, ActorProfile as ft, Holding as g, PaymentTiming as gn, ActorRequestIssueInput as gt, HoldingsMethods as h, PaymentStatus as hn, ActorRequest as ht, ObservationDelivery as i, Payee as in, IdentityTransition as ir, PermissionRevokeInput as it, OrganizationAccount as j, SmartAccountMethods as jn, ActivityListParams as jt, OrgTemplate as k, isSettingUpLifecycle as kn, ActivityItem as kt, postHogObservability as l, PaymentDocumentKind as ln, OrgMeOptions as lt, IdentityRuntimeSendResult as m, PaymentMoney as mn, ActorRelationshipMethods as mt, ObservationAdapter as n, OfframpQuoteInput as nn, isClaimed as nr, PermissionOptions as nt, HostObservability as o, Payment as on, Budget as ot, IdentityRuntime as p, PaymentDocumentsMethods as pn, ActorProfileMethods as pt, PayrollRuns as q, TelemetryPort as qn, DestinationRemoveInput as qt, ObservationContext as r, OfframpStatus as rn, isRestoring as rr, PermissionReplaceInput as rt, PostHogObservabilityClient as s, PaymentActivityEvidence as sn, OrgMe as st, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as t, OfframpQuote as tn, destination as tr, PermissionMethods as tt, CapxulClient as u, PaymentDocumentRef as un, AccountsMethods as ut, SystemHealth as v, PaymentsMethods as vn, AddressBookAddInput as vt, InviteMemberInput as w, TargetReference as wn, InboxMethods as wt, CurrentUserMethods as x, RecipientResolutionKind as xn, AddressBookMethods as xt, MediaMethods as y, PaymentsPayInput as yn, AddressBookEntry as yt, PayrollGroupInput as z, InboxStatus as zn, ActorReference as zt };
@@ -66,6 +66,8 @@ declare const Errors: {
66
66
  readonly accountNotFound: (accountId?: string) => CapxulError;
67
67
  readonly providerError: (provider: string, operation: string, cause: unknown, opts?: {
68
68
  readonly failure_mode?: FailureMode;
69
+ readonly httpStatus?: number; /** Extra evidence for the operator (response body, edge error code). */
70
+ readonly details?: Readonly<Record<string, unknown>>;
69
71
  }) => CapxulError;
70
72
  readonly capabilityUnavailable: (provider: string, operation: string) => CapxulError;
71
73
  readonly invalidInput: (field: string, reason: string) => CapxulError;
@@ -196,6 +198,8 @@ type PermissionId = Brand<string, "PermissionId">;
196
198
  type PermissionAssignmentId = Brand<string, "PermissionAssignmentId">;
197
199
  type BudgetId = Brand<string, "BudgetId">;
198
200
  type PaymentCommandId = Brand<string, "PaymentCommandId">;
201
+ type PayrollRunId = Brand<string, "PayrollRunId">;
202
+ type PayrollGroupId = Brand<string, "PayrollGroupId">;
199
203
  type OrgId = Brand<string, "OrgId">;
200
204
  type AppId = Brand<string, "AppId">;
201
205
  type AllowedOrigin = Brand<string, "AllowedOrigin">;
@@ -406,4 +410,4 @@ interface Eip1193RequestProvider {
406
410
  */
407
411
  declare function injectedWalletSigner(provider: Eip1193RequestProvider): CapxulSigner;
408
412
  //#endregion
409
- export { toCountryCode as $, BlockNumber as A, OrgId as B, Address$1 as C, AppId as D, AnonymousDistinctId as E, DocumentHash as F, Profile$1 as G, PaymentCommandId as H, DurationMs as I, SessionToken as J, PublishableKey as K, Email as L, ChainId as M, CountryCode as N, AuthSession as O, CurrencyCode as P, toAddress as Q, EpochMs as R, AccountId as S, AllowedOrigin as T, PermissionAssignmentId as U, PartyId as V, PermissionId as W, TxHash as X, SmartAccount$1 as Y, WeiAmount as Z, AuthCacheError as _, SignerStatusStore as a, Failure as at, CachedJwt as b, AccountProviderSource as c, eip1193AccountProvider as d, CAPXUL_ERROR_CODES as et, localPrivateKeyAccountProvider as f, SmartAccount as g, Session as h, SignerStatus as i, Errors as it, BudgetId as j, AuthUserId as k, AccountRequirement as l, Profile as m, CapxulSigner as n, CapxulErrorCode as nt, injectedWalletSigner as o, FailureMode as ot, CapxulResult as p, RoleKey as q, Eip1193RequestProvider as r, CapxulErrorDetails as rt, AccountProvider as s, isCapxulError as st, CapxulDigestSigner as t, CapxulError as tt, Eip1193Provider as u, AuthCachePort as v, AllowanceKey as w, Account$1 as x, AuthCachePortTag as y, Money as z };
413
+ export { WeiAmount as $, BlockNumber as A, OrgId as B, Address$1 as C, AppId as D, AnonymousDistinctId as E, DocumentHash as F, PermissionAssignmentId as G, PaymentCommandId as H, DurationMs as I, PublishableKey as J, PermissionId as K, Email as L, ChainId as M, CountryCode as N, AuthSession as O, CurrencyCode as P, TxHash as Q, EpochMs as R, AccountId as S, AllowedOrigin as T, PayrollGroupId as U, PartyId as V, PayrollRunId as W, SessionToken as X, RoleKey as Y, SmartAccount$1 as Z, AuthCacheError as _, SignerStatusStore as a, CapxulErrorDetails as at, CachedJwt as b, AccountProviderSource as c, FailureMode as ct, eip1193AccountProvider as d, toAddress as et, localPrivateKeyAccountProvider as f, SmartAccount as g, Session as h, SignerStatus as i, CapxulErrorCode as it, BudgetId as j, AuthUserId as k, AccountRequirement as l, isCapxulError as lt, Profile as m, CapxulSigner as n, CAPXUL_ERROR_CODES as nt, injectedWalletSigner as o, Errors as ot, CapxulResult as p, Profile$1 as q, Eip1193RequestProvider as r, CapxulError as rt, AccountProvider as s, Failure as st, CapxulDigestSigner as t, toCountryCode as tt, Eip1193Provider as u, AuthCachePort as v, AllowanceKey as w, Account$1 as x, AuthCachePortTag as y, Money as z };
@@ -1,4 +1,4 @@
1
- import { Fn as TelemetryIdentifyInput, Nn as TelemetryEvent, Pn as TelemetryGroupInput, n as ObservationAdapter, qn as IdentityTransition, u as CapxulClient } from "../observation-BfCkJY5z.mjs";
1
+ import { Gn as TelemetryGroupInput, Kn as TelemetryIdentifyInput, Wn as TelemetryEvent, ir as IdentityTransition, n as ObservationAdapter, u as CapxulClient } from "../observation-BQ2VKWH5.mjs";
2
2
  import { Effect, Layer } from "effect";
3
3
 
4
4
  //#region src/testing/telemetry/RecordingTelemetryAdapter.d.ts
@@ -1,5 +1,5 @@
1
- import { E as authClientPortFromPromiseAdapter, M as fromWei, T as bootstrapErrorFromCapxul, Z as deriveCapxulSafeAddress, _ as wireChainId, f as redactTelemetryEvent, g as accountReadErrorFromCapxul, j as toWei, m as smartAccountErrorFromCapxul, t as assembleCapxulClient, x as convexCallErrorFromCapxul, y as identityErrorFromCapxul } from "../create-capxul-client-BrE6tLg6.mjs";
2
- import { C as toDurationMs, D as toJwtToken, E as toEpochSeconds, I as CapxulError, N as toSessionToken, O as toKycTier, R as Errors, T as toEpochMs, _ as toAppId, b as toChainId, g as toAllowedOrigin, h as toAddress, j as toPublishableKey, m as toAccountId, t as InMemoryAuthCacheAdapter, v as toAuthUserId, w as toEmail, x as toCountryCode } from "../InMemoryAuthCacheAdapter-qMpBOGb3.mjs";
1
+ import { $ as deriveCapxulSafeAddress, C as convexCallErrorFromCapxul, D as bootstrapErrorFromCapxul, N as toWei, O as authClientPortFromPromiseAdapter, P as fromWei, g as smartAccountErrorFromCapxul, m as redactTelemetryEvent, t as assembleCapxulClient, v as accountReadErrorFromCapxul, x as identityErrorFromCapxul, y as wireChainId } from "../create-capxul-client-B050H6SY.mjs";
2
+ import { B as Errors, C as toDurationMs, D as toJwtToken, E as toEpochSeconds, F as toSessionToken, N as toPublishableKey, O as toKycTier, R as CapxulError, T as toEpochMs, _ as toAppId, b as toChainId, g as toAllowedOrigin, h as toAddress, m as toAccountId, t as InMemoryAuthCacheAdapter, v as toAuthUserId, w as toEmail, x as toCountryCode } from "../InMemoryAuthCacheAdapter-uOcqpqu8.mjs";
3
3
  import { keccak256 } from "viem";
4
4
  import { Effect, Result, Semaphore } from "effect";
5
5
  import { getFunctionName } from "convex/server";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/sdk",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Xelmar-tech/infrastructure.git",
@@ -46,12 +46,12 @@
46
46
  "typescript": "npm:@typescript/typescript6@6.0.2",
47
47
  "vite-plus": "0.1.23",
48
48
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.23",
49
- "@capxul/config": "0.2.0",
50
- "@capxul/errors": "0.0.1",
49
+ "@capxul/config": "0.2.1",
50
+ "@capxul/errors": "0.0.2",
51
51
  "@capxul/typescript-config": "0.0.0",
52
- "@capxul/wire": "0.5.0",
53
- "@capxul/observability": "2.4.0",
54
- "@capxul/types": "0.2.0"
52
+ "@capxul/types": "0.2.1",
53
+ "@capxul/wire": "0.5.1",
54
+ "@capxul/observability": "2.5.1"
55
55
  },
56
56
  "_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.",
57
57
  "scripts": {