@fungi.computer/truffle 0.1.1 → 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.
Files changed (174) hide show
  1. package/README.md +282 -34
  2. package/dist/auth-cli.d.ts +10 -0
  3. package/dist/auth-cli.js +36 -14
  4. package/dist/fungi-account-command.d.ts +1 -1
  5. package/dist/fungi-account-command.js +6 -3
  6. package/dist/index.d.ts +10 -2
  7. package/dist/index.js +8 -2
  8. package/dist/internal/image-fit-metafile.json +106 -0
  9. package/dist/internal/local-image-fit-worker.mjs +960 -0
  10. package/dist/internal/private-workerd-sandbox-worker.mjs +11 -12
  11. package/dist/internal/sandbox-metafile.json +7 -7
  12. package/dist/local-archive-handoff.d.ts +12 -0
  13. package/dist/local-archive-handoff.js +21 -0
  14. package/dist/local-extensions.d.ts +58 -12
  15. package/dist/local-extensions.js +195 -55
  16. package/dist/local-image-fit.d.ts +30 -0
  17. package/dist/local-image-fit.js +105 -0
  18. package/dist/local-models.d.ts +4 -2
  19. package/dist/local-models.js +11 -6
  20. package/dist/local-session-archives.d.ts +8 -0
  21. package/dist/local-session-archives.js +152 -0
  22. package/dist/local-skill-source.d.ts +18 -3
  23. package/dist/local-skill-source.js +216 -140
  24. package/dist/log-event.d.ts +7 -0
  25. package/dist/log-event.js +8 -4
  26. package/dist/private-bounded-response.d.ts +2 -0
  27. package/dist/private-bounded-response.js +41 -0
  28. package/dist/private-file-credential-store.d.ts +28 -3
  29. package/dist/private-file-credential-store.js +57 -9
  30. package/dist/private-files-patch.d.ts +2 -1
  31. package/dist/private-files-patch.js +21 -3
  32. package/dist/private-fungi-account.d.ts +40 -23
  33. package/dist/private-fungi-account.js +201 -21
  34. package/dist/private-fungi-mcp-connection.d.ts +4 -0
  35. package/dist/private-fungi-mcp-connection.js +25 -6
  36. package/dist/private-fungi-mcp-selection-schema.d.ts +7 -0
  37. package/dist/private-fungi-mcp-selection-schema.js +15 -0
  38. package/dist/private-fungi-mcp-selection.d.ts +6 -6
  39. package/dist/private-fungi-mcp-selection.js +29 -16
  40. package/dist/private-fungi-model-api.js +4 -4
  41. package/dist/private-fungi-model-catalog.d.ts +10 -0
  42. package/dist/private-fungi-model-catalog.js +10 -2
  43. package/dist/private-fungi-model-provider.d.ts +1 -1
  44. package/dist/private-fungi-model-provider.js +6 -1
  45. package/dist/private-fungi-pending-logouts.d.ts +1 -1
  46. package/dist/private-fungi-pending-logouts.js +1 -2
  47. package/dist/private-fungi-service-logout.d.ts +44 -0
  48. package/dist/private-fungi-service-logout.js +59 -0
  49. package/dist/private-invocation-computer.d.ts +24 -3
  50. package/dist/private-invocation-computer.js +101 -62
  51. package/dist/private-invocation-files.d.ts +16 -1
  52. package/dist/private-invocation-files.js +154 -83
  53. package/dist/private-local-acp-stdio.js +3 -0
  54. package/dist/private-local-admission-gate.d.ts +14 -0
  55. package/dist/private-local-admission-gate.js +52 -0
  56. package/dist/private-local-agent-control.d.ts +101 -0
  57. package/dist/private-local-agent-control.js +30 -0
  58. package/dist/private-local-agent-default-model.d.ts +12 -0
  59. package/dist/private-local-agent-default-model.js +31 -0
  60. package/dist/private-local-auth-rpc.d.ts +67 -7
  61. package/dist/private-local-auth-rpc.js +140 -17
  62. package/dist/private-local-bwrap.d.ts +13 -0
  63. package/dist/private-local-bwrap.js +70 -0
  64. package/dist/private-local-client-version.d.ts +5 -0
  65. package/dist/private-local-client-version.js +43 -0
  66. package/dist/private-local-computer-attach.d.ts +3 -3
  67. package/dist/private-local-computer-attach.js +17 -3
  68. package/dist/private-local-computer-processes.d.ts +6 -3
  69. package/dist/private-local-computer-processes.js +55 -31
  70. package/dist/private-local-config-root.d.ts +21 -0
  71. package/dist/private-local-config-root.js +19 -0
  72. package/dist/private-local-containment.d.ts +51 -0
  73. package/dist/private-local-containment.js +161 -0
  74. package/dist/private-local-delegation.d.ts +10 -3
  75. package/dist/private-local-delegation.js +70 -15
  76. package/dist/private-local-effective-model.d.ts +9 -1
  77. package/dist/private-local-effective-model.js +3 -0
  78. package/dist/private-local-exec-environment.d.ts +16 -0
  79. package/dist/private-local-exec-environment.js +11 -0
  80. package/dist/private-local-linux-sandbox.d.ts +8 -0
  81. package/dist/private-local-linux-sandbox.js +67 -0
  82. package/dist/private-local-mail.d.ts +4 -2
  83. package/dist/private-local-mail.js +41 -33
  84. package/dist/private-local-mesh-enrollment.d.ts +34 -0
  85. package/dist/private-local-mesh-enrollment.js +188 -0
  86. package/dist/private-local-mesh-links.d.ts +21 -0
  87. package/dist/private-local-mesh-links.js +229 -0
  88. package/dist/private-local-mesh-record.d.ts +120 -0
  89. package/dist/private-local-mesh-record.js +55 -0
  90. package/dist/private-local-process-identity.d.ts +20 -0
  91. package/dist/private-local-process-identity.js +40 -0
  92. package/dist/private-local-runtime-host.d.ts +64 -13
  93. package/dist/private-local-runtime-host.js +361 -172
  94. package/dist/private-local-sandbox-policy.d.ts +21 -0
  95. package/dist/private-local-sandbox-policy.js +121 -0
  96. package/dist/private-local-sandbox.d.ts +37 -0
  97. package/dist/private-local-sandbox.js +114 -0
  98. package/dist/private-local-seatbelt.d.ts +24 -0
  99. package/dist/private-local-seatbelt.js +68 -0
  100. package/dist/private-local-service-contract.d.ts +91 -11
  101. package/dist/private-local-service-discovery.d.ts +129 -13
  102. package/dist/private-local-service-discovery.js +148 -47
  103. package/dist/private-local-service-lease.d.ts +16 -0
  104. package/dist/private-local-service-lease.js +105 -0
  105. package/dist/private-local-service-listener.d.ts +9 -2
  106. package/dist/private-local-service-listener.js +260 -64
  107. package/dist/private-local-service-log.d.ts +128 -0
  108. package/dist/private-local-service-log.js +321 -0
  109. package/dist/private-local-service-owner.d.ts +87 -1519
  110. package/dist/private-local-service-owner.js +1069 -71
  111. package/dist/private-local-service-process.js +3 -1
  112. package/dist/private-local-service-termination.d.ts +7 -0
  113. package/dist/private-local-service-termination.js +67 -0
  114. package/dist/private-local-service.d.ts +31 -2
  115. package/dist/private-local-service.js +402 -126
  116. package/dist/private-local-session-discovery.d.ts +52 -5
  117. package/dist/private-local-session-discovery.js +132 -11
  118. package/dist/private-local-shiitake-host.js +2 -2
  119. package/dist/private-local-startup-model.d.ts +51 -0
  120. package/dist/private-local-startup-model.js +86 -0
  121. package/dist/private-local-stop-all.d.ts +27 -0
  122. package/dist/private-local-stop-all.js +26 -0
  123. package/dist/private-local-ui-attachment.d.ts +19 -0
  124. package/dist/private-local-ui-attachment.js +71 -0
  125. package/dist/private-local-worker-server.d.ts +1 -0
  126. package/dist/private-local-worker-server.js +13 -5
  127. package/dist/private-mcp-form-contract.d.ts +186 -0
  128. package/dist/private-mcp-form-contract.js +53 -0
  129. package/dist/private-mcp-form-elicitation.d.ts +18 -0
  130. package/dist/private-mcp-form-elicitation.js +97 -0
  131. package/dist/private-mcp-form-session.d.ts +172 -0
  132. package/dist/private-mcp-form-session.js +148 -0
  133. package/dist/private-openai-claims.d.ts +30 -0
  134. package/dist/private-openai-claims.js +69 -0
  135. package/dist/private-oyster-mcp-auth.d.ts +13 -0
  136. package/dist/private-oyster-mcp-auth.js +57 -0
  137. package/dist/private-provider-rejection.d.ts +15 -0
  138. package/dist/private-provider-rejection.js +24 -0
  139. package/dist/private-sqlite-owner.d.ts +34 -2
  140. package/dist/private-sqlite-owner.js +103 -37
  141. package/dist/private-team-computers.d.ts +4 -4
  142. package/dist/private-team-computers.js +11 -2
  143. package/dist/seatbelt/safe-base.sbpl +79 -0
  144. package/dist/subscription-activation.d.ts +9 -0
  145. package/dist/subscription-activation.js +62 -0
  146. package/dist/subscription-identity.d.ts +23 -0
  147. package/dist/subscription-identity.js +124 -0
  148. package/dist/subscription-turn.d.ts +17 -0
  149. package/dist/subscription-turn.js +143 -0
  150. package/dist/team-apps.d.ts +2 -2
  151. package/dist/team-apps.js +7 -2
  152. package/native/bin/LICENSE.bubblewrap +502 -0
  153. package/native/bin/LICENSE.libcap +112 -0
  154. package/native/bin/LICENSE.sandbox-runtime +201 -0
  155. package/native/bin/SOURCE.bubblewrap.tar.xz +0 -0
  156. package/native/bin/bwrap-build-source/Dockerfile +48 -0
  157. package/native/bin/bwrap-build-source/README.md +96 -0
  158. package/native/bin/bwrap-build-source/build.mjs +52 -0
  159. package/native/bin/bwrap-build-source/linux-arm64.ini +14 -0
  160. package/native/bin/bwrap-build-source/pin.mjs +21 -0
  161. package/native/bin/bwrap-build-source/record.mjs +74 -0
  162. package/native/bin/bwrap-build-source/vendor/LICENSE.sandbox-runtime +201 -0
  163. package/native/bin/bwrap-build-source/vendor/README.md +23 -0
  164. package/native/bin/bwrap-build-source/vendor/seccomp-unix-block.c +280 -0
  165. package/native/bin/bwrap-build.json +44 -0
  166. package/native/bin/fungi-bwrap +0 -0
  167. package/native/bin/fungi-bwrap.sha256 +1 -0
  168. package/native/bin/fungi-seccomp.bpf +0 -0
  169. package/native/bin/fungi-seccomp.bpf.sha256 +1 -0
  170. package/package.json +44 -31
  171. package/dist/private-local-model-settings.d.ts +0 -5
  172. package/dist/private-local-model-settings.js +0 -31
  173. package/dist/private-local-subagents.d.ts +0 -27
  174. package/dist/private-local-subagents.js +0 -77
