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/plugin.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;
@@ -73774,8 +73774,8 @@ function machineId() {
73774
73774
  var machineName = () => os3.hostname().replace(/\.local$/, "");
73775
73775
 
73776
73776
  // src/protocol.ts
73777
- var VERSION = true ? "0.6.57" : "0.0.0";
73778
- var AKB_VERSION = true ? "0.11.45" : "0.0.0";
73777
+ var VERSION = true ? "0.6.59" : "0.0.0";
73778
+ var AKB_VERSION = true ? "0.11.46" : "0.0.0";
73779
73779
  var EXIT_REFUSED = 10;
73780
73780
  var EXIT_OUTDATED = 11;
73781
73781
  var EXIT_UPDATE = 12;
@@ -77024,6 +77024,21 @@ function createKimiStreamRenderer(cwd) {
77024
77024
  };
77025
77025
  }
77026
77026
 
77027
+ // ../cli/src/lib/shared/conversation.ts
77028
+ var CONVERSATION_MS = { send: 15e3, claim: 3e4, prepare: 6e4, start: 15e3, startup: 12e4, quiet: 6e4, stop: 1e4 };
77029
+ function bounded(work, ms, reason) {
77030
+ return new Promise((resolve2, reject) => {
77031
+ const timer = setTimeout(() => reject(new Error(reason)), Math.max(0, ms));
77032
+ work.then((value) => {
77033
+ clearTimeout(timer);
77034
+ resolve2(value);
77035
+ }, (error2) => {
77036
+ clearTimeout(timer);
77037
+ reject(error2);
77038
+ });
77039
+ });
77040
+ }
77041
+
77027
77042
  // ../cli/src/lib/agent/wire/acp.ts
77028
77043
  import fs19 from "node:fs";
77029
77044
 
