@jeffreycao/copilot-api 2.2.7 → 2.2.9

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/main.js CHANGED
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
30
30
  const { auth } = await import("./auth-C-RWNXGU.js");
31
31
  const { debug } = await import("./debug-41w6Whae.js");
32
32
  const { mcp } = await import("./mcp-fpSlKZxK.js");
33
- const { start } = await import("./start-DgPGr019.js");
33
+ const { start } = await import("./start-BwRZWHAE.js");
34
34
  await runMain(defineCommand({
35
35
  meta: {
36
36
  name: "copilot-api",
@@ -5384,7 +5384,6 @@ const translateResponsesStreamEvent = (rawEvent, state) => {
5384
5384
  case "response.reasoning_summary_part.added": return handleReasoningSummaryPartAdded(rawEvent, state);
5385
5385
  case "response.output_text.delta": return handleOutputTextDelta(rawEvent, state);
5386
5386
  case "response.reasoning_summary_text.done": return handleReasoningSummaryTextDone(rawEvent, state);
5387
- case "response.output_text.done": return handleOutputTextDone(rawEvent, state);
5388
5387
  case "response.output_item.done": return handleOutputItemDone$1(rawEvent, state);
5389
5388
  case "response.function_call_arguments.delta": return handleFunctionCallArgumentsDelta(rawEvent, state);
5390
5389
  case "response.function_call_arguments.done": return handleFunctionCallArgumentsDone(rawEvent, state);
@@ -5621,26 +5620,6 @@ const handleReasoningSummaryTextDone = (rawEvent, state) => {
5621
5620
  }
5622
5621
  return events;
5623
5622
  };
5624
- const handleOutputTextDone = (rawEvent, state) => {
5625
- const events = new Array();
5626
- const outputIndex = rawEvent.output_index;
5627
- const contentIndex = rawEvent.content_index;
5628
- const text = rawEvent.text;
5629
- const blockIndex = openTextBlockIfNeeded(state, {
5630
- outputIndex,
5631
- contentIndex,
5632
- events
5633
- });
5634
- if (text && !state.blockHasDelta.has(blockIndex)) events.push({
5635
- type: "content_block_delta",
5636
- index: blockIndex,
5637
- delta: {
5638
- type: "text_delta",
5639
- text
5640
- }
5641
- });
5642
- return events;
5643
- };
5644
5623
  const handleResponseCompleted = (rawEvent, state) => {
5645
5624
  const response = rawEvent.response;
5646
5625
  const events = new Array();
@@ -5792,6 +5771,7 @@ const openFunctionCallBlock = (state, params) => {
5792
5771
  }
5793
5772
  const { blockIndex } = functionCallState;
5794
5773
  if (!state.openBlocks.has(blockIndex)) {
5774
+ closeOpenBlocks(state, events);
5795
5775
  events.push({
5796
5776
  type: "content_block_start",
5797
5777
  index: blockIndex,
@@ -7819,7 +7799,7 @@ After deleting anything material, briefly tell the user what was removed and whe
7819
7799
  supports_parallel_tool_calls: true,
7820
7800
  supports_image_detail_original: true,
7821
7801
  context_window: 272e3,
7822
- max_context_window: 272e3,
7802
+ max_context_window: 872e3,
7823
7803
  comp_hash: "3000",
7824
7804
  effective_context_window_percent: 95,
7825
7805
  experimental_supported_tools: [],
@@ -9177,83 +9157,69 @@ var CustomToolInputStreamDecoder = class {
9177
9157
  return this.inputParts.join("");
9178
9158
  }
9179
9159
  consume(char, deltaParts) {
9180
- if (this.state === "prefix") {
9181
- const token = CUSTOM_TOOL_INPUT_PREFIX_TOKENS[this.prefixTokenOffset];
9182
- if (this.prefixCharOffset === 0 && isJsonWhitespace(char)) return;
9183
- if (!token || char !== token[this.prefixCharOffset]) return this.fail("unexpected custom tool input prefix");
9184
- this.prefixCharOffset += 1;
9185
- if (this.prefixCharOffset < token.length) return;
9186
- this.prefixTokenOffset += 1;
9187
- this.prefixCharOffset = 0;
9188
- if (this.prefixTokenOffset === CUSTOM_TOOL_INPUT_PREFIX_TOKENS.length) this.state = "input";
9160
+ switch (this.state) {
9161
+ case "prefix": return this.consumePrefix(char);
9162
+ case "suffix": return this.consumeSuffix(char);
9163
+ case "trailing": return this.consumeTrailing(char);
9164
+ case "done": return this.consumeDone(char);
9165
+ default: return this.consumeInput(char, deltaParts);
9166
+ }
9167
+ }
9168
+ consumePrefix(char) {
9169
+ const token = CUSTOM_TOOL_INPUT_PREFIX_TOKENS[this.prefixTokenOffset];
9170
+ if (this.prefixCharOffset === 0 && isJsonWhitespace(char)) return;
9171
+ if (char !== token?.[this.prefixCharOffset]) return this.fail("unexpected custom tool input prefix");
9172
+ this.prefixCharOffset += 1;
9173
+ if (this.prefixCharOffset < token.length) return;
9174
+ this.prefixTokenOffset += 1;
9175
+ this.prefixCharOffset = 0;
9176
+ if (this.prefixTokenOffset === CUSTOM_TOOL_INPUT_PREFIX_TOKENS.length) this.state = "input";
9177
+ }
9178
+ consumeSuffix(char) {
9179
+ if (isJsonWhitespace(char)) return;
9180
+ if (char === "}") {
9181
+ this.state = "done";
9189
9182
  return;
9190
9183
  }
9191
- if (this.state === "suffix") {
9192
- if (isJsonWhitespace(char)) return;
9193
- if (char === "}") {
9194
- this.state = "done";
9195
- return;
9196
- }
9197
- if (char === ",") {
9198
- this.state = "trailing";
9199
- this.trailingDepth = 1;
9200
- return;
9201
- }
9202
- return this.fail("expected \"}\" or \",\" after the input string");
9184
+ if (char === ",") {
9185
+ this.state = "trailing";
9186
+ this.trailingDepth = 1;
9187
+ return;
9203
9188
  }
9204
- if (this.state === "trailing") {
9205
- if (this.trailingInString) {
9206
- if (this.trailingEscaped) {
9207
- this.trailingEscaped = false;
9208
- return;
9209
- }
9210
- if (char === "\\") {
9211
- this.trailingEscaped = true;
9212
- return;
9213
- }
9214
- if (char === "\"") this.trailingInString = false;
9215
- return;
9216
- }
9217
- if (char === "\"") {
9218
- this.trailingInString = true;
9219
- return;
9220
- }
9221
- if (char === "{" || char === "[") {
9222
- this.trailingDepth += 1;
9223
- return;
9224
- }
9225
- if (char === "}" || char === "]") {
9226
- this.trailingDepth -= 1;
9227
- if (this.trailingDepth === 0) this.state = "done";
9228
- }
9189
+ return this.fail("expected \"}\" or \",\" after the input string");
9190
+ }
9191
+ consumeTrailing(char) {
9192
+ if (this.trailingInString) return this.consumeTrailingString(char);
9193
+ if (char === "\"") {
9194
+ this.trailingInString = true;
9229
9195
  return;
9230
9196
  }
9231
- if (this.state === "done") {
9232
- if (!isJsonWhitespace(char)) return this.fail("unexpected data after the input wrapper");
9197
+ if (char === "{" || char === "[") {
9198
+ this.trailingDepth += 1;
9233
9199
  return;
9234
9200
  }
9235
- if (this.escapeState === "unicode") {
9236
- if (!/^[0-9A-Fa-f]$/u.test(char)) return this.fail("invalid Unicode escape");
9237
- this.encodedInput += char;
9238
- this.unicodeDigitsRemaining -= 1;
9239
- if (this.unicodeDigitsRemaining === 0) {
9240
- this.escapeState = "plain";
9241
- this.safeInputLength = this.encodedInput.length;
9242
- }
9201
+ if (char === "}" || char === "]") {
9202
+ this.trailingDepth -= 1;
9203
+ if (this.trailingDepth === 0) this.state = "done";
9204
+ }
9205
+ }
9206
+ consumeTrailingString(char) {
9207
+ if (this.trailingEscaped) {
9208
+ this.trailingEscaped = false;
9243
9209
  return;
9244
9210
  }
9245
- if (this.escapeState === "escaped") {
9246
- if (!"\"\\/bfnrtu".includes(char)) return this.fail("invalid JSON escape");
9247
- this.encodedInput += char;
9248
- if (char === "u") {
9249
- this.escapeState = "unicode";
9250
- this.unicodeDigitsRemaining = 4;
9251
- } else {
9252
- this.escapeState = "plain";
9253
- this.safeInputLength = this.encodedInput.length;
9254
- }
9211
+ if (char === "\\") {
9212
+ this.trailingEscaped = true;
9255
9213
  return;
9256
9214
  }
9215
+ if (char === "\"") this.trailingInString = false;
9216
+ }
9217
+ consumeDone(char) {
9218
+ if (!isJsonWhitespace(char)) return this.fail("unexpected data after the input wrapper");
9219
+ }
9220
+ consumeInput(char, deltaParts) {
9221
+ if (this.escapeState === "unicode") return this.consumeUnicodeEscape(char);
9222
+ if (this.escapeState === "escaped") return this.consumeEscape(char);
9257
9223
  if (char === "\\") {
9258
9224
  this.encodedInput += char;
9259
9225
  this.escapeState = "escaped";
@@ -9264,10 +9230,30 @@ var CustomToolInputStreamDecoder = class {
9264
9230
  this.state = "suffix";
9265
9231
  return;
9266
9232
  }
9267
- if (char.charCodeAt(0) < 32) return this.fail("unescaped control character in custom tool input");
9233
+ if ((char.codePointAt(0) ?? 0) < 32) return this.fail("unescaped control character in custom tool input");
9268
9234
  this.encodedInput += char;
9269
9235
  this.safeInputLength = this.encodedInput.length;
9270
9236
  }
9237
+ consumeUnicodeEscape(char) {
9238
+ if (!/^[0-9A-Fa-f]$/u.test(char)) return this.fail("invalid Unicode escape");
9239
+ this.encodedInput += char;
9240
+ this.unicodeDigitsRemaining -= 1;
9241
+ if (this.unicodeDigitsRemaining === 0) {
9242
+ this.escapeState = "plain";
9243
+ this.safeInputLength = this.encodedInput.length;
9244
+ }
9245
+ }
9246
+ consumeEscape(char) {
9247
+ if (!String.raw`"\/bfnrtu`.includes(char)) return this.fail("invalid JSON escape");
9248
+ this.encodedInput += char;
9249
+ if (char === "u") {
9250
+ this.escapeState = "unicode";
9251
+ this.unicodeDigitsRemaining = 4;
9252
+ } else {
9253
+ this.escapeState = "plain";
9254
+ this.safeInputLength = this.encodedInput.length;
9255
+ }
9256
+ }
9271
9257
  flushSafeInput(deltaParts) {
9272
9258
  if (this.safeInputLength === 0) return;
9273
9259
  const encoded = this.encodedInput.slice(0, this.safeInputLength);
@@ -10527,4 +10513,4 @@ server.route("/:provider/images", providerImageRoutes);
10527
10513
  //#endregion
10528
10514
  export { server };
10529
10515
 
10530
- //# sourceMappingURL=server-DT2XCiFm.js.map
10516
+ //# sourceMappingURL=server-xe8QDEN1.js.map