@yukino.js/yukino 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +35 -30
  2. package/dist/{acp-LOU6R4C7.js → acp-76S2XII3.js} +1 -1
  3. package/dist/anthropic-WK6EYMUE.js +4 -0
  4. package/dist/chunk-3OULXPVI.js +5 -0
  5. package/dist/chunk-7PPWFSIC.js +4 -0
  6. package/dist/chunk-7ZBAF7M4.js +4 -0
  7. package/dist/{chunk-BPA7URET.js → chunk-HWDSXNX4.js} +2 -2
  8. package/dist/{chunk-GYBJR2RB.js → chunk-IW5L5276.js} +2 -2
  9. package/dist/chunk-NG62ISUV.js +61 -0
  10. package/dist/chunk-P6DHMU7R.js +4 -0
  11. package/dist/{chunk-YVLW4WBA.js → chunk-QQZCYWYI.js} +20 -20
  12. package/dist/chunk-QRO6H32L.js +1031 -0
  13. package/dist/lib/{anthropic-UC7XIWCM.js → anthropic-CDPTNR5L.js} +2 -6
  14. package/dist/lib/{chunk-DXUJGZ5F.js → chunk-6NYUYSER.js} +3 -3
  15. package/dist/lib/{chunk-GAWWN3TY.js → chunk-EO23VPDZ.js} +416 -39
  16. package/dist/lib/chunk-HE4RUUZP.js +1342 -0
  17. package/dist/lib/{chunk-64Z3SMSG.js → chunk-PEV5NGQ2.js} +84 -44
  18. package/dist/lib/{chunk-WDO5MWH2.js → chunk-TKCJSTWI.js} +1 -1
  19. package/dist/lib/index.d.ts +113 -119
  20. package/dist/lib/index.js +6305 -1810
  21. package/dist/lib/{openai-OL5HXQUU.js → openai-TEFKPV7T.js} +2 -4
  22. package/dist/lib/{providers-N35WJDJM.js → providers-2X5JB2JX.js} +1 -1
  23. package/dist/lib/{seatbelt-G5Z5QEDD.js → seatbelt-VE3I3EGH.js} +1 -1
  24. package/dist/main.js +198 -198
  25. package/dist/{openai-NIBMRDVB.js → openai-RYXW7AKZ.js} +15 -15
  26. package/dist/{providers-TG3LGHNS.js → providers-YG2HYIG6.js} +1 -1
  27. package/dist/{seatbelt-IOLIYZZX.js → seatbelt-3YN3GMQO.js} +1 -1
  28. package/dist/server-66HLMSUR.js +4 -0
  29. package/package.json +8 -24
  30. package/dist/agent-5NW5ZV5P.js +0 -4
  31. package/dist/anthropic-UXFSBFXM.js +0 -4
  32. package/dist/chunk-2HUCPWD6.js +0 -29
  33. package/dist/chunk-3EQYWNP6.js +0 -4
  34. package/dist/chunk-3SPUH3TD.js +0 -164
  35. package/dist/chunk-5HF4GLFR.js +0 -865
  36. package/dist/chunk-HBXZ6MB4.js +0 -4
  37. package/dist/chunk-MQAQBW7F.js +0 -35
  38. package/dist/chunk-OFC2GD5K.js +0 -4
  39. package/dist/chunk-SDXAS44V.js +0 -4
  40. package/dist/chunk-TJVN4NL5.js +0 -5
  41. package/dist/chunk-VM26JJ6N.js +0 -4
  42. package/dist/chunk-WNHTKUKK.js +0 -4
  43. package/dist/chunk-ZPYQCXWT.js +0 -5
  44. package/dist/lib/agent-UGEA6EVB.js +0 -16
  45. package/dist/lib/chunk-65EUCQOF.js +0 -259
  46. package/dist/lib/chunk-F2YJG72O.js +0 -150
  47. package/dist/lib/chunk-NIJXTKNM.js +0 -3628
  48. package/dist/lib/chunk-OCTB6YMC.js +0 -625
  49. package/dist/lib/chunk-R3NJ2EET.js +0 -540
  50. package/dist/lib/chunk-UKINFW65.js +0 -652
  51. package/dist/lib/chunk-V2EYBIAU.js +0 -323
  52. package/dist/lib/permissions-EAKP6IZ3.js +0 -23
  53. package/dist/permissions-5EQWZS7O.js +0 -4
  54. package/dist/server-7ENYPCYC.js +0 -4
