@sideboard-ai/core 0.1.117 → 0.1.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/agents/cursor-runner.cjs +59 -0
  2. package/dist/agents/cursor-runner.js +24 -2
  3. package/dist/{agents-GUEKGV7V.js → agents-DRJMECCE.js} +11 -7
  4. package/dist/{agents-OCGAZCKT.js → agents-U5PWL3AJ.js} +10 -6
  5. package/dist/{app-settings-5XAGNDX7.js → app-settings-IKFWZDUK.js} +3 -1
  6. package/dist/{app-settings-J4LUWIRN.js → app-settings-YFWV7MOG.js} +3 -1
  7. package/dist/{chunk-X3NIPGQT.js → chunk-2X7I6MDW.js} +5 -5
  8. package/dist/{chunk-NZBDVBCP.js → chunk-3M5CVKHK.js} +42 -0
  9. package/dist/{chunk-SGEVS5SY.js → chunk-BMIRX64H.js} +10 -0
  10. package/dist/{chunk-5X7GRP5W.js → chunk-EQHXMN7O.js} +69 -27
  11. package/dist/{chunk-4NR5FL46.js → chunk-FXQPY2KU.js} +10 -0
  12. package/dist/{chunk-U3IVCVLH.js → chunk-HZLE6LJJ.js} +2 -2
  13. package/dist/{chunk-74YJHND6.js → chunk-KRM3A5UK.js} +67 -26
  14. package/dist/{chunk-4WV7C7WP.js → chunk-KWGP6RZM.js} +3 -3
  15. package/dist/{chunk-4NAW5BAQ.js → chunk-O43IRQ2Y.js} +3 -3
  16. package/dist/{chunk-4CDCTYTM.js → chunk-OEBYW4TO.js} +201 -66
  17. package/dist/{chunk-WCU3FHEI.js → chunk-OHEFHIG3.js} +1 -1
  18. package/dist/{chunk-YJ2WV5TZ.js → chunk-QHST4DZQ.js} +168 -67
  19. package/dist/{chunk-BKVDZV7X.js → chunk-RBVVWBVB.js} +2 -2
  20. package/dist/{chunk-XTZQL7OU.js → chunk-TRTWH6C2.js} +5 -5
  21. package/dist/{chunk-VGPLXQIH.js → chunk-UAVZ2JSO.js} +1 -1
  22. package/dist/{coordinator-prompt-QMV6YEP5.js → coordinator-prompt-AZ3WRDNC.js} +3 -3
  23. package/dist/{coordinator-prompt-XCBHAOGE.js → coordinator-prompt-LEU62W25.js} +3 -3
  24. package/dist/{global-workspace-Z37MNYU6.js → global-workspace-4YNYDMLQ.js} +4 -4
  25. package/dist/{global-workspace-SBKXKQFS.js → global-workspace-U5UOVXKQ.js} +4 -4
  26. package/dist/index.cjs +276 -79
  27. package/dist/index.d.cts +61 -7
  28. package/dist/index.d.ts +61 -7
  29. package/dist/index.js +30 -17
  30. package/dist/mcp/run-stdio.cjs +266 -79
  31. package/dist/mcp/run-stdio.js +19 -16
  32. package/dist/{orchestrator-4PKR6AZJ.js → orchestrator-EYU7OUFA.js} +7 -7
  33. package/dist/{orchestrator-MKTZYWTI.js → orchestrator-JE5MSVED.js} +8 -8
  34. package/dist/{workspaces-C3TJJFY3.js → workspaces-ICK433ZV.js} +5 -5
  35. package/dist/{workspaces-M4OICPWF.js → workspaces-POWKTH2D.js} +5 -5
  36. package/dist/{worktree-MRSTQ32S.js → worktree-CMGBTVN4.js} +2 -2
  37. package/dist/{worktree-7AEKZSEX.js → worktree-T57RD7BQ.js} +2 -2
  38. package/package.json +1 -1
@@ -9,13 +9,13 @@ import {
9
9
  } from "./chunk-YMRT2DU6.js";
10
10
  import {
11
11
  isOrchestratorThread
12
- } from "./chunk-4NAW5BAQ.js";
12
+ } from "./chunk-O43IRQ2Y.js";
13
13
  import {
14
14
  codexUnattendedGitConfigArgs,
15
15
  mergeAgentGitAuthEnv,
16
16
  resolveAgentGitAuthEnv,
17
17
  resolveCodexGitWritableRoots
18
- } from "./chunk-WCU3FHEI.js";
18
+ } from "./chunk-OHEFHIG3.js";
19
19
  import {
20
20
  enrichPathWithNpmGlobalBin,
21
21
  isConductorBundledCli,
@@ -31,7 +31,7 @@ import {
31
31
  resolveClaudeExecutable,
32
32
  unwrapStrippedElectronLaunch,
33
33
  wrapElectronAsNodeLaunch
34
- } from "./chunk-SGEVS5SY.js";
34
+ } from "./chunk-BMIRX64H.js";
35
35
  import {
36
36
  appDataDir
37
37
  } from "./chunk-BD2ICC4D.js";
