@fungi.computer/oyster 0.14.1 → 0.16.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 (61) hide show
  1. package/README.md +178 -1552
  2. package/dist/agents.d.ts +8 -0
  3. package/dist/agents.js +6 -0
  4. package/dist/app-builds.d.ts +5 -6
  5. package/dist/app-builds.js +3 -10
  6. package/dist/apps/permissions.js +8 -1
  7. package/dist/auth.d.ts +2 -0
  8. package/dist/auth.js +9 -8
  9. package/dist/boot-host-script.js +1 -1
  10. package/dist/build/candidate-cli.mjs +4 -0
  11. package/dist/catalog-frame.d.ts +0 -1
  12. package/dist/computer.d.ts +5 -0
  13. package/dist/computer.js +1 -0
  14. package/dist/embed-metafiles.js +2 -2
  15. package/dist/embed-scripts.js +3 -3
  16. package/dist/hello-app-script.js +1 -1
  17. package/dist/host-page-assets.js +1 -1
  18. package/dist/host-page.d.ts +5 -1
  19. package/dist/host-page.js +23 -23
  20. package/dist/host.js +6 -1
  21. package/dist/page/app-access.js +23 -1
  22. package/dist/page/app-permissions.js +165 -50
  23. package/dist/page/app-rights.d.ts +8 -0
  24. package/dist/page/app-rights.js +13 -0
  25. package/dist/page/computer-handles.d.ts +15 -0
  26. package/dist/page/computer-handles.js +4 -1
  27. package/dist/page/mount.d.ts +5 -0
  28. package/dist/page/mount.js +4 -0
  29. package/dist/page-script.js +3 -3
  30. package/dist/standalone/agents.js +10 -0
  31. package/dist/standalone/app-set.d.ts +9 -0
  32. package/dist/standalone/app-set.js +43 -0
  33. package/dist/standalone/app-source.js +16 -1
  34. package/dist/standalone/builds.d.ts +2 -2
  35. package/dist/standalone/builds.js +4 -0
  36. package/dist/standalone/cloudflare-account.d.ts +10 -0
  37. package/dist/standalone/cloudflare-account.js +17 -0
  38. package/dist/standalone/computer.d.ts +8 -3
  39. package/dist/standalone/computer.js +26 -3
  40. package/dist/standalone/install-apps-cli.js +1 -1
  41. package/dist/standalone/local-desktop.d.ts +19 -2
  42. package/dist/standalone/local-desktop.js +38 -15
  43. package/dist/standalone/media.d.ts +2 -0
  44. package/dist/standalone/media.js +17 -1
  45. package/dist/standalone/registry.d.ts +4 -1
  46. package/dist/standalone/registry.js +6 -0
  47. package/dist/standalone/sign-in-link.d.ts +1 -1
  48. package/dist/standalone/sign-in-link.js +9 -18
  49. package/dist/standalone/try-cli.d.ts +7 -0
  50. package/dist/standalone/try-cli.js +88 -8
  51. package/dist/starter-agent.d.ts +59 -0
  52. package/dist/starter-agent.js +85 -0
  53. package/docs/api/README.md +744 -88
  54. package/docs/api/agents.md +6 -0
  55. package/docs/api/auth.md +10 -0
  56. package/docs/api/computer.md +4 -0
  57. package/docs/api/page/mount.md +2 -0
  58. package/docs/api/workers-git.md +14 -9
  59. package/docs/api/workers.md +8 -3
  60. package/docs/site/agent-quickstart.mdx +1 -1
  61. package/package.json +34 -50
