@one-agent-ctx/native-runtime 0.0.0-stage → 0.1.4
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 +130 -2
- package/cli.d.ts +2 -0
- package/cli.js +26 -0
- package/index.d.ts +24 -0
- package/index.js +15 -0
- package/package.json +37 -4
- package/platform.js +19 -0
package/README.md
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Agent Context OS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local Rust infrastructure for coding/general agents. It provides four bounded
|
|
4
|
+
capabilities and does nothing until the host explicitly calls it or registers a
|
|
5
|
+
directory:
|
|
6
|
+
|
|
7
|
+
- recall confirmed preferences, evidence-backed mistakes and source-bound general memories;
|
|
8
|
+
- search and version-bind executable Skill packages;
|
|
9
|
+
- search knowledge inside explicitly registered Resource directory subtrees;
|
|
10
|
+
- turn verified repeated workflows into replayable Skill drafts, then install
|
|
11
|
+
them only after the host records a successful clean replay.
|
|
12
|
+
|
|
13
|
+
It does not crawl the working directory, auto-install Skills, execute generated
|
|
14
|
+
scripts, or treat Resource text as agent instructions.
|
|
15
|
+
|
|
16
|
+
## Build and verify
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
cargo build --workspace --all-features
|
|
20
|
+
cargo test --workspace --all-features
|
|
21
|
+
cargo clippy --workspace --all-targets --all-features -- -D warnings
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Run
|
|
25
|
+
|
|
26
|
+
Native JSON Lines transport:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
cargo run -p ctxos -- serve --stdio --data-dir /absolute/path/to/ctxos-data
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
MCP stdio transport:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
cargo run -p ctxos --features mcp -- serve --mcp --data-dir /absolute/path/to/ctxos-data
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Host-only control channel (same process, same Store writer):
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
cargo run -p ctxos --features mcp -- serve --mcp --control --data-dir /absolute/path/to/ctxos-data
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The control endpoint is published as owner-only `<data-dir>/control.json`
|
|
45
|
+
(`version`, `pid`, loopback `port`, `started_at_unix_ms`). It is for host
|
|
46
|
+
operations such as durable-context assembly, inbox listing, confirmation and
|
|
47
|
+
forget; it is not a model-facing tool. MCP remains the model transport.
|
|
48
|
+
|
|
49
|
+
`stdout` is reserved for the selected protocol. The SQLite store, immutable
|
|
50
|
+
installed Skill versions, and generated drafts live below `data-dir`.
|
|
51
|
+
|
|
52
|
+
## Explicit directory registration
|
|
53
|
+
|
|
54
|
+
A host may call `register_root` through the native protocol, or pass an absolute
|
|
55
|
+
config file:
|
|
56
|
+
|
|
57
|
+
```toml
|
|
58
|
+
data_dir = { encoding = "utf8", value = "/absolute/ctxos-data" }
|
|
59
|
+
|
|
60
|
+
[[roots]]
|
|
61
|
+
kind = "resource"
|
|
62
|
+
scope = "global"
|
|
63
|
+
path = { encoding = "utf8", value = "/root/product" }
|
|
64
|
+
|
|
65
|
+
[[roots]]
|
|
66
|
+
kind = "skill"
|
|
67
|
+
scope = "global"
|
|
68
|
+
path = { encoding = "utf8", value = "/root/skills" }
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cargo run -p ctxos -- serve --stdio --config /absolute/config.toml
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Registration starts a recursive native watcher and performs an authoritative
|
|
76
|
+
initial reconcile. Queries must still pass a non-empty `within` list. Searching
|
|
77
|
+
`/root/product/taobao` cannot return `/root/product/pdd`; searching
|
|
78
|
+
`/root/product` can return both. Multiple authorized subtrees form a union.
|
|
79
|
+
|
|
80
|
+
Paths use the tagged `NativePath` wire representation so Unix non-UTF-8 bytes
|
|
81
|
+
and Windows UTF-16 paths are not silently corrupted. Skill package members use
|
|
82
|
+
portable `/`-separated relative paths and reject traversal, symlinks, reserved
|
|
83
|
+
Windows names, case collisions, and Unicode-normalization collisions.
|
|
84
|
+
|
|
85
|
+
## Agent lifecycle
|
|
86
|
+
|
|
87
|
+
The intended stable hooks are:
|
|
88
|
+
|
|
89
|
+
1. task start: `recall_memories`;
|
|
90
|
+
2. planning: `search_skills`, then `load_skill` with the returned version/hash;
|
|
91
|
+
3. knowledge gap: `search_resources` with explicit directories;
|
|
92
|
+
4. task completion/correction: `record_episode`;
|
|
93
|
+
5. repeated verified workflow: `draft_skill`, execute its replay plan in the
|
|
94
|
+
host, `record_draft_replay`, then user-confirmed `install_skill`.
|
|
95
|
+
|
|
96
|
+
The MCP tool surface covers the agent loop, explicit model extraction, resource
|
|
97
|
+
understanding and context assembly. Host management operations such as directory
|
|
98
|
+
authorization, replay evidence and installation remain on native `ctxos.v1`;
|
|
99
|
+
they are not implicitly granted to agents. The current protocol contract is in
|
|
100
|
+
`docs/refactor/42-ctxos-api.md`. (A pure-Go JSON Lines client formerly lived in
|
|
101
|
+
`sdk/go/ctxos`; it was removed 2026-09-30 — zero consumers. The historical
|
|
102
|
+
HTTP/FFI SDK of the retired generation was a different protocol.)
|
|
103
|
+
|
|
104
|
+
Context assembly is read-only. Hosts supply the actual turn and confirm only
|
|
105
|
+
the rendered entries after flushing and reading back their durable context
|
|
106
|
+
snapshot. `confirm_context_injection` atomically records the cooldown projection
|
|
107
|
+
and idempotent receipt; it is a host management operation, not an MCP tool.
|
|
108
|
+
Saved-memory deletion, provenance and the context-recall wipe behind the
|
|
109
|
+
schema-v34 stamp are in [memory integrity](docs/refactor/58-memory-integrity.md).
|
|
110
|
+
Schema 33 collided with the parallel epoch-2 identity/TTL cutover; the merged
|
|
111
|
+
build defines 34, and any database stamped by either 33 lineage is archived by
|
|
112
|
+
the epoch gate rather than opened.
|
|
113
|
+
|
|
114
|
+
## Upstream reuse and current backend decision
|
|
115
|
+
|
|
116
|
+
Production retrieval uses Qdrant Edge and upstream BM25/RRF code; exact-dense
|
|
117
|
+
remains a correctness oracle. OpenViking algorithms, prompts and schemas are
|
|
118
|
+
ported into resource, memory, session, assembly and Skill learning paths with
|
|
119
|
+
explicit source and approval safeguards. Remote models require explicit host
|
|
120
|
+
configuration. Every reuse decision and its limits are recorded in
|
|
121
|
+
`provenance/reuse-ledger.toml`; integration is not proof of overall superiority.
|
|
122
|
+
Current tests and remaining migration gaps are recorded in
|
|
123
|
+
`docs/refactor/54-implementation-evidence.md` and `docs/refactor/56-long-run-delivery.md`.
|
|
124
|
+
Cross-compilation must not be described as native Windows execution.
|
|
125
|
+
|
|
126
|
+
For the Node package, the [npm native qualification and release runbook](docs/refactor/06-platform-and-path-portability.md#npm-原生包资格)
|
|
127
|
+
defines the six macOS/Linux/Windows targets, NAPI and CLI native qualification,
|
|
128
|
+
runtime receipts, and explicit release prerequisites.
|
|
129
|
+
|
|
130
|
+
See `docs/refactor/README.md` for the design source of truth and
|
|
131
|
+
`provenance/qdrant-edge-qualification.md` for the qualification evidence.
|
package/cli.d.ts
ADDED
package/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { resolvePlatform } = require('./platform.js');
|
|
3
|
+
const { createHash } = require('node:crypto');
|
|
4
|
+
const { readFileSync } = require('node:fs');
|
|
5
|
+
|
|
6
|
+
/** Resolve the CLI distributed with the exact native platform package. */
|
|
7
|
+
function cliPath() {
|
|
8
|
+
const platform = resolvePlatform(process.platform, process.arch,
|
|
9
|
+
process.platform === 'linux' ? process.report.getReport().header.glibcVersionRuntime : undefined);
|
|
10
|
+
const packageName = `@one-agent-ctx/runtime-${platform.id}`;
|
|
11
|
+
try {
|
|
12
|
+
const binary = require.resolve(`${packageName}/${platform.cli}`);
|
|
13
|
+
const receipt = require(`${packageName}/artifact.json`);
|
|
14
|
+
const version = require('./package.json').version;
|
|
15
|
+
const digest = createHash('sha256').update(readFileSync(binary)).digest('hex');
|
|
16
|
+
if (receipt.version !== version || receipt.platform !== platform.id || receipt.cliSha256 !== digest) {
|
|
17
|
+
throw new Error(`${packageName} CLI bytes differ from its published artifact identity`);
|
|
18
|
+
}
|
|
19
|
+
return binary;
|
|
20
|
+
} catch (cause) {
|
|
21
|
+
if (cause.code !== 'MODULE_NOT_FOUND') throw cause;
|
|
22
|
+
throw new Error(`${packageName} CLI is not installed. Install @one-agent-ctx/native-runtime with optional dependencies enabled.`, { cause });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = { cliPath };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Agent Context OS native runtime (napi-rs binding). */
|
|
2
|
+
export interface CtxosCapabilities {
|
|
3
|
+
readonly version: string;
|
|
4
|
+
readonly methods: readonly string[];
|
|
5
|
+
readonly generationConfigured: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EmbedderConfig {
|
|
8
|
+
readonly baseUrl: string;
|
|
9
|
+
readonly apiKey: string;
|
|
10
|
+
readonly model: string;
|
|
11
|
+
readonly dimension: number;
|
|
12
|
+
}
|
|
13
|
+
export interface GeneratorConfig {
|
|
14
|
+
readonly baseUrl: string;
|
|
15
|
+
readonly apiKey: string;
|
|
16
|
+
readonly model: string;
|
|
17
|
+
readonly maxCalls: number;
|
|
18
|
+
}
|
|
19
|
+
export class CtxosRuntime {
|
|
20
|
+
constructor(dataDir: string);
|
|
21
|
+
static withModels(dataDir: string, embedder?: EmbedderConfig | null, generator?: GeneratorConfig | null): CtxosRuntime;
|
|
22
|
+
handle(requestJson: string): Promise<string>;
|
|
23
|
+
capabilities(): CtxosCapabilities;
|
|
24
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { resolvePlatform } = require('./platform.js');
|
|
3
|
+
const platform = resolvePlatform(process.platform, process.arch,
|
|
4
|
+
process.platform === 'linux' ? process.report.getReport().header.glibcVersionRuntime : undefined);
|
|
5
|
+
const packageName = `@one-agent-ctx/runtime-${platform.id}`;
|
|
6
|
+
let binaryPath;
|
|
7
|
+
try {
|
|
8
|
+
binaryPath = require.resolve(`${packageName}/ctxos_napi.node`);
|
|
9
|
+
} catch (cause) {
|
|
10
|
+
if (cause.code !== 'MODULE_NOT_FOUND') throw cause;
|
|
11
|
+
throw new Error(`${packageName} is not installed. Install @one-agent-ctx/native-runtime with optional dependencies enabled.`, { cause });
|
|
12
|
+
}
|
|
13
|
+
// Preserve native loader errors: a corrupt or incompatible binary cannot be
|
|
14
|
+
// treated as an absent optional dependency or silently replaced.
|
|
15
|
+
module.exports = require(binaryPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@one-agent-ctx/native-runtime",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Agent Context OS - native Node.js binding (napi-rs). Memories, skills, resources, self-evolution.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"index.d.ts",
|
|
10
|
+
"platform.js",
|
|
11
|
+
"cli.js",
|
|
12
|
+
"cli.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"optionalDependencies": {
|
|
15
|
+
"@one-agent-ctx/runtime-darwin-arm64": "0.1.4",
|
|
16
|
+
"@one-agent-ctx/runtime-darwin-x64": "0.1.4",
|
|
17
|
+
"@one-agent-ctx/runtime-linux-arm64": "0.1.4",
|
|
18
|
+
"@one-agent-ctx/runtime-linux-x64": "0.1.4",
|
|
19
|
+
"@one-agent-ctx/runtime-win32-x64-msvc": "0.1.4",
|
|
20
|
+
"@one-agent-ctx/runtime-win32-arm64-msvc": "0.1.4"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test:npm": "node --test tests/harness/npm-release.test.mjs",
|
|
24
|
+
"release:matrix": "node scripts/npm-release.mjs matrix",
|
|
25
|
+
"release:stage": "node scripts/npm-release.mjs stage",
|
|
26
|
+
"release:verify": "node scripts/npm-release.mjs verify",
|
|
27
|
+
"release:publish": "node scripts/npm-release.mjs publish",
|
|
28
|
+
"release:stage-cross": "node scripts/npm-release.mjs stage-cross",
|
|
29
|
+
"release:publish-local": "node scripts/npm-release.mjs publish-local"
|
|
30
|
+
},
|
|
31
|
+
"license": "AGPL-3.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/wocrab/one-ctx.git"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/platform.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// One distribution roster drives package resolution and release qualification.
|
|
4
|
+
const platforms = Object.freeze([
|
|
5
|
+
{ id: 'darwin-arm64', os: 'darwin', cpu: 'arm64', target: 'aarch64-apple-darwin', runner: 'macos-15', library: 'libctxos_napi.dylib', cli: 'ctxos' },
|
|
6
|
+
{ id: 'darwin-x64', os: 'darwin', cpu: 'x64', target: 'x86_64-apple-darwin', runner: 'macos-15-intel', library: 'libctxos_napi.dylib', cli: 'ctxos' },
|
|
7
|
+
{ id: 'linux-arm64', os: 'linux', cpu: 'arm64', target: 'aarch64-unknown-linux-gnu', runner: 'ubuntu-24.04-arm', library: 'libctxos_napi.so', cli: 'ctxos' },
|
|
8
|
+
{ id: 'linux-x64', os: 'linux', cpu: 'x64', target: 'x86_64-unknown-linux-gnu', runner: 'ubuntu-24.04', library: 'libctxos_napi.so', cli: 'ctxos' },
|
|
9
|
+
{ id: 'win32-arm64-msvc', os: 'win32', cpu: 'arm64', target: 'aarch64-pc-windows-msvc', runner: 'windows-11-arm', library: 'ctxos_napi.dll', cli: 'ctxos.exe' },
|
|
10
|
+
{ id: 'win32-x64-msvc', os: 'win32', cpu: 'x64', target: 'x86_64-pc-windows-msvc', runner: 'windows-2025', library: 'ctxos_napi.dll', cli: 'ctxos.exe' },
|
|
11
|
+
].map(Object.freeze));
|
|
12
|
+
|
|
13
|
+
function resolvePlatform(os, cpu, glibcVersion) {
|
|
14
|
+
const platform = platforms.find(entry => entry.os === os && entry.cpu === cpu);
|
|
15
|
+
if (!platform) throw new Error(`@one-agent-ctx/native-runtime does not support ${os}-${cpu}`);
|
|
16
|
+
return platform;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = { platforms, resolvePlatform };
|