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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -13
  2. package/dist/main.mjs +733 -269
  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,
@@ -13689,11 +14066,13 @@ const financialOpsContract = {
13689
14066
  //#region ../../packages/sdk/src/contract/money-execution.ts
13690
14067
  const moneyExecutionContract = {
13691
14068
  abandonPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].abandonPaymentExecution),
14069
+ prepareInvitationConfiguration: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].prepareInvitationConfiguration),
13692
14070
  preparePermissionExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePermissionExecution),
13693
14071
  preparePaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePaymentExecution),
13694
14072
  prepareOrganizationPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].prepareOrganizationPaymentExecution),
13695
14073
  preparePaymentLifecycleExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].preparePaymentLifecycleExecution),
13696
14074
  submitPaymentExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPaymentExecution),
14075
+ submitInvitationConfigurationExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitInvitationConfigurationExecution),
13697
14076
  submitPermissionExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPermissionExecution),
13698
14077
  submitPaymentCommandExecution: makeFunctionReference(CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].submitPaymentCommandExecution)
13699
14078
  };
@@ -14274,7 +14653,7 @@ function subscribeActivity(deps, actor, controls, onChange) {
14274
14653
  }
14275
14654
  //#endregion
14276
14655
  //#region ../../packages/sdk/package.json
14277
- var version$1 = "4.20.0-beta.6";
14656
+ var version$1 = "4.20.0-beta.7";
14278
14657
  //#endregion
14279
14658
  //#region ../../packages/sdk/src/telemetry/exception-projection.ts
14280
14659
  /** Fixed fallback for failures that have no safe message. */
@@ -14901,7 +15280,7 @@ function isMoneyTelemetryDebugEnabled() {
14901
15280
  }
14902
15281
  //#endregion
14903
15282
  //#region ../../packages/sdk/src/surface/payment-command-execution.ts
14904
- function isAborted$2(signal) {
15283
+ function isAborted$3(signal) {
14905
15284
  return signal?.aborted === true;
14906
15285
  }
14907
15286
  function canonicalJson(value) {
@@ -14927,7 +15306,7 @@ async function abandonPrepared$1(deps, executionId, closePayment, reason, result
14927
15306
  return result;
14928
15307
  }
14929
15308
  async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls) {
14930
- if (isAborted$2(signal)) return {
15309
+ if (isAborted$3(signal)) return {
14931
15310
  ok: false,
14932
15311
  error: Errors.cancelled({ operation: "payments" })
14933
15312
  };
@@ -14956,7 +15335,7 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
14956
15335
  ok: false,
14957
15336
  error: Errors.invalidInput("payment", "prepared authority mismatch")
14958
15337
  }, onPreparedClosed, controls);
14959
- if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
15338
+ if (isAborted$3(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
14960
15339
  ok: false,
14961
15340
  error: Errors.cancelled({ operation: "payments" })
14962
15341
  }, onPreparedClosed, controls);
@@ -14982,7 +15361,7 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
14982
15361
  error: signerFailure(deps.signer.source, "signUserOpHash", cause)
14983
15362
  }, onPreparedClosed, controls);
14984
15363
  }
