@arcadia-eternity/content-sdk 4.3.4 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +3 -3
  2. package/bin/arcadia-content-mcp.mjs +2 -0
  3. package/bin/arcadia-content.mjs +2 -0
  4. package/dist/asset-inspect.d.ts +30 -0
  5. package/dist/asset-inspect.js +84 -0
  6. package/dist/author-api.d.ts +48 -0
  7. package/dist/author-api.js +128 -0
  8. package/dist/author-reference.d.ts +61 -0
  9. package/dist/author-reference.js +130 -0
  10. package/dist/build-content.d.ts +2 -0
  11. package/dist/build-content.js +29 -0
  12. package/dist/cli.d.ts +2 -0
  13. package/dist/cli.js +81 -0
  14. package/dist/content-query.d.ts +30 -0
  15. package/dist/content-query.js +326 -0
  16. package/dist/content-workspace.d.ts +171 -0
  17. package/dist/content-workspace.js +981 -0
  18. package/dist/debug-environments.d.ts +117 -0
  19. package/dist/debug-environments.js +135 -0
  20. package/dist/demo.d.ts +1 -0
  21. package/dist/demo.js +18 -0
  22. package/dist/effect-build.d.ts +3 -0
  23. package/dist/effect-build.js +44 -0
  24. package/dist/environment-rules.d.ts +7 -0
  25. package/dist/environment-rules.js +94 -0
  26. package/dist/environment.d.ts +48 -0
  27. package/dist/environment.js +184 -0
  28. package/dist/job-journal.d.ts +19 -0
  29. package/dist/job-journal.js +110 -0
  30. package/dist/jobs.d.ts +103 -0
  31. package/dist/jobs.js +626 -0
  32. package/dist/lib/content.d.ts +24 -0
  33. package/dist/lib/content.js +106 -0
  34. package/dist/lib/presentation.d.ts +26 -0
  35. package/dist/lib/presentation.js +252 -0
  36. package/dist/lib/yaml-sharing.d.ts +16 -0
  37. package/dist/lib/yaml-sharing.js +130 -0
  38. package/dist/managed-projects.d.ts +37 -0
  39. package/dist/managed-projects.js +305 -0
  40. package/dist/managed-sources.d.ts +28 -0
  41. package/dist/managed-sources.js +541 -0
  42. package/dist/mcp-contracts.d.ts +420 -0
  43. package/dist/mcp-contracts.js +146 -0
  44. package/dist/mcp.d.ts +2 -0
  45. package/dist/mcp.js +228 -0
  46. package/dist/module-path.d.ts +1 -0
  47. package/dist/module-path.js +8 -0
  48. package/dist/pack-project.d.ts +13 -0
  49. package/dist/pack-project.js +179 -0
  50. package/dist/preview-control.d.ts +17 -0
  51. package/dist/preview-control.js +273 -0
  52. package/dist/preview.d.ts +24 -0
  53. package/dist/preview.js +332 -0
  54. package/dist/project-teams.d.ts +51 -0
  55. package/dist/project-teams.js +106 -0
  56. package/dist/project.d.ts +18 -0
  57. package/dist/project.js +146 -0
  58. package/dist/rename.d.ts +2 -0
  59. package/dist/rename.js +128 -0
  60. package/dist/setup.d.ts +2 -0
  61. package/dist/setup.js +117 -0
  62. package/dist/source-lock.d.ts +9 -0
  63. package/dist/source-lock.js +117 -0
  64. package/dist/template/README.md +2 -0
  65. package/dist/template/docs/presentation.md +3 -3
  66. package/dist/template/package.json +3 -7
  67. package/dist/template/test/pack.test.mjs +10 -7
  68. package/dist/testing.d.ts +58 -0
  69. package/dist/testing.js +205 -0
  70. package/dist/types.d.ts +5 -0
  71. package/dist/types.js +14 -0
  72. package/dist/workbench-context.d.ts +10 -0
  73. package/dist/workbench-context.js +27 -0
  74. package/dist/workspace-cli.d.ts +1 -0
  75. package/dist/workspace-cli.js +66 -0
  76. package/dist/workspace-materials.d.ts +19 -0
  77. package/dist/workspace-materials.js +165 -0
  78. package/dist/workspace.d.ts +190 -0
  79. package/dist/workspace.js +726 -0
  80. package/package.json +34 -27
  81. package/dist/asset-inspect.mjs +0 -67
  82. package/dist/author-api.mjs +0 -112
  83. package/dist/author-reference.mjs +0 -121
  84. package/dist/build-content.mjs +0 -30
  85. package/dist/cli.mjs +0 -76
  86. package/dist/content-query.mjs +0 -283
  87. package/dist/content-workspace.d.mts +0 -161
  88. package/dist/content-workspace.mjs +0 -936
  89. package/dist/debug-environments.mjs +0 -154
  90. package/dist/demo.mjs +0 -22
  91. package/dist/effect-build.d.mts +0 -2
  92. package/dist/effect-build.mjs +0 -46
  93. package/dist/environment-rules.d.mts +0 -5
  94. package/dist/environment-rules.mjs +0 -92
  95. package/dist/environment.mjs +0 -183
  96. package/dist/job-journal.mjs +0 -94
  97. package/dist/jobs.mjs +0 -579
  98. package/dist/lib/content.mjs +0 -95
  99. package/dist/lib/presentation.mjs +0 -240
  100. package/dist/lib/yaml-sharing.mjs +0 -101
  101. package/dist/managed-projects.d.mts +0 -35
  102. package/dist/managed-projects.mjs +0 -303
  103. package/dist/managed-sources.d.mts +0 -19
  104. package/dist/managed-sources.mjs +0 -503
  105. package/dist/mcp-contracts.mjs +0 -153
  106. package/dist/mcp.mjs +0 -369
  107. package/dist/pack-project.mjs +0 -157
  108. package/dist/preview-control.mjs +0 -260
  109. package/dist/preview.mjs +0 -313
  110. package/dist/project-teams.mjs +0 -98
  111. package/dist/project.mjs +0 -140
  112. package/dist/rename.mjs +0 -112
  113. package/dist/setup.mjs +0 -134
  114. package/dist/source-lock.mjs +0 -103
  115. package/dist/testing.mjs +0 -204
  116. package/dist/workbench-context.mjs +0 -18
  117. package/dist/workspace-cli.mjs +0 -60
  118. package/dist/workspace-materials.mjs +0 -153
  119. package/dist/workspace.mjs +0 -684
  120. /package/dist/{index.d.mts → index.d.ts} +0 -0
  121. /package/dist/{index.mjs → index.js} +0 -0
