@ycodium-ai/agent-kimi 0.2.2938 → 0.2.2942
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 +254 -263
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -24256,6 +24256,230 @@ var UnboundedEventStream = class {
|
|
|
24256
24256
|
}
|
|
24257
24257
|
};
|
|
24258
24258
|
|
|
24259
|
+
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
24260
|
+
function isRecord3(value) {
|
|
24261
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24262
|
+
}
|
|
24263
|
+
function asTrimmedString(value) {
|
|
24264
|
+
if (typeof value !== "string") {
|
|
24265
|
+
return void 0;
|
|
24266
|
+
}
|
|
24267
|
+
const trimmed = value.trim();
|
|
24268
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
24269
|
+
}
|
|
24270
|
+
|
|
24271
|
+
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
24272
|
+
function normalizeCommandValue(value) {
|
|
24273
|
+
const direct = asTrimmedString(value);
|
|
24274
|
+
if (direct) {
|
|
24275
|
+
return direct;
|
|
24276
|
+
}
|
|
24277
|
+
if (!Array.isArray(value)) {
|
|
24278
|
+
return void 0;
|
|
24279
|
+
}
|
|
24280
|
+
const parts = [];
|
|
24281
|
+
for (const entry of value) {
|
|
24282
|
+
const part = asTrimmedString(entry);
|
|
24283
|
+
if (part !== void 0) {
|
|
24284
|
+
parts.push(part);
|
|
24285
|
+
}
|
|
24286
|
+
}
|
|
24287
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
24288
|
+
}
|
|
24289
|
+
function stripTrailingExitCode(value) {
|
|
24290
|
+
const trimmed = value?.trim();
|
|
24291
|
+
if (!trimmed) {
|
|
24292
|
+
return void 0;
|
|
24293
|
+
}
|
|
24294
|
+
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
24295
|
+
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
24296
|
+
return output2.length > 0 ? output2 : void 0;
|
|
24297
|
+
}
|
|
24298
|
+
function extractCommandFromTitle(title) {
|
|
24299
|
+
if (!title) {
|
|
24300
|
+
return void 0;
|
|
24301
|
+
}
|
|
24302
|
+
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
24303
|
+
return backtickMatch?.[1]?.trim() || void 0;
|
|
24304
|
+
}
|
|
24305
|
+
function extractToolCommand(data, title) {
|
|
24306
|
+
const item = isRecord3(data?.["item"]) ? data["item"] : void 0;
|
|
24307
|
+
const itemInput = item && isRecord3(item["input"]) ? item["input"] : void 0;
|
|
24308
|
+
const itemResult = item && isRecord3(item["result"]) ? item["result"] : void 0;
|
|
24309
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24310
|
+
const dataInput = isRecord3(data?.["input"]) ? data["input"] : void 0;
|
|
24311
|
+
const candidates = [
|
|
24312
|
+
normalizeCommandValue(item?.["command"]),
|
|
24313
|
+
normalizeCommandValue(itemInput?.["command"]),
|
|
24314
|
+
normalizeCommandValue(itemResult?.["command"]),
|
|
24315
|
+
normalizeCommandValue(data?.["command"]),
|
|
24316
|
+
normalizeCommandValue(dataInput?.["command"]),
|
|
24317
|
+
normalizeCommandValue(rawInput?.["command"])
|
|
24318
|
+
];
|
|
24319
|
+
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
24320
|
+
if (direct) {
|
|
24321
|
+
return direct;
|
|
24322
|
+
}
|
|
24323
|
+
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
24324
|
+
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
24325
|
+
if (executable && args) {
|
|
24326
|
+
return `${executable} ${args}`;
|
|
24327
|
+
}
|
|
24328
|
+
if (executable) {
|
|
24329
|
+
return executable;
|
|
24330
|
+
}
|
|
24331
|
+
return extractCommandFromTitle(title);
|
|
24332
|
+
}
|
|
24333
|
+
function maybePathLike(value) {
|
|
24334
|
+
if (!value) {
|
|
24335
|
+
return void 0;
|
|
24336
|
+
}
|
|
24337
|
+
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
24338
|
+
return value;
|
|
24339
|
+
}
|
|
24340
|
+
return void 0;
|
|
24341
|
+
}
|
|
24342
|
+
function collectPaths(value, paths, seen, depth) {
|
|
24343
|
+
if (depth > 4 || paths.length >= 8) {
|
|
24344
|
+
return;
|
|
24345
|
+
}
|
|
24346
|
+
if (Array.isArray(value)) {
|
|
24347
|
+
for (const entry of value) {
|
|
24348
|
+
collectPaths(entry, paths, seen, depth + 1);
|
|
24349
|
+
if (paths.length >= 8) {
|
|
24350
|
+
return;
|
|
24351
|
+
}
|
|
24352
|
+
}
|
|
24353
|
+
return;
|
|
24354
|
+
}
|
|
24355
|
+
if (!isRecord3(value)) {
|
|
24356
|
+
return;
|
|
24357
|
+
}
|
|
24358
|
+
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
24359
|
+
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
24360
|
+
if (!candidate || seen.has(candidate)) {
|
|
24361
|
+
continue;
|
|
24362
|
+
}
|
|
24363
|
+
seen.add(candidate);
|
|
24364
|
+
paths.push(candidate);
|
|
24365
|
+
if (paths.length >= 8) {
|
|
24366
|
+
return;
|
|
24367
|
+
}
|
|
24368
|
+
}
|
|
24369
|
+
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
24370
|
+
if (!(nestedKey in value)) {
|
|
24371
|
+
continue;
|
|
24372
|
+
}
|
|
24373
|
+
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
24374
|
+
if (paths.length >= 8) {
|
|
24375
|
+
return;
|
|
24376
|
+
}
|
|
24377
|
+
}
|
|
24378
|
+
}
|
|
24379
|
+
function extractPrimaryPath(data) {
|
|
24380
|
+
const paths = [];
|
|
24381
|
+
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
24382
|
+
return paths[0];
|
|
24383
|
+
}
|
|
24384
|
+
function normalizeEquivalentValue(value) {
|
|
24385
|
+
const trimmed = asTrimmedString(value);
|
|
24386
|
+
if (!trimmed) {
|
|
24387
|
+
return void 0;
|
|
24388
|
+
}
|
|
24389
|
+
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
24390
|
+
}
|
|
24391
|
+
function isEquivalent(left, right) {
|
|
24392
|
+
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
24393
|
+
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
24394
|
+
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
24395
|
+
}
|
|
24396
|
+
function classifyToolAction(input2) {
|
|
24397
|
+
const itemType = input2.itemType ?? void 0;
|
|
24398
|
+
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
24399
|
+
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
24400
|
+
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
24401
|
+
return "command";
|
|
24402
|
+
}
|
|
24403
|
+
if (kind === "read" || title === "read file") {
|
|
24404
|
+
return "read";
|
|
24405
|
+
}
|
|
24406
|
+
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
24407
|
+
return "file_change";
|
|
24408
|
+
}
|
|
24409
|
+
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
24410
|
+
return "search";
|
|
24411
|
+
}
|
|
24412
|
+
return "other";
|
|
24413
|
+
}
|
|
24414
|
+
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
24415
|
+
switch (kind) {
|
|
24416
|
+
case "execute":
|
|
24417
|
+
return "command_execution";
|
|
24418
|
+
case "edit":
|
|
24419
|
+
case "delete":
|
|
24420
|
+
case "move":
|
|
24421
|
+
return "file_change";
|
|
24422
|
+
case "search":
|
|
24423
|
+
case "fetch":
|
|
24424
|
+
return "web_search";
|
|
24425
|
+
default:
|
|
24426
|
+
return "dynamic_tool_call";
|
|
24427
|
+
}
|
|
24428
|
+
}
|
|
24429
|
+
function deriveToolActivityPresentation(input2) {
|
|
24430
|
+
const title = asTrimmedString(input2.title);
|
|
24431
|
+
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
24432
|
+
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
24433
|
+
const data = isRecord3(input2.data) ? input2.data : void 0;
|
|
24434
|
+
const command = extractToolCommand(data, title);
|
|
24435
|
+
const primaryPath = extractPrimaryPath(data);
|
|
24436
|
+
const action = classifyToolAction({
|
|
24437
|
+
itemType: input2.itemType,
|
|
24438
|
+
title,
|
|
24439
|
+
data
|
|
24440
|
+
});
|
|
24441
|
+
if (action === "command") {
|
|
24442
|
+
return {
|
|
24443
|
+
summary: "Ran command",
|
|
24444
|
+
...command ? { detail: command } : {}
|
|
24445
|
+
};
|
|
24446
|
+
}
|
|
24447
|
+
if (action === "read") {
|
|
24448
|
+
if (primaryPath) {
|
|
24449
|
+
return {
|
|
24450
|
+
summary: "Read file",
|
|
24451
|
+
detail: primaryPath
|
|
24452
|
+
};
|
|
24453
|
+
}
|
|
24454
|
+
return {
|
|
24455
|
+
summary: "Read file"
|
|
24456
|
+
};
|
|
24457
|
+
}
|
|
24458
|
+
if (action === "file_change") {
|
|
24459
|
+
return {
|
|
24460
|
+
summary: "Changed files",
|
|
24461
|
+
...primaryPath ? { detail: primaryPath } : {}
|
|
24462
|
+
};
|
|
24463
|
+
}
|
|
24464
|
+
if (action === "search") {
|
|
24465
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24466
|
+
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
24467
|
+
return {
|
|
24468
|
+
summary: "Searched files",
|
|
24469
|
+
...query ? { detail: query } : {}
|
|
24470
|
+
};
|
|
24471
|
+
}
|
|
24472
|
+
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
24473
|
+
return {
|
|
24474
|
+
summary: title ?? fallbackSummary,
|
|
24475
|
+
detail
|
|
24476
|
+
};
|
|
24477
|
+
}
|
|
24478
|
+
return {
|
|
24479
|
+
summary: title ?? fallbackSummary
|
|
24480
|
+
};
|
|
24481
|
+
}
|
|
24482
|
+
|
|
24259
24483
|
// ../../packages/ycodium-acp-executor/src/events.ts
|
|
24260
24484
|
function canonicalRequestTypeFromAcpKind(kind) {
|
|
24261
24485
|
switch (kind) {
|
|
@@ -24311,21 +24535,6 @@ function fileChangesFromAcpPermission(permissionRequest) {
|
|
|
24311
24535
|
}) : [];
|
|
24312
24536
|
return paths.length > 0 ? paths.map((path) => ({ path, omitted: "unavailable" })) : void 0;
|
|
24313
24537
|
}
|
|
24314
|
-
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
24315
|
-
switch (kind) {
|
|
24316
|
-
case "execute":
|
|
24317
|
-
return "command_execution";
|
|
24318
|
-
case "edit":
|
|
24319
|
-
case "delete":
|
|
24320
|
-
case "move":
|
|
24321
|
-
return "file_change";
|
|
24322
|
-
case "search":
|
|
24323
|
-
case "fetch":
|
|
24324
|
-
return "web_search";
|
|
24325
|
-
default:
|
|
24326
|
-
return "dynamic_tool_call";
|
|
24327
|
-
}
|
|
24328
|
-
}
|
|
24329
24538
|
function runtimeItemStatusFromAcpToolStatus(status) {
|
|
24330
24539
|
switch (status) {
|
|
24331
24540
|
case "pending":
|
|
@@ -24397,6 +24606,7 @@ function makeAcpPlanUpdatedEvent(input2) {
|
|
|
24397
24606
|
}
|
|
24398
24607
|
function makeAcpToolCallEvent(input2) {
|
|
24399
24608
|
const runtimeStatus = runtimeItemStatusFromAcpToolStatus(input2.toolCall.status);
|
|
24609
|
+
const { data } = input2.toolCall;
|
|
24400
24610
|
return {
|
|
24401
24611
|
type: input2.toolCall.status === "completed" || input2.toolCall.status === "failed" ? "item.completed" : "item.updated",
|
|
24402
24612
|
...input2.stamp,
|
|
@@ -24409,7 +24619,7 @@ function makeAcpToolCallEvent(input2) {
|
|
|
24409
24619
|
...runtimeStatus ? { status: runtimeStatus } : {},
|
|
24410
24620
|
...input2.toolCall.title ? { title: input2.toolCall.title } : {},
|
|
24411
24621
|
...input2.toolCall.detail ? { detail: input2.toolCall.detail } : {},
|
|
24412
|
-
...Object.keys(
|
|
24622
|
+
...Object.keys(data).length > 0 ? { data } : {}
|
|
24413
24623
|
},
|
|
24414
24624
|
raw: {
|
|
24415
24625
|
source: "acp.jsonrpc",
|
|
@@ -24453,7 +24663,7 @@ function makeAcpContentDeltaEvent(input2) {
|
|
|
24453
24663
|
}
|
|
24454
24664
|
|
|
24455
24665
|
// ../../packages/ycodium-acp-executor/src/config-options.ts
|
|
24456
|
-
function
|
|
24666
|
+
function isRecord4(value) {
|
|
24457
24667
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24458
24668
|
}
|
|
24459
24669
|
function asString(value) {
|
|
@@ -24472,7 +24682,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24472
24682
|
const out = [];
|
|
24473
24683
|
const seen = /* @__PURE__ */ new Set();
|
|
24474
24684
|
const push = (entry) => {
|
|
24475
|
-
if (!
|
|
24685
|
+
if (!isRecord4(entry)) return;
|
|
24476
24686
|
const value = asString(entry["value"]);
|
|
24477
24687
|
if (value === void 0 || seen.has(value)) return;
|
|
24478
24688
|
seen.add(value);
|
|
@@ -24487,7 +24697,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24487
24697
|
});
|
|
24488
24698
|
};
|
|
24489
24699
|
for (const entry of rawOptions) {
|
|
24490
|
-
if (
|
|
24700
|
+
if (isRecord4(entry) && Array.isArray(entry["options"])) {
|
|
24491
24701
|
for (const nested of entry["options"]) push(nested);
|
|
24492
24702
|
continue;
|
|
24493
24703
|
}
|
|
@@ -24497,7 +24707,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24497
24707
|
}
|
|
24498
24708
|
function findAcpEffortConfig(configOptions) {
|
|
24499
24709
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24500
|
-
const candidates = configOptions.filter(
|
|
24710
|
+
const candidates = configOptions.filter(isRecord4).filter((option) => normalizedField(option, "type") === "select").filter(looksLikeEffortOption);
|
|
24501
24711
|
if (candidates.length === 0) return void 0;
|
|
24502
24712
|
const picked = candidates.find((option) => normalizedField(option, "category") === "model_option") ?? candidates.find((option) => normalizedField(option, "id") === "effort") ?? candidates.find((option) => normalizedField(option, "category") === "thought_level") ?? candidates[0];
|
|
24503
24713
|
if (picked === void 0) return void 0;
|
|
@@ -24513,18 +24723,18 @@ function findAcpEffortConfig(configOptions) {
|
|
|
24513
24723
|
}
|
|
24514
24724
|
|
|
24515
24725
|
// ../../packages/ycodium-acp-executor/src/runtime-mode.ts
|
|
24516
|
-
function
|
|
24726
|
+
function isRecord5(value) {
|
|
24517
24727
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24518
24728
|
}
|
|
24519
24729
|
function asString2(value) {
|
|
24520
24730
|
return typeof value === "string" ? value : void 0;
|
|
24521
24731
|
}
|
|
24522
24732
|
function acpModeConfigId(setup) {
|
|
24523
|
-
if (!
|
|
24733
|
+
if (!isRecord5(setup)) return void 0;
|
|
24524
24734
|
const configOptions = setup["configOptions"];
|
|
24525
24735
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24526
24736
|
for (const option of configOptions) {
|
|
24527
|
-
if (!
|
|
24737
|
+
if (!isRecord5(option)) continue;
|
|
24528
24738
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
24529
24739
|
const id = asString2(option["id"])?.trim();
|
|
24530
24740
|
if (id) return id;
|
|
@@ -24532,16 +24742,16 @@ function acpModeConfigId(setup) {
|
|
|
24532
24742
|
return void 0;
|
|
24533
24743
|
}
|
|
24534
24744
|
function acpCurrentModeId(setup) {
|
|
24535
|
-
if (!
|
|
24745
|
+
if (!isRecord5(setup)) return void 0;
|
|
24536
24746
|
const modes = setup["modes"];
|
|
24537
|
-
if (
|
|
24747
|
+
if (isRecord5(modes)) {
|
|
24538
24748
|
const current = asString2(modes["currentModeId"])?.trim();
|
|
24539
24749
|
if (current) return current;
|
|
24540
24750
|
}
|
|
24541
24751
|
const configOptions = setup["configOptions"];
|
|
24542
24752
|
if (Array.isArray(configOptions)) {
|
|
24543
24753
|
for (const option of configOptions) {
|
|
24544
|
-
if (!
|
|
24754
|
+
if (!isRecord5(option)) continue;
|
|
24545
24755
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
24546
24756
|
const current = asString2(option["currentValue"])?.trim();
|
|
24547
24757
|
if (current) return current;
|
|
@@ -24655,215 +24865,6 @@ var Mutex = class {
|
|
|
24655
24865
|
}
|
|
24656
24866
|
};
|
|
24657
24867
|
|
|
24658
|
-
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
24659
|
-
function isRecord5(value) {
|
|
24660
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24661
|
-
}
|
|
24662
|
-
function asTrimmedString(value) {
|
|
24663
|
-
if (typeof value !== "string") {
|
|
24664
|
-
return void 0;
|
|
24665
|
-
}
|
|
24666
|
-
const trimmed = value.trim();
|
|
24667
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
24668
|
-
}
|
|
24669
|
-
|
|
24670
|
-
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
24671
|
-
function normalizeCommandValue(value) {
|
|
24672
|
-
const direct = asTrimmedString(value);
|
|
24673
|
-
if (direct) {
|
|
24674
|
-
return direct;
|
|
24675
|
-
}
|
|
24676
|
-
if (!Array.isArray(value)) {
|
|
24677
|
-
return void 0;
|
|
24678
|
-
}
|
|
24679
|
-
const parts = [];
|
|
24680
|
-
for (const entry of value) {
|
|
24681
|
-
const part = asTrimmedString(entry);
|
|
24682
|
-
if (part !== void 0) {
|
|
24683
|
-
parts.push(part);
|
|
24684
|
-
}
|
|
24685
|
-
}
|
|
24686
|
-
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
24687
|
-
}
|
|
24688
|
-
function stripTrailingExitCode(value) {
|
|
24689
|
-
const trimmed = value?.trim();
|
|
24690
|
-
if (!trimmed) {
|
|
24691
|
-
return void 0;
|
|
24692
|
-
}
|
|
24693
|
-
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
24694
|
-
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
24695
|
-
return output2.length > 0 ? output2 : void 0;
|
|
24696
|
-
}
|
|
24697
|
-
function extractCommandFromTitle(title) {
|
|
24698
|
-
if (!title) {
|
|
24699
|
-
return void 0;
|
|
24700
|
-
}
|
|
24701
|
-
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
24702
|
-
return backtickMatch?.[1]?.trim() || void 0;
|
|
24703
|
-
}
|
|
24704
|
-
function extractToolCommand(data, title) {
|
|
24705
|
-
const item = isRecord5(data?.["item"]) ? data["item"] : void 0;
|
|
24706
|
-
const itemInput = item && isRecord5(item["input"]) ? item["input"] : void 0;
|
|
24707
|
-
const itemResult = item && isRecord5(item["result"]) ? item["result"] : void 0;
|
|
24708
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24709
|
-
const dataInput = isRecord5(data?.["input"]) ? data["input"] : void 0;
|
|
24710
|
-
const candidates = [
|
|
24711
|
-
normalizeCommandValue(item?.["command"]),
|
|
24712
|
-
normalizeCommandValue(itemInput?.["command"]),
|
|
24713
|
-
normalizeCommandValue(itemResult?.["command"]),
|
|
24714
|
-
normalizeCommandValue(data?.["command"]),
|
|
24715
|
-
normalizeCommandValue(dataInput?.["command"]),
|
|
24716
|
-
normalizeCommandValue(rawInput?.["command"])
|
|
24717
|
-
];
|
|
24718
|
-
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
24719
|
-
if (direct) {
|
|
24720
|
-
return direct;
|
|
24721
|
-
}
|
|
24722
|
-
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
24723
|
-
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
24724
|
-
if (executable && args) {
|
|
24725
|
-
return `${executable} ${args}`;
|
|
24726
|
-
}
|
|
24727
|
-
if (executable) {
|
|
24728
|
-
return executable;
|
|
24729
|
-
}
|
|
24730
|
-
return extractCommandFromTitle(title);
|
|
24731
|
-
}
|
|
24732
|
-
function maybePathLike(value) {
|
|
24733
|
-
if (!value) {
|
|
24734
|
-
return void 0;
|
|
24735
|
-
}
|
|
24736
|
-
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
24737
|
-
return value;
|
|
24738
|
-
}
|
|
24739
|
-
return void 0;
|
|
24740
|
-
}
|
|
24741
|
-
function collectPaths(value, paths, seen, depth) {
|
|
24742
|
-
if (depth > 4 || paths.length >= 8) {
|
|
24743
|
-
return;
|
|
24744
|
-
}
|
|
24745
|
-
if (Array.isArray(value)) {
|
|
24746
|
-
for (const entry of value) {
|
|
24747
|
-
collectPaths(entry, paths, seen, depth + 1);
|
|
24748
|
-
if (paths.length >= 8) {
|
|
24749
|
-
return;
|
|
24750
|
-
}
|
|
24751
|
-
}
|
|
24752
|
-
return;
|
|
24753
|
-
}
|
|
24754
|
-
if (!isRecord5(value)) {
|
|
24755
|
-
return;
|
|
24756
|
-
}
|
|
24757
|
-
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
24758
|
-
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
24759
|
-
if (!candidate || seen.has(candidate)) {
|
|
24760
|
-
continue;
|
|
24761
|
-
}
|
|
24762
|
-
seen.add(candidate);
|
|
24763
|
-
paths.push(candidate);
|
|
24764
|
-
if (paths.length >= 8) {
|
|
24765
|
-
return;
|
|
24766
|
-
}
|
|
24767
|
-
}
|
|
24768
|
-
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
24769
|
-
if (!(nestedKey in value)) {
|
|
24770
|
-
continue;
|
|
24771
|
-
}
|
|
24772
|
-
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
24773
|
-
if (paths.length >= 8) {
|
|
24774
|
-
return;
|
|
24775
|
-
}
|
|
24776
|
-
}
|
|
24777
|
-
}
|
|
24778
|
-
function extractPrimaryPath(data) {
|
|
24779
|
-
const paths = [];
|
|
24780
|
-
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
24781
|
-
return paths[0];
|
|
24782
|
-
}
|
|
24783
|
-
function normalizeEquivalentValue(value) {
|
|
24784
|
-
const trimmed = asTrimmedString(value);
|
|
24785
|
-
if (!trimmed) {
|
|
24786
|
-
return void 0;
|
|
24787
|
-
}
|
|
24788
|
-
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
24789
|
-
}
|
|
24790
|
-
function isEquivalent(left, right) {
|
|
24791
|
-
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
24792
|
-
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
24793
|
-
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
24794
|
-
}
|
|
24795
|
-
function classifyToolAction(input2) {
|
|
24796
|
-
const itemType = input2.itemType ?? void 0;
|
|
24797
|
-
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
24798
|
-
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
24799
|
-
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
24800
|
-
return "command";
|
|
24801
|
-
}
|
|
24802
|
-
if (kind === "read" || title === "read file") {
|
|
24803
|
-
return "read";
|
|
24804
|
-
}
|
|
24805
|
-
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
24806
|
-
return "file_change";
|
|
24807
|
-
}
|
|
24808
|
-
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
24809
|
-
return "search";
|
|
24810
|
-
}
|
|
24811
|
-
return "other";
|
|
24812
|
-
}
|
|
24813
|
-
function deriveToolActivityPresentation(input2) {
|
|
24814
|
-
const title = asTrimmedString(input2.title);
|
|
24815
|
-
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
24816
|
-
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
24817
|
-
const data = isRecord5(input2.data) ? input2.data : void 0;
|
|
24818
|
-
const command = extractToolCommand(data, title);
|
|
24819
|
-
const primaryPath = extractPrimaryPath(data);
|
|
24820
|
-
const action = classifyToolAction({
|
|
24821
|
-
itemType: input2.itemType,
|
|
24822
|
-
title,
|
|
24823
|
-
data
|
|
24824
|
-
});
|
|
24825
|
-
if (action === "command") {
|
|
24826
|
-
return {
|
|
24827
|
-
summary: "Ran command",
|
|
24828
|
-
...command ? { detail: command } : {}
|
|
24829
|
-
};
|
|
24830
|
-
}
|
|
24831
|
-
if (action === "read") {
|
|
24832
|
-
if (primaryPath) {
|
|
24833
|
-
return {
|
|
24834
|
-
summary: "Read file",
|
|
24835
|
-
detail: primaryPath
|
|
24836
|
-
};
|
|
24837
|
-
}
|
|
24838
|
-
return {
|
|
24839
|
-
summary: "Read file"
|
|
24840
|
-
};
|
|
24841
|
-
}
|
|
24842
|
-
if (action === "file_change") {
|
|
24843
|
-
return {
|
|
24844
|
-
summary: "Changed files",
|
|
24845
|
-
...primaryPath ? { detail: primaryPath } : {}
|
|
24846
|
-
};
|
|
24847
|
-
}
|
|
24848
|
-
if (action === "search") {
|
|
24849
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24850
|
-
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
24851
|
-
return {
|
|
24852
|
-
summary: "Searched files",
|
|
24853
|
-
...query ? { detail: query } : {}
|
|
24854
|
-
};
|
|
24855
|
-
}
|
|
24856
|
-
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
24857
|
-
return {
|
|
24858
|
-
summary: title ?? fallbackSummary,
|
|
24859
|
-
detail
|
|
24860
|
-
};
|
|
24861
|
-
}
|
|
24862
|
-
return {
|
|
24863
|
-
summary: title ?? fallbackSummary
|
|
24864
|
-
};
|
|
24865
|
-
}
|
|
24866
|
-
|
|
24867
24868
|
// ../../packages/ycodium-acp-executor/src/runtime-model.ts
|
|
24868
24869
|
function extractModelConfigId(sessionResponse) {
|
|
24869
24870
|
const configOptions = sessionResponse.configOptions;
|
|
@@ -24894,11 +24895,11 @@ function collectSessionConfigOptionValues(configOption) {
|
|
|
24894
24895
|
);
|
|
24895
24896
|
}
|
|
24896
24897
|
function collectSessionModelIds(models) {
|
|
24897
|
-
if (!
|
|
24898
|
+
if (!isRecord3(models) || !Array.isArray(models["availableModels"])) {
|
|
24898
24899
|
return [];
|
|
24899
24900
|
}
|
|
24900
24901
|
return models["availableModels"].flatMap(
|
|
24901
|
-
(model) =>
|
|
24902
|
+
(model) => isRecord3(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
24902
24903
|
);
|
|
24903
24904
|
}
|
|
24904
24905
|
function catalogModelLastSegment(value) {
|
|
@@ -24970,7 +24971,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
24970
24971
|
}
|
|
24971
24972
|
const commands = [];
|
|
24972
24973
|
for (const command of availableCommands) {
|
|
24973
|
-
if (!
|
|
24974
|
+
if (!isRecord3(command)) {
|
|
24974
24975
|
continue;
|
|
24975
24976
|
}
|
|
24976
24977
|
const name = typeof command["name"] === "string" ? command["name"].trim() : "";
|
|
@@ -24978,7 +24979,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
24978
24979
|
continue;
|
|
24979
24980
|
}
|
|
24980
24981
|
const description = typeof command["description"] === "string" ? command["description"].trim() || void 0 : void 0;
|
|
24981
|
-
const input2 =
|
|
24982
|
+
const input2 = isRecord3(command["input"]) ? command["input"] : void 0;
|
|
24982
24983
|
const inputHint = typeof input2?.["hint"] === "string" ? input2["hint"].trim() || void 0 : void 0;
|
|
24983
24984
|
commands.push({
|
|
24984
24985
|
name,
|
|
@@ -25040,7 +25041,7 @@ function extractCommandFromTitle2(title) {
|
|
|
25040
25041
|
return match?.[1]?.trim() || void 0;
|
|
25041
25042
|
}
|
|
25042
25043
|
function extractToolCallCommand(rawInput, title) {
|
|
25043
|
-
if (
|
|
25044
|
+
if (isRecord3(rawInput)) {
|
|
25044
25045
|
const directCommand = normalizeCommandValue2(rawInput["command"]);
|
|
25045
25046
|
if (directCommand) {
|
|
25046
25047
|
return directCommand;
|
|
@@ -25067,7 +25068,7 @@ function boundToolCallOutputText(text) {
|
|
|
25067
25068
|
}
|
|
25068
25069
|
var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
|
|
25069
25070
|
function boundToolCallRawOutput(rawOutput) {
|
|
25070
|
-
if (!
|
|
25071
|
+
if (!isRecord3(rawOutput)) {
|
|
25071
25072
|
return rawOutput;
|
|
25072
25073
|
}
|
|
25073
25074
|
let changed = false;
|
|
@@ -25125,21 +25126,6 @@ function extractTextContentFromToolCallContent(content) {
|
|
|
25125
25126
|
function normalizeToolKind(kind) {
|
|
25126
25127
|
return typeof kind === "string" && kind.trim().length > 0 ? kind.trim() : void 0;
|
|
25127
25128
|
}
|
|
25128
|
-
function canonicalItemTypeFromAcpToolKind2(kind) {
|
|
25129
|
-
switch (kind) {
|
|
25130
|
-
case "execute":
|
|
25131
|
-
return "command_execution";
|
|
25132
|
-
case "edit":
|
|
25133
|
-
case "delete":
|
|
25134
|
-
case "move":
|
|
25135
|
-
return "file_change";
|
|
25136
|
-
case "search":
|
|
25137
|
-
case "fetch":
|
|
25138
|
-
return "web_search";
|
|
25139
|
-
default:
|
|
25140
|
-
return "dynamic_tool_call";
|
|
25141
|
-
}
|
|
25142
|
-
}
|
|
25143
25129
|
function makeToolCallState(input2, options) {
|
|
25144
25130
|
const toolCallId = typeof input2.toolCallId === "string" ? input2.toolCallId.trim() : "";
|
|
25145
25131
|
if (!toolCallId) {
|
|
@@ -25155,6 +25141,10 @@ function makeToolCallState(input2, options) {
|
|
|
25155
25141
|
if (kind) {
|
|
25156
25142
|
data["kind"] = kind;
|
|
25157
25143
|
}
|
|
25144
|
+
const name = readAcpText(input2, "name");
|
|
25145
|
+
if (name) {
|
|
25146
|
+
data["name"] = name;
|
|
25147
|
+
}
|
|
25158
25148
|
if (command) {
|
|
25159
25149
|
data["command"] = command;
|
|
25160
25150
|
}
|
|
@@ -25173,7 +25163,7 @@ function makeToolCallState(input2, options) {
|
|
|
25173
25163
|
const fallbackDetail = command ?? normalizedTitle ?? textContent;
|
|
25174
25164
|
const hasPresentationSeed = title !== void 0 || kind !== void 0 || command !== void 0 || normalizedTitle !== void 0 || textContent !== void 0;
|
|
25175
25165
|
const presentation = hasPresentationSeed ? deriveToolActivityPresentation({
|
|
25176
|
-
itemType:
|
|
25166
|
+
itemType: canonicalItemTypeFromAcpToolKind(kind),
|
|
25177
25167
|
title,
|
|
25178
25168
|
detail: fallbackDetail,
|
|
25179
25169
|
data,
|
|
@@ -25279,7 +25269,7 @@ function readAcpText(source, key) {
|
|
|
25279
25269
|
}
|
|
25280
25270
|
function textFromContentBlocks(blocks) {
|
|
25281
25271
|
const parts = blocks.flatMap(
|
|
25282
|
-
(block) =>
|
|
25272
|
+
(block) => isRecord3(block) && block["type"] === "text" && typeof block["text"] === "string" ? [block["text"]] : []
|
|
25283
25273
|
);
|
|
25284
25274
|
const joined = parts.join("");
|
|
25285
25275
|
return joined.trim().length > 0 ? joined : void 0;
|
|
@@ -25304,7 +25294,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25304
25294
|
const entries = Array.isArray(upd["entries"]) ? upd["entries"] : [];
|
|
25305
25295
|
const plan = entries.map((entry, index) => ({
|
|
25306
25296
|
step: readAcpText(entry, "content") ?? `Step ${index + 1}`,
|
|
25307
|
-
status: normalizePlanStepStatus(
|
|
25297
|
+
status: normalizePlanStepStatus(isRecord3(entry) ? entry["status"] : void 0)
|
|
25308
25298
|
}));
|
|
25309
25299
|
if (plan.length > 0) {
|
|
25310
25300
|
events.push({
|
|
@@ -25322,6 +25312,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25322
25312
|
const toolCall = makeToolCallState(
|
|
25323
25313
|
{
|
|
25324
25314
|
toolCallId: upd["toolCallId"],
|
|
25315
|
+
name: upd["name"],
|
|
25325
25316
|
title: typeof upd["title"] === "string" ? upd["title"] : void 0,
|
|
25326
25317
|
kind: upd["kind"],
|
|
25327
25318
|
status: upd["status"],
|
|
@@ -25343,7 +25334,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25343
25334
|
}
|
|
25344
25335
|
case "agent_message_chunk":
|
|
25345
25336
|
case "agent_thought_chunk": {
|
|
25346
|
-
const content =
|
|
25337
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
25347
25338
|
const contentType = content?.["type"];
|
|
25348
25339
|
const streamKind = kind === "agent_thought_chunk" ? "reasoning_text" : "assistant_text";
|
|
25349
25340
|
if (contentType === "text") {
|
|
@@ -25383,7 +25374,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25383
25374
|
}
|
|
25384
25375
|
case "compaction_summary_chunk": {
|
|
25385
25376
|
const compactionId = readAcpText(upd, "compactionId");
|
|
25386
|
-
const content =
|
|
25377
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
25387
25378
|
const text = content?.["type"] === "text" ? content["text"] : void 0;
|
|
25388
25379
|
if (compactionId === void 0 || typeof text !== "string" || text.length === 0) break;
|
|
25389
25380
|
events.push({ _tag: "CompactionSummaryChunk", compactionId, text });
|
|
@@ -25415,7 +25406,7 @@ function normalizeModelId(value) {
|
|
|
25415
25406
|
return value?.trim() || void 0;
|
|
25416
25407
|
}
|
|
25417
25408
|
function modelSelectionStateFromSetup(setup) {
|
|
25418
|
-
const sessionModels =
|
|
25409
|
+
const sessionModels = isRecord3(setup.models) ? setup.models : void 0;
|
|
25419
25410
|
const modelConfigId = extractModelConfigId(setup);
|
|
25420
25411
|
const strategy = sessionModels === void 0 && modelConfigId !== void 0 ? "config-option" : "session/set_model";
|
|
25421
25412
|
const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
|
|
@@ -26660,7 +26651,7 @@ function createAcpExecutor(options) {
|
|
|
26660
26651
|
pendingUserInputs.delete(requestId);
|
|
26661
26652
|
pending.resolve({
|
|
26662
26653
|
kind: "answered",
|
|
26663
|
-
answers:
|
|
26654
|
+
answers: isRecord3(answers) ? answers : {}
|
|
26664
26655
|
});
|
|
26665
26656
|
};
|
|
26666
26657
|
const dispose = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-kimi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2942",
|
|
4
4
|
"description": "Kimi Code executor: runs `kimi acp` over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@types/node": "24.12.4",
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
25
|
-
"ycodium-
|
|
26
|
-
"ycodium-executor
|
|
24
|
+
"@ycodium-ai/plugin-api": "0.2.2942",
|
|
25
|
+
"ycodium-executor-testing": "0.0.0",
|
|
26
|
+
"ycodium-acp-executor": "0.2.2942"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|