@melite/estate-drafts 0.0.0-stage → 0.1.5-pre-alpha

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/lib/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { Context, Plugin } from "@deepseek-ai/cordis";
2
+ import type { DraftsConfig } from "./store.js";
3
+ export { BenchRemoteService, DraftsRemoteService, installBenchChangeSeam } from "./remote.js";
4
+ export { resolveStorageRoot, openDraftsDomain, } from "./store.js";
5
+ export type { DraftsConfig } from "./store.js";
6
+ export { DRAFT_ID_RE, draftIdOk } from "./spec.js";
7
+ export type { CharacterRecord } from "./spec.js";
8
+ export type { BenchChangeSeam } from "./bench.js";
9
+ export { setBenchChangeSeam } from "./bench.js";
10
+ export type { BenchEnsureRow, BenchGetRow, DraftListResult, DraftListRow, } from "./remote.js";
11
+ export declare const name = "estate-drafts";
12
+ export declare function apply(ctx: Context, config?: DraftsConfig): void;
13
+ declare const plugin: Plugin;
14
+ export default plugin;
15
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import { BenchRemoteService, DraftsRemoteService } from "./remote.js";
2
+ import { DraftsDomainSeatService } from "./store.js";
3
+ export { BenchRemoteService, DraftsRemoteService, installBenchChangeSeam } from "./remote.js";
4
+ export { resolveStorageRoot, openDraftsDomain, } from "./store.js";
5
+ export { DRAFT_ID_RE, draftIdOk } from "./spec.js";
6
+ export { setBenchChangeSeam } from "./bench.js";
7
+ export const name = "estate-drafts";
8
+ export function apply(ctx, config = {}) {
9
+ // the domain seat mounts FIRST — the remote services' writers open
10
+ // the drafts domain through it (openDraftsDomain probes this seat)
11
+ new DraftsDomainSeatService(ctx, config);
12
+ new DraftsRemoteService(ctx);
13
+ new BenchRemoteService(ctx);
14
+ }
15
+ const plugin = { name, apply };
16
+ export default plugin;
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,325 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
3
+ import { STAGE_PATCH_KEYS, type StagePatchKey } from "@melite/contracts/benchStage";
4
+ export { STAGE_PATCH_KEYS, type StagePatchKey };
5
+ import { type LaneMigration } from "./bench.js";
6
+ import type { BenchEnsureRow, BenchGetRow, BenchPatchRow, BenchReorderRow, BenchRewireRow, BenchClearRow, BenchStageRow, BenchUndoRow } from "./bench.js";
7
+ export type { BenchEnsureRow, BenchGetRow, BenchPatchRow, BenchReorderRow, BenchRewireRow, BenchStageRow, BenchUndoRow, } from "./bench.js";
8
+ /** Endpoint `drafts/patch` answer — the old door's delivered envelope:
9
+ * a missing doc/stage is delivered:false + reason (a DOMAIN outcome,
10
+ * never an error); a landing patch reports the patched key set and
11
+ * the bench revision it landed at (the CAS law's re-read handle). */
12
+ export interface DraftPatchRow {
13
+ draftId: string;
14
+ stageId: string;
15
+ delivered: boolean;
16
+ reason?: string;
17
+ patched?: string[];
18
+ rev?: number;
19
+ }
20
+ /** draft_id_ok: 1..96 chars of [A-Za-z0-9_-] (the composer mint). */
21
+ /** One listed draft — the index row (recency-ordered by the caller). */
22
+ export interface DraftListRow {
23
+ readonly draft_id: string;
24
+ readonly model: string;
25
+ readonly name: string;
26
+ }
27
+ /** The list result: rows capped at 600, count total pre-cap. */
28
+ export interface DraftListResult {
29
+ readonly count: number;
30
+ readonly drafts: readonly DraftListRow[];
31
+ }
32
+ /** JSON at the wire — the constrained face of every open doc. The
33
+ * Typert generator's boundary law refuses unconstrained `unknown`
34
+ * data in @Remote signatures (assertRemoteJsonType: "Remote
35
+ * boundary contains unconstrained unknown data"); open card
36
+ * payloads (stage params, results, history) are honestly JSON all
37
+ * the way down, so the wire face says exactly that. */
38
+
39
+
40
+
41
+
42
+
43
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
44
+ readonly [key: string]: JsonValue;
45
+ };
46
+ /** Endpoint `drafts/get` answer — the stored draft doc (open,
47
+ * card-authored) with its stages resolved for the wire. */
48
+ export type DraftGetRow = {
49
+ readonly [key: string]: JsonValue;
50
+ };
51
+ /** Endpoint `drafts/patch` body — the door's FIXED key set (unknown
52
+ * keys refuse at admission with the old door's voice; STAGE_PATCH_KEYS).
53
+ * Optional: presence IS the write; a null params value is the
54
+ * merge-patch DELETE (the layered-params law); a null health value
55
+ * is the same DELETE (the recovery clear, LOW-23). */
56
+ export type DraftStagePatch = {
57
+ params?: JsonValue;
58
+ result?: JsonValue;
59
+ runStatus?: JsonValue;
60
+ health?: JsonValue;
61
+ inputs?: JsonValue;
62
+ inputOutputs?: JsonValue;
63
+ };
64
+ /** The bench verbs' wire body — an open JSON doc (each verb's
65
+ * admission law constrains its own keys at the door: stage,
66
+ * expect_rev, index, binding, …). */
67
+ export type BenchDoc = {
68
+ readonly [key: string]: JsonValue;
69
+ };
70
+ /** The drafts' Remote failure codes, merged into the protocol's one
71
+ * vocabulary (cookbook §2: declaration merging, next to the throw). */
72
+ declare module "@deepseek-ai/dsh-typert-protocol" {
73
+ interface RemoteErrorDetailsMap {
74
+ /** The id fails the [A-Za-z0-9_-]{1,96} draft law. */
75
+ "draft/bad-id": {
76
+ readonly draftId: string;
77
+ };
78
+ /** No stored draft carries that id. */
79
+ "draft/not-found": {
80
+ readonly draftId: string;
81
+ };
82
+ /** The storage open refused an otherwise valid call. */
83
+ "draft/store-failed": Record<string, never>;
84
+ /** The stage id is empty/non-string (the patch door). */
85
+ "draft/bad-stage-id": {
86
+ readonly stageId: string;
87
+ };
88
+ /** The patch body is not a plain object (the patch door). */
89
+ "draft/bad-patch": Record<string, never>;
90
+ /** Keys outside the door's fixed set (the old voice names them). */
91
+ "draft/patch-unknown-keys": {
92
+ readonly unknown: readonly string[];
93
+ };
94
+ /** The domain write refused (put failed at the medium). */
95
+ "draft/cannot-persist": Record<string, never>;
96
+ }
97
+ }
98
+ declare module "@deepseek-ai/cordis" {
99
+ interface Context {
100
+ draftsRemote: DraftsRemoteService;
101
+ benchRemote: BenchRemoteService;
102
+ }
103
+ interface Events {
104
+ /**
105
+ * A bench write landed. Emitted after every successful bench verb
106
+ * (and after the drafts-patch door's bench-shaped write).
107
+ * @mode emit
108
+ * @param session - the bench session whose doc changed.
109
+ */
110
+ "bench.changed": (session: string) => void;
111
+ }
112
+ }
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ export declare function installBenchChangeSeam(ctx: Context): () => void;
133
+ /** ── THE OUTPUT HISTORY HELPERS (stroke 40) ──────────────────────
134
+ * resultOutputUrls now lives in trail.ts (the cycle-free seam) and
135
+ * is re-exported below with the trail laws. ───────────────────── */
136
+ export declare function sameResultOutputs(a: unknown, b: unknown): boolean;
137
+
138
+
139
+
140
+
141
+ export { canonicalOutputUrl, resultOutputUrls, isTerminalTrailWord as isTerminalWord, trailDedupe } from "./trail.js";
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+ export declare function admissionOf(ctx: Context): ((card: string, params: Record<string, unknown>, provenance: unknown) => void) | undefined;
164
+
165
+
166
+
167
+
168
+
169
+ export declare const RESTORED_PROVENANCE: unique symbol;
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+ export declare const RESTORED_WIRE_SPELLING = "restored";
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ export declare function laneAdmissionOf(ctx: Context): ((card: string, params: Record<string, unknown>, provenance: unknown) => void) | undefined;
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ export declare function laneMigrationOf(ctx: Context): LaneMigration | undefined;
205
+
206
+
207
+
208
+
209
+
210
+ export declare function benchAdmissionOf(ctx: Context): ((card: string, params: Record<string, unknown>, provenance: unknown) => void) | undefined;
211
+ export declare class DraftsRemoteService extends TypertRemoteService {
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ private benchAdmit;
226
+ constructor(ctx: Context);
227
+ /** Endpoint `drafts/list` — the domain index, recency DESC. */
228
+ remoteExportList(signal: AbortSignal): Promise<DraftListResult>;
229
+ /** Endpoint `drafts/get` — one doc by id. */
230
+ remoteExportGet(draftId: string, signal: AbortSignal): Promise<DraftGetRow>;
231
+ /** The in-process API the adapters above delegate to. */
232
+ list(signal: AbortSignal): Promise<DraftListResult>;
233
+ /** The in-process API the adapter above delegates to. */
234
+ get(draftId: string, signal: AbortSignal): Promise<Record<string, unknown>>;
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ remoteExportPatch(draftId: string, stageId: string, patch: DraftStagePatch, expectRev: number | null, signal: AbortSignal): Promise<DraftPatchRow>;
258
+ /** The patch arm the adapter above delegates to — one write
259
+ * transaction on the draft's own key, shared with the bench
260
+ * verbs (the round-14 race audit's R3: the author arm's
261
+ * spread-copy of the log forked against their in-place push). */
262
+ patch(draftId: string, stageId: string, patch: Record<string, unknown>, expectRev: number | null, signal: AbortSignal): Promise<DraftPatchRow>;
263
+ private patchBody;
264
+ }
265
+ /** The bench Remote owner: ensure/get over the same drafts domain
266
+ * (the bench doc IS a draft doc, id "bench-<session>"). */
267
+ export declare class BenchRemoteService extends TypertRemoteService {
268
+ constructor(ctx: Context);
269
+ /** Endpoint `bench/get` — one session's bench block as the row. */
270
+ remoteExportGet(sessionKey: string, signal: AbortSignal): Promise<BenchGetRow>;
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+ subscribe(sessionKey: string, signal: AbortSignal): AsyncIterable<BenchGetRow>;
282
+ /** Endpoint `bench/ensure` — birth or load (the only creating arm). */
283
+ remoteExportEnsure(doc: BenchDoc, signal: AbortSignal): Promise<BenchEnsureRow>;
284
+ /** The in-process API the adapters above delegate to. Classified
285
+ * bench failures pass through untouched; only the open itself
286
+ * wraps as bench/store-failed. */
287
+ get(session: string, signal: AbortSignal): Promise<BenchGetRow>;
288
+ /** The in-process API the adapter above delegates to. */
289
+ ensure(doc: BenchDoc, signal: AbortSignal): Promise<BenchEnsureRow>;
290
+ /** Endpoint `bench/patch` — params merge (+result/runStatus) with
291
+ * CAS + log. */
292
+ remoteExportPatch(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchPatchRow>;
293
+ /** Endpoint `bench/add-stage` — append a card stage. */
294
+ remoteExportAddStage(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
295
+ /** Endpoint `bench/remove-stage` — splice one stage out. */
296
+ remoteExportRemoveStage(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
297
+
298
+
299
+
300
+
301
+ remoteExportClear(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchClearRow>;
302
+ /** Endpoint `bench/rewire` — set or clear one input binding. */
303
+ remoteExportRewire(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchRewireRow>;
304
+
305
+
306
+ remoteExportReorder(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchReorderRow>;
307
+
308
+
309
+ remoteExportGroup(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
310
+ /** Endpoint `bench/ungroup` — spill a compound's children back. */
311
+ remoteExportUngroup(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
312
+ /** Endpoint `bench/undo` — walk the log tail, apply inverses. */
313
+ remoteExportUndo(sessionKey: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchUndoRow>;
314
+ /** The in-process APIs the adapters above delegate to. The
315
+ * domain's classified failures pass through untouched; only the
316
+ * open itself wraps as bench/store-failed. */
317
+ private open;
318
+ patch(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchPatchRow>;
319
+ addStage(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
320
+ removeStage(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchStageRow>;
321
+ clear(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchClearRow>;
322
+ rewire(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchRewireRow>;
323
+ undo(session: string, doc: BenchDoc, signal: AbortSignal): Promise<BenchUndoRow>;
324
+ }
325
+ //# sourceMappingURL=remote.d.ts.map