14985
- if (isAborted$2(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
15364
+ if (isAborted$3(signal)) return abandonPrepared$1(deps, prepared.value.executionId, closePaymentOnExit, "cancelled", {
14986
15365
  ok: false,
14987
15366
  error: Errors.cancelled({ operation: "payments" })
14988
15367
  }, onPreparedClosed, controls);
@@ -15017,7 +15396,7 @@ function cancelled(operation) {
15017
15396
  error: Errors.cancelled({ operation })
15018
15397
  };
15019
15398
  }
15020
- function isAborted$1(signal) {
15399
+ function isAborted$2(signal) {
15021
15400
  return signal?.aborted === true;
15022
15401
  }
15023
15402
  async function signerCall(source, operation, run) {
@@ -15043,7 +15422,7 @@ async function abandonPrepared(deps, executionId, reason, result, onPreparedClos
15043
15422
  return result;
15044
15423
  }
15045
15424
  async function executePersonalPayment(deps, payment, signal, requestKey, onPreparedClosed) {
15046
- if (isAborted$1(signal)) return cancelled(CAPXUL_OPERATIONS.payments.pay);
15425
+ if (isAborted$2(signal)) return cancelled(CAPXUL_OPERATIONS.payments.pay);
15047
15426
  if (deps.signer === void 0) return mismatch("signer", "payments.pay requires a configured CapxulSigner");
15048
15427
  const session = deps.actor.authSession();
15049
15428
  if (session === null) return {
@@ -15071,10 +15450,10 @@ async function executePersonalPayment(deps, payment, signal, requestKey, onPrepa
15071
15450
  executionId: prepared.value.executionId,
15072
15451
  recipient: prepared.value.recipientObservation
15073
15452
  });
15074
- if (isAborted$1(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15453
+ if (isAborted$2(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15075
15454
  const signature = await signerCall(deps.signer.source, "signUserOpHash", () => deps.signer.signUserOpHash(prepared.value.digest));
15076
15455
  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);
15456
+ if (isAborted$2(signal)) return abandonPrepared(deps, prepared.value.executionId, "cancelled", cancelled(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
15078
15457
  return runIfActive(void 0, CAPXUL_OPERATIONS.payments.submitExecution, () => deps.convexCall.action(deps.functions.submitPaymentExecution, { input: {
15079
15458
  executionId: prepared.value.executionId,
15080
15459
  signature: signature.value
@@ -44993,7 +45372,9 @@ const OBSERVED_CONVEX_MUTATIONS = /* @__PURE__ */ new Set([
44993
45372
  "smartAccount/mutations:provision",
44994
45373
  "org/lifecycle:startOrResume",
44995
45374
  "org/lifecycle:recordFailure",
44996
- "org/lifecycle:retry"
45375
+ "org/lifecycle:retry",
45376
+ "org/mutations:invite",
45377
+ "org/mutations:accept"
44997
45378
  ]);
44998
45379
  var ConvexCallAdapter = class {
44999
45380
  #client;
@@ -45666,10 +46047,7 @@ const DEFAULT_FUNCTIONS$1 = {
45666
46047
  listAll: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listAll),
45667
46048
  listRoles: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listRolesByOrgId),
45668
46049
  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)
46050
+ readTreasury: makeFunctionReference(CAPXUL_FUNCTIONS["org/actions"].readTreasury)
45673
46051
  };
45674
46052
  /**
45675
46053
  * Standard production Organization read adapter. It intentionally has no
@@ -45705,22 +46083,6 @@ var ConvexOrganizationAdapter = class {
45705
46083
  pendingMembers(input) {
45706
46084
  return this.listMembers(input).pipe(Effect.map((members) => members.filter((member) => member.status === "pending" || member.status === "pending_safe" || member.status === "pending_grant")));
45707
46085
  }
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
46086
  #readTreasuryWire(input) {
45725
46087
  const orgId = String(input.orgId);
45726
46088
  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 +46127,12 @@ var ConvexOrganizationSetupAdapter = class {
45765
46127
  #fns;
45766
46128
  constructor(input) {
45767
46129
  this.#convex = input.convex;
45768
- this.#signer = input.signer;
46130
+ this.#signer = input.signer ?? null;
45769
46131
  this.#chainId = input.chainId;
45770
46132
  this.#fns = input.functions ?? DEFAULT_FUNCTIONS;
45771
46133
  }
45772
46134
  async startOrResume(input) {
46135
+ if (this.#signer === null) return fail$1(Errors.capabilityUnavailable("signer", "startOrResume"));
45773
46136
  const result = await runCall("startOrResume", this.#convex.mutation(this.#fns.startOrResume, copyInvocationObservation(input, {
45774
46137
  ...input,
45775
46138
  chainId: this.#chainId
@@ -45797,7 +46160,9 @@ var ConvexOrganizationSetupAdapter = class {
45797
46160
  async authorizeAndSubmitBootstrap(input) {
45798
46161
  const cancelled = cancellation(input.signal);
45799
46162
  if (cancelled !== void 0) return cancelled;
45800
- const signerAddress = await signerResult(this.#signer.source, "getAddress", () => this.#signer.getAddress());
46163
+ const signer = this.#signer;
46164
+ if (signer === null) return fail$1(Errors.capabilityUnavailable("signer", "authorizeAndSubmitBootstrap"));
46165
+ const signerAddress = await signerResult(signer.source, "getAddress", () => signer.getAddress());
45801
46166
  if (!signerAddress.ok) return signerAddress;
45802
46167
  const prepared = await runCall("prepareBootstrap", this.#convex.action(this.#fns.prepareBootstrap, copyInvocationObservation(input, {
45803
46168
  orgId: input.orgId,
@@ -45809,7 +46174,7 @@ var ConvexOrganizationSetupAdapter = class {
45809
46174
  if (!authority.ok) return authority;
45810
46175
  const cancelledAfterPrepare = cancellation(input.signal);
45811
46176
  if (cancelledAfterPrepare !== void 0) return cancelledAfterPrepare;
45812
- const signature = await signerResult(this.#signer.source, "signUserOpHash", () => this.#signer.signUserOpHash(prepared.value.digest));
46177
+ const signature = await signerResult(signer.source, "signUserOpHash", () => signer.signUserOpHash(prepared.value.digest));
45813
46178
  if (!signature.ok) return signature;
45814
46179
  const cancelledAfterSign = cancellation(input.signal);
45815
46180
  if (cancelledAfterSign !== void 0) return cancelledAfterSign;
@@ -45865,7 +46230,8 @@ var ConvexOrganizationSetupAdapter = class {
45865
46230
  ...input.observationContext === void 0 ? {} : { observationContext: input.observationContext }
45866
46231
  });
45867
46232
  if (!current.ok) return current;
45868
- if (current.value.status === "failed" && current.value.retryable && (current.value.at === "awaitingFounderAuthorization" || current.value.at === "submittingBootstrap")) {
46233
+ if (current.value.status === "failed" && current.value.retryable && current.value.at === "awaitingFounderAuthorization") {
46234
+ if (this.#signer === null) return fail$1(Errors.capabilityUnavailable("signer", "retry"));
45869
46235
  const reset = resetSignerSession(this.#signer);
45870
46236
  if (!reset.ok) return reset;
45871
46237
  }
@@ -47913,6 +48279,271 @@ function makeOrgMeMethod(deps, orgId) {
47913
48279
  };
47914
48280
  }
47915
48281
  //#endregion
48282
+ //#region ../../packages/sdk/src/contract/invitations.ts
48283
+ const invitationContract = {
48284
+ preview: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].previewInvite),
48285
+ listMine: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listMyInvitations),
48286
+ listScoped: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].listInvitations),
48287
+ get: makeFunctionReference(CAPXUL_FUNCTIONS["org/queries"].getInvitation),
48288
+ invite: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].invite),
48289
+ accept: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].accept),
48290
+ decline: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].decline),
48291
+ cancel: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].cancel),
48292
+ resend: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].resend),
48293
+ retry: makeFunctionReference(CAPXUL_FUNCTIONS["org/mutations"].retry)
48294
+ };
48295
+ //#endregion
48296
+ //#region ../../packages/sdk/src/surface/invitations.ts
48297
+ /**
48298
+ * The one refusal a scoped invitation result that names another Organization
48299
+ * receives, whether it was read or returned by the authoring write.
48300
+ */
48301
+ function scopeRefusal(orgId) {
48302
+ return Errors.invalidInput("orgId", `The invitation result does not belong to Organization ${JSON.stringify(orgId)}.`);
48303
+ }
48304
+ /**
48305
+ * A scoped invitation result belongs to the Organization it was read under.
48306
+ *
48307
+ * One owner holds the refusal copy and the verified-scope span: a single view
48308
+ * reports whether it names the scope, and a page — which names no Organization
48309
+ * of its own — reports whether every row does. A result that does not belong is
48310
+ * refused here rather than handed to a consumer, so a future route change
48311
+ * cannot turn into a silent cross-Organization read on a caller that trusted
48312
+ * the scope it passed. A successful scoped read also marks the verifying
48313
+ * Organization on the owning span, exactly as `org.me` does — the caller's
48314
+ * scope hint is not authority, the completed scoped read is.
48315
+ */
48316
+ function verifyScope(orgId, value, belongsToScope) {
48317
+ if (!belongsToScope(value)) return Effect.fail(scopeRefusal(orgId));
48318
+ return Effect.annotateCurrentSpan({
48319
+ verified_organization_id: orgId,
48320
+ scope_kind: "organization"
48321
+ }).pipe(Effect.as(value));
48322
+ }
48323
+ /** One view names its own Organization. */
48324
+ const namesScope = (orgId) => (value) => String(value.orgId) === orgId;
48325
+ /** A page names no Organization of its own, so every row must name the scope. */
48326
+ const rowsNameScope = (orgId) => (page) => page.items.every((item) => String(item.orgId) === orgId);
48327
+ const ops = CAPXUL_OPERATIONS.org.invitations;
48328
+ /** Truth for a caller-owned signal, without narrowing its type. */
48329
+ function isAborted$1(signal) {
48330
+ return signal?.aborted === true;
48331
+ }
48332
+ /**
48333
+ * One observed operation around one Convex hop, exactly like `org.me`. The
48334
+ * call-start invocation snapshot rides the arguments, so the backend continues
48335
+ * the attempt this call started rather than resolving a new one.
48336
+ */
48337
+ function observed$1(deps, operation, options, args, call, check) {
48338
+ const controls = deps.invocationControls?.(options) ?? options;
48339
+ 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);
48340
+ }
48341
+ /**
48342
+ * The Admin's preview stays a read: it reaches the preview query and nothing
48343
+ * else. It reads current policies and live assignments, so the operator sees
48344
+ * what the offered authority is now, not a frozen copy.
48345
+ */
48346
+ function makeOrgInvitationMethods(deps, orgId) {
48347
+ const scopeCheck = (value) => verifyScope(orgId, value, namesScope(orgId));
48348
+ return {
48349
+ preview: (input, options) => observed$1(deps, ops.preview, options, {
48350
+ orgId,
48351
+ request: input
48352
+ }, (args) => deps.convexCall.query(invitationContract.preview, args), scopeCheck),
48353
+ invite: makeInviteMethod(deps, orgId),
48354
+ accept: (input, options) => observed$1(deps, ops.accept, options, {
48355
+ orgId,
48356
+ invitationId: input.invitationId,
48357
+ expectedOfferDigest: input.expectedOfferDigest
48358
+ }, (args) => deps.convexCall.mutation(invitationContract.accept, args), scopeCheck),
48359
+ list: (input, options) => observed$1(deps, ops.listScoped, options, {
48360
+ orgId,
48361
+ ...pageArgs(input)
48362
+ }, (args) => deps.convexCall.query(invitationContract.listScoped, args), (page) => verifyScope(orgId, page, rowsNameScope(orgId))),
48363
+ get: (input, options) => observed$1(deps, ops.get, options, {
48364
+ orgId,
48365
+ invitationId: input.invitationId
48366
+ }, (args) => deps.convexCall.query(invitationContract.get, args), scopeCheck),
48367
+ decline: (input, options) => observed$1(deps, ops.decline, options, {
48368
+ orgId,
48369
+ invitationId: input.invitationId
48370
+ }, (args) => deps.convexCall.mutation(invitationContract.decline, args), scopeCheck),
48371
+ cancel: (input, options) => observed$1(deps, ops.cancel, options, {
48372
+ orgId,
48373
+ invitationId: input.invitationId
48374
+ }, (args) => deps.convexCall.mutation(invitationContract.cancel, args), scopeCheck),
48375
+ resend: (input, options) => observed$1(deps, ops.resend, options, {
48376
+ orgId,
48377
+ invitationId: input.invitationId
48378
+ }, (args) => deps.convexCall.mutation(invitationContract.resend, args), scopeCheck),
48379
+ retry: (input, options) => observed$1(deps, ops.retry, options, {
48380
+ orgId,
48381
+ invitationId: input.invitationId
48382
+ }, (args) => deps.convexCall.mutation(invitationContract.retry, args), scopeCheck)
48383
+ };
48384
+ }
48385
+ /**
48386
+ * The authoring write, including its configuration hop.
48387
+ *
48388
+ * The mutation persists the invitation and its configure command before any
48389
+ * signature exists. The write then drives the existing human configuration
48390
+ * owner exactly as the Permission and payment surfaces drive theirs: prepare
48391
+ * the stored command for this Account's Safe, check the prepared authority
48392
+ * against the request, deliver the durable identity to the caller, sign the
48393
+ * returned digest, and submit it. The backend keeps the only authorization
48394
+ * rule (`prepareInvitationConfigurationIntentInTx` /
48395
+ * `submitInvitationConfigurationExecution`); this edge adds no second one.
48396
+ *
48397
+ * Cancellation owns the whole compound: an abort before the digest is signed
48398
+ * stops the write and forwards no signature, and an already-signed submission
48399
+ * completes.
48400
+ */
48401
+ async function executeInvite(deps, orgId, input, signal, controls, verifiedOrganization, onPrepared) {
48402
+ if (isAborted$1(signal)) return {
48403
+ ok: false,
48404
+ error: Errors.cancelled({ operation: ops.authorize })
48405
+ };
48406
+ if (deps.actor === void 0 || deps.chainId === void 0 || deps.signer === void 0) return {
48407
+ ok: false,
48408
+ error: Errors.notImplemented("invitations", "executionComposition")
48409
+ };
48410
+ const session = deps.actor.authSession();
48411
+ if (session === null) return {
48412
+ ok: false,
48413
+ error: Errors.notAuthenticated()
48414
+ };
48415
+ const authored = await runIfActive(signal, ops.authorize, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.mutation(invitationContract.invite, copyInvocationObservation(controls, {
48416
+ orgId,
48417
+ request: input
48418
+ }))), controls), deps.runPromise);
48419
+ if (!authored.ok) return authored;
48420
+ const view = authored.value;
48421
+ if (String(view.orgId) !== orgId) return {
48422
+ ok: false,
48423
+ error: scopeRefusal(orgId)
48424
+ };
48425
+ if (view.phase !== "authorizing") return {
48426
+ ok: true,
48427
+ value: view
48428
+ };
48429
+ if (view.commandId === null) return {
48430
+ ok: false,
48431
+ error: Errors.invalidInput("invitationId", "The invitation does not name its configuration command.")
48432
+ };
48433
+ const commandId = view.commandId;
48434
+ let signerAddress;
48435
+ try {
48436
+ signerAddress = await deps.signer.getAddress();
48437
+ } catch (cause) {
48438
+ return {
48439
+ ok: false,
48440
+ error: signerFailure(deps.signer.source, "getAddress", cause)
48441
+ };
48442
+ }
48443
+ const prepared = await runIfActive(signal, ops.prepareConfiguration, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(moneyExecutionContract.prepareInvitationConfiguration, copyInvocationObservation(controls, { input: {
48444
+ commandId,
48445
+ signerAddress
48446
+ } }))), controls), deps.runPromise);
48447
+ if (!prepared.ok) return prepared;
48448
+ const expectedSafe = deriveCapxulSafeAddress({ email: session.email });
48449
+ if (!preparedAuthorityMatches({
48450
+ prepared: prepared.value,
48451
+ chainId: deps.chainId,
48452
+ signerAddress,
48453
+ expectedSafe,
48454
+ commandId,
48455
+ invitationId: view.id,
48456
+ orgId
48457
+ })) return {
48458
+ ok: false,
48459
+ error: Errors.invalidInput("invitation", "prepared authority mismatch")
48460
+ };
48461
+ verifiedOrganization(prepared.value.orgId);
48462
+ if (isAborted$1(signal)) return {
48463
+ ok: false,
48464
+ error: Errors.cancelled({ operation: ops.authorize })
48465
+ };
48466
+ if (onPrepared !== void 0) try {
48467
+ await onPrepared({
48468
+ invitationId: prepared.value.invitationId,
48469
+ commandId: prepared.value.commandId
48470
+ });
48471
+ } catch (cause) {
48472
+ return {
48473
+ ok: false,
48474
+ error: cause instanceof CapxulError ? cause : Errors.unknown(cause)
48475
+ };
48476
+ }
48477
+ if (isAborted$1(signal)) return {
48478
+ ok: false,
48479
+ error: Errors.cancelled({ operation: ops.authorize })
48480
+ };
48481
+ let signature;
48482
+ try {
48483
+ signature = await deps.signer.signUserOpHash(prepared.value.digest);
48484
+ } catch (cause) {
48485
+ return {
48486
+ ok: false,
48487
+ error: signerFailure(deps.signer.source, "signUserOpHash", cause)
48488
+ };
48489
+ }
48490
+ if (isAborted$1(signal)) return {
48491
+ ok: false,
48492
+ error: Errors.cancelled({ operation: ops.authorize })
48493
+ };
48494
+ const submitted = await runIfActive(void 0, ops.submitConfiguration, () => withInvocationParentSpan(Effect.suspend(() => deps.convexCall.action(moneyExecutionContract.submitInvitationConfigurationExecution, copyInvocationObservation(controls, { input: {
48495
+ executionId: prepared.value.executionId,
48496
+ signature
48497
+ } }))), controls), deps.runPromise);
48498
+ if (!submitted.ok) return submitted;
48499
+ return {
48500
+ ok: true,
48501
+ value: view
48502
+ };
48503
+ }
48504
+ /**
48505
+ * The prepared authority must be exactly the one this write asked for: the same
48506
+ * chain, the caller's signer, this Account's Safe, and the exact command and
48507
+ * invitation the authoring view named.
48508
+ */
48509
+ function preparedAuthorityMatches(input) {
48510
+ 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;
48511
+ }
48512
+ function makeInviteMethod(deps, orgId) {
48513
+ return (input, options) => {
48514
+ const { onPrepared, ...supplied } = options ?? {};
48515
+ const controls = deps.invocationControls?.(supplied) ?? supplied;
48516
+ let verifiedOrganizationId;
48517
+ return runCapxulEffect(Effect.gen(function* () {
48518
+ if (controls?.signal?.aborted === true) return yield* Effect.fail(Errors.cancelled({ operation: ops.authorize }));
48519
+ const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
48520
+ const captured = carryInvocationParentSpan(controls, parent);
48521
+ const result = yield* Effect.tryPromise({
48522
+ try: () => executeInvite(deps, orgId, input, controls?.signal, captured, (id) => {
48523
+ verifiedOrganizationId = id;
48524
+ }, onPrepared),
48525
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.unknown(cause)
48526
+ });
48527
+ return yield* result.ok ? Effect.succeed(result.value) : Effect.fail(result.error);
48528
+ }).pipe(Effect.ensuring(Effect.suspend(() => verifiedOrganizationId === void 0 ? Effect.void : Effect.annotateCurrentSpan({
48529
+ verified_organization_id: verifiedOrganizationId,
48530
+ scope_kind: "organization"
48531
+ })).pipe(Effect.catchCause(() => Effect.void)))), observationOnlyControls(controls), ops.authorize, deps.runPromise);
48532
+ };
48533
+ }
48534
+ /** Drop the page fields the caller did not supply; a bounded page sends only its bounds. */
48535
+ function pageArgs(input) {
48536
+ if (input === void 0) return {};
48537
+ return {
48538
+ ...input.cursor === void 0 ? {} : { cursor: input.cursor },
48539
+ ...input.limit === void 0 ? {} : { limit: input.limit },
48540
+ ...input.phases === void 0 ? {} : { phases: input.phases }
48541
+ };
48542
+ }
48543
+ function makeOwnInvitationsMethod(deps) {
48544
+ return (input, options) => observed$1(deps, ops.list, options, pageArgs(input), (args) => deps.convexCall.query(invitationContract.listMine, args));
48545
+ }
48546
+ //#endregion
47916
48547
  //#region ../../packages/sdk/src/contract/permission.ts
47917
48548
  const permissionContract = { read: makeFunctionReference(CAPXUL_FUNCTIONS["permission/queries"].read) };
47918
48549
  //#endregion
@@ -48600,20 +49231,6 @@ function hermeticOrgView(input) {
48600
49231
  observedAt: 0
48601
49232
  };
48602
49233
  }
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
49234
  function createOrgProgram(input) {
48618
49235
  return Effect.gen(function* () {
48619
49236
  const deps = yield* OrgDepsTag;
@@ -48714,35 +49331,6 @@ function listMembersProgram(orgId) {
48714
49331
  return [];
48715
49332
  });
48716
49333
  }
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
49334
  function listOrgsProgram() {
48747
49335
  return Effect.gen(function* () {
48748
49336
  const deps = yield* OrgDepsTag;
@@ -48848,6 +49436,20 @@ function observedRunnerDeps(deps) {
48848
49436
  ...deps.invocationControls === void 0 ? {} : { invocationControls: deps.invocationControls }
48849
49437
  };
48850
49438
  }
49439
+ /**
49440
+ * The invitation edge needs the call seam, the observed-runner pair, and — for
49441
+ * the authoring write's configuration hop — the same execution composition the
49442
+ * Permission, payment, and payroll bundles receive.
49443
+ */
49444
+ function invitationMethodsDeps(deps, convexCall) {
49445
+ return {
49446
+ convexCall,
49447
+ ...observedRunnerDeps(deps),
49448
+ ...deps.actor === void 0 ? {} : { actor: deps.actor },
49449
+ ...deps.chainId === void 0 ? {} : { chainId: Number(deps.chainId) },
49450
+ ...deps.signer === void 0 ? {} : { signer: deps.signer }
49451
+ };
49452
+ }
48851
49453
  function makeOrgMethods(deps) {
48852
49454
  const orgDeps = {
48853
49455
  ...deps.orgPort === void 0 ? {} : { orgPort: deps.orgPort },
@@ -48879,13 +49481,10 @@ function makeOrgMethods(deps) {
48879
49481
  });
48880
49482
  return toCapxulResult(createOrgProgram(input), layer);
48881
49483
  },
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
- } }),
49484
+ orgs: Object.assign((options) => listOrganizations(deps.invocationControls?.(options) ?? options), { invitations: deps.convexCall === void 0 ? () => Promise.resolve({
49485
+ ok: false,
49486
+ error: Errors.notImplemented("invitations", "listOwn")
49487
+ }) : makeOwnInvitationsMethod(invitationMethodsDeps(deps, deps.convexCall)) }),
48889
49488
  org(orgId) {
48890
49489
  const convexCall = deps.convexCall;
48891
49490
  return {
@@ -48993,17 +49592,7 @@ function makeOrgMethods(deps) {
48993
49592
  });
48994
49593
  return toCapxulResult(listRolesProgram(orgId), layer);
48995
49594
  },
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
- },
49595
+ invitations: convexCall === void 0 ? makeNotImplementedInvitationMethods() : makeOrgInvitationMethods(invitationMethodsDeps(deps, convexCall), String(orgId)),
49007
49596
  auditLog(_options) {
49008
49597
  if (_options?.signal?.aborted) return Promise.resolve({
49009
49598
  ok: false,
@@ -49066,6 +49655,28 @@ const orgMeUnavailable = () => Promise.resolve({
49066
49655
  ok: false,
49067
49656
  error: Errors.notImplemented("org", "me")
49068
49657
  });
49658
+ /**
49659
+ * The closed invitation surface for a client with no backend seam. It reports
49660
+ * `NOT_IMPLEMENTED` for every method rather than an empty list or a fabricated
49661
+ * view: an absent composition root is not an absent invitation.
49662
+ */
49663
+ function makeNotImplementedInvitationMethods() {
49664
+ return {
49665
+ preview: invitationExecutionUnavailable,
49666
+ invite: invitationExecutionUnavailable,
49667
+ accept: invitationExecutionUnavailable,
49668
+ list: invitationExecutionUnavailable,
49669
+ get: invitationExecutionUnavailable,
49670
+ decline: invitationExecutionUnavailable,
49671
+ cancel: invitationExecutionUnavailable,
49672
+ resend: invitationExecutionUnavailable,
49673
+ retry: invitationExecutionUnavailable
49674
+ };
49675
+ }
49676
+ const invitationExecutionUnavailable = () => Promise.resolve({
49677
+ ok: false,
49678
+ error: Errors.notImplemented("invitations", "executionComposition")
49679
+ });
49069
49680
  const permissionExecutionUnavailable = () => Promise.resolve({
49070
49681
  ok: false,
49071
49682
  error: Errors.notImplemented("permissions", "executionComposition")
@@ -49565,7 +50176,6 @@ function assembleCapxulClient(input) {
49565
50176
  };
49566
50177
  if (input.signal !== void 0) input.signal.addEventListener("abort", () => void stopActor(), { once: true });
49567
50178
  const selectedOrgPort = input.orgPort ?? input.orgDeploymentPort;
49568
- let detectPendingOrgInvitations;
49569
50179
  let kickProvisioning;
49570
50180
  const financialOps = makeFinancialOpsMethods({
49571
50181
  runPromise: effectRunner.runPromise,
@@ -49614,7 +50224,6 @@ function assembleCapxulClient(input) {
49614
50224
  if (browserSigner.statusStore?.status() === "unknown" && typeof browserSigner.ensureWalletReady === "function") browserSigner.ensureWalletReady().catch(() => {});
49615
50225
  }
49616
50226
  if (accountSetup === "explicit") return;
49617
- await detectPendingOrgInvitations?.();
49618
50227
  kickProvisioning?.();
49619
50228
  }
49620
50229
  });
@@ -49682,9 +50291,6 @@ function assembleCapxulClient(input) {
49682
50291
  ...input.signer === void 0 ? {} : { signer: input.signer },
49683
50292
  ...input.organizationSetup === void 0 ? {} : { organizationSetup: input.organizationSetup }
49684
50293
  });
49685
- if (selectedOrgPort !== void 0) detectPendingOrgInvitations = async () => {
49686
- await orgMethods.orgs.detectAndAcceptPendingInvitations();
49687
- };
49688
50294
  const currentUser = makeCurrentUserMethods({
49689
50295
  me: financialOps.me,
49690
50296
  accounts,
@@ -50938,11 +51544,11 @@ async function createCapxulClientWithSignerControls(input, controls) {
50938
51544
  accountSetup: input.accountSetup,
50939
51545
  ...signer === void 0 ? {} : { signer },
50940
51546
  orgPort: Context.get(adapters.value.context, OrgPortTag),
50941
- ...signer === void 0 ? {} : { organizationSetup: new ConvexOrganizationSetupAdapter({
51547
+ organizationSetup: new ConvexOrganizationSetupAdapter({
50942
51548
  convex: adapters.value.ports.convexCall,
50943
- signer,
51549
+ ...signer === void 0 ? {} : { signer },
50944
51550
  chainId: adapters.value.bootstrap.chainId
50945
- }) },
51551
+ }),
50946
51552
  ...input.signal === void 0 ? {} : { signal: input.signal },
50947
51553
  ...input.otpTtlMs === void 0 ? {} : { otpTtlMs: input.otpTtlMs },
50948
51554
  invokeTimeoutMs: input.invokeTimeoutMs ?? 3e4,
@@ -51336,7 +51942,7 @@ const staffTools = [
51336
51942
  scope: MANAGE,
51337
51943
  register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.roles, {
51338
51944
  title: "List Organization roles",
51339
- description: "List the active role labels that an Organization invitation can use.",
51945
+ description: "List active Organization role labels.",
51340
51946
  inputSchema: z.object(orgInput),
51341
51947
  outputSchema: z.object({ roles: z.array(z.object({ label: z.string() })) })
51342
51948
  }, ({ organizationId }) => withClient(scope, CAPXUL_OPERATIONS.org.roles, MANAGE, async (client) => {
@@ -51349,7 +51955,7 @@ const staffTools = [
51349
51955
  scope: MANAGE,
51350
51956
  register: (server, scope) => server.registerTool(CAPXUL_OPERATIONS.org.members, {
51351
51957
  title: "List Organization members",
51352
- description: "List Organization member lifecycle states. Poll after activation until the member is active.",
51958
+ description: "List current Organization member lifecycle states.",
51353
51959
  inputSchema: z.object(orgInput),
51354
51960
  outputSchema: z.object({ members: z.array(z.object({
51355
51961
  accountId: z.string().nullable(),
@@ -51362,66 +51968,6 @@ const staffTools = [
51362
51968
  const result = await client.listOrganizationMembers(organizationId);
51363
51969
  return result.ok ? okResult({ members: [...result.value] }) : errorResult(result.error);
51364
51970
  }))
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
51971
  }
51426
51972
  ];
51427
51973
  //#endregion
@@ -51748,7 +52294,7 @@ function stdioIdentity(env = process.env, options = {}) {
51748
52294
  }
51749
52295
  //#endregion
51750
52296
  //#region package.json
51751
- var version = "4.20.0-beta.6";
52297
+ var version = "4.20.0-beta.7";
51752
52298
  //#endregion
51753
52299
  //#region src/deps.ts
51754
52300
  const NO_IDENTITY = async () => void 0;
@@ -51833,9 +52379,6 @@ const SAFE_TOOL_INTENTS = {
51833
52379
  [CAPXUL_OPERATIONS.system.health]: "Verify MCP backend health.",
51834
52380
  [CAPXUL_OPERATIONS.onboarding.completePerson]: "Complete Person onboarding.",
51835
52381
  [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
52382
  [CAPXUL_OPERATIONS.org.list]: "List Organizations.",
51840
52383
  [CAPXUL_OPERATIONS.org.members]: "List Organization members.",
51841
52384
  [CAPXUL_OPERATIONS.org.roles]: "List Organization roles.",
@@ -52254,85 +52797,6 @@ async function createSdkClient(input, createClient = createCapxulClient) {
52254
52797
  }))
52255
52798
  };
52256
52799
  },
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
52800
  getLifecycle: async () => {
52337
52801
  const result = await client.account.getLifecycle();
52338
52802
  if (!result.ok) return result;