@volter/supercode-orchestrator 0.5.92 → 0.5.94

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 (2) hide show
  1. package/board/doors.mjs +23 -2
  2. package/package.json +2 -2
package/board/doors.mjs CHANGED
@@ -38,11 +38,32 @@ export async function machineCall(machine, method, params = {}, { timeoutMs = 60
38
38
  const started = performance.now();
39
39
  try {
40
40
  const door = await opened(machine);
41
+ // A stream on the channel ends with the daemon behind it (another machine's daemon restarting, an upgrade), while
42
+ // the channel to it stays open: a held stream is used only while it is open, and opened again once it is not.
41
43
  if (method.startsWith('harness.v1.sessions.')) {
42
- door.harness ??= (async () => { const client = new SupercodeHarnessClient({ transport: harnessTransport(door.channel) }); await client.start?.(); return client; })();
44
+ if (door.harness && door.harnessStarted && !door.harnessTransport?.running) {
45
+ const ended = door.harness;
46
+ door.harness = null;
47
+ void ended.then((client) => client.close?.(), () => {}).catch(() => {});
48
+ }
49
+ if (!door.harness) {
50
+ const transport = harnessTransport(door.channel);
51
+ door.harnessTransport = transport;
52
+ door.harnessStarted = false;
53
+ const starting = (async () => { const client = new SupercodeHarnessClient({ transport }); await client.start?.(); door.harnessStarted = true; return client; })();
54
+ starting.catch(() => { if (door.harness === starting) door.harness = null; });
55
+ door.harness = starting;
56
+ }
43
57
  return await (await door.harness).request(method, params, { timeoutMs });
44
58
  }
45
- door.node ??= door.channel.open('node').then((stream) => new StreamRpc(stream));
59
+ if (!door.node) {
60
+ const opening = door.channel.open('node').then((stream) => {
61
+ stream.on('close', () => { if (door.node === opening) door.node = null; });
62
+ return new StreamRpc(stream);
63
+ });
64
+ opening.catch(() => { if (door.node === opening) door.node = null; });
65
+ door.node = opening;
66
+ }
46
67
  return await (await door.node).call(method, params, { timeoutMs });
47
68
  } finally {
48
69
  noteStep(`door ${method}${machine ? ' (another machine)' : ''}`, performance.now() - started);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.5.92",
3
+ "version": "0.5.94",
4
4
  "type": "module",
5
5
  "description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
6
6
  "exports": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@volter/supercode-harness-sdk": "^0.3.60",
28
- "@volter/teams": "0.2.34",
28
+ "@volter/teams": "0.2.35",
29
29
  "@volter/ztrack": "^2.4.23",
30
30
  "yaml": "^2.9.0"
31
31
  },