@fungi.computer/shiitake-extensions 0.11.23 → 0.12.1

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.
@@ -0,0 +1,9 @@
1
+ /** One shared footer for Grove and the terminal, over committed Session state. */
2
+ declare const _default: Readonly<{
3
+ protocol: "shiitake.client/v1";
4
+ id: import("@fungi.computer/shiitake/extensions").ExtensionId;
5
+ promptPresentation?: "footer";
6
+ attach?: (context: import("@fungi.computer/shiitake/client-entry").ClientExtensionContextV1) => import("effect/Effect").Effect<void, Error, import("effect/Scope").Scope>;
7
+ contribute?: (slot: import("@fungi.computer/shiitake").ExtensionSlotV0 | undefined) => import("@fungi.computer/shiitake/client-entry").ClientContributionV1;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,95 @@
1
+ import { defineClientEntry } from "@fungi.computer/shiitake/client-entry";
2
+ import * as Cron from "effect/Cron";
3
+ import * as Result from "effect/Result";
4
+ import { almanacContract } from "./contract.js";
5
+ /** Effect owns cron syntax; only common normalized cadences get shorter copy. */
6
+ function cadence(schedule) {
7
+ if (schedule.cron === null)
8
+ return "Once";
9
+ const parsed = Cron.parse(schedule.cron.expression, schedule.cron.timeZone);
10
+ if (Result.isFailure(parsed))
11
+ return schedule.cron.expression;
12
+ const cron = parsed.success;
13
+ if (cron.days.size === 0 &&
14
+ cron.months.size === 0 &&
15
+ cron.seconds.size === 1 &&
16
+ cron.seconds.has(0) &&
17
+ cron.hours.size === 1 &&
18
+ cron.minutes.size === 1) {
19
+ const time = `${String([...cron.hours][0]).padStart(2, "0")}:${String([...cron.minutes][0]).padStart(2, "0")}`;
20
+ if (cron.weekdays.size === 0 || cron.weekdays.size === 7)
21
+ return `Every day ${time}`;
22
+ if (cron.weekdays.size === 5 &&
23
+ [1, 2, 3, 4, 5].every((day) => cron.weekdays.has(day)))
24
+ return `Every weekday ${time}`;
25
+ }
26
+ return schedule.cron.expression;
27
+ }
28
+ function due(schedule) {
29
+ return new Intl.DateTimeFormat(undefined, {
30
+ weekday: "short",
31
+ month: "short",
32
+ day: "numeric",
33
+ hour: "2-digit",
34
+ minute: "2-digit",
35
+ hourCycle: "h23",
36
+ timeZone: schedule.cron?.timeZone,
37
+ timeZoneName: "short",
38
+ }).format(schedule.nextDueAt);
39
+ }
40
+ /** One shared footer for Grove and the terminal, over committed Session state. */
41
+ export default defineClientEntry(almanacContract, {
42
+ contribute: (view) => ({
43
+ chips: [],
44
+ panel: view.status !== "running" || view.value === null
45
+ ? []
46
+ : [
47
+ ...view.value.schedules
48
+ .filter((schedule) => schedule.state === "active" || schedule.state === "paused")
49
+ .map((schedule) => ({
50
+ id: schedule.id,
51
+ title: `${cadence(schedule)} · ${schedule.state === "paused" ? "paused" : `next ${due(schedule)}`}`,
52
+ detail: [
53
+ schedule.prompt,
54
+ schedule.cron?.timeZone ?? null,
55
+ schedule.lastError,
56
+ ]
57
+ .filter((part) => part !== null)
58
+ .join("\n")
59
+ .slice(0, 1024),
60
+ tone: schedule.lastError !== null
61
+ ? "error"
62
+ : schedule.state === "paused"
63
+ ? "muted"
64
+ : "running",
65
+ actions: [
66
+ {
67
+ id: schedule.state === "paused"
68
+ ? "resumeSchedule"
69
+ : "pauseSchedule",
70
+ label: schedule.state === "paused" ? "Resume" : "Pause",
71
+ input: {
72
+ scheduleId: schedule.id,
73
+ },
74
+ },
75
+ {
76
+ id: "cancelSchedule",
77
+ label: "Cancel",
78
+ input: { scheduleId: schedule.id },
79
+ },
80
+ ],
81
+ })),
82
+ ...(view.value.more === 0
83
+ ? []
84
+ : [
85
+ {
86
+ id: "more schedules",
87
+ title: `${String(view.value.more)} more schedules — ask the Agent to list them`,
88
+ tone: "muted",
89
+ },
90
+ ]),
91
+ ],
92
+ timeline: { cells: [], omitted: 0 },
93
+ waiting: null,
94
+ }),
95
+ });
@@ -1,11 +1,67 @@
1
1
  import * as Schema from "effect/Schema";
2
2
  export { Schedule } from "./schema.js";
3
- /** Almanac's contract: agent-scope schedule CRUD, no Session projection. */
3
+ /** A bounded conversation footer, with explicit overflow rather than silent loss. */
4
+ export declare const AlmanacProjection: Schema.Struct<{
5
+ /** Active and paused schedules addressed to this Session. */
6
+ readonly schedules: Schema.$Array<Schema.Struct<{
7
+ readonly id: Schema.String;
8
+ readonly sessionId: Schema.String;
9
+ readonly prompt: Schema.String;
10
+ readonly cron: Schema.NullOr<Schema.Struct<{
11
+ readonly expression: Schema.String;
12
+ readonly timeZone: Schema.String;
13
+ }>>;
14
+ readonly nextDueAt: Schema.Int;
15
+ readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
16
+ readonly lastCommandId: Schema.NullOr<Schema.String>;
17
+ readonly lastError: Schema.NullOr<Schema.String>;
18
+ readonly attempt: Schema.Int;
19
+ }>>;
20
+ /** Additional schedules beyond the footer's row budget. */
21
+ readonly more: Schema.Int;
22
+ }>;
23
+ /** Almanac's Agent controls and Session-owned footer. */
4
24
  export declare const almanacContract: {
5
25
  /** Stable extension identity. */
6
26
  readonly id: string & import("effect/Brand").Brand<"ExtensionId">;
7
- /** Agent-scoped schedule operations. */
27
+ /** Agent operations and ownership-checked Session controls. */
8
28
  readonly commands: {
29
+ /** Pause a schedule belonging to the invoking conversation. */
30
+ readonly pauseSchedule: {
31
+ /** A footer cannot control another conversation's schedule. */
32
+ readonly scope: "session";
33
+ /** Exact schedule identity. */
34
+ readonly input: Schema.Struct<{
35
+ /** Existing schedule targeted by the command. */
36
+ readonly scheduleId: Schema.String;
37
+ }>;
38
+ /** Complete the advertised human command. */
39
+ readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
40
+ };
41
+ /** Resume a schedule belonging to the invoking conversation. */
42
+ readonly resumeSchedule: {
43
+ /** A footer cannot control another conversation's schedule. */
44
+ readonly scope: "session";
45
+ /** Exact schedule identity. */
46
+ readonly input: Schema.Struct<{
47
+ /** Existing schedule targeted by the command. */
48
+ readonly scheduleId: Schema.String;
49
+ }>;
50
+ /** Complete the advertised human command. */
51
+ readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
52
+ };
53
+ /** Cancel a schedule belonging to the invoking conversation. */
54
+ readonly cancelSchedule: {
55
+ /** A footer cannot control another conversation's schedule. */
56
+ readonly scope: "session";
57
+ /** Exact schedule identity. */
58
+ readonly input: Schema.Struct<{
59
+ /** Existing schedule targeted by the command. */
60
+ readonly scheduleId: Schema.String;
61
+ }>;
62
+ /** Complete the advertised human command. */
63
+ readonly output: Schema.declare<import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1, import("@fungi.computer/whistle/catalog").WhistleCatalogStepV1>;
64
+ };
9
65
  /** Create a schedule with one due occurrence. */
10
66
  readonly createOneShot: {
11
67
  /** The Agent owns the schedule collection. */
@@ -196,6 +252,27 @@ export declare const almanacContract: {
196
252
  }>;
197
253
  };
198
254
  };
199
- /** Almanac has no Session projection. */
200
- readonly projection: null;
255
+ /** Schedules visible in their originating conversation. */
256
+ readonly projection: {
257
+ /** Decoder shared with the footer client. */
258
+ readonly schema: Schema.Struct<{
259
+ /** Active and paused schedules addressed to this Session. */
260
+ readonly schedules: Schema.$Array<Schema.Struct<{
261
+ readonly id: Schema.String;
262
+ readonly sessionId: Schema.String;
263
+ readonly prompt: Schema.String;
264
+ readonly cron: Schema.NullOr<Schema.Struct<{
265
+ readonly expression: Schema.String;
266
+ readonly timeZone: Schema.String;
267
+ }>>;
268
+ readonly nextDueAt: Schema.Int;
269
+ readonly state: Schema.Literals<readonly ["active", "paused", "cancelled", "finished"]>;
270
+ readonly lastCommandId: Schema.NullOr<Schema.String>;
271
+ readonly lastError: Schema.NullOr<Schema.String>;
272
+ readonly attempt: Schema.Int;
273
+ }>>;
274
+ /** Additional schedules beyond the footer's row budget. */
275
+ readonly more: Schema.Int;
276
+ }>;
277
+ };
201
278
  };
@@ -1,5 +1,6 @@
1
1
  import { ExtensionId } from "@fungi.computer/shiitake/extensions";
2
2
  import * as Schema from "effect/Schema";
3
+ import { CatalogStep } from "../internal/catalog.js";
3
4
  import { Prompt, SessionId } from "../internal/schedule-fields.js";
4
5
  import { ScheduleId, Instant, CronExpression, TimeZone, Schedule, ScheduleListInput, } from "./schema.js";
5
6
  export { Schedule } from "./schema.js";
@@ -12,12 +13,46 @@ const ScheduleRef = Schema.Struct({
12
13
  /** Existing schedule targeted by the command. */
13
14
  scheduleId: ScheduleId,
14
15
  });
15
- /** Almanac's contract: agent-scope schedule CRUD, no Session projection. */
16
+ /** A bounded conversation footer, with explicit overflow rather than silent loss. */
17
+ export const AlmanacProjection = Schema.Struct({
18
+ /** Active and paused schedules addressed to this Session. */
19
+ schedules: Schema.Array(Schedule).check(Schema.isMaxLength(15)),
20
+ /** Additional schedules beyond the footer's row budget. */
21
+ more: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
22
+ });
23
+ /** Almanac's Agent controls and Session-owned footer. */
16
24
  export const almanacContract = {
17
25
  /** Stable extension identity. */
18
26
  id: ExtensionId.make("botanical-almanac"),
19
- /** Agent-scoped schedule operations. */
27
+ /** Agent operations and ownership-checked Session controls. */
20
28
  commands: {
29
+ /** Pause a schedule belonging to the invoking conversation. */
30
+ pauseSchedule: {
31
+ /** A footer cannot control another conversation's schedule. */
32
+ scope: "session",
33
+ /** Exact schedule identity. */
34
+ input: ScheduleRef,
35
+ /** Complete the advertised human command. */
36
+ output: CatalogStep,
37
+ },
38
+ /** Resume a schedule belonging to the invoking conversation. */
39
+ resumeSchedule: {
40
+ /** A footer cannot control another conversation's schedule. */
41
+ scope: "session",
42
+ /** Exact schedule identity. */
43
+ input: ScheduleRef,
44
+ /** Complete the advertised human command. */
45
+ output: CatalogStep,
46
+ },
47
+ /** Cancel a schedule belonging to the invoking conversation. */
48
+ cancelSchedule: {
49
+ /** A footer cannot control another conversation's schedule. */
50
+ scope: "session",
51
+ /** Exact schedule identity. */
52
+ input: ScheduleRef,
53
+ /** Complete the advertised human command. */
54
+ output: CatalogStep,
55
+ },
21
56
  /** Create a schedule with one due occurrence. */
22
57
  createOneShot: {
23
58
  /** The Agent owns the schedule collection. */
@@ -102,6 +137,9 @@ export const almanacContract = {
102
137
  output: Schedule,
103
138
  },
104
139
  },
105
- /** Almanac has no Session projection. */
106
- projection: null,
140
+ /** Schedules visible in their originating conversation. */
141
+ projection: {
142
+ /** Decoder shared with the footer client. */
143
+ schema: AlmanacProjection,
144
+ },
107
145
  };
@@ -8,7 +8,7 @@ import * as Result from "effect/Result";
8
8
  import * as Option from "effect/Option";
9
9
  import { afterAdmitted, afterRefused, cancelled, occurrenceKey, paused, resumed, settled, } from "@fungi.computer/almanac";
10
10
  import { z } from "zod";
11
- import { freshRequestId } from "../internal/catalog.js";
11
+ import { catalog, freshRequestId } from "../internal/catalog.js";
12
12
  import { nextOccurrence } from "../internal/cron.js";
13
13
  import { almanacContract, Schedule } from "./contract.js";
14
14
  /** Hashed policy: every constant Almanac reads comes from here. */
@@ -100,6 +100,44 @@ function cancelSchedule(ctx, scheduleId) {
100
100
  return next;
101
101
  });
102
102
  }
