tesseract-agent 0.8.1 → 0.8.3
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-bundle/cli.js +478 -301
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -3928,6 +3928,66 @@ var init_domain_id = __esm({
|
|
|
3928
3928
|
}
|
|
3929
3929
|
});
|
|
3930
3930
|
|
|
3931
|
+
// ../../packages/shared/dist/telemetry.js
|
|
3932
|
+
var TELEMETRY_EVENTS, EVENT_CATEGORY;
|
|
3933
|
+
var init_telemetry = __esm({
|
|
3934
|
+
"../../packages/shared/dist/telemetry.js"() {
|
|
3935
|
+
"use strict";
|
|
3936
|
+
TELEMETRY_EVENTS = {
|
|
3937
|
+
app: [
|
|
3938
|
+
"app.launched",
|
|
3939
|
+
"app.foregrounded",
|
|
3940
|
+
"app.backgrounded",
|
|
3941
|
+
"app.quit",
|
|
3942
|
+
"app.updated",
|
|
3943
|
+
"app.crashed"
|
|
3944
|
+
],
|
|
3945
|
+
onboarding: [
|
|
3946
|
+
"intro.shown",
|
|
3947
|
+
"auth.signed_in",
|
|
3948
|
+
"auth.signed_out",
|
|
3949
|
+
"onboarding.step",
|
|
3950
|
+
"onboarding.completed",
|
|
3951
|
+
"permission.prompted",
|
|
3952
|
+
"permission.granted",
|
|
3953
|
+
"eula.accepted"
|
|
3954
|
+
],
|
|
3955
|
+
engagement: [
|
|
3956
|
+
"session.started",
|
|
3957
|
+
"session.ended",
|
|
3958
|
+
"turn.sent",
|
|
3959
|
+
"turn.completed",
|
|
3960
|
+
"turn.interrupted",
|
|
3961
|
+
"session.forked",
|
|
3962
|
+
"session.resumed"
|
|
3963
|
+
],
|
|
3964
|
+
feature: [
|
|
3965
|
+
"tool.used",
|
|
3966
|
+
"mission.started",
|
|
3967
|
+
"mission.completed",
|
|
3968
|
+
"voice.session_started",
|
|
3969
|
+
"voice.session_ended",
|
|
3970
|
+
"browser.tab_opened",
|
|
3971
|
+
"skill.invoked",
|
|
3972
|
+
"plugin.invoked",
|
|
3973
|
+
"connector.used"
|
|
3974
|
+
],
|
|
3975
|
+
plan: [
|
|
3976
|
+
"plan.viewed",
|
|
3977
|
+
"plan.upgrade_started",
|
|
3978
|
+
"plan.changed",
|
|
3979
|
+
"entitlement.gate_hit"
|
|
3980
|
+
],
|
|
3981
|
+
reliability: [
|
|
3982
|
+
"error.surfaced",
|
|
3983
|
+
"daemon.disconnected",
|
|
3984
|
+
"daemon.reconnected"
|
|
3985
|
+
]
|
|
3986
|
+
};
|
|
3987
|
+
EVENT_CATEGORY = Object.fromEntries(Object.entries(TELEMETRY_EVENTS).flatMap(([cat, names]) => names.map((n) => [n, cat])));
|
|
3988
|
+
}
|
|
3989
|
+
});
|
|
3990
|
+
|
|
3931
3991
|
// ../../packages/shared/dist/plans.js
|
|
3932
3992
|
var NO_QUOTAS, NO_FEATURES, PLAN_CATALOG;
|
|
3933
3993
|
var init_plans = __esm({
|
|
@@ -4557,17 +4617,17 @@ function tessExt(token2) {
|
|
|
4557
4617
|
}
|
|
4558
4618
|
function walkTokens(tree) {
|
|
4559
4619
|
const out = [];
|
|
4560
|
-
const rec = (node,
|
|
4620
|
+
const rec = (node, path6) => {
|
|
4561
4621
|
if (!isObj(node))
|
|
4562
4622
|
return;
|
|
4563
4623
|
if (isToken(node)) {
|
|
4564
|
-
out.push({ path:
|
|
4624
|
+
out.push({ path: path6, token: node });
|
|
4565
4625
|
return;
|
|
4566
4626
|
}
|
|
4567
4627
|
for (const key2 of Object.keys(node)) {
|
|
4568
4628
|
if (key2.startsWith("$"))
|
|
4569
4629
|
continue;
|
|
4570
|
-
rec(node[key2], [...
|
|
4630
|
+
rec(node[key2], [...path6, key2]);
|
|
4571
4631
|
}
|
|
4572
4632
|
};
|
|
4573
4633
|
rec(tree, []);
|
|
@@ -4583,13 +4643,13 @@ function stringifyValue(v) {
|
|
|
4583
4643
|
return String(v);
|
|
4584
4644
|
}
|
|
4585
4645
|
function flattenForDisplay(tree) {
|
|
4586
|
-
return walkTokens(tree).map(({ path:
|
|
4646
|
+
return walkTokens(tree).map(({ path: path6, token: token2 }) => {
|
|
4587
4647
|
const dark = tessExt(token2)?.modes?.dark;
|
|
4588
4648
|
return {
|
|
4589
|
-
path:
|
|
4590
|
-
dotPath:
|
|
4591
|
-
group:
|
|
4592
|
-
label:
|
|
4649
|
+
path: path6,
|
|
4650
|
+
dotPath: path6.join("."),
|
|
4651
|
+
group: path6.slice(0, -1).join(" \xB7 "),
|
|
4652
|
+
label: path6[path6.length - 1] ?? "",
|
|
4593
4653
|
type: token2.$type,
|
|
4594
4654
|
value: stringifyValue(token2.$value),
|
|
4595
4655
|
isColor: token2.$type === "color",
|
|
@@ -4600,7 +4660,7 @@ function flattenForDisplay(tree) {
|
|
|
4600
4660
|
function kebab(s) {
|
|
4601
4661
|
return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
4602
4662
|
}
|
|
4603
|
-
function tokenCssVarName(
|
|
4663
|
+
function tokenCssVarName(path6, token2) {
|
|
4604
4664
|
const override = token2 ? tessExt(token2)?.cssVar : void 0;
|
|
4605
4665
|
if (override) {
|
|
4606
4666
|
const name = override.startsWith("--") ? override : `--${override}`;
|
|
@@ -4608,12 +4668,12 @@ function tokenCssVarName(path5, token2) {
|
|
|
4608
4668
|
return name;
|
|
4609
4669
|
}
|
|
4610
4670
|
for (const { match, prefix } of VAR_ALIASES) {
|
|
4611
|
-
if (match.length <=
|
|
4612
|
-
const rest =
|
|
4671
|
+
if (match.length <= path6.length && match.every((seg, i) => path6[i] === seg)) {
|
|
4672
|
+
const rest = path6.slice(match.length).map(kebab).filter(Boolean);
|
|
4613
4673
|
return ["--" + prefix, ...rest].join("-");
|
|
4614
4674
|
}
|
|
4615
4675
|
}
|
|
4616
|
-
return ["--token", ...
|
|
4676
|
+
return ["--token", ...path6.map(kebab).filter(Boolean)].join("-");
|
|
4617
4677
|
}
|
|
4618
4678
|
function categoryRank(top) {
|
|
4619
4679
|
const i = CATEGORY_ORDER.indexOf(top ?? "");
|
|
@@ -4647,8 +4707,8 @@ function tokensToCss(input) {
|
|
|
4647
4707
|
const ordered = rows.map((r, i) => ({ r, i })).sort((a, b) => categoryRank(a.r.path[0]) - categoryRank(b.r.path[0]) || a.i - b.i).map((x) => x.r);
|
|
4648
4708
|
const root = [];
|
|
4649
4709
|
const dark = [];
|
|
4650
|
-
for (const { path:
|
|
4651
|
-
const name = tokenCssVarName(
|
|
4710
|
+
for (const { path: path6, token: token2 } of ordered) {
|
|
4711
|
+
const name = tokenCssVarName(path6, token2);
|
|
4652
4712
|
root.push(` ${name}: ${cssValue(token2.$type, token2.$value)};`);
|
|
4653
4713
|
const d = tessExt(token2)?.modes?.dark;
|
|
4654
4714
|
if (d !== void 0)
|
|
@@ -4902,10 +4962,10 @@ function applyDesignPack(current, packTokens, info, opts) {
|
|
|
4902
4962
|
const { mode } = opts;
|
|
4903
4963
|
const writeLeaves = (base, keep) => {
|
|
4904
4964
|
let acc = base;
|
|
4905
|
-
for (const { path:
|
|
4906
|
-
if (keep && !keep(
|
|
4965
|
+
for (const { path: path6, token: token2 } of walkTokens(pack)) {
|
|
4966
|
+
if (keep && !keep(path6))
|
|
4907
4967
|
continue;
|
|
4908
|
-
acc = setTokenSegments(acc,
|
|
4968
|
+
acc = setTokenSegments(acc, path6, token2);
|
|
4909
4969
|
}
|
|
4910
4970
|
return acc;
|
|
4911
4971
|
};
|
|
@@ -4990,14 +5050,14 @@ function setNested(obj, segs, value) {
|
|
|
4990
5050
|
function tokensToTailwindTheme(input) {
|
|
4991
5051
|
const tokens = normalizeTokens(input);
|
|
4992
5052
|
const extend2 = {};
|
|
4993
|
-
for (const { path:
|
|
4994
|
-
const bucket2 = TW_BUCKETS.find((b) => b.match.length <=
|
|
5053
|
+
for (const { path: path6, token: token2 } of walkTokens(tokens)) {
|
|
5054
|
+
const bucket2 = TW_BUCKETS.find((b) => b.match.length <= path6.length && b.match.every((seg, i) => path6[i] === seg));
|
|
4995
5055
|
if (!bucket2)
|
|
4996
5056
|
continue;
|
|
4997
|
-
const rest =
|
|
5057
|
+
const rest = path6.slice(bucket2.match.length).map(kebab).filter(Boolean);
|
|
4998
5058
|
if (rest.length === 0)
|
|
4999
5059
|
continue;
|
|
5000
|
-
const ref = `var(${tokenCssVarName(
|
|
5060
|
+
const ref = `var(${tokenCssVarName(path6, token2)})`;
|
|
5001
5061
|
if (!extend2[bucket2.key])
|
|
5002
5062
|
extend2[bucket2.key] = {};
|
|
5003
5063
|
if (bucket2.flat)
|
|
@@ -5028,8 +5088,8 @@ function leafSignature(token2) {
|
|
|
5028
5088
|
}
|
|
5029
5089
|
function indexLeaves(t) {
|
|
5030
5090
|
const m = /* @__PURE__ */ new Map();
|
|
5031
|
-
for (const { path:
|
|
5032
|
-
m.set(
|
|
5091
|
+
for (const { path: path6, token: token2 } of walkTokens(t)) {
|
|
5092
|
+
m.set(path6.join("."), { sig: leafSignature(token2), disp: stringifyValue(token2.$value) });
|
|
5033
5093
|
}
|
|
5034
5094
|
return m;
|
|
5035
5095
|
}
|
|
@@ -5281,6 +5341,7 @@ var init_dist = __esm({
|
|
|
5281
5341
|
init_ws_protocol();
|
|
5282
5342
|
init_frame();
|
|
5283
5343
|
init_domain_id();
|
|
5344
|
+
init_telemetry();
|
|
5284
5345
|
init_plans();
|
|
5285
5346
|
init_slug();
|
|
5286
5347
|
init_hosting();
|
|
@@ -6040,10 +6101,10 @@ function mergeDefs(...defs) {
|
|
|
6040
6101
|
function cloneDef(schema) {
|
|
6041
6102
|
return mergeDefs(schema._zod.def);
|
|
6042
6103
|
}
|
|
6043
|
-
function getElementAtPath(obj,
|
|
6044
|
-
if (!
|
|
6104
|
+
function getElementAtPath(obj, path6) {
|
|
6105
|
+
if (!path6)
|
|
6045
6106
|
return obj;
|
|
6046
|
-
return
|
|
6107
|
+
return path6.reduce((acc, key2) => acc?.[key2], obj);
|
|
6047
6108
|
}
|
|
6048
6109
|
function promiseAllObject(promisesObj) {
|
|
6049
6110
|
const keys = Object.keys(promisesObj);
|
|
@@ -6371,11 +6432,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
6371
6432
|
}
|
|
6372
6433
|
return false;
|
|
6373
6434
|
}
|
|
6374
|
-
function prefixIssues(
|
|
6435
|
+
function prefixIssues(path6, issues) {
|
|
6375
6436
|
return issues.map((iss) => {
|
|
6376
6437
|
var _a3;
|
|
6377
6438
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
6378
|
-
iss.path.unshift(
|
|
6439
|
+
iss.path.unshift(path6);
|
|
6379
6440
|
return iss;
|
|
6380
6441
|
});
|
|
6381
6442
|
}
|
|
@@ -6592,16 +6653,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6592
6653
|
}
|
|
6593
6654
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
6594
6655
|
const fieldErrors = { _errors: [] };
|
|
6595
|
-
const processError = (error52,
|
|
6656
|
+
const processError = (error52, path6 = []) => {
|
|
6596
6657
|
for (const issue2 of error52.issues) {
|
|
6597
6658
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6598
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6659
|
+
issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
|
|
6599
6660
|
} else if (issue2.code === "invalid_key") {
|
|
6600
|
-
processError({ issues: issue2.issues }, [...
|
|
6661
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6601
6662
|
} else if (issue2.code === "invalid_element") {
|
|
6602
|
-
processError({ issues: issue2.issues }, [...
|
|
6663
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6603
6664
|
} else {
|
|
6604
|
-
const fullpath = [...
|
|
6665
|
+
const fullpath = [...path6, ...issue2.path];
|
|
6605
6666
|
if (fullpath.length === 0) {
|
|
6606
6667
|
fieldErrors._errors.push(mapper(issue2));
|
|
6607
6668
|
} else {
|
|
@@ -6628,17 +6689,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6628
6689
|
}
|
|
6629
6690
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
6630
6691
|
const result = { errors: [] };
|
|
6631
|
-
const processError = (error52,
|
|
6692
|
+
const processError = (error52, path6 = []) => {
|
|
6632
6693
|
var _a3, _b;
|
|
6633
6694
|
for (const issue2 of error52.issues) {
|
|
6634
6695
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6635
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6696
|
+
issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
|
|
6636
6697
|
} else if (issue2.code === "invalid_key") {
|
|
6637
|
-
processError({ issues: issue2.issues }, [...
|
|
6698
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6638
6699
|
} else if (issue2.code === "invalid_element") {
|
|
6639
|
-
processError({ issues: issue2.issues }, [...
|
|
6700
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6640
6701
|
} else {
|
|
6641
|
-
const fullpath = [...
|
|
6702
|
+
const fullpath = [...path6, ...issue2.path];
|
|
6642
6703
|
if (fullpath.length === 0) {
|
|
6643
6704
|
result.errors.push(mapper(issue2));
|
|
6644
6705
|
continue;
|
|
@@ -6670,8 +6731,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6670
6731
|
}
|
|
6671
6732
|
function toDotPath(_path) {
|
|
6672
6733
|
const segs = [];
|
|
6673
|
-
const
|
|
6674
|
-
for (const seg of
|
|
6734
|
+
const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
6735
|
+
for (const seg of path6) {
|
|
6675
6736
|
if (typeof seg === "number")
|
|
6676
6737
|
segs.push(`[${seg}]`);
|
|
6677
6738
|
else if (typeof seg === "symbol")
|
|
@@ -20101,13 +20162,13 @@ function resolveRef(ref, ctx2) {
|
|
|
20101
20162
|
if (!ref.startsWith("#")) {
|
|
20102
20163
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
20103
20164
|
}
|
|
20104
|
-
const
|
|
20105
|
-
if (
|
|
20165
|
+
const path6 = ref.slice(1).split("/").filter(Boolean);
|
|
20166
|
+
if (path6.length === 0) {
|
|
20106
20167
|
return ctx2.rootSchema;
|
|
20107
20168
|
}
|
|
20108
20169
|
const defsKey = ctx2.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
20109
|
-
if (
|
|
20110
|
-
const key2 =
|
|
20170
|
+
if (path6[0] === defsKey) {
|
|
20171
|
+
const key2 = path6[1];
|
|
20111
20172
|
if (!key2 || !ctx2.defs[key2]) {
|
|
20112
20173
|
throw new Error(`Reference not found: ${ref}`);
|
|
20113
20174
|
}
|
|
@@ -21716,10 +21777,10 @@ function buildCanvasTools(deps) {
|
|
|
21716
21777
|
const id = args.id ? slugify3(args.id) : `${slugify3(args.title ?? "canvas")}-${Math.random().toString(36).slice(2, 8)}`;
|
|
21717
21778
|
const dir2 = await deps.canvasDir();
|
|
21718
21779
|
mkdirSync2(dir2, { recursive: true });
|
|
21719
|
-
const
|
|
21720
|
-
writeFileSync3(
|
|
21721
|
-
deps.emitCanvasReady({ path:
|
|
21722
|
-
return { content: [{ type: "text", text: `Rendered canvas "${args.title ?? id}" in the side panel (${
|
|
21780
|
+
const path6 = join5(dir2, `${id}.html`);
|
|
21781
|
+
writeFileSync3(path6, args.html, "utf8");
|
|
21782
|
+
deps.emitCanvasReady({ path: path6, title: args.title, id });
|
|
21783
|
+
return { content: [{ type: "text", text: `Rendered canvas "${args.title ?? id}" in the side panel (${path6}). Call render_canvas again with id "${id}" to transform it.` }] };
|
|
21723
21784
|
})
|
|
21724
21785
|
];
|
|
21725
21786
|
}
|
|
@@ -23024,9 +23085,57 @@ var init_trace_store = __esm({
|
|
|
23024
23085
|
}
|
|
23025
23086
|
});
|
|
23026
23087
|
|
|
23088
|
+
// ../../packages/agent-core/dist/cost-ledger.js
|
|
23089
|
+
import { promises as fs2 } from "node:fs";
|
|
23090
|
+
import path2 from "node:path";
|
|
23091
|
+
var DIR2, CostLedger;
|
|
23092
|
+
var init_cost_ledger = __esm({
|
|
23093
|
+
"../../packages/agent-core/dist/cost-ledger.js"() {
|
|
23094
|
+
"use strict";
|
|
23095
|
+
DIR2 = ".ccb-traces";
|
|
23096
|
+
CostLedger = class {
|
|
23097
|
+
fileFor(projectDir, sessionId) {
|
|
23098
|
+
return path2.join(projectDir, DIR2, sessionId, "cost.jsonl");
|
|
23099
|
+
}
|
|
23100
|
+
/** Append one turn's cost. Creates the dir + a `.gitignore` (the traces dir is inside the
|
|
23101
|
+
* user's project, usually a git repo) on first write. */
|
|
23102
|
+
async append(projectDir, sessionId, entry) {
|
|
23103
|
+
try {
|
|
23104
|
+
const file2 = this.fileFor(projectDir, sessionId);
|
|
23105
|
+
await fs2.mkdir(path2.dirname(file2), { recursive: true });
|
|
23106
|
+
await fs2.writeFile(path2.join(projectDir, DIR2, ".gitignore"), "*\n", "utf8").catch(() => {
|
|
23107
|
+
});
|
|
23108
|
+
await fs2.appendFile(file2, JSON.stringify(entry) + "\n", "utf8");
|
|
23109
|
+
} catch {
|
|
23110
|
+
}
|
|
23111
|
+
}
|
|
23112
|
+
/** Cumulative session cost = sum of every recorded turn. 0 if the ledger is missing. */
|
|
23113
|
+
async total(projectDir, sessionId) {
|
|
23114
|
+
try {
|
|
23115
|
+
const raw = await fs2.readFile(this.fileFor(projectDir, sessionId), "utf8");
|
|
23116
|
+
let sum = 0;
|
|
23117
|
+
for (const line of raw.split("\n")) {
|
|
23118
|
+
if (!line.trim())
|
|
23119
|
+
continue;
|
|
23120
|
+
try {
|
|
23121
|
+
const e = JSON.parse(line);
|
|
23122
|
+
if (typeof e.costUsd === "number" && Number.isFinite(e.costUsd))
|
|
23123
|
+
sum += e.costUsd;
|
|
23124
|
+
} catch {
|
|
23125
|
+
}
|
|
23126
|
+
}
|
|
23127
|
+
return sum;
|
|
23128
|
+
} catch {
|
|
23129
|
+
return 0;
|
|
23130
|
+
}
|
|
23131
|
+
}
|
|
23132
|
+
};
|
|
23133
|
+
}
|
|
23134
|
+
});
|
|
23135
|
+
|
|
23027
23136
|
// ../../packages/agent-core/dist/session-store.js
|
|
23028
23137
|
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
23029
|
-
import { listSessions, getSessionMessages, forkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
23138
|
+
import { listSessions, getSessionMessages, getSubagentMessages as sdkGetSubagentMessages, forkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
23030
23139
|
function toSessionInfo(s) {
|
|
23031
23140
|
const fromFirst = stripPromptPrefix(s.firstPrompt ?? "").slice(0, 80);
|
|
23032
23141
|
const fromSummary = stripPromptPrefix(s.summary ?? "").slice(0, 80);
|
|
@@ -23141,7 +23250,7 @@ ${input.command}
|
|
|
23141
23250
|
}
|
|
23142
23251
|
}
|
|
23143
23252
|
}
|
|
23144
|
-
blocks.push({ kind: "tool_use", content: detail });
|
|
23253
|
+
blocks.push({ kind: "tool_use", content: detail, name });
|
|
23145
23254
|
} else if (b.type === "advisor_tool_result") {
|
|
23146
23255
|
const c = b.content;
|
|
23147
23256
|
const text4 = c?.type === "advisor_result" ? (c.text ?? "").trim() : "";
|
|
@@ -23212,32 +23321,46 @@ var init_session_store = __esm({
|
|
|
23212
23321
|
}
|
|
23213
23322
|
async getSessionMessages(sessionId) {
|
|
23214
23323
|
try {
|
|
23215
|
-
|
|
23216
|
-
const messages = [];
|
|
23217
|
-
for (const entry of raw) {
|
|
23218
|
-
const blocks = extractBlocks(entry.message);
|
|
23219
|
-
if (blocks.length === 0 && entry.type === "user")
|
|
23220
|
-
continue;
|
|
23221
|
-
let textContent = blocks.filter((b) => b.kind === "text").map((b) => b.content).join("\n");
|
|
23222
|
-
if (entry.type === "user") {
|
|
23223
|
-
textContent = stripPromptPrefix(textContent);
|
|
23224
|
-
}
|
|
23225
|
-
messages.push({
|
|
23226
|
-
role: entry.type === "user" ? "user" : "assistant",
|
|
23227
|
-
// Flat content feeds summaries/merge seeds — keep advisor reviews OUT of it
|
|
23228
|
-
// (they're a side-channel review, rendered as their own card, like tool_use).
|
|
23229
|
-
content: textContent || blocks.find((b) => b.kind !== "advisor")?.content || "",
|
|
23230
|
-
blocks: entry.type === "assistant" ? blocks : void 0,
|
|
23231
|
-
// Thread the per-message SDK uuid so the renderer can pass it as
|
|
23232
|
-
// session:fork.upToMessageId ("fork from here").
|
|
23233
|
-
uuid: typeof entry.uuid === "string" ? entry.uuid : void 0
|
|
23234
|
-
});
|
|
23235
|
-
}
|
|
23236
|
-
return messages;
|
|
23324
|
+
return this.rawToMessages(await getSessionMessages(sessionId));
|
|
23237
23325
|
} catch {
|
|
23238
23326
|
return [];
|
|
23239
23327
|
}
|
|
23240
23328
|
}
|
|
23329
|
+
/** Read a SUBAGENT's (Task tool) transcript from its sidecar JSONL — the granular
|
|
23330
|
+
* activity that never streams to the client. `agentId` is the subagent's id (the app's
|
|
23331
|
+
* subagent-card `taskId`, which equals `task_started.task_id` and the sidecar filename);
|
|
23332
|
+
* `projectDir` scopes the lookup to the right project (required on a remote host). */
|
|
23333
|
+
async getSubagentMessages(sessionId, agentId, projectDir) {
|
|
23334
|
+
try {
|
|
23335
|
+
return this.rawToMessages(await sdkGetSubagentMessages(sessionId, agentId, projectDir ? { dir: projectDir } : void 0));
|
|
23336
|
+
} catch {
|
|
23337
|
+
return [];
|
|
23338
|
+
}
|
|
23339
|
+
}
|
|
23340
|
+
/** Shared normalization: raw SDK transcript entries → the app's SessionMessage shape. */
|
|
23341
|
+
rawToMessages(raw) {
|
|
23342
|
+
const messages = [];
|
|
23343
|
+
for (const entry of raw) {
|
|
23344
|
+
const blocks = extractBlocks(entry.message);
|
|
23345
|
+
if (blocks.length === 0 && entry.type === "user")
|
|
23346
|
+
continue;
|
|
23347
|
+
let textContent = blocks.filter((b) => b.kind === "text").map((b) => b.content).join("\n");
|
|
23348
|
+
if (entry.type === "user") {
|
|
23349
|
+
textContent = stripPromptPrefix(textContent);
|
|
23350
|
+
}
|
|
23351
|
+
messages.push({
|
|
23352
|
+
role: entry.type === "user" ? "user" : "assistant",
|
|
23353
|
+
// Flat content feeds summaries/merge seeds — keep advisor reviews OUT of it
|
|
23354
|
+
// (they're a side-channel review, rendered as their own card, like tool_use).
|
|
23355
|
+
content: textContent || blocks.find((b) => b.kind !== "advisor")?.content || "",
|
|
23356
|
+
blocks: entry.type === "assistant" ? blocks : void 0,
|
|
23357
|
+
// Thread the per-message SDK uuid so the renderer can pass it as
|
|
23358
|
+
// session:fork.upToMessageId ("fork from here").
|
|
23359
|
+
uuid: typeof entry.uuid === "string" ? entry.uuid : void 0
|
|
23360
|
+
});
|
|
23361
|
+
}
|
|
23362
|
+
return messages;
|
|
23363
|
+
}
|
|
23241
23364
|
/** Fork a session into a NEW session id (non-destructive — the source transcript
|
|
23242
23365
|
* is preserved). `upToMessageId` slices the fork at a message uuid; `title` names
|
|
23243
23366
|
* the fork; `projectDir` scopes the lookup to the right project's session store.
|
|
@@ -23683,14 +23806,14 @@ function newestVersionManagerNode() {
|
|
|
23683
23806
|
continue;
|
|
23684
23807
|
}
|
|
23685
23808
|
for (const name of names) {
|
|
23686
|
-
const
|
|
23687
|
-
if (!existsSync2(
|
|
23809
|
+
const path6 = bin(join9(dir2, name));
|
|
23810
|
+
if (!existsSync2(path6))
|
|
23688
23811
|
continue;
|
|
23689
23812
|
const parts = name.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
23690
23813
|
const ver = [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
23691
23814
|
const gt = !best || ver[0] > best.ver[0] || ver[0] === best.ver[0] && (ver[1] > best.ver[1] || ver[1] === best.ver[1] && ver[2] > best.ver[2]);
|
|
23692
23815
|
if (gt)
|
|
23693
|
-
best = { ver, path:
|
|
23816
|
+
best = { ver, path: path6 };
|
|
23694
23817
|
}
|
|
23695
23818
|
}
|
|
23696
23819
|
return best?.path ?? null;
|
|
@@ -23703,8 +23826,8 @@ function loginShellNode() {
|
|
|
23703
23826
|
return null;
|
|
23704
23827
|
try {
|
|
23705
23828
|
const out = execFileSync(shell, ["-lic", `printf '<<NODE:%s>>' "$(command -v node 2>/dev/null)"`], { encoding: "utf8", timeout: 4e3, stdio: ["ignore", "pipe", "ignore"] });
|
|
23706
|
-
const
|
|
23707
|
-
return
|
|
23829
|
+
const path6 = out.match(/<<NODE:(.*?)>>/)?.[1]?.trim();
|
|
23830
|
+
return path6 && existsSync2(path6) ? path6 : null;
|
|
23708
23831
|
} catch {
|
|
23709
23832
|
return null;
|
|
23710
23833
|
}
|
|
@@ -23756,6 +23879,29 @@ function traceFrame(message) {
|
|
|
23756
23879
|
}
|
|
23757
23880
|
const sub = typeof message.subtype === "string" ? `/${message.subtype}` : "";
|
|
23758
23881
|
const parent = message.parent_tool_use_id ? " (subagent)" : "";
|
|
23882
|
+
if (type === "system" && typeof message.subtype === "string" && message.subtype.startsWith("task_")) {
|
|
23883
|
+
const m = message;
|
|
23884
|
+
const u = m.usage ?? {};
|
|
23885
|
+
let patch = "";
|
|
23886
|
+
if (m.patch && typeof m.patch === "object") {
|
|
23887
|
+
try {
|
|
23888
|
+
patch = `patch=${JSON.stringify(m.patch).slice(0, 200)}`;
|
|
23889
|
+
} catch {
|
|
23890
|
+
patch = "patch=?";
|
|
23891
|
+
}
|
|
23892
|
+
}
|
|
23893
|
+
const bits = [
|
|
23894
|
+
typeof m.task_id === "string" ? `id=${m.task_id.slice(0, 8)}` : "",
|
|
23895
|
+
typeof m.status === "string" ? `status=${m.status}` : "",
|
|
23896
|
+
typeof m.subagent_type === "string" ? `agent=${m.subagent_type}` : "",
|
|
23897
|
+
typeof m.last_tool_name === "string" ? `last=${m.last_tool_name}` : "",
|
|
23898
|
+
typeof u.tool_uses === "number" ? `tools=${u.tool_uses}` : "",
|
|
23899
|
+
typeof u.total_tokens === "number" ? `tok=${u.total_tokens}` : "",
|
|
23900
|
+
patch
|
|
23901
|
+
].filter(Boolean).join(" ");
|
|
23902
|
+
log(`frame ${type}${sub}${parent}${bits ? " \u2014 " + bits : ""}`);
|
|
23903
|
+
return;
|
|
23904
|
+
}
|
|
23759
23905
|
log(`frame ${type}${sub}${parent}`);
|
|
23760
23906
|
}
|
|
23761
23907
|
function rawFramePreview(message, limit = 2e3) {
|
|
@@ -24113,9 +24259,9 @@ function editedPathOf(toolInput) {
|
|
|
24113
24259
|
const p = i?.file_path ?? i?.notebook_path;
|
|
24114
24260
|
return typeof p === "string" && p.length > 0 ? p : null;
|
|
24115
24261
|
}
|
|
24116
|
-
async function snapshotFile(
|
|
24262
|
+
async function snapshotFile(path6) {
|
|
24117
24263
|
try {
|
|
24118
|
-
const buf = await readFile6(
|
|
24264
|
+
const buf = await readFile6(path6);
|
|
24119
24265
|
if (buf.length > EDIT_PREVIEW_CAP)
|
|
24120
24266
|
return { noPreview: true };
|
|
24121
24267
|
if (buf.subarray(0, 8192).includes(0))
|
|
@@ -24163,7 +24309,7 @@ MOBILE (${fw}):
|
|
|
24163
24309
|
return "";
|
|
24164
24310
|
}
|
|
24165
24311
|
}
|
|
24166
|
-
var cachedClaudeExe, cachedNodeExe, HUMAN_READABLE_FIELDS,
|
|
24312
|
+
var cachedClaudeExe, cachedNodeExe, HUMAN_READABLE_FIELDS, SYSTEM_EVENT_CATEGORY, TOOL_RESULT_CAP, MAX_RESULT_IMAGES, MAX_IMAGE_BASE64, PERMISSION_MODES, EDIT_PREVIEW_CAP, AsyncMessagePump, IDLE_REAP_MS, MODERATE_IDLE_MS, STEER_COALESCE_MS, STOP_HARD_KILL_AFTER_MS, AgentManager;
|
|
24167
24313
|
var init_agent_manager = __esm({
|
|
24168
24314
|
"../../packages/agent-core/dist/agent-manager.js"() {
|
|
24169
24315
|
"use strict";
|
|
@@ -24186,13 +24332,13 @@ var init_agent_manager = __esm({
|
|
|
24186
24332
|
init_narrator();
|
|
24187
24333
|
init_plan_splitter();
|
|
24188
24334
|
init_trace_store();
|
|
24335
|
+
init_cost_ledger();
|
|
24189
24336
|
init_session_store();
|
|
24190
24337
|
init_session_usage();
|
|
24191
24338
|
init_kill_tree();
|
|
24192
24339
|
init_log();
|
|
24193
24340
|
init_sources();
|
|
24194
24341
|
HUMAN_READABLE_FIELDS = ["message", "text", "content", "summary", "description", "output", "stdout", "error", "reason", "name"];
|
|
24195
|
-
THINKING_THROTTLE_MS = 2e3;
|
|
24196
24342
|
SYSTEM_EVENT_CATEGORY = {
|
|
24197
24343
|
hook_started: "hook",
|
|
24198
24344
|
hook_progress: "hook",
|
|
@@ -24255,6 +24401,7 @@ var init_agent_manager = __esm({
|
|
|
24255
24401
|
projectDir;
|
|
24256
24402
|
/** Per-generation trace persistence (.ccb-traces on the agent's disk). */
|
|
24257
24403
|
traceStore = new TraceStore();
|
|
24404
|
+
costLedger = new CostLedger();
|
|
24258
24405
|
/** On-disk session transcripts — used by mergeSessions to gather context. */
|
|
24259
24406
|
sessionStore = new SessionStore();
|
|
24260
24407
|
liveSessions = /* @__PURE__ */ new Map();
|
|
@@ -24955,6 +25102,21 @@ ${qText}`;
|
|
|
24955
25102
|
return null;
|
|
24956
25103
|
return this.traceStore.readTurn(dir2, sessionId, turnId);
|
|
24957
25104
|
}
|
|
25105
|
+
/** A subagent's activity transcript (from its sidecar JSONL) — the granular frames the
|
|
25106
|
+
* Task tool never streams to the client. `agentId` == the subagent-card taskId. Falls
|
|
25107
|
+
* back to the resident session's cwd / configured project for the file lookup. */
|
|
25108
|
+
async getSubagentMessages(sessionId, agentId, projectDir) {
|
|
25109
|
+
const dir2 = this.liveSessions.get(sessionId)?.cwd ?? projectDir ?? this.projectDir ?? void 0;
|
|
25110
|
+
return this.sessionStore.getSubagentMessages(sessionId, agentId, dir2);
|
|
25111
|
+
}
|
|
25112
|
+
/** Authoritative cumulative cost (USD) for a session, summed from the durable per-turn cost
|
|
25113
|
+
* ledger — survives reload/resume (unlike a client-side sum of the text-only transcript). */
|
|
25114
|
+
async getSessionCost(sessionId, projectDir) {
|
|
25115
|
+
const dir2 = this.liveSessions.get(sessionId)?.cwd ?? projectDir ?? this.projectDir ?? void 0;
|
|
25116
|
+
if (!dir2)
|
|
25117
|
+
return 0;
|
|
25118
|
+
return this.costLedger.total(dir2, sessionId);
|
|
25119
|
+
}
|
|
24958
25120
|
/** Merge sessions into a NEW one: gather each transcript, seed a fresh session with
|
|
24959
25121
|
* the combined context + an instruction to summarize-and-continue. The new session
|
|
24960
25122
|
* resolves via session:created (clientRequestId-keyed) exactly like a brand-new
|
|
@@ -25681,10 +25843,10 @@ CRITICAL RULES:
|
|
|
25681
25843
|
matcher: "Edit|Write|MultiEdit|NotebookEdit",
|
|
25682
25844
|
hooks: [async (input) => {
|
|
25683
25845
|
if (input.hook_event_name === "PreToolUse" && !input.agent_id) {
|
|
25684
|
-
const
|
|
25685
|
-
if (
|
|
25686
|
-
const snap = await snapshotFile(
|
|
25687
|
-
pendingEdits.set(input.tool_use_id, { path:
|
|
25846
|
+
const path6 = editedPathOf(input.tool_input);
|
|
25847
|
+
if (path6) {
|
|
25848
|
+
const snap = await snapshotFile(path6);
|
|
25849
|
+
pendingEdits.set(input.tool_use_id, { path: path6, before: snap.content, created: snap.created, noPreview: snap.noPreview });
|
|
25688
25850
|
}
|
|
25689
25851
|
}
|
|
25690
25852
|
return {};
|
|
@@ -25696,14 +25858,14 @@ CRITICAL RULES:
|
|
|
25696
25858
|
if (input.hook_event_name === "PostToolUse" && !input.agent_id) {
|
|
25697
25859
|
const pre = pendingEdits.get(input.tool_use_id);
|
|
25698
25860
|
pendingEdits.delete(input.tool_use_id);
|
|
25699
|
-
const
|
|
25700
|
-
if (
|
|
25701
|
-
const post = await snapshotFile(
|
|
25861
|
+
const path6 = pre?.path ?? editedPathOf(input.tool_input);
|
|
25862
|
+
if (path6) {
|
|
25863
|
+
const post = await snapshotFile(path6);
|
|
25702
25864
|
emitFileEdit({
|
|
25703
25865
|
type: "agent:file_edit",
|
|
25704
25866
|
sessionId: live.sessionId,
|
|
25705
25867
|
toolName: input.tool_name,
|
|
25706
|
-
path:
|
|
25868
|
+
path: path6,
|
|
25707
25869
|
before: pre?.before,
|
|
25708
25870
|
after: post.content,
|
|
25709
25871
|
created: pre?.created || void 0,
|
|
@@ -25730,6 +25892,9 @@ CRITICAL RULES:
|
|
|
25730
25892
|
const spawnEnv = {
|
|
25731
25893
|
...process.env,
|
|
25732
25894
|
...options.env,
|
|
25895
|
+
// params.env carries CLAUDE_AUTOCOMPACT_PCT_OVERRIDE from the user's setting
|
|
25896
|
+
// (getAgentSettings) — IF this CLI honours it, native mid-run compaction fires
|
|
25897
|
+
// at the same threshold as our renderer-side proactive `/compact`.
|
|
25733
25898
|
...params.env ?? {},
|
|
25734
25899
|
...params.engineEnv ?? {},
|
|
25735
25900
|
CCB_IPC_PORT: String(live.ipcPort)
|
|
@@ -25853,17 +26018,8 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
25853
26018
|
};
|
|
25854
26019
|
const emitEvent = (spec, parentId) => {
|
|
25855
26020
|
const payload = { ...spec, ...parentId ? { parentToolUseId: parentId } : {} };
|
|
25856
|
-
if (spec.updateKey === "thinking_tokens")
|
|
25857
|
-
const now2 = Date.now();
|
|
25858
|
-
if (now2 - (live.lastThinkingEmitAt ?? 0) >= THINKING_THROTTLE_MS) {
|
|
25859
|
-
live.lastThinkingEmitAt = now2;
|
|
25860
|
-
live.pendingThinking = void 0;
|
|
25861
|
-
sendEvent(payload);
|
|
25862
|
-
} else {
|
|
25863
|
-
live.pendingThinking = payload;
|
|
25864
|
-
}
|
|
26021
|
+
if (spec.updateKey === "thinking_tokens")
|
|
25865
26022
|
return;
|
|
25866
|
-
}
|
|
25867
26023
|
flushPendingThinking();
|
|
25868
26024
|
sendEvent(payload);
|
|
25869
26025
|
};
|
|
@@ -26040,6 +26196,16 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26040
26196
|
frames: finishedTrace.frames
|
|
26041
26197
|
});
|
|
26042
26198
|
}
|
|
26199
|
+
if (typeof r.total_cost_usd === "number" && r.total_cost_usd > 0 && live.cwd) {
|
|
26200
|
+
const uc = r.usage;
|
|
26201
|
+
void this.costLedger.append(live.cwd, turnSid, {
|
|
26202
|
+
...traceTurnId ? { turnId: traceTurnId } : {},
|
|
26203
|
+
ts: Date.now(),
|
|
26204
|
+
costUsd: r.total_cost_usd,
|
|
26205
|
+
...typeof uc?.input_tokens === "number" ? { inputTokens: uc.input_tokens } : {},
|
|
26206
|
+
...typeof uc?.output_tokens === "number" ? { outputTokens: uc.output_tokens } : {}
|
|
26207
|
+
});
|
|
26208
|
+
}
|
|
26043
26209
|
if (r.subtype === "success") {
|
|
26044
26210
|
if (!turnStreamed && Array.isArray(live.lastAssistantContent)) {
|
|
26045
26211
|
for (const blk of live.lastAssistantContent) {
|
|
@@ -26148,6 +26314,7 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26148
26314
|
...sstr(m.tool_use_id) ? { toolUseId: sstr(m.tool_use_id) } : {},
|
|
26149
26315
|
...parentToolUseId ? { parentToolUseId } : {},
|
|
26150
26316
|
description: sstr(m.description) || "subagent task",
|
|
26317
|
+
...sstr(m.prompt) ? { prompt: sstr(m.prompt) } : {},
|
|
26151
26318
|
...sstr(m.subagent_type) ? { subagentType: sstr(m.subagent_type) } : {},
|
|
26152
26319
|
...sstr(m.workflow_name) ? { workflowName: sstr(m.workflow_name) } : {}
|
|
26153
26320
|
});
|
|
@@ -26422,7 +26589,7 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26422
26589
|
const detail = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
26423
26590
|
${err.stack}` : ""}` : String(err);
|
|
26424
26591
|
log("Session iterator error:", sid, detail);
|
|
26425
|
-
emit2({ type: "chat:error", sessionId: sid, error: detail });
|
|
26592
|
+
emit2({ type: "chat:error", sessionId: sid, error: detail, transient: true });
|
|
26426
26593
|
emit2({ type: "agent:status", sessionId: sid, status: "error" });
|
|
26427
26594
|
}
|
|
26428
26595
|
} finally {
|
|
@@ -28365,13 +28532,13 @@ function __disposeResources(env) {
|
|
|
28365
28532
|
}
|
|
28366
28533
|
return next();
|
|
28367
28534
|
}
|
|
28368
|
-
function __rewriteRelativeImportExtension(
|
|
28369
|
-
if (typeof
|
|
28370
|
-
return
|
|
28535
|
+
function __rewriteRelativeImportExtension(path6, preserveJsx) {
|
|
28536
|
+
if (typeof path6 === "string" && /^\.\.?\//.test(path6)) {
|
|
28537
|
+
return path6.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
28371
28538
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
28372
28539
|
});
|
|
28373
28540
|
}
|
|
28374
|
-
return
|
|
28541
|
+
return path6;
|
|
28375
28542
|
}
|
|
28376
28543
|
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
|
|
28377
28544
|
var init_tslib_es6 = __esm({
|
|
@@ -39966,14 +40133,14 @@ var require_dependency_container = __commonJS({
|
|
|
39966
40133
|
provider = providerOrConstructor;
|
|
39967
40134
|
}
|
|
39968
40135
|
if (providers_1.isTokenProvider(provider)) {
|
|
39969
|
-
const
|
|
40136
|
+
const path6 = [token2];
|
|
39970
40137
|
let tokenProvider = provider;
|
|
39971
40138
|
while (tokenProvider != null) {
|
|
39972
40139
|
const currentToken = tokenProvider.useToken;
|
|
39973
|
-
if (
|
|
39974
|
-
throw new Error(`Token registration cycle detected! ${[...
|
|
40140
|
+
if (path6.includes(currentToken)) {
|
|
40141
|
+
throw new Error(`Token registration cycle detected! ${[...path6, currentToken].join(" -> ")}`);
|
|
39975
40142
|
}
|
|
39976
|
-
|
|
40143
|
+
path6.push(currentToken);
|
|
39977
40144
|
const registration = this._registry.get(currentToken);
|
|
39978
40145
|
if (registration && providers_1.isTokenProvider(registration.provider)) {
|
|
39979
40146
|
tokenProvider = registration.provider;
|
|
@@ -45318,7 +45485,7 @@ var init_framing = __esm({
|
|
|
45318
45485
|
});
|
|
45319
45486
|
|
|
45320
45487
|
// ../../packages/host-core/dist/peer-link/transport.js
|
|
45321
|
-
function socketPeerLink(socket2, peerHostId,
|
|
45488
|
+
function socketPeerLink(socket2, peerHostId, path6, opts) {
|
|
45322
45489
|
const dec = new FrameDecoder();
|
|
45323
45490
|
const dataCbs = /* @__PURE__ */ new Set();
|
|
45324
45491
|
const closeCbs = /* @__PURE__ */ new Set();
|
|
@@ -45392,7 +45559,7 @@ function socketPeerLink(socket2, peerHostId, path5, opts) {
|
|
|
45392
45559
|
}
|
|
45393
45560
|
const link = {
|
|
45394
45561
|
peerHostId,
|
|
45395
|
-
path:
|
|
45562
|
+
path: path6,
|
|
45396
45563
|
send(chunk) {
|
|
45397
45564
|
if (!closed)
|
|
45398
45565
|
socket2.write(encodeFrame2(chunk));
|
|
@@ -47683,6 +47850,8 @@ async function createClaudeCodeBackend(send3, onBrowserRequest, loadPluginRuntim
|
|
|
47683
47850
|
listSessions: (projectDir) => store.getSessions(projectDir),
|
|
47684
47851
|
searchSessions: (query2, projectDir) => store.searchSessions(query2, projectDir),
|
|
47685
47852
|
getMessages: (sessionId) => store.getSessionMessages(sessionId),
|
|
47853
|
+
getSubagentMessages: (sessionId, agentId, projectDir) => manager2.getSubagentMessages(sessionId, agentId, projectDir),
|
|
47854
|
+
getSessionCost: (sessionId, projectDir) => manager2.getSessionCost(sessionId, projectDir),
|
|
47686
47855
|
getSessionArtifacts: (sessionId, projectDir) => readSessionArtifacts2(sessionId, projectDir),
|
|
47687
47856
|
summarizeSession: async (sessionId) => manager2.summarizeSession(await store.getSessionMessages(sessionId)),
|
|
47688
47857
|
setConfig: (projectDir) => {
|
|
@@ -48159,15 +48328,15 @@ import { homedir as homedir9 } from "node:os";
|
|
|
48159
48328
|
init_dist();
|
|
48160
48329
|
|
|
48161
48330
|
// ../../packages/plugin-host/dist/discovery.js
|
|
48162
|
-
import
|
|
48163
|
-
import
|
|
48331
|
+
import fs3 from "node:fs";
|
|
48332
|
+
import path3 from "node:path";
|
|
48164
48333
|
var isWindows = process.platform === "win32";
|
|
48165
48334
|
function checkTrust(rootDir, trusted, relaxHardlink = false) {
|
|
48166
48335
|
if (trusted)
|
|
48167
48336
|
return null;
|
|
48168
48337
|
let st;
|
|
48169
48338
|
try {
|
|
48170
|
-
st =
|
|
48339
|
+
st = fs3.statSync(rootDir);
|
|
48171
48340
|
} catch {
|
|
48172
48341
|
return "unreadable";
|
|
48173
48342
|
}
|
|
@@ -48181,7 +48350,7 @@ function checkTrust(rootDir, trusted, relaxHardlink = false) {
|
|
|
48181
48350
|
if (!relaxHardlink) {
|
|
48182
48351
|
for (const name of ["package.json"]) {
|
|
48183
48352
|
try {
|
|
48184
|
-
const f =
|
|
48353
|
+
const f = fs3.statSync(path3.join(rootDir, name));
|
|
48185
48354
|
if (f.nlink > 1)
|
|
48186
48355
|
return `${name} is a hardlink`;
|
|
48187
48356
|
} catch {
|
|
@@ -48196,20 +48365,20 @@ function discover(roots) {
|
|
|
48196
48365
|
for (const root of roots) {
|
|
48197
48366
|
let entries;
|
|
48198
48367
|
try {
|
|
48199
|
-
entries =
|
|
48368
|
+
entries = fs3.readdirSync(root.dir, { withFileTypes: true });
|
|
48200
48369
|
} catch {
|
|
48201
48370
|
continue;
|
|
48202
48371
|
}
|
|
48203
48372
|
for (const ent of entries) {
|
|
48204
48373
|
if (!ent.isDirectory() && !ent.isSymbolicLink())
|
|
48205
48374
|
continue;
|
|
48206
|
-
const rootDir =
|
|
48207
|
-
if (!
|
|
48375
|
+
const rootDir = path3.join(root.dir, ent.name);
|
|
48376
|
+
if (!fs3.existsSync(path3.join(rootDir, "package.json"))) {
|
|
48208
48377
|
if (ent.name.startsWith("@")) {
|
|
48209
48378
|
try {
|
|
48210
|
-
for (const sub of
|
|
48211
|
-
const subDir =
|
|
48212
|
-
if (
|
|
48379
|
+
for (const sub of fs3.readdirSync(rootDir, { withFileTypes: true })) {
|
|
48380
|
+
const subDir = path3.join(rootDir, sub.name);
|
|
48381
|
+
if (fs3.existsSync(path3.join(subDir, "package.json")))
|
|
48213
48382
|
pushCandidate(subDir, root, candidates, diagnostics);
|
|
48214
48383
|
}
|
|
48215
48384
|
} catch {
|
|
@@ -48231,13 +48400,13 @@ function pushCandidate(rootDir, root, candidates, diagnostics) {
|
|
|
48231
48400
|
}
|
|
48232
48401
|
|
|
48233
48402
|
// ../../packages/plugin-host/dist/manifest.js
|
|
48234
|
-
import
|
|
48235
|
-
import
|
|
48403
|
+
import fs4 from "node:fs";
|
|
48404
|
+
import path4 from "node:path";
|
|
48236
48405
|
function resolveEntry(rootDir, rel, pkg) {
|
|
48237
48406
|
const candidates = [rel, pkg.module, pkg.main, "index.js", "index.ts", "dist/index.js"].filter(Boolean);
|
|
48238
48407
|
for (const c of candidates) {
|
|
48239
|
-
const abs =
|
|
48240
|
-
if (
|
|
48408
|
+
const abs = path4.resolve(rootDir, c);
|
|
48409
|
+
if (fs4.existsSync(abs))
|
|
48241
48410
|
return abs;
|
|
48242
48411
|
}
|
|
48243
48412
|
return null;
|
|
@@ -48245,7 +48414,7 @@ function resolveEntry(rootDir, rel, pkg) {
|
|
|
48245
48414
|
function readManifest2(rootDir) {
|
|
48246
48415
|
let pkg;
|
|
48247
48416
|
try {
|
|
48248
|
-
pkg = JSON.parse(
|
|
48417
|
+
pkg = JSON.parse(fs4.readFileSync(path4.join(rootDir, "package.json"), "utf8"));
|
|
48249
48418
|
} catch {
|
|
48250
48419
|
return { manifest: null, diagnostic: `${rootDir}: unreadable package.json` };
|
|
48251
48420
|
}
|
|
@@ -48570,12 +48739,12 @@ function createOpenClawAdapter(pluginId, config2, secretResolver, registry2) {
|
|
|
48570
48739
|
}
|
|
48571
48740
|
|
|
48572
48741
|
// ../../packages/plugin-host/dist/openclaw-stub.js
|
|
48573
|
-
import
|
|
48574
|
-
import
|
|
48742
|
+
import fs5 from "node:fs";
|
|
48743
|
+
import path5 from "node:path";
|
|
48575
48744
|
function writeOpenClawShim(pluginsDir) {
|
|
48576
|
-
const stubDir =
|
|
48577
|
-
|
|
48578
|
-
|
|
48745
|
+
const stubDir = path5.join(pluginsDir, "node_modules", "openclaw");
|
|
48746
|
+
fs5.mkdirSync(stubDir, { recursive: true });
|
|
48747
|
+
fs5.writeFileSync(path5.join(stubDir, "package.json"), JSON.stringify({
|
|
48579
48748
|
name: "openclaw",
|
|
48580
48749
|
version: "0.0.0-tesseract-compat",
|
|
48581
48750
|
type: "module",
|
|
@@ -48592,8 +48761,8 @@ function writeOpenClawShim(pluginsDir) {
|
|
|
48592
48761
|
"export default { definePluginEntry };",
|
|
48593
48762
|
""
|
|
48594
48763
|
].join("\n");
|
|
48595
|
-
|
|
48596
|
-
|
|
48764
|
+
fs5.writeFileSync(path5.join(stubDir, "plugin-entry.mjs"), entrySrc);
|
|
48765
|
+
fs5.writeFileSync(path5.join(stubDir, "plugin-sdk.mjs"), "export * from './plugin-entry.mjs';\nexport { default } from './plugin-entry.mjs';\n");
|
|
48597
48766
|
return stubDir;
|
|
48598
48767
|
}
|
|
48599
48768
|
|
|
@@ -49189,10 +49358,10 @@ function augmentedPath() {
|
|
|
49189
49358
|
}
|
|
49190
49359
|
return parts.join(sep8);
|
|
49191
49360
|
}
|
|
49192
|
-
function which(bin,
|
|
49361
|
+
function which(bin, path6) {
|
|
49193
49362
|
const tool12 = process.platform === "win32" ? "where" : "which";
|
|
49194
49363
|
try {
|
|
49195
|
-
const out = execFileSync2(tool12, [bin], { env: { ...process.env, PATH:
|
|
49364
|
+
const out = execFileSync2(tool12, [bin], { env: { ...process.env, PATH: path6 }, timeout: 4e3, encoding: "utf-8" });
|
|
49196
49365
|
return out.split(/\r?\n/).map((l) => l.trim()).find(Boolean) || void 0;
|
|
49197
49366
|
} catch {
|
|
49198
49367
|
return void 0;
|
|
@@ -49204,12 +49373,12 @@ function compute(engineId) {
|
|
|
49204
49373
|
const desc = engineById(engineId);
|
|
49205
49374
|
if (!desc)
|
|
49206
49375
|
return null;
|
|
49207
|
-
const
|
|
49376
|
+
const path6 = augmentedPath();
|
|
49208
49377
|
const explicit = process.env[`CCB_ENGINE_PATH_${envKey(engineId)}`]?.trim();
|
|
49209
|
-
const command = explicit || which(desc.cliBinary,
|
|
49378
|
+
const command = explicit || which(desc.cliBinary, path6);
|
|
49210
49379
|
if (!command)
|
|
49211
49380
|
return null;
|
|
49212
|
-
const env = { PATH:
|
|
49381
|
+
const env = { PATH: path6 };
|
|
49213
49382
|
const prefix = "CCB_ENGINE_ENV_";
|
|
49214
49383
|
for (const [k, v] of Object.entries(process.env)) {
|
|
49215
49384
|
if (v !== void 0 && k.startsWith(prefix))
|
|
@@ -51693,9 +51862,9 @@ function createDaemonImageGenRunner() {
|
|
|
51693
51862
|
mkdirSync8(dir2, { recursive: true });
|
|
51694
51863
|
const files = images.map((img, i) => {
|
|
51695
51864
|
const ext = img.mime.split("/")[1]?.split("+")[0] || "png";
|
|
51696
|
-
const
|
|
51697
|
-
writeFileSync9(
|
|
51698
|
-
return { path:
|
|
51865
|
+
const path6 = join18(dir2, `${i + 1}.${ext}`);
|
|
51866
|
+
writeFileSync9(path6, img.bytes);
|
|
51867
|
+
return { path: path6, mime: img.mime };
|
|
51699
51868
|
});
|
|
51700
51869
|
return { ok: true, files, usedProviderId: id };
|
|
51701
51870
|
} catch (e) {
|
|
@@ -51743,10 +51912,10 @@ function dynamicMetrics() {
|
|
|
51743
51912
|
|
|
51744
51913
|
// ../../packages/host-core/dist/support-submit.js
|
|
51745
51914
|
var LOG_TAIL_BYTES = 64 * 1024;
|
|
51746
|
-
function tail2(
|
|
51915
|
+
function tail2(path6, bytes = LOG_TAIL_BYTES) {
|
|
51747
51916
|
let fd = null;
|
|
51748
51917
|
try {
|
|
51749
|
-
fd = openSync2(
|
|
51918
|
+
fd = openSync2(path6, "r");
|
|
51750
51919
|
const size = fstatSync(fd).size;
|
|
51751
51920
|
const len = Math.min(size, bytes);
|
|
51752
51921
|
const start2 = Math.max(0, size - len);
|
|
@@ -52287,8 +52456,8 @@ function releaseFsClient(key2) {
|
|
|
52287
52456
|
}
|
|
52288
52457
|
var OUTSIDE = (verb) => ({ ok: false, error: `Refusing to ${verb} outside the shared root.` });
|
|
52289
52458
|
var validName = (n) => !!n && !n.includes("/") && !n.includes("\\") && n !== "." && n !== "..";
|
|
52290
|
-
async function readRemoteBytes(root,
|
|
52291
|
-
const real = safeContentPath(
|
|
52459
|
+
async function readRemoteBytes(root, path6) {
|
|
52460
|
+
const real = safeContentPath(path6);
|
|
52292
52461
|
if (!real)
|
|
52293
52462
|
return { error: "Path is outside the shared root." };
|
|
52294
52463
|
try {
|
|
@@ -52878,8 +53047,8 @@ var CHUNK = 64 * 1024;
|
|
|
52878
53047
|
var MAX_MSG = 256 * 1024;
|
|
52879
53048
|
var HIGH_WATER = 8 * 1024 * 1024;
|
|
52880
53049
|
var drainers = /* @__PURE__ */ new WeakMap();
|
|
52881
|
-
async function serveGet(dc, id,
|
|
52882
|
-
const res = await readRemoteBytes(root,
|
|
53050
|
+
async function serveGet(dc, id, path6, root) {
|
|
53051
|
+
const res = await readRemoteBytes(root, path6);
|
|
52883
53052
|
if (!dc.isOpen())
|
|
52884
53053
|
return;
|
|
52885
53054
|
if (res.error || !res.bytes) {
|
|
@@ -53697,9 +53866,9 @@ var PeerLinkManager = class {
|
|
|
53697
53866
|
* match, hand the authed link to its waiter. Shared by both transports so a
|
|
53698
53867
|
* listener doesn't care HOW the peer dialed in — the token in pendingInbound
|
|
53699
53868
|
* matches either. */
|
|
53700
|
-
acceptInbound(sock,
|
|
53869
|
+
acceptInbound(sock, path6) {
|
|
53701
53870
|
let matchedHex;
|
|
53702
|
-
const { link, ready } = socketPeerLink(sock, "",
|
|
53871
|
+
const { link, ready } = socketPeerLink(sock, "", path6, {
|
|
53703
53872
|
expectToken: (f) => {
|
|
53704
53873
|
const hb = Buffer.from(toHex(f));
|
|
53705
53874
|
for (const key2 of this.pendingInbound.keys()) {
|
|
@@ -54713,7 +54882,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
54713
54882
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
54714
54883
|
const statMethod = opts.lstat ? lstat5 : stat4;
|
|
54715
54884
|
if (wantBigintFsStats) {
|
|
54716
|
-
this._stat = (
|
|
54885
|
+
this._stat = (path6) => statMethod(path6, { bigint: true });
|
|
54717
54886
|
} else {
|
|
54718
54887
|
this._stat = statMethod;
|
|
54719
54888
|
}
|
|
@@ -54738,8 +54907,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
54738
54907
|
const par = this.parent;
|
|
54739
54908
|
const fil = par && par.files;
|
|
54740
54909
|
if (fil && fil.length > 0) {
|
|
54741
|
-
const { path:
|
|
54742
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
54910
|
+
const { path: path6, depth } = par;
|
|
54911
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path6));
|
|
54743
54912
|
const awaited = await Promise.all(slice);
|
|
54744
54913
|
for (const entry of awaited) {
|
|
54745
54914
|
if (!entry)
|
|
@@ -54779,20 +54948,20 @@ var ReaddirpStream = class extends Readable {
|
|
|
54779
54948
|
this.reading = false;
|
|
54780
54949
|
}
|
|
54781
54950
|
}
|
|
54782
|
-
async _exploreDir(
|
|
54951
|
+
async _exploreDir(path6, depth) {
|
|
54783
54952
|
let files;
|
|
54784
54953
|
try {
|
|
54785
|
-
files = await readdir6(
|
|
54954
|
+
files = await readdir6(path6, this._rdOptions);
|
|
54786
54955
|
} catch (error51) {
|
|
54787
54956
|
this._onError(error51);
|
|
54788
54957
|
}
|
|
54789
|
-
return { files, depth, path:
|
|
54958
|
+
return { files, depth, path: path6 };
|
|
54790
54959
|
}
|
|
54791
|
-
async _formatEntry(dirent,
|
|
54960
|
+
async _formatEntry(dirent, path6) {
|
|
54792
54961
|
let entry;
|
|
54793
54962
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
54794
54963
|
try {
|
|
54795
|
-
const fullPath = presolve(pjoin(
|
|
54964
|
+
const fullPath = presolve(pjoin(path6, basename7));
|
|
54796
54965
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename7 };
|
|
54797
54966
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
54798
54967
|
} catch (err) {
|
|
@@ -55192,16 +55361,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
55192
55361
|
};
|
|
55193
55362
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
55194
55363
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
55195
|
-
function createFsWatchInstance(
|
|
55364
|
+
function createFsWatchInstance(path6, options, listener, errHandler, emitRaw) {
|
|
55196
55365
|
const handleEvent = (rawEvent, evPath) => {
|
|
55197
|
-
listener(
|
|
55198
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
55199
|
-
if (evPath &&
|
|
55200
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
55366
|
+
listener(path6);
|
|
55367
|
+
emitRaw(rawEvent, evPath, { watchedPath: path6 });
|
|
55368
|
+
if (evPath && path6 !== evPath) {
|
|
55369
|
+
fsWatchBroadcast(sysPath.resolve(path6, evPath), KEY_LISTENERS, sysPath.join(path6, evPath));
|
|
55201
55370
|
}
|
|
55202
55371
|
};
|
|
55203
55372
|
try {
|
|
55204
|
-
return fs_watch(
|
|
55373
|
+
return fs_watch(path6, {
|
|
55205
55374
|
persistent: options.persistent
|
|
55206
55375
|
}, handleEvent);
|
|
55207
55376
|
} catch (error51) {
|
|
@@ -55217,12 +55386,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
55217
55386
|
listener(val1, val2, val3);
|
|
55218
55387
|
});
|
|
55219
55388
|
};
|
|
55220
|
-
var setFsWatchListener = (
|
|
55389
|
+
var setFsWatchListener = (path6, fullPath, options, handlers) => {
|
|
55221
55390
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
55222
55391
|
let cont = FsWatchInstances.get(fullPath);
|
|
55223
55392
|
let watcher;
|
|
55224
55393
|
if (!options.persistent) {
|
|
55225
|
-
watcher = createFsWatchInstance(
|
|
55394
|
+
watcher = createFsWatchInstance(path6, options, listener, errHandler, rawEmitter);
|
|
55226
55395
|
if (!watcher)
|
|
55227
55396
|
return;
|
|
55228
55397
|
return watcher.close.bind(watcher);
|
|
@@ -55233,7 +55402,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55233
55402
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
55234
55403
|
} else {
|
|
55235
55404
|
watcher = createFsWatchInstance(
|
|
55236
|
-
|
|
55405
|
+
path6,
|
|
55237
55406
|
options,
|
|
55238
55407
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
55239
55408
|
errHandler,
|
|
@@ -55248,7 +55417,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55248
55417
|
cont.watcherUnusable = true;
|
|
55249
55418
|
if (isWindows2 && error51.code === "EPERM") {
|
|
55250
55419
|
try {
|
|
55251
|
-
const fd = await open3(
|
|
55420
|
+
const fd = await open3(path6, "r");
|
|
55252
55421
|
await fd.close();
|
|
55253
55422
|
broadcastErr(error51);
|
|
55254
55423
|
} catch (err) {
|
|
@@ -55279,7 +55448,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55279
55448
|
};
|
|
55280
55449
|
};
|
|
55281
55450
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
55282
|
-
var setFsWatchFileListener = (
|
|
55451
|
+
var setFsWatchFileListener = (path6, fullPath, options, handlers) => {
|
|
55283
55452
|
const { listener, rawEmitter } = handlers;
|
|
55284
55453
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
55285
55454
|
const copts = cont && cont.options;
|
|
@@ -55301,7 +55470,7 @@ var setFsWatchFileListener = (path5, fullPath, options, handlers) => {
|
|
|
55301
55470
|
});
|
|
55302
55471
|
const currmtime = curr.mtimeMs;
|
|
55303
55472
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
55304
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
55473
|
+
foreach(cont.listeners, (listener2) => listener2(path6, curr));
|
|
55305
55474
|
}
|
|
55306
55475
|
})
|
|
55307
55476
|
};
|
|
@@ -55329,13 +55498,13 @@ var NodeFsHandler = class {
|
|
|
55329
55498
|
* @param listener on fs change
|
|
55330
55499
|
* @returns closer for the watcher instance
|
|
55331
55500
|
*/
|
|
55332
|
-
_watchWithNodeFs(
|
|
55501
|
+
_watchWithNodeFs(path6, listener) {
|
|
55333
55502
|
const opts = this.fsw.options;
|
|
55334
|
-
const directory = sysPath.dirname(
|
|
55335
|
-
const basename7 = sysPath.basename(
|
|
55503
|
+
const directory = sysPath.dirname(path6);
|
|
55504
|
+
const basename7 = sysPath.basename(path6);
|
|
55336
55505
|
const parent = this.fsw._getWatchedDir(directory);
|
|
55337
55506
|
parent.add(basename7);
|
|
55338
|
-
const absolutePath = sysPath.resolve(
|
|
55507
|
+
const absolutePath = sysPath.resolve(path6);
|
|
55339
55508
|
const options = {
|
|
55340
55509
|
persistent: opts.persistent
|
|
55341
55510
|
};
|
|
@@ -55345,12 +55514,12 @@ var NodeFsHandler = class {
|
|
|
55345
55514
|
if (opts.usePolling) {
|
|
55346
55515
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
55347
55516
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
55348
|
-
closer = setFsWatchFileListener(
|
|
55517
|
+
closer = setFsWatchFileListener(path6, absolutePath, options, {
|
|
55349
55518
|
listener,
|
|
55350
55519
|
rawEmitter: this.fsw._emitRaw
|
|
55351
55520
|
});
|
|
55352
55521
|
} else {
|
|
55353
|
-
closer = setFsWatchListener(
|
|
55522
|
+
closer = setFsWatchListener(path6, absolutePath, options, {
|
|
55354
55523
|
listener,
|
|
55355
55524
|
errHandler: this._boundHandleError,
|
|
55356
55525
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -55372,7 +55541,7 @@ var NodeFsHandler = class {
|
|
|
55372
55541
|
let prevStats = stats;
|
|
55373
55542
|
if (parent.has(basename7))
|
|
55374
55543
|
return;
|
|
55375
|
-
const listener = async (
|
|
55544
|
+
const listener = async (path6, newStats) => {
|
|
55376
55545
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
55377
55546
|
return;
|
|
55378
55547
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -55386,11 +55555,11 @@ var NodeFsHandler = class {
|
|
|
55386
55555
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
55387
55556
|
}
|
|
55388
55557
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
55389
|
-
this.fsw._closeFile(
|
|
55558
|
+
this.fsw._closeFile(path6);
|
|
55390
55559
|
prevStats = newStats2;
|
|
55391
55560
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
55392
55561
|
if (closer2)
|
|
55393
|
-
this.fsw._addPathCloser(
|
|
55562
|
+
this.fsw._addPathCloser(path6, closer2);
|
|
55394
55563
|
} else {
|
|
55395
55564
|
prevStats = newStats2;
|
|
55396
55565
|
}
|
|
@@ -55422,7 +55591,7 @@ var NodeFsHandler = class {
|
|
|
55422
55591
|
* @param item basename of this item
|
|
55423
55592
|
* @returns true if no more processing is needed for this entry.
|
|
55424
55593
|
*/
|
|
55425
|
-
async _handleSymlink(entry, directory,
|
|
55594
|
+
async _handleSymlink(entry, directory, path6, item) {
|
|
55426
55595
|
if (this.fsw.closed) {
|
|
55427
55596
|
return;
|
|
55428
55597
|
}
|
|
@@ -55432,7 +55601,7 @@ var NodeFsHandler = class {
|
|
|
55432
55601
|
this.fsw._incrReadyCount();
|
|
55433
55602
|
let linkPath;
|
|
55434
55603
|
try {
|
|
55435
|
-
linkPath = await fsrealpath(
|
|
55604
|
+
linkPath = await fsrealpath(path6);
|
|
55436
55605
|
} catch (e) {
|
|
55437
55606
|
this.fsw._emitReady();
|
|
55438
55607
|
return true;
|
|
@@ -55442,12 +55611,12 @@ var NodeFsHandler = class {
|
|
|
55442
55611
|
if (dir2.has(item)) {
|
|
55443
55612
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
55444
55613
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
55445
|
-
this.fsw._emit(EV.CHANGE,
|
|
55614
|
+
this.fsw._emit(EV.CHANGE, path6, entry.stats);
|
|
55446
55615
|
}
|
|
55447
55616
|
} else {
|
|
55448
55617
|
dir2.add(item);
|
|
55449
55618
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
55450
|
-
this.fsw._emit(EV.ADD,
|
|
55619
|
+
this.fsw._emit(EV.ADD, path6, entry.stats);
|
|
55451
55620
|
}
|
|
55452
55621
|
this.fsw._emitReady();
|
|
55453
55622
|
return true;
|
|
@@ -55476,9 +55645,9 @@ var NodeFsHandler = class {
|
|
|
55476
55645
|
return;
|
|
55477
55646
|
}
|
|
55478
55647
|
const item = entry.path;
|
|
55479
|
-
let
|
|
55648
|
+
let path6 = sysPath.join(directory, item);
|
|
55480
55649
|
current.add(item);
|
|
55481
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
55650
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path6, item)) {
|
|
55482
55651
|
return;
|
|
55483
55652
|
}
|
|
55484
55653
|
if (this.fsw.closed) {
|
|
@@ -55487,8 +55656,8 @@ var NodeFsHandler = class {
|
|
|
55487
55656
|
}
|
|
55488
55657
|
if (item === target || !target && !previous.has(item)) {
|
|
55489
55658
|
this.fsw._incrReadyCount();
|
|
55490
|
-
|
|
55491
|
-
this._addToNodeFs(
|
|
55659
|
+
path6 = sysPath.join(dir2, sysPath.relative(dir2, path6));
|
|
55660
|
+
this._addToNodeFs(path6, initialAdd, wh, depth + 1);
|
|
55492
55661
|
}
|
|
55493
55662
|
}).on(EV.ERROR, this._boundHandleError);
|
|
55494
55663
|
return new Promise((resolve10, reject) => {
|
|
@@ -55557,13 +55726,13 @@ var NodeFsHandler = class {
|
|
|
55557
55726
|
* @param depth Child path actually targeted for watch
|
|
55558
55727
|
* @param target Child path actually targeted for watch
|
|
55559
55728
|
*/
|
|
55560
|
-
async _addToNodeFs(
|
|
55729
|
+
async _addToNodeFs(path6, initialAdd, priorWh, depth, target) {
|
|
55561
55730
|
const ready = this.fsw._emitReady;
|
|
55562
|
-
if (this.fsw._isIgnored(
|
|
55731
|
+
if (this.fsw._isIgnored(path6) || this.fsw.closed) {
|
|
55563
55732
|
ready();
|
|
55564
55733
|
return false;
|
|
55565
55734
|
}
|
|
55566
|
-
const wh = this.fsw._getWatchHelpers(
|
|
55735
|
+
const wh = this.fsw._getWatchHelpers(path6);
|
|
55567
55736
|
if (priorWh) {
|
|
55568
55737
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
55569
55738
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -55579,8 +55748,8 @@ var NodeFsHandler = class {
|
|
|
55579
55748
|
const follow = this.fsw.options.followSymlinks;
|
|
55580
55749
|
let closer;
|
|
55581
55750
|
if (stats.isDirectory()) {
|
|
55582
|
-
const absPath = sysPath.resolve(
|
|
55583
|
-
const targetPath = follow ? await fsrealpath(
|
|
55751
|
+
const absPath = sysPath.resolve(path6);
|
|
55752
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
55584
55753
|
if (this.fsw.closed)
|
|
55585
55754
|
return;
|
|
55586
55755
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -55590,29 +55759,29 @@ var NodeFsHandler = class {
|
|
|
55590
55759
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
55591
55760
|
}
|
|
55592
55761
|
} else if (stats.isSymbolicLink()) {
|
|
55593
|
-
const targetPath = follow ? await fsrealpath(
|
|
55762
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
55594
55763
|
if (this.fsw.closed)
|
|
55595
55764
|
return;
|
|
55596
55765
|
const parent = sysPath.dirname(wh.watchPath);
|
|
55597
55766
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
55598
55767
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
55599
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
55768
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path6, wh, targetPath);
|
|
55600
55769
|
if (this.fsw.closed)
|
|
55601
55770
|
return;
|
|
55602
55771
|
if (targetPath !== void 0) {
|
|
55603
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
55772
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path6), targetPath);
|
|
55604
55773
|
}
|
|
55605
55774
|
} else {
|
|
55606
55775
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
55607
55776
|
}
|
|
55608
55777
|
ready();
|
|
55609
55778
|
if (closer)
|
|
55610
|
-
this.fsw._addPathCloser(
|
|
55779
|
+
this.fsw._addPathCloser(path6, closer);
|
|
55611
55780
|
return false;
|
|
55612
55781
|
} catch (error51) {
|
|
55613
55782
|
if (this.fsw._handleError(error51)) {
|
|
55614
55783
|
ready();
|
|
55615
|
-
return
|
|
55784
|
+
return path6;
|
|
55616
55785
|
}
|
|
55617
55786
|
}
|
|
55618
55787
|
}
|
|
@@ -55655,26 +55824,26 @@ function createPattern(matcher) {
|
|
|
55655
55824
|
}
|
|
55656
55825
|
return () => false;
|
|
55657
55826
|
}
|
|
55658
|
-
function normalizePath(
|
|
55659
|
-
if (typeof
|
|
55827
|
+
function normalizePath(path6) {
|
|
55828
|
+
if (typeof path6 !== "string")
|
|
55660
55829
|
throw new Error("string expected");
|
|
55661
|
-
|
|
55662
|
-
|
|
55830
|
+
path6 = sysPath2.normalize(path6);
|
|
55831
|
+
path6 = path6.replace(/\\/g, "/");
|
|
55663
55832
|
let prepend = false;
|
|
55664
|
-
if (
|
|
55833
|
+
if (path6.startsWith("//"))
|
|
55665
55834
|
prepend = true;
|
|
55666
55835
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
55667
|
-
while (
|
|
55668
|
-
|
|
55836
|
+
while (path6.match(DOUBLE_SLASH_RE2))
|
|
55837
|
+
path6 = path6.replace(DOUBLE_SLASH_RE2, "/");
|
|
55669
55838
|
if (prepend)
|
|
55670
|
-
|
|
55671
|
-
return
|
|
55839
|
+
path6 = "/" + path6;
|
|
55840
|
+
return path6;
|
|
55672
55841
|
}
|
|
55673
55842
|
function matchPatterns(patterns, testString, stats) {
|
|
55674
|
-
const
|
|
55843
|
+
const path6 = normalizePath(testString);
|
|
55675
55844
|
for (let index = 0; index < patterns.length; index++) {
|
|
55676
55845
|
const pattern = patterns[index];
|
|
55677
|
-
if (pattern(
|
|
55846
|
+
if (pattern(path6, stats)) {
|
|
55678
55847
|
return true;
|
|
55679
55848
|
}
|
|
55680
55849
|
}
|
|
@@ -55714,19 +55883,19 @@ var toUnix = (string4) => {
|
|
|
55714
55883
|
}
|
|
55715
55884
|
return str2;
|
|
55716
55885
|
};
|
|
55717
|
-
var normalizePathToUnix = (
|
|
55718
|
-
var normalizeIgnored = (cwd = "") => (
|
|
55719
|
-
if (typeof
|
|
55720
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
55886
|
+
var normalizePathToUnix = (path6) => toUnix(sysPath2.normalize(toUnix(path6)));
|
|
55887
|
+
var normalizeIgnored = (cwd = "") => (path6) => {
|
|
55888
|
+
if (typeof path6 === "string") {
|
|
55889
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path6) ? path6 : sysPath2.join(cwd, path6));
|
|
55721
55890
|
} else {
|
|
55722
|
-
return
|
|
55891
|
+
return path6;
|
|
55723
55892
|
}
|
|
55724
55893
|
};
|
|
55725
|
-
var getAbsolutePath = (
|
|
55726
|
-
if (sysPath2.isAbsolute(
|
|
55727
|
-
return
|
|
55894
|
+
var getAbsolutePath = (path6, cwd) => {
|
|
55895
|
+
if (sysPath2.isAbsolute(path6)) {
|
|
55896
|
+
return path6;
|
|
55728
55897
|
}
|
|
55729
|
-
return sysPath2.join(cwd,
|
|
55898
|
+
return sysPath2.join(cwd, path6);
|
|
55730
55899
|
};
|
|
55731
55900
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
55732
55901
|
var DirEntry = class {
|
|
@@ -55781,10 +55950,10 @@ var DirEntry = class {
|
|
|
55781
55950
|
var STAT_METHOD_F = "stat";
|
|
55782
55951
|
var STAT_METHOD_L = "lstat";
|
|
55783
55952
|
var WatchHelper = class {
|
|
55784
|
-
constructor(
|
|
55953
|
+
constructor(path6, follow, fsw) {
|
|
55785
55954
|
this.fsw = fsw;
|
|
55786
|
-
const watchPath =
|
|
55787
|
-
this.path =
|
|
55955
|
+
const watchPath = path6;
|
|
55956
|
+
this.path = path6 = path6.replace(REPLACER_RE, "");
|
|
55788
55957
|
this.watchPath = watchPath;
|
|
55789
55958
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
55790
55959
|
this.dirParts = [];
|
|
@@ -55906,20 +56075,20 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
55906
56075
|
this._closePromise = void 0;
|
|
55907
56076
|
let paths = unifyPaths(paths_);
|
|
55908
56077
|
if (cwd) {
|
|
55909
|
-
paths = paths.map((
|
|
55910
|
-
const absPath = getAbsolutePath(
|
|
56078
|
+
paths = paths.map((path6) => {
|
|
56079
|
+
const absPath = getAbsolutePath(path6, cwd);
|
|
55911
56080
|
return absPath;
|
|
55912
56081
|
});
|
|
55913
56082
|
}
|
|
55914
|
-
paths.forEach((
|
|
55915
|
-
this._removeIgnoredPath(
|
|
56083
|
+
paths.forEach((path6) => {
|
|
56084
|
+
this._removeIgnoredPath(path6);
|
|
55916
56085
|
});
|
|
55917
56086
|
this._userIgnored = void 0;
|
|
55918
56087
|
if (!this._readyCount)
|
|
55919
56088
|
this._readyCount = 0;
|
|
55920
56089
|
this._readyCount += paths.length;
|
|
55921
|
-
Promise.all(paths.map(async (
|
|
55922
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
56090
|
+
Promise.all(paths.map(async (path6) => {
|
|
56091
|
+
const res = await this._nodeFsHandler._addToNodeFs(path6, !_internal, void 0, 0, _origAdd);
|
|
55923
56092
|
if (res)
|
|
55924
56093
|
this._emitReady();
|
|
55925
56094
|
return res;
|
|
@@ -55941,17 +56110,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
55941
56110
|
return this;
|
|
55942
56111
|
const paths = unifyPaths(paths_);
|
|
55943
56112
|
const { cwd } = this.options;
|
|
55944
|
-
paths.forEach((
|
|
55945
|
-
if (!sysPath2.isAbsolute(
|
|
56113
|
+
paths.forEach((path6) => {
|
|
56114
|
+
if (!sysPath2.isAbsolute(path6) && !this._closers.has(path6)) {
|
|
55946
56115
|
if (cwd)
|
|
55947
|
-
|
|
55948
|
-
|
|
56116
|
+
path6 = sysPath2.join(cwd, path6);
|
|
56117
|
+
path6 = sysPath2.resolve(path6);
|
|
55949
56118
|
}
|
|
55950
|
-
this._closePath(
|
|
55951
|
-
this._addIgnoredPath(
|
|
55952
|
-
if (this._watched.has(
|
|
56119
|
+
this._closePath(path6);
|
|
56120
|
+
this._addIgnoredPath(path6);
|
|
56121
|
+
if (this._watched.has(path6)) {
|
|
55953
56122
|
this._addIgnoredPath({
|
|
55954
|
-
path:
|
|
56123
|
+
path: path6,
|
|
55955
56124
|
recursive: true
|
|
55956
56125
|
});
|
|
55957
56126
|
}
|
|
@@ -56015,38 +56184,38 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56015
56184
|
* @param stats arguments to be passed with event
|
|
56016
56185
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
56017
56186
|
*/
|
|
56018
|
-
async _emit(event,
|
|
56187
|
+
async _emit(event, path6, stats) {
|
|
56019
56188
|
if (this.closed)
|
|
56020
56189
|
return;
|
|
56021
56190
|
const opts = this.options;
|
|
56022
56191
|
if (isWindows2)
|
|
56023
|
-
|
|
56192
|
+
path6 = sysPath2.normalize(path6);
|
|
56024
56193
|
if (opts.cwd)
|
|
56025
|
-
|
|
56026
|
-
const args = [
|
|
56194
|
+
path6 = sysPath2.relative(opts.cwd, path6);
|
|
56195
|
+
const args = [path6];
|
|
56027
56196
|
if (stats != null)
|
|
56028
56197
|
args.push(stats);
|
|
56029
56198
|
const awf = opts.awaitWriteFinish;
|
|
56030
56199
|
let pw;
|
|
56031
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
56200
|
+
if (awf && (pw = this._pendingWrites.get(path6))) {
|
|
56032
56201
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
56033
56202
|
return this;
|
|
56034
56203
|
}
|
|
56035
56204
|
if (opts.atomic) {
|
|
56036
56205
|
if (event === EVENTS.UNLINK) {
|
|
56037
|
-
this._pendingUnlinks.set(
|
|
56206
|
+
this._pendingUnlinks.set(path6, [event, ...args]);
|
|
56038
56207
|
setTimeout(() => {
|
|
56039
|
-
this._pendingUnlinks.forEach((entry,
|
|
56208
|
+
this._pendingUnlinks.forEach((entry, path7) => {
|
|
56040
56209
|
this.emit(...entry);
|
|
56041
56210
|
this.emit(EVENTS.ALL, ...entry);
|
|
56042
|
-
this._pendingUnlinks.delete(
|
|
56211
|
+
this._pendingUnlinks.delete(path7);
|
|
56043
56212
|
});
|
|
56044
56213
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
56045
56214
|
return this;
|
|
56046
56215
|
}
|
|
56047
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
56216
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path6)) {
|
|
56048
56217
|
event = EVENTS.CHANGE;
|
|
56049
|
-
this._pendingUnlinks.delete(
|
|
56218
|
+
this._pendingUnlinks.delete(path6);
|
|
56050
56219
|
}
|
|
56051
56220
|
}
|
|
56052
56221
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -56064,16 +56233,16 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56064
56233
|
this.emitWithAll(event, args);
|
|
56065
56234
|
}
|
|
56066
56235
|
};
|
|
56067
|
-
this._awaitWriteFinish(
|
|
56236
|
+
this._awaitWriteFinish(path6, awf.stabilityThreshold, event, awfEmit);
|
|
56068
56237
|
return this;
|
|
56069
56238
|
}
|
|
56070
56239
|
if (event === EVENTS.CHANGE) {
|
|
56071
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
56240
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path6, 50);
|
|
56072
56241
|
if (isThrottled)
|
|
56073
56242
|
return this;
|
|
56074
56243
|
}
|
|
56075
56244
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
56076
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
56245
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path6) : path6;
|
|
56077
56246
|
let stats2;
|
|
56078
56247
|
try {
|
|
56079
56248
|
stats2 = await stat6(fullPath);
|
|
@@ -56104,23 +56273,23 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56104
56273
|
* @param timeout duration of time to suppress duplicate actions
|
|
56105
56274
|
* @returns tracking object or false if action should be suppressed
|
|
56106
56275
|
*/
|
|
56107
|
-
_throttle(actionType,
|
|
56276
|
+
_throttle(actionType, path6, timeout) {
|
|
56108
56277
|
if (!this._throttled.has(actionType)) {
|
|
56109
56278
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
56110
56279
|
}
|
|
56111
56280
|
const action = this._throttled.get(actionType);
|
|
56112
56281
|
if (!action)
|
|
56113
56282
|
throw new Error("invalid throttle");
|
|
56114
|
-
const actionPath = action.get(
|
|
56283
|
+
const actionPath = action.get(path6);
|
|
56115
56284
|
if (actionPath) {
|
|
56116
56285
|
actionPath.count++;
|
|
56117
56286
|
return false;
|
|
56118
56287
|
}
|
|
56119
56288
|
let timeoutObject;
|
|
56120
56289
|
const clear = () => {
|
|
56121
|
-
const item = action.get(
|
|
56290
|
+
const item = action.get(path6);
|
|
56122
56291
|
const count = item ? item.count : 0;
|
|
56123
|
-
action.delete(
|
|
56292
|
+
action.delete(path6);
|
|
56124
56293
|
clearTimeout(timeoutObject);
|
|
56125
56294
|
if (item)
|
|
56126
56295
|
clearTimeout(item.timeoutObject);
|
|
@@ -56128,7 +56297,7 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56128
56297
|
};
|
|
56129
56298
|
timeoutObject = setTimeout(clear, timeout);
|
|
56130
56299
|
const thr = { timeoutObject, clear, count: 0 };
|
|
56131
|
-
action.set(
|
|
56300
|
+
action.set(path6, thr);
|
|
56132
56301
|
return thr;
|
|
56133
56302
|
}
|
|
56134
56303
|
_incrReadyCount() {
|
|
@@ -56142,44 +56311,44 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56142
56311
|
* @param event
|
|
56143
56312
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
56144
56313
|
*/
|
|
56145
|
-
_awaitWriteFinish(
|
|
56314
|
+
_awaitWriteFinish(path6, threshold, event, awfEmit) {
|
|
56146
56315
|
const awf = this.options.awaitWriteFinish;
|
|
56147
56316
|
if (typeof awf !== "object")
|
|
56148
56317
|
return;
|
|
56149
56318
|
const pollInterval = awf.pollInterval;
|
|
56150
56319
|
let timeoutHandler;
|
|
56151
|
-
let fullPath =
|
|
56152
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
56153
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
56320
|
+
let fullPath = path6;
|
|
56321
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path6)) {
|
|
56322
|
+
fullPath = sysPath2.join(this.options.cwd, path6);
|
|
56154
56323
|
}
|
|
56155
56324
|
const now2 = /* @__PURE__ */ new Date();
|
|
56156
56325
|
const writes = this._pendingWrites;
|
|
56157
56326
|
function awaitWriteFinishFn(prevStat) {
|
|
56158
56327
|
statcb(fullPath, (err, curStat) => {
|
|
56159
|
-
if (err || !writes.has(
|
|
56328
|
+
if (err || !writes.has(path6)) {
|
|
56160
56329
|
if (err && err.code !== "ENOENT")
|
|
56161
56330
|
awfEmit(err);
|
|
56162
56331
|
return;
|
|
56163
56332
|
}
|
|
56164
56333
|
const now3 = Number(/* @__PURE__ */ new Date());
|
|
56165
56334
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
56166
|
-
writes.get(
|
|
56335
|
+
writes.get(path6).lastChange = now3;
|
|
56167
56336
|
}
|
|
56168
|
-
const pw = writes.get(
|
|
56337
|
+
const pw = writes.get(path6);
|
|
56169
56338
|
const df = now3 - pw.lastChange;
|
|
56170
56339
|
if (df >= threshold) {
|
|
56171
|
-
writes.delete(
|
|
56340
|
+
writes.delete(path6);
|
|
56172
56341
|
awfEmit(void 0, curStat);
|
|
56173
56342
|
} else {
|
|
56174
56343
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
56175
56344
|
}
|
|
56176
56345
|
});
|
|
56177
56346
|
}
|
|
56178
|
-
if (!writes.has(
|
|
56179
|
-
writes.set(
|
|
56347
|
+
if (!writes.has(path6)) {
|
|
56348
|
+
writes.set(path6, {
|
|
56180
56349
|
lastChange: now2,
|
|
56181
56350
|
cancelWait: () => {
|
|
56182
|
-
writes.delete(
|
|
56351
|
+
writes.delete(path6);
|
|
56183
56352
|
clearTimeout(timeoutHandler);
|
|
56184
56353
|
return event;
|
|
56185
56354
|
}
|
|
@@ -56190,8 +56359,8 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56190
56359
|
/**
|
|
56191
56360
|
* Determines whether user has asked to ignore this path.
|
|
56192
56361
|
*/
|
|
56193
|
-
_isIgnored(
|
|
56194
|
-
if (this.options.atomic && DOT_RE.test(
|
|
56362
|
+
_isIgnored(path6, stats) {
|
|
56363
|
+
if (this.options.atomic && DOT_RE.test(path6))
|
|
56195
56364
|
return true;
|
|
56196
56365
|
if (!this._userIgnored) {
|
|
56197
56366
|
const { cwd } = this.options;
|
|
@@ -56201,17 +56370,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56201
56370
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
56202
56371
|
this._userIgnored = anymatch(list, void 0);
|
|
56203
56372
|
}
|
|
56204
|
-
return this._userIgnored(
|
|
56373
|
+
return this._userIgnored(path6, stats);
|
|
56205
56374
|
}
|
|
56206
|
-
_isntIgnored(
|
|
56207
|
-
return !this._isIgnored(
|
|
56375
|
+
_isntIgnored(path6, stat7) {
|
|
56376
|
+
return !this._isIgnored(path6, stat7);
|
|
56208
56377
|
}
|
|
56209
56378
|
/**
|
|
56210
56379
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
56211
56380
|
* @param path file or directory pattern being watched
|
|
56212
56381
|
*/
|
|
56213
|
-
_getWatchHelpers(
|
|
56214
|
-
return new WatchHelper(
|
|
56382
|
+
_getWatchHelpers(path6) {
|
|
56383
|
+
return new WatchHelper(path6, this.options.followSymlinks, this);
|
|
56215
56384
|
}
|
|
56216
56385
|
// Directory helpers
|
|
56217
56386
|
// -----------------
|
|
@@ -56243,63 +56412,63 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56243
56412
|
* @param item base path of item/directory
|
|
56244
56413
|
*/
|
|
56245
56414
|
_remove(directory, item, isDirectory) {
|
|
56246
|
-
const
|
|
56247
|
-
const fullPath = sysPath2.resolve(
|
|
56248
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
56249
|
-
if (!this._throttle("remove",
|
|
56415
|
+
const path6 = sysPath2.join(directory, item);
|
|
56416
|
+
const fullPath = sysPath2.resolve(path6);
|
|
56417
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path6) || this._watched.has(fullPath);
|
|
56418
|
+
if (!this._throttle("remove", path6, 100))
|
|
56250
56419
|
return;
|
|
56251
56420
|
if (!isDirectory && this._watched.size === 1) {
|
|
56252
56421
|
this.add(directory, item, true);
|
|
56253
56422
|
}
|
|
56254
|
-
const wp = this._getWatchedDir(
|
|
56423
|
+
const wp = this._getWatchedDir(path6);
|
|
56255
56424
|
const nestedDirectoryChildren = wp.getChildren();
|
|
56256
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
56425
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path6, nested));
|
|
56257
56426
|
const parent = this._getWatchedDir(directory);
|
|
56258
56427
|
const wasTracked = parent.has(item);
|
|
56259
56428
|
parent.remove(item);
|
|
56260
56429
|
if (this._symlinkPaths.has(fullPath)) {
|
|
56261
56430
|
this._symlinkPaths.delete(fullPath);
|
|
56262
56431
|
}
|
|
56263
|
-
let relPath =
|
|
56432
|
+
let relPath = path6;
|
|
56264
56433
|
if (this.options.cwd)
|
|
56265
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
56434
|
+
relPath = sysPath2.relative(this.options.cwd, path6);
|
|
56266
56435
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
56267
56436
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
56268
56437
|
if (event === EVENTS.ADD)
|
|
56269
56438
|
return;
|
|
56270
56439
|
}
|
|
56271
|
-
this._watched.delete(
|
|
56440
|
+
this._watched.delete(path6);
|
|
56272
56441
|
this._watched.delete(fullPath);
|
|
56273
56442
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
56274
|
-
if (wasTracked && !this._isIgnored(
|
|
56275
|
-
this._emit(eventName,
|
|
56276
|
-
this._closePath(
|
|
56443
|
+
if (wasTracked && !this._isIgnored(path6))
|
|
56444
|
+
this._emit(eventName, path6);
|
|
56445
|
+
this._closePath(path6);
|
|
56277
56446
|
}
|
|
56278
56447
|
/**
|
|
56279
56448
|
* Closes all watchers for a path
|
|
56280
56449
|
*/
|
|
56281
|
-
_closePath(
|
|
56282
|
-
this._closeFile(
|
|
56283
|
-
const dir2 = sysPath2.dirname(
|
|
56284
|
-
this._getWatchedDir(dir2).remove(sysPath2.basename(
|
|
56450
|
+
_closePath(path6) {
|
|
56451
|
+
this._closeFile(path6);
|
|
56452
|
+
const dir2 = sysPath2.dirname(path6);
|
|
56453
|
+
this._getWatchedDir(dir2).remove(sysPath2.basename(path6));
|
|
56285
56454
|
}
|
|
56286
56455
|
/**
|
|
56287
56456
|
* Closes only file-specific watchers
|
|
56288
56457
|
*/
|
|
56289
|
-
_closeFile(
|
|
56290
|
-
const closers = this._closers.get(
|
|
56458
|
+
_closeFile(path6) {
|
|
56459
|
+
const closers = this._closers.get(path6);
|
|
56291
56460
|
if (!closers)
|
|
56292
56461
|
return;
|
|
56293
56462
|
closers.forEach((closer) => closer());
|
|
56294
|
-
this._closers.delete(
|
|
56463
|
+
this._closers.delete(path6);
|
|
56295
56464
|
}
|
|
56296
|
-
_addPathCloser(
|
|
56465
|
+
_addPathCloser(path6, closer) {
|
|
56297
56466
|
if (!closer)
|
|
56298
56467
|
return;
|
|
56299
|
-
let list = this._closers.get(
|
|
56468
|
+
let list = this._closers.get(path6);
|
|
56300
56469
|
if (!list) {
|
|
56301
56470
|
list = [];
|
|
56302
|
-
this._closers.set(
|
|
56471
|
+
this._closers.set(path6, list);
|
|
56303
56472
|
}
|
|
56304
56473
|
list.push(closer);
|
|
56305
56474
|
}
|
|
@@ -57464,9 +57633,9 @@ function friendlyLabel(id, label) {
|
|
|
57464
57633
|
return `Command line (${label})`;
|
|
57465
57634
|
}
|
|
57466
57635
|
}
|
|
57467
|
-
function mk(id,
|
|
57636
|
+
function mk(id, path6, isDefault, label) {
|
|
57468
57637
|
const lbl = label ?? id;
|
|
57469
|
-
return { id, label: lbl, friendly: friendlyLabel(id, lbl), path:
|
|
57638
|
+
return { id, label: lbl, friendly: friendlyLabel(id, lbl), path: path6, default: isDefault || void 0 };
|
|
57470
57639
|
}
|
|
57471
57640
|
function listInterpreters() {
|
|
57472
57641
|
return process.platform === "win32" ? listWindows() : listUnix();
|
|
@@ -57475,11 +57644,11 @@ function listUnix() {
|
|
|
57475
57644
|
const out = [];
|
|
57476
57645
|
const seen = /* @__PURE__ */ new Set();
|
|
57477
57646
|
const loginShell = process.env.SHELL || "";
|
|
57478
|
-
const add = (id,
|
|
57479
|
-
if (!
|
|
57647
|
+
const add = (id, path6) => {
|
|
57648
|
+
if (!path6 || seen.has(path6) || !existsSync14(path6))
|
|
57480
57649
|
return;
|
|
57481
|
-
seen.add(
|
|
57482
|
-
out.push(mk(id,
|
|
57650
|
+
seen.add(path6);
|
|
57651
|
+
out.push(mk(id, path6, path6 === loginShell));
|
|
57483
57652
|
};
|
|
57484
57653
|
if (loginShell)
|
|
57485
57654
|
add(idForPath(loginShell), loginShell);
|
|
@@ -57507,9 +57676,9 @@ function listWindows() {
|
|
|
57507
57676
|
const pf = process.env.ProgramFiles || "C:\\Program Files";
|
|
57508
57677
|
const gitBash = `${pf}\\Git\\bin\\bash.exe`;
|
|
57509
57678
|
const pwsh7 = `${pf}\\PowerShell\\7\\pwsh.exe`;
|
|
57510
|
-
const add = (id,
|
|
57511
|
-
if (
|
|
57512
|
-
out.push(mk(id,
|
|
57679
|
+
const add = (id, path6, label, isDefault = false) => {
|
|
57680
|
+
if (path6 && existsSync14(path6))
|
|
57681
|
+
out.push(mk(id, path6, isDefault, label));
|
|
57513
57682
|
};
|
|
57514
57683
|
add("powershell", winPwsh, "Windows PowerShell", true);
|
|
57515
57684
|
add("pwsh", pwsh7, "pwsh");
|
|
@@ -58205,7 +58374,8 @@ async function handleInboundAgent(msg, driverClientId) {
|
|
|
58205
58374
|
driverBySession.set(msg.sessionId, driverClientId);
|
|
58206
58375
|
const messages = await b.getMessages(msg.sessionId).catch(() => []);
|
|
58207
58376
|
const artifacts = await (b.getSessionArtifacts?.(msg.sessionId, msg.projectDir).catch(() => []) ?? Promise.resolve([]));
|
|
58208
|
-
|
|
58377
|
+
const sessionCostUsd = await (b.getSessionCost?.(msg.sessionId, msg.projectDir).catch(() => 0) ?? Promise.resolve(0));
|
|
58378
|
+
send2("agent", { type: "session:messages", sessionId: msg.sessionId, messages, artifacts, ...sessionCostUsd > 0 ? { sessionCostUsd } : {} }, route2);
|
|
58209
58379
|
break;
|
|
58210
58380
|
}
|
|
58211
58381
|
case "session:summarize": {
|
|
@@ -58227,6 +58397,9 @@ async function handleInboundAgent(msg, driverClientId) {
|
|
|
58227
58397
|
case "agent:trace":
|
|
58228
58398
|
void Promise.resolve(b.getTrace?.(msg.sessionId, msg.turnId, msg.projectDir) ?? null).then((trace) => send2("agent", { type: "agent:trace", sessionId: msg.sessionId, turnId: msg.turnId, clientRequestId: msg.clientRequestId, trace: trace ?? null }, route2));
|
|
58229
58399
|
break;
|
|
58400
|
+
case "agent:subagentMessages":
|
|
58401
|
+
void Promise.resolve(b.getSubagentMessages?.(msg.sessionId, msg.agentId, msg.projectDir) ?? []).then((messages) => send2("agent", { type: "agent:subagentMessages", sessionId: msg.sessionId, agentId: msg.agentId, clientRequestId: msg.clientRequestId, messages }, route2));
|
|
58402
|
+
break;
|
|
58230
58403
|
case "session:merge":
|
|
58231
58404
|
void b.mergeSessions?.(msg.sessionIds, { projectDir: msg.projectDir, title: msg.title, clientRequestId: msg.clientRequestId, origin }).catch(() => {
|
|
58232
58405
|
});
|
|
@@ -58979,7 +59152,8 @@ async function startLocalServer(opts) {
|
|
|
58979
59152
|
case "session:resume": {
|
|
58980
59153
|
const messages = await b.getMessages(msg.sessionId).catch(() => []);
|
|
58981
59154
|
const artifacts = await (b.getSessionArtifacts?.(msg.sessionId, msg.projectDir).catch(() => []) ?? Promise.resolve([]));
|
|
58982
|
-
|
|
59155
|
+
const sessionCostUsd = await (b.getSessionCost?.(msg.sessionId, msg.projectDir).catch(() => 0) ?? Promise.resolve(0));
|
|
59156
|
+
send3("agent", { type: "session:messages", sessionId: msg.sessionId, messages, artifacts, ...sessionCostUsd > 0 ? { sessionCostUsd } : {} });
|
|
58983
59157
|
break;
|
|
58984
59158
|
}
|
|
58985
59159
|
case "session:summarize": {
|
|
@@ -59001,6 +59175,9 @@ async function startLocalServer(opts) {
|
|
|
59001
59175
|
case "agent:trace":
|
|
59002
59176
|
void Promise.resolve(b.getTrace?.(msg.sessionId, msg.turnId, msg.projectDir) ?? null).then((trace) => send3("agent", { type: "agent:trace", sessionId: msg.sessionId, turnId: msg.turnId, clientRequestId: msg.clientRequestId, trace: trace ?? null }));
|
|
59003
59177
|
break;
|
|
59178
|
+
case "agent:subagentMessages":
|
|
59179
|
+
void Promise.resolve(b.getSubagentMessages?.(msg.sessionId, msg.agentId, msg.projectDir) ?? []).then((messages) => send3("agent", { type: "agent:subagentMessages", sessionId: msg.sessionId, agentId: msg.agentId, clientRequestId: msg.clientRequestId, messages }));
|
|
59180
|
+
break;
|
|
59004
59181
|
case "session:merge":
|
|
59005
59182
|
void b.mergeSessions?.(msg.sessionIds, { projectDir: msg.projectDir, title: msg.title, clientRequestId: msg.clientRequestId, origin: loopbackOrigin }).catch(() => {
|
|
59006
59183
|
});
|