@capxul/sdk 0.2.0-alpha.4 → 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +5 -308
  2. package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs +457 -0
  3. package/dist/InMemoryAuthCacheAdapter-v5W-XB5M.mjs.map +1 -0
  4. package/dist/index-CTXgQ_xR.d.mts +158 -0
  5. package/dist/index-CTXgQ_xR.d.mts.map +1 -0
  6. package/dist/index.d.mts +2574 -0
  7. package/dist/index.d.mts.map +1 -0
  8. package/dist/index.mjs +7974 -0
  9. package/dist/index.mjs.map +1 -0
  10. package/dist/node/index.d.mts +55 -0
  11. package/dist/node/index.d.mts.map +1 -0
  12. package/dist/node/index.mjs +158 -0
  13. package/dist/node/index.mjs.map +1 -0
  14. package/dist/ports/safe-deployment.d.mts +2 -0
  15. package/dist/ports/safe-deployment.mjs +38 -0
  16. package/dist/ports/safe-deployment.mjs.map +1 -0
  17. package/dist/safe-deployment-D3k9yndM.d.mts +136 -0
  18. package/dist/safe-deployment-D3k9yndM.d.mts.map +1 -0
  19. package/dist/signer-D9fUJp8o.d.mts +147 -0
  20. package/dist/signer-D9fUJp8o.d.mts.map +1 -0
  21. package/package.json +42 -71
  22. package/CHANGELOG.md +0 -274
  23. package/LICENSE +0 -44
  24. package/dist/client-CbUeJoM9.d.ts +0 -1335
  25. package/dist/client-UEm2oZbZ.d.cts +0 -1335
  26. package/dist/client.cjs +0 -4042
  27. package/dist/client.d.cts +0 -6
  28. package/dist/client.d.ts +0 -6
  29. package/dist/client.js +0 -4040
  30. package/dist/errors-CwhCWGxm.d.ts +0 -70
  31. package/dist/errors-rqxuUhQP.d.cts +0 -70
  32. package/dist/errors.cjs +0 -35
  33. package/dist/errors.d.cts +0 -2
  34. package/dist/errors.d.ts +0 -2
  35. package/dist/errors.js +0 -31
  36. package/dist/index.cjs +0 -4273
  37. package/dist/index.d.cts +0 -461
  38. package/dist/index.d.ts +0 -461
  39. package/dist/index.js +0 -4234
  40. package/dist/next-action-CTGl8wpy.d.cts +0 -177
  41. package/dist/next-action-CTGl8wpy.d.ts +0 -177
  42. package/dist/types-BD4VAQb5.d.ts +0 -1205
  43. package/dist/types-HlwCIjgQ.d.cts +0 -1205
  44. package/dist/webhooks.cjs +0 -118
  45. package/dist/webhooks.d.cts +0 -33
  46. package/dist/webhooks.d.ts +0 -33
  47. package/dist/webhooks.js +0 -116
