@capxul/cli 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.
@@ -5421,6 +5421,28 @@
5421
5421
  //#region ../../packages/config/src/org-payments.ts
5422
5422
  /** Zodiac MultiSendCallOnly module on Base Sepolia. */
5423
5423
  const MULTI_SEND_CALL_ONLY = "0x9641d764fc13c8b624c04430c7356c1c7c8102e2";
5424
+ /** Supported Organization permission identities, newest first. */
5425
+ const ORG_PERMISSION_IDENTITY_PROFILES = [{
5426
+ id: "zodiac-roles-2.1.1",
5427
+ moduleFactoryRuntimeKeccak256: "0x01623cbcf010a1c326230f1b2d5f48a66b440232ee49096102bc84967dc5f21e",
5428
+ mastercopy: "0xf2964ce6161ce0e75964fe7927ce114cb0b283d5",
5429
+ mastercopyRuntimeKeccak256: "0x471d8b3b419f1eb955230c0326c8812176df49bf3c7b414a563fda5a3c6c10b6",
5430
+ proxyRuntimeKeccak256: "0x248f9591f94c24c199ade3e73feb477cf02d387b2bea91f2f931a0deb094f163",
5431
+ multiSendUnwrapper: "0xb4cd4bb764c089f20da18700ce8bc5e49f369efd",
5432
+ multiSendUnwrapperRuntimeKeccak256: "0x1f6e088be5e6ef9d0fbe0547d3fa9a9e40d823433fd8a4449215b5663209a1eb"
5433
+ }, {
5434
+ id: "zodiac-roles-2.1.0",
5435
+ moduleFactoryRuntimeKeccak256: "0x01623cbcf010a1c326230f1b2d5f48a66b440232ee49096102bc84967dc5f21e",
5436
+ mastercopy: "0x9646fdad06d3e24444381f44362a3b0eb343d337",
5437
+ mastercopyRuntimeKeccak256: "0x87911cbc6aa0496e6bcb07dab2462b9c76daea130dede6dcc57d0adf307fa7ec",
5438
+ proxyRuntimeKeccak256: "0x9d4059abf46db50e4b48d9b6404b1f200cb5a1efeb3725be2de630a2a9001944",
5439
+ multiSendUnwrapper: "0x93b7fcbc63ed8a3a24b59e1c3e6649d50b7427c0",
5440
+ multiSendUnwrapperRuntimeKeccak256: "0x4d8d8608b70a6e2f40726b9dd74406bbf73e90cac58e23ee953e2b45ad7dc3df"
5441
+ }];
5442
+ const CURRENT_ORG_PERMISSION_IDENTITY = ORG_PERMISSION_IDENTITY_PROFILES[0];
5443
+ ORG_PERMISSION_IDENTITY_PROFILES[1];
5444
+ CURRENT_ORG_PERMISSION_IDENTITY.mastercopy;
5445
+ CURRENT_ORG_PERMISSION_IDENTITY.multiSendUnwrapper;
5424
5446
  //#endregion
5425
5447
  //#region ../../packages/config/src/capxul-payments-v2.ts
5426
5448
  /** The exact compiled CapxulPaymentsV2 ABI. */
@@ -17571,10 +17593,12 @@
17571
17593
  prepareOrganizationPaymentExecution: "moneyExecution.prepareOrganizationPaymentExecution",
17572
17594
  preparePaymentExecution: "moneyExecution.preparePaymentExecution",
17573
17595
  preparePaymentLifecycleExecution: "moneyExecution.preparePaymentLifecycleExecution",
17596
+ prepareInvitationConfiguration: "moneyExecution.prepareInvitationConfiguration",
17574
17597
  preparePermissionExecution: "moneyExecution.preparePermissionExecution",
17575
17598
  recoverSubmissionClaims: "moneyExecution.recoverSubmissionClaims",
17576
17599
  submit: "moneyExecution.submit",
17577
17600
  submitPaymentCommandExecution: "moneyExecution.submitPaymentCommandExecution",
17601
+ submitInvitationConfigurationExecution: "moneyExecution.submitInvitationConfigurationExecution",
17578
17602
  submitPaymentExecution: "moneyExecution.submitPaymentExecution",
17579
17603
  submitPermissionExecution: "moneyExecution.submitPermissionExecution"
17580
17604
  },
@@ -17596,20 +17620,52 @@
17596
17620
  completePerson: "onboarding.completePerson"
17597
17621
  },
