@fungi.computer/shiitake-extensions 0.0.0-stage → 0.0.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +262 -2
  3. package/dist/almanac/contract.d.ts +213 -0
  4. package/dist/almanac/contract.js +77 -0
  5. package/dist/almanac/host.d.ts +3 -0
  6. package/dist/almanac/host.js +171 -0
  7. package/dist/goal/client.d.ts +10 -0
  8. package/dist/goal/client.js +88 -0
  9. package/dist/goal/contract.d.ts +172 -0
  10. package/dist/goal/contract.js +76 -0
  11. package/dist/goal/host.d.ts +5 -0
  12. package/dist/goal/host.js +542 -0
  13. package/dist/home/contract.d.ts +33 -0
  14. package/dist/home/contract.js +25 -0
  15. package/dist/home/host.d.ts +18 -0
  16. package/dist/home/host.js +136 -0
  17. package/dist/home/routing.d.ts +3 -0
  18. package/dist/home/routing.js +80 -0
  19. package/dist/internal/catalog.d.ts +20 -0
  20. package/dist/internal/catalog.js +33 -0
  21. package/dist/internal/cron.d.ts +5 -0
  22. package/dist/internal/cron.js +14 -0
  23. package/dist/internal/history.d.ts +29 -0
  24. package/dist/internal/history.js +41 -0
  25. package/dist/loop/client.d.ts +10 -0
  26. package/dist/loop/client.js +89 -0
  27. package/dist/loop/contract.d.ts +342 -0
  28. package/dist/loop/contract.js +94 -0
  29. package/dist/loop/host.d.ts +4 -0
  30. package/dist/loop/host.js +637 -0
  31. package/dist/plan/client.d.ts +13 -0
  32. package/dist/plan/client.js +51 -0
  33. package/dist/plan/contract.d.ts +105 -0
  34. package/dist/plan/contract.js +38 -0
  35. package/dist/plan/host.d.ts +3 -0
  36. package/dist/plan/host.js +154 -0
  37. package/dist/question/client.d.ts +10 -0
  38. package/dist/question/client.js +28 -0
  39. package/dist/question/contract.d.ts +251 -0
  40. package/dist/question/contract.js +114 -0
  41. package/dist/question/host.d.ts +3 -0
  42. package/dist/question/host.js +997 -0
  43. package/dist/roster.d.ts +9 -0
  44. package/dist/roster.js +80 -0
  45. package/dist/skills/host.d.ts +7 -0
  46. package/dist/skills/host.js +223 -0
  47. package/dist/skills/source.d.ts +28 -0
  48. package/dist/skills/source.js +1 -0
  49. package/dist/subagents/client.d.ts +10 -0
  50. package/dist/subagents/client.js +53 -0
  51. package/dist/subagents/contract.d.ts +54 -0
  52. package/dist/subagents/contract.js +38 -0
  53. package/dist/subagents/host.d.ts +50 -0
  54. package/dist/subagents/host.js +176 -0
  55. package/package.json +117 -3
