@yugoo-design/dsh-design-studio-dsh 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +427 -3
  2. package/lib/authoring/panel-components.json +10790 -0
  3. package/lib/authoring/studio-creators/material.json +1 -0
  4. package/lib/authoring-agent-Ci08ifdJ.js +634 -0
  5. package/lib/authoring-agent.d.ts +24 -0
  6. package/lib/authoring-agent.js +2 -0
  7. package/lib/authoring-agent.types-QLa61eE6.d.ts +88 -0
  8. package/lib/authoring-entry.d.ts +20 -0
  9. package/lib/authoring-entry.js +77 -0
  10. package/lib/authoring-host-BlsA6wXz.js +347 -0
  11. package/lib/authoring-host.d.ts +5 -0
  12. package/lib/authoring-host.js +2 -0
  13. package/lib/authoring-host.types-d5UT0WEk.d.ts +77 -0
  14. package/lib/authoring-reference-store.d.ts +39 -0
  15. package/lib/authoring-reference-store.js +385 -0
  16. package/lib/authoring-service-qGEk-IE_.js +342 -0
  17. package/lib/authoring-service.d.ts +112 -0
  18. package/lib/authoring-service.js +2 -0
  19. package/lib/authoring-session.d.ts +5 -0
  20. package/lib/authoring-session.js +203 -0
  21. package/lib/authoring-session.types-MHEaEFkO.d.ts +58 -0
  22. package/lib/authoring-sources-BzRuEuub.d.ts +17 -0
  23. package/lib/authoring-sources.d.ts +2 -0
  24. package/lib/authoring-sources.js +85 -0
  25. package/lib/authoring-workbench.d.ts +15 -0
  26. package/lib/authoring-workbench.js +782 -0
  27. package/lib/authoring.page-rpc-Bg6VAT0Z.d.ts +30 -0
  28. package/lib/authoring.page-rpc.d.ts +2 -0
  29. package/lib/authoring.page-rpc.js +55 -0
  30. package/lib/authoring.remote-client.d.ts +2557 -0
  31. package/lib/authoring.remote-client.js +435 -0
  32. package/lib/client-adapter-BgD1mpCC.d.ts +65 -0
  33. package/lib/client-adapter.d.ts +2 -64
  34. package/lib/client.js +1 -2
  35. package/lib/css-assets/dsh-design-studio-page/9178281a0695f79ff8bff8eca529231b67f896dc1c12c8dbaaad24b32dd3fc07.eot +0 -0
  36. package/lib/css-assets/dsh-design-studio-page/b366faf39f6bcc48f10b10f2860e5ebe57091cb2a15beeed8a0977e24560bbba.svg +224 -0
  37. package/lib/css-assets/dsh-design-studio-page/manifest.json +20 -0
  38. package/lib/index.js +4 -105
  39. package/lib/kit-files-DKBlBOG8.js +159 -0
  40. package/lib/page-client.js +4 -23849
  41. package/lib/page-path-Bj5jO20L.d.ts +25 -0
  42. package/lib/page-path.d.ts +2 -2
  43. package/lib/page-path.js +70 -2
  44. package/lib/page-rpc-DiazVY00.d.ts +24 -0
  45. package/lib/page-rpc.d.ts +2 -15
  46. package/lib/page-rpc.js +9 -4
  47. package/lib/page.d.ts +5 -3
  48. package/lib/page.js +219 -2
  49. package/lib/remote-method-ab_lHwWN.js +16 -0
  50. package/lib/typert.host.d.ts +827 -2
  51. package/lib/typert.host.js +2 -1
  52. package/lib/typert.remote-client-CWz-anTr.d.ts +37 -0
  53. package/lib/typert.remote-client.d.ts +1 -36
  54. package/licenses/dsh-distribution.json +8644 -149
  55. package/package.json +73 -10
  56. package/lib/page-path-wn8e_fid.d.ts +0 -14