17598
17622
  org: {
17599
- acceptInvitations: "org.acceptInvitations",
17600
17623
  account: { get: "org.account.get" },
17601
- activateMember: "org.activateMember",
17602
17624
  auditLog: "org.auditLog",
17603
17625
  confirmBootstrap: "org.confirmBootstrap",
17604
17626
  createOrg: "org.createOrg",
17605
17627
  create: "org.create",
17606
- detectAndAcceptPendingInvitations: "org.detectAndAcceptPendingInvitations",
17628
+ /**
17629
+ * §11: the consent mutation reports `org_invite_accepted` through its own
17630
+ * scheduled emitter. It is named for the emit, not the acceptance, because
17631
+ * the interactive acceptance itself owns `org.invitations.accept`.
17632
+ */
17633
+ emitInviteAccepted: "org.emitInviteAccepted",
17607
17634
  emitInviteProgressed: "org.emitInviteProgressed",
17608
17635
  expireInvitations: "org.expireInvitations",
17609
17636
  getLifecycle: "org.getLifecycle",
17610
17637
  getProofReceipt: "org.getProofReceipt",
17611
17638
  invite: "org.invite",
17612
- inviteMember: "org.inviteMember",
17639
+ /** D8 invitation lifecycle: preview, own list, read, and the four transitions. */
17640
+ invitations: {
17641
+ /** The exact grantee's consent commit (§8): one accepted digest, once. */
17642
+ accept: "org.invitations.accept",
17643
+ /**
17644
+ * The authoring write. It is named `authorize`, not `invite`, because the
17645
+ * backend already uses `org.invitations.invite` as a refusal label and
17646
+ * `lint:telemetry-spine` refuses a label that collides with an operation.
17647
+ */
17648
+ authorize: "org.invitations.authorize",
17649
+ cancel: "org.invitations.cancel",
17650
+ decline: "org.invitations.decline",
17651
+ get: "org.invitations.get",
17652
+ list: "org.invitations.list",
17653
+ /**
17654
+ * The Admin-scoped Organization list. It is named `listScoped`, not
17655
+ * `list`, because the own-offer list already owns `org.invitations.list`.
17656
+ */
17657
+ listScoped: "org.invitations.listScoped",
17658
+ /**
17659
+ * The authoring write's inner hops: the SDK drives the backend's existing
17660
+ * prepare/submit pair, and these names label the two Convex calls. The
17661
+ * owning `capxul_sdk_operation` record stays `org.invitations.authorize`.
17662
+ */
17663
+ prepareConfiguration: "org.invitations.prepareConfiguration",
17664
+ preview: "org.invitations.preview",
17665
+ resend: "org.invitations.resend",
17666
+ retry: "org.invitations.retry",
17667
+ submitConfiguration: "org.invitations.submitConfiguration"
17668
+ },
17613
17669
  list: "org.list",
17614
17670
  load: "org.load",
17615
17671
  me: "org.me",
@@ -17668,7 +17724,6 @@
17668
17724
  },
17669
17725
  recordFailure: "org.recordFailure",
17670
17726
  recordProgress: "org.recordProgress",
17671
- resendInviteToken: "org.resendInviteToken",
17672
17727
  resumeBootstrapSubmission: "org.resumeBootstrapSubmission",
17673
17728
  retry: "org.retry",
17674
17729
  retrySetup: "org.retrySetup",
@@ -17685,7 +17740,6 @@
17685
17740
  retry: "organizationPayments.retry"
17686
17741
  },
17687
17742
  organizationSetup: { getProofReceipt: "organizationSetup.getProofReceipt" },
17688
- organizations: { detectAndAcceptPendingInvitations: "orgs.detectAndAcceptPendingInvitations" },
17689
17743
  payments: {
17690
17744
  cancel: "payments.cancel",
17691
17745
  claim: "payments.claim",
@@ -17723,6 +17777,7 @@
17723
17777
  terms: "payroll.terms"
17724
17778
  },
17725
17779
  permission: {
17780
+ verifyInvitationConfiguration: "permission.verifyInvitationConfiguration",
17726
17781
  command: "permission.command",
17727
17782
  retryVerification: "permission.retryVerification",
17728
17783
  verify: "permission.verify",
@@ -18259,6 +18314,11 @@
18259
18314
  const OrgInviteSentProps = Struct({
18260
18315
  ...TelemetryEnvelopeProps,
18261
18316
  org_id: OptionalOrgId,
18317
+ invitation_id: OptionalString,
18318
+ generation: OptionalString,
18319
+ command_id: OptionalString,
18320
+ subject_party_id: OptionalString,
18321
+ persisted_at: OptionalEpochMs,
18262
18322
  email_domain: OptionalString,
18263
18323
  role: OptionalString,
18264
18324
  status: OptionalString
@@ -18266,6 +18326,11 @@
18266
18326
  const OrgInviteAcceptedProps = Struct({
18267
18327
  ...TelemetryEnvelopeProps,
18268
18328
  org_id: OptionalOrgId,
18329
+ invitation_id: OptionalString,
18330
+ accepted_at: OptionalEpochMs,
18331
+ generation: OptionalString,
18332
+ command_id: OptionalString,
18333
+ subject_party_id: OptionalString,
18269
18334
  role: OptionalString,
18270
18335
  status: OptionalString
18271
18336
  });
@@ -18273,6 +18338,7 @@
18273
18338
  ...TelemetryEnvelopeProps,
18274
18339
  org_id: OptionalOrgId,
18275
18340
  email_domain: OptionalString,
18341
+ invitation_id: OptionalString,
18276
18342
  reason: OptionalString,
18277
18343
  role: OptionalString,
18278
18344
  status: OptionalString
@@ -18425,9 +18491,24 @@
18425
18491
  "applied",
18426
18492
  "replayed",
18427
18493
  "conflicting_replay",
18428
- "revision_mismatch"
18494
+ "revision_mismatch",
18495
+ "cleanup_required",
18496
+ "not_applied",
18497
+ "application_failure",
18498
+ "mismatch",
18499
+ "refused"
18429
18500
  ])),
18501
+ command_kind: optional(Literals(["invitation_configuration", "invitation_eoa"])),
18430
18502
  command_id: OptionalString,
