@capxul/sdk 1.0.0-alpha.6 → 1.0.0-alpha.7

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.
package/dist/index.d.mts CHANGED
@@ -1,13 +1,11 @@
1
- import { a as AccountProviderSource, c as eip1193AccountProvider, d as CapxulResult, f as Profile, g as AuthCachePort, i as AccountProvider, l as localPrivateKeyAccountProvider, m as SmartAccount, n as Eip1193RequestProvider, o as AccountRequirement, p as Session, r as injectedWalletSigner, s as Eip1193Provider, t as CapxulSigner, u as openfortEmbeddedAccountProvider, v as CachedJwt } from "./signer-3-awyCio.mjs";
2
- import { a as SafeDeploymentEvidence, n as SafeDeploymentConfig } from "./safe-deployment-Vni46k3t.mjs";
3
- import { Context, Effect, Layer, Request } from "effect";
4
- import { Machine } from "@effect/experimental";
5
- import { CapxulError, CapxulErrorCode, CapxulErrorDetails } from "@capxul/config";
6
- import { Account, Account as Account$1, AccountId, Address, Address as Address$1, AllowedOrigin, AnonymousDistinctId, AppId, AuthSession, AuthSession as AuthSession$1, AuthUserId, AuthUserId as AuthUserId$1, ChainId, CountryCode, DeveloperApplication, DurationMs, Email, EpochMs, Money, Money as Money$1, OrgId, OrgId as OrgId$1, Profile as Profile$1, PublishableKey, PublishableKeyId, PublishableKeyRecord, RoleKey, RoleKey as RoleKey$1, RunId, SessionToken, SmartAccount as SmartAccount$1, SubAccount, SubAccount as SubAccount$1, SubAccountId, SubAccountId as SubAccountId$1 } from "@capxul/types";
7
- import { TelemetryEvent, TelemetryGroupInput, TelemetryIdentifyInput } from "@capxul/observability";
1
+ import { A as SubAccount, C as PublishableKey, D as RunId, E as RoleKey, F as CapxulErrorDetails, I as FailureMode, N as CapxulError, O as SessionToken, P as CapxulErrorCode, S as Profile$1, T as PublishableKeyRecord, _ as EpochMs, a as AnonymousDistinctId, b as Money, c as AuthUserId, d as CountryCode, f as CurrencyCode, g as Email, h as DurationMs, i as AllowedOrigin, j as SubAccountId, k as SmartAccount$1, m as DocumentHash, n as AccountId, o as AppId, p as DeveloperApplication, r as Address, s as AuthSession, t as Account, u as ChainId, w as PublishableKeyId, x as OrgId } from "./index-CTXgQ_xR.mjs";
2
+ import { _ as CachedJwt, a as AccountProviderSource, c as eip1193AccountProvider, d as Profile, f as Session, h as AuthCachePort, i as AccountProvider, l as localPrivateKeyAccountProvider, n as Eip1193RequestProvider, o as AccountRequirement, p as SmartAccount, r as injectedWalletSigner, s as Eip1193Provider, t as CapxulSigner, u as CapxulResult } from "./signer-DqDtJU1l.mjs";
3
+ import { a as SafeDeploymentEvidence, n as SafeDeploymentConfig } from "./safe-deployment-D3k9yndM.mjs";
8
4
  import { Hex } from "viem";
5
+ import { Context, Effect, Layer, Request } from "effect";
9
6
  import { Schema } from "@effect/schema";
10
7
  import { FunctionReference } from "convex/server";
8
+ import { Machine } from "@effect/experimental";
11
9
 
12
10
  //#region src/ports/auth-client.d.ts
