@intx/inference 0.2.2 → 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.
@@ -1,4 +1,4 @@
1
- import type { ConversationTurn } from "@intx/types/runtime";
1
+ import { type ConversationTurn } from "@intx/types/runtime";
2
2
  export type TransformOptions = {
3
3
  targetModel: string;
4
4
  keepThinkingForSameModel?: boolean;
package/dist/transform.js CHANGED
@@ -5,9 +5,10 @@
5
5
  // calls receive synthetic error results, and tool call IDs are normalized to
6
6
  // a portable format.
7
7
  //
8
- // Transformation runs automatically when the target model differs from a
9
- // message's originating model. The originating model is tracked per-message,
10
- // not per-conversation.
8
+ // Callers invoke transformMessages when switching models. Adapter
9
+ // buildRequest paths also apply provider-specific history fixes. The
10
+ // originating model is tracked per-message, not per-conversation.
11
+ import { formatSafetyRatingText, } from "@intx/types/runtime";
11
12
  export function transformMessages(messages, options) {
12
13
  const { targetModel, keepThinkingForSameModel = true } = options;
13
14
  // First pass: strip thinking blocks and filter aborted assistant messages.
@@ -16,11 +17,25 @@ export function transformMessages(messages, options) {
16
17
  if (msg.role === "assistant") {
17
18
  const isSameModel = msg.model === targetModel;
18
19
  const keepThinking = keepThinkingForSameModel && isSameModel;
19
- const filteredContent = msg.content.filter((block) => {
20
+ const filteredContent = msg.content
21
+ .filter((block) => {
20
22
  if (block.type === "thinking") {
21
23
  return keepThinking;
22
24
  }
23
25
  return true;
26
+ })
27
+ // safety_rating is output-only metadata. Convert it to text
28
+ // so cross-provider history keeps role alternation and a
29
+ // human-readable block reason without requiring every
30
+ // adapter to special-case the block.
31
+ .map((block) => {
32
+ if (block.type === "safety_rating") {
33
+ return {
34
+ type: "text",
35
+ text: formatSafetyRatingText(block),
36
+ };
37
+ }
38
+ return block;
24
39
  });
25
40
  // Filter out assistant messages that have no text or tool calls
26
41
  // (aborted/error messages with only thinking blocks removed).
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@intx/inference",
3
- "version": "0.2.2",
3
+ "description": "Provider-agnostic inference runtime with Anthropic, OpenAI, and Google GenAI adapters",
4
+ "version": "0.3.0",
4
5
  "license": "LGPL-2.1-only",
5
6
  "type": "module",
6
7
  "exports": {
@@ -16,12 +17,12 @@
16
17
  }
17
18
  },
18
19
  "dependencies": {
19
- "@intx/log": "0.2.2",
20
- "@intx/types": "0.2.2",
20
+ "@intx/log": "0.3.0",
21
+ "@intx/types": "0.3.0",
21
22
  "arktype": "^2.1.29"
22
23
  },
23
24
  "devDependencies": {
24
- "@intx/mime": "0.2.2"
25
+ "@intx/mime": "0.3.0"
25
26
  },
26
27
  "files": [
27
28
  "dist",