@fungi.computer/tourtois 0.27.1 → 0.28.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.
@@ -1,4 +1,6 @@
1
1
  import "@fungi.computer/parakeet/styles.css";
2
2
  import "./shell.css";
3
3
  import type { MountPlatformControls } from "@fungi.computer/nacre/shell-module";
4
+ /** Image generation on this Oyster: Cloudflare Workers AI, set up once. */
5
+ export declare function OysterImageModels(): import("react/jsx-runtime").JSX.Element;
4
6
  export declare const mountPlatformControls: MountPlatformControls;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // Standalone Oyster Settings chrome, loaded from the chosen shell Release.
3
3
  // App Permissions frame Oyster's own grants page, never its implementation.
4
4
  // Connections, Keys and Computers retain their existing host-backed ports.
@@ -8,6 +8,10 @@ import "./shell.css";
8
8
  import { AppError } from "@fungi.computer/agar";
9
9
  import { createQueryClient } from "@fungi.computer/agar/query";
10
10
  import { workbenchComputerDirectorySchema, workbenchDirectorySchema, } from "@fungi.computer/nacre/workbench-directory";
11
+ import { SectionHeading } from "@fungi.computer/caps/blocks/section-heading";
12
+ import { Button } from "@fungi.computer/caps/components/button";
13
+ import { FormFooter } from "@fungi.computer/caps/components/field";
14
+ import { Prose } from "@fungi.computer/caps/components/prose";
11
15
  import { toast } from "@fungi.computer/caps/components/toaster";
12
16
  import { QueryClientProvider } from "@tanstack/react-query";
13
17
  import * as S from "effect/Schema";
@@ -16,7 +20,7 @@ import { useEffect, useRef, useState } from "react";
16
20
  import { createRoot } from "react-dom/client";
17
21
  import { connectionAddedSchema, connectionsViewSchema, connectionToolsSchema, createPlatformControls, PlatformControlsView, } from "./platform-controls.js";
18
22
  import { createOysterSetupPort, oysterSetupSchema } from "./oyster-setup.js";
19
- import { modelKeysViewSchema } from "./ModelKeys.js";
23
+ import { agentModelsViewSchema, vaultViewSchema, VaultRefusal, } from "./Vault.js";
20
24
  import { WORKBENCH_NOTICES } from "./app-toast.js";
21
25
  import { settingsLocationSchema } from "./settings-routes.js";
22
26
  import { OysterComputers, createOysterComputersPort, } from "./OysterComputers.js";
@@ -90,61 +94,202 @@ const modelKeyMessages = {
90
94
  model_unavailable: "That provider has no such model",
91
95
  invalid_model_choice: "That model choice is not valid",
92
96
  };
