@super-one/cli 0.50.4-alpha → 0.50.5-alpha

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 (3) hide show
  1. package/MANIFEST.json +2 -2
  2. package/lib/cli.mjs +389 -275
  3. package/package.json +1 -1
package/MANIFEST.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@super-one/cli",
3
- "version": "0.50.4-alpha",
3
+ "version": "0.50.5-alpha",
4
4
  "kind": "npm",
5
5
  "minNodeMajor": 20,
6
- "builtAt": "2026-08-07T04:11:13.179Z"
6
+ "builtAt": "2026-08-07T07:57:09.216Z"
7
7
  }
package/lib/cli.mjs CHANGED
@@ -40141,6 +40141,265 @@ var init_slash_filter = __esm({
40141
40141
  }
40142
40142
  });
40143
40143
 
40144
+ // ../../packages/shared/src/tool-ui.ts
40145
+ function normalizeToolIdKey(id) {
40146
+ return id.trim().toLowerCase().replace(/[\s-]+/g, "_");
40147
+ }
40148
+ function uiToolNameFromId(id) {
40149
+ if (!id || typeof id !== "string") return null;
40150
+ if (/[\s`/:]/.test(id) && !TOOL_ID_TO_UI_NAME[normalizeToolIdKey(id)]) return null;
40151
+ const key = normalizeToolIdKey(id);
40152
+ return TOOL_ID_TO_UI_NAME[key] ?? null;
40153
+ }
40154
+ function bytesOrStringToText(value) {
40155
+ if (typeof value === "string") return value;
40156
+ if (Array.isArray(value) && value.length > 0 && value.every((n) => typeof n === "number")) {
40157
+ try {
40158
+ return new TextDecoder("utf-8", { fatal: false }).decode(Uint8Array.from(value));
40159
+ } catch {
40160
+ return "";
40161
+ }
40162
+ }
40163
+ return "";
40164
+ }
40165
+ function formatSearchToolPayload(obj) {
40166
+ let data = obj;
40167
+ if (typeof obj.content === "string" && obj.content.trim()) {
40168
+ try {
40169
+ data = JSON.parse(obj.content);
40170
+ } catch {
40171
+ if (!obj.results) return obj.content;
40172
+ }
40173
+ }
40174
+ if (!data || typeof data !== "object") return null;
40175
+ const root = data;
40176
+ const results = root.results;
40177
+ if (!Array.isArray(results)) {
40178
+ if (typeof root.content === "string") return root.content;
40179
+ return null;
40180
+ }
40181
+ const lines = [];
40182
+ const count = typeof obj.result_count === "number" ? obj.result_count : results.length;
40183
+ lines.push(`Found ${count} tool${count === 1 ? "" : "s"}`);
40184
+ for (const entry of results) {
40185
+ if (!entry || typeof entry !== "object") continue;
40186
+ const group = entry;
40187
+ const server = typeof group.server === "string" ? group.server : "MCP";
40188
+ lines.push("");
40189
+ lines.push(`[${server}]`);
40190
+ const tools = group.tools;
40191
+ if (!Array.isArray(tools)) continue;
40192
+ for (const tool of tools) {
40193
+ if (!tool || typeof tool !== "object") continue;
40194
+ const t = tool;
40195
+ const name = typeof t.tool_name === "string" ? t.tool_name : typeof t.name === "string" ? t.name : "tool";
40196
+ const desc = typeof t.description === "string" ? t.description : "";
40197
+ const score = typeof t.score === "number" ? ` \xB7 ${t.score.toFixed(1)}` : "";
40198
+ lines.push(desc ? ` ${name}${score} \u2014 ${desc}` : ` ${name}${score}`);
40199
+ }
40200
+ }
40201
+ if (typeof root.note === "string" && root.note.trim()) {
40202
+ lines.push("");
40203
+ lines.push(root.note);
40204
+ }
40205
+ return lines.join("\n").trim() || null;
40206
+ }
40207
+ function isAgentOutputEnvelope(obj) {
40208
+ const t = obj.type;
40209
+ return t === "MCP" || t === "ListDir" || t === "list_dir" || t === "LS" || t === "Todo" || t === "SearchTool" || t === "GrepSearch" || t === "grep" || obj.TodosUpdated != null || obj.Content != null && typeof obj.Content === "object" || Array.isArray(obj.results) || obj.action != null && typeof obj.action === "object";
40210
+ }
40211
+ function formatAgentToolOutput(raw) {
40212
+ if (raw == null) return "";
40213
+ if (typeof raw === "string") {
40214
+ const trimmed = raw.trim();
40215
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
40216
+ try {
40217
+ const parsed = JSON.parse(trimmed);
40218
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && isAgentOutputEnvelope(parsed)) {
40219
+ return formatAgentToolOutput(parsed);
40220
+ }
40221
+ return raw;
40222
+ } catch {
40223
+ return raw;
40224
+ }
40225
+ }
40226
+ return raw;
40227
+ }
40228
+ if (typeof raw !== "object") return String(raw);
40229
+ const obj = raw;
40230
+ if (obj.type === "MCP" && obj.output != null) {
40231
+ if (typeof obj.output === "string") return obj.output;
40232
+ if (typeof obj.output === "object") {
40233
+ const values = Object.values(obj.output);
40234
+ if (values.length === 1 && typeof values[0] === "string") return values[0];
40235
+ }
40236
+ }
40237
+ const listContent = obj.Content ?? obj.content;
40238
+ if ((obj.type === "ListDir" || obj.type === "list_dir" || obj.type === "LS") && listContent && typeof listContent === "object") {
40239
+ const body = listContent;
40240
+ if (typeof body.content === "string" && body.content.trim()) return body.content;
40241
+ if (typeof body.text === "string" && body.text.trim()) return body.text;
40242
+ }
40243
+ if ((obj.type === "ListDir" || obj.type === "list_dir") && typeof obj.Content === "string") {
40244
+ return obj.Content;
40245
+ }
40246
+ if (typeof obj.content === "string" && obj.content.includes("\n") && (obj.type === "ListDir" || obj.absolute_root_path != null)) {
40247
+ return obj.content;
40248
+ }
40249
+ if (obj.type === "Todo" || obj.TodosUpdated != null) {
40250
+ const todos = obj.TodosUpdated;
40251
+ if (todos && typeof todos === "object") {
40252
+ const t = todos;
40253
+ if (typeof t.summary_for_prompt === "string" && t.summary_for_prompt.trim()) return t.summary_for_prompt;
40254
+ if (typeof t.summary === "string" && t.summary.trim()) return t.summary;
40255
+ }
40256
+ }
40257
+ if (obj.type === "SearchTool" || Array.isArray(obj.results) || obj.result_count != null && (obj.content != null || obj.results != null)) {
40258
+ const formatted = formatSearchToolPayload(obj);
40259
+ if (formatted) return formatted;
40260
+ }
40261
+ if (obj.type === "GrepSearch" || obj.type === "grep" || Array.isArray(obj.stdout)) {
40262
+ const text = bytesOrStringToText(obj.stdout ?? obj.content ?? obj.output);
40263
+ if (text) return text;
40264
+ }
40265
+ const action = obj.action;
40266
+ if (action && typeof action === "object") {
40267
+ const a = action;
40268
+ if (a.type === "search") {
40269
+ const lines = [];
40270
+ if (typeof a.query === "string") lines.push(`Query: ${a.query}`);
40271
+ const sources = a.sources;
40272
+ if (Array.isArray(sources)) {
40273
+ for (const s2 of sources) {
40274
+ if (s2 && typeof s2 === "object") {
40275
+ const src = s2;
40276
+ if (typeof src.url === "string") lines.push(src.url);
40277
+ else if (typeof src.title === "string") lines.push(src.title);
40278
+ }
40279
+ }
40280
+ }
40281
+ if (typeof a.result === "string") lines.push(a.result);
40282
+ if (typeof a.snippet === "string") lines.push(a.snippet);
40283
+ if (lines.length > 0) return lines.join("\n");
40284
+ }
40285
+ }
40286
+ if (listContent && typeof listContent === "object") {
40287
+ const body = listContent;
40288
+ for (const key of ["content", "text", "output", "result"]) {
40289
+ if (typeof body[key] === "string" && body[key].trim()) {
40290
+ if (obj.type === "ListDir" || obj.type === "list_dir" || obj.type === "LS" || body.absolute_root_path != null || /^[\s-]*\//.test(body[key])) {
40291
+ return body[key];
40292
+ }
40293
+ }
40294
+ }
40295
+ }
40296
+ if (typeof obj.run_id === "string" || typeof obj.runId === "string") {
40297
+ try {
40298
+ return JSON.stringify(raw);
40299
+ } catch {
40300
+ return String(raw);
40301
+ }
40302
+ }
40303
+ for (const key of ["result", "output", "text", "stdout", "message", "summary"]) {
40304
+ const v2 = obj[key];
40305
+ if (typeof v2 === "string" && v2.trim()) return v2;
40306
+ }
40307
+ if (listContent && typeof listContent === "object") {
40308
+ const body = listContent;
40309
+ for (const key of ["content", "text", "output", "result"]) {
40310
+ if (typeof body[key] === "string" && body[key].trim()) return body[key];
40311
+ }
40312
+ }
40313
+ try {
40314
+ return JSON.stringify(raw, null, 2);
40315
+ } catch {
40316
+ return String(raw);
40317
+ }
40318
+ }
40319
+ var TOOL_ID_TO_UI_NAME;
40320
+ var init_tool_ui = __esm({
40321
+ "../../packages/shared/src/tool-ui.ts"() {
40322
+ "use strict";
40323
+ TOOL_ID_TO_UI_NAME = {
40324
+ read: "Read",
40325
+ read_file: "Read",
40326
+ readfile: "Read",
40327
+ edit: "Edit",
40328
+ search_replace: "Edit",
40329
+ str_replace: "Edit",
40330
+ apply_patch: "Edit",
40331
+ write: "Write",
40332
+ write_file: "Write",
40333
+ writefile: "Write",
40334
+ create_file: "Write",
40335
+ bash: "Bash",
40336
+ shell: "Bash",
40337
+ run_terminal_command: "Bash",
40338
+ run_terminal_cmd: "Bash",
40339
+ run_command: "Bash",
40340
+ execute: "Bash",
40341
+ command: "Bash",
40342
+ grep: "Grep",
40343
+ search: "Grep",
40344
+ ripgrep: "Grep",
40345
+ glob: "Glob",
40346
+ find_files: "Glob",
40347
+ list_dir: "LS",
40348
+ listdir: "LS",
40349
+ ls: "LS",
40350
+ web_fetch: "WebFetch",
40351
+ webfetch: "WebFetch",
40352
+ fetch: "WebFetch",
40353
+ open_page: "WebFetch",
40354
+ open_page_with_find: "WebFetch",
40355
+ web_search: "WebSearch",
40356
+ websearch: "WebSearch",
40357
+ todo_write: "TodoWrite",
40358
+ todowrite: "TodoWrite",
40359
+ todo: "TodoWrite",
40360
+ search_tool: "SearchTools",
40361
+ searchtool: "SearchTools",
40362
+ tool_search: "SearchTools",
40363
+ toolsearch: "SearchTools",
40364
+ use_tool: "UseTool",
40365
+ usetool: "UseTool",
40366
+ call_tool: "UseTool",
40367
+ spawn_subagent: "Agent",
40368
+ spawn_agent: "Agent",
40369
+ agent: "Agent",
40370
+ task: "Task",
40371
+ workflow: "Workflow",
40372
+ run_workflow: "Workflow",
40373
+ memory_search: "MemorySearch",
40374
+ memorysearch: "MemorySearch",
40375
+ search_memory: "MemorySearch",
40376
+ ask_user_question: "AskUserQuestion",
40377
+ askuserquestion: "AskUserQuestion",
40378
+ get_task_output: "TaskOutput",
40379
+ get_command_or_subagent_output: "TaskOutput",
40380
+ get_terminal_command_output: "TaskOutput",
40381
+ wait_tasks: "TaskOutput",
40382
+ wait_commands_or_subagents: "TaskOutput",
40383
+ kill_task: "KillTask",
40384
+ kill_command_or_subagent: "KillTask",
40385
+ kill_terminal_command: "KillTask",
40386
+ enter_plan_mode: "EnterPlanMode",
40387
+ exit_plan_mode: "ExitPlanMode",
40388
+ skill: "Skill",
40389
+ image_gen: "ImageGen",
40390
+ image_edit: "ImageEdit",
40391
+ image_to_video: "ImageToVideo",
40392
+ reference_to_video: "ReferenceToVideo",
40393
+ video_gen: "VideoGen",
40394
+ monitor: "Monitor",
40395
+ update_goal: "UpdateGoal",
40396
+ scheduler_create: "SchedulerCreate",
40397
+ scheduler_delete: "SchedulerDelete",
40398
+ scheduler_list: "SchedulerList"
40399
+ };
40400
+ }
40401
+ });
40402
+
40144
40403
  // ../../packages/acp/src/tool-normalization.ts
40145
40404
  function textFromContent(content) {
40146
40405
  if (!content) return "";
@@ -40209,14 +40468,8 @@ function extractFilePath(tool, raw, diffs) {
40209
40468
  "to"
40210
40469
  ]);
40211
40470
  }
40212
- function normalizeToolId(id) {
40213
- return id.trim().toLowerCase().replace(/[\s-]+/g, "_");
40214
- }
40215
40471
  function nameFromToolId(id) {
40216
- if (!id || typeof id !== "string") return null;
40217
- if (/[\s`/:]/.test(id) && !TOOL_ID_TO_NAME[normalizeToolId(id)]) return null;
40218
- const key = normalizeToolId(id);
40219
- return TOOL_ID_TO_NAME[key] ?? null;
40472
+ return uiToolNameFromId(id);
40220
40473
  }