18503
+ invitation_id: OptionalString,
18504
+ generation: OptionalString,
18505
+ purpose: optional(Literals([
18506
+ "configure",
18507
+ "grant",
18508
+ "disable",
18509
+ "compensate"
18510
+ ])),
18511
+ $insert_id: OptionalString,
18431
18512
  /**
18432
18513
  * #1961 R03. The authorized stored row names the Permission it changed; the
18433
18514
  * verified receipt names the chain facts that prove it. Every field is
@@ -18814,6 +18895,13 @@
18814
18895
  "auth.profile",
18815
18896
  "auth.status",
18816
18897
  "auth.logout",
18898
+ "contact",
18899
+ "contact.list",
18900
+ "contact.get",
18901
+ "contact.add",
18902
+ "contact.label",
18903
+ "contact.hide",
18904
+ "contact.unhide",
18817
18905
  "org",
18818
18906
  CAPXUL_OPERATIONS.org.list,
18819
18907
  "org.use",
@@ -18822,6 +18910,24 @@
18822
18910
  CAPXUL_OPERATIONS.org.members,
18823
18911
  "org.member",
18824
18912
  "org.member.get",
18913
+ "org.member.invite",
18914
+ "org.contact",
18915
+ "org.contact.list",
18916
+ "org.contact.get",
18917
+ "org.contact.add",
18918
+ "org.contact.label",
18919
+ "org.contact.hide",
18920
+ "org.contact.unhide",
18921
+ CAPXUL_OPERATIONS.org.invite,
18922
+ "org.invite.list",
18923
+ "org.invite.get",
18924
+ "org.invite.wait",
18925
+ "org.invite.review",
18926
+ "org.invite.accept",
18927
+ "org.invite.decline",
18928
+ "org.invite.cancel",
18929
+ "org.invite.resend",
18930
+ "org.invite.retry",
18825
18931
  "org.wait",
18826
18932
  CAPXUL_OPERATIONS.org.create,
18827
18933
  CAPXUL_OPERATIONS.org.retry,
@@ -18832,7 +18938,8 @@
18832
18938
  "diagnostics",
18833
18939
  "collection",
18834
18940
  "authentication",
18835
- "organization"
18941
+ "organization",
18942
+ "contacts"
18836
18943
  ];
18837
18944
  const CLI_INVOCATION_KINDS = [
18838
18945
  "command",
@@ -19074,6 +19181,7 @@
19074
19181
  ...TelemetryEnvelopeProps,
19075
19182
  organization_id: OrgIdTelemetrySchema,
19076
19183
  progress: Literals([
19184
+ "configuration_authorized",
19077
19185
  "account_ready",
19078
19186
  "permission_applied",
19079
19187
  "membership_activated",
@@ -19081,6 +19189,9 @@
19081
19189
  ]),
19082
19190
  /** The invited Party. The initiating actor stays on the envelope's identity. */
19083
19191
  member_party_id: String$1,
19192
+ invitation_id: optional(String$1),
19193
+ generation: optional(String$1),
19194
+ command_id: optional(String$1),
19084
19195
  occurred_at: Number$1
19085
19196
  })
19086
19197
  });
@@ -19374,8 +19485,10 @@
19374
19485
  "movement/annotations": { overlay: "movement/annotations:overlay" },
19375
19486
  "moneyExecution/actions": {
19376
19487
  abandonPaymentExecution: "moneyExecution/actions:abandonPaymentExecution",
19488
+ prepareInvitationConfiguration: "moneyExecution/actions:prepareInvitationConfiguration",
19377
19489
  preparePermissionExecution: "moneyExecution/actions:preparePermissionExecution",
19378
19490
  preparePaymentExecution: "moneyExecution/actions:preparePaymentExecution",
19491
+ submitInvitationConfigurationExecution: "moneyExecution/actions:submitInvitationConfigurationExecution",
19379
19492
  submitPermissionExecution: "moneyExecution/actions:submitPermissionExecution",
19380
19493
  submitPaymentExecution: "moneyExecution/actions:submitPaymentExecution"
19381
19494
  },
@@ -19392,8 +19505,6 @@
19392
19505
  },
19393
19506
  "org/actions": {
19394
19507
  confirmBootstrap: "org/actions:confirmBootstrap",
19395
- detectAndAcceptPendingInvitations: "org/actions:detectAndAcceptPendingInvitations",
19396
- inviteMember: "org/actions:inviteMember",
19397
19508
  prepareBootstrap: "org/actions:prepareBootstrap",
19398
19509
  prepareFounderAccount: "org/actions:prepareFounderAccount",
19399
19510
  readTreasury: "org/actions:readTreasury",
@@ -19424,16 +19535,25 @@
19424
19535
  startOrResume: "org/lifecycle:startOrResume"
19425
19536
  },
19426
19537
  "org/mutations": {
19538
+ accept: "org/mutations:accept",
19539
+ cancel: "org/mutations:cancel",
19427
19540
  createOrg: "org/mutations:createOrg",
19428
- resendInviteToken: "org/mutations:resendInviteToken"
19541
+ decline: "org/mutations:decline",
19542
+ invite: "org/mutations:invite",
19543
+ resend: "org/mutations:resend",
19544
+ retry: "org/mutations:retry"
19429
19545
  },
19430
19546
  "org/queries": {
19547
+ getInvitation: "org/queries:getInvitation",
19431
19548
  listAll: "org/queries:listAll",
19549
+ listInvitations: "org/queries:listInvitations",
19432
19550
  listMembersByOrgId: "org/queries:listMembersByOrgId",
19433
19551
  listMine: "org/queries:listMine",
19552
+ listMyInvitations: "org/queries:listMyInvitations",
19434
19553
  listRolesByOrgId: "org/queries:listRolesByOrgId",
19435
19554
  loadByOrgId: "org/queries:loadByOrgId",
19436
- me: "org/queries:me"
19555
+ me: "org/queries:me",
19556
+ previewInvite: "org/queries:previewInvite"
19437
19557
  },
19438
19558
  "smartAccount/actions": {
19439
19559
  claim: "smartAccount/actions:claim",
@@ -20369,6 +20489,93 @@
20369
20489
  topic0: Bytes32Schema,
20370
20490
  dataHash: Bytes32Schema
20371
20491
  });
