@kenhkl/agent-moss 0.17.37 → 0.17.38
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/cli.js +93 -15
- package/dist/engine/coordinator.js +5 -0
- package/dist/server.js +91 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1130,7 +1130,7 @@ function logRoots() {
|
|
|
1130
1130
|
}
|
|
1131
1131
|
function reviewRoots() {
|
|
1132
1132
|
const roots = [join4(homeDir(), ".local", "share", "agent_gate")];
|
|
1133
|
-
for (const name of ["AGENT_GATE_DB", "AGENT_GATE_JSON_PATH"]) {
|
|
1133
|
+
for (const name of ["AGENT_GATE_DB", "AGENT_GATE_JSON_PATH", "AGENT_GATE_DATA_DIR"]) {
|
|
1134
1134
|
const v = env(name);
|
|
1135
1135
|
if (v) roots.push(existsSync3(v) && lstatSync(v).isDirectory() ? v : dirname2(v));
|
|
1136
1136
|
}
|
|
@@ -12002,6 +12002,74 @@ function lifecycleFor(detail, stage, isError) {
|
|
|
12002
12002
|
if (detail.includes(">>") || detail.includes(">")) return "alive";
|
|
12003
12003
|
return "";
|
|
12004
12004
|
}
|
|
12005
|
+
function resolveMaxNodes() {
|
|
12006
|
+
const n = Number.parseInt(process.env.AGENT_MOSS_CHAIN_MAX_NODES || "100000", 10);
|
|
12007
|
+
return Number.isFinite(n) && n > 0 ? n : 1e5;
|
|
12008
|
+
}
|
|
12009
|
+
function resolveRetainNodes() {
|
|
12010
|
+
const raw = process.env.AGENT_MOSS_CHAIN_RETAIN_NODES || "";
|
|
12011
|
+
const def = Math.max(1, Math.floor(MAX_NODES / 2));
|
|
12012
|
+
const n = raw ? Number.parseInt(raw, 10) : def;
|
|
12013
|
+
const safe2 = Number.isFinite(n) && n > 0 ? n : def;
|
|
12014
|
+
return Math.max(1, Math.min(safe2, MAX_NODES - 1));
|
|
12015
|
+
}
|
|
12016
|
+
function envInt3(name, def) {
|
|
12017
|
+
const n = Number.parseInt(process.env[name] || "", 10);
|
|
12018
|
+
return Number.isFinite(n) && n >= 0 ? n : def;
|
|
12019
|
+
}
|
|
12020
|
+
function cleanupChainArchives(dir, maxBytes = envInt3("AGENT_MOSS_CHAIN_ARCHIVE_MAX_MB", 512) * 1024 * 1024, maxAgeDays = envInt3("AGENT_MOSS_CHAIN_ARCHIVE_MAX_AGE_DAYS", 0)) {
|
|
12021
|
+
let files = [];
|
|
12022
|
+
try {
|
|
12023
|
+
files = fs5.readdirSync(dir).filter((f) => f.startsWith("chain-nodes-") && f.endsWith(".jsonl.gz")).map((f) => path6.join(dir, f)).sort((a, b) => fs5.statSync(a).mtimeMs - fs5.statSync(b).mtimeMs);
|
|
12024
|
+
} catch {
|
|
12025
|
+
return { deleted: 0, files: 0, bytes: 0 };
|
|
12026
|
+
}
|
|
12027
|
+
let removed = 0;
|
|
12028
|
+
if (maxAgeDays > 0) {
|
|
12029
|
+
const cutoff = Date.now() - maxAgeDays * 864e5;
|
|
12030
|
+
files = files.filter((p) => {
|
|
12031
|
+
try {
|
|
12032
|
+
if (fs5.statSync(p).mtimeMs < cutoff) {
|
|
12033
|
+
fs5.unlinkSync(p);
|
|
12034
|
+
removed += 1;
|
|
12035
|
+
return false;
|
|
12036
|
+
}
|
|
12037
|
+
} catch {
|
|
12038
|
+
}
|
|
12039
|
+
return true;
|
|
12040
|
+
});
|
|
12041
|
+
}
|
|
12042
|
+
let total = files.reduce((n, p) => {
|
|
12043
|
+
try {
|
|
12044
|
+
return n + fs5.statSync(p).size;
|
|
12045
|
+
} catch {
|
|
12046
|
+
return n;
|
|
12047
|
+
}
|
|
12048
|
+
}, 0);
|
|
12049
|
+
if (maxBytes > 0) {
|
|
12050
|
+
for (const p of files) {
|
|
12051
|
+
if (total <= maxBytes) break;
|
|
12052
|
+
try {
|
|
12053
|
+
const size = fs5.statSync(p).size;
|
|
12054
|
+
fs5.unlinkSync(p);
|
|
12055
|
+
total -= size;
|
|
12056
|
+
removed += 1;
|
|
12057
|
+
} catch {
|
|
12058
|
+
}
|
|
12059
|
+
}
|
|
12060
|
+
}
|
|
12061
|
+
let remainFiles = 0;
|
|
12062
|
+
let remainBytes = 0;
|
|
12063
|
+
try {
|
|
12064
|
+
for (const f of fs5.readdirSync(dir)) {
|
|
12065
|
+
if (!f.startsWith("chain-nodes-") || !f.endsWith(".jsonl.gz")) continue;
|
|
12066
|
+
remainFiles += 1;
|
|
12067
|
+
remainBytes += fs5.statSync(path6.join(dir, f)).size;
|
|
12068
|
+
}
|
|
12069
|
+
} catch {
|
|
12070
|
+
}
|
|
12071
|
+
return { deleted: removed, files: remainFiles, bytes: remainBytes };
|
|
12072
|
+
}
|
|
12005
12073
|
var DESTROY_RE, NEVER_ACTIVATED_RE, CRED_FILE_RE2, EXFIL_RE2, PORT_RE, BARE_PORT_RE, SOCK_RE, UNIT_RE, PORT_STAGE_RE, STAGES_PATTERNS, CHAINS, COMMON_DIR_RESOURCES2, MAX_NODES, StatefulChainTracker;
|
|
12006
12074
|
var init_stateful = __esm({
|
|
12007
12075
|
"src/engine/formal-engine/stateful.ts"() {
|
|
@@ -12033,7 +12101,7 @@ var init_stateful = __esm({
|
|
|
12033
12101
|
"/data",
|
|
12034
12102
|
"/storage"
|
|
12035
12103
|
]);
|
|
12036
|
-
MAX_NODES =
|
|
12104
|
+
MAX_NODES = resolveMaxNodes();
|
|
12037
12105
|
StatefulChainTracker = class _StatefulChainTracker {
|
|
12038
12106
|
/** 本地接收时刻(实时路径无 called_at 时的兜底时间戳,ISO)。 */
|
|
12039
12107
|
static now() {
|
|
@@ -12140,7 +12208,7 @@ var init_stateful = __esm({
|
|
|
12140
12208
|
* 派生缓存不是原始历史存储;归档失败抛异常,调用方不得丢状态。
|
|
12141
12209
|
*/
|
|
12142
12210
|
rotate(archiveDir, retain) {
|
|
12143
|
-
const keep = Math.max(1, Math.min(retain ??
|
|
12211
|
+
const keep = Math.max(1, Math.min(retain ?? resolveRetainNodes(), MAX_NODES - 1));
|
|
12144
12212
|
if (this.nodes_.length <= keep) return { archived: 0, file: "" };
|
|
12145
12213
|
const old = this.nodes_.slice(0, this.nodes_.length - keep);
|
|
12146
12214
|
const kept = this.nodes_.slice(-keep);
|
|
@@ -12150,6 +12218,16 @@ var init_stateful = __esm({
|
|
|
12150
12218
|
const file = path6.join(dir, `chain-nodes-${safeAgent}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.jsonl.gz`);
|
|
12151
12219
|
const payload = old.map((n) => JSON.stringify(n)).join("\n") + "\n";
|
|
12152
12220
|
fs5.writeFileSync(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
|
|
12221
|
+
try {
|
|
12222
|
+
const c = cleanupChainArchives(dir);
|
|
12223
|
+
if (c.deleted > 0) {
|
|
12224
|
+
console.error(
|
|
12225
|
+
`[AgentMoss] chain-archive \u6E05\u7406: \u5220\u9664 ${c.deleted} \u4E2A\u65E7\u5F52\u6863\uFF08\u5269\u4F59 ${c.files} \u4E2A / ${c.bytes} \u5B57\u8282\uFF09`
|
|
12226
|
+
);
|
|
12227
|
+
}
|
|
12228
|
+
} catch (e) {
|
|
12229
|
+
console.error(`[AgentMoss] chain-archive \u6E05\u7406\u5931\u8D25\uFF08\u7EE7\u7EED\uFF09: ${e?.message ?? e}`);
|
|
12230
|
+
}
|
|
12153
12231
|
this.nodes_ = [];
|
|
12154
12232
|
this.ptr = {};
|
|
12155
12233
|
this.tainted.clear();
|
|
@@ -13395,7 +13473,7 @@ var init_types = __esm({
|
|
|
13395
13473
|
|
|
13396
13474
|
// src/infra/policy-cache.ts
|
|
13397
13475
|
import { createHash as createHash5 } from "crypto";
|
|
13398
|
-
import { existsSync as existsSync17, lstatSync as lstatSync2, readdirSync as
|
|
13476
|
+
import { existsSync as existsSync17, lstatSync as lstatSync2, readdirSync as readdirSync6, readFileSync as readFileSync17, rmdirSync, unlinkSync as unlinkSync5 } from "fs";
|
|
13399
13477
|
import { tmpdir as tmpdir3 } from "os";
|
|
13400
13478
|
import { join as join18 } from "path";
|
|
13401
13479
|
function cacheDir() {
|
|
@@ -13489,7 +13567,7 @@ var init_policy_cache = __esm({
|
|
|
13489
13567
|
invalidate(sessionId, promptSession) {
|
|
13490
13568
|
this.memory.delete(this.cacheKey(sessionId, promptSession));
|
|
13491
13569
|
try {
|
|
13492
|
-
|
|
13570
|
+
unlinkSync5(this.cacheFilePath(sessionId, promptSession));
|
|
13493
13571
|
} catch {
|
|
13494
13572
|
}
|
|
13495
13573
|
}
|
|
@@ -13501,9 +13579,9 @@ var init_policy_cache = __esm({
|
|
|
13501
13579
|
const dir = join18(cacheDir(), safeSessionId);
|
|
13502
13580
|
try {
|
|
13503
13581
|
if (existsSync17(dir)) {
|
|
13504
|
-
for (const f of
|
|
13582
|
+
for (const f of readdirSync6(dir)) {
|
|
13505
13583
|
try {
|
|
13506
|
-
|
|
13584
|
+
unlinkSync5(join18(dir, f));
|
|
13507
13585
|
} catch {
|
|
13508
13586
|
}
|
|
13509
13587
|
}
|
|
@@ -13516,10 +13594,10 @@ var init_policy_cache = __esm({
|
|
|
13516
13594
|
this.memory.clear();
|
|
13517
13595
|
try {
|
|
13518
13596
|
if (existsSync17(cacheDir())) {
|
|
13519
|
-
for (const sessionDir of
|
|
13597
|
+
for (const sessionDir of readdirSync6(cacheDir())) {
|
|
13520
13598
|
const dir = join18(cacheDir(), sessionDir);
|
|
13521
13599
|
try {
|
|
13522
|
-
for (const f of
|
|
13600
|
+
for (const f of readdirSync6(dir)) unlinkSync5(join18(dir, f));
|
|
13523
13601
|
rmdirSync(dir);
|
|
13524
13602
|
} catch {
|
|
13525
13603
|
}
|
|
@@ -14882,7 +14960,7 @@ var init_routes = __esm({
|
|
|
14882
14960
|
// src/console/router.ts
|
|
14883
14961
|
import { Hono } from "hono";
|
|
14884
14962
|
import { timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
14885
|
-
import { readFileSync as readFileSync20, existsSync as existsSync20, unlinkSync as
|
|
14963
|
+
import { readFileSync as readFileSync20, existsSync as existsSync20, unlinkSync as unlinkSync6 } from "fs";
|
|
14886
14964
|
import { join as join22, dirname as dirname14 } from "path";
|
|
14887
14965
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
14888
14966
|
function getConsoleToken() {
|
|
@@ -15227,7 +15305,7 @@ function createConsoleRouter() {
|
|
|
15227
15305
|
const defaults = generateSourceDefaults();
|
|
15228
15306
|
try {
|
|
15229
15307
|
const p = getRuntimeConfigPath();
|
|
15230
|
-
if (existsSync20(p))
|
|
15308
|
+
if (existsSync20(p)) unlinkSync6(p);
|
|
15231
15309
|
} catch {
|
|
15232
15310
|
}
|
|
15233
15311
|
return c.json(withL22View(defaults));
|
|
@@ -15590,7 +15668,7 @@ async function startUnixSocketServer(socketPath = "/var/run/agent_moss/agent_mos
|
|
|
15590
15668
|
},
|
|
15591
15669
|
serve: async () => {
|
|
15592
15670
|
failFastOnAuthError();
|
|
15593
|
-
const { mkdirSync: mkdirSync13, existsSync: existsSync23, unlinkSync:
|
|
15671
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync23, unlinkSync: unlinkSync7 } = await import("fs");
|
|
15594
15672
|
const { dirname: dirname17 } = await import("path");
|
|
15595
15673
|
const dir = dirname17(socketPath);
|
|
15596
15674
|
if (dir) {
|
|
@@ -15617,7 +15695,7 @@ async function startUnixSocketServer(socketPath = "/var/run/agent_moss/agent_mos
|
|
|
15617
15695
|
);
|
|
15618
15696
|
} else {
|
|
15619
15697
|
try {
|
|
15620
|
-
|
|
15698
|
+
unlinkSync7(socketPath);
|
|
15621
15699
|
console.log(`[AgentMoss] \u6E05\u7406\u6B8B\u7559 socket \u6587\u4EF6: ${socketPath}`);
|
|
15622
15700
|
} catch {
|
|
15623
15701
|
}
|
|
@@ -15729,7 +15807,7 @@ __export(rules_tools_exports, {
|
|
|
15729
15807
|
rulesStatusText: () => rulesStatusText,
|
|
15730
15808
|
templateSourceDir: () => templateSourceDir
|
|
15731
15809
|
});
|
|
15732
|
-
import { existsSync as existsSync22, mkdirSync as mkdirSync12, readdirSync as
|
|
15810
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync12, readdirSync as readdirSync8, readFileSync as readFileSync21, writeFileSync as writeFileSync9 } from "fs";
|
|
15733
15811
|
import { dirname as dirname16, join as join24 } from "path";
|
|
15734
15812
|
import { fileURLToPath as fileURLToPath12 } from "url";
|
|
15735
15813
|
function initRulesDir(targetDir, opts = {}) {
|
|
@@ -15776,7 +15854,7 @@ function templateFiles(dirs) {
|
|
|
15776
15854
|
const out = [];
|
|
15777
15855
|
for (const d of dirs) {
|
|
15778
15856
|
try {
|
|
15779
|
-
for (const name of
|
|
15857
|
+
for (const name of readdirSync8(d)) {
|
|
15780
15858
|
if (name.endsWith(".json.\u793A\u4F8B")) out.push(join24(d, name));
|
|
15781
15859
|
}
|
|
15782
15860
|
} catch {
|
|
@@ -10712,6 +10712,11 @@ import * as fs5 from "fs";
|
|
|
10712
10712
|
import * as os3 from "os";
|
|
10713
10713
|
import * as path6 from "path";
|
|
10714
10714
|
import { gzipSync } from "zlib";
|
|
10715
|
+
function resolveMaxNodes() {
|
|
10716
|
+
const n = Number.parseInt(process.env.AGENT_MOSS_CHAIN_MAX_NODES || "100000", 10);
|
|
10717
|
+
return Number.isFinite(n) && n > 0 ? n : 1e5;
|
|
10718
|
+
}
|
|
10719
|
+
var MAX_NODES = resolveMaxNodes();
|
|
10715
10720
|
|
|
10716
10721
|
// src/engine/formal-engine/chain_state.ts
|
|
10717
10722
|
init_esm_shims();
|
package/dist/server.js
CHANGED
|
@@ -976,7 +976,7 @@ function logRoots() {
|
|
|
976
976
|
}
|
|
977
977
|
function reviewRoots() {
|
|
978
978
|
const roots = [join4(homeDir(), ".local", "share", "agent_gate")];
|
|
979
|
-
for (const name of ["AGENT_GATE_DB", "AGENT_GATE_JSON_PATH"]) {
|
|
979
|
+
for (const name of ["AGENT_GATE_DB", "AGENT_GATE_JSON_PATH", "AGENT_GATE_DATA_DIR"]) {
|
|
980
980
|
const v = env(name);
|
|
981
981
|
if (v) roots.push(existsSync3(v) && lstatSync(v).isDirectory() ? v : dirname2(v));
|
|
982
982
|
}
|
|
@@ -11413,6 +11413,74 @@ function lifecycleFor(detail, stage, isError) {
|
|
|
11413
11413
|
if (detail.includes(">>") || detail.includes(">")) return "alive";
|
|
11414
11414
|
return "";
|
|
11415
11415
|
}
|
|
11416
|
+
function resolveMaxNodes() {
|
|
11417
|
+
const n = Number.parseInt(process.env.AGENT_MOSS_CHAIN_MAX_NODES || "100000", 10);
|
|
11418
|
+
return Number.isFinite(n) && n > 0 ? n : 1e5;
|
|
11419
|
+
}
|
|
11420
|
+
function resolveRetainNodes() {
|
|
11421
|
+
const raw = process.env.AGENT_MOSS_CHAIN_RETAIN_NODES || "";
|
|
11422
|
+
const def = Math.max(1, Math.floor(MAX_NODES / 2));
|
|
11423
|
+
const n = raw ? Number.parseInt(raw, 10) : def;
|
|
11424
|
+
const safe2 = Number.isFinite(n) && n > 0 ? n : def;
|
|
11425
|
+
return Math.max(1, Math.min(safe2, MAX_NODES - 1));
|
|
11426
|
+
}
|
|
11427
|
+
function envInt3(name, def) {
|
|
11428
|
+
const n = Number.parseInt(process.env[name] || "", 10);
|
|
11429
|
+
return Number.isFinite(n) && n >= 0 ? n : def;
|
|
11430
|
+
}
|
|
11431
|
+
function cleanupChainArchives(dir, maxBytes = envInt3("AGENT_MOSS_CHAIN_ARCHIVE_MAX_MB", 512) * 1024 * 1024, maxAgeDays = envInt3("AGENT_MOSS_CHAIN_ARCHIVE_MAX_AGE_DAYS", 0)) {
|
|
11432
|
+
let files = [];
|
|
11433
|
+
try {
|
|
11434
|
+
files = fs5.readdirSync(dir).filter((f) => f.startsWith("chain-nodes-") && f.endsWith(".jsonl.gz")).map((f) => path6.join(dir, f)).sort((a, b) => fs5.statSync(a).mtimeMs - fs5.statSync(b).mtimeMs);
|
|
11435
|
+
} catch {
|
|
11436
|
+
return { deleted: 0, files: 0, bytes: 0 };
|
|
11437
|
+
}
|
|
11438
|
+
let removed = 0;
|
|
11439
|
+
if (maxAgeDays > 0) {
|
|
11440
|
+
const cutoff = Date.now() - maxAgeDays * 864e5;
|
|
11441
|
+
files = files.filter((p) => {
|
|
11442
|
+
try {
|
|
11443
|
+
if (fs5.statSync(p).mtimeMs < cutoff) {
|
|
11444
|
+
fs5.unlinkSync(p);
|
|
11445
|
+
removed += 1;
|
|
11446
|
+
return false;
|
|
11447
|
+
}
|
|
11448
|
+
} catch {
|
|
11449
|
+
}
|
|
11450
|
+
return true;
|
|
11451
|
+
});
|
|
11452
|
+
}
|
|
11453
|
+
let total = files.reduce((n, p) => {
|
|
11454
|
+
try {
|
|
11455
|
+
return n + fs5.statSync(p).size;
|
|
11456
|
+
} catch {
|
|
11457
|
+
return n;
|
|
11458
|
+
}
|
|
11459
|
+
}, 0);
|
|
11460
|
+
if (maxBytes > 0) {
|
|
11461
|
+
for (const p of files) {
|
|
11462
|
+
if (total <= maxBytes) break;
|
|
11463
|
+
try {
|
|
11464
|
+
const size = fs5.statSync(p).size;
|
|
11465
|
+
fs5.unlinkSync(p);
|
|
11466
|
+
total -= size;
|
|
11467
|
+
removed += 1;
|
|
11468
|
+
} catch {
|
|
11469
|
+
}
|
|
11470
|
+
}
|
|
11471
|
+
}
|
|
11472
|
+
let remainFiles = 0;
|
|
11473
|
+
let remainBytes = 0;
|
|
11474
|
+
try {
|
|
11475
|
+
for (const f of fs5.readdirSync(dir)) {
|
|
11476
|
+
if (!f.startsWith("chain-nodes-") || !f.endsWith(".jsonl.gz")) continue;
|
|
11477
|
+
remainFiles += 1;
|
|
11478
|
+
remainBytes += fs5.statSync(path6.join(dir, f)).size;
|
|
11479
|
+
}
|
|
11480
|
+
} catch {
|
|
11481
|
+
}
|
|
11482
|
+
return { deleted: removed, files: remainFiles, bytes: remainBytes };
|
|
11483
|
+
}
|
|
11416
11484
|
var DESTROY_RE, NEVER_ACTIVATED_RE, CRED_FILE_RE2, EXFIL_RE2, PORT_RE, BARE_PORT_RE, SOCK_RE, UNIT_RE, PORT_STAGE_RE, STAGES_PATTERNS, CHAINS, COMMON_DIR_RESOURCES2, MAX_NODES, StatefulChainTracker;
|
|
11417
11485
|
var init_stateful = __esm({
|
|
11418
11486
|
"src/engine/formal-engine/stateful.ts"() {
|
|
@@ -11444,7 +11512,7 @@ var init_stateful = __esm({
|
|
|
11444
11512
|
"/data",
|
|
11445
11513
|
"/storage"
|
|
11446
11514
|
]);
|
|
11447
|
-
MAX_NODES =
|
|
11515
|
+
MAX_NODES = resolveMaxNodes();
|
|
11448
11516
|
StatefulChainTracker = class _StatefulChainTracker {
|
|
11449
11517
|
/** 本地接收时刻(实时路径无 called_at 时的兜底时间戳,ISO)。 */
|
|
11450
11518
|
static now() {
|
|
@@ -11551,7 +11619,7 @@ var init_stateful = __esm({
|
|
|
11551
11619
|
* 派生缓存不是原始历史存储;归档失败抛异常,调用方不得丢状态。
|
|
11552
11620
|
*/
|
|
11553
11621
|
rotate(archiveDir, retain) {
|
|
11554
|
-
const keep = Math.max(1, Math.min(retain ??
|
|
11622
|
+
const keep = Math.max(1, Math.min(retain ?? resolveRetainNodes(), MAX_NODES - 1));
|
|
11555
11623
|
if (this.nodes_.length <= keep) return { archived: 0, file: "" };
|
|
11556
11624
|
const old = this.nodes_.slice(0, this.nodes_.length - keep);
|
|
11557
11625
|
const kept = this.nodes_.slice(-keep);
|
|
@@ -11561,6 +11629,16 @@ var init_stateful = __esm({
|
|
|
11561
11629
|
const file = path6.join(dir, `chain-nodes-${safeAgent}-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.jsonl.gz`);
|
|
11562
11630
|
const payload = old.map((n) => JSON.stringify(n)).join("\n") + "\n";
|
|
11563
11631
|
fs5.writeFileSync(file, gzipSync(Buffer.from(payload, "utf-8")), { mode: 384 });
|
|
11632
|
+
try {
|
|
11633
|
+
const c = cleanupChainArchives(dir);
|
|
11634
|
+
if (c.deleted > 0) {
|
|
11635
|
+
console.error(
|
|
11636
|
+
`[AgentMoss] chain-archive \u6E05\u7406: \u5220\u9664 ${c.deleted} \u4E2A\u65E7\u5F52\u6863\uFF08\u5269\u4F59 ${c.files} \u4E2A / ${c.bytes} \u5B57\u8282\uFF09`
|
|
11637
|
+
);
|
|
11638
|
+
}
|
|
11639
|
+
} catch (e) {
|
|
11640
|
+
console.error(`[AgentMoss] chain-archive \u6E05\u7406\u5931\u8D25\uFF08\u7EE7\u7EED\uFF09: ${e?.message ?? e}`);
|
|
11641
|
+
}
|
|
11564
11642
|
this.nodes_ = [];
|
|
11565
11643
|
this.ptr = {};
|
|
11566
11644
|
this.tainted.clear();
|
|
@@ -13126,7 +13204,7 @@ init_security_policy();
|
|
|
13126
13204
|
init_paths();
|
|
13127
13205
|
init_config();
|
|
13128
13206
|
import { createHash as createHash5 } from "crypto";
|
|
13129
|
-
import { existsSync as existsSync17, lstatSync as lstatSync2, readdirSync as
|
|
13207
|
+
import { existsSync as existsSync17, lstatSync as lstatSync2, readdirSync as readdirSync6, readFileSync as readFileSync17, rmdirSync, unlinkSync as unlinkSync5 } from "fs";
|
|
13130
13208
|
import { tmpdir as tmpdir2 } from "os";
|
|
13131
13209
|
import { join as join17 } from "path";
|
|
13132
13210
|
var CACHE_DIR = join17(tmpdir2(), "agent_moss_policy_cache");
|
|
@@ -13208,7 +13286,7 @@ var PolicyCache = class {
|
|
|
13208
13286
|
invalidate(sessionId, promptSession) {
|
|
13209
13287
|
this.memory.delete(this.cacheKey(sessionId, promptSession));
|
|
13210
13288
|
try {
|
|
13211
|
-
|
|
13289
|
+
unlinkSync5(this.cacheFilePath(sessionId, promptSession));
|
|
13212
13290
|
} catch {
|
|
13213
13291
|
}
|
|
13214
13292
|
}
|
|
@@ -13220,9 +13298,9 @@ var PolicyCache = class {
|
|
|
13220
13298
|
const dir = join17(cacheDir(), safeSessionId);
|
|
13221
13299
|
try {
|
|
13222
13300
|
if (existsSync17(dir)) {
|
|
13223
|
-
for (const f of
|
|
13301
|
+
for (const f of readdirSync6(dir)) {
|
|
13224
13302
|
try {
|
|
13225
|
-
|
|
13303
|
+
unlinkSync5(join17(dir, f));
|
|
13226
13304
|
} catch {
|
|
13227
13305
|
}
|
|
13228
13306
|
}
|
|
@@ -13235,10 +13313,10 @@ var PolicyCache = class {
|
|
|
13235
13313
|
this.memory.clear();
|
|
13236
13314
|
try {
|
|
13237
13315
|
if (existsSync17(cacheDir())) {
|
|
13238
|
-
for (const sessionDir of
|
|
13316
|
+
for (const sessionDir of readdirSync6(cacheDir())) {
|
|
13239
13317
|
const dir = join17(cacheDir(), sessionDir);
|
|
13240
13318
|
try {
|
|
13241
|
-
for (const f of
|
|
13319
|
+
for (const f of readdirSync6(dir)) unlinkSync5(join17(dir, f));
|
|
13242
13320
|
rmdirSync(dir);
|
|
13243
13321
|
} catch {
|
|
13244
13322
|
}
|
|
@@ -14525,7 +14603,7 @@ init_asset_dir();
|
|
|
14525
14603
|
init_rules_mode();
|
|
14526
14604
|
import { Hono } from "hono";
|
|
14527
14605
|
import { timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
14528
|
-
import { readFileSync as readFileSync20, existsSync as existsSync20, unlinkSync as
|
|
14606
|
+
import { readFileSync as readFileSync20, existsSync as existsSync20, unlinkSync as unlinkSync6 } from "fs";
|
|
14529
14607
|
import { join as join21, dirname as dirname14 } from "path";
|
|
14530
14608
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
14531
14609
|
var __dirname10 = dirname14(fileURLToPath11(import.meta.url));
|
|
@@ -14873,7 +14951,7 @@ function createConsoleRouter() {
|
|
|
14873
14951
|
const defaults = generateSourceDefaults();
|
|
14874
14952
|
try {
|
|
14875
14953
|
const p = getRuntimeConfigPath();
|
|
14876
|
-
if (existsSync20(p))
|
|
14954
|
+
if (existsSync20(p)) unlinkSync6(p);
|
|
14877
14955
|
} catch {
|
|
14878
14956
|
}
|
|
14879
14957
|
return c.json(withL22View(defaults));
|
|
@@ -15253,7 +15331,7 @@ async function startUnixSocketServer(socketPath = "/var/run/agent_moss/agent_mos
|
|
|
15253
15331
|
},
|
|
15254
15332
|
serve: async () => {
|
|
15255
15333
|
failFastOnAuthError();
|
|
15256
|
-
const { mkdirSync: mkdirSync11, existsSync: existsSync22, unlinkSync:
|
|
15334
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync22, unlinkSync: unlinkSync7 } = await import("fs");
|
|
15257
15335
|
const { dirname: dirname16 } = await import("path");
|
|
15258
15336
|
const dir = dirname16(socketPath);
|
|
15259
15337
|
if (dir) {
|
|
@@ -15280,7 +15358,7 @@ async function startUnixSocketServer(socketPath = "/var/run/agent_moss/agent_mos
|
|
|
15280
15358
|
);
|
|
15281
15359
|
} else {
|
|
15282
15360
|
try {
|
|
15283
|
-
|
|
15361
|
+
unlinkSync7(socketPath);
|
|
15284
15362
|
console.log(`[AgentMoss] \u6E05\u7406\u6B8B\u7559 socket \u6587\u4EF6: ${socketPath}`);
|
|
15285
15363
|
} catch {
|
|
15286
15364
|
}
|