@gravity-rail/cli 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import {
2
2
  AGUIClient,
3
3
  CredentialsManager,
4
+ __export,
5
+ __reExport,
4
6
  clearScreen,
5
7
  formatTimestamp,
6
8
  getEnvironmentConfig,
@@ -11,7 +13,7 @@ import {
11
13
  printTable,
12
14
  refreshAccessToken,
13
15
  selectFromList
14
- } from "./chunk-OIFV7TAT.js";
16
+ } from "./chunk-C6D4FO6A.js";
15
17
 
16
18
  // src/lib/errors.ts
17
19
  var CLIError = class extends Error {
@@ -43,9 +45,11 @@ function handleError(err) {
43
45
  }
44
46
  }
45
47
  if ("statusCode" in err && err.statusCode === 401) {
46
- process.stderr.write(`
47
- Hint: Run "yarn gr login" or use "--realm <name>" (dev only)
48
- `);
48
+ process.stderr.write(
49
+ `
50
+ Hint: Run "gr login" to authenticate, or set GRAVITY_RAIL_API_KEY for non-interactive use.
51
+ `
52
+ );
49
53
  }
50
54
  process.exit(1);
51
55
  }
@@ -264,8 +268,1583 @@ function findDef(defs, arg) {
264
268
  return void 0;
265
269
  }
266
270
 
267
- // src/lib/context.ts
271
+ // ../client/dist/index.mjs
272
+ var dist_exports = {};
273
+ __export(dist_exports, {
274
+ AdminApi: () => AdminApi,
275
+ ApiClient: () => ApiClient,
276
+ bindAdminMethods: () => bindAdminMethods
277
+ });
278
+ __reExport(dist_exports, internal_star);
279
+ import * as internal_star from "@gravity-rail/sdk/internal";
280
+ import { BaseApiClient } from "@gravity-rail/sdk/internal";
268
281
  import { GravityRailClient } from "@gravity-rail/sdk";
