@lesscap/baton-cli 0.2.10 → 0.2.12
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/baton.mjs +28 -7
- package/package.json +1 -1
package/dist/baton.mjs
CHANGED
|
@@ -1857,12 +1857,13 @@ ${text}` : header;
|
|
|
1857
1857
|
};
|
|
1858
1858
|
|
|
1859
1859
|
// src/session/runner/query.ts
|
|
1860
|
-
var startQuery = (config, text, resuming, queryFn, abortController, log, envOverlay, planMode = false) => {
|
|
1860
|
+
var startQuery = (config, text, resuming, queryFn, abortController, log, { envOverlay, planMode = false, model } = {}) => {
|
|
1861
1861
|
const env = buildSdkEnv(envOverlay);
|
|
1862
1862
|
const exe = claudeExecutable();
|
|
1863
1863
|
const addDirs = additionalDirs();
|
|
1864
1864
|
if (addDirs) log(`[add-dir] ${addDirs.join(", ")}`);
|
|
1865
1865
|
if (planMode) log("[plan] read-only planning turn");
|
|
1866
|
+
if (model) log(`[model] ${model}`);
|
|
1866
1867
|
const options = {
|
|
1867
1868
|
cwd: config.worktreePath,
|
|
1868
1869
|
permissionMode: planMode ? "plan" : "bypassPermissions",
|
|
@@ -1872,7 +1873,8 @@ var startQuery = (config, text, resuming, queryFn, abortController, log, envOver
|
|
|
1872
1873
|
...resuming ? { resume: config.agentSessionId } : { sessionId: config.agentSessionId },
|
|
1873
1874
|
...env ? { env } : {},
|
|
1874
1875
|
...exe ? { pathToClaudeCodeExecutable: exe } : {},
|
|
1875
|
-
...addDirs ? { additionalDirectories: addDirs } : {}
|
|
1876
|
+
...addDirs ? { additionalDirectories: addDirs } : {},
|
|
1877
|
+
...model ? { model } : {}
|
|
1876
1878
|
};
|
|
1877
1879
|
return queryFn({ prompt: text, options });
|
|
1878
1880
|
};
|
|
@@ -1932,6 +1934,7 @@ var runTurn = async (config, worker2, msg, resuming, queryFn, log = (m) => conso
|
|
|
1932
1934
|
const rawText = typeof payload?.text === "string" ? payload.text : "";
|
|
1933
1935
|
const attachments = Array.isArray(payload?.attachments) ? payload.attachments : [];
|
|
1934
1936
|
const planMode = payload?.planMode === true;
|
|
1937
|
+
const model = typeof payload?.model === "string" ? payload.model : void 0;
|
|
1935
1938
|
if (rawText.length === 0 && attachments.length === 0) {
|
|
1936
1939
|
await worker2.emitEvent("turn_error", { message: "user_message missing text and attachments" });
|
|
1937
1940
|
return -1;
|
|
@@ -1955,7 +1958,11 @@ var runTurn = async (config, worker2, msg, resuming, queryFn, log = (m) => conso
|
|
|
1955
1958
|
else externalSignal?.addEventListener("abort", () => resolve2(ABORTED), { once: true });
|
|
1956
1959
|
});
|
|
1957
1960
|
try {
|
|
1958
|
-
const messages = startQuery(config, text, resuming, queryFn, abort, log,
|
|
1961
|
+
const messages = startQuery(config, text, resuming, queryFn, abort, log, {
|
|
1962
|
+
envOverlay,
|
|
1963
|
+
planMode,
|
|
1964
|
+
model
|
|
1965
|
+
});
|
|
1959
1966
|
const consume = streamSdkEvents(messages, worker2);
|
|
1960
1967
|
void consume.catch(() => {
|
|
1961
1968
|
});
|
|
@@ -2446,16 +2453,30 @@ import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
|
|
|
2446
2453
|
// src/session/runner/title.ts
|
|
2447
2454
|
var clip = (s, max) => s.length > max ? s.slice(0, max) : s;
|
|
2448
2455
|
var isDeclined = (title) => title.replace(/[^a-z]/gi, "").toUpperCase() === "NONE";
|
|
2449
|
-
var sanitizeTitle = (raw) => raw.replace(/[\r\n]+/g, " ").replace(/[*_`~#>]/g, "").replace(/["']/g, "").replace(/^\s*(?:title|session|标题)\s*[::-]\s*/i, "").replace(/^\s*(?:[-*•]|\d+[.)、])\s+/, "").replace(/\s+/g, " ").trim().slice(0, 30).replace(/[\s。.,,、;;::!!??.]+$/, "").trim();
|
|
2456
|
+
var sanitizeTitle = (raw) => raw.replace(/[\r\n]+/g, " ").replace(/[*_`~#>]/g, "").replace(/["']/g, "").replace(/^\s*(?:title|session|标题)\s*[::-]\s*/i, "").replace(/^\s*(?:[-*•]|\d+[.)、])\s+/, "").replace(/\s+/g, " ").trim().replace(/(?:[。.!?,、;;]|[.!?;](?=\s|$)).*$/s, "").trim().slice(0, 30).replace(/[\s。.,,、;;::!!??.]+$/, "").trim();
|
|
2450
2457
|
var TITLE_TIMEOUT_MS = 9e4;
|
|
2451
2458
|
var buildPrompt2 = (userText, assistantText) => {
|
|
2452
2459
|
const exchange = [
|
|
2453
2460
|
`User: ${clip(userText, 800)}`,
|
|
2454
2461
|
assistantText ? `Assistant: ${clip(assistantText, 800)}` : ""
|
|
2455
2462
|
].filter(Boolean).join("\n");
|
|
2456
|
-
return
|
|
2457
|
-
|
|
2458
|
-
|
|
2463
|
+
return [
|
|
2464
|
+
"Name the TOPIC of this chat session \u2014 what it is ABOUT \u2014 as a short title:",
|
|
2465
|
+
"a noun phrase like a filename, at most 6 words or ~12 Chinese characters.",
|
|
2466
|
+
"Name the subject, do NOT restate the conclusion or the answer.",
|
|
2467
|
+
"No sentence, no punctuation at all (including Chinese \uFF0C\u3002\u3001\uFF1B\uFF01\uFF1F), no markdown,",
|
|
2468
|
+
`no quotes, and never an opener like "\u597D\u7684"/"\u6536\u5230"/"I'll".`,
|
|
2469
|
+
"",
|
|
2470
|
+
"Examples (exchange \u2192 title):",
|
|
2471
|
+
"User asks whether the material-ui repo needs updating; assistant says it is",
|
|
2472
|
+
"already up to date \u2192 material-ui \u4ED3\u5E93\u66F4\u65B0\u68C0\u67E5",
|
|
2473
|
+
"User: curl the health endpoint and report status \u2192 \u5065\u5EB7\u68C0\u67E5\u63A5\u53E3\u6392\u67E5",
|
|
2474
|
+
"",
|
|
2475
|
+
"Only if the exchange below has no real content at all (just a greeting or a",
|
|
2476
|
+
"test ping) reply with exactly NONE. Otherwise reply with ONLY the title.",
|
|
2477
|
+
"",
|
|
2478
|
+
exchange
|
|
2479
|
+
].join("\n");
|
|
2459
2480
|
};
|
|
2460
2481
|
var generateTitle = async (input) => {
|
|
2461
2482
|
const { worktreePath, userText, assistantText, queryFn } = input;
|