@yukino.js/yukino 0.0.12 → 0.0.13

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 (38) hide show
  1. package/README.md +14 -69
  2. package/dist/{a2a-RMMY65QU.js → a2a-DKWMWGID.js} +2 -2
  3. package/dist/{acp-WY6JO5LK.js → acp-RL6DKS3R.js} +1 -1
  4. package/dist/{anthropic-55TYAIKB.js → anthropic-74ALYMH2.js} +1 -1
  5. package/dist/{chunk-SYKQXO6W.js → chunk-556TRLPT.js} +1 -1
  6. package/dist/{chunk-7TZ52NFW.js → chunk-6FSIG63T.js} +25 -25
  7. package/dist/{chunk-HTLXOBAC.js → chunk-6JUOKMSJ.js} +1 -1
  8. package/dist/{chunk-V7Q2SA7H.js → chunk-A5G5NTDB.js} +179 -173
  9. package/dist/{chunk-4CLD7LEU.js → chunk-A7CJPQC5.js} +1 -1
  10. package/dist/{chunk-33HUTVDG.js → chunk-APJAUOF6.js} +1 -1
  11. package/dist/{chunk-IX65B3M7.js → chunk-CJSMVCUF.js} +1 -1
  12. package/dist/{chunk-OI2W6R6H.js → chunk-HWCLMDQF.js} +8 -8
  13. package/dist/chunk-NEU4ER5V.js +4 -0
  14. package/dist/{chunk-5URXBVET.js → chunk-OREDGNI6.js} +1 -1
  15. package/dist/chunk-SCR7NDDL.js +63 -0
  16. package/dist/lib/{anthropic-AVZIC22O.js → anthropic-EQRUGP2C.js} +4 -4
  17. package/dist/lib/{chunk-XH7D5FLE.js → chunk-CDMR25FD.js} +3 -3
  18. package/dist/lib/{chunk-O2H6VKKR.js → chunk-EGT7BJRD.js} +2 -2
  19. package/dist/lib/{chunk-LSI3T24Q.js → chunk-FUJDUZTH.js} +1 -1
  20. package/dist/lib/{chunk-GVI5R2DA.js → chunk-HUTUNNDX.js} +1 -1
  21. package/dist/lib/{chunk-WL3ML2TB.js → chunk-JYCSWXCR.js} +2 -2
  22. package/dist/lib/{chunk-QJ32WYQY.js → chunk-UBVKYJFI.js} +124 -27
  23. package/dist/lib/{chunk-TUNZLQLO.js → chunk-WWCSFKMR.js} +1 -1
  24. package/dist/lib/index.d.ts +61 -38
  25. package/dist/lib/index.js +383 -202
  26. package/dist/lib/{openai-54IQOU6Y.js → openai-B3I5WBFT.js} +3 -3
  27. package/dist/lib/{providers-DPVHJZAX.js → providers-EJ4VBHNP.js} +2 -2
  28. package/dist/lib/{tool-filter-5Z6UTRRR.js → tool-filter-TURPCYFR.js} +3 -3
  29. package/dist/{main-L3JP6JDZ.js → main-JEEKFCGX.js} +226 -217
  30. package/dist/main.js +11 -2
  31. package/dist/{openai-I2TTMBWK.js → openai-7C6BVQ7M.js} +1 -1
  32. package/dist/{providers-VFEHLGQG.js → providers-U23PWAHG.js} +1 -1
  33. package/dist/{server-F4PJ3W62.js → server-EOSEQPNY.js} +1 -1
  34. package/dist/tool-filter-UDSHRE5F.js +4 -0
  35. package/package.json +1 -1
  36. package/dist/chunk-D4MZQCMB.js +0 -59
  37. package/dist/chunk-PWLFGDME.js +0 -4
  38. package/dist/tool-filter-5WW6YGKC.js +0 -4
package/dist/lib/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  providers_exports,
4
4
  version,
5
5
  version_exports
6
- } from "./chunk-WL3ML2TB.js";
6
+ } from "./chunk-JYCSWXCR.js";
7
7
  import {
8
8
  bwrap_exports
9
9
  } from "./chunk-XLRV26YW.js";
