wildcrane-runner 0.6.121 → 0.6.123

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.121 — built by runner/scripts/build.mjs. Do not edit.
1
+ // wildcrane-runner 0.6.123 — 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;
@@ -40959,6 +40959,7 @@ function withSystemProxy(env2 = process.env, platform = process.platform, read3
40959
40959
 
40960
40960
  // src/proxy.ts
40961
40961
  var LOOPBACK = "localhost,127.0.0.1,[::1]";
40962
+ var withLoopback = (value) => [value, LOOPBACK].filter(Boolean).join(",");
40962
40963
  var HOST_PROXY_ENV = "WILDCRANE_HOST_PROXY";
40963
40964
  var HOST = null;
40964
40965
  var current = {};
@@ -40979,7 +40980,7 @@ function followProxy(read3) {
40979
40980
  const route = {
40980
40981
  httpProxy,
40981
40982
  httpsProxy: current.HTTPS_PROXY || current.https_proxy || httpProxy,
40982
- noProxy: [current.NO_PROXY ?? current.no_proxy, LOOPBACK].filter(Boolean).join(",")
40983
+ noProxy: withLoopback(current.NO_PROXY ?? current.no_proxy)
40983
40984
  };
40984
40985
  const key = JSON.stringify(route);
40985
40986
  if (key !== applied) {
@@ -41418,10 +41419,8 @@ function landSections(body, previews) {
41418
41419
  const start = heading.index;
41419
41420
  const end = start + heading[0].length;
41420
41421
  if (!/^ {0,3}##[ \t]+Land(?:[ \t]+#+)?[ \t]*$/.test(visible.slice(start, end))) return [];
41421
- return [{
41422
- offset: start + heading[0].indexOf("#"),
41423
- empty: !visible.slice(end, headings[index + 1]?.index).replace(comments, "").trim()
41424
- }];
41422
+ const text2 = visible.slice(end, headings[index + 1]?.index).replace(comments, "").trim();
41423
+ return [{ offset: start + heading[0].indexOf("#"), empty: !text2, text: text2 }];
41425
41424
  });
41426
41425
  }
41427
41426
  function parseStudioFile(id, source, from, { requirePreviewCopy = false, requireLand = false } = {}) {
@@ -41756,13 +41755,13 @@ function cloudProblem(response, body) {
41756
41755
  }
41757
41756
 
41758
41757
  // src/protocol.ts
41759
- var VERSION = true ? "0.6.121" : "0.0.0";
41760
- var AKB_VERSION = true ? "0.11.103" : "0.0.0";
41758
+ var VERSION = true ? "0.6.123" : "0.0.0";
41759
+ var AKB_VERSION = true ? "0.11.105" : "0.0.0";
41761
41760
 
41762
41761
  // ../cli/src/lib/agent/harnesses/antigravity.ts
41763
41762
  import fs10 from "node:fs";
41764
41763
  import path12 from "node:path";
41765
- import { createHash as createHash4 } from "node:crypto";
41764
+ import { createHash as createHash5 } from "node:crypto";
41766
41765
  import { spawnSync as spawnSync2 } from "node:child_process";
41767
41766
 
41768
41767
  // ../cli/src/lib/agent/locate.ts
@@ -42274,7 +42273,7 @@ function rootAbove(board) {
42274
42273
  var NESTED_STATE = /(^|[/\\])\.akb[/\\](?:(?:boards|hidden-boards)[/\\])?\.akb(?=[/\\]|$)/;
42275
42274
  var InvalidBoardStatePath = class extends BoardError {
42276
42275
  constructor(file2, state, id) {
42277
- const use = state ? `Use ${state}${id ? ` or an .assets/${id}/\u2026 reference` : ""}.` : "Use the board\u2019s project-local state directory.";
42276
+ const use = state ? `Use ${state}${id ? ` or an asset:<path> reference` : ""}.` : "Use the board\u2019s project-local state directory.";
42278
42277
  super(`Invalid nested board state path: ${file2}. ${use}`, { kind: "board-state-path" });
42279
42278
  }
42280
42279
  };
@@ -42624,7 +42623,22 @@ ${files.map((file2) => `- ${file2}`).join("\n")}` : "";
42624
42623
  import fs9 from "node:fs";
42625
42624
 
42626
42625
  // ../cli/src/lib/agent/wire/events.ts
42626
+ import { createHash as createHash4 } from "node:crypto";
42627
42627
  var TOOL_KINDS = ["read", "edit", "delete", "move", "search", "execute", "fetch", "other"];
42628
+ var isPollingTool = (title) => /^(?:.*\.)?(?:command_status|wait(?:_5_seconds|_agent)?|TaskOutput)$/i.test(title);
42629
+ var toolOutput = (text2) => text2.split(/\r?\n/).map((line) => line.trim()).filter(
42630
+ (line) => line && !/^(?:\[?heartbeat\]?(?:\b|\s|$)|(?:status:\s*)?(?:(?:command|task) (?:is )?(?:still )?running|running|in[_ ]progress|pending)[.!]?$)/i.test(line)
42631
+ ).join("\n");
42632
+ function progressSnapshots() {
42633
+ const seen = /* @__PURE__ */ new Set();
42634
+ return (key, text2) => {
42635
+ if (!text2) return false;
42636
+ const digest = createHash4("sha256").update(key).update("\0").update(text2).digest("base64");
42637
+ if (seen.has(digest)) return false;
42638
+ seen.add(digest);
42639
+ return true;
42640
+ };
42641
+ }
42628
42642
  var toolKind = (v) => TOOL_KINDS.includes(str2(v)) ? v : "other";
42629
42643
  function targetOf(raw) {
42630
42644
  const line = raw.split("\n")[0].trim();
@@ -42662,6 +42676,8 @@ function createEventCollector() {
42662
42676
  let queue = [];
42663
42677
  let said = "";
42664
42678
  let activity = 0;
42679
+ const fresh = progressSnapshots();
42680
+ const polls = /* @__PURE__ */ new Map();
42665
42681
  const todoCalls = /* @__PURE__ */ new Set();
42666
42682
  const held2 = /* @__PURE__ */ new Map();
42667
42683
  let todos = [];
@@ -42680,6 +42696,9 @@ function createEventCollector() {
42680
42696
  progress: () => {
42681
42697
  activity++;
42682
42698
  },
42699
+ progressSnapshot(key, text2) {
42700
+ if (fresh(key, toolOutput(text2))) activity++;
42701
+ },
42683
42702
  submitted() {
42684
42703
  queue.push({ kind: "phase", data: { phase: "submitted", at: (/* @__PURE__ */ new Date()).toISOString() } });
42685
42704
  },
@@ -42701,6 +42720,8 @@ function createEventCollector() {
42701
42720
  todoCalls.add(id);
42702
42721
  return;
42703
42722
  }
42723
+ const title = str2(u.title);
42724
+ if (isPollingTool(title)) polls.set(id, `${title}:${str2(obj2(u.rawInput).task_id) || str2(obj2(u.rawInput).CommandId)}`);
42704
42725
  const target = targetIn(u);
42705
42726
  const subagent = /^(?:Task|Agent|delegate_task|spawn_agent)$/i.test(str2(u.title)) || !!obj2(u.rawInput).subagent_type;
42706
42727
  const data = { toolCallId: id, title: str2(u.title) || "tool", kind: toolKind(u.kind), status: str2(u.status) || "pending", ...subagent ? { subagent: true } : {}, ...target ? { target } : {} };
@@ -42716,7 +42737,9 @@ function createEventCollector() {
42716
42737
  return;
42717
42738
  }
42718
42739
  release(id, targetIn(u));
42719
- const result = contentText(u.content);
42740
+ const result = contentText(u.content) || str2(obj2(u.rawOutput).output) || str2(u.rawOutput);
42741
+ const poll = polls.get(id);
42742
+ if (poll && fresh(poll, toolOutput(result))) activity++;
42720
42743
  if (!u.status && !result) return;
42721
42744
  queue.push({
42722
42745
  kind: "tool_call_update",
@@ -42924,8 +42947,8 @@ function createTail(log) {
42924
42947
  // ../cli/package.json
42925
42948
  var package_default = {
42926
42949
  name: "wildcrane",
42927
- version: "0.11.103",
42928
- akbContract: 36,
42950
+ version: "0.11.105",
42951
+ akbContract: 39,
42929
42952
  canonicalCommands: true,
42930
42953
  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.",
42931
42954
  keywords: [
@@ -43692,11 +43715,22 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
43692
43715
  let out = "";
43693
43716
  if (!calls.has(id)) {
43694
43717
  calls.add(id);
43695
- events.toolCall(id, name, KINDS[name] ?? "other", target);
43718
+ if (["invoke_subagent", "browser_subagent"].includes(name)) events.subagent(id, target || name);
43719
+ else events.toolCall(id, name, KINDS[name] ?? "other", target);
43696
43720
  out = `
43697
43721
  \u23FA ${name}${target ? ` ${target}` : ""}
43698
43722
  `;
43699
43723
  }
43724
+ const output2 = str2(tool.output);
43725
+ if (isPollingTool(name)) {
43726
+ const command = str2(p.CommandId) || str2(p.CommandID) || name;
43727
+ const commandOutput = /(?:^|\n)Command output:\s*([\s\S]*)/.exec(output2)?.[1].trim();
43728
+ const exit = /(?:^|\n)(Command exited with code -?\d+\.)/.exec(output2)?.[1];
43729
+ if (commandOutput) events.progressSnapshot(`command:${command}`, commandOutput);
43730
+ if (exit) events.progressSnapshot(`exit:${command}`, exit);
43731
+ } else if (!["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str2(step.state))) {
43732
+ events.progressSnapshot(id, output2);
43733
+ }
43700
43734
  const error = obj2(tool.error);
43701
43735
  const reason = str2(error.message) || str2(error.type);
43702
43736
  if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str2(step.state)) && !closed.has(id)) {
@@ -43714,7 +43748,7 @@ ${imageError(target, reason || str2(step.state))}
43714
43748
  imageErrors.delete(file2);
43715
43749
  }
43716
43750
  }
43717
- events.toolResult(id, failed ? "failed" : "completed", str2(tool.output) || reason);
43751
+ events.toolResult(id, failed ? "failed" : "completed", output2 || reason);
43718
43752
  }
43719
43753
  return out;
43720
43754
  }
@@ -43828,7 +43862,7 @@ function systemPrompt(text2, _argv, env2) {
43828
43862
  const rule = `${text2}
43829
43863
 
43830
43864
  The task working directory is ${env2.PWD ?? process.cwd()}. Use it as the base for project files and commands. This additional workspace contains only language rules; do not write task output here.`;
43831
- const hash = createHash4("sha256").update(rule).digest("hex").slice(0, 16);
43865
+ const hash = createHash5("sha256").update(rule).digest("hex").slice(0, 16);
43832
43866
  const root2 = path12.join(machineHome(), "prompts", `antigravity-${hash}`);
43833
43867
  const file2 = path12.join(root2, ".agents", "rules", "language.md");
43834
43868
  fs10.mkdirSync(path12.dirname(file2), { recursive: true });
@@ -44080,6 +44114,7 @@ function createStreamRenderer() {
44080
44114
  const plans = /* @__PURE__ */ new Set();
44081
44115
  const subagents = /* @__PURE__ */ new Map();
44082
44116
  const detached = /* @__PURE__ */ new Set();
44117
+ const taskUsage = /* @__PURE__ */ new Map();
44083
44118
  const endSubagent = (id, status2) => {
44084
44119
  if (subagents.get(id) !== false) return;
44085
44120
  subagents.set(id, true);
@@ -44091,8 +44126,18 @@ function createStreamRenderer() {
44091
44126
  if (!ev) return `${line}
44092
44127
  `;
44093
44128
  if (model === void 0) model = eventModel(ev);
44094
- if (str2(ev.parent_tool_use_id)) return "";
44095
- if (ev.type === "assistant" || ev.type === "stream_event" && obj2(ev.event).type === "content_block_delta") events.progress();
44129
+ const parent = str2(ev.parent_tool_use_id);
44130
+ const content = obj2(ev.message).content;
44131
+ const streamEvent = obj2(ev.event);
44132
+ const delta = obj2(streamEvent.delta);
44133
+ if (ev.type === "stream_event" && streamEvent.type === "content_block_delta" && (str2(delta.text) || str2(delta.thinking) || str2(delta.partial_json))) events.progress();
44134
+ if (parent) {
44135
+ if (["assistant", "user"].includes(str2(ev.type)) && Array.isArray(content)) {
44136
+ const useful = content.map(obj2).filter((block) => !!str2(block.text).trim() || !!str2(block.thinking).trim() || block.type === "tool_use" || block.type === "tool_result" && !!resultText(block.content).trim());
44137
+ if (useful.length) events.progressSnapshot(parent, JSON.stringify(useful));
44138
+ }
44139
+ return "";
44140
+ }
44096
44141
  switch (ev.type) {
44097
44142
  case "assistant": {
44098
44143
  apiFailure = typeof ev.error === "string" ? providerFailure({ type: ev.error }, "Claude could not complete the request.") : void 0;
@@ -44108,6 +44153,8 @@ function createStreamRenderer() {
44108
44153
 
44109
44154
  `);
44110
44155
  events.message(b.text);
44156
+ } else if (b?.type === "thinking" && str2(b.thinking).trim()) {
44157
+ events.progressSnapshot("thinking", str2(b.thinking));
44111
44158
  } else if (b?.type === "tool_use" && typeof b.name === "string") {
44112
44159
  out.push(`\u23FA ${b.name}${argHint(b.input, ARG_KEYS)}
44113
44160
  `);
@@ -44127,8 +44174,8 @@ function createStreamRenderer() {
44127
44174
  return out.join("");
44128
44175
  }
44129
44176
  case "user": {
44130
- const content = obj2(ev.message).content;
44131
- for (const raw of Array.isArray(content) ? content : []) {
44177
+ const content2 = obj2(ev.message).content;
44178
+ for (const raw of Array.isArray(content2) ? content2 : []) {
44132
44179
  const b = obj2(raw);
44133
44180
  if (b.type !== "tool_result" || plans.has(str2(b.tool_use_id))) continue;
44134
44181
  if (subagents.has(str2(b.tool_use_id))) {
@@ -44172,8 +44219,20 @@ function createStreamRenderer() {
44172
44219
  if (ev.subtype === "task_notification" && subagents.has(str2(ev.tool_use_id))) {
44173
44220
  endSubagent(str2(ev.tool_use_id), str2(ev.status) === "completed" ? "completed" : "failed");
44174
44221
  }
44175
- if (ev.subtype === "task_notification" && backgrounded.has(str2(ev.task_id)) && str2(ev.summary)) {
44176
- return `\u23FA ${str2(ev.summary)}
44222
+ const task = str2(ev.task_id);
44223
+ if (ev.subtype === "task_progress" && task) {
44224
+ const usage2 = obj2(ev.usage);
44225
+ const previous = taskUsage.get(task) ?? { tokens: 0, tools: 0 };
44226
+ const tokens = Math.max(previous.tokens, Number(usage2.total_tokens) || 0);
44227
+ const tools = Math.max(previous.tools, Number(usage2.tool_uses) || 0);
44228
+ if (tokens > previous.tokens || tools > previous.tools) {
44229
+ taskUsage.set(task, { tokens, tools });
44230
+ events.progress();
44231
+ }
44232
+ }
44233
+ if (ev.subtype === "task_notification" && backgrounded.delete(task)) {
44234
+ events.progress();
44235
+ if (str2(ev.summary)) return `\u23FA ${str2(ev.summary)}
44177
44236
  `;
44178
44237
  }
44179
44238
  return "";
@@ -44513,23 +44572,20 @@ function createCodexStreamRenderer(carried = false) {
44513
44572
  const started = /* @__PURE__ */ new Set();
44514
44573
  const background = createBackgroundTasks();
44515
44574
  const subagents = /* @__PURE__ */ new Set();
44516
- const collabItems = /* @__PURE__ */ new Set();
44517
- const collab = (item, done) => {
44575
+ const collab = (item) => {
44518
44576
  if (item.type !== "collab_tool_call") return;
44519
- const key = `${str2(item.id)}:${done}`;
44520
- if (collabItems.has(key)) return;
44521
- collabItems.add(key);
44522
44577
  for (const [id, raw] of Object.entries(obj2(item.agents_states))) {
44523
44578
  const state = obj2(raw);
44524
44579
  const status2 = str2(state.status);
44525
44580
  if (!["pending_init", "running", "completed", "interrupted", "errored", "shutdown", "not_found"].includes(status2)) continue;
44526
44581
  const previous = background.results().find((t2) => t2.id === id);
44527
- if (["shutdown", "not_found"].includes(status2) && previous && previous.status !== "running") continue;
44582
+ const running = status2 === "pending_init" || status2 === "running";
44583
+ if ((running || ["shutdown", "not_found"].includes(status2)) && previous && previous.status !== "running") continue;
44528
44584
  if (!subagents.has(id)) {
44529
44585
  subagents.add(id);
44530
44586
  events.subagent(`agent:${id}`, str2(item.prompt) || "Agent");
44531
44587
  }
44532
- const running = status2 === "pending_init" || status2 === "running";
44588
+ if (running) events.progressSnapshot(`agent:${id}`, str2(state.message));
44533
44589
  const failed = !running && status2 !== "completed";
44534
44590
  if (background.update(id, running ? "running" : failed ? "failed" : "completed", str2(state.message)) && !running) {
44535
44591
  events.toolResult(`agent:${id}`, failed ? "failed" : "completed", str2(state.message));
@@ -44562,15 +44618,21 @@ function createCodexStreamRenderer(carried = false) {
44562
44618
  if (!threadId) threadId = str2(ev.thread_id).trim() || void 0;
44563
44619
  return "";
44564
44620
  case "item.started":
44565
- collab(obj2(ev.item), false);
44621
+ collab(obj2(ev.item));
44566
44622
  itemEvents(events, started, obj2(ev.item), false);
44567
44623
  return renderStarted(obj2(ev.item));
44568
- case "item.updated":
44569
- if (obj2(ev.item).type === "todo_list") itemEvents(events, started, obj2(ev.item), false);
44624
+ case "item.updated": {
44625
+ const item = obj2(ev.item);
44626
+ collab(item);
44627
+ if (item.type === "todo_list") itemEvents(events, started, item, false);
44628
+ if (item.type === "command_execution" && started.has(str2(item.id))) {
44629
+ events.progressSnapshot(`command:${str2(item.id)}`, str2(item.aggregated_output));
44630
+ }
44570
44631
  return "";
44632
+ }
44571
44633
  case "item.completed": {
44572
44634
  const item = obj2(ev.item);
44573
- collab(item, true);
44635
+ collab(item);
44574
44636
  if (item.type === "mcp_tool_call" && !/view_image|read_image|open_image/.test(str2(item.tool))) {
44575
44637
  const content = obj2(item.result).content;
44576
44638
  for (const block of Array.isArray(content) ? content : []) {
@@ -44839,7 +44901,8 @@ function createKimiStreamRenderer(cwd, resumeId) {
44839
44901
  `;
44840
44902
  switch (row.role) {
44841
44903
  case "assistant": {
44842
- events.progress();
44904
+ const thought = str2(row.reasoning_content);
44905
+ if (thought) events.progressSnapshot("reasoning", thought);
44843
44906
  const said = str2(row.content).trim();
44844
44907
  if (said) final = said;
44845
44908
  if (said) events.message(said);
@@ -44936,7 +44999,7 @@ function modelOf2(ref) {
44936
44999
  const provider = str2(model.providerId);
44937
45000
  return provider ? `${provider}/${id}` : id;
44938
45001
  }
44939
- function createParts(tail) {
45002
+ function createParts(tail, activity) {
44940
45003
  const written = /* @__PURE__ */ new Map();
44941
45004
  const tools = /* @__PURE__ */ new Set();
44942
45005
  const named = /* @__PURE__ */ new Map();
@@ -44945,6 +45008,7 @@ function createParts(tail) {
44945
45008
  const fresh = text2.startsWith(before) ? text2.slice(before.length) : text2;
44946
45009
  if (!fresh) return;
44947
45010
  written.set(partId, text2);
45011
+ activity();
44948
45012
  if (kind === "reasoning" || kind === "thought") tail.thought(fresh);
44949
45013
  else tail.text(fresh);
44950
45014
  };
@@ -44956,7 +45020,10 @@ function createParts(tail) {
44956
45020
  const partId = str2(part.partId);
44957
45021
  if (type === "text" || type === "reasoning" || type === "thought") {
44958
45022
  if (partId) say(partId, type, str2(part.text));
44959
- else tail.text(str2(part.text));
45023
+ else if (str2(part.text)) {
45024
+ activity();
45025
+ tail.text(str2(part.text));
45026
+ }
44960
45027
  return;
44961
45028
  }
44962
45029
  if (type !== "tool") return;
@@ -44980,14 +45047,18 @@ function createParts(tail) {
44980
45047
  const delta = str2(event2.delta);
44981
45048
  if (!delta) return;
44982
45049
  written.set(partId, (written.get(partId) ?? "") + delta);
45050
+ activity();
44983
45051
  if (field === "reasoning") tail.thought(delta);
44984
45052
  else tail.text(delta);
44985
45053
  },
44986
45054
  /** A piece of the turn, as `model.streaming` sends it. */
44987
45055
  streaming(payload) {
44988
45056
  const kind = str2(payload.kind);
44989
- if (kind === "text_delta") return tail.text(str2(payload.delta));
44990
- if (kind === "reasoning_delta") return tail.thought(str2(payload.delta));
45057
+ const delta = str2(payload.delta);
45058
+ if (delta && (kind === "text_delta" || kind === "reasoning_delta")) {
45059
+ activity();
45060
+ return kind === "text_delta" ? tail.text(delta) : tail.thought(delta);
45061
+ }
44991
45062
  if (kind !== "tool_call") return;
44992
45063
  const callId = str2(payload.toolCallId);
44993
45064
  const name = str2(payload.toolName) || "tool";
@@ -45027,7 +45098,7 @@ function stopped(io, why) {
45027
45098
  }
45028
45099
  async function oneTurn2(io, options) {
45029
45100
  const tail = createTail(io.log);
45030
- const parts = createParts(tail);
45101
+ const parts = createParts(tail, () => io.activity?.());
45031
45102
  const activityEvents = createEventCollector();
45032
45103
  const activeCalls = /* @__PURE__ */ new Set();
45033
45104
  let live = false;
@@ -45054,7 +45125,6 @@ async function oneTurn2(io, options) {
45054
45125
  const part = obj2(payload.part);
45055
45126
  const state = obj2(part.state);
45056
45127
  const type = str2(envelope.type);
45057
- if (["part.delta", "model.streaming"].includes(type) && str2(payload.delta)) io.activity?.();
45058
45128
  const id = str2(payload.toolCallId) || str2(part.callId) || str2(part.partId);
45059
45129
  const name = str2(payload.toolName) || str2(part.tool) || str2(state.title);
45060
45130
  if (id && name && !activeCalls.has(id)) {
@@ -45063,7 +45133,21 @@ async function oneTurn2(io, options) {
45063
45133
  else activityEvents.toolCall(id, name, /^(?:bash|shell|execute|run_command|terminal)$/i.test(name) ? "execute" : "other");
45064
45134
  }
45065
45135
  const status2 = str2(state.status) || str2(payload.kind);
45066
- if (id && ["completed", "error", "result"].includes(status2)) activityEvents.toolResult(id, status2 === "error" ? "failed" : "completed", "");
45136
+ const output2 = str2(state.output) || str2(payload.output);
45137
+ if (type === "part.delta" && payload.field === "output") {
45138
+ const before = activityEvents.activity();
45139
+ activityEvents.progressSnapshot(id || str2(payload.partId), str2(payload.delta));
45140
+ if (activityEvents.activity() > before) io.activity?.();
45141
+ }
45142
+ if (id && ["completed", "error", "result"].includes(status2)) {
45143
+ activityEvents.toolResult(id, status2 === "error" ? "failed" : "completed", output2);
45144
+ } else if (id && output2) {
45145
+ activityEvents.update({
45146
+ sessionUpdate: "tool_call_update",
45147
+ toolCallId: id,
45148
+ content: [{ type: "content", content: { text: output2 } }]
45149
+ });
45150
+ }
45067
45151
  for (const e of activityEvents.events()) io.event?.(e);
45068
45152
  }
45069
45153
  event(envelope, parts, tail, live, ended);
@@ -45132,6 +45216,7 @@ async function oneTurn2(io, options) {
45132
45216
  });
45133
45217
  const before = io.resumeId ? await tokensOf(rpc, sessionId) : ZERO_USAGE;
45134
45218
  live = true;
45219
+ io.event?.({ kind: "phase", data: { phase: "submitted", at: (/* @__PURE__ */ new Date()).toISOString() } });
45135
45220
  const accepted = await rpc.call("session/send", { sessionId, content: io.prompt });
45136
45221
  if (accepted.accepted === false) throw new Error("the agent would not take the prompt");
45137
45222
  const done = await finished;
@@ -45213,9 +45298,8 @@ function decide2(params, tail) {
45213
45298
 
45214
45299
  // ../cli/src/lib/agent/idle.ts
45215
45300
  var IDLE_MS = 5 * 6e4;
45216
- var IDLE_ERROR = "No response for 5 minutes (idle timeout).";
45301
+ var IDLE_ERROR = "No verifiable progress for 5 minutes (idle timeout).";
45217
45302
  var IDLE_FAILURE = { code: "idle_timeout", source: "runtime", summary: IDLE_ERROR };
45218
- var PROVIDER_RETRY_MS = { announcement: 10 * 6e4, episode: 30 * 6e4 };
45219
45303
 
45220
45304
  // ../cli/src/lib/agent/wire/codex.ts
45221
45305
  import { randomUUID } from "node:crypto";
@@ -45544,6 +45628,7 @@ async function run(io, options, count2) {
45544
45628
  const offered = /* @__PURE__ */ new Map();
45545
45629
  const snapshot = (w) => JSON.stringify([w.threadId, w.processId, w.status, w.exitCode, w.result]);
45546
45630
  const childEvents = /* @__PURE__ */ new Map();
45631
+ const freshOutput = progressSnapshots();
45547
45632
  const seenItems = /* @__PURE__ */ new Set();
45548
45633
  const completedTurns = /* @__PURE__ */ new Set();
45549
45634
  const historicalTurns = /* @__PURE__ */ new Set();
@@ -45578,6 +45663,9 @@ async function run(io, options, count2) {
45578
45663
  io.stdout.off("close", closed);
45579
45664
  io.stdin.off("error", inputFailed);
45580
45665
  if (settlement) flushMessages(work.work().some((w) => !w.intentionalStop && !["running", "unknown"].includes(w.status) && presented.get(w.id) !== snapshot(w)));
45666
+ if (classified?.code === "codex_ownership_unconfirmed") {
45667
+ cleanup = { ...cleanup, status: "unconfirmed", detail: classified.detail ?? classified.summary };
45668
+ }
45581
45669
  cleanup.items = work.work().map(({ id, threadId: threadId2, processId, status: status3, disposition }) => ({ id, threadId: threadId2, processId, status: status3, disposition }));
45582
45670
  io.log(renderer.flush());
45583
45671
  const usage = ownUsage(total, baseline);
@@ -45638,7 +45726,9 @@ async function run(io, options, count2) {
45638
45726
  io.idleSignal?.addEventListener("abort", idle, { once: true });
45639
45727
  const childUpdates = () => {
45640
45728
  for (const w of work.entries.values()) {
45641
- if (w.kind !== "agent" || childEvents.get(w.id) === w.status) continue;
45729
+ if (w.kind !== "agent") continue;
45730
+ if (w.status === "running" && freshOutput(w.id, toolOutput(w.result))) io.activity?.();
45731
+ if (childEvents.get(w.id) === w.status) continue;
45642
45732
  if (!childEvents.has(w.id)) io.event?.({ kind: "tool_call", data: { toolCallId: w.id, title: "Agent", kind: "other", status: "in_progress", subagent: true } });
45643
45733
  if (w.status !== "running") io.event?.({ kind: "tool_call_update", data: { toolCallId: w.id, status: w.status === "completed" ? "completed" : "failed", result: w.result } });
45644
45734
  childEvents.set(w.id, w.status);
@@ -45876,7 +45966,26 @@ async function run(io, options, count2) {
45876
45966
  armCleanup();
45877
45967
  if (source === threadId && obj2(p.item).type !== "agentMessage") item(obj2(p.item), msg.method === "item/completed", false);
45878
45968
  }
45879
- if (source !== threadId) {
45969
+ const turnId = str2(p.turnId) || str2(obj2(p.turn).id);
45970
+ const main = source === threadId;
45971
+ const live = main ? !historicalTurns.has(turnId) && (!currentTurn2 || !turnId || currentTurn2 === turnId) : work.entries.get(`agent:${source}`)?.status === "running";
45972
+ const delta = str2(p.delta);
45973
+ if (submitted && live && delta) {
45974
+ if (["item/agentMessage/delta", "item/plan/delta", "item/reasoning/summaryTextDelta", "item/reasoning/textDelta"].includes(msg.method ?? "")) {
45975
+ if (main) {
45976
+ if (msg.method?.startsWith("item/reasoning/")) thinking();
45977
+ else recovered();
45978
+ }
45979
+ io.activity?.();
45980
+ }
45981
+ const terminal = terminalKey(source, str2(p.itemId));
45982
+ if (msg.method === "item/commandExecution/outputDelta" && work.entries.get(terminal)?.status === "running" && freshOutput(terminal, toolOutput(delta))) io.activity?.();
45983
+ }
45984
+ if (!main) {
45985
+ if (live && msg.method === "item/completed") {
45986
+ const item2 = obj2(p.item);
45987
+ if (freshOutput(`${source}:${str2(item2.id)}`, toolOutput(str2(item2.text) || str2(item2.aggregatedOutput)))) io.activity?.();
45988
+ }
45880
45989
  if (msg.method === "turn/completed") {
45881
45990
  work.observeTurn(source, obj2(p.turn));
45882
45991
  armCleanup();
@@ -45884,13 +45993,7 @@ async function run(io, options, count2) {
45884
45993
  childUpdates();
45885
45994
  return;
45886
45995
  }
45887
- const turnId = str2(p.turnId) || str2(obj2(p.turn).id);
45888
- if (historicalTurns.has(turnId) || currentTurn2 && turnId && currentTurn2 !== turnId) return;
45889
- if (submitted && ["item/agentMessage/delta", "item/plan/delta", "item/reasoning/summaryTextDelta", "item/reasoning/textDelta"].includes(msg.method ?? "") && str2(p.delta)) {
45890
- if (msg.method?.startsWith("item/reasoning/")) thinking();
45891
- else recovered();
45892
- io.activity?.();
45893
- }
45996
+ if (!live) return;
45894
45997
  if (msg.method === "turn/started") {
45895
45998
  if (!submitted || completedTurns.has(turnId)) return;
45896
45999
  currentTurn2 = turnId;
@@ -45992,7 +46095,6 @@ async function run(io, options, count2) {
45992
46095
  waiting = true;
45993
46096
  io.event?.({ kind: "log", data: { text: failure2.summary } });
45994
46097
  }
45995
- io.activity?.();
45996
46098
  await delay(500, void 0, { signal: io.signal });
45997
46099
  preparingUntil = Date.now() + CONVERSATION_MS.prepare;
45998
46100
  }
@@ -47449,7 +47551,7 @@ var removeFolder = (machineId2, project) => request("POST", `/v1/runner/folders/
47449
47551
  var import_yaml8 = __toESM(require_dist(), 1);
47450
47552
 
47451
47553
  // ../cli/src/lib/agent/cloud-studios.ts
47452
- import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
47554
+ import { createHash as createHash6, randomUUID as randomUUID2 } from "node:crypto";
47453
47555
  import fs17 from "node:fs";
47454
47556
  import path21 from "node:path";
47455
47557
 
@@ -47587,7 +47689,7 @@ function readJson(file2) {
47587
47689
  return null;
47588
47690
  }
47589
47691
  }
47590
- var filesHash = (files) => createHash5("sha256").update(hashInput(files)).digest("hex");
47692
+ var filesHash = (files) => createHash6("sha256").update(hashInput(files)).digest("hex");
47591
47693
  var readVersion = (id, version) => {
47592
47694
  const held2 = readJson(versionFile(id, version));
47593
47695
  return held2?.id === id && held2.version === version && isStudioFiles(held2.files) && (!held2.filesSha256 || filesHash(held2.files) === held2.filesSha256) ? held2 : null;
@@ -48479,16 +48581,36 @@ var PAGE = (outcome, lang, links) => {
48479
48581
  const top = links ? `<h1>${title}</h1><p>${body}</p><form id="f" novalidate><input id="e" type="email" autocomplete="email" placeholder="${c.email}" required><input id="c" inputmode="numeric" autocomplete="one-time-code" maxlength="10" placeholder="${c.code}" hidden><button id="b" class="dark">${c.send}</button><small id="m"></small><button id="x" type="button" class="link" hidden>${c.change}</button></form><div class="or">${c.or}</div><nav><a href="${links.github}">${GITHUB_ICON}${c.github}</a><a href="${links.google}">${GOOGLE_ICON}${c.google}</a></nav><script>${EMAIL_SCRIPT(c)}</script>` : `<span class="icon"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${icon2}</svg></span><h1 class="below">${title}</h1><p>${body}</p>`;
48480
48582
  return `<!doctype html><html lang="${lang === "zh" ? "zh-CN" : "en"}"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${title} \xB7 WildCrane</title><style>*{margin:0;box-sizing:border-box}body{display:flex;flex-direction:column;min-height:100dvh;background:#fff;color:#24231f;font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}header{padding:16px 36px 0}main{flex:1;display:flex;align-items:center;justify-content:center;padding:0 36px 64px;text-align:center}.icon{display:flex;margin:0 auto;width:44px;height:44px;border-radius:50%;align-items:center;justify-content:center;background:${ok ? "#e4f3ea" : "#f7ddce"};color:${ok ? "#2f6b46" : "#b83a12"}}h1{font-size:24px;font-weight:850;line-height:1.25;letter-spacing:-0.02em}h1.below{margin-top:16px}p{margin:8px auto 0;max-width:38ch;font-size:13px;line-height:19px;color:#565550}main>div.choose{width:100%;max-width:320px}nav{margin-top:28px;display:flex;flex-direction:column;gap:12px}nav a{display:flex;height:44px;align-items:center;justify-content:center;gap:8px;border-radius:10px;font-size:14.5px;font-weight:600;color:#24231f;text-decoration:none;background:#fff;border:1px solid rgba(36,35,31,0.14)}nav a.dark{background:#24231f;color:#fff;border-color:#24231f}form{margin-top:28px;display:flex;flex-direction:column;gap:12px}input{height:44px;padding:0 14px;border-radius:10px;border:1px solid rgba(36,35,31,0.14);font:inherit;font-size:14.5px}button{height:44px;border-radius:10px;border:0;font:inherit;font-size:14.5px;font-weight:600;cursor:pointer}button.dark{background:#24231f;color:#fff}button:disabled{opacity:.6}button.link{height:auto;background:none;color:#565550;font-size:13px;font-weight:500}small{font-size:13px;line-height:19px;color:#565550}small.bad{color:#b83a12}small:empty{display:none}.or{margin-top:20px;display:flex;align-items:center;gap:12px;font-size:13px;color:#8a8984}.or::before,.or::after{content:"";flex:1;height:1px;background:rgba(36,35,31,0.12)}.or+nav{margin-top:20px}</style><header><svg viewBox="2 4 56 52" width="23.7" height="22" aria-hidden="true"><path d="${CRANE}" fill="#24231f"/><path d="${CREST}" fill="#dd4f1e"/></svg></header><main><div${links ? ' class="choose"' : ""}>${top}</div></main></html>`;
48481
48583
  };
48584
+ function sameToken(a, b) {
48585
+ if (!a || a.length !== b.length) return false;
48586
+ return crypto6.timingSafeEqual(Buffer.from(a), Buffer.from(b));
48587
+ }
48482
48588
  async function signIn(options = {}) {
48483
48589
  const generation = accountGeneration();
48484
48590
  const verifier = base64url(crypto6.randomBytes(32));
48485
48591
  const challenge = base64url(crypto6.createHash("sha256").update(verifier).digest());
48592
+ const oauthState = base64url(crypto6.randomBytes(24));
48486
48593
  let finish = () => {
48487
48594
  };
48488
48595
  const answered = new Promise((resolve2) => finish = resolve2);
48489
48596
  let answering = false;
48597
+ let expectedOrigin = "";
48490
48598
  const server = http.createServer(async (req, res) => {
48599
+ res.setHeader("cache-control", "no-store");
48600
+ res.setHeader("referrer-policy", "no-referrer");
48601
+ res.setHeader("x-content-type-options", "nosniff");
48602
+ const expectedHost = expectedOrigin.slice(7);
48603
+ const secFetchSite = req.headers["sec-fetch-site"] ? String(req.headers["sec-fetch-site"]) : null;
48604
+ if (req.headers.host !== expectedHost || req.headers.origin && req.headers.origin !== expectedOrigin) {
48605
+ res.writeHead(403, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ error: "forbidden" }));
48606
+ return;
48607
+ }
48491
48608
  const asked = new URL(req.url ?? "/", "http://127.0.0.1");
48609
+ const isCallback = asked.pathname === "/signed-in";
48610
+ if (secFetchSite && !(isCallback ? ["same-origin", "none", "cross-site"] : ["same-origin", "none"]).includes(secFetchSite)) {
48611
+ res.writeHead(403, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ error: "forbidden" }));
48612
+ return;
48613
+ }
48492
48614
  const lang = langOf(req.headers["accept-language"]);
48493
48615
  if (asked.pathname === "/" && !answering) {
48494
48616
  res.writeHead(200, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" });
@@ -48496,6 +48618,10 @@ async function signIn(options = {}) {
48496
48618
  return;
48497
48619
  }
48498
48620
  if (req.method === "POST" && (asked.pathname === "/send" || asked.pathname === "/verify") && !answering) {
48621
+ if (req.headers.origin !== expectedOrigin) {
48622
+ res.writeHead(403, { "content-type": "application/json; charset=utf-8" }).end(JSON.stringify({ error: "forbidden" }));
48623
+ return;
48624
+ }
48499
48625
  const asks = await readJson2(req);
48500
48626
  const answer = asked.pathname === "/send" ? await sendCode(asks.email ?? "", lang) : await verifyCode(asks.email ?? "", asks.code ?? "", generation, options.signal);
48501
48627
  const done = answer.ok && asked.pathname === "/verify";
@@ -48515,7 +48641,8 @@ async function signIn(options = {}) {
48515
48641
  const params = asked.searchParams;
48516
48642
  const code = params.get("code");
48517
48643
  const error = params.get("error");
48518
- const failure3 = code ? await exchange(code, verifier, generation, options.signal) : {
48644
+ const stateOk = sameToken(params.get("state"), oauthState);
48645
+ const failure3 = !stateOk ? { why: "other", detail: "invalid oauth state" } : code ? await exchange(code, verifier, generation, options.signal) : {
48519
48646
  why: error === "access_denied" ? "denied" : "other",
48520
48647
  detail: params.get("error_description") || error || "no code came back"
48521
48648
  };
@@ -48526,6 +48653,7 @@ async function signIn(options = {}) {
48526
48653
  });
48527
48654
  await new Promise((resolve2) => server.listen(0, "127.0.0.1", resolve2));
48528
48655
  const { port } = server.address();
48656
+ expectedOrigin = `http://127.0.0.1:${port}`;
48529
48657
  const { supabaseUrl } = cloudEndpoints();
48530
48658
  const authorize = (provider) => {
48531
48659
  const url = new URL(`${supabaseUrl}/auth/v1/authorize`);
@@ -48534,18 +48662,20 @@ async function signIn(options = {}) {
48534
48662
  if (provider === "github") url.searchParams.set("scopes", "user:email");
48535
48663
  url.searchParams.set("code_challenge", challenge);
48536
48664
  url.searchParams.set("code_challenge_method", "s256");
48665
+ url.searchParams.set("state", oauthState);
48537
48666
  return url.toString().replace(/&/g, "&amp;");
48538
48667
  };
48539
48668
  const choose = `http://127.0.0.1:${port}/`;
48540
48669
  const onUrl = options.onUrl ?? ((u) => status(t.signIn(u)));
48541
48670
  onUrl(choose);
48542
- openBrowser(choose);
48671
+ if (!options.noBrowser) openBrowser(choose);
48543
48672
  const timer = setTimeout(() => finish({ why: "timeout", detail: "timed out" }), WAIT_MS);
48544
48673
  const cancel = () => finish({ why: "cancelled", detail: "cancelled" });
48545
48674
  options.signal?.addEventListener("abort", cancel);
48546
48675
  const failure2 = await answered;
48547
48676
  clearTimeout(timer);
48548
48677
  options.signal?.removeEventListener("abort", cancel);
48678
+ server.closeAllConnections();
48549
48679
  server.close();
48550
48680
  return failure2;
48551
48681
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wildcrane-runner",
3
- "version": "0.6.121",
3
+ "version": "0.6.123",
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/",