moi-computer 0.3.0-next.2 → 0.3.0-next.3
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/README.md +1 -1
- package/client/AGENTS.md +2 -2
- package/client/api/http.ts +1 -1
- package/client/api/workspace-keys.ts +1 -0
- package/client/app/AppRouter.tsx +14 -5
- package/client/app/routes/HomeRoute.tsx +1 -1
- package/client/app/routes/WorkspaceRoute.tsx +8 -2
- package/client/app/shell/SidebarLayout.tsx +10 -5
- package/client/assets/openai.svg +3 -0
- package/client/components/shared/BottomPanel.tsx +2 -2
- package/client/components/ui/button.tsx +3 -2
- package/client/components/ui/input.tsx +1 -1
- package/client/features/applets/AppletMount.tsx +44 -0
- package/client/features/applets/WidgetShell.tsx +4 -1
- package/client/features/applets/applet-cache.ts +8 -0
- package/client/features/applets/applet-styles.ts +61 -0
- package/client/features/chat/ChatComposer.tsx +2 -2
- package/client/features/chat/ChatPanel.tsx +8 -25
- package/client/features/chat/ChatPopup.tsx +3 -3
- package/client/features/chat/{ThreadSelector.tsx → ChatSelector.tsx} +4 -4
- package/client/features/chat/TurnView.tsx +8 -9
- package/client/features/chat/api.ts +1 -1
- package/client/features/chat/chat-send.ts +57 -0
- package/client/features/chat/tool-group/ToolCallGroup.tsx +2 -1
- package/client/features/chat/tool-group/format.ts +117 -0
- package/client/features/chat/useChat.ts +10 -34
- package/client/features/connectors/McpMenu.tsx +4 -21
- package/client/features/dev/DevRoutes.tsx +18 -0
- package/client/features/dev/HarnessDebugPage.tsx +468 -0
- package/client/{components/playground → features/dev}/PlaygroundPage.tsx +1 -1
- package/client/features/home/CreateWorkspaceDialog.tsx +64 -158
- package/client/features/home/CreateWorkspaceDialogSteps.tsx +234 -0
- package/client/features/home/HomeLogo.tsx +344 -0
- package/client/features/home/HomePage.tsx +15 -21
- package/client/features/home/WorkspacePreview.tsx +2 -2
- package/client/features/home/api.ts +11 -3
- package/client/features/home/workspace-presentation.tsx +4 -4
- package/client/features/settings/GeneralSettings.tsx +3 -3
- package/client/features/settings/IconPicker.tsx +4 -3
- package/client/features/settings/icon-picker-options.ts +0 -131
- package/client/features/views/ViewBuilderTab.tsx +153 -0
- package/client/features/views/api.ts +124 -0
- package/client/features/views/useViewBuilderActions.ts +72 -0
- package/client/features/widgets/WidgetGrid.tsx +36 -20
- package/client/features/widgets/Widgets.tsx +140 -90
- package/client/features/workspace/WorkspaceLayoutContext.tsx +3 -9
- package/client/features/workspace/WorkspaceScreen.tsx +179 -40
- package/client/features/workspace/WorkspaceTabs.tsx +4 -4
- package/client/index.css +0 -35
- package/client/index.html +1 -1
- package/client/lib/app-icon-registry.ts +145 -0
- package/client/runtime/useWorkspaceEvents.ts +3 -1
- package/client/theme.css +1 -1
- package/dist/chunk-4vf1t6v1.js +10 -0
- package/dist/chunk-6c24yndg.js +61 -0
- package/dist/chunk-6c8cwpzc.js +1 -0
- package/dist/chunk-b4b276wx.js +15 -0
- package/dist/{chunk-c4j722at.js → chunk-cs8vbert.js} +2 -2
- package/dist/chunk-cwqmay73.css +1 -0
- package/dist/chunk-kxmvv1ax.js +48 -0
- package/dist/chunk-rq0ar7vp.js +1 -0
- package/dist/{chunk-p68fnz3q.js → chunk-vkvb3hjm.js} +1 -1
- package/dist/chunk-zpxrb1ce.js +2 -0
- package/dist/index.html +2 -2
- package/dist/openai-h13pza4b.svg +3 -0
- package/lib/format.ts +2 -2
- package/lib/types.ts +38 -2
- package/lib/view-builder-meta.ts +35 -0
- package/lib/workspace-layout.ts +14 -0
- package/package.json +2 -1
- package/server/AGENTS.md +3 -3
- package/server/api.ts +165 -51
- package/server/applets.ts +1 -1
- package/server/bundle-queue.ts +19 -0
- package/server/bundler/applet-css.ts +50 -0
- package/server/{build-applet.ts → bundler/build-applet.ts} +36 -26
- package/server/cli.ts +79 -2
- package/server/control.ts +106 -8
- package/server/env-apply.ts +2 -2
- package/server/harness/README.md +228 -0
- package/server/harness/claude-code/NOTES.md +578 -0
- package/{lib/claude-adapter.ts → server/harness/claude-code/adapter.ts} +67 -5
- package/server/harness/claude-code/index.ts +124 -0
- package/server/{mcp.ts → harness/claude-code/mcp.ts} +1 -1
- package/server/{cc-session.ts → harness/claude-code/session.ts} +42 -14
- package/server/harness/claude-code/sessions.ts +42 -0
- package/server/harness/codex/NOTES.md +239 -0
- package/server/harness/codex/adapter.ts +414 -0
- package/server/harness/codex/client.ts +343 -0
- package/server/harness/codex/index.ts +68 -0
- package/server/harness/codex/probe.ts +186 -0
- package/server/harness/codex/session.ts +617 -0
- package/server/harness/debug.ts +57 -0
- package/server/harness/openclaw/NOTES.md +316 -0
- package/server/{openclaw-adapter.ts → harness/openclaw/adapter.ts} +2 -2
- package/server/harness/openclaw/index.ts +93 -0
- package/server/{openclaw-session.ts → harness/openclaw/session.ts} +44 -9
- package/server/{openclaw-strip.ts → harness/openclaw/strip.ts} +3 -1
- package/server/harness/registry.ts +36 -0
- package/server/harness/types.ts +87 -0
- package/server/layout.ts +6 -12
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +14 -52
- package/server/state.ts +5 -38
- package/server/status.ts +7 -46
- package/server/vendor.ts +1 -1
- package/server/view-builders.ts +428 -0
- package/server/views.ts +0 -0
- package/server/web.ts +18 -40
- package/server/workspace-init.ts +6 -6
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +1 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +28 -7
- package/client/assets/hermes-nous.png +0 -0
- package/client/hooks/useScrollFade.ts +0 -38
- package/dist/chunk-23cgr1tz.css +0 -1
- package/dist/chunk-3hy3qy6d.js +0 -10
- package/dist/chunk-dyfaffyz.js +0 -119
- package/dist/chunk-kpe40hm8.js +0 -1
- package/dist/chunk-ty6dvda0.js +0 -1
- package/dist/hermes-nous-pznd63x9.png +0 -0
- /package/client/{components/playground → features/dev}/PixelPainter.tsx +0 -0
- /package/client/{components/playground → features/dev}/ToolCallsPage.tsx +0 -0
- /package/server/{agent.ts → harness/claude-code/models.ts} +0 -0
- /package/server/{openclaw.ts → harness/openclaw/discovery.ts} +0 -0
- /package/server/{openclaw-gateway.ts → harness/openclaw/gateway.ts} +0 -0
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ bun run dev
|
|
|
31
31
|
|
|
32
32
|
moi also works with OpenClaw agents — `moi openclaw init` installs the moi
|
|
33
33
|
skills into an OpenClaw agent workspace. Integration notes live in
|
|
34
|
-
[
|
|
34
|
+
[server/harness/openclaw/NOTES.md](server/harness/openclaw/NOTES.md).
|
|
35
35
|
|
|
36
36
|
## No crypto token
|
|
37
37
|
|
package/client/AGENTS.md
CHANGED
|
@@ -6,8 +6,8 @@ Before editing host-app UI, read `../DESIGN.md` and the relevant rules in `../.a
|
|
|
6
6
|
|
|
7
7
|
## Entities
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **Widget** — A configurable card inside the
|
|
9
|
+
- **Workspace** — Top-level container. Has a name and contains widgets and a chat. One workspace is active at a time.
|
|
10
|
+
- **Widget** — A configurable card inside the workspace's main area. Displayed in a grid. When there are no widgets, the chat fills the whole panel.
|
|
11
11
|
- **Chat** — The agent conversation. Contains a scrollable message list and an input. Always lives in the panel. Two modes: sidebar (a bounded pane beside the widgets, or the full panel when there are no widgets) and floating (popover). Floating only applies when there are widgets and they need the room.
|
|
12
12
|
|
|
13
13
|
## Conventions
|
package/client/api/http.ts
CHANGED
|
@@ -22,7 +22,7 @@ export async function requestVoid(
|
|
|
22
22
|
if (!response.ok) throw await errorFrom(response, error)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function jsonRequest(method: 'POST' | 'PUT', body?: unknown): RequestInit {
|
|
25
|
+
export function jsonRequest(method: 'POST' | 'PUT' | 'PATCH', body?: unknown): RequestInit {
|
|
26
26
|
return {
|
|
27
27
|
method,
|
|
28
28
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -6,6 +6,7 @@ export const workspaceKeys = {
|
|
|
6
6
|
layout: (id: string) => ['workspaces', 'layout', id] as const,
|
|
7
7
|
widgets: (id: string) => ['workspaces', 'widgets', id] as const,
|
|
8
8
|
views: (id: string) => ['workspaces', 'views', id] as const,
|
|
9
|
+
viewBuilders: (id: string) => ['workspaces', 'view-builders', id] as const,
|
|
9
10
|
sessions: (id: string) => ['workspaces', 'sessions', id] as const,
|
|
10
11
|
events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
|
|
11
12
|
threadConfig: (id: string, sessionId: string) =>
|
package/client/app/AppRouter.tsx
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
1
|
+
import { Suspense, lazy, useEffect } from 'react'
|
|
2
2
|
|
|
3
3
|
import { Route, Switch, useLocation } from 'wouter'
|
|
4
4
|
|
|
5
|
-
import { PlaygroundPage } from '@/client/components/playground/PlaygroundPage'
|
|
6
|
-
import { ToolCallsPage } from '@/client/components/playground/ToolCallsPage'
|
|
7
5
|
import { setWorkspaceSwitchHandler } from '@/client/features/chat/chat-connection'
|
|
8
6
|
import { ConnectorsPage } from '@/client/features/connectors/ConnectorsPage'
|
|
9
7
|
|
|
10
8
|
import { HomeRoute } from './routes/HomeRoute'
|
|
11
9
|
import { WorkspaceRoute } from './routes/WorkspaceRoute'
|
|
12
10
|
|
|
11
|
+
// Dev-only playground routes: colocated in features/dev and loaded as a
|
|
12
|
+
// separate lazy chunk so none of it ships in the main bundle's hot path.
|
|
13
|
+
const DevRoutes = lazy(() => import('@/client/features/dev/DevRoutes'))
|
|
14
|
+
|
|
15
|
+
function DevLazy() {
|
|
16
|
+
return (
|
|
17
|
+
<Suspense fallback={null}>
|
|
18
|
+
<DevRoutes />
|
|
19
|
+
</Suspense>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
// Top-level router — sets up all client-side routes
|
|
14
24
|
export function AppRouter() {
|
|
15
25
|
const [, navigate] = useLocation()
|
|
@@ -25,8 +35,7 @@ export function AppRouter() {
|
|
|
25
35
|
<Switch>
|
|
26
36
|
<Route path="/" component={HomeRoute} />
|
|
27
37
|
<Route path="/connectors" component={ConnectorsPage} />
|
|
28
|
-
<Route path="/
|
|
29
|
-
<Route path="/playground" component={PlaygroundPage} />
|
|
38
|
+
<Route path="/dev/*?" component={DevLazy} />
|
|
30
39
|
<Route path="/workspace/:id">
|
|
31
40
|
{(params: { id: string }) => <WorkspaceRoute key={params.id} id={params.id} />}
|
|
32
41
|
</Route>
|
|
@@ -4,7 +4,7 @@ import { HomePage } from '@/client/features/home/HomePage'
|
|
|
4
4
|
// The `/` route: the app shell wrapping the workspaces view.
|
|
5
5
|
export function HomeRoute() {
|
|
6
6
|
return (
|
|
7
|
-
<SidebarLayout panel="flat">
|
|
7
|
+
<SidebarLayout panel="flat" showWorkspaces={false}>
|
|
8
8
|
<div className="min-h-0 flex-1 overflow-y-auto">
|
|
9
9
|
<HomePage />
|
|
10
10
|
</div>
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '@/client/features/workspace/WorkspaceLayoutContext'
|
|
16
16
|
import { WorkspaceScreen } from '@/client/features/workspace/WorkspaceScreen'
|
|
17
17
|
import { useWorkspaceViews, useWorkspaceWidgets } from '@/client/features/workspace/api'
|
|
18
|
+
import { useViewBuilders } from '@/client/features/views/api'
|
|
18
19
|
import { useGridReconcile } from '@/client/features/widgets/useGridReconcile'
|
|
19
20
|
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
20
21
|
import type { SessionInfo } from '@/lib/types'
|
|
@@ -38,6 +39,7 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
|
38
39
|
const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
|
|
39
40
|
const widgets = useWorkspaceWidgets(id)
|
|
40
41
|
const views = useWorkspaceViews(id)
|
|
42
|
+
const builders = useViewBuilders(id)
|
|
41
43
|
const sessions = useWorkspaceSessions(id)
|
|
42
44
|
|
|
43
45
|
useGridReconcile(id, widgets.data, layout, setLayout)
|
|
@@ -53,7 +55,7 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
|
53
55
|
}
|
|
54
56
|
})
|
|
55
57
|
|
|
56
|
-
const fresh = layoutLoading || widgets.isLoading
|
|
58
|
+
const fresh = layoutLoading || widgets.isLoading || views.isLoading || builders.isLoading
|
|
57
59
|
|
|
58
60
|
return (
|
|
59
61
|
<>
|
|
@@ -64,7 +66,11 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
|
64
66
|
<LedLogo sprite="moi" effect="chaos" />
|
|
65
67
|
</div>
|
|
66
68
|
) : (
|
|
67
|
-
<WorkspaceScreen
|
|
69
|
+
<WorkspaceScreen
|
|
70
|
+
widgets={widgets.data ?? []}
|
|
71
|
+
views={views.data ?? []}
|
|
72
|
+
builders={builders.data ?? []}
|
|
73
|
+
/>
|
|
68
74
|
)}
|
|
69
75
|
</SidebarLayout>
|
|
70
76
|
</>
|
|
@@ -30,11 +30,16 @@ type SidebarLayoutProps = {
|
|
|
30
30
|
// <PanelHeader>) and body.
|
|
31
31
|
children?: ReactNode
|
|
32
32
|
panel?: 'default' | 'flat'
|
|
33
|
+
showWorkspaces?: boolean
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
// App shell: a slim icon rail beside the page content. The page owns the panel's
|
|
36
37
|
// header and body.
|
|
37
|
-
export function SidebarLayout({
|
|
38
|
+
export function SidebarLayout({
|
|
39
|
+
children,
|
|
40
|
+
panel = 'default',
|
|
41
|
+
showWorkspaces = true
|
|
42
|
+
}: SidebarLayoutProps) {
|
|
38
43
|
const { data: workspaces } = useWorkspaces()
|
|
39
44
|
|
|
40
45
|
// `moi config` / the settings modal broadcast `workspace:updated` (identity
|
|
@@ -51,7 +56,7 @@ export function SidebarLayout({ children, panel = 'default' }: SidebarLayoutProp
|
|
|
51
56
|
|
|
52
57
|
return (
|
|
53
58
|
<div className="flex h-dvh bg-muted">
|
|
54
|
-
<Sidebar workspaces={workspaces ?? []} />
|
|
59
|
+
<Sidebar workspaces={showWorkspaces ? (workspaces ?? []) : []} />
|
|
55
60
|
<main
|
|
56
61
|
className={cn(
|
|
57
62
|
'flex min-w-0 flex-1 flex-col overflow-hidden',
|
|
@@ -81,7 +86,7 @@ function Sidebar({ workspaces }: SidebarProps) {
|
|
|
81
86
|
<nav className="flex max-h-full min-h-0 w-14 flex-1 flex-col items-center justify-center gap-4">
|
|
82
87
|
{workspaces.length > 0 && (
|
|
83
88
|
<>
|
|
84
|
-
<div className="scrollbar
|
|
89
|
+
<div className="no-scrollbar min-h-0 scroll-fade overflow-y-auto [--scroll-fade-reveal:16px]">
|
|
85
90
|
<ReorderableList
|
|
86
91
|
items={workspaces}
|
|
87
92
|
getId={ws => ws.id}
|
|
@@ -101,8 +106,8 @@ function Sidebar({ workspaces }: SidebarProps) {
|
|
|
101
106
|
type="button"
|
|
102
107
|
variant="ghost"
|
|
103
108
|
size="icon-lg"
|
|
104
|
-
aria-label="Create new
|
|
105
|
-
title="Create new
|
|
109
|
+
aria-label="Create new workspace"
|
|
110
|
+
title="Create new workspace"
|
|
106
111
|
className="text-muted-foreground hover:text-foreground"
|
|
107
112
|
>
|
|
108
113
|
<IconPlus data-icon="inline-start" stroke={1.5} />
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill="#10A37F" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.073zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.8956zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997z"/>
|
|
3
|
+
</svg>
|
|
@@ -14,7 +14,7 @@ export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
|
14
14
|
return (
|
|
15
15
|
<motion.div
|
|
16
16
|
ref={ref}
|
|
17
|
-
className="absolute inset-x-6 bottom-0 z-20 flex max-h-[60vh] flex-col rounded-t-2xl bg-card p-
|
|
17
|
+
className="absolute inset-x-6 bottom-0 z-20 flex max-h-[60vh] flex-col rounded-t-2xl bg-card p-(--page-pad) text-card-foreground shadow-md"
|
|
18
18
|
variants={{
|
|
19
19
|
hidden: { opacity: 0, y: 40, filter: 'blur(4px)' },
|
|
20
20
|
visible: { opacity: 1, y: 0, filter: 'blur(0px)' }
|
|
@@ -25,7 +25,7 @@ export function BottomPanel({ title, children, ref }: BottomPanelProps) {
|
|
|
25
25
|
transition={{ type: 'spring', duration: 0.25, bounce: 0 }}
|
|
26
26
|
>
|
|
27
27
|
<p className="mb-4 shrink-0 text-sm font-medium text-muted-foreground">{title}</p>
|
|
28
|
-
<div className="-my-1 [
|
|
28
|
+
<div className="-my-1 mr-[calc(var(--page-pad)*-1)] ml-[calc(var(--page-pad)*-1)] flex-1 overflow-y-auto px-(--page-pad) py-1">
|
|
29
29
|
{children}
|
|
30
30
|
</div>
|
|
31
31
|
</motion.div>
|
|
@@ -10,8 +10,9 @@ const buttonVariants = cva(
|
|
|
10
10
|
variant: {
|
|
11
11
|
default:
|
|
12
12
|
'bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100',
|
|
13
|
-
secondary:
|
|
14
|
-
|
|
13
|
+
secondary:
|
|
14
|
+
'bg-accent text-foreground hover:bg-[color-mix(in_oklch,var(--accent),var(--foreground)_5%)] hover:text-accent-foreground',
|
|
15
|
+
outline: 'bg-background shadow-xs hover:text-accent-foreground hover:shadow-sm',
|
|
15
16
|
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
16
17
|
destructive:
|
|
17
18
|
'bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20'
|
|
@@ -10,7 +10,7 @@ function Input({ className, type, ...props }: ComponentProps<'input'>) {
|
|
|
10
10
|
type={type}
|
|
11
11
|
data-slot="input"
|
|
12
12
|
className={cn(
|
|
13
|
-
'h-8 w-full min-w-0 rounded-
|
|
13
|
+
'h-8 w-full min-w-0 rounded-sm border border-input bg-transparent px-2.5 py-1 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
|
|
14
14
|
className
|
|
15
15
|
)}
|
|
16
16
|
{...props}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode, cloneElement, isValidElement } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useWorkspaceId } from '@/client/features/workspace/WorkspaceContext'
|
|
4
|
+
|
|
5
|
+
import { type AppletSegment, appletStyleKey } from './applet-cache'
|
|
6
|
+
import { useAppletStyle } from './applet-styles'
|
|
7
|
+
|
|
8
|
+
type AppletMountProps = {
|
|
9
|
+
segment: AppletSegment
|
|
10
|
+
name: string
|
|
11
|
+
version: number
|
|
12
|
+
// Merge the scope attribute into the single child element instead of
|
|
13
|
+
// rendering a wrapper — use when the caller already has a filled container
|
|
14
|
+
// (e.g. the shells' motion.div), so no extra node enters the DOM. The child
|
|
15
|
+
// must forward unknown props to its DOM element.
|
|
16
|
+
asChild?: boolean
|
|
17
|
+
children: ReactNode
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The style scope for one mounted applet: puts the `data-applet` attribute the
|
|
21
|
+
// bundle's scoped CSS selectors key off (see server/bundler/applet-css.ts) on a
|
|
22
|
+
// container, and keeps the applet's <style> tag mounted exactly as long as the
|
|
23
|
+
// applet is — unmounting removes the styles from the page. Without `asChild`
|
|
24
|
+
// it renders its own wrapper div filling the parent box (the widget path —
|
|
25
|
+
// merging onto the shell's motion.div interferes with AnimatePresence there);
|
|
26
|
+
// with `asChild` it merges onto the child element instead (the view path).
|
|
27
|
+
export function AppletMount({ segment, name, version, asChild, children }: AppletMountProps) {
|
|
28
|
+
const workspaceId = useWorkspaceId()
|
|
29
|
+
useAppletStyle(appletStyleKey(segment, workspaceId, name), version)
|
|
30
|
+
|
|
31
|
+
const kind = segment === 'widgets' ? 'widget' : 'view'
|
|
32
|
+
const scope = `${kind}:${name}`
|
|
33
|
+
|
|
34
|
+
if (asChild && isValidElement(children)) {
|
|
35
|
+
return cloneElement(children as ReactElement<{ 'data-applet'?: string }>, {
|
|
36
|
+
'data-applet': scope
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
return (
|
|
40
|
+
<div data-applet={scope} className="size-full">
|
|
41
|
+
{children}
|
|
42
|
+
</div>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AnimatePresence, motion } from 'motion/react'
|
|
2
2
|
|
|
3
|
+
import { AppletMount } from '@/client/features/applets/AppletMount'
|
|
3
4
|
import { useWidget } from '@/client/features/applets/useApplet'
|
|
4
5
|
|
|
5
6
|
import { WidgetErrorBoundary } from './WidgetErrorBoundary'
|
|
@@ -23,7 +24,9 @@ export function WidgetShell({ name }: WidgetShellProps) {
|
|
|
23
24
|
transition={{ duration: 0.45, ease: 'easeInOut' }}
|
|
24
25
|
>
|
|
25
26
|
<WidgetErrorBoundary name={name} resetKey={widget.version}>
|
|
26
|
-
<widget.
|
|
27
|
+
<AppletMount segment="widgets" name={name} version={widget.version}>
|
|
28
|
+
<widget.Component />
|
|
29
|
+
</AppletMount>
|
|
27
30
|
</WidgetErrorBoundary>
|
|
28
31
|
</motion.div>
|
|
29
32
|
)}
|
|
@@ -35,6 +35,14 @@ export function appletUrl(segment: AppletSegment, workspaceId: string, name: str
|
|
|
35
35
|
return `/api/workspaces/${workspaceId}/${segment}/${name}/index.js?v=${appletVersion(segment, workspaceId, name)}`
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// The key an applet bundle registers its CSS under (`window.__moiAppletCss`):
|
|
39
|
+
// the bundle-dir path, which the bundle derives from its own import.meta.url
|
|
40
|
+
// (see injectCss in server/bundler/build-applet.ts). Workspace-qualified so two
|
|
41
|
+
// workspaces sharing an applet name never read each other's styles.
|
|
42
|
+
export function appletStyleKey(segment: AppletSegment, workspaceId: string, name: string): string {
|
|
43
|
+
return `/api/workspaces/${workspaceId}/${segment}/${name}`
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
export function getCachedApplet(key: string): Promise<unknown> | undefined {
|
|
39
47
|
return moduleCache.get(key)
|
|
40
48
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useInsertionEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
// Host-managed applet styles. An applet bundle no longer appends its own
|
|
4
|
+
// <style> to <head> (which stuck around forever — a cached ES module is never
|
|
5
|
+
// re-evaluated, let alone disposed). Instead its module side effect registers
|
|
6
|
+
// the compiled, container-scoped CSS on `window.__moiAppletCss`, keyed by the
|
|
7
|
+
// bundle-dir path (`/api/workspaces/<id>/<segment>/<name>` — see injectCss in
|
|
8
|
+
// server/bundler/build-applet.ts and `appletStyleKey`). The host injects a <style> for
|
|
9
|
+
// that key while at least one instance of the applet is mounted, and removes it
|
|
10
|
+
// when the last one unmounts.
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
__moiAppletCss?: Map<string, string>
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ActiveStyle = {
|
|
18
|
+
el: HTMLStyleElement
|
|
19
|
+
refs: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const active = new Map<string, ActiveStyle>()
|
|
23
|
+
|
|
24
|
+
// Mount the applet's registered CSS (refcounted); returns the release fn.
|
|
25
|
+
// Exported for tests — components should use `useAppletStyle`.
|
|
26
|
+
export function acquireAppletStyle(key: string): () => void {
|
|
27
|
+
const css = window.__moiAppletCss?.get(key) ?? ''
|
|
28
|
+
|
|
29
|
+
let entry = active.get(key)
|
|
30
|
+
if (!entry) {
|
|
31
|
+
const el = document.createElement('style')
|
|
32
|
+
el.dataset.appletStyle = key
|
|
33
|
+
document.head.appendChild(el)
|
|
34
|
+
entry = { el, refs: 0 }
|
|
35
|
+
active.set(key, entry)
|
|
36
|
+
}
|
|
37
|
+
// Always sync the text: after a rebuild the registry holds fresh CSS under
|
|
38
|
+
// the same key while an older instance may still be mounted (exit animation).
|
|
39
|
+
if (entry.el.textContent !== css) entry.el.textContent = css
|
|
40
|
+
|
|
41
|
+
entry.refs++
|
|
42
|
+
const acquired = entry
|
|
43
|
+
let released = false
|
|
44
|
+
return () => {
|
|
45
|
+
if (released) return
|
|
46
|
+
released = true
|
|
47
|
+
acquired.refs--
|
|
48
|
+
if (acquired.refs <= 0) {
|
|
49
|
+
acquired.el.remove()
|
|
50
|
+
active.delete(key)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Keep the applet's <style> mounted for the lifetime of the calling component.
|
|
56
|
+
// `version` re-runs the effect after a rebuild so the tag picks up the fresh
|
|
57
|
+
// registry text. useInsertionEffect runs before layout effects and paint, so
|
|
58
|
+
// the styles are in place before the applet's first frame.
|
|
59
|
+
export function useAppletStyle(key: string, version: number): void {
|
|
60
|
+
useInsertionEffect(() => acquireAppletStyle(key), [key, version])
|
|
61
|
+
}
|
|
@@ -116,7 +116,7 @@ export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatCo
|
|
|
116
116
|
addFiles(Array.from(e.dataTransfer.files))
|
|
117
117
|
}}
|
|
118
118
|
className={cn(
|
|
119
|
-
'flex w-full cursor-text flex-col gap-1 rounded-lg bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
|
|
119
|
+
'flex w-full max-w-(--chat-max-container) cursor-text flex-col gap-1 rounded-lg bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
|
|
120
120
|
dragOver && 'ring-2 ring-ring/60'
|
|
121
121
|
)}
|
|
122
122
|
>
|
|
@@ -152,7 +152,7 @@ export function ChatComposer({ composerRef, onSend, onStop, processing }: ChatCo
|
|
|
152
152
|
e.preventDefault()
|
|
153
153
|
addFiles(files)
|
|
154
154
|
}}
|
|
155
|
-
placeholder={processing ? 'Queue a follow-up
|
|
155
|
+
placeholder={processing ? 'Queue a follow-up' : 'Do anything'}
|
|
156
156
|
rows={1}
|
|
157
157
|
className="field-sizing-content max-h-40 w-full resize-none bg-transparent px-2 py-1 text-sm leading-relaxed outline-none placeholder:text-muted-foreground disabled:opacity-50"
|
|
158
158
|
/>
|
|
@@ -2,14 +2,12 @@ import { type ReactNode, useCallback, useEffect, useMemo, useRef } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { IconChevronDown, IconX } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
|
-
import { useScrollFade } from '@/client/hooks/useScrollFade'
|
|
6
5
|
import { useStickToBottom } from '@/client/features/chat/useStickToBottom'
|
|
7
|
-
import { cn } from '@/client/lib/cn'
|
|
8
6
|
import { groupTurns } from '@/client/features/chat/group-turns'
|
|
9
7
|
import type { Turn, ViewState } from '@/lib/types'
|
|
10
8
|
|
|
11
9
|
import { ChatComposer } from './ChatComposer'
|
|
12
|
-
import {
|
|
10
|
+
import { ChatSelector } from './ChatSelector'
|
|
13
11
|
import { EmptyState, ThinkingIndicator, TurnView } from './TurnView'
|
|
14
12
|
import { Button } from '@/client/components/ui/button'
|
|
15
13
|
|
|
@@ -29,10 +27,6 @@ type ChatPanelProps = {
|
|
|
29
27
|
onDismissError?: () => void
|
|
30
28
|
send: (text: string) => void
|
|
31
29
|
stop: () => void
|
|
32
|
-
// Constrain the scrollable history and the composer to a centered max-width
|
|
33
|
-
// column (var --chat-max-container) while the header still spans full width.
|
|
34
|
-
// Always on for now; will be toggled per layout mode later.
|
|
35
|
-
contained?: boolean
|
|
36
30
|
onSwitchThread: (sessionId: string | null) => void
|
|
37
31
|
// Extra content for the header's left edge, rendered before the thread
|
|
38
32
|
// selector when the chat is the primary panel.
|
|
@@ -56,14 +50,13 @@ export function ChatPanel({
|
|
|
56
50
|
onDismissError,
|
|
57
51
|
send,
|
|
58
52
|
stop,
|
|
59
|
-
contained = true,
|
|
60
53
|
onSwitchThread,
|
|
61
54
|
headerLeft,
|
|
62
55
|
headerRight,
|
|
63
56
|
onClose
|
|
64
57
|
}: ChatPanelProps) {
|
|
65
58
|
const composerRef = useRef<HTMLTextAreaElement>(null)
|
|
66
|
-
const
|
|
59
|
+
const scrollRef = useRef<HTMLDivElement>(null)
|
|
67
60
|
const turns = view.turns
|
|
68
61
|
// Visual grouping: fold consecutive tool-only assistant turns into one
|
|
69
62
|
// synthetic turn so OpenAI Codex–style traces (which serialize one
|
|
@@ -96,11 +89,11 @@ export function ChatPanel({
|
|
|
96
89
|
)
|
|
97
90
|
|
|
98
91
|
return (
|
|
99
|
-
<div className="flex min-h-0 flex-1 flex-col pt-2 pb-
|
|
92
|
+
<div className="flex min-h-0 flex-1 flex-col pt-2 pb-3">
|
|
100
93
|
<header className="flex items-center justify-between pr-2 pb-2 pl-2">
|
|
101
94
|
<div className="flex min-w-0 items-center gap-2.5">
|
|
102
95
|
{headerLeft}
|
|
103
|
-
<
|
|
96
|
+
<ChatSelector onSwitch={onSwitchThread} />
|
|
104
97
|
</div>
|
|
105
98
|
<div className="flex items-center gap-0.5">
|
|
106
99
|
{headerRight}
|
|
@@ -115,19 +108,9 @@ export function ChatPanel({
|
|
|
115
108
|
<div className="relative flex min-h-0 flex-1 flex-col">
|
|
116
109
|
<div
|
|
117
110
|
ref={scrollRef}
|
|
118
|
-
className=
|
|
119
|
-
'flex scrollbar-thin flex-1 flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-12',
|
|
120
|
-
showTopFade && showBottomFade && 'mask-fade-y',
|
|
121
|
-
showTopFade && !showBottomFade && 'mask-fade-top',
|
|
122
|
-
!showTopFade && showBottomFade && 'mask-fade-bottom'
|
|
123
|
-
)}
|
|
111
|
+
className="flex scrollbar-thin flex-1 scroll-fade flex-col overflow-y-auto overscroll-contain px-5 pt-4 pb-12 [--scroll-fade-reveal:8px]"
|
|
124
112
|
>
|
|
125
|
-
<div
|
|
126
|
-
className={cn(
|
|
127
|
-
'flex flex-1 flex-col gap-6',
|
|
128
|
-
contained && 'mx-auto w-full max-w-[var(--chat-max-container)]'
|
|
129
|
-
)}
|
|
130
|
-
>
|
|
113
|
+
<div className="mx-auto flex w-full max-w-(--chat-max-container) flex-1 flex-col gap-6">
|
|
131
114
|
{turns.length === 0 && !processing && <EmptyState />}
|
|
132
115
|
{groupedTurns.map((turn, i) => (
|
|
133
116
|
<TurnView
|
|
@@ -158,10 +141,10 @@ export function ChatPanel({
|
|
|
158
141
|
)}
|
|
159
142
|
</div>
|
|
160
143
|
|
|
161
|
-
<div className=
|
|
144
|
+
<div className="mx-auto flex w-full justify-center px-3">
|
|
162
145
|
{error && (
|
|
163
146
|
<div className="mb-2 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive">
|
|
164
|
-
<span className="flex-1 break-
|
|
147
|
+
<span className="flex-1 wrap-break-word">{error}</span>
|
|
165
148
|
{onDismissError && (
|
|
166
149
|
<Button
|
|
167
150
|
type="button"
|
|
@@ -2,7 +2,7 @@ import type { ReactNode, RefObject } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { motion } from 'motion/react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { IconGhost } from '@tabler/icons-react'
|
|
6
6
|
|
|
7
7
|
import { Button } from '@/client/components/ui/button'
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from '@/client/components/ui/popover'
|
|
@@ -46,10 +46,10 @@ export function ChatPopup({
|
|
|
46
46
|
<Button
|
|
47
47
|
variant="outline"
|
|
48
48
|
size="icon-lg"
|
|
49
|
-
className="
|
|
49
|
+
className="shadow-md hover:shadow-lg"
|
|
50
50
|
aria-label="Agent"
|
|
51
51
|
>
|
|
52
|
-
<
|
|
52
|
+
<IconGhost stroke={1.75} />
|
|
53
53
|
</Button>
|
|
54
54
|
</motion.div>
|
|
55
55
|
</div>
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
DropdownMenuTrigger
|
|
16
16
|
} from '@/client/components/ui/dropdown-menu'
|
|
17
17
|
|
|
18
|
-
type
|
|
18
|
+
type ChatSelectorProps = {
|
|
19
19
|
onSwitch: (sessionId: string | null) => void
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -32,13 +32,13 @@ function formatDate(ms: number) {
|
|
|
32
32
|
return date.toLocaleDateString([], { month: 'short', day: 'numeric' })
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function
|
|
35
|
+
export function ChatSelector({ onSwitch }: ChatSelectorProps) {
|
|
36
36
|
const workspaceId = useWorkspaceId()
|
|
37
37
|
const { data: sessions = [], refetch } = useWorkspaceSessions(workspaceId)
|
|
38
38
|
const activeSessionId = useLive(s => s.activeByWorkspace[workspaceId] ?? null)
|
|
39
39
|
|
|
40
40
|
const active = sessions.find(s => s.sessionId === activeSessionId)
|
|
41
|
-
const label = active?.summary ?? 'New
|
|
41
|
+
const label = active?.summary ?? 'New chat'
|
|
42
42
|
|
|
43
43
|
function handleSelect(sessionId: string | null) {
|
|
44
44
|
onSwitch(sessionId)
|
|
@@ -64,7 +64,7 @@ export function ThreadSelector({ onSwitch }: ThreadSelectorProps) {
|
|
|
64
64
|
onClick={() => handleSelect(null)}
|
|
65
65
|
>
|
|
66
66
|
<IconPlus size={16} stroke={1.75} />
|
|
67
|
-
New
|
|
67
|
+
New chat
|
|
68
68
|
</DropdownMenuItem>
|
|
69
69
|
{sessions.length > 0 && (
|
|
70
70
|
<DropdownMenuGroup>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconFile
|
|
3
|
+
import { IconFile } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
5
|
import { MarkdownContent } from '@/client/features/chat/MarkdownContent'
|
|
6
6
|
import { ToolCallGroup } from '@/client/features/chat/tool-group/ToolCallGroup'
|
|
@@ -9,11 +9,11 @@ import type { Part, Turn } from '@/lib/types'
|
|
|
9
9
|
|
|
10
10
|
export function EmptyState() {
|
|
11
11
|
return (
|
|
12
|
-
<div className="flex flex-1 flex-col items-center justify-center gap-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
<div className="flex flex-1 flex-col items-center justify-center gap-1.5 text-center">
|
|
13
|
+
<h2 className="font-medium">Every journey starts somewhere</h2>
|
|
14
|
+
<p className="mx-auto max-w-sm text-sm text-muted-foreground">
|
|
15
|
+
Chat with your agent, create widgets and views, and manage your workspace context from here.
|
|
16
|
+
</p>
|
|
17
17
|
</div>
|
|
18
18
|
)
|
|
19
19
|
}
|
|
@@ -94,9 +94,8 @@ export function TurnParts({ parts, cwd, processing = false }: TurnPartsProps) {
|
|
|
94
94
|
type TurnViewProps = { turn: Turn; processing?: boolean }
|
|
95
95
|
|
|
96
96
|
// Memoized: the message list maps over grouped turns (stable identities — see
|
|
97
|
-
// `groupTurns` in ChatPanel), so
|
|
98
|
-
//
|
|
99
|
-
// `turn` or `processing` actually changed.
|
|
97
|
+
// `groupTurns` in ChatPanel), so parent re-renders only update rows whose `turn`
|
|
98
|
+
// or `processing` actually changed.
|
|
100
99
|
export const TurnView = memo(function TurnView({ turn, processing = false }: TurnViewProps) {
|
|
101
100
|
const cwd = useWorkspaceLayoutCtx().cwd
|
|
102
101
|
|
|
@@ -66,7 +66,7 @@ export function useSaveThreadConfig(workspaceId: string) {
|
|
|
66
66
|
requestJson(
|
|
67
67
|
`/api/workspaces/${workspaceId}/sessions/${sessionId}/config`,
|
|
68
68
|
jsonRequest('PUT', patch),
|
|
69
|
-
'Failed to save
|
|
69
|
+
'Failed to save chat settings'
|
|
70
70
|
),
|
|
71
71
|
onSuccess: (next, { sessionId }) => {
|
|
72
72
|
queryClient.setQueryData<ThreadConfig>(
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { QueryClient } from '@tanstack/react-query'
|
|
2
|
+
|
|
3
|
+
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
4
|
+
import { liveStore } from '@/client/features/chat/chat-store'
|
|
5
|
+
import { STREAM_RESPONSES } from '@/client/lib/flags'
|
|
6
|
+
import { applyEvent, emptyViewState } from '@/lib/format'
|
|
7
|
+
import type { Part, ViewState, WorkspaceModels } from '@/lib/types'
|
|
8
|
+
|
|
9
|
+
type StartOptimisticTurnInput = {
|
|
10
|
+
queryClient: QueryClient
|
|
11
|
+
workspaceId: string
|
|
12
|
+
sessionId: string
|
|
13
|
+
parts: Part[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function startOptimisticTurn({
|
|
17
|
+
queryClient,
|
|
18
|
+
workspaceId,
|
|
19
|
+
sessionId,
|
|
20
|
+
parts
|
|
21
|
+
}: StartOptimisticTurnInput): string {
|
|
22
|
+
const optimisticId = `optimistic:${crypto.randomUUID()}`
|
|
23
|
+
queryClient.setQueryData<ViewState>(workspaceKeys.events(workspaceId, sessionId), current =>
|
|
24
|
+
applyEvent(current ?? emptyViewState(), {
|
|
25
|
+
kind: 'turn',
|
|
26
|
+
turn: {
|
|
27
|
+
id: optimisticId,
|
|
28
|
+
role: 'user',
|
|
29
|
+
origin: { kind: 'user-input' },
|
|
30
|
+
parts,
|
|
31
|
+
timestamp: new Date().toISOString()
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
liveStore.getState().setProcessing(workspaceId, sessionId, true)
|
|
36
|
+
liveStore.getState().setError(workspaceId, sessionId, null)
|
|
37
|
+
return optimisticId
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function resolveChatRunOptions(
|
|
41
|
+
modelsData: WorkspaceModels | undefined,
|
|
42
|
+
pickedModel: string | undefined,
|
|
43
|
+
pickedEffort: string | undefined
|
|
44
|
+
): { model?: string; effort?: string; stream?: true } {
|
|
45
|
+
const models = modelsData?.models
|
|
46
|
+
const model =
|
|
47
|
+
!pickedModel || !models || models.some(candidate => candidate.value === pickedModel)
|
|
48
|
+
? pickedModel
|
|
49
|
+
: undefined
|
|
50
|
+
const modelInfo = models?.find(candidate => candidate.value === model)
|
|
51
|
+
const effort =
|
|
52
|
+
pickedEffort && (!modelInfo || (modelInfo.supportedEffortLevels ?? []).includes(pickedEffort))
|
|
53
|
+
? pickedEffort
|
|
54
|
+
: undefined
|
|
55
|
+
const stream = STREAM_RESPONSES && modelsData?.supportsStreaming ? true : undefined
|
|
56
|
+
return { model, effort, stream }
|
|
57
|
+
}
|