@demicodes/host-local 0.17.2 → 0.17.4

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/dist/index.d.mts CHANGED
@@ -50,6 +50,8 @@ interface LocalHostOptions {
50
50
  storeRoot?: string;
51
51
  /** Where command artifacts land as plain files; defaults next to the store. */
52
52
  commandArtifactsDir?: string;
53
+ /** Bring-your-own persistence, e.g. to wrap or gate writes; defaults to a LocalHostStore rooted at storeRoot. */
54
+ store?: HostStore;
53
55
  }
54
56
  declare class LocalHost implements Host {
55
57
  readonly defaultCwd: string;
@@ -60,6 +62,17 @@ declare class LocalHost implements Host {
60
62
  constructor(defaultCwd: string, options?: LocalHostOptions);
61
63
  }
62
64
  //#endregion
65
+ //#region src/local-store.d.ts
66
+ declare class LocalHostStore implements HostStore {
67
+ readonly root: string;
68
+ constructor(root: string);
69
+ readJson<T>(key: string): Promise<T | null>;
70
+ writeJson<T>(key: string, value: T): Promise<void>;
71
+ delete(key: string): Promise<void>;
72
+ list(prefix: string): Promise<string[]>;
73
+ private pathForKey;
74
+ }
75
+ //#endregion
63
76
  //#region src/local-agent-server.d.ts
64
77
  interface CreateLocalAgentServerOptions {
65
78
  /** Same LocalHost instance the harness was built with. */
@@ -106,4 +119,4 @@ interface LocalAgentServerHandle {
106
119
  */
107
120
  declare function createLocalAgentServer(options: CreateLocalAgentServerOptions): LocalAgentServerHandle;
108
121
  //#endregion
109
- export { COMMAND_BRIDGE_SHIM_SOURCE, CommandBridgeHandle, CommandBridgeOptions, CreateLocalAgentServerOptions, LocalAgentServerHandle, LocalHost, LocalHostOptions, MaterializeCommandBridgeShimsOptions, bridgeBinDirFor, createLocalAgentServer, defaultBridgeSocketPath, materializeCommandBridgeShims, resolveDemiHome, startCommandBridge };
122
+ export { COMMAND_BRIDGE_SHIM_SOURCE, CommandBridgeHandle, CommandBridgeOptions, CreateLocalAgentServerOptions, LocalAgentServerHandle, LocalHost, LocalHostOptions, LocalHostStore, MaterializeCommandBridgeShimsOptions, bridgeBinDirFor, createLocalAgentServer, defaultBridgeSocketPath, materializeCommandBridgeShims, resolveDemiHome, startCommandBridge };
package/dist/index.mjs CHANGED
@@ -284,7 +284,14 @@ var LocalHostStore = class {
284
284
  async writeJson(key, value) {
285
285
  const path = this.pathForKey(key);
286
286
  await mkdir(dirname(path), { recursive: true });
287
- await writeFile(path, stringifyPortableJson(value, 2), "utf8");
287
+ const temp = `${path}.${randomUUID()}.tmp`;
288
+ try {
289
+ await writeFile(temp, stringifyPortableJson(value, 2), "utf8");
290
+ await rename(temp, path);
291
+ } catch (error) {
292
+ await rm(temp, { force: true });
293
+ throw error;
294
+ }
288
295
  }
289
296
  async delete(key) {
290
297
  await rm(this.pathForKey(key), {
@@ -343,7 +350,7 @@ var LocalHost = class {
343
350
  this.commandArtifactsDir = resolve(options.commandArtifactsDir ?? join(storeRoot, "command-artifacts"));
344
351
  this.fs = new LocalHostFileSystem(this.defaultCwd);
345
352
  this.process = new LocalHostProcess(this.defaultCwd);
346
- this.store = new LocalHostStore(storeRoot);
353
+ this.store = options.store ?? new LocalHostStore(storeRoot);
347
354
  }
348
355
  };
349
356
  var LocalHostProcess = class {
@@ -650,4 +657,4 @@ function createLocalAgentServer(options) {
650
657
  };
651
658
  }
652
659
  //#endregion
653
- export { COMMAND_BRIDGE_SHIM_SOURCE, LocalHost, bridgeBinDirFor, createLocalAgentServer, defaultBridgeSocketPath, materializeCommandBridgeShims, resolveDemiHome, startCommandBridge };
660
+ export { COMMAND_BRIDGE_SHIM_SOURCE, LocalHost, LocalHostStore, bridgeBinDirFor, createLocalAgentServer, defaultBridgeSocketPath, materializeCommandBridgeShims, resolveDemiHome, startCommandBridge };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/host-local",
3
3
  "description": "Node LocalHost and open-box local AgentServer assembly (command bridge on by default).",
4
- "version": "0.17.2",
4
+ "version": "0.17.4",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -11,10 +11,10 @@
11
11
  }
12
12
  },
13
13
  "dependencies": {
14
- "@demicodes/agent": "^0.17.2",
15
- "@demicodes/provider": "^0.17.2",
16
- "@demicodes/shell": "^0.17.2",
17
- "@demicodes/utils": "^0.17.2"
14
+ "@demicodes/agent": "^0.17.4",
15
+ "@demicodes/provider": "^0.17.4",
16
+ "@demicodes/shell": "^0.17.4",
17
+ "@demicodes/utils": "^0.17.4"
18
18
  },
19
19
  "license": "Apache-2.0",
20
20
  "main": "./dist/index.mjs",