@fungi.computer/oyster 0.37.1 → 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.
Files changed (86) hide show
  1. package/README.md +5 -4
  2. package/dist/agents.js +9 -2
  3. package/dist/app-builds.d.ts +1 -1
  4. package/dist/app-region.d.ts +94 -0
  5. package/dist/app-region.js +316 -0
  6. package/dist/authorization.d.ts +58 -9
  7. package/dist/authorization.js +56 -11
  8. package/dist/boot-host-script.js +1 -1
  9. package/dist/build/candidate-builder.d.ts +1 -1
  10. package/dist/build/candidate-cli.mjs +284 -17
  11. package/dist/build/effect.d.ts +3 -3
  12. package/dist/build/submission-contract.d.ts +1 -1
  13. package/dist/build/workspace-build.d.ts +2 -2
  14. package/dist/channels/discord-replies.d.ts +8 -1
  15. package/dist/channels/discord-replies.js +80 -29
  16. package/dist/cloudflare.d.ts +1 -0
  17. package/dist/cloudflare.js +11 -0
  18. package/dist/credential-migration-001.d.ts +14 -0
  19. package/dist/credential-migration-001.js +13 -0
  20. package/dist/credential-migration-002.d.ts +38 -0
  21. package/dist/credential-migration-002.js +74 -0
  22. package/dist/embed-metafiles.js +2 -2
  23. package/dist/embed-scripts.js +1 -1
  24. package/dist/host.d.ts +2 -0
  25. package/dist/host.js +20 -1
  26. package/dist/index.d.ts +15 -1
  27. package/dist/index.js +19 -0
  28. package/dist/invocation.d.ts +165 -0
  29. package/dist/invocation.js +67 -0
  30. package/dist/keys.d.ts +4 -3
  31. package/dist/keys.js +5 -4
  32. package/dist/mcp-owner.d.ts +4 -3
  33. package/dist/mcp-owner.js +3 -2
  34. package/dist/page/mount.js +5 -1
  35. package/dist/page/region.d.ts +6 -0
  36. package/dist/page/region.js +12 -0
  37. package/dist/page-config.d.ts +2 -0
  38. package/dist/page-config.js +2 -0
  39. package/dist/page-script.js +3 -3
  40. package/dist/source/seed-receipt.d.ts +1 -1
  41. package/dist/source/template-seed.d.ts +1 -1
  42. package/dist/standalone/agent-connections.d.ts +49 -1
  43. package/dist/standalone/agent-connections.js +101 -12
  44. package/dist/standalone/agent-self.js +2 -1
  45. package/dist/standalone/agents.d.ts +7 -3
  46. package/dist/standalone/agents.js +42 -19
  47. package/dist/standalone/computer-fleet.d.ts +12 -6
  48. package/dist/standalone/computer-fleet.js +70 -29
  49. package/dist/standalone/computer.js +39 -14
  50. package/dist/standalone/instance.d.ts +3 -1
  51. package/dist/standalone/instance.js +8 -0
  52. package/dist/standalone/model-key-vault.d.ts +33 -4
  53. package/dist/standalone/model-key-vault.js +74 -17
  54. package/dist/standalone/preview.js +11 -10
  55. package/dist/standalone/try-cli.d.ts +12 -2
  56. package/dist/standalone/try-cli.js +170 -32
  57. package/dist/standalone/try-worker.d.ts +2 -0
  58. package/dist/standalone/try-worker.js +15 -0
  59. package/dist/standalone/worker.js +3 -3
  60. package/dist/standalone/workflow-host.d.ts +1 -1
  61. package/dist/standalone/workflows.d.ts +3 -3
  62. package/dist/standalone/workflows.js +7 -0
  63. package/dist/testing/capabilities.d.ts +2 -0
  64. package/dist/testing/capabilities.js +2 -0
  65. package/dist/webhook-custody.d.ts +14 -3
  66. package/dist/webhook-custody.js +165 -43
  67. package/dist/webhooks.d.ts +1 -1
  68. package/dist/webhooks.js +15 -3
  69. package/dist/workers-git.d.ts +24 -8
  70. package/dist/workers-git.js +105 -15
  71. package/dist/workers.d.ts +16 -0
  72. package/dist/workers.js +95 -5
  73. package/docs/api/apps.md +31 -31
  74. package/docs/api/authorization.md +119 -17
  75. package/docs/api/build-contract.md +8 -8
  76. package/docs/api/build.md +163 -174
  77. package/docs/api/cloudflare.md +171 -0
  78. package/docs/api/host.md +1 -0
  79. package/docs/api/index.md +23 -0
  80. package/docs/api/invocation.md +623 -23
  81. package/docs/api/keys.md +6 -6
  82. package/docs/api/pack.md +3 -3
  83. package/docs/api/page/mount.md +22 -20
  84. package/docs/api/workers-git.md +273 -157
  85. package/docs/api/workers.md +257 -175
  86. package/package.json +19 -18
