@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,589 @@
|
|
|
1
|
+
import type { FileTool } from "@fungi.computer/knapsack";
|
|
2
|
+
import type { AttentionItem } from "./session-attention.js";
|
|
3
|
+
export { AttentionItemSchema, type AttentionItem, type SessionAttention, } from "./session-attention.js";
|
|
4
|
+
import type { Message, Usage } from "@fungi.computer/mule/effect";
|
|
5
|
+
import type { ModuleRegistration } from "@fungi.computer/mycelium";
|
|
6
|
+
import * as Brand from "effect/Brand";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Result from "effect/Result";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import type * as Scope from "effect/Scope";
|
|
13
|
+
import type { StateUpdate } from "./internal/extension-hook.js";
|
|
14
|
+
import type { DocumentHandlesV0, DocumentsV0 } from "./session-documents.js";
|
|
15
|
+
import { ExtensionId, extensionFingerprintSchema, extensionRevisionSchema, type CommandsV0, type ExtensionCapabilityV0, type ExtensionContractV0, type ExtensionManifestV0 } from "./extension-contract.js";
|
|
16
|
+
export { ExtensionId, extensionIdentifier, extensionVersion, } from "./extension-contract.js";
|
|
17
|
+
export type { AnyCommandSpecV0, ClientActivityV0, CommandsV0, CommandSpecV0, ExtensionCapabilityV0, ExtensionContractV0, ExtensionManifestV0, ProjectionSpecV0, ShiitakeExtensionProtocolV0, } from "./extension-contract.js";
|
|
18
|
+
import { type RegisteredExtensionCommandV0 } from "./internal/extension-command-registry.js";
|
|
19
|
+
export type { RegisteredExtensionCommandV0 } from "./internal/extension-command-registry.js";
|
|
20
|
+
import { type CommandToolsV0 } from "./internal/extension-command-tools.js";
|
|
21
|
+
export type { CommandToolOptionsV0, CommandToolsV0, } from "./internal/extension-command-tools.js";
|
|
22
|
+
import { type ExtensionRuntimePortV0, type CollectionBindingV0 } from "./internal/extension-context.js";
|
|
23
|
+
export type { ExtensionRuntimePortV0, CollectionBindingV0, } from "./internal/extension-context.js";
|
|
24
|
+
import { definitionReader } from "./internal/extension-definitions.js";
|
|
25
|
+
import { ExtensionHookError } from "./internal/extension-hook.js";
|
|
26
|
+
export { ExtensionHookError } from "./internal/extension-hook.js";
|
|
27
|
+
export type { StateUpdate, SyncResult } from "./internal/extension-hook.js";
|
|
28
|
+
import type { ShiitakeError } from "./errors.js";
|
|
29
|
+
/** `sha256:<64 hex>` derived by core from a definition; never authored. */
|
|
30
|
+
export type ExtensionRevision = typeof extensionRevisionSchema.Type;
|
|
31
|
+
/** `sha256:<64 hex>` over one revision and its sorted granted capabilities. */
|
|
32
|
+
export type ExtensionFingerprint = typeof extensionFingerprintSchema.Type;
|
|
33
|
+
/** JSON value accepted as hashed extension configuration. */
|
|
34
|
+
export type Json = null | boolean | number | string | readonly Json[] | Readonly<{
|
|
35
|
+
[key: string]: Json;
|
|
36
|
+
}>;
|
|
37
|
+
/** Parse a serialized extension value into the finite JSON contract. */
|
|
38
|
+
export declare function parseExtensionJson(source: string): Json;
|
|
39
|
+
/** Host decision: the exact subset of requested capabilities it grants. */
|
|
40
|
+
export type ExtensionGrantV0 = Readonly<{
|
|
41
|
+
id: ExtensionId;
|
|
42
|
+
/** Missing grant row means an empty grant. */
|
|
43
|
+
capabilities: readonly ExtensionCapabilityV0[];
|
|
44
|
+
/**
|
|
45
|
+
* The key the host's tool grants name this extension's run_tools modules
|
|
46
|
+
* by; defaults to the extension id. Several extensions may share one key.
|
|
47
|
+
*/
|
|
48
|
+
grantKey?: string;
|
|
49
|
+
}>;
|
|
50
|
+
declare const ExtensionRead_base: Context.ServiceClass<ExtensionRead, "@fungi.computer/shiitake/ExtensionRead", Readonly<{
|
|
51
|
+
extensionId: ExtensionId;
|
|
52
|
+
}>>;
|
|
53
|
+
/** Present only inside a core-run read (projection, run tools, hooks). */
|
|
54
|
+
export declare class ExtensionRead extends ExtensionRead_base {
|
|
55
|
+
}
|
|
56
|
+
declare const ExtensionTx_base: Context.ServiceClass<ExtensionTx, "@fungi.computer/shiitake/ExtensionTx", Readonly<{
|
|
57
|
+
extensionId: ExtensionId;
|
|
58
|
+
}>>;
|
|
59
|
+
/**
|
|
60
|
+
* Present only inside a core-run write transaction (hooks, commands,
|
|
61
|
+
* `transact`). Core runs these Effects synchronously inside the owner
|
|
62
|
+
* transaction; an asynchronous boundary is a defect that stops the extension.
|
|
63
|
+
*/
|
|
64
|
+
export declare class ExtensionTx extends ExtensionTx_base {
|
|
65
|
+
}
|
|
66
|
+
declare const ExtensionStateError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
67
|
+
readonly _tag: "ExtensionStateError";
|
|
68
|
+
} & Readonly<A>;
|
|
69
|
+
/** Durable record failure: stored or supplied values broke their schema or bounds. */
|
|
70
|
+
export declare class ExtensionStateError extends ExtensionStateError_base<{
|
|
71
|
+
reason: "decode" | "encode" | "bound" | "unavailable";
|
|
72
|
+
message: string;
|
|
73
|
+
}> {
|
|
74
|
+
}
|
|
75
|
+
declare const AdmissionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
76
|
+
readonly _tag: "AdmissionError";
|
|
77
|
+
} & Readonly<A>;
|
|
78
|
+
/** The door refused an extension admission. */
|
|
79
|
+
export declare class AdmissionError extends AdmissionError_base<{
|
|
80
|
+
reason: "invalid" | "conflict" | "closed";
|
|
81
|
+
message: string;
|
|
82
|
+
}> {
|
|
83
|
+
}
|
|
84
|
+
declare const ExtensionCommandError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
85
|
+
readonly _tag: "ExtensionCommandError";
|
|
86
|
+
} & Readonly<A>;
|
|
87
|
+
/** Typed rejection of one extension command, returned to its caller. */
|
|
88
|
+
export declare class ExtensionCommandError extends ExtensionCommandError_base<{
|
|
89
|
+
reason: "invalid" | "conflict" | "not_found" | "rejected";
|
|
90
|
+
message: string;
|
|
91
|
+
}> {
|
|
92
|
+
}
|
|
93
|
+
declare const ExtensionStop_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
94
|
+
readonly _tag: "ExtensionStop";
|
|
95
|
+
} & Readonly<A>;
|
|
96
|
+
/** Fail a hook with this (or die) to stop this extension with a visible reason. */
|
|
97
|
+
export declare class ExtensionStop extends ExtensionStop_base<{
|
|
98
|
+
reason: string;
|
|
99
|
+
}> {
|
|
100
|
+
}
|
|
101
|
+
declare const ExtensionActivationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
102
|
+
readonly _tag: "ExtensionActivationError";
|
|
103
|
+
} & Readonly<A>;
|
|
104
|
+
/** Typed activation failure; the extension is stopped with this message. */
|
|
105
|
+
export declare class ExtensionActivationError extends ExtensionActivationError_base<{
|
|
106
|
+
message: string;
|
|
107
|
+
}> {
|
|
108
|
+
}
|
|
109
|
+
/** Failures a background hook may return; each one stops only its extension. */
|
|
110
|
+
export type HookError = ExtensionStop | ExtensionStateError | AdmissionError | ExtensionHookError;
|
|
111
|
+
/** One namespaced collection: its row schema is the only stored-row decoder. */
|
|
112
|
+
export type CollectionSpecV0<A, I> = Readonly<{
|
|
113
|
+
schema: Schema.Codec<A, I>;
|
|
114
|
+
/** Capture this schema and its typed operations before core erases the declaration. */
|
|
115
|
+
bind: (port: ExtensionRuntimePortV0, name: string) => Readonly<{
|
|
116
|
+
read: CollectionV0<A>;
|
|
117
|
+
update: UpdateCollectionV0<A>;
|
|
118
|
+
}>;
|
|
119
|
+
/** Decode migration input before invoking the declared index. */
|
|
120
|
+
indexFromEncoded: (value: Json) => Result.Result<string | null, Schema.SchemaError>;
|
|
121
|
+
/** Primary key, 1..256 characters. */
|
|
122
|
+
key: (value: A) => string;
|
|
123
|
+
/** Optional secondary index value, 1..256 characters or null. */
|
|
124
|
+
index?: (value: A) => string | null;
|
|
125
|
+
}>;
|
|
126
|
+
/** Existential collection spec stored by core. */
|
|
127
|
+
export type AnyCollectionSpecV0 = Readonly<{
|
|
128
|
+
schema: Schema.Codec<unknown>;
|
|
129
|
+
/** Captured handle factory; callers retain its concrete return type. */
|
|
130
|
+
bind: (port: ExtensionRuntimePortV0, name: string) => CollectionBindingV0;
|
|
131
|
+
/** Schema-owned migration indexing. */
|
|
132
|
+
indexFromEncoded: (value: Json) => Result.Result<string | null, Schema.SchemaError>;
|
|
133
|
+
/** Primary key of one decoded row. */
|
|
134
|
+
key: (value: never) => string;
|
|
135
|
+
/** Optional secondary index of one decoded row. */
|
|
136
|
+
index?: (value: never) => string | null;
|
|
137
|
+
}>;
|
|
138
|
+
/** Collections declared by one extension. */
|
|
139
|
+
export type CollectionsV0 = Readonly<Record<string, AnyCollectionSpecV0>>;
|
|
140
|
+
/** One stored record as seen by a pure migration. */
|
|
141
|
+
export type StoredRecordV0 = Readonly<{
|
|
142
|
+
collection: string;
|
|
143
|
+
key: string;
|
|
144
|
+
value: Json;
|
|
145
|
+
}>;
|
|
146
|
+
/** Versioned state declaration; core runs pure row migrations at activation. */
|
|
147
|
+
export type StateSpecV0<C extends CollectionsV0> = Readonly<{
|
|
148
|
+
/** Positive integer; bump on any collection schema change. */
|
|
149
|
+
version: number;
|
|
150
|
+
collections: C;
|
|
151
|
+
/**
|
|
152
|
+
* Keyed by from-version. Total and pure; core applies them in order in one
|
|
153
|
+
* transaction at activation, then re-decodes every row. A stored version
|
|
154
|
+
* above the declared version fails admission (no downgrade).
|
|
155
|
+
*/
|
|
156
|
+
migrations: Readonly<Record<number, (row: StoredRecordV0) => readonly StoredRecordV0[]>>;
|
|
157
|
+
}>;
|
|
158
|
+
/** The versioned state declaration as authored; version defaults to 1. */
|
|
159
|
+
export type StateDeclarationV0<C extends CollectionsV0> = Readonly<{
|
|
160
|
+
version?: number | undefined;
|
|
161
|
+
collections: C;
|
|
162
|
+
migrations?: StateSpecV0<C>["migrations"] | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
/** Typed access to one collection inside a core transaction. */
|
|
165
|
+
export type CollectionV0<A> = Readonly<{
|
|
166
|
+
/** Synchronous read, available only while core builds a Session projection. */
|
|
167
|
+
peek: (key: string) => Option.Option<A>;
|
|
168
|
+
/** Bounded synchronous page while core builds a Session projection. */
|
|
169
|
+
peekPage: (query: Readonly<{
|
|
170
|
+
index?: string | undefined;
|
|
171
|
+
after?: string | undefined;
|
|
172
|
+
limit: number;
|
|
173
|
+
}>) => readonly A[];
|
|
174
|
+
/** Read one record by key. */
|
|
175
|
+
get: (key: string) => Effect.Effect<Option.Option<A>, ExtensionStateError, ExtensionRead>;
|
|
176
|
+
/** Ordered by key, optionally within one index value; `limit` is 1..64. */
|
|
177
|
+
page: (query: Readonly<{
|
|
178
|
+
index?: string | undefined;
|
|
179
|
+
after?: string | undefined;
|
|
180
|
+
limit: number;
|
|
181
|
+
}>) => Effect.Effect<readonly A[], ExtensionStateError, ExtensionRead>;
|
|
182
|
+
/** Upsert one record under its declared key. */
|
|
183
|
+
put: (value: A) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
184
|
+
/** Delete one record; an absent key is a no-op. */
|
|
185
|
+
remove: (key: string) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
186
|
+
}>;
|
|
187
|
+
/** The transaction-local interface used by plain synchronous state.update. */
|
|
188
|
+
export type UpdateCollectionV0<A> = Readonly<{
|
|
189
|
+
/** Read one row by its collection key. */
|
|
190
|
+
get: (key: string) => Option.Option<A>;
|
|
191
|
+
/** Read at most 64 rows in key order. */
|
|
192
|
+
page: (query: Readonly<{
|
|
193
|
+
index?: string | undefined;
|
|
194
|
+
after?: string | undefined;
|
|
195
|
+
limit: number;
|
|
196
|
+
}>) => readonly A[];
|
|
197
|
+
/** Schema-validate and upsert one record. */
|
|
198
|
+
put: (value: A) => void;
|
|
199
|
+
/** Remove one record if present. */
|
|
200
|
+
remove: (key: string) => void;
|
|
201
|
+
}>;
|
|
202
|
+
/** Transaction-scoped collections plus post-commit Session notification. */
|
|
203
|
+
export type UpdateStateV0<C extends CollectionsV0> = {
|
|
204
|
+
readonly [K in keyof C]: ReturnType<C[K]["bind"]>["update"];
|
|
205
|
+
} & Readonly<{
|
|
206
|
+
/** Publish a changed Session after the update commits. */
|
|
207
|
+
observe: (sessionId: string) => void;
|
|
208
|
+
}>;
|
|
209
|
+
/** Synchronous, read-only collection access inside `state.read`. */
|
|
210
|
+
export type ReadStateV0<C extends CollectionsV0> = {
|
|
211
|
+
readonly [K in keyof C]: Pick<ReturnType<C[K]["bind"]>["update"], "get" | "page">;
|
|
212
|
+
};
|
|
213
|
+
/** Typed handles for every declared collection. */
|
|
214
|
+
export type StateHandleV0<C extends CollectionsV0> = {
|
|
215
|
+
readonly [K in keyof C]: ReturnType<C[K]["bind"]>["read"];
|
|
216
|
+
} & Readonly<{
|
|
217
|
+
/** One short, synchronous SQLite transaction; async callbacks are refused. */
|
|
218
|
+
update: StateUpdate<UpdateStateV0<C>>;
|
|
219
|
+
/**
|
|
220
|
+
* Read rows synchronously outside a transaction (prompt sections, tools).
|
|
221
|
+
* Unavailable inside a command, hook or projection; those already hold one.
|
|
222
|
+
*/
|
|
223
|
+
read: StateUpdate<ReadStateV0<C>>;
|
|
224
|
+
}>;
|
|
225
|
+
/** Watchdog settlement or exact Woodstock terminal of one run. */
|
|
226
|
+
export type RunOutcomeV0 = "completed" | "failed" | "cancelled" | "interrupted" | "outcome_unknown";
|
|
227
|
+
/** Extension that admitted a run, with its stored correlation. */
|
|
228
|
+
export type RunOriginV0 = Readonly<{
|
|
229
|
+
extensionId: ExtensionId;
|
|
230
|
+
correlation: string | null;
|
|
231
|
+
}>;
|
|
232
|
+
/** One settled run joined by core with its terminal and admission origin. */
|
|
233
|
+
export type SettledRunV0 = Readonly<{
|
|
234
|
+
/** Watchdog settled-record sequence; delivery is ascending. */
|
|
235
|
+
sequence: number;
|
|
236
|
+
sessionId: string;
|
|
237
|
+
workId: string;
|
|
238
|
+
/** Watchdog settlement. */
|
|
239
|
+
outcome: RunOutcomeV0;
|
|
240
|
+
/** Exact Woodstock terminal for this work, joined by core. */
|
|
241
|
+
terminal: RunOutcomeV0 | "missing";
|
|
242
|
+
/** Distinct tool calls started during this work, including failed calls. */
|
|
243
|
+
toolCalls: number;
|
|
244
|
+
/** Null for human, mail or host admissions. */
|
|
245
|
+
origin: RunOriginV0 | null;
|
|
246
|
+
}>;
|
|
247
|
+
/** 1..64 records, ascending, each delivered to each running extension once. */
|
|
248
|
+
export type SettledPageV0 = readonly SettledRunV0[];
|
|
249
|
+
/** One prompt sent through the accepted-command door. */
|
|
250
|
+
export type SendInputV0 = Readonly<{
|
|
251
|
+
sessionId: string;
|
|
252
|
+
/** Refuse absent targets instead of creating a Session for this admission. */
|
|
253
|
+
requireExistingSession?: boolean;
|
|
254
|
+
/** Encoded prompt, decoded by the same schema as human prompts. */
|
|
255
|
+
prompt: Readonly<{
|
|
256
|
+
text: string;
|
|
257
|
+
requestId: string;
|
|
258
|
+
delivery: "followUp" | "steer";
|
|
259
|
+
}>;
|
|
260
|
+
/** `idle` admits only while the Session queue head is idle. */
|
|
261
|
+
when: "now" | "idle";
|
|
262
|
+
/** Stored with the admission and returned on `SettledRunV0.origin`. */
|
|
263
|
+
correlation?: string;
|
|
264
|
+
}>;
|
|
265
|
+
/** Door outcome for one extension admission. */
|
|
266
|
+
export type SendResultV0 = Readonly<{
|
|
267
|
+
_tag: "Accepted";
|
|
268
|
+
commandId: string;
|
|
269
|
+
delivery: "new" | "replay";
|
|
270
|
+
}> | Readonly<{
|
|
271
|
+
_tag: "NotReady";
|
|
272
|
+
}>;
|
|
273
|
+
/** Durable per-extension wake timers (the scheduling substrate). */
|
|
274
|
+
export type TimersV0 = Readonly<{
|
|
275
|
+
/** Upsert one timer; `dueAt` is epoch milliseconds. */
|
|
276
|
+
set: (key: string, dueAt: number) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
277
|
+
/** Delete one timer; an absent key is a no-op. */
|
|
278
|
+
cancel: (key: string) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
279
|
+
/** Read one timer's due instant. */
|
|
280
|
+
read: (key: string) => Effect.Effect<Option.Option<number>, ExtensionStateError, ExtensionRead>;
|
|
281
|
+
}>;
|
|
282
|
+
/** A fired timer; its row is consumed unless the handler sets it again. */
|
|
283
|
+
export type FiredTimerV0 = Readonly<{
|
|
284
|
+
key: string;
|
|
285
|
+
dueAt: number;
|
|
286
|
+
firedAt: number;
|
|
287
|
+
}>;
|
|
288
|
+
/** A command's scope fixes whether its invocation names a Session. */
|
|
289
|
+
export type CommandSessionIdsV0 = {
|
|
290
|
+
agent: null;
|
|
291
|
+
session: string;
|
|
292
|
+
};
|
|
293
|
+
/** Handlers for every declared command, run in one core transaction. */
|
|
294
|
+
export type CommandHandlersV0<C extends CommandsV0> = {
|
|
295
|
+
readonly [K in keyof C]: (call: Readonly<{
|
|
296
|
+
sessionId: CommandSessionIdsV0[C[K]["scope"]];
|
|
297
|
+
input: C[K]["input"]["Type"];
|
|
298
|
+
}>) => C[K]["output"]["Type"] | Effect.Effect<C[K]["output"]["Type"], ExtensionCommandError | ExtensionStateError | AdmissionError, ExtensionTx | ExtensionRead>;
|
|
299
|
+
};
|
|
300
|
+
/** Transaction-scoped, extension-owned attention on an existing Session. */
|
|
301
|
+
export type AttentionV0 = Readonly<{
|
|
302
|
+
/** Upsert this extension’s item and publish the committed Session change. */
|
|
303
|
+
set: (sessionId: string, item: AttentionItem) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
304
|
+
/** Clear this extension’s item; other owners cannot be changed. */
|
|
305
|
+
clear: (sessionId: string, id: string) => Effect.Effect<void, ExtensionStateError, ExtensionTx>;
|
|
306
|
+
}>;
|
|
307
|
+
/** Everything core hands one activated extension. */
|
|
308
|
+
export type ExtensionContextV0<S extends CollectionsV0, Config extends Json, D extends DocumentsV0 = DocumentsV0> = Readonly<{
|
|
309
|
+
manifest: ExtensionManifestV0;
|
|
310
|
+
revision: ExtensionRevision;
|
|
311
|
+
grants: readonly ExtensionCapabilityV0[];
|
|
312
|
+
/** The hashed value; prose and constants come only from here. */
|
|
313
|
+
config: Config;
|
|
314
|
+
state: StateHandleV0<S>;
|
|
315
|
+
/** Transaction-scoped handles for this extension's Session documents. */
|
|
316
|
+
documents: DocumentHandlesV0<D>;
|
|
317
|
+
/** Send one prompt through the accepted-command door in this transaction. */
|
|
318
|
+
send: (input: SendInputV0) => Effect.Effect<SendResultV0, AdmissionError, ExtensionTx>;
|
|
319
|
+
timers: TimersV0;
|
|
320
|
+
attention: AttentionV0;
|
|
321
|
+
/** Observe accepted steering without consuming Mule's next control delivery. Requires run_tools. */
|
|
322
|
+
hasPendingSteer: (run: Pick<RunIdentityV0, "sessionId" | "workId">) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
|
|
323
|
+
/** Whether this run durably recorded a successful tool outcome. Requires run_tools. */
|
|
324
|
+
hasSuccessfulToolResult: (run: Pick<RunIdentityV0, "sessionId" | "workId">, toolCallId: string) => Effect.Effect<boolean, ExtensionStateError, ExtensionRead>;
|
|
325
|
+
/** Publish a Session observation after this transaction commits. */
|
|
326
|
+
observe: (sessionId: string) => Effect.Effect<void, never, ExtensionTx>;
|
|
327
|
+
/**
|
|
328
|
+
* Run one write transaction from outside a hook (for example a Mycelium
|
|
329
|
+
* tool execute). Core commits, publishes, and requests a wake when it
|
|
330
|
+
* admitted work or changed a timer. Fails with a `store`/`unavailable`
|
|
331
|
+
* `ShiitakeError` when the stop this body caused could not be recorded
|
|
332
|
+
* durably.
|
|
333
|
+
*/
|
|
334
|
+
transact: <A, E>(body: Effect.Effect<A, E, ExtensionTx | ExtensionRead>) => Effect.Effect<A, E | ExtensionStop | ShiitakeError>;
|
|
335
|
+
}>;
|
|
336
|
+
/** One run the extension may attach tools to. */
|
|
337
|
+
export type RunIdentityV0 = Readonly<{
|
|
338
|
+
sessionId: string;
|
|
339
|
+
workId: string;
|
|
340
|
+
origin: RunOriginV0 | null;
|
|
341
|
+
}>;
|
|
342
|
+
/** A named, bounded system-prompt section; core orders by extension and name. */
|
|
343
|
+
export type PromptSectionV0 = Readonly<{
|
|
344
|
+
name: string;
|
|
345
|
+
text: string;
|
|
346
|
+
}>;
|
|
347
|
+
/** Hooks returned by one activation; each runs in its own isolation boundary. */
|
|
348
|
+
export type AgentHooksV0<C extends CommandsV0, P> = Readonly<{
|
|
349
|
+
/** Receive each settled run once; the cursor advances in the same transaction. */
|
|
350
|
+
onSettled?: (page: SettledPageV0) => Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
|
|
351
|
+
/** Handle one fired timer in its own transaction. */
|
|
352
|
+
onTimer?: (timer: FiredTimerV0) => Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
|
|
353
|
+
/** Attach one Mycelium module to a run this extension participates in. */
|
|
354
|
+
moduleForRun?: (run: RunIdentityV0) => Effect.Effect<Option.Option<ModuleRegistration>, HookError, ExtensionRead>;
|
|
355
|
+
/** The exclusive Files holder's branded tools, captured once per run. */
|
|
356
|
+
filesForRun?: (run: RunIdentityV0) => Effect.Effect<Option.Option<readonly FileTool[]>, HookError, ExtensionRead>;
|
|
357
|
+
/** Re-evaluated for each model request, including a retry. */
|
|
358
|
+
prompt?: (run: RunIdentityV0) => readonly PromptSectionV0[] | Promise<readonly PromptSectionV0[]> | Effect.Effect<readonly PromptSectionV0[], HookError, ExtensionRead>;
|
|
359
|
+
/** Project this extension's slot for one Session observation. */
|
|
360
|
+
project?: (sessionId: string) => Option.Option<P>;
|
|
361
|
+
/** The exclusive compaction handoff, when granted `compaction_handoff`. */
|
|
362
|
+
compactionHandoff?: CompactionHandoffV0;
|
|
363
|
+
/** Command handlers keyed by command name. */
|
|
364
|
+
commands: CommandHandlersV0<C>;
|
|
365
|
+
}>;
|
|
366
|
+
/** Core's activated representation; authors use ExtensionDefinitionV0 below. */
|
|
367
|
+
/** Opaque rostered value; core reads the definition existentially. */
|
|
368
|
+
export type RosteredExtensionV0 = Readonly<{
|
|
369
|
+
manifest: ExtensionManifestV0;
|
|
370
|
+
/** Private captured definition; absent on an unregistered roster entry. */
|
|
371
|
+
[definitionReader]?: () => AnyExtensionDefinitionV0;
|
|
372
|
+
}> & Brand.Brand<"RosteredExtensionV0">;
|
|
373
|
+
/** A defined extension: its roster entry and the client contract it declares. */
|
|
374
|
+
export type DefinedExtensionV0<C extends CommandsV0, P, PI> = RosteredExtensionV0 & Readonly<{
|
|
375
|
+
contract: ExtensionContractV0<C, P, PI>;
|
|
376
|
+
}>;
|
|
377
|
+
/** Contributions registered against the builder's captured metadata. */
|
|
378
|
+
export type ExtensionDefinitionV0<S extends CollectionsV0, C extends CommandsV0, P, PI, Config extends Json, D extends DocumentsV0 = DocumentsV0> = Readonly<{
|
|
379
|
+
catalog?: Json;
|
|
380
|
+
commands?: Readonly<{
|
|
381
|
+
specs: C;
|
|
382
|
+
/** Register schema-checked transaction handlers. */
|
|
383
|
+
handlers: (context: ExtensionContextV0<S, Config, D>) => CommandHandlersV0<C>;
|
|
384
|
+
}>;
|
|
385
|
+
projection?: Readonly<{
|
|
386
|
+
schema: Schema.Codec<P, PI>;
|
|
387
|
+
/** Project the advertised command catalog from the same Session value. */
|
|
388
|
+
catalog?: (value: P) => Json;
|
|
389
|
+
/**
|
|
390
|
+
* Read the Session slot synchronously inside the snapshot transaction.
|
|
391
|
+
* Return the value (or an `Option`); `undefined` publishes no slot value.
|
|
392
|
+
*/
|
|
393
|
+
read: (context: ExtensionContextV0<S, Config, D>, sessionId: string) => P | Option.Option<P> | undefined;
|
|
394
|
+
}>;
|
|
395
|
+
/** Rebuild named system-prompt sections before each model request. */
|
|
396
|
+
prompt?: (context: ExtensionContextV0<S, Config, D>, run: RunIdentityV0) => readonly PromptSectionV0[] | Promise<readonly PromptSectionV0[]> | Effect.Effect<readonly PromptSectionV0[], HookError, ExtensionRead>;
|
|
397
|
+
/** Contribute a gated Mycelium module outside the write transaction. */
|
|
398
|
+
tools?: (context: ExtensionContextV0<S, Config, D>, run: RunIdentityV0,
|
|
399
|
+
/** Each declared command as a model tool, bound to this run's Session. */
|
|
400
|
+
commands: CommandToolsV0<C>) => ModuleRegistration | null | Promise<ModuleRegistration | null> | Effect.Effect<ModuleRegistration | null | Option.Option<ModuleRegistration>, HookError, ExtensionRead>;
|
|
401
|
+
/** Supply only Knapsack-minted direct tools; core captures and gates them. */
|
|
402
|
+
files?: (context: ExtensionContextV0<S, Config, D>, run: RunIdentityV0) => readonly FileTool[] | null | Promise<readonly FileTool[] | null> | Effect.Effect<readonly FileTool[] | null | Option.Option<readonly FileTool[]>, HookError, ExtensionRead>;
|
|
403
|
+
hooks?: Readonly<{
|
|
404
|
+
/** Acquire activation-scoped resources outside the write transaction. */
|
|
405
|
+
start?: (context: ExtensionContextV0<S, Config, D>) => void | Promise<void> | Effect.Effect<void, ExtensionActivationError, Scope.Scope>;
|
|
406
|
+
/** Deliver settled runs and commit the cursor in the same transaction. */
|
|
407
|
+
onSettled?: (context: ExtensionContextV0<S, Config, D>, page: SettledPageV0) => void | Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
|
|
408
|
+
/** Consume a timer and its state changes in the same transaction. */
|
|
409
|
+
onTimer?: (context: ExtensionContextV0<S, Config, D>, timer: FiredTimerV0) => void | Effect.Effect<void, HookError, ExtensionTx | ExtensionRead>;
|
|
410
|
+
}>;
|
|
411
|
+
timers?: true;
|
|
412
|
+
/** Request the generic human-attention door. */
|
|
413
|
+
attention?: true;
|
|
414
|
+
/** Consume the borrowed compaction view before it is released. */
|
|
415
|
+
compaction?: (context: ExtensionContextV0<S, Config, D>) => Readonly<{
|
|
416
|
+
/** Finish the borrowed handoff, including asynchronous delivery. */
|
|
417
|
+
consume: (view: BorrowedCompactionViewV0) => CompactionHandoffResultV0 | Promise<CompactionHandoffResultV0> | Effect.Effect<CompactionHandoffResultV0, CompactionHandoffErrorV0 | ExtensionHookError>;
|
|
418
|
+
}>;
|
|
419
|
+
}>;
|
|
420
|
+
/** Reject Promise-returning transactional commands even when output is `{}`. */
|
|
421
|
+
export type CheckedCommandHandlers<H> = {
|
|
422
|
+
readonly [K in keyof H]: H[K] extends (...args: never[]) => infer Result ? Result extends Promise<unknown> ? never : H[K] : never;
|
|
423
|
+
};
|
|
424
|
+
/** Caller-owned extension metadata and handlers accepted by the v0 builder. */
|
|
425
|
+
export type ExtensionAuthorDefinitionV0<S extends CollectionsV0, C extends CommandsV0, P, PI, Config extends Json, D extends DocumentsV0, H extends CommandHandlersV0<C>> = Omit<ExtensionDefinitionV0<S, C, P, PI, Config, D>, "commands"> & Readonly<{
|
|
426
|
+
commands?: Readonly<{
|
|
427
|
+
specs: C;
|
|
428
|
+
/** Register the author's schema-checked transaction handlers. */
|
|
429
|
+
handlers: (context: ExtensionContextV0<S, Config, D>) => CommandHandlersV0<NoInfer<C>> & H & CheckedCommandHandlers<H>;
|
|
430
|
+
}>;
|
|
431
|
+
}>;
|
|
432
|
+
/** Concrete metadata with no declared fields. */
|
|
433
|
+
export type EmptyExtensionFieldsV0 = Readonly<Record<never, never>>;
|
|
434
|
+
/** Configure typed metadata, then register callbacks against its actual values. */
|
|
435
|
+
export declare class ExtensionBuilderV0<S extends CollectionsV0, Config extends Json, D extends DocumentsV0> {
|
|
436
|
+
private readonly metadata;
|
|
437
|
+
private constructor();
|
|
438
|
+
/** Begin with concrete empty metadata and no requested capability. */
|
|
439
|
+
static fromIdentity(identity: Readonly<{
|
|
440
|
+
id: ExtensionId;
|
|
441
|
+
version: string;
|
|
442
|
+
}>): ExtensionBuilderV0<EmptyExtensionFieldsV0, EmptyExtensionFieldsV0, EmptyExtensionFieldsV0>;
|
|
443
|
+
/** Hash this explicit JSON configuration with the extension revision. */
|
|
444
|
+
config<Next extends Json>(value: Next): ExtensionBuilderV0<S, Next, D>;
|
|
445
|
+
/**
|
|
446
|
+
* Request state and bind handles to each collection's declared schema.
|
|
447
|
+
* Pass the collections alone (state version 1, no migrations) or the full
|
|
448
|
+
* versioned declaration.
|
|
449
|
+
*/
|
|
450
|
+
state<Next extends CollectionsV0>(value: StateDeclarationV0<Next> | Next): ExtensionBuilderV0<Next, Config, D>;
|
|
451
|
+
/** Request bounded Session documents under the state grant. */
|
|
452
|
+
documents<Next extends DocumentsV0>(value: Next): ExtensionBuilderV0<S, Config, Next>;
|
|
453
|
+
/** Register commands without a client entry. */
|
|
454
|
+
define<C extends CommandsV0, P, PI, H extends CommandHandlersV0<C> = CommandHandlersV0<C>>(definition: ExtensionAuthorDefinitionV0<S, C, P, PI, Config, D, H> & {
|
|
455
|
+
readonly commands: Readonly<{
|
|
456
|
+
specs: C;
|
|
457
|
+
handlers: (context: ExtensionContextV0<S, Config, D>) => CommandHandlersV0<NoInfer<C>> & H & CheckedCommandHandlers<H>;
|
|
458
|
+
}>;
|
|
459
|
+
}): DefinedExtensionV0<C, P, PI>;
|
|
460
|
+
/** Register contributions without commands or a client entry. */
|
|
461
|
+
define<P, PI>(definition: ExtensionAuthorDefinitionV0<S, EmptyExtensionFieldsV0, P, PI, Config, D, EmptyExtensionFieldsV0> & {
|
|
462
|
+
readonly commands?: never;
|
|
463
|
+
}): DefinedExtensionV0<EmptyExtensionFieldsV0, P, PI>;
|
|
464
|
+
}
|
|
465
|
+
/** An extension id, or an id with an explicit SemVer version. */
|
|
466
|
+
export type ExtensionIdentityV0 = string | Readonly<{
|
|
467
|
+
id: string;
|
|
468
|
+
version?: string | undefined;
|
|
469
|
+
}>;
|
|
470
|
+
/**
|
|
471
|
+
* Begin with honest empty defaults; optional contributions are declared
|
|
472
|
+
* explicitly. The version defaults to `0.0.0` and any SemVer, including a
|
|
473
|
+
* pre-release, is valid. It is part of the extension's revision, which already
|
|
474
|
+
* covers schemas, config and requested capabilities; a different version marks
|
|
475
|
+
* a behaviour change those do not show, such as a fixed hook.
|
|
476
|
+
*/
|
|
477
|
+
export declare function defineExtension(identity: ExtensionIdentityV0): ExtensionBuilderV0<EmptyExtensionFieldsV0, EmptyExtensionFieldsV0, EmptyExtensionFieldsV0>;
|
|
478
|
+
/** Existential hooks as stored by core; each handler is re-typed by its schema. */
|
|
479
|
+
export type AnyAgentHooksV0 = Readonly<{
|
|
480
|
+
/** Receive each settled run once. */
|
|
481
|
+
onSettled?: NonNullable<AgentHooksV0<CommandsV0, never>["onSettled"]>;
|
|
482
|
+
/** Handle one fired timer. */
|
|
483
|
+
onTimer?: NonNullable<AgentHooksV0<CommandsV0, never>["onTimer"]>;
|
|
484
|
+
/** Attach one Mycelium module to a participating run. */
|
|
485
|
+
moduleForRun?: NonNullable<AgentHooksV0<CommandsV0, never>["moduleForRun"]>;
|
|
486
|
+
filesForRun?: NonNullable<AgentHooksV0<CommandsV0, never>["filesForRun"]>;
|
|
487
|
+
prompt?: NonNullable<AgentHooksV0<CommandsV0, never>["prompt"]>;
|
|
488
|
+
/** Project this extension's slot for one Session observation. */
|
|
489
|
+
project?: (sessionId: string) => Option.Option<unknown>;
|
|
490
|
+
/** Decode the projected Session JSON before producing its advertised catalog. */
|
|
491
|
+
projectCatalog?: (value: Json) => Json;
|
|
492
|
+
compactionHandoff?: CompactionHandoffV0;
|
|
493
|
+
/** Schema-bound handlers captured at activation. */
|
|
494
|
+
commands: ReadonlyMap<string, RegisteredExtensionCommandV0>;
|
|
495
|
+
}>;
|
|
496
|
+
/** Existential definition stored by core. */
|
|
497
|
+
export type AnyExtensionDefinitionV0 = Readonly<{
|
|
498
|
+
manifest: ExtensionManifestV0;
|
|
499
|
+
contract: Readonly<{
|
|
500
|
+
id: ExtensionId;
|
|
501
|
+
commands: CommandsV0;
|
|
502
|
+
projection: Readonly<{
|
|
503
|
+
schema: Schema.Codec<unknown>;
|
|
504
|
+
}> | null;
|
|
505
|
+
}>;
|
|
506
|
+
config: Json;
|
|
507
|
+
state: StateSpecV0<CollectionsV0>;
|
|
508
|
+
documents?: DocumentsV0;
|
|
509
|
+
/** Advertised human command catalog, opaque to core. */
|
|
510
|
+
catalog?: Json;
|
|
511
|
+
/** Core passes the context built for this definition's own types. */
|
|
512
|
+
activate: (port: ExtensionRuntimePortV0) => Effect.Effect<AnyAgentHooksV0, ExtensionActivationError | ExtensionHookError, Scope.Scope>;
|
|
513
|
+
}>;
|
|
514
|
+
/** Declare one collection with its key inferred from the row schema. */
|
|
515
|
+
export declare function defineCollection<A, I>(schema: Schema.Codec<A, I>, keys: Readonly<{
|
|
516
|
+
key: (value: A) => string;
|
|
517
|
+
index?: (value: A) => string | null;
|
|
518
|
+
}>): CollectionSpecV0<A, I>;
|
|
519
|
+
/** A host's explicit roster and grants. */
|
|
520
|
+
export type ExtensionRosterV0 = Readonly<{
|
|
521
|
+
/** At most 64 entries; unordered; activated in ASCII id order. */
|
|
522
|
+
roster: readonly RosteredExtensionV0[];
|
|
523
|
+
grants: readonly ExtensionGrantV0[];
|
|
524
|
+
}>;
|
|
525
|
+
/** Visible lifecycle of one rostered extension (wire representation). */
|
|
526
|
+
export type ExtensionStatusV0 = Readonly<{
|
|
527
|
+
id: string;
|
|
528
|
+
version: string;
|
|
529
|
+
/** The extension's core-derived revision. */
|
|
530
|
+
revision: string;
|
|
531
|
+
status: "running" | "stopped";
|
|
532
|
+
reason: string | null;
|
|
533
|
+
stoppedAt: number | null;
|
|
534
|
+
}>;
|
|
535
|
+
/** One extension's encoded slot in a Session snapshot or frame. */
|
|
536
|
+
export type ExtensionSlotV0 = Readonly<{
|
|
537
|
+
status: "running";
|
|
538
|
+
/** The extension's core-derived revision. */
|
|
539
|
+
revision: string;
|
|
540
|
+
/** Encoded projection value, or null when the extension has none. */
|
|
541
|
+
value: Json;
|
|
542
|
+
/** The extension's advertised command catalog, when it has one. */
|
|
543
|
+
catalog?: Json;
|
|
544
|
+
}> | Readonly<{
|
|
545
|
+
status: "stopped";
|
|
546
|
+
/** The extension's core-derived revision. */
|
|
547
|
+
revision: string;
|
|
548
|
+
reason: string;
|
|
549
|
+
}>;
|
|
550
|
+
/** Borrowed view of the exact objects already built for compaction. */
|
|
551
|
+
export type BorrowedCompactionViewV0 = Readonly<{
|
|
552
|
+
/** Exact Pi preparation array summarized by the history call. */
|
|
553
|
+
messagesToSummarize: readonly Message[];
|
|
554
|
+
/** Exact Pi preparation array summarized for a split turn, when present. */
|
|
555
|
+
turnPrefixMessages: readonly Message[];
|
|
556
|
+
/** Actual Pi compaction result values, before their scope is released. */
|
|
557
|
+
result: Readonly<{
|
|
558
|
+
summary: string;
|
|
559
|
+
firstKeptEntryId: string;
|
|
560
|
+
tokensBefore: number;
|
|
561
|
+
usage: Usage;
|
|
562
|
+
details?: Readonly<{
|
|
563
|
+
readFiles: readonly string[];
|
|
564
|
+
modifiedFiles: readonly string[];
|
|
565
|
+
}>;
|
|
566
|
+
}>;
|
|
567
|
+
/** Owner-issued revision of the selected context being compacted. */
|
|
568
|
+
contextRevision: string;
|
|
569
|
+
}>;
|
|
570
|
+
/** Result returned before a borrowed compaction view may be released. */
|
|
571
|
+
export type CompactionHandoffResultV0 = Readonly<{
|
|
572
|
+
type: "accepted";
|
|
573
|
+
/** Opaque receipt issued by the archive owner. */
|
|
574
|
+
receipt: string;
|
|
575
|
+
}> | Readonly<{
|
|
576
|
+
type: "discarded_by_policy";
|
|
577
|
+
}>;
|
|
578
|
+
/** Typed failure returned by the compaction contribution. */
|
|
579
|
+
export type CompactionHandoffErrorV0 = Readonly<{
|
|
580
|
+
/** Stable error tag for handoff failure. */
|
|
581
|
+
_tag: "CompactionHandoffError";
|
|
582
|
+
/** Bounded, caller-safe explanation. */
|
|
583
|
+
message: string;
|
|
584
|
+
}>;
|
|
585
|
+
/** The exclusive compaction handoff callable of one extension. */
|
|
586
|
+
export type CompactionHandoffV0 = Readonly<{
|
|
587
|
+
/** Consume one borrowed view before its objects are released. */
|
|
588
|
+
consume: (view: BorrowedCompactionViewV0) => Effect.Effect<CompactionHandoffResultV0, CompactionHandoffErrorV0 | ExtensionHookError>;
|
|
589
|
+
}>;
|