@lesscap/baton-cli 0.7.9 → 0.7.11

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.
Files changed (3) hide show
  1. package/dist/baton.mjs +34 -8
  2. package/package.json +15 -14
  3. package/LICENSE +0 -21
package/dist/baton.mjs CHANGED
@@ -6706,9 +6706,23 @@ var startedMessageIds = (events) => {
6706
6706
  }
6707
6707
  return ids;
6708
6708
  };
6709
+ var messageLoopId = (event) => {
6710
+ if (event.type !== "user_message") return void 0;
6711
+ const id = event.payload?.loopId;
6712
+ return typeof id === "number" ? id : void 0;
6713
+ };
6709
6714
  var unstartedUserMessages = (events) => {
6710
6715
  const started = startedMessageIds(events);
6711
- return events.filter((e) => e.type === "user_message" && !started.has(e.id));
6716
+ const latest = /* @__PURE__ */ new Map();
6717
+ events.forEach((event) => {
6718
+ const loopId = messageLoopId(event);
6719
+ if (loopId !== void 0) latest.set(loopId, Math.max(latest.get(loopId) ?? -1, event.sequence));
6720
+ });
6721
+ return events.filter((event) => {
6722
+ if (event.type !== "user_message" || started.has(event.id)) return false;
6723
+ const loopId = messageLoopId(event);
6724
+ return loopId === void 0 || event.sequence === latest.get(loopId);
6725
+ });
6712
6726
  };
6713
6727
  var opensTurn = (e) => e.type === "user_message" || e.type === "turn_start";
6714
6728
  var closesTurn = (e) => e.type === "turn_complete" || e.type === "turn_error";
@@ -7908,8 +7922,7 @@ var claudeEffort = (raw) => {
7908
7922
  return void 0;
7909
7923
  };
7910
7924
  var codexEffort = (raw) => {
7911
- if (raw === "max") return "xhigh";
7912
- if (raw === "minimal" || raw === "low" || raw === "medium" || raw === "high" || raw === "xhigh")
7925
+ if (raw === "minimal" || raw === "low" || raw === "medium" || raw === "high" || raw === "xhigh" || raw === "max")
7913
7926
  return raw;
7914
7927
  return void 0;
7915
7928
  };