40221
40474
  function nameFromVariant(raw) {
40222
40475
  const variant = pickString(raw, ["variant", "tool", "name", "toolName", "tool_name"]);
@@ -40492,12 +40745,17 @@ function normalizeInput(toolName, kind, raw, filePath, diffs, terminalCommand) {
40492
40745
  if (raw.limit != null) out.limit = raw.limit;
40493
40746
  return Object.keys(out).length > 0 ? out : { ...raw };
40494
40747
  }
40748
+ case "Agent":
40495
40749
  case "Task": {
40496
40750
  const out = {};
40497
40751
  const desc = pickString(raw, ["description", "prompt", "name", "task", "objective"]);
40498
40752
  if (desc) out.description = desc;
40499
40753
  const sub = pickString(raw, ["subagent_type", "agent_type", "agent", "type"]);
40500
40754
  if (sub) out.subagent_type = sub;
40755
+ const prompt = pickString(raw, ["prompt"]);
40756
+ if (prompt) out.prompt = prompt;
40757
+ const model = pickString(raw, ["model"]);
40758
+ if (model) out.model = model;
40501
40759
  if (raw.run_in_background === true || raw.background === true) out.run_in_background = true;
40502
40760
  return Object.keys(out).length > 0 ? out : { ...raw };
40503
40761
  }
@@ -40593,87 +40851,11 @@ function toolUseBlock(tool, opts) {
40593
40851
  toolFilePath: normalized.toolFilePath
40594
40852
  };
40595
40853
  }
