flavor-code 1.3.11 → 1.3.12

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.
@@ -12,7 +12,7 @@ import {
12
12
  redactConfig,
13
13
  setProjectMcpServerDisabled,
14
14
  updateProtectedFile
15
- } from "./chunk-IG4Z23CL.js";
15
+ } from "./chunk-JFKRX2KG.js";
16
16
  import {
17
17
  AuditLogger,
18
18
  appendUsageLog,
@@ -1082,6 +1082,231 @@ function packageVersion() {
1082
1082
  throw new Error("package.json with a version field was not found");
1083
1083
  }
1084
1084
 
1085
+ // src/ui/char-width.ts
1086
+ function charWidth(codePoint) {
1087
+ if (codePoint === 8203 || // ZERO WIDTH SPACE
1088
+ codePoint === 8204 || // ZERO WIDTH NON-JOINER
1089
+ codePoint === 8205 || // ZERO WIDTH JOINER
1090
+ codePoint === 65279 || // BOM / ZERO WIDTH NO-BREAK SPACE
1091
+ codePoint >= 768 && codePoint <= 879 || // Combining Diacritical Marks
1092
+ codePoint >= 1155 && codePoint <= 1161 || // Cyrillic combining marks
1093
+ codePoint >= 1425 && codePoint <= 1469 || // Hebrew combining marks
1094
+ codePoint >= 1552 && codePoint <= 1562 || // Arabic combining marks
1095
+ codePoint >= 1611 && codePoint <= 1631 || // Arabic combining marks
1096
+ codePoint >= 1648 && codePoint <= 1648 || // Arabic combining marks
1097
+ codePoint >= 1750 && codePoint <= 1756 || // Arabic combining marks
1098
+ codePoint >= 1759 && codePoint <= 1764 || // Arabic combining marks
1099
+ codePoint >= 1767 && codePoint <= 1768 || // Arabic combining marks
1100
+ codePoint >= 1770 && codePoint <= 1773 || // Arabic combining marks
1101
+ codePoint >= 1809 && codePoint <= 1809 || // Syriac combining marks
1102
+ codePoint >= 1840 && codePoint <= 1866 || // Syriac combining marks
1103
+ codePoint >= 1958 && codePoint <= 1968 || // Thaana combining marks
1104
+ codePoint >= 2304 && codePoint <= 2306 || // Devanagari combining marks
1105
+ codePoint >= 2362 && codePoint <= 2362 || // Devanagari combining marks
1106
+ codePoint >= 2364 && codePoint <= 2364 || // Devanagari combining marks
1107
+ codePoint >= 2369 && codePoint <= 2376 || // Devanagari combining marks
1108
+ codePoint >= 2381 && codePoint <= 2381 || // Devanagari combining marks
1109
+ codePoint >= 2385 && codePoint <= 2391 || // Devanagari combining marks
1110
+ codePoint >= 2402 && codePoint <= 2403 || // Devanagari combining marks
1111
+ codePoint >= 2433 && codePoint <= 2433 || // Bengali combining marks
1112
+ codePoint >= 2492 && codePoint <= 2492 || // Bengali combining marks
1113
+ codePoint >= 2497 && codePoint <= 2500 || // Bengali combining marks
1114
+ codePoint >= 2509 && codePoint <= 2509 || // Bengali combining marks
1115
+ codePoint >= 2530 && codePoint <= 2531 || // Bengali combining marks
1116
+ codePoint >= 2561 && codePoint <= 2562 || // Gurmukhi combining marks
1117
+ codePoint >= 2620 && codePoint <= 2620 || // Gurmukhi combining marks
1118
+ codePoint >= 2625 && codePoint <= 2626 || // Gurmukhi combining marks
1119
+ codePoint >= 2631 && codePoint <= 2632 || // Gurmukhi combining marks
1120
+ codePoint >= 2635 && codePoint <= 2637 || // Gurmukhi combining marks
1121
+ codePoint >= 2672 && codePoint <= 2673 || // Gurmukhi combining marks
1122
+ codePoint >= 2689 && codePoint <= 2690 || // Gujarati combining marks
1123
+ codePoint >= 2748 && codePoint <= 2748 || // Gujarati combining marks
1124
+ codePoint >= 2753 && codePoint <= 2757 || // Gujarati combining marks
1125
+ codePoint >= 2759 && codePoint <= 2760 || // Gujarati combining marks
1126
+ codePoint >= 2765 && codePoint <= 2765 || // Gujarati combining marks
1127
+ codePoint >= 2786 && codePoint <= 2787 || // Gujarati combining marks
1128
+ codePoint >= 2817 && codePoint <= 2817 || // Oriya combining marks
1129
+ codePoint >= 2876 && codePoint <= 2876 || // Oriya combining marks
1130
+ codePoint >= 2879 && codePoint <= 2879 || // Oriya combining marks
1131
+ codePoint >= 2881 && codePoint <= 2883 || // Oriya combining marks
1132
+ codePoint >= 2893 && codePoint <= 2893 || // Oriya combining marks
1133
+ codePoint >= 2902 && codePoint <= 2902 || // Oriya combining marks
1134
+ codePoint >= 2946 && codePoint <= 2946 || // Tamil combining marks
1135
+ codePoint >= 3008 && codePoint <= 3008 || // Tamil combining marks
1136
+ codePoint >= 3021 && codePoint <= 3021 || // Tamil combining marks
1137
+ codePoint >= 3134 && codePoint <= 3136 || // Telugu combining marks
1138
+ codePoint >= 3142 && codePoint <= 3144 || // Telugu combining marks
1139
+ codePoint >= 3146 && codePoint <= 3149 || // Telugu combining marks
1140
+ codePoint >= 3157 && codePoint <= 3158 || // Telugu combining marks
1141
+ codePoint >= 3260 && codePoint <= 3260 || // Kannada combining marks
1142
+ codePoint >= 3263 && codePoint <= 3263 || // Kannada combining marks
1143
+ codePoint >= 3270 && codePoint <= 3270 || // Kannada combining marks
1144
+ codePoint >= 3276 && codePoint <= 3277 || // Kannada combining marks
1145
+ codePoint >= 3298 && codePoint <= 3299 || // Kannada combining marks
1146
+ codePoint >= 3393 && codePoint <= 3395 || // Malayalam combining marks
1147
+ codePoint >= 3405 && codePoint <= 3405 || // Malayalam combining marks
1148
+ codePoint >= 3530 && codePoint <= 3530 || // Sinhala combining marks
1149
+ codePoint >= 3538 && codePoint <= 3540 || // Sinhala combining marks
1150
+ codePoint >= 3542 && codePoint <= 3542 || // Sinhala combining marks
1151
+ codePoint >= 3633 && codePoint <= 3633 || // Thai combining marks
1152
+ codePoint >= 3636 && codePoint <= 3642 || // Thai combining marks
1153
+ codePoint >= 3655 && codePoint <= 3662 || // Thai combining marks
1154
+ codePoint >= 3761 && codePoint <= 3761 || // Lao combining marks
1155
+ codePoint >= 3764 && codePoint <= 3769 || // Lao combining marks
1156
+ codePoint >= 3771 && codePoint <= 3772 || // Lao combining marks
1157
+ codePoint >= 3784 && codePoint <= 3789 || // Lao combining marks
1158
+ codePoint >= 3864 && codePoint <= 3865 || // Tibetan combining marks
1159
+ codePoint >= 3893 && codePoint <= 3893 || // Tibetan combining marks
1160
+ codePoint >= 3895 && codePoint <= 3895 || // Tibetan combining marks
1161
+ codePoint >= 3897 && codePoint <= 3897 || // Tibetan combining marks
1162
+ codePoint >= 3953 && codePoint <= 3966 || // Tibetan combining marks
1163
+ codePoint >= 3968 && codePoint <= 3972 || // Tibetan combining marks
1164
+ codePoint >= 3974 && codePoint <= 3975 || // Tibetan combining marks
1165
+ codePoint >= 3984 && codePoint <= 3991 || // Tibetan combining marks
1166
+ codePoint >= 3993 && codePoint <= 4028 || // Tibetan combining marks
1167
+ codePoint >= 4038 && codePoint <= 4038 || // Tibetan combining marks
1168
+ codePoint >= 4146 && codePoint <= 4151 || // Myanmar combining marks
1169
+ codePoint >= 4153 && codePoint <= 4154 || // Myanmar combining marks
1170
+ codePoint >= 4157 && codePoint <= 4158 || // Myanmar combining marks
1171
+ codePoint >= 4184 && codePoint <= 4185 || // Myanmar combining marks
1172
+ codePoint >= 4190 && codePoint <= 4192 || // Myanmar combining marks
1173
+ codePoint >= 4209 && codePoint <= 4212 || // Myanmar combining marks
1174
+ codePoint >= 4226 && codePoint <= 4226 || // Myanmar combining marks
1175
+ codePoint >= 4229 && codePoint <= 4230 || // Myanmar combining marks
1176
+ codePoint >= 4237 && codePoint <= 4237 || // Myanmar combining marks
1177
+ codePoint >= 4957 && codePoint <= 4959 || // Ethiopic combining marks
1178
+ codePoint >= 5906 && codePoint <= 5908 || // Tagalog combining marks
1179
+ codePoint >= 5938 && codePoint <= 5940 || // Hanunoo combining marks
1180
+ codePoint >= 5970 && codePoint <= 5971 || // Buhid combining marks
1181
+ codePoint >= 6002 && codePoint <= 6003 || // Tagbanwa combining marks
1182
+ codePoint >= 6068 && codePoint <= 6069 || // Khmer combining marks
1183
+ codePoint >= 6071 && codePoint <= 6077 || // Khmer combining marks
1184
+ codePoint >= 6086 && codePoint <= 6086 || // Khmer combining marks
1185
+ codePoint >= 6089 && codePoint <= 6099 || // Khmer combining marks
1186
+ codePoint >= 6109 && codePoint <= 6109 || // Khmer combining marks
1187
+ codePoint >= 6155 && codePoint <= 6157 || // Mongolian combining marks
1188
+ codePoint >= 6313 && codePoint <= 6313 || // Mongolian combining marks
1189
+ codePoint >= 6432 && codePoint <= 6434 || // Limbu combining marks
1190
+ codePoint >= 6439 && codePoint <= 6440 || // Limbu combining marks
1191
+ codePoint >= 6450 && codePoint <= 6450 || // Limbu combining marks
1192
+ codePoint >= 6457 && codePoint <= 6459 || // Limbu combining marks
1193
+ codePoint >= 6679 && codePoint <= 6680 || // Buginese combining marks
1194
+ codePoint >= 6912 && codePoint <= 6915 || // Balinese combining marks
1195
+ codePoint >= 6964 && codePoint <= 6964 || // Balinese combining marks
1196
+ codePoint >= 6966 && codePoint <= 6970 || // Balinese combining marks
1197
+ codePoint >= 6972 && codePoint <= 6972 || // Balinese combining marks
1198
+ codePoint >= 6978 && codePoint <= 6978 || // Balinese combining marks
1199
+ codePoint >= 7019 && codePoint <= 7027 || // Balinese combining marks
1200
+ codePoint >= 7616 && codePoint <= 7679 || // Combining Diacritical Marks Supplement
1201
+ codePoint >= 8400 && codePoint <= 8432 || // Combining Diacritical Marks for Symbols
1202
+ codePoint >= 11503 && codePoint <= 11505 || // Coptic combining marks
1203
+ codePoint >= 11647 && codePoint <= 11647 || // Tifinagh combining marks
1204
+ codePoint >= 11744 && codePoint <= 11775 || // Cyrillic Extended-A combining marks
1205
+ codePoint >= 42607 && codePoint <= 42610 || // Cyrillic Extended-B combining marks
1206
+ codePoint >= 42612 && codePoint <= 42621 || // Cyrillic Extended-B combining marks
1207
+ codePoint >= 42654 && codePoint <= 42655 || // Cyrillic Extended-B combining marks
1208
+ codePoint >= 42736 && codePoint <= 42737 || // Bamum combining marks
1209
+ codePoint >= 43010 && codePoint <= 43010 || // Syloti Nagri combining marks
1210
+ codePoint >= 43014 && codePoint <= 43014 || // Syloti Nagri combining marks
1211
+ codePoint >= 43019 && codePoint <= 43019 || // Syloti Nagri combining marks
1212
+ codePoint >= 43045 && codePoint <= 43046 || // Syloti Nagri combining marks
1213
+ codePoint >= 43204 && codePoint <= 43204 || // Saurashtra combining marks
1214
+ codePoint >= 43232 && codePoint <= 43249 || // Devanagari Extended combining marks
1215
+ codePoint >= 43302 && codePoint <= 43309 || // Kayah Li combining marks
1216
+ codePoint >= 43335 && codePoint <= 43345 || // Rejang combining marks
1217
+ codePoint >= 43392 && codePoint <= 43394 || // Javanese combining marks
1218
+ codePoint >= 43443 && codePoint <= 43443 || // Javanese combining marks
1219
+ codePoint >= 43446 && codePoint <= 43449 || // Javanese combining marks
1220
+ codePoint >= 43452 && codePoint <= 43452 || // Javanese combining marks
1221
+ codePoint >= 43561 && codePoint <= 43566 || // Cham combining marks
1222
+ codePoint >= 43569 && codePoint <= 43570 || // Cham combining marks
1223
+ codePoint >= 43573 && codePoint <= 43574 || // Cham combining marks
1224
+ codePoint >= 43587 && codePoint <= 43587 || // Cham combining marks
1225
+ codePoint >= 43596 && codePoint <= 43596 || // Cham combining marks
1226
+ codePoint >= 43696 && codePoint <= 43696 || // Tai Viet combining marks
1227
+ codePoint >= 43698 && codePoint <= 43700 || // Tai Viet combining marks
1228
+ codePoint >= 43703 && codePoint <= 43704 || // Tai Viet combining marks
1229
+ codePoint >= 43710 && codePoint <= 43711 || // Tai Viet combining marks
1230
+ codePoint >= 43713 && codePoint <= 43713 || // Tai Viet combining marks
1231
+ codePoint >= 44005 && codePoint <= 44005 || // Meetei Mayek combining marks
1232
+ codePoint >= 44008 && codePoint <= 44008 || // Meetei Mayek combining marks
1233
+ codePoint >= 44013 && codePoint <= 44013 || // Meetei Mayek combining marks
1234
+ codePoint >= 64286 && codePoint <= 64286 || // Hebrew combining marks
1235
+ codePoint >= 65024 && codePoint <= 65039 || // Variation Selectors
1236
+ codePoint >= 65056 && codePoint <= 65071 || // Combining Half Marks
1237
+ codePoint >= 917760 && codePoint <= 917999) {
1238
+ return 0;
1239
+ }
1240
+ if (codePoint >= 4352 && codePoint <= 4447 || // Hangul Jamo
1241
+ codePoint >= 9001 && codePoint <= 9002 || // Left/Right-pointing angle bracket
1242
+ codePoint >= 11904 && codePoint <= 12350 || // CJK Radicals Supplement, Kangxi Radicals, CJK Symbols
1243
+ codePoint >= 12352 && codePoint <= 13247 || // Hiragana, Katakana, Bopomofo, Hangul Compatibility, Kanbun, CJK Strokes, Enclosed CJK
1244
+ codePoint >= 13312 && codePoint <= 19903 || // CJK Unified Ideographs Extension A
1245
+ codePoint >= 19968 && codePoint <= 42191 || // CJK Unified Ideographs, Yi Syllables, Yi Radicals
1246
+ codePoint >= 43360 && codePoint <= 43388 || // Hangul Jamo Extended-A
1247
+ codePoint >= 44032 && codePoint <= 55203 || // Hangul Syllables
1248
+ codePoint >= 63744 && codePoint <= 64255 || // CJK Compatibility Ideographs
1249
+ codePoint >= 65040 && codePoint <= 65049 || // Vertical forms
1250
+ codePoint >= 65072 && codePoint <= 65135 || // CJK Compatibility Forms, Small Form Variants
1251
+ codePoint >= 65281 && codePoint <= 65376 || // Fullwidth Forms
1252
+ codePoint >= 65504 && codePoint <= 65510 || // Fullwidth Signs
1253
+ codePoint >= 110592 && codePoint <= 111359 || // Kana Supplement, Kana Extended-A, Small Kana Extension
1254
+ codePoint >= 126980 && codePoint <= 126980 || // Mahjong tile
1255
+ codePoint >= 127183 && codePoint <= 127183 || // Playing card
1256
+ codePoint >= 127232 && codePoint <= 129535 || // Enclosed Alphanumeric Supplement, Emoticons, Transport, etc.
1257
+ codePoint >= 129536 && codePoint <= 129647 || // Chess Symbols
1258
+ codePoint >= 129648 && codePoint <= 129791 || // Symbols and Pictographs Extended-A
1259
+ codePoint >= 131072 && codePoint <= 196605 || // CJK Unified Ideographs Extension B–G, CJK Compatibility Supplement
1260
+ codePoint >= 196608 && codePoint <= 262141) {
1261
+ return 2;
1262
+ }
1263
+ return 1;
1264
+ }
1265
+
1266
+ // src/ui/thinking-line.ts
1267
+ var THINKING_SCROLL_CELLS_PER_SEC = 16;
1268
+ var THINKING_EASE = 0.18;
1269
+ var THINKING_MAX_STEP_MS = 250;
1270
+ var THINKING_MAX_STORED_CHARS = 4e3;
1271
+ function normalizeThinkingText(text) {
1272
+ return text.replace(/\s+/gu, " ").trim();
1273
+ }
1274
+ function thinkingDisplayWidth(text) {
1275
+ let width = 0;
1276
+ for (const character of text) width += charWidth(character.codePointAt(0) ?? 32);
1277
+ return width;
1278
+ }
1279
+ function sliceThinkingByWidth(text, startCell, cellCount) {
1280
+ let out = "";
1281
+ let cell = 0;
1282
+ for (const character of text) {
1283
+ const w = charWidth(character.codePointAt(0) ?? 32);
1284
+ if (cell + w > startCell && cell < startCell + cellCount) out += character;
1285
+ cell += w;
1286
+ if (cell >= startCell + cellCount) break;
1287
+ }
1288
+ return out;
1289
+ }
1290
+ function thinkingWindow(text, previousStart, options) {
1291
+ const normalized = normalizeThinkingText(text);
1292
+ const width = Math.max(1, Math.floor(options.width));
1293
+ const total = thinkingDisplayWidth(normalized);
1294
+ if (total <= width) return { text: normalized, start: 0 };
1295
+ const maxStart = total - width;
1296
+ const from = Math.min(Math.max(0, previousStart), maxStart);
1297
+ const cellsPerSecond = options.cellsPerSecond ?? THINKING_SCROLL_CELLS_PER_SEC;
1298
+ const ease = options.ease ?? THINKING_EASE;
1299
+ const dt = Math.max(0, Math.min(options.dtMs, THINKING_MAX_STEP_MS));
1300
+ const lag = maxStart - from;
1301
+ const step = Math.max(cellsPerSecond * dt / 1e3, lag * ease);
1302
+ const start = Math.min(maxStart, Math.floor(from + step));
1303
+ return { text: sliceThinkingByWidth(normalized, start, width), start };
1304
+ }
1305
+ function appendThinkingText(previous, delta) {
1306
+ const next = (previous ?? "") + delta;
1307
+ return next.length > THINKING_MAX_STORED_CHARS ? next.slice(-THINKING_MAX_STORED_CHARS) : next;
1308
+ }
1309
+
1085
1310
  // src/ui/transcript.ts
1086
1311
  function createTranscriptState() {
1087
1312
  return { completed: [], nextId: 1 };
@@ -1178,6 +1403,9 @@ function transcriptReducer(state, action) {
1178
1403
  if (event.type === "text") {
1179
1404
  return { ...state, active: addText(withoutModelActivity(state.active), event.text) };
1180
1405
  }
1406
+ if (event.type === "thinking") {
1407
+ return { ...state, active: attachThinking(state.active, event.text) };
1408
+ }
1181
1409
  if (event.type === "tool-start") return upsertStatus({ ...state, active: withoutModelActivity(state.active) }, {
1182
1410
  kind: "status",
1183
1411
  id: `tool:${event.id}`,
@@ -1478,6 +1706,18 @@ function finishActive(state) {
1478
1706
  ...state.taskSnapshot === void 0 ? {} : { taskSnapshot: state.taskSnapshot }
1479
1707
  };
1480
1708
  }
1709
+ function attachThinking(turn, text) {
1710
+ const blocks = [...turn.blocks];
1711
+ const index = blocks.findIndex((block2) => block2.kind === "status" && block2.activity === "model" && block2.state === "running");
1712
+ if (index < 0) return turn;
1713
+ const block = blocks[index];
1714
+ if (block === void 0 || block.kind !== "status") return turn;
1715
+ blocks[index] = {
1716
+ ...block,
1717
+ thinkingText: appendThinkingText(block.thinkingText, text)
1718
+ };
1719
+ return { ...turn, blocks };
1720
+ }
1481
1721
  function withoutModelActivity(turn, id) {
1482
1722
  const blocks = turn.blocks.filter((block) => block.kind !== "status" || block.activity !== "model" || id !== void 0 && block.id !== id);
1483
1723
  if (blocks.length === turn.blocks.length) return turn;
@@ -6341,7 +6581,12 @@ function providerValidMessages(input) {
6341
6581
  const calls = original.toolCalls.filter((call) => call.id && call.name && availableResults.has(call.id));
6342
6582
  calls.forEach((call) => announced.add(call.id));
6343
6583
  if (!original.content && calls.length === 0) continue;
6344
- output.push({ role: "assistant", content: original.content, ...calls.length === 0 ? {} : { toolCalls: calls.map((call) => ({ ...call })) } });
6584
+ output.push({
6585
+ role: "assistant",
6586
+ content: original.content,
6587
+ ...calls.length === 0 ? {} : { toolCalls: calls.map((call) => ({ ...call })) },
6588
+ ...original.thinkingBlocks === void 0 ? {} : { thinkingBlocks: original.thinkingBlocks.map((block) => ({ ...block })) }
6589
+ });
6345
6590
  continue;
6346
6591
  }
6347
6592
  if (original.role === "tool") {
@@ -7064,6 +7309,7 @@ var AgentLoop = class {
7064
7309
  }
7065
7310
  let assistantText = "";
7066
7311
  const collectedToolCalls = [];
7312
+ const collectedThinking = [];
7067
7313
  let completed = false;
7068
7314
  let reactiveRetried = false;
7069
7315
  let attempt = 1;
@@ -7101,6 +7347,7 @@ var AgentLoop = class {
7101
7347
  }
7102
7348
  assistantText = "";
7103
7349
  collectedToolCalls.length = 0;
7350
+ collectedThinking.length = 0;
7104
7351
  completed = false;
7105
7352
  let terminalError;
7106
7353
  let providerError = false;
@@ -7121,6 +7368,10 @@ var AgentLoop = class {
7121
7368
  assistantText += event.text;
7122
7369
  accumulatedText += event.text;
7123
7370
  yield event;
7371
+ } else if (event.type === "thinking") {
7372
+ yield event;
7373
+ } else if (event.type === "thinking-block") {
7374
+ collectedThinking.push({ text: event.text, ...event.signature === void 0 ? {} : { signature: event.signature } });
7124
7375
  } else if (event.type === "tool-call") {
7125
7376
  collectedToolCalls.push({ kind: "valid", id: event.id, name: event.name, input: event.input });
7126
7377
  } else if (event.type === "invalid-tool-call") {
@@ -7468,7 +7719,8 @@ var AgentLoop = class {
7468
7719
  const assistantMessage = {
7469
7720
  role: "assistant",
7470
7721
  content: assistantText,
7471
- toolCalls: toolCalls.map(({ id, name, input }) => ({ id, name, input }))
7722
+ toolCalls: toolCalls.map(({ id, name, input }) => ({ id, name, input })),
7723
+ ...collectedThinking.length === 0 ? {} : { thinkingBlocks: collectedThinking.map((block) => ({ ...block })) }
7472
7724
  };
7473
7725
  this.#options.context.appendMany([assistantMessage, ...stagedMessages]);
7474
7726
  for (const { call, result } of stagedResults) {
@@ -12725,6 +12977,7 @@ var CLAUDE_CLIENT_HEADERS = {
12725
12977
  "x-app": "cli"
12726
12978
  };
12727
12979
  var DEFAULT_MAX_OUTPUT_TOKENS = 32768;
12980
+ var DEFAULT_THINKING_BUDGET = 8192;
12728
12981
  var MAX_CACHE_MARKERS = 4;
12729
12982
  function collectCacheMarkers(system, messages) {
12730
12983
  const markers = [];
@@ -12783,9 +13036,26 @@ function formatCacheUsage(model, snapshot4, shape) {
12783
13036
  ...shape === void 0 ? {} : { requestMessages: shape.messages, requestMarkers: shape.markers }
12784
13037
  });
12785
13038
  }
13039
+ function stripThinkingBlocks(messages) {
13040
+ for (const message2 of messages) {
13041
+ if (message2.role !== "assistant" || !Array.isArray(message2.content)) continue;
13042
+ const blocks = message2.content;
13043
+ if (!blocks.some((block) => block?.type === "thinking")) continue;
13044
+ message2.content = blocks.filter((block) => block?.type !== "thinking");
13045
+ }
13046
+ }
13047
+ function isThinkingParamRejected(error) {
13048
+ const status = error?.status;
13049
+ if (status !== void 0 && status !== 400) return false;
13050
+ const message2 = error instanceof Error ? error.message : String(error ?? "");
13051
+ return /\bthinking\b/iu.test(message2) && /(budget_tokens|expected|not supported|unsupported|unknown|invalid|extra inputs|unrecognized)/iu.test(message2);
13052
+ }
12786
13053
  var AnthropicModelAdapter = class {
12787
13054
  client;
12788
13055
  maxOutputTokens;
13056
+ thinkingBudget;
13057
+ /** Set once an endpoint rejects the `thinking` parameter; later requests stop sending it. */
13058
+ #thinkingRejected = false;
12789
13059
  debugUsage;
12790
13060
  constructor(options) {
12791
13061
  const maxOutputTokens = options.maxOutputTokens ?? DEFAULT_MAX_OUTPUT_TOKENS;
@@ -12793,6 +13063,7 @@ var AnthropicModelAdapter = class {
12793
13063
  throw new Error("maxOutputTokens must be a positive integer");
12794
13064
  }
12795
13065
  this.maxOutputTokens = maxOutputTokens;
13066
+ this.thinkingBudget = options.thinkingBudget ?? DEFAULT_THINKING_BUDGET;
12796
13067
  this.debugUsage = options.debugUsage ?? isEnvTruthy(process.env.FLAVOR_DEBUG_USAGE);
12797
13068
  this.client = options.client ?? new Anthropic({
12798
13069
  ...options.apiKey === void 0 ? {} : { apiKey: options.apiKey },
@@ -12800,6 +13071,16 @@ var AnthropicModelAdapter = class {
12800
13071
  ...options.headers === void 0 ? {} : { defaultHeaders: options.headers }
12801
13072
  });
12802
13073
  }
13074
+ /**
13075
+ * Extended-thinking request parameter when enabled, otherwise undefined.
13076
+ * Anthropic requires the budget to fit inside max_tokens with a 1024 floor.
13077
+ */
13078
+ #thinkingParam() {
13079
+ if (this.#thinkingRejected || this.thinkingBudget <= 0) return void 0;
13080
+ const budget = Math.min(this.thinkingBudget, this.maxOutputTokens - 1);
13081
+ if (budget < 1024) return void 0;
13082
+ return { type: "enabled", budget_tokens: budget };
13083
+ }
12803
13084
  #logUsage(request, snapshot4, shape) {
12804
13085
  const line = formatCacheUsage(request.model, snapshot4, shape);
12805
13086
  if (this.debugUsage) {
@@ -12855,7 +13136,13 @@ var AnthropicModelAdapter = class {
12855
13136
  }
12856
13137
  messages.push({ role: "user", content: results });
12857
13138
  } else if (message2.role === "assistant" && message2.toolCalls?.length) {
13139
+ const echoThinking = this.#thinkingRejected ? [] : (message2.thinkingBlocks ?? []).filter((block) => block.signature !== void 0);
12858
13140
  const content = [
13141
+ ...echoThinking.map((block) => ({
13142
+ type: "thinking",
13143
+ thinking: block.text,
13144
+ signature: block.signature
13145
+ })),
12859
13146
  ...modelContentText(message2.content) ? [{ type: "text", text: modelContentText(message2.content) }] : [],
12860
13147
  ...message2.toolCalls.map((call) => ({
12861
13148
  type: "tool_use",
@@ -12917,18 +13204,56 @@ var AnthropicModelAdapter = class {
12917
13204
  stream: true,
12918
13205
  messages,
12919
13206
  ...system ? { system } : {},
13207
+ ...(() => {
13208
+ const thinking = this.#thinkingParam();
13209
+ return thinking === void 0 ? {} : { thinking };
13210
+ })(),
12920
13211
  tools: [...request.tools].sort((a, b) => a.name.localeCompare(b.name)).map((tool) => ({
12921
13212
  name: tool.name,
12922
13213
  description: tool.description,
12923
13214
  input_schema: { ...tool.inputSchema, type: "object" }
12924
13215
  }))
12925
13216
  };
12926
- const stream = await this.client.messages.create(body, { signal: request.signal });
13217
+ let stream;
13218
+ try {
13219
+ stream = await this.client.messages.create(body, { signal: request.signal });
13220
+ } catch (error) {
13221
+ if (this.thinkingBudget > 0 && !this.#thinkingRejected && isThinkingParamRejected(error)) {
13222
+ this.#thinkingRejected = true;
13223
+ delete body.thinking;
13224
+ stripThinkingBlocks(body.messages);
13225
+ stream = await this.client.messages.create(body, { signal: request.signal });
13226
+ } else {
13227
+ throw error;
13228
+ }
13229
+ }
13230
+ const thinkingBuffers = /* @__PURE__ */ new Map();
12927
13231
  for await (const event of stream) {
12928
13232
  if (event.type === "message_start") {
12929
13233
  hasUsage = event.message?.usage !== void 0;
12930
13234
  inputTokens = updateInputUsage(inputUsage, event.message?.usage);
12931
13235
  outputTokens = event.message?.usage?.output_tokens ?? outputTokens;
13236
+ } else if (event.type === "content_block_start" && event.content_block?.type === "thinking" && event.index !== void 0) {
13237
+ thinkingBuffers.set(event.index, { text: "" });
13238
+ } else if (event.type === "content_block_delta" && event.delta?.type === "thinking_delta") {
13239
+ if (event.index !== void 0 && event.delta.thinking) {
13240
+ const pending = thinkingBuffers.get(event.index);
13241
+ if (pending) pending.text += event.delta.thinking;
13242
+ }
13243
+ if (event.delta.thinking) yield { type: "thinking", text: event.delta.thinking };
13244
+ } else if (event.type === "content_block_delta" && event.delta?.type === "signature_delta" && event.index !== void 0) {
13245
+ const pending = thinkingBuffers.get(event.index);
13246
+ if (pending) pending.signature = (pending.signature ?? "") + (event.delta.signature ?? "");
13247
+ } else if (event.type === "content_block_stop" && event.index !== void 0 && thinkingBuffers.has(event.index)) {
13248
+ const pending = thinkingBuffers.get(event.index);
13249
+ if (pending.text.length > 0 || pending.signature !== void 0) {
13250
+ yield {
13251
+ type: "thinking-block",
13252
+ text: pending.text,
13253
+ ...pending.signature === void 0 ? {} : { signature: pending.signature }
13254
+ };
13255
+ }
13256
+ thinkingBuffers.delete(event.index);
12932
13257
  } else if (event.type === "content_block_start" && event.content_block?.type === "tool_use" && event.index !== void 0 && event.content_block.id && event.content_block.name) {
12933
13258
  pendingTools.set(event.index, {
12934
13259
  id: event.content_block.id,
@@ -13131,12 +13456,14 @@ function formatOpenAIUsage(model, breakdown) {
13131
13456
  var OpenAIModelAdapter = class {
13132
13457
  client;
13133
13458
  debugUsage;
13459
+ thinkingEffort;
13134
13460
  constructor(options) {
13135
13461
  this.client = options.client ?? new OpenAI({
13136
13462
  ...options.apiKey === void 0 ? {} : { apiKey: options.apiKey },
13137
13463
  ...options.baseURL === void 0 ? {} : { baseURL: options.baseURL }
13138
13464
  });
13139
13465
  this.debugUsage = options.debugUsage ?? isEnvTruthy(process.env.FLAVOR_DEBUG_USAGE);
13466
+ this.thinkingEffort = options.thinkingEffort;
13140
13467
  }
13141
13468
  #logUsage(model, breakdown) {
13142
13469
  if (breakdown === void 0) return;
@@ -13158,6 +13485,7 @@ var OpenAIModelAdapter = class {
13158
13485
  const body = {
13159
13486
  model: request.model,
13160
13487
  input: (await Promise.all(request.messages.map(toInput))).flat(),
13488
+ ...this.thinkingEffort === void 0 ? {} : { reasoning: { effort: this.thinkingEffort } },
13161
13489
  tools: [...request.tools].sort((a, b) => a.name.localeCompare(b.name)).map((tool) => ({
13162
13490
  type: "function",
13163
13491
  name: tool.name,
@@ -13190,6 +13518,8 @@ var OpenAIModelAdapter = class {
13190
13518
  }
13191
13519
  } else if (event.type === "response.output_text.delta" && event.delta) {
13192
13520
  yield { type: "text", text: event.delta };
13521
+ } else if ((event.type === "response.reasoning_summary_text.delta" || event.type === "response.reasoning_text.delta") && event.delta) {
13522
+ yield { type: "thinking", text: event.delta };
13193
13523
  } else if (event.type === "response.function_call_arguments.done" && event.output_index !== void 0 && event.name) {
13194
13524
  const callId = callIds.get(event.output_index);
13195
13525
  if (callId && !emittedCalls.has(event.output_index)) {
@@ -22367,8 +22697,12 @@ ${renderMemoryDocument(entries)}`;
22367
22697
  };
22368
22698
  registry.register(next.providerId, next.apiType === "anthropic" ? new AnthropicModelAdapter({
22369
22699
  ...adapterOptions,
22700
+ ...providerConfig?.thinkingBudget === void 0 ? {} : { thinkingBudget: providerConfig.thinkingBudget },
22370
22701
  ...providerConfig?.claudeClient === true ? { headers: CLAUDE_CLIENT_HEADERS } : {}
22371
- }) : new OpenAIModelAdapter(adapterOptions));
22702
+ }) : new OpenAIModelAdapter({
22703
+ ...adapterOptions,
22704
+ ...providerConfig?.thinkingEffort === void 0 ? {} : { thinkingEffort: providerConfig.thinkingEffort }
22705
+ }));
22372
22706
  effectiveLlm = next;
22373
22707
  mainModel = `${next.providerId}:${next.defaultModel}`;
22374
22708
  childModel = `${next.providerId}:${next.cheapModel}`;
@@ -22954,8 +23288,12 @@ async function registerConfiguredAdapters(providers, registry, environment, diag
22954
23288
  };
22955
23289
  const adapter = apiProtocol === "anthropic" ? new AnthropicModelAdapter({
22956
23290
  ...adapterOptions,
23291
+ ...runtimeProvider.thinkingBudget === void 0 ? {} : { thinkingBudget: runtimeProvider.thinkingBudget },
22957
23292
  ...runtimeProvider.claudeClient === true ? { headers: CLAUDE_CLIENT_HEADERS } : {}
22958
- }) : new OpenAIModelAdapter(adapterOptions);
23293
+ }) : new OpenAIModelAdapter({
23294
+ ...adapterOptions,
23295
+ ...runtimeProvider.thinkingEffort === void 0 ? {} : { thinkingEffort: runtimeProvider.thinkingEffort }
23296
+ });
22959
23297
  const cacheProfile = resolveCacheProfile({ apiType: apiProtocol, baseURL: runtimeProvider.baseURL });
22960
23298
  if (apiProtocol === "openai" && isDashScopeBaseURL(runtimeProvider.baseURL)) {
22961
23299
  diagnostics.push(
@@ -23320,6 +23658,8 @@ export {
23320
23658
  executeShell,
23321
23659
  packageVersion,
23322
23660
  SkillRegistry,
23661
+ charWidth,
23662
+ thinkingWindow,
23323
23663
  createTranscriptState,
23324
23664
  transcriptReducer,
23325
23665
  WorkspaceCheckpointStore,
package/dist/cli.js CHANGED
@@ -3,10 +3,10 @@ import { createRequire } from "node:module"; const require = createRequire(impor
3
3
  import {
4
4
  FlavorRpcServer,
5
5
  TraceRecorder
6
- } from "./chunk-JZ5FVBET.js";
6
+ } from "./chunk-EZNIDHFZ.js";
7
7
  import {
8
8
  staticTaskLines
9
- } from "./chunk-KKIBYDJI.js";
9
+ } from "./chunk-2BF7CVWZ.js";
10
10
  import {
11
11
  DEFAULT_MAX_OUTPUT_BYTES,
12
12
  MAX_ALIAS_LENGTH,
@@ -23,7 +23,7 @@ import {
23
23
  packageVersion,
24
24
  redactErrorText,
25
25
  runPalBroker
26
- } from "./chunk-IGFN2DM5.js";
26
+ } from "./chunk-QC5OYQTB.js";
27
27
  import {
28
28
  McpServerConfigSchema,
29
29
  McpServerNameSchema,
@@ -32,7 +32,7 @@ import {
32
32
  readRecoverableFile,
33
33
  setProjectSkillDisabled,
34
34
  updateProtectedFile
35
- } from "./chunk-IG4Z23CL.js";
35
+ } from "./chunk-JFKRX2KG.js";
36
36
  import "./chunk-RQTYHUMK.js";
37
37
  import "./chunk-S32JRDZK.js";
38
38
 
@@ -750,7 +750,7 @@ async function runEvaluationFile(path, outputPath) {
750
750
  })),
751
751
  ...parsed.maxTokens === void 0 ? {} : { maxTokens: parsed.maxTokens }
752
752
  };
753
- const configured = await import("./load-GKA7P6RJ.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
753
+ const configured = await import("./load-LTTKVPJZ.js").then(({ loadConfig: loadConfig2 }) => loadConfig2({ cwd: workspace, home: process.env.USERPROFILE ?? process.env.HOME ?? workspace }));
754
754
  const environment = createExecutionEnvironment(workspace, configured.config.execution) ?? new LocalExecutionEnvironment();
755
755
  let report;
756
756
  try {
@@ -877,7 +877,7 @@ async function runInteractiveCli(props) {
877
877
  const [{ render, AlternateScreen }, { createElement }, { App }] = await Promise.all([
878
878
  import("./claude-ink-ORUA7GWG.js"),
879
879
  import("react"),
880
- import("./app-L52CTVNR.js")
880
+ import("./app-Z7D7XPVE.js")
881
881
  ]);
882
882
  const instance = await render(createElement(
883
883
  AlternateScreen,
@@ -19,6 +19,12 @@ export declare const ProviderConfigSchema: z.ZodObject<{
19
19
  cheapModel: z.ZodOptional<z.ZodString>;
20
20
  models: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
21
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
22
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
23
+ thinkingEffort: z.ZodOptional<z.ZodEnum<{
24
+ high: "high";
25
+ low: "low";
26
+ medium: "medium";
27
+ }>>;
22
28
  claudeClient: z.ZodOptional<z.ZodBoolean>;
23
29
  apiType: z.ZodOptional<z.ZodEnum<{
24
30
  anthropic: "anthropic";
@@ -68,6 +74,12 @@ export declare const FlavorConfigSchema: z.ZodObject<{
68
74
  cheapModel: z.ZodOptional<z.ZodString>;
69
75
  models: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
76
  maxOutputTokens: z.ZodOptional<z.ZodNumber>;
77
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
78
+ thinkingEffort: z.ZodOptional<z.ZodEnum<{
79
+ high: "high";
80
+ low: "low";
81
+ medium: "medium";
82
+ }>>;
71
83
  claudeClient: z.ZodOptional<z.ZodBoolean>;
72
84
  apiType: z.ZodOptional<z.ZodEnum<{
73
85
  anthropic: "anthropic";