@@ -20,8 +20,9 @@ import { AppInstanceError, selectionOf } from "../index.js";
20
20
  import {} from "../cloudflare.js";
21
21
  import { computerSlots } from "../computer.js";
22
22
  import { oysterPrincipalId, } from "../host.js";
23
- import { authorityOf, computer as computerRoute, owner, reachesComputer, routes as routeTable, } from "../authorization.js";
23
+ import { authorityOf, computer as computerRoute, keyFrameComputer, owner, reachesComputer, routes as routeTable, } from "../authorization.js";
24
24
  import { oysterAppBuildTimeoutMs, } from "../app-builds.js";
25
+ import { ownerHoldsComputer } from "./computer-fleet.js";
25
26
  import { workflowGitStepGrant, } from "./workflow-binding.js";
26
27
  const missingFile = z.lazy(() => z.object({ code: z.literal("ENOENT") }));
27
28
  const workspaceId = computerGrantSchema.shape.computerId;
@@ -30,13 +31,17 @@ const command = computerExecutionRequestSchema({ maximumTimeMs: 45_000 }).omit({
30
31
  backend: true,
31
32
  });
32
33
  const empty = z.strictObject({});
33
- // Frame-bound callers (Agent/Workflow methods) never supply requestId or
34
- // requestScope; the host mints both from the invoking frame's idempotency
35
- // key and installation (see computerInvocation's "processStart" case).
36
- const processStart = processStartInputSchema.omit({
34
+ // Frame-bound callers never supply requestScope; the host mints it from the
35
+ // invoking frame's installation. The replay key is the frame's idempotency key
36
+ // when the host attests one (a Workflow node). A caller it attests none for,
37
+ // such as an external key over MCP, names its own requestId, which Shed
38
+ // passes through (see computerInvocation's "processStart" case).
39
+ const processStart = processStartInputSchema
40
+ .omit({
37
41
  requestId: true,
38
42
  requestScope: true,
39
- });
43
+ })
44
+ .extend({ requestId: processStartInputSchema.shape.requestId.optional() });
40
45
  // The Oyster capability HTTP route has no per-field header mapping (the
41
46
  // generic page capability handle in packages/oyster/src/page/capabilities.ts
42
47
  // just JSON-encodes the whole input), so requestId travels in the body here;
@@ -68,18 +73,21 @@ function grant(computerId, actor) {
68
73
  };
69
74
  }
70
75
  /**
71
- * The Computer grant actor for a principal `authorization.ts` lets reach the
76
+ * The Computer grant actor for a principal `authorization.ts` lets reach this
72
77
  * Computer; null otherwise. `keysLive` is the one owner-checked port every
73
78
  * caller reaches a key's liveness through (the same one `host.keys.live`
74
79
  * is); a caller with none -- the Media binding's own workspace selection
75
80
  * never calls through to a principal at all -- fails every key closed.
76
81
  */