@@ -65,18 +65,53 @@ function mergeUsage(a, b) {
65
65
  outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
66
66
  cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
67
67
  cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
68
+ costUsd: sumOptional(a?.costUsd, b.costUsd),
68
69
  lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
69
70
  };
70
71
  }
72
+ function sumUsageList(list) {
73
+ let acc = null;
74
+ for (const u of list) {
75
+ if (!u) continue;
76
+ acc = mergeUsage(acc, {
77
+ inputTokens: u.inputTokens,
78
+ outputTokens: u.outputTokens,
79
+ cacheReadTokens: u.cacheReadTokens,
80
+ cacheWriteTokens: u.cacheWriteTokens,
81
+ costUsd: u.costUsd
82
+ });
83
+ }
84
+ if (!acc) return null;
85
+ return {
86
+ inputTokens: acc.inputTokens,
87
+ outputTokens: acc.outputTokens,
88
+ ...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
89
+ ...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
90
+ ...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
91
+ };
92
+ }
93
+ function hasBilledTokens(u) {
94
+ return Boolean(
95
+ u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
96
+ );
97
+ }
71
98
  function applyTurnUsage(current, incoming, scope = "request") {
72
99
  if (scope === "turn") {
100
+ if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
101
+ return { ...current, costUsd: incoming.costUsd };
102
+ }
73
103
  return {
74
104
  ...incoming,
105
+ costUsd: incoming.costUsd ?? current?.costUsd,
75
106
  lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
76
107
  };
77
108
  }
78
109
  const merged = mergeUsage(current, incoming);
79
- return { ...merged, lastRequestTokens: requestOccupancy(incoming) };
110
+ const occ = requestOccupancy(incoming);
111
+ return {
112
+ ...merged,
113
+ lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
114
+ };
80
115
  }
