@fungi.computer/shiitake 0.2.0 → 0.3.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.
- package/README.md +155 -34
- package/dist/agent-control.d.ts +77 -5
- package/dist/agent-control.js +271 -65
- package/dist/client-entry.d.ts +15 -8
- package/dist/client-entry.js +7 -5
- package/dist/client-wire.d.ts +24 -8
- package/dist/client-wire.js +53 -11
- package/dist/client.d.ts +56 -11
- package/dist/client.js +1 -1
- package/dist/cloudflare.d.ts +42 -23
- package/dist/cloudflare.js +76 -54
- package/dist/cold-sessions.d.ts +28 -0
- package/dist/cold-sessions.js +1 -0
- package/dist/delegation.d.ts +214 -0
- package/dist/delegation.js +319 -0
- package/dist/effect.d.ts +1 -1
- package/dist/errors.d.ts +2 -2
- package/dist/errors.js +2 -2
- package/dist/extension-contract.d.ts +10 -2
- package/dist/extensions.d.ts +6 -2
- package/dist/fleet.d.ts +43 -9
- package/dist/fleet.js +88 -25
- package/dist/hosted.js +1 -0
- package/dist/http-routes.d.ts +113 -29
- package/dist/http-routes.js +18 -1
- package/dist/index.d.ts +3 -2
- package/dist/internal/accepted-run-executor.d.ts +5 -0
- package/dist/internal/accepted-run-executor.js +10 -4
- package/dist/internal/admission-door.d.ts +3 -0
- package/dist/internal/admission-door.js +12 -2
- package/dist/internal/client-boundary.js +7 -1
- package/dist/internal/compaction/compaction-slot.d.ts +36 -0
- package/dist/internal/compaction/compaction-slot.js +41 -0
- package/dist/internal/compaction/compaction.d.ts +11 -8
- package/dist/internal/compaction/compaction.js +62 -34
- package/dist/internal/compaction/session-compaction.d.ts +8 -16
- package/dist/internal/compaction/session-compaction.js +358 -119
- package/dist/internal/compaction/settings.d.ts +1 -1
- package/dist/internal/compaction/settings.js +5 -0
- package/dist/internal/compaction/utils.d.ts +19 -16
- package/dist/internal/compaction/utils.js +30 -84
- package/dist/internal/contracts.d.ts +40 -13
- package/dist/internal/coordinator.js +28 -10
- package/dist/internal/effect-client.d.ts +4 -2
- package/dist/internal/effect-client.js +29 -0
- package/dist/internal/effect-contracts.d.ts +17 -4
- package/dist/internal/extension-runtime.d.ts +5 -0
- package/dist/internal/extension-runtime.js +184 -89
- package/dist/internal/host-meta.d.ts +7 -0
- package/dist/internal/model-acquisition.js +7 -1
- package/dist/internal/model-preference.d.ts +4 -2
- package/dist/internal/model-preference.js +2 -1
- package/dist/internal/promise-facade.js +4 -16
- package/dist/internal/run-failure-reason.d.ts +10 -0
- package/dist/internal/run-failure-reason.js +19 -0
- package/dist/internal/run-scope.d.ts +4 -1
- package/dist/internal/run-scope.js +38 -5
- package/dist/internal/runtime-coordinator.d.ts +2 -1
- package/dist/internal/runtime-coordinator.js +65 -4
- package/dist/internal/runtime-core.js +1 -0
- package/dist/internal/runtime-reconciliation.js +42 -6
- package/dist/internal/session-context.d.ts +1 -2
- package/dist/internal/session-context.js +8 -30
- package/dist/internal/session-status.d.ts +2 -1
- package/dist/internal/session-status.js +4 -1
- package/dist/internal/woodstock/client-projection.d.ts +6 -5
- package/dist/internal/woodstock/client-projection.js +79 -53
- package/dist/internal/woodstock/cold-sessions.d.ts +4 -0
- package/dist/internal/woodstock/cold-sessions.js +90 -0
- package/dist/internal/woodstock/extension-store.d.ts +2 -0
- package/dist/internal/woodstock/extension-store.js +4 -0
- package/dist/internal/woodstock/fleet-store.d.ts +5 -1
- package/dist/internal/woodstock/fleet-store.js +17 -5
- package/dist/internal/woodstock/index.d.ts +11 -3
- package/dist/internal/woodstock/index.js +33 -14
- package/dist/internal/woodstock/progress.d.ts +14 -1
- package/dist/internal/woodstock/progress.js +97 -19
- package/dist/internal/woodstock/run-recovery.js +6 -4
- package/dist/internal/woodstock/session-attention.d.ts +1 -1
- package/dist/internal/woodstock/session-attention.js +2 -2
- package/dist/internal/woodstock/session-entry.d.ts +110 -43
- package/dist/internal/woodstock/session-entry.js +63 -20
- package/dist/internal/woodstock/session-inbox.js +2 -0
- package/dist/internal/woodstock/session-store.d.ts +104 -24
- package/dist/internal/woodstock/session-store.js +937 -246
- package/dist/internal/woodstock/storage-admission.d.ts +8 -8
- package/dist/internal/woodstock/storage-admission.js +8 -34
- package/dist/internal/woodstock/storage-conformance.d.ts +15 -0
- package/dist/internal/woodstock/storage-conformance.js +489 -0
- package/dist/model-preference.d.ts +2 -2
- package/dist/model-preference.js +2 -2
- package/dist/node.js +1 -1
- package/dist/remote-client.js +8 -1
- package/dist/session-attention.d.ts +8 -1
- package/dist/session-attention.js +6 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -0
- package/docs/api/README.md +18 -16
- package/docs/api/agent-control.md +171 -1
- package/docs/api/client-entry.md +26 -10
- package/docs/api/client.md +153 -37
- package/docs/api/cloudflare.md +76 -23
- package/docs/api/delegation.md +485 -0
- package/docs/api/effect.md +20 -2
- package/docs/api/extensions.md +21 -9
- package/docs/api/fleet.md +159 -104
- package/docs/api/http.md +4 -1
- package/docs/api/index.md +116 -20
- package/docs/api/internal/woodstock/storage-conformance.md +81 -0
- package/docs/api/model-preference.md +27 -10
- package/docs/api/testing.md +16 -4
- package/package.json +26 -14
- package/dist/internal/browser-sessions.d.ts +0 -31
- package/dist/internal/browser-sessions.js +0 -173
package/dist/client-wire.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
-
import type { Accepted, CancelResult, ForkedSession, SessionFrame, SessionSnapshot, SessionSummaryPage, SessionTerminal } from "./client.js";
|
|
2
|
+
import type { Accepted, CancelResult, WithdrawResult, ForkedSession, SessionFrame, SessionPendingPrompt, SessionSnapshot, SessionSummaryPage, SessionTerminal } from "./client.js";
|
|
3
3
|
import { ShiitakeError } from "./errors.js";
|
|
4
4
|
import type { ExtensionSlotV0, ExtensionStatusV0, Json } from "./extensions.js";
|
|
5
5
|
/** Existing terminal wire grammar, shared by exact host settlement facts. */
|
|
@@ -10,7 +10,9 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
10
10
|
readonly hasMore: Schema.Boolean;
|
|
11
11
|
readonly oldestCursor: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
12
12
|
readonly messages: Schema.$Array<Schema.Codec<Readonly<{
|
|
13
|
+
requestId?: string;
|
|
13
14
|
meta?: Json;
|
|
15
|
+
data?: Json;
|
|
14
16
|
origin?: Readonly<{
|
|
15
17
|
extensionId: string;
|
|
16
18
|
correlation: string | null;
|
|
@@ -18,9 +20,11 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
18
20
|
id: string;
|
|
19
21
|
sequence: number;
|
|
20
22
|
commandId: string | null;
|
|
21
|
-
value: import("
|
|
23
|
+
value: import("./client.js").ModelMessage;
|
|
22
24
|
}>, Readonly<{
|
|
25
|
+
requestId?: string;
|
|
23
26
|
meta?: Json;
|
|
27
|
+
data?: Json;
|
|
24
28
|
origin?: Readonly<{
|
|
25
29
|
extensionId: string;
|
|
26
30
|
correlation: string | null;
|
|
@@ -28,7 +32,7 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
28
32
|
id: string;
|
|
29
33
|
sequence: number;
|
|
30
34
|
commandId: string | null;
|
|
31
|
-
value: import("
|
|
35
|
+
value: import("./client.js").ModelMessage;
|
|
32
36
|
}>, never, never>>;
|
|
33
37
|
readonly terminals: Schema.$Array<Schema.Codec<Readonly<{
|
|
34
38
|
commandId: string;
|
|
@@ -49,7 +53,7 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
49
53
|
readonly executionId: Schema.String;
|
|
50
54
|
readonly adapter: Schema.String;
|
|
51
55
|
readonly buildSha: Schema.NullOr<Schema.String>;
|
|
52
|
-
readonly tag: Schema.Literals<readonly ["SourceInvalid", "GuestThrew", "DeadlineExceeded", "Cancelled", "DispatchLost", "SandboxCrashed", "BadResponse", "ResultTooLarge", "ResultNotJson", "CapabilityFailed", "Unknown"]>;
|
|
56
|
+
readonly tag: Schema.Literals<readonly ["SourceInvalid", "GuestThrew", "DeadlineExceeded", "SandboxBusy", "Cancelled", "DispatchLost", "SandboxCrashed", "BadResponse", "ResultTooLarge", "ResultNotJson", "CapabilityFailed", "Unknown"]>;
|
|
53
57
|
readonly fields: Schema.$Record<Schema.String, Schema.Codec<import("zod").JSONType, import("zod").JSONType, never, never>>;
|
|
54
58
|
readonly healthAlert: Schema.Boolean;
|
|
55
59
|
}>>>;
|
|
@@ -73,23 +77,23 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
73
77
|
sequence: number;
|
|
74
78
|
at: number;
|
|
75
79
|
trigger: import("./client.js").SessionCompactionTrigger;
|
|
76
|
-
result: "nothing_to_compact" | "failed";
|
|
80
|
+
result: "nothing_to_compact" | "failed" | "stale" | "insufficient";
|
|
77
81
|
diagnostic: string | null;
|
|
78
82
|
}>, Readonly<{
|
|
79
83
|
id: string;
|
|
80
84
|
sequence: number;
|
|
81
85
|
at: number;
|
|
82
86
|
trigger: import("./client.js").SessionCompactionTrigger;
|
|
83
|
-
result: "nothing_to_compact" | "failed";
|
|
87
|
+
result: "nothing_to_compact" | "failed" | "stale" | "insufficient";
|
|
84
88
|
diagnostic: string | null;
|
|
85
89
|
}>, never, never>>>;
|
|
86
90
|
readonly pending: Schema.Codec<Readonly<{
|
|
87
91
|
total: number;
|
|
88
|
-
prompts: readonly
|
|
92
|
+
prompts: readonly SessionPendingPrompt[];
|
|
89
93
|
hasMore: boolean;
|
|
90
94
|
}>, Readonly<{
|
|
91
95
|
total: number;
|
|
92
|
-
prompts: readonly
|
|
96
|
+
prompts: readonly SessionPendingPrompt[];
|
|
93
97
|
hasMore: boolean;
|
|
94
98
|
}>, never, never>;
|
|
95
99
|
readonly activity: Schema.Codec<Readonly<{
|
|
@@ -156,6 +160,13 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
156
160
|
textTruncated: boolean;
|
|
157
161
|
thinkingTruncated: boolean;
|
|
158
162
|
}>, never, never>>;
|
|
163
|
+
readonly toolOutput: Schema.$Array<Schema.Struct<{
|
|
164
|
+
readonly toolCallId: Schema.String;
|
|
165
|
+
readonly revision: Schema.Int;
|
|
166
|
+
readonly tail: Schema.String;
|
|
167
|
+
readonly droppedBytes: Schema.Int;
|
|
168
|
+
readonly totalBytes: Schema.Int;
|
|
169
|
+
}>>;
|
|
159
170
|
readonly extensions: Schema.$Record<Schema.String, Schema.Codec<ExtensionSlotV0, ExtensionSlotV0, never, never>>;
|
|
160
171
|
readonly attention: Schema.$Array<Schema.Struct<{
|
|
161
172
|
readonly extensionId: Schema.NonEmptyString;
|
|
@@ -164,6 +175,7 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
164
175
|
readonly summary: Schema.NonEmptyString;
|
|
165
176
|
readonly since: Schema.Int;
|
|
166
177
|
readonly expiresAt: Schema.optional<Schema.Int>;
|
|
178
|
+
readonly inbox: Schema.optional<Schema.Literal<false>>;
|
|
167
179
|
}>>;
|
|
168
180
|
readonly context: Schema.optionalKey<Schema.Struct<{
|
|
169
181
|
readonly tokens: Schema.Int;
|
|
@@ -173,6 +185,8 @@ export declare const SessionSnapshotSchema: Schema.Struct<{
|
|
|
173
185
|
export declare const SessionFrameSchema: Schema.Codec<SessionFrame>;
|
|
174
186
|
/** Decode a durable command acceptance value at an RPC boundary. */
|
|
175
187
|
export declare const AcceptedSchema: Schema.Codec<Accepted>;
|
|
188
|
+
/** Decode the owner's atomic request resolution. */
|
|
189
|
+
export declare function parseWithdrawResult(value: string): WithdrawResult;
|
|
176
190
|
/** Parse one serialized extension status. */
|
|
177
191
|
export declare function parseExtensionStatus(value: string): ExtensionStatusV0;
|
|
178
192
|
/** Parse the serialized list of rostered extension statuses. */
|
|
@@ -183,6 +197,8 @@ export declare function parseExtensionOutput(value: string): Json;
|
|
|
183
197
|
export declare function parseAccepted(value: string): Accepted;
|
|
184
198
|
/** Parse one serialized cancel outcome: accepted, or too late. */
|
|
185
199
|
export declare function parseCancelResult(value: string): CancelResult;
|
|
200
|
+
/** Decode the host-authorized newest pending lookup, including an empty result. */
|
|
201
|
+
export declare function parseLatestPendingPrompt(value: string): SessionPendingPrompt | null;
|
|
186
202
|
/** Parse one serialized fork result using Shiitake's public client grammar. */
|
|
187
203
|
export declare function parseForkedSession(value: string): ForkedSession;
|
|
188
204
|
/** Parse one serialized snapshot using Shiitake's public client grammar. */
|
package/dist/client-wire.js
CHANGED
|
@@ -4,10 +4,13 @@ import { SandboxFailureEventSchema } from "@fungi.computer/mycelium";
|
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import { ShiitakeError, ShiitakeErrorWireSchema } from "./errors.js";
|
|
6
6
|
import { JsonValueSchema } from "./internal/json-value.js";
|
|
7
|
+
import { HostMetaSchema } from "./internal/host-meta.js";
|
|
7
8
|
import { StoredPiMessageSchema, ExtensionAdmissionOriginSchema, } from "./internal/woodstock/index.js";
|
|
8
9
|
const ExtensionOriginSchema = ExtensionAdmissionOriginSchema.mapFields(({ extensionId, correlation }) => ({ extensionId, correlation }));
|
|
9
10
|
const SessionMessageSchema = Schema.Struct({
|
|
10
|
-
|
|
11
|
+
requestId: Schema.optionalKey(Schema.String),
|
|
12
|
+
meta: Schema.optionalKey(HostMetaSchema),
|
|
13
|
+
data: Schema.optionalKey(JsonValueSchema),
|
|
11
14
|
origin: Schema.optionalKey(ExtensionOriginSchema),
|
|
12
15
|
id: Schema.String,
|
|
13
16
|
sequence: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
@@ -89,7 +92,7 @@ export const SessionTerminalSchema = Schema.Struct({
|
|
|
89
92
|
]),
|
|
90
93
|
sequence: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
91
94
|
diagnostic: Schema.NullOr(Schema.String),
|
|
92
|
-
meta: Schema.optionalKey(
|
|
95
|
+
meta: Schema.optionalKey(HostMetaSchema),
|
|
93
96
|
});
|
|
94
97
|
const SessionCompactionMarkerSchema = Schema.Struct({
|
|
95
98
|
id: Schema.String,
|
|
@@ -104,7 +107,12 @@ const SessionCompactionNoticeSchema = Schema.Struct({
|
|
|
104
107
|
sequence: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
105
108
|
at: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
106
109
|
trigger: SessionCompactionTriggerSchema,
|
|
107
|
-
result: Schema.Literals([
|
|
110
|
+
result: Schema.Literals([
|
|
111
|
+
"nothing_to_compact",
|
|
112
|
+
"failed",
|
|
113
|
+
"stale",
|
|
114
|
+
"insufficient",
|
|
115
|
+
]),
|
|
108
116
|
diagnostic: Schema.NullOr(Schema.String),
|
|
109
117
|
});
|
|
110
118
|
const SessionProgressSchema = Schema.Struct({
|
|
@@ -115,16 +123,27 @@ const SessionProgressSchema = Schema.Struct({
|
|
|
115
123
|
textTruncated: Schema.Boolean,
|
|
116
124
|
thinkingTruncated: Schema.Boolean,
|
|
117
125
|
});
|
|
126
|
+
const SessionPendingPromptSchema = Schema.Struct({
|
|
127
|
+
commandId: Schema.String,
|
|
128
|
+
requestId: Schema.String,
|
|
129
|
+
meta: Schema.optionalKey(HostMetaSchema),
|
|
130
|
+
origin: Schema.optionalKey(ExtensionOriginSchema),
|
|
131
|
+
text: Schema.String,
|
|
132
|
+
images: Schema.optionalKey(Schema.Array(PromptImageSchema)),
|
|
133
|
+
delivery: Schema.Literals(["steer", "followUp"]),
|
|
134
|
+
});
|
|
135
|
+
const SessionToolOutputSchema = Schema.Struct({
|
|
136
|
+
toolCallId: Schema.String,
|
|
137
|
+
revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
138
|
+
tail: Schema.String.check(Schema.makeFilter((tail) => new TextEncoder().encode(tail).byteLength <= 8192 &&
|
|
139
|
+
tail.split("\n").length <= 200)),
|
|
140
|
+
droppedBytes: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
141
|
+
totalBytes: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
142
|
+
});
|
|
143
|
+
const ToolOutputSchema = Schema.Array(SessionToolOutputSchema).check(Schema.isMaxLength(4));
|
|
118
144
|
const SessionPendingPromptsSchema = Schema.Struct({
|
|
119
145
|
total: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
|
|
120
|
-
prompts: Schema.Array(
|
|
121
|
-
commandId: Schema.String,
|
|
122
|
-
meta: Schema.optionalKey(JsonValueSchema),
|
|
123
|
-
origin: Schema.optionalKey(ExtensionOriginSchema),
|
|
124
|
-
text: Schema.String,
|
|
125
|
-
images: Schema.optionalKey(Schema.Array(PromptImageSchema)),
|
|
126
|
-
delivery: Schema.Literals(["steer", "followUp"]),
|
|
127
|
-
})),
|
|
146
|
+
prompts: Schema.Array(SessionPendingPromptSchema),
|
|
128
147
|
hasMore: Schema.Boolean,
|
|
129
148
|
});
|
|
130
149
|
const SessionContextSchema = Schema.Struct({
|
|
@@ -144,11 +163,17 @@ export const SessionSnapshotSchema = Schema.Struct({
|
|
|
144
163
|
pending: SessionPendingPromptsSchema,
|
|
145
164
|
activity: SessionActivitySchema,
|
|
146
165
|
progress: Schema.NullOr(SessionProgressSchema),
|
|
166
|
+
toolOutput: ToolOutputSchema,
|
|
147
167
|
extensions: ExtensionSlotsSchema,
|
|
148
168
|
attention: SessionAttentionListSchema,
|
|
149
169
|
context: Schema.optionalKey(SessionContextSchema),
|
|
150
170
|
});
|
|
151
171
|
export const SessionFrameSchema = Schema.Union([
|
|
172
|
+
Schema.Struct({
|
|
173
|
+
kind: Schema.Literal("tool_output"),
|
|
174
|
+
toolOutput: ToolOutputSchema,
|
|
175
|
+
activity: SessionActivitySchema,
|
|
176
|
+
}),
|
|
152
177
|
Schema.Struct({
|
|
153
178
|
kind: Schema.Literal("update"),
|
|
154
179
|
delivery: Schema.Literals(["replay", "live"]),
|
|
@@ -181,8 +206,21 @@ export const AcceptedSchema = Schema.Struct({
|
|
|
181
206
|
status: Schema.Literal("accepted"),
|
|
182
207
|
commandId: Schema.String,
|
|
183
208
|
});
|
|
209
|
+
const UnknownRequestSchema = Schema.Struct({
|
|
210
|
+
status: Schema.Literal("unknown"),
|
|
211
|
+
});
|
|
212
|
+
const WithdrawResultSchema = Schema.Union([
|
|
213
|
+
AcceptedSchema,
|
|
214
|
+
UnknownRequestSchema,
|
|
215
|
+
]);
|
|
216
|
+
const decodeWithdrawResult = Schema.decodeUnknownSync(Schema.fromJsonString(WithdrawResultSchema));
|
|
217
|
+
/** Decode the owner's atomic request resolution. */
|
|
218
|
+
export function parseWithdrawResult(value) {
|
|
219
|
+
return decodeWithdrawResult(value);
|
|
220
|
+
}
|
|
184
221
|
const CancelResultSchema = Schema.Union([
|
|
185
222
|
AcceptedSchema,
|
|
223
|
+
UnknownRequestSchema,
|
|
186
224
|
Schema.Struct({
|
|
187
225
|
status: Schema.Literal("too_late"),
|
|
188
226
|
commandId: Schema.String,
|
|
@@ -220,6 +258,10 @@ export function parseAccepted(value) {
|
|
|
220
258
|
export function parseCancelResult(value) {
|
|
221
259
|
return decodeCancelResult(value);
|
|
222
260
|
}
|
|
261
|
+
/** Decode the host-authorized newest pending lookup, including an empty result. */
|
|
262
|
+
export function parseLatestPendingPrompt(value) {
|
|
263
|
+
return Schema.decodeUnknownSync(Schema.fromJsonString(Schema.NullOr(SessionPendingPromptSchema)))(value);
|
|
264
|
+
}
|
|
223
265
|
/** Parse one serialized fork result using Shiitake's public client grammar. */
|
|
224
266
|
export function parseForkedSession(value) {
|
|
225
267
|
return decodeForkedSession(value);
|
package/dist/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ExtensionSlotV0, ExtensionStatusV0, Json } from "./extensions.js";
|
|
|
7
7
|
import type { AbortCommand, BranchCommand, CompactCommand, OperatorCommand, TitleCommand, CancelCommand, ForkCommand, PromptCommand, PromptDelivery, SessionCommand } from "./internal/client-boundary.js";
|
|
8
8
|
export { createShiitakeClient, type ShiitakeClientOptions, } from "./remote-client.js";
|
|
9
9
|
export { bindAgentExtension, bindSessionExtension, type BoundAgentExtensionV0, type BoundCallV0, type BoundSessionExtensionV0, type ExtensionViewV0, type ScopedCommandsV0, } from "./extension-client.js";
|
|
10
|
-
export { AcceptedSchema, parseAccepted, parseCancelResult, parseForkedSession, parseSessionFrame, parseSessionSnapshot, parseSessionSummaryPage, parseShiitakeError, } from "./client-wire.js";
|
|
10
|
+
export { AcceptedSchema, parseAccepted, parseCancelResult, parseLatestPendingPrompt, parseWithdrawResult, parseForkedSession, parseSessionFrame, parseSessionSnapshot, parseSessionSummaryPage, parseShiitakeError, } from "./client-wire.js";
|
|
11
11
|
export type { AbortCommand, BranchCommand, CompactCommand, CancelCommand, ForkCommand, OperatorCommand, PromptCommand, PromptDelivery, SessionCommand, TitleCommand, } from "./internal/client-boundary.js";
|
|
12
12
|
/** Semantic acknowledgement returned after one durable acceptance commit. */
|
|
13
13
|
export type Accepted = Readonly<{
|
|
@@ -26,8 +26,14 @@ export type TooLate = Readonly<{
|
|
|
26
26
|
/** The command the caller tried to cancel. */
|
|
27
27
|
commandId: string;
|
|
28
28
|
}>;
|
|
29
|
-
/**
|
|
30
|
-
export type
|
|
29
|
+
/** No command has been admitted under this request key in the addressed Session. */
|
|
30
|
+
export type UnknownRequest = Readonly<{
|
|
31
|
+
status: "unknown";
|
|
32
|
+
}>;
|
|
33
|
+
/** Outcome of one cancel command or request-based recall. */
|
|
34
|
+
export type CancelResult = Accepted | TooLate | UnknownRequest;
|
|
35
|
+
/** Atomic admission resolution: accepted work is kept; an unknown key is fenced forever. */
|
|
36
|
+
export type WithdrawResult = Accepted | UnknownRequest;
|
|
31
37
|
/** Result returned after a fork commits a new cold-readable Session. */
|
|
32
38
|
export type ForkedSession = Readonly<{
|
|
33
39
|
/** Identity of the newly created Session. */
|
|
@@ -55,13 +61,26 @@ export type SendOptions = Readonly<{
|
|
|
55
61
|
/** Private retry key, generated once when omitted; not the admitted command ID. */
|
|
56
62
|
requestId?: string;
|
|
57
63
|
}>;
|
|
58
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Model-facing Pi content. Application tool display payloads belong to the
|
|
66
|
+
* surrounding entry's `data`, never to a message sent back to a provider.
|
|
67
|
+
*/
|
|
68
|
+
export type ModelMessage = Exclude<Message, {
|
|
69
|
+
role: "toolResult";
|
|
70
|
+
}> | Omit<Extract<Message, {
|
|
71
|
+
role: "toolResult";
|
|
72
|
+
}>, "details">;
|
|
73
|
+
/** One completed model message and its separate application payload. */
|
|
59
74
|
export type SessionMessage = Readonly<{
|
|
75
|
+
/** Caller identity of a prompt or operator line; absent on generated messages. */
|
|
76
|
+
requestId?: string;
|
|
60
77
|
/**
|
|
61
78
|
* Opaque metadata the in-process host attached; Shiitake never reads it.
|
|
62
79
|
* Decode it with the host's own schema.
|
|
63
80
|
*/
|
|
64
81
|
meta?: Json;
|
|
82
|
+
/** Opaque application display payload, independent of host metadata. */
|
|
83
|
+
data?: Json;
|
|
65
84
|
/** Durable extension producer of this user message; absent for human prompts. */
|
|
66
85
|
origin?: Readonly<{
|
|
67
86
|
extensionId: string;
|
|
@@ -73,8 +92,8 @@ export type SessionMessage = Readonly<{
|
|
|
73
92
|
sequence: number;
|
|
74
93
|
/** Owner-issued accepted work correlation for this message, otherwise null. */
|
|
75
94
|
commandId: string | null;
|
|
76
|
-
/**
|
|
77
|
-
value:
|
|
95
|
+
/** Model content; provider replay metadata remains unchanged. */
|
|
96
|
+
value: ModelMessage;
|
|
78
97
|
}>;
|
|
79
98
|
/** Minimal constructor seam for runtimes without a global EventSource. */
|
|
80
99
|
export type ShiitakeEventSourceConstructor = new (url: string) => Pick<EventTarget, "addEventListener"> & Pick<EventSource, "close"> & {
|
|
@@ -166,6 +185,14 @@ export type AgentExtensionControls = Readonly<{
|
|
|
166
185
|
/** Call one Agent-scope command with its encoded input; resolves the encoded output. */
|
|
167
186
|
call: (extensionId: string, command: string, input: Json) => Promise<Json>;
|
|
168
187
|
}>;
|
|
188
|
+
/** Process-local running tool tail; never a durable Session fact. */
|
|
189
|
+
export type SessionToolOutput = Readonly<{
|
|
190
|
+
toolCallId: string;
|
|
191
|
+
revision: number;
|
|
192
|
+
tail: string;
|
|
193
|
+
droppedBytes: number;
|
|
194
|
+
totalBytes: number;
|
|
195
|
+
}>;
|
|
169
196
|
/** Process-local assistant progress; never a durable Session fact. */
|
|
170
197
|
export type SessionProgress = Readonly<{
|
|
171
198
|
/** Stable message identity shared with the eventual completed Pi message. */
|
|
@@ -178,6 +205,8 @@ export type SessionProgress = Readonly<{
|
|
|
178
205
|
}>;
|
|
179
206
|
/** Accepted prompt waiting to enter the conversation, not a scheduling command. */
|
|
180
207
|
export type SessionPendingPrompt = Readonly<{
|
|
208
|
+
/** Caller identity, available even before the command response reaches its client. */
|
|
209
|
+
requestId: string;
|
|
181
210
|
/** Host-admitted metadata, retained opaquely before execution. */
|
|
182
211
|
meta?: SessionMessage["meta"];
|
|
183
212
|
/** Durable extension producer, absent for human prompts. */
|
|
@@ -220,8 +249,11 @@ export type SessionCompactionMarker = Readonly<{
|
|
|
220
249
|
export type SessionCompactionTrigger = "manual" | "threshold" | "overflow";
|
|
221
250
|
/**
|
|
222
251
|
* A compaction that changed nothing: a manual request with nothing to
|
|
223
|
-
* summarize yet,
|
|
224
|
-
*
|
|
252
|
+
* summarize yet, a compaction that failed, or a finished background summary
|
|
253
|
+
* dropped unplaced: stale because the context had moved past its head, or
|
|
254
|
+
* insufficient because placing it would have left the context over the
|
|
255
|
+
* limit. Automatic failures are never silent; each one is a notice at its own
|
|
256
|
+
* place in the timeline.
|
|
225
257
|
*/
|
|
226
258
|
export type SessionCompactionNotice = Readonly<{
|
|
227
259
|
/** Stable identity of the durable notice entry. */
|
|
@@ -231,8 +263,8 @@ export type SessionCompactionNotice = Readonly<{
|
|
|
231
263
|
/** When it was recorded, in milliseconds since the epoch. */
|
|
232
264
|
at: number;
|
|
233
265
|
trigger: SessionCompactionTrigger;
|
|
234
|
-
result: "nothing_to_compact" | "failed";
|
|
235
|
-
/** A failure's bounded reason; null for
|
|
266
|
+
result: "nothing_to_compact" | "failed" | "stale" | "insufficient";
|
|
267
|
+
/** A failure's bounded reason; null for the other results. */
|
|
236
268
|
diagnostic: string | null;
|
|
237
269
|
}>;
|
|
238
270
|
/**
|
|
@@ -273,6 +305,8 @@ export type SessionSnapshot = Readonly<{
|
|
|
273
305
|
activity: SessionActivity;
|
|
274
306
|
/** Latest replaceable progress snapshot, if an assistant message is live. */
|
|
275
307
|
progress: SessionProgress | null;
|
|
308
|
+
/** Current bounded tool tails. Empty outside this process's running work. */
|
|
309
|
+
toolOutput: readonly SessionToolOutput[];
|
|
276
310
|
/** Encoded projection slot of each extension granted one. */
|
|
277
311
|
extensions: SessionExtensionSlots;
|
|
278
312
|
/** Open requests for human attention from extensions. */
|
|
@@ -282,6 +316,10 @@ export type SessionSnapshot = Readonly<{
|
|
|
282
316
|
}>;
|
|
283
317
|
/** One bounded replay or live frame. */
|
|
284
318
|
export type SessionFrame = Readonly<{
|
|
319
|
+
kind: "tool_output";
|
|
320
|
+
toolOutput: readonly SessionToolOutput[];
|
|
321
|
+
activity: SessionActivity;
|
|
322
|
+
}> | Readonly<{
|
|
285
323
|
/** Bounded Session-projection update discriminator. */
|
|
286
324
|
kind: "update";
|
|
287
325
|
/** Whether replay or a post-commit hint discovered the update. */
|
|
@@ -356,10 +394,15 @@ export type SessionWatch = Readonly<{
|
|
|
356
394
|
}>;
|
|
357
395
|
/** Addressable Session interface. Addressing itself performs no I/O. */
|
|
358
396
|
export type ShiitakeSession = Readonly<{
|
|
359
|
-
/**
|
|
397
|
+
/**
|
|
398
|
+
* Address used to share observation across current client mounts.
|
|
399
|
+
* Remote addresses include the transport endpoint, not durable owner identity.
|
|
400
|
+
*/
|
|
360
401
|
address: string;
|
|
361
402
|
/** Execute one retained type-discriminated Session command. */
|
|
362
403
|
command: SessionCommandHandler;
|
|
404
|
+
/** Resolve a stalled request atomically; withdrawn keys can never be admitted later. */
|
|
405
|
+
withdraw: (requestId: string) => Promise<WithdrawResult>;
|
|
363
406
|
/** Cancel the running turn and all queued prompts, retaining their text. */
|
|
364
407
|
abort: () => Promise<void>;
|
|
365
408
|
/** Send text with an optional private caller idempotency identity. */
|
|
@@ -369,6 +412,8 @@ export type ShiitakeSession = Readonly<{
|
|
|
369
412
|
commandId: string;
|
|
370
413
|
onlyIfPending?: boolean;
|
|
371
414
|
}>) => Promise<CancelResult>;
|
|
415
|
+
/** Newest pending prompt in this host-authorized identity, never an oldest-page guess. */
|
|
416
|
+
latestPending: () => Promise<SessionPendingPrompt | null>;
|
|
372
417
|
/** Address one rostered extension's Session-scope commands. */
|
|
373
418
|
extension: (extensionId: string) => SessionExtensionControls;
|
|
374
419
|
/** Lineage-local request for later runs; null inherits the Agent default. */
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export {} from "./session-attention.js";
|
|
2
2
|
export { createShiitakeClient, } from "./remote-client.js";
|
|
3
3
|
export { bindAgentExtension, bindSessionExtension, } from "./extension-client.js";
|
|
4
|
-
export { AcceptedSchema, parseAccepted, parseCancelResult, parseForkedSession, parseSessionFrame, parseSessionSnapshot, parseSessionSummaryPage, parseShiitakeError, } from "./client-wire.js";
|
|
4
|
+
export { AcceptedSchema, parseAccepted, parseCancelResult, parseLatestPendingPrompt, parseWithdrawResult, parseForkedSession, parseSessionFrame, parseSessionSnapshot, parseSessionSummaryPage, parseShiitakeError, } from "./client-wire.js";
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { BirdDogMail } from "@fungi.computer/bird-dog";
|
|
|
3
3
|
import type { VerifiedAgentReply } from "./internal/woodstock/index.js";
|
|
4
4
|
import type { BirdDogEffect } from "@fungi.computer/bird-dog/effect";
|
|
5
5
|
import type { Accepted } from "./client.js";
|
|
6
|
+
import type { ColdSessionPage, ColdSessionPageRequest } from "./cold-sessions.js";
|
|
6
7
|
import type { HostMetaOptions } from "./internal/host-meta.js";
|
|
7
8
|
import { DurableObject } from "cloudflare:workers";
|
|
8
9
|
import type { CapabilitySource, ModuleRegistration, Sandbox } from "@fungi.computer/mycelium";
|
|
@@ -10,11 +11,10 @@ import { type WatchdogExecutionDecision, type WatchdogReadResult, type WatchdogR
|
|
|
10
11
|
import type { ExtensionRosterV0, Json } from "./extensions.js";
|
|
11
12
|
import { type ShiitakeHttpEnv } from "./http-routes.js";
|
|
12
13
|
import { Hono } from "hono";
|
|
13
|
-
import type { InstructionSource, ModelSource, GrantsDelivery, GrantsDeliveryResult, ShiitakeOwnerAgent, SqliteOwner,
|
|
14
|
+
import type { InstructionSource, ModelSource, GrantsDelivery, GrantsDeliveryResult, ShiitakeOwnerAgent, SqliteOwner, StoragePressureCheck, CompactionOptions, ToolAccess } from "./internal/contracts.js";
|
|
14
15
|
import { type SessionInboxChanges } from "./internal/woodstock/index.js";
|
|
15
|
-
import { type BrowserHost } from "./internal/browser-sessions.js";
|
|
16
16
|
export type { SessionInboxChanges } from "./internal/woodstock/index.js";
|
|
17
|
-
export type {
|
|
17
|
+
export type { ColdSessionPage, ColdSessionPageRequest, ColdSessionRow, } from "./cold-sessions.js";
|
|
18
18
|
export type { GrantsDelivery, GrantsDeliveryResult, ShiitakeOwnerAgent, ToolAccess, } from "./internal/contracts.js";
|
|
19
19
|
/**
|
|
20
20
|
* Deliver one Session's grants into a Cloudflare owner's own storage,
|
|
@@ -33,6 +33,11 @@ export type CloudflareShiitakeState = Readonly<{
|
|
|
33
33
|
};
|
|
34
34
|
/** Extend the Durable Object event lifetime through runtime reconciliation. */
|
|
35
35
|
waitUntil: (task: Promise<unknown>) => void;
|
|
36
|
+
/** The Durable Object's identity, named when its store refuses a Session. */
|
|
37
|
+
id?: Readonly<{
|
|
38
|
+
/** The identity as text, used to name the store in refusals. */
|
|
39
|
+
toString: () => string;
|
|
40
|
+
}>;
|
|
36
41
|
}>;
|
|
37
42
|
/** Non-empty Mycelium capabilities supplied by a Cloudflare host. */
|
|
38
43
|
export type CloudflareShiitakeTools = Readonly<{
|
|
@@ -93,10 +98,10 @@ export type CloudflareShiitakeOptions = Readonly<{
|
|
|
93
98
|
instructions: InstructionSource;
|
|
94
99
|
tools?: readonly [] | CloudflareShiitakeTools;
|
|
95
100
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
101
|
+
* The host's storage-pressure check for this Durable Object; absent never
|
|
102
|
+
* refuses for storage pressure. The budget and thresholds are the host's.
|
|
98
103
|
*/
|
|
99
|
-
|
|
104
|
+
storagePressure?: StoragePressureCheck;
|
|
100
105
|
/** Compaction budgets; absent uses Pi's defaults for every model. */
|
|
101
106
|
compaction?: CompactionOptions;
|
|
102
107
|
/** The host's explicit extension roster and grants; there is no default. */
|
|
@@ -112,8 +117,6 @@ export type CloudflareShiitakeOptions = Readonly<{
|
|
|
112
117
|
hostJobs?: CloudflareHostJobs;
|
|
113
118
|
/** Host-owned addressed mail and settlement replies; absent disables mail. */
|
|
114
119
|
mailRoom?: BirdDogEffect;
|
|
115
|
-
/** Session-scoped browser tools and maintained HTTP transport; absent disables it. */
|
|
116
|
-
browser?: (sessionId: string) => BrowserHost;
|
|
117
120
|
/**
|
|
118
121
|
* Lazily open ACP over the owned in-process handle. The host authorizes
|
|
119
122
|
* ingress and supplies its context policy. ACP borrows this handle: closing
|
|
@@ -133,33 +136,33 @@ export type CloudflareShiitake = ShiitakeOwnerAgent & Readonly<{
|
|
|
133
136
|
acceptMail: (mail: BirdDogMail, meta?: Json, reply?: VerifiedAgentReply) => Promise<Accepted>;
|
|
134
137
|
/** Deliver the native owner alarm to the bound runtime. */
|
|
135
138
|
alarm: () => Promise<void>;
|
|
136
|
-
/** Snapshot actual live executors, independent of instruction
|
|
139
|
+
/** Snapshot actual live executors, independent of instruction leases. */
|
|
137
140
|
activeSessions: () => Promise<readonly string[]>;
|
|
138
141
|
/** Abort each currently executing Session through its ordinary cancellation door. */
|
|
139
142
|
abortActive: () => Promise<void>;
|
|
140
|
-
/** Session-scoped browser transport and teardown, owned by this host. */
|
|
141
|
-
browser: Readonly<{
|
|
142
|
-
/** Serve a Session browser request after host ingress authorization. */
|
|
143
|
-
fetch: (request: Request) => Promise<Response>;
|
|
144
|
-
/** Cancel browser connections and release the current ephemeral hosts. */
|
|
145
|
-
clear: () => Promise<void>;
|
|
146
|
-
}>;
|
|
147
143
|
}>;
|
|
148
|
-
/**
|
|
149
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Open Shiitake over one Durable Object's storage. It resolves once the runtime
|
|
146
|
+
* is started and `initialize` has run; if `initialize` throws, the runtime is
|
|
147
|
+
* closed and the error is rethrown.
|
|
148
|
+
*/
|
|
149
|
+
export declare function makeCloudflareShiitake(unnamed: CloudflareShiitakeState, options: CloudflareShiitakeOptions): Promise<CloudflareShiitake>;
|
|
150
150
|
/** Owns runtime opening, HTTP/ACP transport, inbox observation and alarm recovery. */
|
|
151
151
|
export declare abstract class ShiitakeOwner<Env, State extends CloudflareShiitakeState = CloudflareShiitakeState> {
|
|
152
|
+
#private;
|
|
152
153
|
protected readonly ctx: State;
|
|
153
154
|
protected readonly env: Env;
|
|
154
155
|
constructor(ctx: State, env: Env);
|
|
155
156
|
private agentPromise;
|
|
156
157
|
private openAcp;
|
|
158
|
+
/** This owner's state, its storage named once for Woodstock's refusals. */
|
|
159
|
+
private get named();
|
|
157
160
|
private acpServer;
|
|
158
161
|
/** Consecutive native alarm failures; reset on the next successful alarm. */
|
|
159
162
|
private alarmFailures;
|
|
160
163
|
private readonly routes;
|
|
161
164
|
/** Supply this agent's model, instructions, and optional capabilities. */
|
|
162
|
-
protected abstract shiitakeOptions(): CloudflareShiitakeOptions
|
|
165
|
+
protected abstract shiitakeOptions(): CloudflareShiitakeOptions | Promise<CloudflareShiitakeOptions>;
|
|
163
166
|
/** Borrow this owner's runtime directly; only the host owns its lifetime. */
|
|
164
167
|
shiitake(): Promise<CloudflareShiitake>;
|
|
165
168
|
/** Stop live execution without constructing a cold owner's runtime. */
|
|
@@ -167,9 +170,15 @@ export declare abstract class ShiitakeOwner<Env, State extends CloudflareShiitak
|
|
|
167
170
|
/** Close owned resources before storage erasure; a cold owner has none. */
|
|
168
171
|
closeShiitake(): Promise<void>;
|
|
169
172
|
/** Indexed owner-local existence check; corrupt stored Sessions remain unavailable. */
|
|
170
|
-
|
|
173
|
+
hasStoredSession(sessionId: string): Promise<boolean>;
|
|
171
174
|
/** Bounded strict-after read of this Agent's changed inbox rows. */
|
|
172
175
|
readInboxChanges(after: number, limit: number): Promise<SessionInboxChanges>;
|
|
176
|
+
/**
|
|
177
|
+
* One bounded, read-only page of Sessions with stored bytes, last activity
|
|
178
|
+
* and an idle flag, coldest first. The store keeper's only view of cold
|
|
179
|
+
* Sessions; it carries no SQL, transaction or write.
|
|
180
|
+
*/
|
|
181
|
+
readColdSessions(request: ColdSessionPageRequest): Promise<ColdSessionPage>;
|
|
173
182
|
/** Latest inbox revision; read only after the owner has opened. */
|
|
174
183
|
readInboxRevision(): number;
|
|
175
184
|
/** Prune deletion deltas after every current member inbox has acknowledged them. */
|
|
@@ -186,7 +195,7 @@ export declare abstract class ShiitakeOwner<Env, State extends CloudflareShiitak
|
|
|
186
195
|
/** Serve Shiitake's complete transport without subclass routing. */
|
|
187
196
|
private app;
|
|
188
197
|
/**
|
|
189
|
-
* Shiitake's whole HTTP surface (Session routes
|
|
198
|
+
* Shiitake's whole HTTP surface (Session routes and ACP) as one
|
|
190
199
|
* Hono app. A host mounts it behind its own middleware, which alone may
|
|
191
200
|
* set the `shiitakeMeta` variable.
|
|
192
201
|
*/
|
|
@@ -197,11 +206,12 @@ export declare abstract class ShiitakeOwner<Env, State extends CloudflareShiitak
|
|
|
197
206
|
/** Native Cloudflare entry points; all runtime lifetime belongs to the owner. */
|
|
198
207
|
export declare abstract class ShiitakeDO<Env> extends DurableObject<Env> {
|
|
199
208
|
#private;
|
|
200
|
-
protected abstract shiitakeOptions(): CloudflareShiitakeOptions
|
|
209
|
+
protected abstract shiitakeOptions(): CloudflareShiitakeOptions | Promise<CloudflareShiitakeOptions>;
|
|
201
210
|
protected runtimeOwner(): ShiitakeOwner<Env>;
|
|
202
211
|
protected shiitake(): Promise<CloudflareShiitake>;
|
|
203
212
|
protected abortActiveSessions(): Promise<void>;
|
|
204
213
|
protected closeShiitake(): Promise<void>;
|
|
214
|
+
protected hasStoredSession(sessionId: string): Promise<boolean>;
|
|
205
215
|
protected readInboxChanges(after: number, limit: number): Promise<Readonly<{
|
|
206
216
|
rows: readonly (import("./client.js").SessionSummaryRow | Readonly<{
|
|
207
217
|
sessionId: string;
|
|
@@ -211,10 +221,19 @@ export declare abstract class ShiitakeDO<Env> extends DurableObject<Env> {
|
|
|
211
221
|
latest: number;
|
|
212
222
|
}>>;
|
|
213
223
|
protected readInboxRevision(): number;
|
|
224
|
+
protected readColdSessions(request: ColdSessionPageRequest): Promise<Readonly<{
|
|
225
|
+
sessions: readonly import("./cold-sessions.js").ColdSessionRow[];
|
|
226
|
+
next?: string;
|
|
227
|
+
}>>;
|
|
214
228
|
protected pruneInboxTombstones(through: number): void;
|
|
215
229
|
protected wakeRuntime(): Promise<void>;
|
|
216
230
|
/** Reconcile due runtime and host work through the owner. */
|
|
217
231
|
alarm(): Promise<void>;
|
|
218
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* The host's own routes, in front of Shiitake's: return a response to answer
|
|
234
|
+
* the request, or undefined to let Shiitake serve it. Absent means none.
|
|
235
|
+
*/
|
|
236
|
+
protected hostFetch?(request: Request): Promise<Response> | undefined;
|
|
237
|
+
/** Route an authenticated client request through the host's routes, then the owner. */
|
|
219
238
|
fetch(request: Request): Promise<Response>;
|
|
220
239
|
}
|