@fungi.computer/tourtois 0.20.11 → 0.20.12

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.
@@ -4,7 +4,9 @@ import { useEffect, useRef, useState } from "react";
4
4
  import { AppError } from "@fungi.computer/agar";
5
5
  import { Button } from "@fungi.computer/caps/components/button";
6
6
  import { DataList, DataRow } from "@fungi.computer/caps/components/data-list";
7
+ import { toast } from "@fungi.computer/caps/components/toaster";
7
8
  import { Select } from "@fungi.computer/caps/components/select";
9
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
8
10
  const sizeLabels = { S: "Small", M: "Medium", L: "Large" };
9
11
  function GillOption({ app, gill, desktop, consentReadyAt, }) {
10
12
  const sizes = gill.desktop?.sizes ?? [];
@@ -22,10 +24,11 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
22
24
  window.clearTimeout(timer);
23
25
  };
24
26
  }, [consentReadyAt]);
25
- const [error, setError] = useState(null);
27
+ const [unavailable, setUnavailable] = useState(false);
26
28
  useEffect(() => {
27
29
  let retired = false;
28
30
  setSaved(null);
31
+ setUnavailable(false);
29
32
  void Promise.resolve()
30
33
  .then(() => desktop.readGill({ surfaceId: app.surfaceId, gillId: gill.id }))
31
34
  .then((value) => {
@@ -38,8 +41,10 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
38
41
  gillId: gill.id,
39
42
  cause,
40
43
  });
41
- if (!retired)
42
- setError("Your desktop could not be read. Reopen Settings to try again.");
44
+ if (!retired) {
45
+ setUnavailable(true);
46
+ toast.error("Your desktop could not be read. Reopen Settings to try again.", { toasterId: WORKBENCH_NOTICES });
47
+ }
43
48
  return { kind: "failed", cause };
44
49
  });
45
50
  return () => {
@@ -52,7 +57,7 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
52
57
  return { kind: "busy" };
53
58
  busy.current = true;
54
59
  setPending(true);
55
- setError(null);
60
+ setUnavailable(false);
56
61
  const selection = { surfaceId: app.surfaceId, gillId: gill.id };
57
62
  try {
58
63
  if (onDesktop)
@@ -67,9 +72,10 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
67
72
  ...selection,
68
73
  cause,
69
74
  });
70
- setError(cause instanceof AppError
75
+ setUnavailable(true);
76
+ toast.error(cause instanceof AppError
71
77
  ? cause.message
72
- : "The widget could not be changed. Reopen Settings to try again.");
78
+ : "The widget could not be changed. Reopen Settings to try again.", { toasterId: WORKBENCH_NOTICES });
73
79
  // A refusal may mean another tab changed the saved layout. Never keep an optimistic membership flag.
74
80
  setSaved(null);
75
81
  return { kind: "failed", cause };
@@ -79,9 +85,9 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
79
85
  setPending(false);
80
86
  }
81
87
  };
