dsh-agent-enhancer 0.2.0 → 0.3.0

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 (113) hide show
  1. package/README.en.md +41 -34
  2. package/README.md +41 -34
  3. package/lib/client/context/chart.d.ts +21 -0
  4. package/lib/client/context/chart.d.ts.map +1 -0
  5. package/lib/client/context/dock.d.ts +10 -0
  6. package/lib/client/context/dock.d.ts.map +1 -0
  7. package/lib/client/context/enhance-meter.d.ts +12 -0
  8. package/lib/client/context/enhance-meter.d.ts.map +1 -0
  9. package/lib/client/context/format.d.ts +3 -0
  10. package/lib/client/context/format.d.ts.map +1 -0
  11. package/lib/client/context/icons.d.ts +10 -0
  12. package/lib/client/context/icons.d.ts.map +1 -0
  13. package/lib/client/context/open-tab.d.ts +16 -0
  14. package/lib/client/context/open-tab.d.ts.map +1 -0
  15. package/lib/client/context/right-tab.d.ts +14 -0
  16. package/lib/client/context/right-tab.d.ts.map +1 -0
  17. package/lib/client/context/tab.d.ts +15 -0
  18. package/lib/client/context/tab.d.ts.map +1 -0
  19. package/lib/client/context/title.d.ts +5 -0
  20. package/lib/client/context/title.d.ts.map +1 -0
  21. package/lib/client/dsh/controls.d.ts.map +1 -1
  22. package/lib/client/dsh/model-catalog.d.ts +7 -0
  23. package/lib/client/dsh/model-catalog.d.ts.map +1 -1
  24. package/lib/client/dsh/model-pill-label.d.ts +21 -0
  25. package/lib/client/dsh/model-pill-label.d.ts.map +1 -0
  26. package/lib/client/dsh/provider-balance-chip.d.ts +9 -0
  27. package/lib/client/dsh/provider-balance-chip.d.ts.map +1 -0
  28. package/lib/client/dsh/settings.d.ts +3 -0
  29. package/lib/client/dsh/settings.d.ts.map +1 -1
  30. package/lib/client/dsh/usage-chart.d.ts +28 -0
  31. package/lib/client/dsh/usage-chart.d.ts.map +1 -0
  32. package/lib/client/dsh/usage-dock.d.ts +8 -0
  33. package/lib/client/dsh/usage-dock.d.ts.map +1 -0
  34. package/lib/client/dsh/usage-format.d.ts +5 -0
  35. package/lib/client/dsh/usage-format.d.ts.map +1 -0
  36. package/lib/client/dsh/usage-kind.d.ts +8 -0
  37. package/lib/client/dsh/usage-kind.d.ts.map +1 -0
  38. package/lib/client/dsh/usage-meter.d.ts +16 -0
  39. package/lib/client/dsh/usage-meter.d.ts.map +1 -0
  40. package/lib/client/dsh/usage-panel.d.ts +8 -0
  41. package/lib/client/dsh/usage-panel.d.ts.map +1 -0
  42. package/lib/client/dsh/usage-tab.d.ts +11 -0
  43. package/lib/client/dsh/usage-tab.d.ts.map +1 -0
  44. package/lib/client/index.d.ts.map +1 -1
  45. package/lib/client/locales.d.ts +281 -3
  46. package/lib/client/locales.d.ts.map +1 -1
  47. package/lib/client/remote.d.ts +28 -1
  48. package/lib/client/remote.d.ts.map +1 -1
  49. package/lib/client.js +3130 -207
  50. package/lib/client.js.map +1 -1
  51. package/lib/config.d.ts +21 -2
  52. package/lib/config.d.ts.map +1 -1
  53. package/lib/errors.d.ts +1 -1
  54. package/lib/errors.d.ts.map +1 -1
  55. package/lib/host/auto-route/classifier.d.ts +5 -0
  56. package/lib/host/auto-route/classifier.d.ts.map +1 -0
  57. package/lib/host/auto-route/heuristic.d.ts +16 -0
  58. package/lib/host/auto-route/heuristic.d.ts.map +1 -0
  59. package/lib/host/auto-route/router.d.ts +15 -0
  60. package/lib/host/auto-route/router.d.ts.map +1 -0
  61. package/lib/host/auto-route/sentinel.d.ts +7 -0
  62. package/lib/host/auto-route/sentinel.d.ts.map +1 -0
  63. package/lib/host/auto-route/session-hook.d.ts +6 -0
  64. package/lib/host/auto-route/session-hook.d.ts.map +1 -0
  65. package/lib/host/auto-route/session-resolved-route.d.ts +7 -0
  66. package/lib/host/auto-route/session-resolved-route.d.ts.map +1 -0
  67. package/lib/host/auto-route/session-selection.d.ts +10 -0
  68. package/lib/host/auto-route/session-selection.d.ts.map +1 -0
  69. package/lib/host/auto-route/session-turn-hint.d.ts +8 -0
  70. package/lib/host/auto-route/session-turn-hint.d.ts.map +1 -0
  71. package/lib/host/auto-route/types.d.ts +18 -0
  72. package/lib/host/auto-route/types.d.ts.map +1 -0
  73. package/lib/host/context-compact.d.ts +42 -0
  74. package/lib/host/context-compact.d.ts.map +1 -0
  75. package/lib/host/context-inspect.d.ts +46 -0
  76. package/lib/host/context-inspect.d.ts.map +1 -0
  77. package/lib/host/index.d.ts +57 -1
  78. package/lib/host/index.d.ts.map +1 -1
  79. package/lib/host/model.d.ts +9 -1
  80. package/lib/host/model.d.ts.map +1 -1
  81. package/lib/host/rpc.d.ts +179 -0
  82. package/lib/host/rpc.d.ts.map +1 -1
  83. package/lib/host/update/check.d.ts +32 -0
  84. package/lib/host/update/check.d.ts.map +1 -0
  85. package/lib/host/update/cli.d.ts +15 -0
  86. package/lib/host/update/cli.d.ts.map +1 -0
  87. package/lib/host/update/install-kind.d.ts +3 -0
  88. package/lib/host/update/install-kind.d.ts.map +1 -0
  89. package/lib/host/update/registry.d.ts +16 -0
  90. package/lib/host/update/registry.d.ts.map +1 -0
  91. package/lib/host/update/semver.d.ts +2 -0
  92. package/lib/host/update/semver.d.ts.map +1 -0
  93. package/lib/host/update/types.d.ts +17 -0
  94. package/lib/host/update/types.d.ts.map +1 -0
  95. package/lib/host/usage/balance.d.ts +113 -0
  96. package/lib/host/usage/balance.d.ts.map +1 -0
  97. package/lib/host/usage/history.d.ts +23 -0
  98. package/lib/host/usage/history.d.ts.map +1 -0
  99. package/lib/host/usage/ledger.d.ts +20 -0
  100. package/lib/host/usage/ledger.d.ts.map +1 -0
  101. package/lib/host/usage/observe.d.ts +9 -0
  102. package/lib/host/usage/observe.d.ts.map +1 -0
  103. package/lib/host/usage/pricing.d.ts +55 -0
  104. package/lib/host/usage/pricing.d.ts.map +1 -0
  105. package/lib/host/usage/source.d.ts +14 -0
  106. package/lib/host/usage/source.d.ts.map +1 -0
  107. package/lib/host/usage/summarize.d.ts +7 -0
  108. package/lib/host/usage/summarize.d.ts.map +1 -0
  109. package/lib/host/usage/types.d.ts +105 -0
  110. package/lib/host/usage/types.d.ts.map +1 -0
  111. package/lib/index.js +3151 -356
  112. package/lib/index.js.map +4 -4
  113. package/package.json +26 -3
package/lib/client.js CHANGED
@@ -26,10 +26,14 @@ __export(index_exports, {
26
26
  inject: () => inject
27
27
  });
28
28
  module.exports = __toCommonJS(index_exports);
29
- var import_react8 = require("react");
29
+ var import_react15 = require("react");
30
+
31
+ // src/host/auto-route/sentinel.ts
32
+ var AUTO_PROVIDER = "agent-enhancer";
33
+ var AUTO_MODEL = "auto";
30
34
 
31
35
  // src/config.ts
32
- var MODULES = ["history", "optimize", "predict", "rollback"];
36
+ var MODULES = ["history", "optimize", "predict", "rollback", "contextInspect"];
33
37
  function text(value) {
34
38
  return typeof value === "string" ? value : "";
35
39
  }
@@ -39,27 +43,59 @@ function resolveSettings(value) {
39
43
  optimizeEnabled: value?.optimizeEnabled ?? true,
40
44
  predictEnabled: value?.predictEnabled ?? true,
41
45
  rollbackEnabled: value?.rollbackEnabled ?? true,
46
+ contextInspectEnabled: value?.contextInspectEnabled ?? true,
42
47
  optimizeProvider: text(value?.optimizeProvider),
43
48
  optimizeModel: text(value?.optimizeModel),
44
49
  optimizeReasoningEffort: text(value?.optimizeReasoningEffort),
45
50
  predictProvider: text(value?.predictProvider),
46
51
  predictModel: text(value?.predictModel),
47
- predictReasoningEffort: text(value?.predictReasoningEffort)
52
+ predictReasoningEffort: text(value?.predictReasoningEffort),
53
+ compactProvider: text(value?.compactProvider),
54
+ compactModel: text(value?.compactModel),
55
+ compactReasoningEffort: text(value?.compactReasoningEffort),
56
+ autoClassifierEnabled: value?.autoClassifierEnabled ?? false,
57
+ autoInstantProvider: text(value?.autoInstantProvider),
58
+ autoInstantModel: text(value?.autoInstantModel),
59
+ autoInstantReasoningEffort: text(value?.autoInstantReasoningEffort),
60
+ autoThinkingProvider: text(value?.autoThinkingProvider),
61
+ autoThinkingModel: text(value?.autoThinkingModel),
62
+ autoThinkingReasoningEffort: text(value?.autoThinkingReasoningEffort),
63
+ autoProProvider: text(value?.autoProProvider),
64
+ autoProModel: text(value?.autoProModel),
65
+ autoProReasoningEffort: text(value?.autoProReasoningEffort),
66
+ autoClassifierProvider: text(value?.autoClassifierProvider),
67
+ autoClassifierModel: text(value?.autoClassifierModel),
68
+ autoClassifierReasoningEffort: text(value?.autoClassifierReasoningEffort)
48
69
  };
49
70
  }