@@ -0,0 +1,88 @@
1
+ import { Agent } from "@deepseek-ai/dsh-agent";
2
+ //#region src/authoring-agent.types.d.ts
3
+ interface StudioAuthoringScope {
4
+ readonly id: string;
5
+ readonly expectedRevision: number;
6
+ /** Initial read focus; subsequent reads and file changes stay in this bound object/revision. */
7
+ readonly allowedPaths: readonly string[];
8
+ readonly bundle?: Readonly<{
9
+ name: string;
10
+ version: string;
11
+ }>;
12
+ }
13
+ /** The existing S3 capability. Its receipt remains the sole candidate source. */
14
+ interface StudioAuthoringPorts {
15
+ read(input?: {
16
+ paths?: string[];
17
+ }): Promise<unknown>;
18
+ prepare(input: {
19
+ changes: {
20
+ path: string;
21
+ content: string;
22
+ }[];
23
+ }): Promise<unknown>;
24
+ }
25
+ interface StudioAuthoringReference {
26
+ readonly sessionId: string;
27
+ readonly parentSessionId: string;
28
+ readonly invocationId: string;
29
+ readonly epoch: string;
30
+ readonly messageId: string;
31
+ readonly afterSeq: number;
32
+ readonly scope: StudioAuthoringScope;
33
+ }
34
+ interface StudioAuthoringObservation {
35
+ readonly reference: StudioAuthoringReference;
36
+ readonly status: 'queued' | 'running' | 'completed' | 'cancelled' | 'failed' | 'unknown';
37
+ readonly consumed: boolean;
38
+ readonly turn: number | null;
39
+ readonly terminal: boolean;
40
+ readonly reason?: string;
41
+ readonly throughSeq: number;
42
+ readonly source: 'live' | 'prepared';
43
+ /** This adapter witnessed a successful scoped native flush; prepared-cache reads alone do not prove it. */
44
+ readonly durable: boolean;
45
+ readonly pendingInput: boolean;
46
+ readonly diagnostic?: string;
47
+ /** Public messages and tool activity from this invocation's native event range. */
48
+ readonly conversation?: {
49
+ readonly rows: readonly {
50
+ id: string;
51
+ role: 'assistant' | 'tool';
52
+ label: string;
53
+ text: string;
54
+ status: string;
55
+ }[];
56
+ readonly omitted: number;
57
+ };
58
+ }
59
+ interface StudioAuthoringRequest {
60
+ readonly parent: Agent;
61
+ readonly invocationId: string;
62
+ readonly scope: StudioAuthoringScope;
63
+ readonly workspaceRoot: string;
64
+ readonly prompt: string;
65
+ readonly ports: StudioAuthoringPorts;
66
+ readonly signal?: AbortSignal;
67
+ /** Retain this native address before the adapter attempts dispatch. */
68
+ readonly onReference?: (reference: StudioAuthoringReference) => void | Promise<void>;
69
+ /** A projection of the successful S3 tool receipt, not execution completion. */
70
+ readonly onPrepared?: (receipt: unknown) => void | Promise<void>;
71
+ }
72
+ interface StudioAuthoringResumeRequest extends StudioAuthoringRequest {
73
+ readonly previous: StudioAuthoringReference;
74
+ readonly explicit: true;
75
+ }
76
+ interface StudioAuthoringRun {
77
+ readonly reference: StudioAuthoringReference;
78
+ readonly result: Promise<StudioAuthoringObservation>;
79
+ observe(): Promise<StudioAuthoringObservation>;
80
+ /** null fences an invocation whose native turn has not started. */
81
+ cancel(options: {
82
+ expectedTurn: number | null;
83
+ }): Promise<StudioAuthoringObservation>;
84
+ readPrepared(): unknown | undefined;
85
+ dispose(): Promise<void>;
86
+ }
87
+ //#endregion
88
+ export { StudioAuthoringResumeRequest as a, StudioAuthoringRequest as i, StudioAuthoringPorts as n, StudioAuthoringRun as o, StudioAuthoringReference as r, StudioAuthoringScope as s, StudioAuthoringObservation as t };
@@ -0,0 +1,20 @@
1
+ import { DshStudioAuthoringServiceConfig } from "./authoring-service.js";
2
+ import { Context } from "@deepseek-ai/cordis";
3
+ //#region src/authoring-entry.d.ts
4
+ type DshStudioAuthoringEntryConfig = Partial<DshStudioAuthoringServiceConfig>;
5
+ declare const name = "studio-authoring";
6
+ declare const inject: string[];
7
+ /**
8
+ * Prepare private single-leaf roots, then mount the one existing Service.
9
+ * Failed or interrupted initialization preserves already-created directories
10
+ * and namespace metadata; no rollback or automatic retry is attempted.
11
+ * Async keeps this plugin callback non-constructible for Cordis activation.
12
+ */
13
+ declare function apply(ctx: Context, config?: DshStudioAuthoringEntryConfig): Promise<void>;
14
+ declare const _default: {
15
+ name: string;
16
+ inject: string[];
17
+ apply: typeof apply;
18
+ };
19
+ //#endregion
20
+ export { DshStudioAuthoringEntryConfig, apply, _default as default, inject, name };
@@ -0,0 +1,77 @@
1
+ import { prepareStudioAuthoringDirectory } from "./authoring-reference-store.js";
2
+ import { t as DshStudioAuthoringService } from "./authoring-service-qGEk-IE_.js";
3
+ import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
4
+ //#region src/authoring-entry.ts
5
+ const name = "studio-authoring";
6
+ const inject = [...DshStudioAuthoringService.inject];
7
+ /**
8
+ * Prepare private single-leaf roots, then mount the one existing Service.
9
+ * Failed or interrupted initialization preserves already-created directories
10
+ * and namespace metadata; no rollback or automatic retry is attempted.
11
+ * Async keeps this plugin callback non-constructible for Cordis activation.
12
+ */
13
+ async function apply(ctx, config = {}) {
14
+ let closed = false;
15
+ let child;
16
+ let initialization;
17
+ let shutdown;
18
+ const close = () => {
19
+ if (shutdown) return shutdown;
20
+ closed = true;
21
+ const completion = Promise.withResolvers();
22
+ shutdown = completion.promise;
23
+ shutdown.catch(() => {});
24
+ let stop;
25
+ try {
26
+ stop = child?.dispose();
27
+ } catch (error) {
28
+ stop = Promise.reject(error);
29
+ }
30
+ Promise.allSettled([stop, initialization?.then(() => void 0, () => void 0)]).then((results) => {
31
+ const failures = results.filter((r) => r.status === "rejected").map((r) => r.reason);
32
+ if (failures.length) throw new AggregateError(failures, "Studio authoring entry cleanup failed");
33
+ }).then(completion.resolve, completion.reject);
34
+ return shutdown;
35
+ };
36
+ ctx.effect(() => close, "studio-authoring-entry");
37
+ ctx.on("internal/plugin", (fiber) => {
38
+ if (fiber === ctx.fiber && fiber.uid === null) close();
39
+ });
40
+ ctx.on("internal/status", (fiber) => {
41
+ if (fiber === ctx.fiber && (fiber.state === 5 || fiber.state === 4)) close();
42
+ });
43
+ try {
44
+ if (config === null || typeof config !== "object" || Array.isArray(config)) throw new TypeError("Studio authoring entry requires a trusted configuration object");
45
+ const roots = Object.freeze({
46
+ stateRoot: config.stateRoot === void 0 ? dshHomePath("yugoo-design-studio") : config.stateRoot,
47
+ workspaceRoot: config.workspaceRoot === void 0 ? dshHomePath("yugoo-design-studio-workspace") : config.workspaceRoot
48
+ });
49
+ const active = () => {
50
+ if (closed || ctx.fiber.uid === null) throw new Error("Studio authoring entry closed during initialization");
51
+ };
52
+ initialization = Promise.resolve().then(async () => {
53
+ active();
54
+ const stateRoot = await prepareStudioAuthoringDirectory(roots.stateRoot);
55
+ active();
56
+ const workspaceRoot = await prepareStudioAuthoringDirectory(roots.workspaceRoot);
57
+ active();
58
+ child = ctx.plugin(DshStudioAuthoringService, {
59
+ stateRoot,
60
+ workspaceRoot
61
+ });
62
+ await child;
63
+ active();
64
+ });
65
+ } catch (error) {
66
+ initialization = Promise.reject(error);
67
+ }
68
+ initialization.catch(() => {});
69
+ return initialization;
70
+ }
71
+ var authoring_entry_default = {
72
+ name,
73
+ inject,
74
+ apply
75
+ };
76
+ //#endregion
77
+ export { apply, authoring_entry_default as default, inject, name };
@@ -0,0 +1,347 @@
1
+ import { createStudioAuthoringSession } from "./authoring-session.js";
2
+ import { createStudioAuthoringReferenceStore } from "./authoring-reference-store.js";
3
+ import { createDshStudioInstanceAdapters, registerDshStudioCurrentKitSource } from "./authoring-sources.js";
4
+ import { readStudioContentArchive } from "@yugoo-design/dsh-design-studio";
5
+ import { isAbsolute } from "node:path";
6
+ import assert from "node:assert/strict";
7
+ import { randomUUID } from "node:crypto";
8
+ import { createStudioInstances } from "@yugoo-design/dsh-design-studio/node";
9
+ //#region src/authoring-content.ts
10
+ /** Export and stateless archive decoding over the current S2 source authority. */
11
+ async function createDshStudioContent({ instances }) {
12
+ return {
13
+ readArchive: async ({ source }) => readStudioContentArchive(source),
14
+ async exportContentArchive(input) {
15
+ if ("id" in input) return instances.exportArchive(input);
16
+ const current = await instances.editCurrent({
17
+ kind: input.kind,
18
+ [input.kind]: input.pin
19
+ });
20
+ return instances.exportArchive({
21
+ id: current.id,
22
+ expectedRevision: current.revision,
23
+ provenance: input.provenance
24
+ });
25
+ }
26
+ };
27
+ }
28
+ //#endregion
29
+ //#region src/authoring-host.ts
30
+ /** Host-only composition. S2 owns source/save, S5a addresses, S4 native execution. */
31
+ const INSTANCE_METHODS = [
32
+ "read",
33
+ "list",
34
+ "listBundles",
35
+ "copy",
36
+ "editCurrent",
37
+ "captureKit",
38
+ "loadKit",
39
+ "create",
40
+ "importSources",
41
+ "rename",
42
+ "remove",
43
+ "readFile",
44
+ "saveFile",
45
+ "prepareChanges",
46
+ "saveChanges",
47
+ "updateMounts",
48
+ "preview",
49
+ "migrate",
50
+ "exportArchive"
51
+ ];
52
+ const addressOf = (value) => ({
53
+ sessionId: value.sessionId,
54
+ epoch: value.epoch
55
+ });
56
+ const MAX_PREPARED_PROJECTIONS = 16;
57
+ const MAX_PREPARED_BYTES = 33554432;
58
+ const snapshot = (request) => ({
59
+ ...request,
60
+ paths: structuredClone(request.paths),
61
+ ...request.bundle === void 0 ? {} : { bundle: structuredClone(request.bundle) }
62
+ });
63
+ async function createDshStudioAuthoringHost(options) {
64
+ const { ctx, design, fs, stateRoot, workspaceRoot, readComponents } = options;
65
+ assert.ok(typeof workspaceRoot === "string" && isAbsolute(workspaceRoot), "An explicit Host-owned workspaceRoot is required");
66
+ assert.equal(typeof readComponents, "function", "The actual component catalog is required");
67
+ const references = await createStudioAuthoringReferenceStore({ stateRoot });
68
+ const shared = await createStudioInstances({
69
+ stateRoot,
70
+ ...createDshStudioInstanceAdapters({
71
+ design,
72
+ fs
73
+ })
74
+ });
75
+ const content = await createDshStudioContent({ instances: shared });
76
+ const stopCurrentSource = registerDshStudioCurrentKitSource(design, shared);
77
+ const parents = /* @__PURE__ */ new Map();
78
+ const closing = /* @__PURE__ */ new Set(), cleanupFailures = /* @__PURE__ */ new Set();
79
+ let closed = false, disposing;
80
+ const active = () => assert.ok(!closed, "Studio authoring Host is disposed");
81
+ const exact = (parent) => assert.ok(parent && ctx.agents.get(parent.id) === parent, "The exact native authoring parent is disconnected");
82
+ const remember = (promise) => {
83
+ closing.add(promise);
84
+ promise.then(() => closing.delete(promise), (error) => {
85
+ closing.delete(promise);
86
+ cleanupFailures.add(error);
87
+ });
88
+ return promise;
89
+ };
90
+ const forParent = (parent) => {
91
+ active();
92
+ exact(parent);
93
+ const existing = parents.get(parent);
94
+ if (existing) return existing;
95
+ let parentClosed = false, parentDisposing;
96
+ const admitted = /* @__PURE__ */ new Set();
97
+ const guard = () => {
98
+ active();
99
+ assert.ok(!parentClosed, "Studio authoring parent facade is disposed");
100
+ exact(parent);
101
+ };
102
+ const admit = async (operation) => {
103
+ guard();
104
+ let settle;
105
+ const pending = new Promise((resolve) => {
106
+ settle = resolve;
107
+ });
108
+ admitted.add(pending);
109
+ try {
110
+ const value = await operation();
111
+ guard();
112
+ return value;
113
+ } finally {
114
+ admitted.delete(pending);
115
+ settle();
116
+ }
117
+ };
118
+ const instances = Object.freeze(Object.fromEntries(INSTANCE_METHODS.map((name) => [name, (...args) => {
119
+ const captured = structuredClone(args);
120
+ return admit(() => Reflect.apply(shared[name], shared, captured));
121
+ }])));
122
+ const prepared = /* @__PURE__ */ new Map();
123
+ let preparedBytes = 0;
124
+ const pin = (value) => value === void 0 ? void 0 : {
125
+ name: value.name,
126
+ version: value.version
127
+ };
128
+ const targetFor = (record, request) => {
129
+ assert.equal(record.id, request.id);
130
+ assert.equal(record.revision, request.expectedRevision, "Working copy changed; reopen before reviewing");
131
+ const bundle = record.kind === "bundle" ? record.bundle : request.bundle;
132
+ if (record.kind === "bundle" && request.bundle) assert.deepEqual(pin(request.bundle), pin(record.bundle), "Candidate Bundle pin changed");
133
+ if (record.kind === "kit" && bundle) assert.ok(record.mounts.some((mount) => JSON.stringify(pin(mount.bundle)) === JSON.stringify(pin(bundle))), "Candidate Bundle is not mounted in this Kit");
134
+ return {
135
+ id: record.id,
136
+ expectedRevision: record.revision,
137
+ ...bundle ? { bundle: pin(bundle) } : {}
138
+ };
139
+ };
140
+ const prepareChanges = (request) => {
141
+ const captured = structuredClone(request);
142
+ return admit(async () => {
143
+ const candidate = await instances.prepareChanges(captured);
144
+ const target = targetFor(await instances.read({ id: captured.id }), captured);
145
+ guard();
146
+ const key = JSON.stringify({
147
+ request: captured,
148
+ digest: candidate.digest,
149
+ target
150
+ });
151
+ const previous = [...prepared.values()].find((row) => row.key === key);
152
+ if (previous) return structuredClone(previous.value);
153
+ const value = {
154
+ locator: {
155
+ requestId: randomUUID(),
156
+ ...target,
157
+ digest: candidate.digest
158
+ },
159
+ prepared: {
160
+ request: captured,
161
+ candidate
162
+ }
163
+ };
164
+ const bytes = Buffer.byteLength(JSON.stringify(value)) + Buffer.byteLength(key);
165
+ assert.ok(bytes <= MAX_PREPARED_BYTES, "Prepared candidate exceeds the temporary review budget");
166
+ while (prepared.size >= MAX_PREPARED_PROJECTIONS || preparedBytes + bytes > MAX_PREPARED_BYTES) {
167
+ const oldest = prepared.keys().next().value;
168
+ preparedBytes -= prepared.get(oldest).bytes;
169
+ prepared.delete(oldest);
170
+ }
171
+ prepared.set(value.locator.requestId, {
172
+ value: structuredClone(value),
173
+ bytes,
174
+ key
175
+ });
176
+ preparedBytes += bytes;
177
+ return structuredClone(value);
178
+ });
179
+ };
180
+ const readConversationPrepared = (locator) => admit(async () => {
181
+ const row = prepared.get(locator.requestId);
182
+ assert.ok(row, "No prepared candidate for this exact live parent and request");
183
+ assert.deepEqual(locator, row.value.locator, "Prepared candidate locator or Bundle pin changed");
184
+ const { request, candidate } = row.value.prepared;
185
+ const { requestId: _requestId, digest: _digest, ...target } = locator;
186
+ assert.deepEqual(targetFor(await instances.read({ id: request.id }), request), target, "Prepared candidate source pin changed");
187
+ const current = await instances.prepareChanges(request);
188
+ assert.equal(current.digest, candidate.digest, "Prepared candidate digest changed");
189
+ return structuredClone(row.value.prepared);
190
+ });
191
+ let session;
192
+ const release = ctx.effect(() => {
193
+ session = createStudioAuthoringSession({
194
+ ctx,
195
+ parent,
196
+ instances,
197
+ workspaceRoot,
198
+ readComponents: () => admit(() => readComponents()),
199
+ retainReference: (reference) => admit(async () => {
200
+ assert.equal(reference.parentSessionId, String(parent.id));
201
+ await references.retain(reference);
202
+ })
203
+ });
204
+ return () => {
205
+ parentClosed = true;
206
+ prepared.clear();
207
+ preparedBytes = 0;
208
+ return session.dispose();
209
+ };
210
+ }, "studio-authoring-parent");
211
+ const readReference = (address) => {
212
+ const key = addressOf(address);
213
+ return admit(() => references.read({
214
+ ...key,
215
+ parentSessionId: String(parent.id)
216
+ }));
217
+ };
218
+ const retained = async (address) => {
219
+ const reference = await readReference(address);
220
+ guard();
221
+ assert.ok(reference, "No retained Studio native address for this exact parent");
222
+ return reference;
223
+ };
224
+ let facade;
225
+ const wrap = (run) => {
226
+ const address = addressOf(run.reference);
227
+ return Object.freeze({
228
+ reference: structuredClone(run.reference),
229
+ result: run.result,
230
+ observe: () => facade.observe(address),
231
+ cancel: (input) => facade.cancel(address, input),
232
+ readPrepared: () => {
233
+ guard();
234
+ return run.readPrepared();
235
+ }
236
+ });
237
+ };
238
+ const disposeParent = () => {
239
+ if (parentDisposing) return parentDisposing;
240
+ parentClosed = true;
241
+ prepared.clear();
242
+ preparedBytes = 0;
243
+ const stop = Promise.resolve().then(() => session.dispose());
244
+ const unregister = Promise.resolve().then(() => release());
245
+ parentDisposing = remember(Promise.allSettled([
246
+ stop,
247
+ unregister,
248
+ ...admitted
249
+ ]).then((results) => {
250
+ const failures = results.filter((result) => result.status === "rejected").map((result) => result.reason);
251
+ if (failures.length) throw new AggregateError([...new Set(failures)], "Studio parent cleanup failed");
252
+ }));
253
+ return parentDisposing;
254
+ };
255
+ const guardedContent = Object.freeze({
256
+ readArchive: (input) => {
257
+ const captured = structuredClone(input);
258
+ return admit(() => content.readArchive(captured));
259
+ },
260
+ exportContentArchive: (input) => {
261
+ const captured = structuredClone(input);
262
+ return admit(() => content.exportContentArchive(captured));
263
+ }
264
+ });
265
+ facade = Object.freeze({
266
+ instances,
267
+ content: guardedContent,
268
+ prepareChanges,
269
+ readReference,
270
+ listReferences: () => admit(() => references.list({ parentSessionId: String(parent.id) })),
271
+ start: (request) => {
272
+ const captured = snapshot(request);
273
+ return admit(async () => wrap(await session.start(captured)));
274
+ },
275
+ resume: (request) => {
276
+ const captured = snapshot(request), previous = addressOf(request.previous), explicit = request.explicit;
277
+ return admit(async () => {
278
+ const reference = await retained(previous);
279
+ guard();
280
+ return wrap(await session.resume({
281
+ ...captured,
282
+ previous: reference,
283
+ explicit
284
+ }));
285
+ });
286
+ },
287
+ observe: (address) => {
288
+ const key = addressOf(address);
289
+ return admit(async () => {
290
+ const reference = await retained(key);
291
+ guard();
292
+ return session.observe(reference);
293
+ });
294
+ },
295
+ cancel: (address, input) => {
296
+ const key = addressOf(address), expectedTurn = input.expectedTurn;
297
+ return admit(async () => {
298
+ const reference = await retained(key);
299
+ guard();
300
+ return session.cancel(reference, { expectedTurn });
301
+ });
302
+ },
303
+ readPrepared: (address) => {
304
+ if ("requestId" in address) return readConversationPrepared(structuredClone(address));
305
+ const key = addressOf(address);
306
+ return admit(async () => {
307
+ const reference = await retained(key);
308
+ guard();
309
+ return session.readPrepared(reference);
310
+ });
311
+ },
312
+ dispose: disposeParent
313
+ });
314
+ parents.set(parent, facade);
315
+ return facade;
316
+ };
317
+ const stopListening = ctx.on("agent/disposed", ({ agent }) => {
318
+ const facade = parents.get(agent);
319
+ if (!facade) return;
320
+ parents.delete(agent);
321
+ return facade.dispose();
322
+ });
323
+ const dispose = () => {
324
+ if (disposing) return disposing;
325
+ closed = true;
326
+ const stops = [...parents.values()].map((facade) => facade.dispose());
327
+ parents.clear();
328
+ disposing = Promise.allSettled([
329
+ Promise.resolve().then(() => stopListening()),
330
+ Promise.resolve().then(() => stopCurrentSource()),
331
+ ...stops,
332
+ ...closing
333
+ ]).then((results) => {
334
+ const failures = /* @__PURE__ */ new Set([...cleanupFailures, ...results.filter((result) => result.status === "rejected").map((result) => result.reason)]);
335
+ if (failures.size) throw new AggregateError([...failures], "Studio authoring Host cleanup failed");
336
+ });
337
+ disposing.catch(() => {});
338
+ return disposing;
339
+ };
340
+ ctx.effect(() => dispose, "studio-authoring-host");
341
+ return Object.freeze({
342
+ forParent,
343
+ dispose
344
+ });
345
+ }
346
+ //#endregion
347
+ export { createDshStudioAuthoringHost as t };
@@ -0,0 +1,5 @@
1
+ import { a as StudioPreparedLocator, i as StudioAuthoringAddress, n as DshStudioAuthoringHostOptions, o as StudioPreparedProjection, r as DshStudioAuthoringParent, t as DshStudioAuthoringHost } from "./authoring-host.types-d5UT0WEk.js";
2
+ //#region src/authoring-host.d.ts
3
+ declare function createDshStudioAuthoringHost(options: DshStudioAuthoringHostOptions): Promise<DshStudioAuthoringHost>;
4
+ //#endregion
5
+ export { type DshStudioAuthoringHost, type DshStudioAuthoringHostOptions, type DshStudioAuthoringParent, type StudioAuthoringAddress, type StudioPreparedLocator, type StudioPreparedProjection, createDshStudioAuthoringHost };
@@ -0,0 +1,2 @@
1
+ import { t as createDshStudioAuthoringHost } from "./authoring-host-BlsA6wXz.js";
2
+ export { createDshStudioAuthoringHost };
@@ -0,0 +1,77 @@
1
+ import { r as StudioAuthoringReference, t as StudioAuthoringObservation } from "./authoring-agent.types-QLa61eE6.js";
2
+ import { a as StudioSessionRun, n as StudioAuthoringSessionOptions, o as StudioSessionStart, r as StudioSessionPrepared } from "./authoring-session.types-MHEaEFkO.js";
3
+ import { t as DshStudioInstanceSources } from "./authoring-sources-BzRuEuub.js";
4
+ import { Context } from "@deepseek-ai/cordis";
5
+ import DesignService from "@yugoo-design/dsh-design-core";
6
+ import { DesignBundleVersionPin, DesignKitVersionPin, StudioInstanceChangeRequest } from "@yugoo-design/dsh-design-studio";
7
+ import { Agent } from "@deepseek-ai/dsh-agent";
8
+ import { StudioInstances } from "@yugoo-design/dsh-design-studio/node";
9
+ //#region src/authoring-content.d.ts
10
+ type InstalledExport = {
11
+ readonly kind: 'kit' | 'bundle';
12
+ readonly pin: DesignBundleVersionPin | DesignKitVersionPin;
13
+ readonly provenance?: {
14
+ readonly source?: string;
15
+ readonly license?: string;
16
+ };
17
+ };
18
+ declare function createDshStudioContent({ instances }: {
19
+ instances: Pick<StudioInstances, 'editCurrent' | 'exportArchive'>;
20
+ }): Promise<{
21
+ readArchive: ({ source }: {
22
+ source: string;
23
+ }) => Promise<import("@yugoo-design/dsh-design-studio").StudioContentArchive>;
24
+ exportContentArchive(input: InstalledExport | Parameters<StudioInstances["exportArchive"]>[0]): Promise<string>;
25
+ }>;
26
+ type DshStudioContent = Awaited<ReturnType<typeof createDshStudioContent>>;
27
+ //#endregion
28
+ //#region src/authoring-host.types.d.ts
29
+ /** A locator, never a caller-supplied parent, source scope or native authority. */
30
+ type StudioAuthoringAddress = Pick<StudioAuthoringReference, 'sessionId' | 'epoch'>;
31
+ /** Exact browser locator; the live Host parent and S2 still supply authority. */
32
+ interface StudioPreparedLocator {
33
+ readonly requestId: string;
34
+ readonly id: string;
35
+ readonly expectedRevision: number;
36
+ readonly digest: string;
37
+ readonly bundle?: DesignBundleVersionPin;
38
+ }
39
+ interface StudioPreparedProjection {
40
+ readonly locator: StudioPreparedLocator;
41
+ readonly prepared: StudioSessionPrepared;
42
+ }
43
+ interface DshStudioAuthoringHostOptions extends DshStudioInstanceSources {
44
+ readonly design: DshStudioInstanceSources['design'] & Pick<DesignService, 'registerCurrentKitSource' | 'listKits'>;
45
+ readonly ctx: Context;
46
+ readonly stateRoot: string;
47
+ readonly workspaceRoot: string;
48
+ readonly readComponents: StudioAuthoringSessionOptions['readComponents'];
49
+ }
50
+ interface DshStudioAuthoringParent {
51
+ /** Guarded ports over the Host's ONE shared S2 service, not private Agent records. */
52
+ readonly instances: StudioInstances;
53
+ readonly content: DshStudioContent;
54
+ /** Retain a bounded projection of the existing S2 preparation, without saving. */
55
+ prepareChanges(request: StudioInstanceChangeRequest): Promise<StudioPreparedProjection>;
56
+ readReference(address: StudioAuthoringAddress): Promise<StudioAuthoringReference | undefined>;
57
+ listReferences(): Promise<readonly StudioAuthoringReference[]>;
58
+ start(request: StudioSessionStart): Promise<StudioSessionRun>;
59
+ resume(request: StudioSessionStart & {
60
+ readonly previous: StudioAuthoringAddress;
61
+ readonly explicit: true;
62
+ }): Promise<StudioSessionRun>;
63
+ observe(address: StudioAuthoringAddress): Promise<StudioAuthoringObservation>;
64
+ cancel(address: StudioAuthoringAddress, options: {
65
+ readonly expectedTurn: number | null;
66
+ }): Promise<StudioAuthoringObservation>;
67
+ readPrepared(address: StudioAuthoringAddress | StudioPreparedLocator): Promise<StudioSessionPrepared | undefined>;
68
+ /** Permanently close this facade, cancel/release S4, then join admitted I/O. */
69
+ dispose(): Promise<void>;
70
+ }
71
+ interface DshStudioAuthoringHost {
72
+ /** Stable for the same live object; a same-ID replacement never inherits handles. */
73
+ forParent(parent: Agent): DshStudioAuthoringParent;
74
+ dispose(): Promise<void>;
75
+ }
76
+ //#endregion
77
+ export { StudioPreparedLocator as a, StudioAuthoringAddress as i, DshStudioAuthoringHostOptions as n, StudioPreparedProjection as o, DshStudioAuthoringParent as r, DshStudioAuthoringHost as t };
@@ -0,0 +1,39 @@
1
+ import { r as StudioAuthoringReference } from "./authoring-agent.types-QLa61eE6.js";
2
+ //#region src/authoring-reference-store.d.ts
3
+ interface StudioAuthoringReferenceKey {
4
+ readonly parentSessionId: string;
5
+ readonly sessionId: string;
6
+ readonly epoch: string;
7
+ }
8
+ interface StudioAuthoringReferenceStore {
9
+ /** Settles after file sync, no-clobber publication and platform checks; usable as S4's callback. */
10
+ retain(reference: StudioAuthoringReference): Promise<void>;
11
+ read(key: StudioAuthoringReferenceKey): Promise<StudioAuthoringReference | undefined>;
12
+ /** Explicit parent only, deterministic key order, never a latest-session selector. */
13
+ list(input: {
14
+ readonly parentSessionId: string;
15
+ }): Promise<readonly StudioAuthoringReference[]>;
16
+ }
17
+ declare const STUDIO_AUTHORING_REFERENCE_LIMITS: Readonly<{
18
+ references: 256;
19
+ bytes: 524288;
20
+ paths: 64;
21
+ }>;
22
+ /** Prepare one Host-owned private leaf, without creating a store or repairing permissions.
23
+ * The canonical physical parent must already exist. Failures can leave the leaf;
24
+ * POSIX retries complete both sync barriers. Windows uses inherited user access
25
+ * and physical-path checks, without a directory-flush or power-loss guarantee. */
26
+ declare function prepareStudioAuthoringDirectory(path: string): Promise<string>;
27
+ /**
28
+ * Explicit private stateRoot only. The marker owns this namespace, not S2 or the
29
+ * root. No permission repair, stale-lock reclamation, SDK import or native action.
30
+ * Path/handle checks reject detected replacement; they do not sandbox arbitrary
31
+ * same-user mutation between filesystem syscalls. POSIX requires directory sync;
32
+ * Windows uses ordinary user-directory access and file publication, without a
33
+ * directory-flush requirement or cross-platform power-loss guarantee.
34
+ */
35
+ declare function createStudioAuthoringReferenceStore(options: {
36
+ readonly stateRoot: string;
37
+ }): Promise<StudioAuthoringReferenceStore>;
38
+ //#endregion
39
+ export { STUDIO_AUTHORING_REFERENCE_LIMITS, StudioAuthoringReferenceKey, StudioAuthoringReferenceStore, createStudioAuthoringReferenceStore, prepareStudioAuthoringDirectory };