282
+ function supportRequestParams(params) {
283
+ const searchParams = new URLSearchParams();
284
+ if (params?.page) searchParams.append("page", params.page.toString());
285
+ if (params?.pageSize) searchParams.append("pageSize", params.pageSize.toString());
286
+ if (params?.status) searchParams.append("status", params.status);
287
+ if (params?.supportRequestType) {
288
+ searchParams.append("supportRequestType", params.supportRequestType);
289
+ }
290
+ if (params?.severity) searchParams.append("severity", params.severity);
291
+ if (params?.source) searchParams.append("source", params.source);
292
+ if (params?.organizationId !== void 0) {
293
+ searchParams.append("organizationId", params.organizationId.toString());
294
+ }
295
+ if (params?.workspaceId !== void 0) {
296
+ searchParams.append("workspaceId", params.workspaceId.toString());
297
+ }
298
+ if (params?.linearLinked !== void 0) {
299
+ searchParams.append("linearLinked", params.linearLinked.toString());
300
+ }
301
+ const query = searchParams.toString();
302
+ return query ? `?${query}` : "";
303
+ }
304
+ var AdminApi = class extends BaseApiClient {
305
+ // Support Requests API
306
+ async listSupportRequestsAsAdmin(params) {
307
+ return this.fetch(
308
+ `admin/support-requests${supportRequestParams(params)}`
309
+ );
310
+ }
311
+ async getSupportRequestAsAdmin(uuid) {
312
+ return this.fetch(`admin/support-requests/${uuid}`);
313
+ }
314
+ async commentOnSupportRequestAsAdmin(uuid, data) {
315
+ return this.fetch(`admin/support-requests/${uuid}/comments`, {
316
+ method: "POST",
317
+ body: JSON.stringify(data)
318
+ });
319
+ }
320
+ async noteOnSupportRequestAsAdmin(uuid, data) {
321
+ return this.fetch(`admin/support-requests/${uuid}/notes`, {
322
+ method: "POST",
323
+ body: JSON.stringify(data)
324
+ });
325
+ }
326
+ async updateSupportRequestStatusAsAdmin(uuid, data) {
327
+ return this.fetch(`admin/support-requests/${uuid}/status`, {
328
+ method: "POST",
329
+ body: JSON.stringify(data)
330
+ });
331
+ }
332
+ async updateSupportRequestAttributesAsAdmin(uuid, data) {
333
+ return this.fetch(`admin/support-requests/${uuid}/attributes`, {
334
+ method: "POST",
335
+ body: JSON.stringify(data)
336
+ });
337
+ }
338
+ async createSupportRequestLinearIssueAsAdmin(uuid) {
339
+ return this.fetch(`admin/support-requests/${uuid}/linear-issue`, {
340
+ method: "POST"
341
+ });
342
+ }
343
+ // Admin Accounts API
344
+ async getAccounts(options) {
345
+ const params = new URLSearchParams();
346
+ if (options.search) params.append("search", options.search);
347
+ if (options.createdAfter) params.append("created_after", options.createdAfter);
348
+ if (options.createdBefore) params.append("created_before", options.createdBefore);
349
+ if (options.sortBy) params.append("sortBy", options.sortBy);
350
+ if (options.sortOrder) params.append("sortOrder", options.sortOrder);
351
+ if (options.page) params.append("page", options.page.toString());
352
+ if (options.pageSize) params.append("pageSize", options.pageSize.toString());
353
+ if (options.isActive !== void 0) params.append("isActive", options.isActive.toString());
354
+ if (options.organizationId !== void 0)
355
+ params.append("organizationId", options.organizationId.toString());
356
+ if (options.pendingDeletion !== void 0)
357
+ params.append("pendingDeletion", options.pendingDeletion.toString());
358
+ return this.fetch(`admin/accounts?${params.toString()}`);
359
+ }
360
+ async getAccountDetails(id) {
361
+ return this.fetch(`admin/accounts/${id}`);
362
+ }
363
+ async getAccountByUuid(uuid) {
364
+ return this.fetch(`admin/accounts/${uuid}`);
365
+ }
366
+ async getAccountMemberships(accountId) {
367
+ return this.fetch(`admin/accounts/${accountId}/memberships`);
368
+ }
369
+ async getAccountOrgMemberships(accountId) {
370
+ return this.fetch(`admin/accounts/${accountId}/org-memberships`);
371
+ }
372
+ async createAccountOrgMembership(accountId, organizationId, role = "member") {
373
+ return this.fetch(`admin/accounts/${accountId}/org-memberships`, {
374
+ method: "POST",
375
+ body: JSON.stringify({ organizationId, role })
376
+ });
377
+ }
378
+ async deleteAccountOrgMembership(accountId, organizationId) {
379
+ return this.fetch(`admin/accounts/${accountId}/org-memberships/${organizationId}`, {
380
+ method: "DELETE"
381
+ });
382
+ }
383
+ async getAccountMembership(accountId, workspaceId) {
384
+ return this.fetch(
385
+ `admin/accounts/${accountId}/memberships/${workspaceId}`
386
+ );
387
+ }
388
+ async updateAccountMembership(accountId, workspaceId, updates) {
389
+ return this.fetch(
390
+ `admin/accounts/${accountId}/memberships/${workspaceId}`,
391
+ {
392
+ method: "PUT",
393
+ body: JSON.stringify(updates)
394
+ }
395
+ );
396
+ }
397
+ async createAccountMembership(accountId, workspaceId, data) {
398
+ return this.fetch(
399
+ `admin/accounts/${accountId}/memberships/${workspaceId}`,
400
+ {
401
+ method: "POST",
402
+ body: JSON.stringify(data)
403
+ }
404
+ );
405
+ }
406
+ async deleteAccountMembership(accountId, workspaceId) {
407
+ return this.fetch(`admin/accounts/${accountId}/memberships/${workspaceId}`, {
408
+ method: "DELETE"
409
+ });
410
+ }
411
+ async updateAccountAsAdmin(id, updates) {
412
+ return this.fetch(`admin/accounts/${id}`, {
413
+ method: "PUT",
414
+ body: JSON.stringify(updates)
415
+ });
416
+ }
417
+ async createAccountAsAdmin(data) {
418
+ return this.fetch("admin/accounts", {
419
+ method: "POST",
420
+ body: JSON.stringify(data)
421
+ });
422
+ }
423
+ async deleteAccountAsAdmin(id) {
424
+ return this.fetch(`admin/accounts/${id}`, {
425
+ method: "DELETE"
426
+ });
427
+ }
428
+ // GDPR Data Subject Rights (superuser only)
429
+ async exportAccountData(accountId) {
430
+ return this.fetch(`admin/data-rights/${accountId}/export`, {
431
+ method: "POST"
432
+ });
433
+ }
434
+ async requestAccountDeletion(accountId) {
435
+ return this.fetch(`admin/data-rights/${accountId}/delete`, {
436
+ method: "POST"
437
+ });
438
+ }
439
+ async cancelAccountDeletion(accountId) {
440
+ return this.fetch(`admin/data-rights/${accountId}/cancel-delete`, {
441
+ method: "POST"
442
+ });
443
+ }
444
+ /**
445
+ * Look up an account by email or phone. Returns verification status.
446
+ * Used to check if a verified account exists before creating a new one.
447
+ */
448
+ async lookupAccount(options) {
449
+ const params = new URLSearchParams();
450
+ if (options.email) params.append("email", options.email);
451
+ if (options.phone) params.append("phone", options.phone);
452
+ return this.fetch(`admin/accounts/lookup?${params.toString()}`);
453
+ }
454
+ // Admin Organizations API
455
+ async getOrganizations(options) {
456
+ const params = new URLSearchParams();
457
+ if (options?.search) params.append("search", options.search);
458
+ if (options?.page) params.append("page", options.page.toString());
459
+ if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
460
+ if (options?.noSubscription) params.append("no_subscription", "true");
461
+ if (options?.sortBy) params.append("sortBy", options.sortBy);
462
+ if (options?.sortOrder) params.append("sortOrder", options.sortOrder);
463
+ return this.fetch(
464
+ `admin/organizations?${params.toString()}`
465
+ );
466
+ }
467
+ /**
468
+ * Get organization by ID or UUID.
469
+ * Returns different response based on user's role:
470
+ * - Admins/Owners: AdminOrganization with full details
471
+ * - Members: MemberOrgView with basic info and workspace list
472
+ *
473
+ * Use `viewType` field to determine the response type:
474
+ * - 'admin': AdminOrganization
475
+ * - 'member': MemberOrgView
476
+ */
477
+ async getOrganization(idOrUuid) {
478
+ return this.fetch(`o/${idOrUuid}`);
479
+ }
480
+ /**
481
+ * Get organization by numeric ID or UUID via admin endpoint.
482
+ * Does NOT require organization membership — superuser-only.
483
+ */
484
+ async getOrganizationAsAdmin(idOrUuid) {
485
+ return this.fetch(`admin/organizations/${idOrUuid}`);
486
+ }
487
+ async getOrganizationMembersAsAdmin(organizationId, options) {
488
+ const params = new URLSearchParams();
489
+ if (options?.search) params.append("search", options.search);
490
+ if (options?.role) params.append("role", options.role);
491
+ if (options?.page) params.append("page", options.page.toString());
492
+ if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
493
+ const qs = params.toString();
494
+ return this.fetch(
495
+ `admin/organizations/${organizationId}/members${qs ? `?${qs}` : ""}`
496
+ );
497
+ }
498
+ async createOrganization(data) {
499
+ return this.fetch("admin/organizations", {
500
+ method: "POST",
501
+ body: JSON.stringify(data)
502
+ });
503
+ }
504
+ async updateOrganization(id, data) {
505
+ return this.fetch(`admin/organizations/${id}`, {
506
+ method: "PUT",
507
+ body: JSON.stringify(data)
508
+ });
509
+ }
510
+ async deleteOrganization(id) {
511
+ return this.fetch(`admin/organizations/${id}`, {
512
+ method: "DELETE"
513
+ });
514
+ }
515
+ /**
516
+ * Join an organization with a specified role (superuser only).
517
+ * Creates or updates membership in the target org.
518
+ * @param orgUuid - Organization UUID or numeric ID as string
519
+ */
520
+ async joinOrganization(orgUuid, role = "owner") {
521
+ return this.fetch(`admin/organizations/${orgUuid}/join`, {
522
+ method: "POST",
523
+ body: JSON.stringify({ role })
524
+ });
525
+ }
526
+ /**
527
+ * Leave an organization (superuser only).
528
+ * @param orgUuid - Organization UUID or numeric ID as string
529
+ */
530
+ async leaveOrganization(orgUuid) {
531
+ return this.fetch(`admin/organizations/${orgUuid}/join`, {
532
+ method: "DELETE"
533
+ });
534
+ }
535
+ async generateLogoUploadUrl(organizationUuid, data) {
536
+ return this.fetch(`o/${organizationUuid}/logo-upload-url`, {
537
+ method: "POST",
538
+ body: JSON.stringify(data)
539
+ });
540
+ }
541
+ // Organization Members API - moved to OrgApi at /api/v2/o/{org_uuid}/members
542
+ // See packages/client/src/api/org.ts
543
+ // Organization Invitations API - moved to OrgApi at /api/v2/o/{org_uuid}/invitations
544
+ // See packages/client/src/api/org.ts
545
+ // Admin Products API
546
+ async importProducts(workspaceId) {
547
+ return this.fetch("admin/import-products", {
548
+ method: "POST",
549
+ body: JSON.stringify({ workspaceId })
550
+ });
551
+ }
552
+ // ===== Product CRUD =====
553
+ async createProductAsAdmin(product) {
554
+ return this.fetch("admin/products", {
555
+ method: "POST",
556
+ body: JSON.stringify(product)
557
+ });
558
+ }
559
+ async getProductsAsAdmin(workspaceUuid, productTypes) {
560
+ const params = new URLSearchParams();
561
+ if (workspaceUuid) {
562
+ params.append("workspace_uuid", workspaceUuid);
563
+ }
564
+ if (productTypes && productTypes.length > 0) {
565
+ productTypes.forEach((type) => params.append("product_types", type));
566
+ }
567
+ const queryString = params.toString();
568
+ return this.fetch(`admin/products${queryString ? `?${queryString}` : ""}`);
569
+ }
570
+ async getProductAsAdmin(productId) {
571
+ return this.fetch(`admin/products/${productId}`);
572
+ }
573
+ async updateProductAsAdmin(product_id, product) {
574
+ return this.fetch(`admin/products/${product_id}`, {
575
+ method: "PUT",
576
+ body: JSON.stringify(product)
577
+ });
578
+ }
579
+ async deleteProductAsAdmin(productId) {
580
+ return this.fetch(`admin/products/${productId}`, {
581
+ method: "DELETE"
582
+ });
583
+ }
584
+ // Admin Workspace API
585
+ async getWorkspacesAsAdmin(options = {}) {
586
+ const params = new URLSearchParams();
587
+ if (options.page !== void 0) params.append("page", options.page.toString());
588
+ if (options.pageSize !== void 0) params.append("pageSize", options.pageSize.toString());
589
+ if (options.sortBy) params.append("sortBy", options.sortBy);
590
+ if (options.sortOrder) params.append("sortOrder", options.sortOrder);
591
+ if (options.search) params.append("search", options.search);
592
+ if (options.isReseller !== void 0)
593
+ params.append("isReseller", options.isReseller.toString());
594
+ if (options.organizationId !== void 0)
595
+ params.append("organizationId", options.organizationId.toString());
596
+ if (options.noActiveSubscription) params.append("noActiveSubscription", "true");
597
+ return this.fetch(`admin/workspaces?${params.toString()}`);
598
+ }
599
+ async getWorkspaceAsAdmin(wid) {
600
+ return this.fetch(`admin/workspaces/${wid}`);
601
+ }
602
+ async getWorkspaceByNumericIdAsAdmin(workspace_id) {
603
+ return this.fetch(`admin/workspaces/id/${workspace_id}`);
604
+ }
605
+ async createWorkspaceAsAdmin(ws) {
606
+ return this.fetch("admin/workspaces", {
607
+ method: "POST",
608
+ body: JSON.stringify(ws)
609
+ });
610
+ }
611
+ async updateWorkspaceAsAdmin(wid, ws) {
612
+ return this.fetch(`admin/workspaces/${wid}`, {
613
+ method: "PUT",
614
+ body: JSON.stringify(ws)
615
+ });
616
+ }
617
+ async deleteWorkspaceAsAdmin(wid) {
618
+ return this.fetch(`admin/workspaces/${wid}`, {
619
+ method: "DELETE"
620
+ });
621
+ }
622
+ async createSchemaAsAdmin(wid) {
623
+ return this.fetch(`admin/workspaces/${wid}/provision/create`, {
624
+ method: "POST"
625
+ });
626
+ }
627
+ async migrateSchemaAsAdmin(wid) {
628
+ return this.fetch(`admin/workspaces/${wid}/provision/migrate`, {
629
+ method: "POST"
630
+ });
631
+ }
632
+ async provisionWorkspaceAsAdmin(wid) {
633
+ return this.fetch(`admin/workspaces/${wid}/provision`, {
634
+ method: "POST"
635
+ });
636
+ }
637
+ async refreshProvisionStatusAsAdmin(wid) {
638
+ return this.fetch(`admin/workspaces/${wid}/provision/refresh`, {
639
+ method: "POST"
640
+ });
641
+ }
642
+ async enableMaintenanceMode(wid) {
643
+ return this.fetch(`admin/workspaces/${wid}/maintenance`, {
644
+ method: "PUT"
645
+ });
646
+ }
647
+ async disableMaintenanceMode(wid) {
648
+ return this.fetch(`admin/workspaces/${wid}/maintenance`, {
649
+ method: "DELETE"
650
+ });
651
+ }
652
+ // ===== Workspace Health Check =====
653
+ async getWorkspaceHealth(workspaceUuid) {
654
+ return this.fetch(`admin/workspaces/${workspaceUuid}/health`);
655
+ }
656
+ async provisionPlanFeatures(workspaceUuid, request) {
657
+ return this.fetch(`admin/workspaces/${workspaceUuid}/provision-plan`, {
658
+ method: "POST",
659
+ body: JSON.stringify(request || {})
660
+ });
661
+ }
662
+ /**
663
+ * Switch a workspace's plan product on its active SubscriptionItem.
664
+ *
665
+ * Superuser only. Re-syncs ``workspace.features`` from the new product
666
+ * and emits a ``WORKSPACE_PRODUCT_CHANGED`` audit event identifying the
667
+ * actor, target workspace, prior and new product, and feature diff.
668
+ *
669
+ * Stripe is not touched here; price-id changes belong to the dedicated
670
+ * Stripe sync surface (``syncProductToStripe``).
671
+ */
672
+ async changeWorkspaceProduct(workspaceUuid, productId) {
673
+ const body = { productId };
674
+ return this.fetch(
675
+ `admin/workspaces/${workspaceUuid}/product`,
676
+ {
677
+ method: "POST",
678
+ body: JSON.stringify(body)
679
+ }
680
+ );
681
+ }
682
+ // ===== Workflow Access Validation =====
683
+ async validateWorkflowAccessAsAdmin(workspaceUuid) {
684
+ const params = new URLSearchParams();
685
+ if (workspaceUuid) params.append("workspace_uuid", workspaceUuid);
686
+ const qs = params.toString();
687
+ return this.fetch(
688
+ `admin/workspaces/validate-workflow-access${qs ? `?${qs}` : ""}`
689
+ );
690
+ }
691
+ async mergeMembers(wid, request) {
692
+ return this.fetch(`admin/workspaces/${wid}/merge-members`, {
693
+ method: "POST",
694
+ body: JSON.stringify(request)
695
+ });
696
+ }
697
+ async getAdminWorkspaceMember(wid) {
698
+ return this.fetch(`admin/workspaces/${wid}/me`, {
699
+ method: "GET"
700
+ });
701
+ }
702
+ async createAdminWorkspaceMember(wid, data) {
703
+ return this.fetch(`admin/workspaces/${wid}/me`, {
704
+ method: "POST",
705
+ body: JSON.stringify(data)
706
+ });
707
+ }
708
+ async updateAdminWorkspaceMember(wid, data) {
709
+ return this.fetch(`admin/workspaces/${wid}/me`, {
710
+ method: "PUT",
711
+ body: JSON.stringify(data)
712
+ });
713
+ }
714
+ async unarchiveAdminWorkspaceMember(wid) {
715
+ return this.fetch(`admin/workspaces/${wid}/me/unarchive`, {
716
+ method: "POST"
717
+ });
718
+ }
719
+ async getAdminWorkspaceMemberRoles(wid) {
720
+ return this.fetch(`admin/workspaces/${wid}/member-roles`);
721
+ }
722
+ async getUnmappedPhoneNumbers() {
723
+ return this.fetch(`admin/phone-numbers/unmapped`);
724
+ }
725
+ async getWorkspaceUnmappedPhoneNumbers(workspaceId) {
726
+ return this.fetch(
727
+ `admin/phone-numbers/workspace/${workspaceId}/unmapped`
728
+ );
729
+ }
730
+ async getWorkspacePhoneNumbersAsAdmin(workspaceRef) {
731
+ return this.fetch(`admin/workspaces/${workspaceRef}/phone-numbers`);
732
+ }
733
+ // Phone Numbers API (Provider phone numbers from Twilio, AWS, etc.)
734
+ async getProviderPhoneNumbers(options = {}) {
735
+ const params = new URLSearchParams();
736
+ if (options.page) params.append("page", options.page.toString());
737
+ if (options.pageSize) params.append("pageSize", options.pageSize.toString());
738
+ if (options.search) params.append("search", options.search);
739
+ if (options.isAssigned !== void 0)
740
+ params.append("is_assigned", String(options.isAssigned));
741
+ if (options.provider) params.append("provider", options.provider);
742
+ if (options.organizationId !== void 0)
743
+ params.append("organizationId", options.organizationId.toString());
744
+ if (options.sortBy) params.append("sortBy", options.sortBy);
745
+ if (options.sortOrder) params.append("sortOrder", options.sortOrder);
746
+ return this.fetch(
747
+ `admin/phone-numbers${params.toString() ? `?${params.toString()}` : ""}`
748
+ );
749
+ }
750
+ async getProviderPhoneNumber(id) {
751
+ return this.fetch(`admin/phone-numbers/${id}`);
752
+ }
753
+ async updateProviderPhoneNumber(id, data) {
754
+ return this.fetch(`admin/phone-numbers/${id}`, {
755
+ method: "PATCH",
756
+ body: JSON.stringify(data)
757
+ });
758
+ }
759
+ async mapMainAccountPhone(data) {
760
+ return this.fetch(`admin/phone-numbers/map-from-main-account`, {
761
+ method: "POST",
762
+ body: JSON.stringify(data)
763
+ });
764
+ }
765
+ async unmapPhoneNumber(data) {
766
+ return this.fetch(`admin/phone-numbers/unmap`, {
767
+ method: "POST",
768
+ body: JSON.stringify(data)
769
+ });
770
+ }
771
+ async searchAvailablePhoneNumbersAsAdmin(data) {
772
+ return this.fetch(`admin/phone-numbers/search`, {
773
+ method: "POST",
774
+ body: JSON.stringify(data)
775
+ });
776
+ }
777
+ async purchasePhoneNumberAsAdmin(data) {
778
+ return this.fetch(`admin/phone-numbers/purchase`, {
779
+ method: "POST",
780
+ body: JSON.stringify(data)
781
+ });
782
+ }
783
+ async getOrgA2PStatusAsAdmin(organizationId) {
784
+ return this.fetch(`admin/organizations/${organizationId}/a2p-status`);
785
+ }
786
+ async resetOrgA2PStatusAsAdmin(organizationId) {
787
+ return this.fetch(`admin/organizations/${organizationId}/a2p-status`, {
788
+ method: "DELETE"
789
+ });
790
+ }
791
+ // Site Mappings API
792
+ async getSiteMappings(options) {
793
+ const queryParams = new URLSearchParams();
794
+ if (options?.search) queryParams.append("search", options.search);
795
+ if (options?.page) queryParams.append("page", options.page.toString());
796
+ if (options?.pageSize) queryParams.append("pageSize", options.pageSize.toString());
797
+ const queryString = queryParams.toString();
798
+ const url = `admin/site-mappings${queryString ? `?${queryString}` : ""}`;
799
+ return this.fetch(url);
800
+ }
801
+ async getSiteMapping(siteId) {
802
+ return this.fetch(`admin/site-mappings/${siteId}`);
803
+ }
804
+ async updateSiteMapping(siteId, data) {
805
+ return this.fetch(`admin/site-mappings/${siteId}`, {
806
+ method: "PUT",
807
+ body: JSON.stringify(data)
808
+ });
809
+ }
810
+ async updateSiteMappingWorkspace(siteId, workspaceId) {
811
+ return this.updateSiteMapping(siteId, {
812
+ workspaceId,
813
+ siteUuid: ""
814
+ // These fields are required by the type but will be ignored on the server
815
+ });
816
+ }
817
+ async adminDeleteSiteMapping(siteId) {
818
+ return this.fetch(`admin/site-mappings/${siteId}`, {
819
+ method: "DELETE"
820
+ });
821
+ }
822
+ async createSiteMapping(mapping) {
823
+ return this.fetch(`admin/site-mappings`, {
824
+ method: "POST",
825
+ body: JSON.stringify(mapping)
826
+ });
827
+ }
828
+ // Keep for backward compatibility
829
+ async createOrUpdateSiteMapping(wid, mapping) {
830
+ return this.fetch(`admin/workspaces/${wid}/site-mappings`, {
831
+ method: "POST",
832
+ body: JSON.stringify(mapping)
833
+ });
834
+ }
835
+ async deleteSiteMapping(wid, siteUuid) {
836
+ return this.fetch(`admin/workspaces/${wid}/site-mappings/${siteUuid}`, {
837
+ method: "DELETE"
838
+ });
839
+ }
840
+ async getWorkspaceInboxesAsAdmin(workspaceUuid) {
841
+ return this.fetch(
842
+ `admin/workspaces/${workspaceUuid}/inboxes`
843
+ );
844
+ }
845
+ // Admin Inbox Mappings API
846
+ async getInboxMappings(options = {}) {
847
+ const params = new URLSearchParams();
848
+ if (options.page) params.append("page", options.page.toString());
849
+ if (options.pageSize) params.append("pageSize", options.pageSize.toString());
850
+ if (options.search) params.append("search", options.search);
851
+ if (options.workspaceId) params.append("workspaceId", options.workspaceId.toString());
852
+ return this.fetch(
853
+ `admin/inbox-mappings${params.toString() ? `?${params.toString()}` : ""}`
854
+ );
855
+ }
856
+ async getInboxMapping(id) {
857
+ return this.fetch(`admin/inbox-mappings/${id}`);
858
+ }
859
+ async updateInboxMapping(id, workspaceId) {
860
+ return this.fetch(`admin/inbox-mappings/${id}`, {
861
+ method: "PUT",
862
+ body: JSON.stringify({ workspaceId })
863
+ });
864
+ }
865
+ async deleteAdminInboxMapping(id) {
866
+ return this.fetch(`admin/inbox-mappings/${id}`, {
867
+ method: "DELETE"
868
+ });
869
+ }
870
+ // Evaluation API
871
+ async generateChatSummaries(options) {
872
+ return this.fetch("admin/generate-summaries", {
873
+ method: "POST",
874
+ body: JSON.stringify({
875
+ after_date: options.afterDate ? options.afterDate.toISOString().split("T")[0] + "T" + options.afterDate.toTimeString().split(" ")[0] : void 0,
876
+ only_without_summaries: options.onlyWithoutSummaries ?? true
877
+ })
878
+ });
879
+ }
880
+ async executeQuery(options) {
881
+ return this.fetch("admin/execute-query", {
882
+ method: "POST",
883
+ body: JSON.stringify({
884
+ query: options.query,
885
+ workspace_uuid: options.workspaceUuid
886
+ })
887
+ });
888
+ }
889
+ /**
890
+ * Resolve a Langfuse trace UI URL from a trace ID, chat ID, or message ID.
891
+ *
892
+ * URL-only: never fetches Langfuse payloads, Message content, or
893
+ * tool arguments. Exactly one of ``traceId``, ``chatId``, or
894
+ * ``messageId`` must be set; chat/message forms require a
895
+ * workspaceUuid. See
896
+ * docs/development/observability/llm-call-investigation.md.
897
+ */
898
+ async getTraceUrl(options) {
899
+ return this.fetch("admin/trace/url", {
900
+ method: "POST",
901
+ body: JSON.stringify({
902
+ trace_id: options.traceId,
903
+ chat_id: options.chatId,
904
+ message_id: options.messageId,
905
+ workspace_uuid: options.workspaceUuid
906
+ })
907
+ });
908
+ }
909
+ // Admin Themes API
910
+ async listAllThemes() {
911
+ return this.fetch("admin/themes/list");
912
+ }
913
+ // Missing Memberships API
914
+ async getMissingMemberships(workspaceId) {
915
+ return this.fetch(
916
+ `admin/workspaces/${workspaceId}/missing-memberships`
917
+ );
918
+ }
919
+ async linkMissingMembership(workspaceId, memberId, accountId) {
920
+ return this.fetch(
921
+ `admin/workspaces/${workspaceId}/link-membership?member_id=${memberId}&account_id=${accountId}`,
922
+ {
923
+ method: "POST"
924
+ }
925
+ );
926
+ }
927
+ // Bulk Phone Classification API
928
+ async startBulkPhoneClassification(workspaceUuid, includeUnknown = false) {
929
+ const params = new URLSearchParams();
930
+ params.append("include_unknown", includeUnknown.toString());
931
+ return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-classify-phones?${params.toString()}`, {
932
+ method: "POST"
933
+ });
934
+ }
935
+ // Bulk TOS Acceptance API
936
+ async startBulkTOSAcceptance(workspaceUuid) {
937
+ return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-accept-tos`, {
938
+ method: "POST"
939
+ });
940
+ }
941
+ // Token Usage Backfill API
942
+ async startTokenUsageBackfill(workspaceUuid) {
943
+ return this.fetch(`admin/workspaces/${workspaceUuid}/backfill-token-usage`, {
944
+ method: "POST"
945
+ });
946
+ }
947
+ // ===== Admin Chat Endpoints =====
948
+ async listWorkspaceChats(workspaceUuid, options) {
949
+ const params = new URLSearchParams();
950
+ if (options?.page) params.set("page", String(options.page));
951
+ if (options?.pageSize) params.set("pageSize", String(options.pageSize));
952
+ if (options?.search) params.set("search", options.search);
953
+ if (options?.chatType) params.set("chatType", options.chatType);
954
+ if (options?.channel) params.set("channel", options.channel);
955
+ if (options?.archived !== void 0) params.set("archived", String(options.archived));
956
+ const qs = params.toString();
957
+ return this.fetch(
958
+ `admin/workspaces/${workspaceUuid}/chats${qs ? `?${qs}` : ""}`
959
+ );
960
+ }
961
+ async getWorkspaceChat(workspaceUuid, chatId, options) {
962
+ const params = new URLSearchParams();
963
+ if (options?.page) params.set("page", String(options.page));
964
+ if (options?.pageSize) params.set("pageSize", String(options.pageSize));
965
+ const qs = params.toString();
966
+ return this.fetch(
967
+ `admin/workspaces/${workspaceUuid}/chats/${chatId}${qs ? `?${qs}` : ""}`
968
+ );
969
+ }
970
+ // Update chat message content
971
+ async updateChatMessage(workspaceUuid, chatId, messageId, content) {
972
+ return this.fetch(`admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}`, {
973
+ method: "POST",
974
+ body: JSON.stringify({ content })
975
+ });
976
+ }
977
+ async rateWorkspaceChatMessage(workspaceUuid, chatId, messageId, rating, comment) {
978
+ return this.fetch(
979
+ `admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}/rate`,
980
+ {
981
+ method: "POST",
982
+ body: JSON.stringify({ rating, comment })
983
+ }
984
+ );
985
+ }
986
+ // ===== Stripe Customer Management =====
987
+ async getStripeCustomer(accountId) {
988
+ return this.fetch(`admin/accounts/${accountId}/stripe/customer`);
989
+ }
990
+ async createStripeCustomer(accountId, data) {
991
+ return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
992
+ method: "POST",
993
+ body: JSON.stringify(data)
994
+ });
995
+ }
996
+ async updateStripeCustomer(accountId, data) {
997
+ return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
998
+ method: "PUT",
999
+ body: JSON.stringify(data)
1000
+ });
1001
+ }
1002
+ // ===== Customer Management =====
1003
+ async createCustomerFromAccount(accountId) {
1004
+ return this.fetch(`admin/accounts/${accountId}/customer`, {
1005
+ method: "POST"
1006
+ });
1007
+ }
1008
+ async getCustomers(options) {
1009
+ const params = new URLSearchParams();
1010
+ if (options?.search) params.set("search", options.search);
1011
+ if (options?.page) params.set("page", String(options.page));
1012
+ if (options?.pageSize) params.set("page_size", String(options.pageSize));
1013
+ const qs = params.toString();
1014
+ return this.fetch(`admin/customers${qs ? `?${qs}` : ""}`);
1015
+ }
1016
+ async getCustomer(customerId) {
1017
+ return this.fetch(`admin/customers/${customerId}`);
1018
+ }
1019
+ async createCustomer(data) {
1020
+ return this.fetch("admin/customers", {
1021
+ method: "POST",
1022
+ body: JSON.stringify(data)
1023
+ });
1024
+ }
1025
+ async updateCustomer(customerId, data) {
1026
+ return this.fetch(`admin/customers/${customerId}`, {
1027
+ method: "PUT",
1028
+ body: JSON.stringify(data)
1029
+ });
1030
+ }
1031
+ async syncCustomerToStripe(customerId) {
1032
+ return this.fetch(`admin/customers/${customerId}/stripe/sync`, {
1033
+ method: "POST"
1034
+ });
1035
+ }
1036
+ async getCustomerAccounts(customerId) {
1037
+ return this.fetch(`admin/customers/${customerId}/accounts`);
1038
+ }
1039
+ async linkCustomerToAccount(customerId, accountId, role) {
1040
+ return this.fetch(`admin/customers/${customerId}/accounts`, {
1041
+ method: "POST",
1042
+ body: JSON.stringify({ accountId, role })
1043
+ });
1044
+ }
1045
+ async unlinkCustomerFromAccount(customerId, accountId) {
1046
+ await this.fetch(`admin/customers/${customerId}/accounts/${accountId}`, {
1047
+ method: "DELETE"
1048
+ });
1049
+ }
1050
+ // ===== Stripe Subscription Management =====
1051
+ async getStripeSubscriptions(accountId) {
1052
+ return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions`);
1053
+ }
1054
+ async createStripeSubscription(customerId, data) {
1055
+ return this.fetch(`admin/customers/${customerId}/stripe/subscriptions`, {
1056
+ method: "POST",
1057
+ body: JSON.stringify(data)
1058
+ });
1059
+ }
1060
+ async createDirectSubscription(customerId, data) {
1061
+ return this.fetch(`admin/customers/${customerId}/direct/subscriptions`, {
1062
+ method: "POST",
1063
+ body: JSON.stringify(data)
1064
+ });
1065
+ }
1066
+ async updateStripeSubscription(accountId, subscriptionId, data) {
1067
+ return this.fetch(
1068
+ `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
1069
+ {
1070
+ method: "PUT",
1071
+ body: JSON.stringify(data)
1072
+ }
1073
+ );
1074
+ }
1075
+ async cancelStripeSubscription(accountId, subscriptionId) {
1076
+ return this.fetch(
1077
+ `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
1078
+ {
1079
+ method: "DELETE"
1080
+ }
1081
+ );
1082
+ }
1083
+ async provisionWorkspaceForSubscription(accountId, subscriptionId) {
1084
+ return this.fetch(
1085
+ `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/provision`,
1086
+ {
1087
+ method: "POST"
1088
+ }
1089
+ );
1090
+ }
1091
+ async associateWorkspaceWithSubscription(accountId, subscriptionId, workspaceId) {
1092
+ return this.fetch(
1093
+ `admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/associate?workspace_id=${workspaceId}`,
1094
+ {
1095
+ method: "POST"
1096
+ }
1097
+ );
1098
+ }
1099
+ async createSubscriptionPaymentLink(accountId, subscriptionId) {
1100
+ return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/payment-link`, {
1101
+ method: "POST"
1102
+ });
1103
+ }
1104
+ // ===== Stripe Payment Methods Management =====
1105
+ async createSetupIntent(accountId) {
1106
+ return this.fetch(`admin/accounts/${accountId}/stripe/setup-intent`, {
1107
+ method: "POST"
1108
+ });
1109
+ }
1110
+ async getStripePaymentMethods(accountId) {
1111
+ return this.fetch(
1112
+ `admin/accounts/${accountId}/stripe/payment-methods`
1113
+ );
1114
+ }
1115
+ async attachStripePaymentMethod(accountId, paymentMethodId, setAsDefault = false) {
1116
+ return this.fetch(`admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/attach`, {
1117
+ method: "POST",
1118
+ body: JSON.stringify({ setAsDefault })
1119
+ });
1120
+ }
1121
+ async detachStripePaymentMethod(accountId, paymentMethodId) {
1122
+ return this.fetch(
1123
+ `admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}`,
1124
+ {
1125
+ method: "DELETE"
1126
+ }
1127
+ );
1128
+ }
1129
+ async setDefaultStripePaymentMethod(accountId, paymentMethodId) {
1130
+ return this.fetch(
1131
+ `admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/set-default`,
1132
+ {
1133
+ method: "PUT"
1134
+ }
1135
+ );
1136
+ }
1137
+ // ===== Convert Direct Subscription to Stripe =====
1138
+ async convertSubscriptionToStripe(customerId, subscriptionId) {
1139
+ return this.fetch(
1140
+ `admin/customers/${customerId}/subscriptions/${subscriptionId}/convert-to-stripe`,
1141
+ { method: "POST" }
1142
+ );
1143
+ }
1144
+ // ===== Customer-Level Stripe Payment Methods =====
1145
+ async createCustomerSetupIntent(customerId) {
1146
+ return this.fetch(`admin/customers/${customerId}/stripe/setup-intent`, {
1147
+ method: "POST"
1148
+ });
1149
+ }
1150
+ async getCustomerPaymentMethods(customerId) {
1151
+ return this.fetch(
1152
+ `admin/customers/${customerId}/stripe/payment-methods`
1153
+ );
1154
+ }
1155
+ async attachCustomerPaymentMethod(customerId, paymentMethodId, setAsDefault = false) {
1156
+ return this.fetch(`admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/attach`, {
1157
+ method: "POST",
1158
+ body: JSON.stringify({ setAsDefault })
1159
+ });
1160
+ }
1161
+ async detachCustomerPaymentMethod(customerId, paymentMethodId) {
1162
+ return this.fetch(
1163
+ `admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}`,
1164
+ {
1165
+ method: "DELETE"
1166
+ }
1167
+ );
1168
+ }
1169
+ async setDefaultCustomerPaymentMethod(customerId, paymentMethodId) {
1170
+ return this.fetch(
1171
+ `admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/set-default`,
1172
+ {
1173
+ method: "PUT"
1174
+ }
1175
+ );
1176
+ }
1177
+ // ===== Workspace Organization Migration =====
1178
+ async previewWorkspaceOrganizationChange(workspaceUuid, targetOrganizationId, newCreatorId) {
1179
+ return this.fetch(`admin/workspaces/${workspaceUuid}/change-org/preview`, {
1180
+ method: "POST",
1181
+ headers: {
1182
+ "Content-Type": "application/json"
1183
+ },
1184
+ body: JSON.stringify({
1185
+ targetOrganizationId,
1186
+ newCreatorId
1187
+ })
1188
+ });
1189
+ }
1190
+ async changeWorkspaceOrganization(workspaceUuid, targetOrganizationId, newCreatorId) {
1191
+ return this.fetch(`admin/workspaces/${workspaceUuid}/change-org`, {
1192
+ method: "POST",
1193
+ body: JSON.stringify({
1194
+ targetOrganizationId,
1195
+ newCreatorId
1196
+ })
1197
+ });
1198
+ }
1199
+ // ===== Stripe Invoice Management =====
1200
+ async createStripeInvoice(accountId, data) {
1201
+ return this.fetch(`admin/accounts/${accountId}/stripe/invoices`, {
1202
+ method: "POST",
1203
+ body: JSON.stringify({
1204
+ customer: data.customer,
1205
+ description: data.description,
1206
+ collection_method: data.collectionMethod,
1207
+ days_until_due: data.daysUntilDue,
1208
+ auto_advance: data.autoAdvance,
1209
+ metadata: data.metadata
1210
+ })
1211
+ });
1212
+ }
1213
+ async getStripeInvoices(accountId, options) {
1214
+ const params = new URLSearchParams();
1215
+ if (options?.limit) params.append("limit", options.limit.toString());
1216
+ if (options?.startingAfter) params.append("starting_after", options.startingAfter);
1217
+ return this.fetch(`admin/accounts/${accountId}/stripe/invoices?${params.toString()}`);
1218
+ }
1219
+ async getStripeUpcomingInvoice(accountId, subscriptionId) {
1220
+ const params = new URLSearchParams();
1221
+ if (subscriptionId) params.append("subscription_id", subscriptionId);
1222
+ return this.fetch(`admin/accounts/${accountId}/stripe/upcoming-invoice?${params.toString()}`);
1223
+ }
1224
+ // Billing Dashboard API
1225
+ async getWorkspaceUsageDashboard(workspaceUuid) {
1226
+ return this.fetch(
1227
+ `admin/workspaces/${workspaceUuid}/usage-dashboard`
1228
+ );
1229
+ }
1230
+ // Product Stripe Sync API
1231
+ async compareProductsWithStripe(workspaceUuid) {
1232
+ const params = workspaceUuid ? `?workspace_uuid=${encodeURIComponent(workspaceUuid)}` : "";
1233
+ return this.fetch(`admin/products/compare-stripe${params}`);
1234
+ }
1235
+ async syncProductToStripe(productId, request) {
1236
+ return this.fetch(`admin/products/${productId}/sync-stripe`, {
1237
+ method: "POST",
1238
+ body: JSON.stringify({ ...request, productId })
1239
+ });
1240
+ }
1241
+ // Search Stripe products
1242
+ async searchStripeProducts(query, limit = 10) {
1243
+ const params = new URLSearchParams({ query, limit: limit.toString() });
1244
+ return this.fetch(`admin/products/stripe/search?${params.toString()}`);
1245
+ }
1246
+ // ===== Subscriptions API =====
1247
+ async getSubscriptionsAsAdmin(options) {
1248
+ const params = new URLSearchParams();
1249
+ if (options?.productId) params.append("product_id", options.productId.toString());
1250
+ if (options?.productType) params.append("product_type", options.productType);
1251
+ if (options?.customerId) params.append("customer_id", options.customerId.toString());
1252
+ if (options?.organizationId)
1253
+ params.append("organization_id", options.organizationId.toString());
1254
+ if (options?.accountId) params.append("account_id", options.accountId.toString());
1255
+ if (options?.isDirect !== void 0) params.append("is_direct", options.isDirect.toString());
1256
+ if (options?.status) params.append("status", options.status);
1257
+ if (options?.page) params.append("page", options.page.toString());
1258
+ if (options?.pageSize) params.append("page_size", options.pageSize.toString());
1259
+ const queryString = params.toString();
1260
+ return this.fetch(
1261
+ `admin/subscriptions${queryString ? `?${queryString}` : ""}`
1262
+ );
1263
+ }
1264
+ async getSubscriptionAsAdmin(subscriptionId) {
1265
+ return this.fetch(`admin/subscriptions/${subscriptionId}`);
1266
+ }
1267
+ async updateSubscriptionStatusAsAdmin(subscriptionId, subscriptionStatus) {
1268
+ return this.fetch(`admin/subscriptions/${subscriptionId}`, {
1269
+ method: "PUT",
1270
+ body: JSON.stringify({ subscription_status: subscriptionStatus })
1271
+ });
1272
+ }
1273
+ async updateSubscriptionCreditSettingsAsAdmin(subscriptionId, settings) {
1274
+ return this.fetch(`admin/subscriptions/${subscriptionId}`, {
1275
+ method: "PUT",
1276
+ body: JSON.stringify(settings)
1277
+ });
1278
+ }
1279
+ /** Grant credits to a subscription (superuser only). */
1280
+ async grantCreditsAsAdmin(subscriptionId, creditUnits, grantType, reason) {
1281
+ return this.fetch(`admin/subscriptions/${subscriptionId}/grant-credits`, {
1282
+ method: "POST",
1283
+ body: JSON.stringify({ credit_units: creditUnits, grant_type: grantType, reason })
1284
+ });
1285
+ }
1286
+ /** List credit grants for a subscription (superuser only). */
1287
+ async listCreditGrantsAsAdmin(subscriptionId) {
1288
+ return this.fetch(`admin/subscriptions/${subscriptionId}/credit-grants`);
1289
+ }
1290
+ // ===== Usage API =====
1291
+ async getUsageReport(request) {
1292
+ return this.fetch("admin/usage", {
1293
+ method: "POST",
1294
+ body: JSON.stringify(request)
1295
+ });
1296
+ }
1297
+ // Voice Metrics API
1298
+ async getVoiceMetrics(options) {
1299
+ const params = new URLSearchParams();
1300
+ if (options?.hours) params.append("hours", options.hours.toString());
1301
+ if (options?.period) params.append("period", options.period.toString());
1302
+ if (options?.workspace_uuid) params.append("workspace_uuid", options.workspace_uuid);
1303
+ if (options?.organization_id != null)
1304
+ params.append("organization_id", options.organization_id.toString());
1305
+ if (options?.engine) params.append("engine", options.engine);
1306
+ if (options?.channel) params.append("channel", options.channel);
1307
+ const qs = params.toString();
1308
+ return this.fetch(`admin/voice-metrics${qs ? `?${qs}` : ""}`);
1309
+ }
1310
+ // Health Dashboard API
1311
+ async getHealthMetrics(request) {
1312
+ return this.fetch("admin/health/metrics", {
1313
+ method: "POST",
1314
+ body: JSON.stringify(request)
1315
+ });
1316
+ }
1317
+ async getHealthDetail(workspaceUuid, request) {
1318
+ return this.fetch(`admin/health/detail/${workspaceUuid}`, {
1319
+ method: "POST",
1320
+ body: JSON.stringify(request)
1321
+ });
1322
+ }
1323
+ // ===== Reseller Management =====
1324
+ async getResellers(options) {
1325
+ const params = new URLSearchParams();
1326
+ if (options?.search) params.set("search", options.search);
1327
+ if (options?.page) params.set("page", String(options.page));
1328
+ if (options?.pageSize) params.set("page_size", String(options.pageSize));
1329
+ const qs = params.toString();
1330
+ return this.fetch(`admin/resellers${qs ? `?${qs}` : ""}`);
1331
+ }
1332
+ async getReseller(resellerId) {
1333
+ return this.fetch(`admin/resellers/${resellerId}`);
1334
+ }
1335
+ async createReseller(data) {
1336
+ return this.fetch("admin/resellers", {
1337
+ method: "POST",
1338
+ body: JSON.stringify(data)
1339
+ });
1340
+ }
1341
+ async updateReseller(resellerId, data) {
1342
+ return this.fetch(`admin/resellers/${resellerId}`, {
1343
+ method: "PUT",
1344
+ body: JSON.stringify(data)
1345
+ });
1346
+ }
1347
+ async getResellerAccounts(resellerId) {
1348
+ return this.fetch(`admin/resellers/${resellerId}/accounts`);
1349
+ }
1350
+ async linkResellerToAccount(resellerId, data) {
1351
+ return this.fetch(`admin/resellers/${resellerId}/accounts`, {
1352
+ method: "POST",
1353
+ body: JSON.stringify({ account_id: data.accountId, role: data.role })
1354
+ });
1355
+ }
1356
+ async unlinkResellerFromAccount(resellerId, accountId) {
1357
+ await this.fetch(`admin/resellers/${resellerId}/accounts/${accountId}`, {
1358
+ method: "DELETE"
1359
+ });
1360
+ }
1361
+ // ===== Invoice Management =====
1362
+ async generateInvoice(data) {
1363
+ return this.fetch("admin/invoices/generate", {
1364
+ method: "POST",
1365
+ body: JSON.stringify(data)
1366
+ });
1367
+ }
1368
+ async getInvoices(subscriptionId, pageOpts) {
1369
+ const params = new URLSearchParams();
1370
+ if (subscriptionId !== void 0) params.set("subscription_id", String(subscriptionId));
1371
+ if (pageOpts?.page !== void 0) params.set("page", String(pageOpts.page));
1372
+ if (pageOpts?.pageSize !== void 0) params.set("pageSize", String(pageOpts.pageSize));
1373
+ const qs = params.toString();
1374
+ return this.fetch(`admin/invoices${qs ? `?${qs}` : ""}`);
1375
+ }
1376
+ async getBillingPeriods(subscriptionId) {
1377
+ return this.fetch(
1378
+ `admin/invoices/periods?subscription_id=${subscriptionId}`
1379
+ );
1380
+ }
1381
+ async getInvoiceDownloadUrl(invoiceId) {
1382
+ return this.fetch(
1383
+ `admin/invoices/${invoiceId}/download`
1384
+ );
1385
+ }
1386
+ async getReceiptDownloadUrl(invoiceId) {
1387
+ return this.fetch(
1388
+ `admin/invoices/${invoiceId}/receipt`
1389
+ );
1390
+ }
1391
+ async recordInvoicePayment(invoiceId, data) {
1392
+ return this.fetch(`admin/invoices/${invoiceId}/record-payment`, {
1393
+ method: "POST",
1394
+ body: JSON.stringify(data)
1395
+ });
1396
+ }
1397
+ // ===== Admin Temporal Inspection (PHI-safe, read-only) =====
1398
+ /**
1399
+ * Server-enforced bounds for admin Temporal queries (lookback, thresholds,
1400
+ * page sizes, history event cap). Superuser only.
1401
+ */
1402
+ async getTemporalAdminConfig() {
1403
+ return this.fetch("admin/temporal/config");
1404
+ }
1405
+ /**
1406
+ * List recent Temporal workflows in FAILED, TIMED_OUT, or TERMINATED
1407
+ * status. Returns only PHI-safe operational metadata. Superuser only.
1408
+ *
1409
+ * Pass `options.status` to filter to a single status and enable
1410
+ * deep pagination via `nextPageToken`. Merged mode (no status) returns
1411
+ * the first page only and always emits `nextPageToken: null`.
1412
+ */
1413
+ async listFailedTemporalWorkflows(options = {}) {
1414
+ const params = new URLSearchParams();
1415
+ if (options.lookbackHours !== void 0)
1416
+ params.set("lookback_hours", String(options.lookbackHours));
1417
+ if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
1418
+ if (options.status) params.set("status", String(options.status));
1419
+ if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
1420
+ appendTemporalWorkspaceParams(params, options);
1421
+ const qs = params.toString();
1422
+ return this.fetch(
1423
+ `admin/temporal/workflows/failed${qs ? `?${qs}` : ""}`
1424
+ );
1425
+ }
1426
+ /**
1427
+ * List open Temporal workflows older than the stuck threshold.
1428
+ * Superuser only.
1429
+ */
1430
+ async listStuckTemporalWorkflows(options = {}) {
1431
+ const params = new URLSearchParams();
1432
+ if (options.thresholdMinutes !== void 0)
1433
+ params.set("threshold_minutes", String(options.thresholdMinutes));
1434
+ if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
1435
+ if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
1436
+ appendTemporalWorkspaceParams(params, options);
1437
+ const qs = params.toString();
1438
+ return this.fetch(
1439
+ `admin/temporal/workflows/stuck${qs ? `?${qs}` : ""}`
1440
+ );
1441
+ }
1442
+ /**
1443
+ * Return grouped counts for recent Temporal executions. Superuser only.
1444
+ */
1445
+ async getTemporalSummary(options = {}) {
1446
+ const params = new URLSearchParams();
1447
+ if (options.lookbackHours !== void 0)
1448
+ params.set("lookback_hours", String(options.lookbackHours));
1449
+ appendTemporalWorkspaceParams(params, options);
1450
+ const qs = params.toString();
1451
+ return this.fetch(
1452
+ `admin/temporal/workflows/summary${qs ? `?${qs}` : ""}`
1453
+ );
1454
+ }
1455
+ /**
1456
+ * Fetch metadata + bounded sanitized history summary for one Temporal
1457
+ * workflow. Superuser only. Does not return raw events or payloads.
1458
+ */
1459
+ async getTemporalWorkflowDetail(workflowId, options = {}) {
1460
+ const params = new URLSearchParams();
1461
+ if (options.runId) params.set("run_id", options.runId);
1462
+ appendTemporalWorkspaceParams(params, options);
1463
+ const qs = params.toString();
1464
+ const encoded = encodeURIComponent(workflowId);
1465
+ return this.fetch(
1466
+ `admin/temporal/workflows/${encoded}${qs ? `?${qs}` : ""}`
1467
+ );
1468
+ }
1469
+ };
1470
+ function appendTemporalWorkspaceParams(params, options) {
1471
+ const seen = /* @__PURE__ */ new Set();
1472
+ const push = (raw) => {
1473
+ if (!raw) return;
1474
+ const trimmed = raw.trim();
1475
+ if (!trimmed || seen.has(trimmed)) return;
1476
+ seen.add(trimmed);
1477
+ params.append("workspace_uuid", trimmed);
1478
+ };
1479
+ if (options.workspaceUuids) {
1480
+ for (const value of options.workspaceUuids) push(value);
1481
+ }
1482
+ push(options.workspaceUuid);
1483
+ }
1484
+ function bindAdminMethods(target, admin) {
1485
+ target.listSupportRequestsAsAdmin = admin.listSupportRequestsAsAdmin.bind(admin);
1486
+ target.getSupportRequestAsAdmin = admin.getSupportRequestAsAdmin.bind(admin);
1487
+ target.commentOnSupportRequestAsAdmin = admin.commentOnSupportRequestAsAdmin.bind(admin);
1488
+ target.noteOnSupportRequestAsAdmin = admin.noteOnSupportRequestAsAdmin.bind(admin);
1489
+ target.updateSupportRequestStatusAsAdmin = admin.updateSupportRequestStatusAsAdmin.bind(admin);
1490
+ target.updateSupportRequestAttributesAsAdmin = admin.updateSupportRequestAttributesAsAdmin.bind(admin);
1491
+ target.createSupportRequestLinearIssueAsAdmin = admin.createSupportRequestLinearIssueAsAdmin.bind(admin);
1492
+ target.getAccounts = admin.getAccounts.bind(admin);
1493
+ target.getAccountDetails = admin.getAccountDetails.bind(admin);
1494
+ target.getAccountByUuid = admin.getAccountByUuid.bind(admin);
1495
+ target.getAccountMemberships = admin.getAccountMemberships.bind(admin);
1496
+ target.getAccountOrgMemberships = admin.getAccountOrgMemberships.bind(admin);
1497
+ target.createAccountOrgMembership = admin.createAccountOrgMembership.bind(admin);
1498
+ target.deleteAccountOrgMembership = admin.deleteAccountOrgMembership.bind(admin);
1499
+ target.getAccountMembership = admin.getAccountMembership.bind(admin);
1500
+ target.updateAccountMembership = admin.updateAccountMembership.bind(admin);
1501
+ target.createAccountMembership = admin.createAccountMembership.bind(admin);
1502
+ target.deleteAccountMembership = admin.deleteAccountMembership.bind(admin);
1503
+ target.updateAccountAsAdmin = admin.updateAccountAsAdmin.bind(admin);
1504
+ target.createAccountAsAdmin = admin.createAccountAsAdmin.bind(admin);
1505
+ target.deleteAccountAsAdmin = admin.deleteAccountAsAdmin.bind(admin);
1506
+ target.lookupAccount = admin.lookupAccount.bind(admin);
1507
+ target.exportAccountData = admin.exportAccountData.bind(admin);
1508
+ target.requestAccountDeletion = admin.requestAccountDeletion.bind(admin);
1509
+ target.cancelAccountDeletion = admin.cancelAccountDeletion.bind(admin);
1510
+ target.getOrganizations = admin.getOrganizations.bind(admin);
1511
+ target.getOrganization = admin.getOrganization.bind(admin);
1512
+ target.getOrganizationAsAdmin = admin.getOrganizationAsAdmin.bind(admin);
1513
+ target.getOrganizationMembersAsAdmin = admin.getOrganizationMembersAsAdmin.bind(admin);
1514
+ target.createOrganization = admin.createOrganization.bind(admin);
1515
+ target.updateOrganization = admin.updateOrganization.bind(admin);
1516
+ target.deleteOrganization = admin.deleteOrganization.bind(admin);
1517
+ target.joinOrganization = admin.joinOrganization.bind(admin);
1518
+ target.leaveOrganization = admin.leaveOrganization.bind(admin);
1519
+ target.generateLogoUploadUrl = admin.generateLogoUploadUrl.bind(admin);
1520
+ target.importProducts = admin.importProducts.bind(admin);
1521
+ target.createProductAsAdmin = admin.createProductAsAdmin.bind(admin);
1522
+ target.getProductsAsAdmin = admin.getProductsAsAdmin.bind(admin);
1523
+ target.getProductAsAdmin = admin.getProductAsAdmin.bind(admin);
1524
+ target.updateProductAsAdmin = admin.updateProductAsAdmin.bind(admin);
1525
+ target.deleteProductAsAdmin = admin.deleteProductAsAdmin.bind(admin);
1526
+ target.getWorkspacesAsAdmin = admin.getWorkspacesAsAdmin.bind(admin);
1527
+ target.getWorkspaceAsAdmin = admin.getWorkspaceAsAdmin.bind(admin);
1528
+ target.getWorkspaceByNumericIdAsAdmin = admin.getWorkspaceByNumericIdAsAdmin.bind(admin);
1529
+ target.createWorkspaceAsAdmin = admin.createWorkspaceAsAdmin.bind(admin);
1530
+ target.updateWorkspaceAsAdmin = admin.updateWorkspaceAsAdmin.bind(admin);
1531
+ target.deleteWorkspaceAsAdmin = admin.deleteWorkspaceAsAdmin.bind(admin);
1532
+ target.createSchemaAsAdmin = admin.createSchemaAsAdmin.bind(admin);
1533
+ target.migrateSchemaAsAdmin = admin.migrateSchemaAsAdmin.bind(admin);
1534
+ target.provisionWorkspaceAsAdmin = admin.provisionWorkspaceAsAdmin.bind(admin);
1535
+ target.refreshProvisionStatusAsAdmin = admin.refreshProvisionStatusAsAdmin.bind(admin);
1536
+ target.enableMaintenanceMode = admin.enableMaintenanceMode.bind(admin);
1537
+ target.disableMaintenanceMode = admin.disableMaintenanceMode.bind(admin);
1538
+ target.getWorkspaceHealth = admin.getWorkspaceHealth.bind(admin);
1539
+ target.provisionPlanFeatures = admin.provisionPlanFeatures.bind(admin);
1540
+ target.changeWorkspaceProduct = admin.changeWorkspaceProduct.bind(admin);
1541
+ target.validateWorkflowAccessAsAdmin = admin.validateWorkflowAccessAsAdmin.bind(admin);
1542
+ target.mergeMembers = admin.mergeMembers.bind(admin);
1543
+ target.getAdminWorkspaceMember = admin.getAdminWorkspaceMember.bind(admin);
1544
+ target.createAdminWorkspaceMember = admin.createAdminWorkspaceMember.bind(admin);
1545
+ target.updateAdminWorkspaceMember = admin.updateAdminWorkspaceMember.bind(admin);
1546
+ target.unarchiveAdminWorkspaceMember = admin.unarchiveAdminWorkspaceMember.bind(admin);
1547
+ target.getAdminWorkspaceMemberRoles = admin.getAdminWorkspaceMemberRoles.bind(admin);
1548
+ target.getMissingMemberships = admin.getMissingMemberships.bind(admin);
1549
+ target.linkMissingMembership = admin.linkMissingMembership.bind(admin);
1550
+ target.getUnmappedPhoneNumbers = admin.getUnmappedPhoneNumbers.bind(admin);
1551
+ target.getWorkspaceUnmappedPhoneNumbers = admin.getWorkspaceUnmappedPhoneNumbers.bind(admin);
1552
+ target.getWorkspacePhoneNumbersAsAdmin = admin.getWorkspacePhoneNumbersAsAdmin.bind(admin);
1553
+ target.getProviderPhoneNumbers = admin.getProviderPhoneNumbers.bind(admin);
1554
+ target.getProviderPhoneNumber = admin.getProviderPhoneNumber.bind(admin);
1555
+ target.updateProviderPhoneNumber = admin.updateProviderPhoneNumber.bind(admin);
1556
+ target.mapMainAccountPhone = admin.mapMainAccountPhone.bind(admin);
1557
+ target.unmapPhoneNumber = admin.unmapPhoneNumber.bind(admin);
1558
+ target.searchAvailablePhoneNumbersAsAdmin = admin.searchAvailablePhoneNumbersAsAdmin.bind(admin);
1559
+ target.purchasePhoneNumberAsAdmin = admin.purchasePhoneNumberAsAdmin.bind(admin);
1560
+ target.startBulkPhoneClassification = admin.startBulkPhoneClassification.bind(admin);
1561
+ target.getOrgA2PStatusAsAdmin = admin.getOrgA2PStatusAsAdmin.bind(admin);
1562
+ target.resetOrgA2PStatusAsAdmin = admin.resetOrgA2PStatusAsAdmin.bind(admin);
1563
+ target.getSiteMappings = admin.getSiteMappings.bind(admin);
1564
+ target.getSiteMapping = admin.getSiteMapping.bind(admin);
1565
+ target.updateSiteMapping = admin.updateSiteMapping.bind(admin);
1566
+ target.updateSiteMappingWorkspace = admin.updateSiteMappingWorkspace.bind(admin);
1567
+ target.adminDeleteSiteMapping = admin.adminDeleteSiteMapping.bind(admin);
1568
+ target.createSiteMapping = admin.createSiteMapping.bind(admin);
1569
+ target.createOrUpdateSiteMapping = admin.createOrUpdateSiteMapping.bind(admin);
1570
+ target.deleteSiteMapping = admin.deleteSiteMapping.bind(admin);
1571
+ target.getInboxMappings = admin.getInboxMappings.bind(admin);
1572
+ target.getInboxMapping = admin.getInboxMapping.bind(admin);
1573
+ target.updateInboxMapping = admin.updateInboxMapping.bind(admin);
1574
+ target.deleteAdminInboxMapping = admin.deleteAdminInboxMapping.bind(admin);
1575
+ target.generateChatSummaries = admin.generateChatSummaries.bind(admin);
1576
+ target.executeQuery = admin.executeQuery.bind(admin);
1577
+ target.getTraceUrl = admin.getTraceUrl.bind(admin);
1578
+ target.listAllThemes = admin.listAllThemes.bind(admin);
1579
+ target.startBulkTOSAcceptance = admin.startBulkTOSAcceptance.bind(admin);
1580
+ target.startTokenUsageBackfill = admin.startTokenUsageBackfill.bind(admin);
1581
+ target.updateChatMessage = admin.updateChatMessage.bind(admin);
1582
+ target.createCustomerFromAccount = admin.createCustomerFromAccount.bind(admin);
1583
+ target.getCustomers = admin.getCustomers.bind(admin);
1584
+ target.getCustomer = admin.getCustomer.bind(admin);
1585
+ target.createCustomer = admin.createCustomer.bind(admin);
1586
+ target.updateCustomer = admin.updateCustomer.bind(admin);
1587
+ target.getCustomerAccounts = admin.getCustomerAccounts.bind(admin);
1588
+ target.linkCustomerToAccount = admin.linkCustomerToAccount.bind(admin);
1589
+ target.unlinkCustomerFromAccount = admin.unlinkCustomerFromAccount.bind(admin);
1590
+ target.syncCustomerToStripe = admin.syncCustomerToStripe.bind(admin);
1591
+ target.getStripeCustomer = admin.getStripeCustomer.bind(admin);
1592
+ target.createStripeCustomer = admin.createStripeCustomer.bind(admin);
1593
+ target.updateStripeCustomer = admin.updateStripeCustomer.bind(admin);
1594
+ target.getStripeSubscriptions = admin.getStripeSubscriptions.bind(admin);
1595
+ target.createStripeSubscription = admin.createStripeSubscription.bind(admin);
1596
+ target.createDirectSubscription = admin.createDirectSubscription.bind(admin);
1597
+ target.updateStripeSubscription = admin.updateStripeSubscription.bind(admin);
1598
+ target.cancelStripeSubscription = admin.cancelStripeSubscription.bind(admin);
1599
+ target.provisionWorkspaceForSubscription = admin.provisionWorkspaceForSubscription.bind(admin);
1600
+ target.associateWorkspaceWithSubscription = admin.associateWorkspaceWithSubscription.bind(admin);
1601
+ target.createSubscriptionPaymentLink = admin.createSubscriptionPaymentLink.bind(admin);
1602
+ target.createSetupIntent = admin.createSetupIntent.bind(admin);
1603
+ target.getStripePaymentMethods = admin.getStripePaymentMethods.bind(admin);
1604
+ target.attachStripePaymentMethod = admin.attachStripePaymentMethod.bind(admin);
1605
+ target.detachStripePaymentMethod = admin.detachStripePaymentMethod.bind(admin);
1606
+ target.setDefaultStripePaymentMethod = admin.setDefaultStripePaymentMethod.bind(admin);
1607
+ target.convertSubscriptionToStripe = admin.convertSubscriptionToStripe.bind(admin);
1608
+ target.createCustomerSetupIntent = admin.createCustomerSetupIntent.bind(admin);
1609
+ target.getCustomerPaymentMethods = admin.getCustomerPaymentMethods.bind(admin);
1610
+ target.attachCustomerPaymentMethod = admin.attachCustomerPaymentMethod.bind(admin);
1611
+ target.detachCustomerPaymentMethod = admin.detachCustomerPaymentMethod.bind(admin);
1612
+ target.setDefaultCustomerPaymentMethod = admin.setDefaultCustomerPaymentMethod.bind(admin);
1613
+ target.previewWorkspaceOrganizationChange = admin.previewWorkspaceOrganizationChange.bind(admin);
1614
+ target.changeWorkspaceOrganization = admin.changeWorkspaceOrganization.bind(admin);
1615
+ target.createStripeInvoice = admin.createStripeInvoice.bind(admin);
1616
+ target.getStripeInvoices = admin.getStripeInvoices.bind(admin);
1617
+ target.getStripeUpcomingInvoice = admin.getStripeUpcomingInvoice.bind(admin);
1618
+ target.getBillingPeriods = admin.getBillingPeriods.bind(admin);
1619
+ target.generateInvoice = admin.generateInvoice.bind(admin);
1620
+ target.getInvoices = admin.getInvoices.bind(admin);
1621
+ target.getInvoiceDownloadUrl = admin.getInvoiceDownloadUrl.bind(admin);
1622
+ target.getReceiptDownloadUrl = admin.getReceiptDownloadUrl.bind(admin);
1623
+ target.recordInvoicePayment = admin.recordInvoicePayment.bind(admin);
1624
+ target.getWorkspaceUsageDashboard = admin.getWorkspaceUsageDashboard.bind(admin);
1625
+ target.compareProductsWithStripe = admin.compareProductsWithStripe.bind(admin);
1626
+ target.syncProductToStripe = admin.syncProductToStripe.bind(admin);
1627
+ target.searchStripeProducts = admin.searchStripeProducts.bind(admin);
1628
+ target.getUsageReport = admin.getUsageReport.bind(admin);
1629
+ target.getSubscriptionsAsAdmin = admin.getSubscriptionsAsAdmin.bind(admin);
1630
+ target.getSubscriptionAsAdmin = admin.getSubscriptionAsAdmin.bind(admin);
1631
+ target.updateSubscriptionStatusAsAdmin = admin.updateSubscriptionStatusAsAdmin.bind(admin);
1632
+ target.updateSubscriptionCreditSettingsAsAdmin = admin.updateSubscriptionCreditSettingsAsAdmin.bind(admin);
1633
+ target.grantCreditsAsAdmin = admin.grantCreditsAsAdmin.bind(admin);
1634
+ target.listCreditGrantsAsAdmin = admin.listCreditGrantsAsAdmin.bind(admin);
1635
+ target.getVoiceMetrics = admin.getVoiceMetrics.bind(admin);
1636
+ target.getHealthMetrics = admin.getHealthMetrics.bind(admin);
1637
+ target.getHealthDetail = admin.getHealthDetail.bind(admin);
1638
+ target.getWorkspaceInboxesAsAdmin = admin.getWorkspaceInboxesAsAdmin.bind(admin);
1639
+ target.listWorkspaceChats = admin.listWorkspaceChats.bind(admin);
1640
+ target.getWorkspaceChat = admin.getWorkspaceChat.bind(admin);
1641
+ target.rateWorkspaceChatMessage = admin.rateWorkspaceChatMessage.bind(admin);
1642
+ target.getTemporalAdminConfig = admin.getTemporalAdminConfig.bind(admin);
1643
+ target.listFailedTemporalWorkflows = admin.listFailedTemporalWorkflows.bind(admin);
1644
+ target.listStuckTemporalWorkflows = admin.listStuckTemporalWorkflows.bind(admin);
1645
+ target.getTemporalSummary = admin.getTemporalSummary.bind(admin);
1646
+ target.getTemporalWorkflowDetail = admin.getTemporalWorkflowDetail.bind(admin);
1647
+ target.getResellers = admin.getResellers.bind(admin);
1648
+ target.getReseller = admin.getReseller.bind(admin);
1649
+ target.createReseller = admin.createReseller.bind(admin);
1650
+ target.updateReseller = admin.updateReseller.bind(admin);
1651
+ target.getResellerAccounts = admin.getResellerAccounts.bind(admin);
1652
+ target.linkResellerToAccount = admin.linkResellerToAccount.bind(admin);
1653
+ target.unlinkResellerFromAccount = admin.unlinkResellerFromAccount.bind(admin);
1654
+ }
1655
+ var ApiClient = class extends GravityRailClient {
1656
+ // Admin API
1657
+ listSupportRequestsAsAdmin;
1658
+ getSupportRequestAsAdmin;
1659
+ commentOnSupportRequestAsAdmin;
1660
+ noteOnSupportRequestAsAdmin;
1661
+ updateSupportRequestStatusAsAdmin;
1662
+ updateSupportRequestAttributesAsAdmin;
1663
+ createSupportRequestLinearIssueAsAdmin;
1664
+ getAccounts;
1665
+ getAccountDetails;
1666
+ getAccountByUuid;
1667
+ getAccountMemberships;
1668
+ getAccountOrgMemberships;
1669
+ createAccountOrgMembership;
1670
+ deleteAccountOrgMembership;
1671
+ getAccountMembership;
1672
+ updateAccountMembership;
1673
+ createAccountMembership;
1674
+ deleteAccountMembership;
1675
+ updateAccountAsAdmin;
1676
+ createAccountAsAdmin;
1677
+ deleteAccountAsAdmin;
1678
+ lookupAccount;
1679
+ exportAccountData;
1680
+ requestAccountDeletion;
1681
+ cancelAccountDeletion;
1682
+ getOrganizations;
1683
+ getOrganization;
1684
+ getOrganizationAsAdmin;
1685
+ getOrganizationMembersAsAdmin;
1686
+ createOrganization;
1687
+ updateOrganization;
1688
+ deleteOrganization;
1689
+ joinOrganization;
1690
+ leaveOrganization;
1691
+ generateLogoUploadUrl;
1692
+ importProducts;
1693
+ createProductAsAdmin;
1694
+ getProductsAsAdmin;
1695
+ getProductAsAdmin;
1696
+ updateProductAsAdmin;
1697
+ deleteProductAsAdmin;
1698
+ getWorkspacesAsAdmin;
1699
+ getWorkspaceAsAdmin;
1700
+ getWorkspaceByNumericIdAsAdmin;
1701
+ createWorkspaceAsAdmin;
1702
+ updateWorkspaceAsAdmin;
1703
+ deleteWorkspaceAsAdmin;
1704
+ createSchemaAsAdmin;
1705
+ migrateSchemaAsAdmin;
1706
+ provisionWorkspaceAsAdmin;
1707
+ refreshProvisionStatusAsAdmin;
1708
+ enableMaintenanceMode;
1709
+ disableMaintenanceMode;
1710
+ getWorkspaceHealth;
1711
+ provisionPlanFeatures;
1712
+ changeWorkspaceProduct;
1713
+ validateWorkflowAccessAsAdmin;
1714
+ mergeMembers;
1715
+ getAdminWorkspaceMember;
1716
+ createAdminWorkspaceMember;
1717
+ updateAdminWorkspaceMember;
1718
+ unarchiveAdminWorkspaceMember;
1719
+ getAdminWorkspaceMemberRoles;
1720
+ getMissingMemberships;
1721
+ linkMissingMembership;
1722
+ getUnmappedPhoneNumbers;
1723
+ getWorkspaceUnmappedPhoneNumbers;
1724
+ getWorkspacePhoneNumbersAsAdmin;
1725
+ getProviderPhoneNumbers;
1726
+ getProviderPhoneNumber;
1727
+ updateProviderPhoneNumber;
1728
+ mapMainAccountPhone;
1729
+ unmapPhoneNumber;
1730
+ searchAvailablePhoneNumbersAsAdmin;
1731
+ purchasePhoneNumberAsAdmin;
1732
+ startBulkPhoneClassification;
1733
+ getOrgA2PStatusAsAdmin;
1734
+ resetOrgA2PStatusAsAdmin;
1735
+ getSiteMappings;
1736
+ getSiteMapping;
1737
+ updateSiteMapping;
1738
+ updateSiteMappingWorkspace;
1739
+ adminDeleteSiteMapping;
1740
+ createSiteMapping;
1741
+ createOrUpdateSiteMapping;
1742
+ deleteSiteMapping;
1743
+ getInboxMappings;
1744
+ getInboxMapping;
1745
+ updateInboxMapping;
1746
+ deleteAdminInboxMapping;
1747
+ generateChatSummaries;
1748
+ executeQuery;
1749
+ getTraceUrl;
1750
+ listAllThemes;
1751
+ startBulkTOSAcceptance;
1752
+ startTokenUsageBackfill;
1753
+ updateChatMessage;
1754
+ createCustomerFromAccount;
1755
+ getCustomers;
1756
+ getCustomer;
1757
+ createCustomer;
1758
+ updateCustomer;
1759
+ getCustomerAccounts;
1760
+ linkCustomerToAccount;
1761
+ unlinkCustomerFromAccount;
1762
+ syncCustomerToStripe;
1763
+ getStripeCustomer;
1764
+ createStripeCustomer;
1765
+ updateStripeCustomer;
1766
+ getStripeSubscriptions;
1767
+ createStripeSubscription;
1768
+ createDirectSubscription;
1769
+ updateStripeSubscription;
1770
+ cancelStripeSubscription;
1771
+ provisionWorkspaceForSubscription;
1772
+ associateWorkspaceWithSubscription;
1773
+ createSubscriptionPaymentLink;
1774
+ createSetupIntent;
1775
+ getStripePaymentMethods;
1776
+ attachStripePaymentMethod;
1777
+ detachStripePaymentMethod;
1778
+ setDefaultStripePaymentMethod;
1779
+ createCustomerSetupIntent;
1780
+ getCustomerPaymentMethods;
1781
+ attachCustomerPaymentMethod;
1782
+ detachCustomerPaymentMethod;
1783
+ setDefaultCustomerPaymentMethod;
1784
+ convertSubscriptionToStripe;
1785
+ previewWorkspaceOrganizationChange;
1786
+ changeWorkspaceOrganization;
1787
+ createStripeInvoice;
1788
+ getStripeInvoices;
1789
+ getStripeUpcomingInvoice;
1790
+ getWorkspaceUsageDashboard;
1791
+ compareProductsWithStripe;
1792
+ syncProductToStripe;
1793
+ searchStripeProducts;
1794
+ getUsageReport;
1795
+ getSubscriptionsAsAdmin;
1796
+ getSubscriptionAsAdmin;
1797
+ updateSubscriptionStatusAsAdmin;
1798
+ updateSubscriptionCreditSettingsAsAdmin;
1799
+ grantCreditsAsAdmin;
1800
+ listCreditGrantsAsAdmin;
1801
+ getVoiceMetrics;
1802
+ getHealthMetrics;
1803
+ getHealthDetail;
1804
+ getWorkspaceInboxesAsAdmin;
1805
+ listWorkspaceChats;
1806
+ getWorkspaceChat;
1807
+ rateWorkspaceChatMessage;
1808
+ getTemporalAdminConfig;
1809
+ listFailedTemporalWorkflows;
1810
+ listStuckTemporalWorkflows;
1811
+ getTemporalSummary;
1812
+ getTemporalWorkflowDetail;
1813
+ getResellers;
1814
+ getReseller;
1815
+ createReseller;
1816
+ updateReseller;
1817
+ getResellerAccounts;
1818
+ linkResellerToAccount;
1819
+ unlinkResellerFromAccount;
1820
+ getBillingPeriods;
1821
+ generateInvoice;
1822
+ getInvoices;
1823
+ getInvoiceDownloadUrl;
1824
+ getReceiptDownloadUrl;
1825
+ recordInvoicePayment;
1826
+ adminApi;
1827
+ constructor(apiKey, baseUrl3, customFetch) {
1828
+ super(apiKey, baseUrl3, customFetch);
1829
+ this.adminApi = new AdminApi(apiKey, baseUrl3, customFetch);
1830
+ bindAdminMethods(this, this.adminApi);
1831
+ }
1832
+ /**
1833
+ * Propagates acting member switches to the admin API module as well.
1834
+ */
1835
+ setActingMember(memberUuid) {
1836
+ super.setActingMember(memberUuid);
1837
+ if (typeof this.adminApi.setActingMember === "function") {
1838
+ this.adminApi.setActingMember(memberUuid);
1839
+ }
1840
+ }
1841
+ // setOrgToken is intentionally NOT overridden here. Admin routes
1842
+ // (/api/v2/admin/*) are protected by the bearer token's superuser claim and
1843
+ // ignore X-Org-Token entirely, so propagating an org token to adminApi is
1844
+ // dead code that would only obscure auth flow if admin route logic changes.
1845
+ };
1846
+
1847
+ // src/lib/context.ts
269
1848
  import { homedir } from "os";
