toc-ocra 0.3.19 → 0.3.21
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/README.md +1 -1
- package/dist/cli/cli.mjs +214 -71
- package/dist/service/agent.mjs +206 -63
- package/dist/src/acp/acp-dialects/acp-dialect.d.ts +5 -1
- package/dist/src/acp/acp-dialects/acp-dialect.js.map +1 -1
- package/dist/src/acp/acp-dialects/gemini-dialect.d.ts +1 -1
- package/dist/src/acp/acp-dialects/gemini-dialect.js +6 -2
- package/dist/src/acp/acp-dialects/gemini-dialect.js.map +1 -1
- package/dist/src/acp/acp-launch-specs.js +5 -2
- package/dist/src/acp/acp-launch-specs.js.map +1 -1
- package/dist/src/acp/chat-session.js +6 -1
- package/dist/src/acp/chat-session.js.map +1 -1
- package/dist/src/providers/acp/acp-driver.js +7 -2
- package/dist/src/providers/acp/acp-driver.js.map +1 -1
- package/dist/src/providers/claude-quota.d.ts +4 -0
- package/dist/src/providers/claude-quota.js +92 -0
- package/dist/src/providers/claude-quota.js.map +1 -0
- package/dist/src/providers/model-catalog.d.ts +9 -2
- package/dist/src/providers/model-catalog.js +85 -9
- package/dist/src/providers/model-catalog.js.map +1 -1
- package/dist/src/providers/registry.js +2 -1
- package/dist/src/providers/registry.js.map +1 -1
- package/package.json +1 -1
package/dist/service/agent.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/plugin-service.ts
|
|
9
9
|
import { existsSync as existsSync8 } from "node:fs";
|
|
10
|
-
import { delimiter as delimiter5, join as
|
|
10
|
+
import { delimiter as delimiter5, join as join24 } from "node:path";
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
13
|
import { randomUUID } from "node:crypto";
|
|
@@ -21172,7 +21172,7 @@ function codexCatalogArgs() {
|
|
|
21172
21172
|
|
|
21173
21173
|
// src/providers/model-catalog.ts
|
|
21174
21174
|
import { spawn as spawn5 } from "node:child_process";
|
|
21175
|
-
import { readFile as readFile4 } from "node:fs/promises";
|
|
21175
|
+
import { readdir, readFile as readFile4 } from "node:fs/promises";
|
|
21176
21176
|
import { homedir as homedir7 } from "node:os";
|
|
21177
21177
|
import { isAbsolute as isAbsolute2, join as join10, resolve as resolve3 } from "node:path";
|
|
21178
21178
|
|
|
@@ -21305,9 +21305,40 @@ var CLAUDE_REASONING_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
|
21305
21305
|
var CLAUDE_BUILTIN_MODELS = [
|
|
21306
21306
|
{ id: "opus", name: "Opus" },
|
|
21307
21307
|
{ id: "sonnet", name: "Sonnet" },
|
|
21308
|
-
{ id: "haiku", name: "Haiku" }
|
|
21308
|
+
{ id: "haiku", name: "Haiku" },
|
|
21309
|
+
{ id: "fable", name: "Fable" }
|
|
21309
21310
|
];
|
|
21310
|
-
function
|
|
21311
|
+
function parseClaudeCachedModels(cache) {
|
|
21312
|
+
const listed = objectValue(objectValue(objectValue(cache).catalog).config).models;
|
|
21313
|
+
if (!Array.isArray(listed)) return [];
|
|
21314
|
+
const entries = [];
|
|
21315
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21316
|
+
for (const raw of listed) {
|
|
21317
|
+
const model = objectValue(raw);
|
|
21318
|
+
const id = stringValue(model.id);
|
|
21319
|
+
if (!id || model.disabled === true || seen.has(id)) continue;
|
|
21320
|
+
seen.add(id);
|
|
21321
|
+
const runtime = objectValue(model.runtime);
|
|
21322
|
+
const efforts = Array.isArray(runtime.effort_levels) ? runtime.effort_levels.filter((value) => typeof value === "string" && value.trim() !== "") : [];
|
|
21323
|
+
const name = stringValue(model.name);
|
|
21324
|
+
const description = stringValue(model.description);
|
|
21325
|
+
const defaultEffort = stringValue(runtime.default_effort);
|
|
21326
|
+
const section = stringValue(model.section);
|
|
21327
|
+
entries.push({
|
|
21328
|
+
...section && { section },
|
|
21329
|
+
entry: {
|
|
21330
|
+
id,
|
|
21331
|
+
name: name ?? id,
|
|
21332
|
+
...description && { description },
|
|
21333
|
+
...defaultEffort && efforts.includes(defaultEffort) && { default_reasoning_effort: defaultEffort },
|
|
21334
|
+
supported_reasoning_efforts: efforts
|
|
21335
|
+
}
|
|
21336
|
+
});
|
|
21337
|
+
}
|
|
21338
|
+
const main2 = entries.filter((item) => item.section === "main");
|
|
21339
|
+
return (main2.length ? main2 : entries).map((item) => item.entry);
|
|
21340
|
+
}
|
|
21341
|
+
function parseClaudeModelCatalog(settings, environment = process.env, fetchedAt = (/* @__PURE__ */ new Date()).toISOString(), cachedModels = []) {
|
|
21311
21342
|
const source = objectValue(settings);
|
|
21312
21343
|
const mergedEnv = { ...objectValue(source.env), ...environment };
|
|
21313
21344
|
const models2 = /* @__PURE__ */ new Map();
|
|
@@ -21331,8 +21362,18 @@ function parseClaudeModelCatalog(settings, environment = process.env, fetchedAt
|
|
|
21331
21362
|
}
|
|
21332
21363
|
const defaultModel = stringValue(mergedEnv.ANTHROPIC_MODEL) ?? stringValue(source.model);
|
|
21333
21364
|
if (models2.size === 0) {
|
|
21334
|
-
if (
|
|
21335
|
-
|
|
21365
|
+
if (cachedModels.length) {
|
|
21366
|
+
for (const model of cachedModels) if (!models2.has(model.id)) models2.set(model.id, model);
|
|
21367
|
+
if (defaultModel && !models2.has(defaultModel)) {
|
|
21368
|
+
const rest = [...models2.values()];
|
|
21369
|
+
models2.clear();
|
|
21370
|
+
addModel(defaultModel);
|
|
21371
|
+
for (const model of rest) models2.set(model.id, model);
|
|
21372
|
+
}
|
|
21373
|
+
} else {
|
|
21374
|
+
if (defaultModel) addModel(defaultModel);
|
|
21375
|
+
for (const model of CLAUDE_BUILTIN_MODELS) addModel(model.id, model.name);
|
|
21376
|
+
}
|
|
21336
21377
|
}
|
|
21337
21378
|
return {
|
|
21338
21379
|
agent_type: "claude",
|
|
@@ -21358,7 +21399,23 @@ async function readClaudeModelCatalog() {
|
|
|
21358
21399
|
throw new Error("Claude \u672C\u673A settings.json \u4E0D\u662F\u6709\u6548 JSON");
|
|
21359
21400
|
}
|
|
21360
21401
|
}
|
|
21361
|
-
return parseClaudeModelCatalog(settings);
|
|
21402
|
+
return parseClaudeModelCatalog(settings, process.env, (/* @__PURE__ */ new Date()).toISOString(), await readClaudeCachedModels(home));
|
|
21403
|
+
}
|
|
21404
|
+
async function readClaudeCachedModels(home) {
|
|
21405
|
+
const dir = join10(home, "cache", "model-catalog");
|
|
21406
|
+
const names = await readdir(dir).catch(() => []);
|
|
21407
|
+
let newest;
|
|
21408
|
+
for (const name of names) {
|
|
21409
|
+
if (!name.endsWith(".json")) continue;
|
|
21410
|
+
try {
|
|
21411
|
+
const cache = JSON.parse(await readFile4(join10(dir, name), "utf8"));
|
|
21412
|
+
const models2 = parseClaudeCachedModels(cache);
|
|
21413
|
+
const fetchedAt = Number(objectValue(cache).fetchedAt) || 0;
|
|
21414
|
+
if (models2.length && (!newest || fetchedAt > newest.fetchedAt)) newest = { fetchedAt, models: models2 };
|
|
21415
|
+
} catch {
|
|
21416
|
+
}
|
|
21417
|
+
}
|
|
21418
|
+
return newest?.models ?? [];
|
|
21362
21419
|
}
|
|
21363
21420
|
function configValue(content, key) {
|
|
21364
21421
|
const match = content.match(new RegExp(`^\\s*${key}\\s*=\\s*["']([^"']+)["']\\s*(?:#.*)?$`, "m"));
|
|
@@ -21665,7 +21722,7 @@ async function readOpencodeModelCatalog() {
|
|
|
21665
21722
|
}
|
|
21666
21723
|
var TEN_MINUTES = 10 * 60 * 1e3;
|
|
21667
21724
|
var MODEL_SOURCES = {
|
|
21668
|
-
claude: { read: readClaudeModelCatalog, watchFiles: () => [join10(claudeHome(), "settings.json")] },
|
|
21725
|
+
claude: { read: readClaudeModelCatalog, watchFiles: () => [join10(claudeHome(), "settings.json"), join10(claudeHome(), "cache", "model-catalog")] },
|
|
21669
21726
|
codex: {
|
|
21670
21727
|
read: readCodexModelCatalog,
|
|
21671
21728
|
watchFiles: () => {
|
|
@@ -21690,7 +21747,11 @@ var GEMINI_FAILURE_RULES = [
|
|
|
21690
21747
|
{ kind: "sessionMissing", pattern: /session[^\n]{0,60}(?:not found|does not exist)|no session found|invalid session/i },
|
|
21691
21748
|
{ kind: "notSignedIn", pattern: /api key is missing|not configured|login required|please (?:log|sign) ?in/i }
|
|
21692
21749
|
];
|
|
21693
|
-
var GEMINI_ACP_DIALECT = {
|
|
21750
|
+
var GEMINI_ACP_DIALECT = {
|
|
21751
|
+
failureRules: GEMINI_FAILURE_RULES,
|
|
21752
|
+
failureKind: ({ code }) => code === 401 ? "notSignedIn" : code === 429 ? "rateLimited" : void 0,
|
|
21753
|
+
linksFileMentions: true
|
|
21754
|
+
};
|
|
21694
21755
|
|
|
21695
21756
|
// src/acp/acp-dialects/acp-dialect.ts
|
|
21696
21757
|
var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
@@ -21793,7 +21854,7 @@ function classifySpawnError(error62, context) {
|
|
|
21793
21854
|
}
|
|
21794
21855
|
|
|
21795
21856
|
// src/providers/cli/kiro-session-log.ts
|
|
21796
|
-
import { open as open2, readdir, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
21857
|
+
import { open as open2, readdir as readdir2, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
21797
21858
|
import { homedir as homedir8 } from "node:os";
|
|
21798
21859
|
import { join as join11 } from "node:path";
|
|
21799
21860
|
var SHELL_TOOLS = /* @__PURE__ */ new Set(["shell", "execute_bash", "bash"]);
|
|
@@ -21826,7 +21887,7 @@ var KiroSessionLog = class {
|
|
|
21826
21887
|
* in the same folder) leave it unknown.
|
|
21827
21888
|
*/
|
|
21828
21889
|
async findFreshLog() {
|
|
21829
|
-
const names = await
|
|
21890
|
+
const names = await readdir2(this.directory).catch(() => []);
|
|
21830
21891
|
const found = [];
|
|
21831
21892
|
for (const name of names) {
|
|
21832
21893
|
if (!name.endsWith(".json")) continue;
|
|
@@ -22348,8 +22409,11 @@ var KIMI_LAUNCH_SPEC = {
|
|
|
22348
22409
|
var GEMINI_LAUNCH_SPEC = {
|
|
22349
22410
|
agent: "gemini",
|
|
22350
22411
|
headless: "acp",
|
|
22351
|
-
//
|
|
22352
|
-
args: ({
|
|
22412
|
+
// The shared ACP driver enforces each turn's permission level.
|
|
22413
|
+
args: ({ model }) => ["--acp", "--approval-mode", "default", ...model ? ["--model", model] : []],
|
|
22414
|
+
env: { NO_BROWSER: "true" },
|
|
22415
|
+
// Earlier releases can replay session history after `session/load` has answered.
|
|
22416
|
+
minimumVersions: ["0.68.0"],
|
|
22353
22417
|
launchApplies: { model: true },
|
|
22354
22418
|
dialect: GEMINI_ACP_DIALECT,
|
|
22355
22419
|
modelDiscovery: { kind: "reader", source: MODEL_SOURCES.gemini }
|
|
@@ -24437,7 +24501,8 @@ function createAcpProvider(row) {
|
|
|
24437
24501
|
return { display: [runLog.event(`\u539F\u4F1A\u8BDD ${missing} \u5DF2\u4E0D\u5B58\u5728\uFF0C\u672C\u8F6E\u6539\u4E3A\u5F00\u59CB\u65B0\u4F1A\u8BDD`)] };
|
|
24438
24502
|
}
|
|
24439
24503
|
}
|
|
24440
|
-
|
|
24504
|
+
const failureKind = code === AUTH_REQUIRED ? "notSignedIn" : message.error ? dialect.failureKind?.(message.error) : void 0;
|
|
24505
|
+
return fail(text3, failureKind);
|
|
24441
24506
|
};
|
|
24442
24507
|
const onResponse = (message) => {
|
|
24443
24508
|
const phase = typeof message.id === "number" ? phases.get(message.id) : void 0;
|
|
@@ -24463,7 +24528,7 @@ function createAcpProvider(row) {
|
|
|
24463
24528
|
return { display: [runLog.event(`\u65E0\u6CD5\u8BBE\u7F6E${label}\uFF1A${text3.slice(0, 200)}`), ...nextSetting()] };
|
|
24464
24529
|
}
|
|
24465
24530
|
default:
|
|
24466
|
-
return fail(text3, message.error.code === AUTH_REQUIRED ? "notSignedIn" :
|
|
24531
|
+
return fail(text3, message.error.code === AUTH_REQUIRED ? "notSignedIn" : dialect.failureKind?.(message.error));
|
|
24467
24532
|
}
|
|
24468
24533
|
}
|
|
24469
24534
|
switch (phase) {
|
|
@@ -24666,6 +24731,82 @@ var opencodeProvider = {
|
|
|
24666
24731
|
}
|
|
24667
24732
|
};
|
|
24668
24733
|
|
|
24734
|
+
// src/providers/claude-quota.ts
|
|
24735
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
24736
|
+
import { readFile as readFile6 } from "node:fs/promises";
|
|
24737
|
+
import { homedir as homedir10 } from "node:os";
|
|
24738
|
+
import { join as join16 } from "node:path";
|
|
24739
|
+
import { promisify as promisify3 } from "node:util";
|
|
24740
|
+
var execFileAsync3 = promisify3(execFile5);
|
|
24741
|
+
var CLAUDE_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
24742
|
+
var WINDOWS = [
|
|
24743
|
+
{ key: "five_hour", label: "5 \u5C0F\u65F6\u989D\u5EA6", seconds: 5 * 3600 },
|
|
24744
|
+
{ key: "seven_day", label: "\u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 },
|
|
24745
|
+
{ key: "seven_day_opus", label: "Opus \xB7 \u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 },
|
|
24746
|
+
{ key: "seven_day_sonnet", label: "Sonnet \xB7 \u6BCF\u5468\u989D\u5EA6", seconds: 7 * 86400 }
|
|
24747
|
+
];
|
|
24748
|
+
function objectValue2(value) {
|
|
24749
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
24750
|
+
}
|
|
24751
|
+
function resetSeconds(value) {
|
|
24752
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return Math.floor(value > 1e10 ? value / 1e3 : value);
|
|
24753
|
+
if (typeof value === "string" && value.trim()) {
|
|
24754
|
+
const parsed = Date.parse(value);
|
|
24755
|
+
if (Number.isFinite(parsed)) return Math.floor(parsed / 1e3);
|
|
24756
|
+
}
|
|
24757
|
+
return 0;
|
|
24758
|
+
}
|
|
24759
|
+
function parseClaudeQuota(body) {
|
|
24760
|
+
const source = objectValue2(body);
|
|
24761
|
+
const windows = [];
|
|
24762
|
+
for (const { key, label, seconds } of WINDOWS) {
|
|
24763
|
+
const raw = source[key];
|
|
24764
|
+
if (!raw || typeof raw !== "object") continue;
|
|
24765
|
+
const window = objectValue2(raw);
|
|
24766
|
+
const utilization = Number(window.utilization);
|
|
24767
|
+
windows.push({
|
|
24768
|
+
key: `claude:${key}`,
|
|
24769
|
+
label,
|
|
24770
|
+
resets_at: resetSeconds(window.resets_at),
|
|
24771
|
+
window_seconds: seconds,
|
|
24772
|
+
...window.utilization !== null && Number.isFinite(utilization) && utilization >= 0 ? { used_percent: Math.min(100, Math.round(utilization * 100) / 100) } : {}
|
|
24773
|
+
});
|
|
24774
|
+
}
|
|
24775
|
+
return windows;
|
|
24776
|
+
}
|
|
24777
|
+
var claudeHome2 = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join16(homedir10(), ".claude");
|
|
24778
|
+
function tokenFrom(content) {
|
|
24779
|
+
try {
|
|
24780
|
+
const token = objectValue2(objectValue2(JSON.parse(content)).claudeAiOauth).accessToken;
|
|
24781
|
+
return typeof token === "string" && token.trim() ? token.trim() : void 0;
|
|
24782
|
+
} catch {
|
|
24783
|
+
return void 0;
|
|
24784
|
+
}
|
|
24785
|
+
}
|
|
24786
|
+
async function readClaudeAccessToken() {
|
|
24787
|
+
const fromEnv = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
|
|
24788
|
+
if (fromEnv) return fromEnv;
|
|
24789
|
+
const fromFile = tokenFrom(await readFile6(join16(claudeHome2(), ".credentials.json"), "utf8").catch(() => ""));
|
|
24790
|
+
if (fromFile) return fromFile;
|
|
24791
|
+
if (process.platform !== "darwin") return void 0;
|
|
24792
|
+
const { stdout } = await execFileAsync3("security", ["find-generic-password", "-s", "Claude Code-credentials", "-w"], { timeout: 1e4 }).catch(() => ({ stdout: "" }));
|
|
24793
|
+
return tokenFrom(String(stdout).trim());
|
|
24794
|
+
}
|
|
24795
|
+
async function readClaudeQuotaWindows() {
|
|
24796
|
+
const token = await readClaudeAccessToken();
|
|
24797
|
+
if (!token) throw new Error("Claude Code \u672A\u4F7F\u7528 Claude \u8D26\u53F7\u767B\u5F55\uFF08API Key \u65B9\u5F0F\u6CA1\u6709\u5957\u9910\u989D\u5EA6\uFF09\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C claude \u5E76 /login");
|
|
24798
|
+
const response = await fetch(CLAUDE_USAGE_URL, {
|
|
24799
|
+
headers: { authorization: `Bearer ${token}`, "anthropic-beta": "oauth-2025-04-20", accept: "application/json" },
|
|
24800
|
+
redirect: "error",
|
|
24801
|
+
signal: AbortSignal.timeout(15e3)
|
|
24802
|
+
});
|
|
24803
|
+
if (response.status === 401 || response.status === 403) throw new Error("Claude Code \u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C\u4E00\u6B21 claude \u5237\u65B0\u767B\u5F55\u540E\u518D\u8BD5");
|
|
24804
|
+
if (!response.ok) throw new Error(`Claude \u989D\u5EA6\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25 (${response.status})`);
|
|
24805
|
+
const windows = parseClaudeQuota(await response.json());
|
|
24806
|
+
if (!windows.length) throw new Error("Claude \u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u7684\u989D\u5EA6\u7A97\u53E3");
|
|
24807
|
+
return windows;
|
|
24808
|
+
}
|
|
24809
|
+
|
|
24669
24810
|
// src/providers/codex-quota.ts
|
|
24670
24811
|
import { spawn as spawn8 } from "node:child_process";
|
|
24671
24812
|
import { createInterface as createInterface3 } from "node:readline";
|
|
@@ -24764,10 +24905,10 @@ async function readCodexQuotaWindows() {
|
|
|
24764
24905
|
}
|
|
24765
24906
|
|
|
24766
24907
|
// src/providers/kiro-quota.ts
|
|
24767
|
-
import { execFile as
|
|
24908
|
+
import { execFile as execFile6 } from "node:child_process";
|
|
24768
24909
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
24769
|
-
import { promisify as
|
|
24770
|
-
var
|
|
24910
|
+
import { promisify as promisify4, stripVTControlCharacters } from "node:util";
|
|
24911
|
+
var execFileAsync4 = promisify4(execFile6);
|
|
24771
24912
|
var amount = (value) => Number(value.replace(/,/g, ""));
|
|
24772
24913
|
var rounded = (value) => Math.round(value * 100) / 100;
|
|
24773
24914
|
function parseKiroQuota(stdout, now = /* @__PURE__ */ new Date()) {
|
|
@@ -24827,7 +24968,7 @@ async function readKiroQuotaWindows() {
|
|
|
24827
24968
|
const launch = launchCli({ spec: requireCliSpec("kiro"), args: ["chat", "--no-interactive", "/usage"] });
|
|
24828
24969
|
await requireKiroAuthentication(launch.env);
|
|
24829
24970
|
try {
|
|
24830
|
-
const { stdout, stderr } = await
|
|
24971
|
+
const { stdout, stderr } = await execFileAsync4(launch.executable, launch.args, { env: launch.env, cwd: tmpdir2(), timeout: 3e4, maxBuffer: 1024 * 1024, windowsHide: true });
|
|
24831
24972
|
return parseKiroQuota(`${stdout}
|
|
24832
24973
|
${stderr}`);
|
|
24833
24974
|
} catch (error62) {
|
|
@@ -24840,7 +24981,7 @@ ${stderr}`);
|
|
|
24840
24981
|
var ALL_LEVELS = ["read-only", "acceptEdits", "bypassPermissions"];
|
|
24841
24982
|
var NATIVE = {
|
|
24842
24983
|
codex: { headless: codexProvider, chat: codexChatProvider, models: MODEL_SOURCES.codex, quota: readCodexQuotaWindows, runSettings: { permissionModes: ALL_LEVELS, plan: "prompt", fast: true } },
|
|
24843
|
-
claude: { headless: claudeProvider, chat: (_request, attachments) => claudeChatProvider(attachments), models: MODEL_SOURCES.claude, runSettings: { permissionModes: ALL_LEVELS, plan: "native", fast: true } }
|
|
24984
|
+
claude: { headless: claudeProvider, chat: (_request, attachments) => claudeChatProvider(attachments), models: MODEL_SOURCES.claude, quota: readClaudeQuotaWindows, runSettings: { permissionModes: ALL_LEVELS, plan: "native", fast: true } }
|
|
24844
24985
|
};
|
|
24845
24986
|
var ACP_EXTRAS = {
|
|
24846
24987
|
kiro: { quota: readKiroQuotaWindows, legacy: { headless: kiroProvider, restrictedPermission: true, runSettings: { permissionModes: ["read-only", "bypassPermissions"], plan: "prompt" } } },
|
|
@@ -25026,7 +25167,7 @@ var cliDetection = new CliDetectionService();
|
|
|
25026
25167
|
|
|
25027
25168
|
// src/runtime/agent-runtime.ts
|
|
25028
25169
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
25029
|
-
import { join as
|
|
25170
|
+
import { join as join23 } from "node:path";
|
|
25030
25171
|
|
|
25031
25172
|
// src/exec/script-runner.ts
|
|
25032
25173
|
import { spawn as spawn10 } from "node:child_process";
|
|
@@ -25137,7 +25278,7 @@ function resolveChatProvider(type, request, attachments) {
|
|
|
25137
25278
|
}
|
|
25138
25279
|
|
|
25139
25280
|
// src/memory/providers.ts
|
|
25140
|
-
import { execFile as
|
|
25281
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
25141
25282
|
var MemoryCreateInputSchema = external_exports.object({
|
|
25142
25283
|
id: external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/),
|
|
25143
25284
|
name: external_exports.string().trim().min(1).max(200),
|
|
@@ -25159,7 +25300,7 @@ var runNmem = (args) => {
|
|
|
25159
25300
|
const env = providerEnvironment();
|
|
25160
25301
|
const launch = resolveExecutable("nmem", args, env, process.env.TOC_OCRA_NMEM_PATH);
|
|
25161
25302
|
return new Promise((resolve9) => {
|
|
25162
|
-
|
|
25303
|
+
execFile7(launch.executable, launch.args, { env: launch.env, timeout: COMMAND_TIMEOUT_MS, maxBuffer: MAX_OUTPUT_BYTES, windowsHide: true }, (error62, stdout) => {
|
|
25163
25304
|
if (!error62) {
|
|
25164
25305
|
resolve9({ stdout: String(stdout) });
|
|
25165
25306
|
return;
|
|
@@ -25314,16 +25455,16 @@ async function readCLIQuotaReport(agentType) {
|
|
|
25314
25455
|
}
|
|
25315
25456
|
|
|
25316
25457
|
// src/providers/tb-switch-control.ts
|
|
25317
|
-
import { readFile as
|
|
25318
|
-
import { homedir as
|
|
25319
|
-
import { join as
|
|
25458
|
+
import { readFile as readFile7 } from "node:fs/promises";
|
|
25459
|
+
import { homedir as homedir11 } from "node:os";
|
|
25460
|
+
import { join as join17 } from "node:path";
|
|
25320
25461
|
function dataDir() {
|
|
25321
|
-
return process.env.TB_SWITCH_HOME?.trim() ||
|
|
25462
|
+
return process.env.TB_SWITCH_HOME?.trim() || join17(homedir11(), ".tb-switch");
|
|
25322
25463
|
}
|
|
25323
25464
|
async function readLocalService() {
|
|
25324
25465
|
let discovery;
|
|
25325
25466
|
try {
|
|
25326
|
-
discovery = JSON.parse(await
|
|
25467
|
+
discovery = JSON.parse(await readFile7(join17(dataDir(), "api.json"), "utf8"));
|
|
25327
25468
|
} catch {
|
|
25328
25469
|
throw new Error("\u8FD9\u53F0\u8BBE\u5907\u4E0A\u7684 TB Switch \u670D\u52A1\u672A\u8FD0\u884C\uFF0C\u8BF7\u6253\u5F00\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
|
|
25329
25470
|
}
|
|
@@ -25339,7 +25480,7 @@ async function readLocalService() {
|
|
|
25339
25480
|
}
|
|
25340
25481
|
let token = process.env.TB_SWITCH_API_TOKEN?.trim() ?? "";
|
|
25341
25482
|
try {
|
|
25342
|
-
token = (await
|
|
25483
|
+
token = (await readFile7(join17(dataDir(), "api-token"), "utf8")).trim();
|
|
25343
25484
|
} catch {
|
|
25344
25485
|
}
|
|
25345
25486
|
if (!token) throw new Error("\u65E0\u6CD5\u8BFB\u53D6 TB Switch \u672C\u673A\u670D\u52A1\u51ED\u636E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
|
|
@@ -25429,7 +25570,7 @@ async function controlTbSwitch(payload) {
|
|
|
25429
25570
|
}
|
|
25430
25571
|
|
|
25431
25572
|
// src/runs/orphan-registry.ts
|
|
25432
|
-
import { mkdir as mkdir5, readFile as
|
|
25573
|
+
import { mkdir as mkdir5, readFile as readFile8, rename as rename5, writeFile as writeFile5 } from "node:fs/promises";
|
|
25433
25574
|
import { basename, dirname as dirname8 } from "node:path";
|
|
25434
25575
|
var OrphanRegistry = class {
|
|
25435
25576
|
constructor(file2) {
|
|
@@ -25458,7 +25599,7 @@ var OrphanRegistry = class {
|
|
|
25458
25599
|
async reapPrevious() {
|
|
25459
25600
|
let previous = [];
|
|
25460
25601
|
try {
|
|
25461
|
-
previous = JSON.parse(await
|
|
25602
|
+
previous = JSON.parse(await readFile8(this.file, "utf8"));
|
|
25462
25603
|
} catch {
|
|
25463
25604
|
return [];
|
|
25464
25605
|
}
|
|
@@ -25484,7 +25625,7 @@ function commandOf(pid) {
|
|
|
25484
25625
|
// src/runs/run-supervisor.ts
|
|
25485
25626
|
import { spawn as spawn12 } from "node:child_process";
|
|
25486
25627
|
import { mkdir as mkdir8, realpath as realpath2, stat as stat6, writeFile as writeFile8 } from "node:fs/promises";
|
|
25487
|
-
import { basename as basename3, isAbsolute as isAbsolute4, join as
|
|
25628
|
+
import { basename as basename3, isAbsolute as isAbsolute4, join as join21, relative as relative2, resolve as resolve5 } from "node:path";
|
|
25488
25629
|
import { createInterface as createInterface5 } from "node:readline";
|
|
25489
25630
|
|
|
25490
25631
|
// src/session/terminal-tail-buffer.ts
|
|
@@ -25846,19 +25987,19 @@ async function forkCodexThread(options) {
|
|
|
25846
25987
|
|
|
25847
25988
|
// src/runs/run-recorder.ts
|
|
25848
25989
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3 } from "node:fs";
|
|
25849
|
-
import { homedir as
|
|
25850
|
-
import { join as
|
|
25990
|
+
import { homedir as homedir12 } from "node:os";
|
|
25991
|
+
import { join as join18 } from "node:path";
|
|
25851
25992
|
var RunRecorder = class _RunRecorder {
|
|
25852
25993
|
constructor(path) {
|
|
25853
25994
|
this.path = path;
|
|
25854
25995
|
}
|
|
25855
25996
|
path;
|
|
25856
|
-
home =
|
|
25997
|
+
home = homedir12();
|
|
25857
25998
|
static fromEnvironment(runId, meta3) {
|
|
25858
25999
|
const directory = process.env.TOC_OCRA_RECORD_DIR?.trim();
|
|
25859
26000
|
if (!directory) return void 0;
|
|
25860
26001
|
mkdirSync3(directory, { recursive: true });
|
|
25861
|
-
const recorder = new _RunRecorder(
|
|
26002
|
+
const recorder = new _RunRecorder(join18(directory, `${String(meta3.agent ?? "cli")}-${runId}.jsonl`));
|
|
25862
26003
|
recorder.write({ meta: meta3 });
|
|
25863
26004
|
return recorder;
|
|
25864
26005
|
}
|
|
@@ -25873,8 +26014,8 @@ var RunRecorder = class _RunRecorder {
|
|
|
25873
26014
|
};
|
|
25874
26015
|
|
|
25875
26016
|
// src/runs/run-transcript.ts
|
|
25876
|
-
import { chmod as chmod4, mkdir as mkdir6, readdir as
|
|
25877
|
-
import { join as
|
|
26017
|
+
import { chmod as chmod4, mkdir as mkdir6, readdir as readdir3, readFile as readFile9, rename as rename6, stat as stat4, unlink, writeFile as writeFile6 } from "node:fs/promises";
|
|
26018
|
+
import { join as join19 } from "node:path";
|
|
25878
26019
|
var MAX_TRANSCRIPT_ITEMS = 5e3;
|
|
25879
26020
|
var MAX_TRANSCRIPT_TEXT = 2e5;
|
|
25880
26021
|
var MAX_TRANSCRIPT_LINES = 2e4;
|
|
@@ -26139,7 +26280,7 @@ function transcriptFileName(runId) {
|
|
|
26139
26280
|
var TranscriptStore = class {
|
|
26140
26281
|
constructor(dataDir2, logger, env = process.env) {
|
|
26141
26282
|
this.logger = logger;
|
|
26142
|
-
this.directory = dataDir2 ?
|
|
26283
|
+
this.directory = dataDir2 ? join19(dataDir2, "transcripts") : "";
|
|
26143
26284
|
this.enabled = Boolean(dataDir2) && transcriptsOnDisk(env);
|
|
26144
26285
|
}
|
|
26145
26286
|
logger;
|
|
@@ -26194,7 +26335,7 @@ var TranscriptStore = class {
|
|
|
26194
26335
|
await this.writes.get(runId);
|
|
26195
26336
|
let text3;
|
|
26196
26337
|
try {
|
|
26197
|
-
text3 = await
|
|
26338
|
+
text3 = await readFile9(join19(this.directory, name), "utf8");
|
|
26198
26339
|
} catch (error62) {
|
|
26199
26340
|
if (errorCode(error62) !== "ENOENT") this.logger.warn("run-transcript-read-failed", { runId, error: errorMessage(error62) });
|
|
26200
26341
|
return void 0;
|
|
@@ -26259,7 +26400,7 @@ var TranscriptStore = class {
|
|
|
26259
26400
|
transcript.dirty = false;
|
|
26260
26401
|
const body = JSON.stringify(transcript.toFile());
|
|
26261
26402
|
await this.ensureDirectory();
|
|
26262
|
-
const file2 =
|
|
26403
|
+
const file2 = join19(this.directory, name);
|
|
26263
26404
|
const temporary = `${file2}.${process.pid}.tmp`;
|
|
26264
26405
|
await writeFile6(temporary, body, { mode: 384 });
|
|
26265
26406
|
await rename6(temporary, file2);
|
|
@@ -26288,7 +26429,7 @@ var TranscriptStore = class {
|
|
|
26288
26429
|
async pruneOnce() {
|
|
26289
26430
|
let names;
|
|
26290
26431
|
try {
|
|
26291
|
-
names = await
|
|
26432
|
+
names = await readdir3(this.directory);
|
|
26292
26433
|
} catch (error62) {
|
|
26293
26434
|
if (errorCode(error62) === "ENOENT") return;
|
|
26294
26435
|
throw error62;
|
|
@@ -26296,7 +26437,7 @@ var TranscriptStore = class {
|
|
|
26296
26437
|
const now = Date.now();
|
|
26297
26438
|
const files = [];
|
|
26298
26439
|
for (const name of names) {
|
|
26299
|
-
const path =
|
|
26440
|
+
const path = join19(this.directory, name);
|
|
26300
26441
|
if (name.endsWith(".tmp")) {
|
|
26301
26442
|
const info2 = await stat4(path).catch(() => void 0);
|
|
26302
26443
|
if (info2?.isFile() && now - info2.mtimeMs > STALE_TEMPORARY_MS) await unlink(path).catch(() => void 0);
|
|
@@ -26346,7 +26487,7 @@ function errorMessage(error62) {
|
|
|
26346
26487
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
|
|
26347
26488
|
import { constants as constants2 } from "node:fs";
|
|
26348
26489
|
import { lstat, mkdir as mkdir7, open as open3, realpath, rename as rename7, rm as rm4, writeFile as writeFile7 } from "node:fs/promises";
|
|
26349
|
-
import { basename as basename2, isAbsolute as isAbsolute3, join as
|
|
26490
|
+
import { basename as basename2, isAbsolute as isAbsolute3, join as join20, relative } from "node:path";
|
|
26350
26491
|
function within(root2, path) {
|
|
26351
26492
|
const segment = relative(root2, path);
|
|
26352
26493
|
return segment === "" || !segment.startsWith("..") && !isAbsolute3(segment);
|
|
@@ -26354,7 +26495,7 @@ function within(root2, path) {
|
|
|
26354
26495
|
async function attachmentDirectory(workdir, messageId) {
|
|
26355
26496
|
let directory = workdir;
|
|
26356
26497
|
for (const segment of [".echo", "attachments", `message-${encodeURIComponent(messageId).slice(0, 180)}`]) {
|
|
26357
|
-
directory =
|
|
26498
|
+
directory = join20(directory, segment);
|
|
26358
26499
|
await mkdir7(directory, { mode: 448 }).catch((error62) => {
|
|
26359
26500
|
if (error62.code !== "EEXIST") throw error62;
|
|
26360
26501
|
});
|
|
@@ -26362,7 +26503,7 @@ async function attachmentDirectory(workdir, messageId) {
|
|
|
26362
26503
|
if (metadata.isSymbolicLink() || !metadata.isDirectory() || !within(workdir, await realpath(directory))) {
|
|
26363
26504
|
throw new Error("\u9644\u4EF6\u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E CLI \u5DE5\u4F5C\u76EE\u5F55\u5185\uFF0C\u4E14\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");
|
|
26364
26505
|
}
|
|
26365
|
-
if (segment === ".echo") await writeFile7(
|
|
26506
|
+
if (segment === ".echo") await writeFile7(join20(directory, ".gitignore"), "*\n", { flag: "wx", mode: 384 }).catch((error62) => {
|
|
26366
26507
|
if (error62.code !== "EEXIST") throw error62;
|
|
26367
26508
|
});
|
|
26368
26509
|
}
|
|
@@ -26399,9 +26540,9 @@ async function prepareTaskAttachments(payload, workdir, download, signal2) {
|
|
|
26399
26540
|
const characters = Array.from(basename2(file2.name.replace(/\\/g, "/")).replace(/[^\p{L}\p{N}._-]/gu, "_").replace(/\.+$/u, ""));
|
|
26400
26541
|
while (Buffer.byteLength(characters.join("")) > 160) characters.shift();
|
|
26401
26542
|
const name = characters.join("") || "attachment";
|
|
26402
|
-
const path =
|
|
26543
|
+
const path = join20(directory, `${file2.file_id}-${name}`);
|
|
26403
26544
|
if (!await matches(path, file2.size, file2.sha256, signal2)) {
|
|
26404
|
-
const temporary =
|
|
26545
|
+
const temporary = join20(directory, `.download-${file2.file_id}-${randomUUID2()}.part`);
|
|
26405
26546
|
try {
|
|
26406
26547
|
await download(payload.run_id, file2.file_id, temporary, file2.size, file2.sha256, signal2);
|
|
26407
26548
|
signal2.throwIfAborted();
|
|
@@ -26516,7 +26657,7 @@ var ChatEventForwarder = class {
|
|
|
26516
26657
|
|
|
26517
26658
|
// src/acp/chat-session.ts
|
|
26518
26659
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
26519
|
-
import { readFile as
|
|
26660
|
+
import { readFile as readFile10, stat as stat5 } from "node:fs/promises";
|
|
26520
26661
|
import { extname } from "node:path";
|
|
26521
26662
|
import { pathToFileURL } from "node:url";
|
|
26522
26663
|
|
|
@@ -27124,12 +27265,12 @@ var AcpChatSession = class {
|
|
|
27124
27265
|
if (file2.kind === "image" && mimeType && connection.imagePrompts) {
|
|
27125
27266
|
const size = await stat5(file2.path).then((info) => info.size).catch(() => 0);
|
|
27126
27267
|
if (size > 0 && size <= MAX_IMAGE_BYTES) {
|
|
27127
|
-
blocks.push({ type: "image", mimeType, data: (await
|
|
27268
|
+
blocks.push({ type: "image", mimeType, data: (await readFile10(file2.path)).toString("base64") });
|
|
27128
27269
|
continue;
|
|
27129
27270
|
}
|
|
27130
27271
|
}
|
|
27131
27272
|
blocks.push({ type: "resource_link", uri: pathToFileURL(file2.path).href, name: file2.name });
|
|
27132
|
-
notes.push(`\u9644\u4EF6\u6587\u4EF6\uFF1A${file2.name}
|
|
27273
|
+
notes.push(this.spec.dialect?.linksFileMentions ? `@${file2.path}` : `\u9644\u4EF6\u6587\u4EF6\uFF1A${file2.name}
|
|
27133
27274
|
\u672C\u673A\u8DEF\u5F84\uFF1A${file2.path}`);
|
|
27134
27275
|
}
|
|
27135
27276
|
const text3 = [request.prompt, ...notes].filter(Boolean).join("\n\n");
|
|
@@ -27293,6 +27434,8 @@ var AcpChatSession = class {
|
|
|
27293
27434
|
const text3 = detail ?? rpcErrorText(error62);
|
|
27294
27435
|
const context = { label: this.spec.cli.label, ...this.spec.cli.installHint ? { installHint: this.spec.cli.installHint } : {} };
|
|
27295
27436
|
if (/ACP 进程无法启动/.test(text3)) return classifySpawnError(text3, context);
|
|
27437
|
+
const statusFailure = error62 instanceof JsonRpcError ? this.spec.dialect?.failureKind?.({ code: error62.code, message: error62.message, data: error62.data }) : void 0;
|
|
27438
|
+
if (statusFailure) return cliFailure(statusFailure, { ...context, detail: text3 });
|
|
27296
27439
|
if (error62 instanceof JsonRpcError && error62.code === -32e3) return cliFailure("notSignedIn", { ...context, detail: text3 });
|
|
27297
27440
|
const stderr = this.connection?.process.stderrTail() ?? [];
|
|
27298
27441
|
const known = classifyCliOutput([text3, ...stderr], this.spec.dialect?.failureRules, context);
|
|
@@ -28356,12 +28499,12 @@ ${PLAN_MODE_PREFIX}` : payload.prompt;
|
|
|
28356
28499
|
async prepareChatAttachments(payload) {
|
|
28357
28500
|
if (!payload.attachments?.length) return [];
|
|
28358
28501
|
if (!this.reporter.chatMedia) throw new Error("\u9644\u4EF6\u8F6C\u53D1\u672A\u914D\u7F6E");
|
|
28359
|
-
const directory =
|
|
28502
|
+
const directory = join21(this.config.dataDir, "chat-media", encodeURIComponent(payload.chat_session_id ?? payload.run_id));
|
|
28360
28503
|
await mkdir8(directory, { recursive: true, mode: 448 });
|
|
28361
28504
|
const files = [];
|
|
28362
28505
|
for (const attachment of payload.attachments) {
|
|
28363
28506
|
const name = basename3(attachment.name).replace(/[^\p{L}\p{N}._-]/gu, "_").slice(-120) || "attachment";
|
|
28364
|
-
const path =
|
|
28507
|
+
const path = join21(directory, `${encodeURIComponent(attachment.media_id)}-${name}`);
|
|
28365
28508
|
const existing = await stat6(path).catch(() => void 0);
|
|
28366
28509
|
if (!existing?.isFile()) {
|
|
28367
28510
|
const data = await this.reporter.chatMedia(payload.run_id, attachment.media_id);
|
|
@@ -28674,17 +28817,17 @@ var GatewayClient = class {
|
|
|
28674
28817
|
};
|
|
28675
28818
|
|
|
28676
28819
|
// src/workspace/directory-browser.ts
|
|
28677
|
-
import { mkdir as mkdir9, readdir as
|
|
28678
|
-
import { homedir as
|
|
28820
|
+
import { mkdir as mkdir9, readdir as readdir4, realpath as realpath3, stat as stat7 } from "node:fs/promises";
|
|
28821
|
+
import { homedir as homedir13 } from "node:os";
|
|
28679
28822
|
import { dirname as dirname9, isAbsolute as isAbsolute5, parse as parse3, resolve as resolve6 } from "node:path";
|
|
28680
28823
|
var MAX_ENTRIES = 1e3;
|
|
28681
28824
|
async function listDirectory(requested, allowedRoots) {
|
|
28682
|
-
const raw = requested.trim().replace(/^~(?=$|[\\/])/,
|
|
28825
|
+
const raw = requested.trim().replace(/^~(?=$|[\\/])/, homedir13()) || homedir13();
|
|
28683
28826
|
const directory = await realpath3(resolve6(raw)).catch(() => {
|
|
28684
28827
|
throw new Error(`\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${requested}`);
|
|
28685
28828
|
});
|
|
28686
28829
|
if (!(await stat7(directory)).isDirectory()) throw new Error("\u8FD9\u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55");
|
|
28687
|
-
const entries = await
|
|
28830
|
+
const entries = await readdir4(directory, { withFileTypes: true }).catch((error62) => {
|
|
28688
28831
|
throw new Error(error62.code === "EACCES" || error62.code === "EPERM" ? "\u6CA1\u6709\u6743\u9650\u8BFB\u53D6\u8FD9\u4E2A\u76EE\u5F55" : error62.message);
|
|
28689
28832
|
});
|
|
28690
28833
|
const byName = (a, b) => a.name.localeCompare(b.name, void 0, { sensitivity: "base", numeric: true });
|
|
@@ -28697,8 +28840,8 @@ async function listDirectory(requested, allowedRoots) {
|
|
|
28697
28840
|
else if (entry.isFile()) files.push(item);
|
|
28698
28841
|
}
|
|
28699
28842
|
const parent = dirname9(directory);
|
|
28700
|
-
const places = [{ label: "\u4E3B\u76EE\u5F55", path:
|
|
28701
|
-
for (const root2 of allowedRoots) if (root2 !==
|
|
28843
|
+
const places = [{ label: "\u4E3B\u76EE\u5F55", path: homedir13() }];
|
|
28844
|
+
for (const root2 of allowedRoots) if (root2 !== homedir13()) places.push({ label: "\u5141\u8BB8\u7684\u76EE\u5F55", path: root2 });
|
|
28702
28845
|
places.push({ label: "\u6839\u76EE\u5F55", path: process.platform === "win32" ? parse3(directory).root : "/" });
|
|
28703
28846
|
return {
|
|
28704
28847
|
path: directory,
|
|
@@ -28736,7 +28879,7 @@ async function createDirectory(parentRequested, name) {
|
|
|
28736
28879
|
// src/workspace/workspace-manager.ts
|
|
28737
28880
|
import { spawn as spawn13 } from "node:child_process";
|
|
28738
28881
|
import { opendir, realpath as realpath4, stat as stat8 } from "node:fs/promises";
|
|
28739
|
-
import { homedir as
|
|
28882
|
+
import { homedir as homedir14 } from "node:os";
|
|
28740
28883
|
import { isAbsolute as isAbsolute6, relative as relative3, resolve as resolve7 } from "node:path";
|
|
28741
28884
|
var MAX_NODES = 2e3;
|
|
28742
28885
|
var MAX_DIRECTORY_ENTRIES = 12e3;
|
|
@@ -28772,7 +28915,7 @@ var WorkspaceManager = class {
|
|
|
28772
28915
|
return { root_path: rootPath, nodes, truncated: nodes.length >= MAX_NODES, duration_ms: Date.now() - startedAt };
|
|
28773
28916
|
}
|
|
28774
28917
|
validateRootPath(value) {
|
|
28775
|
-
const raw = value.trim().replace(/^~(?=$|[\\/])/,
|
|
28918
|
+
const raw = value.trim().replace(/^~(?=$|[\\/])/, homedir14());
|
|
28776
28919
|
const root2 = resolve7(raw);
|
|
28777
28920
|
if (!isAbsolute6(raw)) throw new Error("\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
|
|
28778
28921
|
if (relative3(root2, resolve7(root2, "..")) === "") throw new Error("\u4E0D\u80FD\u628A\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u4F5C\u4E3A\u76EE\u5F55\u6839");
|
|
@@ -29112,7 +29255,7 @@ var AgentRuntime = class {
|
|
|
29112
29255
|
}
|
|
29113
29256
|
};
|
|
29114
29257
|
this.workspaces = new WorkspaceManager(config2, this.logger);
|
|
29115
|
-
this.orphans = new OrphanRegistry(
|
|
29258
|
+
this.orphans = new OrphanRegistry(join23(config2.dataDir, "active-runs.json"));
|
|
29116
29259
|
this.runs = new RunSupervisor(config2, this.logger, reporter, this.orphans);
|
|
29117
29260
|
}
|
|
29118
29261
|
config;
|
|
@@ -29895,7 +30038,7 @@ function preferSystemNode() {
|
|
|
29895
30038
|
const names = process.platform === "win32" ? ["node.exe"] : ["node"];
|
|
29896
30039
|
for (const directory of (process.env.PATH ?? "").split(delimiter5)) {
|
|
29897
30040
|
for (const name of names) {
|
|
29898
|
-
const candidate = directory &&
|
|
30041
|
+
const candidate = directory && join24(directory, name);
|
|
29899
30042
|
if (candidate && existsSync8(candidate)) {
|
|
29900
30043
|
process.env.TOC_OCRA_NODE_PATH = candidate;
|
|
29901
30044
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CliFailureRule } from '../../providers/cli-failure.js';
|
|
1
|
+
import type { CliFailureKind, CliFailureRule } from '../../providers/cli-failure.js';
|
|
2
2
|
/**
|
|
3
3
|
* A CLI's departures from plain ACP, as hooks over the shared lifecycle: the
|
|
4
4
|
* counterpart of Orca's `AcpDialect` ("hooks interpret extensions; lifecycle
|
|
@@ -18,6 +18,10 @@ export type AcpError = {
|
|
|
18
18
|
export type AcpDialect = {
|
|
19
19
|
/** The agent's wording for sign-in, quota and missing-session errors, before the common rules. */
|
|
20
20
|
failureRules?: readonly CliFailureRule[];
|
|
21
|
+
/** Provider status codes carried by ACP errors, when their message is not enough to classify them. */
|
|
22
|
+
failureKind?(error: AcpError): CliFailureKind | undefined;
|
|
23
|
+
/** The agent reads linked files only when their paths are mentioned in the prompt. */
|
|
24
|
+
linksFileMentions?: true;
|
|
21
25
|
/** The readable part of an error's `data`, when the agent nests its message there. */
|
|
22
26
|
promptErrorDetail?(error: AcpError): string | undefined;
|
|
23
27
|
/** Normalizes a tool update before it is read: shell output in `rawOutput.stdout`, exit code in `rawOutput.exitCode`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-dialect.js","sourceRoot":"","sources":["../../../../src/acp/acp-dialects/acp-dialect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"acp-dialect.js","sourceRoot":"","sources":["../../../../src/acp/acp-dialects/acp-dialect.ts"],"names":[],"mappings":"AAoCA,MAAM,CAAC,MAAM,mBAAmB,GAAe,EAAE,CAAA;AAEjD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAA2B,EAAE,CAChE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAiC,CAAC,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliFailureRule } from '../../providers/cli-failure.js';
|
|
2
2
|
import type { AcpDialect } from './acp-dialect.js';
|
|
3
3
|
export declare const GEMINI_FAILURE_RULES: readonly CliFailureRule[];
|
|
4
|
-
/** Gemini
|
|
4
|
+
/** Gemini's ACP errors carry the model API's HTTP status as their JSON-RPC code. */
|
|
5
5
|
export declare const GEMINI_ACP_DIALECT: AcpDialect;
|
|
@@ -2,6 +2,10 @@ export const GEMINI_FAILURE_RULES = [
|
|
|
2
2
|
{ kind: 'sessionMissing', pattern: /session[^\n]{0,60}(?:not found|does not exist)|no session found|invalid session/i },
|
|
3
3
|
{ kind: 'notSignedIn', pattern: /api key is missing|not configured|login required|please (?:log|sign) ?in/i }
|
|
4
4
|
];
|
|
5
|
-
/** Gemini
|
|
6
|
-
export const GEMINI_ACP_DIALECT = {
|
|
5
|
+
/** Gemini's ACP errors carry the model API's HTTP status as their JSON-RPC code. */
|
|
6
|
+
export const GEMINI_ACP_DIALECT = {
|
|
7
|
+
failureRules: GEMINI_FAILURE_RULES,
|
|
8
|
+
failureKind: ({ code }) => code === 401 ? 'notSignedIn' : code === 429 ? 'rateLimited' : undefined,
|
|
9
|
+
linksFileMentions: true
|
|
10
|
+
};
|
|
7
11
|
//# sourceMappingURL=gemini-dialect.js.map
|