77
- async function computerActor(principal, keysLive) {
82
+ async function computerActor(principal, keysLive, computerId) {
78
83
  const authority = await authorityOf(principal, {
79
84
  liveKey: keysLive ?? (() => Promise.resolve(null)),
80
85
  appToolPolicy: () => null,
86
+ computerId,
81
87
  });
82
- return reachesComputer(authority) ? JSON.stringify(principal) : null;
88
+ return reachesComputer(authority, computerId)
89
+ ? JSON.stringify(principal)
90
+ : null;
83
91
  }
84
92
  /** Each advertised Computer tool, the grant action that accepts it, and its result. */
85
93
  const computerTools = {
@@ -721,7 +729,7 @@ export function standaloneWorkspace(env, keysLive, selectedComputerId = env.OYST
721
729
  return {
722
730
  computerId,
723
731
  computer: async (principal) => {
724
- const actor = await computerActor(principal, keysLive);
732
+ const actor = await computerActor(principal, keysLive, computerId);
725
733
  if (actor === null)
726
734
  return null;
727
735
  return {
@@ -978,14 +986,31 @@ async function computerPreviewInvocation(env, frame, args) {
978
986
  throw new AppInstanceError("revoked");
979
987
  return preview;
980
988
  }
981
- /** Re-admit the Computer captured by this invocation, never the current UI selection. */
989
+ /**
990
+ * Re-admit the Computer captured by this invocation, never the current UI
991
+ * selection. A key's frame also re-reads that key (`keyFrameComputer`): once
992
+ * it is revoked or expired the next call stops here. A key with no
993
+ * `computer.use` grant keeps the owner's Computer, as any App call does; one
994
+ * with a grant must still name this Computer, held by the key's owner.
995
+ */
982
996
  async function frameComputerId(env, scope, frame) {
983
997
  frame.signal.throwIfAborted();
984
998
  const subject = frame.facts.subject;
985
999
  if (subject.kind !== "call" || subject.context.computerId === null)
986
1000
  throw new AppInstanceError("revoked");
987
1001
  const computerId = workspaceId.parse(subject.context.computerId);
988
- if (!(await env.REGISTRY.getByName(scope.durableName("registry")).ownsComputer(computerId)))
1002
+ const registry = env.REGISTRY.getByName(scope.durableName("registry"));
1003
+ const { actor } = subject.context;
1004
+ if (actor.kind === "team-key") {
1005
+ const reach = keyFrameComputer(await env.KEYS.getByName(scope.durableName("keys")).live(actor.keyId), computerId);
1006
+ const admitted = reach.kind === "owner-computer"
1007
+ ? await registry.ownsComputer(computerId)
1008
+ : reach.kind === "granted" &&
1009
+ (await ownerHoldsComputer(registry, reach.owner, computerId));
1010
+ if (!admitted)
1011
+ throw new AppInstanceError("revoked");
1012
+ }
1013
+ else if (!(await registry.ownsComputer(computerId)))
989
1014
  throw new AppInstanceError("revoked");
990
1015
  frame.signal.throwIfAborted();
991
1016
  return computerId;
@@ -1057,11 +1082,11 @@ export async function computerInvocation(env, scope, frame, method, args) {
1057
1082
  break;
1058
1083
  case "processStart": {
1059
1084
  const [parsed] = z.tuple([processStart]).parse(args);
1060
- const requestId = subject.context.idempotencyKey;
1085
+ const requestId = subject.context.idempotencyKey ?? parsed.requestId;
1061
1086
  const owner = frame.facts.selection.owner;
1062
1087
  const methodName = frame.host.method?.name;
1063
1088
  if (requestId === undefined ||
1064
- actor.kind !== "member" ||
1089
+ actor.kind === "agent" ||
1065
1090
  owner.kind !== "installation" ||
1066
1091
  methodName === undefined)
1067
1092
  throw new AppInstanceError("revoked");
@@ -1,3 +1,4 @@
1
+ import { instanceSecretSealer } from "./model-key-vault.js";
1
2
  import { type OysterBindingTable } from "../workers.js";
2
3
  import { OysterGitInstance, OysterWebhooks, type HostRecipientEvent, type OysterGitWorkerEnv } from "../workers-git.js";
3
4
  import { type StandaloneAgentsEnv } from "./agents.js";
@@ -26,7 +27,8 @@ export declare abstract class StandaloneInstance<Env extends StandaloneInstanceE
26
27
  * libraries. A library that is down keeps its own row pending and retried, or
27
28
  * failed after the last retry; the emitting App's write has already returned.
28
29
  */
29
- export declare class StandaloneEventDelivery extends OysterWebhooks<WorkflowEventEnv> {
30
+ export declare class StandaloneEventDelivery extends OysterWebhooks<WorkflowEventEnv & Parameters<typeof instanceSecretSealer>[0]["env"]> {
31
+ protected credentialSealer(): import("../credential-migration-002.js").SecretSealer | undefined;
30
32
  protected deliverToRecipient(delivery: Readonly<{
31
33
  recipient: string;
32
34
  event: HostRecipientEvent;
@@ -1,4 +1,5 @@
1
1
  import { AppInstanceError } from "../index.js";
2
+ import { instanceSecretSealer } from "./model-key-vault.js";
2
3
  import { oysterBindingEntrypoint, } from "../workers.js";
3
4
  import { OysterGitInstance, OysterWebhooks, eventsBindingFor, gitBindings, } from "../workers-git.js";
4
5
  import { agentFrameMethods, dispatchAgentBinding, } from "./agents.js";
@@ -65,6 +66,13 @@ export class StandaloneInstance extends OysterGitInstance {
65
66
  * failed after the last retry; the emitting App's write has already returned.
66
67
  */
67
68
  export class StandaloneEventDelivery extends OysterWebhooks {
69
+ credentialSealer() {
70
+ return instanceSecretSealer({
71
+ owner: this.ctx.storage,
72
+ ownerId: this.ctx.id.toString(),
73
+ env: this.env,
74
+ });
75
+ }
68
76
  deliverToRecipient(delivery) {
69
77
  return deliverWorkflowEvent(this.env, delivery.recipient, delivery.event);
70
78
  }
@@ -1,4 +1,5 @@
1
- import { type CredentialRecord, type CredentialStorage } from "@fungi.computer/veil/credential-store";
1
+ import { type CredentialRecord, type CredentialStorage, type CredentialKeyring } from "@fungi.computer/veil/credential-store";
2
+ import type { SqlStore } from "@fungi.computer/veil/connections";
2
3
  import { type StandaloneModelKeyProvider } from "./model-key-providers.js";
3
4
  /**
4
5
  * This instance's own model-key owner. Provider API keys are sealed (AES-GCM)
@@ -28,13 +29,38 @@ export type ModelKeySealInput = Readonly<{
28
29
  accountId?: string;
29
30
  }>;
30
31
  export type ModelKeyStorage = CredentialStorage;
32
+ /** Deployment-owned wrapping keys. No implicit `instance` key id remains. */
33
+ export declare function instanceCredentialKeyring(env: {
34
+ OYSTER_CREDENTIAL_KEY?: string;
35
+ OYSTER_CREDENTIAL_KEY_ID?: string;
36
+ OYSTER_CREDENTIAL_PREVIOUS_KEYS?: string;
37
+ }): CredentialKeyring | undefined;
38
+ /**
39
+ * The instance's envelope for one object's own secrets beside its credential
40
+ * rows: webhook, subscription and Discord reply secrets. Without a keyring
41
+ * there is no sealer; a malformed keyring refuses each use as unavailable.
42
+ */
43
+ export declare function instanceSecretSealer(options: {
44
+ owner: SqlStore;
45
+ ownerId: string;
46
+ env: Parameters<typeof instanceCredentialKeyring>[0];
47
+ }): SecretSealer | undefined;
48
+ /** One object's sealer and the migration 002 its own tables need. */
49
+ export declare function instanceSecretCustody(options: Parameters<typeof instanceSecretSealer>[0] & {
50
+ tables: readonly SealedTable002[];
51
+ }): {
52
+ sealer: SecretSealer | undefined;
53
+ ready: () => Promise<void>;
54
+ };
31
55
  /**
32
56
  * The instance's one encrypted credential store. Listing and removal need no
33
57
  * key; sealing and opening refuse without one.
34
58
  */
35
59
  export declare function createInstanceCredentialStore(options: {
36
60
  storage: CredentialStorage;
37
- credentialKey: string | undefined;
61
+ owner: SqlStore;
62
+ ownerId: string;
63
+ keyring: CredentialKeyring | undefined;
38
64
  now?: () => number;
39
65
  }): {
40
66
  put(input: {
@@ -49,8 +75,10 @@ export declare function createInstanceCredentialStore(options: {
49
75
  };
50
76
  export declare function createModelKeyVault(options: {
51
77
  storage: ModelKeyStorage;
52
- /** The instance credential key (32 bytes, base64url); absent means no custody. */
53
- credentialKey: string | undefined;
78
+ owner: SqlStore;
79
+ ownerId: string;
80
+ /** Active and retained wrapping keys; absent means no custody. */
81
+ keyring: CredentialKeyring | undefined;
54
82
  fetch?: typeof globalThis.fetch;
55
83
  now?: () => number;
56
84
  }): {
@@ -64,3 +92,4 @@ export declare function createModelKeyVault(options: {
64
92
  /** Send one provider request with the key attached; the caller's auth is dropped. */
65
93
  send(keyId: string, request: Request): Promise<Response>;
66
94
  };
95
+ import { type SealedTable002, type SecretSealer } from "../credential-migration-002.js";
@@ -1,5 +1,5 @@
1
1
  import * as Schema from "effect/Schema";
2
- import { createCredentialSealer, createCredentialStore, CredentialError, } from "@fungi.computer/veil/credential-store";
2
+ import { createOwnerCredentialSealer, createOwnerCredentialStore, CredentialError, } from "@fungi.computer/veil/credential-store";
3
3
  import { modelKeyAuthenticated, modelKeyForwardedHeaders, modelKeyBaseUrl, modelKeyTarget, modelKeyValidationRequest, modelKeyValidationResult, } from "@fungi.computer/veil/model-keys";
4
4
  import { isStandaloneModelKeyProvider, } from "./model-key-providers.js";
5
5
  export class ModelKeyRefused extends Error {
@@ -41,6 +41,29 @@ const providerOf = (kind) => {
41
41
  return provider;
42
42
  };
43
43
  const maxKeyLength = 16_384;
44
+ /** Deployment-owned wrapping keys. No implicit `instance` key id remains. */
45
+ export function instanceCredentialKeyring(env) {
46
+ const key = env.OYSTER_CREDENTIAL_KEY;
47
+ // A deployment that never named its key keeps the id its rows were sealed under.
48
+ const id = env.OYSTER_CREDENTIAL_KEY_ID ??
49
+ (key === undefined ? undefined : "instance");
50
+ const retained = env.OYSTER_CREDENTIAL_PREVIOUS_KEYS;
51
+ if (key === undefined && id === undefined && retained === undefined)
52
+ return undefined;
53
+ if (key === undefined || id === undefined)
54
+ throw new CredentialError("unavailable");
55
+ try {
56
+ const previous = retained === undefined
57
+ ? {}
58
+ : Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Record(Schema.String, Schema.String)))(retained);
59
+ if (Object.hasOwn(previous, id))
60
+ throw new CredentialError("unavailable");
61
+ return { activeKeyId: id, keys: { ...previous, [id]: key } };
62
+ }
63
+ catch {
64
+ throw new CredentialError("unavailable");
65
+ }
66
+ }
44
67
  const publicRecord = (record) => ({
45
68
  keyId: record.credentialId,
46
69
  provider: providerOf(record.kind),
@@ -57,29 +80,61 @@ function authenticated(provider, headers, apiKey) {
57
80
  }
58
81
  return modelKeyAuthenticated(provider, headers, apiKey);
59
82
  }
83
+ const instanceDomain = "fungi.oyster.credentials.v1";
84
+ /**
85
+ * The instance's envelope for one object's own secrets beside its credential
86
+ * rows: webhook, subscription and Discord reply secrets. Without a keyring
87
+ * there is no sealer; a malformed keyring refuses each use as unavailable.
88
+ */
89
+ export function instanceSecretSealer(options) {
90
+ const { env } = options;
91
+ if (env.OYSTER_CREDENTIAL_KEY === undefined &&
92
+ env.OYSTER_CREDENTIAL_KEY_ID === undefined &&
93
+ env.OYSTER_CREDENTIAL_PREVIOUS_KEYS === undefined)
94
+ return undefined;
95
+ // Resolved per use, so a malformed keyring rejects that use, never composition.
96
+ const current = () => {
97
+ const keyring = instanceCredentialKeyring(env);
98
+ if (keyring === undefined)
99
+ throw new CredentialError("unavailable");
100
+ return createOwnerCredentialSealer({
101
+ storage: options.owner,
102
+ ownerId: options.ownerId,
103
+ keyring,
104
+ domain: instanceDomain,
105
+ });
106
+ };
107
+ return {
108
+ seal: async (context, credential) => current().seal(context, credential),
109
+ open: async (context, sealed) => current().open(context, sealed),
110
+ };
111
+ }
112
+ /** One object's sealer and the migration 002 its own tables need. */
113
+ export function instanceSecretCustody(options) {
114
+ const sealer = instanceSecretSealer(options);
115
+ return {
116
+ sealer,
117
+ ready: credentialMigration002({
118
+ store: options.owner,
119
+ sealer,
120
+ tables: options.tables,
121
+ }),
122
+ };
123
+ }
60
124
  /**
61
125
  * The instance's one encrypted credential store. Listing and removal need no
62
126
  * key; sealing and opening refuse without one.
63
127
  */
64
128
  export function createInstanceCredentialStore(options) {
65
- const unavailable = () => Promise.reject(new CredentialError("unavailable"));
66
- const sealer = options.credentialKey === undefined
67
- ? { seal: unavailable, open: unavailable }
68
- : createCredentialSealer({
69
- activeKeyId: "instance",
70
- keys: { instance: options.credentialKey },
71
- }, "fungi.oyster.credentials.v1");
72
- const storeOptions = {
73
- storage: options.storage,
74
- sealer,
75
- };
76
- if (options.now !== undefined)
77
- storeOptions.now = options.now;
78
- return createCredentialStore(storeOptions);
129
+ return createOwnerCredentialStore({
130
+ ...options,
131
+ domain: instanceDomain,
132
+ migrate: () => migrateCredentialRows001(options),
133
+ });
79
134
  }
80
135
  export function createModelKeyVault(options) {
81
136
  const send = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
82
- const credentialKey = options.credentialKey;
137
+ const keyring = options.keyring;
83
138
  const credentials = createInstanceCredentialStore(options);
84
139
  const store = () => credentials;
85
140
  const custody = async (work) => {
@@ -106,7 +161,7 @@ export function createModelKeyVault(options) {
106
161
  apiKey.length === 0 ||
107
162
  apiKey.length > maxKeyLength)
108
163
  throw new ModelKeyRefused("invalid_key");
109
- if (credentialKey === undefined)
164
+ if (keyring === undefined)
110
165
  throw new ModelKeyRefused("custody_unavailable");
111
166
  let secret = apiKey;
112
167
  let probe;
@@ -192,3 +247,5 @@ export function createModelKeyVault(options) {
192
247
  },
193
248
  };
194
249
  }
250
+ import { migrateCredentialRows001 } from "../credential-migration-001.js";
251
+ import { credentialMigration002, } from "../credential-migration-002.js";
@@ -21,6 +21,15 @@ const originSchema = z.lazy(() => z
21
21
  url.pathname === "/" &&
22
22
  !url.search &&
23
23
  !url.hash));
24
+ /**
25
+ * The one registrable-site rule for configuration and the port gate. Private
26
+ * PSL entries (workers.dev, ...) are included because browsers use them for
27
+ * SameSite cookies. Loaded on demand to keep the idle heap budget.
28
+ */
29
+ async function registrableSite() {
30
+ const { getDomain } = await import("tldts");
31
+ return (url) => getDomain(url.hostname, { allowPrivateDomains: true });
32
+ }
24
33
  function configuredPreview(env) {
25
34
  if (env.OYSTER_PREVIEW_DOMAIN !== undefined) {
26
35
  const parsed = originSchema.safeParse(`https://${env.OYSTER_PREVIEW_DOMAIN}`);
@@ -40,8 +49,7 @@ export async function previewOrigins(env) {
40
49
  const configured = configuredPreview(env);
41
50
  if (!owner.success || configured?.mode !== "host")
42
51
  return null;
43
- const { getDomain } = await import("tldts");
44
- const site = (url) => getDomain(url.hostname, { allowPrivateDomains: true });
52
+ const site = await registrableSite();
45
53
  const ownerSite = site(owner.data);
46
54
  const previewSite = site(configured.preview);
47
55
  if (ownerSite === null || previewSite === null || ownerSite === previewSite)
@@ -53,13 +61,6 @@ export async function previewOrigins(env) {
53
61
  }
54
62
  export class PreviewRefused extends Error {
55
63
  }
56
- // Public suffix rules only: a private-suffix preview domain still makes every
57
- // workspace-* host one site, so the gate refuses siblings that browsers might
58
- // treat as separate sites. Loaded on demand like previewOrigins' parser.
59
- async function publicSite() {
60
- const { getDomain } = await import("tldts");
61
- return (url) => getDomain(url.hostname, { allowPrivateDomains: false });
62
- }
63
64
  // The retained flat hostname uses the Computer's non-secret identity. Fleet
64
65
  // IDs have a computer_ prefix; configured standalone IDs can be simple labels.
65
66
  const hostnameComputer = z.string().regex(/^(?:computer_)?[a-z0-9]+$/u);
@@ -99,7 +100,7 @@ export function createStandalonePreview(storage, computerId, origins, native) {
99
100
  return new Response(null, { status: 404 });
100
101
  const policy = {
101
102
  entryUrl: entryUrl(origins, computerId, port),
102
- site: await publicSite(),
103
+ site: await registrableSite(),
103
104
  };
104
105
  return access
105
106
  .gate(port, policy, async (admitted) => {
@@ -1,4 +1,5 @@
1
1
  import { startTrialComputer } from "./trial-computer.js";
2
+ import { type CredentialKeyring } from "@fungi.computer/veil/credential-store";
2
3
  import { Cli } from "@fungi.computer/lantern";
3
4
  import { type DesktopReadiness } from "./local-desktop.js";
4
5
  import { type StarterApp } from "./app-set.js";
@@ -83,6 +84,15 @@ export type Manager = "npm" | "pnpm";
83
84
  /** pnpm when it ran this command (`pnpm dlx`), otherwise npm. */
84
85
  export declare function detectManager(userAgent: string | undefined): "pnpm" | "npm";
85
86
  export declare function installTryDependencies(directory: string, manager: Manager, verbose: boolean, signal: AbortSignal): Promise<void>;
86
- /** Provision the trial's separate encryption key through Wrangler's native secrets. */
87
- export declare function prepareTryModelKeyCustody(directory: string): Promise<void>;
87
+ /** One OS keychain entry, as `@napi-rs/keyring` exposes it. */
88
+ export type TrialKeychainEntry = Readonly<{
89
+ getPassword(): Promise<string | null>;
90
+ setPassword(value: string): Promise<void>;
91
+ }>;
92
+ /** Opens the entry for an account; `undefined` means this host has no keychain. */
93
+ export type TrialKeychain = (account: string) => Promise<TrialKeychainEntry | undefined>;
94
+ /** Keep the trial KEK outside its database and deliver it to the Worker over stdin. */
95
+ export declare function prepareTryModelKeyCustody(directory: string, keychain?: TrialKeychain): Promise<CredentialKeyring>;
96
+ /** The real trial effects; `keychain` holds the wrapping keys (the OS keychain by default). */
97
+ export declare const tryEffects: (keychain?: TrialKeychain) => TryEffects;
88
98
  export declare function tryOyster(args: readonly string[], effects?: TryEffects, ui?: Cli, callerSignal?: AbortSignal): Promise<void>;