20492
+ const InvitationEoaReceiptSchema = Struct({
20493
+ kind: Literal("invitation_eoa"),
20494
+ chainId: BaseSepoliaChainIdSchema,
20495
+ transactionHash: TxHashSchema,
20496
+ blockNumber: BlockNumberSchema,
20497
+ blockHash: Bytes32Schema,
20498
+ sender: AddressSchema,
20499
+ nonce: String$1.pipe(refine((value) => /^(0|[1-9][0-9]*)$/.test(value)))
20500
+ });
20501
+ const PermissionEventRefSchema = Struct({
20502
+ receipt: Union([Struct({
20503
+ kind: Literal("user_operation"),
20504
+ ...ReceiptRefSchema.fields
20505
+ }), InvitationEoaReceiptSchema]),
20506
+ emitter: AddressSchema,
20507
+ transactionIndex: LogIndexSchema,
20508
+ logIndex: LogIndexSchema,
20509
+ topic0: Bytes32Schema,
20510
+ dataHash: Bytes32Schema
20511
+ });
20512
+ Union([
20513
+ Struct({
20514
+ status: Literal("pending"),
20515
+ reason: Literal("receipt_missing")
20516
+ }),
20517
+ Struct({
20518
+ status: Literal("provider_failure"),
20519
+ retryable: Literal(true)
20520
+ }),
20521
+ Struct({
20522
+ status: Literal("mismatch"),
20523
+ code: Literals([
20524
+ "wrong_chain",
20525
+ "wrong_sender",
20526
+ "wrong_transaction",
20527
+ "failed_transaction",
20528
+ "non_canonical_block",
20529
+ "wrong_contract_identity",
20530
+ "missing_event",
20531
+ "extra_authority_event",
20532
+ "wrong_fact_tuple",
20533
+ "wrong_state",
20534
+ "conflicting_replay"
20535
+ ]),
20536
+ attemptTransactionHash: optional(TxHashSchema),
20537
+ receipt: optional(InvitationEoaReceiptSchema)
20538
+ }),
20539
+ Struct({
20540
+ status: Literal("verified"),
20541
+ commandId: PaymentCommandIdSchema,
20542
+ receipt: InvitationEoaReceiptSchema,
20543
+ events: ArraySchema(PermissionEventRefSchema),
20544
+ factsHash: Bytes32Schema
20545
+ })
20546
+ ]);
20547
+ /**
20548
+ * One stored `setAllowance` call inside a command's expected authority set.
20549
+ *
20550
+ * The pinned Roles module emits `SetAllowance` as *post-state*, not as the call
20551
+ * arguments: `maxRefill = 0` becomes `type(uint128).max`, and `timestamp = 0`
20552
+ * becomes the receipt block's timestamp. A hash over the call arguments can
20553
+ * therefore never match that receipt. `index` names the entry in
20554
+ * `expectedAuthorityEvents` the call produced, and `data` is the call's own
20555
+ * calldata, so the verifier can rebuild the one hash the module actually emits.
20556
+ * The rule is pinned by `test:invitation-conformance`.
20557
+ */
20558
+ const AllowanceExpectationSchema = Struct({
20559
+ index: nonNegativeInteger("index"),
20560
+ data: String$1.pipe(refine((value) => /^0x[0-9a-fA-F]+$/u.test(value), { message: "data must be 0x-prefixed hex" }))
20561
+ });
20562
+ Struct({
20563
+ commandId: PaymentCommandIdSchema,
20564
+ userOpHash: Bytes32Schema,
20565
+ generationHash: Bytes32Schema,
20566
+ chainId: BaseSepoliaChainIdSchema,
20567
+ organizationSafe: SafeAddressSchema,
20568
+ rolesModule: ModuleAddressSchema,
20569
+ userOpSenderSafe: SafeAddressSchema,
20570
+ expectedAuthorityEvents: ArraySchema(Bytes32Schema),
20571
+ /**
20572
+ * Absent means "no normalization": every expected hash is compared as stored.
20573
+ * A command whose set contains `setAllowance` then refuses (`wrong_fact_tuple`)
20574
+ * rather than passing on a weakened proof, so an incomplete caller fails
20575
+ * closed.
20576
+ */
20577
+ allowanceExpectations: optional(ArraySchema(AllowanceExpectationSchema))
20578
+ });
20372
20579
  const PermissionOperationSchema = Literals([
20373
20580
  "create",
20374
20581
  "change",
@@ -20411,7 +20618,9 @@
20411
20618
  originatingAuthUserId: optional(String$1),
20412
20619
  originatingObservationContext: optional(Unknown)
20413
20620
  }),
20414
- userOpHash: Bytes32Schema
20621
+ userOpHash: Bytes32Schema,
20622
+ /** The stored `setAllowance` calls of this command's own expectation. */
20623
+ allowanceExpectations: optional(ArraySchema(AllowanceExpectationSchema))
20415
20624
  });