81
116
  function contextTokens(u) {
82
117
  if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
@@ -362,11 +397,16 @@ ${prompt}`;
362
397
  // src/agents/brightsy.ts
363
398
  function usageFromBrightsy(usage) {
364
399
  if (!usage) return null;
365
- return fromInclusiveInputUsage({
400
+ const mapped = fromInclusiveInputUsage({
366
401
  inputTokens: Number(usage.prompt_tokens ?? 0),
367
402
  outputTokens: Number(usage.completion_tokens ?? 0),
368
403
  cachedInputTokens: Number(usage.prompt_tokens_details?.cached_tokens ?? 0)
369
404
  });
405
+ if (!mapped) return null;
406
+ if (usage.cost != null && Number.isFinite(Number(usage.cost))) {
407
+ mapped.costUsd = Number(usage.cost);
408
+ }
409
+ return mapped;
370
410
  }
371
411
  function parseBrightsyCliLine(line) {
372
412
  const trimmed = line.trim();
@@ -903,6 +943,11 @@ function parseDiffStat(result) {
903
943
  }
904
944
  return {};
905
945
  }
946
+ function withPartTimes(next, prev) {
947
+ const now = Date.now();
948
+ const startedAt = prev && typeof prev.startedAt === "number" ? prev.startedAt : now;
949
+ return { ...next, startedAt, updatedAt: now };
950
+ }
906
951
  function applyAgentEvent(parts, event) {
907
952
  if (event.type === "stdout") {
908
953
  const data = event.data;
@@ -910,17 +955,22 @@ function applyAgentEvent(parts, event) {
910
955
  const next = [...parts];
911
956
  const last = next[next.length - 1];
912
957
  if (last?.type === "text" && sameParentId(last.parentId, event.parentId)) {
913
- next[next.length - 1] = {
914
- type: "text",
915
- text: last.text + data,
916
- ...event.parentId ? { parentId: event.parentId } : {}
917
- };
958
+ next[next.length - 1] = withPartTimes(
959
+ {
960
+ type: "text",
961
+ text: last.text + data,
962
+ ...event.parentId ? { parentId: event.parentId } : {}
963
+ },
964
+ last
965
+ );
918
966
  } else {
919
- next.push({
920
- type: "text",
921
- text: data,
922
- ...event.parentId ? { parentId: event.parentId } : {}
923
- });
967
+ next.push(
968
+ withPartTimes({
969
+ type: "text",
970
+ text: data,
971
+ ...event.parentId ? { parentId: event.parentId } : {}
972
+ })
973
+ );
924
974
  }
925
975
  return next;
926
976
  }
@@ -932,34 +982,44 @@ function applyAgentEvent(parts, event) {
932
982
  for (let i = next.length - 1; i >= 0; i--) {
933
983
  const prev = next[i];
934
984
  if (prev?.type === "thinking" && sameParentId(prev.parentId, event.parentId)) {
935
- next[i] = {
936
- type: "thinking",
937
- text: data,
938
- ...event.parentId ? { parentId: event.parentId } : {}
939
- };
985
+ next[i] = withPartTimes(
986
+ {
987
+ type: "thinking",
988
+ text: data,
989
+ ...event.parentId ? { parentId: event.parentId } : {}
990
+ },
991
+ prev
992
+ );
940
993
  return next;
941
994
  }
942
995
  }
943
- next.push({
944
- type: "thinking",
945
- text: data,
946
- ...event.parentId ? { parentId: event.parentId } : {}
947
- });
996
+ next.push(
997
+ withPartTimes({
998
+ type: "thinking",
999
+ text: data,
1000
+ ...event.parentId ? { parentId: event.parentId } : {}
1001
+ })
1002
+ );
948
1003
  return next;
949
1004
  }
950
1005
  const last = next[next.length - 1];
951
1006
  if (last?.type === "thinking" && sameParentId(last.parentId, event.parentId)) {
952
- next[next.length - 1] = {
953
- type: "thinking",
954
- text: last.text + data,
955
- ...event.parentId ? { parentId: event.parentId } : {}
956
- };
1007
+ next[next.length - 1] = withPartTimes(
1008
+ {
1009
+ type: "thinking",
1010
+ text: last.text + data,
1011
+ ...event.parentId ? { parentId: event.parentId } : {}
1012
+ },
1013
+ last
1014
+ );
957
1015
  } else {
958
- next.push({
959
- type: "thinking",
960
- text: data,
961
- ...event.parentId ? { parentId: event.parentId } : {}
962
- });
1016
+ next.push(
1017
+ withPartTimes({
1018
+ type: "thinking",
1019
+ text: data,
1020
+ ...event.parentId ? { parentId: event.parentId } : {}
1021
+ })
1022
+ );
963
1023
  }
964
1024
  return next;
965
1025
  }
@@ -975,22 +1035,25 @@ function applyAgentEvent(parts, event) {
975
1035
  ...input ?? {}
976
1036
  };
977
1037
  const mergedRecord = Object.keys(mergedInput).length > 0 ? mergedInput : void 0;
978
- next[existing] = {
979
- ...prev,
980
- name: event.name || prev.name,
981
- input: mergedRecord,
982
- description: toolDescription(event.name || prev.name, mergedRecord),
983
- detail: toolDetail(event.name || prev.name, mergedRecord) ?? prev.detail,
984
- filePath: toolFilePath(mergedRecord) ?? prev.filePath,
985
- additions: diff.additions ?? prev.additions,
986
- deletions: diff.deletions ?? prev.deletions,
987
- parentId: event.parentId ?? prev.parentId
988
- };
1038
+ next[existing] = withPartTimes(
1039
+ {
1040
+ ...prev,
1041
+ name: event.name || prev.name,
1042
+ input: mergedRecord,
1043
+ description: toolDescription(event.name || prev.name, mergedRecord),
1044
+ detail: toolDetail(event.name || prev.name, mergedRecord) ?? prev.detail,
1045
+ filePath: toolFilePath(mergedRecord) ?? prev.filePath,
1046
+ additions: diff.additions ?? prev.additions,
1047
+ deletions: diff.deletions ?? prev.deletions,
1048
+ parentId: event.parentId ?? prev.parentId
1049
+ },
1050
+ prev
1051
+ );
989
1052
  return next;
990
1053
  }
991
1054
  return [
992
1055
  ...parts,
993
- {
1056
+ withPartTimes({
994
1057
  type: "tool",
995
1058
  id: event.id,
996
1059
  name: event.name,
@@ -1001,7 +1064,7 @@ function applyAgentEvent(parts, event) {
1001
1064
  filePath: toolFilePath(input),
1002
1065
  ...event.parentId ? { parentId: event.parentId } : {},
1003
1066
  ...diff
1004
- }
1067
+ })
1005
1068
  ];
1006
1069
  }
1007
1070
  if (event.type === "tool_result") {
@@ -1011,7 +1074,7 @@ function applyAgentEvent(parts, event) {
1011
1074
  if (existing < 0) {
1012
1075
  return [
1013
1076
  ...parts,
1014
- {
1077
+ withPartTimes({
1015
1078
  type: "tool",
1016
1079
  id: event.id,
1017
1080
  name: "tool",
@@ -1019,22 +1082,25 @@ function applyAgentEvent(parts, event) {
1019
1082
  status: event.isError ? "error" : "running",
1020
1083
  result: event.content,
1021
1084
  ...event.parentId ? { parentId: event.parentId } : {}
1022
- }
1085
+ })
1023
1086
  ];
1024
1087
  }
1025
1088
  return parts.map((p, i) => {
1026
1089
  if (i !== existing || p.type !== "tool") return p;
1027
1090
  if (p.status === "done" || p.status === "error") return p;
1028
- return {
1029
- ...p,
1030
- result: event.content ?? p.result
1031
- };
1091
+ return withPartTimes(
1092
+ {
1093
+ ...p,
1094
+ result: event.content ?? p.result
1095
+ },
1096
+ p
1097
+ );
1032
1098
  });
1033
1099
  }
1034
1100
  if (existing < 0) {
1035
1101
  return [
1036
1102
  ...parts,
1037
- {
1103
+ withPartTimes({
1038
1104
  type: "tool",
1039
1105
  id: event.id,
1040
1106
  name: "tool",
@@ -1044,18 +1110,21 @@ function applyAgentEvent(parts, event) {
1044
1110
  ...event.parentId ? { parentId: event.parentId } : {},
1045
1111
  ...fromResult.additions != null ? { additions: fromResult.additions } : {},
1046
1112
  ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
1047
- }
1113
+ })
1048
1114
  ];
1049
1115
  }
1050
1116
  return parts.map((p, i) => {
1051
1117
  if (i !== existing || p.type !== "tool") return p;
1052
- return {
1053
- ...p,
1054
- status: event.isError ? "error" : "done",
1055
- result: event.content,
1056
- ...fromResult.additions != null ? { additions: fromResult.additions } : {},
1057
- ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
1058
- };
1118
+ return withPartTimes(
1119
+ {
1120
+ ...p,
1121
+ status: event.isError ? "error" : "done",
1122
+ result: event.content,
1123
+ ...fromResult.additions != null ? { additions: fromResult.additions } : {},
1124
+ ...fromResult.deletions != null ? { deletions: fromResult.deletions } : {}
1125
+ },
1126
+ p
1127
+ );
1059
1128
  });
1060
1129
  }
1061
1130
  return parts;
@@ -1708,6 +1777,28 @@ function usageFromClaude(usage) {
1708
1777
  cacheWriteTokens: cacheWriteTokens || void 0
1709
1778
  };
1710
1779
  }
1780
+ function costUsdFromClaudeResult(obj) {
1781
+ const modelUsage = obj.modelUsage ?? obj.model_usage;
1782
+ if (modelUsage && typeof modelUsage === "object") {
1783
+ let sum = 0;
1784
+ let any = false;
1785
+ for (const entry of Object.values(modelUsage)) {
1786
+ if (!entry || typeof entry !== "object") continue;
1787
+ const row = entry;
1788
+ const cost = row.costUSD ?? row.cost_usd;
1789
+ if (cost != null && Number.isFinite(Number(cost))) {
1790
+ sum += Number(cost);
1791
+ any = true;
1792
+ }
1793
+ }
1794
+ if (any) return sum;
1795
+ }
1796
+ const totalCost = obj.total_cost_usd ?? obj.totalCostUsd;
1797
+ if (totalCost != null && Number.isFinite(Number(totalCost))) {
1798
+ return Number(totalCost);
1799
+ }
1800
+ return void 0;
1801
+ }
1711
1802
  function claudeResultErrorDetail(obj) {
1712
1803
  const isError = Boolean(obj.is_error) || typeof obj.subtype === "string" && /^error/i.test(obj.subtype);
1713
1804
  const fromResult = typeof obj.result === "string" ? obj.result.trim() : "";
@@ -1913,7 +2004,7 @@ var claudeAdapter = {
1913
2004
  );
1914
2005
  }
1915
2006
  const mode = permissionMode(thread);
1916
- const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-Z37MNYU6.js");
2007
+ const { isOrchestratorThread: isOrchestratorThread2 } = await import("./global-workspace-4YNYDMLQ.js");
1917
2008
  const isOrchestrator = isOrchestratorThread2(thread);
1918
2009
  const injectedServers = await buildInjectedMcpServers({
1919
2010
  includeSideboard: true,
@@ -2060,7 +2151,11 @@ var claudeAdapter = {
2060
2151
  if (typeof text === "string" && text) events.push({ type: "stdout", data: text });
2061
2152
  }
2062
2153
  const usage = usageFromClaude(obj.usage);
2063
- if (usage) events.push({ type: "usage", data: usage, scope: "turn" });
2154
+ if (usage) {
2155
+ const costUsd = costUsdFromClaudeResult(obj);
2156
+ if (costUsd != null) usage.costUsd = costUsd;
2157
+ events.push({ type: "usage", data: usage, scope: "turn" });
2158
+ }
2064
2159
  if (events.length === 0) return null;
2065
2160
  return events.length === 1 ? events[0] : events;
2066
2161
  }
@@ -2515,6 +2610,38 @@ function usageFromCursor(usage) {
2515
2610
  cacheWriteTokens: usage.cacheWriteTokens ? Number(usage.cacheWriteTokens) : void 0
2516
2611
  };
2517
2612
  }
2613
+ function preferredCursorCostCents(cost) {
2614
+ if (!cost) return void 0;
2615
+ const charged = Number(cost.chargedCents);
2616
+ const raw = Number(cost.rawCostCents);
2617
+ if (Number.isFinite(charged) && charged > 0) return charged;
2618
+ if (Number.isFinite(raw) && raw > 0) return raw;
2619
+ if (Number.isFinite(charged)) return charged;
2620
+ if (Number.isFinite(raw)) return raw;
2621
+ return void 0;
2622
+ }
2623
+ function turnCostUsdFromCursorUsage(before, after) {
2624
+ if (!after) return void 0;
2625
+ const beforeIds = new Set((before?.runs ?? []).map((r) => r.runId));
2626
+ const newRuns = (after.runs ?? []).filter((r) => !beforeIds.has(r.runId));
2627
+ let sum = 0;
2628
+ let any = false;
2629
+ for (const r of newRuns) {
2630
+ const c = preferredCursorCostCents(r.cost);
2631
+ if (c != null) {
2632
+ sum += c;
2633
+ any = true;
2634
+ }
2635
+ }
2636
+ if (any) return sum / 100;
2637
+ if (before == null) return void 0;
2638
+ const afterCents = preferredCursorCostCents(after.cost);
2639
+ if (afterCents == null) return void 0;
2640
+ const beforeCents = preferredCursorCostCents(before.cost) ?? 0;
2641
+ const delta = afterCents - beforeCents;
2642
+ if (!(delta >= 0) || !Number.isFinite(delta)) return void 0;
2643
+ return delta / 100;
2644
+ }
2518
2645
  function asRecord3(value) {
2519
2646
  if (value && typeof value === "object" && !Array.isArray(value)) {
2520
2647
  return value;
@@ -3179,7 +3306,12 @@ var opencodeAdapter = {
3179
3306
  const usage = usageFromOpencode(
3180
3307
  part?.tokens ?? obj.tokens
3181
3308
  );
3182
- return usage ? { type: "usage", data: usage, scope: "request" } : null;
3309
+ if (!usage) return null;
3310
+ const cost = part?.cost ?? obj.cost;
3311
+ if (cost != null && Number.isFinite(Number(cost))) {
3312
+ usage.costUsd = Number(cost);
3313
+ }
3314
+ return { type: "usage", data: usage, scope: "request" };
3183
3315
  }
3184
3316
  return null;
3185
3317
  } catch {
@@ -3691,6 +3823,7 @@ export {
3691
3823
  fallbackTurnFailDetail,
3692
3824
  turnFailChatText,
3693
3825
  formatTurnExitError,
3826
+ sumUsageList,
3694
3827
  applyTurnUsage,
3695
3828
  contextTokens,
3696
3829
  encodeBrightsyTarget,
@@ -3714,6 +3847,8 @@ export {
3714
3847
  claudeAdapter,
3715
3848
  listCodexModels,
3716
3849
  codexAdapter,
3850
+ preferredCursorCostCents,
3851
+ turnCostUsdFromCursorUsage,
3717
3852
  cursorSdkMessageToEvents,
3718
3853
  parseCursorRunnerLine,
3719
3854
  isCursorAutoModel,
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  getGithubGitAuthMode,
16
16
  getGithubPat
17
- } from "./chunk-SGEVS5SY.js";
17
+ } from "./chunk-BMIRX64H.js";
18
18
  import {
19
19
  worktreesRoot
20
20
  } from "./chunk-BD2ICC4D.js";