@corbat-tech/coco 2.5.1 → 2.5.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 +35 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +23 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -12,8 +12,8 @@ import fs32__default, { mkdir, writeFile, readFile, access, readdir, rm } from '
|
|
|
12
12
|
import JSON5 from 'json5';
|
|
13
13
|
import { Logger } from 'tslog';
|
|
14
14
|
import Anthropic from '@anthropic-ai/sdk';
|
|
15
|
-
import OpenAI from 'openai';
|
|
16
15
|
import { jsonrepair } from 'jsonrepair';
|
|
16
|
+
import OpenAI from 'openai';
|
|
17
17
|
import * as crypto from 'crypto';
|
|
18
18
|
import { randomUUID } from 'crypto';
|
|
19
19
|
import * as http from 'http';
|
|
@@ -1079,10 +1079,21 @@ var init_anthropic = __esm({
|
|
|
1079
1079
|
try {
|
|
1080
1080
|
currentToolCall.input = currentToolInputJson ? JSON.parse(currentToolInputJson) : {};
|
|
1081
1081
|
} catch {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1082
|
+
let repaired = false;
|
|
1083
|
+
if (currentToolInputJson) {
|
|
1084
|
+
try {
|
|
1085
|
+
currentToolCall.input = JSON.parse(jsonrepair(currentToolInputJson));
|
|
1086
|
+
repaired = true;
|
|
1087
|
+
getLogger().debug(`Repaired JSON for tool ${currentToolCall.name}`);
|
|
1088
|
+
} catch {
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (!repaired) {
|
|
1092
|
+
getLogger().warn(
|
|
1093
|
+
`Failed to parse tool call arguments for ${currentToolCall.name}: ${currentToolInputJson?.slice(0, 300)}`
|
|
1094
|
+
);
|
|
1095
|
+
currentToolCall.input = {};
|
|
1096
|
+
}
|
|
1086
1097
|
}
|
|
1087
1098
|
yield {
|
|
1088
1099
|
type: "tool_use_end",
|
|
@@ -1692,7 +1703,7 @@ var init_openai = __esm({
|
|
|
1692
1703
|
input = builder.arguments ? JSON.parse(builder.arguments) : {};
|
|
1693
1704
|
} catch (error) {
|
|
1694
1705
|
console.warn(
|
|
1695
|
-
`[${this.name}] Failed to parse tool call arguments for ${builder.name}: ${builder.arguments?.slice(0,
|
|
1706
|
+
`[${this.name}] Failed to parse tool call arguments for ${builder.name}: ${builder.arguments?.slice(0, 300)}`
|
|
1696
1707
|
);
|
|
1697
1708
|
try {
|
|
1698
1709
|
if (builder.arguments) {
|
|
@@ -8165,6 +8176,12 @@ var init_registry4 = __esm({
|
|
|
8165
8176
|
return `${field} (${issue.message.toLowerCase()})`;
|
|
8166
8177
|
});
|
|
8167
8178
|
errorMessage = `Invalid tool input \u2014 ${fields.join(", ")}`;
|
|
8179
|
+
const allUndefined = error.issues.every(
|
|
8180
|
+
(i) => i.message.toLowerCase().includes("received undefined")
|
|
8181
|
+
);
|
|
8182
|
+
if (allUndefined && error.issues.length > 1) {
|
|
8183
|
+
errorMessage += ". All parameters are missing \u2014 this is likely a JSON serialization error on our side. Please retry with the same arguments.";
|
|
8184
|
+
}
|
|
8168
8185
|
} else {
|
|
8169
8186
|
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
8170
8187
|
errorMessage = humanizeError(rawMessage, name);
|
|
@@ -43509,15 +43526,24 @@ function createIntentRecognizer(config = {}) {
|
|
|
43509
43526
|
raw: input
|
|
43510
43527
|
};
|
|
43511
43528
|
}
|
|
43529
|
+
if (!trimmedInput.startsWith("/")) {
|
|
43530
|
+
return {
|
|
43531
|
+
type: "chat",
|
|
43532
|
+
confidence: 1,
|
|
43533
|
+
entities: {},
|
|
43534
|
+
raw: input
|
|
43535
|
+
};
|
|
43536
|
+
}
|
|
43537
|
+
const commandPart = trimmedInput.slice(1);
|
|
43512
43538
|
const intentTypes = ["status", "trust", "help", "exit"];
|
|
43513
43539
|
let bestMatch = null;
|
|
43514
43540
|
for (const type of intentTypes) {
|
|
43515
|
-
const match = matchIntent(
|
|
43541
|
+
const match = matchIntent(commandPart, type);
|
|
43516
43542
|
if (match.matched && match.confidence > (bestMatch?.confidence || 0)) {
|
|
43517
43543
|
bestMatch = {
|
|
43518
43544
|
type,
|
|
43519
43545
|
confidence: match.confidence,
|
|
43520
|
-
entities: extractEntities(
|
|
43546
|
+
entities: extractEntities(commandPart),
|
|
43521
43547
|
raw: input,
|
|
43522
43548
|
matchedPattern: match.pattern
|
|
43523
43549
|
};
|
|
@@ -43528,7 +43554,7 @@ function createIntentRecognizer(config = {}) {
|
|
|
43528
43554
|
return {
|
|
43529
43555
|
type: "chat",
|
|
43530
43556
|
confidence: bestMatch?.confidence || 0.3,
|
|
43531
|
-
entities: extractEntities(
|
|
43557
|
+
entities: extractEntities(commandPart),
|
|
43532
43558
|
raw: input
|
|
43533
43559
|
};
|
|
43534
43560
|
}
|