@fungi.computer/oyster 0.16.0 → 0.18.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/dist/agents.d.ts CHANGED
@@ -7,6 +7,8 @@ import * as Schema from "effect/Schema";
7
7
  import { type OysterCapability, type OysterEnv } from "./host.js";
8
8
  import type { HostActor } from "@fungi.computer/puffball/app";
9
9
  import type { Avatar } from "@fungi.computer/sprite/avatar";
10
+ import type { StarterOutcome } from "./starter-agent.js";
11
+ export type { StarterOutcome };
10
12
  import type { AgentModelChoice, AgentModelRefusal } from "./standalone/agent-model-choice.js";
11
13
  export type { AgentModelChoice, AgentModelRefusal, } from "./standalone/agent-model-choice.js";
12
14
  import type { MemberInboxItem, MemberInboxSession } from "@fungi.computer/puffball/inbox";
@@ -104,6 +106,11 @@ export type OysterAgents = Readonly<{
104
106
  list(options?: Readonly<{
105
107
  archived?: boolean;
106
108
  }>): Promise<readonly OysterAgent[]>;
109
+ /**
110
+ * Offer the owner their starter Agent on an empty Team's first owner read;
111
+ * it creates through this host's ordinary `create` and never fails the read.
112
+ */
113
+ ensureStarter(principal: TenantPrincipal): Promise<StarterOutcome>;
107
114
  /** Owner-only HTTP transition; creator Agents use their own control tool. */
108
115
  setArchived(agentId: string, archived: boolean, principal: TenantPrincipal): Promise<Readonly<{
109
116
  archived: boolean;
package/dist/agents.js CHANGED
@@ -185,12 +185,15 @@ function createAgentRoutes(agents) {
185
185
  .include(ownerAgentRoutes(agents, "direct-or-app"))
186
186
  // Standalone Agents choose no Computer at creation; the owner attaches one.
187
187
  .get("/agent-computers", owner("direct-or-app"), () => Response.json(null))
188
- .get("/agents", agentCollection(), async (context, { reaches }) => {
188
+ .get("/agents", agentCollection(), async (context, { reaches, everyAgent, authority }) => {
189
189
  const selected = context.req.query("archived");
190
190
  if (selected !== undefined &&
191
191
  selected !== "true" &&
192
192
  selected !== "false")
193
193
  return refusal(400, "Choose a valid archive view");
194
+ // The owner's own directory read is the starter Agent's one trigger.
195
+ if (everyAgent && authority.kind === "owner" && selected !== "true")
196
+ await agents.ensureStarter(authority.principal);
194
197
  const listed = await agents.list({ archived: selected === "true" });
195
198
  const reached = [];
196
199
  for (const item of listed)
package/dist/auth.js CHANGED
@@ -2,6 +2,7 @@ import * as Option from "effect/Option";
2
2
  import * as Schema from "effect/Schema";
3
3
  import { presentedGitKey } from "./git-auth.js";
4
4
  import { sha256 } from "./release.js";
5
+ import { isLoopbackHttp } from "./tenancy/registry-record.js";
5
6
  /** Cookie emitted by ownerKeyAuth, for composing credential-specific adapters. */
6
7
  export const ownerKeyCookieName = "oyster_session";
7
8
  /** Marks a browser that has signed in here before; it carries no authority. */
@@ -64,9 +65,12 @@ export function ownerKeyAuth(ownerKey, ownerId = "owner") {
64
65
  if (Option.isNone(form) ||
65
66
  !(await constantTimeEqual(form.value.key, ownerKey)))
66
67
  return new Response("Wrong key", { status: 401 });
68
+ // Secure everywhere except loopback HTTP, where Safari would drop it and
69
+ // the traffic never leaves this machine.
70
+ const secure = isLoopbackHttp(new URL(request.url)) ? "" : " Secure;";
67
71
  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`);
72
+ headers.append("Set-Cookie", `${ownerKeyCookieName}=${await sessionValue}; Path=/; HttpOnly;${secure} SameSite=Strict; Max-Age=2592000`);
73
+ headers.append("Set-Cookie", `${returningCookieName}=1; Path=/; HttpOnly;${secure} SameSite=Strict; Max-Age=31536000`);
70
74
  return new Response(null, { status: 303, headers });
71
75
  },
72
76
  };