package/dist/agents.d.ts CHANGED
@@ -149,6 +149,14 @@ export type OysterAgents = Readonly<{
149
149
  approveAppToolPolicy(agentId: string, principal: TenantPrincipal, level: AppToolPolicy["level"], expectedRevision: string | null, actor: AgentPolicyActor): Promise<AppToolPolicy | PendingAgentPolicy | Readonly<{
150
150
  error: "not_found" | "revision_conflict" | "not_granted";
151
151
  }>>;
152
+ /**
153
+ * Whether a model and an image provider are connected, so an App can say so
154
+ * before it takes a prompt. Reads configuration; never reaches a provider.
155
+ */
156
+ setup(): Promise<Readonly<{
157
+ models: "ready" | "missing";
158
+ media: "ready" | "missing";
159
+ }>>;
152
160
  /** The instance's sealed model keys, never their secrets. */
153
161
  modelKeys(): Promise<readonly ModelKeyRecord[]>;
154
162
  /** Validate with the provider, then seal one key; or an explicit refusal. */
package/dist/agents.js CHANGED
@@ -429,6 +429,12 @@ const modelKeyRefusalStatus = {
429
429
  export function modelKeyRoutes(agents) {
430
430
  return routes()
431
431
  .get("/api/model-keys", owner("direct"), async () => Response.json({ keys: await agents.modelKeys() }))
432
+ .get("/api/setup", owner("direct"), async () => Response.json({
433
+ ...(await agents.setup()),
434
+ // Git and the terminal are read from the Computer, which reports them.
435
+ git: "unknown",
436
+ terminal: "unknown",
437
+ }))
432
438
  .post("/api/model-keys", owner("direct"), async (context) => {
433
439
  const length = Number(context.req.header("content-length") ?? "0");
434
440
  if (length > 32 * 1024)
@@ -31,7 +31,7 @@ export declare const oysterAppBuildTimeoutMs = 900000;
31
31
  export declare const oysterBuildGitHost = "git.team.internal";
32
32
  export declare const oysterBuildReportHost = "build.team.internal";
33
33
  /** Where an App's source is cloned from. */
34
- export declare const oysterBuildLocationSchema: Schema.Union<readonly [Schema.Struct<{
34
+ declare const oysterBuildLocationSchema: Schema.Union<readonly [Schema.Struct<{
35
35
  readonly kind: Schema.Literal<"installation">;
36
36
  /** The installation whose Git holds the repository (Bonsai for a fork). */
37
37
  readonly installationId: Schema.String;
@@ -41,7 +41,7 @@ export declare const oysterBuildLocationSchema: Schema.Union<readonly [Schema.St
41
41
  }>]>;
42
42
  export type OysterBuildLocation = Schema.Schema.Type<typeof oysterBuildLocationSchema>;
43
43
  /** An App's registered build source: where it is cloned and its pinned recipe. */
44
- export declare const oysterBuildSourceSchema: Schema.Struct<{
44
+ declare const oysterBuildSourceSchema: Schema.Struct<{
45
45
  readonly appId: Schema.refine<import("@fungi.computer/puffball").AppId, Schema.String>;
46
46
  readonly location: Schema.Union<readonly [Schema.Struct<{
47
47
  readonly kind: Schema.Literal<"installation">;
@@ -79,9 +79,9 @@ export declare const oysterBuildSourceSchema: Schema.Struct<{
79
79
  }>;
80
80
  readonly buildRecipeDigest: Schema.refine<import("@fungi.computer/puffball").Sha256Digest, Schema.String>;
81
81
  }>;
82
- export type OysterBuildSource = Schema.Schema.Type<typeof oysterBuildSourceSchema>;
82
+ type OysterBuildSource = Schema.Schema.Type<typeof oysterBuildSourceSchema>;
83
83
  /** Installation is a build outcome, never a pending consent/approval record. */
84
- export declare const oysterBuildInstallationSchema: Schema.Union<readonly [Schema.Struct<{
84
+ declare const oysterBuildInstallationSchema: Schema.Union<readonly [Schema.Struct<{
85
85
  readonly kind: Schema.Literal<"pending">;
86
86
  readonly installationId: Schema.String;
87
87
  }>, Schema.Struct<{
@@ -105,8 +105,7 @@ export type OysterBuildView = Readonly<{
105
105
  installation: OysterBuildInstallation | null;
106
106
  }>;
107
107
  /** Known preflight refusals, before a job or Computer run exists. */
108
- export declare const oysterBuildStartReasonSchema: Schema.Literals<readonly ["invalid_revision", "no_source", "not_template_seed", "no_backend"]>;
109
- export type OysterBuildStartReason = Schema.Schema.Type<typeof oysterBuildStartReasonSchema>;
108
+ export type OysterBuildStartReason = "invalid_revision" | "no_source" | "not_template_seed" | "no_backend";
110
109
  export declare const oysterBuildStartMessages: {
111
110
  invalid_revision: string;
112
111
  no_source: string;
@@ -40,7 +40,7 @@ const jobTtlMs = oysterAppBuildTimeoutMs + 5 * 60_000;
40
40
  export const oysterBuildGitHost = "git.team.internal";
41
41
  export const oysterBuildReportHost = "build.team.internal";
42
42
  /** Where an App's source is cloned from. */
43
- export const oysterBuildLocationSchema = Schema.Union([
43
+ const oysterBuildLocationSchema = Schema.Union([
44
44
  Schema.Struct({
45
45
  kind: Schema.Literal("installation"),
46
46
  /** The installation whose Git holds the repository (Bonsai for a fork). */
@@ -51,14 +51,14 @@ export const oysterBuildLocationSchema = Schema.Union([
51
51
  Schema.Struct({ kind: Schema.Literal("template") }),
52
52
  ]);
53
53
  /** An App's registered build source: where it is cloned and its pinned recipe. */
54
- export const oysterBuildSourceSchema = Schema.Struct({
54
+ const oysterBuildSourceSchema = Schema.Struct({
55
55
  appId: appIdSchema,
56
56
  location: oysterBuildLocationSchema,
57
57
  recipe: capturedPinnedRecipeSchema,
58
58
  buildRecipeDigest: sha256DigestSchema,
59
59
  });
60
60
  /** Installation is a build outcome, never a pending consent/approval record. */
61
- export const oysterBuildInstallationSchema = Schema.Union([
61
+ const oysterBuildInstallationSchema = Schema.Union([
62
62
  Schema.Struct({
63
63
  kind: Schema.Literal("pending"),
64
64
  installationId: Schema.String,
@@ -74,13 +74,6 @@ export const oysterBuildInstallationSchema = Schema.Union([
74
74
  }),
75
75
  ]);
76
76
  const installationCodec = Schema.fromJsonString(oysterBuildInstallationSchema);
77
- /** Known preflight refusals, before a job or Computer run exists. */
78
- export const oysterBuildStartReasonSchema = Schema.Literals([
79
- "invalid_revision",
80
- "no_source",
81
- "not_template_seed",
82
- "no_backend",
83
- ]);
84
77
  export const oysterBuildStartMessages = {
85
78
  invalid_revision: "Source revision must be git: followed by a full commit hash",
86
79
  no_source: "App has no build source",
@@ -20,7 +20,14 @@ export function grantRequestFor(authority, facts, request, window) {
20
20
  if (authority.declaredOperationsDigest !== facts.declaredOperations.digest)
21
21
  return { kind: "refused", code: "stale_authority" };
22
22
  const requested = [
23
- ...new Set([...(request.agents ?? []), ...(request.computers ?? [])]),
23
+ ...new Set([
24
+ ...(request.agents ?? []),
25
+ ...(request.computers ?? []),
26
+ ...(request.git ?? []),
27
+ ...(request.workflows ?? []),
28
+ ...(request.events ?? []),
29
+ ...(request.generation ?? []),
30
+ ]),
24
31
  ];
25
32
  if (requested.some((capability) => !facts.declaration.capabilities.includes(capability)))
26
33
  return { kind: "refused", code: "not_declared" };
package/dist/auth.d.ts CHANGED
@@ -2,6 +2,8 @@ import type { OysterAuth } from "./host.js";
2
2
  import type { OysterKeyStore } from "./keys.js";
3
3
  /** Cookie emitted by ownerKeyAuth, for composing credential-specific adapters. */
4
4
  export declare const ownerKeyCookieName = "oyster_session";
5
+ /** Marks a browser that has signed in here before; it carries no authority. */
6
+ export declare const returningCookieName = "oyster_returning";
5
7
  /**
6
8
  * Single-owner sign-in: a bearer token or a session cookie holding the
7
9
  * owner key's digest. The key itself is never stored in the browser.
package/dist/auth.js CHANGED
@@ -4,6 +4,8 @@ import { presentedGitKey } from "./git-auth.js";
4
4
  import { sha256 } from "./release.js";
5
5
  /** Cookie emitted by ownerKeyAuth, for composing credential-specific adapters. */
6
6
  export const ownerKeyCookieName = "oyster_session";
7
+ /** Marks a browser that has signed in here before; it carries no authority. */
8
+ export const returningCookieName = "oyster_returning";
7
9
  const loginFormSchema = Schema.Struct({ key: Schema.String });
8
10
  /** Compare two secrets through their fixed-length digests, in constant time. */
9
11
  async function constantTimeEqual(a, b) {
@@ -56,17 +58,16 @@ export function ownerKeyAuth(ownerKey, ownerId = "owner") {
56
58
  });
57
59
  if (fields === null)
58
60
  return new Response("Expected a sign-in form", { status: 400 });
59
- const form = Schema.decodeUnknownOption(loginFormSchema)(Object.fromEntries(fields));
61
+ const form = Schema.decodeUnknownOption(loginFormSchema)({
62
+ key: fields.get("key"),
63
+ });
60
64
  if (Option.isNone(form) ||
61
65
  !(await constantTimeEqual(form.value.key, ownerKey)))
62
66
  return new Response("Wrong key", { status: 401 });
63
- return new Response(null, {
64
- status: 303,
65
- headers: {
66
- Location: "/",
67
- "Set-Cookie": `${ownerKeyCookieName}=${await sessionValue}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=2592000`,
68
- },
69
- });
67
+ const headers = new Headers({ Location: "/" });
68
+ headers.append("Set-Cookie", `${ownerKeyCookieName}=${await sessionValue}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=2592000`);
69
+ headers.append("Set-Cookie", `${returningCookieName}=1; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=31536000`);
70
+ return new Response(null, { status: 303, headers });
70
71
  },
71
72
  };
72
73
  }