@@ -1,1567 +1,135 @@
1
+ import type { Accepted, CancelResult } from "@fungi.computer/shiitake";
2
+ import { type PrivateLocalConfigRoot } from "./private-local-config-root.js";
3
+ import type { ServiceLogLifecycle } from "./private-local-service-log.js";
4
+ import type { StopAllResult } from "./private-local-stop-all.js";
5
+ import { type LocalExtensions } from "./local-extensions.js";
1
6
  import type { PrivateLocalServiceSelection, PrivateLocalSessionCreation } from "./private-local-service-contract.js";
2
7
  import { openPrivateLocalRuntimeHost, type PrivateLocalRuntimeHost } from "./private-local-runtime-host.js";
3
- export type LocalServiceRuntime = Pick<PrivateLocalRuntimeHost, "databasePath" | "agentId" | "getSession" | "effectiveModel" | "setModel" | "assertModelReady" | "listSessions" | "createSession" | "deleteSession" | "extensions" | "bindSessionPath" | "acceptMail" | "readSettlement" | "close">;
8
+ import type { LocalUiAttachment } from "./private-local-ui-attachment.js";
9
+ export type LocalServiceRuntime = Pick<PrivateLocalRuntimeHost, "databasePath" | "agentId" | "name" | "getSession" | "effectiveModel" | "setModel" | "setArchived" | "setRequireSandbox" | "sandboxStatus" | "pendingDelegation" | "assertModelReady" | "listSessions" | "createSession" | "deleteSession" | "extensions" | "prepareReload" | "bindSessionPath" | "acceptMail" | "readSettlement" | "idle" | "close">;
4
10
  export declare class LocalSessionPathConflict extends Error {
5
11
  readonly name = "LocalSessionPathConflict";
6
12
  constructor();
7
13
  }
8
- export type OpenLocalServiceRuntime = (options: Parameters<typeof openPrivateLocalRuntimeHost>[0]) => Promise<LocalServiceRuntime>;
14
+ /**
15
+ * A folder holds several Agent stores and the request chose none of them.
16
+ * The service never picks one for the caller; --agent, --db or the
17
+ * landing screen does.
18
+ */
19
+ export declare class LocalAgentSelectionAmbiguous extends Error {
20
+ readonly name = "LocalAgentSelectionAmbiguous";
21
+ readonly agentIds: readonly string[];
22
+ constructor(agentIds: readonly string[]);
23
+ }
24
+ export type OpenLocalServiceRuntime = (
25
+ /** Selected by the service, never by a client selection or Agent Files root. */
26
+ options: Parameters<typeof openPrivateLocalRuntimeHost>[0] & Readonly<{
27
+ configRoot: PrivateLocalConfigRoot;
28
+ }>) => Promise<LocalServiceRuntime>;
9
29
  /** One service owns each store, independently of how many clients select it. */
