gitlab-ai-provider 6.5.0 → 6.6.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.
package/dist/index.mjs CHANGED
@@ -282,7 +282,17 @@ var GitLabAnthropicLanguageModel = class {
282
282
  }
283
283
  }
284
284
  /**
285
- * Convert AI SDK prompt to Anthropic messages format
285
+ * Convert AI SDK prompt to Anthropic messages format.
286
+ *
287
+ * Cache breakpoints (`cache_control: { type: "ephemeral" }`) are placed on:
288
+ * 1. The system prompt content block — static across all turns.
289
+ * 2. The last content block of the second-to-last message — the boundary
290
+ * between conversation history and the current turn.
291
+ *
292
+ * This lets Anthropic cache the system prompt and the accumulated
293
+ * conversation prefix, so each new turn only pays for the new content.
294
+ *
295
+ * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
286
296
  */
287
297
  convertPrompt(prompt) {
288
298
  let systemMessage;
@@ -354,7 +364,23 @@ ${message.content}` : message.content;
354
364
  }
355
365
  }
356
366
  }
357
- return { system: systemMessage, messages };
367
+ const system = systemMessage ? [
368
+ {
369
+ type: "text",
370
+ text: systemMessage,
371
+ cache_control: { type: "ephemeral" }
372
+ }
373
+ ] : void 0;
374
+ if (messages.length >= 2) {
375
+ const penultimate = messages[messages.length - 2];
376
+ if (Array.isArray(penultimate.content)) {
377
+ const lastBlock = penultimate.content[penultimate.content.length - 1];
378
+ lastBlock.cache_control = {
379
+ type: "ephemeral"
380
+ };
381
+ }
382
+ }
383
+ return { system, messages };
358
384
  }
359
385
  /**
360
386
  * Convert Anthropic finish reason to AI SDK format
@@ -1583,7 +1609,7 @@ var GitLabOpenAILanguageModel = class {
1583
1609
  import WebSocket from "isomorphic-ws";
1584
1610
 
1585
1611
  // src/version.ts
1586
- var VERSION = true ? "6.4.2" : "0.0.0-dev";
1612
+ var VERSION = true ? "6.5.0" : "0.0.0-dev";
1587
1613
 
1588
1614
  // src/gitlab-workflow-types.ts
1589
1615
  var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {