@ycodium-ai/agent-claude 0.2.5265 → 0.2.5280

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 (2) hide show
  1. package/dist/index.js +419 -419
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import * as NodePath21 from "node:path";
3
3
  import { definePlugin } from "@ycodium-ai/plugin-api";
4
4
 
5
5
  // ../../packages/plugin-api/src/version.ts
6
- var PLUGIN_API_VERSION = 157;
6
+ var PLUGIN_API_VERSION = 158;
7
7
 
8
8
  // src/index.ts
9
9
  import {
@@ -22419,403 +22419,6 @@ function toRequestError(threadId, method, cause) {
22419
22419
  return new Error(`${method} failed`, { cause });
22420
22420
  }
22421
22421
 
22422
- // ../../packages/ycodium-tool-label/src/toolLabel.ts
22423
- var DETAIL_MAX_CHARS = 200;
22424
- var LABEL_TEXT_MAX_CHARS = 400;
22425
- var SUMMARY_KEYS = [
22426
- "description",
22427
- "title",
22428
- "query",
22429
- "pattern",
22430
- "url",
22431
- "command",
22432
- "cmd",
22433
- "prompt",
22434
- "name",
22435
- "path"
22436
- ];
22437
- var PATH_KEYS = ["file_path", "notebook_path"];
22438
- function asTrimmedString(value) {
22439
- if (typeof value !== "string") {
22440
- return void 0;
22441
- }
22442
- const trimmed = value.trim();
22443
- return trimmed.length > 0 ? trimmed : void 0;
22444
- }
22445
- function asPositiveInt(value) {
22446
- return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
22447
- }
22448
- function replacementDiffStat(input, budget) {
22449
- if (input.replace_all === true) return void 0;
22450
- const oldText = input.old_string ?? input.oldText;
22451
- const newText = input.new_string ?? input.newText;
22452
- if (typeof oldText !== "string" || typeof newText !== "string") return void 0;
22453
- budget.characters -= oldText.length + newText.length;
22454
- if (budget.characters < 0) return void 0;
22455
- const before = oldText.match(/[^\n]*\n|[^\n]+$/gu) ?? [];
22456
- const after = newText.match(/[^\n]*\n|[^\n]+$/gu) ?? [];
22457
- let start = 0;
22458
- let beforeEnd = before.length;
22459
- let afterEnd = after.length;
22460
- while (start < beforeEnd && start < afterEnd && before[start] === after[start]) start += 1;
22461
- while (beforeEnd > start && afterEnd > start && before[beforeEnd - 1] === after[afterEnd - 1]) {
22462
- beforeEnd -= 1;
22463
- afterEnd -= 1;
22464
- }
22465
- const deleted = beforeEnd - start;
22466
- const added = afterEnd - start;
22467
- budget.cells -= deleted * added;
22468
- if (budget.cells < 0) return void 0;
22469
- const lengths = new Uint32Array(added + 1);
22470
- for (let i = start; i < beforeEnd; i += 1) {
22471
- let diagonal = 0;
22472
- for (let j3 = 1; j3 <= added; j3 += 1) {
22473
- const previous = lengths[j3] ?? 0;
22474
- lengths[j3] = before[i] === after[start + j3 - 1] ? diagonal + 1 : Math.max(previous, lengths[j3 - 1] ?? 0);
22475
- diagonal = previous;
22476
- }
22477
- }
22478
- const shared = lengths[added] ?? 0;
22479
- return { additions: added - shared, deletions: deleted - shared };
22480
- }
22481
- function inputDiffStat(input) {
22482
- const budget = { characters: 2e5, cells: 25e4 };
22483
- if (!Array.isArray(input.edits)) return replacementDiffStat(input, budget);
22484
- if (input.edits.length === 0 || input.edits.length > 100 || input.replace_all === true)
22485
- return void 0;
22486
- let additions = 0;
22487
- let deletions = 0;
22488
- for (const edit of input.edits) {
22489
- if (edit === null || typeof edit !== "object" || Array.isArray(edit)) return void 0;
22490
- const stat5 = replacementDiffStat(edit, budget);
22491
- if (!stat5) return void 0;
22492
- additions += stat5.additions;
22493
- deletions += stat5.deletions;
22494
- }
22495
- return { additions, deletions };
22496
- }
22497
- function collapse(value, max) {
22498
- const collapsed = value.replace(/\s+/gu, " ").trim();
22499
- return collapsed.length <= max ? collapsed : `${collapsed.slice(0, max - 1).trimEnd()}\u2026`;
22500
- }
22501
- function displayToolName(toolName) {
22502
- const trimmed = toolName.trim();
22503
- if (!trimmed.startsWith("mcp__")) {
22504
- return trimmed;
22505
- }
22506
- const rest = trimmed.slice("mcp__".length).replaceAll("__", " ").trim();
22507
- return rest.length > 0 ? rest : trimmed;
22508
- }
22509
- function readRangeSuffix(input) {
22510
- const offset = asPositiveInt(input.offset);
22511
- const limit = asPositiveInt(input.limit);
22512
- if (offset !== void 0 && limit !== void 0) {
22513
- return `(lines ${offset}-${offset + limit - 1})`;
22514
- }
22515
- if (offset !== void 0) {
22516
- return `(from line ${offset})`;
22517
- }
22518
- if (limit !== void 0) {
22519
- return `(first ${limit} lines)`;
22520
- }
22521
- return void 0;
22522
- }
22523
- function loneStringValue(input) {
22524
- let found;
22525
- for (const value of Object.values(input)) {
22526
- const text2 = asTrimmedString(value);
22527
- if (text2 === void 0) {
22528
- continue;
22529
- }
22530
- if (found !== void 0) {
22531
- return void 0;
22532
- }
22533
- found = text2;
22534
- }
22535
- return found;
22536
- }
22537
- function compactJson(input) {
22538
- let serialized;
22539
- try {
22540
- serialized = JSON.stringify(input);
22541
- } catch {
22542
- return void 0;
22543
- }
22544
- if (!serialized || serialized === "{}" || serialized === "[]") {
22545
- return void 0;
22546
- }
22547
- return collapse(serialized, DETAIL_MAX_CHARS);
22548
- }
22549
- function formatToolLabel(toolName, input) {
22550
- const name = displayToolName(toolName);
22551
- const diffStat = inputDiffStat(input);
22552
- if (name.endsWith("visualize_visualize") && typeof input.fragment === "string") {
22553
- const { fragment: _fragment, ...rest } = input;
22554
- return formatToolLabel(toolName, rest);
22555
- }
22556
- for (const key of PATH_KEYS) {
22557
- const path = asTrimmedString(input[key]);
22558
- if (path === void 0) {
22559
- continue;
22560
- }
22561
- const suffix = readRangeSuffix(input);
22562
- return {
22563
- name,
22564
- path,
22565
- ...suffix ? { detail: suffix } : {},
22566
- ...diffStat ? { diffStat } : {},
22567
- descriptive: true
22568
- };
22569
- }
22570
- for (const key of SUMMARY_KEYS) {
22571
- const value = asTrimmedString(input[key]);
22572
- if (value !== void 0) {
22573
- const detail = collapse(value, DETAIL_MAX_CHARS);
22574
- const scope = key === "pattern" ? asTrimmedString(input.path) : void 0;
22575
- return { name, ...scope ? { path: scope } : {}, detail, descriptive: true };
22576
- }
22577
- }
22578
- const lone = loneStringValue(input);
22579
- if (lone !== void 0) {
22580
- return { name, detail: collapse(lone, DETAIL_MAX_CHARS), descriptive: true };
22581
- }
22582
- const compact = compactJson(input);
22583
- return { name, ...compact ? { detail: compact } : {}, descriptive: false };
22584
- }
22585
- function formatToolLabelText(label) {
22586
- const joined = [label.name, label.path, label.detail].filter((part) => part).join(" ");
22587
- return joined.length <= LABEL_TEXT_MAX_CHARS ? joined : `${joined.slice(0, LABEL_TEXT_MAX_CHARS - 1).trimEnd()}\u2026`;
22588
- }
22589
-
22590
- // src/toolClassify.ts
22591
- function classifyToolItemType(toolName) {
22592
- const normalized = toolName.toLowerCase();
22593
- if (normalized.startsWith("mcp__")) {
22594
- return "mcp_tool_call";
22595
- }
22596
- if (normalized.includes("agent")) {
22597
- return "collab_agent_tool_call";
22598
- }
22599
- if (normalized === "task" || normalized === "agent" || normalized.includes("subagent") || normalized.includes("sub-agent")) {
22600
- return "collab_agent_tool_call";
22601
- }
22602
- if (normalized.includes("bash") || normalized.includes("command") || normalized.includes("shell") || normalized.includes("terminal")) {
22603
- return "command_execution";
22604
- }
22605
- if (normalized.includes("edit") || normalized.includes("write") || normalized.includes("file") || normalized.includes("patch") || normalized.includes("replace") || normalized.includes("create") || normalized.includes("delete")) {
22606
- return "file_change";
22607
- }
22608
- if (normalized.includes("mcp")) {
22609
- return "mcp_tool_call";
22610
- }
22611
- if (normalized.includes("websearch") || normalized.includes("web search")) {
22612
- return "web_search";
22613
- }
22614
- if (normalized.includes("image")) {
22615
- return "image_view";
22616
- }
22617
- return "dynamic_tool_call";
22618
- }
22619
- function isReadOnlyToolName(toolName) {
22620
- const normalized = toolName.toLowerCase();
22621
- return normalized === "read" || normalized.includes("read file") || normalized.includes("view") || normalized.includes("grep") || normalized.includes("glob") || normalized.includes("search");
22622
- }
22623
- function classifyRequestType(toolName) {
22624
- const normalized = toolName.toLowerCase();
22625
- if (normalized.startsWith("mcp__") || normalized.includes("mcp")) {
22626
- return "mcp_tool_approval";
22627
- }
22628
- if (normalized.includes("skill")) {
22629
- return "skill_approval";
22630
- }
22631
- if (normalized.includes("webfetch") || normalized.includes("web fetch")) {
22632
- return "web_fetch_approval";
22633
- }
22634
- if (normalized.includes("websearch") || normalized.includes("web search")) {
22635
- return "web_search_approval";
22636
- }
22637
- if (isReadOnlyToolName(toolName)) {
22638
- return "file_read_approval";
22639
- }
22640
- const itemType = classifyToolItemType(toolName);
22641
- return itemType === "command_execution" ? "command_execution_approval" : itemType === "file_change" ? "file_change_approval" : "dynamic_tool_call";
22642
- }
22643
- function isTodoTool(toolName) {
22644
- return toolName.toLowerCase().includes("todowrite");
22645
- }
22646
- function isClaudeTaskTool(toolName) {
22647
- return toolName === "TaskCreate" || toolName === "TaskUpdate" || toolName === "TaskList";
22648
- }
22649
- function summarizeToolRequest(toolName, input) {
22650
- const itemType = classifyToolItemType(toolName);
22651
- if (itemType === "collab_agent_tool_call") {
22652
- const description = typeof input.description === "string" ? input.description.trim() : void 0;
22653
- const prompt = typeof input.prompt === "string" ? input.prompt.trim() : void 0;
22654
- const label = description || (prompt ? prompt.slice(0, 200) : void 0);
22655
- if (label) {
22656
- return label;
22657
- }
22658
- }
22659
- return formatToolLabelText(formatToolLabel(toolName, input));
22660
- }
22661
- function titleForTool(itemType) {
22662
- switch (itemType) {
22663
- case "command_execution":
22664
- return "Command run";
22665
- case "file_change":
22666
- return "File change";
22667
- case "mcp_tool_call":
22668
- return "MCP tool call";
22669
- case "collab_agent_tool_call":
22670
- return "Subagent task";
22671
- case "web_search":
22672
- return "Web search";
22673
- case "image_view":
22674
- return "Image view";
22675
- case "dynamic_tool_call":
22676
- return "Tool call";
22677
- default:
22678
- return "Item";
22679
- }
22680
- }
22681
- function toolResultStreamKind(itemType) {
22682
- switch (itemType) {
22683
- case "command_execution":
22684
- return "command_output";
22685
- case "file_change":
22686
- return "file_change_output";
22687
- default:
22688
- return void 0;
22689
- }
22690
- }
22691
-
22692
- // src/toolPayload.ts
22693
- function fileChangesFromClaudeToolInput(toolName, input) {
22694
- const path = asStringField(input, "file_path") ?? asStringField(input, "notebook_path");
22695
- if (!path || path.trim().length === 0) {
22696
- return void 0;
22697
- }
22698
- const content = asStringField(input, "content") ?? asStringField(input, "new_source");
22699
- if (content !== void 0) {
22700
- return [{ path, changeKind: "add", content: { kind: "replace", newText: content } }];
22701
- }
22702
- const edits = Array.isArray(input.edits) ? input.edits : void 0;
22703
- if (edits) {
22704
- const changes = edits.flatMap((entry) => {
22705
- if (entry === null || typeof entry !== "object") {
22706
- return [];
22707
- }
22708
- const edit = entry;
22709
- const newText = asStringField(edit, "new_string");
22710
- if (newText === void 0) {
22711
- return [];
22712
- }
22713
- const oldText = asStringField(edit, "old_string");
22714
- return [
22715
- {
22716
- path,
22717
- changeKind: "modify",
22718
- content: {
22719
- kind: "replace",
22720
- ...oldText !== void 0 ? { oldText } : {},
22721
- newText
22722
- }
22723
- }
22724
- ];
22725
- });
22726
- return changes.length > 0 ? changes : void 0;
22727
- }
22728
- const newString = asStringField(input, "new_string");
22729
- if (newString !== void 0) {
22730
- const oldString = asStringField(input, "old_string");
22731
- return [
22732
- {
22733
- path,
22734
- changeKind: "modify",
22735
- content: {
22736
- kind: "replace",
22737
- ...oldString !== void 0 ? { oldText: oldString } : {},
22738
- newText: newString
22739
- }
22740
- }
22741
- ];
22742
- }
22743
- return classifyToolItemType(toolName) === "file_change" ? [{ path, omitted: "unavailable" }] : void 0;
22744
- }
22745
- function skillNameFromClaudeToolInput(input) {
22746
- const name = asStringField(input, "name") ?? asStringField(input, "skill") ?? asStringField(input, "command");
22747
- const trimmed = name?.trim();
22748
- return trimmed && trimmed.length > 0 ? trimmed : void 0;
22749
- }
22750
- function extractPlanStepsFromTodoInput(input) {
22751
- const todos = input.todos;
22752
- if (!Array.isArray(todos) || todos.length === 0) {
22753
- return null;
22754
- }
22755
- return todos.filter((t) => t !== null && typeof t === "object").map((todo) => ({
22756
- step: typeof todo.content === "string" && todo.content.trim().length > 0 ? todo.content.trim() : "Task",
22757
- status: todo.status === "completed" ? "completed" : todo.status === "in_progress" ? "inProgress" : "pending"
22758
- }));
22759
- }
22760
- function readClaudeToolUseResult(message) {
22761
- if (message.type !== "user") {
22762
- return void 0;
22763
- }
22764
- const result = message.tool_use_result;
22765
- return result !== null && typeof result === "object" && !Array.isArray(result) ? result : void 0;
22766
- }
22767
- function extractExitPlanModePlan(value) {
22768
- if (!value || typeof value !== "object") {
22769
- return void 0;
22770
- }
22771
- const record2 = value;
22772
- return typeof record2.plan === "string" && record2.plan.trim().length > 0 ? record2.plan.trim() : void 0;
22773
- }
22774
- function exitPlanCaptureKey(input) {
22775
- return input.toolUseId && input.toolUseId.length > 0 ? `tool:${input.toolUseId}` : `plan:${input.planMarkdown}`;
22776
- }
22777
- function tryParseJsonRecord(value) {
22778
- try {
22779
- const parsed = JSON.parse(value);
22780
- return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
22781
- } catch {
22782
- return void 0;
22783
- }
22784
- }
22785
- function toolInputFingerprint(input) {
22786
- return encodeJsonStringForDiagnostics(input);
22787
- }
22788
- function toolResultBlocksFromUserMessage(message) {
22789
- if (message.type !== "user") {
22790
- return [];
22791
- }
22792
- const content = message.message?.content;
22793
- if (!Array.isArray(content)) {
22794
- return [];
22795
- }
22796
- const blocks = [];
22797
- for (const entry of content) {
22798
- if (!entry || typeof entry !== "object") {
22799
- continue;
22800
- }
22801
- const block = entry;
22802
- if (block.type !== "tool_result") {
22803
- continue;
22804
- }
22805
- const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : void 0;
22806
- if (!toolUseId) {
22807
- continue;
22808
- }
22809
- blocks.push({
22810
- toolUseId,
22811
- block,
22812
- text: extractTextContent(block.content),
22813
- isError: block.is_error === true
22814
- });
22815
- }
22816
- return blocks;
22817
- }
22818
-
22819
22422
  // src/sdkMessage.ts
22820
22423
  function hasDurableClaudeSessionId(message) {
22821
22424
  if (message.type !== "system") {
@@ -23328,30 +22931,300 @@ var claudeFailureCategory = (signals) => {
23328
22931
  default:
23329
22932
  break;
23330
22933
  }
23331
- if (!namesNoReason(signals)) return void 0;
23332
- const status = signals.apiErrorStatus ?? signals.retryErrorStatus;
23333
- if (signals.assistantError === "authentication_failed" || signals.assistantError === "oauth_org_not_allowed" || status === 401 || status === 403) {
23334
- return "auth";
22934
+ if (!namesNoReason(signals)) return void 0;
22935
+ const status = signals.apiErrorStatus ?? signals.retryErrorStatus;
22936
+ if (signals.assistantError === "authentication_failed" || signals.assistantError === "oauth_org_not_allowed" || status === 401 || status === 403) {
22937
+ return "auth";
22938
+ }
22939
+ if (status === 529 || signals.structuredErrorType === "overloaded_error" || signals.assistantError === "overloaded" || signals.assistantError === "model_not_found") {
22940
+ return "model-unavailable";
22941
+ }
22942
+ if (signals.assistantError === "billing_error") return "quota";
22943
+ if (signals.assistantError === "rate_limit" || status === 429) {
22944
+ return signals.quotaWindowRejected === true ? "quota" : "rate-limit";
22945
+ }
22946
+ if (status === 524) return "transport";
22947
+ if (signals.establishedStreamExit === true) return "process-exit";
22948
+ return void 0;
22949
+ };
22950
+ var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
22951
+ var claudeStructuredErrorType = (value) => {
22952
+ if (typeof value !== "object" || value === null) return void 0;
22953
+ const error = value.error;
22954
+ if (typeof error !== "object" || error === null) return void 0;
22955
+ const type4 = error.type;
22956
+ return typeof type4 === "string" ? type4 : void 0;
22957
+ };
22958
+
22959
+ // ../../packages/ycodium-tool-label/src/toolLabel.ts
22960
+ var DETAIL_MAX_CHARS = 200;
22961
+ var LABEL_TEXT_MAX_CHARS = 400;
22962
+ var SUMMARY_KEYS = [
22963
+ "description",
22964
+ "title",
22965
+ "query",
22966
+ "pattern",
22967
+ "url",
22968
+ "command",
22969
+ "cmd",
22970
+ "prompt",
22971
+ "name",
22972
+ "path"
22973
+ ];
22974
+ var PATH_KEYS = ["file_path", "notebook_path"];
22975
+ function asTrimmedString(value) {
22976
+ if (typeof value !== "string") {
22977
+ return void 0;
22978
+ }
22979
+ const trimmed = value.trim();
22980
+ return trimmed.length > 0 ? trimmed : void 0;
22981
+ }
22982
+ function asPositiveInt(value) {
22983
+ return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : void 0;
22984
+ }
22985
+ function replacementDiffStat(input, budget) {
22986
+ if (input.replace_all === true) return void 0;
22987
+ const oldText = input.old_string ?? input.oldText;
22988
+ const newText = input.new_string ?? input.newText;
22989
+ if (typeof oldText !== "string" || typeof newText !== "string") return void 0;
22990
+ budget.characters -= oldText.length + newText.length;
22991
+ if (budget.characters < 0) return void 0;
22992
+ const before = oldText.match(/[^\n]*\n|[^\n]+$/gu) ?? [];
22993
+ const after = newText.match(/[^\n]*\n|[^\n]+$/gu) ?? [];
22994
+ let start = 0;
22995
+ let beforeEnd = before.length;
22996
+ let afterEnd = after.length;
22997
+ while (start < beforeEnd && start < afterEnd && before[start] === after[start]) start += 1;
22998
+ while (beforeEnd > start && afterEnd > start && before[beforeEnd - 1] === after[afterEnd - 1]) {
22999
+ beforeEnd -= 1;
23000
+ afterEnd -= 1;
23001
+ }
23002
+ const deleted = beforeEnd - start;
23003
+ const added = afterEnd - start;
23004
+ budget.cells -= deleted * added;
23005
+ if (budget.cells < 0) return void 0;
23006
+ const lengths = new Uint32Array(added + 1);
23007
+ for (let i = start; i < beforeEnd; i += 1) {
23008
+ let diagonal = 0;
23009
+ for (let j3 = 1; j3 <= added; j3 += 1) {
23010
+ const previous = lengths[j3] ?? 0;
23011
+ lengths[j3] = before[i] === after[start + j3 - 1] ? diagonal + 1 : Math.max(previous, lengths[j3 - 1] ?? 0);
23012
+ diagonal = previous;
23013
+ }
23014
+ }
23015
+ const shared = lengths[added] ?? 0;
23016
+ return { additions: added - shared, deletions: deleted - shared };
23017
+ }
23018
+ function inputDiffStat(input) {
23019
+ const budget = { characters: 2e5, cells: 25e4 };
23020
+ if (!Array.isArray(input.edits)) return replacementDiffStat(input, budget);
23021
+ if (input.edits.length === 0 || input.edits.length > 100 || input.replace_all === true)
23022
+ return void 0;
23023
+ let additions = 0;
23024
+ let deletions = 0;
23025
+ for (const edit of input.edits) {
23026
+ if (edit === null || typeof edit !== "object" || Array.isArray(edit)) return void 0;
23027
+ const stat5 = replacementDiffStat(edit, budget);
23028
+ if (!stat5) return void 0;
23029
+ additions += stat5.additions;
23030
+ deletions += stat5.deletions;
23031
+ }
23032
+ return { additions, deletions };
23033
+ }
23034
+ function collapse(value, max) {
23035
+ const collapsed = value.replace(/\s+/gu, " ").trim();
23036
+ return collapsed.length <= max ? collapsed : `${collapsed.slice(0, max - 1).trimEnd()}\u2026`;
23037
+ }
23038
+ function displayToolName(toolName) {
23039
+ const trimmed = toolName.trim();
23040
+ if (!trimmed.startsWith("mcp__")) {
23041
+ return trimmed;
23042
+ }
23043
+ const rest = trimmed.slice("mcp__".length).replaceAll("__", " ").trim();
23044
+ return rest.length > 0 ? rest : trimmed;
23045
+ }
23046
+ function readRangeSuffix(input) {
23047
+ const offset = asPositiveInt(input.offset);
23048
+ const limit = asPositiveInt(input.limit);
23049
+ if (offset !== void 0 && limit !== void 0) {
23050
+ return `(lines ${offset}-${offset + limit - 1})`;
23051
+ }
23052
+ if (offset !== void 0) {
23053
+ return `(from line ${offset})`;
23054
+ }
23055
+ if (limit !== void 0) {
23056
+ return `(first ${limit} lines)`;
23057
+ }
23058
+ return void 0;
23059
+ }
23060
+ function loneStringValue(input) {
23061
+ let found;
23062
+ for (const value of Object.values(input)) {
23063
+ const text2 = asTrimmedString(value);
23064
+ if (text2 === void 0) {
23065
+ continue;
23066
+ }
23067
+ if (found !== void 0) {
23068
+ return void 0;
23069
+ }
23070
+ found = text2;
23071
+ }
23072
+ return found;
23073
+ }
23074
+ function compactJson(input) {
23075
+ let serialized;
23076
+ try {
23077
+ serialized = JSON.stringify(input);
23078
+ } catch {
23079
+ return void 0;
23080
+ }
23081
+ if (!serialized || serialized === "{}" || serialized === "[]") {
23082
+ return void 0;
23083
+ }
23084
+ return collapse(serialized, DETAIL_MAX_CHARS);
23085
+ }
23086
+ function formatToolLabel(toolName, input) {
23087
+ const name = displayToolName(toolName);
23088
+ const diffStat = inputDiffStat(input);
23089
+ if (name.endsWith("visualize_visualize") && typeof input.fragment === "string") {
23090
+ const { fragment: _fragment, ...rest } = input;
23091
+ return formatToolLabel(toolName, rest);
23092
+ }
23093
+ for (const key of PATH_KEYS) {
23094
+ const path = asTrimmedString(input[key]);
23095
+ if (path === void 0) {
23096
+ continue;
23097
+ }
23098
+ const suffix = readRangeSuffix(input);
23099
+ return {
23100
+ name,
23101
+ path,
23102
+ ...suffix ? { detail: suffix } : {},
23103
+ ...diffStat ? { diffStat } : {},
23104
+ descriptive: true
23105
+ };
23106
+ }
23107
+ for (const key of SUMMARY_KEYS) {
23108
+ const value = asTrimmedString(input[key]);
23109
+ if (value !== void 0) {
23110
+ const detail = collapse(value, DETAIL_MAX_CHARS);
23111
+ const scope = key === "pattern" ? asTrimmedString(input.path) : void 0;
23112
+ return { name, ...scope ? { path: scope } : {}, detail, descriptive: true };
23113
+ }
23114
+ }
23115
+ const lone = loneStringValue(input);
23116
+ if (lone !== void 0) {
23117
+ return { name, detail: collapse(lone, DETAIL_MAX_CHARS), descriptive: true };
23118
+ }
23119
+ const compact = compactJson(input);
23120
+ return { name, ...compact ? { detail: compact } : {}, descriptive: false };
23121
+ }
23122
+ function formatToolLabelText(label) {
23123
+ const joined = [label.name, label.path, label.detail].filter((part) => part).join(" ");
23124
+ return joined.length <= LABEL_TEXT_MAX_CHARS ? joined : `${joined.slice(0, LABEL_TEXT_MAX_CHARS - 1).trimEnd()}\u2026`;
23125
+ }
23126
+
23127
+ // src/toolClassify.ts
23128
+ function classifyToolItemType(toolName) {
23129
+ const normalized = toolName.toLowerCase();
23130
+ if (normalized.startsWith("mcp__")) {
23131
+ return "mcp_tool_call";
23335
23132
  }
23336
- if (status === 529 || signals.structuredErrorType === "overloaded_error" || signals.assistantError === "overloaded" || signals.assistantError === "model_not_found") {
23337
- return "model-unavailable";
23133
+ if (normalized.includes("agent")) {
23134
+ return "collab_agent_tool_call";
23338
23135
  }
23339
- if (signals.assistantError === "billing_error") return "quota";
23340
- if (signals.assistantError === "rate_limit" || status === 429) {
23341
- return signals.quotaWindowRejected === true ? "quota" : "rate-limit";
23136
+ if (normalized === "task" || normalized === "agent" || normalized.includes("subagent") || normalized.includes("sub-agent")) {
23137
+ return "collab_agent_tool_call";
23342
23138
  }
23343
- if (status === 524) return "transport";
23344
- if (signals.establishedStreamExit === true) return "process-exit";
23345
- return void 0;
23346
- };
23347
- var failureCategoryField = (category) => category === void 0 ? {} : { failureCategory: category };
23348
- var claudeStructuredErrorType = (value) => {
23349
- if (typeof value !== "object" || value === null) return void 0;
23350
- const error = value.error;
23351
- if (typeof error !== "object" || error === null) return void 0;
23352
- const type4 = error.type;
23353
- return typeof type4 === "string" ? type4 : void 0;
23354
- };
23139
+ if (normalized.includes("bash") || normalized.includes("command") || normalized.includes("shell") || normalized.includes("terminal")) {
23140
+ return "command_execution";
23141
+ }
23142
+ if (normalized.includes("edit") || normalized.includes("write") || normalized.includes("file") || normalized.includes("patch") || normalized.includes("replace") || normalized.includes("create") || normalized.includes("delete")) {
23143
+ return "file_change";
23144
+ }
23145
+ if (normalized.includes("mcp")) {
23146
+ return "mcp_tool_call";
23147
+ }
23148
+ if (normalized.includes("websearch") || normalized.includes("web search")) {
23149
+ return "web_search";
23150
+ }
23151
+ if (normalized.includes("image")) {
23152
+ return "image_view";
23153
+ }
23154
+ return "dynamic_tool_call";
23155
+ }
23156
+ function isReadOnlyToolName(toolName) {
23157
+ const normalized = toolName.toLowerCase();
23158
+ return normalized === "read" || normalized.includes("read file") || normalized.includes("view") || normalized.includes("grep") || normalized.includes("glob") || normalized.includes("search");
23159
+ }
23160
+ function classifyRequestType(toolName) {
23161
+ const normalized = toolName.toLowerCase();
23162
+ if (normalized.startsWith("mcp__") || normalized.includes("mcp")) {
23163
+ return "mcp_tool_approval";
23164
+ }
23165
+ if (normalized.includes("skill")) {
23166
+ return "skill_approval";
23167
+ }
23168
+ if (normalized.includes("webfetch") || normalized.includes("web fetch")) {
23169
+ return "web_fetch_approval";
23170
+ }
23171
+ if (normalized.includes("websearch") || normalized.includes("web search")) {
23172
+ return "web_search_approval";
23173
+ }
23174
+ if (isReadOnlyToolName(toolName)) {
23175
+ return "file_read_approval";
23176
+ }
23177
+ const itemType = classifyToolItemType(toolName);
23178
+ return itemType === "command_execution" ? "command_execution_approval" : itemType === "file_change" ? "file_change_approval" : "dynamic_tool_call";
23179
+ }
23180
+ function isTodoTool(toolName) {
23181
+ return toolName.toLowerCase().includes("todowrite");
23182
+ }
23183
+ function isClaudeTaskTool(toolName) {
23184
+ return toolName === "TaskCreate" || toolName === "TaskUpdate" || toolName === "TaskList";
23185
+ }
23186
+ function summarizeToolRequest(toolName, input) {
23187
+ const itemType = classifyToolItemType(toolName);
23188
+ if (itemType === "collab_agent_tool_call") {
23189
+ const description = typeof input.description === "string" ? input.description.trim() : void 0;
23190
+ const prompt = typeof input.prompt === "string" ? input.prompt.trim() : void 0;
23191
+ const label = description || (prompt ? prompt.slice(0, 200) : void 0);
23192
+ if (label) {
23193
+ return label;
23194
+ }
23195
+ }
23196
+ return formatToolLabelText(formatToolLabel(toolName, input));
23197
+ }
23198
+ function titleForTool(itemType) {
23199
+ switch (itemType) {
23200
+ case "command_execution":
23201
+ return "Command run";
23202
+ case "file_change":
23203
+ return "File change";
23204
+ case "mcp_tool_call":
23205
+ return "MCP tool call";
23206
+ case "collab_agent_tool_call":
23207
+ return "Subagent task";
23208
+ case "web_search":
23209
+ return "Web search";
23210
+ case "image_view":
23211
+ return "Image view";
23212
+ case "dynamic_tool_call":
23213
+ return "Tool call";
23214
+ default:
23215
+ return "Item";
23216
+ }
23217
+ }
23218
+ function toolResultStreamKind(itemType) {
23219
+ switch (itemType) {
23220
+ case "command_execution":
23221
+ return "command_output";
23222
+ case "file_change":
23223
+ return "file_change_output";
23224
+ default:
23225
+ return void 0;
23226
+ }
23227
+ }
23355
23228
 
23356
23229
  // src/taskProgress.ts
23357
23230
  function claudeTaskRosterKind(input) {
@@ -23595,6 +23468,133 @@ function workflowAgentStatus(entry) {
23595
23468
  }
23596
23469
  }
23597
23470
 
23471
+ // src/toolPayload.ts
23472
+ function fileChangesFromClaudeToolInput(toolName, input) {
23473
+ const path = asStringField(input, "file_path") ?? asStringField(input, "notebook_path");
23474
+ if (!path || path.trim().length === 0) {
23475
+ return void 0;
23476
+ }
23477
+ const content = asStringField(input, "content") ?? asStringField(input, "new_source");
23478
+ if (content !== void 0) {
23479
+ return [{ path, changeKind: "add", content: { kind: "replace", newText: content } }];
23480
+ }
23481
+ const edits = Array.isArray(input.edits) ? input.edits : void 0;
23482
+ if (edits) {
23483
+ const changes = edits.flatMap((entry) => {
23484
+ if (entry === null || typeof entry !== "object") {
23485
+ return [];
23486
+ }
23487
+ const edit = entry;
23488
+ const newText = asStringField(edit, "new_string");
23489
+ if (newText === void 0) {
23490
+ return [];
23491
+ }
23492
+ const oldText = asStringField(edit, "old_string");
23493
+ return [
23494
+ {
23495
+ path,
23496
+ changeKind: "modify",
23497
+ content: {
23498
+ kind: "replace",
23499
+ ...oldText !== void 0 ? { oldText } : {},
23500
+ newText
23501
+ }
23502
+ }
23503
+ ];
23504
+ });
23505
+ return changes.length > 0 ? changes : void 0;
23506
+ }
23507
+ const newString = asStringField(input, "new_string");
23508
+ if (newString !== void 0) {
23509
+ const oldString = asStringField(input, "old_string");
23510
+ return [
23511
+ {
23512
+ path,
23513
+ changeKind: "modify",
23514
+ content: {
23515
+ kind: "replace",
23516
+ ...oldString !== void 0 ? { oldText: oldString } : {},
23517
+ newText: newString
23518
+ }
23519
+ }
23520
+ ];
23521
+ }
23522
+ return classifyToolItemType(toolName) === "file_change" ? [{ path, omitted: "unavailable" }] : void 0;
23523
+ }
23524
+ function skillNameFromClaudeToolInput(input) {
23525
+ const name = asStringField(input, "name") ?? asStringField(input, "skill") ?? asStringField(input, "command");
23526
+ const trimmed = name?.trim();
23527
+ return trimmed && trimmed.length > 0 ? trimmed : void 0;
23528
+ }
23529
+ function extractPlanStepsFromTodoInput(input) {
23530
+ const todos = input.todos;
23531
+ if (!Array.isArray(todos) || todos.length === 0) {
23532
+ return null;
23533
+ }
23534
+ return todos.filter((t) => t !== null && typeof t === "object").map((todo) => ({
23535
+ step: typeof todo.content === "string" && todo.content.trim().length > 0 ? todo.content.trim() : "Task",
23536
+ status: todo.status === "completed" ? "completed" : todo.status === "in_progress" ? "inProgress" : "pending"
23537
+ }));
23538
+ }
23539
+ function readClaudeToolUseResult(message) {
23540
+ if (message.type !== "user") {
23541
+ return void 0;
23542
+ }
23543
+ const result = message.tool_use_result;
23544
+ return result !== null && typeof result === "object" && !Array.isArray(result) ? result : void 0;
23545
+ }
23546
+ function extractExitPlanModePlan(value) {
23547
+ if (!value || typeof value !== "object") {
23548
+ return void 0;
23549
+ }
23550
+ const record2 = value;
23551
+ return typeof record2.plan === "string" && record2.plan.trim().length > 0 ? record2.plan.trim() : void 0;
23552
+ }
23553
+ function exitPlanCaptureKey(input) {
23554
+ return input.toolUseId && input.toolUseId.length > 0 ? `tool:${input.toolUseId}` : `plan:${input.planMarkdown}`;
23555
+ }
23556
+ function tryParseJsonRecord(value) {
23557
+ try {
23558
+ const parsed = JSON.parse(value);
23559
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
23560
+ } catch {
23561
+ return void 0;
23562
+ }
23563
+ }
23564
+ function toolInputFingerprint(input) {
23565
+ return encodeJsonStringForDiagnostics(input);
23566
+ }
23567
+ function toolResultBlocksFromUserMessage(message) {
23568
+ if (message.type !== "user") {
23569
+ return [];
23570
+ }
23571
+ const content = message.message?.content;
23572
+ if (!Array.isArray(content)) {
23573
+ return [];
23574
+ }
23575
+ const blocks = [];
23576
+ for (const entry of content) {
23577
+ if (!entry || typeof entry !== "object") {
23578
+ continue;
23579
+ }
23580
+ const block = entry;
23581
+ if (block.type !== "tool_result") {
23582
+ continue;
23583
+ }
23584
+ const toolUseId = typeof block.tool_use_id === "string" ? block.tool_use_id : void 0;
23585
+ if (!toolUseId) {
23586
+ continue;
23587
+ }
23588
+ blocks.push({
23589
+ toolUseId,
23590
+ block,
23591
+ text: extractTextContent(block.content),
23592
+ isError: block.is_error === true
23593
+ });
23594
+ }
23595
+ return blocks;
23596
+ }
23597
+
23598
23598
  // src/adapter/emitters.ts
23599
23599
  var makeEmitters = (emitter) => {
23600
23600
  const { nowIso, makeEventStamp, eventHeader, offerRuntimeEvent } = emitter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-claude",
3
- "version": "0.2.5265",
3
+ "version": "0.2.5280",
4
4
  "description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
5
5
  "keywords": [
6
6
  "ycodium",
@@ -24,13 +24,13 @@
24
24
  "@types/node": "24.12.4",
25
25
  "esbuild": "0.28.1",
26
26
  "vite-plus": "0.2.2",
27
- "ycodium-credential-account": "0.0.0",
28
- "@ycodium-ai/plugin-api": "0.2.5265",
27
+ "@ycodium-ai/plugin-api": "0.2.5280",
29
28
  "ycodium-composer-tokens": "0.0.0",
30
29
  "ycodium-duration-format": "0.0.0",
31
- "ycodium-instance-config": "0.0.0",
32
- "ycodium-jsonl-stream": "0.0.0",
30
+ "ycodium-credential-account": "0.0.0",
33
31
  "ycodium-executor-testing": "0.0.0",
32
+ "ycodium-jsonl-stream": "0.0.0",
33
+ "ycodium-instance-config": "0.0.0",
34
34
  "ycodium-text-generation": "0.0.0",
35
35
  "ycodium-tool-label": "0.0.0",
36
36
  "ycodium-workspace-path": "0.0.0"