@aliyunrds/ctxdb 1.0.4 → 1.0.6
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 +66 -14
- package/dist/{chunk-SAQT6VL6.js → chunk-6BB65W5W.js} +2 -2
- package/dist/{chunk-BVCDRUU4.js → chunk-7EIJB5LA.js} +7 -3
- package/dist/{chunk-JFTKYEVN.js → chunk-ARZX2RLR.js} +55 -7
- package/dist/{chunk-USMJLDBD.js → chunk-B7JCQL4O.js} +1 -1
- package/dist/{chunk-CWGF5D52.js → chunk-BHRWAU3E.js} +13 -6
- package/dist/{chunk-3PFMHU3C.js → chunk-L4GVGVOP.js} +4 -3
- package/dist/{chunk-Q4JYST7K.js → chunk-VHNHVMCA.js} +137 -20
- package/dist/{chunk-BQA7YSXT.js → chunk-Z6OHSEF2.js} +20 -16
- package/dist/cli/main.js +291 -77
- package/dist/hooks/hermes-post-llm-call.js +3 -3
- package/dist/hooks/hermes-pre-llm-call.js +31 -9
- package/dist/hooks/session-start.js +14 -6
- package/dist/hooks/stop.js +3 -3
- package/dist/hooks/user-prompt-submit.js +13 -6
- package/dist/opencode/index.js +657 -208
- package/dist/setup/skills/contextdb-knowledge/SKILL.md +7 -5
- package/dist/setup/skills/contextdb-memory/SKILL.md +1 -1
- package/dist/workers/version-check.js +1 -1
- package/package.json +2 -2
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import {
|
|
3
3
|
HOOK_TIMEOUT_MS,
|
|
4
4
|
composeSessionStart
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-BHRWAU3E.js";
|
|
6
6
|
import {
|
|
7
7
|
composeUserPromptSubmit
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-7EIJB5LA.js";
|
|
9
9
|
import {
|
|
10
10
|
fetchKbCatalogBlock
|
|
11
|
-
} from "../chunk-
|
|
12
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-VHNHVMCA.js";
|
|
12
|
+
import "../chunk-L4GVGVOP.js";
|
|
13
13
|
import {
|
|
14
14
|
isCircuitOpen
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-B7JCQL4O.js";
|
|
16
16
|
import {
|
|
17
17
|
HttpClient,
|
|
18
18
|
agentFromArgvWithFallback,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isComplete,
|
|
21
21
|
load,
|
|
22
22
|
setDebug
|
|
23
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-ARZX2RLR.js";
|
|
24
24
|
import {
|
|
25
25
|
shouldSkipHooks
|
|
26
26
|
} from "../chunk-UEKR2Z3S.js";
|
|
@@ -41,7 +41,15 @@ function extractHermesPreLlmCall(event) {
|
|
|
41
41
|
return {
|
|
42
42
|
prompt: firstString(extra.user_message, event.user_message, event.prompt),
|
|
43
43
|
cwd: firstString(event.cwd, extra.cwd),
|
|
44
|
-
isFirstTurn: extra.is_first_turn === true || event.is_first_turn === true
|
|
44
|
+
isFirstTurn: extra.is_first_turn === true || event.is_first_turn === true,
|
|
45
|
+
sessionId: firstString(
|
|
46
|
+
event.session_id,
|
|
47
|
+
event.sessionId,
|
|
48
|
+
event.sessionID,
|
|
49
|
+
extra.session_id,
|
|
50
|
+
extra.sessionId,
|
|
51
|
+
extra.sessionID
|
|
52
|
+
) || null
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
55
|
function formatHermesPreLlmCallStdout(ctx) {
|
|
@@ -50,13 +58,26 @@ function formatHermesPreLlmCallStdout(ctx) {
|
|
|
50
58
|
async function composeHermesPreLlmCall(cfg, agent, client, input) {
|
|
51
59
|
const pieces = [];
|
|
52
60
|
const sessionStartNeeded = input.isFirstTurn && Boolean(input.cwd) && (cfg.warmupRecall || cfg.kbCatalogInjection === "session_start");
|
|
53
|
-
const sessionStart = sessionStartNeeded ? await composeSessionStart(
|
|
61
|
+
const sessionStart = sessionStartNeeded ? await composeSessionStart(
|
|
62
|
+
cfg,
|
|
63
|
+
agent,
|
|
64
|
+
client,
|
|
65
|
+
input.cwd,
|
|
66
|
+
HOOK_TIMEOUT_MS,
|
|
67
|
+
input.sessionId
|
|
68
|
+
) : void 0;
|
|
54
69
|
if (sessionStart?.ctx) pieces.push(sessionStart.ctx);
|
|
55
70
|
const repeatSessionCatalog = cfg.kbCatalogInjection === "session_start" && !sessionStartNeeded;
|
|
56
71
|
const recallNeeded = cfg.autoRecall && Boolean(input.prompt.trim());
|
|
57
72
|
const [kbCatalogBlock, recall] = await Promise.all([
|
|
58
73
|
repeatSessionCatalog ? fetchKbCatalogBlock(client, agent).catch(() => "") : Promise.resolve(""),
|
|
59
|
-
recallNeeded ? composeUserPromptSubmit(
|
|
74
|
+
recallNeeded ? composeUserPromptSubmit(
|
|
75
|
+
cfg,
|
|
76
|
+
agent,
|
|
77
|
+
client,
|
|
78
|
+
input.prompt,
|
|
79
|
+
input.sessionId
|
|
80
|
+
) : Promise.resolve(void 0)
|
|
60
81
|
]);
|
|
61
82
|
if (kbCatalogBlock) pieces.push(kbCatalogBlock);
|
|
62
83
|
if (recall?.ctx) pieces.push(recall.ctx);
|
|
@@ -91,6 +112,7 @@ async function main() {
|
|
|
91
112
|
prompt: input.prompt.slice(0, 200),
|
|
92
113
|
cwd: input.cwd,
|
|
93
114
|
isFirstTurn: input.isFirstTurn,
|
|
115
|
+
sessionId: input.sessionId,
|
|
94
116
|
userId: cfg.userId
|
|
95
117
|
});
|
|
96
118
|
const wantsRecall = cfg.autoRecall && Boolean(input.prompt.trim());
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
HOOK_TIMEOUT_MS,
|
|
4
4
|
composeSessionStart,
|
|
5
5
|
formatSessionStartStdout
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-BHRWAU3E.js";
|
|
7
|
+
import "../chunk-VHNHVMCA.js";
|
|
8
|
+
import "../chunk-L4GVGVOP.js";
|
|
9
9
|
import {
|
|
10
10
|
isCircuitOpen
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-B7JCQL4O.js";
|
|
12
12
|
import {
|
|
13
13
|
HttpClient,
|
|
14
14
|
agentFromArgvWithFallback,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
isComplete,
|
|
17
17
|
load,
|
|
18
18
|
setDebug
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ARZX2RLR.js";
|
|
20
20
|
import {
|
|
21
21
|
shouldSkipHooks
|
|
22
22
|
} from "../chunk-UEKR2Z3S.js";
|
|
@@ -46,6 +46,7 @@ async function main() {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
const cwd = typeof event.cwd === "string" ? event.cwd : "";
|
|
49
|
+
const sessionId = typeof event.session_id === "string" ? event.session_id : typeof event.sessionId === "string" ? event.sessionId : null;
|
|
49
50
|
if (!cwd) return 0;
|
|
50
51
|
const cfg = load({ agent });
|
|
51
52
|
setDebug(cfg.debug);
|
|
@@ -64,7 +65,14 @@ async function main() {
|
|
|
64
65
|
apiKey: cfg.apiKey,
|
|
65
66
|
timeoutMs: HOOK_TIMEOUT_MS
|
|
66
67
|
});
|
|
67
|
-
const composed = await composeSessionStart(
|
|
68
|
+
const composed = await composeSessionStart(
|
|
69
|
+
cfg,
|
|
70
|
+
agent,
|
|
71
|
+
client,
|
|
72
|
+
cwd,
|
|
73
|
+
HOOK_TIMEOUT_MS,
|
|
74
|
+
sessionId
|
|
75
|
+
);
|
|
68
76
|
if (composed.warmupTimedOut) {
|
|
69
77
|
process.stderr.write("ctxdb warmup: timeout\n");
|
|
70
78
|
}
|
package/dist/hooks/stop.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
captureTurn
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-6BB65W5W.js";
|
|
5
|
+
import "../chunk-B7JCQL4O.js";
|
|
6
6
|
import {
|
|
7
7
|
HttpClient,
|
|
8
8
|
agentFromArgvWithFallback,
|
|
9
9
|
debug,
|
|
10
10
|
load,
|
|
11
11
|
setDebug
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-ARZX2RLR.js";
|
|
13
13
|
import {
|
|
14
14
|
shouldSkipHooks
|
|
15
15
|
} from "../chunk-UEKR2Z3S.js";
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
composeUserPromptSubmit,
|
|
4
4
|
formatUserPromptSubmitStdout
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-7EIJB5LA.js";
|
|
6
|
+
import "../chunk-VHNHVMCA.js";
|
|
7
|
+
import "../chunk-L4GVGVOP.js";
|
|
8
8
|
import {
|
|
9
9
|
isCircuitOpen
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-B7JCQL4O.js";
|
|
11
11
|
import {
|
|
12
12
|
HttpClient,
|
|
13
13
|
agentFromArgvWithFallback,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
isComplete,
|
|
16
16
|
load,
|
|
17
17
|
setDebug
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-ARZX2RLR.js";
|
|
19
19
|
import {
|
|
20
20
|
shouldSkipHooks
|
|
21
21
|
} from "../chunk-UEKR2Z3S.js";
|
|
@@ -45,6 +45,7 @@ async function main() {
|
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
const prompt = typeof event.prompt === "string" ? event.prompt : "";
|
|
48
|
+
const sessionId = typeof event.session_id === "string" ? event.session_id : typeof event.sessionId === "string" ? event.sessionId : null;
|
|
48
49
|
if (!prompt.trim()) return 0;
|
|
49
50
|
const cfg = load({ agent });
|
|
50
51
|
setDebug(cfg.debug);
|
|
@@ -60,7 +61,13 @@ async function main() {
|
|
|
60
61
|
return 0;
|
|
61
62
|
}
|
|
62
63
|
const client = new HttpClient({ baseUrl: cfg.baseUrl, apiKey: cfg.apiKey, timeoutMs: 5e3 });
|
|
63
|
-
const { ctx, recall, kbBlock } = await composeUserPromptSubmit(
|
|
64
|
+
const { ctx, recall, kbBlock } = await composeUserPromptSubmit(
|
|
65
|
+
cfg,
|
|
66
|
+
agent,
|
|
67
|
+
client,
|
|
68
|
+
prompt,
|
|
69
|
+
sessionId
|
|
70
|
+
);
|
|
64
71
|
if (!recall.ok && !recall.additionalContext && !kbBlock) {
|
|
65
72
|
const reason = recall.reason ?? "no_context";
|
|
66
73
|
debug("recall", `no result: ${reason}`, recall);
|