agentledger-runtime 1.0.5 → 1.2.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/README.md +1 -1
- package/package.json +33 -2
- package/src/adapters/langgraph.d.ts +19 -0
- package/src/adapters/langgraph.js +77 -0
- package/src/adapters/mcp.d.ts +3 -0
- package/src/adapters/mcp.js +9 -0
- package/src/adapters/otel.d.ts +3 -0
- package/src/adapters/otel.js +9 -0
- package/src/adapters/postgres.d.ts +3 -0
- package/src/adapters/postgres.js +9 -0
- package/src/adapters/s3.d.ts +3 -0
- package/src/adapters/s3.js +9 -0
- package/src/adapters/sandbox-docker.d.ts +3 -0
- package/src/adapters/sandbox-docker.js +9 -0
- package/src/cli.js +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AgentLedger Node / TypeScript Runtime
|
|
2
2
|
|
|
3
|
-
This directory contains the dependency-free Node/TypeScript-compatible runtime-core baseline for AgentLedger 1.0.
|
|
3
|
+
This directory contains the dependency-free Node/TypeScript-compatible runtime-core baseline for AgentLedger 1.2.0.
|
|
4
4
|
|
|
5
5
|
It runs a native local runtime loop, participates in the shared Python/Go/TypeScript/Rust conformance gate, and should be treated as runtime-core aligned; concrete production adapters are shipped separately as they mature.
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,14 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentledger-runtime",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Dependency-free Node/TypeScript-compatible runtime for AgentLedger.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"types": "src/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.d.ts",
|
|
12
|
+
"import": "./src/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./postgres": {
|
|
15
|
+
"types": "./src/adapters/postgres.d.ts",
|
|
16
|
+
"import": "./src/adapters/postgres.js"
|
|
17
|
+
},
|
|
18
|
+
"./s3": {
|
|
19
|
+
"types": "./src/adapters/s3.d.ts",
|
|
20
|
+
"import": "./src/adapters/s3.js"
|
|
21
|
+
},
|
|
22
|
+
"./mcp": {
|
|
23
|
+
"types": "./src/adapters/mcp.d.ts",
|
|
24
|
+
"import": "./src/adapters/mcp.js"
|
|
25
|
+
},
|
|
26
|
+
"./otel": {
|
|
27
|
+
"types": "./src/adapters/otel.d.ts",
|
|
28
|
+
"import": "./src/adapters/otel.js"
|
|
29
|
+
},
|
|
30
|
+
"./sandbox/docker": {
|
|
31
|
+
"types": "./src/adapters/sandbox-docker.d.ts",
|
|
32
|
+
"import": "./src/adapters/sandbox-docker.js"
|
|
33
|
+
},
|
|
34
|
+
"./langgraph": {
|
|
35
|
+
"types": "./src/adapters/langgraph.d.ts",
|
|
36
|
+
"import": "./src/adapters/langgraph.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
9
39
|
"scripts": {
|
|
10
40
|
"test": "node --test",
|
|
11
|
-
"check": "node --check src/index.js && node --check test/runtime.test.js",
|
|
41
|
+
"check": "node --check src/index.js && node --check src/adapters/*.js && node --check test/runtime.test.js",
|
|
12
42
|
"conformance": "node src/cli.js conformance",
|
|
13
43
|
"contract:validate": "node src/cli.js contract validate"
|
|
14
44
|
},
|
|
@@ -20,6 +50,7 @@
|
|
|
20
50
|
},
|
|
21
51
|
"files": [
|
|
22
52
|
"src/",
|
|
53
|
+
"src/adapters/",
|
|
23
54
|
"examples/README.md",
|
|
24
55
|
"examples/quickstart/",
|
|
25
56
|
"README.md"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class LangGraphCheckpointerAdapter {
|
|
2
|
+
constructor(runtime: any);
|
|
3
|
+
name: string;
|
|
4
|
+
configForRun(runId: string, options?: { threadId?: string | null; checkpointNs?: string }): any;
|
|
5
|
+
checkpointFromRun(runId: string): any;
|
|
6
|
+
put(config: any, checkpoint: any, metadata?: any, newVersions?: any): any;
|
|
7
|
+
get(config: any): any;
|
|
8
|
+
getTuple(config: any): any;
|
|
9
|
+
list(config?: any): any[];
|
|
10
|
+
}
|
|
11
|
+
export class LangGraphNodeAdapter {
|
|
12
|
+
constructor(node: any, options?: { role?: string });
|
|
13
|
+
name: string;
|
|
14
|
+
role: string;
|
|
15
|
+
mapRunSpec(): any;
|
|
16
|
+
asAgent(options?: { outputKey?: string }): any;
|
|
17
|
+
}
|
|
18
|
+
export const adapterPackage: { name: string; runtimePackage: string; version: string; category: string };
|
|
19
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
export class LangGraphCheckpointerAdapter {
|
|
4
|
+
constructor(runtime) {
|
|
5
|
+
this.runtime = runtime;
|
|
6
|
+
this.name = 'langgraph-checkpointer';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
configForRun(runId, { threadId = null, checkpointNs = '' } = {}) {
|
|
10
|
+
return { configurable: { agentledger_run_id: runId, thread_id: threadId ?? runId, checkpoint_ns: checkpointNs } };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
checkpointFromRun(runId) {
|
|
14
|
+
const loaded = this.runtime.store.loadState(runId);
|
|
15
|
+
return { run_id: runId, session_id: loaded.sessionId, state_version: loaded.version, state: loaded.state };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
put(config, checkpoint, metadata = {}, newVersions = {}) {
|
|
19
|
+
const checkpointId = String(checkpoint.id ?? checkpoint.checkpoint_id ?? newCheckpointId());
|
|
20
|
+
const nextConfig = this.withCheckpointId(config, checkpointId);
|
|
21
|
+
return { config: nextConfig, checkpoint: { ...checkpoint, id: checkpointId }, metadata, new_versions: newVersions };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get(config) {
|
|
25
|
+
const runId = this.runIdFromConfig(config);
|
|
26
|
+
return this.checkpointFromRun(runId);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getTuple(config) {
|
|
30
|
+
return { config, checkpoint: this.get(config), metadata: {}, parent_config: null, pending_writes: [] };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
list(config = null) {
|
|
34
|
+
return config ? [this.getTuple(config)] : [];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
runIdFromConfig(config) {
|
|
38
|
+
const configurable = config?.configurable ?? {};
|
|
39
|
+
const runId = configurable.agentledger_run_id ?? configurable.run_id;
|
|
40
|
+
if (!runId) throw new Error('LangGraph config must include configurable.agentledger_run_id or configurable.run_id');
|
|
41
|
+
return String(runId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
withCheckpointId(config, checkpointId) {
|
|
45
|
+
return { ...config, configurable: { ...(config?.configurable ?? {}), checkpoint_id: checkpointId } };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function newCheckpointId() {
|
|
50
|
+
return `lgckpt_${randomBytes(12).toString('hex')}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class LangGraphNodeAdapter {
|
|
54
|
+
constructor(node, { role = 'LangGraphAgent' } = {}) {
|
|
55
|
+
this.node = node;
|
|
56
|
+
this.role = role;
|
|
57
|
+
this.name = 'langgraph-node';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
mapRunSpec() {
|
|
61
|
+
return { adapter: this.name, role: this.role, node: this.node?.name ?? '<anonymous>' };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
asAgent({ outputKey = 'output' } = {}) {
|
|
65
|
+
return async (ctx, state) => {
|
|
66
|
+
const result = await this.node(ctx, state);
|
|
67
|
+
if (outputKey && result !== undefined) await ctx.writeState(outputKey, result);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const adapterPackage = {
|
|
73
|
+
name: 'agentledger-langgraph',
|
|
74
|
+
runtimePackage: 'agentledger-runtime',
|
|
75
|
+
version: '1.2.0',
|
|
76
|
+
category: 'framework',
|
|
77
|
+
};
|
package/src/cli.js
CHANGED
|
@@ -194,7 +194,7 @@ export function validateFixtures() {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function usage() {
|
|
197
|
-
return `AgentLedger TypeScript Runtime 1.0
|
|
197
|
+
return `AgentLedger TypeScript Runtime 1.2.0\n\nUsage:\n agentledger-ts doctor\n agentledger-ts version\n agentledger-ts quickstart\n agentledger-ts conformance\n agentledger-ts contract validate\n agentledger-ts contract export\n\nProject: https://github.com/yaogdu/AgentLedger`;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export async function runRuntimeSmoke() {
|
|
@@ -577,11 +577,11 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
577
577
|
return 0;
|
|
578
578
|
}
|
|
579
579
|
if (args.length === 1 && args[0] === 'version') {
|
|
580
|
-
console.log('agentledger-ts 1.0
|
|
580
|
+
console.log('agentledger-ts 1.2.0');
|
|
581
581
|
return 0;
|
|
582
582
|
}
|
|
583
583
|
if (args.length === 1 && args[0] === 'doctor') {
|
|
584
|
-
console.log(JSON.stringify({ language: 'typescript', version: '1.0
|
|
584
|
+
console.log(JSON.stringify({ language: 'typescript', version: '1.2.0', status: 'ok', runtime_core_parity: true }, null, 2));
|
|
585
585
|
return 0;
|
|
586
586
|
}
|
|
587
587
|
if (args.length === 1 && args[0] === 'quickstart') {
|