@arcadia-eternity/content-sdk 4.4.2 → 4.5.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.
package/README.md CHANGED
@@ -88,12 +88,14 @@ Environment schema v2 adds versioned rule data and runtime requirements. Existin
88
88
 
89
89
  ## Shared management workspace
90
90
 
91
- `@arcadia-eternity/content-sdk/management-workspace` exports the typed `ContentWorkspace` API used by desktop owners and servers. One process owns each workspace; another live writer is rejected, while a confirmed dead process owner can be recovered. `saveDraft` requires the current revision. `prepareVersion` captures and statically validates a fixed npm installation, while `adoptVersion` borrows existing client materials through a material-owner lease without another installation. Long preparation accepts an abort signal and a trusted `beforeCommit` authorization check.
91
+ `@arcadia-eternity/content-sdk/management-workspace` exports the typed `ContentWorkspace` API used by desktop owners and servers. One process owns each workspace; another live writer is rejected, while a confirmed dead process owner can be recovered. `saveDraft` is a low-level file-editing primitive. User-facing saves submit one apply operation; `prepareEnvironment` accepts the proposed document and expected revision (null for creation), committing it with the validated installation. A failed apply preserves the previous manifest and installation. `prepareEnvironment` installs and statically validates the current environment in its persistent npm project. Its package.json and package-lock.json remain authoritative across preparations. There are no selectable historical environment versions. The managed installer uses the host-provided bundled base directly from local disk; mixed environments use its local archive, never a registry fallback. Long preparation accepts an abort signal and a trusted `beforeCommit` authorization check.
92
92
 
93
- Workspace files own environment definitions and immutable versions. Database adapters supply durable retention roots; runtime leases belong to the current owner. Deletion fails closed when retention information is unavailable, and owner shutdown refuses outstanding runtime leases. Server bindings, accounts, grants and running rooms remain separate from these files.
93
+ Workspace files own persistent environment projects and their current installations. Database adapters supply durable retention roots; runtime leases belong to the current owner. Deletion fails closed when retention information is unavailable, and owner shutdown refuses outstanding runtime leases. Server bindings, accounts, grants and running rooms remain separate from these files.
94
94
 
95
- `exportVersion` creates a portable environment archive with standard npm locks and material bytes, excluding server and workspace identities. `exportSnapshot` captures workspace identity, drafts and fixed versions for a server backup. `restoreSnapshot` requires an empty, inactive staging workspace: restore preserves identities, clone remaps them. The server backup coordinator validates the corresponding database snapshot before switching the full server directory. These file APIs do not provide a transaction spanning the database and filesystem.
95
+ `exportEnvironment` requires the current manifest to be prepared and creates a portable environment archive with standard npm locks and material bytes, excluding server and workspace identities. `exportSnapshot` captures workspace identity and every environment project, including pending manifest edits and uninstalled projects for a server backup. `restoreSnapshot` requires an empty, inactive staging workspace: restore preserves workspace identity, clone creates a new workspace identity while keeping environment names. The server backup coordinator validates the corresponding database snapshot before switching the full server directory. These file APIs do not provide a transaction spanning the database and filesystem.
96
96
 
97
97
  ## Repository development
98
98
 
99
99
  `pnpm --filter @arcadia-eternity/content-sdk watch` builds once, then rebuilds when `src`, `template`, or either bundled skill directory under `docs/guides` changes. Rebuilds are serialized, include deletions, and recover after a failed build. The root `pnpm watch` includes this watcher. `pnpm --filter @arcadia-eternity/content-sdk clear` removes `dist`; root `pnpm clear` includes it as well. The package `typecheck` validates the TypeScript implementation and generated declarations; Node tests exercise the source modules directly.
100
+
101
+ `ManagedProjects.synchronizeBundledBase(workspace, validate)` refreshes shipped base content in existing environments at host startup. It replaces only the local base files and their manifest/lock entries, preserves installed third-party dependencies, and commits each validated update atomically. Old base version declarations follow the shipped version. `synchronizeProject` provides the same staged update for desktop library projects and external startup projects; unchanged base materials are a no-op, including across restarts.
@@ -1,13 +1,14 @@
1
1
  import { type EnvironmentDocumentV2 } from './debug-environments.js';
2
+ export { normalizeEnvironmentDocument } from './debug-environments.js';
2
3
  export type { EnvironmentRules } from './debug-environments.js';
3
4
  export type EnvironmentDocument = EnvironmentDocumentV2;
4
5
  export interface EnvironmentDraft {
5
6
  document: EnvironmentDocument;
6
7
  revision: string;
7
8
  }