71
+ function isAutoModel(selection) {
72
+ return selection.provider === AUTO_PROVIDER && selection.model === AUTO_MODEL;
73
+ }
50
74
  function auxiliaryModelOf(settings, feature) {
51
- if (feature === "optimize") {
52
- return {
53
- provider: settings.optimizeProvider,
54
- model: settings.optimizeModel,
55
- reasoningEffort: settings.optimizeReasoningEffort
56
- };
75
+ switch (feature) {
76
+ case "optimize":
77
+ return {
78
+ provider: settings.optimizeProvider,
79
+ model: settings.optimizeModel,
80
+ reasoningEffort: settings.optimizeReasoningEffort
81
+ };
82
+ case "predict":
83
+ return {
84
+ provider: settings.predictProvider,
85
+ model: settings.predictModel,
86
+ reasoningEffort: settings.predictReasoningEffort
87
+ };
88
+ case "compact":
89
+ return {
90
+ provider: settings.compactProvider,
91
+ model: settings.compactModel,
92
+ reasoningEffort: settings.compactReasoningEffort
93
+ };
94
+ default: {
95
+ const _exhaustive = feature;
96
+ return _exhaustive;
97
+ }
57
98
  }
58
- return {
59
- provider: settings.predictProvider,
60
- model: settings.predictModel,
61
- reasoningEffort: settings.predictReasoningEffort
62
- };
63
99
  }
64
100
  function isFollowSessionModel(selection) {
65
101
  return selection.provider === "" || selection.model === "";
@@ -72,13 +108,34 @@ function resolveUiLocale(id) {
72
108
  return normalized === "zh" || normalized.startsWith("zh-") || normalized.startsWith("zh_") ? "zh" : "en";
73
109
  }
74
110
 
111
+ // src/host/usage/balance.ts
112
+ var PROVIDER_BALANCE_ACCOUNT_KEY = "llm-deepseek-account";
113
+ var PROVIDER_BALANCE_API_KEY_KEY = "llm-deepseek";
114
+
75
115
  // src/errors.ts
116
+ var AUXILIARY_ERROR_CODES = [
117
+ "MODEL_UNAVAILABLE",
118
+ "MODEL_FAILED",
119
+ "INVALID_OUTPUT",
120
+ "SESSION_CHANGED",
121
+ "ROLLBACK_FAILED",
122
+ "COMPACT_UNAVAILABLE",
123
+ "COMPACT_BUSY",
124
+ "COMPACT_FAILED",
125
+ "COMPACT_SUMMARY",
126
+ "COMPACT_CHANGED"
127
+ ];
76
128
  var MESSAGES = {
77
129
  MODEL_UNAVAILABLE: "No model is available for Agent Enhance",
78
130
  MODEL_FAILED: "Auxiliary model request failed",
79
131
  INVALID_OUTPUT: "Auxiliary model returned invalid output",
80
132
  SESSION_CHANGED: "The session changed during the auxiliary request",
81
- ROLLBACK_FAILED: "The draft could not be restored after a failed write"
133
+ ROLLBACK_FAILED: "The draft could not be restored after a failed write",
134
+ COMPACT_UNAVAILABLE: "Official compaction is not available in this session",
135
+ COMPACT_BUSY: "Compaction is unavailable while the agent is busy",
136
+ COMPACT_FAILED: "Compaction did not finish; the conversation is unchanged or only partially updated",
137
+ COMPACT_SUMMARY: "Compaction could not produce a useful summary; the conversation is unchanged",
138
+ COMPACT_CHANGED: "History changed during compaction; the conversation is unchanged"
82
139
  };
83
140
  var AuxiliaryError = class extends Error {
84
141
  constructor(code) {
@@ -1042,8 +1099,15 @@ var styles_default = {
1042
1099
  settingRow: "styles_settingRow",
1043
1100
  settingText: "styles_settingText",
1044
1101
  settingControls: "styles_settingControls",
1102
+ settingsBack: "styles_settingsBack",
1103
+ settingsConfigure: "styles_settingsConfigure",
1104
+ settingsActionPrimary: "styles_settingsActionPrimary",
1045
1105
  modelPill: "styles_modelPill",
1046
1106
  modelPillLabel: "styles_modelPillLabel",
1107
+ settingsUpdate: "styles_settingsUpdate",
1108
+ settingsUpdateStatus: "styles_settingsUpdateStatus",
1109
+ updateCommand: "styles_updateCommand",
1110
+ autoMappingSection: "styles_autoMappingSection",
1047
1111
  prediction: "styles_prediction",
1048
1112
  historyDialog: "styles_historyDialog",
1049
1113
  historyHeader: "styles_historyHeader",
@@ -1062,10 +1126,161 @@ var styles_default = {
1062
1126
  rollbackConflict: "styles_rollbackConflict",
1063
1127
  userMessageRow: "styles_userMessageRow",
1064
1128
  userMessageActions: "styles_userMessageActions",
1065
- userMessageAction: "styles_userMessageAction"
1129
+ userMessageAction: "styles_userMessageAction",
1130
+ contextMeterRow: "styles_contextMeterRow",
1131
+ contextMeterChevron: "styles_contextMeterChevron",
1132
+ usageMeterTitleRow: "styles_usageMeterTitleRow",
1133
+ usageMeterLinkChevron: "styles_usageMeterLinkChevron",
1134
+ contextRightPanel: "styles_contextRightPanel",
1135
+ contextRightHeader: "styles_contextRightHeader",
1136
+ contextRightTitleRow: "styles_contextRightTitleRow",
1137
+ contextRightTitle: "styles_contextRightTitle",
1138
+ contextRightMeta: "styles_contextRightMeta",
1139
+ contextRightSegments: "styles_contextRightSegments",
1140
+ contextRightSegment: "styles_contextRightSegment",
1141
+ contextRightSegmentActive: "styles_contextRightSegmentActive",
1142
+ contextRightStatus: "styles_contextRightStatus",
1143
+ contextChart: "styles_contextChart",
1144
+ contextChartHeading: "styles_contextChartHeading",
1145
+ contextChartTitle: "styles_contextChartTitle",
1146
+ contextChartTotal: "styles_contextChartTotal",
1147
+ contextChartTotalHint: "styles_contextChartTotalHint",
1148
+ contextStackWrap: "styles_contextStackWrap",
1149
+ contextStack: "styles_contextStack",
1150
+ contextStackSegment: "styles_contextStackSegment",
1151
+ contextStackSegmentDim: "styles_contextStackSegmentDim",
1152
+ contextChartTip: "styles_contextChartTip",
1153
+ contextChartTipSwatch: "styles_contextChartTipSwatch",
1154
+ contextChartLegend: "styles_contextChartLegend",
1155
+ contextChartLegendItem: "styles_contextChartLegendItem",
1156
+ contextChartLegendItemDim: "styles_contextChartLegendItemDim",
1157
+ contextChartSwatch: "styles_contextChartSwatch",
1158
+ contextChartLegendMain: "styles_contextChartLegendMain",
1159
+ contextChartLegendTop: "styles_contextChartLegendTop",
1160
+ contextChartLegendLabel: "styles_contextChartLegendLabel",
1161
+ contextChartLegendMeta: "styles_contextChartLegendMeta",
1162
+ contextChartLegendTrack: "styles_contextChartLegendTrack",
1163
+ contextChartLegendFill: "styles_contextChartLegendFill",
1164
+ contextHeadroom: "styles_contextHeadroom",
1165
+ contextHeadroomMeta: "styles_contextHeadroomMeta",
1166
+ contextHeadroomValue: "styles_contextHeadroomValue",
1167
+ contextHeadroomTrack: "styles_contextHeadroomTrack",
1168
+ contextHeadroomFill: "styles_contextHeadroomFill",
1169
+ contextHeadroomHint: "styles_contextHeadroomHint",
1170
+ contextCompactBar: "styles_contextCompactBar",
1171
+ contextCompactButton: "styles_contextCompactButton",
1172
+ contextCompactButtonLabel: "styles_contextCompactButtonLabel",
1173
+ contextCompactHint: "styles_contextCompactHint",
1174
+ contextCompactNote: "styles_contextCompactNote",
1175
+ contextEventRow: "styles_contextEventRow",
1176
+ contextEventChip: "styles_contextEventChip",
1177
+ contextEventChipCompact: "styles_contextEventChipCompact",
1178
+ contextEventChipPrune: "styles_contextEventChipPrune",
1179
+ contextRightScroll: "styles_contextRightScroll",
1180
+ contextRightListFill: "styles_contextRightListFill",
1181
+ contextRightItem: "styles_contextRightItem",
1182
+ contextRightItemActive: "styles_contextRightItemActive",
1183
+ contextRightItemActiveFill: "styles_contextRightItemActiveFill",
1184
+ contextRightRow: "styles_contextRightRow",
1185
+ contextRightItemDot: "styles_contextRightItemDot",
1186
+ contextRightRowMain: "styles_contextRightRowMain",
1187
+ contextRightRowTitle: "styles_contextRightRowTitle",
1188
+ contextRightBadge: "styles_contextRightBadge",
1189
+ contextRightBadgeMuted: "styles_contextRightBadgeMuted",
1190
+ contextRightRowPreview: "styles_contextRightRowPreview",
1191
+ contextRightBarTrack: "styles_contextRightBarTrack",
1192
+ contextRightBarFill: "styles_contextRightBarFill",
1193
+ contextRightRowTokens: "styles_contextRightRowTokens",
1194
+ contextRightShare: "styles_contextRightShare",
1195
+ contextRightDetail: "styles_contextRightDetail",
1196
+ contextRightDetailBody: "styles_contextRightDetailBody",
1197
+ contextRightNote: "styles_contextRightNote",
1198
+ usageRightPane: "styles_usageRightPane",
1199
+ usagePanel: "styles_usagePanel",
1200
+ usageHeader: "styles_usageHeader",
1201
+ usageHero: "styles_usageHero",
1202
+ usageHeroCopy: "styles_usageHeroCopy",
1203
+ usageHeroTotal: "styles_usageHeroTotal",
1204
+ usageHeroTotalValue: "styles_usageHeroTotalValue",
1205
+ usageHeroTotalLabel: "styles_usageHeroTotalLabel",
1206
+ usageMoneyBlock: "styles_usageMoneyBlock",
1207
+ usageEstimate: "styles_usageEstimate",
1208
+ usageEstimateHint: "styles_usageEstimateHint",
1209
+ usageUnpriced: "styles_usageUnpriced",
1210
+ usageBalanceDetail: "styles_usageBalanceDetail",
1211
+ usageBalanceStale: "styles_usageBalanceStale",
1212
+ usageBalanceHint: "styles_usageBalanceHint",
1213
+ usageBalance: "styles_usageBalance",
1214
+ providerBalanceChip: "styles_providerBalanceChip",
1215
+ providerBalancePrimary: "styles_providerBalancePrimary",
1216
+ providerBalanceDetail: "styles_providerBalanceDetail",
1217
+ usageTitle: "styles_usageTitle",
1218
+ usageBack: "styles_usageBack",
1219
+ usageNote: "styles_usageNote",
1220
+ usageRetention: "styles_usageRetention",
1221
+ usageEmpty: "styles_usageEmpty",
1222
+ usageEmptyInline: "styles_usageEmptyInline",
1223
+ usageBucketMeta: "styles_usageBucketMeta",
1224
+ usageToolbar: "styles_usageToolbar",
1225
+ usageRecordsToolbar: "styles_usageRecordsToolbar",
1226
+ usageRanges: "styles_usageRanges",
1227
+ usageRefresh: "styles_usageRefresh",
1228
+ usageRange: "styles_usageRange",
1229
+ usageLink: "styles_usageLink",
1230
+ usageRecordsEntry: "styles_usageRecordsEntry",
1231
+ usageCharts: "styles_usageCharts",
1232
+ usageBuckets: "styles_usageBuckets",
1233
+ usageBucket: "styles_usageBucket",
1234
+ usageBucketLabel: "styles_usageBucketLabel",
1235
+ usageBucketValue: "styles_usageBucketValue",
1236
+ usageSectionTitle: "styles_usageSectionTitle",
1237
+ usageChart: "styles_usageChart",
1238
+ usageChartHead: "styles_usageChartHead",
1239
+ usageChartHint: "styles_usageChartHint",
1240
+ usageHeatBody: "styles_usageHeatBody",
1241
+ usageHeatGrid: "styles_usageHeatGrid",
1242
+ usageHeatGridHour: "styles_usageHeatGridHour",
1243
+ usageHeatGridDay: "styles_usageHeatGridDay",
1244
+ usageHeatCell: "styles_usageHeatCell",
1245
+ usageHeatCellDim: "styles_usageHeatCellDim",
1246
+ usageHeatScale: "styles_usageHeatScale",
1247
+ usageHeatLabel: "styles_usageHeatLabel",
1248
+ usageHeatLegend: "styles_usageHeatLegend",
1249
+ usageHeatTipValue: "styles_usageHeatTipValue",
1250
+ usageHeatTipMeta: "styles_usageHeatTipMeta",
1251
+ usageShareBody: "styles_usageShareBody",
1252
+ usageShareTrack: "styles_usageShareTrack",
1253
+ usageShareSegment: "styles_usageShareSegment",
1254
+ usageShareSegmentDim: "styles_usageShareSegmentDim",
1255
+ usageLegend: "styles_usageLegend",
1256
+ usageRankList: "styles_usageRankList",
1257
+ usageRecentList: "styles_usageRecentList",
1258
+ usageLegendItem: "styles_usageLegendItem",
1259
+ usageLegendItemDim: "styles_usageLegendItemDim",
1260
+ usageLegendSwatch: "styles_usageLegendSwatch",
1261
+ usageLegendLabel: "styles_usageLegendLabel",
1262
+ usageLegendMeta: "styles_usageLegendMeta",
1263
+ usageRankMeta: "styles_usageRankMeta",
1264
+ usageLegendShare: "styles_usageLegendShare",
1265
+ usageRankItem: "styles_usageRankItem",
1266
+ usageRankTop: "styles_usageRankTop",
1267
+ usageRankLabel: "styles_usageRankLabel",
1268
+ usageRankTrack: "styles_usageRankTrack",
1269
+ usageRankFill: "styles_usageRankFill",
1270
+ usageFooter: "styles_usageFooter",
1271
+ usageRecentPreview: "styles_usageRecentPreview",
1272
+ usageRecentHead: "styles_usageRecentHead",
1273
+ usageRecordsEntryMeta: "styles_usageRecordsEntryMeta",
1274
+ usageRecentItem: "styles_usageRecentItem",
1275
+ usageRecentMain: "styles_usageRecentMain",
1276
+ usageRecentSource: "styles_usageRecentSource",
1277
+ usageRecentRoute: "styles_usageRecentRoute",
1278
+ usageRecentProvider: "styles_usageRecentProvider",
1279
+ usageRecentWhen: "styles_usageRecentWhen",
1280
+ usageRecentTokens: "styles_usageRecentTokens"
1066
1281
  };
1067
1282
  var css_module_default = styles_default;
1068
- var cssText = "/* src/client/styles.module.css */\n.styles_root {\n position: relative;\n}\n.styles_toolbarIcon {\n width: 28px;\n padding: 0;\n}\n.styles_settings {\n display: grid;\n gap: 16px;\n max-width: 640px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_settings h2,\n.styles_settings h3,\n.styles_settings p {\n margin: 0;\n}\n.styles_settingsHeader {\n display: grid;\n gap: 4px;\n}\n.styles_settingsHeader p,\n.styles_settingDescription,\n.styles_privacy p {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_settingRow {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.styles_settingText {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_settingText h3,\n.styles_privacy h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_settingControls {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n}\n.styles_modelPill {\n max-width: 168px;\n}\n.styles_modelPillLabel {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_privacy {\n display: grid;\n gap: 8px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_prediction {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 8px 12px;\n color: var(--dsw-alias-label-secondary);\n font: var(--dsw-font-sm-14);\n white-space: pre-wrap;\n pointer-events: none;\n user-select: none;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_prediction kbd {\n margin-left: 8px;\n}\n.styles_historyDialog {\n position: absolute;\n z-index: 20;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 12px;\n color: var(--dsw-alias-label-primary);\n}\n.styles_historyHeader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font: var(--dsw-font-sm-14);\n}\n.styles_historyResults {\n max-height: 240px;\n margin: 0;\n padding: 0;\n overflow-y: auto;\n list-style: none;\n}\n.styles_historyResult {\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: pointer;\n border-radius: var(--dsw-radius-sm);\n}\n.styles_historyResult[aria-selected=true] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_hints {\n position: absolute;\n z-index: 21;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n}\n.styles_hint {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 8px 12px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_rollbackDialog {\n width: min(680px, 100%);\n max-height: 100%;\n min-height: 0;\n}\n.styles_rollbackContent {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n.styles_rollbackPreview {\n display: grid;\n gap: 20px;\n box-sizing: border-box;\n max-width: 72ch;\n padding: 16px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_rollbackSection {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n.styles_rollbackSection h3,\n.styles_rollbackSection p {\n margin: 0;\n}\n.styles_rollbackSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_rollbackList {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_rollbackList li {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.styles_rollbackMessage,\n.styles_rollbackFile {\n display: grid;\n gap: 4px;\n}\n.styles_rollbackFile {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: baseline;\n gap: 12px;\n}\n.styles_rollbackMeta {\n color: var(--dsw-alias-label-secondary);\n font-size: 0.92em;\n}\n.styles_rollbackConflict {\n display: block;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_userMessageRow {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n min-width: 0;\n}\n.styles_userMessageActions {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n}\n.styles_userMessageAction {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n}\n.styles_userMessageAction svg {\n width: calc(15px + var(--dsh-content-font-delta, 0px));\n height: calc(15px + var(--dsh-content-font-delta, 0px));\n}\n.styles_userMessageAction:hover {\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_userMessageAction:disabled,\n.styles_userMessageAction[data-unavailable] {\n cursor: default;\n opacity: 0.4;\n}\n.styles_userMessageAction:disabled:hover,\n.styles_userMessageAction[data-unavailable]:hover {\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n}\n";
1283
+ var cssText = '/* src/client/styles.module.css */\n.styles_root {\n position: relative;\n}\n.styles_toolbarIcon {\n width: 28px;\n padding: 0;\n}\n.styles_settings {\n display: grid;\n gap: 16px;\n max-width: 640px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_settings h2,\n.styles_settings h3,\n.styles_settings p {\n margin: 0;\n}\n.styles_settingsHeader {\n display: grid;\n gap: 4px;\n}\n.styles_settingsHeader p,\n.styles_settingDescription,\n.styles_privacy p {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_settingRow {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n}\n.styles_settingText {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_settingText h3,\n.styles_privacy h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_settingControls {\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n}\n.styles_settingsBack {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_settingsBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_settingsConfigure,\n.styles_settingsActionPrimary {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n font: inherit;\n font-weight: 600;\n line-height: 16px;\n cursor: pointer;\n white-space: nowrap;\n}\n.styles_settingsConfigure {\n color: var(--dsw-alias-label-primary);\n background: var(--dsw-alias-bg-layer-2);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_settingsConfigure:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_settingsConfigure:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.styles_settingsActionPrimary {\n color: #fff;\n background: #3b7ded;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_settingsActionPrimary:hover:not(:disabled) {\n background: #2f6fe0;\n}\n.styles_settingsActionPrimary:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_settingsActionPrimary:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.styles_modelPill {\n max-width: 168px;\n}\n.styles_modelPillLabel {\n display: block;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_privacy {\n display: grid;\n gap: 8px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_settingsUpdate {\n display: grid;\n gap: 8px;\n}\n.styles_settingsUpdateStatus {\n margin: 0;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_updateCommand {\n margin: 0;\n padding: 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-12, var(--dsw-font-sm-14));\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n monospace;\n word-break: break-all;\n white-space: pre-wrap;\n}\n.styles_autoMappingSection {\n display: grid;\n gap: 12px;\n padding: 12px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_autoMappingSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_prediction {\n position: absolute;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 8px 12px;\n color: var(--dsw-alias-label-secondary);\n font: var(--dsw-font-sm-14);\n white-space: pre-wrap;\n pointer-events: none;\n user-select: none;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_prediction kbd {\n margin-left: 8px;\n}\n.styles_historyDialog {\n position: absolute;\n z-index: 20;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n padding: 12px;\n color: var(--dsw-alias-label-primary);\n}\n.styles_historyHeader {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n font: var(--dsw-font-sm-14);\n}\n.styles_historyResults {\n max-height: 240px;\n margin: 0;\n padding: 0;\n overflow-y: auto;\n list-style: none;\n}\n.styles_historyResult {\n padding: 8px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n cursor: pointer;\n border-radius: var(--dsw-radius-sm);\n}\n.styles_historyResult[aria-selected=true] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_hints {\n position: absolute;\n z-index: 21;\n left: 0;\n right: 0;\n bottom: calc(100% + 8px);\n display: grid;\n gap: 8px;\n box-sizing: border-box;\n width: auto;\n max-width: none;\n}\n.styles_hint {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 8px 12px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n}\n.styles_rollbackDialog {\n width: min(680px, 100%);\n max-height: 100%;\n min-height: 0;\n}\n.styles_rollbackContent {\n flex: 1 1 auto;\n min-height: 0;\n overflow-y: auto;\n}\n.styles_rollbackPreview {\n display: grid;\n gap: 20px;\n box-sizing: border-box;\n max-width: 72ch;\n padding: 16px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n}\n.styles_rollbackSection {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n.styles_rollbackSection h3,\n.styles_rollbackSection p {\n margin: 0;\n}\n.styles_rollbackSection h3 {\n font: inherit;\n font-weight: 600;\n}\n.styles_rollbackList {\n display: grid;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_rollbackList li {\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.styles_rollbackMessage,\n.styles_rollbackFile {\n display: grid;\n gap: 4px;\n}\n.styles_rollbackFile {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: baseline;\n gap: 12px;\n}\n.styles_rollbackMeta {\n color: var(--dsw-alias-label-secondary);\n font-size: 0.92em;\n}\n.styles_rollbackConflict {\n display: block;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_userMessageRow {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 6px;\n min-width: 0;\n}\n.styles_userMessageActions {\n display: inline-flex;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n}\n.styles_userMessageAction {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: calc(28px + var(--dsh-content-font-delta, 0px));\n height: calc(28px + var(--dsh-content-font-delta, 0px));\n padding: 6px;\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n}\n.styles_userMessageAction svg {\n width: calc(15px + var(--dsh-content-font-delta, 0px));\n height: calc(15px + var(--dsh-content-font-delta, 0px));\n}\n.styles_userMessageAction:hover {\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_userMessageAction:disabled,\n.styles_userMessageAction[data-unavailable] {\n cursor: default;\n opacity: 0.4;\n}\n.styles_userMessageAction:disabled:hover,\n.styles_userMessageAction[data-unavailable]:hover {\n color: var(--dsw-alias-label-tertiary);\n background: transparent;\n}\n.styles_contextMeterRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_contextMeterRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextMeterRow[data-agent-enhancer-loading="1"] {\n opacity: 0.65;\n}\n.styles_contextMeterChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n}\n.styles_usageMeterTitleRow {\n cursor: pointer;\n position: relative;\n padding-right: 18px;\n}\n.styles_usageMeterTitleRow:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageMeterTitleRow:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageMeterLinkChevron {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n color: var(--dsw-alias-label-tertiary);\n font-size: 14px;\n line-height: 1;\n pointer-events: none;\n}\n.styles_contextRightPanel {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 12px 14px 14px;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n}\n.styles_contextRightHeader {\n display: flex;\n flex-direction: column;\n gap: 10px;\n flex: none;\n}\n.styles_contextRightTitleRow {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_contextRightTitle {\n margin: 0;\n font: var(--dsw-font-sm-14);\n font-weight: 600;\n}\n.styles_contextRightMeta {\n color: var(--dsw-alias-label-tertiary);\n white-space: nowrap;\n font-variant-numeric: tabular-nums;\n}\n.styles_contextRightSegments {\n display: flex;\n gap: 2px;\n flex-wrap: wrap;\n padding: 2px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightSegment,\n.styles_contextRightSegmentActive {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n border-radius: var(--dsw-radius-sm);\n padding: 5px 9px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightSegment:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightSegmentActive {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n}\n.styles_contextRightStatus {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_contextChart {\n flex: none;\n display: grid;\n gap: 10px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextChartHeading {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 10px;\n}\n.styles_contextChartTitle {\n font-weight: 600;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartTotal {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartTotalHint {\n color: var(--dsw-alias-label-tertiary);\n font-weight: 400;\n}\n.styles_contextStackWrap {\n position: relative;\n display: grid;\n gap: 0;\n}\n.styles_contextStack {\n display: flex;\n width: 100%;\n height: 12px;\n border-radius: 999px;\n overflow: hidden;\n background: var(--dsw-alias-border-primary);\n}\n.styles_contextStackSegment,\n.styles_contextStackSegmentDim {\n display: block;\n height: 100%;\n min-width: 2px;\n cursor: default;\n transition: opacity 120ms ease, filter 120ms ease;\n}\n.styles_contextStackSegment {\n opacity: 1;\n filter: saturate(1.08);\n}\n.styles_contextStackSegmentDim {\n opacity: 0.28;\n filter: saturate(0.55);\n}\n.styles_contextChartTip {\n position: absolute;\n left: 50%;\n bottom: calc(100% + 6px);\n transform: translateX(-50%);\n z-index: 2;\n display: inline-flex;\n align-items: center;\n gap: 6px;\n max-width: min(100%, 280px);\n padding: 5px 8px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-1);\n box-shadow: 0 0 0 1px var(--dsw-alias-border-primary);\n color: var(--dsw-alias-label-primary);\n font-size: 12px;\n line-height: 16px;\n white-space: nowrap;\n pointer-events: none;\n}\n.styles_contextChartTipSwatch {\n flex: none;\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_contextChartLegend {\n list-style: none;\n margin: 0;\n padding: 0;\n min-width: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.styles_contextChartLegendItem,\n.styles_contextChartLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr);\n gap: 8px;\n align-items: start;\n font-size: 12px;\n border-radius: var(--dsw-radius-sm);\n padding: 2px 4px;\n margin: 0 -4px;\n transition: opacity 120ms ease, background 120ms ease;\n}\n.styles_contextChartLegendItem {\n opacity: 1;\n background: transparent;\n}\n.styles_contextChartLegendItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextChartLegendItemDim {\n opacity: 0.4;\n}\n.styles_contextChartSwatch {\n width: 8px;\n height: 8px;\n margin-top: 4px;\n border-radius: 999px;\n}\n.styles_contextChartLegendMain {\n min-width: 0;\n display: grid;\n gap: 4px;\n}\n.styles_contextChartLegendTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 8px;\n}\n.styles_contextChartLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextChartLegendMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_contextChartLegendTrack {\n height: 3px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextChartLegendFill {\n height: 100%;\n border-radius: inherit;\n opacity: 0.9;\n}\n.styles_contextHeadroom {\n display: grid;\n gap: 4px;\n padding-top: 2px;\n border-top: 1px solid var(--dsw-alias-border-primary);\n}\n.styles_contextHeadroomMeta {\n display: flex;\n justify-content: space-between;\n gap: 8px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n}\n.styles_contextHeadroomValue {\n color: var(--dsw-alias-label-primary);\n font-variant-numeric: tabular-nums;\n}\n.styles_contextHeadroomTrack {\n height: 5px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextHeadroomFill {\n height: 100%;\n border-radius: inherit;\n background: #4c8bf5;\n opacity: 0.85;\n}\n.styles_contextHeadroomHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n}\n.styles_contextCompactBar {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n flex: none;\n}\n.styles_contextCompactButton {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n flex: none;\n min-height: 30px;\n padding: 0 10px 0 8px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n color: #fff;\n background: #3b7ded;\n font-size: 12px;\n font-weight: 600;\n line-height: 16px;\n box-shadow: 0 0 0 1px color-mix(in srgb, #3b7ded 55%, transparent);\n}\n.styles_contextCompactButton:hover:not(:disabled) {\n color: #fff;\n background: #2f6fe0;\n}\n.styles_contextCompactButton:focus-visible {\n outline: 2px solid color-mix(in srgb, #3b7ded 70%, white);\n outline-offset: 2px;\n}\n.styles_contextCompactButton:disabled {\n cursor: default;\n opacity: 0.55;\n}\n.styles_contextCompactButtonLabel {\n max-width: 9em;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextCompactHint,\n.styles_contextCompactNote {\n margin: 0;\n min-width: 0;\n flex: 1;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n padding-top: 5px;\n}\n.styles_contextCompactNote {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextEventRow {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n flex: none;\n}\n.styles_contextEventChip,\n.styles_contextEventChipCompact,\n.styles_contextEventChipPrune {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 2px 7px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n.styles_contextEventChipCompact {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextEventChipPrune {\n color: var(--dsw-alias-label-primary);\n}\n.styles_contextRightScroll,\n.styles_contextRightListFill {\n min-height: 0;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.styles_contextRightScroll {\n overflow: auto;\n}\n.styles_contextRightListFill {\n overflow: hidden;\n}\n.styles_contextRightItem,\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n}\n.styles_contextRightItem:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActive,\n.styles_contextRightItemActiveFill {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_contextRightItemActiveFill {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightRow {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 10px;\n width: 100%;\n text-align: left;\n border: 0;\n background: transparent;\n color: inherit;\n border-radius: var(--dsw-radius-sm);\n padding: 8px 8px 7px;\n cursor: pointer;\n font: inherit;\n}\n.styles_contextRightItemDot {\n width: 7px;\n height: 7px;\n border-radius: 999px;\n flex: none;\n margin-top: 5px;\n}\n.styles_contextRightRowMain {\n min-width: 0;\n flex: 1;\n display: grid;\n gap: 4px;\n}\n.styles_contextRightRowTitle {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px;\n font-weight: 500;\n}\n.styles_contextRightBadge,\n.styles_contextRightBadgeMuted {\n display: inline-flex;\n align-items: center;\n padding: 0 5px;\n border-radius: var(--dsw-radius-sm);\n font-size: 10px;\n font-weight: 500;\n line-height: 16px;\n color: var(--dsw-alias-label-secondary);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightBadgeMuted {\n opacity: 0.9;\n}\n.styles_contextRightRowPreview {\n color: var(--dsw-alias-label-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_contextRightBarTrack {\n height: 2px;\n border-radius: 999px;\n background: var(--dsw-alias-border-primary);\n overflow: hidden;\n}\n.styles_contextRightBarFill {\n height: 100%;\n background: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightRowTokens {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n text-align: right;\n padding-top: 1px;\n}\n.styles_contextRightShare {\n opacity: 0.85;\n}\n.styles_contextRightDetail {\n margin: 0 8px 8px 22px;\n min-height: 0;\n padding: 8px 10px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetail {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.styles_contextRightDetailBody {\n margin: 0;\n white-space: pre-wrap;\n word-break: break-word;\n font: inherit;\n color: var(--dsw-alias-label-secondary);\n}\n.styles_contextRightItemActiveFill .styles_contextRightDetailBody {\n flex: 1;\n min-height: 0;\n overflow: auto;\n}\n.styles_contextRightNote {\n flex: none;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageRightPane {\n box-sizing: border-box;\n height: 100%;\n min-height: 0;\n display: flex;\n flex-direction: column;\n padding: 0;\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-13);\n background:\n linear-gradient(\n 180deg,\n color-mix(in srgb, #3d7cf5 10%, var(--dsw-alias-bg-layer-1)) 0,\n var(--dsw-alias-bg-layer-1) 120px);\n}\n.styles_usagePanel {\n box-sizing: border-box;\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n gap: 14px;\n overflow: auto;\n padding: 14px 14px 16px;\n}\n.styles_usagePanel h2,\n.styles_usagePanel h3,\n.styles_usagePanel p {\n margin: 0;\n}\n.styles_usageHeader,\n.styles_usageHero {\n display: grid;\n gap: 6px;\n flex: none;\n}\n.styles_usageHero {\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: end;\n gap: 12px;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-md, 10px);\n background:\n linear-gradient(\n 135deg,\n color-mix(in srgb, #3d7cf5 16%, transparent),\n color-mix(in srgb, #1f9a6a 8%, transparent));\n border: 1px solid color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeroCopy {\n display: grid;\n gap: 4px;\n min-width: 0;\n}\n.styles_usageHeroTotal {\n display: grid;\n justify-items: end;\n gap: 2px;\n}\n.styles_usageHeroTotalValue {\n font: var(--dsw-font-sm-16, var(--dsw-font-sm-14));\n font-weight: 700;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.02em;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageHeroTotalLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageMoneyBlock {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n}\n.styles_usageEstimate {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n letter-spacing: -0.01em;\n}\n.styles_usageEstimateHint,\n.styles_usageUnpriced,\n.styles_usageBalanceDetail,\n.styles_usageBalanceStale,\n.styles_usageBalanceHint {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageBalance {\n display: grid;\n gap: 2px;\n margin-top: 4px;\n font-variant-numeric: tabular-nums;\n}\n.styles_providerBalanceChip {\n display: grid;\n gap: 2px;\n justify-items: start;\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n font-size: 12px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n text-align: left;\n cursor: pointer;\n}\n.styles_providerBalanceChip:hover .styles_providerBalancePrimary {\n color: var(--dsw-alias-label-primary);\n}\n.styles_providerBalancePrimary {\n color: var(--dsw-alias-label-secondary);\n}\n.styles_providerBalanceDetail {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageTitle {\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n letter-spacing: -0.01em;\n}\n.styles_usageBack {\n justify-self: start;\n margin: 0 0 2px;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageBack:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageNote,\n.styles_usageRetention,\n.styles_usageEmpty,\n.styles_usageEmptyInline,\n.styles_usageBucketMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 18px;\n}\n.styles_usageToolbar,\n.styles_usageRecordsToolbar {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n flex: none;\n}\n.styles_usageRanges {\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n width: fit-content;\n max-width: 100%;\n padding: 4px;\n background: var(--dsw-alias-bg-layer-2);\n border-radius: var(--dsw-radius-sm);\n flex: none;\n}\n.styles_usageRefresh {\n margin: 0;\n min-height: 28px;\n padding: 0 12px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRefresh:hover:not(:disabled) {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n.styles_usageRefresh:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRefresh:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageRange {\n margin: 0;\n min-height: 28px;\n padding: 0 10px;\n border: 0;\n border-radius: var(--dsw-radius-sm);\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageRange[aria-pressed=true] {\n background: var(--dsw-alias-interactive-bg-hover);\n color: var(--dsw-alias-label-primary);\n font-weight: 600;\n}\n.styles_usageRange:hover:not(:disabled):not([aria-pressed=true]) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRange:focus-visible,\n.styles_usageBack:focus-visible,\n.styles_usageLink:focus-visible,\n.styles_usageRecordsEntry:focus-visible {\n outline: 2px solid var(--dsw-alias-label-secondary);\n outline-offset: 2px;\n}\n.styles_usageRange:disabled,\n.styles_usageRecordsEntry:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n.styles_usageCharts {\n display: grid;\n gap: 16px;\n flex: none;\n}\n.styles_usageBuckets {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 8px;\n}\n.styles_usageBucket {\n display: grid;\n gap: 4px;\n min-width: 0;\n padding: 10px 12px;\n border-radius: var(--dsw-radius-sm);\n background: var(--dsw-alias-bg-layer-2);\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);\n}\n.styles_usageBucketLabel {\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 14px;\n}\n.styles_usageBucketValue {\n color: var(--dsw-alias-label-primary);\n font: var(--dsw-font-sm-14);\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageSectionTitle {\n margin: 0;\n font: var(--dsw-font-sm-13);\n font-weight: 650;\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageChart {\n display: grid;\n gap: 10px;\n}\n.styles_usageChartHead {\n display: grid;\n gap: 4px;\n}\n.styles_usageChartHint {\n margin: 0;\n color: var(--dsw-alias-label-tertiary);\n font-size: 11px;\n line-height: 15px;\n}\n.styles_usageHeatBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageHeatGrid {\n display: grid;\n gap: 4px;\n}\n.styles_usageHeatGridHour {\n grid-template-columns: repeat(6, minmax(0, 1fr));\n}\n.styles_usageHeatGridDay {\n grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));\n}\n.styles_usageHeatCell,\n.styles_usageHeatCellDim {\n box-sizing: border-box;\n display: grid;\n place-items: end start;\n min-height: 36px;\n margin: 0;\n padding: 4px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n border-radius: 6px;\n background: var(--dsw-alias-bg-layer-2);\n color: var(--dsw-alias-label-secondary);\n cursor: pointer;\n transition: opacity 120ms ease, transform 120ms ease;\n}\n.styles_usageHeatCell:hover,\n.styles_usageHeatCell:focus-visible {\n transform: translateY(-1px);\n outline: none;\n}\n.styles_usageHeatCell:focus-visible {\n box-shadow: 0 0 0 2px color-mix(in srgb, #3d7cf5 55%, transparent);\n}\n.styles_usageHeatCellDim {\n opacity: 0.35;\n}\n.styles_usageHeatCell[data-level="0"],\n.styles_usageHeatCellDim[data-level="0"],\n.styles_usageHeatScale span[data-level="0"] {\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageHeatCell[data-level="1"],\n.styles_usageHeatCellDim[data-level="1"],\n.styles_usageHeatScale span[data-level="1"] {\n background: color-mix(in srgb, #3d7cf5 22%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="2"],\n.styles_usageHeatCellDim[data-level="2"],\n.styles_usageHeatScale span[data-level="2"] {\n background: color-mix(in srgb, #3d7cf5 40%, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageHeatCell[data-level="3"],\n.styles_usageHeatCellDim[data-level="3"],\n.styles_usageHeatScale span[data-level="3"] {\n background: color-mix(in srgb, #3d7cf5 62%, var(--dsw-alias-bg-layer-2));\n color: #f4f7ff;\n}\n.styles_usageHeatCell[data-level="4"],\n.styles_usageHeatCellDim[data-level="4"],\n.styles_usageHeatScale span[data-level="4"] {\n background: color-mix(in srgb, #245fd4 88%, #0b1c3a);\n color: #f4f7ff;\n}\n.styles_usageHeatLabel {\n font-size: 10px;\n line-height: 12px;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatLegend {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n min-height: 20px;\n}\n.styles_usageHeatTipValue {\n font-weight: 650;\n font-variant-numeric: tabular-nums;\n}\n.styles_usageHeatTipMeta {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n}\n.styles_usageHeatScale {\n display: inline-flex;\n gap: 3px;\n margin-left: auto;\n}\n.styles_usageHeatScale span {\n width: 12px;\n height: 12px;\n border-radius: 3px;\n border: 1px solid color-mix(in srgb, var(--dsw-alias-label-primary) 8%, transparent);\n}\n.styles_usageShareBody {\n display: grid;\n gap: 10px;\n}\n.styles_usageShareTrack {\n display: flex;\n width: 100%;\n height: 12px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageShareSegment,\n.styles_usageShareSegmentDim {\n height: 100%;\n min-width: 2px;\n transition: opacity 120ms ease;\n}\n.styles_usageShareSegmentDim {\n opacity: 0.28;\n}\n.styles_usageLegend,\n.styles_usageRankList,\n.styles_usageRecentList {\n display: grid;\n gap: 8px;\n width: 100%;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n.styles_usageLegendItem,\n.styles_usageLegendItemDim {\n display: grid;\n grid-template-columns: 8px minmax(0, 1fr) auto;\n gap: 8px;\n align-items: center;\n}\n.styles_usageLegendItemDim {\n opacity: 0.45;\n}\n.styles_usageLegendSwatch {\n width: 8px;\n height: 8px;\n border-radius: 999px;\n}\n.styles_usageLegendLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageLegendMeta,\n.styles_usageRankMeta {\n color: var(--dsw-alias-label-secondary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageLegendShare {\n margin-left: 6px;\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRankItem {\n display: grid;\n gap: 4px;\n}\n.styles_usageRankTop {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRankLabel {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.styles_usageRankTrack {\n height: 6px;\n overflow: hidden;\n border-radius: 999px;\n background: var(--dsw-alias-bg-layer-2);\n}\n.styles_usageRankFill {\n height: 100%;\n border-radius: inherit;\n}\n.styles_usageFooter {\n margin-top: auto;\n flex: none;\n display: grid;\n gap: 8px;\n padding-top: 4px;\n}\n.styles_usageRecentPreview {\n display: grid;\n gap: 8px;\n}\n.styles_usageRecentHead {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageLink {\n margin: 0;\n padding: 0;\n border: 0;\n background: transparent;\n color: var(--dsw-alias-label-secondary);\n font: inherit;\n cursor: pointer;\n}\n.styles_usageLink:hover {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntry {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n width: 100%;\n margin: 0;\n padding: 10px 0;\n border: 0;\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n background: transparent;\n color: var(--dsw-alias-label-primary);\n font: inherit;\n text-align: start;\n cursor: pointer;\n}\n.styles_usageRecordsEntry:hover:not(:disabled) {\n color: var(--dsw-alias-label-primary);\n}\n.styles_usageRecordsEntryMeta {\n color: var(--dsw-alias-label-tertiary);\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n.styles_usageRecentItem {\n display: grid;\n gap: 6px;\n padding: 10px 0;\n}\n.styles_usageRecentItem + .styles_usageRecentItem {\n border-top: 1px solid var(--dsw-alias-border-subtle, var(--dsw-alias-bg-layer-2));\n}\n.styles_usageRecentMain {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n}\n.styles_usageRecentSource {\n font-weight: 650;\n}\n.styles_usageRecentRoute {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n}\n.styles_usageRecentProvider {\n color: var(--dsw-alias-label-tertiary);\n}\n.styles_usageRecentWhen {\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n white-space: nowrap;\n}\n.styles_usageRecentTokens {\n display: flex;\n flex-wrap: wrap;\n gap: 6px 10px;\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 16px;\n font-variant-numeric: tabular-nums;\n}\n';
1069
1284
  function installCss() {
1070
1285
  const style = document.createElement("style");
1071
1286
  style.setAttribute("data-dsh-agent-enhancer", "");
@@ -1130,7 +1345,8 @@ function AgentControls({ session, t }) {
1130
1345
  );
1131
1346
  if (!state.enabled) return null;
1132
1347
  const label = t(state.status === "pending" ? "optimizePending" : state.status === "undo" ? "optimizeUndo" : "optimize");
1133
- const errorLocale = OPTIMIZATION_ERROR_LOCALES[state.error ?? "MODEL_FAILED"];
1348
+ const optimizeError = state.error !== null && state.error in OPTIMIZATION_ERROR_LOCALES ? state.error : "MODEL_FAILED";
1349
+ const errorLocale = OPTIMIZATION_ERROR_LOCALES[optimizeError];
1134
1350
  const tooltip = state.chipSelection ? t("optimizeChipSelection") : state.error !== null ? t(errorLocale) : state.hasChips ? t("optimizeChips") : label;
1135
1351
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1136
1352
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.Tooltip, { label: tooltip, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -1695,6 +1911,12 @@ var SEP = "|";
1695
1911
  function encodeFollowSelection() {
1696
1912
  return "follow";
1697
1913
  }
1914
+ function encodeAutoSelection() {
1915
+ return "auto";
1916
+ }
1917
+ function encodeUnconfiguredSelection() {
1918
+ return "unconfigured";
1919
+ }
1698
1920
  function encodeModelSelection(provider, model) {
1699
1921
  return `m${SEP}${provider}${SEP}${model}`;
1700
1922
  }
@@ -1703,6 +1925,8 @@ function encodeEffortSelection(provider, model, effort) {
1703
1925
  }
1704
1926
  function decodeModelSelection(id) {
1705
1927
  if (id === "follow") return { kind: "follow" };
1928
+ if (id === "auto") return { kind: "auto" };
1929
+ if (id === "unconfigured" || id === "tier:unconfigured") return { kind: "unconfigured" };
1706
1930
  if (id.startsWith(`m${SEP}`)) {
1707
1931
  const parts = id.slice(2).split(SEP);
1708
1932
  if (parts.length !== 2 || parts[0] === "" || parts[1] === "") return null;
@@ -1801,34 +2025,314 @@ var AcceptedSettingsForm = class {
1801
2025
  // src/client/dsh/settings.tsx
1802
2026
  var import_dsh_client_ui_primitives4 = require("@deepseek-ai/dsh-client-ui-primitives");
1803
2027
  var import_react4 = require("react");
2028
+
2029
+ // src/client/dsh/model-pill-label.ts
2030
+ function findModel(groups, provider, model) {
2031
+ return groups.find((group) => group.id === provider)?.models.find((entry) => entry.id === model);
2032
+ }
2033
+ function isUnconfiguredAutoTierMapping(selection) {
2034
+ return !isAutoModel(selection) && selection.provider === "" && selection.model === "";
2035
+ }
2036
+ function pillLabel(selection, groups, followLabel, autoLabel, unconfiguredLabel) {
2037
+ if (isAutoModel(selection)) return autoLabel;
2038
+ if (unconfiguredLabel !== void 0 && isUnconfiguredAutoTierMapping(selection)) {
2039
+ return unconfiguredLabel;
2040
+ }
2041
+ if (isFollowSessionModel(selection)) return followLabel;
2042
+ const model = findModel(groups, selection.provider, selection.model);
2043
+ const name = model?.name ?? selection.model;
2044
+ if (selection.reasoningEffort === "") return name;
2045
+ const effort = model?.reasoning?.efforts.find((entry) => entry.id === selection.reasoningEffort);
2046
+ return `${name} \xB7 ${effort?.name ?? selection.reasoningEffort}`;
2047
+ }
2048
+ function selectedPillMenuId(selection, groups, options) {
2049
+ if (isAutoModel(selection)) return encodeAutoSelection();
2050
+ if (options?.tierMapping === true && isUnconfiguredAutoTierMapping(selection)) {
2051
+ return encodeUnconfiguredSelection();
2052
+ }
2053
+ if (isFollowSessionModel(selection)) return encodeFollowSelection();
2054
+ const model = findModel(groups, selection.provider, selection.model);
2055
+ if ((model?.reasoning?.efforts.length ?? 0) > 0) {
2056
+ return encodeEffortSelection(selection.provider, selection.model, selection.reasoningEffort);
2057
+ }
2058
+ return encodeModelSelection(selection.provider, selection.model);
2059
+ }
2060
+
2061
+ // src/client/dsh/settings.tsx
1804
2062
  var import_jsx_runtime5 = require("react/jsx-runtime");
2063
+ var AUTO_TIER_LABELS = {
2064
+ instant: "autoTier_instant",
2065
+ thinking: "autoTier_thinking",
2066
+ pro: "autoTier_pro",
2067
+ classifier: "autoTier_classifier"
2068
+ };
2069
+ function autoTierSelection(settings, tier) {
2070
+ switch (tier) {
2071
+ case "instant":
2072
+ return {
2073
+ provider: settings.autoInstantProvider,
2074
+ model: settings.autoInstantModel,
2075
+ reasoningEffort: settings.autoInstantReasoningEffort
2076
+ };
2077
+ case "thinking":
2078
+ return {
2079
+ provider: settings.autoThinkingProvider,
2080
+ model: settings.autoThinkingModel,
2081
+ reasoningEffort: settings.autoThinkingReasoningEffort
2082
+ };
2083
+ case "pro":
2084
+ return {
2085
+ provider: settings.autoProProvider,
2086
+ model: settings.autoProModel,
2087
+ reasoningEffort: settings.autoProReasoningEffort
2088
+ };
2089
+ case "classifier":
2090
+ return {
2091
+ provider: settings.autoClassifierProvider,
2092
+ model: settings.autoClassifierModel,
2093
+ reasoningEffort: settings.autoClassifierReasoningEffort
2094
+ };
2095
+ default: {
2096
+ const _exhaustive = tier;
2097
+ return _exhaustive;
2098
+ }
2099
+ }
2100
+ }
2101
+ function autoTierFieldPrefix(tier) {
2102
+ switch (tier) {
2103
+ case "instant":
2104
+ return "autoInstant";
2105
+ case "thinking":
2106
+ return "autoThinking";
2107
+ case "pro":
2108
+ return "autoPro";
2109
+ case "classifier":
2110
+ return "autoClassifier";
2111
+ default: {
2112
+ const _exhaustive = tier;
2113
+ return _exhaustive;
2114
+ }
2115
+ }
2116
+ }
2117
+ function resolveBlockedReason(result) {
2118
+ return result.installKind === "link" ? "link" : "manual";
2119
+ }
2120
+ function resolveCheckState(result) {
2121
+ if (result.latest === null) return { kind: "checkError" };
2122
+ if (!result.updateAvailable) return { kind: "upToDate", result };
2123
+ if (result.canAutoApply) return { kind: "available", result };
2124
+ return { kind: "blocked", result, reason: resolveBlockedReason(result) };
2125
+ }
2126
+ function resolveApplyState(result, apply2) {
2127
+ const applyError = {
2128
+ kind: "applyError",
2129
+ result,
2130
+ command: apply2.command ?? result.command
2131
+ };
2132
+ switch (apply2.message) {
2133
+ case "restart":
2134
+ return apply2.ok ? { kind: "success", result } : applyError;
2135
+ case "link":
2136
+ return { kind: "blocked", result, reason: "link" };
2137
+ case "manual":
2138
+ return { kind: "blocked", result, reason: "manual" };
2139
+ case "none":
2140
+ return resolveCheckState(result);
2141
+ case "failed":
2142
+ return applyError;
2143
+ default: {
2144
+ const unreachable = apply2.message;
2145
+ void unreachable;
2146
+ return applyError;
2147
+ }
2148
+ }
2149
+ }
2150
+ function SettingsUpdateSection({ checkUpdate, applyUpdate, t }) {
2151
+ const [state, setState] = (0, import_react4.useState)({ kind: "idle" });
2152
+ const [copied, setCopied] = (0, import_react4.useState)(false);
2153
+ const runCheck = (0, import_react4.useCallback)(async () => {
2154
+ setState({ kind: "checking" });
2155
+ try {
2156
+ const result2 = await checkUpdate();
2157
+ setState(resolveCheckState(result2));
2158
+ } catch {
2159
+ setState({ kind: "checkError" });
2160
+ }
2161
+ }, [checkUpdate]);
2162
+ (0, import_react4.useEffect)(() => {
2163
+ void runCheck();
2164
+ }, [runCheck]);
2165
+ const onApply = async () => {
2166
+ if (applyUpdate === void 0 || state.kind !== "available") return;
2167
+ const result2 = state.result;
2168
+ setState({ kind: "applying", result: result2 });
2169
+ try {
2170
+ const apply2 = await applyUpdate();
2171
+ setState(resolveApplyState(result2, apply2));
2172
+ } catch {
2173
+ setState({ kind: "applyError", result: result2, command: result2.command });
2174
+ }
2175
+ };
2176
+ const onCopy = async (command) => {
2177
+ try {
2178
+ await navigator.clipboard.writeText(command);
2179
+ setCopied(true);
2180
+ window.setTimeout(() => {
2181
+ setCopied(false);
2182
+ }, 2e3);
2183
+ } catch {
2184
+ setCopied(false);
2185
+ }
2186
+ };
2187
+ const checking = state.kind === "checking";
2188
+ const applying = state.kind === "applying";
2189
+ const busy = checking || applying;
2190
+ const result = state.kind === "idle" || state.kind === "checkError" ? null : "result" in state ? state.result : null;
2191
+ let status = null;
2192
+ switch (state.kind) {
2193
+ case "idle":
2194
+ break;
2195
+ case "checking":
2196
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateChecking") });
2197
+ break;
2198
+ case "upToDate":
2199
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateLatest") });
2200
+ break;
2201
+ case "available":
2202
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateAvailable", { version: state.result.latest ?? state.result.current }) });
2203
+ break;
2204
+ case "applying":
2205
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateApplying") });
2206
+ break;
2207
+ case "success":
2208
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateRestart") });
2209
+ break;
2210
+ case "blocked":
2211
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: state.reason === "link" ? t("updateLinkBlocked") : t("updateManual") });
2212
+ break;
2213
+ case "checkError":
2214
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateCheckFailed") });
2215
+ break;
2216
+ case "applyError":
2217
+ status = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingsUpdateStatus, role: "status", children: t("updateFailed") });
2218
+ break;
2219
+ default: {
2220
+ const _exhaustive = state;
2221
+ return _exhaustive;
2222
+ }
2223
+ }
2224
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingsUpdate, "aria-label": t("updateTitle"), children: [
2225
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2226
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingText, children: [
2227
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("updateTitle") }),
2228
+ result !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingDescription, children: t("updateCurrent", { version: result.current }) })
2229
+ ] }),
2230
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingControls, children: [
2231
+ state.kind === "available" && applyUpdate !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2232
+ "button",
2233
+ {
2234
+ type: "button",
2235
+ className: css_module_default.settingsActionPrimary,
2236
+ disabled: busy,
2237
+ onClick: () => {
2238
+ void onApply();
2239
+ },
2240
+ children: t("updateApply", { version: state.result.latest ?? state.result.current })
2241
+ }
2242
+ ),
2243
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2244
+ "button",
2245
+ {
2246
+ type: "button",
2247
+ className: css_module_default.settingsActionPrimary,
2248
+ disabled: busy,
2249
+ onClick: () => {
2250
+ void runCheck();
2251
+ },
2252
+ children: checking ? t("updateChecking") : t("updateCheck")
2253
+ }
2254
+ )
2255
+ ] })
2256
+ ] }),
2257
+ status,
2258
+ state.kind === "blocked" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2259
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: css_module_default.updateCommand, children: state.result.command }),
2260
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2261
+ "button",
2262
+ {
2263
+ type: "button",
2264
+ className: css_module_default.settingsConfigure,
2265
+ onClick: () => {
2266
+ void onCopy(state.result.command);
2267
+ },
2268
+ children: copied ? t("updateCopied") : t("updateCopy")
2269
+ }
2270
+ )
2271
+ ] }),
2272
+ state.kind === "applyError" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2273
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", { className: css_module_default.updateCommand, children: state.command }),
2274
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2275
+ "button",
2276
+ {
2277
+ type: "button",
2278
+ className: css_module_default.settingsConfigure,
2279
+ onClick: () => {
2280
+ void onCopy(state.command);
2281
+ },
2282
+ children: copied ? t("updateCopied") : t("updateCopy")
2283
+ }
2284
+ )
2285
+ ] })
2286
+ ] });
2287
+ }
1805
2288
  var LABELS = {
1806
2289
  history: "history",
1807
2290
  optimize: "optimize",
1808
2291
  predict: "predict",
1809
- rollback: "rollback"
2292
+ rollback: "rollback",
2293
+ contextInspect: "contextInspect"
1810
2294
  };
