@ricsam/r5d-worker 0.0.147 → 0.0.149

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,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "type": "commonjs"
5
5
  }
package/dist/mjs/main.mjs CHANGED
@@ -7,7 +7,7 @@ import { startManagerRpc } from "./runtime/releases/rpc-main.mjs";
7
7
  import { ManagerRpcConfig } from "./runtime/releases/rpc-protocol.mjs";
8
8
  const args = process.argv.slice(2);
9
9
  if (args.includes("--version")) {
10
- console.log(`r5d-worker ${true ? "0.0.147" : "development"}`);
10
+ console.log(`r5d-worker ${true ? "0.0.149" : "development"}`);
11
11
  } else if (!args.length || args.includes("--help")) {
12
12
  console.log(
13
13
  "Usage: r5d-worker start --label <label> [--root <dir>] [--base-url <url>] [--token <worker-token>]\n r5d-worker executor /absolute/private/config.json\n r5d-worker manager /absolute/private/config.json\n\nRun independently supervised durable runtime services. Provision configuration with r5dinfra."
@@ -15,7 +15,7 @@ if (args.includes("--version")) {
15
15
  } else if (args[0] === "start") {
16
16
  const runtime = await startPersonalWorker(
17
17
  parsePersonalWorkerOptions(args.slice(1)),
18
- true ? "0.0.147" : "development"
18
+ true ? "0.0.149" : "development"
19
19
  );
20
20
  console.log(`Worker connected: ${runtime.resourceId}`);
21
21
  let closing = false;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "type": "module"
5
5
  }
@@ -1,12 +1,14 @@
1
1
  class PersonalActionScheduler {
2
- constructor(execute, failed, limit = 8) {
2
+ constructor(execute, failed, limit = 8, responsiveReserve = 4) {
3
3
  this.execute = execute;
4
4
  this.failed = failed;
5
5
  this.limit = limit;
6
+ this.responsiveReserve = responsiveReserve;
6
7
  }
7
8
  execute;
8
9
  failed;
9
10
  limit;
11
+ responsiveReserve;
10
12
  active = /* @__PURE__ */ new Map();
11
13
  accept(actions) {
12
14
  for (const action of actions) {
@@ -16,8 +18,13 @@ class PersonalActionScheduler {
16
18
  continue;
17
19
  }
18
20
  const request = action.request;
19
- const lane = request.kind === "tcp" && typeof request.command?.streamId === "string" ? `tcp:${request.sessionId}:${request.command.streamId}` : request.kind === "terminal" && ["poll", "processPoll"].includes(request.command?.method ?? "") ? `terminal-poll:${request.sessionId}:${request.command?.operationId ?? request.command?.runId ?? "unknown"}` : request.kind === "inspect" && ["processes", "status"].includes(request.command?.method ?? "") ? `inspect:${request.sessionId}` : "mutation";
20
- if (this.active.size >= this.limit || [...this.active.values()].some((value) => value.lane === lane)) continue;
21
+ const command = request.command;
22
+ const executionId = command?.operationId ?? command?.runId ?? command?.run?.operationId ?? command?.id ?? "unknown";
23
+ const workbenchId = request.workbench?.id ?? request.sessionId ?? "unknown";
24
+ const responsive = ["terminal", "agent", "tcp"].includes(request.kind ?? "");
25
+ const lane = request.kind === "tcp" && typeof request.command?.streamId === "string" ? `tcp:${request.sessionId}:${request.command.streamId}` : ["terminal", "agent"].includes(request.kind ?? "") && ["poll", "processPoll"].includes(command?.method ?? "") ? `execution-poll:${request.sessionId}:${executionId}` : ["terminal", "agent"].includes(request.kind ?? "") && ["write", "resize", "cancel", "processCancel"].includes(command?.method ?? "") ? `execution-action:${request.sessionId}:${executionId}` : request.kind === "inspect" && ["processes", "status"].includes(request.command?.method ?? "") ? `inspect:${workbenchId}` : `mutation:${workbenchId}`;
26
+ const capacity = this.limit + (responsive ? this.responsiveReserve : 0);
27
+ if (this.active.size >= capacity || [...this.active.values()].some((value) => value.lane === lane)) continue;
21
28
  const task = Promise.resolve().then(() => this.execute(action)).catch(this.failed).finally(() => this.active.delete(action.id));
22
29
  this.active.set(action.id, { hash: action.requestHash, lane, task });
23
30
  }
@@ -4,22 +4,33 @@ export type PersonalQueuedAction = {
4
4
  request: {
5
5
  kind?: string;
6
6
  sessionId?: string;
7
+ workbench?: {
8
+ id?: string;
9
+ };
7
10
  command?: {
11
+ id?: string;
8
12
  method?: string;
9
13
  streamId?: string;
10
14
  operationId?: string;
11
15
  runId?: string;
16
+ run?: {
17
+ operationId?: string;
18
+ };
12
19
  };
13
20
  };
14
21
  };
15
22
  /** Native receipts own effects. This only admits bounded independent transport
16
- * lanes; mutations keep their original global order and each TCP stream is serial. */
23
+ * lanes. Workspace authority owns filesystem serialization; this transport keeps
24
+ * actions ordered only within their actual workbench, process, or TCP stream.
25
+ * Terminal, agent, and TCP traffic has a small bounded reserve so background
26
+ * workbench inspections cannot consume every connection needed to control it. */
17
27
  export declare class PersonalActionScheduler {
18
28
  private readonly execute;
19
29
  private readonly failed;
20
30
  private readonly limit;
31
+ private readonly responsiveReserve;
21
32
  private readonly active;
22
- constructor(execute: (action: PersonalQueuedAction) => Promise<void>, failed: (error: unknown) => void, limit?: number);
33
+ constructor(execute: (action: PersonalQueuedAction) => Promise<void>, failed: (error: unknown) => void, limit?: number, responsiveReserve?: number);
23
34
  accept(actions: PersonalQueuedAction[]): void;
24
35
  drain(): Promise<void>;
25
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.147",
3
+ "version": "0.0.149",
4
4
  "type": "module",
5
5
  "main": "./dist/mjs/main.mjs",
6
6
  "module": "./dist/mjs/main.mjs",
@@ -21,8 +21,8 @@
21
21
  "r5d-worker": "dist/mjs/main.mjs"
22
22
  },
23
23
  "dependencies": {
24
- "@ricsam/r5d-api": "^0.0.147",
25
- "@ricsam/r5dctl": "0.0.147",
24
+ "@ricsam/r5d-api": "^0.0.149",
25
+ "@ricsam/r5dctl": "0.0.149",
26
26
  "node-pty": "1.1.0",
27
27
  "zod": "^4.1.13",
28
28
  "picomatch": "^4.0.3"