@botbotgo/agent-harness 0.0.228 → 0.0.230
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/contracts/runtime.d.ts +32 -4
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +2 -0
- package/dist/persistence/file-store.js +10 -2
- package/dist/persistence/sqlite-store.d.ts +2 -0
- package/dist/persistence/sqlite-store.js +23 -9
- package/dist/persistence/types.d.ts +3 -0
- package/dist/protocol/a2a/http.js +6 -0
- package/dist/resource/resource-impl.js +59 -2
- package/dist/runtime/adapter/tool/builtin-middleware-tools.d.ts +54 -1
- package/dist/runtime/adapter/tool/builtin-middleware-tools.js +38 -8
- package/dist/runtime/adapter/tool/declared-middleware.js +2 -1
- package/dist/runtime/harness/run/stream-run.d.ts +2 -0
- package/dist/runtime/harness/run/stream-run.js +1 -0
- package/dist/runtime/harness/run/thread-records.d.ts +2 -1
- package/dist/runtime/harness/run/thread-records.js +66 -37
- package/dist/runtime/harness.js +15 -23
- package/dist/workspace/validate.js +3 -0
- package/package.json +1 -1
|
@@ -62,6 +62,26 @@ export type RuntimeTimelineProjectionOptions = {
|
|
|
62
62
|
threadId?: string;
|
|
63
63
|
runId?: string;
|
|
64
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Ordered upstream/runtime execution trace projected from persisted upstream events.
|
|
67
|
+
* This is an inspection surface for recovery/debugging, not a second execution protocol.
|
|
68
|
+
*/
|
|
69
|
+
export type RuntimeHistoryItem = {
|
|
70
|
+
type: "thinking";
|
|
71
|
+
text: string;
|
|
72
|
+
} | {
|
|
73
|
+
type: "step";
|
|
74
|
+
step: string;
|
|
75
|
+
category: "llm" | "tool" | "skill" | "memory" | "chain" | "approval";
|
|
76
|
+
status: "started" | "completed" | "failed";
|
|
77
|
+
key: string;
|
|
78
|
+
} | {
|
|
79
|
+
type: "tool-result";
|
|
80
|
+
toolName: string;
|
|
81
|
+
output: unknown;
|
|
82
|
+
isError?: boolean;
|
|
83
|
+
key: string;
|
|
84
|
+
};
|
|
65
85
|
export type RuntimeQueueDiagnostics = {
|
|
66
86
|
status: HealthStatus;
|
|
67
87
|
activeRunSlots: number;
|
|
@@ -462,7 +482,11 @@ export type RequestSummary = Omit<ThreadRunRecord, "threadId" | "runId"> & {
|
|
|
462
482
|
sessionId: string;
|
|
463
483
|
requestId: string;
|
|
464
484
|
};
|
|
465
|
-
export type RequestRecord = RequestSummary
|
|
485
|
+
export type RequestRecord = RequestSummary & {
|
|
486
|
+
history?: RuntimeHistoryItem[];
|
|
487
|
+
upstreamEvents?: unknown[];
|
|
488
|
+
runtimeTimeline?: RuntimeTimelineItem[];
|
|
489
|
+
};
|
|
466
490
|
/**
|
|
467
491
|
* Backward-compatible alias for older thread/run terminology.
|
|
468
492
|
*/
|
|
@@ -470,7 +494,11 @@ export type RunSummary = Omit<RequestSummary, "sessionId" | "requestId"> & {
|
|
|
470
494
|
threadId: string;
|
|
471
495
|
runId: string;
|
|
472
496
|
};
|
|
473
|
-
export type RunRecord = RunSummary
|
|
497
|
+
export type RunRecord = RunSummary & {
|
|
498
|
+
history?: RuntimeHistoryItem[];
|
|
499
|
+
upstreamEvents?: unknown[];
|
|
500
|
+
runtimeTimeline?: RuntimeTimelineItem[];
|
|
501
|
+
};
|
|
474
502
|
/**
|
|
475
503
|
* Persisted session inspection record assembled from runtime records.
|
|
476
504
|
* This is an inspectable projection, not a second session semantic model.
|
|
@@ -484,7 +512,7 @@ export type SessionRecord = {
|
|
|
484
512
|
createdAt: string;
|
|
485
513
|
updatedAt: string;
|
|
486
514
|
messages: TranscriptMessage[];
|
|
487
|
-
requests:
|
|
515
|
+
requests: RequestRecord[];
|
|
488
516
|
pendingDecision?: {
|
|
489
517
|
approvalId: string;
|
|
490
518
|
pendingActionId: string;
|
|
@@ -499,7 +527,7 @@ export type SessionRecord = {
|
|
|
499
527
|
export type ThreadRecord = Omit<SessionRecord, "sessionId" | "latestRequestId" | "requests"> & {
|
|
500
528
|
threadId: string;
|
|
501
529
|
latestRunId: string;
|
|
502
|
-
runs:
|
|
530
|
+
runs: RunRecord[];
|
|
503
531
|
};
|
|
504
532
|
export type ResumeOptions = {
|
|
505
533
|
threadId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.229";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.229";
|
|
@@ -60,6 +60,8 @@ export declare class FilePersistence implements RuntimePersistence {
|
|
|
60
60
|
currentAgentId?: string | null;
|
|
61
61
|
delegationChain?: string[];
|
|
62
62
|
runtimeSnapshot?: RunSummary["runtimeSnapshot"] | null;
|
|
63
|
+
upstreamEvents?: unknown[];
|
|
64
|
+
appendUpstreamEvent?: unknown;
|
|
63
65
|
}): Promise<void>;
|
|
64
66
|
deleteThread(threadId: string): Promise<boolean>;
|
|
65
67
|
saveRunRequest(threadId: string, runId: string, request: PersistedRunRequest): Promise<void>;
|
|
@@ -91,6 +91,7 @@ export class FilePersistence {
|
|
|
91
91
|
currentAgentId: input.currentAgentId ?? input.agentId,
|
|
92
92
|
delegationChain: input.delegationChain ?? [input.currentAgentId ?? input.agentId],
|
|
93
93
|
runtimeSnapshot: input.runtimeSnapshot ?? null,
|
|
94
|
+
upstreamEvents: [],
|
|
94
95
|
};
|
|
95
96
|
await Promise.all([
|
|
96
97
|
writeJson(path.join(runDir, "meta.json"), meta),
|
|
@@ -375,11 +376,17 @@ export class FilePersistence {
|
|
|
375
376
|
return readJson(path.join(this.runDir(threadId, runId), "lifecycle.json"));
|
|
376
377
|
}
|
|
377
378
|
async getRunInspection(threadId, runId) {
|
|
378
|
-
|
|
379
|
+
const inspection = await readJson(path.join(this.runDir(threadId, runId), "inspection.json"));
|
|
380
|
+
return {
|
|
381
|
+
...inspection,
|
|
382
|
+
upstreamEvents: Array.isArray(inspection.upstreamEvents) ? inspection.upstreamEvents : [],
|
|
383
|
+
};
|
|
379
384
|
}
|
|
380
385
|
async updateRunInspection(threadId, runId, patch) {
|
|
381
386
|
const inspectionPath = path.join(this.runDir(threadId, runId), "inspection.json");
|
|
382
|
-
const current = await
|
|
387
|
+
const current = await this.getRunInspection(threadId, runId);
|
|
388
|
+
const nextUpstreamEvents = patch.upstreamEvents
|
|
389
|
+
?? (patch.appendUpstreamEvent === undefined ? current.upstreamEvents : [...current.upstreamEvents, patch.appendUpstreamEvent]);
|
|
383
390
|
await writeJson(inspectionPath, {
|
|
384
391
|
...current,
|
|
385
392
|
...(patch.endedAt !== undefined ? { endedAt: patch.endedAt } : {}),
|
|
@@ -387,6 +394,7 @@ export class FilePersistence {
|
|
|
387
394
|
...(patch.currentAgentId !== undefined ? { currentAgentId: patch.currentAgentId } : {}),
|
|
388
395
|
...(patch.delegationChain ? { delegationChain: patch.delegationChain } : {}),
|
|
389
396
|
...(patch.runtimeSnapshot !== undefined ? { runtimeSnapshot: patch.runtimeSnapshot } : {}),
|
|
397
|
+
upstreamEvents: nextUpstreamEvents,
|
|
390
398
|
});
|
|
391
399
|
}
|
|
392
400
|
async deleteThread(threadId) {
|
|
@@ -81,6 +81,8 @@ export declare class SqlitePersistence implements RuntimePersistence {
|
|
|
81
81
|
currentAgentId?: string | null;
|
|
82
82
|
delegationChain?: string[];
|
|
83
83
|
runtimeSnapshot?: RunSummary["runtimeSnapshot"] | null;
|
|
84
|
+
upstreamEvents?: unknown[];
|
|
85
|
+
appendUpstreamEvent?: unknown;
|
|
84
86
|
}): Promise<void>;
|
|
85
87
|
deleteThread(threadId: string): Promise<boolean>;
|
|
86
88
|
saveRunRequest(threadId: string, runId: string, request: PersistedRunRequest): Promise<void>;
|
|
@@ -4,7 +4,7 @@ import { createClient } from "@libsql/client";
|
|
|
4
4
|
import { fileExists, readJson, writeJson } from "../utils/fs.js";
|
|
5
5
|
import { SqliteRunContextStore } from "./sqlite-run-context-store.js";
|
|
6
6
|
import { SqliteRunQueueStore } from "./sqlite-run-queue-store.js";
|
|
7
|
-
const RUNTIME_SQLITE_SCHEMA_VERSION =
|
|
7
|
+
const RUNTIME_SQLITE_SCHEMA_VERSION = 4;
|
|
8
8
|
const RUNTIME_SQLITE_SCHEMA_FAMILY = "agent-harness-runtime";
|
|
9
9
|
function asRow(value) {
|
|
10
10
|
return value;
|
|
@@ -191,6 +191,7 @@ export class SqlitePersistence {
|
|
|
191
191
|
current_agent_id TEXT,
|
|
192
192
|
delegation_chain_json TEXT NOT NULL,
|
|
193
193
|
runtime_snapshot_json TEXT,
|
|
194
|
+
upstream_events_json TEXT NOT NULL DEFAULT '[]',
|
|
194
195
|
FOREIGN KEY (thread_id) REFERENCES threads(thread_id),
|
|
195
196
|
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
196
197
|
)
|
|
@@ -461,19 +462,26 @@ export class SqlitePersistence {
|
|
|
461
462
|
current_agent_id TEXT,
|
|
462
463
|
delegation_chain_json TEXT NOT NULL,
|
|
463
464
|
runtime_snapshot_json TEXT,
|
|
465
|
+
upstream_events_json TEXT NOT NULL DEFAULT '[]',
|
|
464
466
|
FOREIGN KEY (thread_id) REFERENCES threads(thread_id),
|
|
465
467
|
FOREIGN KEY (run_id) REFERENCES runs(run_id)
|
|
466
468
|
)
|
|
467
469
|
`);
|
|
468
470
|
await this.rawExecute(`
|
|
469
471
|
INSERT OR IGNORE INTO run_inspection
|
|
470
|
-
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json)
|
|
471
|
-
SELECT run_id, thread_id, created_at, NULL, updated_at, agent_id, json_array(agent_id), NULL
|
|
472
|
+
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json, upstream_events_json)
|
|
473
|
+
SELECT run_id, thread_id, created_at, NULL, updated_at, agent_id, json_array(agent_id), NULL, '[]'
|
|
472
474
|
FROM runs
|
|
473
475
|
`);
|
|
474
476
|
await this.rawExecute("INSERT OR REPLACE INTO runtime_metadata (key, value) VALUES (?, ?)", ["schema_version", String(RUNTIME_SQLITE_SCHEMA_VERSION)]);
|
|
475
477
|
return;
|
|
476
478
|
}
|
|
479
|
+
if (version === "3") {
|
|
480
|
+
await this.rawExecute("ALTER TABLE run_inspection ADD COLUMN upstream_events_json TEXT NOT NULL DEFAULT '[]'");
|
|
481
|
+
await this.rawExecute("UPDATE run_inspection SET upstream_events_json = '[]' WHERE upstream_events_json IS NULL");
|
|
482
|
+
await this.rawExecute("INSERT OR REPLACE INTO runtime_metadata (key, value) VALUES (?, ?)", ["schema_version", String(RUNTIME_SQLITE_SCHEMA_VERSION)]);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
477
485
|
if (version !== String(RUNTIME_SQLITE_SCHEMA_VERSION)) {
|
|
478
486
|
throw new Error(`Unsupported runtime sqlite schema version ${JSON.stringify(version)} in ${this.dbPath}. Expected ${RUNTIME_SQLITE_SCHEMA_VERSION}.`);
|
|
479
487
|
}
|
|
@@ -522,8 +530,8 @@ export class SqlitePersistence {
|
|
|
522
530
|
args: [input.runId],
|
|
523
531
|
}, {
|
|
524
532
|
sql: `INSERT OR REPLACE INTO run_inspection
|
|
525
|
-
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json)
|
|
526
|
-
VALUES (?, ?, ?, NULL, ?, ?, ?, ?)`,
|
|
533
|
+
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json, upstream_events_json)
|
|
534
|
+
VALUES (?, ?, ?, NULL, ?, ?, ?, ?, ?)`,
|
|
527
535
|
args: [
|
|
528
536
|
input.runId,
|
|
529
537
|
input.threadId,
|
|
@@ -532,6 +540,7 @@ export class SqlitePersistence {
|
|
|
532
540
|
input.currentAgentId ?? input.agentId,
|
|
533
541
|
JSON.stringify(input.delegationChain ?? [input.currentAgentId ?? input.agentId]),
|
|
534
542
|
input.runtimeSnapshot ? JSON.stringify(input.runtimeSnapshot) : null,
|
|
543
|
+
"[]",
|
|
535
544
|
],
|
|
536
545
|
}, {
|
|
537
546
|
sql: `INSERT INTO thread_messages
|
|
@@ -575,8 +584,8 @@ export class SqlitePersistence {
|
|
|
575
584
|
(run_id, cancel_requested, cancel_reason, cancel_requested_at, heartbeat_at, worker_id, worker_started_at)
|
|
576
585
|
VALUES (?, 0, NULL, NULL, NULL, NULL, NULL)`, [input.runId]);
|
|
577
586
|
await this.execute(`INSERT OR REPLACE INTO run_inspection
|
|
578
|
-
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json)
|
|
579
|
-
VALUES (?, ?, ?, NULL, ?, ?, ?, ?)`, [
|
|
587
|
+
(run_id, thread_id, started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json, upstream_events_json)
|
|
588
|
+
VALUES (?, ?, ?, NULL, ?, ?, ?, ?, ?)`, [
|
|
580
589
|
input.runId,
|
|
581
590
|
input.threadId,
|
|
582
591
|
input.startedAt ?? input.createdAt,
|
|
@@ -584,6 +593,7 @@ export class SqlitePersistence {
|
|
|
584
593
|
input.currentAgentId ?? input.agentId,
|
|
585
594
|
JSON.stringify(input.delegationChain ?? [input.currentAgentId ?? input.agentId]),
|
|
586
595
|
input.runtimeSnapshot ? JSON.stringify(input.runtimeSnapshot) : null,
|
|
596
|
+
"[]",
|
|
587
597
|
]);
|
|
588
598
|
}
|
|
589
599
|
async setRunState(threadId, runId, state, checkpointRef) {
|
|
@@ -734,7 +744,7 @@ export class SqlitePersistence {
|
|
|
734
744
|
};
|
|
735
745
|
}
|
|
736
746
|
async getRunInspection(threadId, runId) {
|
|
737
|
-
const row = await this.selectOne(`SELECT started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json
|
|
747
|
+
const row = await this.selectOne(`SELECT started_at, ended_at, last_activity_at, current_agent_id, delegation_chain_json, runtime_snapshot_json, upstream_events_json
|
|
738
748
|
FROM run_inspection
|
|
739
749
|
WHERE thread_id = ? AND run_id = ?`, [threadId, runId]);
|
|
740
750
|
if (!row) {
|
|
@@ -747,18 +757,22 @@ export class SqlitePersistence {
|
|
|
747
757
|
currentAgentId: asNullableString(row.current_agent_id),
|
|
748
758
|
delegationChain: parseJson(row.delegation_chain_json),
|
|
749
759
|
runtimeSnapshot: row.runtime_snapshot_json ? parseJson(row.runtime_snapshot_json) : null,
|
|
760
|
+
upstreamEvents: row.upstream_events_json ? parseJson(row.upstream_events_json) : [],
|
|
750
761
|
};
|
|
751
762
|
}
|
|
752
763
|
async updateRunInspection(threadId, runId, patch) {
|
|
753
764
|
const current = await this.getRunInspection(threadId, runId);
|
|
765
|
+
const nextUpstreamEvents = patch.upstreamEvents
|
|
766
|
+
?? (patch.appendUpstreamEvent === undefined ? current.upstreamEvents : [...current.upstreamEvents, patch.appendUpstreamEvent]);
|
|
754
767
|
await this.execute(`UPDATE run_inspection
|
|
755
|
-
SET ended_at = ?, last_activity_at = ?, current_agent_id = ?, delegation_chain_json = ?, runtime_snapshot_json = ?
|
|
768
|
+
SET ended_at = ?, last_activity_at = ?, current_agent_id = ?, delegation_chain_json = ?, runtime_snapshot_json = ?, upstream_events_json = ?
|
|
756
769
|
WHERE run_id = ? AND thread_id = ?`, [
|
|
757
770
|
patch.endedAt === undefined ? current.endedAt : patch.endedAt,
|
|
758
771
|
patch.lastActivityAt ?? current.lastActivityAt,
|
|
759
772
|
patch.currentAgentId === undefined ? current.currentAgentId : patch.currentAgentId,
|
|
760
773
|
JSON.stringify(patch.delegationChain ?? current.delegationChain),
|
|
761
774
|
JSON.stringify(patch.runtimeSnapshot === undefined ? current.runtimeSnapshot : patch.runtimeSnapshot),
|
|
775
|
+
JSON.stringify(nextUpstreamEvents),
|
|
762
776
|
runId,
|
|
763
777
|
threadId,
|
|
764
778
|
]);
|
|
@@ -32,6 +32,7 @@ export type PersistedRunInspection = {
|
|
|
32
32
|
currentAgentId: string | null;
|
|
33
33
|
delegationChain: string[];
|
|
34
34
|
runtimeSnapshot: RuntimeSnapshot | null;
|
|
35
|
+
upstreamEvents: unknown[];
|
|
35
36
|
};
|
|
36
37
|
export type PersistedRunRequest = {
|
|
37
38
|
input: MessageContent;
|
|
@@ -139,6 +140,8 @@ export interface RuntimePersistence {
|
|
|
139
140
|
currentAgentId?: string | null;
|
|
140
141
|
delegationChain?: string[];
|
|
141
142
|
runtimeSnapshot?: RuntimeSnapshot | null;
|
|
143
|
+
upstreamEvents?: unknown[];
|
|
144
|
+
appendUpstreamEvent?: unknown;
|
|
142
145
|
}): Promise<void>;
|
|
143
146
|
deleteThread(threadId: string): Promise<boolean>;
|
|
144
147
|
saveRunRequest(threadId: string, runId: string, request: PersistedRunRequest): Promise<void>;
|
|
@@ -382,6 +382,9 @@ function toSessionRecord(session) {
|
|
|
382
382
|
currentAgentId: run.currentAgentId,
|
|
383
383
|
delegationChain: run.delegationChain,
|
|
384
384
|
runtimeSnapshot: run.runtimeSnapshot,
|
|
385
|
+
upstreamEvents: run.upstreamEvents,
|
|
386
|
+
history: run.history,
|
|
387
|
+
runtimeTimeline: run.runtimeTimeline,
|
|
385
388
|
})),
|
|
386
389
|
pendingDecision: session.pendingDecision,
|
|
387
390
|
};
|
|
@@ -407,6 +410,9 @@ function toRequestRecord(request) {
|
|
|
407
410
|
currentAgentId: request.currentAgentId,
|
|
408
411
|
delegationChain: request.delegationChain,
|
|
409
412
|
runtimeSnapshot: request.runtimeSnapshot,
|
|
413
|
+
upstreamEvents: request.upstreamEvents,
|
|
414
|
+
history: request.history,
|
|
415
|
+
runtimeTimeline: request.runtimeTimeline,
|
|
410
416
|
};
|
|
411
417
|
}
|
|
412
418
|
function buildTaskFromSessionAndRequest(session, request, approvals, output, failureMessage) {
|
|
@@ -5,7 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { stat } from "node:fs/promises";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
-
import { CompositeBackend, LocalShellBackend, StateBackend, StoreBackend } from "deepagents";
|
|
8
|
+
import { CompositeBackend, LangSmithSandbox, LocalShellBackend, StateBackend, StoreBackend } from "deepagents";
|
|
9
9
|
import { getBindingBackendConfig, getBindingExecutionView, getBindingPrimaryModel } from "../runtime/support/compiled-binding.js";
|
|
10
10
|
import { resolveCompiledEmbeddingModelRef } from "../runtime/support/embedding-models.js";
|
|
11
11
|
import { createRuntimeEnv } from "../runtime/support/runtime-env.js";
|
|
@@ -133,7 +133,60 @@ class CompatibleCompositeBackend {
|
|
|
133
133
|
return this.composite.downloadFiles(paths);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
function omitKind(config) {
|
|
137
|
+
const { kind: _kind, ...rest } = config ?? {};
|
|
138
|
+
return rest;
|
|
139
|
+
}
|
|
140
|
+
class LazyLangSmithSandbox {
|
|
141
|
+
config;
|
|
142
|
+
sandboxPromise = null;
|
|
143
|
+
constructor(config) {
|
|
144
|
+
this.config = config;
|
|
145
|
+
}
|
|
146
|
+
get id() {
|
|
147
|
+
return "langsmith-pending";
|
|
148
|
+
}
|
|
149
|
+
get isRunning() {
|
|
150
|
+
return this.sandboxPromise !== null;
|
|
151
|
+
}
|
|
152
|
+
getSandbox() {
|
|
153
|
+
if (!this.sandboxPromise) {
|
|
154
|
+
this.sandboxPromise = LangSmithSandbox.create(omitKind(this.config));
|
|
155
|
+
}
|
|
156
|
+
return this.sandboxPromise;
|
|
157
|
+
}
|
|
158
|
+
async read(filePath, offset, limit) {
|
|
159
|
+
return (await this.getSandbox()).read(filePath, offset, limit);
|
|
160
|
+
}
|
|
161
|
+
async edit(filePath, oldString, newString, replaceAll) {
|
|
162
|
+
return (await this.getSandbox()).edit(filePath, oldString, newString, replaceAll);
|
|
163
|
+
}
|
|
164
|
+
async ls(dirPath) {
|
|
165
|
+
return (await this.getSandbox()).ls(dirPath);
|
|
166
|
+
}
|
|
167
|
+
async glob(pattern, searchPath) {
|
|
168
|
+
return (await this.getSandbox()).glob(pattern, searchPath);
|
|
169
|
+
}
|
|
170
|
+
async write(filePath, content) {
|
|
171
|
+
return (await this.getSandbox()).write(filePath, content);
|
|
172
|
+
}
|
|
173
|
+
async execute(command) {
|
|
174
|
+
return (await this.getSandbox()).execute(command);
|
|
175
|
+
}
|
|
176
|
+
async uploadFiles(files) {
|
|
177
|
+
return (await this.getSandbox()).uploadFiles(files);
|
|
178
|
+
}
|
|
179
|
+
async downloadFiles(paths) {
|
|
180
|
+
return (await this.getSandbox()).downloadFiles(paths);
|
|
181
|
+
}
|
|
182
|
+
async close() {
|
|
183
|
+
if (!this.sandboxPromise) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
await (await this.sandboxPromise).close();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const INLINE_BACKEND_ERROR = 'Unsupported DeepAgent backend kind "%s". Supported inline kinds: LocalShellBackend, VfsSandbox, StateBackend, StoreBackend, CompositeBackend, LangSmithSandbox.';
|
|
137
190
|
function unsupportedInlineBackend(kind) {
|
|
138
191
|
throw new Error(INLINE_BACKEND_ERROR.replace("%s", kind));
|
|
139
192
|
}
|
|
@@ -172,6 +225,8 @@ function createInlineBackendInstance(workspaceRoot, kind, config, runtimeLike) {
|
|
|
172
225
|
return new StateBackend(runtimeLike);
|
|
173
226
|
case "StoreBackend":
|
|
174
227
|
return new StoreBackend(runtimeLike);
|
|
228
|
+
case "LangSmithSandbox":
|
|
229
|
+
return new LazyLangSmithSandbox(config);
|
|
175
230
|
default:
|
|
176
231
|
return unsupportedInlineBackend(kind);
|
|
177
232
|
}
|
|
@@ -193,6 +248,8 @@ function createInlineBackendResolver(workspace) {
|
|
|
193
248
|
return createInlineBackendInstance(workspace.workspaceRoot, "StateBackend", backendConfig, runtimeLike);
|
|
194
249
|
case "StoreBackend":
|
|
195
250
|
return createInlineBackendInstance(workspace.workspaceRoot, "StoreBackend", backendConfig, runtimeLike);
|
|
251
|
+
case "LangSmithSandbox":
|
|
252
|
+
return createInlineBackendInstance(workspace.workspaceRoot, "LangSmithSandbox", backendConfig, runtimeLike);
|
|
196
253
|
case "CompositeBackend": {
|
|
197
254
|
const stateConfig = typeof backendConfig.state === "object" && backendConfig.state
|
|
198
255
|
? backendConfig.state
|
|
@@ -8,7 +8,28 @@ export type BuiltinMiddlewareBackend = {
|
|
|
8
8
|
is_dir?: boolean;
|
|
9
9
|
size?: number;
|
|
10
10
|
}>;
|
|
11
|
-
|
|
11
|
+
ls?: (path: string) => Promise<{
|
|
12
|
+
files?: Array<{
|
|
13
|
+
path: string;
|
|
14
|
+
isDir?: boolean;
|
|
15
|
+
size?: number;
|
|
16
|
+
}>;
|
|
17
|
+
error?: string;
|
|
18
|
+
}> | {
|
|
19
|
+
files?: Array<{
|
|
20
|
+
path: string;
|
|
21
|
+
isDir?: boolean;
|
|
22
|
+
size?: number;
|
|
23
|
+
}>;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
read?: (filePath: string, offset?: number, limit?: number) => Promise<string | {
|
|
27
|
+
content?: string | Uint8Array;
|
|
28
|
+
error?: string;
|
|
29
|
+
}> | string | {
|
|
30
|
+
content?: string | Uint8Array;
|
|
31
|
+
error?: string;
|
|
32
|
+
};
|
|
12
33
|
write?: (filePath: string, content: string) => Promise<{
|
|
13
34
|
error?: string;
|
|
14
35
|
path?: string;
|
|
@@ -34,6 +55,17 @@ export type BuiltinMiddlewareBackend = {
|
|
|
34
55
|
}>> | Array<{
|
|
35
56
|
path: string;
|
|
36
57
|
}>;
|
|
58
|
+
glob?: (pattern: string, path?: string) => Promise<{
|
|
59
|
+
files?: Array<{
|
|
60
|
+
path: string;
|
|
61
|
+
}>;
|
|
62
|
+
error?: string;
|
|
63
|
+
}> | {
|
|
64
|
+
files?: Array<{
|
|
65
|
+
path: string;
|
|
66
|
+
}>;
|
|
67
|
+
error?: string;
|
|
68
|
+
};
|
|
37
69
|
grepRaw?: (pattern: string, path?: string | null, glob?: string | null) => Promise<Array<{
|
|
38
70
|
path: string;
|
|
39
71
|
line: number;
|
|
@@ -43,6 +75,27 @@ export type BuiltinMiddlewareBackend = {
|
|
|
43
75
|
line: number;
|
|
44
76
|
text: string;
|
|
45
77
|
}> | string;
|
|
78
|
+
grep?: (pattern: string, path?: string | null, glob?: string | null) => Promise<{
|
|
79
|
+
matches?: Array<{
|
|
80
|
+
path: string;
|
|
81
|
+
lineNumber?: number;
|
|
82
|
+
line_number?: number;
|
|
83
|
+
content?: string;
|
|
84
|
+
line?: number;
|
|
85
|
+
text?: string;
|
|
86
|
+
}>;
|
|
87
|
+
error?: string;
|
|
88
|
+
}> | {
|
|
89
|
+
matches?: Array<{
|
|
90
|
+
path: string;
|
|
91
|
+
lineNumber?: number;
|
|
92
|
+
line_number?: number;
|
|
93
|
+
content?: string;
|
|
94
|
+
line?: number;
|
|
95
|
+
text?: string;
|
|
96
|
+
}>;
|
|
97
|
+
error?: string;
|
|
98
|
+
};
|
|
46
99
|
execute?: (command: string) => Promise<{
|
|
47
100
|
output: string;
|
|
48
101
|
exitCode: number | null;
|
|
@@ -2,6 +2,15 @@ import { z } from "zod";
|
|
|
2
2
|
import { isSandboxBackend } from "deepagents";
|
|
3
3
|
import { isRecord } from "../../../utils/object.js";
|
|
4
4
|
import { summarizeBuiltinWriteTodosArgs, truncateLines } from "../runtime-adapter-support.js";
|
|
5
|
+
function toDisplayContent(content) {
|
|
6
|
+
if (typeof content === "string") {
|
|
7
|
+
return content;
|
|
8
|
+
}
|
|
9
|
+
if (content instanceof Uint8Array) {
|
|
10
|
+
return new TextDecoder().decode(content);
|
|
11
|
+
}
|
|
12
|
+
return "";
|
|
13
|
+
}
|
|
5
14
|
export async function createBuiltinMiddlewareTools(backend, options) {
|
|
6
15
|
const tools = new Map();
|
|
7
16
|
tools.set("write_todos", {
|
|
@@ -25,7 +34,14 @@ export async function createBuiltinMiddlewareTools(backend, options) {
|
|
|
25
34
|
schema: z.object({ path: z.string().optional().default("/") }).passthrough(),
|
|
26
35
|
invoke: async (input) => {
|
|
27
36
|
const targetPath = isRecord(input) && typeof input.path === "string" ? input.path : "/";
|
|
28
|
-
const
|
|
37
|
+
const legacyInfos = (await Promise.resolve(backend.lsInfo?.(targetPath))) ?? [];
|
|
38
|
+
const infos = legacyInfos.length > 0
|
|
39
|
+
? legacyInfos
|
|
40
|
+
: ((await Promise.resolve(backend.ls?.(targetPath)))?.files ?? []).map((info) => ({
|
|
41
|
+
path: info.path,
|
|
42
|
+
is_dir: info.isDir,
|
|
43
|
+
size: info.size,
|
|
44
|
+
}));
|
|
29
45
|
if (infos.length === 0) {
|
|
30
46
|
return `No files found in ${targetPath}`;
|
|
31
47
|
}
|
|
@@ -44,7 +60,11 @@ export async function createBuiltinMiddlewareTools(backend, options) {
|
|
|
44
60
|
const filePath = typeof typed.file_path === "string" ? typed.file_path : "";
|
|
45
61
|
const offset = typeof typed.offset === "number" ? typed.offset : 0;
|
|
46
62
|
const limit = typeof typed.limit === "number" ? typed.limit : 500;
|
|
47
|
-
|
|
63
|
+
const result = await Promise.resolve(backend.read?.(filePath, offset, limit));
|
|
64
|
+
if (typeof result === "string") {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
return toDisplayContent(result?.content);
|
|
48
68
|
},
|
|
49
69
|
});
|
|
50
70
|
tools.set("write_file", {
|
|
@@ -77,7 +97,10 @@ export async function createBuiltinMiddlewareTools(backend, options) {
|
|
|
77
97
|
const typed = isRecord(input) ? input : {};
|
|
78
98
|
const pattern = typeof typed.pattern === "string" ? typed.pattern : "";
|
|
79
99
|
const targetPath = typeof typed.path === "string" ? typed.path : "/";
|
|
80
|
-
const
|
|
100
|
+
const legacyInfos = (await Promise.resolve(backend.globInfo?.(pattern, targetPath))) ?? [];
|
|
101
|
+
const infos = legacyInfos.length > 0
|
|
102
|
+
? legacyInfos
|
|
103
|
+
: ((await Promise.resolve(backend.glob?.(pattern, targetPath)))?.files ?? []);
|
|
81
104
|
if (infos.length === 0) {
|
|
82
105
|
return `No files found matching pattern '${pattern}'`;
|
|
83
106
|
}
|
|
@@ -93,16 +116,23 @@ export async function createBuiltinMiddlewareTools(backend, options) {
|
|
|
93
116
|
}).passthrough(),
|
|
94
117
|
invoke: async (input) => {
|
|
95
118
|
const typed = isRecord(input) ? input : {};
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
119
|
+
const legacyResult = await Promise.resolve(backend.grepRaw?.(typeof typed.pattern === "string" ? typed.pattern : "", typeof typed.path === "string" ? typed.path : "/", typeof typed.glob === "string" ? typed.glob : null));
|
|
120
|
+
const structuredResult = await Promise.resolve(backend.grep?.(typeof typed.pattern === "string" ? typed.pattern : "", typeof typed.path === "string" ? typed.path : "/", typeof typed.glob === "string" ? typed.glob : null));
|
|
121
|
+
const normalizedStructuredMatches = structuredResult?.matches?.map((match) => ({
|
|
122
|
+
path: match.path,
|
|
123
|
+
line: match.lineNumber ?? match.line_number ?? match.line ?? 0,
|
|
124
|
+
text: match.content ?? match.text ?? "",
|
|
125
|
+
}));
|
|
126
|
+
const normalizedResult = legacyResult ?? normalizedStructuredMatches;
|
|
127
|
+
if (typeof normalizedResult === "string") {
|
|
128
|
+
return normalizedResult;
|
|
99
129
|
}
|
|
100
|
-
if (!
|
|
130
|
+
if (!normalizedResult || normalizedResult.length === 0) {
|
|
101
131
|
return `No matches found for pattern '${typeof typed.pattern === "string" ? typed.pattern : ""}'`;
|
|
102
132
|
}
|
|
103
133
|
const lines = [];
|
|
104
134
|
let currentFile = "";
|
|
105
|
-
for (const match of
|
|
135
|
+
for (const match of normalizedResult) {
|
|
106
136
|
if (match.path !== currentFile) {
|
|
107
137
|
currentFile = match.path;
|
|
108
138
|
lines.push(`\n${currentFile}:`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { anthropicPromptCachingMiddleware, contextEditingMiddleware, dynamicSystemPromptMiddleware, humanInTheLoopMiddleware, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, modelRetryMiddleware, openAIModerationMiddleware, piiMiddleware, piiRedactionMiddleware, summarizationMiddleware, todoListMiddleware, toolCallLimitMiddleware, toolEmulatorMiddleware, toolRetryMiddleware, } from "langchain";
|
|
2
|
-
import { createFilesystemMiddleware, createPatchToolCallsMiddleware, createSummarizationMiddleware as createDeepAgentSummarizationMiddleware, } from "deepagents";
|
|
2
|
+
import { createCompletionCallbackMiddleware, createFilesystemMiddleware, createPatchToolCallsMiddleware, createSummarizationMiddleware as createDeepAgentSummarizationMiddleware, } from "deepagents";
|
|
3
3
|
function asMiddlewareConfig(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? { ...value } : null;
|
|
5
5
|
}
|
|
@@ -84,6 +84,7 @@ async function createFilesystemDeclarativeMiddleware({ config, resolveFilesystem
|
|
|
84
84
|
return createFilesystemMiddleware(runtimeConfig);
|
|
85
85
|
}
|
|
86
86
|
export const DECLARATIVE_MIDDLEWARE_REGISTRY = {
|
|
87
|
+
completionCallback: async ({ config }) => createCompletionCallbackMiddleware(config),
|
|
87
88
|
filesystem: createFilesystemDeclarativeMiddleware,
|
|
88
89
|
patchToolCalls: async () => createPatchToolCallsMiddleware(),
|
|
89
90
|
summarization: createBindingAwareSummarizationMiddleware,
|
|
@@ -53,6 +53,8 @@ type StreamRunOptions = {
|
|
|
53
53
|
currentAgentId?: string | null;
|
|
54
54
|
delegationChain?: string[];
|
|
55
55
|
runtimeSnapshot?: RuntimeSnapshot | null;
|
|
56
|
+
upstreamEvents?: unknown[];
|
|
57
|
+
appendUpstreamEvent?: unknown;
|
|
56
58
|
}) => Promise<void>;
|
|
57
59
|
emitSyntheticFallback: (threadId: string, runId: string, selectedAgentId: string, error: unknown) => Promise<void>;
|
|
58
60
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ApprovalRecord, SessionRecord, SessionSummary, ThreadRecord, ThreadSummary } from "../../../contracts/types.js";
|
|
1
|
+
import type { ApprovalRecord, RequestRecord, SessionRecord, SessionSummary, RunSummary, ThreadRecord, ThreadSummary } from "../../../contracts/types.js";
|
|
2
2
|
import type { RuntimePersistence } from "../../../persistence/types.js";
|
|
3
|
+
export declare function buildRequestInspectionRecord(persistence: RuntimePersistence, request: RunSummary): Promise<RequestRecord>;
|
|
3
4
|
export declare function buildSessionInspectionRecord(input: {
|
|
4
5
|
persistence: RuntimePersistence;
|
|
5
6
|
getSession: (sessionId: string) => Promise<SessionSummary | null>;
|
|
@@ -1,11 +1,73 @@
|
|
|
1
1
|
import { isTerminalRunState, toInspectableApprovalRecord } from "./helpers.js";
|
|
2
|
+
import { projectRuntimeTimeline } from "../events/timeline.js";
|
|
3
|
+
import { createUpstreamTimelineReducer } from "../../../upstream-events.js";
|
|
2
4
|
function selectLatestPendingApproval(approvals) {
|
|
3
5
|
return approvals
|
|
4
6
|
.filter((approval) => approval.status === "pending")
|
|
5
7
|
.sort((left, right) => right.requestedAt.localeCompare(left.requestedAt))[0];
|
|
6
8
|
}
|
|
9
|
+
function buildRunInspectionProjection(upstreamEvents) {
|
|
10
|
+
const reducer = createUpstreamTimelineReducer();
|
|
11
|
+
const history = upstreamEvents.flatMap((event) => reducer.consume(event));
|
|
12
|
+
return {
|
|
13
|
+
upstreamEvents,
|
|
14
|
+
history,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export async function buildRequestInspectionRecord(persistence, request) {
|
|
18
|
+
const inspection = await persistence.getRunInspection(request.threadId, request.runId);
|
|
19
|
+
const runtimeEvents = await persistence.listRunEvents(request.threadId, request.runId);
|
|
20
|
+
const { upstreamEvents, history } = buildRunInspectionProjection(inspection.upstreamEvents);
|
|
21
|
+
return {
|
|
22
|
+
requestId: request.runId,
|
|
23
|
+
sessionId: request.threadId,
|
|
24
|
+
agentId: request.agentId,
|
|
25
|
+
executionMode: request.executionMode,
|
|
26
|
+
adapterKind: request.adapterKind,
|
|
27
|
+
createdAt: request.createdAt,
|
|
28
|
+
updatedAt: request.updatedAt,
|
|
29
|
+
state: request.state,
|
|
30
|
+
checkpointRef: request.checkpointRef,
|
|
31
|
+
resumable: request.resumable,
|
|
32
|
+
startedAt: request.startedAt,
|
|
33
|
+
endedAt: request.endedAt,
|
|
34
|
+
lastActivityAt: request.lastActivityAt,
|
|
35
|
+
currentAgentId: request.currentAgentId,
|
|
36
|
+
delegationChain: request.delegationChain,
|
|
37
|
+
runtimeSnapshot: request.runtimeSnapshot,
|
|
38
|
+
upstreamEvents,
|
|
39
|
+
history,
|
|
40
|
+
runtimeTimeline: projectRuntimeTimeline(runtimeEvents, {
|
|
41
|
+
threadId: request.threadId,
|
|
42
|
+
runId: request.runId,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function toRunRecord(request) {
|
|
47
|
+
return {
|
|
48
|
+
runId: request.requestId,
|
|
49
|
+
threadId: request.sessionId,
|
|
50
|
+
agentId: request.agentId,
|
|
51
|
+
executionMode: request.executionMode,
|
|
52
|
+
adapterKind: request.adapterKind,
|
|
53
|
+
createdAt: request.createdAt,
|
|
54
|
+
updatedAt: request.updatedAt,
|
|
55
|
+
state: request.state,
|
|
56
|
+
checkpointRef: request.checkpointRef,
|
|
57
|
+
resumable: request.resumable,
|
|
58
|
+
startedAt: request.startedAt,
|
|
59
|
+
endedAt: request.endedAt,
|
|
60
|
+
lastActivityAt: request.lastActivityAt,
|
|
61
|
+
currentAgentId: request.currentAgentId,
|
|
62
|
+
delegationChain: request.delegationChain,
|
|
63
|
+
runtimeSnapshot: request.runtimeSnapshot,
|
|
64
|
+
upstreamEvents: request.upstreamEvents,
|
|
65
|
+
history: request.history,
|
|
66
|
+
runtimeTimeline: request.runtimeTimeline,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
7
69
|
export async function buildSessionInspectionRecord(input, sessionId) {
|
|
8
|
-
const [sessionSummary, meta, messages,
|
|
70
|
+
const [sessionSummary, meta, messages, requestSummaries] = await Promise.all([
|
|
9
71
|
input.getSession(sessionId),
|
|
10
72
|
input.persistence.getThreadMeta(sessionId),
|
|
11
73
|
input.persistence.listThreadMessages(sessionId, 200),
|
|
@@ -15,6 +77,7 @@ export async function buildSessionInspectionRecord(input, sessionId) {
|
|
|
15
77
|
return null;
|
|
16
78
|
}
|
|
17
79
|
const latestRequestId = sessionSummary.latestRequestId;
|
|
80
|
+
const requests = await Promise.all(requestSummaries.map((request) => buildRequestInspectionRecord(input.persistence, request)));
|
|
18
81
|
const latestApprovals = await input.persistence.getRunApprovals(sessionId, latestRequestId);
|
|
19
82
|
const pendingApproval = selectLatestPendingApproval(latestApprovals);
|
|
20
83
|
return {
|
|
@@ -26,24 +89,7 @@ export async function buildSessionInspectionRecord(input, sessionId) {
|
|
|
26
89
|
createdAt: meta.createdAt,
|
|
27
90
|
updatedAt: sessionSummary.updatedAt,
|
|
28
91
|
messages,
|
|
29
|
-
requests
|
|
30
|
-
requestId: request.runId,
|
|
31
|
-
sessionId: request.threadId,
|
|
32
|
-
agentId: request.agentId,
|
|
33
|
-
executionMode: request.executionMode,
|
|
34
|
-
adapterKind: request.adapterKind,
|
|
35
|
-
createdAt: request.createdAt,
|
|
36
|
-
updatedAt: request.updatedAt,
|
|
37
|
-
state: request.state,
|
|
38
|
-
checkpointRef: request.checkpointRef,
|
|
39
|
-
resumable: request.resumable,
|
|
40
|
-
startedAt: request.startedAt,
|
|
41
|
-
endedAt: request.endedAt,
|
|
42
|
-
lastActivityAt: request.lastActivityAt,
|
|
43
|
-
currentAgentId: request.currentAgentId,
|
|
44
|
-
delegationChain: request.delegationChain,
|
|
45
|
-
runtimeSnapshot: request.runtimeSnapshot,
|
|
46
|
-
})),
|
|
92
|
+
requests,
|
|
47
93
|
pendingDecision: pendingApproval
|
|
48
94
|
? {
|
|
49
95
|
approvalId: pendingApproval.approvalId,
|
|
@@ -83,24 +129,7 @@ export async function buildThreadInspectionRecord(input, threadId) {
|
|
|
83
129
|
createdAt: session.createdAt,
|
|
84
130
|
updatedAt: session.updatedAt,
|
|
85
131
|
messages: session.messages,
|
|
86
|
-
runs: session.requests.map((request) => (
|
|
87
|
-
runId: request.requestId,
|
|
88
|
-
threadId: request.sessionId,
|
|
89
|
-
agentId: request.agentId,
|
|
90
|
-
executionMode: request.executionMode,
|
|
91
|
-
adapterKind: request.adapterKind,
|
|
92
|
-
createdAt: request.createdAt,
|
|
93
|
-
updatedAt: request.updatedAt,
|
|
94
|
-
state: request.state,
|
|
95
|
-
checkpointRef: request.checkpointRef,
|
|
96
|
-
resumable: request.resumable,
|
|
97
|
-
startedAt: request.startedAt,
|
|
98
|
-
endedAt: request.endedAt,
|
|
99
|
-
lastActivityAt: request.lastActivityAt,
|
|
100
|
-
currentAgentId: request.currentAgentId,
|
|
101
|
-
delegationChain: request.delegationChain,
|
|
102
|
-
runtimeSnapshot: request.runtimeSnapshot,
|
|
103
|
-
})),
|
|
132
|
+
runs: session.requests.map((request) => toRunRecord(request)),
|
|
104
133
|
pendingDecision: session.pendingDecision,
|
|
105
134
|
}
|
|
106
135
|
: null;
|
package/dist/runtime/harness.js
CHANGED
|
@@ -39,7 +39,7 @@ import { resolveRuntimeAdapterOptions } from "./support/runtime-adapter-options.
|
|
|
39
39
|
import { initializeHarnessRuntime, reclaimExpiredClaimedRuns as reclaimHarnessExpiredClaimedRuns, recoverStartupRuns as recoverHarnessStartupRuns, isStaleRunningRun as isHarnessStaleRunningRun, } from "./harness/run/startup-runtime.js";
|
|
40
40
|
import { streamHarnessRun } from "./harness/run/stream-run.js";
|
|
41
41
|
import { defaultRequestedAgentId, prepareRunStart } from "./harness/run/start-run.js";
|
|
42
|
-
import { buildSessionInspectionRecord, deleteSessionRecord, deleteThreadRecord, getPublicApproval, listPublicApprovals, } from "./harness/run/thread-records.js";
|
|
42
|
+
import { buildRequestInspectionRecord, buildSessionInspectionRecord, deleteSessionRecord, deleteThreadRecord, getPublicApproval, listPublicApprovals, } from "./harness/run/thread-records.js";
|
|
43
43
|
export class AgentHarnessRuntime {
|
|
44
44
|
workspace;
|
|
45
45
|
runtimeAdapterOptions;
|
|
@@ -541,26 +541,7 @@ export class AgentHarnessRuntime {
|
|
|
541
541
|
}
|
|
542
542
|
async getRequest(requestId) {
|
|
543
543
|
const request = await this.persistence.getRun(requestId);
|
|
544
|
-
return request
|
|
545
|
-
? {
|
|
546
|
-
requestId: request.runId,
|
|
547
|
-
sessionId: request.threadId,
|
|
548
|
-
agentId: request.agentId,
|
|
549
|
-
executionMode: request.executionMode,
|
|
550
|
-
adapterKind: request.adapterKind,
|
|
551
|
-
createdAt: request.createdAt,
|
|
552
|
-
updatedAt: request.updatedAt,
|
|
553
|
-
state: request.state,
|
|
554
|
-
checkpointRef: request.checkpointRef,
|
|
555
|
-
resumable: request.resumable,
|
|
556
|
-
startedAt: request.startedAt,
|
|
557
|
-
endedAt: request.endedAt,
|
|
558
|
-
lastActivityAt: request.lastActivityAt,
|
|
559
|
-
currentAgentId: request.currentAgentId,
|
|
560
|
-
delegationChain: request.delegationChain,
|
|
561
|
-
runtimeSnapshot: request.runtimeSnapshot,
|
|
562
|
-
}
|
|
563
|
-
: null;
|
|
544
|
+
return request ? buildRequestInspectionRecord(this.persistence, request) : null;
|
|
564
545
|
}
|
|
565
546
|
async getRun(runId) {
|
|
566
547
|
const request = await this.getRequest(runId);
|
|
@@ -582,6 +563,9 @@ export class AgentHarnessRuntime {
|
|
|
582
563
|
currentAgentId: request.currentAgentId,
|
|
583
564
|
delegationChain: request.delegationChain,
|
|
584
565
|
runtimeSnapshot: request.runtimeSnapshot,
|
|
566
|
+
upstreamEvents: request.upstreamEvents,
|
|
567
|
+
history: request.history,
|
|
568
|
+
runtimeTimeline: request.runtimeTimeline,
|
|
585
569
|
}
|
|
586
570
|
: null;
|
|
587
571
|
}
|
|
@@ -648,6 +632,9 @@ export class AgentHarnessRuntime {
|
|
|
648
632
|
currentAgentId: request.currentAgentId,
|
|
649
633
|
delegationChain: request.delegationChain,
|
|
650
634
|
runtimeSnapshot: request.runtimeSnapshot,
|
|
635
|
+
upstreamEvents: request.upstreamEvents,
|
|
636
|
+
history: request.history,
|
|
637
|
+
runtimeTimeline: request.runtimeTimeline,
|
|
651
638
|
})),
|
|
652
639
|
pendingDecision: session.pendingDecision,
|
|
653
640
|
}
|
|
@@ -1760,12 +1747,17 @@ function toSessionRecord(record) {
|
|
|
1760
1747
|
createdAt: record.createdAt,
|
|
1761
1748
|
updatedAt: record.updatedAt,
|
|
1762
1749
|
messages: record.messages,
|
|
1763
|
-
requests: record.runs.map(
|
|
1750
|
+
requests: record.runs.map(toRequestRecord),
|
|
1764
1751
|
pendingDecision: record.pendingDecision,
|
|
1765
1752
|
};
|
|
1766
1753
|
}
|
|
1767
1754
|
function toRequestRecord(record) {
|
|
1768
|
-
return
|
|
1755
|
+
return {
|
|
1756
|
+
...toRequestSummary(record),
|
|
1757
|
+
upstreamEvents: record.upstreamEvents,
|
|
1758
|
+
history: record.history,
|
|
1759
|
+
runtimeTimeline: record.runtimeTimeline,
|
|
1760
|
+
};
|
|
1769
1761
|
}
|
|
1770
1762
|
function deriveRunRequestFromTranscript(transcript, runId) {
|
|
1771
1763
|
const candidate = [...transcript]
|
|
@@ -39,6 +39,9 @@ function validateMiddlewareConfig(agent) {
|
|
|
39
39
|
if (kind === "humanInTheLoop" && typeof typed.interruptOn !== "object") {
|
|
40
40
|
throw new Error(`Agent ${agent.id} humanInTheLoop middleware requires interruptOn`);
|
|
41
41
|
}
|
|
42
|
+
if (kind === "completionCallback" && typeof typed.callbackGraphId !== "string") {
|
|
43
|
+
throw new Error(`Agent ${agent.id} completionCallback middleware requires callbackGraphId`);
|
|
44
|
+
}
|
|
42
45
|
if (kind === "filesystem" && agent.executionMode === "deepagent") {
|
|
43
46
|
throw new Error(`Agent ${agent.id} cannot use filesystem middleware with DeepAgents; configure filesystem behavior through the deepagent backend instead`);
|
|
44
47
|
}
|