@fungi.computer/shiitake 0.1.0 → 0.2.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.
@@ -36,16 +36,11 @@ export type AgentControlDirectory = Readonly<{
36
36
  list: (signal: AbortSignal) => Promise<readonly AgentControlAgent[]>;
37
37
  /** Follow-up delegation with durable replies to the invoking Session. */
38
38
  send?: (input: AgentDelegationInput, sourceSessionId: string, signal: AbortSignal, invocation?: AgentDelegationInvocation) => Promise<Accepted>;
39
- /**
40
- * Present only when this host authorizes ordinary Agent creation. `invoker`
41
- * names the Session whose run asked, so a host can record provenance.
42
- */
39
+ /** Present only when this host authorizes ordinary Agent creation. */
43
40
  create?: (input: Readonly<{
44
41
  requestId: string;
45
42
  model?: ModelPreference;
46
- }>, signal: AbortSignal, invoker?: Readonly<{
47
- sessionId: string;
48
- }>) => Promise<AgentControlAgent>;
43
+ }>, signal: AbortSignal) => Promise<AgentControlAgent>;
49
44
  /** Present only when the host authorizes changing an Agent's future default. */
50
45
  setModel?: (input: Readonly<{
51
46
  agentId: string;
@@ -235,7 +235,7 @@ function admitModelRefusal(operation, cause) {
235
235
  /** Compose one authorized Agent-control projection for a single run lease. */
236
236
  export function createAgentControlSource(directory) {
237
237
  const create = directory.create;
238
- const createOperation = (session) => create === undefined
238
+ const createOperation = create === undefined
239
239
  ? undefined
240
240
  : Mycelium.operation({
241
241
  replay: "unsafe",
@@ -244,10 +244,9 @@ export function createAgentControlSource(directory) {
244
244
  output: agentOutput,
245
245
  execute: async ({ requestId, model }, context) => agentOutput.parse(await create(model === undefined
246
246
  ? { requestId }
247
- : { requestId, model: parseModelAddress(model) }, context.signal, session === undefined
248
- ? undefined
249
- : { sessionId: session.sessionId }).catch((cause) => admitModelRefusal("create", cause))),
247
+ : { requestId, model: parseModelAddress(model) }, context.signal).catch((cause) => admitModelRefusal("create", cause))),
250
248
  });
249
+ const createOperations = createOperation === undefined ? {} : { create: createOperation };
251
250
  const setModel = directory.setModel;
252
251
  const modelOperations = setModel === undefined
253
252
  ? {}
@@ -288,8 +287,6 @@ export function createAgentControlSource(directory) {
288
287
  acquire: ({ signal, session }) => {
289
288
  signal.throwIfAborted();
290
289
  const sends = new WeakMap();
291
- const created = createOperation(session);
292
- const createOperations = created === undefined ? {} : { create: created };
293
290
  return Promise.resolve({
294
291
  snapshot: {
295
292
  version: "shiitake-agent-control-v6",
package/dist/fleet.d.ts CHANGED
@@ -20,7 +20,7 @@ export declare const agentActionSchema: z.ZodEnum<{
20
20
  /** One host-admitted fleet operation. */
21
21
  export type AgentAction = z.infer<typeof agentActionSchema>;
22
22
  /** Attribution supplied by the admitting host, without Team semantics. */
23
- export declare const agentProvenanceSchema: z.ZodObject<{
23
+ export declare const agentProvenanceSchema: z.ZodLazy<z.ZodObject<{
24
24
  actor: z.ZodString;
25
25
  workflowRunId: z.ZodOptional<z.ZodString>;
26
26
  toolCallInputDigest: z.ZodOptional<z.ZodString>;
@@ -28,9 +28,9 @@ export declare const agentProvenanceSchema: z.ZodObject<{
28
28
  agentId: z.ZodString;
29
29
  sessionId: z.ZodString;
30
30
  }, z.core.$strict>>;
31
- }, z.core.$strict>;
31
+ }, z.core.$strict>>;
32
32
  /** Fleet authority is supplied, never looked up in host policy. */
33
- export declare const agentGrantSchema: z.ZodObject<{
33
+ export declare const agentGrantSchema: z.ZodLazy<z.ZodObject<{
34
34
  agents: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
35
35
  actions: z.ZodArray<z.ZodEnum<{
36
36
  send: "send";
@@ -40,7 +40,7 @@ export declare const agentGrantSchema: z.ZodObject<{
40
40
  delegate: "delegate";
41
41
  }>>;
42
42
  expiresAt: z.ZodNumber;
43
- provenance: z.ZodObject<{
43
+ provenance: z.ZodLazy<z.ZodObject<{
44
44
  actor: z.ZodString;
45
45
  workflowRunId: z.ZodOptional<z.ZodString>;
46
46
  toolCallInputDigest: z.ZodOptional<z.ZodString>;
@@ -48,10 +48,10 @@ export declare const agentGrantSchema: z.ZodObject<{
48
48
  agentId: z.ZodString;
49
49
  sessionId: z.ZodString;
50
50
  }, z.core.$strict>>;
51
- }, z.core.$strict>;
51
+ }, z.core.$strict>>;
52
52
  meta: z.ZodOptional<z.ZodJSONSchema>;
53
53
  maxDepth: z.ZodOptional<z.ZodNumber>;
54
- }, z.core.$strict>;
54
+ }, z.core.$strict>>;
55
55
  /** A trusted host's bounded, addressed authority for fleet operations. */
56
56
  export type AgentGrant = z.infer<typeof agentGrantSchema>;
57
57
  /** A committed directory transition, returned in the host's transaction. */
@@ -74,17 +74,17 @@ export declare const agentIds: Readonly<{
74
74
  /** An ordinary Agent directory identity. */
75
75
  export type AgentId = CairnId<"agent", "agent">;
76
76
  /** Stable replay input; configuration is an opaque host creation choice. */
77
- export declare const agentCreationSchema: z.ZodObject<{
77
+ export declare const agentCreationSchema: z.ZodLazy<z.ZodObject<{
78
78
  name: z.ZodString;
79
79
  requestId: z.ZodString;
80
80
  configuration: z.ZodString;
81
- }, z.core.$strict>;
81
+ }, z.core.$strict>>;
82
82
  /** One idempotent directory reservation. */
83
83
  export type AgentCreation = z.infer<typeof agentCreationSchema>;
84
84
  /** Owner-only rename input: an Agent's new display name. */
85
- export declare const agentRenameSchema: z.ZodObject<{
85
+ export declare const agentRenameSchema: z.ZodLazy<z.ZodObject<{
86
86
  name: z.ZodString;
87
- }, z.core.$strict>;
87
+ }, z.core.$strict>>;
88
88
  /** Input to {@link createAgentDirectory}'s `rename`. */
89
89
  export type AgentRename = z.infer<typeof agentRenameSchema>;
90
90
  /** One durable Agent directory record. */
@@ -154,12 +154,12 @@ export declare function createAgentDirectory(sql: WatchdogSqliteOwner["sql"]): {
154
154
  erasureRosterComplete: () => boolean;
155
155
  };
156
156
  /** Replay identity and work, with the parent supplied exclusively by the grant. */
157
- export declare const agentDelegationTaskSchema: z.ZodObject<{
157
+ export declare const agentDelegationTaskSchema: z.ZodLazy<z.ZodObject<{
158
158
  requestId: z.ZodString;
159
159
  agentId: z.ZodString;
160
160
  sessionId: z.ZodOptional<z.ZodString>;
161
161
  text: z.ZodString;
162
- }, z.core.$strict>;
162
+ }, z.core.$strict>>;
163
163
  /** A caller reuses this task unchanged while polling Pending. */
164
164
  export type AgentDelegationTask = z.infer<typeof agentDelegationTaskSchema>;
165
165
  /** Exact host facts encoded over internal transports, without transcript content. */
@@ -231,17 +231,6 @@ export declare function delegationSendMeta(sender: FungiAuthor, invocationMeta?:
231
231
  * its author, and the verified reply rides beside the caller's own path.
232
232
  */
233
233
  export declare function delegationReplyMeta(delegation: AuthenticatedDelegationReply, replierName: string): DelegationReplyMeta;
234
- /** One Agent a Session sent work to: its latest addressed conversation. */
235
- export type FleetRecipient = Readonly<{
236
- agentId: string;
237
- sessionId: string;
238
- sentAt: number;
239
- }>;
240
- /** A bounded page of recipients and how many more exist past it. */
241
- export type FleetRecipients = Readonly<{
242
- recipients: readonly FleetRecipient[];
243
- more: number;
244
- }>;
245
234
  /**
246
235
  * Hosted BirdDog submission and Pending observation. The durable row freezes
247
236
  * correspondence before transport; an ambiguous delivery reuses that exact mail.
@@ -250,11 +239,6 @@ export type FleetRecipients = Readonly<{
250
239
  export declare function createFleetDelegation(options: FleetDelegationOptions): {
251
240
  /** Authenticate a reply against its frozen mail and restore the caller's path. */
252
241
  authenticateReply: (mail: BirdDogMail) => AuthenticatedDelegationReply | undefined;
253
- /** One grouped read of the Agents a parent Session sent work to. */
254
- recipients: (parent: Readonly<{
255
- agentId: string;
256
- sessionId: string;
257
- }>, limit: number) => FleetRecipients;
258
242
  /** Submit once and return the existing Shiitake admission receipt. */
259
243
  start: (grant: AgentGrant, raw: AgentDelegationTask) => Promise<Accepted>;
260
244
  /** Submit or poll the exact turn, yielding Agar Pending until settled. */
package/dist/fleet.js CHANGED
@@ -18,7 +18,7 @@ export const agentActionSchema = z.enum([
18
18
  "delegate",
19
19
  ]);
20
20
  /** Attribution supplied by the admitting host, without Team semantics. */
21
- export const agentProvenanceSchema = z.strictObject({
21
+ export const agentProvenanceSchema = z.lazy(() => z.strictObject({
22
22
  actor: identity,
23
23
  workflowRunId: identity.optional(),
24
24
  /** Host fingerprint of the enclosing model program, frozen with replay input. */
@@ -29,9 +29,9 @@ export const agentProvenanceSchema = z.strictObject({
29
29
  session: z
30
30
  .strictObject({ agentId: identity, sessionId: identity })
31
31
  .optional(),
32
- });
32
+ }));
33
33
  /** Fleet authority is supplied, never looked up in host policy. */
34
- export const agentGrantSchema = z.strictObject({
34
+ export const agentGrantSchema = z.lazy(() => z.strictObject({
35
35
  agents: z.union([z.literal("all"), z.array(identity)]),
36
36
  actions: z.array(agentActionSchema).max(5),
37
37
  expiresAt: z.number().int().nonnegative(),
@@ -39,7 +39,7 @@ export const agentGrantSchema = z.strictObject({
39
39
  meta: z.json().optional(),
40
40
  /** Delegation abuse bound; inherited paths may only narrow it. */
41
41
  maxDepth: z.number().int().min(1).max(8).optional(),
42
- });
42
+ }));
43
43
  /** Refusal of supplied authority; no host policy lookup is performed. */
44
44
  export class AgentGrantError extends Error {
45
45
  reason;
@@ -67,30 +67,30 @@ export const agentIds = defineIdFamily({
67
67
  version: 1,
68
68
  kinds: { agent: { prefix: "agent" } },
69
69
  });
70
- const agentRowSchema = z.strictObject({
70
+ const agentRowSchema = z.lazy(() => z.strictObject({
71
71
  agent_id: z.string(),
72
72
  name: z.string(),
73
73
  actor_user_id: z.string(),
74
74
  created_at: z.number().int().nonnegative(),
75
75
  updated_at: z.number().int().nonnegative(),
76
- });
77
- const receiptRowSchema = z.strictObject({
76
+ }));
77
+ const receiptRowSchema = z.lazy(() => z.strictObject({
78
78
  request_id: z.string(),
79
79
  actor_user_id: z.string(),
80
80
  name: z.string(),
81
81
  agent_id: z.string(),
82
82
  computer_mode: z.string().min(1).max(4096),
83
- });
83
+ }));
84
84
  /** Stable replay input; configuration is an opaque host creation choice. */
85
- export const agentCreationSchema = z.strictObject({
85
+ export const agentCreationSchema = z.lazy(() => z.strictObject({
86
86
  name: z.string().min(1).max(256),
87
87
  requestId: z.string().min(1).max(256),
88
88
  configuration: z.string().min(1).max(4096),
89
- });
89
+ }));
90
90
  /** Owner-only rename input: an Agent's new display name. */
91
- export const agentRenameSchema = z.strictObject({
91
+ export const agentRenameSchema = z.lazy(() => z.strictObject({
92
92
  name: z.string().min(1).max(256),
93
- });
93
+ }));
94
94
  /** Directory input, replay or storage refusal. */
95
95
  export class DirectoryError extends Error {
96
96
  status;
@@ -247,7 +247,7 @@ export function createAgentDirectory(sql) {
247
247
  };
248
248
  }
249
249
  /** Replay identity and work, with the parent supplied exclusively by the grant. */
250
- export const agentDelegationTaskSchema = z.strictObject({
250
+ export const agentDelegationTaskSchema = z.lazy(() => z.strictObject({
251
251
  requestId: identity,
252
252
  agentId: identity,
253
253
  sessionId: identity.optional(),
@@ -255,7 +255,7 @@ export const agentDelegationTaskSchema = z.strictObject({
255
255
  .string()
256
256
  .min(1)
257
257
  .max(256 * 1024),
258
- });
258
+ }));
259
259
  /** Exact host facts encoded over internal transports, without transcript content. */
260
260
  export const commandSettlementSchema = Schema.Struct({
261
261
  terminal: SessionTerminalSchema,
@@ -318,18 +318,12 @@ export function delegationReplyMeta(delegation, replierName) {
318
318
  const delegationMetadata = z.object({
319
319
  delegation: FungiMessageMetaSchema.shape.delegation,
320
320
  });
321
- const delegationRowSchema = z.strictObject({
321
+ const delegationRowSchema = z.lazy(() => z.strictObject({
322
322
  input: z.string(),
323
323
  mail: z.string(),
324
324
  receipt: z.string().nullable(),
325
- });
325
+ }));
326
326
  const decodeMail = Schema.decodeUnknownSync(Schema.fromJsonString(BirdDogMailSchema));
327
- const recipientRowSchema = z.strictObject({
328
- agent_id: identity,
329
- session_id: identity,
330
- sent_at: z.number().int().nonnegative(),
331
- total: z.number().int().nonnegative(),
332
- });
333
327
  /**
334
328
  * Hosted BirdDog submission and Pending observation. The durable row freezes
335
329
  * correspondence before transport; an ambiguous delivery reuses that exact mail.
@@ -470,28 +464,9 @@ export function createFleetDelegation(options) {
470
464
  reply,
471
465
  };
472
466
  }
473
- /**
474
- * The distinct Agents one parent Session sent work to, newest send first,
475
- * with how many more exist past `limit`. Read-only over the frozen mail.
476
- */
477
- function recipients(parent, limit) {
478
- const rows = store
479
- .recipients(parent.agentId, parent.sessionId, limit)
480
- .map((row) => recipientRowSchema.parse(row));
481
- return {
482
- recipients: rows.map((row) => ({
483
- agentId: row.agent_id,
484
- sessionId: row.session_id,
485
- sentAt: row.sent_at,
486
- })),
487
- more: Math.max(0, (rows[0]?.total ?? 0) - rows.length),
488
- };
489
- }
490
467
  return {
491
468
  /** Authenticate a reply against its frozen mail and restore the caller's path. */
492
469
  authenticateReply,
493
- /** One grouped read of the Agents a parent Session sent work to. */
494
- recipients,
495
470
  /** Submit once and return the existing Shiitake admission receipt. */
496
471
  start,
497
472
  /** Submit or poll the exact turn, yielding Agar Pending until settled. */
@@ -27,10 +27,6 @@ export declare function createFleetDelegationStore(storage: WatchdogSqliteOwner)
27
27
  read: (requestId: string) => {
28
28
  readonly [x: string]: string | number | ArrayBuffer | null;
29
29
  } | undefined;
30
- /** Distinct addressed Agents of one parent Session, newest send first. */
31
- recipients: (parentAgentId: string, parentSessionId: string, limit: number) => readonly {
32
- readonly [x: string]: string | number | ArrayBuffer | null;
33
- }[];
34
30
  reserve(requestId: string, input: string, mail: string): void;
35
31
  recordReceipt(requestId: string, receipt: string): void;
36
32
  };
@@ -70,22 +70,15 @@ export function createFleetDirectoryStore(sql) {
70
70
  return row?.complete === 1;
71
71
  }
72
72
  }
73
- const fromAgent = "json_extract(mail, '$.from.agentId')";
74
- const fromSession = "json_extract(mail, '$.from.sessionId')";
75
73
  /** Durable correspondence is frozen before delivery; retries reuse the same row. */
76
74
  export function createFleetDelegationStore(storage) {
77
75
  storage.sql.exec(`CREATE TABLE IF NOT EXISTS shiitake_fleet_delegations (
78
76
  request_id TEXT PRIMARY KEY, input TEXT NOT NULL, mail TEXT NOT NULL, receipt TEXT
79
77
  ) STRICT`);
80
- storage.sql.exec(`CREATE INDEX IF NOT EXISTS idx_shiitake_fleet_delegations_parent ON shiitake_fleet_delegations(${fromAgent}, ${fromSession})`);
81
78
  return {
82
79
  read: (requestId) => storage.sql
83
80
  .exec("SELECT input, mail, receipt FROM shiitake_fleet_delegations WHERE request_id = ?", requestId)
84
81
  .toArray()[0],
85
- /** Distinct addressed Agents of one parent Session, newest send first. */
86
- recipients: (parentAgentId, parentSessionId, limit) => storage.sql
87
- .exec(`SELECT json_extract(mail, '$.to.agentId') AS agent_id, json_extract(mail, '$.to.sessionId') AS session_id, MAX(json_extract(mail, '$.createdAt')) AS sent_at, COUNT(*) OVER () AS total FROM shiitake_fleet_delegations WHERE ${fromAgent} = ? AND ${fromSession} = ? GROUP BY agent_id ORDER BY sent_at DESC, agent_id LIMIT ?`, parentAgentId, parentSessionId, limit)
88
- .toArray(),
89
82
  reserve(requestId, input, mail) {
90
83
  storage.transactionSync(() => {
91
84
  storage.sql.exec("INSERT OR IGNORE INTO shiitake_fleet_delegations(request_id, input, mail) VALUES (?, ?, ?)", requestId, input, mail);
@@ -72,7 +72,7 @@ Host-only identity and admitted command metadata for one delegated send.
72
72
  type AgentControlDirectory = Readonly<{
73
73
  list: (signal) => Promise<readonly AgentControlAgent[]>;
74
74
  send?: (input, sourceSessionId, signal, invocation?) => Promise<Accepted>;
75
- create?: (input, signal, invoker?) => Promise<AgentControlAgent>;
75
+ create?: (input, signal) => Promise<AgentControlAgent>;
76
76
  setModel?: (input, signal) => Promise<void>;
77
77
  models?: (signal) => Promise<readonly AgentControlModel[]>;
78
78
  checkModel?: (input, signal) => Promise<void>;
package/docs/api/fleet.md CHANGED
@@ -303,33 +303,6 @@ The host metadata on one authenticated reply line, as JSON.
303
303
 
304
304
  ---
305
305
 
306
- ### FleetRecipient
307
-
308
- ```ts
309
- type FleetRecipient = Readonly<{
310
- agentId: string;
311
- sessionId: string;
312
- sentAt: number;
313
- }>;
314
- ```
315
-
316
- One Agent a Session sent work to: its latest addressed conversation.
317
-
318
- ---
319
-
320
- ### FleetRecipients
321
-
322
- ```ts
323
- type FleetRecipients = Readonly<{
324
- recipients: readonly FleetRecipient[];
325
- more: number;
326
- }>;
327
- ```
328
-
329
- A bounded page of recipients and how many more exist past it.
330
-
331
- ---
332
-
333
306
  ### FleetAgentAccess
334
307
 
335
308
  ```ts
@@ -702,7 +675,6 @@ Shiitake owns work deduplication, execution and settlement; Post owns replies.
702
675
  | Name | Type | Description |
703
676
  | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
704
677
  | `authenticateReply()` | (`mail`) => \| `Readonly`\<\{ `ancestors`: readonly `string`[]; `maxDepth`: `number`; `reply`: \{ `commandId`: `string`; `outcome`: `"completed"` \| `"failed"` \| `"cancelled"` \| `"interrupted"` \| `"outcome_unknown"`; `diagnostic?`: `string`; `agentId`: `string`; `sessionId`: `string`; \}; \}\> \| `undefined` | Authenticate a reply against its frozen mail and restore the caller's path. Authenticate one arriving reply against the frozen mail this owner sent. It must be BirdDog's single reply key for that mail, mirror its sender and recipient exactly, carry BirdDog's settlement facts and, once the send's receipt is recorded, name that receipt's `commandId`. The result restores the caller's own delegation path and the verified reply; it never reads the reply's text or any settlement metadata. |
705
- | `recipients()` | (`parent`, `limit`) => [`FleetRecipients`](#fleetrecipients) | One grouped read of the Agents a parent Session sent work to. The distinct Agents one parent Session sent work to, newest send first, with how many more exist past `limit`. Read-only over the frozen mail. |
706
678
  | `start()` | (`grant`, `raw`) => `Promise`\<`Readonly`\<\{ `status`: `"accepted"`; `commandId`: `string`; \}\>\> | Submit once and return the existing Shiitake admission receipt. |
707
679
  | `delegate()` | (`grant`, `task`) => `Promise`\< \| `Readonly`\<\{ `kind`: `"pending"`; `retryAfterMs`: `number`; \}\> \| [`AgentDelegationOutcome`](#agentdelegationoutcome)\> | Submit or poll the exact turn, yielding Agar Pending until settled. |
708
680
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Effect-native durable Session acceptance and bounded run orchestration",
6
6
  "type": "module",
@@ -76,16 +76,16 @@
76
76
  "dependencies": {
77
77
  "@fungi.computer/bird-dog": "0.0.1",
78
78
  "@fungi.computer/cairn": "0.0.1",
79
- "@fungi.computer/knapsack": "0.0.2",
79
+ "@fungi.computer/knapsack": "0.1.0",
80
80
  "@fungi.computer/mule": "0.0.2",
81
- "@fungi.computer/mycelium": "0.0.2",
81
+ "@fungi.computer/mycelium": "0.1.0",
82
82
  "@fungi.computer/watchdog": "0.0.1",
83
83
  "effect": "4.0.2",
84
84
  "hono": "4.13.5",
85
85
  "zod": "4.4.3",
86
86
  "@earendil-works/pi-ai": "0.99.2",
87
- "@fungi.computer/gills": "0.0.1",
88
- "@fungi.computer/agar": "0.1.0"
87
+ "@fungi.computer/gills": "0.1.0",
88
+ "@fungi.computer/agar": "0.2.0"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@cloudflare/workers-types": "5.20260828.1",