@botbotgo/agent-harness 0.0.259 → 0.0.261
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/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/harness/run/startup-runtime.d.ts +1 -0
- package/dist/runtime/harness/run/startup-runtime.js +7 -1
- package/dist/runtime/harness/system/health-monitor.js +11 -3
- package/dist/runtime/harness.d.ts +1 -0
- package/dist/runtime/harness.js +15 -3
- package/dist/workspace/compile.js +20 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.260";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.260";
|
|
@@ -8,6 +8,7 @@ type Startable = {
|
|
|
8
8
|
export declare function initializeHarnessRuntime(input: {
|
|
9
9
|
persistence: RuntimePersistence;
|
|
10
10
|
healthMonitor: Startable | null;
|
|
11
|
+
scheduleBackgroundTask?: (task: Promise<void>) => void;
|
|
11
12
|
}): Promise<void>;
|
|
12
13
|
export declare function recoverStartupRuns(input: {
|
|
13
14
|
recoveryConfig: RecoveryConfig;
|
|
@@ -3,7 +3,13 @@ import { traceStartupStage } from "../../startup-tracing.js";
|
|
|
3
3
|
export async function initializeHarnessRuntime(input) {
|
|
4
4
|
await traceStartupStage("runtime.initialize.persistence", () => input.persistence.initialize());
|
|
5
5
|
if (input.healthMonitor) {
|
|
6
|
-
|
|
6
|
+
const healthMonitorStartTask = traceStartupStage("runtime.initialize.healthMonitor", () => input.healthMonitor.start());
|
|
7
|
+
if (input.scheduleBackgroundTask) {
|
|
8
|
+
input.scheduleBackgroundTask(healthMonitorStartTask);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
await healthMonitorStartTask;
|
|
12
|
+
}
|
|
7
13
|
}
|
|
8
14
|
}
|
|
9
15
|
export async function recoverStartupRuns(input) {
|
|
@@ -24,6 +24,14 @@ const DEFAULT_HEALTH_CONFIG = {
|
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
+
const ACTIVE_RUN_STATES = [
|
|
28
|
+
"queued",
|
|
29
|
+
"claimed",
|
|
30
|
+
"running",
|
|
31
|
+
"waiting_for_approval",
|
|
32
|
+
"resuming",
|
|
33
|
+
"cancelling",
|
|
34
|
+
];
|
|
27
35
|
function asObject(value) {
|
|
28
36
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
29
37
|
}
|
|
@@ -146,10 +154,10 @@ export class HealthMonitor {
|
|
|
146
154
|
async evaluate(nowMs = Date.now()) {
|
|
147
155
|
const updatedAt = new Date(nowMs).toISOString();
|
|
148
156
|
const [runs, approvals] = await Promise.all([
|
|
149
|
-
this.options.persistence.listRuns(),
|
|
150
|
-
this.options.persistence.listApprovals(),
|
|
157
|
+
Promise.all(ACTIVE_RUN_STATES.map((state) => this.options.persistence.listRuns({ state }))).then((groups) => groups.flat()),
|
|
158
|
+
this.options.persistence.listApprovals({ status: "pending" }),
|
|
151
159
|
]);
|
|
152
|
-
const pendingApprovals = approvals.
|
|
160
|
+
const pendingApprovals = approvals.length;
|
|
153
161
|
const stuckRuns = this.countStuckRuns(runs, nowMs);
|
|
154
162
|
const llmCheck = this.evaluateLlmCheck(updatedAt, nowMs);
|
|
155
163
|
const workloadCheck = this.evaluateWorkloadCheck(updatedAt, pendingApprovals, stuckRuns);
|
|
@@ -127,6 +127,7 @@ export declare class AgentHarnessRuntime {
|
|
|
127
127
|
}): Promise<string>;
|
|
128
128
|
private emit;
|
|
129
129
|
private trackBackgroundTask;
|
|
130
|
+
private scheduleBackgroundStartupTask;
|
|
130
131
|
private resolveToolMcpServerTools;
|
|
131
132
|
private loadPriorHistory;
|
|
132
133
|
private loadRunInput;
|
package/dist/runtime/harness.js
CHANGED
|
@@ -43,6 +43,14 @@ import { normalizeProcessExecutablePath } from "./support/runtime-env.js";
|
|
|
43
43
|
import { streamHarnessRun } from "./harness/run/stream-run.js";
|
|
44
44
|
import { defaultRequestedAgentId, prepareRunStart } from "./harness/run/start-run.js";
|
|
45
45
|
import { buildRequestInspectionRecord, buildSessionInspectionRecord, deleteSessionRecord, deleteThreadRecord, getPublicApproval, listPublicApprovals, } from "./harness/run/thread-records.js";
|
|
46
|
+
const ACTIVE_RUN_STATES = [
|
|
47
|
+
"queued",
|
|
48
|
+
"claimed",
|
|
49
|
+
"running",
|
|
50
|
+
"waiting_for_approval",
|
|
51
|
+
"resuming",
|
|
52
|
+
"cancelling",
|
|
53
|
+
];
|
|
46
54
|
function normalizeSessionListText(content, limit) {
|
|
47
55
|
if (!content) {
|
|
48
56
|
return undefined;
|
|
@@ -324,8 +332,9 @@ export class AgentHarnessRuntime {
|
|
|
324
332
|
await initializeHarnessRuntime({
|
|
325
333
|
persistence: this.persistence,
|
|
326
334
|
healthMonitor: this.healthMonitor,
|
|
335
|
+
scheduleBackgroundTask: (task) => this.scheduleBackgroundStartupTask(task),
|
|
327
336
|
});
|
|
328
|
-
|
|
337
|
+
this.scheduleBackgroundStartupTask(traceStartupStage("runtime.initialize.startupRecovery", () => this.recoverStartupRuns()));
|
|
329
338
|
this.initialized = true;
|
|
330
339
|
}
|
|
331
340
|
subscribe(listener) {
|
|
@@ -340,8 +349,8 @@ export class AgentHarnessRuntime {
|
|
|
340
349
|
async getOperatorOverview(options) {
|
|
341
350
|
const [health, runs, approvals] = await Promise.all([
|
|
342
351
|
this.getHealth(),
|
|
343
|
-
this.listRuns(),
|
|
344
|
-
this.listApprovals(),
|
|
352
|
+
Promise.all(ACTIVE_RUN_STATES.map((state) => this.listRuns({ state }))).then((groups) => groups.flat()),
|
|
353
|
+
this.listApprovals({ status: "pending" }),
|
|
345
354
|
]);
|
|
346
355
|
return projectOperatorOverview({
|
|
347
356
|
health,
|
|
@@ -954,6 +963,9 @@ export class AgentHarnessRuntime {
|
|
|
954
963
|
this.backgroundTasks.delete(task);
|
|
955
964
|
});
|
|
956
965
|
}
|
|
966
|
+
scheduleBackgroundStartupTask(task) {
|
|
967
|
+
this.trackBackgroundTask(task.then(() => undefined).catch(() => undefined));
|
|
968
|
+
}
|
|
957
969
|
resolveToolMcpServerTools(agentId) {
|
|
958
970
|
return resolveWorkspaceAgentTools({
|
|
959
971
|
workspace: this.workspace,
|
|
@@ -267,8 +267,25 @@ export async function loadWorkspace(workspaceRoot, options = {}) {
|
|
|
267
267
|
...(localResourceRoot ? [localResourceRoot] : []),
|
|
268
268
|
...collectedResources,
|
|
269
269
|
]));
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
await traceStartupStage("workspace.validate.resources", async () => {
|
|
271
|
+
validateWorkspaceResources(embeddings, mcpServers, models, vectorStores, tools, loaded.agents);
|
|
272
|
+
}, {
|
|
273
|
+
workspaceRoot,
|
|
274
|
+
agentCount: loaded.agents.length,
|
|
275
|
+
toolCount: tools.size,
|
|
276
|
+
modelCount: models.size,
|
|
277
|
+
mcpServerCount: mcpServers.size,
|
|
278
|
+
});
|
|
279
|
+
await traceStartupStage("workspace.validate.routingTargets", async () => {
|
|
280
|
+
validateRoutingTargets(loaded.refs, loaded.agents);
|
|
281
|
+
}, {
|
|
282
|
+
workspaceRoot,
|
|
283
|
+
agentCount: loaded.agents.length,
|
|
284
|
+
});
|
|
285
|
+
const bindings = await traceStartupStage("workspace.compile.bindings", async () => compileBindings(workspaceRoot, loaded.refs, loaded.agents, models, tools), {
|
|
286
|
+
workspaceRoot,
|
|
287
|
+
agentCount: loaded.agents.length,
|
|
288
|
+
});
|
|
272
289
|
return {
|
|
273
290
|
workspaceRoot,
|
|
274
291
|
resources,
|
|
@@ -279,6 +296,6 @@ export async function loadWorkspace(workspaceRoot, options = {}) {
|
|
|
279
296
|
vectorStores,
|
|
280
297
|
tools,
|
|
281
298
|
agents: new Map(loaded.agents.map((agent) => [agent.id, agent])),
|
|
282
|
-
bindings
|
|
299
|
+
bindings,
|
|
283
300
|
};
|
|
284
301
|
}
|