@@ -77158,7 +77173,7 @@ function createTail(log) {
77158
77173
  // ../cli/package.json
77159
77174
  var package_default = {
77160
77175
  name: "wildcrane",
77161
- version: "0.11.45",
77176
+ version: "0.11.46",
77162
77177
  akbContract: 12,
77163
77178
  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.",
77164
77179
  keywords: [
@@ -77317,6 +77332,11 @@ function createAcpClient(options = {}) {
77317
77332
  }
77318
77333
  async function oneTurn(io, options) {
77319
77334
  const tail = createTail(io.log);
77335
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
77336
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
77337
+ let started = false;
77338
+ let contentAt = 0;
77339
+ let currentSession = "";
77320
77340
  const events = createEventCollector();
77321
77341
  const emit = () => {
77322
77342
  for (const e of events.events()) io.event?.(e);
@@ -77329,7 +77349,16 @@ async function oneTurn(io, options) {
77329
77349
  io.stdin,
77330
77350
  (msg) => {
77331
77351
  if (msg.method === "session/update") {
77332
- if (live) {
77352
+ if (live && (!obj(msg.params).sessionId || obj(msg.params).sessionId === currentSession)) {
77353
+ const kind = str2(obj(obj(msg.params).update).sessionUpdate);
77354
+ if (!started && ["agent_message_chunk", "tool_call", "plan"].includes(kind)) {
77355
+ started = true;
77356
+ phase("started");
77357
+ }
77358
+ if (kind === "agent_message_chunk" && Date.now() - contentAt >= 1e3) {
77359
+ contentAt = Date.now();
77360
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
77361
+ }
77333
77362
  update2(obj(msg.params).update, tail, (usd) => costUsd = usd, (window) => context = window);
77334
77363
  events.update(obj(msg.params).update);
77335
77364
  emit();
@@ -77357,20 +77386,22 @@ async function oneTurn(io, options) {
77357
77386
  );
77358
77387
  try {
77359
77388
  const mcpServers = options.mcpConfig ? mcpServersIn(options.mcpConfig) : [];
77360
- await rpc.call("initialize", {
77389
+ phase("preparing");
77390
+ await bounded(rpc.call("initialize", {
77361
77391
  protocolVersion: PROTOCOL_VERSION,
77362
77392
  clientCapabilities: CLIENT_CAPABILITIES,
77363
77393
  clientInfo: { name: "ai4kanban", version: SKILL_VERSION }
77364
- });
77394
+ }), preparingUntil - Date.now(), "ACP initialize timed out.");
77395
+ phase("initialized");
77365
77396
  let sessionId = io.resumeId ?? "";
77366
77397
  let prompt = io.prompt;
77367
77398
  let opened;
77368
77399
  if (sessionId) {
77369
77400
  try {
77370
- opened = await rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers });
77401
+ opened = await bounded(rpc.call("session/load", { sessionId, cwd: io.cwd, mcpServers }), preparingUntil - Date.now(), "ACP session/load timed out.");
77371
77402
  } catch (e) {
77372
77403
  if (!sessionGone(e) || !io.restartPrompt) throw e;
77373
- const fresh = await newSession(rpc, io.cwd, mcpServers);
77404
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
77374
77405
  opened = fresh.opened;
77375
77406
  sessionId = fresh.sessionId;
77376
77407
  prompt = io.restartPrompt;
@@ -77380,7 +77411,7 @@ async function oneTurn(io, options) {
77380
77411
  emit();
77381
77412
  }
77382
77413
  } else {
77383
- const fresh = await newSession(rpc, io.cwd, mcpServers);
77414
+ const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
77384
77415
  opened = fresh.opened;
77385
77416
  sessionId = fresh.sessionId;
77386
77417
  io.gotResumeId(sessionId);
@@ -77389,11 +77420,15 @@ async function oneTurn(io, options) {
77389
77420
  if (options.model) {
77390
77421
  const listed2 = obj(opened.models).currentModelId !== void 0;
77391
77422
  const picked = listed2 ? pickedModel(opened, options.model) : void 0;
77392
- 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 });
77423
+ 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.");
77393
77424
  model = picked?.name ?? modelOf(set) ?? options.model;
77394
77425
  }
77395
77426
  if (model) io.gotModel(model);
77427
+ if (Date.now() >= preparingUntil) throw Error("ACP preparation timed out.");
77428
+ phase("ready");
77429
+ currentSession = sessionId;
77396
77430
  live = true;
77431
+ phase("submitted");
77397
77432
  const done = await rpc.call("session/prompt", {
77398
77433
  sessionId,
77399
77434
  prompt: [{ type: "text", text: prompt }]
@@ -77810,10 +77845,24 @@ function createCodexClient(options = { images: [] }) {
77810
77845
  }
77811
77846
  async function run(io, options, tasks2) {
77812
77847
  const renderer = createCodexStreamRenderer();
77848
+ const preparingUntil = Math.min(io.prepareUntil ?? Infinity, Date.now() + CONVERSATION_MS.prepare);
77849
+ const phase = (phase2) => io.event?.({ kind: "phase", data: { phase: phase2, at: (/* @__PURE__ */ new Date()).toISOString() } });
77850
+ let submitted = false;
77851
+ let started = false;
77852
+ let contentAt = 0;
77853
+ let startupTimer;
77854
+ const began = () => {
77855
+ if (!submitted || started || ended) return;
77856
+ started = true;
77857
+ clearTimeout(startupTimer);
77858
+ phase("started");
77859
+ };
77813
77860
  const children = /* @__PURE__ */ new Set();
77814
77861
  const commands = /* @__PURE__ */ new Set();
77815
77862
  const seenItems = /* @__PURE__ */ new Set();
77816
77863
  const completedTurns = /* @__PURE__ */ new Set();
77864
+ const historicalTurns = /* @__PURE__ */ new Set();
77865
+ let currentTurn2 = "";
77817
77866
  let threadId = "";
77818
77867
  let active = true;
77819
77868
  let waiting2 = false;
@@ -77839,6 +77888,7 @@ async function run(io, options, tasks2) {
77839
77888
  if (ended) return;
77840
77889
  ended = true;
77841
77890
  clearTimeout(timer);
77891
+ clearTimeout(startupTimer);
77842
77892
  deadline.close();
77843
77893
  io.stdout.off("close", closed);
77844
77894
  io.log(renderer.flush());
@@ -77870,10 +77920,11 @@ async function run(io, options, tasks2) {
77870
77920
  io.event?.({ kind: "tool_call_update", data: { toolCallId: `agent:${id}`, status: failed ? "failed" : "completed", result: str2(state2.message) } });
77871
77921
  }
77872
77922
  };
77873
- const item = (raw, completed) => {
77923
+ const item = (raw, completed, proof = true) => {
77874
77924
  if (ended) return;
77875
77925
  const id = str2(raw.id);
77876
77926
  if (raw.type === "collabAgentToolCall") {
77927
+ if (proof) began();
77877
77928
  const key2 = `${id}:${completed}`;
77878
77929
  if (seenItems.has(key2)) return;
77879
77930
  seenItems.add(key2);
@@ -77901,6 +77952,7 @@ async function run(io, options, tasks2) {
77901
77952
  const types = { agentMessage: "agent_message", commandExecution: "command_execution", fileChange: "file_change", mcpToolCall: "mcp_tool_call", webSearch: "web_search", imageGeneration: "image_generation" };
77902
77953
  const type = types[str2(raw.type)];
77903
77954
  if (!type) return;
77955
+ if (proof) began();
77904
77956
  emit(completed ? "item.completed" : "item.started", { item: {
77905
77957
  ...raw,
77906
77958
  type,
@@ -77914,7 +77966,16 @@ async function run(io, options, tasks2) {
77914
77966
  const start = async (text4, images = []) => {
77915
77967
  active = true;
77916
77968
  waiting2 = false;
77917
- await rpc.call("turn/start", { threadId, input: [{ type: "text", text: text4 }, ...images.map((path32) => ({ type: "localImage", path: path32 }))] });
77969
+ submitted = true;
77970
+ currentTurn2 = "";
77971
+ started = false;
77972
+ phase("submitted");
77973
+ startupTimer = setTimeout(() => {
77974
+ if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
77975
+ }, CONVERSATION_MS.start);
77976
+ await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text4 }, ...images.map((path32) => ({ type: "localImage", path: path32 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error2) => {
77977
+ if (!started) throw error2;
77978
+ });
77918
77979
  };
77919
77980
  const schedule = () => {
77920
77981
  if (ended || timer) return;
@@ -77999,11 +78060,21 @@ async function run(io, options, tasks2) {
77999
78060
  }
78000
78061
  const p = obj(msg.params);
78001
78062
  if (str2(p.threadId) !== threadId) return;
78063
+ const turnId = str2(p.turnId) || str2(obj(p.turn).id);
78064
+ if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
78002
78065
  if (msg.method === "turn/started") {
78066
+ if (!submitted || completedTurns.has(turnId)) return;
78067
+ currentTurn2 = turnId;
78003
78068
  active = true;
78069
+ began();
78004
78070
  return;
78005
78071
  }
78006
- if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed");
78072
+ if (submitted && msg.method === "item/agentMessage/delta" && Date.now() - contentAt >= 1e3) {
78073
+ began();
78074
+ contentAt = Date.now();
78075
+ io.event?.({ kind: "phase", data: { phase: "started", at: (/* @__PURE__ */ new Date()).toISOString(), contentAt: new Date(contentAt).toISOString() } });
78076
+ }
78077
+ if (msg.method === "item/started" || msg.method === "item/completed") item(obj(p.item), msg.method === "item/completed", !completedTurns.has(turnId));
78007
78078
  if (msg.method === "thread/tokenUsage/updated") {
78008
78079
  const token = obj(p.tokenUsage);
78009
78080
  const counts = obj(token.total);
@@ -78034,17 +78105,20 @@ async function run(io, options, tasks2) {
78034
78105
  }
78035
78106
  });
78036
78107
  try {
78037
- await rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } });
78108
+ phase("preparing");
78109
+ await bounded(rpc.call("initialize", { clientInfo: { name: "wildcrane", version: "1" }, capabilities: { experimentalApi: true } }), preparingUntil - Date.now(), "Codex initialize timed out.");
78110
+ phase("initialized");
78038
78111
  rpc.notify("initialized");
78039
78112
  const mode = options.mode ?? (io.resumeId ? "resume" : void 0);
78040
78113
  let response;
78041
78114
  try {
78042
- response = await rpc.call(`thread/${mode ?? "start"}`, { cwd: options.cwd ?? io.cwd, ...mode ? { threadId: options.threadId ?? io.resumeId } : {} });
78115
+ 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.`);
78043
78116
  } catch (e) {
78044
78117
  if (mode && e instanceof RpcError && /no rollout found for thread id/i.test(e.message)) throw Error(`Thread not found: ${e.message}`);
78045
78118
  throw e;
78046
78119
  }
78047
78120
  const thread = obj(response.thread);
78121
+ for (const turn2 of list(thread.turns)) historicalTurns.add(str2(turn2.id));
78048
78122
  threadId = str2(thread.id);
78049
78123
  if (!threadId) throw Error("Codex did not return a thread id.");
78050
78124
  provider = str2(thread.modelProvider) || void 0;
@@ -78053,6 +78127,8 @@ async function run(io, options, tasks2) {
78053
78127
  io.gotResumeId(threadId);
78054
78128
  baseline = readCodexRunFacts(threadId)?.turns?.at(-1)?.total;
78055
78129
  emit("thread.started", { thread_id: threadId });
78130
+ if (Date.now() >= preparingUntil) throw Error("Codex preparation timed out.");
78131
+ phase("ready");
78056
78132
  await start(io.prompt, options.images);
78057
78133
  } catch (e) {
78058
78134
  end(e instanceof Error ? e.message : String(e));