@@ -1,28 +1,25 @@
1
- import {
2
- resolveAPIKey
3
- } from "./chunk-R3NJ2EET.js";
4
1
  import {
5
2
  AuthenticationError,
6
3
  ContextTooLongError,
7
4
  LLMError,
8
5
  NetworkError,
9
6
  RateLimitError,
7
+ asRecord,
8
+ asString,
10
9
  clampThinkingLevel,
11
10
  containsContextLengthError,
11
+ contentToText,
12
+ createChildLogger,
12
13
  ensureToolPairing,
13
14
  getMaxOutputTokens,
14
15
  getSupportedThinkingLevels,
15
16
  getThinkingLevel,
16
- toReasoningEffort
17
- } from "./chunk-V2EYBIAU.js";
18
- import {
19
- asRecord,
20
- asString,
21
- contentToText,
22
- createChildLogger,
23
17
  isRecord,
24
- strArg
25
- } from "./chunk-UKINFW65.js";
18
+ parseToolArguments,
19
+ resolveAPIKey,
20
+ strArg,
21
+ toReasoningEffort
22
+ } from "./chunk-HE4RUUZP.js";
26
23
  import {
27
24
  __export
28
25
  } from "./chunk-MLKGABMK.js";
@@ -179,6 +176,8 @@ var OpenAIClient = class {
179
176
  let jsonAccumulate = "";
180
177
  let reasoningId = "";
181
178
  let reasoningText = "";
179
+ let reasoningPartText = "";
180
+ const startedComputerCalls = /* @__PURE__ */ new Set();
182
181
  let sawTerminalResponse = false;
183
182
  for await (const event of stream) {
184
183
  if (event.type === "response.output_text.delta") {
@@ -188,14 +187,20 @@ var OpenAIClient = class {
188
187
  };
189
188
  } else if (event.type === "response.reasoning_summary_text.delta") {
190
189
  reasoningText += event.delta;
190
+ reasoningPartText += event.delta;
191
191
  yield { type: "thinking_delta", text: event.delta };
192
192
  } else if (event.type === "response.reasoning_summary_text.done") {
193
- yield {
194
- type: "thinking_complete",
195
- thinking: reasoningText,
196
- signature: reasoningId
197
- };
193
+ if (!reasoningPartText) {
194
+ reasoningText += event.text;
195
+ yield { type: "thinking_delta", text: event.text };
196
+ }
197
+ reasoningPartText = "";
198
198
  } else if (event.type === "response.function_call_arguments.delta") {
199
+ if (!currentToolId || !currentToolName) {
200
+ throw new NetworkError(
201
+ "Responses tool arguments arrived before a valid tool call"
202
+ );
203
+ }
199
204
  jsonAccumulate += event.delta;
200
205
  yield {
201
206
  type: "tool_call_delta",
@@ -203,6 +208,11 @@ var OpenAIClient = class {
203
208
  };
204
209
  } else if (event.type === "response.output_item.added") {
205
210
  if (event.item.type === "function_call") {
211
+ if (!event.item.call_id || !event.item.name) {
212
+ throw new NetworkError(
213
+ "Responses tool call started without a valid id or name"
214
+ );
215
+ }
206
216
  currentToolName = event.item.name;
207
217
  currentToolId = event.item.call_id;
208
218
  jsonAccumulate = "";
@@ -212,6 +222,12 @@ var OpenAIClient = class {
212
222
  toolId: currentToolId
213
223
  };
214
224
  } else if (event.item.type === "computer_call") {
225
+ if (!event.item.call_id || !event.item.id) {
226
+ throw new NetworkError(
227
+ "Responses computer call started without a valid id"
228
+ );
229
+ }
230
+ startedComputerCalls.add(event.item.call_id);
215
231
  yield {
216
232
  type: "tool_call_start",
217
233
  toolName: "ComputerUse",
@@ -220,29 +236,45 @@ var OpenAIClient = class {
220
236
  } else if (event.item.type === "reasoning") {
221
237
  reasoningId = event.item.id ?? "";
222
238
  reasoningText = "";
239
+ reasoningPartText = "";
223
240
  }
224
241
  } else if (event.type === "response.output_item.done") {
225
- if (event.item.type === "function_call" && currentToolName) {
226
- let args = {};
227
- if (jsonAccumulate) {
228
- try {
229
- const parsed = JSON.parse(jsonAccumulate);
230
- args = isRecord(parsed) ? asRecord(parsed) : {};
231
- } catch (err) {
232
- log.error({ err }, "llm operation failed");
233
- args = {};
234
- }
242
+ if (event.item.type === "reasoning") {
243
+ if (reasoningText) {
244
+ yield {
245
+ type: "thinking_complete",
246
+ thinking: reasoningText,
247
+ signature: reasoningId
248
+ };
249
+ }
250
+ reasoningId = "";
251
+ reasoningText = "";
252
+ reasoningPartText = "";
253
+ } else if (event.item.type === "function_call") {
254
+ if (!currentToolId || !currentToolName) {
255
+ throw new NetworkError(
256
+ "Responses tool call completed without a valid start event"
257
+ );
235
258
  }
259
+ const parsed = parseToolArguments(
260
+ jsonAccumulate.trim() ? jsonAccumulate : event.item.arguments
261
+ );
236
262
  yield {
237
263
  type: "tool_call_complete",
238
264
  toolId: currentToolId,
239
265
  toolName: currentToolName,
240
- arguments: args
266
+ arguments: parsed.arguments,
267
+ ...parsed.parseError ? { parseError: parsed.parseError } : {}
241
268
  };
242
269
  currentToolName = "";
243
270
  currentToolId = "";
244
271
  jsonAccumulate = "";
245
272
  } else if (event.item.type === "computer_call") {
273
+ if (!event.item.call_id || !event.item.id || !startedComputerCalls.delete(event.item.call_id)) {
274
+ throw new NetworkError(
275
+ "Responses computer call completed without a valid start event"
276
+ );
277
+ }
246
278
  yield {
247
279
  type: "tool_call_complete",
248
280
  toolId: event.item.call_id,
@@ -523,6 +555,9 @@ function buildOpenAIInput(messages) {
523
555
  for (const m of messages) {
524
556
  if (m.thinkingBlocks) {
525
557
  for (const tb of m.thinkingBlocks) {
558
+ if (!tb.signature.startsWith("rs_")) {
559
+ continue;
560
+ }
526
561
  result.push({
527
562
  type: "reasoning",
528
563
  id: tb.signature,
@@ -723,10 +758,12 @@ var OpenAICompatClient = class {
723
758
  }
724
759
  if (tc.function?.arguments) {
725
760
  entry.args += tc.function.arguments;
726
- yield {
727
- type: "tool_call_delta",
728
- text: tc.function.arguments
729
- };
761
+ if (entry.started) {
762
+ yield {
763
+ type: "tool_call_delta",
764
+ text: tc.function.arguments
765
+ };
766
+ }
730
767
  }
731
768
  }
732
769
  }
@@ -740,23 +777,26 @@ var OpenAICompatClient = class {
740
777
  };
741
778
  reasoningAccumulate = "";
742
779
  }
780
+ const incompleteCall = [...toolCalls.values()].find(
781
+ (toolCall) => !toolCall.started
782
+ );
783
+ if (incompleteCall) {
784
+ const missing = [
785
+ ...incompleteCall.id ? [] : ["id"],
786
+ ...incompleteCall.name ? [] : ["name"]
787
+ ].join(" and ");
788
+ throw new NetworkError(
789
+ `Chat Completions tool call ended without a valid ${missing}`
790
+ );
791
+ }
743
792
  for (const tu of toolCalls.values()) {
744
- let args = {};
745
- const jsonArgs = tu.args;
746
- if (jsonArgs) {
747
- try {
748
- const parsed = JSON.parse(jsonArgs);
749
- args = isRecord(parsed) ? asRecord(parsed) : {};
750
- } catch (err) {
751
- log.error({ err }, "llm operation failed");
752
- args = {};
753
- }
754
- }
793
+ const parsed = parseToolArguments(tu.args);
755
794
  yield {
756
795
  type: "tool_call_complete",
757
796
  toolName: tu.name,
758
797
  toolId: tu.id,
759
- arguments: args
798
+ arguments: parsed.arguments,
799
+ ...parsed.parseError ? { parseError: parsed.parseError } : {}
760
800
  };
761
801
  }
762
802
  }
@@ -52,7 +52,7 @@ var PackageJsonSchema = z.object({
52
52
  });
53
53
  function resolveVersion() {
54
54
  if (true) {
55
- return "0.0.5";
55
+ return "0.0.7";
56
56
  }
57
57
  const here = path.dirname(fileURLToPath(import.meta.url));
58
58
  for (const levels of ["..", "../.."]) {