wildcrane-runner 0.6.57 → 0.6.59

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/settings.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // wildcrane-runner 0.6.57 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.59 — built by runner/scripts/build.mjs. Do not edit.
2
2
  import { createRequire as __ai4kanbanRequire } from 'node:module'
3
3
  const require = __ai4kanbanRequire(import.meta.url)
4
4
  var __create = Object.create;
@@ -26980,8 +26980,8 @@ function alive(pid) {
26980
26980
  var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
26981
26981
 
26982
26982
  // src/protocol.ts
26983
- var VERSION = true ? "0.6.57" : "0.0.0";
26984
- var AKB_VERSION = true ? "0.11.45" : "0.0.0";
26983
+ var VERSION = true ? "0.6.59" : "0.0.0";
26984
+ var AKB_VERSION = true ? "0.11.46" : "0.0.0";
26985
26985
 
26986
26986
  // src/api.ts
26987
26987
  var RUNTIMES = ["claude-code", "codex", "cursor", "opencode", "kimi", "dsh", "zcode", "grok"];
@@ -29714,6 +29714,21 @@ function createKimiStreamRenderer(cwd) {
29714
29714
  };
29715
29715
  }
29716
29716
 
29717
+ // ../cli/src/lib/shared/conversation.ts
29718
+ var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
29719
+ function bounded(work, ms, reason) {
29720
+ return new Promise((resolve2, reject) => {
29721
+ const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
29722
+ work.then((value) => {
29723
+ clearTimeout(timer);
29724
+ resolve2(value);
29725
+ }, (error) => {
29726
+ clearTimeout(timer);
29727
+ reject(error);
29728
+ });
29729
+ });
29730
+ }
29731
+
29717
29732
  // ../cli/src/lib/agent/wire/acp.ts
29718
29733
  import fs15 from "node:fs";
29719
29734
 
