@botbotgo/agent-harness 0.0.251 → 0.0.253
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/README.md +13 -14
- package/README.zh.md +11 -12
- package/dist/api.d.ts +13 -6
- package/dist/api.js +70 -6
- package/dist/config/agents/direct.yaml +3 -3
- package/dist/config/agents/orchestra.yaml +3 -3
- package/dist/config/catalogs/stores.yaml +3 -9
- package/dist/config/runtime/workspace.yaml +1 -2
- package/dist/contracts/runtime.d.ts +9 -14
- package/dist/flow/build-flow-graph.js +198 -67
- package/dist/flow/export-mermaid.js +314 -4
- package/dist/flow/export-sequence-mermaid.js +149 -2
- package/dist/flow/types.d.ts +11 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +3 -2
- package/dist/persistence/file-store.js +34 -8
- package/dist/persistence/sqlite-store.d.ts +2 -2
- package/dist/persistence/sqlite-store.js +64 -11
- package/dist/persistence/types.d.ts +3 -3
- package/dist/protocol/a2a/http.js +2 -4
- package/dist/resource/isolation.js +30 -2
- package/dist/runtime/harness/events/streaming.js +8 -8
- package/dist/runtime/harness/run/inspection.d.ts +2 -0
- package/dist/runtime/harness/run/inspection.js +91 -46
- package/dist/runtime/harness/run/stream-run.d.ts +2 -2
- package/dist/runtime/harness/run/stream-run.js +34 -23
- package/dist/runtime/harness/run/surface-semantics.d.ts +14 -0
- package/dist/runtime/harness/run/surface-semantics.js +106 -0
- package/dist/runtime/harness/run/thread-records.js +2 -34
- package/dist/runtime/harness/system/store.d.ts +6 -4
- package/dist/runtime/harness/system/store.js +76 -42
- package/dist/runtime/harness.js +5 -7
- package/dist/runtime/maintenance/checkpoint-maintenance.js +4 -119
- package/dist/runtime/maintenance/index.d.ts +0 -1
- package/dist/runtime/maintenance/index.js +0 -1
- package/dist/runtime/support/runtime-factories.js +2 -42
- package/dist/upstream-events.js +14 -0
- package/dist/utils/fs.js +3 -0
- package/package.json +1 -3
- package/dist/runtime/maintenance/sqlite-maintained-checkpoint-saver.d.ts +0 -9
- package/dist/runtime/maintenance/sqlite-maintained-checkpoint-saver.js +0 -39
- package/dist/runtime/support/sqlite-drivers.d.ts +0 -12
- package/dist/runtime/support/sqlite-drivers.js +0 -24
|
@@ -2,42 +2,6 @@ import path from "node:path";
|
|
|
2
2
|
import { MemorySaver } from "@langchain/langgraph";
|
|
3
3
|
import { FileCheckpointSaver } from "../maintenance/file-checkpoint-saver.js";
|
|
4
4
|
import { createInMemoryStore, FileBackedStore, SqliteBackedStore } from "../harness/system/store.js";
|
|
5
|
-
import { loadLanggraphSqliteCheckpointModule } from "./sqlite-drivers.js";
|
|
6
|
-
function createManagedSqliteSaver(SqliteSaver, db) {
|
|
7
|
-
class RuntimeManagedSqliteSaver extends SqliteSaver {
|
|
8
|
-
setup() {
|
|
9
|
-
super.setup();
|
|
10
|
-
this.db.exec(`
|
|
11
|
-
CREATE TABLE IF NOT EXISTS checkpoint_maintenance_meta (
|
|
12
|
-
thread_id TEXT NOT NULL,
|
|
13
|
-
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
14
|
-
checkpoint_id TEXT NOT NULL,
|
|
15
|
-
created_at_ms INTEGER NOT NULL,
|
|
16
|
-
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
|
|
17
|
-
);`);
|
|
18
|
-
}
|
|
19
|
-
async put(config, checkpoint, metadata) {
|
|
20
|
-
const result = await super.put(config, checkpoint, metadata);
|
|
21
|
-
const threadId = result.configurable?.thread_id;
|
|
22
|
-
const checkpointNs = result.configurable?.checkpoint_ns ?? "";
|
|
23
|
-
const checkpointId = result.configurable?.checkpoint_id;
|
|
24
|
-
if (!threadId || !checkpointId) {
|
|
25
|
-
throw new Error("Missing checkpoint identity after SqliteSaver.put");
|
|
26
|
-
}
|
|
27
|
-
this.db
|
|
28
|
-
.prepare(`INSERT OR IGNORE INTO checkpoint_maintenance_meta
|
|
29
|
-
(thread_id, checkpoint_ns, checkpoint_id, created_at_ms)
|
|
30
|
-
VALUES (?, ?, ?, ?)`)
|
|
31
|
-
.run(threadId, checkpointNs, checkpointId, Date.now());
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
async deleteThread(threadId) {
|
|
35
|
-
await super.deleteThread(threadId);
|
|
36
|
-
this.db.prepare(`DELETE FROM checkpoint_maintenance_meta WHERE thread_id = ?`).run(threadId);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return new RuntimeManagedSqliteSaver(db);
|
|
40
|
-
}
|
|
41
5
|
export function createStoreForConfig(storeConfig, runRoot) {
|
|
42
6
|
const kind = typeof storeConfig.kind === "string" ? storeConfig.kind : "FileStore";
|
|
43
7
|
switch (kind) {
|
|
@@ -67,12 +31,8 @@ export function createCheckpointerForConfig(checkpointerConfig, runRoot) {
|
|
|
67
31
|
switch (kind) {
|
|
68
32
|
case "MemorySaver":
|
|
69
33
|
return new MemorySaver();
|
|
70
|
-
case "SqliteSaver":
|
|
71
|
-
|
|
72
|
-
const resolvedPath = path.isAbsolute(configuredPath) ? configuredPath : path.join(runRoot, configuredPath);
|
|
73
|
-
const { SqliteSaver } = loadLanggraphSqliteCheckpointModule();
|
|
74
|
-
return createManagedSqliteSaver(SqliteSaver, SqliteSaver.fromConnString(resolvedPath).db);
|
|
75
|
-
}
|
|
34
|
+
case "SqliteSaver":
|
|
35
|
+
throw new Error("Checkpointer kind SqliteSaver is not supported in this runtime right now");
|
|
76
36
|
case "FileCheckpointer": {
|
|
77
37
|
const configuredPath = typeof checkpointerConfig.path === "string" ? String(checkpointerConfig.path) : "checkpoints.json";
|
|
78
38
|
return new FileCheckpointSaver(path.isAbsolute(configuredPath) ? configuredPath : path.join(runRoot, configuredPath));
|
package/dist/upstream-events.js
CHANGED
|
@@ -117,6 +117,20 @@ export function createUpstreamTimelineReducer() {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
if (context.eventName === "on_chat_model_end") {
|
|
121
|
+
const stepName = context.name || "model";
|
|
122
|
+
const key = createProjectionKey(["llm", "completed", stepName]);
|
|
123
|
+
if (!emittedStepKeys.has(key)) {
|
|
124
|
+
emittedStepKeys.add(key);
|
|
125
|
+
projections.push({
|
|
126
|
+
type: "step",
|
|
127
|
+
step: buildStepLabel("llm", "completed", stepName),
|
|
128
|
+
category: "llm",
|
|
129
|
+
status: "completed",
|
|
130
|
+
key,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
120
134
|
if (context.eventName === "on_tool_start"
|
|
121
135
|
|| (context.eventName === "on_chain_start" && context.runType === "tool")
|
|
122
136
|
|| context.eventName === "on_chain_start") {
|
package/dist/utils/fs.js
CHANGED
|
@@ -28,6 +28,9 @@ export async function listFilesRecursive(root, suffix) {
|
|
|
28
28
|
for (const item of items) {
|
|
29
29
|
const fullPath = path.join(root, item.name);
|
|
30
30
|
if (item.isDirectory()) {
|
|
31
|
+
if (item.name === "node_modules") {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
31
34
|
results.push(...(await listFilesRecursive(fullPath, suffix)));
|
|
32
35
|
continue;
|
|
33
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botbotgo/agent-harness",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.253",
|
|
4
4
|
"description": "Workspace runtime for multi-agent applications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,12 @@
|
|
|
46
46
|
"@langchain/core": "^1.1.33",
|
|
47
47
|
"@langchain/google": "^0.1.7",
|
|
48
48
|
"@langchain/langgraph": "^1.2.6",
|
|
49
|
-
"@langchain/langgraph-checkpoint-sqlite": "^1.0.1",
|
|
50
49
|
"@langchain/ollama": "^1.2.6",
|
|
51
50
|
"@langchain/openai": "^1.1.0",
|
|
52
51
|
"@libsql/client": "^0.17.0",
|
|
53
52
|
"@llamaindex/ollama": "^0.1.23",
|
|
54
53
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
55
54
|
"@qdrant/js-client-rest": "^1.17.0",
|
|
56
|
-
"better-sqlite3": "^12.8.0",
|
|
57
55
|
"deepagents": "^1.9.0",
|
|
58
56
|
"langchain": "^1.3.1",
|
|
59
57
|
"llamaindex": "^0.12.1",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SqliteSaver } from "@langchain/langgraph-checkpoint-sqlite";
|
|
2
|
-
import type { RunnableConfig } from "@langchain/core/runnables";
|
|
3
|
-
export declare class ManagedSqliteSaver extends SqliteSaver {
|
|
4
|
-
constructor(db: ConstructorParameters<typeof SqliteSaver>[0]);
|
|
5
|
-
prepareMaintenance(): void;
|
|
6
|
-
setup(): void;
|
|
7
|
-
put(config: RunnableConfig, checkpoint: Parameters<SqliteSaver["put"]>[1], metadata: Parameters<SqliteSaver["put"]>[2]): Promise<RunnableConfig<Record<string, any>>>;
|
|
8
|
-
deleteThread(threadId: string): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { SqliteSaver } from "@langchain/langgraph-checkpoint-sqlite";
|
|
2
|
-
export class ManagedSqliteSaver extends SqliteSaver {
|
|
3
|
-
constructor(db) {
|
|
4
|
-
super(db);
|
|
5
|
-
}
|
|
6
|
-
prepareMaintenance() {
|
|
7
|
-
this.setup();
|
|
8
|
-
}
|
|
9
|
-
setup() {
|
|
10
|
-
super.setup();
|
|
11
|
-
this.db.exec(`
|
|
12
|
-
CREATE TABLE IF NOT EXISTS checkpoint_maintenance_meta (
|
|
13
|
-
thread_id TEXT NOT NULL,
|
|
14
|
-
checkpoint_ns TEXT NOT NULL DEFAULT '',
|
|
15
|
-
checkpoint_id TEXT NOT NULL,
|
|
16
|
-
created_at_ms INTEGER NOT NULL,
|
|
17
|
-
PRIMARY KEY (thread_id, checkpoint_ns, checkpoint_id)
|
|
18
|
-
);`);
|
|
19
|
-
}
|
|
20
|
-
async put(config, checkpoint, metadata) {
|
|
21
|
-
const result = await super.put(config, checkpoint, metadata);
|
|
22
|
-
const threadId = result.configurable?.thread_id;
|
|
23
|
-
const checkpointNs = result.configurable?.checkpoint_ns ?? "";
|
|
24
|
-
const checkpointId = result.configurable?.checkpoint_id;
|
|
25
|
-
if (!threadId || !checkpointId) {
|
|
26
|
-
throw new Error("Missing checkpoint identity after SqliteSaver.put");
|
|
27
|
-
}
|
|
28
|
-
this.db
|
|
29
|
-
.prepare(`INSERT OR IGNORE INTO checkpoint_maintenance_meta
|
|
30
|
-
(thread_id, checkpoint_ns, checkpoint_id, created_at_ms)
|
|
31
|
-
VALUES (?, ?, ?, ?)`)
|
|
32
|
-
.run(threadId, checkpointNs, checkpointId, Date.now());
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
async deleteThread(threadId) {
|
|
36
|
-
await super.deleteThread(threadId);
|
|
37
|
-
this.db.prepare(`DELETE FROM checkpoint_maintenance_meta WHERE thread_id = ?`).run(threadId);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type BetterSqlite3Constructor = typeof import("better-sqlite3");
|
|
2
|
-
type SqliteCheckpointModule = typeof import("@langchain/langgraph-checkpoint-sqlite");
|
|
3
|
-
declare const defaultBetterSqlite3Loader: () => BetterSqlite3Constructor;
|
|
4
|
-
declare const defaultLanggraphSqliteCheckpointLoader: () => SqliteCheckpointModule;
|
|
5
|
-
export declare function loadBetterSqlite3(): BetterSqlite3Constructor;
|
|
6
|
-
export declare function loadLanggraphSqliteCheckpointModule(): SqliteCheckpointModule;
|
|
7
|
-
export declare function setSqliteModuleLoadersForTest(loaders: {
|
|
8
|
-
betterSqlite3?: typeof defaultBetterSqlite3Loader;
|
|
9
|
-
langgraphCheckpointSqlite?: typeof defaultLanggraphSqliteCheckpointLoader;
|
|
10
|
-
}): void;
|
|
11
|
-
export declare function resetSqliteModuleLoadersForTest(): void;
|
|
12
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
const require = createRequire(import.meta.url);
|
|
3
|
-
const defaultBetterSqlite3Loader = () => require("better-sqlite3");
|
|
4
|
-
const defaultLanggraphSqliteCheckpointLoader = () => require("@langchain/langgraph-checkpoint-sqlite");
|
|
5
|
-
let betterSqlite3Loader = defaultBetterSqlite3Loader;
|
|
6
|
-
let langgraphSqliteCheckpointLoader = defaultLanggraphSqliteCheckpointLoader;
|
|
7
|
-
export function loadBetterSqlite3() {
|
|
8
|
-
return betterSqlite3Loader();
|
|
9
|
-
}
|
|
10
|
-
export function loadLanggraphSqliteCheckpointModule() {
|
|
11
|
-
return langgraphSqliteCheckpointLoader();
|
|
12
|
-
}
|
|
13
|
-
export function setSqliteModuleLoadersForTest(loaders) {
|
|
14
|
-
if (loaders.betterSqlite3) {
|
|
15
|
-
betterSqlite3Loader = loaders.betterSqlite3;
|
|
16
|
-
}
|
|
17
|
-
if (loaders.langgraphCheckpointSqlite) {
|
|
18
|
-
langgraphSqliteCheckpointLoader = loaders.langgraphCheckpointSqlite;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function resetSqliteModuleLoadersForTest() {
|
|
22
|
-
betterSqlite3Loader = defaultBetterSqlite3Loader;
|
|
23
|
-
langgraphSqliteCheckpointLoader = defaultLanggraphSqliteCheckpointLoader;
|
|
24
|
-
}
|