@fungi.computer/shiitake-extensions 0.12.9 → 0.13.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.
@@ -1,10 +1,12 @@
1
1
  import type { WhistleCatalogStepV1 } from "@fungi.computer/whistle/catalog";
2
2
  import { ExtensionCommandError } from "@fungi.computer/shiitake/extensions";
3
3
  import * as Effect from "effect/Effect";
4
- import { type Answers, type AnswerFlowInput, type Question } from "./contract.js";
4
+ import { type ClosedStatus, type Answers, type AnswerFlowInput, type Question } from "./contract.js";
5
5
  import type * as Schema from "effect/Schema";
6
6
  /** Drafts travel in catalog arguments; only an owner's answer commits them. */
7
7
  export type FlowInput = Schema.Schema.Type<typeof AnswerFlowInput>;
8
+ /** Only an answer committed elsewhere is an ordinary quiet dismissal. */
9
+ export declare function closedQuestionNotice(status: Schema.Schema.Type<typeof ClosedStatus>): WhistleCatalogStepV1;
8
10
  /** What the answer conversation does next for one open Ask. */
9
11
  export type AnswerFlowOutcome = Readonly<{
10
12
  type: "step";
@@ -23,5 +25,5 @@ export type AnswerFlowOutcome = Readonly<{
23
25
  export declare function advanceAnswerFlow(row: Readonly<{
24
26
  askId: string;
25
27
  questions: readonly Question[];
26
- closed: boolean;
28
+ closed: false | Schema.Schema.Type<typeof ClosedStatus>;
27
29
  }>, input: FlowInput): Effect.Effect<AnswerFlowOutcome, ExtensionCommandError>;
@@ -58,6 +58,19 @@ function promptQuestion(nextQuestion, next, total) {
58
58
  : base;
59
59
  return ask(nextQuestion.multiple === true ? { ...numbered, multiple: true } : numbered, { stage: "decision", ...next }, "answer");
60
60
  }
61
+ const closedMessages = {
62
+ declined: "That question was declined.",
63
+ withdrawn: "The Agent withdrew that question.",
64
+ expired: "That question has expired.",
65
+ cancelled: "That question was cancelled.",
66
+ undeliverable: "Your answer could not reach the Agent.",
67
+ };
68
+ /** Only an answer committed elsewhere is an ordinary quiet dismissal. */
69
+ export function closedQuestionNotice(status) {
70
+ return status === "answered"
71
+ ? { type: "done" }
72
+ : done({ type: "info", message: closedMessages[status] });
73
+ }
61
74
  /**
62
75
  * Progress one Ask's answer draft by a single human step. The owner of the
63
76
  * Ask commits a completed set; a step only ever returns the next prompt, so
@@ -65,6 +78,9 @@ function promptQuestion(nextQuestion, next, total) {
65
78
  */
66
79
  export function advanceAnswerFlow(row, input) {
67
80
  return Effect.gen(function* () {
81
+ // Preserve the closing cause while ignoring a stale composer's draft.
82
+ if (row.closed !== false)
83
+ return { type: "step", step: closedQuestionNotice(row.closed) };
68
84
  const draft = "stage" in input
69
85
  ? input
70
86
  : {
@@ -95,14 +111,6 @@ export function advanceAnswerFlow(row, input) {
95
111
  answers,
96
112
  };
97
113
  }
98
- if (row.closed)
99
- return {
100
- type: "step",
101
- step: done({
102
- type: "info",
103
- message: "That question is already closed.",
104
- }),
105
- };
106
114
  const next = { askId: row.askId, requestId, index, answers };
107
115
  const nextQuestion = row.questions[index];
108
116
  if (nextQuestion === undefined)
@@ -9,7 +9,7 @@ import { createHash } from "node:crypto";
9
9
  import { z } from "zod";
10
10
  import { catalog, done } from "../internal/catalog.js";
11
11
  import { questionContract, OpenAsk, Questions, Answers, HumanResult, AgentAnswerResult, AnsweredBy, EscalateResult, DeclineInput, ClosedStatus, AnswerFlowInput, } from "./contract.js";
12
- import { advanceAnswerFlow } from "./answer-flow.js";
12
+ import { advanceAnswerFlow, closedQuestionNotice, } from "./answer-flow.js";
13
13
  const config = {
14
14
  maximumOpen: 4,
15
15
  liveWindowMs: 600_000,
@@ -675,7 +675,10 @@ const baseInput = z.strictObject({
675
675
  questions: z
676
676
  .array(z.strictObject({
677
677
  id: z.string().min(1).max(32),
678
- header: z.string().min(1).max(12),
678
+ header: z
679
+ .string()
680
+ .min(1)
681
+ .max(12, "Question header must be at most 12 characters."),
679
682
  question: z.string().min(1).max(1_000),
680
683
  options: z
681
684
  .array(z.strictObject({
@@ -831,11 +834,11 @@ function withdraw(ctx, sessionId, askId) {
831
834
  function answerNotice(result) {
832
835
  if (result.result === "accepted")
833
836
  return done({ type: "success", message: "Answer sent." });
837
+ if (result.result === "closed")
838
+ return closedQuestionNotice(result.status);
834
839
  return done({
835
840
  type: "info",
836
- message: result.result === "closed"
837
- ? `Question closed: ${result.status}.`
838
- : "That question is no longer available.",
841
+ message: "That question is no longer available.",
839
842
  });
840
843
  }
841
844
  function chooseQuestion(ctx, sessionId, askId) {
@@ -874,7 +877,9 @@ function answerQuestion(ctx, sessionId, row, input) {
874
877
  const outcome = yield* advanceAnswerFlow({
875
878
  askId: row.askId,
876
879
  questions: row.questions,
877
- closed: row.status === "settled" || row.pending !== null,
880
+ closed: row.status === "settled"
881
+ ? row.outcome.status
882
+ : (row.pending?.status ?? false),
878
883
  }, input);
879
884
  if (outcome.type === "step")
880
885
  return outcome.step;
@@ -106,9 +106,9 @@ function summary(view) {
106
106
  `${String(total)} sub-agent${total === 1 ? "" : "s"}`,
107
107
  ...counts,
108
108
  ...(view.uncounted > 0 ? [`${String(view.uncounted)} not read`] : []),
109
- "/agents shows them",
110
109
  ].join(" · "),
111
110
  tone,
111
+ actions: [{ id: "agents", label: "Show agents", input: {} }],
112
112
  };
113
113
  }
114
114
  /** One footer row per sub-agent; opening a row shows its conversation beside this one. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake-extensions",
3
- "version": "0.12.9",
3
+ "version": "0.13.0",
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",
@@ -124,9 +124,9 @@
124
124
  "dependencies": {
125
125
  "@fungi.computer/almanac": "0.2.1",
126
126
  "@fungi.computer/cairn": "0.1.0",
127
- "@fungi.computer/knapsack": "0.4.26",
128
- "@fungi.computer/mycelium": "0.4.11",
129
- "@fungi.computer/shiitake": "0.22.2",
127
+ "@fungi.computer/knapsack": "0.4.27",
128
+ "@fungi.computer/mycelium": "0.4.12",
129
+ "@fungi.computer/shiitake": "0.22.4",
130
130
  "@fungi.computer/watchdog": "0.1.5",
131
131
  "@fungi.computer/whistle": "0.3.0",
132
132
  "effect": "4.0.2",