@osdk/aip-core 0.2.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.
Files changed (131) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +211 -0
  3. package/ai-sdk.d.ts +17 -0
  4. package/build/browser/ai-sdk/convert-prompt.js +136 -0
  5. package/build/browser/ai-sdk/convert-prompt.js.map +1 -0
  6. package/build/browser/ai-sdk/foundry-chat-language-model.js +386 -0
  7. package/build/browser/ai-sdk/foundry-chat-language-model.js.map +1 -0
  8. package/build/browser/ai-sdk/map-finish-reason.js +42 -0
  9. package/build/browser/ai-sdk/map-finish-reason.js.map +1 -0
  10. package/build/browser/ai-sdk/provider.js +62 -0
  11. package/build/browser/ai-sdk/provider.js.map +1 -0
  12. package/build/browser/ai-sdk/types.js +2 -0
  13. package/build/browser/ai-sdk/types.js.map +1 -0
  14. package/build/browser/generateText.js +76 -0
  15. package/build/browser/generateText.js.map +1 -0
  16. package/build/browser/index.js +23 -0
  17. package/build/browser/index.js.map +1 -0
  18. package/build/browser/internal/__test__/mockPlatformClient.js +36 -0
  19. package/build/browser/internal/__test__/mockPlatformClient.js.map +1 -0
  20. package/build/browser/internal/ids.js +23 -0
  21. package/build/browser/internal/ids.js.map +1 -0
  22. package/build/browser/internal/openAi.js +293 -0
  23. package/build/browser/internal/openAi.js.map +1 -0
  24. package/build/browser/internal/options.js +58 -0
  25. package/build/browser/internal/options.js.map +1 -0
  26. package/build/browser/internal/runStep.js +107 -0
  27. package/build/browser/internal/runStep.js.map +1 -0
  28. package/build/browser/internal/streamStep.js +223 -0
  29. package/build/browser/internal/streamStep.js.map +1 -0
  30. package/build/browser/internal/uiMessageBridge.js +55 -0
  31. package/build/browser/internal/uiMessageBridge.js.map +1 -0
  32. package/build/browser/lmsChatTransport.js +185 -0
  33. package/build/browser/lmsChatTransport.js.map +1 -0
  34. package/build/browser/model.js +74 -0
  35. package/build/browser/model.js.map +1 -0
  36. package/build/browser/public/ai-sdk.js +18 -0
  37. package/build/browser/public/ai-sdk.js.map +1 -0
  38. package/build/browser/streamText.js +210 -0
  39. package/build/browser/streamText.js.map +1 -0
  40. package/build/browser/types.js +2 -0
  41. package/build/browser/types.js.map +1 -0
  42. package/build/browser/uiMessage.js +34 -0
  43. package/build/browser/uiMessage.js.map +1 -0
  44. package/build/cjs/index.cjs +1012 -0
  45. package/build/cjs/index.cjs.map +1 -0
  46. package/build/cjs/index.d.cts +467 -0
  47. package/build/cjs/model-B5uS56VB.d.cts +45 -0
  48. package/build/cjs/public/ai-sdk.cjs +534 -0
  49. package/build/cjs/public/ai-sdk.cjs.map +1 -0
  50. package/build/cjs/public/ai-sdk.d.cts +49 -0
  51. package/build/esm/ai-sdk/convert-prompt.js +136 -0
  52. package/build/esm/ai-sdk/convert-prompt.js.map +1 -0
  53. package/build/esm/ai-sdk/foundry-chat-language-model.js +386 -0
  54. package/build/esm/ai-sdk/foundry-chat-language-model.js.map +1 -0
  55. package/build/esm/ai-sdk/map-finish-reason.js +42 -0
  56. package/build/esm/ai-sdk/map-finish-reason.js.map +1 -0
  57. package/build/esm/ai-sdk/provider.js +62 -0
  58. package/build/esm/ai-sdk/provider.js.map +1 -0
  59. package/build/esm/ai-sdk/types.js +2 -0
  60. package/build/esm/ai-sdk/types.js.map +1 -0
  61. package/build/esm/generateText.js +76 -0
  62. package/build/esm/generateText.js.map +1 -0
  63. package/build/esm/index.js +23 -0
  64. package/build/esm/index.js.map +1 -0
  65. package/build/esm/internal/__test__/mockPlatformClient.js +36 -0
  66. package/build/esm/internal/__test__/mockPlatformClient.js.map +1 -0
  67. package/build/esm/internal/ids.js +23 -0
  68. package/build/esm/internal/ids.js.map +1 -0
  69. package/build/esm/internal/openAi.js +293 -0
  70. package/build/esm/internal/openAi.js.map +1 -0
  71. package/build/esm/internal/options.js +58 -0
  72. package/build/esm/internal/options.js.map +1 -0
  73. package/build/esm/internal/runStep.js +107 -0
  74. package/build/esm/internal/runStep.js.map +1 -0
  75. package/build/esm/internal/streamStep.js +223 -0
  76. package/build/esm/internal/streamStep.js.map +1 -0
  77. package/build/esm/internal/uiMessageBridge.js +55 -0
  78. package/build/esm/internal/uiMessageBridge.js.map +1 -0
  79. package/build/esm/lmsChatTransport.js +185 -0
  80. package/build/esm/lmsChatTransport.js.map +1 -0
  81. package/build/esm/model.js +74 -0
  82. package/build/esm/model.js.map +1 -0
  83. package/build/esm/public/ai-sdk.js +18 -0
  84. package/build/esm/public/ai-sdk.js.map +1 -0
  85. package/build/esm/streamText.js +210 -0
  86. package/build/esm/streamText.js.map +1 -0
  87. package/build/esm/types.js +2 -0
  88. package/build/esm/types.js.map +1 -0
  89. package/build/esm/uiMessage.js +34 -0
  90. package/build/esm/uiMessage.js.map +1 -0
  91. package/build/types/ai-sdk/convert-prompt.d.ts +19 -0
  92. package/build/types/ai-sdk/convert-prompt.d.ts.map +1 -0
  93. package/build/types/ai-sdk/foundry-chat-language-model.d.ts +20 -0
  94. package/build/types/ai-sdk/foundry-chat-language-model.d.ts.map +1 -0
  95. package/build/types/ai-sdk/map-finish-reason.d.ts +2 -0
  96. package/build/types/ai-sdk/map-finish-reason.d.ts.map +1 -0
  97. package/build/types/ai-sdk/provider.d.ts +46 -0
  98. package/build/types/ai-sdk/provider.d.ts.map +1 -0
  99. package/build/types/ai-sdk/types.d.ts +1 -0
  100. package/build/types/ai-sdk/types.d.ts.map +1 -0
  101. package/build/types/generateText.d.ts +56 -0
  102. package/build/types/generateText.d.ts.map +1 -0
  103. package/build/types/index.d.ts +12 -0
  104. package/build/types/index.d.ts.map +1 -0
  105. package/build/types/internal/__test__/mockPlatformClient.d.ts +13 -0
  106. package/build/types/internal/__test__/mockPlatformClient.d.ts.map +1 -0
  107. package/build/types/internal/ids.d.ts +1 -0
  108. package/build/types/internal/ids.d.ts.map +1 -0
  109. package/build/types/internal/openAi.d.ts +107 -0
  110. package/build/types/internal/openAi.d.ts.map +1 -0
  111. package/build/types/internal/options.d.ts +4 -0
  112. package/build/types/internal/options.d.ts.map +1 -0
  113. package/build/types/internal/runStep.d.ts +29 -0
  114. package/build/types/internal/runStep.d.ts.map +1 -0
  115. package/build/types/internal/streamStep.d.ts +52 -0
  116. package/build/types/internal/streamStep.d.ts.map +1 -0
  117. package/build/types/internal/uiMessageBridge.d.ts +15 -0
  118. package/build/types/internal/uiMessageBridge.d.ts.map +1 -0
  119. package/build/types/lmsChatTransport.d.ts +35 -0
  120. package/build/types/lmsChatTransport.d.ts.map +1 -0
  121. package/build/types/model.d.ts +42 -0
  122. package/build/types/model.d.ts.map +1 -0
  123. package/build/types/public/ai-sdk.d.ts +2 -0
  124. package/build/types/public/ai-sdk.d.ts.map +1 -0
  125. package/build/types/streamText.d.ts +82 -0
  126. package/build/types/streamText.d.ts.map +1 -0
  127. package/build/types/types.d.ts +189 -0
  128. package/build/types/types.d.ts.map +1 -0
  129. package/build/types/uiMessage.d.ts +85 -0
  130. package/build/types/uiMessage.d.ts.map +1 -0
  131. package/package.json +87 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # @osdk/aip-core
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 86cc68c: Add AI SDK custom provider under `@osdk/aip-core/ai-sdk` implementing LanguageModelV3 with `doGenerate` and `doStream`, enabling usage with the `ai` package's `generateText` and `streamText` functions.
8
+ - f747fa3: Add `@osdk/aip-core` — the AIP SDK's chat completion primitives, backed by the Foundry Language Model Service's OpenAI-compatible proxy. Construct a model via `foundryModel({ client, model })` and call `generateText` for non-streaming completions or `streamText` for streaming. `LmsChatTransport` plugs into UI hooks; `useChat` is exposed from `@osdk/react/experimental/aip` and returns `messages`, `status`, `sendMessage`, `regenerate`, `stop`, `clearError`, and accepts a `transport` override. v0 is text-only and single-step — tool round-trips, multi-step loops, image/file content, Zod tool schemas, and stream resume are deferred.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [d9c891e]
13
+ - Updated dependencies [f12977d]
14
+ - Updated dependencies [eb36e21]
15
+ - Updated dependencies [d892397]
16
+ - Updated dependencies [c5a6047]
17
+ - Updated dependencies [45be476]
18
+ - Updated dependencies [20e9678]
19
+ - @osdk/language-models@0.5.0
20
+ - @osdk/client@2.14.0
package/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # @osdk/aip-core
2
+
3
+ Core building blocks for AIP applications backed by the Foundry Language Model Service (LMS). Provides streaming chat completions, tool calling, and an AI SDK adapter.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @osdk/aip-core
9
+ ```
10
+
11
+ Peer dependencies:
12
+
13
+ ```sh
14
+ pnpm add @osdk/client @osdk/language-models
15
+ ```
16
+
17
+ ## Native API
18
+
19
+ ### `foundryModel`
20
+
21
+ Creates a language model handle for Foundry LMS.
22
+
23
+ ```ts
24
+ import { foundryModel } from "@osdk/aip-core";
25
+
26
+ const model = foundryModel({
27
+ client, // PlatformClient from @osdk/client
28
+ model: "gpt-4o", // LMS model API name or a ModelIdentifier
29
+ });
30
+ ```
31
+
32
+ The `model` parameter accepts either a string (LMS API name like `"gpt-4o"`) or a structured identifier:
33
+
34
+ ```ts
35
+ // Built-in LMS model
36
+ { type: "lmsModel", apiName: "gpt-4o" }
37
+
38
+ // Customer-registered model
39
+ { type: "registeredModel", registeredModelRid: "ri.language-model-service..." }
40
+ ```
41
+
42
+ ### `generateText`
43
+
44
+ Performs a single chat completion and returns the full result.
45
+
46
+ ```ts
47
+ import { foundryModel, generateText } from "@osdk/aip-core";
48
+
49
+ const model = foundryModel({ client, model: "gpt-4o" });
50
+
51
+ const result = await generateText({
52
+ model,
53
+ prompt: "Summarize the key points of this document.",
54
+ });
55
+
56
+ console.log(result.text);
57
+ console.log(result.usage); // { inputTokens, outputTokens, totalTokens, ... }
58
+ ```
59
+
60
+ #### With system instructions
61
+
62
+ ```ts
63
+ const result = await generateText({
64
+ model,
65
+ system: "You are a helpful assistant that responds concisely.",
66
+ messages: [
67
+ { role: "user", content: "What is TypeScript?" },
68
+ ],
69
+ });
70
+ ```
71
+
72
+ #### With tool calling
73
+
74
+ ```ts
75
+ const result = await generateText({
76
+ model,
77
+ prompt: "What's the weather in London?",
78
+ tools: {
79
+ getWeather: {
80
+ description: "Get the current weather for a location",
81
+ inputSchema: {
82
+ type: "object",
83
+ properties: {
84
+ location: { type: "string" },
85
+ },
86
+ required: ["location"],
87
+ },
88
+ },
89
+ },
90
+ toolChoice: "auto",
91
+ });
92
+
93
+ for (const call of result.toolCalls) {
94
+ console.log(call.toolName, call.input);
95
+ }
96
+ ```
97
+
98
+ #### Callbacks
99
+
100
+ ```ts
101
+ const result = await generateText({
102
+ model,
103
+ prompt: "Hello",
104
+ onStepFinish: (step) => {
105
+ console.log("Step finished:", step.finishReason);
106
+ },
107
+ onFinish: (event) => {
108
+ console.log("Total usage:", event.totalUsage);
109
+ },
110
+ });
111
+ ```
112
+
113
+ #### Sampling parameters
114
+
115
+ | Parameter | Description |
116
+ | ------------------ | -------------------------------- |
117
+ | `maxOutputTokens` | Maximum tokens to generate |
118
+ | `temperature` | Randomness (0 = deterministic) |
119
+ | `topP` | Nucleus sampling threshold |
120
+ | `presencePenalty` | Penalize repeated topics |
121
+ | `frequencyPenalty` | Penalize repeated tokens |
122
+ | `stopSequences` | Stop generation at these strings |
123
+ | `seed` | Deterministic sampling seed |
124
+
125
+ ## AI SDK Provider
126
+
127
+ `@osdk/aip-core` ships a custom provider for the [AI SDK](https://ai-sdk.dev), allowing you to use Foundry LMS models with `generateText`, `streamText`, and other AI SDK functions.
128
+
129
+ ### Additional dependencies
130
+
131
+ ```sh
132
+ pnpm add ai @ai-sdk/provider
133
+ ```
134
+
135
+ ### Usage
136
+
137
+ ```ts
138
+ import { createFoundryAI } from "@osdk/aip-core/ai-sdk";
139
+ import { generateText } from "ai";
140
+
141
+ const foundryAI = createFoundryAI({ client });
142
+
143
+ const { text } = await generateText({
144
+ model: foundryAI("gpt-4o"),
145
+ prompt: "Hello, world",
146
+ });
147
+ ```
148
+
149
+ ### Streaming
150
+
151
+ ```ts
152
+ import { createFoundryAI } from "@osdk/aip-core/ai-sdk";
153
+ import { streamText } from "ai";
154
+
155
+ const foundryAI = createFoundryAI({ client });
156
+
157
+ const result = streamText({
158
+ model: foundryAI("gpt-4o"),
159
+ prompt: "Write a poem about TypeScript.",
160
+ });
161
+
162
+ for await (const chunk of result.textStream) {
163
+ process.stdout.write(chunk);
164
+ }
165
+ ```
166
+
167
+ ### Registered models
168
+
169
+ ```ts
170
+ const model = foundryAI({
171
+ type: "registeredModel",
172
+ registeredModelRid: "ri.language-model-service...",
173
+ });
174
+ ```
175
+
176
+ ### Tool calling with AI SDK
177
+
178
+ ```ts
179
+ import { createFoundryAI } from "@osdk/aip-core/ai-sdk";
180
+ import { generateText, tool } from "ai";
181
+ import { z } from "zod";
182
+
183
+ const foundryAI = createFoundryAI({ client });
184
+
185
+ const result = await generateText({
186
+ model: foundryAI("gpt-4o"),
187
+ prompt: "What's the weather in London?",
188
+ tools: {
189
+ getWeather: tool({
190
+ description: "Get the current weather for a location",
191
+ parameters: z.object({ location: z.string() }),
192
+ execute: async ({ location }) => {
193
+ return { temperature: 18, condition: "cloudy" };
194
+ },
195
+ }),
196
+ },
197
+ });
198
+ ```
199
+
200
+ ## v0 Limitations
201
+
202
+ The current release (v0) has the following limitations. Unsupported options surface as warnings in the result rather than throwing errors.
203
+
204
+ - **Single-step only** — multi-step tool loops (`stopWhen`, `prepareStep`) are not yet supported
205
+ - **Text content only** — image and file parts in messages are ignored with a warning
206
+ - **No structured output** — JSON response format is not yet wired
207
+ - **No `topK`** — the Foundry LMS OpenAI proxy does not accept this parameter
208
+
209
+ ## License
210
+
211
+ Apache-2.0
package/ai-sdk.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export * from "./build/cjs/public/ai-sdk.cjs";
@@ -0,0 +1,136 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export function convertPrompt(prompt, warnings) {
18
+ const messages = [];
19
+ for (const message of prompt) {
20
+ messages.push(...convertMessage(message, warnings));
21
+ }
22
+ return messages;
23
+ }
24
+ function convertMessage(message, warnings) {
25
+ switch (message.role) {
26
+ case "system":
27
+ return [{
28
+ role: "system",
29
+ content: message.content
30
+ }];
31
+ case "user":
32
+ {
33
+ const parts = [];
34
+ for (const part of message.content) {
35
+ switch (part.type) {
36
+ case "text":
37
+ parts.push({
38
+ type: "text",
39
+ text: part.text
40
+ });
41
+ break;
42
+ case "file":
43
+ warnings.push({
44
+ type: "unsupported",
45
+ feature: "user file content",
46
+ details: "File content in user messages is not supported in v0 — ignored"
47
+ });
48
+ break;
49
+ }
50
+ }
51
+ if (parts.length === 0) {
52
+ parts.push({
53
+ type: "text",
54
+ text: ""
55
+ });
56
+ }
57
+ return [{
58
+ role: "user",
59
+ content: parts
60
+ }];
61
+ }
62
+ case "assistant":
63
+ {
64
+ let text = "";
65
+ const toolCalls = [];
66
+ for (const part of message.content) {
67
+ switch (part.type) {
68
+ case "text":
69
+ text += part.text;
70
+ break;
71
+ case "tool-call":
72
+ toolCalls.push({
73
+ id: part.toolCallId,
74
+ type: "function",
75
+ function: {
76
+ name: part.toolName,
77
+ arguments: typeof part.input === "string" ? part.input : JSON.stringify(part.input ?? {})
78
+ }
79
+ });
80
+ break;
81
+ case "reasoning":
82
+ case "file":
83
+ case "tool-result":
84
+ warnings.push({
85
+ type: "unsupported",
86
+ feature: `assistant ${part.type} content`,
87
+ details: `"${part.type}" parts in assistant messages are not supported in v0 — ignored`
88
+ });
89
+ break;
90
+ }
91
+ }
92
+ return [{
93
+ role: "assistant",
94
+ content: text.length > 0 ? text : null,
95
+ tool_calls: toolCalls.length > 0 ? toolCalls : undefined
96
+ }];
97
+ }
98
+ case "tool":
99
+ return message.content.filter(part => {
100
+ if (part.type === "tool-result") return true;
101
+ warnings.push({
102
+ type: "unsupported",
103
+ feature: `tool ${part.type} content`,
104
+ details: `"${part.type}" parts in tool messages are not supported in v0 — ignored`
105
+ });
106
+ return false;
107
+ }).map(part => ({
108
+ role: "tool",
109
+ content: stringifyToolResult(part.output, warnings),
110
+ tool_call_id: part.toolCallId
111
+ }));
112
+ }
113
+ }
114
+ function stringifyToolResult(output, warnings) {
115
+ switch (output.type) {
116
+ case "text":
117
+ case "error-text":
118
+ return output.value;
119
+ case "json":
120
+ case "error-json":
121
+ return JSON.stringify(output.value);
122
+ case "execution-denied":
123
+ return output.reason ?? "Tool execution denied";
124
+ case "content":
125
+ return output.value.map(c => {
126
+ if (c.type === "text") return c.text;
127
+ warnings.push({
128
+ type: "unsupported",
129
+ feature: "tool result media content",
130
+ details: "Non-text tool result content is not supported in v0 — ignored"
131
+ });
132
+ return "";
133
+ }).filter(s => s.length > 0).join("\n");
134
+ }
135
+ }
136
+ //# sourceMappingURL=convert-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-prompt.js","names":["convertPrompt","prompt","warnings","messages","message","push","convertMessage","role","content","parts","part","type","text","feature","details","length","toolCalls","id","toolCallId","function","name","toolName","arguments","input","JSON","stringify","tool_calls","undefined","filter","map","stringifyToolResult","output","tool_call_id","value","reason","c","s","join"],"sources":["convert-prompt.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LanguageModelV3Message,\n LanguageModelV3Prompt,\n LanguageModelV3ToolResultOutput,\n SharedV3Warning,\n} from \"@ai-sdk/provider\";\n\nexport interface OpenAiMessage {\n role: \"system\" | \"user\" | \"assistant\" | \"tool\";\n content: string | Array<{ type: \"text\"; text: string }> | null;\n tool_calls?: Array<OpenAiAssistantToolCall>;\n tool_call_id?: string;\n}\n\nexport interface OpenAiAssistantToolCall {\n id: string;\n type: \"function\";\n function: { name: string; arguments: string };\n}\n\nexport function convertPrompt(\n prompt: LanguageModelV3Prompt,\n warnings: Array<SharedV3Warning>,\n): Array<OpenAiMessage> {\n const messages: Array<OpenAiMessage> = [];\n\n for (const message of prompt) {\n messages.push(...convertMessage(message, warnings));\n }\n\n return messages;\n}\n\nfunction convertMessage(\n message: LanguageModelV3Message,\n warnings: Array<SharedV3Warning>,\n): Array<OpenAiMessage> {\n switch (message.role) {\n case \"system\":\n return [{ role: \"system\", content: message.content }];\n\n case \"user\": {\n const parts: Array<{ type: \"text\"; text: string }> = [];\n for (const part of message.content) {\n switch (part.type) {\n case \"text\":\n parts.push({ type: \"text\", text: part.text });\n break;\n case \"file\":\n warnings.push({\n type: \"unsupported\",\n feature: \"user file content\",\n details:\n \"File content in user messages is not supported in v0 — ignored\",\n });\n break;\n }\n }\n if (parts.length === 0) {\n parts.push({ type: \"text\", text: \"\" });\n }\n return [{ role: \"user\", content: parts }];\n }\n\n case \"assistant\": {\n let text = \"\";\n const toolCalls: Array<OpenAiAssistantToolCall> = [];\n for (const part of message.content) {\n switch (part.type) {\n case \"text\":\n text += part.text;\n break;\n case \"tool-call\":\n toolCalls.push({\n id: part.toolCallId,\n type: \"function\",\n function: {\n name: part.toolName,\n arguments: typeof part.input === \"string\"\n ? part.input\n : JSON.stringify(part.input ?? {}),\n },\n });\n break;\n case \"reasoning\":\n case \"file\":\n case \"tool-result\":\n warnings.push({\n type: \"unsupported\",\n feature: `assistant ${part.type} content`,\n details:\n `\"${part.type}\" parts in assistant messages are not supported in v0 — ignored`,\n });\n break;\n }\n }\n return [{\n role: \"assistant\",\n content: text.length > 0 ? text : null,\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n }];\n }\n\n case \"tool\":\n return message.content\n .filter(\n (part): part is Extract<typeof part, { type: \"tool-result\" }> => {\n if (part.type === \"tool-result\") return true;\n warnings.push({\n type: \"unsupported\",\n feature: `tool ${part.type} content`,\n details:\n `\"${part.type}\" parts in tool messages are not supported in v0 — ignored`,\n });\n return false;\n },\n )\n .map((part) => ({\n role: \"tool\" as const,\n content: stringifyToolResult(part.output, warnings),\n tool_call_id: part.toolCallId,\n }));\n }\n}\n\nfunction stringifyToolResult(\n output: LanguageModelV3ToolResultOutput,\n warnings: Array<SharedV3Warning>,\n): string {\n switch (output.type) {\n case \"text\":\n case \"error-text\":\n return output.value;\n case \"json\":\n case \"error-json\":\n return JSON.stringify(output.value);\n case \"execution-denied\":\n return output.reason ?? \"Tool execution denied\";\n case \"content\":\n return output.value\n .map((c) => {\n if (c.type === \"text\") return c.text;\n warnings.push({\n type: \"unsupported\",\n feature: \"tool result media content\",\n details:\n \"Non-text tool result content is not supported in v0 — ignored\",\n });\n return \"\";\n })\n .filter((s) => s.length > 0)\n .join(\"\\n\");\n }\n}\n"],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