1811
2295
  var DESCRIPTIONS = {
1812
2296
  history: "historyDescription",
1813
2297
  optimize: "optimizeDescription",
1814
2298
  predict: "predictDescription",
1815
- rollback: "rollbackDescription"
2299
+ rollback: "rollbackDescription",
2300
+ contextInspect: "contextInspectDescription"
1816
2301
  };
1817
- var MODEL_FEATURES = /* @__PURE__ */ new Set(["optimize", "predict"]);
1818
- function findModel(groups, provider, model) {
1819
- return groups.find((group) => group.id === provider)?.models.find((entry) => entry.id === model);
2302
+ function modelFeatureOf(module2) {
2303
+ switch (module2) {
2304
+ case "optimize":
2305
+ return "optimize";
2306
+ case "predict":
2307
+ return "predict";
2308
+ case "contextInspect":
2309
+ return "compact";
2310
+ case "history":
2311
+ case "rollback":
2312
+ return null;
2313
+ default: {
2314
+ const _exhaustive = module2;
2315
+ return _exhaustive;
2316
+ }
2317
+ }
1820
2318
  }
1821
- function pillLabel(selection, groups, followLabel) {
1822
- if (isFollowSessionModel(selection)) return followLabel;
1823
- const model = findModel(groups, selection.provider, selection.model);
1824
- const name = model?.name ?? selection.model;
1825
- if (selection.reasoningEffort === "") return name;
1826
- const effort = model?.reasoning?.efforts.find((entry) => entry.id === selection.reasoningEffort);
1827
- return `${name} \xB7 ${effort?.name ?? selection.reasoningEffort}`;
2319
+ function groupsForPills(groups) {
2320
+ return groups.flatMap((group) => {
2321
+ const models = group.models.filter((model) => !isAutoModel({ provider: group.id, model: model.id }));
2322
+ if (models.length === 0) return [];
2323
+ if (models.length === group.models.length) return [group];
2324
+ return [{ ...group, models }];
2325
+ });
1828
2326
  }
1829
- function catalogMenuItems(groups, followLabel, defaultEffortLabel) {
1830
- const items = [{ id: encodeFollowSelection(), label: followLabel }];
1831
- for (const group of groups) {
2327
+ function catalogMenuItems(groups, followLabel, autoLabel, defaultEffortLabel, includeSessionOptions, unconfiguredLabel) {
2328
+ const items = [];
2329
+ if (includeSessionOptions) {
2330
+ items.push({ id: encodeFollowSelection(), label: followLabel });
2331
+ items.push({ id: encodeAutoSelection(), label: autoLabel });
2332
+ } else if (unconfiguredLabel !== void 0) {
2333
+ items.push({ id: encodeUnconfiguredSelection(), label: unconfiguredLabel });
2334
+ }
2335
+ for (const group of groupsForPills(groups)) {
1832
2336
  items.push({ type: "separator", id: `sep:${group.id}` });
1833
2337
  items.push({ type: "label", id: `label:${group.id}`, text: group.name });
1834
2338
  for (const model of group.models) {
@@ -1854,29 +2358,36 @@ function catalogMenuItems(groups, followLabel, defaultEffortLabel) {
1854
2358
  }
1855
2359
  return items;
1856
2360
  }
1857
- function selectedMenuId(selection, groups) {
1858
- if (isFollowSessionModel(selection)) return encodeFollowSelection();
1859
- const model = findModel(groups, selection.provider, selection.model);
1860
- if ((model?.reasoning?.efforts.length ?? 0) > 0) {
1861
- return encodeEffortSelection(selection.provider, selection.model, selection.reasoningEffort);
1862
- }
1863
- return encodeModelSelection(selection.provider, selection.model);
2361
+ function selectedMenuId(selection, groups, tierMapping) {
2362
+ return selectedPillMenuId(selection, groups, { tierMapping });
1864
2363
  }
1865
2364
  function ModelPill({
1866
- feature,
1867
2365
  selection,
1868
2366
  groups,
1869
2367
  catalogStatus,
1870
2368
  disabled,
1871
2369
  t,
2370
+ ariaLabel,
2371
+ includeSessionOptions,
1872
2372
  onOpen,
1873
2373
  onSelect
1874
2374
  }) {
1875
2375
  const [open, setOpen] = (0, import_react4.useState)(false);
1876
2376
  const followLabel = t("modelFollowSession");
1877
- const label = catalogStatus === "loading" ? t("modelCatalogLoading") : catalogStatus === "error" ? t("modelCatalogError") : pillLabel(selection, groups, followLabel);
1878
- const items = catalogMenuItems(groups, followLabel, t("reasoningDefault"));
1879
- const active = !isFollowSessionModel(selection);
2377
+ const autoLabel = t("modelAuto");
2378
+ const unconfiguredLabel = includeSessionOptions ? void 0 : t("modelUnconfigured");
2379
+ const label = catalogStatus === "loading" ? t("modelCatalogLoading") : catalogStatus === "error" ? t("modelCatalogError") : pillLabel(selection, groups, followLabel, autoLabel, unconfiguredLabel);
2380
+ const items = catalogMenuItems(
2381
+ groups,
2382
+ followLabel,
2383
+ autoLabel,
2384
+ t("reasoningDefault"),
2385
+ includeSessionOptions,
2386
+ unconfiguredLabel
2387
+ );
2388
+ const tierMapping = !includeSessionOptions;
2389
+ const active = tierMapping ? !isUnconfiguredAutoTierMapping(selection) && !isFollowSessionModel(selection) : !isFollowSessionModel(selection);
2390
+ const catalogFallbackItems = includeSessionOptions ? [{ id: encodeFollowSelection(), label: followLabel }, { id: encodeAutoSelection(), label: autoLabel }] : [{ id: encodeUnconfiguredSelection(), label: unconfiguredLabel ?? t("modelUnconfigured") }];
1880
2391
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1881
2392
  import_dsh_client_ui_primitives4.Menu,
1882
2393
  {
@@ -1889,11 +2400,11 @@ function ModelPill({
1889
2400
  portal: true,
1890
2401
  compact: true,
1891
2402
  dense: true,
1892
- selectedId: selectedMenuId(selection, groups),
1893
- items: catalogStatus === "ready" ? items : [{ id: encodeFollowSelection(), label: followLabel }],
2403
+ selectedId: selectedMenuId(selection, groups, tierMapping),
2404
+ items: catalogStatus === "ready" ? items : catalogFallbackItems,
1894
2405
  onSelect: (id) => {
1895
2406
  setOpen(false);
1896
- onSelect(feature, id);
2407
+ onSelect(id);
1897
2408
  },
1898
2409
  anchor: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1899
2410
  import_dsh_client_ui_primitives4.Pill,
@@ -1901,7 +2412,7 @@ function ModelPill({
1901
2412
  active: active || open,
1902
2413
  disabled,
1903
2414
  className: css_module_default.modelPill,
1904
- "aria-label": `${t(LABELS[feature])} ${t("modelLabel")}`,
2415
+ "aria-label": ariaLabel,
1905
2416
  title: label,
1906
2417
  onClick: () => {
1907
2418
  if (disabled) return;
@@ -1927,7 +2438,21 @@ var SettingsErrorBoundary = class extends import_react4.Component {
1927
2438
  return this.props.children;
1928
2439
  }
1929
2440
  };
1930
- function PluginSettingsBody({ form, t, loadCatalog }) {
2441
+ function featureDetailTitle(feature, t) {
2442
+ switch (feature) {
2443
+ case "optimize":
2444
+ return t("optimize");
2445
+ case "predict":
2446
+ return t("predict");
2447
+ case "compact":
2448
+ return t("contextInspect");
2449
+ default: {
2450
+ const _exhaustive = feature;
2451
+ return _exhaustive;
2452
+ }
2453
+ }
2454
+ }
2455
+ function PluginSettingsBody({ form, t, loadCatalog, checkUpdate, applyUpdate }) {
1931
2456
  const formState = (0, import_react4.useSyncExternalStore)(
1932
2457
  (listener) => form.subscribe(listener),
1933
2458
  () => form.getSnapshot(),
@@ -1935,6 +2460,7 @@ function PluginSettingsBody({ form, t, loadCatalog }) {
1935
2460
  );
1936
2461
  const settings = resolveSettings(formState?.value);
1937
2462
  const writable = formState?.writable !== false;
2463
+ const [view, setView] = (0, import_react4.useState)({ kind: "home" });
1938
2464
  const [saving, setSaving] = (0, import_react4.useState)(null);
1939
2465
  const [error, setError] = (0, import_react4.useState)(false);
1940
2466
  const [catalog, setCatalog] = (0, import_react4.useState)(null);
@@ -2014,49 +2540,197 @@ function PluginSettingsBody({ form, t, loadCatalog }) {
2014
2540
  const onModelMenuSelect = async (feature, id) => {
2015
2541
  const decoded = decodeModelSelection(id);
2016
2542
  if (decoded === null) return;
2017
- if (decoded.kind === "follow") {
2018
- await saveFields([
2019
- [`${feature}Provider`, ""],
2020
- [`${feature}Model`, ""],
2021
- [`${feature}ReasoningEffort`, ""]
2022
- ]);
2023
- return;
2543
+ switch (decoded.kind) {
2544
+ case "follow":
2545
+ await saveFields([
2546
+ [`${feature}Provider`, ""],
2547
+ [`${feature}Model`, ""],
2548
+ [`${feature}ReasoningEffort`, ""]
2549
+ ]);
2550
+ return;
2551
+ case "auto":
2552
+ await saveFields([
2553
+ [`${feature}Provider`, AUTO_PROVIDER],
2554
+ [`${feature}Model`, AUTO_MODEL],
2555
+ [`${feature}ReasoningEffort`, ""]
2556
+ ]);
2557
+ return;
2558
+ case "unconfigured":
2559
+ return;
2560
+ case "model":
2561
+ await saveFields([
2562
+ [`${feature}Provider`, decoded.provider],
2563
+ [`${feature}Model`, decoded.model],
2564
+ [`${feature}ReasoningEffort`, decoded.reasoningEffort]
2565
+ ]);
2566
+ return;
2567
+ default: {
2568
+ const _exhaustive = decoded;
2569
+ return _exhaustive;
2570
+ }
2571
+ }
2572
+ };
2573
+ const onAutoTierMenuSelect = async (tier, id) => {
2574
+ const decoded = decodeModelSelection(id);
2575
+ if (decoded === null) return;
2576
+ const prefix = autoTierFieldPrefix(tier);
2577
+ switch (decoded.kind) {
2578
+ case "unconfigured":
2579
+ await saveFields([
2580
+ [`${prefix}Provider`, ""],
2581
+ [`${prefix}Model`, ""],
2582
+ [`${prefix}ReasoningEffort`, ""]
2583
+ ]);
2584
+ return;
2585
+ case "model":
2586
+ await saveFields([
2587
+ [`${prefix}Provider`, decoded.provider],
2588
+ [`${prefix}Model`, decoded.model],
2589
+ [`${prefix}ReasoningEffort`, decoded.reasoningEffort]
2590
+ ]);
2591
+ return;
2592
+ case "follow":
2593
+ case "auto":
2594
+ return;
2595
+ default: {
2596
+ const _exhaustive = decoded;
2597
+ return _exhaustive;
2598
+ }
2599
+ }
2600
+ };
2601
+ const onClassifierToggle = async (checked) => {
2602
+ setSaving("autoClassifierEnabled");
2603
+ setError(false);
2604
+ try {
2605
+ const accepted = await form.set("autoClassifierEnabled", checked);
2606
+ if (!accepted) setError(true);
2607
+ } catch {
2608
+ setError(true);
2609
+ } finally {
2610
+ setSaving(null);
2024
2611
  }
2025
- await saveFields([
2026
- [`${feature}Provider`, decoded.provider],
2027
- [`${feature}Model`, decoded.model],
2028
- [`${feature}ReasoningEffort`, decoded.reasoningEffort]
2029
- ]);
2030
2612
  };
2613
+ const autoTiers = ["instant", "thinking", "pro", "classifier"];
2031
2614
  const busy = !writable || saving !== null;
2032
2615
  const groups = catalog?.groups ?? [];
2616
+ const goHome = () => {
2617
+ setView({ kind: "home" });
2618
+ };
2619
+ const statusBlock = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2620
+ error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "status", children: t("settingsError") }),
2621
+ catalogStatus === "error" && catalogError !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { role: "status", className: css_module_default.settingDescription, title: catalogError, children: [
2622
+ t("modelCatalogError"),
2623
+ ": ",
2624
+ catalogError
2625
+ ] })
2626
+ ] });
2627
+ if (view.kind === "feature") {
2628
+ const selection = auxiliaryModelOf(settings, view.feature);
2629
+ const title = featureDetailTitle(view.feature, t);
2630
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { "aria-label": title, className: css_module_default.settings, children: [
2631
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: css_module_default.settingsHeader, children: [
2632
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: css_module_default.settingsBack, onClick: goHome, children: t("settingsBack") }),
2633
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { children: title }),
2634
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t("modelLabel") })
2635
+ ] }),
2636
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2637
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingText, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("modelLabel") }) }),
2638
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingControls, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2639
+ ModelPill,
2640
+ {
2641
+ selection,
2642
+ groups,
2643
+ catalogStatus,
2644
+ disabled: busy || view.feature === "compact" && !settings.contextInspectEnabled,
2645
+ t,
2646
+ ariaLabel: `${title} ${t("modelLabel")}`,
2647
+ includeSessionOptions: true,
2648
+ onOpen: refreshCatalog,
2649
+ onSelect: (id) => {
2650
+ void onModelMenuSelect(view.feature, id);
2651
+ }
2652
+ }
2653
+ ) })
2654
+ ] }),
2655
+ statusBlock
2656
+ ] });
2657
+ }
2658
+ if (view.kind === "auto") {
2659
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { "aria-label": t("autoRouting"), className: css_module_default.settings, children: [
2660
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: css_module_default.settingsHeader, children: [
2661
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: css_module_default.settingsBack, onClick: goHome, children: t("settingsBack") }),
2662
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { children: t("autoRouting") }),
2663
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t("autoRoutingDescription") })
2664
+ ] }),
2665
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2666
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingText, children: [
2667
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("autoClassifier") }),
2668
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingDescription, children: t("autoClassifierDescription") })
2669
+ ] }),
2670
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingControls, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2671
+ import_dsh_client_ui_primitives4.Switch,
2672
+ {
2673
+ label: t("autoClassifier"),
2674
+ checked: settings.autoClassifierEnabled,
2675
+ disabled: busy,
2676
+ onChange: (checked) => {
2677
+ void onClassifierToggle(checked);
2678
+ }
2679
+ }
2680
+ ) })
2681
+ ] }),
2682
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { "aria-label": t("autoMappingTitle"), className: css_module_default.autoMappingSection, children: [
2683
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("autoMappingTitle") }),
2684
+ autoTiers.map((tier) => {
2685
+ const tierSelection = autoTierSelection(settings, tier);
2686
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2687
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingText, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t(AUTO_TIER_LABELS[tier]) }) }),
2688
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingControls, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2689
+ ModelPill,
2690
+ {
2691
+ selection: tierSelection,
2692
+ groups,
2693
+ catalogStatus,
2694
+ disabled: busy,
2695
+ t,
2696
+ ariaLabel: `${t(AUTO_TIER_LABELS[tier])} ${t("modelLabel")}`,
2697
+ includeSessionOptions: false,
2698
+ onOpen: refreshCatalog,
2699
+ onSelect: (id) => {
2700
+ void onAutoTierMenuSelect(tier, id);
2701
+ }
2702
+ }
2703
+ ) })
2704
+ ] }, tier);
2705
+ })
2706
+ ] }),
2707
+ statusBlock
2708
+ ] });
2709
+ }
2033
2710
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { "aria-label": t("settingsTitle"), className: css_module_default.settings, children: [
2034
2711
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: css_module_default.settingsHeader, children: [
2035
2712
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { children: t("settingsTitle") }),
2036
2713
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t("settingsSubtitle") })
2037
2714
  ] }),
2038
2715
  MODULES.map((module2) => {
2039
- const modelFeature = MODEL_FEATURES.has(module2) ? module2 : null;
2040
- const selection = modelFeature === null ? null : auxiliaryModelOf(settings, modelFeature);
2716
+ const modelFeature = modelFeatureOf(module2);
2041
2717
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2042
2718
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingText, children: [
2043
2719
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t(LABELS[module2]) }),
2044
2720
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingDescription, children: t(DESCRIPTIONS[module2]) })
2045
2721
  ] }),
2046
2722
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingControls, children: [
2047
- modelFeature !== null && selection !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2048
- ModelPill,
2723
+ modelFeature !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2724
+ "button",
2049
2725
  {
2050
- feature: modelFeature,
2051
- selection,
2052
- groups,
2053
- catalogStatus,
2726
+ type: "button",
2727
+ className: css_module_default.settingsConfigure,
2054
2728
  disabled: busy,
2055
- t,
2056
- onOpen: refreshCatalog,
2057
- onSelect: (feature, id) => {
2058
- void onModelMenuSelect(feature, id);
2059
- }
2729
+ "aria-label": `${t(LABELS[module2])} ${t("settingsConfigure")}`,
2730
+ onClick: () => {
2731
+ setView({ kind: "feature", feature: modelFeature });
2732
+ },
2733
+ children: t("settingsConfigure")
2060
2734
  }
2061
2735
  ),
2062
2736
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -2073,12 +2747,27 @@ function PluginSettingsBody({ form, t, loadCatalog }) {
2073
2747
  ] })
2074
2748
  ] }, module2);
2075
2749
  }),
2076
- error && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "status", children: t("settingsError") }),
2077
- catalogStatus === "error" && catalogError !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { role: "status", className: css_module_default.settingDescription, title: catalogError, children: [
2078
- t("modelCatalogError"),
2079
- ": ",
2080
- catalogError
2750
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingRow, children: [
2751
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: css_module_default.settingText, children: [
2752
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("autoRouting") }),
2753
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: css_module_default.settingDescription, children: t("autoRoutingDescription") })
2754
+ ] }),
2755
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: css_module_default.settingControls, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2756
+ "button",
2757
+ {
2758
+ type: "button",
2759
+ className: css_module_default.settingsConfigure,
2760
+ disabled: busy,
2761
+ "aria-label": `${t("autoRouting")} ${t("settingsConfigure")}`,
2762
+ onClick: () => {
2763
+ setView({ kind: "auto" });
2764
+ },
2765
+ children: t("settingsConfigure")
2766
+ }
2767
+ ) })
2081
2768
  ] }),
2769
+ checkUpdate !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SettingsUpdateSection, { checkUpdate, applyUpdate, t }),
2770
+ statusBlock,
2082
2771
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("aside", { "aria-label": t("privacyTitle"), className: css_module_default.privacy, children: [
2083
2772
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t("privacyTitle") }),
2084
2773
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t("privacy") }),
@@ -2095,67 +2784,1660 @@ function PluginSettings(props) {
2095
2784
  ] }), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PluginSettingsBody, { ...props }) });
2096
2785
  }
2097
2786
 
