@capxul/mcp 4.20.0-beta.6 → 4.20.0-beta.8

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 (3) hide show
  1. package/README.md +8 -13
  2. package/dist/main.mjs +770 -274
  3. package/package.json +2 -3
package/dist/main.mjs CHANGED
@@ -2977,6 +2977,28 @@ function getCreate2Address(opts) {
2977
2977
  //#region ../../packages/config/src/org-payments.ts
2978
2978
  /** Zodiac MultiSendCallOnly module on Base Sepolia. */
2979
2979
  const MULTI_SEND_CALL_ONLY = "0x9641d764fc13c8b624c04430c7356c1c7c8102e2";
2980
+ /** Supported Organization permission identities, newest first. */
2981
+ const ORG_PERMISSION_IDENTITY_PROFILES = [{
2982
+ id: "zodiac-roles-2.1.1",
2983
+ moduleFactoryRuntimeKeccak256: "0x01623cbcf010a1c326230f1b2d5f48a66b440232ee49096102bc84967dc5f21e",
2984
+ mastercopy: "0xf2964ce6161ce0e75964fe7927ce114cb0b283d5",
2985
+ mastercopyRuntimeKeccak256: "0x471d8b3b419f1eb955230c0326c8812176df49bf3c7b414a563fda5a3c6c10b6",
2986
+ proxyRuntimeKeccak256: "0x248f9591f94c24c199ade3e73feb477cf02d387b2bea91f2f931a0deb094f163",
2987
+ multiSendUnwrapper: "0xb4cd4bb764c089f20da18700ce8bc5e49f369efd",
2988
+ multiSendUnwrapperRuntimeKeccak256: "0x1f6e088be5e6ef9d0fbe0547d3fa9a9e40d823433fd8a4449215b5663209a1eb"
2989
+ }, {
2990
+ id: "zodiac-roles-2.1.0",
2991
+ moduleFactoryRuntimeKeccak256: "0x01623cbcf010a1c326230f1b2d5f48a66b440232ee49096102bc84967dc5f21e",
2992
+ mastercopy: "0x9646fdad06d3e24444381f44362a3b0eb343d337",
2993
+ mastercopyRuntimeKeccak256: "0x87911cbc6aa0496e6bcb07dab2462b9c76daea130dede6dcc57d0adf307fa7ec",
2994
+ proxyRuntimeKeccak256: "0x9d4059abf46db50e4b48d9b6404b1f200cb5a1efeb3725be2de630a2a9001944",
2995
+ multiSendUnwrapper: "0x93b7fcbc63ed8a3a24b59e1c3e6649d50b7427c0",
2996
+ multiSendUnwrapperRuntimeKeccak256: "0x4d8d8608b70a6e2f40726b9dd74406bbf73e90cac58e23ee953e2b45ad7dc3df"
2997
+ }];
2998
+ const CURRENT_ORG_PERMISSION_IDENTITY = ORG_PERMISSION_IDENTITY_PROFILES[0];
2999
+ ORG_PERMISSION_IDENTITY_PROFILES[1];
3000
+ CURRENT_ORG_PERMISSION_IDENTITY.mastercopy;
3001
+ CURRENT_ORG_PERMISSION_IDENTITY.multiSendUnwrapper;
2980
3002
  //#endregion
2981
3003
  //#region ../../packages/config/src/safe.ts
2982
3004
  const BASE_SEPOLIA_CHAIN_ID = 84532;
@@ -3207,14 +3229,6 @@ function normalizeBindingEmail(email) {
3207
3229
  //#endregion
3208
3230
  //#region ../../packages/config/src/role-dsl.ts
3209
3231
  const ADMIN_ROLE_LABEL = "Admin";
3210
- function normalizeOrgRoleLabel(label) {
3211
- const normalized = label.trim().replace(/\s+/g, " ");
3212
- if (normalized.length === 0) throw Errors.invalidInput("role.label", "must be a non-empty role label");
3213
- return normalized;
3214
- }
3215
- function orgRoleKeyForLabel(label) {
3216
- return keccak256$1(toBytes$1(normalizeOrgRoleLabel(label).toLowerCase()));
3217
- }
3218
3232
  //#endregion
3219
3233
  //#region ../../packages/config/src/capxul-payments-v2.ts
3220
3234
  /** The exact compiled CapxulPaymentsV2 ABI. */
@@ -7223,10 +7237,12 @@ const CAPXUL_OPERATIONS = {
7223
7237
  prepareOrganizationPaymentExecution: "moneyExecution.prepareOrganizationPaymentExecution",
7224
7238
  preparePaymentExecution: "moneyExecution.preparePaymentExecution",
7225
7239
  preparePaymentLifecycleExecution: "moneyExecution.preparePaymentLifecycleExecution",
7240
+ prepareInvitationConfiguration: "moneyExecution.prepareInvitationConfiguration",
7226
7241
  preparePermissionExecution: "moneyExecution.preparePermissionExecution",
7227
7242
  recoverSubmissionClaims: "moneyExecution.recoverSubmissionClaims",
7228
7243
  submit: "moneyExecution.submit",
7229
7244
  submitPaymentCommandExecution: "moneyExecution.submitPaymentCommandExecution",
7245
+ submitInvitationConfigurationExecution: "moneyExecution.submitInvitationConfigurationExecution",
7230
7246
  submitPaymentExecution: "moneyExecution.submitPaymentExecution",
7231
7247
  submitPermissionExecution: "moneyExecution.submitPermissionExecution"
7232
7248
  },
@@ -7248,20 +7264,52 @@ const CAPXUL_OPERATIONS = {
7248
7264
  completePerson: "onboarding.completePerson"
7249
7265
  },
7250
7266
  org: {
7251
- acceptInvitations: "org.acceptInvitations",
7252
7267
  account: { get: "org.account.get" },
7253
- activateMember: "org.activateMember",
7254
7268
  auditLog: "org.auditLog",
7255
7269
  confirmBootstrap: "org.confirmBootstrap",
7256
7270
  createOrg: "org.createOrg",
7257
7271
  create: "org.create",
7258
- detectAndAcceptPendingInvitations: "org.detectAndAcceptPendingInvitations",
7272
+ /**
7273
+ * §11: the consent mutation reports `org_invite_accepted` through its own
7274
+ * scheduled emitter. It is named for the emit, not the acceptance, because
7275
+ * the interactive acceptance itself owns `org.invitations.accept`.
7276
+ */
7277
+ emitInviteAccepted: "org.emitInviteAccepted",
7259
7278
  emitInviteProgressed: "org.emitInviteProgressed",
7260
7279
  expireInvitations: "org.expireInvitations",
7261
7280
  getLifecycle: "org.getLifecycle",
7262
7281
  getProofReceipt: "org.getProofReceipt",
7263
7282
  invite: "org.invite",
7264
- inviteMember: "org.inviteMember",
7283
+ /** D8 invitation lifecycle: preview, own list, read, and the four transitions. */
7284
+ invitations: {
7285
+ /** The exact grantee's consent commit (§8): one accepted digest, once. */
7286
+ accept: "org.invitations.accept",
7287
+ /**
7288
+ * The authoring write. It is named `authorize`, not `invite`, because the
7289
+ * backend already uses `org.invitations.invite` as a refusal label and
7290
+ * `lint:telemetry-spine` refuses a label that collides with an operation.
7291
+ */
7292
+ authorize: "org.invitations.authorize",
7293
+ cancel: "org.invitations.cancel",
7294
+ decline: "org.invitations.decline",
7295
+ get: "org.invitations.get",
7296
+ list: "org.invitations.list",
7297
+ /**
7298
+ * The Admin-scoped Organization list. It is named `listScoped`, not
7299
+ * `list`, because the own-offer list already owns `org.invitations.list`.
7300
+ */
7301
+ listScoped: "org.invitations.listScoped",
7302
+ /**
7303
+ * The authoring write's inner hops: the SDK drives the backend's existing
7304
+ * prepare/submit pair, and these names label the two Convex calls. The
7305
+ * owning `capxul_sdk_operation` record stays `org.invitations.authorize`.
7306
+ */
7307
+ prepareConfiguration: "org.invitations.prepareConfiguration",
7308
+ preview: "org.invitations.preview",
7309
+ resend: "org.invitations.resend",
7310
+ retry: "org.invitations.retry",
7311
+ submitConfiguration: "org.invitations.submitConfiguration"
7312
+ },
7265
7313
  list: "org.list",
7266
7314
  load: "org.load",
7267
7315
  me: "org.me",
@@ -7320,7 +7368,6 @@ const CAPXUL_OPERATIONS = {
7320
7368
  },
7321
7369
  recordFailure: "org.recordFailure",
7322
7370
  recordProgress: "org.recordProgress",
7323
- resendInviteToken: "org.resendInviteToken",
7324
7371
  resumeBootstrapSubmission: "org.resumeBootstrapSubmission",
7325
7372
  retry: "org.retry",
7326
7373
  retrySetup: "org.retrySetup",
@@ -7337,7 +7384,6 @@ const CAPXUL_OPERATIONS = {
7337
7384
  retry: "organizationPayments.retry"
7338
7385
  },
7339
7386
  organizationSetup: { getProofReceipt: "organizationSetup.getProofReceipt" },
7340
- organizations: { detectAndAcceptPendingInvitations: "orgs.detectAndAcceptPendingInvitations" },
7341
7387
  payments: {
7342
7388
  cancel: "payments.cancel",
7343
7389
  claim: "payments.claim",
@@ -7375,6 +7421,7 @@ const CAPXUL_OPERATIONS = {
7375
7421
  terms: "payroll.terms"
7376
7422
  },
7377
7423
  permission: {
7424
+ verifyInvitationConfiguration: "permission.verifyInvitationConfiguration",
7378
7425
  command: "permission.command",
7379
7426
  retryVerification: "permission.retryVerification",
7380
7427
  verify: "permission.verify",
@@ -7917,6 +7964,11 @@ const OrgCreateFailedProps = Schema.Struct({
7917
7964
  const OrgInviteSentProps = Schema.Struct({
7918
7965
  ...TelemetryEnvelopeProps,
7919
7966
  org_id: OptionalOrgId,
7967
+ invitation_id: OptionalString,
7968
+ generation: OptionalString,
7969
+ command_id: OptionalString,
7970
+ subject_party_id: OptionalString,
7971
+ persisted_at: OptionalEpochMs,
7920
7972
  email_domain: OptionalString,
7921
7973
  role: OptionalString,
7922
7974
  status: OptionalString
@@ -7924,6 +7976,11 @@ const OrgInviteSentProps = Schema.Struct({
7924
7976
  const OrgInviteAcceptedProps = Schema.Struct({
7925
7977
  ...TelemetryEnvelopeProps,
7926
7978
  org_id: OptionalOrgId,
7979
+ invitation_id: OptionalString,
7980
+ accepted_at: OptionalEpochMs,
7981
+ generation: OptionalString,
7982
+ command_id: OptionalString,
7983
+ subject_party_id: OptionalString,
7927
7984
  role: OptionalString,
7928
7985
  status: OptionalString
7929
7986
  });
@@ -7931,6 +7988,7 @@ const OrgInviteExpiredProps = Schema.Struct({
7931
7988
  ...TelemetryEnvelopeProps,
7932
7989
  org_id: OptionalOrgId,
7933
7990
  email_domain: OptionalString,
7991
+ invitation_id: OptionalString,
7934
7992
  reason: OptionalString,
7935
7993
  role: OptionalString,
7936
7994
  status: OptionalString
@@ -8083,9 +8141,24 @@ const PermissionMirrorVerificationProps = Schema.Struct({
8083
8141
  "applied",
8084
8142
  "replayed",
8085
8143
  "conflicting_replay",
8086
- "revision_mismatch"
8144
+ "revision_mismatch",
8145
+ "cleanup_required",
8146
+ "not_applied",
8147
+ "application_failure",
8148
+ "mismatch",
8149
+ "refused"
8087
8150
  ])),
8151
+ command_kind: Schema.optional(Schema.Literals(["invitation_configuration", "invitation_eoa"])),
8088
8152
  command_id: OptionalString,
8153
+ invitation_id: OptionalString,
8154
+ generation: OptionalString,
8155
+ purpose: Schema.optional(Schema.Literals([
8156
+ "configure",
8157
+ "grant",
8158
+ "disable",
8159
+ "compensate"
8160
+ ])),
8161
+ $insert_id: OptionalString,
8089
8162
  /**
8090
8163
  * #1961 R03. The authorized stored row names the Permission it changed; the
8091
8164
  * verified receipt names the chain facts that prove it. Every field is
@@ -8472,6 +8545,13 @@ const CLI_COMMAND_NAMES = [
8472
8545
  "auth.profile",
8473
8546
  "auth.status",
8474
8547
  "auth.logout",
8548
+ "contact",
8549
+ "contact.list",
8550
+ "contact.get",
8551
+ "contact.add",
8552
+ "contact.label",
8553
+ "contact.hide",
8554
+ "contact.unhide",
8475
8555
  "org",
8476
8556
  CAPXUL_OPERATIONS.org.list,
8477
8557
  "org.use",
@@ -8480,6 +8560,24 @@ const CLI_COMMAND_NAMES = [
8480
8560
  CAPXUL_OPERATIONS.org.members,
8481
8561
  "org.member",
8482
8562
  "org.member.get",
8563
+ "org.member.invite",
8564
+ "org.contact",
8565
+ "org.contact.list",
8566
+ "org.contact.get",
8567
+ "org.contact.add",
8568
+ "org.contact.label",
8569
+ "org.contact.hide",
8570
+ "org.contact.unhide",
8571
+ CAPXUL_OPERATIONS.org.invite,
8572
+ "org.invite.list",
8573
+ "org.invite.get",
8574
+ "org.invite.wait",
8575
+ "org.invite.review",
8576
+ "org.invite.accept",
8577
+ "org.invite.decline",
8578
+ "org.invite.cancel",
8579
+ "org.invite.resend",
8580
+ "org.invite.retry",
8483
8581
  "org.wait",
8484
8582
  CAPXUL_OPERATIONS.org.create,
8485
8583
  CAPXUL_OPERATIONS.org.retry,
@@ -8490,7 +8588,8 @@ const CLI_CAPABILITIES = [
8490
8588
  "diagnostics",
8491
8589
  "collection",
8492
8590
  "authentication",
8493
- "organization"
8591
+ "organization",
8592
+ "contacts"
8494
8593
  ];
8495
8594
  const CLI_INVOCATION_KINDS = [
8496
8595
  "command",
@@ -8732,6 +8831,7 @@ Schema.Struct({
8732
8831
  ...TelemetryEnvelopeProps,
8733
8832
  organization_id: OrgIdTelemetrySchema,
8734
8833
  progress: Schema.Literals([
8834
+ "configuration_authorized",
8735
8835
  "account_ready",
8736
8836
  "permission_applied",
8737
8837
  "membership_activated",
@@ -8739,6 +8839,9 @@ Schema.Struct({
8739
8839
  ]),
8740
8840
  /** The invited Party. The initiating actor stays on the envelope's identity. */
8741
8841
  member_party_id: Schema.String,
8842
+ invitation_id: Schema.optional(Schema.String),
8843
+ generation: Schema.optional(Schema.String),
8844
+ command_id: Schema.optional(Schema.String),
8742
8845
  occurred_at: Schema.Number
8743
8846
  })
8744
8847
  });
@@ -9291,8 +9394,10 @@ const CAPXUL_FUNCTIONS = {
9291
9394
  "movement/annotations": { overlay: "movement/annotations:overlay" },
9292
9395
  "moneyExecution/actions": {
9293
9396
  abandonPaymentExecution: "moneyExecution/actions:abandonPaymentExecution",
9397
+ prepareInvitationConfiguration: "moneyExecution/actions:prepareInvitationConfiguration",
9294
9398
  preparePermissionExecution: "moneyExecution/actions:preparePermissionExecution",
9295
9399
  preparePaymentExecution: "moneyExecution/actions:preparePaymentExecution",
9400
+ submitInvitationConfigurationExecution: "moneyExecution/actions:submitInvitationConfigurationExecution",
9296
9401
  submitPermissionExecution: "moneyExecution/actions:submitPermissionExecution",
9297
9402
  submitPaymentExecution: "moneyExecution/actions:submitPaymentExecution"
9298
9403
  },
@@ -9309,8 +9414,6 @@ const CAPXUL_FUNCTIONS = {
9309
9414
  },
9310
9415
  "org/actions": {
9311
9416
  confirmBootstrap: "org/actions:confirmBootstrap",
9312
- detectAndAcceptPendingInvitations: "org/actions:detectAndAcceptPendingInvitations",
9313
- inviteMember: "org/actions:inviteMember",
9314
9417
  prepareBootstrap: "org/actions:prepareBootstrap",
9315
9418
  prepareFounderAccount: "org/actions:prepareFounderAccount",
9316
9419
  readTreasury: "org/actions:readTreasury",
@@ -9341,16 +9444,25 @@ const CAPXUL_FUNCTIONS = {
9341
9444
  startOrResume: "org/lifecycle:startOrResume"
9342
9445
  },
9343
9446
  "org/mutations": {
9447
+ accept: "org/mutations:accept",
9448
+ cancel: "org/mutations:cancel",
9344
9449
  createOrg: "org/mutations:createOrg",
9345
- resendInviteToken: "org/mutations:resendInviteToken"
9450
+ decline: "org/mutations:decline",
9451
+ invite: "org/mutations:invite",
9452
+ resend: "org/mutations:resend",
9453
+ retry: "org/mutations:retry"
9346
9454
  },
9347
9455
  "org/queries": {
9456
+ getInvitation: "org/queries:getInvitation",
9348
9457
  listAll: "org/queries:listAll",
9458
+ listInvitations: "org/queries:listInvitations",
9349
9459
  listMembersByOrgId: "org/queries:listMembersByOrgId",
9350
9460
  listMine: "org/queries:listMine",
9461
+ listMyInvitations: "org/queries:listMyInvitations",
9351
9462
  listRolesByOrgId: "org/queries:listRolesByOrgId",
9352
9463
  loadByOrgId: "org/queries:loadByOrgId",
9353
- me: "org/queries:me"
9464
+ me: "org/queries:me",
9465
+ previewInvite: "org/queries:previewInvite"
9354
9466
  },
9355
9467
  "smartAccount/actions": {
9356
9468
  claim: "smartAccount/actions:claim",
@@ -10310,6 +10422,94 @@ const EventRefSchema = Schema.Struct({
10310
10422
  topic0: Bytes32Schema,
10311
10423
  dataHash: Bytes32Schema
10312
10424
  });
10425
+ const InvitationEoaReceiptSchema = Schema.Struct({
10426
+ kind: Schema.Literal("invitation_eoa"),
10427
+ chainId: BaseSepoliaChainIdSchema,
10428
+ transactionHash: TxHashSchema,
10429
+ blockNumber: BlockNumberSchema,
10430
+ blockHash: Bytes32Schema,
10431
+ sender: AddressSchema,
10432
+ nonce: Schema.String.pipe(Schema.refine((value) => /^(0|[1-9][0-9]*)$/.test(value)))
10433
+ });
10434
+ const PermissionReceiptRefSchema = Schema.Union([Schema.Struct({
10435
+ kind: Schema.Literal("user_operation"),
10436
+ ...ReceiptRefSchema.fields
10437
+ }), InvitationEoaReceiptSchema]);
10438
+ const PermissionEventRefSchema = Schema.Struct({
10439
+ receipt: PermissionReceiptRefSchema,
10440
+ emitter: AddressSchema,
10441
+ transactionIndex: LogIndexSchema,
10442
+ logIndex: LogIndexSchema,
10443
+ topic0: Bytes32Schema,
10444
+ dataHash: Bytes32Schema
10445
+ });
10446
+ Schema.Union([
10447
+ Schema.Struct({
10448
+ status: Schema.Literal("pending"),
10449
+ reason: Schema.Literal("receipt_missing")
10450
+ }),
10451
+ Schema.Struct({
10452
+ status: Schema.Literal("provider_failure"),
10453
+ retryable: Schema.Literal(true)
10454
+ }),
10455
+ Schema.Struct({
10456
+ status: Schema.Literal("mismatch"),
10457
+ code: Schema.Literals([
10458
+ "wrong_chain",
10459
+ "wrong_sender",
10460
+ "wrong_transaction",
10461
+ "failed_transaction",
10462
+ "non_canonical_block",
10463
+ "wrong_contract_identity",
10464
+ "missing_event",
10465
+ "extra_authority_event",
10466
+ "wrong_fact_tuple",
10467
+ "wrong_state",
10468
+ "conflicting_replay"
10469
+ ]),
10470
+ attemptTransactionHash: Schema.optional(TxHashSchema),
10471
+ receipt: Schema.optional(InvitationEoaReceiptSchema)
10472
+ }),
10473
+ Schema.Struct({
10474
+ status: Schema.Literal("verified"),
10475
+ commandId: PaymentCommandIdSchema,
10476
+ receipt: InvitationEoaReceiptSchema,
10477
+ events: Schema.Array(PermissionEventRefSchema),
10478
+ factsHash: Bytes32Schema
10479
+ })
10480
+ ]);
10481
+ /**
10482
+ * One stored `setAllowance` call inside a command's expected authority set.
10483
+ *
10484
+ * The pinned Roles module emits `SetAllowance` as *post-state*, not as the call
10485
+ * arguments: `maxRefill = 0` becomes `type(uint128).max`, and `timestamp = 0`
10486
+ * becomes the receipt block's timestamp. A hash over the call arguments can
10487
+ * therefore never match that receipt. `index` names the entry in
10488
+ * `expectedAuthorityEvents` the call produced, and `data` is the call's own
10489
+ * calldata, so the verifier can rebuild the one hash the module actually emits.
10490
+ * The rule is pinned by `test:invitation-conformance`.
10491
+ */
10492
+ const AllowanceExpectationSchema = Schema.Struct({
10493
+ index: nonNegativeInteger("index"),
10494
+ data: Schema.String.pipe(Schema.refine((value) => /^0x[0-9a-fA-F]+$/u.test(value), { message: "data must be 0x-prefixed hex" }))
10495
+ });
10496
+ Schema.Struct({
10497
+ commandId: PaymentCommandIdSchema,
10498
+ userOpHash: Bytes32Schema,
10499
+ generationHash: Bytes32Schema,
10500
+ chainId: BaseSepoliaChainIdSchema,
10501
+ organizationSafe: SafeAddressSchema,
10502
+ rolesModule: ModuleAddressSchema,
10503
+ userOpSenderSafe: SafeAddressSchema,
10504
+ expectedAuthorityEvents: Schema.Array(Bytes32Schema),
10505
+ /**
10506
+ * Absent means "no normalization": every expected hash is compared as stored.
10507
+ * A command whose set contains `setAllowance` then refuses (`wrong_fact_tuple`)
10508
+ * rather than passing on a weakened proof, so an incomplete caller fails
10509
+ * closed.
10510
+ */
10511
+ allowanceExpectations: Schema.optional(Schema.Array(AllowanceExpectationSchema))
10512
+ });
10313
10513
  const PermissionOperationSchema = Schema.Literals([
10314
10514
  "create",
10315
10515
  "change",
@@ -10353,7 +10553,9 @@ const StoredPermissionCommandSchema = Schema.Struct({
10353
10553
  });
10354
10554
  Schema.Struct({
10355
10555
  command: StoredPermissionCommandSchema,
10356
- userOpHash: Bytes32Schema
10556
+ userOpHash: Bytes32Schema,
10557
+ /** The stored `setAllowance` calls of this command's own expectation. */
10558
+ allowanceExpectations: Schema.optional(Schema.Array(AllowanceExpectationSchema))
10357
10559
  });
10358
10560
  Schema.Union([
10359
10561
  Schema.Struct({
@@ -11197,6 +11399,27 @@ Schema.Struct({
11197
11399
  digest: Bytes32Schema,
11198
11400
  value: PermissionResourceSchema
11199
11401
  });
11402
+ Schema.Struct({
11403
+ commandId: PaymentCommandIdSchema,
11404
+ signerAddress: AddressSchema
11405
+ });
11406
+ Schema.Struct({
11407
+ executionId: MoneyExecutionIdSchema,
11408
+ commandId: PaymentCommandIdSchema,
11409
+ orgId: nonEmpty("orgId"),
11410
+ invitationId: nonEmpty("invitationId"),
11411
+ generationHash: Bytes32Schema,
11412
+ chainId: BaseSepoliaChainIdSchema,
11413
+ signerAddress: AddressSchema,
11414
+ userOpSenderSafe: SafeAddressSchema,
11415
+ digest: Bytes32Schema
11416
+ });
11417
+ Schema.Struct({
11418
+ status: Schema.Literal("submitted"),
11419
+ executionId: MoneyExecutionIdSchema,
11420
+ commandId: PaymentCommandIdSchema,
11421
+ userOpHash: Bytes32Schema
11422
+ });
11200
11423
  Schema.Struct({
11201
11424
  status: Schema.Literal("submitted"),
11202
11425
  executionId: MoneyExecutionIdSchema,
@@ -11770,6 +11993,160 @@ const CurrentPolicySchema = Schema.Union([Schema.Struct({
11770
11993
  actions: Schema.NonEmptyArray(Schema.Literals(["pay", "commitments"]))
11771
11994
  })
11772
11995
  }), Schema.Struct({ type: Schema.Literal("managePeople") })]);
11996
+ const BudgetIntentSchema = CurrentPolicySchema.pipe(Schema.refine((value) => {
11997
+ if (value.type !== "budget") return false;
11998
+ const { actions, recipients } = value.scope;
11999
+ if (new Set(actions).size !== actions.length) return false;
12000
+ return recipients.type === "anyone" || recipients.accounts.length >= 1 && recipients.accounts.length <= 32 && new Set(recipients.accounts).size === recipients.accounts.length;
12001
+ }));
12002
+ const InvitationIdSchema = Schema.NonEmptyString;
12003
+ const InvitationTargetSchema = Schema.Struct({ invitationId: InvitationIdSchema });
12004
+ Schema.Struct({
12005
+ ...InvitationTargetSchema.fields,
12006
+ expectedOfferDigest: Bytes32Schema
12007
+ });
12008
+ /** The requested grantee of one invitation. */
12009
+ const GranteeRefSchema = Schema.Union([Schema.Struct({
12010
+ type: Schema.Literal("email"),
12011
+ email: Schema.NonEmptyString
12012
+ }), Schema.Struct({
12013
+ type: Schema.Literal("account"),
12014
+ accountId: AccountIdSchema
12015
+ })]);
12016
+ Schema.Struct({
12017
+ requestKey: Schema.String.pipe(Schema.refine((value) => /^[\x20-\x7e]{1,128}$/.test(value))),
12018
+ to: GranteeRefSchema,
12019
+ grants: Schema.Array(Schema.Union([
12020
+ Schema.Struct({
12021
+ type: Schema.Literal("budget"),
12022
+ budgetId: PermissionIdSchema
12023
+ }),
12024
+ Schema.Struct({
12025
+ type: Schema.Literal("managePeople"),
12026
+ permissionId: PermissionIdSchema
12027
+ }),
12028
+ Schema.Struct({
12029
+ type: Schema.Literal("new_budget"),
12030
+ label: Schema.String.pipe(Schema.refine((value) => value.trim().length >= 1 && value.trim().length <= 128)),
12031
+ intent: BudgetIntentSchema
12032
+ })
12033
+ ]))
12034
+ }).pipe(Schema.refine((value) => {
12035
+ if (value.grants.length < 1 || value.grants.length > 16) return false;
12036
+ const existing = value.grants.flatMap((grant) => grant.type === "new_budget" ? [] : [grant.type === "budget" ? grant.budgetId : grant.permissionId]);
12037
+ return new Set(existing).size === existing.length && value.grants.filter((grant) => grant.type === "new_budget").length <= 4;
12038
+ }));
12039
+ const InvitationPhaseSchema = Schema.Literals([
12040
+ "authorizing",
12041
+ "pending",
12042
+ "pending_grant",
12043
+ "active",
12044
+ "revoking",
12045
+ "declined",
12046
+ "cancelled",
12047
+ "expired",
12048
+ "revoked"
12049
+ ]);
12050
+ const EndingReasonSchema = Schema.Literals([
12051
+ "declined",
12052
+ "cancelled",
12053
+ "expired",
12054
+ "revoked"
12055
+ ]);
12056
+ const OfferedAuthoritySchema = Schema.Union([Schema.Struct({
12057
+ type: Schema.Literal("budget"),
12058
+ budgetId: Schema.NonEmptyString.pipe(Schema.refine((value) => value.length > 0)),
12059
+ label: Schema.String,
12060
+ policy: BudgetIntentSchema,
12061
+ policyDigest: Bytes32Schema
12062
+ }), Schema.Struct({
12063
+ type: Schema.Literal("managePeople"),
12064
+ permissionId: PermissionIdSchema,
12065
+ label: Schema.String
12066
+ })]);
12067
+ const NewBudgetOfferSchema = Schema.Struct({
12068
+ type: Schema.Literal("new_budget"),
12069
+ label: Schema.String,
12070
+ policy: BudgetIntentSchema,
12071
+ policyDigest: Bytes32Schema
12072
+ });
12073
+ const PreviewGranteeSchema = Schema.Struct({
12074
+ partyId: Schema.NullOr(PartyIdSchema),
12075
+ accountId: Schema.NullOr(AccountIdSchema),
12076
+ safeAddress: AddressSchema,
12077
+ accountReady: Schema.NullOr(Schema.Boolean)
12078
+ });
12079
+ Schema.Struct({
12080
+ orgId: Schema.NonEmptyString.pipe(Schema.refine((value) => value.length > 0)),
12081
+ grantee: PreviewGranteeSchema,
12082
+ grants: Schema.Array(Schema.Union([OfferedAuthoritySchema, NewBudgetOfferSchema])),
12083
+ existingAssignments: Schema.Array(PermissionAssignmentIdSchema),
12084
+ includesManagement: Schema.Boolean,
12085
+ observedAt: EpochMsSchema
12086
+ });
12087
+ Schema.Struct({
12088
+ cursor: Schema.optional(Schema.NonEmptyString),
12089
+ limit: Schema.optional(Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 1 && value <= 100))),
12090
+ phases: Schema.optional(Schema.Array(InvitationPhaseSchema).pipe(Schema.refine((value) => new Set(value).size === value.length)))
12091
+ });
12092
+ const InvitationRecoverySchema = Schema.Struct({
12093
+ actor: Schema.Literals([
12094
+ "system",
12095
+ "invitee",
12096
+ "admin"
12097
+ ]),
12098
+ action: Schema.Literals([
12099
+ "wait",
12100
+ "retry",
12101
+ "review_offer",
12102
+ "reauthorize"
12103
+ ]),
12104
+ reason: Schema.Literals([
12105
+ "configuration_pending",
12106
+ "grant_pending",
12107
+ "provider_unavailable",
12108
+ "policy_changed",
12109
+ "cleanup_pending",
12110
+ "signer_unavailable"
12111
+ ])
12112
+ });
12113
+ const InvitationViewSchema = Schema.Struct({
12114
+ id: InvitationIdSchema,
12115
+ orgId: Schema.NonEmptyString.pipe(Schema.refine((value) => value.length > 0)),
12116
+ organizationName: Schema.String,
12117
+ grantee: Schema.Struct({
12118
+ partyId: PartyIdSchema,
12119
+ accountId: Schema.NullOr(AccountIdSchema),
12120
+ safeAddress: AddressSchema,
12121
+ accountReady: Schema.NullOr(Schema.Boolean)
12122
+ }),
12123
+ phase: InvitationPhaseSchema,
12124
+ grants: Schema.Array(Schema.Union([Schema.Struct({
12125
+ type: Schema.Literal("budget"),
12126
+ budgetId: Schema.NonEmptyString.pipe(Schema.refine((value) => value.length > 0))
12127
+ }), Schema.Struct({
12128
+ type: Schema.Literal("managePeople"),
12129
+ permissionId: PermissionIdSchema
12130
+ })])),
12131
+ offers: Schema.Array(OfferedAuthoritySchema),
12132
+ recovery: Schema.NullOr(InvitationRecoverySchema),
12133
+ offerDigest: Bytes32Schema,
12134
+ authorizedAt: Schema.NullOr(EpochMsSchema),
12135
+ acceptedAt: Schema.NullOr(EpochMsSchema),
12136
+ expiresAt: Schema.NullOr(EpochMsSchema),
12137
+ commandId: Schema.NullOr(PaymentCommandIdSchema),
12138
+ endingReason: Schema.NullOr(EndingReasonSchema),
12139
+ delivery: Schema.Literals([
12140
+ "not_confirmed",
12141
+ "sent",
12142
+ "failed"
12143
+ ])
12144
+ });
12145
+ Schema.Struct({
12146
+ items: Schema.Array(InvitationViewSchema),
12147
+ nextCursor: Schema.NullOr(Schema.NonEmptyString),
12148
+ observedAt: EpochMsSchema
12149
+ });
11773
12150
  const ActiveBudgetSchema = Schema.Struct({
11774
12151
  id: PermissionIdSchema,
11775
12152
  label: Schema.String,
@@ -12052,6 +12429,18 @@ function withInvocationParentSpan(effect, controls) {
12052
12429
  const parent = controls?.[INVOCATION_PARENT_SPAN];
12053
12430
  return parent === void 0 ? effect : effect.pipe(Effect.withParentSpan(parent));
12054
12431
  }
12432
+ /**
12433
+ * The input field a refused request named.
12434
+ *
12435
+ * The surfaces that call the port directly already carry `details.field` for an
12436
+ * `INVALID_INPUT` refusal. The actor keeps that one allowlisted detail instead of
12437
+ * dropping it, so a caller sees the same refusal either way.
12438
+ */
12439
+ const refusedInputField = (failure) => {
12440
+ if (failure.code !== "INVALID_INPUT") return void 0;
12441
+ const field = failure.error?.details?.field;
12442
+ return typeof field === "string" && field.length > 0 ? { field } : void 0;
12443
+ };
12055
12444
  var ActorFailure = class extends Error {
12056
12445
  reason;
12057
12446
  machine;
@@ -12217,7 +12606,7 @@ const boot = (spec, options = {}) => Effect.gen(function* () {
12217
12606
  const event = { _tag: env.origin.event };
12218
12607
  const failedState = exit.failure === timeoutFailure || exit.failure === cancelledFailure ? yield* recoverFailure(state, env.origin, exit.failure) : state;
12219
12608
  yield* emit(nonApplied(failedState, event, exit.failure.code, outcome, env, exit.failure));
12220
- const details = exit.failure === timeoutFailure ? { reason: "timeout" } : void 0;
12609
+ const details = exit.failure === timeoutFailure ? { reason: "timeout" } : refusedInputField(exit.failure);
12221
12610
  yield* failReply(held.reply, makeFailure(failedState, event, exit.failure.code, details, exit.failure.error ?? exit.failure));
12222
12611
  return;
12223
12612
  }
@@ -13689,11 +14078,13 @@ const financialOpsContract = {
13689
14078
  //#region ../../packages/sdk/src/contract/money-execution.ts
13690
14079
  const moneyExecutionContract = {
13691
14080
  abandonPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].abandonPaymentExecution),
14081
+ prepareInvitationConfiguration: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].prepareInvitationConfiguration),
13692
14082
  preparePermissionExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePermissionExecution),
13693
14083
  preparePaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePaymentExecution),
13694
14084
  prepareOrganizationPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].prepareOrganizationPaymentExecution),
13695
14085
  preparePaymentLifecycleExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].preparePaymentLifecycleExecution),
13696
14086
  submitPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPaymentExecution),
14087
+ submitInvitationConfigurationExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitInvitationConfigurationExecution),
13697
14088
  submitPermissionExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPermissionExecution),
13698
14089
  submitPaymentCommandExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].submitPaymentCommandExecution)
13699
14090
  };
@@ -14274,7 +14665,7 @@ function subscribeActivity(deps, actor, controls, onChange) {
14274
14665
  }
14275
14666
  //#endregion
14276
14667
  //#region ../../packages/sdk/package.json
14277
- var version$1 = "4.20.0-beta.6";
14668
+ var version$1 = "4.20.0-beta.8";
14278
14669
  //#endregion
14279
14670
  //#region ../../packages/sdk/src/telemetry/exception-projection.ts
14280
14671
  /** Fixed fallback for failures that have no safe message. */
@@ -14901,7 +15292,7 @@ function isMoneyTelemetryDebugEnabled() {
14901
15292
  }
14902
15293
  //#endregion
14903
15294
  //#region ../../packages/sdk/src/surface/payment-command-execution.ts
14904
- function isAborted$2(signal) {
15295
+ function isAborted$3(signal) {
14905
15296
  return signal?.aborted === true;
14906
15297
  }
14907
15298
  function canonicalJson(value) {
@@ -14927,7 +15318,7 @@ async function abandonPrepared$1(deps, executionId, closePayment, reason, result
14927
15318
  return result;
14928
15319
  }
14929
15320
  async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls) {
14930
- if (isAborted$2(signal)) return {
15321
+ if (isAborted$3(signal)) return {
14931
15322
  ok: false,
14932
15323
  error: Errors.cancelled({ operation: "payments" })
14933
15324
  };
@@ -14956,7 +15347,7 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
14956
15347
  ok: false,
14957
15348
  error: Errors.invalidInput("payment", "prepared authority mismatch")
14958
15349
  }, onPreparedClosed, controls);
14959
- if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
15350
+ if (isAborted$3(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
14960
15351
  ok: false,
14961
15352
  error: Errors.cancelled({ operation: "payments" })
14962
15353
  }, onPreparedClosed, controls);
@@ -14982,7 +15373,7 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
14982
15373
  error: signerFailure(deps.signer.source, "signUserOpHash", cause)
14983
15374
  }, onPreparedClosed, controls);
14984
15375
  }
14985
- if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
15376
+ if (isAborted$3(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
14986
15377
  ok: false,
14987
15378
  error: Errors.cancelled({ operation: "payments" })
14988
15379
  }, onPreparedClosed, controls);
@@ -15017,7 +15408,7 @@ function cancelled(operation) {
15017
15408
  error: Errors.cancelled({ operation })
15018
15409
  };
15019
15410
  }
15020
- function isAborted$1(signal) {
15411
+ function isAborted$2(signal) {
15021
15412
  return signal?.aborted === true;
15022
15413
  }
15023
15414
  async function signerCall(source, operation, run) {
@@ -15043,7 +15434,7 @@ async function abandonPrepared(deps, executionId, reason, result, onPreparedClos
15043
15434
  return result;
15044
15435
  }
15045
15436
  async function executePersonalPayment(deps, payment, signal, requestKey, onPreparedClosed) {
15046
- if (isAborted$1(signal)) return cancelled(CAPXUL_OPERATIONS.payments.pay);
15437
+ if (isAborted$2(signal)) return cancelled(CAPXUL_OPERATIONS.payments.pay);
15047
15438
  if (deps.signer === void 0) return mismatch("signer", "payments.pay requires a configured CapxulSigner");
15048
15439
  const session = deps.actor.authSession();
15049
15440
  if (session === null) return {
@@ -15071,10 +15462,10 @@ async function executePersonalPayment(deps, payment, signal, requestKey, onPrepa
15071
15462
  executionId: prepared.value.executionId,
15072
15463
  recipient: prepared.value.recipientObservation
15073
15464
  });
15074
- if (isAborted$1(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15465
+ if (isAborted$2(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15075
15466
  const signature = await signerCall(deps.signer.source, "signUserOpHash", () => deps.signer.signUserOpHash(prepared.value.digest));
15076
15467
  if (!signature.ok) return abandonPrepared(deps, prepared.value.executionId, "signer_rejected", signature, onPreparedClosed);
15077
- if (isAborted$1(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15468
+ if (isAborted$2(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15078
15469
  return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitExecution, () => deps.convexCall.action(deps.functions.submitPaymentExecution, { input: {
15079
15470
  executionId: prepared.value.executionId,
15080
15471
  signature: signature.value
@@ -40793,6 +41184,7 @@ function mapBetterAuthError(operation, body) {
40793
41184
  const code = typeof errBody.code === "string" ? errBody.code : "";
40794
41185
  if (code === "OTP_EXPIRED") return Errors.otpExpired();
40795
41186
  if (code === "INVALID_OTP") return Errors.invalidInput("otp", errBody.message ?? "invalid OTP");
41187
+ if (code === "TOO_MANY_ATTEMPTS") return Errors.rateLimited({ resource: "better-auth/verifyOtp" });
40796
41188
  if (code === "VALIDATION_ERROR" || code === "INVALID_EMAIL") return Errors.invalidInput("email", errBody.message ?? "invalid email");
40797
41189
  }
40798
41190
  return Errors.providerError("better-auth", operation, new Error(String(body)));
@@ -41410,6 +41802,10 @@ var BetterAuthNodeAdapter = class {
41410
41802
  ok: false,
41411
41803
  error: Errors.invalidInput("otp", errBody.message ?? "invalid OTP")
41412
41804
  };
41805
+ if (errBody.code === "TOO_MANY_ATTEMPTS") return {
41806
+ ok: false,
41807
+ error: Errors.rateLimited({ resource: "better-auth/verifyOtp" })
41808
+ };
41413
41809
  }
41414
41810
  }
41415
41811
  return {
@@ -44922,6 +45318,12 @@ const stderrConvexLogger = {
44922
45318
  error: writeConvexDiagnostic,
44923
45319
  logVerbose: () => void 0
44924
45320
  };
45321
+ const silentConvexLogger = {
45322
+ log: () => void 0,
45323
+ warn: () => void 0,
45324
+ error: () => void 0,
45325
+ logVerbose: () => void 0
45326
+ };
44925
45327
  /** Exact floor-first allowlist; every additional handler must migrate its validator first. */
44926
45328
  const OBSERVED_CONVEX_ACTIONS = /* @__PURE__ */ new Set([
44927
45329
  "system:healthObserved",
@@ -44993,7 +45395,9 @@ const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
44993
45395
  "smartAccount/mutations:provision",
44994
45396
  "org/lifecycle:startOrResume",
44995
45397
  "org/lifecycle:recordFailure",
44996
- "org/lifecycle:retry"
45398
+ "org/lifecycle:retry",
45399
+ "org/mutations:invite",
45400
+ "org/mutations:accept"
44997
45401
  ]);
44998
45402
  var ConvexCallAdapter = class {
44999
45403
  #client;
@@ -45008,7 +45412,7 @@ var ConvexCallAdapter = class {
45008
45412
  const webSocketConstructor = this.#connectionMonitor.observedWebSocketConstructor();
45009
45413
  this.#client = deps.client ?? new ConvexClient(deps.convexUrl, {
45010
45414
  ...webSocketConstructor === void 0 ? {} : { webSocketConstructor },
45011
- ...deps.logToStderr === true ? { logger: stderrConvexLogger } : {}
45415
+ logger: deps.localDiagnostics === true ? stderrConvexLogger : silentConvexLogger
45012
45416
  });
45013
45417
  this.#tokenProvider = deps.tokenProvider;
45014
45418
  this.#applicationId = deps.applicationId;
@@ -45666,10 +46070,7 @@ const DEFAULT_FUNCTIONS$1 = {
45666
46070
  listAll: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listAll),
45667
46071
  listRoles: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listRolesByOrgId),
45668
46072
  listMembers: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listMembersByOrgId),
45669
- readTreasury: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].readTreasury),
45670
- inviteMember: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].inviteMember),
45671
- resendInvite: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].resendInviteToken),
45672
- detectInvitations: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].detectAndAcceptPendingInvitations)
46073
+ readTreasury: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].readTreasury)
45673
46074
  };
45674
46075
  /**
45675
46076
  * Standard production Organization read adapter. It intentionally has no
@@ -45705,22 +46106,6 @@ var ConvexOrganizationAdapter = class {
45705
46106
  pendingMembers(input) {
45706
46107
  return this.listMembers(input).pipe(Effect.map((members) => members.filter((member) => member.status === "pending" || member.status === "pending_safe" || member.status === "pending_grant")));
45707
46108
  }
45708
- inviteMember(input) {
45709
- return this.#convex.action(this.#fns.inviteMember, copyInvocationObservation(input, {
45710
- orgId: input.orgId,
45711
- email: input.input.email,
45712
- role: input.input.role
45713
- })).pipe(Effect.mapError((error) => orgErrorFromCapxul("inviteMember", error.publicError, error)), Effect.map(brandOrgMember), Effect.catchDefect((cause) => Effect.fail(toOrgError("inviteMember", cause))));
45714
- }
45715
- resendInviteToken(input) {
45716
- return this.#convex.mutation(this.#fns.resendInvite, {
45717
- orgId: input.orgId,
45718
- email: input.email
45719
- }).pipe(Effect.mapError((error) => orgErrorFromCapxul("resendInviteToken", error.publicError, error)), Effect.map(brandOrgMember), Effect.catchDefect((cause) => Effect.fail(toOrgError("resendInviteToken", cause))));
45720
- }
45721
- detectAndAcceptPendingInvitations(_input) {
45722
- return this.#convex.action(this.#fns.detectInvitations, {}).pipe(Effect.mapError((error) => orgErrorFromCapxul("detectAndAcceptPendingInvitations", error.publicError, error)), Effect.map((result) => ({ matched: result.matched.map(toOrgId) })), Effect.catchDefect((cause) => Effect.fail(toOrgError("detectAndAcceptPendingInvitations", cause))));
45723
- }
45724
46109
  #readTreasuryWire(input) {
45725
46110
  const orgId = String(input.orgId);
45726
46111
  return retryIdempotentRead(this.#convex.action(this.#fns.readTreasury, copyInvocationObservation(input, { orgId })), CAPXUL_OPERATIONS.org.treasury, this.#telemetry, input).pipe(Effect.mapError((error) => orgErrorFromCapxul("readTreasury", error.publicError, error)), Effect.map((wire) => {
@@ -45765,11 +46150,12 @@ var ConvexOrganizationSetupAdapter = class {
45765
46150
  #fns;
45766
46151
  constructor(input) {
45767
46152
  this.#convex = input.convex;
45768
- this.#signer = input.signer;
46153
+ this.#signer = input.signer ?? null;
45769
46154
  this.#chainId = input.chainId;
45770
46155
  this.#fns = input.functions ?? DEFAULT_FUNCTIONS;
45771
46156
  }
45772
46157
  async startOrResume(input) {
46158
+ if (this.#signer === null) return fail$1(Errors.capabilityUnavailable("signer", "startOrResume"));
45773
46159
  const result = await runCall("startOrResume", this.#convex.mutation(this.#fns.startOrResume, copyInvocationObservation(input, {
45774
46160
  ...input,
45775
46161
  chainId: this.#chainId
@@ -45797,7 +46183,9 @@ var ConvexOrganizationSetupAdapter = class {
45797
46183
  async authorizeAndSubmitBootstrap(input) {
45798
46184
  const cancelled = cancellation(input.signal);
45799
46185
  if (cancelled !== void 0) return cancelled;
45800
- const signerAddress = await signerResult(this.#signer.source, "getAddress", () => this.#signer.getAddress());
46186
+ const signer = this.#signer;
46187
+ if (signer === null) return fail$1(Errors.capabilityUnavailable("signer", "authorizeAndSubmitBootstrap"));
46188
+ const signerAddress = await signerResult(signer.source, "getAddress", () => signer.getAddress());
45801
46189
  if (!signerAddress.ok) return signerAddress;
45802
46190
  const prepared = await runCall("prepareBootstrap", this.#convex.action(this.#fns.prepareBootstrap, copyInvocationObservation(input, {
45803
46191
  orgId: input.orgId,
@@ -45809,7 +46197,7 @@ var ConvexOrganizationSetupAdapter = class {
45809
46197
  if (!authority.ok) return authority;
45810
46198
  const cancelledAfterPrepare = cancellation(input.signal);
45811
46199
  if (cancelledAfterPrepare !== void 0) return cancelledAfterPrepare;
45812
- const signature = await signerResult(this.#signer.source, "signUserOpHash", () => this.#signer.signUserOpHash(prepared.value.digest));
46200
+ const signature = await signerResult(signer.source, "signUserOpHash", () => signer.signUserOpHash(prepared.value.digest));
45813
46201
  if (!signature.ok) return signature;
45814
46202
  const cancelledAfterSign = cancellation(input.signal);
45815
46203
  if (cancelledAfterSign !== void 0) return cancelledAfterSign;
@@ -45865,7 +46253,8 @@ var ConvexOrganizationSetupAdapter = class {
45865
46253
  ...input.observationContext === void 0 ? {} : { observationContext: input.observationContext }
45866
46254
  });
45867
46255
  if (!current.ok) return current;
45868
- if (current.value.status === "failed" && current.value.retryable && (current.value.at === "awaitingFounderAuthorization" || current.value.at === "submittingBootstrap")) {
46256
+ if (current.value.status === "failed" && current.value.retryable && current.value.at === "awaitingFounderAuthorization") {
46257
+ if (this.#signer === null) return fail$1(Errors.capabilityUnavailable("signer", "retry"));
45869
46258
  const reset = resetSignerSession(this.#signer);
45870
46259
  if (!reset.ok) return reset;
45871
46260
  }
@@ -47913,6 +48302,271 @@ function makeOrgMeMethod(deps, orgId) {
47913
48302
  };
47914
48303
  }
47915
48304
  //#endregion
48305
+ //#region ../../packages/sdk/src/contract/invitations.ts
48306
+ const invitationContract = {
48307
+ preview: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].previewInvite),
48308
+ listMine: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listMyInvitations),
48309
+ listScoped: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listInvitations),
48310
+ get: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].getInvitation),
48311
+ invite: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].invite),
48312
+ accept: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].accept),
48313
+ decline: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].decline),
48314
+ cancel: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].cancel),
48315
+ resend: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].resend),
48316
+ retry: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].retry)
48317
+ };
48318
+ //#endregion
48319
+ //#region ../../packages/sdk/src/surface/invitations.ts
48320
+ /**
48321
+ * The one refusal a scoped invitation result that names another Organization
48322
+ * receives, whether it was read or returned by the authoring write.
48323
+ */
48324
+ function scopeRefusal(orgId) {
48325
+ return Errors.invalidInput("orgId", `The invitation result does not belong to Organization ${JSON.stringify(orgId)}.`);
48326
+ }
48327
+ /**
48328
+ * A scoped invitation result belongs to the Organization it was read under.
48329
+ *
48330
+ * One owner holds the refusal copy and the verified-scope span: a single view
48331
+ * reports whether it names the scope, and a page — which names no Organization
48332
+ * of its own — reports whether every row does. A result that does not belong is
48333
+ * refused here rather than handed to a consumer, so a future route change
48334
+ * cannot turn into a silent cross-Organization read on a caller that trusted
48335
+ * the scope it passed. A successful scoped read also marks the verifying
48336
+ * Organization on the owning span, exactly as `org.me` does — the caller's
48337
+ * scope hint is not authority, the completed scoped read is.
48338
+ */
48339
+ function verifyScope(orgId, value, belongsToScope) {
48340
+ if (!belongsToScope(value)) return Effect.fail(scopeRefusal(orgId));
48341
+ return Effect.annotateCurrentSpan({
48342
+ verified_organization_id: orgId,
48343
+ scope_kind: "organization"
48344
+ }).pipe(Effect.as(value));
48345
+ }
48346
+ /** One view names its own Organization. */
48347
+ const namesScope = (orgId) => (value) => String(value.orgId) === orgId;
48348
+ /** A page names no Organization of its own, so every row must name the scope. */
48349
+ const rowsNameScope = (orgId) => (page) => page.items.every((item) => String(item.orgId) === orgId);
48350
+ const ops = CAPXUL_OPERATIONS.org.invitations;
48351
+ /** Truth for a caller-owned signal, without narrowing its type. */
48352
+ function isAborted$1(signal) {
48353
+ return signal?.aborted === true;
48354
+ }
48355
+ /**
48356
+ * One observed operation around one Convex hop, exactly like `org.me`. The
48357
+ * call-start invocation snapshot rides the arguments, so the backend continues
48358
+ * the attempt this call started rather than resolving a new one.
48359
+ */
48360
+ function observed$1(deps, operation, options, args, call, check) {
48361
+ const controls = deps.invocationControls?.(options) ?? options;
48362
+ return runCapxulEffect(call(copyInvocationObservation(controls, args)).pipe(Effect.mapError((failure) => failure.publicError), Effect.flatMap((value) => check === void 0 ? Effect.succeed(value) : check(value))), controls, operation, deps.runPromise);
48363
+ }
48364
+ /**
48365
+ * The Admin's preview stays a read: it reaches the preview query and nothing
48366
+ * else. It reads current policies and live assignments, so the operator sees
48367
+ * what the offered authority is now, not a frozen copy.
48368
+ */
48369
+ function makeOrgInvitationMethods(deps, orgId) {
48370
+ const scopeCheck = (value) => verifyScope(orgId, value, namesScope(orgId));
48371
+ return {
48372
+ preview: (input, options) => observed$1(deps, ops.preview, options, {
48373
+ orgId,
48374
+ request: input
48375
+ }, (args) => deps.convexCall.query(invitationContract.preview, args), scopeCheck),
48376
+ invite: makeInviteMethod(deps, orgId),
48377
+ accept: (input, options) => observed$1(deps, ops.accept, options, {
48378
+ orgId,
48379
+ invitationId: input.invitationId,
48380
+ expectedOfferDigest: input.expectedOfferDigest
48381
+ }, (args) => deps.convexCall.mutation(invitationContract.accept, args), scopeCheck),
48382
+ list: (input, options) => observed$1(deps, ops.listScoped, options, {
48383
+ orgId,
48384
+ ...pageArgs(input)
48385
+ }, (args) => deps.convexCall.query(invitationContract.listScoped, args), (page) => verifyScope(orgId, page, rowsNameScope(orgId))),
48386
+ get: (input, options) => observed$1(deps, ops.get, options, {
48387
+ orgId,
48388
+ invitationId: input.invitationId
48389
+ }, (args) => deps.convexCall.query(invitationContract.get, args), scopeCheck),
48390
+ decline: (input, options) => observed$1(deps, ops.decline, options, {
48391
+ orgId,
48392
+ invitationId: input.invitationId
48393
+ }, (args) => deps.convexCall.mutation(invitationContract.decline, args), scopeCheck),
48394
+ cancel: (input, options) => observed$1(deps, ops.cancel, options, {
48395
+ orgId,
48396
+ invitationId: input.invitationId
48397
+ }, (args) => deps.convexCall.mutation(invitationContract.cancel, args), scopeCheck),
48398
+ resend: (input, options) => observed$1(deps, ops.resend, options, {
48399
+ orgId,
48400
+ invitationId: input.invitationId
48401
+ }, (args) => deps.convexCall.mutation(invitationContract.resend, args), scopeCheck),
48402
+ retry: (input, options) => observed$1(deps, ops.retry, options, {
48403
+ orgId,
48404
+ invitationId: input.invitationId
48405
+ }, (args) => deps.convexCall.mutation(invitationContract.retry, args), scopeCheck)
48406
+ };
48407
+ }
48408
+ /**
48409
+ * The authoring write, including its configuration hop.
48410
+ *
48411
+ * The mutation persists the invitation and its configure command before any
48412
+ * signature exists. The write then drives the existing human configuration
48413
+ * owner exactly as the Permission and payment surfaces drive theirs: prepare
48414
+ * the stored command for this Account's Safe, check the prepared authority
48415
+ * against the request, deliver the durable identity to the caller, sign the
48416
+ * returned digest, and submit it. The backend keeps the only authorization
48417
+ * rule (`prepareInvitationConfigurationIntentInTx` /
48418
+ * `submitInvitationConfigurationExecution`); this edge adds no second one.
48419
+ *
48420
+ * Cancellation owns the whole compound: an abort before the digest is signed
48421
+ * stops the write and forwards no signature, and an already-signed submission
48422
+ * completes.
48423
+ */
48424
+ async function executeInvite(deps, orgId, input, signal, controls, verifiedOrganization, onPrepared) {
48425
+ if (isAborted$1(signal)) return {
48426
+ ok: false,
48427
+ error: Errors.cancelled({ operation: ops.authorize })
48428
+ };
48429
+ if (deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0) return {
48430
+ ok: false,
48431
+ error: Errors.notImplemented("invitations", "executionComposition")
48432
+ };
48433
+ const session = deps.actor.authSession();
48434
+ if (session === null) return {
48435
+ ok: false,
48436
+ error: Errors.notAuthenticated()
48437
+ };
48438
+ const authored = await runIfActive(signal, ops.authorize, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.mutation(invitationContract.invite, copyInvocationObservation(controls, {
48439
+ orgId,
48440
+ request: input
48441
+ }))), controls), deps.runPromise);
48442
+ if (!authored.ok) return authored;
48443
+ const view = authored.value;
48444
+ if (String(view.orgId) !== orgId) return {
48445
+ ok: false,
48446
+ error: scopeRefusal(orgId)
48447
+ };
48448
+ if (view.phase !== "authorizing") return {
48449
+ ok: true,
48450
+ value: view
48451
+ };
48452
+ if (view.commandId === null) return {
48453
+ ok: false,
48454
+ error: Errors.invalidInput("invitationId", "The invitation does not name its configuration command.")
48455
+ };
48456
+ const commandId = view.commandId;
48457
+ let signerAddress;
48458
+ try {
48459
+ signerAddress = await deps.signer.getAddress();
48460
+ } catch (cause) {
48461
+ return {
48462
+ ok: false,
48463
+ error: signerFailure(deps.signer.source, "getAddress", cause)
48464
+ };
48465
+ }
48466
+ const prepared = await runIfActive(signal, ops.prepareConfiguration, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(moneyExecutionContract.prepareInvitationConfiguration, copyInvocationObservation(controls, { input: {
48467
+ commandId,
48468
+ signerAddress
48469
+ } }))), controls), deps.runPromise);
48470
+ if (!prepared.ok) return prepared;
48471
+ const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
48472
+ if (!preparedAuthorityMatches({
48473
+ prepared: prepared.value,
48474
+ chainId: deps.chainId,
48475
+ signerAddress,
48476
+ expectedSafe,
48477
+ commandId,
48478
+ invitationId: view.id,
48479
+ orgId
48480
+ })) return {
48481
+ ok: false,
48482
+ error: Errors.invalidInput("invitation", "prepared authority mismatch")
48483
+ };
48484
+ verifiedOrganization(prepared.value.orgId);
48485
+ if (isAborted$1(signal)) return {
48486
+ ok: false,
48487
+ error: Errors.cancelled({ operation: ops.authorize })
48488
+ };
48489
+ if (onPrepared !== void 0) try {
48490
+ await onPrepared({
48491
+ invitationId: prepared.value.invitationId,
48492
+ commandId: prepared.value.commandId
48493
+ });
48494
+ } catch (cause) {
48495
+ return {
48496
+ ok: false,
48497
+ error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
48498
+ };
48499
+ }
48500
+ if (isAborted$1(signal)) return {
48501
+ ok: false,
48502
+ error: Errors.cancelled({ operation: ops.authorize })
48503
+ };
48504
+ let signature;
48505
+ try {
48506
+ signature = await deps.signer.signUserOpHash(prepared.value.digest);
48507
+ } catch (cause) {
48508
+ return {
48509
+ ok: false,
48510
+ error: signerFailure(deps.signer.source, "signUserOpHash", cause)
48511
+ };
48512
+ }
48513
+ if (isAborted$1(signal)) return {
48514
+ ok: false,
48515
+ error: Errors.cancelled({ operation: ops.authorize })
48516
+ };
48517
+ const submitted = await runIfActive(void 0, ops.submitConfiguration, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(moneyExecutionContract.submitInvitationConfigurationExecution, copyInvocationObservation(controls, { input: {
48518
+ executionId: prepared.value.executionId,
48519
+ signature
48520
+ } }))), controls), deps.runPromise);
48521
+ if (!submitted.ok) return submitted;
48522
+ return {
48523
+ ok: true,
48524
+ value: view
48525
+ };
48526
+ }
48527
+ /**
48528
+ * The prepared authority must be exactly the one this write asked for: the same
48529
+ * chain, the caller's signer, this Account's Safe, and the exact command and
48530
+ * invitation the authoring view named.
48531
+ */
48532
+ function preparedAuthorityMatches(input) {
48533
+ return input.prepared.chainId === input.chainId && input.prepared.signerAddress.toLowerCase() === input.signerAddress.toLowerCase() && input.prepared.userOpSenderSafe.toLowerCase() === input.expectedSafe.toLowerCase() && input.prepared.commandId === input.commandId && input.prepared.invitationId === input.invitationId && input.prepared.orgId === input.orgId;
48534
+ }
48535
+ function makeInviteMethod(deps, orgId) {
48536
+ return (input, options) => {
48537
+ const { onPrepared, ...supplied } = options ?? {};
48538
+ const controls = deps.invocationControls?.(supplied) ?? supplied;
48539
+ let verifiedOrganizationId;
48540
+ return runCapxulEffect(Effect.gen(function* () {
48541
+ if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: ops.authorize }));
48542
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
48543
+ const captured = carryInvocationParentSpan(controls, parent);
48544
+ const result = yield* Effect.tryPromise({
48545
+ try: () => executeInvite(deps, orgId, input, controls?.signal, captured, (id) => {
48546
+ verifiedOrganizationId = id;
48547
+ }, onPrepared),
48548
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
48549
+ });
48550
+ return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
48551
+ }).pipe(Effect.ensuring(Effect.suspend(() => verifiedOrganizationId === void 0 ? Effect.void : Effect.annotateCurrentSpan({
48552
+ verified_organization_id: verifiedOrganizationId,
48553
+ scope_kind: "organization"
48554
+ })).pipe(Effect.catchCause(() => Effect.void)))), observationOnlyControls(controls), ops.authorize, deps.runPromise);
48555
+ };
48556
+ }
48557
+ /** Drop the page fields the caller did not supply; a bounded page sends only its bounds. */
48558
+ function pageArgs(input) {
48559
+ if (input === void 0) return {};
48560
+ return {
48561
+ ...input.cursor === void 0 ? {} : { cursor: input.cursor },
48562
+ ...input.limit === void 0 ? {} : { limit: input.limit },
48563
+ ...input.phases === void 0 ? {} : { phases: input.phases }
48564
+ };
48565
+ }
48566
+ function makeOwnInvitationsMethod(deps) {
48567
+ return (input, options) => observed$1(deps, ops.list, options, pageArgs(input), (args) => deps.convexCall.query(invitationContract.listMine, args));
48568
+ }
48569
+ //#endregion
47916
48570
  //#region ../../packages/sdk/src/contract/permission.ts