@@ -29848,7 +29863,7 @@ function createTail(log) {
29848
29863
  // ../cli/package.json
29849
29864
  var package_default = {
29850
29865
  name: "wildcrane",
29851
- version: "0.11.45",
29866
+ version: "0.11.46",
29852
29867
  akbContract: 12,
29853
29868
  description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
29854
29869
  keywords: [
@@ -30007,6 +30022,11 @@ function createAcpClient(options = {}) {
30007
30022
  }
30008
30023
  async function oneTurn(io, options) {
30009
30024
  const tail = createTail(io.log);
30025
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
30026
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
30027
+ let started = false;
30028
+ let contentAt = 0;
30029
+ let currentSession = "";
30010
30030
  const events = createEventCollector();
30011
30031
  const emit = () => {
30012
30032
  for (const e of events.events()) io.event?.(e);
@@ -30019,7 +30039,16 @@ async function oneTurn(io, options) {
30019
30039
  io.stdin,
30020
30040
  (msg) => {
30021
30041
  if (msg.method === "session/update") {
30022
- if (live) {
30042
+ if (live && (!obj(msg.params).sessionId || obj(msg.params).sessionId === currentSession)) {
30043
+ const kind = str2(obj(obj(msg.params).update).sessionUpdate);
30044
+ if (!started && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
30045
+ started = true;
30046
+ phase("started");
30047
+ }
30048
+ if (kind === "agent_message_chunk" && Date.now() - contentAt >= 1e3) {
30049
+ contentAt = Date.now();
30050
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
30051
+ }
30023
30052
  update2(obj(msg.params).update, tail, (usd) => costUsd = usd, (window) => context = window);
30024
30053
  events.update(obj(msg.params).update);
30025
30054
  emit();
@@ -30047,20 +30076,22 @@ async function oneTurn(io, options) {
30047
30076
  );
30048
30077
  try {
30049
30078
  const mcpServers = options.mcpConfig ? mcpServersIn(options.mcpConfig) : [];
30050
- await rpc.call("initialize", {
30079
+ phase("preparing");
30080
+ await bounded(rpc.call("initialize", {
30051
30081
  protocolVersion: PROTOCOL_VERSION,
30052
30082
  clientCapabilities: CLIENT_CAPABILITIES,
30053
30083
  clientInfo: { name: "ai4kanban", version: SKILL_VERSION }
30054
- });
30084
+ }), preparingUntil - Date.now(), "ACP initialize timed out.");
30085
+ phase("initialized");
30055
30086
  let sessionId = io.resumeId ?? "";
30056
30087
  let prompt = io.prompt;
30057
30088
  let opened;
30058
30089
  if (sessionId) {
30059
30090
  try {
30060
- opened = await rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers });
30091
+ opened = await bounded(rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers }), preparingUntil - Date.now(), "ACP session/load timed out.");
30061
30092
  } catch (e) {
30062
30093
  if (!sessionGone(e) || !io.restartPrompt) throw e;
30063
- const fresh = await newSession(rpc, io.cwd, mcpServers);
30094
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
30064
30095
  opened = fresh.opened;
30065
30096
  sessionId = fresh.sessionId;
30066
30097
  prompt = io.restartPrompt;
@@ -30070,7 +30101,7 @@ async function oneTurn(io, options) {
30070
30101
  emit();
30071
30102
  }
30072
30103
  } else {
30073
- const fresh = await newSession(rpc, io.cwd, mcpServers);
30104
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
30074
30105
  opened = fresh.opened;
30075
30106
  sessionId = fresh.sessionId;
30076
30107
  io.gotResumeId(sessionId);
@@ -30079,11 +30110,15 @@ async function oneTurn(io, options) {
30079
30110
  if (options.model) {
30080
30111
  const listed2 = obj(opened.models).currentModelId !== void 0;
30081
30112
  const picked = listed2 ? pickedModel(opened, options.model) : void 0;
30082
- const set = listed2 ? await rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }) : await rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model });
30113
+ const set = listed2 ? await bounded(rpc.call("session/set_model", { sessionId, modelId: picked?.modelId ?? options.model }), preparingUntil - Date.now(), "ACP session/set_model timed out.") : await bounded(rpc.call("session/set_config_option", { sessionId, configId: "model", value: options.model }), preparingUntil - Date.now(), "ACP session/set_config_option timed out.");
30083
30114
  model = picked?.name ?? modelOf(set) ?? options.model;
30084
30115
  }
30085
30116
  if (model) io.gotModel(model);
30117
+ if (Date.now() >= preparingUntil) throw Error("ACP preparation timed out.");
30118
+ phase("ready");
30119
+ currentSession = sessionId;
30086
30120
  live = true;
30121
+ phase("submitted");
30087
30122
  const done = await rpc.call("session/prompt", {
30088
30123
  sessionId,
30089
30124
  prompt: [{ type: "text", text: prompt }]
@@ -30500,10 +30535,24 @@ function createCodexClient(options = { images: [] }) {
30500
30535
  }
30501
30536
  async function run(io, options, tasks) {
30502
30537
  const renderer = createCodexStreamRenderer();
30538
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
30539
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
30540
+ let submitted = false;
30541
+ let started = false;
30542
+ let contentAt = 0;
30543
+ let startupTimer;
30544
+ const began = () => {
30545
+ if (!submitted || started || ended) return;
30546
+ started = true;
30547
+ clearTimeout(startupTimer);
30548
+ phase("started");
30549
+ };
30503
30550
  const children = /* @__PURE__ */ new Set();
30504
30551
  const commands = /* @__PURE__ */ new Set();
30505
30552
  const seenItems = /* @__PURE__ */ new Set();
30506
30553
  const completedTurns = /* @__PURE__ */ new Set();
30554
+ const historicalTurns = /* @__PURE__ */ new Set();
30555
+ let currentTurn2 = "";
30507
30556
  let threadId = "";
30508
30557
  let active = true;
30509
30558
  let waiting = false;
@@ -30529,6 +30578,7 @@ async function run(io, options, tasks) {
30529
30578
  if (ended) return;
30530
30579
  ended = true;
30531
30580
  clearTimeout(timer);
30581
+ clearTimeout(startupTimer);
30532
30582
  deadline.close();
30533
30583
  io.stdout.off("close", closed);
30534
30584
  io.log(renderer.flush());
@@ -30560,10 +30610,11 @@ async function run(io, options, tasks) {
30560
30610
  io.event?.({ kind: "tool_call_update", data: { toolCallId: `agent:${id}`, status: failed ? "failed" : "completed", result: str2(state.message) } });
30561
30611
  }
30562
30612
  };
30563
- const item = (raw, completed) => {
30613
+ const item = (raw, completed, proof = true) => {
30564
30614
  if (ended) return;
30565
30615
  const id = str2(raw.id);
30566
30616
  if (raw.type === "collabAgentToolCall") {
30617
+ if (proof) began();
30567
30618
  const key2 = `${id}:${completed}`;
30568
30619
  if (seenItems.has(key2)) return;
30569
30620
  seenItems.add(key2);
@@ -30591,6 +30642,7 @@ async function run(io, options, tasks) {
30591
30642
  const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
30592
30643
  const type = types[str2(raw.type)];
30593
30644
  if (!type) return;
30645
+ if (proof) began();
30594
30646
  emit(completed ? "item.completed" : "item.started", { item: {
30595
30647
  ...raw,
30596
30648
  type,
@@ -30604,7 +30656,16 @@ async function run(io, options, tasks) {
30604
30656
  const start = async (text3, images = []) => {
30605
30657
  active = true;
30606
30658
  waiting = false;
30607
- await rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path30) => ({ type: "localImage", path: path30 }))] });
30659
+ submitted = true;
30660
+ currentTurn2 = "";
30661
+ started = false;
30662
+ phase("submitted");
30663
+ startupTimer = setTimeout(() => {
30664
+ if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
30665
+ }, CONVERSATION_MS.start);
30666
+ await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text3 }, ...images.map((path30) => ({ type: "localImage", path: path30 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
30667
+ if (!started) throw error;
30668
+ });
30608
30669
  };
30609
30670
  const schedule = () => {
30610
30671
  if (ended || timer) return;
@@ -30689,11 +30750,21 @@ async function run(io, options, tasks) {
30689
30750
  }
30690
30751
  const p = obj(msg.params);
30691
30752
  if (str2(p.threadId) !== threadId) return;
30753
+ const turnId = str2(p.turnId) || str2(obj(p.turn).id);
30754
+ if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
30692
30755
  if (msg.method === "turn/started") {
30756
+ if (!submitted || completedTurns.has(turnId)) return;
30757
+ currentTurn2 = turnId;
30693
30758
  active = true;
30759
+ began();
30694
30760
  return;
30695
30761
  }
30696
- if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed");
30762
+ if (submitted && msg.method === "item/agentMessage/delta" && Date.now() - contentAt >= 1e3) {
30763
+ began();
30764
+ contentAt = Date.now();
30765
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
30766
+ }
30767
+ if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed", !completedTurns.has(turnId));
30697
30768
  if (msg.method === "thread/tokenUsage/updated") {
30698
30769
  const token = obj(p.tokenUsage);
30699
30770
  const counts = obj(token.total);
@@ -30724,17 +30795,20 @@ async function run(io, options, tasks) {
30724
30795
  }
30725
30796
  });
30726
30797
  try {
30727
- await rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } });
30798
+ phase("preparing");
30799
+ await bounded(rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), preparingUntil - Date.now(), "Codex initialize timed out.");
30800
+ phase("initialized");
30728
30801
  rpc.notify("initialized");
30729
30802
  const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
30730
30803
  let response;
30731
30804
  try {
30732
- response = await rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} });
30805
+ response = await bounded(rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} }), preparingUntil - Date.now(), `Codex thread/${mode ?? "start"} timed out.`);
30733
30806
  } catch (e) {
30734
30807
  if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
30735
30808
  throw e;
30736
30809
  }
30737
30810
  const thread = obj(response.thread);
30811
+ for (const turn2 of list(thread.turns)) historicalTurns.add(str2(turn2.id));
30738
30812
  threadId = str2(thread.id);
30739
30813
  if (!threadId) throw Error("Codex did not return a thread id.");
30740
30814
  provider = str2(thread.modelProvider) || void 0;
@@ -30743,6 +30817,8 @@ async function run(io, options, tasks) {
30743
30817
  io.gotResumeId(threadId);
30744
30818
  baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total;
30745
30819
  emit("thread.started", { thread_id: threadId });
30820
+ if (Date.now() >= preparingUntil) throw Error("Codex preparation timed out.");
30821
+ phase("ready");
30746
30822
  await start(io.prompt, options.images);
30747
30823
  } catch (e) {
30748
30824
  end(e instanceof Error ? e.message : String(e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wildcrane-runner",
3
- "version": "0.6.57",
3
+ "version": "0.6.59",
4
4
  "description": "WildCrane's Local Runner — connects this computer to WildCrane and runs its jobs on your local Claude Code, Codex, OpenCode or Cursor.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://wildcrane.ai/",