2098
- // src/client/locales.ts
2099
- var agentLocales = {
2100
- zh: {
2101
- historyTitle: "\u5386\u53F2\u63D0\u793A\u8BCD",
2102
- historySearch: "\u641C\u7D22\u5386\u53F2\u63D0\u793A\u8BCD",
2103
- historyResults: "\u5386\u53F2\u63D0\u793A\u8BCD\u7ED3\u679C",
2104
- historyClose: "\u5173\u95ED\u5386\u53F2\u63D0\u793A\u8BCD",
2105
- optimize: "\u4F18\u5316\u63D0\u793A\u8BCD",
2106
- optimizePending: "\u6B63\u5728\u4F18\u5316\u63D0\u793A\u8BCD",
2107
- optimizeUndo: "\u64A4\u9500\u4F18\u5316",
2108
- optimizeError: "\u4F18\u5316\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
2109
- optimizeModelUnavailable: "\u5F53\u524D\u6A21\u578B\u4E0D\u53EF\u7528\uFF0C\u8BF7\u68C0\u67E5\u6A21\u578B\u9009\u62E9",
2110
- optimizeRequestFailed: "\u4F18\u5316\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
2111
- optimizeInvalidOutput: "\u6A21\u578B\u8FD4\u56DE\u5185\u5BB9\u65E0\u6CD5\u5B89\u5168\u5E94\u7528\uFF0C\u8BF7\u91CD\u8BD5",
2112
- optimizeRollbackFailed: "\u8349\u7A3F\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8349\u7A3F\u5E76\u624B\u52A8\u6062\u590D",
2113
- optimizeSessionChanged: "\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u4F18\u5316",
2114
- optimizeChips: "\u4FDD\u7559\u5F15\u7528\uFF0C\u4EC5\u4F18\u5316\u5176\u4ED6\u6587\u5B57",
2115
- optimizeChipSelection: "\u9009\u533A\u5305\u542B\u5F15\u7528\uFF0C\u8BF7\u4F18\u5316\u6574\u7A3F\u6216\u8C03\u6574\u9009\u533A",
2116
- settingsTitle: "\u667A\u80FD\u4F53\u589E\u5F3A",
2117
- settingsSubtitle: "\u4E00\u4E2A\u63D2\u4EF6\u8865\u9F50\u5E38\u7528 Agent \u4F53\u9A8C\uFF0C\u6309\u9700\u5F00\u5173",
2118
- history: "\u5386\u53F2\u63D0\u793A\u8BCD",
2119
- historyDescription: "\u2191\u2193 \u56DE\u987E\u5DF2\u53D1\u9001\u63D0\u793A\u8BCD\uFF1BAlt+R \u641C\u7D22\uFF08\u53EF\u7528\u73AF\u5883\u517C\u5BB9 Ctrl+R\uFF09",
2120
- optimizeDescription: "\u4F18\u5316\u8349\u7A3F\u6216\u6240\u9009\u5185\u5BB9\uFF0C\u652F\u6301\u4E00\u952E\u64A4\u9500",
2121
- predict: "\u4E0B\u4E00\u6761\u63D0\u793A\u8BCD\u9884\u6D4B",
2122
- predictDescription: "\u56DE\u590D\u540E\u7ED9\u51FA\u4E00\u6761\u5EFA\u8BAE\uFF0C\u6309 Tab \u91C7\u7EB3",
2123
- modelCatalogLoading: "\u52A0\u8F7D\u4E2D\u2026",
2124
- modelCatalogError: "\u6A21\u578B\u4E0D\u53EF\u7528",
2125
- modelLabel: "\u6A21\u578B",
2126
- modelFollowSession: "\u8DDF\u968F\u4F1A\u8BDD",
2127
- reasoningDefault: "\u9ED8\u8BA4",
2128
- privacyTitle: "\u6570\u636E\u4E0E\u9690\u79C1",
2129
- privacy: "\u4F18\u5316\u548C\u9884\u6D4B\u4F1A\u628A\u6240\u9009\u5185\u5BB9\u6216\u8FD1\u671F\u5BF9\u8BDD\u53D1\u9001\u7ED9\u6240\u9009\u6A21\u578B\u63D0\u4F9B\u5546\uFF08\u9ED8\u8BA4\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\u6A21\u578B\uFF09\uFF1B\u5386\u53F2\u4E0D\u8BF7\u6C42\u6A21\u578B\uFF1B\u4E0D\u91C7\u96C6\u63D0\u793A\u8BCD\u5185\u5BB9\u6216\u91C7\u7EB3\u7387\u9065\u6D4B\u3002",
2130
- coexistence: "\u68C0\u6D4B\u5230\u5B98\u65B9\u6216\u7B2C\u4E09\u65B9\u540C\u7C7B\u80FD\u529B\u65F6\u4EC5\u63D0\u793A\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u505C\u7528\u3002",
2131
- settingsError: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002",
2132
- overlapHistory: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u5386\u53F2\u63D0\u793A\u8BCD\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u5386\u53F2\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
2133
- overlapOptimize: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u63D0\u793A\u8BCD\u4F18\u5316\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u4F18\u5316\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
2134
- overlapPredict: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u56DE\u590D\u5EFA\u8BAE\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u9884\u6D4B\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
2135
- dismissHint: "\u5173\u95ED\u5171\u5B58\u63D0\u793A",
2136
- rollback: "\u5BF9\u8BDD\u4E0E\u6587\u4EF6\u6062\u590D",
2137
- rollbackDescription: "\u5728\u5408\u89C4\u7528\u6237\u6D88\u606F\u65C1\u9884\u89C8\u5E76\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
2138
- rollbackBoundary: "\u4E0D\u6062\u590D\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u6216\u672A\u8DDF\u8E2A\u6587\u4EF6\uFF1B\u5173\u95ED\u540E\u4FDD\u7559\u5DF2\u6709\u65E5\u5FD7\u548C\u68C0\u67E5\u70B9\u3002",
2139
- rollbackAction: "\u6062\u590D\u5230\u8FD9\u91CC",
2140
- rollbackUndoAction: "\u64A4\u9500\u6062\u590D",
2141
- rollbackUndoCommandDescription: "\u64A4\u56DE\u6700\u8FD1\u4E00\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u9884\u89C8\u5185\u5BB9",
2142
- rollbackTitle: "\u6062\u590D\u5230\u7B2C {turn} \u8F6E\u4E4B\u524D",
2143
- rollbackUndoTitle: "\u64A4\u9500\u7B2C {turn} \u8F6E\u6062\u590D",
2144
- rollbackScope: "\u53EF\u9009\u62E9\u4EC5\u6062\u590D\u5BF9\u8BDD\uFF0C\u6216\u540C\u65F6\u6062\u590D\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002\u65E0\u6587\u4EF6\u53D8\u66F4\u6216\u4EC5\u6709\u6355\u83B7\u7F3A\u53E3\u65F6\u4ECD\u53EF\u786E\u8BA4\uFF1B\u6709\u6587\u4EF6\u51B2\u7A81\u65F6\u4ECD\u53EF\u4EC5\u6062\u590D\u5BF9\u8BDD\u3002",
2145
- rollbackUndoScope: "\u5C06\u64A4\u56DE\u672C\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u9884\u89C8\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002",
2146
- rollbackUndoScopeConversation: "\u5C06\u64A4\u56DE\u672C\u6B21\u4EC5\u5BF9\u8BDD\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u9884\u89C8\u3002\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u4FDD\u6301\u5F53\u524D\u72B6\u6001\u3002",
2147
- rollbackClose: "\u5173\u95ED\u6062\u590D\u9884\u89C8",
2148
- rollbackConfirm: "\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
2149
- rollbackConfirmConversation: "\u4EC5\u6062\u590D\u5BF9\u8BDD",
2150
- rollbackUndoConfirm: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u9884\u89C8\u5185\u5BB9",
2151
- rollbackUndoConfirmConversation: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD",
2152
- rollbackCancel: "\u53D6\u6D88",
2153
- rollbackLoading: "\u6B63\u5728\u91CD\u65B0\u68C0\u67E5\u5BF9\u8BDD\u548C\u6587\u4EF6\u72B6\u6001\u2026",
2154
- rollbackRestoring: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
2155
- rollbackRestoringConversation: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u2026",
2156
- rollbackUndoRestoring: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
2157
- rollbackUndoRestoringConversation: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u2026",
2158
- rollbackFailed: "\u6062\u590D\u672A\u5B8C\u6210\uFF0C\u8BF7\u5173\u95ED\u9884\u89C8\u540E\u91CD\u8BD5\u3002",
2787
+ // src/client/context/dock.tsx
2788
+ var import_react5 = require("react");
2789
+
2790
+ // src/client/context/enhance-meter.ts
2791
+ var CATEGORIES = ["system", "tools", "messages"];
2792
+ var ENHANCED_ATTR = "data-agent-enhancer-context";
2793
+ var ROW_ATTR = "data-agent-enhancer-context-row";
2794
+ function cls(value) {
2795
+ return value ?? "";
2796
+ }
2797
+ function findOpenContextMeterPanel() {
2798
+ const dock = document.querySelector("[data-composer-dock]");
2799
+ if (!(dock instanceof HTMLElement)) return null;
2800
+ const trigger = dock.querySelector('button[aria-haspopup="dialog"][aria-expanded="true"]');
2801
+ if (!(trigger instanceof HTMLElement)) return null;
2802
+ const dialogs = document.querySelectorAll('body > [role="dialog"]');
2803
+ for (let index = dialogs.length - 1; index >= 0; index -= 1) {
2804
+ const dialog = dialogs[index];
2805
+ if (dialog === void 0) continue;
2806
+ const rows = dialog.querySelectorAll(":scope > dl > div");
2807
+ if (rows.length === 3) return dialog;
2808
+ }
2809
+ return null;
2810
+ }
2811
+ function enhancePanel(panel, options) {
2812
+ if (!options.enabled() || panel.getAttribute(ENHANCED_ATTR) === "1") return;
2813
+ const rows = [...panel.querySelectorAll(":scope > dl > div")];
2814
+ if (rows.length !== 3) return;
2815
+ panel.setAttribute(ENHANCED_ATTR, "1");
2816
+ rows.forEach((row, index) => {
2817
+ if (!(row instanceof HTMLElement)) return;
2818
+ const category = CATEGORIES[index];
2819
+ if (category === void 0) return;
2820
+ row.setAttribute(ROW_ATTR, category);
2821
+ row.classList.add(cls(css_module_default.contextMeterRow));
2822
+ row.tabIndex = 0;
2823
+ row.setAttribute("role", "button");
2824
+ row.setAttribute("aria-label", String(options.t("contextInspectOpenCategory", {
2825
+ category: String(options.t(`contextInspectCategory_${category}`))
2826
+ })));
2827
+ if (!row.querySelector("[data-agent-enhancer-chevron]")) {
2828
+ const chevron = document.createElement("span");
2829
+ chevron.dataset.agentEnhancerChevron = "1";
2830
+ chevron.className = cls(css_module_default.contextMeterChevron);
2831
+ chevron.setAttribute("aria-hidden", "true");
2832
+ chevron.textContent = "\u203A";
2833
+ row.append(chevron);
2834
+ }
2835
+ const open = () => {
2836
+ if (!options.enabled()) return;
2837
+ const sessionId = options.sessionId();
2838
+ if (sessionId === void 0 || sessionId === "") return;
2839
+ options.open(category);
2840
+ };
2841
+ row.addEventListener("click", (event) => {
2842
+ event.preventDefault();
2843
+ event.stopPropagation();
2844
+ open();
2845
+ });
2846
+ row.addEventListener("keydown", (event) => {
2847
+ if (event.key !== "Enter" && event.key !== " ") return;
2848
+ event.preventDefault();
2849
+ event.stopPropagation();
2850
+ open();
2851
+ });
2852
+ });
2853
+ }
2854
+ function installContextMeterEnhance(options) {
2855
+ const scan = () => {
2856
+ const panel = findOpenContextMeterPanel();
2857
+ if (panel !== null) enhancePanel(panel, options);
2858
+ };
2859
+ const observer = new MutationObserver(scan);
2860
+ observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-expanded"] });
2861
+ scan();
2862
+ return () => {
2863
+ observer.disconnect();
2864
+ };
2865
+ }
2866
+
2867
+ // src/client/context/dock.tsx
2868
+ function ContextInspectDock(props) {
2869
+ const sessionId = props.sessionId;
2870
+ (0, import_react5.useEffect)(() => installContextMeterEnhance({
2871
+ enabled: props.enabled,
2872
+ sessionId: () => sessionId,
2873
+ open: props.open,
2874
+ t: (key, params) => props.t(key, params)
2875
+ }), [sessionId, props.enabled, props.open, props.t]);
2876
+ return null;
2877
+ }
2878
+
2879
+ // src/client/dsh/usage-kind.ts
2880
+ var USAGE_TAB_ID = "dsh-agent-enhancer/usage";
2881
+ var USAGE_TAB_KIND = "agentEnhancerUsage";
2882
+
2883
+ // src/client/context/tab.ts
2884
+ var CONTEXT_INSPECT_TAB_ID = "dsh-agent-enhancer/contextInspect";
2885
+ var CONTEXT_INSPECT_TAB_KIND = "agentEnhancerContextInspect";
2886
+
2887
+ // src/client/context/open-tab.ts
2888
+ function openRightTab(sidebarRight, kind, params) {
2889
+ let cancelled = false;
2890
+ let timer = null;
2891
+ let attempts = 0;
2892
+ const maxAttempts = 40;
2893
+ const clear = () => {
2894
+ if (timer !== null) {
2895
+ clearTimeout(timer);
2896
+ timer = null;
2897
+ }
2898
+ };
2899
+ const finish = () => {
2900
+ cancelled = true;
2901
+ clear();
2902
+ };
2903
+ const run = () => {
2904
+ if (cancelled) return;
2905
+ attempts += 1;
2906
+ if (sidebarRight === void 0 || typeof sidebarRight.openTab !== "function") {
2907
+ if (attempts >= maxAttempts) return finish();
2908
+ timer = setTimeout(run, 150);
2909
+ return;
2910
+ }
2911
+ try {
2912
+ sidebarRight.openTab(kind, { params });
2913
+ finish();
2914
+ } catch {
2915
+ if (attempts >= maxAttempts) return finish();
2916
+ timer = setTimeout(run, 200);
2917
+ }
2918
+ };
2919
+ run();
2920
+ return finish;
2921
+ }
2922
+ function openContextInspectTab(sidebarRight, params) {
2923
+ return openRightTab(sidebarRight, CONTEXT_INSPECT_TAB_KIND, params);
2924
+ }
2925
+ function openUsageTab(sidebarRight) {
2926
+ return openRightTab(sidebarRight, USAGE_TAB_KIND, {});
2927
+ }
2928
+
2929
+ // src/client/context/right-tab.tsx
2930
+ var import_react7 = require("react");
2931
+
2932
+ // src/client/context/chart.tsx
2933
+ var import_react6 = require("react");
2934
+
2935
+ // src/client/context/format.ts
2936
+ function formatTokens(value) {
2937
+ if (value < 1e3) return String(value);
2938
+ if (value < 1e6) {
2939
+ const scaled2 = value / 1e3;
2940
+ return `${scaled2 >= 100 ? Math.round(scaled2) : Math.round(scaled2 * 10) / 10}K`;
2941
+ }
2942
+ const scaled = value / 1e6;
2943
+ return `${scaled >= 100 ? Math.round(scaled) : Math.round(scaled * 10) / 10}M`;
2944
+ }
2945
+ function sharePercent(tokens, total) {
2946
+ if (total <= 0 || tokens <= 0) return 0;
2947
+ return Math.max(1, Math.round(tokens / total * 100));
2948
+ }
2949
+
2950
+ // src/client/context/chart.tsx
2951
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2952
+ var CATEGORY_COLORS = {
2953
+ system: "#4c8bf5",
2954
+ tools: "#2f9e6b",
2955
+ messages: "#d4a017"
2956
+ };
2957
+ var KIND_COLORS = {
2958
+ system: "#4c8bf5",
2959
+ tools: "#2f9e6b",
2960
+ user: "#5b8def",
2961
+ inject: "#7c8cff",
2962
+ assistant: "#d4a017",
2963
+ tool: "#2f9e6b",
2964
+ developer: "#8a94a6"
2965
+ };
2966
+ function colorForCategory(category) {
2967
+ return CATEGORY_COLORS[category];
2968
+ }
2969
+ function colorForKind(kind) {
2970
+ return KIND_COLORS[kind];
2971
+ }
2972
+ function ContextShareChart(props) {
2973
+ const tipId = (0, import_react6.useId)();
2974
+ const [hoveredId, setHoveredId] = (0, import_react6.useState)(null);
2975
+ const total = props.slices.reduce((sum, slice) => sum + slice.tokens, 0);
2976
+ const projected = props.pressure?.projectedTokens;
2977
+ const window2 = props.pressure?.contextWindow;
2978
+ const occupancy = projected !== void 0 && window2 !== void 0 && window2 > 0 ? Math.min(100, Math.round(projected / window2 * 1e3) / 10) : void 0;
2979
+ const remaining = projected !== void 0 && window2 !== void 0 ? Math.max(0, window2 - projected) : void 0;
2980
+ const empty = total <= 0 || props.slices.length === 0;
2981
+ const hovered = hoveredId === null ? void 0 : props.slices.find((slice) => slice.id === hoveredId);
2982
+ const tipText = hovered === void 0 ? void 0 : `${hovered.label} \xB7 ~${formatTokens(hovered.tokens)} \xB7 ${sharePercent(hovered.tokens, total)}%`;
2983
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextChart, "aria-label": props.title, children: [
2984
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextChartHeading, children: [
2985
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: css_module_default.contextChartTitle, children: props.title }),
2986
+ !empty ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: css_module_default.contextChartTotal, children: [
2987
+ "~",
2988
+ formatTokens(total),
2989
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: css_module_default.contextChartTotalHint, children: [
2990
+ " ",
2991
+ props.totalLabel
2992
+ ] })
2993
+ ] }) : null
2994
+ ] }),
2995
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: css_module_default.contextRightStatus, children: props.emptyLabel }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2996
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2997
+ "div",
2998
+ {
2999
+ className: css_module_default.contextStackWrap,
3000
+ onMouseLeave: () => setHoveredId(null),
3001
+ children: [
3002
+ tipText !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextChartTip, id: tipId, role: "tooltip", children: [
3003
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3004
+ "span",
3005
+ {
3006
+ className: css_module_default.contextChartTipSwatch,
3007
+ style: { background: hovered.color }
3008
+ }
3009
+ ),
3010
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: tipText })
3011
+ ] }) : null,
3012
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: css_module_default.contextStack, "aria-hidden": "true", children: props.slices.map((slice) => {
3013
+ const active = hoveredId === null || hoveredId === slice.id;
3014
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3015
+ "span",
3016
+ {
3017
+ className: active ? css_module_default.contextStackSegment : css_module_default.contextStackSegmentDim,
3018
+ style: {
3019
+ width: `${Math.max(1.5, slice.tokens / total * 100)}%`,
3020
+ background: slice.color
3021
+ },
3022
+ onMouseEnter: () => setHoveredId(slice.id)
3023
+ },
3024
+ slice.id
3025
+ );
3026
+ }) })
3027
+ ]
3028
+ }
3029
+ ),
3030
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: css_module_default.contextChartLegend, children: props.slices.map((slice) => {
3031
+ const share = sharePercent(slice.tokens, total);
3032
+ const active = hoveredId === null || hoveredId === slice.id;
3033
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
3034
+ "li",
3035
+ {
3036
+ className: active ? css_module_default.contextChartLegendItem : css_module_default.contextChartLegendItemDim,
3037
+ onMouseEnter: () => setHoveredId(slice.id),
3038
+ onMouseLeave: () => setHoveredId(null),
3039
+ children: [
3040
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: css_module_default.contextChartSwatch, style: { background: slice.color } }),
3041
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextChartLegendMain, children: [
3042
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextChartLegendTop, children: [
3043
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: css_module_default.contextChartLegendLabel, children: slice.label }),
3044
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: css_module_default.contextChartLegendMeta, children: [
3045
+ "~",
3046
+ formatTokens(slice.tokens),
3047
+ " \xB7 ",
3048
+ share,
3049
+ "%"
3050
+ ] })
3051
+ ] }),
3052
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: css_module_default.contextChartLegendTrack, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3053
+ "div",
3054
+ {
3055
+ className: css_module_default.contextChartLegendFill,
3056
+ style: { width: `${share}%`, background: slice.color }
3057
+ }
3058
+ ) })
3059
+ ] })
3060
+ ]
3061
+ },
3062
+ slice.id
3063
+ );
3064
+ }) })
3065
+ ] }),
3066
+ projected !== void 0 || window2 !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextHeadroom, "aria-label": props.headroomLabel, children: [
3067
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextHeadroomMeta, children: [
3068
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: props.occupiedLabel }),
3069
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: css_module_default.contextHeadroomValue, children: [
3070
+ projected !== void 0 ? `~${formatTokens(projected)}` : "\u2014",
3071
+ window2 !== void 0 ? ` / ${formatTokens(window2)}` : "",
3072
+ occupancy !== void 0 ? ` \xB7 ${occupancy}%` : ""
3073
+ ] })
3074
+ ] }),
3075
+ window2 !== void 0 && projected !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: css_module_default.contextHeadroomTrack, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3076
+ "div",
3077
+ {
3078
+ className: css_module_default.contextHeadroomFill,
3079
+ style: { width: `${Math.min(100, projected / window2 * 100)}%` }
3080
+ }
3081
+ ) }) : null,
3082
+ remaining !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: css_module_default.contextHeadroomHint, children: [
3083
+ props.headroomLabel,
3084
+ ": ~",
3085
+ formatTokens(remaining)
3086
+ ] }) : null
3087
+ ] }) : null
3088
+ ] });
3089
+ }
3090
+
3091
+ // src/client/context/icons.tsx
3092
+ var import_jsx_runtime7 = require("react/jsx-runtime");
3093
+ var size = 14;
3094
+ function CompactIcon(props) {
3095
+ const px = props.size ?? 16;
3096
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: px, height: px, viewBox: "0 0 16 16", "aria-hidden": "true", children: [
3097
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3098
+ "path",
3099
+ {
3100
+ fill: "currentColor",
3101
+ d: "M2 3.2A1.2 1.2 0 0 1 3.2 2h9.6A1.2 1.2 0 0 1 14 3.2v1.1a.7.7 0 0 1-1.4 0V3.4H3.4v.9a.7.7 0 1 1-1.4 0V3.2Zm0 8.5v1.1A1.2 1.2 0 0 0 3.2 14h9.6a1.2 1.2 0 0 0 1.2-1.2v-1.1a.7.7 0 0 0-1.4 0v.9H3.4v-.9a.7.7 0 0 0-1.4 0Z"
3102
+ }
3103
+ ),
3104
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3105
+ "path",
3106
+ {
3107
+ fill: "currentColor",
3108
+ d: "M5.05 5.2a.7.7 0 0 1 .99.05L8 7.36l1.96-2.11a.7.7 0 1 1 1.04.94L8.7 8.6a1 1 0 0 1-1.4 0L4.99 6.19a.7.7 0 0 1 .06-.99Zm0 5.6a.7.7 0 0 0 .99-.05L8 8.64l1.96 2.11a.7.7 0 1 0 1.04-.94L8.7 7.4a1 1 0 0 0-1.4 0L4.99 9.81a.7.7 0 0 0 .06.99Z"
3109
+ }
3110
+ )
3111
+ ] });
3112
+ }
3113
+ function CategoryIcon(props) {
3114
+ switch (props.category) {
3115
+ case "system":
3116
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3117
+ "path",
3118
+ {
3119
+ fill: "currentColor",
3120
+ d: "M8 1.5A2.5 2.5 0 0 0 5.5 4v.3A2.5 2.5 0 0 0 4 6.7V12a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2V6.7a2.5 2.5 0 0 0-1.5-2.4V4A2.5 2.5 0 0 0 8 1.5Zm0 1a1.5 1.5 0 0 1 1.5 1.5v.16A3.5 3.5 0 0 0 8 4a3.5 3.5 0 0 0-1.5.16V4A1.5 1.5 0 0 1 8 2.5ZM6 6.7c0-.72.58-1.3 1.3-1.3h1.4c.72 0 1.3.58 1.3 1.3V12a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V6.7Z"
3121
+ }
3122
+ ) });
3123
+ case "tools":
3124
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3125
+ "path",
3126
+ {
3127
+ fill: "currentColor",
3128
+ d: "M11.2 1.6a2.4 2.4 0 0 0-3.3 0L6.2 3.3a.7.7 0 0 0 1 1l1.7-1.7a1 1 0 0 1 1.4 1.4L5.6 8.7l-.9-.9a.7.7 0 1 0-1 1l2.4 2.4a.7.7 0 0 0 1 0l5.2-5.2a2.4 2.4 0 0 0-1.1-4.4Zm-7 8.1 1.5 1.5-2.4 1.2a.5.5 0 0 1-.6-.6l1.5-2.1Z"
3129
+ }
3130
+ ) });
3131
+ case "messages":
3132
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: size, height: size, viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3133
+ "path",
3134
+ {
3135
+ fill: "currentColor",
3136
+ d: "M2.5 2.5h11A1.5 1.5 0 0 1 15 4v6a1.5 1.5 0 0 1-1.5 1.5H8.2L5 14.2a.6.6 0 0 1-1-.5v-2.2H2.5A1.5 1.5 0 0 1 1 10V4A1.5 1.5 0 0 1 2.5 2.5Zm0 1A.5.5 0 0 0 2 4v6a.5.5 0 0 0 .5.5H5a.5.5 0 0 1 .5.5v1.4l2-1.5a.5.5 0 0 1 .3-.1h5.7a.5.5 0 0 0 .5-.5V4a.5.5 0 0 0-.5-.5h-11Z"
3137
+ }
3138
+ ) });
3139
+ default: {
3140
+ const _exhaustive = props.category;
3141
+ return _exhaustive;
3142
+ }
3143
+ }
3144
+ }
3145
+
3146
+ // src/client/context/title.ts
3147
+ function kindLabel(kind, t) {
3148
+ switch (kind) {
3149
+ case "system":
3150
+ return t("contextInspectCategory_system");
3151
+ case "tools":
3152
+ return t("contextInspectCategory_tools");
3153
+ case "user":
3154
+ return t("contextInspectKind_user");
3155
+ case "inject":
3156
+ return t("contextInspectKind_inject");
3157
+ case "assistant":
3158
+ return t("contextInspectKind_assistant");
3159
+ case "tool":
3160
+ return t("contextInspectKind_tool");
3161
+ case "developer":
3162
+ return t("contextInspectKind_developer");
3163
+ default: {
3164
+ const _exhaustive = kind;
3165
+ return _exhaustive;
3166
+ }
3167
+ }
3168
+ }
3169
+ function localizeItemTitle(item, t) {
3170
+ const label = kindLabel(item.kind, t);
3171
+ switch (item.kind) {
3172
+ case "system":
3173
+ if (item.title === "System") return label;
3174
+ if (/^System · \d+$/.test(item.title)) return item.title.replace(/^System/, label);
3175
+ return item.title;
3176
+ case "user":
3177
+ return item.title === "User" ? label : item.title;
3178
+ case "assistant":
3179
+ return item.title === "Assistant" ? label : item.title;
3180
+ case "developer":
3181
+ return item.title === "Developer" ? label : item.title;
3182
+ case "inject":
3183
+ return item.title.startsWith("Inject \xB7 ") ? `${label} \xB7 ${item.title.slice("Inject \xB7 ".length)}` : item.title;
3184
+ case "tool":
3185
+ return item.title.startsWith("Tool \xB7 ") ? `${label} \xB7 ${item.title.slice("Tool \xB7 ".length)}` : item.title;
3186
+ case "tools":
3187
+ return item.title;
3188
+ default: {
3189
+ const _exhaustive = item.kind;
3190
+ return _exhaustive;
3191
+ }
3192
+ }
3193
+ }
3194
+
3195
+ // src/client/context/right-tab.tsx
3196
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3197
+ var CATEGORIES2 = ["system", "tools", "messages"];
3198
+ var KIND_ORDER = [
3199
+ "user",
3200
+ "inject",
3201
+ "assistant",
3202
+ "tool",
3203
+ "developer",
3204
+ "system",
3205
+ "tools"
3206
+ ];
3207
+ function paramsOf(raw) {
3208
+ if (raw === null || typeof raw !== "object") return {};
3209
+ return raw;
3210
+ }
3211
+ function kindSlices(items, labelOf) {
3212
+ const totals = /* @__PURE__ */ new Map();
3213
+ for (const item of items) {
3214
+ totals.set(item.kind, (totals.get(item.kind) ?? 0) + item.tokens);
3215
+ }
3216
+ return KIND_ORDER.filter((kind) => (totals.get(kind) ?? 0) > 0).map((kind) => ({
3217
+ id: kind,
3218
+ label: labelOf(kind),
3219
+ tokens: totals.get(kind),
3220
+ color: colorForKind(kind)
3221
+ }));
3222
+ }
3223
+ function kindLabelKey(kind) {
3224
+ switch (kind) {
3225
+ case "system":
3226
+ return "contextInspectCategory_system";
3227
+ case "tools":
3228
+ return "contextInspectCategory_tools";
3229
+ case "user":
3230
+ return "contextInspectKind_user";
3231
+ case "inject":
3232
+ return "contextInspectKind_inject";
3233
+ case "assistant":
3234
+ return "contextInspectKind_assistant";
3235
+ case "tool":
3236
+ return "contextInspectKind_tool";
3237
+ case "developer":
3238
+ return "contextInspectKind_developer";
3239
+ default: {
3240
+ const _exhaustive = kind;
3241
+ return _exhaustive;
3242
+ }
3243
+ }
3244
+ }
3245
+ function eventLabelKey(kind) {
3246
+ switch (kind) {
3247
+ case "compact":
3248
+ return "contextInspectEvent_compact";
3249
+ case "prune":
3250
+ return "contextInspectEvent_prune";
3251
+ case "replace":
3252
+ return "contextInspectEvent_replace";
3253
+ default: {
3254
+ const _exhaustive = kind;
3255
+ return _exhaustive;
3256
+ }
3257
+ }
3258
+ }
3259
+ function ContextInspectRightTab(props) {
3260
+ const info = props.useTabInfo();
3261
+ const nav = info.tab.navigation;
3262
+ const params = paramsOf(nav.params);
3263
+ const sessionId = params.sessionId;
3264
+ const [category, setCategory] = (0, import_react7.useState)(params.category ?? "messages");
3265
+ const [expandedId, setExpandedId] = (0, import_react7.useState)(params.itemId);
3266
+ const [result, setResult] = (0, import_react7.useState)(null);
3267
+ const [overview, setOverview] = (0, import_react7.useState)({});
3268
+ const [pressure, setPressure] = (0, import_react7.useState)({});
3269
+ const [error, setError] = (0, import_react7.useState)(null);
3270
+ const [loading, setLoading] = (0, import_react7.useState)(false);
3271
+ const [refreshToken, setRefreshToken] = (0, import_react7.useState)(0);
3272
+ const [compacting, setCompacting] = (0, import_react7.useState)(false);
3273
+ const [compactNote, setCompactNote] = (0, import_react7.useState)(null);
3274
+ (0, import_react7.useEffect)(() => {
3275
+ if (params.category !== void 0) setCategory(params.category);
3276
+ if (params.itemId !== void 0) setExpandedId(params.itemId);
3277
+ }, [params.category, params.itemId, nav.revision]);
3278
+ (0, import_react7.useEffect)(() => {
3279
+ if (sessionId === void 0) {
3280
+ setOverview({});
3281
+ setPressure({});
3282
+ return;
3283
+ }
3284
+ const controller = new AbortController();
3285
+ void Promise.all(CATEGORIES2.map(async (entry) => {
3286
+ try {
3287
+ const value = await props.inspect(sessionId, entry, controller.signal);
3288
+ return [entry, value];
3289
+ } catch {
3290
+ return [entry, null];
3291
+ }
3292
+ })).then((entries) => {
3293
+ if (controller.signal.aborted) return;
3294
+ const next = {};
3295
+ let nextPressure = {};
3296
+ for (const [entry, value] of entries) {
3297
+ if (value === null) {
3298
+ next[entry] = 0;
3299
+ continue;
3300
+ }
3301
+ next[entry] = value.totalTokens;
3302
+ if (value.pressure.projectedTokens !== void 0 || value.pressure.contextWindow !== void 0) {
3303
+ nextPressure = value.pressure;
3304
+ }
3305
+ }
3306
+ setOverview(next);
3307
+ setPressure(nextPressure);
3308
+ });
3309
+ return () => controller.abort();
3310
+ }, [sessionId, nav.revision, refreshToken, props.inspect]);
3311
+ (0, import_react7.useEffect)(() => {
3312
+ if (sessionId === void 0) {
3313
+ setResult(null);
3314
+ setError(props.t("contextInspectNoSession"));
3315
+ return;
3316
+ }
3317
+ const controller = new AbortController();
3318
+ setLoading(true);
3319
+ setError(null);
3320
+ void props.inspect(sessionId, category, controller.signal).then(
3321
+ (value) => {
3322
+ if (controller.signal.aborted) return;
3323
+ setResult(value);
3324
+ if (value.pressure.projectedTokens !== void 0 || value.pressure.contextWindow !== void 0) {
3325
+ setPressure(value.pressure);
3326
+ }
3327
+ setLoading(false);
3328
+ setExpandedId((current) => {
3329
+ if (current !== void 0 && value.items.some((item) => item.id === current)) return current;
3330
+ return void 0;
3331
+ });
3332
+ },
3333
+ () => {
3334
+ if (controller.signal.aborted) return;
3335
+ setResult(null);
3336
+ setLoading(false);
3337
+ setError(props.t("contextInspectLoadFailed"));
3338
+ }
3339
+ );
3340
+ return () => controller.abort();
3341
+ }, [sessionId, category, nav.revision, refreshToken, props.inspect, props.t]);
3342
+ async function runCompact() {
3343
+ if (sessionId === void 0 || compacting) return;
3344
+ setCompacting(true);
3345
+ setCompactNote(null);
3346
+ const controller = new AbortController();
3347
+ try {
3348
+ const value = await props.compact(sessionId, controller.signal);
3349
+ if (value.status === "noop") {
3350
+ setCompactNote(props.t("contextInspectCompactNoop"));
3351
+ } else {
3352
+ setCompactNote(props.t("contextInspectCompactDone", {
3353
+ count: value.shadowedCount,
3354
+ tokens: formatTokens(value.shadowedTokens)
3355
+ }));
3356
+ }
3357
+ setRefreshToken((token) => token + 1);
3358
+ } catch (error2) {
3359
+ if (error2 instanceof AuxiliaryError) {
3360
+ switch (error2.code) {
3361
+ case "COMPACT_UNAVAILABLE":
3362
+ setCompactNote(props.t("contextInspectCompactUnavailable"));
3363
+ break;
3364
+ case "COMPACT_BUSY":
3365
+ setCompactNote(props.t("contextInspectCompactBusy"));
3366
+ break;
3367
+ case "COMPACT_SUMMARY":
3368
+ setCompactNote(props.t("contextInspectCompactSummary"));
3369
+ break;
3370
+ case "COMPACT_CHANGED":
3371
+ setCompactNote(props.t("contextInspectCompactChanged"));
3372
+ break;
3373
+ case "COMPACT_FAILED":
3374
+ case "SESSION_CHANGED":
3375
+ case "MODEL_FAILED":
3376
+ case "MODEL_UNAVAILABLE":
3377
+ case "INVALID_OUTPUT":
3378
+ case "ROLLBACK_FAILED":
3379
+ setCompactNote(props.t("contextInspectCompactFailed"));
3380
+ break;
3381
+ default: {
3382
+ const _exhaustive = error2.code;
3383
+ setCompactNote(_exhaustive);
3384
+ }
3385
+ }
3386
+ } else {
3387
+ setCompactNote(props.t("contextInspectCompactFailed"));
3388
+ }
3389
+ } finally {
3390
+ setCompacting(false);
3391
+ }
3392
+ }
3393
+ const sorted = (0, import_react7.useMemo)(() => {
3394
+ if (result === null) return [];
3395
+ return [...result.items].sort((a, b) => b.tokens - a.tokens || a.title.localeCompare(b.title));
3396
+ }, [result]);
3397
+ (0, import_react7.useEffect)(() => {
3398
+ if (sorted.length === 1) setExpandedId(sorted[0].id);
3399
+ }, [sorted]);
3400
+ const categoryTotal = result?.totalTokens ?? 0;
3401
+ const overviewTotal = (0, import_react7.useMemo)(
3402
+ () => CATEGORIES2.reduce((sum, entry) => sum + (overview[entry] ?? 0), 0),
3403
+ [overview]
3404
+ );
3405
+ const shareBase = overviewTotal > 0 ? overviewTotal : categoryTotal;
3406
+ const overviewSlices = (0, import_react7.useMemo)(() => CATEGORIES2.map((entry) => ({
3407
+ id: entry,
3408
+ label: entry,
3409
+ tokens: overview[entry] ?? 0,
3410
+ color: colorForCategory(entry)
3411
+ })).filter((slice) => slice.tokens > 0), [overview]);
3412
+ const messageSlices = (0, import_react7.useMemo)(
3413
+ () => kindSlices(sorted, (kind) => kind),
3414
+ [sorted]
3415
+ );
3416
+ const localizedOverviewSlices = overviewSlices.map((slice) => ({
3417
+ ...slice,
3418
+ label: props.t(`contextInspectCategory_${slice.id}`)
3419
+ }));
3420
+ const localizedMessageSlices = messageSlices.map((slice) => ({
3421
+ ...slice,
3422
+ label: props.t(kindLabelKey(slice.id))
3423
+ }));
3424
+ const chartSlices = category === "messages" && localizedMessageSlices.length > 1 ? localizedMessageSlices : localizedOverviewSlices.length > 0 ? localizedOverviewSlices : localizedMessageSlices;
3425
+ const chartTitle = category === "messages" && localizedMessageSlices.length > 1 ? props.t("contextInspectChartMessages") : localizedOverviewSlices.length > 0 ? props.t("contextInspectChartOverview") : props.t("contextInspectChartCategory");
3426
+ const fillExpanded = sorted.length === 1;
3427
+ const events = result?.events ?? [];
3428
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextRightPanel, "aria-label": props.t("contextInspectDetailTitle"), children: [
3429
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: css_module_default.contextRightHeader, children: [
3430
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextRightTitleRow, children: [
3431
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: css_module_default.contextRightTitle, children: props.t("contextInspectDetailTitle") }),
3432
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: css_module_default.contextRightMeta, children: result === null ? props.t("contextInspectApproxBadge") : props.t("contextInspectApproxTotal", { tokens: formatTokens(categoryTotal) }) })
3433
+ ] }),
3434
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: css_module_default.contextRightSegments, role: "tablist", "aria-label": props.t("contextInspectCategories"), children: CATEGORIES2.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3435
+ "button",
3436
+ {
3437
+ type: "button",
3438
+ role: "tab",
3439
+ "aria-selected": entry === category,
3440
+ className: entry === category ? css_module_default.contextRightSegmentActive : css_module_default.contextRightSegment,
3441
+ onClick: () => setCategory(entry),
3442
+ children: [
3443
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CategoryIcon, { category: entry }),
3444
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: props.t(`contextInspectCategory_${entry}`) })
3445
+ ]
3446
+ },
3447
+ entry
3448
+ )) })
3449
+ ] }),
3450
+ !loading && error === null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3451
+ ContextShareChart,
3452
+ {
3453
+ title: chartTitle,
3454
+ totalLabel: props.t("contextInspectApproxBadge"),
3455
+ slices: chartSlices,
3456
+ emptyLabel: props.t("contextInspectEmpty"),
3457
+ pressure,
3458
+ headroomLabel: props.t("contextInspectHeadroom"),
3459
+ occupiedLabel: props.t("contextInspectOccupied")
3460
+ }
3461
+ ) : null,
3462
+ sessionId !== void 0 && error === null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextCompactBar, children: [
3463
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3464
+ "button",
3465
+ {
3466
+ type: "button",
3467
+ className: css_module_default.contextCompactButton,
3468
+ disabled: compacting || loading,
3469
+ "aria-label": compacting ? props.t("contextInspectCompacting") : props.t("contextInspectCompact"),
3470
+ title: props.t("contextInspectCompactHint"),
3471
+ onClick: () => {
3472
+ void runCompact();
3473
+ },
3474
+ children: [
3475
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CompactIcon, {}),
3476
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: css_module_default.contextCompactButtonLabel, children: compacting ? props.t("contextInspectCompacting") : props.t("contextInspectCompact") })
3477
+ ]
3478
+ }
3479
+ ),
3480
+ compactNote !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: css_module_default.contextCompactNote, role: "status", children: compactNote }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: css_module_default.contextCompactHint, children: props.t("contextInspectCompactHint") })
3481
+ ] }) : null,
3482
+ !loading && error === null && events.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: css_module_default.contextEventRow, "aria-label": props.t("contextInspectEvents"), children: events.map((event) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3483
+ "span",
3484
+ {
3485
+ className: event.kind === "compact" ? css_module_default.contextEventChipCompact : event.kind === "prune" ? css_module_default.contextEventChipPrune : css_module_default.contextEventChip,
3486
+ title: `${props.t(eventLabelKey(event.kind))}${event.shadowed > 0 ? ` \xB7 ${event.shadowed}` : ""}`,
3487
+ children: [
3488
+ props.t(eventLabelKey(event.kind)),
3489
+ event.shadowed > 0 ? ` \xB7 ${event.shadowed}` : ""
3490
+ ]
3491
+ },
3492
+ event.id
3493
+ )) }) : null,
3494
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: css_module_default.contextRightStatus, role: "status", children: props.t("contextInspectLoading") }) : null,
3495
+ error !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: css_module_default.contextRightStatus, role: "alert", children: error }) : null,
3496
+ !loading && error === null && sorted.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: css_module_default.contextRightStatus, children: props.t("contextInspectEmpty") }) : null,
3497
+ sorted.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3498
+ "div",
3499
+ {
3500
+ className: fillExpanded ? css_module_default.contextRightListFill : css_module_default.contextRightScroll,
3501
+ role: "list",
3502
+ "aria-label": props.t(`contextInspectCategory_${category}`),
3503
+ children: sorted.map((item) => {
3504
+ const share = sharePercent(item.tokens, shareBase);
3505
+ const expanded = item.id === expandedId;
3506
+ const color = colorForKind(item.kind);
3507
+ const itemClass = expanded ? fillExpanded ? css_module_default.contextRightItemActiveFill : css_module_default.contextRightItemActive : css_module_default.contextRightItem;
3508
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: itemClass, role: "listitem", children: [
3509
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
3510
+ "button",
3511
+ {
3512
+ type: "button",
3513
+ className: css_module_default.contextRightRow,
3514
+ "aria-expanded": expanded,
3515
+ onClick: () => setExpandedId((current) => current === item.id ? void 0 : item.id),
3516
+ children: [
3517
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3518
+ "span",
3519
+ {
3520
+ className: css_module_default.contextRightItemDot,
3521
+ style: { background: color },
3522
+ "aria-hidden": "true"
3523
+ }
3524
+ ),
3525
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextRightRowMain, children: [
3526
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextRightRowTitle, children: [
3527
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: localizeItemTitle(item, props.t) }),
3528
+ item.replaced ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: css_module_default.contextRightBadge, children: props.t("contextInspectReplaced") }) : null,
3529
+ item.kind === "inject" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: css_module_default.contextRightBadgeMuted, children: props.t("contextInspectKind_inject") }) : null
3530
+ ] }),
3531
+ !expanded ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: css_module_default.contextRightRowPreview, children: item.detail }) : null,
3532
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: css_module_default.contextRightBarTrack, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3533
+ "div",
3534
+ {
3535
+ className: css_module_default.contextRightBarFill,
3536
+ style: { width: `${share}%`, background: color }
3537
+ }
3538
+ ) })
3539
+ ] }),
3540
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: css_module_default.contextRightRowTokens, children: [
3541
+ "~",
3542
+ formatTokens(item.tokens),
3543
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: css_module_default.contextRightShare, children: [
3544
+ " \xB7 ",
3545
+ share,
3546
+ "%"
3547
+ ] })
3548
+ ] })
3549
+ ]
3550
+ }
3551
+ ),
3552
+ expanded ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("section", { className: css_module_default.contextRightDetail, "aria-label": props.t("contextInspectItemDetail"), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { className: css_module_default.contextRightDetailBody, children: item.body }) }) : null
3553
+ ] }, item.id);
3554
+ })
3555
+ }
3556
+ ) : null,
3557
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("footer", { className: css_module_default.contextRightNote, children: props.t("contextInspectNote") })
3558
+ ] });
3559
+ }
3560
+ function ContextInspectRightTabTitle(props) {
3561
+ const info = props.useTabInfo();
3562
+ const params = paramsOf(info.tab.navigation.params);
3563
+ const category = params.category;
3564
+ const label = category === void 0 ? props.t("contextInspectDetailTitle") : props.t(`contextInspectCategory_${category}`);
3565
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: label });
3566
+ }
3567
+
3568
+ // src/client/dsh/usage-dock.tsx
3569
+ var import_react8 = require("react");
3570
+
3571
+ // src/client/dsh/usage-meter.ts
3572
+ var USAGE_ATTR = "data-agent-enhancer-usage";
3573
+ var TITLE_RE = /Token\s*(?:用量|usage)/i;
3574
+ var TOTAL_RE = /\d[\d,]*\s*tok/i;
3575
+ var CACHE_RE = /缓存命中|Cache\s*hit|未缓存|Uncached|缓存读取|Cache\s*read/i;
3576
+ function cls2(value) {
3577
+ return value ?? "";
3578
+ }
3579
+ function textOf2(node) {
3580
+ return (node.textContent ?? "").replace(/\s+/g, " ").trim();
3581
+ }
3582
+ function isContextCompositionPanel(dialog) {
3583
+ return dialog.querySelectorAll(":scope > dl > div").length === 3;
3584
+ }
3585
+ function isTokenUsagePanel(dialog) {
3586
+ if (isContextCompositionPanel(dialog)) return false;
3587
+ const text2 = textOf2(dialog);
3588
+ if (!TITLE_RE.test(text2)) return false;
3589
+ return TOTAL_RE.test(text2) || CACHE_RE.test(text2);
3590
+ }
3591
+ function findOpenTokenUsagePanel() {
3592
+ const dock = document.querySelector("[data-composer-dock]");
3593
+ if (!(dock instanceof HTMLElement)) return null;
3594
+ const triggers = dock.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
3595
+ if (triggers.length === 0) return null;
3596
+ const dialogs = document.querySelectorAll('body > [role="dialog"]');
3597
+ for (let index = dialogs.length - 1; index >= 0; index -= 1) {
3598
+ const dialog = dialogs[index];
3599
+ if (dialog === void 0) continue;
3600
+ if (isTokenUsagePanel(dialog)) return dialog;
3601
+ }
3602
+ return null;
3603
+ }
3604
+ function findTokenUsageTitleRow(panel) {
3605
+ const candidates = [];
3606
+ for (const node of panel.querySelectorAll("*")) {
3607
+ if (!(node instanceof HTMLElement)) continue;
3608
+ if (node === panel) continue;
3609
+ const text2 = textOf2(node);
3610
+ if (!TITLE_RE.test(text2) || !TOTAL_RE.test(text2)) continue;
3611
+ candidates.push(node);
3612
+ }
3613
+ if (candidates.length === 0) return null;
3614
+ candidates.sort((left, right) => left.querySelectorAll("*").length - right.querySelectorAll("*").length);
3615
+ return candidates[0] ?? null;
3616
+ }
3617
+ function enhanceTitleRow(row, options) {
3618
+ if (row.getAttribute(USAGE_ATTR) === "1") return;
3619
+ row.setAttribute(USAGE_ATTR, "1");
3620
+ row.classList.add(cls2(css_module_default.usageMeterTitleRow));
3621
+ row.tabIndex = 0;
3622
+ row.setAttribute("role", "button");
3623
+ row.setAttribute("aria-label", options.label());
3624
+ if (!row.querySelector("[data-agent-enhancer-usage-chevron]")) {
3625
+ const chevron = document.createElement("span");
3626
+ chevron.dataset.agentEnhancerUsageChevron = "1";
3627
+ chevron.className = cls2(css_module_default.usageMeterLinkChevron);
3628
+ chevron.setAttribute("aria-hidden", "true");
3629
+ chevron.textContent = "\u203A";
3630
+ row.append(chevron);
3631
+ }
3632
+ const open = () => {
3633
+ options.open();
3634
+ };
3635
+ row.addEventListener("click", (event) => {
3636
+ event.preventDefault();
3637
+ event.stopPropagation();
3638
+ open();
3639
+ });
3640
+ row.addEventListener("keydown", (event) => {
3641
+ if (event.key !== "Enter" && event.key !== " ") return;
3642
+ event.preventDefault();
3643
+ event.stopPropagation();
3644
+ open();
3645
+ });
3646
+ }
3647
+ function installUsageMeterLink(options) {
3648
+ const scan = () => {
3649
+ const panel = findOpenTokenUsagePanel();
3650
+ if (panel === null) return;
3651
+ const title = findTokenUsageTitleRow(panel);
3652
+ if (title !== null) enhanceTitleRow(title, options);
3653
+ };
3654
+ const observer = new MutationObserver(scan);
3655
+ observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["aria-expanded"] });
3656
+ scan();
3657
+ return () => {
3658
+ observer.disconnect();
3659
+ };
3660
+ }
3661
+
3662
+ // src/client/dsh/usage-dock.tsx
3663
+ function UsageMeterDock(props) {
3664
+ (0, import_react8.useEffect)(() => installUsageMeterLink({
3665
+ open: props.open,
3666
+ label: () => props.t("usageMeterOpen")
3667
+ }), [props.open, props.t]);
3668
+ return null;
3669
+ }
3670
+
3671
+ // src/client/dsh/usage-panel.tsx
3672
+ var import_react10 = require("react");
3673
+
3674
+ // src/host/usage/types.ts
3675
+ var USAGE_RANGES = ["today", "7d", "30d", "all"];
3676
+
3677
+ // src/client/dsh/usage-chart.tsx
3678
+ var import_react9 = require("react");
3679
+
3680
+ // src/client/dsh/usage-format.ts
3681
+ function formatTokenCount(value) {
3682
+ return new Intl.NumberFormat("en-US").format(value);
3683
+ }
3684
+ function formatCnyAmount(value) {
3685
+ if (!Number.isFinite(value) || value < 0) return "0";
3686
+ const fixed = value.toFixed(4);
3687
+ return fixed.replace(/\.?0+$/, "") || "0";
3688
+ }
3689
+ function formatUsageWhen(at) {
3690
+ return new Intl.DateTimeFormat(void 0, {
3691
+ month: "numeric",
3692
+ day: "numeric",
3693
+ hour: "2-digit",
3694
+ minute: "2-digit"
3695
+ }).format(at);
3696
+ }
3697
+
3698
+ // src/client/dsh/usage-chart.tsx
3699
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3700
+ function heatLevel(tokens, max) {
3701
+ if (tokens <= 0 || max <= 0) return 0;
3702
+ const ratio = tokens / max;
3703
+ if (ratio < 0.2) return 1;
3704
+ if (ratio < 0.4) return 2;
3705
+ if (ratio < 0.7) return 3;
3706
+ return 4;
3707
+ }
3708
+ function UsageHeatmapChart(props) {
3709
+ const tipId = (0, import_react9.useId)();
3710
+ const [hoveredKey, setHoveredKey] = (0, import_react9.useState)(null);
3711
+ const max = props.heatmap.cells.reduce((high, cell) => Math.max(high, cell.tokens), 0);
3712
+ const empty = max <= 0;
3713
+ const hovered = hoveredKey === null ? void 0 : props.heatmap.cells.find((cell) => cell.key === hoveredKey);
3714
+ const grainClass = props.heatmap.grain === "hour" ? css_module_default.usageHeatGridHour : css_module_default.usageHeatGridDay;
3715
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: css_module_default.usageChart, "aria-label": props.title, children: [
3716
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.usageChartHead, children: [
3717
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: css_module_default.usageSectionTitle, children: props.title }),
3718
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: css_module_default.usageChartHint, children: props.hint })
3719
+ ] }),
3720
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: css_module_default.usageEmptyInline, children: props.emptyLabel }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.usageHeatBody, children: [
3721
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3722
+ "div",
3723
+ {
3724
+ className: `${css_module_default.usageHeatGrid} ${grainClass}`,
3725
+ role: "img",
3726
+ "aria-labelledby": tipId,
3727
+ onMouseLeave: () => {
3728
+ setHoveredKey(null);
3729
+ },
3730
+ children: props.heatmap.cells.map((cell) => {
3731
+ const level = heatLevel(cell.tokens, max);
3732
+ const active = hoveredKey === null || hoveredKey === cell.key;
3733
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3734
+ "button",
3735
+ {
3736
+ type: "button",
3737
+ className: active ? css_module_default.usageHeatCell : css_module_default.usageHeatCellDim,
3738
+ "data-level": level,
3739
+ "aria-label": `${cell.label}: ${formatTokenCount(cell.tokens)}`,
3740
+ onMouseEnter: () => {
3741
+ setHoveredKey(cell.key);
3742
+ },
3743
+ onFocus: () => {
3744
+ setHoveredKey(cell.key);
3745
+ },
3746
+ onBlur: () => {
3747
+ setHoveredKey(null);
3748
+ },
3749
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: css_module_default.usageHeatLabel, children: cell.label })
3750
+ },
3751
+ cell.key
3752
+ );
3753
+ })
3754
+ }
3755
+ ),
3756
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: css_module_default.usageHeatLegend, id: tipId, children: hovered !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
3757
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: css_module_default.usageHeatTipValue, children: formatTokenCount(hovered.tokens) }),
3758
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageHeatTipMeta, children: [
3759
+ hovered.label,
3760
+ " \xB7 ",
3761
+ props.callsLabel(hovered.calls)
3762
+ ] })
3763
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageHeatScale, "aria-hidden": "true", children: [
3764
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-level": 0 }),
3765
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-level": 1 }),
3766
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-level": 2 }),
3767
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-level": 3 }),
3768
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { "data-level": 4 })
3769
+ ] }) })
3770
+ ] })
3771
+ ] });
3772
+ }
3773
+ function UsageShareBar(props) {
3774
+ const [hoveredId, setHoveredId] = (0, import_react9.useState)(null);
3775
+ const total = props.slices.reduce((sum, slice) => sum + slice.tokens, 0);
3776
+ const empty = total <= 0 || props.slices.length === 0;
3777
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: css_module_default.usageChart, "aria-label": props.title, children: [
3778
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: css_module_default.usageSectionTitle, children: props.title }),
3779
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: css_module_default.usageEmptyInline, children: props.emptyLabel }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.usageShareBody, onMouseLeave: () => {
3780
+ setHoveredId(null);
3781
+ }, children: [
3782
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: css_module_default.usageShareTrack, "aria-hidden": "true", children: props.slices.map((slice) => {
3783
+ const width = Math.max(2, slice.tokens / total * 100);
3784
+ const dim = hoveredId !== null && hoveredId !== slice.id;
3785
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3786
+ "div",
3787
+ {
3788
+ className: dim ? css_module_default.usageShareSegmentDim : css_module_default.usageShareSegment,
3789
+ style: { width: `${width}%`, background: slice.color },
3790
+ onMouseEnter: () => {
3791
+ setHoveredId(slice.id);
3792
+ }
3793
+ },
3794
+ slice.id
3795
+ );
3796
+ }) }),
3797
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: css_module_default.usageLegend, children: props.slices.map((slice) => {
3798
+ const share = sharePercent(slice.tokens, total);
3799
+ const active = hoveredId === null || hoveredId === slice.id;
3800
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
3801
+ "li",
3802
+ {
3803
+ className: active ? css_module_default.usageLegendItem : css_module_default.usageLegendItemDim,
3804
+ onMouseEnter: () => {
3805
+ setHoveredId(slice.id);
3806
+ },
3807
+ onMouseLeave: () => {
3808
+ setHoveredId(null);
3809
+ },
3810
+ children: [
3811
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: css_module_default.usageLegendSwatch, style: { background: slice.color } }),
3812
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: css_module_default.usageLegendLabel, children: slice.label }),
3813
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageLegendMeta, children: [
3814
+ formatTokenCount(slice.tokens),
3815
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageLegendShare, children: [
3816
+ share,
3817
+ "%"
3818
+ ] })
3819
+ ] })
3820
+ ]
3821
+ },
3822
+ slice.id
3823
+ );
3824
+ }) })
3825
+ ] })
3826
+ ] });
3827
+ }
3828
+ function UsageRankChart(props) {
3829
+ const total = props.slices.reduce((sum, slice) => sum + slice.tokens, 0);
3830
+ const empty = total <= 0 || props.slices.length === 0;
3831
+ const max = props.slices.reduce((high, slice) => Math.max(high, slice.tokens), 0);
3832
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: css_module_default.usageChart, "aria-label": props.title, children: [
3833
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: css_module_default.usageSectionTitle, children: props.title }),
3834
+ empty ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: css_module_default.usageEmptyInline, children: props.emptyLabel }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: css_module_default.usageRankList, children: props.slices.map((slice) => {
3835
+ const width = max <= 0 ? 0 : Math.max(6, Math.round(slice.tokens / max * 100));
3836
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("li", { className: css_module_default.usageRankItem, children: [
3837
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.usageRankTop, children: [
3838
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: css_module_default.usageRankLabel, children: slice.label }),
3839
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageRankMeta, children: [
3840
+ formatTokenCount(slice.tokens),
3841
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: css_module_default.usageLegendShare, children: [
3842
+ sharePercent(slice.tokens, total),
3843
+ "%"
3844
+ ] })
3845
+ ] })
3846
+ ] }),
3847
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: css_module_default.usageRankTrack, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3848
+ "div",
3849
+ {
3850
+ className: css_module_default.usageRankFill,
3851
+ style: { width: `${width}%`, background: slice.color }
3852
+ }
3853
+ ) })
3854
+ ] }, slice.id);
3855
+ }) })
3856
+ ] });
3857
+ }
3858
+
3859
+ // src/client/dsh/usage-panel.tsx
3860
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3861
+ var SOURCE_LABEL = {
3862
+ optimize: "usageSource_optimize",
3863
+ predict: "usageSource_predict",
3864
+ compact: "usageSource_compact",
3865
+ autoClassifier: "usageSource_autoClassifier",
3866
+ session: "usageSource_session",
3867
+ compaction: "usageSource_compaction",
3868
+ sessionTitle: "usageSource_sessionTitle",
3869
+ other: "usageSource_other"
3870
+ };
3871
+ var SOURCE_COLOR = {
3872
+ optimize: "#3d7cf5",
3873
+ predict: "#6b7cff",
3874
+ compact: "#1f9a6a",
3875
+ autoClassifier: "#3aa88f",
3876
+ session: "#c9921a",
3877
+ compaction: "#c96b45",
3878
+ sessionTitle: "#b87a2e",
3879
+ other: "#7a8496"
3880
+ };
3881
+ var MODEL_COLORS = ["#3d7cf5", "#1f9a6a", "#c9921a", "#c96b45", "#6b7cff", "#3aa88f", "#b87a2e", "#7a8496"];
3882
+ var RANGE_LABEL = {
3883
+ today: "usageRange_today",
3884
+ "7d": "usageRange_7d",
3885
+ "30d": "usageRange_30d",
3886
+ all: "usageRange_all"
3887
+ };
3888
+ var RECENT_INLINE_MIN_PX = 176;
3889
+ function billedVolume(tokens) {
3890
+ return tokens.inputTokens + tokens.outputTokens + tokens.cacheReadTokens + tokens.cacheWriteTokens;
3891
+ }
3892
+ function sourceSlices(summary, t) {
3893
+ return summary.sources.flatMap((line) => {
3894
+ const tokens = billedVolume(line);
3895
+ if (tokens <= 0) return [];
3896
+ return [{
3897
+ id: line.source,
3898
+ label: t(SOURCE_LABEL[line.source]),
3899
+ tokens,
3900
+ color: SOURCE_COLOR[line.source]
3901
+ }];
3902
+ });
3903
+ }
3904
+ function modelLabel(provider, model, reasoningEffort, t) {
3905
+ if (reasoningEffort === "") {
3906
+ return t("usageModelRoute", { provider, model });
3907
+ }
3908
+ return t("usageModelRouteEffort", { provider, model, effort: reasoningEffort });
3909
+ }
3910
+ function modelSlices(summary, t) {
3911
+ const totals = /* @__PURE__ */ new Map();
3912
+ for (const source of summary.sources) {
3913
+ for (const model of source.models) {
3914
+ const key = `${model.provider}\0${model.model}\0${model.reasoningEffort}`;
3915
+ const current = totals.get(key);
3916
+ const tokens = billedVolume(model);
3917
+ if (current === void 0) {
3918
+ totals.set(key, {
3919
+ provider: model.provider,
3920
+ model: model.model,
3921
+ reasoningEffort: model.reasoningEffort,
3922
+ tokens
3923
+ });
3924
+ } else {
3925
+ current.tokens += tokens;
3926
+ }
3927
+ }
3928
+ }
3929
+ return [...totals.values()].filter((item) => item.tokens > 0).sort((left, right) => right.tokens - left.tokens).map((item, index) => ({
3930
+ id: `${item.provider}/${item.model}/${item.reasoningEffort}`,
3931
+ label: modelLabel(item.provider, item.model, item.reasoningEffort, t),
3932
+ tokens: item.tokens,
3933
+ color: MODEL_COLORS[index % MODEL_COLORS.length]
3934
+ }));
3935
+ }
3936
+ function BucketStrip({
3937
+ summary,
3938
+ t
3939
+ }) {
3940
+ const items = [
3941
+ { id: "input", label: t("usageBucketInput"), value: summary.inputTokens },
3942
+ { id: "output", label: t("usageBucketOutput"), value: summary.outputTokens },
3943
+ { id: "cacheRead", label: t("usageBucketCacheRead"), value: summary.cacheReadTokens }
3944
+ ];
3945
+ if (summary.cacheWriteTokens > 0) {
3946
+ items.push({
3947
+ id: "cacheWrite",
3948
+ label: t("usageBucketCacheWrite"),
3949
+ value: summary.cacheWriteTokens
3950
+ });
3951
+ }
3952
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: css_module_default.usageBuckets, "aria-label": t("usageBuckets"), children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageBucket, children: [
3953
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageBucketLabel, children: item.label }),
3954
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageBucketValue, children: formatTokenCount(item.value) })
3955
+ ] }, item.id)) });
3956
+ }
3957
+ function RecentRows({
3958
+ calls,
3959
+ t,
3960
+ limit
3961
+ }) {
3962
+ const rows = limit === void 0 ? calls : calls.slice(0, limit);
3963
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ol", { className: css_module_default.usageRecentList, children: rows.map((call, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
3964
+ "li",
3965
+ {
3966
+ className: css_module_default.usageRecentItem,
3967
+ children: [
3968
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecentMain, children: [
3969
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageRecentSource, children: t(SOURCE_LABEL[call.source]) }),
3970
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageRecentWhen, children: formatUsageWhen(call.at) })
3971
+ ] }),
3972
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecentRoute, children: [
3973
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordModel", { model: call.model }) }),
3974
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageRecentProvider, children: t("usageRecordProvider", { provider: call.provider }) }),
3975
+ call.reasoningEffort !== "" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordEffort", { effort: call.reasoningEffort }) })
3976
+ ] }),
3977
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecentTokens, children: [
3978
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordInput", { tokens: formatTokenCount(call.inputTokens) }) }),
3979
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordOutput", { tokens: formatTokenCount(call.outputTokens) }) }),
3980
+ call.cacheReadTokens > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordCacheRead", { tokens: formatTokenCount(call.cacheReadTokens) }) }),
3981
+ call.cacheWriteTokens > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecordCacheWrite", { tokens: formatTokenCount(call.cacheWriteTokens) }) })
3982
+ ] })
3983
+ ]
3984
+ },
3985
+ `${call.at}:${index}:${call.source}:${call.provider}:${call.model}`
3986
+ )) });
3987
+ }
3988
+ function UsagePanel({ t, loadUsage }) {
3989
+ const [range, setRange] = (0, import_react10.useState)("7d");
3990
+ const [view, setView] = (0, import_react10.useState)("overview");
3991
+ const [summary, setSummary] = (0, import_react10.useState)(null);
3992
+ const [loading, setLoading] = (0, import_react10.useState)(loadUsage !== void 0);
3993
+ const [failed, setFailed] = (0, import_react10.useState)(false);
3994
+ const [inlineRecent, setInlineRecent] = (0, import_react10.useState)(false);
3995
+ const requestId = (0, import_react10.useRef)(0);
3996
+ const shellRef = (0, import_react10.useRef)(null);
3997
+ const chartsRef = (0, import_react10.useRef)(null);
3998
+ (0, import_react10.useEffect)(() => {
3999
+ if (loadUsage === void 0) return void 0;
4000
+ const id = ++requestId.current;
4001
+ setLoading(true);
4002
+ setFailed(false);
4003
+ void loadUsage(range).then(
4004
+ (value) => {
4005
+ if (requestId.current !== id) return;
4006
+ setSummary(value);
4007
+ setLoading(false);
4008
+ },
4009
+ () => {
4010
+ if (requestId.current !== id) return;
4011
+ setFailed(true);
4012
+ setLoading(false);
4013
+ }
4014
+ );
4015
+ return void 0;
4016
+ }, [loadUsage, range]);
4017
+ (0, import_react10.useLayoutEffect)(() => {
4018
+ if (view !== "overview") return void 0;
4019
+ const shell = shellRef.current;
4020
+ const charts = chartsRef.current;
4021
+ if (shell === null || charts === null) return void 0;
4022
+ if (typeof ResizeObserver === "undefined") {
4023
+ setInlineRecent(false);
4024
+ return void 0;
4025
+ }
4026
+ const measure = () => {
4027
+ const leftover = shell.clientHeight - charts.offsetHeight - 24;
4028
+ setInlineRecent(leftover >= RECENT_INLINE_MIN_PX);
4029
+ };
4030
+ measure();
4031
+ const observer = new ResizeObserver(measure);
4032
+ observer.observe(shell);
4033
+ observer.observe(charts);
4034
+ return () => {
4035
+ observer.disconnect();
4036
+ };
4037
+ }, [view, summary, range, loading]);
4038
+ const visible = summary?.range === range ? summary : null;
4039
+ const reload = () => {
4040
+ const id = ++requestId.current;
4041
+ if (loadUsage === void 0) return;
4042
+ setLoading(true);
4043
+ setFailed(false);
4044
+ void loadUsage(range).then(
4045
+ (value) => {
4046
+ if (requestId.current !== id) return;
4047
+ setSummary(value);
4048
+ setLoading(false);
4049
+ },
4050
+ () => {
4051
+ if (requestId.current !== id) return;
4052
+ setFailed(true);
4053
+ setLoading(false);
4054
+ }
4055
+ );
4056
+ };
4057
+ if (view === "records") {
4058
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4059
+ "section",
4060
+ {
4061
+ "aria-label": t("usageRecent"),
4062
+ "aria-busy": loading,
4063
+ className: css_module_default.usagePanel,
4064
+ "data-usage-view": "records",
4065
+ children: [
4066
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: css_module_default.usageHeader, children: [
4067
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecordsToolbar, children: [
4068
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4069
+ "button",
4070
+ {
4071
+ type: "button",
4072
+ className: css_module_default.usageBack,
4073
+ onClick: () => {
4074
+ setView("overview");
4075
+ },
4076
+ children: t("usageBack")
4077
+ }
4078
+ ),
4079
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4080
+ "button",
4081
+ {
4082
+ type: "button",
4083
+ className: css_module_default.usageRefresh,
4084
+ disabled: loading || loadUsage === void 0,
4085
+ onClick: reload,
4086
+ children: t("usageRefresh")
4087
+ }
4088
+ )
4089
+ ] }),
4090
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: css_module_default.usageTitle, children: t("usageRecent") }),
4091
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: css_module_default.usageNote, children: t("usageRecordsHint") })
4092
+ ] }),
4093
+ visible === null || visible.recent.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: css_module_default.usageEmpty, children: t("usageRecordsEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RecentRows, { calls: visible.recent, t })
4094
+ ]
4095
+ }
4096
+ );
4097
+ }
4098
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4099
+ "section",
4100
+ {
4101
+ ref: shellRef,
4102
+ "aria-label": t("usageTitle"),
4103
+ "aria-busy": loading,
4104
+ className: css_module_default.usagePanel,
4105
+ "data-usage-view": "overview",
4106
+ children: [
4107
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: css_module_default.usageHero, children: [
4108
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageHeroCopy, children: [
4109
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { className: css_module_default.usageTitle, children: t("usageTitle") }),
4110
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: css_module_default.usageNote, children: t("usageNote") }),
4111
+ visible !== null && visible.calls > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageMoneyBlock, children: [
4112
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageEstimate, children: t("usageEstimateLabel", { amount: formatCnyAmount(visible.money.estimatedCost) }) }),
4113
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageEstimateHint, children: t("usageEstimateHint") }),
4114
+ visible.money.unpricedCalls > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageUnpriced, children: t("usageUnpriced", { count: formatTokenCount(visible.money.unpricedCalls) }) })
4115
+ ] })
4116
+ ] }),
4117
+ visible !== null && visible.calls > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageHeroTotal, children: [
4118
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageHeroTotalValue, children: formatTokenCount(billedVolume(visible)) }),
4119
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: css_module_default.usageHeroTotalLabel, children: t("usageTotalLabel") })
4120
+ ] })
4121
+ ] }),
4122
+ loadUsage === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { role: "status", children: t("usageUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
4123
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageToolbar, children: [
4124
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "group", "aria-label": t("usageRangeLabel"), className: css_module_default.usageRanges, children: USAGE_RANGES.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4125
+ "button",
4126
+ {
4127
+ type: "button",
4128
+ className: css_module_default.usageRange,
4129
+ "aria-pressed": item === range,
4130
+ disabled: loading,
4131
+ onClick: () => {
4132
+ setRange(item);
4133
+ },
4134
+ children: t(RANGE_LABEL[item])
4135
+ },
4136
+ item
4137
+ )) }),
4138
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4139
+ "button",
4140
+ {
4141
+ type: "button",
4142
+ className: css_module_default.usageRefresh,
4143
+ disabled: loading,
4144
+ onClick: reload,
4145
+ children: t("usageRefresh")
4146
+ }
4147
+ )
4148
+ ] }),
4149
+ loading && visible === null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { role: "status", children: t("usageLoading") }),
4150
+ failed && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { role: "status", children: [
4151
+ t("usageLoadFailed"),
4152
+ " ",
4153
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", className: css_module_default.settingsConfigure, onClick: reload, children: t("usageRetry") })
4154
+ ] }),
4155
+ visible !== null && visible.calls === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: css_module_default.usageEmpty, children: t("usageEmpty") }),
4156
+ visible !== null && visible.calls > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
4157
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { ref: chartsRef, className: css_module_default.usageCharts, children: [
4158
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(BucketStrip, { summary: visible, t }),
4159
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: css_module_default.usageBucketMeta, children: [
4160
+ t("usageCalls", { count: formatTokenCount(visible.calls) }),
4161
+ visible.reasoningTokens > 0 ? ` \xB7 ${t("usageReasoningNote", { tokens: formatTokenCount(visible.reasoningTokens) })}` : ""
4162
+ ] }),
4163
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4164
+ UsageHeatmapChart,
4165
+ {
4166
+ title: t("usageHeatmap"),
4167
+ hint: visible.heatmap.grain === "hour" ? t("usageHeatmapHourHint") : t("usageHeatmapHint"),
4168
+ heatmap: visible.heatmap,
4169
+ emptyLabel: t("usageChartEmpty"),
4170
+ callsLabel: (count) => t("usageCalls", { count: formatTokenCount(count) })
4171
+ }
4172
+ ),
4173
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4174
+ UsageShareBar,
4175
+ {
4176
+ title: t("usageShareBar"),
4177
+ slices: sourceSlices(visible, t),
4178
+ emptyLabel: t("usageChartEmpty")
4179
+ }
4180
+ ),
4181
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4182
+ UsageRankChart,
4183
+ {
4184
+ title: t("usageChartModels"),
4185
+ slices: modelSlices(visible, t),
4186
+ emptyLabel: t("usageChartEmpty")
4187
+ }
4188
+ )
4189
+ ] }),
4190
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("footer", { className: css_module_default.usageFooter, children: inlineRecent && visible.recent.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecentPreview, children: [
4191
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: css_module_default.usageRecentHead, children: [
4192
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { className: css_module_default.usageSectionTitle, children: t("usageRecent") }),
4193
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4194
+ "button",
4195
+ {
4196
+ type: "button",
4197
+ className: css_module_default.usageLink,
4198
+ onClick: () => {
4199
+ setView("records");
4200
+ },
4201
+ children: t("usageRecordsOpen")
4202
+ }
4203
+ )
4204
+ ] }),
4205
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RecentRows, { calls: visible.recent, t, limit: 3 })
4206
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4207
+ "button",
4208
+ {
4209
+ type: "button",
4210
+ className: css_module_default.usageRecordsEntry,
4211
+ onClick: () => {
4212
+ setView("records");
4213
+ },
4214
+ disabled: visible.recent.length === 0,
4215
+ children: [
4216
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("usageRecent") }),
4217
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("span", { className: css_module_default.usageRecordsEntryMeta, children: [
4218
+ visible.recent.length === 0 ? t("usageRecordsEmpty") : t("usageCalls", { count: formatTokenCount(visible.recent.length) }),
4219
+ " \u203A"
4220
+ ] })
4221
+ ]
4222
+ }
4223
+ ) })
4224
+ ] }),
4225
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: css_module_default.usageRetention, children: t("usageRetention") })
4226
+ ] })
4227
+ ]
4228
+ }
4229
+ );
4230
+ }
4231
+
4232
+ // src/client/dsh/usage-tab.tsx
4233
+ var import_jsx_runtime11 = require("react/jsx-runtime");
4234
+ function UsageRightTab(props) {
4235
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: css_module_default.usageRightPane, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(UsagePanel, { t: props.t, loadUsage: props.loadUsage }) });
4236
+ }
4237
+ function UsageRightTabTitle(props) {
4238
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: props.t("usageTitle") });
4239
+ }
4240
+
4241
+ // src/client/locales.ts
4242
+ var agentLocales = {
4243
+ zh: {
4244
+ historyTitle: "\u5386\u53F2\u63D0\u793A\u8BCD",
4245
+ historySearch: "\u641C\u7D22\u5386\u53F2\u63D0\u793A\u8BCD",
4246
+ historyResults: "\u5386\u53F2\u63D0\u793A\u8BCD\u7ED3\u679C",
4247
+ historyClose: "\u5173\u95ED\u5386\u53F2\u63D0\u793A\u8BCD",
4248
+ optimize: "\u4F18\u5316\u63D0\u793A\u8BCD",
4249
+ optimizePending: "\u6B63\u5728\u4F18\u5316\u63D0\u793A\u8BCD",
4250
+ optimizeUndo: "\u64A4\u9500\u4F18\u5316",
4251
+ optimizeError: "\u4F18\u5316\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
4252
+ optimizeModelUnavailable: "\u5F53\u524D\u6A21\u578B\u4E0D\u53EF\u7528\uFF0C\u8BF7\u68C0\u67E5\u6A21\u578B\u9009\u62E9",
4253
+ optimizeRequestFailed: "\u4F18\u5316\u8BF7\u6C42\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
4254
+ optimizeInvalidOutput: "\u6A21\u578B\u8FD4\u56DE\u5185\u5BB9\u65E0\u6CD5\u5B89\u5168\u5E94\u7528\uFF0C\u8BF7\u91CD\u8BD5",
4255
+ optimizeRollbackFailed: "\u8349\u7A3F\u6062\u590D\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u8349\u7A3F\u5E76\u624B\u52A8\u6062\u590D",
4256
+ optimizeSessionChanged: "\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u4F18\u5316",
4257
+ optimizeChips: "\u4FDD\u7559\u5F15\u7528\uFF0C\u4EC5\u4F18\u5316\u5176\u4ED6\u6587\u5B57",
4258
+ optimizeChipSelection: "\u9009\u533A\u5305\u542B\u5F15\u7528\uFF0C\u8BF7\u4F18\u5316\u6574\u7A3F\u6216\u8C03\u6574\u9009\u533A",
4259
+ settingsTitle: "\u667A\u80FD\u4F53\u589E\u5F3A",
4260
+ settingsSubtitle: "\u4E00\u4E2A\u63D2\u4EF6\u8865\u9F50\u5E38\u7528 Agent \u4F53\u9A8C\uFF0C\u6309\u9700\u5F00\u5173",
4261
+ history: "\u5386\u53F2\u63D0\u793A\u8BCD",
4262
+ historyDescription: "\u2191\u2193 \u56DE\u987E\u5DF2\u53D1\u9001\u63D0\u793A\u8BCD\uFF1BAlt+R \u641C\u7D22\uFF08\u53EF\u7528\u73AF\u5883\u517C\u5BB9 Ctrl+R\uFF09",
4263
+ optimizeDescription: "\u4F18\u5316\u8349\u7A3F\u6216\u6240\u9009\u5185\u5BB9\uFF0C\u652F\u6301\u4E00\u952E\u64A4\u9500",
4264
+ predict: "\u4E0B\u4E00\u6761\u63D0\u793A\u8BCD\u9884\u6D4B",
4265
+ predictDescription: "\u56DE\u590D\u540E\u7ED9\u51FA\u4E00\u6761\u5EFA\u8BAE\uFF0C\u6309 Tab \u91C7\u7EB3",
4266
+ modelCatalogLoading: "\u52A0\u8F7D\u4E2D\u2026",
4267
+ modelCatalogError: "\u6A21\u578B\u4E0D\u53EF\u7528",
4268
+ modelLabel: "\u6A21\u578B",
4269
+ modelFollowSession: "\u8DDF\u968F\u4F1A\u8BDD",
4270
+ modelAuto: "Auto",
4271
+ modelUnconfigured: "\u672A\u8BBE\u7F6E",
4272
+ reasoningDefault: "\u9ED8\u8BA4",
4273
+ settingsBack: "\u8FD4\u56DE",
4274
+ settingsConfigure: "\u914D\u7F6E",
4275
+ usageTitle: "\u6A21\u578B\u8D26\u5355",
4276
+ usageNote: "\u63D0\u4F9B\u65B9\u56DE\u62A5\u7684 token\uFF0C\u4E0D\u662F\u91D1\u989D\u3002",
4277
+ usageMeterOpen: "\u67E5\u770B\u8D26\u5355",
4278
+ usageBuckets: "Token \u5206\u9879",
4279
+ usageBucketInput: "\u8F93\u5165",
4280
+ usageBucketOutput: "\u8F93\u51FA",
4281
+ usageBucketCacheRead: "\u7F13\u5B58\u8BFB",
4282
+ usageBucketCacheWrite: "\u7F13\u5B58\u5199",
4283
+ usageReasoningNote: "\u5176\u4E2D\u63A8\u7406 {tokens}",
4284
+ usageChartSources: "\u6309\u529F\u80FD",
4285
+ usageChartModels: "\u6309\u6A21\u578B",
4286
+ usageChartTotal: "token",
4287
+ usageChartEmpty: "\u8FD9\u4E2A\u8303\u56F4\u6CA1\u6709\u53EF\u7ED8\u5236\u7684 token\u3002",
4288
+ usageHeatmap: "\u7528\u91CF\u70ED\u529B",
4289
+ usageHeatmapHint: "\u683C\u5B50\u8D8A\u6DF1\uFF0C\u5F53\u5929\u7528\u5F97\u8D8A\u591A\u3002\u60AC\u505C\u770B\u5177\u4F53\u6570\u5B57\u3002",
4290
+ usageHeatmapHourHint: "\u683C\u5B50\u8D8A\u6DF1\uFF0C\u8BE5\u5C0F\u65F6\u7528\u5F97\u8D8A\u591A\u3002\u60AC\u505C\u770B\u5177\u4F53\u6570\u5B57\u3002",
4291
+ usageShareBar: "\u529F\u80FD\u5360\u6BD4",
4292
+ usageTotalLabel: "\u5408\u8BA1 token",
4293
+ usageEstimateLabel: "\u7EA6 \xA5{amount}",
4294
+ usageEstimateHint: "\u6309\u5B98\u65B9\u4EF7\u4F30\u7B97\uFF0C\u4E0D\u662F\u5E73\u53F0\u53D1\u7968",
4295
+ usageUnpriced: "{count} \u6B21\u8C03\u7528\u65E0\u4EF7\u76EE\uFF0C\u672A\u8BA1\u5165\u91D1\u989D",
4296
+ usageBalanceLabel: "\u4F59\u989D \xA5{amount}",
4297
+ usageBalanceDetail: "\u8D60\u9001 {granted} \xB7 \u5145\u503C {toppedUp}",
4298
+ usageBalanceStale: "\u4F59\u989D\u6765\u81EA\u6700\u8FD1\u4E00\u6B21\u6210\u529F\u67E5\u8BE2",
4299
+ usageBalanceNoKey: "\u672A\u8BFB\u5230 DeepSeek API Key\uFF0C\u65E0\u6CD5\u67E5\u4F59\u989D\uFF08\u4F7F\u7528 Desktop \u6A21\u578B\u9875\u51ED\u636E\uFF0C\u63D2\u4EF6\u4E0D\u643A\u5E26 Key\uFF09",
4300
+ usageBalanceUnavailable: "\u4F59\u989D\u6682\u65F6\u67E5\u4E0D\u5230\uFF0C\u53EF\u70B9\u5237\u65B0\u91CD\u8BD5",
4301
+ providerBalanceLabel: "\u4F59\u989D \xA5{amount}",
4302
+ providerBalanceDetail: "\u8D60\u9001 {granted} \xB7 \u5145\u503C {toppedUp}",
4303
+ providerBalanceStale: "\u6765\u81EA\u6700\u8FD1\u4E00\u6B21\u6210\u529F\u67E5\u8BE2",
4304
+ providerBalanceLoading: "\u6B63\u5728\u8BFB\u53D6\u4F59\u989D\u2026",
4305
+ providerBalanceNoKey: "\u672A\u914D\u7F6E API Key\uFF0C\u65E0\u6CD5\u67E5\u4F59\u989D",
4306
+ providerBalanceSignedOut: "\u672A\u767B\u5F55\uFF0C\u65E0\u6CD5\u67E5\u4F59\u989D",
4307
+ providerBalanceUnavailable: "\u4F59\u989D\u6682\u65F6\u67E5\u4E0D\u5230\uFF0C\u70B9\u51FB\u91CD\u8BD5",
4308
+ providerBalanceRefreshHint: "\u70B9\u51FB\u5237\u65B0\u4F59\u989D",
4309
+ usageRecordModel: "\u6A21\u578B {model}",
4310
+ usageRecordProvider: "\u7EBF\u8DEF {provider}",
4311
+ usageRecordEffort: "\u63A8\u7406 {effort}",
4312
+ usageRecordInput: "\u8F93\u5165 {tokens}",
4313
+ usageRecordOutput: "\u8F93\u51FA {tokens}",
4314
+ usageRecordCacheRead: "\u7F13\u5B58\u8BFB {tokens}",
4315
+ usageRecordCacheWrite: "\u7F13\u5B58\u5199 {tokens}",
4316
+ usageModelRouteEffort: "{provider} / {model} \xB7 {effort}",
4317
+ usageBack: "\u8FD4\u56DE",
4318
+ usageRecordsOpen: "\u5168\u90E8",
4319
+ usageRecordsHint: "\u6700\u8FD1\u4F1A\u8BDD\u4E0E\u63D2\u4EF6\u8C03\u7528\uFF0C\u6309\u65F6\u95F4\u5012\u5E8F\u3002\u6570\u5B57\u662F\u8BE5\u6B21\u8C03\u7528\u7684 token\u3002",
4320
+ usageRecordsEmpty: "\u8FD8\u6CA1\u6709\u8C03\u7528\u8BB0\u5F55\u3002",
4321
+ usageLoading: "\u6B63\u5728\u8BFB\u53D6\u8D26\u5355\u2026",
4322
+ usageLoadFailed: "\u8D26\u5355\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
4323
+ usageRetry: "\u91CD\u8BD5",
4324
+ usageRefresh: "\u5237\u65B0",
4325
+ usageUnavailable: "\u8D26\u5355\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002",
4326
+ usageEmpty: "\u8FD8\u6CA1\u6709\u5DF2\u56DE\u62A5\u7684\u8C03\u7528\u3002",
4327
+ usageRangeLabel: "\u65F6\u95F4\u8303\u56F4",
4328
+ usageRange_today: "\u4ECA\u5929",
4329
+ usageRange_7d: "7 \u5929",
4330
+ usageRange_30d: "30 \u5929",
4331
+ usageRange_all: "\u5168\u90E8",
4332
+ usageRecent: "\u8C03\u7528\u8BB0\u5F55",
4333
+ usageRetention: "\u672C\u5730\u4FDD\u5B58\uFF0C\u4E0D\u542B\u63D0\u793A\u8BCD\u3002\u63D2\u4EF6\u529F\u80FD\u6700\u591A\u4FDD\u7559 90 \u5929 / 2000 \u6B21\u3002",
4334
+ usageCalls: "{count} \u6B21",
4335
+ usageModelRoute: "{provider} / {model}",
4336
+ usageSource_optimize: "\u63D0\u793A\u8BCD\u4F18\u5316",
4337
+ usageSource_predict: "\u4E0B\u4E00\u6761\u9884\u6D4B",
4338
+ usageSource_compact: "\u4E0A\u4E0B\u6587\u538B\u7F29",
4339
+ usageSource_autoClassifier: "Auto \u5206\u7C7B",
4340
+ usageSource_session: "\u684C\u9762\u4F1A\u8BDD",
4341
+ usageSource_compaction: "\u5B98\u65B9\u538B\u7F29",
4342
+ usageSource_sessionTitle: "\u4F1A\u8BDD\u6807\u9898",
4343
+ usageSource_other: "\u5176\u4ED6\u8C03\u7528",
4344
+ updateTitle: "\u63D2\u4EF6\u66F4\u65B0",
4345
+ updateCurrent: "\u5F53\u524D\u7248\u672C v{version}",
4346
+ updateCheck: "\u68C0\u67E5\u66F4\u65B0",
4347
+ updateChecking: "\u6B63\u5728\u68C0\u67E5\u2026",
4348
+ updateLatest: "\u5DF2\u662F\u6700\u65B0\u7248\u672C",
4349
+ updateAvailable: "\u53D1\u73B0 v{version}",
4350
+ updateApply: "\u66F4\u65B0\u5230 v{version}",
4351
+ updateApplying: "\u6B63\u5728\u66F4\u65B0\u2026",
4352
+ updateRestart: "\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u5B8C\u5168\u9000\u51FA\u5E76\u91CD\u542F Desktop",
4353
+ updateLinkBlocked: "\u5F53\u524D\u4E3A\u5F00\u53D1\u76EE\u5F55\u94FE\u63A5\uFF0C\u8BF7\u5728\u672C\u5730\u6267\u884C pnpm build\uFF0C\u52FF\u7528 npm \u8986\u76D6\u3002",
4354
+ updateManual: "\u65E0\u6CD5\u81EA\u52A8\u66F4\u65B0\uFF0C\u8BF7\u9000\u51FA Desktop \u540E\u8FD0\u884C\uFF1A",
4355
+ updateFailed: "\u66F4\u65B0\u5931\u8D25\u3002\u8BF7\u9000\u51FA Desktop \u540E\u8FD0\u884C\uFF1A",
4356
+ updateCheckFailed: "\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
4357
+ updateCopy: "\u590D\u5236\u547D\u4EE4",
4358
+ updateCopied: "\u5DF2\u590D\u5236",
4359
+ autoRouting: "Auto \u8DEF\u7531",
4360
+ autoRoutingDescription: "\u4F1A\u8BDD\u4E0E\u8F85\u52A9\u529F\u80FD\u53EF\u9009 Auto\uFF1B\u5728\u6B64\u914D\u7F6E\u6863\u4F4D\u6620\u5C04\uFF0C\u4EE5\u53CA\u53EF\u9009\u7684\u5C0F\u6A21\u578B\u5206\u7C7B",
4361
+ autoClassifier: "\u7528\u5C0F\u6A21\u578B\u534F\u52A9 Auto \u5206\u7C7B",
4362
+ autoClassifierDescription: "\u5F00\u542F\u540E\uFF0C\u9009\u4E2D Auto \u65F6\u4F1A\u989D\u5916\u8C03\u7528\u5206\u7C7B\u6A21\u578B\u5224\u5B9A instant / thinking / pro\uFF1B\u5173\u95ED\u5219\u4EC5\u7528\u542F\u53D1\u5F0F\u5B9A\u6863",
4363
+ autoMappingTitle: "Auto \u6863\u4F4D\u6A21\u578B\u6620\u5C04",
4364
+ autoTier_instant: "\u5373\u65F6",
4365
+ autoTier_thinking: "\u601D\u8003",
4366
+ autoTier_pro: "\u4E13\u4E1A",
4367
+ autoTier_classifier: "\u5206\u7C7B\u5668",
4368
+ privacyTitle: "\u6570\u636E\u4E0E\u9690\u79C1",
4369
+ privacy: "\u4F18\u5316\u3001\u9884\u6D4B\u4E0E\u4E0A\u4E0B\u6587\u538B\u7F29\u4F1A\u628A\u76F8\u5173\u5185\u5BB9\u53D1\u9001\u7ED9\u6240\u9009\u6A21\u578B\u63D0\u4F9B\u5546\uFF08\u9ED8\u8BA4\u8DDF\u968F\u5F53\u524D\u4F1A\u8BDD\u6A21\u578B\uFF09\uFF1B\u5386\u53F2\u4E0D\u8BF7\u6C42\u6A21\u578B\uFF1B\u4E0D\u91C7\u96C6\u63D0\u793A\u8BCD\u5185\u5BB9\u6216\u91C7\u7EB3\u7387\u9065\u6D4B\u3002\u6A21\u578B\u8D26\u5355\u53EA\u8BB0\u5F55\u529F\u80FD\u3001\u6A21\u578B\u548C token\uFF0C\u7559\u5728\u672C\u673A\uFF0C\u4E0D\u4E0A\u4F20\u3002",
4370
+ coexistence: "\u68C0\u6D4B\u5230\u5B98\u65B9\u6216\u7B2C\u4E09\u65B9\u540C\u7C7B\u80FD\u529B\u65F6\u4EC5\u63D0\u793A\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u505C\u7528\u3002",
4371
+ settingsError: "\u8BBE\u7F6E\u672A\u4FDD\u5B58\uFF0C\u8BF7\u91CD\u8BD5\u3002",
4372
+ overlapHistory: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u5386\u53F2\u63D0\u793A\u8BCD\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u5386\u53F2\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
4373
+ overlapOptimize: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u63D0\u793A\u8BCD\u4F18\u5316\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u4F18\u5316\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
4374
+ overlapPredict: "\u68C0\u6D4B\u5230\u53E6\u4E00\u4E2A\u56DE\u590D\u5EFA\u8BAE\u529F\u80FD\u3002\u667A\u80FD\u4F53\u589E\u5F3A\u7684\u9884\u6D4B\u4ECD\u4FDD\u6301\u5F00\u542F\u3002",
4375
+ dismissHint: "\u5173\u95ED\u5171\u5B58\u63D0\u793A",
4376
+ contextInspect: "\u4E0A\u4E0B\u6587\u660E\u7EC6",
4377
+ contextInspectDescription: "\u70B9\u51FB\u5B98\u65B9\u5360\u7528\u73AF\u6253\u5F00\u53F3\u4FA7\u660E\u7EC6\uFF1B\u53EF\u4E00\u952E\u5B98\u65B9\u538B\u7F29\uFF0C\u5E76\u5355\u72EC\u9009\u62E9\u538B\u7F29\u6458\u8981\u6A21\u578B",
4378
+ contextInspectDetailTitle: "\u4E0A\u4E0B\u6587\u660E\u7EC6",
4379
+ contextInspectNote: "\u6570\u5B57\u4E3A\u542F\u53D1\u5F0F\u4F30\u7B97\uFF08\u7EA6\uFF09\uFF0C\u6309\u5360\u7528\u6392\u5E8F\uFF1B\u7528\u4E8E\u7406\u89E3\u5F53\u524D\u7A97\u53E3\u6784\u6210\uFF0C\u975E\u8D26\u5355\u7CBE\u786E\u503C\u3002",
4380
+ contextInspectEmpty: "\u8FD9\u4E00\u7C7B\u5F53\u524D\u6CA1\u6709\u53EF\u5217\u51FA\u7684\u6761\u76EE\u3002",
4381
+ contextInspectApproxTotal: "\u7EA6 {tokens}",
4382
+ contextInspectApproxBadge: "\u7EA6",
4383
+ contextInspectOpenCategory: "\u5728\u53F3\u4FA7\u680F\u67E5\u770B{category}\u660E\u7EC6",
4384
+ contextInspectCategories: "\u4E0A\u4E0B\u6587\u5206\u7C7B",
4385
+ contextInspectItemDetail: "\u6761\u76EE\u8BE6\u60C5",
4386
+ contextInspectLoading: "\u6B63\u5728\u52A0\u8F7D\u4E0A\u4E0B\u6587\u660E\u7EC6\u2026",
4387
+ contextInspectLoadFailed: "\u4E0A\u4E0B\u6587\u660E\u7EC6\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002",
4388
+ contextInspectNoSession: "\u5F53\u524D\u6CA1\u6709\u53EF\u68C0\u67E5\u7684\u4F1A\u8BDD\u3002",
4389
+ contextInspectChartOverview: "\u7A97\u53E3\u6784\u6210\uFF08\u7EA6\uFF09",
4390
+ contextInspectChartCategory: "\u672C\u7C7B\u6784\u6210\uFF08\u7EA6\uFF09",
4391
+ contextInspectChartMessages: "\u6D88\u606F\u6784\u6210\uFF08\u7EA6\uFF09",
4392
+ contextInspectChartOther: "\u5176\u4ED6",
4393
+ contextInspectCategory_system: "\u7CFB\u7EDF\u63D0\u793A\u8BCD",
4394
+ contextInspectCategory_tools: "\u5DE5\u5177",
4395
+ contextInspectCategory_messages: "\u6D88\u606F",
4396
+ contextInspectKind_user: "\u7528\u6237",
4397
+ contextInspectKind_inject: "\u6CE8\u5165",
4398
+ contextInspectKind_assistant: "\u52A9\u624B",
4399
+ contextInspectKind_tool: "\u5DE5\u5177\u7ED3\u679C",
4400
+ contextInspectKind_developer: "\u5F00\u53D1\u8005",
4401
+ contextInspectHeadroom: "\u7A97\u53E3\u4F59\u91CF",
4402
+ contextInspectOccupied: "\u5F53\u524D\u5360\u7528",
4403
+ contextInspectEvents: "\u538B\u7F29\u4E0E\u88C1\u526A",
4404
+ contextInspectEvent_compact: "\u538B\u7F29",
4405
+ contextInspectEvent_prune: "\u88C1\u526A",
4406
+ contextInspectEvent_replace: "\u66FF\u6362",
4407
+ contextInspectReplaced: "\u7ECF\u538B\u7F29",
4408
+ contextInspectCompact: "\u538B\u7F29\u4E0A\u4E0B\u6587",
4409
+ contextInspectCompactHint: "\u8C03\u7528\u5B98\u65B9 /compact\uFF0C\u6458\u8981\u8F83\u65E9\u5386\u53F2\u5E76\u91CA\u653E\u7A97\u53E3",
4410
+ contextInspectCompacting: "\u6B63\u5728\u538B\u7F29\u2026",
4411
+ contextInspectCompactDone: "\u5DF2\u538B\u7F29 {count} \u9879\uFF08\u7EA6 {tokens}\uFF09",
4412
+ contextInspectCompactNoop: "\u5F53\u524D\u6CA1\u6709\u53EF\u5B89\u5168\u538B\u7F29\u7684\u5386\u53F2\u3002",
4413
+ contextInspectCompactUnavailable: "\u5F53\u524D\u73AF\u5883\u672A\u63D0\u4F9B\u5B98\u65B9\u538B\u7F29\u80FD\u529B\u3002",
4414
+ contextInspectCompactBusy: "\u667A\u80FD\u4F53\u5FD9\u788C\u4E2D\uFF0C\u8BF7\u7ED3\u675F\u540E\u518D\u538B\u7F29\u3002",
4415
+ contextInspectCompactFailed: "\u538B\u7F29\u672A\u5B8C\u6210\uFF0C\u4F1A\u8BDD\u53EF\u80FD\u672A\u53D8\u5316\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
4416
+ contextInspectCompactSummary: "\u672A\u80FD\u751F\u6210\u53EF\u7528\u6458\u8981\uFF0C\u4F1A\u8BDD\u672A\u53D8\u5316\uFF1B\u53EF\u6362\u6A21\u578B\u540E\u91CD\u8BD5\u3002",
4417
+ contextInspectCompactChanged: "\u538B\u7F29\u8FC7\u7A0B\u4E2D\u5386\u53F2\u5DF2\u53D8\u5316\uFF0C\u4F1A\u8BDD\u672A\u5199\u5165\uFF1B\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
4418
+ rollback: "\u5BF9\u8BDD\u4E0E\u6587\u4EF6\u6062\u590D",
4419
+ rollbackDescription: "\u5728\u5408\u89C4\u7528\u6237\u6D88\u606F\u65C1\u9884\u89C8\u5E76\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4420
+ rollbackBoundary: "\u4E0D\u6062\u590D\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u6216\u672A\u8DDF\u8E2A\u6587\u4EF6\uFF1B\u5173\u95ED\u540E\u4FDD\u7559\u5DF2\u6709\u65E5\u5FD7\u548C\u68C0\u67E5\u70B9\u3002",
4421
+ rollbackAction: "\u6062\u590D\u5230\u8FD9\u91CC",
4422
+ rollbackUndoAction: "\u64A4\u9500\u6062\u590D",
4423
+ rollbackUndoCommandDescription: "\u64A4\u56DE\u6700\u8FD1\u4E00\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u9884\u89C8\u5185\u5BB9",
4424
+ rollbackTitle: "\u6062\u590D\u5230\u7B2C {turn} \u8F6E\u4E4B\u524D",
4425
+ rollbackUndoTitle: "\u64A4\u9500\u7B2C {turn} \u8F6E\u6062\u590D",
4426
+ rollbackScope: "\u53EF\u9009\u62E9\u4EC5\u6062\u590D\u5BF9\u8BDD\uFF0C\u6216\u540C\u65F6\u6062\u590D\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002\u65E0\u6587\u4EF6\u53D8\u66F4\u6216\u4EC5\u6709\u6355\u83B7\u7F3A\u53E3\u65F6\u4ECD\u53EF\u786E\u8BA4\uFF1B\u6709\u6587\u4EF6\u51B2\u7A81\u65F6\u4ECD\u53EF\u4EC5\u6062\u590D\u5BF9\u8BDD\u3002",
4427
+ rollbackUndoScope: "\u5C06\u64A4\u56DE\u672C\u6B21\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u9884\u89C8\u3002\u8FDB\u7A0B\u3001\u7EC8\u7AEF\u3001\u540E\u53F0\u4EFB\u52A1\u3001\u6570\u636E\u5E93\u3001\u7F51\u7EDC\u3001\u90E8\u7F72\u3001\u7B2C\u4E09\u65B9\u670D\u52A1\u548C\u672A\u8DDF\u8E2A\u6587\u4EF6\u4E0D\u4F1A\u6062\u590D\u3002",
4428
+ rollbackUndoScopeConversation: "\u5C06\u64A4\u56DE\u672C\u6B21\u4EC5\u5BF9\u8BDD\u6062\u590D\u6807\u8BB0\uFF0C\u5E76\u8FD8\u539F\u6062\u590D\u524D\u7684\u5BF9\u8BDD\u9884\u89C8\u3002\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u4FDD\u6301\u5F53\u524D\u72B6\u6001\u3002",
4429
+ rollbackClose: "\u5173\u95ED\u6062\u590D\u9884\u89C8",
4430
+ rollbackConfirm: "\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6",
4431
+ rollbackConfirmConversation: "\u4EC5\u6062\u590D\u5BF9\u8BDD",
4432
+ rollbackUndoConfirm: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u9884\u89C8\u5185\u5BB9",
4433
+ rollbackUndoConfirmConversation: "\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD",
4434
+ rollbackCancel: "\u53D6\u6D88",
4435
+ rollbackLoading: "\u6B63\u5728\u91CD\u65B0\u68C0\u67E5\u5BF9\u8BDD\u548C\u6587\u4EF6\u72B6\u6001\u2026",
4436
+ rollbackRestoring: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4437
+ rollbackRestoringConversation: "\u6B63\u5728\u6062\u590D\u5BF9\u8BDD\u2026",
4438
+ rollbackUndoRestoring: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u4E0E\u5DF2\u8DDF\u8E2A\u6587\u4EF6\u2026",
4439
+ rollbackUndoRestoringConversation: "\u6B63\u5728\u64A4\u9500\u6062\u590D\u5E76\u8FD8\u539F\u5BF9\u8BDD\u2026",
4440
+ rollbackFailed: "\u6062\u590D\u672A\u5B8C\u6210\uFF0C\u8BF7\u5173\u95ED\u9884\u89C8\u540E\u91CD\u8BD5\u3002",
2159
4441
  rollbackTurnOpen: "\u672C\u8F6E\u5C1A\u672A\u7ED3\u675F",
2160
4442
  rollbackTurnStartMissing: "\u672C\u8F6E\u5F00\u59CB\u4E8B\u4EF6\u5C1A\u672A\u52A0\u8F7D",
2161
4443
  rollbackMessages: "\u5C06\u64A4\u56DE\u7684\u5BF9\u8BDD",
@@ -2217,15 +4499,154 @@ var agentLocales = {
2217
4499
  modelCatalogError: "Unavailable",
2218
4500
  modelLabel: "Model",
2219
4501
  modelFollowSession: "Follow session",
4502
+ modelAuto: "Auto",
4503
+ modelUnconfigured: "Not set",
2220
4504
  reasoningDefault: "Default",
4505
+ settingsBack: "Back",
4506
+ settingsConfigure: "Configure",
4507
+ usageTitle: "Model bill",
4508
+ usageNote: "Provider-reported tokens, not currency.",
4509
+ usageMeterOpen: "View bill",
4510
+ usageBuckets: "Token buckets",
4511
+ usageBucketInput: "Input",
4512
+ usageBucketOutput: "Output",
4513
+ usageBucketCacheRead: "Cache read",
4514
+ usageBucketCacheWrite: "Cache write",
4515
+ usageReasoningNote: "including {tokens} reasoning",
4516
+ usageChartSources: "By feature",
4517
+ usageChartModels: "By model",
4518
+ usageChartTotal: "tokens",
4519
+ usageChartEmpty: "No tokens to chart in this range.",
4520
+ usageHeatmap: "Usage heat",
4521
+ usageHeatmapHint: "Darker cells used more that day. Hover for exact counts.",
4522
+ usageHeatmapHourHint: "Darker cells used more that hour. Hover for exact counts.",
4523
+ usageShareBar: "Feature share",
4524
+ usageTotalLabel: "Total tokens",
4525
+ usageEstimateLabel: "\u2248 \xA5{amount}",
4526
+ usageEstimateHint: "Estimated from official rates, not a provider invoice",
4527
+ usageUnpriced: "{count} calls have no price row and are excluded from cost",
4528
+ usageBalanceLabel: "Balance \xA5{amount}",
4529
+ usageBalanceDetail: "Granted {granted} \xB7 Topped up {toppedUp}",
4530
+ usageBalanceStale: "Balance from the last successful check",
4531
+ usageBalanceNoKey: "No DeepSeek API key found, so balance is unavailable (uses Desktop model credentials; this plugin ships no keys)",
4532
+ usageBalanceUnavailable: "Balance is temporarily unavailable. Try Refresh.",
4533
+ providerBalanceLabel: "Balance \xA5{amount}",
4534
+ providerBalanceDetail: "Granted {granted} \xB7 Topped up {toppedUp}",
4535
+ providerBalanceStale: "From the last successful check",
4536
+ providerBalanceLoading: "Reading balance\u2026",
4537
+ providerBalanceNoKey: "No API key configured, so balance is unavailable",
4538
+ providerBalanceSignedOut: "Not signed in, so balance is unavailable",
4539
+ providerBalanceUnavailable: "Balance is temporarily unavailable. Click to retry",
4540
+ providerBalanceRefreshHint: "Click to refresh balance",
4541
+ usageRecordModel: "Model {model}",
4542
+ usageRecordProvider: "Route {provider}",
4543
+ usageRecordEffort: "Effort {effort}",
4544
+ usageRecordInput: "In {tokens}",
4545
+ usageRecordOutput: "Out {tokens}",
4546
+ usageRecordCacheRead: "Cache read {tokens}",
4547
+ usageRecordCacheWrite: "Cache write {tokens}",
4548
+ usageModelRouteEffort: "{provider} / {model} \xB7 {effort}",
4549
+ usageBack: "Back",
4550
+ usageRecordsOpen: "All",
4551
+ usageRecordsHint: "Latest session and plugin calls, newest first. Numbers are tokens for that call.",
4552
+ usageRecordsEmpty: "No calls yet.",
4553
+ usageLoading: "Reading the bill\u2026",
4554
+ usageLoadFailed: "Could not read the bill. Try again.",
4555
+ usageRetry: "Try again",
4556
+ usageRefresh: "Refresh",
4557
+ usageUnavailable: "The bill is not available yet. Try again later.",
4558
+ usageEmpty: "No reported calls yet.",
4559
+ usageRangeLabel: "Time range",
4560
+ usageRange_today: "Today",
4561
+ usageRange_7d: "7 days",
4562
+ usageRange_30d: "30 days",
4563
+ usageRange_all: "All",
4564
+ usageRecent: "Calls",
4565
+ usageRetention: "Stored locally, no prompt text. Plugin features keep up to 90 days / 2000 calls.",
4566
+ usageCalls: "{count} calls",
4567
+ usageModelRoute: "{provider} / {model}",
4568
+ usageSource_optimize: "Prompt optimize",
4569
+ usageSource_predict: "Next-prompt prediction",
4570
+ usageSource_compact: "Context compact",
4571
+ usageSource_autoClassifier: "Auto classifier",
4572
+ usageSource_session: "Desktop session",
4573
+ usageSource_compaction: "Official compact",
4574
+ usageSource_sessionTitle: "Session title",
4575
+ usageSource_other: "Other calls",
4576
+ updateTitle: "Plugin update",
4577
+ updateCurrent: "Current version v{version}",
4578
+ updateCheck: "Check for updates",
4579
+ updateChecking: "Checking\u2026",
4580
+ updateLatest: "You're up to date",
4581
+ updateAvailable: "Update available: v{version}",
4582
+ updateApply: "Update to v{version}",
4583
+ updateApplying: "Updating\u2026",
4584
+ updateRestart: "Updated. Fully quit and restart Desktop.",
4585
+ updateLinkBlocked: "This install is a linked dev folder. Run pnpm build locally; do not overwrite via npm.",
4586
+ updateManual: "Cannot update automatically. Quit Desktop, then run:",
4587
+ updateFailed: "Update failed. Quit Desktop, then run:",
4588
+ updateCheckFailed: "Could not check for updates. Try again later.",
4589
+ updateCopy: "Copy command",
4590
+ updateCopied: "Copied",
4591
+ autoRouting: "Auto routing",
4592
+ autoRoutingDescription: "Sessions and helpers can pick Auto; configure tier mappings and an optional small-model classifier here",
4593
+ autoClassifier: "Use a small model to help Auto classify",
4594
+ autoClassifierDescription: "When on, Auto may call a classifier model to pick instant / thinking / pro; when off, Auto uses heuristics only",
4595
+ autoMappingTitle: "Auto tier model map",
4596
+ autoTier_instant: "Instant",
4597
+ autoTier_thinking: "Thinking",
4598
+ autoTier_pro: "Pro",
4599
+ autoTier_classifier: "Classifier",
2221
4600
  privacyTitle: "Data and privacy",
2222
- privacy: "Optimization and prediction send selected text or recent conversation to the selected model provider (defaults to the current session model). History never requests a model. No prompt content or acceptance-rate telemetry is collected.",
4601
+ privacy: "Optimize, predict, and context compact send related content to the selected model provider (defaults to the current session model). History never requests a model. No prompt content or acceptance-rate telemetry is collected. The model bill records only the feature, model, and token counts on this computer, and is not uploaded.",
2223
4602
  coexistence: "Similar official or third-party features are only reported; they are never disabled automatically.",
2224
4603
  settingsError: "Setting was not saved. Try again.",
2225
4604
  overlapHistory: "Another prompt-history feature is enabled. Agent Enhance history remains enabled.",
2226
4605
  overlapOptimize: "Another prompt-optimization feature is enabled. Agent Enhance optimization remains enabled.",
2227
4606
  overlapPredict: "Another reply-suggestion feature is enabled. Agent Enhance prediction remains enabled.",
2228
4607
  dismissHint: "Dismiss coexistence notice",
4608
+ contextInspect: "Context details",
4609
+ contextInspectDescription: "Open right-sidebar details from the official meter; one-click official compact with an optional summary model",
4610
+ contextInspectDetailTitle: "Context details",
4611
+ contextInspectNote: "Counts are approximate heuristics sorted by size for understanding the current window, not billing-grade totals.",
4612
+ contextInspectEmpty: "Nothing to list in this category right now.",
4613
+ contextInspectApproxTotal: "~{tokens}",
4614
+ contextInspectApproxBadge: "~",
4615
+ contextInspectOpenCategory: "Open {category} details in the right sidebar",
4616
+ contextInspectCategories: "Context categories",
4617
+ contextInspectItemDetail: "Item detail",
4618
+ contextInspectLoading: "Loading context details\u2026",
4619
+ contextInspectLoadFailed: "Failed to load context details. Try again.",
4620
+ contextInspectNoSession: "No session is available to inspect.",
4621
+ contextInspectChartOverview: "Window composition (~)",
4622
+ contextInspectChartCategory: "Category composition (~)",
4623
+ contextInspectChartMessages: "Message composition (~)",
4624
+ contextInspectChartOther: "Other",
4625
+ contextInspectCategory_system: "System",
4626
+ contextInspectCategory_tools: "Tools",
4627
+ contextInspectCategory_messages: "Messages",
4628
+ contextInspectKind_user: "User",
4629
+ contextInspectKind_inject: "Injected",
4630
+ contextInspectKind_assistant: "Assistant",
4631
+ contextInspectKind_tool: "Tool result",
4632
+ contextInspectKind_developer: "Developer",
4633
+ contextInspectHeadroom: "Headroom",
4634
+ contextInspectOccupied: "Occupied",
4635
+ contextInspectEvents: "Compaction & prune",
4636
+ contextInspectEvent_compact: "Compact",
4637
+ contextInspectEvent_prune: "Prune",
4638
+ contextInspectEvent_replace: "Replace",
4639
+ contextInspectReplaced: "Compacted",
4640
+ contextInspectCompact: "Compact context",
4641
+ contextInspectCompactHint: "Runs official /compact to summarize older history and free window space",
4642
+ contextInspectCompacting: "Compacting\u2026",
4643
+ contextInspectCompactDone: "Compacted {count} items (~{tokens})",
4644
+ contextInspectCompactNoop: "No safe history range to compact yet.",
4645
+ contextInspectCompactUnavailable: "Official compaction is not available here.",
4646
+ contextInspectCompactBusy: "The agent is busy. Try again when it is idle.",
4647
+ contextInspectCompactFailed: "Compaction did not finish. The conversation may be unchanged; try again.",
4648
+ contextInspectCompactSummary: "Could not produce a useful summary; the conversation is unchanged. Try another model.",
4649
+ contextInspectCompactChanged: "History changed during compaction; nothing was written. Try again.",
2229
4650
  rollback: "Conversation and file restore",
2230
4651
  rollbackDescription: "Preview and restore conversation and tracked files from eligible user messages",
2231
4652
  rollbackBoundary: "Processes, terminals, background jobs, databases, network activity, deployments, third-party state, and untracked files are not restored. Existing logs and checkpoints remain after disable.",
@@ -2354,6 +4775,9 @@ var checkpointRollbackRemote = {
2354
4775
  };
2355
4776
 
2356
4777
  // src/client/remote.ts
4778
+ function auxiliaryCode(value, fallback) {
4779
+ return typeof value === "string" && AUXILIARY_ERROR_CODES.includes(value) ? value : fallback;
4780
+ }
2357
4781
  function codec2(typeSymbol) {
2358
4782
  return {
2359
4783
  mode: "strict",
@@ -2390,6 +4814,82 @@ var clientRemoteInfo = {
2390
4814
  invocation: { kind: "direct" },
2391
4815
  parameters: [],
2392
4816
  result: codec2("dsh-agent-enhancer#ModelCatalog")
4817
+ }, {
4818
+ id: "dsh-agent-enhancer#agentEnhancer/inspectContext",
4819
+ service: "agentEnhancer",
4820
+ namespace: "agentEnhancer",
4821
+ method: "inspectContext",
4822
+ implementation: "inspectContext",
4823
+ invocation: { kind: "direct" },
4824
+ parameters: [{
4825
+ name: "request",
4826
+ wire: "request",
4827
+ source: "json",
4828
+ codec: codec2("dsh-agent-enhancer#ContextInspectRequest")
4829
+ }],
4830
+ cancellation: { parameter: "signal" },
4831
+ result: codec2("dsh-agent-enhancer#ContextInspectResult")
4832
+ }, {
4833
+ id: "dsh-agent-enhancer#agentEnhancer/compactContext",
4834
+ service: "agentEnhancer",
4835
+ namespace: "agentEnhancer",
4836
+ method: "compactContext",
4837
+ implementation: "compactContext",
4838
+ invocation: { kind: "direct" },
4839
+ parameters: [{
4840
+ name: "request",
4841
+ wire: "request",
4842
+ source: "json",
4843
+ codec: codec2("dsh-agent-enhancer#ContextCompactRequest")
4844
+ }],
4845
+ cancellation: { parameter: "signal" },
4846
+ result: codec2("dsh-agent-enhancer#ContextCompactResult")
4847
+ }, {
4848
+ id: "dsh-agent-enhancer#agentEnhancer/checkUpdate",
4849
+ service: "agentEnhancer",
4850
+ namespace: "agentEnhancer",
4851
+ method: "checkUpdate",
4852
+ implementation: "checkUpdate",
4853
+ invocation: { kind: "direct" },
4854
+ parameters: [],
4855
+ result: codec2("dsh-agent-enhancer#UpdateCheckResult")
4856
+ }, {
4857
+ id: "dsh-agent-enhancer#agentEnhancer/applyUpdate",
4858
+ service: "agentEnhancer",
4859
+ namespace: "agentEnhancer",
4860
+ method: "applyUpdate",
4861
+ implementation: "applyUpdate",
4862
+ invocation: { kind: "direct" },
4863
+ parameters: [],
4864
+ result: codec2("dsh-agent-enhancer#ApplyUpdateResult")
4865
+ }, {
4866
+ id: "dsh-agent-enhancer#agentEnhancer/usageSummary",
4867
+ service: "agentEnhancer",
4868
+ namespace: "agentEnhancer",
4869
+ method: "usageSummary",
4870
+ implementation: "usageSummary",
4871
+ invocation: { kind: "direct" },
4872
+ parameters: [{
4873
+ name: "range",
4874
+ wire: "range",
4875
+ source: "json",
4876
+ codec: codec2("dsh-agent-enhancer#UsageRange")
4877
+ }],
4878
+ result: codec2("dsh-agent-enhancer#UsageSummary")
4879
+ }, {
4880
+ id: "dsh-agent-enhancer#agentEnhancer/providerBalances",
4881
+ service: "agentEnhancer",
4882
+ namespace: "agentEnhancer",
4883
+ method: "providerBalances",
4884
+ implementation: "providerBalances",
4885
+ invocation: { kind: "direct" },
4886
+ parameters: [{
4887
+ name: "request",
4888
+ wire: "request",
4889
+ source: "json",
4890
+ codec: codec2("dsh-agent-enhancer#ProviderBalancesRequest")
4891
+ }],
4892
+ result: codec2("dsh-agent-enhancer#ProviderBalances")
2393
4893
  }, ...checkpointClientRemoteInfo.descriptors]
2394
4894
  };
2395
4895
  var agentEnhancerCall = {
@@ -2404,12 +4904,240 @@ var agentEnhancerCall = {
2404
4904
  throw new AuxiliaryError("MODEL_FAILED");
2405
4905
  }
2406
4906
  if (!result.ok) {
2407
- const code = result.error.code === "agent-enhancer/failed" ? result.error.details.code : "MODEL_FAILED";
4907
+ const code = result.error.code === "agent-enhancer/failed" ? auxiliaryCode(result.error.details.code, "MODEL_FAILED") : "MODEL_FAILED";
4908
+ throw new AuxiliaryError(code);
4909
+ }
4910
+ return result.value;
4911
+ }
4912
+ };
4913
+ var agentEnhancerInspectContext = {
4914
+ async invoke(remote, request, signal) {
4915
+ const namespace = Reflect.get(remote, "agentEnhancer");
4916
+ const call = Reflect.get(namespace, "inspectContext");
4917
+ let result;
4918
+ try {
4919
+ result = await call.apply(namespace, [request, signal]);
4920
+ } catch (error) {
4921
+ if (signal?.aborted || error instanceof Error && error.name === "AbortError") throw error;
4922
+ throw new AuxiliaryError("MODEL_FAILED");
4923
+ }
4924
+ if (!result.ok) {
4925
+ const code = result.error.code === "agent-enhancer/failed" ? auxiliaryCode(result.error.details.code, "MODEL_FAILED") : "MODEL_FAILED";
4926
+ throw new AuxiliaryError(code);
4927
+ }
4928
+ return result.value;
4929
+ }
4930
+ };
4931
+ var agentEnhancerCompactContext = {
4932
+ async invoke(remote, request, signal) {
4933
+ const namespace = Reflect.get(remote, "agentEnhancer");
4934
+ const call = Reflect.get(namespace, "compactContext");
4935
+ let result;
4936
+ try {
4937
+ result = await call.apply(namespace, [request, signal]);
4938
+ } catch (error) {
4939
+ if (signal?.aborted || error instanceof Error && error.name === "AbortError") throw error;
4940
+ throw new AuxiliaryError("COMPACT_FAILED");
4941
+ }
4942
+ if (!result.ok) {
4943
+ const code = result.error.code === "agent-enhancer/failed" ? auxiliaryCode(result.error.details.code, "COMPACT_FAILED") : "COMPACT_FAILED";
2408
4944
  throw new AuxiliaryError(code);
2409
4945
  }
2410
4946
  return result.value;
2411
4947
  }
2412
4948
  };
4949
+ var agentEnhancerCheckUpdate = {
4950
+ async invoke(remote) {
4951
+ if (remote === null || remote === void 0 || typeof remote !== "object") {
4952
+ throw new AuxiliaryError("MODEL_FAILED");
4953
+ }
4954
+ let namespace;
4955
+ try {
4956
+ const face = Reflect.get(remote, "agentEnhancer");
4957
+ if (face === null || face === void 0 || typeof face !== "object") {
4958
+ throw new AuxiliaryError("MODEL_FAILED");
4959
+ }
4960
+ namespace = face;
4961
+ } catch (error) {
4962
+ if (error instanceof AuxiliaryError) throw error;
4963
+ throw new AuxiliaryError("MODEL_FAILED");
4964
+ }
4965
+ const call = Reflect.get(namespace, "checkUpdate");
4966
+ if (typeof call !== "function") throw new AuxiliaryError("MODEL_FAILED");
4967
+ let result;
4968
+ try {
4969
+ result = await call.call(namespace);
4970
+ } catch {
4971
+ throw new AuxiliaryError("MODEL_FAILED");
4972
+ }
4973
+ if (!result.ok) {
4974
+ throw new AuxiliaryError("MODEL_FAILED");
4975
+ }
4976
+ return result.value;
4977
+ }
4978
+ };
4979
+ var agentEnhancerUsageSummary = {
4980
+ async invoke(remote, range) {
4981
+ if (remote === null || remote === void 0 || typeof remote !== "object") {
4982
+ throw new AuxiliaryError("MODEL_FAILED");
4983
+ }
4984
+ let namespace;
4985
+ try {
4986
+ const face = Reflect.get(remote, "agentEnhancer");
4987
+ if (face === null || face === void 0 || typeof face !== "object") {
4988
+ throw new AuxiliaryError("MODEL_FAILED");
4989
+ }
4990
+ namespace = face;
4991
+ } catch (error) {
4992
+ if (error instanceof AuxiliaryError) throw error;
4993
+ throw new AuxiliaryError("MODEL_FAILED");
4994
+ }
4995
+ const call = Reflect.get(namespace, "usageSummary");
4996
+ if (typeof call !== "function") throw new AuxiliaryError("MODEL_FAILED");
4997
+ let result;
4998
+ try {
4999
+ result = await call.call(namespace, range);
5000
+ } catch {
5001
+ throw new AuxiliaryError("MODEL_FAILED");
5002
+ }
5003
+ if (!result.ok) throw new AuxiliaryError("MODEL_FAILED");
5004
+ return result.value;
5005
+ }
5006
+ };
5007
+ var agentEnhancerProviderBalances = {
5008
+ async invoke(remote, request = {}) {
5009
+ if (remote === null || remote === void 0 || typeof remote !== "object") {
5010
+ throw new AuxiliaryError("MODEL_FAILED");
5011
+ }
5012
+ let namespace;
5013
+ try {
5014
+ const face = Reflect.get(remote, "agentEnhancer");
5015
+ if (face === null || face === void 0 || typeof face !== "object") {
5016
+ throw new AuxiliaryError("MODEL_FAILED");
5017
+ }
5018
+ namespace = face;
5019
+ } catch (error) {
5020
+ if (error instanceof AuxiliaryError) throw error;
5021
+ throw new AuxiliaryError("MODEL_FAILED");
5022
+ }
5023
+ const call = Reflect.get(namespace, "providerBalances");
5024
+ if (typeof call !== "function") throw new AuxiliaryError("MODEL_FAILED");
5025
+ let result;
5026
+ try {
5027
+ result = await call.call(namespace, request);
5028
+ } catch {
5029
+ throw new AuxiliaryError("MODEL_FAILED");
5030
+ }
5031
+ if (!result.ok) throw new AuxiliaryError("MODEL_FAILED");
5032
+ return result.value;
5033
+ }
5034
+ };
5035
+ var agentEnhancerApplyUpdate = {
5036
+ async invoke(remote) {
5037
+ if (remote === null || remote === void 0 || typeof remote !== "object") {
5038
+ throw new AuxiliaryError("MODEL_FAILED");
5039
+ }
5040
+ let namespace;
5041
+ try {
5042
+ const face = Reflect.get(remote, "agentEnhancer");
5043
+ if (face === null || face === void 0 || typeof face !== "object") {
5044
+ throw new AuxiliaryError("MODEL_FAILED");
5045
+ }
5046
+ namespace = face;
5047
+ } catch (error) {
5048
+ if (error instanceof AuxiliaryError) throw error;
5049
+ throw new AuxiliaryError("MODEL_FAILED");
5050
+ }
5051
+ const call = Reflect.get(namespace, "applyUpdate");
5052
+ if (typeof call !== "function") throw new AuxiliaryError("MODEL_FAILED");
5053
+ let result;
5054
+ try {
5055
+ result = await call.call(namespace);
5056
+ } catch {
5057
+ throw new AuxiliaryError("MODEL_FAILED");
5058
+ }
5059
+ if (!result.ok) {
5060
+ throw new AuxiliaryError("MODEL_FAILED");
5061
+ }
5062
+ return result.value;
5063
+ }
5064
+ };
5065
+
5066
+ // src/client/dsh/provider-balance-chip.tsx
5067
+ var import_react11 = require("react");
5068
+ var import_jsx_runtime12 = require("react/jsx-runtime");
5069
+ function ProviderBalanceChip(props) {
5070
+ const { source, t, load } = props;
5071
+ const [state, setState] = (0, import_react11.useState)({ kind: "loading" });
5072
+ const [busy, setBusy] = (0, import_react11.useState)(false);
5073
+ const refresh = (0, import_react11.useCallback)(async (force) => {
5074
+ setBusy(true);
5075
+ try {
5076
+ const snapshot = await load(force);
5077
+ setState({ kind: "ready", snapshot });
5078
+ } catch {
5079
+ setState({ kind: "error" });
5080
+ } finally {
5081
+ setBusy(false);
5082
+ }
5083
+ }, [load]);
5084
+ (0, import_react11.useEffect)(() => {
5085
+ void refresh(false);
5086
+ }, [refresh]);
5087
+ let primary = t("providerBalanceLoading");
5088
+ let detail;
5089
+ if (state.kind === "error") {
5090
+ primary = t("providerBalanceUnavailable");
5091
+ } else if (state.kind === "ready") {
5092
+ const snapshot = state.snapshot;
5093
+ if (snapshot.balance !== void 0) {
5094
+ primary = t("providerBalanceLabel", { amount: snapshot.balance.total });
5095
+ if (source === "account") {
5096
+ detail = t("providerBalanceDetail", {
5097
+ granted: snapshot.balance.granted,
5098
+ toppedUp: snapshot.balance.toppedUp
5099
+ });
5100
+ }
5101
+ if (snapshot.balance.stale === true) {
5102
+ detail = detail === void 0 ? t("providerBalanceStale") : `${detail} \xB7 ${t("providerBalanceStale")}`;
5103
+ }
5104
+ } else {
5105
+ switch (snapshot.status) {
5106
+ case "no-key":
5107
+ primary = t("providerBalanceNoKey");
5108
+ break;
5109
+ case "signed-out":
5110
+ primary = t("providerBalanceSignedOut");
5111
+ break;
5112
+ case "unavailable":
5113
+ case "ready":
5114
+ primary = t("providerBalanceUnavailable");
5115
+ break;
5116
+ default: {
5117
+ const _exhaustive = snapshot.status;
5118
+ primary = _exhaustive;
5119
+ }
5120
+ }
5121
+ }
5122
+ }
5123
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
5124
+ "button",
5125
+ {
5126
+ type: "button",
5127
+ className: css_module_default.providerBalanceChip,
5128
+ "data-provider-balance": source,
5129
+ "aria-busy": busy,
5130
+ title: t("providerBalanceRefreshHint"),
5131
+ onClick: () => {
5132
+ void refresh(true);
5133
+ },
5134
+ children: [
5135
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: css_module_default.providerBalancePrimary, children: primary }),
5136
+ detail !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: css_module_default.providerBalanceDetail, children: detail })
5137
+ ]
5138
+ }
5139
+ );
5140
+ }
2413
5141
 
