@jeffreycao/copilot-api 1.6.0-beta.1 → 1.6.0-beta.2

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
@@ -23,7 +23,7 @@ if (typeof args["enterprise-url"] === "string") process.env.COPILOT_API_ENTERPRI
23
23
  const { auth } = await import("./auth-DAlTk9BR.js");
24
24
  const { checkUsage } = await import("./check-usage-B-1bXEu4.js");
25
25
  const { debug } = await import("./debug-DcC7ZPH0.js");
26
- const { start } = await import("./start-BBJU_Vu_.js");
26
+ const { start } = await import("./start-JMKr-2eK.js");
27
27
  const main = defineCommand({
28
28
  meta: {
29
29
  name: "copilot-api",
@@ -1997,8 +1997,10 @@ const stripToolReferenceTurnBoundary = (anthropicPayload) => {
1997
1997
  msg.content = msg.content.filter((block) => block.type !== "text" || block.text.trim() !== TOOL_REFERENCE_TURN_BOUNDARY);
1998
1998
  }
1999
1999
  };
2000
- const mergeToolResultForClaude = (anthropicPayload) => {
2001
- for (const msg of anthropicPayload.messages) {
2000
+ const mergeToolResultForClaude = (anthropicPayload, options) => {
2001
+ const lastMessageIndex = anthropicPayload.messages.length - 1;
2002
+ for (const [index, msg] of anthropicPayload.messages.entries()) {
2003
+ if (options?.skipLastMessage && index === lastMessageIndex) continue;
2002
2004
  if (msg.role !== "user" || !Array.isArray(msg.content)) continue;
2003
2005
  const toolResults = [];
2004
2006
  const textBlocks = [];
@@ -2511,10 +2513,8 @@ async function handleCompletion(c) {
2511
2513
  const noTools = !anthropicPayload.tools || anthropicPayload.tools.length === 0;
2512
2514
  if (anthropicBeta && noTools && compactType === 0) anthropicPayload.model = getSmallModel();
2513
2515
  if (compactType) logger$5.debug("Compact request type:", compactType);
2514
- else {
2515
- stripToolReferenceTurnBoundary(anthropicPayload);
2516
- mergeToolResultForClaude(anthropicPayload);
2517
- }
2516
+ stripToolReferenceTurnBoundary(anthropicPayload);
2517
+ mergeToolResultForClaude(anthropicPayload, { skipLastMessage: compactType === COMPACT_REQUEST });
2518
2518
  const requestId = generateRequestIdFromPayload(anthropicPayload, sessionId);
2519
2519
  logger$5.debug("Generated request ID:", requestId);
2520
2520
  if (state.manualApprove) await awaitApproval();
@@ -3026,4 +3026,4 @@ server.route("/:provider/v1/models", providerModelRoutes);
3026
3026
 
3027
3027
  //#endregion
3028
3028
  export { server };
3029
- //# sourceMappingURL=server-BZfT6g7P.js.map
3029
+ //# sourceMappingURL=server-DYDw_yEw.js.map