@lesscap/baton-cli 0.5.0 → 0.6.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/baton.mjs +55 -6
- package/package.json +12 -11
- package/LICENSE +0 -21
package/dist/baton.mjs
CHANGED
|
@@ -6411,6 +6411,38 @@ var additionalDirs = () => {
|
|
|
6411
6411
|
const dirs = raw.split(":").map((s) => s.trim()).filter((s) => s !== "" && isAbsolute(s) && existsSync3(s));
|
|
6412
6412
|
return dirs.length > 0 ? dirs : void 0;
|
|
6413
6413
|
};
|
|
6414
|
+
var truthy = (value) => {
|
|
6415
|
+
if (value === void 0) return void 0;
|
|
6416
|
+
const normalized = value.trim().toLowerCase();
|
|
6417
|
+
if (["1", "true", "yes", "on"].includes(normalized)) return true;
|
|
6418
|
+
if (["0", "false", "no", "off"].includes(normalized)) return false;
|
|
6419
|
+
return void 0;
|
|
6420
|
+
};
|
|
6421
|
+
var codexNetworkAccess = () => truthy(process.env.BATON_CODEX_NETWORK_ACCESS);
|
|
6422
|
+
var codexSandboxMode = (planMode) => {
|
|
6423
|
+
if (planMode) return "read-only";
|
|
6424
|
+
const raw = process.env.BATON_CODEX_SANDBOX_MODE;
|
|
6425
|
+
if (raw === "read-only" || raw === "workspace-write" || raw === "danger-full-access") return raw;
|
|
6426
|
+
return "workspace-write";
|
|
6427
|
+
};
|
|
6428
|
+
var codexApprovalPolicy = () => {
|
|
6429
|
+
const raw = process.env.BATON_CODEX_APPROVAL_POLICY;
|
|
6430
|
+
if (raw === "never" || raw === "on-request" || raw === "on-failure" || raw === "untrusted")
|
|
6431
|
+
return raw;
|
|
6432
|
+
return "never";
|
|
6433
|
+
};
|
|
6434
|
+
var claudeEffort = (raw) => {
|
|
6435
|
+
if (raw === "minimal") return "low";
|
|
6436
|
+
if (raw === "low" || raw === "medium" || raw === "high" || raw === "xhigh" || raw === "max")
|
|
6437
|
+
return raw;
|
|
6438
|
+
return void 0;
|
|
6439
|
+
};
|
|
6440
|
+
var codexEffort = (raw) => {
|
|
6441
|
+
if (raw === "max") return "xhigh";
|
|
6442
|
+
if (raw === "minimal" || raw === "low" || raw === "medium" || raw === "high" || raw === "xhigh")
|
|
6443
|
+
return raw;
|
|
6444
|
+
return void 0;
|
|
6445
|
+
};
|
|
6414
6446
|
|
|
6415
6447
|
// src/session/runner/transcript.ts
|
|
6416
6448
|
import { readdirSync, readFileSync as readFileSync4, statSync } from "node:fs";
|
|
@@ -6651,13 +6683,24 @@ async function* startCodexEvents(config, input, worker2, opts) {
|
|
|
6651
6683
|
const codex = new Codex(env ? { env } : void 0);
|
|
6652
6684
|
const resuming = !config.agentSessionId.startsWith("pending:");
|
|
6653
6685
|
const addDirs = additionalDirs();
|
|
6686
|
+
const sandboxMode = codexSandboxMode(opts.planMode ?? false);
|
|
6687
|
+
const approvalPolicy = codexApprovalPolicy();
|
|
6688
|
+
const networkAccessEnabled = codexNetworkAccess();
|
|
6689
|
+
const reasoningEffort = codexEffort(opts.effort);
|
|
6690
|
+
opts.log(
|
|
6691
|
+
`[codex] sandbox=${sandboxMode} approval=${approvalPolicy}${networkAccessEnabled === void 0 ? "" : ` network=${networkAccessEnabled}`}`
|
|
6692
|
+
);
|
|
6693
|
+
if (opts.model) opts.log(`[model] ${opts.model}`);
|
|
6694
|
+
if (reasoningEffort) opts.log(`[effort] ${reasoningEffort}`);
|
|
6654
6695
|
const threadOptions = {
|
|
6655
6696
|
workingDirectory: config.worktreePath,
|
|
6656
6697
|
skipGitRepoCheck: true,
|
|
6657
|
-
sandboxMode
|
|
6658
|
-
approvalPolicy
|
|
6698
|
+
sandboxMode,
|
|
6699
|
+
approvalPolicy,
|
|
6659
6700
|
...opts.model ? { model: opts.model } : {},
|
|
6660
|
-
...
|
|
6701
|
+
...reasoningEffort ? { modelReasoningEffort: reasoningEffort } : {},
|
|
6702
|
+
...addDirs ? { additionalDirectories: addDirs } : {},
|
|
6703
|
+
...networkAccessEnabled === void 0 ? {} : { networkAccessEnabled }
|
|
6661
6704
|
};
|
|
6662
6705
|
const thread = resuming ? codex.resumeThread(config.agentSessionId, threadOptions) : codex.startThread(threadOptions);
|
|
6663
6706
|
const runInput = opts.planMode ? withPlanPrefix(input) : input;
|
|
@@ -6679,13 +6722,15 @@ async function* startCodexEvents(config, input, worker2, opts) {
|
|
|
6679
6722
|
}
|
|
6680
6723
|
|
|
6681
6724
|
// src/session/runner/query.ts
|
|
6682
|
-
var startQuery = (config, text, resuming, queryFn, abortController, log, { envOverlay, planMode = false, model } = {}) => {
|
|
6725
|
+
var startQuery = (config, text, resuming, queryFn, abortController, log, { envOverlay, planMode = false, model, effort } = {}) => {
|
|
6683
6726
|
const env = buildSdkEnv(envOverlay);
|
|
6684
6727
|
const exe = claudeExecutable();
|
|
6685
6728
|
const addDirs = additionalDirs();
|
|
6729
|
+
const level = claudeEffort(effort);
|
|
6686
6730
|
if (addDirs) log(`[add-dir] ${addDirs.join(", ")}`);
|
|
6687
6731
|
if (planMode) log("[plan] read-only planning turn");
|
|
6688
6732
|
if (model) log(`[model] ${model}`);
|
|
6733
|
+
if (level) log(`[effort] ${level}`);
|
|
6689
6734
|
const options = {
|
|
6690
6735
|
cwd: config.worktreePath,
|
|
6691
6736
|
permissionMode: planMode ? "plan" : "bypassPermissions",
|
|
@@ -6700,7 +6745,8 @@ var startQuery = (config, text, resuming, queryFn, abortController, log, { envOv
|
|
|
6700
6745
|
...env ? { env } : {},
|
|
6701
6746
|
...exe ? { pathToClaudeCodeExecutable: exe } : {},
|
|
6702
6747
|
...addDirs ? { additionalDirectories: addDirs } : {},
|
|
6703
|
-
...model ? { model } : {}
|
|
6748
|
+
...model ? { model } : {},
|
|
6749
|
+
...level ? { effort: level } : {}
|
|
6704
6750
|
};
|
|
6705
6751
|
return queryFn({ prompt: text, options });
|
|
6706
6752
|
};
|
|
@@ -6970,6 +7016,7 @@ var runTurn = async (config, worker2, msg, resuming, queryFn, log = (m) => conso
|
|
|
6970
7016
|
const attachments = Array.isArray(payload?.attachments) ? payload.attachments : [];
|
|
6971
7017
|
const planMode = payload?.planMode === true;
|
|
6972
7018
|
const model = typeof payload?.model === "string" ? payload.model : void 0;
|
|
7019
|
+
const effort = typeof payload?.effort === "string" ? payload.effort : void 0;
|
|
6973
7020
|
if (rawText.length === 0 && attachments.length === 0) {
|
|
6974
7021
|
await worker2.emitEvent("turn_error", { message: "user_message missing text and attachments" });
|
|
6975
7022
|
return -1;
|
|
@@ -7002,6 +7049,7 @@ var runTurn = async (config, worker2, msg, resuming, queryFn, log = (m) => conso
|
|
|
7002
7049
|
envOverlay,
|
|
7003
7050
|
planMode,
|
|
7004
7051
|
model,
|
|
7052
|
+
effort,
|
|
7005
7053
|
signal: abort.signal,
|
|
7006
7054
|
log
|
|
7007
7055
|
}),
|
|
@@ -7010,7 +7058,8 @@ var runTurn = async (config, worker2, msg, resuming, queryFn, log = (m) => conso
|
|
|
7010
7058
|
startQuery(config, built.text, resuming, queryFn, abort, log, {
|
|
7011
7059
|
envOverlay,
|
|
7012
7060
|
planMode,
|
|
7013
|
-
model
|
|
7061
|
+
model,
|
|
7062
|
+
effort
|
|
7014
7063
|
}),
|
|
7015
7064
|
worker2
|
|
7016
7065
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lesscap/baton-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -14,27 +14,28 @@
|
|
|
14
14
|
"dist",
|
|
15
15
|
"scripts"
|
|
16
16
|
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"baton": "tsx src/index.ts",
|
|
19
|
+
"build": "node build.mjs && chmod +x dist/baton.mjs",
|
|
20
|
+
"postinstall": "node scripts/postinstall.mjs",
|
|
21
|
+
"prepublishOnly": "pnpm build",
|
|
22
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
23
|
+
"test": "tsx --test 'src/**/*.test.ts'"
|
|
24
|
+
},
|
|
17
25
|
"devDependencies": {
|
|
26
|
+
"@baton/shared": "workspace:*",
|
|
18
27
|
"@types/node": "^25.9.1",
|
|
19
28
|
"@types/ws": "^8.18.1",
|
|
20
29
|
"citty": "^0.2.2",
|
|
21
30
|
"esbuild": "^0.28.0",
|
|
22
31
|
"eventsource": "^4.1.0",
|
|
23
32
|
"tsx": "^4.22.4",
|
|
24
|
-
"typescript": "^6.0.3"
|
|
25
|
-
"@baton/shared": "0.0.0"
|
|
33
|
+
"typescript": "^6.0.3"
|
|
26
34
|
},
|
|
27
35
|
"dependencies": {
|
|
28
36
|
"@anthropic-ai/claude-agent-sdk": "^0.3.161",
|
|
29
37
|
"@openai/codex-sdk": "^0.142.5",
|
|
30
38
|
"node-pty": "^1.1.0",
|
|
31
39
|
"ws": "^8.21.0"
|
|
32
|
-
},
|
|
33
|
-
"scripts": {
|
|
34
|
-
"baton": "tsx src/index.ts",
|
|
35
|
-
"build": "node build.mjs && chmod +x dist/baton.mjs",
|
|
36
|
-
"postinstall": "node scripts/postinstall.mjs",
|
|
37
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
38
|
-
"test": "tsx --test 'src/**/*.test.ts'"
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 bencode
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|