10
- export declare function createLocalServiceOwners(openRuntime?: OpenLocalServiceRuntime, recoveryDirectory?: string): {
30
+ export declare function createLocalServiceOwners(openRuntime?: OpenLocalServiceRuntime, recoveryDirectory?: string,
31
+ /** The installed-extension owner that decides what each Agent holds. */
32
+ suppliedExtensions?: Pick<LocalExtensions, "assertHeldByAgent" | "enableAgent">,
33
+ /** How often idle Agents are checked; one is released on its second idle check. */
34
+ idleSweepMs?: number,
35
+ /** Read the recovery manifest; tests can hold this I/O independently of opens. */
36
+ readRecoveryManifest?: (path: string) => Promise<string>,
37
+ /** Report only the classification, never the manifest or exception text. */
38
+ onRecoveryDisabled?: ServiceLogLifecycle["recoveryDisabled"], configRoot?: PrivateLocalConfigRoot): {
39
+ refreshMesh: () => Promise<void>;
11
40
  createSession: (creation: PrivateLocalSessionCreation) => Promise<{
12
41
  agentId: string;
13
42
  databasePath: string;
43
+ invocationRoot: string;
14
44
  sessionId: string;
15
45
  session: Readonly<{
16
46
  address: string;
17
47
  command: import("@fungi.computer/shiitake").SessionCommandHandler;
48
+ withdraw: (requestId: string) => Promise<import("@fungi.computer/shiitake/client").WithdrawResult>;
18
49
  abort: () => Promise<void>;
19
- send: (text: string, options?: import("@fungi.computer/shiitake").SendOptions) => Promise<import("@fungi.computer/shiitake").Accepted>;
50
+ send: (text: string, options?: import("@fungi.computer/shiitake").SendOptions) => Promise<Accepted>;
20
51
  cancel: (input: Readonly<{
21
52
  commandId: string;
22
53
  onlyIfPending?: boolean;
23
- }>) => Promise<import("@fungi.computer/shiitake").CancelResult>;
54
+ }>) => Promise<CancelResult>;
55
+ latestPending: () => Promise<import("@fungi.computer/shiitake/client").SessionPendingPrompt | null>;
24
56
  extension: (extensionId: string) => import("@fungi.computer/shiitake").SessionExtensionControls;
25
57
  modelPreference: Readonly<{
26
- read: () => Promise<import("@fungi.computer/shiitake/model-preference").ModelPreference | null>;
27
- set: (preference: import("@fungi.computer/shiitake/model-preference").ModelPreference | null) => Promise<void>;
58
+ read: () => Promise<import("@fungi.computer/shiitake").ModelPreference | null>;
59
+ set: (preference: import("@fungi.computer/shiitake").ModelPreference | null) => Promise<void>;
28
60
  }>;
29
61
  read: (input?: import("@fungi.computer/shiitake").ReadOptions) => Promise<import("@fungi.computer/shiitake").SessionSnapshot>;
30
62
  subscribe: (input: import("@fungi.computer/shiitake").SubscribeOptions) => AsyncIterable<import("@fungi.computer/shiitake").SessionFrame>;
31
63
  watch: (input?: import("@fungi.computer/shiitake").WatchOptions) => Promise<import("@fungi.computer/shiitake").SessionWatch>;
32
64
  }>;
33
- effectiveModel: (sessionId: string, signal: AbortSignal) => Promise<import("./private-local-effective-model.js").PrivateLocalEffectiveModel>;
34
- routes: import("hono/hono-base").HonoBase<import("@fungi.computer/shiitake/http").ShiitakeHttpEnv, {
35
- "/extensions": {
36
- $get: {
37
- input: {};
38
- output: readonly {
39
- readonly id: string;
40
- readonly version: string;
41
- readonly revision: string;
42
- readonly status: "running" | "stopped";
43
- readonly reason: string | null;
44
- readonly stoppedAt: number | null;
45
- }[];
46
- outputFormat: "json";
47
- status: 200;
48
- };
49
- };
50
- } & {
51
- "/extensions/:extensionId/resume": {
52
- $post: {
53
- input: {
54
- param: {
55
- extensionId: string;
56
- };
57
- };
58
- output: {
59
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
60
- readonly _tag: "ShiitakeError";
61
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
62
- readonly message: string;
63
- readonly requestId?: string | undefined;
64
- };
65
- outputFormat: "json";
66
- status: 400;
67
- } | {
68
- input: {
69
- param: {
70
- extensionId: string;
71
- };
72
- };
73
- output: {
74
- readonly id: string;
75
- readonly version: string;
76
- readonly revision: string;
77
- readonly status: "running" | "stopped";
78
- readonly reason: string | null;
79
- readonly stoppedAt: number | null;
80
- };
81
- outputFormat: "json";
82
- status: 200;
83
- };
84
- };
85
- } & {
86
- "/extensions/:extensionId/commands/:command": {
87
- $post: {
88
- input: {
89
- param: {
90
- extensionId: string;
91
- } & {
92
- command: string;
93
- };
94
- };
95
- output: {};
96
- outputFormat: string;
97
- status: import("hono/utils/http-status").StatusCode;
98
- };
99
- };
100
- } & {
101
- "/sessions/:sessionId/extensions/:extensionId/commands/:command": {
102
- $post: {
103
- input: {
104
- param: {
105
- extensionId: string;
106
- } & {
107
- command: string;
108
- } & {
109
- sessionId: string;
110
- };
111
- };
112
- output: {};
113
- outputFormat: string;
114
- status: import("hono/utils/http-status").StatusCode;
115
- };
116
- };
117
- } & {
118
- "/sessions": {
119
- $post: {
120
- input: {
121
- json: {
122
- readonly requestId: string;
123
- };
124
- };
125
- output: {
126
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
127
- readonly _tag: "ShiitakeError";
128
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
129
- readonly message: string;
130
- readonly requestId?: string | undefined;
131
- };
132
- outputFormat: "json";
133
- status: 400;
134
- } | {
135
- input: {
136
- json: {
137
- readonly requestId: string;
138
- };
139
- };
140
- output: {
141
- sessionId: string;
142
- };
143
- outputFormat: "json";
144
- status: 201;
145
- };
146
- };
147
- } & {
148
- "/sessions/:sessionId": {
149
- $delete: {
150
- input: {
151
- param: {
152
- sessionId: string;
153
- };
154
- };
155
- output: {
156
- deleted: boolean;
157
- };
158
- outputFormat: "json";
159
- status: 200;
160
- };
161
- };
162
- } & {
163
- "/sessions": {
164
- $get: {
165
- input: {};
166
- output: {
167
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
168
- readonly _tag: "ShiitakeError";
169
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
170
- readonly message: string;
171
- readonly requestId?: string | undefined;
172
- };
173
- outputFormat: "json";
174
- status: 400;
175
- } | {
176
- input: {};
177
- output: {
178
- readonly sessions: readonly ({
179
- readonly sessionId: string;
180
- readonly state: "unavailable";
181
- } | {
182
- readonly createdAt: number;
183
- readonly lastActivityAt: number;
184
- readonly settledAt?: number | undefined;
185
- readonly title: string;
186
- readonly state: import("@fungi.computer/shiitake").SessionInboxState;
187
- readonly sessionId: string;
188
- })[];
189
- readonly next: string | undefined;
190
- };
191
- outputFormat: "json";
192
- status: 200;
193
- };
194
- };
195
- } & {
196
- "/sessions/:sessionId/model-preference": {
197
- $get: {
198
- input: {
199
- param: {
200
- sessionId: string;
201
- };
202
- };
203
- output: {
204
- readonly providerId: string;
205
- readonly modelId: string;
206
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
207
- } | null;
208
- outputFormat: "json";
209
- status: 200;
210
- };
211
- };
212
- } & {
213
- "/sessions/:sessionId/model-preference": {
214
- $put: {
215
- input: {
216
- json: {
217
- readonly providerId: string;
218
- readonly modelId: string;
219
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
220
- } | null;
221
- } & {
222
- param: {
223
- sessionId: string;
224
- };
225
- };
226
- output: {
227
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
228
- readonly _tag: "ShiitakeError";
229
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
230
- readonly message: string;
231
- readonly requestId?: string | undefined;
232
- };
233
- outputFormat: "json";
234
- status: 400;
235
- } | {
236
- input: {
237
- json: {
238
- readonly providerId: string;
239
- readonly modelId: string;
240
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
241
- } | null;
242
- } & {
243
- param: {
244
- sessionId: string;
245
- };
246
- };
247
- output: null;
248
- outputFormat: "body";
249
- status: 204;
250
- };
251
- };
252
- } & {
253
- "/sessions/:sessionId/command": {
254
- $post: {
255
- input: {
256
- json: {
257
- readonly command: {
258
- readonly requestId: string;
259
- readonly type: "prompt";
260
- readonly text: string;
261
- readonly delivery: "followUp" | "steer";
262
- readonly images?: readonly {
263
- readonly type: "image";
264
- readonly data: string;
265
- readonly mimeType: string;
266
- }[];
267
- } | {
268
- readonly type: "abort";
269
- } | {
270
- readonly type: "cancel";
271
- readonly commandId: string;
272
- readonly onlyIfPending?: boolean | undefined;
273
- } | {
274
- readonly type: "branch";
275
- readonly entryId: string;
276
- } | {
277
- readonly type: "fork";
278
- readonly entryId: string;
279
- } | {
280
- readonly type: "operator";
281
- readonly requestId: string;
282
- readonly author: "operator" | "party";
283
- readonly text: string;
284
- } | {
285
- readonly requestId: string;
286
- readonly type: "compact";
287
- readonly instructions?: string;
288
- } | {
289
- readonly type: "title";
290
- readonly title: string | null;
291
- };
292
- };
293
- } & {
294
- param: {
295
- sessionId: string;
296
- };
297
- };
298
- output: {
299
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
300
- readonly _tag: "ShiitakeError";
301
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
302
- readonly message: string;
303
- readonly requestId?: string | undefined;
304
- };
305
- outputFormat: "json";
306
- status: 400;
307
- } | {
308
- input: {
309
- json: {
310
- readonly command: {
311
- readonly requestId: string;
312
- readonly type: "prompt";
313
- readonly text: string;
314
- readonly delivery: "followUp" | "steer";
315
- readonly images?: readonly {
316
- readonly type: "image";
317
- readonly data: string;
318
- readonly mimeType: string;
319
- }[];
320
- } | {
321
- readonly type: "abort";
322
- } | {
323
- readonly type: "cancel";
324
- readonly commandId: string;
325
- readonly onlyIfPending?: boolean | undefined;
326
- } | {
327
- readonly type: "branch";
328
- readonly entryId: string;
329
- } | {
330
- readonly type: "fork";
331
- readonly entryId: string;
332
- } | {
333
- readonly type: "operator";
334
- readonly requestId: string;
335
- readonly author: "operator" | "party";
336
- readonly text: string;
337
- } | {
338
- readonly requestId: string;
339
- readonly type: "compact";
340
- readonly instructions?: string;
341
- } | {
342
- readonly type: "title";
343
- readonly title: string | null;
344
- };
345
- };
346
- } & {
347
- param: {
348
- sessionId: string;
349
- };
350
- };
351
- output: null;
352
- outputFormat: "body";
353
- status: 204;
354
- } | {
355
- input: {
356
- json: {
357
- readonly command: {
358
- readonly requestId: string;
359
- readonly type: "prompt";
360
- readonly text: string;
361
- readonly delivery: "followUp" | "steer";
362
- readonly images?: readonly {
363
- readonly type: "image";
364
- readonly data: string;
365
- readonly mimeType: string;
366
- }[];
367
- } | {
368
- readonly type: "abort";
369
- } | {
370
- readonly type: "cancel";
371
- readonly commandId: string;
372
- readonly onlyIfPending?: boolean | undefined;
373
- } | {
374
- readonly type: "branch";
375
- readonly entryId: string;
376
- } | {
377
- readonly type: "fork";
378
- readonly entryId: string;
379
- } | {
380
- readonly type: "operator";
381
- readonly requestId: string;
382
- readonly author: "operator" | "party";
383
- readonly text: string;
384
- } | {
385
- readonly requestId: string;
386
- readonly type: "compact";
387
- readonly instructions?: string;
388
- } | {
389
- readonly type: "title";
390
- readonly title: string | null;
391
- };
392
- };
393
- } & {
394
- param: {
395
- sessionId: string;
396
- };
397
- };
398
- output: {
399
- readonly status: "accepted";
400
- readonly commandId: string;
401
- } | {
402
- readonly status: "too_late";
403
- readonly commandId: string;
404
- } | {
405
- readonly sessionId: string;
406
- };
407
- outputFormat: "json";
408
- status: 200;
409
- };
410
- };
411
- } & {
412
- "/sessions/:sessionId": {
413
- $get: {
414
- input: {
415
- query: {
416
- readonly includeSandboxFailures?: "true" | undefined;
417
- readonly limit?: number | undefined;
418
- readonly before?: string | undefined;
419
- };
420
- } & {
421
- param: {
422
- sessionId: string;
423
- };
424
- };
425
- output: {
426
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
427
- readonly _tag: "ShiitakeError";
428
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
429
- readonly message: string;
430
- readonly requestId?: string | undefined;
431
- };
432
- outputFormat: "json";
433
- status: 400;
434
- } | {
435
- input: {
436
- query: {
437
- readonly includeSandboxFailures?: "true" | undefined;
438
- readonly limit?: number | undefined;
439
- readonly before?: string | undefined;
440
- };
441
- } & {
442
- param: {
443
- sessionId: string;
444
- };
445
- };
446
- output: {
447
- readonly sessionId: string;
448
- readonly cursor: string | null;
449
- readonly hasMore: boolean;
450
- readonly oldestCursor?: string | null | undefined;
451
- readonly messages: readonly {
452
- readonly meta?: any;
453
- readonly origin?: {
454
- readonly extensionId: string;
455
- readonly correlation: string | null;
456
- } | undefined;
457
- readonly id: string;
458
- readonly sequence: number;
459
- readonly commandId: string | null;
460
- readonly value: {
461
- role: "system";
462
- content: string | {
463
- type: "text";
464
- text: string;
465
- textSignature?: string | undefined;
466
- }[];
467
- sections?: {
468
- [x: string]: string | null;
469
- } | undefined;
470
- toolsAdded?: {
471
- name: string;
472
- description: string;
473
- parameters: never;
474
- constrainedSampling?: false | {
475
- type: "json_schema";
476
- strict: "prefer" | "require";
477
- } | {
478
- type: "grammar";
479
- variants: {
480
- openai_lark?: string | undefined;
481
- openai_regex?: string | undefined;
482
- };
483
- } | undefined;
484
- }[] | undefined;
485
- toolsRemoved?: {
486
- name: string;
487
- }[] | undefined;
488
- timestamp: number;
489
- } | {
490
- role: "user";
491
- content: string | ({
492
- type: "text";
493
- text: string;
494
- textSignature?: string | undefined;
495
- } | {
496
- type: "image";
497
- data: string;
498
- mimeType: string;
499
- })[];
500
- timestamp: number;
501
- } | {
502
- role: "assistant";
503
- content: ({
504
- type: "text";
505
- text: string;
506
- textSignature?: string | undefined;
507
- } | {
508
- type: "toolCall";
509
- id: string;
510
- name: string;
511
- arguments: {
512
- [x: string]: any;
513
- };
514
- thoughtSignature?: string | undefined;
515
- namespace?: string | undefined;
516
- } | {
517
- type: "thinking";
518
- thinking: string;
519
- thinkingSignature?: string | undefined;
520
- redacted?: boolean | undefined;
521
- })[];
522
- api: import("@earendil-works/pi-ai").Api;
523
- provider: import("@earendil-works/pi-ai").ProviderId;
524
- model: string;
525
- responseModel?: string | undefined;
526
- responseId?: string | undefined;
527
- providerThinkingLevel?: string | undefined;
528
- thinkingLevel?: import("@earendil-works/pi-ai").ModelThinkingLevel | undefined;
529
- diagnostics?: {
530
- type: string;
531
- timestamp: number;
532
- error?: {
533
- name?: string | undefined;
534
- message: string;
535
- stack?: string | undefined;
536
- code?: string | number | undefined;
537
- } | undefined;
538
- details?: {
539
- [x: string]: any;
540
- } | undefined;
541
- }[] | undefined;
542
- usage: {
543
- input: number;
544
- output: number;
545
- cacheRead: number;
546
- cacheWrite: number;
547
- cacheWrite1h?: number | undefined;
548
- reasoning?: number | undefined;
549
- totalTokens: number;
550
- cost: {
551
- input: number;
552
- output: number;
553
- cacheRead: number;
554
- cacheWrite: number;
555
- total: number;
556
- };
557
- };
558
- stopReason: import("@earendil-works/pi-ai").StopReason;
559
- deferred?: {
560
- provider: string;
561
- modelId: string;
562
- api: string;
563
- id: string;
564
- expiresAt?: number | undefined;
565
- pollAfterMs?: number | undefined;
566
- data?: any;
567
- } | undefined;
568
- errorMessage?: string | undefined;
569
- rawStopReason?: string | undefined;
570
- endTurn?: boolean | undefined;
571
- timestamp: number;
572
- } | {
573
- role: "toolResult";
574
- toolCallId: string;
575
- toolName: string;
576
- content: ({
577
- type: "text";
578
- text: string;
579
- textSignature?: string | undefined;
580
- } | {
581
- type: "image";
582
- data: string;
583
- mimeType: string;
584
- })[];
585
- details?: any;
586
- usage?: {
587
- input: number;
588
- output: number;
589
- cacheRead: number;
590
- cacheWrite: number;
591
- cacheWrite1h?: number | undefined;
592
- reasoning?: number | undefined;
593
- totalTokens: number;
594
- cost: {
595
- input: number;
596
- output: number;
597
- cacheRead: number;
598
- cacheWrite: number;
599
- total: number;
600
- };
601
- } | undefined;
602
- nestedCalls?: {
603
- calls: {
604
- id: string;
605
- name: string;
606
- arguments?: {
607
- [x: string]: any;
608
- } | undefined;
609
- argumentsBytes?: number | undefined;
610
- status: "ok" | "error" | "unfinished";
611
- durationMs?: number | undefined;
612
- error?: string | undefined;
613
- }[];
614
- complete: boolean;
615
- } | undefined;
616
- isError: boolean;
617
- timestamp: number;
618
- };
619
- }[];
620
- readonly terminals: readonly {
621
- readonly commandId: string;
622
- readonly outcome: "completed" | "cancelled" | "failed" | "interrupted";
623
- readonly sequence: number;
624
- readonly diagnostic: string | null;
625
- readonly meta?: any;
626
- }[];
627
- readonly compactions?: readonly {
628
- readonly id: string;
629
- readonly sequence: number;
630
- readonly at: number;
631
- readonly tokensBefore: number;
632
- readonly tokensAfter: number | null;
633
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger | null;
634
- }[] | undefined;
635
- readonly compactionNotices?: readonly {
636
- readonly id: string;
637
- readonly sequence: number;
638
- readonly at: number;
639
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger;
640
- readonly result: "nothing_to_compact" | "failed";
641
- readonly diagnostic: string | null;
642
- }[] | undefined;
643
- readonly sandboxFailures?: readonly {
644
- readonly kind: "sandbox_failure";
645
- readonly ref: string;
646
- readonly executionId: string;
647
- readonly adapter: string;
648
- readonly buildSha: string | null;
649
- readonly tag: "Unknown" | "SourceInvalid" | "GuestThrew" | "DeadlineExceeded" | "Cancelled" | "DispatchLost" | "SandboxCrashed" | "BadResponse" | "ResultTooLarge" | "ResultNotJson" | "CapabilityFailed";
650
- readonly fields: {
651
- readonly [x: string]: any;
652
- };
653
- readonly healthAlert: boolean;
654
- }[] | undefined;
655
- readonly pending: {
656
- readonly total: number;
657
- readonly prompts: readonly {
658
- readonly meta?: any;
659
- readonly origin?: {
660
- readonly extensionId: string;
661
- readonly correlation: string | null;
662
- } | undefined;
663
- readonly commandId: string;
664
- readonly text: string;
665
- readonly images?: readonly {
666
- readonly type: "image";
667
- readonly data: string;
668
- readonly mimeType: string;
669
- }[] | undefined;
670
- readonly delivery: import("@fungi.computer/shiitake").PromptDelivery;
671
- }[];
672
- readonly hasMore: boolean;
673
- };
674
- readonly activity: {
675
- readonly queue: {
676
- readonly state: "idle";
677
- } | {
678
- readonly state: "queued";
679
- readonly commandId: string;
680
- readonly runningWork: {
681
- readonly kind: "session";
682
- readonly sessionId: string;
683
- readonly commandId: string;
684
- } | {
685
- readonly kind: "host";
686
- readonly lane: string;
687
- readonly jobId: string;
688
- } | null;
689
- } | {
690
- readonly state: "running";
691
- readonly commandId: string;
692
- };
693
- readonly cancellationRequested: boolean;
694
- readonly retry: {
695
- readonly attempt: number;
696
- readonly maxAttempts: number;
697
- readonly delayMs: number;
698
- readonly errorMessage: string;
699
- readonly scheduledAt: number;
700
- } | null;
701
- readonly activeTool: string | null;
702
- readonly lastModelChoiceSequence: number | null;
703
- readonly compaction: {
704
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger;
705
- } | null;
706
- };
707
- readonly progress: {
708
- readonly messageId: string;
709
- readonly revision: number;
710
- readonly text: string;
711
- readonly thinking: string;
712
- readonly textTruncated: boolean;
713
- readonly thinkingTruncated: boolean;
714
- } | null;
715
- readonly extensions: {
716
- readonly [x: string]: {
717
- readonly status: "running";
718
- readonly revision: string;
719
- readonly value: any;
720
- readonly catalog?: any;
721
- } | {
722
- readonly status: "stopped";
723
- readonly revision: string;
724
- readonly reason: string;
725
- };
726
- };
727
- readonly attention: readonly {
728
- readonly id: string;
729
- readonly kind: string;
730
- readonly summary: string;
731
- readonly since: number;
732
- readonly extensionId: string;
733
- readonly expiresAt?: number | undefined;
734
- }[];
735
- readonly context?: {
736
- readonly tokens: number;
737
- readonly window: number | null;
738
- } | undefined;
739
- };
740
- outputFormat: "json";
741
- status: 200;
742
- };
743
- };
744
- } & {
745
- "/sessions/:sessionId/events": {
746
- $get: {
747
- input: {
748
- query: {
749
- readonly includeSandboxFailures?: "true" | undefined;
750
- readonly limit?: number | undefined;
751
- readonly after?: string | undefined;
752
- readonly mode?: "subscribe" | undefined;
753
- };
754
- } & {
755
- param: {
756
- sessionId: string;
757
- };
758
- };
759
- output: {};
760
- outputFormat: string;
761
- status: import("hono/utils/http-status").StatusCode;
762
- } | {
763
- input: {
764
- query: {
765
- readonly includeSandboxFailures?: "true" | undefined;
766
- readonly limit?: number | undefined;
767
- readonly after?: string | undefined;
768
- readonly mode?: "subscribe" | undefined;
769
- };
770
- } & {
771
- param: {
772
- sessionId: string;
773
- };
774
- };
775
- output: {
776
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
777
- readonly _tag: "ShiitakeError";
778
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
779
- readonly message: string;
780
- readonly requestId?: string | undefined;
781
- };
782
- outputFormat: "json";
783
- status: 400;
784
- };
785
- };
786
- }, "/", "/sessions/:sessionId/events">;
65
+ /** End this selection's use; the mounted route reopens the Agent later. */
66
+ release: () => void;
787
67
  }>;
