@aliyunrds/ctxdb 1.0.8-beta.2 → 1.0.8-beta.4

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.
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureParsedMessages
4
- } from "../chunk-LYHGJOHM.js";
5
- import "../chunk-X75B57M2.js";
4
+ } from "../chunk-76AXXLVE.js";
5
+ import "../chunk-5DGRNP55.js";
6
6
  import {
7
7
  HttpClient,
8
8
  agentFromArgvWithFallback,
9
9
  debug,
10
10
  load,
11
+ resolveDataApiCredential,
11
12
  setDebug
12
- } from "../chunk-DMS5YHIK.js";
13
+ } from "../chunk-SVO6H62S.js";
13
14
  import {
14
15
  shouldSkipHooks
15
16
  } from "../chunk-5ML4VSXN.js";
16
- import "../chunk-R67JELM7.js";
17
- import "../chunk-VIG4SYLU.js";
17
+ import "../chunk-5ITT5GSP.js";
18
+ import "../chunk-PI2SUS3M.js";
18
19
 
19
20
  // src/hooks/hermes-post-llm-call.ts
20
21
  import { pathToFileURL } from "url";
@@ -170,19 +171,20 @@ async function main() {
170
171
  }
171
172
  const input = extractHermesPostLlmCall(event);
172
173
  const cfg = load({ agent });
174
+ const credential = resolveDataApiCredential(cfg);
173
175
  setDebug(cfg.debug);
174
176
  debug("hermes.post_llm_call", "start", {
175
177
  sessionId: input.sessionId,
176
178
  messageCount: input.messages.length,
177
179
  userId: cfg.userId
178
180
  });
179
- if (!cfg.apiKey || !cfg.baseUrl) {
181
+ if (!cfg.baseUrl || !credential) {
180
182
  debug("hermes.post_llm_call", "skip (config incomplete)");
181
183
  return 0;
182
184
  }
183
185
  const client = new HttpClient({
184
186
  baseUrl: cfg.baseUrl,
185
- apiKey: cfg.apiKey,
187
+ credential,
186
188
  timeoutMs: 5e3
187
189
  });
188
190
  const result = await captureParsedMessages(
@@ -2,30 +2,30 @@
2
2
  import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart
5
- } from "../chunk-5ZSZMN2T.js";
5
+ } from "../chunk-6MEWI73Y.js";
6
6
  import {
7
7
  composeUserPromptSubmit
8
- } from "../chunk-4FCZ2TZM.js";
8
+ } from "../chunk-O6MKQ2I3.js";
9
9
  import {
10
10
  fetchKbCatalogBlock
11
- } from "../chunk-H33NUAHP.js";
12
- import "../chunk-CULTDVI2.js";
11
+ } from "../chunk-WJTV7JNR.js";
12
+ import "../chunk-ZW7YXNJ6.js";
13
13
  import {
14
14
  isCircuitOpen
15
- } from "../chunk-X75B57M2.js";
15
+ } from "../chunk-5DGRNP55.js";
16
16
  import {
17
17
  HttpClient,
18
18
  agentFromArgvWithFallback,
19
19
  debug,
20
- isComplete,
21
20
  load,
21
+ resolveDataApiCredential,
22
22
  setDebug
23
- } from "../chunk-DMS5YHIK.js";
23
+ } from "../chunk-SVO6H62S.js";
24
24
  import {
25
25
  shouldSkipHooks
26
26
  } from "../chunk-5ML4VSXN.js";
27
- import "../chunk-R67JELM7.js";
28
- import "../chunk-VIG4SYLU.js";
27
+ import "../chunk-5ITT5GSP.js";
28
+ import "../chunk-PI2SUS3M.js";
29
29
 
30
30
  // src/hooks/hermes-pre-llm-call.ts
31
31
  import { pathToFileURL } from "url";
@@ -109,6 +109,7 @@ async function main() {
109
109
  }
110
110
  const input = extractHermesPreLlmCall(event);
111
111
  const cfg = load({ agent });
112
+ const credential = resolveDataApiCredential(cfg);
112
113
  setDebug(cfg.debug);
