@fungi.computer/shiitake 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +454 -2
- package/dist/agar-extension.d.ts +9 -0
- package/dist/agar-extension.js +38 -0
- package/dist/agent-control.d.ts +77 -0
- package/dist/agent-control.js +434 -0
- package/dist/client-entry.d.ts +211 -0
- package/dist/client-entry.js +101 -0
- package/dist/client-wire.d.ts +199 -0
- package/dist/client-wire.js +271 -0
- package/dist/client.d.ts +439 -0
- package/dist/client.js +4 -0
- package/dist/cloudflare.d.ts +220 -0
- package/dist/cloudflare.js +531 -0
- package/dist/effect.d.ts +42 -0
- package/dist/effect.js +20 -0
- package/dist/errors.d.ts +50 -0
- package/dist/errors.js +81 -0
- package/dist/extension-client.d.ts +38 -0
- package/dist/extension-client.js +56 -0
- package/dist/extension-contract.d.ts +73 -0
- package/dist/extension-contract.js +11 -0
- package/dist/extensions.d.ts +589 -0
- package/dist/extensions.js +263 -0
- package/dist/fleet.d.ts +313 -0
- package/dist/fleet.js +540 -0
- package/dist/hosted.d.ts +133 -0
- package/dist/hosted.js +265 -0
- package/dist/http-routes.d.ts +772 -0
- package/dist/http-routes.js +242 -0
- package/dist/http.d.ts +1 -0
- package/dist/http.js +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +13 -0
- package/dist/internal/accepted-run-executor.d.ts +23 -0
- package/dist/internal/accepted-run-executor.js +129 -0
- package/dist/internal/admission-door.d.ts +75 -0
- package/dist/internal/admission-door.js +105 -0
- package/dist/internal/agent-close.d.ts +4 -0
- package/dist/internal/agent-close.js +42 -0
- package/dist/internal/browser-sessions.d.ts +31 -0
- package/dist/internal/browser-sessions.js +173 -0
- package/dist/internal/client-boundary.d.ts +262 -0
- package/dist/internal/client-boundary.js +202 -0
- package/dist/internal/compaction/compaction.d.ts +54 -0
- package/dist/internal/compaction/compaction.js +291 -0
- package/dist/internal/compaction/session-compaction.d.ts +69 -0
- package/dist/internal/compaction/session-compaction.js +330 -0
- package/dist/internal/compaction/settings.d.ts +11 -0
- package/dist/internal/compaction/settings.js +40 -0
- package/dist/internal/compaction/utils.d.ts +45 -0
- package/dist/internal/compaction/utils.js +319 -0
- package/dist/internal/contracts.d.ts +235 -0
- package/dist/internal/contracts.js +1 -0
- package/dist/internal/coordinator.d.ts +18 -0
- package/dist/internal/coordinator.js +362 -0
- package/dist/internal/document-codec.d.ts +11 -0
- package/dist/internal/document-codec.js +39 -0
- package/dist/internal/effect-client.d.ts +13 -0
- package/dist/internal/effect-client.js +102 -0
- package/dist/internal/effect-contracts.d.ts +236 -0
- package/dist/internal/effect-contracts.js +2 -0
- package/dist/internal/extension-command-registry.d.ts +11 -0
- package/dist/internal/extension-command-registry.js +29 -0
- package/dist/internal/extension-command-tools.d.ts +17 -0
- package/dist/internal/extension-command-tools.js +50 -0
- package/dist/internal/extension-context.d.ts +25 -0
- package/dist/internal/extension-context.js +35 -0
- package/dist/internal/extension-definitions.d.ts +5 -0
- package/dist/internal/extension-definitions.js +6 -0
- package/dist/internal/extension-hook.d.ts +25 -0
- package/dist/internal/extension-hook.js +46 -0
- package/dist/internal/extension-roster.d.ts +23 -0
- package/dist/internal/extension-roster.js +228 -0
- package/dist/internal/extension-runtime.d.ts +63 -0
- package/dist/internal/extension-runtime.js +1004 -0
- package/dist/internal/failure.d.ts +2 -0
- package/dist/internal/failure.js +9 -0
- package/dist/internal/host-meta.d.ts +41 -0
- package/dist/internal/host-meta.js +39 -0
- package/dist/internal/json-value.d.ts +4 -0
- package/dist/internal/json-value.js +3 -0
- package/dist/internal/model-acquisition.d.ts +21 -0
- package/dist/internal/model-acquisition.js +98 -0
- package/dist/internal/model-preference.d.ts +21 -0
- package/dist/internal/model-preference.js +20 -0
- package/dist/internal/observation-kernel.d.ts +28 -0
- package/dist/internal/observation-kernel.js +169 -0
- package/dist/internal/promise-facade.d.ts +18 -0
- package/dist/internal/promise-facade.js +172 -0
- package/dist/internal/run-scope.d.ts +27 -0
- package/dist/internal/run-scope.js +214 -0
- package/dist/internal/runtime-coordinator.d.ts +34 -0
- package/dist/internal/runtime-coordinator.js +233 -0
- package/dist/internal/runtime-core.d.ts +19 -0
- package/dist/internal/runtime-core.js +39 -0
- package/dist/internal/runtime-reconciliation.d.ts +18 -0
- package/dist/internal/runtime-reconciliation.js +162 -0
- package/dist/internal/session-context.d.ts +11 -0
- package/dist/internal/session-context.js +67 -0
- package/dist/internal/session-status.d.ts +10 -0
- package/dist/internal/session-status.js +52 -0
- package/dist/internal/woodstock/agent-reply.d.ts +25 -0
- package/dist/internal/woodstock/agent-reply.js +67 -0
- package/dist/internal/woodstock/client-projection.d.ts +29 -0
- package/dist/internal/woodstock/client-projection.js +512 -0
- package/dist/internal/woodstock/compaction-activity.d.ts +17 -0
- package/dist/internal/woodstock/compaction-activity.js +32 -0
- package/dist/internal/woodstock/cursor.d.ts +9 -0
- package/dist/internal/woodstock/cursor.js +44 -0
- package/dist/internal/woodstock/extension-store.d.ts +72 -0
- package/dist/internal/woodstock/extension-store.js +262 -0
- package/dist/internal/woodstock/fleet-store.d.ts +36 -0
- package/dist/internal/woodstock/fleet-store.js +100 -0
- package/dist/internal/woodstock/identities.d.ts +6 -0
- package/dist/internal/woodstock/identities.js +11 -0
- package/dist/internal/woodstock/index.d.ts +170 -0
- package/dist/internal/woodstock/index.js +546 -0
- package/dist/internal/woodstock/progress.d.ts +32 -0
- package/dist/internal/woodstock/progress.js +89 -0
- package/dist/internal/woodstock/run-recovery.d.ts +8 -0
- package/dist/internal/woodstock/run-recovery.js +95 -0
- package/dist/internal/woodstock/session-attention.d.ts +16 -0
- package/dist/internal/woodstock/session-attention.js +88 -0
- package/dist/internal/woodstock/session-documents.d.ts +18 -0
- package/dist/internal/woodstock/session-documents.js +51 -0
- package/dist/internal/woodstock/session-entry.d.ts +478 -0
- package/dist/internal/woodstock/session-entry.js +484 -0
- package/dist/internal/woodstock/session-grants.d.ts +24 -0
- package/dist/internal/woodstock/session-grants.js +84 -0
- package/dist/internal/woodstock/session-inbox.d.ts +56 -0
- package/dist/internal/woodstock/session-inbox.js +307 -0
- package/dist/internal/woodstock/session-store.d.ts +432 -0
- package/dist/internal/woodstock/session-store.js +2006 -0
- package/dist/internal/woodstock/storage-admission.d.ts +14 -0
- package/dist/internal/woodstock/storage-admission.js +44 -0
- package/dist/model-preference.d.ts +20 -0
- package/dist/model-preference.js +30 -0
- package/dist/node.d.ts +64 -0
- package/dist/node.js +256 -0
- package/dist/remote-client.d.ts +11 -0
- package/dist/remote-client.js +298 -0
- package/dist/session-attention.d.ts +35 -0
- package/dist/session-attention.js +22 -0
- package/dist/session-documents.d.ts +28 -0
- package/dist/session-documents.js +1 -0
- package/dist/testing.d.ts +54 -0
- package/dist/testing.js +215 -0
- package/docs/api/README.md +26 -0
- package/docs/api/agar-extension.md +40 -0
- package/docs/api/agent-control.md +151 -0
- package/docs/api/client-entry.md +344 -0
- package/docs/api/client.md +1112 -0
- package/docs/api/cloudflare.md +500 -0
- package/docs/api/effect.md +884 -0
- package/docs/api/extensions.md +2003 -0
- package/docs/api/fleet.md +734 -0
- package/docs/api/hosted.md +382 -0
- package/docs/api/http.md +111 -0
- package/docs/api/index.md +1116 -0
- package/docs/api/model-preference.md +151 -0
- package/docs/api/node.md +142 -0
- package/docs/api/testing.md +250 -0
- package/package.json +130 -3
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
import type { Message, MuleIdentity, MuleToolResult, ToolCall, Usage, UserMessage } from "@fungi.computer/mule/effect";
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
|
+
import * as Result from "effect/Result";
|
|
4
|
+
/** Provider-native usage grammar shared by stored messages and settlement facts. */
|
|
5
|
+
export declare const usage: Schema.Codec<Usage>;
|
|
6
|
+
/** Exact Pi message grammar stored by Woodstock without normalization. */
|
|
7
|
+
export declare const StoredPiMessageSchema: Schema.Codec<Message>;
|
|
8
|
+
declare const LiveRetryEventSchema: Schema.Union<readonly [Schema.Struct<{
|
|
9
|
+
readonly type: Schema.Literal<"auto_retry_start">;
|
|
10
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
11
|
+
readonly attempt: Schema.Number;
|
|
12
|
+
readonly maxAttempts: Schema.Number;
|
|
13
|
+
readonly delayMs: Schema.Number;
|
|
14
|
+
readonly errorMessage: Schema.String;
|
|
15
|
+
}>, Schema.Struct<{
|
|
16
|
+
readonly type: Schema.Literal<"auto_retry_attempt">;
|
|
17
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
18
|
+
readonly attempt: Schema.Number;
|
|
19
|
+
}>, Schema.Struct<{
|
|
20
|
+
readonly type: Schema.Literal<"auto_retry_end">;
|
|
21
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
22
|
+
readonly attempt: Schema.Number;
|
|
23
|
+
readonly success: Schema.Boolean;
|
|
24
|
+
readonly finalError: Schema.optionalKey<Schema.String>;
|
|
25
|
+
}>]>;
|
|
26
|
+
/**
|
|
27
|
+
* One retained Pi live-retry observation, as Woodstock stores it under its
|
|
28
|
+
* `live_retry` session entry kind. Mule's retry loop (`retryAssistantCall`
|
|
29
|
+
* wrapped around each assistant call in `packages/mule/src/effect.ts`)
|
|
30
|
+
* produces the generic `MuleRetryObservation`; `run-scope.ts` maps that onto
|
|
31
|
+
* this exact shape before calling `recordLiveRetryEvent`.
|
|
32
|
+
*/
|
|
33
|
+
export type LiveRetryEvent = Schema.Schema.Type<typeof LiveRetryEventSchema>;
|
|
34
|
+
/** What started one compaction: the user, the context threshold, or an overflow. */
|
|
35
|
+
declare const CompactionTriggerSchema: Schema.Literals<readonly ["manual", "threshold", "overflow"]>;
|
|
36
|
+
/** What started one compaction. */
|
|
37
|
+
export type CompactionTrigger = Schema.Schema.Type<typeof CompactionTriggerSchema>;
|
|
38
|
+
/** Closed grammar stored in one retained Session entry JSON column. */
|
|
39
|
+
declare const StoredSessionEntrySchema: Schema.Union<readonly [Schema.Struct<{
|
|
40
|
+
readonly kind: Schema.Literal<"sandbox_failure">;
|
|
41
|
+
readonly event: Schema.Struct<{
|
|
42
|
+
readonly kind: Schema.Literal<"sandbox_failure">;
|
|
43
|
+
readonly ref: Schema.String;
|
|
44
|
+
readonly executionId: Schema.String;
|
|
45
|
+
readonly adapter: Schema.String;
|
|
46
|
+
readonly buildSha: Schema.NullOr<Schema.String>;
|
|
47
|
+
readonly tag: Schema.Literals<readonly ["SourceInvalid", "GuestThrew", "DeadlineExceeded", "Cancelled", "DispatchLost", "SandboxCrashed", "BadResponse", "ResultTooLarge", "ResultNotJson", "CapabilityFailed", "Unknown"]>;
|
|
48
|
+
readonly fields: Schema.$Record<Schema.String, Schema.Codec<import("zod").JSONType, import("zod").JSONType, never, never>>;
|
|
49
|
+
readonly healthAlert: Schema.Boolean;
|
|
50
|
+
}>;
|
|
51
|
+
readonly workId: Schema.String;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly kind: Schema.Literal<"document">;
|
|
54
|
+
readonly workId: Schema.Null;
|
|
55
|
+
readonly extensionId: Schema.String;
|
|
56
|
+
readonly name: Schema.String;
|
|
57
|
+
readonly valueJson: Schema.String;
|
|
58
|
+
}>, Schema.Struct<{
|
|
59
|
+
readonly kind: Schema.Literal<"model_preference">;
|
|
60
|
+
readonly workId: Schema.Null;
|
|
61
|
+
readonly preference: Schema.NullOr<Schema.Struct<{
|
|
62
|
+
readonly providerId: Schema.String;
|
|
63
|
+
readonly modelId: Schema.String;
|
|
64
|
+
readonly reasoning: Schema.optional<Schema.Literals<readonly ["minimal", "low", "medium", "high", "xhigh", "max"]>>;
|
|
65
|
+
}>>;
|
|
66
|
+
}>, Schema.Struct<{
|
|
67
|
+
readonly kind: Schema.Literal<"command">;
|
|
68
|
+
readonly meta: Schema.optionalKey<Schema.Codec<import("../../extensions.js").Json, import("../../extensions.js").Json, never, never>>;
|
|
69
|
+
/** Present only when the host admitted this line as a verified Agent reply. */
|
|
70
|
+
readonly reply: Schema.optionalKey<Schema.Struct<{
|
|
71
|
+
readonly commandId: Schema.String;
|
|
72
|
+
readonly outcome: Schema.Literals<readonly ["completed", "failed", "interrupted", "cancelled", "outcome_unknown"]>;
|
|
73
|
+
readonly diagnostic: Schema.optionalKey<Schema.String>;
|
|
74
|
+
readonly agentId: Schema.String;
|
|
75
|
+
readonly sessionId: Schema.String;
|
|
76
|
+
}>>;
|
|
77
|
+
readonly delivery: Schema.optionalKey<Schema.Literals<readonly ["steer", "followUp"]>>;
|
|
78
|
+
readonly requestId: Schema.String;
|
|
79
|
+
readonly targetWorkId: Schema.optionalKey<Schema.String>;
|
|
80
|
+
readonly receiptId: Schema.String;
|
|
81
|
+
readonly message: Schema.Codec<UserMessage, UserMessage, never, never>;
|
|
82
|
+
readonly contract: Schema.Struct<{
|
|
83
|
+
readonly core: Schema.String;
|
|
84
|
+
readonly extensions: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
85
|
+
}>;
|
|
86
|
+
readonly workId: Schema.String;
|
|
87
|
+
}>, Schema.Struct<{
|
|
88
|
+
readonly kind: Schema.Literal<"command">;
|
|
89
|
+
readonly work: Schema.Literal<"compact">;
|
|
90
|
+
/** The user's focus for the summary, as Pi's `/compact <instructions>`. */
|
|
91
|
+
readonly instructions: Schema.optionalKey<Schema.String>;
|
|
92
|
+
readonly meta: Schema.optionalKey<Schema.Codec<import("../../extensions.js").Json, import("../../extensions.js").Json, never, never>>;
|
|
93
|
+
readonly requestId: Schema.String;
|
|
94
|
+
readonly receiptId: Schema.String;
|
|
95
|
+
readonly timestamp: Schema.Int;
|
|
96
|
+
readonly contract: Schema.Struct<{
|
|
97
|
+
readonly core: Schema.String;
|
|
98
|
+
readonly extensions: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
99
|
+
}>;
|
|
100
|
+
readonly workId: Schema.String;
|
|
101
|
+
}>, Schema.Struct<{
|
|
102
|
+
readonly kind: Schema.Literal<"operator">;
|
|
103
|
+
readonly workId: Schema.Null;
|
|
104
|
+
readonly requestId: Schema.String;
|
|
105
|
+
readonly author: Schema.Literals<readonly ["operator", "party"]>;
|
|
106
|
+
readonly meta: Schema.optionalKey<Schema.Codec<import("../../extensions.js").Json, import("../../extensions.js").Json, never, never>>;
|
|
107
|
+
readonly message: Schema.Struct<{
|
|
108
|
+
readonly role: Schema.Literal<"user">;
|
|
109
|
+
readonly content: Schema.String;
|
|
110
|
+
readonly timestamp: Schema.Number;
|
|
111
|
+
}>;
|
|
112
|
+
}>, Schema.Struct<{
|
|
113
|
+
readonly kind: Schema.Literal<"cancellation">;
|
|
114
|
+
readonly requestId: Schema.String;
|
|
115
|
+
readonly receiptId: Schema.String;
|
|
116
|
+
readonly targetWorkId: Schema.String;
|
|
117
|
+
readonly meta: Schema.optionalKey<Schema.Codec<import("../../extensions.js").Json, import("../../extensions.js").Json, never, never>>;
|
|
118
|
+
readonly workId: Schema.String;
|
|
119
|
+
}>, Schema.Struct<{
|
|
120
|
+
readonly kind: Schema.Literal<"model_selection">;
|
|
121
|
+
readonly provider: Schema.String;
|
|
122
|
+
readonly model: Schema.String;
|
|
123
|
+
readonly catalogRevision: Schema.String;
|
|
124
|
+
readonly definitionRevision: Schema.String;
|
|
125
|
+
readonly selectionPolicyRevision: Schema.String;
|
|
126
|
+
readonly workId: Schema.String;
|
|
127
|
+
}>, Schema.Struct<{
|
|
128
|
+
readonly kind: Schema.Literal<"run_started">;
|
|
129
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
130
|
+
readonly contract: Schema.Struct<{
|
|
131
|
+
readonly core: Schema.String;
|
|
132
|
+
readonly extensions: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
133
|
+
}>;
|
|
134
|
+
readonly workId: Schema.String;
|
|
135
|
+
}>, Schema.Struct<{
|
|
136
|
+
readonly kind: Schema.Literal<"turn_started">;
|
|
137
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
138
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
139
|
+
readonly workId: Schema.String;
|
|
140
|
+
}>, Schema.Struct<{
|
|
141
|
+
readonly kind: Schema.Literal<"model_prompt">;
|
|
142
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
143
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
144
|
+
readonly attempt: Schema.Number;
|
|
145
|
+
readonly contract: Schema.Struct<{
|
|
146
|
+
readonly core: Schema.String;
|
|
147
|
+
readonly extensions: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
148
|
+
}>;
|
|
149
|
+
readonly systemPrompt: Schema.String;
|
|
150
|
+
readonly workId: Schema.String;
|
|
151
|
+
}>, Schema.Struct<{
|
|
152
|
+
readonly kind: Schema.Literal<"message_start">;
|
|
153
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
154
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
155
|
+
readonly message: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
156
|
+
readonly role: Schema.Literals<readonly ["assistant", "system", "toolResult", "user"]>;
|
|
157
|
+
readonly workId: Schema.String;
|
|
158
|
+
}>, Schema.Struct<{
|
|
159
|
+
readonly kind: Schema.Literal<"message">;
|
|
160
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
161
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
162
|
+
readonly message: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
163
|
+
readonly value: Schema.Codec<Message, Message, never, never>;
|
|
164
|
+
readonly workId: Schema.String;
|
|
165
|
+
}>, Schema.Struct<{
|
|
166
|
+
readonly kind: Schema.Literal<"tool_intent">;
|
|
167
|
+
readonly replay: Schema.withDecodingDefaultType<Schema.Literals<readonly ["safe", "unsafe"]>, never>;
|
|
168
|
+
readonly contract: Schema.Struct<{
|
|
169
|
+
readonly core: Schema.String;
|
|
170
|
+
readonly extensions: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
|
|
171
|
+
}>;
|
|
172
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
173
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
174
|
+
readonly toolCall: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
175
|
+
readonly call: Schema.Codec<ToolCall, ToolCall, never, never>;
|
|
176
|
+
readonly workId: Schema.String;
|
|
177
|
+
}>, Schema.Struct<{
|
|
178
|
+
readonly kind: Schema.Literal<"tool_outcome">;
|
|
179
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
180
|
+
readonly turn: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
181
|
+
readonly toolCall: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
182
|
+
readonly call: Schema.Codec<ToolCall, ToolCall, never, never>;
|
|
183
|
+
readonly result: Schema.Codec<MuleToolResult, MuleToolResult, never, never>;
|
|
184
|
+
readonly workId: Schema.String;
|
|
185
|
+
}>, Schema.Struct<{
|
|
186
|
+
readonly kind: Schema.Literal<"live_retry">;
|
|
187
|
+
readonly event: Schema.Union<readonly [Schema.Struct<{
|
|
188
|
+
readonly type: Schema.Literal<"auto_retry_start">;
|
|
189
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
190
|
+
readonly attempt: Schema.Number;
|
|
191
|
+
readonly maxAttempts: Schema.Number;
|
|
192
|
+
readonly delayMs: Schema.Number;
|
|
193
|
+
readonly errorMessage: Schema.String;
|
|
194
|
+
}>, Schema.Struct<{
|
|
195
|
+
readonly type: Schema.Literal<"auto_retry_attempt">;
|
|
196
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
197
|
+
readonly attempt: Schema.Number;
|
|
198
|
+
}>, Schema.Struct<{
|
|
199
|
+
readonly type: Schema.Literal<"auto_retry_end">;
|
|
200
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
201
|
+
readonly attempt: Schema.Number;
|
|
202
|
+
readonly success: Schema.Boolean;
|
|
203
|
+
readonly finalError: Schema.optionalKey<Schema.String>;
|
|
204
|
+
}>]>;
|
|
205
|
+
readonly workId: Schema.String;
|
|
206
|
+
}>, Schema.Struct<{
|
|
207
|
+
readonly kind: Schema.Literal<"compaction">;
|
|
208
|
+
readonly resumesRun: Schema.optionalKey<Schema.Boolean>;
|
|
209
|
+
readonly trigger: Schema.optionalKey<Schema.Literals<readonly ["manual", "threshold", "overflow"]>>;
|
|
210
|
+
/** Estimated context tokens right after this compaction. */
|
|
211
|
+
readonly tokensAfter: Schema.optionalKey<Schema.Number>;
|
|
212
|
+
readonly firstKeptEntryId: Schema.String;
|
|
213
|
+
readonly summary: Schema.String;
|
|
214
|
+
readonly tokensBefore: Schema.Number;
|
|
215
|
+
readonly usage: Schema.Codec<Usage, Usage, never, never>;
|
|
216
|
+
readonly contextRevision: Schema.String;
|
|
217
|
+
readonly details: Schema.optionalKey<Schema.Struct<{
|
|
218
|
+
readonly readFiles: Schema.$Array<Schema.String>;
|
|
219
|
+
readonly modifiedFiles: Schema.$Array<Schema.String>;
|
|
220
|
+
}>>;
|
|
221
|
+
readonly workId: Schema.String;
|
|
222
|
+
}>, Schema.Struct<{
|
|
223
|
+
readonly kind: Schema.Literal<"compaction_notice">;
|
|
224
|
+
readonly trigger: Schema.Literals<readonly ["manual", "threshold", "overflow"]>;
|
|
225
|
+
readonly result: Schema.Literals<readonly ["nothing_to_compact", "failed"]>;
|
|
226
|
+
readonly diagnostic: Schema.optionalKey<Schema.String>;
|
|
227
|
+
readonly workId: Schema.String;
|
|
228
|
+
}>, Schema.Struct<{
|
|
229
|
+
readonly kind: Schema.Literal<"run_terminal">;
|
|
230
|
+
readonly run: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
231
|
+
readonly terminal: Schema.Codec<MuleIdentity, MuleIdentity, never, never>;
|
|
232
|
+
readonly outcome: Schema.Literals<readonly ["completed", "cancelled", "failed"]>;
|
|
233
|
+
readonly workId: Schema.String;
|
|
234
|
+
}>, Schema.Struct<{
|
|
235
|
+
readonly kind: Schema.Literal<"work_terminal">;
|
|
236
|
+
readonly diagnostic: Schema.optionalKey<Schema.String>;
|
|
237
|
+
readonly outcome: Schema.Literals<readonly ["completed", "interrupted", "cancelled", "failed"]>;
|
|
238
|
+
readonly workId: Schema.String;
|
|
239
|
+
}>]>;
|
|
240
|
+
export type StoredSessionEntry = Schema.Schema.Type<typeof StoredSessionEntrySchema>;
|
|
241
|
+
/** Accepted Session work: a prompt, or a manual compaction request. */
|
|
242
|
+
export type CommandSessionEntry = Extract<StoredSessionEntry, {
|
|
243
|
+
kind: "command";
|
|
244
|
+
}>;
|
|
245
|
+
/** A manual compaction request; it carries no message. */
|
|
246
|
+
export type CompactCommandEntry = Extract<CommandSessionEntry, {
|
|
247
|
+
work: "compact";
|
|
248
|
+
}>;
|
|
249
|
+
/** A prompt command: the only command that enters model context. */
|
|
250
|
+
export type PromptCommandEntry = Exclude<CommandSessionEntry, CompactCommandEntry>;
|
|
251
|
+
/** Whether accepted work is a manual compaction request. */
|
|
252
|
+
export declare function isCompactCommand(entry: CommandSessionEntry): entry is CompactCommandEntry;
|
|
253
|
+
/** The prompt a command carries; a compaction request carries none. */
|
|
254
|
+
export declare function promptCommand(entry: StoredSessionEntry): PromptCommandEntry | undefined;
|
|
255
|
+
/** When the command was accepted, as its own data records it. */
|
|
256
|
+
export declare function commandTimestamp(entry: CommandSessionEntry): number;
|
|
257
|
+
export type OperatorSessionEntry = Extract<StoredSessionEntry, {
|
|
258
|
+
kind: "operator";
|
|
259
|
+
}>;
|
|
260
|
+
/**
|
|
261
|
+
* What a later model run sees of an operator line: always a user-role note,
|
|
262
|
+
* so a human's words are never presented as the model's own output.
|
|
263
|
+
*/
|
|
264
|
+
export declare function operatorContextMessage(entry: OperatorSessionEntry): UserMessage;
|
|
265
|
+
/**
|
|
266
|
+
* What a model run sees of an accepted command: its stored user line, wrapped
|
|
267
|
+
* as a verified Agent reply only when the host admitted it as one.
|
|
268
|
+
*/
|
|
269
|
+
export declare function commandContextMessage(entry: PromptCommandEntry): UserMessage;
|
|
270
|
+
/**
|
|
271
|
+
* What a client sees of an operator line: the party's words as a user
|
|
272
|
+
* message, the operator's as an assistant message from provider `operator`.
|
|
273
|
+
*/
|
|
274
|
+
export declare function operatorClientMessage(entry: OperatorSessionEntry): Message;
|
|
275
|
+
/** Decode the one JSON representation admitted by retained Session storage. */
|
|
276
|
+
export declare function decodeStoredSessionEntry(value: string): Result.Result<{
|
|
277
|
+
readonly kind: "sandbox_failure";
|
|
278
|
+
readonly event: {
|
|
279
|
+
readonly kind: "sandbox_failure";
|
|
280
|
+
readonly ref: string;
|
|
281
|
+
readonly executionId: string;
|
|
282
|
+
readonly adapter: string;
|
|
283
|
+
readonly buildSha: string | null;
|
|
284
|
+
readonly tag: "Unknown" | "SourceInvalid" | "GuestThrew" | "DeadlineExceeded" | "Cancelled" | "DispatchLost" | "SandboxCrashed" | "BadResponse" | "ResultTooLarge" | "ResultNotJson" | "CapabilityFailed";
|
|
285
|
+
readonly fields: {
|
|
286
|
+
readonly [x: string]: import("zod").JSONType;
|
|
287
|
+
};
|
|
288
|
+
readonly healthAlert: boolean;
|
|
289
|
+
};
|
|
290
|
+
readonly workId: string;
|
|
291
|
+
} | {
|
|
292
|
+
readonly kind: "document";
|
|
293
|
+
readonly workId: null;
|
|
294
|
+
readonly extensionId: string;
|
|
295
|
+
readonly name: string;
|
|
296
|
+
readonly valueJson: string;
|
|
297
|
+
} | {
|
|
298
|
+
readonly kind: "model_preference";
|
|
299
|
+
readonly workId: null;
|
|
300
|
+
readonly preference: {
|
|
301
|
+
readonly providerId: string;
|
|
302
|
+
readonly modelId: string;
|
|
303
|
+
readonly reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | undefined;
|
|
304
|
+
} | null;
|
|
305
|
+
} | {
|
|
306
|
+
readonly kind: "command";
|
|
307
|
+
readonly contract: {
|
|
308
|
+
readonly core: string;
|
|
309
|
+
readonly extensions: readonly (readonly [string, string])[];
|
|
310
|
+
};
|
|
311
|
+
readonly requestId: string;
|
|
312
|
+
readonly message: UserMessage;
|
|
313
|
+
readonly workId: string;
|
|
314
|
+
readonly receiptId: string;
|
|
315
|
+
readonly delivery?: "followUp" | "steer";
|
|
316
|
+
readonly meta?: import("../../extensions.js").Json;
|
|
317
|
+
readonly reply?: {
|
|
318
|
+
readonly sessionId: string;
|
|
319
|
+
readonly commandId: string;
|
|
320
|
+
readonly outcome: "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
|
|
321
|
+
readonly agentId: string;
|
|
322
|
+
readonly diagnostic?: string;
|
|
323
|
+
};
|
|
324
|
+
readonly targetWorkId?: string;
|
|
325
|
+
} | {
|
|
326
|
+
readonly kind: "command";
|
|
327
|
+
readonly contract: {
|
|
328
|
+
readonly core: string;
|
|
329
|
+
readonly extensions: readonly (readonly [string, string])[];
|
|
330
|
+
};
|
|
331
|
+
readonly requestId: string;
|
|
332
|
+
readonly workId: string;
|
|
333
|
+
readonly timestamp: number;
|
|
334
|
+
readonly receiptId: string;
|
|
335
|
+
readonly work: "compact";
|
|
336
|
+
readonly instructions?: string;
|
|
337
|
+
readonly meta?: import("../../extensions.js").Json;
|
|
338
|
+
} | {
|
|
339
|
+
readonly kind: "operator";
|
|
340
|
+
readonly requestId: string;
|
|
341
|
+
readonly message: {
|
|
342
|
+
readonly role: "user";
|
|
343
|
+
readonly content: string;
|
|
344
|
+
readonly timestamp: number;
|
|
345
|
+
};
|
|
346
|
+
readonly workId: null;
|
|
347
|
+
readonly author: "operator" | "party";
|
|
348
|
+
readonly meta?: import("../../extensions.js").Json;
|
|
349
|
+
} | {
|
|
350
|
+
readonly kind: "cancellation";
|
|
351
|
+
readonly requestId: string;
|
|
352
|
+
readonly workId: string;
|
|
353
|
+
readonly targetWorkId: string;
|
|
354
|
+
readonly receiptId: string;
|
|
355
|
+
readonly meta?: import("../../extensions.js").Json;
|
|
356
|
+
} | {
|
|
357
|
+
readonly kind: "model_selection";
|
|
358
|
+
readonly provider: string;
|
|
359
|
+
readonly model: string;
|
|
360
|
+
readonly catalogRevision: string;
|
|
361
|
+
readonly definitionRevision: string;
|
|
362
|
+
readonly selectionPolicyRevision: string;
|
|
363
|
+
readonly workId: string;
|
|
364
|
+
} | {
|
|
365
|
+
readonly kind: "run_started";
|
|
366
|
+
readonly run: MuleIdentity;
|
|
367
|
+
readonly contract: {
|
|
368
|
+
readonly core: string;
|
|
369
|
+
readonly extensions: readonly (readonly [string, string])[];
|
|
370
|
+
};
|
|
371
|
+
readonly workId: string;
|
|
372
|
+
} | {
|
|
373
|
+
readonly kind: "turn_started";
|
|
374
|
+
readonly run: MuleIdentity;
|
|
375
|
+
readonly turn: MuleIdentity;
|
|
376
|
+
readonly workId: string;
|
|
377
|
+
} | {
|
|
378
|
+
readonly kind: "model_prompt";
|
|
379
|
+
readonly run: MuleIdentity;
|
|
380
|
+
readonly turn: MuleIdentity;
|
|
381
|
+
readonly attempt: number;
|
|
382
|
+
readonly contract: {
|
|
383
|
+
readonly core: string;
|
|
384
|
+
readonly extensions: readonly (readonly [string, string])[];
|
|
385
|
+
};
|
|
386
|
+
readonly systemPrompt: string;
|
|
387
|
+
readonly workId: string;
|
|
388
|
+
} | {
|
|
389
|
+
readonly kind: "message_start";
|
|
390
|
+
readonly run: MuleIdentity;
|
|
391
|
+
readonly turn: MuleIdentity;
|
|
392
|
+
readonly message: MuleIdentity;
|
|
393
|
+
readonly role: "user" | "assistant" | "system" | "toolResult";
|
|
394
|
+
readonly workId: string;
|
|
395
|
+
} | {
|
|
396
|
+
readonly kind: "message";
|
|
397
|
+
readonly run: MuleIdentity;
|
|
398
|
+
readonly turn: MuleIdentity;
|
|
399
|
+
readonly message: MuleIdentity;
|
|
400
|
+
readonly value: Message;
|
|
401
|
+
readonly workId: string;
|
|
402
|
+
} | {
|
|
403
|
+
readonly kind: "tool_intent";
|
|
404
|
+
readonly replay: "unsafe" | "safe";
|
|
405
|
+
readonly contract: {
|
|
406
|
+
readonly core: string;
|
|
407
|
+
readonly extensions: readonly (readonly [string, string])[];
|
|
408
|
+
};
|
|
409
|
+
readonly run: MuleIdentity;
|
|
410
|
+
readonly turn: MuleIdentity;
|
|
411
|
+
readonly toolCall: MuleIdentity;
|
|
412
|
+
readonly call: ToolCall;
|
|
413
|
+
readonly workId: string;
|
|
414
|
+
} | {
|
|
415
|
+
readonly kind: "tool_outcome";
|
|
416
|
+
readonly run: MuleIdentity;
|
|
417
|
+
readonly turn: MuleIdentity;
|
|
418
|
+
readonly toolCall: MuleIdentity;
|
|
419
|
+
readonly call: ToolCall;
|
|
420
|
+
readonly result: MuleToolResult;
|
|
421
|
+
readonly workId: string;
|
|
422
|
+
} | {
|
|
423
|
+
readonly kind: "live_retry";
|
|
424
|
+
readonly event: {
|
|
425
|
+
readonly type: "auto_retry_start";
|
|
426
|
+
readonly run: MuleIdentity;
|
|
427
|
+
readonly attempt: number;
|
|
428
|
+
readonly maxAttempts: number;
|
|
429
|
+
readonly delayMs: number;
|
|
430
|
+
readonly errorMessage: string;
|
|
431
|
+
} | {
|
|
432
|
+
readonly type: "auto_retry_attempt";
|
|
433
|
+
readonly run: MuleIdentity;
|
|
434
|
+
readonly attempt: number;
|
|
435
|
+
} | {
|
|
436
|
+
readonly run: MuleIdentity;
|
|
437
|
+
readonly success: boolean;
|
|
438
|
+
readonly type: "auto_retry_end";
|
|
439
|
+
readonly attempt: number;
|
|
440
|
+
readonly finalError?: string;
|
|
441
|
+
};
|
|
442
|
+
readonly workId: string;
|
|
443
|
+
} | {
|
|
444
|
+
readonly kind: "compaction";
|
|
445
|
+
readonly summary: string;
|
|
446
|
+
readonly workId: string;
|
|
447
|
+
readonly usage: Usage;
|
|
448
|
+
readonly firstKeptEntryId: string;
|
|
449
|
+
readonly tokensBefore: number;
|
|
450
|
+
readonly contextRevision: string;
|
|
451
|
+
readonly resumesRun?: boolean;
|
|
452
|
+
readonly trigger?: "manual" | "threshold" | "overflow";
|
|
453
|
+
readonly tokensAfter?: number;
|
|
454
|
+
readonly details?: {
|
|
455
|
+
readonly readFiles: readonly string[];
|
|
456
|
+
readonly modifiedFiles: readonly string[];
|
|
457
|
+
};
|
|
458
|
+
} | {
|
|
459
|
+
readonly kind: "compaction_notice";
|
|
460
|
+
readonly workId: string;
|
|
461
|
+
readonly result: "failed" | "nothing_to_compact";
|
|
462
|
+
readonly trigger: "manual" | "threshold" | "overflow";
|
|
463
|
+
readonly diagnostic?: string;
|
|
464
|
+
} | {
|
|
465
|
+
readonly kind: "run_terminal";
|
|
466
|
+
readonly run: MuleIdentity;
|
|
467
|
+
readonly terminal: MuleIdentity;
|
|
468
|
+
readonly outcome: "completed" | "failed" | "cancelled";
|
|
469
|
+
readonly workId: string;
|
|
470
|
+
} | {
|
|
471
|
+
readonly kind: "work_terminal";
|
|
472
|
+
readonly workId: string;
|
|
473
|
+
readonly outcome: "completed" | "failed" | "cancelled" | "interrupted";
|
|
474
|
+
readonly diagnostic?: string;
|
|
475
|
+
}, Schema.SchemaError>;
|
|
476
|
+
/** Serialize Pi's JSON representation, then validate the retained entry. */
|
|
477
|
+
export declare function encodeStoredSessionEntry(entry: StoredSessionEntry): string;
|
|
478
|
+
export {};
|