@ycodium-ai/agent-dsh 0.2.2936 → 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 +255 -262
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -7427,7 +7427,9 @@ var DSH_CARD = {
|
|
|
7427
7427
|
//
|
|
7428
7428
|
// 改这一位要连着 `packages/contracts` 那张表一起改(`executorRegistry.test.ts`
|
|
7429
7429
|
// 的防漂移闸把两边钉成同值)。
|
|
7430
|
-
runtimeModeSwitch: "in-session"
|
|
7430
|
+
runtimeModeSwitch: "in-session",
|
|
7431
|
+
// 打断后 CLI 在同一秒停掉工具并报失败。
|
|
7432
|
+
confirmsToolTermination: true
|
|
7431
7433
|
},
|
|
7432
7434
|
// 凭据由 CLI 自己保管在它 home 里,宿主不读 token。
|
|
7433
7435
|
credentialSources: [],
|
|
@@ -31644,6 +31646,230 @@ var UnboundedEventStream = class {
|
|
|
31644
31646
|
}
|
|
31645
31647
|
};
|
|
31646
31648
|
|
|
31649
|
+
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
31650
|
+
function isRecord3(value) {
|
|
31651
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31652
|
+
}
|
|
31653
|
+
function asTrimmedString(value) {
|
|
31654
|
+
if (typeof value !== "string") {
|
|
31655
|
+
return void 0;
|
|
31656
|
+
}
|
|
31657
|
+
const trimmed = value.trim();
|
|
31658
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
31659
|
+
}
|
|
31660
|
+
|
|
31661
|
+
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
31662
|
+
function normalizeCommandValue(value) {
|
|
31663
|
+
const direct = asTrimmedString(value);
|
|
31664
|
+
if (direct) {
|
|
31665
|
+
return direct;
|
|
31666
|
+
}
|
|
31667
|
+
if (!Array.isArray(value)) {
|
|
31668
|
+
return void 0;
|
|
31669
|
+
}
|
|
31670
|
+
const parts = [];
|
|
31671
|
+
for (const entry of value) {
|
|
31672
|
+
const part = asTrimmedString(entry);
|
|
31673
|
+
if (part !== void 0) {
|
|
31674
|
+
parts.push(part);
|
|
31675
|
+
}
|
|
31676
|
+
}
|
|
31677
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
31678
|
+
}
|
|
31679
|
+
function stripTrailingExitCode(value) {
|
|
31680
|
+
const trimmed = value?.trim();
|
|
31681
|
+
if (!trimmed) {
|
|
31682
|
+
return void 0;
|
|
31683
|
+
}
|
|
31684
|
+
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
31685
|
+
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
31686
|
+
return output2.length > 0 ? output2 : void 0;
|
|
31687
|
+
}
|
|
31688
|
+
function extractCommandFromTitle(title) {
|
|
31689
|
+
if (!title) {
|
|
31690
|
+
return void 0;
|
|
31691
|
+
}
|
|
31692
|
+
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
31693
|
+
return backtickMatch?.[1]?.trim() || void 0;
|
|
31694
|
+
}
|
|
31695
|
+
function extractToolCommand(data, title) {
|
|
31696
|
+
const item = isRecord3(data?.["item"]) ? data["item"] : void 0;
|
|
31697
|
+
const itemInput = item && isRecord3(item["input"]) ? item["input"] : void 0;
|
|
31698
|
+
const itemResult = item && isRecord3(item["result"]) ? item["result"] : void 0;
|
|
31699
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
31700
|
+
const dataInput = isRecord3(data?.["input"]) ? data["input"] : void 0;
|
|
31701
|
+
const candidates = [
|
|
31702
|
+
normalizeCommandValue(item?.["command"]),
|
|
31703
|
+
normalizeCommandValue(itemInput?.["command"]),
|
|
31704
|
+
normalizeCommandValue(itemResult?.["command"]),
|
|
31705
|
+
normalizeCommandValue(data?.["command"]),
|
|
31706
|
+
normalizeCommandValue(dataInput?.["command"]),
|
|
31707
|
+
normalizeCommandValue(rawInput?.["command"])
|
|
31708
|
+
];
|
|
31709
|
+
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
31710
|
+
if (direct) {
|
|
31711
|
+
return direct;
|
|
31712
|
+
}
|
|
31713
|
+
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
31714
|
+
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
31715
|
+
if (executable && args) {
|
|
31716
|
+
return `${executable} ${args}`;
|
|
31717
|
+
}
|
|
31718
|
+
if (executable) {
|
|
31719
|
+
return executable;
|
|
31720
|
+
}
|
|
31721
|
+
return extractCommandFromTitle(title);
|
|
31722
|
+
}
|
|
31723
|
+
function maybePathLike(value) {
|
|
31724
|
+
if (!value) {
|
|
31725
|
+
return void 0;
|
|
31726
|
+
}
|
|
31727
|
+
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
31728
|
+
return value;
|
|
31729
|
+
}
|
|
31730
|
+
return void 0;
|
|
31731
|
+
}
|
|
31732
|
+
function collectPaths(value, paths, seen, depth) {
|
|
31733
|
+
if (depth > 4 || paths.length >= 8) {
|
|
31734
|
+
return;
|
|
31735
|
+
}
|
|
31736
|
+
if (Array.isArray(value)) {
|
|
31737
|
+
for (const entry of value) {
|
|
31738
|
+
collectPaths(entry, paths, seen, depth + 1);
|
|
31739
|
+
if (paths.length >= 8) {
|
|
31740
|
+
return;
|
|
31741
|
+
}
|
|
31742
|
+
}
|
|
31743
|
+
return;
|
|
31744
|
+
}
|
|
31745
|
+
if (!isRecord3(value)) {
|
|
31746
|
+
return;
|
|
31747
|
+
}
|
|
31748
|
+
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
31749
|
+
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
31750
|
+
if (!candidate || seen.has(candidate)) {
|
|
31751
|
+
continue;
|
|
31752
|
+
}
|
|
31753
|
+
seen.add(candidate);
|
|
31754
|
+
paths.push(candidate);
|
|
31755
|
+
if (paths.length >= 8) {
|
|
31756
|
+
return;
|
|
31757
|
+
}
|
|
31758
|
+
}
|
|
31759
|
+
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
31760
|
+
if (!(nestedKey in value)) {
|
|
31761
|
+
continue;
|
|
31762
|
+
}
|
|
31763
|
+
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
31764
|
+
if (paths.length >= 8) {
|
|
31765
|
+
return;
|
|
31766
|
+
}
|
|
31767
|
+
}
|
|
31768
|
+
}
|
|
31769
|
+
function extractPrimaryPath(data) {
|
|
31770
|
+
const paths = [];
|
|
31771
|
+
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
31772
|
+
return paths[0];
|
|
31773
|
+
}
|
|
31774
|
+
function normalizeEquivalentValue(value) {
|
|
31775
|
+
const trimmed = asTrimmedString(value);
|
|
31776
|
+
if (!trimmed) {
|
|
31777
|
+
return void 0;
|
|
31778
|
+
}
|
|
31779
|
+
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
31780
|
+
}
|
|
31781
|
+
function isEquivalent(left, right) {
|
|
31782
|
+
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
31783
|
+
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
31784
|
+
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
31785
|
+
}
|
|
31786
|
+
function classifyToolAction(input2) {
|
|
31787
|
+
const itemType = input2.itemType ?? void 0;
|
|
31788
|
+
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
31789
|
+
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
31790
|
+
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
31791
|
+
return "command";
|
|
31792
|
+
}
|
|
31793
|
+
if (kind === "read" || title === "read file") {
|
|
31794
|
+
return "read";
|
|
31795
|
+
}
|
|
31796
|
+
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
31797
|
+
return "file_change";
|
|
31798
|
+
}
|
|
31799
|
+
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
31800
|
+
return "search";
|
|
31801
|
+
}
|
|
31802
|
+
return "other";
|
|
31803
|
+
}
|
|
31804
|
+
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
31805
|
+
switch (kind) {
|
|
31806
|
+
case "execute":
|
|
31807
|
+
return "command_execution";
|
|
31808
|
+
case "edit":
|
|
31809
|
+
case "delete":
|
|
31810
|
+
case "move":
|
|
31811
|
+
return "file_change";
|
|
31812
|
+
case "search":
|
|
31813
|
+
case "fetch":
|
|
31814
|
+
return "web_search";
|
|
31815
|
+
default:
|
|
31816
|
+
return "dynamic_tool_call";
|
|
31817
|
+
}
|
|
31818
|
+
}
|
|
31819
|
+
function deriveToolActivityPresentation(input2) {
|
|
31820
|
+
const title = asTrimmedString(input2.title);
|
|
31821
|
+
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
31822
|
+
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
31823
|
+
const data = isRecord3(input2.data) ? input2.data : void 0;
|
|
31824
|
+
const command = extractToolCommand(data, title);
|
|
31825
|
+
const primaryPath = extractPrimaryPath(data);
|
|
31826
|
+
const action = classifyToolAction({
|
|
31827
|
+
itemType: input2.itemType,
|
|
31828
|
+
title,
|
|
31829
|
+
data
|
|
31830
|
+
});
|
|
31831
|
+
if (action === "command") {
|
|
31832
|
+
return {
|
|
31833
|
+
summary: "Ran command",
|
|
31834
|
+
...command ? { detail: command } : {}
|
|
31835
|
+
};
|
|
31836
|
+
}
|
|
31837
|
+
if (action === "read") {
|
|
31838
|
+
if (primaryPath) {
|
|
31839
|
+
return {
|
|
31840
|
+
summary: "Read file",
|
|
31841
|
+
detail: primaryPath
|
|
31842
|
+
};
|
|
31843
|
+
}
|
|
31844
|
+
return {
|
|
31845
|
+
summary: "Read file"
|
|
31846
|
+
};
|
|
31847
|
+
}
|
|
31848
|
+
if (action === "file_change") {
|
|
31849
|
+
return {
|
|
31850
|
+
summary: "Changed files",
|
|
31851
|
+
...primaryPath ? { detail: primaryPath } : {}
|
|
31852
|
+
};
|
|
31853
|
+
}
|
|
31854
|
+
if (action === "search") {
|
|
31855
|
+
const rawInput = isRecord3(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
31856
|
+
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
31857
|
+
return {
|
|
31858
|
+
summary: "Searched files",
|
|
31859
|
+
...query ? { detail: query } : {}
|
|
31860
|
+
};
|
|
31861
|
+
}
|
|
31862
|
+
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
31863
|
+
return {
|
|
31864
|
+
summary: title ?? fallbackSummary,
|
|
31865
|
+
detail
|
|
31866
|
+
};
|
|
31867
|
+
}
|
|
31868
|
+
return {
|
|
31869
|
+
summary: title ?? fallbackSummary
|
|
31870
|
+
};
|
|
31871
|
+
}
|
|
31872
|
+
|
|
31647
31873
|
// ../../packages/ycodium-acp-executor/src/events.ts
|
|
31648
31874
|
function canonicalRequestTypeFromAcpKind(kind) {
|
|
31649
31875
|
switch (kind) {
|
|
@@ -31699,21 +31925,6 @@ function fileChangesFromAcpPermission(permissionRequest) {
|
|
|
31699
31925
|
}) : [];
|
|
31700
31926
|
return paths.length > 0 ? paths.map((path) => ({ path, omitted: "unavailable" })) : void 0;
|
|
31701
31927
|
}
|
|
31702
|
-
function canonicalItemTypeFromAcpToolKind(kind) {
|
|
31703
|
-
switch (kind) {
|
|
31704
|
-
case "execute":
|
|
31705
|
-
return "command_execution";
|
|
31706
|
-
case "edit":
|
|
31707
|
-
case "delete":
|
|
31708
|
-
case "move":
|
|
31709
|
-
return "file_change";
|
|
31710
|
-
case "search":
|
|
31711
|
-
case "fetch":
|
|
31712
|
-
return "web_search";
|
|
31713
|
-
default:
|
|
31714
|
-
return "dynamic_tool_call";
|
|
31715
|
-
}
|
|
31716
|
-
}
|
|
31717
31928
|
function runtimeItemStatusFromAcpToolStatus(status) {
|
|
31718
31929
|
switch (status) {
|
|
31719
31930
|
case "pending":
|
|
@@ -31785,6 +31996,7 @@ function makeAcpPlanUpdatedEvent(input2) {
|
|
|
31785
31996
|
}
|
|
31786
31997
|
function makeAcpToolCallEvent(input2) {
|
|
31787
31998
|
const runtimeStatus = runtimeItemStatusFromAcpToolStatus(input2.toolCall.status);
|
|
31999
|
+
const { data } = input2.toolCall;
|
|
31788
32000
|
return {
|
|
31789
32001
|
type: input2.toolCall.status === "completed" || input2.toolCall.status === "failed" ? "item.completed" : "item.updated",
|
|
31790
32002
|
...input2.stamp,
|
|
@@ -31797,7 +32009,7 @@ function makeAcpToolCallEvent(input2) {
|
|
|
31797
32009
|
...runtimeStatus ? { status: runtimeStatus } : {},
|
|
31798
32010
|
...input2.toolCall.title ? { title: input2.toolCall.title } : {},
|
|
31799
32011
|
...input2.toolCall.detail ? { detail: input2.toolCall.detail } : {},
|
|
31800
|
-
...Object.keys(
|
|
32012
|
+
...Object.keys(data).length > 0 ? { data } : {}
|
|
31801
32013
|
},
|
|
31802
32014
|
raw: {
|
|
31803
32015
|
source: "acp.jsonrpc",
|
|
@@ -31841,7 +32053,7 @@ function makeAcpContentDeltaEvent(input2) {
|
|
|
31841
32053
|
}
|
|
31842
32054
|
|
|
31843
32055
|
// ../../packages/ycodium-acp-executor/src/config-options.ts
|
|
31844
|
-
function
|
|
32056
|
+
function isRecord4(value) {
|
|
31845
32057
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31846
32058
|
}
|
|
31847
32059
|
function asString(value) {
|
|
@@ -31860,7 +32072,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
31860
32072
|
const out = [];
|
|
31861
32073
|
const seen = /* @__PURE__ */ new Set();
|
|
31862
32074
|
const push = (entry) => {
|
|
31863
|
-
if (!
|
|
32075
|
+
if (!isRecord4(entry)) return;
|
|
31864
32076
|
const value = asString(entry["value"]);
|
|
31865
32077
|
if (value === void 0 || seen.has(value)) return;
|
|
31866
32078
|
seen.add(value);
|
|
@@ -31875,7 +32087,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
31875
32087
|
});
|
|
31876
32088
|
};
|
|
31877
32089
|
for (const entry of rawOptions) {
|
|
31878
|
-
if (
|
|
32090
|
+
if (isRecord4(entry) && Array.isArray(entry["options"])) {
|
|
31879
32091
|
for (const nested of entry["options"]) push(nested);
|
|
31880
32092
|
continue;
|
|
31881
32093
|
}
|
|
@@ -31885,7 +32097,7 @@ function flattenChoices(rawOptions, currentValue) {
|
|
|
31885
32097
|
}
|
|
31886
32098
|
function findAcpEffortConfig(configOptions) {
|
|
31887
32099
|
if (!Array.isArray(configOptions)) return void 0;
|
|
31888
|
-
const candidates = configOptions.filter(
|
|
32100
|
+
const candidates = configOptions.filter(isRecord4).filter((option) => normalizedField(option, "type") === "select").filter(looksLikeEffortOption);
|
|
31889
32101
|
if (candidates.length === 0) return void 0;
|
|
31890
32102
|
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];
|
|
31891
32103
|
if (picked === void 0) return void 0;
|
|
@@ -31901,7 +32113,7 @@ function findAcpEffortConfig(configOptions) {
|
|
|
31901
32113
|
}
|
|
31902
32114
|
function acpModelChoicesFromConfigOptions(configOptions) {
|
|
31903
32115
|
if (!Array.isArray(configOptions)) return void 0;
|
|
31904
|
-
const records = configOptions.filter(
|
|
32116
|
+
const records = configOptions.filter(isRecord4);
|
|
31905
32117
|
const modelOption = records.find((option) => normalizedField(option, "category") === "model") ?? records.find(
|
|
31906
32118
|
(option) => normalizedField(option, "id") === "model" && normalizedField(option, "type") === "select"
|
|
31907
32119
|
);
|
|
@@ -31911,18 +32123,18 @@ function acpModelChoicesFromConfigOptions(configOptions) {
|
|
|
31911
32123
|
}
|
|
31912
32124
|
|
|
31913
32125
|
// ../../packages/ycodium-acp-executor/src/runtime-mode.ts
|
|
31914
|
-
function
|
|
32126
|
+
function isRecord5(value) {
|
|
31915
32127
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31916
32128
|
}
|
|
31917
32129
|
function asString2(value) {
|
|
31918
32130
|
return typeof value === "string" ? value : void 0;
|
|
31919
32131
|
}
|
|
31920
32132
|
function acpModeConfigId(setup) {
|
|
31921
|
-
if (!
|
|
32133
|
+
if (!isRecord5(setup)) return void 0;
|
|
31922
32134
|
const configOptions = setup["configOptions"];
|
|
31923
32135
|
if (!Array.isArray(configOptions)) return void 0;
|
|
31924
32136
|
for (const option of configOptions) {
|
|
31925
|
-
if (!
|
|
32137
|
+
if (!isRecord5(option)) continue;
|
|
31926
32138
|
if (asString2(option["category"])?.trim().toLowerCase() !== "mode") continue;
|
|
31927
32139
|
const id = asString2(option["id"])?.trim();
|
|
31928
32140
|
if (id) return id;
|
|
@@ -32035,215 +32247,6 @@ var Mutex = class {
|
|
|
32035
32247
|
}
|
|
32036
32248
|
};
|
|
32037
32249
|
|
|
32038
|
-
// ../../packages/ycodium-acp-executor/src/util.ts
|
|
32039
|
-
function isRecord5(value) {
|
|
32040
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32041
|
-
}
|
|
32042
|
-
function asTrimmedString(value) {
|
|
32043
|
-
if (typeof value !== "string") {
|
|
32044
|
-
return void 0;
|
|
32045
|
-
}
|
|
32046
|
-
const trimmed = value.trim();
|
|
32047
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
32048
|
-
}
|
|
32049
|
-
|
|
32050
|
-
// ../../packages/ycodium-acp-executor/src/tool-presentation.ts
|
|
32051
|
-
function normalizeCommandValue(value) {
|
|
32052
|
-
const direct = asTrimmedString(value);
|
|
32053
|
-
if (direct) {
|
|
32054
|
-
return direct;
|
|
32055
|
-
}
|
|
32056
|
-
if (!Array.isArray(value)) {
|
|
32057
|
-
return void 0;
|
|
32058
|
-
}
|
|
32059
|
-
const parts = [];
|
|
32060
|
-
for (const entry of value) {
|
|
32061
|
-
const part = asTrimmedString(entry);
|
|
32062
|
-
if (part !== void 0) {
|
|
32063
|
-
parts.push(part);
|
|
32064
|
-
}
|
|
32065
|
-
}
|
|
32066
|
-
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
32067
|
-
}
|
|
32068
|
-
function stripTrailingExitCode(value) {
|
|
32069
|
-
const trimmed = value?.trim();
|
|
32070
|
-
if (!trimmed) {
|
|
32071
|
-
return void 0;
|
|
32072
|
-
}
|
|
32073
|
-
const match = /^(?<output>[\s\S]*?)(?:\s*<exited with exit code \d+>)\s*$/iu.exec(trimmed);
|
|
32074
|
-
const output2 = match?.groups?.output?.trim() ?? trimmed;
|
|
32075
|
-
return output2.length > 0 ? output2 : void 0;
|
|
32076
|
-
}
|
|
32077
|
-
function extractCommandFromTitle(title) {
|
|
32078
|
-
if (!title) {
|
|
32079
|
-
return void 0;
|
|
32080
|
-
}
|
|
32081
|
-
const backtickMatch = /`([^`]+)`/u.exec(title);
|
|
32082
|
-
return backtickMatch?.[1]?.trim() || void 0;
|
|
32083
|
-
}
|
|
32084
|
-
function extractToolCommand(data, title) {
|
|
32085
|
-
const item = isRecord5(data?.["item"]) ? data["item"] : void 0;
|
|
32086
|
-
const itemInput = item && isRecord5(item["input"]) ? item["input"] : void 0;
|
|
32087
|
-
const itemResult = item && isRecord5(item["result"]) ? item["result"] : void 0;
|
|
32088
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
32089
|
-
const dataInput = isRecord5(data?.["input"]) ? data["input"] : void 0;
|
|
32090
|
-
const candidates = [
|
|
32091
|
-
normalizeCommandValue(item?.["command"]),
|
|
32092
|
-
normalizeCommandValue(itemInput?.["command"]),
|
|
32093
|
-
normalizeCommandValue(itemResult?.["command"]),
|
|
32094
|
-
normalizeCommandValue(data?.["command"]),
|
|
32095
|
-
normalizeCommandValue(dataInput?.["command"]),
|
|
32096
|
-
normalizeCommandValue(rawInput?.["command"])
|
|
32097
|
-
];
|
|
32098
|
-
const direct = candidates.find((candidate) => candidate !== void 0);
|
|
32099
|
-
if (direct) {
|
|
32100
|
-
return direct;
|
|
32101
|
-
}
|
|
32102
|
-
const executable = asTrimmedString(rawInput?.["executable"]);
|
|
32103
|
-
const args = normalizeCommandValue(rawInput?.["args"]);
|
|
32104
|
-
if (executable && args) {
|
|
32105
|
-
return `${executable} ${args}`;
|
|
32106
|
-
}
|
|
32107
|
-
if (executable) {
|
|
32108
|
-
return executable;
|
|
32109
|
-
}
|
|
32110
|
-
return extractCommandFromTitle(title);
|
|
32111
|
-
}
|
|
32112
|
-
function maybePathLike(value) {
|
|
32113
|
-
if (!value) {
|
|
32114
|
-
return void 0;
|
|
32115
|
-
}
|
|
32116
|
-
if (value.includes("/") || value.includes("\\") || value.startsWith(".") || /\.(?:[a-z0-9]{1,12})$/iu.test(value)) {
|
|
32117
|
-
return value;
|
|
32118
|
-
}
|
|
32119
|
-
return void 0;
|
|
32120
|
-
}
|
|
32121
|
-
function collectPaths(value, paths, seen, depth) {
|
|
32122
|
-
if (depth > 4 || paths.length >= 8) {
|
|
32123
|
-
return;
|
|
32124
|
-
}
|
|
32125
|
-
if (Array.isArray(value)) {
|
|
32126
|
-
for (const entry of value) {
|
|
32127
|
-
collectPaths(entry, paths, seen, depth + 1);
|
|
32128
|
-
if (paths.length >= 8) {
|
|
32129
|
-
return;
|
|
32130
|
-
}
|
|
32131
|
-
}
|
|
32132
|
-
return;
|
|
32133
|
-
}
|
|
32134
|
-
if (!isRecord5(value)) {
|
|
32135
|
-
return;
|
|
32136
|
-
}
|
|
32137
|
-
for (const key of ["path", "filePath", "relativePath", "filename", "newPath", "oldPath"]) {
|
|
32138
|
-
const candidate = maybePathLike(asTrimmedString(value[key]));
|
|
32139
|
-
if (!candidate || seen.has(candidate)) {
|
|
32140
|
-
continue;
|
|
32141
|
-
}
|
|
32142
|
-
seen.add(candidate);
|
|
32143
|
-
paths.push(candidate);
|
|
32144
|
-
if (paths.length >= 8) {
|
|
32145
|
-
return;
|
|
32146
|
-
}
|
|
32147
|
-
}
|
|
32148
|
-
for (const nestedKey of ["locations", "item", "input", "result", "rawInput", "data", "changes"]) {
|
|
32149
|
-
if (!(nestedKey in value)) {
|
|
32150
|
-
continue;
|
|
32151
|
-
}
|
|
32152
|
-
collectPaths(value[nestedKey], paths, seen, depth + 1);
|
|
32153
|
-
if (paths.length >= 8) {
|
|
32154
|
-
return;
|
|
32155
|
-
}
|
|
32156
|
-
}
|
|
32157
|
-
}
|
|
32158
|
-
function extractPrimaryPath(data) {
|
|
32159
|
-
const paths = [];
|
|
32160
|
-
collectPaths(data, paths, /* @__PURE__ */ new Set(), 0);
|
|
32161
|
-
return paths[0];
|
|
32162
|
-
}
|
|
32163
|
-
function normalizeEquivalentValue(value) {
|
|
32164
|
-
const trimmed = asTrimmedString(value);
|
|
32165
|
-
if (!trimmed) {
|
|
32166
|
-
return void 0;
|
|
32167
|
-
}
|
|
32168
|
-
return trimmed.replace(/\s+/gu, " ").replace(/\s+(?:complete|completed|started)\s*$/iu, "").trim();
|
|
32169
|
-
}
|
|
32170
|
-
function isEquivalent(left, right) {
|
|
32171
|
-
const normalizedLeft = normalizeEquivalentValue(left)?.toLowerCase();
|
|
32172
|
-
const normalizedRight = normalizeEquivalentValue(right)?.toLowerCase();
|
|
32173
|
-
return normalizedLeft !== void 0 && normalizedLeft === normalizedRight;
|
|
32174
|
-
}
|
|
32175
|
-
function classifyToolAction(input2) {
|
|
32176
|
-
const itemType = input2.itemType ?? void 0;
|
|
32177
|
-
const kind = asTrimmedString(input2.data?.["kind"])?.toLowerCase();
|
|
32178
|
-
const title = asTrimmedString(input2.title)?.toLowerCase();
|
|
32179
|
-
if (itemType === "command_execution" || kind === "execute" || title === "terminal") {
|
|
32180
|
-
return "command";
|
|
32181
|
-
}
|
|
32182
|
-
if (kind === "read" || title === "read file") {
|
|
32183
|
-
return "read";
|
|
32184
|
-
}
|
|
32185
|
-
if (itemType === "file_change" || kind === "edit" || kind === "move" || kind === "delete" || kind === "write") {
|
|
32186
|
-
return "file_change";
|
|
32187
|
-
}
|
|
32188
|
-
if (itemType === "web_search" || kind === "search" || title === "find" || title === "grep") {
|
|
32189
|
-
return "search";
|
|
32190
|
-
}
|
|
32191
|
-
return "other";
|
|
32192
|
-
}
|
|
32193
|
-
function deriveToolActivityPresentation(input2) {
|
|
32194
|
-
const title = asTrimmedString(input2.title);
|
|
32195
|
-
const detail = stripTrailingExitCode(asTrimmedString(input2.detail));
|
|
32196
|
-
const fallbackSummary = asTrimmedString(input2.fallbackSummary) ?? "Tool";
|
|
32197
|
-
const data = isRecord5(input2.data) ? input2.data : void 0;
|
|
32198
|
-
const command = extractToolCommand(data, title);
|
|
32199
|
-
const primaryPath = extractPrimaryPath(data);
|
|
32200
|
-
const action = classifyToolAction({
|
|
32201
|
-
itemType: input2.itemType,
|
|
32202
|
-
title,
|
|
32203
|
-
data
|
|
32204
|
-
});
|
|
32205
|
-
if (action === "command") {
|
|
32206
|
-
return {
|
|
32207
|
-
summary: "Ran command",
|
|
32208
|
-
...command ? { detail: command } : {}
|
|
32209
|
-
};
|
|
32210
|
-
}
|
|
32211
|
-
if (action === "read") {
|
|
32212
|
-
if (primaryPath) {
|
|
32213
|
-
return {
|
|
32214
|
-
summary: "Read file",
|
|
32215
|
-
detail: primaryPath
|
|
32216
|
-
};
|
|
32217
|
-
}
|
|
32218
|
-
return {
|
|
32219
|
-
summary: "Read file"
|
|
32220
|
-
};
|
|
32221
|
-
}
|
|
32222
|
-
if (action === "file_change") {
|
|
32223
|
-
return {
|
|
32224
|
-
summary: "Changed files",
|
|
32225
|
-
...primaryPath ? { detail: primaryPath } : {}
|
|
32226
|
-
};
|
|
32227
|
-
}
|
|
32228
|
-
if (action === "search") {
|
|
32229
|
-
const rawInput = isRecord5(data?.["rawInput"]) ? data["rawInput"] : void 0;
|
|
32230
|
-
const query = asTrimmedString(rawInput?.["query"]) ?? asTrimmedString(rawInput?.["pattern"]) ?? asTrimmedString(rawInput?.["searchTerm"]);
|
|
32231
|
-
return {
|
|
32232
|
-
summary: "Searched files",
|
|
32233
|
-
...query ? { detail: query } : {}
|
|
32234
|
-
};
|
|
32235
|
-
}
|
|
32236
|
-
if (detail && !isEquivalent(detail, title) && !isEquivalent(detail, fallbackSummary)) {
|
|
32237
|
-
return {
|
|
32238
|
-
summary: title ?? fallbackSummary,
|
|
32239
|
-
detail
|
|
32240
|
-
};
|
|
32241
|
-
}
|
|
32242
|
-
return {
|
|
32243
|
-
summary: title ?? fallbackSummary
|
|
32244
|
-
};
|
|
32245
|
-
}
|
|
32246
|
-
|
|
32247
32250
|
// ../../packages/ycodium-acp-executor/src/runtime-model.ts
|
|
32248
32251
|
function extractModelConfigId(sessionResponse) {
|
|
32249
32252
|
const configOptions = sessionResponse.configOptions;
|
|
@@ -32274,11 +32277,11 @@ function collectSessionConfigOptionValues(configOption) {
|
|
|
32274
32277
|
);
|
|
32275
32278
|
}
|
|
32276
32279
|
function collectSessionModelIds(models) {
|
|
32277
|
-
if (!
|
|
32280
|
+
if (!isRecord3(models) || !Array.isArray(models["availableModels"])) {
|
|
32278
32281
|
return [];
|
|
32279
32282
|
}
|
|
32280
32283
|
return models["availableModels"].flatMap(
|
|
32281
|
-
(model) =>
|
|
32284
|
+
(model) => isRecord3(model) && typeof model["modelId"] === "string" ? [model["modelId"]] : []
|
|
32282
32285
|
);
|
|
32283
32286
|
}
|
|
32284
32287
|
function catalogModelLastSegment(value) {
|
|
@@ -32350,7 +32353,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
32350
32353
|
}
|
|
32351
32354
|
const commands = [];
|
|
32352
32355
|
for (const command of availableCommands) {
|
|
32353
|
-
if (!
|
|
32356
|
+
if (!isRecord3(command)) {
|
|
32354
32357
|
continue;
|
|
32355
32358
|
}
|
|
32356
32359
|
const name = typeof command["name"] === "string" ? command["name"].trim() : "";
|
|
@@ -32358,7 +32361,7 @@ function parseAvailableCommandsUpdate(params) {
|
|
|
32358
32361
|
continue;
|
|
32359
32362
|
}
|
|
32360
32363
|
const description = typeof command["description"] === "string" ? command["description"].trim() || void 0 : void 0;
|
|
32361
|
-
const input2 =
|
|
32364
|
+
const input2 = isRecord3(command["input"]) ? command["input"] : void 0;
|
|
32362
32365
|
const inputHint = typeof input2?.["hint"] === "string" ? input2["hint"].trim() || void 0 : void 0;
|
|
32363
32366
|
commands.push({
|
|
32364
32367
|
name,
|
|
@@ -32420,7 +32423,7 @@ function extractCommandFromTitle2(title) {
|
|
|
32420
32423
|
return match?.[1]?.trim() || void 0;
|
|
32421
32424
|
}
|
|
32422
32425
|
function extractToolCallCommand(rawInput, title) {
|
|
32423
|
-
if (
|
|
32426
|
+
if (isRecord3(rawInput)) {
|
|
32424
32427
|
const directCommand = normalizeCommandValue2(rawInput["command"]);
|
|
32425
32428
|
if (directCommand) {
|
|
32426
32429
|
return directCommand;
|
|
@@ -32447,7 +32450,7 @@ function boundToolCallOutputText(text) {
|
|
|
32447
32450
|
}
|
|
32448
32451
|
var RAW_OUTPUT_TEXT_FIELDS = ["content", "stdout", "stderr", "output"];
|
|
32449
32452
|
function boundToolCallRawOutput(rawOutput) {
|
|
32450
|
-
if (!
|
|
32453
|
+
if (!isRecord3(rawOutput)) {
|
|
32451
32454
|
return rawOutput;
|
|
32452
32455
|
}
|
|
32453
32456
|
let changed = false;
|
|
@@ -32505,21 +32508,6 @@ function extractTextContentFromToolCallContent(content) {
|
|
|
32505
32508
|
function normalizeToolKind(kind) {
|
|
32506
32509
|
return typeof kind === "string" && kind.trim().length > 0 ? kind.trim() : void 0;
|
|
32507
32510
|
}
|
|
32508
|
-
function canonicalItemTypeFromAcpToolKind2(kind) {
|
|
32509
|
-
switch (kind) {
|
|
32510
|
-
case "execute":
|
|
32511
|
-
return "command_execution";
|
|
32512
|
-
case "edit":
|
|
32513
|
-
case "delete":
|
|
32514
|
-
case "move":
|
|
32515
|
-
return "file_change";
|
|
32516
|
-
case "search":
|
|
32517
|
-
case "fetch":
|
|
32518
|
-
return "web_search";
|
|
32519
|
-
default:
|
|
32520
|
-
return "dynamic_tool_call";
|
|
32521
|
-
}
|
|
32522
|
-
}
|
|
32523
32511
|
function makeToolCallState(input2, options) {
|
|
32524
32512
|
const toolCallId = typeof input2.toolCallId === "string" ? input2.toolCallId.trim() : "";
|
|
32525
32513
|
if (!toolCallId) {
|
|
@@ -32535,6 +32523,10 @@ function makeToolCallState(input2, options) {
|
|
|
32535
32523
|
if (kind) {
|
|
32536
32524
|
data["kind"] = kind;
|
|
32537
32525
|
}
|
|
32526
|
+
const name = readAcpText(input2, "name");
|
|
32527
|
+
if (name) {
|
|
32528
|
+
data["name"] = name;
|
|
32529
|
+
}
|
|
32538
32530
|
if (command) {
|
|
32539
32531
|
data["command"] = command;
|
|
32540
32532
|
}
|
|
@@ -32553,7 +32545,7 @@ function makeToolCallState(input2, options) {
|
|
|
32553
32545
|
const fallbackDetail = command ?? normalizedTitle ?? textContent;
|
|
32554
32546
|
const hasPresentationSeed = title !== void 0 || kind !== void 0 || command !== void 0 || normalizedTitle !== void 0 || textContent !== void 0;
|
|
32555
32547
|
const presentation = hasPresentationSeed ? deriveToolActivityPresentation({
|
|
32556
|
-
itemType:
|
|
32548
|
+
itemType: canonicalItemTypeFromAcpToolKind(kind),
|
|
32557
32549
|
title,
|
|
32558
32550
|
detail: fallbackDetail,
|
|
32559
32551
|
data,
|
|
@@ -32659,7 +32651,7 @@ function readAcpText(source, key) {
|
|
|
32659
32651
|
}
|
|
32660
32652
|
function textFromContentBlocks(blocks) {
|
|
32661
32653
|
const parts = blocks.flatMap(
|
|
32662
|
-
(block) =>
|
|
32654
|
+
(block) => isRecord3(block) && block["type"] === "text" && typeof block["text"] === "string" ? [block["text"]] : []
|
|
32663
32655
|
);
|
|
32664
32656
|
const joined = parts.join("");
|
|
32665
32657
|
return joined.trim().length > 0 ? joined : void 0;
|
|
@@ -32684,7 +32676,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
32684
32676
|
const entries = Array.isArray(upd["entries"]) ? upd["entries"] : [];
|
|
32685
32677
|
const plan = entries.map((entry, index) => ({
|
|
32686
32678
|
step: readAcpText(entry, "content") ?? `Step ${index + 1}`,
|
|
32687
|
-
status: normalizePlanStepStatus(
|
|
32679
|
+
status: normalizePlanStepStatus(isRecord3(entry) ? entry["status"] : void 0)
|
|
32688
32680
|
}));
|
|
32689
32681
|
if (plan.length > 0) {
|
|
32690
32682
|
events.push({
|
|
@@ -32702,6 +32694,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
32702
32694
|
const toolCall = makeToolCallState(
|
|
32703
32695
|
{
|
|
32704
32696
|
toolCallId: upd["toolCallId"],
|
|
32697
|
+
name: upd["name"],
|
|
32705
32698
|
title: typeof upd["title"] === "string" ? upd["title"] : void 0,
|
|
32706
32699
|
kind: upd["kind"],
|
|
32707
32700
|
status: upd["status"],
|
|
@@ -32723,7 +32716,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
32723
32716
|
}
|
|
32724
32717
|
case "agent_message_chunk":
|
|
32725
32718
|
case "agent_thought_chunk": {
|
|
32726
|
-
const content =
|
|
32719
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
32727
32720
|
const contentType = content?.["type"];
|
|
32728
32721
|
const streamKind = kind === "agent_thought_chunk" ? "reasoning_text" : "assistant_text";
|
|
32729
32722
|
if (contentType === "text") {
|
|
@@ -32763,7 +32756,7 @@ function parseSessionUpdateEvent(params) {
|
|
|
32763
32756
|
}
|
|
32764
32757
|
case "compaction_summary_chunk": {
|
|
32765
32758
|
const compactionId = readAcpText(upd, "compactionId");
|
|
32766
|
-
const content =
|
|
32759
|
+
const content = isRecord3(upd["content"]) ? upd["content"] : void 0;
|
|
32767
32760
|
const text = content?.["type"] === "text" ? content["text"] : void 0;
|
|
32768
32761
|
if (compactionId === void 0 || typeof text !== "string" || text.length === 0) break;
|
|
32769
32762
|
events.push({ _tag: "CompactionSummaryChunk", compactionId, text });
|
|
@@ -32795,7 +32788,7 @@ function normalizeModelId(value) {
|
|
|
32795
32788
|
return value?.trim() || void 0;
|
|
32796
32789
|
}
|
|
32797
32790
|
function modelSelectionStateFromSetup(setup) {
|
|
32798
|
-
const sessionModels =
|
|
32791
|
+
const sessionModels = isRecord3(setup.models) ? setup.models : void 0;
|
|
32799
32792
|
const modelConfigId = extractModelConfigId(setup);
|
|
32800
32793
|
const strategy = sessionModels === void 0 && modelConfigId !== void 0 ? "config-option" : "session/set_model";
|
|
32801
32794
|
const modelConfigOption = modelConfigId === void 0 ? void 0 : findSessionConfigOption(setup.configOptions, modelConfigId);
|
|
@@ -34040,7 +34033,7 @@ function createAcpExecutor(options) {
|
|
|
34040
34033
|
pendingUserInputs.delete(requestId);
|
|
34041
34034
|
pending.resolve({
|
|
34042
34035
|
kind: "answered",
|
|
34043
|
-
answers:
|
|
34036
|
+
answers: isRecord3(answers) ? answers : {}
|
|
34044
34037
|
});
|
|
34045
34038
|
};
|
|
34046
34039
|
const dispose = async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-dsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2942",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
24
|
"yaml": "^2.9.0",
|
|
25
|
-
"ycodium-
|
|
26
|
-
"ycodium-acp-executor": "0.2.
|
|
27
|
-
"
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.2942",
|
|
26
|
+
"ycodium-acp-executor": "0.2.2942",
|
|
27
|
+
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|
|
30
30
|
"plugin": "./dist/index.js",
|