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

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
@@ -83971,6 +83971,71 @@ var init_geminiAuth = __esm(() => {
83971
83971
  }, {}), GEMINI_ADC_CACHE_TTL_MS);
83972
83972
  });
83973
83973
 
83974
+ // src/providers/shared/dsmlSentinel.ts
83975
+ function normalizeDsmlSentinel(value) {
83976
+ return value.replace(/|/g, "|").replace(/\s+/g, "");
83977
+ }
83978
+ function isDsmlFunctionCallSentinelPrefix(value) {
83979
+ const normalized = normalizeDsmlSentinel(value);
83980
+ return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
83981
+ }
83982
+ function findDsmlFunctionCallSentinel(text) {
83983
+ const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
83984
+ const match = re.exec(text);
83985
+ if (!match || match.index === undefined)
83986
+ return null;
83987
+ return { start: match.index, end: match.index + match[0].length };
83988
+ }
83989
+ function findTrailingDsmlCandidateStart(text) {
83990
+ for (let i2 = 0;i2 < text.length; i2++) {
83991
+ if (isDsmlFunctionCallSentinelPrefix(text.slice(i2))) {
83992
+ return i2;
83993
+ }
83994
+ }
83995
+ return null;
83996
+ }
83997
+ function createDsmlFunctionCallTextFilter() {
83998
+ let pending = "";
83999
+ const drain = (final) => {
84000
+ let output = "";
84001
+ while (pending) {
84002
+ const sentinel = findDsmlFunctionCallSentinel(pending);
84003
+ if (sentinel) {
84004
+ output += pending.slice(0, sentinel.start).trimEnd();
84005
+ pending = pending.slice(sentinel.end);
84006
+ continue;
84007
+ }
84008
+ if (final) {
84009
+ output += pending;
84010
+ pending = "";
84011
+ break;
84012
+ }
84013
+ const candidateStart = findTrailingDsmlCandidateStart(pending);
84014
+ if (candidateStart === null) {
84015
+ output += pending;
84016
+ pending = "";
84017
+ break;
84018
+ }
84019
+ output += pending.slice(0, candidateStart).trimEnd();
84020
+ pending = pending.slice(candidateStart);
84021
+ break;
84022
+ }
84023
+ return output;
84024
+ };
84025
+ return {
84026
+ push(text) {
84027
+ if (!text)
84028
+ return "";
84029
+ pending += text;
84030
+ return drain(false);
84031
+ },
84032
+ flush() {
84033
+ return drain(true);
84034
+ }
84035
+ };
84036
+ }
84037
+ var DSML_FUNCTION_CALL_SENTINEL = "<|DSML|function_calls";
84038
+
83974
84039
  // src/providers/shared/geminiCredentials.ts
83975
84040
  var exports_geminiCredentials = {};