103
+ /** The Agent door and Session footer use the same lifecycle transitions. */
104
+ function pauseSchedule(ctx, scheduleId) {
105
+ return Effect.gen(function* () {
106
+ const schedule = yield* requireSchedule(ctx, scheduleId);
107
+ if (settled(schedule))
108
+ return yield* Effect.fail(rejected("conflict", "A settled schedule cannot be paused"));
109
+ const next = paused(schedule);
110
+ yield* ctx.state.schedules.put(next);
111
+ yield* ctx.timers.cancel(schedule.id);
112
+ return next;
113
+ });
114
+ }
115
+ function resumeSchedule(ctx, scheduleId) {
116
+ return Effect.gen(function* () {
117
+ const schedule = yield* requireSchedule(ctx, scheduleId);
118
+ if (settled(schedule))
119
+ return yield* Effect.fail(rejected("conflict", "A settled schedule cannot be resumed"));
120
+ const now = yield* Clock.currentTimeMillis;
121
+ // A human resume is the retry: it clears the failure and skips
122
+ // recurring occurrences missed while paused.
123
+ const back = resumed(schedule, now);
124
+ if (Result.isFailure(back))
125
+ return yield* Effect.fail(rejected("invalid", back.failure.message));
126
+ yield* ctx.state.schedules.put(back.success);
127
+ yield* ctx.timers.set(schedule.id, back.success.nextDueAt);
128
+ return back.success;
129
+ });
130
+ }
131
+ /** Session controls verify ownership before using the existing Agent transition. */
132
+ function controlSchedule(ctx, sessionId, scheduleId, transition) {
133
+ return Effect.gen(function* () {
134
+ const schedule = yield* requireSchedule(ctx, scheduleId);
135
+ if (schedule.sessionId !== sessionId)
136
+ return yield* Effect.fail(rejected("not_found", "Schedule does not belong to this conversation"));
137
+ yield* transition(ctx, scheduleId);
138
+ return { type: "done" };
139
+ });
140
+ }
103
141
  /**
104
142
  * Send the due occurrence through the door. The occurrence request id is
105
143
  * `id:occurrenceAt`, so a retried admission replays instead of duplicating.
@@ -247,11 +285,55 @@ function scheduleModule(ctx, sessionId) {
247
285
  /** Botanical's Almanac on Shiitake timers and the one admission door. */
