@gravity-rail/cli 0.12.0 → 0.13.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/lib.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  startAccountPhoneVerify,
31
31
  stderr,
32
32
  unwrapItems
33
- } from "./chunk-GRLUFHMI.js";
33
+ } from "./chunk-LE5IR5MC.js";
34
34
  import {
35
35
  AGUIClient,
36
36
  formatTimestamp,
@@ -38,7 +38,7 @@ import {
38
38
  getTextDelta,
39
39
  performOAuthFlow,
40
40
  selectFromList
41
- } from "./chunk-SIV2WU2I.js";
41
+ } from "./chunk-XSFAJ5ZO.js";
42
42
  import {
43
43
  AuthRequiredError,
44
44
  CLIError,
@@ -9419,8 +9419,10 @@ Caller-facing messages
9419
9419
  smsUnavailableMessage (string)
9420
9420
  voicemailGreeting (string)
9421
9421
 
9422
- Work modes (voiceWorkMode / smsWorkMode)
9423
- always_forward | forward_off_hours | always_message | message_off_hours | voicemail | voicemail_off_hours
9422
+ Inbound calls (inboundCallHandling)
9423
+ agent | fax | always_forward | forward_off_hours | always_message | message_off_hours | voicemail | voicemail_off_hours | ring_operators
9424
+ SMS work modes (smsWorkMode)
9425
+ always_forward | forward_off_hours | always_message | message_off_hours
9424
9426
  voiceForwardNumber, smsForwardNumber, voiceOffHoursMessage, smsOffHoursMessage
9425
9427
 
9426
9428
  Provider link
@@ -9702,24 +9704,32 @@ function simulateInboundRouting(phone, opts = {}) {
9702
9704
  });
9703
9705
  return finish("anonymous_rejection_tts", false, true, steps, recommendations, callerRole);
9704
9706
  }