@@ -8629,16 +8642,27 @@ var runDaemon = async (config, deps, signal) => {
8629
8642
  log(`bin: ${claudeExecutable() ?? "(sdk bundled)"} cwd: ${config.worktreePath}`);
8630
8643
  log(`runtime env keys: ${maskedEnvKeys(deps.env)}`);
8631
8644
  const state = { seen: /* @__PURE__ */ new Set() };
8632
- const pendingQueue = [];
8645
+ let pendingQueue = [];
8646
+ const latestLoops = /* @__PURE__ */ new Map();
8633
8647
  let busy = false;
8634
8648
  let reconciling = false;
8635
8649
  let lastActivity = Date.now();
8636
8650
  let currentTurn;
8651
+ const trackLoopMessage = (event) => {
8652
+ const loopId = messageLoopId(event);
8653
+ if (loopId === void 0) return true;
8654
+ if (event.sequence < (latestLoops.get(loopId) ?? -1)) return false;
8655
+ latestLoops.set(loopId, event.sequence);
8656
+ pendingQueue = pendingQueue.filter(
8657
+ (queued) => messageLoopId(queued) !== loopId || queued.sequence >= event.sequence
8658
+ );
8659
+ return true;
8660
+ };
8637
8661
  const drain = async () => {
8638
- if (busy) return;
8662
+ if (busy || reconciling) return;
8639
8663
  busy = true;
8640
8664
  try {
8641
- while (pendingQueue.length > 0 && !signal.aborted) {
8665
+ while (pendingQueue.length > 0 && !signal.aborted && !reconciling) {
8642
8666
  const msg = pendingQueue.shift();
8643
8667
  if (!msg) break;
8644
8668
  const resuming = isAgentConversationResumable(config);
@@ -8674,10 +8698,11 @@ var runDaemon = async (config, deps, signal) => {
8674
8698
  reconciling = true;
8675
8699
  try {
8676
8700
  const events = await deps.worker.listEvents();
8701
+ events.forEach(trackLoopMessage);
8677
8702
  const pending = unstartedUserMessages(events);
8678
8703
  let added = 0;
8679
8704
  for (const ev of pending) {
8680
- if (state.seen.has(ev.sequence)) continue;
8705
+ if (state.seen.has(ev.sequence) || !trackLoopMessage(ev)) continue;
8681
8706
  state.seen.add(ev.sequence);
8682
8707
  pendingQueue.push(ev);
8683
8708
  added++;
@@ -8685,7 +8710,6 @@ var runDaemon = async (config, deps, signal) => {
8685
8710
  if (added > 0) {
8686
8711
  log(`reconciled ${added} queued message(s) from transcript`);
8687
8712
  lastActivity = Date.now();
8688
- void drain();
8689
8713
  } else if (pendingQueue.length === 0 && !busy && !currentTurn && isAgentWorking(events)) {
8690
8714
  await deps.worker.emitEvent("turn_error", {
8691
8715
  message: "turn abandoned \u2014 runner restarted",
@@ -8697,6 +8721,7 @@ var runDaemon = async (config, deps, signal) => {
8697
8721
  log(`reconcile failed: ${String(e)}`);
8698
8722
  } finally {
8699
8723
  reconciling = false;
8724
+ if (pendingQueue.length > 0) void drain();
8700
8725
  }
8701
8726
  };
8702
8727
  const es = subscribeStream(
@@ -8707,6 +8732,7 @@ var runDaemon = async (config, deps, signal) => {
8707
8732
  state.seen,
8708
8733
  log,
8709
8734
  (ev) => {
8735
+ if (!trackLoopMessage(ev)) return;
8710
8736
  lastActivity = Date.now();
8711
8737
  pendingQueue.push(ev);
8712
8738
  void drain();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lesscap/baton-cli",
3
- "version": "0.7.9",
3
+ "version": "0.7.11",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,29 +15,30 @@
15
15
  "scripts",
16
16
  "skills"
17
17
  ],
18
+ "scripts": {
19
+ "baton": "tsx src/index.ts",
20
+ "build": "node build.mjs && chmod +x dist/baton.mjs",
21
+ "postinstall": "node scripts/postinstall.mjs",
22
+ "prepublishOnly": "pnpm build",
23
+ "typecheck": "tsc --noEmit -p tsconfig.json",
24
+ "test": "tsx --test 'src/**/*.test.ts'"
25
+ },
18
26
  "devDependencies": {
27
+ "@baton/shared": "workspace:*",
19
28
  "@types/node": "^25.9.1",
20
29
  "@types/ws": "^8.18.1",
21
30
  "citty": "^0.2.2",
22
31
  "esbuild": "^0.28.0",
23
32
  "eventsource": "^4.1.0",
24
33
  "tsx": "^4.22.4",
25
- "typescript": "^6.0.3",
26
- "@baton/shared": "0.0.0"
34
+ "typescript": "^6.0.3"
27
35
  },
28
36
  "dependencies": {
29
- "@anthropic-ai/claude-agent-sdk": "^0.3.220",
30
- "@openai/codex": "0.146.0",
31
- "@openai/codex-sdk": "0.146.0",
37
+ "@anthropic-ai/claude-agent-sdk": "^0.3.263",
38
+ "@openai/codex": "0.153.4",
39
+ "@openai/codex-sdk": "0.153.4",
32
40
  "mime": "^4.1.0",
33
41
  "node-pty": "^1.1.0",
34
42
  "ws": "^8.21.0"
35
- },
36
- "scripts": {
37
- "baton": "tsx src/index.ts",
38
- "build": "node build.mjs && chmod +x dist/baton.mjs",
39
- "postinstall": "node scripts/postinstall.mjs",
40
- "typecheck": "tsc --noEmit -p tsconfig.json",
41
- "test": "tsx --test 'src/**/*.test.ts'"
42
43
  }
43
- }
44
+ }
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.