@absolutejs/ai 0.1.1 → 0.1.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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.1.2 — 2026-09-16
10
+
11
+ ### Fixed
12
+
13
+ - **Preserve every parallel OpenAI tool result and subsequent conversation turn without overwriting expanded messages** (`openai`)
14
+
9
15
  ## 0.1.1 — 2026-09-16
10
16
 
11
17
  ### Added
package/changelog.json CHANGED
@@ -1,121 +1,134 @@
1
1
  {
2
- "contract": 1,
3
- "name": "@absolutejs/ai",
4
- "releases": [
5
- {
6
- "changes": [
7
- {
8
- "kind": "added",
9
- "summary": "Allow a separate preparation model with its own verified capacity while preserving the final answer model and invalidating notes when the preparation model changes",
10
- "symbols": [
11
- "PrepareAITextInputOptions",
12
- "prepareAITextInput",
13
- "prepareAITextInputStep"
14
- ]
15
- },
16
- {
17
- "kind": "fixed",
18
- "summary": "Fill preparation sections with bounded tokenizer-checked refinement, avoid duplicate final counting, and honor cancellation before generation",
19
- "symbols": [
20
- "prepareAITextInput",
21
- "prepareAITextInputStep"
22
- ]
23
- }
24
- ],
25
- "date": "2026-09-16",
26
- "version": "0.1.1"
27
- },
28
- {
29
- "changes": [
30
- {
31
- "kind": "changed",
32
- "summary": "Validate model capacity by default across generation, structured output, WebSocket and SSE entry points; reserve token headroom and support one protocol-preserving context recovery attempt. Providers without counting capability now fail explicitly; contextPolicy: false opts into raw behavior.",
33
- "symbols": [
34
- "generateAI",
35
- "generateAIWithTools",
36
- "generateObjectAI",
37
- "streamAI",
38
- "streamAIToSSE",
39
- "streamAIWithTools",
40
- "inspectAIContext",
41
- "createAIStoredToolResultRecovery",
42
- "StreamAIWithToolsOptions",
43
- "GenerateAIOptions",
44
- "GenerateAIResult",
45
- "GenerateObjectAIOptions",
46
- "AIProviderConfig",
47
- "StreamAIOptions",
48
- "AIChatPluginConfig"
49
- ]
50
- },
51
- {
52
- "kind": "added",
53
- "summary": "Add one-section text preparation steps for durable workers, with explicit pending/ready outcomes and checkpoint persistence before yielding",
54
- "symbols": [
55
- "prepareAITextInputStep",
56
- "AITextPreparationStep"
57
- ]
58
- },
59
- {
60
- "kind": "added",
61
- "summary": "Budget final retrieval instructions and tools before compacting text, with matching checkpoint invalidation",
62
- "symbols": [
63
- "PrepareAITextInputOptions",
64
- "prepareAITextInput"
65
- ]
66
- },
67
- {
68
- "kind": "fixed",
69
- "summary": "Preserve conversation origin across long-text preparation sections, distinguish source facts from embedded instructions, reserve more of the available context for factual notes, and invalidate checkpoints from the previous preparation policy",
70
- "symbols": [
71
- "prepareAITextInput",
72
- "prepareAITextInputStep"
73
- ]
74
- }
75
- ],
76
- "date": "2026-09-16",
77
- "version": "0.1.0"
78
- },
79
- {
80
- "changes": [
81
- {
82
- "kind": "added",
83
- "summary": "Keep compacted text useful with read-only original-source search, checkpointed ingestion, and capacity-checked terminal tool loops",
84
- "symbols": [
85
- "createAITextSource",
86
- "prepareAITextInput",
87
- "PrepareAITextInputOptions",
88
- "streamAIWithTools",
89
- "StreamAIWithToolsOptions"
90
- ]
91
- }
92
- ],
93
- "date": "2026-09-15",
94
- "version": "0.0.58"
95
- },
96
- {
97
- "changes": [
98
- {
99
- "kind": "internal",
100
- "summary": "Regenerate the OpenRouter client declaration with equivalent reordered response union types",
101
- "symbols": [
102
- "createOpenRouterClient"
103
- ]
104
- },
105
- {
106
- "kind": "added",
107
- "summary": "Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation",
108
- "symbols": [
109
- "inspectAIInput",
110
- "prepareAITextInput",
111
- "AIProviderConfig",
112
- "OpenAIConfig",
113
- "OpenAIResponsesConfig"
114
- ]
115
- }
116
- ],
117
- "date": "2026-09-15",
118
- "version": "0.0.57"
119
- }
120
- ]
2
+ "contract": 1,
3
+ "name": "@absolutejs/ai",
4
+ "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Preserve every parallel OpenAI tool result and subsequent conversation turn without overwriting expanded messages",
10
+ "symbols": [
11
+ "openai"
12
+ ]
13
+ }
14
+ ],
15
+ "date": "2026-09-16",
16
+ "version": "0.1.2"
17
+ },
18
+ {
19
+ "changes": [
20
+ {
21
+ "kind": "added",
22
+ "summary": "Allow a separate preparation model with its own verified capacity while preserving the final answer model and invalidating notes when the preparation model changes",
23
+ "symbols": [
24
+ "PrepareAITextInputOptions",
25
+ "prepareAITextInput",
26
+ "prepareAITextInputStep"
27
+ ]
28
+ },
29
+ {
30
+ "kind": "fixed",
31
+ "summary": "Fill preparation sections with bounded tokenizer-checked refinement, avoid duplicate final counting, and honor cancellation before generation",
32
+ "symbols": [
33
+ "prepareAITextInput",
34
+ "prepareAITextInputStep"
35
+ ]
36
+ }
37
+ ],
38
+ "date": "2026-09-16",
39
+ "version": "0.1.1"
40
+ },
41
+ {
42
+ "changes": [
43
+ {
44
+ "kind": "changed",
45
+ "summary": "Validate model capacity by default across generation, structured output, WebSocket and SSE entry points; reserve token headroom and support one protocol-preserving context recovery attempt. Providers without counting capability now fail explicitly; contextPolicy: false opts into raw behavior.",
46
+ "symbols": [
47
+ "generateAI",
48
+ "generateAIWithTools",
49
+ "generateObjectAI",
50
+ "streamAI",
51
+ "streamAIToSSE",
52
+ "streamAIWithTools",
53
+ "inspectAIContext",
54
+ "createAIStoredToolResultRecovery",
55
+ "StreamAIWithToolsOptions",
56
+ "GenerateAIOptions",
57
+ "GenerateAIResult",
58
+ "GenerateObjectAIOptions",
59
+ "AIProviderConfig",
60
+ "StreamAIOptions",
61
+ "AIChatPluginConfig"
62
+ ]
63
+ },
64
+ {
65
+ "kind": "added",
66
+ "summary": "Add one-section text preparation steps for durable workers, with explicit pending/ready outcomes and checkpoint persistence before yielding",
67
+ "symbols": [
68
+ "prepareAITextInputStep",
69
+ "AITextPreparationStep"
70
+ ]
71
+ },
72
+ {
73
+ "kind": "added",
74
+ "summary": "Budget final retrieval instructions and tools before compacting text, with matching checkpoint invalidation",
75
+ "symbols": [
76
+ "PrepareAITextInputOptions",
77
+ "prepareAITextInput"
78
+ ]
79
+ },
80
+ {
81
+ "kind": "fixed",
82
+ "summary": "Preserve conversation origin across long-text preparation sections, distinguish source facts from embedded instructions, reserve more of the available context for factual notes, and invalidate checkpoints from the previous preparation policy",
83
+ "symbols": [
84
+ "prepareAITextInput",
85
+ "prepareAITextInputStep"
86
+ ]
87
+ }
88
+ ],
89
+ "date": "2026-09-16",
90
+ "version": "0.1.0"
91
+ },
92
+ {
93
+ "changes": [
94
+ {
95
+ "kind": "added",
96
+ "summary": "Keep compacted text useful with read-only original-source search, checkpointed ingestion, and capacity-checked terminal tool loops",
97
+ "symbols": [
98
+ "createAITextSource",
99
+ "prepareAITextInput",
100
+ "PrepareAITextInputOptions",
101
+ "streamAIWithTools",
102
+ "StreamAIWithToolsOptions"
103
+ ]
104
+ }
105
+ ],
106
+ "date": "2026-09-15",
107
+ "version": "0.0.58"
108
+ },
109
+ {
110
+ "changes": [
111
+ {
112
+ "kind": "internal",
113
+ "summary": "Regenerate the OpenRouter client declaration with equivalent reordered response union types",
114
+ "symbols": [
115
+ "createOpenRouterClient"
116
+ ]
117
+ },
118
+ {
119
+ "kind": "added",
120
+ "summary": "Add model-specific token capacity, optional provider capacity configuration, and recoverable long-text preparation",
121
+ "symbols": [
122
+ "inspectAIInput",
123
+ "prepareAITextInput",
124
+ "AIProviderConfig",
125
+ "OpenAIConfig",
126
+ "OpenAIResponsesConfig"
127
+ ]
128
+ }
129
+ ],
130
+ "date": "2026-09-15",
131
+ "version": "0.0.57"
132
+ }
133
+ ]
121
134
  }
