@super-one/cli 0.53.6-alpha → 0.53.7-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.7-alpha",
4
4
  "kind": "npm",
5
5
  "minNodeMajor": 20,
6
- "builtAt": "2026-08-15T09:53:30.001Z"
6
+ "builtAt": "2026-08-15T15:41:36.101Z"
7
7
  }
package/lib/cli.mjs CHANGED
@@ -41931,6 +41931,43 @@ function uiToolNameFromId(id) {
41931
41931
  const key = normalizeToolIdKey(id);
41932
41932
  return TOOL_ID_TO_UI_NAME[key] ?? null;
41933
41933
  }
41934
+ function normalizeTranscriptTool(rawName, rawInput) {
41935
+ const envelopeId = typeof rawInput.tool_name === "string" ? rawInput.tool_name : "";
41936
+ const isUseTool = normalizeToolIdKey(rawName) === "use_tool" || rawInput.variant === "UseTool";
41937
+ if (isUseTool && envelopeId.includes("__")) {
41938
+ const mcpInput = rawInput.tool_input && typeof rawInput.tool_input === "object" && !Array.isArray(rawInput.tool_input) ? rawInput.tool_input : {};
41939
+ return { toolName: `mcp__${envelopeId}`, input: mcpInput };
41940
+ }
41941
+ const toolName = uiToolNameFromId(rawName) ?? rawName;
41942
+ const input = { ...rawInput };
41943
+ if (toolName === "Read") {
41944
+ if (input.file_path == null && input.target_file != null) input.file_path = input.target_file;
41945
+ if (input.file_path == null && input.path != null) input.file_path = input.path;
41946
+ } else if (toolName === "Edit" || toolName === "Write" || toolName === "Delete" || toolName === "FileChange") {
41947
+ if (input.file_path == null && input.target_file != null) input.file_path = input.target_file;
41948
+ if (input.file_path == null && input.path != null) input.file_path = input.path;
41949
+ if (toolName === "Write" && input.content == null && input.contents != null) input.content = input.contents;
41950
+ if (toolName === "Write" && input.content == null && input.fileText != null) input.content = input.fileText;
41951
+ if (toolName === "Edit" && input.diff == null && input.diffString != null) input.diff = input.diffString;
41952
+ } else if (toolName === "Bash") {
41953
+ if (input.command == null && input.cmd != null) input.command = input.cmd;
41954
+ } else if (toolName === "LS") {
41955
+ if (input.path == null && input.target_directory != null) input.path = input.target_directory;
41956
+ if (input.path == null && input.directory != null) input.path = input.directory;
41957
+ } else if (toolName === "Grep") {
41958
+ if (input.pattern == null && input.query != null) input.pattern = input.query;
41959
+ } else if (toolName === "Glob") {
41960
+ if (input.pattern == null && input.globPattern != null) input.pattern = input.globPattern;
41961
+ if (input.pattern == null && input.glob_pattern != null) input.pattern = input.glob_pattern;
41962
+ if (input.path == null && input.targetDirectory != null) input.path = input.targetDirectory;
41963
+ if (input.path == null && input.target_directory != null) input.path = input.target_directory;
41964
+ } else if (toolName === "WebFetch") {
41965
+ if (input.url == null && input.uri != null) input.url = input.uri;
41966
+ } else if (toolName === "WebSearch" || toolName === "SearchTools" || toolName === "ToolSearch" || toolName === "SemanticSearch") {
41967
+ if (input.query == null && input.q != null) input.query = input.q;
41968
+ }
41969
+ return { toolName, input };
41970
+ }
41934
41971
  function bytesOrStringToText(value) {
41935
41972
  if (typeof value === "string") return value;
41936
41973
  if (Array.isArray(value) && value.length > 0 && value.every((n) => typeof n === "number")) {
@@ -51717,6 +51754,7 @@ var init_cursor_custom_tools = __esm({
51717
51754
 
51718
51755
  // ../../packages/cursor/src/cursor-event-map.ts
51719
51756
  function toolDisplayName(name) {
51757
+ if (name.startsWith("mcp__")) return name;
51720
51758
  const n = name.toLowerCase();
51721
51759
  if (n.includes("shell") || n === "bash") return "Bash";
51722
51760
  if (n.includes("read") && !n.includes("lint")) return "Read";
@@ -51737,6 +51775,15 @@ function toolDisplayName(name) {
51737
51775
  if (n === "recordscreen") return "RecordScreen";
51738
51776
  return name;
51739
51777
  }
51778
+ function unwrapCursorMcpTool(toolType, args) {
51779
+ if (toolType.toLowerCase() !== "mcp") return { toolType, args };
51780
+ const rec = asRecord9(args);
51781
+ if (!rec) return { toolType, args };
51782
+ const server = typeof rec.providerIdentifier === "string" ? rec.providerIdentifier.trim() : "";
51783
+ const name = typeof rec.toolName === "string" ? rec.toolName.trim() : "";
51784
+ if (!server || !name) return { toolType, args };
51785
+ return { toolType: `mcp__${server}__${name}`, args: rec.args ?? {} };
51786
+ }
51740
51787
  function strField2(obj, key) {
51741
51788
  if (!obj || typeof obj !== "object") return "";
51742
51789
  const v2 = obj[key];
@@ -51809,19 +51856,37 @@ function mapTodosPayload(todos) {
51809
51856
  };
51810
51857
  }
51811
51858
  function toolUseEvent(messageId, callId, toolType, args, status) {
51859
+ const unwrapped = unwrapCursorMcpTool(toolType, args);
51860
+ const toolName = toolDisplayName(unwrapped.toolType);
51812
51861
  return {
51813
51862
  type: "content_delta",
51814
51863
  messageId,
51815
51864
  delta: {
51816
51865
  type: "tool_use",
51817
- toolName: toolDisplayName(toolType),
51866
+ toolName,
51818
51867
  toolUseId: callId,
51819
- input: stringifyPayload(args ?? {}),
51868
+ input: stringifyPayload(normalizeCursorToolInput(toolName, unwrapped.args)),
51820
51869
  status,
51821
51870
  ...status === "streaming" ? { startedAt: Date.now() } : {}
51822
51871
  }
51823
51872
  };
51824
51873
  }
51874
+ function normalizeCursorToolInput(toolName, args) {
51875
+ if (toolName.startsWith("mcp__")) return args;
51876
+ const rec = asRecord9(args);
51877
+ if (!rec) return args ?? {};
51878
+ return normalizeTranscriptTool(toolName, rec).input;
51879
+ }
51880
+ function mergeCursorToolResultArgs(toolType, args, result) {
51881
+ if (toolType.toLowerCase() === "mcp") return args;
51882
+ const res = asRecord9(result);
51883
+ const diff = typeof res?.diffString === "string" ? res.diffString : void 0;
51884
+ if (!diff) return args;
51885
+ const rec = asRecord9(args);
51886
+ if (!rec) return args;
51887
+ if (rec.diffString != null || rec.diff != null) return rec;
51888
+ return { ...rec, diffString: diff };
51889
+ }
51825
51890
  function toolResultEvent(messageId, callId, result, isError) {
51826
51891
  return {
51827
51892
  type: "content_delta",
@@ -51834,14 +51899,22 @@ function toolResultEvent(messageId, callId, result, isError) {
51834
51899
  }
51835
51900
  };
51836
51901
  }
51837
- function usageFromTurn(messageId, usage2, extras) {
51902
+ function billedInputTokens(usage2) {
51903
+ return usage2.inputTokens + usage2.cacheWriteTokens;
51904
+ }
51905
+ function contextTokensFromUsage(usage2) {
51906
+ return usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens;
51907
+ }
51908
+ function mapCursorTokenUsage(messageId, usage2, extras) {
51909
+ const contextTokens = extras?.contextTokens && extras.contextTokens > 0 ? extras.contextTokens : contextTokensFromUsage(usage2);
51838
51910
  return {
51839
51911
  type: "message_usage",
51840
51912
  messageId,
51841
- inputTokens: usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens,
51842
- outputTokens: usage2.outputTokens + (usage2.reasoningTokens ?? 0),
51913
+ inputTokens: billedInputTokens(usage2),
51914
+ outputTokens: usage2.outputTokens,
51843
51915
  cacheReadTokens: usage2.cacheReadTokens,
51844
- ...extras?.contextWindow && extras.contextWindow > 0 ? { contextWindow: extras.contextWindow, contextTokens: usage2.inputTokens + usage2.cacheReadTokens + usage2.cacheWriteTokens } : {}
51916
+ contextTokens,
51917
+ ...extras?.contextWindow && extras.contextWindow > 0 ? { contextWindow: extras.contextWindow } : {}
51845
51918
  };
51846
51919
  }
51847
51920
  function mapInteractionUpdate(messageId, update, options) {
@@ -51924,7 +51997,8 @@ function mapInteractionUpdate(messageId, update, options) {
51924
51997
  }
51925
51998
  case "tool-call-completed": {
51926
51999
  const parts = extractToolCallParts(update);
51927
- events.push(toolUseEvent(messageId, parts.callId, parts.toolType, parts.args, "complete"));
52000
+ const args = mergeCursorToolResultArgs(parts.toolType, parts.args, parts.result);
52001
+ events.push(toolUseEvent(messageId, parts.callId, parts.toolType, args, "complete"));
51928
52002
  events.push(toolResultEvent(messageId, parts.callId, parts.result, parts.isError));
51929
52003
  if (parts.toolType === "updateTodos" || parts.toolType === "update_todos") {
51930
52004
  const todos = asRecord9(parts.args)?.todos ?? asRecord9(parts.result)?.todos;
@@ -51945,13 +52019,13 @@ function mapInteractionUpdate(messageId, update, options) {
51945
52019
  case "token-delta": {
51946
52020
  const tokens = Number(update.tokens);
51947
52021
  if (Number.isFinite(tokens) && tokens > 0) {
52022
+ const turnUsage = options?.turnUsage;
52023
+ if (turnUsage) turnUsage.addTokenDelta(tokens);
51948
52024
  events.push({
51949
52025
  type: "message_usage",
51950
52026
  messageId,
51951
- inputTokens: tokens,
51952
- outputTokens: 0,
51953
- contextTokens: tokens,
51954
- ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
52027
+ inputTokens: turnUsage?.input ?? 0,
52028
+ outputTokens: turnUsage?.output ?? tokens
51955
52029
  });
51956
52030
  }
51957
52031
  break;
@@ -51959,7 +52033,21 @@ function mapInteractionUpdate(messageId, update, options) {
51959
52033
  case "turn-ended": {
51960
52034
  const usage2 = update.usage;
51961
52035
  if (usage2) {
51962
- events.push(usageFromTurn(messageId, usage2, { contextWindow: options?.contextWindow }));
52036
+ const turnUsage = options?.turnUsage;
52037
+ if (turnUsage) {
52038
+ turnUsage.applyInternalTurn(usage2);
52039
+ events.push({
52040
+ type: "message_usage",
52041
+ messageId,
52042
+ inputTokens: turnUsage.input,
52043
+ outputTokens: turnUsage.output,
52044
+ cacheReadTokens: usage2.cacheReadTokens,
52045
+ contextTokens: turnUsage.context,
52046
+ ...options?.contextWindow && options.contextWindow > 0 ? { contextWindow: options.contextWindow } : {}
52047
+ });
52048
+ } else {
52049
+ events.push(mapCursorTokenUsage(messageId, usage2, { contextWindow: options?.contextWindow }));
52050
+ }
51963
52051
  }
51964
52052
  events.push({ type: "status_change", status: "idle" });
51965
52053
  break;
@@ -52032,7 +52120,15 @@ function mapConversationStep(messageId, step, options) {
52032
52120
  }
52033
52121
  const toolType = nested && typeof nested.type === "string" && nested.type ? nested.type : strField2(rec, "name") || "Tool";
52034
52122
  const args = nested?.args ?? nested?.input ?? {};
52035
- events.push(toolUseEvent(messageId, callId, toolType, args, "complete"));
52123
+ const resultRec = asRecord9(nested?.result);
52124
+ const resultValue = resultRec?.status === "success" ? resultRec.value ?? nested?.result : nested?.result;
52125
+ events.push(toolUseEvent(
52126
+ messageId,
52127
+ callId,
52128
+ toolType,
52129
+ mergeCursorToolResultArgs(toolType, args, resultValue),
52130
+ "complete"
52131
+ ));
52036
52132
  if (toolType === "updateTodos" || toolType === "update_todos") {
52037
52133
  const todos = asRecord9(args)?.todos;
52038
52134
  const todoEvent = mapTodosPayload(todos);
@@ -52064,7 +52160,7 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52064
52160
  }
52065
52161
  case "usage": {
52066
52162
  const u = message.usage;
52067
- events.push(usageFromTurn(messageId, {
52163
+ events.push(mapCursorTokenUsage(messageId, {
52068
52164
  inputTokens: u.inputTokens,
52069
52165
  outputTokens: u.outputTokens,
52070
52166
  cacheReadTokens: u.cacheReadTokens,
@@ -52097,17 +52193,7 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52097
52193
  delta: { type: "text", text: block.text }
52098
52194
  });
52099
52195
  } 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
- });
52196
+ events.push(toolUseEvent(messageId, block.id, block.name, block.input, "streaming"));
52111
52197
  }
52112
52198
  }
52113
52199
  }
@@ -52139,35 +52225,39 @@ function mapSdkMessageLifecycle(messageId, message, options) {
52139
52225
  return events;
52140
52226
  }
52141
52227
  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
- }];
52228
+ const status = message.status === "completed" || message.status === "error" ? "complete" : "streaming";
52229
+ const args = status === "complete" ? mergeCursorToolResultArgs(message.name, message.args, message.result) : message.args;
52230
+ const events = [
52231
+ toolUseEvent(messageId, message.call_id, message.name, args, status)
52232
+ ];
52153
52233
  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
- });
52234
+ events.push(toolResultEvent(messageId, message.call_id, message.result, message.status === "error"));
52164
52235
  }
52165
52236
  return events;
52166
52237
  }
52167
- var CursorTurnCallIdBridge;
52238
+ var CursorTurnUsage, CursorTurnCallIdBridge;
52168
52239
  var init_cursor_event_map = __esm({
52169
52240
  "../../packages/cursor/src/cursor-event-map.ts"() {
52170
52241
  "use strict";
52242
+ init_tool_ui();
52243
+ CursorTurnUsage = class {
52244
+ input = 0;
52245
+ output = 0;
52246
+ context = 0;
52247
+ addTokenDelta(tokens) {
52248
+ if (Number.isFinite(tokens) && tokens > 0) this.output += tokens;
52249
+ }
52250
+ applyInternalTurn(usage2) {
52251
+ this.input += billedInputTokens(usage2);
52252
+ if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
52253
+ this.context = contextTokensFromUsage(usage2);
52254
+ }
52255
+ applyRunTotals(usage2) {
52256
+ const billed = billedInputTokens(usage2);
52257
+ if (billed > this.input) this.input = billed;
52258
+ if (usage2.outputTokens > this.output) this.output = usage2.outputTokens;
52259
+ }
52260
+ };
52171
52261
  CursorTurnCallIdBridge = class {
52172
52262
  queue = [];
52173
52263
  seen = /* @__PURE__ */ new Set();
@@ -53090,6 +53180,7 @@ async function createCursorRuntime(opts) {
53090
53180
  lastMcpServers = servers;
53091
53181
  const contextWindow = resolveContextWindow(modelSelection);
53092
53182
  const callIdBridge = new CursorTurnCallIdBridge();
53183
+ const turnUsage = new CursorTurnUsage();
53093
53184
  const sendStarted = Date.now();
53094
53185
  log2.info("[CursorRuntime] send start", { messageId });
53095
53186
  tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
@@ -53106,7 +53197,7 @@ async function createCursorRuntime(opts) {
53106
53197
  onDelta: ({ update }) => {
53107
53198
  tracer.sdk(cursorSdkType(update, "delta"), update, messageId);
53108
53199
  callIdBridge.observeDelta(update);
53109
- for (const event of mapInteractionUpdate(messageId, update, { contextWindow })) {
53200
+ for (const event of mapInteractionUpdate(messageId, update, { contextWindow, turnUsage })) {
53110
53201
  opts.onEvent(event);
53111
53202
  }
53112
53203
  },
@@ -53209,17 +53300,16 @@ async function createCursorRuntime(opts) {
53209
53300
  currentRun = null;
53210
53301
  lastRunId = result.id || lastRunId;
53211
53302
  if (result.usage) {
53303
+ turnUsage.applyRunTotals(result.usage);
53212
53304
  opts.onEvent({
53213
53305
  type: "message_usage",
53214
53306
  messageId,
53215
- inputTokens: result.usage.inputTokens + result.usage.cacheReadTokens + result.usage.cacheWriteTokens,
53216
- outputTokens: result.usage.outputTokens + (result.usage.reasoningTokens ?? 0),
53307
+ inputTokens: turnUsage.input,
53308
+ outputTokens: turnUsage.output,
53217
53309
  cacheReadTokens: result.usage.cacheReadTokens,
53218
53310
  model: result.model?.id ?? modelSelection?.id,
53219
- ...contextWindow && contextWindow > 0 ? {
53220
- contextWindow,
53221
- contextTokens: result.usage.inputTokens + result.usage.cacheReadTokens + result.usage.cacheWriteTokens
53222
- } : {}
53311
+ ...turnUsage.context > 0 ? { contextTokens: turnUsage.context } : {},
53312
+ ...contextWindow && contextWindow > 0 ? { contextWindow } : {}
53223
53313
  });
53224
53314
  }
53225
53315
  if (result.git?.branches?.length) {
@@ -61149,8 +61239,8 @@ import { fileURLToPath } from "node:url";
61149
61239
  function resolveCliReleaseVersion() {
61150
61240
  const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
61151
61241
  if (fromEnv) return fromEnv;
61152
- if ("0.53.6-alpha".trim()) {
61153
- return "0.53.6-alpha".trim();
61242
+ if ("0.53.7-alpha".trim()) {
61243
+ return "0.53.7-alpha".trim();
61154
61244
  }
61155
61245
  const fromDist = readDistManifestVersion();
61156
61246
  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.7-alpha",
4
4
  "description": "SuperOne headless node CLI — remote execution environment (RPC, workspaces, sessions).",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",