@animalabs/membrane 0.5.44 → 0.5.46
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/dist/formatters/index.d.ts +0 -1
- package/dist/formatters/index.js +0 -1
- package/dist/formatters/index.js.map +1 -1
- package/dist/formatters/types.d.ts +0 -4
- package/dist/providers/bedrock.d.ts.map +1 -1
- package/dist/providers/bedrock.js +44 -7
- package/dist/providers/bedrock.js.map +1 -1
- package/dist/providers/gemini.js +11 -2
- package/dist/providers/gemini.js.map +1 -1
- package/dist/providers/openai-compatible.js +25 -15
- package/dist/providers/openai-compatible.js.map +1 -1
- package/dist/providers/openai-completions.js +48 -24
- package/dist/providers/openai-completions.js.map +1 -1
- package/dist/providers/openai-responses.js +6 -1
- package/dist/providers/openai-responses.js.map +1 -1
- package/dist/providers/openai.js +25 -15
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.js +35 -16
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/utils.d.ts +38 -0
- package/dist/providers/utils.d.ts.map +1 -1
- package/dist/providers/utils.js +86 -0
- package/dist/providers/utils.js.map +1 -1
- package/dist/types/request.d.ts +8 -0
- package/dist/types/request.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/providers/bedrock.ts +40 -3
- package/dist/formatters/pseudo-prefill.d.ts +0 -71
- package/dist/formatters/pseudo-prefill.d.ts.map +0 -1
- package/dist/formatters/pseudo-prefill.js +0 -410
- package/dist/formatters/pseudo-prefill.js.map +0 -1
- package/dist/transforms/prefill.d.ts +0 -89
- package/dist/transforms/prefill.d.ts.map +0 -1
- package/dist/transforms/prefill.js +0 -390
- package/dist/transforms/prefill.js.map +0 -1
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pseudo-Prefill Formatter
|
|
3
|
-
*
|
|
4
|
-
* Recovers prefill-like behavior for models that don't support native
|
|
5
|
-
* assistant message prefill (e.g., Sonnet 4.6, Opus 4.6). Uses a CLI
|
|
6
|
-
* simulation framing trick:
|
|
7
|
-
*
|
|
8
|
-
* System: "The assistant is in CLI simulation mode..."
|
|
9
|
-
* User: "<cmd>cut -c 1-N < conversation.txt</cmd>"
|
|
10
|
-
* Assistant: <the full conversation log, N chars>
|
|
11
|
-
* User: "<cmd>cat conversation.txt</cmd>" (or cut -c N+1-)
|
|
12
|
-
* <model continues from where the cut output ended>
|
|
13
|
-
*
|
|
14
|
-
* Two continuation modes:
|
|
15
|
-
* - 'cat': model repeats full file then continues (reliable, caller strips log)
|
|
16
|
-
* - 'tail-cut': model outputs only new content (efficient, needs simulated stops)
|
|
17
|
-
*
|
|
18
|
-
* IMPORTANT: API-level stop sequences should NOT be used with pseudo-prefill.
|
|
19
|
-
* In 'cat' mode, the model repeats participant names from the log which would
|
|
20
|
-
* trigger stops prematurely. The caller should handle stop sequences post-facto
|
|
21
|
-
* after stripping the repeated log. The stop sequences returned in BuildResult
|
|
22
|
-
* are for the caller's post-facto detection, not for the API.
|
|
23
|
-
*
|
|
24
|
-
* Uses PassthroughParser and native API tools (same as NativeFormatter).
|
|
25
|
-
*/
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Pass-through Stream Parser (same as NativeFormatter)
|
|
28
|
-
// ============================================================================
|
|
29
|
-
class PassthroughParser {
|
|
30
|
-
accumulated = '';
|
|
31
|
-
blockIndex = 0;
|
|
32
|
-
blockStarted = false;
|
|
33
|
-
processChunk(chunk) {
|
|
34
|
-
this.accumulated += chunk;
|
|
35
|
-
const meta = {
|
|
36
|
-
type: 'text',
|
|
37
|
-
visible: true,
|
|
38
|
-
blockIndex: this.blockIndex,
|
|
39
|
-
};
|
|
40
|
-
const emissions = [];
|
|
41
|
-
const blockEvents = [];
|
|
42
|
-
if (!this.blockStarted) {
|
|
43
|
-
const startEvent = {
|
|
44
|
-
event: 'block_start',
|
|
45
|
-
index: this.blockIndex,
|
|
46
|
-
block: { type: 'text' },
|
|
47
|
-
};
|
|
48
|
-
emissions.push({ kind: 'blockEvent', event: startEvent });
|
|
49
|
-
blockEvents.push(startEvent);
|
|
50
|
-
this.blockStarted = true;
|
|
51
|
-
}
|
|
52
|
-
emissions.push({ kind: 'content', text: chunk, meta });
|
|
53
|
-
return { emissions, content: [{ text: chunk, meta }], blockEvents };
|
|
54
|
-
}
|
|
55
|
-
flush() {
|
|
56
|
-
const emissions = [];
|
|
57
|
-
const blockEvents = [];
|
|
58
|
-
if (this.blockStarted) {
|
|
59
|
-
const completeEvent = {
|
|
60
|
-
event: 'block_complete',
|
|
61
|
-
index: this.blockIndex,
|
|
62
|
-
block: { type: 'text', content: this.accumulated },
|
|
63
|
-
};
|
|
64
|
-
emissions.push({ kind: 'blockEvent', event: completeEvent });
|
|
65
|
-
blockEvents.push(completeEvent);
|
|
66
|
-
this.blockStarted = false;
|
|
67
|
-
}
|
|
68
|
-
return { emissions, content: [], blockEvents };
|
|
69
|
-
}
|
|
70
|
-
getAccumulated() {
|
|
71
|
-
return this.accumulated;
|
|
72
|
-
}
|
|
73
|
-
reset() {
|
|
74
|
-
this.accumulated = '';
|
|
75
|
-
this.blockIndex = 0;
|
|
76
|
-
this.blockStarted = false;
|
|
77
|
-
}
|
|
78
|
-
push(content) {
|
|
79
|
-
this.accumulated += content;
|
|
80
|
-
}
|
|
81
|
-
getCurrentBlockType() {
|
|
82
|
-
return 'text';
|
|
83
|
-
}
|
|
84
|
-
getBlockIndex() {
|
|
85
|
-
return this.blockIndex;
|
|
86
|
-
}
|
|
87
|
-
incrementBlockIndex() {
|
|
88
|
-
this.blockIndex++;
|
|
89
|
-
}
|
|
90
|
-
isInsideBlock() {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
getDepths() {
|
|
94
|
-
return { functionCalls: 0, functionResults: 0, thinking: 0 };
|
|
95
|
-
}
|
|
96
|
-
resetForNewIteration() {
|
|
97
|
-
// No special reset needed for pass-through mode
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
// ============================================================================
|
|
101
|
-
// Pseudo-Prefill Formatter
|
|
102
|
-
// ============================================================================
|
|
103
|
-
const CLI_DIRECTIVE = 'The assistant is in CLI simulation mode, and responds to the user\'s CLI commands only with the output of the command.';
|
|
104
|
-
export class PseudoPrefillFormatter {
|
|
105
|
-
name = 'pseudo-prefill';
|
|
106
|
-
usesPrefill = false;
|
|
107
|
-
config;
|
|
108
|
-
constructor(config = {}) {
|
|
109
|
-
this.config = {
|
|
110
|
-
filename: config.filename ?? 'conversation.txt',
|
|
111
|
-
continuationMode: config.continuationMode ?? 'cat',
|
|
112
|
-
maxParticipantsForStop: config.maxParticipantsForStop ?? 10,
|
|
113
|
-
messageDelimiter: config.messageDelimiter ?? '',
|
|
114
|
-
unsupportedMedia: config.unsupportedMedia ?? 'strip',
|
|
115
|
-
warnOnStrip: config.warnOnStrip ?? true,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
// ==========================================================================
|
|
119
|
-
// REQUEST BUILDING
|
|
120
|
-
// ==========================================================================
|
|
121
|
-
buildMessages(messages, options) {
|
|
122
|
-
const { assistantParticipant, tools, systemPrompt, promptCaching = false, cacheTtl, contextPrefix, hasCacheMarker, additionalStopSequences, } = options;
|
|
123
|
-
// Build cache_control object
|
|
124
|
-
const cacheControl = { type: 'ephemeral' };
|
|
125
|
-
if (cacheTtl) {
|
|
126
|
-
cacheControl.ttl = cacheTtl;
|
|
127
|
-
}
|
|
128
|
-
// 1. Build system content: user's system prompt + CLI directive
|
|
129
|
-
let systemText = typeof systemPrompt === 'string' ? systemPrompt : '';
|
|
130
|
-
if (Array.isArray(systemPrompt)) {
|
|
131
|
-
systemText = systemPrompt
|
|
132
|
-
.filter((b) => b.type === 'text')
|
|
133
|
-
.map(b => b.text)
|
|
134
|
-
.join('\n');
|
|
135
|
-
}
|
|
136
|
-
systemText = systemText
|
|
137
|
-
? `${systemText}\n\n${CLI_DIRECTIVE}`
|
|
138
|
-
: CLI_DIRECTIVE;
|
|
139
|
-
let systemContent;
|
|
140
|
-
const systemBlock = { type: 'text', text: systemText };
|
|
141
|
-
if (promptCaching) {
|
|
142
|
-
systemBlock.cache_control = cacheControl;
|
|
143
|
-
}
|
|
144
|
-
systemContent = [systemBlock];
|
|
145
|
-
// 2. Build the conversation log, handling images like AnthropicXmlFormatter:
|
|
146
|
-
// When a message has images, flush the accumulated log as an assistant turn,
|
|
147
|
-
// add the image as a user turn, then continue accumulating.
|
|
148
|
-
let currentLog = [];
|
|
149
|
-
let cacheMarkersApplied = promptCaching ? 1 : 0; // system block
|
|
150
|
-
const joiner = this.config.messageDelimiter ? '' : '\n';
|
|
151
|
-
const filename = this.config.filename;
|
|
152
|
-
// Track image flushes — these become user turns between cut result and cat
|
|
153
|
-
const imageTurns = [];
|
|
154
|
-
const logSegments = [];
|
|
155
|
-
// Context prefix (simulacrum seeding) goes first in the log
|
|
156
|
-
if (contextPrefix) {
|
|
157
|
-
currentLog.push(contextPrefix);
|
|
158
|
-
}
|
|
159
|
-
// Serialize messages
|
|
160
|
-
let lastParticipant = '';
|
|
161
|
-
for (let i = 0; i < messages.length; i++) {
|
|
162
|
-
const message = messages[i];
|
|
163
|
-
if (!message)
|
|
164
|
-
continue;
|
|
165
|
-
const { text, images, hasUnsupportedMedia } = this.extractContent(message.content, message.participant);
|
|
166
|
-
const hasImages = images.length > 0;
|
|
167
|
-
const isEmpty = !text.trim() && !hasImages;
|
|
168
|
-
if (hasUnsupportedMedia) {
|
|
169
|
-
if (this.config.unsupportedMedia === 'error') {
|
|
170
|
-
throw new Error(`PseudoPrefillFormatter does not support media in message from ${message.participant}. Configure unsupportedMedia: 'strip' to ignore.`);
|
|
171
|
-
}
|
|
172
|
-
else if (this.config.warnOnStrip) {
|
|
173
|
-
console.warn(`[PseudoPrefillFormatter] Stripped unsupported media from message`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (isEmpty)
|
|
177
|
-
continue;
|
|
178
|
-
// If message has images, flush current log and add image as user turn
|
|
179
|
-
if (hasImages) {
|
|
180
|
-
if (currentLog.length > 0) {
|
|
181
|
-
logSegments.push({ text: currentLog.join(joiner) });
|
|
182
|
-
currentLog = [];
|
|
183
|
-
}
|
|
184
|
-
const userContent = [];
|
|
185
|
-
if (text) {
|
|
186
|
-
userContent.push({ type: 'text', text: `${message.participant}: ${text}` });
|
|
187
|
-
}
|
|
188
|
-
userContent.push(...images);
|
|
189
|
-
imageTurns.push({ role: 'user', content: userContent });
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
// Check cache breakpoint — flush segment WITH this message
|
|
193
|
-
if (message.cacheBreakpoint && promptCaching) {
|
|
194
|
-
currentLog.push(`${message.participant}: ${text}${this.config.messageDelimiter}`);
|
|
195
|
-
logSegments.push({ text: currentLog.join(joiner), cacheBreakpoint: true });
|
|
196
|
-
currentLog = [];
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
// hasCacheMarker: cache boundary BEFORE this message
|
|
200
|
-
if (hasCacheMarker && hasCacheMarker(message, i) && promptCaching && currentLog.length > 0) {
|
|
201
|
-
logSegments.push({ text: currentLog.join(joiner), cacheBreakpoint: true });
|
|
202
|
-
currentLog = [];
|
|
203
|
-
}
|
|
204
|
-
// Same participant as last message — merge without repeating name prefix
|
|
205
|
-
if (message.participant === lastParticipant && lastParticipant !== '') {
|
|
206
|
-
const lastEntry = currentLog[currentLog.length - 1];
|
|
207
|
-
if (lastEntry) {
|
|
208
|
-
currentLog[currentLog.length - 1] = lastEntry.trimEnd() + ' ' + text.trimStart() + '\n\n';
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
currentLog.push(`${message.participant}: ${text}${this.config.messageDelimiter}`);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
currentLog.push(`${message.participant}: ${text}${this.config.messageDelimiter}`);
|
|
216
|
-
}
|
|
217
|
-
lastParticipant = message.participant;
|
|
218
|
-
}
|
|
219
|
-
// Add the assistant participant turn prefix at the end
|
|
220
|
-
currentLog.push(`${assistantParticipant}:`);
|
|
221
|
-
logSegments.push({ text: currentLog.join(joiner) });
|
|
222
|
-
// Combine all log segments into the full conversation log for the cut char count
|
|
223
|
-
const fullLog = logSegments.map(s => s.text).join(joiner);
|
|
224
|
-
const charCount = fullLog.length;
|
|
225
|
-
// 3. Build the message structure
|
|
226
|
-
const providerMessages = [];
|
|
227
|
-
// User: cut command (request first N chars, wrapped in <cmd> tags)
|
|
228
|
-
providerMessages.push({
|
|
229
|
-
role: 'user',
|
|
230
|
-
content: `<cmd>cut -c 1-${charCount} < ${filename}</cmd>`,
|
|
231
|
-
});
|
|
232
|
-
// Assistant: the conversation log
|
|
233
|
-
// If there are multiple segments with cache breakpoints, split into
|
|
234
|
-
// multiple assistant content blocks. Otherwise, single block.
|
|
235
|
-
if (logSegments.length === 1 || !promptCaching) {
|
|
236
|
-
const logBlock = { type: 'text', text: fullLog };
|
|
237
|
-
if (promptCaching) {
|
|
238
|
-
logBlock.cache_control = cacheControl;
|
|
239
|
-
cacheMarkersApplied++;
|
|
240
|
-
}
|
|
241
|
-
providerMessages.push({
|
|
242
|
-
role: 'assistant',
|
|
243
|
-
content: [logBlock],
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
// Multiple segments with cache breakpoints
|
|
248
|
-
const contentBlocks = [];
|
|
249
|
-
for (const segment of logSegments) {
|
|
250
|
-
const block = { type: 'text', text: segment.text };
|
|
251
|
-
if (segment.cacheBreakpoint) {
|
|
252
|
-
block.cache_control = cacheControl;
|
|
253
|
-
cacheMarkersApplied++;
|
|
254
|
-
}
|
|
255
|
-
contentBlocks.push(block);
|
|
256
|
-
}
|
|
257
|
-
// Ensure last block is cached too
|
|
258
|
-
const lastBlock = contentBlocks[contentBlocks.length - 1];
|
|
259
|
-
if (!lastBlock.cache_control && promptCaching) {
|
|
260
|
-
lastBlock.cache_control = cacheControl;
|
|
261
|
-
cacheMarkersApplied++;
|
|
262
|
-
}
|
|
263
|
-
providerMessages.push({
|
|
264
|
-
role: 'assistant',
|
|
265
|
-
content: contentBlocks,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
// Insert image turns between the assistant log and the cat command
|
|
269
|
-
// These are user turns containing image content
|
|
270
|
-
for (const imageTurn of imageTurns) {
|
|
271
|
-
// Need a brief assistant acknowledgment to maintain alternating turns
|
|
272
|
-
providerMessages.push({
|
|
273
|
-
role: 'assistant',
|
|
274
|
-
content: '[image received]',
|
|
275
|
-
});
|
|
276
|
-
providerMessages.push(imageTurn);
|
|
277
|
-
}
|
|
278
|
-
// User: continuation command
|
|
279
|
-
// - 'cat': model repeats full file (caller strips repeated log from response)
|
|
280
|
-
// - 'tail-cut': model outputs only chars after the cut point
|
|
281
|
-
const continuationCmd = this.config.continuationMode === 'tail-cut'
|
|
282
|
-
? `<cmd>cut -c ${charCount + 1}- < ${filename}</cmd>`
|
|
283
|
-
: `<cmd>cat ${filename}</cmd>`;
|
|
284
|
-
providerMessages.push({
|
|
285
|
-
role: 'user',
|
|
286
|
-
content: continuationCmd,
|
|
287
|
-
});
|
|
288
|
-
// 4. Build stop sequences from participant names
|
|
289
|
-
// NOTE: For pseudo-prefill, API-level stop sequences are problematic because
|
|
290
|
-
// in 'cat' mode the model repeats the conversation log (which contains
|
|
291
|
-
// participant names that would trigger stops prematurely).
|
|
292
|
-
// The caller should handle stop sequences post-facto after stripping the log.
|
|
293
|
-
// We still return them here for the caller to use in post-facto detection.
|
|
294
|
-
const stopSequences = this.buildStopSequences(messages, assistantParticipant, options);
|
|
295
|
-
// 5. Native tools
|
|
296
|
-
const nativeTools = tools?.length ? this.convertToNativeTools(tools) : undefined;
|
|
297
|
-
return {
|
|
298
|
-
messages: providerMessages,
|
|
299
|
-
systemContent,
|
|
300
|
-
// No assistantPrefill — model generates a new assistant turn after continuation command
|
|
301
|
-
assistantPrefill: undefined,
|
|
302
|
-
stopSequences,
|
|
303
|
-
nativeTools,
|
|
304
|
-
cacheMarkersApplied,
|
|
305
|
-
// Expose log and mode so callers can strip the repeated log (cat mode)
|
|
306
|
-
// and apply post-facto stop sequences appropriately
|
|
307
|
-
metadata: {
|
|
308
|
-
conversationLog: fullLog,
|
|
309
|
-
conversationLogLength: charCount,
|
|
310
|
-
continuationMode: this.config.continuationMode,
|
|
311
|
-
assistantParticipant: assistantParticipant,
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
formatToolResults(results) {
|
|
316
|
-
// Native mode uses API tool_result blocks
|
|
317
|
-
return JSON.stringify(results.map(r => ({
|
|
318
|
-
tool_use_id: r.toolUseId,
|
|
319
|
-
content: r.content,
|
|
320
|
-
is_error: r.isError,
|
|
321
|
-
})));
|
|
322
|
-
}
|
|
323
|
-
// ==========================================================================
|
|
324
|
-
// RESPONSE PARSING
|
|
325
|
-
// ==========================================================================
|
|
326
|
-
createStreamParser() {
|
|
327
|
-
return new PassthroughParser();
|
|
328
|
-
}
|
|
329
|
-
parseToolCalls(_content) {
|
|
330
|
-
// Native mode gets tool calls from API response
|
|
331
|
-
return [];
|
|
332
|
-
}
|
|
333
|
-
hasToolUse(_content) {
|
|
334
|
-
// Native mode determines tool use from API stop_reason
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
parseContentBlocks(content) {
|
|
338
|
-
if (!content.trim()) {
|
|
339
|
-
return [];
|
|
340
|
-
}
|
|
341
|
-
return [{ type: 'text', text: content }];
|
|
342
|
-
}
|
|
343
|
-
// ==========================================================================
|
|
344
|
-
// PRIVATE HELPERS
|
|
345
|
-
// ==========================================================================
|
|
346
|
-
extractContent(content, participant) {
|
|
347
|
-
const parts = [];
|
|
348
|
-
const images = [];
|
|
349
|
-
let hasUnsupportedMedia = false;
|
|
350
|
-
for (const block of content) {
|
|
351
|
-
if (block.type === 'text') {
|
|
352
|
-
parts.push(block.text);
|
|
353
|
-
}
|
|
354
|
-
else if (block.type === 'image') {
|
|
355
|
-
if (block.source.type === 'base64') {
|
|
356
|
-
images.push({
|
|
357
|
-
type: 'image',
|
|
358
|
-
source: {
|
|
359
|
-
type: 'base64',
|
|
360
|
-
media_type: block.source.mediaType,
|
|
361
|
-
data: block.source.data,
|
|
362
|
-
},
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
else if (block.type === 'tool_use') {
|
|
367
|
-
parts.push(`${participant}>[${block.name}]: ${JSON.stringify(block.input)}`);
|
|
368
|
-
}
|
|
369
|
-
else if (block.type === 'tool_result') {
|
|
370
|
-
const resultText = typeof block.content === 'string'
|
|
371
|
-
? block.content
|
|
372
|
-
: JSON.stringify(block.content);
|
|
373
|
-
parts.push(`${participant}<[tool_result]: ${resultText}`);
|
|
374
|
-
}
|
|
375
|
-
else if (block.type === 'document' || block.type === 'audio') {
|
|
376
|
-
hasUnsupportedMedia = true;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
return { text: parts.join('\n'), images, hasUnsupportedMedia };
|
|
380
|
-
}
|
|
381
|
-
buildStopSequences(messages, assistantName, options) {
|
|
382
|
-
const sequences = [];
|
|
383
|
-
const maxParticipants = options.maxParticipantsForStop ?? this.config.maxParticipantsForStop;
|
|
384
|
-
// Collect unique participants (excluding assistant) from recent messages
|
|
385
|
-
const participants = new Set();
|
|
386
|
-
for (let i = messages.length - 1; i >= 0 && participants.size < maxParticipants; i--) {
|
|
387
|
-
const message = messages[i];
|
|
388
|
-
if (message && message.participant !== assistantName) {
|
|
389
|
-
participants.add(message.participant);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
// Participant-based stops (same format as AnthropicXmlFormatter)
|
|
393
|
-
for (const participant of participants) {
|
|
394
|
-
sequences.push(`\n${participant}:`);
|
|
395
|
-
}
|
|
396
|
-
// Add any additional stop sequences from options
|
|
397
|
-
if (options.additionalStopSequences?.length) {
|
|
398
|
-
sequences.push(...options.additionalStopSequences);
|
|
399
|
-
}
|
|
400
|
-
return sequences;
|
|
401
|
-
}
|
|
402
|
-
convertToNativeTools(tools) {
|
|
403
|
-
return tools.map(tool => ({
|
|
404
|
-
name: tool.name,
|
|
405
|
-
description: tool.description,
|
|
406
|
-
input_schema: tool.inputSchema,
|
|
407
|
-
}));
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
//# sourceMappingURL=pseudo-prefill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pseudo-prefill.js","sourceRoot":"","sources":["../../src/formatters/pseudo-prefill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA0DH,+EAA+E;AAC/E,uDAAuD;AACvD,+EAA+E;AAE/E,MAAM,iBAAiB;IACb,WAAW,GAAG,EAAE,CAAC;IACjB,UAAU,GAAG,CAAC,CAAC;IACf,YAAY,GAAG,KAAK,CAAC;IAE7B,YAAY,CAAC,KAAa;QACxB,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC;QAC1B,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,MAAe;YACrB,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;QAEF,MAAM,SAAS,GAAqB,EAAE,CAAC;QACvC,MAAM,WAAW,GAAiB,EAAE,CAAC;QAErC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,UAAU,GAAe;gBAC7B,KAAK,EAAE,aAAa;gBACpB,KAAK,EAAE,IAAI,CAAC,UAAU;gBACtB,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;aACxB,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;YAC1D,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE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AE,CAAC;YACrF,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5B,IAAI,OAAO,IAAI,OAAO,CAAC,WAAW,KAAK,aAAa,EAAE,CAAC;gBACrD,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAED,iEAAiE;QACjE,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,SAAS,CAAC,IAAI,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC;QACtC,CAAC;QAED,iDAAiD;QACjD,IAAI,OAAO,CAAC,uBAAuB,EAAE,MAAM,EAAE,CAAC;YAC5C,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,oBAAoB,CAAC,KAAuB;QAClD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,WAAW;SAC/B,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
|
|
@@ -1,89 +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 type { NormalizedRequest, CacheControl } from '../types/index.js';
|
|
18
|
-
/**
|
|
19
|
-
* Content block in provider format (Anthropic-style)
|
|
20
|
-
* Can include cache_control for prompt caching
|
|
21
|
-
*/
|
|
22
|
-
export interface ProviderTextBlock {
|
|
23
|
-
type: 'text';
|
|
24
|
-
text: string;
|
|
25
|
-
cache_control?: CacheControl;
|
|
26
|
-
}
|
|
27
|
-
export interface ProviderImageBlock {
|
|
28
|
-
type: 'image';
|
|
29
|
-
source: {
|
|
30
|
-
type: 'base64';
|
|
31
|
-
media_type: string;
|
|
32
|
-
data: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export type ProviderContentBlock = ProviderTextBlock | ProviderImageBlock;
|
|
36
|
-
export interface ProviderMessage {
|
|
37
|
-
role: 'user' | 'assistant';
|
|
38
|
-
content: string | ProviderContentBlock[];
|
|
39
|
-
}
|
|
40
|
-
export interface PrefillTransformResult {
|
|
41
|
-
/** System prompt content blocks (may have cache_control) */
|
|
42
|
-
systemContent: ProviderContentBlock[];
|
|
43
|
-
/** Messages in provider format (ready for API) */
|
|
44
|
-
messages: ProviderMessage[];
|
|
45
|
-
/** For legacy compatibility: system as string */
|
|
46
|
-
system: string;
|
|
47
|
-
/** For legacy compatibility: user content as string */
|
|
48
|
-
userContent: string;
|
|
49
|
-
/** For legacy compatibility: assistant prefill as string */
|
|
50
|
-
assistantPrefill: string;
|
|
51
|
-
/** Stop sequences to use */
|
|
52
|
-
stopSequences: string[];
|
|
53
|
-
/** Number of cache markers applied */
|
|
54
|
-
cacheMarkersApplied: number;
|
|
55
|
-
}
|
|
56
|
-
export interface PrefillTransformOptions {
|
|
57
|
-
/** Name of the assistant participant (default: 'Claude') */
|
|
58
|
-
assistantName?: string;
|
|
59
|
-
/** Maximum participants to include in stop sequences */
|
|
60
|
-
maxParticipantsForStop?: number;
|
|
61
|
-
/** Custom stop sequences to add */
|
|
62
|
-
additionalStopSequences?: string[];
|
|
63
|
-
/**
|
|
64
|
-
* Where to inject tool definitions:
|
|
65
|
-
* - 'conversation': Inject into assistant content ~N messages from end (default)
|
|
66
|
-
* - 'system': Inject into system prompt
|
|
67
|
-
* - 'none': No injection (use getToolInstructions() for manual placement)
|
|
68
|
-
*/
|
|
69
|
-
toolInjectionMode?: 'conversation' | 'system' | 'none';
|
|
70
|
-
/** Position to inject tools when mode is 'conversation' (from end of messages) */
|
|
71
|
-
toolInjectionPosition?: number;
|
|
72
|
-
/** Enable prompt caching (default: true) */
|
|
73
|
-
promptCaching?: boolean;
|
|
74
|
-
/** Message delimiter for base models (e.g., '</s>') */
|
|
75
|
-
messageDelimiter?: string;
|
|
76
|
-
/** Context prefix for simulacrum seeding */
|
|
77
|
-
contextPrefix?: string;
|
|
78
|
-
/** Start assistant response with <thinking> tag */
|
|
79
|
-
prefillThinking?: boolean;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Transform normalized request to prefill format with cache control support
|
|
83
|
-
*/
|
|
84
|
-
export declare function transformToPrefill(request: NormalizedRequest, options?: PrefillTransformOptions): PrefillTransformResult;
|
|
85
|
-
/**
|
|
86
|
-
* Build a continuation request from accumulated output
|
|
87
|
-
*/
|
|
88
|
-
export declare function buildContinuationPrefill(originalResult: PrefillTransformResult, accumulated: string): PrefillTransformResult;
|
|
89
|
-
//# sourceMappingURL=prefill.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prefill.d.ts","sourceRoot":"","sources":["../../src/transforms/prefill.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAEV,iBAAiB,EAGjB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAQ3B;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QACN,IAAI,EAAE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