@fungi.computer/tourtois 0.12.4 → 0.12.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/ModelKeys.d.ts +2 -1
- package/dist/ModelKeys.js +11 -3
- package/dist/SettingsNavigation.js +1 -1
- package/dist/SystemSettings.js +17 -2
- package/dist/oyster-setup.js +2 -2
- package/dist/settings-routes.d.ts +13 -0
- package/dist/settings-routes.js +20 -3
- package/package.json +2 -2
package/dist/ModelKeys.d.ts
CHANGED
|
@@ -62,7 +62,8 @@ export type ModelKeysPort = Readonly<{
|
|
|
62
62
|
* Model keys on a standalone host: store a provider API key once, then pick
|
|
63
63
|
* which model and key each Agent runs on. A key is never shown again.
|
|
64
64
|
*/
|
|
65
|
-
export declare function ModelKeys({ port }: {
|
|
65
|
+
export declare function ModelKeys({ port, focus, }: {
|
|
66
66
|
port: ModelKeysPort;
|
|
67
|
+
focus?: boolean;
|
|
67
68
|
}): import("react/jsx-runtime").JSX.Element;
|
|
68
69
|
export {};
|
package/dist/ModelKeys.js
CHANGED
|
@@ -7,7 +7,7 @@ import { KeycapButton } from "@fungi.computer/caps/components/keycap";
|
|
|
7
7
|
import { SchemaForm, field, useSchemaForm } from "@fungi.computer/caps/form";
|
|
8
8
|
import { Sigil } from "@fungi.computer/sigils";
|
|
9
9
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
|
-
import { useMemo, useState } from "react";
|
|
10
|
+
import { useCallback, useMemo, useState } from "react";
|
|
11
11
|
import * as z from "zod";
|
|
12
12
|
import { SettingsItem } from "./settings-item.js";
|
|
13
13
|
const providers = {
|
|
@@ -48,9 +48,17 @@ const defaultSource = "default";
|
|
|
48
48
|
* Model keys on a standalone host: store a provider API key once, then pick
|
|
49
49
|
* which model and key each Agent runs on. A key is never shown again.
|
|
50
50
|
*/
|
|
51
|
-
export function ModelKeys({ port }) {
|
|
51
|
+
export function ModelKeys({ port, focus = false, }) {
|
|
52
52
|
const client = useQueryClient();
|
|
53
53
|
const view = useQuery({ queryKey, queryFn: () => port.read() });
|
|
54
|
+
const status = view.status;
|
|
55
|
+
const focusSetup = useCallback((section) => {
|
|
56
|
+
if (!focus || status === "pending")
|
|
57
|
+
return;
|
|
58
|
+
const target = section?.querySelector("select") ??
|
|
59
|
+
section?.querySelector("button");
|
|
60
|
+
target?.focus();
|
|
61
|
+
}, [focus, status]);
|
|
54
62
|
const refresh = () => client.invalidateQueries({ queryKey });
|
|
55
63
|
const remove = useMutation({
|
|
56
64
|
mutationFn: (keyId) => port.removeKey(keyId),
|
|
@@ -60,7 +68,7 @@ export function ModelKeys({ port }) {
|
|
|
60
68
|
const agents = view.data?.agents ?? [];
|
|
61
69
|
// A fresh form after each stored key, so the key field empties.
|
|
62
70
|
const [formKey, setFormKey] = useState(0);
|
|
63
|
-
return (_jsxs("section", { className: "tourtois-settings-stack tourtois-model-keys", "aria-label": "Model keys", children: [_jsx(SectionHeading, { children: "Model keys" }), _jsx("p", { className: "tourtois-settings-lede", children: "Bring your own provider API key. It is checked with the provider, sealed on this instance and never shown again. Each Agent can run on any key." }), view.isPending ? _jsx("p", { children: "Loading model keys\u2026" }) : null, view.isError ? (_jsxs("div", { role: "status", className: "tourtois-settings-notice", children: [_jsx("p", { children: "Model keys could not be loaded." }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => void view.refetch(), children: "Retry" })] })) : null, view.isSuccess ? (_jsxs(_Fragment, { children: [_jsxs(DataList, { "aria-label": "Model keys", children: [keys.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "No model keys yet." })) : null, keys.map((key) => (_jsx(DataRow, { children: _jsx(SettingsItem, { icon: _jsx(Sigil, { name: "restricted" }), title: key.label, detail: _jsx("p", { children: providers[key.provider] }), actions: _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${key.label}`, disabled: remove.isPending, onClick: () => {
|
|
71
|
+
return (_jsxs("section", { ref: focusSetup, className: "tourtois-settings-stack tourtois-model-keys", "aria-label": "Model keys", children: [_jsx(SectionHeading, { children: "Model keys" }), _jsx("p", { className: "tourtois-settings-lede", children: "Bring your own provider API key. It is checked with the provider, sealed on this instance and never shown again. Each Agent can run on any key." }), view.isPending ? _jsx("p", { children: "Loading model keys\u2026" }) : null, view.isError ? (_jsxs("div", { role: "status", className: "tourtois-settings-notice", children: [_jsx("p", { children: "Model keys could not be loaded." }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => void view.refetch(), children: "Retry" })] })) : null, view.isSuccess ? (_jsxs(_Fragment, { children: [_jsxs(DataList, { "aria-label": "Model keys", children: [keys.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "No model keys yet." })) : null, keys.map((key) => (_jsx(DataRow, { children: _jsx(SettingsItem, { icon: _jsx(Sigil, { name: "restricted" }), title: key.label, detail: _jsx("p", { children: providers[key.provider] }), actions: _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${key.label}`, disabled: remove.isPending, onClick: () => {
|
|
64
72
|
remove.mutate(key.keyId);
|
|
65
73
|
} }) }) }, key.keyId)))] }), remove.isError ? (_jsx("p", { role: "alert", children: "The model key could not be removed." })) : null, _jsx(AddModelKey, { onAdd: async (draft) => {
|
|
66
74
|
await port.addKey(draft);
|
package/dist/SystemSettings.js
CHANGED
|
@@ -30,6 +30,15 @@ export function SystemSettings({ location: requestedLocation, sections: ceiling,
|
|
|
30
30
|
const connectors = location?.category === "connectors";
|
|
31
31
|
const computersSection = location?.category === "computers";
|
|
32
32
|
const keysSection = location?.category === "keys";
|
|
33
|
+
const keysTarget = location?.category === "keys" ? location.target : "all";
|
|
34
|
+
const keyContent = useRef(null);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const content = keyContent.current;
|
|
37
|
+
if (keysTarget !== "media" || content === null)
|
|
38
|
+
return;
|
|
39
|
+
content.scrollTop = 0;
|
|
40
|
+
content.querySelector("a")?.focus();
|
|
41
|
+
}, [keysTarget]);
|
|
33
42
|
const keyableApps = useMemo(() => apps.flatMap((app) => app.installationId === null
|
|
34
43
|
? []
|
|
35
44
|
: [
|
|
@@ -122,7 +131,9 @@ export function SystemSettings({ location: requestedLocation, sections: ceiling,
|
|
|
122
131
|
}, onOpenChange: (next) => {
|
|
123
132
|
if (!next)
|
|
124
133
|
close();
|
|
125
|
-
}, children: _jsxs(DialogContent, { finalFocus: restoreFocus,
|
|
134
|
+
}, children: _jsxs(DialogContent, { finalFocus: restoreFocus, initialFocus: keysTarget === "all"
|
|
135
|
+
? true
|
|
136
|
+
: () => keyContent.current?.querySelector(keysTarget === "model" ? "select" : "a") ?? true, render: _jsx(WindowFrame, { floating: true }), keepMounted: false, className: "tourtois-system-settings", children: [_jsx(DialogTitle, { className: "sr-only", children: "System Settings" }), _jsx(DialogDescription, { className: "sr-only", children: desktopOnly
|
|
126
137
|
? "Your desktop and App settings."
|
|
127
138
|
: "Your avatar, Channels, Connectors, App access and App settings." }), _jsx(WindowHeader, { ...headerProps }), _jsx(SettingsLeaveContext.Provider, { value: register, children: _jsxs("div", { className: "tourtois-settings-layout", children: [_jsx(SettingsNavigation, { sections: sections, desktopOnly: desktopOnly, location: location, apps: apps, onNavigate: (next) => {
|
|
128
139
|
if (location?.category === "selling" && location.appId !== null)
|
|
@@ -133,7 +144,11 @@ export function SystemSettings({ location: requestedLocation, sections: ceiling,
|
|
|
133
144
|
appCount,
|
|
134
145
|
defaultAppCount: ports.summary?.defaultAppCount ?? null,
|
|
135
146
|
computerCount: ports.summary?.computerCount ?? null,
|
|
136
|
-
}, onNavigate: onNavigate })) : null, avatar && ports.avatar !== undefined ? (_jsx("div", { className: "tourtois-settings-content", children: _jsx(AvatarSettings, { save: ports.avatar.save }) })) : null, connectors && connections !== undefined ? (location.target.kind === "list" ? (_jsx(Connections, { port: connections, target: location.target, onNavigate: onNavigate })) : connections.hostSections ? (_jsx(connections.hostSections, { target: location.target, onNavigate: onNavigate })) : null) : null, location?.category === "selling" && ports.selling !== undefined ? (_jsx(ports.selling, { appId: location.appId, onNavigate: onNavigate })) : null, computersSection && ports.computers !== undefined ? (_jsx("div", { className: "tourtois-settings-content", children: _jsx(ports.computers, {}) })) : null, keysSection ? (_jsxs("div", {
|
|
147
|
+
}, onNavigate: onNavigate })) : null, avatar && ports.avatar !== undefined ? (_jsx("div", { className: "tourtois-settings-content", children: _jsx(AvatarSettings, { save: ports.avatar.save }) })) : null, connectors && connections !== undefined ? (location.target.kind === "list" ? (_jsx(Connections, { port: connections, target: location.target, onNavigate: onNavigate })) : connections.hostSections ? (_jsx(connections.hostSections, { target: location.target, onNavigate: onNavigate })) : null) : null, location?.category === "selling" && ports.selling !== undefined ? (_jsx(ports.selling, { appId: location.appId, onNavigate: onNavigate })) : null, computersSection && ports.computers !== undefined ? (_jsx("div", { className: "tourtois-settings-content", children: _jsx(ports.computers, {}) })) : null, keysSection ? (_jsxs("div", { ref: keyContent, "aria-label": keysTarget === "model"
|
|
148
|
+
? "Model setup"
|
|
149
|
+
: keysTarget === "media"
|
|
150
|
+
? "Image setup"
|
|
151
|
+
: "Keys settings", className: "tourtois-settings-content tourtois-settings-stack", children: [keysTarget === "all" && keys !== undefined ? (_jsx(Keys, { port: keys, apps: keyableApps })) : null, keysTarget !== "media" && ports.modelKeys !== undefined ? (_jsx(ModelKeys, { port: ports.modelKeys, focus: keysTarget === "model" })) : null, keysTarget === "media" ? (_jsxs("section", { className: "tourtois-settings-stack", "aria-label": "Image models", children: [_jsx(SectionHeading, { children: "Image models" }), _jsx("p", { className: "tourtois-settings-lede", children: "Prints creates images with Cloudflare Workers AI. Local Oyster trials have no Cloudflare account for image generation." }), _jsx("p", { children: "Deploy this Oyster to your Cloudflare account with Workers AI enabled, then open Prints there." }), _jsx(Button, { asChild: true, className: "w-fit", children: _jsx("a", { href: "https://github.com/fungi-computer/oyster#deploy-to-cloudflare", target: "_blank", rel: "noreferrer", children: "Set up image generation" }) })] })) : null] })) : null, location?.category === "channels" &&
|
|
137
152
|
ports.channels !== undefined ? (_jsx(ports.channels, {})) : null, defaults && ports.defaults !== undefined ? (_jsx("div", { className: "tourtois-settings-content", children: _jsx(ports.defaults, { onAccepted: onAccepted }) })) : null, appSection && appKey === null ? (_jsxs("section", { className: "tourtois-settings-content", "aria-label": "Choose an App", children: [_jsx(SectionHeading, { className: "tourtois-settings-app-heading", children: desktopOnly ? "App desktop" : "App permissions" }), _jsx(DataList, { density: "compact", "aria-label": "Apps to review", children: apps.map((app) => (_jsx(DataRow, { className: "p-0", children: _jsx(ActionRow, { label: app.displayName ?? app.appId, icon: _jsx(AppIcon, { roles: app.roles, icon: app.icon }), onClick: () => {
|
|
138
153
|
onNavigate({
|
|
139
154
|
category: "apps",
|
package/dist/oyster-setup.js
CHANGED
|
@@ -9,9 +9,9 @@ export const oysterSetupSchema = z.strictObject({
|
|
|
9
9
|
});
|
|
10
10
|
/** Where each need is fixed in this host's Settings. */
|
|
11
11
|
export function settingsForNeed(need) {
|
|
12
|
-
//
|
|
12
|
+
// Model keys and image setup have separate destinations; runtimes live in Computers.
|
|
13
13
|
return need === "model" || need === "media"
|
|
14
|
-
? { category: "keys" }
|
|
14
|
+
? { category: "keys", target: need }
|
|
15
15
|
: { category: "computers" };
|
|
16
16
|
}
|
|
17
17
|
/** The setup port: facts read live, plus the Settings page for each need. */
|
|
@@ -31,6 +31,11 @@ export declare const settingsLocationSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
31
31
|
category: z.ZodLiteral<"computers">;
|
|
32
32
|
}, z.core.$strict>, z.ZodObject<{
|
|
33
33
|
category: z.ZodLiteral<"keys">;
|
|
34
|
+
target: z.ZodEnum<{
|
|
35
|
+
media: "media";
|
|
36
|
+
all: "all";
|
|
37
|
+
model: "model";
|
|
38
|
+
}>;
|
|
34
39
|
}, z.core.$strict>, z.ZodObject<{
|
|
35
40
|
category: z.ZodLiteral<"defaults">;
|
|
36
41
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -112,6 +117,14 @@ export declare function createSettingsRouter(): RouterCore<import("@tanstack/rou
|
|
|
112
117
|
category: "computers";
|
|
113
118
|
}, unknown, unknown, unknown, unknown, undefined>, import("@tanstack/react-router").Route<unknown, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/keys", "/keys", string, "/keys", undefined, import("@tanstack/react-router").ResolveParams<"/keys">, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, () => {
|
|
114
119
|
category: "keys";
|
|
120
|
+
target: "all";
|
|
121
|
+
}, unknown, unknown, unknown, unknown, undefined>, import("@tanstack/react-router").Route<unknown, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/keys/$target", "/keys/$target", string, "/keys/$target", undefined, {
|
|
122
|
+
target: "media" | "model";
|
|
123
|
+
}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, ({ params }: import("@tanstack/react-router").LoaderFnContext<unknown, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/keys/$target", {
|
|
124
|
+
target: "media" | "model";
|
|
125
|
+
}, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, unknown, undefined>) => {
|
|
126
|
+
category: "keys";
|
|
127
|
+
target: "media" | "model";
|
|
115
128
|
}, unknown, unknown, unknown, unknown, undefined>, import("@tanstack/react-router").Route<unknown, import("@tanstack/react-router").RootRoute<import("@tanstack/react-router").Register, undefined, {}, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, undefined, unknown, unknown, unknown, unknown, undefined>, "/channels", "/channels", string, "/channels", undefined, import("@tanstack/react-router").ResolveParams<"/channels">, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, () => {
|
|
116
129
|
category: "channels";
|
|
117
130
|
}, unknown, unknown, unknown, unknown, undefined>], unknown, unknown, unknown, undefined>, "never", false, import("@tanstack/history").RouterHistory, Record<string, any>>;
|
package/dist/settings-routes.js
CHANGED
|
@@ -23,7 +23,10 @@ export const settingsLocationSchema = z.discriminatedUnion("category", [
|
|
|
23
23
|
]),
|
|
24
24
|
}),
|
|
25
25
|
z.strictObject({ category: z.literal("computers") }),
|
|
26
|
-
z.strictObject({
|
|
26
|
+
z.strictObject({
|
|
27
|
+
category: z.literal("keys"),
|
|
28
|
+
target: z.enum(["all", "model", "media"]),
|
|
29
|
+
}),
|
|
27
30
|
z.strictObject({ category: z.literal("defaults") }),
|
|
28
31
|
z.strictObject({ category: z.literal("channels") }),
|
|
29
32
|
z.strictObject({ category: z.literal("selling"), appId: appKey.nullable() }),
|
|
@@ -120,7 +123,15 @@ export function createSettingsRouter() {
|
|
|
120
123
|
const keys = createRoute({
|
|
121
124
|
getParentRoute: () => root,
|
|
122
125
|
path: "/keys",
|
|
123
|
-
loader: () => ({ category: "keys" }),
|
|
126
|
+
loader: () => ({ category: "keys", target: "all" }),
|
|
127
|
+
});
|
|
128
|
+
const keySetup = createRoute({
|
|
129
|
+
getParentRoute: () => root,
|
|
130
|
+
path: "/keys/$target",
|
|
131
|
+
params: {
|
|
132
|
+
parse: (params) => z.object({ target: z.enum(["model", "media"]) }).parse(params),
|
|
133
|
+
},
|
|
134
|
+
loader: ({ params }) => ({ category: "keys", target: params.target }),
|
|
124
135
|
});
|
|
125
136
|
const channels = createRoute({
|
|
126
137
|
getParentRoute: () => root,
|
|
@@ -154,6 +165,7 @@ export function createSettingsRouter() {
|
|
|
154
165
|
connectorAgent,
|
|
155
166
|
computers,
|
|
156
167
|
keys,
|
|
168
|
+
keySetup,
|
|
157
169
|
channels,
|
|
158
170
|
]);
|
|
159
171
|
const router = createRouter({
|
|
@@ -204,7 +216,12 @@ export function navigateSettings(router, location) {
|
|
|
204
216
|
case "computers":
|
|
205
217
|
return router.navigate({ to: "/computers" });
|
|
206
218
|
case "keys":
|
|
207
|
-
return
|
|
219
|
+
return location.target === "all"
|
|
220
|
+
? router.navigate({ to: "/keys" })
|
|
221
|
+
: router.navigate({
|
|
222
|
+
to: "/keys/$target",
|
|
223
|
+
params: { target: location.target },
|
|
224
|
+
});
|
|
208
225
|
case "apps":
|
|
209
226
|
return location.appKey === null
|
|
210
227
|
? router.navigate({ to: "/apps" })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/tourtois",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Tourtois: the trusted desktop shell for Oyster and Fungi, with host-supplied Settings sections",
|
|
6
6
|
"type": "module",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"react": "^18.3.1 || ^19.2.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@fungi.computer/oyster": "0.19.
|
|
109
|
+
"@fungi.computer/oyster": "0.19.5",
|
|
110
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
111
111
|
"@fungi.computer/forage": "0.3.5",
|
|
112
112
|
"@fungi.computer/mycelium": "0.3.8",
|