@jeffreycao/copilot-api 1.14.3 → 1.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -25,7 +25,7 @@ bindElectronFetch();
25
25
  const { auth } = await import("./auth-DvJ8r_tN.js");
26
26
  const { debug } = await import("./debug-Bb5hamXX.js");
27
27
  const { mcp } = await import("./mcp-BseuqgHR.js");
28
- const { start } = await import("./start-CE0CJpAo.js");
28
+ const { start } = await import("./start-DNPIXvm4.js");
29
29
  await runMain(defineCommand({
30
30
  meta: {
31
31
  name: "copilot-api",
@@ -3568,6 +3568,7 @@ const MESSAGE_TYPE = "message";
3568
3568
  const COMPACTION_SIGNATURE_PREFIX = "cm1#";
3569
3569
  const COMPACTION_SIGNATURE_SEPARATOR = "@";
3570
3570
  const THINKING_TEXT = "Thinking...";
3571
+ const REASONING_SUMMARY_SEPARATOR = "⁣\n\n";
3571
3572
  const resolveReasoningEffort = (payload) => payload.output_config?.effort ?? getReasoningEffortForModel(payload.model);
3572
3573
  const buildPromptCacheKey = (basePromptCacheKey, subagentAgentId) => {
3573
3574
  if (!basePromptCacheKey) return null;
@@ -3609,8 +3610,8 @@ const translateAnthropicMessagesToResponsesPayload = (payload, subagentAgentId)
3609
3610
  parallel_tool_calls: true,
3610
3611
  reasoning: {
3611
3612
  effort: resolveReasoningEffort(payload),
3612
- summary: "detailed",
3613
- context: "all_turns"
3613
+ summary: "auto",
3614
+ context: isSupportAllTurns(payload) ? "all_turns" : "auto"
3614
3615
  },
3615
3616
  include: ["reasoning.encrypted_content"]
3616
3617
  };
@@ -3755,17 +3756,24 @@ const createFileContent = (block) => ({
3755
3756
  });
3756
3757
  const createReasoningContent = (block) => {
3757
3758
  const { encryptedContent, id } = parseReasoningSignature(block.signature);
3758
- const thinking = block.thinking === "Thinking..." ? "" : block.thinking;
3759
3759
  return {
3760
3760
  id,
3761
3761
  type: "reasoning",
3762
- summary: thinking ? [{
3763
- type: "summary_text",
3764
- text: thinking
3765
- }] : [],
3762
+ summary: createReasoningSummary(block.thinking === "Thinking..." ? "" : block.thinking),
3766
3763
  encrypted_content: encryptedContent
3767
3764
  };
3768
3765
  };
3766
+ const createReasoningSummary = (thinking) => {
3767
+ if (thinking.length === 0) return [];
3768
+ if (!thinking.includes("⁣\n\n")) return [{
3769
+ type: "summary_text",
3770
+ text: thinking
3771
+ }];
3772
+ return thinking.split(REASONING_SUMMARY_SEPARATOR).map((text) => ({
3773
+ type: "summary_text",
3774
+ text
3775
+ }));
3776
+ };
3769
3777
  const createCompactionContent = (block) => {
3770
3778
  const compaction = decodeCompactionCarrierSignature(block.signature);
3771
3779
  if (!compaction) return;
@@ -4042,7 +4050,7 @@ const extractReasoningText = (item) => {
4042
4050
  };
4043
4051
  if (!item.summary || item.summary.length === 0) return THINKING_TEXT;
4044
4052
  collectFromBlocks(item.summary);
4045
- return segments.join("").trim();
4053
+ return segments.join(REASONING_SUMMARY_SEPARATOR).trim();
4046
4054
  };
4047
4055
  const createToolUseContentBlock = (call) => {
4048
4056
  const toolId = call.call_id;
@@ -4155,6 +4163,10 @@ const convertToolResultContent = (content) => {
4155
4163
  }
4156
4164
  return "";
4157
4165
  };
4166
+ const isSupportAllTurns = (payload) => {
4167
+ if (payload.model === "gpt-5.4" || payload.model === "gpt-5.4-mini" || payload.model === "gpt-5.5") return true;
4168
+ return isGpt56OrAbove(payload.model);
4169
+ };
4158
4170
  //#endregion
4159
4171
  //#region src/routes/messages/responses-stream-translation.ts
4160
4172
  const MAX_CONSECUTIVE_FUNCTION_CALL_WHITESPACE = 20;
@@ -4189,6 +4201,7 @@ const createResponsesStreamState = (options) => ({
4189
4201
  blockIndexByKey: /* @__PURE__ */ new Map(),
4190
4202
  openBlocks: /* @__PURE__ */ new Set(),
4191
4203
  blockHasDelta: /* @__PURE__ */ new Set(),
4204
+ reasoningSummaryHasDelta: /* @__PURE__ */ new Set(),
4192
4205
  functionCallStateByOutputIndex: /* @__PURE__ */ new Map(),
4193
4206
  toolSearchName: options?.toolSearchName ?? "mcp__tool_search__search",
4194
4207
  hasToolCall: false
@@ -4198,6 +4211,7 @@ const translateResponsesStreamEvent = (rawEvent, state) => {
4198
4211
  case "response.created": return handleResponseCreated(rawEvent, state);
4199
4212
  case "response.output_item.added": return handleOutputItemAdded$1(rawEvent, state);
4200
4213
  case "response.reasoning_summary_text.delta": return handleReasoningSummaryTextDelta(rawEvent, state);
4214
+ case "response.reasoning_summary_part.added": return handleReasoningSummaryPartAdded(rawEvent, state);
4201
4215
  case "response.output_text.delta": return handleOutputTextDelta(rawEvent, state);
4202
4216
  case "response.reasoning_summary_text.done": return handleReasoningSummaryTextDone(rawEvent, state);
4203
4217
  case "response.output_text.done": return handleOutputTextDone(rawEvent, state);
@@ -4294,7 +4308,7 @@ const handleOutputItemDone$1 = (rawEvent, state) => {
4294
4308
  const blockIndex = openThinkingBlockIfNeeded(state, outputIndex, events);
4295
4309
  const signature = (item.encrypted_content ?? "") + "@" + item.id;
4296
4310
  if (signature) {
4297
- if (!item.summary || item.summary.length === 0) events.push({
4311
+ if ((!item.summary || item.summary.length === 0) && !state.blockHasDelta.has(blockIndex)) events.push({
4298
4312
  type: "content_block_delta",
4299
4313
  index: blockIndex,
4300
4314
  delta: {
@@ -4385,8 +4399,10 @@ const handleOutputTextDelta = (rawEvent, state) => {
4385
4399
  };
4386
4400
  const handleReasoningSummaryTextDelta = (rawEvent, state) => {
4387
4401
  const outputIndex = rawEvent.output_index;
4402
+ const summaryIndex = rawEvent.summary_index;
4388
4403
  const deltaText = rawEvent.delta;
4389
4404
  const events = new Array();
4405
+ if (!deltaText) return events;
4390
4406
  const blockIndex = openThinkingBlockIfNeeded(state, outputIndex, events);
4391
4407
  events.push({
4392
4408
  type: "content_block_delta",
@@ -4397,21 +4413,42 @@ const handleReasoningSummaryTextDelta = (rawEvent, state) => {
4397
4413
  }
4398
4414
  });
4399
4415
  state.blockHasDelta.add(blockIndex);
4416
+ state.reasoningSummaryHasDelta.add(getBlockKey(outputIndex, summaryIndex));
4400
4417
  return events;
4401
4418
  };
4402
- const handleReasoningSummaryTextDone = (rawEvent, state) => {
4403
- const outputIndex = rawEvent.output_index;
4404
- const text = rawEvent.text;
4419
+ const handleReasoningSummaryPartAdded = (rawEvent, state) => {
4405
4420
  const events = new Array();
4406
- const blockIndex = openThinkingBlockIfNeeded(state, outputIndex, events);
4407
- if (text && !state.blockHasDelta.has(blockIndex)) events.push({
4421
+ const blockIndex = openThinkingBlockIfNeeded(state, rawEvent.output_index, events);
4422
+ if (rawEvent.summary_index === 0) return events;
4423
+ events.push({
4408
4424
  type: "content_block_delta",
4409
4425
  index: blockIndex,
4410
4426
  delta: {
4411
4427
  type: "thinking_delta",
4412
- thinking: text
4428
+ thinking: REASONING_SUMMARY_SEPARATOR
4413
4429
  }
4414
4430
  });
4431
+ state.blockHasDelta.add(blockIndex);
4432
+ return events;
4433
+ };
4434
+ const handleReasoningSummaryTextDone = (rawEvent, state) => {
4435
+ const outputIndex = rawEvent.output_index;
4436
+ const summaryIndex = rawEvent.summary_index;
4437
+ const text = rawEvent.text;
4438
+ const events = new Array();
4439
+ const blockIndex = openThinkingBlockIfNeeded(state, outputIndex, events);
4440
+ const summaryKey = getBlockKey(outputIndex, summaryIndex);
4441
+ if (text && !state.reasoningSummaryHasDelta.has(summaryKey)) {
4442
+ events.push({
4443
+ type: "content_block_delta",
4444
+ index: blockIndex,
4445
+ delta: {
4446
+ type: "thinking_delta",
4447
+ thinking: text
4448
+ }
4449
+ });
4450
+ state.blockHasDelta.add(blockIndex);
4451
+ }
4415
4452
  return events;
4416
4453
  };
4417
4454
  const handleOutputTextDone = (rawEvent, state) => {
@@ -4558,6 +4595,7 @@ const closeOpenBlocks = (state, events) => {
4558
4595
  const closeAllOpenBlocks = (state, events) => {
4559
4596
  closeOpenBlocks(state, events);
4560
4597
  state.functionCallStateByOutputIndex.clear();
4598
+ state.reasoningSummaryHasDelta.clear();
4561
4599
  };
4562
4600
  const buildErrorEvent = (message) => ({
4563
4601
  type: "error",
@@ -6882,4 +6920,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
6882
6920
  //#endregion
6883
6921
  export { server };
6884
6922
 
6885
- //# sourceMappingURL=server-erYoRK9y.js.map
6923
+ //# sourceMappingURL=server-uQjD_RpA.js.map