@super-one/cli 0.53.6-alpha → 0.53.8-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.
package/MANIFEST.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@super-one/cli",
3
- "version": "0.53.6-alpha",
3
+ "version": "0.53.8-alpha",
4
4
  "kind": "npm",
5
5
  "minNodeMajor": 20,
6
- "builtAt": "2026-08-15T09:53:30.001Z"
6
+ "builtAt": "2026-08-16T03:47:08.751Z"
7
7
  }
package/lib/cli.mjs CHANGED
@@ -257,9 +257,10 @@ var init_host_action_superone_descriptors = __esm({
257
257
  "bypassPermissions",
258
258
  "plan",
259
259
  "dontAsk",
260
- "auto"
260
+ "auto",
261
+ "agent"
261
262
  ],
262
- "description": 'How autonomous the child session is. Prefer the most autonomous mode it can finish the task under \u2014 "bypassPermissions" (shown as Bypass on Claude-family harnesses, Full Access on Codex), or "auto" for ACP agents. Nobody watches a child session, so a conservative mode strands it on an approval prompt that is never answered. Requesting an autonomous mode is safe by construction: nothing runs until the user approves this very request, and that approval dialog is where they downgrade permission or sandbox per launch. Pick "plan" or "default" only when stopping for human review is the point of the launch.'
263
+ "description": 'How autonomous the child session is. Prefer the most autonomous mode it can finish the task under \u2014 "bypassPermissions" (shown as Bypass on Claude-family harnesses, Full Access on Codex/Cursor), "agent" for Cursor, or "auto" for ACP agents. Nobody watches a child session, so a conservative mode strands it on an approval prompt that is never answered. Requesting an autonomous mode is safe by construction: nothing runs until the user approves this very request, and that approval dialog is where they downgrade permission or sandbox per launch. Pick "plan" or "default" only when stopping for human review is the point of the launch.'
263
264
  },
