@moonshot-ai/kimi-code 0.13.1 → 0.14.0
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.mjs +50 -2
- package/package.json +3 -3
package/dist/main.mjs
CHANGED
|
@@ -45840,6 +45840,8 @@ const OPENAI_CHAT_TOOL_CALL_ID_POLICY = {
|
|
|
45840
45840
|
normalize: (id) => sanitizeToolCallId(id, 64),
|
|
45841
45841
|
maxLength: 64
|
|
45842
45842
|
};
|
|
45843
|
+
const TOOL_RESULT_IMAGE_PROMPT = "Attached image(s) from tool result:";
|
|
45844
|
+
const TOOL_RESULT_IMAGE_PLACEHOLDER = "(see attached image)";
|
|
45843
45845
|
function extractReasoningContent(source, explicitKey) {
|
|
45844
45846
|
if (typeof source !== "object" || source === null) return void 0;
|
|
45845
45847
|
const record = source;
|
|
@@ -45872,7 +45874,7 @@ function convertMessage$1(message, reasoningKey, toolMessageConversion) {
|
|
|
45872
45874
|
const result = { role: message.role };
|
|
45873
45875
|
if (message.role === "tool") {
|
|
45874
45876
|
const effectiveConversion = message.content.some((p) => p.type !== "text" && p.type !== "think") ? "extract_text" : toolMessageConversion;
|
|
45875
|
-
if (effectiveConversion !== null) result.content =
|
|
45877
|
+
if (effectiveConversion !== null) result.content = convertToolMessageContentForChat(message, effectiveConversion);
|
|
45876
45878
|
else {
|
|
45877
45879
|
const firstPart = nonThinkParts[0];
|
|
45878
45880
|
if (nonThinkParts.length === 1 && firstPart?.type === "text") result.content = firstPart.text;
|
|
@@ -45896,6 +45898,47 @@ function convertMessage$1(message, reasoningKey, toolMessageConversion) {
|
|
|
45896
45898
|
if (reasoningContent) result[reasoningKey ?? DEFAULT_OUTBOUND_REASONING_KEY] = reasoningContent;
|
|
45897
45899
|
return result;
|
|
45898
45900
|
}
|
|
45901
|
+
function convertToolMessageContentForChat(message, conversion) {
|
|
45902
|
+
const content = convertToolMessageContent(message, conversion);
|
|
45903
|
+
if (typeof content === "string" && content.length === 0 && message.content.some((part) => part.type === "image_url")) return TOOL_RESULT_IMAGE_PLACEHOLDER;
|
|
45904
|
+
return content;
|
|
45905
|
+
}
|
|
45906
|
+
function toolResultImageParts(message) {
|
|
45907
|
+
const images = [];
|
|
45908
|
+
for (const part of message.content) {
|
|
45909
|
+
if (part.type !== "image_url") continue;
|
|
45910
|
+
images.push({
|
|
45911
|
+
type: "image_url",
|
|
45912
|
+
image_url: part.imageUrl.id === void 0 ? { url: part.imageUrl.url } : {
|
|
45913
|
+
url: part.imageUrl.url,
|
|
45914
|
+
id: part.imageUrl.id
|
|
45915
|
+
}
|
|
45916
|
+
});
|
|
45917
|
+
}
|
|
45918
|
+
return images;
|
|
45919
|
+
}
|
|
45920
|
+
function appendToolResultImagesMessage(messages, pendingToolResultImages) {
|
|
45921
|
+
if (pendingToolResultImages.length === 0) return;
|
|
45922
|
+
messages.push({
|
|
45923
|
+
role: "user",
|
|
45924
|
+
content: [{
|
|
45925
|
+
type: "text",
|
|
45926
|
+
text: TOOL_RESULT_IMAGE_PROMPT
|
|
45927
|
+
}, ...pendingToolResultImages]
|
|
45928
|
+
});
|
|
45929
|
+
pendingToolResultImages.length = 0;
|
|
45930
|
+
}
|
|
45931
|
+
function convertHistoryMessages(history, reasoningKey, toolMessageConversion) {
|
|
45932
|
+
const messages = [];
|
|
45933
|
+
const pendingToolResultImages = [];
|
|
45934
|
+
for (const msg of history) {
|
|
45935
|
+
if (msg.role !== "tool") appendToolResultImagesMessage(messages, pendingToolResultImages);
|
|
45936
|
+
messages.push(convertMessage$1(msg, reasoningKey, toolMessageConversion));
|
|
45937
|
+
if (msg.role === "tool") pendingToolResultImages.push(...toolResultImageParts(msg));
|
|
45938
|
+
}
|
|
45939
|
+
appendToolResultImagesMessage(messages, pendingToolResultImages);
|
|
45940
|
+
return messages;
|
|
45941
|
+
}
|
|
45899
45942
|
var OpenAILegacyStreamedMessage = class {
|
|
45900
45943
|
_id = null;
|
|
45901
45944
|
_usage = null;
|
|
@@ -46031,7 +46074,7 @@ var OpenAILegacyChatProvider = class {
|
|
|
46031
46074
|
content: systemPrompt
|
|
46032
46075
|
});
|
|
46033
46076
|
const normalizedHistory = normalizeToolCallIdsForProvider(history, OPENAI_CHAT_TOOL_CALL_ID_POLICY);
|
|
46034
|
-
|
|
46077
|
+
messages.push(...convertHistoryMessages(normalizedHistory, this._reasoningKey, this._toolMessageConversion));
|
|
46035
46078
|
const kwargs = normalizeGenerationKwargs(this._model, this._generationKwargs);
|
|
46036
46079
|
let reasoningEffort = this._reasoningEffort;
|
|
46037
46080
|
if (reasoningEffort === void 0 && kwargs["reasoning_effort"] === void 0) {
|
|
@@ -57477,6 +57520,7 @@ const HOOK_EVENT_TYPES = [
|
|
|
57477
57520
|
"UserPromptSubmit",
|
|
57478
57521
|
"Stop",
|
|
57479
57522
|
"StopFailure",
|
|
57523
|
+
"Interrupt",
|
|
57480
57524
|
"SessionStart",
|
|
57481
57525
|
"SessionEnd",
|
|
57482
57526
|
"SubagentStart",
|
|
@@ -89216,6 +89260,10 @@ var TurnFlow = class {
|
|
|
89216
89260
|
}
|
|
89217
89261
|
}
|
|
89218
89262
|
if (this.currentId === turnId) this.agent.usage.endTurn();
|
|
89263
|
+
if (ended.reason === "cancelled" && isUserCancellation(signal.reason)) this.agent.hooks?.fireAndForgetTrigger("Interrupt", { inputData: {
|
|
89264
|
+
turnId,
|
|
89265
|
+
reason: "cancelled"
|
|
89266
|
+
} });
|
|
89219
89267
|
this.agent.emitEvent(ended);
|
|
89220
89268
|
if (standalone && this.currentId === turnId) this.activeTurn = null;
|
|
89221
89269
|
if (this.agent.swarmMode.shouldAutoExit) this.agent.swarmMode.exit();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonshot-ai/kimi-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The Starting Point for Next-Gen Agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Moonshot AI",
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
"postject": "1.0.0-alpha.6",
|
|
61
61
|
"tsx": "^4.21.0",
|
|
62
62
|
"yazl": "^3.3.1",
|
|
63
|
+
"@moonshot-ai/kimi-code-oauth": "^0.2.2",
|
|
63
64
|
"@moonshot-ai/acp-adapter": "^0.2.4",
|
|
64
65
|
"@moonshot-ai/kimi-code-sdk": "^0.9.1",
|
|
65
|
-
"@moonshot-ai/kimi-telemetry": "^0.1.1",
|
|
66
66
|
"@moonshot-ai/migration-legacy": "^0.1.12",
|
|
67
|
-
"@moonshot-ai/kimi-
|
|
67
|
+
"@moonshot-ai/kimi-telemetry": "^0.1.1"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=22.19.0"
|