@agentprojectcontext/apx 1.15.6 → 1.17.0
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/package.json +46 -5
- package/src/cli/commands/log.js +113 -0
- package/src/cli/commands/overlay.js +253 -0
- package/src/cli/commands/sys.js +88 -16
- package/src/cli/index.js +23 -1
- package/src/cli/terminal-chat/renderer.js +71 -56
- package/src/cli-ts/commands/agent.ts +173 -0
- package/src/cli-ts/commands/chat.ts +119 -0
- package/src/cli-ts/commands/daemon.ts +112 -0
- package/src/cli-ts/commands/exec.ts +109 -0
- package/src/cli-ts/commands/mcp.ts +235 -0
- package/src/cli-ts/commands/session.ts +224 -0
- package/src/cli-ts/commands/status.ts +61 -0
- package/src/cli-ts/http.ts +36 -0
- package/src/cli-ts/index.ts +73 -0
- package/src/cli-ts/ui.ts +107 -0
- package/src/core/logging.js +81 -0
- package/src/daemon/api.js +58 -0
- package/src/daemon/engines/anthropic.js +60 -1
- package/src/daemon/engines/index.js +2 -1
- package/src/daemon/engines/ollama.js +70 -3
- package/src/daemon/index.js +58 -0
- package/src/daemon/overlay-ws.js +40 -0
- package/src/daemon/plugins/index.js +2 -1
- package/src/daemon/plugins/overlay.js +177 -0
- package/src/daemon/plugins/telegram.js +15 -3
- package/src/daemon/super-agent-langchain.js +296 -0
- package/src/daemon/super-agent.js +115 -19
- package/src/daemon/transcription.js +262 -59
- package/src/daemon/whisper-server.py +57 -6
- package/src/overlay/index.html +44 -0
- package/src/overlay/main.js +480 -0
- package/src/overlay/package.json +3 -0
- package/src/overlay/preload.js +34 -0
- package/src/overlay/renderer.js +371 -0
- package/src/overlay/style.css +250 -0
- package/src/tui/_shims/cli-error.ts +6 -0
- package/src/tui/_shims/cli-logo.ts +18 -0
- package/src/tui/_shims/cli-ui.ts +1 -0
- package/src/tui/_shims/config-console-state.ts +7 -0
- package/src/tui/_shims/core-any.ts +30 -0
- package/src/tui/_shims/core-binary.ts +13 -0
- package/src/tui/_shims/core-flag.ts +3 -0
- package/src/tui/_shims/core-log.ts +14 -0
- package/src/tui/_shims/lsp-language.ts +1 -0
- package/src/tui/_shims/opencode-any.ts +135 -0
- package/src/tui/_shims/opencode-sdk-v2.ts +48 -0
- package/src/tui/_shims/plugin-tui.ts +13 -0
- package/src/tui/_shims/provider-provider.ts +10 -0
- package/src/tui/_shims/session-retry.ts +1 -0
- package/src/tui/_shims/session-schema.ts +15 -0
- package/src/tui/_shims/session-session.ts +3 -0
- package/src/tui/_shims/snapshot.ts +4 -0
- package/src/tui/_shims/tool-any.ts +18 -0
- package/src/tui/_shims/util-error.ts +7 -0
- package/src/tui/_shims/util-filesystem.ts +79 -0
- package/src/tui/_shims/util-format.ts +7 -0
- package/src/tui/_shims/util-iife.ts +3 -0
- package/src/tui/_shims/util-locale.ts +10 -0
- package/src/tui/_shims/util-process.ts +38 -0
- package/src/tui/app.tsx +783 -0
- package/src/tui/asset/charge.wav +0 -0
- package/src/tui/asset/pulse-a.wav +0 -0
- package/src/tui/asset/pulse-b.wav +0 -0
- package/src/tui/asset/pulse-c.wav +0 -0
- package/src/tui/attach.ts +100 -0
- package/src/tui/component/bg-pulse-render.ts +436 -0
- package/src/tui/component/bg-pulse.tsx +99 -0
- package/src/tui/component/border.tsx +21 -0
- package/src/tui/component/dialog-agent.tsx +31 -0
- package/src/tui/component/dialog-console-org.tsx +103 -0
- package/src/tui/component/dialog-mcp.tsx +85 -0
- package/src/tui/component/dialog-model.tsx +175 -0
- package/src/tui/component/dialog-provider.tsx +456 -0
- package/src/tui/component/dialog-retry-action.tsx +160 -0
- package/src/tui/component/dialog-session-delete-failed.tsx +99 -0
- package/src/tui/component/dialog-session-list.tsx +323 -0
- package/src/tui/component/dialog-session-rename.tsx +31 -0
- package/src/tui/component/dialog-skill.tsx +36 -0
- package/src/tui/component/dialog-stash.tsx +87 -0
- package/src/tui/component/dialog-status.tsx +168 -0
- package/src/tui/component/dialog-tag.tsx +44 -0
- package/src/tui/component/dialog-theme-list.tsx +50 -0
- package/src/tui/component/dialog-variant.tsx +39 -0
- package/src/tui/component/dialog-workspace-create.tsx +302 -0
- package/src/tui/component/dialog-workspace-file-changes.tsx +138 -0
- package/src/tui/component/dialog-workspace-unavailable.tsx +69 -0
- package/src/tui/component/error-component.tsx +92 -0
- package/src/tui/component/logo.tsx +896 -0
- package/src/tui/component/plugin-route-missing.tsx +14 -0
- package/src/tui/component/prompt/autocomplete.tsx +869 -0
- package/src/tui/component/prompt/cwd.ts +0 -0
- package/src/tui/component/prompt/frecency.tsx +90 -0
- package/src/tui/component/prompt/history.tsx +108 -0
- package/src/tui/component/prompt/index.tsx +1809 -0
- package/src/tui/component/prompt/part.ts +16 -0
- package/src/tui/component/prompt/stash.tsx +101 -0
- package/src/tui/component/prompt/traits.ts +35 -0
- package/src/tui/component/spinner.tsx +24 -0
- package/src/tui/component/startup-loading.tsx +63 -0
- package/src/tui/component/todo-item.tsx +32 -0
- package/src/tui/component/use-connected.tsx +9 -0
- package/src/tui/component/workspace-label.tsx +19 -0
- package/src/tui/config/cwd.ts +5 -0
- package/src/tui/config/keybind.ts +432 -0
- package/src/tui/config/tui-migrate.ts +154 -0
- package/src/tui/config/tui-schema.ts +34 -0
- package/src/tui/config/tui.ts +46 -0
- package/src/tui/context/aggregate-failures.ts +34 -0
- package/src/tui/context/args.tsx +15 -0
- package/src/tui/context/command-palette.tsx +163 -0
- package/src/tui/context/directory.ts +15 -0
- package/src/tui/context/editor-zed.ts +283 -0
- package/src/tui/context/editor.ts +468 -0
- package/src/tui/context/event-apx.ts +22 -0
- package/src/tui/context/event.ts +6 -0
- package/src/tui/context/exit.tsx +60 -0
- package/src/tui/context/helper.tsx +25 -0
- package/src/tui/context/kv.tsx +81 -0
- package/src/tui/context/local.tsx +608 -0
- package/src/tui/context/path-format.tsx +39 -0
- package/src/tui/context/project-apx.tsx +48 -0
- package/src/tui/context/project.tsx +7 -0
- package/src/tui/context/prompt.tsx +18 -0
- package/src/tui/context/route.tsx +52 -0
- package/src/tui/context/sdk-apx.tsx +185 -0
- package/src/tui/context/sdk.tsx +6 -0
- package/src/tui/context/sync-apx.tsx +178 -0
- package/src/tui/context/sync-v2.tsx +16 -0
- package/src/tui/context/sync.tsx +118 -0
- package/src/tui/context/theme/aura.json +69 -0
- package/src/tui/context/theme/ayu.json +80 -0
- package/src/tui/context/theme/carbonfox.json +248 -0
- package/src/tui/context/theme/catppuccin-frappe.json +230 -0
- package/src/tui/context/theme/catppuccin-macchiato.json +230 -0
- package/src/tui/context/theme/catppuccin.json +112 -0
- package/src/tui/context/theme/cobalt2.json +225 -0
- package/src/tui/context/theme/cursor.json +249 -0
- package/src/tui/context/theme/dracula.json +219 -0
- package/src/tui/context/theme/everforest.json +241 -0
- package/src/tui/context/theme/flexoki.json +237 -0
- package/src/tui/context/theme/github.json +233 -0
- package/src/tui/context/theme/gruvbox.json +242 -0
- package/src/tui/context/theme/kanagawa.json +77 -0
- package/src/tui/context/theme/lucent-orng.json +234 -0
- package/src/tui/context/theme/material.json +235 -0
- package/src/tui/context/theme/matrix.json +77 -0
- package/src/tui/context/theme/mercury.json +252 -0
- package/src/tui/context/theme/monokai.json +221 -0
- package/src/tui/context/theme/nightowl.json +221 -0
- package/src/tui/context/theme/nord.json +223 -0
- package/src/tui/context/theme/one-dark.json +84 -0
- package/src/tui/context/theme/opencode.json +245 -0
- package/src/tui/context/theme/orng.json +249 -0
- package/src/tui/context/theme/osaka-jade.json +93 -0
- package/src/tui/context/theme/palenight.json +222 -0
- package/src/tui/context/theme/rosepine.json +234 -0
- package/src/tui/context/theme/solarized.json +223 -0
- package/src/tui/context/theme/synthwave84.json +226 -0
- package/src/tui/context/theme/tokyonight.json +243 -0
- package/src/tui/context/theme/vercel.json +245 -0
- package/src/tui/context/theme/vesper.json +218 -0
- package/src/tui/context/theme/zenburn.json +223 -0
- package/src/tui/context/theme.tsx +1247 -0
- package/src/tui/context/tui-config.tsx +9 -0
- package/src/tui/event.ts +16 -0
- package/src/tui/feature-plugins/home/footer.tsx +94 -0
- package/src/tui/feature-plugins/home/tips-view.tsx +166 -0
- package/src/tui/feature-plugins/home/tips.tsx +59 -0
- package/src/tui/feature-plugins/sidebar/context.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/files.tsx +63 -0
- package/src/tui/feature-plugins/sidebar/footer.tsx +94 -0
- package/src/tui/feature-plugins/sidebar/lsp.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/mcp.tsx +97 -0
- package/src/tui/feature-plugins/sidebar/todo.tsx +49 -0
- package/src/tui/feature-plugins/system/plugins.tsx +269 -0
- package/src/tui/feature-plugins/system/session-v2.tsx +1143 -0
- package/src/tui/feature-plugins/system/which-key.tsx +608 -0
- package/src/tui/keymap.tsx +166 -0
- package/src/tui/layer.ts +6 -0
- package/src/tui/plugin/api.tsx +381 -0
- package/src/tui/plugin/command-shim.ts +109 -0
- package/src/tui/plugin/internal.ts +33 -0
- package/src/tui/plugin/runtime.ts +1069 -0
- package/src/tui/plugin/slots.tsx +60 -0
- package/src/tui/routes/home.tsx +96 -0
- package/src/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
- package/src/tui/routes/session/dialog-message.tsx +108 -0
- package/src/tui/routes/session/dialog-subagent.tsx +26 -0
- package/src/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/tui/routes/session/footer.tsx +91 -0
- package/src/tui/routes/session/index.tsx +188 -0
- package/src/tui/routes/session/permission.tsx +722 -0
- package/src/tui/routes/session/question.tsx +490 -0
- package/src/tui/routes/session/sidebar.tsx +102 -0
- package/src/tui/routes/session/subagent-footer.tsx +133 -0
- package/src/tui/run.ts +84 -0
- package/src/tui/thread.ts +261 -0
- package/src/tui/tsconfig.json +40 -0
- package/src/tui/ui/dialog-alert.tsx +66 -0
- package/src/tui/ui/dialog-confirm.tsx +108 -0
- package/src/tui/ui/dialog-export-options.tsx +217 -0
- package/src/tui/ui/dialog-help.tsx +40 -0
- package/src/tui/ui/dialog-prompt.tsx +101 -0
- package/src/tui/ui/dialog-select.tsx +553 -0
- package/src/tui/ui/dialog.tsx +211 -0
- package/src/tui/ui/link.tsx +34 -0
- package/src/tui/ui/spinner.ts +368 -0
- package/src/tui/ui/toast.tsx +111 -0
- package/src/tui/util/clipboard.ts +217 -0
- package/src/tui/util/editor.ts +37 -0
- package/src/tui/util/model.ts +23 -0
- package/src/tui/util/provider-origin.ts +7 -0
- package/src/tui/util/revert-diff.ts +18 -0
- package/src/tui/util/scroll.ts +25 -0
- package/src/tui/util/selection.ts +65 -0
- package/src/tui/util/signal.ts +41 -0
- package/src/tui/util/sound.ts +156 -0
- package/src/tui/util/transcript.ts +112 -0
- package/src/tui/validate-session.ts +29 -0
- package/src/tui/win32.ts +130 -0
- package/src/tui/worker.ts +104 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createResource, createMemo } from "solid-js"
|
|
2
|
+
import { DialogSelect } from "@tui/ui/dialog-select"
|
|
3
|
+
import { useSDK } from "@tui/context/sdk"
|
|
4
|
+
import { useDialog } from "@tui/ui/dialog"
|
|
5
|
+
import { useToast } from "@tui/ui/toast"
|
|
6
|
+
import { useTheme } from "@tui/context/theme"
|
|
7
|
+
import type { ExperimentalConsoleListOrgsResponse } from "@opencode-ai/sdk/v2"
|
|
8
|
+
|
|
9
|
+
type OrgOption = ExperimentalConsoleListOrgsResponse["orgs"][number]
|
|
10
|
+
|
|
11
|
+
const accountHost = (url: string) => {
|
|
12
|
+
try {
|
|
13
|
+
return new URL(url).host
|
|
14
|
+
} catch {
|
|
15
|
+
return url
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const accountLabel = (item: Pick<OrgOption, "accountEmail" | "accountUrl">) =>
|
|
20
|
+
`${item.accountEmail} ${accountHost(item.accountUrl)}`
|
|
21
|
+
|
|
22
|
+
export function DialogConsoleOrg() {
|
|
23
|
+
const sdk = useSDK()
|
|
24
|
+
const dialog = useDialog()
|
|
25
|
+
const toast = useToast()
|
|
26
|
+
const { theme } = useTheme()
|
|
27
|
+
|
|
28
|
+
const [orgs] = createResource(async () => {
|
|
29
|
+
const result = await sdk.client.experimental.console.listOrgs({}, { throwOnError: true })
|
|
30
|
+
return result.data?.orgs ?? []
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const current = createMemo(() => orgs()?.find((item) => item.active))
|
|
34
|
+
|
|
35
|
+
const options = createMemo(() => {
|
|
36
|
+
const listed = orgs()
|
|
37
|
+
if (listed === undefined) {
|
|
38
|
+
return [
|
|
39
|
+
{
|
|
40
|
+
title: "Loading orgs...",
|
|
41
|
+
value: "loading",
|
|
42
|
+
onSelect: () => {},
|
|
43
|
+
},
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (listed.length === 0) {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
title: "No orgs found",
|
|
51
|
+
value: "empty",
|
|
52
|
+
onSelect: () => {},
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return listed
|
|
58
|
+
.toSorted((a, b) => {
|
|
59
|
+
const activeAccountA = a.active ? 0 : 1
|
|
60
|
+
const activeAccountB = b.active ? 0 : 1
|
|
61
|
+
if (activeAccountA !== activeAccountB) return activeAccountA - activeAccountB
|
|
62
|
+
|
|
63
|
+
const accountCompare = accountLabel(a).localeCompare(accountLabel(b))
|
|
64
|
+
if (accountCompare !== 0) return accountCompare
|
|
65
|
+
|
|
66
|
+
return a.orgName.localeCompare(b.orgName)
|
|
67
|
+
})
|
|
68
|
+
.map((item) => ({
|
|
69
|
+
title: item.orgName,
|
|
70
|
+
value: item,
|
|
71
|
+
category: accountLabel(item),
|
|
72
|
+
categoryView: (
|
|
73
|
+
<box flexDirection="row" gap={2}>
|
|
74
|
+
<text fg={theme.accent}>{item.accountEmail}</text>
|
|
75
|
+
<text fg={theme.textMuted}>{accountHost(item.accountUrl)}</text>
|
|
76
|
+
</box>
|
|
77
|
+
),
|
|
78
|
+
onSelect: async () => {
|
|
79
|
+
if (item.active) {
|
|
80
|
+
dialog.clear()
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
await sdk.client.experimental.console.switchOrg(
|
|
85
|
+
{
|
|
86
|
+
accountID: item.accountID,
|
|
87
|
+
orgID: item.orgID,
|
|
88
|
+
},
|
|
89
|
+
{ throwOnError: true },
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
await sdk.client.instance.dispose()
|
|
93
|
+
toast.show({
|
|
94
|
+
message: `Switched to ${item.orgName}`,
|
|
95
|
+
variant: "info",
|
|
96
|
+
})
|
|
97
|
+
dialog.clear()
|
|
98
|
+
},
|
|
99
|
+
}))
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
return <DialogSelect<string | OrgOption> title="Switch org" options={options()} current={current()} />
|
|
103
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createMemo, createSignal } from "solid-js"
|
|
2
|
+
import { useLocal } from "@tui/context/local"
|
|
3
|
+
import { useSync } from "@tui/context/sync"
|
|
4
|
+
import { map, pipe, entries, sortBy } from "remeda"
|
|
5
|
+
import { DialogSelect, type DialogSelectRef, type DialogSelectOption } from "@tui/ui/dialog-select"
|
|
6
|
+
import { useTheme } from "../context/theme"
|
|
7
|
+
import { TextAttributes } from "@opentui/core"
|
|
8
|
+
import { useSDK } from "@tui/context/sdk"
|
|
9
|
+
|
|
10
|
+
function Status(props: { enabled: boolean; loading: boolean }) {
|
|
11
|
+
const { theme } = useTheme()
|
|
12
|
+
if (props.loading) {
|
|
13
|
+
return <span style={{ fg: theme.textMuted }}>⋯ Loading</span>
|
|
14
|
+
}
|
|
15
|
+
if (props.enabled) {
|
|
16
|
+
return <span style={{ fg: theme.success, attributes: TextAttributes.BOLD }}>✓ Enabled</span>
|
|
17
|
+
}
|
|
18
|
+
return <span style={{ fg: theme.textMuted }}>○ Disabled</span>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function DialogMcp() {
|
|
22
|
+
const local = useLocal()
|
|
23
|
+
const sync = useSync()
|
|
24
|
+
const sdk = useSDK()
|
|
25
|
+
const [, setRef] = createSignal<DialogSelectRef<unknown>>()
|
|
26
|
+
const [loading, setLoading] = createSignal<string | null>(null)
|
|
27
|
+
|
|
28
|
+
const options = createMemo(() => {
|
|
29
|
+
// Track sync data and loading state to trigger re-render when they change
|
|
30
|
+
const mcpData = sync.data.mcp
|
|
31
|
+
const loadingMcp = loading()
|
|
32
|
+
|
|
33
|
+
return pipe(
|
|
34
|
+
mcpData ?? {},
|
|
35
|
+
entries(),
|
|
36
|
+
sortBy(([name]) => name),
|
|
37
|
+
map(([name, status]) => ({
|
|
38
|
+
value: name,
|
|
39
|
+
title: name,
|
|
40
|
+
description: status.status === "failed" ? "failed" : status.status,
|
|
41
|
+
footer: <Status enabled={local.mcp.isEnabled(name)} loading={loadingMcp === name} />,
|
|
42
|
+
category: undefined,
|
|
43
|
+
})),
|
|
44
|
+
)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const actions = createMemo(() => [
|
|
48
|
+
{
|
|
49
|
+
command: "dialog.mcp.toggle",
|
|
50
|
+
title: "toggle",
|
|
51
|
+
onTrigger: async (option: DialogSelectOption<string>) => {
|
|
52
|
+
// Prevent toggling while an operation is already in progress
|
|
53
|
+
if (loading() !== null) return
|
|
54
|
+
|
|
55
|
+
setLoading(option.value)
|
|
56
|
+
try {
|
|
57
|
+
await local.mcp.toggle(option.value)
|
|
58
|
+
// Refresh MCP status from server
|
|
59
|
+
const status = await sdk.client.mcp.status()
|
|
60
|
+
if (status.data) {
|
|
61
|
+
sync.set("mcp", status.data)
|
|
62
|
+
} else {
|
|
63
|
+
console.error("Failed to refresh MCP status: no data returned")
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("Failed to toggle MCP:", error)
|
|
67
|
+
} finally {
|
|
68
|
+
setLoading(null)
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<DialogSelect
|
|
76
|
+
ref={setRef}
|
|
77
|
+
title="MCPs"
|
|
78
|
+
options={options()}
|
|
79
|
+
actions={actions()}
|
|
80
|
+
onSelect={(_option) => {
|
|
81
|
+
// Don't close on select, only on escape
|
|
82
|
+
}}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { createMemo, createSignal } from "solid-js"
|
|
2
|
+
import { useLocal } from "@tui/context/local"
|
|
3
|
+
import { useSync } from "@tui/context/sync"
|
|
4
|
+
import { map, pipe, flatMap, entries, filter, sortBy, take } from "remeda"
|
|
5
|
+
import { DialogSelect } from "@tui/ui/dialog-select"
|
|
6
|
+
import { useDialog } from "@tui/ui/dialog"
|
|
7
|
+
import { createDialogProviderOptions, DialogProvider } from "./dialog-provider"
|
|
8
|
+
import { DialogVariant } from "./dialog-variant"
|
|
9
|
+
import * as fuzzysort from "fuzzysort"
|
|
10
|
+
import { useConnected } from "./use-connected"
|
|
11
|
+
|
|
12
|
+
export function DialogModel(props: { providerID?: string }) {
|
|
13
|
+
const local = useLocal()
|
|
14
|
+
const sync = useSync()
|
|
15
|
+
const dialog = useDialog()
|
|
16
|
+
const [query, setQuery] = createSignal("")
|
|
17
|
+
|
|
18
|
+
const connected = useConnected()
|
|
19
|
+
const providers = createDialogProviderOptions()
|
|
20
|
+
|
|
21
|
+
const showExtra = createMemo(() => connected() && !props.providerID)
|
|
22
|
+
|
|
23
|
+
const options = createMemo(() => {
|
|
24
|
+
const needle = query().trim()
|
|
25
|
+
const showSections = showExtra() && needle.length === 0
|
|
26
|
+
const favorites = connected() ? local.model.favorite() : []
|
|
27
|
+
const recents = local.model.recent()
|
|
28
|
+
|
|
29
|
+
function toOptions(items: typeof favorites, category: string) {
|
|
30
|
+
if (!showSections) return []
|
|
31
|
+
return items.flatMap((item) => {
|
|
32
|
+
const provider = sync.data.provider.find((x) => x.id === item.providerID)
|
|
33
|
+
if (!provider) return []
|
|
34
|
+
const model = provider.models[item.modelID]
|
|
35
|
+
if (!model) return []
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
key: item,
|
|
39
|
+
value: { providerID: provider.id, modelID: model.id },
|
|
40
|
+
title: model.name ?? item.modelID,
|
|
41
|
+
description: provider.name,
|
|
42
|
+
category,
|
|
43
|
+
disabled: provider.id === "opencode" && model.id.includes("-nano"),
|
|
44
|
+
footer: model.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
|
45
|
+
onSelect: () => {
|
|
46
|
+
onSelect(provider.id, model.id)
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const favoriteOptions = toOptions(favorites, "Favorites")
|
|
54
|
+
const recentOptions = toOptions(
|
|
55
|
+
recents.filter(
|
|
56
|
+
(item) => !favorites.some((fav) => fav.providerID === item.providerID && fav.modelID === item.modelID),
|
|
57
|
+
),
|
|
58
|
+
"Recent",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const providerOptions = pipe(
|
|
62
|
+
sync.data.provider,
|
|
63
|
+
sortBy(
|
|
64
|
+
(provider) => provider.id !== "opencode",
|
|
65
|
+
(provider) => provider.name,
|
|
66
|
+
),
|
|
67
|
+
flatMap((provider) =>
|
|
68
|
+
pipe(
|
|
69
|
+
provider.models,
|
|
70
|
+
entries(),
|
|
71
|
+
filter(([_, info]) => info.status !== "deprecated"),
|
|
72
|
+
filter(([_, info]) => (props.providerID ? info.providerID === props.providerID : true)),
|
|
73
|
+
map(([model, info]) => ({
|
|
74
|
+
value: { providerID: provider.id, modelID: model },
|
|
75
|
+
title: info.name ?? model,
|
|
76
|
+
description: favorites.some((item) => item.providerID === provider.id && item.modelID === model)
|
|
77
|
+
? "(Favorite)"
|
|
78
|
+
: undefined,
|
|
79
|
+
category: connected() ? provider.name : undefined,
|
|
80
|
+
disabled: provider.id === "opencode" && model.includes("-nano"),
|
|
81
|
+
footer: info.cost?.input === 0 && provider.id === "opencode" ? "Free" : undefined,
|
|
82
|
+
onSelect() {
|
|
83
|
+
onSelect(provider.id, model)
|
|
84
|
+
},
|
|
85
|
+
})),
|
|
86
|
+
filter((x) => {
|
|
87
|
+
if (!showSections) return true
|
|
88
|
+
if (favorites.some((item) => item.providerID === x.value.providerID && item.modelID === x.value.modelID))
|
|
89
|
+
return false
|
|
90
|
+
if (recents.some((item) => item.providerID === x.value.providerID && item.modelID === x.value.modelID))
|
|
91
|
+
return false
|
|
92
|
+
return true
|
|
93
|
+
}),
|
|
94
|
+
sortBy(
|
|
95
|
+
(x) => x.footer !== "Free",
|
|
96
|
+
(x) => x.title,
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
const popularProviders = !connected()
|
|
103
|
+
? pipe(
|
|
104
|
+
providers(),
|
|
105
|
+
map((option) => ({
|
|
106
|
+
...option,
|
|
107
|
+
category: "Popular providers",
|
|
108
|
+
})),
|
|
109
|
+
take(6),
|
|
110
|
+
)
|
|
111
|
+
: []
|
|
112
|
+
|
|
113
|
+
if (needle) {
|
|
114
|
+
return [
|
|
115
|
+
...fuzzysort.go(needle, providerOptions, { keys: ["title", "category"] }).map((x) => x.obj),
|
|
116
|
+
...fuzzysort.go(needle, popularProviders, { keys: ["title"] }).map((x) => x.obj),
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return [...favoriteOptions, ...recentOptions, ...providerOptions, ...popularProviders]
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
const provider = createMemo(() =>
|
|
124
|
+
props.providerID ? sync.data.provider.find((x) => x.id === props.providerID) : null,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
const title = createMemo(() => {
|
|
128
|
+
const value = provider()
|
|
129
|
+
if (!value) return "Select model"
|
|
130
|
+
return value.name
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
function onSelect(providerID: string, modelID: string) {
|
|
134
|
+
local.model.set({ providerID, modelID }, { recent: true })
|
|
135
|
+
const list = local.model.variant.list()
|
|
136
|
+
const cur = local.model.variant.selected()
|
|
137
|
+
if (cur === "default" || (cur && list.includes(cur))) {
|
|
138
|
+
dialog.clear()
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
if (list.length > 0) {
|
|
142
|
+
dialog.replace(() => <DialogVariant />)
|
|
143
|
+
return
|
|
144
|
+
}
|
|
145
|
+
dialog.clear()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<DialogSelect<ReturnType<typeof options>[number]["value"]>
|
|
150
|
+
options={options()}
|
|
151
|
+
actions={[
|
|
152
|
+
{
|
|
153
|
+
command: "model.dialog.provider",
|
|
154
|
+
title: connected() ? "Connect provider" : "View all providers",
|
|
155
|
+
onTrigger() {
|
|
156
|
+
dialog.replace(() => <DialogProvider />)
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
command: "model.dialog.favorite",
|
|
161
|
+
title: "Favorite",
|
|
162
|
+
disabled: !connected(),
|
|
163
|
+
onTrigger: (option) => {
|
|
164
|
+
local.model.toggleFavorite(option.value as { providerID: string; modelID: string })
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
]}
|
|
168
|
+
onFilter={setQuery}
|
|
169
|
+
flat={true}
|
|
170
|
+
skipFilter={true}
|
|
171
|
+
title={title()}
|
|
172
|
+
current={local.model.current()}
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
}
|