788
68
  select: (selection: PrivateLocalServiceSelection, createRequestId?: string) => Promise<{
789
69
  agentId: string;
790
70
  databasePath: string;
71
+ invocationRoot: string;
791
72
  sessionId: string;
792
73
  session: Readonly<{
793
74
  address: string;
794
75
  command: import("@fungi.computer/shiitake").SessionCommandHandler;
76
+ withdraw: (requestId: string) => Promise<import("@fungi.computer/shiitake/client").WithdrawResult>;
795
77
  abort: () => Promise<void>;
796
- send: (text: string, options?: import("@fungi.computer/shiitake").SendOptions) => Promise<import("@fungi.computer/shiitake").Accepted>;
78
+ send: (text: string, options?: import("@fungi.computer/shiitake").SendOptions) => Promise<Accepted>;
797
79
  cancel: (input: Readonly<{
798
80
  commandId: string;
799
81
  onlyIfPending?: boolean;
800
- }>) => Promise<import("@fungi.computer/shiitake").CancelResult>;
82
+ }>) => Promise<CancelResult>;
83
+ latestPending: () => Promise<import("@fungi.computer/shiitake/client").SessionPendingPrompt | null>;
801
84
  extension: (extensionId: string) => import("@fungi.computer/shiitake").SessionExtensionControls;
