@opencow-ai/opencow-agent-sdk 0.4.10 → 0.4.12

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/cli.mjs CHANGED
@@ -5484,6 +5484,27 @@ var init_types = __esm(() => {
5484
5484
  CanonicalUserAbortError = APIUserAbortError;
5485
5485
  });
5486
5486
 
5487
+ // src/session/canonical/imageSource.ts
5488
+ function normalizeCanonicalImageSource(source) {
5489
+ if (!source || typeof source !== "object")
5490
+ return null;
5491
+ const s = source;
5492
+ if (s.type === "base64" && typeof s.data === "string") {
5493
+ return {
5494
+ kind: "base64",
5495
+ mediaType: typeof s.media_type === "string" ? s.media_type : "image/png",
5496
+ data: s.data
5497
+ };
5498
+ }
5499
+ if (s.type === "url" && typeof s.url === "string") {
5500
+ return { kind: "url", url: s.url };
5501
+ }
5502
+ return null;
5503
+ }
5504
+ function imageSourceToDataUri(img) {
5505
+ return img.kind === "base64" ? `data:${img.mediaType};base64,${img.data}` : img.url;
5506
+ }
5507
+
5487
5508
  // src/session/canonical/index.ts
5488
5509
  var init_canonical = __esm(() => {
5489
5510
  init_types();
@@ -83971,6 +83992,71 @@ var init_geminiAuth = __esm(() => {
83971
83992
  }, {}), GEMINI_ADC_CACHE_TTL_MS);
83972
83993
  });
83973
83994
 
83995
+ // src/providers/shared/dsmlSentinel.ts
83996
+ function normalizeDsmlSentinel(value) {
83997
+ return value.replace(/|/g, "|").replace(/\s+/g, "");
83998
+ }
83999
+ function isDsmlFunctionCallSentinelPrefix(value) {
84000
+ const normalized = normalizeDsmlSentinel(value);
84001
+ return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
84002
+ }
84003
+ function findDsmlFunctionCallSentinel(text) {
84004
+ const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
84005
+ const match = re.exec(text);
84006
+ if (!match || match.index === undefined)
84007
+ return null;
84008
+ return { start: match.index, end: match.index + match[0].length };
84009
+ }
84010
+ function findTrailingDsmlCandidateStart(text) {
84011
+ for (let i2 = 0;i2 < text.length; i2++) {
84012
+ if (isDsmlFunctionCallSentinelPrefix(text.slice(i2))) {
84013
+ return i2;
84014
+ }
84015
+ }
84016
+ return null;
84017
+ }
84018
+ function createDsmlFunctionCallTextFilter() {
84019
+ let pending = "";
84020
+ const drain = (final) => {
84021
+ let output = "";
84022
+ while (pending) {
84023
+ const sentinel = findDsmlFunctionCallSentinel(pending);
84024
+ if (sentinel) {
84025
+ output += pending.slice(0, sentinel.start).trimEnd();
84026
+ pending = pending.slice(sentinel.end);
84027
+ continue;
84028
+ }
84029
+ if (final) {
84030
+ output += pending;
84031
+ pending = "";
84032
+ break;
84033
+ }
84034
+ const candidateStart = findTrailingDsmlCandidateStart(pending);
84035
+ if (candidateStart === null) {
84036
+ output += pending;
84037
+ pending = "";
84038
+ break;
84039
+ }
84040
+ output += pending.slice(0, candidateStart).trimEnd();
84041
+ pending = pending.slice(candidateStart);
84042
+ break;
84043
+ }
84044
+ return output;
84045
+ };
84046
+ return {
84047
+ push(text) {
84048
+ if (!text)
84049
+ return "";
84050
+ pending += text;
84051
+ return drain(false);
84052
+ },
84053
+ flush() {
84054
+ return drain(true);
84055
+ }
84056
+ };
84057
+ }
84058
+ var DSML_FUNCTION_CALL_SENTINEL = "<|DSML|function_calls";
84059
+
83974
84060
  // src/providers/shared/geminiCredentials.ts