@@ -0,0 +1,114 @@
1
+ import { ExtensionId } from "@fungi.computer/shiitake/extensions";
2
+ import * as Schema from "effect/Schema";
3
+ import { CatalogStep } from "../internal/catalog.js";
4
+ const text = (maximum) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maximum), Schema.isPattern(/\S/u));
5
+ /** A decision question: first option is recommended, free text belongs to the host. */
6
+ export const Question = Schema.Struct({
7
+ id: text(32).check(Schema.isPattern(/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/u)),
8
+ header: text(12),
9
+ question: text(1_000),
10
+ options: Schema.Array(Schema.Struct({ label: text(60), description: text(300) })).check(Schema.isMinLength(2), Schema.isMaxLength(4), Schema.makeFilter((options) => new Set(options.map((option) => option.label)).size ===
11
+ options.length || "Option labels must be unique", {
12
+ representation: {
13
+ id: "botanical/ask/unique-option-labels",
14
+ payload: null,
15
+ },
16
+ })),
17
+ multiple: Schema.optionalKey(Schema.Boolean),
18
+ });
19
+ export const Questions = Schema.Array(Question).check(Schema.isMinLength(1), Schema.isMaxLength(4), Schema.makeFilter((questions) => new Set(questions.map((question) => question.id)).size ===
20
+ questions.length || "Question ids must be unique", {
21
+ representation: {
22
+ id: "botanical/ask/unique-question-ids",
23
+ payload: null,
24
+ },
25
+ }));
26
+ /** The complete question data shared by ordinary Session clients. */
27
+ export const OpenAsk = Schema.Struct({
28
+ askId: Schema.String,
29
+ questions: Questions,
30
+ status: Schema.Literals(["live", "parked"]),
31
+ createdAt: Schema.Number,
32
+ expiresAt: Schema.NullOr(Schema.Number),
33
+ });
34
+ export const AskProjection = Schema.Struct({
35
+ asks: Schema.Array(OpenAsk).check(Schema.isMaxLength(4)),
36
+ });
37
+ /** Stable identity for a human command and its retry. */
38
+ export const RequestId = text(256);
39
+ export const Answers = Schema.Record(Question.fields.id, Schema.Struct({
40
+ selected: Schema.Array(text(60)).check(Schema.isMaxLength(4)),
41
+ text: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4_000))),
42
+ }));
43
+ export const AnswerInput = Schema.Struct({
44
+ askId: text(256),
45
+ requestId: RequestId,
46
+ answers: Answers,
47
+ });
48
+ export const DeclineInput = Schema.Struct({
49
+ askId: text(256),
50
+ requestId: RequestId,
51
+ note: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4_000))),
52
+ });
53
+ /** Terminal question outcomes, shared by human replies and model withdrawal. */
54
+ export const ClosedStatus = Schema.Literals([
55
+ "answered",
56
+ "declined",
57
+ "withdrawn",
58
+ "expired",
59
+ "cancelled",
60
+ "undeliverable",
61
+ ]);
62
+ export const HumanResult = Schema.Union([
63
+ Schema.Struct({
64
+ result: Schema.Literal("accepted"),
65
+ via: Schema.Literals(["in_turn", "follow_up"]),
66
+ }),
67
+ Schema.Struct({
68
+ result: Schema.Literal("closed"),
69
+ status: ClosedStatus,
70
+ }),
71
+ Schema.Struct({ result: Schema.Literal("not_found") }),
72
+ ]);
73
+ const answerStep = {
74
+ askId: AnswerInput.fields.askId,
75
+ requestId: RequestId,
76
+ index: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 3 })),
77
+ answers: Answers,
78
+ };
79
+ /** The ordinary /answer conversation carries its draft between typed steps. */
80
+ export const AnswerFlowInput = Schema.Union([
81
+ Schema.Struct({
82
+ stage: Schema.Literal("multiple"),
83
+ ...answerStep,
84
+ selection: Schema.String.check(Schema.isMaxLength(1_000)),
85
+ }),
86
+ Schema.Struct({
87
+ stage: Schema.Literal("selection"),
88
+ ...answerStep,
89
+ selection: Schema.String.check(Schema.isMaxLength(1_000)),
90
+ }),
91
+ Schema.Struct({
92
+ stage: Schema.Literal("text"),
93
+ ...answerStep,
94
+ selected: Answers.value.fields.selected,
95
+ text: Schema.String.check(Schema.isMaxLength(4_000)),
96
+ }),
97
+ Schema.Struct({ askId: AnswerInput.fields.askId }),
98
+ Schema.Struct({}),
99
+ ]);
100
+ /** Human reads and the ordinary projection slot; model operations belong to the host. */
101
+ export const questionContract = {
102
+ id: ExtensionId.make("botanical-session-question"),
103
+ commands: {
104
+ answerFlow: {
105
+ scope: "session",
106
+ input: AnswerFlowInput,
107
+ output: CatalogStep,
108
+ },
109
+ answer: { scope: "session", input: AnswerInput, output: HumanResult },
110
+ decline: { scope: "session", input: DeclineInput, output: HumanResult },
111
+ list: { scope: "session", input: Schema.Struct({}), output: AskProjection },
112
+ },
113
+ projection: { schema: AskProjection },
114
+ };
@@ -0,0 +1,3 @@
1
+ import { type RosteredExtensionV0 } from "@fungi.computer/shiitake/extensions";
2
+ /** One durable question owner over the ordinary extension doors. */
3
+ export declare const questionExtension: RosteredExtensionV0;