@one-agent-ctx/native-runtime 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,131 @@
1
- # Temporary Holding Version
1
+ # Agent Context OS
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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 four macOS/Windows targets, native and cross-compiled 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/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,35 @@
1
1
  {
2
2
  "name": "@one-agent-ctx/native-runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
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
+ ],
12
+ "optionalDependencies": {
13
+ "@one-agent-ctx/runtime-darwin-arm64": "0.1.0",
14
+ "@one-agent-ctx/runtime-darwin-x64": "0.1.0",
15
+ "@one-agent-ctx/runtime-win32-x64-msvc": "0.1.0",
16
+ "@one-agent-ctx/runtime-win32-arm64-msvc": "0.1.0"
17
+ },
18
+ "scripts": {
19
+ "test:npm": "node --test tests/harness/npm-release.test.mjs",
20
+ "release:matrix": "node scripts/npm-release.mjs matrix",
21
+ "release:stage": "node scripts/npm-release.mjs stage",
22
+ "release:verify": "node scripts/npm-release.mjs verify",
23
+ "release:publish": "node scripts/npm-release.mjs publish",
24
+ "release:stage-cross": "node scripts/npm-release.mjs stage-cross",
25
+ "release:publish-local": "node scripts/npm-release.mjs publish-local"
26
+ },
27
+ "license": "AGPL-3.0",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/wocrab/one-ctx.git"
31
+ },
32
+ "engines": {
33
+ "node": ">=24"
34
+ }
35
+ }
package/platform.js ADDED
@@ -0,0 +1,17 @@
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' },
6
+ { id: 'darwin-x64', os: 'darwin', cpu: 'x64', target: 'x86_64-apple-darwin', runner: 'macos-15-intel', library: 'libctxos_napi.dylib' },
7
+ { id: 'win32-arm64-msvc', os: 'win32', cpu: 'arm64', target: 'aarch64-pc-windows-msvc', runner: 'windows-11-arm', library: 'ctxos_napi.dll' },
8
+ { id: 'win32-x64-msvc', os: 'win32', cpu: 'x64', target: 'x86_64-pc-windows-msvc', runner: 'windows-2025', library: 'ctxos_napi.dll' },
9
+ ].map(Object.freeze));
10
+
11
+ function resolvePlatform(os, cpu, glibcVersion) {
12
+ const platform = platforms.find(entry => entry.os === os && entry.cpu === cpu);
13
+ if (!platform) throw new Error(`@one-agent-ctx/native-runtime does not support ${os}-${cpu}`);
14
+ return platform;
15
+ }
16
+
17
+ module.exports = { platforms, resolvePlatform };