264
265
  "sandboxMode": {
265
266
  "type": "string",
@@ -411,7 +412,7 @@ var init_host_action_superone_descriptors = __esm({
411
412
  "modules": {
412
413
  "type": "array",
413
414
  "minItems": 1,
414
- "maxItems": 5,
415
+ "maxItems": 6,
415
416
  "uniqueItems": true,
416
417
  "items": {
417
418
  "type": "string",
@@ -420,7 +421,8 @@ var init_host_action_superone_descriptors = __esm({
420
421
  "mockup",
421
422
  "interactive",
422
423
  "chart",
423
- "art"
424
+ "art",
425
+ "native"
424
426
  ]
425
427
  },
426
428
  "description": "Widget only: one or more guideline modules. Mutually exclusive with topic."
@@ -659,7 +661,11 @@ var init_host_action_superone_descriptors = __esm({
659
661
  },
660
662
  {
661
663
  "name": "session_rename",
662
- "description": 'Rename the current chat session to a concise topic label shown in the sidebar. Optional tags (set) label it for session_list/session_search \u2014 discover names with session_tag_list.\n\nOnly the top-level agent talking directly to the user may call this. If you were launched as a Task/subagent worker, do NOT call it \u2014 you do not own the user-facing session title.\n\nIf the tool returns an error containing "user_locked", the user has manually named this session \u2014 do not call session_rename again. Tags in the same call were still applied; use session_tag for later tag edits.',
664
+ "description": `Rename the current chat session to a concise topic label shown in the sidebar. Always pass tags (set): 1\u20134 short kebab-case labels you choose so session_list/session_search can find this chat. Reuse names from session_tag_list when they fit; invent one when they don't.
665
+
666
+ Only the top-level agent talking directly to the user may call this. If you were launched as a Task/subagent worker, do NOT call it \u2014 you do not own the user-facing session title.
667
+
668
+ If the tool returns an error containing "user_locked", the user has manually named this session \u2014 do not call session_rename again. Tags in the same call were still applied; use session_tag for later tag edits.`,
663
669
  "inputSchema": {
664
670
  "type": "object",
665
671
  "properties": {
@@ -673,7 +679,7 @@ var init_host_action_superone_descriptors = __esm({
673
679
  "type": "array",
674
680
  "items": { "type": "string" },
675
681
  "maxItems": 8,
676
- "description": "Replace this session's tags (set). Discover names with session_tag_list. Empty array clears. Applied even when the title is user_locked."
682
+ "description": "Replace this session's tags (set). Pass 1\u20134 short kebab-case labels you choose. Reuse names from session_tag_list when they fit; invent when they don't. Empty array clears. Applied even when the title is user_locked."
677
683
  }
678
684
  },
679
685
  "required": [
@@ -684,7 +690,7 @@ var init_host_action_superone_descriptors = __esm({
684
690
  },
685
691
  {
686
692
  "name": "session_tag",
687
- "description": "Tag SuperOne sessions so session_list/session_search can filter by tag. Default: current session. Pass sessionId for one other session, or sessionIds with add to tag many. Use add, remove, or set (exactly one). set: [] clears. Discover existing labels with session_tag_list first \u2014 do not invent names. Only the top-level agent may call this; subagents must not. Not session_rename (titles) and not live collab.",
693
+ "description": "Tag SuperOne sessions so session_list/session_search can filter by tag. Default: current session. Pass sessionId for one other session, or sessionIds with add to tag many. Use add, remove, or set (exactly one). set: [] clears. Pick 1\u20134 short kebab-case labels; reuse names from session_tag_list when they fit, otherwise invent. Only the top-level agent may call this; subagents must not. Not session_rename (titles) and not live collab.",
688
694
  "inputSchema": {
689
695
  "type": "object",
690
696
  "properties": {
@@ -3373,7 +3379,7 @@ var init_host_action_superone_descriptors = __esm({
3373
3379
  },
3374
3380
  {
3375
3381
  "name": "widget_show",
3376
- "description": 'Render SVG, diagrams, charts, or interactive HTML inline in chat. Pass widget_code for new content, or template + data to reuse a saved template. Before the first new widget in a session, load the relevant design modules with read_manual({ domain: "widget", modules: [...] }).',
3382
+ "description": `Render SVG, diagrams, charts, or interactive HTML inline in chat. Pass widget_code for new content, or template + data to reuse a saved template. To show media you produced yourself, pass a @native/* template so it renders in SuperOne's own gallery (viewer, download, drag-out) instead of a lookalike you build in widget_code \u2014 call widget_list_templates for the list. Before the first new widget in a session, load the relevant design modules with read_manual({ domain: "widget", modules: [...] }).`,
3377
3383
  "inputSchema": {
3378
3384
  "type": "object",
3379
3385
  "properties": {
@@ -3538,7 +3544,7 @@ var init_host_action_superone_descriptors = __esm({
3538
3544
  },
3539
3545
  "permissionMode": {
3540
3546
  "type": "string",
3541
- "enum": ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"],
3547
+ "enum": ["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto", "agent"],
3542
3548
  "description": "Unified permission mode. Prefer bypassPermissions for unattended runs."
3543
3549
  },
3544
3550
  "sandboxMode": {
@@ -12757,7 +12763,7 @@ var SUPERONE_SYSTEM_PROMPT_APPEND;
12757
12763
  var init_superone_system_prompt = __esm({
12758
12764
  "../../packages/shared/src/superone-system-prompt.ts"() {
12759
12765
  "use strict";
12760
- SUPERONE_SYSTEM_PROMPT_APPEND = 'You are running inside SuperOne, a desktop GUI app \u2014 not a terminal. Your replies render as rich Markdown in a chat panel.\n\nPrefer the `widget_show` tool over plain markdown when the user wants something visual, data-heavy, or interactive. For mermaid diagrams, use fenced ```mermaid blocks instead \u2014 the host renders those natively.\n\nTwo markdown forms get special rendering from the host:\n- When you reference a project file, write it as a markdown link with an absolute path \u2014 it renders as a clickable chip. Add `:N` or `#LN` for a line, e.g. `[file.ts](/abs/path/file.ts:42)`.\n- `![alt](path)` embeds an image/video/audio file as an inline player. Use it ONLY when the user explicitly asks to see a file (e.g. "show me ..."), at most once per file per reply. If they only want a path or location, give a plain link instead \u2014 never the embed.\n- Media you create with a generation tool (e.g. `media_generate_image`, `media_generate_video`) is shown to the user inline by the host automatically. Never re-embed or link the result in your reply with Markdown (`![...]` or `[...]`) \u2014 that duplicates it. Just describe the result briefly in words.\n\nOn the first substantive user request, call `session_rename` as your first tool call, before answering \u2014 until you do, the title falls back to a noisy slice of the first message. Also rename when the user approves a plan, when the conversation shifts to a substantially different topic, or every ~10 user turns if the title has drifted. Title rules: 4-8 words, prefer "verb + object" over abstract nouns, match the user\'s conversation language, no surrounding quotes or trailing punctuation.';
12766
+ SUPERONE_SYSTEM_PROMPT_APPEND = 'You are running inside SuperOne, a desktop GUI app \u2014 not a terminal. Your replies render as rich Markdown in a chat panel.\n\nPrefer the `widget_show` tool over plain markdown when the user wants something visual, data-heavy, or interactive. For mermaid diagrams, use fenced ```mermaid blocks instead \u2014 the host renders those natively.\n\nTwo markdown forms get special rendering from the host:\n- When you reference a project file, write it as a markdown link with an absolute path \u2014 it renders as a clickable chip. Add `:N` or `#LN` for a line, e.g. `[file.ts](/abs/path/file.ts:42)`.\n- `![alt](path)` embeds an image/video/audio file as an inline player. Use it ONLY when the user explicitly asks to see a file (e.g. "show me ..."), at most once per file per reply. If they only want a path or location, give a plain link instead \u2014 never the embed.\n- Media you create with a generation tool (e.g. `media_generate_image`, `media_generate_video`) is shown to the user inline by the host automatically. Never re-embed or link the result in your reply with Markdown (`![...]` or `[...]`) \u2014 that duplicates it. Just describe the result briefly in words.\n\nOn the first substantive user request, call `session_rename` as your first tool call, before answering \u2014 until you do, the title falls back to a noisy slice of the first message. Always include `tags` on that call: 1\u20134 short kebab-case labels you pick so session_list/session_search can find this chat later. Reuse names from `session_tag_list` when they fit; invent one when they don\'t. Update tags with `session_tag` if the topic shifts. Also rename when the user approves a plan, when the conversation shifts to a substantially different topic, or every ~10 user turns if the title has drifted. Title rules: 4-8 words, prefer "verb + object" over abstract nouns, match the user\'s conversation language, no surrounding quotes or trailing punctuation.';
12761
12767
  }
12762
12768
  });
12763
12769
 
@@ -41931,6 +41937,43 @@ function uiToolNameFromId(id) {
41931
41937
  const key = normalizeToolIdKey(id);
41932
41938
  return TOOL_ID_TO_UI_NAME[key] ?? null;
41933
41939
  }
41940
+ function normalizeTranscriptTool(rawName, rawInput) {
41941
+ const envelopeId = typeof rawInput.tool_name === "string" ? rawInput.tool_name : "";
41942
+ const isUseTool = normalizeToolIdKey(rawName) === "use_tool" || rawInput.variant === "UseTool";
41943
+ if (isUseTool && envelopeId.includes("__")) {
41944
+ const mcpInput = rawInput.tool_input && typeof rawInput.tool_input === "object" && !Array.isArray(rawInput.tool_input) ? rawInput.tool_input : {};
41945
+ return { toolName: `mcp__${envelopeId}`, input: mcpInput };
41946
+ }
41947
+ const toolName = uiToolNameFromId(rawName) ?? rawName;
41948
+ const input = { ...rawInput };
41949
+ if (toolName === "Read") {
41950
+ if (input.file_path == null && input.target_file != null) input.file_path = input.target_file;
41951
+ if (input.file_path == null && input.path != null) input.file_path = input.path;
41952
+ } else if (toolName === "Edit" || toolName === "Write" || toolName === "Delete" || toolName === "FileChange") {
41953
+ if (input.file_path == null && input.target_file != null) input.file_path = input.target_file;
41954
+ if (input.file_path == null && input.path != null) input.file_path = input.path;
41955
+ if (toolName === "Write" && input.content == null && input.contents != null) input.content = input.contents;
41956
+ if (toolName === "Write" && input.content == null && input.fileText != null) input.content = input.fileText;
41957
+ if (toolName === "Edit" && input.diff == null && input.diffString != null) input.diff = input.diffString;
41958
+ } else if (toolName === "Bash") {
41959
+ if (input.command == null && input.cmd != null) input.command = input.cmd;
41960
+ } else if (toolName === "LS") {
41961
+ if (input.path == null && input.target_directory != null) input.path = input.target_directory;
41962
+ if (input.path == null && input.directory != null) input.path = input.directory;
41963
+ } else if (toolName === "Grep") {
41964
+ if (input.pattern == null && input.query != null) input.pattern = input.query;
41965
+ } else if (toolName === "Glob") {
41966
+ if (input.pattern == null && input.globPattern != null) input.pattern = input.globPattern;
41967
+ if (input.pattern == null && input.glob_pattern != null) input.pattern = input.glob_pattern;
41968
+ if (input.path == null && input.targetDirectory != null) input.path = input.targetDirectory;
41969
+ if (input.path == null && input.target_directory != null) input.path = input.target_directory;
41970
+ } else if (toolName === "WebFetch") {
41971
+ if (input.url == null && input.uri != null) input.url = input.uri;
41972
+ } else if (toolName === "WebSearch" || toolName === "SearchTools" || toolName === "ToolSearch" || toolName === "SemanticSearch") {
41973
+ if (input.query == null && input.q != null) input.query = input.q;
41974
+ }
41975
+ return { toolName, input };
41976
+ }
41934
41977
  function bytesOrStringToText(value) {
41935
41978
  if (typeof value === "string") return value;
41936
41979
  if (Array.isArray(value) && value.length > 0 && value.every((n) => typeof n === "number")) {
@@ -41984,9 +42027,94 @@ function formatSearchToolPayload(obj) {
41984
42027
  }
41985
42028
  return lines.join("\n").trim() || null;
41986
42029
  }
42030
+ function isShellCommandResult(obj) {
42031
+ const hasStream = typeof obj.stdout === "string" || typeof obj.stderr === "string";
42032
+ if (!hasStream) return false;
42033
+ return typeof obj.exitCode === "number" || typeof obj.exit_code === "number" || typeof obj.signal === "string" || typeof obj.executionTime === "number";
42034
+ }
42035
+ function formatShellCommandResult(obj) {
42036
+ const stdout = typeof obj.stdout === "string" ? obj.stdout : "";
42037
+ const stderr = typeof obj.stderr === "string" ? obj.stderr : "";
42038
+ if (stdout && stderr) {
42039
+ return stdout.endsWith("\n") ? `${stdout}${stderr}` : `${stdout}
42040
+ ${stderr}`;
42041
+ }
42042
+ if (stdout || stderr) return stdout || stderr;
42043
+ const code = typeof obj.exitCode === "number" ? obj.exitCode : obj.exit_code;
42044
+ if (typeof code === "number" && code !== 0) return `Exit code ${code}`;
42045
+ return "";
42046
+ }
42047
+ function isCursorGrepResult(obj) {
42048
+ const workspaces = obj.workspaceResults;
42049
+ if (workspaces && typeof workspaces === "object" && !Array.isArray(workspaces)) return true;
42050
+ return obj.activeEditorResult != null && typeof obj.activeEditorResult === "object";
42051
+ }
42052
+ function formatGrepUnion(result) {
42053
+ const rec = result && typeof result === "object" && !Array.isArray(result) ? result : null;
42054
+ if (!rec) return "";
42055
+ const output = rec.output && typeof rec.output === "object" && !Array.isArray(rec.output) ? rec.output : rec;
42056
+ const type = typeof rec.type === "string" ? rec.type : "";
42057
+ if (type === "files" || Array.isArray(output.files)) {
42058
+ const files = Array.isArray(output.files) ? output.files.filter((f2) => typeof f2 === "string") : [];
42059
+ return files.join("\n");
42060
+ }
42061
+ if (type === "count" || Array.isArray(output.counts)) {
42062
+ const counts = Array.isArray(output.counts) ? output.counts : [];
42063
+ const lines2 = [];
42064
+ for (const entry of counts) {
42065
+ if (!entry || typeof entry !== "object") continue;
42066
+ const row = entry;
42067
+ const file2 = typeof row.file === "string" ? row.file : "";
42068
+ const count = typeof row.count === "number" ? row.count : "";
42069
+ if (file2) lines2.push(count === "" ? file2 : `${file2}:${count}`);
42070
+ }
42071
+ return lines2.join("\n");
42072
+ }
42073
+ const matches = Array.isArray(output.matches) ? output.matches : [];
42074
+ const lines = [];
42075
+ for (const entry of matches) {
42076
+ if (!entry || typeof entry !== "object") continue;
42077
+ const row = entry;
42078
+ const file2 = typeof row.file === "string" ? row.file : "";
42079
+ if (!file2) continue;
42080
+ const lineNo = typeof row.lineNumber === "number" ? row.lineNumber : null;
42081
+ const line = typeof row.line === "string" ? row.line : "";
42082
+ if (lineNo != null && line) lines.push(`${file2}:${lineNo}:${line}`);
42083
+ else if (line) lines.push(`${file2}:${line}`);
42084
+ else lines.push(file2);
42085
+ }
42086
+ return lines.join("\n");
42087
+ }
42088
+ function formatCursorGrepResult(obj) {
42089
+ const chunks = [];
42090
+ const editor = formatGrepUnion(obj.activeEditorResult);
42091
+ if (editor) chunks.push(editor);
42092
+ const workspaces = asPlainRecord(obj.workspaceResults);
42093
+ if (workspaces) {
42094
+ const roots = Object.keys(workspaces);
42095
+ const multi = roots.length > 1;
42096
+ for (const root of roots) {
42097
+ const body = formatGrepUnion(workspaces[root]);
42098
+ if (!body) continue;
42099
+ chunks.push(multi ? `${root}
42100
+ ${body}` : body);
42101
+ }
42102
+ }
42103
+ return chunks.join("\n");
42104
+ }
42105
+ function asPlainRecord(value) {
42106
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
42107
+ return value;
42108
+ }
42109
+ function isCursorGlobResult(obj) {
42110
+ return Array.isArray(obj.files) && obj.files.every((f2) => typeof f2 === "string") && typeof obj.totalFiles === "number";
42111
+ }
42112
+ function formatCursorGlobResult(obj) {
42113
+ return obj.files.join("\n");
42114
+ }
41987
42115
  function isAgentOutputEnvelope(obj) {
41988
42116
  const t = obj.type;
41989
- 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";
42117
+ 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" || isShellCommandResult(obj) || isCursorGrepResult(obj) || isCursorGlobResult(obj);
41990
42118
  }
41991
42119
  function formatAgentToolOutput(raw) {
41992
42120
  if (raw == null) return "";
@@ -42042,6 +42170,15 @@ function formatAgentToolOutput(raw) {
42042
42170
  const text = bytesOrStringToText(obj.stdout ?? obj.content ?? obj.output);
42043
42171
  if (text) return text;
42044
42172
  }
42173
+ if (isShellCommandResult(obj)) {
42174
+ return formatShellCommandResult(obj);
42175
+ }
42176
+ if (isCursorGrepResult(obj)) {
42177
+ return formatCursorGrepResult(obj);
42178
+ }
42179
+ if (isCursorGlobResult(obj)) {
42180
+ return formatCursorGlobResult(obj);
42181
+ }
42045
42182
  const action = obj.action;
42046
42183
  if (action && typeof action === "object") {
42047
42184
  const a = action;
@@ -42096,7 +42233,20 @@ function formatAgentToolOutput(raw) {
42096
42233
  return String(raw);
42097
42234
  }
42098
42235
  }
42099
- var TOOL_ID_TO_UI_NAME;
42236
+ function truncateTranscriptToolResult(text, max = MAX_TRANSCRIPT_TOOL_RESULT_CHARS) {
42237
+ if (text.length <= max) return text;
42238
+ const omitted = text.length - max;
42239
+ return `${text.slice(0, max)}
42240
+
42241
+ \u2026 truncated ${omitted.toLocaleString()} characters`;
42242
+ }
42243
+ function formatTranscriptToolResult(content, opts) {
42244
+ const formatted = formatAgentToolOutput(content);
42245
+ if (!formatted) return "";
42246
+ const max = opts?.maxChars ?? MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
42247
+ return truncateTranscriptToolResult(formatted, max);
42248
+ }
42249
+ var TOOL_ID_TO_UI_NAME, MAX_TRANSCRIPT_TOOL_RESULT_CHARS;
42100
42250
  var init_tool_ui = __esm({
42101
42251
  "../../packages/shared/src/tool-ui.ts"() {
42102
42252
  "use strict";
@@ -42177,6 +42327,7 @@ var init_tool_ui = __esm({
42177
42327
  scheduler_delete: "SchedulerDelete",
42178
42328
  scheduler_list: "SchedulerList"
42179
42329
  };
42330
+ MAX_TRANSCRIPT_TOOL_RESULT_CHARS = 48e3;
42180
42331
  }
42181
42332
  });
42182
42333
 
@@ -51483,7 +51634,7 @@ function mapPermissionToCursorLocal(mode) {
51483
51634
  if (mode === "plan") {
51484
51635
  return { mode: "plan", autoReview: false };
51485
51636
  }
51486
- if (mode === "auto" || mode === "acceptEdits" || mode === "default") {
51637
+ if (mode === "agent" || mode === "auto" || mode === "acceptEdits" || mode === "default") {
51487
51638
  return { mode: "agent", autoReview: true };
51488
51639
  }
51489
51640
  return { mode: "agent", autoReview: false };
@@ -51717,6 +51868,7 @@ var init_cursor_custom_tools = __esm({
51717
51868
 
51718
51869
  // ../../packages/cursor/src/cursor-event-map.ts
51719
51870
  function toolDisplayName(name) {
51871
+ if (name.startsWith("mcp__")) return name;
51720
51872
  const n = name.toLowerCase();
51721
51873
  if (n.includes("shell") || n === "bash") return "Bash";
51722
51874
  if (n.includes("read") && !n.includes("lint")) return "Read";
@@ -51737,6 +51889,15 @@ function toolDisplayName(name) {
51737
51889
  if (n === "recordscreen") return "RecordScreen";
51738
51890
  return name;
51739
51891
  }
51892
+ function unwrapCursorMcpTool(toolType, args) {
51893
+ if (toolType.toLowerCase() !== "mcp") return { toolType, args };
51894
+ const rec = asRecord9(args);
51895
+ if (!rec) return { toolType, args };
51896
+ const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
51897
+ const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
51898
+ if (!server || !name) return { toolType, args };
51899
+ return { toolType: `mcp__${server}__${name}`, args: rec.args ?? {} };
51900
+ }
51740
51901
  function strField2(obj, key) {
51741
51902
  if (!obj || typeof obj !== "object") return "";
51742
51903
  const v2 = obj[key];
@@ -51746,13 +51907,21 @@ function stableIdField(obj, ...keys) {
51746
51907
  if (!obj || typeof obj !== "object") return null;
51747
51908
  const rec = obj;
51748
51909
  for (const key of keys) {
51749
- if (typeof rec[key] === "string" && rec[key]) return rec[key];
51910
+ const v2 = rec[key];
51911
+ if (typeof v2 === "string" && v2) return v2;
51912
+ if (typeof v2 === "number" && Number.isFinite(v2)) return String(v2);
51750
51913
  }
51751
51914
  return null;
51752
51915
  }
51753
51916
  function idField(obj, ...keys) {
51754
51917
  return stableIdField(obj, ...keys) ?? `tool_${Date.now()}`;
51755
51918
  }
51919
+ function extractCursorCallId(update) {
51920
+ const rec = asRecord9(update);
51921
+ if (!rec) return null;
51922
+ const nested = asRecord9(rec.toolCall) ?? asRecord9(rec.message);
51923
+ return stableIdField(rec, ...TOOL_CALL_ID_KEYS) ?? (nested ? stableIdField(nested, ...TOOL_CALL_ID_KEYS) : null);
51924
+ }
51756
51925
  function asRecord9(value) {
51757
51926
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
51758
51927
  return value;
@@ -51768,7 +51937,7 @@ function stringifyPayload(value) {
51768
51937
  }
51769
51938
  function extractToolCallParts(update) {
51770
51939
  const rec = asRecord9(update) ?? {};
51771
- const callId = idField(rec, "callId", "toolCallId", "id", "call_id");
51940
+ const callId = extractCursorCallId(update);
51772
51941
  const nested = asRecord9(rec.toolCall);
51773
51942
  if (nested) {
51774
51943
  const toolType2 = typeof nested.type === "string" && nested.type ? nested.type : "Tool";
@@ -51809,19 +51978,53 @@ function mapTodosPayload(todos) {
51809
51978
  };
51810
51979
  }
51811
51980
  function toolUseEvent(messageId, callId, toolType, args, status) {
51981
+ const unwrapped = unwrapCursorMcpTool(toolType, args);
51982
+ const toolName = toolDisplayName(unwrapped.toolType);
51812
51983
  return {
51813
51984
  type: "content_delta",
51814
51985
  messageId,
51815
51986
  delta: {
51816
51987
  type: "tool_use",
51817
- toolName: toolDisplayName(toolType),
51988
+ toolName,
51818
51989
  toolUseId: callId,
51819
- input: stringifyPayload(args ?? {}),
51990
+ input: stringifyPayload(normalizeCursorToolInput(toolName, unwrapped.args)),
51820
51991
  status,
51821
51992
  ...status === "streaming" ? { startedAt: Date.now() } : {}
51822
51993
  }
51823
51994
  };
51824
51995
  }
51996
+ function normalizeCursorToolInput(toolName, args) {
51997
+ if (toolName.startsWith("mcp__")) return args;
51998
+ const rec = asRecord9(args);
51999
+ if (!rec) return args ?? {};
52000
+ return normalizeTranscriptTool(toolName, rec).input;
52001
+ }
52002
+ function mergeCursorToolResultArgs(toolType, args, result) {
52003
+ if (toolType.toLowerCase() === "mcp") return args;
52004
+ const res = asRecord9(result);
52005
+ if (!res) return args;
52006
+ const rec = asRecord9(args);
52007
+ if (!rec) return args;
52008
+ const diff = typeof res.diffString === "string" ? res.diffString : void 0;
52009
+ const linesAdded = typeof res.linesAdded === "number" ? res.linesAdded : void 0;
52010
+ const linesRemoved = typeof res.linesRemoved === "number" ? res.linesRemoved : void 0;
52011
+ if (!diff && linesAdded == null && linesRemoved == null) return args;
52012
+ const next = { ...rec };
52013
+ let changed = false;
52014
+ if (diff && rec.diffString == null && rec.diff == null) {
52015
+ next.diffString = diff;
52016
+ changed = true;
52017
+ }
52018
+ if (linesAdded != null && rec.linesAdded == null) {
52019
+ next.linesAdded = linesAdded;
52020
+ changed = true;
52021
+ }
52022
+ if (linesRemoved != null && rec.linesRemoved == null) {
52023
+ next.linesRemoved = linesRemoved;
52024
+ changed = true;
52025
+ }
52026
+ return changed ? next : rec;
52027
+ }
51825
52028
  function toolResultEvent(messageId, callId, result, isError) {
51826
52029
  return {
51827
52030
  type: "content_delta",
@@ -51829,21 +52032,35 @@ function toolResultEvent(messageId, callId, result, isError) {
51829
52032
  delta: {
51830
52033
  type: "tool_result",
51831
52034
  toolUseId: callId,
51832
- summary: stringifyPayload(result),
52035
+ summary: formatTranscriptToolResult(result) || stringifyPayload(result),
51833
52036
  isError
51834
52037
  }
51835
52038
  };
51836
52039
  }
51837
- function usageFromTurn(messageId, usage2, extras) {
52040
+ function contextTokensFromUsage(usage2) {
52041
+ return usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens;
52042
+ }
52043
+ function mapCursorTokenUsage(messageId, usage2, extras) {
52044
+ const contextTokens = extras?.contextTokens && extras.contextTokens > 0 ? extras.contextTokens : contextTokensFromUsage(usage2);
51838
52045
  return {
51839
52046
  type: "message_usage",
51840
52047
  messageId,
51841
- inputTokens: usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens,
51842
- outputTokens: usage2.outputTokens + (usage2.reasoningTokens ?? 0),
52048
+ inputTokens: usage2.inputTokens,
52049
+ outputTokens: usage2.outputTokens,
51843
52050
  cacheReadTokens: usage2.cacheReadTokens,
51844
- ...extras?.contextWindow && extras.contextWindow > 0 ? { contextWindow: extras.contextWindow, contextTokens: usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens } : {}
52051
+ contextTokens,
52052
+ ...extras?.contextWindow && extras.contextWindow > 0 ? { contextWindow: extras.contextWindow } : {}
51845
52053
  };
51846
52054
  }
52055
+ function stampParentToolUseId(events, parentToolUseId) {
52056
+ if (!parentToolUseId) return events;
52057
+ return events.map((event) => {
52058
+ if (event.type !== "content_delta") return event;
52059
+ const delta = event.delta;
52060
+ if ("parentToolUseId" in delta && delta.parentToolUseId) return event;
52061
+ return { ...event, delta: { ...delta, parentToolUseId } };
52062
+ });
52063
+ }
51847
52064
  function mapInteractionUpdate(messageId, update, options) {
51848
52065
  const events = [];
51849
52066
  const type = String(update.type ?? "");
@@ -51884,6 +52101,7 @@ function mapInteractionUpdate(messageId, update, options) {
51884
52101
  case "tool-call-started":
51885
52102
  case "partial-tool-call": {
51886
52103
  const parts = extractToolCallParts(update);
52104
+ if (!parts.callId) break;
51887
52105
  events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "streaming"));
51888
52106
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
51889
52107
  const todos = asRecord9(parts.args)?.todos;
@@ -51895,6 +52113,7 @@ function mapInteractionUpdate(messageId, update, options) {
51895
52113
  events.push({
51896
52114
  type: "task_started",
51897
52115
  taskId: parts.callId,
52116
+ toolUseId: parts.callId,
51898
52117
  description
51899
52118
  });
51900
52119
  }
@@ -51907,24 +52126,19 @@ function mapInteractionUpdate(messageId, update, options) {
51907
52126
  if (nestedType === "shell-output-delta") {
51908
52127
  break;
51909
52128
  }
51910
- if (nestedType === "text-delta") {
51911
- const text = strField2(taskUpdate, "text");
51912
- if (text) {
51913
- events.push({
51914
- type: "content_delta",
51915
- messageId,
51916
- delta: { type: "text", text }
51917
- });
51918
- }
51919
- break;
51920
- }
51921
- events.push(...mapInteractionUpdate(messageId, taskUpdate, options));
52129
+ const parentCallId = extractCursorCallId(rec) ?? options?.parentToolUseId;
52130
+ events.push(...mapInteractionUpdate(messageId, taskUpdate, {
52131
+ ...options,
52132
+ ...parentCallId ? { parentToolUseId: parentCallId } : {}
52133
+ }));
51922
52134
  }
51923
52135
  break;
51924
52136
  }
51925
52137
  case "tool-call-completed": {
51926
52138
  const parts = extractToolCallParts(update);
51927
- events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "complete"));
52139
+ if (!parts.callId) break;
52140
+ const args = mergeCursorToolResultArgs(parts.toolType, parts.args, parts.result);
52141
+ events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
51928
52142
  events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
51929
52143
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
51930
52144
  const todos = asRecord9(parts.args)?.todos ?? asRecord9(parts.result)?.todos;
@@ -51932,12 +52146,14 @@ function mapInteractionUpdate(messageId, update, options) {
51932
52146
  if (todoEvent) events.push(todoEvent);
51933
52147
  }
51934
52148
  if (parts.toolType === "task") {
52149
+ const transcriptPath = strField2(parts.result, "transcriptPath");
51935
52150
  events.push({
51936
52151
  type: "task_notification",
51937
52152
  taskId: parts.callId,
52153
+ toolUseId: parts.callId,
51938
52154
  taskStatus: parts.isError ? "failed" : "completed",
51939
- outputFile: "",
51940
- summary: stringifyPayload(parts.result) || strField2(parts.args, "description") || "Task"
52155
+ outputFile: transcriptPath,
52156
+ summary: strField2(parts.result, "resultSuffix") || stringifyPayload(parts.result) || strField2(parts.args, "description") || "Task"
51941
52157
  });
51942
52158
  }
51943
52159
  break;
@@ -51945,13 +52161,13 @@ function mapInteractionUpdate(messageId, update, options) {
51945
52161
  case "token-delta": {
51946
52162
  const tokens = Number(update.tokens);
51947
52163
  if (Number.isFinite(tokens) && tokens > 0) {
52164
+ const turnUsage = options?.turnUsage;
52165
+ if (turnUsage) turnUsage.addTokenDelta(tokens);
51948
52166
  events.push({
51949
52167
  type: "message_usage",
51950
52168
  messageId,
51951
- inputTokens: tokens,
51952
- outputTokens: 0,
51953
- contextTokens: tokens,
51954
- ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
52169
+ inputTokens: turnUsage?.input ?? 0,
52170
+ outputTokens: turnUsage?.output ?? tokens
51955
52171
  });
51956
52172
  }
51957
52173
  break;
@@ -51959,7 +52175,21 @@ function mapInteractionUpdate(messageId, update, options) {
51959
52175
  case "turn-ended": {
51960
52176
  const usage2 = update.usage;
51961
52177
  if (usage2) {
51962
- events.push(usageFromTurn(messageId, usage2, { contextWindow: options?.contextWindow }));
52178
+ const turnUsage = options?.turnUsage;
52179
+ if (turnUsage) {
52180
+ turnUsage.applyInternalTurn(usage2);
52181
+ events.push({
52182
+ type: "message_usage",
52183
+ messageId,
52184
+ inputTokens: turnUsage.input,
52185
+ outputTokens: turnUsage.output,
52186
+ cacheReadTokens: usage2.cacheReadTokens,
52187
+ contextTokens: turnUsage.context,
52188
+ ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
52189
+ });
52190
+ } else {
52191
+ events.push(mapCursorTokenUsage(messageId, usage2, { contextWindow: options?.contextWindow }));
52192
+ }
51963
52193
  }
51964
52194
  events.push({ type: "status_change", status: "idle" });
51965
52195
  break;
@@ -52012,7 +52242,7 @@ ${text}
52012
52242
  break;
52013
52243
  }
52014
52244
  }
52015
- return events;
52245
+ return stampParentToolUseId(events, options?.parentToolUseId);
52016
52246
  }
52017
52247
  function mapConversationStep(messageId, step, options) {
52018
52248
  const events = [];
@@ -52025,14 +52255,21 @@ function mapConversationStep(messageId, step, options) {
52025
52255
  if (stepType === "toolCall") {
52026
52256
  const message = rec.message ?? rec.toolCall ?? rec;
52027
52257
  const nested = asRecord9(message);
52028
- const explicitCallId = stableIdField(rec, "callId", "toolCallId", "id", "call_id") || stableIdField(nested, "callId", "toolCallId", "id", "call_id");
52029
- const callId = explicitCallId || options?.resolveCallId?.(step) || null;
52258
+ const callId = extractCursorCallId(rec) || options?.resolveCallId?.(step) || null;
52030
52259
  if (!callId) {
52031
52260
  return events;
52032
52261
  }
52033
52262
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
52034
52263
  const args = nested?.args ?? nested?.input ?? {};
52035
- events.push(toolUseEvent(messageId, callId, toolType, args, "complete"));
52264
+ const resultRec = asRecord9(nested?.result);
52265
+ const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
52266
+ events.push(toolUseEvent(
52267
+ messageId,
52268
+ callId,
52269
+ toolType,
52270
+ mergeCursorToolResultArgs(toolType, args, resultValue),
52271
+ "complete"
52272
+ ));
52036
52273
  if (toolType === "updateTodos" || toolType === "update_todos") {
52037
52274
  const todos = asRecord9(args)?.todos;
52038
52275
  const todoEvent = mapTodosPayload(todos);
@@ -52064,7 +52301,7 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52064
52301
  }
52065
52302
  case "usage": {
52066
52303
  const u = message.usage;
52067
- events.push(usageFromTurn(messageId, {
52304
+ events.push(mapCursorTokenUsage(messageId, {
52068
52305
  inputTokens: u.inputTokens,
52069
52306
  outputTokens: u.outputTokens,
52070
52307
  cacheReadTokens: u.cacheReadTokens,
@@ -52097,17 +52334,7 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52097
52334
  delta: { type: "text", text: block.text }
52098
52335
  });
52099
52336
  } else if (block.type === "tool_use") {
52100
- events.push({
52101
- type: "content_delta",
52102
- messageId,
52103
- delta: {
52104
- type: "tool_use",
52105
- toolName: toolDisplayName(block.name),
52106
- toolUseId: block.id,
52107
- input: JSON.stringify(block.input ?? {}),
52108
- status: "streaming"
52109
- }
52110
- });
52337
+ events.push(toolUseEvent(messageId, block.id, block.name, block.input, "streaming"));
52111
52338
  }
52112
52339
  }
52113
52340
  }
@@ -52139,45 +52366,56 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52139
52366
  return events;
52140
52367
  }
52141
52368
  function mapToolCallMessage(messageId, message) {
52142
- const events = [{
52143
- type: "content_delta",
52144
- messageId,
52145
- delta: {
52146
- type: "tool_use",
52147
- toolName: toolDisplayName(message.name),
52148
- toolUseId: message.call_id,
52149
- input: JSON.stringify(message.args ?? {}),
52150
- status: message.status === "completed" || message.status === "error" ? "complete" : "streaming"
52151
- }
52152
- }];
52369
+ const status = message.status === "completed" || message.status === "error" ? "complete" : "streaming";
52370
+ const args = status === "complete" ? mergeCursorToolResultArgs(message.name, message.args, message.result) : message.args;
52371
+ const events = [
52372
+ toolUseEvent(messageId, message.call_id, message.name, args, status)
52373
+ ];
52153
52374
  if (message.status === "completed" || message.status === "error") {
52154
- events.push({
52155
- type: "content_delta",
52156
- messageId,
52157
- delta: {
52158
- type: "tool_result",
52159
- toolUseId: message.call_id,
52160
- summary: message.result === void 0 ? "" : typeof message.result === "string" ? message.result : JSON.stringify(message.result),
52161
- isError: message.status === "error"
52162
- }
52163
- });
52375
+ events.push(toolResultEvent(messageId, message.call_id, message.result, message.status === "error"));
52164
52376
  }
52165
52377
  return events;
52166
52378
  }
52167
- var CursorTurnCallIdBridge;
52379
+ var TOOL_CALL_ID_KEYS, CursorTurnUsage, CursorTurnCallIdBridge;
52168
52380
  var init_cursor_event_map = __esm({
52169
52381
  "../../packages/cursor/src/cursor-event-map.ts"() {
52170
52382
  "use strict";
52383
+ init_tool_ui();
52384
+ TOOL_CALL_ID_KEYS = ["callId", "toolCallId", "call_id"];
52385
+ CursorTurnUsage = class {
52386
+ input = 0;
52387
+ output = 0;
52388
+ context = 0;
52389
+ addTokenDelta(tokens) {
52390
+ if (Number.isFinite(tokens) && tokens > 0) this.output += tokens;
52391
+ }
52392
+ applyInternalTurn(usage2) {
52393
+ this.input += usage2.inputTokens;
52394
+ if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
52395
+ this.context = contextTokensFromUsage(usage2);
52396
+ }
52397
+ applyRunTotals(usage2) {
52398
+ if (usage2.inputTokens > this.input) this.input = usage2.inputTokens;
52399
+ if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
52400
+ }
52401
+ };
52171
52402
  CursorTurnCallIdBridge = class {
52172
52403
  queue = [];
52173
52404
  seen = /* @__PURE__ */ new Set();
52174
52405
  /** Observe a live InteractionUpdate; record callIds from tool-call events. */
52175
52406
  observeDelta(update) {
52176
52407
  const type = String(update.type ?? "");
52408
+ if (type === "tool-call-delta") {
52409
+ const taskUpdate = asRecord9(update)?.taskUpdate;
52410
+ if (taskUpdate && typeof taskUpdate === "object") {
52411
+ this.observeDelta(taskUpdate);
52412
+ }
52413
+ return;
52414
+ }
52177
52415
  if (type !== "tool-call-started" && type !== "partial-tool-call" && type !== "tool-call-completed") {
52178
52416
  return;
52179
52417
  }
52180
- const callId = stableIdField(update, "callId", "toolCallId", "id", "call_id");
52418
+ const callId = extractCursorCallId(update);
52181
52419
  if (!callId || this.seen.has(callId)) return;
52182
52420
  this.seen.add(callId);
52183
52421
  this.queue.push(callId);
@@ -53090,6 +53328,7 @@ async function createCursorRuntime(opts) {
53090
53328
  lastMcpServers = servers;
53091
53329
  const contextWindow = resolveContextWindow(modelSelection);
53092
53330
  const callIdBridge = new CursorTurnCallIdBridge();
53331
+ const turnUsage = new CursorTurnUsage();
53093
53332
  const sendStarted = Date.now();
53094
53333
  log2.info("[CursorRuntime] send start", { messageId });
53095
53334
  tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
@@ -53106,7 +53345,7 @@ async function createCursorRuntime(opts) {
53106
53345
  onDelta: ({ update }) => {
53107
53346
  tracer.sdk(cursorSdkType(update, "delta"), update, messageId);
53108
53347
  callIdBridge.observeDelta(update);
53109
- for (const event of mapInteractionUpdate(messageId, update, { contextWindow })) {
53348
+ for (const event of mapInteractionUpdate(messageId, update, { contextWindow, turnUsage })) {
53110
53349
  opts.onEvent(event);
53111
53350
  }
53112
53351
  },
@@ -53209,17 +53448,16 @@ async function createCursorRuntime(opts) {
53209
53448
  currentRun = null;
53210
53449
  lastRunId = result.id || lastRunId;
53211
53450
  if (result.usage) {
53451
+ turnUsage.applyRunTotals(result.usage);
53212
53452
  opts.onEvent({
53213
53453
  type: "message_usage",
53214
53454
  messageId,
53215
- inputTokens: result.usage.inputTokens + result.usage.cacheReadTokens + result.usage.cacheWriteTokens,
53216
- outputTokens: result.usage.outputTokens + (result.usage.reasoningTokens ?? 0),
53455
+ inputTokens: turnUsage.input,
53456
+ outputTokens: turnUsage.output,
53217
53457
  cacheReadTokens: result.usage.cacheReadTokens,
53218
53458
  model: result.model?.id ?? modelSelection?.id,
53219
- ...contextWindow && contextWindow > 0 ? {
53220
- contextWindow,
53221
- contextTokens: result.usage.inputTokens + result.usage.cacheReadTokens + result.usage.cacheWriteTokens
53222
- } : {}
53459
+ ...turnUsage.context > 0 ? { contextTokens: turnUsage.context } : {},
53460
+ ...contextWindow && contextWindow > 0 ? { contextWindow } : {}
53223
53461
  });
53224
53462
  }
53225
53463
  if (result.git?.branches?.length) {
@@ -61149,8 +61387,8 @@ import { fileURLToPath } from "node:url";
61149
61387
  function resolveCliReleaseVersion() {
61150
61388
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
61151
61389
  if (fromEnv) return fromEnv;
61152
- if ("0.53.6-alpha".trim()) {
61153
- return "0.53.6-alpha".trim();
61390
+ if ("0.53.8-alpha".trim()) {
61391
+ return "0.53.8-alpha".trim();
61154
61392
  }
61155
61393
  const fromDist = readDistManifestVersion();
61156
61394
  if (fromDist) return fromDist;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-one/cli",
3
- "version": "0.53.6-alpha",
3
+ "version": "0.53.8-alpha",
4
4
  "description": "SuperOne headless node CLI — remote execution environment (RPC, workspaces, sessions).",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",