270
1849
 
271
1850
  // src/lib/output.ts
@@ -434,11 +2013,135 @@ function loadRealmCredentials(realm, devRealmsPath) {
434
2013
  if (!member?.token) {
435
2014
  throw new Error(`Realm member "${memberName}" not found in workspace "${wsName}"`);
436
2015
  }
437
- return { token: member.token, workspaceUuid: ws.workspaceUuid };
438
- }
2016
+ return { token: member.token, workspaceUuid: ws.workspaceUuid };
2017
+ }
2018
+ }
2019
+
2020
+ // src/lib/org-auth.ts
2021
+ import { execFile } from "child_process";
2022
+ var ORG_AUTH_TIMEOUT_MS = 5 * 60 * 1e3;
2023
+ function extractOrgTokenFromSetCookies(setCookieValues, preferredCookieName) {
2024
+ let fallback;
2025
+ for (const value of setCookieValues) {
2026
+ const nameValue = value.split(";")[0]?.trim() ?? "";
2027
+ const eqIdx = nameValue.indexOf("=");
2028
+ if (eqIdx === -1) continue;
2029
+ const name = nameValue.slice(0, eqIdx).trim();
2030
+ const tokenValue = nameValue.slice(eqIdx + 1).trim() || void 0;
2031
+ if (!tokenValue) continue;
2032
+ if (name === preferredCookieName) return tokenValue;
2033
+ if (!fallback && (name.startsWith("orgToken") || name.startsWith("orgSession"))) {
2034
+ fallback = tokenValue;
2035
+ }
2036
+ }
2037
+ return fallback;
2038
+ }
2039
+ async function tryDirectJoin(apiUrl, accessToken, orgAuthInfo) {
2040
+ const response = await fetch(`${apiUrl}/api/v2/o/${orgAuthInfo.orgUuid}/join`, {
2041
+ method: "POST",
2042
+ headers: {
2043
+ "Content-Type": "application/json",
2044
+ Authorization: `Bearer ${accessToken}`
2045
+ },
2046
+ body: "{}"
2047
+ });
2048
+ if (response.status === 400) {
2049
+ return null;
2050
+ }
2051
+ if (!response.ok) {
2052
+ throw new Error(`Org join failed (HTTP ${response.status})`);
2053
+ }
2054
+ const rawHeaders = response.headers;
2055
+ const setCookies = rawHeaders.getSetCookie?.() ?? (rawHeaders.get("set-cookie") ? [rawHeaders.get("set-cookie")] : []);
2056
+ if (setCookies.length === 0) {
2057
+ throw new Error("Org join succeeded but no Set-Cookie header returned");
2058
+ }
2059
+ const orgToken = extractOrgTokenFromSetCookies(setCookies, orgAuthInfo.cookieName);
2060
+ if (!orgToken) {
2061
+ throw new Error("Org join succeeded but org token cookie not found in Set-Cookie");
2062
+ }
2063
+ return orgToken;
2064
+ }
2065
+ function isAllowedAuthUrl(url, apiUrl) {
2066
+ try {
2067
+ const parsed = new URL(url);
2068
+ const api = new URL(apiUrl);
2069
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return false;
2070
+ if (parsed.hostname === api.hostname) return true;
2071
+ const lastTwo = (host) => {
2072
+ const parts = host.split(".").filter(Boolean);
2073
+ return parts.length >= 2 ? parts.slice(-2).join(".") : host;
2074
+ };
2075
+ const isIp = /^[0-9.]+$|^\[.*\]$/.test(parsed.hostname);
2076
+ if (isIp) return false;
2077
+ return lastTwo(parsed.hostname) === lastTwo(api.hostname);
2078
+ } catch {
2079
+ return false;
2080
+ }
2081
+ }
2082
+ function openBrowser(url) {
2083
+ let command;
2084
+ let args;
2085
+ if (process.platform === "darwin") {
2086
+ command = "open";
2087
+ args = [url];
2088
+ } else if (process.platform === "win32") {
2089
+ command = "cmd.exe";
2090
+ args = ["/c", "start", "", url];
2091
+ } else {
2092
+ command = "xdg-open";
2093
+ args = [url];
2094
+ }
2095
+ execFile(command, args, (_err) => {
2096
+ });
2097
+ }
2098
+ function registerOrgAuthHandler(apiClient, apiUrl, accessToken) {
2099
+ apiClient.setOrgAuthHandler(async (orgAuthInfo) => {
2100
+ try {
2101
+ const orgToken = await tryDirectJoin(apiUrl, accessToken, orgAuthInfo);
2102
+ if (orgToken !== null) {
2103
+ apiClient.setOrgToken(orgToken, orgAuthInfo.orgUuid);
2104
+ return;
2105
+ }
2106
+ } catch (err) {
2107
+ const msg = err instanceof Error ? err.message : String(err);
2108
+ stderr(`Warning: org direct-join failed (${msg}); trying browser auth`);
2109
+ }
2110
+ if (!isAllowedAuthUrl(orgAuthInfo.authUrl, apiUrl)) {
2111
+ throw new Error(
2112
+ `Refusing to open organization auth URL: scheme/host does not match the configured API host. Re-run with the expected --api-url, or contact support.`
2113
+ );
2114
+ }
2115
+ stderr(`
2116
+ This workspace requires organization SSO authentication.`);
2117
+ stderr(`Opening browser to complete authentication...`);
2118
+ stderr(` ${orgAuthInfo.authUrl}
2119
+ `);
2120
+ stderr(`If the browser does not open, visit the URL above manually.`);
2121
+ stderr(
2122
+ `After signing in, re-run the command \u2014 the CLI cannot receive the SSO token directly.`
2123
+ );
2124
+ openBrowser(orgAuthInfo.authUrl);
2125
+ await new Promise((_, reject) => {
2126
+ const t = setTimeout(
2127
+ () => reject(
2128
+ new Error(
2129
+ "Organization authentication timed out.\nPlease complete authentication in the browser, then re-run the command."
2130
+ )
2131
+ ),
2132
+ ORG_AUTH_TIMEOUT_MS
2133
+ );
2134
+ t.unref?.();
2135
+ });
2136
+ });
439
2137
  }
