@aliyunrds/ctxdb 1.0.1-beta.1 → 1.0.1-beta.2

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
@@ -129,6 +129,8 @@ Field reference:
129
129
 
130
130
  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 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.
131
131
 
132
+ 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.
133
+
132
134
  `run_id` is **not** env-driven: the Stop hook reads the host's `session_id` from the hook payload (Qoder / Codex / Claude Code all pass it at the top level; opencode reads `ev.properties.sessionID`) and sends it as `run_id` on capture only, so the server can associate turns within one session for richer extraction context. Recall never sends `run_id`. If the payload has no `session_id`, `run_id` is omitted and capture proceeds normally (the server falls back to baseMessages).
133
135
 
134
136
  ## Architecture
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/lib/hook-env.ts
4
+ var CTXDB_SKIP_HOOKS = "CTXDB_SKIP_HOOKS";
5
+ function shouldSkipHooks(env = process.env) {
6
+ return env[CTXDB_SKIP_HOOKS] === "TRUE";
7
+ }
8
+
9
+ export {
10
+ shouldSkipHooks
11
+ };
package/dist/cli/main.js CHANGED
@@ -2257,6 +2257,11 @@ AGENT RESOLUTION (when --agent is omitted):
2257
2257
 
2258
2258
  ENV VARS (override selected ~/.ctxdb/ctxdb.json agent config):
2259
2259
  CTXDB_AGENT CTXDB_API_KEY CTXDB_BASE_URL CTXDB_USER_ID
2260
+ CTXDB_AGENT_ID CTXDB_APP_ID
2261
+
2262
+ HOOK ENV VARS:
2263
+ CTXDB_SKIP_HOOKS=TRUE Hook/plugin entrypoints exit immediately.
2264
+ Direct ctxdb CLI commands are unchanged.
2260
2265
 
2261
2266
  CONFIG: ~/.ctxdb/ctxdb.json (agents.default / agents.qoder / agents.qoderwork / agents.codex / agents.claude / agents.opencode)
2262
2267
  LOGS: ~/.ctxdb/logs/ctxdb.log
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ shouldSkipHooks
4
+ } from "../chunk-UEKR2Z3S.js";
2
5
 
3
6
  // src/hooks/pre-tool-use.ts
4
7
  async function main() {
8
+ if (shouldSkipHooks()) return 0;
5
9
  for await (const _chunk of process.stdin) {
6
10
  }
7
11
  return 0;
@@ -15,6 +15,9 @@ import {
15
15
  load,
16
16
  setDebug
17
17
  } from "../chunk-TKMIWM6Q.js";
18
+ import {
19
+ shouldSkipHooks
20
+ } from "../chunk-UEKR2Z3S.js";
18
21
 
19
22
  // src/hooks/session-start.ts
20
23
  import { pathToFileURL } from "url";
@@ -120,6 +123,7 @@ async function readStdinJson() {
120
123
  }
121
124
  async function main() {
122
125
  try {
126
+ if (shouldSkipHooks()) return 0;
123
127
  const event = await readStdinJson();
124
128
  const { agent, fellBack } = agentFromArgvWithFallback();
125
129
  if (fellBack) {
@@ -14,6 +14,9 @@ import {
14
14
  load,
15
15
  setDebug
16
16
  } from "../chunk-TKMIWM6Q.js";
17
+ import {
18
+ shouldSkipHooks
19
+ } from "../chunk-UEKR2Z3S.js";
17
20
 
18
21
  // src/lib/capture-orchestrator.ts
19
22
  import {
@@ -513,6 +516,7 @@ function extractHookSessionId(event) {
513
516
  }
514
517
  async function main() {
515
518
  try {
519
+ if (shouldSkipHooks()) return 0;
516
520
  const event = await readStdinJson();
517
521
  const { agent, fellBack } = agentFromArgvWithFallback();
518
522
  if (fellBack) {
@@ -15,6 +15,9 @@ import {
15
15
  load,
16
16
  setDebug
17
17
  } from "../chunk-TKMIWM6Q.js";
18
+ import {
19
+ shouldSkipHooks
20
+ } from "../chunk-UEKR2Z3S.js";
18
21
 
19
22
  // src/hooks/user-prompt-submit.ts
20
23
  import { pathToFileURL } from "url";
@@ -52,6 +55,7 @@ async function readStdinJson() {
52
55
  }
53
56
  async function main() {
54
57
  try {
58
+ if (shouldSkipHooks()) return 0;
55
59
  const event = await readStdinJson();
56
60
  const { agent, fellBack } = agentFromArgvWithFallback();
57
61
  if (fellBack) {
@@ -825,6 +825,12 @@ async function runCapture(messages, cfg, client, timeoutMs, lastFingerprint, ses
825
825
  };
826
826
  }
827
827
 
828
+ // src/hook-env.ts
829
+ var CTXDB_SKIP_HOOKS = "CTXDB_SKIP_HOOKS";
830
+ function shouldSkipHooks(env = process.env) {
831
+ return env[CTXDB_SKIP_HOOKS] === "TRUE";
832
+ }
833
+
828
834
  // src/hooks.ts
829
835
  var SESSION_TTL_MS = 15 * 60 * 1e3;
830
836
  var SESSION_MAX = 100;
@@ -870,6 +876,7 @@ function extractTextPrompt(parts) {
870
876
  return chunks.join("\n").trim();
871
877
  }
872
878
  async function buildHooks(input) {
879
+ if (shouldSkipHooks()) return {};
873
880
  const config = loadOpencodeConfig();
874
881
  if (!isConfigured(config)) {
875
882
  logDebug(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliyunrds/ctxdb",
3
- "version": "1.0.1-beta.1",
3
+ "version": "1.0.1-beta.2",
4
4
  "type": "module",
5
5
  "description": "Unified access layer for RDS ContextDatabase: `ctxdb` CLI (memory + KB ops), one-shot `setup --agent <qoder|qoderwork|codex|claude|opencode>` installer, per-agent config, hooks/plugins, and SKILL.md.",
6
6
  "license": "Apache-2.0",