@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/cli/index.js +43 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4220,6 +4220,10 @@ function buildMaxTokensParam(model, maxTokens) {
|
|
|
4220
4220
|
}
|
|
4221
4221
|
return { max_tokens: maxTokens };
|
|
4222
4222
|
}
|
|
4223
|
+
function truncateToolDescription(description) {
|
|
4224
|
+
if (description.length <= MAX_TOOL_DESCRIPTION_LENGTH) return description;
|
|
4225
|
+
return description.slice(0, MAX_TOOL_DESCRIPTION_LENGTH - 1) + "\u2026";
|
|
4226
|
+
}
|
|
4223
4227
|
function createOpenAIProvider(config) {
|
|
4224
4228
|
const provider = new OpenAIProvider();
|
|
4225
4229
|
if (config) {
|
|
@@ -4242,7 +4246,7 @@ function createKimiProvider(config) {
|
|
|
4242
4246
|
}
|
|
4243
4247
|
return provider;
|
|
4244
4248
|
}
|
|
4245
|
-
var DEFAULT_MODEL2, CONTEXT_WINDOWS2, MODELS_WITHOUT_TEMPERATURE, LOCAL_MODEL_PATTERNS, MODELS_WITH_THINKING_MODE, OpenAIProvider;
|
|
4249
|
+
var DEFAULT_MODEL2, CONTEXT_WINDOWS2, MODELS_WITHOUT_TEMPERATURE, LOCAL_MODEL_PATTERNS, MODELS_WITH_THINKING_MODE, OpenAIProvider, MAX_TOOL_DESCRIPTION_LENGTH;
|
|
4246
4250
|
var init_openai = __esm({
|
|
4247
4251
|
"src/providers/openai.ts"() {
|
|
4248
4252
|
init_errors();
|
|
@@ -4400,6 +4404,14 @@ var init_openai = __esm({
|
|
|
4400
4404
|
supportsTemperature(model) {
|
|
4401
4405
|
return !MODELS_WITHOUT_TEMPERATURE.some((m) => model.toLowerCase().includes(m.toLowerCase()));
|
|
4402
4406
|
}
|
|
4407
|
+
/**
|
|
4408
|
+
* Whether this provider instance supports the Responses API for the given model.
|
|
4409
|
+
* Subclasses (e.g. CopilotProvider) can override to force Chat Completions
|
|
4410
|
+
* when their endpoint does not expose /v1/responses.
|
|
4411
|
+
*/
|
|
4412
|
+
modelNeedsResponsesApi(model) {
|
|
4413
|
+
return needsResponsesApi(model);
|
|
4414
|
+
}
|
|
4403
4415
|
/**
|
|
4404
4416
|
* Get extra body parameters for API calls.
|
|
4405
4417
|
* Honors the user's ThinkingMode for Kimi models; defaults to disabled
|
|
@@ -4419,7 +4431,7 @@ var init_openai = __esm({
|
|
|
4419
4431
|
async chat(messages, options) {
|
|
4420
4432
|
this.ensureInitialized();
|
|
4421
4433
|
const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
|
|
4422
|
-
if (
|
|
4434
|
+
if (this.modelNeedsResponsesApi(model)) {
|
|
4423
4435
|
return this.chatViaResponses(messages, options);
|
|
4424
4436
|
}
|
|
4425
4437
|
return withRetry(async () => {
|
|
@@ -4459,7 +4471,7 @@ var init_openai = __esm({
|
|
|
4459
4471
|
async chatWithTools(messages, options) {
|
|
4460
4472
|
this.ensureInitialized();
|
|
4461
4473
|
const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
|
|
4462
|
-
if (
|
|
4474
|
+
if (this.modelNeedsResponsesApi(model)) {
|
|
4463
4475
|
return this.chatWithToolsViaResponses(messages, options);
|
|
4464
4476
|
}
|
|
4465
4477
|
return withRetry(async () => {
|
|
@@ -4511,7 +4523,7 @@ var init_openai = __esm({
|
|
|
4511
4523
|
async *stream(messages, options) {
|
|
4512
4524
|
this.ensureInitialized();
|
|
4513
4525
|
const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
|
|
4514
|
-
if (
|
|
4526
|
+
if (this.modelNeedsResponsesApi(model)) {
|
|
4515
4527
|
yield* this.streamViaResponses(messages, options);
|
|
4516
4528
|
return;
|
|
4517
4529
|
}
|
|
@@ -4549,7 +4561,7 @@ var init_openai = __esm({
|
|
|
4549
4561
|
async *streamWithTools(messages, options) {
|
|
4550
4562
|
this.ensureInitialized();
|
|
4551
4563
|
const model = options?.model ?? this.config.model ?? DEFAULT_MODEL2;
|
|
4552
|
-
if (
|
|
4564
|
+
if (this.modelNeedsResponsesApi(model)) {
|
|
4553
4565
|
yield* this.streamWithToolsViaResponses(messages, options);
|
|
4554
4566
|
return;
|
|
4555
4567
|
}
|
|
@@ -4801,7 +4813,7 @@ var init_openai = __esm({
|
|
|
4801
4813
|
} catch {
|
|
4802
4814
|
try {
|
|
4803
4815
|
const model = this.config.model || DEFAULT_MODEL2;
|
|
4804
|
-
if (
|
|
4816
|
+
if (this.modelNeedsResponsesApi(model)) {
|
|
4805
4817
|
await this.client.responses.create({
|
|
4806
4818
|
model,
|
|
4807
4819
|
input: [{ role: "user", content: [{ type: "input_text", text: "Hi" }] }],
|
|
@@ -4942,7 +4954,7 @@ var init_openai = __esm({
|
|
|
4942
4954
|
type: "function",
|
|
4943
4955
|
function: {
|
|
4944
4956
|
name: tool.name,
|
|
4945
|
-
description: tool.description,
|
|
4957
|
+
description: truncateToolDescription(tool.description),
|
|
4946
4958
|
parameters: tool.input_schema
|
|
4947
4959
|
}
|
|
4948
4960
|
}));
|
|
@@ -5428,12 +5440,13 @@ var init_openai = __esm({
|
|
|
5428
5440
|
return tools.map((tool) => ({
|
|
5429
5441
|
type: "function",
|
|
5430
5442
|
name: tool.name,
|
|
5431
|
-
description: tool.description
|
|
5443
|
+
description: tool.description ? truncateToolDescription(tool.description) : void 0,
|
|
5432
5444
|
parameters: tool.input_schema ?? null,
|
|
5433
5445
|
strict: false
|
|
5434
5446
|
}));
|
|
5435
5447
|
}
|
|
5436
5448
|
};
|
|
5449
|
+
MAX_TOOL_DESCRIPTION_LENGTH = 1024;
|
|
5437
5450
|
}
|
|
5438
5451
|
});
|
|
5439
5452
|
|
|
@@ -6210,6 +6223,14 @@ var init_copilot2 = __esm({
|
|
|
6210
6223
|
/**
|
|
6211
6224
|
* Count tokens (approximate — Copilot models vary in tokenizer)
|
|
6212
6225
|
*/
|
|
6226
|
+
/**
|
|
6227
|
+
* The GitHub Copilot endpoint (api.githubcopilot.com) does not expose the
|
|
6228
|
+
* OpenAI Responses API (/v1/responses). Always use Chat Completions so that
|
|
6229
|
+
* gpt-5-mini and similar models work correctly with MCP tools.
|
|
6230
|
+
*/
|
|
6231
|
+
modelNeedsResponsesApi(_model) {
|
|
6232
|
+
return false;
|
|
6233
|
+
}
|
|
6213
6234
|
countTokens(text15) {
|
|
6214
6235
|
if (!text15) return 0;
|
|
6215
6236
|
return Math.ceil(text15.length / 3.5);
|
|
@@ -10786,7 +10807,7 @@ async function createDefaultReplConfig() {
|
|
|
10786
10807
|
const model = await getLastUsedModel(providerType) || getDefaultModel(providerType);
|
|
10787
10808
|
const persistedThinking = await getLastUsedThinking(providerType);
|
|
10788
10809
|
const thinking = persistedThinking ?? resolveDefaultThinking(providerType, model);
|
|
10789
|
-
const thinkingToStore = thinking === "off" ? void 0 : thinking;
|
|
10810
|
+
const thinkingToStore = persistedThinking !== void 0 ? persistedThinking : thinking === "off" ? void 0 : thinking;
|
|
10790
10811
|
return {
|
|
10791
10812
|
provider: {
|
|
10792
10813
|
type: providerType,
|
|
@@ -34319,6 +34340,12 @@ async function renderStartupPanel(session, gitCtx, mcpServers = []) {
|
|
|
34319
34340
|
}
|
|
34320
34341
|
const cocoStatus = isQualityLoop() ? chalk.magenta(" \u{1F504} quality mode: ") + chalk.green.bold("on") + chalk.dim(" \u2014 iterates until quality \u2265 85. /quality to disable") : chalk.dim(" \u{1F4A1} quality mode is Coco's edge for robust code. Enable with /quality on");
|
|
34321
34342
|
console.log(cocoStatus);
|
|
34343
|
+
if (thinkingCapability.supported) {
|
|
34344
|
+
const modeLabel = formatThinkingMode(session.config.provider.thinking ?? "off");
|
|
34345
|
+
console.log(
|
|
34346
|
+
chalk.dim(" \u{1F9E0} reasoning: ") + chalk.magenta(modeLabel) + chalk.dim(" \xB7 /thinking to change")
|
|
34347
|
+
);
|
|
34348
|
+
}
|
|
34322
34349
|
const skillTotal = session.skillRegistry?.size ?? 0;
|
|
34323
34350
|
const hasSomething = skillTotal > 0 || mcpServers.length > 0;
|
|
34324
34351
|
if (hasSomething) {
|
|
@@ -35928,6 +35955,7 @@ async function ensureConfiguredV2(config) {
|
|
|
35928
35955
|
const preferredHasOpenAIOAuth = preferredProviderDef?.id === "openai" && hasOpenAIOAuthTokens;
|
|
35929
35956
|
const preferredHasCopilotCreds = preferredProviderDef?.id === "copilot" && isProviderConfigured();
|
|
35930
35957
|
const preferredIsConfigured = preferredIsLocal || preferredHasApiKey || preferredHasOpenAIOAuth || preferredHasCopilotCreds;
|
|
35958
|
+
const preferredWasConfigured = Boolean(preferredProviderDef && preferredIsConfigured);
|
|
35931
35959
|
let preferredWasConfiguredButUnavailable = false;
|
|
35932
35960
|
let preferredUnavailableWasLocal = false;
|
|
35933
35961
|
if (preferredProviderDef && preferredIsConfigured) {
|
|
@@ -35973,7 +36001,9 @@ async function ensureConfiguredV2(config) {
|
|
|
35973
36001
|
}
|
|
35974
36002
|
const provider = await createProvider(providerId, { model });
|
|
35975
36003
|
if (await provider.isAvailable()) {
|
|
35976
|
-
|
|
36004
|
+
if (!preferredWasConfigured) {
|
|
36005
|
+
await saveProviderPreference(prov.id, model);
|
|
36006
|
+
}
|
|
35977
36007
|
return {
|
|
35978
36008
|
...config,
|
|
35979
36009
|
provider: {
|
|
@@ -35998,7 +36028,9 @@ async function ensureConfiguredV2(config) {
|
|
|
35998
36028
|
const model = recommended?.id || openaiDef.models[0]?.id || "";
|
|
35999
36029
|
const provider = await createProvider("codex", { model });
|
|
36000
36030
|
if (await provider.isAvailable()) {
|
|
36001
|
-
|
|
36031
|
+
if (!preferredWasConfigured) {
|
|
36032
|
+
await saveProviderPreference("openai", model);
|
|
36033
|
+
}
|
|
36002
36034
|
return {
|
|
36003
36035
|
...config,
|
|
36004
36036
|
provider: {
|