2414
5142
  // src/host/checkpoint/availability.ts
2415
5143
  var CONVERSATION_SOFT = /* @__PURE__ */ new Set([
@@ -2613,11 +5341,11 @@ var RollbackController = class {
2613
5341
 
2614
5342
  // src/client/rollback/modal-host.tsx
2615
5343
  var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
2616
- var import_react5 = require("react");
5344
+ var import_react12 = require("react");
2617
5345
 
2618
5346
  // src/client/rollback/preview.tsx
2619
5347
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
2620
- var import_jsx_runtime6 = require("react/jsx-runtime");
5348
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2621
5349
  var UNAVAILABLE_KEYS = {
2622
5350
  "checkpoint-not-found": "rollbackUnavailableCheckpoint",
2623
5351
  "incomplete-checkpoint": "rollbackUnavailableIncomplete",
@@ -2646,9 +5374,9 @@ var CONFLICT_KEYS = {
2646
5374
  function RollbackPreview({ active, t }) {
2647
5375
  if (active.status === "loading" || active.status === "executing") {
2648
5376
  const loadingKey = active.status === "loading" ? "rollbackLoading" : active.operation === "undo" ? "rollbackUndoRestoring" : "rollbackRestoring";
2649
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "status", children: t(loadingKey) });
5377
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "status", children: t(loadingKey) });
2650
5378
  }
2651
- if (active.status === "error") return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { role: "alert", children: t("rollbackFailed") });
5379
+ if (active.status === "error") return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { role: "alert", children: t("rollbackFailed") });
2652
5380
  const preview = active.preview;
