@kortix/ui 0.14.17 → 0.14.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +2 -2
  2. package/dist/_vendor/kortix-shared.js +38 -2
  3. package/dist/_vendor/shared/channel-descriptors.d.ts +20 -1
  4. package/dist/_vendor/shared/channel-message.d.ts +1 -1
  5. package/dist/_vendor/shared/my-kortix-agent.d.ts +1 -1
  6. package/dist/_vendor/shared/space-slug.d.ts +3 -4
  7. package/dist/_vendor/shared/utils/ambiguous-write.d.ts +3 -3
  8. package/dist/customize/agents/agent-instructions.d.ts +8 -0
  9. package/dist/customize/agents/agent-instructions.js +38 -12
  10. package/dist/customize/agents/agent-overview.d.ts +6 -3
  11. package/dist/customize/agents/agent-overview.js +8 -2
  12. package/dist/customize/agents/agent-page-chrome.d.ts +45 -27
  13. package/dist/customize/agents/agent-page-chrome.js +60 -37
  14. package/dist/customize/agents/agent-page.js +88 -99
  15. package/dist/customize/agents/agent-tabs.d.ts +15 -14
  16. package/dist/customize/agents/agent-tabs.js +19 -16
  17. package/dist/customize/agents/agents-page.js +8 -6
  18. package/dist/customize/connectors/detail/account-info.js +1 -1
  19. package/dist/customize/project-settings/project-admin-sections.d.ts +6 -2
  20. package/dist/customize/project-settings/project-admin-sections.js +5 -3
  21. package/dist/customize/project-settings/project-settings-sections.js +1 -1
  22. package/dist/customize/sections/component/channel-access-panel.js +16 -0
  23. package/dist/customize/sections/component/channel-mocks.d.ts +5 -0
  24. package/dist/customize/sections/component/channel-mocks.js +14 -2
  25. package/dist/customize/sections/component/discord-channel-row.d.ts +6 -0
  26. package/dist/customize/sections/component/discord-channel-row.js +48 -0
  27. package/dist/customize/sections/gateway-access-tab.js +1 -1
  28. package/dist/customize/sections/view/channels-view.js +18 -1
  29. package/dist/customize/sections/view/git-view.js +2 -2
  30. package/dist/customize/sections/view/secret-delivery.js +1 -1
  31. package/dist/customize/sections/view/secrets-view.js +1 -1
  32. package/dist/customize/settings/rail.js +2 -2
  33. package/dist/customize/settings/tabs/experimental-tab.d.ts +2 -2
  34. package/dist/customize/settings/tabs/experimental-tab.js +2 -2
  35. package/dist/customize/settings/tabs/general-tab.js +5 -4
  36. package/dist/customize/shared/capability-library.js +19 -22
  37. package/dist/customize/shared/customize-tab-bar.d.ts +1 -2
  38. package/dist/customize/shared/customize-tab-bar.js +10 -11
  39. package/dist/files/project/components/drive-create-dialog.js +3 -3
  40. package/dist/i18n/en.d.ts +51 -4
  41. package/dist/i18n/en.js +66 -19
  42. package/dist/i18n/ui-catalog/remaining-ui-translation-keys.generated.js +1 -1
  43. package/dist/internal/branding/branding-provider.d.ts +15 -4
  44. package/dist/internal/branding/branding-provider.js +12 -7
  45. package/dist/internal/connector-logo/connector-logo.js +2 -0
  46. package/dist/internal/connector-logo/connector-mark-files.js +1 -0
  47. package/dist/internal/hooks/channels/use-channels-installations.d.ts +7 -2
  48. package/dist/internal/hooks/channels/use-channels-installations.js +31 -1
  49. package/dist/internal/hooks/projects/use-new-project-session.d.ts +6 -14
  50. package/dist/internal/hooks/projects/use-new-project-session.js +12 -97
  51. package/dist/internal/hooks/use-notification-center.d.ts +11 -8
  52. package/dist/internal/hooks/use-notification-center.js +22 -10
  53. package/dist/internal/icons/discord.d.ts +9 -0
  54. package/dist/internal/icons/discord.js +9 -0
  55. package/dist/internal/layout/connect-mcp-modal.js +1 -1
  56. package/dist/internal/lib/browser-noise/rules/expected-states.js +1 -1
  57. package/dist/internal/lib/error-handler.js +1 -1
  58. package/dist/internal/lib/use-project-feature-flags.js +5 -3
  59. package/dist/markdown/markdown-frontmatter.d.ts +0 -3
  60. package/dist/markdown/markdown-frontmatter.js +45 -5
  61. package/dist/session/actions/project-session-list-helpers.d.ts +4 -14
  62. package/dist/session/actions/project-session-list-helpers.js +5 -16
  63. package/dist/session/actions/session-label.d.ts +5 -9
  64. package/dist/session/actions/session-label.js +6 -10
  65. package/dist/session/participants/session-participants.d.ts +7 -5
  66. package/dist/session/participants/session-participants.js +11 -7
  67. package/dist/session/status/provisioning-failure.d.ts +4 -5
  68. package/dist/session/status/provisioning-failure.js +4 -5
  69. package/dist/session/thread/optimistic-turn.js +11 -2
  70. package/dist/session/thread/session-chat.js +73 -25
  71. package/dist/session/thread/transcript.d.ts +9 -0
  72. package/dist/session/thread/transcript.js +44 -5
  73. package/dist/session/tool/tools/channel-send-card.js +1 -0
  74. package/dist/session/turn/channel-brand.js +4 -0
  75. package/dist/session/turn/message-author.d.ts +13 -8
  76. package/dist/session/turn/message-author.js +34 -16
  77. package/dist/session/turn/peer-message-row.js +24 -6
  78. package/dist/session/turn/user-message.js +1 -1
  79. package/dist/session/voice/call-audio.d.ts +32 -0
  80. package/dist/session/voice/call-audio.js +146 -0
  81. package/dist/session/voice/screen-share.d.ts +24 -0
  82. package/dist/session/voice/screen-share.js +75 -0
  83. package/dist/session/voice/use-voice-call.d.ts +15 -0
  84. package/dist/session/voice/use-voice-call.js +220 -0
  85. package/dist/session/voice/voice-call-bar.d.ts +4 -0
  86. package/dist/session/voice/voice-call-bar.js +39 -0
  87. package/dist/session/voice/voice-call-state.d.ts +96 -0
  88. package/dist/session/voice/voice-call-state.js +103 -0
  89. package/dist/session/voice/voice-call-store.d.ts +12 -0
  90. package/dist/session/voice/voice-call-store.js +10 -0
  91. package/dist/session/voice/voice-call-url.d.ts +24 -0
  92. package/dist/session/voice/voice-call-url.js +33 -0
  93. package/dist/session/voice/voice-call.d.ts +15 -0
  94. package/dist/session/voice/voice-call.js +54 -0
  95. package/dist/styles.css +1 -1
  96. package/dist/workspace/admin/project-admin-dashboard.js +9 -4
  97. package/dist/workspace/layout/project-home.js +13 -14
  98. package/dist/workspace/sidebar/footer/project-manifest-issues-alert.d.ts +1 -1
  99. package/dist/workspace/sidebar/footer/project-manifest-issues-alert.js +4 -3
  100. package/dist/workspace/sidebar/project-session-list.js +1 -0
  101. package/dist/workspace/sidebar/session-filter-menu.js +1 -0
  102. package/dist/workspace/sidebar/session-grouping.d.ts +4 -0
  103. package/dist/workspace/sidebar/session-grouping.js +2 -0
  104. package/dist/workspace/sidebar/session-source-icons.js +2 -0
  105. package/dist/workspace/space/space-page.js +2 -2
  106. package/package.json +9 -9
  107. package/skills/kortix-ui/SKILL.md +2 -2
  108. package/skills/kortix-ui/references/custom-dashboard.md +1 -1
  109. package/dist/customize/agents/agent-section-rail.d.ts +0 -21
  110. package/dist/customize/agents/agent-section-rail.js +0 -23
  111. package/dist/internal/hooks/projects/use-warm-project-session.d.ts +0 -270
  112. package/dist/internal/hooks/projects/use-warm-project-session.js +0 -362
  113. package/dist/internal/hooks/projects/warm-session-seed.d.ts +0 -66
  114. package/dist/internal/hooks/projects/warm-session-seed.js +0 -80
  115. package/dist/internal/hooks/projects/warm-session-taken-registry.d.ts +0 -61
  116. package/dist/internal/hooks/projects/warm-session-taken-registry.js +0 -141
