@clawos-dev/clawd 0.2.46 → 0.2.47-beta.71.63ae386
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +166 -213
- package/package.json +2 -2
- package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/SKILL.md +0 -187
- package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/archive-template.md +0 -21
- package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/article-template.md +0 -20
- package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/index-template.md +0 -18
- package/dist/persona-defaults/persona-knowledge-base/.claude/skills/karpathy-llm-wiki/references/raw-template.md +0 -7
- package/dist/persona-defaults/persona-knowledge-base/CLAUDE.md +0 -105
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/README.md +0 -119
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/SKILL.md +0 -108
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/continuation.md +0 -167
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/html-generation.md +0 -103
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/methodology.md +0 -421
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/quality-gates.md +0 -192
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/report-assembly.md +0 -130
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/reference/weasyprint_guidelines.md +0 -324
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/requirements.txt +0 -14
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/claim.schema.json +0 -49
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/evidence.schema.json +0 -43
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/run_manifest.schema.json +0 -97
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/schemas/source.schema.json +0 -49
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/citation_manager.py +0 -300
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/evidence_store.py +0 -205
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/extract_claims.py +0 -358
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/md_to_html.py +0 -330
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/research_engine.py +0 -584
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/source_evaluator.py +0 -292
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/validate_report.py +0 -354
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_citations.py +0 -426
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_claim_support.py +0 -344
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/scripts/verify_html.py +0 -220
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/templates/mckinsey_report_template.html +0 -443
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/templates/report_template.md +0 -414
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/fixtures/invalid_report.md +0 -27
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/fixtures/valid_report.md +0 -114
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_citation_manager.py +0 -195
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_evidence_store.py +0 -166
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_extract_claims.py +0 -213
- package/dist/persona-defaults/persona-researcher/.claude/skills/deep-research/tests/test_verify_claim_support.py +0 -230
- package/dist/persona-defaults/persona-researcher/CLAUDE.md +0 -30
- package/dist/persona-defaults/persona-researcher/skills-lock.json +0 -11
package/dist/cli.cjs
CHANGED
|
@@ -2026,7 +2026,7 @@ var require_thread_stream = __commonJS({
|
|
|
2026
2026
|
var { version: version2 } = require_package();
|
|
2027
2027
|
var { EventEmitter } = require("events");
|
|
2028
2028
|
var { Worker } = require("worker_threads");
|
|
2029
|
-
var { join:
|
|
2029
|
+
var { join: join3 } = require("path");
|
|
2030
2030
|
var { pathToFileURL } = require("url");
|
|
2031
2031
|
var { wait } = require_wait();
|
|
2032
2032
|
var {
|
|
@@ -2062,7 +2062,7 @@ var require_thread_stream = __commonJS({
|
|
|
2062
2062
|
function createWorker(stream, opts) {
|
|
2063
2063
|
const { filename, workerData } = opts;
|
|
2064
2064
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
2065
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
2065
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join3(__dirname, "lib", "worker.js");
|
|
2066
2066
|
const worker = new Worker(toExecute, {
|
|
2067
2067
|
...opts.workerOpts,
|
|
2068
2068
|
trackUnmanagedFds: false,
|
|
@@ -2448,7 +2448,7 @@ var require_transport = __commonJS({
|
|
|
2448
2448
|
"use strict";
|
|
2449
2449
|
var { createRequire } = require("module");
|
|
2450
2450
|
var getCallers = require_caller();
|
|
2451
|
-
var { join:
|
|
2451
|
+
var { join: join3, isAbsolute, sep } = require("path");
|
|
2452
2452
|
var sleep = require_atomic_sleep();
|
|
2453
2453
|
var onExit = require_on_exit_leak_free();
|
|
2454
2454
|
var ThreadStream = require_thread_stream();
|
|
@@ -2511,7 +2511,7 @@ var require_transport = __commonJS({
|
|
|
2511
2511
|
throw new Error("only one of target or targets can be specified");
|
|
2512
2512
|
}
|
|
2513
2513
|
if (targets) {
|
|
2514
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2514
|
+
target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
|
|
2515
2515
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
2516
2516
|
return {
|
|
2517
2517
|
...dest,
|
|
@@ -2529,7 +2529,7 @@ var require_transport = __commonJS({
|
|
|
2529
2529
|
});
|
|
2530
2530
|
});
|
|
2531
2531
|
} else if (pipeline2) {
|
|
2532
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
2532
|
+
target = bundlerOverrides["pino-worker"] || join3(__dirname, "worker.js");
|
|
2533
2533
|
options.pipelines = [pipeline2.map((dest) => {
|
|
2534
2534
|
return {
|
|
2535
2535
|
...dest,
|
|
@@ -2551,7 +2551,7 @@ var require_transport = __commonJS({
|
|
|
2551
2551
|
return origin;
|
|
2552
2552
|
}
|
|
2553
2553
|
if (origin === "pino/file") {
|
|
2554
|
-
return
|
|
2554
|
+
return join3(__dirname, "..", "file.js");
|
|
2555
2555
|
}
|
|
2556
2556
|
let fixTarget2;
|
|
2557
2557
|
for (const filePath of callers) {
|
|
@@ -3541,7 +3541,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3541
3541
|
return circularValue;
|
|
3542
3542
|
}
|
|
3543
3543
|
let res = "";
|
|
3544
|
-
let
|
|
3544
|
+
let join3 = ",";
|
|
3545
3545
|
const originalIndentation = indentation;
|
|
3546
3546
|
if (Array.isArray(value)) {
|
|
3547
3547
|
if (value.length === 0) {
|
|
@@ -3555,7 +3555,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
3555
3555
|
indentation += spacer;
|
|
3556
3556
|
res += `
|
|
3557
3557
|
${indentation}`;
|
|
3558
|
-
|
|
3558
|
+
join3 = `,
|
|
3559
3559
|
${indentation}`;
|
|
3560
3560
|
}
|
|
3561
3561
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3563,13 +3563,13 @@ ${indentation}`;
|
|
|
3563
3563
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3564
3564
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3565
3565
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3566
|
-
res +=
|
|
3566
|
+
res += join3;
|
|
3567
3567
|
}
|
|
3568
3568
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
3569
3569
|
res += tmp !== void 0 ? tmp : "null";
|
|
3570
3570
|
if (value.length - 1 > maximumBreadth) {
|
|
3571
3571
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3572
|
-
res += `${
|
|
3572
|
+
res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3573
3573
|
}
|
|
3574
3574
|
if (spacer !== "") {
|
|
3575
3575
|
res += `
|
|
@@ -3590,7 +3590,7 @@ ${originalIndentation}`;
|
|
|
3590
3590
|
let separator = "";
|
|
3591
3591
|
if (spacer !== "") {
|
|
3592
3592
|
indentation += spacer;
|
|
3593
|
-
|
|
3593
|
+
join3 = `,
|
|
3594
3594
|
${indentation}`;
|
|
3595
3595
|
whitespace = " ";
|
|
3596
3596
|
}
|
|
@@ -3604,13 +3604,13 @@ ${indentation}`;
|
|
|
3604
3604
|
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
3605
3605
|
if (tmp !== void 0) {
|
|
3606
3606
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
3607
|
-
separator =
|
|
3607
|
+
separator = join3;
|
|
3608
3608
|
}
|
|
3609
3609
|
}
|
|
3610
3610
|
if (keyLength > maximumBreadth) {
|
|
3611
3611
|
const removedKeys = keyLength - maximumBreadth;
|
|
3612
3612
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
3613
|
-
separator =
|
|
3613
|
+
separator = join3;
|
|
3614
3614
|
}
|
|
3615
3615
|
if (spacer !== "" && separator.length > 1) {
|
|
3616
3616
|
res = `
|
|
@@ -3651,7 +3651,7 @@ ${originalIndentation}`;
|
|
|
3651
3651
|
}
|
|
3652
3652
|
const originalIndentation = indentation;
|
|
3653
3653
|
let res = "";
|
|
3654
|
-
let
|
|
3654
|
+
let join3 = ",";
|
|
3655
3655
|
if (Array.isArray(value)) {
|
|
3656
3656
|
if (value.length === 0) {
|
|
3657
3657
|
return "[]";
|
|
@@ -3664,7 +3664,7 @@ ${originalIndentation}`;
|
|
|
3664
3664
|
indentation += spacer;
|
|
3665
3665
|
res += `
|
|
3666
3666
|
${indentation}`;
|
|
3667
|
-
|
|
3667
|
+
join3 = `,
|
|
3668
3668
|
${indentation}`;
|
|
3669
3669
|
}
|
|
3670
3670
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -3672,13 +3672,13 @@ ${indentation}`;
|
|
|
3672
3672
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3673
3673
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3674
3674
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
3675
|
-
res +=
|
|
3675
|
+
res += join3;
|
|
3676
3676
|
}
|
|
3677
3677
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
3678
3678
|
res += tmp !== void 0 ? tmp : "null";
|
|
3679
3679
|
if (value.length - 1 > maximumBreadth) {
|
|
3680
3680
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3681
|
-
res += `${
|
|
3681
|
+
res += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3682
3682
|
}
|
|
3683
3683
|
if (spacer !== "") {
|
|
3684
3684
|
res += `
|
|
@@ -3691,7 +3691,7 @@ ${originalIndentation}`;
|
|
|
3691
3691
|
let whitespace = "";
|
|
3692
3692
|
if (spacer !== "") {
|
|
3693
3693
|
indentation += spacer;
|
|
3694
|
-
|
|
3694
|
+
join3 = `,
|
|
3695
3695
|
${indentation}`;
|
|
3696
3696
|
whitespace = " ";
|
|
3697
3697
|
}
|
|
@@ -3700,7 +3700,7 @@ ${indentation}`;
|
|
|
3700
3700
|
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
3701
3701
|
if (tmp !== void 0) {
|
|
3702
3702
|
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
3703
|
-
separator =
|
|
3703
|
+
separator = join3;
|
|
3704
3704
|
}
|
|
3705
3705
|
}
|
|
3706
3706
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -3758,20 +3758,20 @@ ${originalIndentation}`;
|
|
|
3758
3758
|
indentation += spacer;
|
|
3759
3759
|
let res2 = `
|
|
3760
3760
|
${indentation}`;
|
|
3761
|
-
const
|
|
3761
|
+
const join4 = `,
|
|
3762
3762
|
${indentation}`;
|
|
3763
3763
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
3764
3764
|
let i = 0;
|
|
3765
3765
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
3766
3766
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3767
3767
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
3768
|
-
res2 +=
|
|
3768
|
+
res2 += join4;
|
|
3769
3769
|
}
|
|
3770
3770
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
3771
3771
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
3772
3772
|
if (value.length - 1 > maximumBreadth) {
|
|
3773
3773
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
3774
|
-
res2 += `${
|
|
3774
|
+
res2 += `${join4}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
3775
3775
|
}
|
|
3776
3776
|
res2 += `
|
|
3777
3777
|
${originalIndentation}`;
|
|
@@ -3787,16 +3787,16 @@ ${originalIndentation}`;
|
|
|
3787
3787
|
return '"[Object]"';
|
|
3788
3788
|
}
|
|
3789
3789
|
indentation += spacer;
|
|
3790
|
-
const
|
|
3790
|
+
const join3 = `,
|
|
3791
3791
|
${indentation}`;
|
|
3792
3792
|
let res = "";
|
|
3793
3793
|
let separator = "";
|
|
3794
3794
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
3795
3795
|
if (isTypedArrayWithEntries(value)) {
|
|
3796
|
-
res += stringifyTypedArray(value,
|
|
3796
|
+
res += stringifyTypedArray(value, join3, maximumBreadth);
|
|
3797
3797
|
keys = keys.slice(value.length);
|
|
3798
3798
|
maximumPropertiesToStringify -= value.length;
|
|
3799
|
-
separator =
|
|
3799
|
+
separator = join3;
|
|
3800
3800
|
}
|
|
3801
3801
|
if (deterministic) {
|
|
3802
3802
|
keys = sort(keys, comparator);
|
|
@@ -3807,13 +3807,13 @@ ${indentation}`;
|
|
|
3807
3807
|
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
3808
3808
|
if (tmp !== void 0) {
|
|
3809
3809
|
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
3810
|
-
separator =
|
|
3810
|
+
separator = join3;
|
|
3811
3811
|
}
|
|
3812
3812
|
}
|
|
3813
3813
|
if (keyLength > maximumBreadth) {
|
|
3814
3814
|
const removedKeys = keyLength - maximumBreadth;
|
|
3815
3815
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
3816
|
-
separator =
|
|
3816
|
+
separator = join3;
|
|
3817
3817
|
}
|
|
3818
3818
|
if (separator !== "") {
|
|
3819
3819
|
res = `
|
|
@@ -4133,7 +4133,7 @@ var require_multistream = __commonJS({
|
|
|
4133
4133
|
var require_pino = __commonJS({
|
|
4134
4134
|
"../node_modules/.pnpm/pino@9.14.0/node_modules/pino/pino.js"(exports2, module2) {
|
|
4135
4135
|
"use strict";
|
|
4136
|
-
var
|
|
4136
|
+
var os15 = require("os");
|
|
4137
4137
|
var stdSerializers = require_pino_std_serializers();
|
|
4138
4138
|
var caller = require_caller();
|
|
4139
4139
|
var redaction = require_redaction();
|
|
@@ -4180,7 +4180,7 @@ var require_pino = __commonJS({
|
|
|
4180
4180
|
} = symbols;
|
|
4181
4181
|
var { epochTime, nullTime } = time;
|
|
4182
4182
|
var { pid } = process;
|
|
4183
|
-
var hostname =
|
|
4183
|
+
var hostname = os15.hostname();
|
|
4184
4184
|
var defaultErrorSerializer = stdSerializers.err;
|
|
4185
4185
|
var defaultOptions = {
|
|
4186
4186
|
level: "info",
|
|
@@ -9895,7 +9895,7 @@ var init_lib = __esm({
|
|
|
9895
9895
|
tokenize: function tokenize(value) {
|
|
9896
9896
|
return Array.from(value);
|
|
9897
9897
|
},
|
|
9898
|
-
join: function
|
|
9898
|
+
join: function join2(chars) {
|
|
9899
9899
|
return chars.join("");
|
|
9900
9900
|
},
|
|
9901
9901
|
postProcess: function postProcess(changeObjects) {
|
|
@@ -10796,6 +10796,7 @@ function buildSpawnArgs(ctx) {
|
|
|
10796
10796
|
}
|
|
10797
10797
|
}
|
|
10798
10798
|
if (ctx.extraSettings) args.push("--settings", ctx.extraSettings);
|
|
10799
|
+
if (ctx.extraSystemPrompt) args.push("--append-system-prompt", ctx.extraSystemPrompt);
|
|
10799
10800
|
if (ctx.effort) args.push("--effort", ctx.effort);
|
|
10800
10801
|
if (ctx.toolSessionId) args.push("--resume", ctx.toolSessionId);
|
|
10801
10802
|
return args;
|
|
@@ -14944,22 +14945,22 @@ var require_websocket_server = __commonJS({
|
|
|
14944
14945
|
// src/run-case/recorder.ts
|
|
14945
14946
|
function startRunCaseRecorder(opts) {
|
|
14946
14947
|
const now = opts.now ?? Date.now;
|
|
14947
|
-
const dir =
|
|
14948
|
+
const dir = import_node_path21.default.dirname(opts.recordPath);
|
|
14948
14949
|
let stream = null;
|
|
14949
14950
|
let closing = false;
|
|
14950
14951
|
let closedSettled = false;
|
|
14951
14952
|
let closedResolve;
|
|
14952
|
-
const closed = new Promise((
|
|
14953
|
+
const closed = new Promise((resolve) => {
|
|
14953
14954
|
closedResolve = () => {
|
|
14954
14955
|
if (closedSettled) return;
|
|
14955
14956
|
closedSettled = true;
|
|
14956
|
-
|
|
14957
|
+
resolve();
|
|
14957
14958
|
};
|
|
14958
14959
|
});
|
|
14959
14960
|
const ensureStream = () => {
|
|
14960
14961
|
if (stream) return stream;
|
|
14961
|
-
|
|
14962
|
-
stream =
|
|
14962
|
+
import_node_fs21.default.mkdirSync(dir, { recursive: true });
|
|
14963
|
+
stream = import_node_fs21.default.createWriteStream(opts.recordPath, { flags: "a" });
|
|
14963
14964
|
stream.on("close", () => closedResolve());
|
|
14964
14965
|
return stream;
|
|
14965
14966
|
};
|
|
@@ -14984,12 +14985,12 @@ function startRunCaseRecorder(opts) {
|
|
|
14984
14985
|
};
|
|
14985
14986
|
return { tap, close, closed };
|
|
14986
14987
|
}
|
|
14987
|
-
var
|
|
14988
|
+
var import_node_fs21, import_node_path21;
|
|
14988
14989
|
var init_recorder = __esm({
|
|
14989
14990
|
"src/run-case/recorder.ts"() {
|
|
14990
14991
|
"use strict";
|
|
14991
|
-
|
|
14992
|
-
|
|
14992
|
+
import_node_fs21 = __toESM(require("fs"), 1);
|
|
14993
|
+
import_node_path21 = __toESM(require("path"), 1);
|
|
14993
14994
|
}
|
|
14994
14995
|
});
|
|
14995
14996
|
|
|
@@ -15032,7 +15033,7 @@ var init_wire = __esm({
|
|
|
15032
15033
|
// src/run-case/controller.ts
|
|
15033
15034
|
async function runController(opts) {
|
|
15034
15035
|
const now = opts.now ?? Date.now;
|
|
15035
|
-
const cwd = opts.cwd ?? (0,
|
|
15036
|
+
const cwd = opts.cwd ?? (0, import_node_fs22.mkdtempSync)(import_node_path22.default.join(import_node_os14.default.tmpdir(), "clawd-runcase-"));
|
|
15036
15037
|
const ownsCwd = opts.cwd === void 0;
|
|
15037
15038
|
const recorder = startRunCaseRecorder({ recordPath: opts.record, now });
|
|
15038
15039
|
const spawnCtx = { cwd };
|
|
@@ -15045,8 +15046,8 @@ async function runController(opts) {
|
|
|
15045
15046
|
let exitCode = null;
|
|
15046
15047
|
let procExited = false;
|
|
15047
15048
|
let resolveProcExit;
|
|
15048
|
-
const procExitPromise = new Promise((
|
|
15049
|
-
resolveProcExit =
|
|
15049
|
+
const procExitPromise = new Promise((resolve) => {
|
|
15050
|
+
resolveProcExit = resolve;
|
|
15050
15051
|
});
|
|
15051
15052
|
const writeEvent = (event) => {
|
|
15052
15053
|
try {
|
|
@@ -15193,19 +15194,19 @@ async function runController(opts) {
|
|
|
15193
15194
|
if (sigintHandler) process.off("SIGINT", sigintHandler);
|
|
15194
15195
|
if (ownsCwd) {
|
|
15195
15196
|
try {
|
|
15196
|
-
(0,
|
|
15197
|
+
(0, import_node_fs22.rmSync)(cwd, { recursive: true, force: true });
|
|
15197
15198
|
} catch {
|
|
15198
15199
|
}
|
|
15199
15200
|
}
|
|
15200
15201
|
return exitCode ?? 0;
|
|
15201
15202
|
}
|
|
15202
|
-
var
|
|
15203
|
+
var import_node_fs22, import_node_os14, import_node_path22;
|
|
15203
15204
|
var init_controller = __esm({
|
|
15204
15205
|
"src/run-case/controller.ts"() {
|
|
15205
15206
|
"use strict";
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15207
|
+
import_node_fs22 = require("fs");
|
|
15208
|
+
import_node_os14 = __toESM(require("os"), 1);
|
|
15209
|
+
import_node_path22 = __toESM(require("path"), 1);
|
|
15209
15210
|
init_claude();
|
|
15210
15211
|
init_stdout_splitter();
|
|
15211
15212
|
init_permission_stdio();
|
|
@@ -15430,8 +15431,8 @@ Env (advanced):
|
|
|
15430
15431
|
`;
|
|
15431
15432
|
|
|
15432
15433
|
// src/index.ts
|
|
15433
|
-
var
|
|
15434
|
-
var
|
|
15434
|
+
var import_node_path20 = __toESM(require("path"), 1);
|
|
15435
|
+
var import_node_fs20 = __toESM(require("fs"), 1);
|
|
15435
15436
|
|
|
15436
15437
|
// src/logger.ts
|
|
15437
15438
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
@@ -15648,6 +15649,20 @@ function buildRule(tool, input) {
|
|
|
15648
15649
|
|
|
15649
15650
|
// src/session/reducer.ts
|
|
15650
15651
|
init_permission_stdio();
|
|
15652
|
+
|
|
15653
|
+
// src/persona/connection-prompt.ts
|
|
15654
|
+
var OWNER_TEMPLATE = `# \u8FDE\u63A5\u4E0A\u4E0B\u6587
|
|
15655
|
+
\u4F60\u73B0\u5728\u4EE5 Owner \u8EAB\u4EFD\u88AB\u8FDE\u63A5\uFF0C\u5BF9\u65B9\u5C31\u662F owner \u672C\u4EBA\uFF08{ownerLabel}\uFF09\u3002
|
|
15656
|
+
\u81EA\u6211\u4ECB\u7ECD\u65F6\u4F7F\u7528\u7B2C\u4E00/\u7B2C\u4E8C\u4EBA\u79F0\uFF0C\u4F8B\u5982\u300C\u6211\u662F\u60A8\u7684 xxx \u52A9\u624B\u300D\u3002`;
|
|
15657
|
+
var LISTENER_TEMPLATE = `# \u8FDE\u63A5\u4E0A\u4E0B\u6587
|
|
15658
|
+
\u4F60\u73B0\u5728\u4EE5 Listener \u8EAB\u4EFD\u88AB\u8FDE\u63A5\uFF0C\u672C persona \u7684 owner \u662F\u300C{ownerLabel}\u300D\uFF0C\u4F46\u5F53\u524D\u5BF9\u8BDD\u7684\u5BF9\u65B9\u4E0D\u662F owner \u672C\u4EBA\u3002
|
|
15659
|
+
\u81EA\u6211\u4ECB\u7ECD\u65F6\u4F7F\u7528\u7B2C\u4E09\u4EBA\u79F0\u6307\u4EE3 owner\uFF0C\u4F8B\u5982\u300C\u6211\u662F {ownerLabel} \u7684 xxx \u52A9\u624B\uFF0C\u4F60\u53EF\u4EE5\u901A\u8FC7\u6211\u770B\u5230\u4ED6\u7684 xxx\u300D\u3002\u4E0D\u8981\u628A\u5BF9\u65B9\u5F53\u6210 owner\uFF0C\u4E0D\u8981\u66FF owner \u505A\u51FA\u627F\u8BFA\u3002`;
|
|
15660
|
+
function buildConnectionPrompt(args) {
|
|
15661
|
+
const template = args.mode === "owner" ? OWNER_TEMPLATE : LISTENER_TEMPLATE;
|
|
15662
|
+
return template.replace(/\{ownerLabel\}/g, args.ownerLabel);
|
|
15663
|
+
}
|
|
15664
|
+
|
|
15665
|
+
// src/session/reducer.ts
|
|
15651
15666
|
function cloneState(s) {
|
|
15652
15667
|
return {
|
|
15653
15668
|
file: s.file,
|
|
@@ -15697,7 +15712,7 @@ function emitSessionEvent(sessionId, event, target) {
|
|
|
15697
15712
|
};
|
|
15698
15713
|
return target ? { kind: "emit-frame", frame, target } : { kind: "emit-frame", frame };
|
|
15699
15714
|
}
|
|
15700
|
-
function buildSpawnContext(state) {
|
|
15715
|
+
function buildSpawnContext(state, deps) {
|
|
15701
15716
|
const file = state.file;
|
|
15702
15717
|
const ctx = {
|
|
15703
15718
|
cwd: file.cwd,
|
|
@@ -15709,6 +15724,10 @@ function buildSpawnContext(state) {
|
|
|
15709
15724
|
const meta = state.subSessionMeta;
|
|
15710
15725
|
if (meta?.personaMode) {
|
|
15711
15726
|
ctx.personaMode = meta.personaMode;
|
|
15727
|
+
ctx.extraSystemPrompt = buildConnectionPrompt({
|
|
15728
|
+
mode: meta.personaMode,
|
|
15729
|
+
ownerLabel: deps.ownerDisplayName
|
|
15730
|
+
});
|
|
15712
15731
|
}
|
|
15713
15732
|
if (meta?.extraSettings) {
|
|
15714
15733
|
ctx.extraSettings = meta.extraSettings;
|
|
@@ -15897,7 +15916,7 @@ function applyCommand(state, command, deps) {
|
|
|
15897
15916
|
next.nextSeq = 0;
|
|
15898
15917
|
next.turnOpen = false;
|
|
15899
15918
|
next.status = "running";
|
|
15900
|
-
effects.push({ kind: "spawn", ctx: buildSpawnContext(next) });
|
|
15919
|
+
effects.push({ kind: "spawn", ctx: buildSpawnContext(next, deps) });
|
|
15901
15920
|
effects.push({
|
|
15902
15921
|
kind: "emit-frame",
|
|
15903
15922
|
frame: {
|
|
@@ -15949,7 +15968,7 @@ function applyCommand(state, command, deps) {
|
|
|
15949
15968
|
next.nextSeq = 0;
|
|
15950
15969
|
next.turnOpen = false;
|
|
15951
15970
|
next.status = "running";
|
|
15952
|
-
effects.push({ kind: "spawn", ctx: buildSpawnContext(next) });
|
|
15971
|
+
effects.push({ kind: "spawn", ctx: buildSpawnContext(next, deps) });
|
|
15953
15972
|
effects.push({
|
|
15954
15973
|
kind: "emit-frame",
|
|
15955
15974
|
frame: { type: "session:status", sessionId, status: "running" }
|
|
@@ -16286,8 +16305,8 @@ function startRecorder(opts) {
|
|
|
16286
16305
|
const filePath = import_node_path4.default.join(dir, `${tsForFilename(now())}.jsonl`);
|
|
16287
16306
|
let stream = null;
|
|
16288
16307
|
let closedResolve;
|
|
16289
|
-
const closed = new Promise((
|
|
16290
|
-
closedResolve =
|
|
16308
|
+
const closed = new Promise((resolve) => {
|
|
16309
|
+
closedResolve = resolve;
|
|
16291
16310
|
});
|
|
16292
16311
|
let exited = false;
|
|
16293
16312
|
const ensureStream = () => {
|
|
@@ -16411,7 +16430,8 @@ var SessionRunner = class {
|
|
|
16411
16430
|
bufferCap: this.hooks.bufferCap ?? 500,
|
|
16412
16431
|
now: this.hooks.now ?? Date.now,
|
|
16413
16432
|
resolveContextWindow: this.hooks.resolveContextWindow,
|
|
16414
|
-
genUuid: this.hooks.genUuid ?? v4_default
|
|
16433
|
+
genUuid: this.hooks.genUuid ?? v4_default,
|
|
16434
|
+
ownerDisplayName: this.hooks.ownerDisplayName
|
|
16415
16435
|
};
|
|
16416
16436
|
const { state, effects } = reduceSession(this.state, inputMsg, deps);
|
|
16417
16437
|
this.state = state;
|
|
@@ -16427,13 +16447,13 @@ var SessionRunner = class {
|
|
|
16427
16447
|
// 已经停止则立即 resolve;超时(默认 3000ms)抛错由上层透传成 RPC error
|
|
16428
16448
|
async waitUntilStopped(timeoutMs = DEFAULT_WAIT_STOP_TIMEOUT_MS) {
|
|
16429
16449
|
if (!this.state.procAlive) return;
|
|
16430
|
-
return new Promise((
|
|
16450
|
+
return new Promise((resolve, reject) => {
|
|
16431
16451
|
let settled = false;
|
|
16432
16452
|
const onStop = () => {
|
|
16433
16453
|
if (settled) return;
|
|
16434
16454
|
settled = true;
|
|
16435
16455
|
clearTimeout(timer);
|
|
16436
|
-
|
|
16456
|
+
resolve();
|
|
16437
16457
|
};
|
|
16438
16458
|
const timer = setTimeout(() => {
|
|
16439
16459
|
if (settled) return;
|
|
@@ -16478,7 +16498,7 @@ var SessionRunner = class {
|
|
|
16478
16498
|
};
|
|
16479
16499
|
const payload = JSON.stringify(frame) + "\n";
|
|
16480
16500
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CONTROL_REQUEST_TIMEOUT_MS;
|
|
16481
|
-
return new Promise((
|
|
16501
|
+
return new Promise((resolve, reject) => {
|
|
16482
16502
|
const timer = setTimeout(() => {
|
|
16483
16503
|
const pending = this.pendingControlRequests.get(requestId);
|
|
16484
16504
|
if (!pending) return;
|
|
@@ -16486,7 +16506,7 @@ var SessionRunner = class {
|
|
|
16486
16506
|
reject(new Error(`control_request timeout: ${subtype}`));
|
|
16487
16507
|
}, timeoutMs);
|
|
16488
16508
|
timer.unref?.();
|
|
16489
|
-
this.pendingControlRequests.set(requestId, { resolve
|
|
16509
|
+
this.pendingControlRequests.set(requestId, { resolve, reject, timer });
|
|
16490
16510
|
try {
|
|
16491
16511
|
proc.stdin?.write(payload);
|
|
16492
16512
|
this.recorder?.tapStdinWrite(payload);
|
|
@@ -16807,7 +16827,8 @@ var SessionManager = class {
|
|
|
16807
16827
|
// adapter 自己持有模型表 + 兜底逻辑(contains / opus-1M / [1m] 等),manager 不再 cache 转发
|
|
16808
16828
|
resolveContextWindow: (tool, modelId) => this.deps.getAdapter(tool).resolveContextWindow(modelId),
|
|
16809
16829
|
dataDir: this.deps.dataDir,
|
|
16810
|
-
personaStore: this.deps.personaStore
|
|
16830
|
+
personaStore: this.deps.personaStore,
|
|
16831
|
+
ownerDisplayName: this.deps.ownerDisplayName
|
|
16811
16832
|
});
|
|
16812
16833
|
return runner;
|
|
16813
16834
|
}
|
|
@@ -17898,102 +17919,6 @@ var PersonaManager = class {
|
|
|
17898
17919
|
}
|
|
17899
17920
|
};
|
|
17900
17921
|
|
|
17901
|
-
// src/persona/seed.ts
|
|
17902
|
-
var fs7 = __toESM(require("fs"), 1);
|
|
17903
|
-
var path7 = __toESM(require("path"), 1);
|
|
17904
|
-
var import_node_url = require("url");
|
|
17905
|
-
var import_meta = {};
|
|
17906
|
-
var DEFAULT_PERSONAS = [
|
|
17907
|
-
{
|
|
17908
|
-
personaId: "persona-researcher",
|
|
17909
|
-
label: "\u8C03\u7814\u5458",
|
|
17910
|
-
model: "opus",
|
|
17911
|
-
iconKey: "research",
|
|
17912
|
-
public: false
|
|
17913
|
-
},
|
|
17914
|
-
{
|
|
17915
|
-
personaId: "persona-knowledge-base",
|
|
17916
|
-
label: "\u77E5\u8BC6\u5E93\u7BA1\u7406\u5458",
|
|
17917
|
-
model: "opus",
|
|
17918
|
-
iconKey: "reading",
|
|
17919
|
-
public: false
|
|
17920
|
-
}
|
|
17921
|
-
];
|
|
17922
|
-
function findDefaultsRoot() {
|
|
17923
|
-
const candidates = [];
|
|
17924
|
-
try {
|
|
17925
|
-
const here = path7.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
17926
|
-
candidates.push(path7.resolve(here, "defaults"));
|
|
17927
|
-
candidates.push(path7.resolve(here, "persona-defaults"));
|
|
17928
|
-
} catch {
|
|
17929
|
-
}
|
|
17930
|
-
if (process.argv[1]) {
|
|
17931
|
-
const argvDir = path7.dirname(process.argv[1]);
|
|
17932
|
-
candidates.push(path7.resolve(argvDir, "persona-defaults"));
|
|
17933
|
-
}
|
|
17934
|
-
for (const c of candidates) {
|
|
17935
|
-
try {
|
|
17936
|
-
if (fs7.statSync(c).isDirectory()) return c;
|
|
17937
|
-
} catch {
|
|
17938
|
-
}
|
|
17939
|
-
}
|
|
17940
|
-
return null;
|
|
17941
|
-
}
|
|
17942
|
-
function seedDefaultPersonas(args) {
|
|
17943
|
-
const entries = args.entries ?? DEFAULT_PERSONAS;
|
|
17944
|
-
for (const entry of entries) {
|
|
17945
|
-
if (args.store.has(entry.personaId)) {
|
|
17946
|
-
args.logger.info("persona.seed.skip", { personaId: entry.personaId, reason: "exists" });
|
|
17947
|
-
continue;
|
|
17948
|
-
}
|
|
17949
|
-
const bundleDir = path7.join(args.defaultsRoot, entry.personaId);
|
|
17950
|
-
if (!fs7.existsSync(bundleDir)) {
|
|
17951
|
-
args.logger.warn("persona.seed.skip", {
|
|
17952
|
-
personaId: entry.personaId,
|
|
17953
|
-
reason: "bundle-missing",
|
|
17954
|
-
bundleDir
|
|
17955
|
-
});
|
|
17956
|
-
continue;
|
|
17957
|
-
}
|
|
17958
|
-
const claudeMdPath = path7.join(bundleDir, "CLAUDE.md");
|
|
17959
|
-
if (!fs7.existsSync(claudeMdPath)) {
|
|
17960
|
-
args.logger.warn("persona.seed.skip", {
|
|
17961
|
-
personaId: entry.personaId,
|
|
17962
|
-
reason: "no-CLAUDE.md",
|
|
17963
|
-
bundleDir
|
|
17964
|
-
});
|
|
17965
|
-
continue;
|
|
17966
|
-
}
|
|
17967
|
-
const personality = fs7.readFileSync(claudeMdPath, "utf8");
|
|
17968
|
-
const now = Date.now();
|
|
17969
|
-
const persona = {
|
|
17970
|
-
personaId: entry.personaId,
|
|
17971
|
-
label: entry.label,
|
|
17972
|
-
model: entry.model,
|
|
17973
|
-
public: entry.public,
|
|
17974
|
-
iconKey: entry.iconKey,
|
|
17975
|
-
tokenMap: {},
|
|
17976
|
-
createdAt: now,
|
|
17977
|
-
updatedAt: now
|
|
17978
|
-
};
|
|
17979
|
-
args.store.write(persona, personality);
|
|
17980
|
-
copyBundleExtras(bundleDir, args.store.personaDirPath(entry.personaId));
|
|
17981
|
-
args.logger.info("persona.seed.created", { personaId: entry.personaId });
|
|
17982
|
-
}
|
|
17983
|
-
}
|
|
17984
|
-
function copyBundleExtras(srcDir, dstDir) {
|
|
17985
|
-
for (const entry of fs7.readdirSync(srcDir, { withFileTypes: true })) {
|
|
17986
|
-
if (entry.name === "CLAUDE.md" || entry.name === ".clawd") continue;
|
|
17987
|
-
const srcPath = path7.join(srcDir, entry.name);
|
|
17988
|
-
const dstPath = path7.join(dstDir, entry.name);
|
|
17989
|
-
if (entry.isDirectory()) {
|
|
17990
|
-
fs7.cpSync(srcPath, dstPath, { recursive: true, dereference: true });
|
|
17991
|
-
} else if (entry.isFile()) {
|
|
17992
|
-
fs7.copyFileSync(srcPath, dstPath);
|
|
17993
|
-
}
|
|
17994
|
-
}
|
|
17995
|
-
}
|
|
17996
|
-
|
|
17997
17922
|
// src/index.ts
|
|
17998
17923
|
init_claude();
|
|
17999
17924
|
init_claude_history();
|
|
@@ -18755,7 +18680,7 @@ var LocalWsServer = class {
|
|
|
18755
18680
|
pingIntervalMs;
|
|
18756
18681
|
async start() {
|
|
18757
18682
|
const host = this.opts.host ?? "127.0.0.1";
|
|
18758
|
-
await new Promise((
|
|
18683
|
+
await new Promise((resolve, reject) => {
|
|
18759
18684
|
const wss = new import_websocket_server.default({
|
|
18760
18685
|
host,
|
|
18761
18686
|
port: this.opts.port,
|
|
@@ -18763,7 +18688,7 @@ var LocalWsServer = class {
|
|
|
18763
18688
|
});
|
|
18764
18689
|
wss.on("listening", () => {
|
|
18765
18690
|
this.logger?.info("ws listening", { host, port: this.opts.port });
|
|
18766
|
-
|
|
18691
|
+
resolve();
|
|
18767
18692
|
});
|
|
18768
18693
|
wss.on("error", (err) => {
|
|
18769
18694
|
this.logger?.error("ws server error", { err: err.message });
|
|
@@ -18783,8 +18708,8 @@ var LocalWsServer = class {
|
|
|
18783
18708
|
if (c.pingTimer) clearInterval(c.pingTimer);
|
|
18784
18709
|
}
|
|
18785
18710
|
this.clients.clear();
|
|
18786
|
-
await new Promise((
|
|
18787
|
-
this.wss?.close(() =>
|
|
18711
|
+
await new Promise((resolve) => {
|
|
18712
|
+
this.wss?.close(() => resolve());
|
|
18788
18713
|
});
|
|
18789
18714
|
this.wss = null;
|
|
18790
18715
|
}
|
|
@@ -19591,10 +19516,10 @@ async function extractFrpcFromTarball(tarball, binDir, version2, platform, destB
|
|
|
19591
19516
|
const work = import_node_path14.default.join(binDir, `extract-${process.pid}-${Date.now()}`);
|
|
19592
19517
|
import_node_fs14.default.mkdirSync(work, { recursive: true });
|
|
19593
19518
|
try {
|
|
19594
|
-
await new Promise((
|
|
19519
|
+
await new Promise((resolve, reject) => {
|
|
19595
19520
|
const proc = (0, import_node_child_process3.spawn)("tar", ["xzf", tarball, "-C", work], { stdio: "pipe" });
|
|
19596
19521
|
proc.on("error", reject);
|
|
19597
|
-
proc.on("exit", (code) => code === 0 ?
|
|
19522
|
+
proc.on("exit", (code) => code === 0 ? resolve() : reject(new Error(`tar exited ${code}`)));
|
|
19598
19523
|
});
|
|
19599
19524
|
const dirName = `frp_${version2}_${platform.os}_${platform.arch}`;
|
|
19600
19525
|
const src = import_node_path14.default.join(work, dirName, "frpc");
|
|
@@ -19672,17 +19597,17 @@ var TunnelManager = class {
|
|
|
19672
19597
|
this.proc = null;
|
|
19673
19598
|
if (!proc) return;
|
|
19674
19599
|
proc.kill("SIGTERM");
|
|
19675
|
-
await new Promise((
|
|
19600
|
+
await new Promise((resolve) => {
|
|
19676
19601
|
const t = setTimeout(() => {
|
|
19677
19602
|
try {
|
|
19678
19603
|
proc.kill("SIGKILL");
|
|
19679
19604
|
} catch {
|
|
19680
19605
|
}
|
|
19681
|
-
|
|
19606
|
+
resolve();
|
|
19682
19607
|
}, 5e3);
|
|
19683
19608
|
proc.once("exit", () => {
|
|
19684
19609
|
clearTimeout(t);
|
|
19685
|
-
|
|
19610
|
+
resolve();
|
|
19686
19611
|
});
|
|
19687
19612
|
});
|
|
19688
19613
|
}
|
|
@@ -19783,14 +19708,14 @@ function formatFrpcTail(raw, maxLines = 12) {
|
|
|
19783
19708
|
return ["\u2500\u2500\u2500 frpc output (last lines) \u2500\u2500\u2500", tail, "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"].join("\n");
|
|
19784
19709
|
}
|
|
19785
19710
|
async function waitForFrpcReady(proc, timeoutMs) {
|
|
19786
|
-
return new Promise((
|
|
19711
|
+
return new Promise((resolve) => {
|
|
19787
19712
|
let settled = false;
|
|
19788
19713
|
let buf = "";
|
|
19789
19714
|
const finish = (r) => {
|
|
19790
19715
|
if (settled) return;
|
|
19791
19716
|
settled = true;
|
|
19792
19717
|
cleanup();
|
|
19793
|
-
|
|
19718
|
+
resolve(r);
|
|
19794
19719
|
};
|
|
19795
19720
|
const onData = (chunk) => {
|
|
19796
19721
|
buf += String(chunk);
|
|
@@ -19882,6 +19807,38 @@ function writeAuthFile(file, content) {
|
|
|
19882
19807
|
}
|
|
19883
19808
|
}
|
|
19884
19809
|
|
|
19810
|
+
// src/owner-profile.ts
|
|
19811
|
+
var import_node_fs17 = __toESM(require("fs"), 1);
|
|
19812
|
+
var import_node_os10 = __toESM(require("os"), 1);
|
|
19813
|
+
var import_node_path17 = __toESM(require("path"), 1);
|
|
19814
|
+
var PROFILE_FILENAME = "profile.json";
|
|
19815
|
+
function loadOwnerDisplayName(dataDir) {
|
|
19816
|
+
const fallback = import_node_os10.default.userInfo().username;
|
|
19817
|
+
const profilePath = import_node_path17.default.join(dataDir, PROFILE_FILENAME);
|
|
19818
|
+
let raw;
|
|
19819
|
+
try {
|
|
19820
|
+
raw = import_node_fs17.default.readFileSync(profilePath, "utf8");
|
|
19821
|
+
} catch {
|
|
19822
|
+
return fallback;
|
|
19823
|
+
}
|
|
19824
|
+
let parsed;
|
|
19825
|
+
try {
|
|
19826
|
+
parsed = JSON.parse(raw);
|
|
19827
|
+
} catch (err) {
|
|
19828
|
+
console.warn(`[owner-profile] ${PROFILE_FILENAME} parse failed, falling back to OS username:`, err);
|
|
19829
|
+
return fallback;
|
|
19830
|
+
}
|
|
19831
|
+
if (!parsed || typeof parsed !== "object") return fallback;
|
|
19832
|
+
const displayName = parsed.displayName;
|
|
19833
|
+
if (typeof displayName !== "string" || displayName.length === 0) {
|
|
19834
|
+
if (displayName !== void 0) {
|
|
19835
|
+
console.warn(`[owner-profile] displayName must be non-empty string, falling back to OS username`);
|
|
19836
|
+
}
|
|
19837
|
+
return fallback;
|
|
19838
|
+
}
|
|
19839
|
+
return displayName;
|
|
19840
|
+
}
|
|
19841
|
+
|
|
19885
19842
|
// src/index.ts
|
|
19886
19843
|
init_protocol();
|
|
19887
19844
|
|
|
@@ -19889,12 +19846,12 @@ init_protocol();
|
|
|
19889
19846
|
init_protocol();
|
|
19890
19847
|
|
|
19891
19848
|
// src/session/fork.ts
|
|
19892
|
-
var
|
|
19893
|
-
var
|
|
19894
|
-
var
|
|
19849
|
+
var import_node_fs18 = __toESM(require("fs"), 1);
|
|
19850
|
+
var import_node_os11 = __toESM(require("os"), 1);
|
|
19851
|
+
var import_node_path18 = __toESM(require("path"), 1);
|
|
19895
19852
|
init_claude_history();
|
|
19896
19853
|
function readJsonlEntries(file) {
|
|
19897
|
-
const raw =
|
|
19854
|
+
const raw = import_node_fs18.default.readFileSync(file, "utf8");
|
|
19898
19855
|
const out = [];
|
|
19899
19856
|
for (const line of raw.split("\n")) {
|
|
19900
19857
|
const t = line.trim();
|
|
@@ -19907,10 +19864,10 @@ function readJsonlEntries(file) {
|
|
|
19907
19864
|
return out;
|
|
19908
19865
|
}
|
|
19909
19866
|
function forkSession(input) {
|
|
19910
|
-
const baseDir = input.baseDir ??
|
|
19911
|
-
const projectDir =
|
|
19912
|
-
const sourceFile =
|
|
19913
|
-
if (!
|
|
19867
|
+
const baseDir = input.baseDir ?? import_node_path18.default.join(import_node_os11.default.homedir(), ".claude");
|
|
19868
|
+
const projectDir = import_node_path18.default.join(baseDir, "projects", cwdToHashDir(input.cwd));
|
|
19869
|
+
const sourceFile = import_node_path18.default.join(projectDir, `${input.toolSessionId}.jsonl`);
|
|
19870
|
+
if (!import_node_fs18.default.existsSync(sourceFile)) {
|
|
19914
19871
|
throw new Error(`fork: source transcript not found: ${sourceFile}`);
|
|
19915
19872
|
}
|
|
19916
19873
|
const entries = readJsonlEntries(sourceFile);
|
|
@@ -19940,9 +19897,9 @@ function forkSession(input) {
|
|
|
19940
19897
|
}
|
|
19941
19898
|
forkedLines.push(JSON.stringify(forked));
|
|
19942
19899
|
}
|
|
19943
|
-
const forkedFilePath =
|
|
19944
|
-
|
|
19945
|
-
|
|
19900
|
+
const forkedFilePath = import_node_path18.default.join(projectDir, `${forkedToolSessionId}.jsonl`);
|
|
19901
|
+
import_node_fs18.default.mkdirSync(projectDir, { recursive: true });
|
|
19902
|
+
import_node_fs18.default.writeFileSync(forkedFilePath, forkedLines.join("\n") + "\n", { mode: 384 });
|
|
19946
19903
|
return { forkedToolSessionId, forkedFilePath };
|
|
19947
19904
|
}
|
|
19948
19905
|
|
|
@@ -20230,9 +20187,9 @@ init_protocol();
|
|
|
20230
20187
|
|
|
20231
20188
|
// src/workspace/git.ts
|
|
20232
20189
|
var import_node_child_process5 = require("child_process");
|
|
20233
|
-
var
|
|
20234
|
-
var
|
|
20235
|
-
var
|
|
20190
|
+
var import_node_fs19 = __toESM(require("fs"), 1);
|
|
20191
|
+
var import_node_os12 = __toESM(require("os"), 1);
|
|
20192
|
+
var import_node_path19 = __toESM(require("path"), 1);
|
|
20236
20193
|
var import_node_util = require("util");
|
|
20237
20194
|
var pexec = (0, import_node_util.promisify)(import_node_child_process5.execFile);
|
|
20238
20195
|
function formatChildProcessError(err) {
|
|
@@ -20247,9 +20204,9 @@ function formatChildProcessError(err) {
|
|
|
20247
20204
|
return e.message ?? "unknown error";
|
|
20248
20205
|
}
|
|
20249
20206
|
function normalizePath(p) {
|
|
20250
|
-
const resolved =
|
|
20207
|
+
const resolved = import_node_path19.default.resolve(p);
|
|
20251
20208
|
try {
|
|
20252
|
-
return
|
|
20209
|
+
return import_node_fs19.default.realpathSync(resolved);
|
|
20253
20210
|
} catch {
|
|
20254
20211
|
return resolved;
|
|
20255
20212
|
}
|
|
@@ -20336,7 +20293,7 @@ function sanitizeLabel(raw) {
|
|
|
20336
20293
|
function computePrefix() {
|
|
20337
20294
|
let username;
|
|
20338
20295
|
try {
|
|
20339
|
-
username =
|
|
20296
|
+
username = import_node_os12.default.userInfo().username;
|
|
20340
20297
|
} catch {
|
|
20341
20298
|
username = void 0;
|
|
20342
20299
|
}
|
|
@@ -20350,13 +20307,13 @@ function flattenToDirName(branch) {
|
|
|
20350
20307
|
}
|
|
20351
20308
|
function encodeClaudeProjectDir(absPath) {
|
|
20352
20309
|
if (!absPath || typeof absPath !== "string") return "";
|
|
20353
|
-
let canonical =
|
|
20310
|
+
let canonical = import_node_path19.default.resolve(absPath);
|
|
20354
20311
|
try {
|
|
20355
|
-
canonical =
|
|
20312
|
+
canonical = import_node_fs19.default.realpathSync(canonical);
|
|
20356
20313
|
} catch {
|
|
20357
20314
|
try {
|
|
20358
|
-
const parent =
|
|
20359
|
-
canonical =
|
|
20315
|
+
const parent = import_node_fs19.default.realpathSync(import_node_path19.default.dirname(canonical));
|
|
20316
|
+
canonical = import_node_path19.default.join(parent, import_node_path19.default.basename(canonical));
|
|
20360
20317
|
} catch {
|
|
20361
20318
|
}
|
|
20362
20319
|
}
|
|
@@ -20380,11 +20337,11 @@ async function createWorktree(input) {
|
|
|
20380
20337
|
if (!isGitRoot) {
|
|
20381
20338
|
throw new Error(`\u76EE\u5F55 ${cwd} \u4E0D\u662F git repo \u6839`);
|
|
20382
20339
|
}
|
|
20383
|
-
const parent =
|
|
20384
|
-
if (parent === "/" || parent ===
|
|
20340
|
+
const parent = import_node_path19.default.dirname(import_node_path19.default.resolve(cwd));
|
|
20341
|
+
if (parent === "/" || parent === import_node_path19.default.resolve(cwd)) {
|
|
20385
20342
|
throw new Error("repo \u5728\u78C1\u76D8\u6839\u76EE\u5F55\uFF0C\u65E0\u6CD5\u5728\u540C\u7EA7\u521B\u5EFA worktree");
|
|
20386
20343
|
}
|
|
20387
|
-
const worktreeRoot =
|
|
20344
|
+
const worktreeRoot = import_node_path19.default.join(parent, dirName);
|
|
20388
20345
|
try {
|
|
20389
20346
|
await pexec("git", ["-C", cwd, "fetch", "origin", baseBranch, "--no-tags"], {
|
|
20390
20347
|
timeout: 3e4
|
|
@@ -20403,7 +20360,7 @@ async function createWorktree(input) {
|
|
|
20403
20360
|
const msg = err.message;
|
|
20404
20361
|
if (msg.startsWith("\u5206\u652F ")) throw err;
|
|
20405
20362
|
}
|
|
20406
|
-
if (
|
|
20363
|
+
if (import_node_fs19.default.existsSync(worktreeRoot)) {
|
|
20407
20364
|
throw new Error(`\u76EE\u5F55 ${worktreeRoot} \u5DF2\u5B58\u5728\uFF0C\u8BF7\u6362\u4E00\u4E2A label \u6216\u6E05\u7406\u540E\u91CD\u8BD5`);
|
|
20408
20365
|
}
|
|
20409
20366
|
try {
|
|
@@ -20431,8 +20388,8 @@ async function removeWorktree(input) {
|
|
|
20431
20388
|
);
|
|
20432
20389
|
const gitCommonDir = stdout.trim();
|
|
20433
20390
|
if (!gitCommonDir) throw new Error("empty git-common-dir");
|
|
20434
|
-
const absGitCommon =
|
|
20435
|
-
repoRoot =
|
|
20391
|
+
const absGitCommon = import_node_path19.default.isAbsolute(gitCommonDir) ? gitCommonDir : import_node_path19.default.resolve(worktreeRoot, gitCommonDir);
|
|
20392
|
+
repoRoot = import_node_path19.default.dirname(absGitCommon);
|
|
20436
20393
|
} catch {
|
|
20437
20394
|
repoRoot = null;
|
|
20438
20395
|
}
|
|
@@ -20444,7 +20401,7 @@ async function removeWorktree(input) {
|
|
|
20444
20401
|
} catch (err) {
|
|
20445
20402
|
const stderr = err.stderr ?? "";
|
|
20446
20403
|
const lower = stderr.toLowerCase();
|
|
20447
|
-
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !
|
|
20404
|
+
const vanished = lower.includes("not a working tree") || lower.includes("is not a working tree") || !import_node_fs19.default.existsSync(worktreeRoot);
|
|
20448
20405
|
if (!vanished) {
|
|
20449
20406
|
throw new Error(`\u6E05\u7406 worktree \u5931\u8D25\uFF1A${formatChildProcessError(err)}`);
|
|
20450
20407
|
}
|
|
@@ -20463,10 +20420,10 @@ async function removeWorktree(input) {
|
|
|
20463
20420
|
try {
|
|
20464
20421
|
const encoded = encodeClaudeProjectDir(worktreeRoot);
|
|
20465
20422
|
if (encoded) {
|
|
20466
|
-
const projectsRoot =
|
|
20467
|
-
const target =
|
|
20468
|
-
if (target.startsWith(projectsRoot +
|
|
20469
|
-
|
|
20423
|
+
const projectsRoot = import_node_path19.default.join(import_node_os12.default.homedir(), ".claude", "projects");
|
|
20424
|
+
const target = import_node_path19.default.resolve(projectsRoot, encoded);
|
|
20425
|
+
if (target.startsWith(projectsRoot + import_node_path19.default.sep) && target !== projectsRoot) {
|
|
20426
|
+
import_node_fs19.default.rmSync(target, { recursive: true, force: true });
|
|
20470
20427
|
}
|
|
20471
20428
|
}
|
|
20472
20429
|
} catch {
|
|
@@ -20538,7 +20495,7 @@ function buildCapabilitiesHandlers(deps) {
|
|
|
20538
20495
|
}
|
|
20539
20496
|
|
|
20540
20497
|
// src/handlers/meta.ts
|
|
20541
|
-
var
|
|
20498
|
+
var import_node_os13 = __toESM(require("os"), 1);
|
|
20542
20499
|
init_protocol();
|
|
20543
20500
|
|
|
20544
20501
|
// src/version.ts
|
|
@@ -20560,7 +20517,7 @@ function buildReadyFrame(deps) {
|
|
|
20560
20517
|
return {
|
|
20561
20518
|
version,
|
|
20562
20519
|
protocolVersion: PROTOCOL_VERSION,
|
|
20563
|
-
hostname:
|
|
20520
|
+
hostname: import_node_os13.default.hostname(),
|
|
20564
20521
|
os: process.platform,
|
|
20565
20522
|
tools,
|
|
20566
20523
|
runningSessions: info.runningSessions,
|
|
@@ -20681,7 +20638,7 @@ function buildMethodHandlers(deps) {
|
|
|
20681
20638
|
async function startDaemon(config) {
|
|
20682
20639
|
const logger = createLogger({
|
|
20683
20640
|
level: config.logLevel,
|
|
20684
|
-
file:
|
|
20641
|
+
file: import_node_path20.default.join(config.dataDir, "clawd.log")
|
|
20685
20642
|
});
|
|
20686
20643
|
logger.info("starting clawd", { version, config: { port: config.port, host: config.host, dataDir: config.dataDir } });
|
|
20687
20644
|
const stateMgr = new StateFileManager({ dataDir: config.dataDir });
|
|
@@ -20717,21 +20674,17 @@ async function startDaemon(config) {
|
|
|
20717
20674
|
const agents = new AgentsScanner();
|
|
20718
20675
|
const history = new ClaudeHistoryReader();
|
|
20719
20676
|
let transport = null;
|
|
20720
|
-
const personaStore = new PersonaStore(
|
|
20721
|
-
const
|
|
20722
|
-
if (defaultsRoot) {
|
|
20723
|
-
seedDefaultPersonas({ store: personaStore, defaultsRoot, logger });
|
|
20724
|
-
} else {
|
|
20725
|
-
logger.warn("persona.seed.skip", { reason: "defaults-root-not-found" });
|
|
20726
|
-
}
|
|
20677
|
+
const personaStore = new PersonaStore(import_node_path20.default.join(config.dataDir, "personas"));
|
|
20678
|
+
const ownerDisplayName = loadOwnerDisplayName(config.dataDir);
|
|
20727
20679
|
const manager = new SessionManager({
|
|
20728
20680
|
store,
|
|
20729
20681
|
logger,
|
|
20730
20682
|
getAdapter,
|
|
20731
20683
|
historyReader: history,
|
|
20732
20684
|
dataDir: config.dataDir,
|
|
20733
|
-
personaRoot:
|
|
20685
|
+
personaRoot: import_node_path20.default.join(config.dataDir, "personas"),
|
|
20734
20686
|
personaStore,
|
|
20687
|
+
ownerDisplayName,
|
|
20735
20688
|
broadcastFrame: (frame, target) => {
|
|
20736
20689
|
if (target === "all") {
|
|
20737
20690
|
transport?.broadcastAll(frame);
|
|
@@ -20903,8 +20856,8 @@ async function startDaemon(config) {
|
|
|
20903
20856
|
const lines = [
|
|
20904
20857
|
`Tunnel: ${r.url}`,
|
|
20905
20858
|
...resolvedAuthToken ? [`Connect: ${connectUrl}`] : [],
|
|
20906
|
-
`Frpc config: ${
|
|
20907
|
-
`Frpc log: ${
|
|
20859
|
+
`Frpc config: ${import_node_path20.default.join(config.dataDir, "frpc.toml")}`,
|
|
20860
|
+
`Frpc log: ${import_node_path20.default.join(config.dataDir, "frpc.log")}`
|
|
20908
20861
|
];
|
|
20909
20862
|
const width = Math.max(...lines.map((l) => l.length));
|
|
20910
20863
|
const bar = "\u2550".repeat(width + 4);
|
|
@@ -20917,8 +20870,8 @@ ${bar}
|
|
|
20917
20870
|
|
|
20918
20871
|
`);
|
|
20919
20872
|
try {
|
|
20920
|
-
const connectPath =
|
|
20921
|
-
|
|
20873
|
+
const connectPath = import_node_path20.default.join(config.dataDir, "connect.txt");
|
|
20874
|
+
import_node_fs20.default.writeFileSync(connectPath, lines.join("\n") + "\n", { mode: 384 });
|
|
20922
20875
|
} catch {
|
|
20923
20876
|
}
|
|
20924
20877
|
} catch (err) {
|