tesseract-agent 0.8.1 → 0.8.2
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 +417 -301
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -4557,17 +4557,17 @@ function tessExt(token2) {
|
|
|
4557
4557
|
}
|
|
4558
4558
|
function walkTokens(tree) {
|
|
4559
4559
|
const out = [];
|
|
4560
|
-
const rec = (node,
|
|
4560
|
+
const rec = (node, path6) => {
|
|
4561
4561
|
if (!isObj(node))
|
|
4562
4562
|
return;
|
|
4563
4563
|
if (isToken(node)) {
|
|
4564
|
-
out.push({ path:
|
|
4564
|
+
out.push({ path: path6, token: node });
|
|
4565
4565
|
return;
|
|
4566
4566
|
}
|
|
4567
4567
|
for (const key2 of Object.keys(node)) {
|
|
4568
4568
|
if (key2.startsWith("$"))
|
|
4569
4569
|
continue;
|
|
4570
|
-
rec(node[key2], [...
|
|
4570
|
+
rec(node[key2], [...path6, key2]);
|
|
4571
4571
|
}
|
|
4572
4572
|
};
|
|
4573
4573
|
rec(tree, []);
|
|
@@ -4583,13 +4583,13 @@ function stringifyValue(v) {
|
|
|
4583
4583
|
return String(v);
|
|
4584
4584
|
}
|
|
4585
4585
|
function flattenForDisplay(tree) {
|
|
4586
|
-
return walkTokens(tree).map(({ path:
|
|
4586
|
+
return walkTokens(tree).map(({ path: path6, token: token2 }) => {
|
|
4587
4587
|
const dark = tessExt(token2)?.modes?.dark;
|
|
4588
4588
|
return {
|
|
4589
|
-
path:
|
|
4590
|
-
dotPath:
|
|
4591
|
-
group:
|
|
4592
|
-
label:
|
|
4589
|
+
path: path6,
|
|
4590
|
+
dotPath: path6.join("."),
|
|
4591
|
+
group: path6.slice(0, -1).join(" \xB7 "),
|
|
4592
|
+
label: path6[path6.length - 1] ?? "",
|
|
4593
4593
|
type: token2.$type,
|
|
4594
4594
|
value: stringifyValue(token2.$value),
|
|
4595
4595
|
isColor: token2.$type === "color",
|
|
@@ -4600,7 +4600,7 @@ function flattenForDisplay(tree) {
|
|
|
4600
4600
|
function kebab(s) {
|
|
4601
4601
|
return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
4602
4602
|
}
|
|
4603
|
-
function tokenCssVarName(
|
|
4603
|
+
function tokenCssVarName(path6, token2) {
|
|
4604
4604
|
const override = token2 ? tessExt(token2)?.cssVar : void 0;
|
|
4605
4605
|
if (override) {
|
|
4606
4606
|
const name = override.startsWith("--") ? override : `--${override}`;
|
|
@@ -4608,12 +4608,12 @@ function tokenCssVarName(path5, token2) {
|
|
|
4608
4608
|
return name;
|
|
4609
4609
|
}
|
|
4610
4610
|
for (const { match, prefix } of VAR_ALIASES) {
|
|
4611
|
-
if (match.length <=
|
|
4612
|
-
const rest =
|
|
4611
|
+
if (match.length <= path6.length && match.every((seg, i) => path6[i] === seg)) {
|
|
4612
|
+
const rest = path6.slice(match.length).map(kebab).filter(Boolean);
|
|
4613
4613
|
return ["--" + prefix, ...rest].join("-");
|
|
4614
4614
|
}
|
|
4615
4615
|
}
|
|
4616
|
-
return ["--token", ...
|
|
4616
|
+
return ["--token", ...path6.map(kebab).filter(Boolean)].join("-");
|
|
4617
4617
|
}
|
|
4618
4618
|
function categoryRank(top) {
|
|
4619
4619
|
const i = CATEGORY_ORDER.indexOf(top ?? "");
|
|
@@ -4647,8 +4647,8 @@ function tokensToCss(input) {
|
|
|
4647
4647
|
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
4648
|
const root = [];
|
|
4649
4649
|
const dark = [];
|
|
4650
|
-
for (const { path:
|
|
4651
|
-
const name = tokenCssVarName(
|
|
4650
|
+
for (const { path: path6, token: token2 } of ordered) {
|
|
4651
|
+
const name = tokenCssVarName(path6, token2);
|
|
4652
4652
|
root.push(` ${name}: ${cssValue(token2.$type, token2.$value)};`);
|
|
4653
4653
|
const d = tessExt(token2)?.modes?.dark;
|
|
4654
4654
|
if (d !== void 0)
|
|
@@ -4902,10 +4902,10 @@ function applyDesignPack(current, packTokens, info, opts) {
|
|
|
4902
4902
|
const { mode } = opts;
|
|
4903
4903
|
const writeLeaves = (base, keep) => {
|
|
4904
4904
|
let acc = base;
|
|
4905
|
-
for (const { path:
|
|
4906
|
-
if (keep && !keep(
|
|
4905
|
+
for (const { path: path6, token: token2 } of walkTokens(pack)) {
|
|
4906
|
+
if (keep && !keep(path6))
|
|
4907
4907
|
continue;
|
|
4908
|
-
acc = setTokenSegments(acc,
|
|
4908
|
+
acc = setTokenSegments(acc, path6, token2);
|
|
4909
4909
|
}
|
|
4910
4910
|
return acc;
|
|
4911
4911
|
};
|
|
@@ -4990,14 +4990,14 @@ function setNested(obj, segs, value) {
|
|
|
4990
4990
|
function tokensToTailwindTheme(input) {
|
|
4991
4991
|
const tokens = normalizeTokens(input);
|
|
4992
4992
|
const extend2 = {};
|
|
4993
|
-
for (const { path:
|
|
4994
|
-
const bucket2 = TW_BUCKETS.find((b) => b.match.length <=
|
|
4993
|
+
for (const { path: path6, token: token2 } of walkTokens(tokens)) {
|
|
4994
|
+
const bucket2 = TW_BUCKETS.find((b) => b.match.length <= path6.length && b.match.every((seg, i) => path6[i] === seg));
|
|
4995
4995
|
if (!bucket2)
|
|
4996
4996
|
continue;
|
|
4997
|
-
const rest =
|
|
4997
|
+
const rest = path6.slice(bucket2.match.length).map(kebab).filter(Boolean);
|
|
4998
4998
|
if (rest.length === 0)
|
|
4999
4999
|
continue;
|
|
5000
|
-
const ref = `var(${tokenCssVarName(
|
|
5000
|
+
const ref = `var(${tokenCssVarName(path6, token2)})`;
|
|
5001
5001
|
if (!extend2[bucket2.key])
|
|
5002
5002
|
extend2[bucket2.key] = {};
|
|
5003
5003
|
if (bucket2.flat)
|
|
@@ -5028,8 +5028,8 @@ function leafSignature(token2) {
|
|
|
5028
5028
|
}
|
|
5029
5029
|
function indexLeaves(t) {
|
|
5030
5030
|
const m = /* @__PURE__ */ new Map();
|
|
5031
|
-
for (const { path:
|
|
5032
|
-
m.set(
|
|
5031
|
+
for (const { path: path6, token: token2 } of walkTokens(t)) {
|
|
5032
|
+
m.set(path6.join("."), { sig: leafSignature(token2), disp: stringifyValue(token2.$value) });
|
|
5033
5033
|
}
|
|
5034
5034
|
return m;
|
|
5035
5035
|
}
|
|
@@ -6040,10 +6040,10 @@ function mergeDefs(...defs) {
|
|
|
6040
6040
|
function cloneDef(schema) {
|
|
6041
6041
|
return mergeDefs(schema._zod.def);
|
|
6042
6042
|
}
|
|
6043
|
-
function getElementAtPath(obj,
|
|
6044
|
-
if (!
|
|
6043
|
+
function getElementAtPath(obj, path6) {
|
|
6044
|
+
if (!path6)
|
|
6045
6045
|
return obj;
|
|
6046
|
-
return
|
|
6046
|
+
return path6.reduce((acc, key2) => acc?.[key2], obj);
|
|
6047
6047
|
}
|
|
6048
6048
|
function promiseAllObject(promisesObj) {
|
|
6049
6049
|
const keys = Object.keys(promisesObj);
|
|
@@ -6371,11 +6371,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
6371
6371
|
}
|
|
6372
6372
|
return false;
|
|
6373
6373
|
}
|
|
6374
|
-
function prefixIssues(
|
|
6374
|
+
function prefixIssues(path6, issues) {
|
|
6375
6375
|
return issues.map((iss) => {
|
|
6376
6376
|
var _a3;
|
|
6377
6377
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
6378
|
-
iss.path.unshift(
|
|
6378
|
+
iss.path.unshift(path6);
|
|
6379
6379
|
return iss;
|
|
6380
6380
|
});
|
|
6381
6381
|
}
|
|
@@ -6592,16 +6592,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6592
6592
|
}
|
|
6593
6593
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
6594
6594
|
const fieldErrors = { _errors: [] };
|
|
6595
|
-
const processError = (error52,
|
|
6595
|
+
const processError = (error52, path6 = []) => {
|
|
6596
6596
|
for (const issue2 of error52.issues) {
|
|
6597
6597
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6598
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6598
|
+
issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
|
|
6599
6599
|
} else if (issue2.code === "invalid_key") {
|
|
6600
|
-
processError({ issues: issue2.issues }, [...
|
|
6600
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6601
6601
|
} else if (issue2.code === "invalid_element") {
|
|
6602
|
-
processError({ issues: issue2.issues }, [...
|
|
6602
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6603
6603
|
} else {
|
|
6604
|
-
const fullpath = [...
|
|
6604
|
+
const fullpath = [...path6, ...issue2.path];
|
|
6605
6605
|
if (fullpath.length === 0) {
|
|
6606
6606
|
fieldErrors._errors.push(mapper(issue2));
|
|
6607
6607
|
} else {
|
|
@@ -6628,17 +6628,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6628
6628
|
}
|
|
6629
6629
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
6630
6630
|
const result = { errors: [] };
|
|
6631
|
-
const processError = (error52,
|
|
6631
|
+
const processError = (error52, path6 = []) => {
|
|
6632
6632
|
var _a3, _b;
|
|
6633
6633
|
for (const issue2 of error52.issues) {
|
|
6634
6634
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6635
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6635
|
+
issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
|
|
6636
6636
|
} else if (issue2.code === "invalid_key") {
|
|
6637
|
-
processError({ issues: issue2.issues }, [...
|
|
6637
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6638
6638
|
} else if (issue2.code === "invalid_element") {
|
|
6639
|
-
processError({ issues: issue2.issues }, [...
|
|
6639
|
+
processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
|
|
6640
6640
|
} else {
|
|
6641
|
-
const fullpath = [...
|
|
6641
|
+
const fullpath = [...path6, ...issue2.path];
|
|
6642
6642
|
if (fullpath.length === 0) {
|
|
6643
6643
|
result.errors.push(mapper(issue2));
|
|
6644
6644
|
continue;
|
|
@@ -6670,8 +6670,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6670
6670
|
}
|
|
6671
6671
|
function toDotPath(_path) {
|
|
6672
6672
|
const segs = [];
|
|
6673
|
-
const
|
|
6674
|
-
for (const seg of
|
|
6673
|
+
const path6 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
6674
|
+
for (const seg of path6) {
|
|
6675
6675
|
if (typeof seg === "number")
|
|
6676
6676
|
segs.push(`[${seg}]`);
|
|
6677
6677
|
else if (typeof seg === "symbol")
|
|
@@ -20101,13 +20101,13 @@ function resolveRef(ref, ctx2) {
|
|
|
20101
20101
|
if (!ref.startsWith("#")) {
|
|
20102
20102
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
20103
20103
|
}
|
|
20104
|
-
const
|
|
20105
|
-
if (
|
|
20104
|
+
const path6 = ref.slice(1).split("/").filter(Boolean);
|
|
20105
|
+
if (path6.length === 0) {
|
|
20106
20106
|
return ctx2.rootSchema;
|
|
20107
20107
|
}
|
|
20108
20108
|
const defsKey = ctx2.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
20109
|
-
if (
|
|
20110
|
-
const key2 =
|
|
20109
|
+
if (path6[0] === defsKey) {
|
|
20110
|
+
const key2 = path6[1];
|
|
20111
20111
|
if (!key2 || !ctx2.defs[key2]) {
|
|
20112
20112
|
throw new Error(`Reference not found: ${ref}`);
|
|
20113
20113
|
}
|
|
@@ -21716,10 +21716,10 @@ function buildCanvasTools(deps) {
|
|
|
21716
21716
|
const id = args.id ? slugify3(args.id) : `${slugify3(args.title ?? "canvas")}-${Math.random().toString(36).slice(2, 8)}`;
|
|
21717
21717
|
const dir2 = await deps.canvasDir();
|
|
21718
21718
|
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 (${
|
|
21719
|
+
const path6 = join5(dir2, `${id}.html`);
|
|
21720
|
+
writeFileSync3(path6, args.html, "utf8");
|
|
21721
|
+
deps.emitCanvasReady({ path: path6, title: args.title, id });
|
|
21722
|
+
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
21723
|
})
|
|
21724
21724
|
];
|
|
21725
21725
|
}
|
|
@@ -23024,9 +23024,57 @@ var init_trace_store = __esm({
|
|
|
23024
23024
|
}
|
|
23025
23025
|
});
|
|
23026
23026
|
|
|
23027
|
+
// ../../packages/agent-core/dist/cost-ledger.js
|
|
23028
|
+
import { promises as fs2 } from "node:fs";
|
|
23029
|
+
import path2 from "node:path";
|
|
23030
|
+
var DIR2, CostLedger;
|
|
23031
|
+
var init_cost_ledger = __esm({
|
|
23032
|
+
"../../packages/agent-core/dist/cost-ledger.js"() {
|
|
23033
|
+
"use strict";
|
|
23034
|
+
DIR2 = ".ccb-traces";
|
|
23035
|
+
CostLedger = class {
|
|
23036
|
+
fileFor(projectDir, sessionId) {
|
|
23037
|
+
return path2.join(projectDir, DIR2, sessionId, "cost.jsonl");
|
|
23038
|
+
}
|
|
23039
|
+
/** Append one turn's cost. Creates the dir + a `.gitignore` (the traces dir is inside the
|
|
23040
|
+
* user's project, usually a git repo) on first write. */
|
|
23041
|
+
async append(projectDir, sessionId, entry) {
|
|
23042
|
+
try {
|
|
23043
|
+
const file2 = this.fileFor(projectDir, sessionId);
|
|
23044
|
+
await fs2.mkdir(path2.dirname(file2), { recursive: true });
|
|
23045
|
+
await fs2.writeFile(path2.join(projectDir, DIR2, ".gitignore"), "*\n", "utf8").catch(() => {
|
|
23046
|
+
});
|
|
23047
|
+
await fs2.appendFile(file2, JSON.stringify(entry) + "\n", "utf8");
|
|
23048
|
+
} catch {
|
|
23049
|
+
}
|
|
23050
|
+
}
|
|
23051
|
+
/** Cumulative session cost = sum of every recorded turn. 0 if the ledger is missing. */
|
|
23052
|
+
async total(projectDir, sessionId) {
|
|
23053
|
+
try {
|
|
23054
|
+
const raw = await fs2.readFile(this.fileFor(projectDir, sessionId), "utf8");
|
|
23055
|
+
let sum = 0;
|
|
23056
|
+
for (const line of raw.split("\n")) {
|
|
23057
|
+
if (!line.trim())
|
|
23058
|
+
continue;
|
|
23059
|
+
try {
|
|
23060
|
+
const e = JSON.parse(line);
|
|
23061
|
+
if (typeof e.costUsd === "number" && Number.isFinite(e.costUsd))
|
|
23062
|
+
sum += e.costUsd;
|
|
23063
|
+
} catch {
|
|
23064
|
+
}
|
|
23065
|
+
}
|
|
23066
|
+
return sum;
|
|
23067
|
+
} catch {
|
|
23068
|
+
return 0;
|
|
23069
|
+
}
|
|
23070
|
+
}
|
|
23071
|
+
};
|
|
23072
|
+
}
|
|
23073
|
+
});
|
|
23074
|
+
|
|
23027
23075
|
// ../../packages/agent-core/dist/session-store.js
|
|
23028
23076
|
import { readFile as readFile4, stat } from "node:fs/promises";
|
|
23029
|
-
import { listSessions, getSessionMessages, forkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
23077
|
+
import { listSessions, getSessionMessages, getSubagentMessages as sdkGetSubagentMessages, forkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
23030
23078
|
function toSessionInfo(s) {
|
|
23031
23079
|
const fromFirst = stripPromptPrefix(s.firstPrompt ?? "").slice(0, 80);
|
|
23032
23080
|
const fromSummary = stripPromptPrefix(s.summary ?? "").slice(0, 80);
|
|
@@ -23141,7 +23189,7 @@ ${input.command}
|
|
|
23141
23189
|
}
|
|
23142
23190
|
}
|
|
23143
23191
|
}
|
|
23144
|
-
blocks.push({ kind: "tool_use", content: detail });
|
|
23192
|
+
blocks.push({ kind: "tool_use", content: detail, name });
|
|
23145
23193
|
} else if (b.type === "advisor_tool_result") {
|
|
23146
23194
|
const c = b.content;
|
|
23147
23195
|
const text4 = c?.type === "advisor_result" ? (c.text ?? "").trim() : "";
|
|
@@ -23212,32 +23260,46 @@ var init_session_store = __esm({
|
|
|
23212
23260
|
}
|
|
23213
23261
|
async getSessionMessages(sessionId) {
|
|
23214
23262
|
try {
|
|
23215
|
-
|
|
23216
|
-
|
|
23217
|
-
|
|
23218
|
-
|
|
23219
|
-
|
|
23220
|
-
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
|
|
23226
|
-
|
|
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;
|
|
23263
|
+
return this.rawToMessages(await getSessionMessages(sessionId));
|
|
23264
|
+
} catch {
|
|
23265
|
+
return [];
|
|
23266
|
+
}
|
|
23267
|
+
}
|
|
23268
|
+
/** Read a SUBAGENT's (Task tool) transcript from its sidecar JSONL — the granular
|
|
23269
|
+
* activity that never streams to the client. `agentId` is the subagent's id (the app's
|
|
23270
|
+
* subagent-card `taskId`, which equals `task_started.task_id` and the sidecar filename);
|
|
23271
|
+
* `projectDir` scopes the lookup to the right project (required on a remote host). */
|
|
23272
|
+
async getSubagentMessages(sessionId, agentId, projectDir) {
|
|
23273
|
+
try {
|
|
23274
|
+
return this.rawToMessages(await sdkGetSubagentMessages(sessionId, agentId, projectDir ? { dir: projectDir } : void 0));
|
|
23237
23275
|
} catch {
|
|
23238
23276
|
return [];
|
|
23239
23277
|
}
|
|
23240
23278
|
}
|
|
23279
|
+
/** Shared normalization: raw SDK transcript entries → the app's SessionMessage shape. */
|
|
23280
|
+
rawToMessages(raw) {
|
|
23281
|
+
const messages = [];
|
|
23282
|
+
for (const entry of raw) {
|
|
23283
|
+
const blocks = extractBlocks(entry.message);
|
|
23284
|
+
if (blocks.length === 0 && entry.type === "user")
|
|
23285
|
+
continue;
|
|
23286
|
+
let textContent = blocks.filter((b) => b.kind === "text").map((b) => b.content).join("\n");
|
|
23287
|
+
if (entry.type === "user") {
|
|
23288
|
+
textContent = stripPromptPrefix(textContent);
|
|
23289
|
+
}
|
|
23290
|
+
messages.push({
|
|
23291
|
+
role: entry.type === "user" ? "user" : "assistant",
|
|
23292
|
+
// Flat content feeds summaries/merge seeds — keep advisor reviews OUT of it
|
|
23293
|
+
// (they're a side-channel review, rendered as their own card, like tool_use).
|
|
23294
|
+
content: textContent || blocks.find((b) => b.kind !== "advisor")?.content || "",
|
|
23295
|
+
blocks: entry.type === "assistant" ? blocks : void 0,
|
|
23296
|
+
// Thread the per-message SDK uuid so the renderer can pass it as
|
|
23297
|
+
// session:fork.upToMessageId ("fork from here").
|
|
23298
|
+
uuid: typeof entry.uuid === "string" ? entry.uuid : void 0
|
|
23299
|
+
});
|
|
23300
|
+
}
|
|
23301
|
+
return messages;
|
|
23302
|
+
}
|
|
23241
23303
|
/** Fork a session into a NEW session id (non-destructive — the source transcript
|
|
23242
23304
|
* is preserved). `upToMessageId` slices the fork at a message uuid; `title` names
|
|
23243
23305
|
* the fork; `projectDir` scopes the lookup to the right project's session store.
|
|
@@ -23683,14 +23745,14 @@ function newestVersionManagerNode() {
|
|
|
23683
23745
|
continue;
|
|
23684
23746
|
}
|
|
23685
23747
|
for (const name of names) {
|
|
23686
|
-
const
|
|
23687
|
-
if (!existsSync2(
|
|
23748
|
+
const path6 = bin(join9(dir2, name));
|
|
23749
|
+
if (!existsSync2(path6))
|
|
23688
23750
|
continue;
|
|
23689
23751
|
const parts = name.replace(/^v/, "").split(".").map((n) => Number.parseInt(n, 10) || 0);
|
|
23690
23752
|
const ver = [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
|
|
23691
23753
|
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
23754
|
if (gt)
|
|
23693
|
-
best = { ver, path:
|
|
23755
|
+
best = { ver, path: path6 };
|
|
23694
23756
|
}
|
|
23695
23757
|
}
|
|
23696
23758
|
return best?.path ?? null;
|
|
@@ -23703,8 +23765,8 @@ function loginShellNode() {
|
|
|
23703
23765
|
return null;
|
|
23704
23766
|
try {
|
|
23705
23767
|
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
|
|
23768
|
+
const path6 = out.match(/<<NODE:(.*?)>>/)?.[1]?.trim();
|
|
23769
|
+
return path6 && existsSync2(path6) ? path6 : null;
|
|
23708
23770
|
} catch {
|
|
23709
23771
|
return null;
|
|
23710
23772
|
}
|
|
@@ -23756,6 +23818,29 @@ function traceFrame(message) {
|
|
|
23756
23818
|
}
|
|
23757
23819
|
const sub = typeof message.subtype === "string" ? `/${message.subtype}` : "";
|
|
23758
23820
|
const parent = message.parent_tool_use_id ? " (subagent)" : "";
|
|
23821
|
+
if (type === "system" && typeof message.subtype === "string" && message.subtype.startsWith("task_")) {
|
|
23822
|
+
const m = message;
|
|
23823
|
+
const u = m.usage ?? {};
|
|
23824
|
+
let patch = "";
|
|
23825
|
+
if (m.patch && typeof m.patch === "object") {
|
|
23826
|
+
try {
|
|
23827
|
+
patch = `patch=${JSON.stringify(m.patch).slice(0, 200)}`;
|
|
23828
|
+
} catch {
|
|
23829
|
+
patch = "patch=?";
|
|
23830
|
+
}
|
|
23831
|
+
}
|
|
23832
|
+
const bits = [
|
|
23833
|
+
typeof m.task_id === "string" ? `id=${m.task_id.slice(0, 8)}` : "",
|
|
23834
|
+
typeof m.status === "string" ? `status=${m.status}` : "",
|
|
23835
|
+
typeof m.subagent_type === "string" ? `agent=${m.subagent_type}` : "",
|
|
23836
|
+
typeof m.last_tool_name === "string" ? `last=${m.last_tool_name}` : "",
|
|
23837
|
+
typeof u.tool_uses === "number" ? `tools=${u.tool_uses}` : "",
|
|
23838
|
+
typeof u.total_tokens === "number" ? `tok=${u.total_tokens}` : "",
|
|
23839
|
+
patch
|
|
23840
|
+
].filter(Boolean).join(" ");
|
|
23841
|
+
log(`frame ${type}${sub}${parent}${bits ? " \u2014 " + bits : ""}`);
|
|
23842
|
+
return;
|
|
23843
|
+
}
|
|
23759
23844
|
log(`frame ${type}${sub}${parent}`);
|
|
23760
23845
|
}
|
|
23761
23846
|
function rawFramePreview(message, limit = 2e3) {
|
|
@@ -24113,9 +24198,9 @@ function editedPathOf(toolInput) {
|
|
|
24113
24198
|
const p = i?.file_path ?? i?.notebook_path;
|
|
24114
24199
|
return typeof p === "string" && p.length > 0 ? p : null;
|
|
24115
24200
|
}
|
|
24116
|
-
async function snapshotFile(
|
|
24201
|
+
async function snapshotFile(path6) {
|
|
24117
24202
|
try {
|
|
24118
|
-
const buf = await readFile6(
|
|
24203
|
+
const buf = await readFile6(path6);
|
|
24119
24204
|
if (buf.length > EDIT_PREVIEW_CAP)
|
|
24120
24205
|
return { noPreview: true };
|
|
24121
24206
|
if (buf.subarray(0, 8192).includes(0))
|
|
@@ -24163,7 +24248,7 @@ MOBILE (${fw}):
|
|
|
24163
24248
|
return "";
|
|
24164
24249
|
}
|
|
24165
24250
|
}
|
|
24166
|
-
var cachedClaudeExe, cachedNodeExe, HUMAN_READABLE_FIELDS,
|
|
24251
|
+
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
24252
|
var init_agent_manager = __esm({
|
|
24168
24253
|
"../../packages/agent-core/dist/agent-manager.js"() {
|
|
24169
24254
|
"use strict";
|
|
@@ -24186,13 +24271,13 @@ var init_agent_manager = __esm({
|
|
|
24186
24271
|
init_narrator();
|
|
24187
24272
|
init_plan_splitter();
|
|
24188
24273
|
init_trace_store();
|
|
24274
|
+
init_cost_ledger();
|
|
24189
24275
|
init_session_store();
|
|
24190
24276
|
init_session_usage();
|
|
24191
24277
|
init_kill_tree();
|
|
24192
24278
|
init_log();
|
|
24193
24279
|
init_sources();
|
|
24194
24280
|
HUMAN_READABLE_FIELDS = ["message", "text", "content", "summary", "description", "output", "stdout", "error", "reason", "name"];
|
|
24195
|
-
THINKING_THROTTLE_MS = 2e3;
|
|
24196
24281
|
SYSTEM_EVENT_CATEGORY = {
|
|
24197
24282
|
hook_started: "hook",
|
|
24198
24283
|
hook_progress: "hook",
|
|
@@ -24255,6 +24340,7 @@ var init_agent_manager = __esm({
|
|
|
24255
24340
|
projectDir;
|
|
24256
24341
|
/** Per-generation trace persistence (.ccb-traces on the agent's disk). */
|
|
24257
24342
|
traceStore = new TraceStore();
|
|
24343
|
+
costLedger = new CostLedger();
|
|
24258
24344
|
/** On-disk session transcripts — used by mergeSessions to gather context. */
|
|
24259
24345
|
sessionStore = new SessionStore();
|
|
24260
24346
|
liveSessions = /* @__PURE__ */ new Map();
|
|
@@ -24955,6 +25041,21 @@ ${qText}`;
|
|
|
24955
25041
|
return null;
|
|
24956
25042
|
return this.traceStore.readTurn(dir2, sessionId, turnId);
|
|
24957
25043
|
}
|
|
25044
|
+
/** A subagent's activity transcript (from its sidecar JSONL) — the granular frames the
|
|
25045
|
+
* Task tool never streams to the client. `agentId` == the subagent-card taskId. Falls
|
|
25046
|
+
* back to the resident session's cwd / configured project for the file lookup. */
|
|
25047
|
+
async getSubagentMessages(sessionId, agentId, projectDir) {
|
|
25048
|
+
const dir2 = this.liveSessions.get(sessionId)?.cwd ?? projectDir ?? this.projectDir ?? void 0;
|
|
25049
|
+
return this.sessionStore.getSubagentMessages(sessionId, agentId, dir2);
|
|
25050
|
+
}
|
|
25051
|
+
/** Authoritative cumulative cost (USD) for a session, summed from the durable per-turn cost
|
|
25052
|
+
* ledger — survives reload/resume (unlike a client-side sum of the text-only transcript). */
|
|
25053
|
+
async getSessionCost(sessionId, projectDir) {
|
|
25054
|
+
const dir2 = this.liveSessions.get(sessionId)?.cwd ?? projectDir ?? this.projectDir ?? void 0;
|
|
25055
|
+
if (!dir2)
|
|
25056
|
+
return 0;
|
|
25057
|
+
return this.costLedger.total(dir2, sessionId);
|
|
25058
|
+
}
|
|
24958
25059
|
/** Merge sessions into a NEW one: gather each transcript, seed a fresh session with
|
|
24959
25060
|
* the combined context + an instruction to summarize-and-continue. The new session
|
|
24960
25061
|
* resolves via session:created (clientRequestId-keyed) exactly like a brand-new
|
|
@@ -25681,10 +25782,10 @@ CRITICAL RULES:
|
|
|
25681
25782
|
matcher: "Edit|Write|MultiEdit|NotebookEdit",
|
|
25682
25783
|
hooks: [async (input) => {
|
|
25683
25784
|
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:
|
|
25785
|
+
const path6 = editedPathOf(input.tool_input);
|
|
25786
|
+
if (path6) {
|
|
25787
|
+
const snap = await snapshotFile(path6);
|
|
25788
|
+
pendingEdits.set(input.tool_use_id, { path: path6, before: snap.content, created: snap.created, noPreview: snap.noPreview });
|
|
25688
25789
|
}
|
|
25689
25790
|
}
|
|
25690
25791
|
return {};
|
|
@@ -25696,14 +25797,14 @@ CRITICAL RULES:
|
|
|
25696
25797
|
if (input.hook_event_name === "PostToolUse" && !input.agent_id) {
|
|
25697
25798
|
const pre = pendingEdits.get(input.tool_use_id);
|
|
25698
25799
|
pendingEdits.delete(input.tool_use_id);
|
|
25699
|
-
const
|
|
25700
|
-
if (
|
|
25701
|
-
const post = await snapshotFile(
|
|
25800
|
+
const path6 = pre?.path ?? editedPathOf(input.tool_input);
|
|
25801
|
+
if (path6) {
|
|
25802
|
+
const post = await snapshotFile(path6);
|
|
25702
25803
|
emitFileEdit({
|
|
25703
25804
|
type: "agent:file_edit",
|
|
25704
25805
|
sessionId: live.sessionId,
|
|
25705
25806
|
toolName: input.tool_name,
|
|
25706
|
-
path:
|
|
25807
|
+
path: path6,
|
|
25707
25808
|
before: pre?.before,
|
|
25708
25809
|
after: post.content,
|
|
25709
25810
|
created: pre?.created || void 0,
|
|
@@ -25730,6 +25831,9 @@ CRITICAL RULES:
|
|
|
25730
25831
|
const spawnEnv = {
|
|
25731
25832
|
...process.env,
|
|
25732
25833
|
...options.env,
|
|
25834
|
+
// params.env carries CLAUDE_AUTOCOMPACT_PCT_OVERRIDE from the user's setting
|
|
25835
|
+
// (getAgentSettings) — IF this CLI honours it, native mid-run compaction fires
|
|
25836
|
+
// at the same threshold as our renderer-side proactive `/compact`.
|
|
25733
25837
|
...params.env ?? {},
|
|
25734
25838
|
...params.engineEnv ?? {},
|
|
25735
25839
|
CCB_IPC_PORT: String(live.ipcPort)
|
|
@@ -25853,17 +25957,8 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
25853
25957
|
};
|
|
25854
25958
|
const emitEvent = (spec, parentId) => {
|
|
25855
25959
|
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
|
-
}
|
|
25960
|
+
if (spec.updateKey === "thinking_tokens")
|
|
25865
25961
|
return;
|
|
25866
|
-
}
|
|
25867
25962
|
flushPendingThinking();
|
|
25868
25963
|
sendEvent(payload);
|
|
25869
25964
|
};
|
|
@@ -26040,6 +26135,16 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26040
26135
|
frames: finishedTrace.frames
|
|
26041
26136
|
});
|
|
26042
26137
|
}
|
|
26138
|
+
if (typeof r.total_cost_usd === "number" && r.total_cost_usd > 0 && live.cwd) {
|
|
26139
|
+
const uc = r.usage;
|
|
26140
|
+
void this.costLedger.append(live.cwd, turnSid, {
|
|
26141
|
+
...traceTurnId ? { turnId: traceTurnId } : {},
|
|
26142
|
+
ts: Date.now(),
|
|
26143
|
+
costUsd: r.total_cost_usd,
|
|
26144
|
+
...typeof uc?.input_tokens === "number" ? { inputTokens: uc.input_tokens } : {},
|
|
26145
|
+
...typeof uc?.output_tokens === "number" ? { outputTokens: uc.output_tokens } : {}
|
|
26146
|
+
});
|
|
26147
|
+
}
|
|
26043
26148
|
if (r.subtype === "success") {
|
|
26044
26149
|
if (!turnStreamed && Array.isArray(live.lastAssistantContent)) {
|
|
26045
26150
|
for (const blk of live.lastAssistantContent) {
|
|
@@ -26148,6 +26253,7 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26148
26253
|
...sstr(m.tool_use_id) ? { toolUseId: sstr(m.tool_use_id) } : {},
|
|
26149
26254
|
...parentToolUseId ? { parentToolUseId } : {},
|
|
26150
26255
|
description: sstr(m.description) || "subagent task",
|
|
26256
|
+
...sstr(m.prompt) ? { prompt: sstr(m.prompt) } : {},
|
|
26151
26257
|
...sstr(m.subagent_type) ? { subagentType: sstr(m.subagent_type) } : {},
|
|
26152
26258
|
...sstr(m.workflow_name) ? { workflowName: sstr(m.workflow_name) } : {}
|
|
26153
26259
|
});
|
|
@@ -26422,7 +26528,7 @@ ${params.appendSystemPrompt}` : ""), live.sessionId) },
|
|
|
26422
26528
|
const detail = err instanceof Error ? `${err.name}: ${err.message}${err.stack ? `
|
|
26423
26529
|
${err.stack}` : ""}` : String(err);
|
|
26424
26530
|
log("Session iterator error:", sid, detail);
|
|
26425
|
-
emit2({ type: "chat:error", sessionId: sid, error: detail });
|
|
26531
|
+
emit2({ type: "chat:error", sessionId: sid, error: detail, transient: true });
|
|
26426
26532
|
emit2({ type: "agent:status", sessionId: sid, status: "error" });
|
|
26427
26533
|
}
|
|
26428
26534
|
} finally {
|
|
@@ -28365,13 +28471,13 @@ function __disposeResources(env) {
|
|
|
28365
28471
|
}
|
|
28366
28472
|
return next();
|
|
28367
28473
|
}
|
|
28368
|
-
function __rewriteRelativeImportExtension(
|
|
28369
|
-
if (typeof
|
|
28370
|
-
return
|
|
28474
|
+
function __rewriteRelativeImportExtension(path6, preserveJsx) {
|
|
28475
|
+
if (typeof path6 === "string" && /^\.\.?\//.test(path6)) {
|
|
28476
|
+
return path6.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
|
|
28371
28477
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
|
|
28372
28478
|
});
|
|
28373
28479
|
}
|
|
28374
|
-
return
|
|
28480
|
+
return path6;
|
|
28375
28481
|
}
|
|
28376
28482
|
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
|
|
28377
28483
|
var init_tslib_es6 = __esm({
|
|
@@ -39966,14 +40072,14 @@ var require_dependency_container = __commonJS({
|
|
|
39966
40072
|
provider = providerOrConstructor;
|
|
39967
40073
|
}
|
|
39968
40074
|
if (providers_1.isTokenProvider(provider)) {
|
|
39969
|
-
const
|
|
40075
|
+
const path6 = [token2];
|
|
39970
40076
|
let tokenProvider = provider;
|
|
39971
40077
|
while (tokenProvider != null) {
|
|
39972
40078
|
const currentToken = tokenProvider.useToken;
|
|
39973
|
-
if (
|
|
39974
|
-
throw new Error(`Token registration cycle detected! ${[...
|
|
40079
|
+
if (path6.includes(currentToken)) {
|
|
40080
|
+
throw new Error(`Token registration cycle detected! ${[...path6, currentToken].join(" -> ")}`);
|
|
39975
40081
|
}
|
|
39976
|
-
|
|
40082
|
+
path6.push(currentToken);
|
|
39977
40083
|
const registration = this._registry.get(currentToken);
|
|
39978
40084
|
if (registration && providers_1.isTokenProvider(registration.provider)) {
|
|
39979
40085
|
tokenProvider = registration.provider;
|
|
@@ -45318,7 +45424,7 @@ var init_framing = __esm({
|
|
|
45318
45424
|
});
|
|
45319
45425
|
|
|
45320
45426
|
// ../../packages/host-core/dist/peer-link/transport.js
|
|
45321
|
-
function socketPeerLink(socket2, peerHostId,
|
|
45427
|
+
function socketPeerLink(socket2, peerHostId, path6, opts) {
|
|
45322
45428
|
const dec = new FrameDecoder();
|
|
45323
45429
|
const dataCbs = /* @__PURE__ */ new Set();
|
|
45324
45430
|
const closeCbs = /* @__PURE__ */ new Set();
|
|
@@ -45392,7 +45498,7 @@ function socketPeerLink(socket2, peerHostId, path5, opts) {
|
|
|
45392
45498
|
}
|
|
45393
45499
|
const link = {
|
|
45394
45500
|
peerHostId,
|
|
45395
|
-
path:
|
|
45501
|
+
path: path6,
|
|
45396
45502
|
send(chunk) {
|
|
45397
45503
|
if (!closed)
|
|
45398
45504
|
socket2.write(encodeFrame2(chunk));
|
|
@@ -47683,6 +47789,8 @@ async function createClaudeCodeBackend(send3, onBrowserRequest, loadPluginRuntim
|
|
|
47683
47789
|
listSessions: (projectDir) => store.getSessions(projectDir),
|
|
47684
47790
|
searchSessions: (query2, projectDir) => store.searchSessions(query2, projectDir),
|
|
47685
47791
|
getMessages: (sessionId) => store.getSessionMessages(sessionId),
|
|
47792
|
+
getSubagentMessages: (sessionId, agentId, projectDir) => manager2.getSubagentMessages(sessionId, agentId, projectDir),
|
|
47793
|
+
getSessionCost: (sessionId, projectDir) => manager2.getSessionCost(sessionId, projectDir),
|
|
47686
47794
|
getSessionArtifacts: (sessionId, projectDir) => readSessionArtifacts2(sessionId, projectDir),
|
|
47687
47795
|
summarizeSession: async (sessionId) => manager2.summarizeSession(await store.getSessionMessages(sessionId)),
|
|
47688
47796
|
setConfig: (projectDir) => {
|
|
@@ -48159,15 +48267,15 @@ import { homedir as homedir9 } from "node:os";
|
|
|
48159
48267
|
init_dist();
|
|
48160
48268
|
|
|
48161
48269
|
// ../../packages/plugin-host/dist/discovery.js
|
|
48162
|
-
import
|
|
48163
|
-
import
|
|
48270
|
+
import fs3 from "node:fs";
|
|
48271
|
+
import path3 from "node:path";
|
|
48164
48272
|
var isWindows = process.platform === "win32";
|
|
48165
48273
|
function checkTrust(rootDir, trusted, relaxHardlink = false) {
|
|
48166
48274
|
if (trusted)
|
|
48167
48275
|
return null;
|
|
48168
48276
|
let st;
|
|
48169
48277
|
try {
|
|
48170
|
-
st =
|
|
48278
|
+
st = fs3.statSync(rootDir);
|
|
48171
48279
|
} catch {
|
|
48172
48280
|
return "unreadable";
|
|
48173
48281
|
}
|
|
@@ -48181,7 +48289,7 @@ function checkTrust(rootDir, trusted, relaxHardlink = false) {
|
|
|
48181
48289
|
if (!relaxHardlink) {
|
|
48182
48290
|
for (const name of ["package.json"]) {
|
|
48183
48291
|
try {
|
|
48184
|
-
const f =
|
|
48292
|
+
const f = fs3.statSync(path3.join(rootDir, name));
|
|
48185
48293
|
if (f.nlink > 1)
|
|
48186
48294
|
return `${name} is a hardlink`;
|
|
48187
48295
|
} catch {
|
|
@@ -48196,20 +48304,20 @@ function discover(roots) {
|
|
|
48196
48304
|
for (const root of roots) {
|
|
48197
48305
|
let entries;
|
|
48198
48306
|
try {
|
|
48199
|
-
entries =
|
|
48307
|
+
entries = fs3.readdirSync(root.dir, { withFileTypes: true });
|
|
48200
48308
|
} catch {
|
|
48201
48309
|
continue;
|
|
48202
48310
|
}
|
|
48203
48311
|
for (const ent of entries) {
|
|
48204
48312
|
if (!ent.isDirectory() && !ent.isSymbolicLink())
|
|
48205
48313
|
continue;
|
|
48206
|
-
const rootDir =
|
|
48207
|
-
if (!
|
|
48314
|
+
const rootDir = path3.join(root.dir, ent.name);
|
|
48315
|
+
if (!fs3.existsSync(path3.join(rootDir, "package.json"))) {
|
|
48208
48316
|
if (ent.name.startsWith("@")) {
|
|
48209
48317
|
try {
|
|
48210
|
-
for (const sub of
|
|
48211
|
-
const subDir =
|
|
48212
|
-
if (
|
|
48318
|
+
for (const sub of fs3.readdirSync(rootDir, { withFileTypes: true })) {
|
|
48319
|
+
const subDir = path3.join(rootDir, sub.name);
|
|
48320
|
+
if (fs3.existsSync(path3.join(subDir, "package.json")))
|
|
48213
48321
|
pushCandidate(subDir, root, candidates, diagnostics);
|
|
48214
48322
|
}
|
|
48215
48323
|
} catch {
|
|
@@ -48231,13 +48339,13 @@ function pushCandidate(rootDir, root, candidates, diagnostics) {
|
|
|
48231
48339
|
}
|
|
48232
48340
|
|
|
48233
48341
|
// ../../packages/plugin-host/dist/manifest.js
|
|
48234
|
-
import
|
|
48235
|
-
import
|
|
48342
|
+
import fs4 from "node:fs";
|
|
48343
|
+
import path4 from "node:path";
|
|
48236
48344
|
function resolveEntry(rootDir, rel, pkg) {
|
|
48237
48345
|
const candidates = [rel, pkg.module, pkg.main, "index.js", "index.ts", "dist/index.js"].filter(Boolean);
|
|
48238
48346
|
for (const c of candidates) {
|
|
48239
|
-
const abs =
|
|
48240
|
-
if (
|
|
48347
|
+
const abs = path4.resolve(rootDir, c);
|
|
48348
|
+
if (fs4.existsSync(abs))
|
|
48241
48349
|
return abs;
|
|
48242
48350
|
}
|
|
48243
48351
|
return null;
|
|
@@ -48245,7 +48353,7 @@ function resolveEntry(rootDir, rel, pkg) {
|
|
|
48245
48353
|
function readManifest2(rootDir) {
|
|
48246
48354
|
let pkg;
|
|
48247
48355
|
try {
|
|
48248
|
-
pkg = JSON.parse(
|
|
48356
|
+
pkg = JSON.parse(fs4.readFileSync(path4.join(rootDir, "package.json"), "utf8"));
|
|
48249
48357
|
} catch {
|
|
48250
48358
|
return { manifest: null, diagnostic: `${rootDir}: unreadable package.json` };
|
|
48251
48359
|
}
|
|
@@ -48570,12 +48678,12 @@ function createOpenClawAdapter(pluginId, config2, secretResolver, registry2) {
|
|
|
48570
48678
|
}
|
|
48571
48679
|
|
|
48572
48680
|
// ../../packages/plugin-host/dist/openclaw-stub.js
|
|
48573
|
-
import
|
|
48574
|
-
import
|
|
48681
|
+
import fs5 from "node:fs";
|
|
48682
|
+
import path5 from "node:path";
|
|
48575
48683
|
function writeOpenClawShim(pluginsDir) {
|
|
48576
|
-
const stubDir =
|
|
48577
|
-
|
|
48578
|
-
|
|
48684
|
+
const stubDir = path5.join(pluginsDir, "node_modules", "openclaw");
|
|
48685
|
+
fs5.mkdirSync(stubDir, { recursive: true });
|
|
48686
|
+
fs5.writeFileSync(path5.join(stubDir, "package.json"), JSON.stringify({
|
|
48579
48687
|
name: "openclaw",
|
|
48580
48688
|
version: "0.0.0-tesseract-compat",
|
|
48581
48689
|
type: "module",
|
|
@@ -48592,8 +48700,8 @@ function writeOpenClawShim(pluginsDir) {
|
|
|
48592
48700
|
"export default { definePluginEntry };",
|
|
48593
48701
|
""
|
|
48594
48702
|
].join("\n");
|
|
48595
|
-
|
|
48596
|
-
|
|
48703
|
+
fs5.writeFileSync(path5.join(stubDir, "plugin-entry.mjs"), entrySrc);
|
|
48704
|
+
fs5.writeFileSync(path5.join(stubDir, "plugin-sdk.mjs"), "export * from './plugin-entry.mjs';\nexport { default } from './plugin-entry.mjs';\n");
|
|
48597
48705
|
return stubDir;
|
|
48598
48706
|
}
|
|
48599
48707
|
|
|
@@ -49189,10 +49297,10 @@ function augmentedPath() {
|
|
|
49189
49297
|
}
|
|
49190
49298
|
return parts.join(sep8);
|
|
49191
49299
|
}
|
|
49192
|
-
function which(bin,
|
|
49300
|
+
function which(bin, path6) {
|
|
49193
49301
|
const tool12 = process.platform === "win32" ? "where" : "which";
|
|
49194
49302
|
try {
|
|
49195
|
-
const out = execFileSync2(tool12, [bin], { env: { ...process.env, PATH:
|
|
49303
|
+
const out = execFileSync2(tool12, [bin], { env: { ...process.env, PATH: path6 }, timeout: 4e3, encoding: "utf-8" });
|
|
49196
49304
|
return out.split(/\r?\n/).map((l) => l.trim()).find(Boolean) || void 0;
|
|
49197
49305
|
} catch {
|
|
49198
49306
|
return void 0;
|
|
@@ -49204,12 +49312,12 @@ function compute(engineId) {
|
|
|
49204
49312
|
const desc = engineById(engineId);
|
|
49205
49313
|
if (!desc)
|
|
49206
49314
|
return null;
|
|
49207
|
-
const
|
|
49315
|
+
const path6 = augmentedPath();
|
|
49208
49316
|
const explicit = process.env[`CCB_ENGINE_PATH_${envKey(engineId)}`]?.trim();
|
|
49209
|
-
const command = explicit || which(desc.cliBinary,
|
|
49317
|
+
const command = explicit || which(desc.cliBinary, path6);
|
|
49210
49318
|
if (!command)
|
|
49211
49319
|
return null;
|
|
49212
|
-
const env = { PATH:
|
|
49320
|
+
const env = { PATH: path6 };
|
|
49213
49321
|
const prefix = "CCB_ENGINE_ENV_";
|
|
49214
49322
|
for (const [k, v] of Object.entries(process.env)) {
|
|
49215
49323
|
if (v !== void 0 && k.startsWith(prefix))
|
|
@@ -51693,9 +51801,9 @@ function createDaemonImageGenRunner() {
|
|
|
51693
51801
|
mkdirSync8(dir2, { recursive: true });
|
|
51694
51802
|
const files = images.map((img, i) => {
|
|
51695
51803
|
const ext = img.mime.split("/")[1]?.split("+")[0] || "png";
|
|
51696
|
-
const
|
|
51697
|
-
writeFileSync9(
|
|
51698
|
-
return { path:
|
|
51804
|
+
const path6 = join18(dir2, `${i + 1}.${ext}`);
|
|
51805
|
+
writeFileSync9(path6, img.bytes);
|
|
51806
|
+
return { path: path6, mime: img.mime };
|
|
51699
51807
|
});
|
|
51700
51808
|
return { ok: true, files, usedProviderId: id };
|
|
51701
51809
|
} catch (e) {
|
|
@@ -51743,10 +51851,10 @@ function dynamicMetrics() {
|
|
|
51743
51851
|
|
|
51744
51852
|
// ../../packages/host-core/dist/support-submit.js
|
|
51745
51853
|
var LOG_TAIL_BYTES = 64 * 1024;
|
|
51746
|
-
function tail2(
|
|
51854
|
+
function tail2(path6, bytes = LOG_TAIL_BYTES) {
|
|
51747
51855
|
let fd = null;
|
|
51748
51856
|
try {
|
|
51749
|
-
fd = openSync2(
|
|
51857
|
+
fd = openSync2(path6, "r");
|
|
51750
51858
|
const size = fstatSync(fd).size;
|
|
51751
51859
|
const len = Math.min(size, bytes);
|
|
51752
51860
|
const start2 = Math.max(0, size - len);
|
|
@@ -52287,8 +52395,8 @@ function releaseFsClient(key2) {
|
|
|
52287
52395
|
}
|
|
52288
52396
|
var OUTSIDE = (verb) => ({ ok: false, error: `Refusing to ${verb} outside the shared root.` });
|
|
52289
52397
|
var validName = (n) => !!n && !n.includes("/") && !n.includes("\\") && n !== "." && n !== "..";
|
|
52290
|
-
async function readRemoteBytes(root,
|
|
52291
|
-
const real = safeContentPath(
|
|
52398
|
+
async function readRemoteBytes(root, path6) {
|
|
52399
|
+
const real = safeContentPath(path6);
|
|
52292
52400
|
if (!real)
|
|
52293
52401
|
return { error: "Path is outside the shared root." };
|
|
52294
52402
|
try {
|
|
@@ -52878,8 +52986,8 @@ var CHUNK = 64 * 1024;
|
|
|
52878
52986
|
var MAX_MSG = 256 * 1024;
|
|
52879
52987
|
var HIGH_WATER = 8 * 1024 * 1024;
|
|
52880
52988
|
var drainers = /* @__PURE__ */ new WeakMap();
|
|
52881
|
-
async function serveGet(dc, id,
|
|
52882
|
-
const res = await readRemoteBytes(root,
|
|
52989
|
+
async function serveGet(dc, id, path6, root) {
|
|
52990
|
+
const res = await readRemoteBytes(root, path6);
|
|
52883
52991
|
if (!dc.isOpen())
|
|
52884
52992
|
return;
|
|
52885
52993
|
if (res.error || !res.bytes) {
|
|
@@ -53697,9 +53805,9 @@ var PeerLinkManager = class {
|
|
|
53697
53805
|
* match, hand the authed link to its waiter. Shared by both transports so a
|
|
53698
53806
|
* listener doesn't care HOW the peer dialed in — the token in pendingInbound
|
|
53699
53807
|
* matches either. */
|
|
53700
|
-
acceptInbound(sock,
|
|
53808
|
+
acceptInbound(sock, path6) {
|
|
53701
53809
|
let matchedHex;
|
|
53702
|
-
const { link, ready } = socketPeerLink(sock, "",
|
|
53810
|
+
const { link, ready } = socketPeerLink(sock, "", path6, {
|
|
53703
53811
|
expectToken: (f) => {
|
|
53704
53812
|
const hb = Buffer.from(toHex(f));
|
|
53705
53813
|
for (const key2 of this.pendingInbound.keys()) {
|
|
@@ -54713,7 +54821,7 @@ var ReaddirpStream = class extends Readable {
|
|
|
54713
54821
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
54714
54822
|
const statMethod = opts.lstat ? lstat5 : stat4;
|
|
54715
54823
|
if (wantBigintFsStats) {
|
|
54716
|
-
this._stat = (
|
|
54824
|
+
this._stat = (path6) => statMethod(path6, { bigint: true });
|
|
54717
54825
|
} else {
|
|
54718
54826
|
this._stat = statMethod;
|
|
54719
54827
|
}
|
|
@@ -54738,8 +54846,8 @@ var ReaddirpStream = class extends Readable {
|
|
|
54738
54846
|
const par = this.parent;
|
|
54739
54847
|
const fil = par && par.files;
|
|
54740
54848
|
if (fil && fil.length > 0) {
|
|
54741
|
-
const { path:
|
|
54742
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
54849
|
+
const { path: path6, depth } = par;
|
|
54850
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path6));
|
|
54743
54851
|
const awaited = await Promise.all(slice);
|
|
54744
54852
|
for (const entry of awaited) {
|
|
54745
54853
|
if (!entry)
|
|
@@ -54779,20 +54887,20 @@ var ReaddirpStream = class extends Readable {
|
|
|
54779
54887
|
this.reading = false;
|
|
54780
54888
|
}
|
|
54781
54889
|
}
|
|
54782
|
-
async _exploreDir(
|
|
54890
|
+
async _exploreDir(path6, depth) {
|
|
54783
54891
|
let files;
|
|
54784
54892
|
try {
|
|
54785
|
-
files = await readdir6(
|
|
54893
|
+
files = await readdir6(path6, this._rdOptions);
|
|
54786
54894
|
} catch (error51) {
|
|
54787
54895
|
this._onError(error51);
|
|
54788
54896
|
}
|
|
54789
|
-
return { files, depth, path:
|
|
54897
|
+
return { files, depth, path: path6 };
|
|
54790
54898
|
}
|
|
54791
|
-
async _formatEntry(dirent,
|
|
54899
|
+
async _formatEntry(dirent, path6) {
|
|
54792
54900
|
let entry;
|
|
54793
54901
|
const basename7 = this._isDirent ? dirent.name : dirent;
|
|
54794
54902
|
try {
|
|
54795
|
-
const fullPath = presolve(pjoin(
|
|
54903
|
+
const fullPath = presolve(pjoin(path6, basename7));
|
|
54796
54904
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename7 };
|
|
54797
54905
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
54798
54906
|
} catch (err) {
|
|
@@ -55192,16 +55300,16 @@ var delFromSet = (main2, prop, item) => {
|
|
|
55192
55300
|
};
|
|
55193
55301
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
55194
55302
|
var FsWatchInstances = /* @__PURE__ */ new Map();
|
|
55195
|
-
function createFsWatchInstance(
|
|
55303
|
+
function createFsWatchInstance(path6, options, listener, errHandler, emitRaw) {
|
|
55196
55304
|
const handleEvent = (rawEvent, evPath) => {
|
|
55197
|
-
listener(
|
|
55198
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
55199
|
-
if (evPath &&
|
|
55200
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
55305
|
+
listener(path6);
|
|
55306
|
+
emitRaw(rawEvent, evPath, { watchedPath: path6 });
|
|
55307
|
+
if (evPath && path6 !== evPath) {
|
|
55308
|
+
fsWatchBroadcast(sysPath.resolve(path6, evPath), KEY_LISTENERS, sysPath.join(path6, evPath));
|
|
55201
55309
|
}
|
|
55202
55310
|
};
|
|
55203
55311
|
try {
|
|
55204
|
-
return fs_watch(
|
|
55312
|
+
return fs_watch(path6, {
|
|
55205
55313
|
persistent: options.persistent
|
|
55206
55314
|
}, handleEvent);
|
|
55207
55315
|
} catch (error51) {
|
|
@@ -55217,12 +55325,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
55217
55325
|
listener(val1, val2, val3);
|
|
55218
55326
|
});
|
|
55219
55327
|
};
|
|
55220
|
-
var setFsWatchListener = (
|
|
55328
|
+
var setFsWatchListener = (path6, fullPath, options, handlers) => {
|
|
55221
55329
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
55222
55330
|
let cont = FsWatchInstances.get(fullPath);
|
|
55223
55331
|
let watcher;
|
|
55224
55332
|
if (!options.persistent) {
|
|
55225
|
-
watcher = createFsWatchInstance(
|
|
55333
|
+
watcher = createFsWatchInstance(path6, options, listener, errHandler, rawEmitter);
|
|
55226
55334
|
if (!watcher)
|
|
55227
55335
|
return;
|
|
55228
55336
|
return watcher.close.bind(watcher);
|
|
@@ -55233,7 +55341,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55233
55341
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
55234
55342
|
} else {
|
|
55235
55343
|
watcher = createFsWatchInstance(
|
|
55236
|
-
|
|
55344
|
+
path6,
|
|
55237
55345
|
options,
|
|
55238
55346
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
55239
55347
|
errHandler,
|
|
@@ -55248,7 +55356,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55248
55356
|
cont.watcherUnusable = true;
|
|
55249
55357
|
if (isWindows2 && error51.code === "EPERM") {
|
|
55250
55358
|
try {
|
|
55251
|
-
const fd = await open3(
|
|
55359
|
+
const fd = await open3(path6, "r");
|
|
55252
55360
|
await fd.close();
|
|
55253
55361
|
broadcastErr(error51);
|
|
55254
55362
|
} catch (err) {
|
|
@@ -55279,7 +55387,7 @@ var setFsWatchListener = (path5, fullPath, options, handlers) => {
|
|
|
55279
55387
|
};
|
|
55280
55388
|
};
|
|
55281
55389
|
var FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
55282
|
-
var setFsWatchFileListener = (
|
|
55390
|
+
var setFsWatchFileListener = (path6, fullPath, options, handlers) => {
|
|
55283
55391
|
const { listener, rawEmitter } = handlers;
|
|
55284
55392
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
55285
55393
|
const copts = cont && cont.options;
|
|
@@ -55301,7 +55409,7 @@ var setFsWatchFileListener = (path5, fullPath, options, handlers) => {
|
|
|
55301
55409
|
});
|
|
55302
55410
|
const currmtime = curr.mtimeMs;
|
|
55303
55411
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
55304
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
55412
|
+
foreach(cont.listeners, (listener2) => listener2(path6, curr));
|
|
55305
55413
|
}
|
|
55306
55414
|
})
|
|
55307
55415
|
};
|
|
@@ -55329,13 +55437,13 @@ var NodeFsHandler = class {
|
|
|
55329
55437
|
* @param listener on fs change
|
|
55330
55438
|
* @returns closer for the watcher instance
|
|
55331
55439
|
*/
|
|
55332
|
-
_watchWithNodeFs(
|
|
55440
|
+
_watchWithNodeFs(path6, listener) {
|
|
55333
55441
|
const opts = this.fsw.options;
|
|
55334
|
-
const directory = sysPath.dirname(
|
|
55335
|
-
const basename7 = sysPath.basename(
|
|
55442
|
+
const directory = sysPath.dirname(path6);
|
|
55443
|
+
const basename7 = sysPath.basename(path6);
|
|
55336
55444
|
const parent = this.fsw._getWatchedDir(directory);
|
|
55337
55445
|
parent.add(basename7);
|
|
55338
|
-
const absolutePath = sysPath.resolve(
|
|
55446
|
+
const absolutePath = sysPath.resolve(path6);
|
|
55339
55447
|
const options = {
|
|
55340
55448
|
persistent: opts.persistent
|
|
55341
55449
|
};
|
|
@@ -55345,12 +55453,12 @@ var NodeFsHandler = class {
|
|
|
55345
55453
|
if (opts.usePolling) {
|
|
55346
55454
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
55347
55455
|
options.interval = enableBin && isBinaryPath(basename7) ? opts.binaryInterval : opts.interval;
|
|
55348
|
-
closer = setFsWatchFileListener(
|
|
55456
|
+
closer = setFsWatchFileListener(path6, absolutePath, options, {
|
|
55349
55457
|
listener,
|
|
55350
55458
|
rawEmitter: this.fsw._emitRaw
|
|
55351
55459
|
});
|
|
55352
55460
|
} else {
|
|
55353
|
-
closer = setFsWatchListener(
|
|
55461
|
+
closer = setFsWatchListener(path6, absolutePath, options, {
|
|
55354
55462
|
listener,
|
|
55355
55463
|
errHandler: this._boundHandleError,
|
|
55356
55464
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -55372,7 +55480,7 @@ var NodeFsHandler = class {
|
|
|
55372
55480
|
let prevStats = stats;
|
|
55373
55481
|
if (parent.has(basename7))
|
|
55374
55482
|
return;
|
|
55375
|
-
const listener = async (
|
|
55483
|
+
const listener = async (path6, newStats) => {
|
|
55376
55484
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
55377
55485
|
return;
|
|
55378
55486
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -55386,11 +55494,11 @@ var NodeFsHandler = class {
|
|
|
55386
55494
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
55387
55495
|
}
|
|
55388
55496
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
55389
|
-
this.fsw._closeFile(
|
|
55497
|
+
this.fsw._closeFile(path6);
|
|
55390
55498
|
prevStats = newStats2;
|
|
55391
55499
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
55392
55500
|
if (closer2)
|
|
55393
|
-
this.fsw._addPathCloser(
|
|
55501
|
+
this.fsw._addPathCloser(path6, closer2);
|
|
55394
55502
|
} else {
|
|
55395
55503
|
prevStats = newStats2;
|
|
55396
55504
|
}
|
|
@@ -55422,7 +55530,7 @@ var NodeFsHandler = class {
|
|
|
55422
55530
|
* @param item basename of this item
|
|
55423
55531
|
* @returns true if no more processing is needed for this entry.
|
|
55424
55532
|
*/
|
|
55425
|
-
async _handleSymlink(entry, directory,
|
|
55533
|
+
async _handleSymlink(entry, directory, path6, item) {
|
|
55426
55534
|
if (this.fsw.closed) {
|
|
55427
55535
|
return;
|
|
55428
55536
|
}
|
|
@@ -55432,7 +55540,7 @@ var NodeFsHandler = class {
|
|
|
55432
55540
|
this.fsw._incrReadyCount();
|
|
55433
55541
|
let linkPath;
|
|
55434
55542
|
try {
|
|
55435
|
-
linkPath = await fsrealpath(
|
|
55543
|
+
linkPath = await fsrealpath(path6);
|
|
55436
55544
|
} catch (e) {
|
|
55437
55545
|
this.fsw._emitReady();
|
|
55438
55546
|
return true;
|
|
@@ -55442,12 +55550,12 @@ var NodeFsHandler = class {
|
|
|
55442
55550
|
if (dir2.has(item)) {
|
|
55443
55551
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
55444
55552
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
55445
|
-
this.fsw._emit(EV.CHANGE,
|
|
55553
|
+
this.fsw._emit(EV.CHANGE, path6, entry.stats);
|
|
55446
55554
|
}
|
|
55447
55555
|
} else {
|
|
55448
55556
|
dir2.add(item);
|
|
55449
55557
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
55450
|
-
this.fsw._emit(EV.ADD,
|
|
55558
|
+
this.fsw._emit(EV.ADD, path6, entry.stats);
|
|
55451
55559
|
}
|
|
55452
55560
|
this.fsw._emitReady();
|
|
55453
55561
|
return true;
|
|
@@ -55476,9 +55584,9 @@ var NodeFsHandler = class {
|
|
|
55476
55584
|
return;
|
|
55477
55585
|
}
|
|
55478
55586
|
const item = entry.path;
|
|
55479
|
-
let
|
|
55587
|
+
let path6 = sysPath.join(directory, item);
|
|
55480
55588
|
current.add(item);
|
|
55481
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
55589
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path6, item)) {
|
|
55482
55590
|
return;
|
|
55483
55591
|
}
|
|
55484
55592
|
if (this.fsw.closed) {
|
|
@@ -55487,8 +55595,8 @@ var NodeFsHandler = class {
|
|
|
55487
55595
|
}
|
|
55488
55596
|
if (item === target || !target && !previous.has(item)) {
|
|
55489
55597
|
this.fsw._incrReadyCount();
|
|
55490
|
-
|
|
55491
|
-
this._addToNodeFs(
|
|
55598
|
+
path6 = sysPath.join(dir2, sysPath.relative(dir2, path6));
|
|
55599
|
+
this._addToNodeFs(path6, initialAdd, wh, depth + 1);
|
|
55492
55600
|
}
|
|
55493
55601
|
}).on(EV.ERROR, this._boundHandleError);
|
|
55494
55602
|
return new Promise((resolve10, reject) => {
|
|
@@ -55557,13 +55665,13 @@ var NodeFsHandler = class {
|
|
|
55557
55665
|
* @param depth Child path actually targeted for watch
|
|
55558
55666
|
* @param target Child path actually targeted for watch
|
|
55559
55667
|
*/
|
|
55560
|
-
async _addToNodeFs(
|
|
55668
|
+
async _addToNodeFs(path6, initialAdd, priorWh, depth, target) {
|
|
55561
55669
|
const ready = this.fsw._emitReady;
|
|
55562
|
-
if (this.fsw._isIgnored(
|
|
55670
|
+
if (this.fsw._isIgnored(path6) || this.fsw.closed) {
|
|
55563
55671
|
ready();
|
|
55564
55672
|
return false;
|
|
55565
55673
|
}
|
|
55566
|
-
const wh = this.fsw._getWatchHelpers(
|
|
55674
|
+
const wh = this.fsw._getWatchHelpers(path6);
|
|
55567
55675
|
if (priorWh) {
|
|
55568
55676
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
55569
55677
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -55579,8 +55687,8 @@ var NodeFsHandler = class {
|
|
|
55579
55687
|
const follow = this.fsw.options.followSymlinks;
|
|
55580
55688
|
let closer;
|
|
55581
55689
|
if (stats.isDirectory()) {
|
|
55582
|
-
const absPath = sysPath.resolve(
|
|
55583
|
-
const targetPath = follow ? await fsrealpath(
|
|
55690
|
+
const absPath = sysPath.resolve(path6);
|
|
55691
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
55584
55692
|
if (this.fsw.closed)
|
|
55585
55693
|
return;
|
|
55586
55694
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -55590,29 +55698,29 @@ var NodeFsHandler = class {
|
|
|
55590
55698
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
55591
55699
|
}
|
|
55592
55700
|
} else if (stats.isSymbolicLink()) {
|
|
55593
|
-
const targetPath = follow ? await fsrealpath(
|
|
55701
|
+
const targetPath = follow ? await fsrealpath(path6) : path6;
|
|
55594
55702
|
if (this.fsw.closed)
|
|
55595
55703
|
return;
|
|
55596
55704
|
const parent = sysPath.dirname(wh.watchPath);
|
|
55597
55705
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
55598
55706
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
55599
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
55707
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path6, wh, targetPath);
|
|
55600
55708
|
if (this.fsw.closed)
|
|
55601
55709
|
return;
|
|
55602
55710
|
if (targetPath !== void 0) {
|
|
55603
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
55711
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path6), targetPath);
|
|
55604
55712
|
}
|
|
55605
55713
|
} else {
|
|
55606
55714
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
55607
55715
|
}
|
|
55608
55716
|
ready();
|
|
55609
55717
|
if (closer)
|
|
55610
|
-
this.fsw._addPathCloser(
|
|
55718
|
+
this.fsw._addPathCloser(path6, closer);
|
|
55611
55719
|
return false;
|
|
55612
55720
|
} catch (error51) {
|
|
55613
55721
|
if (this.fsw._handleError(error51)) {
|
|
55614
55722
|
ready();
|
|
55615
|
-
return
|
|
55723
|
+
return path6;
|
|
55616
55724
|
}
|
|
55617
55725
|
}
|
|
55618
55726
|
}
|
|
@@ -55655,26 +55763,26 @@ function createPattern(matcher) {
|
|
|
55655
55763
|
}
|
|
55656
55764
|
return () => false;
|
|
55657
55765
|
}
|
|
55658
|
-
function normalizePath(
|
|
55659
|
-
if (typeof
|
|
55766
|
+
function normalizePath(path6) {
|
|
55767
|
+
if (typeof path6 !== "string")
|
|
55660
55768
|
throw new Error("string expected");
|
|
55661
|
-
|
|
55662
|
-
|
|
55769
|
+
path6 = sysPath2.normalize(path6);
|
|
55770
|
+
path6 = path6.replace(/\\/g, "/");
|
|
55663
55771
|
let prepend = false;
|
|
55664
|
-
if (
|
|
55772
|
+
if (path6.startsWith("//"))
|
|
55665
55773
|
prepend = true;
|
|
55666
55774
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
55667
|
-
while (
|
|
55668
|
-
|
|
55775
|
+
while (path6.match(DOUBLE_SLASH_RE2))
|
|
55776
|
+
path6 = path6.replace(DOUBLE_SLASH_RE2, "/");
|
|
55669
55777
|
if (prepend)
|
|
55670
|
-
|
|
55671
|
-
return
|
|
55778
|
+
path6 = "/" + path6;
|
|
55779
|
+
return path6;
|
|
55672
55780
|
}
|
|
55673
55781
|
function matchPatterns(patterns, testString, stats) {
|
|
55674
|
-
const
|
|
55782
|
+
const path6 = normalizePath(testString);
|
|
55675
55783
|
for (let index = 0; index < patterns.length; index++) {
|
|
55676
55784
|
const pattern = patterns[index];
|
|
55677
|
-
if (pattern(
|
|
55785
|
+
if (pattern(path6, stats)) {
|
|
55678
55786
|
return true;
|
|
55679
55787
|
}
|
|
55680
55788
|
}
|
|
@@ -55714,19 +55822,19 @@ var toUnix = (string4) => {
|
|
|
55714
55822
|
}
|
|
55715
55823
|
return str2;
|
|
55716
55824
|
};
|
|
55717
|
-
var normalizePathToUnix = (
|
|
55718
|
-
var normalizeIgnored = (cwd = "") => (
|
|
55719
|
-
if (typeof
|
|
55720
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
55825
|
+
var normalizePathToUnix = (path6) => toUnix(sysPath2.normalize(toUnix(path6)));
|
|
55826
|
+
var normalizeIgnored = (cwd = "") => (path6) => {
|
|
55827
|
+
if (typeof path6 === "string") {
|
|
55828
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path6) ? path6 : sysPath2.join(cwd, path6));
|
|
55721
55829
|
} else {
|
|
55722
|
-
return
|
|
55830
|
+
return path6;
|
|
55723
55831
|
}
|
|
55724
55832
|
};
|
|
55725
|
-
var getAbsolutePath = (
|
|
55726
|
-
if (sysPath2.isAbsolute(
|
|
55727
|
-
return
|
|
55833
|
+
var getAbsolutePath = (path6, cwd) => {
|
|
55834
|
+
if (sysPath2.isAbsolute(path6)) {
|
|
55835
|
+
return path6;
|
|
55728
55836
|
}
|
|
55729
|
-
return sysPath2.join(cwd,
|
|
55837
|
+
return sysPath2.join(cwd, path6);
|
|
55730
55838
|
};
|
|
55731
55839
|
var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
55732
55840
|
var DirEntry = class {
|
|
@@ -55781,10 +55889,10 @@ var DirEntry = class {
|
|
|
55781
55889
|
var STAT_METHOD_F = "stat";
|
|
55782
55890
|
var STAT_METHOD_L = "lstat";
|
|
55783
55891
|
var WatchHelper = class {
|
|
55784
|
-
constructor(
|
|
55892
|
+
constructor(path6, follow, fsw) {
|
|
55785
55893
|
this.fsw = fsw;
|
|
55786
|
-
const watchPath =
|
|
55787
|
-
this.path =
|
|
55894
|
+
const watchPath = path6;
|
|
55895
|
+
this.path = path6 = path6.replace(REPLACER_RE, "");
|
|
55788
55896
|
this.watchPath = watchPath;
|
|
55789
55897
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
55790
55898
|
this.dirParts = [];
|
|
@@ -55906,20 +56014,20 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
55906
56014
|
this._closePromise = void 0;
|
|
55907
56015
|
let paths = unifyPaths(paths_);
|
|
55908
56016
|
if (cwd) {
|
|
55909
|
-
paths = paths.map((
|
|
55910
|
-
const absPath = getAbsolutePath(
|
|
56017
|
+
paths = paths.map((path6) => {
|
|
56018
|
+
const absPath = getAbsolutePath(path6, cwd);
|
|
55911
56019
|
return absPath;
|
|
55912
56020
|
});
|
|
55913
56021
|
}
|
|
55914
|
-
paths.forEach((
|
|
55915
|
-
this._removeIgnoredPath(
|
|
56022
|
+
paths.forEach((path6) => {
|
|
56023
|
+
this._removeIgnoredPath(path6);
|
|
55916
56024
|
});
|
|
55917
56025
|
this._userIgnored = void 0;
|
|
55918
56026
|
if (!this._readyCount)
|
|
55919
56027
|
this._readyCount = 0;
|
|
55920
56028
|
this._readyCount += paths.length;
|
|
55921
|
-
Promise.all(paths.map(async (
|
|
55922
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
56029
|
+
Promise.all(paths.map(async (path6) => {
|
|
56030
|
+
const res = await this._nodeFsHandler._addToNodeFs(path6, !_internal, void 0, 0, _origAdd);
|
|
55923
56031
|
if (res)
|
|
55924
56032
|
this._emitReady();
|
|
55925
56033
|
return res;
|
|
@@ -55941,17 +56049,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
55941
56049
|
return this;
|
|
55942
56050
|
const paths = unifyPaths(paths_);
|
|
55943
56051
|
const { cwd } = this.options;
|
|
55944
|
-
paths.forEach((
|
|
55945
|
-
if (!sysPath2.isAbsolute(
|
|
56052
|
+
paths.forEach((path6) => {
|
|
56053
|
+
if (!sysPath2.isAbsolute(path6) && !this._closers.has(path6)) {
|
|
55946
56054
|
if (cwd)
|
|
55947
|
-
|
|
55948
|
-
|
|
56055
|
+
path6 = sysPath2.join(cwd, path6);
|
|
56056
|
+
path6 = sysPath2.resolve(path6);
|
|
55949
56057
|
}
|
|
55950
|
-
this._closePath(
|
|
55951
|
-
this._addIgnoredPath(
|
|
55952
|
-
if (this._watched.has(
|
|
56058
|
+
this._closePath(path6);
|
|
56059
|
+
this._addIgnoredPath(path6);
|
|
56060
|
+
if (this._watched.has(path6)) {
|
|
55953
56061
|
this._addIgnoredPath({
|
|
55954
|
-
path:
|
|
56062
|
+
path: path6,
|
|
55955
56063
|
recursive: true
|
|
55956
56064
|
});
|
|
55957
56065
|
}
|
|
@@ -56015,38 +56123,38 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56015
56123
|
* @param stats arguments to be passed with event
|
|
56016
56124
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
56017
56125
|
*/
|
|
56018
|
-
async _emit(event,
|
|
56126
|
+
async _emit(event, path6, stats) {
|
|
56019
56127
|
if (this.closed)
|
|
56020
56128
|
return;
|
|
56021
56129
|
const opts = this.options;
|
|
56022
56130
|
if (isWindows2)
|
|
56023
|
-
|
|
56131
|
+
path6 = sysPath2.normalize(path6);
|
|
56024
56132
|
if (opts.cwd)
|
|
56025
|
-
|
|
56026
|
-
const args = [
|
|
56133
|
+
path6 = sysPath2.relative(opts.cwd, path6);
|
|
56134
|
+
const args = [path6];
|
|
56027
56135
|
if (stats != null)
|
|
56028
56136
|
args.push(stats);
|
|
56029
56137
|
const awf = opts.awaitWriteFinish;
|
|
56030
56138
|
let pw;
|
|
56031
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
56139
|
+
if (awf && (pw = this._pendingWrites.get(path6))) {
|
|
56032
56140
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
56033
56141
|
return this;
|
|
56034
56142
|
}
|
|
56035
56143
|
if (opts.atomic) {
|
|
56036
56144
|
if (event === EVENTS.UNLINK) {
|
|
56037
|
-
this._pendingUnlinks.set(
|
|
56145
|
+
this._pendingUnlinks.set(path6, [event, ...args]);
|
|
56038
56146
|
setTimeout(() => {
|
|
56039
|
-
this._pendingUnlinks.forEach((entry,
|
|
56147
|
+
this._pendingUnlinks.forEach((entry, path7) => {
|
|
56040
56148
|
this.emit(...entry);
|
|
56041
56149
|
this.emit(EVENTS.ALL, ...entry);
|
|
56042
|
-
this._pendingUnlinks.delete(
|
|
56150
|
+
this._pendingUnlinks.delete(path7);
|
|
56043
56151
|
});
|
|
56044
56152
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
56045
56153
|
return this;
|
|
56046
56154
|
}
|
|
56047
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
56155
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path6)) {
|
|
56048
56156
|
event = EVENTS.CHANGE;
|
|
56049
|
-
this._pendingUnlinks.delete(
|
|
56157
|
+
this._pendingUnlinks.delete(path6);
|
|
56050
56158
|
}
|
|
56051
56159
|
}
|
|
56052
56160
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -56064,16 +56172,16 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56064
56172
|
this.emitWithAll(event, args);
|
|
56065
56173
|
}
|
|
56066
56174
|
};
|
|
56067
|
-
this._awaitWriteFinish(
|
|
56175
|
+
this._awaitWriteFinish(path6, awf.stabilityThreshold, event, awfEmit);
|
|
56068
56176
|
return this;
|
|
56069
56177
|
}
|
|
56070
56178
|
if (event === EVENTS.CHANGE) {
|
|
56071
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
56179
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path6, 50);
|
|
56072
56180
|
if (isThrottled)
|
|
56073
56181
|
return this;
|
|
56074
56182
|
}
|
|
56075
56183
|
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,
|
|
56184
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path6) : path6;
|
|
56077
56185
|
let stats2;
|
|
56078
56186
|
try {
|
|
56079
56187
|
stats2 = await stat6(fullPath);
|
|
@@ -56104,23 +56212,23 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56104
56212
|
* @param timeout duration of time to suppress duplicate actions
|
|
56105
56213
|
* @returns tracking object or false if action should be suppressed
|
|
56106
56214
|
*/
|
|
56107
|
-
_throttle(actionType,
|
|
56215
|
+
_throttle(actionType, path6, timeout) {
|
|
56108
56216
|
if (!this._throttled.has(actionType)) {
|
|
56109
56217
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
56110
56218
|
}
|
|
56111
56219
|
const action = this._throttled.get(actionType);
|
|
56112
56220
|
if (!action)
|
|
56113
56221
|
throw new Error("invalid throttle");
|
|
56114
|
-
const actionPath = action.get(
|
|
56222
|
+
const actionPath = action.get(path6);
|
|
56115
56223
|
if (actionPath) {
|
|
56116
56224
|
actionPath.count++;
|
|
56117
56225
|
return false;
|
|
56118
56226
|
}
|
|
56119
56227
|
let timeoutObject;
|
|
56120
56228
|
const clear = () => {
|
|
56121
|
-
const item = action.get(
|
|
56229
|
+
const item = action.get(path6);
|
|
56122
56230
|
const count = item ? item.count : 0;
|
|
56123
|
-
action.delete(
|
|
56231
|
+
action.delete(path6);
|
|
56124
56232
|
clearTimeout(timeoutObject);
|
|
56125
56233
|
if (item)
|
|
56126
56234
|
clearTimeout(item.timeoutObject);
|
|
@@ -56128,7 +56236,7 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56128
56236
|
};
|
|
56129
56237
|
timeoutObject = setTimeout(clear, timeout);
|
|
56130
56238
|
const thr = { timeoutObject, clear, count: 0 };
|
|
56131
|
-
action.set(
|
|
56239
|
+
action.set(path6, thr);
|
|
56132
56240
|
return thr;
|
|
56133
56241
|
}
|
|
56134
56242
|
_incrReadyCount() {
|
|
@@ -56142,44 +56250,44 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56142
56250
|
* @param event
|
|
56143
56251
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
56144
56252
|
*/
|
|
56145
|
-
_awaitWriteFinish(
|
|
56253
|
+
_awaitWriteFinish(path6, threshold, event, awfEmit) {
|
|
56146
56254
|
const awf = this.options.awaitWriteFinish;
|
|
56147
56255
|
if (typeof awf !== "object")
|
|
56148
56256
|
return;
|
|
56149
56257
|
const pollInterval = awf.pollInterval;
|
|
56150
56258
|
let timeoutHandler;
|
|
56151
|
-
let fullPath =
|
|
56152
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
56153
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
56259
|
+
let fullPath = path6;
|
|
56260
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path6)) {
|
|
56261
|
+
fullPath = sysPath2.join(this.options.cwd, path6);
|
|
56154
56262
|
}
|
|
56155
56263
|
const now2 = /* @__PURE__ */ new Date();
|
|
56156
56264
|
const writes = this._pendingWrites;
|
|
56157
56265
|
function awaitWriteFinishFn(prevStat) {
|
|
56158
56266
|
statcb(fullPath, (err, curStat) => {
|
|
56159
|
-
if (err || !writes.has(
|
|
56267
|
+
if (err || !writes.has(path6)) {
|
|
56160
56268
|
if (err && err.code !== "ENOENT")
|
|
56161
56269
|
awfEmit(err);
|
|
56162
56270
|
return;
|
|
56163
56271
|
}
|
|
56164
56272
|
const now3 = Number(/* @__PURE__ */ new Date());
|
|
56165
56273
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
56166
|
-
writes.get(
|
|
56274
|
+
writes.get(path6).lastChange = now3;
|
|
56167
56275
|
}
|
|
56168
|
-
const pw = writes.get(
|
|
56276
|
+
const pw = writes.get(path6);
|
|
56169
56277
|
const df = now3 - pw.lastChange;
|
|
56170
56278
|
if (df >= threshold) {
|
|
56171
|
-
writes.delete(
|
|
56279
|
+
writes.delete(path6);
|
|
56172
56280
|
awfEmit(void 0, curStat);
|
|
56173
56281
|
} else {
|
|
56174
56282
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
56175
56283
|
}
|
|
56176
56284
|
});
|
|
56177
56285
|
}
|
|
56178
|
-
if (!writes.has(
|
|
56179
|
-
writes.set(
|
|
56286
|
+
if (!writes.has(path6)) {
|
|
56287
|
+
writes.set(path6, {
|
|
56180
56288
|
lastChange: now2,
|
|
56181
56289
|
cancelWait: () => {
|
|
56182
|
-
writes.delete(
|
|
56290
|
+
writes.delete(path6);
|
|
56183
56291
|
clearTimeout(timeoutHandler);
|
|
56184
56292
|
return event;
|
|
56185
56293
|
}
|
|
@@ -56190,8 +56298,8 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56190
56298
|
/**
|
|
56191
56299
|
* Determines whether user has asked to ignore this path.
|
|
56192
56300
|
*/
|
|
56193
|
-
_isIgnored(
|
|
56194
|
-
if (this.options.atomic && DOT_RE.test(
|
|
56301
|
+
_isIgnored(path6, stats) {
|
|
56302
|
+
if (this.options.atomic && DOT_RE.test(path6))
|
|
56195
56303
|
return true;
|
|
56196
56304
|
if (!this._userIgnored) {
|
|
56197
56305
|
const { cwd } = this.options;
|
|
@@ -56201,17 +56309,17 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56201
56309
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
56202
56310
|
this._userIgnored = anymatch(list, void 0);
|
|
56203
56311
|
}
|
|
56204
|
-
return this._userIgnored(
|
|
56312
|
+
return this._userIgnored(path6, stats);
|
|
56205
56313
|
}
|
|
56206
|
-
_isntIgnored(
|
|
56207
|
-
return !this._isIgnored(
|
|
56314
|
+
_isntIgnored(path6, stat7) {
|
|
56315
|
+
return !this._isIgnored(path6, stat7);
|
|
56208
56316
|
}
|
|
56209
56317
|
/**
|
|
56210
56318
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
56211
56319
|
* @param path file or directory pattern being watched
|
|
56212
56320
|
*/
|
|
56213
|
-
_getWatchHelpers(
|
|
56214
|
-
return new WatchHelper(
|
|
56321
|
+
_getWatchHelpers(path6) {
|
|
56322
|
+
return new WatchHelper(path6, this.options.followSymlinks, this);
|
|
56215
56323
|
}
|
|
56216
56324
|
// Directory helpers
|
|
56217
56325
|
// -----------------
|
|
@@ -56243,63 +56351,63 @@ var FSWatcher = class extends EventEmitter2 {
|
|
|
56243
56351
|
* @param item base path of item/directory
|
|
56244
56352
|
*/
|
|
56245
56353
|
_remove(directory, item, isDirectory) {
|
|
56246
|
-
const
|
|
56247
|
-
const fullPath = sysPath2.resolve(
|
|
56248
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
56249
|
-
if (!this._throttle("remove",
|
|
56354
|
+
const path6 = sysPath2.join(directory, item);
|
|
56355
|
+
const fullPath = sysPath2.resolve(path6);
|
|
56356
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path6) || this._watched.has(fullPath);
|
|
56357
|
+
if (!this._throttle("remove", path6, 100))
|
|
56250
56358
|
return;
|
|
56251
56359
|
if (!isDirectory && this._watched.size === 1) {
|
|
56252
56360
|
this.add(directory, item, true);
|
|
56253
56361
|
}
|
|
56254
|
-
const wp = this._getWatchedDir(
|
|
56362
|
+
const wp = this._getWatchedDir(path6);
|
|
56255
56363
|
const nestedDirectoryChildren = wp.getChildren();
|
|
56256
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
56364
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path6, nested));
|
|
56257
56365
|
const parent = this._getWatchedDir(directory);
|
|
56258
56366
|
const wasTracked = parent.has(item);
|
|
56259
56367
|
parent.remove(item);
|
|
56260
56368
|
if (this._symlinkPaths.has(fullPath)) {
|
|
56261
56369
|
this._symlinkPaths.delete(fullPath);
|
|
56262
56370
|
}
|
|
56263
|
-
let relPath =
|
|
56371
|
+
let relPath = path6;
|
|
56264
56372
|
if (this.options.cwd)
|
|
56265
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
56373
|
+
relPath = sysPath2.relative(this.options.cwd, path6);
|
|
56266
56374
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
56267
56375
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
56268
56376
|
if (event === EVENTS.ADD)
|
|
56269
56377
|
return;
|
|
56270
56378
|
}
|
|
56271
|
-
this._watched.delete(
|
|
56379
|
+
this._watched.delete(path6);
|
|
56272
56380
|
this._watched.delete(fullPath);
|
|
56273
56381
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
56274
|
-
if (wasTracked && !this._isIgnored(
|
|
56275
|
-
this._emit(eventName,
|
|
56276
|
-
this._closePath(
|
|
56382
|
+
if (wasTracked && !this._isIgnored(path6))
|
|
56383
|
+
this._emit(eventName, path6);
|
|
56384
|
+
this._closePath(path6);
|
|
56277
56385
|
}
|
|
56278
56386
|
/**
|
|
56279
56387
|
* Closes all watchers for a path
|
|
56280
56388
|
*/
|
|
56281
|
-
_closePath(
|
|
56282
|
-
this._closeFile(
|
|
56283
|
-
const dir2 = sysPath2.dirname(
|
|
56284
|
-
this._getWatchedDir(dir2).remove(sysPath2.basename(
|
|
56389
|
+
_closePath(path6) {
|
|
56390
|
+
this._closeFile(path6);
|
|
56391
|
+
const dir2 = sysPath2.dirname(path6);
|
|
56392
|
+
this._getWatchedDir(dir2).remove(sysPath2.basename(path6));
|
|
56285
56393
|
}
|
|
56286
56394
|
/**
|
|
56287
56395
|
* Closes only file-specific watchers
|
|
56288
56396
|
*/
|
|
56289
|
-
_closeFile(
|
|
56290
|
-
const closers = this._closers.get(
|
|
56397
|
+
_closeFile(path6) {
|
|
56398
|
+
const closers = this._closers.get(path6);
|
|
56291
56399
|
if (!closers)
|
|
56292
56400
|
return;
|
|
56293
56401
|
closers.forEach((closer) => closer());
|
|
56294
|
-
this._closers.delete(
|
|
56402
|
+
this._closers.delete(path6);
|
|
56295
56403
|
}
|
|
56296
|
-
_addPathCloser(
|
|
56404
|
+
_addPathCloser(path6, closer) {
|
|
56297
56405
|
if (!closer)
|
|
56298
56406
|
return;
|
|
56299
|
-
let list = this._closers.get(
|
|
56407
|
+
let list = this._closers.get(path6);
|
|
56300
56408
|
if (!list) {
|
|
56301
56409
|
list = [];
|
|
56302
|
-
this._closers.set(
|
|
56410
|
+
this._closers.set(path6, list);
|
|
56303
56411
|
}
|
|
56304
56412
|
list.push(closer);
|
|
56305
56413
|
}
|
|
@@ -57464,9 +57572,9 @@ function friendlyLabel(id, label) {
|
|
|
57464
57572
|
return `Command line (${label})`;
|
|
57465
57573
|
}
|
|
57466
57574
|
}
|
|
57467
|
-
function mk(id,
|
|
57575
|
+
function mk(id, path6, isDefault, label) {
|
|
57468
57576
|
const lbl = label ?? id;
|
|
57469
|
-
return { id, label: lbl, friendly: friendlyLabel(id, lbl), path:
|
|
57577
|
+
return { id, label: lbl, friendly: friendlyLabel(id, lbl), path: path6, default: isDefault || void 0 };
|
|
57470
57578
|
}
|
|
57471
57579
|
function listInterpreters() {
|
|
57472
57580
|
return process.platform === "win32" ? listWindows() : listUnix();
|
|
@@ -57475,11 +57583,11 @@ function listUnix() {
|
|
|
57475
57583
|
const out = [];
|
|
57476
57584
|
const seen = /* @__PURE__ */ new Set();
|
|
57477
57585
|
const loginShell = process.env.SHELL || "";
|
|
57478
|
-
const add = (id,
|
|
57479
|
-
if (!
|
|
57586
|
+
const add = (id, path6) => {
|
|
57587
|
+
if (!path6 || seen.has(path6) || !existsSync14(path6))
|
|
57480
57588
|
return;
|
|
57481
|
-
seen.add(
|
|
57482
|
-
out.push(mk(id,
|
|
57589
|
+
seen.add(path6);
|
|
57590
|
+
out.push(mk(id, path6, path6 === loginShell));
|
|
57483
57591
|
};
|
|
57484
57592
|
if (loginShell)
|
|
57485
57593
|
add(idForPath(loginShell), loginShell);
|
|
@@ -57507,9 +57615,9 @@ function listWindows() {
|
|
|
57507
57615
|
const pf = process.env.ProgramFiles || "C:\\Program Files";
|
|
57508
57616
|
const gitBash = `${pf}\\Git\\bin\\bash.exe`;
|
|
57509
57617
|
const pwsh7 = `${pf}\\PowerShell\\7\\pwsh.exe`;
|
|
57510
|
-
const add = (id,
|
|
57511
|
-
if (
|
|
57512
|
-
out.push(mk(id,
|
|
57618
|
+
const add = (id, path6, label, isDefault = false) => {
|
|
57619
|
+
if (path6 && existsSync14(path6))
|
|
57620
|
+
out.push(mk(id, path6, isDefault, label));
|
|
57513
57621
|
};
|
|
57514
57622
|
add("powershell", winPwsh, "Windows PowerShell", true);
|
|
57515
57623
|
add("pwsh", pwsh7, "pwsh");
|
|
@@ -58205,7 +58313,8 @@ async function handleInboundAgent(msg, driverClientId) {
|
|
|
58205
58313
|
driverBySession.set(msg.sessionId, driverClientId);
|
|
58206
58314
|
const messages = await b.getMessages(msg.sessionId).catch(() => []);
|
|
58207
58315
|
const artifacts = await (b.getSessionArtifacts?.(msg.sessionId, msg.projectDir).catch(() => []) ?? Promise.resolve([]));
|
|
58208
|
-
|
|
58316
|
+
const sessionCostUsd = await (b.getSessionCost?.(msg.sessionId, msg.projectDir).catch(() => 0) ?? Promise.resolve(0));
|
|
58317
|
+
send2("agent", { type: "session:messages", sessionId: msg.sessionId, messages, artifacts, ...sessionCostUsd > 0 ? { sessionCostUsd } : {} }, route2);
|
|
58209
58318
|
break;
|
|
58210
58319
|
}
|
|
58211
58320
|
case "session:summarize": {
|
|
@@ -58227,6 +58336,9 @@ async function handleInboundAgent(msg, driverClientId) {
|
|
|
58227
58336
|
case "agent:trace":
|
|
58228
58337
|
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
58338
|
break;
|
|
58339
|
+
case "agent:subagentMessages":
|
|
58340
|
+
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));
|
|
58341
|
+
break;
|
|
58230
58342
|
case "session:merge":
|
|
58231
58343
|
void b.mergeSessions?.(msg.sessionIds, { projectDir: msg.projectDir, title: msg.title, clientRequestId: msg.clientRequestId, origin }).catch(() => {
|
|
58232
58344
|
});
|
|
@@ -58979,7 +59091,8 @@ async function startLocalServer(opts) {
|
|
|
58979
59091
|
case "session:resume": {
|
|
58980
59092
|
const messages = await b.getMessages(msg.sessionId).catch(() => []);
|
|
58981
59093
|
const artifacts = await (b.getSessionArtifacts?.(msg.sessionId, msg.projectDir).catch(() => []) ?? Promise.resolve([]));
|
|
58982
|
-
|
|
59094
|
+
const sessionCostUsd = await (b.getSessionCost?.(msg.sessionId, msg.projectDir).catch(() => 0) ?? Promise.resolve(0));
|
|
59095
|
+
send3("agent", { type: "session:messages", sessionId: msg.sessionId, messages, artifacts, ...sessionCostUsd > 0 ? { sessionCostUsd } : {} });
|
|
58983
59096
|
break;
|
|
58984
59097
|
}
|
|
58985
59098
|
case "session:summarize": {
|
|
@@ -59001,6 +59114,9 @@ async function startLocalServer(opts) {
|
|
|
59001
59114
|
case "agent:trace":
|
|
59002
59115
|
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
59116
|
break;
|
|
59117
|
+
case "agent:subagentMessages":
|
|
59118
|
+
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 }));
|
|
59119
|
+
break;
|
|
59004
59120
|
case "session:merge":
|
|
59005
59121
|
void b.mergeSessions?.(msg.sessionIds, { projectDir: msg.projectDir, title: msg.title, clientRequestId: msg.clientRequestId, origin: loopbackOrigin }).catch(() => {
|
|
59006
59122
|
});
|