@@ -0,0 +1,326 @@
1
+ import { lstat, readFile, realpath } from 'node:fs/promises';
2
+ import { dirname, join } from 'node:path';
3
+ import { AuthorWorkspace, WorkspaceError, diagnostic, } from './workspace.js';
4
+ import { recordSharing } from './lib/yaml-sharing.js';
5
+ import { errorCode, isRecord } from './types.js';
6
+ const kinds = ['content', 'presentations', 'resources', 'assets', 'files', 'locales', 'diagnostics'];
7
+ const contentKinds = ['species', 'skills', 'marks', 'behaviors', 'presentations', 'resources'];
8
+ const scopes = ['project', 'dependencies', 'all'];
9
+ const details = ['summary', 'full'];
10
+ const localeKinds = {
11
+ species: 'species',
12
+ skill: 'skills',
13
+ mark: 'marks',
14
+ mark_ability: 'marks',
15
+ mark_emblem: 'marks',
16
+ mark_global: 'marks',
17
+ };
18
+ const compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
19
+ function invalid(message) {
20
+ throw new WorkspaceError('QUERY_INVALID', message);
21
+ }
22
+ const pageBytes = 2 * 1024 * 1024;
23
+ const packageLimit = 256;
24
+ const packageNamePattern = /^(?:@[a-z0-9_.-]+\/)?[a-z0-9][a-z0-9_.-]*$/i;
25
+ function options(input = {}) {
26
+ const kind = input.kind ?? 'content';
27
+ const scope = input.scope ?? 'project';
28
+ const detail = input.detail ?? 'summary';
29
+ if (typeof kind !== 'string' || !kinds.includes(kind))
30
+ invalid('查询类型无效');
31
+ if (typeof scope !== 'string' || !scopes.includes(scope))
32
+ invalid('查询范围无效');
33
+ if (typeof detail !== 'string' || !details.includes(detail))
34
+ invalid('查询详情级别无效');
35
+ const contentKind = input.contentKind;
36
+ if (contentKind !== undefined &&
37
+ (typeof contentKind !== 'string' || !contentKinds.includes(contentKind)))
38
+ invalid('内容类型无效');
39
+ for (const key of ['search', 'id', 'locale', 'namespace', 'packageName']) {
40
+ const value = input[key];
41
+ if (value !== undefined && (typeof value !== 'string' || value.length > 200))
42
+ invalid(`${key} 需要不超过 200 字符的文本`);
43
+ }
44
+ const offset = input.offset ?? 0;
45
+ const limit = input.limit ?? 50;
46
+ if (typeof offset !== 'number' || !Number.isInteger(offset) || offset < 0)
47
+ invalid('offset 需要非负整数');
48
+ if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)
49
+ invalid('limit 需要 1–100 的整数');
50
+ return {
51
+ kind: kind,
52
+ scope: scope,
53
+ detail: detail,
54
+ search: typeof input.search === 'string' ? input.search : '',
55
+ offset,
56
+ limit,
57
+ ...(typeof contentKind === 'string' ? { contentKind } : {}),
58
+ ...(typeof input.id === 'string' ? { id: input.id } : {}),
59
+ ...(typeof input.locale === 'string' ? { locale: input.locale } : {}),
60
+ ...(typeof input.namespace === 'string' ? { namespace: input.namespace } : {}),
61
+ ...(typeof input.packageName === 'string' ? { packageName: input.packageName } : {}),
62
+ };
63
+ }
64
+ function runtimeDependencies(manifest) {
65
+ const entries = new Map();
66
+ const metadata = isRecord(manifest.peerDependenciesMeta) ? manifest.peerDependenciesMeta : {};
67
+ for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies']) {
68
+ const value = manifest[field];
69
+ if (!isRecord(value))
70
+ continue;
71
+ for (const name of Object.keys(value).sort(compare)) {
72
+ if (!packageNamePattern.test(name))
73
+ throw new WorkspaceError('DEPENDENCY_INVALID', '依赖包名无效', 'package.json');
74
+ const optional = isRecord(metadata[name]) && metadata[name].optional === true;
75
+ entries.set(name, field === 'optionalDependencies' || optional);
76
+ }
77
+ }
78
+ return [...entries].sort(([a], [b]) => compare(a, b));
79
+ }
80
+ // Resolve declared packages without executing package exports or consulting global module paths.
81
+ async function installedPackage(from, name) {
82
+ for (let directory = from;; directory = dirname(directory)) {
83
+ const candidate = join(directory, 'node_modules', name);
84
+ try {
85
+ const root = await realpath(candidate);
86
+ const file = join(root, 'package.json');
87
+ const info = await lstat(file);
88
+ if (!info.isFile() || info.size > pageBytes)
89
+ throw new WorkspaceError('DEPENDENCY_INVALID', '依赖清单需要不超过 2 MiB 的普通文件', file);
90
+ return { root, manifest: JSON.parse(await readFile(file, 'utf8')) };
91
+ }
92
+ catch (error) {
93
+ if (errorCode(error) !== 'ENOENT')
94
+ throw error;
95
+ }
96
+ if (dirname(directory) === directory)
97
+ throw new WorkspaceError('DEPENDENCY_MISSING', `未安装声明的依赖:${name}`);
98
+ }
99
+ }
100
+ function provenance(snapshot, scope, manifest) {
101
+ return {
102
+ namespace: snapshot.project.namespace,
103
+ packageName: manifest.name,
104
+ packageVersion: manifest.version,
105
+ projectId: snapshot.project.projectId,
106
+ scope,
107
+ readOnly: scope === 'dependencies' || !snapshot.capabilities.sourceEditing,
108
+ };
109
+ }
110
+ async function catalogs(workspace, scope) {
111
+ const manifest = JSON.parse((await workspace.read('package.json')).text);
112
+ const project = await workspace.snapshot();
113
+ const own = { snapshot: project, owner: provenance(project, 'project', manifest) };
114
+ const result = scope === 'dependencies' ? [] : [own];
115
+ const diagnostics = [];
116
+ if (scope === 'project')
117
+ return { catalogs: result, diagnostics };
118
+ const queue = runtimeDependencies(manifest).map(([name, optional]) => ({
119
+ from: workspace.root,
120
+ name,
121
+ optional,
122
+ }));
123
+ const visited = new Set([workspace.root]);
124
+ const identities = new Map([[project.project.namespace, manifest.name]]);
125
+ let inspected = 0;
126
+ while (queue.length) {
127
+ if (++inspected > packageLimit) {
128
+ diagnostics.push({
129
+ code: 'DEPENDENCY_QUERY_LIMIT',
130
+ severity: 'warning',
131
+ message: '依赖查询超过 256 项,请缩小依赖树;结果不完整',
132
+ });
133
+ break;
134
+ }
135
+ const next = queue.shift();
136
+ if (!next)
137
+ break;
138
+ const { from, name, optional } = next;
139
+ let dependency;
140
+ try {
141
+ const { root, manifest: metadata } = await installedPackage(from, name);
142
+ if (visited.has(root))
143
+ continue;
144
+ visited.add(root);
145
+ if (metadata.arcadia || metadata.name === '@arcadia-eternity/data-pack-base') {
146
+ dependency = await AuthorWorkspace.open(root, { watch: false, readOnly: true, published: !!metadata.arcadia });
147
+ const snapshot = await dependency.snapshot();
148
+ const owner = provenance(snapshot, 'dependencies', metadata);
149
+ const previous = identities.get(owner.namespace);
150
+ if (previous !== undefined)
151
+ diagnostics.push({
152
+ ...owner,
153
+ code: 'NAMESPACE_CONFLICT',
154
+ severity: 'error',
155
+ message: `命名空间 ${owner.namespace} 同时用于 ${previous} 和 ${metadata.name}`,
156
+ });
157
+ identities.set(owner.namespace, metadata.name);
158
+ result.push({ snapshot, owner });
159
+ // Match the loader's visible content dependencies: stop at each content package.
160
+ }
161
+ else {
162
+ queue.push(...runtimeDependencies(metadata).map(([child, absentAllowed]) => ({
163
+ from: root,
164
+ name: child,
165
+ optional: absentAllowed,
166
+ })));
167
+ }
168
+ }
169
+ catch (error) {
170
+ if (!(optional && errorCode(error) === 'DEPENDENCY_MISSING'))
171
+ diagnostics.push({ ...diagnostic(error), packageName: name, scope: 'dependencies', readOnly: true });
172
+ }
173
+ finally {
174
+ await dependency?.close();
175
+ }
176
+ }
177
+ return { catalogs: result, diagnostics };
178
+ }
179
+ function translations(snapshot, row, locale) {
180
+ return snapshot.localeSources
181
+ .flatMap((source) => {
182
+ const entries = isRecord(source.entries) ? source.entries : undefined;
183
+ const entry = entries?.[row.record.id];
184
+ return localeKinds[source.namespace] === row.kind && (!locale || source.language === locale) && isRecord(entry)
185
+ ? [{ locale: source.language, localeNamespace: source.namespace, ...entry }]
186
+ : [];
187
+ })
188
+ .sort((a, b) => compare(a.locale, b.locale) || compare(a.localeNamespace, b.localeNamespace));
189
+ }
190
+ function nameFields(localizations, requested, fallback) {
191
+ const locale = requested ?? localizations.find(entry => entry.locale === 'zh-CN')?.locale ?? localizations[0]?.locale;
192
+ const names = [
193
+ ...new Set(localizations
194
+ .filter(entry => entry.locale === locale)
195
+ .map(entry => entry.name)
196
+ .filter((value) => typeof value === 'string' && value.length > 0)),
197
+ ];
198
+ return {
199
+ ...(locale ? { locale } : {}),
200
+ ...(names.length === 1
201
+ ? { name: names[0].slice(0, 200) }
202
+ : !names.length && typeof fallback === 'string'
203
+ ? { name: fallback.slice(0, 200) }
204
+ : {}),
205
+ ...(names.length > 1 ? { ambiguousName: true } : {}),
206
+ };
207
+ }
208
+ function rowsFor(catalog, query) {
209
+ const { snapshot, owner } = catalog;
210
+ const identify = (id, kind, source = {}) => ({
211
+ ...owner,
212
+ kind,
213
+ id,
214
+ qualifiedId: `${owner.namespace}:${id}`,
215
+ ...source,
216
+ });
217
+ if (query.kind === 'locales')
218
+ return snapshot.localeSources.flatMap(source => {
219
+ const entries = isRecord(source.entries) ? source.entries : {};
220
+ return Object.entries(entries).flatMap(([id, record]) => {
221
+ if (!isRecord(record))
222
+ return [];
223
+ const row = identify(id, 'locales', {
224
+ contentKind: localeKinds[source.namespace],
225
+ file: source.file,
226
+ version: source.version,
227
+ locale: source.language,
228
+ localeNamespace: source.namespace,
229
+ ...(source.locations?.[id] ?? {}),
230
+ });
231
+ return [
232
+ {
233
+ row,
234
+ text: JSON.stringify({ ...row, ...record }),
235
+ full: { ...row, record, sharedFields: recordSharing(source.sharedFields, id) },
236
+ summary: {
237
+ ...row,
238
+ ...(typeof record.name === 'string' ? { name: record.name.slice(0, 200) } : {}),
239
+ ...(typeof record.description === 'string'
240
+ ? { descriptionPreview: record.description.slice(0, 240) }
241
+ : {}),
242
+ },
243
+ },
244
+ ];
245
+ });
246
+ });
247
+ if (query.kind === 'files' || query.kind === 'diagnostics')
248
+ return (query.kind === 'files' ? snapshot.files : snapshot.diagnostics).map((entry) => {
249
+ const row = { ...owner, kind: query.kind, ...entry };
250
+ return { row, text: JSON.stringify(row), full: row, summary: row };
251
+ });
252
+ if (query.kind === 'assets')
253
+ return snapshot.assets.map((asset) => {
254
+ const definition = snapshot.records.find(row => row.kind === 'resources' && row.record.id === asset.id && row.file === asset.definition);
255
+ const { kind: resourceKind, ...metadata } = asset;
256
+ const row = identify(asset.id, 'assets', {
257
+ contentKind: 'resources',
258
+ resourceKind,
259
+ ...metadata,
260
+ ...(definition ? { version: definition.version, index: definition.index } : {}),
261
+ });
262
+ const { references, ...summary } = row;
263
+ return {
264
+ row,
265
+ text: JSON.stringify(row),
266
+ full: row,
267
+ summary: { ...summary, referenceCount: Array.isArray(references) ? references.length : 0 },
268
+ };
269
+ });
270
+ return snapshot.records
271
+ .filter(row => !['presentations', 'resources'].includes(query.kind) || row.kind === query.kind)
272
+ .map((source) => {
273
+ const localizations = translations(snapshot, source, query.locale);
274
+ const row = identify(source.record.id, source.kind, {
275
+ contentKind: source.kind,
276
+ file: source.file,
277
+ version: source.version,
278
+ index: source.index,
279
+ ...(source.line ? { line: source.line, column: source.column } : {}),
280
+ ...nameFields(localizations, query.locale, source.record.name),
281
+ });
282
+ return {
283
+ row,
284
+ text: JSON.stringify({ ...row, record: source.record, localizations }),
285
+ summary: row,
286
+ full: { ...row, record: source.record, sharedFields: source.sharedFields, localizations },
287
+ };
288
+ });
289
+ }
290
+ /** Read-only discovery over disk data. Never loads effects or changes workbench selection/drafts. */
291
+ export async function queryContent(workspace, input = {}) {
292
+ const query = options(input);
293
+ const { catalogs: sources, diagnostics } = await catalogs(workspace, query.scope);
294
+ const needle = query.search.toLowerCase();
295
+ const rows = sources
296
+ .flatMap(source => rowsFor(source, query))
297
+ .filter(({ row, text }) => (query.id === undefined || row.id === query.id || row.qualifiedId === query.id) &&
298
+ (query.contentKind === undefined || row.contentKind === query.contentKind) &&
299
+ (query.namespace === undefined || row.namespace === query.namespace) &&
300
+ (query.packageName === undefined || row.packageName === query.packageName) &&
301
+ (query.kind !== 'locales' || query.locale === undefined || row.locale === query.locale) &&
302
+ text.toLowerCase().includes(needle));
303
+ if (query.id !== undefined &&
304
+ ['content', 'presentations', 'resources', 'assets'].includes(query.kind) &&
305
+ rows.length > 1)
306
+ diagnostics.push({
307
+ code: 'CONTENT_AMBIGUOUS',
308
+ severity: 'warning',
309
+ message: '此 ID 对应多个对象;请使用 contentKind、namespace 或 packageName 明确目标',
310
+ });
311
+ const items = [];
312
+ let bytes = 0;
313
+ for (const candidate of rows.slice(query.offset, query.offset + query.limit)) {
314
+ const item = candidate[query.detail === 'full' ? 'full' : 'summary'];
315
+ const size = Buffer.byteLength(JSON.stringify(item));
316
+ if (bytes + size > pageBytes) {
317
+ if (!items.length)
318
+ throw new WorkspaceError('QUERY_ITEM_TOO_LARGE', '此详情超过 2 MiB,请查询摘要并读取对应源码文件');
319
+ break;
320
+ }
321
+ bytes += size;
322
+ items.push(item);
323
+ }
324
+ const next = query.offset + items.length;
325
+ return { total: rows.length, offset: query.offset, nextOffset: next < rows.length ? next : null, items, diagnostics };
326
+ }
@@ -0,0 +1,171 @@
1
+ import { type EnvironmentDocumentV2 } from './debug-environments.js';
2
+ export type { EnvironmentRules } from './debug-environments.js';
3
+ export type EnvironmentDocument = EnvironmentDocumentV2;
4
+ export interface EnvironmentDraft {
5
+ document: EnvironmentDocument;
6
+ revision: string;
7
+ }
8
+ export interface EnvironmentVersion {
9
+ format: 'arcadia.environment-version/1';
10
+ versionId: string;
11
+ workspaceId: string;
12
+ environmentId: string;
13
+ document: EnvironmentDocument;
14
+ draftRevision: string;
15
+ contentRevision: string;
16
+ members?: EnvironmentMember[];
17
+ packages: unknown[];
18
+ createdAt: number;
19
+ adopted: boolean;
20
+ materialDirectory: string;
21
+ directory: string;
22
+ status: 'ready';
23
+ }
24
+ export interface UnavailableVersion {
25
+ versionId: string;
26
+ workspaceId: string;
27
+ environmentId?: string;
28
+ status: 'unavailable';
29
+ reason: string;
30
+ }
31
+ export interface PrepareVersionInput {
32
+ onProgress?: (progress: {
33
+ stage: string;
34
+ completed?: number;
35
+ total?: number;
36
+ }) => void | Promise<void>;
37
+ environmentId: string;
38
+ expectedRevision: string;
39
+ projectDirectory?: string;
40
+ directory?: string;
41
+ signal?: AbortSignal;
42
+ beforeCommit?: () => Promise<void>;
43
+ }
44
+ export type StaticPreparer = (input: {
45
+ directory: string;
46
+ draft: EnvironmentDocument;
47
+ signal?: AbortSignal;
48
+ }) => Promise<{
49
+ contentRevision: string;
50
+ packages?: unknown[];
51
+ }>;
52
+ export interface ContentWorkspaceOptions {
53
+ maxBytes?: number;
54
+ maxFiles?: number;
55
+ stagingRetentionMs?: number;
56
+ resolveProject?: (environmentId: string) => string | undefined | Promise<string | undefined>;
57
+ acquireMaterials?: (directory: string, versionId: string) => Promise<() => void | Promise<void>>;
58
+ retentions?: {
59
+ list(versionId: string): Promise<Record<string, unknown>[]>;
60
+ put?(versionId: string, retentionId: string): Promise<void>;
61
+ remove?(retentionId: string): Promise<void>;
62
+ };
63
+ }
64
+ export interface EnvironmentExport {
65
+ format: 'arcadia.environment-export/1';
66
+ document: EnvironmentDocument;
67
+ contentRevision: string;
68
+ files: {
69
+ path: string;
70
+ data: string;
71
+ }[];
72
+ }
73
+ export interface WorkspaceSnapshot {
74
+ format: 'arcadia.workspace-snapshot/1';
75
+ workspaceId: string;
76
+ drafts: EnvironmentDraft[];
77
+ versions: {
78
+ version: Pick<EnvironmentVersion, 'versionId' | 'environmentId' | 'document' | 'draftRevision' | 'contentRevision' | 'packages' | 'createdAt'>;
79
+ files: {
80
+ path: string;
81
+ data: string;
82
+ }[];
83
+ }[];
84
+ }
85
+ export interface WorkspaceSnapshotStamp {
86
+ workspaceId: string;
87
+ bootId: string;
88
+ generation: number;
89
+ }
90
+ export interface WorkspaceSnapshotCapture {
91
+ snapshot: WorkspaceSnapshot;
92
+ stamp: WorkspaceSnapshotStamp;
93
+ }
94
+ export interface ContentWorkspace {
95
+ readonly root: string;
96
+ readonly workspaceId: string;
97
+ readonly bootId: string;
98
+ listDrafts(): Promise<EnvironmentDraft[]>;
99
+ getDraft(environmentId: string): Promise<EnvironmentDraft>;
100
+ saveDraft(input: {
101
+ document: unknown;
102
+ expectedRevision: string | null;
103
+ }): Promise<EnvironmentDraft>;
104
+ deleteDraft(input: {
105
+ environmentId: string;
106
+ expectedRevision: string;
107
+ }): Promise<void>;
108
+ prepareVersion(input: PrepareVersionInput, preparer: StaticPreparer): Promise<EnvironmentVersion>;
109
+ adoptVersion(input: PrepareVersionInput, preparer: StaticPreparer): Promise<EnvironmentVersion>;
110
+ getVersion(versionId: string): Promise<EnvironmentVersion>;
111
+ listVersions(environmentId?: string): Promise<(EnvironmentVersion | UnavailableVersion)[]>;
112
+ acquire(versionId: string, owner?: string): Promise<EnvironmentVersion & {
113
+ release(): Promise<void>;
114
+ }>;
115
+ retain(versionId: string, retentionId: string): Promise<void>;
116
+ releaseRetention(retentionId: string): Promise<void>;
117
+ references(versionId: string): Promise<Record<string, unknown>[]>;
118
+ deleteVersion(versionId: string): Promise<void>;
119
+ exportVersion(versionId: string): Promise<EnvironmentExport>;
120
+ exportSnapshot(): Promise<WorkspaceSnapshot>;
121
+ captureSnapshot(): Promise<WorkspaceSnapshotCapture>;
122
+ isSnapshotCurrent(stamp: WorkspaceSnapshotStamp): Promise<boolean>;
123
+ restoreSnapshot(snapshot: WorkspaceSnapshot, input: {
124
+ mode: 'restore' | 'clone';
125
+ }, preparer: StaticPreparer): Promise<{
126
+ workspaceId: string;
127
+ versionIds: Record<string, string>;
128
+ }>;
129
+ importVersion(bundle: EnvironmentExport, input: {
130
+ environmentId?: string;
131
+ expectedRevision?: string | null;
132
+ signal?: AbortSignal;
133
+ beforeCommit?: () => Promise<void>;
134
+ importId?: string;
135
+ }, preparer: StaticPreparer): Promise<EnvironmentVersion>;
136
+ recoverImport(importId: string): Promise<EnvironmentVersion>;
137
+ forgetImport(importId: string, input?: {
138
+ discard?: boolean;
139
+ }): Promise<void>;
140
+ reconcile(): Promise<{
141
+ workspaceId: string;
142
+ versions: (EnvironmentVersion | UnavailableVersion)[];
143
+ abandoned: string[];
144
+ }>;
145
+ close(input?: {
146
+ force?: boolean;
147
+ }): Promise<void>;
148
+ cleanupStaging(): Promise<string[]>;
149
+ }
150
+ export interface ContentWorkspaceConstructor {
151
+ new (root: string, options?: ContentWorkspaceOptions): ContentWorkspace;
152
+ open(directory: string, options?: ContentWorkspaceOptions): Promise<ContentWorkspace>;
153
+ }
154
+ export interface EnvironmentMember {
155
+ name: string;
156
+ version: string;
157
+ projectId: string;
158
+ namespace: string;
159
+ direct: boolean;
160
+ dependencies: string[];
161
+ requiredBy: string[];
162
+ }
163
+ export declare const ContentWorkspace: ContentWorkspaceConstructor;
164
+ /** Change desired roots only. Resolved material and all published versions remain immutable. */
165
+ export declare function setEnvironmentPackageEnabled(workspace: Pick<ContentWorkspace, 'listDrafts' | 'listVersions' | 'saveDraft'>, input: {
166
+ environmentId: string;
167
+ expectedRevision: string;
168
+ name: string;
169
+ enabled: boolean;
170
+ cascade?: boolean;
171
+ }): Promise<EnvironmentDraft>;