agent-relay-runner 0.118.4 → 0.119.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
- "version": "0.118.4",
3
+ "version": "0.119.0",
4
4
  "description": "Unified provider lifecycle runner for Agent Relay",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "agent-relay-providers": "0.104.1",
24
- "agent-relay-sdk": "0.2.101",
24
+ "agent-relay-sdk": "0.2.102",
25
25
  "callmux": "0.23.0"
26
26
  },
27
27
  "devDependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
3
  "description": "Thin Agent Relay runner bridge for Claude Code",
4
- "version": "0.118.4",
4
+ "version": "0.119.0",
5
5
  "agentRelayContracts": {
6
6
  "providerPluginProtocol": 1
7
7
  }
@@ -848,6 +848,61 @@ import { promisify } from "util";
848
848
  var execFileAsync = promisify(execFile);
849
849
  // sdk/src/teams-config.ts
850
850
  var TEAM_IDLE_THRESHOLD_MINUTES_MAX = 24 * 60;
851
+ // sdk/src/admission/semaphore.ts
852
+ class Semaphore {
853
+ #limit;
854
+ #inFlight = 0;
855
+ #waiters = [];
856
+ constructor(limit) {
857
+ if (!Number.isInteger(limit) || limit < 1) {
858
+ throw new RangeError(`Semaphore limit must be an integer >= 1, got ${limit}`);
859
+ }
860
+ this.#limit = limit;
861
+ }
862
+ get limit() {
863
+ return this.#limit;
864
+ }
865
+ get inFlight() {
866
+ return this.#inFlight;
867
+ }
868
+ get waiting() {
869
+ return this.#waiters.length;
870
+ }
871
+ get available() {
872
+ return this.#limit - this.#inFlight;
873
+ }
874
+ tryAcquire() {
875
+ if (this.#inFlight < this.#limit) {
876
+ this.#inFlight++;
877
+ return true;
878
+ }
879
+ return false;
880
+ }
881
+ acquire() {
882
+ if (this.tryAcquire())
883
+ return Promise.resolve();
884
+ return new Promise((resolve) => {
885
+ this.#waiters.push(resolve);
886
+ });
887
+ }
888
+ release() {
889
+ const next = this.#waiters.shift();
890
+ if (next) {
891
+ next();
892
+ return;
893
+ }
894
+ if (this.#inFlight > 0)
895
+ this.#inFlight--;
896
+ }
897
+ async run(fn) {
898
+ await this.acquire();
899
+ try {
900
+ return await fn();
901
+ } finally {
902
+ this.release();
903
+ }
904
+ }
905
+ }
851
906
  // runner/src/config.ts
852
907
  function messageBodyMaxCharsFromEnv() {
853
908
  return process.env.AGENT_RELAY_MESSAGE_BODY_MAX_CHARS;
@@ -245,6 +245,7 @@ export class AgentRunner {
245
245
  // its final response. Set when a provider-turn starts, cleared when it ends.
246
246
  private currentTurnId?: string;
247
247
  private currentTurnStartedAt?: number;
248
+ private completedProviderTurns = 0;
248
249
  // #435: high-water-mark for the pre-turn narrative flush. Counts how many
249
250
  // valid JSONL entries were in the transcript at last pre-flush time so the
250
251
  // Stop-hook capture (full mode) can skip what was already emitted.
@@ -1241,7 +1242,7 @@ export class AgentRunner {
1241
1242
  }
1242
1243
  this.busyReconciler.arm();
1243
1244
  } else if (status === "idle" && reason === "provider-turn") {
1244
- if (this.currentTurnId) this.sessionLog(`turn ended via provider idle (turn ${this.currentTurnId})`);
1245
+ if (this.currentTurnId) { this.completedProviderTurns += 1; this.sessionLog(`turn ended via provider idle (turn ${this.currentTurnId})`); }
1245
1246
  this.currentTurnId = undefined;
1246
1247
  this.currentTurnStartedAt = undefined;
1247
1248
  this.compactionMidTurn = false;
@@ -1928,6 +1929,7 @@ export class AgentRunner {
1928
1929
  : { lastError: "Claude provider exited; manual intervention required" }),
1929
1930
  } : {}),
1930
1931
  busyReasons: this.claims.reasons(),
1932
+ completedProviderTurns: this.completedProviderTurns,
1931
1933
  activeWork,
1932
1934
  activeSubagents,
1933
1935
  activeSubagentCount: activeSubagents.length,