@timurproko/a1 0.1.8-dev.277 → 0.1.8-dev.282

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.
@@ -1,7 +1,17 @@
1
+ import { rename, rm, writeFile } from "node:fs/promises";
1
2
  import { type SupervisorSnapshot } from "../lifecycle/index.js";
2
3
  import { type MaterializedRelease } from "../release/index.js";
3
4
  import { ControlStore } from "../storage/index.js";
4
5
  import { type ProductPaths } from "./paths.js";
6
+ interface EndpointMetadataCommitOperations {
7
+ readonly platform?: NodeJS.Platform;
8
+ readonly write?: typeof writeFile;
9
+ readonly replace?: typeof rename;
10
+ readonly remove?: typeof rm;
11
+ readonly wait?: (delayMs: number) => Promise<void>;
12
+ }
13
+ /** Atomically replaces endpoint metadata while tolerating bounded Windows reader sharing. */
14
+ export declare function commitEndpointMetadata(path: string, source: string, operations?: EndpointMetadataCommitOperations): Promise<void>;
5
15
  /** Owns one release-cohort endpoint and the authenticated launch instances registered through it. */
6
16
  export declare class SupervisorServer {
7
17
  #private;
@@ -38,3 +48,4 @@ export declare class SupervisorServer {
38
48
  close(stopAgents?: boolean): Promise<void>;
39
49
  closeForReleaseReplacement(stopAgents: boolean): Promise<void>;
40
50
  }
51
+ export {};
@@ -9,6 +9,36 @@ import { processIsAlive } from "../release/index.js";
9
9
  import { ControlStore } from "../storage/index.js";
10
10
  import { resolveProductPaths } from "./paths.js";
11
11
  import { PRODUCT_IDENTITY, PRODUCT_TEXT } from "../../product-identity.js";
12
+ const WINDOWS_METADATA_REPLACE_RETRY_DELAYS_MS = [5, 10, 20, 40, 80, 160];
13
+ /** Atomically replaces endpoint metadata while tolerating bounded Windows reader sharing. */
14
+ export async function commitEndpointMetadata(path, source, operations = {}) {
15
+ const temporary = `${path}.${process.pid}.tmp`;
16
+ const write = operations.write ?? writeFile;
17
+ const replace = operations.replace ?? rename;
18
+ const remove = operations.remove ?? rm;
19
+ const wait = operations.wait ?? (delayMs => new Promise(resolvePromise => setTimeout(resolvePromise, delayMs)));
20
+ let committed = false;
21
+ try {
22
+ await write(temporary, source, { mode: 0o600 });
23
+ for (let attempt = 0;; attempt += 1) {
24
+ try {
25
+ await replace(temporary, path);
26
+ committed = true;
27
+ return;
28
+ }
29
+ catch (error) {
30
+ const delayMs = WINDOWS_METADATA_REPLACE_RETRY_DELAYS_MS[attempt];
31
+ if ((operations.platform ?? platform()) !== "win32" || delayMs === undefined || !isWindowsSharingViolation(error))
32
+ throw error;
33
+ await wait(delayMs);
34
+ }
35
+ }
36
+ }
37
+ finally {
38
+ if (!committed)
39
+ await remove(temporary, { force: true }).catch(() => undefined);
40
+ }
41
+ }
12
42
  /** Owns one release-cohort endpoint and the authenticated launch instances registered through it. */
13
43
  export class SupervisorServer {
14
44
  store;
@@ -464,11 +494,10 @@ export class SupervisorServer {
464
494
  uncertainInstanceIds: [...this.#uncertainInstances],
465
495
  },
466
496
  };
467
- const temporary = `${this.paths.endpointMetadataPath}.${process.pid}.tmp`;
468
- this.#metadataWrites = this.#metadataWrites.then(async () => {
469
- await writeFile(temporary, JSON.stringify(metadata, null, 2), { mode: 0o600 });
470
- await rename(temporary, this.paths.endpointMetadataPath);
471
- });
497
+ const commit = () => commitEndpointMetadata(this.paths.endpointMetadataPath, JSON.stringify(metadata, null, 2));
498
+ // Platform: one exhausted filesystem replacement must fail its command, but it must not
499
+ // poison every later ownership revision after the sharing condition has cleared.
500
+ this.#metadataWrites = this.#metadataWrites.then(commit, commit);
472
501
  return this.#metadataWrites;
473
502
  }
474
503
  #send(socket, message) {
@@ -492,6 +521,10 @@ function sameContainmentIdentity(left, right) {
492
521
  function isMessageType(value, type) {
493
522
  return typeof value === "object" && value !== null && "type" in value && value.type === type;
494
523
  }
524
+ function isWindowsSharingViolation(error) {
525
+ return error instanceof Error && "code" in error
526
+ && (error.code === "EPERM" || error.code === "EACCES" || error.code === "EBUSY");
527
+ }
495
528
  async function ensureManagedEndpointDirectory(path) {
496
529
  await mkdir(path, { recursive: true, mode: 0o700 });
497
530
  const metadata = await lstat(path);
@@ -5,7 +5,7 @@
5
5
  "platform": "darwin",
6
6
  "architecture": "arm64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-09-07T08:25:38.527Z",
8
+ "builtAt": "2026-09-08T08:10:40.090Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian",
11
11
  "sha256": "dc03605e5780e2aeebb4ecafd62868dc673e22ddd38b024a369aff704ff136dc",
@@ -5,7 +5,7 @@
5
5
  "platform": "linux",
6
6
  "architecture": "x64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-09-07T08:25:31.488Z",
8
+ "builtAt": "2026-09-08T08:10:24.232Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian",
11
11
  "sha256": "ee8a00eaaf79c707459bbbfb52518e9739314967049fbe5fa625f36ce33db9ee",
@@ -5,10 +5,10 @@
5
5
  "platform": "win32",
6
6
  "architecture": "x64",
7
7
  "capability": "supported",
8
- "builtAt": "2026-09-07T08:27:38.736Z",
8
+ "builtAt": "2026-09-08T08:11:13.440Z",
9
9
  "artifact": {
10
10
  "filename": "process-guardian.exe",
11
- "sha256": "96f8b06771b8295aa89e52c773efb62d4a128ac71e0588875c603376ba58c3a0",
11
+ "sha256": "b6daac4921fa900e544d9db45f85177267934415ecdf2935c2d6d1ae8bc59b0a",
12
12
  "size": 177664
13
13
  },
14
14
  "provenance": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timurproko/a1",
3
- "version": "0.1.8-dev.277",
3
+ "version": "0.1.8-dev.282",
4
4
  "description": "Standalone terminal workspace for supervised native and managed agents",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.13.0",