248
286
  export const almanacExtension = defineExtension({
249
287
  id: almanacContract.id,
250
- version: "1.2.0",
288
+ version: "1.3.0",
251
289
  })
252
290
  .config(config)
253
291
  .state({ version: 1, migrations: {}, collections })
254
292
  .define({
293
+ catalog: catalog([
294
+ {
295
+ id: "pauseSchedule",
296
+ title: "Pause schedule",
297
+ category: "Conversation",
298
+ description: "Pause a schedule in this conversation",
299
+ },
300
+ {
301
+ id: "resumeSchedule",
302
+ title: "Resume schedule",
303
+ category: "Conversation",
304
+ description: "Resume a schedule in this conversation",
305
+ },
306
+ {
307
+ id: "cancelSchedule",
308
+ title: "Cancel schedule",
309
+ category: "Conversation",
310
+ description: "Cancel a schedule in this conversation",
311
+ },
312
+ ]),
313
+ projection: {
314
+ schema: almanacContract.projection.schema,
315
+ read: (ctx, sessionId) => {
316
+ const schedules = [];
317
+ let more = 0;
318
+ // Use the existing state index: settled rows never crowd out live work.
319
+ for (const index of ["active", "paused"]) {
320
+ let after;
321
+ do {
322
+ const page = ctx.state.schedules.peekPage({
323
+ index,
324
+ after,
325
+ limit: 64,
326
+ });
327
+ const matching = page.filter((schedule) => schedule.sessionId === sessionId);
328
+ const visible = matching.slice(0, 15 - schedules.length);
329
+ schedules.push(...visible);
330
+ more += matching.length - visible.length;
331
+ after = page.length === 64 ? page.at(-1)?.id : undefined;
332
+ } while (after !== undefined);
333
+ }
334
+ return Option.some({ schedules, more });
335
+ },
336
+ },
255
337
  prompt: () => Effect.succeed([{ name: "schedule", text: config.idle }]),
256
338
  tools: (ctx, { sessionId }) => Effect.succeed(Option.some(scheduleModule(ctx, sessionId))),
257
339
  hooks: { onTimer: (ctx, timer) => fire(ctx, timer.key, timer.firedAt) },
@@ -267,29 +349,11 @@ export const almanacExtension = defineExtension({
267
349
  after: input.after,
268
350
  limit: input.limit ?? 64,
269
351
  }),
270
- pause: ({ input }) => Effect.gen(function* () {
271
- const schedule = yield* requireSchedule(ctx, input.scheduleId);
272
- if (settled(schedule))
273
- return yield* Effect.fail(rejected("conflict", "A settled schedule cannot be paused"));
274
- const next = paused(schedule);
275
- yield* ctx.state.schedules.put(next);
276
- yield* ctx.timers.cancel(schedule.id);
277
- return next;
278
- }),
279
- resume: ({ input }) => Effect.gen(function* () {
280
- const schedule = yield* requireSchedule(ctx, input.scheduleId);
281
- if (settled(schedule))
282
- return yield* Effect.fail(rejected("conflict", "A settled schedule cannot be resumed"));
283
- const now = yield* Clock.currentTimeMillis;
284
- // A human resume is the retry: it clears the failure and skips
285
- // recurring occurrences missed while paused.
286
- const back = resumed(schedule, now);
287
- if (Result.isFailure(back))
288
- return yield* Effect.fail(rejected("invalid", back.failure.message));
289
- yield* ctx.state.schedules.put(back.success);
290
- yield* ctx.timers.set(schedule.id, back.success.nextDueAt);
291
- return back.success;
292
- }),
352
+ pause: ({ input }) => pauseSchedule(ctx, input.scheduleId),
353
+ resume: ({ input }) => resumeSchedule(ctx, input.scheduleId),
354
+ pauseSchedule: ({ sessionId, input }) => controlSchedule(ctx, sessionId, input.scheduleId, pauseSchedule),
355
+ resumeSchedule: ({ sessionId, input }) => controlSchedule(ctx, sessionId, input.scheduleId, resumeSchedule),
356
+ cancelSchedule: ({ sessionId, input }) => controlSchedule(ctx, sessionId, input.scheduleId, cancelSchedule),
293
357
  cancel: ({ input }) => cancelSchedule(ctx, input.scheduleId),
294
358
  }),
