@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
|
@@ -9122,11 +9122,18 @@ var init_deny = __esm(() => {
|
|
|
9122
9122
|
CONFIG_WORKTREE_NAME = [`^.*/${hfsFoldedName("config")}\\.[^/]*$`, `^.*/[^/]*${hfsFoldedName("worktree")}$`];
|
|
9123
9123
|
});
|
|
9124
9124
|
|
|
9125
|
+
// src/local/shell-environment.ts
|
|
9126
|
+
import { join as join14 } from "path";
|
|
9127
|
+
function sandboxCommandEnvironment(base, own) {
|
|
9128
|
+
return { BUN_INSTALL_CACHE_DIR: join14(own, "bun-cache"), NPM_CONFIG_CACHE: join14(own, "npm-cache"), ...base, TMPDIR: `${own}/` };
|
|
9129
|
+
}
|
|
9130
|
+
var init_shell_environment = () => {};
|
|
9131
|
+
|
|
9125
9132
|
// src/local/sandbox.ts
|
|
9126
9133
|
import { spawn as spawn8, spawnSync as spawnSync3 } from "child_process";
|
|
9127
9134
|
import { existsSync as existsSync7, lstatSync as lstatSync13, mkdtempSync as mkdtempSync4, readdirSync as readdirSync2, rmdirSync as rmdirSync2, rmSync as rmSync5 } from "fs";
|
|
9128
9135
|
import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
|
|
9129
|
-
import { dirname as dirname10, join as
|
|
9136
|
+
import { dirname as dirname10, join as join15, resolve as resolve10 } from "path";
|
|
9130
9137
|
function developerDir() {
|
|
9131
9138
|
const out = spawnSync3("xcode-select", ["-p"], { encoding: "utf8" });
|
|
9132
9139
|
let dir = out.status === 0 ? out.stdout.trim() : "";
|
|
@@ -9145,7 +9152,7 @@ function externalGitDirs(root) {
|
|
|
9145
9152
|
}
|
|
9146
9153
|
function worktreesRoot(root) {
|
|
9147
9154
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir"], { encoding: "utf8" });
|
|
9148
|
-
return out.status === 0 && out.stdout.trim() ?
|
|
9155
|
+
return out.status === 0 && out.stdout.trim() ? join15(resolve10(root, out.stdout.trim()), "worktrees") : undefined;
|
|
9149
9156
|
}
|
|
9150
9157
|
function moduleGitDirs(root) {
|
|
9151
9158
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir", "--absolute-git-dir"], { encoding: "utf8" });
|
|
@@ -9156,12 +9163,12 @@ function moduleGitDirs(root) {
|
|
|
9156
9163
|
if (!commonRaw || !ownRaw)
|
|
9157
9164
|
return [];
|
|
9158
9165
|
const common = resolve10(root, commonRaw), own = resolve10(root, ownRaw);
|
|
9159
|
-
const roots = new Set([
|
|
9166
|
+
const roots = new Set([join15(common, "modules"), join15(own, "modules")]);
|
|
9160
9167
|
try {
|
|
9161
|
-
for (const e of readdirSync2(
|
|
9168
|
+
for (const e of readdirSync2(join15(common, "worktrees"), { withFileTypes: true })) {
|
|
9162
9169
|
if (!e.isDirectory())
|
|
9163
9170
|
continue;
|
|
9164
|
-
const modules =
|
|
9171
|
+
const modules = join15(common, "worktrees", e.name, "modules");
|
|
9165
9172
|
if (existsSync7(modules))
|
|
9166
9173
|
roots.add(modules);
|
|
9167
9174
|
}
|
|
@@ -9185,7 +9192,7 @@ function moduleGitDirs(root) {
|
|
|
9185
9192
|
}
|
|
9186
9193
|
for (const e of entries)
|
|
9187
9194
|
if (e.isDirectory())
|
|
9188
|
-
walk(
|
|
9195
|
+
walk(join15(dir, e.name), depth + 1);
|
|
9189
9196
|
};
|
|
9190
9197
|
walk(modulesRoot, 0);
|
|
9191
9198
|
const found = nesting >= MODULE_DEPTH ? [] : dirs;
|
|
@@ -9195,11 +9202,11 @@ function moduleGitDirs(root) {
|
|
|
9195
9202
|
entries.add(p);
|
|
9196
9203
|
trees.push({ root: modulesRoot, entries: [...entries], dirs: found });
|
|
9197
9204
|
for (const d of found) {
|
|
9198
|
-
tree(
|
|
9205
|
+
tree(join15(d, "modules"), nesting + 1);
|
|
9199
9206
|
try {
|
|
9200
|
-
for (const e of readdirSync2(
|
|
9201
|
-
if (e.isDirectory() && existsSync7(
|
|
9202
|
-
tree(
|
|
9207
|
+
for (const e of readdirSync2(join15(d, "worktrees"), { withFileTypes: true })) {
|
|
9208
|
+
if (e.isDirectory() && existsSync7(join15(d, "worktrees", e.name, "modules")))
|
|
9209
|
+
tree(join15(d, "worktrees", e.name, "modules"), nesting + 1);
|
|
9203
9210
|
}
|
|
9204
9211
|
} catch {}
|
|
9205
9212
|
}
|
|
@@ -9210,14 +9217,14 @@ function moduleGitDirs(root) {
|
|
|
9210
9217
|
}
|
|
9211
9218
|
function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
9212
9219
|
const home = homedir4();
|
|
9213
|
-
const inHome = (p) => p.startsWith("~/") ?
|
|
9220
|
+
const inHome = (p) => p.startsWith("~/") ? join15(home, p.slice(2)) : p;
|
|
9214
9221
|
const root = realPath(cwd);
|
|
9215
9222
|
const gitDirs = externalGitDirs(root);
|
|
9216
9223
|
const moduleGit = moduleGitDirs(root);
|
|
9217
9224
|
const worktrees = worktreesRoot(root);
|
|
9218
9225
|
const creds = [".ssh", ".aws", ".gnupg", ".config/gh", ".config/gcloud", ".kube", ".docker", ".netrc", ".npmrc", ".omniroute", ".claude", ".codex", ".kimi-code", "Library/Keychains"];
|
|
9219
9226
|
const dev = developerDir();
|
|
9220
|
-
const readable = [root, ...HOME_READABLE.map((p) =>
|
|
9227
|
+
const readable = [root, ...HOME_READABLE.map((p) => join15(home, p)), ...readAllow.map(inHome), ...gitDirs, ...dev ? [dev] : []];
|
|
9221
9228
|
const subpaths = (paths) => paths.map((p) => `(subpath ${q(p)})`).join(" ");
|
|
9222
9229
|
const globals = (names) => names.map((n) => `(global-name ${q(n)})`).join(" ");
|
|
9223
9230
|
const proxy = typeof network === "object" ? `(allow network-outbound (remote ip ${q(`localhost:${network.proxyPort}`)}))` : undefined;
|
|
@@ -9235,7 +9242,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9235
9242
|
'(allow file-ioctl (regex #"^/dev/"))',
|
|
9236
9243
|
...proxy ? [proxy] : network ? ["(allow network*)"] : []
|
|
9237
9244
|
];
|
|
9238
|
-
const places = `${creds.map((c) => `(subpath ${q(
|
|
9245
|
+
const places = `${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")} ${denyRegexes(root, deny, false).join(" ")}`;
|
|
9239
9246
|
return [
|
|
9240
9247
|
"(version 1)",
|
|
9241
9248
|
...start,
|
|
@@ -9243,7 +9250,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9243
9250
|
...readOnly.length ? ['(allow file-write* (literal "/dev/null"))'] : [`(allow file-write* (subpath ${q(root)}) (regex #"^/dev/") ${gitDirs.map((d) => `(subpath ${q(d)})`).join(" ")})`],
|
|
9244
9251
|
`(deny file-write* ${hubWriteRegexes(root, gitDirs, moduleGit, worktrees).join(" ")})`,
|
|
9245
9252
|
...worktrees ? objectStoreRules(dirname10(worktrees)) : [],
|
|
9246
|
-
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(
|
|
9253
|
+
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")})`,
|
|
9247
9254
|
`(deny file-read* file-write* ${denyRegexes(root, deny).join(" ")})`,
|
|
9248
9255
|
...network ? [`(allow file-read* ${CA_BUNDLES.map((p) => `(literal ${q(p)})`).join(" ")} (regex ${q("/certifi/cacert\\.pem$")}))`, `(deny file-read* file-write* ${places})`] : []
|
|
9249
9256
|
].join(`
|
|
@@ -9259,10 +9266,10 @@ function sandboxedExec(argv, opts) {
|
|
|
9259
9266
|
if (opts.signal?.aborted)
|
|
9260
9267
|
return Promise.resolve({ code: null, output: "error: command cancelled before execution" });
|
|
9261
9268
|
return new Promise((resolve) => {
|
|
9262
|
-
const own = realPath(mkdtempSync4(
|
|
9269
|
+
const own = realPath(mkdtempSync4(join15(tmpdir4(), "ahub-cmd-")));
|
|
9263
9270
|
const sandbox = `${opts.profile}
|
|
9264
9271
|
(allow file-read* ${opts.readOnlyData ? "" : "file-write* "}process-exec (subpath ${q(own)}))`;
|
|
9265
|
-
const env = { PATH: process.env.PATH ?? "/usr/bin:/bin", HOME: homedir4(), LANG: process.env.LANG ?? "en_US.UTF-8", TERM: "dumb", ...opts.env,
|
|
9272
|
+
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);
|
|
9266
9273
|
const child = spawn8(SANDBOX_EXEC, ["-p", sandbox, ...argv], { cwd: opts.cwd, env, stdio: ["ignore", "pipe", "pipe"], detached: true });
|
|
9267
9274
|
let output = "";
|
|
9268
9275
|
let killRequested = false;
|
|
@@ -9328,7 +9335,7 @@ async function probeCommand(argv, opts) {
|
|
|
9328
9335
|
} catch {
|
|
9329
9336
|
return { code: null, output: "error: probe command authority or environment unavailable", quiescent: true };
|
|
9330
9337
|
}
|
|
9331
|
-
const own = realPath(mkdtempSync4(
|
|
9338
|
+
const own = realPath(mkdtempSync4(join15(proof.temporaryRoot, "command-")));
|
|
9332
9339
|
const created = lstatSync13(own);
|
|
9333
9340
|
let removed = false;
|
|
9334
9341
|
const dropOwn = () => {
|
|
@@ -9427,6 +9434,7 @@ var init_sandbox = __esm(() => {
|
|
|
9427
9434
|
init_git();
|
|
9428
9435
|
init_deny();
|
|
9429
9436
|
init_child_process();
|
|
9437
|
+
init_shell_environment();
|
|
9430
9438
|
q = sbplString;
|
|
9431
9439
|
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"];
|
|
9432
9440
|
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"];
|
|
@@ -9938,7 +9946,7 @@ var init_probe_errors = __esm(() => {
|
|
|
9938
9946
|
|
|
9939
9947
|
// src/local/probe-workspace.ts
|
|
9940
9948
|
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";
|
|
9941
|
-
import { dirname as dirname11, isAbsolute as isAbsolute6, join as
|
|
9949
|
+
import { dirname as dirname11, isAbsolute as isAbsolute6, join as join16 } from "path";
|
|
9942
9950
|
function refused() {
|
|
9943
9951
|
throw new Error("probe workspace source, role, path or resource proof is unavailable");
|
|
9944
9952
|
}
|
|
@@ -9999,7 +10007,7 @@ var init_probe_workspace = __esm(() => {
|
|
|
9999
10007
|
|
|
10000
10008
|
// src/local/tools.ts
|
|
10001
10009
|
import { lstatSync as lstatSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync7, statSync as statSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
10002
|
-
import { dirname as dirname12, join as
|
|
10010
|
+
import { dirname as dirname12, join as join17, relative as relative4, resolve as resolve11 } from "path";
|
|
10003
10011
|
function probeCurrent(probe) {
|
|
10004
10012
|
try {
|
|
10005
10013
|
probe.current();
|
|
@@ -10094,7 +10102,7 @@ function guardPath(ctx, path, mode) {
|
|
|
10094
10102
|
throw new ProbeToolRefusal("nonregular_target");
|
|
10095
10103
|
throw new Error(`${path} goes through a dangling symlink`);
|
|
10096
10104
|
}
|
|
10097
|
-
const real =
|
|
10105
|
+
const real = join17(realExisting, relative4(existing, abs));
|
|
10098
10106
|
const rel = relative4(root, real);
|
|
10099
10107
|
if (rel.startsWith("..") || resolve11(root, rel) !== real) {
|
|
10100
10108
|
if (ctx.probe)
|
|
@@ -10436,7 +10444,7 @@ __export(exports_pi, {
|
|
|
10436
10444
|
});
|
|
10437
10445
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10438
10446
|
import { existsSync as existsSync8, mkdirSync as mkdirSync10 } from "fs";
|
|
10439
|
-
import { join as
|
|
10447
|
+
import { join as join18, resolve as resolve12 } from "path";
|
|
10440
10448
|
import { spawn as spawn9 } from "child_process";
|
|
10441
10449
|
function piVersionAsync(command, cwd, timeoutMs = 1e4) {
|
|
10442
10450
|
const [bin, ...prefix] = command;
|
|
@@ -11035,7 +11043,7 @@ var init_pi = __esm(() => {
|
|
|
11035
11043
|
this.approvalStopReason = "";
|
|
11036
11044
|
this.approvalAbortSent = false;
|
|
11037
11045
|
mkdirSync10(this.opts.stateDir, { recursive: true });
|
|
11038
|
-
const sessions =
|
|
11046
|
+
const sessions = join18(this.opts.stateDir, "pi-sessions");
|
|
11039
11047
|
mkdirSync10(sessions, { recursive: true, mode: 448 });
|
|
11040
11048
|
if (this.opts.sessionFile) {
|
|
11041
11049
|
try {
|
|
@@ -11098,7 +11106,7 @@ var init_pi = __esm(() => {
|
|
|
11098
11106
|
return new Response("not found", { status: 404 });
|
|
11099
11107
|
} });
|
|
11100
11108
|
this.server = bridge;
|
|
11101
|
-
const extension = resolve12(
|
|
11109
|
+
const extension = resolve12(join18(import.meta.dir, "../pi/extension.ts"));
|
|
11102
11110
|
const inherited = {};
|
|
11103
11111
|
for (const key of ["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"])
|
|
11104
11112
|
if (process.env[key])
|
|
@@ -12637,7 +12645,7 @@ var init_shipped_roles = __esm(() => {
|
|
|
12637
12645
|
// src/hub/roles.ts
|
|
12638
12646
|
import { createHash as createHash7 } from "crypto";
|
|
12639
12647
|
import { constants as constants7, closeSync as closeSync8, fstatSync as fstatSync7, lstatSync as lstatSync17, openSync as openSync8, readSync as readSync5, readdirSync as readdirSync3 } from "fs";
|
|
12640
|
-
import { join as
|
|
12648
|
+
import { join as join19 } from "path";
|
|
12641
12649
|
function parseRole(text, stem, layer) {
|
|
12642
12650
|
if (Buffer.byteLength(text) > 8192 || text.includes("\r") || !ID.test(stem))
|
|
12643
12651
|
throw new Error("invalid role size, encoding or file id");
|
|
@@ -12716,7 +12724,7 @@ function loadRoleCatalog(cwd) {
|
|
|
12716
12724
|
if (!cwd)
|
|
12717
12725
|
return { roles, errors };
|
|
12718
12726
|
try {
|
|
12719
|
-
const config =
|
|
12727
|
+
const config = join19(cwd, ".agenthub"), dir = join19(config, "roles");
|
|
12720
12728
|
for (const path of [config, dir]) {
|
|
12721
12729
|
const stat = lstatSync17(path);
|
|
12722
12730
|
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
@@ -12728,7 +12736,7 @@ function loadRoleCatalog(cwd) {
|
|
|
12728
12736
|
for (const file of files) {
|
|
12729
12737
|
const id = file.slice(0, -3);
|
|
12730
12738
|
try {
|
|
12731
|
-
roles.set(id, parseRole(projectRole(
|
|
12739
|
+
roles.set(id, parseRole(projectRole(join19(dir, file)), id, "project"));
|
|
12732
12740
|
} catch {
|
|
12733
12741
|
errors.push({ id: ID.test(id) ? id : "invalid-file-id", reason: "invalid or unsafe project role" });
|
|
12734
12742
|
}
|
|
@@ -13175,6 +13183,7 @@ function controlWriteSpan(phase, fn) {
|
|
|
13175
13183
|
}
|
|
13176
13184
|
span.async = true;
|
|
13177
13185
|
request.telemetry.recordSyncPrefix(span);
|
|
13186
|
+
request.telemetry.followSpan(span);
|
|
13178
13187
|
return Promise.resolve(result).then((value) => {
|
|
13179
13188
|
request.telemetry.finishSpan(span);
|
|
13180
13189
|
return value;
|
|
@@ -13201,6 +13210,9 @@ class ControlWriteTelemetry {
|
|
|
13201
13210
|
timer;
|
|
13202
13211
|
nextSampleAt;
|
|
13203
13212
|
lastNow = 0;
|
|
13213
|
+
hops = 0;
|
|
13214
|
+
turn = 0;
|
|
13215
|
+
turnPending = false;
|
|
13204
13216
|
stopped = false;
|
|
13205
13217
|
completedRequests = 0;
|
|
13206
13218
|
expiredRequests = 0;
|
|
@@ -13251,6 +13263,7 @@ class ControlWriteTelemetry {
|
|
|
13251
13263
|
phaseOrder: [],
|
|
13252
13264
|
settled: false,
|
|
13253
13265
|
privacySuppressed: false,
|
|
13266
|
+
hopsLeft: MAX_REQUEST_HOPS,
|
|
13254
13267
|
logPrivacy: () => false
|
|
13255
13268
|
};
|
|
13256
13269
|
request.logPrivacy = () => !request.privacySuppressed && this.privateNow(request.privacyCurrent);
|
|
@@ -13368,7 +13381,14 @@ class ControlWriteTelemetry {
|
|
|
13368
13381
|
};
|
|
13369
13382
|
}
|
|
13370
13383
|
beginSpan(request, phase) {
|
|
13371
|
-
|
|
13384
|
+
if (!this.turnPending && !this.stopped) {
|
|
13385
|
+
this.turnPending = true;
|
|
13386
|
+
setImmediate(() => {
|
|
13387
|
+
this.turn++;
|
|
13388
|
+
this.turnPending = false;
|
|
13389
|
+
}).unref?.();
|
|
13390
|
+
}
|
|
13391
|
+
const span = { request, phase, startedAt: this.readNow(), async: false, finished: false, prefixRecorded: false, turn: this.turn };
|
|
13372
13392
|
if (this.spans.size >= this.maxActiveSpans) {
|
|
13373
13393
|
this.droppedSpans++;
|
|
13374
13394
|
return span;
|
|
@@ -13394,6 +13414,8 @@ class ControlWriteTelemetry {
|
|
|
13394
13414
|
request.phases.set(span.phase, prior + durationMs);
|
|
13395
13415
|
if (!span.async && !span.prefixRecorded)
|
|
13396
13416
|
this.rememberSyncInterval(span, endedAt);
|
|
13417
|
+
else if (span.async && span.turn === this.turn && endedAt - span.startedAt >= MIN_SYNC_PREFIX_MS)
|
|
13418
|
+
this.rememberSyncInterval(span, endedAt);
|
|
13397
13419
|
}
|
|
13398
13420
|
recordSyncPrefix(span) {
|
|
13399
13421
|
if (span.finished || span.prefixRecorded || span.request.settled)
|
|
@@ -13404,6 +13426,25 @@ class ControlWriteTelemetry {
|
|
|
13404
13426
|
span.prefixRecorded = true;
|
|
13405
13427
|
this.rememberSyncInterval(span, endedAt);
|
|
13406
13428
|
}
|
|
13429
|
+
followedHops() {
|
|
13430
|
+
return this.hops;
|
|
13431
|
+
}
|
|
13432
|
+
followSpan(span) {
|
|
13433
|
+
let last = this.readNow();
|
|
13434
|
+
const hop = () => {
|
|
13435
|
+
const request = span.request;
|
|
13436
|
+
if (span.finished || request.settled || this.stopped || request.hopsLeft <= 0)
|
|
13437
|
+
return;
|
|
13438
|
+
request.hopsLeft--;
|
|
13439
|
+
this.hops++;
|
|
13440
|
+
const now = this.readNow();
|
|
13441
|
+
if (now - last >= MIN_SYNC_PREFIX_MS)
|
|
13442
|
+
this.rememberSyncInterval({ ...span, startedAt: last }, now);
|
|
13443
|
+
last = now;
|
|
13444
|
+
queueMicrotask(hop);
|
|
13445
|
+
};
|
|
13446
|
+
queueMicrotask(hop);
|
|
13447
|
+
}
|
|
13407
13448
|
rememberSyncInterval(span, endedAt) {
|
|
13408
13449
|
const request = span.request;
|
|
13409
13450
|
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 });
|
|
@@ -13524,7 +13565,7 @@ class ControlWriteTelemetry {
|
|
|
13524
13565
|
return Math.round(bounded * 10) / 10;
|
|
13525
13566
|
}
|
|
13526
13567
|
}
|
|
13527
|
-
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;
|
|
13568
|
+
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;
|
|
13528
13569
|
var init_control_write_trace = __esm(() => {
|
|
13529
13570
|
CONTROL_WRITE_KINDS = [
|
|
13530
13571
|
"hub_task_propose",
|
|
@@ -13573,7 +13614,7 @@ var package_default;
|
|
|
13573
13614
|
var init_package = __esm(() => {
|
|
13574
13615
|
package_default = {
|
|
13575
13616
|
name: "@staix/agent-hub",
|
|
13576
|
-
version: "0.
|
|
13617
|
+
version: "0.44.0",
|
|
13577
13618
|
description: "Native multi-agent hub: Claude Code, Codex, Kimi Code, Pi and local inference as peers in one project",
|
|
13578
13619
|
license: "MIT",
|
|
13579
13620
|
type: "module",
|
|
@@ -13590,7 +13631,7 @@ var init_package = __esm(() => {
|
|
|
13590
13631
|
bun: ">=1.4.4"
|
|
13591
13632
|
},
|
|
13592
13633
|
dependencies: {
|
|
13593
|
-
"@staix/agent-mem": "0.
|
|
13634
|
+
"@staix/agent-mem": "0.30.0"
|
|
13594
13635
|
},
|
|
13595
13636
|
devDependencies: {
|
|
13596
13637
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
@@ -13638,12 +13679,13 @@ var init_db_schema = __esm(() => {
|
|
|
13638
13679
|
});
|
|
13639
13680
|
|
|
13640
13681
|
// src/hub/snapshots.ts
|
|
13641
|
-
var HEAD_LOG_MAX_APPEND_BYTES;
|
|
13682
|
+
var SNAPSHOT_COOLDOWN_MS, HEAD_LOG_MAX_APPEND_BYTES;
|
|
13642
13683
|
var init_snapshots = __esm(() => {
|
|
13643
13684
|
init_db_schema();
|
|
13644
13685
|
init_child_process();
|
|
13645
13686
|
init_git();
|
|
13646
13687
|
init_project();
|
|
13688
|
+
SNAPSHOT_COOLDOWN_MS = 10 * 60000;
|
|
13647
13689
|
HEAD_LOG_MAX_APPEND_BYTES = 128 * 1024;
|
|
13648
13690
|
});
|
|
13649
13691
|
|
|
@@ -13870,13 +13912,14 @@ var init_sync_placement_plan = __esm(() => {
|
|
|
13870
13912
|
});
|
|
13871
13913
|
|
|
13872
13914
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-journal-format.ts
|
|
13873
|
-
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES;
|
|
13915
|
+
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES, PLACEMENT_CHECKPOINT_COMMAND = "amem migrate --sync-placement --checkpoint", PLACEMENT_CHECKPOINT_PENDING_MESSAGE;
|
|
13874
13916
|
var init_sync_placement_journal_format = __esm(() => {
|
|
13875
13917
|
init_generation();
|
|
13876
13918
|
init_policy();
|
|
13877
13919
|
init_sync_placement_format();
|
|
13878
13920
|
PLACEMENT_JOURNAL_CHUNK_MAX_BYTES = 64 * 1024;
|
|
13879
13921
|
PLACEMENT_JOURNAL_ROOT_MAX_BYTES = 256 * 1024;
|
|
13922
|
+
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.`;
|
|
13880
13923
|
});
|
|
13881
13924
|
|
|
13882
13925
|
// node_modules/@staix/agent-mem/src/memory/public-prune-view.ts
|
|
@@ -13912,7 +13955,6 @@ var init_mutation = __esm(() => {
|
|
|
13912
13955
|
init_platform();
|
|
13913
13956
|
mutations = new WeakMap;
|
|
13914
13957
|
});
|
|
13915
|
-
|
|
13916
13958
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-bound.ts
|
|
13917
13959
|
var PLACEMENT_SOURCE_MAX_BYTES;
|
|
13918
13960
|
var init_sync_placement_bound = __esm(() => {
|
|
@@ -13949,16 +13991,45 @@ var init_sync_placement_writer_revision_format = __esm(() => {
|
|
|
13949
13991
|
init_generation();
|
|
13950
13992
|
init_sync_placement_writers();
|
|
13951
13993
|
init_sync_placement_format();
|
|
13994
|
+
init_sync_placement_journal_format();
|
|
13952
13995
|
WRITER_REVISION_MAX_BYTES = 512 * 1024;
|
|
13953
13996
|
WRITER_COMMIT_MAX_BYTES = 64 * 1024;
|
|
13954
13997
|
WRITER_RENEWAL_INTENT_MAX_BYTES = 1024 * 1024;
|
|
13955
13998
|
});
|
|
13956
13999
|
|
|
14000
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-format.ts
|
|
14001
|
+
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;
|
|
14002
|
+
var init_sync_placement_checkpoint_format = __esm(() => {
|
|
14003
|
+
init_generation();
|
|
14004
|
+
init_sync_placement_journal_format();
|
|
14005
|
+
init_sync_placement_writer_revision_format();
|
|
14006
|
+
PLACEMENT_CHECKPOINT_PAGE_MAX_BYTES = 64 * 1024;
|
|
14007
|
+
PLACEMENT_CHECKPOINT_MANIFEST_MAX_BYTES = 256 * 1024;
|
|
14008
|
+
PLACEMENT_CHECKPOINT_COMMITS_MAX_BYTES = PLACEMENT_CHECKPOINT_LIMIT * 1024;
|
|
14009
|
+
PLACEMENT_CHECKPOINT_INTENT_MAX_BYTES = 1024 * 1024;
|
|
14010
|
+
PLACEMENT_CHECKPOINT_ARCHIVE_MAX_BYTES = 8 * 1024 ** 3;
|
|
14011
|
+
});
|
|
14012
|
+
|
|
14013
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-storage.ts
|
|
14014
|
+
var MEMBER_MAX_BYTES;
|
|
14015
|
+
var init_sync_placement_checkpoint_storage = __esm(() => {
|
|
14016
|
+
init_generation();
|
|
14017
|
+
init_platform();
|
|
14018
|
+
init_sync_placement_journal_format();
|
|
14019
|
+
init_sync_placement_checkpoint_format();
|
|
14020
|
+
init_sync_placement_writer_revision_format();
|
|
14021
|
+
init_sync_placement_journal_format();
|
|
14022
|
+
MEMBER_MAX_BYTES = 1024 * 1024;
|
|
14023
|
+
});
|
|
14024
|
+
|
|
13957
14025
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-writer-history.ts
|
|
13958
14026
|
var init_sync_placement_writer_history = __esm(() => {
|
|
13959
14027
|
init_generation();
|
|
13960
14028
|
init_home_identity();
|
|
13961
14029
|
init_platform();
|
|
14030
|
+
init_sync_placement_checkpoint_storage();
|
|
14031
|
+
init_sync_placement_checkpoint_format();
|
|
14032
|
+
init_sync_placement_journal_format();
|
|
13962
14033
|
init_mutation();
|
|
13963
14034
|
init_sync_placement_writer_revision_format();
|
|
13964
14035
|
});
|
|
@@ -14002,6 +14073,8 @@ var init_sync_placement_journal_storage = __esm(() => {
|
|
|
14002
14073
|
init_sync_placement_writer_history();
|
|
14003
14074
|
init_sync_placement_batch_intent();
|
|
14004
14075
|
init_formats();
|
|
14076
|
+
init_sync_placement_checkpoint_storage();
|
|
14077
|
+
init_sync_placement_checkpoint_format();
|
|
14005
14078
|
inflight = new WeakSet;
|
|
14006
14079
|
publicationDurability = new WeakMap;
|
|
14007
14080
|
});
|
|
@@ -14577,11 +14650,16 @@ var init_catalog = __esm(() => {
|
|
|
14577
14650
|
init_capture();
|
|
14578
14651
|
init_store();
|
|
14579
14652
|
init_lifecycle();
|
|
14653
|
+
init_sync_placement_guard();
|
|
14580
14654
|
});
|
|
14581
14655
|
|
|
14656
|
+
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14657
|
+
var init_hook_resources = () => {};
|
|
14658
|
+
|
|
14582
14659
|
// node_modules/@staix/agent-mem/src/memory/metrics.ts
|
|
14583
14660
|
var METRICS_MAX_BYTES;
|
|
14584
14661
|
var init_metrics = __esm(() => {
|
|
14662
|
+
init_hook_resources();
|
|
14585
14663
|
METRICS_MAX_BYTES = 64 * 1024;
|
|
14586
14664
|
});
|
|
14587
14665
|
|
|
@@ -14934,6 +15012,7 @@ var init_mcp_memory = __esm(() => {
|
|
|
14934
15012
|
init_capture();
|
|
14935
15013
|
init_generation();
|
|
14936
15014
|
init_home();
|
|
15015
|
+
init_metrics();
|
|
14937
15016
|
init_platform();
|
|
14938
15017
|
init_policy();
|
|
14939
15018
|
init_config();
|
|
@@ -14962,9 +15041,6 @@ var init_record_instruction = __esm(() => {
|
|
|
14962
15041
|
MAX_BYTES6 = 64 * 1024;
|
|
14963
15042
|
});
|
|
14964
15043
|
|
|
14965
|
-
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14966
|
-
var init_hook_resources = () => {};
|
|
14967
|
-
|
|
14968
15044
|
// node_modules/@staix/agent-mem/src/hook-git.ts
|
|
14969
15045
|
var init_hook_git = __esm(() => {
|
|
14970
15046
|
init_platform();
|
|
@@ -15264,7 +15340,9 @@ var init_sync_placement_effective_writers = __esm(() => {
|
|
|
15264
15340
|
init_sync_placement_writer_revision_format();
|
|
15265
15341
|
init_sync_placement_writer_roots();
|
|
15266
15342
|
init_sync_placement_prerequisites();
|
|
15343
|
+
init_sync_placement_checkpoint_storage();
|
|
15267
15344
|
});
|
|
15345
|
+
|
|
15268
15346
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-capture.ts
|
|
15269
15347
|
var init_sync_placement_capture = __esm(() => {
|
|
15270
15348
|
init_sync_placement_journal_format();
|
|
@@ -16214,7 +16292,7 @@ var init_config2 = __esm(() => {
|
|
|
16214
16292
|
});
|
|
16215
16293
|
|
|
16216
16294
|
// src/hub/routing.ts
|
|
16217
|
-
import { join as
|
|
16295
|
+
import { join as join20, resolve as resolve13 } from "path";
|
|
16218
16296
|
function effectiveLocalRoute(defaultRoute, classRoute, classFixedModel) {
|
|
16219
16297
|
return classRoute ?? (classFixedModel === undefined ? defaultRoute : undefined);
|
|
16220
16298
|
}
|
|
@@ -16228,7 +16306,7 @@ var init_routing = __esm(() => {
|
|
|
16228
16306
|
init_spec_read();
|
|
16229
16307
|
init_config2();
|
|
16230
16308
|
init_stage_fallback();
|
|
16231
|
-
TEMPLATE =
|
|
16309
|
+
TEMPLATE = join20(import.meta.dir, "..", "..", "templates", "routing.toml");
|
|
16232
16310
|
cache = new Map;
|
|
16233
16311
|
});
|
|
16234
16312
|
|
|
@@ -18796,7 +18874,7 @@ var init_hub_tools = __esm(() => {
|
|
|
18796
18874
|
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"]),
|
|
18797
18875
|
tool2("hub_backlog_list", "Read public backlog cards with planning revisions. Configured planners only; PII remains a stub.", {}),
|
|
18798
18876
|
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"]),
|
|
18799
|
-
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"]),
|
|
18877
|
+
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"]),
|
|
18800
18878
|
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"]),
|
|
18801
18879
|
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"]),
|
|
18802
18880
|
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"]),
|
|
@@ -19976,7 +20054,7 @@ __export(exports_claude_implementer, {
|
|
|
19976
20054
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
19977
20055
|
import { lstatSync as lstatSync18, mkdtempSync as mkdtempSync6, rmSync as rmSync7, writeFileSync as writeFileSync9 } from "fs";
|
|
19978
20056
|
import { tmpdir as tmpdir5 } from "os";
|
|
19979
|
-
import { join as
|
|
20057
|
+
import { join as join21 } from "path";
|
|
19980
20058
|
function provenVersion(binding) {
|
|
19981
20059
|
return provenVersions.get(binding);
|
|
19982
20060
|
}
|
|
@@ -20035,7 +20113,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20035
20113
|
const file = realPath(binary), stat = lstatSync18(file);
|
|
20036
20114
|
return [file, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
|
|
20037
20115
|
};
|
|
20038
|
-
const binding = fingerprint(), home = mkdtempSync6(
|
|
20116
|
+
const binding = fingerprint(), home = mkdtempSync6(join21(tmpdir5(), "ahub-claude-proof-"));
|
|
20039
20117
|
let version = "", timedOut = false;
|
|
20040
20118
|
const child = new OwnedPrintChild({
|
|
20041
20119
|
peer,
|
|
@@ -20044,7 +20122,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20044
20122
|
cwd: home,
|
|
20045
20123
|
input: "",
|
|
20046
20124
|
envMode: "replace",
|
|
20047
|
-
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR:
|
|
20125
|
+
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR: join21(home, ".claude") },
|
|
20048
20126
|
maxFrameBytes: 4096,
|
|
20049
20127
|
maxOutputBytes: 4096,
|
|
20050
20128
|
onLine: (line) => {
|
|
@@ -20131,7 +20209,7 @@ var init_claude_implementer = __esm(() => {
|
|
|
20131
20209
|
if (options.mode !== undefined && options.mode !== "ask" && options.mode !== "ask-when-needed")
|
|
20132
20210
|
throw new Error("Claude implementer refuses unsupported permission mode");
|
|
20133
20211
|
this.mode = options.mode ?? "ask";
|
|
20134
|
-
this.sessions = new ClaudeTaskSessions(
|
|
20212
|
+
this.sessions = new ClaudeTaskSessions(join21(options.stateDir, claudeStateFile("claude-task-sessions", id)));
|
|
20135
20213
|
}
|
|
20136
20214
|
get permissionModeState() {
|
|
20137
20215
|
return this.mode;
|
|
@@ -20300,7 +20378,7 @@ var init_claude_implementer = __esm(() => {
|
|
|
20300
20378
|
this.observerSessionIdValue = turn.sessionId;
|
|
20301
20379
|
this.currentInputContext = inputContext;
|
|
20302
20380
|
this.options.beforeInput?.(inputContext, group.envs);
|
|
20303
|
-
const launchId = randomUUID9(), directory = mkdtempSync6(
|
|
20381
|
+
const launchId = randomUUID9(), directory = mkdtempSync6(join21(this.options.stateDir, "claude-child-")), settings = join21(directory, "settings.json");
|
|
20304
20382
|
let launchFailureTrace;
|
|
20305
20383
|
this.cleanup = () => rmSync7(directory, { recursive: true, force: true });
|
|
20306
20384
|
writeFileSync9(settings, sessionSettings(undefined, { script: this.options.factsHook, stateDir: this.options.stateDir, purpose: "permission" }), { mode: 384, flag: "wx" });
|
|
@@ -20647,7 +20725,7 @@ var init_reviewer_variants = __esm(() => {
|
|
|
20647
20725
|
// src/adapters/agy/hooks.ts
|
|
20648
20726
|
import { closeSync as closeSync10, constants as constants9, fstatSync as fstatSync9, lstatSync as lstatSync19, openSync as openSync10, readSync as readSync7 } from "fs";
|
|
20649
20727
|
import { homedir as homedir5 } from "os";
|
|
20650
|
-
import { isAbsolute as isAbsolute7, join as
|
|
20728
|
+
import { isAbsolute as isAbsolute7, join as join22, relative as relative5 } from "path";
|
|
20651
20729
|
import { createHash as createHash12 } from "crypto";
|
|
20652
20730
|
function agyModel(value) {
|
|
20653
20731
|
const model = safeModelLabel(value);
|
|
@@ -20702,14 +20780,14 @@ function readAgyTranscript(session, transcript, options) {
|
|
|
20702
20780
|
if (!UUID2.test(session))
|
|
20703
20781
|
return empty;
|
|
20704
20782
|
const home = process.env.HOME ?? homedir5();
|
|
20705
|
-
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) =>
|
|
20783
|
+
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) => join22(home, ".gemini", surface, "brain", session, ".system_generated/logs/transcript_full.jsonl"));
|
|
20706
20784
|
if (!candidates.includes(transcript))
|
|
20707
20785
|
return empty;
|
|
20708
20786
|
let fd;
|
|
20709
20787
|
try {
|
|
20710
20788
|
let cursor = home;
|
|
20711
20789
|
for (const name of relative5(home, transcript).split("/")) {
|
|
20712
|
-
cursor =
|
|
20790
|
+
cursor = join22(cursor, name);
|
|
20713
20791
|
if (lstatSync19(cursor).isSymbolicLink())
|
|
20714
20792
|
return empty;
|
|
20715
20793
|
}
|
|
@@ -20869,7 +20947,7 @@ function builtinCliEntries(definitions) {
|
|
|
20869
20947
|
}
|
|
20870
20948
|
// src/adapters/definitions/native-cli-entry-claude.ts
|
|
20871
20949
|
import { readFileSync as readFileSync10 } from "fs";
|
|
20872
|
-
import { join as
|
|
20950
|
+
import { join as join23 } from "path";
|
|
20873
20951
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
20874
20952
|
async function runClaudeEntry(ctx) {
|
|
20875
20953
|
const { args, cwd, stateDir, cliDir, unattendedEnv, projectConfig, fail } = ctx;
|
|
@@ -20920,17 +20998,17 @@ async function runClaudeEntry(ctx) {
|
|
|
20920
20998
|
}
|
|
20921
20999
|
}
|
|
20922
21000
|
let original;
|
|
20923
|
-
for (const file of [
|
|
21001
|
+
for (const file of [join23(executionCwd, ".claude", "settings.local.json"), join23(executionCwd, ".claude", "settings.json"), join23(process.env.HOME ?? "", ".claude", "settings.json")]) {
|
|
20924
21002
|
try {
|
|
20925
21003
|
original ??= JSON.parse(readFileSync10(file, "utf8")).statusLine;
|
|
20926
21004
|
} catch {}
|
|
20927
21005
|
}
|
|
20928
|
-
const facts = claudeObservationHooks(projectConfig(), { script:
|
|
21006
|
+
const facts = claudeObservationHooks(projectConfig(), { script: join23(cliDir, "facts-hook.ts"), stateDir });
|
|
20929
21007
|
let previousLaunch;
|
|
20930
21008
|
try {
|
|
20931
|
-
previousLaunch = JSON.parse(readFileSync10(
|
|
21009
|
+
previousLaunch = JSON.parse(readFileSync10(join23(stateDir, claudeStateFile("claude-launch", peer)), "utf8"));
|
|
20932
21010
|
} catch {}
|
|
20933
|
-
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script:
|
|
21011
|
+
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join23(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original } : {} }, ...facts ? { facts } : {} });
|
|
20934
21012
|
let result;
|
|
20935
21013
|
try {
|
|
20936
21014
|
let launchRecord;
|
|
@@ -21025,7 +21103,7 @@ var init_native_cli_entry_codex = () => {};
|
|
|
21025
21103
|
// src/cli/kimi-plugin.ts
|
|
21026
21104
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
21027
21105
|
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";
|
|
21028
|
-
import { dirname as dirname14, isAbsolute as isAbsolute8, join as
|
|
21106
|
+
import { dirname as dirname14, isAbsolute as isAbsolute8, join as join24 } from "path";
|
|
21029
21107
|
function file(path, cap) {
|
|
21030
21108
|
const stat = lstatSync20(path, { throwIfNoEntry: false });
|
|
21031
21109
|
if (!stat)
|
|
@@ -21098,7 +21176,7 @@ function plan2(options) {
|
|
|
21098
21176
|
const hook = file(options.hookScript, MAX_HOOK);
|
|
21099
21177
|
if (!hook)
|
|
21100
21178
|
throw new Error("Kimi hook bundle is missing");
|
|
21101
|
-
const root =
|
|
21179
|
+
const root = join24(options.home, "plugins"), managed = join24(root, "managed", ID2), installed = join24(root, "installed.json");
|
|
21102
21180
|
const installedBefore = file(installed, MAX_INSTALLED), document = parse2(installedBefore, installed);
|
|
21103
21181
|
if (document && (document.version !== 1 || !Array.isArray(document.plugins)))
|
|
21104
21182
|
throw new Error(`${installed} has an unsupported shape`);
|
|
@@ -21111,7 +21189,7 @@ function plan2(options) {
|
|
|
21111
21189
|
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)) {
|
|
21112
21190
|
throw new Error("Kimi's agent-hub plugin belongs to another launch or is disabled; it was not changed");
|
|
21113
21191
|
}
|
|
21114
|
-
const manifestBefore = file(
|
|
21192
|
+
const manifestBefore = file(join24(managed, "kimi.plugin.json"), MAX_INSTALLED), hookBefore = file(join24(managed, "kimi-hook.js"), MAX_HOOK);
|
|
21115
21193
|
const nextManifest = Buffer.from(`${JSON.stringify(manifest(), null, 2)}
|
|
21116
21194
|
`);
|
|
21117
21195
|
const now = new Date(options.now ?? Date.now()).toISOString();
|
|
@@ -21136,8 +21214,8 @@ function plan2(options) {
|
|
|
21136
21214
|
...record ? { record } : {},
|
|
21137
21215
|
changed,
|
|
21138
21216
|
targets: [
|
|
21139
|
-
{ path:
|
|
21140
|
-
{ path:
|
|
21217
|
+
{ path: join24(managed, "kimi.plugin.json"), next: nextManifest, ...manifestBefore ? { before: manifestBefore } : {} },
|
|
21218
|
+
{ path: join24(managed, "kimi-hook.js"), next: hook.bytes, ...hookBefore ? { before: hookBefore } : {} },
|
|
21141
21219
|
{ path: installed, next: Buffer.from(`${JSON.stringify(nextDocument, null, 2)}
|
|
21142
21220
|
`), ...installedBefore ? { before: installedBefore } : {} }
|
|
21143
21221
|
]
|
|
@@ -21149,13 +21227,13 @@ function kimiPluginPreview(home, hookScript) {
|
|
|
21149
21227
|
directory(home, false);
|
|
21150
21228
|
if (!file(hookScript, MAX_HOOK))
|
|
21151
21229
|
throw new Error("Kimi hook bundle is missing");
|
|
21152
|
-
return { file:
|
|
21230
|
+
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" };
|
|
21153
21231
|
}
|
|
21154
21232
|
function locked(options, run) {
|
|
21155
21233
|
if (!isAbsolute8(options.home))
|
|
21156
21234
|
throw new Error("Kimi home must be an absolute path");
|
|
21157
21235
|
directory(options.home);
|
|
21158
|
-
const path =
|
|
21236
|
+
const path = join24(options.home, "agent-hub-plugin.lock");
|
|
21159
21237
|
let fd;
|
|
21160
21238
|
try {
|
|
21161
21239
|
fd = openSync11(path, "wx", 384);
|
|
@@ -21174,7 +21252,7 @@ function ensureKimiPlugin(options) {
|
|
|
21174
21252
|
const current = plan2(options);
|
|
21175
21253
|
if (!current.changed)
|
|
21176
21254
|
return { changed: false };
|
|
21177
|
-
for (const path of [
|
|
21255
|
+
for (const path of [join24(options.home, "plugins"), join24(options.home, "plugins", "managed"), current.managed]) {
|
|
21178
21256
|
if (!directory(path, false))
|
|
21179
21257
|
mkdirSync12(path, { mode: 448 });
|
|
21180
21258
|
}
|
|
@@ -21199,8 +21277,8 @@ function cleanupKimiPlugin(options) {
|
|
|
21199
21277
|
atomic(current.installed, Buffer.from(`${JSON.stringify(next, null, 2)}
|
|
21200
21278
|
`), installedBefore?.stat);
|
|
21201
21279
|
const [manifestTarget, hookTarget] = current.targets;
|
|
21202
|
-
removeFile(
|
|
21203
|
-
removeFile(
|
|
21280
|
+
removeFile(join24(current.managed, "kimi.plugin.json"), manifestTarget.next);
|
|
21281
|
+
removeFile(join24(current.managed, "kimi-hook.js"), hookTarget.next);
|
|
21204
21282
|
try {
|
|
21205
21283
|
rmdirSync4(current.managed);
|
|
21206
21284
|
} catch {}
|
|
@@ -21222,7 +21300,7 @@ var init_kimi_plugin = __esm(() => {
|
|
|
21222
21300
|
});
|
|
21223
21301
|
|
|
21224
21302
|
// src/adapters/definitions/native-cli-entry-kimi.ts
|
|
21225
|
-
import { join as
|
|
21303
|
+
import { join as join25, resolve as resolve14 } from "path";
|
|
21226
21304
|
import { homedir as homedir6 } from "os";
|
|
21227
21305
|
import { spawn as spawn10, spawnSync as spawnSync4 } from "child_process";
|
|
21228
21306
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
@@ -21344,7 +21422,7 @@ async function runKimiEntry(ctx) {
|
|
|
21344
21422
|
if (!gate.ok) {
|
|
21345
21423
|
result = await runKimiTui(launch.cmd, launch.args, cwd, nativeEnv);
|
|
21346
21424
|
} else {
|
|
21347
|
-
const nativeHome = nativeEnv.KIMI_CODE_HOME ??
|
|
21425
|
+
const nativeHome = nativeEnv.KIMI_CODE_HOME ?? join25(nativeEnv.HOME ?? homedir6(), ".kimi-code");
|
|
21348
21426
|
let nativeLaunchId, completionEnv, plugin;
|
|
21349
21427
|
try {
|
|
21350
21428
|
mkdirSync13(nativeHome, { recursive: true, mode: 448 });
|
|
@@ -21353,7 +21431,7 @@ async function runKimiEntry(ctx) {
|
|
|
21353
21431
|
throw new Error(native.error ?? "native hook launch was not admitted");
|
|
21354
21432
|
nativeLaunchId = native.launchId;
|
|
21355
21433
|
plugin = { home: nativeHome, hookScript: resolve14(serverBundle, "../kimi-hook.js"), launchId: native.launchId, replaceStale: true };
|
|
21356
|
-
console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${
|
|
21434
|
+
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`);
|
|
21357
21435
|
ensureKimiPlugin(plugin);
|
|
21358
21436
|
completionEnv = { ...nativeEnv, AGENTHUB_INSTANCE_ID: native.instanceId, AGENTHUB_LAUNCH_ID: native.launchId, AGENTHUB_HOOK_PURPOSE: "facts" };
|
|
21359
21437
|
} catch (error) {
|
|
@@ -21364,7 +21442,7 @@ async function runKimiEntry(ctx) {
|
|
|
21364
21442
|
try {
|
|
21365
21443
|
cleanupKimiPlugin(plugin);
|
|
21366
21444
|
} catch {
|
|
21367
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21445
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join25(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21368
21446
|
}
|
|
21369
21447
|
}
|
|
21370
21448
|
if (completionEnv) {
|
|
@@ -21377,7 +21455,7 @@ async function runKimiEntry(ctx) {
|
|
|
21377
21455
|
try {
|
|
21378
21456
|
cleanupKimiPlugin(plugin);
|
|
21379
21457
|
} catch {
|
|
21380
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21458
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join25(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21381
21459
|
}
|
|
21382
21460
|
}
|
|
21383
21461
|
} else {
|
|
@@ -21746,7 +21824,7 @@ var init_native_cli_entry_jcode = __esm(() => {
|
|
|
21746
21824
|
|
|
21747
21825
|
// src/adapters/definitions/native-cli-preview-claude.ts
|
|
21748
21826
|
import { readFileSync as readFileSync12 } from "fs";
|
|
21749
|
-
import { join as
|
|
21827
|
+
import { join as join26 } from "path";
|
|
21750
21828
|
function previewClaude(ctx) {
|
|
21751
21829
|
const { args, cwd, stateDir, cliDir, unattended, config } = ctx;
|
|
21752
21830
|
const { buildLaunch, claudeObservationHooks } = ctx.helpers;
|
|
@@ -21754,13 +21832,13 @@ function previewClaude(ctx) {
|
|
|
21754
21832
|
let envNames = state.envNames;
|
|
21755
21833
|
let launch;
|
|
21756
21834
|
let original;
|
|
21757
|
-
for (const file of [
|
|
21835
|
+
for (const file of [join26(cwd, ".claude/settings.local.json"), join26(cwd, ".claude/settings.json"), join26(process.env.HOME ?? "", ".claude/settings.json")]) {
|
|
21758
21836
|
try {
|
|
21759
21837
|
original ??= JSON.parse(readFileSync12(file, "utf8")).statusLine;
|
|
21760
21838
|
} catch {}
|
|
21761
21839
|
}
|
|
21762
|
-
const facts = claudeObservationHooks(config, { script:
|
|
21763
|
-
launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script:
|
|
21840
|
+
const facts = claudeObservationHooks(config, { script: join26(cliDir, "facts-hook.ts"), stateDir });
|
|
21841
|
+
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 } : {} });
|
|
21764
21842
|
const safeArgs = args.map((arg, i) => {
|
|
21765
21843
|
if (args[i - 1] === "--settings")
|
|
21766
21844
|
return "{}";
|
|
@@ -21771,7 +21849,7 @@ function previewClaude(ctx) {
|
|
|
21771
21849
|
return publicArg(arg);
|
|
21772
21850
|
});
|
|
21773
21851
|
const publicLaunch = buildLaunch("claude", safeArgs, { preview: true, unattended, statusLine: {
|
|
21774
|
-
script:
|
|
21852
|
+
script: join26(cliDir, "statusline-tee.ts"),
|
|
21775
21853
|
stateDir,
|
|
21776
21854
|
...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 } : {} } } : {}
|
|
21777
21855
|
}, facts });
|
|
@@ -21804,7 +21882,7 @@ function previewCodex(ctx) {
|
|
|
21804
21882
|
var init_native_cli_preview_codex = () => {};
|
|
21805
21883
|
|
|
21806
21884
|
// src/adapters/definitions/native-cli-preview-kimi.ts
|
|
21807
|
-
import { join as
|
|
21885
|
+
import { join as join27 } from "path";
|
|
21808
21886
|
import { homedir as homedir7 } from "os";
|
|
21809
21887
|
function previewKimi(ctx) {
|
|
21810
21888
|
const { args, cwd, stateDir, cliDir, config } = ctx;
|
|
@@ -21830,10 +21908,10 @@ function previewKimi(ctx) {
|
|
|
21830
21908
|
const nativeEnv = nativeLaunchEnv("kimi", childEnv());
|
|
21831
21909
|
envNames = Object.keys(nativeEnv).concat(["AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR", "AGENTHUB_INSTANCE_ID", "AGENTHUB_LAUNCH_ID", "AGENTHUB_HOOK_PURPOSE"]);
|
|
21832
21910
|
unresolved.push({ field: "nativeLaunchId", reason: "native completion facts bind to the launch admitted by the running hub" });
|
|
21833
|
-
const home = nativeEnv.KIMI_CODE_HOME ??
|
|
21834
|
-
completionPlugin = kimiPluginPreview(home,
|
|
21911
|
+
const home = nativeEnv.KIMI_CODE_HOME ?? join27(nativeEnv.HOME ?? homedir7(), ".kimi-code");
|
|
21912
|
+
completionPlugin = kimiPluginPreview(home, join27(cliDir, "../../plugins/agent-hub/kimi-hook.js"));
|
|
21835
21913
|
}
|
|
21836
|
-
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir,
|
|
21914
|
+
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir, join27(cliDir, "../../plugins/agent-hub/server.js"), mode);
|
|
21837
21915
|
kimiMetadata = { mode, mcp: { file, action, changed, tracked }, ...completionPlugin ? { completionPlugin } : {} };
|
|
21838
21916
|
return finishPreview(ctx, launch, envNames, unresolved, kimiMetadata);
|
|
21839
21917
|
}
|
|
@@ -21842,7 +21920,7 @@ var init_native_cli_preview_kimi = __esm(() => {
|
|
|
21842
21920
|
});
|
|
21843
21921
|
|
|
21844
21922
|
// src/adapters/definitions/native-cli-preview-pi.ts
|
|
21845
|
-
import { join as
|
|
21923
|
+
import { join as join28, resolve as resolve16 } from "path";
|
|
21846
21924
|
function previewPi(ctx) {
|
|
21847
21925
|
const { args, stateDir, cliDir, config } = ctx;
|
|
21848
21926
|
const { relayModelIds, buildPiLaunch, startModeOf } = ctx.helpers;
|
|
@@ -21877,7 +21955,7 @@ function previewPi(ctx) {
|
|
|
21877
21955
|
tools: [],
|
|
21878
21956
|
preamble: REDACTED,
|
|
21879
21957
|
maxSteps: config.pi.max_steps
|
|
21880
|
-
}, {}, resolve16(
|
|
21958
|
+
}, {}, resolve16(join28(cliDir, "../pi/extension.ts")), UNRESOLVED, UNRESOLVED);
|
|
21881
21959
|
launch = pi;
|
|
21882
21960
|
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));
|
|
21883
21961
|
if (mode === "tui")
|
|
@@ -21968,7 +22046,7 @@ var init_native_config_policy = __esm(() => {
|
|
|
21968
22046
|
|
|
21969
22047
|
// src/adapters/definitions/native-policy-aux.ts
|
|
21970
22048
|
import { closeSync as closeSync12, constants as constants10, fstatSync as fstatSync10, openSync as openSync12, readdirSync as readdirSync4, readFileSync as readFileSync13 } from "fs";
|
|
21971
|
-
import { isAbsolute as isAbsolute9, join as
|
|
22049
|
+
import { isAbsolute as isAbsolute9, join as join29, normalize } from "path";
|
|
21972
22050
|
function claudeCrashPlan(_meta) {
|
|
21973
22051
|
return { how: "claude: the Claude Code plugin reconnects by itself while that session is still open" };
|
|
21974
22052
|
}
|
|
@@ -22013,13 +22091,13 @@ function localCrashPlan(meta) {
|
|
|
22013
22091
|
}
|
|
22014
22092
|
function claudePlugins(root, cwd) {
|
|
22015
22093
|
const enabled = new Map;
|
|
22016
|
-
for (const file of [
|
|
22094
|
+
for (const file of [join29(root, "settings.json"), ...cwd ? [join29(cwd, ".claude", "settings.json"), join29(cwd, ".claude", "settings.local.json")] : []]) {
|
|
22017
22095
|
const map = json(file)?.enabledPlugins;
|
|
22018
22096
|
if (map && typeof map === "object")
|
|
22019
22097
|
for (const [key, on] of Object.entries(map))
|
|
22020
22098
|
enabled.set(key, on === true);
|
|
22021
22099
|
}
|
|
22022
|
-
const installed = json(
|
|
22100
|
+
const installed = json(join29(root, "plugins", "installed_plugins.json"))?.plugins ?? {};
|
|
22023
22101
|
const out = [];
|
|
22024
22102
|
for (const [key, on] of enabled) {
|
|
22025
22103
|
if (!on)
|
|
@@ -22033,7 +22111,7 @@ function claudePlugins(root, cwd) {
|
|
|
22033
22111
|
return out;
|
|
22034
22112
|
}
|
|
22035
22113
|
function codexPlugins(root) {
|
|
22036
|
-
const config = text2(
|
|
22114
|
+
const config = text2(join29(root, "config.toml"));
|
|
22037
22115
|
if (config === undefined)
|
|
22038
22116
|
return [];
|
|
22039
22117
|
const found = new Map, disabled = new Set;
|
|
@@ -22052,7 +22130,7 @@ function codexPlugins(root) {
|
|
|
22052
22130
|
continue;
|
|
22053
22131
|
let versions = [];
|
|
22054
22132
|
try {
|
|
22055
|
-
versions = readdirSync4(
|
|
22133
|
+
versions = readdirSync4(join29(root, "plugins", "cache", market, plugin));
|
|
22056
22134
|
} catch {}
|
|
22057
22135
|
out.push({ name, version: versions.length === 1 ? version2(versions[0]) : null });
|
|
22058
22136
|
}
|
|
@@ -22090,7 +22168,7 @@ var str3 = (value) => typeof value === "string" && value ? value : undefined, PL
|
|
|
22090
22168
|
} catch {
|
|
22091
22169
|
return;
|
|
22092
22170
|
}
|
|
22093
|
-
}, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() ||
|
|
22171
|
+
}, 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;
|
|
22094
22172
|
var init_native_policy_aux = __esm(() => {
|
|
22095
22173
|
PLUGINS = new Map([["claude-mem", "claude-mem"], ["ponytail", "ponytail"], ["open-code-review", "open-code-review"]]);
|
|
22096
22174
|
CLAUDE_ONLY = new Map([["codex@openai-codex", "codex-plugin"]]);
|
|
@@ -22135,7 +22213,7 @@ var init_native_cli_launch_common = __esm(() => {
|
|
|
22135
22213
|
// src/adapters/definitions/native-cli-claude-launch.ts
|
|
22136
22214
|
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync11, renameSync as renameSync6, unlinkSync as unlinkSync5, readFileSync as readFileSync14 } from "fs";
|
|
22137
22215
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
22138
|
-
import { resolve as resolve17, join as
|
|
22216
|
+
import { resolve as resolve17, join as join30 } from "path";
|
|
22139
22217
|
function claudeChannel(userArgs) {
|
|
22140
22218
|
const bundle = resolve17(import.meta.dir, "../../../plugins/agent-hub/server.js");
|
|
22141
22219
|
for (let i = 0;i < userArgs.length; i++) {
|
|
@@ -22197,7 +22275,7 @@ function claudeNativeLaunch(ctx) {
|
|
|
22197
22275
|
const stateDir = ctx.facts?.stateDir ?? ctx.statusLine?.stateDir;
|
|
22198
22276
|
if (!stateDir)
|
|
22199
22277
|
throw new Error("Claude session settings require the hub state directory");
|
|
22200
|
-
const file =
|
|
22278
|
+
const file = join30(stateDir, `claude-settings-${randomUUID12()}.json`);
|
|
22201
22279
|
try {
|
|
22202
22280
|
mkdirSync14(stateDir, { recursive: true, mode: 448 });
|
|
22203
22281
|
writeFileSync11(`${file}.tmp`, settingsArgs[1], { mode: 384, flag: "wx" });
|
|
@@ -22280,13 +22358,13 @@ var init_events = () => {};
|
|
|
22280
22358
|
// src/cli/recovery-session-file.ts
|
|
22281
22359
|
import { statSync as statSync5 } from "fs";
|
|
22282
22360
|
import { homedir as homedir8 } from "os";
|
|
22283
|
-
import { join as
|
|
22361
|
+
import { join as join31 } from "path";
|
|
22284
22362
|
function checkedSessionPath(binding, kind) {
|
|
22285
22363
|
if (kind === "rollout")
|
|
22286
|
-
return
|
|
22287
|
-
const config = binding.launch.env.CLAUDE_CONFIG_DIR ??
|
|
22364
|
+
return join31(binding.launch.env.CODEX_HOME ?? join31(homedir8(), ".codex"), "sessions");
|
|
22365
|
+
const config = binding.launch.env.CLAUDE_CONFIG_DIR ?? join31(homedir8(), ".claude");
|
|
22288
22366
|
const slug = binding.projectRoot.replace(/[^a-zA-Z0-9]/g, "-");
|
|
22289
|
-
return
|
|
22367
|
+
return join31(config, "projects", slug, `${binding.sessionId}.jsonl`);
|
|
22290
22368
|
}
|
|
22291
22369
|
function recordedFileState(file) {
|
|
22292
22370
|
try {
|
|
@@ -22299,7 +22377,7 @@ var init_recovery_session_file = () => {};
|
|
|
22299
22377
|
|
|
22300
22378
|
// src/adapters/definitions/native-recovery.ts
|
|
22301
22379
|
import { readdirSync as readdirSync5 } from "fs";
|
|
22302
|
-
import { basename as basename5, join as
|
|
22380
|
+
import { basename as basename5, join as join32 } from "path";
|
|
22303
22381
|
var rolloutState = (binding) => {
|
|
22304
22382
|
try {
|
|
22305
22383
|
return readdirSync5(checkedSessionPath(binding, "rollout"), { recursive: true }).some((name) => String(name).endsWith(".jsonl") && basename5(String(name)).includes(binding.sessionId));
|
|
@@ -22323,7 +22401,7 @@ var init_native_recovery = __esm(() => {
|
|
|
22323
22401
|
if (phase !== "plan")
|
|
22324
22402
|
return false;
|
|
22325
22403
|
let current, started = false, turned = false;
|
|
22326
|
-
for (const e of readEvents(
|
|
22404
|
+
for (const e of readEvents(join32(stateDir, "events.jsonl"))) {
|
|
22327
22405
|
if (e.type === "native_thread" && e.peer === binding.peer) {
|
|
22328
22406
|
current = e.thread;
|
|
22329
22407
|
if (e.thread === binding.sessionId && e.fresh)
|
|
@@ -22402,7 +22480,7 @@ var init_native_recovery = __esm(() => {
|
|
|
22402
22480
|
// src/adapters/kimi-tui-facts.ts
|
|
22403
22481
|
import { closeSync as closeSync14, constants as constants11, fstatSync as fstatSync12, lstatSync as lstatSync21, openSync as openSync14, readSync as readSync9, readdirSync as readdirSync6 } from "fs";
|
|
22404
22482
|
import { createHash as createHash13 } from "crypto";
|
|
22405
|
-
import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute10, join as
|
|
22483
|
+
import { basename as basename6, dirname as dirname15, isAbsolute as isAbsolute10, join as join33, relative as relative6 } from "path";
|
|
22406
22484
|
import { homedir as homedir9 } from "os";
|
|
22407
22485
|
function decodeKimiTuiHook(event, value) {
|
|
22408
22486
|
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)
|
|
@@ -22411,8 +22489,8 @@ function decodeKimiTuiHook(event, value) {
|
|
|
22411
22489
|
return;
|
|
22412
22490
|
if (event === "TaskStarted" && (typeof value.task_id !== "string" || !TASK.test(value.task_id)))
|
|
22413
22491
|
return;
|
|
22414
|
-
const home = process.env.KIMI_CODE_HOME ??
|
|
22415
|
-
const transcriptPath = value.agentHubTranscriptPath ??
|
|
22492
|
+
const home = process.env.KIMI_CODE_HOME ?? join33(process.env.HOME ?? homedir9(), ".kimi-code");
|
|
22493
|
+
const transcriptPath = value.agentHubTranscriptPath ?? join33(home, "session_index.jsonl");
|
|
22416
22494
|
if (typeof transcriptPath !== "string" || !isAbsolute10(transcriptPath) || transcriptPath.length > 4096)
|
|
22417
22495
|
return;
|
|
22418
22496
|
const phase = { TurnStarted: "start", Stop: "stop", StopFailure: "stop", Interrupt: "stop", SessionEnd: "session", TaskStarted: "pre", Notification: "post" }[event];
|
|
@@ -22445,7 +22523,7 @@ function readBytes(path, cap, tail = false) {
|
|
|
22445
22523
|
}
|
|
22446
22524
|
}
|
|
22447
22525
|
function sessionDirectory(index, session) {
|
|
22448
|
-
const home = dirname15(index), sessions = realPath(
|
|
22526
|
+
const home = dirname15(index), sessions = realPath(join33(home, "sessions"));
|
|
22449
22527
|
let listed;
|
|
22450
22528
|
for (const line of readBytes(index, INDEX_CAP2).toString("utf8").split(`
|
|
22451
22529
|
`)) {
|
|
@@ -22480,7 +22558,7 @@ function taskInventory(agents) {
|
|
|
22480
22558
|
continue;
|
|
22481
22559
|
if (!entry.isDirectory())
|
|
22482
22560
|
continue;
|
|
22483
|
-
const tasks =
|
|
22561
|
+
const tasks = join33(agents, entry.name, "tasks");
|
|
22484
22562
|
const dir = lstatSync21(tasks, { throwIfNoEntry: false });
|
|
22485
22563
|
if (!dir)
|
|
22486
22564
|
continue;
|
|
@@ -22492,7 +22570,7 @@ function taskInventory(agents) {
|
|
|
22492
22570
|
for (const name of files) {
|
|
22493
22571
|
if (!TASK.test(name.slice(0, -5)))
|
|
22494
22572
|
throw new Error("invalid task name");
|
|
22495
|
-
const row = JSON.parse(readBytes(
|
|
22573
|
+
const row = JSON.parse(readBytes(join33(tasks, name), TASK_CAP).toString("utf8"));
|
|
22496
22574
|
if (!record7(row) || row.taskId !== name.slice(0, -5) || typeof row.status !== "string")
|
|
22497
22575
|
throw new Error("invalid task");
|
|
22498
22576
|
if (row.status === "running" && row.endedAt === null) {
|
|
@@ -22511,7 +22589,7 @@ function readKimiTuiTranscript(session, index) {
|
|
|
22511
22589
|
return empty();
|
|
22512
22590
|
try {
|
|
22513
22591
|
const directory = sessionDirectory(index, session);
|
|
22514
|
-
const wire =
|
|
22592
|
+
const wire = join33(directory, "agents", "main", "wire.jsonl");
|
|
22515
22593
|
if (!inside3(directory, realPath(wire)))
|
|
22516
22594
|
return empty();
|
|
22517
22595
|
const bytes = readBytes(wire, WIRE_CAP, true);
|
|
@@ -22565,7 +22643,7 @@ function readKimiTuiTranscript(session, index) {
|
|
|
22565
22643
|
}
|
|
22566
22644
|
let background;
|
|
22567
22645
|
try {
|
|
22568
|
-
background = taskInventory(
|
|
22646
|
+
background = taskInventory(join33(directory, "agents"));
|
|
22569
22647
|
} catch {}
|
|
22570
22648
|
return {
|
|
22571
22649
|
factIds: [],
|
|
@@ -22954,7 +23032,7 @@ var init_native_cli_entry_qwen = __esm(() => {
|
|
|
22954
23032
|
});
|
|
22955
23033
|
|
|
22956
23034
|
// src/adapters/definitions/native-cli-preview-qwen.ts
|
|
22957
|
-
import { join as
|
|
23035
|
+
import { join as join34 } from "path";
|
|
22958
23036
|
function previewQwen(ctx) {
|
|
22959
23037
|
const { tool, args, cwd, stateDir, cliDir, config } = ctx;
|
|
22960
23038
|
const state = previewState(args, ctx.baseEnvNames), { unresolved, value } = state;
|
|
@@ -22984,7 +23062,7 @@ function previewQwen(ctx) {
|
|
|
22984
23062
|
form: "headless",
|
|
22985
23063
|
projectRoot: cwd,
|
|
22986
23064
|
stateDir,
|
|
22987
|
-
entrypoint:
|
|
23065
|
+
entrypoint: join34(cliDir, "main.js"),
|
|
22988
23066
|
userArgs: [],
|
|
22989
23067
|
unattended: false,
|
|
22990
23068
|
env: {},
|
|
@@ -30875,7 +30953,7 @@ init_project();
|
|
|
30875
30953
|
// src/hub/instance-config.ts
|
|
30876
30954
|
init_registry();
|
|
30877
30955
|
import { readFileSync as readFileSync17 } from "fs";
|
|
30878
|
-
import { join as
|
|
30956
|
+
import { join as join37 } from "path";
|
|
30879
30957
|
|
|
30880
30958
|
// src/adapters/external-metadata.ts
|
|
30881
30959
|
import { types as types9 } from "util";
|
|
@@ -30989,7 +31067,7 @@ init_registry();
|
|
|
30989
31067
|
init_child_process();
|
|
30990
31068
|
init_git();
|
|
30991
31069
|
import { lstatSync as lstatSync22, statSync as statSync6 } from "fs";
|
|
30992
|
-
import { dirname as dirname16, join as
|
|
31070
|
+
import { dirname as dirname16, join as join35 } from "path";
|
|
30993
31071
|
var MACHINE_LOCAL = [
|
|
30994
31072
|
"kimi_cmd",
|
|
30995
31073
|
"permission_modes",
|
|
@@ -31029,7 +31107,7 @@ function configTracked(cwd, name) {
|
|
|
31029
31107
|
return;
|
|
31030
31108
|
let opened;
|
|
31031
31109
|
try {
|
|
31032
|
-
opened = statSync6(
|
|
31110
|
+
opened = statSync6(join35(cwd, ".agenthub", name));
|
|
31033
31111
|
} catch {}
|
|
31034
31112
|
return r.stdout.split("\x00").filter(Boolean).some((row) => {
|
|
31035
31113
|
const path = row.slice(row.indexOf("\t") + 1);
|
|
@@ -31038,7 +31116,7 @@ function configTracked(cwd, name) {
|
|
|
31038
31116
|
if (!opened)
|
|
31039
31117
|
return path === `.agenthub/${name}`;
|
|
31040
31118
|
try {
|
|
31041
|
-
const s = statSync6(
|
|
31119
|
+
const s = statSync6(join35(cwd, path));
|
|
31042
31120
|
return !!opened && s.dev === opened.dev && s.ino === opened.ino;
|
|
31043
31121
|
} catch {
|
|
31044
31122
|
return false;
|
|
@@ -31096,7 +31174,7 @@ function readAdapterModuleDeclarations(cwd, layers) {
|
|
|
31096
31174
|
// src/hub/control-client.ts
|
|
31097
31175
|
init_project();
|
|
31098
31176
|
import { readFileSync as readFileSync16 } from "fs";
|
|
31099
|
-
import { join as
|
|
31177
|
+
import { join as join36, resolve as resolve18 } from "path";
|
|
31100
31178
|
|
|
31101
31179
|
// src/hub/tool-request.ts
|
|
31102
31180
|
init_capabilities();
|
|
@@ -31200,8 +31278,8 @@ function controlProtocolWindow(descriptor) {
|
|
|
31200
31278
|
}
|
|
31201
31279
|
function readControl(stateDir) {
|
|
31202
31280
|
try {
|
|
31203
|
-
const status = JSON.parse(readFileSync16(
|
|
31204
|
-
const token = readFileSync16(
|
|
31281
|
+
const status = JSON.parse(readFileSync16(join36(stateDir, "status.json"), "utf8"));
|
|
31282
|
+
const token = readFileSync16(join36(stateDir, "control-token"), "utf8").trim();
|
|
31205
31283
|
if (!Number.isInteger(status.controlPort) || status.controlPort < 1 || status.controlPort > 65535 || !token)
|
|
31206
31284
|
return;
|
|
31207
31285
|
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;
|
|
@@ -31614,6 +31692,7 @@ init_sdlc();
|
|
|
31614
31692
|
init_review_findings();
|
|
31615
31693
|
init_eval_gate();
|
|
31616
31694
|
init_sdlc();
|
|
31695
|
+
var MERGE_READBACK_INTERVAL_MS = 5 * 60000;
|
|
31617
31696
|
|
|
31618
31697
|
// src/hub/sdlc-mirror.ts
|
|
31619
31698
|
init_envelope();
|
|
@@ -31714,6 +31793,8 @@ QUIET_EVENTS.add("plan observed");
|
|
|
31714
31793
|
QUIET_EVENTS.add("planner changed");
|
|
31715
31794
|
QUIET_EVENTS.add("claim verdict");
|
|
31716
31795
|
QUIET_EVENTS.add("invocation");
|
|
31796
|
+
QUIET_EVENTS.add("check run passed");
|
|
31797
|
+
QUIET_EVENTS.add("check run failed");
|
|
31717
31798
|
QUIET_EVENTS.add("wait recorded");
|
|
31718
31799
|
QUIET_EVENTS.add("shell branch bound");
|
|
31719
31800
|
var OWNERSHIP_EVENTS = new Set(["assigned", "escalated", "reassigned", "unassigned"]);
|
|
@@ -31966,7 +32047,7 @@ var INSTANCE_CONFIG_FILES = ["config.json", "config.local.json"];
|
|
|
31966
32047
|
function readInstanceConfigLayers(cwd) {
|
|
31967
32048
|
return INSTANCE_CONFIG_FILES.flatMap((name) => {
|
|
31968
32049
|
try {
|
|
31969
|
-
return [{ name, raw: JSON.parse(readFileSync17(
|
|
32050
|
+
return [{ name, raw: JSON.parse(readFileSync17(join37(cwd, ".agenthub", name), "utf8")) }];
|
|
31970
32051
|
} catch (error) {
|
|
31971
32052
|
if (error.code === "ENOENT")
|
|
31972
32053
|
return [];
|
|
@@ -40359,7 +40440,7 @@ class StdioServerTransport {
|
|
|
40359
40440
|
|
|
40360
40441
|
// src/adapters/claude-channel.ts
|
|
40361
40442
|
import { readFileSync as readFileSync18 } from "fs";
|
|
40362
|
-
import { join as
|
|
40443
|
+
import { join as join40 } from "path";
|
|
40363
40444
|
|
|
40364
40445
|
// src/hub/channel-project.ts
|
|
40365
40446
|
init_registry();
|
|
@@ -40368,7 +40449,7 @@ init_registry();
|
|
|
40368
40449
|
init_git();
|
|
40369
40450
|
init_project();
|
|
40370
40451
|
import { lstatSync as lstatSync24 } from "fs";
|
|
40371
|
-
import { join as
|
|
40452
|
+
import { join as join38, resolve as resolve20 } from "path";
|
|
40372
40453
|
var refuse = (reason) => {
|
|
40373
40454
|
throw new Error(`instance execution workspace refused: ${reason}`);
|
|
40374
40455
|
};
|
|
@@ -40415,7 +40496,7 @@ function resolveInstanceExecutionCwd(projectRoot, id, declarations, roles, adapt
|
|
|
40415
40496
|
} catch {
|
|
40416
40497
|
return refuse("workspace paths are unavailable");
|
|
40417
40498
|
}
|
|
40418
|
-
const expected =
|
|
40499
|
+
const expected = join38(root, ".worktrees", id);
|
|
40419
40500
|
if (cwd !== expected)
|
|
40420
40501
|
return refuse("worktree must be the exact managed instance directory");
|
|
40421
40502
|
const inventory = git(root, ["worktree", "list", "--porcelain", "-z"]);
|
|
@@ -40445,7 +40526,7 @@ function resolveInstanceExecutionCwd(projectRoot, id, declarations, roles, adapt
|
|
|
40445
40526
|
// src/hub/channel-project.ts
|
|
40446
40527
|
init_project();
|
|
40447
40528
|
import { existsSync as existsSync10 } from "fs";
|
|
40448
|
-
import { join as
|
|
40529
|
+
import { join as join39 } from "path";
|
|
40449
40530
|
function channelProject(cwd, env, policyRoles) {
|
|
40450
40531
|
const override = env.AGENTHUB_STATE_DIR?.trim(), declared = env.AGENTHUB_PROJECT_DIR?.trim();
|
|
40451
40532
|
if (env.AGENTHUB_MODE === "tools" && override && declared)
|
|
@@ -40475,7 +40556,7 @@ function channelProject(cwd, env, policyRoles) {
|
|
|
40475
40556
|
const inherited = inheritedStateDir(own.root, env);
|
|
40476
40557
|
if (inherited)
|
|
40477
40558
|
return { root: own.root, stateDir: inherited, inherited: true };
|
|
40478
|
-
if (override && !existsSync10(
|
|
40559
|
+
if (override && !existsSync10(join39(own.root, ".agenthub", "config.json")))
|
|
40479
40560
|
return asSession();
|
|
40480
40561
|
return { root: own.root, stateDir: own.stateDir, inherited: false };
|
|
40481
40562
|
}
|
|
@@ -40611,7 +40692,7 @@ function currentClaudeChannelEvidence() {
|
|
|
40611
40692
|
var own5 = channelProject(process.cwd(), process.env, (root) => {
|
|
40612
40693
|
const read = (name) => {
|
|
40613
40694
|
try {
|
|
40614
|
-
return JSON.parse(readFileSync18(
|
|
40695
|
+
return JSON.parse(readFileSync18(join40(root, ".agenthub", name), "utf8")).roles ?? {};
|
|
40615
40696
|
} catch {
|
|
40616
40697
|
return {};
|
|
40617
40698
|
}
|
|
@@ -40637,7 +40718,7 @@ var channel = !toolsMode && channelEvidence === "development-channel-launch";
|
|
|
40637
40718
|
function roles2() {
|
|
40638
40719
|
const read = (name) => {
|
|
40639
40720
|
try {
|
|
40640
|
-
return JSON.parse(readFileSync18(
|
|
40721
|
+
return JSON.parse(readFileSync18(join40(projectRoot2, ".agenthub", name), "utf8")).roles ?? {};
|
|
40641
40722
|
} catch {
|
|
40642
40723
|
return {};
|
|
40643
40724
|
}
|
|
@@ -40656,7 +40737,7 @@ function sessionProfile() {
|
|
|
40656
40737
|
for (const name of ["config.json", "config.local.json"]) {
|
|
40657
40738
|
let data;
|
|
40658
40739
|
try {
|
|
40659
|
-
data = JSON.parse(readFileSync18(
|
|
40740
|
+
data = JSON.parse(readFileSync18(join40(projectRoot2, ".agenthub", name), "utf8"));
|
|
40660
40741
|
} catch (error) {
|
|
40661
40742
|
if (error.code === "ENOENT")
|
|
40662
40743
|
continue;
|
|
@@ -40683,7 +40764,7 @@ function sessionRoles() {
|
|
|
40683
40764
|
const read = (name) => {
|
|
40684
40765
|
let raw;
|
|
40685
40766
|
try {
|
|
40686
|
-
raw = JSON.parse(readFileSync18(
|
|
40767
|
+
raw = JSON.parse(readFileSync18(join40(projectRoot2, ".agenthub", name), "utf8")).catalog_roles;
|
|
40687
40768
|
} catch {
|
|
40688
40769
|
return {};
|
|
40689
40770
|
}
|
|
@@ -40714,14 +40795,14 @@ var HELD = `another session is attached to the hub as "${peerId}"; this one is s
|
|
|
40714
40795
|
var INBOX_CAP = 200;
|
|
40715
40796
|
function sessionSupported() {
|
|
40716
40797
|
try {
|
|
40717
|
-
return (JSON.parse(readFileSync18(
|
|
40798
|
+
return (JSON.parse(readFileSync18(join40(stateDir, "status.json"), "utf8")).features ?? []).includes("session_identity");
|
|
40718
40799
|
} catch {
|
|
40719
40800
|
return false;
|
|
40720
40801
|
}
|
|
40721
40802
|
}
|
|
40722
40803
|
function peerHeld() {
|
|
40723
40804
|
try {
|
|
40724
|
-
const status = JSON.parse(readFileSync18(
|
|
40805
|
+
const status = JSON.parse(readFileSync18(join40(stateDir, "status.json"), "utf8"));
|
|
40725
40806
|
const peer = status.peers?.[peerId];
|
|
40726
40807
|
if (channel && peer?.toolsOnly && !peer.claiming)
|
|
40727
40808
|
return false;
|