20416
20625
  Union([
20417
20626
  Struct({
@@ -21247,6 +21456,27 @@
21247
21456
  digest: Bytes32Schema,
21248
21457
  value: PermissionResourceSchema
21249
21458
  });
21459
+ Struct({
21460
+ commandId: PaymentCommandIdSchema,
21461
+ signerAddress: AddressSchema
21462
+ });
21463
+ Struct({
21464
+ executionId: MoneyExecutionIdSchema,
21465
+ commandId: PaymentCommandIdSchema,
21466
+ orgId: nonEmpty("orgId"),
21467
+ invitationId: nonEmpty("invitationId"),
21468
+ generationHash: Bytes32Schema,
21469
+ chainId: BaseSepoliaChainIdSchema,
21470
+ signerAddress: AddressSchema,
21471
+ userOpSenderSafe: SafeAddressSchema,
21472
+ digest: Bytes32Schema
21473
+ });
21474
+ Struct({
21475
+ status: Literal("submitted"),
21476
+ executionId: MoneyExecutionIdSchema,
21477
+ commandId: PaymentCommandIdSchema,
21478
+ userOpHash: Bytes32Schema
21479
+ });
21250
21480
  Struct({
21251
21481
  status: Literal("submitted"),
21252
21482
  executionId: MoneyExecutionIdSchema,
@@ -21751,6 +21981,158 @@
21751
21981
  actions: NonEmptyArray(Literals(["pay", "commitments"]))
21752
21982
  })
21753
21983
  }), Struct({ type: Literal("managePeople") })]);
21984
+ const BudgetIntentSchema = CurrentPolicySchema.pipe(refine((value) => {
21985
+ if (value.type !== "budget") return false;
21986
+ const { actions, recipients } = value.scope;
21987
+ if (new Set(actions).size !== actions.length) return false;
21988
+ return recipients.type === "anyone" || recipients.accounts.length >= 1 && recipients.accounts.length <= 32 && new Set(recipients.accounts).size === recipients.accounts.length;
21989
+ }));
21990
+ const InvitationIdSchema = NonEmptyString;
21991
+ Struct({
21992
+ ...Struct({ invitationId: InvitationIdSchema }).fields,
21993
+ expectedOfferDigest: Bytes32Schema
21994
+ });
21995
+ /** The requested grantee of one invitation. */
21996
+ const GranteeRefSchema = Union([Struct({
21997
+ type: Literal("email"),
21998
+ email: NonEmptyString
21999
+ }), Struct({
22000
+ type: Literal("account"),
22001
+ accountId: AccountIdSchema
22002
+ })]);
22003
+ Struct({
22004
+ requestKey: String$1.pipe(refine((value) => /^[\x20-\x7e]{1,128}$/.test(value))),
22005
+ to: GranteeRefSchema,
22006
+ grants: ArraySchema(Union([
22007
+ Struct({
22008
+ type: Literal("budget"),
22009
+ budgetId: PermissionIdSchema
22010
+ }),
22011
+ Struct({
22012
+ type: Literal("managePeople"),
22013
+ permissionId: PermissionIdSchema
22014
+ }),
22015
+ Struct({
22016
+ type: Literal("new_budget"),
22017
+ label: String$1.pipe(refine((value) => value.trim().length >= 1 && value.trim().length <= 128)),
22018
+ intent: BudgetIntentSchema
22019
+ })
22020
+ ]))
22021
+ }).pipe(refine((value) => {
22022
+ if (value.grants.length < 1 || value.grants.length > 16) return false;
22023
+ const existing = value.grants.flatMap((grant) => grant.type === "new_budget" ? [] : [grant.type === "budget" ? grant.budgetId : grant.permissionId]);
22024
+ return new Set(existing).size === existing.length && value.grants.filter((grant) => grant.type === "new_budget").length <= 4;
22025
+ }));
22026
+ const InvitationPhaseSchema = Literals([
22027
+ "authorizing",
22028
+ "pending",
22029
+ "pending_grant",
22030
+ "active",
22031
+ "revoking",
22032
+ "declined",
22033
+ "cancelled",
22034
+ "expired",
22035
+ "revoked"
22036
+ ]);
22037
+ const EndingReasonSchema = Literals([
22038
+ "declined",
22039
+ "cancelled",
22040
+ "expired",
22041
+ "revoked"
22042
+ ]);
22043
+ const OfferedAuthoritySchema = Union([Struct({
22044
+ type: Literal("budget"),
22045
+ budgetId: NonEmptyString.pipe(refine((value) => value.length > 0)),
22046
+ label: String$1,
22047
+ policy: BudgetIntentSchema,
22048
+ policyDigest: Bytes32Schema
22049
+ }), Struct({
22050
+ type: Literal("managePeople"),
22051
+ permissionId: PermissionIdSchema,
22052
+ label: String$1
22053
+ })]);
22054
+ const NewBudgetOfferSchema = Struct({
22055
+ type: Literal("new_budget"),
22056
+ label: String$1,
22057
+ policy: BudgetIntentSchema,
22058
+ policyDigest: Bytes32Schema
22059
+ });
22060
+ const PreviewGranteeSchema = Struct({
22061
+ partyId: NullOr(PartyIdSchema),
22062
+ accountId: NullOr(AccountIdSchema),
22063
+ safeAddress: AddressSchema,
22064
+ accountReady: NullOr(Boolean$1)
22065
+ });
22066
+ Struct({
22067
+ orgId: NonEmptyString.pipe(refine((value) => value.length > 0)),
22068
+ grantee: PreviewGranteeSchema,
22069
+ grants: ArraySchema(Union([OfferedAuthoritySchema, NewBudgetOfferSchema])),
22070
+ existingAssignments: ArraySchema(PermissionAssignmentIdSchema),
22071
+ includesManagement: Boolean$1,
22072
+ observedAt: EpochMsSchema
22073
+ });
22074
+ Struct({
22075
+ cursor: optional(NonEmptyString),
22076
+ limit: optional(Number$1.pipe(refine((value) => Number.isSafeInteger(value) && value >= 1 && value <= 100))),
22077
+ phases: optional(ArraySchema(InvitationPhaseSchema).pipe(refine((value) => new Set(value).size === value.length)))
22078
+ });
22079
+ const InvitationRecoverySchema = Struct({
22080
+ actor: Literals([
22081
+ "system",
22082
+ "invitee",
22083
+ "admin"
22084
+ ]),
22085
+ action: Literals([
22086
+ "wait",
22087
+ "retry",
22088
+ "review_offer",
22089
+ "reauthorize"
22090
+ ]),
22091
+ reason: Literals([
22092
+ "configuration_pending",
22093
+ "grant_pending",
22094
+ "provider_unavailable",
22095
+ "policy_changed",
22096
+ "cleanup_pending",
22097
+ "signer_unavailable"
22098
+ ])
22099
+ });
22100
+ Struct({
22101
+ items: ArraySchema(Struct({
22102
+ id: InvitationIdSchema,
22103
+ orgId: NonEmptyString.pipe(refine((value) => value.length > 0)),
22104
+ organizationName: String$1,
22105
+ grantee: Struct({
22106
+ partyId: PartyIdSchema,
22107
+ accountId: NullOr(AccountIdSchema),
22108
+ safeAddress: AddressSchema,
22109
+ accountReady: NullOr(Boolean$1)
22110
+ }),
22111
+ phase: InvitationPhaseSchema,
22112
+ grants: ArraySchema(Union([Struct({
22113
+ type: Literal("budget"),
22114
+ budgetId: NonEmptyString.pipe(refine((value) => value.length > 0))
22115
+ }), Struct({
22116
+ type: Literal("managePeople"),
22117
+ permissionId: PermissionIdSchema
22118
+ })])),
22119
+ offers: ArraySchema(OfferedAuthoritySchema),
22120
+ recovery: NullOr(InvitationRecoverySchema),
22121
+ offerDigest: Bytes32Schema,
22122
+ authorizedAt: NullOr(EpochMsSchema),
22123
+ acceptedAt: NullOr(EpochMsSchema),
22124
+ expiresAt: NullOr(EpochMsSchema),
22125
+ commandId: NullOr(PaymentCommandIdSchema),
22126
+ endingReason: NullOr(EndingReasonSchema),
22127
+ delivery: Literals([
22128
+ "not_confirmed",
22129
+ "sent",
22130
+ "failed"
22131
+ ])
22132
+ })),
22133
+ nextCursor: NullOr(NonEmptyString),
22134
+ observedAt: EpochMsSchema
22135
+ });
21754
22136
  const ActiveBudgetSchema = Struct({
21755
22137
  id: PermissionIdSchema,
21756
22138
  label: String$1,
@@ -22048,7 +22430,7 @@
22048
22430
  createApi();
22049
22431
  CAPXUL_FUNCTIONS["financialOps/addressBook"].list, CAPXUL_FUNCTIONS["financialOps/addressBook"].get, CAPXUL_FUNCTIONS["financialOps/addressBook"].add, CAPXUL_FUNCTIONS["financialOps/addressBook"].hide, CAPXUL_FUNCTIONS["financialOps/addressBook"].unhide, CAPXUL_FUNCTIONS["financialOps/addressBook"].label, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].issue, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].list, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].get, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].cancel, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].inboxList, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].approve, CAPXUL_FUNCTIONS["financialOps/requestsInbox"].decline;