9705
- const voiceWorkMode = phone.voiceWorkMode;
9706
- if (voiceWorkMode === "always_forward" && phone.voiceForwardNumber) {
9707
- steps.push({ step: "voice_work_mode", outcome: "forward", detail: voiceWorkMode });
9707
+ const inboundCallHandling = phone.inboundCallHandling ?? "agent";
9708
+ if (inboundCallHandling === "fax") {
9709
+ steps.push({ step: "inbound_call_handling", outcome: "receive_fax" });
9710
+ return finish("fax_receive", true, true, steps, recommendations, callerRole);
9711
+ }
9712
+ if (inboundCallHandling === "always_forward" && phone.voiceForwardNumber) {
9713
+ steps.push({
9714
+ step: "inbound_call_handling",
9715
+ outcome: "forward",
9716
+ detail: inboundCallHandling
9717
+ });
9708
9718
  return finish("forward_pstn", false, true, steps, recommendations, callerRole);
9709
9719
  }
9710
- if (voiceWorkMode === "forward_off_hours" && !isBusinessHours && phone.voiceForwardNumber) {
9711
- steps.push({ step: "voice_work_mode", outcome: "forward_off_hours" });
9720
+ if (inboundCallHandling === "forward_off_hours" && !isBusinessHours && phone.voiceForwardNumber) {
9721
+ steps.push({ step: "inbound_call_handling", outcome: "forward_off_hours" });
9712
9722
  return finish("forward_pstn", false, true, steps, recommendations, callerRole);
9713
9723
  }
9714
- if (voiceWorkMode === "voicemail" || voiceWorkMode === "voicemail_off_hours" && !isBusinessHours) {
9715
- steps.push({ step: "voice_work_mode", outcome: "voicemail" });
9724
+ if (inboundCallHandling === "voicemail" || inboundCallHandling === "voicemail_off_hours" && !isBusinessHours) {
9725
+ steps.push({ step: "inbound_call_handling", outcome: "voicemail" });
9716
9726
  return finish("voicemail_record", true, true, steps, recommendations, callerRole);
9717
9727
  }
9718
- if ((voiceWorkMode === "always_message" || voiceWorkMode === "message_off_hours") && phone.voiceOffHoursMessage) {
9719
- steps.push({ step: "voice_work_mode", outcome: "play_message" });
9728
+ if ((inboundCallHandling === "always_message" || inboundCallHandling === "message_off_hours") && phone.voiceOffHoursMessage) {
9729
+ steps.push({ step: "inbound_call_handling", outcome: "play_message" });
9720
9730
  return finish("play_message_hangup", false, false, steps, recommendations, callerRole);
9721
9731
  }
9722
- steps.push({ step: "voice_work_mode", outcome: "ai_path" });
9732
+ steps.push({ step: "inbound_call_handling", outcome: "ai_path" });
9723
9733
  const workflowId = phone.defaultWorkflowId;
9724
9734
  if (workflowId === null || workflowId === void 0) {
9725
9735
  steps.push({
@@ -9774,6 +9784,7 @@ function finish(code, createsChat, createsPhoneCall, steps, recommendations, cal
9774
9784
  forward_pstn: "Forward to voiceForwardNumber",
9775
9785
  voicemail_record: "Record voicemail",
9776
9786
  play_message_hangup: "Play off-hours message, hang up",
9787
+ fax_receive: "Create fax chat + receive document",
9777
9788
  no_inbound_workflow: "Play unavailable message (no inbound workflow)",
9778
9789
  workflow_member_role_denied: "Reject \u2014 caller member role lacks workflow USE (memberRoleAccess)",
9779
9790
  ai_voice_chat: "Create chat + connect AI voice"
@@ -9846,9 +9857,7 @@ function formatPhoneNumberBehaviorMatrix(phone, outboundUsers, warnings = collec
9846
9857
  lines.push(
9847
9858
  ` allowAnonymous: ${phone.allowAnonymous} (role ${phone.anonymousMemberRoleId ?? "\u2014"}) allowSignup: ${phone.allowSignup} (role ${phone.signupMemberRoleId ?? "\u2014"})`
9848
9859
  );
9849
- if (phone.voiceWorkMode) {
9850
- lines.push(` voiceWorkMode: ${phone.voiceWorkMode}`);
9851
- }
9860
+ lines.push(` inboundCallHandling: ${phone.inboundCallHandling ?? "agent"}`);
9852
9861
  lines.push("");
9853
9862
  lines.push("## Outbound users");
9854
9863
  if (outboundUsers.length === 0) {
@@ -16382,6 +16391,10 @@ var ChatTUI = class {
16382
16391
  this.activeToolName = "";
16383
16392
  this.dirty();
16384
16393
  }
16394
+ /** Whether a local user→assistant turn is currently in progress. */
16395
+ get isTurnInProgress() {
16396
+ return this.turnInProgress;
16397
+ }
16385
16398
  /** Temporarily leave alt-screen for an external prompt (HITL). */
16386
16399
  pauseForPrompt() {
16387
16400
  if (!this.started || this.pausedForPrompt) return;
@@ -16424,6 +16437,10 @@ var ChatTUI = class {
16424
16437
  }
16425
16438
  /** Add a transcription of the user's spoken words (voice mode) */
16426
16439
  addTranscription(text) {
16440
+ this.addUserMessage(text);
16441
+ }
16442
+ /** Append a user message (e.g. a feed echo of a member's message). */
16443
+ addUserMessage(text) {
16427
16444
  this.items.push({ role: "user", content: text });
16428
16445
  this.scrollOffset = 0;
16429
16446
  this.dirty();
@@ -17194,6 +17211,38 @@ function handleAguiEvent(tui, event) {
17194
17211
  break;
17195
17212
  }
17196
17213
  }
17214
+ function createFeedRenderer(tui, isTurnInProgress) {
17215
+ const renderedMessageIds = /* @__PURE__ */ new Set();
17216
+ const userMessageBuffers = /* @__PURE__ */ new Map();
17217
+ return (event) => {
17218
+ if (isTurnInProgress()) return;
17219
+ const type = event.type?.toLowerCase() ?? "";
17220
+ const messageId = event.messageId;
17221
+ if (messageId && renderedMessageIds.has(messageId)) return;
17222
+ if (type === "text_message_start" && (event.role ?? "").toLowerCase() === "user") {
17223
+ if (messageId) userMessageBuffers.set(messageId, "");
17224
+ return;
17225
+ }
17226
+ if (messageId !== void 0 && userMessageBuffers.has(messageId)) {
17227
+ if (type === "text_message_content") {
17228
+ userMessageBuffers.set(
17229
+ messageId,
17230
+ (userMessageBuffers.get(messageId) ?? "") + (event.delta ?? "")
17231
+ );
17232
+ } else if (type === "text_message_end") {
17233
+ const text = (userMessageBuffers.get(messageId) ?? "").trim();
17234
+ userMessageBuffers.delete(messageId);
17235
+ renderedMessageIds.add(messageId);
17236
+ if (text) tui.addUserMessage(text);
17237
+ }
17238
+ return;
17239
+ }
17240
+ handleAguiEvent(tui, event);
17241
+ if (type === "text_message_end" && messageId) {
17242
+ renderedMessageIds.add(messageId);
17243
+ }
17244
+ };
17245
+ }
17197
17246
 
17198
17247
  // src/lib/audio.ts
17199
17248
  import { spawn, execSync, spawnSync } from "child_process";
@@ -17705,6 +17754,8 @@ async function interactiveChatSession(session, debug, autoApprove, allowWrite) {
17705
17754
  tui.runFinished();
17706
17755
  }
17707
17756
  };
17757
+ const feedController = new AbortController();
17758
+ const canSubscribeToFeed = !!session.workspaceUuid && session.chatId > 0;
17708
17759
  await new Promise((resolve) => {
17709
17760
  tui = new ChatTUI({
17710
17761
  title: session.label,
@@ -17713,6 +17764,7 @@ async function interactiveChatSession(session, debug, autoApprove, allowWrite) {
17713
17764
  void sendTurn(text);
17714
17765
  },
17715
17766
  onExit: () => {
17767
+ feedController.abort();
17716
17768
  tui.stop();
17717
17769
  resolve();
17718
17770
  },
@@ -17721,6 +17773,24 @@ async function interactiveChatSession(session, debug, autoApprove, allowWrite) {
17721
17773
  });
17722
17774
  tui.loadHistory(history);
17723
17775
  tui.start();
17776
+ if (canSubscribeToFeed) {
17777
+ const renderFeedEvent = createFeedRenderer(tui, () => tui.isTurnInProgress);
17778
+ void aguiClient.subscribeToFeed({
17779
+ onEvent: renderFeedEvent,
17780
+ signal: feedController.signal,
17781
+ onDebug: (msg) => tui.logDebug("in", { type: "feed", message: msg })
17782
+ }).catch((err) => {
17783
+ tui.logDebug("in", {
17784
+ type: "feed",
17785
+ message: `feed subscription ended: ${err instanceof Error ? err.message : String(err)}`
17786
+ });
17787
+ });
17788
+ } else {
17789
+ tui.logDebug("in", {
17790
+ type: "feed",
17791
+ message: "feed subscription skipped (concierge session has no workspace/chat feed)"
17792
+ });
17793
+ }
17724
17794
  });
17725
17795
  }
17726
17796
  function buildConversationMessages(messages) {
@@ -18824,7 +18894,7 @@ var topLevelCommands = [
18824
18894
  mutates: true,
18825
18895
  args: [{ name: "phone", description: "E.164 phone number (optional; prompts if omitted)" }],
18826
18896
  handler: async (hctx) => {
18827
- const { accountVerifyPhoneCommand } = await import("./account-verify-phone-7YQXKU3X.js");
18897
+ const { accountVerifyPhoneCommand } = await import("./account-verify-phone-N7EJS4J3.js");
18828
18898
  await accountVerifyPhoneCommand(hctx);
18829
18899
  }
18830
18900
  },