2653
5381
  if (preview === void 0) return null;
2654
5382
  const hardUnavailable = blockingUnavailable(preview.unavailable, "conversation", {
@@ -2657,38 +5385,38 @@ function RollbackPreview({ active, t }) {
2657
5385
  const filesLimited = active.operation !== "undo" && blockingUnavailable(preview.unavailable, "conversation-and-files", {
2658
5386
  trackedFiles: preview.files.length
2659
5387
  }).length > hardUnavailable.length;
2660
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_dsh_client_ui_primitives5.MenuSurface, { className: css_module_default.rollbackPreview, children: [
2661
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackMessages"), children: [
2662
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: t("rollbackMessages") }),
2663
- preview.messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: t("rollbackNoMessages") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: css_module_default.rollbackList, children: preview.messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: css_module_default.rollbackMessage, children: [
2664
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: css_module_default.rollbackMeta, children: [
5388
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_dsh_client_ui_primitives5.MenuSurface, { className: css_module_default.rollbackPreview, children: [
5389
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackMessages"), children: [
5390
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackMessages") }),
5391
+ preview.messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("rollbackNoMessages") }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.messages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: css_module_default.rollbackMessage, children: [
5392
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: css_module_default.rollbackMeta, children: [
2665
5393
  message.type,
2666
5394
  " \xB7 ",
2667
5395
  message.seq
2668
5396
  ] }),
2669
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: message.text })
5397
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: message.text })
2670
5398
  ] }, message.seq)) })