47917
48571
  const permissionContract = { read: makeFunctionReference(CAPXUL_FUNCTIONS["permission/queries"].read) };
47918
48572
  //#endregion
@@ -48600,20 +49254,6 @@ function hermeticOrgView(input) {
48600
49254
  observedAt: 0
48601
49255
  };
48602
49256
  }
48603
- function hermeticMember(input) {
48604
- return {
48605
- orgId: input.orgId,
48606
- accountId: null,
48607
- email: toEmail(input.email),
48608
- name: null,
48609
- personalSafeAddress: input.personalSafeAddress ?? null,
48610
- role: input.role,
48611
- roleKey: toRoleKey(orgRoleKeyForLabel(input.role)),
48612
- status: input.status,
48613
- grantTxHash: input.grantTxHash ?? null,
48614
- revokeTxHash: input.revokeTxHash ?? null
48615
- };
48616
- }
48617
49257
  function createOrgProgram(input) {
48618
49258
  return Effect.gen(function* () {
48619
49259
  const deps = yield* OrgDepsTag;
@@ -48714,35 +49354,6 @@ function listMembersProgram(orgId) {
48714
49354
  return [];
48715
49355
  });
48716
49356
  }
48717
- /**
48718
- * R06 (#1964): the SDK no longer emits `org_invite_sent`. The backend action
48719
- * that writes the invitation is its ONE producer, so a hermetic call — which
48720
- * writes nothing — can no longer report an invitation that never happened, and
48721
- * a live call is counted once instead of twice. The captured attempt rides the
48722
- * port input, so the durable event carries the correlation this call ran under.
48723
- */
48724
- function inviteMemberProgram(orgId, input) {
48725
- return Effect.gen(function* () {
48726
- const deps = yield* OrgDepsTag;
48727
- if (deps.orgPort === void 0) return hermeticMember({
48728
- orgId,
48729
- email: input.email,
48730
- role: input.role,
48731
- status: "pending"
48732
- });
48733
- return yield* deps.orgPort.inviteMember(copyInvocationObservation(deps.invocationSource, {
48734
- orgId,
48735
- input
48736
- })).pipe(Effect.mapError((error) => error.publicError));
48737
- });
48738
- }
48739
- function detectAndAcceptPendingInvitationsProgram() {
48740
- return Effect.gen(function* () {
48741
- const deps = yield* OrgDepsTag;
48742
- if (deps.orgPort !== void 0) return yield* deps.orgPort.detectAndAcceptPendingInvitations({}).pipe(Effect.mapError((error) => error.publicError));
48743
- return { matched: [] };
48744
- });
48745
- }
48746
49357
  function listOrgsProgram() {
48747
49358
  return Effect.gen(function* () {
48748
49359
  const deps = yield* OrgDepsTag;
@@ -48848,6 +49459,20 @@ function observedRunnerDeps(deps) {
48848
49459
  ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls }
48849
49460
  };
48850
49461
  }
49462
+ /**
49463
+ * The invitation edge needs the call seam, the observed-runner pair, and — for
49464
+ * the authoring write's configuration hop — the same execution composition the
49465
+ * Permission, payment, and payroll bundles receive.
49466
+ */
49467
+ function invitationMethodsDeps(deps, convexCall) {
49468
+ return {
49469
+ convexCall,
49470
+ ...observedRunnerDeps(deps),
49471
+ ...deps.actor === void 0 ? {} : { actor: deps.actor },
49472
+ ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
49473
+ ...deps.signer === void 0 ? {} : { signer: deps.signer }
49474
+ };
49475
+ }
48851
49476
  function makeOrgMethods(deps) {
48852
49477
  const orgDeps = {
48853
49478
  ...deps.orgPort === void 0 ? {} : { orgPort: deps.orgPort },
@@ -48879,13 +49504,10 @@ function makeOrgMethods(deps) {
48879
49504
  });
48880
49505
  return toCapxulResult(createOrgProgram(input), layer);
48881
49506
  },
48882
- orgs: Object.assign((options) => listOrganizations(deps.invocationControls?.(options) ?? options), { detectAndAcceptPendingInvitations(options) {
48883
- if (options?.signal?.aborted) return Promise.resolve({
48884
- ok: false,
48885
- error: Errors.cancelled({ operation: CAPXUL_OPERATIONS.organizations.detectAndAcceptPendingInvitations })
48886
- });
48887
- return toCapxulResult(detectAndAcceptPendingInvitationsProgram(), layer);
48888
- } }),
49507
+ orgs: Object.assign((options) => listOrganizations(deps.invocationControls?.(options) ?? options), { invitations: deps.convexCall === void 0 ? () => Promise.resolve({
49508
+ ok: false,
49509
+ error: Errors.notImplemented("invitations", "listOwn")
49510
+ }) : makeOwnInvitationsMethod(invitationMethodsDeps(deps, deps.convexCall)) }),
48889
49511
  org(orgId) {
48890
49512
  const convexCall = deps.convexCall;
48891
49513
  return {
@@ -48993,17 +49615,7 @@ function makeOrgMethods(deps) {
48993
49615
  });
48994
49616
  return toCapxulResult(listRolesProgram(orgId), layer);
48995
49617
  },
48996
- invite(_input, _options) {
48997
- const controls = deps.invocationControls?.(_options) ?? _options;
48998
- if (controls?.signal?.aborted) return Promise.resolve({
48999
- ok: false,
49000
- error: Errors.cancelled({ operation: CAPXUL_OPERATIONS.org.invite })
49001
- });
49002
- return runCapxulEffect(inviteMemberProgram(orgId, _input).pipe(Effect.provide(orgDepsLayer({
49003
- ...orgDeps,
49004
- ...controls === void 0 ? {} : { invocationSource: controls }
49005
- }))), controls, CAPXUL_OPERATIONS.org.invite, deps.runPromise);
49006
- },
49618
+ invitations: convexCall === void 0 ? makeNotImplementedInvitationMethods() : makeOrgInvitationMethods(invitationMethodsDeps(deps, convexCall), String(orgId)),
49007
49619
  auditLog(_options) {
49008
49620
  if (_options?.signal?.aborted) return Promise.resolve({
49009
49621
  ok: false,
@@ -49066,6 +49678,28 @@ const orgMeUnavailable = () => Promise.resolve({
49066
49678
  ok: false,
49067
49679
  error: Errors.notImplemented("org", "me")
49068
49680
  });
49681
+ /**
49682
+ * The closed invitation surface for a client with no backend seam. It reports
49683
+ * `NOT_IMPLEMENTED` for every method rather than an empty list or a fabricated
49684
+ * view: an absent composition root is not an absent invitation.
49685
+ */
49686
+ function makeNotImplementedInvitationMethods() {
49687
+ return {
49688
+ preview: invitationExecutionUnavailable,
49689
+ invite: invitationExecutionUnavailable,
49690
+ accept: invitationExecutionUnavailable,
49691
+ list: invitationExecutionUnavailable,
49692
+ get: invitationExecutionUnavailable,
49693
+ decline: invitationExecutionUnavailable,
49694
+ cancel: invitationExecutionUnavailable,
49695
+ resend: invitationExecutionUnavailable,
49696
+ retry: invitationExecutionUnavailable
49697
+ };
49698
+ }
49699
+ const invitationExecutionUnavailable = () => Promise.resolve({
49700
+ ok: false,
49701
+ error: Errors.notImplemented("invitations", "executionComposition")
49702
+ });
49069
49703
  const permissionExecutionUnavailable = () => Promise.resolve({
49070
49704
  ok: false,
49071
49705
  error: Errors.notImplemented("permissions", "executionComposition")
@@ -49565,7 +50199,6 @@ function assembleCapxulClient(input) {
49565
50199
  };
49566
50200
  if (input.signal !== void 0) input.signal.addEventListener("abort", () => void stopActor(), { once: true });
49567
50201
  const selectedOrgPort = input.orgPort ?? input.orgDeploymentPort;
49568
- let detectPendingOrgInvitations;
49569
50202
  let kickProvisioning;
49570
50203
  const financialOps = makeFinancialOpsMethods({
49571
50204
  runPromise: effectRunner.runPromise,
@@ -49614,7 +50247,6 @@ function assembleCapxulClient(input) {
49614
50247
  if (browserSigner.statusStore?.status() === "unknown" && typeof browserSigner.ensureWalletReady === "function") browserSigner.ensureWalletReady().catch(() => {});
49615
50248
  }
49616
50249
  if (accountSetup === "explicit") return;
49617
- await detectPendingOrgInvitations?.();
49618
50250
  kickProvisioning?.();
49619
50251
  }
49620
50252
  });
@@ -49682,9 +50314,6 @@ function assembleCapxulClient(input) {
49682
50314
  ...input.signer === void 0 ? {} : { signer: input.signer },
49683
50315
  ...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup }
49684
50316
  });
49685
- if (selectedOrgPort !== void 0) detectPendingOrgInvitations = async () => {
49686
- await orgMethods.orgs.detectAndAcceptPendingInvitations();
49687
- };
49688
50317
  const currentUser = makeCurrentUserMethods({
49689
50318
  me: financialOps.me,
49690
50319
  accounts,
@@ -50658,7 +51287,7 @@ function productionAuthCacheLayer(input) {
50658
51287
  function productionConvexCallLayer(input, refreshConvexAuthRef) {
50659
51288
  return Layer.unwrap(Effect.map(AuthClientPortTag, (authClient) => ConvexCallLayer({
50660
51289
  convexUrl: input.runtimeUrls.convexUrl,
50661
- logToStderr: input.runtime === "node",
51290
+ localDiagnostics: input.localDiagnostics,
50662
51291
  ...input.applicationId === void 0 ? {} : { applicationId: input.applicationId },
50663
51292
  ...input.observation === void 0 ? {} : { observation: input.observation },
50664
51293
  ...input.convexClient === void 0 ? {} : { client: input.convexClient },
@@ -50697,6 +51326,7 @@ function resolveProductionObservability(input) {
50697
51326
  };
50698
51327
  }
50699
51328
  async function createProductionAdapters(input) {
51329
+ const localDiagnostics = productionLocalDiagnostics(input);
50700
51330
  const { observation, telemetry, invocationObservation, invocationTelemetry } = resolveProductionObservability(input);
50701
51331
  const resolvedInput = resolveInput(input);
50702
51332
  if (!resolvedInput.ok) return resolvedInput;
@@ -50767,6 +51397,7 @@ async function createProductionAdapters(input) {
50767
51397
  const portsLayer = mergeProductionAdapterLayers(makeProductionAdapterLayerEntries({
50768
51398
  bootstrap,
50769
51399
  runtime: resolvedInput.value.runtime,
51400
+ localDiagnostics,
50770
51401
  ...resolvedInput.value.origin === void 0 ? {} : { origin: resolvedInput.value.origin },
50771
51402
  runtimeUrls: runtimeUrls.value,
50772
51403
  chainId: bootstrapResult.value.chainId,
@@ -50781,7 +51412,7 @@ async function createProductionAdapters(input) {
50781
51412
  ...input.signal === void 0 ? {} : { signal: input.signal },
50782
51413
  ...input.resetSignerSession === void 0 ? {} : { resetSignerSession: input.resetSignerSession }
50783
51414
  }));
50784
- const applicationLayer = Layer.merge(portsLayer, optionalEngineeringTelemetryLayer(bootstrapResult.value.engineeringTelemetry, resolvedInput.value.runtime, hostEngineeringPolicy(input.observability))).pipe(Layer.provideMerge(resolvedInput.value.runtime === "node" ? Layer.succeed(Logger.LogToStderr, true) : Layer.empty));
51415
+ const applicationLayer = Layer.merge(portsLayer, optionalEngineeringTelemetryLayer(bootstrapResult.value.engineeringTelemetry, resolvedInput.value.runtime, hostEngineeringPolicy(input.observability))).pipe(Layer.provideMerge(localDiagnosticsLayer(localDiagnostics, resolvedInput.value.runtime)));
50785
51416
  const context = await Effect.runPromise(Layer.buildWithScope(applicationLayer, scope));
50786
51417
  const collected = await Effect.runPromise(collectProductionFlowPorts.pipe(Effect.provide(context)));
50787
51418
  const indexerUrl = input.indexerUrl ?? bootstrapResult.value.indexerUrl;
@@ -50845,6 +51476,13 @@ function optionalEngineeringTelemetryLayer(policy, runtime, hostPolicy) {
50845
51476
  return Layer.empty;
50846
51477
  }
50847
51478
  }
51479
+ function localDiagnosticsLayer(enabled, runtime) {
51480
+ if (!enabled) return Logger.layer([]);
51481
+ return runtime === "node" ? Layer.succeed(Logger.LogToStderr, true) : Layer.empty;
51482
+ }
51483
+ function productionLocalDiagnostics(input) {
51484
+ return input.localDiagnostics !== false;
51485
+ }
50848
51486
  function refreshConvexAuthOnSession(authClient, refresh) {
50849
51487
  return {
50850
51488
  ...authClient,
@@ -50909,7 +51547,7 @@ async function createCapxulClientWithSignerControls(input, controls) {
50909
51547
  runtime,
50910
51548
  authBaseUrl: resolvedAuthBaseUrl,
50911
51549
  createBrowserSigner: createOpenfortBrowserSignerFromBootstrap,
50912
- diagnostic: new EffectLogDiagnosticAdapter(adapters.value.context, new ConsoleDiagnosticAdapter()),
51550
+ diagnostic: new EffectLogDiagnosticAdapter(adapters.value.context, productionLocalDiagnostics(input) ? new ConsoleDiagnosticAdapter() : void 0),
50913
51551
  signer: input.signer,
50914
51552
  factory: input.openfortSignerFactory,
50915
51553
  finalSign: controls.signUserOpHash,
@@ -50938,11 +51576,11 @@ async function createCapxulClientWithSignerControls(input, controls) {
50938
51576
  accountSetup: input.accountSetup,
50939
51577
  ...signer === void 0 ? {} : { signer },
50940
51578
  orgPort: Context.get(adapters.value.context, OrgPortTag),
50941
- ...signer === void 0 ? {} : { organizationSetup: new ConvexOrganizationSetupAdapter({
51579
+ organizationSetup: new ConvexOrganizationSetupAdapter({
50942
51580
  convex: adapters.value.ports.convexCall,
50943
- signer,
51581
+ ...signer === void 0 ? {} : { signer },
50944
51582
  chainId: adapters.value.bootstrap.chainId
50945
- }) },
51583
+ }),
50946
51584
  ...input.signal === void 0 ? {} : { signal: input.signal },
50947
51585
  ...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
50948
51586
  invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
@@ -51336,7 +51974,7 @@ const staffTools = [
51336
51974
  scope: MANAGE,
51337
51975
  register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.roles, {
51338
51976
  title: "List Organization roles",
51339
- description: "List the active role labels that an Organization invitation can use.",
51977
+ description: "List active Organization role labels.",
51340
51978
  inputSchema: z.object(orgInput),
51341
51979
  outputSchema: z.object({ roles: z.array(z.object({ label: z.string() })) })
51342
51980
  }, ({ organizationId }) => withClient(scope, CAPXUL_OPERATIONS.org.roles, MANAGE, async (client) => {
@@ -51349,7 +51987,7 @@ const staffTools = [
51349
51987
  scope: MANAGE,
51350
51988
  register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.members, {
51351
51989
  title: "List Organization members",
51352
- description: "List Organization member lifecycle states. Poll after activation until the member is active.",
51990
+ description: "List current Organization member lifecycle states.",
51353
51991
  inputSchema: z.object(orgInput),
51354
51992
  outputSchema: z.object({ members: z.array(z.object({
51355
51993
  accountId: z.string().nullable(),
@@ -51362,66 +52000,6 @@ const staffTools = [
51362
52000
  const result = await client.listOrganizationMembers(organizationId);
51363
52001
  return result.ok ? okResult({ members: [...result.value] }) : errorResult(result.error);
51364
52002
  }))
51365
- },
51366
- {
51367
- name: CAPXUL_OPERATIONS.org.invite,
51368
- scope: MANAGE,
51369
- register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.invite, {
51370
- title: "Invite Organization member",
51371
- description: "Invite one Person by email into an Organization. Use a role label returned by org.roles.",
51372
- inputSchema: z.object({
51373
- ...orgInput,
51374
- email,
51375
- role: z.string().trim().min(1)
51376
- }),
51377
- outputSchema: z.object({
51378
- email,
51379
- role: z.string(),
51380
- status: memberStatus
51381
- })
51382
- }, ({ organizationId, email: invitee, role }) => withClient(scope, CAPXUL_OPERATIONS.org.invite, MANAGE, async (client) => {
51383
- const result = await client.inviteOrganizationMember(organizationId, {
51384
- email: invitee,
51385
- role
51386
- });
51387
- return result.ok ? okResult({ ...result.value }) : errorResult(result.error);
51388
- }))
51389
- },
51390
- {
51391
- name: CAPXUL_OPERATIONS.org.acceptInvitations,
51392
- scope: MANAGE,
51393
- register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.acceptInvitations, {
51394
- title: "Accept Organization invitations",
51395
- description: "Accept every pending Organization invitation for the signed-in Person's verified email.",
51396
- inputSchema: z.object({}),
51397
- outputSchema: z.object({ organizationIds: z.array(z.string()) })
51398
- }, () => withClient(scope, CAPXUL_OPERATIONS.org.acceptInvitations, MANAGE, async (client) => {
51399
- const result = await client.acceptOrganizationInvitations();
51400
- return result.ok ? okResult({ ...result.value }) : errorResult(result.error);
51401
- }))
51402
- },
51403
- {
51404
- name: CAPXUL_OPERATIONS.org.activateMember,
51405
- scope: MANAGE,
51406
- register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.activateMember, {
51407
- title: "Activate Organization member",
51408
- description: "Grant the invited role to a pending member's ready Account. The Organization founder signs this operation.",
51409
- inputSchema: z.object({
51410
- ...orgInput,
51411
- email,
51412
- accountId: z.string().trim().min(1)
51413
- }),
51414
- outputSchema: z.object({
51415
- email,
51416
- status: z.enum(["active", "submitted"])
51417
- })
51418
- }, ({ organizationId, email: invitee, accountId }) => withClient(scope, CAPXUL_OPERATIONS.org.activateMember, MANAGE, async (client) => {
51419
- const result = await client.activateOrganizationMember(organizationId, {
51420
- email: invitee,
51421
- accountId
51422
- });
51423
- return result.ok ? okResult({ ...result.value }) : errorResult(result.error);
51424
- }))
51425
52003
  }
51426
52004
  ];
51427
52005
  //#endregion
@@ -51748,7 +52326,7 @@ function stdioIdentity(env = process.env, options = {}) {
51748
52326
  }
51749
52327
  //#endregion
51750
52328
  //#region package.json
51751
- var version = "4.20.0-beta.6";
52329
+ var version = "4.20.0-beta.8";
51752
52330
  //#endregion
51753
52331
  //#region src/deps.ts
51754
52332
  const NO_IDENTITY = async () => void 0;
@@ -51833,9 +52411,6 @@ const SAFE_TOOL_INTENTS = {
51833
52411
  [CAPXUL_OPERATIONS.system.health]: "Verify MCP backend health.",
51834
52412
  [CAPXUL_OPERATIONS.onboarding.completePerson]: "Complete Person onboarding.",
51835
52413
  [CAPXUL_OPERATIONS.onboarding.completeOrganization]: "Complete Organization onboarding.",
51836
- [CAPXUL_OPERATIONS.org.acceptInvitations]: "Accept Organization invitations.",
51837
- [CAPXUL_OPERATIONS.org.activateMember]: "Activate an Organization member.",
51838
- [CAPXUL_OPERATIONS.org.invite]: "Invite an Organization member.",
51839
52414
  [CAPXUL_OPERATIONS.org.list]: "List Organizations.",
51840
52415
  [CAPXUL_OPERATIONS.org.members]: "List Organization members.",
51841
52416
  [CAPXUL_OPERATIONS.org.roles]: "List Organization roles.",
@@ -52254,85 +52829,6 @@ async function createSdkClient(input, createClient = createCapxulClient) {
52254
52829
  }))
52255
52830
  };
52256
52831
  },
52257
- inviteOrganizationMember: async (orgId, invitation) => {
52258
- const result = await client.org(orgId).invite(invitation);
52259
- if (!result.ok) return result;
52260
- return {
52261
- ok: true,
52262
- value: {
52263
- email: String(result.value.email),
52264
- role: result.value.role,
52265
- status: result.value.status
52266
- }
52267
- };
52268
- },
52269
- acceptOrganizationInvitations: async () => {
52270
- const result = await client.orgs.detectAndAcceptPendingInvitations();
52271
- if (!result.ok) return result;
52272
- return {
52273
- ok: true,
52274
- value: { organizationIds: result.value.matched.map(String) }
52275
- };
52276
- },
52277
- activateOrganizationMember: async (orgId, activation) => {
52278
- const memberEmail = activation.email.trim().toLowerCase();
52279
- const scoped = client.org(orgId);
52280
- const members = await scoped.members();
52281
- if (!members.ok) return members;
52282
- const matches = members.value.filter((member) => String(member.email) === memberEmail);
52283
- const member = matches.length === 1 ? matches[0] : void 0;
52284
- if (member === void 0) return {
52285
- ok: false,
52286
- error: Errors.invalidInput("email", "member was not found")
52287
- };
52288
- if (member.status === "active") return {
52289
- ok: true,
52290
- value: {
52291
- email: memberEmail,
52292
- status: "active"
52293
- }
52294
- };
52295
- if (member.status !== "pending_grant" || member.roleKey === null) return {
52296
- ok: false,
52297
- error: Errors.wrongState({
52298
- method: CAPXUL_OPERATIONS.org.activateMember,
52299
- currentState: member.status,
52300
- validStates: ["pending_grant", "active"]
52301
- })
52302
- };
52303
- const permissions = await scoped.permissions.list();
52304
- if (!permissions.ok) return permissions;
52305
- const matchingPermissions = permissions.value.permissions.filter((permission) => permission.type === "managePeople" && permission.state === "active" && String(permission.roleKey).toLowerCase() === String(member.roleKey).toLowerCase());
52306
- const permission = matchingPermissions.length === 1 ? matchingPermissions[0] : void 0;
52307
- if (permission === void 0) return {
52308
- ok: false,
52309
- error: Errors.wrongState({
52310
- method: CAPXUL_OPERATIONS.org.activateMember,
52311
- currentState: "matching-permission-missing",
52312
- validStates: ["one-active-role-permission"]
52313
- })
52314
- };
52315
- const requestKey = `mcp-staff-${createHash("sha256").update(JSON.stringify({
52316
- orgId,
52317
- email: memberEmail,
52318
- accountId: activation.accountId,
52319
- permissionId: permission.permissionId
52320
- })).digest("hex")}`;
52321
- const assigned = await scoped.permissions.assign({
52322
- requestKey,
52323
- permissionId: String(permission.permissionId),
52324
- accountId: activation.accountId,
52325
- expectedMemberEmail: memberEmail
52326
- });
52327
- if (!assigned.ok) return assigned;
52328
- return {
52329
- ok: true,
52330
- value: {
52331
- email: memberEmail,
52332
- status: "submitted"
52333
- }
52334
- };
52335
- },
52336
52832
  getLifecycle: async () => {
52337
52833
  const result = await client.account.getLifecycle();
52338
52834
  if (!result.ok) return result;