8
- export interface EnvironmentVersion {
9
- format: 'arcadia.environment-version/1';
10
- versionId: string;
9
+ export interface EnvironmentInstallation {
10
+ format: 'arcadia.environment-installation/1';
11
+ installationId: string;
11
12
  workspaceId: string;
12
13
  environmentId: string;
13
14
  document: EnvironmentDocument;
@@ -16,26 +17,26 @@ export interface EnvironmentVersion {
16
17
  members?: EnvironmentMember[];
17
18
  packages: unknown[];
18
19
  createdAt: number;
19
- adopted: boolean;
20
20
  materialDirectory: string;
21
21
  directory: string;
22
22
  status: 'ready';
23
23
  }
24
- export interface UnavailableVersion {
25
- versionId: string;
24
+ export interface UnavailableInstallation {
25
+ installationId: string;
26
26
  workspaceId: string;
27
27
  environmentId?: string;
28
28
  status: 'unavailable';
29
29
  reason: string;
30
30
  }
31
- export interface PrepareVersionInput {
31
+ export interface PrepareEnvironmentInput {
32
32
  onProgress?: (progress: {
33
33
  stage: string;
34
34
  completed?: number;
35
35
  total?: number;
36
36
  }) => void | Promise<void>;
37
37
  environmentId: string;
38
- expectedRevision: string;
38
+ expectedRevision: string | null;
39
+ document?: EnvironmentDocument;
39
40
  projectDirectory?: string;
40
41
  directory?: string;
41
42
  signal?: AbortSignal;
@@ -54,15 +55,14 @@ export interface ContentWorkspaceOptions {
54
55
  maxFiles?: number;
55
56
  stagingRetentionMs?: number;
56
57
  resolveProject?: (environmentId: string) => string | undefined | Promise<string | undefined>;
57
- acquireMaterials?: (directory: string, versionId: string) => Promise<() => void | Promise<void>>;
58
58
  retentions?: {
59
- list(versionId: string): Promise<Record<string, unknown>[]>;
60
- put?(versionId: string, retentionId: string): Promise<void>;
59
+ list(installationId: string): Promise<Record<string, unknown>[]>;
60
+ put?(installationId: string, retentionId: string): Promise<void>;
61
61
  remove?(retentionId: string): Promise<void>;
62
62
  };
63
63
  }
64
64
  export interface EnvironmentExport {
65
- format: 'arcadia.environment-export/1';
65
+ format: 'arcadia.environment-export/2';
66
66
  document: EnvironmentDocument;
67
67
  contentRevision: string;
68
68
  files: {
@@ -71,11 +71,16 @@ export interface EnvironmentExport {
71
71
  }[];
72
72
  }
73
73
  export interface WorkspaceSnapshot {
74
- format: 'arcadia.workspace-snapshot/1';
74
+ format: 'arcadia.workspace-snapshot/2';
75
75
  workspaceId: string;
76
- drafts: EnvironmentDraft[];
77
- versions: {
78
- version: Pick<EnvironmentVersion, 'versionId' | 'environmentId' | 'document' | 'draftRevision' | 'contentRevision' | 'packages' | 'createdAt'>;
76
+ drafts: (EnvironmentDraft & {
77
+ files?: {
78
+ path: string;
79
+ data: string;
80
+ }[];
81
+ })[];
82
+ installations: {
83
+ version: Pick<EnvironmentInstallation, 'installationId' | 'environmentId' | 'document' | 'draftRevision' | 'contentRevision' | 'packages' | 'createdAt'>;
79
84
  files: {
80
85
  path: string;
81
86
  data: string;
@@ -105,18 +110,17 @@ export interface ContentWorkspace {
105
110
  environmentId: string;
106
111
  expectedRevision: string;
107
112
  }): 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
+ prepareEnvironment(input: PrepareEnvironmentInput, preparer: StaticPreparer): Promise<EnvironmentInstallation>;
114
+ getInstallation(installationId: string): Promise<EnvironmentInstallation>;
115
+ listInstallations(environmentId?: string): Promise<(EnvironmentInstallation | UnavailableInstallation)[]>;
116
+ acquire(installationId: string, owner?: string): Promise<EnvironmentInstallation & {
113
117
  release(): Promise<void>;
114
118
  }>;
115
- retain(versionId: string, retentionId: string): Promise<void>;
119
+ retain(installationId: string, retentionId: string): Promise<void>;
116
120
  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>;
121
+ references(installationId: string): Promise<Record<string, unknown>[]>;
122
+ clearInstallation(installationId: string): Promise<void>;
123
+ exportEnvironment(installationId: string): Promise<EnvironmentExport>;
120
124
  exportSnapshot(): Promise<WorkspaceSnapshot>;
121
125
  captureSnapshot(): Promise<WorkspaceSnapshotCapture>;
122
126
  isSnapshotCurrent(stamp: WorkspaceSnapshotStamp): Promise<boolean>;
@@ -124,22 +128,22 @@ export interface ContentWorkspace {
124
128
  mode: 'restore' | 'clone';
125
129
  }, preparer: StaticPreparer): Promise<{
126
130
  workspaceId: string;
127
- versionIds: Record<string, string>;
131
+ installationIds: Record<string, string>;
128
132
  }>;
129
- importVersion(bundle: EnvironmentExport, input: {
133
+ importEnvironment(bundle: EnvironmentExport, input: {
130
134
  environmentId?: string;
131
135
  expectedRevision?: string | null;
132
136
  signal?: AbortSignal;
133
137
  beforeCommit?: () => Promise<void>;
134
138
  importId?: string;
135
- }, preparer: StaticPreparer): Promise<EnvironmentVersion>;
136
- recoverImport(importId: string): Promise<EnvironmentVersion>;
139
+ }, preparer: StaticPreparer): Promise<EnvironmentInstallation>;
140
+ recoverImport(importId: string): Promise<EnvironmentInstallation>;
137
141
  forgetImport(importId: string, input?: {
138
142
  discard?: boolean;
139
143
  }): Promise<void>;
140
144
  reconcile(): Promise<{
141
145
  workspaceId: string;
142
- versions: (EnvironmentVersion | UnavailableVersion)[];
146
+ installations: (EnvironmentInstallation | UnavailableInstallation)[];
143
147
  abandoned: string[];
144
148
  }>;
145
149
  close(input?: {
@@ -161,8 +165,8 @@ export interface EnvironmentMember {
161
165
  requiredBy: string[];
162
166
  }
163
167
  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: {
168
+ /** Change desired roots only. Resolved material and all published installations remain immutable. */
169
+ export declare function setEnvironmentPackageEnabled(workspace: Pick<ContentWorkspace, 'listDrafts' | 'listInstallations' | 'saveDraft'>, input: {
166
170
  environmentId: string;
167
171
  expectedRevision: string;
168
172
  name: string;