@animalabs/membrane 0.5.47 → 0.5.51

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 (143) hide show
  1. package/dist/membrane.d.ts.map +1 -1
  2. package/dist/membrane.js +72 -5
  3. package/dist/membrane.js.map +1 -1
  4. package/dist/providers/anthropic.d.ts.map +1 -1
  5. package/dist/providers/anthropic.js +11 -1
  6. package/dist/providers/anthropic.js.map +1 -1
  7. package/dist/providers/bedrock.d.ts.map +1 -1
  8. package/dist/providers/bedrock.js +9 -0
  9. package/dist/providers/bedrock.js.map +1 -1
  10. package/dist/types/yielding-stream.d.ts +10 -1
  11. package/dist/types/yielding-stream.d.ts.map +1 -1
  12. package/dist/types/yielding-stream.js.map +1 -1
  13. package/package.json +5 -1
  14. package/src/membrane.ts +77 -6
  15. package/src/providers/anthropic.ts +12 -0
  16. package/src/providers/bedrock.ts +8 -0
  17. package/src/types/yielding-stream.ts +10 -1
  18. package/dist/context/index.d.ts +0 -12
  19. package/dist/context/index.js +0 -11
  20. package/dist/context/index.js.map +0 -1
  21. package/dist/context/process.d.ts +0 -43
  22. package/dist/context/process.js +0 -381
  23. package/dist/context/process.js.map +0 -1
  24. package/dist/context/types.d.ts +0 -164
  25. package/dist/context/types.js +0 -61
  26. package/dist/context/types.js.map +0 -1
  27. package/dist/formatters/anthropic-xml.d.ts +0 -63
  28. package/dist/formatters/anthropic-xml.js +0 -417
  29. package/dist/formatters/anthropic-xml.js.map +0 -1
  30. package/dist/formatters/completions.d.ts +0 -68
  31. package/dist/formatters/completions.js +0 -261
  32. package/dist/formatters/completions.js.map +0 -1
  33. package/dist/formatters/index.d.ts +0 -8
  34. package/dist/formatters/index.js +0 -7
  35. package/dist/formatters/index.js.map +0 -1
  36. package/dist/formatters/native.d.ts +0 -35
  37. package/dist/formatters/native.js +0 -336
  38. package/dist/formatters/native.js.map +0 -1
  39. package/dist/formatters/types.d.ts +0 -167
  40. package/dist/formatters/types.js +0 -7
  41. package/dist/formatters/types.js.map +0 -1
  42. package/dist/index.d.ts +0 -13
  43. package/dist/index.js +0 -20
  44. package/dist/index.js.map +0 -1
  45. package/dist/membrane.d.ts +0 -155
  46. package/dist/providers/anthropic.d.ts +0 -36
  47. package/dist/providers/bedrock.d.ts +0 -43
  48. package/dist/providers/gemini.d.ts +0 -68
  49. package/dist/providers/gemini.js +0 -538
  50. package/dist/providers/gemini.js.map +0 -1
  51. package/dist/providers/index.d.ts +0 -13
  52. package/dist/providers/index.js +0 -13
  53. package/dist/providers/index.js.map +0 -1
  54. package/dist/providers/mock.d.ts +0 -90
  55. package/dist/providers/mock.d.ts.map +0 -1
  56. package/dist/providers/mock.js +0 -210
  57. package/dist/providers/mock.js.map +0 -1
  58. package/dist/providers/openai-compatible.d.ts +0 -82
  59. package/dist/providers/openai-compatible.js +0 -480
  60. package/dist/providers/openai-compatible.js.map +0 -1
  61. package/dist/providers/openai-completions.d.ts +0 -89
  62. package/dist/providers/openai-completions.js +0 -347
  63. package/dist/providers/openai-completions.js.map +0 -1
  64. package/dist/providers/openai-responses.d.ts +0 -77
  65. package/dist/providers/openai-responses.js +0 -333
  66. package/dist/providers/openai-responses.js.map +0 -1
  67. package/dist/providers/openai.d.ts +0 -77
  68. package/dist/providers/openai.js +0 -533
  69. package/dist/providers/openai.js.map +0 -1
  70. package/dist/providers/openrouter.d.ts +0 -82
  71. package/dist/providers/openrouter.js +0 -556
  72. package/dist/providers/openrouter.js.map +0 -1
  73. package/dist/providers/utils.d.ts +0 -44
  74. package/dist/providers/utils.d.ts.map +0 -1
  75. package/dist/providers/utils.js +0 -100
  76. package/dist/providers/utils.js.map +0 -1
  77. package/dist/registry/default-pricing.d.ts +0 -3
  78. package/dist/registry/default-pricing.d.ts.map +0 -1
  79. package/dist/registry/default-pricing.js +0 -75
  80. package/dist/registry/default-pricing.js.map +0 -1
  81. package/dist/transforms/chat.d.ts +0 -52
  82. package/dist/transforms/chat.js +0 -136
  83. package/dist/transforms/chat.js.map +0 -1
  84. package/dist/transforms/index.d.ts +0 -5
  85. package/dist/transforms/index.js +0 -7
  86. package/dist/transforms/index.js.map +0 -1
  87. package/dist/transforms/prefill.d.ts +0 -89
  88. package/dist/transforms/prefill.d.ts.map +0 -1
  89. package/dist/transforms/prefill.js +0 -391
  90. package/dist/transforms/prefill.js.map +0 -1
  91. package/dist/types/config.d.ts +0 -110
  92. package/dist/types/config.js +0 -21
  93. package/dist/types/config.js.map +0 -1
  94. package/dist/types/content.d.ts +0 -87
  95. package/dist/types/content.d.ts.map +0 -1
  96. package/dist/types/content.js +0 -40
  97. package/dist/types/content.js.map +0 -1
  98. package/dist/types/errors.d.ts +0 -50
  99. package/dist/types/errors.d.ts.map +0 -1
  100. package/dist/types/errors.js +0 -253
  101. package/dist/types/errors.js.map +0 -1
  102. package/dist/types/index.d.ts +0 -20
  103. package/dist/types/index.js +0 -10
  104. package/dist/types/index.js.map +0 -1
  105. package/dist/types/message.d.ts +0 -52
  106. package/dist/types/message.d.ts.map +0 -1
  107. package/dist/types/message.js +0 -38
  108. package/dist/types/message.js.map +0 -1
  109. package/dist/types/provider.d.ts +0 -169
  110. package/dist/types/provider.d.ts.map +0 -1
  111. package/dist/types/provider.js +0 -5
  112. package/dist/types/provider.js.map +0 -1
  113. package/dist/types/request.d.ts +0 -116
  114. package/dist/types/request.d.ts.map +0 -1
  115. package/dist/types/request.js +0 -5
  116. package/dist/types/request.js.map +0 -1
  117. package/dist/types/response.d.ts +0 -131
  118. package/dist/types/response.d.ts.map +0 -1
  119. package/dist/types/response.js +0 -7
  120. package/dist/types/response.js.map +0 -1
  121. package/dist/types/streaming.d.ts +0 -194
  122. package/dist/types/streaming.js +0 -5
  123. package/dist/types/streaming.js.map +0 -1
  124. package/dist/types/tools.d.ts +0 -71
  125. package/dist/types/tools.d.ts.map +0 -1
  126. package/dist/types/tools.js +0 -5
  127. package/dist/types/tools.js.map +0 -1
  128. package/dist/utils/cost.d.ts +0 -10
  129. package/dist/utils/cost.d.ts.map +0 -1
  130. package/dist/utils/cost.js +0 -19
  131. package/dist/utils/cost.js.map +0 -1
  132. package/dist/utils/index.d.ts +0 -7
  133. package/dist/utils/index.js +0 -6
  134. package/dist/utils/index.js.map +0 -1
  135. package/dist/utils/stream-parser.d.ts +0 -84
  136. package/dist/utils/stream-parser.js +0 -418
  137. package/dist/utils/stream-parser.js.map +0 -1
  138. package/dist/utils/tool-parser.d.ts +0 -134
  139. package/dist/utils/tool-parser.js +0 -600
  140. package/dist/utils/tool-parser.js.map +0 -1
  141. package/dist/yielding-stream.d.ts +0 -60
  142. package/dist/yielding-stream.js +0 -206
  143. package/dist/yielding-stream.js.map +0 -1
