@elpapi42/pi-fleet 0.1.0-beta.6 → 0.1.0-beta.8

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.
@@ -2,24 +2,24 @@
2
2
  "schemaVersion": 3,
3
3
  "package": {
4
4
  "name": "@elpapi42/pi-fleet",
5
- "version": "0.1.0-beta.6"
5
+ "version": "0.1.0-beta.8"
6
6
  },
7
7
  "managedPi": "@earendil-works/pi-coding-agent@0.80.10",
8
8
  "files": [
9
9
  {
10
10
  "path": "dist/cli-meta.json",
11
11
  "bytes": 21248,
12
- "sha256": "e4ed20fc94195e21b0da78bb789d54a74913fe9db6ea7b8041a201873447f957"
12
+ "sha256": "5847ef7406dd0e1186b7c1395cf6afa8f30cd8a43bdcb36caeb780edee9969d7"
13
13
  },
14
14
  {
15
15
  "path": "dist/cli.mjs",
16
- "bytes": 150369,
17
- "sha256": "59a79d1a66ddd63eccdf00bb8c88d9c35ce1bca9505bd5af99c846ff0e7150bc"
16
+ "bytes": 150476,
17
+ "sha256": "0553362dc5d95b35035ef98aa6dffffaa0bcf1d3dba8e9e1d64629befb7fedb0"
18
18
  },
19
19
  {
20
20
  "path": "dist/cli.mjs.map",
21
- "bytes": 270001,
22
- "sha256": "e8ceebe12bc4c8b97293b4f2e0b82d435d4073e97bcb00104aa9c97814f13322"
21
+ "bytes": 270235,
22
+ "sha256": "b1a0e49b475f8a10b88dcd94ee3c5e53fdc3c959026c48685e8d1639d3104c5c"
23
23
  },
24
24
  {
25
25
  "path": "dist/installer-meta.json",
@@ -39,17 +39,17 @@
39
39
  {
40
40
  "path": "dist/runtime-meta.json",
41
41
  "bytes": 241246,
42
- "sha256": "e731bbd8617a5c14f7d6337462d93a51c519b5f1e04a39b75631a900917f560d"
42
+ "sha256": "c032364ccea9b67eb133199beabc76f81a3cc8b74e074f8c3e6861166f4e6266"
43
43
  },
44
44
  {
45
45
  "path": "dist/runtime.mjs",
46
- "bytes": 320861,
47
- "sha256": "d0818457b5f53e205c81eee9a5aa43af0c342eefc5e7c0df87465eb78ba015be"
46
+ "bytes": 322583,
47
+ "sha256": "de25fd4f02af9a886f350626da70ac872e211b011e5583a32972e8a937023f20"
48
48
  },
49
49
  {
50
50
  "path": "dist/runtime.mjs.map",
51
- "bytes": 700987,
52
- "sha256": "5d318062779cc135816b22e91e0ea4689718c660116c2639b3e259b8f5b27b5c"
51
+ "bytes": 703760,
52
+ "sha256": "ab625292928298bad35333d62178a40a9a91ca4d3309cf39957a610239d42297"
53
53
  },
54
54
  {
55
55
  "path": "dist/sqlite-worker-meta.json",
@@ -79,7 +79,7 @@
79
79
  {
80
80
  "path": "package.json",
81
81
  "bytes": 2375,
82
- "sha256": "b0ec0589bf8e177ef1f9d974ad3d34354485b853cd17fac7188c38073c96fe69"
82
+ "sha256": "a1cbfc1347c7d28ecf289fb3f4e77e7bd6b5b477d397b6cf7b1890be0c69f1fd"
83
83
  }
84
84
  ],
85
85
  "dependencies": [
@@ -6272,7 +6272,7 @@
6272
6272
  "format": "esm"
6273
6273
  },
6274
6274
  "src/runtime/fleet-service.ts": {
6275
- "bytes": 35183,
6275
+ "bytes": 36962,
6276
6276
  "imports": [
6277
6277
  {
6278
6278
  "path": "node:crypto",
@@ -6385,7 +6385,7 @@
6385
6385
  "imports": [],
6386
6386
  "exports": [],
6387
6387
  "inputs": {},
6388
- "bytes": 700987
6388
+ "bytes": 703760
6389
6389
  },
6390
6390
  "dist/runtime.mjs": {
6391
6391
  "imports": [
@@ -6950,7 +6950,7 @@
6950
6950
  "bytesInOutput": 108
6951
6951
  },
6952
6952
  "src/runtime/fleet-service.ts": {
6953
- "bytesInOutput": 30238
6953
+ "bytesInOutput": 31960
6954
6954
  },
6955
6955
  "src/pi/session-selector.ts": {
6956
6956
  "bytesInOutput": 2113
@@ -6968,7 +6968,7 @@
6968
6968
  "bytesInOutput": 3543
6969
6969
  }
6970
6970
  },
6971
- "bytes": 320861
6971
+ "bytes": 322583
6972
6972
  }
6973
6973
  }
6974
6974
  }
package/dist/runtime.mjs CHANGED
@@ -7829,6 +7829,8 @@ var FleetService = class {
7829
7829
  async #dispatchSend(input, operationId, acceptedAt, initialAgent, ordinal) {
7830
7830
  let agent = initialAgent;
7831
7831
  let incarnationId = null;
7832
+ let startingProcess = null;
7833
+ let restoring = false;
7832
7834
  try {
7833
7835
  let coordinator = this.#coordinators.get(input.name);
7834
7836
  if (this.#launcher !== void 0 && coordinator === void 0) {
@@ -7853,6 +7855,7 @@ var FleetService = class {
7853
7855
  message: `Pi Fleet has reached its ${String(this.#limits.maxResidentProcesses)} process limit.`
7854
7856
  });
7855
7857
  } else {
7858
+ restoring = true;
7856
7859
  agent = await this.#markRestoring(agent);
7857
7860
  incarnationId = randomUUID2();
7858
7861
  await this.store.putIncarnation({
@@ -7861,7 +7864,7 @@ var FleetService = class {
7861
7864
  pid: null,
7862
7865
  state: "starting"
7863
7866
  });
7864
- const process2 = await this.#launcher.start(agent.launch, true, async (pid) => {
7867
+ startingProcess = await this.#launcher.start(agent.launch, true, async (pid) => {
7865
7868
  await this.store.putIncarnation({
7866
7869
  incarnationId,
7867
7870
  agentName: input.name,
@@ -7869,6 +7872,7 @@ var FleetService = class {
7869
7872
  state: "starting"
7870
7873
  });
7871
7874
  });
7875
+ const process2 = startingProcess;
7872
7876
  await this.store.putIncarnation({
7873
7877
  incarnationId,
7874
7878
  agentName: input.name,
@@ -7893,6 +7897,7 @@ var FleetService = class {
7893
7897
  };
7894
7898
  await this.store.putAgent(agent);
7895
7899
  coordinator = this.#attachCoordinator(agent, process2, incarnationId);
7900
+ restoring = false;
7896
7901
  }
7897
7902
  }
7898
7903
  await this.store.putSend({
@@ -7926,7 +7931,49 @@ var FleetService = class {
7926
7931
  agent: { id: agent.summary.id, name: agent.summary.name },
7927
7932
  acceptedAt
7928
7933
  });
7929
- } catch {
7934
+ } catch (error) {
7935
+ if (restoring && incarnationId !== null) {
7936
+ let cleanupUncertain = error instanceof PiCleanupUncertainError;
7937
+ let cleanupPid = error instanceof PiCleanupUncertainError ? error.pid : null;
7938
+ if (startingProcess !== null) {
7939
+ cleanupPid = startingProcess.pid;
7940
+ try {
7941
+ await startingProcess.stop();
7942
+ } catch {
7943
+ cleanupUncertain = true;
7944
+ }
7945
+ }
7946
+ const code = cleanupUncertain ? "incarnation_cleanup_uncertain" : "pi_start_failed";
7947
+ agent = {
7948
+ ...agent,
7949
+ summary: {
7950
+ ...agent.summary,
7951
+ state: "failed",
7952
+ process: { state: cleanupUncertain ? "cleanup_uncertain" : "absent" },
7953
+ error: { code }
7954
+ }
7955
+ };
7956
+ await this.store.putAgent(agent);
7957
+ await this.store.putIncarnation({
7958
+ incarnationId,
7959
+ agentName: input.name,
7960
+ pid: cleanupPid,
7961
+ state: cleanupUncertain ? "cleanup_uncertain" : "gone"
7962
+ });
7963
+ await this.store.putSend({
7964
+ sendId: operationId,
7965
+ agentName: input.name,
7966
+ ordinal,
7967
+ message: input.message,
7968
+ state: "failed",
7969
+ acceptedAt
7970
+ });
7971
+ if (!cleanupUncertain) this.#releaseProcessSlot(input.name);
7972
+ return err({
7973
+ code,
7974
+ message: cleanupUncertain ? `Fleet could not prove the failed Pi restoration for ${input.name} was removed.` : `Pi failed to restore for ${input.name}; the message was not dispatched.`
7975
+ });
7976
+ }
7930
7977
  if (!this.#coordinators.has(input.name)) this.#releaseProcessSlot(input.name);
7931
7978
  if (incarnationId !== null && !this.#coordinators.has(input.name)) {
7932
7979
  await this.store.putIncarnation({