93
- const modelKeyMessage = (code) => new Map(Object.entries(modelKeyMessages)).get(code) ?? code;
94
- /** A model-key request whose host refusal code reads as a sentence. */
95
- async function modelKeyRequest(path, init, refused) {
97
+ const vaultMessages = {
98
+ not_found: "That credential was removed. Reload the Vault",
99
+ conflict: "That credential changed since you opened it. Reload the Vault",
100
+ denied: "You can't change this credential",
101
+ invalid_input: "Check the name, sites and value, then try again",
102
+ duplicate_name: "A secret with that reference already exists",
103
+ limit: "Revoke a secret before adding another",
104
+ invalid_endpoint: "Bind it to public https hosts only: exact names, no addresses or wildcards",
105
+ unsupported_subject: "That can't be given a secret",
106
+ };
107
+ /** A request whose host refusal code reads as a sentence. */
108
+ async function sentenceRequest(path, init, refused, messages) {
96
109
  try {
97
110
  return await ownerRequest(path, init, refused);
98
111
  }
99
112
  catch (cause) {
100
- if (cause instanceof AppError)
101
- throw new Error(modelKeyMessage(cause.message), { cause });
113
+ const sentence = cause instanceof AppError
114
+ ? new Map(Object.entries(messages)).get(cause.message)
115
+ : undefined;
116
+ if (sentence !== undefined)
117
+ throw new VaultRefusal(sentence, { cause });
102
118
  throw cause;
103
119
  }
104
120
  }
121
+ const modelKeyRequest = (path, init, refused) => sentenceRequest(path, init, refused, modelKeyMessages);
122
+ const vaultRequest = (path, init, refused) => sentenceRequest(path, init, refused, vaultMessages);
105
123
  const jsonInit = (method, body) => ({
106
124
  method,
107
125
  headers: { "Content-Type": "application/json" },
108
126
  body,
109
127
  });
110
- /** Owner-direct model-key custody: a key goes in once and never comes back. */
111
- const modelKeys = {
128
+ /** The instance Vault as `/api/vault` lists it: no value, ever. */
129
+ const oysterVaultWire = z.object({
130
+ modelKeys: z.array(z.object({
131
+ keyId: z.string(),
132
+ provider: z.string(),
133
+ label: z.string(),
134
+ createdAt: z.number(),
135
+ })),
136
+ credentials: z.array(z.unknown()),
137
+ coverage: z.unknown(),
138
+ });
139
+ const agentModelsWire = z.object({
140
+ agents: z.unknown(),
141
+ catalogs: z.unknown(),
142
+ models: z.unknown(),
143
+ providers: z.array(z.object({ id: z.string(), label: z.string(), accountId: z.boolean() })),
144
+ });
145
+ const subjectWire = z.object({
146
+ kind: z.enum(["agent", "computer", "app", "team-key"]),
147
+ id: z.string().min(1),
148
+ });
149
+ const credentialUsageWire = z.object({
150
+ usage: z.array(z.object({
151
+ subject: subjectWire,
152
+ host: z.string().nullable(),
153
+ method: z.string(),
154
+ outcome: z.enum([
155
+ "placed",
156
+ "refused_destination",
157
+ "refused_grant",
158
+ "upstream_status",
159
+ ]),
160
+ status: z.number().nullable(),
161
+ lastAt: z.number(),
162
+ count: z.number().int().positive(),
163
+ })),
164
+ });
165
+ const modelKeyUsageWire = z.object({
166
+ usage: z.array(z.object({
167
+ subject: subjectWire.nullable(),
168
+ outcome: z.enum(["upstream_status", "failed"]),
169
+ status: z.number().nullable(),
170
+ lastAt: z.number(),
171
+ count: z.number().int().positive(),
172
+ })),
173
+ });
174
+ const credentialPath = (connectionId, suffix = "") => `/api/vault/credentials/${encodeURIComponent(connectionId)}${suffix}`;
175
+ const subjectPath = (connectionId, subject) => credentialPath(connectionId, `/subjects/${encodeURIComponent(subject.kind)}/${encodeURIComponent(subject.id)}`);
176
+ /**
177
+ * Owner-direct Vault: one page over the instance's model keys and Connection
178
+ * credentials. A value goes in once and never comes back. The owner is the
179
+ * only actor on an Oyster, so everything here is theirs to manage.
180
+ */
181
+ const vault = {
112
182
  read: async () => {
113
- const [keys, agents] = await Promise.all([
114
- json("/api/model-keys"),
183
+ const [stored, agents, computers] = await Promise.all([
184
+ json("/api/vault"),
115
185
  json("/api/agent-models"),
186
+ oysterComputerTargets(),
116
187
  ]);
117
- return modelKeysViewSchema.parse({
118
- keys: z.object({ keys: z.unknown() }).parse(keys).keys,
119
- ...z
120
- .object({
121
- agents: z.unknown(),
122
- catalogs: z.unknown(),
123
- models: z.unknown(),
124
- })
125
- .parse(agents),
188
+ const held = oysterVaultWire.parse(stored);
189
+ const models = agentModelsWire.parse(agents);
190
+ return vaultViewSchema.parse({
191
+ role: { manageTeam: true, managePersonal: true },
192
+ coverage: held.coverage,
193
+ providers: models.providers.map((provider) => ({
194
+ ...provider,
195
+ baseUrl: false,
196
+ })),
197
+ scopes: ["team"],
198
+ modelKeys: held.modelKeys.map((key) => ({
199
+ keyId: key.keyId,
200
+ provider: key.provider,
201
+ label: key.label,
202
+ scope: "team",
203
+ createdAt: key.createdAt,
204
+ baseUrl: null,
205
+ })),
206
+ credentials: held.credentials,
207
+ subjects: {
208
+ agents: agentModelsViewSchema.shape.agents
209
+ .parse(models.agents)
210
+ .map((agent) => ({ id: agent.agentId, name: agent.name })),
211
+ computers: computers.map((computer) => ({
212
+ id: computer.id,
213
+ name: computer.name,
214
+ })),
215
+ },
126
216
  });
127
217
  },
128
- addKey: async (draft) => {
129
- await modelKeyRequest("/api/model-keys", jsonInit("POST", JSON.stringify(draft)), "The model key was refused");
218
+ addSecret: async (draft) => {
219
+ await vaultRequest("/api/vault/secrets", jsonInit("POST", JSON.stringify(draft)), "The secret was refused");
130
220
  },
131
- removeKey: async (keyId) => {
132
- await modelKeyRequest(`/api/model-keys/${encodeURIComponent(keyId)}`, { method: "DELETE" }, "The model key could not be removed");
221
+ updateCredential: async (connectionId, change) => {
222
+ await vaultRequest(credentialPath(connectionId), jsonInit("PUT", JSON.stringify(change)), "The change was refused");
133
223
  },
134
- chooseModel: async (agentId, draft) => {
135
- await modelKeyRequest(`/api/agent-models/${encodeURIComponent(agentId)}`, jsonInit("PUT", JSON.stringify(draft.keyId === null
136
- ? {
137
- keySource: "workers-ai",
138
- model: {
139
- providerId: "cloudflare-workers-ai",
140
- modelId: "@cf/moonshotai/kimi-k2.6",
141
- },
142
- }
143
- : {
144
- keySource: "byok",
145
- keyId: draft.keyId,
146
- model: { providerId: draft.provider, modelId: draft.modelId },
147
- })), "The model could not be saved");
224
+ revokeCredential: async (connectionId, expectedVersion) => {
225
+ await vaultRequest(credentialPath(connectionId), jsonInit("DELETE", JSON.stringify({ expectedVersion })), "The credential could not be revoked");
226
+ },
227
+ grant: async (connectionId, subject) => {
228
+ await vaultRequest(subjectPath(connectionId, subject), { method: "PUT" }, "The grant was refused");
229
+ },
230
+ ungrant: async (connectionId, subject) => {
231
+ await vaultRequest(subjectPath(connectionId, subject), { method: "DELETE" }, "The grant could not be removed");
232
+ },
233
+ credentialUsage: async (connectionId) => credentialUsageWire
234
+ .parse(await json(credentialPath(connectionId, "/usage")))
235
+ .usage.map((use) => ({
236
+ subject: use.subject,
237
+ host: use.host,
238
+ method: use.method,
239
+ outcome: use.outcome,
240
+ status: use.status,
241
+ count: use.count,
242
+ lastAt: use.lastAt,
243
+ })),
244
+ modelKeys: {
245
+ add: async ({ provider, label, apiKey, accountId }) => {
246
+ await modelKeyRequest("/api/model-keys", jsonInit("POST", JSON.stringify({
247
+ provider,
248
+ label,
249
+ apiKey,
250
+ // JSON drops an absent account ID, as the strict door expects.
251
+ accountId,
252
+ })), "The model key was refused");
253
+ },
254
+ remove: async (keyId) => {
255
+ await modelKeyRequest(`/api/model-keys/${encodeURIComponent(keyId)}`, { method: "DELETE" }, "The model key could not be removed");
256
+ },
257
+ usage: async (keyId) => modelKeyUsageWire
258
+ .parse(await json(`/api/vault/model-keys/${encodeURIComponent(keyId)}/usage`))
259
+ .usage.map((use) => ({
260
+ subject: use.subject,
261
+ host: null,
262
+ method: null,
263
+ outcome: use.outcome,
264
+ status: use.status,
265
+ count: use.count,
266
+ lastAt: use.lastAt,
267
+ })),
268
+ },
269
+ agentModels: {
270
+ read: async () => {
271
+ const models = agentModelsWire.parse(await json("/api/agent-models"));
272
+ return agentModelsViewSchema.parse({
273
+ agents: models.agents,
274
+ catalogs: models.catalogs,
275
+ models: models.models,
276
+ });
277
+ },
278
+ choose: async (agentId, draft) => {
279
+ await modelKeyRequest(`/api/agent-models/${encodeURIComponent(agentId)}`, jsonInit("PUT", JSON.stringify(draft.keyId === null
280
+ ? {
281
+ keySource: "workers-ai",
282
+ model: {
283
+ providerId: "cloudflare-workers-ai",
284
+ modelId: "@cf/moonshotai/kimi-k2.6",
285
+ },
286
+ }
287
+ : {
288
+ keySource: "byok",
289
+ keyId: draft.keyId,
290
+ model: { providerId: draft.provider, modelId: draft.modelId },
291
+ })), "The model could not be saved");
292
+ },
148
293
  },
149
294
  };
150
295
  const directory = async () => workbenchDirectorySchema.parse(await json("/api/workbench/directory"));
@@ -299,6 +444,10 @@ const oysterWebsiteCopy = {
299
444
  visitors: (agentName) => `A chat with ${agentName}. Visitors don’t sign in, and they see its replies. Message limits apply to each visitor.`,
300
445
  reach: (agentName) => `Visitors talk to ${agentName} itself, with ${agentName}’s own tools and permissions. They cannot sign in to this Oyster or reach your account. The address list limits where the chat appears, not who can call it directly.`,
301
446
  };
447
+ /** Image generation on this Oyster: Cloudflare Workers AI, set up once. */
448
+ export function OysterImageModels() {
449
+ return (_jsxs("section", { className: "tourtois-settings-stack", "aria-label": "Image models", children: [_jsx(SectionHeading, { children: "Image models" }), _jsx("p", { className: "tourtois-settings-lede", children: "Flux images use Cloudflare Workers AI." }), _jsxs(Prose, { children: [_jsx("p", { children: "Local trials can upload images. To generate:" }), _jsxs("ol", { children: [_jsx("li", { children: "Enable Workers AI in your Cloudflare account." }), _jsx("li", { children: "Deploy this Oyster using the setup guide." }), _jsx("li", { children: "Open Prints at the deployed Oyster address." })] })] }), _jsx(FormFooter, { divider: false, children: _jsx(Button, { asChild: true, children: _jsx("a", { href: "https://docs.fungi.computer/guides/run-your-own-oyster/#image-models", target: "_blank", rel: "noreferrer", children: "Set up Cloudflare Workers AI" }) }) })] }));
450
+ }
302
451
  export const mountPlatformControls = (root, input) => {
303
452
  const keys = createOysterKeysPort(input.keysWire);
304
453
  const requestAppAccess = (target, request, dialog) => input.requestAppAccess(target, request, {
@@ -310,7 +459,15 @@ export const mountPlatformControls = (root, input) => {
310
459
  }),
311
460
  });
312
461
  const controls = createPlatformControls({
313
- sections: ["home", "apps", "connectors", "computers", "keys", "channels"],
462
+ sections: [
463
+ "home",
464
+ "apps",
465
+ "connectors",
466
+ "computers",
467
+ "vault",
468
+ "keys",
469
+ "channels",
470
+ ],
314
471
  });
315
472
  const computersPort = createOysterComputersPort(new URL(window.location.origin));
316
473
  const computers = () => (_jsx(OysterComputers, { teamId: input.teamId, port: computersPort, onChanged: controls.changed }));
@@ -325,15 +482,18 @@ export const mountPlatformControls = (root, input) => {
325
482
  subscribeSettingsClosed: controls.subscribeSettingsClosed,
326
483
  });
327
484
  // A key added or removed changes what is ready before Settings closes.
328
- const trackedModelKeys = {
329
- ...modelKeys,
330
- addKey: async (draft) => {
331
- await modelKeys.addKey(draft);
332
- setup.changed();
333
- },
334
- removeKey: async (keyId) => {
335
- await modelKeys.removeKey(keyId);
336
- setup.changed();
485
+ const trackedVault = {
486
+ ...vault,
487
+ modelKeys: {
488
+ ...vault.modelKeys,
489
+ add: async (draft) => {
490
+ await vault.modelKeys.add(draft);
491
+ setup.changed();
492
+ },
493
+ remove: async (keyId) => {
494
+ await vault.modelKeys.remove(keyId);
495
+ setup.changed();
496
+ },
337
497
  },
338
498
  };
339
499
  const client = createQueryClient();
@@ -344,7 +504,8 @@ export const mountPlatformControls = (root, input) => {
344
504
  computers,
345
505
  channels,
346
506
  keys,
347
- modelKeys: trackedModelKeys,
507
+ imageModels: OysterImageModels,
508
+ vault: trackedVault,
348
509
  requestAppAccess,
349
510
  appPermissions: OysterAppPermissions,
350
511
  } }) }));
@@ -10,10 +10,12 @@ export const oysterSetupSchema = z.strictObject({
10
10
  });
11
11
  /** Where each need is fixed in this host's Settings. */
12
12
  export function settingsForNeed(need) {
13
- // Model keys and image setup have separate destinations; runtimes live in Computers.
14
- return need === "model" || need === "media"
15
- ? { category: "keys", target: need }
16
- : { category: "computers" };
13
+ // A model key lives in the Vault, image setup beside Keys and runtimes in Computers.
14
+ return need === "model"
15
+ ? { category: "vault", target: "model" }
16
+ : need === "media"
17
+ ? { category: "keys", target: "media" }
18
+ : { category: "computers" };
17
19
  }
18
20
  /** The setup port: facts read live, plus the Settings page for each need. */
19
21
  export function createOysterSetupPort(deps) {
@@ -8,6 +8,7 @@ export { parseSettingsLocation } from "./settings-routes.js";
8
8
  import type { SettingsSectionPorts } from "./settings-sections.js";
9
9
  export type { SettingsSectionPorts, TeamAdministrationPort, } from "./settings-sections.js";
10
10
  export { connectionAddedSchema, connectionToolsSchema, connectionsViewSchema, type ConnectionAccess, type ConnectionDraft, type ConnectionsPort, type ConnectionsView, } from "./Connections.js";
11
+ export { agentModelsViewSchema, vaultViewSchema, VaultRefusal, type AgentModelChoiceDraft, type AgentModelsView, type VaultCredential, type VaultCredentialChange, type VaultDestination, type VaultModelKey, type VaultModelKeyDraft, type VaultPlacement, type VaultPort, type VaultSecretDraft, type VaultSubject, type VaultUse, type VaultView, } from "./Vault.js";
11
12
  export { type KeyAppOption, type KeyGrantOption, type KeyGrantPreviewProps, type KeyTargetOption, type KeyChange, type KeyIssueDraft, type KeyIssueResult, type KeysPort, type KeysView, } from "./Keys.js";
12
13
  /**
13
14
  * Team administration a dashboard may ask for but never performs itself:
@@ -13,6 +13,7 @@ import { createSettingsRouter, navigateSettings, settingsLocationSchema, } from
13
13
  export { parseSettingsLocation } from "./settings-routes.js";
14
14
  import { MemberAvatarSource } from "./member-avatar.js";
15
15
  export { connectionAddedSchema, connectionToolsSchema, connectionsViewSchema, } from "./Connections.js";
16
+ export { agentModelsViewSchema, vaultViewSchema, VaultRefusal, } from "./Vault.js";
16
17
  export {} from "./Keys.js";
17
18
  const overlayLayers = ["popover", "dialog", "toast", "tooltip"];
18
19
  /** The shell's own layer roots, or the body where no shell is mounted. */
@@ -6,7 +6,7 @@ import type { ReactNode } from "react";
6
6
  */
7
7
  export declare function SettingsItem({ icon, title, detail, actions, }: {
8
8
  /** A Sigil at 16px; decorative, the title names the item. */
9
- icon: ReactNode;
9
+ icon?: ReactNode;
10
10
  title: ReactNode;
11
11
  detail?: ReactNode;
12
12
  /** Compact keycaps or a status dot. */
@@ -5,5 +5,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
5
  * keys and connected servers all use this line.
6
6
  */
7
7
  export function SettingsItem({ icon, title, detail, actions, }) {
8
- return (_jsxs("div", { className: "tourtois-settings-item", children: [_jsxs("div", { className: "tourtois-settings-item-copy", children: [_jsxs("h3", { className: "tourtois-settings-item-title", children: [_jsx("span", { className: "tourtois-settings-item-icon", "aria-hidden": "true", children: icon }), _jsx("span", { className: "tourtois-settings-item-name", children: title })] }), detail ? (_jsx("div", { className: "tourtois-settings-item-detail", children: detail })) : null] }), actions ? (_jsx("div", { className: "tourtois-settings-item-keys", children: actions })) : null] }));
8
+ return (_jsxs("div", { className: "tourtois-settings-item", "data-plain": icon === undefined || undefined, children: [_jsxs("div", { className: "tourtois-settings-item-copy", children: [_jsxs("h3", { className: "tourtois-settings-item-title", children: [icon === undefined ? null : (_jsx("span", { className: "tourtois-settings-item-icon", "aria-hidden": "true", children: icon })), _jsx("span", { className: "tourtois-settings-item-name", children: title })] }), detail ? (_jsx("div", { className: "tourtois-settings-item-detail", children: detail })) : null] }), actions ? (_jsx("div", { className: "tourtois-settings-item-keys", children: actions })) : null] }));
9
9
  }
@@ -34,6 +34,11 @@ export declare const settingsLocationSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
34
34
  target: z.ZodEnum<{
35
35
  media: "media";
36
36
  all: "all";
37
+ }>;
38
+ }, z.core.$strict>, z.ZodObject<{
39
+ category: z.ZodLiteral<"vault">;
40
+ target: z.ZodEnum<{
41
+ all: "all";
37
42
  model: "model";
38
43
  }>;
39
44
  }, z.core.$strict>, z.ZodObject<{
@@ -118,13 +123,15 @@ export declare function createSettingsRouter(): RouterCore<import("@tanstack/rou
118
123
  }, 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, {}, () => {
119
124
  category: "keys";
120
125
  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
+ }, 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/media", "/keys/media", string, "/keys/media", undefined, import("@tanstack/react-router").ResolveParams<"/keys/media">, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, () => {
126
127
  category: "keys";
127
- target: "media" | "model";
128
+ target: "media";
129
+ }, 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>, "/vault", "/vault", string, "/vault", undefined, import("@tanstack/react-router").ResolveParams<"/vault">, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, () => {
130
+ category: "vault";
131
+ target: "all";
132
+ }, 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>, "/vault/model", "/vault/model", string, "/vault/model", undefined, import("@tanstack/react-router").ResolveParams<"/vault/model">, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, {}, () => {
133
+ category: "vault";
134
+ target: "model";
128
135
  }, 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, {}, () => {
129
136
  category: "channels";
130
137
  }, unknown, unknown, unknown, unknown, undefined>], unknown, unknown, unknown, undefined>, "never", false, import("@tanstack/history").RouterHistory, Record<string, any>>;
@@ -25,7 +25,12 @@ export const settingsLocationSchema = z.discriminatedUnion("category", [
25
25
  z.strictObject({ category: z.literal("computers") }),
26
26
  z.strictObject({
27
27
  category: z.literal("keys"),
28
- target: z.enum(["all", "model", "media"]),
28
+ target: z.enum(["all", "media"]),
29
+ }),
30
+ /** Every stored key and credential; `model` opens on the model-key form. */
31
+ z.strictObject({
32
+ category: z.literal("vault"),
33
+ target: z.enum(["all", "model"]),
29
34
  }),
30
35
  z.strictObject({ category: z.literal("defaults") }),
31
36
  z.strictObject({ category: z.literal("channels") }),
@@ -125,13 +130,20 @@ export function createSettingsRouter() {
125
130
  path: "/keys",
126
131
  loader: () => ({ category: "keys", target: "all" }),
127
132
  });
128
- const keySetup = createRoute({
133
+ const imageSetup = createRoute({
129
134
  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 }),
135
+ path: "/keys/media",
136
+ loader: () => ({ category: "keys", target: "media" }),
137
+ });
138
+ const vault = createRoute({
139
+ getParentRoute: () => root,
140
+ path: "/vault",
141
+ loader: () => ({ category: "vault", target: "all" }),
142
+ });
143
+ const modelSetup = createRoute({
144
+ getParentRoute: () => root,
145
+ path: "/vault/model",
146
+ loader: () => ({ category: "vault", target: "model" }),
135
147
  });
136
148
  const channels = createRoute({
137
149
  getParentRoute: () => root,
@@ -165,7 +177,9 @@ export function createSettingsRouter() {
165
177
  connectorAgent,
166
178
  computers,
167
179
  keys,
168
- keySetup,
180
+ imageSetup,
181
+ vault,
182
+ modelSetup,
169
183
  channels,
170
184
  ]);
171
185
  const router = createRouter({
@@ -216,12 +230,13 @@ export function navigateSettings(router, location) {
216
230
  case "computers":
217
231
  return router.navigate({ to: "/computers" });
218
232
  case "keys":
219
- return location.target === "all"
220
- ? router.navigate({ to: "/keys" })
221
- : router.navigate({
222
- to: "/keys/$target",
223
- params: { target: location.target },
224
- });
233
+ return router.navigate({
234
+ to: location.target === "all" ? "/keys" : "/keys/media",
235
+ });
236
+ case "vault":
237
+ return router.navigate({
238
+ to: location.target === "all" ? "/vault" : "/vault/model",
239
+ });
225
240
  case "apps":
226
241
  return location.appKey === null
227
242
  ? router.navigate({ to: "/apps" })
@@ -1,7 +1,7 @@
1
1
  import type { ComponentType } from "react";
2
2
  import type { ConnectionsPort } from "./Connections.js";
3
3
  import type { KeysPort } from "./Keys.js";
4
- import type { ModelKeysPort } from "./ModelKeys.js";
4
+ import type { VaultPort } from "./Vault.js";
5
5
  import type { MemberAvatarReader, MemberAvatarSave } from "./member-avatar.js";
6
6
  import { type SettingsLocation } from "./settings-routes.js";
7
7
  export type SettingsCategory = SettingsLocation["category"];
@@ -36,8 +36,10 @@ export type SettingsSectionPorts = Readonly<{
36
36
  computers?: ComponentType;
37
37
  /** Keys settings: the host's owner-direct Keys custody. */
38
38
  keys?: KeysPort;
39
- /** Model keys beside Keys: the host's sealed provider keys and per-Agent models. */
40
- modelKeys?: ModelKeysPort;
39
+ /** Image model setup beside Keys, on a host that generates images itself. */
40
+ imageModels?: ComponentType;
41
+ /** The Vault: every model key and credential the host holds, write-only. */
42
+ vault?: VaultPort;
41
43
  /** The Team's role defaults. */
42
44
  defaults?: ComponentType<{
43
45
  onAccepted: Accepted;
@@ -8,7 +8,8 @@ export function offeredSettings(ceiling, ports) {
8
8
  avatar: ports.avatar !== undefined,
9
9
  connectors: ports.connections !== undefined,
10
10
  computers: ports.computers !== undefined,
11
- keys: ports.keys !== undefined || ports.modelKeys !== undefined,
11
+ keys: ports.keys !== undefined || ports.imageModels !== undefined,
12
+ vault: ports.vault !== undefined,
12
13
  defaults: ports.defaults !== undefined,
13
14
  channels: ports.channels !== undefined,
14
15
  selling: ports.selling !== undefined,