@@ -1,391 +0,0 @@
1
- /**
2
- * Prefill mode transforms
3
- *
4
- * Converts normalized messages to participant-based conversation log format:
5
- *
6
- * Alice: Hello there!
7
- *
8
- * Bob: Hi Alice!
9
- *
10
- * Claude: [assistant continuation starts here...]
11
- *
12
- * Key features:
13
- * - Cache control markers for Anthropic prompt caching
14
- * - Image flushing (images cause conversation flush to user turn)
15
- * - Tool injection into conversation
16
- */
17
- import { formatToolDefinitions } from '../utils/tool-parser.js';
18
- // ============================================================================
19
- // Main Transform Function
20
- // ============================================================================
21
- /**
22
- * Transform normalized request to prefill format with cache control support
23
- */
24
- export function transformToPrefill(request, options = {}) {
25
- const { assistantName = 'Claude', maxParticipantsForStop = 10, additionalStopSequences = [], toolInjectionMode = 'conversation', toolInjectionPosition = 10, promptCaching = true, messageDelimiter = '', contextPrefix, prefillThinking = false, } = options;
26
- const messages = request.messages;
27
- const providerMessages = [];
28
- // Track cache marker GLOBALLY across all flushes
29
- // Everything BEFORE we see the marker gets cache_control
30
- // Everything AFTER does NOT
31
- let passedCacheMarker = false;
32
- let cacheMarkersApplied = 0;
33
- // Joiner between messages (if delimiter, no newlines needed)
34
- const joiner = messageDelimiter ? '' : '\n';
35
- // Track conversation lines for current section
36
- let currentConversation = [];
37
- let lastNonEmptyParticipant = null;
38
- // Build system prompt
39
- let systemText = request.system ?? '';
40
- // Inject tool definitions into system prompt if mode is 'system'
41
- if (toolInjectionMode === 'system' && request.tools && request.tools.length > 0) {
42
- const toolsXml = formatToolsForPrefill(request.tools);
43
- systemText = injectToolsIntoSystem(systemText, toolsXml);
44
- }
45
- // System prompt content (with cache_control if enabled)
46
- const systemContent = [];
47
- if (systemText) {
48
- const systemBlock = { type: 'text', text: systemText };
49
- if (promptCaching) {
50
- systemBlock.cache_control = { type: 'ephemeral' };
51
- cacheMarkersApplied++;
52
- }
53
- systemContent.push(systemBlock);
54
- // Note: system content goes in systemContent, not providerMessages
55
- // Anthropic's API requires system as a top-level parameter
56
- }
57
- // Add context prefix as first cached assistant message (for simulacrum seeding)
58
- if (contextPrefix) {
59
- const prefixBlock = { type: 'text', text: contextPrefix };
60
- if (promptCaching) {
61
- prefixBlock.cache_control = { type: 'ephemeral' };
62
- cacheMarkersApplied++;
63
- }
64
- providerMessages.push({
65
- role: 'assistant',
66
- content: [prefixBlock],
67
- });
68
- }
69
- // Process messages
70
- for (let i = 0; i < messages.length; i++) {
71
- const message = messages[i];
72
- if (!message)
73
- continue;
74
- const isLastMessage = i === messages.length - 1;
75
- const isAssistant = message.participant === assistantName;
76
- const hasCacheMarker = !!message.metadata?.cacheControl;
77
- // Extract text and images
78
- const { text, images } = formatContentForPrefill(message.content, message.participant);
79
- const hasImages = images.length > 0;
80
- const isEmpty = !text.trim() && !hasImages;
81
- // Check for tool results
82
- const hasToolResult = message.content.some(c => c.type === 'tool_result');
83
- // If message has images, flush current conversation and add as user message
84
- if (hasImages && !isEmpty) {
85
- // Flush current assistant conversation
86
- if (currentConversation.length > 0) {
87
- const content = currentConversation.join(joiner);
88
- providerMessages.push({
89
- role: 'assistant',
90
- content: content,
91
- });
92
- currentConversation = [];
93
- }
94
- // Add message with image as user turn
95
- const userContent = [];
96
- if (text) {
97
- userContent.push({ type: 'text', text: `${message.participant}: ${text}` });
98
- }
99
- userContent.push(...images);
100
- providerMessages.push({
101
- role: 'user',
102
- content: userContent,
103
- });
104
- lastNonEmptyParticipant = message.participant;
105
- continue;
106
- }
107
- // Skip empty messages (except last)
108
- if (isEmpty && !isLastMessage) {
109
- continue;
110
- }
111
- // Check if this message has the cache marker - switch to uncached mode AFTER this
112
- if (hasCacheMarker && !passedCacheMarker) {
113
- // Flush everything before this message WITH cache_control (if caching enabled)
114
- if (currentConversation.length > 0) {
115
- const content = currentConversation.join(joiner);
116
- const contentBlock = { type: 'text', text: content };
117
- if (promptCaching) {
118
- contentBlock.cache_control = { type: 'ephemeral' };
119
- cacheMarkersApplied++;
120
- }
121
- providerMessages.push({
122
- role: 'assistant',
123
- content: [contentBlock],
124
- });
125
- currentConversation = [];
126
- }
127
- passedCacheMarker = true;
128
- }
129
- // Check bot continuation logic
130
- const isBotMessage = message.participant === assistantName;
131
- const isContinuation = isBotMessage && lastNonEmptyParticipant === assistantName && !hasToolResult;
132
- if (isContinuation && isLastMessage) {
133
- // Bot continuation - don't add prefix, just complete from where we are
134
- continue;
135
- }
136
- else if (isLastMessage && isEmpty) {
137
- // Completion target - optionally start with thinking tag
138
- if (prefillThinking) {
139
- currentConversation.push(`${message.participant}: <thinking>`);
140
- }
141
- else {
142
- currentConversation.push(`${message.participant}:`);
143
- }
144
- }
145
- else if (text) {
146
- // Regular message - append delimiter if configured
147
- currentConversation.push(`${message.participant}: ${text}${messageDelimiter}`);
148
- if (!hasToolResult) {
149
- lastNonEmptyParticipant = message.participant;
150
- }
151
- }
152
- }
153
- // Flush any remaining conversation, inject tools if mode is 'conversation'
154
- if (currentConversation.length > 0) {
155
- const hasToolsForConversation = toolInjectionMode === 'conversation' &&
156
- request.tools &&
157
- request.tools.length > 0;
158
- if (hasToolsForConversation) {
159
- // Inject tools into assistant content
160
- const toolsText = formatToolsForInjection(request.tools);
161
- if (currentConversation.length > toolInjectionPosition) {
162
- // Long conversation: insert tools ~N messages from the end
163
- const splitPoint = currentConversation.length - toolInjectionPosition;
164
- const beforeTools = currentConversation.slice(0, splitPoint);
165
- const afterTools = currentConversation.slice(splitPoint);
166
- const combined = [
167
- ...beforeTools,
168
- toolsText,
169
- ...afterTools,
170
- ].join(joiner);
171
- providerMessages.push({
172
- role: 'assistant',
173
- content: combined,
174
- });
175
- }
176
- else {
177
- // Short conversation: inject tools at the end (right before completion point)
178
- const combined = [...currentConversation, toolsText].join(joiner);
179
- providerMessages.push({
180
- role: 'assistant',
181
- content: combined,
182
- });
183
- }
184
- }
185
- else {
186
- // No tool injection needed
187
- providerMessages.push({
188
- role: 'assistant',
189
- content: currentConversation.join(joiner),
190
- });
191
- }
192
- }
193
- // Build stop sequences from participants
194
- const stopSequences = buildStopSequences(messages, assistantName, maxParticipantsForStop, additionalStopSequences);
195
- // Build legacy string versions for backwards compatibility
196
- const legacyStrings = buildLegacyStrings(providerMessages, systemText);
197
- return {
198
- systemContent,
199
- messages: providerMessages,
200
- system: systemText,
201
- userContent: legacyStrings.userContent,
202
- assistantPrefill: legacyStrings.assistantPrefill,
203
- stopSequences,
204
- cacheMarkersApplied,
205
- };
206
- }
207
- // ============================================================================
208
- // Helper Functions
209
- // ============================================================================
210
- function formatContentForPrefill(content, participant) {
211
- const parts = [];
212
- const images = [];
213
- for (const block of content) {
214
- if (block.type === 'text') {
215
- parts.push(block.text);
216
- }
217
- else if (block.type === 'image') {
218
- // Convert to provider format
219
- if (block.source.type === 'base64') {
220
- images.push({
221
- type: 'image',
222
- source: {
223
- type: 'base64',
224
- media_type: block.source.mediaType,
225
- data: block.source.data,
226
- },
227
- });
228
- }
229
- }
230
- else if (block.type === 'tool_use') {
231
- // Format as: Name>[toolname]: {json}
232
- parts.push(`${participant}>[${block.name}]: ${JSON.stringify(block.input)}`);
233
- }
234
- else if (block.type === 'tool_result') {
235
- // Format as: Name<[tool_result]: result
236
- const resultText = typeof block.content === 'string'
237
- ? block.content
238
- : JSON.stringify(block.content);
239
- parts.push(`${participant}<[tool_result]: ${resultText}`);
240
- }
241
- }
242
- return { text: parts.join('\n'), images };
243
- }
244
- function formatToolsForPrefill(tools) {
245
- const toolsForPrompt = tools.map((tool) => ({
246
- name: tool.name,
247
- description: tool.description,
248
- parameters: Object.fromEntries(Object.entries(tool.inputSchema.properties).map(([name, schema]) => [
249
- name,
250
- {
251
- type: schema.type,
252
- description: schema.description,
253
- required: tool.inputSchema.required?.includes(name),
254
- enum: schema.enum,
255
- },
256
- ])),
257
- }));
258
- return formatToolDefinitions(toolsForPrompt);
259
- }
260
- function injectToolsIntoSystem(system, toolsXml) {
261
- const toolsSection = `
262
- <available_tools>
263
- ${toolsXml}
264
- </available_tools>
265
-
266
- When you want to use a tool, output:
267
- <function_calls>
268
- <invoke name="tool_name">
269
- <parameter name="param_name">value</parameter>
270
- </invoke>
271
- </function_calls>
272
- `;
273
- return system + '\n\n' + toolsSection;
274
- }
275
- // Tool format constants (assembled to avoid triggering stop sequences)
276
- const FUNCTIONS_OPEN = '<' + 'functions>';
277
- const FUNCTIONS_CLOSE = '</' + 'functions>';
278
- const FUNCTION_OPEN = '<' + 'function>';
279
- const FUNCTION_CLOSE = '</' + 'function>';
280
- const FUNC_CALLS_OPEN = '<' + 'function_calls>';
281
- const FUNC_CALLS_CLOSE = '</' + 'function_calls>';
282
- const INVOKE_OPEN = '<' + 'invoke name="';
283
- const INVOKE_CLOSE = '</' + 'invoke>';
284
- const PARAM_OPEN = '<' + 'parameter name="';
285
- const PARAM_CLOSE = '</' + 'parameter>';
286
- function formatToolsForInjection(tools) {
287
- // Use the same XML format as system mode for consistency
288
- const toolsXml = formatToolsForPrefill(tools);
289
- return `
290
- <available_tools>
291
- ${toolsXml}
292
- </available_tools>
293
-
294
- When you want to use a tool, output:
295
- ${FUNC_CALLS_OPEN}
296
- ${INVOKE_OPEN}tool_name">
297
- ${PARAM_OPEN}param_name">value${PARAM_CLOSE}
298
- ${INVOKE_CLOSE}
299
- ${FUNC_CALLS_CLOSE}`;
300
- }
301
- function buildStopSequences(messages, assistantName, maxParticipants, additionalSequences) {
302
- // Collect unique participants (excluding assistant)
303
- const participants = new Set();
304
- // Scan from end of messages
305
- for (let i = messages.length - 1; i >= 0 && participants.size < maxParticipants; i--) {
306
- const message = messages[i];
307
- if (!message)
308
- continue;
309
- const participant = message.participant;
310
- if (participant !== assistantName) {
311
- participants.add(participant);
312
- }
313
- }
314
- // Build stop sequences
315
- const sequences = [];
316
- // Participant-based stops
317
- for (const participant of participants) {
318
- sequences.push(`\n${participant}:`);
319
- }
320
- // Tool-related stop
321
- sequences.push('</function_calls>');
322
- // Additional sequences
323
- sequences.push(...additionalSequences);
324
- return sequences;
325
- }
326
- function buildLegacyStrings(messages, systemText) {
327
- // Extract user content (first user message after system)
328
- let userContent = '';
329
- let assistantPrefill = '';
330
- for (const msg of messages) {
331
- if (msg.role === 'user') {
332
- if (typeof msg.content === 'string') {
333
- userContent += msg.content + '\n\n';
334
- }
335
- else {
336
- // Extract text from blocks
337
- for (const block of msg.content) {
338
- if (block.type === 'text') {
339
- userContent += block.text + '\n\n';
340
- }
341
- }
342
- }
343
- }
344
- else if (msg.role === 'assistant') {
345
- if (typeof msg.content === 'string') {
346
- assistantPrefill += msg.content;
347
- }
348
- else {
349
- for (const block of msg.content) {
350
- if (block.type === 'text') {
351
- assistantPrefill += block.text;
352
- }
353
- }
354
- }
355
- }
356
- }
357
- return {
358
- userContent: userContent.trim(),
359
- assistantPrefill: assistantPrefill,
360
- };
361
- }
362
- // ============================================================================
363
- // Prefill Continuation
364
- // ============================================================================
365
- /**
366
- * Build a continuation request from accumulated output
367
- */
368
- export function buildContinuationPrefill(originalResult, accumulated) {
369
- // Update the last assistant message with accumulated content
370
- const newMessages = [...originalResult.messages];
371
- // Find the last assistant message or add one
372
- const lastIdx = newMessages.length - 1;
373
- if (lastIdx >= 0 && newMessages[lastIdx]?.role === 'assistant') {
374
- newMessages[lastIdx] = {
375
- role: 'assistant',
376
- content: accumulated,
377
- };
378
- }
379
- else {
380
- newMessages.push({
381
- role: 'assistant',
382
- content: accumulated,
383
- });
384
- }
385
- return {
386
- ...originalResult,
387
- messages: newMessages,
388
- assistantPrefill: accumulated,
389
- };
390
- }
391
- //# sourceMappingURL=prefill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefill.js","sourceRoot":"","sources":["../../src/transforms/prefill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,OAAO,EAAE,qBAAqB,EAAgC,MAAM,yBAAyB,CAAC;AAqG9F,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAA0B,EAC1B,UAAmC,EAAE;IAErC,MAAM,EACJ,aAAa,GAAG,QAAQ,EACxB,sBAAsB,GAAG,EAAE,EAC3B,uBAAuB,GAAG,EAAE,EAC5B,iBAAiB,GAAG,cAAc,EAClC,qBAAqB,GAAG,EAAE,EAC1B,aAAa,GAAG,IAAI,EACpB,gBAAgB,GAAG,EAAE,EACrB,aAAa,EACb,eAAe,GAAG,KAAK,GACxB,GAAG,OAAO,CAAC;IAEZ,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,gBAAgB,GAAsB,EAAE,CAAC;IAE/C,iDAAiD;IACjD,yDAAyD;IACzD,4BAA4B;IAC5B,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,mBAAmB,GAAG,CAAC,CAAC;IAE5B,6DAA6D;IAC7D,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAE5C,+CAA+C;IAC/C,IAAI,mBAAmB,GAAa,EAAE,CAAC;IACvC,IAAI,uBAAuB,GAAkB,IAAI,CAAC;IAElD,sBAAsB;IACtB,IAAI,UAAU,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;IAEtC,iEAAiE;IACjE,IAAI,iBAAiB,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,GA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,IAAI,CAAC,IAAI,WAAW,CAAC,OAAO,CAAC,EAAE,IAAI,KAAK,WAAW,EAAE,CAAC;QAC/D,WAAW,CAAC,OAAO,CAAC,GAAG;YACrB,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,WAAW;SACrB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,WAAW,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,WAAW;SACrB,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,GAAG,cAAc;QACjB,QAAQ,EAAE,WAAW;QACrB,gBAAgB,EAAE,WAAW;KAC9B,CAAC;AACJ,CAAC"}
@@ -1,110 +0,0 @@
1
- /**
2
- * Configuration types for membrane
3
- */
4
- import type { ModelRegistry } from './provider.js';
5
- import type { ErrorInfo } from './errors.js';
6
- import type { NormalizedRequest } from './request.js';
7
- import type { NormalizedResponse } from './response.js';
8
- import type { PrefillFormatter } from '../formatters/types.js';
9
- export interface RetryConfig {
10
- /** Maximum number of retry attempts (default: 3) */
11
- maxRetries: number;
12
- /** Initial retry delay in milliseconds (default: 1000) */
13
- retryDelayMs: number;
14
- /** Backoff multiplier (default: 2) */
15
- backoffMultiplier: number;
16
- /** Maximum retry delay (default: 30000) */
17
- maxRetryDelayMs: number;
18
- }
19
- export interface MediaConfig {
20
- images: {
21
- /** Maximum input image size in bytes */
22
- maxSizeBytes: number;
23
- /** Maximum dimensions */
24
- maxDimensions?: {
25
- width: number;
26
- height: number;
27
- };
28
- /** Auto-resize if exceeds limits */
29
- autoResize: boolean;
30
- /** JPEG quality for resizing (0-100) */
31
- resizeQuality?: number;
32
- /** Relocate images to user turns in prefill mode */
33
- relocateInPrefillMode: boolean;
34
- };
35
- documents?: {
36
- /** Maximum document size */
37
- maxSizeBytes: number;
38
- };
39
- audio?: {
40
- /** Maximum duration in seconds */
41
- maxDurationSec: number;
42
- };
43
- video?: {
44
- /** Maximum duration in seconds */
45
- maxDurationSec: number;
46
- };
47
- }
48
- export interface MembraneHooks {
49
- /**
50
- * Called before sending request to provider
51
- * Can modify the raw request
52
- */
53
- beforeRequest?: (request: NormalizedRequest, rawRequest: unknown) => unknown | Promise<unknown>;
54
- /**
55
- * Called after receiving response from provider
56
- * Can modify the response
57
- */
58
- afterResponse?: (response: NormalizedResponse, rawResponse: unknown) => NormalizedResponse | Promise<NormalizedResponse>;
59
- /**
60
- * Called on error, before retry decision
61
- * Return 'retry' to retry, 'abort' to stop
62
- */
63
- onError?: (error: ErrorInfo, attempt: number) => 'retry' | 'abort' | Promise<'retry' | 'abort'>;
64
- }
65
- export interface MembraneLogger {
66
- debug(message: string, data?: Record<string, unknown>): void;
67
- info(message: string, data?: Record<string, unknown>): void;
68
- warn(message: string, data?: Record<string, unknown>): void;
69
- error(message: string, data?: Record<string, unknown>): void;
70
- }
71
- export interface MembraneConfig {
72
- /** Model registry for capability lookup */
73
- registry?: ModelRegistry;
74
- /** Default model to use */
75
- defaultModel?: string;
76
- /**
77
- * Participant name to recognize as assistant in prefill mode.
78
- * Messages with this participant will be formatted as assistant turns.
79
- * Default: 'Claude'
80
- */
81
- assistantParticipant?: string;
82
- /**
83
- * Maximum number of participants to include in auto-generated stop sequences.
84
- * In prefill mode, membrane generates stop sequences like "\nUsername:" to prevent
85
- * the model from speaking as other participants.
86
- *
87
- * Set to 0 to disable participant-based stop sequences (allows frags/quotes).
88
- * Default: 10
89
- */
90
- maxParticipantsForStop?: number;
91
- /**
92
- * Prefill formatter for message serialization and response parsing.
93
- * Controls how messages are formatted for the API and how responses are parsed.
94
- * Default: AnthropicXmlFormatter
95
- */
96
- formatter?: PrefillFormatter;
97
- /** Retry configuration */
98
- retry?: Partial<RetryConfig>;
99
- /** Media processing configuration */
100
- media?: Partial<MediaConfig>;
101
- /** Lifecycle hooks */
102
- hooks?: MembraneHooks;
103
- /** Logger instance */
104
- logger?: MembraneLogger;
105
- /** Enable debug logging */
106
- debug?: boolean;
107
- }
108
- export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
109
- export declare const DEFAULT_MEDIA_CONFIG: MediaConfig;
110
- //# sourceMappingURL=config.d.ts.map
@@ -1,21 +0,0 @@
1
- /**
2
- * Configuration types for membrane
3
- */
4
- // ============================================================================
5
- // Default Config
6
- // ============================================================================
7
- export const DEFAULT_RETRY_CONFIG = {
8
- maxRetries: 0,
9
- retryDelayMs: 1000,
10
- backoffMultiplier: 2,
11
- maxRetryDelayMs: 30000,
12
- };
13
- export const DEFAULT_MEDIA_CONFIG = {
14
- images: {
15
- maxSizeBytes: 5 * 1024 * 1024, // 5MB (Anthropic limit)
16
- autoResize: true,
17
- resizeQuality: 85,
18
- relocateInPrefillMode: true,
19
- },
20
- };
21
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AA+JH,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,UAAU,EAAE,CAAC;IACb,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,CAAC;IACpB,eAAe,EAAE,KAAK;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAgB;IAC/C,MAAM,EAAE;QACN,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,wBAAwB;QACvD,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,EAAE;QACjB,qBAAqB,EAAE,IAAI;KAC5B;CACF,CAAC"}
@@ -1,87 +0,0 @@
1
- /**
2
- * Content block types for normalized messages
3
- */
4
- export interface CacheControl {
5
- type: 'ephemeral';
6
- /** TTL for cache - '5m' (default) or '1h' for extended caching */
7
- ttl?: '5m' | '1h';
8
- }
9
- export interface Base64Source {
10
- type: 'base64';
11
- data: string;
12
- mediaType: string;
13
- }
14
- export interface UrlSource {
15
- type: 'url';
16
- url: string;
17
- }
18
- export type MediaSource = Base64Source | UrlSource;
19
- export interface TextContent {
20
- type: 'text';
21
- text: string;
22
- /** Cache control for Anthropic prompt caching */
23
- cache_control?: CacheControl;
24
- }
25
- export interface ImageContent {
26
- type: 'image';
27
- source: MediaSource;
28
- tokenEstimate?: number;
29
- /** Original URL of the image (e.g., Discord CDN). Used by providers that
30
- * can auto-fetch URLs from text (like Gemini 3.x) when inlineData is
31
- * not viable (e.g., missing thought_signature on model-role images). */
32
- sourceUrl?: string;
33
- }
34
- export interface DocumentContent {
35
- type: 'document';
36
- source: Base64Source;
37
- filename?: string;
38
- }
39
- export interface AudioContent {
40
- type: 'audio';
41
- source: Base64Source;
42
- duration?: number;
43
- }
44
- export interface VideoContent {
45
- type: 'video';
46
- source: Base64Source;
47
- duration?: number;
48
- }
49
- export interface GeneratedImageContent {
50
- type: 'generated_image';
51
- data: string;
52
- mimeType: string;
53
- isPreview?: boolean;
54
- }
55
- export interface ToolUseContent {
56
- type: 'tool_use';
57
- id: string;
58
- name: string;
59
- input: Record<string, unknown>;
60
- }
61
- export interface ToolResultContent {
62
- type: 'tool_result';
63
- toolUseId: string;
64
- content: string | ContentBlock[];
65
- isError?: boolean;
66
- }
67
- export interface ThinkingContent {
68
- type: 'thinking';
69
- thinking: string;
70
- signature?: string;
71
- }
72
- export interface RedactedThinkingContent {
73
- type: 'redacted_thinking';
74
- }
75
- export type ContentBlock = TextContent | ImageContent | DocumentContent | AudioContent | VideoContent | GeneratedImageContent | ToolUseContent | ToolResultContent | ThinkingContent | RedactedThinkingContent;
76
- export declare function isTextContent(block: ContentBlock): block is TextContent;
77
- export declare function isImageContent(block: ContentBlock): block is ImageContent;
78
- export declare function isDocumentContent(block: ContentBlock): block is DocumentContent;
79
- export declare function isAudioContent(block: ContentBlock): block is AudioContent;
80
- export declare function isVideoContent(block: ContentBlock): block is VideoContent;
81
- export declare function isGeneratedImageContent(block: ContentBlock): block is GeneratedImageContent;
82
- export declare function isToolUseContent(block: ContentBlock): block is ToolUseContent;
83
- export declare function isToolResultContent(block: ContentBlock): block is ToolResultContent;
84
- export declare function isThinkingContent(block: ContentBlock): block is ThinkingContent;
85
- export declare function isRedactedThinkingContent(block: ContentBlock): block is RedactedThinkingContent;
86
- export declare function isMediaContent(block: ContentBlock): block is ImageContent | DocumentContent | AudioContent | VideoContent;
87
- //# sourceMappingURL=content.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/types/content.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,kEAAkE;IAClE,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB;AAMD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,SAAS,CAAC;AAMnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAMD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;6EAEyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,QAAQ,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