113
114
  debug("hermes.pre_llm_call", "start", {
114
115
  prompt: input.prompt.slice(0, 200),
@@ -120,7 +121,7 @@ async function main() {
120
121
  const wantsRecall = cfg.autoRecall && Boolean(input.prompt.trim());
121
122
  const wantsSessionStart = input.isFirstTurn && Boolean(input.cwd) && (cfg.warmupRecall || cfg.kbCatalogInjection === "session_start");
122
123
  const wantsRepeatedSessionCatalog = cfg.kbCatalogInjection === "session_start";
123
- if (!isComplete(cfg) || !wantsRecall && !wantsSessionStart && !wantsRepeatedSessionCatalog) {
124
+ if (!cfg.baseUrl || !credential || !wantsRecall && !wantsSessionStart && !wantsRepeatedSessionCatalog) {
124
125
  debug("hermes.pre_llm_call", "skip (config incomplete or no enabled injection)");
125
126
  return 0;
126
127
  }
@@ -132,7 +133,7 @@ async function main() {
132
133
  }
133
134
  const client = new HttpClient({
134
135
  baseUrl: cfg.baseUrl,
135
- apiKey: cfg.apiKey,
136
+ credential,
136
137
  timeoutMs: HOOK_TIMEOUT_MS
137
138
  });
138
139
  const composed = await composeHermesPreLlmCall(cfg, agent, client, input);
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  shouldSkipHooks
4
4
  } from "../chunk-5ML4VSXN.js";
5
- import "../chunk-VIG4SYLU.js";
5
+ import "../chunk-PI2SUS3M.js";
6
6
 
7
7
  // src/hooks/pre-tool-use.ts
8
8
  async function main() {
@@ -3,25 +3,25 @@ import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart,
5
5
  formatSessionStartStdout
6
- } from "../chunk-5ZSZMN2T.js";
7
- import "../chunk-H33NUAHP.js";
8
- import "../chunk-CULTDVI2.js";
6
+ } from "../chunk-6MEWI73Y.js";
7
+ import "../chunk-WJTV7JNR.js";
8
+ import "../chunk-ZW7YXNJ6.js";
9
9
  import {
10
10
  isCircuitOpen
11
- } from "../chunk-X75B57M2.js";
11
+ } from "../chunk-5DGRNP55.js";
12
12
  import {
13
13
  HttpClient,
14
14
  agentFromArgvWithFallback,
15
15
  debug,
16
- isComplete,
17
16
  load,
17
+ resolveDataApiCredential,
18
18
  setDebug
19
- } from "../chunk-DMS5YHIK.js";
19
+ } from "../chunk-SVO6H62S.js";
20
20
  import {
21
21
  shouldSkipHooks
22
22
  } from "../chunk-5ML4VSXN.js";
23
- import "../chunk-R67JELM7.js";
24
- import "../chunk-VIG4SYLU.js";
23
+ import "../chunk-5ITT5GSP.js";
24
+ import "../chunk-PI2SUS3M.js";
25
25
 
26
26
  // src/hooks/session-start.ts
27
27
  import { pathToFileURL } from "url";
@@ -51,10 +51,11 @@ async function main() {
51
51
  const sessionId = typeof event.session_id === "string" ? event.session_id : typeof event.sessionId === "string" ? event.sessionId : null;
52
52
  if (!cwd) return 0;
53
53
  const cfg = load({ agent });
54
+ const credential = resolveDataApiCredential(cfg);
54
55
  setDebug(cfg.debug);
55
56
  debug("warmup", "start", { cwd, userId: cfg.userId });
56
57
  const kbInjectHere = cfg.kbCatalogInjection === "session_start";
57
- if (!isComplete(cfg) || !cfg.warmupRecall && !kbInjectHere) {
58
+ if (!cfg.baseUrl || !credential || !cfg.warmupRecall && !kbInjectHere) {
58
59
  debug("warmup", "skip (config incomplete or both warmup+kb off)");
59
60
  return 0;
60
61
  }
@@ -64,7 +65,7 @@ async function main() {
64
65
  }
65
66
  const client = new HttpClient({
66
67
  baseUrl: cfg.baseUrl,
67
- apiKey: cfg.apiKey,
68
+ credential,
68
69
  timeoutMs: HOOK_TIMEOUT_MS
69
70
  });
70
71
  const composed = await composeSessionStart(
@@ -1,20 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureTurn
4
- } from "../chunk-LYHGJOHM.js";
5
- import "../chunk-X75B57M2.js";
4
+ } from "../chunk-76AXXLVE.js";
5
+ import "../chunk-5DGRNP55.js";
6
6
  import {
7
7
  HttpClient,
8
8
  agentFromArgvWithFallback,
9
9
  debug,
10
10
  load,
11
+ resolveDataApiCredential,
11
12
  setDebug
12
- } from "../chunk-DMS5YHIK.js";
13
+ } from "../chunk-SVO6H62S.js";
13
14
  import {
14
15
  shouldSkipHooks
15
16
  } from "../chunk-5ML4VSXN.js";