22050
22432
  CAPXUL_FUNCTIONS["financialOps/queries"].me, CAPXUL_FUNCTIONS["financialOps/queries"].depositInstructions, CAPXUL_FUNCTIONS["financialOps/queries"].resolveRecipient, CAPXUL_FUNCTIONS["financialOps/destinations"].add, CAPXUL_FUNCTIONS["financialOps/destinations"].list, CAPXUL_FUNCTIONS["financialOps/destinations"].remove, CAPXUL_FUNCTIONS["financialOps/queries"].listPayments, CAPXUL_FUNCTIONS["financialOps/queries"].getPayment, CAPXUL_FUNCTIONS["movement/activity"].list, CAPXUL_FUNCTIONS["movement/activity"].summary, CAPXUL_FUNCTIONS["movement/activity"].get, CAPXUL_FUNCTIONS["movement/activity"].annotate, CAPXUL_FUNCTIONS["movement/annotations"].overlay, CAPXUL_FUNCTIONS["financialOps/queries"].getPaymentDocument, CAPXUL_FUNCTIONS["financialOps/queries"].verifyPaymentDocument, CAPXUL_FUNCTIONS["financialOps/queries"].renderStoredDocument;
22051
- CAPXUL_FUNCTIONS["moneyExecution/actions"].abandonPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePermissionExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].prepareOrganizationPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].preparePaymentLifecycleExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPermissionExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].submitPaymentCommandExecution;
22433
+ CAPXUL_FUNCTIONS["moneyExecution/actions"].abandonPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].prepareInvitationConfiguration, CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePermissionExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].preparePaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].prepareOrganizationPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].preparePaymentLifecycleExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPaymentExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].submitInvitationConfigurationExecution, CAPXUL_FUNCTIONS["moneyExecution/actions"].submitPermissionExecution, CAPXUL_FUNCTIONS["moneyExecution/paymentCommandActions"].submitPaymentCommandExecution;
22052
22434
  TaggedError("IndexerReadError");
22053
22435
  Service()("@capxul/sdk/ports/IndexerReadPort");
22054
22436
  //#endregion
