@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/dist/cli/main.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  uploadFile,
40
40
  uploadText,
41
41
  validateLocalFile
42
- } from "../chunk-JM7EOAQZ.js";
42
+ } from "../chunk-EX6SM7I3.js";
43
43
  import {
44
44
  AGENT_CHOICES,
45
45
  CtxdbError,
@@ -100,7 +100,7 @@ import {
100
100
  withStateLock,
101
101
  writeInstalledPkgVersion,
102
102
  writeState
103
- } from "../chunk-HHKQPWYI.js";
103
+ } from "../chunk-HUX2XS5P.js";
104
104
  import {
105
105
  DISTRIBUTION_MANIFEST
106
106
  } from "../chunk-5ITT5GSP.js";
@@ -987,7 +987,8 @@ async function runSetupAll(options = {}, dependencies = {}) {
987
987
  agent,
988
988
  apiKey,
989
989
  login: options.login,
990
- // Public setup resets the endpoint by default, including shared logins.
990
+ site: options.site,
991
+ // Public setup resolves site assertions and preserves each credential's endpoint.
991
992
  baseUrl: options.baseUrl ?? (publicAuth ? void 0 : existing?.baseUrl),
992
993
  userId: options.userId ?? existing?.userId,
993
994
  persistCredential: options.persistCredential,
@@ -2275,7 +2276,7 @@ async function runUpgrade(options = {}) {
2275
2276
  }
2276
2277
 
2277
2278
  // src/cli/setup-cli.ts
2278
- import { validateDataBaseUrl as validateDataBaseUrl2 } from "@aliyunrds/ctxdb-shared";
2279
+ import { validateDataBaseUrl as validateDataBaseUrl2, parsePublicSite, siteBaseUrl } from "@aliyunrds/ctxdb-shared";
2279
2280
  var HELP = `ctxdb setup \u2014 configure an agent
2280
2281
 
2281
2282
  USAGE
@@ -2348,7 +2349,7 @@ async function setup(args) {
2348
2349
  ).replace(
2349
2350
  " --base-url <url> Server URL (default: https://api.cn-hangzhou.agentcontext.aliyuncs.com)\n",
2350
2351
  ""
2351
- ) : HELP.replace("[--api-key=K]", "[--api-key=K | --login=default|ID]").replace(" --api-key <key> API key (required on first setup)", " --api-key <key> Replace this Agent's authentication with an API key\n --login <default|ID> Bind an existing login; ordinary setup preserves existing authentication").replace("BEHAVIOR\n", "BEHAVIOR\n First-time auth binds default's login when available. Explicit unbind or invalid auth is preserved.\n")
2352
+ ) : HELP.replace("[--base-url=URL]", "[--site=cn|intl | --base-url=URL]").replace(" --base-url <url> Server URL (default: https://api.cn-hangzhou.agentcontext.aliyuncs.com)", " --site <cn|intl> Official site; intl selects Singapore\n --base-url <url> Custom service URL; omitted URL preserves existing credentials").replace("[--api-key=K]", "[--api-key=K | --login=default|ID]").replace(" --api-key <key> API key (required on first setup)", " --api-key <key> Replace this Agent's authentication with an API key\n --login <default|ID> Bind an existing login; ordinary setup preserves existing authentication").replace("BEHAVIOR\n", "BEHAVIOR\n First-time auth binds default's login when available. Explicit unbind or invalid auth is preserved.\n")
2352
2353
  );
2353
2354
  return 0;
2354
2355
  }
@@ -2376,6 +2377,15 @@ async function setup(args) {
2376
2377
  );
2377
2378
  return 2;
2378
2379
  }
2380
+ let site;
2381
+ try {
2382
+ site = parsePublicSite(args.flags.site);
2383
+ siteBaseUrl(site, args.flags["base-url"]);
2384
+ if (site && DISTRIBUTION_MANIFEST.capabilities.managedCredentials) throw new Error("--site is supported only in the public distribution.");
2385
+ } catch (error) {
2386
+ process.stderr.write(error.message + "\n");
2387
+ return 2;
2388
+ }
2379
2389
  const baseUrl = args.flags["base-url"];
2380
2390
  if (baseUrl !== void 0) {
2381
2391
  try {
@@ -2394,6 +2404,7 @@ async function setup(args) {
2394
2404
  const result2 = await runSetupAll({
2395
2405
  apiKey: explicitApiKey,
2396
2406
  login,
2407
+ site,
2397
2408
  baseUrl,
2398
2409
  userId: typeof args.flags["user-id"] === "string" ? args.flags["user-id"] : void 0,
2399
2410
  persistCredential,
@@ -2428,6 +2439,7 @@ ${highlightInlineCode(hint)}
2428
2439
  agent,
2429
2440
  apiKey: explicitApiKey,
2430
2441
  login,
2442
+ site,
2431
2443
  baseUrl,
2432
2444
  userId: typeof args.flags["user-id"] === "string" ? args.flags["user-id"] : void 0,
2433
2445
  persistCredential,
@@ -6031,9 +6043,9 @@ function publicSetupSpec(managedCredentials) {
6031
6043
  option("--login", "Bind an existing login ID; default selects the default Agent's current login.", {
6032
6044
  valueName: "default|ID"
6033
6045
  }),
6034
- option("--base-url", "ContextDB DATA API base URL.", {
6035
- valueName: "url",
6036
- default: "https://api.cn-hangzhou.agentcontext.aliyuncs.com"
6046
+ option("--site", "Official site: cn (China) or intl (Singapore).", { valueName: "cn|intl", choices: ["cn", "intl"] }),
6047
+ option("--base-url", "Custom DATA URL; omitted URL preserves the saved endpoint.", {
6048
+ valueName: "url"
6037
6049
  })
6038
6050
  ];
6039
6051
  return leaf(
@@ -6042,7 +6054,7 @@ function publicSetupSpec(managedCredentials) {
6042
6054
  setup,
6043
6055
  details({
6044
6056
  usage: [
6045
- `ctxdb setup [--agent <${SUPPORTED_AGENT_CHOICES}> | --all]${managedCredentials ? "" : " [--api-key=<key> | --login=<default|ID>] [--base-url=<url>]"} [--user-id=<id>] [--no-install-skill] [--no-validate] [--json]`
6057
+ `ctxdb setup [--agent <${SUPPORTED_AGENT_CHOICES}> | --all]${managedCredentials ? "" : " [--api-key=<key> | --login=<default|ID>] [--site=<cn|intl> | --base-url=<url>]"} [--user-id=<id>] [--no-install-skill] [--no-validate] [--json]`
6046
6058
  ],
6047
6059
  options: [
6048
6060
  option("--agent", "Configure exactly one built-in Agent; omit for the CLI-only default profile.", {
@@ -6069,6 +6081,7 @@ function publicSetupSpec(managedCredentials) {
6069
6081
  "--agent and --all are mutually exclusive.",
6070
6082
  ...!managedCredentials ? [
6071
6083
  "--api-key and --login are mutually exclusive.",
6084
+ "--site and --base-url are mutually exclusive. Switching sites requires login or a new API key.",
6072
6085
  "Unset CTXDB_ACCESS_TOKEN and CTXDB_API_KEY before explicitly switching persisted authentication."
6073
6086
  ] : []
6074
6087
  ],
@@ -7374,13 +7387,15 @@ import {
7374
7387
  rejectAuthEnvironment,
7375
7388
  releaseLogin,
7376
7389
  collectUnusedLogins,
7377
- validateDataBaseUrl as validateDataBaseUrl3
7390
+ validateDataBaseUrl as validateDataBaseUrl3,
7391
+ parsePublicSite as parsePublicSite2,
7392
+ siteBaseUrl as siteBaseUrl2,
7393
+ PUBLIC_SITES as PUBLIC_SITES2
7378
7394
  } from "@aliyunrds/ctxdb-shared";
7379
7395
 
7380
7396
  // src/lib/oauth-login-config.ts
7381
7397
  import { existsSync as existsSync7, readFileSync as readFileSync3 } from "node:fs";
7382
- import { isOfficialProductionUrl, normalizeCoreOrigin } from "@aliyunrds/ctxdb-shared";
7383
- var PRODUCTION_AUTHORIZATION_URL = "https://rdsnext.console.aliyun.com/contextDbCliAuthorization/cn-hangzhou";
7398
+ import { PUBLIC_SITES, publicSiteForUrl, normalizeCoreOrigin } from "@aliyunrds/ctxdb-shared";
7384
7399
  function authorizationPage(value2) {
7385
7400
  if (typeof value2 !== "string" || !value2.trim()) throw new Error();
7386
7401
  const url = new URL(value2);
@@ -7395,7 +7410,8 @@ function consoleAuthorizationBase(path, core, loginUrl) {
7395
7410
  throw new Error("--login-url requires an HTTPS page URL without credentials, query parameters or fragment. No authorization request was created.");
7396
7411
  }
7397
7412
  }
7398
- const fallback = isOfficialProductionUrl(core) ? PRODUCTION_AUTHORIZATION_URL : void 0;
7413
+ const site = publicSiteForUrl(core);
7414
+ const fallback = site ? PUBLIC_SITES[site].authorizationUrl : void 0;
7399
7415
  if (!existsSync7(path)) return fallback;
7400
7416
  try {
7401
7417
  const raw = JSON.parse(readFileSync3(path, "utf8"));
@@ -7439,7 +7455,7 @@ function openBrowser(url) {
7439
7455
  }
7440
7456
 
7441
7457
  // src/cli/device-auth-cli.ts
7442
- var usage = "ctxdb login [--agent <name> | --login <default|ID>] [--base-url <core-origin> | --server <core-origin>] [--login-url <console-page>] [--yes] [--device-code] [--no-browser] [--json]\n";
7458
+ var usage = "ctxdb login [--agent <name> | --login <default|ID>] [--site <cn|intl> | --base-url <core-origin> | --server <core-origin>] [--login-url <console-page>] [--yes] [--device-code] [--no-browser] [--json]\n";
7443
7459
  function createPublicAuthCommands(dependencies = {}) {
7444
7460
  const env = () => dependencies.env ?? process.env;
7445
7461
  const stdout = dependencies.stdout ?? ((s) => {
@@ -7452,7 +7468,7 @@ function createPublicAuthCommands(dependencies = {}) {
7452
7468
  const launchBrowser = dependencies.openBrowser ?? openBrowser;
7453
7469
  const output = (value2, json) => stdout(json ? JSON.stringify(value2) + "\n" : String(value2) + "\n");
7454
7470
  function options(args, command) {
7455
- const allowed = ["agent", "json", "help", "h", ...command === "login" ? ["base-url", "login-url", "server", "device-code", "no-browser", "login", "yes"] : command === "logout" ? ["login", "yes"] : command === "status" ? ["all"] : []];
7471
+ const allowed = ["agent", "json", "help", "h", ...command === "login" ? ["site", "base-url", "login-url", "server", "device-code", "no-browser", "login", "yes"] : command === "logout" ? ["login", "yes"] : command === "status" ? ["all"] : []];
7456
7472
  if (args.positional.length || Object.keys(args.flags).some((k) => !allowed.includes(k))) throw new Error("Unsupported authentication option.");
7457
7473
  for (const flag of ["json", "help", "h", "device-code", "no-browser", "yes", "all"]) {
7458
7474
  if (args.flags[flag] !== void 0 && args.flags[flag] !== true) throw new Error("Invalid boolean authentication option.");
@@ -7493,10 +7509,13 @@ function createPublicAuthCommands(dependencies = {}) {
7493
7509
  if (args.flags["base-url"] !== void 0 && args.flags.server !== void 0) throw new Error("Use --base-url or its legacy alias --server, not both.");
7494
7510
  const explicitBase = args.flags["base-url"] ?? args.flags.server;
7495
7511
  if (explicitBase !== void 0) validateDataBaseUrl3(explicitBase, true);
7512
+ const site = parsePublicSite2(args.flags.site);
7513
+ const presetBase = siteBaseUrl2(site, explicitBase);
7514
+ if (site && args.flags["login-url"] !== void 0) throw new Error("--site and --login-url are mutually exclusive.");
7496
7515
  const pending = beginLogin(path, agent, name);
7497
7516
  await confirmImpact(name ? pending.users[0] ?? agent : agent, pending.users, args, "Reauthorizing this login");
7498
- const baseUrl = normalizeCoreOrigin2(explicitBase ?? DEFAULT_BASE_URL);
7499
- const consoleBase = consoleAuthorizationBase(join6(dirname2(path), "device-environments.json"), baseUrl, args.flags["login-url"]);
7517
+ const baseUrl = normalizeCoreOrigin2(presetBase ?? explicitBase ?? pending.previous?.baseUrl ?? load({ path, agent, env: {} }).baseUrl ?? DEFAULT_BASE_URL);
7518
+ const consoleBase = site ? PUBLIC_SITES2[site].authorizationUrl : consoleAuthorizationBase(join6(dirname2(path), "device-environments.json"), baseUrl, args.flags["login-url"]);
7500
7519
  const connection = client(baseUrl), controller = new AbortController();
7501
7520
  let browserOpening = Promise.resolve();
7502
7521
  const interrupt = () => controller.abort();
@@ -7720,10 +7739,11 @@ var ENVIRONMENT_CONSTRAINT = "Unset CTXDB_ACCESS_TOKEN and CTXDB_API_KEY before
7720
7739
  function publicCommands() {
7721
7740
  return [
7722
7741
  leaf("login", "Authorize a public Device Flow login and configure the selected Agent.", deviceLogin, details({
7723
- usage: ["ctxdb login [--agent=<name> | --login=<default|ID>] [--base-url=<core-origin> | --server=<core-origin>] [--login-url=<console-page>] [--device-code] [--no-browser] [--yes] [--json]"],
7742
+ usage: ["ctxdb login [--agent=<name> | --login=<default|ID>] [--site=<cn|intl> | --base-url=<core-origin> | --server=<core-origin>] [--login-url=<console-page>] [--device-code] [--no-browser] [--yes] [--json]"],
7724
7743
  options: [
7725
7744
  AGENT_OPTION2,
7726
7745
  LOGIN_OPTION,
7746
+ option("--site", "Official site: cn (China) or intl (Singapore).", { valueName: "cn|intl", choices: ["cn", "intl"] }),
7727
7747
  option("--base-url", "Core service origin for Device Flow and DATA requests.", { valueName: "core-origin" }),
7728
7748
  option("--server", "Legacy alias for --base-url; do not combine them.", { valueName: "core-origin" }),
7729
7749
  option("--login-url", "HTTPS console authorization page; CLI appends the current user_code.", { valueName: "console-page" }),
@@ -7732,8 +7752,9 @@ function publicCommands() {
7732
7752
  YES_OPTION,
7733
7753
  JSON_OPTION2
7734
7754
  ],
7735
- constraints: ["--agent and --login are mutually exclusive.", "--base-url and --server are mutually exclusive.", ENVIRONMENT_CONSTRAINT],
7755
+ constraints: ["--agent and --login are mutually exclusive.", "--base-url and --server are mutually exclusive.", "--site cannot be combined with --base-url, --server or --login-url.", ENVIRONMENT_CONSTRAINT],
7736
7756
  notes: [
7757
+ "With no site or URL override, reauthorization keeps the saved endpoint; a fresh installation defaults to cn.",
7737
7758
  "Default login creates or updates the default shared login; login for another Agent creates an independent login.",
7738
7759
  "--login reauthorizes the selected existing login while retaining its stable local ID.",
7739
7760
  "Device scope is fixed to default. A non-default Agent login also installs hooks/skills and validates connectivity; no separate setup command is needed.",
@@ -7747,6 +7768,7 @@ function publicCommands() {
7747
7768
  examples: [
7748
7769
  { command: "ctxdb login" },
7749
7770
  { command: "ctxdb login --agent=codex --json" },
7771
+ { command: "ctxdb login --agent=codex --site=intl" },
7750
7772
  { command: "ctxdb login --login=default --yes --json" },
7751
7773
  { command: "ctxdb login --base-url=https://core.example.com --login-url=https://console.example.com/contextDbCliAuthorization/cn-hangzhou" }
7752
7774
  ]
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureParsedMessages
4
- } from "../chunk-EWCB3UQS.js";
5
- import "../chunk-7RMETV4M.js";
6
- import {
7
- shouldSkipHooks
8
- } from "../chunk-5ML4VSXN.js";
4
+ } from "../chunk-4GYXLFNU.js";
9
5
  import "../chunk-SR3M7AL5.js";
6
+ import "../chunk-7CZIQG6Z.js";
10
7
  import {
11
8
  HttpClient,
12
9
  agentFromArgvWithFallback,
@@ -16,12 +13,16 @@ import {
16
13
  sessionBinding,
17
14
  setDebug,
18
15
  skillStopRows
19
- } from "../chunk-HHKQPWYI.js";
16
+ } from "../chunk-HUX2XS5P.js";
20
17
  import "../chunk-5ITT5GSP.js";
18
+ import {
19
+ shouldSkipHooks
20
+ } from "../chunk-5ML4VSXN.js";
21
21
  import "../chunk-PI2SUS3M.js";
22
22
 
23
23
  // src/hooks/hermes-post-llm-call.ts
24
24
  import { pathToFileURL } from "node:url";
25
+ import { selectCaptureTurn, captureText, captureToolCalls, captureCompletionReason } from "@aliyunrds/ctxdb-shared";
25
26
  function asRecord(value) {
26
27
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
27
28
  }
@@ -31,38 +32,15 @@ function firstString(...values) {
31
32
  }
32
33
  return "";
33
34
  }
34
- function textContent(content) {
35
- if (typeof content === "string") return content.trim();
36
- if (!Array.isArray(content)) return "";
37
- const chunks = [];
38
- for (const rawBlock of content) {
39
- if (typeof rawBlock === "string") {
40
- if (rawBlock.trim()) chunks.push(rawBlock.trim());
41
- continue;
42
- }
43
- const block = asRecord(rawBlock);
44
- const text = firstString(block.text, block.content);
45
- if (text.trim()) chunks.push(text.trim());
46
- }
47
- return chunks.join("\n").trim();
48
- }
49
35
  function currentTurnHistory(history) {
50
- const records = history.map(asRecord);
51
- let start = -1;
52
- for (let i = records.length - 1; i >= 0; i--) {
53
- if (records[i].role === "user") {
54
- start = i;
55
- break;
56
- }
57
- }
58
- return start >= 0 ? records.slice(start) : records;
36
+ return selectCaptureTurn(history).map(asRecord);
59
37
  }
60
38
  function parsedHistoryMessages(history) {
61
39
  const messages = [];
62
40
  for (const item of history) {
63
41
  const role = item.role;
64
42
  if (role !== "user" && role !== "assistant") continue;
65
- const content = textContent(item.content);
43
+ const content = captureText(item).trim();
66
44
  if (!content) continue;
67
45
  messages.push({
68
46
  role,
@@ -147,7 +125,15 @@ function extractHermesPostLlmCall(event) {
147
125
  return {
148
126
  sessionId,
149
127
  messages: userMessage && assistantResponse ? explicitMessages : historyMessages.length > 0 ? historyMessages : explicitMessages,
150
- kbDetectionMessages: toHermesKbDetectionMessages(turnHistory)
128
+ kbDetectionMessages: toHermesKbDetectionMessages(turnHistory),
129
+ toolCalls: captureToolCalls(turnHistory),
130
+ completionReason: userMessage && historyMessages.find((m) => m.role === "user")?.content !== userMessage ? "turn_unverified" : captureCompletionReason(turnHistory, {
131
+ // post_llm_call may fire for tool-producing intermediate calls. Require
132
+ // the host's final answer to match the final history message as well.
133
+ lastAssistantMessage: assistantResponse || void 0,
134
+ turnId: firstString(extra.turn_id, event.turn_id) || void 0,
135
+ sessionId
136
+ })
151
137
  };
152
138
  }
153
139
  async function readStdinJson() {
@@ -213,7 +199,7 @@ async function main() {
213
199
  client,
214
200
  agent,
215
201
  input.sessionId,
216
- { kbDetectionMessages: input.kbDetectionMessages }
202
+ { kbDetectionMessages: input.kbDetectionMessages, toolCalls: input.toolCalls, completionReason: input.completionReason }
217
203
  );
218
204
  if (result.captured) {
219
205
  debug("hermes.post_llm_call", `ok (${result.messageCount} msgs)`, result);
@@ -2,20 +2,17 @@
2
2
  import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart
5
- } from "../chunk-WCVCSOFL.js";
5
+ } from "../chunk-CGA7EITY.js";
6
6
  import {
7
7
  composeUserPromptSubmit
8
- } from "../chunk-6XK3RDZ6.js";
8
+ } from "../chunk-BRCQTX2M.js";
9
9
  import {
10
10
  fetchKbCatalogBlock
11
- } from "../chunk-XEX5344F.js";
11
+ } from "../chunk-C66FQHNI.js";
12
+ import "../chunk-EX6SM7I3.js";
12
13
  import {
13
14
  isCircuitOpen
14
- } from "../chunk-7RMETV4M.js";
15
- import {
16
- shouldSkipHooks
17
- } from "../chunk-5ML4VSXN.js";
18
- import "../chunk-JM7EOAQZ.js";
15
+ } from "../chunk-7CZIQG6Z.js";
19
16
  import {
20
17
  HttpClient,
21
18
  agentFromArgvWithFallback,
@@ -28,8 +25,11 @@ import {
28
25
  skillDeferredFeedback,
29
26
  skillPromptContext,
30
27
  skillSessionStart
31
- } from "../chunk-HHKQPWYI.js";
28
+ } from "../chunk-HUX2XS5P.js";
32
29
  import "../chunk-5ITT5GSP.js";
30
+ import {
31
+ shouldSkipHooks
32
+ } from "../chunk-5ML4VSXN.js";
33
33
  import "../chunk-PI2SUS3M.js";
34
34
 
35
35
  // src/hooks/hermes-pre-llm-call.ts
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- shouldSkipHooks
4
- } from "../chunk-5ML4VSXN.js";
5
2
  import {
6
3
  agentFromArgvWithFallback,
7
4
  receiveEnd,
8
5
  sessionBinding
9
- } from "../chunk-HHKQPWYI.js";
6
+ } from "../chunk-HUX2XS5P.js";
10
7
  import "../chunk-5ITT5GSP.js";
8
+ import {
9
+ shouldSkipHooks
10
+ } from "../chunk-5ML4VSXN.js";
11
11
  import "../chunk-PI2SUS3M.js";
12
12
 
13
13
  // src/hooks/session-end.ts
@@ -3,15 +3,12 @@ import {
3
3
  HOOK_TIMEOUT_MS,
4
4
  composeSessionStart,
5
5
  formatSessionStartStdout
6
- } from "../chunk-WCVCSOFL.js";
7
- import "../chunk-XEX5344F.js";
6
+ } from "../chunk-CGA7EITY.js";
7
+ import "../chunk-C66FQHNI.js";
8
+ import "../chunk-EX6SM7I3.js";
8
9
  import {
9
10
  isCircuitOpen
10
- } from "../chunk-7RMETV4M.js";
11
- import {
12
- shouldSkipHooks
13
- } from "../chunk-5ML4VSXN.js";
14
- import "../chunk-JM7EOAQZ.js";
11
+ } from "../chunk-7CZIQG6Z.js";
15
12
  import {
16
13
  HttpClient,
17
14
  agentFromArgvWithFallback,
@@ -20,8 +17,11 @@ import {
20
17
  resolveDataApiCredential,
21
18
  setDebug,
22
19
  skillSessionStart
23
- } from "../chunk-HHKQPWYI.js";
20
+ } from "../chunk-HUX2XS5P.js";
24
21
  import "../chunk-5ITT5GSP.js";
22
+ import {
23
+ shouldSkipHooks
24
+ } from "../chunk-5ML4VSXN.js";
25
25
  import "../chunk-PI2SUS3M.js";
26
26
 
27
27
  // src/hooks/session-start.ts
@@ -1,12 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  captureTurn
4
- } from "../chunk-EWCB3UQS.js";
5
- import "../chunk-7RMETV4M.js";
6
- import {
7
- shouldSkipHooks
8
- } from "../chunk-5ML4VSXN.js";
4
+ } from "../chunk-4GYXLFNU.js";
9
5
  import "../chunk-SR3M7AL5.js";
6
+ import "../chunk-7CZIQG6Z.js";
10
7
  import {
11
8
  HttpClient,
12
9
  agentFromArgvWithFallback,
@@ -16,8 +13,11 @@ import {
16
13
  sessionBinding,
17
14
  setDebug,
18
15
  skillStop
19
- } from "../chunk-HHKQPWYI.js";
16
+ } from "../chunk-HUX2XS5P.js";
20
17
  import "../chunk-5ITT5GSP.js";
18
+ import {
19
+ shouldSkipHooks
20
+ } from "../chunk-5ML4VSXN.js";
21
21
  import "../chunk-PI2SUS3M.js";
22
22
 
23
23
  // src/hooks/stop.ts
@@ -67,7 +67,12 @@ async function main() {
67
67
  return 0;
68
68
  }
69
69
  const client = new HttpClient({ baseUrl: cfg.baseUrl, credential, timeoutMs: 5e3 });
70
- const result = await captureTurn(transcriptPath, cfg, client, agent, sessionId);
70
+ if (event.stop_hook_active === true || event.isSidechain === true || event.is_subagent === true) return 0;
71
+ const result = await captureTurn(transcriptPath, cfg, client, agent, sessionId, {
72
+ sessionId,
73
+ turnId: typeof event.turn_id === "string" ? event.turn_id : void 0,
74
+ lastAssistantMessage: typeof event.last_assistant_message === "string" ? event.last_assistant_message : void 0
75
+ });
71
76
  if (result.captured) {
72
77
  debug("capture", `ok (${result.messageCount} msgs)`, result);
73
78
  process.stderr.write(
@@ -2,15 +2,12 @@
2
2
  import {
3
3
  composeUserPromptSubmit,
4
4
  formatUserPromptSubmitStdout
5
- } from "../chunk-6XK3RDZ6.js";
6
- import "../chunk-XEX5344F.js";
5
+ } from "../chunk-BRCQTX2M.js";
6
+ import "../chunk-C66FQHNI.js";
7
+ import "../chunk-EX6SM7I3.js";
7
8
  import {
8
9
  isCircuitOpen
9
- } from "../chunk-7RMETV4M.js";
10
- import {
11
- shouldSkipHooks
12
- } from "../chunk-5ML4VSXN.js";
13
- import "../chunk-JM7EOAQZ.js";
10
+ } from "../chunk-7CZIQG6Z.js";
14
11
  import {
15
12
  HttpClient,
16
13
  agentFromArgvWithFallback,
@@ -19,8 +16,11 @@ import {
19
16
  resolveDataApiCredential,
20
17
  setDebug,
21
18
  skillPromptContext
22
- } from "../chunk-HHKQPWYI.js";
19
+ } from "../chunk-HUX2XS5P.js";
23
20
  import "../chunk-5ITT5GSP.js";
21
+ import {
22
+ shouldSkipHooks
23
+ } from "../chunk-5ML4VSXN.js";
24
24
  import "../chunk-PI2SUS3M.js";
25
25
 
26
26
  // src/hooks/user-prompt-submit.ts