@aliyunrds/ctxdb 1.0.11-beta.0 → 1.0.12-beta.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 +31 -12
- package/dist/{chunk-EWCB3UQS.js → chunk-4GYXLFNU.js} +35 -9
- package/dist/{chunk-7RMETV4M.js → chunk-7CZIQG6Z.js} +1 -1
- package/dist/{chunk-6XK3RDZ6.js → chunk-BRCQTX2M.js} +1 -1
- package/dist/{chunk-XEX5344F.js → chunk-C66FQHNI.js} +5 -5
- package/dist/{chunk-WCVCSOFL.js → chunk-CGA7EITY.js} +2 -2
- package/dist/{chunk-JM7EOAQZ.js → chunk-EX6SM7I3.js} +1 -1
- package/dist/{chunk-HHKQPWYI.js → chunk-HUX2XS5P.js} +1720 -1709
- package/dist/cli/main.js +41 -19
- package/dist/hooks/hermes-post-llm-call.js +19 -33
- package/dist/hooks/hermes-pre-llm-call.js +9 -9
- package/dist/hooks/session-end.js +4 -4
- package/dist/hooks/session-start.js +8 -8
- package/dist/hooks/stop.js +12 -7
- package/dist/hooks/user-prompt-submit.js +8 -8
- package/dist/opencode/index.js +421 -69
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -44,9 +44,9 @@ session remains available for `ctxdb setup --agent <name>` to retry. Hermes appr
|
|
|
44
44
|
remain explicit, and successful setup includes the usual host restart/trust reminders.
|
|
45
45
|
Ordinary setup preserves
|
|
46
46
|
existing authentication and binds the default login only for an Agent without an authentication
|
|
47
|
-
choice.
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
choice. Setup, setup --all, update and reauthorization retain each credential's saved DATA endpoint.
|
|
48
|
+
A fresh installation defaults to China. To switch sites, authorize a new login with `--site`,
|
|
49
|
+
or supply that site's API key with `setup --api-key ... --site ...`; setup never redirects an existing token.
|
|
50
50
|
An explicit invalid `--base-url` (including a missing or empty value) fails before configuration
|
|
51
51
|
changes and suggests the current production URL; it never acts like an omitted option.
|
|
52
52
|
|
|
@@ -85,13 +85,20 @@ Upgrade the CLI and the actual hooks/plugin artifacts together before enabling s
|
|
|
85
85
|
New CLI reading old v2 configuration is supported; old CLI reading shared-login configuration is not.
|
|
86
86
|
See [共享登录、完整命令与兼容契约](../../docs/cli-shared-login.md) for migration and concurrency details.
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
`
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
Official site presets live in `access_layer/shared/src/sites.ts` and are shared with debug policy.
|
|
89
|
+
Use `ctxdb login --agent codex --site intl` for international Singapore, or `--site cn` for China.
|
|
90
|
+
`setup --api-key <key> --site intl` and `openclaw ctxdb init --api-key <key> --site intl`
|
|
91
|
+
select the same service. A matching `setup --site` preserves the credential's exact official alias.
|
|
92
|
+
|
|
93
|
+
| Site | Core endpoint | Console authorization page |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `cn` | `https://api.cn-hangzhou.agentcontext.aliyuncs.com` | `https://rdsnext.console.aliyun.com/contextDbCliAuthorization/cn-hangzhou` |
|
|
96
|
+
| `intl` | `https://context-database.ap-southeast-1.aliyuncs.com` | `https://rds.console.alibabacloud.com/contextDbCliAuthorization/ap-southeast-1` |
|
|
97
|
+
|
|
98
|
+
The China alias `https://context-database.aliyuncs.com` retains its China console mapping.
|
|
99
|
+
Specifying the Singapore `--base-url` also selects the international authorization page automatically.
|
|
100
|
+
CLI appends the current `user_code`. A site preset cannot be combined with `--base-url`, `--server`
|
|
101
|
+
or `--login-url`; explicit `--site` uses its built-in authorization page.
|
|
95
102
|
Use `--base-url` to select the Core service and `--login-url` to supply the HTTPS console page
|
|
96
103
|
for this invocation. The latter does not change the service origin or persist a console mapping.
|
|
97
104
|
The legacy `--server` alias for `--base-url` remains accepted; do not pass both.
|
|
@@ -155,7 +162,11 @@ ctxdb auth status --json
|
|
|
155
162
|
|
|
156
163
|
The internal tarball bundles `@aliyunrds/ctxdb-shared`, so users install only
|
|
157
164
|
one ContextDB package. `semver` and `yaml` remain normal registry dependencies.
|
|
158
|
-
Maintainers should follow [`INTERNAL_PUBLISH.md`](./INTERNAL_PUBLISH.md).
|
|
165
|
+
Maintainers should follow [`INTERNAL_PUBLISH.md`](./INTERNAL_PUBLISH.md) for Ali NPM.
|
|
166
|
+
For public releases, use [`LOCAL_PUBLISH.md`](./LOCAL_PUBLISH.md) to build with
|
|
167
|
+
`pnpm pack` and validate the exact tarballs, then follow [`PUBLISH.md`](./PUBLISH.md)
|
|
168
|
+
to upload those tarballs with `npm publish`. npm publication does not update the
|
|
169
|
+
separate [OSS installer scripts and agent manual](../../docs/bootstrap-release.md).
|
|
159
170
|
|
|
160
171
|
### Recommended: console-generated installer command
|
|
161
172
|
|
|
@@ -407,7 +418,8 @@ hooks, plugins, or skills. It requires that profile to already exist.
|
|
|
407
418
|
|
|
408
419
|
The official-production URL allowlist contains
|
|
409
420
|
`https://api.cn-hangzhou.agentcontext.aliyuncs.com` and the legacy
|
|
410
|
-
`https://context-database.aliyuncs.com
|
|
421
|
+
`https://context-database.aliyuncs.com`, plus Singapore
|
|
422
|
+
`https://context-database.ap-southeast-1.aliyuncs.com` (a trailing slash is equivalent).
|
|
411
423
|
Policy is evaluated after profile/default inheritance and `CTXDB_BASE_URL`.
|
|
412
424
|
Any other complete URL—including pre-production domains, numeric IPs,
|
|
413
425
|
localhost, HTTP, alternate ports or paths—and any invalid URL forces effective
|
|
@@ -1017,3 +1029,10 @@ Codex 0.153.4 has completed the automatic lifecycle against a local test center/
|
|
|
1017
1029
|
上传时可用 `ctxdb kb upload-text` 或 `ctxdb kb upload-file` 的 `--review-enabled` / `--no-review-enabled` 覆盖本次文档评审开关;不传时沿用服务端默认,不修改知识库策略。两标志互斥,分片上传保留同一选择。上传回执不代表评审或入库完成,应查询实际状态。
|
|
1018
1030
|
|
|
1019
1031
|
`memory get <fact-id> --verbose` 通过原生 Fact 详情接口读取状态、关联实体 ID、来源及参考/记录时间;默认 `memory get` 的 mem0 输出保持兼容。召回统计可从同一身份的 `memory list` 中按 ID 对应读取。
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
### 删除记忆与自动采集
|
|
1035
|
+
|
|
1036
|
+
Agent 本轮实际调用 `ctxdb memory delete` / `memory batch-delete` 或已注册的 ContextDB 删除工具后,该轮自动采集返回 `memory_cleanup_skip`。即使删除失败,也不会把清理请求和结果汇报再次自动写入记忆;同轮其他业务信息也会跳过。查询、搜索、列出记忆正常采集,下一轮正常判断。
|
|
1037
|
+
|
|
1038
|
+
该规则不改变删除接口,不新增配置项。自动采集只发送当前轮正文,不重复加入前序摘要。命令示例和帮助命令不触发;隐藏在自定义脚本、动态命令或直接 HTTP/SDK 请求内的删除不在首版检测保证范围。宿主完成条件与验收范围见 [hooks 支持矩阵](../../docs/hooks-support-matrix.md)。
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolveMemoryUploadAgentId
|
|
4
|
+
} from "./chunk-SR3M7AL5.js";
|
|
2
5
|
import {
|
|
3
6
|
isCircuitOpen,
|
|
4
7
|
isConnectionError,
|
|
5
8
|
resetCircuit,
|
|
6
9
|
tripCircuit
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import {
|
|
9
|
-
resolveMemoryUploadAgentId
|
|
10
|
-
} from "./chunk-SR3M7AL5.js";
|
|
10
|
+
} from "./chunk-7CZIQG6Z.js";
|
|
11
11
|
import {
|
|
12
12
|
CtxdbError,
|
|
13
13
|
debug,
|
|
14
14
|
extractSkillSignals,
|
|
15
15
|
isDataApiReady,
|
|
16
16
|
isDebug,
|
|
17
|
-
|
|
17
|
+
normalizeTranscriptRows,
|
|
18
|
+
readTranscriptSnapshot,
|
|
18
19
|
selectTurnRows,
|
|
19
20
|
toKbDetectionMessages,
|
|
20
21
|
toParsedMessages
|
|
21
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HUX2XS5P.js";
|
|
22
23
|
|
|
23
24
|
// src/lib/capture-orchestrator.ts
|
|
24
25
|
import {
|
|
25
26
|
filterMessagesForExtraction,
|
|
27
|
+
detectMemoryCleanup,
|
|
28
|
+
captureToolCalls,
|
|
29
|
+
selectCaptureTurn,
|
|
30
|
+
captureCompletionReason,
|
|
26
31
|
isKnowledgeBaseUploadTurn,
|
|
27
32
|
selectTurnMessages
|
|
28
33
|
} from "@aliyunrds/ctxdb-shared";
|
|
@@ -48,10 +53,23 @@ function getGitContext() {
|
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
// src/lib/capture-orchestrator.ts
|
|
51
|
-
async function captureTurn(transcriptPath, cfg, client, agent = "default", sessionId) {
|
|
56
|
+
async function captureTurn(transcriptPath, cfg, client, agent = "default", sessionId, completion = {}) {
|
|
52
57
|
const preflight = capturePreflight(cfg, agent);
|
|
53
58
|
if (preflight) return preflight;
|
|
54
|
-
const
|
|
59
|
+
const snapshot = readTranscriptSnapshot(transcriptPath);
|
|
60
|
+
if (snapshot.incomplete) return { captured: false, reason: "transcript_incomplete", messageCount: 0 };
|
|
61
|
+
const rawTurn = selectCaptureTurn(snapshot.rawRows);
|
|
62
|
+
const toolCalls = captureToolCalls(rawTurn);
|
|
63
|
+
const cleanup = detectMemoryCleanup(toolCalls);
|
|
64
|
+
if (cleanup.detected) {
|
|
65
|
+
debug("capture", "memory cleanup skipped", { agent, sessionId, turnId: completion.turnId, operation: cleanup.operation, source: cleanup.source });
|
|
66
|
+
return { captured: false, reason: "memory_cleanup_skip", messageCount: 0 };
|
|
67
|
+
}
|
|
68
|
+
const rows = normalizeTranscriptRows(rawTurn);
|
|
69
|
+
if (!rawTurn.length && snapshot.rows.length) {
|
|
70
|
+
const reason = toParsedMessages(snapshot.rows).length ? "empty_turn_slice" : `transcript_schema_mismatch: rows=${snapshot.rows.length} parsed=0`;
|
|
71
|
+
return { captured: false, reason, messageCount: 0 };
|
|
72
|
+
}
|
|
55
73
|
if (rows.length === 0) {
|
|
56
74
|
return { captured: false, reason: "empty_transcript", messageCount: 0 };
|
|
57
75
|
}
|
|
@@ -69,12 +87,19 @@ async function captureTurn(transcriptPath, cfg, client, agent = "default", sessi
|
|
|
69
87
|
if (dbg) debug("capture", "current turn rows", summarizeTranscriptRows(turnRows));
|
|
70
88
|
return captureParsedMessages(parsed, cfg, client, agent, sessionId, {
|
|
71
89
|
kbDetectionMessages: toKbDetectionMessages(turnRows),
|
|
72
|
-
skills: extractSkillSignals(rows)
|
|
90
|
+
skills: extractSkillSignals(rows),
|
|
91
|
+
toolCalls,
|
|
92
|
+
completionReason: captureCompletionReason(rawTurn, completion)
|
|
73
93
|
});
|
|
74
94
|
}
|
|
75
95
|
async function captureParsedMessages(parsed, cfg, client, agent = "default", sessionId, options = {}) {
|
|
76
96
|
const preflight = capturePreflight(cfg, agent);
|
|
77
97
|
if (preflight) return preflight;
|
|
98
|
+
const cleanup = detectMemoryCleanup(options.toolCalls ?? captureToolCalls(options.kbDetectionMessages ?? []));
|
|
99
|
+
if (cleanup.detected) {
|
|
100
|
+
debug("capture", "memory cleanup skipped", { agent, sessionId, operation: cleanup.operation, source: cleanup.source });
|
|
101
|
+
return { captured: false, reason: "memory_cleanup_skip", messageCount: 0 };
|
|
102
|
+
}
|
|
78
103
|
if (parsed.length === 0) {
|
|
79
104
|
return { captured: false, reason: "empty_messages", messageCount: 0 };
|
|
80
105
|
}
|
|
@@ -101,6 +126,7 @@ async function captureParsedMessages(parsed, cfg, client, agent = "default", ses
|
|
|
101
126
|
messageCount: 0
|
|
102
127
|
};
|
|
103
128
|
}
|
|
129
|
+
if (options.completionReason) return { captured: false, reason: options.completionReason, messageCount: 0 };
|
|
104
130
|
const rawMessages = turn.map((m) => ({ role: m.role, content: m.content }));
|
|
105
131
|
const filtered = filterMessagesForExtraction(rawMessages);
|
|
106
132
|
if (dbg) debug("capture", "filtered messages", summarizeTextMessages(filtered));
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
listKnowledgeBases
|
|
4
|
+
} from "./chunk-EX6SM7I3.js";
|
|
2
5
|
import {
|
|
3
6
|
isConnectionError,
|
|
4
7
|
resetCircuit,
|
|
5
8
|
tripCircuit
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import {
|
|
8
|
-
listKnowledgeBases
|
|
9
|
-
} from "./chunk-JM7EOAQZ.js";
|
|
9
|
+
} from "./chunk-7CZIQG6Z.js";
|
|
10
10
|
import {
|
|
11
11
|
CtxdbError,
|
|
12
12
|
isDataApiReady,
|
|
13
13
|
resolveDataApiCredential
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HUX2XS5P.js";
|
|
15
15
|
|
|
16
16
|
// src/lib/kb-catalog.ts
|
|
17
17
|
function sanitizeKeyEntities(raw) {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
fetchKbCatalogBlock,
|
|
4
4
|
recallTurn
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C66FQHNI.js";
|
|
6
6
|
import {
|
|
7
7
|
debug
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HUX2XS5P.js";
|
|
9
9
|
|
|
10
10
|
// src/lib/warmup-recall.ts
|
|
11
11
|
import { execSync } from "node:child_process";
|