@staix/agent-hub 0.43.0 → 0.44.0
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/CHANGELOG.md +21 -0
- package/README.md +1 -1
- package/docs/agent-notes/daemon.md +3 -3
- package/docs/agent-notes/local-worker.md +1 -0
- package/docs/agent-notes/tasks.md +2 -1
- package/docs/agent-notes/tests.md +1 -1
- package/docs/design/agent-hub-architecture.md +2 -0
- package/docs/design/supervision.md +13 -1
- package/docs/design/task-board.md +7 -1
- package/docs/dogfood.md +8 -2
- package/docs/events.md +4 -2
- package/docs/memory.md +3 -3
- package/docs/operations.md +37 -17
- package/docs/quickstart.md +8 -2
- package/docs/research.md +2 -0
- package/docs/sdlc.md +5 -2
- package/docs/security.md +2 -2
- package/docs/verification/2026-11-11-supervision-pilot-1221.md +864 -0
- package/docs/verification/2026-11-19-0.44.0.md +60 -0
- package/docs/verified.json +22 -22
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +183 -105
- package/plugins/agent-hub/server.js +202 -121
- package/src/cli/main.ts +1 -1
- package/src/cli/output.ts +2 -2
- package/src/cli/sdlc-output.ts +7 -1
- package/src/cli/upgrade.ts +9 -3
- package/src/hub/board.ts +14 -1
- package/src/hub/bus.ts +4 -0
- package/src/hub/claude-shell-wrapper.ts +2 -1
- package/src/hub/control-write-trace.ts +39 -2
- package/src/hub/daemon.ts +66 -24
- package/src/hub/facts.ts +30 -0
- package/src/hub/hub-tools.ts +1 -1
- package/src/hub/quota-events.ts +40 -0
- package/src/hub/recovery-store.ts +21 -3
- package/src/hub/report.ts +1 -1
- package/src/hub/research-quality.ts +5 -1
- package/src/hub/research-record.ts +3 -2
- package/src/hub/restart.ts +49 -2
- package/src/hub/runtime-capture-prune.ts +9 -1
- package/src/hub/runtime-prune-health.ts +5 -1
- package/src/hub/sdlc-merge.ts +7 -3
- package/src/hub/sdlc-metrics.ts +15 -6
- package/src/hub/sdlc.ts +18 -6
- package/src/hub/snapshots.ts +43 -0
- package/src/hub/supervision-rules.ts +2 -2
- package/src/hub/task-shell-command.ts +124 -0
- package/src/hub/tasks.ts +124 -20
- package/src/hub/worktree-shelf.ts +2 -1
- package/src/local/sandbox.ts +2 -1
- package/src/local/shell-environment.ts +6 -0
- package/src/memory/brief.ts +10 -1
|
@@ -9140,11 +9140,18 @@ var init_deny = __esm(() => {
|
|
|
9140
9140
|
CONFIG_WORKTREE_NAME = [`^.*/${hfsFoldedName("config")}\\.[^/]*$`, `^.*/[^/]*${hfsFoldedName("worktree")}$`];
|
|
9141
9141
|
});
|
|
9142
9142
|
|
|
9143
|
+
// src/local/shell-environment.ts
|
|
9144
|
+
import { join as join14 } from "path";
|
|
9145
|
+
function sandboxCommandEnvironment(base, own) {
|
|
9146
|
+
return { BUN_INSTALL_CACHE_DIR: join14(own, "bun-cache"), NPM_CONFIG_CACHE: join14(own, "npm-cache"), ...base, TMPDIR: `${own}/` };
|
|
9147
|
+
}
|
|
9148
|
+
var init_shell_environment = () => {};
|
|
9149
|
+
|
|
9143
9150
|
// src/local/sandbox.ts
|
|
9144
9151
|
import { spawn as spawn8, spawnSync as spawnSync3 } from "child_process";
|
|
9145
9152
|
import { existsSync as existsSync7, lstatSync as lstatSync13, mkdtempSync as mkdtempSync4, readdirSync as readdirSync2, rmdirSync as rmdirSync2, rmSync as rmSync5 } from "fs";
|
|
9146
9153
|
import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
|
|
9147
|
-
import { dirname as dirname10, join as
|
|
9154
|
+
import { dirname as dirname10, join as join15, resolve as resolve10 } from "path";
|
|
9148
9155
|
function developerDir() {
|
|
9149
9156
|
const out = spawnSync3("xcode-select", ["-p"], { encoding: "utf8" });
|
|
9150
9157
|
let dir = out.status === 0 ? out.stdout.trim() : "";
|
|
@@ -9163,7 +9170,7 @@ function externalGitDirs(root) {
|
|
|
9163
9170
|
}
|
|
9164
9171
|
function worktreesRoot(root) {
|
|
9165
9172
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir"], { encoding: "utf8" });
|
|
9166
|
-
return out.status === 0 && out.stdout.trim() ?
|
|
9173
|
+
return out.status === 0 && out.stdout.trim() ? join15(resolve10(root, out.stdout.trim()), "worktrees") : undefined;
|
|
9167
9174
|
}
|
|
9168
9175
|
function moduleGitDirs(root) {
|
|
9169
9176
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir", "--absolute-git-dir"], { encoding: "utf8" });
|
|
@@ -9174,12 +9181,12 @@ function moduleGitDirs(root) {
|
|
|
9174
9181
|
if (!commonRaw || !ownRaw)
|
|
9175
9182
|
return [];
|
|
9176
9183
|
const common = resolve10(root, commonRaw), own = resolve10(root, ownRaw);
|
|
9177
|
-
const roots = new Set([
|
|
9184
|
+
const roots = new Set([join15(common, "modules"), join15(own, "modules")]);
|
|
9178
9185
|
try {
|
|
9179
|
-
for (const e of readdirSync2(
|
|
9186
|
+
for (const e of readdirSync2(join15(common, "worktrees"), { withFileTypes: true })) {
|
|
9180
9187
|
if (!e.isDirectory())
|
|
9181
9188
|
continue;
|
|
9182
|
-
const modules =
|
|
9189
|
+
const modules = join15(common, "worktrees", e.name, "modules");
|
|
9183
9190
|
if (existsSync7(modules))
|
|
9184
9191
|
roots.add(modules);
|
|
9185
9192
|
}
|
|
@@ -9203,7 +9210,7 @@ function moduleGitDirs(root) {
|
|
|
9203
9210
|
}
|
|
9204
9211
|
for (const e of entries)
|
|
9205
9212
|
if (e.isDirectory())
|
|
9206
|
-
walk(
|
|
9213
|
+
walk(join15(dir, e.name), depth + 1);
|
|
9207
9214
|
};
|
|
9208
9215
|
walk(modulesRoot, 0);
|
|
9209
9216
|
const found = nesting >= MODULE_DEPTH ? [] : dirs;
|
|
@@ -9213,11 +9220,11 @@ function moduleGitDirs(root) {
|
|
|
9213
9220
|
entries.add(p);
|
|
9214
9221
|
trees.push({ root: modulesRoot, entries: [...entries], dirs: found });
|
|
9215
9222
|
for (const d of found) {
|
|
9216
|
-
tree(
|
|
9223
|
+
tree(join15(d, "modules"), nesting + 1);
|
|
9217
9224
|
try {
|
|
9218
|
-
for (const e of readdirSync2(
|
|
9219
|
-
if (e.isDirectory() && existsSync7(
|
|
9220
|
-
tree(
|
|
9225
|
+
for (const e of readdirSync2(join15(d, "worktrees"), { withFileTypes: true })) {
|
|
9226
|
+
if (e.isDirectory() && existsSync7(join15(d, "worktrees", e.name, "modules")))
|
|
9227
|
+
tree(join15(d, "worktrees", e.name, "modules"), nesting + 1);
|
|
9221
9228
|
}
|
|
9222
9229
|
} catch {}
|
|
9223
9230
|
}
|
|
@@ -9228,14 +9235,14 @@ function moduleGitDirs(root) {
|
|
|
9228
9235
|
}
|
|
9229
9236
|
function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
9230
9237
|
const home = homedir4();
|
|
9231
|
-
const inHome = (p) => p.startsWith("~/") ?
|
|
9238
|
+
const inHome = (p) => p.startsWith("~/") ? join15(home, p.slice(2)) : p;
|
|
9232
9239
|
const root = realPath(cwd);
|
|
9233
9240
|
const gitDirs = externalGitDirs(root);
|
|
9234
9241
|
const moduleGit = moduleGitDirs(root);
|
|
9235
9242
|
const worktrees = worktreesRoot(root);
|
|
9236
9243
|
const creds = [".ssh", ".aws", ".gnupg", ".config/gh", ".config/gcloud", ".kube", ".docker", ".netrc", ".npmrc", ".omniroute", ".claude", ".codex", ".kimi-code", "Library/Keychains"];
|
|
9237
9244
|
const dev = developerDir();
|
|
9238
|
-
const readable = [root, ...HOME_READABLE.map((p) =>
|
|
9245
|
+
const readable = [root, ...HOME_READABLE.map((p) => join15(home, p)), ...readAllow.map(inHome), ...gitDirs, ...dev ? [dev] : []];
|
|
9239
9246
|
const subpaths = (paths) => paths.map((p) => `(subpath ${q(p)})`).join(" ");
|
|
9240
9247
|
const globals = (names) => names.map((n) => `(global-name ${q(n)})`).join(" ");
|
|
9241
9248
|
const proxy = typeof network === "object" ? `(allow network-outbound (remote ip ${q(`localhost:${network.proxyPort}`)}))` : undefined;
|
|
@@ -9253,7 +9260,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9253
9260
|
'(allow file-ioctl (regex #"^/dev/"))',
|
|
9254
9261
|
...proxy ? [proxy] : network ? ["(allow network*)"] : []
|
|
9255
9262
|
];
|
|
9256
|
-
const places = `${creds.map((c) => `(subpath ${q(
|
|
9263
|
+
const places = `${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")} ${denyRegexes(root, deny, false).join(" ")}`;
|
|
9257
9264
|
return [
|
|
9258
9265
|
"(version 1)",
|
|
9259
9266
|
...start,
|
|
@@ -9261,7 +9268,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9261
9268
|
...readOnly.length ? ['(allow file-write* (literal "/dev/null"))'] : [`(allow file-write* (subpath ${q(root)}) (regex #"^/dev/") ${gitDirs.map((d) => `(subpath ${q(d)})`).join(" ")})`],
|
|
9262
9269
|
`(deny file-write* ${hubWriteRegexes(root, gitDirs, moduleGit, worktrees).join(" ")})`,
|
|
9263
9270
|
...worktrees ? objectStoreRules(dirname10(worktrees)) : [],
|
|
9264
|
-
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(
|
|
9271
|
+
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")})`,
|
|
9265
9272
|
`(deny file-read* file-write* ${denyRegexes(root, deny).join(" ")})`,
|
|
9266
9273
|
...network ? [`(allow file-read* ${CA_BUNDLES.map((p) => `(literal ${q(p)})`).join(" ")} (regex ${q("/certifi/cacert\\.pem$")}))`, `(deny file-read* file-write* ${places})`] : []
|
|
9267
9274
|
].join(`
|
|
@@ -9277,10 +9284,10 @@ function sandboxedExec(argv, opts) {
|
|
|
9277
9284
|
if (opts.signal?.aborted)
|
|
9278
9285
|
return Promise.resolve({ code: null, output: "error: command cancelled before execution" });
|
|
9279
9286
|
return new Promise((resolve) => {
|
|
9280
|
-
const own = realPath(mkdtempSync4(
|
|
9287
|
+
const own = realPath(mkdtempSync4(join15(tmpdir4(), "ahub-cmd-")));
|
|
9281
9288
|
const sandbox = `${opts.profile}
|
|
9282
9289
|
(allow file-read* ${opts.readOnlyData ? "" : "file-write* "}process-exec (subpath ${q(own)}))`;
|
|
9283
|
-
const env = { PATH: process.env.PATH ?? "/usr/bin:/bin", HOME: homedir4(), LANG: process.env.LANG ?? "en_US.UTF-8", TERM: "dumb", ...opts.env,
|
|
9290
|
+
const env = sandboxCommandEnvironment({ PATH: process.env.PATH ?? "/usr/bin:/bin", HOME: homedir4(), LANG: process.env.LANG ?? "en_US.UTF-8", TERM: "dumb", ...opts.env }, own);
|
|
9284
9291
|
const child = spawn8(SANDBOX_EXEC, ["-p", sandbox, ...argv], { cwd: opts.cwd, env, stdio: ["ignore", "pipe", "pipe"], detached: true });
|
|
9285
9292
|
let output = "";
|
|
9286
9293
|
let killRequested = false;
|
|
@@ -9346,7 +9353,7 @@ async function probeCommand(argv, opts) {
|
|
|
9346
9353
|
} catch {
|
|
9347
9354
|
return { code: null, output: "error: probe command authority or environment unavailable", quiescent: true };
|
|
9348
9355
|
}
|
|
9349
|
-
const own = realPath(mkdtempSync4(
|
|
9356
|
+
const own = realPath(mkdtempSync4(join15(proof.temporaryRoot, "command-")));
|
|
9350
9357
|
const created = lstatSync13(own);
|
|
9351
9358
|
let removed = false;
|
|
9352
9359
|
const dropOwn = () => {
|
|
@@ -9445,6 +9452,7 @@ var init_sandbox = __esm(() => {
|
|
|
9445
9452
|
init_git();
|
|
9446
9453
|
init_deny();
|
|
9447
9454
|
init_child_process();
|
|
9455
|
+
init_shell_environment();
|
|
9448
9456
|
q = sbplString;
|
|
9449
9457
|
HOME_READABLE = [".bun", ".cargo", ".rustup", ".local", ".npm", ".cache", ".pyenv", ".nvm", ".deno", "go", ".gitconfig", ".config/git", "Library/Caches", ".volta", ".asdf", ".nodenv", ".rbenv", ".sdkman", "Library/Application Support/fnm", "Library/pnpm"];
|
|
9450
9458
|
CA_BUNDLES = ["/private/etc/ssl/cert.pem", "/opt/homebrew/etc/ca-certificates/cert.pem", "/opt/homebrew/etc/openssl@3/cert.pem", "/usr/local/etc/ca-certificates/cert.pem", "/usr/local/etc/openssl@3/cert.pem"];
|
|
@@ -9956,7 +9964,7 @@ var init_probe_errors = __esm(() => {
|
|
|
9956
9964
|
|
|
9957
9965
|
// src/local/probe-workspace.ts
|
|
9958
9966
|
import { chmodSync as chmodSync2, constants as constants6, closeSync as closeSync7, fstatSync as fstatSync6, lstatSync as lstatSync15, mkdirSync as mkdirSync8, mkdtempSync as mkdtempSync5, openSync as openSync7, opendirSync as opendirSync2, readSync as readSync4, rmSync as rmSync6, rmdirSync as rmdirSync3, unlinkSync as unlinkSync3, writeFileSync as writeFileSync7 } from "fs";
|
|
9959
|
-
import { dirname as dirname11, isAbsolute as isAbsolute6, join as
|
|
9967
|
+
import { dirname as dirname11, isAbsolute as isAbsolute6, join as join16 } from "path";
|
|
9960
9968
|
function refused() {
|
|
9961
9969
|
throw new Error("probe workspace source, role, path or resource proof is unavailable");
|
|
9962
9970
|
}
|
|
@@ -10017,7 +10025,7 @@ var init_probe_workspace = __esm(() => {
|
|
|
10017
10025
|
|
|
10018
10026
|
// src/local/tools.ts
|
|
10019
10027
|
import { lstatSync as lstatSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync7, statSync as statSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
10020
|
-
import { dirname as dirname12, join as
|
|
10028
|
+
import { dirname as dirname12, join as join17, relative as relative4, resolve as resolve11 } from "path";
|
|
10021
10029
|
function probeCurrent(probe) {
|
|
10022
10030
|
try {
|
|
10023
10031
|
probe.current();
|
|
@@ -10112,7 +10120,7 @@ function guardPath(ctx, path, mode) {
|
|
|
10112
10120
|
throw new ProbeToolRefusal("nonregular_target");
|
|
10113
10121
|
throw new Error(`${path} goes through a dangling symlink`);
|
|
10114
10122
|
}
|
|
10115
|
-
const real =
|
|
10123
|
+
const real = join17(realExisting, relative4(existing, abs));
|
|
10116
10124
|
const rel = relative4(root, real);
|
|
10117
10125
|
if (rel.startsWith("..") || resolve11(root, rel) !== real) {
|
|
10118
10126
|
if (ctx.probe)
|
|
@@ -10454,7 +10462,7 @@ __export(exports_pi, {
|
|
|
10454
10462
|
});
|
|
10455
10463
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10456
10464
|
import { existsSync as existsSync8, mkdirSync as mkdirSync10 } from "fs";
|
|
10457
|
-
import { join as
|
|
10465
|
+
import { join as join18, resolve as resolve12 } from "path";
|
|
10458
10466
|
import { spawn as spawn9 } from "child_process";
|
|
10459
10467
|
function piVersionAsync(command, cwd, timeoutMs = 1e4) {
|
|
10460
10468
|
const [bin, ...prefix] = command;
|
|
@@ -11053,7 +11061,7 @@ var init_pi = __esm(() => {
|
|
|
11053
11061
|
this.approvalStopReason = "";
|
|
11054
11062
|
this.approvalAbortSent = false;
|
|
11055
11063
|
mkdirSync10(this.opts.stateDir, { recursive: true });
|
|
11056
|
-
const sessions =
|
|
11064
|
+
const sessions = join18(this.opts.stateDir, "pi-sessions");
|
|
11057
11065
|
mkdirSync10(sessions, { recursive: true, mode: 448 });
|
|
11058
11066
|
if (this.opts.sessionFile) {
|
|
11059
11067
|
try {
|
|
@@ -11116,7 +11124,7 @@ var init_pi = __esm(() => {
|
|
|
11116
11124
|
return new Response("not found", { status: 404 });
|
|
11117
11125
|
} });
|
|
11118
11126
|
this.server = bridge;
|
|
11119
|
-
const extension = resolve12(
|
|
11127
|
+
const extension = resolve12(join18(import.meta.dir, "../pi/extension.ts"));
|
|
11120
11128
|
const inherited = {};
|
|
11121
11129
|
for (const key of ["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"])
|
|
11122
11130
|
if (process.env[key])
|
|
@@ -12655,7 +12663,7 @@ var init_shipped_roles = __esm(() => {
|
|
|
12655
12663
|
// src/hub/roles.ts
|
|
12656
12664
|
import { createHash as createHash7 } from "crypto";
|
|
12657
12665
|
import { constants as constants7, closeSync as closeSync8, fstatSync as fstatSync7, lstatSync as lstatSync17, openSync as openSync8, readSync as readSync5, readdirSync as readdirSync3 } from "fs";
|
|
12658
|
-
import { join as
|
|
12666
|
+
import { join as join19 } from "path";
|
|
12659
12667
|
function parseRole(text, stem, layer) {
|
|
12660
12668
|
if (Buffer.byteLength(text) > 8192 || text.includes("\r") || !ID.test(stem))
|
|
12661
12669
|
throw new Error("invalid role size, encoding or file id");
|
|
@@ -12734,7 +12742,7 @@ function loadRoleCatalog(cwd) {
|
|
|
12734
12742
|
if (!cwd)
|
|
12735
12743
|
return { roles, errors };
|
|
12736
12744
|
try {
|
|
12737
|
-
const config =
|
|
12745
|
+
const config = join19(cwd, ".agenthub"), dir = join19(config, "roles");
|
|
12738
12746
|
for (const path of [config, dir]) {
|
|
12739
12747
|
const stat = lstatSync17(path);
|
|
12740
12748
|
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
@@ -12746,7 +12754,7 @@ function loadRoleCatalog(cwd) {
|
|
|
12746
12754
|
for (const file of files) {
|
|
12747
12755
|
const id = file.slice(0, -3);
|
|
12748
12756
|
try {
|
|
12749
|
-
roles.set(id, parseRole(projectRole(
|
|
12757
|
+
roles.set(id, parseRole(projectRole(join19(dir, file)), id, "project"));
|
|
12750
12758
|
} catch {
|
|
12751
12759
|
errors.push({ id: ID.test(id) ? id : "invalid-file-id", reason: "invalid or unsafe project role" });
|
|
12752
12760
|
}
|
|
@@ -13193,6 +13201,7 @@ function controlWriteSpan(phase, fn) {
|
|
|
13193
13201
|
}
|
|
13194
13202
|
span.async = true;
|
|
13195
13203
|
request.telemetry.recordSyncPrefix(span);
|
|
13204
|
+
request.telemetry.followSpan(span);
|
|
13196
13205
|
return Promise.resolve(result).then((value) => {
|
|
13197
13206
|
request.telemetry.finishSpan(span);
|
|
13198
13207
|
return value;
|
|
@@ -13219,6 +13228,9 @@ class ControlWriteTelemetry {
|
|
|
13219
13228
|
timer;
|
|
13220
13229
|
nextSampleAt;
|
|
13221
13230
|
lastNow = 0;
|
|
13231
|
+
hops = 0;
|
|
13232
|
+
turn = 0;
|
|
13233
|
+
turnPending = false;
|
|
13222
13234
|
stopped = false;
|
|
13223
13235
|
completedRequests = 0;
|
|
13224
13236
|
expiredRequests = 0;
|
|
@@ -13269,6 +13281,7 @@ class ControlWriteTelemetry {
|
|
|
13269
13281
|
phaseOrder: [],
|
|
13270
13282
|
settled: false,
|
|
13271
13283
|
privacySuppressed: false,
|
|
13284
|
+
hopsLeft: MAX_REQUEST_HOPS,
|
|
13272
13285
|
logPrivacy: () => false
|
|
13273
13286
|
};
|
|
13274
13287
|
request.logPrivacy = () => !request.privacySuppressed && this.privateNow(request.privacyCurrent);
|
|
@@ -13386,7 +13399,14 @@ class ControlWriteTelemetry {
|
|
|
13386
13399
|
};
|
|
13387
13400
|
}
|
|
13388
13401
|
beginSpan(request, phase) {
|
|
13389
|
-
|
|
13402
|
+
if (!this.turnPending && !this.stopped) {
|
|
13403
|
+
this.turnPending = true;
|
|
13404
|
+
setImmediate(() => {
|
|
13405
|
+
this.turn++;
|
|
13406
|
+
this.turnPending = false;
|
|
13407
|
+
}).unref?.();
|
|
13408
|
+
}
|
|
13409
|
+
const span = { request, phase, startedAt: this.readNow(), async: false, finished: false, prefixRecorded: false, turn: this.turn };
|
|
13390
13410
|
if (this.spans.size >= this.maxActiveSpans) {
|
|
13391
13411
|
this.droppedSpans++;
|
|
13392
13412
|
return span;
|
|
@@ -13412,6 +13432,8 @@ class ControlWriteTelemetry {
|
|
|
13412
13432
|
request.phases.set(span.phase, prior + durationMs);
|
|
13413
13433
|
if (!span.async && !span.prefixRecorded)
|
|
13414
13434
|
this.rememberSyncInterval(span, endedAt);
|
|
13435
|
+
else if (span.async && span.turn === this.turn && endedAt - span.startedAt >= MIN_SYNC_PREFIX_MS)
|
|
13436
|
+
this.rememberSyncInterval(span, endedAt);
|
|
13415
13437
|
}
|
|
13416
13438
|
recordSyncPrefix(span) {
|
|
13417
13439
|
if (span.finished || span.prefixRecorded || span.request.settled)
|
|
@@ -13422,6 +13444,25 @@ class ControlWriteTelemetry {
|
|
|
13422
13444
|
span.prefixRecorded = true;
|
|
13423
13445
|
this.rememberSyncInterval(span, endedAt);
|
|
13424
13446
|
}
|
|
13447
|
+
followedHops() {
|
|
13448
|
+
return this.hops;
|
|
13449
|
+
}
|
|
13450
|
+
followSpan(span) {
|
|
13451
|
+
let last = this.readNow();
|
|
13452
|
+
const hop = () => {
|
|
13453
|
+
const request = span.request;
|
|
13454
|
+
if (span.finished || request.settled || this.stopped || request.hopsLeft <= 0)
|
|
13455
|
+
return;
|
|
13456
|
+
request.hopsLeft--;
|
|
13457
|
+
this.hops++;
|
|
13458
|
+
const now = this.readNow();
|
|
13459
|
+
if (now - last >= MIN_SYNC_PREFIX_MS)
|
|
13460
|
+
this.rememberSyncInterval({ ...span, startedAt: last }, now);
|
|
13461
|
+
last = now;
|
|
13462
|
+
queueMicrotask(hop);
|
|
13463
|
+
};
|
|
13464
|
+
queueMicrotask(hop);
|
|
13465
|
+
}
|
|
13425
13466
|
rememberSyncInterval(span, endedAt) {
|
|
13426
13467
|
const request = span.request;
|
|
13427
13468
|
this.recent.push({ kind: request.metadata.kind, ...request.metadata.task === undefined ? {} : { task: request.metadata.task }, phase: span.phase, startedAt: span.startedAt, endedAt, async: false, privacyCurrent: request.logPrivacy });
|
|
@@ -13542,7 +13583,7 @@ class ControlWriteTelemetry {
|
|
|
13542
13583
|
return Math.round(bounded * 10) / 10;
|
|
13543
13584
|
}
|
|
13544
13585
|
}
|
|
13545
|
-
var CONTROL_WRITE_KINDS, CONTROL_WRITE_PHASES, CONTROL_WRITE_SLOW_MS = 1000, CONTROL_WRITE_LOOP_DELAY_MS = 250, CONTROL_WRITE_SAMPLE_MS = 100, CONTROL_WRITE_MAX_LINE_BYTES = 2048, CONTROL_WRITE_MAX_DURATION_MS = 86400000, CONTROL_WRITE_REQUEST_MAX_AGE_MS, MAX_ACTIVE_REQUESTS = 128, MAX_ACTIVE_SPANS = 256, MAX_RECENT_SPANS = 512, MAX_LOOP_SPANS = 8, MIN_SYNC_PREFIX_MS = 10, MAX_EMITS_PER_MINUTE = 60, RATE_LIMIT_MS = 1000, currentTrace, OPERATIONS;
|
|
13586
|
+
var CONTROL_WRITE_KINDS, CONTROL_WRITE_PHASES, CONTROL_WRITE_SLOW_MS = 1000, CONTROL_WRITE_LOOP_DELAY_MS = 250, CONTROL_WRITE_SAMPLE_MS = 100, CONTROL_WRITE_MAX_LINE_BYTES = 2048, CONTROL_WRITE_MAX_DURATION_MS = 86400000, CONTROL_WRITE_REQUEST_MAX_AGE_MS, MAX_ACTIVE_REQUESTS = 128, MAX_ACTIVE_SPANS = 256, MAX_RECENT_SPANS = 512, MAX_LOOP_SPANS = 8, MIN_SYNC_PREFIX_MS = 10, MAX_REQUEST_HOPS = 16, MAX_EMITS_PER_MINUTE = 60, RATE_LIMIT_MS = 1000, currentTrace, OPERATIONS;
|
|
13546
13587
|
var init_control_write_trace = __esm(() => {
|
|
13547
13588
|
CONTROL_WRITE_KINDS = [
|
|
13548
13589
|
"hub_task_propose",
|
|
@@ -13591,7 +13632,7 @@ var package_default;
|
|
|
13591
13632
|
var init_package = __esm(() => {
|
|
13592
13633
|
package_default = {
|
|
13593
13634
|
name: "@staix/agent-hub",
|
|
13594
|
-
version: "0.
|
|
13635
|
+
version: "0.44.0",
|
|
13595
13636
|
description: "Native multi-agent hub: Claude Code, Codex, Kimi Code, Pi and local inference as peers in one project",
|
|
13596
13637
|
license: "MIT",
|
|
13597
13638
|
type: "module",
|
|
@@ -13608,7 +13649,7 @@ var init_package = __esm(() => {
|
|
|
13608
13649
|
bun: ">=1.4.4"
|
|
13609
13650
|
},
|
|
13610
13651
|
dependencies: {
|
|
13611
|
-
"@staix/agent-mem": "0.
|
|
13652
|
+
"@staix/agent-mem": "0.30.0"
|
|
13612
13653
|
},
|
|
13613
13654
|
devDependencies: {
|
|
13614
13655
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
@@ -13656,12 +13697,13 @@ var init_db_schema = __esm(() => {
|
|
|
13656
13697
|
});
|
|
13657
13698
|
|
|
13658
13699
|
// src/hub/snapshots.ts
|
|
13659
|
-
var HEAD_LOG_MAX_APPEND_BYTES;
|
|
13700
|
+
var SNAPSHOT_COOLDOWN_MS, HEAD_LOG_MAX_APPEND_BYTES;
|
|
13660
13701
|
var init_snapshots = __esm(() => {
|
|
13661
13702
|
init_db_schema();
|
|
13662
13703
|
init_child_process();
|
|
13663
13704
|
init_git();
|
|
13664
13705
|
init_project();
|
|
13706
|
+
SNAPSHOT_COOLDOWN_MS = 10 * 60000;
|
|
13665
13707
|
HEAD_LOG_MAX_APPEND_BYTES = 128 * 1024;
|
|
13666
13708
|
});
|
|
13667
13709
|
|
|
@@ -13888,13 +13930,14 @@ var init_sync_placement_plan = __esm(() => {
|
|
|
13888
13930
|
});
|
|
13889
13931
|
|
|
13890
13932
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-journal-format.ts
|
|
13891
|
-
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES;
|
|
13933
|
+
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES, PLACEMENT_CHECKPOINT_COMMAND = "amem migrate --sync-placement --checkpoint", PLACEMENT_CHECKPOINT_PENDING_MESSAGE;
|
|
13892
13934
|
var init_sync_placement_journal_format = __esm(() => {
|
|
13893
13935
|
init_generation();
|
|
13894
13936
|
init_policy();
|
|
13895
13937
|
init_sync_placement_format();
|
|
13896
13938
|
PLACEMENT_JOURNAL_CHUNK_MAX_BYTES = 64 * 1024;
|
|
13897
13939
|
PLACEMENT_JOURNAL_ROOT_MAX_BYTES = 256 * 1024;
|
|
13940
|
+
PLACEMENT_CHECKPOINT_PENDING_MESSAGE = `A placement checkpoint is pending; placement effects are paused until it finishes. Run ${PLACEMENT_CHECKPOINT_COMMAND} --resume to complete its recorded bytes, or ${PLACEMENT_CHECKPOINT_COMMAND} --abandon if its commit line has not started.`;
|
|
13898
13941
|
});
|
|
13899
13942
|
|
|
13900
13943
|
// node_modules/@staix/agent-mem/src/memory/public-prune-view.ts
|
|
@@ -13930,7 +13973,6 @@ var init_mutation = __esm(() => {
|
|
|
13930
13973
|
init_platform();
|
|
13931
13974
|
mutations = new WeakMap;
|
|
13932
13975
|
});
|
|
13933
|
-
|
|
13934
13976
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-bound.ts
|
|
13935
13977
|
var PLACEMENT_SOURCE_MAX_BYTES;
|
|
13936
13978
|
var init_sync_placement_bound = __esm(() => {
|
|
@@ -13967,16 +14009,45 @@ var init_sync_placement_writer_revision_format = __esm(() => {
|
|
|
13967
14009
|
init_generation();
|
|
13968
14010
|
init_sync_placement_writers();
|
|
13969
14011
|
init_sync_placement_format();
|
|
14012
|
+
init_sync_placement_journal_format();
|
|
13970
14013
|
WRITER_REVISION_MAX_BYTES = 512 * 1024;
|
|
13971
14014
|
WRITER_COMMIT_MAX_BYTES = 64 * 1024;
|
|
13972
14015
|
WRITER_RENEWAL_INTENT_MAX_BYTES = 1024 * 1024;
|
|
13973
14016
|
});
|
|
13974
14017
|
|
|
14018
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-format.ts
|
|
14019
|
+
var PLACEMENT_CHECKPOINT_LIMIT = 256, PLACEMENT_CHECKPOINT_PAGE_MAX_BYTES, PLACEMENT_CHECKPOINT_MANIFEST_MAX_BYTES, PLACEMENT_CHECKPOINT_COMMITS_MAX_BYTES, PLACEMENT_CHECKPOINT_INTENT_MAX_BYTES, PLACEMENT_CHECKPOINT_ARCHIVE_MAX_BYTES;
|
|
14020
|
+
var init_sync_placement_checkpoint_format = __esm(() => {
|
|
14021
|
+
init_generation();
|
|
14022
|
+
init_sync_placement_journal_format();
|
|
14023
|
+
init_sync_placement_writer_revision_format();
|
|
14024
|
+
PLACEMENT_CHECKPOINT_PAGE_MAX_BYTES = 64 * 1024;
|
|
14025
|
+
PLACEMENT_CHECKPOINT_MANIFEST_MAX_BYTES = 256 * 1024;
|
|
14026
|
+
PLACEMENT_CHECKPOINT_COMMITS_MAX_BYTES = PLACEMENT_CHECKPOINT_LIMIT * 1024;
|
|
14027
|
+
PLACEMENT_CHECKPOINT_INTENT_MAX_BYTES = 1024 * 1024;
|
|
14028
|
+
PLACEMENT_CHECKPOINT_ARCHIVE_MAX_BYTES = 8 * 1024 ** 3;
|
|
14029
|
+
});
|
|
14030
|
+
|
|
14031
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-storage.ts
|
|
14032
|
+
var MEMBER_MAX_BYTES;
|
|
14033
|
+
var init_sync_placement_checkpoint_storage = __esm(() => {
|
|
14034
|
+
init_generation();
|
|
14035
|
+
init_platform();
|
|
14036
|
+
init_sync_placement_journal_format();
|
|
14037
|
+
init_sync_placement_checkpoint_format();
|
|
14038
|
+
init_sync_placement_writer_revision_format();
|
|
14039
|
+
init_sync_placement_journal_format();
|
|
14040
|
+
MEMBER_MAX_BYTES = 1024 * 1024;
|
|
14041
|
+
});
|
|
14042
|
+
|
|
13975
14043
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-writer-history.ts
|
|
13976
14044
|
var init_sync_placement_writer_history = __esm(() => {
|
|
13977
14045
|
init_generation();
|
|
13978
14046
|
init_home_identity();
|
|
13979
14047
|
init_platform();
|
|
14048
|
+
init_sync_placement_checkpoint_storage();
|
|
14049
|
+
init_sync_placement_checkpoint_format();
|
|
14050
|
+
init_sync_placement_journal_format();
|
|
13980
14051
|
init_mutation();
|
|
13981
14052
|
init_sync_placement_writer_revision_format();
|
|
13982
14053
|
});
|
|
@@ -14020,6 +14091,8 @@ var init_sync_placement_journal_storage = __esm(() => {
|
|
|
14020
14091
|
init_sync_placement_writer_history();
|
|
14021
14092
|
init_sync_placement_batch_intent();
|
|
14022
14093
|
init_formats();
|
|
14094
|
+
init_sync_placement_checkpoint_storage();
|
|
14095
|
+
init_sync_placement_checkpoint_format();
|
|
14023
14096
|
inflight = new WeakSet;
|
|
14024
14097
|
publicationDurability = new WeakMap;
|
|
14025
14098
|
});
|
|
@@ -14595,11 +14668,16 @@ var init_catalog = __esm(() => {
|
|
|
14595
14668
|
init_capture();
|
|
14596
14669
|
init_store();
|
|
14597
14670
|
init_lifecycle();
|
|
14671
|
+
init_sync_placement_guard();
|
|
14598
14672
|
});
|
|
14599
14673
|
|
|
14674
|
+
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14675
|
+
var init_hook_resources = () => {};
|
|
14676
|
+
|
|
14600
14677
|
// node_modules/@staix/agent-mem/src/memory/metrics.ts
|
|
14601
14678
|
var METRICS_MAX_BYTES;
|
|
14602
14679
|
var init_metrics = __esm(() => {
|
|
14680
|
+
init_hook_resources();
|
|
14603
14681
|
METRICS_MAX_BYTES = 64 * 1024;
|
|
14604
14682
|
});
|
|
14605
14683
|
|
|
@@ -14952,6 +15030,7 @@ var init_mcp_memory = __esm(() => {
|
|
|
14952
15030
|
init_capture();
|
|
14953
15031
|
init_generation();
|
|
14954
15032
|
init_home();
|
|
15033
|
+
init_metrics();
|
|
14955
15034
|
init_platform();
|
|
14956
15035
|
init_policy();
|
|
14957
15036
|
init_config();
|
|
@@ -14980,9 +15059,6 @@ var init_record_instruction = __esm(() => {
|
|
|
14980
15059
|
MAX_BYTES6 = 64 * 1024;
|
|
14981
15060
|
});
|
|
14982
15061
|
|
|
14983
|
-
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14984
|
-
var init_hook_resources = () => {};
|
|
14985
|
-
|
|
14986
15062
|
// node_modules/@staix/agent-mem/src/hook-git.ts
|
|
14987
15063
|
var init_hook_git = __esm(() => {
|
|
14988
15064
|
init_platform();
|
|
@@ -15282,7 +15358,9 @@ var init_sync_placement_effective_writers = __esm(() => {
|
|
|
15282
15358
|
init_sync_placement_writer_revision_format();
|
|
15283
15359
|
init_sync_placement_writer_roots();
|
|
15284
15360
|
init_sync_placement_prerequisites();
|
|
15361
|
+
init_sync_placement_checkpoint_storage();
|
|
15285
15362
|
});
|
|
15363
|
+
|
|
15286
15364
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-capture.ts
|
|
15287
15365
|
var init_sync_placement_capture = __esm(() => {
|
|
15288
15366
|
init_sync_placement_journal_format();
|
|
@@ -16232,7 +16310,7 @@ var init_config2 = __esm(() => {
|
|
|
16232
16310
|
});
|
|
16233
16311
|
|
|
16234
16312
|
// src/hub/routing.ts
|
|
16235
|
-
import { join as
|
|
16313
|
+
import { join as join20, resolve as resolve13 } from "path";
|
|
16236
16314
|
function effectiveLocalRoute(defaultRoute, classRoute, classFixedModel) {
|
|
16237
16315
|
return classRoute ?? (classFixedModel === undefined ? defaultRoute : undefined);
|
|
16238
16316
|
}
|
|
@@ -16246,7 +16324,7 @@ var init_routing = __esm(() => {
|
|
|
16246
16324
|
init_spec_read();
|
|
16247
16325
|
init_config2();
|
|
16248
16326
|
init_stage_fallback();
|
|
16249
|
-
TEMPLATE =
|
|
16327
|
+
TEMPLATE = join20(import.meta.dir, "..", "..", "templates", "routing.toml");
|
|
16250
16328
|
cache = new Map;
|
|
16251
16329
|
});
|
|
16252
16330
|
|
|
@@ -18814,7 +18892,7 @@ var init_hub_tools = __esm(() => {
|
|
|
18814
18892
|
tool2("hub_delivery_resolve", "Confirm completion or discard your own needs_review delivery using the revision shown by hub_inbox. Requires a reason. Never replays the delivery or changes task state; another peer's row and stale revisions are refused.", { delivery_id: { type: "string", minLength: 1, maxLength: 256 }, revision: { type: "integer", minimum: 0 }, action: { type: "string", enum: ["completed", "discard"] }, reason: { type: "string", minLength: 1, maxLength: 1000 } }, ["delivery_id", "revision", "action", "reason"]),
|
|
18815
18893
|
tool2("hub_backlog_list", "Read public backlog cards with planning revisions. Configured planners only; PII remains a stub.", {}),
|
|
18816
18894
|
tool2("hub_backlog_plan", "Plan an unpinned backlog item outside frozen releases with the revision you read and a bounded reason. Omit fields or give {} for a note-only revision. fields.sdlc accepts only repo/issue identity on unstarted backlog work; relinking clears old spec acceptance. A person's rank is retained. Actual dates cannot be set. fields.needsPerson (marking a leg only the person can run) is the person's: an agent that sends it, or plans a marked card, is refused.", { id: id2, revision: { type: "integer", minimum: 0 }, reason: { type: "string", maxLength: 1000 }, fields: { type: "object", properties: { sdlc: { type: "object", minProperties: 1, properties: { repo: { type: ["string", "null"], maxLength: 400 }, issue: { type: ["integer", "null"], minimum: 1 } }, additionalProperties: false }, rank: { type: ["integer", "null"], minimum: 0 }, priority: { type: ["integer", "null"], minimum: 0, maximum: 3 }, release: { type: ["integer", "null"], minimum: 1 }, plannedStart: { type: ["integer", "null"], minimum: 1 }, due: { type: ["integer", "null"], minimum: 1 }, deps: { type: "array", maxItems: 64, uniqueItems: true, items: { type: "integer", minimum: 1 } }, reserved: { type: ["string", "null"], minLength: 1, maxLength: 32 }, needsPerson: { type: "boolean" } }, additionalProperties: false } }, ["id", "revision", "reason"]),
|
|
18817
|
-
tool2("hub_backlog_pull", "Reserve a WIP slot and pull ready unpinned backlog work into To Do at its current revision. Preserves person order/reservations and frozen scope; pending unowned work can be undone with hub_backlog_undo.", { id: id2, revision: { type: "integer", minimum: 0 }, reason: { type: "string", minLength: 1, maxLength: 1000 } }, ["id", "revision", "reason"]),
|
|
18895
|
+
tool2("hub_backlog_pull", "Configured planners only. Reserve a WIP slot and pull ready unpinned backlog work into To Do at its current revision. Preserves person order/reservations and frozen scope; pending unowned work can be undone with hub_backlog_undo.", { id: id2, revision: { type: "integer", minimum: 0 }, reason: { type: "string", minLength: 1, maxLength: 1000 } }, ["id", "revision", "reason"]),
|
|
18818
18896
|
tool2("hub_backlog_split", "Split unstarted backlog work into two to eight staged parts. The original card retains integration/acceptance and depends on the children. Use after for existing prerequisite ids and afterParts for earlier zero-based part indexes. Latest unused unchanged children can be undone with hub_backlog_undo.", { id: id2, revision: { type: "integer", minimum: 0 }, reason: { type: "string", minLength: 1, maxLength: 1000 }, parts: { type: "array", minItems: 2, maxItems: 8, items: { type: "object", properties: { title: { type: "string", minLength: 1, maxLength: 300 }, detail: { type: "string", maxLength: 8000 }, class: str2, refs, plan, after: { type: "array", maxItems: 64, uniqueItems: true, items: { type: "integer", minimum: 1 } }, afterParts: { type: "array", maxItems: 8, uniqueItems: true, items: { type: "integer", minimum: 0 } } }, required: ["title"], additionalProperties: false } } }, ["id", "revision", "reason", "parts"]),
|
|
18819
18897
|
tool2("hub_backlog_undo", "Undo your latest planning change at its current revision. Refuses intervening changes and another actor's edit.", { id: id2, revision: { type: "integer", minimum: 1 } }, ["id", "revision"]),
|
|
18820
18898
|
tool2("hub_study_draft", "Store a research campaign contract as a DRAFT revision 1 on an approved parent task. Configured planners only; it creates no task, dispatches nothing and never approves (only the person approves, with ahub study approve). The contract is data: question, scope, exclusions, sourceIds, units, deliverableSections, stopPolicy and an optional budget.", { parentTaskId: id2, contract: { type: "object" } }, ["parentTaskId", "contract"]),
|
|
@@ -19977,7 +20055,7 @@ __export(exports_claude_implementer, {
|
|
|
19977
20055
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
19978
20056
|
import { lstatSync as lstatSync18, mkdtempSync as mkdtempSync6, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
19979
20057
|
import { tmpdir as tmpdir5 } from "os";
|
|
19980
|
-
import { join as
|
|
20058
|
+
import { join as join21 } from "path";
|
|
19981
20059
|
function provenVersion(binding) {
|
|
19982
20060
|
return provenVersions.get(binding);
|
|
19983
20061
|
}
|
|
@@ -20036,7 +20114,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20036
20114
|
const file = realPath(binary), stat = lstatSync18(file);
|
|
20037
20115
|
return [file, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
|
|
20038
20116
|
};
|
|
20039
|
-
const binding = fingerprint(), home = mkdtempSync6(
|
|
20117
|
+
const binding = fingerprint(), home = mkdtempSync6(join21(tmpdir5(), "ahub-claude-proof-"));
|
|
20040
20118
|
let version = "", timedOut = false;
|
|
20041
20119
|
const child = new OwnedPrintChild({
|
|
20042
20120
|
peer,
|
|
@@ -20045,7 +20123,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20045
20123
|
cwd: home,
|
|
20046
20124
|
input: "",
|
|
20047
20125
|
envMode: "replace",
|
|
20048
|
-
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR:
|
|
20126
|
+
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR: join21(home, ".claude") },
|
|
20049
20127
|
maxFrameBytes: 4096,
|
|
20050
20128
|
maxOutputBytes: 4096,
|
|
20051
20129
|
onLine: (line) => {
|
|
@@ -20132,7 +20210,7 @@ var init_claude_implementer = __esm(() => {
|
|
|
20132
20210
|
if (options.mode !== undefined && options.mode !== "ask" && options.mode !== "ask-when-needed")
|
|
20133
20211
|
throw new Error("Claude implementer refuses unsupported permission mode");
|
|
20134
20212
|
this.mode = options.mode ?? "ask";
|
|
20135
|
-
this.sessions = new ClaudeTaskSessions(
|
|
20213
|
+
this.sessions = new ClaudeTaskSessions(join21(options.stateDir, claudeStateFile("claude-task-sessions", id)));
|
|
20136
20214
|
}
|
|
20137
20215
|
get permissionModeState() {
|
|
20138
20216
|
return this.mode;
|
|
@@ -20301,7 +20379,7 @@ var init_claude_implementer = __esm(() => {
|
|
|
20301
20379
|
this.observerSessionIdValue = turn.sessionId;
|
|
20302
20380
|
this.currentInputContext = inputContext;
|
|
20303
20381
|
this.options.beforeInput?.(inputContext, group.envs);
|
|
20304
|
-
const launchId = randomUUID9(), directory = mkdtempSync6(
|
|
20382
|
+
const launchId = randomUUID9(), directory = mkdtempSync6(join21(this.options.stateDir, "claude-child-")), settings = join21(directory, "settings.json");
|
|
20305
20383
|
let launchFailureTrace;
|
|
20306
20384
|
this.cleanup = () => rmSync7(directory, { recursive: true, force: true });
|
|
20307
20385
|
writeFileSync9(settings, sessionSettings(undefined, { script: this.options.factsHook, stateDir: this.options.stateDir, purpose: "permission" }), { mode: 384, flag: "wx" });
|
|
@@ -20648,7 +20726,7 @@ var init_reviewer_variants = __esm(() => {
|
|
|
20648
20726
|
// src/adapters/agy/hooks.ts
|
|
20649
20727
|
import { closeSync as closeSync10, constants as constants9, fstatSync as fstatSync9, lstatSync as lstatSync19, openSync as openSync10, readSync as readSync7 } from "fs";
|
|
20650
20728
|
import { homedir as homedir5 } from "os";
|
|
20651
|
-
import { isAbsolute as isAbsolute7, join as
|
|
20729
|
+
import { isAbsolute as isAbsolute7, join as join22, relative as relative5 } from "path";
|
|
20652
20730
|
import { createHash as createHash12 } from "crypto";
|
|
20653
20731
|
function agyModel(value) {
|
|
20654
20732
|
const model = safeModelLabel(value);
|
|
@@ -20703,14 +20781,14 @@ function readAgyTranscript(session, transcript, options) {
|
|
|
20703
20781
|
if (!UUID2.test(session))
|
|
20704
20782
|
return empty;
|
|
20705
20783
|
const home = process.env.HOME ?? homedir5();
|
|
20706
|
-
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) =>
|
|
20784
|
+
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) => join22(home, ".gemini", surface, "brain", session, ".system_generated/logs/transcript_full.jsonl"));
|
|
20707
20785
|
if (!candidates.includes(transcript))
|
|
20708
20786
|
return empty;
|
|
20709
20787
|
let fd;
|
|
20710
20788
|
try {
|
|
20711
20789
|
let cursor = home;
|
|
20712
20790
|
for (const name of relative5(home, transcript).split("/")) {
|
|
20713
|
-
cursor =
|
|
20791
|
+
cursor = join22(cursor, name);
|
|
20714
20792
|
if (lstatSync19(cursor).isSymbolicLink())
|
|
20715
20793
|
return empty;
|
|
20716
20794
|
}
|
|
@@ -20870,7 +20948,7 @@ function builtinCliEntries(definitions) {
|
|
|
20870
20948
|
}
|
|
20871
20949
|
// src/adapters/definitions/native-cli-entry-claude.ts
|
|
20872
20950
|
import { readFileSync as readFileSync10 } from "fs";
|
|
20873
|
-
import { join as
|
|
20951
|
+
import { join as join23 } from "path";
|
|
20874
20952
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
20875
20953
|
async function runClaudeEntry(ctx) {
|
|
20876
20954
|
const { args, cwd, stateDir, cliDir, unattendedEnv, projectConfig, fail } = ctx;
|
|
@@ -20921,17 +20999,17 @@ async function runClaudeEntry(ctx) {
|
|
|
20921
20999
|
}
|
|
20922
21000
|
}
|
|
20923
21001
|
let original;
|
|
20924
|
-
for (const file of [
|
|
21002
|
+
for (const file of [join23(executionCwd, ".claude", "settings.local.json"), join23(executionCwd, ".claude", "settings.json"), join23(process.env.HOME ?? "", ".claude", "settings.json")]) {
|
|
20925
21003
|
try {
|
|
20926
21004
|
original ??= JSON.parse(readFileSync10(file, "utf8")).statusLine;
|
|
20927
21005
|
} catch {}
|
|
20928
21006
|
}
|
|
20929
|
-
const facts = claudeObservationHooks(projectConfig(), { script:
|
|
21007
|
+
const facts = claudeObservationHooks(projectConfig(), { script: join23(cliDir, "facts-hook.ts"), stateDir });
|
|
20930
21008
|
let previousLaunch;
|
|
20931
21009
|
try {
|
|
20932
|
-
previousLaunch = JSON.parse(readFileSync10(
|
|
21010
|
+
previousLaunch = JSON.parse(readFileSync10(join23(stateDir, claudeStateFile("claude-launch", peer)), "utf8"));
|
|
20933
21011
|
} catch {}
|
|
20934
|
-
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script:
|
|
21012
|
+
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join23(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original } : {} }, ...facts ? { facts } : {} });
|
|
20935
21013
|
let result;
|
|
20936
21014
|
try {
|
|
20937
21015
|
let launchRecord;
|
|
@@ -21026,7 +21104,7 @@ var init_native_cli_entry_codex = () => {};
|
|
|
21026
21104
|
// src/cli/kimi-plugin.ts
|
|
21027
21105
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
21028
21106
|
import { closeSync as closeSync11, lstatSync as lstatSync20, mkdirSync as mkdirSync12, openSync as openSync11, readFileSync as readFileSync11, renameSync as renameSync5, rmdirSync as rmdirSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync10 } from "fs";
|
|
21029
|
-
import { dirname as dirname14, isAbsolute as isAbsolute8, join as
|
|
21107
|
+
import { dirname as dirname14, isAbsolute as isAbsolute8, join as join24 } from "path";
|
|
21030
21108
|
function file(path, cap) {
|
|
21031
21109
|
const stat = lstatSync20(path, { throwIfNoEntry: false });
|
|
21032
21110
|
if (!stat)
|
|
@@ -21099,7 +21177,7 @@ function plan2(options) {
|
|
|
21099
21177
|
const hook = file(options.hookScript, MAX_HOOK);
|
|
21100
21178
|
if (!hook)
|
|
21101
21179
|
throw new Error("Kimi hook bundle is missing");
|
|
21102
|
-
const root =
|
|
21180
|
+
const root = join24(options.home, "plugins"), managed = join24(root, "managed", ID2), installed = join24(root, "installed.json");
|
|
21103
21181
|
const installedBefore = file(installed, MAX_INSTALLED), document = parse2(installedBefore, installed);
|
|
21104
21182
|
if (document && (document.version !== 1 || !Array.isArray(document.plugins)))
|
|
21105
21183
|
throw new Error(`${installed} has an unsupported shape`);
|
|
@@ -21112,7 +21190,7 @@ function plan2(options) {
|
|
|
21112
21190
|
if (record && (record.root !== managed || record.source !== "local-path" || record.origin !== "custom" || record.enabled !== true || typeof record.originalSource !== "string" || record.agentHubLaunch !== options.launchId && options.replaceStale !== true)) {
|
|
21113
21191
|
throw new Error("Kimi's agent-hub plugin belongs to another launch or is disabled; it was not changed");
|
|
21114
21192
|
}
|
|
21115
|
-
const manifestBefore = file(
|
|
21193
|
+
const manifestBefore = file(join24(managed, "kimi.plugin.json"), MAX_INSTALLED), hookBefore = file(join24(managed, "kimi-hook.js"), MAX_HOOK);
|
|
21116
21194
|
const nextManifest = Buffer.from(`${JSON.stringify(manifest(), null, 2)}
|
|
21117
21195
|
`);
|
|
21118
21196
|
const now = new Date(options.now ?? Date.now()).toISOString();
|
|
@@ -21137,8 +21215,8 @@ function plan2(options) {
|
|
|
21137
21215
|
...record ? { record } : {},
|
|
21138
21216
|
changed,
|
|
21139
21217
|
targets: [
|
|
21140
|
-
{ path:
|
|
21141
|
-
{ path:
|
|
21218
|
+
{ path: join24(managed, "kimi.plugin.json"), next: nextManifest, ...manifestBefore ? { before: manifestBefore } : {} },
|
|
21219
|
+
{ path: join24(managed, "kimi-hook.js"), next: hook.bytes, ...hookBefore ? { before: hookBefore } : {} },
|
|
21142
21220
|
{ path: installed, next: Buffer.from(`${JSON.stringify(nextDocument, null, 2)}
|
|
21143
21221
|
`), ...installedBefore ? { before: installedBefore } : {} }
|
|
21144
21222
|
]
|
|
@@ -21150,13 +21228,13 @@ function kimiPluginPreview(home, hookScript) {
|
|
|
21150
21228
|
directory(home, false);
|
|
21151
21229
|
if (!file(hookScript, MAX_HOOK))
|
|
21152
21230
|
throw new Error("Kimi hook bundle is missing");
|
|
21153
|
-
return { file:
|
|
21231
|
+
return { file: join24(home, "plugins", "managed", ID2), changed: true, action: "only after Kimi 2.5.2 is confirmed, install the launch-scoped completion plugin and remove it on exit; other versions keep the existing TUI with no plugin" };
|
|
21154
21232
|
}
|
|
21155
21233
|
function locked(options, run) {
|
|
21156
21234
|
if (!isAbsolute8(options.home))
|
|
21157
21235
|
throw new Error("Kimi home must be an absolute path");
|
|
21158
21236
|
directory(options.home);
|
|
21159
|
-
const path =
|
|
21237
|
+
const path = join24(options.home, "agent-hub-plugin.lock");
|
|
21160
21238
|
let fd;
|
|
21161
21239
|
try {
|
|
21162
21240
|
fd = openSync11(path, "wx", 384);
|
|
@@ -21175,7 +21253,7 @@ function ensureKimiPlugin(options) {
|
|
|
21175
21253
|
const current = plan2(options);
|
|
21176
21254
|
if (!current.changed)
|
|
21177
21255
|
return { changed: false };
|
|
21178
|
-
for (const path of [
|
|
21256
|
+
for (const path of [join24(options.home, "plugins"), join24(options.home, "plugins", "managed"), current.managed]) {
|
|
21179
21257
|
if (!directory(path, false))
|
|
21180
21258
|
mkdirSync12(path, { mode: 448 });
|
|
21181
21259
|
}
|
|
@@ -21200,8 +21278,8 @@ function cleanupKimiPlugin(options) {
|
|
|
21200
21278
|
atomic(current.installed, Buffer.from(`${JSON.stringify(next, null, 2)}
|
|
21201
21279
|
`), installedBefore?.stat);
|
|
21202
21280
|
const [manifestTarget, hookTarget] = current.targets;
|
|
21203
|
-
removeFile(
|
|
21204
|
-
removeFile(
|
|
21281
|
+
removeFile(join24(current.managed, "kimi.plugin.json"), manifestTarget.next);
|
|
21282
|
+
removeFile(join24(current.managed, "kimi-hook.js"), hookTarget.next);
|
|
21205
21283
|
try {
|
|
21206
21284
|
rmdirSync4(current.managed);
|
|
21207
21285
|
} catch {}
|
|
@@ -21223,7 +21301,7 @@ var init_kimi_plugin = __esm(() => {
|
|
|
21223
21301
|
});
|
|
21224
21302
|
|
|
21225
21303
|
// src/adapters/definitions/native-cli-entry-kimi.ts
|
|
21226
|
-
import { join as
|
|
21304
|
+
import { join as join25, resolve as resolve14 } from "path";
|
|
21227
21305
|
import { homedir as homedir6 } from "os";
|
|
21228
21306
|
import { spawn as spawn10, spawnSync as spawnSync4 } from "child_process";
|
|
21229
21307
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
@@ -21345,7 +21423,7 @@ async function runKimiEntry(ctx) {
|
|
|
21345
21423
|
if (!gate.ok) {
|
|
21346
21424
|
result = await runKimiTui(launch.cmd, launch.args, cwd, nativeEnv);
|
|
21347
21425
|
} else {
|
|
21348
|
-
const nativeHome = nativeEnv.KIMI_CODE_HOME ??
|
|
21426
|
+
const nativeHome = nativeEnv.KIMI_CODE_HOME ?? join25(nativeEnv.HOME ?? homedir6(), ".kimi-code");
|
|
21349
21427
|
let nativeLaunchId, completionEnv, plugin;
|
|
21350
21428
|
try {
|
|
21351
21429
|
mkdirSync13(nativeHome, { recursive: true, mode: 448 });
|
|
@@ -21354,7 +21432,7 @@ async function runKimiEntry(ctx) {
|
|
|
21354
21432
|
throw new Error(native.error ?? "native hook launch was not admitted");
|
|
21355
21433
|
nativeLaunchId = native.launchId;
|
|
21356
21434
|
plugin = { home: nativeHome, hookScript: resolve14(serverBundle, "../kimi-hook.js"), launchId: native.launchId, replaceStale: true };
|
|
21357
|
-
console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${
|
|
21435
|
+
console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${join25(nativeHome, "plugins", "managed", "agent-hub")}; it will be removed after this TUI exits`);
|
|
21358
21436
|
ensureKimiPlugin(plugin);
|
|
21359
21437
|
completionEnv = { ...nativeEnv, AGENTHUB_INSTANCE_ID: native.instanceId, AGENTHUB_LAUNCH_ID: native.launchId, AGENTHUB_HOOK_PURPOSE: "facts" };
|
|
21360
21438
|
} catch (error) {
|
|
@@ -21365,7 +21443,7 @@ async function runKimiEntry(ctx) {
|
|
|
21365
21443
|
try {
|
|
21366
21444
|
cleanupKimiPlugin(plugin);
|
|
21367
21445
|
} catch {
|
|
21368
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21446
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join25(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21369
21447
|
}
|
|
21370
21448
|
}
|
|
21371
21449
|
if (completionEnv) {
|
|
@@ -21378,7 +21456,7 @@ async function runKimiEntry(ctx) {
|
|
|
21378
21456
|
try {
|
|
21379
21457
|
cleanupKimiPlugin(plugin);
|
|
21380
21458
|
} catch {
|
|
21381
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21459
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join25(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21382
21460
|
}
|
|
21383
21461
|
}
|
|
21384
21462
|
} else {
|
|
@@ -21747,7 +21825,7 @@ var init_native_cli_entry_jcode = __esm(() => {
|
|
|
21747
21825
|
|
|
21748
21826
|
// src/adapters/definitions/native-cli-preview-claude.ts
|
|
21749
21827
|
import { readFileSync as readFileSync12 } from "fs";
|
|
21750
|
-
import { join as
|
|
21828
|
+
import { join as join26 } from "path";
|
|
21751
21829
|
function previewClaude(ctx) {
|
|
21752
21830
|
const { args, cwd, stateDir, cliDir, unattended, config } = ctx;
|
|
21753
21831
|
const { buildLaunch, claudeObservationHooks } = ctx.helpers;
|
|
@@ -21755,13 +21833,13 @@ function previewClaude(ctx) {
|
|
|
21755
21833
|
let envNames = state.envNames;
|
|
21756
21834
|
let launch;
|
|
21757
21835
|
let original;
|
|
21758
|
-
for (const file of [
|
|
21836
|
+
for (const file of [join26(cwd, ".claude/settings.local.json"), join26(cwd, ".claude/settings.json"), join26(process.env.HOME ?? "", ".claude/settings.json")]) {
|
|
21759
21837
|
try {
|
|
21760
21838
|
original ??= JSON.parse(readFileSync12(file, "utf8")).statusLine;
|
|
21761
21839
|
} catch {}
|
|
21762
21840
|
}
|
|
21763
|
-
const facts = claudeObservationHooks(config, { script:
|
|
21764
|
-
launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script:
|
|
21841
|
+
const facts = claudeObservationHooks(config, { script: join26(cliDir, "facts-hook.ts"), stateDir });
|
|
21842
|
+
launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script: join26(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original: { command: original.command ? REDACTED : "", ...typeof original.refreshInterval === "number" && Number.isFinite(original.refreshInterval) ? { refreshInterval: original.refreshInterval } : {}, ...typeof original.padding === "number" && Number.isFinite(original.padding) ? { padding: original.padding } : {} } } : {} }, ...facts ? { facts } : {} });
|
|
21765
21843
|
const safeArgs = args.map((arg, i) => {
|
|
21766
21844
|
if (args[i - 1] === "--settings")
|
|
21767
21845
|
return "{}";
|
|
@@ -21772,7 +21850,7 @@ function previewClaude(ctx) {
|
|
|
21772
21850
|
return publicArg(arg);
|
|
21773
21851
|
});
|
|
21774
21852
|
const publicLaunch = buildLaunch("claude", safeArgs, { preview: true, unattended, statusLine: {
|
|
21775
|
-
script:
|
|
21853
|
+
script: join26(cliDir, "statusline-tee.ts"),
|
|
21776
21854
|
stateDir,
|
|
21777
21855
|
...original ? { original: { command: original.command ? REDACTED : "", ...typeof original.refreshInterval === "number" && Number.isFinite(original.refreshInterval) ? { refreshInterval: original.refreshInterval } : {}, ...typeof original.padding === "number" && Number.isFinite(original.padding) ? { padding: original.padding } : {} } } : {}
|
|
21778
21856
|
}, facts });
|
|
@@ -21805,7 +21883,7 @@ function previewCodex(ctx) {
|
|
|
21805
21883
|
var init_native_cli_preview_codex = () => {};
|
|
21806
21884
|
|
|
21807
21885
|
// src/adapters/definitions/native-cli-preview-kimi.ts
|
|
21808
|
-
import { join as
|
|
21886
|
+
import { join as join27 } from "path";
|
|
21809
21887
|
import { homedir as homedir7 } from "os";
|
|
21810
21888
|
function previewKimi(ctx) {
|
|
21811
21889
|
const { args, cwd, stateDir, cliDir, config } = ctx;
|
|
@@ -21831,10 +21909,10 @@ function previewKimi(ctx) {
|
|
|
21831
21909
|
const nativeEnv = nativeLaunchEnv("kimi", childEnv());
|
|
21832
21910
|
envNames = Object.keys(nativeEnv).concat(["AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR", "AGENTHUB_INSTANCE_ID", "AGENTHUB_LAUNCH_ID", "AGENTHUB_HOOK_PURPOSE"]);
|
|
21833
21911
|
unresolved.push({ field: "nativeLaunchId", reason: "native completion facts bind to the launch admitted by the running hub" });
|
|
21834
|
-
const home = nativeEnv.KIMI_CODE_HOME ??
|
|
21835
|
-
completionPlugin = kimiPluginPreview(home,
|
|
21912
|
+
const home = nativeEnv.KIMI_CODE_HOME ?? join27(nativeEnv.HOME ?? homedir7(), ".kimi-code");
|
|
21913
|
+
completionPlugin = kimiPluginPreview(home, join27(cliDir, "../../plugins/agent-hub/kimi-hook.js"));
|
|
21836
21914
|
}
|
|
21837
|
-
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir,
|
|
21915
|
+
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir, join27(cliDir, "../../plugins/agent-hub/server.js"), mode);
|
|
21838
21916
|
kimiMetadata = { mode, mcp: { file, action, changed, tracked }, ...completionPlugin ? { completionPlugin } : {} };
|
|
21839
21917
|
return finishPreview(ctx, launch, envNames, unresolved, kimiMetadata);
|
|
21840
21918
|
}
|
|
@@ -21843,7 +21921,7 @@ var init_native_cli_preview_kimi = __esm(() => {
|
|
|
21843
21921
|
});
|
|
21844
21922
|
|
|
21845
21923
|
// src/adapters/definitions/native-cli-preview-pi.ts
|
|
21846
|
-
import { join as
|
|
21924
|
+
import { join as join28, resolve as resolve16 } from "path";
|
|
21847
21925
|
function previewPi(ctx) {
|
|
21848
21926
|
const { args, stateDir, cliDir, config } = ctx;
|
|
21849
21927
|
const { relayModelIds, buildPiLaunch, startModeOf } = ctx.helpers;
|
|
@@ -21878,7 +21956,7 @@ function previewPi(ctx) {
|
|
|
21878
21956
|
tools: [],
|
|
21879
21957
|
preamble: REDACTED,
|
|
21880
21958
|
maxSteps: config.pi.max_steps
|
|
21881
|
-
}, {}, resolve16(
|
|
21959
|
+
}, {}, resolve16(join28(cliDir, "../pi/extension.ts")), UNRESOLVED, UNRESOLVED);
|
|
21882
21960
|
launch = pi;
|
|
21883
21961
|
envNames = Object.keys(pi.env).concat(["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"].filter((key) => process.env[key] !== undefined));
|
|
21884
21962
|
if (mode === "tui")
|
|
@@ -21969,7 +22047,7 @@ var init_native_config_policy = __esm(() => {
|
|
|
21969
22047
|
|
|
21970
22048
|
// src/adapters/definitions/native-policy-aux.ts
|
|
21971
22049
|
import { closeSync as closeSync12, constants as constants10, fstatSync as fstatSync10, openSync as openSync12, readdirSync as readdirSync4, readFileSync as readFileSync13 } from "fs";
|
|
21972
|
-
import { isAbsolute as isAbsolute9, join as
|
|
22050
|
+
import { isAbsolute as isAbsolute9, join as join29, normalize } from "path";
|
|
21973
22051
|
function claudeCrashPlan(_meta) {
|
|
21974
22052
|
return { how: "claude: the Claude Code plugin reconnects by itself while that session is still open" };
|
|
21975
22053
|
}
|
|
@@ -22014,13 +22092,13 @@ function localCrashPlan(meta) {
|
|
|
22014
22092
|
}
|
|
22015
22093
|
function claudePlugins(root, cwd) {
|
|
22016
22094
|
const enabled = new Map;
|
|
22017
|
-
for (const file of [
|
|
22095
|
+
for (const file of [join29(root, "settings.json"), ...cwd ? [join29(cwd, ".claude", "settings.json"), join29(cwd, ".claude", "settings.local.json")] : []]) {
|
|
22018
22096
|
const map = json(file)?.enabledPlugins;
|
|
22019
22097
|
if (map && typeof map === "object")
|
|
22020
22098
|
for (const [key, on] of Object.entries(map))
|
|
22021
22099
|
enabled.set(key, on === true);
|
|
22022
22100
|
}
|
|
22023
|
-
const installed = json(
|
|
22101
|
+
const installed = json(join29(root, "plugins", "installed_plugins.json"))?.plugins ?? {};
|
|
22024
22102
|
const out = [];
|
|
22025
22103
|
for (const [key, on] of enabled) {
|
|
22026
22104
|
if (!on)
|
|
@@ -22034,7 +22112,7 @@ function claudePlugins(root, cwd) {
|
|
|
22034
22112
|
return out;
|
|
22035
22113
|
}
|
|
22036
22114
|
function codexPlugins(root) {
|
|
22037
|
-
const config = text2(
|
|
22115
|
+
const config = text2(join29(root, "config.toml"));
|
|
22038
22116
|
if (config === undefined)
|
|
22039
22117
|
return [];
|
|
22040
22118
|
const found = new Map, disabled = new Set;
|
|
@@ -22053,7 +22131,7 @@ function codexPlugins(root) {
|
|
|
22053
22131
|
continue;
|
|
22054
22132
|
let versions = [];
|
|
22055
22133
|
try {
|
|
22056
|
-
versions = readdirSync4(
|
|
22134
|
+
versions = readdirSync4(join29(root, "plugins", "cache", market, plugin));
|
|
22057
22135
|
} catch {}
|
|
22058
22136
|
out.push({ name, version: versions.length === 1 ? version2(versions[0]) : null });
|
|
22059
22137
|
}
|
|
@@ -22091,7 +22169,7 @@ var str3 = (value) => typeof value === "string" && value ? value : undefined, PL
|
|
|
22091
22169
|
} catch {
|
|
22092
22170
|
return;
|
|
22093
22171
|
}
|
|
22094
|
-
}, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() ||
|
|
22172
|
+
}, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() || join29(ctx.home, ".claude"), ctx.cwd), codexPluginInventory = (ctx) => codexPlugins(ctx.env.CODEX_HOME?.trim() || join29(ctx.home, ".codex")), codexToolSemantic = (name, _command) => name.toLowerCase() === "filechange" ? "edit" : undefined;
|
|
22095
22173
|
var init_native_policy_aux = __esm(() => {
|
|
22096
22174
|
PLUGINS = new Map([["claude-mem", "claude-mem"], ["ponytail", "ponytail"], ["open-code-review", "open-code-review"]]);
|
|
22097
22175
|
CLAUDE_ONLY = new Map([["codex@openai-codex", "codex-plugin"]]);
|
|
@@ -22136,7 +22214,7 @@ var init_native_cli_launch_common = __esm(() => {
|
|
|
22136
22214
|
// src/adapters/definitions/native-cli-claude-launch.ts
|
|
22137
22215
|
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync11, renameSync as renameSync6, unlinkSync as unlinkSync5, readFileSync as readFileSync14 } from "fs";
|
|
22138
22216
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
22139
|
-
import { resolve as resolve17, join as
|
|
22217
|
+
import { resolve as resolve17, join as join30 } from "path";
|
|
22140
22218
|
function claudeChannel(userArgs) {
|
|
22141
22219
|
const bundle = resolve17(import.meta.dir, "../../../plugins/agent-hub/server.js");
|
|
22142
22220
|
for (let i = 0;i < userArgs.length; i++) {
|
|
@@ -22198,7 +22276,7 @@ function claudeNativeLaunch(ctx) {
|
|
|
22198
22276
|
const stateDir = ctx.facts?.stateDir ?? ctx.statusLine?.stateDir;
|
|
22199
22277
|
if (!stateDir)
|
|
22200
22278
|
throw new Error("Claude session settings require the hub state directory");
|
|
22201
|
-
const file =
|
|
22279
|
+
const file = join30(stateDir, `claude-settings-${randomUUID12()}.json`);
|
|
22202
22280
|
try {
|
|
22203
22281
|
mkdirSync14(stateDir, { recursive: true, mode: 448 });
|
|
22204
22282
|
writeFileSync11(`${file}.tmp`, settingsArgs[1], { mode: 384, flag: "wx" });
|
|
@@ -22281,13 +22359,13 @@ var init_events = () => {};
|
|
|
22281
22359
|
// src/cli/recovery-session-file.ts
|
|
22282
22360
|
import { statSync as statSync5 } from "fs";
|
|
22283
22361
|
import { homedir as homedir8 } from "os";
|
|
22284
|
-
import { join as
|
|
22362
|
+
import { join as join31 } from "path";
|
|
22285
22363
|
function checkedSessionPath(binding, kind) {
|
|
22286
22364
|
if (kind === "rollout")
|
|
22287
|
-
return
|
|
22288
|
-
const config = binding.launch.env.CLAUDE_CONFIG_DIR ??
|
|
22365
|
+
return join31(binding.launch.env.CODEX_HOME ?? join31(homedir8(), ".codex"), "sessions");
|
|
22366
|
+
const config = binding.launch.env.CLAUDE_CONFIG_DIR ?? join31(homedir8(), ".claude");
|
|
22289
22367
|
const slug = binding.projectRoot.replace(/[^a-zA-Z0-9]/g, "-");
|
|
22290
|
-
return
|
|
22368
|
+
return join31(config, "projects", slug, `${binding.sessionId}.jsonl`);
|
|
22291
22369
|
}
|
|
22292
22370
|
function recordedFileState(file) {
|
|
22293
22371
|
try {
|
|
@@ -22300,7 +22378,7 @@ var init_recovery_session_file = () => {};
|
|
|
22300
22378
|
|
|
22301
22379
|
// src/adapters/definitions/native-recovery.ts
|
|
22302
22380
|
import { readdirSync as readdirSync5 } from "fs";
|
|
22303
|
-
import { basename as basename5, join as
|
|
22381
|
+
import { basename as basename5, join as join32 } from "path";
|
|
22304
22382
|
var rolloutState = (binding) => {
|
|
22305
22383
|
try {
|
|
22306
22384
|
return readdirSync5(checkedSessionPath(binding, "rollout"), { recursive: true }).some((name) => String(name).endsWith(".jsonl") && basename5(String(name)).includes(binding.sessionId));
|
|
@@ -22324,7 +22402,7 @@ var init_native_recovery = __esm(() => {
|
|
|
22324
22402
|
if (phase !== "plan")
|
|
22325
22403
|
return false;
|
|
22326
22404
|
let current, started = false, turned = false;
|
|
22327
|
-
for (const e of readEvents(
|
|
22405
|
+
for (const e of readEvents(join32(stateDir, "events.jsonl"))) {
|
|
22328
22406
|
if (e.type === "native_thread" && e.peer === binding.peer) {
|
|
22329
22407
|
current = e.thread;
|
|
22330
22408
|
if (e.thread === binding.sessionId && e.fresh)
|
|
@@ -22403,7 +22481,7 @@ var init_native_recovery = __esm(() => {
|
|
|
22403
22481
|
// src/adapters/kimi-tui-facts.ts
|
|
22404
22482
|
import { closeSync as closeSync14, constants as constants11, fstatSync as fstatSync12, lstatSync as lstatSync21, openSync as openSync14, readSync as readSync9, readdirSync as readdirSync6 } from "fs";
|
|
22405
22483
|
import { createHash as createHash13 } from "crypto";
|
|
22406
|
-
import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute10, join as
|
|
22484
|
+
import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute10, join as join33, relative as relative6 } from "path";
|
|
22407
22485
|
import { homedir as homedir9 } from "os";
|
|
22408
22486
|
function decodeKimiTuiHook(event, value) {
|
|
22409
22487
|
if (!EVENTS4.includes(event) || !record7(value) || value.hook_event_name !== event || value.client_type !== "kimi_code_cli" || typeof value.session_id !== "string" || !SESSION.test(value.session_id) || typeof value.cwd !== "string" || !isAbsolute10(value.cwd) || value.cwd.length > 4096)
|
|
@@ -22412,8 +22490,8 @@ function decodeKimiTuiHook(event, value) {
|
|
|
22412
22490
|
return;
|
|
22413
22491
|
if (event === "TaskStarted" && (typeof value.task_id !== "string" || !TASK.test(value.task_id)))
|
|
22414
22492
|
return;
|
|
22415
|
-
const home = process.env.KIMI_CODE_HOME ??
|
|
22416
|
-
const transcriptPath = value.agentHubTranscriptPath ??
|
|
22493
|
+
const home = process.env.KIMI_CODE_HOME ?? join33(process.env.HOME ?? homedir9(), ".kimi-code");
|
|
22494
|
+
const transcriptPath = value.agentHubTranscriptPath ?? join33(home, "session_index.jsonl");
|
|
22417
22495
|
if (typeof transcriptPath !== "string" || !isAbsolute10(transcriptPath) || transcriptPath.length > 4096)
|
|
22418
22496
|
return;
|
|
22419
22497
|
const phase = { TurnStarted: "start", Stop: "stop", StopFailure: "stop", Interrupt: "stop", SessionEnd: "session", TaskStarted: "pre", Notification: "post" }[event];
|
|
@@ -22446,7 +22524,7 @@ function readBytes(path, cap, tail = false) {
|
|
|
22446
22524
|
}
|
|
22447
22525
|
}
|
|
22448
22526
|
function sessionDirectory(index, session) {
|
|
22449
|
-
const home = dirname15(index), sessions = realPath(
|
|
22527
|
+
const home = dirname15(index), sessions = realPath(join33(home, "sessions"));
|
|
22450
22528
|
let listed;
|
|
22451
22529
|
for (const line of readBytes(index, INDEX_CAP2).toString("utf8").split(`
|
|
22452
22530
|
`)) {
|
|
@@ -22481,7 +22559,7 @@ function taskInventory(agents) {
|
|
|
22481
22559
|
continue;
|
|
22482
22560
|
if (!entry.isDirectory())
|
|
22483
22561
|
continue;
|
|
22484
|
-
const tasks =
|
|
22562
|
+
const tasks = join33(agents, entry.name, "tasks");
|
|
22485
22563
|
const dir = lstatSync21(tasks, { throwIfNoEntry: false });
|
|
22486
22564
|
if (!dir)
|
|
22487
22565
|
continue;
|
|
@@ -22493,7 +22571,7 @@ function taskInventory(agents) {
|
|
|
22493
22571
|
for (const name of files) {
|
|
22494
22572
|
if (!TASK.test(name.slice(0, -5)))
|
|
22495
22573
|
throw new Error("invalid task name");
|
|
22496
|
-
const row = JSON.parse(readBytes(
|
|
22574
|
+
const row = JSON.parse(readBytes(join33(tasks, name), TASK_CAP).toString("utf8"));
|
|
22497
22575
|
if (!record7(row) || row.taskId !== name.slice(0, -5) || typeof row.status !== "string")
|
|
22498
22576
|
throw new Error("invalid task");
|
|
22499
22577
|
if (row.status === "running" && row.endedAt === null) {
|
|
@@ -22512,7 +22590,7 @@ function readKimiTuiTranscript(session, index) {
|
|
|
22512
22590
|
return empty();
|
|
22513
22591
|
try {
|
|
22514
22592
|
const directory = sessionDirectory(index, session);
|
|
22515
|
-
const wire =
|
|
22593
|
+
const wire = join33(directory, "agents", "main", "wire.jsonl");
|
|
22516
22594
|
if (!inside3(directory, realPath(wire)))
|
|
22517
22595
|
return empty();
|
|
22518
22596
|
const bytes = readBytes(wire, WIRE_CAP, true);
|
|
@@ -22566,7 +22644,7 @@ function readKimiTuiTranscript(session, index) {
|
|
|
22566
22644
|
}
|
|
22567
22645
|
let background;
|
|
22568
22646
|
try {
|
|
22569
|
-
background = taskInventory(
|
|
22647
|
+
background = taskInventory(join33(directory, "agents"));
|
|
22570
22648
|
} catch {}
|
|
22571
22649
|
return {
|
|
22572
22650
|
factIds: [],
|
|
@@ -22955,7 +23033,7 @@ var init_native_cli_entry_qwen = __esm(() => {
|
|
|
22955
23033
|
});
|
|
22956
23034
|
|
|
22957
23035
|
// src/adapters/definitions/native-cli-preview-qwen.ts
|
|
22958
|
-
import { join as
|
|
23036
|
+
import { join as join34 } from "path";
|
|
22959
23037
|
function previewQwen(ctx) {
|
|
22960
23038
|
const { tool, args, cwd, stateDir, cliDir, config } = ctx;
|
|
22961
23039
|
const state = previewState(args, ctx.baseEnvNames), { unresolved, value } = state;
|
|
@@ -22985,7 +23063,7 @@ function previewQwen(ctx) {
|
|
|
22985
23063
|
form: "headless",
|
|
22986
23064
|
projectRoot: cwd,
|
|
22987
23065
|
stateDir,
|
|
22988
|
-
entrypoint:
|
|
23066
|
+
entrypoint: join34(cliDir, "main.js"),
|
|
22989
23067
|
userArgs: [],
|
|
22990
23068
|
unattended: false,
|
|
22991
23069
|
env: {},
|
|
@@ -23565,7 +23643,7 @@ import { relative as relative7, resolve as resolve19, isAbsolute as isAbsolute11
|
|
|
23565
23643
|
// src/hub/control-client.ts
|
|
23566
23644
|
init_project();
|
|
23567
23645
|
import { readFileSync as readFileSync16 } from "fs";
|
|
23568
|
-
import { join as
|
|
23646
|
+
import { join as join35, resolve as resolve18 } from "path";
|
|
23569
23647
|
|
|
23570
23648
|
// src/hub/tool-request.ts
|
|
23571
23649
|
init_capabilities();
|
|
@@ -23773,8 +23851,8 @@ function controlProtocolWindow(descriptor) {
|
|
|
23773
23851
|
}
|
|
23774
23852
|
function readControl(stateDir) {
|
|
23775
23853
|
try {
|
|
23776
|
-
const status = JSON.parse(readFileSync16(
|
|
23777
|
-
const token = readFileSync16(
|
|
23854
|
+
const status = JSON.parse(readFileSync16(join35(stateDir, "status.json"), "utf8"));
|
|
23855
|
+
const token = readFileSync16(join35(stateDir, "control-token"), "utf8").trim();
|
|
23778
23856
|
if (!Number.isInteger(status.controlPort) || status.controlPort < 1 || status.controlPort > 65535 || !token)
|
|
23779
23857
|
return;
|
|
23780
23858
|
const startModes = status.startModes && typeof status.startModes === "object" && !Array.isArray(status.startModes) ? Object.fromEntries(Object.entries(status.startModes).filter((entry) => entry[1] === "tui" || entry[1] === "headless")) : undefined;
|