@aliyunrds/ctxdb 1.0.8-beta.1 → 1.0.8-beta.3
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 +14 -10
- package/dist/{chunk-NFAPLK4C.js → chunk-3NJ37TEY.js} +1 -1
- package/dist/{chunk-NF5KFV2P.js → chunk-7OX6UVPB.js} +15 -8
- package/dist/{chunk-LTAO6USK.js → chunk-AUBVVYQL.js} +1 -1
- package/dist/{chunk-KYW76CL7.js → chunk-BUK4SZC2.js} +980 -958
- package/dist/{chunk-3B7J5VUT.js → chunk-EI63DQX3.js} +1 -1
- package/dist/{chunk-TYW6ABNS.js → chunk-LZ2LOWZL.js} +2 -2
- package/dist/{chunk-SGRMPSZU.js → chunk-ZFS6OMWE.js} +4 -3
- package/dist/cli/main.js +29 -17
- package/dist/hooks/hermes-post-llm-call.js +10 -8
- package/dist/hooks/hermes-pre-llm-call.js +13 -12
- package/dist/hooks/session-start.js +12 -11
- package/dist/hooks/stop.js +10 -8
- package/dist/hooks/user-prompt-submit.js +12 -11
- package/dist/opencode/index.js +21 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Unified access layer for RDS ContextDatabase. One `ctxdb` CLI (memory + KB ops),
|
|
|
11
11
|
| **claude** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.claude/skills/ctxdb/` | hooks-driven (auto capture/recall) |
|
|
12
12
|
| **opencode** | Plugin shim (`~/.config/opencode/plugins/ctxdb.ts`) | `~/.config/opencode/skills/` | in-process plugin (auto capture/recall + KB catalog injection) |
|
|
13
13
|
| **hermes** | ✅ `pre_llm_call` + `post_llm_call` | `~/.hermes/skills/` | shell hooks (auto capture/recall + first-turn warmup) |
|
|
14
|
-
| **workbuddy** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.workbuddy/skills/ctxdb/` | hooks-driven (auto capture/recall); Claude-Code-isomorphic (exec form) |
|
|
14
|
+
| **workbuddy** | ✅ UserPromptSubmit + Stop + SessionStart | `~/.workbuddy-ai/skills/ctxdb/` | hooks-driven (auto capture/recall); Claude-Code-isomorphic (exec form) |
|
|
15
15
|
|
|
16
16
|
Config and logs live under `~/.ctxdb/`. `~/.ctxdb/ctxdb.json` is one file, but runtime config is isolated per agent under `agents.qoder`, `agents.qoderwork`, `agents.qwenwork`, `agents.codex`, `agents.claude`, `agents.opencode`, `agents.hermes`, and `agents.workbuddy`. (Pre-2026-05-23 installs used `~/.ctxdb.json` at the home root; running `ctxdb setup --agent <name>` migrates the file into the selected agent section.)
|
|
17
17
|
|
|
@@ -31,12 +31,14 @@ Internal login stores its single active connection in owner-only
|
|
|
31
31
|
without writing an `api_key` field into the Agent or default profile; an
|
|
32
32
|
existing field in either updated profile is removed. At runtime this managed
|
|
33
33
|
credential overrides the API key and DATA URL in the existing v2
|
|
34
|
-
`~/.ctxdb/ctxdb.json`; `CTXDB_API_KEY
|
|
35
|
-
priority overrides.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
`
|
|
34
|
+
`~/.ctxdb/ctxdb.json`; `CTXDB_ACCESS_TOKEN`, `CTXDB_API_KEY`, and
|
|
35
|
+
`CTXDB_BASE_URL` remain higher-priority overrides. `ctxdb login` rejects all
|
|
36
|
+
three while `ctxdb logout` rejects the two credential overrides, so command
|
|
37
|
+
output cannot disagree with subsequent DATA requests. Re-login replaces the
|
|
38
|
+
active connection and revokes the previous key after setup succeeds. The
|
|
39
|
+
public `@aliyunrds/ctxdb` build does not contain or advertise these commands and
|
|
40
|
+
continues to use `ctxdb setup` and the v2 config exactly as before. Build the
|
|
41
|
+
internal staging package with `pnpm build:internal`.
|
|
40
42
|
|
|
41
43
|
The distinction is a compile-time distribution manifest, not a runtime
|
|
42
44
|
environment-variable or file-existence check. The `public` manifest disables
|
|
@@ -210,7 +212,7 @@ ctxdb setup --agent codex --api-key 'ctxdb-new-...'
|
|
|
210
212
|
ctxdb status --agent codex --json
|
|
211
213
|
```
|
|
212
214
|
|
|
213
|
-
Setup first checks that the target agent home exists (`~/.qoder`, `~/.qoderwork`, `~/.qwenwork`, `~/.codex`, `~/.claude`, or `~/.workbuddy`; the declared CN variant home also satisfies this check). Setup writes hooks and skills only into homes that already exist, so a CN-only install does not create the international product home, and vice versa. If no home exists, install or start that agent once before running `ctxdb setup --agent <name>`. OpenCode and Hermes are config-dir style: setup creates `~/.config/opencode` / `~/.hermes` when they are missing.
|
|
215
|
+
Setup first checks that the target agent home exists (`~/.qoder`, `~/.qoderwork`, `~/.qwenwork`, `~/.codex`, `~/.claude`, or `~/.workbuddy-ai`; the declared CN variant home also satisfies this check). Setup writes hooks and skills only into homes that already exist, so a CN-only install does not create the international product home, and vice versa. If no home exists, install or start that agent once before running `ctxdb setup --agent <name>`. OpenCode and Hermes are config-dir style: setup creates `~/.config/opencode` / `~/.hermes` when they are missing.
|
|
214
216
|
|
|
215
217
|
For **qoder**, **qoderwork**, **qwenwork**, **codex**, **claude**, and **workbuddy**, restart the harness (CLI: just exit + restart; app: Cmd+R or quit/relaunch) so it picks up the new hooks/skill. For **codex**, setup also writes `[features].hooks = true` into `~/.codex/config.toml` (creating the file if missing) — Codex won't fire any hook entries without it. On first use Codex may prompt you to trust the new hook commands. For **opencode**, restart OpenCode so it loads `~/.config/opencode/plugins/ctxdb.ts`. For **hermes**, setup also checks `~/.hermes/shell-hooks-allowlist.json`; it reports setup as incomplete until both ctxdb hook commands are approved.
|
|
216
218
|
|
|
@@ -603,7 +605,9 @@ Field reference:
|
|
|
603
605
|
| `knowledge_top_k` | int | `6` | KB chunks pulled per recall (only effective when `recall_knowledge: true`) |
|
|
604
606
|
| `debug` | bool | `false` | Configured preference for verbose hook logging and full recall tracing. Effective debug is forced on for every final `base_url` outside the exact official-production allowlist; see “Debug control and recall replay”. General logs go to `~/.ctxdb/logs/ctxdb.log`, structured full-content recall records to `~/.ctxdb/logs/recall-trace.jsonl` |
|
|
605
607
|
|
|
606
|
-
Env-var overrides apply to the selected agent config (env wins): `CTXDB_AGENT` / `CTXDB_API_KEY` / `CTXDB_BASE_URL` / `CTXDB_USER_ID` / `CTXDB_AGENT_ID` / `CTXDB_APP_ID`. The internal login command additionally reads `CTXDB_LOGIN_SERVER` as its provider-neutral login endpoint. The last two default to unset — the request body omits `agent_id`/`app_id` entirely; set them only when you want per-agent / per-app scope isolation on the server.
|
|
608
|
+
Env-var overrides apply to the selected agent config (env wins): `CTXDB_AGENT` / `CTXDB_ACCESS_TOKEN` / `CTXDB_API_KEY` / `CTXDB_BASE_URL` / `CTXDB_USER_ID` / `CTXDB_AGENT_ID` / `CTXDB_APP_ID`. The internal login command additionally reads `CTXDB_LOGIN_SERVER` as its provider-neutral login endpoint. The last two default to unset — the request body omits `agent_id`/`app_id` entirely; set them only when you want per-agent / per-app scope isolation on the server.
|
|
609
|
+
|
|
610
|
+
Downstream Agent hosts can set `CTXDB_ACCESS_TOKEN` to send `Authorization: Bearer <token>` to the Data API. It is runtime-only, never written to `~/.ctxdb/ctxdb.json`, and takes precedence over an API key for CLI, process hooks, and the in-process OpenCode plugin; a rejected token does not fall back to the API key. `ctxdb setup` remains API-key-only and never persists or validates an access token.
|
|
607
611
|
|
|
608
612
|
Hook/plugin escape hatch: set `CTXDB_SKIP_HOOKS=TRUE` on the agent process to make all ctxdb hook entrypoints exit immediately before reading config or calling the API. Direct `ctxdb memory` / `ctxdb kb` / `ctxdb setup` CLI commands are unchanged.
|
|
609
613
|
|
|
@@ -664,7 +668,7 @@ ctxdb uninstall --purge-logs # also deletes ~/.ctxdb/logs/
|
|
|
664
668
|
|
|
665
669
|
### What uninstall does (and doesn't) touch
|
|
666
670
|
|
|
667
|
-
- **Hook entries in `~/.qoder/settings.json`, `~/.qoderwork/settings.json`, `~/.qwenwork/settings.json`, `~/.codex/hooks.json`, `~/.claude/settings.json`, `~/.workbuddy/settings.json`, and `~/.hermes/config.yaml`**: stripped precisely by marker (`_ctxdb = @aliyunrds/ctxdb`, plus legacy keys `_ctxdbQoder` / `_ctxdbPackage` and the legacy `@aliyunrds/ctxdb-qoder` value for installs predating the unified marker). Any hooks you added yourself stay. A timestamped `*.bak-ctxdb-<TS>` is written before each modification (rotation keeps the 5 most recent).
|
|
671
|
+
- **Hook entries in `~/.qoder/settings.json`, `~/.qoderwork/settings.json`, `~/.qwenwork/settings.json`, `~/.codex/hooks.json`, `~/.claude/settings.json`, `~/.workbuddy-ai/settings.json`, and `~/.hermes/config.yaml`**: stripped precisely by marker (`_ctxdb = @aliyunrds/ctxdb`, plus legacy keys `_ctxdbQoder` / `_ctxdbPackage` and the legacy `@aliyunrds/ctxdb-qoder` value for installs predating the unified marker). Any hooks you added yourself stay. A timestamped `*.bak-ctxdb-<TS>` is written before each modification (rotation keeps the 5 most recent).
|
|
668
672
|
- **Skill directories**: `~/.<agent>/skills/ctxdb/` for each set-up agent, plus legacy dirs (`ctxdb-qoder`, `rds-ctxdb-qoder`, `qoder-ctxdb`) under `~/.qoder/skills/` from older package names.
|
|
669
673
|
- **`~/.ctxdb/` state**: only with `--purge-config` / `--purge-logs` / `--purge-all`. Defensive: `--purge-all` removes the `~/.ctxdb/` root only if it's empty after the named files are deleted (won't blanket-rm an unknown directory).
|
|
670
674
|
- **`~/.codex/config.toml` `[features].hooks`**: **NOT** reverted. Setup adds `hooks = true` so Codex will fire ctxdb's hook entries; uninstall leaves the flag alone because (a) the user may have wanted it on for non-ctxdb hooks, and (b) it's harmless when `~/.codex/hooks.json` is empty. If you want it off, edit the file by hand.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
listKnowledgeBases
|
|
4
|
+
} from "./chunk-3NJ37TEY.js";
|
|
2
5
|
import {
|
|
3
6
|
isConnectionError,
|
|
4
7
|
resetCircuit,
|
|
5
8
|
tripCircuit
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
listKnowledgeBases
|
|
9
|
-
} from "./chunk-NFAPLK4C.js";
|
|
9
|
+
} from "./chunk-EI63DQX3.js";
|
|
10
10
|
import {
|
|
11
|
-
CtxdbError
|
|
12
|
-
|
|
11
|
+
CtxdbError,
|
|
12
|
+
isDataApiReady,
|
|
13
|
+
resolveDataApiCredential
|
|
14
|
+
} from "./chunk-BUK4SZC2.js";
|
|
13
15
|
|
|
14
16
|
// src/lib/kb-catalog.ts
|
|
15
17
|
function sanitizeKeyEntities(raw) {
|
|
@@ -152,12 +154,13 @@ async function recallTurn(prompt, cfg, client, agentOrOptions = "default") {
|
|
|
152
154
|
const options = typeof agentOrOptions === "string" ? { agent: agentOrOptions } : agentOrOptions;
|
|
153
155
|
const agent = options.agent ?? "default";
|
|
154
156
|
if (!prompt.trim()) return { ...EMPTY, reason: "empty_prompt" };
|
|
155
|
-
if (!cfg
|
|
157
|
+
if (!isDataApiReady(cfg)) {
|
|
156
158
|
return { ...EMPTY, reason: "config_incomplete" };
|
|
157
159
|
}
|
|
158
160
|
if (!cfg.autoRecall) {
|
|
159
161
|
return { ...EMPTY, reason: "auto_recall_disabled" };
|
|
160
162
|
}
|
|
163
|
+
const credential = resolveDataApiCredential(cfg);
|
|
161
164
|
const query = stripSystemReminders(prompt);
|
|
162
165
|
const trace = cfg.debug ? {
|
|
163
166
|
agent,
|
|
@@ -175,7 +178,11 @@ async function recallTurn(prompt, cfg, client, agentOrOptions = "default") {
|
|
|
175
178
|
},
|
|
176
179
|
store: {
|
|
177
180
|
...options.traceStore,
|
|
178
|
-
secrets: [
|
|
181
|
+
secrets: [
|
|
182
|
+
...options.traceStore?.secrets ?? [],
|
|
183
|
+
cfg.apiKey,
|
|
184
|
+
credential.value
|
|
185
|
+
]
|
|
179
186
|
}
|
|
180
187
|
} : null;
|
|
181
188
|
if (trace) {
|