40596
- var TOOL_ID_TO_NAME, GREP_NON_PATTERN_TITLES;
40854
+ var GREP_NON_PATTERN_TITLES;
40597
40855
  var init_tool_normalization = __esm({
40598
40856
  "../../packages/acp/src/tool-normalization.ts"() {
40599
40857
  "use strict";
40600
- TOOL_ID_TO_NAME = {
40601
- read: "Read",
40602
- read_file: "Read",
40603
- readfile: "Read",
40604
- edit: "Edit",
40605
- search_replace: "Edit",
40606
- str_replace: "Edit",
40607
- apply_patch: "Edit",
40608
- write: "Write",
40609
- write_file: "Write",
40610
- writefile: "Write",
40611
- create_file: "Write",
40612
- bash: "Bash",
40613
- shell: "Bash",
40614
- run_terminal_command: "Bash",
40615
- run_terminal_cmd: "Bash",
40616
- run_command: "Bash",
40617
- execute: "Bash",
40618
- command: "Bash",
40619
- grep: "Grep",
40620
- search: "Grep",
40621
- ripgrep: "Grep",
40622
- glob: "Glob",
40623
- find_files: "Glob",
40624
- list_dir: "LS",
40625
- listdir: "LS",
40626
- ls: "LS",
40627
- web_fetch: "WebFetch",
40628
- webfetch: "WebFetch",
40629
- fetch: "WebFetch",
40630
- open_page: "WebFetch",
40631
- open_page_with_find: "WebFetch",
40632
- web_search: "WebSearch",
40633
- websearch: "WebSearch",
40634
- todo_write: "TodoWrite",
40635
- todowrite: "TodoWrite",
40636
- todo: "TodoWrite",
40637
- search_tool: "SearchTools",
40638
- searchtool: "SearchTools",
40639
- tool_search: "SearchTools",
40640
- toolsearch: "SearchTools",
40641
- use_tool: "UseTool",
40642
- usetool: "UseTool",
40643
- call_tool: "UseTool",
40644
- spawn_subagent: "Task",
40645
- spawn_agent: "Task",
40646
- task: "Task",
40647
- agent: "Task",
40648
- workflow: "Workflow",
40649
- run_workflow: "Workflow",
40650
- memory_search: "MemorySearch",
40651
- memorysearch: "MemorySearch",
40652
- search_memory: "MemorySearch",
40653
- ask_user_question: "AskUserQuestion",
40654
- askuserquestion: "AskUserQuestion",
40655
- get_task_output: "TaskOutput",
40656
- get_command_or_subagent_output: "TaskOutput",
40657
- get_terminal_command_output: "TaskOutput",
40658
- wait_tasks: "TaskOutput",
40659
- wait_commands_or_subagents: "TaskOutput",
40660
- kill_task: "KillTask",
40661
- kill_command_or_subagent: "KillTask",
40662
- kill_terminal_command: "KillTask",
40663
- enter_plan_mode: "EnterPlanMode",
40664
- exit_plan_mode: "ExitPlanMode",
40665
- skill: "Skill",
40666
- image_gen: "ImageGen",
40667
- image_edit: "ImageEdit",
40668
- image_to_video: "ImageToVideo",
40669
- reference_to_video: "ReferenceToVideo",
40670
- video_gen: "VideoGen",
40671
- monitor: "Monitor",
40672
- update_goal: "UpdateGoal",
40673
- scheduler_create: "SchedulerCreate",
40674
- scheduler_delete: "SchedulerDelete",
40675
- scheduler_list: "SchedulerList"
40676
- };
40858
+ init_tool_ui();
40677
40859
  GREP_NON_PATTERN_TITLES = /* @__PURE__ */ new Set([
40678
40860
  "grep",
40679
40861
  "Grep",
@@ -40687,170 +40869,8 @@ var init_tool_normalization = __esm({
40687
40869
  });
40688
40870
 
40689
40871
  // ../../packages/acp/src/tool-result-map.ts
40690
- function bytesOrStringToText(value) {
40691
- if (typeof value === "string") return value;
40692
- if (Array.isArray(value) && value.every((n) => typeof n === "number")) {
40693
- try {
40694
- return Buffer.from(value).toString("utf8");
40695
- } catch {
40696
- return "";
40697
- }
40698
- }
40699
- return "";
40700
- }
40701
- function formatSearchToolPayload(obj) {
40702
- let data = obj;
40703
- if (typeof obj.content === "string" && obj.content.trim()) {
40704
- try {
40705
- data = JSON.parse(obj.content);
40706
- } catch {
40707
- if (!obj.results) return obj.content;
40708
- }
40709
- }
40710
- if (!data || typeof data !== "object") return null;
40711
- const root = data;
40712
- const results = root.results;
40713
- if (!Array.isArray(results)) {
40714
- if (typeof root.content === "string") return root.content;
40715
- return null;
40716
- }
40717
- const lines = [];
40718
- const count = typeof obj.result_count === "number" ? obj.result_count : results.length;
40719
- lines.push(`Found ${count} tool${count === 1 ? "" : "s"}`);
40720
- for (const entry of results) {
40721
- if (!entry || typeof entry !== "object") continue;
40722
- const group = entry;
40723
- const server = typeof group.server === "string" ? group.server : "MCP";
40724
- lines.push("");
40725
- lines.push(`[${server}]`);
40726
- const tools = group.tools;
40727
- if (!Array.isArray(tools)) continue;
40728
- for (const tool of tools) {
40729
- if (!tool || typeof tool !== "object") continue;
40730
- const t = tool;
40731
- const name = typeof t.tool_name === "string" ? t.tool_name : typeof t.name === "string" ? t.name : "tool";
40732
- const desc = typeof t.description === "string" ? t.description : "";
40733
- const score = typeof t.score === "number" ? ` \xB7 ${t.score.toFixed(1)}` : "";
40734
- lines.push(desc ? ` ${name}${score} \u2014 ${desc}` : ` ${name}${score}`);
40735
- }
40736
- }
40737
- if (typeof root.note === "string" && root.note.trim()) {
40738
- lines.push("");
40739
- lines.push(root.note);
40740
- }
40741
- return lines.join("\n").trim() || null;
40742
- }
40743
- function isAgentOutputEnvelope(obj) {
40744
- const t = obj.type;
40745
- return t === "MCP" || t === "ListDir" || t === "list_dir" || t === "LS" || t === "Todo" || t === "SearchTool" || t === "GrepSearch" || t === "grep" || obj.TodosUpdated != null || obj.Content != null && typeof obj.Content === "object" || Array.isArray(obj.results) || obj.action != null && typeof obj.action === "object";
40746
- }
40747
40872
  function formatAcpRawOutput(raw) {
40748
- if (raw == null) return "";
40749
- if (typeof raw === "string") {
40750
- const trimmed = raw.trim();
40751
- if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
40752
- try {
40753
- const parsed = JSON.parse(trimmed);
40754
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && isAgentOutputEnvelope(parsed)) {
40755
- return formatAcpRawOutput(parsed);
40756
- }
40757
- return raw;
40758
- } catch {
40759
- return raw;
40760
- }
40761
- }
40762
- return raw;
40763
- }
40764
- if (typeof raw !== "object") return String(raw);
40765
- const obj = raw;
40766
- if (obj.type === "MCP" && obj.output != null) {
40767
- if (typeof obj.output === "string") return obj.output;
40768
- if (typeof obj.output === "object") {
40769
- const values = Object.values(obj.output);
40770
- if (values.length === 1 && typeof values[0] === "string") return values[0];
40771
- }
40772
- }
40773
- const listContent = obj.Content ?? obj.content;
40774
- if ((obj.type === "ListDir" || obj.type === "list_dir" || obj.type === "LS") && listContent && typeof listContent === "object") {
40775
- const body = listContent;
40776
- if (typeof body.content === "string" && body.content.trim()) return body.content;
40777
- if (typeof body.text === "string" && body.text.trim()) return body.text;
40778
- }
40779
- if ((obj.type === "ListDir" || obj.type === "list_dir") && typeof obj.Content === "string") {
40780
- return obj.Content;
40781
- }
40782
- if (typeof obj.content === "string" && obj.content.includes("\n") && (obj.type === "ListDir" || obj.absolute_root_path != null)) {
40783
- return obj.content;
40784
- }
40785
- if (obj.type === "Todo" || obj.TodosUpdated != null) {
40786
- const todos = obj.TodosUpdated;
40787
- if (todos && typeof todos === "object") {
40788
- const t = todos;
40789
- if (typeof t.summary_for_prompt === "string" && t.summary_for_prompt.trim()) return t.summary_for_prompt;
40790
- if (typeof t.summary === "string" && t.summary.trim()) return t.summary;
40791
- }
40792
- }
40793
- if (obj.type === "SearchTool" || Array.isArray(obj.results) || obj.result_count != null && (obj.content != null || obj.results != null)) {
40794
- const formatted = formatSearchToolPayload(obj);
40795
- if (formatted) return formatted;
40796
- }
40797
- if (obj.type === "GrepSearch" || obj.type === "grep" || Array.isArray(obj.stdout)) {
40798
- const text = bytesOrStringToText(obj.stdout ?? obj.content ?? obj.output);
40799
- if (text) return text;
40800
- }
40801
- const action = obj.action;
40802
- if (action && typeof action === "object") {
40803
- const a = action;
40804
- if (a.type === "search") {
40805
- const lines = [];
40806
- if (typeof a.query === "string") lines.push(`Query: ${a.query}`);
40807
- const sources = a.sources;
40808
- if (Array.isArray(sources)) {
40809
- for (const s2 of sources) {
40810
- if (s2 && typeof s2 === "object") {
40811
- const src = s2;
40812
- if (typeof src.url === "string") lines.push(src.url);
40813
- else if (typeof src.title === "string") lines.push(src.title);
40814
- }
40815
- }
40816
- }
40817
- if (typeof a.result === "string") lines.push(a.result);
40818
- if (typeof a.snippet === "string") lines.push(a.snippet);
40819
- if (lines.length > 0) return lines.join("\n");
40820
- }
40821
- }
40822
- if (listContent && typeof listContent === "object") {
40823
- const body = listContent;
40824
- for (const key of ["content", "text", "output", "result"]) {
40825
- if (typeof body[key] === "string" && body[key].trim()) {
40826
- if (obj.type === "ListDir" || obj.type === "list_dir" || obj.type === "LS" || body.absolute_root_path != null || /^[\s-]*\//.test(body[key])) {
40827
- return body[key];
40828
- }
40829
- }
40830
- }
40831
- }
40832
- if (typeof obj.run_id === "string" || typeof obj.runId === "string") {
40833
- try {
40834
- return JSON.stringify(raw);
40835
- } catch {
40836
- return String(raw);
40837
- }
40838
- }
40839
- for (const key of ["result", "output", "text", "stdout", "message", "summary"]) {
40840
- const v2 = obj[key];
40841
- if (typeof v2 === "string" && v2.trim()) return v2;
40842
- }
40843
- if (listContent && typeof listContent === "object") {
40844
- const body = listContent;
40845
- for (const key of ["content", "text", "output", "result"]) {
40846
- if (typeof body[key] === "string" && body[key].trim()) return body[key];
40847
- }
40848
- }
40849
- try {
40850
- return JSON.stringify(raw, null, 2);
40851
- } catch {
40852
- return String(raw);
40853
- }
40873
+ return formatAgentToolOutput(raw);
40854
40874
  }
40855
40875
  function mediaGenGallerySummary(raw) {
40856
40876
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
@@ -40965,6 +40985,7 @@ var init_tool_result_map = __esm({
40965
40985
  "../../packages/acp/src/tool-result-map.ts"() {
40966
40986
  "use strict";
40967
40987
  init_capability_prompt_tags();
40988
+ init_tool_ui();
40968
40989
  init_tool_normalization();
40969
40990
  }
40970
40991
  });
@@ -40976,6 +40997,8 @@ function createXaiCorrelationState() {
40976
40997
  workflowRevision: /* @__PURE__ */ new Map(),
40977
40998
  workflowStarted: /* @__PURE__ */ new Set(),
40978
40999
  workflowOwnedSubagents: /* @__PURE__ */ new Set(),
41000
+ smokeWorkflowToolIds: /* @__PURE__ */ new Set(),
41001
+ pendingToolNamesById: /* @__PURE__ */ new Map(),
40979
41002
  subagentToolById: /* @__PURE__ */ new Map(),
40980
41003
  subagentStarted: /* @__PURE__ */ new Set(),
40981
41004
  bgTaskById: /* @__PURE__ */ new Map(),
@@ -40985,6 +41008,27 @@ function createXaiCorrelationState() {
40985
41008
  lastMessageId: null
40986
41009
  };
40987
41010
  }
41011
+ function isSubagentLaunchToolName(name) {
41012
+ if (!name) return false;
41013
+ const n = name.toLowerCase();
41014
+ return n === "agent" || n === "task" || n === "spawn_subagent" || n === "spawn_agent";
41015
+ }
41016
+ function bindSubagentToolId(state, subagentId, toolUseId, description, migrateOut) {
41017
+ if (state.workflowOwnedSubagents.has(subagentId)) return;
41018
+ const existing = state.subagentToolById.get(subagentId);
41019
+ if (existing && existing !== toolUseId) return;
41020
+ const isNew = !existing;
41021
+ if (isNew) state.subagentToolById.set(subagentId, toolUseId);
41022
+ if (isNew && state.subagentStarted.has(subagentId)) {
41023
+ migrateOut.push({
41024
+ type: "task_progress",
41025
+ taskId: subagentId,
41026
+ toolUseId,
41027
+ description: description ?? subagentId,
41028
+ usage: { totalTokens: 0, toolUses: 0, durationMs: 0 }
41029
+ });
41030
+ }
41031
+ }
40988
41032
  function asRecord7(v2) {
40989
41033
  if (!v2 || typeof v2 !== "object" || Array.isArray(v2)) return null;
40990
41034
  return v2;
@@ -41031,7 +41075,22 @@ function parseXaiSessionNotificationEnvelope(raw) {
41031
41075
  function parseXaiExtParams(raw) {
41032
41076
  return asRecord7(raw) ?? {};
41033
41077
  }
41078
+ function parsePlainTextTaskAck(text) {
41079
+ const subagentId = text.match(/subagent_id:\s*(\S+)/i)?.[1] ?? text.match(/task_ids?\s*=\s*\[\s*"([^"]+)"/i)?.[1];
41080
+ const taskId = text.match(/(?:^|\n)\s*task_id:\s*(\S+)/i)?.[1] ?? subagentId;
41081
+ const outputFile = text.match(/output_file:\s*(\S+)/i)?.[1];
41082
+ const description = text.match(/(?:^|\n)\s*description:\s*(.+)$/im)?.[1]?.trim();
41083
+ const subagentType = text.match(/(?:^|\n)\s*(?:type|subagent_type):\s*(\S+)/i)?.[1];
41084
+ return {
41085
+ ...subagentId ? { subagentId } : {},
41086
+ ...taskId ? { taskId } : {},
41087
+ ...outputFile ? { outputFile } : {},
41088
+ ...description ? { description } : {},
41089
+ ...subagentType ? { subagentType } : {}
41090
+ };
41091
+ }
41034
41092
  function noteToolCorrelationFromAgentEvents(events, state) {
41093
+ const migrate = [];
41035
41094
  for (const event of events) {
41036
41095
  if (event.type === "message_usage") {
41037
41096
  state.lastMessageId = event.messageId;
@@ -41040,32 +41099,79 @@ function noteToolCorrelationFromAgentEvents(events, state) {
41040
41099
  if (event.type !== "content_delta") continue;
41041
41100
  const d = event.delta;
41042
41101
  if (d.type === "tool_use") {
41102
+ if (d.toolUseId && d.toolName) {
41103
+ state.pendingToolNamesById.set(d.toolUseId, d.toolName);
41104
+ }
41105
+ const toolName = (d.toolName ?? "").toLowerCase();
41106
+ if ((toolName === "workflow" || toolName === "run_workflow") && d.toolUseId && isValidateOnlyToolInput(d.input)) {
41107
+ state.smokeWorkflowToolIds.add(d.toolUseId);
41108
+ }
41043
41109
  continue;
41044
41110
  }
41045
41111
  if (d.type !== "tool_result" || !d.summary) continue;
41046
41112
  const toolUseId = d.toolUseId;
41113
+ const launchName = state.pendingToolNamesById.get(toolUseId);
41114
+ const isSpawnLaunch = isSubagentLaunchToolName(launchName);
41047
41115
  const parsed = tryParseJsonObject(d.summary);
41048
- if (!parsed) continue;
41049
- const runId = strField(parsed, "run_id", "runId");
41050
- if (runId) {
41051
- state.workflowToolByRunId.set(runId, toolUseId);
41052
- }
41053
- const subagentId = strField(parsed, "subagent_id", "subagentId") ?? strField(parsed, "agent_id", "agentId") ?? strField(parsed, "task_id", "taskId");
41054
- if (subagentId && (strField(parsed, "subagent_id", "subagentId") || strField(parsed, "subagent_type", "subagentType"))) {
41055
- state.subagentToolById.set(subagentId, toolUseId);
41056
- } else if (subagentId && strField(parsed, "agent_id", "agentId") && !runId) {
41057
- state.subagentToolById.set(subagentId, toolUseId);
41058
- }
41059
- const taskId = strField(parsed, "task_id", "taskId");
41060
- if (taskId && !runId) {
41061
- const existing = state.bgTaskById.get(taskId);
41062
- state.bgTaskById.set(taskId, {
41063
- toolUseId: toolUseId ?? existing?.toolUseId,
41064
- description: existing?.description ?? strField(parsed, "description", "name") ?? taskId,
41065
- outputFile: strField(parsed, "output_file", "outputFile") ?? existing?.outputFile
41066
- });
41116
+ if (parsed) {
41117
+ const runId = strField(parsed, "run_id", "runId");
41118
+ if (runId && toolUseId && !state.smokeWorkflowToolIds.has(toolUseId)) {
41119
+ state.workflowToolByRunId.set(runId, toolUseId);
41120
+ }
41121
+ const explicitSubagentId = strField(parsed, "subagent_id", "subagentId");
41122
+ const agentId = strField(parsed, "agent_id", "agentId");
41123
+ const hasSubagentShape = !!(explicitSubagentId || strField(parsed, "subagent_type", "subagentType") || agentId && !runId);
41124
+ const subagentId = explicitSubagentId ?? agentId ?? strField(parsed, "task_id", "taskId");
41125
+ if (subagentId && (explicitSubagentId || strField(parsed, "subagent_type", "subagentType"))) {
41126
+ if (isSpawnLaunch || !launchName) {
41127
+ bindSubagentToolId(state, subagentId, toolUseId, strField(parsed, "description", "name"), migrate);
41128
+ }
41129
+ } else if (subagentId && agentId && !runId) {
41130
+ if (isSpawnLaunch || !launchName) {
41131
+ bindSubagentToolId(state, subagentId, toolUseId, strField(parsed, "description", "name"), migrate);
41132
+ }
41133
+ }
41134
+ const taskId = strField(parsed, "task_id", "taskId");
41135
+ if (taskId && !runId && !hasSubagentShape) {
41136
+ const existing = state.bgTaskById.get(taskId);
41137
+ if (!existing?.toolUseId || existing.toolUseId === toolUseId) {
41138
+ state.bgTaskById.set(taskId, {
41139
+ toolUseId: toolUseId ?? existing?.toolUseId,
41140
+ description: existing?.description ?? strField(parsed, "description", "name") ?? taskId,
41141
+ outputFile: strField(parsed, "output_file", "outputFile") ?? existing?.outputFile
41142
+ });
41143
+ }
41144
+ }
41145
+ continue;
41067
41146
  }
41147
+ const plain = parsePlainTextTaskAck(d.summary);
41148
+ const allowPlain = isSpawnLaunch || /started in background/i.test(d.summary);
41149
+ if (allowPlain && plain.subagentId) {
41150
+ bindSubagentToolId(state, plain.subagentId, toolUseId, plain.description, migrate);
41151
+ }
41152
+ const explicitTaskId = d.summary.match(/(?:^|\n)\s*task_id:\s*(\S+)/i)?.[1];
41153
+ const bgTaskId = plain.outputFile ? explicitTaskId ?? plain.taskId : explicitTaskId && explicitTaskId !== plain.subagentId ? explicitTaskId : explicitTaskId && !plain.subagentId ? explicitTaskId : void 0;
41154
+ if (allowPlain && bgTaskId) {
41155
+ const existing = state.bgTaskById.get(bgTaskId);
41156
+ if (!existing?.toolUseId || existing.toolUseId === toolUseId) {
41157
+ state.bgTaskById.set(bgTaskId, {
41158
+ toolUseId: toolUseId ?? existing?.toolUseId,
41159
+ description: plain.description ?? existing?.description ?? bgTaskId,
41160
+ outputFile: plain.outputFile ?? existing?.outputFile
41161
+ });
41162
+ }
41163
+ }
41164
+ }
41165
+ return migrate;
41166
+ }
41167
+ function isValidateOnlyToolInput(input) {
41168
+ if (!input) return false;
41169
+ try {
41170
+ const o = tryParseJsonObject(input);
41171
+ if (o) return o.validate_only === true || o.validateOnly === true;
41172
+ } catch {
41068
41173
  }
41174
+ return /"validate_only"\s*:\s*true/.test(input) || /"validateOnly"\s*:\s*true/.test(input);
41069
41175
  }
41070
41176
  function tryParseJsonObject(text) {
41071
41177
  const trimmed = text.trim();
@@ -41388,16 +41494,22 @@ function mapSubagentProgress(u, state) {
41388
41494
  const durationMs = numField(u, "duration_ms", "durationMs") ?? 0;
41389
41495
  const toolCalls = numField(u, "tool_call_count", "toolCallCount") ?? 0;
41390
41496
  const tokens = numField(u, "tokens_used", "tokensUsed") ?? 0;
41391
- const toolsUsed = arrField(u, "tools_used", "toolsUsed");
41392
- const activityText = toolsUsed?.filter((t) => typeof t === "string").slice(-5).join(", ");
41497
+ const toolsUsed = (arrField(u, "tools_used", "toolsUsed") ?? []).filter((t) => typeof t === "string" && t.length > 0);
41498
+ const recent = toolsUsed.slice(-8);
41499
+ const lastTool = recent[recent.length - 1];
41500
+ const activityText = recent.length ? recent.join(", ") : void 0;
41501
+ const toolEntries = recent.map((toolName) => ({ toolName, description: "" }));
41393
41502
  const toolUseId = state.subagentToolById.get(id);
41394
41503
  events.push({
41395
41504
  type: "task_progress",
41396
41505
  taskId: id,
41397
41506
  ...toolUseId ? { toolUseId } : {},
41398
- description: id,
41507
+ // Prefer last tool name as description so reducer toolHistory advances.
41508
+ description: lastTool ?? id,
41509
+ ...lastTool ? { lastToolName: lastTool } : {},
41399
41510
  usage: { totalTokens: tokens, toolUses: toolCalls, durationMs },
41400
- ...activityText ? { activityText } : {}
41511
+ ...activityText ? { activityText } : {},
41512
+ ...toolEntries.length ? { toolEntries } : {}
41401
41513
  });
41402
41514
  return events;
41403
41515
  }
@@ -42223,7 +42335,7 @@ function createAcpAgentEventMapper(options) {
42223
42335
  });
42224
42336
  }
42225
42337
  trackOpenAcpTools(openTools, events);
42226
- noteToolCorrelationFromAgentEvents(events, xaiCorrelation);
42338
+ const migrate = noteToolCorrelationFromAgentEvents(events, xaiCorrelation);
42227
42339
  let textDelta = "";
42228
42340
  for (const event of events) {
42229
42341
  if (event.type === "content_delta" && event.delta.type === "text" && !event.delta.parentToolUseId) {
@@ -42231,6 +42343,7 @@ function createAcpAgentEventMapper(options) {
42231
42343
  }
42232
42344
  options.emit(event);
42233
42345
  }
42346
+ for (const event of migrate) options.emit(event);
42234
42347
  return { textDelta: textDelta || null };
42235
42348
  },
42236
42349
  applyXaiNotification(method, params) {
@@ -42241,8 +42354,9 @@ function createAcpAgentEventMapper(options) {
42241
42354
  { messageId: currentMessageId }
42242
42355
  );
42243
42356
  trackOpenAcpTools(openTools, events);
42244
- noteToolCorrelationFromAgentEvents(events, xaiCorrelation);
42357
+ const migrate = noteToolCorrelationFromAgentEvents(events, xaiCorrelation);
42245
42358
  for (const event of events) options.emit(event);
42359
+ for (const event of migrate) options.emit(event);
42246
42360
  },
42247
42361
  complete(stopReason = "end_turn") {
42248
42362
  if (terminal) return;
@@ -57187,8 +57301,8 @@ import { fileURLToPath } from "node:url";
57187
57301
  function resolveCliReleaseVersion() {
57188
57302
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
57189
57303
  if (fromEnv) return fromEnv;
57190
- if ("0.50.4-alpha".trim()) {
57191
- return "0.50.4-alpha".trim();
57304
+ if ("0.50.5-alpha".trim()) {
57305
+ return "0.50.5-alpha".trim();
57192
57306
  }
57193
57307
  const fromDist = readDistManifestVersion();
57194
57308
  if (fromDist) return fromDist;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-one/cli",
3
- "version": "0.50.4-alpha",
3
+ "version": "0.50.5-alpha",
4
4
  "description": "SuperOne headless node CLI — remote execution environment (RPC, workspaces, sessions).",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",