package/dist/ai/index.js CHANGED
@@ -1262,30 +1262,6 @@ var buildToolMessages = (blocks) => {
1262
1262
  }
1263
1263
  return messages;
1264
1264
  };
1265
- var processMessageAtIndex = (result, msg, idx) => {
1266
- if (!hasArrayContent(msg)) {
1267
- return;
1268
- }
1269
- const hasToolBlocks2 = msg.content.some((block) => block.type === "tool_use" || block.type === "tool_result");
1270
- if (!hasToolBlocks2) {
1271
- return;
1272
- }
1273
- const toolMessages = buildToolMessages(msg.content);
1274
- result.splice(idx, 1, ...toolMessages);
1275
- };
1276
- var convertSingleMessage = (result, msg, idx) => {
1277
- if (!msg) {
1278
- return;
1279
- }
1280
- processMessageAtIndex(result, msg, idx);
1281
- };
1282
- var convertToolResultMessages = (messages, params) => {
1283
- const result = [...messages];
1284
- for (let idx = 0;idx < params.messages.length; idx++) {
1285
- convertSingleMessage(result, params.messages[idx], idx);
1286
- }
1287
- return result;
1288
- };
1289
1265
  var mapToolDefinitions = (tools) => tools.map((tool) => ({
1290
1266
  function: {
1291
1267
  description: tool.description,
@@ -1342,10 +1318,11 @@ var mapOpenAIContent = (msg) => {
1342
1318
  return msg.content.map(mapContentBlockToOpenAI).filter((mapped) => mapped !== null);
1343
1319
  };
1344
1320
  var buildRequestBody = (params, capabilityModel = params.model) => {
1345
- const messages = convertToolResultMessages(params.messages.map((msg) => ({
1346
- content: mapOpenAIContent(msg),
1347
- role: msg.role
1348
- })), params);
1321
+ const messages = params.messages.flatMap((msg) => {
1322
+ if (hasArrayContent(msg) && msg.content.some((block) => block.type === "tool_use" || block.type === "tool_result"))
1323
+ return buildToolMessages(msg.content);
1324
+ return [{ content: mapOpenAIContent(msg), role: msg.role }];
1325
+ });
1349
1326
  if (params.systemPrompt) {
1350
1327
  messages.unshift({ content: params.systemPrompt, role: "system" });
1351
1328
  }
@@ -1882,7 +1859,7 @@ var convertMessageContent = (content) => {
1882
1859
  return content.map(mapContentBlock).filter((mapped) => mapped !== null);
1883
1860
  };
1884
1861
  var hasFunctionResponse = (content) => content.some((block) => block.type === "tool_result");
1885
- var convertSingleMessage2 = (msg) => {
1862
+ var convertSingleMessage = (msg) => {
1886
1863
  if (typeof msg.content !== "string" && hasFunctionResponse(msg.content)) {
1887
1864
  return { parts: convertMessageContent(msg.content), role: "user" };
1888
1865
  }
@@ -1891,7 +1868,7 @@ var convertSingleMessage2 = (msg) => {
1891
1868
  role: mapRole(msg.role)
1892
1869
  };
1893
1870
  };
1894
- var convertMessages = (messages) => messages.map(convertSingleMessage2);
1871
+ var convertMessages = (messages) => messages.map(convertSingleMessage);
1895
1872
  var mapToolDefinitions2 = (tools) => tools.map((tool) => ({
1896
1873
  description: tool.description,
1897
1874
  name: tool.name,
@@ -8727,5 +8704,5 @@ export {
8727
8704
  xai
8728
8705
  };
8729
8706
 
8730
- //# debugId=0E6BB4F28F8F0BB064756E2164756E21
8707
+ //# debugId=5DA989DD67F99C1B64756E2164756E21
8731
8708
  //# sourceMappingURL=index.js.map