83976
84041
  __export(exports_geminiCredentials, {
@@ -84957,9 +85022,21 @@ async function* codexStreamToAnthropic(response, model) {
84957
85022
  let nextContentBlockIndex = 0;
84958
85023
  let sawToolUse = false;
84959
85024
  let finalResponse;
85025
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
84960
85026
  const closeActiveTextBlock = async function* () {
84961
85027
  if (activeTextBlockIndex === null)
84962
85028
  return;
85029
+ const flushedText = dsmlTextFilter.flush();
85030
+ if (flushedText) {
85031
+ yield {
85032
+ type: "content_block_delta",
85033
+ index: activeTextBlockIndex,
85034
+ delta: {
85035
+ type: "text_delta",
85036
+ text: flushedText
85037
+ }
85038
+ };
85039
+ }
84963
85040
  yield {
84964
85041
  type: "content_block_stop",
84965
85042
  index: activeTextBlockIndex
@@ -85071,14 +85148,17 @@ async function* codexStreamToAnthropic(response, model) {
85071
85148
  if (event.event === "response.output_text.delta") {
85072
85149
  yield* startTextBlockIfNeeded();
85073
85150
  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
- };
85151
+ const filteredText = dsmlTextFilter.push(payload.delta ?? "");
85152
+ if (filteredText) {
85153
+ yield {
85154
+ type: "content_block_delta",
85155
+ index: activeTextBlockIndex,
85156
+ delta: {
85157
+ type: "text_delta",
85158
+ text: filteredText
85159
+ }
85160
+ };
85161
+ }
85082
85162
  }
85083
85163
  continue;
85084
85164
  }
@@ -85609,32 +85689,6 @@ function buildOpenAIRequestBody(params, ctx) {
85609
85689
  }
85610
85690
  return body;
85611
85691
  }
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
85692
  async function* openaiStreamToAnthropic(response, model) {
85639
85693
  const messageId = makeMessageId2();
85640
85694
  let contentBlockIndex = 0;
@@ -85646,27 +85700,13 @@ async function* openaiStreamToAnthropic(response, model) {
85646
85700
  let hasEmittedFinalUsage = false;
85647
85701
  let hasProcessedFinishReason = false;
85648
85702
  let pendingTextBuffer = "";
85703
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
85649
85704
  const emitBufferedText = (mode) => {
85650
85705
  const events = [];
85651
- if (!pendingTextBuffer)
85706
+ if (!pendingTextBuffer && mode !== "final")
85652
85707
  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)
85667
- return events;
85668
- const visible = pendingTextBuffer.slice(0, emitUntil);
85669
- pendingTextBuffer = pendingTextBuffer.slice(emitUntil);
85708
+ const visible = mode === "final" ? dsmlTextFilter.push(pendingTextBuffer) + dsmlTextFilter.flush() : dsmlTextFilter.push(pendingTextBuffer);
85709
+ pendingTextBuffer = "";
85670
85710
  if (visible) {
85671
85711
  events.push(...emitTextDeltaEvents(visible));
85672
85712
  }
@@ -86243,7 +86283,7 @@ function createOpenAIShimClient(options) {
86243
86283
  messages: beta.messages
86244
86284
  };
86245
86285
  }
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;
86286
+ 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
86287
  var init_shim2 = __esm(() => {
86248
86288
  init_sdk();
86249
86289
  init_envUtils();
@@ -94500,7 +94540,7 @@ function printStartupScreen() {
94500
94540
  const sLen = ` ● ${sL} Ready — type /help to begin`.length;
94501
94541
  out.push(boxRow(sRow, W2, sLen));
94502
94542
  out.push(`${rgb(...BORDER)}╚${"═".repeat(W2 - 2)}╝${RESET}`);
94503
- out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.10"}${RESET}`);
94543
+ out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.11"}${RESET}`);
94504
94544
  out.push("");
94505
94545
  process.stdout.write(out.join(`
94506
94546
  `) + `
@@ -244370,7 +244410,7 @@ function getAnthropicEnvMetadata() {
244370
244410
  function getBuildAgeMinutes() {
244371
244411
  if (false)
244372
244412
  ;
244373
- const buildTime = new Date("2026-06-23T14:32:49.206Z").getTime();
244413
+ const buildTime = new Date("2026-06-24T03:20:56.844Z").getTime();
244374
244414
  if (isNaN(buildTime))
244375
244415
  return;
244376
244416
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -307798,6 +307838,7 @@ ${deferredToolList}
307798
307838
  const STALL_THRESHOLD_MS2 = 30000;
307799
307839
  let totalStallTime = 0;
307800
307840
  let stallCount = 0;
307841
+ const dsmlTextFilters = new Map;
307801
307842
  for await (const part of stream4) {
307802
307843
  resetStreamIdleTimer();
307803
307844
  const now = Date.now();
@@ -307864,6 +307905,7 @@ ${deferredToolList}
307864
307905
  ...part.content_block,
307865
307906
  text: ""
307866
307907
  };
307908
+ dsmlTextFilters.set(part.index, createDsmlFunctionCallTextFilter());
307867
307909
  break;
307868
307910
  case "thinking":
307869
307911
  contentBlocks[part.index] = {
@@ -307923,7 +307965,13 @@ ${deferredToolList}
307923
307965
  });
307924
307966
  throw new Error("Content block is not a text block");
307925
307967
  }
307926
- contentBlock.text += delta.text;
307968
+ {
307969
+ const filter2 = dsmlTextFilters.get(part.index) ?? createDsmlFunctionCallTextFilter();
307970
+ dsmlTextFilters.set(part.index, filter2);
307971
+ const visibleText = filter2.push(delta.text);
307972
+ delta.text = visibleText;
307973
+ contentBlock.text += visibleText;
307974
+ }
307927
307975
  break;
307928
307976
  case "signature_delta":
307929
307977
  if (false) {}
@@ -307972,6 +308020,11 @@ ${deferredToolList}
307972
308020
  });
307973
308021
  throw new Error("Message not found");
307974
308022
  }
308023
+ const filter2 = dsmlTextFilters.get(part.index);
308024
+ if (filter2 && contentBlock.type === "text") {
308025
+ contentBlock.text += filter2.flush();
308026
+ dsmlTextFilters.delete(part.index);
308027
+ }
307975
308028
  const m = {
307976
308029
  message: {
307977
308030
  ...partialMessage,
@@ -479733,7 +479786,7 @@ function buildPrimarySection() {
479733
479786
  }, undefined, false, undefined, this);
479734
479787
  return [{
479735
479788
  label: "Version",
479736
- value: "0.4.10"
479789
+ value: "0.4.11"
479737
479790
  }, {
479738
479791
  label: "Session name",
479739
479792
  value: nameValue
@@ -536055,7 +536108,7 @@ var init_bridge_kick = __esm(() => {
536055
536108
  var call58 = async () => {
536056
536109
  return {
536057
536110
  type: "text",
536058
- value: `${"99.0.0"} (built ${"2026-06-23T14:32:49.206Z"})`
536111
+ value: `${"99.0.0"} (built ${"2026-06-24T03:20:56.844Z"})`
536059
536112
  };
536060
536113
  }, version2, version_default;
536061
536114
  var init_version = __esm(() => {
@@ -558165,7 +558218,7 @@ function WelcomeV2() {
558165
558218
  dimColor: true,
558166
558219
  children: [
558167
558220
  "v",
558168
- "0.4.10",
558221
+ "0.4.11",
558169
558222
  " "
558170
558223
  ]
558171
558224
  }, undefined, true, undefined, this)
@@ -558365,7 +558418,7 @@ function WelcomeV2() {
558365
558418
  dimColor: true,
558366
558419
  children: [
558367
558420
  "v",
558368
- "0.4.10",
558421
+ "0.4.11",
558369
558422
  " "
558370
558423
  ]
558371
558424
  }, undefined, true, undefined, this)
@@ -558591,7 +558644,7 @@ function AppleTerminalWelcomeV2(t0) {
558591
558644
  dimColor: true,
558592
558645
  children: [
558593
558646
  "v",
558594
- "0.4.10",
558647
+ "0.4.11",
558595
558648
  " "
558596
558649
  ]
558597
558650
  }, undefined, true, undefined, this);
@@ -558845,7 +558898,7 @@ function AppleTerminalWelcomeV2(t0) {
558845
558898
  dimColor: true,
558846
558899
  children: [
558847
558900
  "v",
558848
- "0.4.10",
558901
+ "0.4.11",
558849
558902
  " "
558850
558903
  ]
558851
558904
  }, undefined, true, undefined, this);
@@ -579702,7 +579755,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
579702
579755
  pendingHookMessages
579703
579756
  }, renderAndRun);
579704
579757
  }
579705
- }).version("0.4.10 (OpenCow)", "-v, --version", "Output the version number");
579758
+ }).version("0.4.11 (OpenCow)", "-v, --version", "Output the version number");
579706
579759
  program2.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
579707
579760
  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
579761
  if (canUserConfigureAdvisor()) {
@@ -580348,7 +580401,7 @@ if (false) {}
580348
580401
  async function main2() {
580349
580402
  const args = process.argv.slice(2);
580350
580403
  if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
580351
- console.log(`${"0.4.10"} (OpenCow)`);
580404
+ console.log(`${"0.4.11"} (OpenCow)`);
580352
580405
  return;
580353
580406
  }
580354
580407
  if (args.includes("--provider")) {
@@ -580466,4 +580519,4 @@ async function main2() {
580466
580519
  }
580467
580520
  main2();
580468
580521
 
580469
- //# debugId=10DA61343644BBA264756E2164756E21
580522
+ //# debugId=A3FE6F2E9266C7E764756E2164756E21
package/dist/client.js CHANGED
@@ -94790,6 +94790,71 @@ var init_geminiAuth = __esm(() => {
94790
94790
  }, {}), GEMINI_ADC_CACHE_TTL_MS);
94791
94791
  });
94792
94792
 
94793
+ // src/providers/shared/dsmlSentinel.ts
94794
+ function normalizeDsmlSentinel(value) {
94795
+ return value.replace(/|/g, "|").replace(/\s+/g, "");
94796
+ }
94797
+ function isDsmlFunctionCallSentinelPrefix(value) {
94798
+ const normalized = normalizeDsmlSentinel(value);
94799
+ return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
94800
+ }
94801
+ function findDsmlFunctionCallSentinel(text) {
94802
+ const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
94803
+ const match = re.exec(text);
94804
+ if (!match || match.index === undefined)
94805
+ return null;
94806
+ return { start: match.index, end: match.index + match[0].length };
94807
+ }
94808
+ function findTrailingDsmlCandidateStart(text) {
94809
+ for (let i2 = 0;i2 < text.length; i2++) {
94810
+ if (isDsmlFunctionCallSentinelPrefix(text.slice(i2))) {
94811
+ return i2;
94812
+ }
94813
+ }
94814
+ return null;
94815
+ }
94816
+ function createDsmlFunctionCallTextFilter() {
94817
+ let pending = "";
94818
+ const drain = (final) => {
94819
+ let output = "";
94820
+ while (pending) {
94821
+ const sentinel = findDsmlFunctionCallSentinel(pending);
94822
+ if (sentinel) {
94823
+ output += pending.slice(0, sentinel.start).trimEnd();
94824
+ pending = pending.slice(sentinel.end);
94825
+ continue;
94826
+ }
94827
+ if (final) {
94828
+ output += pending;
94829
+ pending = "";
94830
+ break;
94831
+ }
94832
+ const candidateStart = findTrailingDsmlCandidateStart(pending);
94833
+ if (candidateStart === null) {
94834
+ output += pending;
94835
+ pending = "";
94836
+ break;
94837
+ }
94838
+ output += pending.slice(0, candidateStart).trimEnd();
94839
+ pending = pending.slice(candidateStart);
94840
+ break;
94841
+ }
94842
+ return output;
94843
+ };
94844
+ return {
94845
+ push(text) {
94846
+ if (!text)
94847
+ return "";
94848
+ pending += text;
94849
+ return drain(false);
94850
+ },
94851
+ flush() {
94852
+ return drain(true);
94853
+ }
94854
+ };
94855
+ }
94856
+ var DSML_FUNCTION_CALL_SENTINEL = "<|DSML|function_calls";
94857
+
94793
94858
  // src/providers/shared/geminiCredentials.ts
94794
94859
  function readGeminiAccessToken() {
94795
94860
  if (isBareMode())
@@ -95706,9 +95771,21 @@ async function* codexStreamToAnthropic(response, model) {
95706
95771
  let nextContentBlockIndex = 0;
95707
95772
  let sawToolUse = false;
95708
95773
  let finalResponse;
95774
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
95709
95775
  const closeActiveTextBlock = async function* () {
95710
95776
  if (activeTextBlockIndex === null)
95711
95777
  return;
95778
+ const flushedText = dsmlTextFilter.flush();
95779
+ if (flushedText) {
95780
+ yield {
95781
+ type: "content_block_delta",
95782
+ index: activeTextBlockIndex,
95783
+ delta: {
95784
+ type: "text_delta",
95785
+ text: flushedText
95786
+ }
95787
+ };
95788
+ }
95712
95789
  yield {
95713
95790
  type: "content_block_stop",
95714
95791
  index: activeTextBlockIndex
@@ -95820,14 +95897,17 @@ async function* codexStreamToAnthropic(response, model) {
95820
95897
  if (event.event === "response.output_text.delta") {
95821
95898
  yield* startTextBlockIfNeeded();
95822
95899
  if (activeTextBlockIndex !== null) {
95823
- yield {
95824
- type: "content_block_delta",
95825
- index: activeTextBlockIndex,
95826
- delta: {
95827
- type: "text_delta",
95828
- text: payload.delta ?? ""
95829
- }
95830
- };
95900
+ const filteredText = dsmlTextFilter.push(payload.delta ?? "");
95901
+ if (filteredText) {
95902
+ yield {
95903
+ type: "content_block_delta",
95904
+ index: activeTextBlockIndex,
95905
+ delta: {
95906
+ type: "text_delta",
95907
+ text: filteredText
95908
+ }
95909
+ };
95910
+ }
95831
95911
  }
95832
95912
  continue;
95833
95913
  }
@@ -96433,32 +96513,6 @@ function buildOpenAIRequestBody(params, ctx) {
96433
96513
  }
96434
96514
  return body;
96435
96515
  }
96436
- function normalizeDsmlSentinelPrefix(value) {
96437
- return value.replace(/|/g, "|").replace(/\s+/g, "");
96438
- }
96439
- function isDsmlFunctionCallSentinelPrefix(value) {
96440
- const normalized = normalizeDsmlSentinelPrefix(value);
96441
- return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
96442
- }
96443
- function findTrailingDsmlSentinelCandidateStart(text) {
96444
- const lt = text.lastIndexOf("<");
96445
- if (lt === -1)
96446
- return null;
96447
- return isDsmlFunctionCallSentinelPrefix(text.slice(lt)) ? lt : null;
96448
- }
96449
- function findBufferedTextFlushBoundary(text) {
96450
- const sentinelStart = findTrailingDsmlSentinelCandidateStart(text);
96451
- if (sentinelStart === null)
96452
- return text.length;
96453
- return text.slice(0, sentinelStart).trimEnd().length;
96454
- }
96455
- function findDsmlFunctionCallSentinel(text) {
96456
- const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
96457
- const match = re.exec(text);
96458
- if (!match || match.index === undefined)
96459
- return null;
96460
- return { start: match.index, end: match.index + match[0].length };
96461
- }
96462
96516
  async function* openaiStreamToAnthropic(response, model) {
96463
96517
  const messageId = makeMessageId2();
96464
96518
  let contentBlockIndex = 0;
@@ -96470,27 +96524,13 @@ async function* openaiStreamToAnthropic(response, model) {
96470
96524
  let hasEmittedFinalUsage = false;
96471
96525
  let hasProcessedFinishReason = false;
96472
96526
  let pendingTextBuffer = "";
96527
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
96473
96528
  const emitBufferedText = (mode) => {
96474
96529
  const events = [];
96475
- if (!pendingTextBuffer)
96530
+ if (!pendingTextBuffer && mode !== "final")
96476
96531
  return events;
96477
- const sentinel = findDsmlFunctionCallSentinel(pendingTextBuffer);
96478
- if (sentinel) {
96479
- const visible2 = pendingTextBuffer.slice(0, sentinel.start).trimEnd();
96480
- pendingTextBuffer = pendingTextBuffer.slice(sentinel.end);
96481
- if (visible2) {
96482
- events.push(...emitTextDeltaEvents(visible2));
96483
- }
96484
- if (pendingTextBuffer) {
96485
- events.push(...emitBufferedText(mode));
96486
- }
96487
- return events;
96488
- }
96489
- const emitUntil = mode === "final" ? pendingTextBuffer.length : mode === "before_tool_call" ? findTrailingDsmlSentinelCandidateStart(pendingTextBuffer) ?? pendingTextBuffer.length : findBufferedTextFlushBoundary(pendingTextBuffer);
96490
- if (emitUntil <= 0)
96491
- return events;
96492
- const visible = pendingTextBuffer.slice(0, emitUntil);
96493
- pendingTextBuffer = pendingTextBuffer.slice(emitUntil);
96532
+ const visible = mode === "final" ? dsmlTextFilter.push(pendingTextBuffer) + dsmlTextFilter.flush() : dsmlTextFilter.push(pendingTextBuffer);
96533
+ pendingTextBuffer = "";
96494
96534
  if (visible) {
96495
96535
  events.push(...emitTextDeltaEvents(visible));
96496
96536
  }
@@ -97067,7 +97107,7 @@ function createOpenAIShimClient(options) {
97067
97107
  messages: beta.messages
97068
97108
  };
97069
97109
  }
97070
- 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;
97110
+ 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;
97071
97111
  var init_shim2 = __esm(() => {
97072
97112
  init_sdk();
97073
97113
  init_envUtils();
@@ -282652,7 +282692,7 @@ function getAnthropicEnvMetadata() {
282652
282692
  function getBuildAgeMinutes() {
282653
282693
  if (false)
282654
282694
  ;
282655
- const buildTime = new Date("2026-06-23T14:32:49.206Z").getTime();
282695
+ const buildTime = new Date("2026-06-24T03:20:56.844Z").getTime();
282656
282696
  if (isNaN(buildTime))
282657
282697
  return;
282658
282698
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -293936,6 +293976,7 @@ ${deferredToolList}
293936
293976
  const STALL_THRESHOLD_MS2 = 30000;
293937
293977
  let totalStallTime = 0;
293938
293978
  let stallCount = 0;
293979
+ const dsmlTextFilters = new Map;
293939
293980
  for await (const part of stream4) {
293940
293981
  resetStreamIdleTimer();
293941
293982
  const now = Date.now();
@@ -294002,6 +294043,7 @@ ${deferredToolList}
294002
294043
  ...part.content_block,
294003
294044
  text: ""
294004
294045
  };
294046
+ dsmlTextFilters.set(part.index, createDsmlFunctionCallTextFilter());
294005
294047
  break;
294006
294048
  case "thinking":
294007
294049
  contentBlocks[part.index] = {
@@ -294061,7 +294103,13 @@ ${deferredToolList}
294061
294103
  });
294062
294104
  throw new Error("Content block is not a text block");
294063
294105
  }
294064
- contentBlock.text += delta.text;
294106
+ {
294107
+ const filter2 = dsmlTextFilters.get(part.index) ?? createDsmlFunctionCallTextFilter();
294108
+ dsmlTextFilters.set(part.index, filter2);
294109
+ const visibleText = filter2.push(delta.text);
294110
+ delta.text = visibleText;
294111
+ contentBlock.text += visibleText;
294112
+ }
294065
294113
  break;
294066
294114
  case "signature_delta":
294067
294115
  if (false) {}
@@ -294110,6 +294158,11 @@ ${deferredToolList}
294110
294158
  });
294111
294159
  throw new Error("Message not found");
294112
294160
  }
294161
+ const filter2 = dsmlTextFilters.get(part.index);
294162
+ if (filter2 && contentBlock.type === "text") {
294163
+ contentBlock.text += filter2.flush();
294164
+ dsmlTextFilters.delete(part.index);
294165
+ }
294113
294166
  const m = {
294114
294167
  message: {
294115
294168
  ...partialMessage,
@@ -336002,4 +336055,4 @@ export {
336002
336055
  AbortError2 as AbortError
336003
336056
  };
336004
336057
 
336005
- //# debugId=F1D1A50370F2E48F64756E2164756E21
336058
+ //# debugId=7376AE95E91B9BFD64756E2164756E21
@@ -0,0 +1,5 @@
1
+ export interface DsmlFunctionCallTextFilter {
2
+ push(text: string): string;
3
+ flush(): string;
4
+ }
5
+ export declare function createDsmlFunctionCallTextFilter(): DsmlFunctionCallTextFilter;
package/dist/sdk.js CHANGED
@@ -94790,6 +94790,71 @@ var init_geminiAuth = __esm(() => {
94790
94790
  }, {}), GEMINI_ADC_CACHE_TTL_MS);
94791
94791
  });
94792
94792
 
94793
+ // src/providers/shared/dsmlSentinel.ts
94794
+ function normalizeDsmlSentinel(value) {
94795
+ return value.replace(/|/g, "|").replace(/\s+/g, "");
94796
+ }
94797
+ function isDsmlFunctionCallSentinelPrefix(value) {
94798
+ const normalized = normalizeDsmlSentinel(value);
94799
+ return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
94800
+ }
94801
+ function findDsmlFunctionCallSentinel(text) {
94802
+ const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
94803
+ const match = re.exec(text);
94804
+ if (!match || match.index === undefined)
94805
+ return null;
94806
+ return { start: match.index, end: match.index + match[0].length };
94807
+ }
94808
+ function findTrailingDsmlCandidateStart(text) {
94809
+ for (let i2 = 0;i2 < text.length; i2++) {
94810
+ if (isDsmlFunctionCallSentinelPrefix(text.slice(i2))) {
94811
+ return i2;
94812
+ }
94813
+ }
94814
+ return null;
94815
+ }
94816
+ function createDsmlFunctionCallTextFilter() {
94817
+ let pending = "";
94818
+ const drain = (final) => {
94819
+ let output = "";
94820
+ while (pending) {
94821
+ const sentinel = findDsmlFunctionCallSentinel(pending);
94822
+ if (sentinel) {
94823
+ output += pending.slice(0, sentinel.start).trimEnd();
94824
+ pending = pending.slice(sentinel.end);
94825
+ continue;
94826
+ }
94827
+ if (final) {
94828
+ output += pending;
94829
+ pending = "";
94830
+ break;
94831
+ }
94832
+ const candidateStart = findTrailingDsmlCandidateStart(pending);
94833
+ if (candidateStart === null) {
94834
+ output += pending;
94835
+ pending = "";
94836
+ break;
94837
+ }
94838
+ output += pending.slice(0, candidateStart).trimEnd();
94839
+ pending = pending.slice(candidateStart);
94840
+ break;
94841
+ }
94842
+ return output;
94843
+ };
94844
+ return {
94845
+ push(text) {
94846
+ if (!text)
94847
+ return "";
94848
+ pending += text;
94849
+ return drain(false);
94850
+ },
94851
+ flush() {
94852
+ return drain(true);
94853
+ }
94854
+ };
94855
+ }
94856
+ var DSML_FUNCTION_CALL_SENTINEL = "<|DSML|function_calls";
94857
+
94793
94858
  // src/providers/shared/geminiCredentials.ts
94794
94859
  function readGeminiAccessToken() {
94795
94860
  if (isBareMode())
@@ -95706,9 +95771,21 @@ async function* codexStreamToAnthropic(response, model) {
95706
95771
  let nextContentBlockIndex = 0;
95707
95772
  let sawToolUse = false;
95708
95773
  let finalResponse;
95774
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
95709
95775
  const closeActiveTextBlock = async function* () {
95710
95776
  if (activeTextBlockIndex === null)
95711
95777
  return;
95778
+ const flushedText = dsmlTextFilter.flush();
95779
+ if (flushedText) {
95780
+ yield {
95781
+ type: "content_block_delta",
95782
+ index: activeTextBlockIndex,
95783
+ delta: {
95784
+ type: "text_delta",
95785
+ text: flushedText
95786
+ }
95787
+ };
95788
+ }
95712
95789
  yield {
95713
95790
  type: "content_block_stop",
95714
95791
  index: activeTextBlockIndex
@@ -95820,14 +95897,17 @@ async function* codexStreamToAnthropic(response, model) {
95820
95897
  if (event.event === "response.output_text.delta") {
95821
95898
  yield* startTextBlockIfNeeded();
95822
95899
  if (activeTextBlockIndex !== null) {
95823
- yield {
95824
- type: "content_block_delta",
95825
- index: activeTextBlockIndex,
95826
- delta: {
95827
- type: "text_delta",
95828
- text: payload.delta ?? ""
95829
- }
95830
- };
95900
+ const filteredText = dsmlTextFilter.push(payload.delta ?? "");
95901
+ if (filteredText) {
95902
+ yield {
95903
+ type: "content_block_delta",
95904
+ index: activeTextBlockIndex,
95905
+ delta: {
95906
+ type: "text_delta",
95907
+ text: filteredText
95908
+ }
95909
+ };
95910
+ }
95831
95911
  }
95832
95912
  continue;
95833
95913
  }
@@ -96433,32 +96513,6 @@ function buildOpenAIRequestBody(params, ctx) {
96433
96513
  }
96434
96514
  return body;
96435
96515
  }
96436
- function normalizeDsmlSentinelPrefix(value) {
96437
- return value.replace(/|/g, "|").replace(/\s+/g, "");
96438
- }
96439
- function isDsmlFunctionCallSentinelPrefix(value) {
96440
- const normalized = normalizeDsmlSentinelPrefix(value);
96441
- return normalized.length > 0 && DSML_FUNCTION_CALL_SENTINEL.startsWith(normalized);
96442
- }
96443
- function findTrailingDsmlSentinelCandidateStart(text) {
96444
- const lt = text.lastIndexOf("<");
96445
- if (lt === -1)
96446
- return null;
96447
- return isDsmlFunctionCallSentinelPrefix(text.slice(lt)) ? lt : null;
96448
- }
96449
- function findBufferedTextFlushBoundary(text) {
96450
- const sentinelStart = findTrailingDsmlSentinelCandidateStart(text);
96451
- if (sentinelStart === null)
96452
- return text.length;
96453
- return text.slice(0, sentinelStart).trimEnd().length;
96454
- }
96455
- function findDsmlFunctionCallSentinel(text) {
96456
- const re = /<\s*[||]\s*DSML\s*[||]\s*function_calls\b/;
96457
- const match = re.exec(text);
96458
- if (!match || match.index === undefined)
96459
- return null;
96460
- return { start: match.index, end: match.index + match[0].length };
96461
- }
96462
96516
  async function* openaiStreamToAnthropic(response, model) {
96463
96517
  const messageId = makeMessageId2();
96464
96518
  let contentBlockIndex = 0;
@@ -96470,27 +96524,13 @@ async function* openaiStreamToAnthropic(response, model) {
96470
96524
  let hasEmittedFinalUsage = false;
96471
96525
  let hasProcessedFinishReason = false;
96472
96526
  let pendingTextBuffer = "";
96527
+ const dsmlTextFilter = createDsmlFunctionCallTextFilter();
96473
96528
  const emitBufferedText = (mode) => {
96474
96529
  const events = [];
96475
- if (!pendingTextBuffer)
96530
+ if (!pendingTextBuffer && mode !== "final")
96476
96531
  return events;
96477
- const sentinel = findDsmlFunctionCallSentinel(pendingTextBuffer);
96478
- if (sentinel) {
96479
- const visible2 = pendingTextBuffer.slice(0, sentinel.start).trimEnd();
96480
- pendingTextBuffer = pendingTextBuffer.slice(sentinel.end);
96481
- if (visible2) {
96482
- events.push(...emitTextDeltaEvents(visible2));
96483
- }
96484
- if (pendingTextBuffer) {
96485
- events.push(...emitBufferedText(mode));
96486
- }
96487
- return events;
96488
- }
96489
- const emitUntil = mode === "final" ? pendingTextBuffer.length : mode === "before_tool_call" ? findTrailingDsmlSentinelCandidateStart(pendingTextBuffer) ?? pendingTextBuffer.length : findBufferedTextFlushBoundary(pendingTextBuffer);
96490
- if (emitUntil <= 0)
96491
- return events;
96492
- const visible = pendingTextBuffer.slice(0, emitUntil);
96493
- pendingTextBuffer = pendingTextBuffer.slice(emitUntil);
96532
+ const visible = mode === "final" ? dsmlTextFilter.push(pendingTextBuffer) + dsmlTextFilter.flush() : dsmlTextFilter.push(pendingTextBuffer);
96533
+ pendingTextBuffer = "";
96494
96534
  if (visible) {
96495
96535
  events.push(...emitTextDeltaEvents(visible));
96496
96536
  }
@@ -97067,7 +97107,7 @@ function createOpenAIShimClient(options) {
97067
97107
  messages: beta.messages
97068
97108
  };
97069
97109
  }
97070
- 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;
97110
+ 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;
97071
97111
  var init_shim2 = __esm(() => {
97072
97112
  init_sdk();
97073
97113
  init_envUtils();
@@ -282652,7 +282692,7 @@ function getAnthropicEnvMetadata() {
282652
282692
  function getBuildAgeMinutes() {
282653
282693
  if (false)
282654
282694
  ;
282655
- const buildTime = new Date("2026-06-23T14:32:49.206Z").getTime();
282695
+ const buildTime = new Date("2026-06-24T03:20:56.844Z").getTime();
282656
282696
  if (isNaN(buildTime))
282657
282697
  return;
282658
282698
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -293936,6 +293976,7 @@ ${deferredToolList}
293936
293976
  const STALL_THRESHOLD_MS2 = 30000;
293937
293977
  let totalStallTime = 0;
293938
293978
  let stallCount = 0;
293979
+ const dsmlTextFilters = new Map;
293939
293980
  for await (const part of stream4) {
293940
293981
  resetStreamIdleTimer();
293941
293982
  const now = Date.now();
@@ -294002,6 +294043,7 @@ ${deferredToolList}
294002
294043
  ...part.content_block,
294003
294044
  text: ""
294004
294045
  };
294046
+ dsmlTextFilters.set(part.index, createDsmlFunctionCallTextFilter());
294005
294047
  break;
294006
294048
  case "thinking":
294007
294049
  contentBlocks[part.index] = {
@@ -294061,7 +294103,13 @@ ${deferredToolList}
294061
294103
  });
294062
294104
  throw new Error("Content block is not a text block");
294063
294105
  }
294064
- contentBlock.text += delta.text;
294106
+ {
294107
+ const filter2 = dsmlTextFilters.get(part.index) ?? createDsmlFunctionCallTextFilter();
294108
+ dsmlTextFilters.set(part.index, filter2);
294109
+ const visibleText = filter2.push(delta.text);
294110
+ delta.text = visibleText;
294111
+ contentBlock.text += visibleText;
294112
+ }
294065
294113
  break;
294066
294114
  case "signature_delta":
294067
294115
  if (false) {}
@@ -294110,6 +294158,11 @@ ${deferredToolList}
294110
294158
  });
294111
294159
  throw new Error("Message not found");
294112
294160
  }
294161
+ const filter2 = dsmlTextFilters.get(part.index);
294162
+ if (filter2 && contentBlock.type === "text") {
294163
+ contentBlock.text += filter2.flush();
294164
+ dsmlTextFilters.delete(part.index);
294165
+ }
294113
294166
  const m = {
294114
294167
  message: {
294115
294168
  ...partialMessage,
@@ -336002,4 +336055,4 @@ export {
336002
336055
  AbortError2 as AbortError
336003
336056
  };
336004
336057
 
336005
- //# debugId=432C8411F9337F1F64756E2164756E21
336058
+ //# debugId=7DBFD07CC9AC2F7C64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencow-ai/opencow-agent-sdk",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "Claude Code opened to any LLM — OpenAI, Gemini, DeepSeek, Ollama, and 200+ models",
5
5
  "type": "module",
6
6
  "main": "./dist/sdk.js",