@corbat-tech/coco 2.33.1 → 2.33.2

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/index.js CHANGED
@@ -14532,6 +14532,14 @@ var OpenAIProvider = class {
14532
14532
  supportsTemperature(model) {
14533
14533
  return !MODELS_WITHOUT_TEMPERATURE.some((m) => model.toLowerCase().includes(m.toLowerCase()));
14534
14534
  }
14535
+ /**
14536
+ * Whether this provider instance supports the Responses API for the given model.
14537
+ * Subclasses (e.g. CopilotProvider) can override to force Chat Completions
14538
+ * when their endpoint does not expose /v1/responses.
14539
+ */
14540
+ modelNeedsResponsesApi(model) {
14541
+ return needsResponsesApi(model);
14542
+ }
14535
14543
  /**
14536
14544
  * Get extra body parameters for API calls.
14537
14545
  * Honors the user's ThinkingMode for Kimi models; defaults to disabled
@@ -14551,7 +14559,7 @@ var OpenAIProvider = class {
14551
14559
  async chat(messages, options) {
14552
14560
  this.ensureInitialized();
14553
14561
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
14554
- if (needsResponsesApi(model)) {
14562
+ if (this.modelNeedsResponsesApi(model)) {
14555
14563
  return this.chatViaResponses(messages, options);
14556
14564
  }
14557
14565
  return withRetry(async () => {
@@ -14591,7 +14599,7 @@ var OpenAIProvider = class {
14591
14599
  async chatWithTools(messages, options) {
14592
14600
  this.ensureInitialized();
14593
14601
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
14594
- if (needsResponsesApi(model)) {
14602
+ if (this.modelNeedsResponsesApi(model)) {
14595
14603
  return this.chatWithToolsViaResponses(messages, options);
14596
14604
  }
14597
14605
  return withRetry(async () => {
@@ -14643,7 +14651,7 @@ var OpenAIProvider = class {
14643
14651
  async *stream(messages, options) {
14644
14652
  this.ensureInitialized();
14645
14653
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
14646
- if (needsResponsesApi(model)) {
14654
+ if (this.modelNeedsResponsesApi(model)) {
14647
14655
  yield* this.streamViaResponses(messages, options);
14648
14656
  return;
14649
14657
  }
@@ -14681,7 +14689,7 @@ var OpenAIProvider = class {
14681
14689
  async *streamWithTools(messages, options) {
14682
14690
  this.ensureInitialized();
14683
14691
  const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
14684
- if (needsResponsesApi(model)) {
14692
+ if (this.modelNeedsResponsesApi(model)) {
14685
14693
  yield* this.streamWithToolsViaResponses(messages, options);
14686
14694
  return;
14687
14695
  }
@@ -14933,7 +14941,7 @@ var OpenAIProvider = class {
14933
14941
  } catch {
14934
14942
  try {
14935
14943
  const model = this.config.model || DEFAULT_MODEL2;
14936
- if (needsResponsesApi(model)) {
14944
+ if (this.modelNeedsResponsesApi(model)) {
14937
14945
  await this.client.responses.create({
14938
14946
  model,
14939
14947
  input: [{ role: "user", content: [{ type: "input_text", text: "Hi" }] }],
@@ -15074,7 +15082,7 @@ var OpenAIProvider = class {
15074
15082
  type: "function",
15075
15083
  function: {
15076
15084
  name: tool.name,
15077
- description: tool.description,
15085
+ description: truncateToolDescription(tool.description),
15078
15086
  parameters: tool.input_schema
15079
15087
  }
15080
15088
  }));
@@ -15560,12 +15568,17 @@ var OpenAIProvider = class {
15560
15568
  return tools.map((tool) => ({
15561
15569
  type: "function",
15562
15570
  name: tool.name,
15563
- description: tool.description ?? void 0,
15571
+ description: tool.description ? truncateToolDescription(tool.description) : void 0,
15564
15572
  parameters: tool.input_schema ?? null,
15565
15573
  strict: false
15566
15574
  }));
15567
15575
  }
15568
15576
  };
15577
+ var MAX_TOOL_DESCRIPTION_LENGTH = 1024;
15578
+ function truncateToolDescription(description) {
15579
+ if (description.length <= MAX_TOOL_DESCRIPTION_LENGTH) return description;
15580
+ return description.slice(0, MAX_TOOL_DESCRIPTION_LENGTH - 1) + "\u2026";
15581
+ }
15569
15582
  function createKimiProvider(config) {
15570
15583
  const provider = new OpenAIProvider("kimi", "Kimi (Moonshot)");
15571
15584
  const kimiConfig = {
@@ -16334,6 +16347,14 @@ var CopilotProvider = class extends OpenAIProvider {
16334
16347
  /**
16335
16348
  * Count tokens (approximate — Copilot models vary in tokenizer)
16336
16349
  */
16350
+ /**
16351
+ * The GitHub Copilot endpoint (api.githubcopilot.com) does not expose the
16352
+ * OpenAI Responses API (/v1/responses). Always use Chat Completions so that
16353
+ * gpt-5-mini and similar models work correctly with MCP tools.
16354
+ */
16355
+ modelNeedsResponsesApi(_model) {
16356
+ return false;
16357
+ }
16337
16358
  countTokens(text) {
16338
16359
  if (!text) return 0;
16339
16360
  return Math.ceil(text.length / 3.5);