@fungi.computer/tourtois 0.12.16 → 0.12.18
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 +16 -0
- package/dist/ModelKeys.js +52 -37
- package/dist/oyster-platform-controls.js +7 -1
- package/package.json +4 -4
package/dist/ModelKeys.d.ts
CHANGED
|
@@ -20,6 +20,22 @@ export declare const modelKeysViewSchema: z.ZodObject<{
|
|
|
20
20
|
createdAt: z.ZodNumber;
|
|
21
21
|
validatedAt: z.ZodNumber;
|
|
22
22
|
}, z.core.$strict>>;
|
|
23
|
+
models: z.ZodEnum<{
|
|
24
|
+
missing: "missing";
|
|
25
|
+
ready: "ready";
|
|
26
|
+
unknown: "unknown";
|
|
27
|
+
}>;
|
|
28
|
+
catalogs: z.ZodRecord<z.ZodEnum<{
|
|
29
|
+
"cloudflare-workers-ai": "cloudflare-workers-ai";
|
|
30
|
+
anthropic: "anthropic";
|
|
31
|
+
openai: "openai";
|
|
32
|
+
openrouter: "openrouter";
|
|
33
|
+
}> & z.core.$partial, z.ZodArray<z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
input: z.ZodNumber;
|
|
37
|
+
output: z.ZodNumber;
|
|
38
|
+
}, z.core.$strict>>>;
|
|
23
39
|
agents: z.ZodArray<z.ZodObject<{
|
|
24
40
|
agentId: z.ZodString;
|
|
25
41
|
name: z.ZodString;
|
package/dist/ModelKeys.js
CHANGED
|
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { SectionHeading } from "@fungi.computer/caps/blocks/section-heading";
|
|
3
3
|
import { Button } from "@fungi.computer/caps/components/button";
|
|
4
4
|
import { DataList, DataListHeading, DataRow, FactRow, } from "@fungi.computer/caps/components/data-list";
|
|
5
|
+
import { Select } from "@fungi.computer/caps/components/select";
|
|
5
6
|
import { FormFooter } from "@fungi.computer/caps/components/field";
|
|
6
7
|
import { KeycapButton } from "@fungi.computer/caps/components/keycap";
|
|
7
|
-
import { FormFields, SchemaForm, field, useSchemaForm, } from "@fungi.computer/caps/form";
|
|
8
|
+
import { FormField, FormFields, SchemaForm, field, useSchemaForm, } from "@fungi.computer/caps/form";
|
|
8
9
|
import { Sigil } from "@fungi.computer/sigils";
|
|
9
10
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
11
|
import { useCallback, useMemo, useState } from "react";
|
|
@@ -42,6 +43,13 @@ const agentChoiceSchema = z.strictObject({
|
|
|
42
43
|
/** Every stored key and every Agent with its persisted model choice. */
|
|
43
44
|
export const modelKeysViewSchema = z.strictObject({
|
|
44
45
|
keys: z.array(modelKeySchema),
|
|
46
|
+
models: z.enum(["ready", "missing", "unknown"]),
|
|
47
|
+
catalogs: z.partialRecord(providerSchema, z.array(z.strictObject({
|
|
48
|
+
id: z.string().min(1),
|
|
49
|
+
name: z.string().min(1),
|
|
50
|
+
input: z.number().nonnegative(),
|
|
51
|
+
output: z.number().nonnegative(),
|
|
52
|
+
}))),
|
|
45
53
|
agents: z.array(z.strictObject({
|
|
46
54
|
agentId: z.string().min(1),
|
|
47
55
|
name: z.string(),
|
|
@@ -80,16 +88,24 @@ export function ModelKeys({ port, focus = false, }) {
|
|
|
80
88
|
await port.addKey(draft);
|
|
81
89
|
await refresh();
|
|
82
90
|
setFormKey((current) => current + 1);
|
|
83
|
-
} }, formKey), _jsx(SectionHeading, { children: "Agent models" }), _jsxs(DataList, { density: "compact", "aria-label": "Agent models", children: [_jsx(DataListHeading, { children: "Current choice" }), agents.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "Create an Agent first." })) : null, agents.map((agent) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
} }, formKey), _jsx(SectionHeading, { children: "Agent models" }), view.data.models === "missing" ? (_jsx("p", { role: "status", children: "No model is connected yet. The instance default cannot reply until you add a model key." })) : null, _jsxs(DataList, { density: "compact", "aria-label": "Agent models", children: [_jsx(DataListHeading, { children: "Current choice" }), agents.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "Create an Agent first." })) : null, agents.map((agent) => {
|
|
92
|
+
const selectedKey = keys.find((key) => key.keyId === agent.choice?.keyId);
|
|
93
|
+
const catalog = Object.entries(view.data.catalogs).find(([provider]) => provider === agent.choice?.model.providerId)?.[1];
|
|
94
|
+
const name = catalog?.find((model) => model.id === agent.choice?.model.modelId)?.name;
|
|
95
|
+
const disconnected = view.data.models === "missing" ||
|
|
96
|
+
(agent.choice?.keySource === "byok" &&
|
|
97
|
+
selectedKey === undefined);
|
|
98
|
+
return (_jsxs(FactRow, { icon: _jsx(Sigil, { name: "agent" }), label: agent.name, children: [disconnected
|
|
99
|
+
? "Not connected"
|
|
100
|
+
: agent.choice === null
|
|
101
|
+
? "Unavailable"
|
|
102
|
+
: (name ?? "Instance default"), disconnected || selectedKey === undefined
|
|
103
|
+
? ""
|
|
104
|
+
: ` · ${selectedKey.label}`] }, agent.agentId));
|
|
105
|
+
})] }), agents.length > 0 ? (_jsx(ChooseAgentModel, { agents: agents, keys: keys, catalogs: view.data.catalogs, models: view.data.models, onChoose: async (agentId, draft) => {
|
|
90
106
|
await port.chooseModel(agentId, draft);
|
|
91
107
|
await refresh();
|
|
92
|
-
} })) : null] })) : null] }));
|
|
108
|
+
} }, keys.map((key) => key.keyId).join(":"))) : null] })) : null] }));
|
|
93
109
|
}
|
|
94
110
|
function AddModelKey({ onAdd, }) {
|
|
95
111
|
const schema = useMemo(() => z.object({
|
|
@@ -172,7 +188,7 @@ function AddModelKey({ onAdd, }) {
|
|
|
172
188
|
? ["provider", "label", "accountId", "apiKey"]
|
|
173
189
|
: ["provider", "label", "apiKey"], layout: "columns" })) }) }));
|
|
174
190
|
}
|
|
175
|
-
function ChooseAgentModel({ agents, keys, onChoose, }) {
|
|
191
|
+
function ChooseAgentModel({ agents, keys, catalogs, models, onChoose, }) {
|
|
176
192
|
const schema = useMemo(() => z.object({
|
|
177
193
|
agentId: z.string().meta(field({
|
|
178
194
|
label: "Agent",
|
|
@@ -180,28 +196,9 @@ function ChooseAgentModel({ agents, keys, onChoose, }) {
|
|
|
180
196
|
kind: "select",
|
|
181
197
|
options: Object.fromEntries(agents.map((agent) => [agent.agentId, agent.name])),
|
|
182
198
|
})),
|
|
183
|
-
source: z.string()
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
kind: "select",
|
|
187
|
-
options: {
|
|
188
|
-
[defaultSource]: "Instance default model",
|
|
189
|
-
...Object.fromEntries(keys.map((key) => [
|
|
190
|
-
key.keyId,
|
|
191
|
-
`${key.label} (${providers[key.provider]})`,
|
|
192
|
-
])),
|
|
193
|
-
},
|
|
194
|
-
})),
|
|
195
|
-
modelId: z
|
|
196
|
-
.string()
|
|
197
|
-
.max(256)
|
|
198
|
-
.meta(field({
|
|
199
|
-
label: "Model",
|
|
200
|
-
icon: _jsx(Sigil, { name: "write" }),
|
|
201
|
-
help: "For a key: the provider's model id, such as gpt-6-luna.",
|
|
202
|
-
maxLength: 256,
|
|
203
|
-
})),
|
|
204
|
-
}), [agents, keys]);
|
|
199
|
+
source: z.string(),
|
|
200
|
+
modelId: z.string(),
|
|
201
|
+
}), [agents]);
|
|
205
202
|
const choose = useMutation({
|
|
206
203
|
mutationFn: (input) => onChoose(input.agentId, input.draft),
|
|
207
204
|
});
|
|
@@ -209,15 +206,20 @@ function ChooseAgentModel({ agents, keys, onChoose, }) {
|
|
|
209
206
|
schema,
|
|
210
207
|
defaultValues: {
|
|
211
208
|
agentId: agents[0]?.agentId ?? "",
|
|
212
|
-
source: defaultSource,
|
|
209
|
+
source: keys[0]?.keyId ?? defaultSource,
|
|
213
210
|
modelId: "",
|
|
214
211
|
},
|
|
215
212
|
onSubmit: async (value) => {
|
|
216
213
|
const key = keys.find((item) => item.keyId === value.source);
|
|
217
214
|
if (value.source !== defaultSource && key === undefined)
|
|
218
215
|
return { kind: "refused", error: "Choose a stored key." };
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
const available = key === undefined ? [] : (catalogs[key.provider] ?? []);
|
|
217
|
+
const modelId = value.modelId || available[0]?.id;
|
|
218
|
+
if (key !== undefined && !available.some((item) => item.id === modelId))
|
|
219
|
+
return {
|
|
220
|
+
kind: "refused",
|
|
221
|
+
error: "Choose a supported model for this key.",
|
|
222
|
+
};
|
|
221
223
|
try {
|
|
222
224
|
await choose.mutateAsync({
|
|
223
225
|
agentId: value.agentId,
|
|
@@ -226,7 +228,7 @@ function ChooseAgentModel({ agents, keys, onChoose, }) {
|
|
|
226
228
|
: {
|
|
227
229
|
keyId: key.keyId,
|
|
228
230
|
provider: key.provider,
|
|
229
|
-
modelId:
|
|
231
|
+
modelId: modelId ?? "",
|
|
230
232
|
},
|
|
231
233
|
});
|
|
232
234
|
return { kind: "saved" };
|
|
@@ -241,5 +243,18 @@ function ChooseAgentModel({ agents, keys, onChoose, }) {
|
|
|
241
243
|
}
|
|
242
244
|
},
|
|
243
245
|
});
|
|
244
|
-
return (
|
|
246
|
+
return (_jsxs(SchemaForm, { model: model, layout: "columns", "aria-label": "Choose Agent model", disabled: choose.isPending, footer: _jsx(FormFooter, { divider: false, error: model.error, children: _jsx(Button, { type: "submit", children: choose.isPending ? "Saving…" : "Save model" }) }), children: [_jsx(FormFields, { model: model, names: ["agentId"] }), _jsx(FormField, { form: model.form, name: "source", label: "Runs on", children: (source) => (_jsxs(Select, { name: "source", value: source.state.value, onChange: (event) => {
|
|
247
|
+
source.handleChange(event.target.value);
|
|
248
|
+
model.form.setFieldValue("modelId", "");
|
|
249
|
+
}, children: [_jsx("option", { value: defaultSource, children: models === "missing"
|
|
250
|
+
? "Instance default — not connected"
|
|
251
|
+
: "Instance default model" }), keys.map((key) => (_jsxs("option", { value: key.keyId, children: [key.label, " (", providers[key.provider], ")"] }, key.keyId)))] })) }), _jsx(model.form.Subscribe, { selector: (state) => state.values.source, children: (source) => {
|
|
252
|
+
const key = keys.find((item) => item.keyId === source);
|
|
253
|
+
if (key === undefined)
|
|
254
|
+
return null;
|
|
255
|
+
const available = catalogs[key.provider] ?? [];
|
|
256
|
+
return (_jsx(FormField, { form: model.form, name: "modelId", label: "Model", description: "USD per million tokens: input / output. Lowest combined rate first.", children: (choice) => (_jsxs(Select, { name: "modelId", value: choice.state.value || (available[0]?.id ?? ""), onChange: (event) => {
|
|
257
|
+
choice.handleChange(event.target.value);
|
|
258
|
+
}, children: [available.length === 0 ? (_jsx("option", { value: "", children: "No supported models available" })) : null, available.map((item) => (_jsxs("option", { value: item.id, children: [item.name, " \u00B7 $", item.input, " / $", item.output] }, item.id)))] })) }));
|
|
259
|
+
} })] }));
|
|
245
260
|
}
|
|
@@ -113,7 +113,13 @@ const modelKeys = {
|
|
|
113
113
|
]);
|
|
114
114
|
return modelKeysViewSchema.parse({
|
|
115
115
|
keys: z.object({ keys: z.unknown() }).parse(keys).keys,
|
|
116
|
-
|
|
116
|
+
...z
|
|
117
|
+
.object({
|
|
118
|
+
agents: z.unknown(),
|
|
119
|
+
catalogs: z.unknown(),
|
|
120
|
+
models: z.unknown(),
|
|
121
|
+
})
|
|
122
|
+
.parse(agents),
|
|
117
123
|
});
|
|
118
124
|
},
|
|
119
125
|
addKey: async (draft) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/tourtois",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.18",
|
|
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",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
84
84
|
"@fungi.computer/gills": "0.3.0",
|
|
85
85
|
"@fungi.computer/maosaico": "0.1.2",
|
|
86
|
-
"@fungi.computer/parakeet": "0.11.
|
|
86
|
+
"@fungi.computer/parakeet": "0.11.9",
|
|
87
87
|
"@fungi.computer/puffball": "0.5.5",
|
|
88
88
|
"@fungi.computer/shiitake": "0.12.4",
|
|
89
|
-
"@fungi.computer/sigils": "0.3.
|
|
89
|
+
"@fungi.computer/sigils": "0.3.1",
|
|
90
90
|
"@fungi.computer/sprite": "0.2.2",
|
|
91
91
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
92
92
|
"@fungi.computer/whistle": "0.3.0",
|
|
@@ -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.32",
|
|
110
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
111
111
|
"@fungi.computer/forage": "0.3.5",
|
|
112
112
|
"@fungi.computer/mycelium": "0.3.8",
|