@@ -74028,7 +74410,7 @@ ${SUCCESS}
74028
74410
  CAPXUL_FUNCTIONS["smartAccount/queries"].loadByAuthUserId, CAPXUL_FUNCTIONS["smartAccount/queries"].loadBySmartAccountAddress, CAPXUL_FUNCTIONS["smartAccount/mutations"].provision, CAPXUL_FUNCTIONS["smartAccount/actions"].confirmDeployment, CAPXUL_FUNCTIONS["smartAccount/actions"].claim;
74029
74411
  TaggedError("OrgError");
74030
74412
  Service()("@capxul/sdk/ports/OrgPort");
74031
- CAPXUL_FUNCTIONS["org/queries"].listAll, CAPXUL_FUNCTIONS["org/queries"].listRolesByOrgId, CAPXUL_FUNCTIONS["org/queries"].listMembersByOrgId, CAPXUL_FUNCTIONS["org/actions"].readTreasury, CAPXUL_FUNCTIONS["org/actions"].inviteMember, CAPXUL_FUNCTIONS["org/mutations"].resendInviteToken, CAPXUL_FUNCTIONS["org/actions"].detectAndAcceptPendingInvitations;
74413
+ CAPXUL_FUNCTIONS["org/queries"].listAll, CAPXUL_FUNCTIONS["org/queries"].listRolesByOrgId, CAPXUL_FUNCTIONS["org/queries"].listMembersByOrgId, CAPXUL_FUNCTIONS["org/actions"].readTreasury;
74032
74414
  CAPXUL_FUNCTIONS["org/lifecycle"].startOrResume, CAPXUL_FUNCTIONS["org/actions"].prepareFounderAccount, CAPXUL_FUNCTIONS["org/actions"].prepareBootstrap, CAPXUL_FUNCTIONS["org/actions"].submitBootstrap, CAPXUL_FUNCTIONS["org/actions"].resumeBootstrapSubmission, CAPXUL_FUNCTIONS["org/actions"].confirmBootstrap, CAPXUL_FUNCTIONS["org/lifecycle"].recordFailure, CAPXUL_FUNCTIONS["org/lifecycle"].load, CAPXUL_FUNCTIONS["org/lifecycle"].retry;
74033
74415
  //#endregion
74034
74416
  //#region ../../packages/sdk/src/flows/identity.ts
@@ -74181,6 +74563,8 @@ ${SUCCESS}
74181
74563
  CAPXUL_FUNCTIONS.media.generateUploadUrl, CAPXUL_FUNCTIONS.media.setProfileImage, CAPXUL_FUNCTIONS.media.setOrgLogo;
74182
74564
  CAPXUL_FUNCTIONS.system.healthObserved;
74183
74565
  CAPXUL_FUNCTIONS["org/queries"].me;
74566
+ CAPXUL_FUNCTIONS["org/queries"].previewInvite, CAPXUL_FUNCTIONS["org/queries"].listMyInvitations, CAPXUL_FUNCTIONS["org/queries"].listInvitations, CAPXUL_FUNCTIONS["org/queries"].getInvitation, CAPXUL_FUNCTIONS["org/mutations"].invite, CAPXUL_FUNCTIONS["org/mutations"].accept, CAPXUL_FUNCTIONS["org/mutations"].decline, CAPXUL_FUNCTIONS["org/mutations"].cancel, CAPXUL_FUNCTIONS["org/mutations"].resend, CAPXUL_FUNCTIONS["org/mutations"].retry;
74567
+ CAPXUL_OPERATIONS.org.invitations;
74184
74568
  CAPXUL_FUNCTIONS["permission/queries"].read;
74185
74569
  CAPXUL_FUNCTIONS["payroll/actions"].authorizeRun, CAPXUL_FUNCTIONS["payroll/queries"].runs, CAPXUL_FUNCTIONS["payroll/queries"].groups, CAPXUL_FUNCTIONS["payroll/queries"].terms, CAPXUL_FUNCTIONS["payroll/mutations"].saveGroup, CAPXUL_FUNCTIONS["payroll/mutations"].removeGroup;
74186
74570
  CAPXUL_OPERATIONS.payroll.authorizeRun;
@@ -74241,16 +74625,28 @@ ${SUCCESS}
74241
74625
  //#region browser/main.ts
74242
74626
  const main = document.querySelector("main");
74243
74627
  const title = document.querySelector("#title");
74244
- const lead = document.querySelector("#lead");
74245
74628
  const account = document.querySelector("#account");
74246
74629
  const environment = document.querySelector("#environment");
74247
74630
  const status = document.querySelector("#status");
74248
- const show = (state, heading, message) => {
74631
+ const dismiss = document.querySelector("#dismiss");
74632
+ let shownMessage = "";
74633
+ let failedStepShown = false;
74634
+ const show = (state, heading, message = "", options) => {
74249
74635
  main.setAttribute("data-state", state);
74250
74636
  main.setAttribute("aria-busy", String(state === "working"));
74251
74637
  title.textContent = heading;
74252
74638
  status.textContent = message;
74639
+ shownMessage = message;
74640
+ dismiss.hidden = options?.dismiss !== true;
74641
+ dismiss.textContent = "Close this page";
74253
74642
  };
74643
+ dismiss.addEventListener("click", () => {
74644
+ window.close();
74645
+ setTimeout(() => {
74646
+ dismiss.textContent = "Close this tab manually";
74647
+ status.textContent = `${shownMessage} This browser blocks scripted closing, so close the tab yourself.`;
74648
+ }, 400);
74649
+ });
74254
74650
  const post = async (path, body, token) => {
74255
74651
  const response = await fetch(path, {
74256
74652
  method: "POST",
@@ -74279,6 +74675,7 @@ ${SUCCESS}
74279
74675
  };
74280
74676
  };
74281
74677
  (async () => {
74678
+ show("working", "Connecting to Capxul CLI");
74282
74679
  const capability = new URLSearchParams(location.hash.slice(1)).get("cap");
74283
74680
  history.replaceState(null, "", location.pathname);
74284
74681
  if (capability === null) throw new Error("missing capability");
@@ -74324,33 +74721,47 @@ ${SUCCESS}
74324
74721
  } }
74325
74722
  });
