opencode-puter-auth 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -153,6 +153,32 @@ opencode run "Hello" --model=puter/claude-opus-4-5
153
153
  | `puter/gemini-2.5-pro` | Best Gemini | 1M | Huge context |
154
154
  | `puter/gemini-2.5-flash` | Fast Gemini | 1M | Quick analysis |
155
155
 
156
+ ## AI SDK Provider (Standalone Usage)
157
+
158
+ You can also use the Puter AI SDK provider directly in your own applications:
159
+
160
+ ```typescript
161
+ import { createPuter } from 'opencode-puter-auth';
162
+
163
+ // Create a Puter provider instance
164
+ const puter = createPuter({
165
+ authToken: 'your-puter-auth-token',
166
+ });
167
+
168
+ // Use with AI SDK
169
+ const model = puter('claude-opus-4-5');
170
+
171
+ // Or use specific methods
172
+ const chatModel = puter.chat('claude-sonnet-4-5');
173
+ const languageModel = puter.languageModel('gpt-4o');
174
+ ```
175
+
176
+ This implements the full AI SDK v3 specification with:
177
+ - Non-streaming and streaming generation
178
+ - Tool/function calling support
179
+ - Reasoning/thinking token support
180
+ - Proper finish reason mapping
181
+
156
182
  ## Configuration
157
183
 
