@fungi.computer/oyster 0.19.30 → 0.19.32
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/agents.js
CHANGED
|
@@ -4,6 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import {} from "./host.js";
|
|
5
5
|
import { agentAvatarSchema } from "./agent-avatars.js";
|
|
6
6
|
import { computerTargetParam } from "./computer-target.js";
|
|
7
|
+
import { supportedAgentModels } from "./standalone/agent-model-choice.js";
|
|
7
8
|
import { agentAvatar, agentList, agentManage, agentRename, agentSessionRead, agentSessionWrite, agentToolPolicy, } from "@fungi.computer/agar/agents";
|
|
8
9
|
/** At most this many connections per Agent. */
|
|
9
10
|
export const maxAgentConnections = 16;
|
|
@@ -371,7 +372,16 @@ export function agentApprovalRoutes(agents) {
|
|
|
371
372
|
name: item.name,
|
|
372
373
|
choice: await agents.readModelChoice(item.agentId),
|
|
373
374
|
})));
|
|
374
|
-
|
|
375
|
+
const keys = await agents.modelKeys();
|
|
376
|
+
const providers = [...new Set(keys.map((key) => key.provider))];
|
|
377
|
+
const catalogs = Object.fromEntries(await Promise.all(providers
|
|
378
|
+
.filter((provider) => provider !== "openai-compatible")
|
|
379
|
+
.map(async (provider) => [provider, await supportedAgentModels(provider)])));
|
|
380
|
+
return Response.json({
|
|
381
|
+
agents: rows,
|
|
382
|
+
catalogs,
|
|
383
|
+
models: (await agents.setup()).models,
|
|
384
|
+
});
|
|
375
385
|
})
|
|
376
386
|
.get("/api/agent-models/:agentId", owner("direct"), async (context) => {
|
|
377
387
|
const agentId = context.req.param("agentId");
|
|
@@ -21,6 +21,15 @@ export declare class AgentModelRefused extends Error {
|
|
|
21
21
|
readonly reason: AgentModelRefusal;
|
|
22
22
|
constructor(reason: AgentModelRefusal);
|
|
23
23
|
}
|
|
24
|
+
/** A supported model and Pi's USD prices per million tokens, without credentials. */
|
|
25
|
+
export type SupportedAgentModel = Readonly<{
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
input: number;
|
|
29
|
+
output: number;
|
|
30
|
+
}>;
|
|
31
|
+
/** Settings and selection share Pi's catalog; cheapest combined token rate first. */
|
|
32
|
+
export declare function supportedAgentModels(provider: "anthropic" | "openai" | "openrouter" | "cloudflare-workers-ai"): Promise<readonly SupportedAgentModel[]>;
|
|
24
33
|
/**
|
|
25
34
|
* An Agent with no saved choice runs on a model its host can reach, chosen when
|
|
26
35
|
* it runs: Workers AI where a Cloudflare account answers, then the Fungi
|
|
@@ -43,6 +43,17 @@ async function byokCatalog(provider) {
|
|
|
43
43
|
.openrouterProvider()
|
|
44
44
|
.getModels();
|
|
45
45
|
}
|
|
46
|
+
/** Settings and selection share Pi's catalog; cheapest combined token rate first. */
|
|
47
|
+
export async function supportedAgentModels(provider) {
|
|
48
|
+
return (await byokCatalog(provider))
|
|
49
|
+
.map((model) => ({
|
|
50
|
+
id: model.id,
|
|
51
|
+
name: model.name,
|
|
52
|
+
input: model.cost.input,
|
|
53
|
+
output: model.cost.output,
|
|
54
|
+
}))
|
|
55
|
+
.sort((a, b) => a.input + a.output - b.input - b.output || a.id.localeCompare(b.id));
|
|
56
|
+
}
|
|
46
57
|
/**
|
|
47
58
|
* An Agent with no saved choice runs on a model its host can reach, chosen when
|
|
48
59
|
* it runs: Workers AI where a Cloudflare account answers, then the Fungi
|
|
@@ -91,4 +91,6 @@ export declare function wranglerDevArguments(input: {
|
|
|
91
91
|
port: number;
|
|
92
92
|
key: string;
|
|
93
93
|
}): readonly string[];
|
|
94
|
+
/** Provision the trial's separate encryption key through Wrangler's native secrets. */
|
|
95
|
+
export declare function prepareTryModelKeyCustody(directory: string): Promise<void>;
|
|
94
96
|
export declare function tryOyster(args: readonly string[], effects?: TryEffects, ui?: Cli, callerSignal?: AbortSignal): Promise<void>;
|
|
@@ -14,14 +14,16 @@
|
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
15
|
import { startTrialComputer } from "./trial-computer.js";
|
|
16
16
|
import { randomBytes } from "node:crypto";
|
|
17
|
+
import { encode as encodeBase64Url } from "effect/encoding/Base64Url";
|
|
17
18
|
import { addAbortListener } from "node:events";
|
|
18
19
|
import { finished } from "node:stream/promises";
|
|
19
20
|
import { runGit } from "../build/local-build.js";
|
|
20
21
|
import { CleanupError, stopProcessGroup, awaitCleanup, } from "../build/process-group.js";
|
|
21
22
|
import { InstallationObservationError } from "../installation-client.js";
|
|
22
23
|
import { createWriteStream } from "node:fs";
|
|
23
|
-
import { mkdir, mkdtemp, rename, readdir, rm, readFile, stat, writeFile, } from "node:fs/promises";
|
|
24
|
+
import { appendFile, chmod, mkdir, mkdtemp, rename, readdir, rm, readFile, stat, writeFile, } from "node:fs/promises";
|
|
24
25
|
import { createServer } from "node:net";
|
|
26
|
+
import { createCredentialSealer } from "@fungi.computer/veil/credential-store";
|
|
25
27
|
import { basename, dirname, delimiter, join, resolve } from "node:path";
|
|
26
28
|
import process from "node:process";
|
|
27
29
|
import { parseArgs, stripVTControlCharacters } from "node:util";
|
|
@@ -438,12 +440,62 @@ export function wranglerDevArguments(input) {
|
|
|
438
440
|
"OYSTER_COMPUTER_BACKEND:local",
|
|
439
441
|
];
|
|
440
442
|
}
|
|
443
|
+
/** Provision the trial's separate encryption key through Wrangler's native secrets. */
|
|
444
|
+
export async function prepareTryModelKeyCustody(directory) {
|
|
445
|
+
try {
|
|
446
|
+
const native = await import("wrangler");
|
|
447
|
+
const resolveKey = () => {
|
|
448
|
+
const config = native.unstable_readConfig({
|
|
449
|
+
config: join(directory, "wrangler.jsonc"),
|
|
450
|
+
});
|
|
451
|
+
const binding = native.unstable_getVarsForDev(config.userConfigPath, undefined, config.vars, undefined, true, config.secrets).OYSTER_CREDENTIAL_KEY;
|
|
452
|
+
if (binding === undefined)
|
|
453
|
+
return undefined;
|
|
454
|
+
if (binding.type !== "secret_text" && binding.type !== "plain_text")
|
|
455
|
+
throw new Error("Invalid credential-key binding");
|
|
456
|
+
return binding.value;
|
|
457
|
+
};
|
|
458
|
+
const validate = async (key) => {
|
|
459
|
+
await createCredentialSealer({ activeKeyId: "instance", keys: { instance: key } }, "fungi.oyster.credentials.v1").seal([], "Oyster credential custody check");
|
|
460
|
+
};
|
|
461
|
+
const secretFiles = [".dev.vars", ".env", ".env.local"];
|
|
462
|
+
const ignored = "\n# Local Oyster secrets\n/.dev.vars\n/.env\n/.env.local\n";
|
|
463
|
+
const ignorePath = join(directory, ".gitignore");
|
|
464
|
+
const before = (await exists(ignorePath))
|
|
465
|
+
? await readFile(ignorePath, "utf8")
|
|
466
|
+
: "";
|
|
467
|
+
if (!before.includes(ignored))
|
|
468
|
+
await appendFile(ignorePath, ignored);
|
|
469
|
+
for (const name of secretFiles) {
|
|
470
|
+
const path = join(directory, name);
|
|
471
|
+
if (await exists(path))
|
|
472
|
+
await chmod(path, 0o600);
|
|
473
|
+
}
|
|
474
|
+
const existing = resolveKey();
|
|
475
|
+
if (existing !== undefined) {
|
|
476
|
+
await validate(existing);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const key = encodeBase64Url(randomBytes(32));
|
|
480
|
+
const path = join(directory, (await exists(join(directory, ".dev.vars"))) ? ".dev.vars" : ".env.local");
|
|
481
|
+
await appendFile(path, `\nOYSTER_CREDENTIAL_KEY=${key}\n`, { mode: 0o600 });
|
|
482
|
+
await chmod(path, 0o600);
|
|
483
|
+
const provisioned = resolveKey();
|
|
484
|
+
if (provisioned !== key)
|
|
485
|
+
throw new Error("Credential key was not loaded");
|
|
486
|
+
await validate(provisioned);
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
throw new TryError("This Oyster could not prepare private model-key storage.", "Check the local secret files and Wrangler environment settings, then restart the Oyster. Existing keys were not replaced.");
|
|
490
|
+
}
|
|
491
|
+
}
|
|
441
492
|
function startWrangler(input) {
|
|
442
493
|
return (async () => {
|
|
443
494
|
input.signal.throwIfAborted();
|
|
444
495
|
const wrangler = join(input.directory, "node_modules", "wrangler", "bin", "wrangler.js");
|
|
445
496
|
if (!(await exists(wrangler)))
|
|
446
497
|
throw new TryError(`wrangler is not installed in ${input.directory}.`, `Run \`npm install\` there, then run \`${retryCommand(input.directory, input.port)}\` again.`);
|
|
498
|
+
await prepareTryModelKeyCustody(input.directory);
|
|
447
499
|
await mkdir(join(input.directory, ".oyster"), { recursive: true });
|
|
448
500
|
const log = join(input.directory, logFile);
|
|
449
501
|
input.signal.throwIfAborted();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.32",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Self-hosted Apps for people and AI agents, with a local trial and deployment to your Cloudflare account.",
|
|
6
6
|
"homepage": "https://docs.fungi.computer/oyster",
|
|
@@ -356,12 +356,12 @@
|
|
|
356
356
|
"@fungi.computer/lantern": "0.4.2",
|
|
357
357
|
"@fungi.computer/mycelium": "0.3.8",
|
|
358
358
|
"@fungi.computer/nacre": "0.4.5",
|
|
359
|
-
"@fungi.computer/parakeet": "0.11.
|
|
359
|
+
"@fungi.computer/parakeet": "0.11.9",
|
|
360
360
|
"@fungi.computer/puffball": "0.5.5",
|
|
361
361
|
"@fungi.computer/seam": "0.2.5",
|
|
362
362
|
"@fungi.computer/shiitake": "0.12.4",
|
|
363
363
|
"@fungi.computer/shiitake-extensions": "0.6.11",
|
|
364
|
-
"@fungi.computer/sigils": "0.3.
|
|
364
|
+
"@fungi.computer/sigils": "0.3.1",
|
|
365
365
|
"@fungi.computer/sprite": "0.2.2",
|
|
366
366
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
367
367
|
"@fungi.computer/veil": "0.6.6",
|
|
@@ -383,18 +383,13 @@
|
|
|
383
383
|
"parse5": "8.0.1",
|
|
384
384
|
"path-to-regexp": "8.4.2",
|
|
385
385
|
"strip-ansi": "7.2.0",
|
|
386
|
-
"zod": "4.4.3"
|
|
386
|
+
"zod": "4.4.3",
|
|
387
|
+
"wrangler": "4.156.2"
|
|
387
388
|
},
|
|
388
389
|
"license": "MIT",
|
|
389
390
|
"peerDependencies": {
|
|
390
391
|
"react": "^18.3.1 || ^19.2.0",
|
|
391
|
-
"react-dom": "^18.3.1 || ^19.2.0"
|
|
392
|
-
"wrangler": "^4.127.1"
|
|
393
|
-
},
|
|
394
|
-
"peerDependenciesMeta": {
|
|
395
|
-
"wrangler": {
|
|
396
|
-
"optional": true
|
|
397
|
-
}
|
|
392
|
+
"react-dom": "^18.3.1 || ^19.2.0"
|
|
398
393
|
},
|
|
399
394
|
"repository": {
|
|
400
395
|
"type": "git",
|