13
11
  type AuthClientOperationOptions = {
@@ -41,8 +39,8 @@ declare class AuthClientError extends AuthClientError_base<{
41
39
  interface AuthClientPort {
42
40
  canSendOtp(input: CanSendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<CanSendOtpStatus, AuthClientError>;
43
41
  sendOtp(input: SendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
44
- verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession$1, AuthClientError>;
45
- getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession$1 | null, AuthClientError>;
42
+ verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession, AuthClientError>;
43
+ getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession | null, AuthClientError>;
46
44
  signOut(options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
47
45
  /**
48
46
  * Fetches a Convex-aud JWT from `/api/auth/convex/token` (W7). Server mints
@@ -67,12 +65,48 @@ declare class ClockError extends ClockError_base<{
67
65
  readonly cause: unknown;
68
66
  }> {}
69
67
  //#endregion
70
- //#region src/ports/telemetry.d.ts
68
+ //#region ../observability/src/telemetry-port.d.ts
69
+ /**
70
+ * Context for reporting handled errors via `reportHandledError`.
71
+ * Carries structured metadata extracted from the error context.
72
+ */
73
+ interface HandledErrorReportContext$1 {
74
+ readonly layer?: string;
75
+ readonly operation?: string;
76
+ readonly failure_mode?: FailureMode;
77
+ readonly provider?: string;
78
+ }
79
+ /**
80
+ * Canonical TelemetryPort interface. Every adapter (production, test, in-memory)
81
+ * implements this contract. All methods return `Effect<void, never>` —
82
+ * fire-and-forget, defects are caught and traced.
83
+ */
71
84
  interface TelemetryPort {
72
85
  readonly emit: (event: TelemetryEvent) => Effect.Effect<void, never>;
73
86
  readonly identify: (input: TelemetryIdentifyInput) => Effect.Effect<void, never>;
74
87
  readonly group: (input: TelemetryGroupInput) => Effect.Effect<void, never>;
75
88
  readonly reset: () => Effect.Effect<void, never>;
89
+ readonly reportHandledError?: (error: CapxulError, context?: HandledErrorReportContext$1) => Effect.Effect<void, never>;
90
+ }
91
+ //#endregion
92
+ //#region ../observability/src/index.d.ts
93
+ declare const TELEMETRY_EVENT_NAMES: readonly ["auth_otp_requested", "auth_otp_delivered", "auth_otp_expired", "auth_verified", "auth_failed", "auth_signed_out", "provisioning_safe_created", "provisioning_safe_confirmed", "bootstrap_resolved", "bootstrap_failed", "account_balance_read", "account_balance_failed", "faucet_requested", "faucet_confirmed", "faucet_failed", "subaccount_created", "subaccount_renamed", "subaccount_deleted", "subaccount_op_failed", "transfer_requested", "transfer_confirmed", "transfer_failed", "org_create_started", "org_safe_created", "org_safe_confirmed", "org_roles_seeded", "org_created", "org_create_failed", "org_invite_sent", "org_invite_accepted", "org_role_granted", "org_member_active", "org_member_removed", "org_invite_expired", "org_role_grant_failed", "payment_requested", "payment_resolved", "payment_document_attached", "payment_submitted", "payment_settled", "payment_claimed", "payment_cancelled", "payment_redirected", "payment_failed", "stream_created", "stream_claimed", "stream_cancelled", "stream_completed", "stream_failed", "withdrawal_requested", "withdrawal_submitted", "withdrawal_settled", "withdrawal_failed"];
94
+ type TelemetryEventName = (typeof TELEMETRY_EVENT_NAMES)[number];
95
+ type TelemetryProps = Record<string, unknown>;
96
+ type TelemetryEvent = {
97
+ readonly name: TelemetryEventName;
98
+ readonly props?: TelemetryProps | undefined;
99
+ };
100
+ interface TelemetryIdentifyInput {
101
+ readonly distinctId: string;
102
+ readonly anonDistinctId?: AnonymousDistinctId;
103
+ readonly traits?: TelemetryProps;
104
+ readonly properties?: TelemetryProps;
105
+ }
106
+ interface TelemetryGroupInput {
107
+ readonly groupType: string;
108
+ readonly groupKey: string;
109
+ readonly properties?: TelemetryProps;
76
110
  }
77
111
  //#endregion
78
112
  //#region src/flows/auth.d.ts
@@ -83,7 +117,7 @@ type AuthFlowState = "idle" | "sending_otp" | "otp_requested" | "verifying" | "a
83
117
  interface AuthFlowContext {
84
118
  readonly state: AuthFlowState;
85
119
  readonly email: Email | null;
86
- readonly session: AuthSession$1 | null;
120
+ readonly session: AuthSession | null;
87
121
  readonly otpRequestedAt: EpochMs | null;
88
122
  readonly anonDistinctId?: AnonymousDistinctId;
89
123
  readonly error: CapxulError | null;
@@ -126,41 +160,6 @@ interface EnvPort {
126
160
  readonly has: (key: EnvKey) => Effect.Effect<boolean, EnvError, never>;
127
161
  }
128
162
  //#endregion
129
- //#region src/ports/evm-signer.d.ts
130
- type HexString = `0x${string}`;
131
- type UserOperationRequest = {
132
- readonly sender: Address$1;
133
- readonly chainId: ChainId;
134
- readonly callData: HexString;
135
- readonly nonce?: HexString;
136
- readonly maxFeePerGas?: HexString;
137
- readonly maxPriorityFeePerGas?: HexString;
138
- readonly callGasLimit?: HexString;
139
- readonly verificationGasLimit?: HexString;
140
- readonly preVerificationGas?: HexString;
141
- readonly paymasterAndData?: HexString;
142
- };
143
- type SignedUserOperation = UserOperationRequest & {
144
- readonly sender: Address$1;
145
- readonly signature: HexString;
146
- readonly userOpHash: HexString;
147
- };
148
- declare const EvmSignerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
149
- readonly _tag: "EvmSignerError";
150
- } & Readonly<A>;
151
- declare class EvmSignerError extends EvmSignerError_base<{
152
- readonly publicError: CapxulError;
153
- readonly publicCode?: CapxulErrorCode;
154
- readonly operation?: string;
155
- readonly details?: CapxulErrorDetails;
156
- readonly cause?: unknown;
157
- }> {}
158
- interface EvmSignerPort {
159
- readonly getAddress: Effect.Effect<Address$1, EvmSignerError, never>;
160
- readonly signMessage: (message: string | Uint8Array) => Effect.Effect<HexString, EvmSignerError, never>;
161
- readonly signUserOp: (userOperation: UserOperationRequest) => Effect.Effect<SignedUserOperation, EvmSignerError, never>;
162
- }
163
- //#endregion
164
163
  //#region src/ports/transport.d.ts
165
164
  type TransportOperationKind = "query" | "mutation" | "action";
166
165
  type TransportRequest<TArgs = unknown> = {
@@ -302,22 +301,22 @@ interface ConvexCallPort {
302
301
  //#endregion
303
302
  //#region src/ports/credentials.d.ts
304
303
  type CreateApplicationInput = {
305
- readonly authUserId: AuthUserId$1;
304
+ readonly authUserId: AuthUserId;
306
305
  readonly name: string;
307
306
  readonly allowedOrigins: readonly AllowedOrigin[];
308
307
  };
309
308
  type MintKeyInput = {
310
309
  readonly applicationId: AppId;
311
- readonly authUserId: AuthUserId$1;
310
+ readonly authUserId: AuthUserId;
312
311
  };
313
312
  type RotateKeyInput = {
314
313
  readonly keyId: PublishableKeyId;
315
- readonly authUserId: AuthUserId$1;
314
+ readonly authUserId: AuthUserId;
316
315
  readonly graceMs: DurationMs;
317
316
  };
318
317
  type RevokeKeyInput = {
319
318
  readonly keyId: PublishableKeyId;
320
- readonly authUserId: AuthUserId$1;
319
+ readonly authUserId: AuthUserId;
321
320
  };
322
321
  type RotateKeyResult = {
323
322
  readonly active: PublishableKeyRecord;
@@ -334,7 +333,7 @@ declare class CredentialsError extends CredentialsError_base<{
334
333
  readonly details?: CapxulErrorDetails;
335
334
  }> {}
336
335
  interface CredentialsPort {
337
- listApplications(authUserId: AuthUserId$1): Effect.Effect<readonly DeveloperApplication[], CredentialsError>;
336
+ listApplications(authUserId: AuthUserId): Effect.Effect<readonly DeveloperApplication[], CredentialsError>;
338
337
  createApplication(input: CreateApplicationInput): Effect.Effect<DeveloperApplication, CredentialsError>;
339
338
  mintPublishableKey(input: MintKeyInput): Effect.Effect<PublishableKeyRecord, CredentialsError>;
340
339
  rotatePublishableKey(input: RotateKeyInput): Effect.Effect<RotateKeyResult, CredentialsError>;
@@ -343,13 +342,13 @@ interface CredentialsPort {
343
342
  //#endregion
344
343
  //#region src/ports/identity.d.ts
345
344
  type CreateIdentityInput = {
346
- readonly authUserId: AuthUserId$1;
345
+ readonly authUserId: AuthUserId;
347
346
  readonly email: Email;
348
347
  readonly displayName?: string;
349
348
  readonly country?: CountryCode;
350
349
  };
351
350
  type UpdateIdentityInput = {
352
- readonly authUserId: AuthUserId$1;
351
+ readonly authUserId: AuthUserId;
353
352
  readonly displayName?: string;
354
353
  readonly country?: CountryCode;
355
354
  };
@@ -364,14 +363,14 @@ declare class IdentityError extends IdentityError_base<{
364
363
  readonly details?: CapxulErrorDetails;
365
364
  }> {}
366
365
  interface IdentityPort {
367
- loadByAuthUserId(authUserId: AuthUserId$1): Effect.Effect<Profile$1 | null, IdentityError, never>;
366
+ loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<Profile$1 | null, IdentityError, never>;
368
367
  create(input: CreateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
369
368
  update(input: UpdateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
370
369
  }
371
370
  //#endregion
372
371
  //#region src/ports/smart-account.d.ts
373
372
  type ProvisionInput = {
374
- readonly authUserId: AuthUserId$1;
373
+ readonly authUserId: AuthUserId;
375
374
  readonly chainId: ChainId;
376
375
  };
377
376
  /**
@@ -389,9 +388,9 @@ type ProvisionInput = {
389
388
  * `eth_getUserOperationReceipt(userOpHash)` to re-verify and derive.
390
389
  */
391
390
  type ConfirmDeploymentInput = {
392
- readonly authUserId: AuthUserId$1;
391
+ readonly authUserId: AuthUserId;
393
392
  readonly chainId: ChainId;
394
- readonly safeAddress: Address$1;
393
+ readonly safeAddress: Address;
395
394
  readonly evidence: SafeDeploymentEvidence;
396
395
  /**
397
396
  * Optional live-E2E correlation id. This does not prove deployment; the
@@ -400,41 +399,16 @@ type ConfirmDeploymentInput = {
400
399
  */
401
400
  readonly telemetryRunId?: RunId;
402
401
  };
403
- /** Opaque wire form of the backend-built deployment UserOperation (hex strings). */
404
- type DeploymentUserOpFields = {
405
- readonly sender: string;
406
- readonly nonce: string;
407
- readonly factory: string;
408
- readonly factoryData: string;
409
- readonly callData: string;
410
- readonly callGasLimit: string;
411
- readonly verificationGasLimit: string;
412
- readonly preVerificationGas: string;
413
- readonly maxFeePerGas: string;
414
- readonly maxPriorityFeePerGas: string;
415
- readonly paymaster: string;
416
- readonly paymasterVerificationGasLimit?: string | undefined;
417
- readonly paymasterPostOpGasLimit?: string | undefined;
418
- readonly paymasterData: string;
419
- };
420
- /** Input to `SmartAccountPort.deployPrepare` (backend-orchestrated-deploy.md · #289). */
421
- type DeployPrepareInput = {
422
- readonly authUserId: AuthUserId$1;
423
- readonly chainId: ChainId;
424
- readonly telemetryRunId?: RunId;
425
- };
426
- /** Backend-built deployment UserOp + the EIP-712 SafeOp digest the CapxulSigner signs. */
427
- type DeployPrepareResult = {
428
- readonly digest: Hex;
429
- readonly safeAddress: Address$1;
430
- readonly userOp: DeploymentUserOpFields;
431
- };
432
- /** Input to `SmartAccountPort.deploySubmit` — the consumer-signed deployment UserOp. */
433
- type DeploySubmitInput = {
434
- readonly authUserId: AuthUserId$1;
402
+ /**
403
+ * Input to `SmartAccountPort.claim` (PRD #462). The authenticated session
404
+ * reports the browser-created signer address; the BACKEND builds and
405
+ * bootstrap-signs the claim userOp (deploy + swapOwner) — the consumer signs
406
+ * nothing at claim.
407
+ */
408
+ type ClaimInput = {
409
+ readonly authUserId: AuthUserId;
435
410
  readonly chainId: ChainId;
436
- readonly userOp: DeploymentUserOpFields;
437
- readonly signature: Hex;
411
+ readonly signerAddress: Address;
438
412
  readonly telemetryRunId?: RunId;
439
413
  };
440
414
  declare const SmartAccountError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
@@ -448,8 +422,8 @@ declare class SmartAccountError extends SmartAccountError_base<{
448
422
  readonly details?: CapxulErrorDetails;
449
423
  }> {}
450
424
  interface SmartAccountPort {
451
- loadByAuthUserId(authUserId: AuthUserId$1): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
452
- loadBySmartAccountAddress(address: Address$1): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
425
+ loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
426
+ loadBySmartAccountAddress(address: Address): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
453
427
  provision(input: ProvisionInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
454
428
  /**
455
429
  * Persist on-chain Safe-deployment evidence. The backend re-verifies
@@ -462,42 +436,13 @@ interface SmartAccountPort {
462
436
  */
463
437
  confirmDeployment(input: ConfirmDeploymentInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
464
438
  /**
465
- * Build + gas-fill + paymaster-sponsor the deployment UserOperation
466
- * server-side and return the EIP-712 `SafeOp` digest for the consumer's
467
- * `CapxulSigner` to sign. The client never holds RPC, a gas policy, or a
468
- * bundler see `docs/canon/decisions/backend-orchestrated-deploy.md`.
439
+ * Claim the account (PRD #462): the backend builds, bootstrap-signs, and
440
+ * submits ONE sponsored userOp deploy (when undeployed) + swapOwner
441
+ * (bootstrap → `signerAddress`). Idempotent; returns the updated row. When
442
+ * another claim is in flight the row comes back with `claimedAt: null` —
443
+ * callers poll lifecycle until the claim lands.
469
444
  */
470
- deployPrepare(input: DeployPrepareInput): Effect.Effect<DeployPrepareResult, SmartAccountError, never>;
471
- /**
472
- * Submit the signed deployment UserOperation through the bundler and confirm
473
- * `deployedAt` on-chain (absorbing the `confirmDeployment` verify path).
474
- * Returns the updated `SmartAccount` row.
475
- */
476
- deploySubmit(input: DeploySubmitInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
477
- }
478
- //#endregion
479
- //#region src/ports/binding.d.ts
480
- type EmailBinding = {
481
- readonly bindingId: string;
482
- readonly signerAddress: Address$1;
483
- readonly safeAddress: Address$1;
484
- };
485
- type EnsureBindingResolvedInput = {
486
- readonly email: Email; /** Browser embedded wallet EOA when the client already configured Openfort Shield. */
487
- readonly signerAddress?: Address$1;
488
- };
489
- declare const BindingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
490
- readonly _tag: "BindingError";
491
- } & Readonly<A>;
492
- declare class BindingError extends BindingError_base<{
493
- readonly operation: string;
494
- readonly publicCode: CapxulErrorCode;
495
- readonly publicError: CapxulError;
496
- readonly cause: unknown;
497
- readonly details?: CapxulErrorDetails;
498
- }> {}
499
- interface BindingPort {
500
- readonly ensureResolved: (input: EnsureBindingResolvedInput) => Effect.Effect<EmailBinding, BindingError>;
445
+ claim(input: ClaimInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
501
446
  }
502
447
  //#endregion
503
448
  //#region src/ports/account-read.d.ts
@@ -506,7 +451,7 @@ type ReadAccountBalanceInput = {
506
451
  };
507
452
  type FundFromFaucetInput = {
508
453
  readonly chainId: ChainId;
509
- readonly amount: Money$1;
454
+ readonly amount: Money;
510
455
  };
511
456
  type FundFromFaucetResult = {
512
457
  readonly txHash: string;
@@ -526,7 +471,7 @@ declare class AccountReadError extends AccountReadError_base<{
526
471
  * live RPC `balanceOf` pull; the adapter lifts wire integers to `Money`.
527
472
  */
528
473
  interface AccountReadPort {
529
- readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account$1, AccountReadError, never>;
474
+ readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account, AccountReadError, never>;
530
475
  fundFromFaucet(input: FundFromFaucetInput): Effect.Effect<FundFromFaucetResult, AccountReadError, never>;
531
476
  }
532
477
  //#endregion
@@ -546,10 +491,10 @@ type CreateSubAccountInput = {
546
491
  readonly name: string;
547
492
  };
548
493
  type SubAccountIdInput = {
549
- readonly subAccountId: SubAccountId$1;
494
+ readonly subAccountId: SubAccountId;
550
495
  };
551
496
  type RenameSubAccountInput = {
552
- readonly subAccountId: SubAccountId$1;
497
+ readonly subAccountId: SubAccountId;
553
498
  readonly name: string;
554
499
  };
555
500
  /**
@@ -558,7 +503,7 @@ type RenameSubAccountInput = {
558
503
  * specific sub-account, addressed by its `SubAccountId` (canon
559
504
  * `account-balance-model.md` §5, §12).
560
505
  */
561
- type TransferEndpoint = "main" | SubAccountId$1;
506
+ type TransferEndpoint = "main" | SubAccountId;
562
507
  /**
563
508
  * Move money between two of the SAME Account's balances (canon §12). The
564
509
  * backend resolves the Account from auth (v1 = one Account per user), so the
@@ -569,7 +514,7 @@ type TransferEndpoint = "main" | SubAccountId$1;
569
514
  type TransferInput = {
570
515
  readonly from: TransferEndpoint;
571
516
  readonly to: TransferEndpoint;
572
- readonly amount: Money$1;
517
+ readonly amount: Money;
573
518
  };
574
519
  /**
575
520
  * Result of a `transfer`: the recomputed `available` (`balanceOf − Σ`), plus
@@ -577,27 +522,29 @@ type TransferInput = {
577
522
  * has no stored row, so its slot is `null`.
578
523
  */
579
524
  type TransferResult = {
580
- readonly available: Money$1;
581
- readonly from: SubAccount$1 | null;
582
- readonly to: SubAccount$1 | null;
525
+ readonly available: Money;
526
+ readonly from: SubAccount | null;
527
+ readonly to: SubAccount | null;
583
528
  };
584
529
  interface SubAccountPort {
585
- create(input: CreateSubAccountInput): Effect.Effect<SubAccount$1, SubAccountError, never>;
586
- get(input: SubAccountIdInput): Effect.Effect<SubAccount$1 | null, SubAccountError, never>;
530
+ create(input: CreateSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
531
+ get(input: SubAccountIdInput): Effect.Effect<SubAccount | null, SubAccountError, never>;
587
532
  list(input: {
588
533
  readonly accountId: AccountId;
589
- }): Effect.Effect<readonly SubAccount$1[], SubAccountError, never>;
590
- rename(input: RenameSubAccountInput): Effect.Effect<SubAccount$1, SubAccountError, never>;
534
+ }): Effect.Effect<readonly SubAccount[], SubAccountError, never>;
535
+ rename(input: RenameSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
591
536
  delete(input: SubAccountIdInput): Effect.Effect<void, SubAccountError, never>;
592
537
  transfer(input: TransferInput): Effect.Effect<TransferResult, SubAccountError, never>;
593
538
  }
594
539
  //#endregion
595
540
  //#region src/flows/types.d.ts
596
541
  /**
597
- * The full 14-port bundle that `assembleCapxulClient` (slice 5) consumes.
542
+ * The full 13-port bundle that `assembleCapxulClient` (slice 5) consumes.
543
+ * (Was 15 before the dead local-signer port was retired; the deploy path
544
+ * now signs exclusively through `CapxulSigner`.)
598
545
  *
599
546
  * Each per-flow factory in slices 2-4 takes a narrowed subset, e.g.
600
- * `AuthFlowPorts = Pick<FlowPorts, "authClient" | "authCache" | "clock" | "telemetry">`.
547
+ * `AuthFlowPorts = Pick<FlowPorts, "authClient" | "clock" | "telemetry">`.
601
548
  * Slice 1 ships only the union; per Q6 each per-flow slice declares its
602
549
  * own narrowed `Pick<FlowPorts, ...>` inside its flow file.
603
550
  */
@@ -606,12 +553,10 @@ interface FlowPorts {
606
553
  readonly authCache: AuthCachePort;
607
554
  readonly identity: IdentityPort;
608
555
  readonly smartAccount: SmartAccountPort;
609
- readonly binding: BindingPort;
610
556
  readonly accountRead: AccountReadPort;
611
557
  readonly subAccount: SubAccountPort;
612
558
  readonly credentials: CredentialsPort;
613
559
  readonly bootstrap: BootstrapPort;
614
- readonly evmSigner: EvmSignerPort;
615
560
  readonly clock: ClockPort;
616
561
  readonly env: EnvPort;
617
562
  readonly telemetry: TelemetryPort;
@@ -650,7 +595,7 @@ interface FlowPorts {
650
595
  * convention, flow-shape composites stay co-located with their flow.
651
596
  */
652
597
  interface ExternalSigner {
653
- readonly address: Address$1;
598
+ readonly address: Address;
654
599
  readonly signedProof: string;
655
600
  }
656
601
  //#endregion
@@ -696,13 +641,11 @@ interface IdentityMethods {
696
641
  }
697
642
  //#endregion
698
643
  //#region src/client/account-lane.d.ts
699
- type ProvisioningFailureStep = "wallet" | "binding" | "identity" | "provision" | "deploy";
644
+ type ProvisioningFailureStep = "wallet" | "identity" | "provision" | "deploy";
700
645
  type ProvisioningPhase = {
701
646
  readonly status: "idle";
702
647
  } | {
703
648
  readonly status: "wallet";
704
- } | {
705
- readonly status: "binding";
706
649
  } | {
707
650
  readonly status: "identity";
708
651
  } | {
@@ -747,7 +690,7 @@ type AccountStatus = {
747
690
  readonly requirement: AccountRequirement;
748
691
  readonly chainId: number;
749
692
  readonly source: AccountProviderSource;
750
- readonly signerAddress: Address$1;
693
+ readonly signerAddress: Address;
751
694
  } | {
752
695
  readonly status: "accountPrepared";
753
696
  readonly requirement: AccountRequirement;
@@ -822,18 +765,11 @@ interface AccountInternalSurface {
822
765
  retryProvisioning(): Promise<CapxulResult<ProvisioningPhase>>;
823
766
  }
824
767
  //#endregion
825
- //#region src/client/binding.d.ts
826
- interface BindingMethods {
827
- readonly ensureResolved: (input: {
828
- readonly email: string;
829
- }) => Promise<CapxulResult<EmailBinding>>;
830
- }
831
- //#endregion
832
768
  //#region src/client/accounts.d.ts
833
769
  interface AccountsMethods {
834
770
  read(options?: {
835
771
  readonly signal?: AbortSignal;
836
- }): Promise<CapxulResult<Account$1>>;
772
+ }): Promise<CapxulResult<Account>>;
837
773
  }
838
774
  /**
839
775
  * Faucet surface (dev-only). Deliberately OFF the public `AccountsMethods`;
@@ -841,30 +777,658 @@ interface AccountsMethods {
841
777
  * The reference CLI uses it behind a test-env gate — consumers never see `fund`.
842
778
  */
843
779
  interface AccountsFaucetMethods {
844
- fund(amount: Money$1, options?: {
780
+ fund(amount: Money, options?: {
845
781
  readonly signal?: AbortSignal;
846
782
  }): Promise<CapxulResult<{
847
783
  readonly txHash: string;
848
784
  }>>;
849
785
  }
850
786
  //#endregion
787
+ //#region ../wire/src/financial-ops.d.ts
788
+ declare const PaymentDocumentEnvelope: Schema.Union<[Schema.Struct<{
789
+ protocol: Schema.Literal<["capxul.payment-document"]>;
790
+ version: Schema.Literal<[1]>;
791
+ domain: Schema.Struct<{
792
+ name: Schema.Literal<["CapxulPayments"]>;
793
+ version: Schema.Literal<["1"]>;
794
+ chainId: Schema.Schema<ChainId, number, never>;
795
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
796
+ }>;
797
+ primaryType: Schema.Literal<["Memo"]>;
798
+ message: Schema.Struct<{
799
+ kind: Schema.Literal<[0]>;
800
+ reference: typeof Schema.String;
801
+ note: typeof Schema.String;
802
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
803
+ }>;
804
+ }>, Schema.Struct<{
805
+ protocol: Schema.Literal<["capxul.payment-document"]>;
806
+ version: Schema.Literal<[1]>;
807
+ domain: Schema.Struct<{
808
+ name: Schema.Literal<["CapxulPayments"]>;
809
+ version: Schema.Literal<["1"]>;
810
+ chainId: Schema.Schema<ChainId, number, never>;
811
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
812
+ }>;
813
+ primaryType: Schema.Literal<["Invoice"]>;
814
+ message: Schema.Struct<{
815
+ kind: Schema.Literal<[1]>;
816
+ invoiceNumber: typeof Schema.String;
817
+ payerRef: typeof Schema.String;
818
+ payeeRef: typeof Schema.String;
819
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
820
+ currency: Schema.Schema<CurrencyCode, string, never>;
821
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
822
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
823
+ dueAt: Schema.refine<number, Schema.Schema<number, number, never>>;
824
+ lineItemsHash: Schema.Schema<DocumentHash, string, never>;
825
+ }>;
826
+ }>, Schema.Struct<{
827
+ protocol: Schema.Literal<["capxul.payment-document"]>;
828
+ version: Schema.Literal<[1]>;
829
+ domain: Schema.Struct<{
830
+ name: Schema.Literal<["CapxulPayments"]>;
831
+ version: Schema.Literal<["1"]>;
832
+ chainId: Schema.Schema<ChainId, number, never>;
833
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
834
+ }>;
835
+ primaryType: Schema.Literal<["Payslip"]>;
836
+ message: Schema.Struct<{
837
+ kind: Schema.Literal<[2]>;
838
+ employerRef: typeof Schema.String;
839
+ employeeRef: typeof Schema.String;
840
+ period: typeof Schema.String;
841
+ gross: Schema.refine<string, Schema.Schema<string, string, never>>;
842
+ net: Schema.refine<string, Schema.Schema<string, string, never>>;
843
+ currency: Schema.Schema<CurrencyCode, string, never>;
844
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
845
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
846
+ }>;
847
+ }>, Schema.Struct<{
848
+ protocol: Schema.Literal<["capxul.payment-document"]>;
849
+ version: Schema.Literal<[1]>;
850
+ domain: Schema.Struct<{
851
+ name: Schema.Literal<["CapxulPayments"]>;
852
+ version: Schema.Literal<["1"]>;
853
+ chainId: Schema.Schema<ChainId, number, never>;
854
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
855
+ }>;
856
+ primaryType: Schema.Literal<["Receipt"]>;
857
+ message: Schema.Struct<{
858
+ kind: Schema.Literal<[3]>;
859
+ reference: typeof Schema.String;
860
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
861
+ currency: Schema.Schema<CurrencyCode, string, never>;
862
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
863
+ paidAt: Schema.refine<number, Schema.Schema<number, number, never>>;
864
+ note: typeof Schema.String;
865
+ }>;
866
+ }>, Schema.Struct<{
867
+ protocol: Schema.Literal<["capxul.payment-document"]>;
868
+ version: Schema.Literal<[1]>;
869
+ domain: Schema.Struct<{
870
+ name: Schema.Literal<["CapxulPayments"]>;
871
+ version: Schema.Literal<["1"]>;
872
+ chainId: Schema.Schema<ChainId, number, never>;
873
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
874
+ }>;
875
+ primaryType: Schema.Literal<["Withdrawal"]>;
876
+ message: Schema.Struct<{
877
+ kind: Schema.Literal<[4]>;
878
+ reference: typeof Schema.String;
879
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
880
+ currency: Schema.Schema<CurrencyCode, string, never>;
881
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
882
+ destChain: Schema.Schema<ChainId, number, never>;
883
+ destAddress: Schema.refine<string, Schema.Schema<string, string, never>>;
884
+ settledAt: Schema.refine<number, Schema.Schema<number, number, never>>;
885
+ provider: typeof Schema.String;
886
+ note: typeof Schema.String;
887
+ }>;
888
+ }>]>;
889
+ /**
890
+ * #592 invoice line item. `quantity` is a positive integer; `unitMinor` is the
891
+ * per-unit price in integer minor units. The list is canonically hashed by
892
+ * `hashLineItems` (payment-document-hash.ts) into the Invoice `lineItemsHash`,
893
+ * and Σ(quantity × unitMinor) MUST equal the invoice `amount`. The hash binds
894
+ * the documentHash to the exact items; the sum-check makes the items add up to
895
+ * the amount due. See the payment-document spec (canon/mcp/financial-ops.md).
896
+ */
897
+ declare const LineItem: Schema.Struct<{
898
+ description: typeof Schema.String;
899
+ quantity: Schema.refine<number, Schema.Schema<number, number, never>>;
900
+ unitMinor: Schema.refine<string, Schema.Schema<string, string, never>>;
901
+ }>;
902
+ type PaymentDocumentEnvelopeV1 = Schema.Schema.Type<typeof PaymentDocumentEnvelope>;
903
+ type LineItemV1 = Schema.Schema.Type<typeof LineItem>;
904
+ //#endregion
905
+ //#region ../wire/src/leak-safety.d.ts
906
+ declare const OnchainEvidenceBrand: unique symbol;
907
+ /**
908
+ * The branded `{ userOpHash, txHash }` pair. On-chain settlement evidence is
909
+ * INTERNAL — it flows on the server-internal channel only, never onto a wire
910
+ * Payment or any MCP tool output. The brand makes "this is internal evidence"
911
+ * a type, so a loose pair can't be passed where a wire field is expected.
912
+ */
913
+ type OnchainEvidence = {
914
+ readonly userOpHash: string;
915
+ readonly txHash: string;
916
+ } & {
917
+ readonly [OnchainEvidenceBrand]: "OnchainEvidence";
918
+ };
919
+ //#endregion
920
+ //#region src/client/financial-ops.d.ts
921
+ type RecipientResolutionKind = "email" | "org" | "payee";
922
+ interface MeProfile {
923
+ readonly authUserId: string;
924
+ readonly email: string;
925
+ readonly displayName: string | null;
926
+ readonly personalSafeAddress: string;
927
+ }
928
+ interface DepositInstructions {
929
+ readonly accountKind: "personalSafe";
930
+ readonly chainId: number;
931
+ readonly network: "base-sepolia";
932
+ readonly currency: "USD";
933
+ readonly address: string;
934
+ readonly label: string;
935
+ }
936
+ interface RecipientResolution {
937
+ readonly kind: RecipientResolutionKind;
938
+ readonly recipient: string;
939
+ readonly label: string;
940
+ readonly safeAddress: string;
941
+ readonly payeeId?: string;
942
+ readonly orgId?: string;
943
+ readonly handle?: string;
944
+ readonly email?: string;
945
+ }
946
+ interface Payee {
947
+ readonly payeeId: string;
948
+ readonly label: string;
949
+ readonly recipientRef: string;
950
+ readonly handle: string | null;
951
+ readonly destinationKind: "email" | "org" | "payeeHandle";
952
+ readonly safeAddress: string;
953
+ readonly createdAt: number;
954
+ readonly updatedAt: number;
955
+ }
956
+ interface MeMethods {
957
+ get(options?: {
958
+ readonly signal?: AbortSignal;
959
+ }): Promise<CapxulResult<MeProfile>>;
960
+ depositInstructions(options?: {
961
+ readonly signal?: AbortSignal;
962
+ }): Promise<CapxulResult<DepositInstructions>>;
963
+ }
964
+ interface HandlesMethods {
965
+ resolve(handle: string, options?: {
966
+ readonly signal?: AbortSignal;
967
+ }): Promise<CapxulResult<RecipientResolution>>;
968
+ }
969
+ interface PayeesMethods {
970
+ create(input: {
971
+ readonly label: string;
972
+ readonly recipient: string;
973
+ readonly handle?: string;
974
+ }, options?: {
975
+ readonly signal?: AbortSignal;
976
+ }): Promise<CapxulResult<Payee>>;
977
+ get(payeeId: string, options?: {
978
+ readonly signal?: AbortSignal;
979
+ }): Promise<CapxulResult<Payee | null>>;
980
+ resolve(recipient: string, options?: {
981
+ readonly signal?: AbortSignal;
982
+ }): Promise<CapxulResult<RecipientResolution>>;
983
+ }
984
+ interface PaymentMoney {
985
+ readonly currency: string;
986
+ readonly value: string;
987
+ readonly decimals: number;
988
+ }
989
+ type PaymentStatus = "pending" | "submitted" | "pending_claim" | "scheduled" | "streaming" | "settled" | "cancelled" | "redirected" | "expired" | "failed";
990
+ type PaymentType = "unspecified" | "invoice" | "payroll" | "reimbursement";
991
+ interface PaymentDocumentRef {
992
+ readonly documentHash: string;
993
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
994
+ readonly title?: string;
995
+ readonly uri?: string;
996
+ readonly issuedAt?: number;
997
+ }
998
+ type PaymentRelease = {
999
+ readonly kind: "instant";
1000
+ } | {
1001
+ readonly kind: "scheduled";
1002
+ readonly at: number;
1003
+ } | {
1004
+ readonly kind: "stream";
1005
+ readonly startsAt: number;
1006
+ readonly endsAt: number;
1007
+ readonly cliffAt?: number;
1008
+ };
1009
+ interface Payment {
1010
+ readonly id: string;
1011
+ readonly status: PaymentStatus;
1012
+ readonly amount: PaymentMoney;
1013
+ readonly paymentType: PaymentType;
1014
+ readonly recipient: {
1015
+ readonly kind: "handle" | "email" | "payee" | "me" | "org" | "external_address";
1016
+ readonly label: string;
1017
+ readonly payeeId?: string;
1018
+ };
1019
+ readonly documents: readonly PaymentDocumentRef[];
1020
+ readonly release: PaymentRelease;
1021
+ readonly released: PaymentMoney;
1022
+ readonly availableToClaim: PaymentMoney;
1023
+ readonly createdAt: number;
1024
+ readonly updatedAt: number;
1025
+ }
1026
+ interface PaymentsPayInput {
1027
+ readonly to: string;
1028
+ readonly amount: PaymentMoney;
1029
+ /** Full EIP-712 document envelope; hashed + stored, committed on-chain. */
1030
+ readonly document?: PaymentDocumentEnvelopeV1;
1031
+ /**
1032
+ * Release clause (G3 · #546). Omitted ⇒ `instant` (the G2 direct-send path).
1033
+ * A `scheduled`/`stream` clause turns the payment into a Commitment
1034
+ * (escrow-vest-claim) backed by `CapxulPayments.createCommitment`.
1035
+ */
1036
+ readonly release?: PaymentRelease;
1037
+ /**
1038
+ * #592: itemized line items backing an Invoice `document`. The backend asserts
1039
+ * `hashLineItems(lineItems) === document.lineItemsHash` AND `Σ(quantity ×
1040
+ * unitMinor) === document.amount`, then persists the list for itemized render.
1041
+ */
1042
+ readonly lineItems?: readonly LineItemV1[];
1043
+ }
1044
+ /**
1045
+ * B3 withdraw / cash-out input. Stripe-shaped: `to` is the EXTERNAL 0x wallet
1046
+ * (the ONE place the SDK accepts a raw address — the pay lane never does),
1047
+ * `amount` is a Money, `document` is the REQUIRED kind:4 Withdrawal envelope
1048
+ * (carries the audit-visible destAddress). No chain / Safe / token / hash
1049
+ * custody substrate on the input. Returns a leak-safe `Payment` whose recipient
1050
+ * label is the redacted address — never the full 0x.
1051
+ */
1052
+ interface PaymentsWithdrawInput {
1053
+ readonly to: string;
1054
+ readonly amount: PaymentMoney;
1055
+ readonly document: PaymentDocumentEnvelopeV1;
1056
+ }
1057
+ interface PaymentSettlementInput {
1058
+ readonly paymentId: string;
1059
+ readonly evidence: OnchainEvidence;
1060
+ }
1061
+ /**
1062
+ * Host-execution callback recording the on-chain escrow of a commitment
1063
+ * (G3 · #546): `createCommitment` returned `onchainCommitmentId`, escrowing
1064
+ * the total. `onchainCommitmentId` + the userOp/tx hashes are internal evidence,
1065
+ * never on the wire (internal channel only).
1066
+ */
1067
+ interface CommitmentCreatedInput {
1068
+ readonly paymentId: string;
1069
+ readonly onchainCommitmentId: string;
1070
+ readonly evidence: OnchainEvidence;
1071
+ }
1072
+ /** Host-execution callback recording a recipient-side `claim` (G3 · #546). */
1073
+ interface CommitmentClaimInput {
1074
+ readonly paymentId: string;
1075
+ readonly evidence: OnchainEvidence;
1076
+ }
1077
+ /**
1078
+ * Host-execution callback recording a creator-side `cancel` (G3 · #546):
1079
+ * on-chain the unvested remainder returns to the creator; vested-unclaimed
1080
+ * stays the recipient's. An optional credit-note document is appended.
1081
+ */
1082
+ interface CommitmentCancelInput {
1083
+ readonly paymentId: string;
1084
+ readonly evidence: OnchainEvidence;
1085
+ readonly document?: PaymentDocumentEnvelopeV1;
1086
+ }
1087
+ /**
1088
+ * Host-execution callback recording a pre-claim `redirect` to a new validated
1089
+ * recipient (G3 · #546). `to` is a validated recipient (handle/email/payee id),
1090
+ * never a raw address.
1091
+ */
1092
+ interface CommitmentRedirectInput {
1093
+ readonly paymentId: string;
1094
+ readonly to: string;
1095
+ readonly evidence: OnchainEvidence;
1096
+ readonly document?: PaymentDocumentEnvelopeV1;
1097
+ }
1098
+ /**
1099
+ * Host-execution callback recording a settled ORG spend/payroll on the ONE
1100
+ * `payments` ledger (D3 · #565). An org spend is a KIND of Payment — it lands a
1101
+ * real `payments` row with `source:"org"` + `orgId` (no parallel `orgSpends`
1102
+ * table, no synthetic client-side fabrication). The signer-side host calls this
1103
+ * AFTER the on-chain Roles-modifier spend settles; `evidence` carries the
1104
+ * internal userOp/tx hashes (never wire fields). `recipient` is the validated
1105
+ * recipient ref label; `recipientSafeAddress` is internal evidence on the row.
1106
+ */
1107
+ interface OrgPaymentRecordInput {
1108
+ readonly orgId: string;
1109
+ readonly recipientLabel: string;
1110
+ readonly recipientSafeAddress: string;
1111
+ readonly amount: PaymentMoney;
1112
+ readonly paymentType: PaymentType;
1113
+ readonly document?: PaymentDocumentEnvelopeV1;
1114
+ /** The org Safe the spend debited — bound as the `from` of the settlement transfer. */
1115
+ readonly orgSafeAddress: string;
1116
+ /**
1117
+ * 0-based occurrence among batch runs with the same (recipient, amount), so
1118
+ * each run binds to + de-dupes on its own on-chain `Transfer` (D3 · #565).
1119
+ */
1120
+ readonly occurrenceIndex: number;
1121
+ readonly evidence: OnchainEvidence;
1122
+ }
1123
+ interface PaymentDocumentVerification {
1124
+ readonly documentHash: string;
1125
+ readonly ok: boolean;
1126
+ readonly derivedHash: string;
1127
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
1128
+ }
1129
+ /**
1130
+ * #577 render-on-demand result. `html` is self-contained user-visible document
1131
+ * HTML (stylesheet + rendered document). The MCP `paymentDocuments.render` tool
1132
+ * exposes only `{documentHash, kind, ok}` to the model and returns `html` in an
1133
+ * audience:["user"] content block (#506 redaction matrix).
1134
+ */
1135
+ interface PaymentDocumentRender {
1136
+ readonly documentHash: string;
1137
+ readonly ok: boolean;
1138
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
1139
+ readonly html: string;
1140
+ }
1141
+ /**
1142
+ * Internal commitment execution reference (G3 · #546). The on-chain
1143
+ * `onchainCommitmentId` is internal evidence (like userOp/tx hashes) — it never
1144
+ * appears on the wire `Payment` or any MCP tool output, but the signer-side host
1145
+ * needs it to build a claim/cancel/redirect UserOp. This is the server-internal
1146
+ * channel that carries it (and the recipient Safe address for an auto-claim
1147
+ * relayer), never a consumer-facing surface.
1148
+ */
1149
+ interface PaymentCommitmentRef {
1150
+ readonly paymentId: string;
1151
+ readonly onchainCommitmentId: string | null;
1152
+ readonly status: PaymentStatus;
1153
+ }
1154
+ /**
1155
+ * The host-execution + on-chain-evidence channel for Payments (D2 · #564).
1156
+ * SPLIT OFF the public `PaymentsMethods` so an external builder consuming
1157
+ * `@capxul/sdk` directly never sees the custody substrate. Reached only via
1158
+ * `client.payments._internal` (mirrors `client._internal.*`); the signer-side
1159
+ * host (the dev MCP edge / a self-custody integrator) drives it AFTER executing
1160
+ * a UserOp. Every input carries the `OnchainEvidence` brand — never a wire field.
1161
+ */
1162
+ interface PaymentsInternalMethods {
1163
+ /** Report on-chain settlement evidence for an instant payment. */
1164
+ markSettled(input: PaymentSettlementInput, options?: {
1165
+ readonly signal?: AbortSignal;
1166
+ }): Promise<CapxulResult<Payment>>;
1167
+ /**
1168
+ * B3: report on-chain settlement evidence for a withdraw/cash-out. The
1169
+ * backend binds the userOp to a matching external `Transfer` before settling.
1170
+ */
1171
+ markWithdrawalSettled(input: PaymentSettlementInput, options?: {
1172
+ readonly signal?: AbortSignal;
1173
+ }): Promise<CapxulResult<Payment>>;
1174
+ /**
1175
+ * Record the on-chain escrow of a commitment after `createCommitment` returns
1176
+ * its `onchainCommitmentId` (G3 · #546).
1177
+ */
1178
+ markCommitmentCreated(input: CommitmentCreatedInput, options?: {
1179
+ readonly signal?: AbortSignal;
1180
+ }): Promise<CapxulResult<Payment>>;
1181
+ /**
1182
+ * Record a settled ORG spend/payroll on the one `payments` ledger
1183
+ * (D3 · #565) — `source:"org"` + `orgId`, read back as a leak-safe Payment.
1184
+ */
1185
+ recordOrgPayment(input: OrgPaymentRecordInput, options?: {
1186
+ readonly signal?: AbortSignal;
1187
+ }): Promise<CapxulResult<Payment>>;
1188
+ /** Record a recipient-side `claim` after the on-chain claim UserOp settles. */
1189
+ claim(input: CommitmentClaimInput, options?: {
1190
+ readonly signal?: AbortSignal;
1191
+ }): Promise<CapxulResult<Payment>>;
1192
+ /** Record a creator-side `cancel` reclaiming only the unvested remainder. */
1193
+ cancel(input: CommitmentCancelInput, options?: {
1194
+ readonly signal?: AbortSignal;
1195
+ }): Promise<CapxulResult<Payment>>;
1196
+ /** Record a pre-claim `redirect` to a new validated recipient. */
1197
+ redirect(input: CommitmentRedirectInput, options?: {
1198
+ readonly signal?: AbortSignal;
1199
+ }): Promise<CapxulResult<Payment>>;
1200
+ /**
1201
+ * The on-chain commitment reference the signer-side host needs to build a
1202
+ * claim/cancel/redirect UserOp. `onchainCommitmentId` is internal evidence.
1203
+ */
1204
+ commitmentRef(paymentId: string, options?: {
1205
+ readonly signal?: AbortSignal;
1206
+ }): Promise<CapxulResult<PaymentCommitmentRef | null>>;
1207
+ }
1208
+ /**
1209
+ * The PUBLIC, Stripe-shaped Payments surface (D2 · #564). Genus verbs only —
1210
+ * `pay` / `list` / `get`. No `userOpHash` / `txHash` / `onchainCommitmentId` /
1211
+ * `chainId` / `safeAddress`. Host-execution + on-chain evidence live on the
1212
+ * `_internal` channel below; an external builder never touches custody substrate.
1213
+ */
1214
+ interface PaymentsMethods {
1215
+ pay(input: PaymentsPayInput, options?: {
1216
+ readonly signal?: AbortSignal;
1217
+ }): Promise<CapxulResult<Payment>>;
1218
+ /**
1219
+ * B3 withdraw / cash-out: send USDX from the user's custody Safe to an
1220
+ * external 0x wallet, minting a kind:4 Withdrawal document. Returns a
1221
+ * leak-safe `Payment` (recipient label is the redacted address).
1222
+ */
1223
+ withdraw(input: PaymentsWithdrawInput, options?: {
1224
+ readonly signal?: AbortSignal;
1225
+ }): Promise<CapxulResult<Payment>>;
1226
+ list(options?: {
1227
+ readonly signal?: AbortSignal;
1228
+ }): Promise<CapxulResult<readonly Payment[]>>;
1229
+ get(paymentId: string, options?: {
1230
+ readonly signal?: AbortSignal;
1231
+ }): Promise<CapxulResult<Payment | null>>;
1232
+ /**
1233
+ * Host-execution + on-chain-evidence channel — off the public surface
1234
+ * (production-surface-policy.md pattern). Self-custody integrators drive this;
1235
+ * a Stripe-shaped consumer never does.
1236
+ *
1237
+ * @internal-use
1238
+ */
1239
+ readonly _internal: PaymentsInternalMethods;
1240
+ }
1241
+ interface PaymentDocumentsMethods {
1242
+ verify(documentHash: string, options?: {
1243
+ readonly signal?: AbortSignal;
1244
+ }): Promise<CapxulResult<PaymentDocumentVerification>>;
1245
+ /**
1246
+ * #577: render-on-demand. Loads the owner's stored document by `documentHash`,
1247
+ * re-verifies its EIP-712 hash, and renders it to self-contained HTML using the
1248
+ * verified stored line items. Returns `{documentHash, kind, ok, html}`.
1249
+ */
1250
+ render(documentHash: string, options?: {
1251
+ readonly signal?: AbortSignal;
1252
+ }): Promise<CapxulResult<PaymentDocumentRender>>;
1253
+ }
1254
+ type PaymentRequestStatus = "draft" | "sent" | "viewed" | "paid" | "expired" | "cancelled";
1255
+ interface PaymentRequest {
1256
+ readonly id: string;
1257
+ readonly status: PaymentRequestStatus;
1258
+ readonly amount: PaymentMoney;
1259
+ readonly reference: string;
1260
+ readonly memo: string | null;
1261
+ /** Fixed-amount payment link token (HITL #519: basic, not replay-hardened). */
1262
+ readonly linkToken: string;
1263
+ /** Minimal entitlement (HITL #501): true once paid. */
1264
+ readonly entitlementGranted: boolean;
1265
+ /** The Payment this receivable settled into (set on collect). */
1266
+ readonly settledPaymentId: string | null;
1267
+ /** The receipt document committed for this receivable (set on collect). */
1268
+ readonly receiptDocumentHash: string | null;
1269
+ readonly expiresAt: number | null;
1270
+ readonly createdAt: number;
1271
+ readonly updatedAt: number;
1272
+ }
1273
+ interface ReconciliationEntry {
1274
+ readonly paymentRequestId: string;
1275
+ readonly reference: string;
1276
+ readonly status: "paid" | "exception";
1277
+ readonly settledPaymentId: string | null;
1278
+ readonly receiptDocumentHash: string | null;
1279
+ }
1280
+ interface PaymentRequestsCreateInput {
1281
+ readonly amount: PaymentMoney;
1282
+ readonly reference: string;
1283
+ readonly memo?: string;
1284
+ /** Optional expiry (epoch ms). HITL #519: expiry policy is a basic timestamp. */
1285
+ readonly expiresAt?: number;
1286
+ }
1287
+ interface PaymentRequestsMethods {
1288
+ /** Open a receivable in `draft` with a fixed-amount payment link. */
1289
+ create(input: PaymentRequestsCreateInput, options?: {
1290
+ readonly signal?: AbortSignal;
1291
+ }): Promise<CapxulResult<PaymentRequest>>;
1292
+ markSent(paymentRequestId: string, options?: {
1293
+ readonly signal?: AbortSignal;
1294
+ }): Promise<CapxulResult<PaymentRequest>>;
1295
+ markViewed(paymentRequestId: string, options?: {
1296
+ readonly signal?: AbortSignal;
1297
+ }): Promise<CapxulResult<PaymentRequest>>;
1298
+ cancel(paymentRequestId: string, options?: {
1299
+ readonly signal?: AbortSignal;
1300
+ }): Promise<CapxulResult<PaymentRequest>>;
1301
+ /**
1302
+ * Collect the receivable (HERMETIC until a live inbound path exists): settle
1303
+ * it into the Payment ledger and mint a receipt linked by `documentHash`.
1304
+ */
1305
+ collect(paymentRequestId: string, options?: {
1306
+ readonly signal?: AbortSignal;
1307
+ }): Promise<CapxulResult<PaymentRequest>>;
1308
+ list(options?: {
1309
+ readonly signal?: AbortSignal;
1310
+ }): Promise<CapxulResult<readonly PaymentRequest[]>>;
1311
+ get(paymentRequestId: string, options?: {
1312
+ readonly signal?: AbortSignal;
1313
+ }): Promise<CapxulResult<PaymentRequest | null>>;
1314
+ getByLink(linkToken: string, options?: {
1315
+ readonly signal?: AbortSignal;
1316
+ }): Promise<CapxulResult<PaymentRequest | null>>;
1317
+ /** Inbound reconciliation: paid / exception status per receivable. */
1318
+ reconcile(options?: {
1319
+ readonly signal?: AbortSignal;
1320
+ }): Promise<CapxulResult<readonly ReconciliationEntry[]>>;
1321
+ }
1322
+ type PaymentDraftStatus = "draft" | "simulated" | "approval_pending" | "approved" | "executed" | "cancelled" | "expired";
1323
+ /** The leak-safe, model-visible draft/approval (#506). */
1324
+ interface PaymentDraft {
1325
+ readonly id: string;
1326
+ readonly status: PaymentDraftStatus;
1327
+ readonly recipient: {
1328
+ readonly kind: string;
1329
+ readonly label: string;
1330
+ };
1331
+ readonly amount: PaymentMoney;
1332
+ readonly documentHash: string | null;
1333
+ /** The canonical-plan binding fingerprint (set at approvals.request). */
1334
+ readonly planHash: string | null;
1335
+ /** The opaque read-model version the draft was simulated against (stale-state). */
1336
+ readonly readModelVersion: string;
1337
+ readonly idempotencyKey: string;
1338
+ readonly policyDecision: "allow" | "deny";
1339
+ readonly expiresAt: number | null;
1340
+ readonly settledPaymentId: string | null;
1341
+ readonly createdAt: number;
1342
+ readonly updatedAt: number;
1343
+ }
1344
+ interface WorkbenchDraftInput {
1345
+ readonly clientId: string;
1346
+ readonly audience: string;
1347
+ readonly scopes: readonly string[];
1348
+ readonly to: string;
1349
+ readonly amount: PaymentMoney;
1350
+ readonly document?: PaymentDocumentEnvelopeV1;
1351
+ readonly idempotencyKey: string;
1352
+ /** Untrusted connector/model suggestion blob (default-deny taint). */
1353
+ readonly tainted?: Record<string, unknown>;
1354
+ }
1355
+ interface WorkbenchMintResult {
1356
+ readonly approvalToken: string;
1357
+ readonly planHash: string;
1358
+ readonly expiresAt: number;
1359
+ }
1360
+ interface WorkbenchExecuteInput {
1361
+ readonly draftId: string;
1362
+ readonly clientId: string;
1363
+ readonly approvalToken: string;
1364
+ readonly readModelVersion: string;
1365
+ readonly userOpHash: string;
1366
+ readonly txHash: string;
1367
+ }
1368
+ /**
1369
+ * The decomposed workbench (G6 · #549). The edge PROPOSES (draft → simulate →
1370
+ * request); the BACKEND mints the one-time plan-bound token via the human's
1371
+ * browser (`mint`); `execute` consumes it. `mint` is the human step — the edge
1372
+ * normally only reaches `request`, then hands the human a browser URL.
1373
+ */
1374
+ interface WorkbenchMethods {
1375
+ draft(input: WorkbenchDraftInput, options?: {
1376
+ readonly signal?: AbortSignal;
1377
+ }): Promise<CapxulResult<PaymentDraft>>;
1378
+ simulate(draftId: string, options?: {
1379
+ readonly signal?: AbortSignal;
1380
+ }): Promise<CapxulResult<PaymentDraft>>;
1381
+ requestApproval(draftId: string, options?: {
1382
+ readonly signal?: AbortSignal;
1383
+ }): Promise<CapxulResult<PaymentDraft>>;
1384
+ /**
1385
+ * THE HUMAN STEP: mint the one-time approval token (browser/approval app).
1386
+ * F2 (#549): the backend gates minting on a human-origin `capability` the
1387
+ * agent/edge does NOT possess (`CAPXUL_APPROVAL_CAPABILITY`); only the
1388
+ * apps/approve browser app passes it. The edge/SDK lane cannot self-approve.
1389
+ */
1390
+ mint(draftId: string, capability: string, options?: {
1391
+ readonly signal?: AbortSignal;
1392
+ }): Promise<CapxulResult<WorkbenchMintResult>>;
1393
+ execute(input: WorkbenchExecuteInput, options?: {
1394
+ readonly signal?: AbortSignal;
1395
+ }): Promise<CapxulResult<Payment>>;
1396
+ status(draftId: string, options?: {
1397
+ readonly signal?: AbortSignal;
1398
+ }): Promise<CapxulResult<PaymentDraft | null>>;
1399
+ cancel(draftId: string, options?: {
1400
+ readonly signal?: AbortSignal;
1401
+ }): Promise<CapxulResult<PaymentDraft>>;
1402
+ }
1403
+ interface FinancialOpsMethods {
1404
+ readonly me: MeMethods;
1405
+ readonly handles: HandlesMethods;
1406
+ readonly payees: PayeesMethods;
1407
+ readonly payments: PaymentsMethods;
1408
+ readonly paymentDocuments: PaymentDocumentsMethods;
1409
+ /** Receivables surface (G5 · #548). */
1410
+ readonly paymentRequests: PaymentRequestsMethods;
1411
+ /** Decomposed workbench + trust substrate (G6 · #549). */
1412
+ readonly workbench: WorkbenchMethods;
1413
+ }
1414
+ //#endregion
851
1415
  //#region src/client/sub-accounts.d.ts
852
1416
  interface SubAccountsMethods {
853
1417
  create(accountId: AccountId, input: {
854
1418
  readonly name: string;
855
1419
  }, options?: {
856
1420
  readonly signal?: AbortSignal;
857
- }): Promise<CapxulResult<SubAccount$1>>;
858
- get(subAccountId: SubAccountId$1, options?: {
1421
+ }): Promise<CapxulResult<SubAccount>>;
1422
+ get(subAccountId: SubAccountId, options?: {
859
1423
  readonly signal?: AbortSignal;
860
- }): Promise<CapxulResult<SubAccount$1 | null>>;
1424
+ }): Promise<CapxulResult<SubAccount | null>>;
861
1425
  list(accountId: AccountId, options?: {
862
1426
  readonly signal?: AbortSignal;
863
- }): Promise<CapxulResult<readonly SubAccount$1[]>>;
864
- rename(subAccountId: SubAccountId$1, name: string, options?: {
1427
+ }): Promise<CapxulResult<readonly SubAccount[]>>;
1428
+ rename(subAccountId: SubAccountId, name: string, options?: {
865
1429
  readonly signal?: AbortSignal;
866
- }): Promise<CapxulResult<SubAccount$1>>;
867
- delete(subAccountId: SubAccountId$1, options?: {
1430
+ }): Promise<CapxulResult<SubAccount>>;
1431
+ delete(subAccountId: SubAccountId, options?: {
868
1432
  readonly signal?: AbortSignal;
869
1433
  }): Promise<CapxulResult<void>>;
870
1434
  transfer(input: TransferInput, options?: {
@@ -873,49 +1437,68 @@ interface SubAccountsMethods {
873
1437
  }
874
1438
  //#endregion
875
1439
  //#region src/client/org-spend-gate.d.ts
876
- type SpendGateRecipients = "anyone" | readonly Address$1[];
1440
+ /**
1441
+ * The role's allowed recipients. The address form backs the S4 `spend` path
1442
+ * (recipient is a resolved `Address`); the string form backs the G4
1443
+ * `spendViaPayments` / `batchPayroll` path, whose recipient is a VALIDATED REF
1444
+ * (handle/email/payee/org) compared in the same ref space as the role's set.
1445
+ * Comparison is case-insensitive over the raw string value either way.
1446
+ */
1447
+ type SpendGateRecipients = "anyone" | readonly (Address | string)[];
877
1448
  type SpendGateSubAccountScope = {
878
1449
  readonly scope: "all";
879
1450
  } | {
880
1451
  readonly scope: "only";
881
- readonly subAccountIds: readonly SubAccountId$1[];
1452
+ readonly subAccountIds: readonly SubAccountId[];
882
1453
  };
883
1454
  //#endregion
884
1455
  //#region src/ports/org.d.ts
1456
+ /**
1457
+ * The minimal `{from, to, amount}` spend shape the authority read keys off
1458
+ * (D3 #565). The legacy address-keyed `OrgSpendInput`/`org.spend` lane was
1459
+ * hard-removed when `orgSpends` folded into the one `payments` ledger; the
1460
+ * leak-safe ref-based lane (`spendViaPayments`/`batchPayroll`) constructs this
1461
+ * internally and enforces the real validated recipient on the gate.
1462
+ */
1463
+ type OrgSpendShape = {
1464
+ readonly from: SubAccountId;
1465
+ readonly to: Address;
1466
+ readonly amount: Money;
1467
+ };
885
1468
  type CreateOrgPortInput = {
886
1469
  readonly input: CreateOrgInput;
887
1470
  };
888
1471
  type ReadOrgTreasuryInput = {
889
- readonly orgId: OrgId$1;
1472
+ readonly orgId: OrgId;
890
1473
  };
891
1474
  type ListOrgsInput = Record<never, never>;
892
1475
  type ListOrgRolesInput = {
893
- readonly orgId: OrgId$1;
1476
+ readonly orgId: OrgId;
894
1477
  };
895
1478
  type ListOrgMembersInput = {
896
- readonly orgId: OrgId$1;
1479
+ readonly orgId: OrgId;
897
1480
  };
898
1481
  type InviteOrgMemberInput = {
899
- readonly orgId: OrgId$1;
1482
+ readonly orgId: OrgId;
900
1483
  readonly input: InviteMemberInput;
901
1484
  };
902
1485
  type DetectPendingOrgInvitationsInput = Record<never, never>;
903
1486
  type DetectPendingOrgInvitationsResult$1 = {
904
- readonly matched: readonly OrgId$1[];
1487
+ readonly matched: readonly OrgId[];
905
1488
  };
906
1489
  type DeployOrgRolesInput = {
907
- readonly orgId: OrgId$1;
1490
+ readonly orgId: OrgId;
908
1491
  };
909
1492
  type OrgRolesDeploymentResult = {
910
- readonly orgId: OrgId$1;
1493
+ readonly orgId: OrgId;
911
1494
  readonly roles: readonly RoleView[];
912
1495
  };
913
1496
  type GrantOrgRoleInput = {
914
- readonly orgId: OrgId$1;
1497
+ readonly orgId: OrgId;
915
1498
  readonly input: AssignRoleInput;
916
1499
  };
917
1500
  type RevokeOrgRoleInput = {
918
- readonly orgId: OrgId$1;
1501
+ readonly orgId: OrgId;
919
1502
  readonly input: RemoveMemberInput;
920
1503
  };
921
1504
  type OrgSpendAuthority = {
@@ -929,15 +1512,9 @@ type OrgSpendAuthority = {
929
1512
  readonly role?: string;
930
1513
  };
931
1514
  type ReadOrgSpendAuthorityInput = {
932
- readonly orgId: OrgId$1;
933
- readonly input: OrgSpendInput;
934
- readonly amountRaw: string;
935
- };
936
- type SubmitOrgSpendInput = {
937
- readonly orgId: OrgId$1;
938
- readonly input: OrgSpendInput;
1515
+ readonly orgId: OrgId;
1516
+ readonly input: OrgSpendShape;
939
1517
  readonly amountRaw: string;
940
- readonly authority: OrgSpendAuthority;
941
1518
  };
942
1519
  declare const OrgError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => import("effect/Cause").YieldableError & {
943
1520
  readonly _tag: "OrgError";
@@ -957,7 +1534,7 @@ declare class OrgError extends OrgError_base<{
957
1534
  */
958
1535
  interface OrgPort {
959
1536
  createOrg(input: CreateOrgPortInput): Effect.Effect<OrgView, OrgError, never>;
960
- readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account$1, OrgError, never>;
1537
+ readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account, OrgError, never>;
961
1538
  listOrgs(input: ListOrgsInput): Effect.Effect<readonly OrgView[], OrgError, never>;
962
1539
  listRoles(input: ListOrgRolesInput): Effect.Effect<readonly RoleView[], OrgError, never>;
963
1540
  listMembers(input: ListOrgMembersInput): Effect.Effect<readonly MemberView[], OrgError, never>;
@@ -969,9 +1546,34 @@ interface OrgRolesDeploymentPort {
969
1546
  grantRole(input: GrantOrgRoleInput): Effect.Effect<MemberView, OrgError, never>;
970
1547
  revokeRole(input: RevokeOrgRoleInput): Effect.Effect<void, OrgError, never>;
971
1548
  }
1549
+ type SubmitOrgSpendViaPaymentsInput = {
1550
+ readonly orgId: OrgId;
1551
+ readonly input: OrgSpendViaPaymentsInput;
1552
+ readonly amountRaw: string;
1553
+ readonly authority: OrgSpendAuthority;
1554
+ };
1555
+ type SubmitOrgBatchPayrollInput = {
1556
+ readonly orgId: OrgId;
1557
+ readonly from: OrgSpendViaPaymentsInput["from"];
1558
+ readonly runs: readonly {
1559
+ readonly run: OrgPayrollRun;
1560
+ readonly amountRaw: string;
1561
+ }[];
1562
+ readonly authorities: readonly OrgSpendAuthority[];
1563
+ };
972
1564
  interface OrgSpendPort {
973
1565
  readSpendAuthority(input: ReadOrgSpendAuthorityInput): Effect.Effect<OrgSpendAuthority, OrgError, never>;
974
- submitSpend(input: SubmitOrgSpendInput): Effect.Effect<OrgSpendResult, OrgError, never>;
1566
+ /**
1567
+ * Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
1568
+ * the spend through the payments engine (Roles modifier → CapxulPayments),
1569
+ * write a real `payments` row (`source:"org"`) and read it back as a `Payment`
1570
+ * — the wire carries no `txHash` / Safe / userOp internals. Optional so a
1571
+ * hermetic adapter without a payments-submit lane still compiles; absent ⇒ the
1572
+ * program falls back to a deterministic hermetic `Payment`.
1573
+ */
1574
+ submitSpendViaPayments?(input: SubmitOrgSpendViaPaymentsInput): Effect.Effect<Payment, OrgError, never>;
1575
+ /** Leak-safe org payroll batch (G4 · #547): one MultiSend, one Payment per run. */
1576
+ submitBatchPayroll?(input: SubmitOrgBatchPayrollInput): Effect.Effect<readonly Payment[], OrgError, never>;
975
1577
  }
976
1578
  //#endregion
977
1579
  //#region src/client/org.d.ts
@@ -991,12 +1593,12 @@ type MemberStatus = "pending" | "pending_safe" | "pending_grant" | "active" | "r
991
1593
  * brand.
992
1594
  */
993
1595
  type OrgView = {
994
- readonly id: OrgId$1;
1596
+ readonly id: OrgId;
995
1597
  readonly name: string;
996
1598
  readonly handle: string;
997
- readonly safeAddress: Address$1; /** The viewing member's own role label within this org. */
1599
+ readonly safeAddress: Address; /** The viewing member's own role label within this org. */
998
1600
  readonly role: string; /** The Org treasury — the real M2 Account over the Org Safe (D3). */
999
- readonly treasury: Account$1;
1601
+ readonly treasury: Account;
1000
1602
  };
1001
1603
  /**
1002
1604
  * One member of an Org (canon §C1 "Members" — name/email, role, status; D7/D8).
@@ -1005,12 +1607,12 @@ type OrgView = {
1005
1607
  * yet provisioned a personal Safe). `email` is the universal entry point (D8).
1006
1608
  */
1007
1609
  type MemberView = {
1008
- readonly orgId: OrgId$1;
1610
+ readonly orgId: OrgId;
1009
1611
  readonly email: Email;
1010
1612
  readonly name: string | null; /** Member-identity key (D7). `null` until the invitee provisions a Safe. */
1011
- readonly personalSafeAddress: Address$1 | null; /** The member's role label (maps deterministically to the on-chain `roleKey`, D9). */
1613
+ readonly personalSafeAddress: Address | null; /** The member's role label (maps deterministically to the on-chain `roleKey`, D9). */
1012
1614
  readonly role: string;
1013
- readonly roleKey: RoleKey$1 | null;
1615
+ readonly roleKey: RoleKey | null;
1014
1616
  readonly status: MemberStatus;
1015
1617
  readonly grantTxHash: string | null;
1016
1618
  readonly revokeTxHash: string | null;
@@ -1022,9 +1624,9 @@ type MemberView = {
1022
1624
  * (the Owner role).
1023
1625
  */
1024
1626
  type RoleSpendCap = {
1025
- readonly perTx?: Money$1;
1026
- readonly perDay?: Money$1;
1027
- readonly toRecipients?: "anyone" | readonly Address$1[];
1627
+ readonly perTx?: Money;
1628
+ readonly perDay?: Money;
1629
+ readonly toRecipients?: "anyone" | readonly Address[];
1028
1630
  };
1029
1631
  /**
1030
1632
  * The Capxul-owned Role DSL definition (D4). `label` becomes the sticky
@@ -1036,7 +1638,7 @@ type RoleDefinition = {
1036
1638
  readonly label: string;
1037
1639
  readonly spend?: RoleSpendCap;
1038
1640
  readonly subAccounts?: {
1039
- readonly scope: "all" | readonly SubAccountId$1[];
1641
+ readonly scope: "all" | readonly SubAccountId[];
1040
1642
  };
1041
1643
  readonly canManageMembers?: boolean;
1042
1644
  readonly canManageRoles?: boolean;
@@ -1047,9 +1649,9 @@ type RoleDefinition = {
1047
1649
  * is the full Role DSL entry.
1048
1650
  */
1049
1651
  type RoleView = {
1050
- readonly orgId: OrgId$1;
1652
+ readonly orgId: OrgId;
1051
1653
  readonly label: string;
1052
- readonly roleKey: RoleKey$1;
1654
+ readonly roleKey: RoleKey;
1053
1655
  readonly definition: RoleDefinition;
1054
1656
  };
1055
1657
  /** Built-in role templates that seed a new Org at creation (D6). */
@@ -1084,7 +1686,7 @@ type InviteMemberInput = {
1084
1686
  * mirror.
1085
1687
  */
1086
1688
  type RemoveMemberInput = {
1087
- readonly memberSafeAddress: Address$1;
1689
+ readonly memberSafeAddress: Address;
1088
1690
  };
1089
1691
  /**
1090
1692
  * Input to `org(orgId).assignRole` (S3, D7/D9). Keyed on the member's personal
@@ -1092,26 +1694,48 @@ type RemoveMemberInput = {
1092
1694
  * label maps deterministically to the on-chain `roleKey`.
1093
1695
  */
1094
1696
  type AssignRoleInput = {
1095
- readonly memberSafeAddress: Address$1;
1697
+ readonly memberSafeAddress: Address;
1096
1698
  readonly role: string;
1097
1699
  };
1098
1700
  /**
1099
- * Input to `org(orgId).spend` (S4, capstone, D5). A member spends `amount` from
1100
- * a scoped sub-account `from` to `to`, gated Level 1 (Zodiac cap) + Level 2
1101
- * (envelope scope/balance). One UserOp: signer personal Safe Org Roles
1102
- * modifier `CapxulPayments.send`.
1701
+ * Input to `org(orgId).spendViaPayments` (G4 · #547). The LEAK-SAFE org spend:
1702
+ * delegates `org.spend` to the payments engine WITH the member's org role
1703
+ * authority and returns a `Payment`, not a `txHash`. `to` is a VALIDATED
1704
+ * recipient ref (handle / email / payee id / org handle) — never a raw
1705
+ * `Address` (the legacy address-keyed `org.spend` lane was hard-removed in D3
1706
+ * #565 when `orgSpends` was folded into the one `payments` ledger).
1707
+ * `from` is the Level-2 sub-account envelope the spend draws from (D5).
1103
1708
  */
1104
- type OrgSpendInput = {
1105
- /** The sub-account (envelope) the spend draws from (Level-2 scope, D5). */readonly from: SubAccountId$1;
1106
- readonly to: Address$1;
1107
- readonly amount: Money$1;
1709
+ type OrgSpendViaPaymentsInput = {
1710
+ readonly from: SubAccountId; /** Validated recipient ref (handle/email/payee/org) never a raw address. */
1711
+ readonly to: string;
1712
+ readonly amount: Money; /** Full EIP-712 payment document; hashed + stored, committed on-chain. */
1713
+ readonly document?: PaymentDocumentEnvelopeV1;
1714
+ readonly paymentType?: PaymentType;
1108
1715
  };
1109
- /** Result of a settled Org spend — the settling transaction hash (S4). */
1110
- type OrgSpendResult = {
1111
- readonly txHash: string;
1716
+ /**
1717
+ * One run in an `org(orgId).batchPayroll` batch (G4 · #547): a validated
1718
+ * recipient, an amount, and an optional payslip document. Each run is gated
1719
+ * independently against the role's per-tx / per-day / recipient conditions.
1720
+ */
1721
+ type OrgPayrollRun = {
1722
+ /** Validated recipient ref (handle/email/payee/org) — never a raw address. */readonly to: string;
1723
+ readonly amount: Money; /** The payslip — an EIP-712 payment document, committed by `documentHash`. */
1724
+ readonly payslip?: PaymentDocumentEnvelopeV1;
1725
+ };
1726
+ /**
1727
+ * Input to `org(orgId).batchPayroll` (G4 · #547). Pays N employees in one
1728
+ * MultiSend through the Roles modifier; each carries a payslip and settles as
1729
+ * `paymentType = payroll`. Every run is gated; an over-cap run REJECTS the
1730
+ * whole batch (no partial treasury drain). Returns one leak-safe `Payment` per
1731
+ * run.
1732
+ */
1733
+ type OrgBatchPayrollInput = {
1734
+ readonly from: SubAccountId;
1735
+ readonly runs: readonly OrgPayrollRun[];
1112
1736
  };
1113
1737
  type DetectPendingOrgInvitationsResult = {
1114
- readonly matched: readonly OrgId$1[];
1738
+ readonly matched: readonly OrgId[];
1115
1739
  };
1116
1740
  /**
1117
1741
  * Entity-scoped Org method bundle, returned by `capxul.org(orgId)`. Every
@@ -1123,7 +1747,7 @@ interface OrgScopedMethods {
1123
1747
  /** The Org treasury — the real M2 Account over the Org Safe (D3). */
1124
1748
  treasury(options?: {
1125
1749
  readonly signal?: AbortSignal;
1126
- }): Promise<CapxulResult<Account$1>>;
1750
+ }): Promise<CapxulResult<Account>>;
1127
1751
  members(options?: {
1128
1752
  readonly signal?: AbortSignal;
1129
1753
  }): Promise<CapxulResult<readonly MemberView[]>>;
@@ -1142,9 +1766,23 @@ interface OrgScopedMethods {
1142
1766
  assignRole(input: AssignRoleInput, options?: {
1143
1767
  readonly signal?: AbortSignal;
1144
1768
  }): Promise<CapxulResult<MemberView>>;
1145
- spend(input: OrgSpendInput, options?: {
1769
+ /**
1770
+ * Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
1771
+ * the spend through the payments engine with the member's org role authority
1772
+ * and return a `Payment` (no `to: Address`, no `txHash`, no Safe / userOp
1773
+ * internals). Writes a real `payments` row (`source:"org"`).
1774
+ */
1775
+ spendViaPayments(input: OrgSpendViaPaymentsInput, options?: {
1776
+ readonly signal?: AbortSignal;
1777
+ }): Promise<CapxulResult<Payment>>;
1778
+ /**
1779
+ * Org payroll batch (G4 · #547): pay N employees in one MultiSend through the
1780
+ * Roles modifier, each with a payslip. Every run is gated; an over-cap run
1781
+ * rejects the whole batch. Returns one leak-safe `Payment` per run.
1782
+ */
1783
+ batchPayroll(input: OrgBatchPayrollInput, options?: {
1146
1784
  readonly signal?: AbortSignal;
1147
- }): Promise<CapxulResult<OrgSpendResult>>;
1785
+ }): Promise<CapxulResult<readonly Payment[]>>;
1148
1786
  }
1149
1787
  type OrgsMethod = {
1150
1788
  (options?: {
@@ -1164,7 +1802,7 @@ interface OrgMethods {
1164
1802
  }): Promise<CapxulResult<OrgView>>;
1165
1803
  readonly orgs: OrgsMethod;
1166
1804
  /** Resolve the entity-scoped bundle for a specific Org (D13). */
1167
- org(orgId: OrgId$1): OrgScopedMethods;
1805
+ org(orgId: OrgId): OrgScopedMethods;
1168
1806
  }
1169
1807
  //#endregion
1170
1808
  //#region src/client/create-capxul-client.d.ts
@@ -1178,13 +1816,37 @@ interface CapxulClient {
1178
1816
  * namespace with `provision` + `deploySafe` lands in sibling #161.
1179
1817
  */
1180
1818
  readonly account: AccountMethods;
1181
- /** Email address binding resolution (#338). */
1182
- readonly binding: BindingMethods;
1183
1819
  /**
1184
1820
  * Consumer-facing logical Account money read (M2 Slice S1a · #265).
1185
1821
  * Returns `{ balance, available }` as `Money` — never wei or token units.
1186
1822
  */
1187
1823
  readonly accounts: AccountsMethods;
1824
+ readonly me: MeMethods;
1825
+ readonly handles: HandlesMethods;
1826
+ readonly payees: PayeesMethods;
1827
+ /**
1828
+ * Direct Payments surface (G2 · #545). `pay` records a validated-recipient
1829
+ * payment; `list`/`get` read the ledger; `markSettled` is the host-execution
1830
+ * callback. The MCP `draft → simulate → approve → execute` workbench is G6.
1831
+ */
1832
+ readonly payments: PaymentsMethods;
1833
+ /** Payment document verification (G2 · #545): re-derive the EIP-712 hash. */
1834
+ readonly paymentDocuments: PaymentDocumentsMethods;
1835
+ /**
1836
+ * Receivables surface (G5 · #548). `create` opens a `PaymentRequest` with a
1837
+ * fixed-amount link; `markSent`/`markViewed`/`cancel` move the funnel;
1838
+ * `collect` settles the receivable into the Payment ledger + mints a receipt
1839
+ * linked by `documentHash`; `list`/`get`/`getByLink`/`reconcile` read it.
1840
+ */
1841
+ readonly paymentRequests: PaymentRequestsMethods;
1842
+ /**
1843
+ * Decomposed workbench + trust substrate (G6 · #549). The MCP
1844
+ * `draft → simulate → approvals.request → execute` workbench: the edge
1845
+ * PROPOSES, the BACKEND mints a one-time plan-bound approval token via the
1846
+ * human's browser (#510), and `execute` consumes it. Taint / idempotency /
1847
+ * stale-state / scope guards are enforced backend-side.
1848
+ */
1849
+ readonly workbench: WorkbenchMethods;
1188
1850
  /** Sub-account lifecycle (M2 Slice S2a · #267). Transfer lands in S2b. */
1189
1851
  readonly subAccounts: SubAccountsMethods;
1190
1852
  /**
@@ -1197,8 +1859,6 @@ interface CapxulClient {
1197
1859
  readonly createOrg: OrgMethods["createOrg"];
1198
1860
  readonly orgs: OrgMethods["orgs"];
1199
1861
  readonly org: OrgMethods["org"];
1200
- /** Resolved bootstrap for this client instance (chain, auth URLs, etc.). */
1201
- readonly bootstrap: BootstrapResolution;
1202
1862
  /**
1203
1863
  * Internal observation namespace. Consumers MUST NOT drive the actor
1204
1864
  * directly — use the method bundles instead.
@@ -1207,17 +1867,23 @@ interface CapxulClient {
1207
1867
  */
1208
1868
  readonly _internal: {
1209
1869
  readonly authActor: AuthFlowObserver;
1870
+ /**
1871
+ * Resolved bootstrap for this client instance (chain, auth URLs, etc.).
1872
+ * Off the public surface per production-surface-policy.md (#31).
1873
+ */
1874
+ readonly bootstrap: BootstrapResolution;
1210
1875
  /**
1211
1876
  * Dev-only faucet bundle (production-surface-policy.md). `fund` lives here,
1212
1877
  * NOT on the public `client.accounts` surface.
1213
1878
  */
1214
- readonly accounts: AccountsFaucetMethods;
1879
+ readonly accounts: AccountsFaucetMethods; /** Telemetry port for error reporting. Used by React hooks to report errors before throwing. */
1880
+ readonly telemetry?: TelemetryPort;
1215
1881
  readonly close?: () => Promise<void>;
1216
1882
  };
1217
1883
  }
1218
1884
  interface CreateCapxulClientInput {
1219
1885
  /**
1220
- * The 12-port `FlowPorts` bundle. The factory narrows this to the
1886
+ * The 13-port `FlowPorts` bundle. The factory narrows this to the
1221
1887
  * 3-port AuthFlow subset (`authClient`, `clock`, `telemetry`) for
1222
1888
  * the flow internally, and uses additional ports (`identity`,
1223
1889
  * `smartAccount`) for the method bundles.
@@ -1281,7 +1947,31 @@ interface CreateCapxulClientInput {
1281
1947
  readonly orgSpendPort?: OrgSpendPort;
1282
1948
  readonly orgDeploymentConfig?: SafeDeploymentConfig;
1283
1949
  }
1284
- declare function assembleCapxulClient(input: CreateCapxulClientInput): CapxulClient;
1950
+ //#endregion
1951
+ //#region src/adapters/auth-cache/BrowserAuthCacheAdapter.d.ts
1952
+ interface BrowserStorageShape {
1953
+ getItem(key: string): string | null;
1954
+ setItem(key: string, value: string): void;
1955
+ removeItem(key: string): void;
1956
+ }
1957
+ //#endregion
1958
+ //#region src/dev-signer.d.ts
1959
+ interface DevPrivateKeySignerInput {
1960
+ /** Dev-only derivation seed (e.g. `VITE_CAPXUL_DEV_SIGNER_SEED`). Throwaway keys only. */
1961
+ readonly seed: string;
1962
+ /** Explicit email — skips the auth-cache lookup (tests, node harnesses). */
1963
+ readonly email?: string;
1964
+ /** Storage holding the cached session. Defaults to browser `localStorage`. */
1965
+ readonly storage?: BrowserStorageShape;
1966
+ }
1967
+ /** Deterministic dev private key for an email under a seed. Exported for probes. */
1968
+ declare function deriveDevPrivateKey(seed: string, email: string): Hex;
1969
+ /**
1970
+ * Browser-safe dev signer. Lazy: the email (and so the key) is resolved at
1971
+ * each `getAddress()` / `signUserOpHash()` from the cached session, so the
1972
+ * same signer instance follows whichever user is signed in.
1973
+ */
1974
+ declare function devPrivateKeySigner(input: DevPrivateKeySignerInput): CapxulSigner;
1285
1975
  //#endregion
1286
1976
  //#region src/adapters/openfort/embedded-wallet-port.d.ts
1287
1977
  /**
@@ -1320,13 +2010,25 @@ interface OpenfortEmbeddedSignerInput {
1320
2010
  declare function openfortEmbeddedSignerFromWallet(input: {
1321
2011
  readonly embeddedWallet: OpenfortEmbeddedWalletApi;
1322
2012
  readonly ensureWalletReady?: () => Promise<void>;
1323
- }): CapxulSigner;
2013
+ }): OpenfortEmbeddedSigner;
1324
2014
  /**
1325
2015
  * Browser `CapxulSigner` backed by an Openfort embedded wallet (#335).
1326
2016
  * Signs the backend's SafeOp digest via raw `signMessage` (no EIP-191 prefix)
1327
2017
  * and verifies recovery before the backend submits.
1328
2018
  */
1329
- declare function openfortEmbeddedSigner(input: OpenfortEmbeddedSignerInput): CapxulSigner;
2019
+ type OpenfortEmbeddedSigner = CapxulSigner & {
2020
+ /** Drop cached `getAddress()` so the next read hits the embedded wallet again. */readonly resetAddressCache: () => void;
2021
+ };
2022
+ declare function openfortEmbeddedSigner(input: OpenfortEmbeddedSignerInput): OpenfortEmbeddedSigner;
2023
+ /**
2024
+ * Canonical name for the embedded-wallet `CapxulSigner` constructor
2025
+ * (backend-orchestrated-deploy.md). The embedded-wallet (passkey / Openfort)
2026
+ * member of the named constructor trio `localPrivateKeySigner` /
2027
+ * `injectedWalletSigner` / `embeddedSigner`. Takes the provider-agnostic
2028
+ * `OpenfortEmbeddedWalletPort` (getAddress + signRawDigest); the Openfort-API
2029
+ * convenience wrapper is `openfortEmbeddedSignerFromWallet`.
2030
+ */
2031
+ declare const embeddedSigner: typeof openfortEmbeddedSigner;
1330
2032
  //#endregion
1331
2033
  //#region src/production.d.ts
1332
2034
  /**
@@ -1358,5 +2060,32 @@ interface CapxulClientInput {
1358
2060
  /** Consumer-facing factory — accepts only production-meaningful inputs (#326). */
1359
2061
  declare function createCapxulClient(input: CapxulClientInput): Promise<CapxulResult<CapxulClient>>;
1360
2062
  //#endregion
1361
- export { type Account, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type Address, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, type BindingMethods, type CapxulClient, type CapxulClientInput, type CapxulResult, type CapxulSigner, type CreateCapxulClientInput, type CreateOrgInput, type DetectPendingOrgInvitationsResult, type Eip1193Provider, type Eip1193RequestProvider, type EmailBinding, type IdentityMethods, type InviteMemberInput, type MemberStatus, type MemberView, type Money, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgId, type OrgMethods, type OrgScopedMethods, type OrgSpendInput, type OrgSpendResult, type OrgTemplate, type OrgView, type Profile, type RemoveMemberInput, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type Session, type SmartAccount, type SmartAccountMethods, type SubAccount, type SubAccountId, type SubAccountsMethods, type TransferEndpoint, type TransferInput, type TransferResult, assembleCapxulClient, createCapxulClient, eip1193AccountProvider, injectedWalletSigner, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
2063
+ //#region src/telemetry/capture-exception.d.ts
2064
+ interface HandledErrorReportContext {
2065
+ readonly layer?: string;
2066
+ readonly operation?: string;
2067
+ readonly provider?: string;
2068
+ readonly capxul_error_code?: string;
2069
+ readonly failure_mode?: FailureMode;
2070
+ }
2071
+ /**
2072
+ * Capture an error as a `$exception` event through the telemetry port,
2073
+ * formatted for PostHog Error Tracking.
2074
+ *
2075
+ * Parses stack traces into `$exception_list` format, extracts structured
2076
+ * metadata from CapxulError objects, and supplements with context props.
2077
+ * Fire-and-forget: telemetry defects are silently swallowed.
2078
+ * Returns `Effect<void, never>` for use in Effect pipelines; the underlying
2079
+ * adapter work is synchronous, so callers outside Effect contexts can
2080
+ * use `Effect.runSync`.
2081
+ */
2082
+ declare function captureException(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): Effect.Effect<void, never>;
2083
+ /**
2084
+ * Synchronous fire-and-forget capture. Runs the Effect inline with
2085
+ * `Effect.runSync` so callers outside an Effect context (e.g. React
2086
+ * hooks before throwing) can report errors without awaiting.
2087
+ */
2088
+ declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
2089
+ //#endregion
2090
+ export { type Account, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type Address, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, type CapxulClient, type CapxulClientInput, type CapxulResult, type CapxulSigner, type CreateCapxulClientInput, type CreateOrgInput, type DepositInstructions, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type IdentityMethods, type InviteMemberInput, type MeMethods, type MeProfile, type MemberStatus, type MemberView, type Money, type OpenfortEmbeddedSignerInput, type OpenfortEmbeddedWalletApi, type OpenfortEmbeddedWalletPort, type OrgBatchPayrollInput, type OrgId, type OrgMethods, type OrgPayrollRun, type OrgScopedMethods, type OrgSpendViaPaymentsInput, type OrgTemplate, type OrgView, type Payee, type PayeesMethods, type Payment, type PaymentDocumentRef, type PaymentDocumentRender, type PaymentDocumentVerification, type PaymentDocumentsMethods, type PaymentDraft, type PaymentDraftStatus, type PaymentMoney, type PaymentRelease, type PaymentRequest, type PaymentRequestStatus, type PaymentRequestsCreateInput, type PaymentRequestsMethods, type PaymentSettlementInput, type PaymentStatus, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PaymentsWithdrawInput, type Profile, type RecipientResolution, type RecipientResolutionKind, type ReconciliationEntry, type RemoveMemberInput, type RoleDefinition, type RoleKey, type RoleSpendCap, type RoleView, type Session, type SmartAccount, type SmartAccountMethods, type SubAccount, type SubAccountId, type SubAccountsMethods, type TelemetryPort, type TransferEndpoint, type TransferInput, type TransferResult, type WorkbenchDraftInput, type WorkbenchExecuteInput, type WorkbenchMethods, type WorkbenchMintResult, captureException, captureExceptionSync, createCapxulClient, deriveDevPrivateKey, devPrivateKeySigner, eip1193AccountProvider, embeddedSigner, injectedWalletSigner, isSettingUpLifecycle, localPrivateKeyAccountProvider, openfortEmbeddedSigner, openfortEmbeddedSignerFromWallet, openfortEmbeddedWalletPort };
1362
2091
  //# sourceMappingURL=index.d.mts.map