@openma/deepseek-harness-acp 0.4.2 → 0.4.3
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/bridge.js +80 -12
- package/dist/index.js +80 -12
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -954,6 +954,7 @@ async function apply(ctx, config = {}) {
|
|
|
954
954
|
delete record.selection;
|
|
955
955
|
ensureSelection(record);
|
|
956
956
|
setApprovalPolicy(record, record.approvals);
|
|
957
|
+
publishCommands(acpSessionId, record);
|
|
957
958
|
};
|
|
958
959
|
const setApprovalPolicy = (record, policy) => {
|
|
959
960
|
try {
|
|
@@ -1085,18 +1086,64 @@ async function apply(ctx, config = {}) {
|
|
|
1085
1086
|
}
|
|
1086
1087
|
return result;
|
|
1087
1088
|
};
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1089
|
+
const BUILTIN_COMMANDS = [
|
|
1090
|
+
{ name: "status", description: "Show adapter, model, mode, and token status" },
|
|
1091
|
+
{
|
|
1092
|
+
name: "login",
|
|
1093
|
+
description: "Save a DeepSeek API key into the harness credential store (~/.dsh/.credentials.yaml)",
|
|
1094
|
+
input: { hint: "<api-key>" }
|
|
1095
|
+
},
|
|
1096
|
+
{ name: "logout", description: "Remove the API key stored in the harness credential store" }
|
|
1097
|
+
];
|
|
1098
|
+
const availableCommandsFor = async (record) => {
|
|
1099
|
+
const list = [...BUILTIN_COMMANDS];
|
|
1100
|
+
const seen = new Set(list.map((command) => command.name));
|
|
1101
|
+
const commandsSvc = ctx.get("commands");
|
|
1102
|
+
if (commandsSvc !== void 0) {
|
|
1103
|
+
try {
|
|
1104
|
+
for (const descriptor of commandsSvc.list(record.agent)) {
|
|
1105
|
+
if (seen.has(descriptor.name)) continue;
|
|
1106
|
+
seen.add(descriptor.name);
|
|
1107
|
+
list.push({
|
|
1108
|
+
name: descriptor.name,
|
|
1109
|
+
description: descriptor.description,
|
|
1110
|
+
...descriptor.input !== void 0 ? { input: { hint: descriptor.input.hint } } : {}
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
} catch (error) {
|
|
1114
|
+
logWarn(`command listing failed: ${String(error)}`);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
const skillsSvc = ctx.get("skills");
|
|
1118
|
+
if (skillsSvc !== void 0) {
|
|
1119
|
+
try {
|
|
1120
|
+
const skills = await skillsSvc.list({
|
|
1121
|
+
...record.agent.session.header.cwd !== void 0 ? { cwd: record.agent.session.header.cwd } : {},
|
|
1122
|
+
scope: record.agent
|
|
1123
|
+
});
|
|
1124
|
+
for (const skill of skills) {
|
|
1125
|
+
if (skill.invocation.userInvocable !== true) continue;
|
|
1126
|
+
if (seen.has(skill.name)) continue;
|
|
1127
|
+
seen.add(skill.name);
|
|
1128
|
+
list.push({
|
|
1129
|
+
name: skill.name,
|
|
1130
|
+
description: skill.description,
|
|
1131
|
+
input: { hint: "instructions for the skill" }
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
} catch (error) {
|
|
1135
|
+
logDebug(`skill listing failed: ${String(error)}`);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
return list;
|
|
1139
|
+
};
|
|
1140
|
+
const publishCommands = (sessionId, record) => {
|
|
1141
|
+
const target = record ?? sessions.get(sessionId);
|
|
1142
|
+
if (target === void 0) return;
|
|
1143
|
+
void availableCommandsFor(target).then((availableCommands) => {
|
|
1144
|
+
notify(sessionId, { sessionUpdate: "available_commands_update", availableCommands });
|
|
1145
|
+
}).catch((error) => {
|
|
1146
|
+
logWarn(`publishing commands failed: ${String(error)}`);
|
|
1100
1147
|
});
|
|
1101
1148
|
};
|
|
1102
1149
|
const credentialStore = () => {
|
|
@@ -1444,6 +1491,27 @@ async function apply(ctx, config = {}) {
|
|
|
1444
1491
|
return respond(await loginText(trimmed.slice(commandMatch[0].length)));
|
|
1445
1492
|
}
|
|
1446
1493
|
if (commandMatch?.[1] === "logout") return respond(await logoutText());
|
|
1494
|
+
if (commandMatch !== null && commandMatch[1] !== void 0) {
|
|
1495
|
+
const commandsSvc = ctx.get("commands");
|
|
1496
|
+
if (commandsSvc !== void 0) {
|
|
1497
|
+
let execution;
|
|
1498
|
+
try {
|
|
1499
|
+
execution = await commandsSvc.execute(
|
|
1500
|
+
record.agent,
|
|
1501
|
+
trimmed,
|
|
1502
|
+
new AbortController().signal
|
|
1503
|
+
);
|
|
1504
|
+
} catch (error) {
|
|
1505
|
+
return respond(`\u26A0 /${commandMatch[1]} failed: ${errorChain2(error)}`);
|
|
1506
|
+
}
|
|
1507
|
+
if (execution !== void 0) {
|
|
1508
|
+
const { result } = execution;
|
|
1509
|
+
const text = result.text ?? (result.kind === "success" ? `/${commandMatch[1]} \u2713` : `/${commandMatch[1]} failed`);
|
|
1510
|
+
publishCommands(params.sessionId, record);
|
|
1511
|
+
return respond(result.kind === "error" ? `\u26A0 ${text}` : text);
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1447
1515
|
if (!await credentialPresent()) {
|
|
1448
1516
|
return respond(
|
|
1449
1517
|
[
|
package/dist/index.js
CHANGED
|
@@ -979,6 +979,7 @@ async function apply(ctx, config = {}) {
|
|
|
979
979
|
delete record.selection;
|
|
980
980
|
ensureSelection(record);
|
|
981
981
|
setApprovalPolicy(record, record.approvals);
|
|
982
|
+
publishCommands(acpSessionId, record);
|
|
982
983
|
};
|
|
983
984
|
const setApprovalPolicy = (record, policy) => {
|
|
984
985
|
try {
|
|
@@ -1110,18 +1111,64 @@ async function apply(ctx, config = {}) {
|
|
|
1110
1111
|
}
|
|
1111
1112
|
return result;
|
|
1112
1113
|
};
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1114
|
+
const BUILTIN_COMMANDS = [
|
|
1115
|
+
{ name: "status", description: "Show adapter, model, mode, and token status" },
|
|
1116
|
+
{
|
|
1117
|
+
name: "login",
|
|
1118
|
+
description: "Save a DeepSeek API key into the harness credential store (~/.dsh/.credentials.yaml)",
|
|
1119
|
+
input: { hint: "<api-key>" }
|
|
1120
|
+
},
|
|
1121
|
+
{ name: "logout", description: "Remove the API key stored in the harness credential store" }
|
|
1122
|
+
];
|
|
1123
|
+
const availableCommandsFor = async (record) => {
|
|
1124
|
+
const list = [...BUILTIN_COMMANDS];
|
|
1125
|
+
const seen = new Set(list.map((command) => command.name));
|
|
1126
|
+
const commandsSvc = ctx.get("commands");
|
|
1127
|
+
if (commandsSvc !== void 0) {
|
|
1128
|
+
try {
|
|
1129
|
+
for (const descriptor of commandsSvc.list(record.agent)) {
|
|
1130
|
+
if (seen.has(descriptor.name)) continue;
|
|
1131
|
+
seen.add(descriptor.name);
|
|
1132
|
+
list.push({
|
|
1133
|
+
name: descriptor.name,
|
|
1134
|
+
description: descriptor.description,
|
|
1135
|
+
...descriptor.input !== void 0 ? { input: { hint: descriptor.input.hint } } : {}
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
logWarn(`command listing failed: ${String(error)}`);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
const skillsSvc = ctx.get("skills");
|
|
1143
|
+
if (skillsSvc !== void 0) {
|
|
1144
|
+
try {
|
|
1145
|
+
const skills = await skillsSvc.list({
|
|
1146
|
+
...record.agent.session.header.cwd !== void 0 ? { cwd: record.agent.session.header.cwd } : {},
|
|
1147
|
+
scope: record.agent
|
|
1148
|
+
});
|
|
1149
|
+
for (const skill of skills) {
|
|
1150
|
+
if (skill.invocation.userInvocable !== true) continue;
|
|
1151
|
+
if (seen.has(skill.name)) continue;
|
|
1152
|
+
seen.add(skill.name);
|
|
1153
|
+
list.push({
|
|
1154
|
+
name: skill.name,
|
|
1155
|
+
description: skill.description,
|
|
1156
|
+
input: { hint: "instructions for the skill" }
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
} catch (error) {
|
|
1160
|
+
logDebug(`skill listing failed: ${String(error)}`);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
return list;
|
|
1164
|
+
};
|
|
1165
|
+
const publishCommands = (sessionId, record) => {
|
|
1166
|
+
const target = record ?? sessions.get(sessionId);
|
|
1167
|
+
if (target === void 0) return;
|
|
1168
|
+
void availableCommandsFor(target).then((availableCommands) => {
|
|
1169
|
+
notify(sessionId, { sessionUpdate: "available_commands_update", availableCommands });
|
|
1170
|
+
}).catch((error) => {
|
|
1171
|
+
logWarn(`publishing commands failed: ${String(error)}`);
|
|
1125
1172
|
});
|
|
1126
1173
|
};
|
|
1127
1174
|
const credentialStore = () => {
|
|
@@ -1469,6 +1516,27 @@ async function apply(ctx, config = {}) {
|
|
|
1469
1516
|
return respond(await loginText(trimmed.slice(commandMatch[0].length)));
|
|
1470
1517
|
}
|
|
1471
1518
|
if (commandMatch?.[1] === "logout") return respond(await logoutText());
|
|
1519
|
+
if (commandMatch !== null && commandMatch[1] !== void 0) {
|
|
1520
|
+
const commandsSvc = ctx.get("commands");
|
|
1521
|
+
if (commandsSvc !== void 0) {
|
|
1522
|
+
let execution;
|
|
1523
|
+
try {
|
|
1524
|
+
execution = await commandsSvc.execute(
|
|
1525
|
+
record.agent,
|
|
1526
|
+
trimmed,
|
|
1527
|
+
new AbortController().signal
|
|
1528
|
+
);
|
|
1529
|
+
} catch (error) {
|
|
1530
|
+
return respond(`\u26A0 /${commandMatch[1]} failed: ${errorChain2(error)}`);
|
|
1531
|
+
}
|
|
1532
|
+
if (execution !== void 0) {
|
|
1533
|
+
const { result } = execution;
|
|
1534
|
+
const text = result.text ?? (result.kind === "success" ? `/${commandMatch[1]} \u2713` : `/${commandMatch[1]} failed`);
|
|
1535
|
+
publishCommands(params.sessionId, record);
|
|
1536
|
+
return respond(result.kind === "error" ? `\u26A0 ${text}` : text);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1472
1540
|
if (!await credentialPresent()) {
|
|
1473
1541
|
return respond(
|
|
1474
1542
|
[
|