2671
5399
  ] }),
2672
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFiles"), children: [
2673
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: t("rollbackFiles") }),
2674
- preview.files.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: t("rollbackNoFiles") }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: css_module_default.rollbackList, children: preview.files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: css_module_default.rollbackFile, children: [
2675
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: file.path }),
2676
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: css_module_default.rollbackMeta, children: t(`rollbackFile_${file.change}`) })
5400
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFiles"), children: [
5401
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackFiles") }),
5402
+ preview.files.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("rollbackNoFiles") }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.files.map((file) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { className: css_module_default.rollbackFile, children: [
5403
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: file.path }),
5404
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: css_module_default.rollbackMeta, children: t(`rollbackFile_${file.change}`) })
2677
5405
  ] }, file.path)) })
2678
5406
  ] }),
2679
- hardUnavailable.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackGaps"), children: [
2680
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: t("rollbackGaps") }),
2681
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: css_module_default.rollbackList, children: hardUnavailable.map((reason) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { children: t(UNAVAILABLE_KEYS[reason]) }, reason)) })
5407
+ hardUnavailable.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackGaps"), children: [
5408
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackGaps") }),
5409
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: hardUnavailable.map((reason) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { children: t(UNAVAILABLE_KEYS[reason]) }, reason)) })
2682
5410
  ] }),
