@eddyskywalker/dsh-chatgpt-subscription 1.2.2 → 1.3.1
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/lib/client.js +27 -14
- package/lib/client.js.map +1 -1
- package/lib/codemode.js +138 -1
- package/lib/index.js +264 -96
- package/lib/reverse-board.js +121 -30
- package/lib/{tool-result-pruner-Cd3sTkjl.js → tool-result-pruner-CuKHwU2R.js} +15 -6
- package/lib/tool-result-pruner.js +1 -1
- package/lib/types/client/features/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/client/providers/claude/locales.d.ts +3 -3
- package/lib/types/client/providers/claude-api/locales.d.ts +2 -2
- package/lib/types/client/providers/kimi-code/locales.d.ts +3 -3
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/host/providers/chatgpt-api/model-catalog.d.ts.map +1 -1
- package/lib/types/host/providers/claude-api/model-catalog.d.ts.map +1 -1
- package/lib/types/host/providers/longcat/model-catalog.d.ts.map +1 -1
- package/lib/types/host/providers/qianwen-token-plan/adapter.d.ts.map +1 -1
- package/lib/types/host/providers/qoder/mapper.d.ts +7 -0
- package/lib/types/host/providers/qoder/mapper.d.ts.map +1 -1
- package/lib/types/host/providers/qoder/model-catalog.d.ts.map +1 -1
- package/lib/types/host/runtime/codemode/transport.d.ts.map +1 -1
- package/lib/types/host/runtime/compact-after-turn/index.d.ts +22 -2
- package/lib/types/host/runtime/compact-after-turn/index.d.ts.map +1 -1
- package/lib/types/host/runtime/compaction-gate.d.ts +21 -0
- package/lib/types/host/runtime/compaction-gate.d.ts.map +1 -1
- package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts +2 -1
- package/lib/types/host/runtime/deepseek-v41-flash/index.d.ts.map +1 -1
- package/lib/types/host/runtime/deepseek-v41-flash/match.d.ts +7 -5
- package/lib/types/host/runtime/deepseek-v41-flash/match.d.ts.map +1 -1
- package/lib/types/host/runtime/deepseek-v41-flash/reasoning-seed.d.ts.map +1 -1
- package/lib/types/host/runtime/presets/reverse-persona.d.ts.map +1 -1
- package/lib/types/host/runtime/reverse/frontier.d.ts +4 -0
- package/lib/types/host/runtime/reverse/frontier.d.ts.map +1 -1
- package/lib/types/host/runtime/reverse/store.d.ts +17 -2
- package/lib/types/host/runtime/reverse/store.d.ts.map +1 -1
- package/lib/types/host/runtime/reverse/tool.d.ts +1 -1
- package/lib/types/host/runtime/reverse/tool.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/presets/reverse/README.md +2 -2
- package/presets/reverse/agent.cordis.yml +11 -19
package/lib/codemode.js
CHANGED
|
@@ -1347,6 +1347,12 @@ function createTransportDefinition(host, rules) {
|
|
|
1347
1347
|
kind: "execute"
|
|
1348
1348
|
};
|
|
1349
1349
|
}
|
|
1350
|
+
const directFile = directFileCallOf(args);
|
|
1351
|
+
if (directFile !== void 0) return {
|
|
1352
|
+
card: "generic",
|
|
1353
|
+
title: directFile.description ?? "Run a file tool",
|
|
1354
|
+
kind: "execute"
|
|
1355
|
+
};
|
|
1350
1356
|
try {
|
|
1351
1357
|
const input = readArguments(args);
|
|
1352
1358
|
return {
|
|
@@ -1361,7 +1367,8 @@ function createTransportDefinition(host, rules) {
|
|
|
1361
1367
|
},
|
|
1362
1368
|
async execute(args, exec) {
|
|
1363
1369
|
const directShell = directShellCallOf(args);
|
|
1364
|
-
const
|
|
1370
|
+
const directFile = directShell === void 0 ? directFileCallOf(args) : void 0;
|
|
1371
|
+
const input = directShell !== void 0 ? readShellArguments(directShell) : directFile !== void 0 ? readFileArguments(directFile) : readArguments(args);
|
|
1365
1372
|
const runtime = host.runtime();
|
|
1366
1373
|
if (runtime === void 0) throw new CodemodeContextUnavailableError("codemode: no PTC runtime is mounted (ctx.ptcRuntime); the program transport is unavailable");
|
|
1367
1374
|
if (input.timeoutMs !== void 0 && runtime.timeout !== void 0 === false && isStrictTimeoutUnsupported(runtime)) throw new CodemodeArgsError("timeoutMs is not available for this PTC runtime");
|
|
@@ -1375,6 +1382,10 @@ function createTransportDefinition(host, rules) {
|
|
|
1375
1382
|
const shell = shellToolOf(catalog);
|
|
1376
1383
|
if (shell === void 0) throw missingCodeError(directShell.record, directShell.raw);
|
|
1377
1384
|
code = shellProgramFor(shell, directShell.record);
|
|
1385
|
+
} else if (directFile !== void 0) {
|
|
1386
|
+
const target = directFileToolOf(catalog, directFile);
|
|
1387
|
+
if (target === void 0) throw missingCodeError(directFile.record, directFile.raw);
|
|
1388
|
+
code = fileProgramFor(target.entry, target.args);
|
|
1378
1389
|
}
|
|
1379
1390
|
const runController = new AbortController();
|
|
1380
1391
|
const onOuterAbort = () => {
|
|
@@ -1932,6 +1943,33 @@ const SHELL_TOOL_NAMES = Object.freeze([
|
|
|
1932
1943
|
"bash",
|
|
1933
1944
|
"pwsh"
|
|
1934
1945
|
]);
|
|
1946
|
+
/** 模型把文件工具入参直接发给 `code_run` 时可能出现的键。 */
|
|
1947
|
+
const FILE_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
1948
|
+
"file_path",
|
|
1949
|
+
"path",
|
|
1950
|
+
"pattern",
|
|
1951
|
+
"include",
|
|
1952
|
+
"old_string",
|
|
1953
|
+
"new_string",
|
|
1954
|
+
"content",
|
|
1955
|
+
"input"
|
|
1956
|
+
]);
|
|
1957
|
+
/** 可接住直接文件工具调用的工具名;顺序即同场竞争时的优先级。 */
|
|
1958
|
+
const FILE_TOOL_NAMES = Object.freeze([
|
|
1959
|
+
"edit",
|
|
1960
|
+
"write",
|
|
1961
|
+
"read",
|
|
1962
|
+
"read_image",
|
|
1963
|
+
"apply_patch",
|
|
1964
|
+
"grep",
|
|
1965
|
+
"glob"
|
|
1966
|
+
]);
|
|
1967
|
+
/** `code_run` 自己用于卡片标题、不属于目标文件工具的键。 */
|
|
1968
|
+
const DIRECT_META_KEYS = /* @__PURE__ */ new Set([
|
|
1969
|
+
"description",
|
|
1970
|
+
"desc",
|
|
1971
|
+
"summary"
|
|
1972
|
+
]);
|
|
1935
1973
|
/** 模型把「先汇报再执行」写成一次调用时,简报落在 `progress_update` 的那两个键上。 */
|
|
1936
1974
|
const NARRATION_TITLE_KEY = "title";
|
|
1937
1975
|
/** 见 {@link NARRATION_TITLE_KEY}。 */
|
|
@@ -2106,6 +2144,105 @@ function readShellArguments(direct) {
|
|
|
2106
2144
|
description: direct.description ?? descriptionFromCode(command)
|
|
2107
2145
|
};
|
|
2108
2146
|
}
|
|
2147
|
+
/**
|
|
2148
|
+
* 认出「文件工具参数被直接发进 code_run」的形态。
|
|
2149
|
+
*
|
|
2150
|
+
* 与 Shell 兜底同一条审计线:模型经常把 `edit` / `write` / `read` 的参数直接发给
|
|
2151
|
+
* `code_run`,此时它已经表达了完整意图,只差一层 `tools.<name>(...)` 包装。这里只收
|
|
2152
|
+
* 可识别的文件参数字段;是否真的执行由清单里的目标工具与严格形状共同决定。
|
|
2153
|
+
*/
|
|
2154
|
+
function directFileCallOf(args) {
|
|
2155
|
+
let parsed;
|
|
2156
|
+
try {
|
|
2157
|
+
parsed = parseArguments(args);
|
|
2158
|
+
} catch {
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
const record = parsed.record;
|
|
2162
|
+
if (CODE_KEYS.some((key) => stringOf(record[key]) !== void 0)) return void 0;
|
|
2163
|
+
const fileTarget = stringOf(record["file_path"]) ?? stringOf(record["path"]);
|
|
2164
|
+
const content = stringOf(record["content"]);
|
|
2165
|
+
if (codeOf(record) !== void 0 && !(fileTarget !== void 0 && content !== void 0)) return void 0;
|
|
2166
|
+
if (stringOf(record["command"]) !== void 0) return void 0;
|
|
2167
|
+
if (!Object.keys(record).filter((key) => !DIRECT_META_KEYS.has(key)).some((key) => FILE_ARG_KEYS.has(key))) return void 0;
|
|
2168
|
+
const description = stringOf(record["description"])?.trim() ?? stringOf(record["desc"])?.trim() ?? stringOf(record["summary"])?.trim();
|
|
2169
|
+
return {
|
|
2170
|
+
record,
|
|
2171
|
+
...description === void 0 ? {} : { description },
|
|
2172
|
+
raw: parsed.raw,
|
|
2173
|
+
...parsed.narration === void 0 ? {} : { narration: parsed.narration }
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
/** 参数 schema 里不属于工具参数的元键(扁平 schema 形态下需要排除)。 */
|
|
2177
|
+
const SCHEMA_META_KEYS = /* @__PURE__ */ new Set([
|
|
2178
|
+
"type",
|
|
2179
|
+
"properties",
|
|
2180
|
+
"required",
|
|
2181
|
+
"additionalProperties",
|
|
2182
|
+
"$schema",
|
|
2183
|
+
"title",
|
|
2184
|
+
"description"
|
|
2185
|
+
]);
|
|
2186
|
+
/**
|
|
2187
|
+
* 对象参数 schema 的顶层属性与必填项。
|
|
2188
|
+
*
|
|
2189
|
+
* 兼容宿主的两种真实形态:标准 JSON Schema 的 `{ type, properties, required }`,
|
|
2190
|
+
* 以及 DSH 工具定义常用的「属性名 → 参数规格」扁平对象(必填写在属性上)。
|
|
2191
|
+
*/
|
|
2192
|
+
function objectShapeOf(parameters) {
|
|
2193
|
+
if (!isRecord(parameters)) return void 0;
|
|
2194
|
+
const nested = isRecord(parameters["properties"]) ? parameters["properties"] : void 0;
|
|
2195
|
+
const specs = nested ?? parameters;
|
|
2196
|
+
const properties = new Set(Object.keys(specs).filter((key) => !SCHEMA_META_KEYS.has(key)));
|
|
2197
|
+
const required = /* @__PURE__ */ new Set();
|
|
2198
|
+
if (nested !== void 0 && Array.isArray(parameters["required"])) {
|
|
2199
|
+
for (const key of parameters["required"]) if (typeof key === "string") required.add(key);
|
|
2200
|
+
}
|
|
2201
|
+
for (const [key, spec] of Object.entries(specs)) if (isRecord(spec) && spec["required"] === true) required.add(key);
|
|
2202
|
+
return {
|
|
2203
|
+
properties,
|
|
2204
|
+
required
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
/**
|
|
2208
|
+
* 找出唯一的文件工具承接者。
|
|
2209
|
+
*
|
|
2210
|
+
* 不允许「看起来像」就猜:参数里每个非标题键都必须出现在该工具的 properties 中,
|
|
2211
|
+
* 且该工具声明的 required 必须齐全;多个候选同时成立时按 {@link FILE_TOOL_NAMES}
|
|
2212
|
+
* 的优先级取第一个(例如只有 `file_path` 时优先 `read`,不是 `read_image`)。
|
|
2213
|
+
*/
|
|
2214
|
+
function directFileToolOf(catalog, direct) {
|
|
2215
|
+
for (const name of FILE_TOOL_NAMES) {
|
|
2216
|
+
const entry = catalog.find((candidate) => candidate.name === name);
|
|
2217
|
+
if (entry === void 0) continue;
|
|
2218
|
+
const shape = objectShapeOf(entry.parameters);
|
|
2219
|
+
if (shape === void 0) continue;
|
|
2220
|
+
const normalized = normalizeSubCallArgs(entry, direct.record);
|
|
2221
|
+
if (!isRecord(normalized)) continue;
|
|
2222
|
+
const keys = Object.keys(normalized).filter((key) => !DIRECT_META_KEYS.has(key));
|
|
2223
|
+
if (keys.length === 0) continue;
|
|
2224
|
+
if (!keys.every((key) => shape.properties.has(key))) continue;
|
|
2225
|
+
if ([...shape.required].some((key) => normalized[key] === void 0)) continue;
|
|
2226
|
+
return {
|
|
2227
|
+
entry,
|
|
2228
|
+
args: normalized
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
/** 把文件工具参数包成一条调用真实工具的程序。 */
|
|
2233
|
+
function fileProgramFor(entry, record) {
|
|
2234
|
+
const args = {};
|
|
2235
|
+
for (const key of Object.keys(record)) if (!DIRECT_META_KEYS.has(key)) args[key] = record[key];
|
|
2236
|
+
return "return await tools." + entry.name + "(" + JSON.stringify(args) + ")";
|
|
2237
|
+
}
|
|
2238
|
+
/** 把文件工具调用读成程序传输的标题(真正源码要等工具清单才能生成)。 */
|
|
2239
|
+
function readFileArguments(direct) {
|
|
2240
|
+
return {
|
|
2241
|
+
code: "",
|
|
2242
|
+
description: direct.description ?? "Run a file tool",
|
|
2243
|
+
...direct.narration === void 0 ? {} : { narration: direct.narration }
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2109
2246
|
/** 一段文本像不像程序源码(模型把源码直接发成字符串时判这个)。 */
|
|
2110
2247
|
function looksLikeProgram(text) {
|
|
2111
2248
|
return text.includes("\n") || /\b(await|return|const|let|function|import|console\.)\b/.test(text);
|