@harness-engineering/orchestrator 0.8.0 → 0.8.1
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/dist/index.js +36 -26
- package/dist/index.mjs +36 -26
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2887,6 +2887,21 @@ var path21 = __toESM(require("path"));
|
|
|
2887
2887
|
var import_node_crypto16 = require("crypto");
|
|
2888
2888
|
var import_core14 = require("@harness-engineering/core");
|
|
2889
2889
|
|
|
2890
|
+
// src/core/stall-detector.ts
|
|
2891
|
+
function detectStalledIssues(running, nowMs, stallTimeoutMs) {
|
|
2892
|
+
if (stallTimeoutMs <= 0) return [];
|
|
2893
|
+
const stalled = [];
|
|
2894
|
+
for (const [runId, entry] of running) {
|
|
2895
|
+
const reference = entry.session?.lastTimestamp ?? entry.startedAt;
|
|
2896
|
+
if (!reference) continue;
|
|
2897
|
+
const silentMs = nowMs - new Date(reference).getTime();
|
|
2898
|
+
if (silentMs >= stallTimeoutMs) {
|
|
2899
|
+
stalled.push(runId);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
return stalled;
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2890
2905
|
// src/intelligence/pipeline-runner.ts
|
|
2891
2906
|
var path9 = __toESM(require("path"));
|
|
2892
2907
|
var import_intelligence = require("@harness-engineering/intelligence");
|
|
@@ -6941,7 +6956,7 @@ var ChatRequestSchema = import_zod6.z.object({
|
|
|
6941
6956
|
});
|
|
6942
6957
|
function handleChatProxyRoute(req, res, command = "claude") {
|
|
6943
6958
|
const { method, url } = req;
|
|
6944
|
-
if (method === "POST" && url === "/api/chat") {
|
|
6959
|
+
if (method === "POST" && (url === "/api/chat" || url === "/api/chat-proxy")) {
|
|
6945
6960
|
void handleChatRequest(req, res, command);
|
|
6946
6961
|
return true;
|
|
6947
6962
|
}
|
|
@@ -9300,7 +9315,7 @@ function requiredScopeForRoute(method, path24) {
|
|
|
9300
9315
|
if (path24.startsWith("/api/maintenance")) return "trigger-job";
|
|
9301
9316
|
if (path24.startsWith("/api/streams")) return "read-status";
|
|
9302
9317
|
if (path24.startsWith("/api/sessions")) return "read-status";
|
|
9303
|
-
if (path24.startsWith("/api/chat-proxy")) return "trigger-job";
|
|
9318
|
+
if (path24 === "/api/chat" || path24.startsWith("/api/chat-proxy")) return "trigger-job";
|
|
9304
9319
|
return null;
|
|
9305
9320
|
}
|
|
9306
9321
|
|
|
@@ -13011,32 +13026,27 @@ ${messages}`);
|
|
|
13011
13026
|
await this.handleEffect(effect);
|
|
13012
13027
|
}
|
|
13013
13028
|
const stallTimeoutMs = this.config.agent.stallTimeoutMs;
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
}
|
|
13023
|
-
|
|
13024
|
-
for (const runId of stalledIds) {
|
|
13025
|
-
const runEntry = this.state.running.get(runId);
|
|
13026
|
-
if (!runEntry) continue;
|
|
13027
|
-
this.logger.warn(
|
|
13028
|
-
`Agent stalled for ${runEntry.identifier}: ${Math.round((nowMs - new Date(runEntry.session?.lastTimestamp ?? 0).getTime()) / 1e3)}s since last event`,
|
|
13029
|
-
{ issueId: runId }
|
|
13030
|
-
);
|
|
13031
|
-
const stallEvent = {
|
|
13032
|
-
type: "stall_detected",
|
|
13029
|
+
const stalledIds = detectStalledIssues(this.state.running, nowMs, stallTimeoutMs);
|
|
13030
|
+
for (const runId of stalledIds) {
|
|
13031
|
+
const runEntry = this.state.running.get(runId);
|
|
13032
|
+
if (!runEntry) continue;
|
|
13033
|
+
const reference = runEntry.session?.lastTimestamp ?? runEntry.startedAt;
|
|
13034
|
+
const silentSec = Math.round((nowMs - new Date(reference).getTime()) / 1e3);
|
|
13035
|
+
const sinceWhat = runEntry.session?.lastTimestamp ? "last event" : "dispatch";
|
|
13036
|
+
this.logger.warn(
|
|
13037
|
+
`Agent stalled for ${runEntry.identifier}: ${silentSec}s since ${sinceWhat}`,
|
|
13038
|
+
{
|
|
13033
13039
|
issueId: runId
|
|
13034
|
-
};
|
|
13035
|
-
const stallResult = applyEvent(this.state, stallEvent, this.config);
|
|
13036
|
-
this.state = stallResult.nextState;
|
|
13037
|
-
for (const eff of stallResult.effects) {
|
|
13038
|
-
await this.handleEffect(eff);
|
|
13039
13040
|
}
|
|
13041
|
+
);
|
|
13042
|
+
const stallEvent = {
|
|
13043
|
+
type: "stall_detected",
|
|
13044
|
+
issueId: runId
|
|
13045
|
+
};
|
|
13046
|
+
const stallResult = applyEvent(this.state, stallEvent, this.config);
|
|
13047
|
+
this.state = stallResult.nextState;
|
|
13048
|
+
for (const eff of stallResult.effects) {
|
|
13049
|
+
await this.handleEffect(eff);
|
|
13040
13050
|
}
|
|
13041
13051
|
}
|
|
13042
13052
|
const openPrNumbers = [];
|
package/dist/index.mjs
CHANGED
|
@@ -2778,6 +2778,21 @@ import * as path21 from "path";
|
|
|
2778
2778
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
2779
2779
|
import { writeTaint } from "@harness-engineering/core";
|
|
2780
2780
|
|
|
2781
|
+
// src/core/stall-detector.ts
|
|
2782
|
+
function detectStalledIssues(running, nowMs, stallTimeoutMs) {
|
|
2783
|
+
if (stallTimeoutMs <= 0) return [];
|
|
2784
|
+
const stalled = [];
|
|
2785
|
+
for (const [runId, entry] of running) {
|
|
2786
|
+
const reference = entry.session?.lastTimestamp ?? entry.startedAt;
|
|
2787
|
+
if (!reference) continue;
|
|
2788
|
+
const silentMs = nowMs - new Date(reference).getTime();
|
|
2789
|
+
if (silentMs >= stallTimeoutMs) {
|
|
2790
|
+
stalled.push(runId);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
return stalled;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2781
2796
|
// src/intelligence/pipeline-runner.ts
|
|
2782
2797
|
import * as path9 from "path";
|
|
2783
2798
|
import { weightedRecommendPersona, refreshProfiles } from "@harness-engineering/intelligence";
|
|
@@ -6874,7 +6889,7 @@ var ChatRequestSchema = z6.object({
|
|
|
6874
6889
|
});
|
|
6875
6890
|
function handleChatProxyRoute(req, res, command = "claude") {
|
|
6876
6891
|
const { method, url } = req;
|
|
6877
|
-
if (method === "POST" && url === "/api/chat") {
|
|
6892
|
+
if (method === "POST" && (url === "/api/chat" || url === "/api/chat-proxy")) {
|
|
6878
6893
|
void handleChatRequest(req, res, command);
|
|
6879
6894
|
return true;
|
|
6880
6895
|
}
|
|
@@ -9263,7 +9278,7 @@ function requiredScopeForRoute(method, path24) {
|
|
|
9263
9278
|
if (path24.startsWith("/api/maintenance")) return "trigger-job";
|
|
9264
9279
|
if (path24.startsWith("/api/streams")) return "read-status";
|
|
9265
9280
|
if (path24.startsWith("/api/sessions")) return "read-status";
|
|
9266
|
-
if (path24.startsWith("/api/chat-proxy")) return "trigger-job";
|
|
9281
|
+
if (path24 === "/api/chat" || path24.startsWith("/api/chat-proxy")) return "trigger-job";
|
|
9267
9282
|
return null;
|
|
9268
9283
|
}
|
|
9269
9284
|
|
|
@@ -12982,32 +12997,27 @@ ${messages}`);
|
|
|
12982
12997
|
await this.handleEffect(effect);
|
|
12983
12998
|
}
|
|
12984
12999
|
const stallTimeoutMs = this.config.agent.stallTimeoutMs;
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
}
|
|
12994
|
-
|
|
12995
|
-
for (const runId of stalledIds) {
|
|
12996
|
-
const runEntry = this.state.running.get(runId);
|
|
12997
|
-
if (!runEntry) continue;
|
|
12998
|
-
this.logger.warn(
|
|
12999
|
-
`Agent stalled for ${runEntry.identifier}: ${Math.round((nowMs - new Date(runEntry.session?.lastTimestamp ?? 0).getTime()) / 1e3)}s since last event`,
|
|
13000
|
-
{ issueId: runId }
|
|
13001
|
-
);
|
|
13002
|
-
const stallEvent = {
|
|
13003
|
-
type: "stall_detected",
|
|
13000
|
+
const stalledIds = detectStalledIssues(this.state.running, nowMs, stallTimeoutMs);
|
|
13001
|
+
for (const runId of stalledIds) {
|
|
13002
|
+
const runEntry = this.state.running.get(runId);
|
|
13003
|
+
if (!runEntry) continue;
|
|
13004
|
+
const reference = runEntry.session?.lastTimestamp ?? runEntry.startedAt;
|
|
13005
|
+
const silentSec = Math.round((nowMs - new Date(reference).getTime()) / 1e3);
|
|
13006
|
+
const sinceWhat = runEntry.session?.lastTimestamp ? "last event" : "dispatch";
|
|
13007
|
+
this.logger.warn(
|
|
13008
|
+
`Agent stalled for ${runEntry.identifier}: ${silentSec}s since ${sinceWhat}`,
|
|
13009
|
+
{
|
|
13004
13010
|
issueId: runId
|
|
13005
|
-
};
|
|
13006
|
-
const stallResult = applyEvent(this.state, stallEvent, this.config);
|
|
13007
|
-
this.state = stallResult.nextState;
|
|
13008
|
-
for (const eff of stallResult.effects) {
|
|
13009
|
-
await this.handleEffect(eff);
|
|
13010
13011
|
}
|
|
13012
|
+
);
|
|
13013
|
+
const stallEvent = {
|
|
13014
|
+
type: "stall_detected",
|
|
13015
|
+
issueId: runId
|
|
13016
|
+
};
|
|
13017
|
+
const stallResult = applyEvent(this.state, stallEvent, this.config);
|
|
13018
|
+
this.state = stallResult.nextState;
|
|
13019
|
+
for (const eff of stallResult.effects) {
|
|
13020
|
+
await this.handleEffect(eff);
|
|
13011
13021
|
}
|
|
13012
13022
|
}
|
|
13013
13023
|
const openPrNumbers = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harness-engineering/orchestrator",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Orchestrator daemon for dispatching coding agents to issues",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"ws": "^8.21.0",
|
|
49
49
|
"yaml": "^2.8.3",
|
|
50
50
|
"zod": "^3.25.76",
|
|
51
|
-
"@harness-engineering/core": "0.
|
|
52
|
-
"@harness-engineering/
|
|
53
|
-
"@harness-engineering/
|
|
54
|
-
"@harness-engineering/
|
|
51
|
+
"@harness-engineering/core": "0.29.0",
|
|
52
|
+
"@harness-engineering/graph": "0.11.0",
|
|
53
|
+
"@harness-engineering/intelligence": "0.2.7",
|
|
54
|
+
"@harness-engineering/types": "0.16.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@asteasolutions/zod-to-openapi": "^7.3.0",
|