@ycodium-ai/agent-acp 0.2.2938 → 0.2.2944
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 +264 -273
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -24173,6 +24173,230 @@ var UnboundedEventStream = class {
|
|
|
24173
24173
|
}
|
|
24174
24174
|
};
|
|
24175
24175
|
|
|
24176
|
+
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
24177
|
+
function isRecord3(value) {
|
|
24178
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24179
|
+
}
|
|
24180
|
+
function asTrimmedString(value) {
|
|
24181
|
+
if (typeof value !== "string") {
|
|
24182
|
+
return void 0;
|
|
24183
|
+
}
|
|
24184
|
+
const trimmed = value.trim();
|
|
24185
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
24186
|
+
}
|
|
24187
|
+
|
|
24188
|
+
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
24189
|
+
function normalizeCommandValue(value) {
|
|
24190
|
+
const direct = asTrimmedString(value);
|
|
24191
|
+
if (direct) {
|
|
24192
|
+
return direct;
|
|
24193
|
+
}
|
|
24194
|
+
if (!Array.isArray(value)) {
|
|
24195
|
+
return void 0;
|
|
24196
|
+
}
|
|
24197
|
+
const parts = [];
|
|
24198
|
+
for (const entry of value) {
|
|
24199
|
+
const part = asTrimmedString(entry);
|
|
24200
|
+
if (part !== void 0) {
|
|
24201
|
+
parts.push(part);
|
|
24202
|
+
}
|
|
24203
|
+
}
|
|
24204
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
24205
|
+
}
|
|
24206
|
+
function stripTrailingExitCode(value) {
|
|
24207
|
+
const trimmed = value?.trim();
|
|
24208
|
+
if (!trimmed) {
|
|
24209
|
+
return void 0;
|
|
24210
|
+
}
|
|
24211
|
+
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
24212
|
+
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
24213
|
+
return output2.length > 0 ? output2 : void 0;
|
|
24214
|
+
}
|
|
24215
|
+
function extractCommandFromTitle(title) {
|
|
24216
|
+
if (!title) {
|
|
24217
|
+
return void 0;
|
|
24218
|
+
}
|
|
24219
|
+
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
24220
|
+
return backtickMatch?.[1]?.trim() || void 0;
|
|
24221
|
+
}
|
|
24222
|
+
function extractToolCommand(data, title) {
|
|
24223
|
+
const item = isRecord3(data?.["item"]) ? data["item"] : void 0;
|
|
24224
|
+
const itemInput = item && isRecord3(item["input"]) ? item["input"] : void 0;
|
|
24225
|
+
const itemResult = item && isRecord3(item["result"]) ? item["result"] : void 0;
|
|
24226
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24227
|
+
const dataInput = isRecord3(data?.["input"]) ? data["input"] : void 0;
|
|
24228
|
+
const candidates = [
|
|
24229
|
+
normalizeCommandValue(item?.["command"]),
|
|
24230
|
+
normalizeCommandValue(itemInput?.["command"]),
|
|
24231
|
+
normalizeCommandValue(itemResult?.["command"]),
|
|
24232
|
+
normalizeCommandValue(data?.["command"]),
|
|
24233
|
+
normalizeCommandValue(dataInput?.["command"]),
|
|
24234
|
+
normalizeCommandValue(rawInput?.["command"])
|
|
24235
|
+
];
|
|
24236
|
+
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
24237
|
+
if (direct) {
|
|
24238
|
+
return direct;
|
|
24239
|
+
}
|
|
24240
|
+
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
24241
|
+
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
24242
|
+
if (executable && args) {
|
|
24243
|
+
return `${executable} ${args}`;
|
|
24244
|
+
}
|
|
24245
|
+
if (executable) {
|
|
24246
|
+
return executable;
|
|
24247
|
+
}
|
|
24248
|
+
return extractCommandFromTitle(title);
|
|
24249
|
+
}
|
|
24250
|
+
function maybePathLike(value) {
|
|
24251
|
+
if (!value) {
|
|
24252
|
+
return void 0;
|
|
24253
|
+
}
|
|
24254
|
+
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
24255
|
+
return value;
|
|
24256
|
+
}
|
|
24257
|
+
return void 0;
|
|
24258
|
+
}
|
|
24259
|
+
function collectPaths(value, paths, seen, depth) {
|
|
24260
|
+
if (depth > 4 || paths.length >= 8) {
|
|
24261
|
+
return;
|
|
24262
|
+
}
|
|
24263
|
+
if (Array.isArray(value)) {
|
|
24264
|
+
for (const entry of value) {
|
|
24265
|
+
collectPaths(entry, paths, seen, depth + 1);
|
|
24266
|
+
if (paths.length >= 8) {
|
|
24267
|
+
return;
|
|
24268
|
+
}
|
|
24269
|
+
}
|
|
24270
|
+
return;
|
|
24271
|
+
}
|
|
24272
|
+
if (!isRecord3(value)) {
|
|
24273
|
+
return;
|
|
24274
|
+
}
|
|
24275
|
+
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
24276
|
+
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
24277
|
+
if (!candidate || seen.has(candidate)) {
|
|
24278
|
+
continue;
|
|
24279
|
+
}
|
|
24280
|
+
seen.add(candidate);
|
|
24281
|
+
paths.push(candidate);
|
|
24282
|
+
if (paths.length >= 8) {
|
|
24283
|
+
return;
|
|
24284
|
+
}
|
|
24285
|
+
}
|
|
24286
|
+
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
24287
|
+
if (!(nestedKey in value)) {
|
|
24288
|
+
continue;
|
|
24289
|
+
}
|
|
24290
|
+
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
24291
|
+
if (paths.length >= 8) {
|
|
24292
|
+
return;
|
|
24293
|
+
}
|
|
24294
|
+
}
|
|
24295
|
+
}
|
|
24296
|
+
function extractPrimaryPath(data) {
|
|
24297
|
+
const paths = [];
|
|
24298
|
+
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
24299
|
+
return paths[0];
|
|
24300
|
+
}
|
|
24301
|
+
function normalizeEquivalentValue(value) {
|
|
24302
|
+
const trimmed = asTrimmedString(value);
|
|
24303
|
+
if (!trimmed) {
|
|
24304
|
+
return void 0;
|
|
24305
|
+
}
|
|
24306
|
+
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
24307
|
+
}
|
|
24308
|
+
function isEquivalent(left, right) {
|
|
24309
|
+
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
24310
|
+
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
24311
|
+
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
24312
|
+
}
|
|
24313
|
+
function classifyToolAction(input2) {
|
|
24314
|
+
const itemType = input2.itemType ?? void 0;
|
|
24315
|
+
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
24316
|
+
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
24317
|
+
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
24318
|
+
return "command";
|
|
24319
|
+
}
|
|
24320
|
+
if (kind === "read" || title === "read file") {
|
|
24321
|
+
return "read";
|
|
24322
|
+
}
|
|
24323
|
+
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
24324
|
+
return "file_change";
|
|
24325
|
+
}
|
|
24326
|
+
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
24327
|
+
return "search";
|
|
24328
|
+
}
|
|
24329
|
+
return "other";
|
|
24330
|
+
}
|
|
24331
|
+
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
24332
|
+
switch (kind) {
|
|
24333
|
+
case "execute":
|
|
24334
|
+
return "command_execution";
|
|
24335
|
+
case "edit":
|
|
24336
|
+
case "delete":
|
|
24337
|
+
case "move":
|
|
24338
|
+
return "file_change";
|
|
24339
|
+
case "search":
|
|
24340
|
+
case "fetch":
|
|
24341
|
+
return "web_search";
|
|
24342
|
+
default:
|
|
24343
|
+
return "dynamic_tool_call";
|
|
24344
|
+
}
|
|
24345
|
+
}
|
|
24346
|
+
function deriveToolActivityPresentation(input2) {
|
|
24347
|
+
const title = asTrimmedString(input2.title);
|
|
24348
|
+
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
24349
|
+
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
24350
|
+
const data = isRecord3(input2.data) ? input2.data : void 0;
|
|
24351
|
+
const command = extractToolCommand(data, title);
|
|
24352
|
+
const primaryPath = extractPrimaryPath(data);
|
|
24353
|
+
const action = classifyToolAction({
|
|
24354
|
+
itemType: input2.itemType,
|
|
24355
|
+
title,
|
|
24356
|
+
data
|
|
24357
|
+
});
|
|
24358
|
+
if (action === "command") {
|
|
24359
|
+
return {
|
|
24360
|
+
summary: "Ran command",
|
|
24361
|
+
...command ? { detail: command } : {}
|
|
24362
|
+
};
|
|
24363
|
+
}
|
|
24364
|
+
if (action === "read") {
|
|
24365
|
+
if (primaryPath) {
|
|
24366
|
+
return {
|
|
24367
|
+
summary: "Read file",
|
|
24368
|
+
detail: primaryPath
|
|
24369
|
+
};
|
|
24370
|
+
}
|
|
24371
|
+
return {
|
|
24372
|
+
summary: "Read file"
|
|
24373
|
+
};
|
|
24374
|
+
}
|
|
24375
|
+
if (action === "file_change") {
|
|
24376
|
+
return {
|
|
24377
|
+
summary: "Changed files",
|
|
24378
|
+
...primaryPath ? { detail: primaryPath } : {}
|
|
24379
|
+
};
|
|
24380
|
+
}
|
|
24381
|
+
if (action === "search") {
|
|
24382
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24383
|
+
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
24384
|
+
return {
|
|
24385
|
+
summary: "Searched files",
|
|
24386
|
+
...query ? { detail: query } : {}
|
|
24387
|
+
};
|
|
24388
|
+
}
|
|
24389
|
+
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
24390
|
+
return {
|
|
24391
|
+
summary: title ?? fallbackSummary,
|
|
24392
|
+
detail
|
|
24393
|
+
};
|
|
24394
|
+
}
|
|
24395
|
+
return {
|
|
24396
|
+
summary: title ?? fallbackSummary
|
|
24397
|
+
};
|
|
24398
|
+
}
|
|
24399
|
+
|
|
24176
24400
|
// ../../packages/ycodium-acp-executor/src/events.ts
|
|
24177
24401
|
function canonicalRequestTypeFromAcpKind(kind) {
|
|
24178
24402
|
switch (kind) {
|
|
@@ -24228,21 +24452,6 @@ function fileChangesFromAcpPermission(permissionRequest) {
|
|
|
24228
24452
|
}) : [];
|
|
24229
24453
|
return paths.length > 0 ? paths.map((path) => ({ path, omitted: "unavailable" })) : void 0;
|
|
24230
24454
|
}
|
|
24231
|
-
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
24232
|
-
switch (kind) {
|
|
24233
|
-
case "execute":
|
|
24234
|
-
return "command_execution";
|
|
24235
|
-
case "edit":
|
|
24236
|
-
case "delete":
|
|
24237
|
-
case "move":
|
|
24238
|
-
return "file_change";
|
|
24239
|
-
case "search":
|
|
24240
|
-
case "fetch":
|
|
24241
|
-
return "web_search";
|
|
24242
|
-
default:
|
|
24243
|
-
return "dynamic_tool_call";
|
|
24244
|
-
}
|
|
24245
|
-
}
|
|
24246
24455
|
function runtimeItemStatusFromAcpToolStatus(status) {
|
|
24247
24456
|
switch (status) {
|
|
24248
24457
|
case "pending":
|
|
@@ -24314,6 +24523,7 @@ function makeAcpPlanUpdatedEvent(input2) {
|
|
|
24314
24523
|
}
|
|
24315
24524
|
function makeAcpToolCallEvent(input2) {
|
|
24316
24525
|
const runtimeStatus = runtimeItemStatusFromAcpToolStatus(input2.toolCall.status);
|
|
24526
|
+
const { data } = input2.toolCall;
|
|
24317
24527
|
return {
|
|
24318
24528
|
type: input2.toolCall.status === "completed" || input2.toolCall.status === "failed" ? "item.completed" : "item.updated",
|
|
24319
24529
|
...input2.stamp,
|
|
@@ -24326,7 +24536,7 @@ function makeAcpToolCallEvent(input2) {
|
|
|
24326
24536
|
...runtimeStatus ? { status: runtimeStatus } : {},
|
|
24327
24537
|
...input2.toolCall.title ? { title: input2.toolCall.title } : {},
|
|
24328
24538
|
...input2.toolCall.detail ? { detail: input2.toolCall.detail } : {},
|
|
24329
|
-
...Object.keys(
|
|
24539
|
+
...Object.keys(data).length > 0 ? { data } : {}
|
|
24330
24540
|
},
|
|
24331
24541
|
raw: {
|
|
24332
24542
|
source: "acp.jsonrpc",
|
|
@@ -24370,7 +24580,7 @@ function makeAcpContentDeltaEvent(input2) {
|
|
|
24370
24580
|
}
|
|
24371
24581
|
|
|
24372
24582
|
// ../../packages/ycodium-acp-executor/src/config-options.ts
|
|
24373
|
-
function
|
|
24583
|
+
function isRecord4(value) {
|
|
24374
24584
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24375
24585
|
}
|
|
24376
24586
|
function asString(value) {
|
|
@@ -24389,7 +24599,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24389
24599
|
const out = [];
|
|
24390
24600
|
const seen = /* @__PURE__ */ new Set();
|
|
24391
24601
|
const push = (entry) => {
|
|
24392
|
-
if (!
|
|
24602
|
+
if (!isRecord4(entry)) return;
|
|
24393
24603
|
const value = asString(entry["value"]);
|
|
24394
24604
|
if (value === void 0 || seen.has(value)) return;
|
|
24395
24605
|
seen.add(value);
|
|
@@ -24404,7 +24614,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24404
24614
|
});
|
|
24405
24615
|
};
|
|
24406
24616
|
for (const entry of rawOptions) {
|
|
24407
|
-
if (
|
|
24617
|
+
if (isRecord4(entry) && Array.isArray(entry["options"])) {
|
|
24408
24618
|
for (const nested of entry["options"]) push(nested);
|
|
24409
24619
|
continue;
|
|
24410
24620
|
}
|
|
@@ -24414,7 +24624,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
24414
24624
|
}
|
|
24415
24625
|
function findAcpEffortConfig(configOptions) {
|
|
24416
24626
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24417
|
-
const candidates = configOptions.filter(
|
|
24627
|
+
const candidates = configOptions.filter(isRecord4).filter((option) => normalizedField(option, "type") === "select").filter(looksLikeEffortOption);
|
|
24418
24628
|
if (candidates.length === 0) return void 0;
|
|
24419
24629
|
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];
|
|
24420
24630
|
if (picked === void 0) return void 0;
|
|
@@ -24430,7 +24640,7 @@ function findAcpEffortConfig(configOptions) {
|
|
|
24430
24640
|
}
|
|
24431
24641
|
function acpModelChoicesFromConfigOptions(configOptions) {
|
|
24432
24642
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24433
|
-
const records = configOptions.filter(
|
|
24643
|
+
const records = configOptions.filter(isRecord4);
|
|
24434
24644
|
const modelOption = records.find((option) => normalizedField(option, "category") === "model") ?? records.find(
|
|
24435
24645
|
(option) => normalizedField(option, "id") === "model" && normalizedField(option, "type") === "select"
|
|
24436
24646
|
);
|
|
@@ -24439,12 +24649,12 @@ function acpModelChoicesFromConfigOptions(configOptions) {
|
|
|
24439
24649
|
return flattenChoices(modelOption["options"], asString(modelOption["currentValue"])?.trim());
|
|
24440
24650
|
}
|
|
24441
24651
|
function acpModelChoicesFromSessionModels(models) {
|
|
24442
|
-
if (!
|
|
24652
|
+
if (!isRecord4(models) || !Array.isArray(models["availableModels"])) return void 0;
|
|
24443
24653
|
const currentModelId = asString(models["currentModelId"])?.trim();
|
|
24444
24654
|
const out = [];
|
|
24445
24655
|
const seen = /* @__PURE__ */ new Set();
|
|
24446
24656
|
for (const entry of models["availableModels"]) {
|
|
24447
|
-
if (!
|
|
24657
|
+
if (!isRecord4(entry)) continue;
|
|
24448
24658
|
const value = asString(entry["modelId"])?.trim();
|
|
24449
24659
|
if (!value || seen.has(value)) continue;
|
|
24450
24660
|
seen.add(value);
|
|
@@ -24462,23 +24672,23 @@ function acpModelChoicesFromSessionModels(models) {
|
|
|
24462
24672
|
}
|
|
24463
24673
|
|
|
24464
24674
|
// ../../packages/ycodium-acp-executor/src/runtime-mode.ts
|
|
24465
|
-
function
|
|
24675
|
+
function isRecord5(value) {
|
|
24466
24676
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24467
24677
|
}
|
|
24468
24678
|
function asString2(value) {
|
|
24469
24679
|
return typeof value === "string" ? value : void 0;
|
|
24470
24680
|
}
|
|
24471
24681
|
function acpAvailableModes(setup) {
|
|
24472
|
-
if (!
|
|
24682
|
+
if (!isRecord5(setup)) return [];
|
|
24473
24683
|
const out = [];
|
|
24474
24684
|
const seen = /* @__PURE__ */ new Set();
|
|
24475
24685
|
const push = (entry) => {
|
|
24476
|
-
if (!
|
|
24686
|
+
if (!isRecord5(entry)) return;
|
|
24477
24687
|
const id = (asString2(entry["id"]) ?? asString2(entry["value"]))?.trim();
|
|
24478
24688
|
if (!id || seen.has(id)) return;
|
|
24479
24689
|
seen.add(id);
|
|
24480
24690
|
const meta3 = entry["_meta"];
|
|
24481
|
-
const kind =
|
|
24691
|
+
const kind = isRecord5(meta3) ? asString2(meta3["kind"])?.trim().toLowerCase() : void 0;
|
|
24482
24692
|
const name = asString2(entry["name"])?.trim();
|
|
24483
24693
|
const description = asString2(entry["description"])?.trim();
|
|
24484
24694
|
out.push({
|
|
@@ -24489,13 +24699,13 @@ function acpAvailableModes(setup) {
|
|
|
24489
24699
|
});
|
|
24490
24700
|
};
|
|
24491
24701
|
const modes = setup["modes"];
|
|
24492
|
-
if (
|
|
24702
|
+
if (isRecord5(modes) && Array.isArray(modes["availableModes"])) {
|
|
24493
24703
|
for (const entry of modes["availableModes"]) push(entry);
|
|
24494
24704
|
}
|
|
24495
24705
|
const configOptions = setup["configOptions"];
|
|
24496
24706
|
if (Array.isArray(configOptions)) {
|
|
24497
24707
|
for (const option of configOptions) {
|
|
24498
|
-
if (!
|
|
24708
|
+
if (!isRecord5(option)) continue;
|
|
24499
24709
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
24500
24710
|
if (!Array.isArray(option["options"])) continue;
|
|
24501
24711
|
for (const entry of option["options"]) push(entry);
|
|
@@ -24504,11 +24714,11 @@ function acpAvailableModes(setup) {
|
|
|
24504
24714
|
return out;
|
|
24505
24715
|
}
|
|
24506
24716
|
function acpModeConfigId(setup) {
|
|
24507
|
-
if (!
|
|
24717
|
+
if (!isRecord5(setup)) return void 0;
|
|
24508
24718
|
const configOptions = setup["configOptions"];
|
|
24509
24719
|
if (!Array.isArray(configOptions)) return void 0;
|
|
24510
24720
|
for (const option of configOptions) {
|
|
24511
|
-
if (!
|
|
24721
|
+
if (!isRecord5(option)) continue;
|
|
24512
24722
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
24513
24723
|
const id = asString2(option["id"])?.trim();
|
|
24514
24724
|
if (id) return id;
|
|
@@ -24516,16 +24726,16 @@ function acpModeConfigId(setup) {
|
|
|
24516
24726
|
return void 0;
|
|
24517
24727
|
}
|
|
24518
24728
|
function acpCurrentModeId(setup) {
|
|
24519
|
-
if (!
|
|
24729
|
+
if (!isRecord5(setup)) return void 0;
|
|
24520
24730
|
const modes = setup["modes"];
|
|
24521
|
-
if (
|
|
24731
|
+
if (isRecord5(modes)) {
|
|
24522
24732
|
const current = asString2(modes["currentModeId"])?.trim();
|
|
24523
24733
|
if (current) return current;
|
|
24524
24734
|
}
|
|
24525
24735
|
const configOptions = setup["configOptions"];
|
|
24526
24736
|
if (Array.isArray(configOptions)) {
|
|
24527
24737
|
for (const option of configOptions) {
|
|
24528
|
-
if (!
|
|
24738
|
+
if (!isRecord5(option)) continue;
|
|
24529
24739
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
24530
24740
|
const current = asString2(option["currentValue"])?.trim();
|
|
24531
24741
|
if (current) return current;
|
|
@@ -24639,215 +24849,6 @@ var Mutex = class {
|
|
|
24639
24849
|
}
|
|
24640
24850
|
};
|
|
24641
24851
|
|
|
24642
|
-
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
24643
|
-
function isRecord5(value) {
|
|
24644
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24645
|
-
}
|
|
24646
|
-
function asTrimmedString(value) {
|
|
24647
|
-
if (typeof value !== "string") {
|
|
24648
|
-
return void 0;
|
|
24649
|
-
}
|
|
24650
|
-
const trimmed = value.trim();
|
|
24651
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
24652
|
-
}
|
|
24653
|
-
|
|
24654
|
-
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
24655
|
-
function normalizeCommandValue(value) {
|
|
24656
|
-
const direct = asTrimmedString(value);
|
|
24657
|
-
if (direct) {
|
|
24658
|
-
return direct;
|
|
24659
|
-
}
|
|
24660
|
-
if (!Array.isArray(value)) {
|
|
24661
|
-
return void 0;
|
|
24662
|
-
}
|
|
24663
|
-
const parts = [];
|
|
24664
|
-
for (const entry of value) {
|
|
24665
|
-
const part = asTrimmedString(entry);
|
|
24666
|
-
if (part !== void 0) {
|
|
24667
|
-
parts.push(part);
|
|
24668
|
-
}
|
|
24669
|
-
}
|
|
24670
|
-
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
24671
|
-
}
|
|
24672
|
-
function stripTrailingExitCode(value) {
|
|
24673
|
-
const trimmed = value?.trim();
|
|
24674
|
-
if (!trimmed) {
|
|
24675
|
-
return void 0;
|
|
24676
|
-
}
|
|
24677
|
-
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
24678
|
-
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
24679
|
-
return output2.length > 0 ? output2 : void 0;
|
|
24680
|
-
}
|
|
24681
|
-
function extractCommandFromTitle(title) {
|
|
24682
|
-
if (!title) {
|
|
24683
|
-
return void 0;
|
|
24684
|
-
}
|
|
24685
|
-
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
24686
|
-
return backtickMatch?.[1]?.trim() || void 0;
|
|
24687
|
-
}
|
|
24688
|
-
function extractToolCommand(data, title) {
|
|
24689
|
-
const item = isRecord5(data?.["item"]) ? data["item"] : void 0;
|
|
24690
|
-
const itemInput = item && isRecord5(item["input"]) ? item["input"] : void 0;
|
|
24691
|
-
const itemResult = item && isRecord5(item["result"]) ? item["result"] : void 0;
|
|
24692
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24693
|
-
const dataInput = isRecord5(data?.["input"]) ? data["input"] : void 0;
|
|
24694
|
-
const candidates = [
|
|
24695
|
-
normalizeCommandValue(item?.["command"]),
|
|
24696
|
-
normalizeCommandValue(itemInput?.["command"]),
|
|
24697
|
-
normalizeCommandValue(itemResult?.["command"]),
|
|
24698
|
-
normalizeCommandValue(data?.["command"]),
|
|
24699
|
-
normalizeCommandValue(dataInput?.["command"]),
|
|
24700
|
-
normalizeCommandValue(rawInput?.["command"])
|
|
24701
|
-
];
|
|
24702
|
-
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
24703
|
-
if (direct) {
|
|
24704
|
-
return direct;
|
|
24705
|
-
}
|
|
24706
|
-
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
24707
|
-
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
24708
|
-
if (executable && args) {
|
|
24709
|
-
return `${executable} ${args}`;
|
|
24710
|
-
}
|
|
24711
|
-
if (executable) {
|
|
24712
|
-
return executable;
|
|
24713
|
-
}
|
|
24714
|
-
return extractCommandFromTitle(title);
|
|
24715
|
-
}
|
|
24716
|
-
function maybePathLike(value) {
|
|
24717
|
-
if (!value) {
|
|
24718
|
-
return void 0;
|
|
24719
|
-
}
|
|
24720
|
-
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
24721
|
-
return value;
|
|
24722
|
-
}
|
|
24723
|
-
return void 0;
|
|
24724
|
-
}
|
|
24725
|
-
function collectPaths(value, paths, seen, depth) {
|
|
24726
|
-
if (depth > 4 || paths.length >= 8) {
|
|
24727
|
-
return;
|
|
24728
|
-
}
|
|
24729
|
-
if (Array.isArray(value)) {
|
|
24730
|
-
for (const entry of value) {
|
|
24731
|
-
collectPaths(entry, paths, seen, depth + 1);
|
|
24732
|
-
if (paths.length >= 8) {
|
|
24733
|
-
return;
|
|
24734
|
-
}
|
|
24735
|
-
}
|
|
24736
|
-
return;
|
|
24737
|
-
}
|
|
24738
|
-
if (!isRecord5(value)) {
|
|
24739
|
-
return;
|
|
24740
|
-
}
|
|
24741
|
-
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
24742
|
-
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
24743
|
-
if (!candidate || seen.has(candidate)) {
|
|
24744
|
-
continue;
|
|
24745
|
-
}
|
|
24746
|
-
seen.add(candidate);
|
|
24747
|
-
paths.push(candidate);
|
|
24748
|
-
if (paths.length >= 8) {
|
|
24749
|
-
return;
|
|
24750
|
-
}
|
|
24751
|
-
}
|
|
24752
|
-
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
24753
|
-
if (!(nestedKey in value)) {
|
|
24754
|
-
continue;
|
|
24755
|
-
}
|
|
24756
|
-
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
24757
|
-
if (paths.length >= 8) {
|
|
24758
|
-
return;
|
|
24759
|
-
}
|
|
24760
|
-
}
|
|
24761
|
-
}
|
|
24762
|
-
function extractPrimaryPath(data) {
|
|
24763
|
-
const paths = [];
|
|
24764
|
-
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
24765
|
-
return paths[0];
|
|
24766
|
-
}
|
|
24767
|
-
function normalizeEquivalentValue(value) {
|
|
24768
|
-
const trimmed = asTrimmedString(value);
|
|
24769
|
-
if (!trimmed) {
|
|
24770
|
-
return void 0;
|
|
24771
|
-
}
|
|
24772
|
-
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
24773
|
-
}
|
|
24774
|
-
function isEquivalent(left, right) {
|
|
24775
|
-
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
24776
|
-
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
24777
|
-
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
24778
|
-
}
|
|
24779
|
-
function classifyToolAction(input2) {
|
|
24780
|
-
const itemType = input2.itemType ?? void 0;
|
|
24781
|
-
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
24782
|
-
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
24783
|
-
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
24784
|
-
return "command";
|
|
24785
|
-
}
|
|
24786
|
-
if (kind === "read" || title === "read file") {
|
|
24787
|
-
return "read";
|
|
24788
|
-
}
|
|
24789
|
-
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
24790
|
-
return "file_change";
|
|
24791
|
-
}
|
|
24792
|
-
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
24793
|
-
return "search";
|
|
24794
|
-
}
|
|
24795
|
-
return "other";
|
|
24796
|
-
}
|
|
24797
|
-
function deriveToolActivityPresentation(input2) {
|
|
24798
|
-
const title = asTrimmedString(input2.title);
|
|
24799
|
-
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
24800
|
-
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
24801
|
-
const data = isRecord5(input2.data) ? input2.data : void 0;
|
|
24802
|
-
const command = extractToolCommand(data, title);
|
|
24803
|
-
const primaryPath = extractPrimaryPath(data);
|
|
24804
|
-
const action = classifyToolAction({
|
|
24805
|
-
itemType: input2.itemType,
|
|
24806
|
-
title,
|
|
24807
|
-
data
|
|
24808
|
-
});
|
|
24809
|
-
if (action === "command") {
|
|
24810
|
-
return {
|
|
24811
|
-
summary: "Ran command",
|
|
24812
|
-
...command ? { detail: command } : {}
|
|
24813
|
-
};
|
|
24814
|
-
}
|
|
24815
|
-
if (action === "read") {
|
|
24816
|
-
if (primaryPath) {
|
|
24817
|
-
return {
|
|
24818
|
-
summary: "Read file",
|
|
24819
|
-
detail: primaryPath
|
|
24820
|
-
};
|
|
24821
|
-
}
|
|
24822
|
-
return {
|
|
24823
|
-
summary: "Read file"
|
|
24824
|
-
};
|
|
24825
|
-
}
|
|
24826
|
-
if (action === "file_change") {
|
|
24827
|
-
return {
|
|
24828
|
-
summary: "Changed files",
|
|
24829
|
-
...primaryPath ? { detail: primaryPath } : {}
|
|
24830
|
-
};
|
|
24831
|
-
}
|
|
24832
|
-
if (action === "search") {
|
|
24833
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
24834
|
-
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
24835
|
-
return {
|
|
24836
|
-
summary: "Searched files",
|
|
24837
|
-
...query ? { detail: query } : {}
|
|
24838
|
-
};
|
|
24839
|
-
}
|
|
24840
|
-
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
24841
|
-
return {
|
|
24842
|
-
summary: title ?? fallbackSummary,
|
|
24843
|
-
detail
|
|
24844
|
-
};
|
|
24845
|
-
}
|
|
24846
|
-
return {
|
|
24847
|
-
summary: title ?? fallbackSummary
|
|
24848
|
-
};
|
|
24849
|
-
}
|
|
24850
|
-
|
|
24851
24852
|
// ../../packages/ycodium-acp-executor/src/runtime-model.ts
|
|
24852
24853
|
function extractModelConfigId(sessionResponse) {
|
|
24853
24854
|
const configOptions = sessionResponse.configOptions;
|
|
@@ -24878,11 +24879,11 @@ function collectSessionConfigOptionValues(configOption) {
|
|
|
24878
24879
|
);
|
|
24879
24880
|
}
|
|
24880
24881
|
function collectSessionModelIds(models) {
|
|
24881
|
-
if (!
|
|
24882
|
+
if (!isRecord3(models) || !Array.isArray(models["availableModels"])) {
|
|
24882
24883
|
return [];
|
|
24883
24884
|
}
|
|
24884
24885
|
return models["availableModels"].flatMap(
|
|
24885
|
-
(model) =>
|
|
24886
|
+
(model) => isRecord3(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
24886
24887
|
);
|
|
24887
24888
|
}
|
|
24888
24889
|
function catalogModelLastSegment(value) {
|
|
@@ -24954,7 +24955,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
24954
24955
|
}
|
|
24955
24956
|
const commands = [];
|
|
24956
24957
|
for (const command of availableCommands) {
|
|
24957
|
-
if (!
|
|
24958
|
+
if (!isRecord3(command)) {
|
|
24958
24959
|
continue;
|
|
24959
24960
|
}
|
|
24960
24961
|
const name = typeof command["name"] === "string" ? command["name"].trim() : "";
|
|
@@ -24962,7 +24963,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
24962
24963
|
continue;
|
|
24963
24964
|
}
|
|
24964
24965
|
const description = typeof command["description"] === "string" ? command["description"].trim() || void 0 : void 0;
|
|
24965
|
-
const input2 =
|
|
24966
|
+
const input2 = isRecord3(command["input"]) ? command["input"] : void 0;
|
|
24966
24967
|
const inputHint = typeof input2?.["hint"] === "string" ? input2["hint"].trim() || void 0 : void 0;
|
|
24967
24968
|
commands.push({
|
|
24968
24969
|
name,
|
|
@@ -25024,7 +25025,7 @@ function extractCommandFromTitle2(title) {
|
|
|
25024
25025
|
return match?.[1]?.trim() || void 0;
|
|
25025
25026
|
}
|
|
25026
25027
|
function extractToolCallCommand(rawInput, title) {
|
|
25027
|
-
if (
|
|
25028
|
+
if (isRecord3(rawInput)) {
|
|
25028
25029
|
const directCommand = normalizeCommandValue2(rawInput["command"]);
|
|
25029
25030
|
if (directCommand) {
|
|
25030
25031
|
return directCommand;
|
|
@@ -25051,7 +25052,7 @@ function boundToolCallOutputText(text) {
|
|
|
25051
25052
|
}
|
|
25052
25053
|
var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
|
|
25053
25054
|
function boundToolCallRawOutput(rawOutput) {
|
|
25054
|
-
if (!
|
|
25055
|
+
if (!isRecord3(rawOutput)) {
|
|
25055
25056
|
return rawOutput;
|
|
25056
25057
|
}
|
|
25057
25058
|
let changed = false;
|
|
@@ -25109,21 +25110,6 @@ function extractTextContentFromToolCallContent(content) {
|
|
|
25109
25110
|
function normalizeToolKind(kind) {
|
|
25110
25111
|
return typeof kind === "string" && kind.trim().length > 0 ? kind.trim() : void 0;
|
|
25111
25112
|
}
|
|
25112
|
-
function canonicalItemTypeFromAcpToolKind2(kind) {
|
|
25113
|
-
switch (kind) {
|
|
25114
|
-
case "execute":
|
|
25115
|
-
return "command_execution";
|
|
25116
|
-
case "edit":
|
|
25117
|
-
case "delete":
|
|
25118
|
-
case "move":
|
|
25119
|
-
return "file_change";
|
|
25120
|
-
case "search":
|
|
25121
|
-
case "fetch":
|
|
25122
|
-
return "web_search";
|
|
25123
|
-
default:
|
|
25124
|
-
return "dynamic_tool_call";
|
|
25125
|
-
}
|
|
25126
|
-
}
|
|
25127
25113
|
function makeToolCallState(input2, options) {
|
|
25128
25114
|
const toolCallId = typeof input2.toolCallId === "string" ? input2.toolCallId.trim() : "";
|
|
25129
25115
|
if (!toolCallId) {
|
|
@@ -25139,6 +25125,10 @@ function makeToolCallState(input2, options) {
|
|
|
25139
25125
|
if (kind) {
|
|
25140
25126
|
data["kind"] = kind;
|
|
25141
25127
|
}
|
|
25128
|
+
const name = readAcpText(input2, "name");
|
|
25129
|
+
if (name) {
|
|
25130
|
+
data["name"] = name;
|
|
25131
|
+
}
|
|
25142
25132
|
if (command) {
|
|
25143
25133
|
data["command"] = command;
|
|
25144
25134
|
}
|
|
@@ -25157,7 +25147,7 @@ function makeToolCallState(input2, options) {
|
|
|
25157
25147
|
const fallbackDetail = command ?? normalizedTitle ?? textContent;
|
|
25158
25148
|
const hasPresentationSeed = title !== void 0 || kind !== void 0 || command !== void 0 || normalizedTitle !== void 0 || textContent !== void 0;
|
|
25159
25149
|
const presentation = hasPresentationSeed ? deriveToolActivityPresentation({
|
|
25160
|
-
itemType:
|
|
25150
|
+
itemType: canonicalItemTypeFromAcpToolKind(kind),
|
|
25161
25151
|
title,
|
|
25162
25152
|
detail: fallbackDetail,
|
|
25163
25153
|
data,
|
|
@@ -25263,7 +25253,7 @@ function readAcpText(source, key) {
|
|
|
25263
25253
|
}
|
|
25264
25254
|
function textFromContentBlocks(blocks) {
|
|
25265
25255
|
const parts = blocks.flatMap(
|
|
25266
|
-
(block) =>
|
|
25256
|
+
(block) => isRecord3(block) && block["type"] === "text" && typeof block["text"] === "string" ? [block["text"]] : []
|
|
25267
25257
|
);
|
|
25268
25258
|
const joined = parts.join("");
|
|
25269
25259
|
return joined.trim().length > 0 ? joined : void 0;
|
|
@@ -25288,7 +25278,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25288
25278
|
const entries = Array.isArray(upd["entries"]) ? upd["entries"] : [];
|
|
25289
25279
|
const plan = entries.map((entry, index) => ({
|
|
25290
25280
|
step: readAcpText(entry, "content") ?? `Step ${index + 1}`,
|
|
25291
|
-
status: normalizePlanStepStatus(
|
|
25281
|
+
status: normalizePlanStepStatus(isRecord3(entry) ? entry["status"] : void 0)
|
|
25292
25282
|
}));
|
|
25293
25283
|
if (plan.length > 0) {
|
|
25294
25284
|
events.push({
|
|
@@ -25306,6 +25296,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25306
25296
|
const toolCall = makeToolCallState(
|
|
25307
25297
|
{
|
|
25308
25298
|
toolCallId: upd["toolCallId"],
|
|
25299
|
+
name: upd["name"],
|
|
25309
25300
|
title: typeof upd["title"] === "string" ? upd["title"] : void 0,
|
|
25310
25301
|
kind: upd["kind"],
|
|
25311
25302
|
status: upd["status"],
|
|
@@ -25327,7 +25318,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25327
25318
|
}
|
|
25328
25319
|
case "agent_message_chunk":
|
|
25329
25320
|
case "agent_thought_chunk": {
|
|
25330
|
-
const content =
|
|
25321
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
25331
25322
|
const contentType = content?.["type"];
|
|
25332
25323
|
const streamKind = kind === "agent_thought_chunk" ? "reasoning_text" : "assistant_text";
|
|
25333
25324
|
if (contentType === "text") {
|
|
@@ -25367,7 +25358,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
25367
25358
|
}
|
|
25368
25359
|
case "compaction_summary_chunk": {
|
|
25369
25360
|
const compactionId = readAcpText(upd, "compactionId");
|
|
25370
|
-
const content =
|
|
25361
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
25371
25362
|
const text = content?.["type"] === "text" ? content["text"] : void 0;
|
|
25372
25363
|
if (compactionId === void 0 || typeof text !== "string" || text.length === 0) break;
|
|
25373
25364
|
events.push({ _tag: "CompactionSummaryChunk", compactionId, text });
|
|
@@ -25399,7 +25390,7 @@ function normalizeModelId(value) {
|
|
|
25399
25390
|
return value?.trim() || void 0;
|
|
25400
25391
|
}
|
|
25401
25392
|
function modelSelectionStateFromSetup(setup) {
|
|
25402
|
-
const sessionModels =
|
|
25393
|
+
const sessionModels = isRecord3(setup.models) ? setup.models : void 0;
|
|
25403
25394
|
const modelConfigId = extractModelConfigId(setup);
|
|
25404
25395
|
const strategy = sessionModels === void 0 && modelConfigId !== void 0 ? "config-option" : "session/set_model";
|
|
25405
25396
|
const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
|
|
@@ -26644,7 +26635,7 @@ function createAcpExecutor(options) {
|
|
|
26644
26635
|
pendingUserInputs.delete(requestId);
|
|
26645
26636
|
pending.resolve({
|
|
26646
26637
|
kind: "answered",
|
|
26647
|
-
answers:
|
|
26638
|
+
answers: isRecord3(answers) ? answers : {}
|
|
26648
26639
|
});
|
|
26649
26640
|
};
|
|
26650
26641
|
const dispose = async () => {
|
|
@@ -26777,9 +26768,9 @@ async function openAcpProbeHandshake(input2) {
|
|
|
26777
26768
|
}
|
|
26778
26769
|
}
|
|
26779
26770
|
function acpAgentVersion(initializeResult) {
|
|
26780
|
-
if (!
|
|
26771
|
+
if (!isRecord3(initializeResult)) return null;
|
|
26781
26772
|
const agentInfo = initializeResult["agentInfo"];
|
|
26782
|
-
return
|
|
26773
|
+
return isRecord3(agentInfo) ? asTrimmedString(agentInfo["version"]) ?? null : null;
|
|
26783
26774
|
}
|
|
26784
26775
|
var MAX_VERSION_OUTPUT_BYTES = 64 * 1024;
|
|
26785
26776
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-acp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2944",
|
|
4
4
|
"description": "Generic ACP executor: user-supplied CLI 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-acp-executor": "0.2.2944",
|
|
24
25
|
"ycodium-executor-testing": "0.0.0",
|
|
25
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
26
|
-
"ycodium-acp-executor": "0.2.2938"
|
|
26
|
+
"@ycodium-ai/plugin-api": "0.2.2944"
|
|
27
27
|
},
|
|
28
28
|
"ycodium": {
|
|
29
29
|
"plugin": "./dist/index.js",
|