802
85
  modelPreference: Readonly<{
803
- read: () => Promise<import("@fungi.computer/shiitake/model-preference").ModelPreference | null>;
804
- set: (preference: import("@fungi.computer/shiitake/model-preference").ModelPreference | null) => Promise<void>;
86
+ read: () => Promise<import("@fungi.computer/shiitake").ModelPreference | null>;
87
+ set: (preference: import("@fungi.computer/shiitake").ModelPreference | null) => Promise<void>;
805
88
  }>;
806
89
  read: (input?: import("@fungi.computer/shiitake").ReadOptions) => Promise<import("@fungi.computer/shiitake").SessionSnapshot>;
807
90
  subscribe: (input: import("@fungi.computer/shiitake").SubscribeOptions) => AsyncIterable<import("@fungi.computer/shiitake").SessionFrame>;
808
91
  watch: (input?: import("@fungi.computer/shiitake").WatchOptions) => Promise<import("@fungi.computer/shiitake").SessionWatch>;
809
92
  }>;
810
- effectiveModel: (sessionId: string, signal: AbortSignal) => Promise<import("./private-local-effective-model.js").PrivateLocalEffectiveModel>;
811
- routes: import("hono/hono-base").HonoBase<import("@fungi.computer/shiitake/http").ShiitakeHttpEnv, {
812
- "/extensions": {
813
- $get: {
814
- input: {};
815
- output: readonly {
816
- readonly id: string;
817
- readonly version: string;
818
- readonly revision: string;
819
- readonly status: "running" | "stopped";
820
- readonly reason: string | null;
821
- readonly stoppedAt: number | null;
822
- }[];
823
- outputFormat: "json";
824
- status: 200;
825
- };
826
- };
827
- } & {
828
- "/extensions/:extensionId/resume": {
829
- $post: {
830
- input: {
831
- param: {
832
- extensionId: string;
833
- };
834
- };
835
- output: {
836
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
837
- readonly _tag: "ShiitakeError";
838
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
839
- readonly message: string;
840
- readonly requestId?: string | undefined;
841
- };
842
- outputFormat: "json";
843
- status: 400;
844
- } | {
845
- input: {
846
- param: {
847
- extensionId: string;
848
- };
849
- };
850
- output: {
851
- readonly id: string;
852
- readonly version: string;
853
- readonly revision: string;
854
- readonly status: "running" | "stopped";
855
- readonly reason: string | null;
856
- readonly stoppedAt: number | null;
857
- };
858
- outputFormat: "json";
859
- status: 200;
860
- };
861
- };
862
- } & {
863
- "/extensions/:extensionId/commands/:command": {
864
- $post: {
865
- input: {
866
- param: {
867
- extensionId: string;
868
- } & {
869
- command: string;
870
- };
871
- };
872
- output: {};
873
- outputFormat: string;
874
- status: import("hono/utils/http-status").StatusCode;
875
- };
876
- };
877
- } & {
878
- "/sessions/:sessionId/extensions/:extensionId/commands/:command": {
879
- $post: {
880
- input: {
881
- param: {
882
- extensionId: string;
883
- } & {
884
- command: string;
885
- } & {
886
- sessionId: string;
887
- };
888
- };
889
- output: {};
890
- outputFormat: string;
891
- status: import("hono/utils/http-status").StatusCode;
892
- };
893
- };
894
- } & {
895
- "/sessions": {
896
- $post: {
897
- input: {
898
- json: {
899
- readonly requestId: string;
900
- };
901
- };
902
- output: {
903
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
904
- readonly _tag: "ShiitakeError";
905
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
906
- readonly message: string;
907
- readonly requestId?: string | undefined;
908
- };
909
- outputFormat: "json";
910
- status: 400;
911
- } | {
912
- input: {
913
- json: {
914
- readonly requestId: string;
915
- };
916
- };
917
- output: {
918
- sessionId: string;
919
- };
920
- outputFormat: "json";
921
- status: 201;
922
- };
923
- };
924
- } & {
925
- "/sessions/:sessionId": {
926
- $delete: {
927
- input: {
928
- param: {
929
- sessionId: string;
930
- };
931
- };
932
- output: {
933
- deleted: boolean;
934
- };
935
- outputFormat: "json";
936
- status: 200;
937
- };
938
- };
939
- } & {
940
- "/sessions": {
941
- $get: {
942
- input: {};
943
- output: {
944
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
945
- readonly _tag: "ShiitakeError";
946
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
947
- readonly message: string;
948
- readonly requestId?: string | undefined;
949
- };
950
- outputFormat: "json";
951
- status: 400;
952
- } | {
953
- input: {};
954
- output: {
955
- readonly sessions: readonly ({
956
- readonly sessionId: string;
957
- readonly state: "unavailable";
958
- } | {
959
- readonly createdAt: number;
960
- readonly lastActivityAt: number;
961
- readonly settledAt?: number | undefined;
962
- readonly title: string;
963
- readonly state: import("@fungi.computer/shiitake").SessionInboxState;
964
- readonly sessionId: string;
965
- })[];
966
- readonly next: string | undefined;
967
- };
968
- outputFormat: "json";
969
- status: 200;
970
- };
971
- };
972
- } & {
973
- "/sessions/:sessionId/model-preference": {
974
- $get: {
975
- input: {
976
- param: {
977
- sessionId: string;
978
- };
979
- };
980
- output: {
981
- readonly providerId: string;
982
- readonly modelId: string;
983
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
984
- } | null;
985
- outputFormat: "json";
986
- status: 200;
987
- };
988
- };
989
- } & {
990
- "/sessions/:sessionId/model-preference": {
991
- $put: {
992
- input: {
993
- json: {
994
- readonly providerId: string;
995
- readonly modelId: string;
996
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
997
- } | null;
998
- } & {
999
- param: {
1000
- sessionId: string;
1001
- };
1002
- };
1003
- output: {
1004
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
1005
- readonly _tag: "ShiitakeError";
1006
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
1007
- readonly message: string;
1008
- readonly requestId?: string | undefined;
1009
- };
1010
- outputFormat: "json";
1011
- status: 400;
1012
- } | {
1013
- input: {
1014
- json: {
1015
- readonly providerId: string;
1016
- readonly modelId: string;
1017
- readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
1018
- } | null;
1019
- } & {
1020
- param: {
1021
- sessionId: string;
1022
- };
1023
- };
1024
- output: null;
1025
- outputFormat: "body";
1026
- status: 204;
1027
- };
1028
- };
1029
- } & {
1030
- "/sessions/:sessionId/command": {
1031
- $post: {
1032
- input: {
1033
- json: {
1034
- readonly command: {
1035
- readonly requestId: string;
1036
- readonly type: "prompt";
1037
- readonly text: string;
1038
- readonly delivery: "followUp" | "steer";
1039
- readonly images?: readonly {
1040
- readonly type: "image";
1041
- readonly data: string;
1042
- readonly mimeType: string;
1043
- }[];
1044
- } | {
1045
- readonly type: "abort";
1046
- } | {
1047
- readonly type: "cancel";
1048
- readonly commandId: string;
1049
- readonly onlyIfPending?: boolean | undefined;
1050
- } | {
1051
- readonly type: "branch";
1052
- readonly entryId: string;
1053
- } | {
1054
- readonly type: "fork";
1055
- readonly entryId: string;
1056
- } | {
1057
- readonly type: "operator";
1058
- readonly requestId: string;
1059
- readonly author: "operator" | "party";
1060
- readonly text: string;
1061
- } | {
1062
- readonly requestId: string;
1063
- readonly type: "compact";
1064
- readonly instructions?: string;
1065
- } | {
1066
- readonly type: "title";
1067
- readonly title: string | null;
1068
- };
1069
- };
1070
- } & {
1071
- param: {
1072
- sessionId: string;
1073
- };
1074
- };
1075
- output: {
1076
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
1077
- readonly _tag: "ShiitakeError";
1078
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
1079
- readonly message: string;
1080
- readonly requestId?: string | undefined;
1081
- };
1082
- outputFormat: "json";
1083
- status: 400;
1084
- } | {
1085
- input: {
1086
- json: {
1087
- readonly command: {
1088
- readonly requestId: string;
1089
- readonly type: "prompt";
1090
- readonly text: string;
1091
- readonly delivery: "followUp" | "steer";
1092
- readonly images?: readonly {
1093
- readonly type: "image";
1094
- readonly data: string;
1095
- readonly mimeType: string;
1096
- }[];
1097
- } | {
1098
- readonly type: "abort";
1099
- } | {
1100
- readonly type: "cancel";
1101
- readonly commandId: string;
1102
- readonly onlyIfPending?: boolean | undefined;
1103
- } | {
1104
- readonly type: "branch";
1105
- readonly entryId: string;
1106
- } | {
1107
- readonly type: "fork";
1108
- readonly entryId: string;
1109
- } | {
1110
- readonly type: "operator";
1111
- readonly requestId: string;
1112
- readonly author: "operator" | "party";
1113
- readonly text: string;
1114
- } | {
1115
- readonly requestId: string;
1116
- readonly type: "compact";
1117
- readonly instructions?: string;
1118
- } | {
1119
- readonly type: "title";
1120
- readonly title: string | null;
1121
- };
1122
- };
1123
- } & {
1124
- param: {
1125
- sessionId: string;
1126
- };
1127
- };
1128
- output: null;
1129
- outputFormat: "body";
1130
- status: 204;
1131
- } | {
1132
- input: {
1133
- json: {
1134
- readonly command: {
1135
- readonly requestId: string;
1136
- readonly type: "prompt";
1137
- readonly text: string;
1138
- readonly delivery: "followUp" | "steer";
1139
- readonly images?: readonly {
1140
- readonly type: "image";
1141
- readonly data: string;
1142
- readonly mimeType: string;
1143
- }[];
1144
- } | {
1145
- readonly type: "abort";
1146
- } | {
1147
- readonly type: "cancel";
1148
- readonly commandId: string;
1149
- readonly onlyIfPending?: boolean | undefined;
1150
- } | {
1151
- readonly type: "branch";
1152
- readonly entryId: string;
1153
- } | {
1154
- readonly type: "fork";
1155
- readonly entryId: string;
1156
- } | {
1157
- readonly type: "operator";
1158
- readonly requestId: string;
1159
- readonly author: "operator" | "party";
1160
- readonly text: string;
1161
- } | {
1162
- readonly requestId: string;
1163
- readonly type: "compact";
1164
- readonly instructions?: string;
1165
- } | {
1166
- readonly type: "title";
1167
- readonly title: string | null;
1168
- };
1169
- };
1170
- } & {
1171
- param: {
1172
- sessionId: string;
1173
- };
1174
- };
1175
- output: {
1176
- readonly status: "accepted";
1177
- readonly commandId: string;
1178
- } | {
1179
- readonly status: "too_late";
1180
- readonly commandId: string;
1181
- } | {
1182
- readonly sessionId: string;
1183
- };
1184
- outputFormat: "json";
1185
- status: 200;
1186
- };
1187
- };
1188
- } & {
1189
- "/sessions/:sessionId": {
1190
- $get: {
1191
- input: {
1192
- query: {
1193
- readonly includeSandboxFailures?: "true" | undefined;
1194
- readonly limit?: number | undefined;
1195
- readonly before?: string | undefined;
1196
- };
1197
- } & {
1198
- param: {
1199
- sessionId: string;
1200
- };
1201
- };
1202
- output: {
1203
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
1204
- readonly _tag: "ShiitakeError";
1205
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
1206
- readonly message: string;
1207
- readonly requestId?: string | undefined;
1208
- };
1209
- outputFormat: "json";
1210
- status: 400;
1211
- } | {
1212
- input: {
1213
- query: {
1214
- readonly includeSandboxFailures?: "true" | undefined;
1215
- readonly limit?: number | undefined;
1216
- readonly before?: string | undefined;
1217
- };
1218
- } & {
1219
- param: {
1220
- sessionId: string;
1221
- };
1222
- };
1223
- output: {
1224
- readonly sessionId: string;
1225
- readonly cursor: string | null;
1226
- readonly hasMore: boolean;
1227
- readonly oldestCursor?: string | null | undefined;
1228
- readonly messages: readonly {
1229
- readonly meta?: any;
1230
- readonly origin?: {
1231
- readonly extensionId: string;
1232
- readonly correlation: string | null;
1233
- } | undefined;
1234
- readonly id: string;
1235
- readonly sequence: number;
1236
- readonly commandId: string | null;
1237
- readonly value: {
1238
- role: "system";
1239
- content: string | {
1240
- type: "text";
1241
- text: string;
1242
- textSignature?: string | undefined;
1243
- }[];
1244
- sections?: {
1245
- [x: string]: string | null;
1246
- } | undefined;
1247
- toolsAdded?: {
1248
- name: string;
1249
- description: string;
1250
- parameters: never;
1251
- constrainedSampling?: false | {
1252
- type: "json_schema";
1253
- strict: "prefer" | "require";
1254
- } | {
1255
- type: "grammar";
1256
- variants: {
1257
- openai_lark?: string | undefined;
1258
- openai_regex?: string | undefined;
1259
- };
1260
- } | undefined;
1261
- }[] | undefined;
1262
- toolsRemoved?: {
1263
- name: string;
1264
- }[] | undefined;
1265
- timestamp: number;
1266
- } | {
1267
- role: "user";
1268
- content: string | ({
1269
- type: "text";
1270
- text: string;
1271
- textSignature?: string | undefined;
1272
- } | {
1273
- type: "image";
1274
- data: string;
1275
- mimeType: string;
1276
- })[];
1277
- timestamp: number;
1278
- } | {
1279
- role: "assistant";
1280
- content: ({
1281
- type: "text";
1282
- text: string;
1283
- textSignature?: string | undefined;
1284
- } | {
1285
- type: "toolCall";
1286
- id: string;
1287
- name: string;
1288
- arguments: {
1289
- [x: string]: any;
1290
- };
1291
- thoughtSignature?: string | undefined;
1292
- namespace?: string | undefined;
1293
- } | {
1294
- type: "thinking";
1295
- thinking: string;
1296
- thinkingSignature?: string | undefined;
1297
- redacted?: boolean | undefined;
1298
- })[];
1299
- api: import("@earendil-works/pi-ai").Api;
1300
- provider: import("@earendil-works/pi-ai").ProviderId;
1301
- model: string;
1302
- responseModel?: string | undefined;
1303
- responseId?: string | undefined;
1304
- providerThinkingLevel?: string | undefined;
1305
- thinkingLevel?: import("@earendil-works/pi-ai").ModelThinkingLevel | undefined;
1306
- diagnostics?: {
1307
- type: string;
1308
- timestamp: number;
1309
- error?: {
1310
- name?: string | undefined;
1311
- message: string;
1312
- stack?: string | undefined;
1313
- code?: string | number | undefined;
1314
- } | undefined;
1315
- details?: {
1316
- [x: string]: any;
1317
- } | undefined;
1318
- }[] | undefined;
1319
- usage: {
1320
- input: number;
1321
- output: number;
1322
- cacheRead: number;
1323
- cacheWrite: number;
1324
- cacheWrite1h?: number | undefined;
1325
- reasoning?: number | undefined;
1326
- totalTokens: number;
1327
- cost: {
1328
- input: number;
1329
- output: number;
1330
- cacheRead: number;
1331
- cacheWrite: number;
1332
- total: number;
1333
- };
1334
- };
1335
- stopReason: import("@earendil-works/pi-ai").StopReason;
1336
- deferred?: {
1337
- provider: string;
1338
- modelId: string;
1339
- api: string;
1340
- id: string;
1341
- expiresAt?: number | undefined;
1342
- pollAfterMs?: number | undefined;
1343
- data?: any;
1344
- } | undefined;
1345
- errorMessage?: string | undefined;
1346
- rawStopReason?: string | undefined;
1347
- endTurn?: boolean | undefined;
1348
- timestamp: number;
1349
- } | {
1350
- role: "toolResult";
1351
- toolCallId: string;
1352
- toolName: string;
1353
- content: ({
1354
- type: "text";
1355
- text: string;
1356
- textSignature?: string | undefined;
1357
- } | {
1358
- type: "image";
1359
- data: string;
1360
- mimeType: string;
1361
- })[];
1362
- details?: any;
1363
- usage?: {
1364
- input: number;
1365
- output: number;
1366
- cacheRead: number;
1367
- cacheWrite: number;
1368
- cacheWrite1h?: number | undefined;
1369
- reasoning?: number | undefined;
1370
- totalTokens: number;
1371
- cost: {
1372
- input: number;
1373
- output: number;
1374
- cacheRead: number;
1375
- cacheWrite: number;
1376
- total: number;
1377
- };
1378
- } | undefined;
1379
- nestedCalls?: {
1380
- calls: {
1381
- id: string;
1382
- name: string;
1383
- arguments?: {
1384
- [x: string]: any;
1385
- } | undefined;
1386
- argumentsBytes?: number | undefined;
1387
- status: "ok" | "error" | "unfinished";
1388
- durationMs?: number | undefined;
1389
- error?: string | undefined;
1390
- }[];
1391
- complete: boolean;
1392
- } | undefined;
1393
- isError: boolean;
1394
- timestamp: number;
1395
- };
1396
- }[];
1397
- readonly terminals: readonly {
1398
- readonly commandId: string;
1399
- readonly outcome: "completed" | "cancelled" | "failed" | "interrupted";
1400
- readonly sequence: number;
1401
- readonly diagnostic: string | null;
1402
- readonly meta?: any;
1403
- }[];
1404
- readonly compactions?: readonly {
1405
- readonly id: string;
1406
- readonly sequence: number;
1407
- readonly at: number;
1408
- readonly tokensBefore: number;
1409
- readonly tokensAfter: number | null;
1410
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger | null;
1411
- }[] | undefined;
1412
- readonly compactionNotices?: readonly {
1413
- readonly id: string;
1414
- readonly sequence: number;
1415
- readonly at: number;
1416
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger;
1417
- readonly result: "nothing_to_compact" | "failed";
1418
- readonly diagnostic: string | null;
1419
- }[] | undefined;
1420
- readonly sandboxFailures?: readonly {
1421
- readonly kind: "sandbox_failure";
1422
- readonly ref: string;
1423
- readonly executionId: string;
1424
- readonly adapter: string;
1425
- readonly buildSha: string | null;
1426
- readonly tag: "Unknown" | "SourceInvalid" | "GuestThrew" | "DeadlineExceeded" | "Cancelled" | "DispatchLost" | "SandboxCrashed" | "BadResponse" | "ResultTooLarge" | "ResultNotJson" | "CapabilityFailed";
1427
- readonly fields: {
1428
- readonly [x: string]: any;
1429
- };
1430
- readonly healthAlert: boolean;
1431
- }[] | undefined;
1432
- readonly pending: {
1433
- readonly total: number;
1434
- readonly prompts: readonly {
1435
- readonly meta?: any;
1436
- readonly origin?: {
1437
- readonly extensionId: string;
1438
- readonly correlation: string | null;
1439
- } | undefined;
1440
- readonly commandId: string;
1441
- readonly text: string;
1442
- readonly images?: readonly {
1443
- readonly type: "image";
1444
- readonly data: string;
1445
- readonly mimeType: string;
1446
- }[] | undefined;
1447
- readonly delivery: import("@fungi.computer/shiitake").PromptDelivery;
1448
- }[];
1449
- readonly hasMore: boolean;
1450
- };
1451
- readonly activity: {
1452
- readonly queue: {
1453
- readonly state: "idle";
1454
- } | {
1455
- readonly state: "queued";
1456
- readonly commandId: string;
1457
- readonly runningWork: {
1458
- readonly kind: "session";
1459
- readonly sessionId: string;
1460
- readonly commandId: string;
1461
- } | {
1462
- readonly kind: "host";
1463
- readonly lane: string;
1464
- readonly jobId: string;
1465
- } | null;
1466
- } | {
1467
- readonly state: "running";
1468
- readonly commandId: string;
1469
- };
1470
- readonly cancellationRequested: boolean;
1471
- readonly retry: {
1472
- readonly attempt: number;
1473
- readonly maxAttempts: number;
1474
- readonly delayMs: number;
1475
- readonly errorMessage: string;
1476
- readonly scheduledAt: number;
1477
- } | null;
1478
- readonly activeTool: string | null;
1479
- readonly lastModelChoiceSequence: number | null;
1480
- readonly compaction: {
1481
- readonly trigger: import("@fungi.computer/shiitake").SessionCompactionTrigger;
1482
- } | null;
1483
- };
1484
- readonly progress: {
1485
- readonly messageId: string;
1486
- readonly revision: number;
1487
- readonly text: string;
1488
- readonly thinking: string;
1489
- readonly textTruncated: boolean;
1490
- readonly thinkingTruncated: boolean;
1491
- } | null;
1492
- readonly extensions: {
1493
- readonly [x: string]: {
1494
- readonly status: "running";
1495
- readonly revision: string;
1496
- readonly value: any;
1497
- readonly catalog?: any;
1498
- } | {
1499
- readonly status: "stopped";
1500
- readonly revision: string;
1501
- readonly reason: string;
1502
- };
1503
- };
1504
- readonly attention: readonly {
1505
- readonly id: string;
1506
- readonly kind: string;
1507
- readonly summary: string;
1508
- readonly since: number;
1509
- readonly extensionId: string;
1510
- readonly expiresAt?: number | undefined;
1511
- }[];
1512
- readonly context?: {
1513
- readonly tokens: number;
1514
- readonly window: number | null;
1515
- } | undefined;
1516
- };
1517
- outputFormat: "json";
1518
- status: 200;
1519
- };
1520
- };
1521
- } & {
1522
- "/sessions/:sessionId/events": {
1523
- $get: {
1524
- input: {
1525
- query: {
1526
- readonly includeSandboxFailures?: "true" | undefined;
1527
- readonly limit?: number | undefined;
1528
- readonly after?: string | undefined;
1529
- readonly mode?: "subscribe" | undefined;
1530
- };
1531
- } & {
1532
- param: {
1533
- sessionId: string;
1534
- };
1535
- };
1536
- output: {};
1537
- outputFormat: string;
1538
- status: import("hono/utils/http-status").StatusCode;
1539
- } | {
1540
- input: {
1541
- query: {
1542
- readonly includeSandboxFailures?: "true" | undefined;
1543
- readonly limit?: number | undefined;
1544
- readonly after?: string | undefined;
1545
- readonly mode?: "subscribe" | undefined;
1546
- };
1547
- } & {
1548
- param: {
1549
- sessionId: string;
1550
- };
1551
- };
1552
- output: {
1553
- readonly cause: "closed" | "conflict" | "incompatible" | "invalid" | "rejected" | "unavailable" | "storage_pressure" | "context_too_large";
1554
- readonly _tag: "ShiitakeError";
1555
- readonly boundary: "contract" | "extensions" | "instructions" | "model" | "runtime" | "store" | "tools";
1556
- readonly message: string;
1557
- readonly requestId?: string | undefined;
1558
- };
1559
- outputFormat: "json";
1560
- status: 400;
1561
- };
1562
- };
1563
- }, "/", "/sessions/:sessionId/events">;
93
+ /** End this selection's use; the mounted route reopens the Agent later. */
94
+ release: () => void;
95
+ }>;
96
+ serve: (selection: Pick<PrivateLocalServiceSelection, "invocationRoot" | "databasePath" | "fungiMcp">, request: Request, attachment?: LocalUiAttachment) => Promise<Response>;
97
+ effectiveModel: (selection: Pick<PrivateLocalServiceSelection, "invocationRoot" | "databasePath" | "fungiMcp">, sessionId: string, signal: AbortSignal) => Promise<{
98
+ agentName: "Shiitake";
99
+ providerId: string;
100
+ providerName: string;
101
+ modelId: string;
102
+ modelName: string;
103
+ credential: {
104
+ kind: "oauth" | "api_key" | "missing";
105
+ source: string;
106
+ };
107
+ label: string;
108
+ reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
109
+ }>;
110
+ sandboxStatus: (selection: Pick<PrivateLocalServiceSelection, "invocationRoot" | "databasePath" | "fungiMcp">, signal: AbortSignal) => Promise<{
111
+ state: "available";
112
+ requireSandbox: boolean;
113
+ } | {
114
+ state: "unavailable";
115
+ requireSandbox: boolean;
116
+ reason: {
117
+ kind: "missing" | "invalid-digest" | "digest-mismatch" | "not-executable" | "unsupported-platform" | "invalid-folder" | "backend-refused";
118
+ message: string;
119
+ };
1564
120
  }>;
121
+ sweepIdle: () => Promise<void>;
122
+ archive: (request: Readonly<{
123
+ invocationRoot: string;
124
+ agentId: string;
125
+ archived: boolean;
126
+ }>, signal: AbortSignal) => Promise<void>;
127
+ stopAll: (request: Readonly<{
128
+ invocationRoot: string;
129
+ agentId: string;
130
+ }>) => Promise<StopAllResult>;
1565
131
  restore: () => Promise<void>;
1566
132
  close: () => Promise<void>;
133
+ reload: (invocationRoot: string, clientPath: string) => Promise<void>;
134
+ unfinishedOwners: () => string[];
1567
135
  };