74326
74723
  try {
74724
+ let idling = false;
74725
+ let failed = false;
74726
+ let produced = "none";
74727
+ let terminalDelivered = false;
74327
74728
  for (;;) {
74328
74729
  const next = await message({ kind: "poll" });
74329
74730
  if (next.action === "idle") {
74731
+ if (!idling && !failed && !terminalDelivered) {
74732
+ idling = true;
74733
+ show("working", "Waiting for your terminal");
74734
+ }
74330
74735
  await wait(250);
74331
74736
  continue;
74332
74737
  }
74738
+ idling = false;
74333
74739
  if (next.action === "finish") {
74334
- show("ready", "Wallet session finished", "You can close this tab");
74335
- lead.textContent = "Your terminal has the result. This page is now inactive.";
74336
74740
  await message({ kind: "finished" }).catch(() => void 0);
74337
74741
  clearInterval(heartbeat);
74338
74742
  removeEventListener("pagehide", disconnect);
74743
+ if (failedStepShown) return;
74744
+ show("ready", "Wallet session finished", "", { dismiss: true });
74339
74745
  window.close();
74340
74746
  return;
74341
74747
  }
74342
74748
  const requestId = next.requestId;
74343
74749
  const requestEpoch = next.epoch;
74344
74750
  if (typeof requestId !== "string" || typeof requestEpoch !== "string") throw new Error("invalid wallet request");
74751
+ failed = false;
74752
+ failedStepShown = false;
74753
+ produced = "none";
74754
+ terminalDelivered = false;
74345
74755
  try {
74346
74756
  if (next.action === "address") {
74347
- show("working", "Preparing your wallet", "Recovering the same Openfort signer");
74757
+ show("working", "Preparing your wallet");
74348
74758
  await message({
74349
74759
  kind: "status",
74350
74760
  stage: "recovering"
74351
74761
  });
74352
74762
  await signer.ensureWalletReady();
74353
74763
  const address = await signer.getAddress();
74764
+ produced = "address";
74354
74765
  await settleDiagnostics(diagnosticWork);
74355
74766
  await message({
74356
74767
  kind: "address",
@@ -74358,7 +74769,8 @@ ${SUCCESS}
74358
74769
  epoch: requestEpoch,
74359
74770
  address
74360
74771
  });
74361
- show("ready", "Wallet connected", "Continue in your terminal");
74772
+ terminalDelivered = true;
74773
+ show("ready", "Wallet connected");
74362
74774
  await message({
74363
74775
  kind: "status",
74364
74776
  stage: "ready"
@@ -74366,12 +74778,13 @@ ${SUCCESS}
74366
74778
  continue;
74367
74779
  }
74368
74780
  if (next.action === "sign" && typeof next.hash === "string") {
74369
- show("working", "Signing with your wallet", "Signing the validated Capxul operation");
74781
+ show("working", "Signing with your wallet");
74370
74782
  await message({
74371
74783
  kind: "status",
74372
74784
  stage: "signing"
74373
74785
  });
74374
74786
  const signature = await signer.signUserOpHash(next.hash);
74787
+ produced = "signature";
74375
74788
  await settleDiagnostics(diagnosticWork);
74376
74789
  await message({
74377
74790
  kind: "signature",
@@ -74379,7 +74792,8 @@ ${SUCCESS}
74379
74792
  epoch: requestEpoch,
74380
74793
  signature
74381
74794
  });
74382
- show("ready", "Signature returned", "Continue in your terminal");
74795
+ terminalDelivered = true;
74796
+ show("ready", "Signature returned");
74383
74797
  await message({
74384
74798
  kind: "status",
74385
74799
  stage: "returned"
@@ -74389,20 +74803,26 @@ ${SUCCESS}
74389
74803
  throw new Error("unknown wallet action");
74390
74804
  } catch {
74391
74805
  await settleDiagnostics(diagnosticWork);
74806
+ if (terminalDelivered) continue;
74392
74807
  await message({
74393
74808
  kind: "failure",
74394
74809
  requestId,
74395
74810
  epoch: requestEpoch
74396
74811
  }).catch(() => void 0);
74397
- throw new Error("wallet operation failed");
74812
+ failed = true;
74813
+ failedStepShown = true;
74814
+ if (produced === "signature") show("failed", "The signature did not reach the terminal", "Retry from your terminal.", { dismiss: true });
74815
+ else if (produced === "address") show("failed", "The wallet step stopped before signing", "No signature was created. Retry from your terminal.", { dismiss: true });
74816
+ else show("failed", "That wallet step did not finish", "Nothing was signed. Retry from your terminal.", { dismiss: true });
74817
+ continue;
74398
74818
  }
74399
74819
  }
74400
74820
  } finally {
74401
74821
  clearInterval(heartbeat);
74402
74822
  }
74403
74823
  })().catch(() => {
74404
- show("failed", "Wallet connection ended", "Return to your terminal");
74405
- lead.textContent = "The terminal can retry this wallet step safely.";
74824
+ if (failedStepShown) return;
74825
+ show("failed", "Wallet connection ended", "Return to your terminal.", { dismiss: true });
74406
74826
  });
74407
74827
  //#endregion
74408
74828
  })();