@staix/agent-hub 0.43.0 → 0.45.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 +61 -0
- package/README.md +3 -8
- package/docs/agent-notes/adapters.md +2 -2
- package/docs/agent-notes/daemon.md +4 -4
- package/docs/agent-notes/local-worker.md +2 -1
- package/docs/agent-notes/security-review.md +1 -1
- package/docs/agent-notes/tasks.md +5 -2
- package/docs/agent-notes/tests.md +4 -3
- package/docs/design/adapters.md +4 -2
- package/docs/design/agent-hub-architecture.md +2 -0
- package/docs/design/agent-hub.md +1 -1
- package/docs/design/roadmap.md +75 -2
- package/docs/design/supervision.md +34 -2
- package/docs/design/task-board.md +36 -2
- package/docs/dogfood.md +20 -5
- package/docs/events.md +9 -3
- package/docs/influences.md +7 -0
- package/docs/memory.md +4 -4
- package/docs/operations.md +84 -31
- package/docs/quickstart.md +14 -2
- package/docs/research.md +18 -0
- package/docs/roadmap.json +4 -0
- package/docs/roadmap.md +9 -0
- package/docs/sdlc.md +19 -4
- package/docs/security.md +4 -4
- 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/verification/2026-11-19-claude-implementer-2.1.328.md +49 -0
- package/docs/verification/2026-11-20-claude-implementer-2.1.329.md +49 -0
- package/docs/verification/2026-11-20-sdlc-metrics-diagnosis.md +7 -0
- package/docs/verification/2026-11-21-0.45.0.md +69 -0
- package/docs/verification/2026-11-22-codex-0171-reviewer-isolation.md +47 -0
- package/docs/verified.json +32 -26
- package/package.json +2 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +585 -264
- package/plugins/agent-hub/kimi-review-policy-worker.js +5 -5
- package/plugins/agent-hub/server.js +629 -293
- package/scripts/check-docs.mjs +9 -1
- package/src/adapters/acp.ts +11 -1
- package/src/adapters/compat.ts +3 -3
- package/src/adapters/definitions/builtin-metadata.ts +2 -2
- package/src/adapters/definitions/native-context.ts +10 -0
- package/src/adapters/jcode.ts +10 -0
- package/src/adapters/local-worker.ts +3 -2
- package/src/adapters/pi.ts +15 -4
- package/src/cli/console-state.ts +3 -1
- package/src/cli/help.ts +3 -1
- package/src/cli/identity.ts +2 -1
- package/src/cli/main.ts +12 -6
- package/src/cli/output.ts +2 -2
- package/src/cli/recovery-package.ts +16 -3
- package/src/cli/roadmap-write.ts +59 -0
- package/src/cli/roadmap.ts +81 -4
- package/src/cli/sdlc-output.ts +11 -1
- package/src/cli/upgrade-runtime.ts +10 -6
- package/src/cli/upgrade.ts +9 -3
- package/src/hub/agent-mem-range.ts +43 -0
- package/src/hub/board.ts +116 -2
- package/src/hub/bus.ts +4 -0
- package/src/hub/check-runner.ts +25 -1
- package/src/hub/claude-shell-wrapper.ts +2 -1
- package/src/hub/config-apply.ts +4 -2
- package/src/hub/config-trust.ts +1 -1
- package/src/hub/context-window.ts +1 -1
- package/src/hub/control-write-trace.ts +39 -2
- package/src/hub/cost-governance.ts +11 -7
- package/src/hub/daemon.ts +318 -53
- package/src/hub/dogfood-read.ts +4 -2
- package/src/hub/edit-guard.ts +100 -0
- package/src/hub/events.ts +79 -8
- package/src/hub/facts.ts +85 -2
- package/src/hub/hub-tools.ts +3 -1
- package/src/hub/lifecycle.ts +6 -1
- package/src/hub/log-rotation.ts +130 -0
- package/src/hub/memory-profile.ts +137 -21
- package/src/hub/no-writes.ts +1 -0
- package/src/hub/operational-authority.ts +3 -2
- package/src/hub/operational-settings.ts +2 -2
- package/src/hub/quota-events.ts +40 -0
- package/src/hub/recovery-store.ts +70 -24
- package/src/hub/report.ts +1 -1
- package/src/hub/research-experiments.ts +132 -0
- package/src/hub/research-quality.ts +13 -3
- package/src/hub/research-record.ts +38 -2
- package/src/hub/research.ts +128 -28
- package/src/hub/restart.ts +49 -2
- package/src/hub/roadmap-check.ts +65 -0
- package/src/hub/roadmap-decompose.ts +80 -0
- package/src/hub/roadmap-export.ts +27 -0
- package/src/hub/roadmap-sync.ts +97 -0
- package/src/hub/roadmap.ts +40 -0
- package/src/hub/runtime-capture-prune.ts +9 -1
- package/src/hub/runtime-prune-health.ts +5 -1
- package/src/hub/sdlc-branch-ci.ts +128 -0
- package/src/hub/sdlc-merge.ts +12 -5
- package/src/hub/sdlc-metrics.ts +33 -10
- package/src/hub/sdlc.ts +90 -10
- package/src/hub/settings.ts +1 -0
- package/src/hub/snapshots.ts +56 -1
- package/src/hub/startup-event-seeds.ts +21 -15
- package/src/hub/startup-timing.ts +3 -1
- package/src/hub/supervision-proposals.ts +10 -2
- package/src/hub/supervision-rules.ts +27 -4
- package/src/hub/supervision.ts +7 -0
- package/src/hub/task-pr.ts +47 -0
- package/src/hub/task-shell-command.ts +124 -0
- package/src/hub/task-worktree.ts +18 -11
- package/src/hub/tasks.ts +617 -45
- package/src/hub/usage-rollup.ts +35 -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/local/tools.ts +13 -1
- package/src/memory/brief.ts +10 -1
- package/src/memory/client.ts +3 -2
- package/src/pi/extension.ts +15 -3
- package/src/pi/tool-receipts.ts +26 -0
|
@@ -112,7 +112,7 @@ var init_envelope = __esm(() => {
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
// node_modules/@staix/agent-mem/src/memory/platform.ts
|
|
115
|
-
import { realpathSync } from "fs";
|
|
115
|
+
import { lstatSync, realpathSync } from "fs";
|
|
116
116
|
import { basename, dirname, join, resolve, sep } from "path";
|
|
117
117
|
import { createRequire } from "module";
|
|
118
118
|
import { createHash } from "crypto";
|
|
@@ -216,7 +216,7 @@ var init_git = __esm(() => {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
// src/hub/project.ts
|
|
219
|
-
import { existsSync, lstatSync, readFileSync } from "fs";
|
|
219
|
+
import { existsSync, lstatSync as lstatSync2, readFileSync } from "fs";
|
|
220
220
|
import { homedir } from "os";
|
|
221
221
|
import { dirname as dirname2, isAbsolute, join as join2, resolve as resolve2 } from "path";
|
|
222
222
|
function gitRoot(dir) {
|
|
@@ -234,7 +234,7 @@ function projectRoot(cwd) {
|
|
|
234
234
|
let dir;
|
|
235
235
|
try {
|
|
236
236
|
dir = canonicalPath(input);
|
|
237
|
-
if (!
|
|
237
|
+
if (!lstatSync2(dir).isDirectory())
|
|
238
238
|
throw new Error(`${cwd} is not a directory`);
|
|
239
239
|
} catch (error) {
|
|
240
240
|
throw new Error(`cannot resolve project directory ${cwd}: ${error.message}`);
|
|
@@ -325,7 +325,7 @@ function finishPreview(ctx, launch, envNames, unresolved, metadata, settings) {
|
|
|
325
325
|
var REDACTED = "[redacted]", UNRESOLVED = "[unresolved]";
|
|
326
326
|
|
|
327
327
|
// src/adapters/compat.ts
|
|
328
|
-
import { closeSync, constants, fstatSync, lstatSync as
|
|
328
|
+
import { closeSync, constants, fstatSync, lstatSync as lstatSync3, mkdirSync, openSync, readSync, renameSync, unlinkSync, writeFileSync } from "fs";
|
|
329
329
|
import { dirname as dirname3, join as join3 } from "path";
|
|
330
330
|
function inLine(version, line) {
|
|
331
331
|
const v = parts(version);
|
|
@@ -393,12 +393,12 @@ var init_compat = __esm(() => {
|
|
|
393
393
|
},
|
|
394
394
|
"claude-implementer": {
|
|
395
395
|
label: "Claude headless implementer",
|
|
396
|
-
verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322", "2.1.323"],
|
|
396
|
+
verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322", "2.1.323", "2.1.328", "2.1.329"],
|
|
397
397
|
gate: "contract",
|
|
398
398
|
probe: ["claude", "--version"],
|
|
399
399
|
parse: (out) => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
|
|
400
400
|
trustNote: "The native prompt-tool transport and host-wrapper rewrite, environment isolation and replay contract have isolated receipts. No dontAsk/bypass fallback exists; another version's permission or rewrite behavior is unverified.",
|
|
401
|
-
receipt: "docs/verification/2026-11-
|
|
401
|
+
receipt: "docs/verification/2026-11-20-claude-implementer-2.1.329.md"
|
|
402
402
|
},
|
|
403
403
|
"codex-review": {
|
|
404
404
|
label: "Codex reviewer (codex-cli)",
|
|
@@ -514,7 +514,7 @@ var init_same_directory = __esm(() => {
|
|
|
514
514
|
|
|
515
515
|
// src/cli/agy-mcp.ts
|
|
516
516
|
import { randomUUID } from "crypto";
|
|
517
|
-
import { closeSync as closeSync2, fstatSync as fstatSync2, lstatSync as
|
|
517
|
+
import { closeSync as closeSync2, fstatSync as fstatSync2, lstatSync as lstatSync4, mkdirSync as mkdirSync2, openSync as openSync2, readFileSync as readFileSync2, renameSync as renameSync2, rmdirSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
518
518
|
import { isAbsolute as isAbsolute2, join as join4, resolve as resolve3 } from "path";
|
|
519
519
|
import { isDeepStrictEqual } from "util";
|
|
520
520
|
function object(value) {
|
|
@@ -568,13 +568,13 @@ function validateOptions(options) {
|
|
|
568
568
|
return { root, peer };
|
|
569
569
|
}
|
|
570
570
|
function safeDirectory(path) {
|
|
571
|
-
const stat =
|
|
571
|
+
const stat = lstatSync4(path, { throwIfNoEntry: false });
|
|
572
572
|
if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
|
|
573
573
|
throw new Error(`${path} must be a project directory, not a link`);
|
|
574
574
|
return stat;
|
|
575
575
|
}
|
|
576
576
|
function safeFile(path) {
|
|
577
|
-
const stat =
|
|
577
|
+
const stat = lstatSync4(path, { throwIfNoEntry: false });
|
|
578
578
|
if (!stat)
|
|
579
579
|
return;
|
|
580
580
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > MAX_CONFIG_BYTES)
|
|
@@ -759,7 +759,7 @@ function internalPlan(options) {
|
|
|
759
759
|
return { file: pluginDir, tracked, changed, action: changed ? "create or update the managed agent-hub plugin" : "keep the managed agent-hub plugin", root, pluginDir, canonicalRoot, ...canonicalPluginDir ? { canonicalPluginDir } : {}, ...directories ? { directories } : {}, targets };
|
|
760
760
|
}
|
|
761
761
|
function identityMatches(path, before) {
|
|
762
|
-
const now =
|
|
762
|
+
const now = lstatSync4(path, { throwIfNoEntry: false });
|
|
763
763
|
return before ? !!now && now.dev === before.dev && now.ino === before.ino : !now;
|
|
764
764
|
}
|
|
765
765
|
function atomicWrite(path, bytes, expected, plan) {
|
|
@@ -778,7 +778,7 @@ function atomicWrite(path, bytes, expected, plan) {
|
|
|
778
778
|
if (!identityMatches(path, expected))
|
|
779
779
|
throw new Error(`${path} changed while the managed plugin was being written`);
|
|
780
780
|
renameSync2(temporary, path);
|
|
781
|
-
const stat =
|
|
781
|
+
const stat = lstatSync4(path);
|
|
782
782
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1)
|
|
783
783
|
throw new Error(`${path} changed while the managed plugin was written`);
|
|
784
784
|
return { dev: stat.dev, ino: stat.ino };
|
|
@@ -786,7 +786,7 @@ function atomicWrite(path, bytes, expected, plan) {
|
|
|
786
786
|
if (fd !== undefined)
|
|
787
787
|
closeSync2(fd);
|
|
788
788
|
try {
|
|
789
|
-
const current =
|
|
789
|
+
const current = lstatSync4(temporary, { throwIfNoEntry: false });
|
|
790
790
|
if (current && tempIdentity && current.dev === tempIdentity.dev && current.ino === tempIdentity.ino)
|
|
791
791
|
unlinkSync2(temporary);
|
|
792
792
|
} catch {}
|
|
@@ -795,7 +795,7 @@ function atomicWrite(path, bytes, expected, plan) {
|
|
|
795
795
|
function rollback(plan, written, createdDirs) {
|
|
796
796
|
for (const { target, own } of written.reverse()) {
|
|
797
797
|
try {
|
|
798
|
-
const now =
|
|
798
|
+
const now = lstatSync4(target.path, { throwIfNoEntry: false });
|
|
799
799
|
if (!now || now.dev !== own.dev || now.ino !== own.ino)
|
|
800
800
|
continue;
|
|
801
801
|
if (target.current)
|
|
@@ -806,7 +806,7 @@ function rollback(plan, written, createdDirs) {
|
|
|
806
806
|
}
|
|
807
807
|
for (const { path, dev, ino } of createdDirs.reverse()) {
|
|
808
808
|
try {
|
|
809
|
-
const now =
|
|
809
|
+
const now = lstatSync4(path);
|
|
810
810
|
if (now.isDirectory() && !now.isSymbolicLink() && now.dev === dev && now.ino === ino)
|
|
811
811
|
rmdirSync(path);
|
|
812
812
|
} catch {}
|
|
@@ -862,7 +862,7 @@ function cleanupAgyMcp(options) {
|
|
|
862
862
|
const deleted = [];
|
|
863
863
|
try {
|
|
864
864
|
for (const target of plan.targets) {
|
|
865
|
-
const stat =
|
|
865
|
+
const stat = lstatSync4(target.path);
|
|
866
866
|
if (!target.stat || stat.dev !== target.stat.dev || stat.ino !== target.stat.ino)
|
|
867
867
|
throw new Error(`${target.path} changed before agy plugin cleanup`);
|
|
868
868
|
}
|
|
@@ -891,7 +891,7 @@ function cleanupAgyMcp(options) {
|
|
|
891
891
|
} catch (error) {
|
|
892
892
|
for (const item of deleted.reverse()) {
|
|
893
893
|
try {
|
|
894
|
-
const current =
|
|
894
|
+
const current = lstatSync4(item.path, { throwIfNoEntry: false });
|
|
895
895
|
if (item.own) {
|
|
896
896
|
if (current?.dev === item.own.dev && current.ino === item.own.ino)
|
|
897
897
|
atomicWrite(item.path, item.bytes, current, plan);
|
|
@@ -2750,7 +2750,7 @@ var init_claude_print = __esm(() => {
|
|
|
2750
2750
|
// src/adapters/codex-review-isolation.ts
|
|
2751
2751
|
import { createHash as createHash2 } from "crypto";
|
|
2752
2752
|
import { spawn as spawn3 } from "child_process";
|
|
2753
|
-
import { existsSync as existsSync3, lstatSync as
|
|
2753
|
+
import { existsSync as existsSync3, lstatSync as lstatSync5, mkdirSync as mkdirSync3, mkdtempSync, readFileSync as readFileSync3, rmSync, statSync, symlinkSync, writeFileSync as writeFileSync3 } from "fs";
|
|
2754
2754
|
import { createRequire as createRequire2 } from "module";
|
|
2755
2755
|
import { homedir as homedir2, tmpdir } from "os";
|
|
2756
2756
|
import { basename as basename2, delimiter, dirname as dirname5, isAbsolute as isAbsolute3, join as join5, relative, resolve as resolve5 } from "path";
|
|
@@ -2872,7 +2872,7 @@ function toml(value) {
|
|
|
2872
2872
|
}
|
|
2873
2873
|
function metadata(file) {
|
|
2874
2874
|
try {
|
|
2875
|
-
const link =
|
|
2875
|
+
const link = lstatSync5(file), stat = statSync(file);
|
|
2876
2876
|
return [link.dev, link.ino, link.mtimeMs, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
|
|
2877
2877
|
} catch (error) {
|
|
2878
2878
|
if (error.code === "ENOENT")
|
|
@@ -2918,7 +2918,7 @@ function credentialCanonicalPath(lexical) {
|
|
|
2918
2918
|
let ancestor = lexical;
|
|
2919
2919
|
for (;; ) {
|
|
2920
2920
|
try {
|
|
2921
|
-
|
|
2921
|
+
lstatSync5(ancestor);
|
|
2922
2922
|
break;
|
|
2923
2923
|
} catch (error) {
|
|
2924
2924
|
if (error.code !== "ENOENT" || dirname5(ancestor) === ancestor)
|
|
@@ -3279,7 +3279,7 @@ var init_codex_review_isolation = __esm(() => {
|
|
|
3279
3279
|
});
|
|
3280
3280
|
|
|
3281
3281
|
// src/adapters/kimi-wire-usage.ts
|
|
3282
|
-
import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync3, lstatSync as
|
|
3282
|
+
import { closeSync as closeSync3, constants as constants2, fstatSync as fstatSync3, lstatSync as lstatSync6, openSync as openSync3, readSync as fsReadSync, readdirSync, statSync as statSync2 } from "fs";
|
|
3283
3283
|
import { createHash as createHash3 } from "crypto";
|
|
3284
3284
|
import { join as join6, sep as sep2 } from "path";
|
|
3285
3285
|
function kimiCountedTokens(row) {
|
|
@@ -3483,7 +3483,7 @@ class KimiWireReader {
|
|
|
3483
3483
|
for (const name of names) {
|
|
3484
3484
|
const path = join6(dir, "agents", name, "wire.jsonl");
|
|
3485
3485
|
try {
|
|
3486
|
-
|
|
3486
|
+
lstatSync6(path);
|
|
3487
3487
|
} catch (error) {
|
|
3488
3488
|
if (error.code === "ENOENT")
|
|
3489
3489
|
continue;
|
|
@@ -3982,10 +3982,10 @@ var init_kimi_usage = __esm(() => {
|
|
|
3982
3982
|
|
|
3983
3983
|
// src/adapters/kimi-review-policy.ts
|
|
3984
3984
|
import { createHash as createHash4 } from "crypto";
|
|
3985
|
-
import { lstatSync as
|
|
3985
|
+
import { lstatSync as lstatSync7, readFileSync as readFileSync4 } from "fs";
|
|
3986
3986
|
import { dirname as dirname6, join as join7, resolve as resolve6 } from "path";
|
|
3987
3987
|
function readKimiReviewFile(file, limit = 262144) {
|
|
3988
|
-
const stat =
|
|
3988
|
+
const stat = lstatSync7(file);
|
|
3989
3989
|
if (!stat.isFile() || stat.size > limit)
|
|
3990
3990
|
throw new Error("unsupported reviewer file");
|
|
3991
3991
|
return readFileSync4(file, "utf8");
|
|
@@ -3998,7 +3998,7 @@ function assertCleanCwdAncestors(...candidates) {
|
|
|
3998
3998
|
if (!seen.has(ancestor)) {
|
|
3999
3999
|
seen.add(ancestor);
|
|
4000
4000
|
for (const marker of [".git", ".kimi-code", "AGENTS.md"]) {
|
|
4001
|
-
if (
|
|
4001
|
+
if (lstatSync7(join7(ancestor, marker), { throwIfNoEntry: false }) !== undefined) {
|
|
4002
4002
|
throw new Error("private cwd ancestor contains ambient configuration");
|
|
4003
4003
|
}
|
|
4004
4004
|
}
|
|
@@ -4034,7 +4034,7 @@ function projectKimiReviewPolicyBinding(binding) {
|
|
|
4034
4034
|
function checkKimiReviewPolicy(binding) {
|
|
4035
4035
|
try {
|
|
4036
4036
|
assertCleanCwdAncestors(binding.lexicalCwd, binding.physicalCwd);
|
|
4037
|
-
const now =
|
|
4037
|
+
const now = lstatSync7(binding.executable), expected = binding.executableStat;
|
|
4038
4038
|
return realPath(binding.sourcePath) === binding.source && now.dev === expected.dev && now.ino === expected.ino && now.size === expected.size && now.mtimeMs === expected.mtimeMs && now.ctimeMs === expected.ctimeMs && kimiReviewFingerprint(readKimiReviewFile(binding.sourceConfig)) === binding.sourceConfigHash && binding.privateFiles.length === 3 && binding.privateFiles.every((file) => kimiReviewFingerprint(readKimiReviewFile(file.path, 2097152)) === file.hash) && binding.authTargets.length === 3 && ["credentials", "oauth", "device_id"].every((name, index) => realPath(join7(binding.source, name)) === binding.authTargets[index] && realPath(join7(binding.tool, name)) === binding.authTargets[index]);
|
|
4039
4039
|
} catch {
|
|
4040
4040
|
return false;
|
|
@@ -4174,7 +4174,7 @@ var init_kimi_review_policy_worker = __esm(() => {
|
|
|
4174
4174
|
|
|
4175
4175
|
// src/adapters/kimi-review.ts
|
|
4176
4176
|
import { spawn as spawn4 } from "child_process";
|
|
4177
|
-
import { existsSync as existsSync4, lstatSync as
|
|
4177
|
+
import { existsSync as existsSync4, lstatSync as lstatSync8, mkdirSync as mkdirSync4, mkdtempSync as mkdtempSync2, rmSync as rmSync2, symlinkSync as symlinkSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
4178
4178
|
import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
|
|
4179
4179
|
import { basename as basename3, join as join8, resolve as resolve7 } from "path";
|
|
4180
4180
|
function managedConfig(raw) {
|
|
@@ -4330,7 +4330,7 @@ async function prepareKimiReviewer(context, policyFactory = startKimiReviewPolic
|
|
|
4330
4330
|
const sourcePath = process.env.KIMI_CODE_HOME ?? join8(process.env.HOME ?? homedir3(), ".kimi-code"), source = realPath(sourcePath);
|
|
4331
4331
|
const sourceConfig = join8(source, "config.toml"), original = readKimiReviewFile(sourceConfig), selected = managedConfig(original);
|
|
4332
4332
|
const sources = ["credentials", "oauth", "device_id"].map((name) => realPath(join8(source, name)));
|
|
4333
|
-
if (!sources.every((file, index) => index < 2 ?
|
|
4333
|
+
if (!sources.every((file, index) => index < 2 ? lstatSync8(file).isDirectory() : lstatSync8(file).isFile()))
|
|
4334
4334
|
throw new Error("native OAuth directories and device identity required");
|
|
4335
4335
|
const mcp = mcpConfig(context);
|
|
4336
4336
|
if (Buffer.byteLength(context.input ?? "") > 1048576)
|
|
@@ -4364,7 +4364,7 @@ ${context.input ?? "No review is active; startup self-check only."}
|
|
|
4364
4364
|
const native = context.command ?? [Bun.which("kimi", { PATH: process.env.PATH }) ?? "kimi"];
|
|
4365
4365
|
const executable = realPath(Bun.which(native[0], { PATH: process.env.PATH }) ?? resolve7(native[0]));
|
|
4366
4366
|
const command = [executable, ...native.slice(1)];
|
|
4367
|
-
const executableStat =
|
|
4367
|
+
const executableStat = lstatSync8(executable);
|
|
4368
4368
|
const verdict = assessVersion("kimi-review", COMPAT["kimi-review"].parse(await version(command, cwd, env, context.signal)));
|
|
4369
4369
|
if (!verdict.ok)
|
|
4370
4370
|
throw new Error(verdict.reason);
|
|
@@ -4519,6 +4519,14 @@ function jcodeContextValue(value, sessionId, measuredAt) {
|
|
|
4519
4519
|
const tokens = okay ? raw.used : null, window = okay ? raw.size : null;
|
|
4520
4520
|
return { source: "jcode_usage_update", sessionId, measuredAt, tokens, window, used: tokens !== null && window !== null ? Math.min(1, tokens / window) : null };
|
|
4521
4521
|
}
|
|
4522
|
+
function piContext(value, sessionId, measuredAt) {
|
|
4523
|
+
const raw = object4(value), parts = [raw.input, raw.cacheRead, raw.cacheWrite];
|
|
4524
|
+
const valid = parts.every((n) => Number.isSafeInteger(n) && n >= 0);
|
|
4525
|
+
const sum = valid ? parts.reduce((a, n) => a + n, 0) : null;
|
|
4526
|
+
const tokens = Number.isSafeInteger(sum) ? sum : null;
|
|
4527
|
+
const window = Number.isSafeInteger(raw.contextWindow) && raw.contextWindow > 0 ? raw.contextWindow : null;
|
|
4528
|
+
return { source: "pi_usage", sessionId, measuredAt, tokens, window, used: tokens !== null && window !== null ? Math.min(1, tokens / window) : null };
|
|
4529
|
+
}
|
|
4522
4530
|
var nonnegative = (n) => typeof n === "number" && Number.isFinite(n) && n >= 0, positive = (n) => nonnegative(n) && n > 0, record2 = (v) => v !== null && typeof v === "object" && !Array.isArray(v), object4 = (v) => record2(v) ? v : {};
|
|
4523
4531
|
|
|
4524
4532
|
// src/hub/context-window.ts
|
|
@@ -5026,7 +5034,7 @@ var init_acp = __esm(() => {
|
|
|
5026
5034
|
init_model_token();
|
|
5027
5035
|
init_acp_session_model();
|
|
5028
5036
|
init_native_capabilities();
|
|
5029
|
-
TOOL_CEILING_MS =
|
|
5037
|
+
TOOL_CEILING_MS = 60 * 60000;
|
|
5030
5038
|
managedLaunches = new WeakMap;
|
|
5031
5039
|
RpcTimeoutError = class RpcTimeoutError extends Error {
|
|
5032
5040
|
};
|
|
@@ -5689,6 +5697,9 @@ ${renderDigest(envs, this.primed)}` : renderDigest(envs, this.primed) }] });
|
|
|
5689
5697
|
this.touch(Math.min(this.watchdogMs, remaining));
|
|
5690
5698
|
return;
|
|
5691
5699
|
}
|
|
5700
|
+
try {
|
|
5701
|
+
this.opts.onToolCeiling?.({ ceilingMs: ceiling });
|
|
5702
|
+
} catch {}
|
|
5692
5703
|
try {
|
|
5693
5704
|
this.activityPrivate ||= this.opts.isPrivateTurn?.() === true;
|
|
5694
5705
|
} catch {
|
|
@@ -7148,7 +7159,7 @@ __export(exports_jcode, {
|
|
|
7148
7159
|
});
|
|
7149
7160
|
import { spawn as spawn7, spawnSync as spawnSync2 } from "child_process";
|
|
7150
7161
|
import { createConnection } from "net";
|
|
7151
|
-
import { closeSync as closeSync4, constants as constants3, existsSync as existsSync5, fstatSync as fstatSync4, lstatSync as
|
|
7162
|
+
import { closeSync as closeSync4, constants as constants3, existsSync as existsSync5, fstatSync as fstatSync4, lstatSync as lstatSync9, mkdtempSync as mkdtempSync3, openSync as openSync4, readSync as readSync2, rmSync as rmSync3 } from "fs";
|
|
7152
7163
|
import { tmpdir as tmpdir3 } from "os";
|
|
7153
7164
|
import { isAbsolute as isAbsolute4, join as join9 } from "path";
|
|
7154
7165
|
function jcodeCommand(command, kind, socket, cwd, model, profile, provider, peer = "jcode") {
|
|
@@ -7193,12 +7204,12 @@ function jcodeTuiCommand(command, socket, sessionId, model, profile, provider) {
|
|
|
7193
7204
|
function savedSession(home, id) {
|
|
7194
7205
|
if (!/^[A-Za-z0-9_-]{1,128}$/.test(id))
|
|
7195
7206
|
throw new Error("invalid native session identity");
|
|
7196
|
-
const directory = join9(home, "sessions"), info =
|
|
7207
|
+
const directory = join9(home, "sessions"), info = lstatSync9(directory, { throwIfNoEntry: false });
|
|
7197
7208
|
if (!info)
|
|
7198
7209
|
return false;
|
|
7199
7210
|
if (!info.isDirectory() || info.isSymbolicLink())
|
|
7200
7211
|
throw new Error("unsafe native session directory");
|
|
7201
|
-
const file = join9(directory, `${id}.json`), entry =
|
|
7212
|
+
const file = join9(directory, `${id}.json`), entry = lstatSync9(file, { throwIfNoEntry: false });
|
|
7202
7213
|
if (!entry)
|
|
7203
7214
|
return false;
|
|
7204
7215
|
if (!entry.isFile() || entry.isSymbolicLink())
|
|
@@ -7397,7 +7408,7 @@ var init_jcode = __esm(() => {
|
|
|
7397
7408
|
ready.once("data", () => {
|
|
7398
7409
|
clearTimeout(timer);
|
|
7399
7410
|
server.off("exit", fail);
|
|
7400
|
-
if (
|
|
7411
|
+
if (lstatSync9(this.socket, { throwIfNoEntry: false })?.isSocket())
|
|
7401
7412
|
resolve();
|
|
7402
7413
|
else
|
|
7403
7414
|
reject(new Error("Jcode readiness has no private socket"));
|
|
@@ -7407,7 +7418,7 @@ var init_jcode = __esm(() => {
|
|
|
7407
7418
|
if (!this.ending && this.server === server)
|
|
7408
7419
|
this.stop("Jcode owned daemon disconnected").catch(() => {});
|
|
7409
7420
|
});
|
|
7410
|
-
const identity =
|
|
7421
|
+
const identity = lstatSync9(this.socket);
|
|
7411
7422
|
this.socketIdentity = { dev: identity.dev, ino: identity.ino };
|
|
7412
7423
|
await super.start();
|
|
7413
7424
|
} catch (error) {
|
|
@@ -7481,7 +7492,7 @@ var init_jcode = __esm(() => {
|
|
|
7481
7492
|
throw new Error(reason);
|
|
7482
7493
|
};
|
|
7483
7494
|
const sessionId = super.recoveryMetadata().sessionId;
|
|
7484
|
-
const socket =
|
|
7495
|
+
const socket = lstatSync9(this.socket, { throwIfNoEntry: false });
|
|
7485
7496
|
if (this.state !== "busy")
|
|
7486
7497
|
refuse(`jcode is ${this.state}`);
|
|
7487
7498
|
if (this.ending || !this.server || this.server.exitCode !== null || this.server.signalCode !== null || !socket?.isSocket() || socket.dev !== this.socketIdentity?.dev || socket.ino !== this.socketIdentity.ino || typeof sessionId !== "string")
|
|
@@ -7494,7 +7505,7 @@ var init_jcode = __esm(() => {
|
|
|
7494
7505
|
return "owned Jcode server changed before the steer was sent";
|
|
7495
7506
|
if (super.recoveryMetadata().sessionId !== sessionId)
|
|
7496
7507
|
return "jcode's session changed before the steer was sent";
|
|
7497
|
-
const now =
|
|
7508
|
+
const now = lstatSync9(this.socket, { throwIfNoEntry: false });
|
|
7498
7509
|
if (!now?.isSocket() || now.dev !== identity?.dev || now.ino !== identity.ino)
|
|
7499
7510
|
return "owned Jcode socket changed before the steer was sent";
|
|
7500
7511
|
return;
|
|
@@ -7519,7 +7530,7 @@ var init_jcode = __esm(() => {
|
|
|
7519
7530
|
}
|
|
7520
7531
|
tuiLaunch(expected, options = {}) {
|
|
7521
7532
|
const sessionId = super.recoveryMetadata().sessionId;
|
|
7522
|
-
const socket =
|
|
7533
|
+
const socket = lstatSync9(this.socket, { throwIfNoEntry: false });
|
|
7523
7534
|
if (this.ending || !this.server || this.server.exitCode !== null || this.server.signalCode !== null || this.state === "offline")
|
|
7524
7535
|
throw new JcodeTuiRefusal("server_not_running");
|
|
7525
7536
|
if (!socket?.isSocket() || socket.dev !== this.socketIdentity?.dev || socket.ino !== this.socketIdentity.ino)
|
|
@@ -7560,7 +7571,7 @@ var exports_qwen_dual = {};
|
|
|
7560
7571
|
__export(exports_qwen_dual, {
|
|
7561
7572
|
QwenDualPeer: () => QwenDualPeer
|
|
7562
7573
|
});
|
|
7563
|
-
import { closeSync as closeSync5, constants as constants4, fstatSync as fstatSync5, lstatSync as
|
|
7574
|
+
import { closeSync as closeSync5, constants as constants4, fstatSync as fstatSync5, lstatSync as lstatSync10, mkdirSync as mkdirSync5, openSync as openSync5, readSync as readSync3, realpathSync as realpathSync2, renameSync as renameSync3, writeFileSync as writeFileSync5, writeSync } from "fs";
|
|
7564
7575
|
import { join as join10 } from "path";
|
|
7565
7576
|
function qwenDualNamesStateDir(input, stateDir) {
|
|
7566
7577
|
const needles = new Set([".agenthub/state", ".agenthub\\state", "qwen-dual", "input.jsonl", stateDir]);
|
|
@@ -7697,7 +7708,7 @@ var init_qwen_dual = __esm(() => {
|
|
|
7697
7708
|
return { ...this.state_.sessionId ? { sessionId: this.state_.sessionId } : {}, launch: { mode: "tui" } };
|
|
7698
7709
|
}
|
|
7699
7710
|
ensureFile(path, create) {
|
|
7700
|
-
const found =
|
|
7711
|
+
const found = lstatSync10(path, { throwIfNoEntry: false });
|
|
7701
7712
|
if (!found) {
|
|
7702
7713
|
if (!create)
|
|
7703
7714
|
throw new Error("Qwen dual-output file is missing");
|
|
@@ -7762,7 +7773,7 @@ var init_qwen_dual = __esm(() => {
|
|
|
7762
7773
|
}
|
|
7763
7774
|
async start() {
|
|
7764
7775
|
mkdirSync5(this.dir, { recursive: true, mode: 448 });
|
|
7765
|
-
const dir =
|
|
7776
|
+
const dir = lstatSync10(this.dir);
|
|
7766
7777
|
if (!dir.isDirectory() || dir.isSymbolicLink() || typeof process.getuid === "function" && dir.uid !== process.getuid() || (dir.mode & 63) !== 0)
|
|
7767
7778
|
throw new Error("Qwen dual-output directory is not private to the person running the hub");
|
|
7768
7779
|
this._launch = undefined;
|
|
@@ -7802,7 +7813,7 @@ var init_qwen_dual = __esm(() => {
|
|
|
7802
7813
|
if (fenced && !this.freshBaselineAbsent) {
|
|
7803
7814
|
this.sessionSeen = this.state_.sessionId !== undefined;
|
|
7804
7815
|
this.primed = true;
|
|
7805
|
-
this.denyCursor =
|
|
7816
|
+
this.denyCursor = lstatSync10(this.eventFile).size;
|
|
7806
7817
|
this.setState("offline");
|
|
7807
7818
|
try {
|
|
7808
7819
|
this.opts.onNotice?.(`${this.id}: the hub could not verify that the old Qwen terminal is absent; inspect and end that terminal before running ahub qwen --mode tui again`);
|
|
@@ -7855,7 +7866,7 @@ var init_qwen_dual = __esm(() => {
|
|
|
7855
7866
|
}
|
|
7856
7867
|
prepareFreshEvents(fenced) {
|
|
7857
7868
|
if (!fenced) {
|
|
7858
|
-
const previous =
|
|
7869
|
+
const previous = lstatSync10(this.eventFile);
|
|
7859
7870
|
if (previous.size > 0) {
|
|
7860
7871
|
try {
|
|
7861
7872
|
renameSync3(this.eventFile, join10(this.dir, "events.prev.jsonl"));
|
|
@@ -7868,7 +7879,7 @@ var init_qwen_dual = __esm(() => {
|
|
|
7868
7879
|
let fd;
|
|
7869
7880
|
let ready = false;
|
|
7870
7881
|
try {
|
|
7871
|
-
const previous =
|
|
7882
|
+
const previous = lstatSync10(this.eventFile);
|
|
7872
7883
|
if (previous.size > 0)
|
|
7873
7884
|
renameSync3(this.eventFile, join10(this.dir, "events.prev.jsonl"));
|
|
7874
7885
|
this.ensureFile(this.eventFile, true);
|
|
@@ -8450,7 +8461,7 @@ ${text}`;
|
|
|
8450
8461
|
this.discardReadProof();
|
|
8451
8462
|
return;
|
|
8452
8463
|
}
|
|
8453
|
-
const current = fstatSync5(fd), named =
|
|
8464
|
+
const current = fstatSync5(fd), named = lstatSync10(this.eventFile);
|
|
8454
8465
|
if (!current.isFile() || !named.isFile() || named.isSymbolicLink() || current.dev !== named.dev || current.ino !== named.ino || `${current.dev}:${current.ino}` !== candidate.source || this.freshInputPending && candidate.source !== this.freshRead?.source || current.size !== this.state_.offset || named.size !== current.size) {
|
|
8455
8466
|
this.discardReadProof();
|
|
8456
8467
|
return;
|
|
@@ -8688,7 +8699,7 @@ var init_recovery_error = __esm(() => {
|
|
|
8688
8699
|
});
|
|
8689
8700
|
|
|
8690
8701
|
// src/hub/recovery-store.ts
|
|
8691
|
-
import { chmodSync, existsSync as existsSync6, linkSync, lstatSync as
|
|
8702
|
+
import { chmodSync, existsSync as existsSync6, linkSync, lstatSync as lstatSync11, mkdirSync as mkdirSync6, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
8692
8703
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
8693
8704
|
function atomicPrivateJSON(file, value) {
|
|
8694
8705
|
const temporary = `${file}.${randomUUID4()}.tmp`;
|
|
@@ -8764,10 +8775,10 @@ var init_session = __esm(() => {
|
|
|
8764
8775
|
});
|
|
8765
8776
|
|
|
8766
8777
|
// src/hub/permission-mode.ts
|
|
8767
|
-
import { lstatSync as
|
|
8778
|
+
import { lstatSync as lstatSync12 } from "fs";
|
|
8768
8779
|
function hardLinked(path) {
|
|
8769
8780
|
try {
|
|
8770
|
-
const st =
|
|
8781
|
+
const st = lstatSync12(path);
|
|
8771
8782
|
return st.isFile() && st.nlink > 1;
|
|
8772
8783
|
} catch {
|
|
8773
8784
|
return false;
|
|
@@ -8786,11 +8797,11 @@ var init_permission_mode = __esm(() => {
|
|
|
8786
8797
|
});
|
|
8787
8798
|
|
|
8788
8799
|
// src/hub/path-policy.ts
|
|
8789
|
-
import { accessSync, constants as constants5, lstatSync as
|
|
8800
|
+
import { accessSync, constants as constants5, lstatSync as lstatSync13, opendirSync, readlinkSync, statSync as statSync3 } from "fs";
|
|
8790
8801
|
import { dirname as dirname8, isAbsolute as isAbsolute5, join as join13, relative as relative3, resolve as resolve9, sep as sep3 } from "path";
|
|
8791
8802
|
function existing(path) {
|
|
8792
8803
|
try {
|
|
8793
|
-
|
|
8804
|
+
lstatSync13(path);
|
|
8794
8805
|
return true;
|
|
8795
8806
|
} catch (error) {
|
|
8796
8807
|
if (error.code === "ENOENT")
|
|
@@ -8839,7 +8850,7 @@ function directAliasTarget(path) {
|
|
|
8839
8850
|
return;
|
|
8840
8851
|
ancestor = parent;
|
|
8841
8852
|
}
|
|
8842
|
-
if (!
|
|
8853
|
+
if (!lstatSync13(ancestor).isSymbolicLink())
|
|
8843
8854
|
return;
|
|
8844
8855
|
target = resolve9(dirname8(ancestor), readlinkSync(ancestor), relative3(ancestor, target));
|
|
8845
8856
|
}
|
|
@@ -9122,11 +9133,18 @@ var init_deny = __esm(() => {
|
|
|
9122
9133
|
CONFIG_WORKTREE_NAME = [`^.*/${hfsFoldedName("config")}\\.[^/]*$`, `^.*/[^/]*${hfsFoldedName("worktree")}$`];
|
|
9123
9134
|
});
|
|
9124
9135
|
|
|
9136
|
+
// src/local/shell-environment.ts
|
|
9137
|
+
import { join as join14 } from "path";
|
|
9138
|
+
function sandboxCommandEnvironment(base, own) {
|
|
9139
|
+
return { BUN_INSTALL_CACHE_DIR: join14(own, "bun-cache"), NPM_CONFIG_CACHE: join14(own, "npm-cache"), ...base, TMPDIR: `${own}/` };
|
|
9140
|
+
}
|
|
9141
|
+
var init_shell_environment = () => {};
|
|
9142
|
+
|
|
9125
9143
|
// src/local/sandbox.ts
|
|
9126
9144
|
import { spawn as spawn8, spawnSync as spawnSync3 } from "child_process";
|
|
9127
|
-
import { existsSync as existsSync7, lstatSync as
|
|
9145
|
+
import { existsSync as existsSync7, lstatSync as lstatSync14, mkdtempSync as mkdtempSync4, readdirSync as readdirSync2, rmdirSync as rmdirSync2, rmSync as rmSync5 } from "fs";
|
|
9128
9146
|
import { homedir as homedir4, tmpdir as tmpdir4 } from "os";
|
|
9129
|
-
import { dirname as dirname10, join as
|
|
9147
|
+
import { dirname as dirname10, join as join15, resolve as resolve10 } from "path";
|
|
9130
9148
|
function developerDir() {
|
|
9131
9149
|
const out = spawnSync3("xcode-select", ["-p"], { encoding: "utf8" });
|
|
9132
9150
|
let dir = out.status === 0 ? out.stdout.trim() : "";
|
|
@@ -9145,7 +9163,7 @@ function externalGitDirs(root) {
|
|
|
9145
9163
|
}
|
|
9146
9164
|
function worktreesRoot(root) {
|
|
9147
9165
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir"], { encoding: "utf8" });
|
|
9148
|
-
return out.status === 0 && out.stdout.trim() ?
|
|
9166
|
+
return out.status === 0 && out.stdout.trim() ? join15(resolve10(root, out.stdout.trim()), "worktrees") : undefined;
|
|
9149
9167
|
}
|
|
9150
9168
|
function moduleGitDirs(root) {
|
|
9151
9169
|
const out = memoryGitSync(["-C", root, "rev-parse", "--git-common-dir", "--absolute-git-dir"], { encoding: "utf8" });
|
|
@@ -9156,12 +9174,12 @@ function moduleGitDirs(root) {
|
|
|
9156
9174
|
if (!commonRaw || !ownRaw)
|
|
9157
9175
|
return [];
|
|
9158
9176
|
const common = resolve10(root, commonRaw), own = resolve10(root, ownRaw);
|
|
9159
|
-
const roots = new Set([
|
|
9177
|
+
const roots = new Set([join15(common, "modules"), join15(own, "modules")]);
|
|
9160
9178
|
try {
|
|
9161
|
-
for (const e of readdirSync2(
|
|
9179
|
+
for (const e of readdirSync2(join15(common, "worktrees"), { withFileTypes: true })) {
|
|
9162
9180
|
if (!e.isDirectory())
|
|
9163
9181
|
continue;
|
|
9164
|
-
const modules =
|
|
9182
|
+
const modules = join15(common, "worktrees", e.name, "modules");
|
|
9165
9183
|
if (existsSync7(modules))
|
|
9166
9184
|
roots.add(modules);
|
|
9167
9185
|
}
|
|
@@ -9185,7 +9203,7 @@ function moduleGitDirs(root) {
|
|
|
9185
9203
|
}
|
|
9186
9204
|
for (const e of entries)
|
|
9187
9205
|
if (e.isDirectory())
|
|
9188
|
-
walk(
|
|
9206
|
+
walk(join15(dir, e.name), depth + 1);
|
|
9189
9207
|
};
|
|
9190
9208
|
walk(modulesRoot, 0);
|
|
9191
9209
|
const found = nesting >= MODULE_DEPTH ? [] : dirs;
|
|
@@ -9195,11 +9213,11 @@ function moduleGitDirs(root) {
|
|
|
9195
9213
|
entries.add(p);
|
|
9196
9214
|
trees.push({ root: modulesRoot, entries: [...entries], dirs: found });
|
|
9197
9215
|
for (const d of found) {
|
|
9198
|
-
tree(
|
|
9216
|
+
tree(join15(d, "modules"), nesting + 1);
|
|
9199
9217
|
try {
|
|
9200
|
-
for (const e of readdirSync2(
|
|
9201
|
-
if (e.isDirectory() && existsSync7(
|
|
9202
|
-
tree(
|
|
9218
|
+
for (const e of readdirSync2(join15(d, "worktrees"), { withFileTypes: true })) {
|
|
9219
|
+
if (e.isDirectory() && existsSync7(join15(d, "worktrees", e.name, "modules")))
|
|
9220
|
+
tree(join15(d, "worktrees", e.name, "modules"), nesting + 1);
|
|
9203
9221
|
}
|
|
9204
9222
|
} catch {}
|
|
9205
9223
|
}
|
|
@@ -9210,14 +9228,14 @@ function moduleGitDirs(root) {
|
|
|
9210
9228
|
}
|
|
9211
9229
|
function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
9212
9230
|
const home = homedir4();
|
|
9213
|
-
const inHome = (p) => p.startsWith("~/") ?
|
|
9231
|
+
const inHome = (p) => p.startsWith("~/") ? join15(home, p.slice(2)) : p;
|
|
9214
9232
|
const root = realPath(cwd);
|
|
9215
9233
|
const gitDirs = externalGitDirs(root);
|
|
9216
9234
|
const moduleGit = moduleGitDirs(root);
|
|
9217
9235
|
const worktrees = worktreesRoot(root);
|
|
9218
9236
|
const creds = [".ssh", ".aws", ".gnupg", ".config/gh", ".config/gcloud", ".kube", ".docker", ".netrc", ".npmrc", ".omniroute", ".claude", ".codex", ".kimi-code", "Library/Keychains"];
|
|
9219
9237
|
const dev = developerDir();
|
|
9220
|
-
const readable = [root, ...HOME_READABLE.map((p) =>
|
|
9238
|
+
const readable = [root, ...HOME_READABLE.map((p) => join15(home, p)), ...readAllow.map(inHome), ...gitDirs, ...dev ? [dev] : []];
|
|
9221
9239
|
const subpaths = (paths) => paths.map((p) => `(subpath ${q(p)})`).join(" ");
|
|
9222
9240
|
const globals = (names) => names.map((n) => `(global-name ${q(n)})`).join(" ");
|
|
9223
9241
|
const proxy = typeof network === "object" ? `(allow network-outbound (remote ip ${q(`localhost:${network.proxyPort}`)}))` : undefined;
|
|
@@ -9235,7 +9253,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9235
9253
|
'(allow file-ioctl (regex #"^/dev/"))',
|
|
9236
9254
|
...proxy ? [proxy] : network ? ["(allow network*)"] : []
|
|
9237
9255
|
];
|
|
9238
|
-
const places = `${creds.map((c) => `(subpath ${q(
|
|
9256
|
+
const places = `${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")} ${denyRegexes(root, deny, false).join(" ")}`;
|
|
9239
9257
|
return [
|
|
9240
9258
|
"(version 1)",
|
|
9241
9259
|
...start,
|
|
@@ -9243,7 +9261,7 @@ function profile(cwd, network, readAllow = [], deny = [], readOnly = []) {
|
|
|
9243
9261
|
...readOnly.length ? ['(allow file-write* (literal "/dev/null"))'] : [`(allow file-write* (subpath ${q(root)}) (regex #"^/dev/") ${gitDirs.map((d) => `(subpath ${q(d)})`).join(" ")})`],
|
|
9244
9262
|
`(deny file-write* ${hubWriteRegexes(root, gitDirs, moduleGit, worktrees).join(" ")})`,
|
|
9245
9263
|
...worktrees ? objectStoreRules(dirname10(worktrees)) : [],
|
|
9246
|
-
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(
|
|
9264
|
+
`(deny file-read* file-write* ${creds.map((c) => `(subpath ${q(join15(home, c))})`).join(" ")})`,
|
|
9247
9265
|
`(deny file-read* file-write* ${denyRegexes(root, deny).join(" ")})`,
|
|
9248
9266
|
...network ? [`(allow file-read* ${CA_BUNDLES.map((p) => `(literal ${q(p)})`).join(" ")} (regex ${q("/certifi/cacert\\.pem$")}))`, `(deny file-read* file-write* ${places})`] : []
|
|
9249
9267
|
].join(`
|
|
@@ -9259,10 +9277,10 @@ function sandboxedExec(argv, opts) {
|
|
|
9259
9277
|
if (opts.signal?.aborted)
|
|
9260
9278
|
return Promise.resolve({ code: null, output: "error: command cancelled before execution" });
|
|
9261
9279
|
return new Promise((resolve) => {
|
|
9262
|
-
const own = realPath(mkdtempSync4(
|
|
9280
|
+
const own = realPath(mkdtempSync4(join15(tmpdir4(), "ahub-cmd-")));
|
|
9263
9281
|
const sandbox = `${opts.profile}
|
|
9264
9282
|
(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,
|
|
9283
|
+
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
9284
|
const child = spawn8(SANDBOX_EXEC, ["-p", sandbox, ...argv], { cwd: opts.cwd, env, stdio: ["ignore", "pipe", "pipe"], detached: true });
|
|
9267
9285
|
let output = "";
|
|
9268
9286
|
let killRequested = false;
|
|
@@ -9328,14 +9346,14 @@ async function probeCommand(argv, opts) {
|
|
|
9328
9346
|
} catch {
|
|
9329
9347
|
return { code: null, output: "error: probe command authority or environment unavailable", quiescent: true };
|
|
9330
9348
|
}
|
|
9331
|
-
const own = realPath(mkdtempSync4(
|
|
9332
|
-
const created =
|
|
9349
|
+
const own = realPath(mkdtempSync4(join15(proof.temporaryRoot, "command-")));
|
|
9350
|
+
const created = lstatSync14(own);
|
|
9333
9351
|
let removed = false;
|
|
9334
9352
|
const dropOwn = () => {
|
|
9335
9353
|
if (removed)
|
|
9336
9354
|
return;
|
|
9337
9355
|
proof.physical();
|
|
9338
|
-
const current =
|
|
9356
|
+
const current = lstatSync14(own);
|
|
9339
9357
|
if (!current.isDirectory() || current.isSymbolicLink() || current.dev !== created.dev || current.ino !== created.ino || realPath(own) !== own)
|
|
9340
9358
|
throw new Error("probe command temp ownership changed");
|
|
9341
9359
|
rmdirSync2(own);
|
|
@@ -9427,6 +9445,7 @@ var init_sandbox = __esm(() => {
|
|
|
9427
9445
|
init_git();
|
|
9428
9446
|
init_deny();
|
|
9429
9447
|
init_child_process();
|
|
9448
|
+
init_shell_environment();
|
|
9430
9449
|
q = sbplString;
|
|
9431
9450
|
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
9451
|
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"];
|
|
@@ -9447,7 +9466,7 @@ var init_text_projection = __esm(() => {
|
|
|
9447
9466
|
});
|
|
9448
9467
|
|
|
9449
9468
|
// src/local/doc-read.ts
|
|
9450
|
-
import { lstatSync as
|
|
9469
|
+
import { lstatSync as lstatSync15 } from "fs";
|
|
9451
9470
|
import { extname } from "path";
|
|
9452
9471
|
function docRead(file, shown, args, port, cwd) {
|
|
9453
9472
|
const projections = port.projections();
|
|
@@ -9457,7 +9476,7 @@ function docRead(file, shown, args, port, cwd) {
|
|
|
9457
9476
|
}
|
|
9458
9477
|
let st;
|
|
9459
9478
|
try {
|
|
9460
|
-
st =
|
|
9479
|
+
st = lstatSync15(file);
|
|
9461
9480
|
} catch {
|
|
9462
9481
|
return `error: ${shown} cannot be read`;
|
|
9463
9482
|
}
|
|
@@ -9937,13 +9956,13 @@ var init_probe_errors = __esm(() => {
|
|
|
9937
9956
|
});
|
|
9938
9957
|
|
|
9939
9958
|
// src/local/probe-workspace.ts
|
|
9940
|
-
import { chmodSync as chmodSync2, constants as constants6, closeSync as closeSync7, fstatSync as fstatSync6, lstatSync as
|
|
9941
|
-
import { dirname as dirname11, isAbsolute as isAbsolute6, join as
|
|
9959
|
+
import { chmodSync as chmodSync2, constants as constants6, closeSync as closeSync7, fstatSync as fstatSync6, lstatSync as lstatSync16, 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";
|
|
9960
|
+
import { dirname as dirname11, isAbsolute as isAbsolute6, join as join16 } from "path";
|
|
9942
9961
|
function refused() {
|
|
9943
9962
|
throw new Error("probe workspace source, role, path or resource proof is unavailable");
|
|
9944
9963
|
}
|
|
9945
9964
|
function directoryIdentity(file) {
|
|
9946
|
-
const stat =
|
|
9965
|
+
const stat = lstatSync16(file);
|
|
9947
9966
|
if (!stat.isDirectory() || stat.isSymbolicLink() || realPath(file) !== file)
|
|
9948
9967
|
refused();
|
|
9949
9968
|
return { file, dev: stat.dev, ino: stat.ino };
|
|
@@ -9970,7 +9989,7 @@ function probeWorkspaceCurrent(workspace) {
|
|
|
9970
9989
|
state.current();
|
|
9971
9990
|
probeWorkspacePhysical(workspace);
|
|
9972
9991
|
for (const entry of state.identities) {
|
|
9973
|
-
const stat =
|
|
9992
|
+
const stat = lstatSync16(entry.file);
|
|
9974
9993
|
if (!stat.isFile() || stat.nlink !== 1 || stat.dev !== entry.dev || stat.ino !== entry.ino || stat.size !== entry.size || stat.mtimeMs !== entry.mtimeMs || stat.ctimeMs !== entry.ctimeMs)
|
|
9975
9994
|
refused();
|
|
9976
9995
|
}
|
|
@@ -9998,8 +10017,8 @@ var init_probe_workspace = __esm(() => {
|
|
|
9998
10017
|
});
|
|
9999
10018
|
|
|
10000
10019
|
// src/local/tools.ts
|
|
10001
|
-
import { lstatSync as
|
|
10002
|
-
import { dirname as dirname12, join as
|
|
10020
|
+
import { lstatSync as lstatSync17, mkdirSync as mkdirSync9, readFileSync as readFileSync7, statSync as statSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
10021
|
+
import { dirname as dirname12, join as join17, relative as relative4, resolve as resolve11 } from "path";
|
|
10003
10022
|
function probeCurrent(probe) {
|
|
10004
10023
|
try {
|
|
10005
10024
|
probe.current();
|
|
@@ -10008,7 +10027,7 @@ function probeCurrent(probe) {
|
|
|
10008
10027
|
}
|
|
10009
10028
|
}
|
|
10010
10029
|
function probeTargetIdentity(target) {
|
|
10011
|
-
const stat =
|
|
10030
|
+
const stat = lstatSync17(target, { throwIfNoEntry: false });
|
|
10012
10031
|
if (!stat)
|
|
10013
10032
|
return;
|
|
10014
10033
|
if (!stat.isFile())
|
|
@@ -10031,7 +10050,7 @@ function planProbeTool(name, rawArgs, ctx) {
|
|
|
10031
10050
|
if (name === "write")
|
|
10032
10051
|
maximum = Buffer.byteLength(String(value.content ?? ""), "utf8");
|
|
10033
10052
|
else {
|
|
10034
|
-
const stat =
|
|
10053
|
+
const stat = lstatSync17(target, { throwIfNoEntry: false });
|
|
10035
10054
|
if (!stat || !stat.isFile())
|
|
10036
10055
|
throw new ProbeToolRefusal("nonregular_target");
|
|
10037
10056
|
maximum = Math.min(PROBE_WORKSPACE_LIMITS.fileBytes, stat.size + Buffer.byteLength(String(value.new ?? ""), "utf8"));
|
|
@@ -10094,7 +10113,7 @@ function guardPath(ctx, path, mode) {
|
|
|
10094
10113
|
throw new ProbeToolRefusal("nonregular_target");
|
|
10095
10114
|
throw new Error(`${path} goes through a dangling symlink`);
|
|
10096
10115
|
}
|
|
10097
|
-
const real =
|
|
10116
|
+
const real = join17(realExisting, relative4(existing, abs));
|
|
10098
10117
|
const rel = relative4(root, real);
|
|
10099
10118
|
if (rel.startsWith("..") || resolve11(root, rel) !== real) {
|
|
10100
10119
|
if (ctx.probe)
|
|
@@ -10108,7 +10127,7 @@ function guardPath(ctx, path, mode) {
|
|
|
10108
10127
|
throw new Error(`${path} is on the secrets denylist`);
|
|
10109
10128
|
}
|
|
10110
10129
|
if (ctx.probe) {
|
|
10111
|
-
const stat =
|
|
10130
|
+
const stat = lstatSync17(real, { throwIfNoEntry: false });
|
|
10112
10131
|
if (stat && !stat.isFile() && !(mode === "read" && stat.isDirectory()))
|
|
10113
10132
|
throw new ProbeToolRefusal("nonregular_target");
|
|
10114
10133
|
if (stat?.isFile() && stat.nlink !== 1)
|
|
@@ -10120,7 +10139,7 @@ function guardPath(ctx, path, mode) {
|
|
|
10120
10139
|
}
|
|
10121
10140
|
if (mode === "write" && (isHubWritePath(rel) || inside && isHubWritePath(typed)))
|
|
10122
10141
|
throw new Error(`${path} is not writable by the local worker`);
|
|
10123
|
-
if (mode === "write" && ctx.readOnly?.length && (
|
|
10142
|
+
if (mode === "write" && ctx.readOnly?.length && (lstatSync17(real, { throwIfNoEntry: false })?.nlink ?? 1) > 1)
|
|
10124
10143
|
throw new Error("hardlinked write target cannot be verified with data.readonly");
|
|
10125
10144
|
if (mode === "write" && matchesPolicy(root, path, ctx.readOnly ?? []))
|
|
10126
10145
|
throw new Error("target is protected by data.readonly");
|
|
@@ -10195,11 +10214,14 @@ async function runTool(name, rawArgs, ctx) {
|
|
|
10195
10214
|
const file = guardPath(ctx, String(a.path), "read");
|
|
10196
10215
|
if (statSync4(file).size > 5000000)
|
|
10197
10216
|
return "error: file is larger than 5 MB; use bash (head, grep, sed -n) to look at parts of it";
|
|
10198
|
-
const
|
|
10217
|
+
const bytes = readFileSync7(file);
|
|
10218
|
+
const lines = bytes.toString("utf8").split(`
|
|
10199
10219
|
`);
|
|
10200
10220
|
const from = Math.max(1, Number(a.offset) || 1);
|
|
10201
10221
|
const out = lines.slice(from - 1, from - 1 + (Number(a.limit) || 2000)).map((l, i) => `${from + i} ${l}`).join(`
|
|
10202
10222
|
`);
|
|
10223
|
+
ctx.editGuard?.read(file, bytes, a.offset === undefined && a.limit === undefined && out.split(`
|
|
10224
|
+
`).length === lines.length && out.length <= OUTPUT_CAP);
|
|
10203
10225
|
return out.length > OUTPUT_CAP ? `${out.slice(0, OUTPUT_CAP)}
|
|
10204
10226
|
(truncated: read again with offset/limit)` : out;
|
|
10205
10227
|
}
|
|
@@ -10229,8 +10251,12 @@ ${preview(content)}`, "write", ctx.signal, file, undefined, String(a.path), a),
|
|
|
10229
10251
|
if (guardPath(ctx, String(a.path), "write") !== approvedTarget)
|
|
10230
10252
|
return formatProbeToolRefusal(new ProbeToolRefusal("target_changed"));
|
|
10231
10253
|
}
|
|
10254
|
+
const unverified = ctx.editGuard?.write(file);
|
|
10232
10255
|
mkdirSync9(dirname12(file), { recursive: true });
|
|
10233
10256
|
writeFileSync8(file, content);
|
|
10257
|
+
try {
|
|
10258
|
+
ctx.editGuard?.written(file, unverified);
|
|
10259
|
+
} catch {}
|
|
10234
10260
|
return `wrote ${a.path}`;
|
|
10235
10261
|
}
|
|
10236
10262
|
case "edit": {
|
|
@@ -10266,7 +10292,11 @@ ${preview(content)}`, "write", ctx.signal, file, undefined, String(a.path), a),
|
|
|
10266
10292
|
if (guardPath(ctx, String(a.path), "write") !== approvedTarget || readFileSync7(file, "utf8") !== text)
|
|
10267
10293
|
return formatProbeToolRefusal(new ProbeToolRefusal("target_changed"));
|
|
10268
10294
|
}
|
|
10295
|
+
const unverified = ctx.editGuard?.write(file);
|
|
10269
10296
|
writeFileSync8(file, replacement);
|
|
10297
|
+
try {
|
|
10298
|
+
ctx.editGuard?.written(file, unverified);
|
|
10299
|
+
} catch {}
|
|
10270
10300
|
return `edited ${a.path}`;
|
|
10271
10301
|
}
|
|
10272
10302
|
case "bash": {
|
|
@@ -10295,7 +10325,11 @@ ${preview(content)}`, "write", ctx.signal, file, undefined, String(a.path), a),
|
|
|
10295
10325
|
if (attempt)
|
|
10296
10326
|
return "error: read-only shell proof remained unstable; no command was executed";
|
|
10297
10327
|
}
|
|
10328
|
+
const observedShell = ctx.editGuard?.shell(command);
|
|
10298
10329
|
const res = await sandboxedExec(["/bin/bash", "-c", command], { cwd: ctx.cwd, profile: ctx.sandboxProfile, readOnlyData: !!ctx.readOnly?.length, timeoutMs: (Number(a.timeout_s) || 120) * 1000, ...ctx.sandboxEnv ? { env: ctx.sandboxEnv } : {}, ...ctx.signal ? { signal: ctx.signal } : {} });
|
|
10330
|
+
try {
|
|
10331
|
+
observedShell?.();
|
|
10332
|
+
} catch {}
|
|
10299
10333
|
try {
|
|
10300
10334
|
ctx.onProcessExit?.(res.code);
|
|
10301
10335
|
} catch {}
|
|
@@ -10348,7 +10382,7 @@ note: the sandbox does not let you move a branch, tag or HEAD, or stage inside a
|
|
|
10348
10382
|
}
|
|
10349
10383
|
var APPROVAL_EXPIRED_TEXT = "error: approval expired: no person answered; do not retry this call; hand the task off or stop", ApprovalWaitStop, approvalError = (picked, denied) => picked === true ? undefined : picked === "expired" ? APPROVAL_EXPIRED_TEXT : picked === "aborted" ? "error: approval withdrawn because the turn ended; no operation was executed" : denied, probeToolPlans, lexists = (p) => {
|
|
10350
10384
|
try {
|
|
10351
|
-
|
|
10385
|
+
lstatSync17(p);
|
|
10352
10386
|
return true;
|
|
10353
10387
|
} catch {
|
|
10354
10388
|
return false;
|
|
@@ -10436,7 +10470,7 @@ __export(exports_pi, {
|
|
|
10436
10470
|
});
|
|
10437
10471
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
10438
10472
|
import { existsSync as existsSync8, mkdirSync as mkdirSync10 } from "fs";
|
|
10439
|
-
import { join as
|
|
10473
|
+
import { join as join18, resolve as resolve12 } from "path";
|
|
10440
10474
|
import { spawn as spawn9 } from "child_process";
|
|
10441
10475
|
function piVersionAsync(command, cwd, timeoutMs = 1e4) {
|
|
10442
10476
|
const [bin, ...prefix] = command;
|
|
@@ -10528,6 +10562,7 @@ var init_pi = __esm(() => {
|
|
|
10528
10562
|
PiPeer = class PiPeer extends BasePeer {
|
|
10529
10563
|
opts;
|
|
10530
10564
|
preflight;
|
|
10565
|
+
sessionModel;
|
|
10531
10566
|
hubNative = true;
|
|
10532
10567
|
hubOwned = true;
|
|
10533
10568
|
proc;
|
|
@@ -10753,6 +10788,9 @@ var init_pi = __esm(() => {
|
|
|
10753
10788
|
const session = this.recoveryMetadata().sessionId;
|
|
10754
10789
|
return typeof session === "string" ? session : undefined;
|
|
10755
10790
|
}
|
|
10791
|
+
get verifiedRecordSession() {
|
|
10792
|
+
return this.verifiedOwner() ? this.nativeSession : undefined;
|
|
10793
|
+
}
|
|
10756
10794
|
async captureResume() {
|
|
10757
10795
|
if (this.state === "offline") {
|
|
10758
10796
|
if (this.canReuseVerifiedEmptyResume())
|
|
@@ -10770,6 +10808,10 @@ var init_pi = __esm(() => {
|
|
|
10770
10808
|
const snapshot = this.opts.mode === "headless" ? (await this.waitRpc("get_state", 15000)).data : await this.sendTui({ type: "get_session_state" });
|
|
10771
10809
|
if (this.state !== "idle" || this.activeTools || snapshot?.sessionId !== this.sessionId || snapshot?.sessionFile !== this.sessionFile)
|
|
10772
10810
|
throw new Error("Pi source session changed during capture");
|
|
10811
|
+
if (this.opts.mode === "tui" && this.verifiedOwner() && this.sessionId) {
|
|
10812
|
+
this.sessionModel = stateModelId(snapshot);
|
|
10813
|
+
this.opts.onContext?.(snapshot.context, this.sessionId);
|
|
10814
|
+
}
|
|
10773
10815
|
if (!this.observeSnapshotTitle(snapshot, titleRevisionBefore, titleEpochBefore))
|
|
10774
10816
|
throw new Error("Pi source session title changed during capture; retry with a fresh native session snapshot");
|
|
10775
10817
|
const empty = this.opts.mode === "headless" ? snapshot.messageCount === 0 && snapshot.pendingMessageCount === 0 && snapshot.isStreaming === false && snapshot.isCompacting !== true && !snapshot.sessionName : snapshot.empty === true && snapshot.idle === true;
|
|
@@ -11035,7 +11077,7 @@ var init_pi = __esm(() => {
|
|
|
11035
11077
|
this.approvalStopReason = "";
|
|
11036
11078
|
this.approvalAbortSent = false;
|
|
11037
11079
|
mkdirSync10(this.opts.stateDir, { recursive: true });
|
|
11038
|
-
const sessions =
|
|
11080
|
+
const sessions = join18(this.opts.stateDir, "pi-sessions");
|
|
11039
11081
|
mkdirSync10(sessions, { recursive: true, mode: 448 });
|
|
11040
11082
|
if (this.opts.sessionFile) {
|
|
11041
11083
|
try {
|
|
@@ -11098,7 +11140,7 @@ var init_pi = __esm(() => {
|
|
|
11098
11140
|
return new Response("not found", { status: 404 });
|
|
11099
11141
|
} });
|
|
11100
11142
|
this.server = bridge;
|
|
11101
|
-
const extension = resolve12(
|
|
11143
|
+
const extension = resolve12(join18(import.meta.dir, "../pi/extension.ts"));
|
|
11102
11144
|
const inherited = {};
|
|
11103
11145
|
for (const key of ["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"])
|
|
11104
11146
|
if (process.env[key])
|
|
@@ -11252,6 +11294,10 @@ var init_pi = __esm(() => {
|
|
|
11252
11294
|
throw new Error("Pi roster return could not verify the current native session");
|
|
11253
11295
|
if (lifecycle !== this.rosterLifecycleRevision)
|
|
11254
11296
|
throw new Error("Pi native activity changed during roster return; retry with a fresh session snapshot");
|
|
11297
|
+
if (session) {
|
|
11298
|
+
this.sessionModel = stateModelId(snapshot);
|
|
11299
|
+
this.opts.onContext?.(snapshot.context, session);
|
|
11300
|
+
}
|
|
11255
11301
|
this.observeSnapshotTitle(snapshot, titleRevisionBefore, titleEpochBefore);
|
|
11256
11302
|
this.rosterDetached = false;
|
|
11257
11303
|
this.hubPromptId = undefined;
|
|
@@ -11422,7 +11468,7 @@ var init_pi = __esm(() => {
|
|
|
11422
11468
|
attempted = true;
|
|
11423
11469
|
if (deliveryId)
|
|
11424
11470
|
this.activeDeliveryIds.add(deliveryId);
|
|
11425
|
-
const recordPrompt = this.
|
|
11471
|
+
const recordPrompt = this.turnRecordPrompt("");
|
|
11426
11472
|
const message = [recordPrompt, envs.some((env) => env.private || remoteEnvelope(env)) ? undefined : this.opts.titlePreface?.(), renderDigest(envs, true)].filter(Boolean).join(`
|
|
11427
11473
|
`);
|
|
11428
11474
|
if (this.opts.mode === "tui") {
|
|
@@ -11532,6 +11578,11 @@ var init_pi = __esm(() => {
|
|
|
11532
11578
|
return;
|
|
11533
11579
|
}
|
|
11534
11580
|
} catch {}
|
|
11581
|
+
} else {
|
|
11582
|
+
if (this.verifiedOwner() && this.sessionModel) {
|
|
11583
|
+
this.turnModel = { model: this.sessionModel, evidence: "session" };
|
|
11584
|
+
return;
|
|
11585
|
+
}
|
|
11535
11586
|
}
|
|
11536
11587
|
if (requested)
|
|
11537
11588
|
this.turnModel = { model: requested, evidence: "configured" };
|
|
@@ -11557,9 +11608,11 @@ var init_pi = __esm(() => {
|
|
|
11557
11608
|
const slash = model.indexOf("/");
|
|
11558
11609
|
const provider = "agent-hub-local";
|
|
11559
11610
|
const modelId = model;
|
|
11560
|
-
if (this.opts.mode === "tui")
|
|
11611
|
+
if (this.opts.mode === "tui") {
|
|
11612
|
+
if (this.sessionModel !== modelId)
|
|
11613
|
+
this.sessionModel = undefined;
|
|
11561
11614
|
await this.sendTui({ type: "set_model", provider, modelId });
|
|
11562
|
-
else
|
|
11615
|
+
} else
|
|
11563
11616
|
await this.sendRpc({ type: "set_model", provider, modelId });
|
|
11564
11617
|
this.requestedModel = model;
|
|
11565
11618
|
}
|
|
@@ -11642,6 +11695,7 @@ var init_pi = __esm(() => {
|
|
|
11642
11695
|
this.opts.log?.(`[${this.id}] Pi session identity mismatch`);
|
|
11643
11696
|
return;
|
|
11644
11697
|
}
|
|
11698
|
+
this.sessionModel = stateModelId(event);
|
|
11645
11699
|
this.titleRevision = -1;
|
|
11646
11700
|
this.titleEpoch++;
|
|
11647
11701
|
this.nativeTitleEpoch = typeof event.titleEpoch === "string" && event.titleEpoch ? event.titleEpoch : undefined;
|
|
@@ -11688,6 +11742,8 @@ var init_pi = __esm(() => {
|
|
|
11688
11742
|
const generation = Number.isSafeInteger(event.generation) ? event.generation : this.budgetGeneration + 1;
|
|
11689
11743
|
if (generation <= this.budgetGeneration)
|
|
11690
11744
|
return;
|
|
11745
|
+
if (this.opts.mode === "tui" && this.sessionModel && this.verifiedOwner() && (event.sessionId === undefined || event.sessionId === this.sessionId))
|
|
11746
|
+
this.turnModel = { model: this.sessionModel, evidence: "session" };
|
|
11691
11747
|
this.modelStep = 0;
|
|
11692
11748
|
this.ceilingUnsafe = false;
|
|
11693
11749
|
this.turnObserved = false;
|
|
@@ -11718,6 +11774,14 @@ var init_pi = __esm(() => {
|
|
|
11718
11774
|
}
|
|
11719
11775
|
if (event.type === "activity" && this.state === "busy")
|
|
11720
11776
|
this.touch();
|
|
11777
|
+
if (event.type === "pi_model" && event.sessionId === this.sessionId && this.verifiedOwner() && this.sessionId) {
|
|
11778
|
+
this.sessionModel = stateModelId(event);
|
|
11779
|
+
this.opts.onContext?.(undefined, this.sessionId);
|
|
11780
|
+
}
|
|
11781
|
+
if (event.type === "pi_usage" && this.agentRunning && this.state === "busy" && event.sessionId === this.sessionId && event.generation === this.budgetGeneration && this.verifiedOwner() && this.sessionId) {
|
|
11782
|
+
this.sessionModel = stateModelId(event);
|
|
11783
|
+
this.opts.onContext?.(event.context, this.sessionId);
|
|
11784
|
+
}
|
|
11721
11785
|
if (event.type === "tokens" && this.state === "busy" && typeof event.id === "string" && event.id.length <= 100 && Number.isSafeInteger(event.tokens) && event.tokens >= 0 && !this.usageSeen.has(event.id)) {
|
|
11722
11786
|
this.usageSeen.add(event.id);
|
|
11723
11787
|
if (this.usageSeen.size > 1000)
|
|
@@ -12636,8 +12700,8 @@ var init_shipped_roles = __esm(() => {
|
|
|
12636
12700
|
|
|
12637
12701
|
// src/hub/roles.ts
|
|
12638
12702
|
import { createHash as createHash7 } from "crypto";
|
|
12639
|
-
import { constants as constants7, closeSync as closeSync8, fstatSync as fstatSync7, lstatSync as
|
|
12640
|
-
import { join as
|
|
12703
|
+
import { constants as constants7, closeSync as closeSync8, fstatSync as fstatSync7, lstatSync as lstatSync18, openSync as openSync8, readSync as readSync5, readdirSync as readdirSync3 } from "fs";
|
|
12704
|
+
import { join as join19 } from "path";
|
|
12641
12705
|
function parseRole(text, stem, layer) {
|
|
12642
12706
|
if (Buffer.byteLength(text) > 8192 || text.includes("\r") || !ID.test(stem))
|
|
12643
12707
|
throw new Error("invalid role size, encoding or file id");
|
|
@@ -12716,9 +12780,9 @@ function loadRoleCatalog(cwd) {
|
|
|
12716
12780
|
if (!cwd)
|
|
12717
12781
|
return { roles, errors };
|
|
12718
12782
|
try {
|
|
12719
|
-
const config =
|
|
12783
|
+
const config = join19(cwd, ".agenthub"), dir = join19(config, "roles");
|
|
12720
12784
|
for (const path of [config, dir]) {
|
|
12721
|
-
const stat =
|
|
12785
|
+
const stat = lstatSync18(path);
|
|
12722
12786
|
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
12723
12787
|
throw new Error("unsafe role directory");
|
|
12724
12788
|
}
|
|
@@ -12728,7 +12792,7 @@ function loadRoleCatalog(cwd) {
|
|
|
12728
12792
|
for (const file of files) {
|
|
12729
12793
|
const id = file.slice(0, -3);
|
|
12730
12794
|
try {
|
|
12731
|
-
roles.set(id, parseRole(projectRole(
|
|
12795
|
+
roles.set(id, parseRole(projectRole(join19(dir, file)), id, "project"));
|
|
12732
12796
|
} catch {
|
|
12733
12797
|
errors.push({ id: ID.test(id) ? id : "invalid-file-id", reason: "invalid or unsafe project role" });
|
|
12734
12798
|
}
|
|
@@ -13175,6 +13239,7 @@ function controlWriteSpan(phase, fn) {
|
|
|
13175
13239
|
}
|
|
13176
13240
|
span.async = true;
|
|
13177
13241
|
request.telemetry.recordSyncPrefix(span);
|
|
13242
|
+
request.telemetry.followSpan(span);
|
|
13178
13243
|
return Promise.resolve(result).then((value) => {
|
|
13179
13244
|
request.telemetry.finishSpan(span);
|
|
13180
13245
|
return value;
|
|
@@ -13201,6 +13266,9 @@ class ControlWriteTelemetry {
|
|
|
13201
13266
|
timer;
|
|
13202
13267
|
nextSampleAt;
|
|
13203
13268
|
lastNow = 0;
|
|
13269
|
+
hops = 0;
|
|
13270
|
+
turn = 0;
|
|
13271
|
+
turnPending = false;
|
|
13204
13272
|
stopped = false;
|
|
13205
13273
|
completedRequests = 0;
|
|
13206
13274
|
expiredRequests = 0;
|
|
@@ -13251,6 +13319,7 @@ class ControlWriteTelemetry {
|
|
|
13251
13319
|
phaseOrder: [],
|
|
13252
13320
|
settled: false,
|
|
13253
13321
|
privacySuppressed: false,
|
|
13322
|
+
hopsLeft: MAX_REQUEST_HOPS,
|
|
13254
13323
|
logPrivacy: () => false
|
|
13255
13324
|
};
|
|
13256
13325
|
request.logPrivacy = () => !request.privacySuppressed && this.privateNow(request.privacyCurrent);
|
|
@@ -13368,7 +13437,14 @@ class ControlWriteTelemetry {
|
|
|
13368
13437
|
};
|
|
13369
13438
|
}
|
|
13370
13439
|
beginSpan(request, phase) {
|
|
13371
|
-
|
|
13440
|
+
if (!this.turnPending && !this.stopped) {
|
|
13441
|
+
this.turnPending = true;
|
|
13442
|
+
setImmediate(() => {
|
|
13443
|
+
this.turn++;
|
|
13444
|
+
this.turnPending = false;
|
|
13445
|
+
}).unref?.();
|
|
13446
|
+
}
|
|
13447
|
+
const span = { request, phase, startedAt: this.readNow(), async: false, finished: false, prefixRecorded: false, turn: this.turn };
|
|
13372
13448
|
if (this.spans.size >= this.maxActiveSpans) {
|
|
13373
13449
|
this.droppedSpans++;
|
|
13374
13450
|
return span;
|
|
@@ -13394,6 +13470,8 @@ class ControlWriteTelemetry {
|
|
|
13394
13470
|
request.phases.set(span.phase, prior + durationMs);
|
|
13395
13471
|
if (!span.async && !span.prefixRecorded)
|
|
13396
13472
|
this.rememberSyncInterval(span, endedAt);
|
|
13473
|
+
else if (span.async && span.turn === this.turn && endedAt - span.startedAt >= MIN_SYNC_PREFIX_MS)
|
|
13474
|
+
this.rememberSyncInterval(span, endedAt);
|
|
13397
13475
|
}
|
|
13398
13476
|
recordSyncPrefix(span) {
|
|
13399
13477
|
if (span.finished || span.prefixRecorded || span.request.settled)
|
|
@@ -13404,6 +13482,25 @@ class ControlWriteTelemetry {
|
|
|
13404
13482
|
span.prefixRecorded = true;
|
|
13405
13483
|
this.rememberSyncInterval(span, endedAt);
|
|
13406
13484
|
}
|
|
13485
|
+
followedHops() {
|
|
13486
|
+
return this.hops;
|
|
13487
|
+
}
|
|
13488
|
+
followSpan(span) {
|
|
13489
|
+
let last = this.readNow();
|
|
13490
|
+
const hop = () => {
|
|
13491
|
+
const request = span.request;
|
|
13492
|
+
if (span.finished || request.settled || this.stopped || request.hopsLeft <= 0)
|
|
13493
|
+
return;
|
|
13494
|
+
request.hopsLeft--;
|
|
13495
|
+
this.hops++;
|
|
13496
|
+
const now = this.readNow();
|
|
13497
|
+
if (now - last >= MIN_SYNC_PREFIX_MS)
|
|
13498
|
+
this.rememberSyncInterval({ ...span, startedAt: last }, now);
|
|
13499
|
+
last = now;
|
|
13500
|
+
queueMicrotask(hop);
|
|
13501
|
+
};
|
|
13502
|
+
queueMicrotask(hop);
|
|
13503
|
+
}
|
|
13407
13504
|
rememberSyncInterval(span, endedAt) {
|
|
13408
13505
|
const request = span.request;
|
|
13409
13506
|
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 +13621,7 @@ class ControlWriteTelemetry {
|
|
|
13524
13621
|
return Math.round(bounded * 10) / 10;
|
|
13525
13622
|
}
|
|
13526
13623
|
}
|
|
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;
|
|
13624
|
+
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
13625
|
var init_control_write_trace = __esm(() => {
|
|
13529
13626
|
CONTROL_WRITE_KINDS = [
|
|
13530
13627
|
"hub_task_propose",
|
|
@@ -13573,7 +13670,7 @@ var package_default;
|
|
|
13573
13670
|
var init_package = __esm(() => {
|
|
13574
13671
|
package_default = {
|
|
13575
13672
|
name: "@staix/agent-hub",
|
|
13576
|
-
version: "0.
|
|
13673
|
+
version: "0.45.0",
|
|
13577
13674
|
description: "Native multi-agent hub: Claude Code, Codex, Kimi Code, Pi and local inference as peers in one project",
|
|
13578
13675
|
license: "MIT",
|
|
13579
13676
|
type: "module",
|
|
@@ -13590,7 +13687,7 @@ var init_package = __esm(() => {
|
|
|
13590
13687
|
bun: ">=1.4.4"
|
|
13591
13688
|
},
|
|
13592
13689
|
dependencies: {
|
|
13593
|
-
"@staix/agent-mem": "0.
|
|
13690
|
+
"@staix/agent-mem": ">=0.33.0 <1.0.0"
|
|
13594
13691
|
},
|
|
13595
13692
|
devDependencies: {
|
|
13596
13693
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
@@ -13638,12 +13735,13 @@ var init_db_schema = __esm(() => {
|
|
|
13638
13735
|
});
|
|
13639
13736
|
|
|
13640
13737
|
// src/hub/snapshots.ts
|
|
13641
|
-
var HEAD_LOG_MAX_APPEND_BYTES;
|
|
13738
|
+
var SNAPSHOT_COOLDOWN_MS, HEAD_LOG_MAX_APPEND_BYTES;
|
|
13642
13739
|
var init_snapshots = __esm(() => {
|
|
13643
13740
|
init_db_schema();
|
|
13644
13741
|
init_child_process();
|
|
13645
13742
|
init_git();
|
|
13646
13743
|
init_project();
|
|
13744
|
+
SNAPSHOT_COOLDOWN_MS = 10 * 60000;
|
|
13647
13745
|
HEAD_LOG_MAX_APPEND_BYTES = 128 * 1024;
|
|
13648
13746
|
});
|
|
13649
13747
|
|
|
@@ -13706,6 +13804,12 @@ var init_host_executable = __esm(() => {
|
|
|
13706
13804
|
init_project();
|
|
13707
13805
|
});
|
|
13708
13806
|
|
|
13807
|
+
// src/hub/sdlc-branch-ci.ts
|
|
13808
|
+
var CAP2;
|
|
13809
|
+
var init_sdlc_branch_ci = __esm(() => {
|
|
13810
|
+
CAP2 = 256 * 1024;
|
|
13811
|
+
});
|
|
13812
|
+
|
|
13709
13813
|
// src/hub/sdlc.ts
|
|
13710
13814
|
var SDLC_STAGES, PLAYBOOK_STAGES, BASES2, STAGE_GATES, GATES;
|
|
13711
13815
|
var init_sdlc = __esm(() => {
|
|
@@ -13720,6 +13824,7 @@ var init_sdlc = __esm(() => {
|
|
|
13720
13824
|
init_workflow();
|
|
13721
13825
|
init_child_process();
|
|
13722
13826
|
init_host_executable();
|
|
13827
|
+
init_sdlc_branch_ci();
|
|
13723
13828
|
SDLC_STAGES = ["spec", "plan", "implement", "review", "verify", "merge", "release"];
|
|
13724
13829
|
PLAYBOOK_STAGES = ["intent", "spec", "plan", "build", "test", "review", "merge", "release", "maintain"];
|
|
13725
13830
|
BASES2 = [...new Set([...SDLC_STAGES, ...PLAYBOOK_STAGES])];
|
|
@@ -13771,6 +13876,12 @@ var init_review_comments = __esm(() => {
|
|
|
13771
13876
|
init_review_anchor();
|
|
13772
13877
|
});
|
|
13773
13878
|
|
|
13879
|
+
// node_modules/@staix/agent-mem/src/memory/recap-scratch.ts
|
|
13880
|
+
var RECAP_SCRATCH;
|
|
13881
|
+
var init_recap_scratch = __esm(() => {
|
|
13882
|
+
RECAP_SCRATCH = Symbol("recap scratch without search");
|
|
13883
|
+
});
|
|
13884
|
+
|
|
13774
13885
|
// node_modules/@staix/agent-mem/src/memory/screen.ts
|
|
13775
13886
|
var SECRETS, looksSecret = (text) => SECRETS.some((re) => re.test(text));
|
|
13776
13887
|
var init_screen = __esm(() => {
|
|
@@ -13870,13 +13981,14 @@ var init_sync_placement_plan = __esm(() => {
|
|
|
13870
13981
|
});
|
|
13871
13982
|
|
|
13872
13983
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-journal-format.ts
|
|
13873
|
-
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES;
|
|
13984
|
+
var PLACEMENT_JOURNAL_CHUNK_MAX_BYTES, PLACEMENT_JOURNAL_ROOT_MAX_BYTES, PLACEMENT_CHECKPOINT_COMMAND = "amem migrate --sync-placement --checkpoint", PLACEMENT_CHECKPOINT_PENDING_MESSAGE;
|
|
13874
13985
|
var init_sync_placement_journal_format = __esm(() => {
|
|
13875
13986
|
init_generation();
|
|
13876
13987
|
init_policy();
|
|
13877
13988
|
init_sync_placement_format();
|
|
13878
13989
|
PLACEMENT_JOURNAL_CHUNK_MAX_BYTES = 64 * 1024;
|
|
13879
13990
|
PLACEMENT_JOURNAL_ROOT_MAX_BYTES = 256 * 1024;
|
|
13991
|
+
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
13992
|
});
|
|
13881
13993
|
|
|
13882
13994
|
// node_modules/@staix/agent-mem/src/memory/public-prune-view.ts
|
|
@@ -13912,7 +14024,6 @@ var init_mutation = __esm(() => {
|
|
|
13912
14024
|
init_platform();
|
|
13913
14025
|
mutations = new WeakMap;
|
|
13914
14026
|
});
|
|
13915
|
-
|
|
13916
14027
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-bound.ts
|
|
13917
14028
|
var PLACEMENT_SOURCE_MAX_BYTES;
|
|
13918
14029
|
var init_sync_placement_bound = __esm(() => {
|
|
@@ -13949,16 +14060,45 @@ var init_sync_placement_writer_revision_format = __esm(() => {
|
|
|
13949
14060
|
init_generation();
|
|
13950
14061
|
init_sync_placement_writers();
|
|
13951
14062
|
init_sync_placement_format();
|
|
14063
|
+
init_sync_placement_journal_format();
|
|
13952
14064
|
WRITER_REVISION_MAX_BYTES = 512 * 1024;
|
|
13953
14065
|
WRITER_COMMIT_MAX_BYTES = 64 * 1024;
|
|
13954
14066
|
WRITER_RENEWAL_INTENT_MAX_BYTES = 1024 * 1024;
|
|
13955
14067
|
});
|
|
13956
14068
|
|
|
14069
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-format.ts
|
|
14070
|
+
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;
|
|
14071
|
+
var init_sync_placement_checkpoint_format = __esm(() => {
|
|
14072
|
+
init_generation();
|
|
14073
|
+
init_sync_placement_journal_format();
|
|
14074
|
+
init_sync_placement_writer_revision_format();
|
|
14075
|
+
PLACEMENT_CHECKPOINT_PAGE_MAX_BYTES = 64 * 1024;
|
|
14076
|
+
PLACEMENT_CHECKPOINT_MANIFEST_MAX_BYTES = 256 * 1024;
|
|
14077
|
+
PLACEMENT_CHECKPOINT_COMMITS_MAX_BYTES = PLACEMENT_CHECKPOINT_LIMIT * 1024;
|
|
14078
|
+
PLACEMENT_CHECKPOINT_INTENT_MAX_BYTES = 1024 * 1024;
|
|
14079
|
+
PLACEMENT_CHECKPOINT_ARCHIVE_MAX_BYTES = 8 * 1024 ** 3;
|
|
14080
|
+
});
|
|
14081
|
+
|
|
14082
|
+
// node_modules/@staix/agent-mem/src/memory/sync-placement-checkpoint-storage.ts
|
|
14083
|
+
var MEMBER_MAX_BYTES;
|
|
14084
|
+
var init_sync_placement_checkpoint_storage = __esm(() => {
|
|
14085
|
+
init_generation();
|
|
14086
|
+
init_platform();
|
|
14087
|
+
init_sync_placement_journal_format();
|
|
14088
|
+
init_sync_placement_checkpoint_format();
|
|
14089
|
+
init_sync_placement_writer_revision_format();
|
|
14090
|
+
init_sync_placement_journal_format();
|
|
14091
|
+
MEMBER_MAX_BYTES = 1024 * 1024;
|
|
14092
|
+
});
|
|
14093
|
+
|
|
13957
14094
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-writer-history.ts
|
|
13958
14095
|
var init_sync_placement_writer_history = __esm(() => {
|
|
13959
14096
|
init_generation();
|
|
13960
14097
|
init_home_identity();
|
|
13961
14098
|
init_platform();
|
|
14099
|
+
init_sync_placement_checkpoint_storage();
|
|
14100
|
+
init_sync_placement_checkpoint_format();
|
|
14101
|
+
init_sync_placement_journal_format();
|
|
13962
14102
|
init_mutation();
|
|
13963
14103
|
init_sync_placement_writer_revision_format();
|
|
13964
14104
|
});
|
|
@@ -14002,6 +14142,8 @@ var init_sync_placement_journal_storage = __esm(() => {
|
|
|
14002
14142
|
init_sync_placement_writer_history();
|
|
14003
14143
|
init_sync_placement_batch_intent();
|
|
14004
14144
|
init_formats();
|
|
14145
|
+
init_sync_placement_checkpoint_storage();
|
|
14146
|
+
init_sync_placement_checkpoint_format();
|
|
14005
14147
|
inflight = new WeakSet;
|
|
14006
14148
|
publicationDurability = new WeakMap;
|
|
14007
14149
|
});
|
|
@@ -14432,11 +14574,45 @@ var init_capture = __esm(() => {
|
|
|
14432
14574
|
});
|
|
14433
14575
|
|
|
14434
14576
|
// node_modules/@staix/agent-mem/src/memory/style.ts
|
|
14435
|
-
function
|
|
14436
|
-
return
|
|
14577
|
+
function paint(role, text, color) {
|
|
14578
|
+
return color && ROLE_SGR[role] ? `${ROLE_SGR[role]}${text}${SGR_RESET}` : text;
|
|
14437
14579
|
}
|
|
14438
|
-
|
|
14580
|
+
function style(color, ascii = true) {
|
|
14581
|
+
return {
|
|
14582
|
+
color,
|
|
14583
|
+
ascii,
|
|
14584
|
+
ok: (text) => paint("success", text, color),
|
|
14585
|
+
attention: (text) => paint("warning", text, color),
|
|
14586
|
+
error: (text) => paint("error", text, color),
|
|
14587
|
+
dim: (text) => paint("hint", text, color),
|
|
14588
|
+
bold: (text) => paint("value", text, color)
|
|
14589
|
+
};
|
|
14590
|
+
}
|
|
14591
|
+
var ESC, SGR_RESET, ROLE_SGR, MARKERS, PLAIN;
|
|
14439
14592
|
var init_style = __esm(() => {
|
|
14593
|
+
ESC = String.fromCharCode(27);
|
|
14594
|
+
SGR_RESET = `${ESC}[0m`;
|
|
14595
|
+
ROLE_SGR = Object.freeze({
|
|
14596
|
+
header: `${ESC}[1;34m`,
|
|
14597
|
+
section: `${ESC}[1;35m`,
|
|
14598
|
+
key: `${ESC}[34m`,
|
|
14599
|
+
value: "",
|
|
14600
|
+
success: `${ESC}[1;32m`,
|
|
14601
|
+
warning: `${ESC}[1;33m`,
|
|
14602
|
+
error: `${ESC}[1;31m`,
|
|
14603
|
+
hint: `${ESC}[90m`,
|
|
14604
|
+
accent: `${ESC}[36m`
|
|
14605
|
+
});
|
|
14606
|
+
MARKERS = Object.freeze({
|
|
14607
|
+
ok: { glyph: "\u2713", ascii: "ok", role: "success" },
|
|
14608
|
+
fail: { glyph: "\u2717", ascii: "x", role: "error" },
|
|
14609
|
+
warn: { glyph: "\u26A0", ascii: "!", role: "warning" },
|
|
14610
|
+
absent: { glyph: "-", ascii: "-", role: "hint" },
|
|
14611
|
+
unknown: { glyph: "?", ascii: "?", role: "hint" },
|
|
14612
|
+
pending: { glyph: "~", ascii: "~", role: "hint" },
|
|
14613
|
+
active: { glyph: "*", ascii: "*", role: "success" },
|
|
14614
|
+
next: { glyph: "\u2192", ascii: "->", role: "accent" }
|
|
14615
|
+
});
|
|
14440
14616
|
PLAIN = style(false);
|
|
14441
14617
|
});
|
|
14442
14618
|
|
|
@@ -14536,6 +14712,7 @@ var init_reader_lease = __esm(() => {
|
|
|
14536
14712
|
// node_modules/@staix/agent-mem/src/memory/store.ts
|
|
14537
14713
|
var DEFAULT_TTL_MS, UNSETTLED_MS, DEFAULT_LEASE_MS, MIGRATION_BOOTSTRAP, curatedDepth, curatedPending;
|
|
14538
14714
|
var init_store = __esm(() => {
|
|
14715
|
+
init_recap_scratch();
|
|
14539
14716
|
init_brief_curated();
|
|
14540
14717
|
init_curated_cache_state();
|
|
14541
14718
|
init_sync_placement_guard();
|
|
@@ -14577,11 +14754,16 @@ var init_catalog = __esm(() => {
|
|
|
14577
14754
|
init_capture();
|
|
14578
14755
|
init_store();
|
|
14579
14756
|
init_lifecycle();
|
|
14757
|
+
init_sync_placement_guard();
|
|
14580
14758
|
});
|
|
14581
14759
|
|
|
14760
|
+
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14761
|
+
var init_hook_resources = () => {};
|
|
14762
|
+
|
|
14582
14763
|
// node_modules/@staix/agent-mem/src/memory/metrics.ts
|
|
14583
14764
|
var METRICS_MAX_BYTES;
|
|
14584
14765
|
var init_metrics = __esm(() => {
|
|
14766
|
+
init_hook_resources();
|
|
14585
14767
|
METRICS_MAX_BYTES = 64 * 1024;
|
|
14586
14768
|
});
|
|
14587
14769
|
|
|
@@ -14610,6 +14792,7 @@ var init_gc = __esm(() => {
|
|
|
14610
14792
|
|
|
14611
14793
|
// node_modules/@staix/agent-mem/src/memory/curated-read.ts
|
|
14612
14794
|
var init_curated_read = __esm(() => {
|
|
14795
|
+
init_recap_scratch();
|
|
14613
14796
|
init_store();
|
|
14614
14797
|
init_shard();
|
|
14615
14798
|
});
|
|
@@ -14819,6 +15002,9 @@ var init_commands = __esm(() => {
|
|
|
14819
15002
|
// node_modules/@staix/agent-mem/src/memory/shard-migration.ts
|
|
14820
15003
|
var USER2;
|
|
14821
15004
|
var init_shard_migration = __esm(() => {
|
|
15005
|
+
init_sync_placement_active();
|
|
15006
|
+
init_sync_placement_guard();
|
|
15007
|
+
init_sync_placement_format();
|
|
14822
15008
|
init_bridge();
|
|
14823
15009
|
init_generation();
|
|
14824
15010
|
init_generation_index();
|
|
@@ -14934,6 +15120,7 @@ var init_mcp_memory = __esm(() => {
|
|
|
14934
15120
|
init_capture();
|
|
14935
15121
|
init_generation();
|
|
14936
15122
|
init_home();
|
|
15123
|
+
init_metrics();
|
|
14937
15124
|
init_platform();
|
|
14938
15125
|
init_policy();
|
|
14939
15126
|
init_config();
|
|
@@ -14962,9 +15149,6 @@ var init_record_instruction = __esm(() => {
|
|
|
14962
15149
|
MAX_BYTES6 = 64 * 1024;
|
|
14963
15150
|
});
|
|
14964
15151
|
|
|
14965
|
-
// node_modules/@staix/agent-mem/src/hook-resources.ts
|
|
14966
|
-
var init_hook_resources = () => {};
|
|
14967
|
-
|
|
14968
15152
|
// node_modules/@staix/agent-mem/src/hook-git.ts
|
|
14969
15153
|
var init_hook_git = __esm(() => {
|
|
14970
15154
|
init_platform();
|
|
@@ -15064,6 +15248,11 @@ var init_hooks = __esm(() => {
|
|
|
15064
15248
|
hookStartedAt = performance.now();
|
|
15065
15249
|
});
|
|
15066
15250
|
|
|
15251
|
+
// node_modules/@staix/agent-mem/src/memory/native-roots.ts
|
|
15252
|
+
var init_native_roots = __esm(() => {
|
|
15253
|
+
init_platform();
|
|
15254
|
+
});
|
|
15255
|
+
|
|
15067
15256
|
// node_modules/@staix/agent-mem/src/ingest-records.ts
|
|
15068
15257
|
var init_ingest_records = __esm(() => {
|
|
15069
15258
|
init_hook_record();
|
|
@@ -15074,6 +15263,7 @@ var MAX_BYTES8, DEFAULT_BYTES, MAX_CURSOR_BYTES, utf8, MAX_RECORD;
|
|
|
15074
15263
|
var init_ingest = __esm(() => {
|
|
15075
15264
|
init_capture();
|
|
15076
15265
|
init_home();
|
|
15266
|
+
init_native_roots();
|
|
15077
15267
|
init_platform();
|
|
15078
15268
|
init_policy();
|
|
15079
15269
|
init_config();
|
|
@@ -15132,10 +15322,15 @@ var init_curated_brief_cache = __esm(() => {
|
|
|
15132
15322
|
init_store();
|
|
15133
15323
|
});
|
|
15134
15324
|
|
|
15325
|
+
// node_modules/@staix/agent-mem/src/memory/review-targets.ts
|
|
15326
|
+
var init_review_targets = () => {};
|
|
15327
|
+
|
|
15135
15328
|
// node_modules/@staix/agent-mem/src/memory/decay-review.ts
|
|
15136
15329
|
var init_decay_review = __esm(() => {
|
|
15137
15330
|
init_generation();
|
|
15138
15331
|
init_candidates();
|
|
15332
|
+
init_candidates();
|
|
15333
|
+
init_review_targets();
|
|
15139
15334
|
});
|
|
15140
15335
|
|
|
15141
15336
|
// node_modules/@staix/agent-mem/src/memory/goal-promotion.ts
|
|
@@ -15264,7 +15459,9 @@ var init_sync_placement_effective_writers = __esm(() => {
|
|
|
15264
15459
|
init_sync_placement_writer_revision_format();
|
|
15265
15460
|
init_sync_placement_writer_roots();
|
|
15266
15461
|
init_sync_placement_prerequisites();
|
|
15462
|
+
init_sync_placement_checkpoint_storage();
|
|
15267
15463
|
});
|
|
15464
|
+
|
|
15268
15465
|
// node_modules/@staix/agent-mem/src/memory/sync-placement-capture.ts
|
|
15269
15466
|
var init_sync_placement_capture = __esm(() => {
|
|
15270
15467
|
init_sync_placement_journal_format();
|
|
@@ -15715,6 +15912,7 @@ var init_sync_placement_writer_context = __esm(() => {
|
|
|
15715
15912
|
|
|
15716
15913
|
// node_modules/@staix/agent-mem/src/index.ts
|
|
15717
15914
|
var init_src = __esm(() => {
|
|
15915
|
+
init_platform();
|
|
15718
15916
|
init_cli_attribution();
|
|
15719
15917
|
init_search_fts();
|
|
15720
15918
|
init_platform();
|
|
@@ -15765,6 +15963,7 @@ var init_src = __esm(() => {
|
|
|
15765
15963
|
init_recall_staleness();
|
|
15766
15964
|
init_intent_brief();
|
|
15767
15965
|
init_plan_guard();
|
|
15966
|
+
init_review_targets();
|
|
15768
15967
|
init_consolidate();
|
|
15769
15968
|
init_record_candidates();
|
|
15770
15969
|
init_consolidation_clusters();
|
|
@@ -15779,6 +15978,145 @@ var init_src = __esm(() => {
|
|
|
15779
15978
|
init_sync_placement_journal();
|
|
15780
15979
|
});
|
|
15781
15980
|
|
|
15981
|
+
// src/hub/log-rotation.ts
|
|
15982
|
+
import { appendFileSync, closeSync as closeSync10, copyFileSync, existsSync as existsSync9, fstatSync as fstatSync9, openSync as openSync10, readdirSync as readdirSync4, readSync as readSync7, renameSync as renameSync5, rmSync as rmSync7, statSync as statSync5, truncateSync } from "fs";
|
|
15983
|
+
import { basename as basename5, dirname as dirname13, join as join20 } from "path";
|
|
15984
|
+
function segmentsOf(file) {
|
|
15985
|
+
const dir = dirname13(file), prefix = `${basename5(file)}.`;
|
|
15986
|
+
let names;
|
|
15987
|
+
try {
|
|
15988
|
+
names = readdirSync4(dir);
|
|
15989
|
+
} catch {
|
|
15990
|
+
names = [];
|
|
15991
|
+
}
|
|
15992
|
+
const rotated = [];
|
|
15993
|
+
for (const name of names) {
|
|
15994
|
+
if (!name.startsWith(prefix))
|
|
15995
|
+
continue;
|
|
15996
|
+
const digits = /^(0|[1-9][0-9]{0,15})$/.exec(name.slice(prefix.length));
|
|
15997
|
+
if (!digits)
|
|
15998
|
+
continue;
|
|
15999
|
+
const path = join20(dir, name);
|
|
16000
|
+
try {
|
|
16001
|
+
const stat = statSync5(path);
|
|
16002
|
+
if (stat.isFile())
|
|
16003
|
+
rotated.push({ path, start: Number(digits[1]), size: stat.size, live: false });
|
|
16004
|
+
} catch {}
|
|
16005
|
+
}
|
|
16006
|
+
rotated.sort((a, b) => a.start - b.start);
|
|
16007
|
+
const last = rotated[rotated.length - 1];
|
|
16008
|
+
const start = last ? last.start + last.size : 0;
|
|
16009
|
+
try {
|
|
16010
|
+
const stat = statSync5(file);
|
|
16011
|
+
if (stat.isFile())
|
|
16012
|
+
rotated.push({ path: file, start, size: stat.size, live: true });
|
|
16013
|
+
} catch {}
|
|
16014
|
+
return rotated;
|
|
16015
|
+
}
|
|
16016
|
+
var EVENTS_SEGMENT_BYTES, HUB_LOG_SEGMENT_BYTES;
|
|
16017
|
+
var init_log_rotation = __esm(() => {
|
|
16018
|
+
EVENTS_SEGMENT_BYTES = 64 * 1024 * 1024;
|
|
16019
|
+
HUB_LOG_SEGMENT_BYTES = 16 * 1024 * 1024;
|
|
16020
|
+
});
|
|
16021
|
+
|
|
16022
|
+
// src/hub/events.ts
|
|
16023
|
+
import { appendFileSync as appendFileSync2, closeSync as closeSync11, existsSync as existsSync10, fstatSync as fstatSync10, openSync as openSync11, readFileSync as readFileSync9, readSync as readSync8 } from "fs";
|
|
16024
|
+
function readEvents(file, since = 0) {
|
|
16025
|
+
for (let attempt = 0;; attempt++) {
|
|
16026
|
+
const segments = segmentsOf(file), out = [];
|
|
16027
|
+
for (const segment of segments) {
|
|
16028
|
+
let text;
|
|
16029
|
+
try {
|
|
16030
|
+
text = readFileSync9(segment.path, "utf8");
|
|
16031
|
+
} catch {
|
|
16032
|
+
continue;
|
|
16033
|
+
}
|
|
16034
|
+
for (const line of text.split(`
|
|
16035
|
+
`)) {
|
|
16036
|
+
const event = parseEventLine(line, since);
|
|
16037
|
+
if (event !== undefined)
|
|
16038
|
+
out.push(event);
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
16041
|
+
const again = segmentsOf(file);
|
|
16042
|
+
if (attempt >= 3 || again.length === segments.length && again.every((segment, i) => segment.path === segments[i].path && segment.start === segments[i].start))
|
|
16043
|
+
return out;
|
|
16044
|
+
}
|
|
16045
|
+
}
|
|
16046
|
+
function parseEventLine(line, since = 0) {
|
|
16047
|
+
if (!line.trim())
|
|
16048
|
+
return;
|
|
16049
|
+
try {
|
|
16050
|
+
const e = JSON.parse(line);
|
|
16051
|
+
const measuredAt = e.type === "usage" && typeof e.measuredAt === "string" ? e.measuredAt : e.at;
|
|
16052
|
+
return Date.parse(measuredAt) >= since ? e : undefined;
|
|
16053
|
+
} catch {
|
|
16054
|
+
return;
|
|
16055
|
+
}
|
|
16056
|
+
}
|
|
16057
|
+
var init_events = __esm(() => {
|
|
16058
|
+
init_log_rotation();
|
|
16059
|
+
});
|
|
16060
|
+
|
|
16061
|
+
// src/hub/tooling.ts
|
|
16062
|
+
var identities;
|
|
16063
|
+
var init_tooling = __esm(() => {
|
|
16064
|
+
init_registry();
|
|
16065
|
+
init_project();
|
|
16066
|
+
identities = new Map;
|
|
16067
|
+
});
|
|
16068
|
+
|
|
16069
|
+
// src/hub/bench.ts
|
|
16070
|
+
var TASK_FIELDS, CLASSES3, HEAD;
|
|
16071
|
+
var init_bench = __esm(() => {
|
|
16072
|
+
init_project();
|
|
16073
|
+
init_process_signature();
|
|
16074
|
+
TASK_FIELDS = new Set(["id", "title", "detail", "class", "owner", "ref", "setup", "verify", "timeout_s"]);
|
|
16075
|
+
CLASSES3 = new Set(["plan", "implement", "bulk_edit", "test", "review", "summarize", "triage"]);
|
|
16076
|
+
HEAD = `${"".padEnd(28)} ${"attempts".padStart(8)} ${"pass".padStart(5)} ${"p/f/t/e".padStart(11)} ${"first pass".padStart(10)} ${"rework".padStart(6)} ${"tokens p50".padStart(10)} ${"wall p50".padStart(8)}`;
|
|
16077
|
+
});
|
|
16078
|
+
|
|
16079
|
+
// src/hub/research-memory.ts
|
|
16080
|
+
var UNKNOWN_MEMORY_FIGURES;
|
|
16081
|
+
var init_research_memory = __esm(() => {
|
|
16082
|
+
UNKNOWN_MEMORY_FIGURES = Object.freeze({ rendered: null, delivered: null, cited: null, failsExposed: null, failsCited: null, failRetrySignal: null });
|
|
16083
|
+
});
|
|
16084
|
+
|
|
16085
|
+
// src/hub/person-figures.ts
|
|
16086
|
+
var UNKNOWN_PERSON_FIGURES, ALLOW, DENY;
|
|
16087
|
+
var init_person_figures = __esm(() => {
|
|
16088
|
+
UNKNOWN_PERSON_FIGURES = Object.freeze({ permissions: null, questions: null, completions: null, cliRefusals: null, consoleConfirmations: null, latencyMs: null });
|
|
16089
|
+
ALLOW = new Set(["allow_once", "allow_always"]);
|
|
16090
|
+
DENY = new Set(["reject_once", "reject_always"]);
|
|
16091
|
+
});
|
|
16092
|
+
|
|
16093
|
+
// src/hub/cost-governance.ts
|
|
16094
|
+
var init_cost_governance = () => {};
|
|
16095
|
+
|
|
16096
|
+
// src/hub/research-record.ts
|
|
16097
|
+
var NO_EVIDENCE;
|
|
16098
|
+
var init_research_record = __esm(() => {
|
|
16099
|
+
init_cost_governance();
|
|
16100
|
+
init_db_schema();
|
|
16101
|
+
init_sdlc_metrics();
|
|
16102
|
+
NO_EVIDENCE = { tasks: new Map, board: false };
|
|
16103
|
+
});
|
|
16104
|
+
|
|
16105
|
+
// src/hub/research.ts
|
|
16106
|
+
var FAILED, TRACKED2;
|
|
16107
|
+
var init_research2 = __esm(() => {
|
|
16108
|
+
init_log_rotation();
|
|
16109
|
+
init_events();
|
|
16110
|
+
init_project();
|
|
16111
|
+
init_tooling();
|
|
16112
|
+
init_bench();
|
|
16113
|
+
init_research_memory();
|
|
16114
|
+
init_person_figures();
|
|
16115
|
+
init_research_record();
|
|
16116
|
+
FAILED = new Set(["regressed", "reverted", "incomplete", "wrong", "abandoned"]);
|
|
16117
|
+
TRACKED2 = new Set(["hub_start", "state", "tooling", "memory_brief", "task", "usage"]);
|
|
16118
|
+
});
|
|
16119
|
+
|
|
15782
16120
|
// src/hub/deliverables.ts
|
|
15783
16121
|
var DELIVERABLE_LIMITS;
|
|
15784
16122
|
var init_deliverables = __esm(() => {
|
|
@@ -15797,6 +16135,8 @@ var BODY2;
|
|
|
15797
16135
|
var init_research_experiments = __esm(() => {
|
|
15798
16136
|
init_src();
|
|
15799
16137
|
init_packs();
|
|
16138
|
+
init_research2();
|
|
16139
|
+
init_events();
|
|
15800
16140
|
init_research_runner();
|
|
15801
16141
|
init_deliverables();
|
|
15802
16142
|
BODY2 = 64 * 1024;
|
|
@@ -15814,12 +16154,13 @@ var init_planning = __esm(() => {
|
|
|
15814
16154
|
});
|
|
15815
16155
|
|
|
15816
16156
|
// src/hub/roadmap.ts
|
|
15817
|
-
var MILESTONE_STATES, MILESTONE_HORIZONS, MILESTONE_LINK_KINDS, MILESTONE_LIMITS;
|
|
16157
|
+
var MILESTONE_STATES, MILESTONE_HORIZONS, MILESTONE_LINK_KINDS, MILESTONE_LIMITS, DECOMPOSE_LIMITS;
|
|
15818
16158
|
var init_roadmap = __esm(() => {
|
|
15819
16159
|
MILESTONE_STATES = ["proposed", "planned", "active", "done", "dropped"];
|
|
15820
16160
|
MILESTONE_HORIZONS = ["now", "next", "later"];
|
|
15821
16161
|
MILESTONE_LINK_KINDS = ["spec", "issue", "task", "release"];
|
|
15822
16162
|
MILESTONE_LIMITS = Object.freeze({ title: 300, outcome: 4000, spec: 160, issue: 300, actor: 64 });
|
|
16163
|
+
DECOMPOSE_LIMITS = Object.freeze({ parts: 8, title: 300, detail: 1200, cites: 16 });
|
|
15823
16164
|
});
|
|
15824
16165
|
|
|
15825
16166
|
// src/hub/research-campaign.ts
|
|
@@ -15844,7 +16185,7 @@ var init_considered_findings = __esm(() => {
|
|
|
15844
16185
|
});
|
|
15845
16186
|
|
|
15846
16187
|
// src/hub/board.ts
|
|
15847
|
-
var SURVEY_STORE_BYTES, GUIDANCE_VARIANT_SELECT, HOST_MERGE_ADOPTION, HOST_SPEC_ACCEPTANCE_CARRY, EXECUTION_REFERENCE_SELECT, CLASSES2, SPEC_ACCEPTANCE_FIELD_BYTES, SPEC_ACCEPTANCE_TOTAL_BYTES, PLAN_KEYS, ALL_PLAN_KEYS, OUTCOMES_KEPT_MS;
|
|
16188
|
+
var SURVEY_STORE_BYTES, GUIDANCE_VARIANT_SELECT, HOST_MERGE_ADOPTION, HOST_SPEC_ACCEPTANCE_CARRY, HOST_ROADMAP_DRAFT, EXECUTION_REFERENCE_SELECT, CLASSES2, SPEC_ACCEPTANCE_FIELD_BYTES, SPEC_ACCEPTANCE_TOTAL_BYTES, PLAN_KEYS, ALL_PLAN_KEYS, OUTCOMES_KEPT_MS;
|
|
15848
16189
|
var init_board = __esm(() => {
|
|
15849
16190
|
init_tool_refusal();
|
|
15850
16191
|
init_guidance_variants();
|
|
@@ -15877,6 +16218,7 @@ var init_board = __esm(() => {
|
|
|
15877
16218
|
CASE WHEN withdrawn_by IS NULL OR typeof(withdrawn_by)='text' AND length(CAST(withdrawn_by AS BLOB))<=${EXECUTION_REFERENCE_LIMITS.id} THEN 1 ELSE 0 END AS valid_withdrawn_by`;
|
|
15878
16219
|
HOST_MERGE_ADOPTION = Symbol("host merge adoption");
|
|
15879
16220
|
HOST_SPEC_ACCEPTANCE_CARRY = Symbol("host spec acceptance carry");
|
|
16221
|
+
HOST_ROADMAP_DRAFT = Symbol("host roadmap acceptance draft");
|
|
15880
16222
|
EXECUTION_REFERENCE_SELECT = `SELECT
|
|
15881
16223
|
CASE WHEN length(CAST(id AS BLOB))=64 THEN id END AS id,
|
|
15882
16224
|
CASE WHEN length(CAST(project_id AS BLOB)) BETWEEN 1 AND 256 THEN project_id END AS project_id,
|
|
@@ -16214,7 +16556,7 @@ var init_config2 = __esm(() => {
|
|
|
16214
16556
|
});
|
|
16215
16557
|
|
|
16216
16558
|
// src/hub/routing.ts
|
|
16217
|
-
import { join as
|
|
16559
|
+
import { join as join21, resolve as resolve13 } from "path";
|
|
16218
16560
|
function effectiveLocalRoute(defaultRoute, classRoute, classFixedModel) {
|
|
16219
16561
|
return classRoute ?? (classFixedModel === undefined ? defaultRoute : undefined);
|
|
16220
16562
|
}
|
|
@@ -16228,7 +16570,7 @@ var init_routing = __esm(() => {
|
|
|
16228
16570
|
init_spec_read();
|
|
16229
16571
|
init_config2();
|
|
16230
16572
|
init_stage_fallback();
|
|
16231
|
-
TEMPLATE =
|
|
16573
|
+
TEMPLATE = join21(import.meta.dir, "..", "..", "templates", "routing.toml");
|
|
16232
16574
|
cache = new Map;
|
|
16233
16575
|
});
|
|
16234
16576
|
|
|
@@ -18761,8 +19103,10 @@ var init_hub_tools = __esm(() => {
|
|
|
18761
19103
|
TASK_TOOLS = [
|
|
18762
19104
|
tool2("hub_roadmap_list", "Read public milestones with computed task/issue/spec/train progress. Private work is a count only; unknown evidence stays unknown. Read only, with no GitHub or model call.", {}),
|
|
18763
19105
|
tool2("hub_roadmap_show", "Read a milestone's public links, inherited membership and computed progress. Inspect this before editing and copy its current revision. Private tasks are counts only.", { id: { type: "integer", minimum: 1 } }, ["id"]),
|
|
19106
|
+
tool2("hub_roadmap_check", "Read roadmap drift findings and unknown evidence. Private tasks stay withheld; no writes are made.", {}),
|
|
18764
19107
|
tool2("hub_roadmap_unplaced", "Read the open GitHub issues, open board tasks and active/draft specs that no live milestone places, each with why. Private tasks are a count only. partial: true means the GitHub read stopped early or a list was cut, so the lists are a lower bound; unavailable names evidence that could not be read. Read only: no write, no model call. Optional repo is owner/name.", { repo: { type: "string", maxLength: MILESTONE_LIMITS.issue } }),
|
|
18765
19108
|
tool2("hub_roadmap_triage", "Ask the hub's model to suggest a milestone (or a new one) for unplaced work. Each suggestion cites the milestone and item words it matched and is saved as a pending model answer; nothing is linked until hub_roadmap_edit accept. Configured planner or unique conductor only. list: true reads the pending public suggestions without a model call and is open to any agent.", { repo: { type: "string", maxLength: MILESTONE_LIMITS.issue }, list: { type: "boolean" } }),
|
|
19109
|
+
tool2("hub_roadmap_decompose", "Ask the hub's model to decompose one milestone into parts, from its outcome, the specs it links and the issues it links. Each part cites linked ids and says whether it needs a spec issue or goes straight to a task; the answer is saved as a pending model answer and nothing is linked, intaken or published. Pass accept with one part's number to hold that part as an intake draft instead: it is linked to the milestone, carries the part's spec-issue or task kind, and is offered to nobody until the person releases it with ahub intake approve. Configured planner or unique conductor only. On refusal inspect hub_roadmap_show and correct the named input.", { id: { type: "integer", minimum: 1 }, accept: { type: "integer", minimum: 1 } }, ["id"]),
|
|
18766
19110
|
tool2("hub_roadmap_edit", "Create or change a milestone. Configured planner or unique conductor only; done/dropped are person-only. new/edit take fields; edit also needs the current revision. Link kinds are spec/issue/task/release; issue refs are owner/repo#N. accept applies exactly one pending triage suggestion through link (creating its proposed milestone first); reject drops it. No GitHub write, task assignment or model call. On refusal inspect hub_roadmap_show and correct the named input.", {
|
|
18767
19111
|
op: { type: "string", enum: ["new", "edit", "link", "unlink", "order", "state", "accept", "reject"] },
|
|
18768
19112
|
id: { type: "integer", minimum: 1 },
|
|
@@ -18796,7 +19140,7 @@ var init_hub_tools = __esm(() => {
|
|
|
18796
19140
|
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
19141
|
tool2("hub_backlog_list", "Read public backlog cards with planning revisions. Configured planners only; PII remains a stub.", {}),
|
|
18798
19142
|
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"]),
|
|
19143
|
+
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
19144
|
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
19145
|
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
19146
|
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"]),
|
|
@@ -19406,7 +19750,7 @@ var init_local_worker = __esm(() => {
|
|
|
19406
19750
|
}
|
|
19407
19751
|
const taskToolName = name.replace(/^mcp__[^ ]+__/, "");
|
|
19408
19752
|
const reviewNoteWrite = taskToolName === "hub_remember" || taskToolName === "hub_task_propose";
|
|
19409
|
-
const toolRun = () => this.probeConfinement && !["read", "write", "edit"].includes(name) ? Promise.resolve(formatProbeToolRefusal(new ProbeToolRefusal("tool_unavailable"))) : reviewScope.excluded && reviewNoteWrite ? Promise.resolve("error: anchored review in this batch; save notes in a later turn") : (TASK_TOOL_NAMES.has(name) || CONDUCTOR_TOOL_NAMES.has(name)) && this.opts.taskTool ? this.opts.taskTool(name, safeParse(call.function.arguments), { pii: !!policy?.pii, signal: turnSignal }).catch((e) => `error: ${e.message}`) : runTool(name, call.function.arguments, ctx);
|
|
19753
|
+
const toolRun = () => this.probeConfinement && !["read", "write", "edit"].includes(name) ? Promise.resolve(formatProbeToolRefusal(new ProbeToolRefusal("tool_unavailable"))) : reviewScope.excluded && reviewNoteWrite ? Promise.resolve("error: anchored review in this batch; save notes in a later turn") : (TASK_TOOL_NAMES.has(name) || CONDUCTOR_TOOL_NAMES.has(name)) && this.opts.taskTool ? this.opts.taskTool(name, safeParse(call.function.arguments), { pii: !!policy?.pii, signal: turnSignal }).catch((e) => `error: ${e.message}`) : runTool(name, call.function.arguments, this.probeConfinement ? ctx : this.toolContext(envs, turnSignal, !!policy?.pii, reply, policy?.task));
|
|
19410
19754
|
const probe = this.probeSession;
|
|
19411
19755
|
const running = probe ? (async () => {
|
|
19412
19756
|
try {
|
|
@@ -19470,6 +19814,7 @@ var init_local_worker = __esm(() => {
|
|
|
19470
19814
|
...this.opts.tools.docRead ? { docRead: { ...this.opts.tools.docRead, pii } } : {},
|
|
19471
19815
|
...this.opts.tools.webFetch ? { webFetch: { ...this.opts.tools.webFetch, pii } } : {},
|
|
19472
19816
|
cwd: this.opts.cwd,
|
|
19817
|
+
...this.opts.tools.editGuard && !probe ? { editGuard: this.opts.tools.editGuard(task, () => !turnSignal.aborted && executionGeneration === this.turn) } : {},
|
|
19473
19818
|
deny: this.opts.tools.deny,
|
|
19474
19819
|
readOnly: this.opts.tools.readOnly,
|
|
19475
19820
|
...probe ? { probe: {
|
|
@@ -19842,12 +20187,12 @@ var init_launch2 = __esm(() => {
|
|
|
19842
20187
|
|
|
19843
20188
|
// src/adapters/claude-task-sessions.ts
|
|
19844
20189
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
19845
|
-
import { mkdirSync as mkdirSync11, readFileSync as
|
|
19846
|
-
import { dirname as
|
|
20190
|
+
import { mkdirSync as mkdirSync11, readFileSync as readFileSync10 } from "fs";
|
|
20191
|
+
import { dirname as dirname14 } from "path";
|
|
19847
20192
|
function readState(file) {
|
|
19848
20193
|
let text;
|
|
19849
20194
|
try {
|
|
19850
|
-
text =
|
|
20195
|
+
text = readFileSync10(file, "utf8");
|
|
19851
20196
|
} catch (error) {
|
|
19852
20197
|
if (error.code === "ENOENT")
|
|
19853
20198
|
return { version: 1, sessions: {} };
|
|
@@ -19880,7 +20225,7 @@ class ClaudeTaskSessions {
|
|
|
19880
20225
|
}
|
|
19881
20226
|
write(sessions) {
|
|
19882
20227
|
const next = { version: 1, sessions };
|
|
19883
|
-
mkdirSync11(
|
|
20228
|
+
mkdirSync11(dirname14(this.file), { recursive: true, mode: 448 });
|
|
19884
20229
|
atomicPrivateJSON(this.file, next);
|
|
19885
20230
|
this.state = next;
|
|
19886
20231
|
}
|
|
@@ -19974,9 +20319,9 @@ __export(exports_claude_implementer, {
|
|
|
19974
20319
|
ClaudeImplementerPeer: () => ClaudeImplementerPeer
|
|
19975
20320
|
});
|
|
19976
20321
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
19977
|
-
import { lstatSync as
|
|
20322
|
+
import { lstatSync as lstatSync19, mkdtempSync as mkdtempSync6, rmSync as rmSync8, writeFileSync as writeFileSync9 } from "fs";
|
|
19978
20323
|
import { tmpdir as tmpdir5 } from "os";
|
|
19979
|
-
import { join as
|
|
20324
|
+
import { join as join22 } from "path";
|
|
19980
20325
|
function provenVersion(binding) {
|
|
19981
20326
|
return provenVersions.get(binding);
|
|
19982
20327
|
}
|
|
@@ -20032,10 +20377,10 @@ function claudeImplementerArgs(turn, mcp, settings, prompt, model) {
|
|
|
20032
20377
|
async function proveClaudeImplementer(peer, command) {
|
|
20033
20378
|
const binary = Bun.which(command[0], { PATH: process.env.PATH }) ?? command[0];
|
|
20034
20379
|
const fingerprint = () => {
|
|
20035
|
-
const file = realPath(binary), stat =
|
|
20380
|
+
const file = realPath(binary), stat = lstatSync19(file);
|
|
20036
20381
|
return [file, stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
|
|
20037
20382
|
};
|
|
20038
|
-
const binding = fingerprint(), home = mkdtempSync6(
|
|
20383
|
+
const binding = fingerprint(), home = mkdtempSync6(join22(tmpdir5(), "ahub-claude-proof-"));
|
|
20039
20384
|
let version = "", timedOut = false;
|
|
20040
20385
|
const child = new OwnedPrintChild({
|
|
20041
20386
|
peer,
|
|
@@ -20044,7 +20389,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20044
20389
|
cwd: home,
|
|
20045
20390
|
input: "",
|
|
20046
20391
|
envMode: "replace",
|
|
20047
|
-
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR:
|
|
20392
|
+
env: { PATH: process.env.PATH, HOME: home, CLAUDE_CONFIG_DIR: join22(home, ".claude") },
|
|
20048
20393
|
maxFrameBytes: 4096,
|
|
20049
20394
|
maxOutputBytes: 4096,
|
|
20050
20395
|
onLine: (line) => {
|
|
@@ -20080,7 +20425,7 @@ async function proveClaudeImplementer(peer, command) {
|
|
|
20080
20425
|
} finally {
|
|
20081
20426
|
clearTimeout(timer);
|
|
20082
20427
|
await child.stop();
|
|
20083
|
-
|
|
20428
|
+
rmSync8(home, { recursive: true, force: true });
|
|
20084
20429
|
}
|
|
20085
20430
|
}
|
|
20086
20431
|
var provenVersions, ClaudeImplementerPeer;
|
|
@@ -20131,7 +20476,7 @@ var init_claude_implementer = __esm(() => {
|
|
|
20131
20476
|
if (options.mode !== undefined && options.mode !== "ask" && options.mode !== "ask-when-needed")
|
|
20132
20477
|
throw new Error("Claude implementer refuses unsupported permission mode");
|
|
20133
20478
|
this.mode = options.mode ?? "ask";
|
|
20134
|
-
this.sessions = new ClaudeTaskSessions(
|
|
20479
|
+
this.sessions = new ClaudeTaskSessions(join22(options.stateDir, claudeStateFile("claude-task-sessions", id)));
|
|
20135
20480
|
}
|
|
20136
20481
|
get permissionModeState() {
|
|
20137
20482
|
return this.mode;
|
|
@@ -20300,9 +20645,9 @@ var init_claude_implementer = __esm(() => {
|
|
|
20300
20645
|
this.observerSessionIdValue = turn.sessionId;
|
|
20301
20646
|
this.currentInputContext = inputContext;
|
|
20302
20647
|
this.options.beforeInput?.(inputContext, group.envs);
|
|
20303
|
-
const launchId = randomUUID9(), directory = mkdtempSync6(
|
|
20648
|
+
const launchId = randomUUID9(), directory = mkdtempSync6(join22(this.options.stateDir, "claude-child-")), settings = join22(directory, "settings.json");
|
|
20304
20649
|
let launchFailureTrace;
|
|
20305
|
-
this.cleanup = () =>
|
|
20650
|
+
this.cleanup = () => rmSync8(directory, { recursive: true, force: true });
|
|
20306
20651
|
writeFileSync9(settings, sessionSettings(undefined, { script: this.options.factsHook, stateDir: this.options.stateDir, purpose: "permission" }), { mode: 384, flag: "wx" });
|
|
20307
20652
|
const env = {
|
|
20308
20653
|
AGENTHUB_MODE: "tools",
|
|
@@ -20645,9 +20990,9 @@ var init_reviewer_variants = __esm(() => {
|
|
|
20645
20990
|
});
|
|
20646
20991
|
|
|
20647
20992
|
// src/adapters/agy/hooks.ts
|
|
20648
|
-
import { closeSync as
|
|
20993
|
+
import { closeSync as closeSync12, constants as constants9, fstatSync as fstatSync11, lstatSync as lstatSync20, openSync as openSync12, readSync as readSync9 } from "fs";
|
|
20649
20994
|
import { homedir as homedir5 } from "os";
|
|
20650
|
-
import { isAbsolute as isAbsolute7, join as
|
|
20995
|
+
import { isAbsolute as isAbsolute7, join as join23, relative as relative5 } from "path";
|
|
20651
20996
|
import { createHash as createHash12 } from "crypto";
|
|
20652
20997
|
function agyModel(value) {
|
|
20653
20998
|
const model = safeModelLabel(value);
|
|
@@ -20702,19 +21047,19 @@ function readAgyTranscript(session, transcript, options) {
|
|
|
20702
21047
|
if (!UUID2.test(session))
|
|
20703
21048
|
return empty;
|
|
20704
21049
|
const home = process.env.HOME ?? homedir5();
|
|
20705
|
-
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) =>
|
|
21050
|
+
const candidates = ["antigravity-cli", "antigravity", "antigravity-ide"].map((surface) => join23(home, ".gemini", surface, "brain", session, ".system_generated/logs/transcript_full.jsonl"));
|
|
20706
21051
|
if (!candidates.includes(transcript))
|
|
20707
21052
|
return empty;
|
|
20708
21053
|
let fd;
|
|
20709
21054
|
try {
|
|
20710
21055
|
let cursor = home;
|
|
20711
21056
|
for (const name of relative5(home, transcript).split("/")) {
|
|
20712
|
-
cursor =
|
|
20713
|
-
if (
|
|
21057
|
+
cursor = join23(cursor, name);
|
|
21058
|
+
if (lstatSync20(cursor).isSymbolicLink())
|
|
20714
21059
|
return empty;
|
|
20715
21060
|
}
|
|
20716
|
-
fd =
|
|
20717
|
-
const stat =
|
|
21061
|
+
fd = openSync12(transcript, constants9.O_RDONLY | constants9.O_NOFOLLOW);
|
|
21062
|
+
const stat = fstatSync11(fd);
|
|
20718
21063
|
if (!stat.isFile() || stat.nlink !== 1)
|
|
20719
21064
|
return empty;
|
|
20720
21065
|
if (options?.unchanged && stat.size === options.unchanged.size && stat.mtimeMs === options.unchanged.mtimeMs)
|
|
@@ -20729,7 +21074,7 @@ function readAgyTranscript(session, transcript, options) {
|
|
|
20729
21074
|
const buffer = Buffer.alloc(stat.size - from);
|
|
20730
21075
|
let bytes = 0;
|
|
20731
21076
|
while (bytes < buffer.length) {
|
|
20732
|
-
const count =
|
|
21077
|
+
const count = readSync9(fd, buffer, bytes, buffer.length - bytes, from + bytes);
|
|
20733
21078
|
if (!count)
|
|
20734
21079
|
break;
|
|
20735
21080
|
bytes += count;
|
|
@@ -20790,7 +21135,7 @@ function readAgyTranscript(session, transcript, options) {
|
|
|
20790
21135
|
return empty;
|
|
20791
21136
|
} finally {
|
|
20792
21137
|
if (fd !== undefined)
|
|
20793
|
-
|
|
21138
|
+
closeSync12(fd);
|
|
20794
21139
|
}
|
|
20795
21140
|
}
|
|
20796
21141
|
var EVENTS2, UUID2, record6 = (value) => !!value && typeof value === "object" && !Array.isArray(value), AGY_FACTS_HOOK;
|
|
@@ -20868,8 +21213,8 @@ function builtinCliEntries(definitions) {
|
|
|
20868
21213
|
return Object.freeze(definitions.flatMap((definition) => definition.cli.entry ? [Object.freeze({ ...definition.cli.entry, command: definition.cli.command })] : []));
|
|
20869
21214
|
}
|
|
20870
21215
|
// src/adapters/definitions/native-cli-entry-claude.ts
|
|
20871
|
-
import { readFileSync as
|
|
20872
|
-
import { join as
|
|
21216
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
21217
|
+
import { join as join24 } from "path";
|
|
20873
21218
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
20874
21219
|
async function runClaudeEntry(ctx) {
|
|
20875
21220
|
const { args, cwd, stateDir, cliDir, unattendedEnv, projectConfig, fail } = ctx;
|
|
@@ -20920,17 +21265,17 @@ async function runClaudeEntry(ctx) {
|
|
|
20920
21265
|
}
|
|
20921
21266
|
}
|
|
20922
21267
|
let original;
|
|
20923
|
-
for (const file of [
|
|
21268
|
+
for (const file of [join24(executionCwd, ".claude", "settings.local.json"), join24(executionCwd, ".claude", "settings.json"), join24(process.env.HOME ?? "", ".claude", "settings.json")]) {
|
|
20924
21269
|
try {
|
|
20925
|
-
original ??= JSON.parse(
|
|
21270
|
+
original ??= JSON.parse(readFileSync11(file, "utf8")).statusLine;
|
|
20926
21271
|
} catch {}
|
|
20927
21272
|
}
|
|
20928
|
-
const facts = claudeObservationHooks(projectConfig(), { script:
|
|
21273
|
+
const facts = claudeObservationHooks(projectConfig(), { script: join24(cliDir, "facts-hook.ts"), stateDir });
|
|
20929
21274
|
let previousLaunch;
|
|
20930
21275
|
try {
|
|
20931
|
-
previousLaunch = JSON.parse(
|
|
21276
|
+
previousLaunch = JSON.parse(readFileSync11(join24(stateDir, claudeStateFile("claude-launch", peer)), "utf8"));
|
|
20932
21277
|
} catch {}
|
|
20933
|
-
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script:
|
|
21278
|
+
const launch = buildLaunch("claude", args, { unattended: unattendedEnv, statusLine: { script: join24(cliDir, "statusline-tee.ts"), stateDir, ...original ? { original } : {} }, ...facts ? { facts } : {} });
|
|
20934
21279
|
let result;
|
|
20935
21280
|
try {
|
|
20936
21281
|
let launchRecord;
|
|
@@ -21024,15 +21369,15 @@ var init_native_cli_entry_codex = () => {};
|
|
|
21024
21369
|
|
|
21025
21370
|
// src/cli/kimi-plugin.ts
|
|
21026
21371
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
21027
|
-
import { closeSync as
|
|
21028
|
-
import { dirname as
|
|
21372
|
+
import { closeSync as closeSync13, lstatSync as lstatSync21, mkdirSync as mkdirSync12, openSync as openSync13, readFileSync as readFileSync12, renameSync as renameSync6, rmdirSync as rmdirSync4, unlinkSync as unlinkSync4, writeFileSync as writeFileSync10 } from "fs";
|
|
21373
|
+
import { dirname as dirname15, isAbsolute as isAbsolute8, join as join25 } from "path";
|
|
21029
21374
|
function file(path, cap) {
|
|
21030
|
-
const stat =
|
|
21375
|
+
const stat = lstatSync21(path, { throwIfNoEntry: false });
|
|
21031
21376
|
if (!stat)
|
|
21032
21377
|
return;
|
|
21033
21378
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.nlink !== 1 || stat.size > cap)
|
|
21034
21379
|
throw new Error(`${path} must be a bounded regular file`);
|
|
21035
|
-
return { stat, bytes:
|
|
21380
|
+
return { stat, bytes: readFileSync12(path) };
|
|
21036
21381
|
}
|
|
21037
21382
|
function parse2(value, name) {
|
|
21038
21383
|
if (!value)
|
|
@@ -21047,28 +21392,28 @@ function parse2(value, name) {
|
|
|
21047
21392
|
}
|
|
21048
21393
|
}
|
|
21049
21394
|
function atomic(path, bytes, before) {
|
|
21050
|
-
const current =
|
|
21395
|
+
const current = lstatSync21(path, { throwIfNoEntry: false });
|
|
21051
21396
|
if (before ? !current || current.dev !== before.dev || current.ino !== before.ino : current)
|
|
21052
21397
|
throw new Error(`${path} changed before its managed write`);
|
|
21053
21398
|
const temporary = `${path}.${randomUUID11()}.tmp`;
|
|
21054
21399
|
let fd;
|
|
21055
21400
|
try {
|
|
21056
|
-
fd =
|
|
21401
|
+
fd = openSync13(temporary, "wx", 384);
|
|
21057
21402
|
writeFileSync10(fd, bytes);
|
|
21058
|
-
|
|
21403
|
+
closeSync13(fd);
|
|
21059
21404
|
fd = undefined;
|
|
21060
|
-
|
|
21405
|
+
renameSync6(temporary, path);
|
|
21061
21406
|
} finally {
|
|
21062
21407
|
if (fd !== undefined)
|
|
21063
|
-
|
|
21408
|
+
closeSync13(fd);
|
|
21064
21409
|
try {
|
|
21065
21410
|
unlinkSync4(temporary);
|
|
21066
21411
|
} catch {}
|
|
21067
21412
|
}
|
|
21068
21413
|
}
|
|
21069
21414
|
function removeFile(path, expected) {
|
|
21070
|
-
const current =
|
|
21071
|
-
if (!current || !current.isFile() || current.isSymbolicLink() || current.nlink !== 1 || !
|
|
21415
|
+
const current = lstatSync21(path, { throwIfNoEntry: false });
|
|
21416
|
+
if (!current || !current.isFile() || current.isSymbolicLink() || current.nlink !== 1 || !readFileSync12(path).equals(expected))
|
|
21072
21417
|
return;
|
|
21073
21418
|
unlinkSync4(path);
|
|
21074
21419
|
}
|
|
@@ -21098,7 +21443,7 @@ function plan2(options) {
|
|
|
21098
21443
|
const hook = file(options.hookScript, MAX_HOOK);
|
|
21099
21444
|
if (!hook)
|
|
21100
21445
|
throw new Error("Kimi hook bundle is missing");
|
|
21101
|
-
const root =
|
|
21446
|
+
const root = join25(options.home, "plugins"), managed = join25(root, "managed", ID2), installed = join25(root, "installed.json");
|
|
21102
21447
|
const installedBefore = file(installed, MAX_INSTALLED), document = parse2(installedBefore, installed);
|
|
21103
21448
|
if (document && (document.version !== 1 || !Array.isArray(document.plugins)))
|
|
21104
21449
|
throw new Error(`${installed} has an unsupported shape`);
|
|
@@ -21111,11 +21456,11 @@ function plan2(options) {
|
|
|
21111
21456
|
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
21457
|
throw new Error("Kimi's agent-hub plugin belongs to another launch or is disabled; it was not changed");
|
|
21113
21458
|
}
|
|
21114
|
-
const manifestBefore = file(
|
|
21459
|
+
const manifestBefore = file(join25(managed, "kimi.plugin.json"), MAX_INSTALLED), hookBefore = file(join25(managed, "kimi-hook.js"), MAX_HOOK);
|
|
21115
21460
|
const nextManifest = Buffer.from(`${JSON.stringify(manifest(), null, 2)}
|
|
21116
21461
|
`);
|
|
21117
21462
|
const now = new Date(options.now ?? Date.now()).toISOString();
|
|
21118
|
-
const changed = !record || record.agentHubLaunch !== options.launchId || !record.agentHubOwner || !manifestBefore?.bytes.equals(nextManifest) || !hookBefore?.bytes.equals(hook.bytes) || record.originalSource !==
|
|
21463
|
+
const changed = !record || record.agentHubLaunch !== options.launchId || !record.agentHubOwner || !manifestBefore?.bytes.equals(nextManifest) || !hookBefore?.bytes.equals(hook.bytes) || record.originalSource !== dirname15(options.hookScript);
|
|
21119
21464
|
const nextRecord = {
|
|
21120
21465
|
id: ID2,
|
|
21121
21466
|
root: managed,
|
|
@@ -21124,7 +21469,7 @@ function plan2(options) {
|
|
|
21124
21469
|
enabled: true,
|
|
21125
21470
|
installedAt: typeof record?.installedAt === "string" ? record.installedAt : now,
|
|
21126
21471
|
updatedAt: changed ? now : typeof record?.updatedAt === "string" ? record.updatedAt : now,
|
|
21127
|
-
originalSource:
|
|
21472
|
+
originalSource: dirname15(options.hookScript),
|
|
21128
21473
|
agentHubLaunch: options.launchId,
|
|
21129
21474
|
agentHubOwner: record && record.agentHubLaunch === options.launchId && record.agentHubOwner ? record.agentHubOwner : ownerProof(options)
|
|
21130
21475
|
};
|
|
@@ -21136,8 +21481,8 @@ function plan2(options) {
|
|
|
21136
21481
|
...record ? { record } : {},
|
|
21137
21482
|
changed,
|
|
21138
21483
|
targets: [
|
|
21139
|
-
{ path:
|
|
21140
|
-
{ path:
|
|
21484
|
+
{ path: join25(managed, "kimi.plugin.json"), next: nextManifest, ...manifestBefore ? { before: manifestBefore } : {} },
|
|
21485
|
+
{ path: join25(managed, "kimi-hook.js"), next: hook.bytes, ...hookBefore ? { before: hookBefore } : {} },
|
|
21141
21486
|
{ path: installed, next: Buffer.from(`${JSON.stringify(nextDocument, null, 2)}
|
|
21142
21487
|
`), ...installedBefore ? { before: installedBefore } : {} }
|
|
21143
21488
|
]
|
|
@@ -21149,23 +21494,23 @@ function kimiPluginPreview(home, hookScript) {
|
|
|
21149
21494
|
directory(home, false);
|
|
21150
21495
|
if (!file(hookScript, MAX_HOOK))
|
|
21151
21496
|
throw new Error("Kimi hook bundle is missing");
|
|
21152
|
-
return { file:
|
|
21497
|
+
return { file: join25(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
21498
|
}
|
|
21154
21499
|
function locked(options, run) {
|
|
21155
21500
|
if (!isAbsolute8(options.home))
|
|
21156
21501
|
throw new Error("Kimi home must be an absolute path");
|
|
21157
21502
|
directory(options.home);
|
|
21158
|
-
const path =
|
|
21503
|
+
const path = join25(options.home, "agent-hub-plugin.lock");
|
|
21159
21504
|
let fd;
|
|
21160
21505
|
try {
|
|
21161
|
-
fd =
|
|
21506
|
+
fd = openSync13(path, "wx", 384);
|
|
21162
21507
|
} catch {
|
|
21163
21508
|
throw new Error(`Another Kimi plugin replacement is active or left a stale lock; retry after it exits or inspect ${path}`);
|
|
21164
21509
|
}
|
|
21165
21510
|
try {
|
|
21166
21511
|
return run();
|
|
21167
21512
|
} finally {
|
|
21168
|
-
|
|
21513
|
+
closeSync13(fd);
|
|
21169
21514
|
unlinkSync4(path);
|
|
21170
21515
|
}
|
|
21171
21516
|
}
|
|
@@ -21174,7 +21519,7 @@ function ensureKimiPlugin(options) {
|
|
|
21174
21519
|
const current = plan2(options);
|
|
21175
21520
|
if (!current.changed)
|
|
21176
21521
|
return { changed: false };
|
|
21177
|
-
for (const path of [
|
|
21522
|
+
for (const path of [join25(options.home, "plugins"), join25(options.home, "plugins", "managed"), current.managed]) {
|
|
21178
21523
|
if (!directory(path, false))
|
|
21179
21524
|
mkdirSync12(path, { mode: 448 });
|
|
21180
21525
|
}
|
|
@@ -21199,15 +21544,15 @@ function cleanupKimiPlugin(options) {
|
|
|
21199
21544
|
atomic(current.installed, Buffer.from(`${JSON.stringify(next, null, 2)}
|
|
21200
21545
|
`), installedBefore?.stat);
|
|
21201
21546
|
const [manifestTarget, hookTarget] = current.targets;
|
|
21202
|
-
removeFile(
|
|
21203
|
-
removeFile(
|
|
21547
|
+
removeFile(join25(current.managed, "kimi.plugin.json"), manifestTarget.next);
|
|
21548
|
+
removeFile(join25(current.managed, "kimi-hook.js"), hookTarget.next);
|
|
21204
21549
|
try {
|
|
21205
21550
|
rmdirSync4(current.managed);
|
|
21206
21551
|
} catch {}
|
|
21207
21552
|
});
|
|
21208
21553
|
}
|
|
21209
21554
|
var EVENTS3, ID2 = "agent-hub", MAX_INSTALLED, MAX_HOOK, object8 = (value) => !!value && typeof value === "object" && !Array.isArray(value), directory = (path, required = true) => {
|
|
21210
|
-
const stat =
|
|
21555
|
+
const stat = lstatSync21(path, { throwIfNoEntry: false });
|
|
21211
21556
|
if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
|
|
21212
21557
|
throw new Error(`${path} must be a plain directory`);
|
|
21213
21558
|
if (!stat && required)
|
|
@@ -21222,7 +21567,7 @@ var init_kimi_plugin = __esm(() => {
|
|
|
21222
21567
|
});
|
|
21223
21568
|
|
|
21224
21569
|
// src/adapters/definitions/native-cli-entry-kimi.ts
|
|
21225
|
-
import { join as
|
|
21570
|
+
import { join as join26, resolve as resolve14 } from "path";
|
|
21226
21571
|
import { homedir as homedir6 } from "os";
|
|
21227
21572
|
import { spawn as spawn10, spawnSync as spawnSync4 } from "child_process";
|
|
21228
21573
|
import { mkdirSync as mkdirSync13 } from "fs";
|
|
@@ -21344,7 +21689,7 @@ async function runKimiEntry(ctx) {
|
|
|
21344
21689
|
if (!gate.ok) {
|
|
21345
21690
|
result = await runKimiTui(launch.cmd, launch.args, cwd, nativeEnv);
|
|
21346
21691
|
} else {
|
|
21347
|
-
const nativeHome = nativeEnv.KIMI_CODE_HOME ??
|
|
21692
|
+
const nativeHome = nativeEnv.KIMI_CODE_HOME ?? join26(nativeEnv.HOME ?? homedir6(), ".kimi-code");
|
|
21348
21693
|
let nativeLaunchId, completionEnv, plugin;
|
|
21349
21694
|
try {
|
|
21350
21695
|
mkdirSync13(nativeHome, { recursive: true, mode: 448 });
|
|
@@ -21353,7 +21698,7 @@ async function runKimiEntry(ctx) {
|
|
|
21353
21698
|
throw new Error(native.error ?? "native hook launch was not admitted");
|
|
21354
21699
|
nativeLaunchId = native.launchId;
|
|
21355
21700
|
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 ${
|
|
21701
|
+
console.error(`Kimi TUI completion facts: installing a launch-scoped native plugin under ${join26(nativeHome, "plugins", "managed", "agent-hub")}; it will be removed after this TUI exits`);
|
|
21357
21702
|
ensureKimiPlugin(plugin);
|
|
21358
21703
|
completionEnv = { ...nativeEnv, AGENTHUB_INSTANCE_ID: native.instanceId, AGENTHUB_LAUNCH_ID: native.launchId, AGENTHUB_HOOK_PURPOSE: "facts" };
|
|
21359
21704
|
} catch (error) {
|
|
@@ -21364,7 +21709,7 @@ async function runKimiEntry(ctx) {
|
|
|
21364
21709
|
try {
|
|
21365
21710
|
cleanupKimiPlugin(plugin);
|
|
21366
21711
|
} catch {
|
|
21367
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21712
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join26(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21368
21713
|
}
|
|
21369
21714
|
}
|
|
21370
21715
|
if (completionEnv) {
|
|
@@ -21377,7 +21722,7 @@ async function runKimiEntry(ctx) {
|
|
|
21377
21722
|
try {
|
|
21378
21723
|
cleanupKimiPlugin(plugin);
|
|
21379
21724
|
} catch {
|
|
21380
|
-
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${
|
|
21725
|
+
console.error(`Managed Kimi plugin cleanup refused: files or ownership changed; inspect ${join26(nativeHome, "plugins", "managed", "agent-hub")} before removing it`);
|
|
21381
21726
|
}
|
|
21382
21727
|
}
|
|
21383
21728
|
} else {
|
|
@@ -21745,8 +22090,8 @@ var init_native_cli_entry_jcode = __esm(() => {
|
|
|
21745
22090
|
});
|
|
21746
22091
|
|
|
21747
22092
|
// src/adapters/definitions/native-cli-preview-claude.ts
|
|
21748
|
-
import { readFileSync as
|
|
21749
|
-
import { join as
|
|
22093
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
22094
|
+
import { join as join27 } from "path";
|
|
21750
22095
|
function previewClaude(ctx) {
|
|
21751
22096
|
const { args, cwd, stateDir, cliDir, unattended, config } = ctx;
|
|
21752
22097
|
const { buildLaunch, claudeObservationHooks } = ctx.helpers;
|
|
@@ -21754,13 +22099,13 @@ function previewClaude(ctx) {
|
|
|
21754
22099
|
let envNames = state.envNames;
|
|
21755
22100
|
let launch;
|
|
21756
22101
|
let original;
|
|
21757
|
-
for (const file of [
|
|
22102
|
+
for (const file of [join27(cwd, ".claude/settings.local.json"), join27(cwd, ".claude/settings.json"), join27(process.env.HOME ?? "", ".claude/settings.json")]) {
|
|
21758
22103
|
try {
|
|
21759
|
-
original ??= JSON.parse(
|
|
22104
|
+
original ??= JSON.parse(readFileSync13(file, "utf8")).statusLine;
|
|
21760
22105
|
} catch {}
|
|
21761
22106
|
}
|
|
21762
|
-
const facts = claudeObservationHooks(config, { script:
|
|
21763
|
-
launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script:
|
|
22107
|
+
const facts = claudeObservationHooks(config, { script: join27(cliDir, "facts-hook.ts"), stateDir });
|
|
22108
|
+
launch = buildLaunch("claude", args, { preview: true, unattended, statusLine: { script: join27(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
22109
|
const safeArgs = args.map((arg, i) => {
|
|
21765
22110
|
if (args[i - 1] === "--settings")
|
|
21766
22111
|
return "{}";
|
|
@@ -21771,7 +22116,7 @@ function previewClaude(ctx) {
|
|
|
21771
22116
|
return publicArg(arg);
|
|
21772
22117
|
});
|
|
21773
22118
|
const publicLaunch = buildLaunch("claude", safeArgs, { preview: true, unattended, statusLine: {
|
|
21774
|
-
script:
|
|
22119
|
+
script: join27(cliDir, "statusline-tee.ts"),
|
|
21775
22120
|
stateDir,
|
|
21776
22121
|
...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
22122
|
}, facts });
|
|
@@ -21804,7 +22149,7 @@ function previewCodex(ctx) {
|
|
|
21804
22149
|
var init_native_cli_preview_codex = () => {};
|
|
21805
22150
|
|
|
21806
22151
|
// src/adapters/definitions/native-cli-preview-kimi.ts
|
|
21807
|
-
import { join as
|
|
22152
|
+
import { join as join28 } from "path";
|
|
21808
22153
|
import { homedir as homedir7 } from "os";
|
|
21809
22154
|
function previewKimi(ctx) {
|
|
21810
22155
|
const { args, cwd, stateDir, cliDir, config } = ctx;
|
|
@@ -21830,10 +22175,10 @@ function previewKimi(ctx) {
|
|
|
21830
22175
|
const nativeEnv = nativeLaunchEnv("kimi", childEnv());
|
|
21831
22176
|
envNames = Object.keys(nativeEnv).concat(["AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR", "AGENTHUB_INSTANCE_ID", "AGENTHUB_LAUNCH_ID", "AGENTHUB_HOOK_PURPOSE"]);
|
|
21832
22177
|
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,
|
|
22178
|
+
const home = nativeEnv.KIMI_CODE_HOME ?? join28(nativeEnv.HOME ?? homedir7(), ".kimi-code");
|
|
22179
|
+
completionPlugin = kimiPluginPreview(home, join28(cliDir, "../../plugins/agent-hub/kimi-hook.js"));
|
|
21835
22180
|
}
|
|
21836
|
-
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir,
|
|
22181
|
+
const { file, action, changed, tracked } = kimiMcpPlan(cwd, stateDir, join28(cliDir, "../../plugins/agent-hub/server.js"), mode);
|
|
21837
22182
|
kimiMetadata = { mode, mcp: { file, action, changed, tracked }, ...completionPlugin ? { completionPlugin } : {} };
|
|
21838
22183
|
return finishPreview(ctx, launch, envNames, unresolved, kimiMetadata);
|
|
21839
22184
|
}
|
|
@@ -21842,7 +22187,7 @@ var init_native_cli_preview_kimi = __esm(() => {
|
|
|
21842
22187
|
});
|
|
21843
22188
|
|
|
21844
22189
|
// src/adapters/definitions/native-cli-preview-pi.ts
|
|
21845
|
-
import { join as
|
|
22190
|
+
import { join as join29, resolve as resolve16 } from "path";
|
|
21846
22191
|
function previewPi(ctx) {
|
|
21847
22192
|
const { args, stateDir, cliDir, config } = ctx;
|
|
21848
22193
|
const { relayModelIds, buildPiLaunch, startModeOf } = ctx.helpers;
|
|
@@ -21877,7 +22222,7 @@ function previewPi(ctx) {
|
|
|
21877
22222
|
tools: [],
|
|
21878
22223
|
preamble: REDACTED,
|
|
21879
22224
|
maxSteps: config.pi.max_steps
|
|
21880
|
-
}, {}, resolve16(
|
|
22225
|
+
}, {}, resolve16(join29(cliDir, "../pi/extension.ts")), UNRESOLVED, UNRESOLVED);
|
|
21881
22226
|
launch = pi;
|
|
21882
22227
|
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
22228
|
if (mode === "tui")
|
|
@@ -21967,8 +22312,8 @@ var init_native_config_policy = __esm(() => {
|
|
|
21967
22312
|
});
|
|
21968
22313
|
|
|
21969
22314
|
// src/adapters/definitions/native-policy-aux.ts
|
|
21970
|
-
import { closeSync as
|
|
21971
|
-
import { isAbsolute as isAbsolute9, join as
|
|
22315
|
+
import { closeSync as closeSync14, constants as constants10, fstatSync as fstatSync12, openSync as openSync14, readdirSync as readdirSync5, readFileSync as readFileSync14 } from "fs";
|
|
22316
|
+
import { isAbsolute as isAbsolute9, join as join30, normalize } from "path";
|
|
21972
22317
|
function claudeCrashPlan(_meta) {
|
|
21973
22318
|
return { how: "claude: the Claude Code plugin reconnects by itself while that session is still open" };
|
|
21974
22319
|
}
|
|
@@ -22013,13 +22358,13 @@ function localCrashPlan(meta) {
|
|
|
22013
22358
|
}
|
|
22014
22359
|
function claudePlugins(root, cwd) {
|
|
22015
22360
|
const enabled = new Map;
|
|
22016
|
-
for (const file of [
|
|
22361
|
+
for (const file of [join30(root, "settings.json"), ...cwd ? [join30(cwd, ".claude", "settings.json"), join30(cwd, ".claude", "settings.local.json")] : []]) {
|
|
22017
22362
|
const map = json(file)?.enabledPlugins;
|
|
22018
22363
|
if (map && typeof map === "object")
|
|
22019
22364
|
for (const [key, on] of Object.entries(map))
|
|
22020
22365
|
enabled.set(key, on === true);
|
|
22021
22366
|
}
|
|
22022
|
-
const installed = json(
|
|
22367
|
+
const installed = json(join30(root, "plugins", "installed_plugins.json"))?.plugins ?? {};
|
|
22023
22368
|
const out = [];
|
|
22024
22369
|
for (const [key, on] of enabled) {
|
|
22025
22370
|
if (!on)
|
|
@@ -22033,7 +22378,7 @@ function claudePlugins(root, cwd) {
|
|
|
22033
22378
|
return out;
|
|
22034
22379
|
}
|
|
22035
22380
|
function codexPlugins(root) {
|
|
22036
|
-
const config = text2(
|
|
22381
|
+
const config = text2(join30(root, "config.toml"));
|
|
22037
22382
|
if (config === undefined)
|
|
22038
22383
|
return [];
|
|
22039
22384
|
const found = new Map, disabled = new Set;
|
|
@@ -22052,7 +22397,7 @@ function codexPlugins(root) {
|
|
|
22052
22397
|
continue;
|
|
22053
22398
|
let versions = [];
|
|
22054
22399
|
try {
|
|
22055
|
-
versions =
|
|
22400
|
+
versions = readdirSync5(join30(root, "plugins", "cache", market, plugin));
|
|
22056
22401
|
} catch {}
|
|
22057
22402
|
out.push({ name, version: versions.length === 1 ? version2(versions[0]) : null });
|
|
22058
22403
|
}
|
|
@@ -22072,16 +22417,16 @@ function absoluteContinuityPath(value) {
|
|
|
22072
22417
|
var str3 = (value) => typeof value === "string" && value ? value : undefined, PLUGINS, CLAUDE_ONLY, text2 = (file) => {
|
|
22073
22418
|
let fd;
|
|
22074
22419
|
try {
|
|
22075
|
-
fd =
|
|
22076
|
-
const st =
|
|
22420
|
+
fd = openSync14(file, constants10.O_RDONLY | constants10.O_NONBLOCK);
|
|
22421
|
+
const st = fstatSync12(fd);
|
|
22077
22422
|
if (!st.isFile() || st.size > 1024 * 1024)
|
|
22078
22423
|
return;
|
|
22079
|
-
return
|
|
22424
|
+
return readFileSync14(fd, "utf8");
|
|
22080
22425
|
} catch {
|
|
22081
22426
|
return;
|
|
22082
22427
|
} finally {
|
|
22083
22428
|
if (fd !== undefined)
|
|
22084
|
-
|
|
22429
|
+
closeSync14(fd);
|
|
22085
22430
|
}
|
|
22086
22431
|
}, json = (file) => {
|
|
22087
22432
|
try {
|
|
@@ -22090,7 +22435,7 @@ var str3 = (value) => typeof value === "string" && value ? value : undefined, PL
|
|
|
22090
22435
|
} catch {
|
|
22091
22436
|
return;
|
|
22092
22437
|
}
|
|
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() ||
|
|
22438
|
+
}, version2 = (v) => typeof v === "string" && /^[0-9A-Za-z.+_-]{1,40}$/.test(v) ? v : null, claudePluginInventory = (ctx) => claudePlugins(ctx.env.CLAUDE_CONFIG_DIR?.trim() || join30(ctx.home, ".claude"), ctx.cwd), codexPluginInventory = (ctx) => codexPlugins(ctx.env.CODEX_HOME?.trim() || join30(ctx.home, ".codex")), codexToolSemantic = (name, _command) => name.toLowerCase() === "filechange" ? "edit" : undefined;
|
|
22094
22439
|
var init_native_policy_aux = __esm(() => {
|
|
22095
22440
|
PLUGINS = new Map([["claude-mem", "claude-mem"], ["ponytail", "ponytail"], ["open-code-review", "open-code-review"]]);
|
|
22096
22441
|
CLAUDE_ONLY = new Map([["codex@openai-codex", "codex-plugin"]]);
|
|
@@ -22133,9 +22478,9 @@ var init_native_cli_launch_common = __esm(() => {
|
|
|
22133
22478
|
});
|
|
22134
22479
|
|
|
22135
22480
|
// src/adapters/definitions/native-cli-claude-launch.ts
|
|
22136
|
-
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync11, renameSync as
|
|
22481
|
+
import { mkdirSync as mkdirSync14, writeFileSync as writeFileSync11, renameSync as renameSync7, unlinkSync as unlinkSync5, readFileSync as readFileSync15 } from "fs";
|
|
22137
22482
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
22138
|
-
import { resolve as resolve17, join as
|
|
22483
|
+
import { resolve as resolve17, join as join31 } from "path";
|
|
22139
22484
|
function claudeChannel(userArgs) {
|
|
22140
22485
|
const bundle = resolve17(import.meta.dir, "../../../plugins/agent-hub/server.js");
|
|
22141
22486
|
for (let i = 0;i < userArgs.length; i++) {
|
|
@@ -22144,7 +22489,7 @@ function claudeChannel(userArgs) {
|
|
|
22144
22489
|
if (!path)
|
|
22145
22490
|
continue;
|
|
22146
22491
|
try {
|
|
22147
|
-
const server = JSON.parse(
|
|
22492
|
+
const server = JSON.parse(readFileSync15(resolve17(path), "utf8")).mcpServers?.["agent-hub"];
|
|
22148
22493
|
if (server?.command === "bun" && Array.isArray(server.args) && server.args.some((value) => typeof value === "string" && resolve17(value) === bundle))
|
|
22149
22494
|
return "server:agent-hub";
|
|
22150
22495
|
} catch {}
|
|
@@ -22168,7 +22513,7 @@ function claudeNativeLaunch(ctx) {
|
|
|
22168
22513
|
throw new Error("--settings requires a JSON object or readable file so the hub permission hook can be installed");
|
|
22169
22514
|
let caller;
|
|
22170
22515
|
try {
|
|
22171
|
-
caller = JSON.parse(value.trim().startsWith("{") ? value :
|
|
22516
|
+
caller = JSON.parse(value.trim().startsWith("{") ? value : readFileSync15(resolve17(value), "utf8"));
|
|
22172
22517
|
if (!caller || typeof caller !== "object" || Array.isArray(caller))
|
|
22173
22518
|
throw new Error("not an object");
|
|
22174
22519
|
} catch {
|
|
@@ -22197,11 +22542,11 @@ function claudeNativeLaunch(ctx) {
|
|
|
22197
22542
|
const stateDir = ctx.facts?.stateDir ?? ctx.statusLine?.stateDir;
|
|
22198
22543
|
if (!stateDir)
|
|
22199
22544
|
throw new Error("Claude session settings require the hub state directory");
|
|
22200
|
-
const file =
|
|
22545
|
+
const file = join31(stateDir, `claude-settings-${randomUUID12()}.json`);
|
|
22201
22546
|
try {
|
|
22202
22547
|
mkdirSync14(stateDir, { recursive: true, mode: 448 });
|
|
22203
22548
|
writeFileSync11(`${file}.tmp`, settingsArgs[1], { mode: 384, flag: "wx" });
|
|
22204
|
-
|
|
22549
|
+
renameSync7(`${file}.tmp`, file);
|
|
22205
22550
|
} catch {
|
|
22206
22551
|
try {
|
|
22207
22552
|
unlinkSync5(`${file}.tmp`);
|
|
@@ -22253,44 +22598,20 @@ var init_native_cli_codex_launch = __esm(() => {
|
|
|
22253
22598
|
CODEX_LAUNCH_POLICY = Object.freeze({ hubSwitches: Object.freeze(["--unattended", "--safe", "--new"]), ownedFlags: Object.freeze(["--remote", "--remote-auth-token-env", "--yolo", "--dangerously-bypass-approvals-and-sandbox"]), unattended: true, passthrough: true });
|
|
22254
22599
|
});
|
|
22255
22600
|
|
|
22256
|
-
// src/hub/events.ts
|
|
22257
|
-
import { appendFileSync, closeSync as closeSync13, existsSync as existsSync9, fstatSync as fstatSync11, openSync as openSync13, readFileSync as readFileSync15, readSync as readSync8 } from "fs";
|
|
22258
|
-
function readEvents(file, since = 0) {
|
|
22259
|
-
if (!existsSync9(file))
|
|
22260
|
-
return [];
|
|
22261
|
-
return readFileSync15(file, "utf8").split(`
|
|
22262
|
-
`).flatMap((line) => {
|
|
22263
|
-
const event = parseEventLine(line, since);
|
|
22264
|
-
return event === undefined ? [] : [event];
|
|
22265
|
-
});
|
|
22266
|
-
}
|
|
22267
|
-
function parseEventLine(line, since = 0) {
|
|
22268
|
-
if (!line.trim())
|
|
22269
|
-
return;
|
|
22270
|
-
try {
|
|
22271
|
-
const e = JSON.parse(line);
|
|
22272
|
-
const measuredAt = e.type === "usage" && typeof e.measuredAt === "string" ? e.measuredAt : e.at;
|
|
22273
|
-
return Date.parse(measuredAt) >= since ? e : undefined;
|
|
22274
|
-
} catch {
|
|
22275
|
-
return;
|
|
22276
|
-
}
|
|
22277
|
-
}
|
|
22278
|
-
var init_events = () => {};
|
|
22279
|
-
|
|
22280
22601
|
// src/cli/recovery-session-file.ts
|
|
22281
|
-
import { statSync as
|
|
22602
|
+
import { statSync as statSync6 } from "fs";
|
|
22282
22603
|
import { homedir as homedir8 } from "os";
|
|
22283
|
-
import { join as
|
|
22604
|
+
import { join as join32 } from "path";
|
|
22284
22605
|
function checkedSessionPath(binding, kind) {
|
|
22285
22606
|
if (kind === "rollout")
|
|
22286
|
-
return
|
|
22287
|
-
const config = binding.launch.env.CLAUDE_CONFIG_DIR ??
|
|
22607
|
+
return join32(binding.launch.env.CODEX_HOME ?? join32(homedir8(), ".codex"), "sessions");
|
|
22608
|
+
const config = binding.launch.env.CLAUDE_CONFIG_DIR ?? join32(homedir8(), ".claude");
|
|
22288
22609
|
const slug = binding.projectRoot.replace(/[^a-zA-Z0-9]/g, "-");
|
|
22289
|
-
return
|
|
22610
|
+
return join32(config, "projects", slug, `${binding.sessionId}.jsonl`);
|
|
22290
22611
|
}
|
|
22291
22612
|
function recordedFileState(file) {
|
|
22292
22613
|
try {
|
|
22293
|
-
return
|
|
22614
|
+
return statSync6(file).isFile() ? "found" : "unknown";
|
|
22294
22615
|
} catch (error) {
|
|
22295
22616
|
return error.code === "ENOENT" ? "missing" : "unknown";
|
|
22296
22617
|
}
|
|
@@ -22298,11 +22619,11 @@ function recordedFileState(file) {
|
|
|
22298
22619
|
var init_recovery_session_file = () => {};
|
|
22299
22620
|
|
|
22300
22621
|
// src/adapters/definitions/native-recovery.ts
|
|
22301
|
-
import { readdirSync as
|
|
22302
|
-
import { basename as
|
|
22622
|
+
import { readdirSync as readdirSync6 } from "fs";
|
|
22623
|
+
import { basename as basename6, join as join33 } from "path";
|
|
22303
22624
|
var rolloutState = (binding) => {
|
|
22304
22625
|
try {
|
|
22305
|
-
return
|
|
22626
|
+
return readdirSync6(checkedSessionPath(binding, "rollout"), { recursive: true }).some((name) => String(name).endsWith(".jsonl") && basename6(String(name)).includes(binding.sessionId));
|
|
22306
22627
|
} catch (error) {
|
|
22307
22628
|
return error.code === "ENOENT" ? false : "unknown";
|
|
22308
22629
|
}
|
|
@@ -22323,7 +22644,7 @@ var init_native_recovery = __esm(() => {
|
|
|
22323
22644
|
if (phase !== "plan")
|
|
22324
22645
|
return false;
|
|
22325
22646
|
let current, started = false, turned = false;
|
|
22326
|
-
for (const e of readEvents(
|
|
22647
|
+
for (const e of readEvents(join33(stateDir, "events.jsonl"))) {
|
|
22327
22648
|
if (e.type === "native_thread" && e.peer === binding.peer) {
|
|
22328
22649
|
current = e.thread;
|
|
22329
22650
|
if (e.thread === binding.sessionId && e.fresh)
|
|
@@ -22400,9 +22721,9 @@ var init_native_recovery = __esm(() => {
|
|
|
22400
22721
|
});
|
|
22401
22722
|
|
|
22402
22723
|
// src/adapters/kimi-tui-facts.ts
|
|
22403
|
-
import { closeSync as
|
|
22724
|
+
import { closeSync as closeSync15, constants as constants11, fstatSync as fstatSync13, lstatSync as lstatSync22, openSync as openSync15, readSync as readSync10, readdirSync as readdirSync7 } from "fs";
|
|
22404
22725
|
import { createHash as createHash13 } from "crypto";
|
|
22405
|
-
import { basename as
|
|
22726
|
+
import { basename as basename7, dirname as dirname16, isAbsolute as isAbsolute10, join as join34, relative as relative6 } from "path";
|
|
22406
22727
|
import { homedir as homedir9 } from "os";
|
|
22407
22728
|
function decodeKimiTuiHook(event, value) {
|
|
22408
22729
|
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 +22732,8 @@ function decodeKimiTuiHook(event, value) {
|
|
|
22411
22732
|
return;
|
|
22412
22733
|
if (event === "TaskStarted" && (typeof value.task_id !== "string" || !TASK.test(value.task_id)))
|
|
22413
22734
|
return;
|
|
22414
|
-
const home = process.env.KIMI_CODE_HOME ??
|
|
22415
|
-
const transcriptPath = value.agentHubTranscriptPath ??
|
|
22735
|
+
const home = process.env.KIMI_CODE_HOME ?? join34(process.env.HOME ?? homedir9(), ".kimi-code");
|
|
22736
|
+
const transcriptPath = value.agentHubTranscriptPath ?? join34(home, "session_index.jsonl");
|
|
22416
22737
|
if (typeof transcriptPath !== "string" || !isAbsolute10(transcriptPath) || transcriptPath.length > 4096)
|
|
22417
22738
|
return;
|
|
22418
22739
|
const phase = { TurnStarted: "start", Stop: "stop", StopFailure: "stop", Interrupt: "stop", SessionEnd: "session", TaskStarted: "pre", Notification: "post" }[event];
|
|
@@ -22422,30 +22743,30 @@ function encodeKimiTuiHook() {
|
|
|
22422
22743
|
return;
|
|
22423
22744
|
}
|
|
22424
22745
|
function readBytes(path, cap, tail = false) {
|
|
22425
|
-
const link =
|
|
22746
|
+
const link = lstatSync22(path);
|
|
22426
22747
|
if (!link.isFile() || link.isSymbolicLink() || link.nlink !== 1)
|
|
22427
22748
|
throw new Error("not a regular file");
|
|
22428
|
-
const fd =
|
|
22749
|
+
const fd = openSync15(path, constants11.O_RDONLY | constants11.O_NOFOLLOW);
|
|
22429
22750
|
try {
|
|
22430
|
-
const stat =
|
|
22751
|
+
const stat = fstatSync13(fd);
|
|
22431
22752
|
if (!stat.isFile() || stat.nlink !== 1 || !tail && stat.size > cap)
|
|
22432
22753
|
throw new Error("invalid file");
|
|
22433
22754
|
const length = Math.min(stat.size, cap), start = tail ? stat.size - length : 0;
|
|
22434
22755
|
const bytes = Buffer.alloc(length);
|
|
22435
22756
|
let offset = 0;
|
|
22436
22757
|
while (offset < length) {
|
|
22437
|
-
const count =
|
|
22758
|
+
const count = readSync10(fd, bytes, offset, length - offset, start + offset);
|
|
22438
22759
|
if (count <= 0)
|
|
22439
22760
|
throw new Error("short read");
|
|
22440
22761
|
offset += count;
|
|
22441
22762
|
}
|
|
22442
22763
|
return bytes;
|
|
22443
22764
|
} finally {
|
|
22444
|
-
|
|
22765
|
+
closeSync15(fd);
|
|
22445
22766
|
}
|
|
22446
22767
|
}
|
|
22447
22768
|
function sessionDirectory(index, session) {
|
|
22448
|
-
const home =
|
|
22769
|
+
const home = dirname16(index), sessions = realPath(join34(home, "sessions"));
|
|
22449
22770
|
let listed;
|
|
22450
22771
|
for (const line of readBytes(index, INDEX_CAP2).toString("utf8").split(`
|
|
22451
22772
|
`)) {
|
|
@@ -22472,7 +22793,7 @@ function sessionDirectory(index, session) {
|
|
|
22472
22793
|
}
|
|
22473
22794
|
function taskInventory(agents) {
|
|
22474
22795
|
let active = 0;
|
|
22475
|
-
const names =
|
|
22796
|
+
const names = readdirSync7(agents, { withFileTypes: true });
|
|
22476
22797
|
if (names.length > MAX_AGENTS2)
|
|
22477
22798
|
throw new Error("too many agents");
|
|
22478
22799
|
for (const entry of names) {
|
|
@@ -22480,19 +22801,19 @@ function taskInventory(agents) {
|
|
|
22480
22801
|
continue;
|
|
22481
22802
|
if (!entry.isDirectory())
|
|
22482
22803
|
continue;
|
|
22483
|
-
const tasks =
|
|
22484
|
-
const dir =
|
|
22804
|
+
const tasks = join34(agents, entry.name, "tasks");
|
|
22805
|
+
const dir = lstatSync22(tasks, { throwIfNoEntry: false });
|
|
22485
22806
|
if (!dir)
|
|
22486
22807
|
continue;
|
|
22487
22808
|
if (!dir.isDirectory() || dir.isSymbolicLink())
|
|
22488
22809
|
throw new Error("invalid task directory");
|
|
22489
|
-
const files =
|
|
22810
|
+
const files = readdirSync7(tasks).filter((name) => name.endsWith(".json")).sort();
|
|
22490
22811
|
if (files.length > MAX_TASKS)
|
|
22491
22812
|
throw new Error("too many tasks");
|
|
22492
22813
|
for (const name of files) {
|
|
22493
22814
|
if (!TASK.test(name.slice(0, -5)))
|
|
22494
22815
|
throw new Error("invalid task name");
|
|
22495
|
-
const row = JSON.parse(readBytes(
|
|
22816
|
+
const row = JSON.parse(readBytes(join34(tasks, name), TASK_CAP).toString("utf8"));
|
|
22496
22817
|
if (!record7(row) || row.taskId !== name.slice(0, -5) || typeof row.status !== "string")
|
|
22497
22818
|
throw new Error("invalid task");
|
|
22498
22819
|
if (row.status === "running" && row.endedAt === null) {
|
|
@@ -22507,11 +22828,11 @@ function taskInventory(agents) {
|
|
|
22507
22828
|
return active;
|
|
22508
22829
|
}
|
|
22509
22830
|
function readKimiTuiTranscript(session, index) {
|
|
22510
|
-
if (!SESSION.test(session) ||
|
|
22831
|
+
if (!SESSION.test(session) || basename7(index) !== "session_index.jsonl" || !isAbsolute10(index))
|
|
22511
22832
|
return empty();
|
|
22512
22833
|
try {
|
|
22513
22834
|
const directory = sessionDirectory(index, session);
|
|
22514
|
-
const wire =
|
|
22835
|
+
const wire = join34(directory, "agents", "main", "wire.jsonl");
|
|
22515
22836
|
if (!inside3(directory, realPath(wire)))
|
|
22516
22837
|
return empty();
|
|
22517
22838
|
const bytes = readBytes(wire, WIRE_CAP, true);
|
|
@@ -22565,7 +22886,7 @@ function readKimiTuiTranscript(session, index) {
|
|
|
22565
22886
|
}
|
|
22566
22887
|
let background;
|
|
22567
22888
|
try {
|
|
22568
|
-
background = taskInventory(
|
|
22889
|
+
background = taskInventory(join34(directory, "agents"));
|
|
22569
22890
|
} catch {}
|
|
22570
22891
|
return {
|
|
22571
22892
|
factIds: [],
|
|
@@ -22822,7 +23143,7 @@ var init_builtin_metadata = __esm(() => {
|
|
|
22822
23143
|
session: { idField: "sessionId", currentId: sessionId("sessionId"), restoreOnStart: true, launchKind: "pi", launchRecord: true, ...PI_RECOVERY_SESSION, crashPlan: piCrashPlan, unrecordedTerminal: "tui", continuityBookmark: piRecoveryContinuity, continuity: { key: "pi", parse: parsePiContinuity } },
|
|
22823
23144
|
turnEnd: "adapter",
|
|
22824
23145
|
settle: { signal: "agent-settled" },
|
|
22825
|
-
budget: { account: "pi", instrumented: true, noQuotaReason: "on-prem backends have no provider quota" },
|
|
23146
|
+
budget: { account: "pi", instrumented: true, noQuotaReason: "on-prem backends have no provider quota", context: { source: "pi_usage", read: piContext } },
|
|
22826
23147
|
reporting: { tokensNotReported: true },
|
|
22827
23148
|
configuration: { schema: piConfigSchema, routingSchema: piRoutingSchema, settings: PI_SETTINGS, restartReasons: PI_RESTART_REASONS, validateEffective: piEffectiveConfig },
|
|
22828
23149
|
routing: { localAllowedRefusal: "local_allowed = false also excludes pi for this class", longContext: "backend-limit", preferredTier: true, handoffPriority: 0, trace: "backend", backendLabel: "pi" },
|
|
@@ -22954,7 +23275,7 @@ var init_native_cli_entry_qwen = __esm(() => {
|
|
|
22954
23275
|
});
|
|
22955
23276
|
|
|
22956
23277
|
// src/adapters/definitions/native-cli-preview-qwen.ts
|
|
22957
|
-
import { join as
|
|
23278
|
+
import { join as join35 } from "path";
|
|
22958
23279
|
function previewQwen(ctx) {
|
|
22959
23280
|
const { tool, args, cwd, stateDir, cliDir, config } = ctx;
|
|
22960
23281
|
const state = previewState(args, ctx.baseEnvNames), { unresolved, value } = state;
|
|
@@ -22984,7 +23305,7 @@ function previewQwen(ctx) {
|
|
|
22984
23305
|
form: "headless",
|
|
22985
23306
|
projectRoot: cwd,
|
|
22986
23307
|
stateDir,
|
|
22987
|
-
entrypoint:
|
|
23308
|
+
entrypoint: join35(cliDir, "main.js"),
|
|
22988
23309
|
userArgs: [],
|
|
22989
23310
|
unattended: false,
|
|
22990
23311
|
env: {},
|
|
@@ -23081,7 +23402,7 @@ var init_qwen = __esm(() => {
|
|
|
23081
23402
|
});
|
|
23082
23403
|
|
|
23083
23404
|
// src/adapters/configured-acp.ts
|
|
23084
|
-
import { basename as
|
|
23405
|
+
import { basename as basename8 } from "path";
|
|
23085
23406
|
import { types as types7 } from "util";
|
|
23086
23407
|
function fields(raw, at) {
|
|
23087
23408
|
if (!raw || typeof raw !== "object" || types7.isProxy(raw) || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)) || Object.getOwnPropertySymbols(raw).length)
|
|
@@ -23149,7 +23470,7 @@ function configuredAcpDefinitions(raw, builtinKinds) {
|
|
|
23149
23470
|
return fail(`${at}.identity`, "unknown identity field");
|
|
23150
23471
|
identity = { name: text4(value.name?.value, `${at}.identity.name`, 256), version: text4(value.version?.value, `${at}.identity.version`, 256) };
|
|
23151
23472
|
}
|
|
23152
|
-
const grokContract = kind === "grok" || /^grok(?:\.exe)?$/i.test(
|
|
23473
|
+
const grokContract = kind === "grok" || /^grok(?:\.exe)?$/i.test(basename8(command)) || identity?.name.toLowerCase() === "grok";
|
|
23153
23474
|
const noLeader = args.indexOf("--no-leader"), endOptions = args.indexOf("--");
|
|
23154
23475
|
if (grokContract && (noLeader < 0 || endOptions >= 0 && noLeader > endOptions || args.some((arg) => arg.startsWith("--no-leader=")))) {
|
|
23155
23476
|
return fail(`${at}.args`, "Grok requires explicit --no-leader before argv termination; valued opt-outs are unsupported");
|
|
@@ -30657,10 +30978,10 @@ var adapterNumber = (def) => ({ group: "Start", store: "config", risk: "raises",
|
|
|
30657
30978
|
var ACP_TOOL_CEILING_SETTING = adapterNumber({
|
|
30658
30979
|
key: "adapter_timing.acp_tool_ceiling_min",
|
|
30659
30980
|
path: ["adapter_timing", "acp_tool_ceiling_min"],
|
|
30660
|
-
label: "Next ACP launch: open-tool ceiling (minutes, at least the watchdog)",
|
|
30981
|
+
label: "Next ACP launch: open-tool ceiling (minutes, at least the watchdog; 60 covers a documented 50-minute gate wait)",
|
|
30661
30982
|
min: 1,
|
|
30662
|
-
max:
|
|
30663
|
-
defaultValue:
|
|
30983
|
+
max: 120,
|
|
30984
|
+
defaultValue: 60,
|
|
30664
30985
|
unit: "minutes",
|
|
30665
30986
|
inventory: "src/adapters/acp.ts:TOOL_CEILING_MS"
|
|
30666
30987
|
});
|
|
@@ -30875,7 +31196,7 @@ init_project();
|
|
|
30875
31196
|
// src/hub/instance-config.ts
|
|
30876
31197
|
init_registry();
|
|
30877
31198
|
import { readFileSync as readFileSync17 } from "fs";
|
|
30878
|
-
import { join as
|
|
31199
|
+
import { join as join38 } from "path";
|
|
30879
31200
|
|
|
30880
31201
|
// src/adapters/external-metadata.ts
|
|
30881
31202
|
import { types as types9 } from "util";
|
|
@@ -30988,8 +31309,8 @@ init_registry();
|
|
|
30988
31309
|
// src/hub/config-trust.ts
|
|
30989
31310
|
init_child_process();
|
|
30990
31311
|
init_git();
|
|
30991
|
-
import { lstatSync as
|
|
30992
|
-
import { dirname as
|
|
31312
|
+
import { lstatSync as lstatSync23, statSync as statSync7 } from "fs";
|
|
31313
|
+
import { dirname as dirname17, join as join36 } from "path";
|
|
30993
31314
|
var MACHINE_LOCAL = [
|
|
30994
31315
|
"kimi_cmd",
|
|
30995
31316
|
"permission_modes",
|
|
@@ -31018,7 +31339,7 @@ var MACHINE_LOCAL = [
|
|
|
31018
31339
|
"corpus.paths",
|
|
31019
31340
|
"invocation"
|
|
31020
31341
|
];
|
|
31021
|
-
var ALL_MACHINE_LOCAL = [...MACHINE_LOCAL, "research.runners", "rooms", "tasks.queue_backpressure", "context.max_assignment_used", "action_policy", "protect_instruction_files", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_provider_profile", "start.agents", "adapters", "adapter_modules", "text_projection", "instances"];
|
|
31342
|
+
var ALL_MACHINE_LOCAL = [...MACHINE_LOCAL, "edit_governance.arm", "roadmap.github_mirror", "roadmap.github_write", "research.runners", "rooms", "tasks.queue_backpressure", "context.max_assignment_used", "action_policy", "protect_instruction_files", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_provider_profile", "start.agents", "adapters", "adapter_modules", "text_projection", "instances"];
|
|
31022
31343
|
function configRefusal(cwd, name) {
|
|
31023
31344
|
const tracked = configTracked(cwd, name);
|
|
31024
31345
|
return tracked === undefined ? `git could not confirm that .agenthub/${name} is untracked` : tracked ? `.agenthub/${name} is committed to git` : undefined;
|
|
@@ -31029,7 +31350,7 @@ function configTracked(cwd, name) {
|
|
|
31029
31350
|
return;
|
|
31030
31351
|
let opened;
|
|
31031
31352
|
try {
|
|
31032
|
-
opened =
|
|
31353
|
+
opened = statSync7(join36(cwd, ".agenthub", name));
|
|
31033
31354
|
} catch {}
|
|
31034
31355
|
return r.stdout.split("\x00").filter(Boolean).some((row) => {
|
|
31035
31356
|
const path = row.slice(row.indexOf("\t") + 1);
|
|
@@ -31038,7 +31359,7 @@ function configTracked(cwd, name) {
|
|
|
31038
31359
|
if (!opened)
|
|
31039
31360
|
return path === `.agenthub/${name}`;
|
|
31040
31361
|
try {
|
|
31041
|
-
const s =
|
|
31362
|
+
const s = statSync7(join36(cwd, path));
|
|
31042
31363
|
return !!opened && s.dev === opened.dev && s.ino === opened.ino;
|
|
31043
31364
|
} catch {
|
|
31044
31365
|
return false;
|
|
@@ -31096,7 +31417,7 @@ function readAdapterModuleDeclarations(cwd, layers) {
|
|
|
31096
31417
|
// src/hub/control-client.ts
|
|
31097
31418
|
init_project();
|
|
31098
31419
|
import { readFileSync as readFileSync16 } from "fs";
|
|
31099
|
-
import { join as
|
|
31420
|
+
import { join as join37, resolve as resolve18 } from "path";
|
|
31100
31421
|
|
|
31101
31422
|
// src/hub/tool-request.ts
|
|
31102
31423
|
init_capabilities();
|
|
@@ -31200,8 +31521,8 @@ function controlProtocolWindow(descriptor) {
|
|
|
31200
31521
|
}
|
|
31201
31522
|
function readControl(stateDir) {
|
|
31202
31523
|
try {
|
|
31203
|
-
const status = JSON.parse(readFileSync16(
|
|
31204
|
-
const token = readFileSync16(
|
|
31524
|
+
const status = JSON.parse(readFileSync16(join37(stateDir, "status.json"), "utf8"));
|
|
31525
|
+
const token = readFileSync16(join37(stateDir, "control-token"), "utf8").trim();
|
|
31205
31526
|
if (!Number.isInteger(status.controlPort) || status.controlPort < 1 || status.controlPort > 65535 || !token)
|
|
31206
31527
|
return;
|
|
31207
31528
|
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;
|
|
@@ -31464,15 +31785,25 @@ init_db_schema();
|
|
|
31464
31785
|
init_hub_tools();
|
|
31465
31786
|
init_envelope();
|
|
31466
31787
|
|
|
31788
|
+
// src/hub/github-import.ts
|
|
31789
|
+
init_sdlc();
|
|
31790
|
+
|
|
31467
31791
|
// src/hub/tasks.ts
|
|
31468
31792
|
init_roadmap();
|
|
31469
31793
|
|
|
31470
31794
|
// src/hub/roadmap-view.ts
|
|
31471
31795
|
init_envelope();
|
|
31472
31796
|
|
|
31797
|
+
// src/hub/roadmap-sync.ts
|
|
31798
|
+
init_roadmap();
|
|
31799
|
+
|
|
31473
31800
|
// src/hub/roadmap-unplaced.ts
|
|
31474
31801
|
init_envelope();
|
|
31475
31802
|
|
|
31803
|
+
// src/hub/roadmap-decompose.ts
|
|
31804
|
+
init_board();
|
|
31805
|
+
init_roadmap();
|
|
31806
|
+
|
|
31476
31807
|
// src/hub/tasks.ts
|
|
31477
31808
|
init_src();
|
|
31478
31809
|
init_guidance_variants();
|
|
@@ -31571,6 +31902,7 @@ import { fileURLToPath } from "url";
|
|
|
31571
31902
|
var CHECKER_PATH = fileURLToPath(new URL("../../scripts/check-docs.mjs", import.meta.url));
|
|
31572
31903
|
|
|
31573
31904
|
// src/hub/tasks.ts
|
|
31905
|
+
init_cost_governance();
|
|
31574
31906
|
init_spec_read();
|
|
31575
31907
|
|
|
31576
31908
|
// src/hub/schedules.ts
|
|
@@ -31588,6 +31920,7 @@ var INTAKE_MAX_ANSWER = 64 * 1024;
|
|
|
31588
31920
|
// src/hub/tasks.ts
|
|
31589
31921
|
init_sdlc_metrics();
|
|
31590
31922
|
init_security_baseline();
|
|
31923
|
+
init_cost_governance();
|
|
31591
31924
|
init_version();
|
|
31592
31925
|
|
|
31593
31926
|
// src/hub/no-writes.ts
|
|
@@ -31595,9 +31928,7 @@ var OWNER_TOOL_EFFECTS = new Set(["hub_task_propose", "hub_task_decline", "hub_t
|
|
|
31595
31928
|
OWNER_TOOL_EFFECTS.add("hub_survey_report");
|
|
31596
31929
|
OWNER_TOOL_EFFECTS.add("hub_roadmap_edit");
|
|
31597
31930
|
OWNER_TOOL_EFFECTS.add("hub_roadmap_triage");
|
|
31598
|
-
|
|
31599
|
-
// src/hub/github-import.ts
|
|
31600
|
-
init_sdlc();
|
|
31931
|
+
OWNER_TOOL_EFFECTS.add("hub_roadmap_decompose");
|
|
31601
31932
|
|
|
31602
31933
|
// src/hub/tasks.ts
|
|
31603
31934
|
init_planning();
|
|
@@ -31613,7 +31944,9 @@ init_sdlc();
|
|
|
31613
31944
|
// src/hub/sdlc-merge.ts
|
|
31614
31945
|
init_review_findings();
|
|
31615
31946
|
init_eval_gate();
|
|
31947
|
+
init_cost_governance();
|
|
31616
31948
|
init_sdlc();
|
|
31949
|
+
var MERGE_READBACK_INTERVAL_MS = 5 * 60000;
|
|
31617
31950
|
|
|
31618
31951
|
// src/hub/sdlc-mirror.ts
|
|
31619
31952
|
init_envelope();
|
|
@@ -31651,7 +31984,7 @@ var LEARNING_DEFAULTS = { windowMs: 30 * 24 * 3600000, threshold: 3, maxGroups:
|
|
|
31651
31984
|
init_deliverables();
|
|
31652
31985
|
|
|
31653
31986
|
// src/hub/deliverable-files.ts
|
|
31654
|
-
import { constants as constants12, lstatSync as
|
|
31987
|
+
import { constants as constants12, lstatSync as lstatSync24 } from "fs";
|
|
31655
31988
|
init_tools();
|
|
31656
31989
|
init_deny();
|
|
31657
31990
|
init_permission_mode();
|
|
@@ -31714,10 +32047,13 @@ QUIET_EVENTS.add("plan observed");
|
|
|
31714
32047
|
QUIET_EVENTS.add("planner changed");
|
|
31715
32048
|
QUIET_EVENTS.add("claim verdict");
|
|
31716
32049
|
QUIET_EVENTS.add("invocation");
|
|
32050
|
+
QUIET_EVENTS.add("check run passed");
|
|
32051
|
+
QUIET_EVENTS.add("check run failed");
|
|
31717
32052
|
QUIET_EVENTS.add("wait recorded");
|
|
31718
32053
|
QUIET_EVENTS.add("shell branch bound");
|
|
31719
32054
|
var OWNERSHIP_EVENTS = new Set(["assigned", "escalated", "reassigned", "unassigned"]);
|
|
31720
32055
|
var GROOM_FYI_WINDOW_MS = 10 * 60000;
|
|
32056
|
+
var MANAGED_HANDOFF = Symbol("managed worktree handoff");
|
|
31721
32057
|
|
|
31722
32058
|
// src/hub/conductor.ts
|
|
31723
32059
|
init_tool_refusal();
|
|
@@ -31731,7 +32067,7 @@ import { types as types10 } from "util";
|
|
|
31731
32067
|
init_project();
|
|
31732
32068
|
init_registry();
|
|
31733
32069
|
init_permission_mode();
|
|
31734
|
-
import { dirname as
|
|
32070
|
+
import { dirname as dirname18, isAbsolute as isAbsolute11, sep as sep4 } from "path";
|
|
31735
32071
|
init_model_token();
|
|
31736
32072
|
init_model_token();
|
|
31737
32073
|
var JCODE_FIELDS = ["jcode_home", "provider", "model", "provider_profile"];
|
|
@@ -31966,7 +32302,7 @@ var INSTANCE_CONFIG_FILES = ["config.json", "config.local.json"];
|
|
|
31966
32302
|
function readInstanceConfigLayers(cwd) {
|
|
31967
32303
|
return INSTANCE_CONFIG_FILES.flatMap((name) => {
|
|
31968
32304
|
try {
|
|
31969
|
-
return [{ name, raw: JSON.parse(readFileSync17(
|
|
32305
|
+
return [{ name, raw: JSON.parse(readFileSync17(join38(cwd, ".agenthub", name), "utf8")) }];
|
|
31970
32306
|
} catch (error) {
|
|
31971
32307
|
if (error.code === "ENOENT")
|
|
31972
32308
|
return [];
|
|
@@ -40359,7 +40695,7 @@ class StdioServerTransport {
|
|
|
40359
40695
|
|
|
40360
40696
|
// src/adapters/claude-channel.ts
|
|
40361
40697
|
import { readFileSync as readFileSync18 } from "fs";
|
|
40362
|
-
import { join as
|
|
40698
|
+
import { join as join41 } from "path";
|
|
40363
40699
|
|
|
40364
40700
|
// src/hub/channel-project.ts
|
|
40365
40701
|
init_registry();
|
|
@@ -40367,8 +40703,8 @@ init_registry();
|
|
|
40367
40703
|
// src/hub/instance-execution.ts
|
|
40368
40704
|
init_git();
|
|
40369
40705
|
init_project();
|
|
40370
|
-
import { lstatSync as
|
|
40371
|
-
import { join as
|
|
40706
|
+
import { lstatSync as lstatSync25 } from "fs";
|
|
40707
|
+
import { join as join39, resolve as resolve20 } from "path";
|
|
40372
40708
|
var refuse = (reason) => {
|
|
40373
40709
|
throw new Error(`instance execution workspace refused: ${reason}`);
|
|
40374
40710
|
};
|
|
@@ -40410,12 +40746,12 @@ function resolveInstanceExecutionCwd(projectRoot, id, declarations, roles, adapt
|
|
|
40410
40746
|
try {
|
|
40411
40747
|
root = realPath(projectRoot);
|
|
40412
40748
|
cwd = realPath(resolve20(root, declaration.worktree));
|
|
40413
|
-
if (!
|
|
40749
|
+
if (!lstatSync25(root).isDirectory() || !lstatSync25(cwd).isDirectory())
|
|
40414
40750
|
return refuse("workspace is not a directory");
|
|
40415
40751
|
} catch {
|
|
40416
40752
|
return refuse("workspace paths are unavailable");
|
|
40417
40753
|
}
|
|
40418
|
-
const expected =
|
|
40754
|
+
const expected = join39(root, ".worktrees", id);
|
|
40419
40755
|
if (cwd !== expected)
|
|
40420
40756
|
return refuse("worktree must be the exact managed instance directory");
|
|
40421
40757
|
const inventory = git(root, ["worktree", "list", "--porcelain", "-z"]);
|
|
@@ -40444,8 +40780,8 @@ function resolveInstanceExecutionCwd(projectRoot, id, declarations, roles, adapt
|
|
|
40444
40780
|
|
|
40445
40781
|
// src/hub/channel-project.ts
|
|
40446
40782
|
init_project();
|
|
40447
|
-
import { existsSync as
|
|
40448
|
-
import { join as
|
|
40783
|
+
import { existsSync as existsSync11 } from "fs";
|
|
40784
|
+
import { join as join40 } from "path";
|
|
40449
40785
|
function channelProject(cwd, env, policyRoles) {
|
|
40450
40786
|
const override = env.AGENTHUB_STATE_DIR?.trim(), declared = env.AGENTHUB_PROJECT_DIR?.trim();
|
|
40451
40787
|
if (env.AGENTHUB_MODE === "tools" && override && declared)
|
|
@@ -40475,7 +40811,7 @@ function channelProject(cwd, env, policyRoles) {
|
|
|
40475
40811
|
const inherited = inheritedStateDir(own.root, env);
|
|
40476
40812
|
if (inherited)
|
|
40477
40813
|
return { root: own.root, stateDir: inherited, inherited: true };
|
|
40478
|
-
if (override && !
|
|
40814
|
+
if (override && !existsSync11(join40(own.root, ".agenthub", "config.json")))
|
|
40479
40815
|
return asSession();
|
|
40480
40816
|
return { root: own.root, stateDir: own.stateDir, inherited: false };
|
|
40481
40817
|
}
|
|
@@ -40611,7 +40947,7 @@ function currentClaudeChannelEvidence() {
|
|
|
40611
40947
|
var own5 = channelProject(process.cwd(), process.env, (root) => {
|
|
40612
40948
|
const read = (name) => {
|
|
40613
40949
|
try {
|
|
40614
|
-
return JSON.parse(readFileSync18(
|
|
40950
|
+
return JSON.parse(readFileSync18(join41(root, ".agenthub", name), "utf8")).roles ?? {};
|
|
40615
40951
|
} catch {
|
|
40616
40952
|
return {};
|
|
40617
40953
|
}
|
|
@@ -40637,7 +40973,7 @@ var channel = !toolsMode && channelEvidence === "development-channel-launch";
|
|
|
40637
40973
|
function roles2() {
|
|
40638
40974
|
const read = (name) => {
|
|
40639
40975
|
try {
|
|
40640
|
-
return JSON.parse(readFileSync18(
|
|
40976
|
+
return JSON.parse(readFileSync18(join41(projectRoot2, ".agenthub", name), "utf8")).roles ?? {};
|
|
40641
40977
|
} catch {
|
|
40642
40978
|
return {};
|
|
40643
40979
|
}
|
|
@@ -40656,7 +40992,7 @@ function sessionProfile() {
|
|
|
40656
40992
|
for (const name of ["config.json", "config.local.json"]) {
|
|
40657
40993
|
let data;
|
|
40658
40994
|
try {
|
|
40659
|
-
data = JSON.parse(readFileSync18(
|
|
40995
|
+
data = JSON.parse(readFileSync18(join41(projectRoot2, ".agenthub", name), "utf8"));
|
|
40660
40996
|
} catch (error) {
|
|
40661
40997
|
if (error.code === "ENOENT")
|
|
40662
40998
|
continue;
|
|
@@ -40683,7 +41019,7 @@ function sessionRoles() {
|
|
|
40683
41019
|
const read = (name) => {
|
|
40684
41020
|
let raw;
|
|
40685
41021
|
try {
|
|
40686
|
-
raw = JSON.parse(readFileSync18(
|
|
41022
|
+
raw = JSON.parse(readFileSync18(join41(projectRoot2, ".agenthub", name), "utf8")).catalog_roles;
|
|
40687
41023
|
} catch {
|
|
40688
41024
|
return {};
|
|
40689
41025
|
}
|
|
@@ -40714,14 +41050,14 @@ var HELD = `another session is attached to the hub as "${peerId}"; this one is s
|
|
|
40714
41050
|
var INBOX_CAP = 200;
|
|
40715
41051
|
function sessionSupported() {
|
|
40716
41052
|
try {
|
|
40717
|
-
return (JSON.parse(readFileSync18(
|
|
41053
|
+
return (JSON.parse(readFileSync18(join41(stateDir, "status.json"), "utf8")).features ?? []).includes("session_identity");
|
|
40718
41054
|
} catch {
|
|
40719
41055
|
return false;
|
|
40720
41056
|
}
|
|
40721
41057
|
}
|
|
40722
41058
|
function peerHeld() {
|
|
40723
41059
|
try {
|
|
40724
|
-
const status = JSON.parse(readFileSync18(
|
|
41060
|
+
const status = JSON.parse(readFileSync18(join41(stateDir, "status.json"), "utf8"));
|
|
40725
41061
|
const peer = status.peers?.[peerId];
|
|
40726
41062
|
if (channel && peer?.toolsOnly && !peer.claiming)
|
|
40727
41063
|
return false;
|