@kortix/ui 0.15.3 → 0.15.5
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/_vendor/kortix-shared.js +87 -29
- package/dist/_vendor/shared/markdown-math.d.ts +6 -0
- package/dist/customize/agents/agent-drives-section.d.ts +1 -3
- package/dist/customize/agents/agent-drives-section.js +3 -4
- package/dist/customize/agents/agent-page.js +2 -2
- package/dist/customize/agents/agent-tabs.d.ts +1 -1
- package/dist/customize/agents/agent-tabs.js +1 -2
- package/dist/customize/connectors/add-mcp/add-mcp-server-dialog.js +7 -2
- package/dist/customize/connectors/add-mcp/add-mcp-server.d.ts +7 -0
- package/dist/customize/connectors/add-mcp/add-mcp-server.js +3 -0
- package/dist/customize/connectors/connectors-page.d.ts +8 -0
- package/dist/customize/connectors/connectors-page.js +34 -1
- package/dist/customize/sections/view/agent-editor-access-fields.js +1 -3
- package/dist/files/project/components/drive-explorer.js +64 -43
- package/dist/files/project/components/drive-upload-tray.d.ts +2 -1
- package/dist/files/project/components/drive-upload-tray.js +9 -4
- package/dist/files/project/drop-tree.d.ts +16 -0
- package/dist/files/project/drop-tree.js +39 -0
- package/dist/files/project/upload-batch.d.ts +15 -0
- package/dist/files/project/upload-batch.js +12 -0
- package/dist/i18n/en.d.ts +16 -6
- package/dist/i18n/en.js +29 -19
- package/dist/internal/billing/use-cost-explorer.d.ts +19 -1
- package/dist/internal/billing/use-cost-explorer.js +27 -1
- package/dist/internal/lib/billing/billing-gate-state.d.ts +5 -6
- package/dist/internal/lib/billing/billing-gate-state.js +10 -11
- package/dist/internal/lib/browser-error-noise.d.ts +1 -1
- package/dist/internal/lib/browser-error-noise.js +1 -1
- package/dist/internal/lib/browser-noise/rules/injected-scripts.d.ts +5 -1
- package/dist/internal/lib/browser-noise/rules/injected-scripts.js +86 -0
- package/dist/internal/lib/mermaid-utils.js +2 -24
- package/dist/primitives/mermaid-render.js +3 -20
- package/dist/session/composer/ComposerCard.d.ts +1 -1
- package/dist/session/composer/ComposerCard.js +2 -2
- package/dist/session/composer/composer-chat-input.d.ts +14 -1
- package/dist/session/composer/composer-chat-input.js +4 -2
- package/dist/session/composer/composer-toolbar.d.ts +4 -1
- package/dist/session/composer/composer-toolbar.js +2 -2
- package/dist/session/composer/composer.d.ts +8 -0
- package/dist/session/composer/queue-projection.d.ts +10 -8
- package/dist/session/composer/queue-projection.js +10 -9
- package/dist/session/composer/send-stop-control.d.ts +15 -1
- package/dist/session/composer/send-stop-control.js +30 -5
- package/dist/session/composer/use-instant-session-send.js +2 -2
- package/dist/session/header/session-embed-menu-item.d.ts +12 -0
- package/dist/session/header/session-embed-menu-item.js +30 -0
- package/dist/{workspace/sidebar/modal/session-embed-section.d.ts → session/header/session-embed-snippet.d.ts} +2 -11
- package/dist/session/header/session-embed-snippet.js +21 -0
- package/dist/session/header/session-site-header.js +9 -2
- package/dist/session/models/ask-owner-for-credits-button.d.ts +7 -1
- package/dist/session/models/ask-owner-for-credits-button.js +3 -2
- package/dist/session/thread/session-chat.js +18 -7
- package/dist/session/voice/composer-call.d.ts +31 -0
- package/dist/session/voice/composer-call.js +46 -0
- package/dist/session/voice/voice-call-card.js +2 -0
- package/dist/session/voice/voice-call-store.d.ts +8 -0
- package/dist/session/voice/voice-call-store.js +5 -0
- package/dist/session/voice/voice-call.d.ts +2 -2
- package/dist/session/voice/voice-call.js +6 -6
- package/dist/test-utils/intl.d.ts +16 -6
- package/dist/workspace/home/existing-repo-setup-prompt.js +2 -3
- package/dist/workspace/instant-session-shell.js +11 -1
- package/dist/workspace/layout/project-home.js +24 -2
- package/dist/workspace/layout/use-project-home-call.d.ts +24 -0
- package/dist/workspace/layout/use-project-home-call.js +56 -0
- package/dist/workspace/new/workspace-name.d.ts +13 -0
- package/dist/workspace/new/workspace-name.js +20 -0
- package/dist/workspace/sidebar/footer/project-balance-warning.js +9 -6
- package/dist/workspace/sidebar/footer/sidebar-alert.d.ts +1 -1
- package/dist/workspace/sidebar/modal/share-session-modal.js +2 -3
- package/package.json +7 -7
- package/dist/workspace/sidebar/modal/session-embed-section.js +0 -71
|
@@ -25,6 +25,7 @@ import { SessionPendingApprovalsIndicator } from './session-pending-approvals-in
|
|
|
25
25
|
import { SessionGoalIndicator } from './session-goal-indicator.js';
|
|
26
26
|
import { SessionRemindersIndicator } from './session-reminders-indicator.js';
|
|
27
27
|
import { SessionTitleInput } from './session-title-input.js';
|
|
28
|
+
import { SessionEmbedMenuItem } from './session-embed-menu-item.js';
|
|
28
29
|
import { subagentTitle } from '../agents/agent-model.js';
|
|
29
30
|
import { SubagentHoverCard } from './subagent-hover-card.js';
|
|
30
31
|
import { Copy } from '../../icons/copy.js';
|
|
@@ -63,7 +64,7 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
63
64
|
const tPinArchive = useTranslations('sidebar.pinArchive');
|
|
64
65
|
const localizedDevTools = useLocalizedUiCatalog(DEV_TOOLS);
|
|
65
66
|
// A host that cannot reach the pty WebSocket turns the terminal off (`config.terminalEnabled`).
|
|
66
|
-
const { terminalEnabled } = useUiHostConfig();
|
|
67
|
+
const { terminalEnabled, publicSharesEnabled } = useUiHostConfig();
|
|
67
68
|
// A template on a base other than Ubuntu 24.04, or an old image, has no desktop.
|
|
68
69
|
const hasDesktop = useHasSessionDesktop() === true;
|
|
69
70
|
const devTools = useMemo(() => localizedDevTools.filter((tool) => (tool.view !== 'terminal' || terminalEnabled) && (tool.view !== 'desktop' || hasDesktop)), [localizedDevTools, terminalEnabled, hasDesktop]);
|
|
@@ -243,10 +244,16 @@ export function SessionSiteHeader({ sessionId, sessionTitle, isMobileView, leadi
|
|
|
243
244
|
else
|
|
244
245
|
errorToast(tPalette('copyFailed'));
|
|
245
246
|
};
|
|
247
|
+
// The embed snippet left the Session access dialog (KRTX-4639): a developer
|
|
248
|
+
// affordance does not belong in a permissions dialog. Its one entry point is
|
|
249
|
+
// the Embed submenu in the session menu below, gated like the dialog's
|
|
250
|
+
// section was: the same `can_manage_sharing` server verdict, and the host
|
|
251
|
+
// serves public shares at all.
|
|
252
|
+
const canEmbed = isProjectSession && canManageSharing && publicSharesEnabled;
|
|
246
253
|
const sessionActionItems = (_jsxs(_Fragment, { children: [isProjectSession && (_jsxs(_Fragment, { children: [canRename && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onSelect: () => {
|
|
247
254
|
renameFromMenu.current = true;
|
|
248
255
|
startRename();
|
|
249
|
-
}, children: [_jsx(PencilSimpleIcon, {}), tI18nHardcoded.raw('autoFeaturesSessionHeaderSessionSiteHeaderJsxTextRename41731a53')] }), _jsx(DropdownMenuSeparator, {})] })), canManageLifecycle && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: restartMutation.isPending, onClick: () => restartMutation.mutate(), children: [restartMutation.isPending ? _jsx(Loading, {}) : _jsx(RotateCcw, {}), tI18nHardcoded.raw('i18nComplete.text6b983a81e5e8')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: reloadConfig.isPending, onClick: () => reloadConfig.reload(), children: [reloadConfig.isPending ? _jsx(Loading, {}) : _jsx(ArrowsClockwiseIcon, {}), tI18nHardcoded.raw('i18nComplete.textb4b21a20cc58')] }), canStop && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: stopMutation.isPending, onClick: () => stopMutation.mutate(), children: [stopMutation.isPending ? _jsx(Loading, {}) : _jsx(Square, {}), tI18nHardcoded.raw('i18nComplete.textcae7d57bc067')] })), _jsx(DropdownMenuSeparator, {})] }))] })), isProjectSession && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionId'), projectSessionId), children: [_jsx(Copy, {}), tPalette('copyAction', { label: tPalette('copySessionId') })] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionLink'), window.location.href), children: [_jsx(LinkSimpleIcon, {}), tPalette('copyAction', { label: tPalette('copySessionLink') })] }), watching !== undefined && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: toggleWatch, children: [watching ? _jsx(BellSlashIcon, {}) : _jsx(BellIcon, {}), watching ? tNotifications('session.mute') : tNotifications('session.unmute')] })), listState && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setPinned(projectSessionId, !listState.pinned), children: [listState.pinned ? _jsx(PushPinSlashIcon, {}) : _jsx(PushPinIcon, {}), tPinArchive(listState.pinned ? 'unpin' : 'pin')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setArchived(projectSessionId, !listState.archived), children: [_jsx(ArchiveIcon, {}), tPinArchive(listState.archived ? 'unarchive' : 'archive')] })] })), canFork && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: forkSession.isPending, onClick: () => forkSession.mutate({ sessionId: projectSessionId }, {
|
|
256
|
+
}, children: [_jsx(PencilSimpleIcon, {}), tI18nHardcoded.raw('autoFeaturesSessionHeaderSessionSiteHeaderJsxTextRename41731a53')] }), _jsx(DropdownMenuSeparator, {})] })), canManageLifecycle && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: restartMutation.isPending, onClick: () => restartMutation.mutate(), children: [restartMutation.isPending ? _jsx(Loading, {}) : _jsx(RotateCcw, {}), tI18nHardcoded.raw('i18nComplete.text6b983a81e5e8')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: reloadConfig.isPending, onClick: () => reloadConfig.reload(), children: [reloadConfig.isPending ? _jsx(Loading, {}) : _jsx(ArrowsClockwiseIcon, {}), tI18nHardcoded.raw('i18nComplete.textb4b21a20cc58')] }), canStop && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: stopMutation.isPending, onClick: () => stopMutation.mutate(), children: [stopMutation.isPending ? _jsx(Loading, {}) : _jsx(Square, {}), tI18nHardcoded.raw('i18nComplete.textcae7d57bc067')] })), _jsx(DropdownMenuSeparator, {})] }))] })), isProjectSession && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionId'), projectSessionId), children: [_jsx(Copy, {}), tPalette('copyAction', { label: tPalette('copySessionId') })] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => copyValue(tPalette('copySessionLink'), window.location.href), children: [_jsx(LinkSimpleIcon, {}), tPalette('copyAction', { label: tPalette('copySessionLink') })] }), canEmbed && projectId && projectSessionId && (_jsx(SessionEmbedMenuItem, { projectId: projectId, sessionId: projectSessionId })), watching !== undefined && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: toggleWatch, children: [watching ? _jsx(BellSlashIcon, {}) : _jsx(BellIcon, {}), watching ? tNotifications('session.mute') : tNotifications('session.unmute')] })), listState && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setPinned(projectSessionId, !listState.pinned), children: [listState.pinned ? _jsx(PushPinSlashIcon, {}) : _jsx(PushPinIcon, {}), tPinArchive(listState.pinned ? 'unpin' : 'pin')] }), _jsxs(DropdownMenuItem, { className: "cursor-pointer", onClick: () => void listActions.setArchived(projectSessionId, !listState.archived), children: [_jsx(ArchiveIcon, {}), tPinArchive(listState.archived ? 'unarchive' : 'archive')] })] })), canFork && (_jsxs(DropdownMenuItem, { className: "cursor-pointer", disabled: forkSession.isPending, onClick: () => forkSession.mutate({ sessionId: projectSessionId }, {
|
|
250
257
|
onSuccess: (fork) => {
|
|
251
258
|
successToast(tI18nHardcoded.raw('i18nComplete.text95de71e25038'));
|
|
252
259
|
if (projectId && projectSessionId) {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
import { Button } from '../../primitives/button.js';
|
|
1
3
|
/**
|
|
2
4
|
* KRTX-1718: the member's way to tell an owner, from where they are blocked.
|
|
3
5
|
* Emails every owner; the API takes one request per member a day (429 after).
|
|
4
6
|
*/
|
|
5
|
-
export declare function AskOwnerForCreditsButton({ accountId }: {
|
|
7
|
+
export declare function AskOwnerForCreditsButton({ accountId, variant, size, className, }: {
|
|
6
8
|
accountId: string;
|
|
9
|
+
/** Defaults to the banner's outline `sm`; the out-of-credits modal makes it its primary action. */
|
|
10
|
+
variant?: ComponentProps<typeof Button>['variant'];
|
|
11
|
+
size?: ComponentProps<typeof Button>['size'];
|
|
12
|
+
className?: string;
|
|
7
13
|
}): import("react").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { Button } from '../../primitives/button.js';
|
|
5
|
+
import { cn } from '../../lib/utils.js';
|
|
5
6
|
import Loading from '../../primitives/loading.js';
|
|
6
7
|
import { useTranslations } from '../../i18n/index.js';
|
|
7
8
|
import { requestTopUp } from '@kortix/sdk';
|
|
@@ -9,7 +10,7 @@ import { requestTopUp } from '@kortix/sdk';
|
|
|
9
10
|
* KRTX-1718: the member's way to tell an owner, from where they are blocked.
|
|
10
11
|
* Emails every owner; the API takes one request per member a day (429 after).
|
|
11
12
|
*/
|
|
12
|
-
export function AskOwnerForCreditsButton({ accountId }) {
|
|
13
|
+
export function AskOwnerForCreditsButton({ accountId, variant = 'outline', size = 'sm', className, }) {
|
|
13
14
|
const tHardcodedUi = useTranslations('hardcodedUi');
|
|
14
15
|
const [state, setState] = useState('idle');
|
|
15
16
|
const label = state === 'asked'
|
|
@@ -29,5 +30,5 @@ export function AskOwnerForCreditsButton({ accountId }) {
|
|
|
29
30
|
setState(err?.status === 429 ? 'already' : 'failed');
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
|
-
return (_jsxs(Button, { variant:
|
|
33
|
+
return (_jsxs(Button, { variant: variant, size: size, className: cn('active:scale-[0.96]', className), disabled: state === 'asking' || state === 'asked' || state === 'already', onClick: () => void ask(), children: [state === 'asking' ? _jsx(Loading, { className: "size-3.5 shrink-0" }) : null, tHardcodedUi.raw(`componentsSessionSessionErrorBanner.${label}`)] }));
|
|
33
34
|
}
|
|
@@ -44,6 +44,7 @@ import { ProjectFilesProvider } from '../../files/project/context.js';
|
|
|
44
44
|
import { useOptionalSessionPanel } from '../panel/session-panel-provider.js';
|
|
45
45
|
import { COMPOSER_SHELL_CLASS, Composer as SessionChatInput, } from '../composer/composer.js';
|
|
46
46
|
import { ComposerDropZone } from '../composer/composer-drop-zone.js';
|
|
47
|
+
import { useSessionComposerCall } from '../voice/composer-call.js';
|
|
47
48
|
import { AgentsLine } from '../agents/agent-strip.js';
|
|
48
49
|
import { HeldMessages } from '../agents/held-messages.js';
|
|
49
50
|
import { SessionPromptContext } from '../agents/session-prompt.js';
|
|
@@ -606,6 +607,15 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
606
607
|
});
|
|
607
608
|
const composerAgentName = composerAgent.selected;
|
|
608
609
|
const noAccessibleAgents = composerAgent.disabled;
|
|
610
|
+
// Nothing typed: the Send button calls this session instead (flag
|
|
611
|
+
// `voice_call`, `voice/composer-call.ts`). Its agent answers here, so the
|
|
612
|
+
// call's turns fill this chat. Not a sub-session: its box binds no relay.
|
|
613
|
+
const composerCall = useSessionComposerCall({
|
|
614
|
+
projectId,
|
|
615
|
+
sessionId: projectSessionId,
|
|
616
|
+
agent: projectSessionRow?.agent_name ?? composerAgentName,
|
|
617
|
+
topLevel: !!projectSessionRow && !projectSessionRow.parent_session_id,
|
|
618
|
+
});
|
|
609
619
|
// The slash menu lists only the commands the composer's agent may run. The
|
|
610
620
|
// transcript keeps the full list: a past turn may have run any of them.
|
|
611
621
|
const { data: agentCommands } = useRuntimeCommands({ agent: composerAgentName ?? undefined });
|
|
@@ -1207,8 +1217,8 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
1207
1217
|
},
|
|
1208
1218
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1209
1219
|
[promptInbox.retry]);
|
|
1210
|
-
// "
|
|
1211
|
-
//
|
|
1220
|
+
// "Send now": the waiting row goes next, ahead of older waiting rows, and
|
|
1221
|
+
// steers the running turn. The turn does not stop.
|
|
1212
1222
|
const handleStopAndSendQueuedMessage = useCallback((id) => {
|
|
1213
1223
|
void promptInbox
|
|
1214
1224
|
.interrupt(id)
|
|
@@ -1526,7 +1536,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
1526
1536
|
return (liveQuestions.some((q) => q.id === renderedQuestion.id) ||
|
|
1527
1537
|
parkedAskIdByRequest.has(renderedQuestion.id));
|
|
1528
1538
|
}, [renderedQuestion, liveQuestions, parkedAskIdByRequest]);
|
|
1529
|
-
//
|
|
1539
|
+
// Transcript-placed waiting entries share the turn renderer. The inbox marks their IDs as
|
|
1530
1540
|
// pending until delivery; a client-minted wire ID does not place a message.
|
|
1531
1541
|
// Each is the user message `sessionLogPromptMessage` mints for its prompt.
|
|
1532
1542
|
const queuedSyntheticMessages = useMemo(() => {
|
|
@@ -2384,8 +2394,9 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
2384
2394
|
}
|
|
2385
2395
|
const placement = overrides?.placement ?? 'transcript';
|
|
2386
2396
|
const delivery = overrides?.delivery;
|
|
2387
|
-
// Placement decides WHERE the send waits:
|
|
2388
|
-
// the transcript now,
|
|
2397
|
+
// Placement decides WHERE the send waits: an idle send paints its bubble
|
|
2398
|
+
// in the transcript now, a send into a running turn draws a row above the
|
|
2399
|
+
// composer until the turn reads it. Busy
|
|
2389
2400
|
// state or earlier live rows decide only whether it waits at all.
|
|
2390
2401
|
const willQueue = isBusyRef.current || promptInbox.prompts.some((prompt) => prompt.state !== 'failed');
|
|
2391
2402
|
const paintTranscript = placement === 'transcript';
|
|
@@ -3957,7 +3968,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
3957
3968
|
autoFocus: deferComposerFocus || !composerAutoFocus ? false : undefined, onSend: async (text, files, mentions, attachments, placement) => {
|
|
3958
3969
|
if (await queueEdit.save(text))
|
|
3959
3970
|
return;
|
|
3960
|
-
// Enter while a turn runs steers it (
|
|
3971
|
+
// Enter or Cmd/Ctrl+Enter while a turn runs steers it (one delivery mode).
|
|
3961
3972
|
await handleSend(text, files, mentions, attachments, composerSendDelivery(placement ?? 'transcript', isBusyRef.current));
|
|
3962
3973
|
}, prefill: composerPrefill, onPrefillApplied: (id) => {
|
|
3963
3974
|
useSessionComposerPrefillStore.getState().clearPrefill(sessionId, id);
|
|
@@ -4001,7 +4012,7 @@ export function SessionChat({ sessionId, projectSessionId, sessionState, project
|
|
|
4001
4012
|
// A thread panel's rows run `px-5`, and the channel composer
|
|
4002
4013
|
// beside it sits `pb-4` off the window's bottom edge: the same
|
|
4003
4014
|
// margins, so the two boxes line up.
|
|
4004
|
-
parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
|
|
4015
|
+
parentClassName: transcriptRows ? 'max-w-none px-5 pb-4' : undefined, call: composerCall, onNoticeRetry: composerReadiness.notice && composerReadiness.retryable
|
|
4005
4016
|
? requestRuntimeReconnect
|
|
4006
4017
|
: undefined }), _jsx("div", { className: cn(COMPOSER_SHELL_CLASS, 'pb-3 empty:hidden', transcriptRows && 'max-w-none px-5'), children: _jsx(HeldMessages, { projectId: projectId, sessionId: projectSessionId }) })] }))] })] }) }) }) }) }));
|
|
4007
4018
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The voice call an empty composer offers in Send's place, as a phone's chat app does: with a draft the button sends
|
|
3
|
+
* it, with none it calls. `SendStopControl` draws it; a host that passes none keeps the plain Send. The call itself
|
|
4
|
+
* runs in the call card (voice-call-card.tsx, in the project shell), wherever the person goes in the project.
|
|
5
|
+
*/
|
|
6
|
+
export interface ComposerCall {
|
|
7
|
+
/** Places the call. */
|
|
8
|
+
onCall: () => void;
|
|
9
|
+
/** A call is in progress already. One microphone, one call: the button stays, disabled, and says so. */
|
|
10
|
+
inCall: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whether this project may place a voice call from here: the project's `voice_call` flag is on, the host mounts a
|
|
14
|
+
* call card to run it (`VoiceCallCard`: apps/web's project shell does, a white-label host may not), and the page is
|
|
15
|
+
* not the desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
|
|
16
|
+
*/
|
|
17
|
+
export declare function useVoiceCallsEnabled(projectId: string | undefined): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* A call with the session `sessionId` from its own composer. The session's agent answers in this same chat: the
|
|
20
|
+
* box's voice relay binds every top-level session under its Kortix session id (packages/voice), so the call's turns
|
|
21
|
+
* are this session's turns. A sub-session (`topLevel: false`) has no relay and gets no call.
|
|
22
|
+
*
|
|
23
|
+
* `agent` names the call card's mark and name; the relay answers as the session's own agent either way.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useSessionComposerCall({ projectId, sessionId, agent, topLevel, }: {
|
|
26
|
+
projectId: string | undefined;
|
|
27
|
+
/** The Kortix session id (`project_sessions.session_id`), never a runtime conversation id. */
|
|
28
|
+
sessionId: string | undefined;
|
|
29
|
+
agent: string | null | undefined;
|
|
30
|
+
topLevel?: boolean;
|
|
31
|
+
}): ComposerCall | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { platformConfig } from '@kortix/sdk';
|
|
3
|
+
import { useFeatureFlag } from '@kortix/sdk/react';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { useProjectCanRun } from '../../internal/hooks/projects/use-project-can-run.js';
|
|
6
|
+
import { isDesktop } from '../../internal/lib/desktop-detect.js';
|
|
7
|
+
import { useUpgradeDialogStore } from '../../internal/stores/upgrade-dialog-store.js';
|
|
8
|
+
import { useVoiceCallStore } from './voice-call-store.js';
|
|
9
|
+
/**
|
|
10
|
+
* Whether this project may place a voice call from here: the project's `voice_call` flag is on, the host mounts a
|
|
11
|
+
* call card to run it (`VoiceCallCard`: apps/web's project shell does, a white-label host may not), and the page is
|
|
12
|
+
* not the desktop shell, whose signed app has no microphone entitlement yet (apps/desktop-electron).
|
|
13
|
+
*/
|
|
14
|
+
export function useVoiceCallsEnabled(projectId) {
|
|
15
|
+
const { enabled } = useFeatureFlag(projectId ?? null, 'voice_call');
|
|
16
|
+
const runnable = useVoiceCallStore((s) => s.cards > 0);
|
|
17
|
+
return enabled && runnable && !!projectId && !isDesktop();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A call with the session `sessionId` from its own composer. The session's agent answers in this same chat: the
|
|
21
|
+
* box's voice relay binds every top-level session under its Kortix session id (packages/voice), so the call's turns
|
|
22
|
+
* are this session's turns. A sub-session (`topLevel: false`) has no relay and gets no call.
|
|
23
|
+
*
|
|
24
|
+
* `agent` names the call card's mark and name; the relay answers as the session's own agent either way.
|
|
25
|
+
*/
|
|
26
|
+
export function useSessionComposerCall({ projectId, sessionId, agent, topLevel = true, }) {
|
|
27
|
+
const enabled = useVoiceCallsEnabled(projectId);
|
|
28
|
+
const inCall = useVoiceCallStore((s) => !!s.call);
|
|
29
|
+
const { canRun, isLoading: billingLoading, accountId } = useProjectCanRun(enabled ? projectId : undefined);
|
|
30
|
+
const openUpgradeDialog = useUpgradeDialogStore((s) => s.openUpgradeDialog);
|
|
31
|
+
return useMemo(() => {
|
|
32
|
+
if (!enabled || !projectId || !sessionId || !agent || !topLevel)
|
|
33
|
+
return undefined;
|
|
34
|
+
return {
|
|
35
|
+
inCall,
|
|
36
|
+
onCall: () => {
|
|
37
|
+
// The gate Start session and the agent page's Call apply: a call runs billed turns.
|
|
38
|
+
if (platformConfig().billingEnabled && !billingLoading && !canRun) {
|
|
39
|
+
openUpgradeDialog({ reason: 'subscription_required', accountId });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
useVoiceCallStore.getState().place({ projectId, sessionId, agent });
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}, [enabled, projectId, sessionId, agent, topLevel, inCall, billingLoading, canRun, openUpgradeDialog, accountId]);
|
|
46
|
+
}
|
|
@@ -29,6 +29,8 @@ const ENDED = {
|
|
|
29
29
|
*/
|
|
30
30
|
export function VoiceCallCard() {
|
|
31
31
|
const call = useVoiceCallStore((s) => s.call);
|
|
32
|
+
// Mounted, this host can run a call: the call controls show (`useVoiceCallsEnabled`).
|
|
33
|
+
useEffect(() => useVoiceCallStore.getState().mountCard(), []);
|
|
32
34
|
if (!call || isDesktop())
|
|
33
35
|
return null;
|
|
34
36
|
return _jsx(PlacedCall, { call: call }, call.sessionId);
|
|
@@ -14,9 +14,17 @@ export interface ActiveCall {
|
|
|
14
14
|
*/
|
|
15
15
|
interface VoiceCallStore {
|
|
16
16
|
call: ActiveCall | null;
|
|
17
|
+
/**
|
|
18
|
+
* How many call cards are mounted. A call runs only in a card, and only a host that mounts one (apps/web's project
|
|
19
|
+
* shell) can run it: with none, no control offers a call (`useVoiceCallsEnabled`), so a placed call is never left
|
|
20
|
+
* with nothing to ring it.
|
|
21
|
+
*/
|
|
22
|
+
cards: number;
|
|
17
23
|
place: (call: Omit<ActiveCall, 'placedAt'>) => void;
|
|
18
24
|
/** Ends the call (only that session's, when one is named). */
|
|
19
25
|
end: (sessionId?: string) => void;
|
|
26
|
+
/** A call card mounted; the returned function unmounts it. */
|
|
27
|
+
mountCard: () => () => void;
|
|
20
28
|
}
|
|
21
29
|
export declare const useVoiceCallStore: import("zustand").UseBoundStore<import("zustand").StoreApi<VoiceCallStore>>;
|
|
22
30
|
export {};
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
export const useVoiceCallStore = create()((set, get) => ({
|
|
4
4
|
call: null,
|
|
5
|
+
cards: 0,
|
|
5
6
|
place: (call) => set({ call: { ...call, placedAt: Date.now() } }),
|
|
6
7
|
end: (sessionId) => {
|
|
7
8
|
if (!sessionId || get().call?.sessionId === sessionId)
|
|
8
9
|
set({ call: null });
|
|
9
10
|
},
|
|
11
|
+
mountCard: () => {
|
|
12
|
+
set((s) => ({ cards: s.cards + 1 }));
|
|
13
|
+
return () => set((s) => ({ cards: s.cards - 1 }));
|
|
14
|
+
},
|
|
10
15
|
}));
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* The agent page's Call button (Customize → Agents → <agent>). A call is a session of its own on this agent: the
|
|
3
3
|
* agent answers with its own instructions, tools and memory, and the call's transcript is that session's chat. The
|
|
4
4
|
* page stays: the session is created here, with no navigation and no toast, and the call card (voice-call-card.tsx)
|
|
5
|
-
* rings until its box answers. Only
|
|
6
|
-
*
|
|
5
|
+
* rings until its box answers. Only where `useVoiceCallsEnabled` says so: the project's `voice_call` flag is on, the
|
|
6
|
+
* host mounts the call card, and the page is not the desktop shell (no microphone entitlement yet).
|
|
7
7
|
*/
|
|
8
8
|
export declare function AgentCallButton({ projectId, agentName }: {
|
|
9
9
|
projectId: string;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { createProjectSession, markSessionFresh, platformConfig } from '@kortix/sdk';
|
|
4
|
-
import { qk, upsertCachedProjectSession
|
|
4
|
+
import { qk, upsertCachedProjectSession } from '@kortix/sdk/react';
|
|
5
5
|
import { PhoneIcon } from '@phosphor-icons/react';
|
|
6
6
|
import { useQueryClient } from '@tanstack/react-query';
|
|
7
7
|
import { useTranslations } from '../../i18n/index.js';
|
|
8
8
|
import { useProjectCanRun } from '../../internal/hooks/projects/use-project-can-run.js';
|
|
9
|
-
import { isDesktop } from '../../internal/lib/desktop-detect.js';
|
|
10
9
|
import { useUpgradeDialogStore } from '../../internal/stores/upgrade-dialog-store.js';
|
|
11
10
|
import { randomUUID } from '../../internal/lib/utils/random-uuid.js';
|
|
12
11
|
import { Button } from '../../primitives/button.js';
|
|
13
12
|
import Hint from '../../primitives/hint.js';
|
|
14
13
|
import { errorToast } from '../../primitives/toast.js';
|
|
14
|
+
import { useVoiceCallsEnabled } from './composer-call.js';
|
|
15
15
|
import { useVoiceCallStore } from './voice-call-store.js';
|
|
16
16
|
/**
|
|
17
17
|
* The agent page's Call button (Customize → Agents → <agent>). A call is a session of its own on this agent: the
|
|
18
18
|
* agent answers with its own instructions, tools and memory, and the call's transcript is that session's chat. The
|
|
19
19
|
* page stays: the session is created here, with no navigation and no toast, and the call card (voice-call-card.tsx)
|
|
20
|
-
* rings until its box answers. Only
|
|
21
|
-
*
|
|
20
|
+
* rings until its box answers. Only where `useVoiceCallsEnabled` says so: the project's `voice_call` flag is on, the
|
|
21
|
+
* host mounts the call card, and the page is not the desktop shell (no microphone entitlement yet).
|
|
22
22
|
*/
|
|
23
23
|
export function AgentCallButton({ projectId, agentName }) {
|
|
24
24
|
const t = useTranslations('voiceCall');
|
|
25
|
-
const
|
|
25
|
+
const enabled = useVoiceCallsEnabled(projectId);
|
|
26
26
|
const { canRun, isLoading: billingLoading, accountId } = useProjectCanRun(projectId);
|
|
27
27
|
const openUpgradeDialog = useUpgradeDialogStore((s) => s.openUpgradeDialog);
|
|
28
28
|
const inCall = useVoiceCallStore((s) => !!s.call);
|
|
29
29
|
const queryClient = useQueryClient();
|
|
30
|
-
if (!enabled
|
|
30
|
+
if (!enabled)
|
|
31
31
|
return null;
|
|
32
32
|
const call = async () => {
|
|
33
33
|
// The same gate as Start session: no session the account cannot run.
|
|
@@ -920,6 +920,14 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
920
920
|
historyDescription: string;
|
|
921
921
|
openLedger: string;
|
|
922
922
|
unit: string;
|
|
923
|
+
dailySpend: string;
|
|
924
|
+
heatLess: string;
|
|
925
|
+
heatMore: string;
|
|
926
|
+
busiestDay: string;
|
|
927
|
+
noSpendInRange: string;
|
|
928
|
+
idleWorkspaces: string;
|
|
929
|
+
showIdle: string;
|
|
930
|
+
hideIdle: string;
|
|
923
931
|
};
|
|
924
932
|
tokens: {
|
|
925
933
|
keyRevoked: string;
|
|
@@ -6396,11 +6404,6 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
6396
6404
|
recentThreads: string;
|
|
6397
6405
|
searchChannels: string;
|
|
6398
6406
|
};
|
|
6399
|
-
repositoryAccess: {
|
|
6400
|
-
label: string;
|
|
6401
|
-
enabled: string;
|
|
6402
|
-
disabled: string;
|
|
6403
|
-
};
|
|
6404
6407
|
customProvider: {
|
|
6405
6408
|
intro: string;
|
|
6406
6409
|
add: string;
|
|
@@ -6819,6 +6822,9 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
6819
6822
|
addMcpUrlNamed: string;
|
|
6820
6823
|
addMcpUrlInvalid: string;
|
|
6821
6824
|
addMcpConnect: string;
|
|
6825
|
+
addMcpStageConnector: string;
|
|
6826
|
+
addMcpStageAccount: string;
|
|
6827
|
+
addMcpStageSignIn: string;
|
|
6822
6828
|
addMcpConnected: string;
|
|
6823
6829
|
addMcpSignInFailed: string;
|
|
6824
6830
|
addMcpFailed: string;
|
|
@@ -7765,6 +7771,10 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
7765
7771
|
treeYou: string;
|
|
7766
7772
|
treeExpand: string;
|
|
7767
7773
|
treeCollapse: string;
|
|
7774
|
+
emptyWorkspaces: string;
|
|
7775
|
+
storageMoreWorkspaces: string;
|
|
7776
|
+
storageWorkspaceLimit: string;
|
|
7777
|
+
storageShowFewer: string;
|
|
7768
7778
|
};
|
|
7769
7779
|
genui: {
|
|
7770
7780
|
showData: string;
|
|
@@ -9372,6 +9382,7 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
9372
9382
|
call: string;
|
|
9373
9383
|
calling: string;
|
|
9374
9384
|
start: string;
|
|
9385
|
+
inCall: string;
|
|
9375
9386
|
end: string;
|
|
9376
9387
|
connecting: string;
|
|
9377
9388
|
listening: string;
|
|
@@ -9440,7 +9451,6 @@ export declare const testUiTranslator: import("use-intl")._Translator<{
|
|
|
9440
9451
|
agentMounts: {
|
|
9441
9452
|
lead: string;
|
|
9442
9453
|
mount: string;
|
|
9443
|
-
repository: string;
|
|
9444
9454
|
viaAgent: string;
|
|
9445
9455
|
viaProject: string;
|
|
9446
9456
|
from: string;
|
|
@@ -33,17 +33,16 @@ agents:
|
|
|
33
33
|
description: "General-purpose worker: coding, research, writing, ops and data work."
|
|
34
34
|
mode: primary
|
|
35
35
|
permission: allow
|
|
36
|
-
prompt: "
|
|
36
|
+
prompt: "Your session starts with an empty /workspace. Run \`kortix workspaces clone\` to get this repository, then read AGENTS.md or CLAUDE.md when it exists."
|
|
37
37
|
tools: "*"
|
|
38
38
|
skills: "*"
|
|
39
39
|
connectors: "*"
|
|
40
40
|
secrets: "*"
|
|
41
41
|
kortix_permissions: "*"
|
|
42
|
-
workspace: { project_repository: true }
|
|
43
42
|
\`\`\`
|
|
44
43
|
|
|
45
44
|
3. Keep the agent setup this repository already has. Do not move, copy or edit those files.
|
|
46
|
-
- For each \`.claude/agents/<name>.md\`, add an agent \`<name>\` with \`prompt_file: .claude/agents/<name>.md\`, the \`description\` from its frontmatter, \`mode: primary\`, \`tools: "*"\` and \`
|
|
45
|
+
- For each \`.claude/agents/<name>.md\`, add an agent \`<name>\` with \`prompt_file: .claude/agents/<name>.md\`, the \`description\` from its frontmatter, \`mode: primary\`, \`tools: "*"\` and \`kortix_permissions: [workspace.gitops.read]\`, so it can clone the repository.
|
|
47
46
|
- For each folder that holds a \`SKILL.md\` (\`.agents/skills/<name>\`, \`.claude/skills/<name>\`, \`skills/<name>\`), add \`<name>: <folder>\` under \`skills:\`. Skip a name that starts with \`kortix-\`.
|
|
48
47
|
4. Run \`kortix validate\`. Fix every error it prints and run it again until it exits 0.
|
|
49
48
|
5. Commit only \`kortix.yaml\` with the message "chore: add kortix.yaml" and push it to \`${branch}\`.
|
|
@@ -17,6 +17,7 @@ import { SessionWelcome } from '../session/thread/session-welcome.js';
|
|
|
17
17
|
import { QUEUED_BUBBLE_OPACITY_CLASS, QueuedPromptFailure, } from '../session/turn/queued-prompt-bubbles.js';
|
|
18
18
|
import { buildOptimisticPromptTextWithUploads } from '../session/composer/uploaded-file-refs.js';
|
|
19
19
|
import { useInstantSessionSend } from '../session/composer/use-instant-session-send.js';
|
|
20
|
+
import { useSessionComposerCall } from '../session/voice/composer-call.js';
|
|
20
21
|
import { ProjectHomeWelcomeBody } from './home/welcome-body.js';
|
|
21
22
|
import { useUiViewerId } from '../providers/ui-provider.js';
|
|
22
23
|
import { cn } from '../lib/utils.js';
|
|
@@ -91,6 +92,15 @@ export function InstantSessionShell({ projectId, sessionId, stage, boundAgentNam
|
|
|
91
92
|
enabled: !!projectId && !!sessionId,
|
|
92
93
|
}).data;
|
|
93
94
|
const viewerManagesSession = projectSessionRow?.can_manage_lifecycle !== false;
|
|
95
|
+
// Nothing typed: the Send button calls this session while its computer
|
|
96
|
+
// boots, as the real chat's does once it is up (flag `voice_call`). The call
|
|
97
|
+
// card rings until the box answers.
|
|
98
|
+
const call = useSessionComposerCall({
|
|
99
|
+
projectId,
|
|
100
|
+
sessionId,
|
|
101
|
+
agent: boundAgentName ?? projectSessionRow?.agent_name,
|
|
102
|
+
topLevel: !!projectSessionRow && !projectSessionRow.parent_session_id,
|
|
103
|
+
});
|
|
94
104
|
const shellQueue = useMemo(() => projectQueueRows({
|
|
95
105
|
prompts: promptInbox.prompts,
|
|
96
106
|
drafts: extraSends.map((entry) => ({
|
|
@@ -180,7 +190,7 @@ export function InstantSessionShell({ projectId, sessionId, stage, boundAgentNam
|
|
|
180
190
|
}, editing: queueEdit.editing, onCancelEdit: queueEdit.cancel })) : undefined,
|
|
181
191
|
// Editing a queued message: the send saves it back into the queue, so the
|
|
182
192
|
// control says Submit, never the boot-time Stop.
|
|
183
|
-
submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, onArrowUpAtStart: () => queueEdit.takeBack(), autoFocus: true,
|
|
193
|
+
submitLabel: queueEdit.editing ? tQueue('submitEdit') : null, onArrowUpAtStart: () => queueEdit.takeBack(), call: call, autoFocus: true,
|
|
184
194
|
// Hero radius pre-submit (matches the project home); back to the default
|
|
185
195
|
// card radius once docked so the crossfade into SessionChat doesn't pop.
|
|
186
196
|
cardClassName: submitted ? undefined : 'rounded-xl' }));
|
|
@@ -5,7 +5,7 @@ import { ACCOUNT_PANEL_PARAM, hubTarget } from '../../internal/stores/account-pa
|
|
|
5
5
|
import { SplitNoticeBanner } from '../settings/split-notice-banner.js';
|
|
6
6
|
import { useTranslations } from '../../i18n/index.js';
|
|
7
7
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
-
import { ComposerChatInput } from '../../session/composer/composer-chat-input.js';
|
|
8
|
+
import { ComposerChatInput, } from '../../session/composer/composer-chat-input.js';
|
|
9
9
|
import { ComposerDropZone } from '../../session/composer/composer-drop-zone.js';
|
|
10
10
|
import { SidebarToggle } from '../../internal/layout/sidebar-toggle.js';
|
|
11
11
|
import { PROJECT_ACTIONS } from '../../internal/lib/project-actions.js';
|
|
@@ -24,6 +24,7 @@ import { composerSelectableAgents } from '../../session/composer/composer-agent-
|
|
|
24
24
|
import { FirstChat } from '../home/first-chat.js';
|
|
25
25
|
import { SandboxPicker } from '../home/sandbox-picker.js';
|
|
26
26
|
import { ProjectHomeWallpaper, ProjectHomeWelcomeBody } from '../home/welcome-body.js';
|
|
27
|
+
import { useProjectHomeCall } from './use-project-home-call.js';
|
|
27
28
|
import { useProjectHomeSend } from './use-project-home-send.js';
|
|
28
29
|
// This path is this view's public surface — the instant session shell and the
|
|
29
30
|
// IAM tests already import from here, so the moved pieces keep their address.
|
|
@@ -211,6 +212,27 @@ function ProjectHomeView({ projectId, onSend, busy, beforeSend, onboarding: onbo
|
|
|
211
212
|
}
|
|
212
213
|
return sent;
|
|
213
214
|
}, [metaSelected, selectedSlug, send, onboarding, projectId, queryClient]);
|
|
215
|
+
// Nothing typed: the Send button calls a new session instead (flag
|
|
216
|
+
// `voice_call`, `use-project-home-call.ts`), with the sandbox chosen here as
|
|
217
|
+
// a send gets it. Only with the default send: a host's own `onSend` decides
|
|
218
|
+
// what a new session is, and a call would bypass it. Not in the first chat:
|
|
219
|
+
// it is the onboarding, and its kickoff is a typed message.
|
|
220
|
+
const homeCall = useProjectHomeCall(projectId, { beforeSend });
|
|
221
|
+
const call = useMemo(() => {
|
|
222
|
+
if (!homeCall || onSend || firstChat)
|
|
223
|
+
return undefined;
|
|
224
|
+
return {
|
|
225
|
+
inCall: homeCall.inCall,
|
|
226
|
+
onCall: (options) => homeCall.onCall({
|
|
227
|
+
...options,
|
|
228
|
+
...(metaSelected
|
|
229
|
+
? { sandbox_slug: MY_KORTIX_SANDBOX_SLUG }
|
|
230
|
+
: selectedSlug
|
|
231
|
+
? { sandbox_slug: selectedSlug }
|
|
232
|
+
: {}),
|
|
233
|
+
}),
|
|
234
|
+
};
|
|
235
|
+
}, [homeCall, onSend, firstChat, metaSelected, selectedSlug]);
|
|
214
236
|
const isMobile = useIsMobile();
|
|
215
237
|
const pendingPrefill = useComposerPrefillStore((s) => s.prefillByProject[projectId]);
|
|
216
238
|
const consumePrefill = useComposerPrefillStore((s) => s.consume);
|
|
@@ -275,7 +297,7 @@ function ProjectHomeView({ projectId, onSend, busy, beforeSend, onboarding: onbo
|
|
|
275
297
|
// beneath, the menu above.
|
|
276
298
|
underbarPlacement: firstChat || isMobile ? 'below' : 'inline', slashMenuPlacement: firstChat ? 'above' : 'below', placeholder: firstChat
|
|
277
299
|
? tFirstChat('placeholder')
|
|
278
|
-
: tI18nHardcoded.raw('autoFeaturesCoWorkerProjectLayoutProjectHomeJsxAttrPlaceholder115e6c2d'), prefill: prefill, onAgentSelectionChange: setSelectedAgent, sandboxSlot: sandboxSlot }));
|
|
300
|
+
: tI18nHardcoded.raw('autoFeaturesCoWorkerProjectLayoutProjectHomeJsxAttrPlaceholder115e6c2d'), prefill: prefill, onAgentSelectionChange: setSelectedAgent, sandboxSlot: sandboxSlot, call: call }));
|
|
279
301
|
return (
|
|
280
302
|
// A file dropped anywhere on the page attaches to the composer, as on a
|
|
281
303
|
// session page.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComposerOptions } from '../../session/composer/composer-chat-input.js';
|
|
2
|
+
/**
|
|
3
|
+
* What the home composer's call carries: its picks (`ComposerOptions`, with the agent it shows: the composer offers
|
|
4
|
+
* a call only once it resolved one) and the sandbox template chosen beside it.
|
|
5
|
+
*/
|
|
6
|
+
export type ProjectHomeCallOptions = ComposerOptions & {
|
|
7
|
+
agent: string;
|
|
8
|
+
sandbox_slug?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The project home composer's voice call: with nothing typed, its button calls instead of sending. A call is a new
|
|
12
|
+
* session, as a send is: the same create (agent, sandbox, connectors, secrets, through `useNewProjectSession` with
|
|
13
|
+
* its billing, connector and double-click guards), with no first prompt. The call is placed as the create lands and
|
|
14
|
+
* the session opens, so the conversation fills its chat while the person talks.
|
|
15
|
+
*
|
|
16
|
+
* `beforeSend` is the host's own gate (apps/web checks the account's billing state): it runs first, and a throw
|
|
17
|
+
* places nothing. Undefined while the project's `voice_call` flag is off: the composer keeps the plain Send.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useProjectHomeCall(projectId: string, { beforeSend }?: {
|
|
20
|
+
beforeSend?: () => Promise<void>;
|
|
21
|
+
}): {
|
|
22
|
+
onCall: (options: ProjectHomeCallOptions) => void;
|
|
23
|
+
inCall: boolean;
|
|
24
|
+
} | undefined;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { writeStartStash } from '@kortix/sdk/react';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useIsCreatingProjectSession } from '../../internal/hooks/projects/new-session-guard.js';
|
|
5
|
+
import { useNewProjectSession } from '../../internal/hooks/projects/use-new-project-session.js';
|
|
6
|
+
import { useVoiceCallsEnabled } from '../../session/voice/composer-call.js';
|
|
7
|
+
import { useVoiceCallStore } from '../../session/voice/voice-call-store.js';
|
|
8
|
+
import { buildNewSessionCreateInput } from './new-session-create.js';
|
|
9
|
+
/**
|
|
10
|
+
* The project home composer's voice call: with nothing typed, its button calls instead of sending. A call is a new
|
|
11
|
+
* session, as a send is: the same create (agent, sandbox, connectors, secrets, through `useNewProjectSession` with
|
|
12
|
+
* its billing, connector and double-click guards), with no first prompt. The call is placed as the create lands and
|
|
13
|
+
* the session opens, so the conversation fills its chat while the person talks.
|
|
14
|
+
*
|
|
15
|
+
* `beforeSend` is the host's own gate (apps/web checks the account's billing state): it runs first, and a throw
|
|
16
|
+
* places nothing. Undefined while the project's `voice_call` flag is off: the composer keeps the plain Send.
|
|
17
|
+
*/
|
|
18
|
+
export function useProjectHomeCall(projectId, { beforeSend } = {}) {
|
|
19
|
+
const enabled = useVoiceCallsEnabled(projectId);
|
|
20
|
+
const startSession = useNewProjectSession(projectId);
|
|
21
|
+
const creating = useIsCreatingProjectSession(projectId);
|
|
22
|
+
const inCall = useVoiceCallStore((s) => !!s.call);
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
if (!enabled)
|
|
25
|
+
return undefined;
|
|
26
|
+
return {
|
|
27
|
+
// A create in flight holds the button too: the guard would drop a second click anyway.
|
|
28
|
+
inCall: inCall || creating,
|
|
29
|
+
onCall: (options) => {
|
|
30
|
+
void (async () => {
|
|
31
|
+
try {
|
|
32
|
+
await beforeSend?.();
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
startSession({
|
|
38
|
+
create: buildNewSessionCreateInput(options),
|
|
39
|
+
scope: options.scope,
|
|
40
|
+
onNavigate: (sessionId) => {
|
|
41
|
+
// The picks the composer showed, for the session's own composer: a message typed during the call runs
|
|
42
|
+
// on them, as a first send's would (`useProjectHomeSend`).
|
|
43
|
+
writeStartStash(sessionId, {
|
|
44
|
+
prompt: '',
|
|
45
|
+
agent: options.agent,
|
|
46
|
+
model: options.model ?? null,
|
|
47
|
+
variant: options.variant ?? null,
|
|
48
|
+
});
|
|
49
|
+
useVoiceCallStore.getState().place({ projectId, sessionId, agent: options.agent });
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
})();
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}, [enabled, inCall, creating, beforeSend, startSession, projectId]);
|
|
56
|
+
}
|
|
@@ -18,6 +18,19 @@ export type WorkspaceNameResult = {
|
|
|
18
18
|
error: string;
|
|
19
19
|
};
|
|
20
20
|
export declare function validateWorkspaceName(raw: string): WorkspaceNameResult;
|
|
21
|
+
/**
|
|
22
|
+
* The message a workspace-name field renders for `result`, or null.
|
|
23
|
+
*
|
|
24
|
+
* Every error but `required` reports itself live: it can exist only after the
|
|
25
|
+
* user typed a character, and the form model (`isSubmittable`) already
|
|
26
|
+
* disables submit the moment it exists — a disabled button with no visible
|
|
27
|
+
* reason strands the user (KRTX-4627). `required` is also true before the
|
|
28
|
+
* first keystroke, the normal state while typing a name, so it waits for the
|
|
29
|
+
* field to be left once.
|
|
30
|
+
*/
|
|
31
|
+
export declare function workspaceNameMessage(result: WorkspaceNameResult, touched: boolean, t: (key: 'validation.nameRequired' | 'validation.nameCharacters' | 'validation.nameTooLong', vars?: {
|
|
32
|
+
max: number;
|
|
33
|
+
}) => string): string | null;
|
|
21
34
|
/**
|
|
22
35
|
* A ready-to-use project name ("Amber Falcon"), so `/workspaces/new` opens with a valid,
|
|
23
36
|
* friendly name instead of an empty required field. Always passes
|