@@ -0,0 +1,2574 @@
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 { a as AccountProvider, c as Eip1193Provider, d as CapxulResult, f as Profile, g as AuthCachePort, i as injectedWalletSigner, l as eip1193AccountProvider, m as SmartAccount, n as CapxulSigner, o as AccountProviderSource, p as Session, r as Eip1193RequestProvider, s as AccountRequirement, t as CapxulDigestSigner, u as localPrivateKeyAccountProvider, v as CachedJwt } from "./signer-D9fUJp8o.mjs";
3
+ import { a as SafeDeploymentEvidence, n as SafeDeploymentConfig } from "./safe-deployment-D3k9yndM.mjs";
4
+ import { Hex } from "viem";
5
+ import { Context, Effect, Layer, Request } from "effect";
6
+ import { FunctionReference } from "convex/server";
7
+ import { Schema } from "@effect/schema";
8
+ import { Machine } from "@effect/experimental";
9
+
10
+ //#region src/ports/auth-client.d.ts
11
+ type AuthClientOperationOptions = {
12
+ readonly signal?: AbortSignal;
13
+ };
14
+ type SendOtpInput = {
15
+ readonly email: Email;
16
+ };
17
+ type CanSendOtpInput = {
18
+ readonly email: Email;
19
+ };
20
+ type CanSendOtpStatus = {
21
+ readonly allowed: boolean;
22
+ readonly cooldownMs: DurationMs;
23
+ };
24
+ type VerifyOtpInput = {
25
+ readonly email: Email;
26
+ readonly otp: string;
27
+ };
28
+ type GetConvexJwtOptions = AuthClientOperationOptions & {
29
+ readonly forceRefresh?: boolean;
30
+ };
31
+ declare const AuthClientError_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 & {
32
+ readonly _tag: "AuthClientError";
33
+ } & Readonly<A>;
34
+ declare class AuthClientError extends AuthClientError_base<{
35
+ readonly operation: string;
36
+ readonly kind: string;
37
+ readonly cause: unknown;
38
+ }> {}
39
+ interface AuthClientPort {
40
+ canSendOtp(input: CanSendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<CanSendOtpStatus, AuthClientError>;
41
+ sendOtp(input: SendOtpInput, options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
42
+ verifyOtp(input: VerifyOtpInput, options?: AuthClientOperationOptions): Effect.Effect<AuthSession, AuthClientError>;
43
+ getSession(options?: AuthClientOperationOptions): Effect.Effect<AuthSession | null, AuthClientError>;
44
+ signOut(options?: AuthClientOperationOptions): Effect.Effect<void, AuthClientError>;
45
+ /**
46
+ * Fetches a Convex-aud JWT from `/api/auth/convex/token` (W7). Server mints
47
+ * a fresh JWT on every call per Probe A's 2026-05-19 finding (RS256, 900 s
48
+ * lifetime, `iss = <site-url>`, `aud = convex`). The caller (the SDK's
49
+ * `tokenProvider` wired into ConvexCallPort) is responsible for the
50
+ * `exp - 30s` proactive cache + `forceRefresh` callback handshake.
51
+ */
52
+ getConvexJwt(options?: GetConvexJwtOptions): Effect.Effect<CachedJwt, AuthClientError>;
53
+ }
54
+ //#endregion
55
+ //#region src/ports/clock.d.ts
56
+ interface ClockPort {
57
+ readonly now: Effect.Effect<EpochMs, ClockError>;
58
+ readonly sleep: (duration: DurationMs) => Effect.Effect<void, ClockError>;
59
+ }
60
+ declare const ClockError_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 & {
61
+ readonly _tag: "ClockError";
62
+ } & Readonly<A>;
63
+ declare class ClockError extends ClockError_base<{
64
+ readonly operation: "now" | "sleep" | "initialize";
65
+ readonly cause: unknown;
66
+ }> {}
67
+ //#endregion
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
+ */
84
+ interface TelemetryPort {
85
+ readonly emit: (event: TelemetryEvent) => Effect.Effect<void, never>;
86
+ readonly identify: (input: TelemetryIdentifyInput) => Effect.Effect<void, never>;
87
+ readonly group: (input: TelemetryGroupInput) => Effect.Effect<void, never>;
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;
110
+ }
111
+ //#endregion
112
+ //#region src/flows/auth.d.ts
113
+ interface AuthFlowInput {
114
+ readonly otpTtlMs?: number;
115
+ }
116
+ type AuthFlowState = "idle" | "sending_otp" | "otp_requested" | "verifying" | "authenticated" | "signing_out" | "error";
117
+ interface AuthFlowContext {
118
+ readonly state: AuthFlowState;
119
+ readonly email: Email | null;
120
+ readonly session: AuthSession | null;
121
+ readonly otpRequestedAt: EpochMs | null;
122
+ readonly anonDistinctId?: AnonymousDistinctId;
123
+ readonly error: CapxulError | null;
124
+ }
125
+ interface AuthFlowObserver {
126
+ readonly input: AuthFlowInput;
127
+ readonly getSnapshot: () => {
128
+ readonly value: AuthFlowState;
129
+ readonly context: AuthFlowContext;
130
+ readonly status: "active" | "stopped";
131
+ };
132
+ readonly stop: () => void;
133
+ }
134
+ //#endregion
135
+ //#region src/env/_internal.d.ts
136
+ declare const envShapeSchema: Schema.Struct<{
137
+ [k: string]: Schema.Schema<string, string, never> | Schema.optional<Schema.Schema<string, string, never>>;
138
+ }>;
139
+ type EnvShape = Schema.Schema.Type<typeof envShapeSchema>;
140
+ type EnvKey = keyof EnvShape & string;
141
+ //#endregion
142
+ //#region src/env/index.d.ts
143
+ type RequiredEnvKey = EnvKey;
144
+ type OptionalEnvKey = EnvKey;
145
+ //#endregion
146
+ //#region src/ports/env.d.ts
147
+ declare const EnvError_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 & {
148
+ readonly _tag: "EnvError";
149
+ } & Readonly<A>;
150
+ declare class EnvError extends EnvError_base<{
151
+ readonly publicError: CapxulError;
152
+ readonly publicCode?: CapxulErrorCode;
153
+ readonly key?: string;
154
+ readonly details?: CapxulErrorDetails;
155
+ readonly cause?: unknown;
156
+ }> {}
157
+ interface EnvPort {
158
+ readonly require: <K extends RequiredEnvKey>(key: K) => Effect.Effect<EnvShape[K], EnvError, never>;
159
+ readonly optional: <K extends OptionalEnvKey>(key: K) => Effect.Effect<EnvShape[K] | undefined, EnvError, never>;
160
+ readonly has: (key: EnvKey) => Effect.Effect<boolean, EnvError, never>;
161
+ }
162
+ //#endregion
163
+ //#region src/ports/transport.d.ts
164
+ type TransportOperationKind = "query" | "mutation" | "action";
165
+ type TransportRequest<TArgs = unknown> = {
166
+ readonly name: string;
167
+ readonly args: TArgs;
168
+ readonly correlationId?: string;
169
+ };
170
+ declare const TransportError_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 & {
171
+ readonly _tag: "TransportError";
172
+ } & Readonly<A>;
173
+ declare class TransportError extends TransportError_base<{
174
+ readonly operation: TransportOperationKind;
175
+ readonly name: string;
176
+ readonly publicCode: CapxulErrorCode;
177
+ readonly publicError: CapxulError;
178
+ readonly cause: unknown;
179
+ readonly correlationId?: string;
180
+ readonly details?: CapxulErrorDetails;
181
+ }> {}
182
+ interface TransportPort {
183
+ readonly runQuery: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
184
+ readonly runMutation: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
185
+ readonly runAction: <TOutput = unknown, TArgs = unknown>(request: TransportRequest<TArgs>) => Effect.Effect<TOutput, TransportError>;
186
+ }
187
+ //#endregion
188
+ //#region src/ports/bootstrap.d.ts
189
+ type BootstrapInput = {
190
+ readonly publishableKey: PublishableKey;
191
+ /**
192
+ * Browser callers send the App origin so bootstrap can enforce the
193
+ * publishable-key allowlist. Node/server callers may omit it; the backend
194
+ * only applies the origin allowlist when an origin is present.
195
+ */
196
+ readonly origin?: AllowedOrigin;
197
+ };
198
+ type BootstrapResolution = {
199
+ readonly applicationId: AppId;
200
+ readonly chainId: ChainId;
201
+ /**
202
+ * SDK-handshake session token — distinct from the user-auth `AuthSession`
203
+ * token issued by `AuthClientPort`. Both use the `SessionToken` brand for
204
+ * opaque-string discipline; the issuance source distinguishes them.
205
+ */
206
+ readonly sessionToken: SessionToken;
207
+ readonly issuedAt: EpochMs;
208
+ readonly expiresIn: DurationMs;
209
+ readonly authBaseUrl: string;
210
+ readonly convexUrl: string;
211
+ readonly siteBaseUrl: string;
212
+ readonly openfortPublishableKey: string;
213
+ readonly shieldPublishableKey: string;
214
+ };
215
+ type BootstrapErrorKind = "notAuthenticated" | "network" | "provider" | "malformedBody" | "invalidInput" | "rateLimited";
216
+ declare const BootstrapError_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 & {
217
+ readonly _tag: "BootstrapError";
218
+ } & Readonly<A>;
219
+ declare class BootstrapError extends BootstrapError_base<{
220
+ readonly operation: "resolve";
221
+ readonly kind: BootstrapErrorKind;
222
+ readonly publicCode: CapxulErrorCode;
223
+ readonly cause: unknown;
224
+ readonly details?: CapxulErrorDetails;
225
+ }> {}
226
+ interface BootstrapPort {
227
+ readonly resolve: (input: BootstrapInput) => Effect.Effect<BootstrapResolution, BootstrapError>;
228
+ }
229
+ //#endregion
230
+ //#region src/ports/subscription.d.ts
231
+ /**
232
+ * Canonical teardown handle for substrate-level reactive callbacks.
233
+ *
234
+ * Calling it stops the subscription; no further snapshots will be delivered
235
+ * to the callback after the first invocation. Calling more than once is a
236
+ * no-op (idempotent).
237
+ *
238
+ * @internal-use
239
+ */
240
+ type Unsubscribe = () => void;
241
+ /**
242
+ * Snapshot is the substrate discriminated union for reactive callbacks over
243
+ * `ConvexCallPort.subscribe`. The public SDK surface is imperative
244
+ * (`Promise<CapxulResult>`). This type is reachable for internal XState
245
+ * `fromCallback` actor wiring,
246
+ * property-based `crossAdapterSubscriptionProperty` harness consumers, and
247
+ * genuinely non-React advanced consumers.
248
+ *
249
+ * - `loading` · initial state before any value arrives from the substrate
250
+ * - `ok` · a successful snapshot carrying `value`
251
+ * - `error` · a failed snapshot carrying a typed error (defaults to
252
+ * `CapxulError`)
253
+ *
254
+ * Generic over the value type `T`. The error type `E` is parameterised but
255
+ * defaults to `CapxulError` — every shipped port today uses the default. A
256
+ * narrower or wider `E` is reserved for future ports that need a different
257
+ * error vocabulary.
258
+ *
259
+ * The substrate guarantees the first snapshot is `loading` (CC8 in the
260
+ * `ConvexCallPort` contract); subsequent snapshots carry `ok` or `error`
261
+ * per the underlying transport.
262
+ *
263
+ * Per ARCH-LOCK-1 (`docs/decisions/stage-4-reactivity-pivot.html`), domain
264
+ * ports do not expose reactive callback methods.
265
+ *
266
+ * @internal-use
267
+ */
268
+ type Snapshot<T, E = CapxulError> = {
269
+ readonly status: "loading";
270
+ } | {
271
+ readonly status: "ok";
272
+ readonly value: T;
273
+ } | {
274
+ readonly status: "error";
275
+ readonly error: E;
276
+ };
277
+ //#endregion
278
+ //#region src/ports/convex-call.d.ts
279
+ declare const ConvexCallError_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 & {
280
+ readonly _tag: "ConvexCallError";
281
+ } & Readonly<A>;
282
+ declare class ConvexCallError extends ConvexCallError_base<{
283
+ readonly operation: string;
284
+ readonly publicCode: CapxulErrorCode;
285
+ readonly publicError: CapxulError;
286
+ readonly cause: unknown;
287
+ readonly details?: CapxulErrorDetails;
288
+ }> {}
289
+ interface ConvexCallPort {
290
+ query<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"query", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
291
+ mutation<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"mutation", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
292
+ action<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"action", "public", TArgs, TOutput>, args: TArgs): Effect.Effect<TOutput, ConvexCallError>;
293
+ /**
294
+ * Substrate-level reactive transport over Convex's `onUpdate`.
295
+ *
296
+ * @internal-use — substrate only; see `ports/subscription.ts`. Domain
297
+ * ports do not expose reactive callback methods to consumers (ARCH-LOCK-1).
298
+ */
299
+ subscribe<TArgs extends Record<string, unknown>, TOutput>(fn: FunctionReference<"query", "public", TArgs, TOutput>, args: TArgs, callback: (snapshot: Snapshot<TOutput>) => void): Effect.Effect<Unsubscribe, ConvexCallError>;
300
+ }
301
+ //#endregion
302
+ //#region src/ports/credentials.d.ts
303
+ type CreateApplicationInput = {
304
+ readonly authUserId: AuthUserId;
305
+ readonly name: string;
306
+ readonly allowedOrigins: readonly AllowedOrigin[];
307
+ };
308
+ type MintKeyInput = {
309
+ readonly applicationId: AppId;
310
+ readonly authUserId: AuthUserId;
311
+ };
312
+ type RotateKeyInput = {
313
+ readonly keyId: PublishableKeyId;
314
+ readonly authUserId: AuthUserId;
315
+ readonly graceMs: DurationMs;
316
+ };
317
+ type RevokeKeyInput = {
318
+ readonly keyId: PublishableKeyId;
319
+ readonly authUserId: AuthUserId;
320
+ };
321
+ type RotateKeyResult = {
322
+ readonly active: PublishableKeyRecord;
323
+ readonly retired: PublishableKeyRecord;
324
+ };
325
+ declare const CredentialsError_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 & {
326
+ readonly _tag: "CredentialsError";
327
+ } & Readonly<A>;
328
+ declare class CredentialsError extends CredentialsError_base<{
329
+ readonly operation: string;
330
+ readonly publicCode: CapxulErrorCode;
331
+ readonly publicError: CapxulError;
332
+ readonly cause: unknown;
333
+ readonly details?: CapxulErrorDetails;
334
+ }> {}
335
+ interface CredentialsPort {
336
+ listApplications(authUserId: AuthUserId): Effect.Effect<readonly DeveloperApplication[], CredentialsError>;
337
+ createApplication(input: CreateApplicationInput): Effect.Effect<DeveloperApplication, CredentialsError>;
338
+ mintPublishableKey(input: MintKeyInput): Effect.Effect<PublishableKeyRecord, CredentialsError>;
339
+ rotatePublishableKey(input: RotateKeyInput): Effect.Effect<RotateKeyResult, CredentialsError>;
340
+ revokePublishableKey(input: RevokeKeyInput): Effect.Effect<void, CredentialsError>;
341
+ }
342
+ //#endregion
343
+ //#region src/ports/identity.d.ts
344
+ type CreateIdentityInput = {
345
+ readonly authUserId: AuthUserId;
346
+ readonly email: Email;
347
+ readonly displayName?: string;
348
+ readonly country?: CountryCode;
349
+ };
350
+ type UpdateIdentityInput = {
351
+ readonly authUserId: AuthUserId;
352
+ readonly displayName?: string;
353
+ readonly country?: CountryCode;
354
+ };
355
+ /**
356
+ * D-ONBOARD (#669) — the onboarding-complete identity write. Composes the
357
+ * existing create/update write into one idempotent upsert that ALSO sets the
358
+ * `onboarded` flag and persists the optional `withdrawalAddress` (the one
359
+ * allowed raw-0x class). `displayName` + `country` are required at onboarding
360
+ * time. The returned `Profile` is the existing branded shape — the onboarding
361
+ * flags live on the wire row and are not projected onto the read surface.
362
+ */
363
+ type CompleteOnboardingIdentityInput = {
364
+ readonly authUserId: AuthUserId;
365
+ readonly email: Email;
366
+ readonly displayName: string;
367
+ readonly country: CountryCode;
368
+ readonly withdrawalAddress?: Address;
369
+ };
370
+ declare const IdentityError_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 & {
371
+ readonly _tag: "IdentityError";
372
+ } & Readonly<A>;
373
+ declare class IdentityError extends IdentityError_base<{
374
+ readonly operation: string;
375
+ readonly publicCode: CapxulErrorCode;
376
+ readonly publicError: CapxulError;
377
+ readonly cause: unknown;
378
+ readonly details?: CapxulErrorDetails;
379
+ }> {}
380
+ interface IdentityPort {
381
+ loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<Profile$1 | null, IdentityError, never>;
382
+ create(input: CreateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
383
+ update(input: UpdateIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
384
+ /** D-ONBOARD (#669): idempotent upsert that marks the identity onboarded. */
385
+ completeOnboarding(input: CompleteOnboardingIdentityInput): Effect.Effect<Profile$1, IdentityError, never>;
386
+ }
387
+ //#endregion
388
+ //#region src/ports/smart-account.d.ts
389
+ type ProvisionInput = {
390
+ readonly authUserId: AuthUserId;
391
+ readonly chainId: ChainId;
392
+ };
393
+ /**
394
+ * Input to `SmartAccountPort.confirmDeployment` (#161 · γ-B).
395
+ *
396
+ * The SDK provides evidence pointers; the backend is the oracle for
397
+ * `deployedAt`. `evidence.deployedAt` does NOT exist by schema (see
398
+ * `SafeDeploymentEvidence`) — the backend derives `deployedAt` from
399
+ * the on-chain receipt block via `eth_getBlockByNumber`.
400
+ *
401
+ * Precheck path: `evidence.userOpHash` omitted; backend scans
402
+ * `SafeProxyFactory.ProxyCreation(safeAddress, _)` via `eth_getLogs`.
403
+ *
404
+ * Real-userOp path: `evidence.userOpHash` populated; backend calls
405
+ * `eth_getUserOperationReceipt(userOpHash)` to re-verify and derive.
406
+ */
407
+ type ConfirmDeploymentInput = {
408
+ readonly authUserId: AuthUserId;
409
+ readonly chainId: ChainId;
410
+ readonly safeAddress: Address;
411
+ readonly evidence: SafeDeploymentEvidence;
412
+ /**
413
+ * Optional live-E2E correlation id. This does not prove deployment; the
414
+ * backend still re-verifies chain evidence and only mirrors this branded
415
+ * id onto telemetry for PostHog run joins.
416
+ */
417
+ readonly telemetryRunId?: RunId;
418
+ };
419
+ /**
420
+ * Input to `SmartAccountPort.claim` (PRD #462). The authenticated session
421
+ * reports the browser-created signer address; the BACKEND builds and
422
+ * bootstrap-signs the claim userOp (deploy + swapOwner) — the consumer signs
423
+ * nothing at claim.
424
+ */
425
+ type ClaimInput = {
426
+ readonly authUserId: AuthUserId;
427
+ readonly chainId: ChainId;
428
+ readonly signerAddress: Address;
429
+ readonly telemetryRunId?: RunId;
430
+ };
431
+ 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 & {
432
+ readonly _tag: "SmartAccountError";
433
+ } & Readonly<A>;
434
+ declare class SmartAccountError extends SmartAccountError_base<{
435
+ readonly operation: string;
436
+ readonly publicCode: CapxulErrorCode;
437
+ readonly publicError: CapxulError;
438
+ readonly cause: unknown;
439
+ readonly details?: CapxulErrorDetails;
440
+ }> {}
441
+ interface SmartAccountPort {
442
+ loadByAuthUserId(authUserId: AuthUserId): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
443
+ loadBySmartAccountAddress(address: Address): Effect.Effect<SmartAccount$1 | null, SmartAccountError, never>;
444
+ provision(input: ProvisionInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
445
+ /**
446
+ * Persist on-chain Safe-deployment evidence. The backend re-verifies
447
+ * the evidence against chain state and derives `deployedAt` from the
448
+ * receipt block's timestamp. Returns the updated `SmartAccount` row.
449
+ *
450
+ * γ-B trust model: the SDK supplies evidence pointers only. The
451
+ * backend is the SOLE oracle for `deployedAt` — see
452
+ * `docs/canon/ports/smart-account.md`.
453
+ */
454
+ confirmDeployment(input: ConfirmDeploymentInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
455
+ /**
456
+ * Claim the account (PRD #462): the backend builds, bootstrap-signs, and
457
+ * submits ONE sponsored userOp — deploy (when undeployed) + swapOwner
458
+ * (bootstrap → `signerAddress`). Idempotent; returns the updated row. When
459
+ * another claim is in flight the row comes back with `claimedAt: null` —
460
+ * callers poll lifecycle until the claim lands.
461
+ */
462
+ claim(input: ClaimInput): Effect.Effect<SmartAccount$1, SmartAccountError, never>;
463
+ }
464
+ //#endregion
465
+ //#region src/ports/account-read.d.ts
466
+ type ReadAccountBalanceInput = {
467
+ readonly chainId: ChainId;
468
+ };
469
+ type FundFromFaucetInput = {
470
+ readonly chainId: ChainId;
471
+ readonly amount: Money;
472
+ };
473
+ type FundFromFaucetResult = {
474
+ readonly txHash: string;
475
+ };
476
+ declare const AccountReadError_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 & {
477
+ readonly _tag: "AccountReadError";
478
+ } & Readonly<A>;
479
+ declare class AccountReadError extends AccountReadError_base<{
480
+ readonly operation: string;
481
+ readonly publicCode: CapxulErrorCode;
482
+ readonly publicError: CapxulError;
483
+ readonly cause: unknown;
484
+ readonly details?: CapxulErrorDetails;
485
+ }> {}
486
+ /**
487
+ * Logical Account money read (M2 Slice S1a). Joins the `accounts` row with a
488
+ * live RPC `balanceOf` pull; the adapter lifts wire integers to `Money`.
489
+ */
490
+ interface AccountReadPort {
491
+ readBalance(input: ReadAccountBalanceInput): Effect.Effect<Account, AccountReadError, never>;
492
+ fundFromFaucet(input: FundFromFaucetInput): Effect.Effect<FundFromFaucetResult, AccountReadError, never>;
493
+ }
494
+ //#endregion
495
+ //#region src/ports/sub-account.d.ts
496
+ declare const SubAccountError_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 & {
497
+ readonly _tag: "SubAccountError";
498
+ } & Readonly<A>;
499
+ declare class SubAccountError extends SubAccountError_base<{
500
+ readonly operation: string;
501
+ readonly publicCode: CapxulErrorCode;
502
+ readonly publicError: CapxulError;
503
+ readonly cause: unknown;
504
+ readonly details?: CapxulErrorDetails;
505
+ }> {}
506
+ type CreateSubAccountInput = {
507
+ readonly accountId: AccountId;
508
+ readonly name: string;
509
+ };
510
+ type SubAccountIdInput = {
511
+ readonly subAccountId: SubAccountId;
512
+ };
513
+ type RenameSubAccountInput = {
514
+ readonly subAccountId: SubAccountId;
515
+ readonly name: string;
516
+ };
517
+ /**
518
+ * A `transfer` endpoint is either the Account's MAIN balance (the remainder
519
+ * left over after every sub-account is funded — never a stored row) or a
520
+ * specific sub-account, addressed by its `SubAccountId` (canon
521
+ * `account-balance-model.md` §5, §12).
522
+ */
523
+ type TransferEndpoint = "main" | SubAccountId;
524
+ /**
525
+ * Move money between two of the SAME Account's balances (canon §12). The
526
+ * backend resolves the Account from auth (v1 = one Account per user), so the
527
+ * input carries no `accountId` — only the from/to endpoints and the `Money`
528
+ * amount. One verb covers money in (`main → sub`), money out (`sub → main`),
529
+ * and `sub → sub`.
530
+ */
531
+ type TransferInput = {
532
+ readonly from: TransferEndpoint;
533
+ readonly to: TransferEndpoint;
534
+ readonly amount: Money;
535
+ };
536
+ /**
537
+ * Result of a `transfer`: the recomputed `available` (`balanceOf − Σ`), plus
538
+ * the updated source/destination sub-account rows. An endpoint that is `"main"`
539
+ * has no stored row, so its slot is `null`.
540
+ */
541
+ type TransferResult = {
542
+ readonly available: Money;
543
+ readonly from: SubAccount | null;
544
+ readonly to: SubAccount | null;
545
+ };
546
+ interface SubAccountPort {
547
+ create(input: CreateSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
548
+ get(input: SubAccountIdInput): Effect.Effect<SubAccount | null, SubAccountError, never>;
549
+ list(input: {
550
+ readonly accountId: AccountId;
551
+ }): Effect.Effect<readonly SubAccount[], SubAccountError, never>;
552
+ rename(input: RenameSubAccountInput): Effect.Effect<SubAccount, SubAccountError, never>;
553
+ delete(input: SubAccountIdInput): Effect.Effect<void, SubAccountError, never>;
554
+ transfer(input: TransferInput): Effect.Effect<TransferResult, SubAccountError, never>;
555
+ }
556
+ //#endregion
557
+ //#region src/flows/types.d.ts
558
+ /**
559
+ * The full 13-port bundle that `assembleCapxulClient` (slice 5) consumes.
560
+ * (Was 15 before the dead local-signer port was retired; the deploy path
561
+ * now signs exclusively through `CapxulSigner`.)
562
+ *
563
+ * Each per-flow factory in slices 2-4 takes a narrowed subset, e.g.
564
+ * `AuthFlowPorts = Pick<FlowPorts, "authClient" | "clock" | "telemetry">`.
565
+ * Slice 1 ships only the union; per Q6 each per-flow slice declares its
566
+ * own narrowed `Pick<FlowPorts, ...>` inside its flow file.
567
+ */
568
+ interface FlowPorts {
569
+ readonly authClient: AuthClientPort;
570
+ readonly authCache: AuthCachePort;
571
+ readonly identity: IdentityPort;
572
+ readonly smartAccount: SmartAccountPort;
573
+ readonly accountRead: AccountReadPort;
574
+ readonly subAccount: SubAccountPort;
575
+ readonly credentials: CredentialsPort;
576
+ readonly bootstrap: BootstrapPort;
577
+ readonly clock: ClockPort;
578
+ readonly env: EnvPort;
579
+ readonly telemetry: TelemetryPort;
580
+ readonly transport: TransportPort;
581
+ readonly convexCall: ConvexCallPort;
582
+ }
583
+ /**
584
+ * Pre-resolved external signer + signed proof. The UI obtains this
585
+ * BEFORE prompting the user to verify (MetaMask popup, hardware-wallet
586
+ * confirm, etc.), then the consumer sends it to AuthFlow via the
587
+ * `SET_SIGNER` event between `idle` and `verifying`. AuthFlow assigns
588
+ * to `context.externalSigner` on the SET_SIGNER self-loop in either
589
+ * `idle` or `otp_requested`, then flows the value through to the
590
+ * invoked ProvisioningFlow child via `invoke.input.externalSigner`.
591
+ * The child's `branching` state inspects `context.signerAddress`
592
+ * (derived from `input.externalSigner?.address`) to route through
593
+ * `register_external` instead of `mint_openfort` when present.
594
+ *
595
+ * The signer's lifetime is the authenticated session — `clearAuthContext`
596
+ * (on SIGN_OUT → idle) and `clearErrorAndContext` (on error → RESET →
597
+ * idle) both wipe `context.externalSigner`. A subsequent sign-in cycle
598
+ * begins fresh; the consumer re-sends SET_SIGNER (or omits it for the
599
+ * Openfort fallback path). Reference:
600
+ * `docs/decisions/stage-3-external-signer-lifecycle.html` (Option C,
601
+ * locked 2026-05-17, supersedes the earlier factory-input shape).
602
+ *
603
+ * `signedProof` is an EIP-191 signed message proving the user controls
604
+ * the address. ProvisioningFlow does not verify the proof itself —
605
+ * verification is delegated to the indexer registration in Stage 4 when
606
+ * `IndexerPort.registerSafe` lands. For Stage 3 the field is recorded
607
+ * verbatim for trace fidelity.
608
+ *
609
+ * The type lives in this flows/types module (not in `@capxul/types`)
610
+ * because it is a flow-shape composite — `Address` + a freeform proof
611
+ * string — not a primitive brand. Per the Stage 3 plan's vocabulary
612
+ * convention, flow-shape composites stay co-located with their flow.
613
+ */
614
+ interface ExternalSigner {
615
+ readonly address: Address;
616
+ readonly signedProof: string;
617
+ }
618
+ //#endregion
619
+ //#region src/client/auth.d.ts
620
+ interface SignInOptions {
621
+ readonly signal?: AbortSignal;
622
+ }
623
+ type AuthMethodOptions = SignInOptions;
624
+ interface AuthMethods {
625
+ canSendOtp(input: {
626
+ readonly email: string;
627
+ }, options?: AuthMethodOptions): Promise<CapxulResult<CanSendOtpStatus>>;
628
+ signIn(input: {
629
+ readonly email: string;
630
+ }, options?: SignInOptions): Promise<CapxulResult<{
631
+ readonly sessionId: string;
632
+ readonly expiresAt: number;
633
+ }>>;
634
+ verifyOtp(input: {
635
+ readonly email: string;
636
+ readonly code: string;
637
+ readonly signer?: ExternalSigner;
638
+ }, options?: AuthMethodOptions): Promise<CapxulResult<Session>>;
639
+ signOut(options?: AuthMethodOptions): Promise<CapxulResult<void>>;
640
+ getSession(options?: AuthMethodOptions): Promise<CapxulResult<Session | null>>;
641
+ }
642
+ //#endregion
643
+ //#region src/client/smart-account.d.ts
644
+ interface SmartAccountMethods {
645
+ loadCurrent(options?: {
646
+ readonly signal?: AbortSignal;
647
+ }): Promise<CapxulResult<SmartAccount | null>>;
648
+ provision(input?: {
649
+ readonly externalSigner?: ExternalSigner;
650
+ }): Promise<CapxulResult<SmartAccount>>;
651
+ }
652
+ //#endregion
653
+ //#region src/client/identity.d.ts
654
+ interface IdentityMethods {
655
+ loadCurrent(options?: {
656
+ readonly signal?: AbortSignal;
657
+ }): Promise<CapxulResult<Profile | null>>;
658
+ }
659
+ //#endregion
660
+ //#region src/client/account-lane.d.ts
661
+ type ProvisioningFailureStep = "wallet" | "identity" | "provision" | "deploy";
662
+ type ProvisioningPhase = {
663
+ readonly status: "idle";
664
+ } | {
665
+ readonly status: "wallet";
666
+ } | {
667
+ readonly status: "identity";
668
+ } | {
669
+ readonly status: "provision";
670
+ } | {
671
+ readonly status: "deploy";
672
+ } | {
673
+ readonly status: "ready";
674
+ } | {
675
+ readonly status: "failed";
676
+ readonly at: ProvisioningFailureStep;
677
+ readonly error: CapxulError;
678
+ };
679
+ //#endregion
680
+ //#region src/client/account-lifecycle.d.ts
681
+ type AccountSetupStep = "connecting" | "confirmingIdentity" | "registering" | "activating";
682
+ type AccountLifecycle = {
683
+ readonly status: "loading";
684
+ } | {
685
+ readonly status: "settingUp";
686
+ readonly step: AccountSetupStep;
687
+ } | {
688
+ readonly status: "ready";
689
+ readonly accountId: string;
690
+ readonly canTransact: boolean;
691
+ } | {
692
+ readonly status: "failed";
693
+ readonly at: AccountSetupStep;
694
+ readonly error: CapxulError;
695
+ };
696
+ declare function isSettingUpLifecycle(lifecycle: AccountLifecycle): boolean;
697
+ //#endregion
698
+ //#region ../wire/src/financial-ops.d.ts
699
+ declare const AttachablePaymentDocumentEnvelope: Schema.Union<[Schema.Struct<{
700
+ protocol: Schema.Literal<["capxul.payment-document"]>;
701
+ version: Schema.Literal<[1]>;
702
+ domain: Schema.Struct<{
703
+ name: Schema.Literal<["CapxulPayments"]>;
704
+ version: Schema.Literal<["1"]>;
705
+ chainId: Schema.Schema<ChainId, number, never>;
706
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
707
+ }>;
708
+ primaryType: Schema.Literal<["Memo"]>;
709
+ message: Schema.Struct<{
710
+ kind: Schema.Literal<[0]>;
711
+ reference: typeof Schema.String;
712
+ note: typeof Schema.String;
713
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
714
+ }>;
715
+ }>, Schema.Struct<{
716
+ protocol: Schema.Literal<["capxul.payment-document"]>;
717
+ version: Schema.Literal<[1]>;
718
+ domain: Schema.Struct<{
719
+ name: Schema.Literal<["CapxulPayments"]>;
720
+ version: Schema.Literal<["1"]>;
721
+ chainId: Schema.Schema<ChainId, number, never>;
722
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
723
+ }>;
724
+ primaryType: Schema.Literal<["Invoice"]>;
725
+ message: Schema.Struct<{
726
+ kind: Schema.Literal<[1]>;
727
+ invoiceNumber: typeof Schema.String;
728
+ payerRef: typeof Schema.String;
729
+ payeeRef: typeof Schema.String;
730
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
731
+ currency: Schema.Schema<CurrencyCode, string, never>;
732
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
733
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
734
+ dueAt: Schema.refine<number, Schema.Schema<number, number, never>>;
735
+ lineItemsHash: Schema.Schema<DocumentHash, string, never>;
736
+ }>;
737
+ }>, Schema.Struct<{
738
+ protocol: Schema.Literal<["capxul.payment-document"]>;
739
+ version: Schema.Literal<[1]>;
740
+ domain: Schema.Struct<{
741
+ name: Schema.Literal<["CapxulPayments"]>;
742
+ version: Schema.Literal<["1"]>;
743
+ chainId: Schema.Schema<ChainId, number, never>;
744
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
745
+ }>;
746
+ primaryType: Schema.Literal<["Payslip"]>;
747
+ message: Schema.Struct<{
748
+ kind: Schema.Literal<[2]>;
749
+ employerRef: typeof Schema.String;
750
+ employeeRef: typeof Schema.String;
751
+ period: typeof Schema.String;
752
+ gross: Schema.refine<string, Schema.Schema<string, string, never>>;
753
+ net: Schema.refine<string, Schema.Schema<string, string, never>>;
754
+ currency: Schema.Schema<CurrencyCode, string, never>;
755
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
756
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
757
+ }>;
758
+ }>, Schema.Struct<{
759
+ protocol: Schema.Literal<["capxul.payment-document"]>;
760
+ version: Schema.Literal<[1]>;
761
+ domain: Schema.Struct<{
762
+ name: Schema.Literal<["CapxulPayments"]>;
763
+ version: Schema.Literal<["1"]>;
764
+ chainId: Schema.Schema<ChainId, number, never>;
765
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
766
+ }>;
767
+ primaryType: Schema.Literal<["Receipt"]>;
768
+ message: Schema.Struct<{
769
+ kind: Schema.Literal<[3]>;
770
+ reference: typeof Schema.String;
771
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
772
+ currency: Schema.Schema<CurrencyCode, string, never>;
773
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
774
+ paidAt: Schema.refine<number, Schema.Schema<number, number, never>>;
775
+ note: typeof Schema.String;
776
+ }>;
777
+ }>]>;
778
+ declare const WithdrawalDocumentEnvelope: Schema.Struct<{
779
+ protocol: Schema.Literal<["capxul.payment-document"]>;
780
+ version: Schema.Literal<[1]>;
781
+ domain: Schema.Struct<{
782
+ name: Schema.Literal<["CapxulPayments"]>;
783
+ version: Schema.Literal<["1"]>;
784
+ chainId: Schema.Schema<ChainId, number, never>;
785
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
786
+ }>;
787
+ primaryType: Schema.Literal<["Withdrawal"]>;
788
+ message: Schema.Struct<{
789
+ kind: Schema.Literal<[4]>;
790
+ reference: typeof Schema.String;
791
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
792
+ currency: Schema.Schema<CurrencyCode, string, never>;
793
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
794
+ destChain: Schema.Schema<ChainId, number, never>;
795
+ destAddress: Schema.refine<string, Schema.Schema<string, string, never>>;
796
+ settledAt: Schema.refine<number, Schema.Schema<number, number, never>>;
797
+ provider: typeof Schema.String;
798
+ note: typeof Schema.String;
799
+ }>;
800
+ }>;
801
+ declare const PaymentDocumentEnvelope: Schema.Union<[Schema.Union<[Schema.Struct<{
802
+ protocol: Schema.Literal<["capxul.payment-document"]>;
803
+ version: Schema.Literal<[1]>;
804
+ domain: Schema.Struct<{
805
+ name: Schema.Literal<["CapxulPayments"]>;
806
+ version: Schema.Literal<["1"]>;
807
+ chainId: Schema.Schema<ChainId, number, never>;
808
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
809
+ }>;
810
+ primaryType: Schema.Literal<["Memo"]>;
811
+ message: Schema.Struct<{
812
+ kind: Schema.Literal<[0]>;
813
+ reference: typeof Schema.String;
814
+ note: typeof Schema.String;
815
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
816
+ }>;
817
+ }>, Schema.Struct<{
818
+ protocol: Schema.Literal<["capxul.payment-document"]>;
819
+ version: Schema.Literal<[1]>;
820
+ domain: Schema.Struct<{
821
+ name: Schema.Literal<["CapxulPayments"]>;
822
+ version: Schema.Literal<["1"]>;
823
+ chainId: Schema.Schema<ChainId, number, never>;
824
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
825
+ }>;
826
+ primaryType: Schema.Literal<["Invoice"]>;
827
+ message: Schema.Struct<{
828
+ kind: Schema.Literal<[1]>;
829
+ invoiceNumber: typeof Schema.String;
830
+ payerRef: typeof Schema.String;
831
+ payeeRef: typeof Schema.String;
832
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
833
+ currency: Schema.Schema<CurrencyCode, string, never>;
834
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
835
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
836
+ dueAt: Schema.refine<number, Schema.Schema<number, number, never>>;
837
+ lineItemsHash: Schema.Schema<DocumentHash, string, never>;
838
+ }>;
839
+ }>, Schema.Struct<{
840
+ protocol: Schema.Literal<["capxul.payment-document"]>;
841
+ version: Schema.Literal<[1]>;
842
+ domain: Schema.Struct<{
843
+ name: Schema.Literal<["CapxulPayments"]>;
844
+ version: Schema.Literal<["1"]>;
845
+ chainId: Schema.Schema<ChainId, number, never>;
846
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
847
+ }>;
848
+ primaryType: Schema.Literal<["Payslip"]>;
849
+ message: Schema.Struct<{
850
+ kind: Schema.Literal<[2]>;
851
+ employerRef: typeof Schema.String;
852
+ employeeRef: typeof Schema.String;
853
+ period: typeof Schema.String;
854
+ gross: Schema.refine<string, Schema.Schema<string, string, never>>;
855
+ net: Schema.refine<string, Schema.Schema<string, string, never>>;
856
+ currency: Schema.Schema<CurrencyCode, string, never>;
857
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
858
+ issuedAt: Schema.refine<number, Schema.Schema<number, number, never>>;
859
+ }>;
860
+ }>, Schema.Struct<{
861
+ protocol: Schema.Literal<["capxul.payment-document"]>;
862
+ version: Schema.Literal<[1]>;
863
+ domain: Schema.Struct<{
864
+ name: Schema.Literal<["CapxulPayments"]>;
865
+ version: Schema.Literal<["1"]>;
866
+ chainId: Schema.Schema<ChainId, number, never>;
867
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
868
+ }>;
869
+ primaryType: Schema.Literal<["Receipt"]>;
870
+ message: Schema.Struct<{
871
+ kind: Schema.Literal<[3]>;
872
+ reference: typeof Schema.String;
873
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
874
+ currency: Schema.Schema<CurrencyCode, string, never>;
875
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
876
+ paidAt: Schema.refine<number, Schema.Schema<number, number, never>>;
877
+ note: typeof Schema.String;
878
+ }>;
879
+ }>]>, Schema.Struct<{
880
+ protocol: Schema.Literal<["capxul.payment-document"]>;
881
+ version: Schema.Literal<[1]>;
882
+ domain: Schema.Struct<{
883
+ name: Schema.Literal<["CapxulPayments"]>;
884
+ version: Schema.Literal<["1"]>;
885
+ chainId: Schema.Schema<ChainId, number, never>;
886
+ verifyingContract: Schema.Literal<["0xe740ea65521edc9bef0ea75d30b5334711db99f4"]>;
887
+ }>;
888
+ primaryType: Schema.Literal<["Withdrawal"]>;
889
+ message: Schema.Struct<{
890
+ kind: Schema.Literal<[4]>;
891
+ reference: typeof Schema.String;
892
+ amount: Schema.refine<string, Schema.Schema<string, string, never>>;
893
+ currency: Schema.Schema<CurrencyCode, string, never>;
894
+ decimals: Schema.refine<number, Schema.Schema<number, number, never>>;
895
+ destChain: Schema.Schema<ChainId, number, never>;
896
+ destAddress: Schema.refine<string, Schema.Schema<string, string, never>>;
897
+ settledAt: Schema.refine<number, Schema.Schema<number, number, never>>;
898
+ provider: typeof Schema.String;
899
+ note: typeof Schema.String;
900
+ }>;
901
+ }>]>;
902
+ /**
903
+ * #592 invoice line item. `quantity` is a positive integer; `unitMinor` is the
904
+ * per-unit price in integer minor units. The list is canonically hashed by
905
+ * `hashLineItems` (payment-document-hash.ts) into the Invoice `lineItemsHash`,
906
+ * and Σ(quantity × unitMinor) MUST equal the invoice `amount`. The hash binds
907
+ * the documentHash to the exact items; the sum-check makes the items add up to
908
+ * the amount due. See the payment-document spec (canon/mcp/financial-ops.md).
909
+ */
910
+ declare const LineItem: Schema.Struct<{
911
+ description: typeof Schema.String;
912
+ quantity: Schema.refine<number, Schema.Schema<number, number, never>>;
913
+ unitMinor: Schema.refine<string, Schema.Schema<string, string, never>>;
914
+ }>;
915
+ type AttachablePaymentDocumentEnvelopeV1 = Schema.Schema.Type<typeof AttachablePaymentDocumentEnvelope>;
916
+ type PaymentDocumentEnvelopeV1 = Schema.Schema.Type<typeof PaymentDocumentEnvelope>;
917
+ type WithdrawalDocumentEnvelopeV1 = Schema.Schema.Type<typeof WithdrawalDocumentEnvelope>;
918
+ type LineItemV1 = Schema.Schema.Type<typeof LineItem>;
919
+ //#endregion
920
+ //#region ../wire/src/leak-safety.d.ts
921
+ declare const OnchainEvidenceBrand: unique symbol;
922
+ /**
923
+ * The branded `{ userOpHash, txHash }` pair. On-chain settlement evidence is
924
+ * INTERNAL — it flows on the server-internal channel only, never onto a wire
925
+ * Payment or any MCP tool output. The brand makes "this is internal evidence"
926
+ * a type, so a loose pair can't be passed where a wire field is expected.
927
+ */
928
+ type OnchainEvidence = {
929
+ readonly userOpHash: string;
930
+ readonly txHash: string;
931
+ } & {
932
+ readonly [OnchainEvidenceBrand]: "OnchainEvidence";
933
+ };
934
+ //#endregion
935
+ //#region src/client/financial-ops.d.ts
936
+ type RecipientResolutionKind = "email" | "org" | "payee";
937
+ type Ref = {
938
+ readonly kind: "handle";
939
+ readonly handle: string;
940
+ } | {
941
+ readonly kind: "email";
942
+ readonly email: string;
943
+ } | {
944
+ readonly kind: "orgHandle";
945
+ readonly orgHandle: string;
946
+ } | {
947
+ readonly kind: "capxulUserId";
948
+ readonly capxulUserId: string;
949
+ } | {
950
+ readonly kind: "payeeId";
951
+ readonly payeeId: string;
952
+ };
953
+ interface MeProfile {
954
+ readonly authUserId: string;
955
+ readonly email: string;
956
+ readonly displayName: string | null;
957
+ }
958
+ interface DepositInstructions {
959
+ readonly accountKind: "personalSafe" | "orgTreasury";
960
+ readonly chainId: number;
961
+ readonly network: "base-sepolia";
962
+ readonly currency: "USD";
963
+ readonly address: string;
964
+ readonly label: string;
965
+ }
966
+ interface RecipientResolution {
967
+ readonly kind: RecipientResolutionKind;
968
+ readonly recipient: string;
969
+ readonly label: string;
970
+ readonly safeAddress: string;
971
+ readonly payeeId?: string;
972
+ readonly orgId?: string;
973
+ readonly handle?: string;
974
+ readonly email?: string;
975
+ }
976
+ interface Payee {
977
+ readonly payeeId: string;
978
+ readonly label: string;
979
+ readonly recipientRef: string;
980
+ readonly handle: string | null;
981
+ readonly destinationKind: "email" | "org" | "payeeHandle";
982
+ readonly safeAddress: string;
983
+ readonly createdAt: number;
984
+ readonly updatedAt: number;
985
+ }
986
+ interface MeMethods {
987
+ get(options?: {
988
+ readonly signal?: AbortSignal;
989
+ }): Promise<CapxulResult<MeProfile>>;
990
+ depositInstructions(options?: {
991
+ readonly signal?: AbortSignal;
992
+ }): Promise<CapxulResult<DepositInstructions>>;
993
+ }
994
+ interface HandlesMethods {
995
+ resolve(handle: string, options?: {
996
+ readonly signal?: AbortSignal;
997
+ }): Promise<CapxulResult<RecipientResolution>>;
998
+ }
999
+ interface PayeesMethods {
1000
+ create(input: {
1001
+ readonly label: string;
1002
+ readonly recipient: string;
1003
+ readonly handle?: string;
1004
+ }, options?: {
1005
+ readonly signal?: AbortSignal;
1006
+ }): Promise<CapxulResult<Payee>>;
1007
+ get(payeeId: string, options?: {
1008
+ readonly signal?: AbortSignal;
1009
+ }): Promise<CapxulResult<Payee | null>>;
1010
+ resolve(recipient: string, options?: {
1011
+ readonly signal?: AbortSignal;
1012
+ }): Promise<CapxulResult<RecipientResolution>>;
1013
+ }
1014
+ interface PaymentMoney {
1015
+ readonly currency: string;
1016
+ readonly value: string;
1017
+ readonly decimals: number;
1018
+ }
1019
+ type PaymentStatus = "pending" | "submitted" | "pending_claim" | "scheduled" | "streaming" | "settled" | "cancelled" | "redirected" | "expired" | "failed";
1020
+ type PaymentType = "unspecified" | "invoice" | "payroll" | "reimbursement";
1021
+ interface PaymentDocumentRef {
1022
+ readonly documentHash: string;
1023
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
1024
+ readonly title?: string;
1025
+ readonly uri?: string;
1026
+ readonly issuedAt?: number;
1027
+ }
1028
+ type PaymentTiming = {
1029
+ readonly kind: "instant";
1030
+ } | {
1031
+ readonly kind: "scheduled";
1032
+ readonly at: number;
1033
+ } | {
1034
+ readonly kind: "stream";
1035
+ readonly startsAt: number;
1036
+ readonly endsAt: number;
1037
+ readonly cliffAt?: number;
1038
+ };
1039
+ interface Payment {
1040
+ readonly id: string;
1041
+ readonly status: PaymentStatus;
1042
+ readonly amount: PaymentMoney;
1043
+ readonly paymentType: PaymentType;
1044
+ readonly recipient: {
1045
+ readonly kind: "handle" | "email" | "payee" | "capxulUserId" | "me" | "org" | "external_address";
1046
+ readonly label: string;
1047
+ readonly payeeId?: string;
1048
+ };
1049
+ readonly documents: readonly PaymentDocumentRef[];
1050
+ readonly timing: PaymentTiming;
1051
+ readonly released: PaymentMoney;
1052
+ readonly availableToClaim: PaymentMoney;
1053
+ readonly createdAt: number;
1054
+ readonly updatedAt: number;
1055
+ }
1056
+ interface PaymentsPayInput {
1057
+ readonly to: Ref;
1058
+ readonly amount: PaymentMoney;
1059
+ /** Full EIP-712 document envelope; hashed + stored, committed on-chain. */
1060
+ readonly document?: AttachablePaymentDocumentEnvelopeV1;
1061
+ /**
1062
+ * Timing clause (D-SHAPE · #646). Omitted ⇒ `instant` (the G2 direct-send path).
1063
+ * A `scheduled`/`stream` clause turns the payment into a Commitment
1064
+ * (escrow-vest-claim) backed by `CapxulPayments.createCommitment`.
1065
+ */
1066
+ readonly timing?: PaymentTiming;
1067
+ /**
1068
+ * #592: itemized line items backing an Invoice `document`. The backend asserts
1069
+ * `hashLineItems(lineItems) === document.lineItemsHash` AND `Σ(quantity ×
1070
+ * unitMinor) === document.amount`, then persists the list for itemized render.
1071
+ */
1072
+ readonly lineItems?: readonly LineItemV1[];
1073
+ }
1074
+ /**
1075
+ * B3 withdraw / cash-out input. Stripe-shaped: `to` is the EXTERNAL 0x wallet
1076
+ * (the ONE place the SDK accepts a raw address — the pay lane never does),
1077
+ * `amount` is a Money, `document` is the REQUIRED kind:4 Withdrawal envelope
1078
+ * (carries the audit-visible destAddress). No chain / Safe / token / hash
1079
+ * custody substrate on the input. Returns a leak-safe `Payment` whose recipient
1080
+ * label is the redacted address — never the full 0x.
1081
+ */
1082
+ interface PaymentsWithdrawInput {
1083
+ readonly to: string;
1084
+ readonly amount: PaymentMoney;
1085
+ readonly document: WithdrawalDocumentEnvelopeV1;
1086
+ }
1087
+ /**
1088
+ * Payout via a saved destination. The caller selects the destination by opaque
1089
+ * id and never re-enters a raw wallet address on this path.
1090
+ */
1091
+ interface PaymentsPayoutInput {
1092
+ readonly actor?: {
1093
+ readonly kind: "account";
1094
+ } | {
1095
+ readonly kind: "org";
1096
+ readonly orgId: string;
1097
+ };
1098
+ readonly destinationId: string;
1099
+ readonly amount: PaymentMoney;
1100
+ }
1101
+ type DestinationKind = "bank" | "mobile-money" | "wallet";
1102
+ type DestinationPayload = {
1103
+ readonly accountHolderName: string;
1104
+ readonly bankName: string;
1105
+ readonly country: string;
1106
+ readonly currency: string;
1107
+ readonly accountNumberLast4: string;
1108
+ } | {
1109
+ readonly provider: string;
1110
+ readonly country: string;
1111
+ readonly currency: string;
1112
+ readonly phoneNumberLast4: string;
1113
+ } | {
1114
+ readonly network: "base-sepolia";
1115
+ readonly address: string;
1116
+ };
1117
+ interface Destination {
1118
+ readonly id: string;
1119
+ readonly counterpartyId: string;
1120
+ readonly ref: Ref;
1121
+ readonly kind: DestinationKind;
1122
+ readonly label: string | null;
1123
+ readonly payload: DestinationPayload;
1124
+ readonly createdAt: number;
1125
+ readonly updatedAt: number;
1126
+ }
1127
+ interface DestinationAddInput {
1128
+ readonly actor?: {
1129
+ readonly kind: "account";
1130
+ } | {
1131
+ readonly kind: "org";
1132
+ readonly orgId: string;
1133
+ };
1134
+ readonly ref: Ref;
1135
+ readonly kind: DestinationKind;
1136
+ readonly label?: string;
1137
+ readonly payload: DestinationPayload;
1138
+ }
1139
+ interface DestinationListInput {
1140
+ readonly actor?: {
1141
+ readonly kind: "account";
1142
+ } | {
1143
+ readonly kind: "org";
1144
+ readonly orgId: string;
1145
+ };
1146
+ readonly ref: Ref;
1147
+ }
1148
+ interface DestinationRemoveInput {
1149
+ readonly actor?: {
1150
+ readonly kind: "account";
1151
+ } | {
1152
+ readonly kind: "org";
1153
+ readonly orgId: string;
1154
+ };
1155
+ readonly destinationId: string;
1156
+ }
1157
+ interface DestinationsMethods {
1158
+ add(input: DestinationAddInput, options?: {
1159
+ readonly signal?: AbortSignal;
1160
+ }): Promise<CapxulResult<Destination>>;
1161
+ list(input: DestinationListInput, options?: {
1162
+ readonly signal?: AbortSignal;
1163
+ }): Promise<CapxulResult<readonly Destination[]>>;
1164
+ remove(input: DestinationRemoveInput, options?: {
1165
+ readonly signal?: AbortSignal;
1166
+ }): Promise<CapxulResult<{
1167
+ readonly id: string;
1168
+ }>>;
1169
+ }
1170
+ interface PaymentSettlementInput {
1171
+ readonly paymentId: string;
1172
+ readonly evidence: OnchainEvidence;
1173
+ }
1174
+ /**
1175
+ * Host-execution callback recording the on-chain escrow of a commitment
1176
+ * (G3 · #546): `createCommitment` returned `onchainCommitmentId`, escrowing
1177
+ * the total. `onchainCommitmentId` + the userOp/tx hashes are internal evidence,
1178
+ * never on the wire (internal channel only).
1179
+ */
1180
+ interface CommitmentCreatedInput {
1181
+ readonly paymentId: string;
1182
+ readonly onchainCommitmentId: string;
1183
+ readonly evidence: OnchainEvidence;
1184
+ }
1185
+ /** Host-execution callback recording a recipient-side `claim` (G3 · #546). */
1186
+ interface CommitmentClaimInput {
1187
+ readonly paymentId: string;
1188
+ readonly evidence: OnchainEvidence;
1189
+ }
1190
+ /**
1191
+ * Host-execution callback recording a creator-side `cancel` (G3 · #546):
1192
+ * on-chain the unvested remainder returns to the creator; vested-unclaimed
1193
+ * stays the recipient's. An optional credit-note document is appended.
1194
+ */
1195
+ interface CommitmentCancelInput {
1196
+ readonly paymentId: string;
1197
+ readonly evidence: OnchainEvidence;
1198
+ readonly document?: PaymentDocumentEnvelopeV1;
1199
+ }
1200
+ /**
1201
+ * Host-execution callback recording a pre-claim `redirect` to a new validated
1202
+ * recipient (G3 · #546). `to` is a validated recipient (handle/email/payee id),
1203
+ * never a raw address.
1204
+ */
1205
+ interface CommitmentRedirectInput {
1206
+ readonly paymentId: string;
1207
+ readonly to: Ref;
1208
+ readonly evidence: OnchainEvidence;
1209
+ readonly document?: PaymentDocumentEnvelopeV1;
1210
+ }
1211
+ /**
1212
+ * Host-execution callback recording a settled ORG spend/payroll on the ONE
1213
+ * `payments` ledger (D3 · #565). An org spend is a KIND of Payment — it lands a
1214
+ * real `payments` row with `source:"org"` + `orgId` (no parallel `orgSpends`
1215
+ * table, no synthetic client-side fabrication). The signer-side host calls this
1216
+ * AFTER the on-chain Roles-modifier spend settles; `evidence` carries the
1217
+ * internal userOp/tx hashes (never wire fields). `recipient` is the validated
1218
+ * recipient ref label; `recipientSafeAddress` is internal evidence on the row.
1219
+ */
1220
+ interface OrgPaymentRecordInput {
1221
+ readonly orgId: string;
1222
+ readonly recipientLabel: string;
1223
+ readonly recipientKind?: "handle" | "email" | "payee" | "capxulUserId" | "me" | "org";
1224
+ readonly recipientRef?: string;
1225
+ readonly recipientPayeeId?: string;
1226
+ readonly recipientSafeAddress: string;
1227
+ readonly amount: PaymentMoney;
1228
+ readonly paymentType: PaymentType;
1229
+ readonly document?: PaymentDocumentEnvelopeV1;
1230
+ /** The org Safe the spend debited — bound as the `from` of the settlement transfer. */
1231
+ readonly orgSafeAddress: string;
1232
+ /**
1233
+ * 0-based occurrence among batch runs with the same (recipient, amount), so
1234
+ * each run binds to + de-dupes on its own on-chain `Transfer` (D3 · #565).
1235
+ */
1236
+ readonly occurrenceIndex: number;
1237
+ readonly evidence: OnchainEvidence;
1238
+ }
1239
+ interface PaymentDocumentVerification {
1240
+ readonly documentHash: string;
1241
+ readonly ok: boolean;
1242
+ readonly derivedHash: string;
1243
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
1244
+ }
1245
+ /**
1246
+ * #577 render-on-demand result. `html` is self-contained user-visible document
1247
+ * HTML (stylesheet + rendered document). The MCP `paymentDocuments.render` tool
1248
+ * exposes only `{documentHash, kind, ok}` to the model and returns `html` in an
1249
+ * audience:["user"] content block (#506 redaction matrix).
1250
+ */
1251
+ interface PaymentDocumentRender {
1252
+ readonly documentHash: string;
1253
+ readonly ok: boolean;
1254
+ readonly kind: "memo" | "invoice" | "payslip" | "receipt" | "withdrawal";
1255
+ readonly html: string;
1256
+ }
1257
+ /**
1258
+ * Internal commitment execution reference (G3 · #546). The on-chain
1259
+ * `onchainCommitmentId` is internal evidence (like userOp/tx hashes) — it never
1260
+ * appears on the wire `Payment` or any MCP tool output, but the signer-side host
1261
+ * needs it to build a claim/cancel/redirect UserOp. This is the server-internal
1262
+ * channel that carries it (and the recipient Safe address for an auto-claim
1263
+ * relayer), never a consumer-facing surface.
1264
+ */
1265
+ interface PaymentCommitmentRef {
1266
+ readonly paymentId: string;
1267
+ readonly onchainCommitmentId: string | null;
1268
+ readonly status: PaymentStatus;
1269
+ }
1270
+ /**
1271
+ * The host-execution + on-chain-evidence channel for Payments (D2 · #564).
1272
+ * SPLIT OFF the public `PaymentsMethods` so an external builder consuming
1273
+ * `@capxul/sdk` directly never sees the custody substrate. Reached only via
1274
+ * `client.payments._internal` (mirrors `client._internal.*`); the signer-side
1275
+ * host (the dev MCP edge / a self-custody integrator) drives it AFTER executing
1276
+ * a UserOp. Every input carries the `OnchainEvidence` brand — never a wire field.
1277
+ */
1278
+ interface PaymentsInternalMethods {
1279
+ /** Report on-chain settlement evidence for an instant payment. */
1280
+ markSettled(input: PaymentSettlementInput, options?: {
1281
+ readonly signal?: AbortSignal;
1282
+ }): Promise<CapxulResult<Payment>>;
1283
+ /**
1284
+ * B3: report on-chain settlement evidence for a withdraw/cash-out. The
1285
+ * backend binds the userOp to a matching external `Transfer` before settling.
1286
+ */
1287
+ markWithdrawalSettled(input: PaymentSettlementInput, options?: {
1288
+ readonly signal?: AbortSignal;
1289
+ }): Promise<CapxulResult<Payment>>;
1290
+ /**
1291
+ * Record the on-chain escrow of a commitment after `createCommitment` returns
1292
+ * its `onchainCommitmentId` (G3 · #546).
1293
+ */
1294
+ markCommitmentCreated(input: CommitmentCreatedInput, options?: {
1295
+ readonly signal?: AbortSignal;
1296
+ }): Promise<CapxulResult<Payment>>;
1297
+ /**
1298
+ * Record a settled ORG spend/payroll on the one `payments` ledger
1299
+ * (D3 · #565) — `source:"org"` + `orgId`, read back as a leak-safe Payment.
1300
+ */
1301
+ recordOrgPayment(input: OrgPaymentRecordInput, options?: {
1302
+ readonly signal?: AbortSignal;
1303
+ }): Promise<CapxulResult<Payment>>;
1304
+ /** Record a recipient-side `claim` after the on-chain claim UserOp settles. */
1305
+ claim(input: CommitmentClaimInput, options?: {
1306
+ readonly signal?: AbortSignal;
1307
+ }): Promise<CapxulResult<Payment>>;
1308
+ /** Record a creator-side `cancel` reclaiming only the unvested remainder. */
1309
+ cancel(input: CommitmentCancelInput, options?: {
1310
+ readonly signal?: AbortSignal;
1311
+ }): Promise<CapxulResult<Payment>>;
1312
+ /** Record a pre-claim `redirect` to a new validated recipient. */
1313
+ redirect(input: CommitmentRedirectInput, options?: {
1314
+ readonly signal?: AbortSignal;
1315
+ }): Promise<CapxulResult<Payment>>;
1316
+ /**
1317
+ * The on-chain commitment reference the signer-side host needs to build a
1318
+ * claim/cancel/redirect UserOp. `onchainCommitmentId` is internal evidence.
1319
+ */
1320
+ commitmentRef(paymentId: string, options?: {
1321
+ readonly signal?: AbortSignal;
1322
+ }): Promise<CapxulResult<PaymentCommitmentRef | null>>;
1323
+ }
1324
+ /**
1325
+ * The PUBLIC, Stripe-shaped Payments surface (D2 · #564). Genus verbs only —
1326
+ * `pay` / `list` / `get`. No `userOpHash` / `txHash` / `onchainCommitmentId` /
1327
+ * `chainId` / `safeAddress`. Host-execution + on-chain evidence live on the
1328
+ * `_internal` channel below; an external builder never touches custody substrate.
1329
+ */
1330
+ interface PaymentsMethods {
1331
+ pay(input: PaymentsPayInput, options?: {
1332
+ readonly signal?: AbortSignal;
1333
+ }): Promise<CapxulResult<Payment>>;
1334
+ payout(input: PaymentsPayoutInput, options?: {
1335
+ readonly signal?: AbortSignal;
1336
+ }): Promise<CapxulResult<Payment>>;
1337
+ /**
1338
+ * B3 withdraw / cash-out: send USDX from the user's custody Safe to an
1339
+ * external 0x wallet, minting a kind:4 Withdrawal document. Returns a
1340
+ * leak-safe `Payment` (recipient label is the redacted address).
1341
+ */
1342
+ withdraw(input: PaymentsWithdrawInput, options?: {
1343
+ readonly signal?: AbortSignal;
1344
+ }): Promise<CapxulResult<Payment>>;
1345
+ list(options?: {
1346
+ readonly signal?: AbortSignal;
1347
+ }): Promise<CapxulResult<readonly Payment[]>>;
1348
+ get(paymentId: string, options?: {
1349
+ readonly signal?: AbortSignal;
1350
+ }): Promise<CapxulResult<Payment | null>>;
1351
+ /**
1352
+ * Host-execution + on-chain-evidence channel — off the public surface
1353
+ * (production-surface-policy.md pattern). Self-custody integrators drive this;
1354
+ * a Stripe-shaped consumer never does.
1355
+ *
1356
+ * @internal-use
1357
+ */
1358
+ readonly _internal: PaymentsInternalMethods;
1359
+ }
1360
+ interface PaymentDocumentsMethods {
1361
+ verify(documentHash: string, options?: {
1362
+ readonly signal?: AbortSignal;
1363
+ }): Promise<CapxulResult<PaymentDocumentVerification>>;
1364
+ /**
1365
+ * #577: render-on-demand. Loads the owner's stored document by `documentHash`,
1366
+ * re-verifies its EIP-712 hash, and renders it to self-contained HTML using the
1367
+ * verified stored line items. Returns `{documentHash, kind, ok, html}`.
1368
+ */
1369
+ render(documentHash: string, options?: {
1370
+ readonly signal?: AbortSignal;
1371
+ }): Promise<CapxulResult<PaymentDocumentRender>>;
1372
+ }
1373
+ type PaymentRequestStatus = "draft" | "sent" | "viewed" | "paid" | "expired" | "cancelled";
1374
+ interface PaymentRequest {
1375
+ readonly id: string;
1376
+ readonly status: PaymentRequestStatus;
1377
+ readonly amount: PaymentMoney;
1378
+ readonly reference: string;
1379
+ readonly memo: string | null;
1380
+ /** Fixed-amount payment link token (HITL #519: basic, not replay-hardened). */
1381
+ readonly linkToken: string;
1382
+ /** Minimal entitlement (HITL #501): true once paid. */
1383
+ readonly entitlementGranted: boolean;
1384
+ /** The Payment this receivable settled into (set on collect). */
1385
+ readonly settledPaymentId: string | null;
1386
+ /** The receipt document committed for this receivable (set on collect). */
1387
+ readonly receiptDocumentHash: string | null;
1388
+ readonly expiresAt: number | null;
1389
+ readonly createdAt: number;
1390
+ readonly updatedAt: number;
1391
+ }
1392
+ interface ReconciliationEntry {
1393
+ readonly paymentRequestId: string;
1394
+ readonly reference: string;
1395
+ readonly status: "paid" | "exception";
1396
+ readonly settledPaymentId: string | null;
1397
+ readonly receiptDocumentHash: string | null;
1398
+ }
1399
+ interface PaymentRequestsCreateInput {
1400
+ readonly amount: PaymentMoney;
1401
+ readonly reference: string;
1402
+ readonly memo?: string;
1403
+ /** Optional expiry (epoch ms). HITL #519: expiry policy is a basic timestamp. */
1404
+ readonly expiresAt?: number;
1405
+ }
1406
+ interface PaymentRequestsMethods {
1407
+ /** Open a receivable in `draft` with a fixed-amount payment link. */
1408
+ create(input: PaymentRequestsCreateInput, options?: {
1409
+ readonly signal?: AbortSignal;
1410
+ }): Promise<CapxulResult<PaymentRequest>>;
1411
+ markSent(paymentRequestId: string, options?: {
1412
+ readonly signal?: AbortSignal;
1413
+ }): Promise<CapxulResult<PaymentRequest>>;
1414
+ markViewed(paymentRequestId: string, options?: {
1415
+ readonly signal?: AbortSignal;
1416
+ }): Promise<CapxulResult<PaymentRequest>>;
1417
+ cancel(paymentRequestId: string, options?: {
1418
+ readonly signal?: AbortSignal;
1419
+ }): Promise<CapxulResult<PaymentRequest>>;
1420
+ /**
1421
+ * Collect the receivable (HERMETIC until a live inbound path exists): settle
1422
+ * it into the Payment ledger and mint a receipt linked by `documentHash`.
1423
+ */
1424
+ collect(paymentRequestId: string, options?: {
1425
+ readonly signal?: AbortSignal;
1426
+ }): Promise<CapxulResult<PaymentRequest>>;
1427
+ list(options?: {
1428
+ readonly signal?: AbortSignal;
1429
+ }): Promise<CapxulResult<readonly PaymentRequest[]>>;
1430
+ get(paymentRequestId: string, options?: {
1431
+ readonly signal?: AbortSignal;
1432
+ }): Promise<CapxulResult<PaymentRequest | null>>;
1433
+ getByLink(linkToken: string, options?: {
1434
+ readonly signal?: AbortSignal;
1435
+ }): Promise<CapxulResult<PaymentRequest | null>>;
1436
+ /** Inbound reconciliation: paid / exception status per receivable. */
1437
+ reconcile(options?: {
1438
+ readonly signal?: AbortSignal;
1439
+ }): Promise<CapxulResult<readonly ReconciliationEntry[]>>;
1440
+ }
1441
+ type PaymentDraftStatus = "draft" | "simulated" | "approval_pending" | "approved" | "executed" | "cancelled" | "expired";
1442
+ /** The leak-safe, model-visible draft/approval (#506). */
1443
+ interface PaymentDraft {
1444
+ readonly id: string;
1445
+ readonly status: PaymentDraftStatus;
1446
+ readonly recipient: {
1447
+ readonly kind: string;
1448
+ readonly label: string;
1449
+ };
1450
+ readonly amount: PaymentMoney;
1451
+ readonly documentHash: string | null;
1452
+ /** The canonical-plan binding fingerprint (set at approvals.request). */
1453
+ readonly planHash: string | null;
1454
+ /** The opaque read-model version the draft was simulated against (stale-state). */
1455
+ readonly readModelVersion: string;
1456
+ readonly idempotencyKey: string;
1457
+ readonly policyDecision: "allow" | "deny";
1458
+ readonly expiresAt: number | null;
1459
+ readonly settledPaymentId: string | null;
1460
+ readonly createdAt: number;
1461
+ readonly updatedAt: number;
1462
+ }
1463
+ interface WorkbenchDraftInput {
1464
+ readonly clientId: string;
1465
+ readonly audience: string;
1466
+ readonly scopes: readonly string[];
1467
+ readonly to: Ref;
1468
+ readonly amount: PaymentMoney;
1469
+ readonly document?: PaymentDocumentEnvelopeV1;
1470
+ readonly idempotencyKey: string;
1471
+ /** Untrusted connector/model suggestion blob (default-deny taint). */
1472
+ readonly tainted?: Record<string, unknown>;
1473
+ }
1474
+ interface WorkbenchMintResult {
1475
+ readonly approvalToken: string;
1476
+ readonly planHash: string;
1477
+ readonly expiresAt: number;
1478
+ }
1479
+ interface WorkbenchExecuteInput {
1480
+ readonly draftId: string;
1481
+ readonly clientId: string;
1482
+ readonly approvalToken: string;
1483
+ readonly readModelVersion: string;
1484
+ readonly userOpHash: string;
1485
+ readonly txHash: string;
1486
+ }
1487
+ /**
1488
+ * The decomposed workbench (G6 · #549). The edge PROPOSES (draft → simulate →
1489
+ * request); the BACKEND mints the one-time plan-bound token via the human's
1490
+ * browser (`mint`); `execute` consumes it. `mint` is the human step — the edge
1491
+ * normally only reaches `request`, then hands the human a browser URL.
1492
+ */
1493
+ interface WorkbenchMethods {
1494
+ draft(input: WorkbenchDraftInput, options?: {
1495
+ readonly signal?: AbortSignal;
1496
+ }): Promise<CapxulResult<PaymentDraft>>;
1497
+ simulate(draftId: string, options?: {
1498
+ readonly signal?: AbortSignal;
1499
+ }): Promise<CapxulResult<PaymentDraft>>;
1500
+ requestApproval(draftId: string, options?: {
1501
+ readonly signal?: AbortSignal;
1502
+ }): Promise<CapxulResult<PaymentDraft>>;
1503
+ /**
1504
+ * THE HUMAN STEP: mint the one-time approval token (browser/approval app).
1505
+ * F2 (#549): the backend gates minting on a human-origin `capability` the
1506
+ * agent/edge does NOT possess (`CAPXUL_APPROVAL_CAPABILITY`); only the
1507
+ * apps/approve browser app passes it. The edge/SDK lane cannot self-approve.
1508
+ */
1509
+ mint(draftId: string, capability: string, options?: {
1510
+ readonly signal?: AbortSignal;
1511
+ }): Promise<CapxulResult<WorkbenchMintResult>>;
1512
+ execute(input: WorkbenchExecuteInput, options?: {
1513
+ readonly signal?: AbortSignal;
1514
+ }): Promise<CapxulResult<Payment>>;
1515
+ status(draftId: string, options?: {
1516
+ readonly signal?: AbortSignal;
1517
+ }): Promise<CapxulResult<PaymentDraft | null>>;
1518
+ cancel(draftId: string, options?: {
1519
+ readonly signal?: AbortSignal;
1520
+ }): Promise<CapxulResult<PaymentDraft>>;
1521
+ }
1522
+ interface FinancialOpsMethods {
1523
+ readonly me: MeMethods;
1524
+ readonly handles: HandlesMethods;
1525
+ readonly payees: PayeesMethods;
1526
+ readonly destinations: DestinationsMethods;
1527
+ readonly payments: PaymentsMethods;
1528
+ readonly paymentDocuments: PaymentDocumentsMethods;
1529
+ /** Receivables surface (G5 · #548). */
1530
+ readonly paymentRequests: PaymentRequestsMethods;
1531
+ /** Decomposed workbench + trust substrate (G6 · #549). */
1532
+ readonly workbench: WorkbenchMethods;
1533
+ }
1534
+ //#endregion
1535
+ //#region src/client/actor-scope.d.ts
1536
+ type ActorScopeRef = {
1537
+ readonly kind: "account";
1538
+ } | {
1539
+ readonly kind: "org";
1540
+ readonly orgId: string;
1541
+ };
1542
+ interface ActorProfile {
1543
+ readonly actor: ActorScopeRef;
1544
+ readonly displayName: string | null;
1545
+ readonly email?: string;
1546
+ readonly handle?: string;
1547
+ }
1548
+ interface AddressBookEntry {
1549
+ readonly id: string;
1550
+ readonly ref: Ref;
1551
+ readonly label: string;
1552
+ readonly relationship: readonly ("paid" | "paidBy" | "requested" | "member" | "employee")[];
1553
+ readonly hidden: boolean;
1554
+ }
1555
+ interface AddressBookAddInput {
1556
+ readonly ref: Ref;
1557
+ readonly label?: string;
1558
+ }
1559
+ interface AddressBookLabelInput {
1560
+ readonly entryId: string;
1561
+ readonly label: string;
1562
+ }
1563
+ interface AddressBookMethods {
1564
+ list(options?: {
1565
+ readonly signal?: AbortSignal;
1566
+ }): Promise<CapxulResult<readonly AddressBookEntry[]>>;
1567
+ get(entryId: string, options?: {
1568
+ readonly signal?: AbortSignal;
1569
+ }): Promise<CapxulResult<AddressBookEntry | null>>;
1570
+ add(input: AddressBookAddInput, options?: {
1571
+ readonly signal?: AbortSignal;
1572
+ }): Promise<CapxulResult<AddressBookEntry>>;
1573
+ hide(entryId: string, options?: {
1574
+ readonly signal?: AbortSignal;
1575
+ }): Promise<CapxulResult<AddressBookEntry>>;
1576
+ unhide(entryId: string, options?: {
1577
+ readonly signal?: AbortSignal;
1578
+ }): Promise<CapxulResult<AddressBookEntry>>;
1579
+ label(input: AddressBookLabelInput, options?: {
1580
+ readonly signal?: AbortSignal;
1581
+ }): Promise<CapxulResult<AddressBookEntry>>;
1582
+ }
1583
+ interface ActorRequest {
1584
+ readonly id: string;
1585
+ readonly payer?: Ref;
1586
+ readonly amount: PaymentMoney;
1587
+ readonly reference: string;
1588
+ readonly status: "draft" | "sent" | "viewed" | "pending_settlement" | "paid" | "declined" | "cancelled" | "expired";
1589
+ readonly expiresAt: number | null;
1590
+ }
1591
+ interface ActorRequestIssueInput {
1592
+ readonly payer: Ref;
1593
+ readonly amount: PaymentMoney;
1594
+ readonly reference: string;
1595
+ readonly memo?: string;
1596
+ readonly expiresAt?: number;
1597
+ }
1598
+ interface ActorRequestsMethods {
1599
+ issue(input: ActorRequestIssueInput, options?: {
1600
+ readonly signal?: AbortSignal;
1601
+ }): Promise<CapxulResult<ActorRequest>>;
1602
+ list(options?: {
1603
+ readonly signal?: AbortSignal;
1604
+ }): Promise<CapxulResult<readonly ActorRequest[]>>;
1605
+ get(requestId: string, options?: {
1606
+ readonly signal?: AbortSignal;
1607
+ }): Promise<CapxulResult<ActorRequest | null>>;
1608
+ cancel(requestId: string, options?: {
1609
+ readonly signal?: AbortSignal;
1610
+ }): Promise<CapxulResult<ActorRequest>>;
1611
+ reconcile(options?: {
1612
+ readonly signal?: AbortSignal;
1613
+ }): Promise<CapxulResult<readonly ReconciliationEntry[]>>;
1614
+ }
1615
+ interface InboxItem {
1616
+ readonly id: string;
1617
+ readonly issuer: Ref;
1618
+ readonly amount: PaymentMoney;
1619
+ readonly reference: string;
1620
+ readonly status: "open" | "approved" | "declined" | "paid" | "cancelled" | "expired";
1621
+ }
1622
+ interface InboxApproveInput {
1623
+ readonly requestId: string;
1624
+ readonly timing?: PaymentTiming;
1625
+ }
1626
+ interface InboxMethods {
1627
+ list(options?: {
1628
+ readonly signal?: AbortSignal;
1629
+ }): Promise<CapxulResult<readonly InboxItem[]>>;
1630
+ approve(input: InboxApproveInput, options?: {
1631
+ readonly signal?: AbortSignal;
1632
+ }): Promise<CapxulResult<Payment>>;
1633
+ decline(requestId: string, options?: {
1634
+ readonly signal?: AbortSignal;
1635
+ }): Promise<CapxulResult<InboxItem>>;
1636
+ }
1637
+ interface InsightsSummary {
1638
+ readonly pending: {
1639
+ readonly count: number;
1640
+ readonly total: PaymentMoney;
1641
+ };
1642
+ readonly paidThisMonth: {
1643
+ readonly count: number;
1644
+ readonly total: PaymentMoney;
1645
+ };
1646
+ readonly drafts: {
1647
+ readonly count: number;
1648
+ };
1649
+ readonly reconciliation: {
1650
+ readonly open: number;
1651
+ readonly exceptions: number;
1652
+ };
1653
+ }
1654
+ interface InsightsMethods {
1655
+ summary(options?: {
1656
+ readonly signal?: AbortSignal;
1657
+ }): Promise<CapxulResult<InsightsSummary>>;
1658
+ history(options?: {
1659
+ readonly signal?: AbortSignal;
1660
+ }): Promise<CapxulResult<readonly Payment[]>>;
1661
+ }
1662
+ interface ActorProfileMethods {
1663
+ get(options?: {
1664
+ readonly signal?: AbortSignal;
1665
+ }): Promise<CapxulResult<ActorProfile>>;
1666
+ depositInstructions(options?: {
1667
+ readonly signal?: AbortSignal;
1668
+ }): Promise<CapxulResult<DepositInstructions>>;
1669
+ }
1670
+ interface ActorRelationshipMethods {
1671
+ readonly addressBook: AddressBookMethods;
1672
+ readonly requests: ActorRequestsMethods;
1673
+ readonly inbox: InboxMethods;
1674
+ readonly insights: InsightsMethods;
1675
+ readonly profile: ActorProfileMethods;
1676
+ }
1677
+ //#endregion
1678
+ //#region src/client/account.d.ts
1679
+ type AccountStatus = {
1680
+ readonly status: "notAuthenticated";
1681
+ } | {
1682
+ readonly status: "accountRequired";
1683
+ readonly requirement: AccountRequirement;
1684
+ readonly chainId: number;
1685
+ } | {
1686
+ readonly status: "accountProviderReady";
1687
+ readonly requirement: AccountRequirement;
1688
+ readonly chainId: number;
1689
+ readonly source: AccountProviderSource;
1690
+ readonly signerAddress: Address;
1691
+ } | {
1692
+ readonly status: "accountPrepared";
1693
+ readonly requirement: AccountRequirement;
1694
+ readonly account: SmartAccount$1;
1695
+ readonly deployment: {
1696
+ readonly status: "counterfactual";
1697
+ };
1698
+ } | {
1699
+ readonly status: "accountReady";
1700
+ readonly requirement: AccountRequirement;
1701
+ readonly account: SmartAccount$1 | null;
1702
+ readonly deployment: {
1703
+ readonly status: "counterfactual";
1704
+ } | {
1705
+ readonly status: "deployed";
1706
+ readonly deployedAt: SmartAccount$1["deployedAt"];
1707
+ };
1708
+ };
1709
+ /**
1710
+ * Public consumer-facing surface (issue #159 · AC1+AC3). Exactly two
1711
+ * methods. `provision` and `deploySafe` are intentionally NOT here —
1712
+ * they are advanced/testing-only and will live on
1713
+ * `client._internal.account` when sibling issue #161 lands. Per
1714
+ * `docs/canon/rules/public-surface.md`, the narrowing is enforced at
1715
+ * both the type level (the `keyof AccountMethods` extract is exactly
1716
+ * `"getStatus" | "ensureReady"`) and at runtime (the bundle returned
1717
+ * here has those two own-keys and nothing else).
1718
+ *
1719
+ * Per `docs/canon/conventions/flow-internal-substrate.md`, the
1720
+ * `AccountStatus` discriminant — including the variants this slice can
1721
+ * only reach via `getStatus` (e.g. `accountPrepared`) — is the durable
1722
+ * shape consumers depend on. Sibling #161 will extend `ensureReady` to
1723
+ * advance the ladder past `accountProviderReady` and from
1724
+ * `accountPrepared` to `accountReady(deployed)`; until then, the type
1725
+ * surface is stable and the runtime fixed-point is documented.
1726
+ */
1727
+ interface AccountMethods extends ActorRelationshipMethods {
1728
+ /**
1729
+ * Post-auth account setup lifecycle — domain vocabulary over the internal
1730
+ * readiness ladder + provisioning lane (#356).
1731
+ */
1732
+ getLifecycle(): Promise<CapxulResult<AccountLifecycle>>;
1733
+ /** Resume setup after `failed` and return the updated lifecycle snapshot. */
1734
+ retrySetup(): Promise<CapxulResult<AccountLifecycle>>;
1735
+ /**
1736
+ * Internal advanced surface (#161 · AC1). Reserved for the rebuild's
1737
+ * own `ensureReady` upward transitions and for testing harnesses;
1738
+ * consumers MUST NOT depend on this in production. Tagged
1739
+ * `@internal-use` per `.claude/rules/flow-internal-substrate.md`.
1740
+ *
1741
+ * @internal-use
1742
+ */
1743
+ readonly _internal: AccountInternalSurface;
1744
+ }
1745
+ /**
1746
+ * Internal `provision` + `deploySafe` arms exposed at
1747
+ * `client._internal.account` (#161). Each returns `Promise<CapxulResult<T>>`
1748
+ * with the same error catalog the public methods use.
1749
+ *
1750
+ * @internal-use
1751
+ */
1752
+ interface AccountInternalSurface {
1753
+ provision(): Promise<CapxulResult<SmartAccount$1>>;
1754
+ deploySafe(): Promise<CapxulResult<SmartAccount$1>>;
1755
+ /** @internal-use Substrate readiness ladder — tests and e2e only. */
1756
+ getStatus(): Promise<CapxulResult<AccountStatus>>;
1757
+ /** @internal-use Lane runner — tests and e2e only. */
1758
+ ensureReady(): Promise<CapxulResult<AccountStatus>>;
1759
+ /** @internal-use Provisioning lane phase — tests and e2e only. */
1760
+ getProvisioningPhase(): Promise<CapxulResult<ProvisioningPhase>>;
1761
+ /** @internal-use Lane retry — tests and e2e only. */
1762
+ retryProvisioning(): Promise<CapxulResult<ProvisioningPhase>>;
1763
+ }
1764
+ //#endregion
1765
+ //#region src/client/accounts.d.ts
1766
+ interface AccountsMethods {
1767
+ read(options?: {
1768
+ readonly signal?: AbortSignal;
1769
+ }): Promise<CapxulResult<Account>>;
1770
+ }
1771
+ /**
1772
+ * Faucet surface (dev-only). Deliberately OFF the public `AccountsMethods`;
1773
+ * reachable only via `client._internal.accounts` (production-surface-policy.md).
1774
+ * The reference CLI uses it behind a test-env gate — consumers never see `fund`.
1775
+ */
1776
+ interface AccountsFaucetMethods {
1777
+ fund(amount: Money, options?: {
1778
+ readonly signal?: AbortSignal;
1779
+ }): Promise<CapxulResult<{
1780
+ readonly txHash: string;
1781
+ }>>;
1782
+ }
1783
+ //#endregion
1784
+ //#region src/client/sub-accounts.d.ts
1785
+ interface SubAccountsMethods {
1786
+ create(accountId: AccountId, input: {
1787
+ readonly name: string;
1788
+ }, options?: {
1789
+ readonly signal?: AbortSignal;
1790
+ }): Promise<CapxulResult<SubAccount>>;
1791
+ get(subAccountId: SubAccountId, options?: {
1792
+ readonly signal?: AbortSignal;
1793
+ }): Promise<CapxulResult<SubAccount | null>>;
1794
+ list(accountId: AccountId, options?: {
1795
+ readonly signal?: AbortSignal;
1796
+ }): Promise<CapxulResult<readonly SubAccount[]>>;
1797
+ rename(subAccountId: SubAccountId, name: string, options?: {
1798
+ readonly signal?: AbortSignal;
1799
+ }): Promise<CapxulResult<SubAccount>>;
1800
+ delete(subAccountId: SubAccountId, options?: {
1801
+ readonly signal?: AbortSignal;
1802
+ }): Promise<CapxulResult<void>>;
1803
+ transfer(input: TransferInput, options?: {
1804
+ readonly signal?: AbortSignal;
1805
+ }): Promise<CapxulResult<TransferResult>>;
1806
+ }
1807
+ //#endregion
1808
+ //#region src/client/org-spend-gate.d.ts
1809
+ /**
1810
+ * The role's allowed recipients. The address form backs the S4 `spend` path
1811
+ * (recipient is a resolved `Address`); the string form backs the G4
1812
+ * `spendViaPayments` / `batchPayroll` path, whose recipient is a VALIDATED REF
1813
+ * (handle/email/payee/org) compared in the same ref space as the role's set.
1814
+ * Comparison is case-insensitive over the raw string value either way.
1815
+ */
1816
+ type SpendGateRecipients = "anyone" | readonly (Address | string)[];
1817
+ type SpendGateSubAccountScope = {
1818
+ readonly scope: "all";
1819
+ } | {
1820
+ readonly scope: "only";
1821
+ readonly subAccountIds: readonly SubAccountId[];
1822
+ };
1823
+ //#endregion
1824
+ //#region src/ports/org.d.ts
1825
+ /**
1826
+ * The minimal `{from, to, amount}` spend shape the authority read keys off
1827
+ * (D3 #565). The legacy address-keyed `OrgSpendInput`/`org.spend` lane was
1828
+ * hard-removed when `orgSpends` folded into the one `payments` ledger; the
1829
+ * leak-safe ref-based lane (`spendViaPayments`/`batchPayroll`) constructs this
1830
+ * internally and enforces the real validated recipient on the gate.
1831
+ */
1832
+ type OrgSpendShape = {
1833
+ readonly from: SubAccountId;
1834
+ readonly to: Address;
1835
+ readonly amount: Money;
1836
+ };
1837
+ type CreateOrgPortInput = {
1838
+ readonly input: CreateOrgInput;
1839
+ };
1840
+ type ReadOrgTreasuryInput = {
1841
+ readonly orgId: OrgId;
1842
+ };
1843
+ type ListOrgsInput = Record<never, never>;
1844
+ type ListOrgRolesInput = {
1845
+ readonly orgId: OrgId;
1846
+ };
1847
+ type ListOrgMembersInput = {
1848
+ readonly orgId: OrgId;
1849
+ };
1850
+ type InviteOrgMemberInput = {
1851
+ readonly orgId: OrgId;
1852
+ readonly input: InviteMemberInput;
1853
+ };
1854
+ type ResendOrgInviteTokenInput = {
1855
+ readonly orgId: OrgId;
1856
+ readonly email: string;
1857
+ };
1858
+ type DetectPendingOrgInvitationsInput = Record<never, never>;
1859
+ type DetectPendingOrgInvitationsResult$1 = {
1860
+ readonly matched: readonly OrgId[];
1861
+ };
1862
+ type DeployOrgRolesInput = {
1863
+ readonly orgId: OrgId;
1864
+ };
1865
+ type OrgRolesDeploymentResult = {
1866
+ readonly orgId: OrgId;
1867
+ readonly roles: readonly RoleView[];
1868
+ };
1869
+ type GrantOrgRoleInput = {
1870
+ readonly orgId: OrgId;
1871
+ readonly input: AssignRoleInput;
1872
+ };
1873
+ type RevokeOrgRoleInput = {
1874
+ readonly orgId: OrgId;
1875
+ readonly input: RemoveMemberInput;
1876
+ };
1877
+ type OrgSpendAuthority = {
1878
+ readonly activeMember: boolean;
1879
+ readonly subAccountBalanceRaw: string;
1880
+ readonly recipients: SpendGateRecipients;
1881
+ readonly subAccounts: SpendGateSubAccountScope;
1882
+ readonly perTxCapRaw?: string | null;
1883
+ readonly perDayCapRaw?: string | null;
1884
+ readonly spentTodayRaw?: string | null;
1885
+ readonly role?: string;
1886
+ };
1887
+ type ReadOrgSpendAuthorityInput = {
1888
+ readonly orgId: OrgId;
1889
+ readonly input: OrgSpendShape;
1890
+ readonly amountRaw: string;
1891
+ };
1892
+ 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 & {
1893
+ readonly _tag: "OrgError";
1894
+ } & Readonly<A>;
1895
+ declare class OrgError extends OrgError_base<{
1896
+ readonly operation: string;
1897
+ readonly publicCode: CapxulErrorCode;
1898
+ readonly publicError: CapxulError;
1899
+ readonly cause: unknown;
1900
+ readonly details?: CapxulErrorDetails;
1901
+ }> {}
1902
+ /**
1903
+ * Live org seam. `createOrg` runs the SDK-orchestrated deploy (D10) and returns
1904
+ * the created `OrgView` (its treasury is the real M2 `Account` over the Org
1905
+ * Safe — $0 at creation, D3). `readTreasury` pulls the org's Account via RPC
1906
+ * `balanceOf` (D3). `listOrgs` lists the orgs the authenticated user belongs to.
1907
+ */
1908
+ interface OrgPort {
1909
+ createOrg(input: CreateOrgPortInput): Effect.Effect<OrgView, OrgError, never>;
1910
+ readTreasury(input: ReadOrgTreasuryInput): Effect.Effect<Account, OrgError, never>;
1911
+ listOrgs(input: ListOrgsInput): Effect.Effect<readonly OrgView[], OrgError, never>;
1912
+ listRoles(input: ListOrgRolesInput): Effect.Effect<readonly RoleView[], OrgError, never>;
1913
+ listMembers(input: ListOrgMembersInput): Effect.Effect<readonly MemberView[], OrgError, never>;
1914
+ pendingMembers?(input: ListOrgMembersInput): Effect.Effect<readonly MemberView[], OrgError, never>;
1915
+ inviteMember(input: InviteOrgMemberInput): Effect.Effect<MemberView, OrgError, never>;
1916
+ resendInviteToken?(input: ResendOrgInviteTokenInput): Effect.Effect<MemberView, OrgError, never>;
1917
+ detectAndAcceptPendingInvitations(input: DetectPendingOrgInvitationsInput): Effect.Effect<DetectPendingOrgInvitationsResult$1, OrgError, never>;
1918
+ }
1919
+ interface OrgRolesDeploymentPort {
1920
+ deployRoles(input: DeployOrgRolesInput): Effect.Effect<OrgRolesDeploymentResult, OrgError, never>;
1921
+ grantRole(input: GrantOrgRoleInput): Effect.Effect<MemberView, OrgError, never>;
1922
+ revokeRole(input: RevokeOrgRoleInput): Effect.Effect<void, OrgError, never>;
1923
+ }
1924
+ type SubmitOrgSpendViaPaymentsInput = {
1925
+ readonly orgId: OrgId;
1926
+ readonly input: OrgSpendViaPaymentsInput;
1927
+ readonly amountRaw: string;
1928
+ readonly authority: OrgSpendAuthority;
1929
+ };
1930
+ type SubmitOrgBatchPayrollInput = {
1931
+ readonly orgId: OrgId;
1932
+ readonly from: OrgSpendViaPaymentsInput["from"];
1933
+ readonly runs: readonly {
1934
+ readonly run: OrgPayrollRun;
1935
+ readonly amountRaw: string;
1936
+ }[];
1937
+ readonly authorities: readonly OrgSpendAuthority[];
1938
+ };
1939
+ interface OrgSpendPort {
1940
+ readSpendAuthority(input: ReadOrgSpendAuthorityInput): Effect.Effect<OrgSpendAuthority, OrgError, never>;
1941
+ /**
1942
+ * Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
1943
+ * the spend through the payments engine (Roles modifier → CapxulPayments),
1944
+ * write a real `payments` row (`source:"org"`) and read it back as a `Payment`
1945
+ * — the wire carries no `txHash` / Safe / userOp internals. Optional so a
1946
+ * hermetic adapter without a payments-submit lane still compiles; absent ⇒ the
1947
+ * program falls back to a deterministic hermetic `Payment`.
1948
+ */
1949
+ submitSpendViaPayments?(input: SubmitOrgSpendViaPaymentsInput): Effect.Effect<Payment, OrgError, never>;
1950
+ /** Leak-safe org payroll batch (G4 · #547): one MultiSend, one Payment per run. */
1951
+ submitBatchPayroll?(input: SubmitOrgBatchPayrollInput): Effect.Effect<readonly Payment[], OrgError, never>;
1952
+ }
1953
+ //#endregion
1954
+ //#region src/client/org.d.ts
1955
+ /**
1956
+ * A member's lifecycle status (D9 — unified `Member` with status
1957
+ * `pending | active | revoked | expired`). `pending` = invited (incl. a
1958
+ * non-user emailed into existence) but not yet a provisioned member with an
1959
+ * on-chain grant; `active` = on-chain role granted; `revoked` = offboarded
1960
+ * (on-chain REVOKE fired); `expired` = pending invitation timed out.
1961
+ */
1962
+ type MemberStatus = "pending" | "pending_safe" | "pending_grant" | "active" | "revoked" | "expired";
1963
+ /**
1964
+ * One Org you belong to (canon §C1 "Org list" — name, role, balance).
1965
+ * `role` is the member's role label within THIS org. `treasury` is the M2
1966
+ * `Account` over the Org Safe (D3). `handle` is the globally-unique,
1967
+ * normalized org handle (D10a). Pure record of brand-typed fields — not a
1968
+ * brand.
1969
+ */
1970
+ type OrgView = {
1971
+ readonly id: OrgId;
1972
+ readonly name: string;
1973
+ readonly handle: string;
1974
+ readonly safeAddress: Address; /** The viewing member's own role label within this org. */
1975
+ readonly role: string; /** The Org treasury — the real M2 Account over the Org Safe (D3). */
1976
+ readonly treasury: Account;
1977
+ };
1978
+ /**
1979
+ * One member of an Org (canon §C1 "Members" — name/email, role, status; D7/D8).
1980
+ * `personalSafeAddress` is the member-identity key (D7 — Safe-as-identity); it
1981
+ * is `null` while the member is still `pending` (emailed into existence but not
1982
+ * yet provisioned a personal Safe). `email` is the universal entry point (D8).
1983
+ */
1984
+ type MemberView = {
1985
+ readonly orgId: OrgId;
1986
+ readonly email: Email;
1987
+ readonly name: string | null; /** Member-identity key (D7). `null` until the invitee provisions a Safe. */
1988
+ readonly personalSafeAddress: Address | null; /** The member's role label (maps deterministically to the on-chain `roleKey`, D9). */
1989
+ readonly role: string;
1990
+ readonly roleKey: RoleKey | null;
1991
+ readonly status: MemberStatus;
1992
+ readonly grantTxHash: string | null;
1993
+ readonly revokeTxHash: string | null;
1994
+ };
1995
+ /**
1996
+ * A role's on-chain Level-1 spend cap (D4/D5 — physically enforced via Zodiac
1997
+ * Roles + Allowance). `perTx` / `perDay` are `Money`; `toRecipients` scopes the
1998
+ * allowed recipient set. Omitting a field means "unbounded on that axis"
1999
+ * (the Owner role).
2000
+ */
2001
+ type RoleSpendCap = {
2002
+ readonly perTx?: Money;
2003
+ readonly perDay?: Money;
2004
+ readonly toRecipients?: "anyone" | readonly Address[];
2005
+ };
2006
+ /**
2007
+ * The Capxul-owned Role DSL definition (D4). `label` becomes the sticky
2008
+ * bytes32 `roleKey` on-chain. `spend` compiles to Level-1 on-chain Zodiac
2009
+ * conditions; `subAccounts` + `canManage*` compile to Level-2 off-chain Convex
2010
+ * guards (D5).
2011
+ */
2012
+ type RoleDefinition = {
2013
+ readonly label: string;
2014
+ readonly spend?: RoleSpendCap;
2015
+ readonly subAccounts?: {
2016
+ readonly scope: "all" | readonly SubAccountId[];
2017
+ };
2018
+ readonly canManageMembers?: boolean;
2019
+ readonly canManageRoles?: boolean;
2020
+ };
2021
+ /**
2022
+ * One role seeded on an Org (canon §C1 "Roles" — label + caps; D4/D6).
2023
+ * `roleKey` is the on-chain bytes32 role key derived from the label. `definition`
2024
+ * is the full Role DSL entry.
2025
+ */
2026
+ type RoleView = {
2027
+ readonly orgId: OrgId;
2028
+ readonly label: string;
2029
+ readonly roleKey: RoleKey;
2030
+ readonly definition: RoleDefinition;
2031
+ };
2032
+ /** Built-in role templates that seed a new Org at creation (D6). */
2033
+ type OrgTemplate = "Solo" | "Startup" | "Custom";
2034
+ /**
2035
+ * Input to `capxul.createOrg` (S1, D10a, D14). `name` is the display name;
2036
+ * `handle` is the globally-unique normalized handle (`^[a-z0-9-]{3,32}$`, D10a);
2037
+ * `template` seeds the initial role set (D6); `country` is stored unvalidated
2038
+ * (D14 — KYB deferred). For `template: "Custom"`, `roles` carries the authored
2039
+ * `RoleDefinition[]`.
2040
+ */
2041
+ type CreateOrgInput = {
2042
+ readonly name: string;
2043
+ readonly handle: string;
2044
+ readonly template: OrgTemplate;
2045
+ readonly country?: string;
2046
+ readonly roles?: readonly RoleDefinition[];
2047
+ };
2048
+ /**
2049
+ * Input to `org(orgId).invite` (S3, D8). Email is the universal entry point —
2050
+ * inviting an address that is not yet a Capxul user auto-creates a `pending`
2051
+ * membership that resolves on sign-in (the virality loop). `role` names the
2052
+ * role label the invitee is granted on accept.
2053
+ */
2054
+ type InviteMemberInput = {
2055
+ readonly email: string;
2056
+ readonly role: string;
2057
+ };
2058
+ type ResendInviteTokenInput = {
2059
+ readonly email: string;
2060
+ };
2061
+ /**
2062
+ * Input to `org(orgId).removeMember` (S3, D8). Keyed on the member's personal
2063
+ * Safe address (D7 — Safe-as-identity). Drives the on-chain REVOKE + Convex
2064
+ * mirror.
2065
+ */
2066
+ type RemoveMemberInput = {
2067
+ readonly memberSafeAddress: Address;
2068
+ };
2069
+ /**
2070
+ * Input to `org(orgId).assignRole` (S3, D7/D9). Keyed on the member's personal
2071
+ * Safe address (D7). Drives the on-chain GRANT + Convex mirror; the `role`
2072
+ * label maps deterministically to the on-chain `roleKey`.
2073
+ */
2074
+ type AssignRoleInput = {
2075
+ readonly memberSafeAddress: Address;
2076
+ readonly role: string;
2077
+ };
2078
+ /**
2079
+ * Input to `org(orgId).spendViaPayments` (G4 · #547). The LEAK-SAFE org spend:
2080
+ * delegates `org.spend` to the payments engine WITH the member's org role
2081
+ * authority and returns a `Payment`, not a `txHash`. `to` is a VALIDATED
2082
+ * recipient ref (handle / email / payee id / org handle) — never a raw
2083
+ * `Address` (the legacy address-keyed `org.spend` lane was hard-removed in D3
2084
+ * #565 when `orgSpends` was folded into the one `payments` ledger).
2085
+ * `from` is the Level-2 sub-account envelope the spend draws from (D5).
2086
+ */
2087
+ type OrgSpendViaPaymentsInput = {
2088
+ readonly from: SubAccountId; /** Validated recipient ref (handle/email/payee/org) — never a raw address. */
2089
+ readonly to: Ref;
2090
+ readonly amount: Money; /** Full EIP-712 payment document; hashed + stored, committed on-chain. */
2091
+ readonly document?: PaymentDocumentEnvelopeV1;
2092
+ readonly timing?: PaymentTiming;
2093
+ readonly paymentType?: PaymentType;
2094
+ };
2095
+ /**
2096
+ * One run in an `org(orgId).batchPayroll` batch (G4 · #547): a validated
2097
+ * recipient, an amount, and an optional payslip document. Each run is gated
2098
+ * independently against the role's per-tx / per-day / recipient conditions.
2099
+ */
2100
+ type OrgPayrollRun = {
2101
+ /** Validated recipient ref (handle/email/payee/org) — never a raw address. */readonly to: Ref;
2102
+ readonly amount: Money;
2103
+ readonly timing?: PaymentTiming; /** The payslip — an EIP-712 payment document, committed by `documentHash`. */
2104
+ readonly payslip?: PaymentDocumentEnvelopeV1;
2105
+ };
2106
+ /**
2107
+ * Input to `org(orgId).batchPayroll` (G4 · #547). Pays N employees in one
2108
+ * MultiSend through the Roles modifier; each carries a payslip and settles as
2109
+ * `paymentType = payroll`. Every run is gated; an over-cap run REJECTS the
2110
+ * whole batch (no partial treasury drain). Returns one leak-safe `Payment` per
2111
+ * run.
2112
+ */
2113
+ type OrgBatchPayrollInput = {
2114
+ readonly from: SubAccountId;
2115
+ readonly runs: readonly OrgPayrollRun[];
2116
+ };
2117
+ type DetectPendingOrgInvitationsResult = {
2118
+ readonly matched: readonly OrgId[];
2119
+ };
2120
+ /**
2121
+ * Entity-scoped Org method bundle, returned by `capxul.org(orgId)`. Every
2122
+ * method names the entity implicitly via the closed-over `orgId` (D13 — no
2123
+ * stateful active context). `treasury()` returns the real M2 `Account` over
2124
+ * the Org Safe (D3).
2125
+ */
2126
+ interface PayrollRosterLine {
2127
+ readonly id: string;
2128
+ readonly employee: Ref;
2129
+ readonly amount: Money;
2130
+ readonly timing: PaymentTiming;
2131
+ readonly status: "active" | "paused" | "ended";
2132
+ }
2133
+ interface PayrollPayslipTemplate {
2134
+ readonly title: string;
2135
+ readonly memo?: string;
2136
+ }
2137
+ interface PayrollRosterAddInput {
2138
+ readonly employee: Ref;
2139
+ readonly amount: Money;
2140
+ readonly timing: PaymentTiming;
2141
+ readonly payslipTemplate?: PaymentDocumentEnvelopeV1 | PayrollPayslipTemplate;
2142
+ }
2143
+ interface PayrollRunInput {
2144
+ readonly from: SubAccountId;
2145
+ readonly period: string;
2146
+ }
2147
+ interface PayrollMethods {
2148
+ readonly roster: {
2149
+ add(input: PayrollRosterAddInput, options?: {
2150
+ readonly signal?: AbortSignal;
2151
+ }): Promise<CapxulResult<PayrollRosterLine>>;
2152
+ list(options?: {
2153
+ readonly signal?: AbortSignal;
2154
+ }): Promise<CapxulResult<readonly PayrollRosterLine[]>>;
2155
+ update(rosterLineId: string, input: Partial<PayrollRosterAddInput>, options?: {
2156
+ readonly signal?: AbortSignal;
2157
+ }): Promise<CapxulResult<PayrollRosterLine>>;
2158
+ remove(rosterLineId: string, options?: {
2159
+ readonly signal?: AbortSignal;
2160
+ }): Promise<CapxulResult<PayrollRosterLine>>;
2161
+ };
2162
+ run(input: PayrollRunInput, options?: {
2163
+ readonly signal?: AbortSignal;
2164
+ }): Promise<CapxulResult<readonly Payment[]>>;
2165
+ }
2166
+ interface OrgScopedMethods extends ActorRelationshipMethods {
2167
+ /** The Org treasury — the real M2 Account over the Org Safe (D3). */
2168
+ treasury(options?: {
2169
+ readonly signal?: AbortSignal;
2170
+ }): Promise<CapxulResult<Account>>;
2171
+ members(options?: {
2172
+ readonly signal?: AbortSignal;
2173
+ }): Promise<CapxulResult<readonly MemberView[]>>;
2174
+ roles(options?: {
2175
+ readonly signal?: AbortSignal;
2176
+ }): Promise<CapxulResult<readonly RoleView[]>>;
2177
+ deployRoles(options?: {
2178
+ readonly signal?: AbortSignal;
2179
+ }): Promise<CapxulResult<readonly RoleView[]>>;
2180
+ invite(input: InviteMemberInput, options?: {
2181
+ readonly signal?: AbortSignal;
2182
+ }): Promise<CapxulResult<MemberView>>;
2183
+ pendingMembers(options?: {
2184
+ readonly signal?: AbortSignal;
2185
+ }): Promise<CapxulResult<readonly MemberView[]>>;
2186
+ readonly inviteToken: {
2187
+ resend(input: ResendInviteTokenInput, options?: {
2188
+ readonly signal?: AbortSignal;
2189
+ }): Promise<CapxulResult<MemberView>>;
2190
+ };
2191
+ removeMember(input: RemoveMemberInput, options?: {
2192
+ readonly signal?: AbortSignal;
2193
+ }): Promise<CapxulResult<void>>;
2194
+ assignRole(input: AssignRoleInput, options?: {
2195
+ readonly signal?: AbortSignal;
2196
+ }): Promise<CapxulResult<MemberView>>;
2197
+ /**
2198
+ * Leak-safe org spend (G4 · #547; D3 #565 — the one ledger of record): execute
2199
+ * the spend through the payments engine with the member's org role authority
2200
+ * and return a `Payment` (no `to: Address`, no `txHash`, no Safe / userOp
2201
+ * internals). Writes a real `payments` row (`source:"org"`).
2202
+ */
2203
+ spendViaPayments(input: OrgSpendViaPaymentsInput, options?: {
2204
+ readonly signal?: AbortSignal;
2205
+ }): Promise<CapxulResult<Payment>>;
2206
+ /**
2207
+ * Org payroll batch (G4 · #547): pay N employees in one MultiSend through the
2208
+ * Roles modifier, each with a payslip. Every run is gated; an over-cap run
2209
+ * rejects the whole batch. Returns one leak-safe `Payment` per run.
2210
+ */
2211
+ batchPayroll(input: OrgBatchPayrollInput, options?: {
2212
+ readonly signal?: AbortSignal;
2213
+ }): Promise<CapxulResult<readonly Payment[]>>;
2214
+ readonly payroll: PayrollMethods;
2215
+ }
2216
+ type OrgsMethod = {
2217
+ (options?: {
2218
+ readonly signal?: AbortSignal;
2219
+ }): Promise<CapxulResult<readonly OrgView[]>>;
2220
+ detectAndAcceptPendingInvitations(options?: {
2221
+ readonly signal?: AbortSignal;
2222
+ }): Promise<CapxulResult<DetectPendingOrgInvitationsResult>>;
2223
+ };
2224
+ /**
2225
+ * Top-level Org method bundle, exposed at `client.org` / `client.orgs` /
2226
+ * `client.createOrg`. `org(orgId)` resolves the entity-scoped bundle (D13).
2227
+ */
2228
+ interface OrgMethods {
2229
+ createOrg(input: CreateOrgInput, options?: {
2230
+ readonly signal?: AbortSignal;
2231
+ }): Promise<CapxulResult<OrgView>>;
2232
+ readonly orgs: OrgsMethod;
2233
+ /** Resolve the entity-scoped bundle for a specific Org (D13). */
2234
+ org(orgId: OrgId): OrgScopedMethods;
2235
+ }
2236
+ //#endregion
2237
+ //#region src/client/onboarding.d.ts
2238
+ /**
2239
+ * Input to `capxul.onboarding.completePersonal`. `displayName` + `country`
2240
+ * (ISO-3166, persisted to `identities.country`) are required; `withdrawalAddress`
2241
+ * is the OPTIONAL cash-out destination — a `0x`-prefixed 20-byte address string
2242
+ * (the one allowed raw-0x class), validated + normalized at the boundary.
2243
+ */
2244
+ type CompletePersonalOnboardingInput = {
2245
+ readonly displayName: string;
2246
+ readonly country: string;
2247
+ readonly withdrawalAddress?: string;
2248
+ };
2249
+ /**
2250
+ * Input to `capxul.onboarding.completeOrganization`. `handle` is the org slug
2251
+ * (`createOrg` requires it); `ownerDisplayName` is the founder's personal
2252
+ * identity profile.
2253
+ */
2254
+ type CompleteOrganizationOnboardingInput = {
2255
+ readonly organizationName: string;
2256
+ readonly handle: string;
2257
+ readonly country: string;
2258
+ readonly ownerDisplayName: string;
2259
+ };
2260
+ /** Result of `completePersonal` — the post-onboarding readiness snapshot. */
2261
+ type CompletePersonalOnboardingResult = {
2262
+ readonly lifecycle: AccountLifecycle;
2263
+ };
2264
+ /** Result of `completeOrganization` — the created org + readiness snapshot. */
2265
+ type CompleteOrganizationOnboardingResult = {
2266
+ readonly org: OrgView;
2267
+ readonly lifecycle: AccountLifecycle;
2268
+ };
2269
+ /**
2270
+ * Onboarding method bundle, exposed at `client.onboarding`. Exactly two verbs;
2271
+ * the choreography lives in `flows/onboarding.ts`.
2272
+ */
2273
+ interface OnboardingMethods {
2274
+ completePersonal(input: CompletePersonalOnboardingInput, options?: {
2275
+ readonly signal?: AbortSignal;
2276
+ }): Promise<CapxulResult<CompletePersonalOnboardingResult>>;
2277
+ completeOrganization(input: CompleteOrganizationOnboardingInput, options?: {
2278
+ readonly signal?: AbortSignal;
2279
+ }): Promise<CapxulResult<CompleteOrganizationOnboardingResult>>;
2280
+ }
2281
+ //#endregion
2282
+ //#region src/client/create-capxul-client.d.ts
2283
+ interface CapxulClient {
2284
+ readonly auth: AuthMethods;
2285
+ readonly smartAccount: SmartAccountMethods;
2286
+ readonly identity: IdentityMethods;
2287
+ /**
2288
+ * Consumer-facing account readiness surface (issue #159 · AC1+AC3).
2289
+ * Exactly `getStatus` + `ensureReady`; the `_internal.account`
2290
+ * namespace with `provision` + `deploySafe` lands in sibling #161.
2291
+ */
2292
+ readonly account: AccountMethods;
2293
+ /**
2294
+ * Consumer-facing logical Account money read (M2 Slice S1a · #265).
2295
+ * Returns `{ balance, available }` as `Money` — never wei or token units.
2296
+ */
2297
+ readonly accounts: AccountsMethods;
2298
+ readonly me: MeMethods;
2299
+ readonly handles: HandlesMethods;
2300
+ readonly payees: PayeesMethods;
2301
+ readonly destinations: DestinationsMethods;
2302
+ /**
2303
+ * Direct Payments surface (G2 · #545). `pay` records a validated-recipient
2304
+ * payment; `list`/`get` read the ledger; `markSettled` is the host-execution
2305
+ * callback. The MCP `draft → simulate → approve → execute` workbench is G6.
2306
+ */
2307
+ readonly payments: PaymentsMethods;
2308
+ /** Payment document verification (G2 · #545): re-derive the EIP-712 hash. */
2309
+ readonly paymentDocuments: PaymentDocumentsMethods;
2310
+ /**
2311
+ * Receivables surface (G5 · #548). `create` opens a `PaymentRequest` with a
2312
+ * fixed-amount link; `markSent`/`markViewed`/`cancel` move the funnel;
2313
+ * `collect` settles the receivable into the Payment ledger + mints a receipt
2314
+ * linked by `documentHash`; `list`/`get`/`getByLink`/`reconcile` read it.
2315
+ */
2316
+ readonly paymentRequests: PaymentRequestsMethods;
2317
+ /**
2318
+ * Decomposed workbench + trust substrate (G6 · #549). The MCP
2319
+ * `draft → simulate → approvals.request → execute` workbench: the edge
2320
+ * PROPOSES, the BACKEND mints a one-time plan-bound approval token via the
2321
+ * human's browser (#510), and `execute` consumes it. Taint / idempotency /
2322
+ * stale-state / scope guards are enforced backend-side.
2323
+ */
2324
+ readonly workbench: WorkbenchMethods;
2325
+ /** Sub-account lifecycle (M2 Slice S2a · #267). Transfer lands in S2b. */
2326
+ readonly subAccounts: SubAccountsMethods;
2327
+ /**
2328
+ * Organization domain surface (canon `org-domain-model.md` §C2/§C3, D13).
2329
+ * `createOrg(input)` creates an Org; `orgs()` lists the Orgs you belong to;
2330
+ * `org(orgId)` resolves the entity-scoped bundle (treasury / members / roles
2331
+ * / invite / removeMember / assignRole / spend). Explicit entity scoping —
2332
+ * NO stateful active context (D13). RED until the S1→S4 slices fill it.
2333
+ */
2334
+ readonly createOrg: OrgMethods["createOrg"];
2335
+ readonly orgs: OrgMethods["orgs"];
2336
+ readonly org: OrgMethods["org"];
2337
+ /**
2338
+ * Onboarding domain surface (D-ONBOARD · #669). `completePersonal` /
2339
+ * `completeOrganization` bridge the post-OTP auth → provision bookends:
2340
+ * persist the first identity profile (+ org), then trigger the existing
2341
+ * provisioning lane. Pre-scope — the on-ramp before the D-RELATE actor
2342
+ * scopes. `lifecycle.status` is the single routing source of truth.
2343
+ */
2344
+ readonly onboarding: OnboardingMethods;
2345
+ /**
2346
+ * Internal observation namespace. Consumers MUST NOT drive the actor
2347
+ * directly — use the method bundles instead.
2348
+ *
2349
+ * @internal-use
2350
+ */
2351
+ readonly _internal: {
2352
+ readonly authActor: AuthFlowObserver;
2353
+ /**
2354
+ * Resolved bootstrap for this client instance (chain, auth URLs, etc.).
2355
+ * Off the public surface per production-surface-policy.md (#31).
2356
+ */
2357
+ readonly bootstrap: BootstrapResolution;
2358
+ /**
2359
+ * Dev-only faucet bundle (production-surface-policy.md). `fund` lives here,
2360
+ * NOT on the public `client.accounts` surface.
2361
+ */
2362
+ readonly accounts: AccountsFaucetMethods; /** Telemetry port for error reporting. Used by React hooks to report errors before throwing. */
2363
+ readonly telemetry?: TelemetryPort;
2364
+ readonly close?: () => Promise<void>;
2365
+ };
2366
+ }
2367
+ interface CreateCapxulClientInput {
2368
+ /**
2369
+ * The 13-port `FlowPorts` bundle. The factory narrows this to the
2370
+ * 3-port AuthFlow subset (`authClient`, `clock`, `telemetry`) for
2371
+ * the flow internally, and uses additional ports (`identity`,
2372
+ * `smartAccount`) for the method bundles.
2373
+ */
2374
+ readonly ports: FlowPorts;
2375
+ /**
2376
+ * Bootstrap resolution for this client instance. The factory closes over
2377
+ * `bootstrap.chainId` internally; consumers do not pass a standalone
2378
+ * chainId and no method boundary accepts one.
2379
+ */
2380
+ readonly bootstrap: BootstrapResolution;
2381
+ /**
2382
+ * Optional AuthCachePort. When omitted, `detectAuthCacheAdapter()` selects
2383
+ * the appropriate per-environment adapter (Browser/FileSystem/InMemory).
2384
+ */
2385
+ readonly authCache?: AuthCachePort;
2386
+ /**
2387
+ * Optional AbortSignal reserved for callers that coordinate client lifetime.
2388
+ */
2389
+ readonly signal?: AbortSignal;
2390
+ /**
2391
+ * OTP TTL window in ms. Default 300_000 (5 min).
2392
+ */
2393
+ readonly otpTtlMs?: number;
2394
+ /**
2395
+ * Optional per-call timeout for invoked auth requests.
2396
+ */
2397
+ readonly invokeTimeoutMs?: number;
2398
+ /**
2399
+ * Init-time account readiness target (issue #159 · AC4). The factory
2400
+ * closes over this so `client.account.{getStatus,ensureReady}` don't
2401
+ * need to take a per-call requirement arg. REQUIRED — there is no
2402
+ * hidden default. Consumers building flows that never need a smart
2403
+ * account pass `"none"`; flows that want a counterfactual deposit
2404
+ * address pass `"counterfactual"`; flows that need an on-chain Safe
2405
+ * pass `"deployed"` (deploy path lands in sibling #161).
2406
+ */
2407
+ readonly requirement: AccountRequirement;
2408
+ /**
2409
+ * Consumer-held signer (backend-orchestrated-deploy.md). Required for
2410
+ * `requirement: "deployed"` flows: `provision` reads `getAddress()` and the
2411
+ * deploy path signs the backend's SafeOp digest via `signUserOpHash()`. The
2412
+ * backend orchestrates build + gas + paymaster + submit — the client never
2413
+ * holds an RPC URL, a gas-sponsorship policy, or a bundler.
2414
+ */
2415
+ readonly signer?: CapxulSigner;
2416
+ /**
2417
+ * Optional live Org-deploy lane (canon D10 SDK-orchestrated Org Safe deploy +
2418
+ * D3 RPC treasury). When supplied, `client.createOrg` / `org(id).treasury`
2419
+ * run the live path (real deploy + on-chain balance); when omitted, the
2420
+ * hermetic `$0` path runs (a fresh Org has no on-chain funds). The adapter
2421
+ * that CONSTRUCTS this port (deployer key + RPC + authenticated Convex seam)
2422
+ * is wired by the CLI deploy-stack; the factory only threads it through.
2423
+ */
2424
+ readonly orgDeploymentPort?: OrgPort;
2425
+ /** Locked D6 data-port name. Prefer over `orgDeploymentPort` in new code. */
2426
+ readonly orgPort?: OrgPort;
2427
+ /** S2 deploy/grant/revoke port. S2 uses deploy; S3 adds grant/revoke. */
2428
+ readonly orgRolesDeploymentPort?: OrgRolesDeploymentPort;
2429
+ /** S4 treasury-spend authority + submit port. */
2430
+ readonly orgSpendPort?: OrgSpendPort;
2431
+ readonly orgDeploymentConfig?: SafeDeploymentConfig;
2432
+ }
2433
+ //#endregion
2434
+ //#region src/adapters/auth-cache/BrowserAuthCacheAdapter.d.ts
2435
+ interface BrowserStorageShape {
2436
+ getItem(key: string): string | null;
2437
+ setItem(key: string, value: string): void;
2438
+ removeItem(key: string): void;
2439
+ }
2440
+ //#endregion
2441
+ //#region src/dev-signer.d.ts
2442
+ interface DevPrivateKeySignerInput {
2443
+ /** Dev-only derivation seed (e.g. `VITE_CAPXUL_DEV_SIGNER_SEED`). Throwaway keys only. */
2444
+ readonly seed: string;
2445
+ /** Explicit email — skips the auth-cache lookup (tests, node harnesses). */
2446
+ readonly email?: string;
2447
+ /** Storage holding the cached session. Defaults to browser `localStorage`. */
2448
+ readonly storage?: BrowserStorageShape;
2449
+ }
2450
+ /** Deterministic dev private key for an email under a seed. Exported for probes. */
2451
+ declare function deriveDevPrivateKey(seed: string, email: string): Hex;
2452
+ /**
2453
+ * Browser-safe dev signer. Lazy: the email (and so the key) is resolved at
2454
+ * each `getAddress()` / `signUserOpHash()` from the cached session, so the
2455
+ * same signer instance follows whichever user is signed in.
2456
+ */
2457
+ declare function devPrivateKeySigner(input: DevPrivateKeySignerInput): CapxulSigner;
2458
+ //#endregion
2459
+ //#region src/adapters/openfort/embedded-wallet-port.d.ts
2460
+ /**
2461
+ * Minimal Openfort embedded-wallet surface for hermetic tests and
2462
+ * `openfortEmbeddedSigner`. Keeps Convex / Shield secrets out of the SDK.
2463
+ */
2464
+ interface OpenfortEmbeddedWalletPort {
2465
+ /** Owner EOA address — must stay stable for the lifetime of this port. */
2466
+ getAddress(): Promise<string>;
2467
+ /**
2468
+ * Sign a 32-byte SafeOp digest without EIP-191 prefixing (backend-orchestrated
2469
+ * deploy contract).
2470
+ */
2471
+ signRawDigest(hash: Hex): Promise<Hex>;
2472
+ }
2473
+ /** Openfort `embeddedWallet` subset used by `openfortEmbeddedWalletPort`. */
2474
+ interface OpenfortEmbeddedWalletApi {
2475
+ get(): Promise<{
2476
+ readonly address: string;
2477
+ }>;
2478
+ signMessage(message: string | Uint8Array, options?: {
2479
+ readonly hashMessage?: boolean;
2480
+ readonly arrayifyMessage?: boolean;
2481
+ }): Promise<string>;
2482
+ }
2483
+ declare function openfortEmbeddedWalletPort(input: {
2484
+ readonly embeddedWallet: OpenfortEmbeddedWalletApi;
2485
+ readonly ensureReady?: () => Promise<void>;
2486
+ }): OpenfortEmbeddedWalletPort;
2487
+ //#endregion
2488
+ //#region src/openfort-embedded-signer.d.ts
2489
+ interface OpenfortEmbeddedSignerInput {
2490
+ readonly wallet: OpenfortEmbeddedWalletPort;
2491
+ }
2492
+ /** Browser helper: wrap an initialized Openfort `embeddedWallet` API. */
2493
+ declare function openfortEmbeddedSignerFromWallet(input: {
2494
+ readonly embeddedWallet: OpenfortEmbeddedWalletApi;
2495
+ readonly ensureWalletReady?: () => Promise<void>;
2496
+ }): OpenfortEmbeddedSigner;
2497
+ /**
2498
+ * Browser `CapxulSigner` backed by an Openfort embedded wallet (#335).
2499
+ * Signs the backend's SafeOp digest via raw `signMessage` (no EIP-191 prefix)
2500
+ * and verifies recovery before the backend submits.
2501
+ */
2502
+ type OpenfortEmbeddedSigner = CapxulSigner & {
2503
+ /** Drop cached `getAddress()` so the next read hits the embedded wallet again. */readonly resetAddressCache: () => void;
2504
+ };
2505
+ declare function openfortEmbeddedSigner(input: OpenfortEmbeddedSignerInput): OpenfortEmbeddedSigner;
2506
+ /**
2507
+ * Canonical name for the embedded-wallet `CapxulSigner` constructor
2508
+ * (backend-orchestrated-deploy.md). The embedded-wallet (passkey / Openfort)
2509
+ * member of the named constructor trio `localPrivateKeySigner` /
2510
+ * `injectedWalletSigner` / `embeddedSigner`. Takes the provider-agnostic
2511
+ * `OpenfortEmbeddedWalletPort` (getAddress + signRawDigest); the Openfort-API
2512
+ * convenience wrapper is `openfortEmbeddedSignerFromWallet`.
2513
+ */
2514
+ declare const embeddedSigner: typeof openfortEmbeddedSigner;
2515
+ //#endregion
2516
+ //#region src/production.d.ts
2517
+ /**
2518
+ * Consumer-facing `createCapxulClient` input (SDK DX public surface · #326).
2519
+ * The publishable key is the primary input; bootstrap host, invoke timeout,
2520
+ * runtime detection, and auth-cache selection are SDK-owned defaults.
2521
+ */
2522
+ interface CapxulClientInput {
2523
+ readonly publishableKey: string;
2524
+ /**
2525
+ * Init-time account readiness target (issue #159 · AC4). Threaded into
2526
+ * `assembleCapxulClient` so `client.account.{getStatus,ensureReady}` reflect
2527
+ * the consumer's chosen requirement. Optional — defaults to `"none"` (SDK
2528
+ * publish readiness · I3) so `createCapxulClient({ publishableKey })` works
2529
+ * with no account lane.
2530
+ */
2531
+ readonly requirement?: AccountRequirement;
2532
+ /**
2533
+ * Consumer-held signer (backend-orchestrated-deploy.md). Required for
2534
+ * `requirement: "deployed"` flows: `provision` reads `getAddress()` and the
2535
+ * deploy path signs the backend's SafeOp digest via `signUserOpHash()`. The
2536
+ * backend orchestrates build + gas + paymaster + submit — the client never
2537
+ * holds an RPC URL, a gas-sponsorship policy, or a bundler.
2538
+ */
2539
+ readonly signer?: CapxulSigner;
2540
+ }
2541
+ //#endregion
2542
+ //#region src/client/create-capxul-client-from-production.d.ts
2543
+ /** Consumer-facing factory — accepts only production-meaningful inputs (#326). */
2544
+ declare function createCapxulClient(input: CapxulClientInput): Promise<CapxulResult<CapxulClient>>;
2545
+ //#endregion
2546
+ //#region src/telemetry/capture-exception.d.ts
2547
+ interface HandledErrorReportContext {
2548
+ readonly layer?: string;
2549
+ readonly operation?: string;
2550
+ readonly provider?: string;
2551
+ readonly capxul_error_code?: string;
2552
+ readonly failure_mode?: FailureMode;
2553
+ }
2554
+ /**
2555
+ * Capture an error as a `$exception` event through the telemetry port,
2556
+ * formatted for PostHog Error Tracking.
2557
+ *
2558
+ * Parses stack traces into `$exception_list` format, extracts structured
2559
+ * metadata from CapxulError objects, and supplements with context props.
2560
+ * Fire-and-forget: telemetry defects are silently swallowed.
2561
+ * Returns `Effect<void, never>` for use in Effect pipelines; the underlying
2562
+ * adapter work is synchronous, so callers outside Effect contexts can
2563
+ * use `Effect.runSync`.
2564
+ */
2565
+ declare function captureException(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): Effect.Effect<void, never>;
2566
+ /**
2567
+ * Synchronous fire-and-forget capture. Runs the Effect inline with
2568
+ * `Effect.runSync` so callers outside an Effect context (e.g. React
2569
+ * hooks before throwing) can report errors without awaiting.
2570
+ */
2571
+ declare function captureExceptionSync(telemetry: TelemetryPort, error: unknown, context?: HandledErrorReportContext): void;
2572
+ //#endregion
2573
+ export { type Account, type AccountLifecycle, type AccountMethods, type AccountProvider, type AccountProviderSource, type AccountRequirement, type AccountSetupStep, type AccountsMethods, type ActorProfile, type ActorProfileMethods, type ActorRelationshipMethods, type ActorRequest, type ActorRequestIssueInput, type ActorRequestsMethods, type Address, type AddressBookAddInput, type AddressBookEntry, type AddressBookLabelInput, type AddressBookMethods, type AssignRoleInput, type AuthMethods, type AuthSession, type AuthUserId, type CapxulClient, type CapxulClientInput, type CapxulDigestSigner, type CapxulResult, type CapxulSigner, type CompleteOrganizationOnboardingInput, type CompleteOrganizationOnboardingResult, type CompletePersonalOnboardingInput, type CompletePersonalOnboardingResult, type CreateCapxulClientInput, type CreateOrgInput, type DepositInstructions, type Destination, type DestinationAddInput, type DestinationKind, type DestinationListInput, type DestinationPayload, type DestinationRemoveInput, type DestinationsMethods, type DetectPendingOrgInvitationsResult, type DevPrivateKeySignerInput, type Eip1193Provider, type Eip1193RequestProvider, type FinancialOpsMethods, type HandledErrorReportContext, type HandlesMethods, type IdentityMethods, type InboxApproveInput, type InboxItem, type InboxMethods, type InsightsMethods, type InsightsSummary, type InviteMemberInput, type MeMethods, type MeProfile, type MemberStatus, type MemberView, type Money, type OnboardingMethods, 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 PaymentRequest, type PaymentRequestStatus, type PaymentRequestsCreateInput, type PaymentRequestsMethods, type PaymentSettlementInput, type PaymentStatus, type PaymentTiming, type PaymentType, type PaymentsMethods, type PaymentsPayInput, type PaymentsPayoutInput, type PaymentsWithdrawInput, type PayrollMethods, type PayrollPayslipTemplate, type PayrollRosterAddInput, type PayrollRosterLine, type PayrollRunInput, type Profile, type RecipientResolution, type RecipientResolutionKind, type ReconciliationEntry, type Ref, type RemoveMemberInput, type ResendInviteTokenInput, 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 };
2574
+ //# sourceMappingURL=index.d.mts.map