16
- import "../chunk-R67JELM7.js";
17
- import "../chunk-VIG4SYLU.js";
17
+ import "../chunk-5ITT5GSP.js";
18
+ import "../chunk-PI2SUS3M.js";
18
19
 
19
20
  // src/hooks/stop.ts
20
21
  async function readStdinJson() {
@@ -47,13 +48,14 @@ async function main() {
47
48
  if (typeof transcriptPath !== "string" || !transcriptPath) return 0;
48
49
  const sessionId = extractHookSessionId(event);
49
50
  const cfg = load({ agent });
51
+ const credential = resolveDataApiCredential(cfg);
50
52
  setDebug(cfg.debug);
51
53
  debug("capture", "start", { transcriptPath, userId: cfg.userId });
52
- if (!cfg.apiKey || !cfg.baseUrl) {
54
+ if (!cfg.baseUrl || !credential) {
53
55
  debug("capture", "skip (config incomplete)");
54
56
  return 0;
55
57
  }
56
- const client = new HttpClient({ baseUrl: cfg.baseUrl, apiKey: cfg.apiKey, timeoutMs: 5e3 });
58
+ const client = new HttpClient({ baseUrl: cfg.baseUrl, credential, timeoutMs: 5e3 });
57
59
  const result = await captureTurn(transcriptPath, cfg, client, agent, sessionId);
58
60
  if (result.captured) {
59
61
  debug("capture", `ok (${result.messageCount} msgs)`, result);
@@ -2,25 +2,25 @@
2
2
  import {
3
3
  composeUserPromptSubmit,
4
4
  formatUserPromptSubmitStdout
5
- } from "../chunk-4FCZ2TZM.js";
6
- import "../chunk-H33NUAHP.js";
7
- import "../chunk-CULTDVI2.js";
5
+ } from "../chunk-O6MKQ2I3.js";
6
+ import "../chunk-WJTV7JNR.js";
7
+ import "../chunk-ZW7YXNJ6.js";
8
8
  import {
9
9
  isCircuitOpen
10
- } from "../chunk-X75B57M2.js";
10
+ } from "../chunk-5DGRNP55.js";
11
11
  import {
12
12
  HttpClient,
13
13
  agentFromArgvWithFallback,
14
14
  debug,
15
- isComplete,
16
15
  load,
16
+ resolveDataApiCredential,
17
17
  setDebug
18
- } from "../chunk-DMS5YHIK.js";
18
+ } from "../chunk-SVO6H62S.js";
19
19
  import {
20
20
  shouldSkipHooks
21
21
  } from "../chunk-5ML4VSXN.js";
22
- import "../chunk-R67JELM7.js";
23
- import "../chunk-VIG4SYLU.js";
22
+ import "../chunk-5ITT5GSP.js";
23
+ import "../chunk-PI2SUS3M.js";
24
24
 
25
25
  // src/hooks/user-prompt-submit.ts
26
26
  import { pathToFileURL } from "url";
@@ -50,9 +50,10 @@ async function main() {
50
50
  const sessionId = typeof event.session_id === "string" ? event.session_id : typeof event.sessionId === "string" ? event.sessionId : null;
51
51
  if (!prompt.trim()) return 0;
52
52
  const cfg = load({ agent });
53
+ const credential = resolveDataApiCredential(cfg);
53
54
  setDebug(cfg.debug);
54
55
  debug("recall", "start", { prompt: prompt.slice(0, 200), userId: cfg.userId });
55
- if (!isComplete(cfg) || !cfg.autoRecall) {
56
+ if (!cfg.baseUrl || !credential || !cfg.autoRecall) {
56
57
  debug("recall", "skip (config incomplete or autoRecall=false)");
57
58
  return 0;
58
59
  }
@@ -62,7 +63,7 @@ async function main() {
62
63
  `);
63
64
  return 0;
64
65
  }
65
- const client = new HttpClient({ baseUrl: cfg.baseUrl, apiKey: cfg.apiKey, timeoutMs: 5e3 });
66
+ const client = new HttpClient({ baseUrl: cfg.baseUrl, credential, timeoutMs: 5e3 });
66
67
  const { ctx, recall, kbBlock } = await composeUserPromptSubmit(
67
68
  cfg,
68
69
  agent,