@fungi.computer/tourtois 0.18.0 → 0.19.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/dist/OysterComputers.d.ts +14 -1
- package/dist/OysterComputers.js +35 -11
- package/package.json +9 -9
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { teamComputerDirectorySchema, type TeamComputer } from "@fungi.computer/nacre/workbench";
|
|
2
2
|
import { type ReactElement, type ReactNode } from "react";
|
|
3
3
|
import * as z from "zod";
|
|
4
|
+
/** A Computer's size: its vCPUs and memory, chosen once at creation. */
|
|
5
|
+
export type ComputerSize = TeamComputer["size"];
|
|
6
|
+
/** What to create: the owner's choices and the identity a retry reuses. */
|
|
7
|
+
export type ComputerCreateInput = Readonly<{
|
|
8
|
+
name: string | undefined;
|
|
9
|
+
size: ComputerSize;
|
|
10
|
+
requestId: string;
|
|
11
|
+
}>;
|
|
4
12
|
/** One owner-fleet page returned by the public Computer controls port. */
|
|
5
13
|
export type ComputerPage = z.output<typeof teamComputerDirectorySchema>;
|
|
6
14
|
/** Host-supplied owner controls over the existing fleet, not a second inventory. */
|
|
7
15
|
export type OysterComputersPort = Readonly<{
|
|
8
16
|
list(offset: number): Promise<ComputerPage>;
|
|
9
|
-
create(
|
|
17
|
+
create(input: ComputerCreateInput): Promise<TeamComputer>;
|
|
18
|
+
/**
|
|
19
|
+
* Hosts that bill a Computer by size say what each costs, such as
|
|
20
|
+
* "$0.03 an hour". Hosts that do not bill omit it.
|
|
21
|
+
*/
|
|
22
|
+
sizePrices?: Readonly<Record<ComputerSize, string>>;
|
|
10
23
|
start(computerId: string): Promise<void>;
|
|
11
24
|
internetAccess(computerId: string): Promise<boolean>;
|
|
12
25
|
setInternetAccess(computerId: string, enabled: boolean): Promise<boolean>;
|
package/dist/OysterComputers.js
CHANGED
|
@@ -14,10 +14,20 @@ import { SettingsItem } from "./settings-item.js";
|
|
|
14
14
|
import { teamComputerDirectorySchema, teamComputerSchema, } from "@fungi.computer/nacre/workbench";
|
|
15
15
|
import { workbenchDirectorySchema } from "@fungi.computer/nacre/workbench-directory";
|
|
16
16
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
17
|
-
import { useRef, useState } from "react";
|
|
17
|
+
import { useMemo, useRef, useState, } from "react";
|
|
18
18
|
import * as z from "zod";
|
|
19
19
|
import { requestIds } from "./team-directory.js";
|
|
20
20
|
import { tourtoisQueryKeys } from "./queries.js";
|
|
21
|
+
const computerSizes = {
|
|
22
|
+
small: { label: "Small", resources: "2 vCPU, 4 GiB" },
|
|
23
|
+
default: { label: "Default", resources: "4 vCPU, 8 GiB" },
|
|
24
|
+
large: { label: "Large", resources: "8 vCPU, 16 GiB" },
|
|
25
|
+
};
|
|
26
|
+
const computerSizeOrder = ["small", "default", "large"];
|
|
27
|
+
/** What a size gives, with its price when the host bills for it. */
|
|
28
|
+
const sizeDetail = (size, prices) => [computerSizes[size].resources, prices?.[size]]
|
|
29
|
+
.filter((part) => part !== undefined)
|
|
30
|
+
.join(", ");
|
|
21
31
|
const missingRuntime = z.strictObject({ error: z.literal("no_runtime") });
|
|
22
32
|
const computerSwitchSchema = z.strictObject({ enabled: z.boolean() });
|
|
23
33
|
async function request(url, init) {
|
|
@@ -60,10 +70,10 @@ export function createOysterComputersPort(origin) {
|
|
|
60
70
|
const response = await read(`/api/computers?${new URLSearchParams({ limit: "100", offset: String(offset) })}`);
|
|
61
71
|
return teamComputerDirectorySchema.parse(await response.json());
|
|
62
72
|
},
|
|
63
|
-
create: async (name, requestId) => {
|
|
73
|
+
create: async ({ name, size, requestId }) => {
|
|
64
74
|
const response = await read("/api/computers", {
|
|
65
75
|
method: "POST",
|
|
66
|
-
body: JSON.stringify(name === undefined ? { requestId } : { requestId, name }),
|
|
76
|
+
body: JSON.stringify(name === undefined ? { requestId, size } : { requestId, name, size }),
|
|
67
77
|
});
|
|
68
78
|
return teamComputerSchema.parse(await response.json());
|
|
69
79
|
},
|
|
@@ -141,7 +151,7 @@ function KeepAwake({ teamId, computer, port, }) {
|
|
|
141
151
|
export const keepAwakeHelp = (idleMetered) => `${idleMetered
|
|
142
152
|
? "Stays on when idle, and idle time is charged."
|
|
143
153
|
: "Stays on when idle."} Off, it sleeps after 15 idle minutes.`;
|
|
144
|
-
const createComputerSchema = z.object({
|
|
154
|
+
const createComputerSchema = (prices) => z.object({
|
|
145
155
|
name: z
|
|
146
156
|
.string()
|
|
147
157
|
.trim()
|
|
@@ -152,6 +162,16 @@ const createComputerSchema = z.object({
|
|
|
152
162
|
placeholder: "Leave blank for a generated name",
|
|
153
163
|
maxLength: 256,
|
|
154
164
|
})),
|
|
165
|
+
size: z.enum(computerSizeOrder).meta(field({
|
|
166
|
+
label: "Size",
|
|
167
|
+
kind: "select",
|
|
168
|
+
icon: _jsx(Sigil, { name: "computer" }),
|
|
169
|
+
options: Object.fromEntries(computerSizeOrder.map((size) => [
|
|
170
|
+
size,
|
|
171
|
+
`${computerSizes[size].label}: ${sizeDetail(size, prices)}`,
|
|
172
|
+
])),
|
|
173
|
+
help: "Fixed when the Computer is created.",
|
|
174
|
+
})),
|
|
155
175
|
});
|
|
156
176
|
/** Owner Settings over the host's existing inventory and optional default. */
|
|
157
177
|
export function OysterComputers({ teamId, port, onChanged, }) {
|
|
@@ -183,7 +203,7 @@ export function OysterComputers({ teamId, port, onChanged, }) {
|
|
|
183
203
|
mutationFn: async (input) => {
|
|
184
204
|
switch (input.kind) {
|
|
185
205
|
case "create":
|
|
186
|
-
await port.create(input
|
|
206
|
+
await port.create(input);
|
|
187
207
|
return;
|
|
188
208
|
case "start":
|
|
189
209
|
await port.start(input.computerId);
|
|
@@ -213,17 +233,21 @@ export function OysterComputers({ teamId, port, onChanged, }) {
|
|
|
213
233
|
inventory.isFetching ||
|
|
214
234
|
(selection !== undefined && selected.isFetching) ||
|
|
215
235
|
action.isPending;
|
|
236
|
+
const createSchema = useMemo(() => createComputerSchema(port.sizePrices), [port.sizePrices]);
|
|
216
237
|
const create = useSchemaForm({
|
|
217
|
-
schema:
|
|
218
|
-
defaultValues: { name: "" },
|
|
238
|
+
schema: createSchema,
|
|
239
|
+
defaultValues: { name: "", size: "default" },
|
|
219
240
|
failure: "Could not create the Computer.",
|
|
220
|
-
onSubmit: async ({ name }) => {
|
|
241
|
+
onSubmit: async ({ name, size, }) => {
|
|
221
242
|
const requestedName = name === "" ? undefined : name;
|
|
222
243
|
// A retried create keeps its request identity until the host confirms it.
|
|
223
|
-
if (intent.current === null ||
|
|
244
|
+
if (intent.current === null ||
|
|
245
|
+
intent.current.name !== requestedName ||
|
|
246
|
+
intent.current.size !== size)
|
|
224
247
|
intent.current = {
|
|
225
248
|
kind: "create",
|
|
226
249
|
name: requestedName,
|
|
250
|
+
size,
|
|
227
251
|
requestId: requestIds.request.generate(),
|
|
228
252
|
};
|
|
229
253
|
try {
|
|
@@ -234,7 +258,7 @@ export function OysterComputers({ teamId, port, onChanged, }) {
|
|
|
234
258
|
? { kind: "refused", error: cause.message }
|
|
235
259
|
: { kind: "refused" };
|
|
236
260
|
}
|
|
237
|
-
return { kind: "saved", values: { name: "" } };
|
|
261
|
+
return { kind: "saved", values: { name: "", size } };
|
|
238
262
|
},
|
|
239
263
|
});
|
|
240
264
|
const policyStatus = port.egressPolicy === undefined
|
|
@@ -252,7 +276,7 @@ export function OysterComputers({ teamId, port, onChanged, }) {
|
|
|
252
276
|
const isDefault = selection !== undefined &&
|
|
253
277
|
selected.isSuccess &&
|
|
254
278
|
selected.data === computer.computerId;
|
|
255
|
-
return (_jsxs("section", { className: "tourtois-computer", "aria-label": computer.name, children: [_jsx(SettingsItem, { icon: _jsx(Sigil, { name: "computer" }), title: computer.name, actions: _jsxs(_Fragment, { children: [_jsx(KeycapButton, { density: "compact", label: "Start", icon: _jsx(Sigil, { name: "run" }), "aria-label": `Start ${computer.name}`, disabled: unavailable, onClick: () => {
|
|
279
|
+
return (_jsxs("section", { className: "tourtois-computer", "aria-label": computer.name, children: [_jsx(SettingsItem, { icon: _jsx(Sigil, { name: "computer" }), title: computer.name, detail: `${computerSizes[computer.size].label}: ${sizeDetail(computer.size, port.sizePrices)}`, actions: _jsxs(_Fragment, { children: [_jsx(KeycapButton, { density: "compact", label: "Start", icon: _jsx(Sigil, { name: "run" }), "aria-label": `Start ${computer.name}`, disabled: unavailable, onClick: () => {
|
|
256
280
|
action.mutate({
|
|
257
281
|
kind: "start",
|
|
258
282
|
computerId: computer.computerId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/tourtois",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
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",
|
|
@@ -77,15 +77,15 @@
|
|
|
77
77
|
"LICENSE"
|
|
78
78
|
],
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@fungi.computer/agar": "0.12.
|
|
80
|
+
"@fungi.computer/agar": "0.12.1",
|
|
81
81
|
"@fungi.computer/cairn": "0.1.0",
|
|
82
82
|
"@fungi.computer/caps": "0.11.3",
|
|
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.
|
|
87
|
-
"@fungi.computer/puffball": "0.
|
|
88
|
-
"@fungi.computer/shiitake": "0.
|
|
86
|
+
"@fungi.computer/parakeet": "0.11.25",
|
|
87
|
+
"@fungi.computer/puffball": "0.7.0",
|
|
88
|
+
"@fungi.computer/shiitake": "0.15.0",
|
|
89
89
|
"@fungi.computer/sigils": "0.3.1",
|
|
90
90
|
"@fungi.computer/sprite": "0.2.2",
|
|
91
91
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
@@ -100,16 +100,16 @@
|
|
|
100
100
|
"lucide-react": "0.460.0",
|
|
101
101
|
"react-dom": "18.3.1",
|
|
102
102
|
"zod": "4.4.3",
|
|
103
|
-
"@fungi.computer/nacre": "0.
|
|
103
|
+
"@fungi.computer/nacre": "0.6.0"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"react": "^18.3.1 || ^19.2.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@fungi.computer/oyster": "0.
|
|
109
|
+
"@fungi.computer/oyster": "0.26.0",
|
|
110
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
111
|
-
"@fungi.computer/forage": "0.3.
|
|
112
|
-
"@fungi.computer/mycelium": "0.3.
|
|
111
|
+
"@fungi.computer/forage": "0.3.7",
|
|
112
|
+
"@fungi.computer/mycelium": "0.3.10",
|
|
113
113
|
"@ladle/react": "5.1.1",
|
|
114
114
|
"@types/react": "18.3.3",
|
|
115
115
|
"@vitejs/plugin-react": "6.1.1",
|