@@ -0,0 +1,96 @@
1
+ import type { PreviewPortProbe } from '@kortix/sdk';
2
+ /**
3
+ * A call's state as the bar shows it, and the relay messages that move it (packages/voice README, "The call,
4
+ * from the browser"). Pure: `use-voice-call.ts` owns the socket and feeds this.
5
+ */
6
+ export type CallPhase = 'connecting' | 'live' | 'reconnecting' | 'ended';
7
+ /** Why a call ended by itself. A hang-up closes the bar instead. */
8
+ export type CallEnd =
9
+ /** The relay closed the call (`{type:'closed'}`). */
10
+ 'closed'
11
+ /** Nothing listens on the relay's port: the sandbox started before the flag was on. */
12
+ | 'unavailable'
13
+ /** The first dial or the audio failed. */
14
+ | 'failed'
15
+ /** A live call dropped and every redial failed. */
16
+ | 'lost';
17
+ export interface CallLine {
18
+ role: 'agent' | 'user';
19
+ /** The relay's name for the speaker: the voice's name for an agent line. */
20
+ who: string;
21
+ text: string;
22
+ }
23
+ export interface CallState {
24
+ phase: CallPhase;
25
+ /** The voice is audible now. */
26
+ speaking: boolean;
27
+ /** The latest line said or heard. */
28
+ line: CallLine | null;
29
+ end: CallEnd | null;
30
+ /** The browser gave no microphone: the call only listens to the voice. */
31
+ micBlocked: boolean;
32
+ /** Redials since the call was last live (or, before its first `ready`, since it was placed). */
33
+ redials: number;
34
+ }
35
+ export declare const INITIAL_CALL: CallState;
36
+ /** A live call that drops is dialed again after each of these waits, then it ends as `lost`. */
37
+ export declare const REDIAL_MS: readonly [1000, 2000, 4000];
38
+ /**
39
+ * A first dial that drops before `ready` is dialed again after each of these waits, then the call ends: a box that
40
+ * just started (a call placed from the agent page boots its own session) opens the relay's port a few seconds after
41
+ * its daemon answers.
42
+ */
43
+ export declare const DIAL_MS: readonly [1000, 2000, 3000, 4000];
44
+ export type CallEvent = {
45
+ type: 'ready';
46
+ } | {
47
+ type: 'text';
48
+ role?: unknown;
49
+ who?: unknown;
50
+ text?: unknown;
51
+ } | {
52
+ type: 'closed';
53
+ }
54
+ /** The socket closed without `closed`. `relay` is the health probe's answer, taken only for a first dial. */
55
+ | {
56
+ type: 'drop';
57
+ relay?: PreviewPortProbe;
58
+ } | {
59
+ type: 'audio-failed';
60
+ } | {
61
+ type: 'speaking';
62
+ on: boolean;
63
+ } | {
64
+ type: 'mic-blocked';
65
+ };
66
+ export declare function reduceCall(state: CallState, event: CallEvent): CallState;
67
+ /** The voice's gain while `duck` is on: quieter, because someone may be talking. */
68
+ export declare const DUCK_GAIN = 0.25;
69
+ /** `clear` lowers the voice for this long before the queue is dropped, so the cut is a roll-off, not a click. */
70
+ export declare const CLEAR_ROLLOFF_MS = 120;
71
+ /** `hold` pauses the queue within this beat, after the gain went to 0. */
72
+ export declare const HOLD_PAUSE_MS = 60;
73
+ /** What the playback messages act on: the speaker worklet's port and the voice's gain. */
74
+ export interface PlaybackOutput {
75
+ post(message: 'clear' | 'pause' | 'resume'): void;
76
+ level(gain: number): void;
77
+ }
78
+ /**
79
+ * The relay's playback messages (`clear`, `duck`, `hold`), ported from the voice lab's call page. A `clear`
80
+ * ends a hold and a duck as well: no `hold off` follows it, and the worklet's flush unpauses.
81
+ */
82
+ export declare function createPlayback(out: PlaybackOutput, schedule?: (run: () => void, ms: number) => void): {
83
+ /** Where a speaker set up later starts. */
84
+ current: () => {
85
+ held: boolean;
86
+ ducked: boolean;
87
+ };
88
+ /** Acts on a playback message; false for any other message. */
89
+ handle(message: {
90
+ type?: unknown;
91
+ on?: unknown;
92
+ }): boolean;
93
+ };
94
+ /** The voice counts as audible above this output level (RMS), and as speaking until this long after. */
95
+ export declare const AUDIBLE_RMS = 0.003;
96
+ export declare const SPEAKING_HOLD_MS = 250;
@@ -0,0 +1,103 @@
1
+ export const INITIAL_CALL = {
2
+ phase: 'connecting',
3
+ speaking: false,
4
+ line: null,
5
+ end: null,
6
+ micBlocked: false,
7
+ redials: 0,
8
+ };
9
+ /** A live call that drops is dialed again after each of these waits, then it ends as `lost`. */
10
+ export const REDIAL_MS = [1_000, 2_000, 4_000];
11
+ /**
12
+ * A first dial that drops before `ready` is dialed again after each of these waits, then the call ends: a box that
13
+ * just started (a call placed from the agent page boots its own session) opens the relay's port a few seconds after
14
+ * its daemon answers.
15
+ */
16
+ export const DIAL_MS = [1_000, 2_000, 3_000, 4_000];
17
+ export function reduceCall(state, event) {
18
+ switch (event.type) {
19
+ case 'ready':
20
+ return state.phase === 'ended' ? state : { ...state, phase: 'live', redials: 0 };
21
+ case 'text': {
22
+ const { role, who, text } = event;
23
+ // `screen` lines are what the voice read off a shared screen: neither said nor heard.
24
+ if ((role !== 'agent' && role !== 'user') || typeof text !== 'string' || !text.trim())
25
+ return state;
26
+ return { ...state, line: { role, who: typeof who === 'string' ? who : '', text: text.trim() } };
27
+ }
28
+ case 'closed':
29
+ return ended(state, 'closed');
30
+ case 'audio-failed':
31
+ return state.phase === 'ended' ? state : ended(state, 'failed');
32
+ case 'drop':
33
+ if (state.phase === 'ended')
34
+ return state;
35
+ if (state.phase === 'connecting') {
36
+ if (state.redials < DIAL_MS.length)
37
+ return { ...state, redials: state.redials + 1 };
38
+ return ended(state, event.relay === 'unreachable' ? 'unavailable' : 'failed');
39
+ }
40
+ if (state.phase === 'live')
41
+ return { ...state, phase: 'reconnecting', speaking: false, redials: 0 };
42
+ return state.redials + 1 < REDIAL_MS.length ? { ...state, redials: state.redials + 1 } : ended(state, 'lost');
43
+ case 'speaking':
44
+ return state.speaking === event.on ? state : { ...state, speaking: event.on };
45
+ case 'mic-blocked':
46
+ return state.micBlocked ? state : { ...state, micBlocked: true };
47
+ }
48
+ }
49
+ function ended(state, end) {
50
+ return { ...state, phase: 'ended', end, speaking: false };
51
+ }
52
+ /** The voice's gain while `duck` is on: quieter, because someone may be talking. */
53
+ export const DUCK_GAIN = 0.25;
54
+ /** `clear` lowers the voice for this long before the queue is dropped, so the cut is a roll-off, not a click. */
55
+ export const CLEAR_ROLLOFF_MS = 120;
56
+ /** `hold` pauses the queue within this beat, after the gain went to 0. */
57
+ export const HOLD_PAUSE_MS = 60;
58
+ /**
59
+ * The relay's playback messages (`clear`, `duck`, `hold`), ported from the voice lab's call page. A `clear`
60
+ * ends a hold and a duck as well: no `hold off` follows it, and the worklet's flush unpauses.
61
+ */
62
+ export function createPlayback(out, schedule = (run, ms) => void setTimeout(run, ms)) {
63
+ let held = false;
64
+ let ducked = false;
65
+ return {
66
+ /** Where a speaker set up later starts. */
67
+ current: () => ({ held, ducked }),
68
+ /** Acts on a playback message; false for any other message. */
69
+ handle(message) {
70
+ switch (message.type) {
71
+ case 'clear':
72
+ held = ducked = false;
73
+ out.level(0);
74
+ schedule(() => {
75
+ out.post('clear');
76
+ out.level(held ? 0 : ducked ? DUCK_GAIN : 1);
77
+ }, CLEAR_ROLLOFF_MS);
78
+ return true;
79
+ case 'duck':
80
+ ducked = !!message.on;
81
+ if (!held)
82
+ out.level(ducked ? DUCK_GAIN : 1);
83
+ return true;
84
+ case 'hold':
85
+ held = !!message.on;
86
+ if (held) {
87
+ out.level(0);
88
+ schedule(() => held && out.post('pause'), HOLD_PAUSE_MS);
89
+ }
90
+ else {
91
+ out.post('resume');
92
+ out.level(ducked ? DUCK_GAIN : 1);
93
+ }
94
+ return true;
95
+ default:
96
+ return false;
97
+ }
98
+ },
99
+ };
100
+ }
101
+ /** The voice counts as audible above this output level (RMS), and as speaking until this long after. */
102
+ export const AUDIBLE_RMS = 0.003;
103
+ export const SPEAKING_HOLD_MS = 250;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The session (Kortix session id) whose call bar is open: one call at a time, as there is one microphone. The agent
3
+ * page's Call button opens it for the session it starts, and the bar above that session's composer runs the call
4
+ * while it is open.
5
+ */
6
+ interface VoiceCallStore {
7
+ sessionId: string | null;
8
+ open: (sessionId: string) => void;
9
+ close: (sessionId: string) => void;
10
+ }
11
+ export declare const useVoiceCallStore: import("zustand").UseBoundStore<import("zustand").StoreApi<VoiceCallStore>>;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ 'use client';
2
+ import { create } from 'zustand';
3
+ export const useVoiceCallStore = create()((set, get) => ({
4
+ sessionId: null,
5
+ open: (sessionId) => set({ sessionId }),
6
+ close: (sessionId) => {
7
+ if (get().sessionId === sessionId)
8
+ set({ sessionId: null });
9
+ },
10
+ }));
@@ -0,0 +1,24 @@
1
+ /** The port of the box's voice relay (`KORTIX_VOICE_PORT` in packages/voice, beside the desktop's 6901). */
2
+ export declare const VOICE_PORT = 6902;
3
+ /**
4
+ * The WebSocket URL of a call with `session` (the Kortix session id the relay binds).
5
+ *
6
+ * `portUrl` is the path form of the sandbox port proxy, `getSandboxUrlForExternalId(sandbox, VOICE_PORT)`:
7
+ * the API authenticates its upgrade with `?token=`. A preview origin (what `proxyUrl` returns where the
8
+ * deployment has one) refuses a WebSocket from this page's site and reads no token.
9
+ *
10
+ * The rest is `getKortixPtyWebSocketUrl`'s conversion: http→ws, wss on an https page (a browser blocks
11
+ * ws:// there), and the token as a query parameter (a browser WebSocket sends no header). A redial asks
12
+ * the relay not to greet again (`greet=0`): the call already said who is speaking when it started.
13
+ */
14
+ export declare function voiceCallSocketUrl(portUrl: string, opts: {
15
+ session: string;
16
+ token: string | null;
17
+ redial: boolean;
18
+ securePage: boolean;
19
+ }): string;
20
+ /**
21
+ * The relay's health route behind the same proxy: the probe that tells "no relay" from a failed dial. It carries no
22
+ * credential: only the WebSocket upgrade reads `?token=`, and a token in a plain URL would only reach logs and history.
23
+ */
24
+ export declare function voiceRelayHealthUrl(portUrl: string): string;
@@ -0,0 +1,33 @@
1
+ /** The port of the box's voice relay (`KORTIX_VOICE_PORT` in packages/voice, beside the desktop's 6901). */
2
+ export const VOICE_PORT = 6902;
3
+ /**
4
+ * The WebSocket URL of a call with `session` (the Kortix session id the relay binds).
5
+ *
6
+ * `portUrl` is the path form of the sandbox port proxy, `getSandboxUrlForExternalId(sandbox, VOICE_PORT)`:
7
+ * the API authenticates its upgrade with `?token=`. A preview origin (what `proxyUrl` returns where the
8
+ * deployment has one) refuses a WebSocket from this page's site and reads no token.
9
+ *
10
+ * The rest is `getKortixPtyWebSocketUrl`'s conversion: http→ws, wss on an https page (a browser blocks
11
+ * ws:// there), and the token as a query parameter (a browser WebSocket sends no header). A redial asks
12
+ * the relay not to greet again (`greet=0`): the call already said who is speaking when it started.
13
+ */
14
+ export function voiceCallSocketUrl(portUrl, opts) {
15
+ const url = new URL(portUrl);
16
+ url.protocol = url.protocol === 'https:' || opts.securePage ? 'wss:' : 'ws:';
17
+ url.pathname = url.pathname.endsWith('/') ? `${url.pathname}stream` : `${url.pathname}/stream`;
18
+ url.searchParams.set('session', opts.session);
19
+ if (opts.token)
20
+ url.searchParams.set('token', opts.token);
21
+ if (opts.redial)
22
+ url.searchParams.set('greet', '0');
23
+ return url.toString();
24
+ }
25
+ /**
26
+ * The relay's health route behind the same proxy: the probe that tells "no relay" from a failed dial. It carries no
27
+ * credential: only the WebSocket upgrade reads `?token=`, and a token in a plain URL would only reach logs and history.
28
+ */
29
+ export function voiceRelayHealthUrl(portUrl) {
30
+ const url = new URL(portUrl);
31
+ url.pathname = url.pathname.endsWith('/') ? `${url.pathname}health` : `${url.pathname}/health`;
32
+ return url.toString();
33
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The agent page's Call button (Customize → Agents → <agent>). A call is a session of its own on this agent: the
3
+ * agent answers with its own instructions, tools and memory, and the call's transcript is that session's chat, never
4
+ * mixed into one already open. It starts the session the way Start session does and opens the call for it, so the
5
+ * session page dials as soon as its box is up. Only while the project's `voice_call` flag is on, and not in the
6
+ * desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
7
+ */
8
+ export declare function AgentCallButton({ projectId, agentName }: {
9
+ projectId: string;
10
+ agentName: string;
11
+ }): import("react").JSX.Element | null;
12
+ /** Where the call bar sits above the composer: nothing unless this session's call is open. */
13
+ export declare function VoiceCallSlot({ sessionId }: {
14
+ sessionId: string | undefined;
15
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useFeatureFlag } from '@kortix/sdk/react';
4
+ import { PhoneIcon } from '@phosphor-icons/react';
5
+ import { lazy, Suspense, useEffect } from 'react';
6
+ import { useTranslations } from '../../i18n/index.js';
7
+ import { useNewProjectSession } from '../../internal/hooks/projects/use-new-project-session.js';
8
+ import { isDesktop } from '../../internal/lib/desktop-detect.js';
9
+ import { Button } from '../../primitives/button.js';
10
+ import Hint from '../../primitives/hint.js';
11
+ import { useVoiceCallStore } from './voice-call-store.js';
12
+ // The call itself (socket, audio, screen share) loads with the first call, never for a project without the flag.
13
+ const VoiceCallBar = lazy(() => import('./voice-call-bar.js').then((m) => ({ default: m.VoiceCallBar })));
14
+ /**
15
+ * The agent page's Call button (Customize → Agents → <agent>). A call is a session of its own on this agent: the
16
+ * agent answers with its own instructions, tools and memory, and the call's transcript is that session's chat, never
17
+ * mixed into one already open. It starts the session the way Start session does and opens the call for it, so the
18
+ * session page dials as soon as its box is up. Only while the project's `voice_call` flag is on, and not in the
19
+ * desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
20
+ */
21
+ export function AgentCallButton({ projectId, agentName }) {
22
+ const t = useTranslations('voiceCall');
23
+ const { enabled } = useFeatureFlag(projectId, 'voice_call');
24
+ const startSession = useNewProjectSession(projectId);
25
+ if (!enabled || isDesktop())
26
+ return null;
27
+ const call = () => {
28
+ let placed;
29
+ startSession({
30
+ create: { agent_name: agentName },
31
+ onCreating: (sessionId) => {
32
+ placed = sessionId;
33
+ useVoiceCallStore.getState().open(sessionId);
34
+ },
35
+ onError: () => {
36
+ if (placed)
37
+ useVoiceCallStore.getState().close(placed);
38
+ },
39
+ });
40
+ };
41
+ return (_jsx(Hint, { side: "bottom", sideOffset: 4, delayDuration: 300, label: t('start'), children: _jsxs(Button, { variant: "secondary", size: "sm", "aria-label": t('start'), onClick: call, children: [_jsx(PhoneIcon, { weight: "fill", className: "size-3.5 shrink-0" }), _jsx("span", { className: "hidden sm:inline", children: t('call') })] }) }));
42
+ }
43
+ /** Where the call bar sits above the composer: nothing unless this session's call is open. */
44
+ export function VoiceCallSlot({ sessionId }) {
45
+ const open = useVoiceCallStore((s) => !!sessionId && s.sessionId === sessionId);
46
+ // A call lasts while its session is on screen: leaving the session ends it, so coming back never redials.
47
+ useEffect(() => () => {
48
+ if (sessionId)
49
+ useVoiceCallStore.getState().close(sessionId);
50
+ }, [sessionId]);
51
+ if (!open || !sessionId)
52
+ return null;
53
+ return (_jsx(Suspense, { fallback: null, children: _jsx(VoiceCallBar, { sessionId: sessionId }) }));
54
+ }