158
184
  Create `~/.config/opencode/puter.json` for advanced settings:
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Puter AI SDK Provider
3
+ *
4
+ * This module exports the Puter provider for use with the Vercel AI SDK.
5
+ * It enables FREE, UNLIMITED access to Claude Opus 4.5, Sonnet 4.5, GPT-5,
6
+ * Gemini, and 500+ AI models through Puter.com's "User-Pays" model.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { createPuter, puter } from 'opencode-puter-auth/ai-provider';
11
+ *
12
+ * // Create a custom provider instance
13
+ * const myPuter = createPuter({
14
+ * authToken: 'your-puter-auth-token',
15
+ * });
16
+ *
17
+ * // Use the model
18
+ * const model = myPuter('claude-opus-4-5');
19
+ *
20
+ * // Or use the default provider (requires PUTER_AUTH_TOKEN env var)
21
+ * const defaultModel = puter('claude-opus-4-5');
22
+ * ```
23
+ */
24
+ export { createPuter, puter } from './puter-provider.js';
25
+ export type { PuterProvider } from './puter-provider.js';
26
+ export { PuterChatLanguageModel } from './puter-chat-language-model.js';
27
+ export type { PuterChatSettings, PuterProviderConfig, PuterChatConfig, } from './puter-chat-settings.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Puter AI SDK Provider
3
+ *
4
+ * This module exports the Puter provider for use with the Vercel AI SDK.
5
+ * It enables FREE, UNLIMITED access to Claude Opus 4.5, Sonnet 4.5, GPT-5,
6
+ * Gemini, and 500+ AI models through Puter.com's "User-Pays" model.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { createPuter, puter } from 'opencode-puter-auth/ai-provider';
11
+ *
12
+ * // Create a custom provider instance
13
+ * const myPuter = createPuter({
14
+ * authToken: 'your-puter-auth-token',
15
+ * });
16
+ *
17
+ * // Use the model
18
+ * const model = myPuter('claude-opus-4-5');
19
+ *
20
+ * // Or use the default provider (requires PUTER_AUTH_TOKEN env var)
21
+ * const defaultModel = puter('claude-opus-4-5');
22
+ * ```
23
+ */
24
+ // Provider exports
25
+ export { createPuter, puter } from './puter-provider.js';
26
+ // Model exports
27
+ export { PuterChatLanguageModel } from './puter-chat-language-model.js';
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai-provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,mBAAmB;AACnB,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGzD,gBAAgB;AAChB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Puter Chat Language Model
3
+ *
4
+ * Implements the AI SDK LanguageModelV3 interface for Puter.com's AI API.
5
+ * This enables Puter to work as a proper AI SDK provider in OpenCode.
6
+ */
7
+ import type { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from '@ai-sdk/provider';
8
+ import type { PuterChatSettings, PuterChatConfig } from './puter-chat-settings.js';
9
+ /**
10
+ * Puter Chat Language Model implementing LanguageModelV3.
11
+ */
12
+ export declare class PuterChatLanguageModel implements LanguageModelV3 {
13
+ readonly specificationVersion: "v3";
14
+ readonly provider: string;
15
+ readonly modelId: string;
16
+ private readonly settings;
17
+ private readonly config;
18
+ constructor(modelId: string, settings: PuterChatSettings, config: PuterChatConfig);
19
+ /**
20
+ * Supported URL patterns for native file handling.
21
+ * Puter doesn't natively handle URLs, so we return an empty map.
22
+ */
23
+ get supportedUrls(): Record<string, RegExp[]>;
24
+ /**
25
+ * Convert AI SDK prompt to Puter message format.
26
+ */
27
+ private convertPromptToMessages;
28
+ /**
29
+ * Convert AI SDK tools to Puter tool format.
30
+ */
31
+ private convertTools;
32
+ /**
33
+ * Build the request body for Puter API.
34
+ */
35
+ private buildRequestBody;
36
+ /**
37
+ * Map Puter finish reason to AI SDK format.
38
+ */
39
+ private mapFinishReason;
40
+ /**
41
+ * Map Puter usage to AI SDK format.
42
+ */
43
+ private mapUsage;
44
+ /**
45
+ * Non-streaming generation.
46
+ */
47
+ doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
48
+ /**
49
+ * Streaming generation.
50
+ */
51
+ doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
52
+ }
53
+ //# sourceMappingURL=puter-chat-language-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puter-chat-language-model.d.ts","sourceRoot":"","sources":["../../src/ai-provider/puter-chat-language-model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,6BAA6B,EAC7B,2BAA2B,EAW5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAuFnF;;GAEG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D,QAAQ,CAAC,oBAAoB,EAAG,IAAI,CAAU;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;gBAGvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,eAAe;IAQzB;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAE5C;IAED;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA4E/B;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAgBvB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAgBhB;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,6BAA6B,CAAC;IA4D7F;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmL1F"}
@@ -0,0 +1,405 @@
1
+ /**
2
+ * Puter Chat Language Model
3
+ *
4
+ * Implements the AI SDK LanguageModelV3 interface for Puter.com's AI API.
5
+ * This enables Puter to work as a proper AI SDK provider in OpenCode.
6
+ */
7
+ /**
8
+ * Puter Chat Language Model implementing LanguageModelV3.
9
+ */
10
+ export class PuterChatLanguageModel {
11
+ specificationVersion = 'v3';
12
+ provider;
13
+ modelId;
14
+ settings;
15
+ config;
16
+ constructor(modelId, settings, config) {
17
+ this.modelId = modelId;
18
+ this.settings = settings;
19
+ this.config = config;
20
+ this.provider = config.provider;
21
+ }
22
+ /**
23
+ * Supported URL patterns for native file handling.
24
+ * Puter doesn't natively handle URLs, so we return an empty map.
25
+ */
26
+ get supportedUrls() {
27
+ return {};
28
+ }
29
+ /**
30
+ * Convert AI SDK prompt to Puter message format.
31
+ */
32
+ convertPromptToMessages(prompt) {
33
+ const messages = [];
34
+ for (const message of prompt) {
35
+ if (message.role === 'system') {
36
+ messages.push({
37
+ role: 'system',
38
+ content: message.content,
39
+ });
40
+ }
41
+ else if (message.role === 'user') {
42
+ // Extract text from user message parts
43
+ const textParts = message.content
44
+ .filter((part) => part.type === 'text')
45
+ .map(part => part.text);
46
+ messages.push({
47
+ role: 'user',
48
+ content: textParts.join('\n'),
49
+ });
50
+ }
51
+ else if (message.role === 'assistant') {
52
+ // Handle assistant messages with potential tool calls
53
+ const textParts = message.content
54
+ .filter((part) => part.type === 'text')
55
+ .map(part => part.text);
56
+ const toolCallParts = message.content
57
+ .filter((part) => part.type === 'tool-call');
58
+ const puterMessage = {
59
+ role: 'assistant',
60
+ content: textParts.join('\n') || '',
61
+ };
62
+ if (toolCallParts.length > 0) {
63
+ puterMessage.tool_calls = toolCallParts.map(tc => ({
64
+ id: tc.toolCallId,
65
+ type: 'function',
66
+ function: {
67
+ name: tc.toolName,
68
+ arguments: typeof tc.input === 'string' ? tc.input : JSON.stringify(tc.input),
69
+ },
70
+ }));
71
+ }
72
+ messages.push(puterMessage);
73
+ }
74
+ else if (message.role === 'tool') {
75
+ // Handle tool results
76
+ for (const part of message.content) {
77
+ if (part.type === 'tool-result') {
78
+ const toolResultPart = part;
79
+ const output = toolResultPart.output;
80
+ let contentStr;
81
+ if (typeof output === 'string') {
82
+ contentStr = output;
83
+ }
84
+ else if (Array.isArray(output)) {
85
+ // Handle array of output parts
86
+ contentStr = output.map(p => {
87
+ if (p.type === 'text')
88
+ return p.text;
89
+ return JSON.stringify(p);
90
+ }).join('\n');
91
+ }
92
+ else {
93
+ contentStr = JSON.stringify(output);
94
+ }
95
+ messages.push({
96
+ role: 'tool',
97
+ content: contentStr,
98
+ tool_call_id: toolResultPart.toolCallId,
99
+ });
100
+ }
101
+ }
102
+ }
103
+ }
104
+ return messages;
105
+ }
106
+ /**
107
+ * Convert AI SDK tools to Puter tool format.
108
+ */
109
+ convertTools(tools) {
110
+ if (!tools || tools.length === 0)
111
+ return undefined;
112
+ return tools.map(tool => ({
113
+ type: 'function',
114
+ function: {
115
+ name: tool.name,
116
+ description: tool.description || '',
117
+ parameters: tool.inputSchema,
118
+ },
119
+ }));
120
+ }
121
+ /**
122
+ * Build the request body for Puter API.
123
+ */
124
+ buildRequestBody(options, streaming) {
125
+ const messages = this.convertPromptToMessages(options.prompt);
126
+ // Filter to only function tools
127
+ const functionTools = options.tools?.filter((tool) => tool.type === 'function');
128
+ const tools = this.convertTools(functionTools);
129
+ return {
130
+ interface: 'puter-chat-completion',
131
+ service: 'ai-chat',
132
+ method: 'complete',
133
+ args: {
134
+ messages,
135
+ model: this.modelId,
136
+ stream: streaming,
137
+ max_tokens: options.maxOutputTokens ?? this.settings.maxTokens,
138
+ temperature: options.temperature ?? this.settings.temperature,
139
+ top_p: options.topP ?? this.settings.topP,
140
+ top_k: options.topK ?? this.settings.topK,
141
+ stop: options.stopSequences ?? this.settings.stopSequences,
142
+ tools,
143
+ },
144
+ auth_token: this.config.headers()['Authorization']?.replace('Bearer ', '') || '',
145
+ };
146
+ }
147
+ /**
148
+ * Map Puter finish reason to AI SDK format.
149
+ */
150
+ mapFinishReason(reason) {
151
+ const unified = (() => {
152
+ if (!reason)
153
+ return 'other';
154
+ if (reason === 'stop' || reason === 'end_turn')
155
+ return 'stop';
156
+ if (reason === 'length' || reason === 'max_tokens')
157
+ return 'length';
158
+ if (reason === 'tool_calls' || reason === 'tool_use')
159
+ return 'tool-calls';
160
+ if (reason === 'content_filter')
161
+ return 'content-filter';
162
+ return 'other';
163
+ })();
164
+ return {
165
+ unified,
166
+ raw: reason,
167
+ };
168
+ }
169
+ /**
170
+ * Map Puter usage to AI SDK format.
171
+ */
172
+ mapUsage(usage) {
173
+ return {
174
+ inputTokens: {
175
+ total: usage?.prompt_tokens,
176
+ noCache: undefined,
177
+ cacheRead: undefined,
178
+ cacheWrite: undefined,
179
+ },
180
+ outputTokens: {
181
+ total: usage?.completion_tokens,
182
+ text: undefined,
183
+ reasoning: undefined,
184
+ },
185
+ };
186
+ }
187
+ /**
188
+ * Non-streaming generation.
189
+ */
190
+ async doGenerate(options) {
191
+ const requestBody = this.buildRequestBody(options, false);
192
+ const warnings = [];
193
+ const response = await this.config.fetch(`${this.config.baseURL}/drivers/call`, {
194
+ method: 'POST',
195
+ headers: {
196
+ 'Content-Type': 'application/json',
197
+ ...this.config.headers(),
198
+ },
199
+ body: JSON.stringify(requestBody),
200
+ signal: options.abortSignal,
201
+ });
202
+ if (!response.ok) {
203
+ const errorText = await response.text();
204
+ throw new Error(`Puter API error (${response.status}): ${errorText}`);
205
+ }
206
+ const puterResponse = await response.json();
207
+ if (puterResponse.error) {
208
+ throw new Error(`Puter API error: ${puterResponse.error.message}`);
209
+ }
210
+ const result = puterResponse.result;
211
+ const content = [];
212
+ // Add text content
213
+ if (result?.message?.content) {
214
+ content.push({
215
+ type: 'text',
216
+ text: result.message.content,
217
+ });
218
+ }
219
+ // Add tool calls
220
+ if (result?.message?.tool_calls) {
221
+ for (const tc of result.message.tool_calls) {
222
+ content.push({
223
+ type: 'tool-call',
224
+ toolCallId: tc.id,
225
+ toolName: tc.function.name,
226
+ input: tc.function.arguments,
227
+ });
228
+ }
229
+ }
230
+ return {
231
+ content,
232
+ finishReason: this.mapFinishReason(result?.finish_reason),
233
+ usage: this.mapUsage(result?.usage),
234
+ warnings,
235
+ request: { body: requestBody },
236
+ response: {
237
+ body: puterResponse,
238
+ },
239
+ };
240
+ }
241
+ /**
242
+ * Streaming generation.
243
+ */
244
+ async doStream(options) {
245
+ const requestBody = this.buildRequestBody(options, true);
246
+ const warnings = [];
247
+ const generateId = this.config.generateId;
248
+ const response = await this.config.fetch(`${this.config.baseURL}/drivers/call`, {
249
+ method: 'POST',
250
+ headers: {
251
+ 'Content-Type': 'application/json',
252
+ ...this.config.headers(),
253
+ },
254
+ body: JSON.stringify(requestBody),
255
+ signal: options.abortSignal,
256
+ });
257
+ if (!response.ok) {
258
+ const errorText = await response.text();
259
+ throw new Error(`Puter API error (${response.status}): ${errorText}`);
260
+ }
261
+ if (!response.body) {
262
+ throw new Error('No response body for streaming');
263
+ }
264
+ const self = this;
265
+ let textId = null;
266
+ let reasoningId = null;
267
+ const toolCallIds = new Map();
268
+ let buffer = '';
269
+ const transformStream = new TransformStream({
270
+ start(controller) {
271
+ // Emit stream-start
272
+ controller.enqueue({
273
+ type: 'stream-start',
274
+ warnings,
275
+ });
276
+ },
277
+ async transform(chunk, controller) {
278
+ const decoder = new TextDecoder();
279
+ buffer += decoder.decode(chunk, { stream: true });
280
+ const lines = buffer.split('\n');
281
+ buffer = lines.pop() || '';
282
+ for (const line of lines) {
283
+ if (!line.trim())
284
+ continue;
285
+ try {
286
+ const puterChunk = JSON.parse(line);
287
+ // Handle text content
288
+ if (puterChunk.text) {
289
+ if (!textId) {
290
+ textId = generateId();
291
+ controller.enqueue({
292
+ type: 'text-start',
293
+ id: textId,
294
+ });
295
+ }
296
+ controller.enqueue({
297
+ type: 'text-delta',
298
+ id: textId,
299
+ delta: puterChunk.text,
300
+ });
301
+ }
302
+ // Handle reasoning content
303
+ if (puterChunk.reasoning) {
304
+ if (!reasoningId) {
305
+ reasoningId = generateId();
306
+ controller.enqueue({
307
+ type: 'reasoning-start',
308
+ id: reasoningId,
309
+ });
310
+ }
311
+ controller.enqueue({
312
+ type: 'reasoning-delta',
313
+ id: reasoningId,
314
+ delta: puterChunk.reasoning,
315
+ });
316
+ }
317
+ // Handle tool calls
318
+ if (puterChunk.tool_calls) {
319
+ for (const tc of puterChunk.tool_calls) {
320
+ if (!toolCallIds.has(tc.id)) {
321
+ const streamId = generateId();
322
+ toolCallIds.set(tc.id, streamId);
323
+ controller.enqueue({
324
+ type: 'tool-input-start',
325
+ id: streamId,
326
+ toolName: tc.function.name,
327
+ });
328
+ }
329
+ const streamId = toolCallIds.get(tc.id);
330
+ controller.enqueue({
331
+ type: 'tool-input-delta',
332
+ id: streamId,
333
+ delta: tc.function.arguments,
334
+ });
335
+ }
336
+ }
337
+ // Handle completion
338
+ if (puterChunk.done || puterChunk.finish_reason) {
339
+ // Close text stream
340
+ if (textId) {
341
+ controller.enqueue({
342
+ type: 'text-end',
343
+ id: textId,
344
+ });
345
+ }
346
+ // Close reasoning stream
347
+ if (reasoningId) {
348
+ controller.enqueue({
349
+ type: 'reasoning-end',
350
+ id: reasoningId,
351
+ });
352
+ }
353
+ // Close tool call streams and emit tool-call events
354
+ for (const [, streamId] of toolCallIds) {
355
+ controller.enqueue({
356
+ type: 'tool-input-end',
357
+ id: streamId,
358
+ });
359
+ }
360
+ // Emit finish
361
+ controller.enqueue({
362
+ type: 'finish',
363
+ usage: self.mapUsage(puterChunk.usage),
364
+ finishReason: self.mapFinishReason(puterChunk.finish_reason),
365
+ });
366
+ }
367
+ }
368
+ catch {
369
+ // Skip malformed lines
370
+ }
371
+ }
372
+ },
373
+ flush(controller) {
374
+ // Process any remaining buffer
375
+ if (buffer.trim()) {
376
+ try {
377
+ const puterChunk = JSON.parse(buffer);
378
+ if (puterChunk.done || puterChunk.finish_reason) {
379
+ if (textId) {
380
+ controller.enqueue({
381
+ type: 'text-end',
382
+ id: textId,
383
+ });
384
+ }
385
+ controller.enqueue({
386
+ type: 'finish',
387
+ usage: self.mapUsage(puterChunk.usage),
388
+ finishReason: self.mapFinishReason(puterChunk.finish_reason),
389
+ });
390
+ }
391
+ }
392
+ catch {
393
+ // Ignore
394
+ }
395
+ }
396
+ },
397
+ });
398
+ const stream = response.body.pipeThrough(transformStream);
399
+ return {
400
+ stream,
401
+ request: { body: requestBody },
402
+ };
403
+ }
404
+ }
405
+ //# sourceMappingURL=puter-chat-language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puter-chat-language-model.js","sourceRoot":"","sources":["../../src/ai-provider/puter-chat-language-model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyGH;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACxB,oBAAoB,GAAG,IAAa,CAAC;IACrC,QAAQ,CAAS;IACjB,OAAO,CAAS;IAER,QAAQ,CAAoB;IAC5B,MAAM,CAAkB;IAEzC,YACE,OAAe,EACf,QAA2B,EAC3B,MAAuB;QAEvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa;QACf,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;OAEG;IACK,uBAAuB,CAAC,MAAgC;QAC9D,MAAM,QAAQ,GAAmB,EAAE,CAAC;QAEpC,KAAK,MAAM,OAAO,IAAI,MAAM,EAAE,CAAC;YAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,QAAQ,CAAC,IAAI,CAAC;oBACZ,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,OAAO,CAAC,OAAO;iBACzB,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