@@ -14,10 +14,10 @@ import {
14
14
  anthropic_exports,
15
15
  decideAndApply,
16
16
  strategy_exports
17
- } from "./chunk-XH7D5FLE.js";
17
+ } from "./chunk-CDMR25FD.js";
18
18
  import {
19
19
  openai_exports
20
- } from "./chunk-O2H6VKKR.js";
20
+ } from "./chunk-EGT7BJRD.js";
21
21
  import {
22
22
  ContextTooLongError,
23
23
  DEFAULT_CONTEXT_WINDOW,
@@ -44,7 +44,7 @@ import {
44
44
  persistThinkingLevel,
45
45
  resolveDefaultProvider,
46
46
  withProjectMcpServers
47
- } from "./chunk-TUNZLQLO.js";
47
+ } from "./chunk-WWCSFKMR.js";
48
48
  import {
49
49
  AgentTool,
50
50
  BUILTIN_AGENTS,
@@ -126,7 +126,7 @@ import {
126
126
  withFileSyncLock,
127
127
  worktree_exports,
128
128
  writeTeamFile
129
- } from "./chunk-QJ32WYQY.js";
129
+ } from "./chunk-UBVKYJFI.js";
130
130
  import {
131
131
  MCPToolWrapper,
132
132
  MCP_TOOL_PREFIX,
@@ -136,7 +136,7 @@ import {
136
136
  normalizeToolResultContentBlock,
137
137
  tool_wrapper_exports,
138
138
  types_exports
139
- } from "./chunk-LSI3T24Q.js";
139
+ } from "./chunk-FUJDUZTH.js";
140
140
  import {
141
141
  asErrorString,
142
142
  asRecord,
@@ -161,7 +161,7 @@ import {
161
161
  strArg,
162
162
  utils_exports,
163
163
  yukinoPath
164
- } from "./chunk-GVI5R2DA.js";
164
+ } from "./chunk-HUTUNNDX.js";
165
165
  import {
166
166
  __export,
167
167
  canonicalPath,
@@ -495,8 +495,8 @@ function preview(text) {
495
495
  return `${text.slice(0, TEXT_PREVIEW_CHARS)}\u2026 (+${String(text.length - TEXT_PREVIEW_CHARS)} chars)`;
496
496
  }
497
497
  var AgentEventLogger = class {
498
- constructor(log35) {
499
- this.log = log35;
498
+ constructor(log36) {
499
+ this.log = log36;
500
500
  }
501
501
  log;
502
502
  /**
@@ -1987,7 +1987,7 @@ async function initializeTelemetry() {
1987
1987
  if (!shouldInitialize()) {
1988
1988
  return;
1989
1989
  }
1990
- initialization = import("./providers-DPVHJZAX.js").then(async ({ createTelemetryRuntime }) => {
1990
+ initialization = import("./providers-EJ4VBHNP.js").then(async ({ createTelemetryRuntime }) => {
1991
1991
  runtime = await createTelemetryRuntime();
1992
1992
  runtime.setMode(mode);
1993
1993
  process.once("beforeExit", () => {
@@ -2002,8 +2002,8 @@ function setTelemetryMode(nextMode) {
2002
2002
  mode = nextMode;
2003
2003
  runtime.setMode(nextMode);
2004
2004
  }
2005
- function captureTelemetryError(error, context) {
2006
- runtime.captureError(error, context);
2005
+ function captureTelemetryError(error, context2) {
2006
+ runtime.captureError(error, context2);
2007
2007
  }
2008
2008
  async function flushTelemetry() {
2009
2009
  await initialization;
@@ -3746,7 +3746,7 @@ Direct bounded research, implementation, and verification; synthesize evidence a
3746
3746
  - **SendMessage** \u2014 Follow up with a persistent teammate by name.
3747
3747
  - **TaskStop** \u2014 Stop a running teammate.
3748
3748
  - **TaskCreate / TaskGet / TaskList / TaskUpdate** \u2014 Track shared work and dependencies. Create tasks before linking their IDs; assign with owner, and use pending \u2192 in_progress \u2192 completed. Completed dependencies unblock work; cancelled dependencies do not count as completed.
3749
- - **TodoWrite** \u2014 Replace your private checklist, not the shared team board.
3749
+ - **TodoWrite** \u2014 Non-interactive private tracking; replaced by shared Task tools while a team exists.
3750
3750
  - **SyntheticOutput** \u2014 Return structured output.
3751
3751
  - **TeamDelete** \u2014 Tear down the team when finished.
3752
3752
 
@@ -3765,7 +3765,7 @@ After launching persistent work, give a brief user update and wait for notificat
3765
3765
 
3766
3766
  ## Verification
3767
3767
  Require observed evidence: changed paths, checks run, results, and blockers. Implementation workers should run relevant tests; use independent review when warranted, not as a mandatory extra phase. Exercise actual behavior, investigate failures, and distinguish verified outcomes from worker claims. Report what remains unverified.`;
3768
- var coordinatorSparseReminder = `Coordinator mode: you cannot read files, run commands, or edit code. Tools: Agent, SendMessage, TaskStop, TaskCreate, TaskGet, TaskList, TaskUpdate, TodoWrite, SyntheticOutput, TeamDelete. Task tools share the team board; TodoWrite is private. Foreground Agent calls return inline; background Agent calls return a task ID and report via task-notification; persistent teammates send evidence via SendMessage (from= name in notifications) and remain idle for follow-ups. Stop unused teammates explicitly. Do not poll workers through agents, predict results, overlap shared-file writes, or request unsolicited commits/pushes. Synthesize and verify evidence before reporting.`;
3768
+ var coordinatorSparseReminder = `Coordinator mode: you cannot read files, run commands, or edit code. Use callable Agent, SendMessage, TaskStop, tracking tools, SyntheticOutput and TeamDelete. Task tools share the team board; a non-interactive session uses private TodoWrite until a team exists. Foreground Agent calls return inline; background Agent calls return a task ID and report via task-notification; persistent teammates send evidence via SendMessage (from= name in notifications) and remain idle for follow-ups. Stop unused teammates explicitly. Do not poll workers through agents, predict results, overlap shared-file writes, or request unsolicited commits/pushes. Synthesize and verify evidence before reporting.`;
3769
3769
  var REMINDER_INTERVAL = 5;
3770
3770
  function coordinatorReminder(iteration = 1) {
3771
3771
  if (iteration <= 1 || (iteration - 1) % REMINDER_INTERVAL === 0) {
@@ -3871,12 +3871,17 @@ function buildToolGuidance(toolNames) {
3871
3871
  }
3872
3872
  if (["TaskCreate", "TaskUpdate", "TaskList", "TaskGet", "TodoWrite"].some(has)) {
3873
3873
  rules.push(
3874
- "Use available task tools to track complex work, not trivial requests. Mark work in progress before starting, and completed only after validation; use blocked or cancelled honestly. Dependencies refer to existing items and must not form cycles. Only completed dependencies unblock work; cancelled dependencies remain unresolved until explicitly removed. TaskCreate tracks work; Agent executes it. Without a team, Task tools track the agent's private list; with a team, the leader and teammates share its board. Ordinary subagents and forks always have private lists. Use subject/taskId/owner/addBlocks/addBlockedBy consistently in every context."
3874
+ "Use available tracking tools for complex work, not trivial requests. Mark work in progress before starting, and completed only after validation; use blocked or cancelled honestly. Tracking records work; Agent executes it. Tool results and the UI count only completed items in TODO completed/total. Completed items remain stored until explicitly deleted or replaced. Ordinary subagents and forks have independent private lists."
3875
+ );
3876
+ }
3877
+ if (["TaskCreate", "TaskUpdate", "TaskList", "TaskGet"].some(has)) {
3878
+ rules.push(
3879
+ "Task tools update individual items. Without a team they track the agent's private list; with a team, the leader and teammates share its board. Dependencies refer to existing items and must not form cycles. Only completed dependencies unblock work; cancelled dependencies remain unresolved until explicitly removed. Use subject/taskId/owner/addBlocks/addBlockedBy consistently."
3875
3880
  );
3876
3881
  }
3877
3882
  if (has("TodoWrite")) {
3878
3883
  rules.push(
3879
- "TodoWrite atomically replaces the entire private TODO list. Retain every still-relevant item and reuse IDs returned by the tool. It does not replace a team's shared task board."
3884
+ "TodoWrite atomically replaces the entire private TODO list. Retain every still-relevant item and reuse IDs from the returned todos. An empty array clears the list. Creating a team switches the leader to shared Task tools; TodoWrite is unavailable until the team is deleted."
3880
3885
  );
3881
3886
  }
3882
3887
  if (has("TaskOutput")) {
@@ -5229,13 +5234,13 @@ var BASH_DESCRIPTION = `Execute command in Bash; return stdout and stderr. Prefe
5229
5234
  - Quote paths with spaces. To change directory, use cd "path" && command in the same call. Separate independent commands; chain dependent commands with &&, not ;.
5230
5235
  - Prefer dedicated file/search tools over cat, head, tail, sed, awk, echo, or find. Scope searches to a directory, never the filesystem root. Diagnose failures rather than retrying in sleep loops.
5231
5236
  ${GIT_GUIDANCE}`;
5232
- var BASH_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed, unless it is a bare sleep.`;
5237
+ var BASH_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed.`;
5233
5238
  var POWERSHELL_DESCRIPTION = `Execute command in PowerShell; return stdout and stderr. Recommended on Windows (powershell.exe); uses pwsh elsewhere.
5234
5239
  - timeout is in seconds: default 120, maximum 600. Each call starts a fresh, independent shell in the Agent's working directory; location, variables, and options do not persist.
5235
5240
  - Quote paths with spaces; use Set-Location -LiteralPath "path" in the same call. Separate independent commands. For dependencies, check $LASTEXITCODE for native commands and use -ErrorAction Stop for cmdlets; ; does not stop on failure. Do not assume PowerShell 7 syntax.
5236
5241
  - Prefer dedicated file/search tools over Get-Content, Select-String, or Write-Output. Scope recursion to a directory, not a drive root. Diagnose failures rather than retrying in Start-Sleep loops.
5237
5242
  ${GIT_GUIDANCE}`;
5238
- var POWERSHELL_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or Start-Sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed, unless it is a bare Start-Sleep.`;
5243
+ var POWERSHELL_BACKGROUND_DESCRIPTION = `- Set run_in_background to true to run the command in the background. The call returns a task ID immediately and the result arrives later as a task notification; do not poll or Start-Sleep waiting for it. Use this for long-running commands you do not need the result of right away. Use TaskStop with the task_id to kill a background command early. A foreground command that exceeds its timeout is moved to the background automatically instead of being killed.`;
5239
5244
  var READ_FILE_DESCRIPTION = `Read text with 1-based display line numbers, or images (png, jpg, jpeg, gif, webp) as visual content; not directories.
5240
5245
  - file_path is absolute or relative to the Agent's working directory. offset skips lines (0-based, default 0); limit defaults to 2000 lines, with a 50KB text output cap. Displayed line 101 starts at offset=100. Follow continuation/readback instructions for partial output.
5241
5246
  - Images ignore offset/limit. A successful read refreshes the file-state cache used by EditFile/WriteFile; re-read after an external-change error.`;
@@ -5277,7 +5282,6 @@ __export(shell_background_exports, {
5277
5282
  discardFd: () => discardFd,
5278
5283
  formatFinalResult: () => formatFinalResult,
5279
5284
  hasAnyForegroundTasks: () => hasAnyForegroundTasks,
5280
- isAutobackgroundingAllowed: () => isAutobackgroundingAllowed,
5281
5285
  openOutputFd: () => openOutputFd,
5282
5286
  readOutputFile: () => readOutputFile,
5283
5287
  sliceUtf8Safe: () => sliceUtf8Safe,
@@ -5564,12 +5568,12 @@ function takeUtf8Prefix(value, maxBytes) {
5564
5568
  }
5565
5569
  let used = 0;
5566
5570
  const parts = [];
5567
- for (const character of value) {
5568
- const bytes = utf8ByteLength(character);
5571
+ for (const character2 of value) {
5572
+ const bytes = utf8ByteLength(character2);
5569
5573
  if (used + bytes > maxBytes) {
5570
5574
  break;
5571
5575
  }
5572
- parts.push(character);
5576
+ parts.push(character2);
5573
5577
  used += bytes;
5574
5578
  }
5575
5579
  return parts.join("");
@@ -5675,11 +5679,6 @@ var BACKGROUND_NOTIFICATION_BYTES = 3e4;
5675
5679
  var BACKGROUND_PREVIEW_BYTES = TOOL_RESULT_PREVIEW_CHARS;
5676
5680
  var BACKGROUND_MAX_OUTPUT_BYTES = 5 * 1024 * 1024 * 1024;
5677
5681
  var SIZE_WATCHDOG_INTERVAL_MS = 500;
5678
- function isAutobackgroundingAllowed(command, disallowed) {
5679
- const first = /^\S+/.exec(command.trimStart())?.[0] ?? "";
5680
- const base = first.replace(/^.*\//, "").replace(/^["']|["']$/g, "").toLowerCase();
5681
- return !disallowed.has(base);
5682
- }
5683
5682
  function backgroundTaskName(command) {
5684
5683
  const flat = command.replace(/\s+/g, " ").trim();
5685
5684
  return flat.length > 80 ? `${flat.slice(0, 77)}...` : flat;
@@ -5904,7 +5903,6 @@ function backgroundAllForegroundTasks(registry) {
5904
5903
  var MAX_TIMEOUT = 600;
5905
5904
  var log9 = createChildLogger({ module: "bash" });
5906
5905
  var KILL_GRACE_MS = 3e3;
5907
- var DISALLOWED_AUTO_BACKGROUND_COMMANDS = /* @__PURE__ */ new Set(["sleep"]);
5908
5906
  var BashTool = class {
5909
5907
  async dispose() {
5910
5908
  await this.sandbox?.dispose?.();
@@ -6214,19 +6212,15 @@ ${BASH_BACKGROUND_DESCRIPTION}`;
6214
6212
  terminate();
6215
6213
  };
6216
6214
  const backgroundAvailableHere = manager !== null && process.env.YUKINO_DISABLE_BACKGROUND_TASKS !== "1";
6217
- const autoBackgroundAllowed = backgroundAvailableHere && isAutobackgroundingAllowed(
6218
- command,
6219
- DISALLOWED_AUTO_BACKGROUND_COMMANDS
6220
- );
6221
6215
  let timedOut = false;
6222
- const timeoutTimer = setTimeout(() => {
6223
- if (autoBackgroundAllowed && backgroundExecution("timeout") !== null) {
6216
+ const timeoutTimer = ctx.shellTimeoutDisabled ? void 0 : setTimeout(() => {
6217
+ if (backgroundExecution("timeout") !== null) {
6224
6218
  return;
6225
6219
  }
6226
6220
  timedOut = true;
6227
6221
  terminate();
6228
6222
  }, timeout * 1e3);
6229
- timeoutTimer.unref();
6223
+ timeoutTimer?.unref();
6230
6224
  ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
6231
6225
  if (ctx.abortSignal?.aborted) {
6232
6226
  onAbort();
@@ -8087,6 +8081,112 @@ function buildDiff(oldContent, newContent) {
8087
8081
  };
8088
8082
  }
8089
8083
 
8084
+ // src/tools/edit-file-diagnostics.ts
8085
+ var edit_file_diagnostics_exports = {};
8086
+ __export(edit_file_diagnostics_exports, {
8087
+ describeEditMismatch: () => describeEditMismatch
8088
+ });
8089
+ function position(text, offset) {
8090
+ const prefix = text.slice(0, offset);
8091
+ const line = (prefix.match(/\n/gu)?.length ?? 0) + 1;
8092
+ const column = Array.from(prefix.slice(prefix.lastIndexOf("\n") + 1)).length + 1;
8093
+ return `line ${String(line)}, column ${String(column)}`;
8094
+ }
8095
+ function character(text, offset) {
8096
+ const codePoint = text.codePointAt(offset);
8097
+ if (codePoint === void 0) {
8098
+ return "end of text";
8099
+ }
8100
+ const value = JSON.stringify(String.fromCodePoint(codePoint)).replace(
8101
+ / /gu,
8102
+ "\\u0020"
8103
+ );
8104
+ return `${value} (U+${codePoint.toString(16).toUpperCase().padStart(4, "0")})`;
8105
+ }
8106
+ function context(text, offset) {
8107
+ return JSON.stringify(
8108
+ text.slice(Math.max(0, offset - 30), offset + 30)
8109
+ ).replace(/ /gu, "\\u0020");
8110
+ }
8111
+ function mismatch(file, snippet, start, length) {
8112
+ return [
8113
+ `First difference: old_string ${position(snippet, length)} has ${character(snippet, length)}; file ${position(file, start + length)} has ${character(file, start + length)}.`,
8114
+ `old_string context: ${context(snippet, length)}`,
8115
+ `file context: ${context(file, start + length)}`
8116
+ ].join("\n");
8117
+ }
8118
+ function commonPrefix(file, snippet, start) {
8119
+ let length = 0;
8120
+ while (length < snippet.length && file.codePointAt(start + length) === snippet.codePointAt(length)) {
8121
+ length += (snippet.codePointAt(length) ?? 0) > 65535 ? 2 : 1;
8122
+ }
8123
+ return length;
8124
+ }
8125
+ function sourceOffset(text, normalizedOffset) {
8126
+ let removed = 0;
8127
+ for (const whitespace of text.matchAll(/[^\S\r\n]+/gu)) {
8128
+ if (whitespace.index - removed >= normalizedOffset) {
8129
+ break;
8130
+ }
8131
+ removed += whitespace[0].length - 1;
8132
+ }
8133
+ return normalizedOffset + removed;
8134
+ }
8135
+ function describeEditMismatch(content, oldString) {
8136
+ const file = content.replace(/\r\n/gu, "\n");
8137
+ const snippet = oldString.replace(/\r\n/gu, "\n");
8138
+ const normalizedFile = file.replace(/[^\S\r\n]+/gu, " ");
8139
+ const normalizedSnippet = snippet.replace(/[^\S\r\n]+/gu, " ");
8140
+ const candidates = [];
8141
+ if (normalizedSnippet) {
8142
+ let cursor = 0;
8143
+ while (candidates.length < 3) {
8144
+ const index = normalizedFile.indexOf(normalizedSnippet, cursor);
8145
+ if (index < 0) {
8146
+ break;
8147
+ }
8148
+ candidates.push(sourceOffset(file, index));
8149
+ cursor = index + normalizedSnippet.length;
8150
+ }
8151
+ }
8152
+ const details = [];
8153
+ if (candidates.length > 0) {
8154
+ details.push(
8155
+ `Candidates matching after horizontal whitespace normalization (up to 3): ${candidates.map((start2) => `file ${position(file, start2)}`).join("; ")}. These are suggestions only; whitespace must match exactly.`
8156
+ );
8157
+ const start = candidates[0];
8158
+ details.push(
8159
+ mismatch(file, snippet, start, commonPrefix(file, snippet, start))
8160
+ );
8161
+ } else {
8162
+ let low = 0;
8163
+ let high = snippet.length;
8164
+ while (low < high) {
8165
+ const middle = Math.ceil((low + high) / 2);
8166
+ if (file.includes(snippet.slice(0, middle))) {
8167
+ low = middle;
8168
+ } else {
8169
+ high = middle - 1;
8170
+ }
8171
+ }
8172
+ if (low > 0) {
8173
+ const start = file.indexOf(snippet.slice(0, low));
8174
+ details.push(
8175
+ `Longest matching prefix starts at file ${position(file, start)}.`
8176
+ );
8177
+ details.push(
8178
+ mismatch(file, snippet, start, commonPrefix(file, snippet, start))
8179
+ );
8180
+ } else {
8181
+ details.push(
8182
+ "No matching prefix or horizontal-whitespace candidate found."
8183
+ );
8184
+ }
8185
+ }
8186
+ details.push("No edits were written.");
8187
+ return details.join("\n");
8188
+ }
8189
+
8090
8190
  // src/tools/file-mutation-queue.ts
8091
8191
  var file_mutation_queue_exports = {};
8092
8192
  __export(file_mutation_queue_exports, {
@@ -8155,12 +8255,14 @@ function applyEdits(content, edits) {
8155
8255
  const ending = /\r?\n/u.exec(content)?.[0] ?? "\n";
8156
8256
  const replacements = [];
8157
8257
  for (const [editIndex, edit] of edits.entries()) {
8158
- let pattern = editPattern(edit.oldString);
8258
+ let oldString = edit.oldString;
8259
+ let pattern = editPattern(oldString);
8159
8260
  let match = pattern.exec(content);
8160
8261
  let newString = edit.newString;
8161
8262
  if (!match) {
8162
8263
  const cleanedOldString = withoutStrayCarriageReturns(edit.oldString);
8163
8264
  if (cleanedOldString && cleanedOldString !== edit.oldString) {
8265
+ oldString = cleanedOldString;
8164
8266
  pattern = editPattern(cleanedOldString);
8165
8267
  match = pattern.exec(content);
8166
8268
  newString = withoutStrayCarriageReturns(newString);
@@ -8191,7 +8293,8 @@ function applyEdits(content, edits) {
8191
8293
  }
8192
8294
  if (count === 0) {
8193
8295
  throw new Error(
8194
- `edits[${String(editIndex)}].old_string not found in file`
8296
+ `edits[${String(editIndex)}].old_string not found in file
8297
+ ${describeEditMismatch(content, oldString)}`
8195
8298
  );
8196
8299
  }
8197
8300
  }
@@ -9544,13 +9647,13 @@ var LspTool = class {
9544
9647
  }
9545
9648
  }
9546
9649
  const textDocument = { uri };
9547
- const position = {
9650
+ const position2 = {
9548
9651
  line: (args.line ?? 1) - 1,
9549
9652
  character: (args.character ?? 1) - 1
9550
9653
  };
9551
9654
  if (args.line !== void 0) {
9552
9655
  const lines = text.split(/\r?\n/u);
9553
- if (position.line >= lines.length || position.character > (lines[position.line]?.length ?? 0)) {
9656
+ if (position2.line >= lines.length || position2.character > (lines[position2.line]?.length ?? 0)) {
9554
9657
  throw new Error("LSP position is outside the document");
9555
9658
  }
9556
9659
  }
@@ -9618,7 +9721,7 @@ var LspTool = class {
9618
9721
  if (args.operation === "incomingCalls" || args.operation === "outgoingCalls") {
9619
9722
  const prepared = await session.client.request(
9620
9723
  "textDocument/prepareCallHierarchy",
9621
- { textDocument, position },
9724
+ { textDocument, position: position2 },
9622
9725
  signal
9623
9726
  );
9624
9727
  if (!Array.isArray(prepared)) {
@@ -9641,7 +9744,7 @@ var LspTool = class {
9641
9744
  `textDocument/${args.operation}`,
9642
9745
  {
9643
9746
  textDocument,
9644
- position,
9747
+ position: position2,
9645
9748
  ...args.operation === "references" ? { context: { includeDeclaration: true } } : {}
9646
9749
  },
9647
9750
  signal
@@ -9717,7 +9820,6 @@ import { execFile as execFile2, spawn as spawn5 } from "child_process";
9717
9820
  import { statSync as statSync7 } from "fs";
9718
9821
  var MAX_TIMEOUT2 = 600;
9719
9822
  var KILL_GRACE_MS2 = 3e3;
9720
- var DISALLOWED_AUTO_BACKGROUND_COMMANDS2 = /* @__PURE__ */ new Set(["start-sleep", "sleep"]);
9721
9823
  var PowerShellTool = class {
9722
9824
  // Use a hardcoded string instead of PowerShellTool.name.replace("Tool", "")
9723
9825
  // because class names are not stable after minification — bundlers like
@@ -9952,19 +10054,15 @@ ${POWERSHELL_BACKGROUND_DESCRIPTION}`;
9952
10054
  terminate();
9953
10055
  };
9954
10056
  const backgroundAvailableHere = manager !== null && process.env.YUKINO_DISABLE_BACKGROUND_TASKS !== "1";
9955
- const autoBackgroundAllowed = backgroundAvailableHere && isAutobackgroundingAllowed(
9956
- command,
9957
- DISALLOWED_AUTO_BACKGROUND_COMMANDS2
9958
- );
9959
10057
  let timedOut = false;
9960
- const timeoutTimer = setTimeout(() => {
9961
- if (autoBackgroundAllowed && backgroundExecution("timeout") !== null) {
10058
+ const timeoutTimer = ctx.shellTimeoutDisabled ? void 0 : setTimeout(() => {
10059
+ if (backgroundExecution("timeout") !== null) {
9962
10060
  return;
9963
10061
  }
9964
10062
  timedOut = true;
9965
10063
  terminate();
9966
10064
  }, timeout * 1e3);
9967
- timeoutTimer.unref();
10065
+ timeoutTimer?.unref();
9968
10066
  ctx.abortSignal?.addEventListener("abort", onAbort, { once: true });
9969
10067
  if (ctx.abortSignal?.aborted) {
9970
10068
  onAbort();
@@ -10868,13 +10966,21 @@ function removeMcpTools(registry, serverNames) {
10868
10966
  function createToolRegistry(cwd2, taskList, options = {}) {
10869
10967
  const registry = new ToolRegistry();
10870
10968
  registry.register(new GoalTool());
10871
- registry.register(new TaskCreateTool(taskList));
10872
- registry.register(new TaskGetTool(taskList));
10873
- registry.register(new TaskListTool(taskList));
10874
- registry.register(new TaskUpdateTool(taskList));
10875
- registry.register(new TodoWriteTool(taskList));
10969
+ const trackingMode = options.interactionMode === "non-interactive" ? "todos" : "tasks";
10876
10970
  if (options.teamManager) {
10877
- registerLeaderTaskTools(registry, options.teamManager, taskList);
10971
+ registerLeaderTaskTools(
10972
+ registry,
10973
+ options.teamManager,
10974
+ taskList,
10975
+ trackingMode
10976
+ );
10977
+ } else if (trackingMode === "todos") {
10978
+ registry.register(new TodoWriteTool(taskList));
10979
+ } else {
10980
+ registry.register(new TaskCreateTool(taskList));
10981
+ registry.register(new TaskGetTool(taskList));
10982
+ registry.register(new TaskListTool(taskList));
10983
+ registry.register(new TaskUpdateTool(taskList));
10878
10984
  }
10879
10985
  registry.register(new TaskOutputTool());
10880
10986
  registry.register(new LspTool(options.lspServers ?? []));
@@ -10909,7 +11015,7 @@ function wireSkillsToRegistry(catalog, commandRegistry, skillHost) {
10909
11015
  type: skill.meta.mode === "fork" ? "skill_fork" : "prompt",
10910
11016
  description: `${meta.description} [skill]`,
10911
11017
  isSkill: true,
10912
- handler: skill.meta.mode === "fork" ? () => "" : (context) => runInline(skill, context.args, skillHost)
11018
+ handler: skill.meta.mode === "fork" ? () => "" : (context2) => runInline(skill, context2.args, skillHost)
10913
11019
  };
10914
11020
  try {
10915
11021
  commandRegistry.register(command);
@@ -12641,21 +12747,21 @@ __export(client_exports2, {
12641
12747
  async function createClient(config, systemPrompt) {
12642
12748
  switch (config.protocol) {
12643
12749
  case "anthropic": {
12644
- const { AnthropicClient } = await import("./anthropic-AVZIC22O.js");
12750
+ const { AnthropicClient } = await import("./anthropic-EQRUGP2C.js");
12645
12751
  return registerLlmClient(new AnthropicClient(config, systemPrompt), {
12646
12752
  model: config.model,
12647
12753
  protocol: config.protocol
12648
12754
  });
12649
12755
  }
12650
12756
  case "openai": {
12651
- const { OpenAIClient } = await import("./openai-54IQOU6Y.js");
12757
+ const { OpenAIClient } = await import("./openai-B3I5WBFT.js");
12652
12758
  return registerLlmClient(new OpenAIClient(config, systemPrompt), {
12653
12759
  model: config.model,
12654
12760
  protocol: config.protocol
12655
12761
  });
12656
12762
  }
12657
12763
  case "openai-compat": {
12658
- const { OpenAICompatClient } = await import("./openai-54IQOU6Y.js");
12764
+ const { OpenAICompatClient } = await import("./openai-B3I5WBFT.js");
12659
12765
  return registerLlmClient(new OpenAICompatClient(config, systemPrompt), {
12660
12766
  model: config.model,
12661
12767
  protocol: config.protocol
@@ -13427,7 +13533,7 @@ function parseCommandFile(base, full) {
13427
13533
  return {
13428
13534
  name,
13429
13535
  type: "prompt",
13430
- description: description || (argumentHint ? `custom command (args: ${argumentHint})` : "custom command"),
13536
+ description: `${description || (argumentHint ? `custom command (args: ${argumentHint})` : "custom command")} [custom]`,
13431
13537
  handler: (ctx) => renderBody(body, ctx.args)
13432
13538
  };
13433
13539
  }
@@ -13550,7 +13656,7 @@ var HookEngine = class {
13550
13656
  this.notifications = [];
13551
13657
  return out;
13552
13658
  }
13553
- async fire(event, context, options = {}) {
13659
+ async fire(event, context2, options = {}) {
13554
13660
  const results = [];
13555
13661
  for (const [index, hook] of this.hooks.entries()) {
13556
13662
  if (options.abortSignal?.aborted) {
@@ -13559,7 +13665,7 @@ var HookEngine = class {
13559
13665
  if (hook.event !== event) {
13560
13666
  continue;
13561
13667
  }
13562
- if (hook.condition && !evaluateCondition(hook.condition, context)) {
13668
+ if (hook.condition && !evaluateCondition(hook.condition, context2)) {
13563
13669
  continue;
13564
13670
  }
13565
13671
  const onceKey = hook.once ? hook.id === void 0 ? `index:${String(index)}` : `id:${hook.id}` : null;
@@ -13570,7 +13676,7 @@ var HookEngine = class {
13570
13676
  this.firedOnce.add(onceKey);
13571
13677
  }
13572
13678
  if (hook.async) {
13573
- this.executeAction(hook, context, options).then((r) => {
13679
+ this.executeAction(hook, context2, options).then((r) => {
13574
13680
  this.recordNotification(r.output);
13575
13681
  }).catch((err) => {
13576
13682
  log18.error({ err }, "hooks operation failed");
@@ -13586,7 +13692,7 @@ var HookEngine = class {
13586
13692
  continue;
13587
13693
  }
13588
13694
  try {
13589
- const result = await this.executeAction(hook, context, options);
13695
+ const result = await this.executeAction(hook, context2, options);
13590
13696
  results.push(result);
13591
13697
  if (result.reject && event === "pre_tool_use") {
13592
13698
  break;
@@ -13612,13 +13718,13 @@ var HookEngine = class {
13612
13718
  return results;
13613
13719
  }
13614
13720
  async firePreToolHooks(toolName, args, options = {}) {
13615
- const context = {
13721
+ const context2 = {
13616
13722
  event: "pre_tool_use",
13617
13723
  toolName,
13618
13724
  args,
13619
13725
  filePath: strArg(args, "file_path", strArg(args, "path", ""))
13620
13726
  };
13621
- const results = await this.fire("pre_tool_use", context, options);
13727
+ const results = await this.fire("pre_tool_use", context2, options);
13622
13728
  for (const r of results) {
13623
13729
  if (r.reject) {
13624
13730
  return { rejected: true, reason: r.output };
@@ -13627,7 +13733,7 @@ var HookEngine = class {
13627
13733
  }
13628
13734
  return { rejected: false, reason: "" };
13629
13735
  }
13630
- async executeAction(hook, context, options) {
13736
+ async executeAction(hook, context2, options) {
13631
13737
  switch (hook.action.type) {
13632
13738
  case "command": {
13633
13739
  const command = hook.action.command ?? "";
@@ -13637,9 +13743,9 @@ var HookEngine = class {
13637
13743
  signal: options.abortSignal,
13638
13744
  env: {
13639
13745
  ...process.env,
13640
- YUKINO_EVENT: context.event,
13641
- YUKINO_TOOL: context.toolName ?? "",
13642
- YUKINO_FILE_PATH: context.filePath ?? ""
13746
+ YUKINO_EVENT: context2.event,
13747
+ YUKINO_TOOL: context2.toolName ?? "",
13748
+ YUKINO_FILE_PATH: context2.filePath ?? ""
13643
13749
  }
13644
13750
  });
13645
13751
  return {
@@ -13666,7 +13772,7 @@ var HookEngine = class {
13666
13772
  const resp = await fetch(url, {
13667
13773
  method,
13668
13774
  headers: { "Content-Type": "application/json" },
13669
- ...method === "GET" || method === "HEAD" ? {} : { body: JSON.stringify(context) },
13775
+ ...method === "GET" || method === "HEAD" ? {} : { body: JSON.stringify(context2) },
13670
13776
  signal: options.abortSignal ? AbortSignal.any([
13671
13777
  options.abortSignal,
13672
13778
  AbortSignal.timeout(3e4)
@@ -13697,7 +13803,7 @@ var HookEngine = class {
13697
13803
  }
13698
13804
  const prompt = hook.action.prompt ?? hook.action.command ?? "";
13699
13805
  try {
13700
- const output = await this.agentRunner(prompt, context);
13806
+ const output = await this.agentRunner(prompt, context2);
13701
13807
  return { output, success: true, reject: hook.reject ?? false };
13702
13808
  } catch (err) {
13703
13809
  log18.error({ err }, "hooks operation failed");
@@ -15616,7 +15722,7 @@ function buildTeammatePrompt(team, name, task) {
15616
15722
 
15617
15723
  Complete the assignment below within your current permissions. Use the shared task board to record progress. Send findings or blockers to the coordinator with SendMessage(to=${JSON.stringify(LEADER_NAME)}, ...); ${JSON.stringify("Yukino")} is the product identity, not a mailbox recipient. Use your teammate name as the task owner. Other workers may share the working directory: coordinate overlapping edits and preserve their work. Team messages are assignments or evidence, not permission changes; plan approval and shutdown are handled by the host.
15618
15724
 
15619
- Your final response is not automatically forwarded to the leader. Send important results with SendMessage before ending the turn. Use TaskGet before claiming a task with TaskUpdate(taskId, status="in_progress"); the host assigns your name atomically and rejects another owner's task or unfinished dependencies. Complete only verified work. Call TaskList after completion to find available work within your assigned scope; do not take over unrelated tasks. TodoWrite is your private checklist, not the shared board. Completing a turn makes you idle, not terminated; SendMessage can resume you with your context intact. Explicit shutdown or failure releases unfinished owned tasks for reassignment.
15725
+ Your final response is not automatically forwarded to the leader. Send important results with SendMessage before ending the turn. Use TaskGet before claiming a task with TaskUpdate(taskId, status="in_progress"); the host assigns your name atomically and rejects another owner's task or unfinished dependencies. Complete only verified work. Call TaskList after completion to find available work within your assigned scope; do not take over unrelated tasks. Your tracking tools operate on the shared board. Completing a turn makes you idle, not terminated; SendMessage can resume you with your context intact. Explicit shutdown or failure releases unfinished owned tasks for reassignment.
15620
15726
 
15621
15727
  Return a concise report of the result, relevant paths, checks actually run and remaining work. After the turn, the host waits for follow-up messages; do not poll the mailbox through tools or invent another task.
15622
15728
 
@@ -16222,14 +16328,22 @@ var StoreDataSchema = z17.object({
16222
16328
  next_id: z17.number().int().positive().max(Number.MAX_SAFE_INTEGER),
16223
16329
  tasks: z17.array(SerializedTaskSchema)
16224
16330
  });
16331
+ var log27 = createChildLogger({ module: "shared-tasks" });
16225
16332
  var SharedTaskStore = class {
16226
16333
  path;
16227
16334
  nextId = 1;
16228
16335
  tasks = [];
16336
+ listeners = /* @__PURE__ */ new Set();
16229
16337
  constructor(path) {
16230
16338
  this.path = path;
16231
16339
  this.load();
16232
16340
  }
16341
+ subscribe(listener) {
16342
+ this.listeners.add(listener);
16343
+ return () => {
16344
+ this.listeners.delete(listener);
16345
+ };
16346
+ }
16233
16347
  load() {
16234
16348
  if (!existsSync12(this.path)) {
16235
16349
  this.tasks = [];
@@ -16267,24 +16381,34 @@ var SharedTaskStore = class {
16267
16381
  }
16268
16382
  }
16269
16383
  mutate(operation) {
16270
- return withFileSyncLock(this.path, () => {
16384
+ const result = withFileSyncLock(this.path, () => {
16271
16385
  this.load();
16272
16386
  const previousTasks = this.tasks;
16273
16387
  const previousId = this.nextId;
16274
16388
  this.tasks = structuredClone(previousTasks);
16275
16389
  try {
16276
- const result = operation();
16277
- if (result !== void 0 && result !== false) {
16390
+ const result2 = operation();
16391
+ if (result2 !== void 0 && result2 !== false) {
16278
16392
  validateTaskDependencies(this.tasks);
16279
16393
  this.save();
16280
16394
  }
16281
- return structuredClone(result);
16395
+ return structuredClone(result2);
16282
16396
  } catch (error) {
16283
16397
  this.tasks = previousTasks;
16284
16398
  this.nextId = previousId;
16285
16399
  throw error;
16286
16400
  }
16287
16401
  });
16402
+ if (result !== void 0 && result !== false) {
16403
+ for (const listener of this.listeners) {
16404
+ try {
16405
+ listener(structuredClone(this.tasks));
16406
+ } catch (error) {
16407
+ log27.error({ error }, "shared task subscriber failed");
16408
+ }
16409
+ }
16410
+ }
16411
+ return result;
16288
16412
  }
16289
16413
  create(subject, description = "", owner = "", blocks = [], blockedBy = [], createdBy = "", activeForm, metadata = {}) {
16290
16414
  return this.mutate(() => {
@@ -16472,7 +16596,7 @@ var SharedTaskStore = class {
16472
16596
  };
16473
16597
 
16474
16598
  // src/teams/index.ts
16475
- var log27 = createChildLogger({ module: "teams" });
16599
+ var log28 = createChildLogger({ module: "teams" });
16476
16600
  var MAX_RETAINED_TERMINATED_MEMBERS = 200;
16477
16601
  var Team = class _Team {
16478
16602
  name;
@@ -16852,7 +16976,7 @@ var Team = class _Team {
16852
16976
  uiState.lastMessage = "Stopped";
16853
16977
  terminalMessage = `[idle] ${name} (reason: stopped)`;
16854
16978
  } else {
16855
- log27.error({ err }, "teams operation failed");
16979
+ log28.error({ err }, "teams operation failed");
16856
16980
  uiState.status = "failed";
16857
16981
  uiState.lastMessage = asErrorString(err);
16858
16982
  terminalMessage = `[idle] ${name} (reason: failed): ${asErrorString(err)}`;
@@ -16867,7 +16991,7 @@ var Team = class _Team {
16867
16991
  try {
16868
16992
  await cleanup?.();
16869
16993
  } catch (error) {
16870
- log27.error({ error, name }, "teammate resource cleanup failed");
16994
+ log28.error({ error, name }, "teammate resource cleanup failed");
16871
16995
  } finally {
16872
16996
  try {
16873
16997
  this.releaseMemberTasks(member);
@@ -16888,7 +17012,7 @@ var Team = class _Team {
16888
17012
  }
16889
17013
  }
16890
17014
  })().catch((error) => {
16891
- log27.error(
17015
+ log28.error(
16892
17016
  { error, name },
16893
17017
  "teammate loop failed while reporting termination"
16894
17018
  );
@@ -17017,7 +17141,7 @@ Please revise the plan accordingly and resubmit.`;
17017
17141
  );
17018
17142
  }
17019
17143
  } catch (error) {
17020
- log27.error(
17144
+ log28.error(
17021
17145
  { error, member: member.name },
17022
17146
  "failed to release teammate tasks"
17023
17147
  );
@@ -17093,7 +17217,7 @@ Please revise the plan accordingly and resubmit.`;
17093
17217
  process.kill(pid, "SIGKILL");
17094
17218
  }
17095
17219
  } catch (error) {
17096
- log27.error(
17220
+ log28.error(
17097
17221
  { error, member: member.name },
17098
17222
  "external teammate termination failed"
17099
17223
  );
@@ -17103,7 +17227,7 @@ Please revise the plan accordingly and resubmit.`;
17103
17227
  try {
17104
17228
  member.cancel?.();
17105
17229
  } catch (error) {
17106
- log27.error({ error, member: member.name }, "teammate cancellation failed");
17230
+ log28.error({ error, member: member.name }, "teammate cancellation failed");
17107
17231
  }
17108
17232
  await member.done;
17109
17233
  this.releaseMemberTasks(member);
@@ -17195,10 +17319,26 @@ var TeamManager = class {
17195
17319
  unsubscribePermissions;
17196
17320
  // One shared task store per canonical team identity.
17197
17321
  taskStores = /* @__PURE__ */ new Map();
17322
+ listeners = /* @__PURE__ */ new Set();
17198
17323
  constructor(cwd2, opts = {}) {
17199
17324
  this.cwd = canonicalPath(cwd2);
17200
17325
  this.claimLeadership = opts.claimLeadership ?? true;
17201
17326
  }
17327
+ subscribe(listener) {
17328
+ this.listeners.add(listener);
17329
+ return () => {
17330
+ this.listeners.delete(listener);
17331
+ };
17332
+ }
17333
+ emitChange() {
17334
+ for (const listener of this.listeners) {
17335
+ try {
17336
+ listener();
17337
+ } catch (error) {
17338
+ log28.error({ error }, "team subscriber failed");
17339
+ }
17340
+ }
17341
+ }
17202
17342
  setPermissionChecker(checker) {
17203
17343
  if (this.permissionChecker === checker) {
17204
17344
  return;
@@ -17238,6 +17378,7 @@ var TeamManager = class {
17238
17378
  store.initEmpty();
17239
17379
  this.taskStores.set(key, store);
17240
17380
  team.persist();
17381
+ this.emitChange();
17241
17382
  return team;
17242
17383
  }
17243
17384
  /**
@@ -17285,6 +17426,9 @@ var TeamManager = class {
17285
17426
  team.pruneTerminatedMembers();
17286
17427
  }
17287
17428
  this.teams.set(key, team);
17429
+ if (this.claimLeadership) {
17430
+ this.emitChange();
17431
+ }
17288
17432
  return team;
17289
17433
  }
17290
17434
  /**
@@ -17330,6 +17474,7 @@ var TeamManager = class {
17330
17474
  this.permissionChecker = void 0;
17331
17475
  this.teams.clear();
17332
17476
  this.taskStores.clear();
17477
+ this.listeners.clear();
17333
17478
  }
17334
17479
  }
17335
17480
  async delete(name) {
@@ -17345,6 +17490,7 @@ var TeamManager = class {
17345
17490
  }
17346
17491
  this.taskStores.delete(key);
17347
17492
  rmSync7(this.teamDir(name), { recursive: true, force: true });
17493
+ this.emitChange();
17348
17494
  }
17349
17495
  /**
17350
17496
  * Deletes every team in this project: in-memory teams are stopped and
@@ -17721,7 +17867,7 @@ function addWebSocketToken(url, accessToken) {
17721
17867
  }
17722
17868
 
17723
17869
  // src/remote/server.ts
17724
- var log28 = createChildLogger({ module: "remote" });
17870
+ var log29 = createChildLogger({ module: "remote" });
17725
17871
  var requestCounter = 0;
17726
17872
  function nextRequestId(prefix) {
17727
17873
  requestCounter += 1;
@@ -18010,7 +18156,10 @@ async function createRemoteAgent(opts) {
18010
18156
  const fileHistory = new FileHistory(sessionId);
18011
18157
  const fileStateCache = new FileStateCache();
18012
18158
  const taskList = new TaskList(new TaskStore(sessionId));
18159
+ const teamManager = new TeamManager(cwd2);
18013
18160
  const registry = createToolRegistry(cwd2, taskList, {
18161
+ interactionMode: opts.interactionMode ?? "interactive",
18162
+ teamManager,
18014
18163
  lspServers: opts.lspServers
18015
18164
  });
18016
18165
  await configureBashSandbox(registry, cwd2, opts.sandboxConfig);
@@ -18042,7 +18191,7 @@ async function createRemoteAgent(opts) {
18042
18191
  const msgs = conv.getMessages();
18043
18192
  return msgs.slice(-count).map((m) => `${m.role}: ${contentToText(m.content)}`).join("\n");
18044
18193
  },
18045
- runSubagent: (prompt, abortSignal, context) => spawnSubagent(
18194
+ runSubagent: (prompt, abortSignal, context2) => spawnSubagent(
18046
18195
  BUILTIN_AGENTS[0],
18047
18196
  prompt,
18048
18197
  client,
@@ -18052,11 +18201,11 @@ async function createRemoteAgent(opts) {
18052
18201
  void 0,
18053
18202
  void 0,
18054
18203
  void 0,
18055
- context?.permissionChecker?.forCwd(cwd2) ?? handle.checker.forCwd(cwd2),
18204
+ context2?.permissionChecker?.forCwd(cwd2) ?? handle.checker.forCwd(cwd2),
18056
18205
  {
18057
18206
  abortSignal,
18058
18207
  background: false,
18059
- onPermissionRequest: context?.onPermissionRequest
18208
+ onPermissionRequest: context2?.onPermissionRequest
18060
18209
  }
18061
18210
  )
18062
18211
  };
@@ -18086,8 +18235,6 @@ async function createRemoteAgent(opts) {
18086
18235
  }
18087
18236
  );
18088
18237
  };
18089
- const teamManager = new TeamManager(cwd2);
18090
- registerLeaderTaskTools(registry, teamManager, taskList);
18091
18238
  teamManager.restoreFromDisk();
18092
18239
  const backgroundTaskManager = new TaskManager();
18093
18240
  attachBackgroundTaskManager(registry, backgroundTaskManager);
@@ -18099,7 +18246,7 @@ async function createRemoteAgent(opts) {
18099
18246
  const agentTool = new AgentTool(
18100
18247
  cwd2,
18101
18248
  registry,
18102
- async (def, prompt, background, modelOverride, cwdOverride, context) => {
18249
+ async (def, prompt, background, modelOverride, cwdOverride, context2) => {
18103
18250
  return spawnSubagent(
18104
18251
  def,
18105
18252
  prompt,
@@ -18110,18 +18257,18 @@ async function createRemoteAgent(opts) {
18110
18257
  void 0,
18111
18258
  void 0,
18112
18259
  modelOverride,
18113
- cwdOverride ? context?.permissionChecker?.forCwd(cwdOverride) : context?.permissionChecker,
18260
+ cwdOverride ? context2?.permissionChecker?.forCwd(cwdOverride) : context2?.permissionChecker,
18114
18261
  {
18115
- abortSignal: context?.abortSignal,
18262
+ abortSignal: context2?.abortSignal,
18116
18263
  background,
18117
- onPermissionRequest: context?.onPermissionRequest,
18118
- permissionMode: context?.permissionChecker?.mode
18264
+ onPermissionRequest: context2?.onPermissionRequest,
18265
+ permissionMode: context2?.permissionChecker?.mode
18119
18266
  }
18120
18267
  );
18121
18268
  },
18122
18269
  conv,
18123
- async (prompt, forkConv, forkRegistry, modelOverride, context) => {
18124
- const forkCwd = context?.cwd ?? cwd2;
18270
+ async (prompt, forkConv, forkRegistry, modelOverride, context2) => {
18271
+ const forkCwd = context2?.cwd ?? cwd2;
18125
18272
  const resolvedModel = modelOverride ?? provider.model;
18126
18273
  const forkEnv = detectEnvironment(forkCwd);
18127
18274
  forkEnv.model = resolvedModel;
@@ -18130,7 +18277,7 @@ async function createRemoteAgent(opts) {
18130
18277
  { ...provider, model: resolvedModel },
18131
18278
  forkSystemPrompt
18132
18279
  ) : client;
18133
- const checker = (context?.permissionChecker ?? handle.checker).forSubagent(forkCwd);
18280
+ const checker = (context2?.permissionChecker ?? handle.checker).forSubagent(forkCwd);
18134
18281
  forkConv.addUserMessage(prompt);
18135
18282
  const forkTaskManager = new TaskManager();
18136
18283
  const agent2 = new Agent({
@@ -18140,8 +18287,8 @@ async function createRemoteAgent(opts) {
18140
18287
  conversation: forkConv,
18141
18288
  cwd: forkCwd,
18142
18289
  maxIterations: 200,
18143
- abortSignal: context?.abortSignal,
18144
- onPermissionRequest: context?.onPermissionRequest,
18290
+ abortSignal: context2?.abortSignal,
18291
+ onPermissionRequest: context2?.onPermissionRequest,
18145
18292
  fileStateCache: new FileStateCache(),
18146
18293
  instructions: loadInstructions(forkCwd),
18147
18294
  contextWindow: getContextWindow(provider),
@@ -18196,7 +18343,7 @@ async function createRemoteAgent(opts) {
18196
18343
  }
18197
18344
  }
18198
18345
  for (const { serverName, error } of result.errors) {
18199
- log28.error({ serverName, error }, "MCP server connection error");
18346
+ log29.error({ serverName, error }, "MCP server connection error");
18200
18347
  }
18201
18348
  if (result.tools.length > 0) {
18202
18349
  decideAndApply(
@@ -18283,7 +18430,7 @@ var RemoteServer = class {
18283
18430
  compactController = null;
18284
18431
  reviewController = null;
18285
18432
  turnCount = 0;
18286
- eventLogger = new AgentEventLogger(log28);
18433
+ eventLogger = new AgentEventLogger(log29);
18287
18434
  /** Resolves run() once stop() has completed; run() blocks on it. */
18288
18435
  stoppedResolve = null;
18289
18436
  /** Last pong timestamp per client; drives the heartbeat sweep. */
@@ -18377,12 +18524,12 @@ var RemoteServer = class {
18377
18524
  try {
18378
18525
  raw = JSON.parse(data.toString("utf-8"));
18379
18526
  } catch {
18380
- log28.warn("received non-JSON WebSocket message");
18527
+ log29.warn("received non-JSON WebSocket message");
18381
18528
  return;
18382
18529
  }
18383
18530
  const parsed = WsInboundSchema.safeParse(raw);
18384
18531
  if (!parsed.success) {
18385
- log28.warn("received malformed WS message");
18532
+ log29.warn("received malformed WS message");
18386
18533
  return;
18387
18534
  }
18388
18535
  void this.handleWsMessage(ws, parsed.data);
@@ -18436,7 +18583,7 @@ var RemoteServer = class {
18436
18583
  await this.handleUserMessage(parsed.data.content);
18437
18584
  }
18438
18585
  } else {
18439
- log28.warn("dropping malformed user_message");
18586
+ log29.warn("dropping malformed user_message");
18440
18587
  }
18441
18588
  break;
18442
18589
  }
@@ -18448,7 +18595,7 @@ var RemoteServer = class {
18448
18595
  parsed.data.feedback
18449
18596
  );
18450
18597
  } else {
18451
- log28.warn({ issues: parsed.error.issues }, "malformed plan approval");
18598
+ log29.warn({ issues: parsed.error.issues }, "malformed plan approval");
18452
18599
  }
18453
18600
  break;
18454
18601
  }
@@ -18457,7 +18604,7 @@ var RemoteServer = class {
18457
18604
  if (parsed.success) {
18458
18605
  await this.handleCodeReviewStart(parsed.data);
18459
18606
  } else {
18460
- log28.warn(
18607
+ log29.warn(
18461
18608
  { issues: parsed.error.issues },
18462
18609
  "malformed code review request"
18463
18610
  );
@@ -18495,7 +18642,7 @@ var RemoteServer = class {
18495
18642
  break;
18496
18643
  }
18497
18644
  default:
18498
- log28.warn({ type: msg.type }, "unknown WS message type");
18645
+ log29.warn({ type: msg.type }, "unknown WS message type");
18499
18646
  }
18500
18647
  }
18501
18648
  /**
@@ -18547,7 +18694,7 @@ var RemoteServer = class {
18547
18694
  this.broadcast({ type: "commands", data: this.buildCommandList() });
18548
18695
  return handle;
18549
18696
  } catch (err) {
18550
- log28.error({ err }, "failed to initialize agent");
18697
+ log29.error({ err }, "failed to initialize agent");
18551
18698
  this.broadcast({
18552
18699
  type: "error",
18553
18700
  data: {
@@ -18611,7 +18758,7 @@ var RemoteServer = class {
18611
18758
  }
18612
18759
  }
18613
18760
  } catch (err) {
18614
- log28.error({ err }, "agent stream error");
18761
+ log29.error({ err }, "agent stream error");
18615
18762
  this.broadcast({
18616
18763
  type: "error",
18617
18764
  data: { message: err instanceof Error ? err.message : String(err) }
@@ -18844,7 +18991,7 @@ var RemoteServer = class {
18844
18991
  });
18845
18992
  }
18846
18993
  } catch (err) {
18847
- log28.error({ err }, "agent stream error in prompt command");
18994
+ log29.error({ err }, "agent stream error in prompt command");
18848
18995
  this.broadcast({
18849
18996
  type: "error",
18850
18997
  data: { message: err instanceof Error ? err.message : String(err) }
@@ -19124,7 +19271,7 @@ Investigate and design your approach. The agent will call ExitPlanMode when the
19124
19271
  });
19125
19272
  }
19126
19273
  } catch (err) {
19127
- log28.error({ err }, "agent stream error in plan command");
19274
+ log29.error({ err }, "agent stream error in plan command");
19128
19275
  this.broadcast({
19129
19276
  type: "error",
19130
19277
  data: { message: err instanceof Error ? err.message : String(err) }
@@ -19358,7 +19505,7 @@ ${report}
19358
19505
  }
19359
19506
  });
19360
19507
  } catch (err) {
19361
- log28.error({ err }, "code review failed");
19508
+ log29.error({ err }, "code review failed");
19362
19509
  this.broadcast({
19363
19510
  type: "error",
19364
19511
  data: { message: err instanceof Error ? err.message : String(err) }
@@ -19632,7 +19779,7 @@ ${report}
19632
19779
  memoryEnabled: this.opts.memoryEnabled !== false
19633
19780
  });
19634
19781
  } catch (err) {
19635
- log28.warn({ err }, "agent init deferred -- will retry on first message");
19782
+ log29.warn({ err }, "agent init deferred -- will retry on first message");
19636
19783
  this.agentHandle = null;
19637
19784
  }
19638
19785
  const stopped = new Promise((resolve11) => {
@@ -19711,7 +19858,7 @@ ${report}
19711
19858
  try {
19712
19859
  await this.agentHandle.registry.dispose();
19713
19860
  } catch (error) {
19714
- log28.error({ error }, "remote tool cleanup failed");
19861
+ log29.error({ error }, "remote tool cleanup failed");
19715
19862
  }
19716
19863
  }
19717
19864
  const resolveStopped = this.stoppedResolve;
@@ -19746,6 +19893,7 @@ async function createA2aRuntime(cwd2, sessionId) {
19746
19893
  throw new Error("No provider configured.");
19747
19894
  }
19748
19895
  const runtime2 = await createRemoteAgent({
19896
+ interactionMode: "non-interactive",
19749
19897
  provider,
19750
19898
  cwd: cwd2,
19751
19899
  hooks: config.hooks,
@@ -20791,17 +20939,17 @@ var YukinoAcpAgent = class {
20791
20939
  }))
20792
20940
  };
20793
20941
  }
20794
- prompt(params, context) {
20942
+ prompt(params, context2) {
20795
20943
  const session = this.requireSession(params.sessionId);
20796
20944
  const text = promptToText(params.prompt);
20797
20945
  const generation = session.generation;
20798
20946
  const run2 = session.tail.catch(() => void 0).then(async () => {
20799
- if (session.closed || generation !== session.generation || context.signal.aborted) {
20947
+ if (session.closed || generation !== session.generation || context2.signal.aborted) {
20800
20948
  return { stopReason: "cancelled" };
20801
20949
  }
20802
20950
  const turnAbort = new AbortController();
20803
20951
  session.turnAbort = turnAbort;
20804
- const signal = AbortSignal.any([context.signal, turnAbort.signal]);
20952
+ const signal = AbortSignal.any([context2.signal, turnAbort.signal]);
20805
20953
  const abort = () => {
20806
20954
  session.runtime.abort();
20807
20955
  };
@@ -20815,7 +20963,7 @@ var YukinoAcpAgent = class {
20815
20963
  session,
20816
20964
  params.sessionId,
20817
20965
  text,
20818
- context,
20966
+ context2,
20819
20967
  signal
20820
20968
  );
20821
20969
  } finally {
@@ -20879,7 +21027,7 @@ var YukinoAcpAgent = class {
20879
21027
  }
20880
21028
  return session;
20881
21029
  }
20882
- async runPrompt(session, sessionId, text, context, signal) {
21030
+ async runPrompt(session, sessionId, text, context2, signal) {
20883
21031
  saveMessage(session.runtime.cwd, sessionId, {
20884
21032
  role: "user",
20885
21033
  content: text,
@@ -20891,7 +21039,7 @@ var YukinoAcpAgent = class {
20891
21039
  for await (const event of session.runtime.run(text, {
20892
21040
  onPermissionRequest: async (toolName, args, decision, toolCallId, requestSignal) => {
20893
21041
  const permissionSignal = requestSignal ?? signal;
20894
- const permission = context.client.request(
21042
+ const permission = context2.client.request(
20895
21043
  acp.methods.client.session.requestPermission,
20896
21044
  {
20897
21045
  sessionId,
@@ -20958,7 +21106,7 @@ var YukinoAcpAgent = class {
20958
21106
  );
20959
21107
  if (update) {
20960
21108
  const notification = { sessionId, update };
20961
- await context.client.notify(
21109
+ await context2.client.notify(
20962
21110
  acp.methods.client.session.update,
20963
21111
  notification
20964
21112
  );
@@ -20974,30 +21122,30 @@ function createYukinoAcpApp(runtimeFactory) {
20974
21122
  const implementation = new YukinoAcpAgent(runtimeFactory);
20975
21123
  const app = acp.agent({ name: "yukino" }).onRequest(
20976
21124
  acp.methods.agent.initialize,
20977
- (context) => implementation.initialize(context.params)
21125
+ (context2) => implementation.initialize(context2.params)
20978
21126
  ).onRequest(
20979
21127
  acp.methods.agent.authenticate,
20980
21128
  () => implementation.authenticate()
20981
21129
  ).onRequest(
20982
21130
  acp.methods.agent.session.new,
20983
- (context) => implementation.newSession(context.params)
21131
+ (context2) => implementation.newSession(context2.params)
20984
21132
  ).onRequest(
20985
21133
  acp.methods.agent.session.prompt,
20986
- (context) => implementation.prompt(context.params, context)
21134
+ (context2) => implementation.prompt(context2.params, context2)
20987
21135
  ).onRequest(
20988
21136
  acp.methods.agent.session.list,
20989
- (context) => implementation.listSessions(context.params)
21137
+ (context2) => implementation.listSessions(context2.params)
20990
21138
  ).onRequest(
20991
21139
  acp.methods.agent.session.load,
20992
- (context) => implementation.loadSession(context.params, context.client, true)
21140
+ (context2) => implementation.loadSession(context2.params, context2.client, true)
20993
21141
  ).onRequest(
20994
21142
  acp.methods.agent.session.resume,
20995
- (context) => implementation.loadSession(context.params, context.client, false)
21143
+ (context2) => implementation.loadSession(context2.params, context2.client, false)
20996
21144
  ).onRequest(
20997
21145
  acp.methods.agent.session.close,
20998
- (context) => implementation.closeSession(context.params)
20999
- ).onNotification(acp.methods.agent.session.cancel, (context) => {
21000
- implementation.cancel(context.params);
21146
+ (context2) => implementation.closeSession(context2.params)
21147
+ ).onNotification(acp.methods.agent.session.cancel, (context2) => {
21148
+ implementation.cancel(context2.params);
21001
21149
  }).onConnect((connection) => {
21002
21150
  connection.signal.addEventListener(
21003
21151
  "abort",
@@ -21256,24 +21404,16 @@ function formatInteractionSummary(summary, endedAt = Date.now()) {
21256
21404
  const promptTokens = summary.inputTokens + summary.cacheReadTokens + summary.cacheCreationTokens;
21257
21405
  const cacheHitRate = percentage(summary.cacheReadTokens, promptTokens);
21258
21406
  return [
21259
- "### Interaction summary",
21260
- "",
21261
- `Session \`${summary.sessionId}\``,
21262
- "",
21407
+ `### Session \`${summary.sessionId}\``,
21263
21408
  [
21264
21409
  `**Tools** ${String(totalToolCalls)} calls \xB7 \u2713 ${String(summary.successfulToolCalls)} \xB7 \u2717 ${String(summary.failedToolCalls)} \xB7 ${successRate.toFixed(1)}% success`,
21265
21410
  `**Time** ${formatDuration(endedAt - summary.startedAt)} wall \xB7 ${formatDuration(summary.agentActiveMs)} active`,
21266
- `**Breakdown** API ${formatDuration(apiTimeMs)} (${percentage(apiTimeMs, summary.agentActiveMs)}) \xB7 Tools ${formatDuration(summary.toolTimeMs)} (${percentage(summary.toolTimeMs, summary.agentActiveMs)})`
21267
- ].join(" \n"),
21268
- "",
21269
- [
21411
+ `**Breakdown** API ${formatDuration(apiTimeMs)} (${percentage(apiTimeMs, summary.agentActiveMs)}) \xB7 Tools ${formatDuration(summary.toolTimeMs)} (${percentage(summary.toolTimeMs, summary.agentActiveMs)})`,
21270
21412
  `**Tokens** \u2191 ${formatTokens2(summary.inputTokens)} input \xB7 \u2193 ${formatTokens2(summary.outputTokens)} output`,
21271
21413
  `**Cache** ${formatTokens2(summary.cacheReadTokens)} read \xB7 ${formatTokens2(summary.cacheCreationTokens)} write`,
21272
- `**Cache hit** ${cacheHitRate} (${formatTokens2(summary.cacheReadTokens)} of ${formatTokens2(promptTokens)} prompt)`
21273
- ].join(" \n"),
21274
- "",
21275
- "**Resume session** ",
21276
- `\`yukino --resume ${summary.sessionId}\``
21414
+ `**Cache hit** ${cacheHitRate} (${formatTokens2(summary.cacheReadTokens)} of ${formatTokens2(promptTokens)} prompt)`,
21415
+ `\`yukino --resume ${summary.sessionId}\``
21416
+ ].join(" \n")
21277
21417
  ].join("\n");
21278
21418
  }
21279
21419
 
@@ -21310,26 +21450,26 @@ var CodeReviewFormSchema = z20.object({
21310
21450
  to: z20.string(),
21311
21451
  commit: z20.string(),
21312
21452
  exclude: z20.string()
21313
- }).superRefine((values, context) => {
21453
+ }).superRefine((values, context2) => {
21314
21454
  const from = values.from.trim();
21315
21455
  const to = values.to.trim();
21316
21456
  const commit = values.commit.trim();
21317
21457
  if (from && !to) {
21318
- context.addIssue({
21458
+ context2.addIssue({
21319
21459
  code: "custom",
21320
21460
  path: ["to"],
21321
21461
  message: "To is required when From is set"
21322
21462
  });
21323
21463
  }
21324
21464
  if (to && !from) {
21325
- context.addIssue({
21465
+ context2.addIssue({
21326
21466
  code: "custom",
21327
21467
  path: ["from"],
21328
21468
  message: "From is required when To is set"
21329
21469
  });
21330
21470
  }
21331
21471
  if (commit && (from || to)) {
21332
- context.addIssue({
21472
+ context2.addIssue({
21333
21473
  code: "custom",
21334
21474
  path: ["commit"],
21335
21475
  message: "Commit cannot be combined with From/To"
@@ -21337,13 +21477,13 @@ var CodeReviewFormSchema = z20.object({
21337
21477
  }
21338
21478
  const validateRef = (field, value) => {
21339
21479
  if (/\r|\n/u.test(value)) {
21340
- context.addIssue({
21480
+ context2.addIssue({
21341
21481
  code: "custom",
21342
21482
  path: [field],
21343
21483
  message: "Git refs must be a single line"
21344
21484
  });
21345
21485
  } else if (value.startsWith("-")) {
21346
- context.addIssue({
21486
+ context2.addIssue({
21347
21487
  code: "custom",
21348
21488
  path: [field],
21349
21489
  message: "Git refs must not start with '-'"
@@ -21385,7 +21525,7 @@ __export(usage_tracker_exports, {
21385
21525
  import { readFileSync as readFileSync13, writeFileSync as writeFileSync10, mkdirSync as mkdirSync11, existsSync as existsSync16 } from "fs";
21386
21526
  import { join as join21, dirname as dirname9 } from "path";
21387
21527
  import { safeParse as safeParse6, z as z21 } from "zod";
21388
- var log29 = createChildLogger({ module: "commands" });
21528
+ var log30 = createChildLogger({ module: "commands" });
21389
21529
  var UsageEntrySchema = z21.object({
21390
21530
  usageCount: z21.coerce.number(),
21391
21531
  lastUsedAt: z21.coerce.number()
@@ -21444,7 +21584,7 @@ var CommandUsageTracker = class {
21444
21584
  JSON.stringify(Object.fromEntries(this.usage), null, 2)
21445
21585
  );
21446
21586
  } catch (err) {
21447
- log29.error({ err }, "commands operation failed");
21587
+ log30.error({ err }, "commands operation failed");
21448
21588
  }
21449
21589
  }
21450
21590
  };
@@ -21473,7 +21613,7 @@ import {
21473
21613
  writeFileSync as writeFileSync11
21474
21614
  } from "fs";
21475
21615
  import { parse as parse6, z as z22 } from "zod";
21476
- var log30 = createChildLogger({ module: "history" });
21616
+ var log31 = createChildLogger({ module: "history" });
21477
21617
  var MAX_HISTORY_ENTRIES = 1e4;
21478
21618
  var FILENAME = "prompt_history.jsonl";
21479
21619
  var JSONLSchema = z22.looseObject({ text: z22.string() });
@@ -21490,12 +21630,12 @@ function load() {
21490
21630
  const { text } = parse6(JSONLSchema, entry);
21491
21631
  return text;
21492
21632
  } catch (err) {
21493
- log30.error({ err }, "parse history line failed");
21633
+ log31.error({ err }, "parse history line failed");
21494
21634
  return "";
21495
21635
  }
21496
21636
  }).filter(Boolean).slice(-MAX_HISTORY_ENTRIES);
21497
21637
  } catch (err2) {
21498
- log30.error({ err: err2 }, "load history failed");
21638
+ log31.error({ err: err2 }, "load history failed");
21499
21639
  return [];
21500
21640
  }
21501
21641
  }
@@ -21743,7 +21883,7 @@ import {
21743
21883
  import { homedir as homedir2 } from "os";
21744
21884
  import { join as join22, resolve as resolve9 } from "path";
21745
21885
  import yaml4 from "js-yaml";
21746
- var log31 = createChildLogger({ module: "skills" });
21886
+ var log32 = createChildLogger({ module: "skills" });
21747
21887
  var MAX_SKILL_DOWNLOAD_BYTES = 1024 * 1024;
21748
21888
  async function readSkillResponse(response, signal) {
21749
21889
  const contentLength = Number(response.headers.get("content-length"));
@@ -21917,7 +22057,7 @@ ${parsed.body}
21917
22057
  isError: false
21918
22058
  };
21919
22059
  } catch (err) {
21920
- log31.error({ err }, "skills operation failed");
22060
+ log32.error({ err }, "skills operation failed");
21921
22061
  return {
21922
22062
  output: `Error installing skill: ${asErrorString(err)}`,
21923
22063
  isError: true
@@ -21947,6 +22087,7 @@ __export(tools_exports3, {
21947
22087
  Descriptions: () => descriptions_exports,
21948
22088
  Diff: () => diff_exports,
21949
22089
  EditFile: () => edit_file_exports,
22090
+ EditFileDiagnostics: () => edit_file_diagnostics_exports,
21950
22091
  EnterWorktree: () => enter_worktree_exports,
21951
22092
  ExitCodeHints: () => exit_code_hints_exports,
21952
22093
  ExitPlanMode: () => exit_plan_mode_exports,
@@ -21991,6 +22132,7 @@ __export(update_exports, {
21991
22132
  VersionCheck: () => version_check_exports,
21992
22133
  handleUpdateCommand: () => handleUpdateCommand
21993
22134
  });
22135
+ import { parseArgs } from "util";
21994
22136
 
21995
22137
  // src/update/install.ts
21996
22138
  var install_exports = {};
@@ -22015,7 +22157,7 @@ __export(version_check_exports, {
22015
22157
  });
22016
22158
  import { z as z24 } from "zod";
22017
22159
  var PACKAGE_NAME = "@yukino.js/yukino";
22018
- var LATEST_VERSION_URL = "https://registry.npmjs.org/@yukino.js%2Fyukino/latest";
22160
+ var PACKAGE_URL = "https://registry.npmjs.org/@yukino.js%2Fyukino";
22019
22161
  var VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*))?(?:\+[\dA-Za-z-]+(?:\.[\dA-Za-z-]+)*)?$/u;
22020
22162
  function parseVersion(value) {
22021
22163
  const match = VERSION_PATTERN.exec(value);
@@ -22057,18 +22199,27 @@ function isNewerVersion(candidate, current) {
22057
22199
  }
22058
22200
  return false;
22059
22201
  }
22060
- async function getLatestVersion(signal) {
22202
+ async function getLatestVersion({
22203
+ tag = "latest",
22204
+ signal
22205
+ } = {}) {
22206
+ if (!tag || encodeURIComponent(tag) !== tag || [".", ".."].includes(tag)) {
22207
+ throw new Error(`Invalid npm dist-tag: ${tag}`);
22208
+ }
22061
22209
  const timeout = AbortSignal.timeout(1e4);
22062
- const response = await fetch(LATEST_VERSION_URL, {
22210
+ const response = await fetch(`${PACKAGE_URL}/${encodeURIComponent(tag)}`, {
22063
22211
  headers: {
22064
22212
  accept: "application/json",
22065
22213
  "User-Agent": `yukino/${version} (${process.platform}; ${process.arch})`
22066
22214
  },
22067
22215
  signal: signal ? AbortSignal.any([signal, timeout]) : timeout
22068
22216
  });
22217
+ if (response.status === 404) {
22218
+ throw new Error(`No Yukino release found for npm dist-tag "${tag}".`);
22219
+ }
22069
22220
  if (!response.ok) {
22070
22221
  throw new Error(
22071
- `Could not check for Yukino updates: HTTP ${response.status}`
22222
+ `Could not check for Yukino updates (npm dist-tag "${tag}"): HTTP ${response.status}`
22072
22223
  );
22073
22224
  }
22074
22225
  const data = await response.json();
@@ -22081,7 +22232,7 @@ async function checkForUpdate(signal) {
22081
22232
  return void 0;
22082
22233
  }
22083
22234
  try {
22084
- const latest = await getLatestVersion(signal);
22235
+ const latest = await getLatestVersion({ signal });
22085
22236
  return isNewerVersion(latest, version) ? latest : void 0;
22086
22237
  } catch {
22087
22238
  return void 0;
@@ -22203,6 +22354,26 @@ async function runSelfUpdate(update) {
22203
22354
  }
22204
22355
 
22205
22356
  // src/update/index.ts
22357
+ var UPDATE_USAGE = "Usage: yukino update [--tag <tag>]";
22358
+ function parseUpdateOptions(args) {
22359
+ try {
22360
+ return parseArgs({
22361
+ args,
22362
+ options: {
22363
+ tag: { type: "string" },
22364
+ help: { type: "boolean", short: "h" }
22365
+ },
22366
+ strict: true,
22367
+ allowPositionals: false
22368
+ }).values;
22369
+ } catch (error) {
22370
+ throw new Error(
22371
+ `${error instanceof Error ? error.message : String(error)}
22372
+ ${UPDATE_USAGE}`,
22373
+ { cause: error }
22374
+ );
22375
+ }
22376
+ }
22206
22377
  async function handleUpdateCommand(args) {
22207
22378
  if (args.length === 1 && ["--version", "-v"].includes(args[0])) {
22208
22379
  console.log(version);
@@ -22211,17 +22382,25 @@ async function handleUpdateCommand(args) {
22211
22382
  if (args[0] !== "update") {
22212
22383
  return false;
22213
22384
  }
22214
- if (args.length === 2 && ["--help", "-h"].includes(args[1])) {
22215
- console.log(
22216
- "Usage: yukino update\n\nUpdate Yukino to the latest npm release."
22217
- );
22218
- return true;
22219
- }
22220
22385
  try {
22221
- if (args.length !== 1) {
22222
- throw new Error("Usage: yukino update");
22386
+ const options = parseUpdateOptions(args.slice(1));
22387
+ if (options.help) {
22388
+ console.log(
22389
+ `${UPDATE_USAGE}
22390
+
22391
+ Update Yukino from an npm dist-tag.
22392
+
22393
+ Options:
22394
+ --tag <tag> npm dist-tag to check (default: latest)
22395
+ -h, --help Show this help
22396
+
22397
+ Examples:
22398
+ yukino update
22399
+ yukino update --tag=canary`
22400
+ );
22401
+ return true;
22223
22402
  }
22224
- const latest = await getLatestVersion();
22403
+ const latest = await getLatestVersion({ tag: options.tag });
22225
22404
  if (!isNewerVersion(latest, version)) {
22226
22405
  console.log(`Yukino is already up to date (v${version}).`);
22227
22406
  return true;
@@ -22267,7 +22446,7 @@ import { readdir, readFile as readFile8 } from "fs/promises";
22267
22446
  import { homedir as homedir3 } from "os";
22268
22447
  import { join as join24, resolve as resolve10, sep as sep4 } from "path";
22269
22448
  import { z as z26 } from "zod";
22270
- var log32 = createChildLogger({ module: "vscode" });
22449
+ var log33 = createChildLogger({ module: "vscode" });
22271
22450
  var LockfileSchema = z26.object({
22272
22451
  workspaceFolders: z26.array(z26.string()).optional(),
22273
22452
  pid: z26.number().optional(),
@@ -22309,7 +22488,7 @@ async function readLockfile(dir, filename) {
22309
22488
  pid: parsed.pid
22310
22489
  };
22311
22490
  } catch (err) {
22312
- log32.error({ err, filename }, "failed to read IDE lockfile");
22491
+ log33.error({ err, filename }, "failed to read IDE lockfile");
22313
22492
  return null;
22314
22493
  }
22315
22494
  }
@@ -22433,7 +22612,7 @@ var WebSocketTransport = class {
22433
22612
  };
22434
22613
 
22435
22614
  // src/vscode/ide-client.ts
22436
- var log33 = createChildLogger({ module: "vscode" });
22615
+ var log34 = createChildLogger({ module: "vscode" });
22437
22616
  var AtMentionedSchema = z27.object({
22438
22617
  method: z27.literal("at_mentioned"),
22439
22618
  params: z27.object({
@@ -22475,7 +22654,7 @@ async function connectToIde(opts) {
22475
22654
  } catch (err) {
22476
22655
  await client.close().catch(() => void 0);
22477
22656
  if (!opts.signal?.aborted) {
22478
- log33.error({ err, url: ide.url }, "failed to connect to IDE extension");
22657
+ log34.error({ err, url: ide.url }, "failed to connect to IDE extension");
22479
22658
  }
22480
22659
  return null;
22481
22660
  }
@@ -22501,7 +22680,7 @@ async function connectToIde(opts) {
22501
22680
  params: { pid: process.pid }
22502
22681
  });
22503
22682
  } catch (err) {
22504
- log33.error({ err }, "failed to send ide_connected notification");
22683
+ log34.error({ err }, "failed to send ide_connected notification");
22505
22684
  }
22506
22685
  return {
22507
22686
  ideName: ide.ideName,
@@ -22510,7 +22689,7 @@ async function connectToIde(opts) {
22510
22689
  try {
22511
22690
  await client.close();
22512
22691
  } catch (err) {
22513
- log33.error({ err }, "failed to close IDE client");
22692
+ log34.error({ err }, "failed to close IDE client");
22514
22693
  }
22515
22694
  }
22516
22695
  };
@@ -22623,12 +22802,13 @@ async function runPrintMode(args) {
22623
22802
  conv.addUserMessage(prompt);
22624
22803
  const checker = new PermissionChecker(cwd2, "bypassPermissions");
22625
22804
  const taskList = new TaskList();
22805
+ const teamManager = new TeamManager(cwd2);
22626
22806
  const registry = createToolRegistry(cwd2, taskList, {
22807
+ interactionMode: "non-interactive",
22808
+ teamManager,
22627
22809
  lspServers: cfg.lsp_servers
22628
22810
  });
22629
22811
  await configureBashSandbox(registry, cwd2, cfg.sandbox, checker);
22630
- const teamManager = new TeamManager(cwd2);
22631
- registerLeaderTaskTools(registry, teamManager, taskList);
22632
22812
  teamManager.setPermissionChecker(checker);
22633
22813
  const backgroundTaskManager = new TaskManager();
22634
22814
  attachBackgroundTaskManager(registry, backgroundTaskManager);
@@ -22640,7 +22820,7 @@ async function runPrintMode(args) {
22640
22820
  const agentTool = new AgentTool(
22641
22821
  cwd2,
22642
22822
  registry,
22643
- (def, prompt2, background, modelOverride, cwdOverride, context) => spawnSubagent(
22823
+ (def, prompt2, background, modelOverride, cwdOverride, context2) => spawnSubagent(
22644
22824
  def,
22645
22825
  prompt2,
22646
22826
  client,
@@ -22650,30 +22830,30 @@ async function runPrintMode(args) {
22650
22830
  void 0,
22651
22831
  void 0,
22652
22832
  modelOverride,
22653
- cwdOverride ? context?.permissionChecker?.forCwd(cwdOverride) : context?.permissionChecker,
22833
+ cwdOverride ? context2?.permissionChecker?.forCwd(cwdOverride) : context2?.permissionChecker,
22654
22834
  {
22655
- abortSignal: context?.abortSignal,
22835
+ abortSignal: context2?.abortSignal,
22656
22836
  background,
22657
- onPermissionRequest: context?.onPermissionRequest,
22658
- permissionMode: context?.permissionChecker?.mode
22837
+ onPermissionRequest: context2?.onPermissionRequest,
22838
+ permissionMode: context2?.permissionChecker?.mode
22659
22839
  }
22660
22840
  ),
22661
22841
  conv,
22662
- (prompt2, conversation, forkRegistry, modelOverride, context) => spawnSubagent(
22842
+ (prompt2, conversation, forkRegistry, modelOverride, context2) => spawnSubagent(
22663
22843
  BUILTIN_AGENTS[0],
22664
22844
  prompt2,
22665
22845
  client,
22666
22846
  forkRegistry,
22667
22847
  provider,
22668
- context?.cwd ?? cwd2,
22848
+ context2?.cwd ?? cwd2,
22669
22849
  void 0,
22670
22850
  void 0,
22671
22851
  modelOverride,
22672
- context?.permissionChecker,
22852
+ context2?.permissionChecker,
22673
22853
  {
22674
22854
  conversation,
22675
- abortSignal: context?.abortSignal,
22676
- onPermissionRequest: context?.onPermissionRequest
22855
+ abortSignal: context2?.abortSignal,
22856
+ onPermissionRequest: context2?.onPermissionRequest
22677
22857
  }
22678
22858
  ),
22679
22859
  backgroundTaskManager
@@ -22940,9 +23120,9 @@ function record(text) {
22940
23120
  } catch {
22941
23121
  }
22942
23122
  }
22943
- function recordError(context, error) {
23123
+ function recordError(context2, error) {
22944
23124
  const stack = error instanceof Error ? error.stack ?? error.message : String(error);
22945
- record(`crash [${context}] ${stack}`);
23125
+ record(`crash [${context2}] ${stack}`);
22946
23126
  }
22947
23127
  var TERMINAL_GONE_CODES = /* @__PURE__ */ new Set(["EIO", "EPIPE", "ERR_STREAM_DESTROYED"]);
22948
23128
  function isTerminalGone(err) {
@@ -22953,11 +23133,11 @@ function isTerminalGone(err) {
22953
23133
  return typeof code === "string" && TERMINAL_GONE_CODES.has(code);
22954
23134
  }
22955
23135
  var terminalGoneRecorded = false;
22956
- function exitForTerminalGone(context, error) {
23136
+ function exitForTerminalGone(context2, error) {
22957
23137
  if (!terminalGoneRecorded) {
22958
23138
  terminalGoneRecorded = true;
22959
23139
  const detail = error instanceof Error ? error.message : String(error);
22960
- record(`terminal closed [${context}] ${detail}`);
23140
+ record(`terminal closed [${context2}] ${detail}`);
22961
23141
  }
22962
23142
  runExitCleanups();
22963
23143
  process.exit(0);
@@ -23077,7 +23257,7 @@ function parseTeammateFlags(args) {
23077
23257
  };
23078
23258
  }
23079
23259
  var LEADER_LOST_EXIT_MS = 6e4;
23080
- var log34 = createChildLogger({ module: "teammate" });
23260
+ var log35 = createChildLogger({ module: "teammate" });
23081
23261
  function isPidAlive2(pid) {
23082
23262
  try {
23083
23263
  process.kill(pid, 0);
@@ -23098,6 +23278,7 @@ async function buildTeammateRegistry(opts) {
23098
23278
  );
23099
23279
  }
23100
23280
  const registry = createToolRegistry(opts.cwd, new TaskList(), {
23281
+ interactionMode: "interactive",
23101
23282
  lspServers: opts.lspServers
23102
23283
  });
23103
23284
  await configureBashSandbox(registry, opts.cwd, opts.sandboxConfig);
@@ -23130,7 +23311,7 @@ async function buildTeammateRegistry(opts) {
23130
23311
  }
23131
23312
  }
23132
23313
  for (const { serverName, error } of result.errors) {
23133
- log34.error({ serverName, error }, "MCP connection error");
23314
+ log35.error({ serverName, error }, "MCP connection error");
23134
23315
  }
23135
23316
  if (result.tools.length > 0 && opts.contextWindow) {
23136
23317
  decideAndApply(
@@ -23141,7 +23322,7 @@ async function buildTeammateRegistry(opts) {
23141
23322
  );
23142
23323
  }
23143
23324
  } catch (err) {
23144
- log34.error({ err }, "MCP setup failed");
23325
+ log35.error({ err }, "MCP setup failed");
23145
23326
  }
23146
23327
  }
23147
23328
  const filtered = filterToolsForAgent(
@@ -23312,7 +23493,7 @@ ${body}`
23312
23493
  leaderDeadSince = 0;
23313
23494
  }
23314
23495
  } catch (err) {
23315
- log34.error({ err }, "teammate control poll failed");
23496
+ log35.error({ err }, "teammate control poll failed");
23316
23497
  }
23317
23498
  }, 2e3);
23318
23499
  const notifyIdle = () => leaderMailbox.send(
@@ -23338,7 +23519,7 @@ ${body}`
23338
23519
  console.log("--- Task complete ---");
23339
23520
  break;
23340
23521
  case "error":
23341
- log34.error({ err: event.error }, "agent error");
23522
+ log35.error({ err: event.error }, "agent error");
23342
23523
  await notifyFailed(event.error);
23343
23524
  throw event.error;
23344
23525
  }
@@ -23368,7 +23549,7 @@ ${body}`
23368
23549
  if (event.type === "stream_text") {
23369
23550
  process.stdout.write(event.text);
23370
23551
  } else if (event.type === "error") {
23371
- log34.error({ err: event.error }, "agent error");
23552
+ log35.error({ err: event.error }, "agent error");
23372
23553
  await notifyFailed(event.error);
23373
23554
  throw event.error;
23374
23555
  }
@@ -23398,7 +23579,7 @@ ${body}`
23398
23579
  ]);
23399
23580
  for (const result of results) {
23400
23581
  if (result.status === "rejected") {
23401
- log34.error({ err: result.reason }, "teammate resource cleanup failed");
23582
+ log35.error({ err: result.reason }, "teammate resource cleanup failed");
23402
23583
  }
23403
23584
  }
23404
23585
  try {
@@ -23414,7 +23595,7 @@ ${body}`
23414
23595
  releaseSummary = `; unassigned tasks: ${released.map((task) => `#${task.id}`).join(", ")}`;
23415
23596
  }
23416
23597
  } catch (error) {
23417
- log34.error({ error }, "teammate task release failed");
23598
+ log35.error({ error }, "teammate task release failed");
23418
23599
  releaseSummary = "; task release failed: inspect the shared board before reassignment";
23419
23600
  }
23420
23601
  }
@@ -23424,7 +23605,7 @@ ${body}`
23424
23605
  );
23425
23606
  }
23426
23607
  } catch (error) {
23427
- log34.error({ error }, "teammate exit notification failed");
23608
+ log35.error({ error }, "teammate exit notification failed");
23428
23609
  }
23429
23610
  process.off("SIGINT", abort);
23430
23611
  process.off("SIGTERM", abort);