@ricsam/r5d-worker 0.0.148 → 0.0.150

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.148",
3
+ "version": "0.0.150",
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.148" : "development"}`);
10
+ console.log(`r5d-worker ${true ? "0.0.150" : "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.148" : "development"
18
+ true ? "0.0.150" : "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.148",
3
+ "version": "0.0.150",
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) {
@@ -19,8 +21,10 @@ class PersonalActionScheduler {
19
21
  const command = request.command;
20
22
  const executionId = command?.operationId ?? command?.runId ?? command?.run?.operationId ?? command?.id ?? "unknown";
21
23
  const workbenchId = request.workbench?.id ?? request.sessionId ?? "unknown";
22
- 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:${request.sessionId}` : `mutation:${workbenchId}`;
23
- if (this.active.size >= this.limit || [...this.active.values()].some((value) => value.lane === lane)) continue;
24
+ const responsive = action.schedulingPriority === "interactive" || ["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;
24
28
  const task = Promise.resolve().then(() => this.execute(action)).catch(this.failed).finally(() => this.active.delete(action.id));
25
29
  this.active.set(action.id, { hash: action.requestHash, lane, task });
26
30
  }
@@ -1,6 +1,7 @@
1
1
  export type PersonalQueuedAction = {
2
2
  id: string;
3
3
  requestHash: string;
4
+ schedulingPriority?: "background" | "interactive";
4
5
  request: {
5
6
  kind?: string;
6
7
  sessionId?: string;
@@ -21,13 +22,17 @@ export type PersonalQueuedAction = {
21
22
  };
22
23
  /** Native receipts own effects. This only admits bounded independent transport
23
24
  * lanes. Workspace authority owns filesystem serialization; this transport keeps
24
- * actions ordered only within their actual workbench, process, or TCP stream. */
25
+ * actions ordered only within their actual workbench, process, or TCP stream.
26
+ * Terminal, agent, TCP and explicitly interactive traffic has a small bounded
27
+ * reserve so background workbench inspections cannot consume every connection
28
+ * needed to control it. */
25
29
  export declare class PersonalActionScheduler {
26
30
  private readonly execute;
27
31
  private readonly failed;
28
32
  private readonly limit;
33
+ private readonly responsiveReserve;
29
34
  private readonly active;
30
- constructor(execute: (action: PersonalQueuedAction) => Promise<void>, failed: (error: unknown) => void, limit?: number);
35
+ constructor(execute: (action: PersonalQueuedAction) => Promise<void>, failed: (error: unknown) => void, limit?: number, responsiveReserve?: number);
31
36
  accept(actions: PersonalQueuedAction[]): void;
32
37
  drain(): Promise<void>;
33
38
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.148",
3
+ "version": "0.0.150",
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.148",
25
- "@ricsam/r5dctl": "0.0.148",
24
+ "@ricsam/r5d-api": "^0.0.150",
25
+ "@ricsam/r5dctl": "0.0.150",
26
26
  "node-pty": "1.1.0",
27
27
  "zod": "^4.1.13",
28
28
  "picomatch": "^4.0.3"