2683
- !filesLimited ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFilesLimited"), children: [
2684
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: t("rollbackFilesLimited") }),
2685
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: t("rollbackFilesLimitedHint") })
5411
+ !filesLimited ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackFilesLimited"), children: [
5412
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackFilesLimited") }),
5413
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("rollbackFilesLimitedHint") })
2686
5414
  ] }),
2687
- preview.conflicts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackConflicts"), children: [
2688
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { children: t("rollbackConflicts") }),
2689
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: css_module_default.rollbackList, children: preview.conflicts.map((conflict) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { children: [
2690
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: conflict.path }),
2691
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: css_module_default.rollbackConflict, children: t(CONFLICT_KEYS[conflict.reason]) })
5415
+ preview.conflicts.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: css_module_default.rollbackSection, "aria-label": t("rollbackConflicts"), children: [
5416
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("rollbackConflicts") }),
5417
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: css_module_default.rollbackList, children: preview.conflicts.map((conflict) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { children: [
5418
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: conflict.path }),
5419
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: css_module_default.rollbackConflict, children: t(CONFLICT_KEYS[conflict.reason]) })
2692
5420
  ] }, `${conflict.path}:${conflict.reason}`)) })
2693
5421
  ] })
2694
5422
  ] });
@@ -2716,9 +5444,9 @@ function rollbackModalCopy(operation, t, turn, scope) {
2716
5444
  }
2717
5445
 
2718
5446
  // src/client/rollback/modal-host.tsx
2719
- var import_jsx_runtime7 = require("react/jsx-runtime");
5447
+ var import_jsx_runtime14 = require("react/jsx-runtime");
2720
5448
  function RollbackModalHost(props) {
2721
- const snapshot = (0, import_react5.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
5449
+ const snapshot = (0, import_react12.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
2722
5450
  const active = snapshot.active;
2723
5451
  const trackedFiles = active?.preview?.files.length ?? 0;
2724
5452
  const undoScope = scopeLabel(active?.scope ?? active?.preview?.scope);
@@ -2733,7 +5461,7 @@ function RollbackModalHost(props) {
2733
5461
  );
2734
5462
  const ready = active?.status === "ready";
2735
5463
  const executing = active?.status === "executing";
2736
- (0, import_react5.useEffect)(() => {
5464
+ (0, import_react12.useEffect)(() => {
2737
5465
  if (active === null) return;
2738
5466
  const dialog = document.querySelector(`.${css_module_default.rollbackDialog}`);
2739
5467
  const parent = dialog?.parentElement;
@@ -2763,7 +5491,7 @@ function RollbackModalHost(props) {
2763
5491
  if (active.status !== "ready" || executing) return;
2764
5492
  void props.rollback.confirm(props.inputActions, scope);
2765
5493
  };
2766
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
5494
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2767
5495
  import_dsh_client_ui_primitives6.Modal,
2768
5496
  {
2769
5497
  open: true,
@@ -2773,8 +5501,8 @@ function RollbackModalHost(props) {
2773
5501
  className: css_module_default.rollbackDialog,
2774
5502
  contentClassName: css_module_default.rollbackContent,
2775
5503
  onClose: requestClose,
2776
- footer: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2777
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
5504
+ footer: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
5505
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2778
5506
  import_dsh_client_ui_primitives6.Button,
2779
5507
  {
2780
5508
  type: "button",
@@ -2783,7 +5511,7 @@ function RollbackModalHost(props) {
2783
5511
  children: props.t("rollbackCancel")
2784
5512
  }
2785
5513
  ),
2786
- active.operation === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
5514
+ active.operation === "undo" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2787
5515
  import_dsh_client_ui_primitives6.Button,
2788
5516
  {
2789
5517
  type: "button",
@@ -2794,8 +5522,8 @@ function RollbackModalHost(props) {
2794
5522
  },
2795
5523
  children: executing ? modal.executing : modal.confirm
2796
5524
  }
2797
- ) : executing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", disabled: true, children: active.scope === "conversation" ? modal.executingConversation : modal.executing }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2798
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
5525
+ ) : executing ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", disabled: true, children: active.scope === "conversation" ? modal.executingConversation : modal.executing }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
5526
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2799
5527
  import_dsh_client_ui_primitives6.Button,
2800
5528
  {
2801
5529
  type: "button",
@@ -2807,7 +5535,7 @@ function RollbackModalHost(props) {
2807
5535
  children: modal.confirmConversation
2808
5536
  }
2809
5537
  ),
2810
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
5538
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2811
5539
  import_dsh_client_ui_primitives6.Button,
2812
5540
  {
2813
5541
  type: "button",
@@ -2820,7 +5548,7 @@ function RollbackModalHost(props) {
2820
5548
  )
2821
5549
  ] })
2822
5550
  ] }),
2823
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(RollbackPreview, { active, t: props.t })
5551
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RollbackPreview, { active, t: props.t })
2824
5552
  }
2825
5553
  );
2826
5554
  }
@@ -3262,14 +5990,14 @@ var RollbackUndoTipStore = class {
3262
5990
 
3263
5991
  // src/client/rollback/user-node.tsx
3264
5992
  var import_dsh_client_ui_primitives9 = require("@deepseek-ai/dsh-client-ui-primitives");
3265
- var import_react7 = require("react");
5993
+ var import_react14 = require("react");
3266
5994
 
3267
5995
  // src/client/rollback/actions.tsx
3268
5996
  var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
3269
- var import_react6 = require("react");
3270
- var import_jsx_runtime8 = require("react/jsx-runtime");
5997
+ var import_react13 = require("react");
5998
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3271
5999
  function RollbackMessageActions(props) {
3272
- const snapshot = (0, import_react6.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
6000
+ const snapshot = (0, import_react13.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot);
3273
6001
  const session = props.useSession((state) => state);
3274
6002
  const turn = props.turn;
3275
6003
  if (!snapshot.enabled) return null;
@@ -3277,7 +6005,7 @@ function RollbackMessageActions(props) {
3277
6005
  const disabledReason = canExecute === false ? "rollbackUnavailablePermission" : session.running ? "rollbackUnavailableRunning" : turn.status !== "closed" ? "rollbackTurnOpen" : turn.start === void 0 ? "rollbackTurnStartMissing" : null;
3278
6006
  const entryLabel = props.t("rollbackAction");
3279
6007
  const entryTooltip = disabledReason === null ? entryLabel : props.t(disabledReason);
3280
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: entryTooltip, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
6008
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_dsh_client_ui_primitives8.Tooltip, { label: entryTooltip, side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3281
6009
  "button",
3282
6010
  {
3283
6011
  type: "button",
@@ -3289,7 +6017,7 @@ function RollbackMessageActions(props) {
3289
6017
  onClick: () => {
3290
6018
  if (disabledReason === null) props.rollback.open(turn.turn, "rollback");
3291
6019
  },
3292
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(UndoIcon, {})
6020
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(UndoIcon, {})
3293
6021
  }
3294
6022
  ) });
3295
6023
  }
@@ -3311,21 +6039,21 @@ function contentParts(content) {
3311
6039
  }
3312
6040
 
3313
6041
  // src/client/rollback/user-node.tsx
3314
- var import_jsx_runtime9 = require("react/jsx-runtime");
6042
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3315
6043
  function turnOf2(location) {
3316
6044
  return location.kind === "turn" || location.kind === "step" ? location.turn : null;
3317
6045
  }
3318
6046
  function UserCopyAction({ text: text2, tChat }) {
3319
- const [copied, setCopied] = (0, import_react7.useState)(false);
3320
- const copyPending = (0, import_react7.useRef)(false);
3321
- const copyTimer = (0, import_react7.useRef)(null);
3322
- const copyEpoch = (0, import_react7.useRef)(0);
3323
- (0, import_react7.useEffect)(() => () => {
6047
+ const [copied, setCopied] = (0, import_react14.useState)(false);
6048
+ const copyPending = (0, import_react14.useRef)(false);
6049
+ const copyTimer = (0, import_react14.useRef)(null);
6050
+ const copyEpoch = (0, import_react14.useRef)(0);
6051
+ (0, import_react14.useEffect)(() => () => {
3324
6052
  copyEpoch.current += 1;
3325
6053
  copyPending.current = false;
3326
6054
  if (copyTimer.current !== null) window.clearTimeout(copyTimer.current);
3327
6055
  }, []);
3328
- const onCopy = (0, import_react7.useCallback)(() => {
6056
+ const onCopy = (0, import_react14.useCallback)(() => {
3329
6057
  if (copied || copyPending.current) return;
3330
6058
  const epoch = copyEpoch.current;
3331
6059
  copyPending.current = true;
@@ -3340,45 +6068,45 @@ function UserCopyAction({ text: text2, tChat }) {
3340
6068
  }, 1e3);
3341
6069
  });
3342
6070
  }, [copied, text2]);
3343
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives9.Tooltip, { label: copied ? tChat("copied") : tChat("copy"), side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
6071
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_dsh_client_ui_primitives9.Tooltip, { label: copied ? tChat("copied") : tChat("copy"), side: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3344
6072
  "button",
3345
6073
  {
3346
6074
  type: "button",
3347
6075
  className: css_module_default.userMessageAction,
3348
6076
  "aria-label": copied ? tChat("copied") : tChat("copy"),
3349
6077
  onClick: onCopy,
3350
- children: copied ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives9.IconCheckOutlineRegular, {}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives9.IconCopyOutlineRegular, {})
6078
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_dsh_client_ui_primitives9.IconCheckOutlineRegular, {}) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_dsh_client_ui_primitives9.IconCopyOutlineRegular, {})
3351
6079
  }
3352
6080
  ) });
3353
6081
  }
3354
6082
  function RollbackUserNode(props) {
3355
6083
  const data = props.node.data;
3356
6084
  const messageId = data.id;
3357
- const parts = (0, import_react7.useMemo)(() => contentParts(data.content), [data.content]);
3358
- const prepared = (0, import_react7.useMemo)(() => ({
6085
+ const parts = (0, import_react14.useMemo)(() => contentParts(data.content), [data.content]);
6086
+ const prepared = (0, import_react14.useMemo)(() => ({
3359
6087
  text: parts.text,
3360
6088
  attachments: parts.attachments,
3361
6089
  extraBlocks: parts.rest,
3362
6090
  ...data.referenceLabels === void 0 ? {} : { referenceLabels: data.referenceLabels }
3363
6091
  }), [parts, data.referenceLabels]);
3364
- const facts = (0, import_react7.useMemo)(() => ({
6092
+ const facts = (0, import_react14.useMemo)(() => ({
3365
6093
  ...data.referenceLabels === void 0 ? {} : { sessionLabels: data.referenceLabels },
3366
6094
  ...data.skillNames === void 0 ? {} : { skillNames: data.skillNames }
3367
6095
  }), [data.referenceLabels, data.skillNames]);
3368
6096
  const turn = turnOf2(props.node.location);
3369
6097
  const isMarker = isRollbackMarkerMessage(data.source, messageId);
3370
6098
  const rollbackTurn = turnFromRollbackMarkerId(messageId) ?? turn?.turn;
3371
- const rollbackEnabled = (0, import_react7.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot).enabled;
3372
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.userMessageRow, children: [
6099
+ const rollbackEnabled = (0, import_react14.useSyncExternalStore)(props.rollback.subscribe, props.rollback.getSnapshot).enabled;
6100
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: css_module_default.userMessageRow, children: [
3373
6101
  props.renderFactorySlot("conversation.chat.user.content", {
3374
6102
  content: prepared,
3375
6103
  loadImage: props.loadImage,
3376
6104
  facts,
3377
6105
  interactive: true
3378
6106
  }),
3379
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: css_module_default.userMessageActions, "data-clock": "start", children: [
3380
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(UserCopyAction, { text: prepared.text, tChat: props.tChat }),
3381
- rollbackEnabled && turn !== null && rollbackTurn !== void 0 && !isMarker ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
6107
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: css_module_default.userMessageActions, "data-clock": "start", children: [
6108
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UserCopyAction, { text: prepared.text, tChat: props.tChat }),
6109
+ rollbackEnabled && turn !== null && rollbackTurn !== void 0 && !isMarker ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3382
6110
  RollbackMessageActions,
3383
6111
  {
3384
6112
  rollback: props.rollback,
@@ -3393,22 +6121,90 @@ function RollbackUserNode(props) {
3393
6121
  }
3394
6122
 
3395
6123
  // src/client/index.ts
3396
- var inject = ["remote", "remote.session", "remote.pluginInventory", "configForms", "locale", "slots"];
6124
+ var inject = [
6125
+ "remote",
6126
+ "remote.session",
6127
+ "remote.pluginInventory",
6128
+ "configForms",
6129
+ "locale",
6130
+ "slots",
6131
+ "sidebarRightTabs",
6132
+ "sidebarRight"
6133
+ ];
3397
6134
  function apply(ctx) {
3398
6135
  ctx.effect(installCss);
3399
6136
  ctx.effect(() => ctx.locale.register("agent-enhancer", agentLocales));
3400
6137
  const t = ctx.locale.bind("agent-enhancer");
3401
6138
  const form = new AcceptedSettingsForm(ctx.configForms.get("agent-enhancer"));
3402
6139
  const catalogLoaders = { ...catalogLoadersFromRemote(ctx.remote) };
6140
+ let agentEnhancerRemote;
6141
+ const agentRemoteWaiters = [];
3403
6142
  const adoptCatalogLoaders = (remote) => {
3404
6143
  const next = catalogLoadersFromRemote(remote);
3405
6144
  if (next.sessionModelCatalog) catalogLoaders.sessionModelCatalog = next.sessionModelCatalog;
3406
6145
  if (next.hostListCatalog) catalogLoaders.hostListCatalog = next.hostListCatalog;
3407
6146
  };
6147
+ const readAgentEnhancerFace = (mountedCtx) => {
6148
+ try {
6149
+ const injected = Reflect.get(mountedCtx, "remote.agentEnhancer");
6150
+ if (injected !== null && injected !== void 0 && typeof injected === "object") {
6151
+ return injected;
6152
+ }
6153
+ } catch {
6154
+ }
6155
+ try {
6156
+ const nested = Reflect.get(mountedCtx.remote, "agentEnhancer");
6157
+ if (nested !== null && nested !== void 0 && typeof nested === "object") {
6158
+ return nested;
6159
+ }
6160
+ } catch {
6161
+ }
6162
+ return void 0;
6163
+ };
6164
+ const adoptAgentRemote = (mountedCtx) => {
6165
+ adoptCatalogLoaders(mountedCtx.remote);
6166
+ const face = readAgentEnhancerFace(mountedCtx);
6167
+ if (face === void 0) return;
6168
+ const remote = { agentEnhancer: face };
6169
+ agentEnhancerRemote = remote;
6170
+ while (agentRemoteWaiters.length > 0) agentRemoteWaiters.shift()?.(remote);
6171
+ };
6172
+ const withAgentRemote = async (run) => {
6173
+ if (agentEnhancerRemote !== void 0) return run(agentEnhancerRemote);
6174
+ const remote = await new Promise((resolve) => {
6175
+ agentRemoteWaiters.push(resolve);
6176
+ });
6177
+ return run(remote);
6178
+ };
3408
6179
  const loadCatalog = () => Promise.resolve().then(
3409
6180
  () => loadDesktopModelCatalog(catalogLoaders)
3410
6181
  );
3411
- const SettingsTab = (props) => (0, import_react8.createElement)(PluginSettings, { form: props.form, t: props.t, loadCatalog });
6182
+ const checkUpdate = () => withAgentRemote((remote) => agentEnhancerCheckUpdate.invoke(remote));
6183
+ const applyUpdate = () => withAgentRemote((remote) => agentEnhancerApplyUpdate.invoke(remote));
6184
+ const loadUsage = (range) => withAgentRemote(
6185
+ (remote) => agentEnhancerUsageSummary.invoke(remote, range)
6186
+ );
6187
+ const desktopLocale = () => {
6188
+ try {
6189
+ return ctx.locale.getLocale().active;
6190
+ } catch {
6191
+ return "zh-CN";
6192
+ }
6193
+ };
6194
+ const loadProviderSnapshot = (source) => async (force = false) => {
6195
+ const all = await withAgentRemote((remote) => agentEnhancerProviderBalances.invoke(remote, {
6196
+ force,
6197
+ locale: desktopLocale()
6198
+ }));
6199
+ return source === "account" ? all.account : all.apiKey;
6200
+ };
6201
+ const SettingsTab = (props) => (0, import_react15.createElement)(PluginSettings, {
6202
+ form: props.form,
6203
+ t: props.t,
6204
+ loadCatalog,
6205
+ checkUpdate,
6206
+ applyUpdate
6207
+ });
3412
6208
  ctx.effect(() => ctx.slots.inject("settings.plugins.tab", () => ctx.slots.register({
3413
6209
  name: "settings.plugins.tab",
3414
6210
  id: "agent-enhancer",
@@ -3417,6 +6213,24 @@ function apply(ctx) {
3417
6213
  locale: "agent-enhancer",
3418
6214
  inject: () => ({ form })
3419
6215
  }, SettingsTab)));
6216
+ const AccountBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
6217
+ source: "account",
6218
+ t,
6219
+ load: loadProviderSnapshot("account")
6220
+ });
6221
+ const ApiKeyBalanceChip = () => (0, import_react15.createElement)(ProviderBalanceChip, {
6222
+ source: "api-key",
6223
+ t,
6224
+ load: loadProviderSnapshot("api-key")
6225
+ });
6226
+ ctx.effect(() => ctx.slots.inject("settings.models.provider-card", () => ctx.slots.register({
6227
+ name: "settings.models.provider-card",
6228
+ key: PROVIDER_BALANCE_ACCOUNT_KEY
6229
+ }, AccountBalanceChip)));
6230
+ ctx.effect(() => ctx.slots.inject("settings.models.provider-card", () => ctx.slots.register({
6231
+ name: "settings.models.provider-card",
6232
+ key: PROVIDER_BALANCE_API_KEY_KEY
6233
+ }, ApiKeyBalanceChip)));
3420
6234
  const hints = new OverlapHintStore();
3421
6235
  ctx.effect(() => {
3422
6236
  let active = true;
@@ -3483,6 +6297,115 @@ function apply(ctx) {
3483
6297
  locale: "agent-enhancer",
3484
6298
  inject: (sessionId) => ({ session: sessionFor(sessionId), hints })
3485
6299
  }, AgentOverlay));
6300
+ const contextInspectEnabled = () => resolveSettings(form.getSnapshot().value).contextInspectEnabled;
6301
+ const tContext = mountedCtx.locale.bind("agent-enhancer");
6302
+ const inspectContext = (sessionId, category, signal) => agentEnhancerInspectContext.invoke(mountedCtx.remote, { sessionId, category }, signal);
6303
+ const compactContext = (sessionId, signal) => agentEnhancerCompactContext.invoke(mountedCtx.remote, { sessionId }, signal);
6304
+ const ContextDock = (props) => (0, import_react15.createElement)(ContextInspectDock, {
6305
+ ...props,
6306
+ enabled: contextInspectEnabled,
6307
+ open: (category) => {
6308
+ openContextInspectTab(mountedCtx.sidebarRight, {
6309
+ sessionId: props.sessionId,
6310
+ category
6311
+ });
6312
+ },
6313
+ t: tContext
6314
+ });
6315
+ const BillDock = (props) => (0, import_react15.createElement)(UsageMeterDock, {
6316
+ ...props,
6317
+ open: () => {
6318
+ openUsageTab(mountedCtx.sidebarRight);
6319
+ },
6320
+ t: tContext
6321
+ });
6322
+ const ContextRightTab = (props) => (0, import_react15.createElement)(ContextInspectRightTab, {
6323
+ ...props,
6324
+ inspect: inspectContext,
6325
+ compact: compactContext,
6326
+ t: tContext
6327
+ });
6328
+ const ContextRightTitle = (props) => (0, import_react15.createElement)(
6329
+ ContextInspectRightTabTitle,
6330
+ { ...props, t: tContext }
6331
+ );
6332
+ const BillRightTab = (props) => (0, import_react15.createElement)(UsageRightTab, {
6333
+ ...props,
6334
+ loadUsage,
6335
+ t: tContext
6336
+ });
6337
+ const BillRightTitle = (props) => (0, import_react15.createElement)(
6338
+ UsageRightTabTitle,
6339
+ { ...props, t: tContext }
6340
+ );
6341
+ mountedCtx.effect(() => {
6342
+ const disposers = [
6343
+ mountedCtx.sidebarRightTabs.register({
6344
+ id: USAGE_TAB_ID,
6345
+ kind: USAGE_TAB_KIND,
6346
+ priority: "extension",
6347
+ title: () => tContext("usageTitle")
6348
+ }),
6349
+ mountedCtx.slots.inject("sidebar.right.pane.tab", () => mountedCtx.slots.register({
6350
+ name: "sidebar.right.pane.tab",
6351
+ key: USAGE_TAB_ID,
6352
+ locale: "agent-enhancer"
6353
+ }, BillRightTab)),
6354
+ mountedCtx.slots.inject("sidebar.right.pane.tab.title", () => mountedCtx.slots.register({
6355
+ name: "sidebar.right.pane.tab.title",
6356
+ key: USAGE_TAB_ID,
6357
+ locale: "agent-enhancer"
6358
+ }, BillRightTitle)),
6359
+ mountedCtx.slots.inject("conversation.composer.dock", () => mountedCtx.slots.register({
6360
+ name: "conversation.composer.dock",
6361
+ id: "agent-enhancer-usage",
6362
+ order: 40,
6363
+ locale: "agent-enhancer"
6364
+ }, BillDock))
6365
+ ];
6366
+ return () => {
6367
+ while (disposers.length > 0) disposers.pop()?.();
6368
+ };
6369
+ });
6370
+ mountedCtx.effect(() => {
6371
+ const disposers = [];
6372
+ const synchronize = () => {
6373
+ const enabled = contextInspectEnabled();
6374
+ if (!enabled) {
6375
+ while (disposers.length > 0) disposers.pop()?.();
6376
+ return;
6377
+ }
6378
+ if (disposers.length > 0) return;
6379
+ disposers.push(mountedCtx.sidebarRightTabs.register({
6380
+ id: CONTEXT_INSPECT_TAB_ID,
6381
+ kind: CONTEXT_INSPECT_TAB_KIND,
6382
+ priority: "extension",
6383
+ title: () => tContext("contextInspectDetailTitle")
6384
+ }));
6385
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab", () => mountedCtx.slots.register({
6386
+ name: "sidebar.right.pane.tab",
6387
+ key: CONTEXT_INSPECT_TAB_ID,
6388
+ locale: "agent-enhancer"
6389
+ }, ContextRightTab)));
6390
+ disposers.push(mountedCtx.slots.inject("sidebar.right.pane.tab.title", () => mountedCtx.slots.register({
6391
+ name: "sidebar.right.pane.tab.title",
6392
+ key: CONTEXT_INSPECT_TAB_ID,
6393
+ locale: "agent-enhancer"
6394
+ }, ContextRightTitle)));
6395
+ disposers.push(mountedCtx.slots.inject("conversation.composer.dock", () => mountedCtx.slots.register({
6396
+ name: "conversation.composer.dock",
6397
+ id: "agent-enhancer-context",
6398
+ order: 50,
6399
+ locale: "agent-enhancer"
6400
+ }, ContextDock)));
6401
+ };
6402
+ const unsubscribe = form.subscribe(synchronize);
6403
+ synchronize();
6404
+ return () => {
6405
+ unsubscribe();
6406
+ while (disposers.length > 0) disposers.pop()?.();
6407
+ };
6408
+ });
3486
6409
  };
3487
6410
  const applyRollbackMounted = (mountedCtx) => {
3488
6411
  const rollbackRemote = {
@@ -3516,11 +6439,11 @@ function apply(ctx) {
3516
6439
  }
3517
6440
  return rollback;
3518
6441
  };
3519
- const rollbackUserNode = (props) => (0, import_react8.createElement)(
6442
+ const rollbackUserNode = (props) => (0, import_react15.createElement)(
3520
6443
  RollbackUserNode,
3521
6444
  { ...props, rollback: rollbackFor(props.sessionId), tEnhancer, tChat }
3522
6445
  );
3523
- const rollbackOverlay = (props) => (0, import_react8.createElement)(
6446
+ const rollbackOverlay = (props) => (0, import_react15.createElement)(
3524
6447
  RollbackModalHost,
3525
6448
  { rollback: rollbackFor(props.sessionId), t: tEnhancer, inputActions: props.inputActions }
3526
6449
  );
@@ -3576,7 +6499,7 @@ function apply(ctx) {
3576
6499
  name: "agent-enhancer-mounted",
3577
6500
  inject: ["remote.agentEnhancer"],
3578
6501
  apply: (mountedCtx) => {
3579
- adoptCatalogLoaders(mountedCtx.remote);
6502
+ adoptAgentRemote(mountedCtx);
3580
6503
  applyAgentMounted(mountedCtx);
3581
6504
  }
3582
6505
  });