295
359
  },
package/dist/roster.js CHANGED
@@ -72,6 +72,7 @@ export const botanicalAgentExtensions = Object.freeze({
72
72
  "send",
73
73
  "timers",
74
74
  "commands",
75
+ "projection",
75
76
  "run_tools",
76
77
  "prompt",
77
78
  ],
@@ -10,6 +10,7 @@
10
10
 
11
11
  | Module | Description |
12
12
  | ----------------------------------------------------------- | ----------- |
13
+ | [almanac/client](almanac/client.md) | - |
13
14
  | [almanac/contract](almanac/contract.md) | - |
14
15
  | [almanac/host](almanac/host.md) | - |
15
16
  | [goal/client](goal/client.md) | - |
@@ -0,0 +1,25 @@
1
+ <!-- Generated by Botanical API docs (TypeDoc + typedoc-plugin-markdown). Do not edit. -->
2
+
3
+ [**@fungi.computer/shiitake-extensions**](../README.md)
4
+
5
+ ---
6
+
7
+ [@fungi.computer/shiitake-extensions](../README.md) / almanac/client
8
+
9
+ # almanac/client
10
+
11
+ ## Variables
12
+
13
+ ### default
14
+
15
+ ```ts
16
+ default: Readonly<{
17
+ protocol: "shiitake.client/v1";
18
+ id: string & Brand<"ExtensionId">;
19
+ promptPresentation?: "footer";
20
+ attach?: (context) => Effect<void, Error, Scope>;
21
+ contribute?: (slot) => object;
22
+ }>;
23
+ ```
24
+
25
+ One shared footer for Grove and the terminal, over committed Session state.
@@ -20,49 +20,92 @@ One durable schedule.
20
20
 
21
21
  ## Variables
22
22
 
23
+ ### AlmanacProjection
24
+
25
+ ```ts
26
+ const AlmanacProjection: Struct<{
27
+ schedules: $Array<
28
+ Struct<{
29
+ id: String;
30
+ sessionId: String;
31
+ prompt: String;
32
+ cron: NullOr<
33
+ Struct<{
34
+ expression: String;
35
+ timeZone: String;
36
+ }>
37
+ >;
38
+ nextDueAt: Int;
39
+ state: Literals<readonly ["active", "paused", "cancelled", "finished"]>;
40
+ lastCommandId: NullOr<String>;
41
+ lastError: NullOr<String>;
42
+ attempt: Int;
43
+ }>
44
+ >;
45
+ more: Int;
46
+ }>;
47
+ ```
48
+
49
+ A bounded conversation footer, with explicit overflow rather than silent loss.
50
+
51
+ ---
52
+
23
53
  ### almanacContract
24
54
 
25
55
  ```ts
26
56
  const almanacContract: object;
27
57
  ```
28
58
 
29
- Almanac's contract: agent-scope schedule CRUD, no Session projection.
59
+ Almanac's Agent controls and Session-owned footer.
30
60
 
31
61
  #### Type Declaration
32
62
 
33
- | Name | Type | Default value | Description |
34
- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------------------------------------------------------------ |
35
- | <a id="property-id"></a> `id` | `string` & `Brand`\<`"ExtensionId"`\> | - | Stable extension identity. |
36
- | <a id="property-commands"></a> `commands` | `object` | - | Agent-scoped schedule operations. |
37
- | `commands.createOneShot` | `object` | - | Create a schedule with one due occurrence. |
38
- | `commands.createOneShot.scope` | `"agent"` | `"agent"` | The Agent owns the schedule collection. |
39
- | `commands.createOneShot.input` | `Struct`\<\{ `requestId`: `String`; `sessionId`: `String`; `prompt`: `String`; `dueAt`: `Int`; \}\> | - | Decode the caller's one-shot schedule request. |
40
- | `commands.createOneShot.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return the created durable schedule. |
41
- | `commands.createRecurring` | `object` | - | Create a recurring cron schedule. |
42
- | `commands.createRecurring.scope` | `"agent"` | `"agent"` | The Agent owns the schedule collection. |
43
- | `commands.createRecurring.input` | `Struct`\<\{ `requestId`: `String`; `sessionId`: `String`; `prompt`: `String`; `expression`: `String`; `timeZone`: `String`; \}\> | - | Decode the caller's recurring schedule request. |
44
- | `commands.createRecurring.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return the created durable schedule. |
45
- | `commands.read` | `object` | - | Read one schedule, or null when absent. |
46
- | `commands.read.scope` | `"agent"` | `"agent"` | Read from the Agent's schedule collection. |
47
- | `commands.read.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to read. |
48
- | `commands.read.output` | `NullOr`\<`Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\>\> | - | Decode the schedule or its absence. |
49
- | `commands.list` | `object` | - | Read a bounded page of schedules after an optional identity. |
50
- | `commands.list.scope` | `"agent"` | `"agent"` | Read from the Agent's schedule collection. |
51
- | `commands.list.input` | `Struct`\<\{ `after`: `optionalKey`\<`String`\>; `limit`: `optionalKey`\<`Int`\>; \}\> | `ScheduleListInput` | Decode pagination arguments. |
52
- | `commands.list.output` | `$Array`\<`Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\>\> | - | Decode the returned schedule rows. |
53
- | `commands.pause` | `object` | - | Suspend future occurrences of a schedule. |
54
- | `commands.pause.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
55
- | `commands.pause.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to pause. |
56
- | `commands.pause.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
57
- | `commands.resume` | `object` | - | Restore a paused schedule to active scheduling. |
58
- | `commands.resume.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
59
- | `commands.resume.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to resume. |
60
- | `commands.resume.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
61
- | `commands.cancel` | `object` | - | Cancel future occurrences of a schedule. |
62
- | `commands.cancel.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
63
- | `commands.cancel.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to cancel. |
64
- | `commands.cancel.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
65
- | <a id="property-projection"></a> `projection` | `null` | `null` | Almanac has no Session projection. |
63
+ | Name | Type | Default value | Description |
64
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ------------------------------------------------------------ |
65
+ | <a id="property-id"></a> `id` | `string` & `Brand`\<`"ExtensionId"`\> | - | Stable extension identity. |
66
+ | <a id="property-commands"></a> `commands` | `object` | - | Agent operations and ownership-checked Session controls. |
67
+ | `commands.pauseSchedule` | `object` | - | Pause a schedule belonging to the invoking conversation. |
68
+ | `commands.pauseSchedule.scope` | `"session"` | `"session"` | A footer cannot control another conversation's schedule. |
69
+ | `commands.pauseSchedule.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Exact schedule identity. |
70
+ | `commands.pauseSchedule.output` | `declare`\<`WhistleCatalogStepV1`, `WhistleCatalogStepV1`\> | `CatalogStep` | Complete the advertised human command. |
71
+ | `commands.resumeSchedule` | `object` | - | Resume a schedule belonging to the invoking conversation. |
72
+ | `commands.resumeSchedule.scope` | `"session"` | `"session"` | A footer cannot control another conversation's schedule. |
73
+ | `commands.resumeSchedule.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Exact schedule identity. |
74
+ | `commands.resumeSchedule.output` | `declare`\<`WhistleCatalogStepV1`, `WhistleCatalogStepV1`\> | `CatalogStep` | Complete the advertised human command. |
75
+ | `commands.cancelSchedule` | `object` | - | Cancel a schedule belonging to the invoking conversation. |
76
+ | `commands.cancelSchedule.scope` | `"session"` | `"session"` | A footer cannot control another conversation's schedule. |
77
+ | `commands.cancelSchedule.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Exact schedule identity. |
78
+ | `commands.cancelSchedule.output` | `declare`\<`WhistleCatalogStepV1`, `WhistleCatalogStepV1`\> | `CatalogStep` | Complete the advertised human command. |
79
+ | `commands.createOneShot` | `object` | - | Create a schedule with one due occurrence. |
80
+ | `commands.createOneShot.scope` | `"agent"` | `"agent"` | The Agent owns the schedule collection. |
81
+ | `commands.createOneShot.input` | `Struct`\<\{ `requestId`: `String`; `sessionId`: `String`; `prompt`: `String`; `dueAt`: `Int`; \}\> | - | Decode the caller's one-shot schedule request. |
82
+ | `commands.createOneShot.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return the created durable schedule. |
83
+ | `commands.createRecurring` | `object` | - | Create a recurring cron schedule. |
84
+ | `commands.createRecurring.scope` | `"agent"` | `"agent"` | The Agent owns the schedule collection. |
85
+ | `commands.createRecurring.input` | `Struct`\<\{ `requestId`: `String`; `sessionId`: `String`; `prompt`: `String`; `expression`: `String`; `timeZone`: `String`; \}\> | - | Decode the caller's recurring schedule request. |
86
+ | `commands.createRecurring.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return the created durable schedule. |
87
+ | `commands.read` | `object` | - | Read one schedule, or null when absent. |
88
+ | `commands.read.scope` | `"agent"` | `"agent"` | Read from the Agent's schedule collection. |
89
+ | `commands.read.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to read. |
90
+ | `commands.read.output` | `NullOr`\<`Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\>\> | - | Decode the schedule or its absence. |
91
+ | `commands.list` | `object` | - | Read a bounded page of schedules after an optional identity. |
92
+ | `commands.list.scope` | `"agent"` | `"agent"` | Read from the Agent's schedule collection. |
93
+ | `commands.list.input` | `Struct`\<\{ `after`: `optionalKey`\<`String`\>; `limit`: `optionalKey`\<`Int`\>; \}\> | `ScheduleListInput` | Decode pagination arguments. |
94
+ | `commands.list.output` | `$Array`\<`Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\>\> | - | Decode the returned schedule rows. |
95
+ | `commands.pause` | `object` | - | Suspend future occurrences of a schedule. |
96
+ | `commands.pause.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
97
+ | `commands.pause.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to pause. |
98
+ | `commands.pause.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
99
+ | `commands.resume` | `object` | - | Restore a paused schedule to active scheduling. |
100
+ | `commands.resume.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
101
+ | `commands.resume.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to resume. |
102
+ | `commands.resume.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
103
+ | `commands.cancel` | `object` | - | Cancel future occurrences of a schedule. |
104
+ | `commands.cancel.scope` | `"agent"` | `"agent"` | The Agent owns the schedule. |
105
+ | `commands.cancel.input` | `Struct`\<\{ `scheduleId`: `String`; \}\> | `ScheduleRef` | Identify the schedule to cancel. |
106
+ | `commands.cancel.output` | `Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\> | `Schedule` | Return its updated state. |
107
+ | <a id="property-projection"></a> `projection` | `object` | - | Schedules visible in their originating conversation. |
108
+ | `projection.schema` | `Struct`\<\{ `schedules`: `$Array`\<`Struct`\<\{ `id`: `String`; `sessionId`: `String`; `prompt`: `String`; `cron`: `NullOr`\<`Struct`\<\{ `expression`: `String`; `timeZone`: `String`; \}\>\>; `nextDueAt`: `Int`; `state`: `Literals`\<readonly \[`"active"`, `"paused"`, `"cancelled"`, `"finished"`\]\>; `lastCommandId`: `NullOr`\<`String`\>; `lastError`: `NullOr`\<`String`\>; `attempt`: `Int`; \}\>\>; `more`: `Int`; \}\> | `AlmanacProjection` | Decoder shared with the footer client. |
66
109
 
67
110
  ---
68
111
 
@@ -31,7 +31,7 @@ function readAgentSchedulePage(
31
31
  timeZone: string;
32
32
  } | null;
33
33
  nextDueAt: number;
34
- state: "active" | "paused" | "cancelled" | "finished";
34
+ state: "cancelled" | "active" | "paused" | "finished";
35
35
  lastCommandId: string | null;
36
36
  lastError: string | null;
37
37
  attempt: number;
@@ -50,7 +50,7 @@ function readAgentSchedulePage(
50
50
  expression: string;
51
51
  timeZone: string;
52
52
  } | null;
53
- state: "active" | "paused" | "cancelled" | "finished" | "failed";
53
+ state: "cancelled" | "active" | "paused" | "finished" | "failed";
54
54
  commandId: string;
55
55
  reason: string | null;
56
56
  nextDueAt: number | null;
@@ -89,14 +89,14 @@ The caller owns Agent, home and resource authorization and the owner's lifetime.
89
89
  `Promise`\<\{ `items`: readonly ( \| \{ `agentId`: `string`; `kind`:
90
90
  `"almanac"`; `schedule`: \{ `id`: `string`; `sessionId`: `string`; `prompt`:
91
91
  `string`; `cron`: \| \{ `expression`: `string`; `timeZone`: `string`; \} \|
92
- `null`; `nextDueAt`: `number`; `state`: `"active"` \| `"paused"` \|
93
- `"cancelled"` \| `"finished"`; `lastCommandId`: `string` \| `null`; `lastError`:
92
+ `null`; `nextDueAt`: `number`; `state`: `"cancelled"` \| `"active"` \|
93
+ `"paused"` \| `"finished"`; `lastCommandId`: `string` \| `null`; `lastError`:
94
94
  `string` \| `null`; `attempt`: `number`; \}; \} \| \{ `agentId`: `string`;
95
95
  `kind`: `"loop"`; `schedule`: \{ `loopId`: `string`; `origin`: `"human"` \|
96
96
  `"model"`; `expiresAt`: `number` \| `null`; `prompt`: `string`; `mode`:
97
97
  `"self_paced"` \| `"fixed_interval"`; `cron`: \| \{ `expression`: `string`;
98
- `timeZone`: `string`; \} \| `null`; `state`: `"active"` \| `"paused"` \|
99
- `"cancelled"` \| `"finished"` \| `"failed"`; `commandId`: `string`; `reason`:
98
+ `timeZone`: `string`; \} \| `null`; `state`: `"cancelled"` \| `"active"` \|
99
+ `"paused"` \| `"finished"` \| `"failed"`; `commandId`: `string`; `reason`:
100
100
  `string` \| `null`; `nextDueAt`: `number` \| `null`; `lastError`: `string` \|
101
101
  `null`; `consecutiveFailures`: `number`; `sessionId`: `string`; \}; \})[];
102
102
  `next`: \| \{ `agentId`: `string`; `kind`: `"loop"` \| `"almanac"`; `after?`:
@@ -124,7 +124,7 @@ function controlAgentScheduleWithContent(
124
124
  timeZone: string;
125
125
  } | null;
126
126
  nextDueAt: number;
127
- state: "active" | "paused" | "cancelled" | "finished";
127
+ state: "cancelled" | "active" | "paused" | "finished";
128
128
  lastCommandId: string | null;
129
129
  lastError: string | null;
130
130
  attempt: number;
@@ -143,7 +143,7 @@ function controlAgentScheduleWithContent(
143
143
  expression: string;
144
144
  timeZone: string;
145
145
  } | null;
146
- state: "active" | "paused" | "cancelled" | "finished" | "failed";
146
+ state: "cancelled" | "active" | "paused" | "finished" | "failed";
147
147
  commandId: string;
148
148
  reason: string | null;
149
149
  nextDueAt: number | null;
@@ -172,16 +172,16 @@ must already be admitted for target.agentId; this helper grants no authority.
172
172
  `Promise`\< \| \{ `agentId`: `string`; `kind`: `"almanac"`; `schedule`: \{ `id`:
173
173
  `string`; `sessionId`: `string`; `prompt`: `string`; `cron`: \| \{ `expression`:
174
174
  `string`; `timeZone`: `string`; \} \| `null`; `nextDueAt`: `number`; `state`:
175
- `"active"` \| `"paused"` \| `"cancelled"` \| `"finished"`; `lastCommandId`:
175
+ `"cancelled"` \| `"active"` \| `"paused"` \| `"finished"`; `lastCommandId`:
176
176
  `string` \| `null`; `lastError`: `string` \| `null`; `attempt`: `number`; \}; \}
177
177
  \| \{ `agentId`: `string`; `kind`: `"loop"`; `schedule`: \{ `loopId`: `string`;
178
178
  `origin`: `"human"` \| `"model"`; `expiresAt`: `number` \| `null`; `prompt`:
179
179
  `string`; `mode`: `"self_paced"` \| `"fixed_interval"`; `cron`: \| \{
180
- `expression`: `string`; `timeZone`: `string`; \} \| `null`; `state`: `"active"`
181
- \| `"paused"` \| `"cancelled"` \| `"finished"` \| `"failed"`; `commandId`:
182
- `string`; `reason`: `string` \| `null`; `nextDueAt`: `number` \| `null`;
183
- `lastError`: `string` \| `null`; `consecutiveFailures`: `number`; `sessionId`:
184
- `string`; \}; \}\>
180
+ `expression`: `string`; `timeZone`: `string`; \} \| `null`; `state`:
181
+ `"cancelled"` \| `"active"` \| `"paused"` \| `"finished"` \| `"failed"`;
182
+ `commandId`: `string`; `reason`: `string` \| `null`; `nextDueAt`: `number` \|
183
+ `null`; `lastError`: `string` \| `null`; `consecutiveFailures`: `number`;
184
+ `sessionId`: `string`; \}; \}\>
185
185
 
186
186
  ---
187
187
 
@@ -197,14 +197,14 @@ function controlAgentSchedule(
197
197
  agentId: string;
198
198
  kind: "almanac";
199
199
  scheduleId: string;
200
- state: "active" | "paused" | "cancelled" | "finished";
200
+ state: "cancelled" | "active" | "paused" | "finished";
201
201
  }
202
202
  | {
203
203
  agentId: string;
204
204
  kind: "loop";
205
205
  sessionId: string;
206
206
  loopId: string;
207
- state: "active" | "paused" | "cancelled" | "finished" | "failed";
207
+ state: "cancelled" | "active" | "paused" | "finished" | "failed";
208
208
  }
209
209
  >;
210
210
  ```
@@ -222,7 +222,7 @@ Control an already-admitted owner; manage-only callers receive no read content.
222
222
  #### Returns
223
223
 
224
224
  `Promise`\< \| \{ `agentId`: `string`; `kind`: `"almanac"`; `scheduleId`:
225
- `string`; `state`: `"active"` \| `"paused"` \| `"cancelled"` \| `"finished"`; \}
225
+ `string`; `state`: `"cancelled"` \| `"active"` \| `"paused"` \| `"finished"`; \}
226
226
  \| \{ `agentId`: `string`; `kind`: `"loop"`; `sessionId`: `string`; `loopId`:
227
- `string`; `state`: `"active"` \| `"paused"` \| `"cancelled"` \| `"finished"` \|
227
+ `string`; `state`: `"cancelled"` \| `"active"` \| `"paused"` \| `"finished"` \|
228
228
  `"failed"`; \}\>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake-extensions",
3
- "version": "0.11.23",
3
+ "version": "0.12.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Botanical's product Shiitake extensions: goal, loop and Almanac on the generic extension surface",
@@ -10,6 +10,10 @@
10
10
  "types": "./dist/almanac/contract.d.ts",
11
11
  "import": "./dist/almanac/contract.js"
12
12
  },
13
+ "./almanac/client": {
14
+ "types": "./dist/almanac/client.d.ts",
15
+ "import": "./dist/almanac/client.js"
16
+ },
13
17
  "./almanac/host": {
14
18
  "types": "./dist/almanac/host.d.ts",
15
19
  "import": "./dist/almanac/host.js"
@@ -122,7 +126,7 @@
122
126
  "@fungi.computer/cairn": "0.1.0",
123
127
  "@fungi.computer/knapsack": "0.4.21",
124
128
  "@fungi.computer/mycelium": "0.4.7",
125
- "@fungi.computer/shiitake": "0.21.11",
129
+ "@fungi.computer/shiitake": "0.21.12",
126
130
  "@fungi.computer/watchdog": "0.1.4",
127
131
  "@fungi.computer/whistle": "0.3.0",
128
132
  "effect": "4.0.2",