82
- return (_jsxs(DataRow, { style: { gridTemplateColumns: "minmax(0, 1fr)" }, children: [_jsxs("div", { children: [_jsx("strong", { children: gill.title }), _jsxs("p", { children: [saved === null && !error && "Reading your desktop…", saved !== null && onDesktop && (_jsxs("span", { role: "status", children: ["On your desktop \u00B7", " ", saved.map((value) => sizeLabels[value]).join(", ")] })), saved !== null &&
88
+ return (_jsxs(DataRow, { style: { gridTemplateColumns: "minmax(0, 1fr)" }, children: [_jsxs("div", { children: [_jsx("strong", { children: gill.title }), _jsxs("p", { children: [saved === null && !unavailable && "Reading your desktop…", saved === null && unavailable && "Your desktop is unavailable.", saved !== null && onDesktop && (_jsxs("span", { role: "status", children: ["On your desktop \u00B7", " ", saved.map((value) => sizeLabels[value]).join(", ")] })), saved !== null &&
83
89
  !onDesktop &&
84
- "Choose a size, then add this widget to your desktop.", error ? _jsx("span", { role: "alert", children: error }) : null] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", style: { gridRow: 2, gridColumn: "1 / -1" }, children: [!onDesktop ? (_jsx("div", { style: { width: "7rem", flex: "0 0 auto" }, children: _jsx(Select, { "aria-label": `Size for ${gill.title}`, value: size, disabled: pending || saved === null || !consentReady, onChange: (event) => {
90
+ "Choose a size, then add this widget to your desktop."] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", style: { gridRow: 2, gridColumn: "1 / -1" }, children: [!onDesktop ? (_jsx("div", { style: { width: "7rem", flex: "0 0 auto" }, children: _jsx(Select, { "aria-label": `Size for ${gill.title}`, value: size, disabled: pending || saved === null || !consentReady, onChange: (event) => {
85
91
  const next = sizes.find((value) => value === event.currentTarget.value);
86
92
  if (next)
87
93
  setSize(next);
@@ -11,6 +11,8 @@ import { queryOptions, useMutation, useQuery, useQueryClient, } from "@tanstack/
11
11
  import { useState } from "react";
12
12
  import * as z from "zod";
13
13
  import { SettingsItem } from "./settings-item.js";
14
+ import { toast } from "@fungi.computer/caps/components/toaster";
15
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
14
16
  /** What an Agent may do with one connection: everything, only reads, or named tools. */
15
17
  const connectionAccessSchema = z.union([
16
18
  z.literal("all"),
@@ -74,6 +76,11 @@ export function Connections({ port, target, onNavigate, }) {
74
76
  const remove = useMutation({
75
77
  mutationFn: (connectionId) => port.remove(connectionId),
76
78
  onSuccess: refresh,
79
+ onError: () => {
80
+ toast.error("The connection could not be removed.", {
81
+ toasterId: WORKBENCH_NOTICES,
82
+ });
83
+ },
77
84
  });
78
85
  const agents = view.data?.agents ?? [];
79
86
  const connections = view.data?.connections ?? [];
@@ -89,7 +96,7 @@ export function Connections({ port, target, onNavigate, }) {
89
96
  });
90
97
  } })) : null, _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${connection.label}`, disabled: remove.isPending, onClick: () => {
91
98
  remove.mutate(connection.connectionId);
92
- } })] })] }) }) }, connection.connectionId))) })), remove.isError ? (_jsx("p", { role: "alert", children: "The connection could not be removed." })) : null, _jsx(AddConnection, { signIn: view.data.callbackUrl !== null, onAdd: async (draft) => {
99
+ } })] })] }) }) }, connection.connectionId))) })), _jsx(AddConnection, { signIn: view.data.callbackUrl !== null, onAdd: async (draft) => {
93
100
  const added = await port.add(draft);
94
101
  // OAuth servers finish at the authorization server, then return here.
95
102
  if (added.authorizeUrl !== null) {
@@ -114,6 +121,11 @@ function AgentAccess({ connection, agents, port, onChanged, }) {
114
121
  });
115
122
  },
116
123
  onSuccess: onChanged,
124
+ onError: () => {
125
+ toast.error("The access could not be changed.", {
126
+ toasterId: WORKBENCH_NOTICES,
127
+ });
128
+ },
117
129
  });
118
130
  if (agents.length === 0)
119
131
  return _jsx("p", { children: "Create an Agent to share this." });
@@ -134,7 +146,7 @@ function AgentAccess({ connection, agents, port, onChanged, }) {
134
146
  change.mutate({ agentId: agent.agentId, access });
135
147
  } }, agent.agentId),
136
148
  ];
137
- }), change.isError ? (_jsx("p", { role: "alert", children: "The access could not be changed." })) : null] }));
149
+ })] }));
138
150
  }
139
151
  /** Narrow one Agent's access: everything, reads only, or the tools you pick. */
140
152
  function ChooseAccess({ connection, agentName, access, port, onChoose, }) {
@@ -6,6 +6,7 @@ import { CopyField } from "@fungi.computer/caps/components/copy-field";
6
6
  import { FormFooter } from "@fungi.computer/caps/components/field";
7
7
  import { InlineCode } from "@fungi.computer/caps/components/inline-code";
8
8
  import { KeycapButton } from "@fungi.computer/caps/components/keycap";
9
+ import { toast } from "@fungi.computer/caps/components/toaster";
9
10
  import { Prose } from "@fungi.computer/caps/components/prose";
10
11
  import { Status } from "@fungi.computer/caps/components/status";
11
12
  import { SchemaForm, field, sections, useSchemaForm, } from "@fungi.computer/caps/form";
@@ -17,6 +18,7 @@ import * as Schema from "effect/Schema";
17
18
  import * as z from "zod";
18
19
  import { websiteConversationSchema, websiteTranscriptSchema, } from "@fungi.computer/nacre/website-channels";
19
20
  import { ChannelConversations } from "./ChannelConversations.js";
21
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
20
22
  import { tourtoisQueryKeys } from "./queries.js";
21
23
  import { requestIds } from "./team-directory.js";
22
24
  const snowflake = z.string().regex(/^\d{17,20}$/u);
@@ -344,10 +346,22 @@ function DiscordRow({ port, binding, interactionsOrigin, agentName, open, justCr
344
346
  throw new Error("Discord unavailable. Reload before changing it.");
345
347
  return port.update(binding.bindingId, current.authorityVersion, change);
346
348
  },
349
+ onError: () => {
350
+ toast.error("Couldn't update Discord. Please try again.", {
351
+ toasterId: WORKBENCH_NOTICES,
352
+ closeButton: true,
353
+ });
354
+ },
347
355
  onSettled: () => cache.invalidateQueries({ queryKey: key }),
348
356
  });
349
357
  const register = useMutation({
350
358
  mutationFn: () => port.registerCommands(binding.bindingId),
359
+ onError: () => {
360
+ toast.error("Couldn't register the Discord commands. Please try again.", {
361
+ toasterId: WORKBENCH_NOTICES,
362
+ closeButton: true,
363
+ });
364
+ },
351
365
  });
352
366
  const { applicationId, guildIds, channelIds } = binding.selector;
353
367
  const endpoint = `${interactionsOrigin}/api/discord/interactions/${binding.bindingId}`;
@@ -371,7 +385,7 @@ function DiscordRow({ port, binding, interactionsOrigin, agentName, open, justCr
371
385
  patch.mutate({
372
386
  lifecycle: active ? "suspended" : "active",
373
387
  });
374
- } })] }) })] }), patch.isError ? _jsx("p", { role: "alert", children: patch.error.message }) : null, register.isError ? (_jsx("p", { role: "alert", children: register.error.message })) : null, _jsx(ChannelConversations, { keys: {
388
+ } })] }) })] }), _jsx(ChannelConversations, { keys: {
375
389
  list: tourtoisQueryKeys.discordConversations(port.scope, binding.bindingId),
376
390
  transcript: (sessionId) => tourtoisQueryKeys.discordTranscript(port.scope, binding.bindingId, sessionId),
377
391
  }, load: () => port.conversations(binding), read: (sessionId) => port.transcript(binding, sessionId), problems: {
package/dist/Keys.js CHANGED
@@ -13,6 +13,8 @@ import { useState } from "react";
13
13
  import * as z from "zod";
14
14
  import { Sigil } from "@fungi.computer/sigils";
15
15
  import { SettingsItem } from "./settings-item.js";
16
+ import { toast } from "@fungi.computer/caps/components/toaster";
17
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
16
18
  const mutationIds = defineIdFamily({
17
19
  family: "tourtois-keys-mutation",
18
20
  version: 1,
@@ -40,12 +42,10 @@ function KeysContent({ port, apps, }) {
40
42
  const [command, setCommand] = useState(null);
41
43
  const [busy, setBusy] = useState(false);
42
44
  const [notice, setNotice] = useState(null);
43
- const [error, setError] = useState(null);
44
45
  const refresh = () => client.invalidateQueries({ queryKey });
45
46
  const mutate = async (pending) => {
46
47
  setCommand(pending);
47
48
  setBusy(true);
48
- setError(null);
49
49
  setNotice(null);
50
50
  try {
51
51
  const change = pending.kind === "revoke"
@@ -62,9 +62,10 @@ function KeysContent({ port, apps, }) {
62
62
  await refresh();
63
63
  }
64
64
  catch (cause) {
65
- setError(cause instanceof Error
65
+ console.error("Key change failed", pending.kind, cause);
66
+ toast.error(cause instanceof Error
66
67
  ? cause.message
67
- : "The key change could not be confirmed.");
68
+ : "The key change could not be confirmed.", { toasterId: WORKBENCH_NOTICES });
68
69
  }
69
70
  finally {
70
71
  setBusy(false);
@@ -86,7 +87,7 @@ function KeysContent({ port, apps, }) {
86
87
  kind: "revoke",
87
88
  keyId: key.keyId,
88
89
  requestId: mutationIds.request.generate(),
89
- }) })] })) : undefined }) }, key.keyId))) }), notice ? _jsx("p", { role: "status", children: notice }) : null, error ? _jsx("p", { role: "alert", children: error }) : null, command !== null ? (_jsxs("div", { className: "tourtois-settings-notice", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => void mutate(command), children: "Retry key change" }), _jsx(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => {
90
+ }) })] })) : undefined }) }, key.keyId))) }), notice ? _jsx("p", { role: "status", children: notice }) : null, command !== null ? (_jsxs("div", { className: "tourtois-settings-notice", children: [_jsx(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => void mutate(command), children: "Retry key change" }), _jsx(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => {
90
91
  setCommand(null);
91
92
  setEditing(null);
92
93
  void refresh();
package/dist/ModelKeys.js CHANGED
@@ -11,6 +11,8 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
11
11
  import { useCallback, useMemo, useState } from "react";
12
12
  import * as z from "zod";
13
13
  import { SettingsItem } from "./settings-item.js";
14
+ import { toast } from "@fungi.computer/caps/components/toaster";
15
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
14
16
  /** A provider the host offers; the host owns the list and the client only shows it. */
15
17
  const providerChoiceSchema = z.strictObject({
16
18
  id: z.string().min(1),
@@ -76,6 +78,11 @@ export function ModelKeys({ port, focus = false, }) {
76
78
  const remove = useMutation({
77
79
  mutationFn: (keyId) => port.removeKey(keyId),
78
80
  onSuccess: refresh,
81
+ onError: () => {
82
+ toast.error("The model key could not be removed.", {
83
+ toasterId: WORKBENCH_NOTICES,
84
+ });
85
+ },
79
86
  });
80
87
  const keys = view.data?.keys ?? [];
81
88
  const agents = view.data?.agents ?? [];
@@ -83,7 +90,7 @@ export function ModelKeys({ port, focus = false, }) {
83
90
  const [formKey, setFormKey] = useState(0);
84
91
  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: providerLabel(view.data.providers, key.provider) }), actions: _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${key.label}`, disabled: remove.isPending, onClick: () => {
85
92
  remove.mutate(key.keyId);
86
- } }) }) }, key.keyId)))] }), remove.isError ? (_jsx("p", { role: "alert", children: "The model key could not be removed." })) : null, _jsx(AddModelKey, { providers: view.data.providers, onAdd: async (draft) => {
93
+ } }) }) }, key.keyId)))] }), _jsx(AddModelKey, { providers: view.data.providers, onAdd: async (draft) => {
87
94
  await port.addKey(draft);
88
95
  await refresh();
89
96
  setFormKey((current) => current + 1);
@@ -1,5 +1,8 @@
1
1
  import { type WebsiteConversation, type WebsiteSite, type WebsiteTranscript } from "@fungi.computer/nacre/website-channels";
2
2
  import { type ReactNode } from "react";
3
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
4
+ /** The Toaster id a host mounts so channel failures reach the person. */
5
+ export { WORKBENCH_NOTICES };
3
6
  export type { WebsiteConversation, WebsiteSite, WebsiteTranscript };
4
7
  /** An Agent a website can be bound to. */
5
8
  export type WebsiteAgent = Readonly<{
@@ -8,6 +8,7 @@ import { FormFooter } from "@fungi.computer/caps/components/field";
8
8
  import { CheckKey } from "@fungi.computer/caps/components/icon-checkbox";
9
9
  import { InlineCode } from "@fungi.computer/caps/components/inline-code";
10
10
  import { KeycapButton } from "@fungi.computer/caps/components/keycap";
11
+ import { toast } from "@fungi.computer/caps/components/toaster";
11
12
  import { Prose } from "@fungi.computer/caps/components/prose";
12
13
  import { Status } from "@fungi.computer/caps/components/status";
13
14
  import { SchemaForm, field, sections, useSchemaForm, } from "@fungi.computer/caps/form";
@@ -17,8 +18,11 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
17
18
  import { useId, useMemo, useState } from "react";
18
19
  import * as z from "zod";
19
20
  import { ChannelConversations } from "./ChannelConversations.js";
21
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
20
22
  import { tourtoisQueryKeys } from "./queries.js";
21
23
  import { requestIds } from "./team-directory.js";
24
+ /** The Toaster id a host mounts so channel failures reach the person. */
25
+ export { WORKBENCH_NOTICES };
22
26
  const exampleAddress = "https://example.com";
23
27
  /**
24
28
  * Read the owner's typed addresses, then run the web origin schema on each.
@@ -316,6 +320,12 @@ function WebsiteRow({ port, copy, site, notice, embedOrigin, agentName, open, ju
316
320
  throw new Error("Website unavailable. Reload before changing it.");
317
321
  return port.update(site.bindingId, current.authorityVersion, change);
318
322
  },
323
+ onError: () => {
324
+ toast.error("Couldn't save the website. Please try again.", {
325
+ toasterId: WORKBENCH_NOTICES,
326
+ closeButton: true,
327
+ });
328
+ },
319
329
  onSettled: () => cache.invalidateQueries({ queryKey: key }),
320
330
  });
321
331
  const { origins, siteKey, turnstile } = site.selector;
@@ -341,7 +351,7 @@ function WebsiteRow({ port, copy, site, notice, embedOrigin, agentName, open, ju
341
351
  setConfirmingKey(false);
342
352
  } })] })) : (_jsx(KeycapButton, { density: "compact", label: "New site key", disabled: patch.isPending, onClick: () => {
343
353
  setConfirmingKey(true);
344
- } }))] }) })] }), notice, patch.isError ? _jsx("p", { role: "alert", children: patch.error.message }) : null, _jsx(ChannelConversations, { keys: {
354
+ } }))] }) })] }), notice, _jsx(ChannelConversations, { keys: {
345
355
  list: tourtoisQueryKeys.websiteConversations(port.scope, site.bindingId),
346
356
  transcript: (sessionId) => tourtoisQueryKeys.websiteTranscript(port.scope, site.bindingId, sessionId),
347
357
  }, load: () => port.conversations(site), read: (sessionId) => port.transcript(site, sessionId), speaker: "Visitor", empty: "No visitor has written yet.", label: "Website conversations" })] })) : null] }) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.20.11",
3
+ "version": "0.20.12",
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,7 +83,7 @@
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.37",
86
+ "@fungi.computer/parakeet": "0.11.38",
87
87
  "@fungi.computer/puffball": "0.9.0",
88
88
  "@fungi.computer/shiitake": "0.18.2",
89
89
  "@fungi.computer/sigils": "0.3.2",
@@ -106,7 +106,7 @@
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.31.0",
109
+ "@fungi.computer/oyster": "0.31.1",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
111
  "@fungi.computer/forage": "0.3.9",
112
112
  "@fungi.computer/mycelium": "0.4.0",