@fungi.computer/oyster 0.37.2 → 0.38.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/README.md +5 -4
- package/dist/agents.js +9 -2
- package/dist/app-builds.d.ts +1 -1
- package/dist/app-region.d.ts +94 -0
- package/dist/app-region.js +316 -0
- package/dist/authorization.d.ts +58 -9
- package/dist/authorization.js +56 -11
- package/dist/boot-host-script.js +1 -1
- package/dist/build/candidate-builder.d.ts +1 -1
- package/dist/build/candidate-cli.mjs +284 -17
- package/dist/build/effect.d.ts +3 -3
- package/dist/build/submission-contract.d.ts +1 -1
- package/dist/build/workspace-build.d.ts +2 -2
- package/dist/channels/discord-replies.d.ts +8 -1
- package/dist/channels/discord-replies.js +80 -29
- package/dist/cloudflare.d.ts +1 -0
- package/dist/cloudflare.js +11 -0
- package/dist/credential-migration-001.d.ts +14 -0
- package/dist/credential-migration-001.js +13 -0
- package/dist/credential-migration-002.d.ts +38 -0
- package/dist/credential-migration-002.js +74 -0
- package/dist/embed-metafiles.js +2 -2
- package/dist/embed-scripts.js +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.js +20 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +19 -0
- package/dist/invocation.d.ts +165 -0
- package/dist/invocation.js +67 -0
- package/dist/keys.d.ts +4 -3
- package/dist/keys.js +5 -4
- package/dist/mcp-owner.d.ts +4 -3
- package/dist/mcp-owner.js +3 -2
- package/dist/page/mount.js +5 -1
- package/dist/page/region.d.ts +6 -0
- package/dist/page/region.js +12 -0
- package/dist/page-config.d.ts +2 -0
- package/dist/page-config.js +2 -0
- package/dist/page-script.js +2 -2
- package/dist/source/seed-receipt.d.ts +1 -1
- package/dist/source/template-seed.d.ts +1 -1
- package/dist/standalone/agent-connections.d.ts +49 -1
- package/dist/standalone/agent-connections.js +101 -12
- package/dist/standalone/agent-self.js +2 -1
- package/dist/standalone/agents.d.ts +7 -3
- package/dist/standalone/agents.js +42 -19
- package/dist/standalone/computer-fleet.d.ts +12 -6
- package/dist/standalone/computer-fleet.js +70 -29
- package/dist/standalone/computer.js +39 -14
- package/dist/standalone/instance.d.ts +3 -1
- package/dist/standalone/instance.js +8 -0
- package/dist/standalone/model-key-vault.d.ts +33 -4
- package/dist/standalone/model-key-vault.js +74 -17
- package/dist/standalone/preview.js +11 -10
- package/dist/standalone/try-cli.d.ts +12 -2
- package/dist/standalone/try-cli.js +170 -32
- package/dist/standalone/try-worker.d.ts +2 -0
- package/dist/standalone/try-worker.js +15 -0
- package/dist/standalone/worker.js +3 -3
- package/dist/standalone/workflow-host.d.ts +1 -1
- package/dist/standalone/workflows.d.ts +3 -3
- package/dist/standalone/workflows.js +7 -0
- package/dist/testing/capabilities.d.ts +2 -0
- package/dist/testing/capabilities.js +2 -0
- package/dist/webhook-custody.d.ts +14 -3
- package/dist/webhook-custody.js +165 -43
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.js +15 -3
- package/dist/workers-git.d.ts +24 -8
- package/dist/workers-git.js +105 -15
- package/dist/workers.d.ts +16 -0
- package/dist/workers.js +95 -5
- package/docs/api/apps.md +31 -31
- package/docs/api/authorization.md +119 -17
- package/docs/api/build-contract.md +8 -8
- package/docs/api/build.md +163 -174
- package/docs/api/cloudflare.md +171 -0
- package/docs/api/host.md +1 -0
- package/docs/api/index.md +23 -0
- package/docs/api/invocation.md +623 -23
- package/docs/api/keys.md +6 -6
- package/docs/api/pack.md +3 -3
- package/docs/api/page/mount.md +22 -20
- package/docs/api/workers-git.md +273 -157
- package/docs/api/workers.md +257 -175
- package/package.json +19 -18
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// and --verbose streams them instead. Piped output or CI gets plain lines.
|
|
14
14
|
import { spawn } from "node:child_process";
|
|
15
15
|
import { startTrialComputer } from "./trial-computer.js";
|
|
16
|
-
import { createTrialOwner, prepareTrialPrivateState
|
|
16
|
+
import { createTrialOwner, prepareTrialPrivateState } from "./try-custody.js";
|
|
17
17
|
import { randomBytes } from "node:crypto";
|
|
18
18
|
import { encode as encodeBase64Url } from "effect/encoding/Base64Url";
|
|
19
19
|
import { addAbortListener } from "node:events";
|
|
@@ -22,12 +22,12 @@ import { runGit } from "../build/local-build.js";
|
|
|
22
22
|
import { CleanupError, stopProcessGroup, awaitCleanup, } from "../build/process-group.js";
|
|
23
23
|
import { InstallationObservationError } from "../installation-client.js";
|
|
24
24
|
import { createWriteStream } from "node:fs";
|
|
25
|
-
import {
|
|
25
|
+
import { access, chmod, mkdir, mkdtemp, rename, readdir, rm, readFile, realpath, stat, writeFile, } from "node:fs/promises";
|
|
26
26
|
import { createServer } from "node:net";
|
|
27
|
-
import { createCredentialSealer } from "@fungi.computer/veil/credential-store";
|
|
27
|
+
import { createCredentialSealer, } from "@fungi.computer/veil/credential-store";
|
|
28
28
|
import { basename, dirname, delimiter, join, resolve } from "node:path";
|
|
29
29
|
import process from "node:process";
|
|
30
|
-
import { parseArgs, stripVTControlCharacters } from "node:util";
|
|
30
|
+
import { isDeepStrictEqual, parseArgs, parseEnv, stripVTControlCharacters, } from "node:util";
|
|
31
31
|
import { Cli } from "@fungi.computer/lantern";
|
|
32
32
|
import * as z from "zod";
|
|
33
33
|
import { installHelloApp } from "./hello-app.js";
|
|
@@ -414,50 +414,185 @@ async function waitUntilReady(url, child, timeoutMs, signal) {
|
|
|
414
414
|
}
|
|
415
415
|
return signal.aborted ? "exited" : "timeout";
|
|
416
416
|
}
|
|
417
|
-
|
|
418
|
-
|
|
417
|
+
const trialKeyringSchema = z.strictObject({
|
|
418
|
+
activeKeyId: z.string(),
|
|
419
|
+
keys: z.record(z.string(), z.string()),
|
|
420
|
+
});
|
|
421
|
+
const warnedCredentialFiles = new Set();
|
|
422
|
+
/** A known-absent session bus permits a file; a locked/broken keychain does not. */
|
|
423
|
+
async function headlessKeychain() {
|
|
424
|
+
if (process.platform !== "linux" ||
|
|
425
|
+
process.env.DBUS_SESSION_BUS_ADDRESS ||
|
|
426
|
+
process.env.DISPLAY)
|
|
427
|
+
return false;
|
|
428
|
+
if (process.env.XDG_RUNTIME_DIR === undefined)
|
|
429
|
+
return true;
|
|
430
|
+
try {
|
|
431
|
+
await access(join(process.env.XDG_RUNTIME_DIR, "bus"));
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
catch (cause) {
|
|
435
|
+
if (z.object({ code: z.literal("ENOENT") }).safeParse(cause).success)
|
|
436
|
+
return true;
|
|
437
|
+
throw cause;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/** The host's keychain, never the library's nonpersistent keyutils fallback. */
|
|
441
|
+
const osKeychain = async (account) => (await headlessKeychain())
|
|
442
|
+
? undefined
|
|
443
|
+
: new (await import("@napi-rs/keyring")).AsyncEntry("fungi-oyster-credentials", account, { linux: { store: "secret-service" } });
|
|
444
|
+
/** Convert native dotenv input once, after private custody has retained the key. */
|
|
445
|
+
async function removeTrialCredentialBindings(directory) {
|
|
446
|
+
for (const name of [".dev.vars", ".env", ".env.local"]) {
|
|
447
|
+
const file = join(directory, name);
|
|
448
|
+
if (!(await exists(file)))
|
|
449
|
+
continue;
|
|
450
|
+
const path = await realpath(file);
|
|
451
|
+
const before = await readFile(path, "utf8");
|
|
452
|
+
const values = parseEnv(before);
|
|
453
|
+
const removed = [
|
|
454
|
+
"OYSTER_CREDENTIAL_KEY",
|
|
455
|
+
"OYSTER_CREDENTIAL_KEY_ID",
|
|
456
|
+
"OYSTER_CREDENTIAL_PREVIOUS_KEYS",
|
|
457
|
+
];
|
|
458
|
+
if (!removed.some((key) => Object.hasOwn(values, key)))
|
|
459
|
+
continue;
|
|
460
|
+
const kept = Object.fromEntries(Object.entries(values).filter(([key]) => !removed.includes(key)));
|
|
461
|
+
// Drop only the custody lines; comments and other settings keep their bytes.
|
|
462
|
+
const next = before
|
|
463
|
+
.split(/(?<=\n)/u)
|
|
464
|
+
.filter((line) => !/^\s*(?:export\s+)?OYSTER_CREDENTIAL_(?:KEY|KEY_ID|PREVIOUS_KEYS)\s*=/u.test(line))
|
|
465
|
+
.join("");
|
|
466
|
+
// Node owns decoding. Never rewrite a file whose other values would change.
|
|
467
|
+
if (!isDeepStrictEqual(parseEnv(next), kept))
|
|
468
|
+
throw new Error("Native secret settings cannot be migrated losslessly");
|
|
469
|
+
const stage = await mkdtemp(join(dirname(path), ".credential-migration-"));
|
|
470
|
+
try {
|
|
471
|
+
const temporary = join(stage, "vars");
|
|
472
|
+
await writeFile(temporary, next, { mode: 0o600, flag: "wx" });
|
|
473
|
+
if ((await readFile(path, "utf8")) !== before)
|
|
474
|
+
throw new Error("Native secret settings changed during migration");
|
|
475
|
+
await rename(temporary, path);
|
|
476
|
+
}
|
|
477
|
+
finally {
|
|
478
|
+
await rm(stage, { recursive: true, force: true });
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
/** Keep the trial KEK outside its database and deliver it to the Worker over stdin. */
|
|
483
|
+
export async function prepareTryModelKeyCustody(directory, keychain = osKeychain) {
|
|
419
484
|
try {
|
|
420
485
|
await prepareTrialPrivateState(directory);
|
|
421
486
|
const native = await import("wrangler");
|
|
422
|
-
const
|
|
487
|
+
const resolveKeyring = () => {
|
|
423
488
|
const config = native.unstable_readConfig({
|
|
424
489
|
config: join(directory, "wrangler.jsonc"),
|
|
425
490
|
});
|
|
426
|
-
const
|
|
427
|
-
|
|
491
|
+
const bindings = native.unstable_getVarsForDev(config.userConfigPath, undefined, config.vars, undefined, true, config.secrets);
|
|
492
|
+
const value = (name) => {
|
|
493
|
+
const binding = bindings[name];
|
|
494
|
+
if (binding === undefined)
|
|
495
|
+
return undefined;
|
|
496
|
+
if (binding.type !== "secret_text" && binding.type !== "plain_text")
|
|
497
|
+
throw new Error("Invalid credential-key binding");
|
|
498
|
+
return binding.value;
|
|
499
|
+
};
|
|
500
|
+
const key = value("OYSTER_CREDENTIAL_KEY");
|
|
501
|
+
if (key === undefined)
|
|
428
502
|
return undefined;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
503
|
+
const id = value("OYSTER_CREDENTIAL_KEY_ID");
|
|
504
|
+
const previous = z
|
|
505
|
+
.record(z.string(), z.string())
|
|
506
|
+
.parse(JSON.parse(value("OYSTER_CREDENTIAL_PREVIOUS_KEYS") ?? "{}"));
|
|
507
|
+
// The old generated trial used `instance`; it is migration input only.
|
|
508
|
+
return id === undefined
|
|
509
|
+
? { activeKeyId: "local", keys: { instance: key, local: key } }
|
|
510
|
+
: { activeKeyId: id, keys: { ...previous, [id]: key } };
|
|
432
511
|
};
|
|
433
|
-
const validate = async (
|
|
434
|
-
await createCredentialSealer(
|
|
512
|
+
const validate = async (keyring) => {
|
|
513
|
+
await createCredentialSealer(keyring, "fungi.oyster.credentials.v1").seal([], "Oyster credential custody check");
|
|
514
|
+
return keyring;
|
|
435
515
|
};
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
516
|
+
const account = await realpath(join(directory, ownerKeyFile));
|
|
517
|
+
const path = join(dirname(account), "credential-keyring.json");
|
|
518
|
+
const entry = await keychain(account);
|
|
519
|
+
const saved = await entry?.getPassword();
|
|
520
|
+
const file = (await exists(path))
|
|
521
|
+
? await readFile(path, "utf8")
|
|
522
|
+
: undefined;
|
|
523
|
+
const configured = resolveKeyring();
|
|
524
|
+
// Disabled dotenv loading can hide an existing key; never mint a replacement over it.
|
|
525
|
+
if (configured === undefined)
|
|
526
|
+
for (const name of [".dev.vars", ".env", ".env.local"]) {
|
|
527
|
+
const native = join(directory, name);
|
|
528
|
+
if ((await exists(native)) &&
|
|
529
|
+
Object.hasOwn(parseEnv(await readFile(native, "utf8")), "OYSTER_CREDENTIAL_KEY"))
|
|
530
|
+
throw new Error("An existing wrapping key is not loadable");
|
|
531
|
+
}
|
|
532
|
+
const existing = saved ?? file;
|
|
533
|
+
const keyring = await validate(existing === undefined
|
|
534
|
+
? (configured ?? {
|
|
535
|
+
activeKeyId: "local",
|
|
536
|
+
keys: {
|
|
537
|
+
local: encodeBase64Url(crypto.getRandomValues(new Uint8Array(32))),
|
|
538
|
+
},
|
|
539
|
+
})
|
|
540
|
+
: trialKeyringSchema.parse(JSON.parse(existing)));
|
|
541
|
+
if (configured !== undefined && !isDeepStrictEqual(configured, keyring))
|
|
542
|
+
throw new Error("Native configuration and private custody disagree");
|
|
543
|
+
if (file !== undefined &&
|
|
544
|
+
!isDeepStrictEqual(trialKeyringSchema.parse(JSON.parse(file)), keyring))
|
|
545
|
+
throw new Error("File and keychain custody disagree");
|
|
546
|
+
const encoded = JSON.stringify(keyring);
|
|
547
|
+
if (existing === undefined) {
|
|
548
|
+
// Exclusive creation also gives concurrent startup attempts one durable candidate.
|
|
549
|
+
try {
|
|
550
|
+
await writeFile(path, encoded, { mode: 0o600, flag: "wx" });
|
|
551
|
+
}
|
|
552
|
+
catch (cause) {
|
|
553
|
+
if (!z.object({ code: z.literal("EEXIST") }).safeParse(cause).success)
|
|
554
|
+
throw cause;
|
|
555
|
+
throw new Error("Another startup is preparing credential custody", {
|
|
556
|
+
cause,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
if (entry === undefined) {
|
|
561
|
+
await chmod(path, 0o600);
|
|
562
|
+
if (!warnedCredentialFiles.has(path)) {
|
|
563
|
+
warnedCredentialFiles.add(path);
|
|
564
|
+
process.stderr.write(`oyster: OS keychain unavailable (Linux Secret Service); wrapping keys stored/read in 0600 file ${JSON.stringify(path)}.\n`);
|
|
565
|
+
}
|
|
440
566
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
567
|
+
else {
|
|
568
|
+
if (saved == null) {
|
|
569
|
+
const current = await entry.getPassword();
|
|
570
|
+
if (current !== null && current !== encoded)
|
|
571
|
+
throw new Error("Keychain changed during startup");
|
|
572
|
+
if (current === null)
|
|
573
|
+
await entry.setPassword(encoded);
|
|
574
|
+
}
|
|
575
|
+
const retained = await entry.getPassword();
|
|
576
|
+
if (retained === null ||
|
|
577
|
+
!isDeepStrictEqual(trialKeyringSchema.parse(JSON.parse(retained)), keyring))
|
|
578
|
+
throw new Error("Keychain did not retain the wrapping keys");
|
|
579
|
+
if (await exists(path))
|
|
580
|
+
await rm(path);
|
|
581
|
+
}
|
|
582
|
+
await removeTrialCredentialBindings(directory);
|
|
583
|
+
return keyring;
|
|
449
584
|
}
|
|
450
585
|
catch {
|
|
451
|
-
throw new TryError("This Oyster could not prepare private model-key storage.", "Check the
|
|
586
|
+
throw new TryError("This Oyster could not prepare private model-key storage.", "Check the OS keychain and private credential-keyring.json, then restart the Oyster. Existing keys were not replaced.");
|
|
452
587
|
}
|
|
453
588
|
}
|
|
454
|
-
function startWrangler(input) {
|
|
589
|
+
function startWrangler(input, keychain) {
|
|
455
590
|
return (async () => {
|
|
456
591
|
input.signal.throwIfAborted();
|
|
457
592
|
const workerHost = join(input.directory, trialWorkerFile);
|
|
458
593
|
if (!(await exists(workerHost)))
|
|
459
594
|
throw new TryError(`The local Oyster worker is not installed in ${input.directory}.`, `Run \`npm install\` there, then run \`${retryCommand(input.directory, input.port)}\` again.`);
|
|
460
|
-
await prepareTryModelKeyCustody(input.directory);
|
|
595
|
+
const credentialKeyring = await prepareTryModelKeyCustody(input.directory, keychain);
|
|
461
596
|
await mkdir(join(input.directory, ".oyster"), { recursive: true });
|
|
462
597
|
const log = join(input.directory, logFile);
|
|
463
598
|
input.signal.throwIfAborted();
|
|
@@ -486,6 +621,7 @@ function startWrangler(input) {
|
|
|
486
621
|
directory: input.directory,
|
|
487
622
|
port: input.port,
|
|
488
623
|
key: input.key,
|
|
624
|
+
credentialKeyring,
|
|
489
625
|
}));
|
|
490
626
|
const exited = new Promise((done) => {
|
|
491
627
|
child.on("close", (code) => {
|
|
@@ -568,9 +704,10 @@ function isTryCancellation(cause, signal) {
|
|
|
568
704
|
(cause instanceof Error && cause.name === "AbortError") ||
|
|
569
705
|
cause instanceof InstallationObservationError));
|
|
570
706
|
}
|
|
571
|
-
|
|
707
|
+
/** The real trial effects; `keychain` holds the wrapping keys (the OS keychain by default). */
|
|
708
|
+
export const tryEffects = (keychain = osKeychain) => ({
|
|
572
709
|
installDependencies: installTryDependencies,
|
|
573
|
-
startServer: startWrangler,
|
|
710
|
+
startServer: (input) => startWrangler(input, keychain),
|
|
574
711
|
installHello: installHelloApp,
|
|
575
712
|
installDesktop: async ({ directory, ...input }) => {
|
|
576
713
|
process.env.PATH = `${join(directory, "node_modules", ".bin")}${delimiter}${process.env.PATH ?? ""}`;
|
|
@@ -597,7 +734,8 @@ const realEffects = {
|
|
|
597
734
|
signInLink: startSignInLink,
|
|
598
735
|
open: openBrowser,
|
|
599
736
|
portFree,
|
|
600
|
-
};
|
|
737
|
+
});
|
|
738
|
+
const realEffects = tryEffects();
|
|
601
739
|
export async function tryOyster(args, effects = realEffects, ui = createTryCli(args), callerSignal) {
|
|
602
740
|
const { values, positionals } = parseArgs({
|
|
603
741
|
args: [...args],
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { unstable_startWorker } from "wrangler";
|
|
2
|
+
import type { CredentialKeyring } from "@fungi.computer/veil/credential-store";
|
|
2
3
|
/** Wrangler owns the local Worker; the trial owns its credentials and lifetime. */
|
|
3
4
|
export declare function trialWorkerConfiguration(input: {
|
|
4
5
|
directory: string;
|
|
5
6
|
port: number;
|
|
6
7
|
key: string;
|
|
8
|
+
credentialKeyring: CredentialKeyring;
|
|
7
9
|
}): Parameters<typeof unstable_startWorker>[0];
|
|
@@ -6,14 +6,29 @@ const inputSchema = z.strictObject({
|
|
|
6
6
|
directory: z.string().min(1),
|
|
7
7
|
port: z.number().int().min(1).max(65535),
|
|
8
8
|
key: z.string().min(1),
|
|
9
|
+
credentialKeyring: z.strictObject({
|
|
10
|
+
activeKeyId: z.string().min(1),
|
|
11
|
+
keys: z.record(z.string(), z.string()),
|
|
12
|
+
}),
|
|
9
13
|
});
|
|
10
14
|
/** Wrangler owns the local Worker; the trial owns its credentials and lifetime. */
|
|
11
15
|
export function trialWorkerConfiguration(input) {
|
|
16
|
+
const { activeKeyId, keys } = input.credentialKeyring;
|
|
17
|
+
const activeKey = keys[activeKeyId];
|
|
18
|
+
if (activeKey === undefined)
|
|
19
|
+
throw new Error("Missing active wrapping key");
|
|
20
|
+
const previous = Object.fromEntries(Object.entries(keys).filter(([id]) => id !== activeKeyId));
|
|
12
21
|
return {
|
|
13
22
|
config: join(input.directory, "wrangler.jsonc"),
|
|
14
23
|
sendMetrics: false,
|
|
15
24
|
bindings: {
|
|
16
25
|
OYSTER_OWNER_KEY: { type: "secret_text", value: input.key },
|
|
26
|
+
OYSTER_CREDENTIAL_KEY: { type: "secret_text", value: activeKey },
|
|
27
|
+
OYSTER_CREDENTIAL_KEY_ID: { type: "plain_text", value: activeKeyId },
|
|
28
|
+
OYSTER_CREDENTIAL_PREVIOUS_KEYS: {
|
|
29
|
+
type: "secret_text",
|
|
30
|
+
value: JSON.stringify(previous),
|
|
31
|
+
},
|
|
17
32
|
OYSTER_ORIGIN: {
|
|
18
33
|
type: "plain_text",
|
|
19
34
|
value: `http://127.0.0.1:${String(input.port)}`,
|
|
@@ -86,7 +86,7 @@ const standaloneRoot = (selectComputer) => {
|
|
|
86
86
|
: null,
|
|
87
87
|
workspace: async (env, keysLive, scope, request) => {
|
|
88
88
|
const registry = tenantRegistry(env, scope);
|
|
89
|
-
const { computerId, computerName } = await selectComputer(registry, request);
|
|
89
|
+
const { computerId, computerName } = await selectComputer(registry, keysLive, request);
|
|
90
90
|
return {
|
|
91
91
|
...standaloneWorkspace(env, keysLive, computerId),
|
|
92
92
|
computerName,
|
|
@@ -127,8 +127,8 @@ const standaloneRoot = (selectComputer) => {
|
|
|
127
127
|
});
|
|
128
128
|
return root;
|
|
129
129
|
};
|
|
130
|
-
const oysterRoot = standaloneRoot(async (registry, incoming) => {
|
|
131
|
-
const computerId = await standaloneComputerSelection(registry, incoming);
|
|
130
|
+
const oysterRoot = standaloneRoot(async (registry, keysLive, incoming) => {
|
|
131
|
+
const computerId = await standaloneComputerSelection(registry, keysLive, incoming);
|
|
132
132
|
return { computerId, computerName: await registry.computerName(computerId) };
|
|
133
133
|
});
|
|
134
134
|
export class OysterMcp extends createOysterGitMcpOwner(oysterRoot) {
|
|
@@ -825,9 +825,9 @@ export declare function createStandaloneWorkflowHost(owner: WatchdogSqliteOwner,
|
|
|
825
825
|
readonly title?: string | undefined;
|
|
826
826
|
} | {
|
|
827
827
|
readonly id: string;
|
|
828
|
+
readonly event: string;
|
|
828
829
|
readonly app: string;
|
|
829
830
|
readonly on: "event";
|
|
830
|
-
readonly event: string;
|
|
831
831
|
readonly eventDigest: string;
|
|
832
832
|
readonly when?: import("@fungi.computer/braid").Predicate | undefined;
|
|
833
833
|
readonly input?: {
|
|
@@ -169,7 +169,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
|
|
|
169
169
|
runId: string;
|
|
170
170
|
workflowId: string | undefined;
|
|
171
171
|
commit: string | undefined;
|
|
172
|
-
source: "key" | "manual" | "agent" | "
|
|
172
|
+
source: "key" | "manual" | "agent" | "event" | "schedule";
|
|
173
173
|
initiatedBy: Readonly<{
|
|
174
174
|
kind: "member";
|
|
175
175
|
memberId: string;
|
|
@@ -188,7 +188,7 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
|
|
|
188
188
|
runId: string;
|
|
189
189
|
workflowId: string | undefined;
|
|
190
190
|
commit: string | undefined;
|
|
191
|
-
source: "key" | "manual" | "agent" | "
|
|
191
|
+
source: "key" | "manual" | "agent" | "event" | "schedule";
|
|
192
192
|
initiatedBy: Readonly<{
|
|
193
193
|
kind: "member";
|
|
194
194
|
memberId: string;
|
|
@@ -551,9 +551,9 @@ export declare abstract class StandaloneWorkflowRunsBase<Env extends StandaloneW
|
|
|
551
551
|
readonly title?: string | undefined;
|
|
552
552
|
} | {
|
|
553
553
|
readonly id: string;
|
|
554
|
+
readonly event: string;
|
|
554
555
|
readonly app: string;
|
|
555
556
|
readonly on: "event";
|
|
556
|
-
readonly event: string;
|
|
557
557
|
readonly eventDigest: string;
|
|
558
558
|
readonly when?: import("@fungi.computer/braid").Predicate | undefined;
|
|
559
559
|
readonly input?: {
|
|
@@ -19,6 +19,7 @@ import { runKey, reviewKey, workflowGitPassRequestSchema, } from "./workflow-bin
|
|
|
19
19
|
import { agentDirectoryForScope } from "./agent-directory.js";
|
|
20
20
|
import { createWorkflowWebhooks, workflowWebhookCommandSchema, workflowWebhookControlResponse, } from "../webhooks.js";
|
|
21
21
|
import { workflowWebhookRefusal } from "../webhook-ingress.js";
|
|
22
|
+
import { instanceSecretSealer } from "./model-key-vault.js";
|
|
22
23
|
import { Hono } from "hono";
|
|
23
24
|
/** SQLite and the native Workflow binding belong to this standalone host; its root supplies `hostFor`. */
|
|
24
25
|
export class StandaloneWorkflowRunsBase extends DurableObject {
|
|
@@ -176,6 +177,12 @@ export class StandaloneWorkflowRunsBase extends DurableObject {
|
|
|
176
177
|
webhooks = createWorkflowWebhooks({
|
|
177
178
|
sql: ctx.storage.sql,
|
|
178
179
|
transactionSync: (body) => ctx.storage.transactionSync(body),
|
|
180
|
+
sealer: instanceSecretSealer({
|
|
181
|
+
owner: ctx.storage,
|
|
182
|
+
// This object is the library's; its keys open only for it.
|
|
183
|
+
ownerId: libraryId,
|
|
184
|
+
env,
|
|
185
|
+
}),
|
|
179
186
|
now: () => this.scheduleClock.now(),
|
|
180
187
|
scope: { host: env.OYSTER_ORIGIN, tenant: libraryId },
|
|
181
188
|
owner: async (principal) => {
|
|
@@ -21,6 +21,8 @@ export type CapabilityFixtureOptions = Readonly<{
|
|
|
21
21
|
authenticate?: (request: Request) => Promise<OysterAuthResult>;
|
|
22
22
|
agents?: OysterAgents;
|
|
23
23
|
liveKey?: (keyId: string) => Promise<LiveOysterKey | null>;
|
|
24
|
+
/** The Computer the host serves; absent, the host has none. */
|
|
25
|
+
computerId?: string;
|
|
24
26
|
}>;
|
|
25
27
|
/** One Oyster host with a single installation whose capability grants the options shape. */
|
|
26
28
|
export declare function capabilityFixture(options?: CapabilityFixtureOptions): Promise<{
|
|
@@ -118,6 +118,8 @@ export async function capabilityFixture(options = {}) {
|
|
|
118
118
|
};
|
|
119
119
|
if (options.liveKey !== undefined)
|
|
120
120
|
base = { ...base, keys: { live: options.liveKey } };
|
|
121
|
+
if (options.computerId !== undefined)
|
|
122
|
+
base = { ...base, computerId: options.computerId };
|
|
121
123
|
const host = options.agents === undefined
|
|
122
124
|
? base
|
|
123
125
|
: { ...base, ownerRoutes: agentApprovalRoutes(options.agents) };
|
|
@@ -2,23 +2,31 @@ import { z } from "zod";
|
|
|
2
2
|
import type { WatchdogSqliteOwner } from "@fungi.computer/watchdog";
|
|
3
3
|
import { type ArmedWorkflowTrigger } from "@fungi.computer/braid/runtime";
|
|
4
4
|
import type { WebhookDelivery } from "./webhook-ingress.js";
|
|
5
|
+
import type { SealedTable002, SecretSealer } from "./credential-migration-002.js";
|
|
5
6
|
export declare const workflowWebhookVerifierSchema: z.ZodEnum<{
|
|
6
7
|
"fungi-v1": "fungi-v1";
|
|
7
8
|
github: "github";
|
|
8
9
|
"standard-webhooks": "standard-webhooks";
|
|
9
10
|
}>;
|
|
10
11
|
export type WorkflowWebhookVerifier = z.output<typeof workflowWebhookVerifierSchema>;
|
|
12
|
+
/** Migration 002's step: the plaintext JSON record gains its sealed key bytes. */
|
|
13
|
+
export declare const workflowWebhookKeys002: SealedTable002;
|
|
11
14
|
/**
|
|
12
15
|
* This owner lives INSIDE the Team DO / standalone store. Only verification is
|
|
13
16
|
* handed to ingress. No read-existing-secret method, master key or generation
|
|
14
17
|
* derivation exists. Host authentication supplies the principal; owner() must
|
|
15
18
|
* resolve CURRENT server-side ownership, not trust a caller-supplied role.
|
|
19
|
+
* Key bytes rest only in the owner's S1 envelope; `ready` is the host's
|
|
20
|
+
* migration 002, which runs before any row is read or written.
|
|
16
21
|
*/
|
|
17
22
|
export declare function workflowWebhookCustody<Principal>(options: {
|
|
18
23
|
sql: WatchdogSqliteOwner["sql"];
|
|
19
24
|
transactionSync: WatchdogSqliteOwner["transactionSync"];
|
|
20
25
|
now(): number;
|
|
21
26
|
owner(principal: Principal): Promise<string | null>;
|
|
27
|
+
/** Absent without a configured keyring: sealing and opening refuse. */
|
|
28
|
+
sealer: SecretSealer | undefined;
|
|
29
|
+
ready(): Promise<void>;
|
|
22
30
|
}): {
|
|
23
31
|
create(principal: Principal, bindingId: string, verifier: WorkflowWebhookVerifier, rawBinding: ArmedWorkflowTrigger): Promise<{
|
|
24
32
|
readonly kind: "refused";
|
|
@@ -57,8 +65,11 @@ export declare function workflowWebhookCustody<Principal>(options: {
|
|
|
57
65
|
verification: {
|
|
58
66
|
/** Final owner-store check for an already verified durable reservation. */
|
|
59
67
|
isActive(bindingId: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Always opens one envelope and does six maintained verifier checks,
|
|
70
|
+
* including unknown IDs. Without a keyring it refuses as unavailable.
|
|
71
|
+
*/
|
|
72
|
+
verify(delivery: WebhookDelivery): Promise<{
|
|
62
73
|
status: "refused";
|
|
63
74
|
eventId?: undefined;
|
|
64
75
|
binding?: undefined;
|
|
@@ -139,6 +150,6 @@ export declare function workflowWebhookCustody<Principal>(options: {
|
|
|
139
150
|
readonly graphId?: string;
|
|
140
151
|
}[] | undefined;
|
|
141
152
|
};
|
|
142
|
-
}
|
|
153
|
+
}>;
|
|
143
154
|
};
|
|
144
155
|
};
|