@veryfront/ext-llm-openai 0.1.1223 → 0.1.1225

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.
@@ -1 +1 @@
1
- {"version":3,"file":"openai-tool-input.d.ts","sourceRoot":"","sources":["../src/openai-tool-input.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qCAAqC,UAAY,CAAC;AAC/D,eAAO,MAAM,yCAAyC,OAAQ,CAAC;AAE/D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,8BAA8B,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,GAAG,WAAW,GAAG,SAAS,CAgBnC;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE/E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOvD"}
1
+ {"version":3,"file":"openai-tool-input.d.ts","sourceRoot":"","sources":["../src/openai-tool-input.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qCAAqC,UAAY,CAAC;AAC/D,eAAO,MAAM,yCAAyC,OAAQ,CAAC;AAE/D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAIF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,8BAA8B,EACtC,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,MAAM,GACf,OAAO,GAAG,WAAW,GAAG,SAAS,CA+BnC;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE/E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOvD"}
@@ -2,18 +2,32 @@ export const MAX_OPENAI_STREAM_TOOL_ARGUMENT_BYTES = 1_048_576;
2
2
  export const MAX_OPENAI_STREAM_TOOL_ARGUMENT_FRAGMENTS = 4_096;
3
3
  const TOOL_ARGUMENT_ENCODER = new TextEncoder();
4
4
  export function appendOpenAIStreamToolArgument(budget, chunks, fragment) {
5
- if (budget.fragments >= MAX_OPENAI_STREAM_TOOL_ARGUMENT_FRAGMENTS) {
6
- return "fragments";
7
- }
8
5
  const fragmentBytes = TOOL_ARGUMENT_ENCODER.encode(fragment).byteLength;
6
+ // Zero-byte fragments never advance the byte budget, so they are the only
7
+ // ones that can arrive without bound -- and they are what the fragment cap
8
+ // exists to stop. Both provider streams exercise it exactly that way, by
9
+ // flooding empty deltas.
10
+ //
11
+ // Counting non-empty fragments here too made the cap bind long before the
12
+ // byte budget: at typical delta sizes, 4096 fragments is roughly 2-8% of the
13
+ // 1 MiB a tool call is nominally allowed, which left the byte limit
14
+ // unreachable. Fragment count is chosen by the provider's tokenizer rather
15
+ // than by the caller, so the same tool call passed or failed depending on how
16
+ // the stream happened to be chunked.
17
+ if (fragmentBytes === 0) {
18
+ if (budget.fragments >= MAX_OPENAI_STREAM_TOOL_ARGUMENT_FRAGMENTS) {
19
+ return "fragments";
20
+ }
21
+ budget.fragments++;
22
+ return undefined;
23
+ }
9
24
  if (fragmentBytes > MAX_OPENAI_STREAM_TOOL_ARGUMENT_BYTES - budget.bytes) {
10
25
  return "bytes";
11
26
  }
12
- budget.fragments++;
27
+ // Content is bounded by bytes: every fragment kept here is at least one byte,
28
+ // so the array cannot outgrow the byte budget.
13
29
  budget.bytes += fragmentBytes;
14
- if (fragment.length > 0) {
15
- chunks.push(fragment);
16
- }
30
+ chunks.push(fragment);
17
31
  return undefined;
18
32
  }
19
33
  export function joinOpenAIStreamToolArguments(chunks) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfront/ext-llm-openai",
3
- "version": "0.1.1223",
3
+ "version": "0.1.1225",
4
4
  "description": "Veryfront first-party extension package for ext-llm-openai",
5
5
  "keywords": [
6
6
  "veryfront",
@@ -45,7 +45,7 @@
45
45
  "capabilities": []
46
46
  },
47
47
  "peerDependencies": {
48
- "veryfront": "^0.1.1223"
48
+ "veryfront": "^0.1.1225"
49
49
  },
50
50
  "type": "module",
51
51
  "types": "./esm/index.d.ts",