@fungi.computer/oyster 0.19.29 → 0.19.31
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/standalone/try-cli.d.ts +2 -0
- package/dist/standalone/try-cli.js +53 -1
- package/package.json +17 -12
|
@@ -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,8 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/oyster",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.31",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Self-hosted Apps for people and AI agents, with a local trial and deployment to your Cloudflare account.",
|
|
6
|
+
"homepage": "https://docs.fungi.computer/oyster",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"fungi",
|
|
9
|
+
"apps",
|
|
10
|
+
"ai-agents",
|
|
11
|
+
"self-hosted",
|
|
12
|
+
"cloudflare",
|
|
13
|
+
"workers",
|
|
14
|
+
"local-development"
|
|
15
|
+
],
|
|
6
16
|
"type": "module",
|
|
7
17
|
"main": "./dist/index.js",
|
|
8
18
|
"types": "./dist/index.d.ts",
|
|
@@ -346,12 +356,12 @@
|
|
|
346
356
|
"@fungi.computer/lantern": "0.4.2",
|
|
347
357
|
"@fungi.computer/mycelium": "0.3.8",
|
|
348
358
|
"@fungi.computer/nacre": "0.4.5",
|
|
349
|
-
"@fungi.computer/parakeet": "0.11.
|
|
359
|
+
"@fungi.computer/parakeet": "0.11.9",
|
|
350
360
|
"@fungi.computer/puffball": "0.5.5",
|
|
351
361
|
"@fungi.computer/seam": "0.2.5",
|
|
352
362
|
"@fungi.computer/shiitake": "0.12.4",
|
|
353
363
|
"@fungi.computer/shiitake-extensions": "0.6.11",
|
|
354
|
-
"@fungi.computer/sigils": "0.3.
|
|
364
|
+
"@fungi.computer/sigils": "0.3.1",
|
|
355
365
|
"@fungi.computer/sprite": "0.2.2",
|
|
356
366
|
"@fungi.computer/sprite-zdog": "0.3.2",
|
|
357
367
|
"@fungi.computer/veil": "0.6.6",
|
|
@@ -373,18 +383,13 @@
|
|
|
373
383
|
"parse5": "8.0.1",
|
|
374
384
|
"path-to-regexp": "8.4.2",
|
|
375
385
|
"strip-ansi": "7.2.0",
|
|
376
|
-
"zod": "4.4.3"
|
|
386
|
+
"zod": "4.4.3",
|
|
387
|
+
"wrangler": "4.156.2"
|
|
377
388
|
},
|
|
378
389
|
"license": "MIT",
|
|
379
390
|
"peerDependencies": {
|
|
380
391
|
"react": "^18.3.1 || ^19.2.0",
|
|
381
|
-
"react-dom": "^18.3.1 || ^19.2.0"
|
|
382
|
-
"wrangler": "^4.127.1"
|
|
383
|
-
},
|
|
384
|
-
"peerDependenciesMeta": {
|
|
385
|
-
"wrangler": {
|
|
386
|
-
"optional": true
|
|
387
|
-
}
|
|
392
|
+
"react-dom": "^18.3.1 || ^19.2.0"
|
|
388
393
|
},
|
|
389
394
|
"repository": {
|
|
390
395
|
"type": "git",
|