83975
84061
  var exports_geminiCredentials = {};
83976
84062
  __export(exports_geminiCredentials, {
@@ -84593,19 +84679,9 @@ function splitToolResultMedia(content) {
84593
84679
  continue;
84594
84680
  }
84595
84681
  if (block?.type === "image") {
84596
- const src = block.source;
84597
- if (src?.type === "base64" && typeof src.data === "string") {
84598
- images.push({
84599
- kind: "base64",
84600
- mediaType: src.media_type ?? "image/png",
84601
- data: src.data
84602
- });
84603
- continue;
84604
- }
84605
- if (src?.type === "url" && typeof src.url === "string") {
84606
- images.push({ kind: "url", url: src.url });
84607
- continue;
84608
- }
84682
+ const img = normalizeCanonicalImageSource(block.source);
84683
+ if (img)
84684
+ images.push(img);
84609
84685
  continue;
84610
84686
  }
84611
84687
  if (typeof block?.text === "string") {
@@ -84616,8 +84692,7 @@ function splitToolResultMedia(content) {
84616
84692
  `), images };
84617
84693
  }
84618
84694
  function toResponsesInputImagePart(img) {
84619
- const url3 = img.kind === "base64" ? `data:${img.mediaType};base64,${img.data}` : img.url;
84620
- return { type: "input_image", image_url: url3 };
84695
+ return { type: "input_image", image_url: imageSourceToDataUri(img) };
84621
84696
  }
84622
84697
  function convertContentBlocksToResponsesParts(content, role) {
84623
84698
  const textType = role === "assistant" ? "output_text" : "input_text";
@@ -84636,18 +84711,9 @@ function convertContentBlocksToResponsesParts(content, role) {
84636
84711
  case "image": {
84637
84712
  if (role === "assistant")
84638
84713
  break;
84639
- const source = block.source;
84640
- if (source?.type === "base64") {
84641
- parts.push({
84642
- type: "input_image",
84643
- image_url: `data:${source.media_type};base64,${source.data}`
84644
- });
84645
- } else if (source?.type === "url" && source.url) {
84646
- parts.push({
84647
- type: "input_image",
84648
- image_url: source.url
84649
- });
84650
- }
84714
+ const img = normalizeCanonicalImageSource(block.source);
84715
+ if (img)
84716
+ parts.push(toResponsesInputImagePart(img));
84651
84717
  break;
84652
84718
  }
84653
84719
  case "thinking":
@@ -84957,9 +85023,21 @@ async function* codexStreamToAnthropic(response, model) {
84957
85023
  let nextContentBlockIndex = 0;
84958
85024
  let sawToolUse = false;
84959
85025
  let finalResponse;
85026
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
84960
85027
  const closeActiveTextBlock = async function* () {
84961
85028
  if (activeTextBlockIndex === null)
84962
85029
  return;
85030
+ const flushedText = dsmlTextFilter.flush();
85031
+ if (flushedText) {
85032
+ yield {
85033
+ type: "content_block_delta",
85034
+ index: activeTextBlockIndex,
85035
+ delta: {
85036
+ type: "text_delta",
85037
+ text: flushedText
85038
+ }
85039
+ };
85040
+ }
84963
85041
  yield {
84964
85042
  type: "content_block_stop",
84965
85043
  index: activeTextBlockIndex
@@ -85071,14 +85149,17 @@ async function* codexStreamToAnthropic(response, model) {
85071
85149
  if (event.event === "response.output_text.delta") {
85072
85150
  yield* startTextBlockIfNeeded();
85073
85151
  if (activeTextBlockIndex !== null) {
85074
- yield {
85075
- type: "content_block_delta",
85076
- index: activeTextBlockIndex,
85077
- delta: {
85078
- type: "text_delta",
85079
- text: payload.delta ?? ""
85080
- }
85081
- };
85152
+ const filteredText = dsmlTextFilter.push(payload.delta ?? "");
85153
+ if (filteredText) {
85154
+ yield {
85155
+ type: "content_block_delta",
85156
+ index: activeTextBlockIndex,
85157
+ delta: {
85158
+ type: "text_delta",
85159
+ text: filteredText
85160
+ }
85161
+ };
85162
+ }
85082
85163
  }
85083
85164
  continue;
85084
85165
  }
@@ -85220,6 +85301,7 @@ var init_shim = __esm(() => {
85220
85301
  init_sdk();
85221
85302
  init_schema();
85222
85303
  init_capabilities2();
85304
+ init_canonical();
85223
85305
  });
85224
85306
 
85225
85307
  // src/providers/openai/shim.ts
@@ -85287,19 +85369,9 @@ function splitToolResultMedia2(content) {
85287
85369
  continue;
85288
85370
  }
85289
85371
  if (block?.type === "image") {
85290
- const source = block.source;
85291
- if (source?.type === "base64" && typeof source.data === "string") {
85292
- images.push({
85293
- kind: "base64",
85294
- mediaType: source.media_type ?? "image/png",
85295
- data: source.data
85296
- });
85297
- continue;
85298
- }
85299
- if (source?.type === "url" && typeof source.url === "string") {
85300
- images.push({ kind: "url", url: source.url });
85301
- continue;
85302
- }
85372
+ const img = normalizeCanonicalImageSource(block.source);
85373
+ if (img)
85374
+ images.push(img);
85303
85375
  continue;
85304
85376
  }
85305
85377
  if (block?.type === "tool_reference" && typeof block.tool_name === "string") {
@@ -85314,8 +85386,7 @@ function splitToolResultMedia2(content) {
85314
85386
  `), images };
85315
85387
  }
85316
85388
  function toOpenAIImageUrl(img) {
85317
- const url3 = img.kind === "base64" ? `data:${img.mediaType};base64,${img.data}` : img.url;
85318
- return { type: "image_url", image_url: { url: url3 } };
85389
+ return { type: "image_url", image_url: { url: imageSourceToDataUri(img) } };
85319
85390
  }
85320
85391
  function convertContentBlocks(content) {
85321
85392
  if (typeof content === "string")
@@ -85329,17 +85400,9 @@ function convertContentBlocks(content) {
85329
85400
  parts.push({ type: "text", text: block.text ?? "" });
85330
85401
  break;
85331
85402
  case "image": {
85332
- const src = block.source;
85333
- if (src?.type === "base64") {
85334
- parts.push({
85335
- type: "image_url",
85336
- image_url: {
85337
- url: `data:${src.media_type};base64,${src.data}`
85338
- }
85339
- });
85340
- } else if (src?.type === "url") {
85341
- parts.push({ type: "image_url", image_url: { url: src.url } });
85342
- }
85403
+ const img = normalizeCanonicalImageSource(block.source);
85404
+ if (img)
85405
+ parts.push(toOpenAIImageUrl(img));
85343
85406
  break;
85344
85407
  }
85345
85408
  case "tool_use":
@@ -85609,32 +85672,6 @@ function buildOpenAIRequestBody(params, ctx) {
85609
85672
  }
85610
85673
  return body;
85611
85674
  }
85612
- function normalizeDsmlSentinelPrefix(value) {
85613
- return value.replace(/|/g, "|").replace(/\s+/g, "");
85614
- }
85615
- function isDsmlFunctionCallSentinelPrefix(value) {
85616
- const normalized = normalizeDsmlSentinelPrefix(value);
85617
- return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
85618
- }
85619
- function findTrailingDsmlSentinelCandidateStart(text) {
85620
- const lt = text.lastIndexOf("<");
85621
- if (lt === -1)
85622
- return null;
85623
- return isDsmlFunctionCallSentinelPrefix(text.slice(lt)) ? lt : null;
85624
- }
85625
- function findBufferedTextFlushBoundary(text) {
85626
- const sentinelStart = findTrailingDsmlSentinelCandidateStart(text);
85627
- if (sentinelStart === null)
85628
- return text.length;
85629
- return text.slice(0, sentinelStart).trimEnd().length;
85630
- }
85631
- function findDsmlFunctionCallSentinel(text) {
85632
- const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
85633
- const match = re.exec(text);
85634
- if (!match || match.index === undefined)
85635
- return null;
85636
- return { start: match.index, end: match.index + match[0].length };
85637
- }
85638
85675
  async function* openaiStreamToAnthropic(response, model) {
85639
85676
  const messageId = makeMessageId2();
85640
85677
  let contentBlockIndex = 0;
@@ -85646,27 +85683,13 @@ async function* openaiStreamToAnthropic(response, model) {
85646
85683
  let hasEmittedFinalUsage = false;
85647
85684
  let hasProcessedFinishReason = false;
85648
85685
  let pendingTextBuffer = "";
85686
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
85649
85687
  const emitBufferedText = (mode) => {
85650
85688
  const events = [];
85651
- if (!pendingTextBuffer)
85652
- return events;
85653
- const sentinel = findDsmlFunctionCallSentinel(pendingTextBuffer);
85654
- if (sentinel) {
85655
- const visible2 = pendingTextBuffer.slice(0, sentinel.start).trimEnd();
85656
- pendingTextBuffer = pendingTextBuffer.slice(sentinel.end);
85657
- if (visible2) {
85658
- events.push(...emitTextDeltaEvents(visible2));
85659
- }
85660
- if (pendingTextBuffer) {
85661
- events.push(...emitBufferedText(mode));
85662
- }
85663
- return events;
85664
- }
85665
- const emitUntil = mode === "final" ? pendingTextBuffer.length : mode === "before_tool_call" ? findTrailingDsmlSentinelCandidateStart(pendingTextBuffer) ?? pendingTextBuffer.length : findBufferedTextFlushBoundary(pendingTextBuffer);
85666
- if (emitUntil <= 0)
85689
+ if (!pendingTextBuffer && mode !== "final")
85667
85690
  return events;
85668
- const visible = pendingTextBuffer.slice(0, emitUntil);
85669
- pendingTextBuffer = pendingTextBuffer.slice(emitUntil);
85691
+ const visible = mode === "final" ? dsmlTextFilter.push(pendingTextBuffer) + dsmlTextFilter.flush() : dsmlTextFilter.push(pendingTextBuffer);
85692
+ pendingTextBuffer = "";
85670
85693
  if (visible) {
85671
85694
  events.push(...emitTextDeltaEvents(visible));
85672
85695
  }
@@ -86243,7 +86266,7 @@ function createOpenAIShimClient(options) {
86243
86266
  messages: beta.messages
86244
86267
  };
86245
86268
  }
86246
- var GITHUB_MODELS_DEFAULT_BASE = "https://models.github.ai/inference", GITHUB_API_VERSION = "2022-11-28", GITHUB_429_MAX_RETRIES = 3, GITHUB_429_BASE_DELAY_SEC = 1, GITHUB_429_MAX_DELAY_SEC = 32, DSML_FUNCTION_CALL_SENTINEL = "<|DSML|function_calls", OpenAIShimStream;
86269
+ var GITHUB_MODELS_DEFAULT_BASE = "https://models.github.ai/inference", GITHUB_API_VERSION = "2022-11-28", GITHUB_429_MAX_RETRIES = 3, GITHUB_429_BASE_DELAY_SEC = 1, GITHUB_429_MAX_DELAY_SEC = 32, OpenAIShimStream;
86247
86270
  var init_shim2 = __esm(() => {
86248
86271
  init_sdk();
86249
86272
  init_envUtils();
@@ -86256,6 +86279,7 @@ var init_shim2 = __esm(() => {
86256
86279
  init_schemaSanitizer();
86257
86280
  init_providerProfile();
86258
86281
  init_capabilities2();
86282
+ init_canonical();
86259
86283
  OpenAIShimStream = class OpenAIShimStream {
86260
86284
  generator;
86261
86285
  controller = new AbortController;
@@ -94500,7 +94524,7 @@ function printStartupScreen() {
94500
94524
  const sLen = ` ● ${sL} Ready — type /help to begin`.length;
94501
94525
  out.push(boxRow(sRow, W2, sLen));
94502
94526
  out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
94503
- out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.10"}${RESET}`);
94527
+ out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.12"}${RESET}`);
94504
94528
  out.push("");
94505
94529
  process.stdout.write(out.join(`
94506
94530
  `) + `
@@ -120443,6 +120467,16 @@ async function validateContentTokens(content, ext, maxTokens) {
120443
120467
  throw new MaxFileReadTokenExceededError(effectiveCount, effectiveMaxTokens);
120444
120468
  }
120445
120469
  }
120470
+ async function maybeUploadBytes(uploadMedia, bytes, mediaType) {
120471
+ if (!uploadMedia)
120472
+ return null;
120473
+ try {
120474
+ return await uploadMedia({ bytes, mediaType });
120475
+ } catch (e) {
120476
+ logError(e);
120477
+ return null;
120478
+ }
120479
+ }
120446
120480
  function createImageResponse(buffer, mediaType, originalSize, dimensions) {
120447
120481
  return {
120448
120482
  type: "image",
@@ -120490,6 +120524,10 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
120490
120524
  if (IMAGE_EXTENSIONS.has(ext)) {
120491
120525
  const data2 = await readImageWithTokenBudget(resolvedFilePath, maxTokens);
120492
120526
  context3.nestedMemoryAttachmentTriggers?.add(fullFilePath);
120527
+ const uploadedUrl = await maybeUploadBytes(context3.uploadMedia, Buffer.from(data2.file.base64, "base64"), data2.file.type);
120528
+ if (uploadedUrl) {
120529
+ data2.file.url = uploadedUrl;
120530
+ }
120493
120531
  logFileOperation({
120494
120532
  operation: "read",
120495
120533
  tool: "FileReadTool",
@@ -120531,14 +120569,14 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
120531
120569
  const imgPath = path11.join(extractResult.data.file.outputDir, f);
120532
120570
  const imgBuffer = await getFsImplementation().readFile(imgPath);
120533
120571
  const resized = await maybeResizeAndDownsampleImageBuffer(imgBuffer, imgBuffer.length, "jpeg");
120534
- return {
120535
- type: "image",
120536
- source: {
120537
- type: "base64",
120538
- media_type: `image/${resized.mediaType}`,
120539
- data: resized.buffer.toString("base64")
120540
- }
120572
+ const mediaType = `image/${resized.mediaType}`;
120573
+ const uploadedUrl2 = await maybeUploadBytes(context3.uploadMedia, resized.buffer, mediaType);
120574
+ const source = uploadedUrl2 ? { type: "url", url: uploadedUrl2 } : {
120575
+ type: "base64",
120576
+ media_type: mediaType,
120577
+ data: resized.buffer.toString("base64")
120541
120578
  };
120579
+ return { type: "image", source };
120542
120580
  }));
120543
120581
  return {
120544
120582
  data: extractResult.data,
@@ -120586,20 +120624,17 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
120586
120624
  filePath: fullFilePath,
120587
120625
  content: pdfData.file.base64
120588
120626
  });
120627
+ const uploadedUrl = await maybeUploadBytes(context3.uploadMedia, Buffer.from(pdfData.file.base64, "base64"), "application/pdf");
120628
+ const documentSource = uploadedUrl ? { type: "url", url: uploadedUrl } : {
120629
+ type: "base64",
120630
+ media_type: "application/pdf",
120631
+ data: pdfData.file.base64
120632
+ };
120589
120633
  return {
120590
120634
  data: pdfData,
120591
120635
  newMessages: [
120592
120636
  createUserMessage({
120593
- content: [
120594
- {
120595
- type: "document",
120596
- source: {
120597
- type: "base64",
120598
- media_type: "application/pdf",
120599
- data: pdfData.file.base64
120600
- }
120601
- }
120602
- ],
120637
+ content: [{ type: "document", source: documentSource }],
120603
120638
  isMeta: true
120604
120639
  })
120605
120640
  ]
@@ -120806,6 +120841,7 @@ var init_FileReadTool = __esm(() => {
120806
120841
  base64: exports_external.string().describe("Base64-encoded image data"),
120807
120842
  type: imageMediaTypes.describe("The MIME type of the image"),
120808
120843
  originalSize: exports_external.number().describe("Original file size in bytes"),
120844
+ url: exports_external.string().optional().describe("Fetchable URL for the (compressed) image when a host uploader is configured; takes precedence over base64 for rendering"),
120809
120845
  dimensions: exports_external.object({
120810
120846
  originalWidth: exports_external.number().optional().describe("Original image width in pixels"),
120811
120847
  originalHeight: exports_external.number().optional().describe("Original image height in pixels"),
@@ -121034,17 +121070,18 @@ var init_FileReadTool = __esm(() => {
121034
121070
  mapToolResultToToolResultBlockParam(data, toolUseID) {
121035
121071
  switch (data.type) {
121036
121072
  case "image": {
121073
+ const source = data.file.url ? { type: "url", url: data.file.url } : {
121074
+ type: "base64",
121075
+ data: data.file.base64,
121076
+ media_type: data.file.type
121077
+ };
121037
121078
  return {
121038
121079
  tool_use_id: toolUseID,
121039
121080
  type: "tool_result",
121040
121081
  content: [
121041
121082
  {
121042
121083
  type: "image",
121043
- source: {
121044
- type: "base64",
121045
- data: data.file.base64,
121046
- media_type: data.file.type
121047
- }
121084
+ source
121048
121085
  }
121049
121086
  ]
121050
121087
  };
@@ -244370,7 +244407,7 @@ function getAnthropicEnvMetadata() {
244370
244407
  function getBuildAgeMinutes() {
244371
244408
  if (false)
244372
244409
  ;
244373
- const buildTime = new Date("2026-06-23T14:32:49.206Z").getTime();
244410
+ const buildTime = new Date("2026-06-24T10:02:32.669Z").getTime();
244374
244411
  if (isNaN(buildTime))
244375
244412
  return;
244376
244413
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -292993,9 +293030,21 @@ var init_mcpWebSocketTransport = __esm(() => {
292993
293030
  });
292994
293031
 
292995
293032
  // src/capabilities/adapters/callToolResultAdapter.ts
293033
+ async function buildImageBlock(bytes, mediaType, uploadMedia) {
293034
+ let url3 = null;
293035
+ if (uploadMedia) {
293036
+ try {
293037
+ url3 = await uploadMedia({ bytes, mediaType });
293038
+ } catch (e) {
293039
+ logError(e);
293040
+ }
293041
+ }
293042
+ const source = url3 ? { type: "url", url: url3 } : { type: "base64", media_type: mediaType, data: bytes.toString("base64") };
293043
+ return { type: "image", source };
293044
+ }
292996
293045
  async function translateMcpContentItem(input) {
292997
293046
  const { item, options: options2 } = input;
292998
- const { sourceName } = options2;
293047
+ const { sourceName, uploadMedia } = options2;
292999
293048
  switch (item.type) {
293000
293049
  case "text":
293001
293050
  return [{ type: "text", text: item.text }];
@@ -293013,14 +293062,7 @@ async function translateMcpContentItem(input) {
293013
293062
  const ext = item.mimeType?.split("/")[1] || "png";
293014
293063
  const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
293015
293064
  return [
293016
- {
293017
- type: "image",
293018
- source: {
293019
- data: resized.buffer.toString("base64"),
293020
- media_type: `image/${resized.mediaType}`,
293021
- type: "base64"
293022
- }
293023
- }
293065
+ await buildImageBlock(resized.buffer, `image/${resized.mediaType}`, uploadMedia)
293024
293066
  ];
293025
293067
  }
293026
293068
  case "resource": {
@@ -293037,14 +293079,7 @@ async function translateMcpContentItem(input) {
293037
293079
  const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
293038
293080
  return [
293039
293081
  { type: "text", text: prefix },
293040
- {
293041
- type: "image",
293042
- source: {
293043
- data: resized.buffer.toString("base64"),
293044
- media_type: `image/${resized.mediaType}`,
293045
- type: "base64"
293046
- }
293047
- }
293082
+ await buildImageBlock(resized.buffer, `image/${resized.mediaType}`, uploadMedia)
293048
293083
  ];
293049
293084
  }
293050
293085
  return await persistBlobToTextBlock({
@@ -293090,6 +293125,7 @@ var IMAGE_MIME_TYPES;
293090
293125
  var init_callToolResultAdapter = __esm(() => {
293091
293126
  init_imageResizer();
293092
293127
  init_mcpOutputStorage();
293128
+ init_log2();
293093
293129
  IMAGE_MIME_TYPES = new Set([
293094
293130
  "image/jpeg",
293095
293131
  "image/png",
@@ -307798,6 +307834,7 @@ ${deferredToolList}
307798
307834
  const STALL_THRESHOLD_MS2 = 30000;
307799
307835
  let totalStallTime = 0;
307800
307836
  let stallCount = 0;
307837
+ const dsmlTextFilters = new Map;
307801
307838
  for await (const part of stream4) {
307802
307839
  resetStreamIdleTimer();
307803
307840
  const now = Date.now();
@@ -307864,6 +307901,7 @@ ${deferredToolList}
307864
307901
  ...part.content_block,
307865
307902
  text: ""
307866
307903
  };
307904
+ dsmlTextFilters.set(part.index, createDsmlFunctionCallTextFilter());
307867
307905
  break;
307868
307906
  case "thinking":
307869
307907
  contentBlocks[part.index] = {
@@ -307923,7 +307961,13 @@ ${deferredToolList}
307923
307961
  });
307924
307962
  throw new Error("Content block is not a text block");
307925
307963
  }
307926
- contentBlock.text += delta.text;
307964
+ {
307965
+ const filter2 = dsmlTextFilters.get(part.index) ?? createDsmlFunctionCallTextFilter();
307966
+ dsmlTextFilters.set(part.index, filter2);
307967
+ const visibleText = filter2.push(delta.text);
307968
+ delta.text = visibleText;
307969
+ contentBlock.text += visibleText;
307970
+ }
307927
307971
  break;
307928
307972
  case "signature_delta":
307929
307973
  if (false) {}
@@ -307972,6 +308016,11 @@ ${deferredToolList}
307972
308016
  });
307973
308017
  throw new Error("Message not found");
307974
308018
  }
308019
+ const filter2 = dsmlTextFilters.get(part.index);
308020
+ if (filter2 && contentBlock.type === "text") {
308021
+ contentBlock.text += filter2.flush();
308022
+ dsmlTextFilters.delete(part.index);
308023
+ }
307975
308024
  const m = {
307976
308025
  message: {
307977
308026
  ...partialMessage,
@@ -479733,7 +479782,7 @@ function buildPrimarySection() {
479733
479782
  }, undefined, false, undefined, this);
479734
479783
  return [{
479735
479784
  label: "Version",
479736
- value: "0.4.10"
479785
+ value: "0.4.12"
479737
479786
  }, {
479738
479787
  label: "Session name",
479739
479788
  value: nameValue
@@ -536055,7 +536104,7 @@ var init_bridge_kick = __esm(() => {
536055
536104
  var call58 = async () => {
536056
536105
  return {
536057
536106
  type: "text",
536058
- value: `${"99.0.0"} (built ${"2026-06-23T14:32:49.206Z"})`
536107
+ value: `${"99.0.0"} (built ${"2026-06-24T10:02:32.669Z"})`
536059
536108
  };
536060
536109
  }, version2, version_default;
536061
536110
  var init_version = __esm(() => {
@@ -558165,7 +558214,7 @@ function WelcomeV2() {
558165
558214
  dimColor: true,
558166
558215
  children: [
558167
558216
  "v",
558168
- "0.4.10",
558217
+ "0.4.12",
558169
558218
  " "
558170
558219
  ]
558171
558220
  }, undefined, true, undefined, this)
@@ -558365,7 +558414,7 @@ function WelcomeV2() {
558365
558414
  dimColor: true,
558366
558415
  children: [
558367
558416
  "v",
558368
- "0.4.10",
558417
+ "0.4.12",
558369
558418
  " "
558370
558419
  ]
558371
558420
  }, undefined, true, undefined, this)
@@ -558591,7 +558640,7 @@ function AppleTerminalWelcomeV2(t0) {
558591
558640
  dimColor: true,
558592
558641
  children: [
558593
558642
  "v",
558594
- "0.4.10",
558643
+ "0.4.12",
558595
558644
  " "
558596
558645
  ]
558597
558646
  }, undefined, true, undefined, this);
@@ -558845,7 +558894,7 @@ function AppleTerminalWelcomeV2(t0) {
558845
558894
  dimColor: true,
558846
558895
  children: [
558847
558896
  "v",
558848
- "0.4.10",
558897
+ "0.4.12",
558849
558898
  " "
558850
558899
  ]
558851
558900
  }, undefined, true, undefined, this);
@@ -569480,6 +569529,7 @@ class QueryEngine {
569480
569529
  agents: agents2 = [],
569481
569530
  setSDKStatus,
569482
569531
  onToolInvoke,
569532
+ uploadMedia,
569483
569533
  orphanedPermission
569484
569534
  } = this.config;
569485
569535
  this.discoveredSkillNames.clear();
@@ -569583,7 +569633,8 @@ class QueryEngine {
569583
569633
  });
569584
569634
  },
569585
569635
  setSDKStatus,
569586
- onToolInvoke
569636
+ onToolInvoke,
569637
+ uploadMedia
569587
569638
  };
569588
569639
  if (orphanedPermission && !this.hasHandledOrphanedPermission) {
569589
569640
  this.hasHandledOrphanedPermission = true;
@@ -569672,7 +569723,8 @@ class QueryEngine {
569672
569723
  setResponseLength: () => {},
569673
569724
  updateFileHistoryState: processUserInputContext.updateFileHistoryState,
569674
569725
  updateAttributionState: processUserInputContext.updateAttributionState,
569675
- setSDKStatus
569726
+ setSDKStatus,
569727
+ uploadMedia
569676
569728
  };
569677
569729
  headlessProfilerCheckpoint("before_skills_plugins");
569678
569730
  const [skills2, { enabled: enabledPlugins }] = await Promise.all([
@@ -570167,6 +570219,7 @@ async function* ask({
570167
570219
  agents: agents2 = [],
570168
570220
  setSDKStatus,
570169
570221
  onToolInvoke,
570222
+ uploadMedia,
570170
570223
  orphanedPermission
570171
570224
  }) {
570172
570225
  const engine = new QueryEngine({
@@ -570199,6 +570252,7 @@ async function* ask({
570199
570252
  includePartialMessages,
570200
570253
  setSDKStatus,
570201
570254
  onToolInvoke,
570255
+ uploadMedia,
570202
570256
  abortController,
570203
570257
  orphanedPermission,
570204
570258
  ...{}
@@ -579702,7 +579756,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
579702
579756
  pendingHookMessages
579703
579757
  }, renderAndRun);
579704
579758
  }
579705
- }).version("0.4.10 (OpenCow)", "-v, --version", "Output the version number");
579759
+ }).version("0.4.12 (OpenCow)", "-v, --version", "Output the version number");
579706
579760
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
579707
579761
  program2.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
579708
579762
  if (canUserConfigureAdvisor()) {
@@ -580348,7 +580402,7 @@ if (false) {}
580348
580402
  async function main2() {
580349
580403
  const args = process.argv.slice(2);
580350
580404
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
580351
- console.log(`${"0.4.10"} (OpenCow)`);
580405
+ console.log(`${"0.4.12"} (OpenCow)`);
580352
580406
  return;
580353
580407
  }
580354
580408
  if (args.includes("--provider")) {
@@ -580466,4 +580520,4 @@ async function main2() {
580466
580520
  }
580467
580521
  main2();
580468
580522
 
580469
- //# debugId=10DA61343644BBA264756E2164756E21
580523
+ //# debugId=61239C1856C7488B64756E2164756E21