@fungi.computer/shiitake 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 (164) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +454 -2
  3. package/dist/agar-extension.d.ts +9 -0
  4. package/dist/agar-extension.js +38 -0
  5. package/dist/agent-control.d.ts +72 -0
  6. package/dist/agent-control.js +431 -0
  7. package/dist/client-entry.d.ts +211 -0
  8. package/dist/client-entry.js +101 -0
  9. package/dist/client-wire.d.ts +199 -0
  10. package/dist/client-wire.js +271 -0
  11. package/dist/client.d.ts +439 -0
  12. package/dist/client.js +4 -0
  13. package/dist/cloudflare.d.ts +220 -0
  14. package/dist/cloudflare.js +531 -0
  15. package/dist/effect.d.ts +42 -0
  16. package/dist/effect.js +20 -0
  17. package/dist/errors.d.ts +50 -0
  18. package/dist/errors.js +81 -0
  19. package/dist/extension-client.d.ts +38 -0
  20. package/dist/extension-client.js +56 -0
  21. package/dist/extension-contract.d.ts +73 -0
  22. package/dist/extension-contract.js +11 -0
  23. package/dist/extensions.d.ts +589 -0
  24. package/dist/extensions.js +263 -0
  25. package/dist/fleet.d.ts +297 -0
  26. package/dist/fleet.js +515 -0
  27. package/dist/hosted.d.ts +133 -0
  28. package/dist/hosted.js +265 -0
  29. package/dist/http-routes.d.ts +772 -0
  30. package/dist/http-routes.js +242 -0
  31. package/dist/http.d.ts +1 -0
  32. package/dist/http.js +1 -0
  33. package/dist/index.d.ts +35 -0
  34. package/dist/index.js +13 -0
  35. package/dist/internal/accepted-run-executor.d.ts +23 -0
  36. package/dist/internal/accepted-run-executor.js +129 -0
  37. package/dist/internal/admission-door.d.ts +75 -0
  38. package/dist/internal/admission-door.js +105 -0
  39. package/dist/internal/agent-close.d.ts +4 -0
  40. package/dist/internal/agent-close.js +42 -0
  41. package/dist/internal/browser-sessions.d.ts +31 -0
  42. package/dist/internal/browser-sessions.js +173 -0
  43. package/dist/internal/client-boundary.d.ts +262 -0
  44. package/dist/internal/client-boundary.js +202 -0
  45. package/dist/internal/compaction/compaction.d.ts +54 -0
  46. package/dist/internal/compaction/compaction.js +292 -0
  47. package/dist/internal/compaction/session-compaction.d.ts +69 -0
  48. package/dist/internal/compaction/session-compaction.js +330 -0
  49. package/dist/internal/compaction/settings.d.ts +11 -0
  50. package/dist/internal/compaction/settings.js +40 -0
  51. package/dist/internal/compaction/utils.d.ts +45 -0
  52. package/dist/internal/compaction/utils.js +319 -0
  53. package/dist/internal/contracts.d.ts +235 -0
  54. package/dist/internal/contracts.js +1 -0
  55. package/dist/internal/coordinator.d.ts +18 -0
  56. package/dist/internal/coordinator.js +362 -0
  57. package/dist/internal/document-codec.d.ts +11 -0
  58. package/dist/internal/document-codec.js +39 -0
  59. package/dist/internal/effect-client.d.ts +13 -0
  60. package/dist/internal/effect-client.js +102 -0
  61. package/dist/internal/effect-contracts.d.ts +236 -0
  62. package/dist/internal/effect-contracts.js +2 -0
  63. package/dist/internal/extension-command-registry.d.ts +11 -0
  64. package/dist/internal/extension-command-registry.js +29 -0
  65. package/dist/internal/extension-command-tools.d.ts +17 -0
  66. package/dist/internal/extension-command-tools.js +50 -0
  67. package/dist/internal/extension-context.d.ts +25 -0
  68. package/dist/internal/extension-context.js +35 -0
  69. package/dist/internal/extension-definitions.d.ts +5 -0
  70. package/dist/internal/extension-definitions.js +6 -0
  71. package/dist/internal/extension-hook.d.ts +25 -0
  72. package/dist/internal/extension-hook.js +46 -0
  73. package/dist/internal/extension-roster.d.ts +23 -0
  74. package/dist/internal/extension-roster.js +228 -0
  75. package/dist/internal/extension-runtime.d.ts +63 -0
  76. package/dist/internal/extension-runtime.js +1004 -0
  77. package/dist/internal/failure.d.ts +2 -0
  78. package/dist/internal/failure.js +9 -0
  79. package/dist/internal/host-meta.d.ts +41 -0
  80. package/dist/internal/host-meta.js +39 -0
  81. package/dist/internal/json-value.d.ts +4 -0
  82. package/dist/internal/json-value.js +3 -0
  83. package/dist/internal/model-acquisition.d.ts +21 -0
  84. package/dist/internal/model-acquisition.js +98 -0
  85. package/dist/internal/model-preference.d.ts +21 -0
  86. package/dist/internal/model-preference.js +20 -0
  87. package/dist/internal/observation-kernel.d.ts +28 -0
  88. package/dist/internal/observation-kernel.js +169 -0
  89. package/dist/internal/promise-facade.d.ts +18 -0
  90. package/dist/internal/promise-facade.js +172 -0
  91. package/dist/internal/run-scope.d.ts +27 -0
  92. package/dist/internal/run-scope.js +214 -0
  93. package/dist/internal/runtime-coordinator.d.ts +34 -0
  94. package/dist/internal/runtime-coordinator.js +233 -0
  95. package/dist/internal/runtime-core.d.ts +19 -0
  96. package/dist/internal/runtime-core.js +39 -0
  97. package/dist/internal/runtime-reconciliation.d.ts +18 -0
  98. package/dist/internal/runtime-reconciliation.js +162 -0
  99. package/dist/internal/session-context.d.ts +11 -0
  100. package/dist/internal/session-context.js +67 -0
  101. package/dist/internal/session-status.d.ts +10 -0
  102. package/dist/internal/session-status.js +52 -0
  103. package/dist/internal/woodstock/agent-reply.d.ts +25 -0
  104. package/dist/internal/woodstock/agent-reply.js +67 -0
  105. package/dist/internal/woodstock/client-projection.d.ts +29 -0
  106. package/dist/internal/woodstock/client-projection.js +512 -0
  107. package/dist/internal/woodstock/compaction-activity.d.ts +17 -0
  108. package/dist/internal/woodstock/compaction-activity.js +32 -0
  109. package/dist/internal/woodstock/cursor.d.ts +9 -0
  110. package/dist/internal/woodstock/cursor.js +44 -0
  111. package/dist/internal/woodstock/extension-store.d.ts +72 -0
  112. package/dist/internal/woodstock/extension-store.js +262 -0
  113. package/dist/internal/woodstock/fleet-store.d.ts +32 -0
  114. package/dist/internal/woodstock/fleet-store.js +93 -0
  115. package/dist/internal/woodstock/identities.d.ts +6 -0
  116. package/dist/internal/woodstock/identities.js +11 -0
  117. package/dist/internal/woodstock/index.d.ts +170 -0
  118. package/dist/internal/woodstock/index.js +546 -0
  119. package/dist/internal/woodstock/progress.d.ts +32 -0
  120. package/dist/internal/woodstock/progress.js +89 -0
  121. package/dist/internal/woodstock/run-recovery.d.ts +8 -0
  122. package/dist/internal/woodstock/run-recovery.js +95 -0
  123. package/dist/internal/woodstock/session-attention.d.ts +16 -0
  124. package/dist/internal/woodstock/session-attention.js +88 -0
  125. package/dist/internal/woodstock/session-documents.d.ts +18 -0
  126. package/dist/internal/woodstock/session-documents.js +51 -0
  127. package/dist/internal/woodstock/session-entry.d.ts +478 -0
  128. package/dist/internal/woodstock/session-entry.js +484 -0
  129. package/dist/internal/woodstock/session-grants.d.ts +24 -0
  130. package/dist/internal/woodstock/session-grants.js +84 -0
  131. package/dist/internal/woodstock/session-inbox.d.ts +56 -0
  132. package/dist/internal/woodstock/session-inbox.js +307 -0
  133. package/dist/internal/woodstock/session-store.d.ts +432 -0
  134. package/dist/internal/woodstock/session-store.js +2006 -0
  135. package/dist/internal/woodstock/storage-admission.d.ts +14 -0
  136. package/dist/internal/woodstock/storage-admission.js +44 -0
  137. package/dist/model-preference.d.ts +20 -0
  138. package/dist/model-preference.js +30 -0
  139. package/dist/node.d.ts +64 -0
  140. package/dist/node.js +256 -0
  141. package/dist/remote-client.d.ts +11 -0
  142. package/dist/remote-client.js +298 -0
  143. package/dist/session-attention.d.ts +35 -0
  144. package/dist/session-attention.js +22 -0
  145. package/dist/session-documents.d.ts +28 -0
  146. package/dist/session-documents.js +1 -0
  147. package/dist/testing.d.ts +54 -0
  148. package/dist/testing.js +215 -0
  149. package/docs/api/README.md +26 -0
  150. package/docs/api/agar-extension.md +40 -0
  151. package/docs/api/agent-control.md +151 -0
  152. package/docs/api/client-entry.md +344 -0
  153. package/docs/api/client.md +1112 -0
  154. package/docs/api/cloudflare.md +500 -0
  155. package/docs/api/effect.md +904 -0
  156. package/docs/api/extensions.md +2003 -0
  157. package/docs/api/fleet.md +706 -0
  158. package/docs/api/hosted.md +382 -0
  159. package/docs/api/http.md +111 -0
  160. package/docs/api/index.md +1116 -0
  161. package/docs/api/model-preference.md +151 -0
  162. package/docs/api/node.md +142 -0
  163. package/docs/api/testing.md +250 -0
  164. package/package.json +130 -3
