@gravity-rail/cli 2.0.0 → 3.0.1

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/gr.js CHANGED
@@ -241,7 +241,7 @@ var init_pagination = __esm({
241
241
  }
242
242
  });
243
243
 
244
- // ../sdk/dist/chunk-GCN4OMYU.js
244
+ // ../sdk/dist/chunk-RLFS7O2L.js
245
245
  function isApiValidationError(value) {
246
246
  if (!value || typeof value !== "object") return false;
247
247
  const v = value;
@@ -276,8 +276,8 @@ function setOrgAuthHeader(headers2, token) {
276
276
  headers2.set(orgAuthHeaderName(token), token);
277
277
  }
278
278
  var ApiError, BaseApiClient;
279
- var init_chunk_GCN4OMYU = __esm({
280
- "../sdk/dist/chunk-GCN4OMYU.js"() {
279
+ var init_chunk_RLFS7O2L = __esm({
280
+ "../sdk/dist/chunk-RLFS7O2L.js"() {
281
281
  ApiError = class extends Error {
282
282
  statusCode;
283
283
  /** Legacy string-array errors — kept for non-validation callers. */
@@ -526,6 +526,9 @@ ${formattedErrors}`, response.status);
526
526
  const headers2 = new Headers({
527
527
  ...options?.headers || {}
528
528
  });
529
+ if (typeof options?.body === "string" && !headers2.has("Content-Type")) {
530
+ headers2.set("Content-Type", "application/json");
531
+ }
529
532
  if (this.apiKey) {
530
533
  headers2.set("Authorization", `Bearer ${this.apiKey}`);
531
534
  }
@@ -3164,7 +3167,7 @@ var init_libphonenumber_js = __esm({
3164
3167
  }
3165
3168
  });
3166
3169
 
3167
- // ../sdk/dist/chunk-SVRE6KIM.js
3170
+ // ../sdk/dist/chunk-LWRMGN4Z.js
3168
3171
  function resourceWorkflowsPath(wid, ...segments) {
3169
3172
  const tail = segments.map((segment) => encodeURIComponent(String(segment))).join("/");
3170
3173
  const base = `w/${encodeURIComponent(wid)}/resource-workflows`;
@@ -3268,6 +3271,9 @@ function memberImportUpload(file, roleId, options) {
3268
3271
  function businessProfilePath(orgUuid, legalEntityUuid) {
3269
3272
  return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
3270
3273
  }
3274
+ function campaignQuery(options) {
3275
+ return options?.campaignUuid ? `?campaignUuid=${encodeURIComponent(options.campaignUuid)}` : "";
3276
+ }
3271
3277
  function getOAuthPath(providerSlug, action) {
3272
3278
  if (providerSlug === "google_calendar") {
3273
3279
  return `api/v2/oauth/google/calendar/${action}`;
@@ -3300,6 +3306,13 @@ function appendAnalyticsFilters(params, filters) {
3300
3306
  filters.answeredBy?.forEach((v) => params.append("answeredBy", v));
3301
3307
  filters.memberLabel?.forEach((v) => params.append("memberLabel", v));
3302
3308
  }
3309
+ function appendPhoneLogFilters(params, filters) {
3310
+ if (!filters) return;
3311
+ if (filters.inbound !== void 0) params.set("inbound", String(filters.inbound));
3312
+ if (filters.dateFrom) params.set("dateFrom", filters.dateFrom);
3313
+ if (filters.dateTo) params.set("dateTo", filters.dateTo);
3314
+ if (filters.otherNumber) params.set("otherNumber", filters.otherNumber);
3315
+ }
3303
3316
  function appendFilters(params, filters) {
3304
3317
  if (!filters) return;
3305
3318
  if (filters.channel !== void 0) params.set("channel", filters.channel);
@@ -3561,7 +3574,6 @@ function bindChatsMethods(target, chats) {
3561
3574
  target.summarizeChat = chats.summarizeChat.bind(chats);
3562
3575
  target.getChatMessages = chats.getChatMessages.bind(chats);
3563
3576
  target.getChatTaskTransitions = chats.getChatTaskTransitions.bind(chats);
3564
- target.getChildThreadMessages = chats.getChildThreadMessages.bind(chats);
3565
3577
  target.getChatToolCallMessages = chats.getChatToolCallMessages.bind(chats);
3566
3578
  target.getChatTools = chats.getChatTools.bind(chats);
3567
3579
  target.initiateOutboundCall = chats.initiateOutboundCall.bind(chats);
@@ -3784,7 +3796,6 @@ function bindWorkspacesMethods(target, workspaces, signupRequests) {
3784
3796
  target.dismissNotification = workspaces.dismissNotification.bind(workspaces);
3785
3797
  target.dismissAllNotifications = workspaces.dismissAllNotifications.bind(workspaces);
3786
3798
  target.getResellerWorkspaces = workspaces.getResellerWorkspaces.bind(workspaces);
3787
- target.createClientWorkspace = workspaces.createClientWorkspace.bind(workspaces);
3788
3799
  target.getClientWorkspace = workspaces.getClientWorkspace.bind(workspaces);
3789
3800
  target.updateClientWorkspace = workspaces.updateClientWorkspace.bind(workspaces);
3790
3801
  target.deleteClientWorkspace = workspaces.deleteClientWorkspace.bind(workspaces);
@@ -3839,6 +3850,9 @@ function bindWorkspacesMethods(target, workspaces, signupRequests) {
3839
3850
  target.declineInvitation = signupRequests.declineInvitation.bind(signupRequests);
3840
3851
  }
3841
3852
  function bindAuthMethods(target, auth, assignments) {
3853
+ target.getAccountNotices = auth.getAccountNotices.bind(auth);
3854
+ target.viewAccountNotice = auth.viewAccountNotice.bind(auth);
3855
+ target.dismissAccountNotice = auth.dismissAccountNotice.bind(auth);
3842
3856
  target.getUserAccount = auth.getUserAccount.bind(auth);
3843
3857
  target.updateUserAccount = auth.updateUserAccount.bind(auth);
3844
3858
  target.recordAcquisition = auth.recordAcquisition.bind(auth);
@@ -3898,6 +3912,11 @@ function bindAuthMethods(target, auth, assignments) {
3898
3912
  target.executeAssignmentTool = assignments.executeAssignmentTool.bind(assignments);
3899
3913
  }
3900
3914
  function bindSitesMethods(target, sites) {
3915
+ target.endPublicDemo = sites.endPublicDemo.bind(sites);
3916
+ target.startPublicDemo = sites.startPublicDemo.bind(sites);
3917
+ target.getPublicDemo = sites.getPublicDemo.bind(sites);
3918
+ target.sendPublicDemoMessage = sites.sendPublicDemoMessage.bind(sites);
3919
+ target.submitPublicDemoForm = sites.submitPublicDemoForm.bind(sites);
3901
3920
  target.getSites = sites.getSites.bind(sites);
3902
3921
  target.checkSiteSlugAvailability = sites.checkSiteSlugAvailability.bind(sites);
3903
3922
  target.checkSiteDomainAvailability = sites.checkSiteDomainAvailability.bind(sites);
@@ -3905,6 +3924,7 @@ function bindSitesMethods(target, sites) {
3905
3924
  target.getSiteSharing = sites.getSiteSharing.bind(sites);
3906
3925
  target.updateSiteSharing = sites.updateSiteSharing.bind(sites);
3907
3926
  target.getSiteSource = sites.getSiteSource.bind(sites);
3927
+ target.getSiteSourceReleases = sites.getSiteSourceReleases.bind(sites);
3908
3928
  target.getSiteSourceTemplates = sites.getSiteSourceTemplates.bind(sites);
3909
3929
  target.createSiteSource = sites.createSiteSource.bind(sites);
3910
3930
  target.buildSiteSource = sites.buildSiteSource.bind(sites);
@@ -3963,6 +3983,8 @@ function bindFilesMethods(target, files) {
3963
3983
  target.createFolder = files.createFolder.bind(files);
3964
3984
  target.updateFolder = files.updateFolder.bind(files);
3965
3985
  target.deleteFolder = files.deleteFolder.bind(files);
3986
+ target.reindexFile = files.reindexFile.bind(files);
3987
+ target.searchFile = files.searchFile.bind(files);
3966
3988
  target.reindexFolder = files.reindexFolder.bind(files);
3967
3989
  target.searchFolder = files.searchFolder.bind(files);
3968
3990
  target.getFileLabels = files.getFileLabels.bind(files);
@@ -4042,6 +4064,7 @@ function bindWorkflowsMethods(target, workflows, workflowNotes, voice, superviso
4042
4064
  target.getWorkflowsOutlineBatch = workflows.getWorkflowsOutlineBatch.bind(workflows);
4043
4065
  target.createWorkflow = workflows.createWorkflow.bind(workflows);
4044
4066
  target.updateWorkflow = workflows.updateWorkflow.bind(workflows);
4067
+ target.uploadWorkflowKnowledge = workflows.uploadWorkflowKnowledge.bind(workflows);
4045
4068
  target.getWorkflowDeletionPreview = workflows.getWorkflowDeletionPreview.bind(workflows);
4046
4069
  target.deleteWorkflow = workflows.deleteWorkflow.bind(workflows);
4047
4070
  target.archiveWorkflow = workflows.archiveWorkflow.bind(workflows);
@@ -4129,6 +4152,7 @@ function bindCommunicationsMethods(target, phoneNumbers, inboxes, notificationRu
4129
4152
  target.getPhoneNumberOutboundAnalyticsSummary = phoneNumbers.getPhoneNumberOutboundAnalyticsSummary.bind(phoneNumbers);
4130
4153
  target.getPhoneNumberOutboundAnalyticsCalls = phoneNumbers.getPhoneNumberOutboundAnalyticsCalls.bind(phoneNumbers);
4131
4154
  target.exportPhoneNumberOutboundAnalyticsCsv = phoneNumbers.exportPhoneNumberOutboundAnalyticsCsv.bind(phoneNumbers);
4155
+ target.getPhoneNumberActivity = phoneNumbers.getPhoneNumberActivity.bind(phoneNumbers);
4132
4156
  target.getPhoneNumberMessages = phoneNumbers.getPhoneNumberMessages.bind(phoneNumbers);
4133
4157
  target.getPhoneNumberFaxes = phoneNumbers.getPhoneNumberFaxes.bind(phoneNumbers);
4134
4158
  target.getPhoneNumberVoicemails = phoneNumbers.getPhoneNumberVoicemails.bind(phoneNumbers);
@@ -4142,6 +4166,8 @@ function bindCommunicationsMethods(target, phoneNumbers, inboxes, notificationRu
4142
4166
  target.createInbox = inboxes.createInbox.bind(inboxes);
4143
4167
  target.updateInbox = inboxes.updateInbox.bind(inboxes);
4144
4168
  target.deleteInbox = inboxes.deleteInbox.bind(inboxes);
4169
+ target.archiveInbox = inboxes.archiveInbox.bind(inboxes);
4170
+ target.getInboxArchiveBlockers = inboxes.getInboxArchiveBlockers.bind(inboxes);
4145
4171
  target.getInboxEmails = inboxes.getInboxEmails.bind(inboxes);
4146
4172
  target.getInboxEmail = inboxes.getInboxEmail.bind(inboxes);
4147
4173
  target.markEmailAsRead = inboxes.markEmailAsRead.bind(inboxes);
@@ -4295,7 +4321,6 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
4295
4321
  target.autoCreateDataTypeFromBoard = mondayIntegration.autoCreateDataTypeFromBoard.bind(mondayIntegration);
4296
4322
  target.getDiscordBots = discordBots.getDiscordBots.bind(discordBots);
4297
4323
  target.getDiscordBot = discordBots.getDiscordBot.bind(discordBots);
4298
- target.getDiscordBotByUuid = discordBots.getDiscordBotByUuid.bind(discordBots);
4299
4324
  target.createDiscordBot = discordBots.createDiscordBot.bind(discordBots);
4300
4325
  target.updateDiscordBot = discordBots.updateDiscordBot.bind(discordBots);
4301
4326
  target.deleteDiscordBot = discordBots.deleteDiscordBot.bind(discordBots);
@@ -4360,6 +4385,7 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
4360
4385
  target.fhirGetEncounterSyncRuns = fhirConnections.fhirGetEncounterSyncRuns.bind(fhirConnections);
4361
4386
  target.fhirRefreshEncounterPatient = fhirConnections.fhirRefreshEncounterPatient.bind(fhirConnections);
4362
4387
  target.fhirBackfillEncounterSync = fhirConnections.fhirBackfillEncounterSync.bind(fhirConnections);
4388
+ target.getFhirConnectionSyncConfig = fhirConnections.getFhirConnectionSyncConfig.bind(fhirConnections);
4363
4389
  target.getAthenaPlatformApp = fhirConnections.getAthenaPlatformApp.bind(fhirConnections);
4364
4390
  target.verifyAthenaAccess = fhirConnections.verifyAthenaAccess.bind(fhirConnections);
4365
4391
  target.connectAthena = fhirConnections.connectAthena.bind(fhirConnections);
@@ -4454,6 +4480,7 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
4454
4480
  target.startSyncRun = connectionSync.startSyncRun.bind(connectionSync);
4455
4481
  target.getSyncRuns = connectionSync.getSyncRuns.bind(connectionSync);
4456
4482
  target.getSyncRunItems = connectionSync.getSyncRunItems.bind(connectionSync);
4483
+ target.getSyncRunItemsPage = connectionSync.getSyncRunItemsPage.bind(connectionSync);
4457
4484
  target.getMemberSyncSummary = connectionSync.getMemberSyncSummary.bind(connectionSync);
4458
4485
  target.getConnectionFieldHomes = connectionSync.getConnectionFieldHomes.bind(connectionSync);
4459
4486
  target.getInboundRecordStatus = connectionSync.getInboundRecordStatus.bind(connectionSync);
@@ -4496,6 +4523,13 @@ function bindOperatorMethods(target, operatorGroups) {
4496
4523
  target.sendOperatorMessage = operatorGroups.sendOperatorMessage.bind(operatorGroups);
4497
4524
  }
4498
4525
  function bindOrgMethods(target, org) {
4526
+ target.authorizeOrgManagerDelegation = org.authorizeOrgManagerDelegation.bind(org);
4527
+ target.getOrgManagerCredentialResponse = org.getOrgManagerCredentialResponse.bind(org);
4528
+ target.stopOrgManagerTurn = org.stopOrgManagerTurn.bind(org);
4529
+ target.getOrgManagerChats = org.getOrgManagerChats.bind(org);
4530
+ target.createOrgManagerChat = org.createOrgManagerChat.bind(org);
4531
+ target.getOrgManagerMessages = org.getOrgManagerMessages.bind(org);
4532
+ target.startOrgManagerTurn = org.startOrgManagerTurn.bind(org);
4499
4533
  target.listOrgDomains = org.listOrgDomains.bind(org);
4500
4534
  target.registerOrgDomain = org.registerOrgDomain.bind(org);
4501
4535
  target.getOrgDomain = org.getOrgDomain.bind(org);
@@ -4693,6 +4727,7 @@ function bindMetricsMethods(target, metrics) {
4693
4727
  target.deleteMetric = metrics.deleteMetric.bind(metrics);
4694
4728
  target.listMetricObservations = metrics.listMetricObservations.bind(metrics);
4695
4729
  target.getMetricSeries = metrics.getMetricSeries.bind(metrics);
4730
+ target.getMetricSeriesBatch = metrics.getMetricSeriesBatch.bind(metrics);
4696
4731
  target.computeChatMetrics = metrics.computeChatMetrics.bind(metrics);
4697
4732
  }
4698
4733
  function bindDataReportsMethods(target, dataReports) {
@@ -4768,9 +4803,9 @@ function getRevisionState(workflow, revision) {
4768
4803
  };
4769
4804
  }
4770
4805
  var AbilitiesApi, ResourceWorkflowsApi, BundlesApi, InstallationsApi, AccessGrantsApi, AgentTasksApi, AgentsApi, AIModelsApi, ApiKeysApi, AppsApi, AssignmentsApi, VoiceApi, AuthApi, BuildersApi, CalendarsApi, CallsApi, CELApi, ChatsApi, ConfluenceApi, CustomToolkitsApi, DataTypesApi, DiscordBotsApi, SlackAppsApi, EventsApi, FeaturesApi, FhirConnectionsApi, StediApi, InboundFaxStatus, DocumoFaxApi, HealthieApi, FilesApi, InboxesApi, InquiriesApi, AppConnectionsApi, McpServersApi, MemberImportValidationError, MembersApi, MondayIntegrationApi, NotificationRulesApi, OperatorApi, OrgApi, OAuthConnectionsApi, OAuthApi, PhoneNumbersApi, PronunciationsApi, PromptsApi, PersonasApi, QueriesApi, QualificationsApi, ReportsApi, RoutingRulesApi, SalesforceApi, ConnectionSyncApi, HubspotApi, SitesApi, SubscriptionsApi, SupportRequestsApi, CustomersApi, ResellersApi, SupervisorsApi, TasksApi, TemplatesApi, ToolkitsApi, JourneysApi, WorkflowsApi, WorkflowNotesApi, EventRuleObjectType, EventRuleEventType, EventRuleActionType, DriverMode, MEMBER_RELATIONSHIP_KINDS, WorkspaceInvitationsApi, WorkspacesApi, MedicalBillingApi, DashboardsApi, DevicesApi, TeamsAppsApi, ExperimentsApi, PatientSyncConnectionsApi, ClaimMdApi, ActivityApi, MotdApi, InterventionRequestsApi, MetricsApi, DataReportsApi, ProjectsApi, TrackedLinksApi, WORKSPACE_METHOD_NAMES, WORKSPACE_METHOD_NAME_SET, GravityRailClient, WIDGET_SLUGS, CHAT_TYPES, BUILTIN_ASSISTANT_CHAT_TYPES, MEMBER_AGENT_CHAT_TYPES, ActivityGrain, ActivityGroupBy, ActivityOpenItemOrder, ActivityWindowBasis;
4771
- var init_chunk_SVRE6KIM = __esm({
4772
- "../sdk/dist/chunk-SVRE6KIM.js"() {
4773
- init_chunk_GCN4OMYU();
4806
+ var init_chunk_LWRMGN4Z = __esm({
4807
+ "../sdk/dist/chunk-LWRMGN4Z.js"() {
4808
+ init_chunk_RLFS7O2L();
4774
4809
  init_libphonenumber_js();
4775
4810
  AbilitiesApi = class extends BaseApiClient {
4776
4811
  /**
@@ -5625,6 +5660,18 @@ var init_chunk_SVRE6KIM = __esm({
5625
5660
  async getUserAccount() {
5626
5661
  return this.fetch("account");
5627
5662
  }
5663
+ /** Active, undismissed product notices for this account across workspaces. */
5664
+ async getAccountNotices() {
5665
+ return this.fetch("account/notices");
5666
+ }
5667
+ async viewAccountNotice(id) {
5668
+ return this.fetch(`account/notices/${encodeURIComponent(id)}/view`, { method: "PUT" });
5669
+ }
5670
+ async dismissAccountNotice(id) {
5671
+ return this.fetch(`account/notices/${encodeURIComponent(id)}/dismiss`, {
5672
+ method: "PUT"
5673
+ });
5674
+ }
5628
5675
  /** Update the authenticated user's account information. */
5629
5676
  async updateUserAccount(info) {
5630
5677
  return this.fetch("account", {
@@ -6716,24 +6763,6 @@ var init_chunk_SVRE6KIM = __esm({
6716
6763
  `w/${wid}/chats/${id}/task-transitions${params.toString() ? `?${params.toString()}` : ""}`
6717
6764
  );
6718
6765
  }
6719
- /** List the background-work thread hanging off a message.
6720
- *
6721
- * When a tool trajectory outgrows its turn it detaches and runs in the
6722
- * background (ADR-11 / forked trajectories), writing its messages as a
6723
- * child thread parented at the fork point. Main-history reads exclude
6724
- * them, so this is how the "show work" affordance fetches them — lazily,
6725
- * only when a message with a non-zero `childMessageCount` is expanded.
6726
- * Returns the thread in chronological order, empty when there is none.
6727
- *
6728
- * `messageUuid` is the fork point's `ChatMessage.id`. */
6729
- async getChildThreadMessages(wid, chatId, messageUuid, limit = 200, offset = 0) {
6730
- const params = new URLSearchParams();
6731
- params.append("limit", limit.toString());
6732
- params.append("offset", offset.toString());
6733
- return this.fetch(
6734
- `w/${wid}/chats/${chatId}/messages/${messageUuid}/children?${params.toString()}`
6735
- );
6736
- }
6737
6766
  /** List messages associated with a specific tool call in a chat. */
6738
6767
  async getChatToolCallMessages(wid, chatId, callId, limit = 100, offset = 0) {
6739
6768
  const params = new URLSearchParams();
@@ -7389,12 +7418,6 @@ var init_chunk_SVRE6KIM = __esm({
7389
7418
  async getDiscordBot(wid, botId) {
7390
7419
  return this.fetch(`w/${wid}/app-connections/discord/bots/${botId}`);
7391
7420
  }
7392
- /**
7393
- * Get a Discord bot by UUID.
7394
- */
7395
- async getDiscordBotByUuid(wid, uuid) {
7396
- return this.fetch(`w/${wid}/app-connections/discord/bots/uuid/${uuid}`);
7397
- }
7398
7421
  /**
7399
7422
  * Create a new Discord bot configuration.
7400
7423
  */
@@ -7646,6 +7669,7 @@ var init_chunk_SVRE6KIM = __esm({
7646
7669
  /** List event rules in the workspace, paginated. */
7647
7670
  async getEventRules(wid, params) {
7648
7671
  const query2 = new URLSearchParams();
7672
+ if (params?.search) query2.set("search", params.search);
7649
7673
  if (params?.page !== void 0) query2.set("page", String(params.page));
7650
7674
  if (params?.pageSize !== void 0) query2.set("pageSize", String(params.pageSize));
7651
7675
  const qs = query2.toString() ? `?${query2.toString()}` : "";
@@ -7905,6 +7929,22 @@ var init_chunk_SVRE6KIM = __esm({
7905
7929
  async getFhirConnectionByUuid(wid, uuid) {
7906
7930
  return this.fetch(`w/${wid}/app-connections/fhir/connections/uuid/${uuid}`);
7907
7931
  }
7932
+ /**
7933
+ * The connection's sync configuration, with the eCW encounter-sync runtime
7934
+ * state (`connectionParams.ecwEncounterSyncState`) typed.
7935
+ *
7936
+ * This is the generic connector sync-config route (the same one
7937
+ * `ConnectionSyncApi.getConnectionSyncConfig` wraps), not a FHIR-only
7938
+ * path. It is the one read that still returns the encounter
7939
+ * watermark for a workspace whose eCW feature flag is off: the
7940
+ * encounter-sync status route is flag-gated, while this route requires
7941
+ * only `apps:read`.
7942
+ */
7943
+ async getFhirConnectionSyncConfig(wid, connectionId) {
7944
+ return this.fetch(
7945
+ `w/${wid}/app-connections/${connectionId}/sync-config`
7946
+ );
7947
+ }
7908
7948
  /**
7909
7949
  * Create a new FHIR connection configuration.
7910
7950
  */
@@ -8530,6 +8570,21 @@ var init_chunk_SVRE6KIM = __esm({
8530
8570
  method: "DELETE"
8531
8571
  });
8532
8572
  }
8573
+ /** Queue indexing of an individual File, including a File without a folder. */
8574
+ async reindexFile(wid, id) {
8575
+ return this.fetch(`w/${wid}/files/${id}/reindex`, {
8576
+ method: "POST",
8577
+ body: JSON.stringify({})
8578
+ });
8579
+ }
8580
+ /** Search the current indexed version of an individual File. */
8581
+ async searchFile(wid, id, params) {
8582
+ const searchParams = new URLSearchParams({ query: params.query });
8583
+ if (params.topK !== void 0) searchParams.append("top_k", params.topK.toString());
8584
+ return this.fetch(
8585
+ `w/${wid}/files/${id}/search?${searchParams.toString()}`
8586
+ );
8587
+ }
8533
8588
  /** Trigger reindexing of a folder's contents for search. */
8534
8589
  async reindexFolder(wid, id) {
8535
8590
  return this.fetch(`w/${wid}/folders/${id}/reindex`, {
@@ -8656,9 +8711,20 @@ var init_chunk_SVRE6KIM = __esm({
8656
8711
  }
8657
8712
  };
8658
8713
  InboxesApi = class extends BaseApiClient {
8659
- /** List all inboxes in a workspace. */
8660
- async getInboxes(wid) {
8661
- return this.fetch(`w/${wid}/inboxes`);
8714
+ /**
8715
+ * List inboxes in a workspace.
8716
+ *
8717
+ * `isArchived` picks the half of the archive switch: omitted (or `false`) is
8718
+ * the Active list, `true` the Archived one. The server defaults to active,
8719
+ * so a caller that never passes it sees usable inboxes only.
8720
+ */
8721
+ async getInboxes(wid, options) {
8722
+ const params = new URLSearchParams();
8723
+ if (options?.isArchived !== void 0) {
8724
+ params.set("is_archived", String(options.isArchived));
8725
+ }
8726
+ const query2 = params.toString();
8727
+ return this.fetch(`w/${wid}/inboxes${query2 ? `?${query2}` : ""}`);
8662
8728
  }
8663
8729
  /**
8664
8730
  * Get an inbox by ID or UUID.
@@ -8685,17 +8751,45 @@ var init_chunk_SVRE6KIM = __esm({
8685
8751
  body: JSON.stringify(inbox)
8686
8752
  });
8687
8753
  }
8688
- /** Delete an inbox. */
8754
+ /** Delete an inbox and its emails. Prefer {@link archiveInbox}. */
8689
8755
  async deleteInbox(wid, id) {
8690
8756
  return this.fetch(`w/${wid}/inboxes/${id}`, {
8691
8757
  method: "DELETE"
8692
8758
  });
8693
8759
  }
8694
- /** List emails in an inbox with pagination and optional attachment inclusion. */
8760
+ /**
8761
+ * Archive an inbox: it leaves the Active list, refuses new mail and new
8762
+ * sends, and keeps every email it already holds. One-way.
8763
+ *
8764
+ * Refused with a 400 while a Workflow uses the inbox as its default or an
8765
+ * EventRule sends from it — read {@link getInboxArchiveBlockers} first to
8766
+ * explain that before committing.
8767
+ */
8768
+ async archiveInbox(wid, id) {
8769
+ return this.fetch(`w/${wid}/inboxes/${id}/archive`, {
8770
+ method: "POST",
8771
+ // The route requires a JSON body as a CSRF barrier; `{}` is enough.
8772
+ body: JSON.stringify({})
8773
+ });
8774
+ }
8775
+ /**
8776
+ * What still points at this inbox: Workflows whose default inbox it is, and
8777
+ * EventRules that send from it. `canArchive` is the authoritative answer.
8778
+ */
8779
+ async getInboxArchiveBlockers(wid, id) {
8780
+ return this.fetch(`w/${wid}/inboxes/${id}/archive-blockers`);
8781
+ }
8782
+ /**
8783
+ * List emails in an inbox with pagination, optional attachment inclusion,
8784
+ * a `search` term (sender or subject) and a sort.
8785
+ */
8695
8786
  async getInboxEmails(wid, inboxId, options = {}) {
8696
8787
  const params = new URLSearchParams();
8697
8788
  if (options.page) params.append("page", options.page.toString());
8698
8789
  if (options.pageSize) params.append("pageSize", options.pageSize.toString());
8790
+ if (options.search) params.append("search", options.search);
8791
+ if (options.sortBy) params.append("sortBy", options.sortBy);
8792
+ if (options.sortOrder) params.append("sortOrder", options.sortOrder);
8699
8793
  if (options.includeAttachments)
8700
8794
  params.append("include_attachments", options.includeAttachments.toString());
8701
8795
  return this.fetch(
@@ -8809,9 +8903,15 @@ var init_chunk_SVRE6KIM = __esm({
8809
8903
  `w/${wid}/inboxes/${inboxId}/outbound-email-stats${query2 ? `?${query2}` : ""}`
8810
8904
  );
8811
8905
  }
8812
- /** List email threads in an inbox. */
8813
- async getInboxThreads(wid, inboxId) {
8814
- return this.fetch(`w/${wid}/inboxes/${inboxId}/threads`);
8906
+ /** List email threads in an inbox, `limit` threads from `offset`. */
8907
+ async getInboxThreads(wid, inboxId, options = {}) {
8908
+ const params = new URLSearchParams();
8909
+ if (options.limit !== void 0) params.append("limit", options.limit.toString());
8910
+ if (options.offset) params.append("offset", options.offset.toString());
8911
+ const query2 = params.toString();
8912
+ return this.fetch(
8913
+ `w/${wid}/inboxes/${inboxId}/threads${query2 ? `?${query2}` : ""}`
8914
+ );
8815
8915
  }
8816
8916
  /** List emails in a thread by assignment ID with pagination. */
8817
8917
  async getThreadEmails(wid, inboxId, assignmentId, options = {}) {
@@ -10031,6 +10131,47 @@ var init_chunk_SVRE6KIM = __esm({
10031
10131
  }
10032
10132
  };
10033
10133
  OrgApi = class extends BaseApiClient {
10134
+ async getOrgManagerChats(org, cursor) {
10135
+ return this.fetch(
10136
+ `o/${encodeURIComponent(org)}/manager/chats${cursor === void 0 ? "" : `?cursor=${encodeURIComponent(cursor)}`}`
10137
+ );
10138
+ }
10139
+ async createOrgManagerChat(org, title) {
10140
+ return this.fetch(`o/${encodeURIComponent(org)}/manager/chats`, {
10141
+ method: "POST",
10142
+ body: JSON.stringify({ title })
10143
+ });
10144
+ }
10145
+ async authorizeOrgManagerDelegation(workspace, orgUuid, chatId, callId) {
10146
+ return this.fetch(`w/${encodeURIComponent(workspace)}/a2a/manager/delegation-credential`, {
10147
+ method: "POST",
10148
+ body: JSON.stringify({ orgUuid, chatId, callId }),
10149
+ cache: "no-store"
10150
+ });
10151
+ }
10152
+ async getOrgManagerCredentialResponse(org, chatId, deliveryId) {
10153
+ return this.fetch(
10154
+ `o/${encodeURIComponent(org)}/manager/chats/${chatId}/credentials/${encodeURIComponent(deliveryId)}`,
10155
+ { cache: "no-store" }
10156
+ );
10157
+ }
10158
+ async getOrgManagerMessages(org, chatId, before) {
10159
+ return this.fetch(
10160
+ `o/${encodeURIComponent(org)}/manager/chats/${chatId}/messages${before ? `?before=${before}` : ""}`
10161
+ );
10162
+ }
10163
+ async stopOrgManagerTurn(org, chatId) {
10164
+ return this.fetch(`o/${encodeURIComponent(org)}/manager/chats/${chatId}/stop`, {
10165
+ method: "POST",
10166
+ body: JSON.stringify({})
10167
+ });
10168
+ }
10169
+ async startOrgManagerTurn(org, chatId, body) {
10170
+ return this.fetch(`o/${encodeURIComponent(org)}/manager/chats/${chatId}/turns`, {
10171
+ method: "POST",
10172
+ body: JSON.stringify(body)
10173
+ });
10174
+ }
10034
10175
  /**
10035
10176
  * Get organization by ID or UUID.
10036
10177
  * Returns different response based on user's role:
@@ -10280,6 +10421,7 @@ var init_chunk_SVRE6KIM = __esm({
10280
10421
  if (options?.page) params.set("page", String(options.page));
10281
10422
  if (options?.pageSize) params.set("pageSize", String(options.pageSize));
10282
10423
  if (options?.search) params.set("search", options.search);
10424
+ if (options?.label) params.set("label", options.label);
10283
10425
  return this.fetch(
10284
10426
  `o/${orgIdOrUuid}/workspaces/summary?${params}`
10285
10427
  );
@@ -10347,7 +10489,8 @@ var init_chunk_SVRE6KIM = __esm({
10347
10489
  });
10348
10490
  }
10349
10491
  /**
10350
- * Search for available phone numbers to purchase from Twilio.
10492
+ * Search available numbers. Use `mobile` for AU and `local` or `toll_free`
10493
+ * for US; the server defaults to US local when the type is omitted.
10351
10494
  */
10352
10495
  async searchPhoneNumbers(orgUuid, params) {
10353
10496
  const query2 = new URLSearchParams();
@@ -10364,8 +10507,9 @@ var init_chunk_SVRE6KIM = __esm({
10364
10507
  /**
10365
10508
  * Purchase a phone number from Twilio for this org inventory (org admin only).
10366
10509
  *
10367
- * Numbers in regulated countries (e.g. Australia) require a Twilio regulatory
10368
- * bundle and an address — pass `bundleSid` and `addressSid` for those.
10510
+ * Australian mobile numbers require an approved business registration. Pass
10511
+ * `legalEntityUuid`; the server resolves its bundle and address. Do not pass
10512
+ * `bundleSid` or `addressSid` for Australian purchases.
10369
10513
  */
10370
10514
  async purchasePhoneNumber(orgUuid, phoneNumber, numberType, opts) {
10371
10515
  return this.fetch(`o/${orgUuid}/phone-numbers/purchase`, {
@@ -10374,11 +10518,31 @@ var init_chunk_SVRE6KIM = __esm({
10374
10518
  phoneNumber,
10375
10519
  numberType,
10376
10520
  country: opts?.country,
10521
+ legalEntityUuid: opts?.legalEntityUuid,
10377
10522
  bundleSid: opts?.bundleSid,
10378
10523
  addressSid: opts?.addressSid
10379
10524
  })
10380
10525
  });
10381
10526
  }
10527
+ async getNumberRegistration(orgUuid, entityUuid) {
10528
+ return this.fetch(`o/${orgUuid}/legal-entities/${entityUuid}/number-registration`);
10529
+ }
10530
+ async uploadNumberRegistrationDocument(orgUuid, entityUuid, file, documentType, requirementName) {
10531
+ const body = new FormData();
10532
+ body.append("file", file);
10533
+ body.append("documentType", documentType);
10534
+ body.append("requirementName", requirementName);
10535
+ return this.fetch(`o/${orgUuid}/legal-entities/${entityUuid}/number-registration/documents`, {
10536
+ method: "POST",
10537
+ body
10538
+ });
10539
+ }
10540
+ async submitNumberRegistration(orgUuid, entityUuid) {
10541
+ return this.fetch(`o/${orgUuid}/legal-entities/${entityUuid}/number-registration/submit`, {
10542
+ method: "POST",
10543
+ body: JSON.stringify({})
10544
+ });
10545
+ }
10382
10546
  /**
10383
10547
  * Delete a phone number from the org (releases from Twilio).
10384
10548
  */
@@ -10425,7 +10589,9 @@ var init_chunk_SVRE6KIM = __esm({
10425
10589
  * Delete a registered organization domain.
10426
10590
  */
10427
10591
  async deleteOrgDomain(orgIdOrUuid, domainUuid) {
10428
- await this.fetch(`o/${orgIdOrUuid}/domains/${domainUuid}`, { method: "DELETE" });
10592
+ await this.fetch(`o/${orgIdOrUuid}/domains/${domainUuid}`, {
10593
+ method: "DELETE"
10594
+ });
10429
10595
  }
10430
10596
  /**
10431
10597
  * Enable email DNS provisioning for a verified org domain.
@@ -10599,17 +10765,20 @@ var init_chunk_SVRE6KIM = __esm({
10599
10765
  });
10600
10766
  }
10601
10767
  /**
10602
- * Activate SMS on a workspace-assigned number: attach it to the given
10603
- * brand's Messaging Service (A2P 10DLC). Preconditions (412 otherwise):
10604
- * campaign VERIFIED, brand has a Messaging Service, phone assigned to a
10605
- * workspace with a Twilio SID.
10768
+ * Enable sending on a workspace-assigned number: attach it to the
10769
+ * Messaging Service of the given brand's campaign (A2P 10DLC).
10770
+ *
10771
+ * `campaignUuid` names the campaign to attach the number to, including the
10772
+ * brand's first; omit it to target the brand's first campaign. Preconditions
10773
+ * (412 otherwise): campaign VERIFIED, brand has a Messaging Service, phone
10774
+ * assigned to a workspace with a Twilio SID.
10606
10775
  */
10607
- async activateA2PNumber(orgUuid, providerPhoneUuid, brandUuid) {
10776
+ async activateA2PNumber(orgUuid, providerPhoneUuid, brandUuid, campaignUuid) {
10608
10777
  return this.fetch(
10609
10778
  `o/${orgUuid}/phone-numbers/a2p/activate-number`,
10610
10779
  {
10611
10780
  method: "POST",
10612
- body: JSON.stringify({ providerPhoneUuid, brandUuid })
10781
+ body: JSON.stringify({ providerPhoneUuid, brandUuid, campaignUuid })
10613
10782
  }
10614
10783
  );
10615
10784
  }
@@ -10626,7 +10795,10 @@ var init_chunk_SVRE6KIM = __esm({
10626
10795
  * entity's business profile must be approved (400 otherwise).
10627
10796
  */
10628
10797
  async attachPhoneVoiceTrust(orgUuid, providerPhoneUuid, legalEntityUuid) {
10629
- const body = { providerPhoneUuid, legalEntityUuid };
10798
+ const body = {
10799
+ providerPhoneUuid,
10800
+ legalEntityUuid
10801
+ };
10630
10802
  return this.fetch(`o/${orgUuid}/phone-numbers/voice-trust/attach`, {
10631
10803
  method: "POST",
10632
10804
  body: JSON.stringify(body)
@@ -10790,23 +10962,53 @@ var init_chunk_SVRE6KIM = __esm({
10790
10962
  `o/${orgUuid}/a2p-brands/${brandUuid}/use-cases`
10791
10963
  );
10792
10964
  }
10965
+ /**
10966
+ * Add a draft campaign to a brand. `sourceCampaignUuid` goes in an optional
10967
+ * JSON body; omitting it copies the brand's first campaign. The draft
10968
+ * reaches no provider until it is submitted. A sole-proprietor brand is
10969
+ * refused.
10970
+ */
10971
+ async createA2PCampaign(orgUuid, brandUuid, data = {}) {
10972
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}/campaigns`, {
10973
+ method: "POST",
10974
+ body: JSON.stringify(data)
10975
+ });
10976
+ }
10977
+ /**
10978
+ * Submit a later campaign that has never been submitted. The caller must be
10979
+ * an org admin with recent 2FA, and the billing owner on subscription
10980
+ * billing (the submission buys the campaign's vetting). The brand's first
10981
+ * campaign is submitted by approving its sample messages during registration;
10982
+ * an ineligible campaign comes back as a structured 409 with a `code`. A brand
10983
+ * that no longer reads approved at the carrier, or a use case it no longer
10984
+ * allows, is a 400 with no `code`.
10985
+ */
10986
+ async submitA2PCampaign(orgUuid, brandUuid, campaignUuid) {
10987
+ return this.fetch(
10988
+ `o/${orgUuid}/a2p-brands/${brandUuid}/campaigns/${encodeURIComponent(campaignUuid)}/submit`,
10989
+ { method: "POST" }
10990
+ );
10991
+ }
10793
10992
  /**
10794
10993
  * Fetch a brand's resolved A2P campaign config. The response carries both the
10795
10994
  * raw `overrides` and the `resolved` payload (defaults + overrides) the editor
10796
- * previews — including the canonical SMS consent text.
10995
+ * previews — including the canonical SMS consent text. `campaignUuid` names
10996
+ * one of the brand's campaigns; without it the brand's first is read.
10797
10997
  */
10798
- async getA2PCampaignConfig(orgUuid, brandUuid) {
10998
+ async getA2PCampaignConfig(orgUuid, brandUuid, options) {
10799
10999
  return this.fetch(
10800
- `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config`
11000
+ `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config${campaignQuery(options)}`
10801
11001
  );
10802
11002
  }
10803
11003
  /**
10804
11004
  * Partial-update a brand's A2P campaign config. Returns the freshly resolved
10805
11005
  * config so the editor's live preview updates without a second round-trip.
11006
+ * `campaignUuid` names one of the brand's campaigns; without it the brand's
11007
+ * first is updated.
10806
11008
  */
10807
- async updateA2PCampaignConfig(orgUuid, brandUuid, data) {
11009
+ async updateA2PCampaignConfig(orgUuid, brandUuid, data, options) {
10808
11010
  return this.fetch(
10809
- `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config`,
11011
+ `o/${orgUuid}/a2p-brands/${brandUuid}/campaign-config${campaignQuery(options)}`,
10810
11012
  {
10811
11013
  method: "PUT",
10812
11014
  body: JSON.stringify(data)
@@ -10816,10 +11018,12 @@ var init_chunk_SVRE6KIM = __esm({
10816
11018
  /**
10817
11019
  * Resubmit a campaign the carrier rejected, with the brand's current
10818
11020
  * campaign copy. Edits the campaign in place, so no second vetting fee.
11021
+ * `campaignUuid` names one of the brand's campaigns; without it the brand's
11022
+ * first is resubmitted.
10819
11023
  */
10820
- async resubmitA2PCampaign(orgUuid, brandUuid) {
11024
+ async resubmitA2PCampaign(orgUuid, brandUuid, options) {
10821
11025
  return this.fetch(
10822
- `o/${orgUuid}/a2p-brands/${brandUuid}/resubmit-campaign`,
11026
+ `o/${orgUuid}/a2p-brands/${brandUuid}/resubmit-campaign${campaignQuery(options)}`,
10823
11027
  { method: "POST" }
10824
11028
  );
10825
11029
  }
@@ -10835,11 +11039,13 @@ var init_chunk_SVRE6KIM = __esm({
10835
11039
  }
10836
11040
  /**
10837
11041
  * Link the brand to a published enrollment Site (sets `site_uuid`). Returns
10838
- * the refreshed campaign config.
11042
+ * the refreshed campaign config. `campaignUuid` names one of the brand's
11043
+ * campaigns; without it the brand's first campaign is written. Only a first
11044
+ * campaign may link a site.
10839
11045
  */
10840
- async linkA2PEnrollmentSite(orgUuid, brandUuid, data) {
11046
+ async linkA2PEnrollmentSite(orgUuid, brandUuid, data, options) {
10841
11047
  return this.fetch(
10842
- `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site`,
11048
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site${campaignQuery(options)}`,
10843
11049
  {
10844
11050
  method: "PUT",
10845
11051
  body: JSON.stringify(data)
@@ -10851,20 +11057,25 @@ var init_chunk_SVRE6KIM = __esm({
10851
11057
  * the explicit counterpart to the automatic provisioning at brand
10852
11058
  * registration. `workspaceUuid` is required only when the org has multiple
10853
11059
  * workspaces. Returns the refreshed campaign config. Idempotent.
11060
+ * `campaignUuid` names one of the brand's campaigns; without it the brand's
11061
+ * first campaign is written. Only a first campaign may link a site.
10854
11062
  */
10855
- async provisionA2PEnrollmentSite(orgUuid, brandUuid, data = {}) {
11063
+ async provisionA2PEnrollmentSite(orgUuid, brandUuid, data = {}, options) {
10856
11064
  return this.fetch(
10857
- `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site/provision`,
11065
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site/provision${campaignQuery(options)}`,
10858
11066
  {
10859
11067
  method: "POST",
10860
11068
  body: JSON.stringify(data)
10861
11069
  }
10862
11070
  );
10863
11071
  }
10864
- /** Clear the brand's enrollment-site link. */
10865
- async unlinkA2PEnrollmentSite(orgUuid, brandUuid) {
11072
+ /**
11073
+ * Clear the brand's enrollment-site link. `campaignUuid` names one of the
11074
+ * brand's campaigns; without it the brand's first campaign is cleared.
11075
+ */
11076
+ async unlinkA2PEnrollmentSite(orgUuid, brandUuid, options) {
10866
11077
  return this.fetch(
10867
- `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site`,
11078
+ `o/${orgUuid}/a2p-brands/${brandUuid}/enrollment-site${campaignQuery(options)}`,
10868
11079
  { method: "DELETE" }
10869
11080
  );
10870
11081
  }
@@ -10872,10 +11083,12 @@ var init_chunk_SVRE6KIM = __esm({
10872
11083
  * Stage one A2P opt-in evidence file: get a presigned POST to send the bytes
10873
11084
  * straight to storage. Nothing is recorded on the brand until
10874
11085
  * {@link registerA2PEvidenceUpload} reads the object back and normalizes it.
11086
+ * `campaignUuid` names one of the brand's campaigns; without it the brand's
11087
+ * first campaign is written.
10875
11088
  */
10876
- async createA2PEvidenceUploadUrl(orgUuid, brandUuid, data) {
11089
+ async createA2PEvidenceUploadUrl(orgUuid, brandUuid, data, options) {
10877
11090
  return this.fetch(
10878
- `o/${orgUuid}/a2p-brands/${brandUuid}/evidence-attachments/upload-url`,
11091
+ `o/${orgUuid}/a2p-brands/${brandUuid}/evidence-attachments/upload-url${campaignQuery(options)}`,
10879
11092
  {
10880
11093
  method: "POST",
10881
11094
  body: JSON.stringify(data)
@@ -10883,25 +11096,29 @@ var init_chunk_SVRE6KIM = __esm({
10883
11096
  );
10884
11097
  }
10885
11098
  /**
10886
- * Normalize a staged evidence upload and record it on the brand. Returns the
10887
- * refreshed campaign config, so the editor's evidence list updates without a
10888
- * second round trip.
11099
+ * Normalize a staged evidence upload and record it on the campaign. Returns
11100
+ * the refreshed campaign config, so the editor's evidence list updates
11101
+ * without a second round trip. `campaignUuid` names one of the brand's
11102
+ * campaigns; without it the brand's first campaign is written.
10889
11103
  */
10890
- async registerA2PEvidenceUpload(orgUuid, brandUuid, data) {
11104
+ async registerA2PEvidenceUpload(orgUuid, brandUuid, data, options) {
10891
11105
  return this.fetch(
10892
- `o/${orgUuid}/a2p-brands/${brandUuid}/evidence-attachments`,
11106
+ `o/${orgUuid}/a2p-brands/${brandUuid}/evidence-attachments${campaignQuery(options)}`,
10893
11107
  {
10894
11108
  method: "POST",
10895
11109
  body: JSON.stringify(data)
10896
11110
  }
10897
11111
  );
10898
11112
  }
10899
- /** Remove one uploaded evidence artifact. */
10900
- async deleteA2PEvidenceUpload(orgUuid, brandUuid, attachmentUuid) {
11113
+ /**
11114
+ * Remove one uploaded evidence artifact. `campaignUuid` names one of the
11115
+ * brand's campaigns; without it the brand's first campaign is written.
11116
+ */
11117
+ async deleteA2PEvidenceUpload(orgUuid, brandUuid, attachmentUuid, options) {
10901
11118
  return this.fetch(
10902
11119
  `o/${orgUuid}/a2p-brands/${brandUuid}/evidence-attachments/${encodeURIComponent(
10903
11120
  attachmentUuid
10904
- )}`,
11121
+ )}${campaignQuery(options)}`,
10905
11122
  { method: "DELETE" }
10906
11123
  );
10907
11124
  }
@@ -10957,9 +11174,13 @@ var init_chunk_SVRE6KIM = __esm({
10957
11174
  method: "DELETE"
10958
11175
  });
10959
11176
  }
10960
- async listOrgWebhookEndpointDeliveries(orgIdOrUuid, endpointUuid, limit = 50, offset = 0) {
11177
+ async listOrgWebhookEndpointDeliveries(orgIdOrUuid, endpointUuid, limit = 50, offset = 0, filters = {}) {
11178
+ const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
11179
+ if (filters.status) params.set("status", filters.status);
11180
+ if (filters.occurredAfter) params.set("occurredAfter", filters.occurredAfter);
11181
+ if (filters.occurredBefore) params.set("occurredBefore", filters.occurredBefore);
10961
11182
  return this.fetch(
10962
- `o/${orgIdOrUuid}/webhooks/${endpointUuid}/deliveries?limit=${limit}&offset=${offset}`
11183
+ `o/${orgIdOrUuid}/webhooks/${endpointUuid}/deliveries?${params}`
10963
11184
  );
10964
11185
  }
10965
11186
  async getOrgWebhookDeliveryDetail(orgIdOrUuid, endpointUuid, deliveryId) {
@@ -11277,16 +11498,32 @@ var init_chunk_SVRE6KIM = __esm({
11277
11498
  if (filters?.inbound !== void 0) params.set("inbound", String(filters.inbound));
11278
11499
  if (filters?.dateFrom) params.set("dateFrom", filters.dateFrom);
11279
11500
  if (filters?.dateTo) params.set("dateTo", filters.dateTo);
11501
+ if (filters?.otherNumber) params.set("otherNumber", filters.otherNumber);
11280
11502
  if (filters?.callId !== void 0) params.set("callId", String(filters.callId));
11281
11503
  return this.fetch(`w/${wid}/calls?${params}`);
11282
11504
  }
11505
+ /**
11506
+ * One time-ordered page over a number's calls, texts and voicemails.
11507
+ *
11508
+ * Paged by keyset: pass the previous page's `nextCursor` as `cursor` to get
11509
+ * the entries after it. A new entry at the head cannot repeat or skip one.
11510
+ * `modalities` limits the feed to some of the logs.
11511
+ */
11512
+ async getPhoneNumberActivity(wid, id, options = {}) {
11513
+ const params = new URLSearchParams({ pageSize: String(options.pageSize ?? 25) });
11514
+ if (options.cursor) params.set("cursor", options.cursor);
11515
+ options.modalities?.forEach((modality) => params.append("modality", modality));
11516
+ appendPhoneLogFilters(params, options);
11517
+ return this.fetch(`w/${wid}/phone-numbers/${id}/activity?${params}`);
11518
+ }
11283
11519
  /** List paginated voicemails for a phone number. */
11284
- async getPhoneNumberVoicemails(wid, id, page = 1, pageSize = 10, status) {
11520
+ async getPhoneNumberVoicemails(wid, id, page = 1, pageSize = 10, status, filters) {
11285
11521
  const params = new URLSearchParams({
11286
11522
  page: String(page),
11287
11523
  page_size: String(pageSize)
11288
11524
  });
11289
11525
  if (status) params.set("status", status);
11526
+ appendPhoneLogFilters(params, filters);
11290
11527
  return this.fetch(
11291
11528
  `w/${wid}/phone-numbers/${id}/voicemails?${params}`
11292
11529
  );
@@ -11312,9 +11549,7 @@ var init_chunk_SVRE6KIM = __esm({
11312
11549
  pageSize: String(pageSize)
11313
11550
  });
11314
11551
  if (filters?.status) params.set("status", filters.status);
11315
- if (filters?.inbound !== void 0) params.set("inbound", String(filters.inbound));
11316
- if (filters?.dateFrom) params.set("dateFrom", filters.dateFrom);
11317
- if (filters?.dateTo) params.set("dateTo", filters.dateTo);
11552
+ appendPhoneLogFilters(params, filters);
11318
11553
  return this.fetch(
11319
11554
  `w/${wid}/phone-numbers/${id}/messages?${params}`
11320
11555
  );
@@ -11573,6 +11808,7 @@ var init_chunk_SVRE6KIM = __esm({
11573
11808
  body: JSON.stringify(data)
11574
11809
  });
11575
11810
  }
11811
+ /** Archives the Persona and its current test Member. Returns 409 while a test chat is open. */
11576
11812
  async archivePersona(wid, id) {
11577
11813
  return this.fetch(`w/${wid}/personas/${id}/archive`, {
11578
11814
  method: "POST",
@@ -11800,9 +12036,12 @@ var init_chunk_SVRE6KIM = __esm({
11800
12036
  );
11801
12037
  }
11802
12038
  async evaluateTestChatRun(wid, runId) {
11803
- await this.fetch(`w/${wid}/qualifications/test-chat-runs/${runId}/evaluate`, {
11804
- method: "POST"
11805
- });
12039
+ return this.fetch(
12040
+ `w/${wid}/qualifications/test-chat-runs/${runId}/evaluate`,
12041
+ {
12042
+ method: "POST"
12043
+ }
12044
+ );
11806
12045
  }
11807
12046
  /** Manually end a test chat run (for human-driven runs, which have no
11808
12047
  * simulator workflow to mark them completed). */
@@ -12196,11 +12435,29 @@ var init_chunk_SVRE6KIM = __esm({
12196
12435
  `w/${wid}/app-connections/${connectionId}/sync/member-summary`
12197
12436
  );
12198
12437
  }
12199
- async getSyncRunItems(wid, connectionId, runId, limit = 500) {
12438
+ /**
12439
+ * One page of a run's items. ``cursor`` is the previous page's
12440
+ * ``nextCursor`` and continues in the requested direction; exhaustion comes
12441
+ * from ``hasMore``, never from the returned row count.
12442
+ */
12443
+ async getSyncRunItemsPage(wid, connectionId, runId, options) {
12444
+ const params = new URLSearchParams();
12445
+ if (options?.limit != null) params.set("limit", String(options.limit));
12446
+ if (options?.newestFirst) params.set("newest_first", "true");
12447
+ if (options?.cursor) params.set("cursor", options.cursor);
12448
+ const qs = params.toString() ? `?${params.toString()}` : "";
12200
12449
  return this.fetch(
12201
- `w/${wid}/app-connections/${connectionId}/sync/runs/${runId}/items?limit=${limit}`
12450
+ `w/${wid}/app-connections/${connectionId}/sync/runs/${runId}/items${qs}`
12202
12451
  );
12203
12452
  }
12453
+ /**
12454
+ * The run's items as a flat list. Kept for the published CLI surface; the
12455
+ * server returns the canonical cursor page, and this unwraps its ``items``.
12456
+ */
12457
+ async getSyncRunItems(wid, connectionId, runId, limit = 500) {
12458
+ const page = await this.getSyncRunItemsPage(wid, connectionId, runId, { limit });
12459
+ return page.items;
12460
+ }
12204
12461
  /**
12205
12462
  * Clear a manual-unlink exclusion for a member on a connection so
12206
12463
  * subsequent outbound syncs stop silently skipping them. Idempotent:
@@ -12472,6 +12729,37 @@ var init_chunk_SVRE6KIM = __esm({
12472
12729
  }
12473
12730
  };
12474
12731
  SitesApi = class extends BaseApiClient {
12732
+ /** Start a fresh synthetic patient session on the Site's configured Workflow. */
12733
+ async startPublicDemo(wid, siteUuid, request) {
12734
+ return this.fetch(`w/${wid}/demos/${encodeURIComponent(siteUuid)}/runs`, {
12735
+ method: "POST",
12736
+ body: JSON.stringify(request)
12737
+ });
12738
+ }
12739
+ /** Read only a demo the acting Member drives. */
12740
+ async getPublicDemo(wid, siteUuid, runId) {
12741
+ return this.fetch(`w/${wid}/demos/${encodeURIComponent(siteUuid)}/runs/${runId}`);
12742
+ }
12743
+ /** End this visitor's run and release its test resources. */
12744
+ async endPublicDemo(wid, siteUuid, runId) {
12745
+ return this.fetch(`w/${wid}/demos/${encodeURIComponent(siteUuid)}/runs/${runId}/end`, {
12746
+ method: "POST",
12747
+ keepalive: true,
12748
+ body: JSON.stringify({})
12749
+ });
12750
+ }
12751
+ async sendPublicDemoMessage(wid, siteUuid, runId, request) {
12752
+ return this.fetch(`w/${wid}/demos/${encodeURIComponent(siteUuid)}/runs/${runId}/messages`, {
12753
+ method: "POST",
12754
+ body: JSON.stringify(request)
12755
+ });
12756
+ }
12757
+ async submitPublicDemoForm(wid, siteUuid, runId, request) {
12758
+ return this.fetch(`w/${wid}/demos/${encodeURIComponent(siteUuid)}/runs/${runId}/form`, {
12759
+ method: "PUT",
12760
+ body: JSON.stringify(request)
12761
+ });
12762
+ }
12475
12763
  /** List all sites in a workspace. */
12476
12764
  async getSites(wid) {
12477
12765
  return this.fetch(`w/${wid}/sites`);
@@ -12511,6 +12799,15 @@ var init_chunk_SVRE6KIM = __esm({
12511
12799
  async getSiteSource(wid, siteId) {
12512
12800
  return this.fetch(`w/${wid}/sites/${siteId}/source`);
12513
12801
  }
12802
+ /** List source release revisions from newest to oldest. */
12803
+ async getSiteSourceReleases(wid, siteId, options = {}) {
12804
+ const params = new URLSearchParams();
12805
+ if (options.beforeVersion != null) params.set("beforeVersion", String(options.beforeVersion));
12806
+ if (options.limit != null) params.set("limit", String(options.limit));
12807
+ return this.fetch(
12808
+ `w/${wid}/sites/${siteId}/source/releases${params.size ? `?${params}` : ""}`
12809
+ );
12810
+ }
12514
12811
  /** Starter templates the caller may seed (superuser-only ones filtered server-side). */
12515
12812
  async getSiteSourceTemplates(wid, siteId) {
12516
12813
  return this.fetch(`w/${wid}/sites/${siteId}/source/templates`);
@@ -13344,6 +13641,8 @@ var init_chunk_SVRE6KIM = __esm({
13344
13641
  async getJourneys(wid, includeArchived = false, pageOpts) {
13345
13642
  const query2 = new URLSearchParams();
13346
13643
  if (includeArchived) query2.set("include_archived", "true");
13644
+ if (pageOpts?.search) query2.set("search", pageOpts.search);
13645
+ if (pageOpts?.archivedOnly) query2.set("archived_only", "true");
13347
13646
  if (pageOpts?.page !== void 0) query2.set("page", String(pageOpts.page));
13348
13647
  if (pageOpts?.pageSize !== void 0) query2.set("pageSize", String(pageOpts.pageSize));
13349
13648
  const qs = query2.toString() ? `?${query2.toString()}` : "";
@@ -13698,6 +13997,12 @@ var init_chunk_SVRE6KIM = __esm({
13698
13997
  }
13699
13998
  };
13700
13999
  WorkflowsApi = class extends BaseApiClient {
14000
+ async uploadWorkflowKnowledge(wid, id, file, relativePath) {
14001
+ const body = new FormData();
14002
+ body.append("file", file, relativePath.split("/").pop());
14003
+ body.append("relativePath", relativePath);
14004
+ return this.fetch(`w/${wid}/workflows/${id}/knowledge/uploads`, { method: "POST", body });
14005
+ }
13701
14006
  /** List all workflows in a workspace, optionally including archived ones. */
13702
14007
  async getWorkflows(wid, options = {}) {
13703
14008
  const params = new URLSearchParams();
@@ -14115,6 +14420,7 @@ var init_chunk_SVRE6KIM = __esm({
14115
14420
  EventRuleEventType2["CHAT_SUMMARY"] = "chat:summary";
14116
14421
  EventRuleEventType2["MESSAGE_CREATED"] = "message:created";
14117
14422
  EventRuleEventType2["LINK_CLICKED"] = "link:clicked";
14423
+ EventRuleEventType2["SMS_DELIVERY_FAILED"] = "sms:delivery_failed";
14118
14424
  EventRuleEventType2["CHAT_CALLBACK"] = "chat:callback";
14119
14425
  EventRuleEventType2["MEMBER_UPDATED"] = "member:updated";
14120
14426
  EventRuleEventType2["ROUTINE_TRIGGERED"] = "routine:triggered";
@@ -14714,13 +15020,6 @@ var init_chunk_SVRE6KIM = __esm({
14714
15020
  const qs = query2.toString() ? `?${query2.toString()}` : "";
14715
15021
  return this.fetch(`w/${wid}/reseller/workspaces${qs}`);
14716
15022
  }
14717
- /** Create a new client workspace under a reseller workspace. */
14718
- async createClientWorkspace(wid, data) {
14719
- return this.fetch(`w/${wid}/reseller/workspaces`, {
14720
- method: "POST",
14721
- body: JSON.stringify(data)
14722
- });
14723
- }
14724
15023
  /** Get a single client workspace by ID. */
14725
15024
  async getClientWorkspace(wid, workspaceId) {
14726
15025
  return this.fetch(`w/${wid}/reseller/workspaces/${workspaceId}`);
@@ -14830,7 +15129,9 @@ var init_chunk_SVRE6KIM = __esm({
14830
15129
  searchParams.set("revision_mode", "active");
14831
15130
  }
14832
15131
  const qs = searchParams.toString();
14833
- const data = await this.fetch(`w/${wid}/export${qs ? `?${qs}` : ""}`);
15132
+ const data = await this.fetch(
15133
+ `w/${wid}/export${qs ? `?${qs}` : ""}`
15134
+ );
14834
15135
  this.verifyExportSelection(data, workflowId, options);
14835
15136
  return data;
14836
15137
  }
@@ -15363,7 +15664,7 @@ var init_chunk_SVRE6KIM = __esm({
15363
15664
  const query2 = new URLSearchParams();
15364
15665
  if (params?.page !== void 0) query2.set("page", String(params.page));
15365
15666
  if (params?.pageSize !== void 0) query2.set("pageSize", String(params.pageSize));
15366
- if (params?.includeArchived) query2.set("includeArchived", "true");
15667
+ if (params?.archived !== void 0) query2.set("archived", String(params.archived));
15367
15668
  const qs = query2.toString() ? `?${query2.toString()}` : "";
15368
15669
  return this.fetch(`w/${wid}/experiments${qs}`);
15369
15670
  }
@@ -15778,8 +16079,7 @@ var init_chunk_SVRE6KIM = __esm({
15778
16079
  const q = new URLSearchParams();
15779
16080
  if (params?.page !== void 0) q.set("page", String(params.page));
15780
16081
  if (params?.pageSize !== void 0) q.set("pageSize", String(params.pageSize));
15781
- if (params?.includeArchived !== void 0)
15782
- q.set("includeArchived", String(params.includeArchived));
16082
+ if (params?.archived !== void 0) q.set("archived", String(params.archived));
15783
16083
  if (params?.source) q.set("source", params.source);
15784
16084
  const qs = q.toString() ? `?${q.toString()}` : "";
15785
16085
  return this.fetch(`w/${wid}/metrics${qs}`);
@@ -15823,6 +16123,18 @@ var init_chunk_SVRE6KIM = __esm({
15823
16123
  `w/${wid}/metrics/${metricId}/series?${q.toString()}`
15824
16124
  );
15825
16125
  }
16126
+ /**
16127
+ * Series for several metrics in one request, each with its default
16128
+ * aggregation. Items come back in the order the ids were given.
16129
+ */
16130
+ async getMetricSeriesBatch(wid, params) {
16131
+ const q = new URLSearchParams();
16132
+ for (const id of params.metricIds) q.append("metricIds", String(id));
16133
+ q.set("start", params.start);
16134
+ q.set("end", params.end);
16135
+ if (params.bucket) q.set("bucket", params.bucket);
16136
+ return this.fetch(`w/${wid}/metrics/series?${q.toString()}`);
16137
+ }
15826
16138
  /** On-demand compute of enabled chat-source metrics for one chat. */
15827
16139
  async computeChatMetrics(wid, data) {
15828
16140
  return this.fetch(`w/${wid}/metrics/compute-for-chat`, {
@@ -15993,6 +16305,7 @@ var init_chunk_SVRE6KIM = __esm({
15993
16305
  "archiveMemberByExternalId",
15994
16306
  "archiveMemberRelationship",
15995
16307
  "archivePersona",
16308
+ "archiveInbox",
15996
16309
  "archivePhoneNumber",
15997
16310
  "archiveStep",
15998
16311
  "archiveTask",
@@ -16066,7 +16379,6 @@ var init_chunk_SVRE6KIM = __esm({
16066
16379
  "createChatCompletion",
16067
16380
  "createChatFilter",
16068
16381
  "createChatLabel",
16069
- "createClientWorkspace",
16070
16382
  "createConnection",
16071
16383
  "createContactPermission",
16072
16384
  "createCustomTool",
@@ -16274,6 +16586,7 @@ var init_chunk_SVRE6KIM = __esm({
16274
16586
  "getApiKeys",
16275
16587
  "getArchiveBlockers",
16276
16588
  "getAthenaPlatformApp",
16589
+ "getFhirConnectionSyncConfig",
16277
16590
  "getAssignment",
16278
16591
  "getAssignmentCelContext",
16279
16592
  "getAssignmentMessages",
@@ -16332,7 +16645,6 @@ var init_chunk_SVRE6KIM = __esm({
16332
16645
  "getChats",
16333
16646
  "getChatsDailyCreationStats",
16334
16647
  "getChatsNeedsResponse",
16335
- "getChildThreadMessages",
16336
16648
  "getClientWorkspace",
16337
16649
  "getConfigurationHealth",
16338
16650
  "getConfluenceStatus",
@@ -16374,7 +16686,6 @@ var init_chunk_SVRE6KIM = __esm({
16374
16686
  "getDevices",
16375
16687
  "getDiscordBot",
16376
16688
  "getDiscordBotAccounts",
16377
- "getDiscordBotByUuid",
16378
16689
  "getDiscordBots",
16379
16690
  "getDiscordGuilds",
16380
16691
  "getDiscordThreads",
@@ -16421,6 +16732,7 @@ var init_chunk_SVRE6KIM = __esm({
16421
16732
  "getQueryFields",
16422
16733
  "getSiteSharing",
16423
16734
  "getSiteSource",
16735
+ "getSiteSourceReleases",
16424
16736
  "getSiteSourceTemplates",
16425
16737
  "getThemeSettings",
16426
16738
  "importSiteSourceZip",
@@ -16477,6 +16789,7 @@ var init_chunk_SVRE6KIM = __esm({
16477
16789
  "getInbox",
16478
16790
  "getInboxEmail",
16479
16791
  "getInboxEmails",
16792
+ "getInboxArchiveBlockers",
16480
16793
  "getInboxOutboundEmailStats",
16481
16794
  "getInboxThreads",
16482
16795
  "getInboxes",
@@ -16552,6 +16865,7 @@ var init_chunk_SVRE6KIM = __esm({
16552
16865
  "getPhoneCalls",
16553
16866
  "getPhoneCallByUuid",
16554
16867
  "getPhoneNumber",
16868
+ "getPhoneNumberActivity",
16555
16869
  "getPhoneNumberCalls",
16556
16870
  "getPhoneNumberFaxes",
16557
16871
  "getPhoneNumberMessages",
@@ -16605,6 +16919,7 @@ var init_chunk_SVRE6KIM = __esm({
16605
16919
  "getSupervisor",
16606
16920
  "getSupervisors",
16607
16921
  "getSyncRunItems",
16922
+ "getSyncRunItemsPage",
16608
16923
  "getSyncRuns",
16609
16924
  "getTask",
16610
16925
  "getTaskChats",
@@ -16727,6 +17042,7 @@ var init_chunk_SVRE6KIM = __esm({
16727
17042
  "deleteMetric",
16728
17043
  "listMetricObservations",
16729
17044
  "getMetricSeries",
17045
+ "getMetricSeriesBatch",
16730
17046
  "computeChatMetrics",
16731
17047
  "listPushSubscriptions",
16732
17048
  "listResourceWorkflows",
@@ -17017,7 +17333,6 @@ var init_chunk_SVRE6KIM = __esm({
17017
17333
  summarizeChat;
17018
17334
  getChatMessages;
17019
17335
  getChatTaskTransitions;
17020
- getChildThreadMessages;
17021
17336
  getChatToolCallMessages;
17022
17337
  getChatTools;
17023
17338
  initiateOutboundCall;
@@ -17225,6 +17540,7 @@ var init_chunk_SVRE6KIM = __esm({
17225
17540
  deleteMetric;
17226
17541
  listMetricObservations;
17227
17542
  getMetricSeries;
17543
+ getMetricSeriesBatch;
17228
17544
  computeChatMetrics;
17229
17545
  // Dashboards API
17230
17546
  getDashboards;
@@ -17418,7 +17734,6 @@ var init_chunk_SVRE6KIM = __esm({
17418
17734
  dismissNotification;
17419
17735
  dismissAllNotifications;
17420
17736
  getResellerWorkspaces;
17421
- createClientWorkspace;
17422
17737
  getClientWorkspace;
17423
17738
  updateClientWorkspace;
17424
17739
  deleteClientWorkspace;
@@ -17454,6 +17769,13 @@ var init_chunk_SVRE6KIM = __esm({
17454
17769
  upsertWidgetDomain;
17455
17770
  deleteWidgetDomain;
17456
17771
  // Org API
17772
+ getOrgManagerCredentialResponse;
17773
+ authorizeOrgManagerDelegation;
17774
+ getOrgManagerChats;
17775
+ createOrgManagerChat;
17776
+ getOrgManagerMessages;
17777
+ startOrgManagerTurn;
17778
+ stopOrgManagerTurn;
17457
17779
  listOrgDomains;
17458
17780
  registerOrgDomain;
17459
17781
  getOrgDomain;
@@ -17528,6 +17850,9 @@ var init_chunk_SVRE6KIM = __esm({
17528
17850
  declineInvitation;
17529
17851
  // Auth API
17530
17852
  getUserAccount;
17853
+ getAccountNotices;
17854
+ viewAccountNotice;
17855
+ dismissAccountNotice;
17531
17856
  updateUserAccount;
17532
17857
  recordAcquisition;
17533
17858
  login;
@@ -17585,6 +17910,11 @@ var init_chunk_SVRE6KIM = __esm({
17585
17910
  getAssignmentTools;
17586
17911
  executeAssignmentTool;
17587
17912
  // Sites API
17913
+ startPublicDemo;
17914
+ endPublicDemo;
17915
+ getPublicDemo;
17916
+ sendPublicDemoMessage;
17917
+ submitPublicDemoForm;
17588
17918
  getSites;
17589
17919
  checkSiteSlugAvailability;
17590
17920
  checkSiteDomainAvailability;
@@ -17592,6 +17922,7 @@ var init_chunk_SVRE6KIM = __esm({
17592
17922
  getSiteSharing;
17593
17923
  updateSiteSharing;
17594
17924
  getSiteSource;
17925
+ getSiteSourceReleases;
17595
17926
  getSiteSourceTemplates;
17596
17927
  createSiteSource;
17597
17928
  buildSiteSource;
@@ -17654,6 +17985,8 @@ var init_chunk_SVRE6KIM = __esm({
17654
17985
  createFolder;
17655
17986
  updateFolder;
17656
17987
  deleteFolder;
17988
+ reindexFile;
17989
+ searchFile;
17657
17990
  reindexFolder;
17658
17991
  searchFolder;
17659
17992
  getFileLabels;
@@ -17710,6 +18043,7 @@ var init_chunk_SVRE6KIM = __esm({
17710
18043
  getWorkflowsOutlineBatch;
17711
18044
  createWorkflow;
17712
18045
  updateWorkflow;
18046
+ uploadWorkflowKnowledge;
17713
18047
  getWorkflowDeletionPreview;
17714
18048
  deleteWorkflow;
17715
18049
  archiveWorkflow;
@@ -17795,6 +18129,7 @@ var init_chunk_SVRE6KIM = __esm({
17795
18129
  getPhoneNumberOutboundAnalyticsSummary;
17796
18130
  getPhoneNumberOutboundAnalyticsCalls;
17797
18131
  exportPhoneNumberOutboundAnalyticsCsv;
18132
+ getPhoneNumberActivity;
17798
18133
  getPhoneNumberMessages;
17799
18134
  getPhoneNumberFaxes;
17800
18135
  getPhoneNumberVoicemails;
@@ -17808,6 +18143,8 @@ var init_chunk_SVRE6KIM = __esm({
17808
18143
  createInbox;
17809
18144
  updateInbox;
17810
18145
  deleteInbox;
18146
+ archiveInbox;
18147
+ getInboxArchiveBlockers;
17811
18148
  getInboxEmails;
17812
18149
  getInboxEmail;
17813
18150
  markEmailAsRead;
@@ -17966,7 +18303,6 @@ var init_chunk_SVRE6KIM = __esm({
17966
18303
  // Discord Bots API
17967
18304
  getDiscordBots;
17968
18305
  getDiscordBot;
17969
- getDiscordBotByUuid;
17970
18306
  createDiscordBot;
17971
18307
  updateDiscordBot;
17972
18308
  deleteDiscordBot;
@@ -18034,6 +18370,7 @@ var init_chunk_SVRE6KIM = __esm({
18034
18370
  fhirGetEncounterSyncRuns;
18035
18371
  fhirRefreshEncounterPatient;
18036
18372
  fhirBackfillEncounterSync;
18373
+ getFhirConnectionSyncConfig;
18037
18374
  getAthenaPlatformApp;
18038
18375
  verifyAthenaAccess;
18039
18376
  connectAthena;
@@ -18133,6 +18470,7 @@ var init_chunk_SVRE6KIM = __esm({
18133
18470
  startSyncRun;
18134
18471
  getSyncRuns;
18135
18472
  getSyncRunItems;
18473
+ getSyncRunItemsPage;
18136
18474
  getMemberSyncSummary;
18137
18475
  getConnectionFieldHomes;
18138
18476
  getInboundRecordStatus;
@@ -18508,10 +18846,10 @@ var init_chunk_6KPGCPGW = __esm({
18508
18846
  var SEARCHABLE_EVENT_RULE_SOURCE_FIELDS, ActivityEventType, EntityKind;
18509
18847
  var init_dist = __esm({
18510
18848
  "../sdk/dist/index.js"() {
18511
- init_chunk_SVRE6KIM();
18849
+ init_chunk_LWRMGN4Z();
18512
18850
  init_chunk_D5VNVTUQ();
18513
18851
  init_chunk_6KPGCPGW();
18514
- init_chunk_GCN4OMYU();
18852
+ init_chunk_RLFS7O2L();
18515
18853
  SEARCHABLE_EVENT_RULE_SOURCE_FIELDS = [
18516
18854
  "taskId",
18517
18855
  "dataTypeId",
@@ -18546,6 +18884,7 @@ var init_dist = __esm({
18546
18884
  chatcall_ended: "chat.call_ended",
18547
18885
  chatsummary: "chat.summary",
18548
18886
  messagesent: "message.sent",
18887
+ messagesend_failed: "message.send_failed",
18549
18888
  membermessage_received: "member.message_received",
18550
18889
  escalationopened: "escalation.opened",
18551
18890
  escalationresolved: "escalation.resolved",
@@ -18553,6 +18892,8 @@ var init_dist = __esm({
18553
18892
  callcompleted: "call.completed",
18554
18893
  callmissed: "call.missed",
18555
18894
  callsummary: "call.summary",
18895
+ callqueued: "call.queued",
18896
+ callnot_placed: "call.not_placed",
18556
18897
  presencewent_online: "presence.went_online",
18557
18898
  presencewent_offline: "presence.went_offline",
18558
18899
  operator_groupmember_added: "operator_group.member_added",
@@ -22932,7 +23273,7 @@ var init_package = __esm({
22932
23273
  "package.json"() {
22933
23274
  package_default = {
22934
23275
  name: "@gravity-rail/cli",
22935
- version: "2.0.0",
23276
+ version: "3.0.1",
22936
23277
  description: "Gravity Rail CLI \u2014 manage workspaces from the command line",
22937
23278
  type: "module",
22938
23279
  bin: {
@@ -22958,7 +23299,8 @@ var init_package = __esm({
22958
23299
  license: "MIT",
22959
23300
  repository: {
22960
23301
  type: "git",
22961
- url: "https://developer.gravityrail.com"
23302
+ url: "git+https://github.com/Gravity-Rail/gravity-team.git",
23303
+ directory: "packages/cli"
22962
23304
  },
22963
23305
  homepage: "https://developer.gravityrail.com",
22964
23306
  keywords: [
@@ -22994,7 +23336,7 @@ var init_package = __esm({
22994
23336
  tsup: "^9.0.0",
22995
23337
  typescript: "^6.0.3",
22996
23338
  "typescript-native": "npm:typescript@7.0.2",
22997
- undici: "6.28.1"
23339
+ undici: "6.29.1"
22998
23340
  }
22999
23341
  };
23000
23342
  }
@@ -25287,6 +25629,10 @@ function readStdinIfPiped(firstByteWaitMs) {
25287
25629
 
25288
25630
  // src/lib/phone-voice.ts
25289
25631
  init_errors();
25632
+ function describeOutboundCallReceipt(receipt) {
25633
+ if (!receipt) return "";
25634
+ return `queued (intent ${receipt.intentUuid}, ${receipt.intentState})`;
25635
+ }
25290
25636
 
25291
25637
  // src/lib.ts
25292
25638
  init_output();
@@ -26111,6 +26457,7 @@ init_output();
26111
26457
  init_cli_utils();
26112
26458
  init_context();
26113
26459
  init_concierge_api();
26460
+ init_errors();
26114
26461
  var COLUMNS2 = [
26115
26462
  COL.id(),
26116
26463
  COL.uuid(),
@@ -26124,6 +26471,13 @@ var COLUMNS2 = [
26124
26471
  { header: "CHANNEL", getValue: (item) => item.channel ?? "" },
26125
26472
  COL.created()
26126
26473
  ];
26474
+ var CREATE_COLUMNS = [
26475
+ ...COLUMNS2,
26476
+ {
26477
+ header: "OUTBOUND_CALL",
26478
+ getValue: (item) => describeOutboundCallReceipt(item.outboundCallReceipt)
26479
+ }
26480
+ ];
26127
26481
  var LABEL_COLUMNS = [
26128
26482
  COL.id(),
26129
26483
  COL.uuid(),
@@ -26275,7 +26629,7 @@ var chatsDomain = {
26275
26629
  entityName: "chat",
26276
26630
  listMethod: "getChats",
26277
26631
  // getMethod omitted — the custom get below takes --id or --uuid
26278
- createMethod: "createChat",
26632
+ // createMethod omitted — the custom create below shows the call receipt
26279
26633
  updateMethod: "updateChat",
26280
26634
  deleteMethod: "deleteChat",
26281
26635
  archiveMethod: "archiveChat",
@@ -26283,8 +26637,23 @@ var chatsDomain = {
26283
26637
  columns: COLUMNS2,
26284
26638
  paginationSupport: "full",
26285
26639
  listArgs: [
26286
- { name: "search", description: "Search by name" },
26640
+ {
26641
+ name: "search",
26642
+ description: "Search chat titles, summaries, message content, participant names, emails and phone numbers"
26643
+ },
26287
26644
  { name: "channel", description: "Filter by channel (phone, sms, web, email)" },
26645
+ {
26646
+ name: "workflow-id",
26647
+ description: "Only chats whose assignment pins any revision of this workflow"
26648
+ },
26649
+ {
26650
+ name: "created-after",
26651
+ description: "Only chats created on or after this ISO-8601 timestamp"
26652
+ },
26653
+ {
26654
+ name: "created-before",
26655
+ description: "Only chats created on or before this ISO-8601 timestamp"
26656
+ },
26288
26657
  {
26289
26658
  name: "is-anonymous",
26290
26659
  description: "Show only anonymous chats (requires CHATS_ADMIN)",
@@ -26298,6 +26667,21 @@ var chatsDomain = {
26298
26667
  }
26299
26668
  ]
26300
26669
  }),
26670
+ {
26671
+ path: ["chats", "create"],
26672
+ description: "Create a chat",
26673
+ mutates: true,
26674
+ requiresWorkspace: true,
26675
+ examples: [
26676
+ `gr chats create -w $WORKSPACE_UUID --data '{"channel":"phone-voice","workflowId":12,"memberId":34}' --allow-write`
26677
+ ],
26678
+ handler: async ({ ctx, workspace, data }) => {
26679
+ if (!data) throw new CLIError("JSON data required (--data, --file, or stdin)");
26680
+ const client3 = requireAuth(ctx).apiClient;
26681
+ const chat = await client3.createChat(workspace, data);
26682
+ outputSingle(chat, ctx, CREATE_COLUMNS);
26683
+ }
26684
+ },
26301
26685
  {
26302
26686
  path: ["chats", "get"],
26303
26687
  description: "Get a chat by ID or UUID",
@@ -26838,7 +27222,7 @@ var chatsDomain = {
26838
27222
 
26839
27223
  // ../sdk/dist/helpers.js
26840
27224
  init_chunk_6KPGCPGW();
26841
- init_chunk_GCN4OMYU();
27225
+ init_chunk_RLFS7O2L();
26842
27226
  new TextEncoder();
26843
27227
  var WORKSPACE_EXPORT_JSON_MEMBER = "export.json";
26844
27228
  var MAX_EXPORT_JSON_BYTES = 8 * 1024 * 1024;
@@ -27999,6 +28383,12 @@ Assistant / models (live on the DRAFT revision \u2014 publish to go live)
27999
28383
  "voiceModel":"xai:voice:ara"}}
28000
28384
  realtimeModelConfig (object|null) Realtime config. Omit on update to keep the
28001
28385
  stored config. null replaces it.
28386
+ enableVoicemailDetection (bool|null) Wait for a voicemail greeting to end on
28387
+ outbound calls (adds 3-5 s on a human
28388
+ pickup). null inherits the workspace
28389
+ phone setting. Omit on update to keep
28390
+ the stored choice; null resets it to
28391
+ inherit.
28002
28392
  copyFromAgentId (number) Copy full assistant settings from an agent
28003
28393
  copyFromWorkflowRevisionId (number) Copy assistant settings from a revision
28004
28394
 
@@ -31245,11 +31635,12 @@ var ACTION_PARAM_HINTS = {
31245
31635
  ]
31246
31636
  },
31247
31637
  "webhook:send": {
31248
- summary: "POST the event payload to a URL",
31638
+ summary: "legacy: existing rules only \u2014 POST the event payload to a URL",
31249
31639
  shape: ['{"webhookUrl":"https://example.com/hook"}'],
31250
31640
  notes: [
31251
- "webhookUrl is required and must be https in production.",
31252
- "signingSecret is generated for you when omitted on create; an update that omits it keeps the stored secret."
31641
+ "New webhook:send rules are refused; set up new integrations under Organization \u2192 Webhooks.",
31642
+ "This shape is for updating an existing rule: webhookUrl must be https in production,",
31643
+ "and an update that omits signingSecret keeps the stored secret."
31253
31644
  ]
31254
31645
  },
31255
31646
  "assistant:message": {
@@ -31302,7 +31693,7 @@ Field reference for --data JSON (create/update):
31302
31693
  Required
31303
31694
  objectType (string) task | routine | journey | workflow | calendar | ...
31304
31695
  eventType (string) e.g. routine:triggered, journey_step:execute, chat:created
31305
- actionType (string) e.g. chat:create, member:label, sms:send, webhook:send
31696
+ actionType (string) e.g. chat:create, member:label, sms:send, email:send
31306
31697
 
31307
31698
  Common optional
31308
31699
  name (string)
@@ -31555,8 +31946,11 @@ ${EVENT_RULE_FIELD_REFERENCE}`,
31555
31946
  "Common eventTypes: journey_step:execute, journey:enrolled, routine:triggered,",
31556
31947
  " task:created, chat:created, data_record:created, member:created",
31557
31948
  "",
31558
- "Common actionTypes: member:label, member:notify, webhook:send, email:send,",
31559
- " sms:send, chat:create, member:upsert",
31949
+ "Common actionTypes: member:label, member:notify, email:send, sms:send,",
31950
+ " chat:create, member:upsert",
31951
+ "",
31952
+ "New webhook:send rules are refused: set up outbound webhooks under",
31953
+ "Organization \u2192 Webhooks. Existing webhook:send rules can still be updated or disabled.",
31560
31954
  "",
31561
31955
  'member:label actionParams: {"addLabelIds":["uuid"],"removeLabelIds":["uuid"]}'
31562
31956
  ]
@@ -31662,8 +32056,8 @@ var createRoutineRuleCmd = {
31662
32056
  { name: "delay", description: "Seconds to wait before running the action (default: 0)" }
31663
32057
  ],
31664
32058
  examples: [
31665
- "Trigger: routine:triggered. Common actions: chat:create, webhook:send,",
31666
- "email:send, member:notify.",
32059
+ "Trigger: routine:triggered. Common actions: chat:create, email:send,",
32060
+ "member:notify.",
31667
32061
  "",
31668
32062
  "Scheduled outbound voice check-in:",
31669
32063
  "gr events rules create-routine-rule -w $WID --allow-write \\",
@@ -31671,12 +32065,12 @@ var createRoutineRuleCmd = {
31671
32065
  ' --workflow-uuid "$(gr workflows get --id 3 -w $WID --jq .uuid)" \\',
31672
32066
  ` --action-params '{"channel":"phone-voice","phoneNumberUUID":"<uuid>"}'`,
31673
32067
  "",
31674
- "Webhook on every fire, only for high-priority members:",
32068
+ "Notify the member on every fire, only for high-priority members:",
31675
32069
  "gr events rules create-routine-rule -w $WID --allow-write \\",
31676
- " --routine-id 12 --action-type webhook:send \\",
31677
- ` --action-params '{"webhookUrl":"https://example.com/hook"}' \\`,
32070
+ " --routine-id 12 --action-type member:notify \\",
32071
+ ` --action-params '{"recipientMode":"target_member","messageTemplate":"Time for your check-in."}' \\`,
31678
32072
  ` --conditions 'member.labels.exists(l, l == "priority")'`,
31679
- ...actionParamExampleLines(["chat:create", "webhook:send", "email:send", "member:notify"]),
32073
+ ...actionParamExampleLines(["chat:create", "email:send", "member:notify"]),
31680
32074
  ...VERIFY_EXAMPLE_LINES
31681
32075
  ],
31682
32076
  handler: async (hctx) => {
@@ -31753,7 +32147,8 @@ var createDataRecordRuleCmd = {
31753
32147
  ],
31754
32148
  examples: [
31755
32149
  "Triggers: data_record:created, data_record:updated. Common actions:",
31756
- "chat:create, webhook:send, email:send, member:label.",
32150
+ "chat:create, email:send, member:label. To tell an external system about",
32151
+ "record changes, use Organization \u2192 Webhooks, not an event rule.",
31757
32152
  "",
31758
32153
  "CEL conditions read record fields as record.data.<fieldname>:",
31759
32154
  "gr events rules create-data-record-rule -w $WID --allow-write \\",
@@ -31762,11 +32157,11 @@ var createDataRecordRuleCmd = {
31762
32157
  " --conditions 'record.data.total_score >= 15' \\",
31763
32158
  ` --action-params '{"recipientMode":"specific_member","memberId":<staff-member-id>,"messageTemplate":"High-risk screening submitted."}'`,
31764
32159
  "",
31765
- "Webhook on every update of the form:",
32160
+ "Label the member on every update of the form:",
31766
32161
  "gr events rules create-data-record-rule -w $WID --allow-write \\",
31767
32162
  " --data-type-id 45 --event-type data_record:updated \\",
31768
- ` --action-type webhook:send --action-params '{"webhookUrl":"https://example.com/hook"}'`,
31769
- ...actionParamExampleLines(["chat:create", "webhook:send", "email:send", "member:label"]),
32163
+ ` --action-type member:label --action-params '{"addLabelIds":["<label-uuid>"]}'`,
32164
+ ...actionParamExampleLines(["chat:create", "email:send", "member:label"]),
31770
32165
  ...VERIFY_EXAMPLE_LINES
31771
32166
  ],
31772
32167
  handler: async (hctx) => {
@@ -32003,18 +32398,19 @@ var experimentsDomain = {
32003
32398
  args: [
32004
32399
  ...LIST_PAGINATION_ARGS,
32005
32400
  {
32006
- name: "include-archived",
32007
- description: "Include archived experiments",
32401
+ name: "archived",
32402
+ description: "List archived experiments instead of active experiments",
32403
+ isFlag: true,
32008
32404
  required: false
32009
32405
  }
32010
32406
  ],
32011
32407
  handler: async ({ ctx, workspace, args }) => {
32012
- const includeArchived = args["include-archived"] === "true";
32408
+ const archived = args.archived === true;
32013
32409
  const pag = parsePaginationArgs(args);
32014
32410
  const result3 = await requireAuth(ctx).apiClient.getExperiments(workspace, {
32015
32411
  ...pag.page ? { page: pag.page } : {},
32016
32412
  ...pag.pageSize ? { pageSize: pag.pageSize } : {},
32017
- includeArchived
32413
+ archived
32018
32414
  });
32019
32415
  outputData(listResult(result3, true), ctx, EXPERIMENT_COLUMNS);
32020
32416
  }
@@ -33500,10 +33896,11 @@ var journeysDomain = {
33500
33896
  mutates: true,
33501
33897
  requiresWorkspace: true,
33502
33898
  examples: [
33503
- `gr journeys create -w $WID --data '{"name":"Onboarding","description":"New patient flow","status":"draft"}'`,
33899
+ `gr journeys create -w $WID --data '{"name":"Onboarding","description":"New patient flow","status":"draft","executionModel":"v2"}'`,
33504
33900
  "",
33505
33901
  "Fields: name (required), description, status (draft|active|paused)",
33506
- " ownerId (member ID), autoEnrollFilterId (legacy filter ID), executionModel (legacy|v2)",
33902
+ " ownerId (member ID), autoEnrollFilterId (legacy filter ID)",
33903
+ " executionModel: v2 (the default when omitted; new legacy Journeys cannot be created)",
33507
33904
  " enrollmentConditions (V2): array of {uuid?, name?, filterId OR memberPredicate}"
33508
33905
  ],
33509
33906
  handler: async ({ ctx, workspace, data }) => {
@@ -34338,6 +34735,13 @@ var metricsDomain = {
34338
34735
  prefix: ["metrics"],
34339
34736
  entityName: "metric",
34340
34737
  listMethod: "listMetrics",
34738
+ listArgs: [
34739
+ {
34740
+ name: "archived",
34741
+ description: "List archived metrics instead of active metrics",
34742
+ isFlag: true
34743
+ }
34744
+ ],
34341
34745
  getMethod: "getMetric",
34342
34746
  createMethod: "createMetric",
34343
34747
  updateMethod: "updateMetric",
@@ -34637,11 +35041,45 @@ function parseMaxBudgetUsd(raw, flagName) {
34637
35041
  var REALTIME_MAX_CONCURRENCY = 4;
34638
35042
  function summarizeCriterionResults(run) {
34639
35043
  if (!run.criterionResults?.length) return void 0;
34640
- return run.criterionResults.map((c) => ({
34641
- name: c.criterionName ?? `criterion-${c.criterionId}`,
34642
- passed: c.passed ?? null,
34643
- score: c.score ?? null
34644
- }));
35044
+ return run.criterionResults.map((c) => {
35045
+ const data = c.evaluationData ?? {};
35046
+ const status = data.status === "skipped" && data.reason === "expression_criterion_failed" ? "skipped" : data.error_type != null || data.error != null ? "grading_error" : c.passed === true ? "passed" : c.passed === false ? "failed" : "not_graded";
35047
+ return {
35048
+ name: c.criterionName ?? `criterion-${c.criterionId}`,
35049
+ passed: c.passed ?? null,
35050
+ score: c.score ?? null,
35051
+ status
35052
+ };
35053
+ });
35054
+ }
35055
+ function batchEvaluationStatus(row) {
35056
+ if (row.batch_skipped) return "skipped";
35057
+ if (row.launch_refused) return "launch_refused";
35058
+ if (isConfigurationBlockerFailure(row.failure_reason)) return "configuration_blocker";
35059
+ if (row.outcome === "instrument_failure") return "instrument_failure";
35060
+ if (row.failure_reason?.startsWith("Grading did not finish:") || row.criterion_results?.some((c) => c.status === "grading_error"))
35061
+ return "grading_error";
35062
+ if (row.error || row.failure_reason) return "execution_error";
35063
+ if (!row.evaluated_at) return "not_evaluated";
35064
+ if (row.passed === true) return "passed";
35065
+ if (row.passed === false) return "criterion_failed";
35066
+ return "not_evaluated";
35067
+ }
35068
+ function qualificationRunDiagnostics(run) {
35069
+ const row = runToBatchRow(
35070
+ { round: 0, warmup: false, scenarioId: run.scenarioId ?? 0, modelId: "" },
35071
+ run.workflowId ?? 0,
35072
+ run
35073
+ );
35074
+ const criterionCounts = {};
35075
+ for (const criterion of row.criterion_results ?? []) {
35076
+ criterionCounts[criterion.status] = (criterionCounts[criterion.status] ?? 0) + 1;
35077
+ }
35078
+ return { evaluationStatus: batchEvaluationStatus(row), criterionCounts };
35079
+ }
35080
+ function isLaunchRefusal(error) {
35081
+ if (typeof error !== "object" || error === null || !("statusCode" in error)) return false;
35082
+ return [400, 401, 403, 404, 409, 422].includes(Number(error.statusCode));
34645
35083
  }
34646
35084
  function formatRevisionLabel(row) {
34647
35085
  const pin = row.workflow_revision_pinned ? "(pinned)" : "";
@@ -34676,6 +35114,8 @@ function runToBatchRow(job, workflowId, run, error, batchLabel, pinnedRevisionId
34676
35114
  assistant_realtime_model_id: run?.assistantRealtimeModelId ?? null,
34677
35115
  error,
34678
35116
  failure_reason: run?.failureReason ?? null,
35117
+ simulated_datetime: run?.simulatedDatetime ?? null,
35118
+ simulated_timezone: run?.simulatedTimezone ?? null,
34679
35119
  passed: run?.passed ?? null,
34680
35120
  overall_score: run?.overallScore ?? null,
34681
35121
  timing_summary: run?.timingSummary ?? null,
@@ -34712,13 +35152,13 @@ async function waitForRunTerminal(api, workspace, runId, timeoutMs, pollMs, slee
34712
35152
  }
34713
35153
  throw new BatchWaitTimeoutError(`Timed out waiting for run ${runId} to complete`, lastPolled);
34714
35154
  }
34715
- async function waitForEvaluation(api, workspace, runId, timeoutMs, pollMs, sleep) {
35155
+ async function waitForEvaluation(api, workspace, runId, timeoutMs, pollMs, sleep, previousEvaluatedAt, previousFailureReason) {
34716
35156
  let lastPolled;
34717
35157
  const deadline = Date.now() + timeoutMs;
34718
35158
  while (Date.now() < deadline) {
34719
35159
  const run = await api.getTestChatRun(workspace, runId);
34720
35160
  lastPolled = run;
34721
- if (run.evaluatedAt) {
35161
+ if (run.evaluatedAt && run.evaluatedAt !== previousEvaluatedAt || run.failureReason?.startsWith("Grading did not finish:") && run.failureReason !== previousFailureReason) {
34722
35162
  return run;
34723
35163
  }
34724
35164
  if (run.failedAt) {
@@ -34732,10 +35172,11 @@ function formatBatchProgressLine(job, row) {
34732
35172
  const ttftP50 = row.timing_summary && typeof row.timing_summary === "object" && row.timing_summary.ttft_ms && typeof row.timing_summary.ttft_ms === "object" && "p50" in row.timing_summary.ttft_ms ? String(row.timing_summary.ttft_ms.p50) : "-";
34733
35173
  const cfg = isConfigurationBlockerFailure(row.failure_reason) ? " CONFIG_BLOCKER" : "";
34734
35174
  const skipped = row.batch_skipped ? " SKIPPED" : "";
34735
- return `r${job.round} ${job.modelId} scenario=${job.scenarioId} rev=${formatRevisionLabel(row)} run=${row.run_id ?? "ERR"} passed=${row.passed ?? "-"} score=${row.overall_score != null ? row.overall_score.toFixed(2) : "-"} ttft_p50=${ttftP50}ms${row.error ? ` [${formatProgressError(row.error)}]` : ""}${cfg}${skipped}${job.warmup ? " WARM" : ""}`;
35175
+ return `r${job.round} ${job.modelId} scenario=${job.scenarioId} rev=${formatRevisionLabel(row)} run=${row.run_id ?? "ERR"} lane=${row.lane ?? "?"} status=${row.evaluation_status ?? batchEvaluationStatus(row)} passed=${row.passed ?? "-"} ` + (row.evaluation_request ? `evaluation=${row.evaluation_request} ` : "") + `score=${row.overall_score != null ? row.overall_score.toFixed(2) : "-"} ttft_p50=${ttftP50}ms${row.error ? ` [${formatProgressError(row.error, 60)}]` : ""}${cfg}${skipped}${job.warmup ? " WARM" : ""}`;
34736
35176
  }
34737
35177
  async function executeModelEvalJob(api, options, job, waitTimeoutMs, pollMs, sleep) {
34738
35178
  let run;
35179
+ let evaluationRequest;
34739
35180
  try {
34740
35181
  const started = await api.startTestChatRun(options.workspace, options.workflowId, {
34741
35182
  scenarioId: job.scenarioId,
@@ -34746,6 +35187,7 @@ async function executeModelEvalJob(api, options, job, waitTimeoutMs, pollMs, sle
34746
35187
  ...options.realtimeConfig ? { assistantRealtimeModelConfig: options.realtimeConfig } : {}
34747
35188
  } : { assistantChatModelId: job.modelId }
34748
35189
  });
35190
+ run = started.run;
34749
35191
  run = await waitForRunTerminal(
34750
35192
  api,
34751
35193
  options.workspace,
@@ -34755,35 +35197,49 @@ async function executeModelEvalJob(api, options, job, waitTimeoutMs, pollMs, sle
34755
35197
  sleep
34756
35198
  );
34757
35199
  if (options.evaluate && run.completedAt && !run.failedAt) {
34758
- await api.evaluateTestChatRun(options.workspace, run.id);
34759
- run = await waitForEvaluation(
34760
- api,
34761
- options.workspace,
34762
- run.id,
34763
- waitTimeoutMs,
34764
- pollMs,
34765
- sleep
34766
- );
35200
+ const previousEvaluatedAt = run.evaluatedAt;
35201
+ const previousFailureReason = run.failureReason;
35202
+ const response = await api.evaluateTestChatRun(options.workspace, run.id);
35203
+ evaluationRequest = response?.alreadyEvaluated ? "retained_existing_grade" : "requested";
35204
+ if (!response?.alreadyEvaluated) {
35205
+ run = await waitForEvaluation(
35206
+ api,
35207
+ options.workspace,
35208
+ run.id,
35209
+ waitTimeoutMs,
35210
+ pollMs,
35211
+ sleep,
35212
+ previousEvaluatedAt,
35213
+ previousFailureReason
35214
+ );
35215
+ }
34767
35216
  }
34768
- return runToBatchRow(
34769
- job,
34770
- options.workflowId,
34771
- run,
34772
- void 0,
34773
- options.batchLabel,
34774
- options.workflowRevisionId
34775
- );
35217
+ return {
35218
+ ...runToBatchRow(
35219
+ job,
35220
+ options.workflowId,
35221
+ run,
35222
+ void 0,
35223
+ options.batchLabel,
35224
+ options.workflowRevisionId
35225
+ ),
35226
+ ...evaluationRequest ? { evaluation_request: evaluationRequest } : {}
35227
+ };
34776
35228
  } catch (e) {
34777
35229
  const message = e instanceof Error ? e.message : String(e);
34778
35230
  const lastKnown = (e instanceof BatchWaitTimeoutError ? e.lastPolledRun : void 0) ?? run ?? null;
34779
- return runToBatchRow(
34780
- job,
34781
- options.workflowId,
34782
- lastKnown,
34783
- message,
34784
- options.batchLabel,
34785
- options.workflowRevisionId
34786
- );
35231
+ return {
35232
+ ...runToBatchRow(
35233
+ job,
35234
+ options.workflowId,
35235
+ lastKnown,
35236
+ message,
35237
+ options.batchLabel,
35238
+ options.workflowRevisionId
35239
+ ),
35240
+ ...!run && isLaunchRefusal(e) ? { launch_refused: true } : {},
35241
+ ...evaluationRequest ? { evaluation_request: evaluationRequest } : {}
35242
+ };
34787
35243
  }
34788
35244
  }
34789
35245
  function createSpacingGate(spacingSec, sleep) {
@@ -34823,6 +35279,9 @@ async function executeModelEvalBatch(api, options) {
34823
35279
  `);
34824
35280
  }
34825
35281
  };
35282
+ emitProgress(
35283
+ `Batch: ${jobs.length} run(s), Workflow ${options.workflowId}, revision ${options.workflowRevisionId != null ? `id${options.workflowRevisionId} (pinned)` : "active at each launch (use --workflow-revision-id for a fixed comparison)"}.`
35284
+ );
34826
35285
  const realtimeJobCount = jobs.filter((j) => j.realtime).length;
34827
35286
  let concurrency = options.concurrency ?? 1;
34828
35287
  if (realtimeJobCount > 0 && concurrency > REALTIME_MAX_CONCURRENCY) {
@@ -34844,6 +35303,7 @@ async function executeModelEvalBatch(api, options) {
34844
35303
  }
34845
35304
  }
34846
35305
  const recordRow = (job, row) => {
35306
+ row.evaluation_status = batchEvaluationStatus(row);
34847
35307
  rows.push(row);
34848
35308
  if (options.outPath) {
34849
35309
  appendFileSync(options.outPath, `${JSON.stringify(row)}
@@ -34868,16 +35328,16 @@ async function executeModelEvalBatch(api, options) {
34868
35328
  return makeSkippedRow(job);
34869
35329
  }
34870
35330
  const row = await executeModelEvalJob(api, options, job, waitTimeoutMs, pollMs, sleep);
34871
- if (isConfigurationBlockerFailure(row.failure_reason)) {
35331
+ if (row.launch_refused || isConfigurationBlockerFailure(row.failure_reason)) {
34872
35332
  stopBatch = true;
34873
35333
  }
34874
- if (job.realtime && !row.batch_skipped) {
35334
+ if (job.realtime && !row.batch_skipped && !row.launch_refused) {
34875
35335
  actualSpendUsd += actualRealtimeRowCostUsd(row, job.modelId);
34876
35336
  if (options.maxBudgetUsd != null && actualSpendUsd >= options.maxBudgetUsd && !stopBatch) {
34877
35337
  stopBatch = true;
34878
35338
  budgetStopped = true;
34879
35339
  emitProgress(
34880
- `realtime budget: actual spend ~$${actualSpendUsd.toFixed(2)} reached cap $${options.maxBudgetUsd.toFixed(2)} \u2014 stopping dispatch`
35340
+ `realtime budget: attributed spend ~$${actualSpendUsd.toFixed(2)} reached cap $${options.maxBudgetUsd.toFixed(2)} \u2014 stopping dispatch`
34881
35341
  );
34882
35342
  }
34883
35343
  }
@@ -34898,7 +35358,14 @@ async function executeModelEvalBatch(api, options) {
34898
35358
  }
34899
35359
  } else {
34900
35360
  const results = new Array(jobs.length);
34901
- let nextIndex = 0;
35361
+ const firstJob = jobs[0];
35362
+ if (firstJob) {
35363
+ emitProgress("Checking the first run before parallel dispatch (no extra test run).");
35364
+ const firstRow = await runOne(firstJob);
35365
+ results[0] = firstRow;
35366
+ recordRow(firstJob, firstRow);
35367
+ }
35368
+ let nextIndex = 1;
34902
35369
  const worker = async () => {
34903
35370
  while (true) {
34904
35371
  if (stopBatch) {
@@ -34932,7 +35399,45 @@ async function executeModelEvalBatch(api, options) {
34932
35399
  }
34933
35400
  }
34934
35401
  if (realtimeJobCount > 0) {
34935
- emitProgress(`realtime budget: total actual spend ~$${actualSpendUsd.toFixed(2)}`);
35402
+ emitProgress(
35403
+ `realtime budget: total attributed spend ~$${actualSpendUsd.toFixed(2)} (measured duration where available; estimated otherwise)`
35404
+ );
35405
+ }
35406
+ const counts = rows.reduce((result3, row) => {
35407
+ const status = row.evaluation_status ?? batchEvaluationStatus(row);
35408
+ result3[status] = (result3[status] ?? 0) + 1;
35409
+ return result3;
35410
+ }, {});
35411
+ emitProgress(
35412
+ `Batch results: ${Object.entries(counts).map(([status, count]) => `${status}=${count}`).join(" ")}. Criterion failures are not necessarily model defects.`
35413
+ );
35414
+ const criteria = rows.flatMap((row) => row.criterion_results ?? []);
35415
+ if (criteria.length) {
35416
+ const criterionCounts = criteria.reduce((result3, criterion) => {
35417
+ result3[criterion.status] = (result3[criterion.status] ?? 0) + 1;
35418
+ return result3;
35419
+ }, {});
35420
+ emitProgress(
35421
+ `Criteria: ${Object.entries(criterionCounts).map(([status, count]) => `${status}=${count}`).join(
35422
+ " "
35423
+ )}. Inspect individual criteria; runtime/setup checks can fail independently of the Agent.`
35424
+ );
35425
+ }
35426
+ const skippedCriteria = criteria.filter((c) => c.status === "skipped").length;
35427
+ if (skippedCriteria)
35428
+ emitProgress(
35429
+ `Rubric criteria skipped after expression failure: ${skippedCriteria}; these are not failing grades.`
35430
+ );
35431
+ if (rows.some((row) => row.simulated_datetime)) {
35432
+ emitProgress(
35433
+ "Simulated time does not change external service clocks. Verify captured routing time separately."
35434
+ );
35435
+ }
35436
+ const refusalRow = rows.find((row) => row.launch_refused);
35437
+ if (refusalRow) {
35438
+ throw new CLIError(
35439
+ `Batch stopped: the API refused a run before launch. Check the scenario persona Member role or the workspace default role, request permissions, and Workflow/model settings. No role or permission was changed. Remaining jobs were not started. Last refusal: ${formatProgressError(refusalRow.error ?? "", 200)}`
35440
+ );
34936
35441
  }
34937
35442
  const blockerRow = rows.find((r) => isConfigurationBlockerFailure(r.failure_reason));
34938
35443
  if (blockerRow) {
@@ -34989,6 +35494,16 @@ var RUN_COLUMNS = [
34989
35494
  header: "DRIVER",
34990
35495
  getValue: (item) => item.driverMemberId == null ? "auto" : item.driverMemberName ?? `member #${item.driverMemberId}`
34991
35496
  },
35497
+ { header: "STATUS", getValue: (item) => item.evaluationStatus ?? "" },
35498
+ {
35499
+ header: "MODEL",
35500
+ getValue: (item) => item.assistantRealtimeModelId ?? item.assistantChatModelId ?? ""
35501
+ },
35502
+ {
35503
+ header: "REVISION",
35504
+ getValue: (item) => String(item.workflowRevisionNumber ?? item.workflowRevisionId ?? "")
35505
+ },
35506
+ { header: "LANE", getValue: (item) => item.lane ?? "" },
34992
35507
  { header: "STARTED", getValue: (item) => item.startedAt ?? "" },
34993
35508
  { header: "COMPLETED", getValue: (item) => item.completedAt ?? "" },
34994
35509
  {
@@ -35133,7 +35648,14 @@ var qualificationsDomain = {
35133
35648
  ...assistantChatModelId ? { assistantChatModelId } : {}
35134
35649
  }
35135
35650
  );
35136
- outputData(result3, ctx, RUN_COLUMNS);
35651
+ outputData(
35652
+ result3.map((run) => ({
35653
+ ...run,
35654
+ ...qualificationRunDiagnostics(run)
35655
+ })),
35656
+ ctx,
35657
+ RUN_COLUMNS
35658
+ );
35137
35659
  }
35138
35660
  },
35139
35661
  {
@@ -35146,7 +35668,7 @@ var qualificationsDomain = {
35146
35668
  workspace,
35147
35669
  requireNumber(args, "id")
35148
35670
  );
35149
- outputSingle(result3, ctx);
35671
+ outputSingle({ ...result3, ...qualificationRunDiagnostics(result3) }, ctx);
35150
35672
  }
35151
35673
  },
35152
35674
  {
@@ -35263,11 +35785,12 @@ var qualificationsDomain = {
35263
35785
  requiresWorkspace: true,
35264
35786
  args: [{ name: "id", description: "Test chat run ID", required: true }],
35265
35787
  handler: async ({ ctx, workspace, args }) => {
35266
- await requireAuth(ctx).apiClient.evaluateTestChatRun(
35788
+ const result3 = await requireAuth(ctx).apiClient.evaluateTestChatRun(
35267
35789
  workspace,
35268
35790
  requireNumber(args, "id")
35269
35791
  );
35270
- process.stdout.write(`Evaluation started for test chat run ${args["id"]}
35792
+ const message = result3.alreadyEvaluated ? `Test chat run ${args["id"]} is already evaluated; its stored grade is unchanged.` : `Evaluation requested for test chat run ${args["id"]}.`;
35793
+ process.stdout.write(`${message}
35271
35794
  `);
35272
35795
  }
35273
35796
  },
@@ -36879,9 +37402,9 @@ function buildQueryRequest(args, now) {
36879
37402
  if (groupBy) request.groupBy = groupBy;
36880
37403
  const eventTypes = parseEventTypes(args);
36881
37404
  if (eventTypes.length > 0) request.eventTypes = eventTypes;
36882
- const subject = parseSubject(args);
36883
- if (subject) {
36884
- request.subject = subject;
37405
+ const subject2 = parseSubject(args);
37406
+ if (subject2) {
37407
+ request.subject = subject2;
36885
37408
  if (!request.grain) request.grain = ActivityGrain.event;
36886
37409
  }
36887
37410
  const scope = parseScope(args);
@@ -37849,7 +38372,7 @@ var COLUMNS16 = [
37849
38372
  { header: "PREFIX", getValue: (item) => item.prefix ?? "" },
37850
38373
  COL.created()
37851
38374
  ];
37852
- var CREATE_COLUMNS = [
38375
+ var CREATE_COLUMNS2 = [
37853
38376
  COL.id(),
37854
38377
  COL.name(),
37855
38378
  { header: "KEY", getValue: (item) => item.key ?? "" },
@@ -37876,7 +38399,7 @@ var apiKeysDomain = {
37876
38399
  requiresWorkspace: true,
37877
38400
  handler: async ({ ctx, workspace, data }) => {
37878
38401
  const result3 = await requireAuth(ctx).apiClient.createApiKey(workspace, data);
37879
- outputSingle(result3, ctx, CREATE_COLUMNS);
38402
+ outputSingle(result3, ctx, CREATE_COLUMNS2);
37880
38403
  if (ctx.outputFormat === "table") {
37881
38404
  process.stdout.write("\n\u26A0 This key will not be shown again. Copy it now.\n");
37882
38405
  }
@@ -37911,7 +38434,7 @@ var apiKeysDomain = {
37911
38434
  requiresWorkspace: false,
37912
38435
  handler: async ({ ctx, data }) => {
37913
38436
  const result3 = await requireAuth(ctx).apiClient.createGlobalApiKey(data);
37914
- outputSingle(result3, ctx, CREATE_COLUMNS);
38437
+ outputSingle(result3, ctx, CREATE_COLUMNS2);
37915
38438
  if (ctx.outputFormat === "table") {
37916
38439
  process.stdout.write("\n\u26A0 This key will not be shown again. Copy it now.\n");
37917
38440
  }
@@ -38795,6 +39318,10 @@ var inboxesDomain = {
38795
39318
  createMethod: "createInbox",
38796
39319
  updateMethod: "updateInbox",
38797
39320
  deleteMethod: "deleteInbox",
39321
+ // One-way, like a phone number: the inbox leaves the Active list,
39322
+ // refuses new mail, and keeps its emails. Delete stays the verb that
39323
+ // finally removes it.
39324
+ archiveMethod: "archiveInbox",
38798
39325
  columns: COLUMNS19
38799
39326
  }),
38800
39327
  {
@@ -39243,6 +39770,131 @@ var operatorGroupsDomain = {
39243
39770
  ]
39244
39771
  };
39245
39772
 
39773
+ // src/domains/org-billing.ts
39774
+ init_context();
39775
+ init_errors();
39776
+ init_output();
39777
+ async function subject(hctx) {
39778
+ const auth = requireAuth(hctx.ctx);
39779
+ const billing = await auth.apiClient.getOrgBillingCustomer(requireOrgRef(hctx.args));
39780
+ if (!billing.hasAccess || !billing.customerUuid || !billing.subscriptionId) {
39781
+ throw new CLIError("A billing role on this organization\u2019s billing customer is required");
39782
+ }
39783
+ return { auth, billing };
39784
+ }
39785
+ var orgBillingCommands = [
39786
+ {
39787
+ path: ["org", "billing", "get"],
39788
+ description: "Read only this organization\u2019s billable subscription",
39789
+ args: [ORG_UUID_ARG],
39790
+ handler: async (hctx) => {
39791
+ const { auth, billing } = await subject(hctx);
39792
+ outputSingle(
39793
+ await auth.apiClient.getMyCustomerSubscriptions(billing.customerUuid, {
39794
+ subscriptionId: billing.subscriptionId,
39795
+ pageSize: 1
39796
+ }),
39797
+ hctx.ctx
39798
+ );
39799
+ }
39800
+ },
39801
+ {
39802
+ path: ["org", "billing", "update"],
39803
+ description: "Update this organization\u2019s subscription credit settings (billing owner required)",
39804
+ args: [ORG_UUID_ARG],
39805
+ mutates: true,
39806
+ acceptsJsonInput: true,
39807
+ handler: async (hctx) => {
39808
+ const { auth, billing } = await subject(hctx);
39809
+ if (!hctx.data || typeof hctx.data !== "object" || Array.isArray(hctx.data))
39810
+ throw new CLIError("Provide credit settings as a JSON object with --data");
39811
+ outputSingle(
39812
+ await auth.apiClient.updateSubscription(billing.subscriptionId, hctx.data),
39813
+ hctx.ctx
39814
+ );
39815
+ }
39816
+ },
39817
+ {
39818
+ path: ["org", "billing", "purchase-credits"],
39819
+ description: "Purchase extra credits for this organization (charges the billing owner\u2019s payment method)",
39820
+ args: [
39821
+ ORG_UUID_ARG,
39822
+ { name: "amount-cents", description: "Amount to charge in cents", required: true },
39823
+ {
39824
+ name: "idempotency-key",
39825
+ description: "Stable operation key to prevent a duplicate charge"
39826
+ }
39827
+ ],
39828
+ mutates: true,
39829
+ handler: async (hctx) => {
39830
+ const { auth, billing } = await subject(hctx);
39831
+ const amount = Number(hctx.args["amount-cents"]);
39832
+ if (!Number.isInteger(amount) || amount < 100 || amount > 1e7)
39833
+ throw new CLIError("Use an integer amount between 100 and 10000000 cents");
39834
+ outputSingle(
39835
+ await auth.apiClient.purchaseCredits(
39836
+ billing.subscriptionId,
39837
+ amount,
39838
+ hctx.args["idempotency-key"]
39839
+ ),
39840
+ hctx.ctx
39841
+ );
39842
+ }
39843
+ }
39844
+ ];
39845
+
39846
+ // src/domains/org-api.ts
39847
+ init_context();
39848
+ init_errors();
39849
+ init_output();
39850
+ var orgApiCommands = [
39851
+ {
39852
+ path: ["org", "api"],
39853
+ description: "Call an organization management endpoint. --path is relative to /o/{org}. Use the same method and JSON body as the org UI. Covers members, invitations, workspaces, brands/campaigns, phone numbers, domains, SSO, connectors, billing policy and webhooks. Workspace data and credential changes keep their existing authorization gates.",
39854
+ args: [
39855
+ ORG_UUID_ARG,
39856
+ {
39857
+ name: "path",
39858
+ description: "Org-relative API path, e.g. /members or /a2p-brands",
39859
+ required: true
39860
+ },
39861
+ { name: "method", description: "GET, POST, PUT, PATCH or DELETE", default: "GET" }
39862
+ ],
39863
+ mutates: true,
39864
+ acceptsJsonInput: true,
39865
+ examples: [
39866
+ "gr org api --org $ORG_UUID --path /members --allow-write",
39867
+ `gr org api --org $ORG_UUID --path /invitations --method POST --data '{"email":"colleague@example.test","role":"member"}' --allow-write`
39868
+ ],
39869
+ handler: async ({ ctx, args, data }) => {
39870
+ const auth = requireAuth(ctx);
39871
+ const method = String(args.method).toUpperCase();
39872
+ if (!["GET", "POST", "PUT", "PATCH", "DELETE"].includes(method)) {
39873
+ throw new CLIError("Use GET, POST, PUT, PATCH or DELETE");
39874
+ }
39875
+ const org = encodeURIComponent(requireOrgRef(args));
39876
+ const path4 = String(args.path);
39877
+ const prefix = `/api/v2/o/${org}`;
39878
+ const base = new URL(auth.envConfig.apiUrl);
39879
+ const url = new URL(`${prefix}${path4}`, base);
39880
+ if (!path4.startsWith("/") || path4.startsWith("//") || path4.includes("\\") || /%(?:2e|2f|5c)/i.test(path4.split("?")[0] ?? "") || url.origin !== base.origin || url.pathname !== prefix && !url.pathname.startsWith(prefix + "/")) {
39881
+ throw new CLIError("Use a path within this organization");
39882
+ }
39883
+ const response = await fetch(url, {
39884
+ method,
39885
+ redirect: "error",
39886
+ headers: {
39887
+ Authorization: `Bearer ${auth.accessToken}`,
39888
+ "Content-Type": "application/json"
39889
+ },
39890
+ ...data !== void 0 && method !== "GET" ? { body: JSON.stringify(data) } : {}
39891
+ });
39892
+ if (!response.ok) throw new CLIError(`Organization request failed (${response.status})`);
39893
+ outputSingle(response.status === 204 ? { success: true } : await response.json(), ctx);
39894
+ }
39895
+ }
39896
+ ];
39897
+
39246
39898
  // src/domains/org.ts
39247
39899
  init_dist();
39248
39900
  init_context();
@@ -39453,7 +40105,7 @@ var ORG_MEMBER_ID_ARG = {
39453
40105
  };
39454
40106
  var ORG_MEMBER_ROLE_ARG = {
39455
40107
  name: "role",
39456
- description: "New role: member, admin, owner, or platform_support"
40108
+ description: "New role: member, developer, admin, owner, or platform_support"
39457
40109
  };
39458
40110
  var ORG_MEMBER_NAME_ARG = {
39459
40111
  name: "name",
@@ -40311,6 +40963,8 @@ var orgDomain = {
40311
40963
  name: "org",
40312
40964
  description: "Organization membership, domains, webhook endpoints, and workspace labels",
40313
40965
  commands: [
40966
+ ...orgApiCommands,
40967
+ ...orgBillingCommands,
40314
40968
  {
40315
40969
  path: ["org", "list"],
40316
40970
  description: "List my organizations",
@@ -40347,6 +41001,7 @@ init_errors();
40347
41001
  init_output();
40348
41002
  var LEGAL_ENTITY_COLUMNS = [
40349
41003
  { header: "UUID", getValue: (e) => e.uuid ?? "" },
41004
+ { header: "LABEL", getValue: (e) => e.displayName ?? e.legalName ?? "" },
40350
41005
  { header: "LEGAL NAME", getValue: (e) => e.legalName ?? "" },
40351
41006
  { header: "PRIMARY", getValue: (e) => e.isPrimary ? "yes" : "" },
40352
41007
  { header: "ID TYPE", getValue: (e) => e.registrationIdentifierType ?? "" },
@@ -40430,12 +41085,13 @@ var commands2 = [
40430
41085
  },
40431
41086
  {
40432
41087
  path: ["org", "legal-entities", "create"],
40433
- description: "Create a legal entity (its business profile is filled in separately)",
41088
+ description: "Create a legal entity (its business profile is filled in separately). displayName defaults to legalName; give a second entity for the same business (another region) a distinct label.",
40434
41089
  mutates: true,
40435
41090
  requiresWorkspace: false,
40436
41091
  args: [ORG_UUID_ARG],
40437
41092
  examples: [
40438
- `yarn gr org legal-entities create --org-uuid $ORG_UUID --data '{"legalName":"Acme Health"}' --allow-write`
41093
+ `yarn gr org legal-entities create --org-uuid $ORG_UUID --data '{"legalName":"Acme Health"}' --allow-write`,
41094
+ `yarn gr org legal-entities create --org-uuid $ORG_UUID --data '{"legalName":"Leapcure","displayName":"Leapcure (Australia)"}' --allow-write`
40439
41095
  ],
40440
41096
  handler: async (hctx) => {
40441
41097
  const result3 = await requireAuth(hctx.ctx).apiClient.createLegalEntity(
@@ -40618,11 +41274,14 @@ var commands3 = [
40618
41274
  { name: "org-uuid", aliases: ["org"], description: "Organization UUID", required: true },
40619
41275
  {
40620
41276
  name: "country",
40621
- description: "ISO country code, e.g. US, AU, GB (default: US)",
41277
+ description: "Country: US or AU (default: US)",
40622
41278
  default: "US"
40623
41279
  },
40624
- { name: "number-type", description: "Number type: local or toll_free", default: "local" },
40625
- { name: "area-code", description: "Area code filter" },
41280
+ {
41281
+ name: "number-type",
41282
+ description: "US: local or toll_free (default: local); AU: mobile (default: mobile)"
41283
+ },
41284
+ { name: "area-code", description: "US local area code filter" },
40626
41285
  { name: "contains", description: "Phone number pattern to match" },
40627
41286
  { name: "limit", description: "Maximum results (default: 20)" }
40628
41287
  ],
@@ -40630,9 +41289,10 @@ var commands3 = [
40630
41289
  columns: AVAILABLE_PHONE_COLUMNS,
40631
41290
  handler: async (hctx) => {
40632
41291
  const orgUuid = requireOrgRef(hctx.args);
41292
+ const country = hctx.args.country ?? "US";
40633
41293
  const result3 = await getOrgApi(hctx).searchPhoneNumbers(orgUuid, {
40634
- country: hctx.args.country ?? "US",
40635
- numberType: hctx.args["number-type"] ?? "local",
41294
+ country,
41295
+ numberType: hctx.args["number-type"] ?? (country.toUpperCase() === "AU" ? "mobile" : "local"),
40636
41296
  areaCode: hctx.args["area-code"],
40637
41297
  contains: hctx.args.contains,
40638
41298
  limit: hctx.args.limit ? Number(hctx.args.limit) : void 0
@@ -40647,19 +41307,26 @@ var commands3 = [
40647
41307
  args: [
40648
41308
  { name: "org-uuid", aliases: ["org"], description: "Organization UUID", required: true },
40649
41309
  { name: "phone-number", description: "E.164 phone number to purchase", required: true },
40650
- { name: "number-type", description: "Number type: local or toll_free", default: "local" },
41310
+ {
41311
+ name: "number-type",
41312
+ description: "US: local or toll_free (default: local); AU: mobile (default: mobile)"
41313
+ },
40651
41314
  {
40652
41315
  name: "country",
40653
- description: "ISO country code of the number, e.g. US, AU (default: US)",
41316
+ description: "Country: US or AU (default: US)",
40654
41317
  default: "US"
40655
41318
  },
41319
+ {
41320
+ name: "legal-entity",
41321
+ description: "Approved business UUID for Australian mobile numbers"
41322
+ },
40656
41323
  {
40657
41324
  name: "bundle-sid",
40658
- description: "Twilio regulatory bundle SID (BUxxxx) \u2014 required for regulated countries like AU"
41325
+ description: "Twilio regulatory bundle SID (BUxxxx); not accepted for AU, use --legal-entity"
40659
41326
  },
40660
41327
  {
40661
41328
  name: "address-sid",
40662
- description: "Twilio address SID (ADxxxx) \u2014 required alongside the bundle for regulated countries"
41329
+ description: "Twilio address SID (ADxxxx); not accepted for AU, use --legal-entity"
40663
41330
  }
40664
41331
  ],
40665
41332
  requiresWorkspace: false,
@@ -40668,13 +41335,15 @@ var commands3 = [
40668
41335
  const orgUuid = requireOrgRef(hctx.args);
40669
41336
  const phoneNumber = hctx.args["phone-number"];
40670
41337
  if (!phoneNumber) throw new CLIError("Missing required argument: --phone-number");
40671
- const numberType = hctx.args["number-type"] ?? "local";
41338
+ const country = hctx.args.country ?? "US";
41339
+ const numberType = hctx.args["number-type"] ?? (country.toUpperCase() === "AU" ? "mobile" : "local");
40672
41340
  const result3 = await getOrgApi(hctx).purchasePhoneNumber(
40673
41341
  orgUuid,
40674
41342
  phoneNumber,
40675
41343
  numberType,
40676
41344
  {
40677
- country: hctx.args.country ?? "US",
41345
+ country,
41346
+ legalEntityUuid: hctx.args["legal-entity"],
40678
41347
  bundleSid: hctx.args["bundle-sid"],
40679
41348
  addressSid: hctx.args["address-sid"]
40680
41349
  }
@@ -45868,6 +46537,44 @@ var COLUMNS31 = [
45868
46537
  { header: "URL", getValue: (item) => item.baseUrl ?? "" },
45869
46538
  COL.status()
45870
46539
  ];
46540
+ var COLUMNS_WITH_SYNC_STATE = [
46541
+ ...COLUMNS31,
46542
+ {
46543
+ header: "LAST SYNC OK",
46544
+ getValue: (item) => item.syncState?.lastSuccessfulAt ?? ""
46545
+ },
46546
+ {
46547
+ header: "SYNC STATUS",
46548
+ getValue: (item) => item.syncState?.lastStatus ?? ""
46549
+ }
46550
+ ];
46551
+ var SYNC_CONFIG_COLUMNS = [
46552
+ { header: "SYNC KEY", getValue: (config) => config.syncKey ?? "default" },
46553
+ {
46554
+ header: "POLL (MIN)",
46555
+ getValue: (config) => config.inboundPollIntervalMinutes == null ? "" : String(config.inboundPollIntervalMinutes)
46556
+ },
46557
+ {
46558
+ header: "LAST ATTEMPTED",
46559
+ getValue: (config) => config.connectionParams?.ecwEncounterSyncState?.lastAttemptedAt ?? ""
46560
+ },
46561
+ {
46562
+ header: "LAST SUCCESSFUL",
46563
+ getValue: (config) => config.connectionParams?.ecwEncounterSyncState?.lastSuccessfulAt ?? ""
46564
+ },
46565
+ {
46566
+ header: "STATUS",
46567
+ getValue: (config) => config.connectionParams?.ecwEncounterSyncState?.lastStatus ?? ""
46568
+ },
46569
+ {
46570
+ header: "LAST ERROR",
46571
+ getValue: (config) => config.connectionParams?.ecwEncounterSyncState?.lastError ?? ""
46572
+ },
46573
+ {
46574
+ header: "PATIENT REFRESH",
46575
+ getValue: (config) => config.connectionParams?.ecwEncounterSyncState?.lastPatientRefreshStatus ?? ""
46576
+ }
46577
+ ];
45871
46578
  function summarizeReasons(collections, key) {
45872
46579
  if (!collections?.length) return "";
45873
46580
  const parts = [];
@@ -45909,13 +46616,61 @@ var fhirConnectionsDomain = {
45909
46616
  prefix: ["fhir-connections"],
45910
46617
  entityName: "FHIR connection",
45911
46618
  listMethod: "getFhirConnections",
45912
- getMethod: "getFhirConnection",
45913
46619
  createMethod: "createFhirConnection",
45914
46620
  updateMethod: "updateFhirConnection",
45915
46621
  deleteMethod: "deleteFhirConnection",
45916
46622
  columns: COLUMNS31,
45917
46623
  paginationSupport: "full"
45918
46624
  }),
46625
+ {
46626
+ path: ["fhir-connections", "get"],
46627
+ description: "Get a FHIR connection by ID, optionally with its eCW encounter-sync state",
46628
+ requiresWorkspace: true,
46629
+ args: [
46630
+ { name: "id", description: "FHIR connection ID", required: true },
46631
+ {
46632
+ name: "with-sync-state",
46633
+ description: "Also read the connection sync config and include syncState (one extra request)",
46634
+ isFlag: true
46635
+ }
46636
+ ],
46637
+ examples: [
46638
+ "fhir-connections get --id 12",
46639
+ "fhir-connections get --id 12 --with-sync-state --output-format json"
46640
+ ],
46641
+ handler: async ({ ctx, workspace, args }) => {
46642
+ const api = requireAuth(ctx).apiClient;
46643
+ const id = requireNumber(args, "id");
46644
+ const connection = await api.getFhirConnection(workspace, id);
46645
+ if (!args["with-sync-state"]) {
46646
+ outputSingle(connection, ctx, COLUMNS31);
46647
+ return;
46648
+ }
46649
+ const config = await api.getFhirConnectionSyncConfig(workspace, id);
46650
+ const withState = {
46651
+ ...connection,
46652
+ syncState: config.connectionParams?.ecwEncounterSyncState ?? null
46653
+ };
46654
+ outputSingle(withState, ctx, COLUMNS_WITH_SYNC_STATE);
46655
+ }
46656
+ },
46657
+ {
46658
+ path: ["fhir-connections", "sync-config"],
46659
+ description: "Get the FHIR connection sync configuration and its eCW encounter-sync watermark",
46660
+ requiresWorkspace: true,
46661
+ args: [{ name: "id", description: "FHIR connection ID", required: true }],
46662
+ examples: [
46663
+ "fhir-connections sync-config --id 12",
46664
+ "fhir-connections sync-config --id 12 --output-format json"
46665
+ ],
46666
+ handler: async ({ ctx, workspace, args }) => {
46667
+ const config = await requireAuth(ctx).apiClient.getFhirConnectionSyncConfig(
46668
+ workspace,
46669
+ requireNumber(args, "id")
46670
+ );
46671
+ outputSingle(config, ctx, SYNC_CONFIG_COLUMNS);
46672
+ }
46673
+ },
45919
46674
  {
45920
46675
  path: ["fhir-connections", "test"],
45921
46676
  description: "Test a FHIR connection",
@@ -49718,6 +50473,7 @@ var ChatTUI = class {
49718
50473
  activeToolName = "";
49719
50474
  pausedForPrompt = false;
49720
50475
  turnInProgress = false;
50476
+ queuedMessageCount = 0;
49721
50477
  constructor(options) {
49722
50478
  this.options = options;
49723
50479
  this.debugPanelVisible = !!options.debug;
@@ -49801,6 +50557,10 @@ var ChatTUI = class {
49801
50557
  this.activeToolName = "";
49802
50558
  this.dirty();
49803
50559
  }
50560
+ setQueuedMessageCount(count) {
50561
+ this.queuedMessageCount = count;
50562
+ this.dirty();
50563
+ }
49804
50564
  /** Whether a local user→assistant turn is currently in progress. */
49805
50565
  get isTurnInProgress() {
49806
50566
  return this.turnInProgress;
@@ -50155,10 +50915,6 @@ var ChatTUI = class {
50155
50915
  this.dirty();
50156
50916
  }
50157
50917
  handleEnter() {
50158
- if (this.turnInProgress) {
50159
- this.dirty();
50160
- return;
50161
- }
50162
50918
  const text = this.inputBuffer.trim();
50163
50919
  this.inputBuffer = "";
50164
50920
  if (!text) {
@@ -50314,6 +51070,7 @@ var ChatTUI = class {
50314
51070
  break;
50315
51071
  }
50316
51072
  if (status) parts.push(status);
51073
+ if (this.queuedMessageCount) parts.push(`${this.queuedMessageCount} queued`);
50317
51074
  const line = parts.join(` ${DIM3}|${RESET3} `);
50318
51075
  return truncateAnsi(line, this.cols);
50319
51076
  }
@@ -50567,6 +51324,49 @@ function buildDebugSummary(_direction, msg) {
50567
51324
  return type;
50568
51325
  }
50569
51326
 
51327
+ // src/lib/chat-turn-queue.ts
51328
+ var ChatTurnQueue = class {
51329
+ constructor(send, onCount, onError) {
51330
+ this.send = send;
51331
+ this.onCount = onCount;
51332
+ this.onError = onError;
51333
+ }
51334
+ send;
51335
+ onCount;
51336
+ onError;
51337
+ pending = [];
51338
+ running = false;
51339
+ closed = false;
51340
+ enqueue(text) {
51341
+ if (this.closed) return;
51342
+ this.pending.push(text);
51343
+ this.onCount(this.running ? this.pending.length : Math.max(0, this.pending.length - 1));
51344
+ void this.drain();
51345
+ }
51346
+ close() {
51347
+ this.closed = true;
51348
+ this.pending = [];
51349
+ this.onCount(0);
51350
+ }
51351
+ async drain() {
51352
+ if (this.running || this.closed) return;
51353
+ this.running = true;
51354
+ try {
51355
+ while (!this.closed && this.pending.length) {
51356
+ const text = this.pending.shift();
51357
+ this.onCount(this.pending.length);
51358
+ try {
51359
+ await this.send(text);
51360
+ } catch (error) {
51361
+ if (!this.closed) this.onError(error);
51362
+ }
51363
+ }
51364
+ } finally {
51365
+ this.running = false;
51366
+ }
51367
+ }
51368
+ };
51369
+
50570
51370
  // src/lib/agui-tui-events.ts
50571
51371
  init_agui();
50572
51372
  function handleAguiEvent(tui, event) {
@@ -51169,14 +51969,20 @@ async function interactiveChatSession(session, debug, autoApprove, allowWrite) {
51169
51969
  };
51170
51970
  const feedController = new AbortController();
51171
51971
  const canSubscribeToFeed = !!session.workspaceUuid && session.chatId > 0;
51972
+ const queue = new ChatTurnQueue(
51973
+ sendTurn,
51974
+ (count) => tui.setQueuedMessageCount(count),
51975
+ (error) => tui.showError(error instanceof Error ? error.message : String(error))
51976
+ );
51172
51977
  await new Promise((resolve3) => {
51173
51978
  tui = new ChatTUI({
51174
51979
  title: session.label,
51175
51980
  subtitle: session.chatTitle,
51176
51981
  onSend: (text) => {
51177
- void sendTurn(text);
51982
+ queue.enqueue(text);
51178
51983
  },
51179
51984
  onExit: () => {
51985
+ queue.close();
51180
51986
  feedController.abort();
51181
51987
  tui.stop();
51182
51988
  resolve3();