440
2138
 
441
2139
  // src/lib/context.ts
2140
+ function makeApiClient(accessToken, apiUrl) {
2141
+ const apiClient = new ApiClient(accessToken, apiUrl);
2142
+ registerOrgAuthHandler(apiClient, apiUrl, accessToken);
2143
+ return apiClient;
2144
+ }
442
2145
  async function tryTokenRefresh(ctx, creds) {
443
2146
  if (!creds.refreshToken) return null;
444
2147
  const refreshed = await refreshAccessToken(
@@ -448,7 +2151,7 @@ async function tryTokenRefresh(ctx, creds) {
448
2151
  ctx.env
449
2152
  );
450
2153
  if (!refreshed?.accessToken) return null;
451
- const apiClient = new GravityRailClient(refreshed.accessToken, ctx.envConfig.apiUrl);
2154
+ const apiClient = makeApiClient(refreshed.accessToken, ctx.envConfig.apiUrl);
452
2155
  return { ...ctx, accessToken: refreshed.accessToken, apiClient };
453
2156
  }
454
2157
  function createContext(opts) {
@@ -472,12 +2175,12 @@ async function createAuthenticatedContext(opts) {
472
2175
  devRealmsPath = loadDevCloudRealmFile(namespace);
473
2176
  }
474
2177
  const { token, workspaceUuid } = loadRealmCredentials(opts.realm, devRealmsPath);
475
- const apiClient = new GravityRailClient(token, ctx.envConfig.apiUrl);
2178
+ const apiClient = makeApiClient(token, ctx.envConfig.apiUrl);
476
2179
  return { ...ctx, accessToken: token, apiClient, realmWorkspace: workspaceUuid };
477
2180
  }
478
2181
  const apiKey = process.env.GRAVITY_RAIL_API_KEY;
479
2182
  if (apiKey) {
480
- const apiClient = new GravityRailClient(apiKey, ctx.envConfig.apiUrl);
2183
+ const apiClient = makeApiClient(apiKey, ctx.envConfig.apiUrl);
481
2184
  return { ...ctx, accessToken: apiKey, apiClient };
482
2185
  }
483
2186
  const creds = ctx.credentialsManager.load(ctx.env);
@@ -485,7 +2188,7 @@ async function createAuthenticatedContext(opts) {
485
2188
  const buffer = 5 * 60 * 1e3;
486
2189
  const notExpired = !creds.expiresAt || new Date(creds.expiresAt) > new Date(Date.now() + buffer);
487
2190
  if (notExpired) {
488
- const apiClient = new GravityRailClient(creds.accessToken, ctx.envConfig.apiUrl);
2191
+ const apiClient = makeApiClient(creds.accessToken, ctx.envConfig.apiUrl);
489
2192
  return { ...ctx, accessToken: creds.accessToken, apiClient };
490
2193
  }
491
2194
  const refreshed = await tryTokenRefresh(ctx, creds);
@@ -517,7 +2220,7 @@ async function createPublicAuthenticatedContext(opts) {
517
2220
  const ctx = createPublicContext(opts);
518
2221
  const apiKey = process.env.GRAVITY_RAIL_API_KEY;
519
2222
  if (apiKey) {
520
- const apiClient = new GravityRailClient(apiKey, ctx.envConfig.apiUrl);
2223
+ const apiClient = makeApiClient(apiKey, ctx.envConfig.apiUrl);
521
2224
  return { ...ctx, accessToken: apiKey, apiClient };
522
2225
  }
523
2226
  const creds = ctx.credentialsManager.load(ctx.env);
@@ -525,7 +2228,7 @@ async function createPublicAuthenticatedContext(opts) {
525
2228
  const buffer = 5 * 60 * 1e3;
526
2229
  const notExpired = !creds.expiresAt || new Date(creds.expiresAt) > new Date(Date.now() + buffer);
527
2230
  if (notExpired) {
528
- const apiClient = new GravityRailClient(creds.accessToken, ctx.envConfig.apiUrl);
2231
+ const apiClient = makeApiClient(creds.accessToken, ctx.envConfig.apiUrl);
529
2232
  return { ...ctx, accessToken: creds.accessToken, apiClient };
530
2233
  }
531
2234
  const refreshed = await tryTokenRefresh(ctx, creds);
@@ -1358,6 +3061,10 @@ var MESSAGE_COLUMNS2 = [
1358
3061
  getValue: (item) => String(item.content ?? "").slice(0, 80),
1359
3062
  maxWidth: 80
1360
3063
  },
3064
+ {
3065
+ header: "TOOL_CALLS",
3066
+ getValue: (item) => Array.isArray(item.tool_calls) && item.tool_calls.length > 0 ? item.tool_calls.map((t) => t.function?.name ?? "?").join(",") : ""
3067
+ },
1361
3068
  COL.created()
1362
3069
  ];
1363
3070
  var chatsDomain = {
@@ -1391,13 +3098,35 @@ var chatsDomain = {
1391
3098
  // Messages
1392
3099
  {
1393
3100
  path: ["chats", "messages", "list"],
1394
- description: "List messages for a chat",
3101
+ description: "List messages for a chat. Use --limit/--offset to page; the API caps a single request at 100. Tool-call shell rows that the API filter excludes (parent_message_id IS NOT NULL or parent_call_id IS NOT NULL) are still hidden \u2014 use `gr chats inspect --id <chat>` for the full debug view.",
1395
3102
  requiresWorkspace: true,
1396
- args: [{ name: "chat-id", description: "Chat ID", required: true }],
3103
+ args: [
3104
+ { name: "chat-id", description: "Chat ID", required: true },
3105
+ {
3106
+ name: "limit",
3107
+ description: "Max messages to return (1-100, default 100)"
3108
+ },
3109
+ {
3110
+ name: "offset",
3111
+ description: "Offset for pagination (default 0)"
3112
+ }
3113
+ ],
1397
3114
  handler: async ({ ctx, workspace, args }) => {
3115
+ const rawLimit = args.limit;
3116
+ const rawOffset = args.offset;
3117
+ const limit = rawLimit === void 0 || rawLimit === null || rawLimit === "" ? 100 : Number(rawLimit);
3118
+ const offset = rawOffset === void 0 || rawOffset === null || rawOffset === "" ? 0 : Number(rawOffset);
3119
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
3120
+ throw new Error("--limit must be an integer between 1 and 100");
3121
+ }
3122
+ if (!Number.isInteger(offset) || offset < 0) {
3123
+ throw new Error("--offset must be a non-negative integer");
3124
+ }
1398
3125
  const result = await requireAuth(ctx).apiClient.getChatMessages(
1399
3126
  workspace,
1400
- requireNumber(args, "chat-id")
3127
+ requireNumber(args, "chat-id"),
3128
+ limit,
3129
+ offset
1401
3130
  );
1402
3131
  outputData(result, ctx, MESSAGE_COLUMNS2);
1403
3132
  }
@@ -3495,8 +5224,8 @@ var dataTypesDomain = {
3495
5224
  var RULE_COLUMNS = [
3496
5225
  COL.id(),
3497
5226
  COL.name(),
3498
- { header: "EVENT", getValue: (item) => item.event_type ?? "" },
3499
- COL.enabled()
5227
+ { header: "EVENT", getValue: (item) => item.eventType ?? "" },
5228
+ { header: "ACTIVE", getValue: (item) => String(item.active ?? "") }
3500
5229
  ];
3501
5230
  var EVENT_COLUMNS2 = [
3502
5231
  COL.id(),
@@ -3504,10 +5233,9 @@ var EVENT_COLUMNS2 = [
3504
5233
  { header: "SLUG", getValue: (item) => item.slug ?? "" },
3505
5234
  COL.status()
3506
5235
  ];
3507
- var eventRulesCrud = crudCommands({
5236
+ var eventRulesCrudNoList = crudCommands({
3508
5237
  prefix: ["events", "rules"],
3509
5238
  entityName: "event rule",
3510
- listMethod: "getEventRules",
3511
5239
  getMethod: "getEventRule",
3512
5240
  createMethod: "createEventRule",
3513
5241
  updateMethod: "updateEventRule",
@@ -3530,6 +5258,57 @@ var eventRulesCrud = crudCommands({
3530
5258
  'member:label actionParams: {"addLabelIds":["uuid"],"removeLabelIds":["uuid"]}'
3531
5259
  ]
3532
5260
  });
5261
+ var eventRulesListCmd = {
5262
+ path: ["events", "rules", "list"],
5263
+ description: "List event rules (use --journey-step-id or --event-type to filter)",
5264
+ requiresWorkspace: true,
5265
+ columns: RULE_COLUMNS,
5266
+ args: [
5267
+ { name: "journey-step-id", description: "Filter by journey step ID" },
5268
+ { name: "event-type", description: "Filter by event type (e.g. journey_step:execute)" },
5269
+ { name: "object-type", description: "Filter by object type (e.g. journey, task)" },
5270
+ { name: "include-disabled", description: "Include inactive rules", isFlag: true },
5271
+ { name: "page", description: "Page number (without filters)" },
5272
+ { name: "page-size", description: "Page size (without filters)" },
5273
+ {
5274
+ name: "all",
5275
+ description: "Fetch all pages (without filters)",
5276
+ isFlag: true
5277
+ }
5278
+ ],
5279
+ handler: async ({ ctx, workspace, args }) => {
5280
+ const client = requireAuth(ctx).apiClient;
5281
+ const journeyStepId = args["journey-step-id"] ? requireNumber(args, "journey-step-id") : void 0;
5282
+ const eventType = args["event-type"];
5283
+ const objectType = args["object-type"];
5284
+ const includeDisabled = args["include-disabled"] === true;
5285
+ if (journeyStepId !== void 0 || eventType !== void 0 || objectType !== void 0 || includeDisabled) {
5286
+ const result2 = await client.searchEventRules(workspace, {
5287
+ ...journeyStepId !== void 0 ? { journeyStepId } : {},
5288
+ ...eventType ? { eventType } : {},
5289
+ ...objectType ? { objectType } : {},
5290
+ ...includeDisabled ? { includeDisabled: true } : {}
5291
+ });
5292
+ outputData(listResult(result2, false), ctx, RULE_COLUMNS);
5293
+ return;
5294
+ }
5295
+ if (args["all"]) {
5296
+ const allItems = await fetchAllPages(
5297
+ async ({ page: page2, pageSize: pageSize2 }) => client.getEventRules(workspace, { page: page2, pageSize: pageSize2 })
5298
+ );
5299
+ outputData(allItems, ctx, RULE_COLUMNS);
5300
+ return;
5301
+ }
5302
+ const page = args["page"] ? requireNumber(args, "page") : void 0;
5303
+ const pageSize = args["page-size"] ? requireNumber(args, "page-size") : void 0;
5304
+ const result = await client.getEventRules(workspace, {
5305
+ ...page !== void 0 ? { page } : {},
5306
+ ...pageSize !== void 0 ? { pageSize } : {}
5307
+ });
5308
+ outputData(listResult(result, true), ctx, RULE_COLUMNS);
5309
+ }
5310
+ };
5311
+ var eventRulesCrud = [eventRulesListCmd, ...eventRulesCrudNoList];
3533
5312
  var eventRulesAliases = eventRulesCrud.filter((cmd) => {
3534
5313
  const verb = cmd.path[cmd.path.length - 1];
3535
5314
  return verb === "list" || verb === "get";
@@ -3559,6 +5338,48 @@ var eventsDomain = {
3559
5338
  outputData(result, ctx);
3560
5339
  }
3561
5340
  },
5341
+ {
5342
+ // The /event-rules/search endpoint returns an unpaginated list — the
5343
+ // server applies the filters and returns whatever matches. No --all
5344
+ // flag is needed; if the result becomes too large in practice,
5345
+ // tighten the filter rather than paginate.
5346
+ path: ["events", "rules", "search"],
5347
+ description: "Search event rules by object/event/action type or related entity ID",
5348
+ requiresWorkspace: true,
5349
+ args: [
5350
+ {
5351
+ name: "object-type",
5352
+ description: "Filter by object type (task, routine, journey, workflow, calendar, ...)"
5353
+ },
5354
+ { name: "event-type", description: "Filter by event type" },
5355
+ { name: "action-type", description: "Filter by action type" },
5356
+ { name: "task-id", description: "Filter by task ID" },
5357
+ { name: "data-type-id", description: "Filter by data type ID" },
5358
+ { name: "routine-id", description: "Filter by routine ID" },
5359
+ { name: "workflow-id", description: "Filter by workflow ID" },
5360
+ { name: "journey-step-id", description: "Filter by journey step ID" },
5361
+ {
5362
+ name: "include-disabled",
5363
+ description: "Include inactive rules (default: active only)"
5364
+ }
5365
+ ],
5366
+ columns: RULE_COLUMNS,
5367
+ handler: async ({ ctx, workspace, args }) => {
5368
+ const opts = {};
5369
+ if (args["object-type"]) opts.objectType = args["object-type"];
5370
+ if (args["event-type"]) opts.eventType = args["event-type"];
5371
+ if (args["action-type"]) opts.actionType = args["action-type"];
5372
+ if (args["task-id"]) opts.taskId = requireNumber(args, "task-id");
5373
+ if (args["data-type-id"]) opts.dataTypeId = requireNumber(args, "data-type-id");
5374
+ if (args["routine-id"]) opts.routineId = requireNumber(args, "routine-id");
5375
+ if (args["workflow-id"]) opts.workflowId = requireNumber(args, "workflow-id");
5376
+ if (args["journey-step-id"])
5377
+ opts.journeyStepId = requireNumber(args, "journey-step-id");
5378
+ if (args["include-disabled"]) opts.includeDisabled = true;
5379
+ const result = await requireAuth(ctx).apiClient.searchEventRules(workspace, opts);
5380
+ outputData(result, ctx, RULE_COLUMNS);
5381
+ }
5382
+ },
3562
5383
  // Routines
3563
5384
  ...crudCommands({
3564
5385
  prefix: ["routines"],
@@ -3697,6 +5518,7 @@ var filesDomain = {
3697
5518
  };
3698
5519
 
3699
5520
  // src/domains/journeys.ts
5521
+ import { EventRuleEventType } from "@gravity-rail/sdk";
3700
5522
  var JOURNEY_COLUMNS = [
3701
5523
  COL.id(),
3702
5524
  { header: "UUID", getValue: (item) => (item.uuid ?? "").slice(0, 8) },
@@ -3760,6 +5582,15 @@ var NOTE_COLUMNS2 = [
3760
5582
  { header: "CONTENT", getValue: (item) => (item.contents ?? "").slice(0, 60) },
3761
5583
  { header: "CREATED", getValue: (item) => item.createdAt ?? "" }
3762
5584
  ];
5585
+ var ACTION_COLUMNS = [
5586
+ COL.id(),
5587
+ { header: "UUID", getValue: (item) => (item.uuid ?? "").slice(0, 8) },
5588
+ COL.name(),
5589
+ { header: "EVENT", getValue: (item) => item.eventType ?? "" },
5590
+ { header: "ACTION", getValue: (item) => item.actionType ?? "" },
5591
+ { header: "ACTIVE", getValue: (item) => String(item.active ?? "") },
5592
+ { header: "CONDITIONS", getValue: (item) => (item.conditions ?? "").slice(0, 40) }
5593
+ ];
3763
5594
  function baseUrl(ctx, wid) {
3764
5595
  return `${ctx.envConfig.apiUrl}/api/v2/w/${wid}/journeys`;
3765
5596
  }
@@ -4474,6 +6305,70 @@ var journeysDomain = {
4474
6305
  process.stdout.write(`Deleted note ${noteId}
4475
6306
  `);
4476
6307
  }
6308
+ },
6309
+ // ── Step execute actions (event rules scoped to a step) ────────
6310
+ {
6311
+ path: ["journeys", "steps", "actions", "list"],
6312
+ description: "List event rules (actions) attached to a journey step",
6313
+ requiresWorkspace: true,
6314
+ args: [
6315
+ { name: "step-id", description: "Journey step ID (numeric)", required: true },
6316
+ {
6317
+ name: "include-disabled",
6318
+ description: "Include inactive/disabled rules",
6319
+ isFlag: true
6320
+ }
6321
+ ],
6322
+ examples: [
6323
+ "gr journeys steps actions list -w $WID --step-id <step-id>",
6324
+ "gr journeys steps actions list -w $WID --step-id <step-id> --include-disabled"
6325
+ ],
6326
+ handler: async ({ ctx, workspace, args }) => {
6327
+ const stepId = requireNumber(args, "step-id");
6328
+ const includeDisabled = args["include-disabled"] === true;
6329
+ const result = await requireAuth(ctx).apiClient.searchEventRules(workspace, {
6330
+ eventType: EventRuleEventType.JOURNEY_STEP_EXECUTE,
6331
+ journeyStepId: stepId,
6332
+ ...includeDisabled ? { includeDisabled: true } : {}
6333
+ });
6334
+ outputData(listResult(result, false), ctx, ACTION_COLUMNS);
6335
+ }
6336
+ },
6337
+ {
6338
+ path: ["journeys", "steps", "actions", "get"],
6339
+ description: "Get a journey step action (event rule) by ID",
6340
+ requiresWorkspace: true,
6341
+ args: [{ name: "id", description: "Event rule ID", required: true }],
6342
+ examples: ["gr journeys steps actions get -w $WID --id <rule-id>"],
6343
+ handler: async ({ ctx, workspace, args }) => {
6344
+ const id = requireNumber(args, "id");
6345
+ const result = await requireAuth(ctx).apiClient.getEventRule(workspace, id);
6346
+ outputSingle(result, ctx, ACTION_COLUMNS);
6347
+ }
6348
+ },
6349
+ {
6350
+ path: ["journeys", "steps", "actions", "update"],
6351
+ description: "Update a journey step action \u2014 modify template, conditions, or active state",
6352
+ mutates: true,
6353
+ requiresWorkspace: true,
6354
+ args: [{ name: "id", description: "Event rule ID", required: true }],
6355
+ examples: [
6356
+ "gr journeys steps actions update -w $WID --id <rule-id> \\",
6357
+ ` --data '{"actionParams":{"messageTemplate":"Hello {{member.name}}"}}' --allow-write`,
6358
+ "",
6359
+ "Updatable fields: name, conditions (CEL), actionParams, active, delay, order",
6360
+ "Non-updatable: objectType, eventType, actionType, journeyStepId"
6361
+ ],
6362
+ handler: async ({ ctx, workspace, args, data }) => {
6363
+ if (!data) throw new CLIError("JSON data required (--data, --file, or stdin)");
6364
+ const id = requireNumber(args, "id");
6365
+ const result = await requireAuth(ctx).apiClient.updateEventRule(
6366
+ workspace,
6367
+ id,
6368
+ data
6369
+ );
6370
+ outputSingle(result, ctx, ACTION_COLUMNS);
6371
+ }
4477
6372
  }
4478
6373
  ]
4479
6374
  };
@@ -5099,6 +6994,13 @@ var COLUMNS16 = [
5099
6994
  { header: "PREFIX", getValue: (item) => item.prefix ?? "" },
5100
6995
  COL.created()
5101
6996
  ];
6997
+ var CREATE_COLUMNS = [
6998
+ COL.id(),
6999
+ COL.name(),
7000
+ { header: "KEY", getValue: (item) => item.key ?? "" },
7001
+ { header: "PREFIX", getValue: (item) => item.prefix ?? "" },
7002
+ COL.created()
7003
+ ];
5102
7004
  var apiKeysDomain = {
5103
7005
  name: "api-keys",
5104
7006
  description: "Manage API keys",
@@ -5119,7 +7021,10 @@ var apiKeysDomain = {
5119
7021
  requiresWorkspace: true,
5120
7022
  handler: async ({ ctx, workspace, data }) => {
5121
7023
  const result = await requireAuth(ctx).apiClient.createApiKey(workspace, data);
5122
- outputSingle(result, ctx, COLUMNS16);
7024
+ outputSingle(result, ctx, CREATE_COLUMNS);
7025
+ if (ctx.outputFormat === "table") {
7026
+ process.stdout.write("\n\u26A0 This key will not be shown again. Copy it now.\n");
7027
+ }
5123
7028
  }
5124
7029
  },
5125
7030
  {
@@ -5151,7 +7056,10 @@ var apiKeysDomain = {
5151
7056
  requiresWorkspace: false,
5152
7057
  handler: async ({ ctx, data }) => {
5153
7058
  const result = await requireAuth(ctx).apiClient.createGlobalApiKey(data);
5154
- outputSingle(result, ctx, COLUMNS16);
7059
+ outputSingle(result, ctx, CREATE_COLUMNS);
7060
+ if (ctx.outputFormat === "table") {
7061
+ process.stdout.write("\n\u26A0 This key will not be shown again. Copy it now.\n");
7062
+ }
5155
7063
  }
5156
7064
  },
5157
7065
  {
@@ -5963,8 +7871,9 @@ var mcpServersDomain = {
5963
7871
  // src/domains/member-memories.ts
5964
7872
  var COLUMNS21 = [
5965
7873
  { header: "KEY", getValue: (item) => item.key ?? "" },
5966
- { header: "STRATEGY", getValue: (item) => item.strategy ?? "" },
5967
- { header: "CONTENT", getValue: (item) => truncate(item.content ?? "", 80) },
7874
+ { header: "TYPE", getValue: (item) => item.type ?? "basic" },
7875
+ { header: "DESCRIPTION", getValue: (item) => truncate(item.description ?? "", 60) },
7876
+ { header: "PRIORITY", getValue: (item) => item.priority ?? 0 },
5968
7877
  { header: "UPDATED", getValue: (item) => item.updatedAt ?? item.createdAt ?? "" }
5969
7878
  ];
5970
7879
  function truncate(s, max) {
@@ -5972,7 +7881,7 @@ function truncate(s, max) {
5972
7881
  }
5973
7882
  var memberMemoriesDomain = {
5974
7883
  name: "member-memories",
5975
- description: "Manage member long-term memories",
7884
+ description: "Manage member persistent memories",
5976
7885
  commands: [
5977
7886
  {
5978
7887
  path: ["member-memories", "list"],
@@ -5981,38 +7890,18 @@ var memberMemoriesDomain = {
5981
7890
  args: [
5982
7891
  { name: "member-id", description: "Member ID", required: true },
5983
7892
  {
5984
- name: "strategy",
5985
- description: "Filter by strategy (preferences, semantic, summaries, episodic)"
5986
- }
5987
- ],
5988
- handler: async ({ ctx, workspace, args }) => {
5989
- const memberId = requireNumber(args, "member-id");
5990
- const strategy = args.strategy;
5991
- const result = await requireAuth(ctx).apiClient.getMemberMemories(workspace, memberId, {
5992
- strategy
5993
- });
5994
- outputData(listResult(result, false), ctx, COLUMNS21);
5995
- }
5996
- },
5997
- {
5998
- path: ["member-memories", "search"],
5999
- description: "Search memories for a member by query",
6000
- requiresWorkspace: true,
6001
- args: [
6002
- { name: "member-id", description: "Member ID", required: true },
6003
- { name: "query", description: "Search query", required: true },
6004
- {
6005
- name: "strategy",
6006
- description: "Filter by strategy (preferences, semantic, summaries, episodic)"
6007
- }
7893
+ name: "type",
7894
+ description: "Memory type filter (basic, preferences, semantic, summaries, episodic, all)"
7895
+ },
7896
+ { name: "query", description: "Semantic search query (for AgentCore memory types)" }
6008
7897
  ],
6009
7898
  handler: async ({ ctx, workspace, args }) => {
6010
7899
  const memberId = requireNumber(args, "member-id");
6011
- const query = requireString(args, "query");
6012
- const strategy = args.strategy;
7900
+ const type = args.type;
7901
+ const query = args.query;
6013
7902
  const result = await requireAuth(ctx).apiClient.getMemberMemories(workspace, memberId, {
6014
- query,
6015
- strategy
7903
+ type,
7904
+ query
6016
7905
  });
6017
7906
  outputData(listResult(result, false), ctx, COLUMNS21);
6018
7907
  }
@@ -6025,17 +7914,20 @@ var memberMemoriesDomain = {
6025
7914
  args: [
6026
7915
  { name: "member-id", description: "Member ID", required: true },
6027
7916
  { name: "key", description: "Memory key", required: true },
6028
- { name: "strategy", description: "Memory strategy", required: true }
7917
+ {
7918
+ name: "type",
7919
+ description: "Memory type (basic, preferences, semantic, summaries, episodic)"
7920
+ }
6029
7921
  ],
6030
7922
  handler: async ({ ctx, workspace, args }) => {
6031
7923
  const memberId = requireNumber(args, "member-id");
6032
7924
  const key = requireString(args, "key");
6033
- const strategy = requireString(args, "strategy");
7925
+ const type = args.type;
6034
7926
  await requireAuth(ctx).apiClient.deleteMemberMemory(
6035
7927
  workspace,
6036
7928
  memberId,
6037
7929
  key,
6038
- strategy
7930
+ type ? { type } : void 0
6039
7931
  );
6040
7932
  process.stdout.write(`Deleted memory ${key}
6041
7933
  `);
@@ -6073,7 +7965,7 @@ var milestonesDomain = {
6073
7965
  var COLUMNS23 = [
6074
7966
  COL.id(),
6075
7967
  COL.name(),
6076
- { header: "TYPE", getValue: (item) => item.type ?? "" },
7968
+ { header: "TYPE", getValue: (item) => item.noticeType ?? "" },
6077
7969
  COL.enabled()
6078
7970
  ];
6079
7971
  var notificationRulesDomain = {
@@ -6179,55 +8071,381 @@ var operatorGroupsDomain = {
6179
8071
  );
6180
8072
  outputSingle(result, ctx);
6181
8073
  }
6182
- },
6183
- {
6184
- path: ["operator-groups", "remove-member"],
6185
- description: "Remove a member from an operator group",
6186
- mutates: true,
6187
- requiresWorkspace: true,
6188
- args: [
6189
- { name: "id", description: "Operator group ID", required: true },
6190
- { name: "member-id", description: "Member ID to remove", required: true }
6191
- ],
6192
- handler: async ({ ctx, workspace, args }) => {
6193
- await requireAuth(ctx).apiClient.removeGroupMember(
6194
- workspace,
6195
- requireNumber(args, "id"),
6196
- requireNumber(args, "member-id")
8074
+ },
8075
+ {
8076
+ path: ["operator-groups", "remove-member"],
8077
+ description: "Remove a member from an operator group",
8078
+ mutates: true,
8079
+ requiresWorkspace: true,
8080
+ args: [
8081
+ { name: "id", description: "Operator group ID", required: true },
8082
+ { name: "member-id", description: "Member ID to remove", required: true }
8083
+ ],
8084
+ handler: async ({ ctx, workspace, args }) => {
8085
+ await requireAuth(ctx).apiClient.removeGroupMember(
8086
+ workspace,
8087
+ requireNumber(args, "id"),
8088
+ requireNumber(args, "member-id")
8089
+ );
8090
+ process.stdout.write("Member removed from group\n");
8091
+ }
8092
+ },
8093
+ {
8094
+ path: ["operator-groups", "live"],
8095
+ description: "List live operators",
8096
+ requiresWorkspace: true,
8097
+ handler: async ({ ctx, workspace }) => {
8098
+ const result = await requireAuth(ctx).apiClient.getLiveOperators(workspace);
8099
+ outputData(result, ctx);
8100
+ }
8101
+ },
8102
+ {
8103
+ path: ["operator-groups", "presence"],
8104
+ description: "Get presence status",
8105
+ requiresWorkspace: true,
8106
+ handler: async ({ ctx, workspace }) => {
8107
+ const result = await requireAuth(ctx).apiClient.getPresenceStatus(workspace);
8108
+ outputSingle(result, ctx);
8109
+ }
8110
+ }
8111
+ ]
8112
+ };
8113
+
8114
+ // src/domains/org.ts
8115
+ var ORG_COLUMNS = [
8116
+ { header: "ID", getValue: (item) => String(item.organizationId ?? "") },
8117
+ { header: "NAME", getValue: (item) => item.organizationName || "" },
8118
+ { header: "ROLE", getValue: (item) => item.role || "" }
8119
+ ];
8120
+ var ORG_DOMAIN_COLUMNS = [
8121
+ { header: "UUID", getValue: (item) => item.uuid ?? "" },
8122
+ { header: "DOMAIN", getValue: (item) => item.domain ?? "" },
8123
+ { header: "OWNERSHIP", getValue: (item) => item.ownershipStatus ?? "" },
8124
+ { header: "EMAIL", getValue: (item) => item.emailStatus ?? "-" },
8125
+ { header: "SITE", getValue: (item) => item.siteStatus ?? "-" },
8126
+ { header: "TXT HOST", getValue: (item) => item.ownershipDnsRecord?.host ?? "" },
8127
+ {
8128
+ header: "TXT VALUE",
8129
+ getValue: (item) => item.ownershipDnsRecord?.value ?? "",
8130
+ maxWidth: 80
8131
+ }
8132
+ ];
8133
+ function requireOrgId(args) {
8134
+ const val = args["org-uuid"] ?? args.org;
8135
+ if (typeof val !== "string" || !val) {
8136
+ throw new CLIError("Missing required argument: --org-uuid");
8137
+ }
8138
+ return val;
8139
+ }
8140
+ function requireDomainUuid(args) {
8141
+ const val = args["domain-uuid"] ?? args.uuid;
8142
+ if (typeof val !== "string" || !val) {
8143
+ throw new CLIError("Missing required argument: --domain-uuid");
8144
+ }
8145
+ return val;
8146
+ }
8147
+ function requireDomain(args) {
8148
+ const val = args.domain;
8149
+ if (typeof val !== "string" || !val) {
8150
+ throw new CLIError("Missing required argument: --domain");
8151
+ }
8152
+ return val;
8153
+ }
8154
+ var ORG_UUID_ARG = {
8155
+ name: "org-uuid",
8156
+ aliases: ["org"],
8157
+ description: "Organization UUID or ID",
8158
+ required: true
8159
+ };
8160
+ var DOMAIN_UUID_ARG = {
8161
+ name: "domain-uuid",
8162
+ aliases: ["domain-id"],
8163
+ description: "OrgDomain UUID",
8164
+ required: true
8165
+ };
8166
+ function pluralize(count, singular, plural = `${singular}s`) {
8167
+ return count === 1 ? singular : plural;
8168
+ }
8169
+ function emailVerifyCommand(path, description) {
8170
+ return {
8171
+ path,
8172
+ description,
8173
+ mutates: true,
8174
+ requiresWorkspace: false,
8175
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8176
+ examples: [
8177
+ `yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write`
8178
+ ],
8179
+ handler: async (hctx) => {
8180
+ const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainEmail(
8181
+ requireOrgId(hctx.args),
8182
+ requireDomainUuid(hctx.args)
8183
+ );
8184
+ outputSingle(result, hctx.ctx);
8185
+ }
8186
+ };
8187
+ }
8188
+ function siteVerifyCommand(path, description) {
8189
+ return {
8190
+ path,
8191
+ description,
8192
+ mutates: true,
8193
+ requiresWorkspace: false,
8194
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8195
+ examples: [
8196
+ `yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write`
8197
+ ],
8198
+ handler: async (hctx) => {
8199
+ const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainSite(
8200
+ requireOrgId(hctx.args),
8201
+ requireDomainUuid(hctx.args)
8202
+ );
8203
+ outputSingle(result, hctx.ctx);
8204
+ }
8205
+ };
8206
+ }
8207
+ function registerDomainCommand(path) {
8208
+ return {
8209
+ path,
8210
+ description: "Register an organization domain and return ownership TXT instructions",
8211
+ mutates: true,
8212
+ requiresWorkspace: false,
8213
+ args: [
8214
+ ORG_UUID_ARG,
8215
+ { name: "domain", description: "Domain to register, e.g. example.com", required: true }
8216
+ ],
8217
+ examples: [
8218
+ `yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain example.com --allow-write`
8219
+ ],
8220
+ handler: async (hctx) => {
8221
+ const result = await requireAuth(hctx.ctx).apiClient.registerOrgDomain(
8222
+ requireOrgId(hctx.args),
8223
+ requireDomain(hctx.args)
8224
+ );
8225
+ outputSingle(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
8226
+ }
8227
+ };
8228
+ }
8229
+ var domainCommands = [
8230
+ {
8231
+ path: ["org", "domains", "list"],
8232
+ description: "List domains registered to an organization",
8233
+ requiresWorkspace: false,
8234
+ args: [ORG_UUID_ARG],
8235
+ examples: ["yarn gr org domains list --org-uuid $ORG_UUID"],
8236
+ handler: async (hctx) => {
8237
+ const result = await requireAuth(hctx.ctx).apiClient.listOrgDomains(
8238
+ requireOrgId(hctx.args)
8239
+ );
8240
+ outputData(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
8241
+ }
8242
+ },
8243
+ {
8244
+ path: ["org", "domains", "get"],
8245
+ description: "Get a registered organization domain",
8246
+ requiresWorkspace: false,
8247
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8248
+ examples: ["yarn gr org domains get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
8249
+ handler: async (hctx) => {
8250
+ const result = await requireAuth(hctx.ctx).apiClient.getOrgDomain(
8251
+ requireOrgId(hctx.args),
8252
+ requireDomainUuid(hctx.args)
8253
+ );
8254
+ outputSingle(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
8255
+ }
8256
+ },
8257
+ registerDomainCommand(["org", "domains", "register"]),
8258
+ registerDomainCommand(["org", "domains", "create"]),
8259
+ {
8260
+ path: ["org", "domains", "verify-ownership"],
8261
+ description: "Verify domain ownership by checking the _gravity-verify TXT record",
8262
+ mutates: true,
8263
+ requiresWorkspace: false,
8264
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8265
+ examples: [
8266
+ "yarn gr org domains verify-ownership --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
8267
+ ],
8268
+ handler: async (hctx) => {
8269
+ const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainOwnership(
8270
+ requireOrgId(hctx.args),
8271
+ requireDomainUuid(hctx.args)
8272
+ );
8273
+ outputSingle(result, hctx.ctx);
8274
+ }
8275
+ },
8276
+ {
8277
+ path: ["org", "domains", "delete"],
8278
+ description: "Delete a registered organization domain",
8279
+ mutates: true,
8280
+ requiresWorkspace: false,
8281
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8282
+ examples: [
8283
+ "yarn gr org domains delete --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
8284
+ ],
8285
+ handler: async (hctx) => {
8286
+ const domainUuid = requireDomainUuid(hctx.args);
8287
+ await requireAuth(hctx.ctx).apiClient.deleteOrgDomain(requireOrgId(hctx.args), domainUuid);
8288
+ process.stdout.write(`Deleted org domain ${domainUuid}
8289
+ `);
8290
+ }
8291
+ },
8292
+ {
8293
+ path: ["org", "domains", "email", "enable"],
8294
+ description: "Enable email DNS records on a verified organization domain",
8295
+ mutates: true,
8296
+ requiresWorkspace: false,
8297
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8298
+ examples: [
8299
+ "yarn gr org domains email enable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
8300
+ ],
8301
+ handler: async (hctx) => {
8302
+ const result = await requireAuth(hctx.ctx).apiClient.enableOrgDomainEmail(
8303
+ requireOrgId(hctx.args),
8304
+ requireDomainUuid(hctx.args)
8305
+ );
8306
+ outputSingle(result, hctx.ctx);
8307
+ }
8308
+ },
8309
+ {
8310
+ path: ["org", "domains", "email", "get"],
8311
+ description: "Get email DNS setup and status for an organization domain",
8312
+ requiresWorkspace: false,
8313
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8314
+ examples: ["yarn gr org domains email get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
8315
+ handler: async (hctx) => {
8316
+ const result = await requireAuth(hctx.ctx).apiClient.getOrgDomainEmail(
8317
+ requireOrgId(hctx.args),
8318
+ requireDomainUuid(hctx.args)
8319
+ );
8320
+ outputSingle(result, hctx.ctx);
8321
+ }
8322
+ },
8323
+ emailVerifyCommand(
8324
+ ["org", "domains", "email", "verify"],
8325
+ "Verify email DNS records, including MX"
8326
+ ),
8327
+ emailVerifyCommand(
8328
+ ["org", "domains", "email", "verify-mx"],
8329
+ "Verify email DNS records, including MX"
8330
+ ),
8331
+ {
8332
+ path: ["org", "domains", "email", "disable"],
8333
+ description: "Disable email on an organization domain",
8334
+ mutates: true,
8335
+ requiresWorkspace: false,
8336
+ args: [
8337
+ ORG_UUID_ARG,
8338
+ DOMAIN_UUID_ARG,
8339
+ {
8340
+ name: "confirm",
8341
+ description: "Confirm removal of inbox routing that depends on this domain",
8342
+ isFlag: true
8343
+ }
8344
+ ],
8345
+ examples: [
8346
+ "yarn gr org domains email disable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --confirm --allow-write"
8347
+ ],
8348
+ handler: async (hctx) => {
8349
+ const domainUuid = requireDomainUuid(hctx.args);
8350
+ const result = await requireAuth(hctx.ctx).apiClient.disableOrgDomainEmail(
8351
+ requireOrgId(hctx.args),
8352
+ domainUuid,
8353
+ hctx.args.confirm === true
8354
+ );
8355
+ if (!result.ok) {
8356
+ const { inboxCount } = result.impact;
8357
+ throw new CLIError(
8358
+ `Email is still used by ${inboxCount} ${pluralize(
8359
+ inboxCount,
8360
+ "inbox",
8361
+ "inboxes"
8362
+ )}. Re-run with --confirm to disable it anyway.`
6197
8363
  );
6198
- process.stdout.write("Member removed from group\n");
6199
8364
  }
6200
- },
6201
- {
6202
- path: ["operator-groups", "live"],
6203
- description: "List live operators",
6204
- requiresWorkspace: true,
6205
- handler: async ({ ctx, workspace }) => {
6206
- const result = await requireAuth(ctx).apiClient.getLiveOperators(workspace);
6207
- outputData(result, ctx);
8365
+ process.stdout.write(`Disabled email for org domain ${domainUuid}
8366
+ `);
8367
+ }
8368
+ },
8369
+ {
8370
+ path: ["org", "domains", "site", "enable"],
8371
+ description: "Enable custom site CNAME verification on a verified organization domain",
8372
+ mutates: true,
8373
+ requiresWorkspace: false,
8374
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8375
+ examples: [
8376
+ "yarn gr org domains site enable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
8377
+ ],
8378
+ handler: async (hctx) => {
8379
+ const result = await requireAuth(hctx.ctx).apiClient.enableOrgDomainSite(
8380
+ requireOrgId(hctx.args),
8381
+ requireDomainUuid(hctx.args)
8382
+ );
8383
+ outputSingle(result, hctx.ctx);
8384
+ }
8385
+ },
8386
+ {
8387
+ path: ["org", "domains", "site", "get"],
8388
+ description: "Get custom site CNAME setup and status for an organization domain",
8389
+ requiresWorkspace: false,
8390
+ args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
8391
+ examples: ["yarn gr org domains site get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
8392
+ handler: async (hctx) => {
8393
+ const result = await requireAuth(hctx.ctx).apiClient.getOrgDomainSite(
8394
+ requireOrgId(hctx.args),
8395
+ requireDomainUuid(hctx.args)
8396
+ );
8397
+ outputSingle(result, hctx.ctx);
8398
+ }
8399
+ },
8400
+ siteVerifyCommand(
8401
+ ["org", "domains", "site", "verify"],
8402
+ "Verify the site CNAME points at Gravity Rail"
8403
+ ),
8404
+ siteVerifyCommand(
8405
+ ["org", "domains", "site", "verify-cname"],
8406
+ "Verify the site CNAME points at Gravity Rail"
8407
+ ),
8408
+ {
8409
+ path: ["org", "domains", "site", "disable"],
8410
+ description: "Disable custom site routing on an organization domain",
8411
+ mutates: true,
8412
+ requiresWorkspace: false,
8413
+ args: [
8414
+ ORG_UUID_ARG,
8415
+ DOMAIN_UUID_ARG,
8416
+ {
8417
+ name: "confirm",
8418
+ description: "Confirm removal of site mappings that depend on this domain",
8419
+ isFlag: true
6208
8420
  }
6209
- },
6210
- {
6211
- path: ["operator-groups", "presence"],
6212
- description: "Get presence status",
6213
- requiresWorkspace: true,
6214
- handler: async ({ ctx, workspace }) => {
6215
- const result = await requireAuth(ctx).apiClient.getPresenceStatus(workspace);
6216
- outputSingle(result, ctx);
8421
+ ],
8422
+ examples: [
8423
+ "yarn gr org domains site disable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --confirm --allow-write"
8424
+ ],
8425
+ handler: async (hctx) => {
8426
+ const domainUuid = requireDomainUuid(hctx.args);
8427
+ const result = await requireAuth(hctx.ctx).apiClient.disableOrgDomainSite(
8428
+ requireOrgId(hctx.args),
8429
+ domainUuid,
8430
+ hctx.args.confirm === true
8431
+ );
8432
+ if (!result.ok) {
8433
+ const { siteCount } = result.impact;
8434
+ throw new CLIError(
8435
+ `Site routing is still used by ${siteCount} ${pluralize(
8436
+ siteCount,
8437
+ "site"
8438
+ )}. Re-run with --confirm to disable it anyway.`
8439
+ );
6217
8440
  }
8441
+ process.stdout.write(`Disabled site routing for org domain ${domainUuid}
8442
+ `);
6218
8443
  }
6219
- ]
6220
- };
6221
-
6222
- // src/domains/org.ts
6223
- var ORG_COLUMNS = [
6224
- COL.id(),
6225
- COL.name(),
6226
- { header: "ROLE", getValue: (item) => item.role ?? "" }
8444
+ }
6227
8445
  ];
6228
8446
  var orgDomain = {
6229
8447
  name: "org",
6230
- description: "Organization membership",
8448
+ description: "Organization membership and domains",
6231
8449
  commands: [
6232
8450
  {
6233
8451
  path: ["org", "list"],
@@ -6237,7 +8455,8 @@ var orgDomain = {
6237
8455
  const result = await requireAuth(ctx).apiClient.getMyOrganizations();
6238
8456
  outputData(result, ctx, ORG_COLUMNS);
6239
8457
  }
6240
- }
8458
+ },
8459
+ ...domainCommands
6241
8460
  ]
6242
8461
  };
6243
8462
 
@@ -6765,20 +8984,20 @@ var promptsDomain = {
6765
8984
  "gr prompts inspect --chat-id 789 --turn 3"
6766
8985
  ],
6767
8986
  handler: async ({ ctx, workspace, args }) => {
6768
- const taskId = args["task-id"] ? requireNumber(args, "task-id") : void 0;
6769
- const chatId = args["chat-id"] ? requireNumber(args, "chat-id") : void 0;
6770
- if (!taskId && !chatId) {
8987
+ const taskId = args["task-id"] !== void 0 ? requireNumber(args, "task-id") : void 0;
8988
+ const chatId = args["chat-id"] !== void 0 ? requireNumber(args, "chat-id") : void 0;
8989
+ if (taskId === void 0 && chatId === void 0) {
6771
8990
  throw new Error("Provide --task-id or --chat-id");
6772
8991
  }
6773
- if (taskId && chatId) {
8992
+ if (taskId !== void 0 && chatId !== void 0) {
6774
8993
  throw new Error("Provide --task-id or --chat-id, not both");
6775
8994
  }
6776
8995
  const channel = args.channel || void 0;
6777
- const turn = args.turn ? requireNumber(args, "turn") : void 0;
6778
- const result = await requireAuth(ctx).apiClient.inspectPrompt(workspace, taskId ?? 0, {
6779
- channel,
6780
- ...chatId ? { chatId } : {},
6781
- ...turn ? { turn } : {}
8996
+ const turn = args.turn !== void 0 ? requireNumber(args, "turn") : void 0;
8997
+ const result = await requireAuth(ctx).apiClient.inspectPrompt(workspace, {
8998
+ ...taskId !== void 0 ? { taskId } : { chatId },
8999
+ ...channel ? { channel } : {},
9000
+ ...turn !== void 0 ? { turn } : {}
6782
9001
  });
6783
9002
  outputSingle(result, ctx);
6784
9003
  }
@@ -6786,6 +9005,128 @@ var promptsDomain = {
6786
9005
  ]
6787
9006
  };
6788
9007
 
9008
+ // src/domains/support.ts
9009
+ var SUPPORT_COLUMNS = [
9010
+ COL.uuid(),
9011
+ { header: "STATUS", getValue: (item) => item.status ?? "" },
9012
+ { header: "TYPE", getValue: (item) => item.supportRequestType ?? "" },
9013
+ { header: "SEVERITY", getValue: (item) => item.severity ?? "" },
9014
+ { header: "SOURCE", getValue: (item) => item.source ?? "" },
9015
+ { header: "CREATED", getValue: (item) => (item.createdAt ?? "").slice(0, 19) },
9016
+ { header: "TITLE", getValue: (item) => item.title ?? "" }
9017
+ ];
9018
+ var CONTEXT_ARGS = [
9019
+ { name: "workspace", aliases: ["w"], description: "Workspace UUID" },
9020
+ { name: "org-uuid", description: "Organization UUID" }
9021
+ ];
9022
+ function listParams(args) {
9023
+ return {
9024
+ page: args.page ? Number(args.page) : void 0,
9025
+ pageSize: args["page-size"] ? Number(args["page-size"]) : void 0,
9026
+ status: args.status,
9027
+ supportRequestType: args.type,
9028
+ severity: args.severity,
9029
+ source: args.source
9030
+ };
9031
+ }
9032
+ function requestPayload(data, args) {
9033
+ const input = data ?? {};
9034
+ return {
9035
+ supportRequestType: input.supportRequestType ?? input.support_request_type ?? args.type ?? "question",
9036
+ title: input.title ?? requireString(args, "title"),
9037
+ description: input.description ?? requireString(args, "description"),
9038
+ severity: input.severity ?? args.severity
9039
+ };
9040
+ }
9041
+ function commentPayload(data, args) {
9042
+ const input = data ?? {};
9043
+ return {
9044
+ body: input.body ?? requireString(args, "body")
9045
+ };
9046
+ }
9047
+ var supportDomain = {
9048
+ name: "support",
9049
+ description: "Manage support requests",
9050
+ commands: [
9051
+ {
9052
+ path: ["support", "list"],
9053
+ description: "List support requests",
9054
+ args: [
9055
+ ...CONTEXT_ARGS,
9056
+ { name: "status", description: "Filter by status" },
9057
+ { name: "type", description: "Filter by type: bug, feature_request, question" },
9058
+ { name: "severity", description: "Filter by severity" },
9059
+ { name: "source", description: "Filter by source" },
9060
+ { name: "page", description: "Page number" },
9061
+ { name: "page-size", description: "Page size" }
9062
+ ],
9063
+ columns: SUPPORT_COLUMNS,
9064
+ handler: async ({ ctx, args, workspace }) => {
9065
+ const client = requireAuth(ctx).apiClient;
9066
+ const wid = args.workspace ?? workspace;
9067
+ const orgUuid = args["org-uuid"];
9068
+ const result = wid ? await client.listWorkspaceSupportRequests(wid, listParams(args)) : orgUuid ? await client.listOrgSupportRequests(orgUuid, listParams(args)) : await client.listSupportRequests(listParams(args));
9069
+ outputData(result, ctx, SUPPORT_COLUMNS);
9070
+ }
9071
+ },
9072
+ {
9073
+ path: ["support", "get"],
9074
+ description: "Get a support request",
9075
+ args: [
9076
+ ...CONTEXT_ARGS,
9077
+ { name: "id", aliases: ["uuid"], description: "Support request UUID", required: true }
9078
+ ],
9079
+ handler: async ({ ctx, args, workspace }) => {
9080
+ const client = requireAuth(ctx).apiClient;
9081
+ const id = requireString(args, "id");
9082
+ const wid = args.workspace ?? workspace;
9083
+ const orgUuid = args["org-uuid"];
9084
+ const result = wid ? await client.getWorkspaceSupportRequest(wid, id) : orgUuid ? await client.getOrgSupportRequest(orgUuid, id) : await client.getSupportRequest(id);
9085
+ outputSingle(result, ctx, SUPPORT_COLUMNS);
9086
+ }
9087
+ },
9088
+ {
9089
+ path: ["support", "create"],
9090
+ description: "Create a support request",
9091
+ mutates: true,
9092
+ args: [
9093
+ ...CONTEXT_ARGS,
9094
+ { name: "type", description: "Request type: bug, feature_request, question" },
9095
+ { name: "title", description: "Support request title" },
9096
+ { name: "description", description: "Support request description" },
9097
+ { name: "severity", description: "Optional severity" }
9098
+ ],
9099
+ handler: async ({ ctx, args, workspace, data }) => {
9100
+ const client = requireAuth(ctx).apiClient;
9101
+ const wid = args.workspace ?? workspace;
9102
+ const orgUuid = args["org-uuid"];
9103
+ const payload = requestPayload(data, args);
9104
+ const result = wid ? await client.createWorkspaceSupportRequest(wid, payload) : orgUuid ? await client.createOrgSupportRequest(orgUuid, payload) : await client.createSupportRequest(payload);
9105
+ outputSingle(result, ctx, SUPPORT_COLUMNS);
9106
+ }
9107
+ },
9108
+ {
9109
+ path: ["support", "comment"],
9110
+ description: "Add a customer comment to a support request",
9111
+ mutates: true,
9112
+ args: [
9113
+ ...CONTEXT_ARGS,
9114
+ { name: "id", aliases: ["uuid"], description: "Support request UUID", required: true },
9115
+ { name: "body", description: "Comment body" }
9116
+ ],
9117
+ handler: async ({ ctx, args, workspace, data }) => {
9118
+ const client = requireAuth(ctx).apiClient;
9119
+ const id = requireString(args, "id");
9120
+ const wid = args.workspace ?? workspace;
9121
+ const orgUuid = args["org-uuid"];
9122
+ const payload = commentPayload(data, args);
9123
+ const result = wid ? await client.commentOnWorkspaceSupportRequest(wid, id, payload) : orgUuid ? await client.commentOnOrgSupportRequest(orgUuid, id, payload) : await client.commentOnSupportRequest(id, payload);
9124
+ outputSingle(result, ctx, SUPPORT_COLUMNS);
9125
+ }
9126
+ }
9127
+ ]
9128
+ };
9129
+
6789
9130
  // src/domains/supervisors.ts
6790
9131
  var COLUMNS28 = [
6791
9132
  COL.id(),
@@ -6902,6 +9243,10 @@ var syncDomain = {
6902
9243
  {
6903
9244
  name: "board-id",
6904
9245
  description: "Scope to a single board mapping (requires --entity-type)"
9246
+ },
9247
+ {
9248
+ name: "record-limit",
9249
+ description: "Cap the run to a preview sample (1..200). Requires --dry-run and --entity-type."
6905
9250
  }
6906
9251
  ],
6907
9252
  examples: [
@@ -6910,7 +9255,8 @@ var syncDomain = {
6910
9255
  "sync run --connection-id 6 --full-resync",
6911
9256
  "sync run --connection-id 6 --quiet",
6912
9257
  "sync run --connection-id 6 --entity-type member",
6913
- "sync run --connection-id 6 --entity-type member --board-id 18406694561"
9258
+ "sync run --connection-id 6 --entity-type member --board-id 18406694561",
9259
+ "sync run --connection-id 6 --dry-run --entity-type member --record-limit 20"
6914
9260
  ],
6915
9261
  mutates: true,
6916
9262
  handler: async ({ ctx, args, workspace }) => {
@@ -6930,12 +9276,39 @@ var syncDomain = {
6930
9276
  entityType = rawEntityType;
6931
9277
  }
6932
9278
  const boardId = args["board-id"];
9279
+ const rawRecordLimit = args["record-limit"];
9280
+ let recordLimit;
9281
+ if (rawRecordLimit !== void 0 && rawRecordLimit !== "") {
9282
+ const parsed = Number(rawRecordLimit);
9283
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > 200) {
9284
+ throw new CLIError(
9285
+ `Invalid --record-limit "${rawRecordLimit}". Must be an integer between 1 and 200.`
9286
+ );
9287
+ }
9288
+ if (!dryRun) {
9289
+ throw new CLIError(
9290
+ "--record-limit requires --dry-run: capped runs are preview-only."
9291
+ );
9292
+ }
9293
+ if (entityType === void 0) {
9294
+ throw new CLIError(
9295
+ "--record-limit requires --entity-type: capped previews must target a single entity type."
9296
+ );
9297
+ }
9298
+ recordLimit = parsed;
9299
+ }
9300
+ if (fullResync && (dryRun || recordLimit !== void 0)) {
9301
+ throw new CLIError(
9302
+ "--full-resync is incompatible with --dry-run / --record-limit: checkpoint reset must happen on a non-preview run."
9303
+ );
9304
+ }
6933
9305
  if (!quiet) {
6934
9306
  const flags = [
6935
9307
  dryRun && "(dry run)",
6936
9308
  fullResync && "(full re-sync)",
6937
9309
  entityType && `(${entityType} only)`,
6938
- boardId && `(board ${boardId})`
9310
+ boardId && `(board ${boardId})`,
9311
+ recordLimit !== void 0 && `(limit ${recordLimit})`
6939
9312
  ].filter(Boolean).join(" ");
6940
9313
  console.error(
6941
9314
  `Starting sync for connection ${connectionId}${flags ? ` ${flags}` : ""}...`
@@ -6948,7 +9321,8 @@ var syncDomain = {
6948
9321
  dryRun,
6949
9322
  resetCheckpoints: fullResync,
6950
9323
  entityType,
6951
- boardId
9324
+ boardId,
9325
+ recordLimit
6952
9326
  }
6953
9327
  );
6954
9328
  if (!response.ok) {
@@ -7142,6 +9516,31 @@ var appConnectionsDomain = {
7142
9516
  );
7143
9517
  outputSingle(result, ctx);
7144
9518
  }
9519
+ },
9520
+ {
9521
+ path: ["app-connections", "relink-member"],
9522
+ description: "Re-enable sync for a previously unlinked member by clearing the manual-unlink exclusion on this connection. Idempotent: returns cleared=false when no exclusion exists.",
9523
+ mutates: true,
9524
+ requiresWorkspace: true,
9525
+ args: [
9526
+ { name: "id", description: "Connection ID (numeric)", required: true },
9527
+ { name: "member-id", description: "Member ID (numeric)", required: true },
9528
+ {
9529
+ name: "board-id",
9530
+ description: "Optional Monday board ID. Required for Monday connections where exclusions are board-scoped; omit for single-scope connectors."
9531
+ }
9532
+ ],
9533
+ handler: async ({ ctx, workspace, args }) => {
9534
+ const boardIdRaw = args["board-id"];
9535
+ const options = boardIdRaw !== void 0 && boardIdRaw !== "" ? { boardId: String(boardIdRaw) } : void 0;
9536
+ const result = await requireAuth(ctx).apiClient.clearConnectionMemberExclusion(
9537
+ workspace,
9538
+ requireNumber(args, "id"),
9539
+ requireNumber(args, "member-id"),
9540
+ options
9541
+ );
9542
+ outputSingle(result, ctx);
9543
+ }
7145
9544
  }
7146
9545
  ]
7147
9546
  };
@@ -7834,49 +10233,6 @@ var mondayDomain = {
7834
10233
  outputData(result, ctx);
7835
10234
  }
7836
10235
  },
7837
- {
7838
- path: ["monday", "webhook-get"],
7839
- description: "Get a Monday.com webhook",
7840
- requiresWorkspace: true,
7841
- args: [
7842
- { name: "board-id", description: "Board ID", required: true },
7843
- { name: "id", description: "Webhook ID", required: true }
7844
- ],
7845
- handler: async ({ ctx, args, workspace }) => {
7846
- const result = await requireAuth(ctx).apiClient.getMondayWebhook(
7847
- workspace,
7848
- requireString(args, "board-id"),
7849
- requireString(args, "id")
7850
- );
7851
- outputSingle(result, ctx);
7852
- }
7853
- },
7854
- {
7855
- path: ["monday", "webhook-create"],
7856
- description: "Create a Monday.com webhook",
7857
- mutates: true,
7858
- requiresWorkspace: true,
7859
- handler: async ({ ctx, data, workspace }) => {
7860
- const result = await requireAuth(ctx).apiClient.createMondayWebhook(
7861
- workspace,
7862
- data
7863
- );
7864
- outputSingle(result, ctx);
7865
- }
7866
- },
7867
- {
7868
- path: ["monday", "webhook-delete"],
7869
- description: "Delete a Monday.com webhook",
7870
- mutates: true,
7871
- requiresWorkspace: true,
7872
- args: [{ name: "id", description: "Webhook ID", required: true }],
7873
- handler: async ({ ctx, args, workspace }) => {
7874
- const id = requireString(args, "id");
7875
- await requireAuth(ctx).apiClient.deleteMondayWebhook(workspace, id);
7876
- process.stdout.write(`Deleted Monday webhook ${id}
7877
- `);
7878
- }
7879
- },
7880
10236
  {
7881
10237
  path: ["monday", "user-info"],
7882
10238
  description: "Get current Monday.com user info",
@@ -8216,6 +10572,113 @@ var slackAppsDomain = {
8216
10572
  ]
8217
10573
  };
8218
10574
 
10575
+ // src/domains/integrations/teams-apps.ts
10576
+ var COLUMNS33 = [COL.id(), COL.name(), COL.status()];
10577
+ function addTeamsUrls(data, apiUrl, workspaceUuid) {
10578
+ const base = `${apiUrl}/api/v2/w/${workspaceUuid}/app-connections/teams`;
10579
+ return {
10580
+ ...data,
10581
+ _urls: {
10582
+ eventsEndpoint: `${base}/events`,
10583
+ oauthUserAuthorize: `${base}/oauth/user/authorize?app_id=${data.id ?? ""}`,
10584
+ oauthUserCallback: `${base}/oauth/user/callback`
10585
+ }
10586
+ };
10587
+ }
10588
+ var teamsAppsDomain = {
10589
+ name: "teams-apps",
10590
+ description: "Manage Microsoft Teams app integrations",
10591
+ commands: [
10592
+ ...crudCommands({
10593
+ prefix: ["teams-apps"],
10594
+ entityName: "Teams app",
10595
+ listMethod: "getTeamsApps",
10596
+ deleteMethod: "deleteTeamsApp",
10597
+ columns: COLUMNS33,
10598
+ paginationSupport: "full"
10599
+ }),
10600
+ {
10601
+ path: ["teams-apps", "get"],
10602
+ description: "Get a Teams app by ID",
10603
+ args: [{ name: "id", description: "Teams app ID", required: true }],
10604
+ requiresWorkspace: true,
10605
+ handler: async ({ ctx, workspace, args }) => {
10606
+ const result = await requireAuth(ctx).apiClient.getTeamsApp(
10607
+ workspace,
10608
+ requireNumber(args, "id")
10609
+ );
10610
+ outputSingle(addTeamsUrls(result, ctx.envConfig.apiUrl, workspace), ctx);
10611
+ }
10612
+ },
10613
+ {
10614
+ path: ["teams-apps", "create"],
10615
+ description: "Create a Teams app",
10616
+ mutates: true,
10617
+ requiresWorkspace: true,
10618
+ handler: async ({ ctx, workspace, data }) => {
10619
+ if (!data) throw new CLIError("JSON data required (--data, --file, or stdin)");
10620
+ const result = await requireAuth(ctx).apiClient.createTeamsApp(workspace, data);
10621
+ outputSingle(addTeamsUrls(result, ctx.envConfig.apiUrl, workspace), ctx);
10622
+ }
10623
+ },
10624
+ {
10625
+ path: ["teams-apps", "update"],
10626
+ description: "Update a Teams app",
10627
+ mutates: true,
10628
+ args: [{ name: "id", description: "Teams app ID", required: true }],
10629
+ requiresWorkspace: true,
10630
+ handler: async ({ ctx, workspace, args, data }) => {
10631
+ if (!data) throw new CLIError("JSON data required (--data, --file, or stdin)");
10632
+ const result = await requireAuth(ctx).apiClient.updateTeamsApp(
10633
+ workspace,
10634
+ requireNumber(args, "id"),
10635
+ data
10636
+ );
10637
+ outputSingle(addTeamsUrls(result, ctx.envConfig.apiUrl, workspace), ctx);
10638
+ }
10639
+ },
10640
+ {
10641
+ path: ["teams-apps", "conversations"],
10642
+ description: "List Teams conversations linked to chats",
10643
+ requiresWorkspace: true,
10644
+ args: [{ name: "id", description: "Teams app ID", required: true }],
10645
+ handler: async ({ ctx, workspace, args }) => {
10646
+ const result = await requireAuth(ctx).apiClient.getTeamsConversations(
10647
+ workspace,
10648
+ requireNumber(args, "id")
10649
+ );
10650
+ outputData(result, ctx);
10651
+ }
10652
+ },
10653
+ {
10654
+ path: ["teams-apps", "installations"],
10655
+ description: "List per-tenant Teams installations",
10656
+ requiresWorkspace: true,
10657
+ args: [{ name: "id", description: "Teams app ID", required: true }],
10658
+ handler: async ({ ctx, workspace, args }) => {
10659
+ const result = await requireAuth(ctx).apiClient.getTeamsInstallations(
10660
+ workspace,
10661
+ requireNumber(args, "id")
10662
+ );
10663
+ outputData(result, ctx);
10664
+ }
10665
+ },
10666
+ {
10667
+ path: ["teams-apps", "accounts"],
10668
+ description: "List linked Teams (Entra) accounts for this app",
10669
+ requiresWorkspace: true,
10670
+ args: [{ name: "id", description: "Teams app ID", required: true }],
10671
+ handler: async ({ ctx, workspace, args }) => {
10672
+ const result = await requireAuth(ctx).apiClient.getTeamsAppAccounts(
10673
+ workspace,
10674
+ requireNumber(args, "id")
10675
+ );
10676
+ outputData(result, ctx);
10677
+ }
10678
+ }
10679
+ ]
10680
+ };
10681
+
8219
10682
  // src/domains/index.ts
8220
10683
  function registerPublicDomains(registry) {
8221
10684
  registry.register(tasksDomain);
@@ -8247,6 +10710,7 @@ function registerPublicDomains(registry) {
8247
10710
  registry.register(mcpServersDomain);
8248
10711
  registry.register(apiKeysDomain);
8249
10712
  registry.register(subscriptionsDomain);
10713
+ registry.register(supportDomain);
8250
10714
  registry.register(reportsDomain);
8251
10715
  registry.register(aiModelsDomain);
8252
10716
  registry.register(featuresDomain);
@@ -8262,6 +10726,7 @@ function registerPublicDomains(registry) {
8262
10726
  registry.register(confluenceDomain);
8263
10727
  registry.register(discordBotsDomain);
8264
10728
  registry.register(slackAppsDomain);
10729
+ registry.register(teamsAppsDomain);
8265
10730
  registry.register(fhirConnectionsDomain);
8266
10731
  registry.register(appConnectionsDomain);
8267
10732
  registry.register(hubspotDomain);
@@ -8271,7 +10736,7 @@ function registerPublicDomains(registry) {
8271
10736
  }
8272
10737
 
8273
10738
  // src/commands/auth-browser.ts
8274
- import { execFile } from "child_process";
10739
+ import { execFile as execFile2 } from "child_process";
8275
10740
  async function authBrowserCommand(ctx, args) {
8276
10741
  const noOpen = Boolean(args["no-open"]);
8277
10742
  const account = await ctx.apiClient.getUserAccount();
@@ -8307,7 +10772,7 @@ function openUrl(url) {
8307
10772
  command = "xdg-open";
8308
10773
  args = [url];
8309
10774
  }
8310
- execFile(command, args, (err) => {
10775
+ execFile2(command, args, (err) => {
8311
10776
  if (err) {
8312
10777
  process.stderr.write("Warning: Could not open browser automatically\n");
8313
10778
  }
@@ -10338,7 +12803,7 @@ async function createMemberChat(apiClient, workspace, memberId) {
10338
12803
  }
10339
12804
 
10340
12805
  // src/commands/organizations.ts
10341
- var COLUMNS33 = [
12806
+ var COLUMNS34 = [
10342
12807
  { header: "NAME", getValue: (o) => o.organizationName || "", maxWidth: 35 },
10343
12808
  { header: "SLUG", getValue: (o) => o.organizationSlug || "", maxWidth: 25 },
10344
12809
  { header: "UUID", getValue: (o) => o.organizationUuid },
@@ -10346,11 +12811,11 @@ var COLUMNS33 = [
10346
12811
  ];
10347
12812
  async function organizationsListCommand(ctx) {
10348
12813
  const organizations = await ctx.apiClient.getMyOrganizations();
10349
- outputData(organizations, ctx, COLUMNS33);
12814
+ outputData(organizations, ctx, COLUMNS34);
10350
12815
  }
10351
12816
 
10352
12817
  // src/commands/whoami.ts
10353
- var COLUMNS34 = [
12818
+ var COLUMNS35 = [
10354
12819
  { header: "NAME", getValue: (a) => a.name || "", maxWidth: 30 },
10355
12820
  { header: "EMAIL", getValue: (a) => a.email || "", maxWidth: 40 },
10356
12821
  { header: "UUID", getValue: (a) => a.uuid },
@@ -10358,7 +12823,7 @@ var COLUMNS34 = [
10358
12823
  ];
10359
12824
  async function whoamiCommand(ctx) {
10360
12825
  const account = await ctx.apiClient.getUserAccount();
10361
- outputSingle(account, ctx, COLUMNS34);
12826
+ outputSingle(account, ctx, COLUMNS35);
10362
12827
  }
10363
12828
  export {
10364
12829
  AuthRequiredError,