@@ -0,0 +1,42 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Latch from "effect/Latch";
3
+ import * as Exit from "effect/Exit";
4
+ function replayCloseResult(result) {
5
+ return Exit.match(result, {
6
+ onFailure: Effect.failCause,
7
+ onSuccess: () => Effect.void,
8
+ });
9
+ }
10
+ function closeCoordinatorThenExtensions(coordinatorClose, extensionClose) {
11
+ return Effect.matchCauseEffect(coordinatorClose, {
12
+ onFailure: (coordinatorCause) => Effect.exit(extensionClose).pipe(Effect.andThen(Effect.failCause(coordinatorCause))),
13
+ onSuccess: () => extensionClose,
14
+ });
15
+ }
16
+ /** Compose one idempotent close action for the constructed agent. */
17
+ export function composeAgentClose(coordinatorClose, extensionClose) {
18
+ let state = { _tag: "open" };
19
+ const runClose = (running) => closeCoordinatorThenExtensions(coordinatorClose, extensionClose).pipe(Effect.exit, Effect.flatMap((result) => Effect.sync(() => {
20
+ running.result = result;
21
+ state = { _tag: "closed" };
22
+ }).pipe(Effect.andThen(running.settled.open), Effect.andThen(replayCloseResult(result)))), Effect.uninterruptible);
23
+ return Effect.suspend(() => {
24
+ if (state._tag === "closed")
25
+ return Effect.void;
26
+ if (state._tag !== "open") {
27
+ const running = state;
28
+ return running.settled.await.pipe(Effect.andThen(Effect.suspend(() => {
29
+ const result = running.result;
30
+ return result === undefined
31
+ ? Effect.die(new Error("Agent close settlement was not recorded"))
32
+ : replayCloseResult(result);
33
+ })));
34
+ }
35
+ const running = {
36
+ _tag: "running",
37
+ settled: Latch.makeUnsafe(false),
38
+ };
39
+ state = running;
40
+ return runClose(running);
41
+ });
42
+ }
@@ -0,0 +1,31 @@
1
+ import type { ModuleRegistration } from "@fungi.computer/mycelium";
2
+ /** The maintained browser transport and its Session-bound tool descriptors. */
3
+ export type BrowserHost = Readonly<{
4
+ /** Mycelium tools bound to this host's Session and call-time gates. */
5
+ modules: readonly ModuleRegistration[];
6
+ /** Forward one browser events, claims or results request to the maintained host. */
7
+ fetch: (request: Request) => Promise<Response>;
8
+ }>;
9
+ export type BrowserLease = Readonly<{
10
+ host: BrowserHost;
11
+ release: () => void;
12
+ }>;
13
+ /** One ephemeral browser host per Session, borrowed by run and SSE scopes. */
14
+ export declare class BrowserSessions {
15
+ private readonly open;
16
+ private readonly hasSession;
17
+ private generation;
18
+ private closed;
19
+ private readonly hosts;
20
+ constructor(open: (sessionId: string) => BrowserHost, hasSession: (sessionId: string) => Promise<boolean>);
21
+ clear(): Promise<void>;
22
+ close(): Promise<void>;
23
+ fetch(request: Request): Promise<Response>;
24
+ /** Own the async transport opening until its stream joins the connection scope. */
25
+ private openEvents;
26
+ private createHost;
27
+ acquire(sessionId: string): BrowserLease;
28
+ private releaseBrowserConnection;
29
+ private releaseIdleHost;
30
+ private trackBrowserConnection;
31
+ }
@@ -0,0 +1,173 @@
1
+ /** One ephemeral browser host per Session, borrowed by run and SSE scopes. */
2
+ export class BrowserSessions {
3
+ open;
4
+ hasSession;
5
+ generation = 0;
6
+ closed = false;
7
+ hosts = new Map();
8
+ constructor(open, hasSession) {
9
+ this.open = open;
10
+ this.hasSession = hasSession;
11
+ }
12
+ async clear() {
13
+ this.generation += 1;
14
+ const old = [...this.hosts.values()];
15
+ this.hosts.clear();
16
+ await Promise.all(old.flatMap((entry) => [...entry.connections].map((close) => close())));
17
+ }
18
+ async close() {
19
+ this.closed = true;
20
+ await this.clear();
21
+ }
22
+ async fetch(request) {
23
+ if (this.closed)
24
+ return new Response(null, { status: 410 });
25
+ const generation = this.generation;
26
+ const path = new URL(request.url).pathname;
27
+ const browserRoute = /^\/browser\/sessions\/([^/]+)\/browser\/(events|claims|results)$/u.exec(path);
28
+ if (browserRoute === null)
29
+ return new Response("Not found", { status: 404 });
30
+ let sessionId;
31
+ try {
32
+ sessionId = decodeURIComponent(browserRoute[1] ?? "");
33
+ }
34
+ catch {
35
+ return new Response("Not found", { status: 404 });
36
+ }
37
+ const route = browserRoute[2];
38
+ if (!sessionId || !route)
39
+ return new Response("Not found", { status: 404 });
40
+ let entry = this.hosts.get(sessionId);
41
+ if (entry === undefined) {
42
+ if (route !== "events")
43
+ return new Response("Not found", { status: 404 });
44
+ if (!(await this.hasSession(sessionId)))
45
+ return new Response("Not found", { status: 404 });
46
+ if (generation !== this.generation)
47
+ return new Response(null, { status: 404 });
48
+ entry = this.hosts.get(sessionId) ?? this.createHost(sessionId);
49
+ }
50
+ const target = new URL(request.url);
51
+ target.pathname = `/browser/${route}`;
52
+ if (route !== "events")
53
+ return entry.host.fetch(new Request(target, request));
54
+ return this.openEvents(new Request(target, request), sessionId, entry, generation);
55
+ }
56
+ /** Own the async transport opening until its stream joins the connection scope. */
57
+ async openEvents(request, sessionId, entry, generation) {
58
+ entry.browserConnections += 1;
59
+ try {
60
+ const response = await entry.host.fetch(request);
61
+ if (generation !== this.generation) {
62
+ // The maintained transport may finish opening after teardown. Its
63
+ // late scope belongs to the old generation and must never escape.
64
+ await response.body?.cancel();
65
+ this.releaseBrowserConnection(sessionId, entry);
66
+ return new Response(null, { status: 404 });
67
+ }
68
+ if (!response.ok || response.body === null) {
69
+ this.releaseBrowserConnection(sessionId, entry);
70
+ return response;
71
+ }
72
+ return this.trackBrowserConnection(response, sessionId, entry);
73
+ }
74
+ catch (error) {
75
+ this.releaseBrowserConnection(sessionId, entry);
76
+ throw error;
77
+ }
78
+ }
79
+ createHost(sessionId) {
80
+ const entry = {
81
+ host: this.open(sessionId),
82
+ activeRuns: 0,
83
+ browserConnections: 0,
84
+ connections: new Set(),
85
+ };
86
+ this.hosts.set(sessionId, entry);
87
+ return entry;
88
+ }
89
+ acquire(sessionId) {
90
+ if (this.closed)
91
+ throw new Error("Browser host is closed");
92
+ const entry = this.hosts.get(sessionId) ?? this.createHost(sessionId);
93
+ entry.activeRuns += 1;
94
+ let released = false;
95
+ return {
96
+ host: entry.host,
97
+ release: () => {
98
+ if (released)
99
+ return;
100
+ released = true;
101
+ entry.activeRuns -= 1;
102
+ this.releaseIdleHost(sessionId, entry);
103
+ },
104
+ };
105
+ }
106
+ releaseBrowserConnection(sessionId, entry) {
107
+ entry.browserConnections -= 1;
108
+ this.releaseIdleHost(sessionId, entry);
109
+ }
110
+ releaseIdleHost(sessionId, entry) {
111
+ if (entry.activeRuns === 0 &&
112
+ entry.browserConnections === 0 &&
113
+ this.hosts.get(sessionId) === entry)
114
+ this.hosts.delete(sessionId);
115
+ }
116
+ trackBrowserConnection(response, sessionId, entry) {
117
+ const reader = response.body?.getReader();
118
+ if (reader === undefined) {
119
+ this.releaseBrowserConnection(sessionId, entry);
120
+ return response;
121
+ }
122
+ let released = false;
123
+ let controller;
124
+ const close = async () => {
125
+ if (released)
126
+ return;
127
+ release();
128
+ controller.close();
129
+ await reader.cancel();
130
+ };
131
+ const release = () => {
132
+ if (released)
133
+ return;
134
+ released = true;
135
+ entry.connections.delete(close);
136
+ this.releaseBrowserConnection(sessionId, entry);
137
+ };
138
+ entry.connections.add(close);
139
+ const body = new ReadableStream({
140
+ start: (streamController) => {
141
+ controller = streamController;
142
+ },
143
+ pull: async (controller) => {
144
+ try {
145
+ const next = await reader.read();
146
+ if (released)
147
+ return;
148
+ if (next.done) {
149
+ controller.close();
150
+ release();
151
+ }
152
+ else
153
+ controller.enqueue(next.value);
154
+ }
155
+ catch (error) {
156
+ if (released)
157
+ return;
158
+ controller.error(error);
159
+ release();
160
+ }
161
+ },
162
+ cancel: async (reason) => {
163
+ release();
164
+ await reader.cancel(reason);
165
+ },
166
+ });
167
+ return new Response(body, {
168
+ status: response.status,
169
+ statusText: response.statusText,
170
+ headers: response.headers,
171
+ });
172
+ }
173
+ }
@@ -0,0 +1,262 @@
1
+ import * as Result from "effect/Result";
2
+ import * as Schema from "effect/Schema";
3
+ /** Bounded image payload admitted and persisted by the Session owner. */
4
+ export declare const PromptImageSchema: Schema.Struct<{
5
+ readonly type: Schema.Literal<"image">;
6
+ readonly data: Schema.String;
7
+ readonly mimeType: Schema.String;
8
+ }>;
9
+ /** Delivery policy for input accepted while a Session run is active. */
10
+ export type PromptDelivery = "steer" | "followUp";
11
+ declare const SessionCreationRequestSchema: Schema.Struct<{
12
+ readonly requestId: Schema.String;
13
+ }>;
14
+ declare const PromptCommandSchema: Schema.Struct<{
15
+ readonly delivery: Schema.Literals<readonly ["steer", "followUp"]>;
16
+ readonly requestId: Schema.String;
17
+ readonly type: Schema.Literal<"prompt">;
18
+ readonly text: Schema.String;
19
+ readonly images: Schema.optionalKey<Schema.$Array<Schema.Struct<{
20
+ readonly type: Schema.Literal<"image">;
21
+ readonly data: Schema.String;
22
+ readonly mimeType: Schema.String;
23
+ }>>>;
24
+ }>;
25
+ declare const AbortCommandSchema: Schema.Struct<{
26
+ readonly type: Schema.Literal<"abort">;
27
+ }>;
28
+ declare const CancelCommandSchema: Schema.Struct<{
29
+ readonly commandId: Schema.String;
30
+ readonly onlyIfPending: Schema.optional<Schema.Boolean>;
31
+ readonly type: Schema.Literal<"cancel">;
32
+ }>;
33
+ /**
34
+ * Compact the Session's context now. It is accepted Session work, queued
35
+ * behind any running work and idempotent by `requestId`; it runs no model
36
+ * turn beyond the summary and never enters model context or a title.
37
+ */
38
+ /** Bounded focus text a manual compaction passes to its summary. */
39
+ export declare const CompactionInstructionsSchema: Schema.String;
40
+ /** Work the accepted-command door admits: a prompt or a compaction request. */
41
+ declare const AcceptedCommandSchema: Schema.Union<readonly [Schema.Struct<{
42
+ readonly delivery: Schema.Literals<readonly ["steer", "followUp"]>;
43
+ readonly requestId: Schema.String;
44
+ readonly type: Schema.Literal<"prompt">;
45
+ readonly text: Schema.String;
46
+ readonly images: Schema.optionalKey<Schema.$Array<Schema.Struct<{
47
+ readonly type: Schema.Literal<"image">;
48
+ readonly data: Schema.String;
49
+ readonly mimeType: Schema.String;
50
+ }>>>;
51
+ }>, Schema.Struct<{
52
+ readonly type: Schema.Literal<"compact">;
53
+ readonly requestId: Schema.String;
54
+ /** Focus for the summary, appended as Pi's "Additional focus". */
55
+ readonly instructions: Schema.optionalKey<Schema.String>;
56
+ }>]>;
57
+ /**
58
+ * The longest Session title, in Unicode code points; the derived first-prompt
59
+ * title uses the same bound.
60
+ */
61
+ export declare const sessionTitleLimit = 120;
62
+ /** One user-set Session title: trimmed, single-line and bounded. */
63
+ export declare const SessionTitleSchema: Schema.String;
64
+ declare const SessionCommandSchema: Schema.Union<readonly [Schema.Struct<{
65
+ readonly delivery: Schema.Literals<readonly ["steer", "followUp"]>;
66
+ readonly requestId: Schema.String;
67
+ readonly type: Schema.Literal<"prompt">;
68
+ readonly text: Schema.String;
69
+ readonly images: Schema.optionalKey<Schema.$Array<Schema.Struct<{
70
+ readonly type: Schema.Literal<"image">;
71
+ readonly data: Schema.String;
72
+ readonly mimeType: Schema.String;
73
+ }>>>;
74
+ }>, Schema.Struct<{
75
+ readonly type: Schema.Literal<"abort">;
76
+ }>, Schema.Struct<{
77
+ readonly commandId: Schema.String;
78
+ readonly onlyIfPending: Schema.optional<Schema.Boolean>;
79
+ readonly type: Schema.Literal<"cancel">;
80
+ }>, Schema.Struct<{
81
+ readonly type: Schema.Literal<"branch">;
82
+ readonly entryId: Schema.String;
83
+ }>, Schema.Struct<{
84
+ readonly type: Schema.Literal<"fork">;
85
+ readonly entryId: Schema.String;
86
+ }>, Schema.Struct<{
87
+ readonly type: Schema.Literal<"operator">;
88
+ readonly requestId: Schema.String;
89
+ readonly author: Schema.Literals<readonly ["operator", "party"]>;
90
+ readonly text: Schema.String;
91
+ }>, Schema.Struct<{
92
+ readonly type: Schema.Literal<"compact">;
93
+ readonly requestId: Schema.String;
94
+ /** Focus for the summary, appended as Pi's "Additional focus". */
95
+ readonly instructions: Schema.optionalKey<Schema.String>;
96
+ }>, Schema.Struct<{
97
+ readonly type: Schema.Literal<"title">;
98
+ readonly title: Schema.NullOr<Schema.String>;
99
+ }>]>;
100
+ declare const ReadOptionsSchema: Schema.Struct<{
101
+ readonly includeSandboxFailures: Schema.optional<Schema.Boolean>;
102
+ readonly limit: Schema.optional<Schema.Int>;
103
+ readonly before: Schema.optional<Schema.String>;
104
+ }>;
105
+ export declare const decodeClientSessionCreationRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
106
+ readonly requestId: string;
107
+ }, Schema.SchemaError>;
108
+ /** The accepted-command door's one decoder for queued Session work. */
109
+ export declare const decodeClientAcceptedCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
110
+ readonly requestId: string;
111
+ readonly type: "prompt";
112
+ readonly text: string;
113
+ readonly delivery: "followUp" | "steer";
114
+ readonly images?: readonly {
115
+ readonly type: "image";
116
+ readonly data: string;
117
+ readonly mimeType: string;
118
+ }[];
119
+ } | {
120
+ readonly requestId: string;
121
+ readonly type: "compact";
122
+ readonly instructions?: string;
123
+ }, Schema.SchemaError>;
124
+ /** Decode one owner-issued identity (command, extension or cursor). */
125
+ export declare const decodeClientIdentity: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<string, Schema.SchemaError>;
126
+ export declare const decodeClientSessionCommand: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
127
+ readonly requestId: string;
128
+ readonly type: "prompt";
129
+ readonly text: string;
130
+ readonly delivery: "followUp" | "steer";
131
+ readonly images?: readonly {
132
+ readonly type: "image";
133
+ readonly data: string;
134
+ readonly mimeType: string;
135
+ }[];
136
+ } | {
137
+ readonly type: "abort";
138
+ } | {
139
+ readonly type: "cancel";
140
+ readonly commandId: string;
141
+ readonly onlyIfPending?: boolean | undefined;
142
+ } | {
143
+ readonly type: "branch";
144
+ readonly entryId: string;
145
+ } | {
146
+ readonly type: "fork";
147
+ readonly entryId: string;
148
+ } | {
149
+ readonly type: "operator";
150
+ readonly requestId: string;
151
+ readonly author: "operator" | "party";
152
+ readonly text: string;
153
+ } | {
154
+ readonly requestId: string;
155
+ readonly type: "compact";
156
+ readonly instructions?: string;
157
+ } | {
158
+ readonly type: "title";
159
+ readonly title: string | null;
160
+ }, Schema.SchemaError>;
161
+ export declare const decodeClientSessionCommandRequest: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
162
+ readonly command: {
163
+ readonly requestId: string;
164
+ readonly type: "prompt";
165
+ readonly text: string;
166
+ readonly delivery: "followUp" | "steer";
167
+ readonly images?: readonly {
168
+ readonly type: "image";
169
+ readonly data: string;
170
+ readonly mimeType: string;
171
+ }[];
172
+ } | {
173
+ readonly type: "abort";
174
+ } | {
175
+ readonly type: "cancel";
176
+ readonly commandId: string;
177
+ readonly onlyIfPending?: boolean | undefined;
178
+ } | {
179
+ readonly type: "branch";
180
+ readonly entryId: string;
181
+ } | {
182
+ readonly type: "fork";
183
+ readonly entryId: string;
184
+ } | {
185
+ readonly type: "operator";
186
+ readonly requestId: string;
187
+ readonly author: "operator" | "party";
188
+ readonly text: string;
189
+ } | {
190
+ readonly requestId: string;
191
+ readonly type: "compact";
192
+ readonly instructions?: string;
193
+ } | {
194
+ readonly type: "title";
195
+ readonly title: string | null;
196
+ };
197
+ }, Schema.SchemaError>;
198
+ export declare const decodeClientReadQuery: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
199
+ readonly includeSandboxFailures?: "true" | undefined;
200
+ readonly limit?: number | undefined;
201
+ readonly before?: string | undefined;
202
+ }, Schema.SchemaError>;
203
+ export declare const decodeClientEventsQuery: (input: unknown, options?: import("effect/SchemaAST").ParseOptions) => Result.Result<{
204
+ readonly includeSandboxFailures?: "true" | undefined;
205
+ readonly limit?: number | undefined;
206
+ readonly after?: string | undefined;
207
+ readonly mode?: "subscribe" | undefined;
208
+ }, Schema.SchemaError>;
209
+ /** Normalized C1 read policy after the public option bag is decoded once. */
210
+ export type ClientReadOptions = Readonly<{
211
+ includeSandboxFailures?: boolean;
212
+ limit: number;
213
+ before?: string;
214
+ }>;
215
+ /** Public Session command inferred from its one runtime parser. */
216
+ export type SessionCommand = Schema.Schema.Type<typeof SessionCommandSchema>;
217
+ /** Public prompt command accepted as durable Session work. */
218
+ export type PromptCommand = Schema.Schema.Type<typeof PromptCommandSchema>;
219
+ /** Cancel the running turn and all queued prompts, retaining their text. */
220
+ export type AbortCommand = Schema.Schema.Type<typeof AbortCommandSchema>;
221
+ /** Public command that cancels exactly one accepted request. */
222
+ export type CancelCommand = Schema.Schema.Type<typeof CancelCommandSchema>;
223
+ /** Public command that selects one complete entry as the active lineage leaf. */
224
+ export type BranchCommand = Extract<SessionCommand, Readonly<{
225
+ type: "branch";
226
+ }>>;
227
+ /** Public command that records one operator or party line without a run. */
228
+ export type OperatorCommand = Extract<SessionCommand, Readonly<{
229
+ type: "operator";
230
+ }>>;
231
+ /** Public command that compacts the Session's context as queued work. */
232
+ export type CompactCommand = Extract<SessionCommand, Readonly<{
233
+ type: "compact";
234
+ }>>;
235
+ /** Accepted Session work the door admits and Watchdog queues. */
236
+ export type AcceptedWork = Schema.Schema.Type<typeof AcceptedCommandSchema>;
237
+ /** Public command that sets or clears the user's Session title. */
238
+ export type TitleCommand = Extract<SessionCommand, Readonly<{
239
+ type: "title";
240
+ }>>;
241
+ /** Public command that creates a new Session from one complete entry lineage. */
242
+ export type ForkCommand = Extract<SessionCommand, Readonly<{
243
+ type: "fork";
244
+ }>>;
245
+ /** Exact C2 replay position after the public option bag is decoded once. */
246
+ export type ClientSubscribeOptions = Readonly<{
247
+ after?: string;
248
+ includeSandboxFailures?: boolean;
249
+ }>;
250
+ /** Decode one ordinary Session-id value without exposing input detail. */
251
+ export declare function decodeClientSessionId(value: string): string;
252
+ /** Decode one opaque session-page cursor; its owner decodes the position. */
253
+ export declare function decodeClientPageCursor(value: string): string;
254
+ /** Decode the exact public Session creation request. */
255
+ export declare function decodeClientSessionCreationRequestId(value: Schema.Schema.Type<typeof SessionCreationRequestSchema>): string;
256
+ /** Decode and normalize the exact public C1 read option bag. */
257
+ export declare function decodeClientReadOptions(value: Schema.Schema.Type<typeof ReadOptionsSchema> | undefined): ClientReadOptions;
258
+ /** Decode the exact public C2 subscribe option bag before cursor classification. */
259
+ export declare function decodeClientSubscribeOptions(value: ClientSubscribeOptions): ClientSubscribeOptions;
260
+ /** Take one decoder result, or reject with a sanitized contract error. */
261
+ export declare function requireDecoded<A, E>(decoded: Result.Result<A, E>, message: string): A;
262
+ export {};