@hotpathrun/cli 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hotpath.mjs
CHANGED
|
@@ -982,7 +982,7 @@ var require_command = __commonJS({
|
|
|
982
982
|
"../../node_modules/.pnpm/commander@12.1.0/node_modules/commander/lib/command.js"(exports) {
|
|
983
983
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
984
984
|
var childProcess = __require("node:child_process");
|
|
985
|
-
var
|
|
985
|
+
var path36 = __require("node:path");
|
|
986
986
|
var fs6 = __require("node:fs");
|
|
987
987
|
var process4 = __require("node:process");
|
|
988
988
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1915,9 +1915,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1915
1915
|
let launchWithNode = false;
|
|
1916
1916
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1917
1917
|
function findFile(baseDir, baseName) {
|
|
1918
|
-
const localBin =
|
|
1918
|
+
const localBin = path36.resolve(baseDir, baseName);
|
|
1919
1919
|
if (fs6.existsSync(localBin)) return localBin;
|
|
1920
|
-
if (sourceExt.includes(
|
|
1920
|
+
if (sourceExt.includes(path36.extname(baseName))) return void 0;
|
|
1921
1921
|
const foundExt = sourceExt.find(
|
|
1922
1922
|
(ext) => fs6.existsSync(`${localBin}${ext}`)
|
|
1923
1923
|
);
|
|
@@ -1935,17 +1935,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1935
1935
|
} catch (err) {
|
|
1936
1936
|
resolvedScriptPath = this._scriptPath;
|
|
1937
1937
|
}
|
|
1938
|
-
executableDir =
|
|
1939
|
-
|
|
1938
|
+
executableDir = path36.resolve(
|
|
1939
|
+
path36.dirname(resolvedScriptPath),
|
|
1940
1940
|
executableDir
|
|
1941
1941
|
);
|
|
1942
1942
|
}
|
|
1943
1943
|
if (executableDir) {
|
|
1944
1944
|
let localFile = findFile(executableDir, executableFile);
|
|
1945
1945
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1946
|
-
const legacyName =
|
|
1946
|
+
const legacyName = path36.basename(
|
|
1947
1947
|
this._scriptPath,
|
|
1948
|
-
|
|
1948
|
+
path36.extname(this._scriptPath)
|
|
1949
1949
|
);
|
|
1950
1950
|
if (legacyName !== this._name) {
|
|
1951
1951
|
localFile = findFile(
|
|
@@ -1956,7 +1956,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1956
1956
|
}
|
|
1957
1957
|
executableFile = localFile || executableFile;
|
|
1958
1958
|
}
|
|
1959
|
-
launchWithNode = sourceExt.includes(
|
|
1959
|
+
launchWithNode = sourceExt.includes(path36.extname(executableFile));
|
|
1960
1960
|
let proc;
|
|
1961
1961
|
if (process4.platform !== "win32") {
|
|
1962
1962
|
if (launchWithNode) {
|
|
@@ -2796,7 +2796,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2796
2796
|
* @return {Command}
|
|
2797
2797
|
*/
|
|
2798
2798
|
nameFromFilename(filename) {
|
|
2799
|
-
this._name =
|
|
2799
|
+
this._name = path36.basename(filename, path36.extname(filename));
|
|
2800
2800
|
return this;
|
|
2801
2801
|
}
|
|
2802
2802
|
/**
|
|
@@ -2810,9 +2810,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2810
2810
|
* @param {string} [path]
|
|
2811
2811
|
* @return {(string|null|Command)}
|
|
2812
2812
|
*/
|
|
2813
|
-
executableDir(
|
|
2814
|
-
if (
|
|
2815
|
-
this._executableDir =
|
|
2813
|
+
executableDir(path37) {
|
|
2814
|
+
if (path37 === void 0) return this._executableDir;
|
|
2815
|
+
this._executableDir = path37;
|
|
2816
2816
|
return this;
|
|
2817
2817
|
}
|
|
2818
2818
|
/**
|
|
@@ -3478,8 +3478,8 @@ var init_parseUtil = __esm({
|
|
|
3478
3478
|
init_errors();
|
|
3479
3479
|
init_en();
|
|
3480
3480
|
makeIssue = (params) => {
|
|
3481
|
-
const { data, path:
|
|
3482
|
-
const fullPath = [...
|
|
3481
|
+
const { data, path: path36, errorMaps, issueData } = params;
|
|
3482
|
+
const fullPath = [...path36, ...issueData.path || []];
|
|
3483
3483
|
const fullIssue = {
|
|
3484
3484
|
...issueData,
|
|
3485
3485
|
path: fullPath
|
|
@@ -3787,11 +3787,11 @@ var init_types = __esm({
|
|
|
3787
3787
|
init_parseUtil();
|
|
3788
3788
|
init_util();
|
|
3789
3789
|
ParseInputLazyPath = class {
|
|
3790
|
-
constructor(parent, value,
|
|
3790
|
+
constructor(parent, value, path36, key) {
|
|
3791
3791
|
this._cachedPath = [];
|
|
3792
3792
|
this.parent = parent;
|
|
3793
3793
|
this.data = value;
|
|
3794
|
-
this._path =
|
|
3794
|
+
this._path = path36;
|
|
3795
3795
|
this._key = key;
|
|
3796
3796
|
}
|
|
3797
3797
|
get path() {
|
|
@@ -7196,8 +7196,8 @@ function renderString(text, ctx) {
|
|
|
7196
7196
|
function lookupReference(expr, ctx) {
|
|
7197
7197
|
return lookup(expr, ctx);
|
|
7198
7198
|
}
|
|
7199
|
-
function walk(value,
|
|
7200
|
-
for (const p3 of
|
|
7199
|
+
function walk(value, path36) {
|
|
7200
|
+
for (const p3 of path36) value = child(value, p3);
|
|
7201
7201
|
return value;
|
|
7202
7202
|
}
|
|
7203
7203
|
function lookup(expr, ctx) {
|
|
@@ -7945,8 +7945,8 @@ var init_schemas = __esm({
|
|
|
7945
7945
|
|
|
7946
7946
|
// ../shared/src/trace.ts
|
|
7947
7947
|
import { readFile } from "node:fs/promises";
|
|
7948
|
-
async function readTrace(
|
|
7949
|
-
const lines = (await readFile(
|
|
7948
|
+
async function readTrace(file2, options = {}) {
|
|
7949
|
+
const lines = (await readFile(file2, "utf8")).split("\n").map((l2) => l2.trim()).filter((l2) => l2.length > 0);
|
|
7950
7950
|
const hasEnd = lines.some((l2) => l2.includes('"type":"end"'));
|
|
7951
7951
|
if (options.allowOpen && !hasEnd && lines.length > 0) {
|
|
7952
7952
|
try {
|
|
@@ -7959,7 +7959,7 @@ async function readTrace(file, options = {}) {
|
|
|
7959
7959
|
const meta = parsed.find((l2) => l2.type === "meta");
|
|
7960
7960
|
const end = parsed.find((l2) => l2.type === "end");
|
|
7961
7961
|
if (!meta || !end && !options.allowOpen) {
|
|
7962
|
-
throw new Error(`trace ${
|
|
7962
|
+
throw new Error(`trace ${file2} is missing a meta or end line`);
|
|
7963
7963
|
}
|
|
7964
7964
|
const calls = parsed.filter((l2) => l2.type === "tool_call").map((l2) => traceToolCallSchema.parse(l2));
|
|
7965
7965
|
const parsedMeta = traceMetaSchema.parse(meta);
|
|
@@ -10881,14 +10881,14 @@ function redactSensitive(body) {
|
|
|
10881
10881
|
}
|
|
10882
10882
|
return null;
|
|
10883
10883
|
}
|
|
10884
|
-
async function checkCredentialsFileSafety(
|
|
10884
|
+
async function checkCredentialsFileSafety(path36, onWarn = (m3) => console.warn(`anthropic-sdk: ${m3}`)) {
|
|
10885
10885
|
if (typeof process === "undefined" || process.platform === "win32")
|
|
10886
10886
|
return;
|
|
10887
10887
|
const { fs: fs6 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
10888
|
-
let resolved =
|
|
10888
|
+
let resolved = path36;
|
|
10889
10889
|
let st2;
|
|
10890
10890
|
try {
|
|
10891
|
-
resolved = await fs6.promises.realpath(
|
|
10891
|
+
resolved = await fs6.promises.realpath(path36);
|
|
10892
10892
|
st2 = await fs6.promises.stat(resolved);
|
|
10893
10893
|
} catch {
|
|
10894
10894
|
return;
|
|
@@ -10905,8 +10905,8 @@ async function checkCredentialsFileSafety(path34, onWarn = (m3) => console.warn(
|
|
|
10905
10905
|
}
|
|
10906
10906
|
}
|
|
10907
10907
|
async function writeCredentialsFileAtomic(targetPath, data) {
|
|
10908
|
-
const { fs: fs6, path:
|
|
10909
|
-
const dir =
|
|
10908
|
+
const { fs: fs6, path: path36 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
10909
|
+
const dir = path36.dirname(targetPath);
|
|
10910
10910
|
await fs6.promises.mkdir(dir, { recursive: true, mode: 448 });
|
|
10911
10911
|
const tmpPath = `${targetPath}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
10912
10912
|
try {
|
|
@@ -11855,9 +11855,9 @@ function stainlessHelperHeader(tools, messages) {
|
|
|
11855
11855
|
return {};
|
|
11856
11856
|
return { [STAINLESS_HELPER_HEADER]: helpers.join(", ") };
|
|
11857
11857
|
}
|
|
11858
|
-
function stainlessHelperHeaderFromFile(
|
|
11859
|
-
if (wasCreatedByStainlessHelper(
|
|
11860
|
-
return { [STAINLESS_HELPER_HEADER]:
|
|
11858
|
+
function stainlessHelperHeaderFromFile(file2) {
|
|
11859
|
+
if (wasCreatedByStainlessHelper(file2)) {
|
|
11860
|
+
return { [STAINLESS_HELPER_HEADER]: file2[SDK_HELPER_SYMBOL] };
|
|
11861
11861
|
}
|
|
11862
11862
|
return {};
|
|
11863
11863
|
}
|
|
@@ -12078,8 +12078,8 @@ var init_credentials = __esm({
|
|
|
12078
12078
|
return null;
|
|
12079
12079
|
}
|
|
12080
12080
|
validateProfileName(profileName);
|
|
12081
|
-
const { fs: fs6, path:
|
|
12082
|
-
const configPath =
|
|
12081
|
+
const { fs: fs6, path: path36 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
12082
|
+
const configPath = path36.join(rootConfigPath, "configs", `${profileName}.json`);
|
|
12083
12083
|
let configRaw;
|
|
12084
12084
|
try {
|
|
12085
12085
|
configRaw = await fs6.promises.readFile(configPath, "utf-8");
|
|
@@ -12139,37 +12139,37 @@ var init_credentials = __esm({
|
|
|
12139
12139
|
return null;
|
|
12140
12140
|
}
|
|
12141
12141
|
validateProfileName(profileName);
|
|
12142
|
-
const { path:
|
|
12143
|
-
return
|
|
12142
|
+
const { path: path36 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
12143
|
+
return path36.join(rootConfigPath, "credentials", `${profileName}.json`);
|
|
12144
12144
|
};
|
|
12145
12145
|
getRootConfigPath = async () => {
|
|
12146
12146
|
if (!supportsLocalConfigFiles()) {
|
|
12147
12147
|
return null;
|
|
12148
12148
|
}
|
|
12149
|
-
const { path:
|
|
12149
|
+
const { path: path36 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
12150
12150
|
const configDir = readEnv("ANTHROPIC_CONFIG_DIR");
|
|
12151
12151
|
if (configDir) {
|
|
12152
12152
|
return configDir;
|
|
12153
12153
|
}
|
|
12154
|
-
const
|
|
12155
|
-
if (
|
|
12154
|
+
const os8 = getPlatformHeaders()["X-Stainless-OS"];
|
|
12155
|
+
if (os8 === "Windows") {
|
|
12156
12156
|
const appData = readEnv("APPDATA");
|
|
12157
12157
|
if (appData) {
|
|
12158
|
-
return
|
|
12158
|
+
return path36.join(appData, "Anthropic");
|
|
12159
12159
|
}
|
|
12160
12160
|
const userProfile = readEnv("USERPROFILE");
|
|
12161
12161
|
if (userProfile) {
|
|
12162
|
-
return
|
|
12162
|
+
return path36.join(userProfile, "AppData", "Roaming", "Anthropic");
|
|
12163
12163
|
}
|
|
12164
12164
|
return null;
|
|
12165
12165
|
}
|
|
12166
12166
|
const xdgConfigHome = readEnv("XDG_CONFIG_HOME");
|
|
12167
12167
|
if (xdgConfigHome) {
|
|
12168
|
-
return
|
|
12168
|
+
return path36.join(xdgConfigHome, "anthropic");
|
|
12169
12169
|
}
|
|
12170
12170
|
const home = readEnv("HOME");
|
|
12171
12171
|
if (home) {
|
|
12172
|
-
return
|
|
12172
|
+
return path36.join(home, ".config", "anthropic");
|
|
12173
12173
|
}
|
|
12174
12174
|
return null;
|
|
12175
12175
|
};
|
|
@@ -12186,8 +12186,8 @@ var init_credentials = __esm({
|
|
|
12186
12186
|
if (profileName) {
|
|
12187
12187
|
return profileName;
|
|
12188
12188
|
}
|
|
12189
|
-
const { fs: fs6, path:
|
|
12190
|
-
const filePath =
|
|
12189
|
+
const { fs: fs6, path: path36 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
12190
|
+
const filePath = path36.join(rootConfigPath, "active_config");
|
|
12191
12191
|
try {
|
|
12192
12192
|
return (await fs6.promises.readFile(filePath, "utf-8")).trim() || "default";
|
|
12193
12193
|
} catch (err) {
|
|
@@ -12201,21 +12201,21 @@ var init_credentials = __esm({
|
|
|
12201
12201
|
});
|
|
12202
12202
|
|
|
12203
12203
|
// ../../node_modules/.pnpm/@anthropic-ai+sdk@1.4.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs
|
|
12204
|
-
function identityTokenFromFile(
|
|
12205
|
-
if (!
|
|
12204
|
+
function identityTokenFromFile(path36) {
|
|
12205
|
+
if (!path36) {
|
|
12206
12206
|
throw new AnthropicError("Identity token file path is empty");
|
|
12207
12207
|
}
|
|
12208
12208
|
return async () => {
|
|
12209
12209
|
const { fs: fs6 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
12210
12210
|
let content;
|
|
12211
12211
|
try {
|
|
12212
|
-
content = await fs6.promises.readFile(
|
|
12212
|
+
content = await fs6.promises.readFile(path36, "utf-8");
|
|
12213
12213
|
} catch (err) {
|
|
12214
|
-
throw new AnthropicError(`Failed to read identity token file at ${
|
|
12214
|
+
throw new AnthropicError(`Failed to read identity token file at ${path36}: ${err}`);
|
|
12215
12215
|
}
|
|
12216
12216
|
const token = content.trim();
|
|
12217
12217
|
if (!token) {
|
|
12218
|
-
throw new AnthropicError(`Identity token file at ${
|
|
12218
|
+
throw new AnthropicError(`Identity token file at ${path36} is empty`);
|
|
12219
12219
|
}
|
|
12220
12220
|
return token;
|
|
12221
12221
|
};
|
|
@@ -14148,10 +14148,10 @@ var init_MessageStream = __esm({
|
|
|
14148
14148
|
}
|
|
14149
14149
|
}, Symbol.asyncIterator)]() {
|
|
14150
14150
|
const pushQueue = [];
|
|
14151
|
-
const
|
|
14151
|
+
const readQueue2 = [];
|
|
14152
14152
|
let done = false;
|
|
14153
14153
|
this.on("_rawEvent", (event) => {
|
|
14154
|
-
const reader =
|
|
14154
|
+
const reader = readQueue2.shift();
|
|
14155
14155
|
if (reader) {
|
|
14156
14156
|
reader.resolve(event);
|
|
14157
14157
|
} else {
|
|
@@ -14160,24 +14160,24 @@ var init_MessageStream = __esm({
|
|
|
14160
14160
|
});
|
|
14161
14161
|
this.on("end", () => {
|
|
14162
14162
|
done = true;
|
|
14163
|
-
for (const reader of
|
|
14163
|
+
for (const reader of readQueue2) {
|
|
14164
14164
|
reader.resolve(void 0);
|
|
14165
14165
|
}
|
|
14166
|
-
|
|
14166
|
+
readQueue2.length = 0;
|
|
14167
14167
|
});
|
|
14168
14168
|
this.on("abort", (err) => {
|
|
14169
14169
|
done = true;
|
|
14170
|
-
for (const reader of
|
|
14170
|
+
for (const reader of readQueue2) {
|
|
14171
14171
|
reader.reject(err);
|
|
14172
14172
|
}
|
|
14173
|
-
|
|
14173
|
+
readQueue2.length = 0;
|
|
14174
14174
|
});
|
|
14175
14175
|
this.on("error", (err) => {
|
|
14176
14176
|
done = true;
|
|
14177
|
-
for (const reader of
|
|
14177
|
+
for (const reader of readQueue2) {
|
|
14178
14178
|
reader.reject(err);
|
|
14179
14179
|
}
|
|
14180
|
-
|
|
14180
|
+
readQueue2.length = 0;
|
|
14181
14181
|
});
|
|
14182
14182
|
return {
|
|
14183
14183
|
next: async () => {
|
|
@@ -14185,7 +14185,7 @@ var init_MessageStream = __esm({
|
|
|
14185
14185
|
if (done) {
|
|
14186
14186
|
return { value: void 0, done: true };
|
|
14187
14187
|
}
|
|
14188
|
-
return new Promise((resolve2, reject) =>
|
|
14188
|
+
return new Promise((resolve2, reject) => readQueue2.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
14189
14189
|
}
|
|
14190
14190
|
const chunk = pushQueue.shift();
|
|
14191
14191
|
return { value: chunk, done: false };
|
|
@@ -14264,12 +14264,12 @@ var init_path = __esm({
|
|
|
14264
14264
|
"../../node_modules/.pnpm/@anthropic-ai+sdk@1.4.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/internal/utils/path.mjs"() {
|
|
14265
14265
|
init_error();
|
|
14266
14266
|
EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
14267
|
-
createPathTagFunction = (pathEncoder = encodeURIPath) => function
|
|
14267
|
+
createPathTagFunction = (pathEncoder = encodeURIPath) => function path36(statics, ...params) {
|
|
14268
14268
|
if (statics.length === 1)
|
|
14269
14269
|
return statics[0];
|
|
14270
14270
|
let postPath = false;
|
|
14271
14271
|
const invalidSegments = [];
|
|
14272
|
-
const
|
|
14272
|
+
const path37 = statics.reduce((previousValue, currentValue, index) => {
|
|
14273
14273
|
if (/[?#]/.test(currentValue)) {
|
|
14274
14274
|
postPath = true;
|
|
14275
14275
|
}
|
|
@@ -14293,7 +14293,7 @@ var init_path = __esm({
|
|
|
14293
14293
|
}
|
|
14294
14294
|
return previousValue + currentValue + (index === params.length ? "" : encoded);
|
|
14295
14295
|
}, "");
|
|
14296
|
-
const pathOnly =
|
|
14296
|
+
const pathOnly = path37.split(/[?#]/, 1)[0];
|
|
14297
14297
|
const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
|
|
14298
14298
|
let match;
|
|
14299
14299
|
while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
|
|
@@ -14314,10 +14314,10 @@ var init_path = __esm({
|
|
|
14314
14314
|
const underline = Array.from(marks, (mark) => mark ?? " ").join("");
|
|
14315
14315
|
throw new AnthropicError(`Path parameters result in path with invalid segments:
|
|
14316
14316
|
${invalidSegments.map((e2) => e2.error).join("\n")}
|
|
14317
|
-
${
|
|
14317
|
+
${path37}
|
|
14318
14318
|
${underline}`);
|
|
14319
14319
|
}
|
|
14320
|
-
return
|
|
14320
|
+
return path37;
|
|
14321
14321
|
};
|
|
14322
14322
|
path3 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
14323
14323
|
}
|
|
@@ -17709,29 +17709,29 @@ async function atomicWriteFile(targetPath, content) {
|
|
|
17709
17709
|
throw err;
|
|
17710
17710
|
}
|
|
17711
17711
|
}
|
|
17712
|
-
function fsErrorMessage(err,
|
|
17712
|
+
function fsErrorMessage(err, file2) {
|
|
17713
17713
|
const code = errnoCode(err);
|
|
17714
17714
|
switch (code) {
|
|
17715
17715
|
case "ENOENT":
|
|
17716
|
-
return `${
|
|
17716
|
+
return `${file2}: no such file or directory`;
|
|
17717
17717
|
case "EACCES":
|
|
17718
17718
|
case "EPERM":
|
|
17719
|
-
return `${
|
|
17719
|
+
return `${file2}: permission denied`;
|
|
17720
17720
|
case "ENOTDIR":
|
|
17721
|
-
return `${
|
|
17721
|
+
return `${file2}: not a directory`;
|
|
17722
17722
|
case "EISDIR":
|
|
17723
|
-
return `${
|
|
17723
|
+
return `${file2}: is a directory`;
|
|
17724
17724
|
case "ELOOP":
|
|
17725
|
-
return `${
|
|
17725
|
+
return `${file2}: too many levels of symbolic links`;
|
|
17726
17726
|
case "ENAMETOOLONG":
|
|
17727
|
-
return `${
|
|
17727
|
+
return `${file2}: file name too long`;
|
|
17728
17728
|
case "ENOSPC":
|
|
17729
|
-
return `${
|
|
17729
|
+
return `${file2}: no space left on device`;
|
|
17730
17730
|
case "EMFILE":
|
|
17731
17731
|
case "ENFILE":
|
|
17732
|
-
return `${
|
|
17732
|
+
return `${file2}: too many open files`;
|
|
17733
17733
|
default:
|
|
17734
|
-
return `${
|
|
17734
|
+
return `${file2}: ${code !== void 0 ? `i/o error (${code})` : "i/o error"}`;
|
|
17735
17735
|
}
|
|
17736
17736
|
}
|
|
17737
17737
|
var fs2, DIR_CREATE_MODE, FILE_CREATE_MODE, MAX_SYMLINK_HOPS;
|
|
@@ -17923,8 +17923,8 @@ async function extractArgs(cmd, archive, stage, special, excludeFile) {
|
|
|
17923
17923
|
await fs3.writeFile(excludeFile, patterns.join("\n") + "\n", { flag: "wx", mode: 384 });
|
|
17924
17924
|
return ["-xf", archive, "-C", stage, "-X", excludeFile];
|
|
17925
17925
|
}
|
|
17926
|
-
async function readHead(
|
|
17927
|
-
const handle = await fs3.open(
|
|
17926
|
+
async function readHead(file2, n3) {
|
|
17927
|
+
const handle = await fs3.open(file2, "r");
|
|
17928
17928
|
try {
|
|
17929
17929
|
const buf = Buffer.alloc(n3);
|
|
17930
17930
|
const { bytesRead } = await handle.read(buf, 0, n3, 0);
|
|
@@ -19551,8 +19551,8 @@ async function runWalkGrep(pattern, root, signal) {
|
|
|
19551
19551
|
hits.push(line);
|
|
19552
19552
|
return true;
|
|
19553
19553
|
};
|
|
19554
|
-
const
|
|
19555
|
-
if (
|
|
19554
|
+
const stat10 = await fs4.stat(root).catch(() => null);
|
|
19555
|
+
if (stat10?.isFile()) {
|
|
19556
19556
|
await grepFile(root, re3, push2);
|
|
19557
19557
|
} else {
|
|
19558
19558
|
await walk3(root, "", (rel) => grepFile(path4.join(root, rel), re3, push2), signal);
|
|
@@ -19563,8 +19563,8 @@ async function runWalkGrep(pattern, root, signal) {
|
|
|
19563
19563
|
return "no matches";
|
|
19564
19564
|
return hits.join("\n");
|
|
19565
19565
|
}
|
|
19566
|
-
async function grepFile(
|
|
19567
|
-
const stream2 = fssync.createReadStream(
|
|
19566
|
+
async function grepFile(file2, re3, push2) {
|
|
19567
|
+
const stream2 = fssync.createReadStream(file2, { encoding: "utf8" });
|
|
19568
19568
|
const rl = readline.createInterface({ input: stream2, crlfDelay: Infinity });
|
|
19569
19569
|
let i2 = 0;
|
|
19570
19570
|
try {
|
|
@@ -19572,7 +19572,7 @@ async function grepFile(file, re3, push2) {
|
|
|
19572
19572
|
i2++;
|
|
19573
19573
|
if (line.length > GREP_MAX_LINE_LENGTH)
|
|
19574
19574
|
continue;
|
|
19575
|
-
if (re3.test(line) && !push2(`${
|
|
19575
|
+
if (re3.test(line) && !push2(`${file2}:${i2}:${line}`))
|
|
19576
19576
|
return false;
|
|
19577
19577
|
}
|
|
19578
19578
|
} catch {
|
|
@@ -22317,10 +22317,10 @@ var init_BetaMessageStream = __esm({
|
|
|
22317
22317
|
return new AnthropicError(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${err}. JSON: ${jsonBuf}`);
|
|
22318
22318
|
}, Symbol.asyncIterator)]() {
|
|
22319
22319
|
const pushQueue = [];
|
|
22320
|
-
const
|
|
22320
|
+
const readQueue2 = [];
|
|
22321
22321
|
let done = false;
|
|
22322
22322
|
this.on("_rawEvent", (event) => {
|
|
22323
|
-
const reader =
|
|
22323
|
+
const reader = readQueue2.shift();
|
|
22324
22324
|
if (reader) {
|
|
22325
22325
|
reader.resolve(event);
|
|
22326
22326
|
} else {
|
|
@@ -22329,24 +22329,24 @@ var init_BetaMessageStream = __esm({
|
|
|
22329
22329
|
});
|
|
22330
22330
|
this.on("end", () => {
|
|
22331
22331
|
done = true;
|
|
22332
|
-
for (const reader of
|
|
22332
|
+
for (const reader of readQueue2) {
|
|
22333
22333
|
reader.resolve(void 0);
|
|
22334
22334
|
}
|
|
22335
|
-
|
|
22335
|
+
readQueue2.length = 0;
|
|
22336
22336
|
});
|
|
22337
22337
|
this.on("abort", (err) => {
|
|
22338
22338
|
done = true;
|
|
22339
|
-
for (const reader of
|
|
22339
|
+
for (const reader of readQueue2) {
|
|
22340
22340
|
reader.reject(err);
|
|
22341
22341
|
}
|
|
22342
|
-
|
|
22342
|
+
readQueue2.length = 0;
|
|
22343
22343
|
});
|
|
22344
22344
|
this.on("error", (err) => {
|
|
22345
22345
|
done = true;
|
|
22346
|
-
for (const reader of
|
|
22346
|
+
for (const reader of readQueue2) {
|
|
22347
22347
|
reader.reject(err);
|
|
22348
22348
|
}
|
|
22349
|
-
|
|
22349
|
+
readQueue2.length = 0;
|
|
22350
22350
|
});
|
|
22351
22351
|
return {
|
|
22352
22352
|
next: async () => {
|
|
@@ -22354,7 +22354,7 @@ var init_BetaMessageStream = __esm({
|
|
|
22354
22354
|
if (done) {
|
|
22355
22355
|
return { value: void 0, done: true };
|
|
22356
22356
|
}
|
|
22357
|
-
return new Promise((resolve2, reject) =>
|
|
22357
|
+
return new Promise((resolve2, reject) => readQueue2.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
22358
22358
|
}
|
|
22359
22359
|
const chunk = pushQueue.shift();
|
|
22360
22360
|
return { value: chunk, done: false };
|
|
@@ -36452,9 +36452,9 @@ var init_client = __esm({
|
|
|
36452
36452
|
makeStatusError(status2, error2, message, headers) {
|
|
36453
36453
|
return APIError.generate(status2, error2, message, headers);
|
|
36454
36454
|
}
|
|
36455
|
-
buildURL(
|
|
36455
|
+
buildURL(path36, query, defaultBaseURL) {
|
|
36456
36456
|
const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
|
|
36457
|
-
const url2 = isAbsoluteURL(
|
|
36457
|
+
const url2 = isAbsoluteURL(path36) ? new URL(path36) : new URL(baseURL + (baseURL.endsWith("/") && path36.startsWith("/") ? path36.slice(1) : path36));
|
|
36458
36458
|
const defaultQuery = this.defaultQuery();
|
|
36459
36459
|
const pathQuery = Object.fromEntries(url2.searchParams);
|
|
36460
36460
|
if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
|
|
@@ -36530,24 +36530,24 @@ var init_client = __esm({
|
|
|
36530
36530
|
backendMiddleware() {
|
|
36531
36531
|
return [];
|
|
36532
36532
|
}
|
|
36533
|
-
get(
|
|
36534
|
-
return this.methodRequest("get",
|
|
36533
|
+
get(path36, opts) {
|
|
36534
|
+
return this.methodRequest("get", path36, opts);
|
|
36535
36535
|
}
|
|
36536
|
-
post(
|
|
36537
|
-
return this.methodRequest("post",
|
|
36536
|
+
post(path36, opts) {
|
|
36537
|
+
return this.methodRequest("post", path36, opts);
|
|
36538
36538
|
}
|
|
36539
|
-
patch(
|
|
36540
|
-
return this.methodRequest("patch",
|
|
36539
|
+
patch(path36, opts) {
|
|
36540
|
+
return this.methodRequest("patch", path36, opts);
|
|
36541
36541
|
}
|
|
36542
|
-
put(
|
|
36543
|
-
return this.methodRequest("put",
|
|
36542
|
+
put(path36, opts) {
|
|
36543
|
+
return this.methodRequest("put", path36, opts);
|
|
36544
36544
|
}
|
|
36545
|
-
delete(
|
|
36546
|
-
return this.methodRequest("delete",
|
|
36545
|
+
delete(path36, opts) {
|
|
36546
|
+
return this.methodRequest("delete", path36, opts);
|
|
36547
36547
|
}
|
|
36548
|
-
methodRequest(method,
|
|
36548
|
+
methodRequest(method, path36, opts) {
|
|
36549
36549
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
36550
|
-
return { method, path:
|
|
36550
|
+
return { method, path: path36, ...opts2 };
|
|
36551
36551
|
}));
|
|
36552
36552
|
}
|
|
36553
36553
|
request(options, remainingRetries = null) {
|
|
@@ -36694,8 +36694,8 @@ var init_client = __esm({
|
|
|
36694
36694
|
armAbandonmentBackstop(response.body ?? response, controller);
|
|
36695
36695
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
36696
36696
|
}
|
|
36697
|
-
getAPIList(
|
|
36698
|
-
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
36697
|
+
getAPIList(path36, Page3, opts) {
|
|
36698
|
+
return this.requestAPIList(Page3, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path36, ...opts2 })) : { method: "get", path: path36, ...opts });
|
|
36699
36699
|
}
|
|
36700
36700
|
requestAPIList(Page3, options) {
|
|
36701
36701
|
if (!this._tracer) {
|
|
@@ -36829,14 +36829,14 @@ var init_client = __esm({
|
|
|
36829
36829
|
}
|
|
36830
36830
|
async buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
36831
36831
|
const options = { ...inputOptions };
|
|
36832
|
-
const { method, path:
|
|
36832
|
+
const { method, path: path36, query, defaultBaseURL } = options;
|
|
36833
36833
|
if (this._authState.resolution) {
|
|
36834
36834
|
await this._authState.resolution;
|
|
36835
36835
|
}
|
|
36836
36836
|
if (!this._baseURLIsExplicit && this._authState.baseURL && this.baseURL !== this._authState.baseURL) {
|
|
36837
36837
|
this.baseURL = this._authState.baseURL;
|
|
36838
36838
|
}
|
|
36839
|
-
const url2 = this.buildURL(
|
|
36839
|
+
const url2 = this.buildURL(path36, query, defaultBaseURL);
|
|
36840
36840
|
if ("timeout" in options)
|
|
36841
36841
|
validatePositiveInteger("timeout", options.timeout);
|
|
36842
36842
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -37044,8 +37044,8 @@ var require_package = __commonJS({
|
|
|
37044
37044
|
var require_main = __commonJS({
|
|
37045
37045
|
"../../node_modules/.pnpm/dotenv@16.6.1/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
37046
37046
|
var fs6 = __require("fs");
|
|
37047
|
-
var
|
|
37048
|
-
var
|
|
37047
|
+
var path36 = __require("path");
|
|
37048
|
+
var os8 = __require("os");
|
|
37049
37049
|
var crypto4 = __require("crypto");
|
|
37050
37050
|
var packageJson = require_package();
|
|
37051
37051
|
var version2 = packageJson.version;
|
|
@@ -37160,7 +37160,7 @@ var require_main = __commonJS({
|
|
|
37160
37160
|
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
37161
37161
|
}
|
|
37162
37162
|
} else {
|
|
37163
|
-
possibleVaultPath =
|
|
37163
|
+
possibleVaultPath = path36.resolve(process.cwd(), ".env.vault");
|
|
37164
37164
|
}
|
|
37165
37165
|
if (fs6.existsSync(possibleVaultPath)) {
|
|
37166
37166
|
return possibleVaultPath;
|
|
@@ -37168,7 +37168,7 @@ var require_main = __commonJS({
|
|
|
37168
37168
|
return null;
|
|
37169
37169
|
}
|
|
37170
37170
|
function _resolveHome(envPath) {
|
|
37171
|
-
return envPath[0] === "~" ?
|
|
37171
|
+
return envPath[0] === "~" ? path36.join(os8.homedir(), envPath.slice(1)) : envPath;
|
|
37172
37172
|
}
|
|
37173
37173
|
function _configVault(options) {
|
|
37174
37174
|
const debug2 = Boolean(options && options.debug);
|
|
@@ -37185,7 +37185,7 @@ var require_main = __commonJS({
|
|
|
37185
37185
|
return { parsed };
|
|
37186
37186
|
}
|
|
37187
37187
|
function configDotenv(options) {
|
|
37188
|
-
const dotenvPath =
|
|
37188
|
+
const dotenvPath = path36.resolve(process.cwd(), ".env");
|
|
37189
37189
|
let encoding = "utf8";
|
|
37190
37190
|
const debug2 = Boolean(options && options.debug);
|
|
37191
37191
|
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
@@ -37209,13 +37209,13 @@ var require_main = __commonJS({
|
|
|
37209
37209
|
}
|
|
37210
37210
|
let lastError;
|
|
37211
37211
|
const parsedAll = {};
|
|
37212
|
-
for (const
|
|
37212
|
+
for (const path37 of optionPaths) {
|
|
37213
37213
|
try {
|
|
37214
|
-
const parsed = DotenvModule.parse(fs6.readFileSync(
|
|
37214
|
+
const parsed = DotenvModule.parse(fs6.readFileSync(path37, { encoding }));
|
|
37215
37215
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
37216
37216
|
} catch (e2) {
|
|
37217
37217
|
if (debug2) {
|
|
37218
|
-
_debug(`Failed to load ${
|
|
37218
|
+
_debug(`Failed to load ${path37} ${e2.message}`);
|
|
37219
37219
|
}
|
|
37220
37220
|
lastError = e2;
|
|
37221
37221
|
}
|
|
@@ -37230,7 +37230,7 @@ var require_main = __commonJS({
|
|
|
37230
37230
|
const shortPaths = [];
|
|
37231
37231
|
for (const filePath of optionPaths) {
|
|
37232
37232
|
try {
|
|
37233
|
-
const relative =
|
|
37233
|
+
const relative = path36.relative(process.cwd(), filePath);
|
|
37234
37234
|
shortPaths.push(relative);
|
|
37235
37235
|
} catch (e2) {
|
|
37236
37236
|
if (debug2) {
|
|
@@ -38506,14 +38506,14 @@ var require_url_state_machine = __commonJS({
|
|
|
38506
38506
|
return url2.replace(/\u0009|\u000A|\u000D/g, "");
|
|
38507
38507
|
}
|
|
38508
38508
|
function shortenPath(url2) {
|
|
38509
|
-
const
|
|
38510
|
-
if (
|
|
38509
|
+
const path36 = url2.path;
|
|
38510
|
+
if (path36.length === 0) {
|
|
38511
38511
|
return;
|
|
38512
38512
|
}
|
|
38513
|
-
if (url2.scheme === "file" &&
|
|
38513
|
+
if (url2.scheme === "file" && path36.length === 1 && isNormalizedWindowsDriveLetter(path36[0])) {
|
|
38514
38514
|
return;
|
|
38515
38515
|
}
|
|
38516
|
-
|
|
38516
|
+
path36.pop();
|
|
38517
38517
|
}
|
|
38518
38518
|
function includesCredentials(url2) {
|
|
38519
38519
|
return url2.username !== "" || url2.password !== "";
|
|
@@ -44499,29 +44499,29 @@ __export(fileFromPath_exports, {
|
|
|
44499
44499
|
});
|
|
44500
44500
|
import { statSync, createReadStream as createReadStream2, promises as fs5 } from "fs";
|
|
44501
44501
|
import { basename } from "path";
|
|
44502
|
-
function createFileFromPath(
|
|
44502
|
+
function createFileFromPath(path36, { mtimeMs, size }, filenameOrOptions, options = {}) {
|
|
44503
44503
|
let filename;
|
|
44504
44504
|
if (isPlainObject_default2(filenameOrOptions)) {
|
|
44505
44505
|
[options, filename] = [filenameOrOptions, void 0];
|
|
44506
44506
|
} else {
|
|
44507
44507
|
filename = filenameOrOptions;
|
|
44508
44508
|
}
|
|
44509
|
-
const
|
|
44509
|
+
const file2 = new FileFromPath({ path: path36, size, lastModified: mtimeMs });
|
|
44510
44510
|
if (!filename) {
|
|
44511
|
-
filename =
|
|
44511
|
+
filename = file2.name;
|
|
44512
44512
|
}
|
|
44513
|
-
return new File3([
|
|
44513
|
+
return new File3([file2], filename, {
|
|
44514
44514
|
...options,
|
|
44515
|
-
lastModified:
|
|
44515
|
+
lastModified: file2.lastModified
|
|
44516
44516
|
});
|
|
44517
44517
|
}
|
|
44518
|
-
function fileFromPathSync(
|
|
44519
|
-
const stats = statSync(
|
|
44520
|
-
return createFileFromPath(
|
|
44518
|
+
function fileFromPathSync(path36, filenameOrOptions, options = {}) {
|
|
44519
|
+
const stats = statSync(path36);
|
|
44520
|
+
return createFileFromPath(path36, stats, filenameOrOptions, options);
|
|
44521
44521
|
}
|
|
44522
|
-
async function fileFromPath2(
|
|
44523
|
-
const stats = await fs5.stat(
|
|
44524
|
-
return createFileFromPath(
|
|
44522
|
+
async function fileFromPath2(path36, filenameOrOptions, options) {
|
|
44523
|
+
const stats = await fs5.stat(path36);
|
|
44524
|
+
return createFileFromPath(path36, stats, filenameOrOptions, options);
|
|
44525
44525
|
}
|
|
44526
44526
|
var import_node_domexception, __classPrivateFieldSet5, __classPrivateFieldGet6, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
|
|
44527
44527
|
var init_fileFromPath = __esm({
|
|
@@ -44583,13 +44583,13 @@ var init_fileFromPath = __esm({
|
|
|
44583
44583
|
import { ReadStream as FsReadStream } from "node:fs";
|
|
44584
44584
|
import { Readable } from "node:stream";
|
|
44585
44585
|
import { ReadableStream as ReadableStream3 } from "node:stream/web";
|
|
44586
|
-
async function fileFromPath3(
|
|
44586
|
+
async function fileFromPath3(path36, ...args) {
|
|
44587
44587
|
const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
|
|
44588
44588
|
if (!fileFromPathWarned) {
|
|
44589
|
-
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(
|
|
44589
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path36)}) instead`);
|
|
44590
44590
|
fileFromPathWarned = true;
|
|
44591
44591
|
}
|
|
44592
|
-
return await _fileFromPath(
|
|
44592
|
+
return await _fileFromPath(path36, ...args);
|
|
44593
44593
|
}
|
|
44594
44594
|
async function getMultipartRequestOptions2(form, opts) {
|
|
44595
44595
|
const encoder = new FormDataEncoder(form);
|
|
@@ -45265,8 +45265,8 @@ var init_uploads3 = __esm({
|
|
|
45265
45265
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
45266
45266
|
form.append(key, String(value));
|
|
45267
45267
|
} else if (isUploadable(value)) {
|
|
45268
|
-
const
|
|
45269
|
-
form.append(key,
|
|
45268
|
+
const file2 = await toFile2(value);
|
|
45269
|
+
form.append(key, file2);
|
|
45270
45270
|
} else if (Array.isArray(value)) {
|
|
45271
45271
|
await Promise.all(value.map((entry) => addFormValue2(form, key + "[]", entry)));
|
|
45272
45272
|
} else if (typeof value === "object") {
|
|
@@ -45519,29 +45519,29 @@ var init_core = __esm({
|
|
|
45519
45519
|
defaultIdempotencyKey() {
|
|
45520
45520
|
return `stainless-node-retry-${uuid42()}`;
|
|
45521
45521
|
}
|
|
45522
|
-
get(
|
|
45523
|
-
return this.methodRequest("get",
|
|
45522
|
+
get(path36, opts) {
|
|
45523
|
+
return this.methodRequest("get", path36, opts);
|
|
45524
45524
|
}
|
|
45525
|
-
post(
|
|
45526
|
-
return this.methodRequest("post",
|
|
45525
|
+
post(path36, opts) {
|
|
45526
|
+
return this.methodRequest("post", path36, opts);
|
|
45527
45527
|
}
|
|
45528
|
-
patch(
|
|
45529
|
-
return this.methodRequest("patch",
|
|
45528
|
+
patch(path36, opts) {
|
|
45529
|
+
return this.methodRequest("patch", path36, opts);
|
|
45530
45530
|
}
|
|
45531
|
-
put(
|
|
45532
|
-
return this.methodRequest("put",
|
|
45531
|
+
put(path36, opts) {
|
|
45532
|
+
return this.methodRequest("put", path36, opts);
|
|
45533
45533
|
}
|
|
45534
|
-
delete(
|
|
45535
|
-
return this.methodRequest("delete",
|
|
45534
|
+
delete(path36, opts) {
|
|
45535
|
+
return this.methodRequest("delete", path36, opts);
|
|
45536
45536
|
}
|
|
45537
|
-
methodRequest(method,
|
|
45537
|
+
methodRequest(method, path36, opts) {
|
|
45538
45538
|
return this.request(Promise.resolve(opts).then(async (opts2) => {
|
|
45539
45539
|
const body = opts2 && isBlobLike2(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
|
|
45540
|
-
return { method, path:
|
|
45540
|
+
return { method, path: path36, ...opts2, body };
|
|
45541
45541
|
}));
|
|
45542
45542
|
}
|
|
45543
|
-
getAPIList(
|
|
45544
|
-
return this.requestAPIList(Page3, { method: "get", path:
|
|
45543
|
+
getAPIList(path36, Page3, opts) {
|
|
45544
|
+
return this.requestAPIList(Page3, { method: "get", path: path36, ...opts });
|
|
45545
45545
|
}
|
|
45546
45546
|
calculateContentLength(body) {
|
|
45547
45547
|
if (typeof body === "string") {
|
|
@@ -45560,10 +45560,10 @@ var init_core = __esm({
|
|
|
45560
45560
|
}
|
|
45561
45561
|
buildRequest(inputOptions, { retryCount = 0 } = {}) {
|
|
45562
45562
|
const options = { ...inputOptions };
|
|
45563
|
-
const { method, path:
|
|
45563
|
+
const { method, path: path36, query, headers = {} } = options;
|
|
45564
45564
|
const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
|
|
45565
45565
|
const contentLength = this.calculateContentLength(body);
|
|
45566
|
-
const url2 = this.buildURL(
|
|
45566
|
+
const url2 = this.buildURL(path36, query);
|
|
45567
45567
|
if ("timeout" in options)
|
|
45568
45568
|
validatePositiveInteger2("timeout", options.timeout);
|
|
45569
45569
|
options.timeout = options.timeout ?? this.timeout;
|
|
@@ -45679,8 +45679,8 @@ var init_core = __esm({
|
|
|
45679
45679
|
const request = this.makeRequest(options, null);
|
|
45680
45680
|
return new PagePromise2(this, request, Page3);
|
|
45681
45681
|
}
|
|
45682
|
-
buildURL(
|
|
45683
|
-
const url2 = isAbsoluteURL2(
|
|
45682
|
+
buildURL(path36, query) {
|
|
45683
|
+
const url2 = isAbsoluteURL2(path36) ? new URL(path36) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path36.startsWith("/") ? path36.slice(1) : path36));
|
|
45684
45684
|
const defaultQuery = this.defaultQuery();
|
|
45685
45685
|
if (!isEmptyObj2(defaultQuery)) {
|
|
45686
45686
|
query = { ...defaultQuery, ...query };
|
|
@@ -46627,10 +46627,10 @@ var init_AssistantStream = __esm({
|
|
|
46627
46627
|
}
|
|
46628
46628
|
[(_AssistantStream_events = /* @__PURE__ */ new WeakMap(), _AssistantStream_runStepSnapshots = /* @__PURE__ */ new WeakMap(), _AssistantStream_messageSnapshots = /* @__PURE__ */ new WeakMap(), _AssistantStream_messageSnapshot = /* @__PURE__ */ new WeakMap(), _AssistantStream_finalRun = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentContentIndex = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentContent = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentToolCallIndex = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentToolCall = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentEvent = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentRunSnapshot = /* @__PURE__ */ new WeakMap(), _AssistantStream_currentRunStepSnapshot = /* @__PURE__ */ new WeakMap(), _AssistantStream_instances = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
|
|
46629
46629
|
const pushQueue = [];
|
|
46630
|
-
const
|
|
46630
|
+
const readQueue2 = [];
|
|
46631
46631
|
let done = false;
|
|
46632
46632
|
this.on("event", (event) => {
|
|
46633
|
-
const reader =
|
|
46633
|
+
const reader = readQueue2.shift();
|
|
46634
46634
|
if (reader) {
|
|
46635
46635
|
reader.resolve(event);
|
|
46636
46636
|
} else {
|
|
@@ -46639,24 +46639,24 @@ var init_AssistantStream = __esm({
|
|
|
46639
46639
|
});
|
|
46640
46640
|
this.on("end", () => {
|
|
46641
46641
|
done = true;
|
|
46642
|
-
for (const reader of
|
|
46642
|
+
for (const reader of readQueue2) {
|
|
46643
46643
|
reader.resolve(void 0);
|
|
46644
46644
|
}
|
|
46645
|
-
|
|
46645
|
+
readQueue2.length = 0;
|
|
46646
46646
|
});
|
|
46647
46647
|
this.on("abort", (err) => {
|
|
46648
46648
|
done = true;
|
|
46649
|
-
for (const reader of
|
|
46649
|
+
for (const reader of readQueue2) {
|
|
46650
46650
|
reader.reject(err);
|
|
46651
46651
|
}
|
|
46652
|
-
|
|
46652
|
+
readQueue2.length = 0;
|
|
46653
46653
|
});
|
|
46654
46654
|
this.on("error", (err) => {
|
|
46655
46655
|
done = true;
|
|
46656
|
-
for (const reader of
|
|
46656
|
+
for (const reader of readQueue2) {
|
|
46657
46657
|
reader.reject(err);
|
|
46658
46658
|
}
|
|
46659
|
-
|
|
46659
|
+
readQueue2.length = 0;
|
|
46660
46660
|
});
|
|
46661
46661
|
return {
|
|
46662
46662
|
next: async () => {
|
|
@@ -46664,7 +46664,7 @@ var init_AssistantStream = __esm({
|
|
|
46664
46664
|
if (done) {
|
|
46665
46665
|
return { value: void 0, done: true };
|
|
46666
46666
|
}
|
|
46667
|
-
return new Promise((resolve2, reject) =>
|
|
46667
|
+
return new Promise((resolve2, reject) => readQueue2.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
46668
46668
|
}
|
|
46669
46669
|
const chunk = pushQueue.shift();
|
|
46670
46670
|
return { value: chunk, done: false };
|
|
@@ -48370,10 +48370,10 @@ var init_ChatCompletionStream = __esm({
|
|
|
48370
48370
|
return snapshot;
|
|
48371
48371
|
}, Symbol.asyncIterator)]() {
|
|
48372
48372
|
const pushQueue = [];
|
|
48373
|
-
const
|
|
48373
|
+
const readQueue2 = [];
|
|
48374
48374
|
let done = false;
|
|
48375
48375
|
this.on("chunk", (chunk) => {
|
|
48376
|
-
const reader =
|
|
48376
|
+
const reader = readQueue2.shift();
|
|
48377
48377
|
if (reader) {
|
|
48378
48378
|
reader.resolve(chunk);
|
|
48379
48379
|
} else {
|
|
@@ -48382,24 +48382,24 @@ var init_ChatCompletionStream = __esm({
|
|
|
48382
48382
|
});
|
|
48383
48383
|
this.on("end", () => {
|
|
48384
48384
|
done = true;
|
|
48385
|
-
for (const reader of
|
|
48385
|
+
for (const reader of readQueue2) {
|
|
48386
48386
|
reader.resolve(void 0);
|
|
48387
48387
|
}
|
|
48388
|
-
|
|
48388
|
+
readQueue2.length = 0;
|
|
48389
48389
|
});
|
|
48390
48390
|
this.on("abort", (err) => {
|
|
48391
48391
|
done = true;
|
|
48392
|
-
for (const reader of
|
|
48392
|
+
for (const reader of readQueue2) {
|
|
48393
48393
|
reader.reject(err);
|
|
48394
48394
|
}
|
|
48395
|
-
|
|
48395
|
+
readQueue2.length = 0;
|
|
48396
48396
|
});
|
|
48397
48397
|
this.on("error", (err) => {
|
|
48398
48398
|
done = true;
|
|
48399
|
-
for (const reader of
|
|
48399
|
+
for (const reader of readQueue2) {
|
|
48400
48400
|
reader.reject(err);
|
|
48401
48401
|
}
|
|
48402
|
-
|
|
48402
|
+
readQueue2.length = 0;
|
|
48403
48403
|
});
|
|
48404
48404
|
return {
|
|
48405
48405
|
next: async () => {
|
|
@@ -48407,7 +48407,7 @@ var init_ChatCompletionStream = __esm({
|
|
|
48407
48407
|
if (done) {
|
|
48408
48408
|
return { value: void 0, done: true };
|
|
48409
48409
|
}
|
|
48410
|
-
return new Promise((resolve2, reject) =>
|
|
48410
|
+
return new Promise((resolve2, reject) => readQueue2.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
48411
48411
|
}
|
|
48412
48412
|
const chunk = pushQueue.shift();
|
|
48413
48413
|
return { value: chunk, done: false };
|
|
@@ -49414,17 +49414,17 @@ var init_files4 = __esm({
|
|
|
49414
49414
|
async waitForProcessing(id, { pollInterval = 5e3, maxWait = 30 * 60 * 1e3 } = {}) {
|
|
49415
49415
|
const TERMINAL_STATES = /* @__PURE__ */ new Set(["processed", "error", "deleted"]);
|
|
49416
49416
|
const start = Date.now();
|
|
49417
|
-
let
|
|
49418
|
-
while (!
|
|
49417
|
+
let file2 = await this.retrieve(id);
|
|
49418
|
+
while (!file2.status || !TERMINAL_STATES.has(file2.status)) {
|
|
49419
49419
|
await sleep2(pollInterval);
|
|
49420
|
-
|
|
49420
|
+
file2 = await this.retrieve(id);
|
|
49421
49421
|
if (Date.now() - start > maxWait) {
|
|
49422
49422
|
throw new APIConnectionTimeoutError2({
|
|
49423
49423
|
message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`
|
|
49424
49424
|
});
|
|
49425
49425
|
}
|
|
49426
49426
|
}
|
|
49427
|
-
return
|
|
49427
|
+
return file2;
|
|
49428
49428
|
}
|
|
49429
49429
|
};
|
|
49430
49430
|
FileObjectsPage = class extends CursorPage {
|
|
@@ -50223,10 +50223,10 @@ var init_ResponseStream = __esm({
|
|
|
50223
50223
|
return snapshot;
|
|
50224
50224
|
}, Symbol.asyncIterator)]() {
|
|
50225
50225
|
const pushQueue = [];
|
|
50226
|
-
const
|
|
50226
|
+
const readQueue2 = [];
|
|
50227
50227
|
let done = false;
|
|
50228
50228
|
this.on("event", (event) => {
|
|
50229
|
-
const reader =
|
|
50229
|
+
const reader = readQueue2.shift();
|
|
50230
50230
|
if (reader) {
|
|
50231
50231
|
reader.resolve(event);
|
|
50232
50232
|
} else {
|
|
@@ -50235,24 +50235,24 @@ var init_ResponseStream = __esm({
|
|
|
50235
50235
|
});
|
|
50236
50236
|
this.on("end", () => {
|
|
50237
50237
|
done = true;
|
|
50238
|
-
for (const reader of
|
|
50238
|
+
for (const reader of readQueue2) {
|
|
50239
50239
|
reader.resolve(void 0);
|
|
50240
50240
|
}
|
|
50241
|
-
|
|
50241
|
+
readQueue2.length = 0;
|
|
50242
50242
|
});
|
|
50243
50243
|
this.on("abort", (err) => {
|
|
50244
50244
|
done = true;
|
|
50245
|
-
for (const reader of
|
|
50245
|
+
for (const reader of readQueue2) {
|
|
50246
50246
|
reader.reject(err);
|
|
50247
50247
|
}
|
|
50248
|
-
|
|
50248
|
+
readQueue2.length = 0;
|
|
50249
50249
|
});
|
|
50250
50250
|
this.on("error", (err) => {
|
|
50251
50251
|
done = true;
|
|
50252
|
-
for (const reader of
|
|
50252
|
+
for (const reader of readQueue2) {
|
|
50253
50253
|
reader.reject(err);
|
|
50254
50254
|
}
|
|
50255
|
-
|
|
50255
|
+
readQueue2.length = 0;
|
|
50256
50256
|
});
|
|
50257
50257
|
return {
|
|
50258
50258
|
next: async () => {
|
|
@@ -50260,7 +50260,7 @@ var init_ResponseStream = __esm({
|
|
|
50260
50260
|
if (done) {
|
|
50261
50261
|
return { value: void 0, done: true };
|
|
50262
50262
|
}
|
|
50263
|
-
return new Promise((resolve2, reject) =>
|
|
50263
|
+
return new Promise((resolve2, reject) => readQueue2.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
50264
50264
|
}
|
|
50265
50265
|
const event = pushQueue.shift();
|
|
50266
50266
|
return { value: event, done: false };
|
|
@@ -50547,8 +50547,8 @@ var init_files5 = __esm({
|
|
|
50547
50547
|
* Attach a file to the given vector store and wait for it to be processed.
|
|
50548
50548
|
*/
|
|
50549
50549
|
async createAndPoll(vectorStoreId, body, options) {
|
|
50550
|
-
const
|
|
50551
|
-
return await this.poll(vectorStoreId,
|
|
50550
|
+
const file2 = await this.create(vectorStoreId, body, options);
|
|
50551
|
+
return await this.poll(vectorStoreId, file2.id, options);
|
|
50552
50552
|
}
|
|
50553
50553
|
/**
|
|
50554
50554
|
* Wait for the vector store file to finish processing.
|
|
@@ -50566,8 +50566,8 @@ var init_files5 = __esm({
|
|
|
50566
50566
|
...options,
|
|
50567
50567
|
headers
|
|
50568
50568
|
}).withResponse();
|
|
50569
|
-
const
|
|
50570
|
-
switch (
|
|
50569
|
+
const file2 = fileResponse.data;
|
|
50570
|
+
switch (file2.status) {
|
|
50571
50571
|
case "in_progress":
|
|
50572
50572
|
let sleepInterval = 5e3;
|
|
50573
50573
|
if (options?.pollIntervalMs) {
|
|
@@ -50585,7 +50585,7 @@ var init_files5 = __esm({
|
|
|
50585
50585
|
break;
|
|
50586
50586
|
case "failed":
|
|
50587
50587
|
case "completed":
|
|
50588
|
-
return
|
|
50588
|
+
return file2;
|
|
50589
50589
|
}
|
|
50590
50590
|
}
|
|
50591
50591
|
}
|
|
@@ -50595,15 +50595,15 @@ var init_files5 = __esm({
|
|
|
50595
50595
|
* Note the file will be asynchronously processed (you can use the alternative
|
|
50596
50596
|
* polling helper method to wait for processing to complete).
|
|
50597
50597
|
*/
|
|
50598
|
-
async upload(vectorStoreId,
|
|
50599
|
-
const fileInfo = await this._client.files.create({ file, purpose: "assistants" }, options);
|
|
50598
|
+
async upload(vectorStoreId, file2, options) {
|
|
50599
|
+
const fileInfo = await this._client.files.create({ file: file2, purpose: "assistants" }, options);
|
|
50600
50600
|
return this.create(vectorStoreId, { file_id: fileInfo.id }, options);
|
|
50601
50601
|
}
|
|
50602
50602
|
/**
|
|
50603
50603
|
* Add a file to a vector store and poll until processing is complete.
|
|
50604
50604
|
*/
|
|
50605
|
-
async uploadAndPoll(vectorStoreId,
|
|
50606
|
-
const fileInfo = await this.upload(vectorStoreId,
|
|
50605
|
+
async uploadAndPoll(vectorStoreId, file2, options) {
|
|
50606
|
+
const fileInfo = await this.upload(vectorStoreId, file2, options);
|
|
50607
50607
|
return await this.poll(vectorStoreId, fileInfo.id, options);
|
|
50608
50608
|
}
|
|
50609
50609
|
/**
|
|
@@ -51231,16 +51231,19 @@ var init_llm_anthropic = __esm({
|
|
|
51231
51231
|
|
|
51232
51232
|
// ../shared/src/paths.ts
|
|
51233
51233
|
import { existsSync } from "node:fs";
|
|
51234
|
+
import os2 from "node:os";
|
|
51234
51235
|
import path5 from "node:path";
|
|
51235
51236
|
import { fileURLToPath } from "node:url";
|
|
51236
|
-
function sourceRoot(
|
|
51237
|
-
const match = /^(.*)[\\/]packages[\\/]shared[\\/](?:src|dist)$/.exec(
|
|
51237
|
+
function sourceRoot(file2 = here) {
|
|
51238
|
+
const match = /^(.*)[\\/]packages[\\/]shared[\\/](?:src|dist)$/.exec(file2);
|
|
51238
51239
|
return match ? match[1] : null;
|
|
51239
51240
|
}
|
|
51240
|
-
function findProject(start, exists4 = existsSync) {
|
|
51241
|
+
function findProject(start, exists4 = existsSync, home = os2.homedir()) {
|
|
51241
51242
|
let dir = path5.resolve(start);
|
|
51243
|
+
const homeDir = path5.resolve(home);
|
|
51242
51244
|
for (; ; ) {
|
|
51243
|
-
|
|
51245
|
+
const markers = dir === homeDir ? ["hotpath.config.json"] : MARKERS;
|
|
51246
|
+
if (markers.some((m3) => exists4(path5.join(dir, m3)))) return dir;
|
|
51244
51247
|
const parent = path5.dirname(dir);
|
|
51245
51248
|
if (parent === dir) return null;
|
|
51246
51249
|
dir = parent;
|
|
@@ -51253,7 +51256,7 @@ function resolveProjectRoot(options = {}) {
|
|
|
51253
51256
|
const source = options.source === void 0 ? sourceRoot() : options.source;
|
|
51254
51257
|
if (source) return source;
|
|
51255
51258
|
const cwd = options.cwd ?? process.cwd();
|
|
51256
|
-
return findProject(cwd, options.exists) ?? path5.resolve(cwd);
|
|
51259
|
+
return findProject(cwd, options.exists, options.home) ?? path5.resolve(cwd);
|
|
51257
51260
|
}
|
|
51258
51261
|
function projectRoot() {
|
|
51259
51262
|
cached ??= resolveProjectRoot();
|
|
@@ -51673,17 +51676,17 @@ var init_answer_key = __esm({
|
|
|
51673
51676
|
});
|
|
51674
51677
|
|
|
51675
51678
|
// ../shared/src/layout.ts
|
|
51676
|
-
function field(item,
|
|
51679
|
+
function field(item, path36) {
|
|
51677
51680
|
let value = item;
|
|
51678
|
-
for (const key of
|
|
51681
|
+
for (const key of path36.split(".").filter(Boolean)) {
|
|
51679
51682
|
value = value !== null && typeof value === "object" ? value[key] : void 0;
|
|
51680
51683
|
}
|
|
51681
51684
|
return value;
|
|
51682
51685
|
}
|
|
51683
51686
|
function renderRow(template, item) {
|
|
51684
51687
|
let ok = true;
|
|
51685
|
-
const text = template.replace(ITEM_REF, (_m,
|
|
51686
|
-
const value = field(item,
|
|
51688
|
+
const text = template.replace(ITEM_REF, (_m, path36) => {
|
|
51689
|
+
const value = field(item, path36);
|
|
51687
51690
|
if (typeof value === "string") return value;
|
|
51688
51691
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
51689
51692
|
return String(value);
|
|
@@ -52065,12 +52068,12 @@ var init_grounding = __esm({
|
|
|
52065
52068
|
});
|
|
52066
52069
|
|
|
52067
52070
|
// ../compiler/src/layout.ts
|
|
52068
|
-
function lists(node,
|
|
52071
|
+
function lists(node, path36 = []) {
|
|
52069
52072
|
if (Array.isArray(node)) {
|
|
52070
|
-
return node.length >= 2 && node.every(isObject3) ? [{ path:
|
|
52073
|
+
return node.length >= 2 && node.every(isObject3) ? [{ path: path36, items: node }] : [];
|
|
52071
52074
|
}
|
|
52072
52075
|
if (!isObject3(node)) return [];
|
|
52073
|
-
return Object.entries(node).flatMap(([k3, v3]) => lists(v3, [...
|
|
52076
|
+
return Object.entries(node).flatMap(([k3, v3]) => lists(v3, [...path36, k3]));
|
|
52074
52077
|
}
|
|
52075
52078
|
function leaves(node, deep = false, prefix = [], out = []) {
|
|
52076
52079
|
if (isObject3(node)) {
|
|
@@ -52328,37 +52331,37 @@ function compileTraceDetailed(trace2, compiledFrom) {
|
|
|
52328
52331
|
};
|
|
52329
52332
|
return { workflow, recorded: earlier };
|
|
52330
52333
|
}
|
|
52331
|
-
function arraysIn(node,
|
|
52334
|
+
function arraysIn(node, path36 = []) {
|
|
52332
52335
|
const found = [];
|
|
52333
52336
|
if (Array.isArray(node)) {
|
|
52334
|
-
if (node.length >= 2) found.push({ path:
|
|
52335
|
-
node.forEach((v3, i2) => found.push(...arraysIn(v3, [...
|
|
52337
|
+
if (node.length >= 2) found.push({ path: path36, items: node });
|
|
52338
|
+
node.forEach((v3, i2) => found.push(...arraysIn(v3, [...path36, String(i2)])));
|
|
52336
52339
|
} else if (node !== null && typeof node === "object") {
|
|
52337
52340
|
for (const [k3, v3] of Object.entries(node)) {
|
|
52338
|
-
found.push(...arraysIn(v3, [...
|
|
52341
|
+
found.push(...arraysIn(v3, [...path36, k3]));
|
|
52339
52342
|
}
|
|
52340
52343
|
}
|
|
52341
52344
|
return found;
|
|
52342
52345
|
}
|
|
52343
|
-
function pathsOf(node, value,
|
|
52344
|
-
if (deepEqual(node, value)) return [
|
|
52346
|
+
function pathsOf(node, value, path36 = []) {
|
|
52347
|
+
if (deepEqual(node, value)) return [path36];
|
|
52345
52348
|
const found = [];
|
|
52346
52349
|
if (node !== null && typeof node === "object") {
|
|
52347
52350
|
for (const [k3, v3] of Object.entries(node)) {
|
|
52348
|
-
found.push(...pathsOf(v3, value, [...
|
|
52351
|
+
found.push(...pathsOf(v3, value, [...path36, k3]));
|
|
52349
52352
|
}
|
|
52350
52353
|
}
|
|
52351
52354
|
return found;
|
|
52352
52355
|
}
|
|
52353
|
-
function walk4(node,
|
|
52356
|
+
function walk4(node, path36) {
|
|
52354
52357
|
let value = node;
|
|
52355
|
-
for (const p3 of
|
|
52358
|
+
for (const p3 of path36) {
|
|
52356
52359
|
value = value !== null && typeof value === "object" ? value[p3] : void 0;
|
|
52357
52360
|
}
|
|
52358
52361
|
return value;
|
|
52359
52362
|
}
|
|
52360
|
-
function loopVariable(
|
|
52361
|
-
const last =
|
|
52363
|
+
function loopVariable(path36) {
|
|
52364
|
+
const last = path36.filter((p3) => !/^\d+$/.test(p3)).at(-1) ?? "";
|
|
52362
52365
|
const singular = last.endsWith("ies") ? `${last.slice(0, -3)}y` : last.endsWith("s") ? last.slice(0, -1) : "";
|
|
52363
52366
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(singular) && !["inputs", "steps", ""].includes(singular) ? singular : "item";
|
|
52364
52367
|
}
|
|
@@ -52385,13 +52388,13 @@ function detectLoop(calls, index, earlier) {
|
|
|
52385
52388
|
const itemArgs = /* @__PURE__ */ new Map();
|
|
52386
52389
|
for (const key of varying) {
|
|
52387
52390
|
const candidates2 = pathsOf(list.items[0], window2[0].args[key]);
|
|
52388
|
-
const
|
|
52391
|
+
const path36 = candidates2.find(
|
|
52389
52392
|
(p3) => window2.every(
|
|
52390
52393
|
(c2, i2) => deepEqual(c2.args[key], walk4(list.items[i2], p3))
|
|
52391
52394
|
)
|
|
52392
52395
|
);
|
|
52393
|
-
if (!
|
|
52394
|
-
itemArgs.set(key,
|
|
52396
|
+
if (!path36) break;
|
|
52397
|
+
itemArgs.set(key, path36);
|
|
52395
52398
|
}
|
|
52396
52399
|
if (itemArgs.size !== varying.length) continue;
|
|
52397
52400
|
return {
|
|
@@ -52427,18 +52430,18 @@ function detectItemSubsetLoop(calls, index, runLength, earlier) {
|
|
|
52427
52430
|
}
|
|
52428
52431
|
}
|
|
52429
52432
|
for (const raw of paths) {
|
|
52430
|
-
const
|
|
52433
|
+
const path36 = JSON.parse(raw);
|
|
52431
52434
|
const chosen = [];
|
|
52432
52435
|
let at2 = 0;
|
|
52433
52436
|
for (const c2 of window2) {
|
|
52434
|
-
while (at2 < items.length && !deepEqual(walk4(items[at2],
|
|
52437
|
+
while (at2 < items.length && !deepEqual(walk4(items[at2], path36), c2.args[first])) {
|
|
52435
52438
|
at2++;
|
|
52436
52439
|
}
|
|
52437
52440
|
if (at2 === items.length) break;
|
|
52438
52441
|
chosen.push(at2++);
|
|
52439
52442
|
}
|
|
52440
52443
|
if (chosen.length !== window2.length) continue;
|
|
52441
|
-
const itemArgs = /* @__PURE__ */ new Map([[first,
|
|
52444
|
+
const itemArgs = /* @__PURE__ */ new Map([[first, path36]]);
|
|
52442
52445
|
for (const key of varying.slice(1)) {
|
|
52443
52446
|
const p3 = pathsOf(items[chosen[0]], window2[0].args[key]).find(
|
|
52444
52447
|
(q2) => chosen.every(
|
|
@@ -52699,23 +52702,23 @@ function constantSiblings(args, skip) {
|
|
|
52699
52702
|
}
|
|
52700
52703
|
function findInEarlierSteps(value, earlier) {
|
|
52701
52704
|
for (const { id, field: field2, result } of earlier) {
|
|
52702
|
-
const
|
|
52703
|
-
if (
|
|
52705
|
+
const path36 = findPath(result, value, []);
|
|
52706
|
+
if (path36 !== null) return { id, field: field2, path: path36.join(".") };
|
|
52704
52707
|
}
|
|
52705
52708
|
return null;
|
|
52706
52709
|
}
|
|
52707
|
-
function findPath(node, value,
|
|
52708
|
-
if (deepEqual(node, value)) return
|
|
52710
|
+
function findPath(node, value, path36) {
|
|
52711
|
+
if (deepEqual(node, value)) return path36;
|
|
52709
52712
|
if (Array.isArray(node)) {
|
|
52710
52713
|
for (let i2 = 0; i2 < node.length; i2++) {
|
|
52711
|
-
const found = findPath(node[i2], value, [...
|
|
52714
|
+
const found = findPath(node[i2], value, [...path36, String(i2)]);
|
|
52712
52715
|
if (found !== null) return found;
|
|
52713
52716
|
}
|
|
52714
52717
|
return null;
|
|
52715
52718
|
}
|
|
52716
52719
|
if (node !== null && typeof node === "object") {
|
|
52717
52720
|
for (const [k3, v3] of Object.entries(node)) {
|
|
52718
|
-
const found = findPath(v3, value, [...
|
|
52721
|
+
const found = findPath(v3, value, [...path36, k3]);
|
|
52719
52722
|
if (found !== null) return found;
|
|
52720
52723
|
}
|
|
52721
52724
|
}
|
|
@@ -53247,10 +53250,10 @@ async function pruneTraces(dir, keep, days, now = Date.now()) {
|
|
|
53247
53250
|
const deleted = [];
|
|
53248
53251
|
for (const name of names2) {
|
|
53249
53252
|
if (!name.endsWith(".jsonl") || name === keep) continue;
|
|
53250
|
-
const
|
|
53251
|
-
const { mtimeMs } = await stat2(
|
|
53253
|
+
const file2 = path7.join(dir, name);
|
|
53254
|
+
const { mtimeMs } = await stat2(file2);
|
|
53252
53255
|
if (now - mtimeMs > days * 864e5) {
|
|
53253
|
-
await rm(
|
|
53256
|
+
await rm(file2, { force: true });
|
|
53254
53257
|
deleted.push(name);
|
|
53255
53258
|
}
|
|
53256
53259
|
}
|
|
@@ -53604,10 +53607,10 @@ function learnCoverage(base, workflow, all) {
|
|
|
53604
53607
|
if (!baseStep) continue;
|
|
53605
53608
|
for (const entry of step.guard.grounding ?? []) {
|
|
53606
53609
|
if (entry.positions !== void 0) continue;
|
|
53607
|
-
const
|
|
53608
|
-
const oneItem =
|
|
53609
|
-
if (
|
|
53610
|
-
const parts =
|
|
53610
|
+
const path36 = entry.paths.length === 1 ? entry.paths[0] : "";
|
|
53611
|
+
const oneItem = path36.split(".").slice(3).some((p3) => /^\d+$/.test(p3));
|
|
53612
|
+
if (path36 === "" || oneItem) continue;
|
|
53613
|
+
const parts = path36.split(".");
|
|
53611
53614
|
const sourceId = ids.get(parts[1]);
|
|
53612
53615
|
if (!sourceId) continue;
|
|
53613
53616
|
const mapped = [parts[0], sourceId, ...parts.slice(2)].join(".");
|
|
@@ -53699,14 +53702,14 @@ function usable(value) {
|
|
|
53699
53702
|
}
|
|
53700
53703
|
return false;
|
|
53701
53704
|
}
|
|
53702
|
-
function listsIn2(node,
|
|
53705
|
+
function listsIn2(node, path36 = []) {
|
|
53703
53706
|
const found = [];
|
|
53704
53707
|
if (Array.isArray(node)) {
|
|
53705
|
-
if (node.length > 0) found.push({ path:
|
|
53706
|
-
for (const item of node) found.push(...listsIn2(item, [...
|
|
53708
|
+
if (node.length > 0) found.push({ path: path36, items: node });
|
|
53709
|
+
for (const item of node) found.push(...listsIn2(item, [...path36, "*"]));
|
|
53707
53710
|
} else if (isObject4(node)) {
|
|
53708
53711
|
for (const [k3, v3] of Object.entries(node)) {
|
|
53709
|
-
found.push(...listsIn2(v3, [...
|
|
53712
|
+
found.push(...listsIn2(v3, [...path36, k3]));
|
|
53710
53713
|
}
|
|
53711
53714
|
}
|
|
53712
53715
|
return found;
|
|
@@ -53774,7 +53777,7 @@ function listCoverage(workflow, recorded) {
|
|
|
53774
53777
|
const best = [...group.fields].sort(
|
|
53775
53778
|
(a2, b3) => (group.counts.get(b3) ?? 0) - (group.counts.get(a2) ?? 0) || rank(a2) - rank(b3) || group.fields.indexOf(a2) - group.fields.indexOf(b3)
|
|
53776
53779
|
)[0];
|
|
53777
|
-
const
|
|
53780
|
+
const path36 = best === "" ? `${list}.*` : `${list}.*.${best}`;
|
|
53778
53781
|
out.push({
|
|
53779
53782
|
step: step.id,
|
|
53780
53783
|
list,
|
|
@@ -53783,7 +53786,7 @@ function listCoverage(workflow, recorded) {
|
|
|
53783
53786
|
mentioned: group.counts.get(best) ?? 0,
|
|
53784
53787
|
// a nested list is required through one path per outer item: all of
|
|
53785
53788
|
// them must be there
|
|
53786
|
-
required: required2.has(
|
|
53789
|
+
required: required2.has(path36) || [...required2].filter((r2) => sameShape(r2, path36)).length >= group.lists
|
|
53787
53790
|
});
|
|
53788
53791
|
}
|
|
53789
53792
|
}
|
|
@@ -53814,8 +53817,8 @@ function coverageWarnings(coverage) {
|
|
|
53814
53817
|
const weak = coverage.filter((c2) => !c2.required && c2.mentioned < c2.items);
|
|
53815
53818
|
const warnings = weak.slice(0, MAX_COVERAGE_WARNINGS).map((c2) => {
|
|
53816
53819
|
const what = noun(c2.list);
|
|
53817
|
-
const
|
|
53818
|
-
const fix = `If every one belongs in the text, record the task again with an agent that covers them, or compile with --require ${
|
|
53820
|
+
const path36 = c2.field === "" ? `${c2.list}.*` : `${c2.list}.*.${c2.field}`;
|
|
53821
|
+
const fix = `If every one belongs in the text, record the task again with an agent that covers them, or compile with --require ${path36}`;
|
|
53819
53822
|
return c2.mentioned === 0 ? `${c2.step}: the recorded text mentions none of the ${c2.items} ${what} (${c2.list}), so the workflow will not check for them. ${fix}` : `${c2.step}: the recorded text mentions ${c2.mentioned} of ${c2.items} ${what} (${c2.list}, by ${c2.field || "value"}), so the workflow is only required to mention ${c2.mentioned === 1 ? "that one" : "those"}. ${fix}`;
|
|
53820
53823
|
});
|
|
53821
53824
|
if (weak.length > MAX_COVERAGE_WARNINGS) {
|
|
@@ -53835,8 +53838,8 @@ function parseRequirement(text) {
|
|
|
53835
53838
|
}
|
|
53836
53839
|
return { ...m3[1] ? { step: m3[1] } : {}, path: m3[2] };
|
|
53837
53840
|
}
|
|
53838
|
-
function valuesAt(
|
|
53839
|
-
const parts =
|
|
53841
|
+
function valuesAt(path36, recorded) {
|
|
53842
|
+
const parts = path36.split(".");
|
|
53840
53843
|
const source = recorded.find(
|
|
53841
53844
|
(r2) => r2.id === parts[1] && r2.field === parts[2]
|
|
53842
53845
|
);
|
|
@@ -54079,9 +54082,9 @@ async function earlierTraces(task, newest) {
|
|
|
54079
54082
|
}
|
|
54080
54083
|
const before = files2.map((f3) => path8.join(dir, f3)).filter((f3) => f3 < newest).slice(-(MAX_RECORDINGS - 1));
|
|
54081
54084
|
const out = [];
|
|
54082
|
-
for (const
|
|
54085
|
+
for (const file2 of before) {
|
|
54083
54086
|
try {
|
|
54084
|
-
const t2 = await readTrace(
|
|
54087
|
+
const t2 = await readTrace(file2);
|
|
54085
54088
|
if (t2.meta.task === task && t2.calls.some((c2) => !c2.isError)) out.push(t2);
|
|
54086
54089
|
} catch {
|
|
54087
54090
|
}
|
|
@@ -54260,10 +54263,10 @@ function coverageProblems(workflow, recorded) {
|
|
|
54260
54263
|
return [...out, ...coverageWarnings(rest)];
|
|
54261
54264
|
}
|
|
54262
54265
|
async function loadWorkflow(task) {
|
|
54263
|
-
const
|
|
54266
|
+
const file2 = path8.join(workflowsDir, `${assertTaskName(task)}.json`);
|
|
54264
54267
|
let raw;
|
|
54265
54268
|
try {
|
|
54266
|
-
raw = await readFile3(
|
|
54269
|
+
raw = await readFile3(file2, "utf8");
|
|
54267
54270
|
} catch {
|
|
54268
54271
|
throw new Error(
|
|
54269
54272
|
`no workflow for task "${task}" \u2014 run hotpath compile ${task} first`
|
|
@@ -54621,10 +54624,10 @@ function assignProp(target, prop, value) {
|
|
|
54621
54624
|
configurable: true
|
|
54622
54625
|
});
|
|
54623
54626
|
}
|
|
54624
|
-
function getElementAtPath(obj,
|
|
54625
|
-
if (!
|
|
54627
|
+
function getElementAtPath(obj, path36) {
|
|
54628
|
+
if (!path36)
|
|
54626
54629
|
return obj;
|
|
54627
|
-
return
|
|
54630
|
+
return path36.reduce((acc, key) => acc?.[key], obj);
|
|
54628
54631
|
}
|
|
54629
54632
|
function promiseAllObject(promisesObj) {
|
|
54630
54633
|
const keys = Object.keys(promisesObj);
|
|
@@ -54873,11 +54876,11 @@ function aborted(x3, startIndex = 0) {
|
|
|
54873
54876
|
}
|
|
54874
54877
|
return false;
|
|
54875
54878
|
}
|
|
54876
|
-
function prefixIssues(
|
|
54879
|
+
function prefixIssues(path36, issues) {
|
|
54877
54880
|
return issues.map((iss) => {
|
|
54878
54881
|
var _a3;
|
|
54879
54882
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
54880
|
-
iss.path.unshift(
|
|
54883
|
+
iss.path.unshift(path36);
|
|
54881
54884
|
return iss;
|
|
54882
54885
|
});
|
|
54883
54886
|
}
|
|
@@ -58114,28 +58117,28 @@ var init_to_json_schema = __esm({
|
|
|
58114
58117
|
}
|
|
58115
58118
|
case "file": {
|
|
58116
58119
|
const json = _json;
|
|
58117
|
-
const
|
|
58120
|
+
const file2 = {
|
|
58118
58121
|
type: "string",
|
|
58119
58122
|
format: "binary",
|
|
58120
58123
|
contentEncoding: "binary"
|
|
58121
58124
|
};
|
|
58122
58125
|
const { minimum, maximum, mime } = schema._zod.bag;
|
|
58123
58126
|
if (minimum !== void 0)
|
|
58124
|
-
|
|
58127
|
+
file2.minLength = minimum;
|
|
58125
58128
|
if (maximum !== void 0)
|
|
58126
|
-
|
|
58129
|
+
file2.maxLength = maximum;
|
|
58127
58130
|
if (mime) {
|
|
58128
58131
|
if (mime.length === 1) {
|
|
58129
|
-
|
|
58130
|
-
Object.assign(json,
|
|
58132
|
+
file2.contentMediaType = mime[0];
|
|
58133
|
+
Object.assign(json, file2);
|
|
58131
58134
|
} else {
|
|
58132
58135
|
json.anyOf = mime.map((m3) => {
|
|
58133
|
-
const mFile = { ...
|
|
58136
|
+
const mFile = { ...file2, contentMediaType: m3 };
|
|
58134
58137
|
return mFile;
|
|
58135
58138
|
});
|
|
58136
58139
|
}
|
|
58137
58140
|
} else {
|
|
58138
|
-
Object.assign(json,
|
|
58141
|
+
Object.assign(json, file2);
|
|
58139
58142
|
}
|
|
58140
58143
|
break;
|
|
58141
58144
|
}
|
|
@@ -58629,11 +58632,11 @@ function normalizeObjectSchema(schema) {
|
|
|
58629
58632
|
}
|
|
58630
58633
|
return void 0;
|
|
58631
58634
|
}
|
|
58632
|
-
function getDotPath(
|
|
58633
|
-
if (
|
|
58635
|
+
function getDotPath(path36) {
|
|
58636
|
+
if (path36.length === 0) {
|
|
58634
58637
|
return "object root";
|
|
58635
58638
|
}
|
|
58636
|
-
return
|
|
58639
|
+
return path36.reduce((acc, seg, index) => {
|
|
58637
58640
|
if (index === 0) {
|
|
58638
58641
|
return String(seg);
|
|
58639
58642
|
}
|
|
@@ -65773,9 +65776,9 @@ var require_json_schema_traverse = __commonJS({
|
|
|
65773
65776
|
cb = opts.cb || cb;
|
|
65774
65777
|
var pre = typeof cb == "function" ? cb : cb.pre || function() {
|
|
65775
65778
|
};
|
|
65776
|
-
var
|
|
65779
|
+
var post2 = cb.post || function() {
|
|
65777
65780
|
};
|
|
65778
|
-
_traverse(opts, pre,
|
|
65781
|
+
_traverse(opts, pre, post2, schema, "", schema);
|
|
65779
65782
|
};
|
|
65780
65783
|
traverse.keywords = {
|
|
65781
65784
|
additionalItems: true,
|
|
@@ -65821,7 +65824,7 @@ var require_json_schema_traverse = __commonJS({
|
|
|
65821
65824
|
maxProperties: true,
|
|
65822
65825
|
minProperties: true
|
|
65823
65826
|
};
|
|
65824
|
-
function _traverse(opts, pre,
|
|
65827
|
+
function _traverse(opts, pre, post2, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
65825
65828
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
65826
65829
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
65827
65830
|
for (var key in schema) {
|
|
@@ -65829,18 +65832,18 @@ var require_json_schema_traverse = __commonJS({
|
|
|
65829
65832
|
if (Array.isArray(sch)) {
|
|
65830
65833
|
if (key in traverse.arrayKeywords) {
|
|
65831
65834
|
for (var i2 = 0; i2 < sch.length; i2++)
|
|
65832
|
-
_traverse(opts, pre,
|
|
65835
|
+
_traverse(opts, pre, post2, sch[i2], jsonPtr + "/" + key + "/" + i2, rootSchema, jsonPtr, key, schema, i2);
|
|
65833
65836
|
}
|
|
65834
65837
|
} else if (key in traverse.propsKeywords) {
|
|
65835
65838
|
if (sch && typeof sch == "object") {
|
|
65836
65839
|
for (var prop in sch)
|
|
65837
|
-
_traverse(opts, pre,
|
|
65840
|
+
_traverse(opts, pre, post2, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
|
|
65838
65841
|
}
|
|
65839
65842
|
} else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
|
|
65840
|
-
_traverse(opts, pre,
|
|
65843
|
+
_traverse(opts, pre, post2, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
|
|
65841
65844
|
}
|
|
65842
65845
|
}
|
|
65843
|
-
|
|
65846
|
+
post2(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
65844
65847
|
}
|
|
65845
65848
|
}
|
|
65846
65849
|
function escapeJsonPtr(str3) {
|
|
@@ -66948,8 +66951,8 @@ var require_utils2 = __commonJS({
|
|
|
66948
66951
|
}
|
|
66949
66952
|
return ind;
|
|
66950
66953
|
}
|
|
66951
|
-
function removeDotSegments(
|
|
66952
|
-
let input =
|
|
66954
|
+
function removeDotSegments(path36) {
|
|
66955
|
+
let input = path36;
|
|
66953
66956
|
const output = [];
|
|
66954
66957
|
let nextSlash = -1;
|
|
66955
66958
|
let len = 0;
|
|
@@ -67023,11 +67026,11 @@ var require_utils2 = __commonJS({
|
|
|
67023
67026
|
}
|
|
67024
67027
|
return output.join("");
|
|
67025
67028
|
}
|
|
67026
|
-
function removeDotSegmentsRelative(
|
|
67027
|
-
if (
|
|
67028
|
-
return removeDotSegments(
|
|
67029
|
+
function removeDotSegmentsRelative(path36) {
|
|
67030
|
+
if (path36 === "" || path36[0] === "/") {
|
|
67031
|
+
return removeDotSegments(path36);
|
|
67029
67032
|
}
|
|
67030
|
-
const segments =
|
|
67033
|
+
const segments = path36.split("/");
|
|
67031
67034
|
const last = segments.length - 1;
|
|
67032
67035
|
const output = [];
|
|
67033
67036
|
let trailingDirectory = false;
|
|
@@ -67390,8 +67393,8 @@ var require_schemes = __commonJS({
|
|
|
67390
67393
|
}
|
|
67391
67394
|
if (wsComponent.resourceName) {
|
|
67392
67395
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
67393
|
-
const
|
|
67394
|
-
wsComponent.path =
|
|
67396
|
+
const path36 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
67397
|
+
wsComponent.path = path36 && path36 !== "/" ? path36 : void 0;
|
|
67395
67398
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
67396
67399
|
wsComponent.resourceName = void 0;
|
|
67397
67400
|
}
|
|
@@ -68533,11 +68536,11 @@ var require_core = __commonJS({
|
|
|
68533
68536
|
}
|
|
68534
68537
|
function addRule(keyword, definition, dataType) {
|
|
68535
68538
|
var _a3;
|
|
68536
|
-
const
|
|
68537
|
-
if (dataType &&
|
|
68539
|
+
const post2 = definition === null || definition === void 0 ? void 0 : definition.post;
|
|
68540
|
+
if (dataType && post2)
|
|
68538
68541
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
68539
68542
|
const { RULES } = this;
|
|
68540
|
-
let ruleGroup =
|
|
68543
|
+
let ruleGroup = post2 ? RULES.post : RULES.rules.find(({ type: t2 }) => t2 === dataType);
|
|
68541
68544
|
if (!ruleGroup) {
|
|
68542
68545
|
ruleGroup = { type: dataType, rules: [] };
|
|
68543
68546
|
RULES.rules.push(ruleGroup);
|
|
@@ -71741,7 +71744,7 @@ var require_windows = __commonJS({
|
|
|
71741
71744
|
module.exports = isexe;
|
|
71742
71745
|
isexe.sync = sync;
|
|
71743
71746
|
var fs6 = __require("fs");
|
|
71744
|
-
function checkPathExt(
|
|
71747
|
+
function checkPathExt(path36, options) {
|
|
71745
71748
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
71746
71749
|
if (!pathext) {
|
|
71747
71750
|
return true;
|
|
@@ -71752,25 +71755,25 @@ var require_windows = __commonJS({
|
|
|
71752
71755
|
}
|
|
71753
71756
|
for (var i2 = 0; i2 < pathext.length; i2++) {
|
|
71754
71757
|
var p3 = pathext[i2].toLowerCase();
|
|
71755
|
-
if (p3 &&
|
|
71758
|
+
if (p3 && path36.substr(-p3.length).toLowerCase() === p3) {
|
|
71756
71759
|
return true;
|
|
71757
71760
|
}
|
|
71758
71761
|
}
|
|
71759
71762
|
return false;
|
|
71760
71763
|
}
|
|
71761
|
-
function checkStat(
|
|
71762
|
-
if (!
|
|
71764
|
+
function checkStat(stat10, path36, options) {
|
|
71765
|
+
if (!stat10.isSymbolicLink() && !stat10.isFile()) {
|
|
71763
71766
|
return false;
|
|
71764
71767
|
}
|
|
71765
|
-
return checkPathExt(
|
|
71768
|
+
return checkPathExt(path36, options);
|
|
71766
71769
|
}
|
|
71767
|
-
function isexe(
|
|
71768
|
-
fs6.stat(
|
|
71769
|
-
cb(er2, er2 ? false : checkStat(
|
|
71770
|
+
function isexe(path36, options, cb) {
|
|
71771
|
+
fs6.stat(path36, function(er2, stat10) {
|
|
71772
|
+
cb(er2, er2 ? false : checkStat(stat10, path36, options));
|
|
71770
71773
|
});
|
|
71771
71774
|
}
|
|
71772
|
-
function sync(
|
|
71773
|
-
return checkStat(fs6.statSync(
|
|
71775
|
+
function sync(path36, options) {
|
|
71776
|
+
return checkStat(fs6.statSync(path36), path36, options);
|
|
71774
71777
|
}
|
|
71775
71778
|
}
|
|
71776
71779
|
});
|
|
@@ -71781,21 +71784,21 @@ var require_mode = __commonJS({
|
|
|
71781
71784
|
module.exports = isexe;
|
|
71782
71785
|
isexe.sync = sync;
|
|
71783
71786
|
var fs6 = __require("fs");
|
|
71784
|
-
function isexe(
|
|
71785
|
-
fs6.stat(
|
|
71786
|
-
cb(er2, er2 ? false : checkStat(
|
|
71787
|
+
function isexe(path36, options, cb) {
|
|
71788
|
+
fs6.stat(path36, function(er2, stat10) {
|
|
71789
|
+
cb(er2, er2 ? false : checkStat(stat10, options));
|
|
71787
71790
|
});
|
|
71788
71791
|
}
|
|
71789
|
-
function sync(
|
|
71790
|
-
return checkStat(fs6.statSync(
|
|
71792
|
+
function sync(path36, options) {
|
|
71793
|
+
return checkStat(fs6.statSync(path36), options);
|
|
71791
71794
|
}
|
|
71792
|
-
function checkStat(
|
|
71793
|
-
return
|
|
71795
|
+
function checkStat(stat10, options) {
|
|
71796
|
+
return stat10.isFile() && checkMode(stat10, options);
|
|
71794
71797
|
}
|
|
71795
|
-
function checkMode(
|
|
71796
|
-
var mod =
|
|
71797
|
-
var uid =
|
|
71798
|
-
var gid =
|
|
71798
|
+
function checkMode(stat10, options) {
|
|
71799
|
+
var mod = stat10.mode;
|
|
71800
|
+
var uid = stat10.uid;
|
|
71801
|
+
var gid = stat10.gid;
|
|
71799
71802
|
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
71800
71803
|
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
71801
71804
|
var u2 = parseInt("100", 8);
|
|
@@ -71820,7 +71823,7 @@ var require_isexe = __commonJS({
|
|
|
71820
71823
|
}
|
|
71821
71824
|
module.exports = isexe;
|
|
71822
71825
|
isexe.sync = sync;
|
|
71823
|
-
function isexe(
|
|
71826
|
+
function isexe(path36, options, cb) {
|
|
71824
71827
|
if (typeof options === "function") {
|
|
71825
71828
|
cb = options;
|
|
71826
71829
|
options = {};
|
|
@@ -71830,7 +71833,7 @@ var require_isexe = __commonJS({
|
|
|
71830
71833
|
throw new TypeError("callback not provided");
|
|
71831
71834
|
}
|
|
71832
71835
|
return new Promise(function(resolve2, reject) {
|
|
71833
|
-
isexe(
|
|
71836
|
+
isexe(path36, options || {}, function(er2, is) {
|
|
71834
71837
|
if (er2) {
|
|
71835
71838
|
reject(er2);
|
|
71836
71839
|
} else {
|
|
@@ -71839,7 +71842,7 @@ var require_isexe = __commonJS({
|
|
|
71839
71842
|
});
|
|
71840
71843
|
});
|
|
71841
71844
|
}
|
|
71842
|
-
core(
|
|
71845
|
+
core(path36, options || {}, function(er2, is) {
|
|
71843
71846
|
if (er2) {
|
|
71844
71847
|
if (er2.code === "EACCES" || options && options.ignoreErrors) {
|
|
71845
71848
|
er2 = null;
|
|
@@ -71849,9 +71852,9 @@ var require_isexe = __commonJS({
|
|
|
71849
71852
|
cb(er2, is);
|
|
71850
71853
|
});
|
|
71851
71854
|
}
|
|
71852
|
-
function sync(
|
|
71855
|
+
function sync(path36, options) {
|
|
71853
71856
|
try {
|
|
71854
|
-
return core.sync(
|
|
71857
|
+
return core.sync(path36, options || {});
|
|
71855
71858
|
} catch (er2) {
|
|
71856
71859
|
if (options && options.ignoreErrors || er2.code === "EACCES") {
|
|
71857
71860
|
return false;
|
|
@@ -71867,7 +71870,7 @@ var require_isexe = __commonJS({
|
|
|
71867
71870
|
var require_which = __commonJS({
|
|
71868
71871
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports, module) {
|
|
71869
71872
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
71870
|
-
var
|
|
71873
|
+
var path36 = __require("path");
|
|
71871
71874
|
var COLON = isWindows ? ";" : ":";
|
|
71872
71875
|
var isexe = require_isexe();
|
|
71873
71876
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -71905,7 +71908,7 @@ var require_which = __commonJS({
|
|
|
71905
71908
|
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
71906
71909
|
const ppRaw = pathEnv[i2];
|
|
71907
71910
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
71908
|
-
const pCmd =
|
|
71911
|
+
const pCmd = path36.join(pathPart, cmd);
|
|
71909
71912
|
const p3 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
71910
71913
|
resolve2(subStep(p3, i2, 0));
|
|
71911
71914
|
});
|
|
@@ -71932,7 +71935,7 @@ var require_which = __commonJS({
|
|
|
71932
71935
|
for (let i2 = 0; i2 < pathEnv.length; i2++) {
|
|
71933
71936
|
const ppRaw = pathEnv[i2];
|
|
71934
71937
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
71935
|
-
const pCmd =
|
|
71938
|
+
const pCmd = path36.join(pathPart, cmd);
|
|
71936
71939
|
const p3 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
71937
71940
|
for (let j2 = 0; j2 < pathExt.length; j2++) {
|
|
71938
71941
|
const cur = p3 + pathExt[j2];
|
|
@@ -71980,7 +71983,7 @@ var require_path_key = __commonJS({
|
|
|
71980
71983
|
var require_resolveCommand = __commonJS({
|
|
71981
71984
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module) {
|
|
71982
71985
|
"use strict";
|
|
71983
|
-
var
|
|
71986
|
+
var path36 = __require("path");
|
|
71984
71987
|
var which = require_which();
|
|
71985
71988
|
var getPathKey = require_path_key();
|
|
71986
71989
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -71998,7 +72001,7 @@ var require_resolveCommand = __commonJS({
|
|
|
71998
72001
|
try {
|
|
71999
72002
|
resolved = which.sync(parsed.command, {
|
|
72000
72003
|
path: env[getPathKey({ env })],
|
|
72001
|
-
pathExt: withoutPathExt ?
|
|
72004
|
+
pathExt: withoutPathExt ? path36.delimiter : void 0
|
|
72002
72005
|
});
|
|
72003
72006
|
} catch (e2) {
|
|
72004
72007
|
} finally {
|
|
@@ -72007,7 +72010,7 @@ var require_resolveCommand = __commonJS({
|
|
|
72007
72010
|
}
|
|
72008
72011
|
}
|
|
72009
72012
|
if (resolved) {
|
|
72010
|
-
resolved =
|
|
72013
|
+
resolved = path36.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
72011
72014
|
}
|
|
72012
72015
|
return resolved;
|
|
72013
72016
|
}
|
|
@@ -72061,8 +72064,8 @@ var require_shebang_command = __commonJS({
|
|
|
72061
72064
|
if (!match) {
|
|
72062
72065
|
return null;
|
|
72063
72066
|
}
|
|
72064
|
-
const [
|
|
72065
|
-
const binary =
|
|
72067
|
+
const [path36, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
72068
|
+
const binary = path36.split("/").pop();
|
|
72066
72069
|
if (binary === "env") {
|
|
72067
72070
|
return argument;
|
|
72068
72071
|
}
|
|
@@ -72097,7 +72100,7 @@ var require_readShebang = __commonJS({
|
|
|
72097
72100
|
var require_parse = __commonJS({
|
|
72098
72101
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports, module) {
|
|
72099
72102
|
"use strict";
|
|
72100
|
-
var
|
|
72103
|
+
var path36 = __require("path");
|
|
72101
72104
|
var resolveCommand = require_resolveCommand();
|
|
72102
72105
|
var escape2 = require_escape();
|
|
72103
72106
|
var readShebang = require_readShebang();
|
|
@@ -72122,7 +72125,7 @@ var require_parse = __commonJS({
|
|
|
72122
72125
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
72123
72126
|
if (parsed.options.forceShell || needsShell) {
|
|
72124
72127
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
72125
|
-
parsed.command =
|
|
72128
|
+
parsed.command = path36.normalize(parsed.command);
|
|
72126
72129
|
parsed.command = escape2.command(parsed.command);
|
|
72127
72130
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
72128
72131
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -73503,8 +73506,8 @@ var init_journal = __esm({
|
|
|
73503
73506
|
"../runtime/src/journal.ts"() {
|
|
73504
73507
|
"use strict";
|
|
73505
73508
|
Journal = class _Journal {
|
|
73506
|
-
constructor(
|
|
73507
|
-
this.file =
|
|
73509
|
+
constructor(file2, previous, entry) {
|
|
73510
|
+
this.file = file2;
|
|
73508
73511
|
this.previous = previous;
|
|
73509
73512
|
this.entry = entry;
|
|
73510
73513
|
}
|
|
@@ -73513,10 +73516,10 @@ var init_journal = __esm({
|
|
|
73513
73516
|
entry;
|
|
73514
73517
|
static async open(dir, task, inputs) {
|
|
73515
73518
|
const key = inputsKey(task, inputs);
|
|
73516
|
-
const
|
|
73519
|
+
const file2 = path10.join(dir, `${key}.json`);
|
|
73517
73520
|
let previous = null;
|
|
73518
73521
|
try {
|
|
73519
|
-
previous = JSON.parse(await readFile4(
|
|
73522
|
+
previous = JSON.parse(await readFile4(file2, "utf8"));
|
|
73520
73523
|
} catch {
|
|
73521
73524
|
previous = null;
|
|
73522
73525
|
}
|
|
@@ -73531,7 +73534,7 @@ var init_journal = __esm({
|
|
|
73531
73534
|
)
|
|
73532
73535
|
};
|
|
73533
73536
|
await mkdir3(dir, { recursive: true, mode: 448 });
|
|
73534
|
-
return new _Journal(
|
|
73537
|
+
return new _Journal(file2, previous, entry);
|
|
73535
73538
|
}
|
|
73536
73539
|
get key() {
|
|
73537
73540
|
return this.entry.inputsKey;
|
|
@@ -75761,10 +75764,10 @@ function buildAgentArgv(agentCommand, request) {
|
|
|
75761
75764
|
return argv;
|
|
75762
75765
|
}
|
|
75763
75766
|
async function runAgentCommand(agentCommand, request) {
|
|
75764
|
-
const [
|
|
75765
|
-
const printable = [
|
|
75767
|
+
const [file2, ...args] = buildAgentArgv(agentCommand, request);
|
|
75768
|
+
const printable = [file2, ...args].join(" ");
|
|
75766
75769
|
await new Promise((resolve2, reject) => {
|
|
75767
|
-
const child2 = (0, import_cross_spawn2.default)(
|
|
75770
|
+
const child2 = (0, import_cross_spawn2.default)(file2, args, {
|
|
75768
75771
|
cwd: repoRoot2,
|
|
75769
75772
|
stdio: "inherit",
|
|
75770
75773
|
env: process.env
|
|
@@ -75790,10 +75793,10 @@ async function runAgentCommand(agentCommand, request) {
|
|
|
75790
75793
|
async function readAgentRun(since) {
|
|
75791
75794
|
const none = { costUsd: 0, rateLimitWaitMs: 0 };
|
|
75792
75795
|
try {
|
|
75793
|
-
const
|
|
75794
|
-
const { mtimeMs } = await stat4(
|
|
75796
|
+
const file2 = path11.join(outDir, "agent-run.json");
|
|
75797
|
+
const { mtimeMs } = await stat4(file2);
|
|
75795
75798
|
if (mtimeMs < since - 1e3) return none;
|
|
75796
|
-
const parsed = JSON.parse(await readFile5(
|
|
75799
|
+
const parsed = JSON.parse(await readFile5(file2, "utf8"));
|
|
75797
75800
|
return {
|
|
75798
75801
|
costUsd: typeof parsed.costUsd === "number" ? parsed.costUsd : 0,
|
|
75799
75802
|
rateLimitWaitMs: typeof parsed.rateLimitWaitMs === "number" ? parsed.rateLimitWaitMs : 0
|
|
@@ -76283,9 +76286,9 @@ async function loadAnswers(task) {
|
|
|
76283
76286
|
async function saveAnswer(task, answers, key, output) {
|
|
76284
76287
|
answers[key] = { output, savedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
76285
76288
|
const kept = Object.entries(answers).sort(([, a2], [, b3]) => b3.savedAt.localeCompare(a2.savedAt)).slice(0, MAX_ANSWERS);
|
|
76286
|
-
const
|
|
76287
|
-
await mkdir4(path11.dirname(
|
|
76288
|
-
await writeFile3(
|
|
76289
|
+
const file2 = answersFile(task);
|
|
76290
|
+
await mkdir4(path11.dirname(file2), { recursive: true, mode: 448 });
|
|
76291
|
+
await writeFile3(file2, JSON.stringify(Object.fromEntries(kept), null, 2));
|
|
76289
76292
|
}
|
|
76290
76293
|
async function writeMetrics(metrics) {
|
|
76291
76294
|
await mkdir4(outDir, { recursive: true });
|
|
@@ -76357,11 +76360,11 @@ function checkGrounding(grounding, ctx, text) {
|
|
|
76357
76360
|
continue;
|
|
76358
76361
|
}
|
|
76359
76362
|
const items = /* @__PURE__ */ new Map();
|
|
76360
|
-
for (const
|
|
76361
|
-
for (const ref of expandWildcards(
|
|
76363
|
+
for (const path36 of entry.paths) {
|
|
76364
|
+
for (const ref of expandWildcards(path36, ctx)) {
|
|
76362
76365
|
const v3 = lookupReference(ref, ctx);
|
|
76363
76366
|
if (!isValue(v3)) continue;
|
|
76364
|
-
const listPath =
|
|
76367
|
+
const listPath = path36.slice(0, path36.lastIndexOf(".*"));
|
|
76365
76368
|
const dot = ref.indexOf(".", listPath.length + 1);
|
|
76366
76369
|
const item = dot < 0 ? ref : ref.slice(0, dot);
|
|
76367
76370
|
items.set(item, (items.get(item) ?? false) || mentions(text, v3));
|
|
@@ -76394,11 +76397,11 @@ function checkGrounding(grounding, ctx, text) {
|
|
|
76394
76397
|
}
|
|
76395
76398
|
return missing;
|
|
76396
76399
|
}
|
|
76397
|
-
function expandWildcards(
|
|
76398
|
-
const at2 =
|
|
76399
|
-
if (at2 < 0) return [
|
|
76400
|
-
const prefix =
|
|
76401
|
-
const rest =
|
|
76400
|
+
function expandWildcards(path36, ctx) {
|
|
76401
|
+
const at2 = path36.indexOf(".*");
|
|
76402
|
+
if (at2 < 0) return [path36];
|
|
76403
|
+
const prefix = path36.slice(0, at2);
|
|
76404
|
+
const rest = path36.slice(at2 + 2);
|
|
76402
76405
|
const list = lookupReference(prefix, ctx);
|
|
76403
76406
|
if (!Array.isArray(list)) return [];
|
|
76404
76407
|
return list.flatMap((_3, i2) => expandWildcards(`${prefix}.${i2}${rest}`, ctx));
|
|
@@ -77437,33 +77440,33 @@ function processAlive(pid) {
|
|
|
77437
77440
|
return err.code === "EPERM";
|
|
77438
77441
|
}
|
|
77439
77442
|
}
|
|
77440
|
-
async function acquireLock(
|
|
77443
|
+
async function acquireLock(file2, pid = process.pid, isAlive = processAlive) {
|
|
77441
77444
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
77442
77445
|
try {
|
|
77443
|
-
await writeFile4(
|
|
77446
|
+
await writeFile4(file2, `${pid}
|
|
77444
77447
|
`, { flag: "wx" });
|
|
77445
77448
|
return async () => {
|
|
77446
77449
|
try {
|
|
77447
|
-
const owner = Number((await readFile7(
|
|
77448
|
-
if (owner === pid) await unlink(
|
|
77450
|
+
const owner = Number((await readFile7(file2, "utf8")).trim());
|
|
77451
|
+
if (owner === pid) await unlink(file2);
|
|
77449
77452
|
} catch {
|
|
77450
77453
|
}
|
|
77451
77454
|
};
|
|
77452
77455
|
} catch (err) {
|
|
77453
77456
|
if (err.code !== "EEXIST") throw err;
|
|
77454
77457
|
const owner = Number(
|
|
77455
|
-
(await readFile7(
|
|
77458
|
+
(await readFile7(file2, "utf8").catch(() => "")).trim()
|
|
77456
77459
|
);
|
|
77457
77460
|
if (Number.isInteger(owner) && owner > 0 && owner !== pid && isAlive(owner)) {
|
|
77458
77461
|
throw new Error(
|
|
77459
|
-
`another Hotpath daemon is running for this project (pid ${owner}, lock ${
|
|
77462
|
+
`another Hotpath daemon is running for this project (pid ${owner}, lock ${file2}) \u2014 stop it first`
|
|
77460
77463
|
);
|
|
77461
77464
|
}
|
|
77462
|
-
await unlink(
|
|
77465
|
+
await unlink(file2).catch(() => {
|
|
77463
77466
|
});
|
|
77464
77467
|
}
|
|
77465
77468
|
}
|
|
77466
|
-
throw new Error(`could not take the daemon lock ${
|
|
77469
|
+
throw new Error(`could not take the daemon lock ${file2}`);
|
|
77467
77470
|
}
|
|
77468
77471
|
var init_lock = __esm({
|
|
77469
77472
|
"../scheduler/src/lock.ts"() {
|
|
@@ -77474,10 +77477,10 @@ var init_lock = __esm({
|
|
|
77474
77477
|
// ../scheduler/src/notify.ts
|
|
77475
77478
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
77476
77479
|
async function loadConfig(stateDir2) {
|
|
77477
|
-
const
|
|
77480
|
+
const file2 = statePaths(stateDir2).config;
|
|
77478
77481
|
let text;
|
|
77479
77482
|
try {
|
|
77480
|
-
text = await readFile8(
|
|
77483
|
+
text = await readFile8(file2, "utf8");
|
|
77481
77484
|
} catch {
|
|
77482
77485
|
return {};
|
|
77483
77486
|
}
|
|
@@ -77485,7 +77488,7 @@ async function loadConfig(stateDir2) {
|
|
|
77485
77488
|
return hotpathConfigSchema.parse(JSON.parse(text));
|
|
77486
77489
|
} catch (err) {
|
|
77487
77490
|
throw new Error(
|
|
77488
|
-
`${
|
|
77491
|
+
`${file2} is not valid (${err instanceof Error ? err.message.split("\n")[0] : String(err)}) \u2014 expected {"notify": {"desktop": true, "webhook": "https://\u2026"}}`
|
|
77489
77492
|
);
|
|
77490
77493
|
}
|
|
77491
77494
|
}
|
|
@@ -77616,10 +77619,10 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
77616
77619
|
import { mkdir as mkdir6, readFile as readFile9, rename as rename2, writeFile as writeFile5 } from "node:fs/promises";
|
|
77617
77620
|
import path13 from "node:path";
|
|
77618
77621
|
async function loadSchedules(stateDir2) {
|
|
77619
|
-
const
|
|
77622
|
+
const file2 = statePaths(stateDir2).schedules;
|
|
77620
77623
|
let text;
|
|
77621
77624
|
try {
|
|
77622
|
-
text = await readFile9(
|
|
77625
|
+
text = await readFile9(file2, "utf8");
|
|
77623
77626
|
} catch {
|
|
77624
77627
|
return [];
|
|
77625
77628
|
}
|
|
@@ -77628,21 +77631,21 @@ async function loadSchedules(stateDir2) {
|
|
|
77628
77631
|
data = schedulesFileSchema.parse(JSON.parse(text));
|
|
77629
77632
|
} catch (err) {
|
|
77630
77633
|
throw new Error(
|
|
77631
|
-
`${
|
|
77634
|
+
`${file2} is not a valid schedules file (${err instanceof Error ? err.message.split("\n")[0] : String(err)}) \u2014 fix or delete it`
|
|
77632
77635
|
);
|
|
77633
77636
|
}
|
|
77634
77637
|
return data.schedules;
|
|
77635
77638
|
}
|
|
77636
77639
|
async function saveSchedules(stateDir2, schedules) {
|
|
77637
|
-
const
|
|
77640
|
+
const file2 = statePaths(stateDir2).schedules;
|
|
77638
77641
|
await mkdir6(stateDir2, { recursive: true, mode: 448 });
|
|
77639
77642
|
const body = { version: 1, schedules };
|
|
77640
|
-
const tmp = `${
|
|
77643
|
+
const tmp = `${file2}.${randomBytes(4).toString("hex")}.tmp`;
|
|
77641
77644
|
await writeFile5(
|
|
77642
77645
|
tmp,
|
|
77643
77646
|
JSON.stringify(schedulesFileSchema.parse(body), null, 2) + "\n"
|
|
77644
77647
|
);
|
|
77645
|
-
await rename2(tmp,
|
|
77648
|
+
await rename2(tmp, file2);
|
|
77646
77649
|
}
|
|
77647
77650
|
function defaultWorkflowExists(task) {
|
|
77648
77651
|
return existsSync3(path13.join(workflowsDir, `${assertTaskName(task)}.json`));
|
|
@@ -77875,10 +77878,10 @@ var init_daemon = __esm({
|
|
|
77875
77878
|
log;
|
|
77876
77879
|
/** Re-read schedules.json when it changed since the last look. */
|
|
77877
77880
|
async reload() {
|
|
77878
|
-
const
|
|
77881
|
+
const file2 = statePaths(this.deps.stateDir).schedules;
|
|
77879
77882
|
let mtime = 0;
|
|
77880
77883
|
try {
|
|
77881
|
-
mtime = (await stat5(
|
|
77884
|
+
mtime = (await stat5(file2)).mtimeMs;
|
|
77882
77885
|
} catch {
|
|
77883
77886
|
mtime = 0;
|
|
77884
77887
|
}
|
|
@@ -78408,20 +78411,20 @@ async function startStaticViewer(dir, workflow, port2 = 5173) {
|
|
|
78408
78411
|
res.end("bad request");
|
|
78409
78412
|
return;
|
|
78410
78413
|
}
|
|
78411
|
-
const
|
|
78414
|
+
const file2 = path15.resolve(
|
|
78412
78415
|
root,
|
|
78413
78416
|
relative === "/" ? "index.html" : `.${relative}`
|
|
78414
78417
|
);
|
|
78415
|
-
if (
|
|
78418
|
+
if (file2 !== root && !file2.startsWith(root + path15.sep)) {
|
|
78416
78419
|
res.statusCode = 404;
|
|
78417
78420
|
res.end("not found");
|
|
78418
78421
|
return;
|
|
78419
78422
|
}
|
|
78420
|
-
readFile11(
|
|
78423
|
+
readFile11(file2).then(
|
|
78421
78424
|
(body) => {
|
|
78422
78425
|
res.setHeader(
|
|
78423
78426
|
"content-type",
|
|
78424
|
-
CONTENT_TYPES[path15.extname(
|
|
78427
|
+
CONTENT_TYPES[path15.extname(file2).toLowerCase()] ?? "application/octet-stream"
|
|
78425
78428
|
);
|
|
78426
78429
|
res.end(body);
|
|
78427
78430
|
},
|
|
@@ -78487,7 +78490,7 @@ var init_package = __esm({
|
|
|
78487
78490
|
"../../package.json"() {
|
|
78488
78491
|
package_default = {
|
|
78489
78492
|
name: "hotpath",
|
|
78490
|
-
version: "0.
|
|
78493
|
+
version: "0.3.0",
|
|
78491
78494
|
description: "Record your AI agent once. Replay it faster and cheaper, with AI only where judgment is needed.",
|
|
78492
78495
|
license: "Apache-2.0",
|
|
78493
78496
|
repository: {
|
|
@@ -78537,23 +78540,445 @@ var init_package = __esm({
|
|
|
78537
78540
|
}
|
|
78538
78541
|
});
|
|
78539
78542
|
|
|
78540
|
-
// src/
|
|
78541
|
-
import {
|
|
78543
|
+
// src/account/credentials.ts
|
|
78544
|
+
import { chmod, mkdir as mkdir9, readFile as readFile12, rm as rm4, writeFile as writeFile8 } from "node:fs/promises";
|
|
78545
|
+
import os3 from "node:os";
|
|
78542
78546
|
import path16 from "node:path";
|
|
78543
|
-
|
|
78547
|
+
function credentialsDir(env = process.env, platform = process.platform, home = os3.homedir()) {
|
|
78548
|
+
const override = env.HOTPATH_CREDENTIALS_DIR?.trim();
|
|
78549
|
+
if (override) return override;
|
|
78550
|
+
if (platform === "win32") {
|
|
78551
|
+
return path16.join(
|
|
78552
|
+
env.APPDATA?.trim() || path16.join(home, "AppData", "Roaming"),
|
|
78553
|
+
"hotpath"
|
|
78554
|
+
);
|
|
78555
|
+
}
|
|
78556
|
+
return path16.join(
|
|
78557
|
+
env.XDG_CONFIG_HOME?.trim() || path16.join(home, ".config"),
|
|
78558
|
+
"hotpath"
|
|
78559
|
+
);
|
|
78560
|
+
}
|
|
78561
|
+
function legacyCredentialsDir(home = os3.homedir()) {
|
|
78562
|
+
return path16.join(home, ".hotpath");
|
|
78563
|
+
}
|
|
78564
|
+
async function migrateLegacyCredentials(dir, legacyDir = legacyCredentialsDir()) {
|
|
78565
|
+
if (path16.resolve(dir) === path16.resolve(legacyDir)) return false;
|
|
78566
|
+
if (await readCredentials(dir)) return false;
|
|
78567
|
+
const old = await readCredentials(legacyDir);
|
|
78568
|
+
if (!old) return false;
|
|
78569
|
+
await writeCredentials(dir, old);
|
|
78570
|
+
await deleteCredentials(legacyDir);
|
|
78571
|
+
return true;
|
|
78572
|
+
}
|
|
78573
|
+
async function readCredentials(dir) {
|
|
78574
|
+
try {
|
|
78575
|
+
const c2 = JSON.parse(
|
|
78576
|
+
await readFile12(file(dir), "utf8")
|
|
78577
|
+
);
|
|
78578
|
+
return typeof c2.token === "string" && c2.token.length > 0 ? { token: c2.token, email: c2.email ?? "", savedAt: c2.savedAt ?? "" } : null;
|
|
78579
|
+
} catch {
|
|
78580
|
+
return null;
|
|
78581
|
+
}
|
|
78582
|
+
}
|
|
78583
|
+
async function writeCredentials(dir, c2) {
|
|
78584
|
+
await mkdir9(dir, { recursive: true, mode: 448 });
|
|
78585
|
+
await writeFile8(file(dir), JSON.stringify(c2, null, 2) + "\n", {
|
|
78586
|
+
mode: 384
|
|
78587
|
+
});
|
|
78588
|
+
await chmod(file(dir), 384).catch(() => void 0);
|
|
78589
|
+
}
|
|
78590
|
+
async function deleteCredentials(dir) {
|
|
78591
|
+
await rm4(file(dir), { force: true });
|
|
78592
|
+
await rm4(checkFile(dir), { force: true });
|
|
78593
|
+
}
|
|
78594
|
+
async function readLastCheck(dir) {
|
|
78595
|
+
try {
|
|
78596
|
+
const v3 = JSON.parse(await readFile12(checkFile(dir), "utf8"));
|
|
78597
|
+
return typeof v3.at === "number" ? v3.at : null;
|
|
78598
|
+
} catch {
|
|
78599
|
+
return null;
|
|
78600
|
+
}
|
|
78601
|
+
}
|
|
78602
|
+
async function writeLastCheck(dir, at2) {
|
|
78603
|
+
await mkdir9(dir, { recursive: true, mode: 448 });
|
|
78604
|
+
await writeFile8(checkFile(dir), JSON.stringify({ at: at2 }) + "\n", {
|
|
78605
|
+
mode: 384
|
|
78606
|
+
});
|
|
78607
|
+
}
|
|
78608
|
+
var file, checkFile;
|
|
78609
|
+
var init_credentials3 = __esm({
|
|
78610
|
+
"src/account/credentials.ts"() {
|
|
78611
|
+
"use strict";
|
|
78612
|
+
file = (dir) => path16.join(dir, "credentials.json");
|
|
78613
|
+
checkFile = (dir) => path16.join(dir, "last-check.json");
|
|
78614
|
+
}
|
|
78615
|
+
});
|
|
78616
|
+
|
|
78617
|
+
// src/account/config.ts
|
|
78618
|
+
var REQUIRE_LOGIN, API_BASE, LOGIN_REQUIRED_MESSAGE, CHECK_EVERY_MS, OFFLINE_GRACE_MS;
|
|
78619
|
+
var init_config = __esm({
|
|
78620
|
+
"src/account/config.ts"() {
|
|
78621
|
+
"use strict";
|
|
78622
|
+
REQUIRE_LOGIN = true;
|
|
78623
|
+
API_BASE = "https://amjgasdhzhndqkvvvads.supabase.co";
|
|
78624
|
+
LOGIN_REQUIRED_MESSAGE = "Hotpath needs a free hotpath.run account. Run `hotpath login` (it opens your browser). For CI, set HOTPATH_TOKEN.";
|
|
78625
|
+
CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
|
|
78626
|
+
OFFLINE_GRACE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
78627
|
+
}
|
|
78628
|
+
});
|
|
78629
|
+
|
|
78630
|
+
// src/account/api.ts
|
|
78631
|
+
async function post(fetchImpl, fn, body, token, signal) {
|
|
78632
|
+
const res = await fetchImpl(`${API_BASE}/functions/v1/${fn}`, {
|
|
78633
|
+
method: "POST",
|
|
78634
|
+
// The functions are public (they check the user's own token), so the CLI
|
|
78635
|
+
// ships no project key at all: only the user's token, when there is one.
|
|
78636
|
+
headers: {
|
|
78637
|
+
"content-type": "application/json",
|
|
78638
|
+
...token ? { authorization: `Bearer ${token}` } : {}
|
|
78639
|
+
},
|
|
78640
|
+
body: JSON.stringify(body),
|
|
78641
|
+
signal
|
|
78642
|
+
});
|
|
78643
|
+
let data = {};
|
|
78644
|
+
try {
|
|
78645
|
+
data = await res.json();
|
|
78646
|
+
} catch {
|
|
78647
|
+
}
|
|
78648
|
+
if (!res.ok) {
|
|
78649
|
+
throw new HttpError(
|
|
78650
|
+
res.status,
|
|
78651
|
+
typeof data.error === "string" ? data.error : `HTTP ${res.status}`
|
|
78652
|
+
);
|
|
78653
|
+
}
|
|
78654
|
+
return data;
|
|
78655
|
+
}
|
|
78656
|
+
var HttpError;
|
|
78657
|
+
var init_api2 = __esm({
|
|
78658
|
+
"src/account/api.ts"() {
|
|
78659
|
+
"use strict";
|
|
78660
|
+
init_config();
|
|
78661
|
+
HttpError = class extends Error {
|
|
78662
|
+
constructor(status2, message) {
|
|
78663
|
+
super(message);
|
|
78664
|
+
this.status = status2;
|
|
78665
|
+
}
|
|
78666
|
+
status;
|
|
78667
|
+
};
|
|
78668
|
+
}
|
|
78669
|
+
});
|
|
78670
|
+
|
|
78671
|
+
// src/account/gate.ts
|
|
78672
|
+
function pidAlive(pid) {
|
|
78673
|
+
try {
|
|
78674
|
+
process.kill(pid, 0);
|
|
78675
|
+
return true;
|
|
78676
|
+
} catch (err) {
|
|
78677
|
+
return err.code === "EPERM";
|
|
78678
|
+
}
|
|
78679
|
+
}
|
|
78680
|
+
async function currentToken(env, dir) {
|
|
78681
|
+
const fromEnv = env.HOTPATH_TOKEN?.trim();
|
|
78682
|
+
if (fromEnv) return fromEnv;
|
|
78683
|
+
return (await readCredentials(dir))?.token ?? null;
|
|
78684
|
+
}
|
|
78685
|
+
async function checkLogin(deps) {
|
|
78686
|
+
if (!REQUIRE_LOGIN) return { ok: true };
|
|
78687
|
+
const marker = Number(deps.env[GATE_MARKER]);
|
|
78688
|
+
if (Number.isInteger(marker) && marker > 0 && deps.pidAlive(marker)) {
|
|
78689
|
+
return { ok: true };
|
|
78690
|
+
}
|
|
78691
|
+
if (deps.env.HOTPATH_TOKEN?.trim()) return { ok: true };
|
|
78692
|
+
const creds = await readCredentials(deps.dir);
|
|
78693
|
+
if (!creds) return { ok: false, message: LOGIN_REQUIRED_MESSAGE };
|
|
78694
|
+
const now = deps.now();
|
|
78695
|
+
const lastGood = await readLastCheck(deps.dir);
|
|
78696
|
+
if (lastGood !== null && now - lastGood < CHECK_EVERY_MS) return { ok: true };
|
|
78697
|
+
try {
|
|
78698
|
+
const ctl = new AbortController();
|
|
78699
|
+
const timer = setTimeout(() => ctl.abort(), deps.timeoutMs ?? 4e3);
|
|
78700
|
+
try {
|
|
78701
|
+
await post(
|
|
78702
|
+
deps.fetch,
|
|
78703
|
+
"cli-auth",
|
|
78704
|
+
{ action: "whoami" },
|
|
78705
|
+
creds.token,
|
|
78706
|
+
ctl.signal
|
|
78707
|
+
);
|
|
78708
|
+
} finally {
|
|
78709
|
+
clearTimeout(timer);
|
|
78710
|
+
}
|
|
78711
|
+
await writeLastCheck(deps.dir, now);
|
|
78712
|
+
return { ok: true };
|
|
78713
|
+
} catch (err) {
|
|
78714
|
+
if (err instanceof HttpError && err.status === 401) {
|
|
78715
|
+
await deleteCredentials(deps.dir);
|
|
78716
|
+
return { ok: false, message: LOGIN_REQUIRED_MESSAGE };
|
|
78717
|
+
}
|
|
78718
|
+
const since = lastGood ?? (Date.parse(creds.savedAt) || 0);
|
|
78719
|
+
if (now - since <= OFFLINE_GRACE_MS) return { ok: true };
|
|
78720
|
+
return {
|
|
78721
|
+
ok: false,
|
|
78722
|
+
message: `${LOGIN_REQUIRED_MESSAGE} (Hotpath could not reach hotpath.run to confirm your account for over 7 days.)`
|
|
78723
|
+
};
|
|
78724
|
+
}
|
|
78725
|
+
}
|
|
78726
|
+
var OPEN_COMMANDS, GATE_MARKER;
|
|
78727
|
+
var init_gate = __esm({
|
|
78728
|
+
"src/account/gate.ts"() {
|
|
78729
|
+
"use strict";
|
|
78730
|
+
init_api2();
|
|
78731
|
+
init_config();
|
|
78732
|
+
init_credentials3();
|
|
78733
|
+
OPEN_COMMANDS = /* @__PURE__ */ new Set([
|
|
78734
|
+
"login",
|
|
78735
|
+
"logout",
|
|
78736
|
+
"whoami",
|
|
78737
|
+
"demo-tools",
|
|
78738
|
+
// hidden: sends the queued summaries, started detached after a gated command
|
|
78739
|
+
"sync-flush"
|
|
78740
|
+
]);
|
|
78741
|
+
GATE_MARKER = "HOTPATH_GATE_PASSED";
|
|
78742
|
+
}
|
|
78743
|
+
});
|
|
78744
|
+
|
|
78745
|
+
// src/account/login.ts
|
|
78746
|
+
import os4 from "node:os";
|
|
78747
|
+
function openInBrowser(url2) {
|
|
78748
|
+
const [cmd, args] = process.platform === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", url2]] : process.platform === "darwin" ? ["open", [url2]] : ["xdg-open", [url2]];
|
|
78749
|
+
try {
|
|
78750
|
+
const child2 = (0, import_cross_spawn5.default)(cmd, args, { stdio: "ignore", detached: true });
|
|
78751
|
+
child2.on("error", () => void 0);
|
|
78752
|
+
child2.unref();
|
|
78753
|
+
} catch {
|
|
78754
|
+
}
|
|
78755
|
+
}
|
|
78756
|
+
function safeToOpen(url2) {
|
|
78757
|
+
try {
|
|
78758
|
+
const u2 = new URL(url2);
|
|
78759
|
+
return u2.protocol === "https:" && /(^|\.)hotpath\.run$/.test(u2.hostname);
|
|
78760
|
+
} catch {
|
|
78761
|
+
return false;
|
|
78762
|
+
}
|
|
78763
|
+
}
|
|
78764
|
+
async function login(deps) {
|
|
78765
|
+
const start = await post(deps.fetch, "cli-auth", {
|
|
78766
|
+
action: "start",
|
|
78767
|
+
client: `hotpath-cli/${deps.version}`,
|
|
78768
|
+
host: deps.host ?? os4.hostname()
|
|
78769
|
+
});
|
|
78770
|
+
const device = String(start.device_code ?? "");
|
|
78771
|
+
const userCode = String(start.user_code ?? "");
|
|
78772
|
+
const url2 = String(start.verify_url ?? "");
|
|
78773
|
+
if (!device || !userCode || !url2) {
|
|
78774
|
+
throw new Error(
|
|
78775
|
+
"hotpath.run answered with something unexpected. Try again in a minute."
|
|
78776
|
+
);
|
|
78777
|
+
}
|
|
78778
|
+
const interval = Math.max(1, Number(start.interval) || 3) * 1e3;
|
|
78779
|
+
const deadline = deps.now() + (Number(start.expires_in) || 600) * 1e3;
|
|
78780
|
+
deps.out(`Your code: ${userCode}`);
|
|
78781
|
+
deps.out(`Open this page to sign in and approve it: ${url2}`);
|
|
78782
|
+
if (safeToOpen(url2)) deps.open(url2);
|
|
78783
|
+
deps.out("Waiting for you to approve in the browser\u2026");
|
|
78784
|
+
while (deps.now() < deadline) {
|
|
78785
|
+
await deps.sleep(interval);
|
|
78786
|
+
const res = await post(deps.fetch, "cli-auth", {
|
|
78787
|
+
action: "poll",
|
|
78788
|
+
device_code: device
|
|
78789
|
+
});
|
|
78790
|
+
switch (res.status) {
|
|
78791
|
+
case "approved": {
|
|
78792
|
+
const token = String(res.token ?? "");
|
|
78793
|
+
if (!token) {
|
|
78794
|
+
throw new Error(
|
|
78795
|
+
"hotpath.run approved the login but sent no token. Try again."
|
|
78796
|
+
);
|
|
78797
|
+
}
|
|
78798
|
+
const email2 = String(res.email ?? "");
|
|
78799
|
+
const now = deps.now();
|
|
78800
|
+
await writeCredentials(deps.dir, {
|
|
78801
|
+
token,
|
|
78802
|
+
email: email2,
|
|
78803
|
+
savedAt: new Date(now).toISOString()
|
|
78804
|
+
});
|
|
78805
|
+
await writeLastCheck(deps.dir, now);
|
|
78806
|
+
deps.out(`Signed in as ${email2}.`);
|
|
78807
|
+
return true;
|
|
78808
|
+
}
|
|
78809
|
+
case "denied":
|
|
78810
|
+
deps.out(
|
|
78811
|
+
"The login was cancelled on hotpath.run. Run `hotpath login` to try again."
|
|
78812
|
+
);
|
|
78813
|
+
return false;
|
|
78814
|
+
case "expired":
|
|
78815
|
+
deps.out("The code expired. Run `hotpath login` to get a new one.");
|
|
78816
|
+
return false;
|
|
78817
|
+
default:
|
|
78818
|
+
break;
|
|
78819
|
+
}
|
|
78820
|
+
}
|
|
78821
|
+
deps.out("The code expired. Run `hotpath login` to get a new one.");
|
|
78822
|
+
return false;
|
|
78823
|
+
}
|
|
78824
|
+
async function logout(deps) {
|
|
78825
|
+
const creds = await readCredentials(deps.dir);
|
|
78826
|
+
if (!creds) {
|
|
78827
|
+
deps.out("You are not signed in.");
|
|
78828
|
+
return;
|
|
78829
|
+
}
|
|
78830
|
+
try {
|
|
78831
|
+
await post(deps.fetch, "cli-auth", { action: "revoke" }, creds.token);
|
|
78832
|
+
} catch (err) {
|
|
78833
|
+
if (!(err instanceof HttpError && err.status === 401)) {
|
|
78834
|
+
deps.out(
|
|
78835
|
+
"Could not reach hotpath.run to revoke this session; revoke it under Settings \u2192 CLI sessions on the dashboard."
|
|
78836
|
+
);
|
|
78837
|
+
}
|
|
78838
|
+
}
|
|
78839
|
+
await deleteCredentials(deps.dir);
|
|
78840
|
+
deps.out("Signed out.");
|
|
78841
|
+
}
|
|
78842
|
+
async function whoami(deps) {
|
|
78843
|
+
const token = deps.env.HOTPATH_TOKEN?.trim() || (await readCredentials(deps.dir))?.token;
|
|
78844
|
+
if (!token) {
|
|
78845
|
+
deps.out("Not signed in. Run `hotpath login`.");
|
|
78846
|
+
return false;
|
|
78847
|
+
}
|
|
78848
|
+
try {
|
|
78849
|
+
const res = await post(deps.fetch, "cli-auth", { action: "whoami" }, token);
|
|
78850
|
+
deps.out(`${String(res.email ?? "")} (${String(res.plan ?? "free")})`);
|
|
78851
|
+
return true;
|
|
78852
|
+
} catch (err) {
|
|
78853
|
+
if (err instanceof HttpError && err.status === 401) {
|
|
78854
|
+
deps.out("That session is no longer valid. Run `hotpath login`.");
|
|
78855
|
+
return false;
|
|
78856
|
+
}
|
|
78857
|
+
const saved = await readCredentials(deps.dir);
|
|
78858
|
+
if (saved?.email) {
|
|
78859
|
+
deps.out(`${saved.email} (offline, not checked)`);
|
|
78860
|
+
return true;
|
|
78861
|
+
}
|
|
78862
|
+
deps.out("Could not reach hotpath.run.");
|
|
78863
|
+
return false;
|
|
78864
|
+
}
|
|
78865
|
+
}
|
|
78866
|
+
var import_cross_spawn5;
|
|
78867
|
+
var init_login = __esm({
|
|
78868
|
+
"src/account/login.ts"() {
|
|
78869
|
+
"use strict";
|
|
78870
|
+
import_cross_spawn5 = __toESM(require_cross_spawn(), 1);
|
|
78871
|
+
init_api2();
|
|
78872
|
+
init_credentials3();
|
|
78873
|
+
}
|
|
78874
|
+
});
|
|
78875
|
+
|
|
78876
|
+
// src/account/commands.ts
|
|
78877
|
+
function defaultAccountDeps(version2) {
|
|
78878
|
+
return {
|
|
78879
|
+
fetch: globalThis.fetch,
|
|
78880
|
+
env: process.env,
|
|
78881
|
+
dir: credentialsDir(process.env),
|
|
78882
|
+
legacyDir: process.env.HOTPATH_CREDENTIALS_DIR?.trim() ? void 0 : legacyCredentialsDir(),
|
|
78883
|
+
version: version2,
|
|
78884
|
+
now: Date.now,
|
|
78885
|
+
exit: (code) => process.exit(code),
|
|
78886
|
+
out: (line) => console.log(line),
|
|
78887
|
+
err: (line) => console.error(line)
|
|
78888
|
+
};
|
|
78889
|
+
}
|
|
78890
|
+
async function moveOldSignIn(deps) {
|
|
78891
|
+
if (!deps.legacyDir) return;
|
|
78892
|
+
await migrateLegacyCredentials(deps.dir, deps.legacyDir).catch(() => false);
|
|
78893
|
+
}
|
|
78894
|
+
function topLevelName(command) {
|
|
78895
|
+
let c2 = command;
|
|
78896
|
+
while (c2.parent?.parent) c2 = c2.parent;
|
|
78897
|
+
return c2.name();
|
|
78898
|
+
}
|
|
78899
|
+
function addLoginGate(program2, deps) {
|
|
78900
|
+
program2.hook("preAction", async (_program, action) => {
|
|
78901
|
+
await moveOldSignIn(deps);
|
|
78902
|
+
if (OPEN_COMMANDS.has(topLevelName(action))) return;
|
|
78903
|
+
const result = await checkLogin({
|
|
78904
|
+
env: deps.env,
|
|
78905
|
+
dir: deps.dir,
|
|
78906
|
+
fetch: deps.fetch,
|
|
78907
|
+
now: deps.now,
|
|
78908
|
+
pidAlive
|
|
78909
|
+
});
|
|
78910
|
+
if (!result.ok) {
|
|
78911
|
+
deps.err(result.message);
|
|
78912
|
+
deps.exit(1);
|
|
78913
|
+
throw new Error(result.message);
|
|
78914
|
+
}
|
|
78915
|
+
deps.env[GATE_MARKER] = String(process.pid);
|
|
78916
|
+
});
|
|
78917
|
+
}
|
|
78918
|
+
function addAccountCommands(program2, deps) {
|
|
78919
|
+
const loginDeps = () => ({
|
|
78920
|
+
fetch: deps.fetch,
|
|
78921
|
+
dir: deps.dir,
|
|
78922
|
+
version: deps.version,
|
|
78923
|
+
out: deps.out,
|
|
78924
|
+
open: openInBrowser,
|
|
78925
|
+
sleep: (ms3) => new Promise((r2) => setTimeout(r2, ms3)),
|
|
78926
|
+
now: deps.now
|
|
78927
|
+
});
|
|
78928
|
+
const failed = (err) => {
|
|
78929
|
+
deps.err(err instanceof Error ? err.message : String(err));
|
|
78930
|
+
deps.exit(1);
|
|
78931
|
+
};
|
|
78932
|
+
program2.command("login").description(
|
|
78933
|
+
"Sign in to your free hotpath.run account (opens your browser)"
|
|
78934
|
+
).action(async () => {
|
|
78935
|
+
try {
|
|
78936
|
+
if (!await login(loginDeps())) deps.exit(1);
|
|
78937
|
+
} catch (err) {
|
|
78938
|
+
failed(err);
|
|
78939
|
+
}
|
|
78940
|
+
});
|
|
78941
|
+
program2.command("logout").description("Sign out and revoke this computer's session").action(async () => {
|
|
78942
|
+
try {
|
|
78943
|
+
await logout(loginDeps());
|
|
78944
|
+
} catch (err) {
|
|
78945
|
+
failed(err);
|
|
78946
|
+
}
|
|
78947
|
+
});
|
|
78948
|
+
program2.command("whoami").description("Show the account you are signed in as").action(async () => {
|
|
78949
|
+
try {
|
|
78950
|
+
if (!await whoami({ ...loginDeps(), env: deps.env })) deps.exit(1);
|
|
78951
|
+
} catch (err) {
|
|
78952
|
+
failed(err);
|
|
78953
|
+
}
|
|
78954
|
+
});
|
|
78955
|
+
}
|
|
78956
|
+
var init_commands = __esm({
|
|
78957
|
+
"src/account/commands.ts"() {
|
|
78958
|
+
"use strict";
|
|
78959
|
+
init_credentials3();
|
|
78960
|
+
init_gate();
|
|
78961
|
+
init_login();
|
|
78962
|
+
}
|
|
78963
|
+
});
|
|
78964
|
+
|
|
78965
|
+
// src/forget.ts
|
|
78966
|
+
import { readdir as readdir4, readFile as readFile13, rm as rm5, stat as stat6, writeFile as writeFile9 } from "node:fs/promises";
|
|
78967
|
+
import path17 from "node:path";
|
|
78968
|
+
async function exists(file2) {
|
|
78544
78969
|
try {
|
|
78545
|
-
await stat6(
|
|
78970
|
+
await stat6(file2);
|
|
78546
78971
|
return true;
|
|
78547
78972
|
} catch {
|
|
78548
78973
|
return false;
|
|
78549
78974
|
}
|
|
78550
78975
|
}
|
|
78551
78976
|
async function runLines(stateDir2) {
|
|
78552
|
-
const
|
|
78977
|
+
const file2 = statePaths(stateDir2).runs;
|
|
78553
78978
|
try {
|
|
78554
|
-
return { file, lines: (await
|
|
78979
|
+
return { file: file2, lines: (await readFile13(file2, "utf8")).split("\n") };
|
|
78555
78980
|
} catch {
|
|
78556
|
-
return { file, lines: [] };
|
|
78981
|
+
return { file: file2, lines: [] };
|
|
78557
78982
|
}
|
|
78558
78983
|
}
|
|
78559
78984
|
function isRunOf(line, task) {
|
|
@@ -78566,7 +78991,7 @@ function isRunOf(line, task) {
|
|
|
78566
78991
|
async function planForget(task, dirs) {
|
|
78567
78992
|
assertTaskName(task);
|
|
78568
78993
|
const items = [];
|
|
78569
|
-
const traces =
|
|
78994
|
+
const traces = path17.join(dirs.tracesDir, task);
|
|
78570
78995
|
if (await exists(traces)) {
|
|
78571
78996
|
items.push({
|
|
78572
78997
|
what: "recordings (tool calls and their results)",
|
|
@@ -78587,12 +79012,12 @@ async function planForget(task, dirs) {
|
|
|
78587
79012
|
if (!isWorkflow && !isBackup) continue;
|
|
78588
79013
|
items.push({
|
|
78589
79014
|
what: isWorkflow ? "workflow" : "workflow backup",
|
|
78590
|
-
path:
|
|
79015
|
+
path: path17.join(dirs.workflowsDir, name),
|
|
78591
79016
|
kind: "file",
|
|
78592
79017
|
count: 1
|
|
78593
79018
|
});
|
|
78594
79019
|
}
|
|
78595
|
-
const answers =
|
|
79020
|
+
const answers = path17.join(dirs.stateDir, "answers", `${task}.json`);
|
|
78596
79021
|
if (await exists(answers)) {
|
|
78597
79022
|
items.push({
|
|
78598
79023
|
what: "saved AI answers",
|
|
@@ -78601,7 +79026,7 @@ async function planForget(task, dirs) {
|
|
|
78601
79026
|
count: 1
|
|
78602
79027
|
});
|
|
78603
79028
|
}
|
|
78604
|
-
const journal =
|
|
79029
|
+
const journal = path17.join(dirs.stateDir, "journal", task);
|
|
78605
79030
|
if (await exists(journal)) {
|
|
78606
79031
|
items.push({
|
|
78607
79032
|
what: "crash journal (actions of an interrupted run)",
|
|
@@ -78631,7 +79056,7 @@ async function planForget(task, dirs) {
|
|
|
78631
79056
|
count: mine
|
|
78632
79057
|
});
|
|
78633
79058
|
}
|
|
78634
|
-
const lastRun =
|
|
79059
|
+
const lastRun = path17.join(dirs.outDir, "hotpath-run.json");
|
|
78635
79060
|
if (items.length > 0 && await exists(lastRun)) {
|
|
78636
79061
|
items.push({
|
|
78637
79062
|
what: "last run's metrics (may be another task's; it is rewritten on the next run)",
|
|
@@ -78660,7 +79085,7 @@ async function forgetTask(task, dirs) {
|
|
|
78660
79085
|
const items = await planForget(task, dirs);
|
|
78661
79086
|
for (const item of items) {
|
|
78662
79087
|
if (item.kind !== "entries") {
|
|
78663
|
-
await
|
|
79088
|
+
await rm5(item.path, { recursive: item.kind === "folder", force: true });
|
|
78664
79089
|
}
|
|
78665
79090
|
}
|
|
78666
79091
|
const schedules = await loadSchedules(dirs.stateDir);
|
|
@@ -78672,7 +79097,7 @@ async function forgetTask(task, dirs) {
|
|
|
78672
79097
|
}
|
|
78673
79098
|
const runs = await runLines(dirs.stateDir);
|
|
78674
79099
|
if (runs.lines.some((l2) => isRunOf(l2, task))) {
|
|
78675
|
-
await
|
|
79100
|
+
await writeFile9(
|
|
78676
79101
|
runs.file,
|
|
78677
79102
|
runs.lines.filter((l2) => !isRunOf(l2, task)).join("\n")
|
|
78678
79103
|
);
|
|
@@ -79025,8 +79450,8 @@ var init_candidate = __esm({
|
|
|
79025
79450
|
});
|
|
79026
79451
|
|
|
79027
79452
|
// ../learn/src/learn.ts
|
|
79028
|
-
import { mkdir as
|
|
79029
|
-
import
|
|
79453
|
+
import { mkdir as mkdir10, readdir as readdir5, readFile as readFile14, stat as stat7, writeFile as writeFile10 } from "node:fs/promises";
|
|
79454
|
+
import path18 from "node:path";
|
|
79030
79455
|
async function readRuns2(tracesDir3) {
|
|
79031
79456
|
const runs = [];
|
|
79032
79457
|
const skipped = [];
|
|
@@ -79039,18 +79464,18 @@ async function readRuns2(tracesDir3) {
|
|
|
79039
79464
|
for (const folder of folders.sort()) {
|
|
79040
79465
|
let files2;
|
|
79041
79466
|
try {
|
|
79042
|
-
files2 = (await readdir5(
|
|
79467
|
+
files2 = (await readdir5(path18.join(tracesDir3, folder))).filter(
|
|
79043
79468
|
(f3) => f3.endsWith(".jsonl")
|
|
79044
79469
|
);
|
|
79045
79470
|
} catch {
|
|
79046
79471
|
continue;
|
|
79047
79472
|
}
|
|
79048
79473
|
for (const f3 of files2) {
|
|
79049
|
-
const
|
|
79474
|
+
const file2 = path18.join(tracesDir3, folder, f3);
|
|
79050
79475
|
try {
|
|
79051
|
-
runs.push({ file, trace: await readTrace(
|
|
79476
|
+
runs.push({ file: file2, trace: await readTrace(file2, { allowOpen: true }) });
|
|
79052
79477
|
} catch {
|
|
79053
|
-
skipped.push(
|
|
79478
|
+
skipped.push(file2);
|
|
79054
79479
|
}
|
|
79055
79480
|
}
|
|
79056
79481
|
}
|
|
@@ -79061,16 +79486,16 @@ async function readRuns2(tracesDir3) {
|
|
|
79061
79486
|
}
|
|
79062
79487
|
async function configuredHotAfter(configFile) {
|
|
79063
79488
|
try {
|
|
79064
|
-
const config2 = JSON.parse(await
|
|
79489
|
+
const config2 = JSON.parse(await readFile14(configFile, "utf8"));
|
|
79065
79490
|
const n3 = config2.learn?.hotAfter;
|
|
79066
79491
|
if (typeof n3 === "number" && Number.isInteger(n3) && n3 >= 1) return n3;
|
|
79067
79492
|
} catch {
|
|
79068
79493
|
}
|
|
79069
79494
|
return DEFAULT_HOT_AFTER;
|
|
79070
79495
|
}
|
|
79071
|
-
async function exists2(
|
|
79496
|
+
async function exists2(file2) {
|
|
79072
79497
|
try {
|
|
79073
|
-
await stat7(
|
|
79498
|
+
await stat7(file2);
|
|
79074
79499
|
return true;
|
|
79075
79500
|
} catch {
|
|
79076
79501
|
return false;
|
|
@@ -79079,7 +79504,7 @@ async function exists2(file) {
|
|
|
79079
79504
|
async function readCandidate(dirs, id) {
|
|
79080
79505
|
try {
|
|
79081
79506
|
const held = JSON.parse(
|
|
79082
|
-
await
|
|
79507
|
+
await readFile14(candidateFile(dirs, id), "utf8")
|
|
79083
79508
|
);
|
|
79084
79509
|
return { ...held, workflow: workflowSchema.parse(held.workflow) };
|
|
79085
79510
|
} catch {
|
|
@@ -79118,7 +79543,7 @@ async function describePath2(dirs, group) {
|
|
|
79118
79543
|
for (const run of group.runs) {
|
|
79119
79544
|
const baseline = await agentBaseline(
|
|
79120
79545
|
run,
|
|
79121
|
-
dirs.agentRunFile ??
|
|
79546
|
+
dirs.agentRunFile ?? path18.join(dirs.stateDir, "..", "out", "agent-run.json")
|
|
79122
79547
|
);
|
|
79123
79548
|
if (baseline?.costUsd !== void 0) {
|
|
79124
79549
|
costUsd += baseline.costUsd;
|
|
@@ -79157,16 +79582,16 @@ async function holdCandidate(dirs, group, fileOf) {
|
|
|
79157
79582
|
runFile: fileOf.get(newest),
|
|
79158
79583
|
compiledAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
79159
79584
|
};
|
|
79160
|
-
await
|
|
79161
|
-
await
|
|
79585
|
+
await mkdir10(candidatesDir(dirs), { recursive: true, mode: 448 });
|
|
79586
|
+
await writeFile10(
|
|
79162
79587
|
candidateFile(dirs, group.id),
|
|
79163
79588
|
JSON.stringify(held, null, 2) + "\n"
|
|
79164
79589
|
);
|
|
79165
79590
|
return held;
|
|
79166
79591
|
}
|
|
79167
79592
|
async function writeLive(dirs, workflow) {
|
|
79168
|
-
await
|
|
79169
|
-
await
|
|
79593
|
+
await mkdir10(dirs.workflowsDir, { recursive: true, mode: 448 });
|
|
79594
|
+
await writeFile10(
|
|
79170
79595
|
workflowFile(dirs, workflow.task),
|
|
79171
79596
|
JSON.stringify(workflow, null, 2) + "\n"
|
|
79172
79597
|
);
|
|
@@ -79199,9 +79624,9 @@ var init_learn = __esm({
|
|
|
79199
79624
|
init_src();
|
|
79200
79625
|
init_candidate();
|
|
79201
79626
|
init_paths4();
|
|
79202
|
-
candidatesDir = (dirs) =>
|
|
79203
|
-
candidateFile = (dirs, id) =>
|
|
79204
|
-
workflowFile = (dirs, id) =>
|
|
79627
|
+
candidatesDir = (dirs) => path18.join(dirs.stateDir, "learn", "candidates");
|
|
79628
|
+
candidateFile = (dirs, id) => path18.join(candidatesDir(dirs), `${assertTaskName(id)}.json`);
|
|
79629
|
+
workflowFile = (dirs, id) => path18.join(dirs.workflowsDir, `${assertTaskName(id)}.json`);
|
|
79205
79630
|
}
|
|
79206
79631
|
});
|
|
79207
79632
|
|
|
@@ -79635,8 +80060,8 @@ var init_langfuse = __esm({
|
|
|
79635
80060
|
});
|
|
79636
80061
|
|
|
79637
80062
|
// ../learn/src/scan/import.ts
|
|
79638
|
-
import { readdir as readdir6, readFile as
|
|
79639
|
-
import
|
|
80063
|
+
import { readdir as readdir6, readFile as readFile15, stat as stat8 } from "node:fs/promises";
|
|
80064
|
+
import path19 from "node:path";
|
|
79640
80065
|
function detectFormat(json) {
|
|
79641
80066
|
if (looksLikeOtlp(json)) return "otlp";
|
|
79642
80067
|
if (looksLikeLangSmith(json)) return "langsmith";
|
|
@@ -79668,13 +80093,13 @@ function importLines(text, where) {
|
|
|
79668
80093
|
}
|
|
79669
80094
|
return importJson(docs, where);
|
|
79670
80095
|
}
|
|
79671
|
-
async function importFile(
|
|
79672
|
-
const text = await
|
|
79673
|
-
const where =
|
|
79674
|
-
if (
|
|
80096
|
+
async function importFile(file2) {
|
|
80097
|
+
const text = await readFile15(file2, "utf8");
|
|
80098
|
+
const where = path19.basename(file2);
|
|
80099
|
+
if (file2.endsWith(".jsonl")) {
|
|
79675
80100
|
const first = text.split("\n").find((l2) => l2.trim());
|
|
79676
80101
|
if (first && /"type"\s*:\s*"meta"/.test(first)) {
|
|
79677
|
-
const trace2 = await readTrace(
|
|
80102
|
+
const trace2 = await readTrace(file2, { allowOpen: true });
|
|
79678
80103
|
return [{ source: "hotpath", id: where, trace: trace2, usage: null }];
|
|
79679
80104
|
}
|
|
79680
80105
|
return importLines(text, where);
|
|
@@ -79693,7 +80118,7 @@ async function files(target) {
|
|
|
79693
80118
|
const out = [];
|
|
79694
80119
|
for (const entry of await readdir6(target, { withFileTypes: true })) {
|
|
79695
80120
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
79696
|
-
const full =
|
|
80121
|
+
const full = path19.join(target, entry.name);
|
|
79697
80122
|
if (entry.isDirectory()) out.push(...await files(full));
|
|
79698
80123
|
else if (/\.jsonl?$/.test(entry.name)) out.push(full);
|
|
79699
80124
|
}
|
|
@@ -79711,13 +80136,13 @@ async function loadRuns(target) {
|
|
|
79711
80136
|
const runs = [];
|
|
79712
80137
|
const skipped = [];
|
|
79713
80138
|
let filesRead = 0;
|
|
79714
|
-
for (const
|
|
80139
|
+
for (const file2 of list) {
|
|
79715
80140
|
try {
|
|
79716
|
-
runs.push(...await importFile(
|
|
80141
|
+
runs.push(...await importFile(file2));
|
|
79717
80142
|
filesRead++;
|
|
79718
80143
|
} catch (err) {
|
|
79719
80144
|
skipped.push({
|
|
79720
|
-
file:
|
|
80145
|
+
file: path19.relative(process.cwd(), file2) || file2,
|
|
79721
80146
|
why: err instanceof Error ? err.message : String(err)
|
|
79722
80147
|
});
|
|
79723
80148
|
}
|
|
@@ -80020,13 +80445,13 @@ function formatScanJson(r2) {
|
|
|
80020
80445
|
);
|
|
80021
80446
|
}
|
|
80022
80447
|
function formatScanHtml(r2) {
|
|
80023
|
-
const
|
|
80448
|
+
const stat10 = (value, label) => `<div class="stat"><div class="v">${esc2(value)}</div><div class="l">${esc2(label)}</div></div>`;
|
|
80024
80449
|
const stats = [
|
|
80025
|
-
|
|
80026
|
-
|
|
80027
|
-
|
|
80450
|
+
stat10(pct(r2.potentialHitRate), "estimated hit rate"),
|
|
80451
|
+
stat10(n2(r2.compilablePaths), "repeated paths"),
|
|
80452
|
+
stat10(`${n2(r2.compilableRuns)} of ${n2(r2.runs)}`, "runs on those paths"),
|
|
80028
80453
|
...r2.monthly ? [
|
|
80029
|
-
|
|
80454
|
+
stat10(
|
|
80030
80455
|
`${usd2(r2.monthly.savingLowUsd)} \u2013 ${usd2(r2.monthly.savingHighUsd)}`,
|
|
80031
80456
|
"estimated saving a month"
|
|
80032
80457
|
)
|
|
@@ -80102,9 +80527,79 @@ var init_src7 = __esm({
|
|
|
80102
80527
|
}
|
|
80103
80528
|
});
|
|
80104
80529
|
|
|
80530
|
+
// src/sync/summary.ts
|
|
80531
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
80532
|
+
function children(step) {
|
|
80533
|
+
if (step.type === "foreach") return step.body;
|
|
80534
|
+
if (step.type === "branch") {
|
|
80535
|
+
return [...step.cases.flatMap((c2) => c2.steps), ...step.else ?? []];
|
|
80536
|
+
}
|
|
80537
|
+
return [];
|
|
80538
|
+
}
|
|
80539
|
+
function summarizeWorkflow(workflow, updatedAt) {
|
|
80540
|
+
const nodes = [];
|
|
80541
|
+
const edges = [];
|
|
80542
|
+
let modelSteps = 0;
|
|
80543
|
+
let toolSteps = 0;
|
|
80544
|
+
let sideEffects = 0;
|
|
80545
|
+
const walk5 = (steps, parent) => {
|
|
80546
|
+
let previous;
|
|
80547
|
+
for (const step of steps) {
|
|
80548
|
+
nodes.push({
|
|
80549
|
+
id: step.id,
|
|
80550
|
+
kind: step.type,
|
|
80551
|
+
label: step.type === "tool" ? step.tool : step.type
|
|
80552
|
+
});
|
|
80553
|
+
if (step.type === "tool") {
|
|
80554
|
+
toolSteps++;
|
|
80555
|
+
if (step.sideEffect) sideEffects++;
|
|
80556
|
+
} else if (step.type === "llm") {
|
|
80557
|
+
modelSteps++;
|
|
80558
|
+
}
|
|
80559
|
+
const from = previous ?? parent;
|
|
80560
|
+
if (from) edges.push({ from, to: step.id });
|
|
80561
|
+
previous = step.id;
|
|
80562
|
+
const inner = children(step);
|
|
80563
|
+
if (inner.length > 0) walk5(inner, step.id);
|
|
80564
|
+
}
|
|
80565
|
+
};
|
|
80566
|
+
walk5(workflow.steps);
|
|
80567
|
+
return {
|
|
80568
|
+
name: workflow.task,
|
|
80569
|
+
steps: toolSteps + modelSteps,
|
|
80570
|
+
modelSteps,
|
|
80571
|
+
toolSteps,
|
|
80572
|
+
sideEffects,
|
|
80573
|
+
graph: { nodes, edges },
|
|
80574
|
+
updatedAt: updatedAt.toISOString()
|
|
80575
|
+
};
|
|
80576
|
+
}
|
|
80577
|
+
function summarizeRun(input) {
|
|
80578
|
+
const m3 = input.metrics;
|
|
80579
|
+
return {
|
|
80580
|
+
id: input.id ?? randomUUID2(),
|
|
80581
|
+
workflow: input.workflow,
|
|
80582
|
+
kind: input.kind,
|
|
80583
|
+
ok: input.ok,
|
|
80584
|
+
fallback: m3.fallback,
|
|
80585
|
+
dryRun: input.dryRun === true,
|
|
80586
|
+
durationMs: Math.round(m3.durationMs),
|
|
80587
|
+
llmCalls: m3.llmCalls,
|
|
80588
|
+
costUsd: m3.costUsd,
|
|
80589
|
+
...input.baseline?.costUsd !== void 0 ? { baselineCostUsd: input.baseline.costUsd } : {},
|
|
80590
|
+
...input.baseline ? { baselineDurationMs: Math.round(input.baseline.durationMs) } : {},
|
|
80591
|
+
startedAt: input.startedAt.toISOString()
|
|
80592
|
+
};
|
|
80593
|
+
}
|
|
80594
|
+
var init_summary = __esm({
|
|
80595
|
+
"src/sync/summary.ts"() {
|
|
80596
|
+
"use strict";
|
|
80597
|
+
}
|
|
80598
|
+
});
|
|
80599
|
+
|
|
80105
80600
|
// ../../examples/demo-agent/src/config.ts
|
|
80106
|
-
import { readFile as
|
|
80107
|
-
import
|
|
80601
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
80602
|
+
import path20 from "node:path";
|
|
80108
80603
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
80109
80604
|
function splitCommand2(cmd) {
|
|
80110
80605
|
return (cmd.match(/(?:[^\s"]+|"[^"]*")+/g) ?? []).map(
|
|
@@ -80113,7 +80608,7 @@ function splitCommand2(cmd) {
|
|
|
80113
80608
|
}
|
|
80114
80609
|
async function loadTaskConfig(task) {
|
|
80115
80610
|
const config2 = JSON.parse(
|
|
80116
|
-
await
|
|
80611
|
+
await readFile16(path20.join(repoRoot4, "hotpath.config.json"), "utf8")
|
|
80117
80612
|
);
|
|
80118
80613
|
const entry = config2.tasks[task];
|
|
80119
80614
|
if (!entry) {
|
|
@@ -80124,11 +80619,11 @@ async function loadTaskConfig(task) {
|
|
|
80124
80619
|
return entry;
|
|
80125
80620
|
}
|
|
80126
80621
|
var repoRoot4;
|
|
80127
|
-
var
|
|
80622
|
+
var init_config2 = __esm({
|
|
80128
80623
|
"../../examples/demo-agent/src/config.ts"() {
|
|
80129
80624
|
"use strict";
|
|
80130
|
-
repoRoot4 =
|
|
80131
|
-
|
|
80625
|
+
repoRoot4 = path20.resolve(
|
|
80626
|
+
path20.dirname(fileURLToPath3(import.meta.url)),
|
|
80132
80627
|
"../../.."
|
|
80133
80628
|
);
|
|
80134
80629
|
}
|
|
@@ -80160,8 +80655,8 @@ var init_nudge = __esm({
|
|
|
80160
80655
|
});
|
|
80161
80656
|
|
|
80162
80657
|
// ../../examples/demo-agent/src/agent.ts
|
|
80163
|
-
import { mkdir as
|
|
80164
|
-
import
|
|
80658
|
+
import { mkdir as mkdir11, writeFile as writeFile11 } from "node:fs/promises";
|
|
80659
|
+
import path21 from "node:path";
|
|
80165
80660
|
function promptFor(task) {
|
|
80166
80661
|
const entry = PROMPTS[task];
|
|
80167
80662
|
if (!entry) {
|
|
@@ -80192,7 +80687,7 @@ async function runAgent(options) {
|
|
|
80192
80687
|
process.execPath,
|
|
80193
80688
|
"--import",
|
|
80194
80689
|
"tsx",
|
|
80195
|
-
|
|
80690
|
+
path21.join(repoRoot4, "packages/cli/src/index.ts"),
|
|
80196
80691
|
"record",
|
|
80197
80692
|
"--task",
|
|
80198
80693
|
options.task,
|
|
@@ -80288,10 +80783,10 @@ async function runAgent(options) {
|
|
|
80288
80783
|
} finally {
|
|
80289
80784
|
await client2.close();
|
|
80290
80785
|
}
|
|
80291
|
-
const outDir3 =
|
|
80292
|
-
await
|
|
80293
|
-
await
|
|
80294
|
-
|
|
80786
|
+
const outDir3 = path21.join(root, "out");
|
|
80787
|
+
await mkdir11(outDir3, { recursive: true });
|
|
80788
|
+
await writeFile11(
|
|
80789
|
+
path21.join(outDir3, "agent-run.json"),
|
|
80295
80790
|
JSON.stringify(metrics, null, 2)
|
|
80296
80791
|
);
|
|
80297
80792
|
console.log(
|
|
@@ -80312,7 +80807,7 @@ var init_agent = __esm({
|
|
|
80312
80807
|
init_client3();
|
|
80313
80808
|
init_stdio2();
|
|
80314
80809
|
init_src();
|
|
80315
|
-
|
|
80810
|
+
init_config2();
|
|
80316
80811
|
init_nudge();
|
|
80317
80812
|
PROMPTS = {
|
|
80318
80813
|
"morning-brief": {
|
|
@@ -80400,15 +80895,15 @@ var init_agent = __esm({
|
|
|
80400
80895
|
// src/wrap/self.ts
|
|
80401
80896
|
import { existsSync as existsSync5 } from "node:fs";
|
|
80402
80897
|
import { createRequire } from "node:module";
|
|
80403
|
-
import
|
|
80898
|
+
import path22 from "node:path";
|
|
80404
80899
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
80405
80900
|
function selfCommandFor(options) {
|
|
80406
80901
|
if (options.installed) {
|
|
80407
80902
|
return [options.node, options.file, "--home", options.home];
|
|
80408
80903
|
}
|
|
80409
|
-
const dir =
|
|
80904
|
+
const dir = path22.dirname(options.file);
|
|
80410
80905
|
const fromTs = options.file.endsWith(".ts");
|
|
80411
|
-
const entry =
|
|
80906
|
+
const entry = path22.join(dir, "..", fromTs ? "index.ts" : "index.js");
|
|
80412
80907
|
if (!fromTs) return [options.node, entry];
|
|
80413
80908
|
return [options.node, options.tsx(), entry];
|
|
80414
80909
|
}
|
|
@@ -80419,7 +80914,7 @@ function selfCommand() {
|
|
|
80419
80914
|
node: process.execPath,
|
|
80420
80915
|
home: repoRoot5,
|
|
80421
80916
|
tsx: () => {
|
|
80422
|
-
const stable =
|
|
80917
|
+
const stable = path22.join(
|
|
80423
80918
|
here3,
|
|
80424
80919
|
"../../../..",
|
|
80425
80920
|
"node_modules",
|
|
@@ -80437,7 +80932,7 @@ var init_self = __esm({
|
|
|
80437
80932
|
"use strict";
|
|
80438
80933
|
init_src();
|
|
80439
80934
|
thisFile = fileURLToPath4(import.meta.url);
|
|
80440
|
-
here3 =
|
|
80935
|
+
here3 = path22.dirname(thisFile);
|
|
80441
80936
|
repoRoot5 = projectRoot();
|
|
80442
80937
|
}
|
|
80443
80938
|
});
|
|
@@ -81405,14 +81900,14 @@ var init_mcp = __esm({
|
|
|
81405
81900
|
});
|
|
81406
81901
|
|
|
81407
81902
|
// ../../examples/demo-tools/src/messages.ts
|
|
81408
|
-
import { mkdir as
|
|
81409
|
-
import
|
|
81903
|
+
import { mkdir as mkdir12, readFile as readFile17, writeFile as writeFile12 } from "node:fs/promises";
|
|
81904
|
+
import path23 from "node:path";
|
|
81410
81905
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
81411
81906
|
async function appendMessage(msg) {
|
|
81412
|
-
await
|
|
81907
|
+
await mkdir12(outDir2, { recursive: true });
|
|
81413
81908
|
let messages = [];
|
|
81414
81909
|
try {
|
|
81415
|
-
messages = JSON.parse(await
|
|
81910
|
+
messages = JSON.parse(await readFile17(messagesFile, "utf8"));
|
|
81416
81911
|
} catch {
|
|
81417
81912
|
}
|
|
81418
81913
|
const message = {
|
|
@@ -81422,15 +81917,15 @@ async function appendMessage(msg) {
|
|
|
81422
81917
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
81423
81918
|
};
|
|
81424
81919
|
messages.push(message);
|
|
81425
|
-
await
|
|
81920
|
+
await writeFile12(messagesFile, JSON.stringify(messages, null, 2));
|
|
81426
81921
|
return message;
|
|
81427
81922
|
}
|
|
81428
81923
|
var outDir2, messagesFile;
|
|
81429
81924
|
var init_messages6 = __esm({
|
|
81430
81925
|
"../../examples/demo-tools/src/messages.ts"() {
|
|
81431
81926
|
"use strict";
|
|
81432
|
-
outDir2 = process.env.DEMO_OUT_DIR ??
|
|
81433
|
-
messagesFile =
|
|
81927
|
+
outDir2 = process.env.DEMO_OUT_DIR ?? path23.resolve(path23.dirname(fileURLToPath5(import.meta.url)), "../../../out");
|
|
81928
|
+
messagesFile = path23.join(outDir2, "messages.json");
|
|
81434
81929
|
}
|
|
81435
81930
|
});
|
|
81436
81931
|
|
|
@@ -81464,19 +81959,19 @@ var init_common = __esm({
|
|
|
81464
81959
|
});
|
|
81465
81960
|
|
|
81466
81961
|
// ../../examples/demo-tools/src/fixtures.ts
|
|
81467
|
-
import { readFile as
|
|
81468
|
-
import
|
|
81962
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
81963
|
+
import path24 from "node:path";
|
|
81469
81964
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
81470
81965
|
async function loadFixture(name) {
|
|
81471
81966
|
const set = process.env.DEMO_FIXTURES ?? "default";
|
|
81472
|
-
const
|
|
81473
|
-
return JSON.parse(await
|
|
81967
|
+
const file2 = path24.join(fixturesDir, set, `${name}.json`);
|
|
81968
|
+
return JSON.parse(await readFile18(file2, "utf8"));
|
|
81474
81969
|
}
|
|
81475
81970
|
var fixturesDir;
|
|
81476
81971
|
var init_fixtures = __esm({
|
|
81477
81972
|
"../../examples/demo-tools/src/fixtures.ts"() {
|
|
81478
81973
|
"use strict";
|
|
81479
|
-
fixturesDir = process.env.DEMO_FIXTURES_DIR ??
|
|
81974
|
+
fixturesDir = process.env.DEMO_FIXTURES_DIR ?? path24.resolve(path24.dirname(fileURLToPath6(import.meta.url)), "../fixtures");
|
|
81480
81975
|
}
|
|
81481
81976
|
});
|
|
81482
81977
|
|
|
@@ -81571,16 +82066,16 @@ var init_src8 = __esm({
|
|
|
81571
82066
|
|
|
81572
82067
|
// src/demo.ts
|
|
81573
82068
|
import { existsSync as existsSync6 } from "node:fs";
|
|
81574
|
-
import { readFile as
|
|
81575
|
-
import
|
|
82069
|
+
import { readFile as readFile19 } from "node:fs/promises";
|
|
82070
|
+
import path25 from "node:path";
|
|
81576
82071
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
81577
82072
|
function demoFixturesDir() {
|
|
81578
82073
|
const root = projectRoot();
|
|
81579
82074
|
if (runningFromSource()) {
|
|
81580
|
-
return
|
|
82075
|
+
return path25.join(root, "examples", "demo-tools", "fixtures");
|
|
81581
82076
|
}
|
|
81582
|
-
return
|
|
81583
|
-
|
|
82077
|
+
return path25.resolve(
|
|
82078
|
+
path25.dirname(fileURLToPath7(import.meta.url)),
|
|
81584
82079
|
"..",
|
|
81585
82080
|
"demo",
|
|
81586
82081
|
"fixtures"
|
|
@@ -81592,10 +82087,12 @@ function addDays(date4, days) {
|
|
|
81592
82087
|
return d2.toISOString().slice(0, 10);
|
|
81593
82088
|
}
|
|
81594
82089
|
function hasModelSettings(root) {
|
|
81595
|
-
return Boolean(process.env.LLM_API_KEY) || existsSync6(
|
|
82090
|
+
return Boolean(process.env.LLM_API_KEY) || existsSync6(path25.join(root, ".env"));
|
|
81596
82091
|
}
|
|
81597
|
-
function addDemoCommand(program2) {
|
|
82092
|
+
function addDemoCommand(program2, afterCommand) {
|
|
81598
82093
|
program2.command("demo-tools", { hidden: true }).description("(internal) the demo's fake MCP tool server").action(async () => {
|
|
82094
|
+
process.env.DEMO_FIXTURES_DIR ??= demoFixturesDir();
|
|
82095
|
+
process.env.DEMO_OUT_DIR ??= path25.join(projectRoot(), "out");
|
|
81599
82096
|
await init_src8().then(() => src_exports);
|
|
81600
82097
|
});
|
|
81601
82098
|
program2.command("demo").description(
|
|
@@ -81615,15 +82112,21 @@ function addDemoCommand(program2) {
|
|
|
81615
82112
|
);
|
|
81616
82113
|
}
|
|
81617
82114
|
const fixtures = demoFixturesDir();
|
|
81618
|
-
if (!existsSync6(
|
|
82115
|
+
if (!existsSync6(path25.join(fixtures, "default", "emails.json"))) {
|
|
81619
82116
|
throw new Error(`demo fixtures not found in ${fixtures}.`);
|
|
81620
82117
|
}
|
|
81621
82118
|
const self2 = selfCommand();
|
|
81622
82119
|
const env = {
|
|
81623
82120
|
DEMO_FIXTURES_DIR: fixtures,
|
|
81624
|
-
DEMO_OUT_DIR:
|
|
81625
|
-
DEMO_FIXTURES: "default"
|
|
82121
|
+
DEMO_OUT_DIR: path25.join(root, "out"),
|
|
82122
|
+
DEMO_FIXTURES: "default",
|
|
82123
|
+
// the MCP SDK passes a child only the variables listed here, so the
|
|
82124
|
+
// recorder it starts would not see that this command passed the login gate
|
|
82125
|
+
...process.env[GATE_MARKER] ? { [GATE_MARKER]: process.env[GATE_MARKER] } : {},
|
|
82126
|
+
...process.env.HOTPATH_TOKEN ? { HOTPATH_TOKEN: process.env.HOTPATH_TOKEN } : {},
|
|
82127
|
+
...process.env.HOTPATH_NO_SYNC ? { HOTPATH_NO_SYNC: process.env.HOTPATH_NO_SYNC } : {}
|
|
81626
82128
|
};
|
|
82129
|
+
const summaries = [];
|
|
81627
82130
|
console.log(
|
|
81628
82131
|
`Step 1 of 3: the agent does the "${TASK}" task (a model call each; every tool call is recorded)`
|
|
81629
82132
|
);
|
|
@@ -81631,7 +82134,7 @@ function addDemoCommand(program2) {
|
|
|
81631
82134
|
tracesDir,
|
|
81632
82135
|
workflowsDir,
|
|
81633
82136
|
stateDir: defaultStateDir,
|
|
81634
|
-
agentRunFile:
|
|
82137
|
+
agentRunFile: path25.join(root, "out", "agent-run.json")
|
|
81635
82138
|
};
|
|
81636
82139
|
let done = 0;
|
|
81637
82140
|
let id;
|
|
@@ -81649,6 +82152,15 @@ function addDemoCommand(program2) {
|
|
|
81649
82152
|
env
|
|
81650
82153
|
}
|
|
81651
82154
|
});
|
|
82155
|
+
summaries.push(
|
|
82156
|
+
summarizeRun({
|
|
82157
|
+
workflow: TASK,
|
|
82158
|
+
kind: "record",
|
|
82159
|
+
ok: true,
|
|
82160
|
+
metrics: { ...metrics, fallback: false },
|
|
82161
|
+
startedAt: new Date(Date.now() - metrics.durationMs)
|
|
82162
|
+
})
|
|
82163
|
+
);
|
|
81652
82164
|
console.log(
|
|
81653
82165
|
` run ${done + 1} (${date5}): ${metrics.llmCalls} model calls, ${(metrics.durationMs / 1e3).toFixed(1)} s`
|
|
81654
82166
|
);
|
|
@@ -81680,13 +82192,24 @@ function addDemoCommand(program2) {
|
|
|
81680
82192
|
Step 3 of 3: replay "${id}" on new data (${date4}); the model is called only where judgment is needed`
|
|
81681
82193
|
);
|
|
81682
82194
|
const start = Date.now();
|
|
81683
|
-
await runTask(id, { inputs: { date: date4 } });
|
|
82195
|
+
const replayed = await runTask(id, { inputs: { date: date4 } });
|
|
82196
|
+
const baseline = await loadWorkflow(id).then((w3) => w3.baseline).catch(() => void 0);
|
|
82197
|
+
summaries.push(
|
|
82198
|
+
summarizeRun({
|
|
82199
|
+
workflow: id,
|
|
82200
|
+
kind: "replay",
|
|
82201
|
+
ok: true,
|
|
82202
|
+
metrics: replayed,
|
|
82203
|
+
baseline,
|
|
82204
|
+
startedAt: new Date(start)
|
|
82205
|
+
})
|
|
82206
|
+
);
|
|
81684
82207
|
console.log(
|
|
81685
82208
|
`replay took ${((Date.now() - start) / 1e3).toFixed(1)} s`
|
|
81686
82209
|
);
|
|
81687
82210
|
try {
|
|
81688
82211
|
const sent = JSON.parse(
|
|
81689
|
-
await
|
|
82212
|
+
await readFile19(path25.join(root, "out", "messages.json"), "utf8")
|
|
81690
82213
|
);
|
|
81691
82214
|
const last = sent[sent.length - 1];
|
|
81692
82215
|
if (last)
|
|
@@ -81695,6 +82218,7 @@ message sent to "${last.to}":
|
|
|
81695
82218
|
${last.text}`);
|
|
81696
82219
|
} catch {
|
|
81697
82220
|
}
|
|
82221
|
+
await afterCommand(summaries);
|
|
81698
82222
|
console.log(
|
|
81699
82223
|
`
|
|
81700
82224
|
Done. See the workflow: hotpath show ${id} or hotpath view ${id}`
|
|
@@ -81716,6 +82240,8 @@ var init_demo = __esm({
|
|
|
81716
82240
|
init_src4();
|
|
81717
82241
|
init_src5();
|
|
81718
82242
|
init_src();
|
|
82243
|
+
init_summary();
|
|
82244
|
+
init_gate();
|
|
81719
82245
|
init_agent();
|
|
81720
82246
|
init_self();
|
|
81721
82247
|
TASK = "morning-brief";
|
|
@@ -81724,16 +82250,16 @@ var init_demo = __esm({
|
|
|
81724
82250
|
});
|
|
81725
82251
|
|
|
81726
82252
|
// src/learn.ts
|
|
81727
|
-
import
|
|
82253
|
+
import path26 from "node:path";
|
|
81728
82254
|
function learnDirs() {
|
|
81729
82255
|
return {
|
|
81730
82256
|
tracesDir,
|
|
81731
82257
|
workflowsDir,
|
|
81732
82258
|
stateDir: defaultStateDir,
|
|
81733
|
-
agentRunFile:
|
|
82259
|
+
agentRunFile: path26.join(repoRoot5, "out", "agent-run.json")
|
|
81734
82260
|
};
|
|
81735
82261
|
}
|
|
81736
|
-
function addLearnCommand(program2) {
|
|
82262
|
+
function addLearnCommand(program2, afterCommand) {
|
|
81737
82263
|
program2.command("learn").description(
|
|
81738
82264
|
"Find the paths your agent repeats and compile the hot ones, with no recording step"
|
|
81739
82265
|
).option(
|
|
@@ -81758,16 +82284,18 @@ function addLearnCommand(program2) {
|
|
|
81758
82284
|
);
|
|
81759
82285
|
}
|
|
81760
82286
|
console.log(
|
|
81761
|
-
`${options.promote} is live: ${
|
|
82287
|
+
`${options.promote} is live: ${path26.relative(repoRoot5, result.workflowFile)}
|
|
81762
82288
|
run it with: hotpath run ${options.promote} --input <name>=<value>`
|
|
81763
82289
|
);
|
|
82290
|
+
await afterCommand();
|
|
81764
82291
|
return;
|
|
81765
82292
|
}
|
|
81766
82293
|
const hotAfter = options.hotAfter ? parseHotAfter(options.hotAfter) : await configuredHotAfter(
|
|
81767
|
-
|
|
82294
|
+
path26.join(repoRoot5, "hotpath.config.json")
|
|
81768
82295
|
);
|
|
81769
82296
|
const report = await learn(dirs, { hotAfter, auto: options.auto });
|
|
81770
82297
|
console.log(formatLearnReport(report));
|
|
82298
|
+
await afterCommand();
|
|
81771
82299
|
} catch (err) {
|
|
81772
82300
|
console.error(err instanceof Error ? err.message : String(err));
|
|
81773
82301
|
process.exit(1);
|
|
@@ -81795,8 +82323,8 @@ var init_learn2 = __esm({
|
|
|
81795
82323
|
});
|
|
81796
82324
|
|
|
81797
82325
|
// src/scan.ts
|
|
81798
|
-
import { writeFile as
|
|
81799
|
-
import
|
|
82326
|
+
import { writeFile as writeFile13 } from "node:fs/promises";
|
|
82327
|
+
import path27 from "node:path";
|
|
81800
82328
|
function positive(name, text) {
|
|
81801
82329
|
const v3 = Number(text);
|
|
81802
82330
|
if (!Number.isFinite(v3) || v3 <= 0)
|
|
@@ -81840,7 +82368,7 @@ function addScanCommand(program2) {
|
|
|
81840
82368
|
runCostUsd: options.runCost
|
|
81841
82369
|
});
|
|
81842
82370
|
if (options.html) {
|
|
81843
|
-
await
|
|
82371
|
+
await writeFile13(options.html, formatScanHtml(result), "utf8");
|
|
81844
82372
|
}
|
|
81845
82373
|
if (options.json) {
|
|
81846
82374
|
console.log(formatScanJson(result));
|
|
@@ -81848,7 +82376,7 @@ function addScanCommand(program2) {
|
|
|
81848
82376
|
console.log(formatScanText(result));
|
|
81849
82377
|
if (options.html)
|
|
81850
82378
|
console.log(`
|
|
81851
|
-
Report written to ${
|
|
82379
|
+
Report written to ${path27.resolve(options.html)}`);
|
|
81852
82380
|
}
|
|
81853
82381
|
const note = options.json ? console.error : console.log;
|
|
81854
82382
|
if (skipped.length > 0) {
|
|
@@ -82293,7 +82821,7 @@ var init_formats3 = __esm({
|
|
|
82293
82821
|
|
|
82294
82822
|
// ../proxy/src/record.ts
|
|
82295
82823
|
import { createHash as createHash5 } from "node:crypto";
|
|
82296
|
-
import { writeFile as
|
|
82824
|
+
import { writeFile as writeFile14 } from "node:fs/promises";
|
|
82297
82825
|
function inferInputs2(calls, user, system = "") {
|
|
82298
82826
|
const fromUser = inputsIn(calls, user);
|
|
82299
82827
|
return Object.keys(fromUser).length > 0 ? fromUser : inputsIn(calls, system);
|
|
@@ -82459,7 +82987,7 @@ var init_record2 = __esm({
|
|
|
82459
82987
|
system,
|
|
82460
82988
|
user: userTemplate
|
|
82461
82989
|
};
|
|
82462
|
-
await
|
|
82990
|
+
await writeFile14(
|
|
82463
82991
|
writer.file.replace(/\.jsonl$/, ".prompt.json"),
|
|
82464
82992
|
JSON.stringify(template, null, 2) + "\n",
|
|
82465
82993
|
{ mode: 384 }
|
|
@@ -82602,11 +83130,11 @@ var init_replay = __esm({
|
|
|
82602
83130
|
|
|
82603
83131
|
// ../proxy/src/server.ts
|
|
82604
83132
|
import { createHash as createHash6 } from "node:crypto";
|
|
82605
|
-
import { access as access2, readdir as readdir7, readFile as
|
|
83133
|
+
import { access as access2, readdir as readdir7, readFile as readFile20 } from "node:fs/promises";
|
|
82606
83134
|
import {
|
|
82607
83135
|
createServer
|
|
82608
83136
|
} from "node:http";
|
|
82609
|
-
import
|
|
83137
|
+
import path28 from "node:path";
|
|
82610
83138
|
function header(req, name) {
|
|
82611
83139
|
const v3 = req.headers[name];
|
|
82612
83140
|
return Array.isArray(v3) ? v3[0] : v3;
|
|
@@ -82692,12 +83220,12 @@ async function templates() {
|
|
|
82692
83220
|
const out = [];
|
|
82693
83221
|
for (const task of tasks) {
|
|
82694
83222
|
try {
|
|
82695
|
-
await access2(
|
|
82696
|
-
const files2 = (await readdir7(
|
|
83223
|
+
await access2(path28.join(workflowsDir, `${task}.json`));
|
|
83224
|
+
const files2 = (await readdir7(path28.join(tracesDir, task))).filter((f3) => f3.endsWith(".prompt.json")).sort().reverse();
|
|
82697
83225
|
for (const f3 of files2) {
|
|
82698
83226
|
out.push(
|
|
82699
83227
|
JSON.parse(
|
|
82700
|
-
await
|
|
83228
|
+
await readFile20(path28.join(tracesDir, task, f3), "utf8")
|
|
82701
83229
|
)
|
|
82702
83230
|
);
|
|
82703
83231
|
}
|
|
@@ -82742,14 +83270,14 @@ async function startProxy(options = {}) {
|
|
|
82742
83270
|
clearTimeout(s3.endTimer);
|
|
82743
83271
|
sessions.delete(s3);
|
|
82744
83272
|
forgetCalls(s3);
|
|
82745
|
-
const
|
|
82746
|
-
if (
|
|
82747
|
-
stats.tracesWritten.push(
|
|
83273
|
+
const file2 = await s3.recording?.finish() ?? null;
|
|
83274
|
+
if (file2) {
|
|
83275
|
+
stats.tracesWritten.push(file2);
|
|
82748
83276
|
log(
|
|
82749
|
-
`\u25CF recorded ${s3.recording?.callCount ?? 0} tool call(s): ${
|
|
83277
|
+
`\u25CF recorded ${s3.recording?.callCount ?? 0} tool call(s): ${path28.basename(path28.dirname(file2))}/${path28.basename(file2)}`
|
|
82750
83278
|
);
|
|
82751
83279
|
}
|
|
82752
|
-
return
|
|
83280
|
+
return file2;
|
|
82753
83281
|
};
|
|
82754
83282
|
const sweeper = setInterval(() => {
|
|
82755
83283
|
const now = Date.now();
|
|
@@ -83161,8 +83689,8 @@ async function startProxy(options = {}) {
|
|
|
83161
83689
|
const files2 = [];
|
|
83162
83690
|
for (const s3 of [...sessions]) {
|
|
83163
83691
|
if (s3.kind !== "record") continue;
|
|
83164
|
-
const
|
|
83165
|
-
if (
|
|
83692
|
+
const file2 = await finishRecording(s3);
|
|
83693
|
+
if (file2) files2.push(file2);
|
|
83166
83694
|
}
|
|
83167
83695
|
return files2;
|
|
83168
83696
|
};
|
|
@@ -83309,10 +83837,184 @@ var init_proxy = __esm({
|
|
|
83309
83837
|
}
|
|
83310
83838
|
});
|
|
83311
83839
|
|
|
83840
|
+
// src/sync/queue.ts
|
|
83841
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
83842
|
+
import { mkdir as mkdir13, readdir as readdir8, readFile as readFile21, stat as stat9, writeFile as writeFile15 } from "node:fs/promises";
|
|
83843
|
+
import path29 from "node:path";
|
|
83844
|
+
function syncDisabled(env) {
|
|
83845
|
+
const v3 = env.HOTPATH_NO_SYNC?.trim();
|
|
83846
|
+
return v3 === "1" || v3?.toLowerCase() === "true";
|
|
83847
|
+
}
|
|
83848
|
+
async function readQueue(stateDir2) {
|
|
83849
|
+
try {
|
|
83850
|
+
const q2 = JSON.parse(
|
|
83851
|
+
await readFile21(queueFile(stateDir2), "utf8")
|
|
83852
|
+
);
|
|
83853
|
+
return {
|
|
83854
|
+
workflows: Array.isArray(q2.workflows) ? q2.workflows : [],
|
|
83855
|
+
runs: Array.isArray(q2.runs) ? q2.runs : []
|
|
83856
|
+
};
|
|
83857
|
+
} catch {
|
|
83858
|
+
return { workflows: [], runs: [] };
|
|
83859
|
+
}
|
|
83860
|
+
}
|
|
83861
|
+
async function writeQueue(stateDir2, q2) {
|
|
83862
|
+
await mkdir13(stateDir2, { recursive: true, mode: 448 });
|
|
83863
|
+
await writeFile15(queueFile(stateDir2), JSON.stringify(q2) + "\n");
|
|
83864
|
+
}
|
|
83865
|
+
async function enqueue(stateDir2, add) {
|
|
83866
|
+
const q2 = await readQueue(stateDir2);
|
|
83867
|
+
const byName = new Map(q2.workflows.map((w3) => [w3.name, w3]));
|
|
83868
|
+
for (const w3 of add.workflows ?? []) byName.set(w3.name, w3);
|
|
83869
|
+
const runs = [...q2.runs, ...add.runs ?? []].slice(-MAX_QUEUED_RUNS);
|
|
83870
|
+
await writeQueue(stateDir2, { workflows: [...byName.values()], runs });
|
|
83871
|
+
}
|
|
83872
|
+
async function enqueueChangedWorkflows(workflowsDir2, stateDir2) {
|
|
83873
|
+
let files2;
|
|
83874
|
+
try {
|
|
83875
|
+
files2 = (await readdir8(workflowsDir2)).filter(
|
|
83876
|
+
(f3) => f3.endsWith(".json") && !f3.endsWith(".bak.json")
|
|
83877
|
+
);
|
|
83878
|
+
} catch {
|
|
83879
|
+
return 0;
|
|
83880
|
+
}
|
|
83881
|
+
let seen = {};
|
|
83882
|
+
try {
|
|
83883
|
+
seen = JSON.parse(await readFile21(stateFile(stateDir2), "utf8"));
|
|
83884
|
+
} catch {
|
|
83885
|
+
}
|
|
83886
|
+
const changed = [];
|
|
83887
|
+
for (const f3 of files2) {
|
|
83888
|
+
const file2 = path29.join(workflowsDir2, f3);
|
|
83889
|
+
try {
|
|
83890
|
+
const raw = await readFile21(file2, "utf8");
|
|
83891
|
+
const hash = createHash7("sha256").update(raw).digest("hex");
|
|
83892
|
+
if (seen[f3] === hash) continue;
|
|
83893
|
+
const parsed = workflowSchema.safeParse(JSON.parse(raw));
|
|
83894
|
+
if (!parsed.success) continue;
|
|
83895
|
+
changed.push(summarizeWorkflow(parsed.data, (await stat9(file2)).mtime));
|
|
83896
|
+
seen[f3] = hash;
|
|
83897
|
+
} catch {
|
|
83898
|
+
}
|
|
83899
|
+
}
|
|
83900
|
+
if (changed.length === 0) return 0;
|
|
83901
|
+
await enqueue(stateDir2, { workflows: changed });
|
|
83902
|
+
await mkdir13(stateDir2, { recursive: true, mode: 448 });
|
|
83903
|
+
await writeFile15(stateFile(stateDir2), JSON.stringify(seen) + "\n");
|
|
83904
|
+
return changed.length;
|
|
83905
|
+
}
|
|
83906
|
+
async function flushQueue(deps) {
|
|
83907
|
+
try {
|
|
83908
|
+
let q2 = await readQueue(deps.stateDir);
|
|
83909
|
+
let sentAny = false;
|
|
83910
|
+
while (q2.workflows.length > 0 || q2.runs.length > 0) {
|
|
83911
|
+
const workflows = q2.workflows.slice(0, MAX_WORKFLOWS_PER_CALL);
|
|
83912
|
+
const runs = q2.runs.slice(0, MAX_RUNS_PER_CALL);
|
|
83913
|
+
const ctl = new AbortController();
|
|
83914
|
+
const timer = setTimeout(() => ctl.abort(), deps.timeoutMs ?? 1e4);
|
|
83915
|
+
try {
|
|
83916
|
+
await post(
|
|
83917
|
+
deps.fetch,
|
|
83918
|
+
"cli-sync",
|
|
83919
|
+
{ client: deps.client, workflows, runs },
|
|
83920
|
+
deps.token,
|
|
83921
|
+
ctl.signal
|
|
83922
|
+
);
|
|
83923
|
+
} catch (err) {
|
|
83924
|
+
if (err instanceof HttpError && (err.status === 400 || err.status === 413)) {
|
|
83925
|
+
q2 = {
|
|
83926
|
+
workflows: q2.workflows.slice(workflows.length),
|
|
83927
|
+
runs: q2.runs.slice(runs.length)
|
|
83928
|
+
};
|
|
83929
|
+
await writeQueue(deps.stateDir, q2);
|
|
83930
|
+
continue;
|
|
83931
|
+
}
|
|
83932
|
+
return { sent: sentAny };
|
|
83933
|
+
} finally {
|
|
83934
|
+
clearTimeout(timer);
|
|
83935
|
+
}
|
|
83936
|
+
sentAny = true;
|
|
83937
|
+
const now = await readQueue(deps.stateDir);
|
|
83938
|
+
const sentIds = new Set(runs.map((r2) => r2.id));
|
|
83939
|
+
const sentNames = new Map(workflows.map((w3) => [w3.name, w3.updatedAt]));
|
|
83940
|
+
q2 = {
|
|
83941
|
+
runs: now.runs.filter((r2) => !sentIds.has(r2.id)),
|
|
83942
|
+
workflows: now.workflows.filter(
|
|
83943
|
+
(w3) => sentNames.get(w3.name) !== w3.updatedAt
|
|
83944
|
+
)
|
|
83945
|
+
};
|
|
83946
|
+
await writeQueue(deps.stateDir, q2);
|
|
83947
|
+
}
|
|
83948
|
+
return { sent: sentAny };
|
|
83949
|
+
} catch {
|
|
83950
|
+
return { sent: false };
|
|
83951
|
+
}
|
|
83952
|
+
}
|
|
83953
|
+
var MAX_RUNS_PER_CALL, MAX_WORKFLOWS_PER_CALL, MAX_QUEUED_RUNS, queueFile, stateFile;
|
|
83954
|
+
var init_queue = __esm({
|
|
83955
|
+
"src/sync/queue.ts"() {
|
|
83956
|
+
"use strict";
|
|
83957
|
+
init_src();
|
|
83958
|
+
init_api2();
|
|
83959
|
+
init_summary();
|
|
83960
|
+
MAX_RUNS_PER_CALL = 500;
|
|
83961
|
+
MAX_WORKFLOWS_PER_CALL = 100;
|
|
83962
|
+
MAX_QUEUED_RUNS = 5e3;
|
|
83963
|
+
queueFile = (stateDir2) => path29.join(stateDir2, "sync-queue.json");
|
|
83964
|
+
stateFile = (stateDir2) => path29.join(stateDir2, "sync-state.json");
|
|
83965
|
+
}
|
|
83966
|
+
});
|
|
83967
|
+
|
|
83968
|
+
// src/sync/background.ts
|
|
83969
|
+
async function syncAfterCommand(ctx, runs = []) {
|
|
83970
|
+
try {
|
|
83971
|
+
if (syncDisabled(ctx.env)) return;
|
|
83972
|
+
await enqueueChangedWorkflows(ctx.workflowsDir, ctx.stateDir);
|
|
83973
|
+
if (runs.length > 0) await enqueue(ctx.stateDir, { runs });
|
|
83974
|
+
ctx.startFlush();
|
|
83975
|
+
} catch {
|
|
83976
|
+
}
|
|
83977
|
+
}
|
|
83978
|
+
function detachedFlush(self2, env) {
|
|
83979
|
+
return () => {
|
|
83980
|
+
try {
|
|
83981
|
+
const child2 = (0, import_cross_spawn6.default)(self2[0], [...self2.slice(1), "sync-flush"], {
|
|
83982
|
+
detached: true,
|
|
83983
|
+
stdio: "ignore",
|
|
83984
|
+
windowsHide: true,
|
|
83985
|
+
env
|
|
83986
|
+
});
|
|
83987
|
+
child2.on("error", () => void 0);
|
|
83988
|
+
child2.unref();
|
|
83989
|
+
} catch {
|
|
83990
|
+
}
|
|
83991
|
+
};
|
|
83992
|
+
}
|
|
83993
|
+
async function runFlush(opts) {
|
|
83994
|
+
if (syncDisabled(opts.env)) return;
|
|
83995
|
+
const token = await currentToken(opts.env, opts.dir);
|
|
83996
|
+
if (!token) return;
|
|
83997
|
+
await flushQueue({
|
|
83998
|
+
fetch: opts.fetch,
|
|
83999
|
+
stateDir: opts.stateDir,
|
|
84000
|
+
token,
|
|
84001
|
+
client: opts.client
|
|
84002
|
+
});
|
|
84003
|
+
}
|
|
84004
|
+
var import_cross_spawn6;
|
|
84005
|
+
var init_background = __esm({
|
|
84006
|
+
"src/sync/background.ts"() {
|
|
84007
|
+
"use strict";
|
|
84008
|
+
import_cross_spawn6 = __toESM(require_cross_spawn(), 1);
|
|
84009
|
+
init_queue();
|
|
84010
|
+
init_gate();
|
|
84011
|
+
}
|
|
84012
|
+
});
|
|
84013
|
+
|
|
83312
84014
|
// src/report.ts
|
|
83313
|
-
import { mkdir as
|
|
83314
|
-
import
|
|
83315
|
-
import
|
|
84015
|
+
import { mkdir as mkdir14, readdir as readdir9, readFile as readFile22, writeFile as writeFile16 } from "node:fs/promises";
|
|
84016
|
+
import os5 from "node:os";
|
|
84017
|
+
import path30 from "node:path";
|
|
83316
84018
|
function redact2(value) {
|
|
83317
84019
|
if (typeof value === "string") return `<string, ${value.length} chars>`;
|
|
83318
84020
|
if (typeof value === "number") return "<number>";
|
|
@@ -83419,7 +84121,7 @@ function workflowStructure(workflow) {
|
|
|
83419
84121
|
task: workflow.task,
|
|
83420
84122
|
// the command's name only: its arguments and folder can hold tokens or names
|
|
83421
84123
|
server: {
|
|
83422
|
-
command:
|
|
84124
|
+
command: path30.basename(argv[0] ?? ""),
|
|
83423
84125
|
arguments: Math.max(0, argv.length - 1)
|
|
83424
84126
|
},
|
|
83425
84127
|
inputs: Object.fromEntries(
|
|
@@ -83494,14 +84196,14 @@ function redactTraceLine(line) {
|
|
|
83494
84196
|
}
|
|
83495
84197
|
async function names(dir) {
|
|
83496
84198
|
try {
|
|
83497
|
-
return (await
|
|
84199
|
+
return (await readdir9(dir)).sort();
|
|
83498
84200
|
} catch {
|
|
83499
84201
|
return [];
|
|
83500
84202
|
}
|
|
83501
84203
|
}
|
|
83502
|
-
async function readJson(
|
|
84204
|
+
async function readJson(file2) {
|
|
83503
84205
|
try {
|
|
83504
|
-
return JSON.parse(await
|
|
84206
|
+
return JSON.parse(await readFile22(file2, "utf8"));
|
|
83505
84207
|
} catch {
|
|
83506
84208
|
return null;
|
|
83507
84209
|
}
|
|
@@ -83523,9 +84225,9 @@ async function buildReport(options) {
|
|
|
83523
84225
|
(f3) => f3.endsWith(".json") && !f3.endsWith(".bak.json")
|
|
83524
84226
|
);
|
|
83525
84227
|
const workflows = /* @__PURE__ */ new Map();
|
|
83526
|
-
for (const
|
|
84228
|
+
for (const file2 of workflowFiles) {
|
|
83527
84229
|
const parsed = workflowSchema.safeParse(
|
|
83528
|
-
await readJson(
|
|
84230
|
+
await readJson(path30.join(dirs.workflowsDir, file2))
|
|
83529
84231
|
);
|
|
83530
84232
|
if (parsed.success && wanted(parsed.data.task)) {
|
|
83531
84233
|
workflows.set(parsed.data.task, parsed.data);
|
|
@@ -83550,7 +84252,7 @@ async function buildReport(options) {
|
|
|
83550
84252
|
for (const task of tasks) {
|
|
83551
84253
|
recordings.set(
|
|
83552
84254
|
task,
|
|
83553
|
-
(await names(
|
|
84255
|
+
(await names(path30.join(dirs.tracesDir, task))).filter(
|
|
83554
84256
|
(f3) => f3.endsWith(".jsonl")
|
|
83555
84257
|
)
|
|
83556
84258
|
);
|
|
@@ -83566,7 +84268,7 @@ async function buildReport(options) {
|
|
|
83566
84268
|
sideEffects: r2.sideEffectsMode,
|
|
83567
84269
|
...r2.error ? { problem: problemKind(r2.error) } : {}
|
|
83568
84270
|
});
|
|
83569
|
-
const last = options.task ? null : await readJson(
|
|
84271
|
+
const last = options.task ? null : await readJson(path30.join(dirs.outDir, "hotpath-run.json"));
|
|
83570
84272
|
const lastRun = last ? {
|
|
83571
84273
|
durationMs: last.durationMs,
|
|
83572
84274
|
connectMs: last.connectMs,
|
|
@@ -83598,7 +84300,7 @@ async function buildReport(options) {
|
|
|
83598
84300
|
generatedAt: now.toISOString(),
|
|
83599
84301
|
hotpath: options.version,
|
|
83600
84302
|
node: process.versions.node,
|
|
83601
|
-
os: { platform:
|
|
84303
|
+
os: { platform: os5.platform(), release: os5.release(), arch: os5.arch() },
|
|
83602
84304
|
models: {
|
|
83603
84305
|
agent: env.HOTPATH_AGENT_MODEL,
|
|
83604
84306
|
replay: env.HOTPATH_CHEAP_MODEL,
|
|
@@ -83634,8 +84336,8 @@ async function buildReport(options) {
|
|
|
83634
84336
|
if (options.includeTraces) {
|
|
83635
84337
|
for (const task of tasks) {
|
|
83636
84338
|
for (const name of (recordings.get(task) ?? []).slice(-TRACES_PER_TASK)) {
|
|
83637
|
-
const text = await
|
|
83638
|
-
|
|
84339
|
+
const text = await readFile22(
|
|
84340
|
+
path30.join(dirs.tracesDir, task, name),
|
|
83639
84341
|
"utf8"
|
|
83640
84342
|
);
|
|
83641
84343
|
const lines = [];
|
|
@@ -83690,9 +84392,9 @@ function describeReport(files2, dir) {
|
|
|
83690
84392
|
}
|
|
83691
84393
|
async function writeReport(dir, files2) {
|
|
83692
84394
|
for (const [name, content] of files2) {
|
|
83693
|
-
const
|
|
83694
|
-
await
|
|
83695
|
-
await
|
|
84395
|
+
const file2 = path30.join(dir, name);
|
|
84396
|
+
await mkdir14(path30.dirname(file2), { recursive: true });
|
|
84397
|
+
await writeFile16(file2, content);
|
|
83696
84398
|
}
|
|
83697
84399
|
}
|
|
83698
84400
|
var TEMPLATE_RE2, SCHEMA_KEYS, TRACES_PER_TASK, MAX_TASKS_SHOWN;
|
|
@@ -84938,16 +85640,16 @@ var require_lib3 = __commonJS({
|
|
|
84938
85640
|
|
|
84939
85641
|
// src/wrap/json-file.ts
|
|
84940
85642
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
84941
|
-
import { readFile as
|
|
84942
|
-
import
|
|
84943
|
-
async function readJsonFile(
|
|
85643
|
+
import { readFile as readFile23, realpath as realpath2, rename as rename3, writeFile as writeFile17 } from "node:fs/promises";
|
|
85644
|
+
import path31 from "node:path";
|
|
85645
|
+
async function readJsonFile(file2) {
|
|
84944
85646
|
let real;
|
|
84945
85647
|
try {
|
|
84946
|
-
real = await realpath2(
|
|
85648
|
+
real = await realpath2(file2);
|
|
84947
85649
|
} catch {
|
|
84948
|
-
throw new Error(`config file not found: ${
|
|
85650
|
+
throw new Error(`config file not found: ${file2}`);
|
|
84949
85651
|
}
|
|
84950
|
-
const text = await
|
|
85652
|
+
const text = await readFile23(real, "utf8");
|
|
84951
85653
|
let data;
|
|
84952
85654
|
let strict = true;
|
|
84953
85655
|
try {
|
|
@@ -84974,17 +85676,17 @@ function stringifyLike(data, original) {
|
|
|
84974
85676
|
if (/\r?\n$/.test(original)) out += "\n";
|
|
84975
85677
|
return original.includes("\r\n") ? out.replace(/\r?\n/g, "\r\n") : out;
|
|
84976
85678
|
}
|
|
84977
|
-
async function writeFileAtomic(
|
|
84978
|
-
const tmp =
|
|
84979
|
-
|
|
84980
|
-
`.${
|
|
85679
|
+
async function writeFileAtomic(file2, content, mode) {
|
|
85680
|
+
const tmp = path31.join(
|
|
85681
|
+
path31.dirname(file2),
|
|
85682
|
+
`.${path31.basename(file2)}.${randomBytes2(4).toString("hex")}.tmp`
|
|
84981
85683
|
);
|
|
84982
|
-
await
|
|
85684
|
+
await writeFile17(
|
|
84983
85685
|
tmp,
|
|
84984
85686
|
content,
|
|
84985
85687
|
mode === void 0 ? "utf8" : { encoding: "utf8", mode }
|
|
84986
85688
|
);
|
|
84987
|
-
await rename3(tmp,
|
|
85689
|
+
await rename3(tmp, file2);
|
|
84988
85690
|
}
|
|
84989
85691
|
var import_json5;
|
|
84990
85692
|
var init_json_file = __esm({
|
|
@@ -84996,8 +85698,8 @@ var init_json_file = __esm({
|
|
|
84996
85698
|
|
|
84997
85699
|
// src/wrap/agents.ts
|
|
84998
85700
|
import { isDeepStrictEqual as isDeepStrictEqual5 } from "node:util";
|
|
84999
|
-
import
|
|
85000
|
-
import
|
|
85701
|
+
import os6 from "node:os";
|
|
85702
|
+
import path32 from "node:path";
|
|
85001
85703
|
function servers(data, ...keys) {
|
|
85002
85704
|
let node = data;
|
|
85003
85705
|
for (const key of keys) {
|
|
@@ -85012,14 +85714,14 @@ function entryOf(map, name) {
|
|
|
85012
85714
|
}
|
|
85013
85715
|
function openclawConfigPath(options) {
|
|
85014
85716
|
const env = options.env ?? process.env;
|
|
85015
|
-
if (options.config) return
|
|
85016
|
-
if (env.OPENCLAW_CONFIG_PATH) return
|
|
85017
|
-
return
|
|
85717
|
+
if (options.config) return path32.resolve(options.config);
|
|
85718
|
+
if (env.OPENCLAW_CONFIG_PATH) return path32.resolve(env.OPENCLAW_CONFIG_PATH);
|
|
85719
|
+
return path32.join(options.home ?? os6.homedir(), ".openclaw", "openclaw.json");
|
|
85018
85720
|
}
|
|
85019
85721
|
function spawnRunner(command) {
|
|
85020
85722
|
return (args, env) => new Promise((resolve2) => {
|
|
85021
85723
|
const [bin, ...pre] = command;
|
|
85022
|
-
const child2 = (0,
|
|
85724
|
+
const child2 = (0, import_cross_spawn7.default)(bin, [...pre, ...args], {
|
|
85023
85725
|
env: { ...process.env, ...env },
|
|
85024
85726
|
stdio: ["ignore", "pipe", "pipe"]
|
|
85025
85727
|
});
|
|
@@ -85077,12 +85779,12 @@ function projectKeys(cwd) {
|
|
|
85077
85779
|
return [.../* @__PURE__ */ new Set([cwd, cwd.replace(/\\/g, "/")])];
|
|
85078
85780
|
}
|
|
85079
85781
|
async function openClaudeCodeConfig(name, options) {
|
|
85080
|
-
const cwd =
|
|
85081
|
-
const userFile = options.config ?
|
|
85082
|
-
const projectFile =
|
|
85083
|
-
const tryRead = async (
|
|
85782
|
+
const cwd = path32.resolve(options.cwd ?? process.cwd());
|
|
85783
|
+
const userFile = options.config ? path32.resolve(options.config) : path32.join(options.home ?? os6.homedir(), ".claude.json");
|
|
85784
|
+
const projectFile = path32.join(cwd, ".mcp.json");
|
|
85785
|
+
const tryRead = async (file2) => {
|
|
85084
85786
|
try {
|
|
85085
|
-
return await readJsonFile(
|
|
85787
|
+
return await readJsonFile(file2);
|
|
85086
85788
|
} catch (err) {
|
|
85087
85789
|
if (err instanceof Error && err.message.startsWith("config file not found"))
|
|
85088
85790
|
return void 0;
|
|
@@ -85150,56 +85852,56 @@ async function writeServer(original, keys, name, entry) {
|
|
|
85150
85852
|
}
|
|
85151
85853
|
function claudeDesktopConfigPath(options) {
|
|
85152
85854
|
const env = options.env ?? process.env;
|
|
85153
|
-
const home = options.home ??
|
|
85855
|
+
const home = options.home ?? os6.homedir();
|
|
85154
85856
|
const platform = options.platform ?? process.platform;
|
|
85155
|
-
const
|
|
85857
|
+
const file2 = "claude_desktop_config.json";
|
|
85156
85858
|
if (platform === "win32") {
|
|
85157
|
-
return
|
|
85158
|
-
env.APPDATA ??
|
|
85859
|
+
return path32.join(
|
|
85860
|
+
env.APPDATA ?? path32.join(home, "AppData", "Roaming"),
|
|
85159
85861
|
"Claude",
|
|
85160
|
-
|
|
85862
|
+
file2
|
|
85161
85863
|
);
|
|
85162
85864
|
}
|
|
85163
85865
|
if (platform === "darwin") {
|
|
85164
|
-
return
|
|
85866
|
+
return path32.join(home, "Library", "Application Support", "Claude", file2);
|
|
85165
85867
|
}
|
|
85166
|
-
return
|
|
85167
|
-
env.XDG_CONFIG_HOME ??
|
|
85868
|
+
return path32.join(
|
|
85869
|
+
env.XDG_CONFIG_HOME ?? path32.join(home, ".config"),
|
|
85168
85870
|
"Claude",
|
|
85169
|
-
|
|
85871
|
+
file2
|
|
85170
85872
|
);
|
|
85171
85873
|
}
|
|
85172
85874
|
function placesFor(agent, options) {
|
|
85173
85875
|
const env = options.env ?? process.env;
|
|
85174
|
-
const home = options.home ??
|
|
85175
|
-
const cwd =
|
|
85876
|
+
const home = options.home ?? os6.homedir();
|
|
85877
|
+
const cwd = path32.resolve(options.cwd ?? process.cwd());
|
|
85176
85878
|
const mcp = ["mcpServers"];
|
|
85177
85879
|
if (agent === "cursor") {
|
|
85178
85880
|
return [
|
|
85179
85881
|
{
|
|
85180
85882
|
scope: "project",
|
|
85181
|
-
file:
|
|
85883
|
+
file: path32.join(cwd, ".cursor", "mcp.json"),
|
|
85182
85884
|
keys: mcp
|
|
85183
85885
|
},
|
|
85184
85886
|
{
|
|
85185
85887
|
scope: "user",
|
|
85186
|
-
file:
|
|
85888
|
+
file: path32.join(home, ".cursor", "mcp.json"),
|
|
85187
85889
|
keys: mcp
|
|
85188
85890
|
}
|
|
85189
85891
|
];
|
|
85190
85892
|
}
|
|
85191
85893
|
if (agent === "vscode") {
|
|
85192
|
-
const copilotHome = env.COPILOT_HOME ??
|
|
85894
|
+
const copilotHome = env.COPILOT_HOME ?? path32.join(home, ".copilot");
|
|
85193
85895
|
return [
|
|
85194
|
-
{ scope: "project", file:
|
|
85896
|
+
{ scope: "project", file: path32.join(cwd, ".mcp.json"), keys: mcp },
|
|
85195
85897
|
{
|
|
85196
85898
|
scope: "project",
|
|
85197
|
-
file:
|
|
85899
|
+
file: path32.join(cwd, ".vscode", "mcp.json"),
|
|
85198
85900
|
keys: ["servers"]
|
|
85199
85901
|
},
|
|
85200
85902
|
{
|
|
85201
85903
|
scope: "user",
|
|
85202
|
-
file:
|
|
85904
|
+
file: path32.join(copilotHome, "mcp-config.json"),
|
|
85203
85905
|
keys: mcp
|
|
85204
85906
|
}
|
|
85205
85907
|
];
|
|
@@ -85214,13 +85916,13 @@ async function openServersFileConfig(agent, name, options) {
|
|
|
85214
85916
|
}
|
|
85215
85917
|
let places;
|
|
85216
85918
|
if (options.config) {
|
|
85217
|
-
const
|
|
85218
|
-
const json = await readJsonFile(
|
|
85919
|
+
const file2 = path32.resolve(options.config);
|
|
85920
|
+
const json = await readJsonFile(file2);
|
|
85219
85921
|
const legacy = !servers(json.data, "mcpServers") && servers(json.data, "servers");
|
|
85220
85922
|
places = [
|
|
85221
85923
|
{
|
|
85222
85924
|
scope: options.scope ?? "user",
|
|
85223
|
-
file,
|
|
85925
|
+
file: file2,
|
|
85224
85926
|
keys: legacy ? ["servers"] : ["mcpServers"]
|
|
85225
85927
|
}
|
|
85226
85928
|
];
|
|
@@ -85255,7 +85957,7 @@ async function openServersFileConfig(agent, name, options) {
|
|
|
85255
85957
|
agent,
|
|
85256
85958
|
file: chosen.json.file,
|
|
85257
85959
|
scope: chosen.place.scope,
|
|
85258
|
-
cwd:
|
|
85960
|
+
cwd: path32.resolve(options.cwd ?? process.cwd()),
|
|
85259
85961
|
names: () => [
|
|
85260
85962
|
...new Set(found.flatMap((f3) => Object.keys(mapOf(f3) ?? {})))
|
|
85261
85963
|
],
|
|
@@ -85272,11 +85974,11 @@ async function openAgentConfig(agent, server2, options) {
|
|
|
85272
85974
|
}
|
|
85273
85975
|
throw unknownAgent(agent);
|
|
85274
85976
|
}
|
|
85275
|
-
var
|
|
85977
|
+
var import_cross_spawn7, RELOAD;
|
|
85276
85978
|
var init_agents2 = __esm({
|
|
85277
85979
|
"src/wrap/agents.ts"() {
|
|
85278
85980
|
"use strict";
|
|
85279
|
-
|
|
85981
|
+
import_cross_spawn7 = __toESM(require_cross_spawn(), 1);
|
|
85280
85982
|
init_entry();
|
|
85281
85983
|
init_json_file();
|
|
85282
85984
|
RELOAD = {
|
|
@@ -85329,11 +86031,11 @@ var init_env_file = __esm({
|
|
|
85329
86031
|
});
|
|
85330
86032
|
|
|
85331
86033
|
// src/setup/doctor.ts
|
|
85332
|
-
import { readdir as
|
|
85333
|
-
import
|
|
85334
|
-
async function exists3(
|
|
86034
|
+
import { readdir as readdir10, readFile as readFile24 } from "node:fs/promises";
|
|
86035
|
+
import path33 from "node:path";
|
|
86036
|
+
async function exists3(file2) {
|
|
85335
86037
|
try {
|
|
85336
|
-
await
|
|
86038
|
+
await readFile24(file2);
|
|
85337
86039
|
return true;
|
|
85338
86040
|
} catch {
|
|
85339
86041
|
return false;
|
|
@@ -85341,7 +86043,7 @@ async function exists3(file) {
|
|
|
85341
86043
|
}
|
|
85342
86044
|
async function count(dir, filter) {
|
|
85343
86045
|
try {
|
|
85344
|
-
return (await
|
|
86046
|
+
return (await readdir10(dir)).filter(filter);
|
|
85345
86047
|
} catch {
|
|
85346
86048
|
return [];
|
|
85347
86049
|
}
|
|
@@ -85365,7 +86067,7 @@ async function runDoctor(options) {
|
|
|
85365
86067
|
}
|
|
85366
86068
|
);
|
|
85367
86069
|
const hasEnvFile = await exists3(options.envFile);
|
|
85368
|
-
const fileEnv = hasEnvFile ? parseEnv(await
|
|
86070
|
+
const fileEnv = hasEnvFile ? parseEnv(await readFile24(options.envFile, "utf8")) : {};
|
|
85369
86071
|
const key = env.LLM_API_KEY ?? env.MOONSHOT_API_KEY ?? fileEnv.LLM_API_KEY;
|
|
85370
86072
|
const baseUrl = env.LLM_BASE_URL ?? fileEnv.LLM_BASE_URL;
|
|
85371
86073
|
const cheap = env.HOTPATH_CHEAP_MODEL ?? fileEnv.HOTPATH_CHEAP_MODEL;
|
|
@@ -85472,13 +86174,13 @@ async function runDoctor(options) {
|
|
|
85472
86174
|
checks.push({
|
|
85473
86175
|
name: "Your tasks",
|
|
85474
86176
|
status: "ok",
|
|
85475
|
-
detail: `${traces.length} recorded \xB7 ${workflows.length} compiled${workflows.length ? ` (${workflows.map((w3) =>
|
|
86177
|
+
detail: `${traces.length} recorded \xB7 ${workflows.length} compiled${workflows.length ? ` (${workflows.map((w3) => path33.basename(w3, ".json")).slice(0, 5).join(", ")})` : ""}`
|
|
85476
86178
|
});
|
|
85477
86179
|
const firstProblem = checks.find((c2) => c2.status === "fail");
|
|
85478
86180
|
let next;
|
|
85479
86181
|
if (firstProblem) next = firstProblem.fix ?? `fix: ${firstProblem.name}`;
|
|
85480
86182
|
else if (workflows.length > 0)
|
|
85481
|
-
next = `hotpath run ${
|
|
86183
|
+
next = `hotpath run ${path33.basename(workflows[0], ".json")} --dry-run`;
|
|
85482
86184
|
else if (traces.length > 0) next = `hotpath compile ${traces[0]}`;
|
|
85483
86185
|
else if (wrappedTotal > 0)
|
|
85484
86186
|
next = "do the task once in your agent, then: hotpath compile <task>";
|
|
@@ -85567,10 +86269,10 @@ var init_presets = __esm({
|
|
|
85567
86269
|
});
|
|
85568
86270
|
|
|
85569
86271
|
// src/setup/init.ts
|
|
85570
|
-
import { chmod, readFile as
|
|
85571
|
-
async function readOrEmpty(
|
|
86272
|
+
import { chmod as chmod2, readFile as readFile25, writeFile as writeFile18 } from "node:fs/promises";
|
|
86273
|
+
async function readOrEmpty(file2) {
|
|
85572
86274
|
try {
|
|
85573
|
-
return await
|
|
86275
|
+
return await readFile25(file2, "utf8");
|
|
85574
86276
|
} catch {
|
|
85575
86277
|
return null;
|
|
85576
86278
|
}
|
|
@@ -85661,13 +86363,13 @@ async function runInit(options) {
|
|
|
85661
86363
|
if (answer !== "y" && answer !== "yes") throw refuse();
|
|
85662
86364
|
}
|
|
85663
86365
|
backupFile = `${options.envFile}.backup-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace("T", "-").slice(0, 15)}`;
|
|
85664
|
-
await
|
|
85665
|
-
await
|
|
86366
|
+
await writeFile18(backupFile, existingText, { mode: 384 });
|
|
86367
|
+
await chmod2(backupFile, 384).catch(() => void 0);
|
|
85666
86368
|
}
|
|
85667
|
-
await
|
|
86369
|
+
await writeFile18(options.envFile, setEnv(existingText ?? "", values), {
|
|
85668
86370
|
mode: 384
|
|
85669
86371
|
});
|
|
85670
|
-
await
|
|
86372
|
+
await chmod2(options.envFile, 384).catch(() => void 0);
|
|
85671
86373
|
log("");
|
|
85672
86374
|
log(
|
|
85673
86375
|
`${existingText === null ? "Created" : "Updated"} ${options.envFile} (${preset.id}: ${baseUrl}).`
|
|
@@ -85719,11 +86421,11 @@ var init_init = __esm({
|
|
|
85719
86421
|
});
|
|
85720
86422
|
|
|
85721
86423
|
// src/wrap/wrap.ts
|
|
85722
|
-
import { mkdir as
|
|
85723
|
-
import
|
|
86424
|
+
import { mkdir as mkdir15, readFile as readFile26, rm as rm6 } from "node:fs/promises";
|
|
86425
|
+
import path34 from "node:path";
|
|
85724
86426
|
function backupPath(stateDir2, agent, server2) {
|
|
85725
86427
|
const safe = server2.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
85726
|
-
return
|
|
86428
|
+
return path34.join(stateDir2, "wrap-backups", `${agent}-${safe}.json`);
|
|
85727
86429
|
}
|
|
85728
86430
|
async function wrap(options) {
|
|
85729
86431
|
checkTaskName(options.task);
|
|
@@ -85741,7 +86443,7 @@ async function wrap(options) {
|
|
|
85741
86443
|
};
|
|
85742
86444
|
}
|
|
85743
86445
|
const backupFile = backupPath(options.stateDir, config2.agent, options.server);
|
|
85744
|
-
await
|
|
86446
|
+
await mkdir15(path34.dirname(backupFile), { recursive: true });
|
|
85745
86447
|
const backup = {
|
|
85746
86448
|
version: 1,
|
|
85747
86449
|
agent: config2.agent,
|
|
@@ -85776,7 +86478,7 @@ async function unwrap(options) {
|
|
|
85776
86478
|
);
|
|
85777
86479
|
let backup;
|
|
85778
86480
|
try {
|
|
85779
|
-
backup = JSON.parse(await
|
|
86481
|
+
backup = JSON.parse(await readFile26(backupFile, "utf8"));
|
|
85780
86482
|
} catch {
|
|
85781
86483
|
throw new WrapError(
|
|
85782
86484
|
`no wrap backup for ${options.agent} server "${options.server}" (looked for ${backupFile}); it was never wrapped from this Hotpath folder`
|
|
@@ -85811,7 +86513,7 @@ async function unwrap(options) {
|
|
|
85811
86513
|
};
|
|
85812
86514
|
}
|
|
85813
86515
|
await config2.set(options.server, backup.entry);
|
|
85814
|
-
await
|
|
86516
|
+
await rm6(backupFile);
|
|
85815
86517
|
return {
|
|
85816
86518
|
file: config2.file,
|
|
85817
86519
|
diff,
|
|
@@ -85833,9 +86535,9 @@ var program_exports = {};
|
|
|
85833
86535
|
__export(program_exports, {
|
|
85834
86536
|
createProgram: () => createProgram
|
|
85835
86537
|
});
|
|
85836
|
-
import { mkdir as
|
|
85837
|
-
import
|
|
85838
|
-
import
|
|
86538
|
+
import { mkdir as mkdir16, readFile as readFile27 } from "node:fs/promises";
|
|
86539
|
+
import os7 from "node:os";
|
|
86540
|
+
import path35 from "node:path";
|
|
85839
86541
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
85840
86542
|
function passthroughArgs() {
|
|
85841
86543
|
const dash = process.argv.indexOf("--");
|
|
@@ -85849,16 +86551,43 @@ function collectInputs(value, previous) {
|
|
|
85849
86551
|
previous[value.slice(0, eq)] = value.slice(eq + 1);
|
|
85850
86552
|
return previous;
|
|
85851
86553
|
}
|
|
85852
|
-
function createProgram() {
|
|
86554
|
+
function createProgram(options = {}) {
|
|
86555
|
+
const account = {
|
|
86556
|
+
...defaultAccountDeps(package_default.version),
|
|
86557
|
+
// a caller that picks its own sign-in folder (tests) never moves the
|
|
86558
|
+
// user's real one
|
|
86559
|
+
...options.account?.dir ? { legacyDir: void 0 } : {},
|
|
86560
|
+
...options.account
|
|
86561
|
+
};
|
|
86562
|
+
const syncCtx = {
|
|
86563
|
+
stateDir,
|
|
86564
|
+
workflowsDir,
|
|
86565
|
+
env: account.env,
|
|
86566
|
+
startFlush: detachedFlush(selfCommand(), account.env),
|
|
86567
|
+
...options.sync
|
|
86568
|
+
};
|
|
86569
|
+
const afterCommand = (runs) => syncAfterCommand(syncCtx, runs);
|
|
85853
86570
|
const program2 = new Command();
|
|
85854
86571
|
program2.name("hotpath").description("JIT compiler for AI agent tasks").version(package_default.version, "-V, --version", "print the version").option(
|
|
85855
86572
|
"--home <dir>",
|
|
85856
86573
|
"project folder (traces, workflows, .env); must come first. Default: HOTPATH_HOME, else the folder you are in"
|
|
85857
86574
|
);
|
|
86575
|
+
addLoginGate(program2, account);
|
|
86576
|
+
addAccountCommands(program2, account);
|
|
86577
|
+
program2.command("sync-flush", { hidden: true }).description("(internal) send the queued run summaries").action(
|
|
86578
|
+
() => runFlush({
|
|
86579
|
+
stateDir: syncCtx.stateDir,
|
|
86580
|
+
dir: account.dir,
|
|
86581
|
+
env: account.env,
|
|
86582
|
+
fetch: account.fetch,
|
|
86583
|
+
client: `hotpath-cli/${package_default.version}`
|
|
86584
|
+
})
|
|
86585
|
+
);
|
|
85858
86586
|
program2.addHelpText(
|
|
85859
86587
|
"after",
|
|
85860
86588
|
`
|
|
85861
86589
|
First steps:
|
|
86590
|
+
0. hotpath login sign in (free account; opens your browser)
|
|
85862
86591
|
1. hotpath init pick a model provider, write .env
|
|
85863
86592
|
2. hotpath doctor check it works; lists your agents
|
|
85864
86593
|
(hotpath demo try it on the bundled demo agent first)
|
|
@@ -85877,14 +86606,14 @@ First steps:
|
|
|
85877
86606
|
"--force",
|
|
85878
86607
|
"replace a key that .env already has for another endpoint (a copy is kept)"
|
|
85879
86608
|
).action(
|
|
85880
|
-
async (
|
|
86609
|
+
async (options2) => {
|
|
85881
86610
|
try {
|
|
85882
86611
|
await runInit({
|
|
85883
|
-
...
|
|
85884
|
-
envFile:
|
|
86612
|
+
...options2,
|
|
86613
|
+
envFile: path35.join(repoRoot5, ".env"),
|
|
85885
86614
|
ask: terminalAsk()
|
|
85886
86615
|
});
|
|
85887
|
-
await
|
|
86616
|
+
await mkdir16(stateDir, { recursive: true });
|
|
85888
86617
|
} catch (err) {
|
|
85889
86618
|
if (!(err instanceof InitError)) throw err;
|
|
85890
86619
|
console.error(`hotpath init: ${err.message}`);
|
|
@@ -85894,19 +86623,19 @@ First steps:
|
|
|
85894
86623
|
);
|
|
85895
86624
|
program2.command("doctor").description(
|
|
85896
86625
|
"Check the setup: Node, settings, model provider, agents, tasks"
|
|
85897
|
-
).option("--offline", "don't contact the model provider").action(async (
|
|
86626
|
+
).option("--offline", "don't contact the model provider").action(async (options2) => {
|
|
85898
86627
|
const result = await runDoctor({
|
|
85899
|
-
envFile:
|
|
86628
|
+
envFile: path35.join(repoRoot5, ".env"),
|
|
85900
86629
|
workflowsDir,
|
|
85901
86630
|
tracesDir,
|
|
85902
86631
|
env: process.env,
|
|
85903
|
-
offline:
|
|
86632
|
+
offline: options2.offline,
|
|
85904
86633
|
listModels
|
|
85905
86634
|
});
|
|
85906
86635
|
console.log(formatDoctor(result));
|
|
85907
86636
|
if (result.checks.some((c2) => c2.status === "fail")) process.exitCode = 1;
|
|
85908
86637
|
});
|
|
85909
|
-
program2.command("record").description("Record an agent run through an MCP proxy").requiredOption("--task <name>", "task name").allowExcessArguments(true).action(async (
|
|
86638
|
+
program2.command("record").description("Record an agent run through an MCP proxy").requiredOption("--task <name>", "task name").allowExcessArguments(true).action(async (options2) => {
|
|
85910
86639
|
const serverArgv = passthroughArgs();
|
|
85911
86640
|
if (serverArgv.length === 0) {
|
|
85912
86641
|
console.error(
|
|
@@ -85914,7 +86643,7 @@ First steps:
|
|
|
85914
86643
|
);
|
|
85915
86644
|
process.exit(1);
|
|
85916
86645
|
}
|
|
85917
|
-
await runRecorder({ task:
|
|
86646
|
+
await runRecorder({ task: options2.task, serverArgv });
|
|
85918
86647
|
});
|
|
85919
86648
|
program2.command("compile").description("Compile a trace into a workflow").argument("<task>", "task name").option("--trace <file>", "trace file (default: latest trace for the task)").option(
|
|
85920
86649
|
"--require <path...>",
|
|
@@ -85923,9 +86652,9 @@ First steps:
|
|
|
85923
86652
|
"--strict",
|
|
85924
86653
|
"refuse a recording that has a warning: write nothing and exit 1 (then record the task again)"
|
|
85925
86654
|
).action(
|
|
85926
|
-
(task,
|
|
85927
|
-
const compiled = await compileTaskInMemory(task,
|
|
85928
|
-
require:
|
|
86655
|
+
(task, options2) => guarded(async () => {
|
|
86656
|
+
const compiled = await compileTaskInMemory(task, options2.trace, {
|
|
86657
|
+
require: options2.require
|
|
85929
86658
|
});
|
|
85930
86659
|
const { workflow, notes } = compiled;
|
|
85931
86660
|
const replayed = await verifyOnRecording(
|
|
@@ -85936,7 +86665,7 @@ First steps:
|
|
|
85936
86665
|
...compiled.warnings,
|
|
85937
86666
|
...replayed.map((p3) => `replayed on the recorded data: ${p3}`)
|
|
85938
86667
|
];
|
|
85939
|
-
if (
|
|
86668
|
+
if (options2.strict && warnings.length > 0) {
|
|
85940
86669
|
for (const warning of warnings) console.log(`\u26A0 ${warning}`);
|
|
85941
86670
|
throw new Error(
|
|
85942
86671
|
`not compiled (--strict): the recording has ${warnings.length} warning${warnings.length === 1 ? "" : "s"}; workflows/${task}.json is unchanged. Record the task again, or compile without --strict.`
|
|
@@ -85946,6 +86675,7 @@ First steps:
|
|
|
85946
86675
|
console.log(formatCompileResult(workflow));
|
|
85947
86676
|
for (const note of notes) console.log(`+ ${note}`);
|
|
85948
86677
|
for (const warning of warnings) console.log(`\u26A0 ${warning}`);
|
|
86678
|
+
await afterCommand();
|
|
85949
86679
|
})
|
|
85950
86680
|
);
|
|
85951
86681
|
program2.command("show").description("Show a workflow as a readable list of steps").argument("<task>", "task name").action(async (task) => {
|
|
@@ -85966,25 +86696,44 @@ First steps:
|
|
|
85966
86696
|
"--accept-recompile",
|
|
85967
86697
|
"after a fallback, replace the workflow even if the recompile lost read-only steps"
|
|
85968
86698
|
).action(
|
|
85969
|
-
async (task,
|
|
86699
|
+
async (task, options2) => {
|
|
86700
|
+
const startedAt = /* @__PURE__ */ new Date();
|
|
86701
|
+
let metrics;
|
|
86702
|
+
let ok = true;
|
|
85970
86703
|
try {
|
|
85971
|
-
await runTask(task, {
|
|
85972
|
-
inputs:
|
|
85973
|
-
dryRun:
|
|
85974
|
-
noFallback: !
|
|
85975
|
-
acceptRecompile:
|
|
86704
|
+
metrics = await runTask(task, {
|
|
86705
|
+
inputs: options2.input,
|
|
86706
|
+
dryRun: options2.dryRun,
|
|
86707
|
+
noFallback: !options2.fallback,
|
|
86708
|
+
acceptRecompile: options2.acceptRecompile
|
|
85976
86709
|
});
|
|
85977
86710
|
} catch (err) {
|
|
86711
|
+
ok = false;
|
|
86712
|
+
if (err instanceof DriftError) metrics = err.metrics;
|
|
85978
86713
|
console.error(err instanceof Error ? err.message : String(err));
|
|
85979
|
-
process.exit(1);
|
|
85980
86714
|
}
|
|
86715
|
+
if (metrics) {
|
|
86716
|
+
const baseline = await loadWorkflow(task).then((w3) => w3.baseline).catch(() => void 0);
|
|
86717
|
+
await afterCommand([
|
|
86718
|
+
summarizeRun({
|
|
86719
|
+
workflow: task,
|
|
86720
|
+
kind: "replay",
|
|
86721
|
+
ok,
|
|
86722
|
+
dryRun: options2.dryRun,
|
|
86723
|
+
metrics,
|
|
86724
|
+
baseline,
|
|
86725
|
+
startedAt
|
|
86726
|
+
})
|
|
86727
|
+
]);
|
|
86728
|
+
}
|
|
86729
|
+
if (!ok) process.exit(1);
|
|
85981
86730
|
}
|
|
85982
86731
|
);
|
|
85983
|
-
program2.command("view").description("Open the workflow graph viewer").argument("<task>", "task name").option("--port <port>", "port for the local viewer server", "5173").option("--no-open", "don't open the browser").action(async (task,
|
|
86732
|
+
program2.command("view").description("Open the workflow graph viewer").argument("<task>", "task name").option("--port <port>", "port for the local viewer server", "5173").option("--no-open", "don't open the browser").action(async (task, options2) => {
|
|
85984
86733
|
try {
|
|
85985
86734
|
const viewer = await startViewer(task, {
|
|
85986
|
-
port: Number(
|
|
85987
|
-
open:
|
|
86735
|
+
port: Number(options2.port),
|
|
86736
|
+
open: options2.open
|
|
85988
86737
|
});
|
|
85989
86738
|
console.log(`viewer for "${task}": ${viewer.url} (Ctrl+C to stop)`);
|
|
85990
86739
|
} catch (err) {
|
|
@@ -86001,10 +86750,10 @@ First steps:
|
|
|
86001
86750
|
"local (claude-code only), project or user",
|
|
86002
86751
|
parseScope
|
|
86003
86752
|
).action(
|
|
86004
|
-
async (agent, server2,
|
|
86753
|
+
async (agent, server2, options2) => {
|
|
86005
86754
|
await reportWrap(
|
|
86006
|
-
() => wrap({ agent, server: server2, ...
|
|
86007
|
-
|
|
86755
|
+
() => wrap({ agent, server: server2, ...options2, stateDir, self: selfCommand() }),
|
|
86756
|
+
options2.dryRun ? "dry run, nothing written" : `wrapped "${server2}": ${agent} now records task "${options2.task}"
|
|
86008
86757
|
undo with: hotpath unwrap ${agent} ${server2}`
|
|
86009
86758
|
);
|
|
86010
86759
|
}
|
|
@@ -86016,27 +86765,27 @@ undo with: hotpath unwrap ${agent} ${server2}`
|
|
|
86016
86765
|
"--config <path>",
|
|
86017
86766
|
"agent config file (default: the one wrap edited)"
|
|
86018
86767
|
).action(
|
|
86019
|
-
async (agent, server2,
|
|
86768
|
+
async (agent, server2, options2) => {
|
|
86020
86769
|
await reportWrap(
|
|
86021
|
-
() => unwrap({ agent, server: server2, ...
|
|
86022
|
-
|
|
86770
|
+
() => unwrap({ agent, server: server2, ...options2, stateDir }),
|
|
86771
|
+
options2.dryRun ? "dry run, nothing written" : `restored "${server2}" in the ${agent} config`
|
|
86023
86772
|
);
|
|
86024
86773
|
}
|
|
86025
86774
|
);
|
|
86026
86775
|
program2.command("forget").description(
|
|
86027
86776
|
"Delete everything stored for a task: recordings, workflow, saved answers, schedules, history"
|
|
86028
86777
|
).argument("<task>", "task name").option("--dry-run", "list what would be deleted, delete nothing").option("--yes", "don't ask for confirmation").action(
|
|
86029
|
-
(task,
|
|
86778
|
+
(task, options2) => guarded(async () => {
|
|
86030
86779
|
const dirs = {
|
|
86031
86780
|
tracesDir,
|
|
86032
86781
|
workflowsDir,
|
|
86033
86782
|
stateDir: defaultStateDir,
|
|
86034
|
-
outDir:
|
|
86783
|
+
outDir: path35.join(repoRoot5, "out")
|
|
86035
86784
|
};
|
|
86036
86785
|
const items = await planForget(task, dirs);
|
|
86037
86786
|
console.log(describeForget(task, items));
|
|
86038
|
-
if (items.length === 0 ||
|
|
86039
|
-
if (!
|
|
86787
|
+
if (items.length === 0 || options2.dryRun) return;
|
|
86788
|
+
if (!options2.yes && !await confirm("\ndelete? [y/N] ")) {
|
|
86040
86789
|
console.log("nothing changed");
|
|
86041
86790
|
return;
|
|
86042
86791
|
}
|
|
@@ -86050,16 +86799,16 @@ undo with: hotpath unwrap ${agent} ${server2}`
|
|
|
86050
86799
|
"--include-traces",
|
|
86051
86800
|
"add the recordings, with every text and number replaced by its type"
|
|
86052
86801
|
).option("--out <dir>", "where to write it (default: hotpath-report-<date>)").option("--yes", "don't ask before writing").action(
|
|
86053
|
-
(
|
|
86802
|
+
(options2) => guarded(async () => {
|
|
86054
86803
|
const now = /* @__PURE__ */ new Date();
|
|
86055
|
-
const dir =
|
|
86056
|
-
|
|
86804
|
+
const dir = path35.resolve(
|
|
86805
|
+
options2.out ?? path35.join(
|
|
86057
86806
|
repoRoot5,
|
|
86058
86807
|
`hotpath-report-${now.toISOString().slice(0, 10)}`
|
|
86059
86808
|
)
|
|
86060
86809
|
);
|
|
86061
86810
|
const doctor = await runDoctor({
|
|
86062
|
-
envFile:
|
|
86811
|
+
envFile: path35.join(repoRoot5, ".env"),
|
|
86063
86812
|
workflowsDir,
|
|
86064
86813
|
tracesDir,
|
|
86065
86814
|
env: process.env,
|
|
@@ -86070,19 +86819,19 @@ undo with: hotpath unwrap ${agent} ${server2}`
|
|
|
86070
86819
|
tracesDir,
|
|
86071
86820
|
workflowsDir,
|
|
86072
86821
|
stateDir: defaultStateDir,
|
|
86073
|
-
outDir:
|
|
86822
|
+
outDir: path35.join(repoRoot5, "out")
|
|
86074
86823
|
},
|
|
86075
|
-
task:
|
|
86076
|
-
includeTraces:
|
|
86824
|
+
task: options2.task,
|
|
86825
|
+
includeTraces: options2.includeTraces,
|
|
86077
86826
|
version: package_default.version,
|
|
86078
86827
|
env: process.env,
|
|
86079
86828
|
doctor,
|
|
86080
86829
|
now,
|
|
86081
86830
|
project: repoRoot5,
|
|
86082
|
-
home:
|
|
86831
|
+
home: os7.homedir()
|
|
86083
86832
|
});
|
|
86084
86833
|
console.log(describeReport(files2, dir));
|
|
86085
|
-
if (!
|
|
86834
|
+
if (!options2.yes && !await confirm("\nwrite it? [y/N] ")) {
|
|
86086
86835
|
console.log("nothing written");
|
|
86087
86836
|
return;
|
|
86088
86837
|
}
|
|
@@ -86094,9 +86843,9 @@ undo with: hotpath unwrap ${agent} ${server2}`
|
|
|
86094
86843
|
);
|
|
86095
86844
|
addScheduleCommands(program2);
|
|
86096
86845
|
addDaemonCommands(program2);
|
|
86097
|
-
addLearnCommand(program2);
|
|
86846
|
+
addLearnCommand(program2, afterCommand);
|
|
86098
86847
|
addScanCommand(program2);
|
|
86099
|
-
addDemoCommand(program2);
|
|
86848
|
+
addDemoCommand(program2, afterCommand);
|
|
86100
86849
|
return program2;
|
|
86101
86850
|
}
|
|
86102
86851
|
async function guarded(fn) {
|
|
@@ -86270,7 +87019,7 @@ function addDaemonCommands(program2) {
|
|
|
86270
87019
|
return planInstall(platform, {
|
|
86271
87020
|
argv: [...selfCommand(), "daemon"],
|
|
86272
87021
|
projectDir: repoRoot5,
|
|
86273
|
-
home:
|
|
87022
|
+
home: os7.homedir(),
|
|
86274
87023
|
uid: process.getuid?.()
|
|
86275
87024
|
});
|
|
86276
87025
|
};
|
|
@@ -86302,7 +87051,7 @@ ${action}? [y/N] `)) {
|
|
|
86302
87051
|
let pid = 0;
|
|
86303
87052
|
try {
|
|
86304
87053
|
pid = Number(
|
|
86305
|
-
(await
|
|
87054
|
+
(await readFile27(statePaths(defaultStateDir).lock, "utf8")).trim()
|
|
86306
87055
|
);
|
|
86307
87056
|
} catch {
|
|
86308
87057
|
pid = 0;
|
|
@@ -86373,17 +87122,21 @@ var init_program = __esm({
|
|
|
86373
87122
|
init_src5();
|
|
86374
87123
|
init_src6();
|
|
86375
87124
|
init_package();
|
|
87125
|
+
init_commands();
|
|
86376
87126
|
init_forget();
|
|
86377
87127
|
init_demo();
|
|
86378
87128
|
init_learn2();
|
|
86379
87129
|
init_scan2();
|
|
86380
87130
|
init_proxy();
|
|
87131
|
+
init_background();
|
|
87132
|
+
init_summary();
|
|
87133
|
+
init_src4();
|
|
86381
87134
|
init_report2();
|
|
86382
87135
|
init_doctor();
|
|
86383
87136
|
init_init();
|
|
86384
87137
|
init_self();
|
|
86385
87138
|
init_wrap();
|
|
86386
|
-
stateDir =
|
|
87139
|
+
stateDir = path35.join(repoRoot5, ".hotpath");
|
|
86387
87140
|
}
|
|
86388
87141
|
});
|
|
86389
87142
|
|