tarsk 0.6.88 → 0.6.89
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/README.md +63 -24
- package/dist/index.js +787 -738
- package/dist/node_modules/@libsql/darwin-x64/README.md +3 -0
- package/dist/node_modules/@libsql/{darwin-arm64 → darwin-x64}/index.node +0 -0
- package/dist/node_modules/@libsql/{darwin-arm64 → darwin-x64}/package.json +6 -6
- package/dist/public/assets/api-8Rp2LlXt.js +1 -0
- package/dist/public/assets/api-Cp9I7CxD.js +2 -0
- package/dist/public/assets/{async-error-boundary-FT8_xvjy.js → async-error-boundary-CFVUPiuG.js} +1 -1
- package/dist/public/assets/{browser-tab-DCjHytQ8.js → browser-tab-CPPorbL6.js} +2 -2
- package/dist/public/assets/{chat-dock-context-a2bV9cnz.js → chat-dock-context-DbiJNr3O.js} +1 -1
- package/dist/public/assets/chat-handlers-context-DYU2LQ5V.js +9 -0
- package/dist/public/assets/{commit-dialog-C1oUFznJ.js → commit-dialog-DPaci3dp.js} +1 -1
- package/dist/public/assets/{commit-error-dialog--NTHg7Aw.js → commit-error-dialog-Dnlkgb_H.js} +1 -1
- package/dist/public/assets/{conversation-history-view-CdfE7JTD.js → conversation-history-view-CqIugfyO.js} +1 -1
- package/dist/public/assets/{create-project-dialog-BdR6iQE9.js → create-project-dialog-DStWPoDE.js} +2 -2
- package/dist/public/assets/{create-project-workspace-DSTTGom_.js → create-project-workspace-CJ94yHAB.js} +2 -2
- package/dist/public/assets/{create-repo-dialog-gw-8Rpdm.js → create-repo-dialog-B_QiEz-v.js} +1 -1
- package/dist/public/assets/diff-view-4koPcOcE.js +4 -0
- package/dist/public/assets/{explorer-file-drop-CzyAqZgf.js → explorer-file-drop-DAP7ha-E.js} +1 -1
- package/dist/public/assets/explorer-tab-view-Bt9hRZUm.js +2 -0
- package/dist/public/assets/explorer-tree-CAs89lPz.js +1 -0
- package/dist/public/assets/{explorer-view-Daxl93oM.js → explorer-view-B1JuejkU.js} +2 -2
- package/dist/public/assets/index-CcAwxnT5.js +97 -0
- package/dist/public/assets/index-dNrgKdYv.css +1 -0
- package/dist/public/assets/{markdown-renderer-D2VcKU4g.js → markdown-renderer-DQONI6WG.js} +3 -3
- package/dist/public/assets/{mcp-manager-D1HmLT3t.js → mcp-manager-D2FG-h2e.js} +1 -1
- package/dist/public/assets/{model-list-controls-rXmaDp2r.js → model-list-controls-B6ofHWh3.js} +1 -1
- package/dist/public/assets/{onboarding-dialog-DSqBJyBa.js → onboarding-dialog-DAut3X4K.js} +1 -1
- package/dist/public/assets/{pill-tabs-DtdTmrg7.js → pill-tabs-BAhOHad7.js} +1 -1
- package/dist/public/assets/{project-coding-view-DP4qKePE.js → project-coding-view-B2FpHeiO.js} +1 -1
- package/dist/public/assets/{project-danger-zone-view-CGxIenpr.js → project-danger-zone-view-BqP1dcRT.js} +1 -1
- package/dist/public/assets/{project-env-vars-view-DKyQkh7h.js → project-env-vars-view-zhigkQFG.js} +1 -1
- package/dist/public/assets/{project-model-aliases-view-BewwJZAx.js → project-model-aliases-view-APAVFfym.js} +1 -1
- package/dist/public/assets/{project-settings-view-CE4nAz5B.js → project-settings-view-FnK-LRsv.js} +1 -1
- package/dist/public/assets/project-tools-view-Dmp5ViRC.js +1 -0
- package/dist/public/assets/providers-list-view-Clbp73Hh.js +1 -0
- package/dist/public/assets/{pull-request-dialog-nKYATjbm.js → pull-request-dialog-D40BQPMk.js} +1 -1
- package/dist/public/assets/{pull-with-changes-dialog-zzoFzCv4.js → pull-with-changes-dialog-pkXK-VP2.js} +1 -1
- package/dist/public/assets/query-keys-CcnonAAG.js +1 -0
- package/dist/public/assets/{remote-media-url-CyuN31H_.js → remote-media-url-C-GdJb-D.js} +1 -1
- package/dist/public/assets/{scroll-area-CGEZ1gAL.js → scroll-area-DGF9wUqQ.js} +1 -1
- package/dist/public/assets/{select-BR2pG61R.js → select-DMcNYwgt.js} +1 -1
- package/dist/public/assets/{settings-general-tabs-view-BWR0UX2P.js → settings-general-tabs-view-DBZQbihJ.js} +2 -2
- package/dist/public/assets/settings-general-view-0dhBET2R.js +1 -0
- package/dist/public/assets/{settings-list-Dgip9HpD.js → settings-list-Co3JPr9w.js} +1 -1
- package/dist/public/assets/{settings-logs-view-CS29x4VT.js → settings-logs-view-DvHXUDko.js} +2 -2
- package/dist/public/assets/settings-mcp-servers-view-414Dt5py.js +5 -0
- package/dist/public/assets/{settings-models-view-DS7nm54P.js → settings-models-view-ByeR7Enb.js} +1 -1
- package/dist/public/assets/{settings-plugins-view-avaUE36r.js → settings-plugins-view-8te2MPyh.js} +2 -2
- package/dist/public/assets/{settings-providers-view-B39k1iRQ.js → settings-providers-view-BAuv9gam.js} +2 -2
- package/dist/public/assets/{settings-remote-machines-view-BXondQG_.js → settings-remote-machines-view-CHyywazU.js} +1 -1
- package/dist/public/assets/{settings-setup-view-I5MGUi_D.js → settings-setup-view-Btp46Vh_.js} +2 -2
- package/dist/public/assets/{settings-skills-view-BKrUABbi.js → settings-skills-view-BNVx4bZl.js} +2 -2
- package/dist/public/assets/{settings-slack-view-B0p-96GC.js → settings-slack-view-Caly5yGt.js} +1 -1
- package/dist/public/assets/settings-slash-commands-view-m6mp1knu.js +1 -0
- package/dist/public/assets/{settings-statistics-view-B3g6BD7p.js → settings-statistics-view-BnOxr4sZ.js} +1 -1
- package/dist/public/assets/settings-storage-view-Dg8xfpTG.js +1 -0
- package/dist/public/assets/{settings-subagents-view-BziLwvNq.js → settings-subagents-view-CucwEk2A.js} +1 -1
- package/dist/public/assets/{settings-system-prompt-view-BqAk56cD.js → settings-system-prompt-view-CEDU2saT.js} +1 -1
- package/dist/public/assets/{settings-tab-bar-DYzU_lmi.js → settings-tab-bar-CdIbQ0WI.js} +1 -1
- package/dist/public/assets/settings-view-XcJhRclT.js +2 -0
- package/dist/public/assets/task-utils-Cnq9Eszt.js +1 -0
- package/dist/public/assets/tasks-view-B8_jkq_a.js +1 -0
- package/dist/public/assets/{terminal-panel-Bm_ZelN-.js → terminal-panel-xoLVfA-h.js} +1 -1
- package/dist/public/assets/{use-account-settings-query-C-zOdREq.js → use-account-settings-query-D_qL1I4w.js} +1 -1
- package/dist/public/assets/{use-active-dock-panel-instance-4Ss8lB9K.js → use-active-dock-panel-instance-kmJOnmL7.js} +1 -1
- package/dist/public/assets/use-git-check-BD9gdXpK.js +1 -0
- package/dist/public/assets/{use-installed-ai-files-DQey9Zm3.js → use-installed-ai-files-Nn-sN_V2.js} +1 -1
- package/dist/public/assets/{use-open-chat-dock-panel-DqfWJ8e8.js → use-open-chat-dock-panel-CXzpgxVs.js} +1 -1
- package/dist/public/assets/use-projects-B0xTjTaA.js +2 -0
- package/dist/public/assets/{web-CGP-jEpi.js → web-C1tBQoCB.js} +1 -1
- package/dist/public/assets/{web-CKC9gpFi.js → web-cJXG33sT.js} +1 -1
- package/dist/public/index.html +18 -18
- package/package.json +4 -4
- package/dist/node_modules/@libsql/darwin-arm64/README.md +0 -3
- package/dist/public/assets/account-view-DkuCOxkE.js +0 -1
- package/dist/public/assets/api-B_GSyYGh.js +0 -1
- package/dist/public/assets/api-C4ukGdyH.js +0 -2
- package/dist/public/assets/chat-handlers-context-2xSKzkKa.js +0 -9
- package/dist/public/assets/diff-view-B6JJNyn1.js +0 -4
- package/dist/public/assets/explorer-tab-view-CiUPh4uK.js +0 -2
- package/dist/public/assets/explorer-tree-BA12VLz_.js +0 -1
- package/dist/public/assets/index-CoY8DilQ.js +0 -97
- package/dist/public/assets/index-D14wLW4o.css +0 -1
- package/dist/public/assets/project-tools-view-CbDfst02.js +0 -1
- package/dist/public/assets/providers-list-view-BtwccvX2.js +0 -1
- package/dist/public/assets/query-keys-BwswkbMn.js +0 -1
- package/dist/public/assets/settings-general-view-BhtrDmJH.js +0 -1
- package/dist/public/assets/settings-mcp-servers-view-B5ithpfh.js +0 -5
- package/dist/public/assets/settings-slash-commands-view-DA1scWv1.js +0 -1
- package/dist/public/assets/settings-storage-view-BJvjhI4f.js +0 -1
- package/dist/public/assets/settings-view-zjMs7jNe.js +0 -2
- package/dist/public/assets/task-utils-BZPVmvY4.js +0 -1
- package/dist/public/assets/tasks-view-wFf77AQX.js +0 -1
- package/dist/public/assets/use-git-check-CumqGAvN.js +0 -1
- package/dist/public/assets/use-projects-CizIH2Fa.js +0 -2
package/dist/index.js
CHANGED
|
@@ -56226,7 +56226,7 @@ function formatContentLine(displayPath, match3, withFilename, lineNumber, maxCol
|
|
|
56226
56226
|
return "--";
|
|
56227
56227
|
}
|
|
56228
56228
|
const body = omitLongLine(match3.line, maxColumns);
|
|
56229
|
-
const
|
|
56229
|
+
const sep11 = match3.isContext ? "-" : ":";
|
|
56230
56230
|
const parts2 = [];
|
|
56231
56231
|
if (withFilename) {
|
|
56232
56232
|
parts2.push(displayPath);
|
|
@@ -56237,7 +56237,7 @@ function formatContentLine(displayPath, match3, withFilename, lineNumber, maxCol
|
|
|
56237
56237
|
if (parts2.length === 0) {
|
|
56238
56238
|
return body;
|
|
56239
56239
|
}
|
|
56240
|
-
return `${parts2.join(
|
|
56240
|
+
return `${parts2.join(sep11)}${sep11}${body}`;
|
|
56241
56241
|
}
|
|
56242
56242
|
function formatResults(results, parsed, cwd) {
|
|
56243
56243
|
const lines2 = [];
|
|
@@ -56847,14 +56847,14 @@ function relativizeCountLine(cwd, line) {
|
|
|
56847
56847
|
return line;
|
|
56848
56848
|
}
|
|
56849
56849
|
function toRipgrepSearchPath(absoluteSearchPath, cwd) {
|
|
56850
|
-
const
|
|
56851
|
-
if (!
|
|
56850
|
+
const relative18 = path3.relative(cwd, absoluteSearchPath);
|
|
56851
|
+
if (!relative18) {
|
|
56852
56852
|
return ".";
|
|
56853
56853
|
}
|
|
56854
|
-
if (
|
|
56854
|
+
if (relative18.startsWith("..") || path3.isAbsolute(relative18)) {
|
|
56855
56855
|
return absoluteSearchPath;
|
|
56856
56856
|
}
|
|
56857
|
-
return
|
|
56857
|
+
return relative18.replace(/\\/g, "/");
|
|
56858
56858
|
}
|
|
56859
56859
|
function formatRipgrepFailure(stderr, code) {
|
|
56860
56860
|
const trimmed = stderr.trim();
|
|
@@ -137797,7 +137797,7 @@ var require_gaxios = __commonJS({
|
|
|
137797
137797
|
var retry_js_1 = require_retry3();
|
|
137798
137798
|
var stream_1 = __require("stream");
|
|
137799
137799
|
var interceptor_js_1 = require_interceptor();
|
|
137800
|
-
var
|
|
137800
|
+
var randomUUID34 = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
137801
137801
|
var HTTP_STATUS_NO_CONTENT = 204;
|
|
137802
137802
|
var Gaxios = class {
|
|
137803
137803
|
agentCache = /* @__PURE__ */ new Map();
|
|
@@ -138070,7 +138070,7 @@ var require_gaxios = __commonJS({
|
|
|
138070
138070
|
*/
|
|
138071
138071
|
["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
138072
138072
|
if (opts.multipart?.length) {
|
|
138073
|
-
const boundary = await
|
|
138073
|
+
const boundary = await randomUUID34();
|
|
138074
138074
|
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
138075
138075
|
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
138076
138076
|
} else if (shouldDirectlyPassData) {
|
|
@@ -145234,9 +145234,9 @@ var require_filesubjecttokensupplier = __commonJS({
|
|
|
145234
145234
|
var fs25 = __require("fs");
|
|
145235
145235
|
var readFile32 = (0, util_1.promisify)(fs25.readFile ?? (() => {
|
|
145236
145236
|
}));
|
|
145237
|
-
var
|
|
145237
|
+
var realpath4 = (0, util_1.promisify)(fs25.realpath ?? (() => {
|
|
145238
145238
|
}));
|
|
145239
|
-
var
|
|
145239
|
+
var lstat4 = (0, util_1.promisify)(fs25.lstat ?? (() => {
|
|
145240
145240
|
}));
|
|
145241
145241
|
var FileSubjectTokenSupplier = class {
|
|
145242
145242
|
filePath;
|
|
@@ -145261,8 +145261,8 @@ var require_filesubjecttokensupplier = __commonJS({
|
|
|
145261
145261
|
async getSubjectToken() {
|
|
145262
145262
|
let parsedFilePath = this.filePath;
|
|
145263
145263
|
try {
|
|
145264
|
-
parsedFilePath = await
|
|
145265
|
-
if (!(await
|
|
145264
|
+
parsedFilePath = await realpath4(parsedFilePath);
|
|
145265
|
+
if (!(await lstat4(parsedFilePath)).isFile()) {
|
|
145266
145266
|
throw new Error();
|
|
145267
145267
|
}
|
|
145268
145268
|
} catch (err) {
|
|
@@ -161501,7 +161501,7 @@ function isPlainObject$1(value) {
|
|
|
161501
161501
|
return false;
|
|
161502
161502
|
}
|
|
161503
161503
|
}
|
|
161504
|
-
function formEncoder(
|
|
161504
|
+
function formEncoder(sep11) {
|
|
161505
161505
|
return (key, value, options2) => {
|
|
161506
161506
|
let out = "";
|
|
161507
161507
|
const pairs = (options2 === null || options2 === void 0 ? void 0 : options2.explode) ? explode(key, value) : [[key, value]];
|
|
@@ -161512,7 +161512,7 @@ function formEncoder(sep10) {
|
|
|
161512
161512
|
return (options2 === null || options2 === void 0 ? void 0 : options2.charEncoding) === "percent" ? encodeURIComponent(v3) : v3;
|
|
161513
161513
|
};
|
|
161514
161514
|
const encodeValue = (v3) => encodeString(serializeValue(v3));
|
|
161515
|
-
const encodedSep = encodeString(
|
|
161515
|
+
const encodedSep = encodeString(sep11);
|
|
161516
161516
|
pairs.forEach(([pk, pv]) => {
|
|
161517
161517
|
var _a17, _b2;
|
|
161518
161518
|
let tmp = "";
|
|
@@ -178837,13 +178837,13 @@ var init_package = __esm({
|
|
|
178837
178837
|
"package.json"() {
|
|
178838
178838
|
package_default = {
|
|
178839
178839
|
name: "tarsk",
|
|
178840
|
-
version: "0.6.
|
|
178841
|
-
description: "CLI for Tarsk
|
|
178840
|
+
version: "0.6.89",
|
|
178841
|
+
description: "CLI for Tarsk",
|
|
178842
178842
|
keywords: [
|
|
178843
178843
|
"cli",
|
|
178844
178844
|
"git",
|
|
178845
|
-
"
|
|
178846
|
-
"
|
|
178845
|
+
"coding",
|
|
178846
|
+
"agent"
|
|
178847
178847
|
],
|
|
178848
178848
|
license: "MIT",
|
|
178849
178849
|
author: "",
|
|
@@ -198867,49 +198867,49 @@ var require_fast_uri = __commonJS({
|
|
|
198867
198867
|
schemelessOptions.skipEscape = true;
|
|
198868
198868
|
return serialize2(resolved, schemelessOptions);
|
|
198869
198869
|
}
|
|
198870
|
-
function resolveComponent(base,
|
|
198870
|
+
function resolveComponent(base, relative18, options2, skipNormalization) {
|
|
198871
198871
|
const target = {};
|
|
198872
198872
|
if (!skipNormalization) {
|
|
198873
198873
|
base = parse4(serialize2(base, options2), options2);
|
|
198874
|
-
|
|
198874
|
+
relative18 = parse4(serialize2(relative18, options2), options2);
|
|
198875
198875
|
}
|
|
198876
198876
|
options2 = options2 || {};
|
|
198877
|
-
if (!options2.tolerant &&
|
|
198878
|
-
target.scheme =
|
|
198879
|
-
target.userinfo =
|
|
198880
|
-
target.host =
|
|
198881
|
-
target.port =
|
|
198882
|
-
target.path = removeDotSegments(
|
|
198883
|
-
target.query =
|
|
198877
|
+
if (!options2.tolerant && relative18.scheme) {
|
|
198878
|
+
target.scheme = relative18.scheme;
|
|
198879
|
+
target.userinfo = relative18.userinfo;
|
|
198880
|
+
target.host = relative18.host;
|
|
198881
|
+
target.port = relative18.port;
|
|
198882
|
+
target.path = removeDotSegments(relative18.path || "");
|
|
198883
|
+
target.query = relative18.query;
|
|
198884
198884
|
} else {
|
|
198885
|
-
if (
|
|
198886
|
-
target.userinfo =
|
|
198887
|
-
target.host =
|
|
198888
|
-
target.port =
|
|
198889
|
-
target.path = removeDotSegments(
|
|
198890
|
-
target.query =
|
|
198885
|
+
if (relative18.userinfo !== void 0 || relative18.host !== void 0 || relative18.port !== void 0) {
|
|
198886
|
+
target.userinfo = relative18.userinfo;
|
|
198887
|
+
target.host = relative18.host;
|
|
198888
|
+
target.port = relative18.port;
|
|
198889
|
+
target.path = removeDotSegments(relative18.path || "");
|
|
198890
|
+
target.query = relative18.query;
|
|
198891
198891
|
} else {
|
|
198892
|
-
if (!
|
|
198892
|
+
if (!relative18.path) {
|
|
198893
198893
|
target.path = base.path;
|
|
198894
|
-
if (
|
|
198895
|
-
target.query =
|
|
198894
|
+
if (relative18.query !== void 0) {
|
|
198895
|
+
target.query = relative18.query;
|
|
198896
198896
|
} else {
|
|
198897
198897
|
target.query = base.query;
|
|
198898
198898
|
}
|
|
198899
198899
|
} else {
|
|
198900
|
-
if (
|
|
198901
|
-
target.path = removeDotSegments(
|
|
198900
|
+
if (relative18.path[0] === "/") {
|
|
198901
|
+
target.path = removeDotSegments(relative18.path);
|
|
198902
198902
|
} else {
|
|
198903
198903
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
198904
|
-
target.path = "/" +
|
|
198904
|
+
target.path = "/" + relative18.path;
|
|
198905
198905
|
} else if (!base.path) {
|
|
198906
|
-
target.path =
|
|
198906
|
+
target.path = relative18.path;
|
|
198907
198907
|
} else {
|
|
198908
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
198908
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative18.path;
|
|
198909
198909
|
}
|
|
198910
198910
|
target.path = removeDotSegments(target.path);
|
|
198911
198911
|
}
|
|
198912
|
-
target.query =
|
|
198912
|
+
target.query = relative18.query;
|
|
198913
198913
|
}
|
|
198914
198914
|
target.userinfo = base.userinfo;
|
|
198915
198915
|
target.host = base.host;
|
|
@@ -198917,7 +198917,7 @@ var require_fast_uri = __commonJS({
|
|
|
198917
198917
|
}
|
|
198918
198918
|
target.scheme = base.scheme;
|
|
198919
198919
|
}
|
|
198920
|
-
target.fragment =
|
|
198920
|
+
target.fragment = relative18.fragment;
|
|
198921
198921
|
return target;
|
|
198922
198922
|
}
|
|
198923
198923
|
function equal2(uriA, uriB, options2) {
|
|
@@ -232755,7 +232755,7 @@ var require_snapshot_utils = __commonJS({
|
|
|
232755
232755
|
var require_snapshot_recorder = __commonJS({
|
|
232756
232756
|
"../node_modules/.bun/undici@7.28.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
|
|
232757
232757
|
"use strict";
|
|
232758
|
-
var { writeFile: writeFile21, readFile: readFile32, mkdir:
|
|
232758
|
+
var { writeFile: writeFile21, readFile: readFile32, mkdir: mkdir22 } = __require("node:fs/promises");
|
|
232759
232759
|
var { dirname: dirname29, resolve: resolve24 } = __require("node:path");
|
|
232760
232760
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
|
|
232761
232761
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
@@ -232987,7 +232987,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
232987
232987
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
232988
232988
|
}
|
|
232989
232989
|
const resolvedPath2 = resolve24(path27);
|
|
232990
|
-
await
|
|
232990
|
+
await mkdir22(dirname29(resolvedPath2), { recursive: true });
|
|
232991
232991
|
const data = Array.from(this.#snapshots.entries()).map(([hash3, snapshot]) => ({
|
|
232992
232992
|
hash: hash3,
|
|
232993
232993
|
snapshot
|
|
@@ -249127,10 +249127,10 @@ var require_resolve_block_map = __commonJS({
|
|
|
249127
249127
|
let offset = bm.offset;
|
|
249128
249128
|
let commentEnd = null;
|
|
249129
249129
|
for (const collItem of bm.items) {
|
|
249130
|
-
const { start, key, sep:
|
|
249130
|
+
const { start, key, sep: sep11, value } = collItem;
|
|
249131
249131
|
const keyProps = resolveProps.resolveProps(start, {
|
|
249132
249132
|
indicator: "explicit-key-ind",
|
|
249133
|
-
next: key ??
|
|
249133
|
+
next: key ?? sep11?.[0],
|
|
249134
249134
|
offset,
|
|
249135
249135
|
onError,
|
|
249136
249136
|
parentIndent: bm.indent,
|
|
@@ -249144,7 +249144,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
249144
249144
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
249145
249145
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
249146
249146
|
}
|
|
249147
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
249147
|
+
if (!keyProps.anchor && !keyProps.tag && !sep11) {
|
|
249148
249148
|
commentEnd = keyProps.end;
|
|
249149
249149
|
if (keyProps.comment) {
|
|
249150
249150
|
if (map3.comment)
|
|
@@ -249168,7 +249168,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
249168
249168
|
ctx.atKey = false;
|
|
249169
249169
|
if (utilMapIncludes.mapIncludes(ctx, map3.items, keyNode))
|
|
249170
249170
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
249171
|
-
const valueProps = resolveProps.resolveProps(
|
|
249171
|
+
const valueProps = resolveProps.resolveProps(sep11 ?? [], {
|
|
249172
249172
|
indicator: "map-value-ind",
|
|
249173
249173
|
next: value,
|
|
249174
249174
|
offset: keyNode.range[2],
|
|
@@ -249184,7 +249184,7 @@ var require_resolve_block_map = __commonJS({
|
|
|
249184
249184
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
249185
249185
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
249186
249186
|
}
|
|
249187
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
249187
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep11, null, valueProps, onError);
|
|
249188
249188
|
if (ctx.schema.compat)
|
|
249189
249189
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
249190
249190
|
offset = valueNode.range[2];
|
|
@@ -249275,7 +249275,7 @@ var require_resolve_end = __commonJS({
|
|
|
249275
249275
|
let comment = "";
|
|
249276
249276
|
if (end) {
|
|
249277
249277
|
let hasSpace = false;
|
|
249278
|
-
let
|
|
249278
|
+
let sep11 = "";
|
|
249279
249279
|
for (const token of end) {
|
|
249280
249280
|
const { source: source2, type } = token;
|
|
249281
249281
|
switch (type) {
|
|
@@ -249289,13 +249289,13 @@ var require_resolve_end = __commonJS({
|
|
|
249289
249289
|
if (!comment)
|
|
249290
249290
|
comment = cb;
|
|
249291
249291
|
else
|
|
249292
|
-
comment +=
|
|
249293
|
-
|
|
249292
|
+
comment += sep11 + cb;
|
|
249293
|
+
sep11 = "";
|
|
249294
249294
|
break;
|
|
249295
249295
|
}
|
|
249296
249296
|
case "newline":
|
|
249297
249297
|
if (comment)
|
|
249298
|
-
|
|
249298
|
+
sep11 += source2;
|
|
249299
249299
|
hasSpace = true;
|
|
249300
249300
|
break;
|
|
249301
249301
|
default:
|
|
@@ -249338,18 +249338,18 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
249338
249338
|
let offset = fc.offset + fc.start.source.length;
|
|
249339
249339
|
for (let i2 = 0; i2 < fc.items.length; ++i2) {
|
|
249340
249340
|
const collItem = fc.items[i2];
|
|
249341
|
-
const { start, key, sep:
|
|
249341
|
+
const { start, key, sep: sep11, value } = collItem;
|
|
249342
249342
|
const props = resolveProps.resolveProps(start, {
|
|
249343
249343
|
flow: fcName,
|
|
249344
249344
|
indicator: "explicit-key-ind",
|
|
249345
|
-
next: key ??
|
|
249345
|
+
next: key ?? sep11?.[0],
|
|
249346
249346
|
offset,
|
|
249347
249347
|
onError,
|
|
249348
249348
|
parentIndent: fc.indent,
|
|
249349
249349
|
startOnNewline: false
|
|
249350
249350
|
});
|
|
249351
249351
|
if (!props.found) {
|
|
249352
|
-
if (!props.anchor && !props.tag && !
|
|
249352
|
+
if (!props.anchor && !props.tag && !sep11 && !value) {
|
|
249353
249353
|
if (i2 === 0 && props.comma)
|
|
249354
249354
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
249355
249355
|
else if (i2 < fc.items.length - 1)
|
|
@@ -249403,8 +249403,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
249403
249403
|
}
|
|
249404
249404
|
}
|
|
249405
249405
|
}
|
|
249406
|
-
if (!isMap && !
|
|
249407
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
249406
|
+
if (!isMap && !sep11 && !props.found) {
|
|
249407
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep11, null, props, onError);
|
|
249408
249408
|
coll.items.push(valueNode);
|
|
249409
249409
|
offset = valueNode.range[2];
|
|
249410
249410
|
if (isBlock(value))
|
|
@@ -249416,7 +249416,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
249416
249416
|
if (isBlock(key))
|
|
249417
249417
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
249418
249418
|
ctx.atKey = false;
|
|
249419
|
-
const valueProps = resolveProps.resolveProps(
|
|
249419
|
+
const valueProps = resolveProps.resolveProps(sep11 ?? [], {
|
|
249420
249420
|
flow: fcName,
|
|
249421
249421
|
indicator: "map-value-ind",
|
|
249422
249422
|
next: value,
|
|
@@ -249427,8 +249427,8 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
249427
249427
|
});
|
|
249428
249428
|
if (valueProps.found) {
|
|
249429
249429
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
249430
|
-
if (
|
|
249431
|
-
for (const st2 of
|
|
249430
|
+
if (sep11)
|
|
249431
|
+
for (const st2 of sep11) {
|
|
249432
249432
|
if (st2 === valueProps.found)
|
|
249433
249433
|
break;
|
|
249434
249434
|
if (st2.type === "newline") {
|
|
@@ -249445,7 +249445,7 @@ var require_resolve_flow_collection = __commonJS({
|
|
|
249445
249445
|
else
|
|
249446
249446
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
249447
249447
|
}
|
|
249448
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
249448
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep11, null, valueProps, onError) : null;
|
|
249449
249449
|
if (valueNode) {
|
|
249450
249450
|
if (isBlock(value))
|
|
249451
249451
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -249625,7 +249625,7 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
249625
249625
|
chompStart = i2 + 1;
|
|
249626
249626
|
}
|
|
249627
249627
|
let value = "";
|
|
249628
|
-
let
|
|
249628
|
+
let sep11 = "";
|
|
249629
249629
|
let prevMoreIndented = false;
|
|
249630
249630
|
for (let i2 = 0; i2 < contentStart; ++i2)
|
|
249631
249631
|
value += lines2[i2][0].slice(trimIndent) + "\n";
|
|
@@ -249642,24 +249642,24 @@ var require_resolve_block_scalar = __commonJS({
|
|
|
249642
249642
|
indent = "";
|
|
249643
249643
|
}
|
|
249644
249644
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
249645
|
-
value +=
|
|
249646
|
-
|
|
249645
|
+
value += sep11 + indent.slice(trimIndent) + content;
|
|
249646
|
+
sep11 = "\n";
|
|
249647
249647
|
} else if (indent.length > trimIndent || content[0] === " ") {
|
|
249648
|
-
if (
|
|
249649
|
-
|
|
249650
|
-
else if (!prevMoreIndented &&
|
|
249651
|
-
|
|
249652
|
-
value +=
|
|
249653
|
-
|
|
249648
|
+
if (sep11 === " ")
|
|
249649
|
+
sep11 = "\n";
|
|
249650
|
+
else if (!prevMoreIndented && sep11 === "\n")
|
|
249651
|
+
sep11 = "\n\n";
|
|
249652
|
+
value += sep11 + indent.slice(trimIndent) + content;
|
|
249653
|
+
sep11 = "\n";
|
|
249654
249654
|
prevMoreIndented = true;
|
|
249655
249655
|
} else if (content === "") {
|
|
249656
|
-
if (
|
|
249656
|
+
if (sep11 === "\n")
|
|
249657
249657
|
value += "\n";
|
|
249658
249658
|
else
|
|
249659
|
-
|
|
249659
|
+
sep11 = "\n";
|
|
249660
249660
|
} else {
|
|
249661
|
-
value +=
|
|
249662
|
-
|
|
249661
|
+
value += sep11 + content;
|
|
249662
|
+
sep11 = " ";
|
|
249663
249663
|
prevMoreIndented = false;
|
|
249664
249664
|
}
|
|
249665
249665
|
}
|
|
@@ -249841,25 +249841,25 @@ var require_resolve_flow_scalar = __commonJS({
|
|
|
249841
249841
|
if (!match3)
|
|
249842
249842
|
return source2;
|
|
249843
249843
|
let res = match3[1];
|
|
249844
|
-
let
|
|
249844
|
+
let sep11 = " ";
|
|
249845
249845
|
let pos = first2.lastIndex;
|
|
249846
249846
|
line.lastIndex = pos;
|
|
249847
249847
|
while (match3 = line.exec(source2)) {
|
|
249848
249848
|
if (match3[1] === "") {
|
|
249849
|
-
if (
|
|
249850
|
-
res +=
|
|
249849
|
+
if (sep11 === "\n")
|
|
249850
|
+
res += sep11;
|
|
249851
249851
|
else
|
|
249852
|
-
|
|
249852
|
+
sep11 = "\n";
|
|
249853
249853
|
} else {
|
|
249854
|
-
res +=
|
|
249855
|
-
|
|
249854
|
+
res += sep11 + match3[1];
|
|
249855
|
+
sep11 = " ";
|
|
249856
249856
|
}
|
|
249857
249857
|
pos = line.lastIndex;
|
|
249858
249858
|
}
|
|
249859
249859
|
const last2 = /[ \t]*(.*)/sy;
|
|
249860
249860
|
last2.lastIndex = pos;
|
|
249861
249861
|
match3 = last2.exec(source2);
|
|
249862
|
-
return res +
|
|
249862
|
+
return res + sep11 + (match3?.[1] ?? "");
|
|
249863
249863
|
}
|
|
249864
249864
|
function doubleQuotedValue(source2, onError) {
|
|
249865
249865
|
let res = "";
|
|
@@ -250669,14 +250669,14 @@ var require_cst_stringify = __commonJS({
|
|
|
250669
250669
|
}
|
|
250670
250670
|
}
|
|
250671
250671
|
}
|
|
250672
|
-
function stringifyItem({ start, key, sep:
|
|
250672
|
+
function stringifyItem({ start, key, sep: sep11, value }) {
|
|
250673
250673
|
let res = "";
|
|
250674
250674
|
for (const st2 of start)
|
|
250675
250675
|
res += st2.source;
|
|
250676
250676
|
if (key)
|
|
250677
250677
|
res += stringifyToken(key);
|
|
250678
|
-
if (
|
|
250679
|
-
for (const st2 of
|
|
250678
|
+
if (sep11)
|
|
250679
|
+
for (const st2 of sep11)
|
|
250680
250680
|
res += st2.source;
|
|
250681
250681
|
if (value)
|
|
250682
250682
|
res += stringifyToken(value);
|
|
@@ -251843,18 +251843,18 @@ var require_parser = __commonJS({
|
|
|
251843
251843
|
if (this.type === "map-value-ind") {
|
|
251844
251844
|
const prev = getPrevProps(this.peek(2));
|
|
251845
251845
|
const start = getFirstKeyStartProps(prev);
|
|
251846
|
-
let
|
|
251846
|
+
let sep11;
|
|
251847
251847
|
if (scalar.end) {
|
|
251848
|
-
|
|
251849
|
-
|
|
251848
|
+
sep11 = scalar.end;
|
|
251849
|
+
sep11.push(this.sourceToken);
|
|
251850
251850
|
delete scalar.end;
|
|
251851
251851
|
} else
|
|
251852
|
-
|
|
251852
|
+
sep11 = [this.sourceToken];
|
|
251853
251853
|
const map3 = {
|
|
251854
251854
|
type: "block-map",
|
|
251855
251855
|
offset: scalar.offset,
|
|
251856
251856
|
indent: scalar.indent,
|
|
251857
|
-
items: [{ start, key: scalar, sep:
|
|
251857
|
+
items: [{ start, key: scalar, sep: sep11 }]
|
|
251858
251858
|
};
|
|
251859
251859
|
this.onKeyLine = true;
|
|
251860
251860
|
this.stack[this.stack.length - 1] = map3;
|
|
@@ -252007,15 +252007,15 @@ var require_parser = __commonJS({
|
|
|
252007
252007
|
} else if (isFlowToken(it2.key) && !includesToken(it2.sep, "newline")) {
|
|
252008
252008
|
const start2 = getFirstKeyStartProps(it2.start);
|
|
252009
252009
|
const key = it2.key;
|
|
252010
|
-
const
|
|
252011
|
-
|
|
252010
|
+
const sep11 = it2.sep;
|
|
252011
|
+
sep11.push(this.sourceToken);
|
|
252012
252012
|
delete it2.key;
|
|
252013
252013
|
delete it2.sep;
|
|
252014
252014
|
this.stack.push({
|
|
252015
252015
|
type: "block-map",
|
|
252016
252016
|
offset: this.offset,
|
|
252017
252017
|
indent: this.indent,
|
|
252018
|
-
items: [{ start: start2, key, sep:
|
|
252018
|
+
items: [{ start: start2, key, sep: sep11 }]
|
|
252019
252019
|
});
|
|
252020
252020
|
} else if (start.length > 0) {
|
|
252021
252021
|
it2.sep = it2.sep.concat(start, this.sourceToken);
|
|
@@ -252209,13 +252209,13 @@ var require_parser = __commonJS({
|
|
|
252209
252209
|
const prev = getPrevProps(parent);
|
|
252210
252210
|
const start = getFirstKeyStartProps(prev);
|
|
252211
252211
|
fixFlowSeqItems(fc);
|
|
252212
|
-
const
|
|
252213
|
-
|
|
252212
|
+
const sep11 = fc.end.splice(1, fc.end.length);
|
|
252213
|
+
sep11.push(this.sourceToken);
|
|
252214
252214
|
const map3 = {
|
|
252215
252215
|
type: "block-map",
|
|
252216
252216
|
offset: fc.offset,
|
|
252217
252217
|
indent: fc.indent,
|
|
252218
|
-
items: [{ start, key: fc, sep:
|
|
252218
|
+
items: [{ start, key: fc, sep: sep11 }]
|
|
252219
252219
|
};
|
|
252220
252220
|
this.onKeyLine = true;
|
|
252221
252221
|
this.stack[this.stack.length - 1] = map3;
|
|
@@ -292265,6 +292265,38 @@ var init_agents_manager = __esm({
|
|
|
292265
292265
|
import { cp as cp2, mkdir as mkdir7, readFile as readFile15, readdir as readdir9, rm as rm5 } from "node:fs/promises";
|
|
292266
292266
|
import { existsSync as existsSync21, readFileSync as readFileSync9 } from "node:fs";
|
|
292267
292267
|
import { join as join37, resolve as resolve12 } from "node:path";
|
|
292268
|
+
function readPackageName(manifestPath) {
|
|
292269
|
+
if (!existsSync21(manifestPath)) return null;
|
|
292270
|
+
try {
|
|
292271
|
+
const parsed = JSON.parse(readFileSync9(manifestPath, "utf-8"));
|
|
292272
|
+
return typeof parsed.name === "string" ? parsed.name : null;
|
|
292273
|
+
} catch {
|
|
292274
|
+
return null;
|
|
292275
|
+
}
|
|
292276
|
+
}
|
|
292277
|
+
function isTarskCheckout(bundledRoot) {
|
|
292278
|
+
const cliDir = resolve12(bundledRoot, "..");
|
|
292279
|
+
if (readPackageName(join37(cliDir, "package.json")) === "tarsk") return true;
|
|
292280
|
+
return readPackageName(join37(cliDir, "..", "package.json")) === "tarsk-monorepo";
|
|
292281
|
+
}
|
|
292282
|
+
function parseSemver(version3) {
|
|
292283
|
+
if (!version3) return null;
|
|
292284
|
+
const match3 = /^(\d+)\.(\d+)\.(\d+)/.exec(version3.trim());
|
|
292285
|
+
if (!match3) return null;
|
|
292286
|
+
return {
|
|
292287
|
+
major: Number(match3[1]),
|
|
292288
|
+
minor: Number(match3[2]),
|
|
292289
|
+
patch: Number(match3[3])
|
|
292290
|
+
};
|
|
292291
|
+
}
|
|
292292
|
+
function decideExportAction(args2) {
|
|
292293
|
+
if (!args2.projectExists) return "copy";
|
|
292294
|
+
if (args2.bundledVersion === args2.projectVersion) return "leave";
|
|
292295
|
+
const bundled = parseSemver(args2.bundledVersion);
|
|
292296
|
+
const project = parseSemver(args2.projectVersion);
|
|
292297
|
+
if (bundled && project && bundled.major > project.major) return "overwrite";
|
|
292298
|
+
return "leave";
|
|
292299
|
+
}
|
|
292268
292300
|
function parseFrontmatter2(content) {
|
|
292269
292301
|
const match3 = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
292270
292302
|
if (!match3) return {};
|
|
@@ -292309,6 +292341,56 @@ async function skillPublishesTools(skillDir) {
|
|
|
292309
292341
|
const meta3 = await readSkillMeta(skillDir);
|
|
292310
292342
|
return meta3.tools.length > 0;
|
|
292311
292343
|
}
|
|
292344
|
+
async function exportToolSkillsFrom(bundledRoot, projectSkillsDir) {
|
|
292345
|
+
const result = {
|
|
292346
|
+
copied: [],
|
|
292347
|
+
overwritten: [],
|
|
292348
|
+
left: [],
|
|
292349
|
+
editableToolSkills: [],
|
|
292350
|
+
projectSkillsDir,
|
|
292351
|
+
bundledRoot
|
|
292352
|
+
};
|
|
292353
|
+
if (!existsSync21(bundledRoot)) {
|
|
292354
|
+
return result;
|
|
292355
|
+
}
|
|
292356
|
+
if (isTarskCheckout(bundledRoot)) {
|
|
292357
|
+
return { ...result, skipped: "tarsk-checkout" };
|
|
292358
|
+
}
|
|
292359
|
+
await mkdir7(projectSkillsDir, { recursive: true });
|
|
292360
|
+
const entries = await readdir9(bundledRoot, { withFileTypes: true });
|
|
292361
|
+
for (const entry of entries) {
|
|
292362
|
+
if (!entry.isDirectory() || !entry.name.startsWith("tarsk-")) continue;
|
|
292363
|
+
const bundledDir = join37(bundledRoot, entry.name);
|
|
292364
|
+
const projectDir = join37(projectSkillsDir, entry.name);
|
|
292365
|
+
const bundledMeta = await readSkillMeta(bundledDir);
|
|
292366
|
+
const projectExists = existsSync21(projectDir);
|
|
292367
|
+
const projectMeta = projectExists ? await readSkillMeta(projectDir) : { tools: [] };
|
|
292368
|
+
const action = decideExportAction({
|
|
292369
|
+
projectExists,
|
|
292370
|
+
bundledVersion: bundledMeta.version,
|
|
292371
|
+
projectVersion: projectMeta.version
|
|
292372
|
+
});
|
|
292373
|
+
if (action === "leave") {
|
|
292374
|
+
result.left.push(entry.name);
|
|
292375
|
+
} else {
|
|
292376
|
+
if (projectExists) {
|
|
292377
|
+
await rm5(projectDir, { recursive: true, force: true });
|
|
292378
|
+
}
|
|
292379
|
+
await cp2(bundledDir, projectDir, { recursive: true });
|
|
292380
|
+
if (action === "copy") {
|
|
292381
|
+
result.copied.push(entry.name);
|
|
292382
|
+
} else {
|
|
292383
|
+
result.overwritten.push(entry.name);
|
|
292384
|
+
}
|
|
292385
|
+
}
|
|
292386
|
+
const editableDir = join37(projectSkillsDir, entry.name);
|
|
292387
|
+
if (existsSync21(editableDir) && await skillPublishesTools(editableDir)) {
|
|
292388
|
+
result.editableToolSkills.push(entry.name);
|
|
292389
|
+
}
|
|
292390
|
+
}
|
|
292391
|
+
result.editableToolSkills.sort((a2, b2) => a2.localeCompare(b2));
|
|
292392
|
+
return result;
|
|
292393
|
+
}
|
|
292312
292394
|
async function listRelativeFiles(dir, base = "") {
|
|
292313
292395
|
const out = [];
|
|
292314
292396
|
for (const entry of await readdir9(dir, { withFileTypes: true })) {
|
|
@@ -292375,9 +292457,24 @@ var init_export_tool_skills_lib = __esm({
|
|
|
292375
292457
|
});
|
|
292376
292458
|
|
|
292377
292459
|
// src/tools/agent-runtime/export-tool-skills.ts
|
|
292460
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
292378
292461
|
function emptyPruneResult(projectSkillsDir, bundledRoot) {
|
|
292379
292462
|
return { removed: [], kept: [], editableToolSkills: [], projectSkillsDir, bundledRoot };
|
|
292380
292463
|
}
|
|
292464
|
+
async function exportToolSkillsFrom2(bundledRoot, projectSkillsDir) {
|
|
292465
|
+
if (!existsSync22(bundledRoot)) {
|
|
292466
|
+
log96.warn("[Tool skill export] Bundled skills directory not found", { bundledRoot });
|
|
292467
|
+
return {
|
|
292468
|
+
copied: [],
|
|
292469
|
+
overwritten: [],
|
|
292470
|
+
left: [],
|
|
292471
|
+
editableToolSkills: [],
|
|
292472
|
+
projectSkillsDir,
|
|
292473
|
+
bundledRoot
|
|
292474
|
+
};
|
|
292475
|
+
}
|
|
292476
|
+
return exportToolSkillsFrom(bundledRoot, projectSkillsDir);
|
|
292477
|
+
}
|
|
292381
292478
|
async function pruneUnchangedProjectToolSkills(projectSkillsDir) {
|
|
292382
292479
|
const bundledRoot = getBundledSkillsDir();
|
|
292383
292480
|
if (!bundledRoot) {
|
|
@@ -293780,18 +293877,18 @@ var init_server_bind_mode = __esm({
|
|
|
293780
293877
|
});
|
|
293781
293878
|
|
|
293782
293879
|
// src/core/server-bind-mode-store.ts
|
|
293783
|
-
import { existsSync as
|
|
293880
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync6, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "fs";
|
|
293784
293881
|
import { join as join39 } from "path";
|
|
293785
293882
|
function getServerBindModeFilePath() {
|
|
293786
293883
|
return join39(getDataDir(), "server-bind-mode.json");
|
|
293787
293884
|
}
|
|
293788
293885
|
function hasServerBindModeFile() {
|
|
293789
|
-
return
|
|
293886
|
+
return existsSync23(getServerBindModeFilePath());
|
|
293790
293887
|
}
|
|
293791
293888
|
function readServerBindMode() {
|
|
293792
293889
|
try {
|
|
293793
293890
|
const filePath = getServerBindModeFilePath();
|
|
293794
|
-
if (!
|
|
293891
|
+
if (!existsSync23(filePath)) {
|
|
293795
293892
|
return DEFAULT_SERVER_BIND_MODE;
|
|
293796
293893
|
}
|
|
293797
293894
|
const raw2 = readFileSync11(filePath, "utf8");
|
|
@@ -294294,117 +294391,6 @@ var init_account_settings_route = __esm({
|
|
|
294294
294391
|
}
|
|
294295
294392
|
});
|
|
294296
294393
|
|
|
294297
|
-
// src/features/account/account-get-info.route.ts
|
|
294298
|
-
import { randomUUID as randomUUID17 } from "crypto";
|
|
294299
|
-
async function writeBalance(balance) {
|
|
294300
|
-
const db = await getDatabase();
|
|
294301
|
-
const verification = await encrypt(String(balance));
|
|
294302
|
-
await db.batch([
|
|
294303
|
-
{
|
|
294304
|
-
sql: "INSERT OR REPLACE INTO state (key, value) VALUES (?, ?)",
|
|
294305
|
-
args: [KEY_BALANCE, JSON.stringify(balance)]
|
|
294306
|
-
},
|
|
294307
|
-
{
|
|
294308
|
-
sql: "INSERT OR REPLACE INTO state (key, value) VALUES (?, ?)",
|
|
294309
|
-
args: [KEY_VERIFICATION, JSON.stringify(verification)]
|
|
294310
|
-
}
|
|
294311
|
-
]);
|
|
294312
|
-
}
|
|
294313
|
-
async function readVerifiedBalance() {
|
|
294314
|
-
const db = await getDatabase();
|
|
294315
|
-
const rawBalance = await getState(db, KEY_BALANCE);
|
|
294316
|
-
if (rawBalance === null || rawBalance === void 0) {
|
|
294317
|
-
await writeBalance(DEFAULT_BALANCE);
|
|
294318
|
-
return DEFAULT_BALANCE;
|
|
294319
|
-
}
|
|
294320
|
-
const balance = rawBalance;
|
|
294321
|
-
const rawVerification = await getState(db, KEY_VERIFICATION);
|
|
294322
|
-
if (rawVerification === null || rawVerification === void 0) {
|
|
294323
|
-
throw new Error("PromptBalanceVerification is missing \u2014 balance integrity cannot be confirmed");
|
|
294324
|
-
}
|
|
294325
|
-
const decrypted = await decrypt(rawVerification);
|
|
294326
|
-
if (decrypted !== String(balance)) {
|
|
294327
|
-
throw new Error(
|
|
294328
|
-
"PromptBalance integrity check failed: verification does not match stored balance"
|
|
294329
|
-
);
|
|
294330
|
-
}
|
|
294331
|
-
return balance;
|
|
294332
|
-
}
|
|
294333
|
-
async function getOrCreateClientReferenceId() {
|
|
294334
|
-
const db = await getDatabase();
|
|
294335
|
-
const existing = await getState(db, KEY_CLIENT_REFERENCE_ID);
|
|
294336
|
-
if (existing !== null && existing !== void 0) {
|
|
294337
|
-
return existing;
|
|
294338
|
-
}
|
|
294339
|
-
const id = randomUUID17();
|
|
294340
|
-
await setState(db, KEY_CLIENT_REFERENCE_ID, id);
|
|
294341
|
-
return id;
|
|
294342
|
-
}
|
|
294343
|
-
async function decrementBalance() {
|
|
294344
|
-
const current = await readVerifiedBalance();
|
|
294345
|
-
if (current <= 0) return;
|
|
294346
|
-
await writeBalance(current - 1);
|
|
294347
|
-
}
|
|
294348
|
-
async function processPayments(clientReferenceId) {
|
|
294349
|
-
const controller = new AbortController();
|
|
294350
|
-
const timeoutId = setTimeout(() => controller.abort(), 5e3);
|
|
294351
|
-
try {
|
|
294352
|
-
const res = await fetch(`https://payments.webnative.dev/account/${clientReferenceId}`, {
|
|
294353
|
-
method: "POST",
|
|
294354
|
-
signal: controller.signal
|
|
294355
|
-
});
|
|
294356
|
-
if (!res.ok) return;
|
|
294357
|
-
const data = await res.json();
|
|
294358
|
-
if (!data.success || !data.lineItems?.length) return;
|
|
294359
|
-
const db = await getDatabase();
|
|
294360
|
-
for (const item of data.lineItems) {
|
|
294361
|
-
if (item === "top-up-1000") {
|
|
294362
|
-
const current = await readVerifiedBalance();
|
|
294363
|
-
await writeBalance(current + 1e3);
|
|
294364
|
-
} else if (item === "pro-plan") {
|
|
294365
|
-
await setState(db, KEY_PLAN, "unlimited-pro");
|
|
294366
|
-
}
|
|
294367
|
-
}
|
|
294368
|
-
} catch {
|
|
294369
|
-
return;
|
|
294370
|
-
} finally {
|
|
294371
|
-
clearTimeout(timeoutId);
|
|
294372
|
-
}
|
|
294373
|
-
}
|
|
294374
|
-
async function getAccountInfo(c) {
|
|
294375
|
-
try {
|
|
294376
|
-
const db = await getDatabase();
|
|
294377
|
-
const clientReferenceId = await getOrCreateClientReferenceId();
|
|
294378
|
-
await processPayments(clientReferenceId);
|
|
294379
|
-
const promptsRemaining = await readVerifiedBalance();
|
|
294380
|
-
const rawPlan = await getState(db, KEY_PLAN);
|
|
294381
|
-
const plan = rawPlan === "unlimited-pro" ? "unlimited-pro" : "pay-as-you-go";
|
|
294382
|
-
return c.json({ promptsRemaining, plan, clientReferenceId });
|
|
294383
|
-
} catch (error2) {
|
|
294384
|
-
log101.error("Failed to get account info:", error2);
|
|
294385
|
-
return c.json(
|
|
294386
|
-
{ error: error2 instanceof Error ? error2.message : "Failed to get account info" },
|
|
294387
|
-
500
|
|
294388
|
-
);
|
|
294389
|
-
}
|
|
294390
|
-
}
|
|
294391
|
-
var log101, KEY_BALANCE, KEY_VERIFICATION, KEY_PLAN, KEY_CLIENT_REFERENCE_ID, DEFAULT_BALANCE;
|
|
294392
|
-
var init_account_get_info_route = __esm({
|
|
294393
|
-
"src/features/account/account-get-info.route.ts"() {
|
|
294394
|
-
"use strict";
|
|
294395
|
-
init_database();
|
|
294396
|
-
init_database_state();
|
|
294397
|
-
init_crypto();
|
|
294398
|
-
init_dist();
|
|
294399
|
-
log101 = createLogger("features.account.account-get-info");
|
|
294400
|
-
KEY_BALANCE = "PromptBalance";
|
|
294401
|
-
KEY_VERIFICATION = "PromptBalanceVerification";
|
|
294402
|
-
KEY_PLAN = "Plan";
|
|
294403
|
-
KEY_CLIENT_REFERENCE_ID = "clientReferenceId";
|
|
294404
|
-
DEFAULT_BALANCE = 1e3;
|
|
294405
|
-
}
|
|
294406
|
-
});
|
|
294407
|
-
|
|
294408
294394
|
// src/features/goals/goals.service.ts
|
|
294409
294395
|
function checkForPrompt(checkCommand, checkWorkdir) {
|
|
294410
294396
|
const where = checkWorkdir ? `Run it from \`${checkWorkdir}\` in this repository. ` : "";
|
|
@@ -294524,19 +294510,19 @@ async function writeGoalSummaryNote(args2) {
|
|
|
294524
294510
|
];
|
|
294525
294511
|
await args2.conversationManager.completeMessage(messageId, args2.summary, events);
|
|
294526
294512
|
} catch (error2) {
|
|
294527
|
-
|
|
294513
|
+
log101.warn("Failed to write a Goal summary into its conversation", {
|
|
294528
294514
|
threadId: args2.threadId,
|
|
294529
294515
|
conversationId: args2.conversationId,
|
|
294530
294516
|
error: error2
|
|
294531
294517
|
});
|
|
294532
294518
|
}
|
|
294533
294519
|
}
|
|
294534
|
-
var
|
|
294520
|
+
var log101, GOAL_ROUND_SUMMARY_LIMIT, GOAL_SUMMARY_HEADLINES;
|
|
294535
294521
|
var init_goals_service = __esm({
|
|
294536
294522
|
"src/features/goals/goals.service.ts"() {
|
|
294537
294523
|
"use strict";
|
|
294538
294524
|
init_dist();
|
|
294539
|
-
|
|
294525
|
+
log101 = createLogger("goal.service");
|
|
294540
294526
|
GOAL_ROUND_SUMMARY_LIMIT = 240;
|
|
294541
294527
|
GOAL_SUMMARY_HEADLINES = {
|
|
294542
294528
|
"check-passed": "Goal complete \u2014 the recorded Goal check passed.",
|
|
@@ -294809,15 +294795,15 @@ async function releaseRunLease(db, threadId, conversationId, startedAt) {
|
|
|
294809
294795
|
await deleteRunLease(db, threadId, conversationId);
|
|
294810
294796
|
}
|
|
294811
294797
|
} catch (error2) {
|
|
294812
|
-
|
|
294798
|
+
log102.warn("Failed to release a run lease", { error: error2, threadId, conversationId });
|
|
294813
294799
|
}
|
|
294814
294800
|
}
|
|
294815
|
-
var
|
|
294801
|
+
var log102, LEASE_COLUMNS, shuttingDown, lastLeaseStartedMs;
|
|
294816
294802
|
var init_run_leases = __esm({
|
|
294817
294803
|
"src/features/chat/run-leases.ts"() {
|
|
294818
294804
|
"use strict";
|
|
294819
294805
|
init_dist();
|
|
294820
|
-
|
|
294806
|
+
log102 = createLogger("chat.run-leases");
|
|
294821
294807
|
LEASE_COLUMNS = `threadId, conversationId, messageId, goalId, model, provider,
|
|
294822
294808
|
planMode, orchestrateMode, startedAt, resumeAttempts, forwardedCredentials`;
|
|
294823
294809
|
shuttingDown = false;
|
|
@@ -294826,7 +294812,7 @@ var init_run_leases = __esm({
|
|
|
294826
294812
|
});
|
|
294827
294813
|
|
|
294828
294814
|
// src/features/chat/chat-post.route.ts
|
|
294829
|
-
import { randomUUID as
|
|
294815
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
294830
294816
|
import { readFile as readFile16, unlink as unlink4 } from "fs/promises";
|
|
294831
294817
|
import { join as join40 } from "path";
|
|
294832
294818
|
function parseTurnAttribution(value) {
|
|
@@ -294861,7 +294847,7 @@ async function handleReplayRequest(c, userContent, activeThreadId, thread, conve
|
|
|
294861
294847
|
if (userContent.trim().toLowerCase() !== "replay") {
|
|
294862
294848
|
return null;
|
|
294863
294849
|
}
|
|
294864
|
-
|
|
294850
|
+
log103.info("Replay request detected", { threadId: activeThreadId });
|
|
294865
294851
|
const conversationId = thread.currentConversationId;
|
|
294866
294852
|
if (!conversationId) {
|
|
294867
294853
|
return errorResponse(
|
|
@@ -294884,7 +294870,7 @@ async function handleReplayRequest(c, userContent, activeThreadId, thread, conve
|
|
|
294884
294870
|
404
|
|
294885
294871
|
);
|
|
294886
294872
|
}
|
|
294887
|
-
|
|
294873
|
+
log103.info("Replaying message", {
|
|
294888
294874
|
messageId: lastMessage.id,
|
|
294889
294875
|
timestamp: lastMessage.timestamp,
|
|
294890
294876
|
eventCount: lastMessage.response.events.length
|
|
@@ -294899,7 +294885,7 @@ async function handleReplayRequest(c, userContent, activeThreadId, thread, conve
|
|
|
294899
294885
|
await delay(1e3);
|
|
294900
294886
|
yield replayEvent;
|
|
294901
294887
|
for (const event of response.events) {
|
|
294902
|
-
|
|
294888
|
+
log103.debug("Replaying event", event);
|
|
294903
294889
|
await delay(1e3);
|
|
294904
294890
|
yield event;
|
|
294905
294891
|
}
|
|
@@ -294921,19 +294907,19 @@ async function loadSkillAndAgentContext(thread, threadPath, userContent) {
|
|
|
294921
294907
|
try {
|
|
294922
294908
|
await pruneUnchangedProjectToolSkills(join40(exportRoot, ".agents", "skills"));
|
|
294923
294909
|
} catch (error2) {
|
|
294924
|
-
|
|
294910
|
+
log103.warn("Tool skill prune failed", { error: error2 });
|
|
294925
294911
|
}
|
|
294926
294912
|
const allSkills = await skillManager2.loadSkills(threadPath, skillProject?.path);
|
|
294927
294913
|
const bundledSkills = await skillManager2.loadBundledSkills();
|
|
294928
294914
|
const availableSkills = getAvailableSkills(allSkills, thread, bundledSkills);
|
|
294929
294915
|
const activatedSkills = await activateSkills(allSkills, userContent, thread, bundledSkills);
|
|
294930
294916
|
if (activatedSkills.length > 0) {
|
|
294931
|
-
|
|
294917
|
+
log103.info("Activated skills", { skills: activatedSkills.map((s2) => s2.name) });
|
|
294932
294918
|
}
|
|
294933
294919
|
const agentsManager = new AgentsManager();
|
|
294934
294920
|
const agents = await agentsManager.loadAgents(threadPath);
|
|
294935
294921
|
if (agents.length > 0) {
|
|
294936
|
-
|
|
294922
|
+
log103.info("Loaded agents", { agents: agents.map((a2) => a2.name) });
|
|
294937
294923
|
}
|
|
294938
294924
|
return { availableSkills, activatedSkills, agents };
|
|
294939
294925
|
}
|
|
@@ -295085,7 +295071,7 @@ async function* executeAgent(deps2, prompt, ctx, history2, captured) {
|
|
|
295085
295071
|
if (!next.settled) {
|
|
295086
295072
|
abandoned = true;
|
|
295087
295073
|
quarantineAbandonedExecution();
|
|
295088
|
-
|
|
295074
|
+
log103.warn("Agent run did not stop in time after Stop; ending the turn without it", {
|
|
295089
295075
|
threadId: deps2.activeThreadId,
|
|
295090
295076
|
conversationId: deps2.conversationId,
|
|
295091
295077
|
graceMs: STOP_ABORT_GRACE_MS
|
|
@@ -295131,7 +295117,7 @@ async function* executeAgent(deps2, prompt, ctx, history2, captured) {
|
|
|
295131
295117
|
clearSessionQuarantine(sessionKey, token);
|
|
295132
295118
|
},
|
|
295133
295119
|
function failedAbandonedClose(error2) {
|
|
295134
|
-
|
|
295120
|
+
log103.warn("Stopped execution cleanup failed; conversation remains quarantined", {
|
|
295135
295121
|
error: error2,
|
|
295136
295122
|
threadId: deps2.activeThreadId,
|
|
295137
295123
|
conversationId: deps2.conversationId
|
|
@@ -295197,7 +295183,7 @@ function applyStreamWatch(deps2, captured, watchers, event) {
|
|
|
295197
295183
|
captured.events.push(result.notice);
|
|
295198
295184
|
deps2.processingStateManager.pushEvent(deps2.activeThreadId, result.notice, deps2.conversationId);
|
|
295199
295185
|
deps2.abortController.abort(result.notice.error?.code);
|
|
295200
|
-
|
|
295186
|
+
log103.info(
|
|
295201
295187
|
result.stop === "tool_markup_leak" ? "Stopped run for Tool markup leak" : "Stopped run for Stream repetition",
|
|
295202
295188
|
{
|
|
295203
295189
|
threadId: deps2.activeThreadId,
|
|
@@ -295255,12 +295241,12 @@ async function* runGoalLoop(deps2, baseContext, startGoal, pendingMessageId) {
|
|
|
295255
295241
|
async function evaluateGoalRoundGate(deps2, db, current) {
|
|
295256
295242
|
const goal = await getGoal(db, current.id);
|
|
295257
295243
|
if (!goal) {
|
|
295258
|
-
|
|
295244
|
+
log103.warn("Goal disappeared while its loop was running", { goalId: current.id });
|
|
295259
295245
|
return { goal: current, roundNumber: current.roundsCompleted + 1, stop: true, notices: [] };
|
|
295260
295246
|
}
|
|
295261
295247
|
const roundNumber = goal.roundsCompleted + 1;
|
|
295262
295248
|
if (goal.status !== "running") {
|
|
295263
|
-
|
|
295249
|
+
log103.info("Goal is no longer running; stopping its loop", {
|
|
295264
295250
|
goalId: goal.id,
|
|
295265
295251
|
status: goal.status
|
|
295266
295252
|
});
|
|
@@ -295313,7 +295299,7 @@ async function* executeGoalRound(deps2, db, baseContext, goal, roundNumber, pend
|
|
|
295313
295299
|
void 0,
|
|
295314
295300
|
deps2.ralphMode
|
|
295315
295301
|
);
|
|
295316
|
-
const roundId =
|
|
295302
|
+
const roundId = randomUUID17();
|
|
295317
295303
|
const startedMs = Date.now();
|
|
295318
295304
|
await createGoalRound(db, {
|
|
295319
295305
|
id: roundId,
|
|
@@ -295343,9 +295329,6 @@ async function* executeGoalRound(deps2, db, baseContext, goal, roundNumber, pend
|
|
|
295343
295329
|
}
|
|
295344
295330
|
async function recordGoalRound(deps2, db, goal, thread, round) {
|
|
295345
295331
|
await addGoalRoundSpend(deps2, goal.id, round.captured.events, thread);
|
|
295346
|
-
decrementBalance().catch((err) => {
|
|
295347
|
-
log104.error("Failed to decrement balance", err);
|
|
295348
|
-
});
|
|
295349
295332
|
const afterRound = await getGoal(db, goal.id);
|
|
295350
295333
|
if (!afterRound) {
|
|
295351
295334
|
return null;
|
|
@@ -295441,7 +295424,7 @@ async function assessGoalObjective(deps2, goal, thread) {
|
|
|
295441
295424
|
const text = await readVerifier(deps2, goalAssessabilityPrompt(goal), goal.id, thread);
|
|
295442
295425
|
return parseGoalAssessability(text);
|
|
295443
295426
|
} catch (error2) {
|
|
295444
|
-
|
|
295427
|
+
log103.warn("Goal assessability check failed", { goalId: goal.id, error: error2 });
|
|
295445
295428
|
return {
|
|
295446
295429
|
assessable: false,
|
|
295447
295430
|
reason: "The verifier could not judge whether this objective can be assessed."
|
|
@@ -295453,7 +295436,7 @@ async function judgeGoalRound(deps2, goal, roundText, thread) {
|
|
|
295453
295436
|
const text = await readVerifier(deps2, goalRoundVerdictPrompt(goal, roundText), goal.id, thread);
|
|
295454
295437
|
return parseGoalRoundVerdict(text);
|
|
295455
295438
|
} catch (error2) {
|
|
295456
|
-
|
|
295439
|
+
log103.warn("Goal round verification failed", { goalId: goal.id, error: error2 });
|
|
295457
295440
|
return parseGoalRoundVerdict("");
|
|
295458
295441
|
}
|
|
295459
295442
|
}
|
|
@@ -295520,7 +295503,7 @@ async function addGoalRoundSpend(deps2, goalId, events, thread) {
|
|
|
295520
295503
|
await addGoalSpend(db, goalId, cost);
|
|
295521
295504
|
}
|
|
295522
295505
|
} catch (error2) {
|
|
295523
|
-
|
|
295506
|
+
log103.warn("Failed to add a Round's cost to its Goal", { goalId, error: error2 });
|
|
295524
295507
|
}
|
|
295525
295508
|
}
|
|
295526
295509
|
function buildErrorEvent(error2) {
|
|
@@ -295557,10 +295540,10 @@ async function finalizeWorkingState(activeThreadId, threadPath, goalOwnsTodos) {
|
|
|
295557
295540
|
}
|
|
295558
295541
|
}
|
|
295559
295542
|
} catch (e2) {
|
|
295560
|
-
|
|
295543
|
+
log103.error("Failed to process plan file for task", e2);
|
|
295561
295544
|
}
|
|
295562
295545
|
} catch (e2) {
|
|
295563
|
-
|
|
295546
|
+
log103.error("Failed to clear working state for thread tasks", e2);
|
|
295564
295547
|
}
|
|
295565
295548
|
}
|
|
295566
295549
|
async function* chatExecutionGenerator(deps2, autoCompactNotice, context2, conversationHistory, userContent, messageId) {
|
|
@@ -295579,7 +295562,7 @@ async function* chatExecutionGenerator(deps2, autoCompactNotice, context2, conve
|
|
|
295579
295562
|
try {
|
|
295580
295563
|
yield* runGoalLoop(deps2, context2, deps2.goal, messageId || void 0);
|
|
295581
295564
|
} catch (goalError) {
|
|
295582
|
-
|
|
295565
|
+
log103.error("Goal loop failed", { goalId: deps2.goal.id, error: goalError });
|
|
295583
295566
|
yield buildErrorEvent(goalError);
|
|
295584
295567
|
await parkGoalAfterFailure(deps2.goal.id);
|
|
295585
295568
|
}
|
|
@@ -295608,7 +295591,7 @@ async function* chatExecutionGenerator(deps2, autoCompactNotice, context2, conve
|
|
|
295608
295591
|
return;
|
|
295609
295592
|
}
|
|
295610
295593
|
const finalContent = await completeCapturedMessage(deps2, messageId, captured);
|
|
295611
|
-
|
|
295594
|
+
log103.info("Conversation captured", {
|
|
295612
295595
|
messageId,
|
|
295613
295596
|
eventCount: captured.events.length,
|
|
295614
295597
|
contentLength: finalContent.length
|
|
@@ -295620,7 +295603,7 @@ async function* chatExecutionGenerator(deps2, autoCompactNotice, context2, conve
|
|
|
295620
295603
|
try {
|
|
295621
295604
|
await completeCapturedMessage(deps2, messageId, captured);
|
|
295622
295605
|
} catch (saveError) {
|
|
295623
|
-
|
|
295606
|
+
log103.error("Failed to save partial conversation", saveError);
|
|
295624
295607
|
}
|
|
295625
295608
|
} finally {
|
|
295626
295609
|
deps2.processingStateManager.clearProcessing(
|
|
@@ -295628,14 +295611,6 @@ async function* chatExecutionGenerator(deps2, autoCompactNotice, context2, conve
|
|
|
295628
295611
|
deps2.conversationId,
|
|
295629
295612
|
deps2.runId
|
|
295630
295613
|
);
|
|
295631
|
-
const noResponse = captured.events.some(
|
|
295632
|
-
(e2) => e2.type === "error" && e2.error?.code === "NO_CONTENT_NO_TOOLS"
|
|
295633
|
-
);
|
|
295634
|
-
if (!noResponse && !deps2.goal) {
|
|
295635
|
-
decrementBalance().catch((err) => {
|
|
295636
|
-
log104.error("Failed to decrement balance", err);
|
|
295637
|
-
});
|
|
295638
|
-
}
|
|
295639
295614
|
await finalizeWorkingState(
|
|
295640
295615
|
deps2.activeThreadId,
|
|
295641
295616
|
deps2.threadPath,
|
|
@@ -295869,7 +295844,7 @@ async function stampChatReadTracking(threadManager, threadId, c) {
|
|
|
295869
295844
|
isInternalChatContext(c) ? { lastAutomationActivityAt: /* @__PURE__ */ new Date() } : { humanReadAt: /* @__PURE__ */ new Date() }
|
|
295870
295845
|
);
|
|
295871
295846
|
} catch (stampError) {
|
|
295872
|
-
|
|
295847
|
+
log103.warn("Failed to stamp thread chat read-tracking", {
|
|
295873
295848
|
threadId,
|
|
295874
295849
|
error: stampError
|
|
295875
295850
|
});
|
|
@@ -295883,7 +295858,7 @@ function duplicateIdempotencyResponse(c, processingStateManager, idempotencyKey)
|
|
|
295883
295858
|
if (!existingThreadId) {
|
|
295884
295859
|
return null;
|
|
295885
295860
|
}
|
|
295886
|
-
|
|
295861
|
+
log103.info("Rejecting duplicate chat POST; client should resume via subscribe", {
|
|
295887
295862
|
threadId: existingThreadId,
|
|
295888
295863
|
idempotencyKey
|
|
295889
295864
|
});
|
|
@@ -295918,7 +295893,7 @@ async function parkGoalAfterFailure(goalId) {
|
|
|
295918
295893
|
const db = await getDatabase();
|
|
295919
295894
|
await pauseGoalIfRunning(db, goalId);
|
|
295920
295895
|
} catch (parkError) {
|
|
295921
|
-
|
|
295896
|
+
log103.error("Failed to park a Goal whose run failed", { goalId, error: parkError });
|
|
295922
295897
|
}
|
|
295923
295898
|
}
|
|
295924
295899
|
async function resolveOrCreateConversationId(thread, threadManager, requestedConversationId) {
|
|
@@ -295926,7 +295901,7 @@ async function resolveOrCreateConversationId(thread, threadManager, requestedCon
|
|
|
295926
295901
|
if (requested) {
|
|
295927
295902
|
return requested;
|
|
295928
295903
|
}
|
|
295929
|
-
const conversationId =
|
|
295904
|
+
const conversationId = randomUUID17();
|
|
295930
295905
|
const db = await getDatabase();
|
|
295931
295906
|
await db.execute({
|
|
295932
295907
|
sql: "DELETE FROM todos WHERE threadId = ?",
|
|
@@ -295980,7 +295955,7 @@ async function leaseChatRun(db, args2) {
|
|
|
295980
295955
|
{ resumed: args2.options?.resumedInterruptedRun === true }
|
|
295981
295956
|
);
|
|
295982
295957
|
} catch (error2) {
|
|
295983
|
-
|
|
295958
|
+
log103.warn("Failed to record a run lease", {
|
|
295984
295959
|
error: error2,
|
|
295985
295960
|
threadId: args2.deps.activeThreadId,
|
|
295986
295961
|
conversationId: args2.deps.conversationId
|
|
@@ -296040,10 +296015,10 @@ async function launchReservedChatTurn(args2) {
|
|
|
296040
296015
|
}
|
|
296041
296016
|
if (args2.options?.runInBackground) {
|
|
296042
296017
|
let logBackgroundChatFailure2 = function(error2) {
|
|
296043
|
-
|
|
296018
|
+
log103.error("Background chat execution failed", error2);
|
|
296044
296019
|
};
|
|
296045
296020
|
var logBackgroundChatFailure = logBackgroundChatFailure2;
|
|
296046
|
-
|
|
296021
|
+
log103.info("Starting background chat execution", {
|
|
296047
296022
|
threadId: args2.deps.activeThreadId,
|
|
296048
296023
|
conversationId: args2.deps.conversationId
|
|
296049
296024
|
});
|
|
@@ -296082,7 +296057,7 @@ function tryReserveProcessing(processingStateManager, threadId, conversationId,
|
|
|
296082
296057
|
}
|
|
296083
296058
|
function logBuiltExecutionContext(args2) {
|
|
296084
296059
|
const attachments = args2.attachments ?? [];
|
|
296085
|
-
|
|
296060
|
+
log103.info("Built execution context", {
|
|
296086
296061
|
threadId: args2.activeThreadId,
|
|
296087
296062
|
threadPath: args2.threadPath,
|
|
296088
296063
|
model: args2.model,
|
|
@@ -296213,7 +296188,7 @@ async function resolveChatTarget(c, request3, deps2) {
|
|
|
296213
296188
|
idempotencyKey,
|
|
296214
296189
|
goal: goalRequest
|
|
296215
296190
|
} = request3;
|
|
296216
|
-
|
|
296191
|
+
log103.info("Received user message", { threadId: activeThreadId, content: userContent });
|
|
296217
296192
|
const duplicate = duplicateIdempotencyResponse(c, deps2.processingStateManager, idempotencyKey);
|
|
296218
296193
|
if (duplicate) {
|
|
296219
296194
|
return { ok: false, response: duplicate };
|
|
@@ -296260,7 +296235,7 @@ async function resolveChatTarget(c, request3, deps2) {
|
|
|
296260
296235
|
);
|
|
296261
296236
|
assertSessionAdmissionAvailable(activeThreadId, conversationId);
|
|
296262
296237
|
if (deps2.processingStateManager.isProcessing(activeThreadId, conversationId)) {
|
|
296263
|
-
|
|
296238
|
+
log103.info("Rejecting chat POST; conversation already processing", {
|
|
296264
296239
|
threadId: activeThreadId,
|
|
296265
296240
|
conversationId
|
|
296266
296241
|
});
|
|
@@ -296270,7 +296245,7 @@ async function resolveChatTarget(c, request3, deps2) {
|
|
|
296270
296245
|
if (goalRequest) {
|
|
296271
296246
|
const openGoal = await getOpenGoalForConversation(db, conversationId);
|
|
296272
296247
|
if (openGoal) {
|
|
296273
|
-
|
|
296248
|
+
log103.info("Rejecting chat POST; conversation already has an open Goal", {
|
|
296274
296249
|
threadId: activeThreadId,
|
|
296275
296250
|
conversationId,
|
|
296276
296251
|
goalId: openGoal.id
|
|
@@ -296389,7 +296364,7 @@ async function createChatGoal(db, rollback, goalRequest, activeThreadId, convers
|
|
|
296389
296364
|
}
|
|
296390
296365
|
assertSessionAdmissionAvailable(activeThreadId, conversationId);
|
|
296391
296366
|
const createdGoal = await createGoal(db, {
|
|
296392
|
-
id:
|
|
296367
|
+
id: randomUUID17(),
|
|
296393
296368
|
threadId: activeThreadId,
|
|
296394
296369
|
conversationId,
|
|
296395
296370
|
objective: goalRequest.objective,
|
|
@@ -296399,7 +296374,7 @@ async function createChatGoal(db, rollback, goalRequest, activeThreadId, convers
|
|
|
296399
296374
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
296400
296375
|
});
|
|
296401
296376
|
rollback.createdGoal = createdGoal;
|
|
296402
|
-
|
|
296377
|
+
log103.info("Started Goal", {
|
|
296403
296378
|
goalId: createdGoal.id,
|
|
296404
296379
|
threadId: activeThreadId,
|
|
296405
296380
|
conversationId,
|
|
@@ -296409,7 +296384,7 @@ async function createChatGoal(db, rollback, goalRequest, activeThreadId, convers
|
|
|
296409
296384
|
}
|
|
296410
296385
|
async function rollbackFailedChatLaunch(c, processingStateManager, rollback, error2) {
|
|
296411
296386
|
if (rollback.createdGoal) {
|
|
296412
|
-
|
|
296387
|
+
log103.error("Failed to launch the Goal", { goalId: rollback.createdGoal.id, error: error2 });
|
|
296413
296388
|
await parkGoalAfterFailure(rollback.createdGoal.id);
|
|
296414
296389
|
}
|
|
296415
296390
|
if (rollback.reservedRun) {
|
|
@@ -296444,7 +296419,7 @@ function stoppedBeforeStartResponse(c, threadId, conversationId, requestStartedA
|
|
|
296444
296419
|
if (!wasStopRequestedSince(threadId, conversationId, requestStartedAt, Date.now(), runId)) {
|
|
296445
296420
|
return null;
|
|
296446
296421
|
}
|
|
296447
|
-
|
|
296422
|
+
log103.info("Not starting chat run; Stop arrived while the message was being prepared", {
|
|
296448
296423
|
threadId,
|
|
296449
296424
|
conversationId
|
|
296450
296425
|
});
|
|
@@ -296475,7 +296450,7 @@ async function maybeResumeParkedGoalForChat(c, request3, target, deps2, launch4)
|
|
|
296475
296450
|
if (!resumed) {
|
|
296476
296451
|
return null;
|
|
296477
296452
|
}
|
|
296478
|
-
|
|
296453
|
+
log103.info("Resuming Goal from chat message", {
|
|
296479
296454
|
goalId: resumed.id,
|
|
296480
296455
|
threadId: request3.activeThreadId,
|
|
296481
296456
|
conversationId: target.conversationId,
|
|
@@ -296519,7 +296494,7 @@ async function postChatMessage(c, threadManager, agentExecutor, conversationMana
|
|
|
296519
296494
|
return prepared.response;
|
|
296520
296495
|
}
|
|
296521
296496
|
const request3 = prepared.request;
|
|
296522
|
-
const runId = request3.idempotencyKey ?? options2?.runId ??
|
|
296497
|
+
const runId = request3.idempotencyKey ?? options2?.runId ?? randomUUID17();
|
|
296523
296498
|
const runInBackground = options2?.runInBackground === true || request3.runInBackground === true;
|
|
296524
296499
|
const target = await resolveChatTarget(c, request3, {
|
|
296525
296500
|
threadManager,
|
|
@@ -296625,7 +296600,7 @@ async function postChatMessage(c, threadManager, agentExecutor, conversationMana
|
|
|
296625
296600
|
}
|
|
296626
296601
|
async function launchGoalRun(c, goal, threadManager, agentExecutor, conversationManager, processingStateManager, options2, perfTrace) {
|
|
296627
296602
|
let reservedConversation;
|
|
296628
|
-
const runId = options2?.runId ?? options2?.idempotencyKey ??
|
|
296603
|
+
const runId = options2?.runId ?? options2?.idempotencyKey ?? randomUUID17();
|
|
296629
296604
|
const requestStartedAt = options2?.requestStartedAt ?? Date.now();
|
|
296630
296605
|
try {
|
|
296631
296606
|
assertSessionAdmissionAvailable(goal.threadId, goal.conversationId);
|
|
@@ -296717,7 +296692,7 @@ async function launchGoalRun(c, goal, threadManager, agentExecutor, conversation
|
|
|
296717
296692
|
wireCallerAbortSignal(runController, options2?.abortSignal);
|
|
296718
296693
|
runController.signal.throwIfAborted();
|
|
296719
296694
|
context2.runId = runId;
|
|
296720
|
-
|
|
296695
|
+
log103.info("Running Goal", {
|
|
296721
296696
|
goalId: goal.id,
|
|
296722
296697
|
threadId: thread.id,
|
|
296723
296698
|
conversationId: goal.conversationId,
|
|
@@ -296776,7 +296751,7 @@ async function launchGoalRun(c, goal, threadManager, agentExecutor, conversation
|
|
|
296776
296751
|
);
|
|
296777
296752
|
}
|
|
296778
296753
|
}
|
|
296779
|
-
var
|
|
296754
|
+
var log103;
|
|
296780
296755
|
var init_chat_post_route = __esm({
|
|
296781
296756
|
"src/features/chat/chat-post.route.ts"() {
|
|
296782
296757
|
"use strict";
|
|
@@ -296810,7 +296785,6 @@ var init_chat_post_route = __esm({
|
|
|
296810
296785
|
init_model_aliases_store();
|
|
296811
296786
|
init_project_tasks_database();
|
|
296812
296787
|
init_git_status_cache_database();
|
|
296813
|
-
init_account_get_info_route();
|
|
296814
296788
|
init_projects_database();
|
|
296815
296789
|
init_tasks_database();
|
|
296816
296790
|
init_agent_run_guard();
|
|
@@ -296821,7 +296795,7 @@ var init_chat_post_route = __esm({
|
|
|
296821
296795
|
init_forwarded_model_credentials();
|
|
296822
296796
|
init_spend_cost();
|
|
296823
296797
|
init_run_leases();
|
|
296824
|
-
|
|
296798
|
+
log103 = createLogger("chat.post");
|
|
296825
296799
|
}
|
|
296826
296800
|
});
|
|
296827
296801
|
|
|
@@ -296839,7 +296813,7 @@ function chatLaunchOptions(options2) {
|
|
|
296839
296813
|
}
|
|
296840
296814
|
async function startTurn(c, deps2, options2) {
|
|
296841
296815
|
const source2 = options2?.source ?? (options2?.goal ? "goal" : "chat");
|
|
296842
|
-
|
|
296816
|
+
log104.info("Starting turn", {
|
|
296843
296817
|
source: source2,
|
|
296844
296818
|
goalId: options2?.goal?.id
|
|
296845
296819
|
});
|
|
@@ -296868,13 +296842,13 @@ async function startTurn(c, deps2, options2) {
|
|
|
296868
296842
|
launchOptions
|
|
296869
296843
|
);
|
|
296870
296844
|
}
|
|
296871
|
-
var
|
|
296845
|
+
var log104;
|
|
296872
296846
|
var init_start_turn = __esm({
|
|
296873
296847
|
"src/features/chat/start-turn.ts"() {
|
|
296874
296848
|
"use strict";
|
|
296875
296849
|
init_dist();
|
|
296876
296850
|
init_chat_post_route();
|
|
296877
|
-
|
|
296851
|
+
log104 = createLogger("chat.start-turn");
|
|
296878
296852
|
}
|
|
296879
296853
|
});
|
|
296880
296854
|
|
|
@@ -297467,7 +297441,7 @@ var init_conversation_route_params = __esm({
|
|
|
297467
297441
|
});
|
|
297468
297442
|
|
|
297469
297443
|
// src/features/chat/chat-delete.route.ts
|
|
297470
|
-
import { randomUUID as
|
|
297444
|
+
import { randomUUID as randomUUID18 } from "crypto";
|
|
297471
297445
|
async function deleteChat(c, threadManager) {
|
|
297472
297446
|
try {
|
|
297473
297447
|
const existingThread = await requireExistingThread(c, threadManager);
|
|
@@ -297484,7 +297458,7 @@ async function deleteChat(c, threadManager) {
|
|
|
297484
297458
|
if (previousConversationId) {
|
|
297485
297459
|
await markConversationRead(db, threadId, previousConversationId);
|
|
297486
297460
|
}
|
|
297487
|
-
const newConversationId =
|
|
297461
|
+
const newConversationId = randomUUID18();
|
|
297488
297462
|
await threadManager.updateThread(threadId, { currentConversationId: newConversationId });
|
|
297489
297463
|
return successResponse(
|
|
297490
297464
|
c,
|
|
@@ -297512,7 +297486,7 @@ var init_chat_delete_route = __esm({
|
|
|
297512
297486
|
});
|
|
297513
297487
|
|
|
297514
297488
|
// src/features/chat/chat-agent-note.route.ts
|
|
297515
|
-
import { randomUUID as
|
|
297489
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
297516
297490
|
async function postAgentNote(c, threadManager, conversationManager) {
|
|
297517
297491
|
try {
|
|
297518
297492
|
const threadIdResult = requireThreadIdParam(c);
|
|
@@ -297538,7 +297512,7 @@ async function postAgentNote(c, threadManager, conversationManager) {
|
|
|
297538
297512
|
const requestedConversationId = typeof body.conversationId === "string" ? body.conversationId.trim() : "";
|
|
297539
297513
|
let conversationId = requestedConversationId || thread.currentConversationId;
|
|
297540
297514
|
if (!conversationId) {
|
|
297541
|
-
conversationId =
|
|
297515
|
+
conversationId = randomUUID19();
|
|
297542
297516
|
await threadManager.updateThread(threadId, { currentConversationId: conversationId });
|
|
297543
297517
|
}
|
|
297544
297518
|
const messageId = await conversationManager.startMessage(
|
|
@@ -297934,7 +297908,7 @@ async function stopChatGeneration(c, processingStateManager, agentExecutor) {
|
|
|
297934
297908
|
...abortAll ? { all: true } : {}
|
|
297935
297909
|
});
|
|
297936
297910
|
if (aborted2 || cancellation.childrenStopped || cancellation.imagesStopped || cancellation.wakesStopped) {
|
|
297937
|
-
|
|
297911
|
+
log105.info("Requested chat cancellation", { threadId, conversationId, abortAll });
|
|
297938
297912
|
return c.json({ success: true, message: "Cancellation requested" }, 200);
|
|
297939
297913
|
}
|
|
297940
297914
|
return c.json(
|
|
@@ -297946,7 +297920,7 @@ async function stopChatGeneration(c, processingStateManager, agentExecutor) {
|
|
|
297946
297920
|
200
|
|
297947
297921
|
);
|
|
297948
297922
|
}
|
|
297949
|
-
var
|
|
297923
|
+
var log105;
|
|
297950
297924
|
var init_chat_stop_route = __esm({
|
|
297951
297925
|
"src/features/chat/chat-stop.route.ts"() {
|
|
297952
297926
|
"use strict";
|
|
@@ -297956,7 +297930,7 @@ var init_chat_stop_route = __esm({
|
|
|
297956
297930
|
init_chat_stop_requests();
|
|
297957
297931
|
init_image_runs();
|
|
297958
297932
|
init_background_subagent_wake();
|
|
297959
|
-
|
|
297933
|
+
log105 = createLogger("chat.stop");
|
|
297960
297934
|
}
|
|
297961
297935
|
});
|
|
297962
297936
|
|
|
@@ -298124,7 +298098,7 @@ async function buildCompletedMessageSpendStatements(db, events, messageRecord, u
|
|
|
298124
298098
|
completedMessageSpendDelta(messageRecord, usage2, estimatedCost)
|
|
298125
298099
|
);
|
|
298126
298100
|
} catch (error2) {
|
|
298127
|
-
|
|
298101
|
+
log106.error("Failed to record daily spend", {
|
|
298128
298102
|
error: error2,
|
|
298129
298103
|
threadId: messageRecord.threadId
|
|
298130
298104
|
});
|
|
@@ -298139,7 +298113,7 @@ async function commitMessageCompletion(db, messageId, completion2, spendStatemen
|
|
|
298139
298113
|
if (spendStatements.length === 0) {
|
|
298140
298114
|
throw error2;
|
|
298141
298115
|
}
|
|
298142
|
-
|
|
298116
|
+
log106.error("Failed to record daily spend", { error: error2, messageId });
|
|
298143
298117
|
const result = await db.execute(completion2.statement);
|
|
298144
298118
|
warnIfMessageMissing(messageId, result.rowsAffected);
|
|
298145
298119
|
}
|
|
@@ -298156,9 +298130,9 @@ function buildAttachmentSummaries(attachments) {
|
|
|
298156
298130
|
}
|
|
298157
298131
|
function logConversationTurn(data) {
|
|
298158
298132
|
const label = data.role === "user" ? "User message" : "Assistant response";
|
|
298159
|
-
|
|
298133
|
+
log106.info(label, data);
|
|
298160
298134
|
}
|
|
298161
|
-
var
|
|
298135
|
+
var log106, ConversationManagerImpl;
|
|
298162
298136
|
var init_conversations_manager = __esm({
|
|
298163
298137
|
"src/features/conversations/conversations.manager.ts"() {
|
|
298164
298138
|
"use strict";
|
|
@@ -298171,7 +298145,7 @@ var init_conversations_manager = __esm({
|
|
|
298171
298145
|
init_spend_cost();
|
|
298172
298146
|
init_observations_store();
|
|
298173
298147
|
init_paths();
|
|
298174
|
-
|
|
298148
|
+
log106 = createLogger("agent.conversation");
|
|
298175
298149
|
ConversationManagerImpl = class {
|
|
298176
298150
|
storedDb = null;
|
|
298177
298151
|
/**
|
|
@@ -298240,7 +298214,7 @@ var init_conversations_manager = __esm({
|
|
|
298240
298214
|
await publishUnreadChangedForThread(await this.ensureDb(), threadId);
|
|
298241
298215
|
return messageId;
|
|
298242
298216
|
} catch (error2) {
|
|
298243
|
-
|
|
298217
|
+
log106.error("Failed to start conversation message", error2);
|
|
298244
298218
|
throw error2;
|
|
298245
298219
|
}
|
|
298246
298220
|
}
|
|
@@ -298285,7 +298259,7 @@ var init_conversations_manager = __esm({
|
|
|
298285
298259
|
});
|
|
298286
298260
|
}
|
|
298287
298261
|
} catch (error2) {
|
|
298288
|
-
|
|
298262
|
+
log106.error("Failed to complete conversation message", error2);
|
|
298289
298263
|
throw error2;
|
|
298290
298264
|
}
|
|
298291
298265
|
}
|
|
@@ -298304,7 +298278,7 @@ var init_conversations_manager = __esm({
|
|
|
298304
298278
|
try {
|
|
298305
298279
|
return await getConversationHistory(await this.ensureDb(), threadId, options2);
|
|
298306
298280
|
} catch (error2) {
|
|
298307
|
-
|
|
298281
|
+
log106.error("Failed to get conversation history", { error: error2, threadId });
|
|
298308
298282
|
throw error2;
|
|
298309
298283
|
}
|
|
298310
298284
|
}
|
|
@@ -298320,7 +298294,7 @@ var init_conversations_manager = __esm({
|
|
|
298320
298294
|
options2
|
|
298321
298295
|
);
|
|
298322
298296
|
} catch (error2) {
|
|
298323
|
-
|
|
298297
|
+
log106.error("Failed to get conversation history by conversation ID", {
|
|
298324
298298
|
error: error2,
|
|
298325
298299
|
threadId,
|
|
298326
298300
|
conversationId,
|
|
@@ -298341,7 +298315,7 @@ var init_conversations_manager = __esm({
|
|
|
298341
298315
|
count
|
|
298342
298316
|
);
|
|
298343
298317
|
} catch (error2) {
|
|
298344
|
-
|
|
298318
|
+
log106.error("Failed to get last messages", { error: error2, threadId, conversationId, count });
|
|
298345
298319
|
throw error2;
|
|
298346
298320
|
}
|
|
298347
298321
|
}
|
|
@@ -298354,7 +298328,7 @@ var init_conversations_manager = __esm({
|
|
|
298354
298328
|
count
|
|
298355
298329
|
);
|
|
298356
298330
|
} catch (error2) {
|
|
298357
|
-
|
|
298331
|
+
log106.error("Failed to get recent context messages", {
|
|
298358
298332
|
error: error2,
|
|
298359
298333
|
threadId,
|
|
298360
298334
|
conversationId,
|
|
@@ -298374,7 +298348,7 @@ var init_conversations_manager = __esm({
|
|
|
298374
298348
|
conversationId
|
|
298375
298349
|
);
|
|
298376
298350
|
} catch (error2) {
|
|
298377
|
-
|
|
298351
|
+
log106.error("Failed to get conversation message count", {
|
|
298378
298352
|
error: error2,
|
|
298379
298353
|
threadId,
|
|
298380
298354
|
conversationId
|
|
@@ -298390,7 +298364,7 @@ var init_conversations_manager = __esm({
|
|
|
298390
298364
|
conversationId
|
|
298391
298365
|
);
|
|
298392
298366
|
} catch (error2) {
|
|
298393
|
-
|
|
298367
|
+
log106.error("Failed to get completed conversation message count", {
|
|
298394
298368
|
error: error2,
|
|
298395
298369
|
threadId,
|
|
298396
298370
|
conversationId
|
|
@@ -298419,7 +298393,7 @@ var init_conversations_manager = __esm({
|
|
|
298419
298393
|
conversationId
|
|
298420
298394
|
);
|
|
298421
298395
|
} catch (error2) {
|
|
298422
|
-
|
|
298396
|
+
log106.error("Failed to clear conversation history", { error: error2, threadId, conversationId });
|
|
298423
298397
|
throw error2;
|
|
298424
298398
|
}
|
|
298425
298399
|
}
|
|
@@ -298434,10 +298408,10 @@ var init_conversations_manager = __esm({
|
|
|
298434
298408
|
checkpointRef
|
|
298435
298409
|
);
|
|
298436
298410
|
await garbageCollectOrphanedObservations(await this.ensureDb(), getDataDir(), 0);
|
|
298437
|
-
|
|
298411
|
+
log106.info("Truncated conversation from checkpoint", { threadId, checkpointRef, deletedCount });
|
|
298438
298412
|
return deletedCount;
|
|
298439
298413
|
} catch (error2) {
|
|
298440
|
-
|
|
298414
|
+
log106.error("Failed to truncate conversation from checkpoint", {
|
|
298441
298415
|
error: error2,
|
|
298442
298416
|
threadId,
|
|
298443
298417
|
checkpointRef
|
|
@@ -298452,7 +298426,7 @@ var init_conversations_manager = __esm({
|
|
|
298452
298426
|
try {
|
|
298453
298427
|
return await getConversationIds(await this.ensureDb(), threadId);
|
|
298454
298428
|
} catch (error2) {
|
|
298455
|
-
|
|
298429
|
+
log106.error("Failed to get conversation IDs", { error: error2, threadId });
|
|
298456
298430
|
throw error2;
|
|
298457
298431
|
}
|
|
298458
298432
|
}
|
|
@@ -298463,7 +298437,7 @@ var init_conversations_manager = __esm({
|
|
|
298463
298437
|
try {
|
|
298464
298438
|
return await getDeletedConversationHistory(await this.ensureDb(), threadId);
|
|
298465
298439
|
} catch (error2) {
|
|
298466
|
-
|
|
298440
|
+
log106.error("Failed to get deleted conversation history", { error: error2, threadId });
|
|
298467
298441
|
throw error2;
|
|
298468
298442
|
}
|
|
298469
298443
|
}
|
|
@@ -298474,7 +298448,7 @@ var init_conversations_manager = __esm({
|
|
|
298474
298448
|
try {
|
|
298475
298449
|
return await getDeletedConversationIds(await this.ensureDb(), threadId);
|
|
298476
298450
|
} catch (error2) {
|
|
298477
|
-
|
|
298451
|
+
log106.error("Failed to get deleted conversation IDs", { error: error2, threadId });
|
|
298478
298452
|
throw error2;
|
|
298479
298453
|
}
|
|
298480
298454
|
}
|
|
@@ -298522,7 +298496,7 @@ var init_conversations_manager = __esm({
|
|
|
298522
298496
|
excludeThreadIds
|
|
298523
298497
|
);
|
|
298524
298498
|
} catch (error2) {
|
|
298525
|
-
|
|
298499
|
+
log106.error("Failed to get recent conversations", { error: error2, scope });
|
|
298526
298500
|
throw error2;
|
|
298527
298501
|
}
|
|
298528
298502
|
}
|
|
@@ -298535,7 +298509,7 @@ var init_conversations_manager = __esm({
|
|
|
298535
298509
|
await markConversationRead(await this.ensureDb(), threadId, conversationId);
|
|
298536
298510
|
await publishUnreadChangedForThread(await this.ensureDb(), threadId);
|
|
298537
298511
|
} catch (error2) {
|
|
298538
|
-
|
|
298512
|
+
log106.error("Failed to mark conversation read", { error: error2, threadId, conversationId });
|
|
298539
298513
|
throw error2;
|
|
298540
298514
|
}
|
|
298541
298515
|
}
|
|
@@ -298551,7 +298525,7 @@ var init_conversations_manager = __esm({
|
|
|
298551
298525
|
conversationId
|
|
298552
298526
|
);
|
|
298553
298527
|
} catch (error2) {
|
|
298554
|
-
|
|
298528
|
+
log106.error("Failed to mark conversation complete", { error: error2, threadId, conversationId });
|
|
298555
298529
|
throw error2;
|
|
298556
298530
|
}
|
|
298557
298531
|
}
|
|
@@ -298563,7 +298537,7 @@ var init_conversations_manager = __esm({
|
|
|
298563
298537
|
conversationId
|
|
298564
298538
|
);
|
|
298565
298539
|
} catch (error2) {
|
|
298566
|
-
|
|
298540
|
+
log106.error("Failed to dismiss conversation completion", { error: error2, threadId, conversationId });
|
|
298567
298541
|
throw error2;
|
|
298568
298542
|
}
|
|
298569
298543
|
}
|
|
@@ -298571,7 +298545,7 @@ var init_conversations_manager = __esm({
|
|
|
298571
298545
|
try {
|
|
298572
298546
|
await clearThreadCompletionMarks(await this.ensureDb(), threadId);
|
|
298573
298547
|
} catch (error2) {
|
|
298574
|
-
|
|
298548
|
+
log106.error("Failed to clear thread completion marks", { error: error2, threadId });
|
|
298575
298549
|
throw error2;
|
|
298576
298550
|
}
|
|
298577
298551
|
}
|
|
@@ -298579,7 +298553,7 @@ var init_conversations_manager = __esm({
|
|
|
298579
298553
|
try {
|
|
298580
298554
|
return await getCompletedConversationIds(await this.ensureDb(), threadId);
|
|
298581
298555
|
} catch (error2) {
|
|
298582
|
-
|
|
298556
|
+
log106.error("Failed to get completed conversation IDs", { error: error2, threadId });
|
|
298583
298557
|
throw error2;
|
|
298584
298558
|
}
|
|
298585
298559
|
}
|
|
@@ -298588,7 +298562,7 @@ var init_conversations_manager = __esm({
|
|
|
298588
298562
|
await unmarkConversationRead(await this.ensureDb(), threadId, conversationId);
|
|
298589
298563
|
await publishUnreadChangedForThread(await this.ensureDb(), threadId);
|
|
298590
298564
|
} catch (error2) {
|
|
298591
|
-
|
|
298565
|
+
log106.error("Failed to unmark conversation read", { error: error2, threadId, conversationId });
|
|
298592
298566
|
throw error2;
|
|
298593
298567
|
}
|
|
298594
298568
|
}
|
|
@@ -298596,7 +298570,7 @@ var init_conversations_manager = __esm({
|
|
|
298596
298570
|
try {
|
|
298597
298571
|
await archiveConversation(await this.ensureDb(), threadId, conversationId);
|
|
298598
298572
|
} catch (error2) {
|
|
298599
|
-
|
|
298573
|
+
log106.error("Failed to archive conversation", { error: error2, threadId, conversationId });
|
|
298600
298574
|
throw error2;
|
|
298601
298575
|
}
|
|
298602
298576
|
}
|
|
@@ -298604,7 +298578,7 @@ var init_conversations_manager = __esm({
|
|
|
298604
298578
|
try {
|
|
298605
298579
|
await unarchiveConversation(await this.ensureDb(), threadId, conversationId);
|
|
298606
298580
|
} catch (error2) {
|
|
298607
|
-
|
|
298581
|
+
log106.error("Failed to unarchive conversation", { error: error2, threadId, conversationId });
|
|
298608
298582
|
throw error2;
|
|
298609
298583
|
}
|
|
298610
298584
|
}
|
|
@@ -298616,7 +298590,7 @@ var init_conversations_manager = __esm({
|
|
|
298616
298590
|
conversationId
|
|
298617
298591
|
);
|
|
298618
298592
|
} catch (error2) {
|
|
298619
|
-
|
|
298593
|
+
log106.error("Failed to check for a sibling conversation", { error: error2, threadId, conversationId });
|
|
298620
298594
|
throw error2;
|
|
298621
298595
|
}
|
|
298622
298596
|
}
|
|
@@ -298633,7 +298607,7 @@ var init_conversations_manager = __esm({
|
|
|
298633
298607
|
title
|
|
298634
298608
|
);
|
|
298635
298609
|
} catch (error2) {
|
|
298636
|
-
|
|
298610
|
+
log106.error("Failed to rename conversation", { error: error2, threadId, conversationId });
|
|
298637
298611
|
throw error2;
|
|
298638
298612
|
}
|
|
298639
298613
|
}
|
|
@@ -298661,7 +298635,7 @@ var init_conversations_manager = __esm({
|
|
|
298661
298635
|
await purgeAllConversationHistory(await this.ensureDb());
|
|
298662
298636
|
await garbageCollectOrphanedObservations(await this.ensureDb(), getDataDir(), 0);
|
|
298663
298637
|
} catch (error2) {
|
|
298664
|
-
|
|
298638
|
+
log106.error("Failed to purge conversation history", { error: error2, options: options2 });
|
|
298665
298639
|
throw error2;
|
|
298666
298640
|
}
|
|
298667
298641
|
}
|
|
@@ -298674,7 +298648,7 @@ var init_conversations_manager = __esm({
|
|
|
298674
298648
|
await garbageCollectOrphanedObservations(await this.ensureDb(), getDataDir(), 0);
|
|
298675
298649
|
return purged;
|
|
298676
298650
|
} catch (error2) {
|
|
298677
|
-
|
|
298651
|
+
log106.error("Failed to purge archived conversation history", { error: error2, cutoffIso });
|
|
298678
298652
|
throw error2;
|
|
298679
298653
|
}
|
|
298680
298654
|
}
|
|
@@ -299351,7 +299325,7 @@ async function replaceCachedRemoteConversations(db, threadId, scope, fetched) {
|
|
|
299351
299325
|
});
|
|
299352
299326
|
return true;
|
|
299353
299327
|
} catch (error2) {
|
|
299354
|
-
|
|
299328
|
+
log107.warn("Failed to cache remote conversations", error2);
|
|
299355
299329
|
return false;
|
|
299356
299330
|
}
|
|
299357
299331
|
}
|
|
@@ -299393,17 +299367,17 @@ async function readCachedRemoteConversations(db, threadId, scope) {
|
|
|
299393
299367
|
return toCachedConversation(row);
|
|
299394
299368
|
});
|
|
299395
299369
|
} catch (error2) {
|
|
299396
|
-
|
|
299370
|
+
log107.warn("Failed to read cached remote conversations", error2);
|
|
299397
299371
|
return [];
|
|
299398
299372
|
}
|
|
299399
299373
|
}
|
|
299400
|
-
var
|
|
299374
|
+
var log107, CACHE_INSERT_ROWS_PER_STATEMENT;
|
|
299401
299375
|
var init_remote_conversation_cache_database = __esm({
|
|
299402
299376
|
"src/features/remote-threads/remote-conversation-cache.database.ts"() {
|
|
299403
299377
|
"use strict";
|
|
299404
299378
|
init_dist();
|
|
299405
299379
|
init_database_writer();
|
|
299406
|
-
|
|
299380
|
+
log107 = createLogger("remote-threads.conversation-cache");
|
|
299407
299381
|
CACHE_INSERT_ROWS_PER_STATEMENT = 500;
|
|
299408
299382
|
}
|
|
299409
299383
|
});
|
|
@@ -299582,7 +299556,7 @@ var init_remote_list_fetch = __esm({
|
|
|
299582
299556
|
});
|
|
299583
299557
|
|
|
299584
299558
|
// src/features/remote-machines/remote-machines.database.ts
|
|
299585
|
-
import { randomUUID as
|
|
299559
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
299586
299560
|
function rowToRemoteMachine(row) {
|
|
299587
299561
|
return {
|
|
299588
299562
|
id: row.id,
|
|
@@ -299656,7 +299630,7 @@ async function findRemoteMachineById(id) {
|
|
|
299656
299630
|
}
|
|
299657
299631
|
async function insertRemoteMachine(input2) {
|
|
299658
299632
|
const db = await getDatabase();
|
|
299659
|
-
const id =
|
|
299633
|
+
const id = randomUUID20();
|
|
299660
299634
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
299661
299635
|
await db.execute({
|
|
299662
299636
|
sql: `INSERT INTO remote_machines (id, tunnelId, publicUrl, machineName, createdAt)
|
|
@@ -300877,7 +300851,7 @@ async function getConversationSibling(c, conversationManager, threadManager) {
|
|
|
300877
300851
|
const hasSibling = await conversationManager.hasSiblingConversation(threadId, conversationId);
|
|
300878
300852
|
return successResponse(c, { threadId, conversationId, hasSibling });
|
|
300879
300853
|
} catch (error2) {
|
|
300880
|
-
|
|
300854
|
+
log108.error("Failed to check for a sibling conversation", { error: error2 });
|
|
300881
300855
|
return caughtErrorResponse(
|
|
300882
300856
|
c,
|
|
300883
300857
|
ErrorCodes.HISTORY_FETCH_ERROR,
|
|
@@ -300886,7 +300860,7 @@ async function getConversationSibling(c, conversationManager, threadManager) {
|
|
|
300886
300860
|
);
|
|
300887
300861
|
}
|
|
300888
300862
|
}
|
|
300889
|
-
var
|
|
300863
|
+
var log108;
|
|
300890
300864
|
var init_conversations_sibling_route = __esm({
|
|
300891
300865
|
"src/features/conversations/conversations-sibling.route.ts"() {
|
|
300892
300866
|
"use strict";
|
|
@@ -300894,7 +300868,7 @@ var init_conversations_sibling_route = __esm({
|
|
|
300894
300868
|
init_route_helpers();
|
|
300895
300869
|
init_error_responses();
|
|
300896
300870
|
init_conversation_route_params();
|
|
300897
|
-
|
|
300871
|
+
log108 = createLogger("conversations.sibling");
|
|
300898
300872
|
}
|
|
300899
300873
|
});
|
|
300900
300874
|
|
|
@@ -301174,7 +301148,7 @@ async function handleGetConversationUsage(c, conversationManager, threadManager)
|
|
|
301174
301148
|
cacheByModel: Array.from(cacheByModel.values())
|
|
301175
301149
|
});
|
|
301176
301150
|
} catch (error2) {
|
|
301177
|
-
|
|
301151
|
+
log109.error("Failed to get conversation usage", { error: error2 });
|
|
301178
301152
|
return caughtErrorResponse(
|
|
301179
301153
|
c,
|
|
301180
301154
|
ErrorCodes.INTERNAL_ERROR,
|
|
@@ -301288,7 +301262,7 @@ async function handleGetThreadUsage(c, conversationManager, threadManager) {
|
|
|
301288
301262
|
lastUpdated: conversations.at(-1)?.completedAt ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
301289
301263
|
});
|
|
301290
301264
|
} catch (error2) {
|
|
301291
|
-
|
|
301265
|
+
log109.error("Failed to get thread usage", { error: error2 });
|
|
301292
301266
|
return caughtErrorResponse(
|
|
301293
301267
|
c,
|
|
301294
301268
|
ErrorCodes.INTERNAL_ERROR,
|
|
@@ -301324,7 +301298,7 @@ async function handleGetThreadUsageSummary(c, conversationManager, threadManager
|
|
|
301324
301298
|
averageTokensPerConversation: conversationCount > 0 ? Math.round((totalInputTokens + totalOutputTokens) / conversationCount) : 0
|
|
301325
301299
|
});
|
|
301326
301300
|
} catch (error2) {
|
|
301327
|
-
|
|
301301
|
+
log109.error("Failed to get thread usage summary", { error: error2 });
|
|
301328
301302
|
return caughtErrorResponse(
|
|
301329
301303
|
c,
|
|
301330
301304
|
ErrorCodes.INTERNAL_ERROR,
|
|
@@ -301333,7 +301307,7 @@ async function handleGetThreadUsageSummary(c, conversationManager, threadManager
|
|
|
301333
301307
|
);
|
|
301334
301308
|
}
|
|
301335
301309
|
}
|
|
301336
|
-
var
|
|
301310
|
+
var log109;
|
|
301337
301311
|
var init_token_usage_route = __esm({
|
|
301338
301312
|
"src/features/conversations/token-usage.route.ts"() {
|
|
301339
301313
|
"use strict";
|
|
@@ -301341,7 +301315,7 @@ var init_token_usage_route = __esm({
|
|
|
301341
301315
|
init_route_helpers();
|
|
301342
301316
|
init_error_responses();
|
|
301343
301317
|
init_conversation_route_params();
|
|
301344
|
-
|
|
301318
|
+
log109 = createLogger("conversations.token-usage");
|
|
301345
301319
|
}
|
|
301346
301320
|
});
|
|
301347
301321
|
|
|
@@ -301383,7 +301357,7 @@ async function handleGetContextBreakdown(c, conversationManager, threadManager,
|
|
|
301383
301357
|
)
|
|
301384
301358
|
);
|
|
301385
301359
|
} catch (error2) {
|
|
301386
|
-
|
|
301360
|
+
log110.error("Failed to get context breakdown", { error: error2 });
|
|
301387
301361
|
return caughtErrorResponse(
|
|
301388
301362
|
c,
|
|
301389
301363
|
ErrorCodes.INTERNAL_ERROR,
|
|
@@ -301392,7 +301366,7 @@ async function handleGetContextBreakdown(c, conversationManager, threadManager,
|
|
|
301392
301366
|
);
|
|
301393
301367
|
}
|
|
301394
301368
|
}
|
|
301395
|
-
var
|
|
301369
|
+
var log110;
|
|
301396
301370
|
var init_context_breakdown_route = __esm({
|
|
301397
301371
|
"src/features/conversations/context-breakdown.route.ts"() {
|
|
301398
301372
|
"use strict";
|
|
@@ -301401,7 +301375,7 @@ var init_context_breakdown_route = __esm({
|
|
|
301401
301375
|
init_context_breakdown();
|
|
301402
301376
|
init_dist();
|
|
301403
301377
|
init_conversation_breakdown_response();
|
|
301404
|
-
|
|
301378
|
+
log110 = createLogger("conversations.context-breakdown");
|
|
301405
301379
|
}
|
|
301406
301380
|
});
|
|
301407
301381
|
|
|
@@ -301419,7 +301393,7 @@ async function handleGetToolDefinitionsBreakdown(c, conversationManager, threadM
|
|
|
301419
301393
|
)
|
|
301420
301394
|
);
|
|
301421
301395
|
} catch (error2) {
|
|
301422
|
-
|
|
301396
|
+
log111.error("Failed to get tool definitions breakdown", { error: error2 });
|
|
301423
301397
|
return caughtErrorResponse(
|
|
301424
301398
|
c,
|
|
301425
301399
|
ErrorCodes.INTERNAL_ERROR,
|
|
@@ -301428,7 +301402,7 @@ async function handleGetToolDefinitionsBreakdown(c, conversationManager, threadM
|
|
|
301428
301402
|
);
|
|
301429
301403
|
}
|
|
301430
301404
|
}
|
|
301431
|
-
var
|
|
301405
|
+
var log111;
|
|
301432
301406
|
var init_tool_definitions_breakdown_route = __esm({
|
|
301433
301407
|
"src/features/conversations/tool-definitions-breakdown.route.ts"() {
|
|
301434
301408
|
"use strict";
|
|
@@ -301437,7 +301411,7 @@ var init_tool_definitions_breakdown_route = __esm({
|
|
|
301437
301411
|
init_context_breakdown();
|
|
301438
301412
|
init_dist();
|
|
301439
301413
|
init_conversation_breakdown_response();
|
|
301440
|
-
|
|
301414
|
+
log111 = createLogger("conversations.tool-definitions-breakdown");
|
|
301441
301415
|
}
|
|
301442
301416
|
});
|
|
301443
301417
|
|
|
@@ -301948,7 +301922,7 @@ async function decryptLoadedProviderKeys(encryptedKeys) {
|
|
|
301948
301922
|
try {
|
|
301949
301923
|
providerKeys[provider] = await decryptProviderKey(encryptedKey);
|
|
301950
301924
|
} catch (error2) {
|
|
301951
|
-
|
|
301925
|
+
log112.error(`[MetadataManager] Failed to decrypt key for ${provider}:`, error2);
|
|
301952
301926
|
providerKeys[provider] = "";
|
|
301953
301927
|
unreadableProviders.push(provider);
|
|
301954
301928
|
}
|
|
@@ -301973,7 +301947,7 @@ async function encryptKeyMap(keys) {
|
|
|
301973
301947
|
}
|
|
301974
301948
|
return encryptedKeys;
|
|
301975
301949
|
}
|
|
301976
|
-
var
|
|
301950
|
+
var log112, APP_STATE_KEYS, MetadataManager;
|
|
301977
301951
|
var init_metadata_manager = __esm({
|
|
301978
301952
|
"src/features/metadata/metadata.manager.ts"() {
|
|
301979
301953
|
"use strict";
|
|
@@ -301987,7 +301961,7 @@ var init_metadata_manager = __esm({
|
|
|
301987
301961
|
init_tarsk_debug();
|
|
301988
301962
|
init_project_settings_store();
|
|
301989
301963
|
init_project_settings_database();
|
|
301990
|
-
|
|
301964
|
+
log112 = createLogger("features.metadata.metadata.manager");
|
|
301991
301965
|
APP_STATE_KEYS = [
|
|
301992
301966
|
"selectedThreadId",
|
|
301993
301967
|
"onboardingCompleted",
|
|
@@ -302033,7 +302007,7 @@ var init_metadata_manager = __esm({
|
|
|
302033
302007
|
});
|
|
302034
302008
|
} catch (error2) {
|
|
302035
302009
|
if (logMessage) {
|
|
302036
|
-
|
|
302010
|
+
log112.error(logMessage, error2);
|
|
302037
302011
|
}
|
|
302038
302012
|
throw new Error(`${failureMessage2}: ${String(error2)}`);
|
|
302039
302013
|
}
|
|
@@ -302374,7 +302348,7 @@ var init_metadata_manager = __esm({
|
|
|
302374
302348
|
});
|
|
302375
302349
|
} catch (error2) {
|
|
302376
302350
|
if (logMessage) {
|
|
302377
|
-
|
|
302351
|
+
log112.error(logMessage, error2);
|
|
302378
302352
|
}
|
|
302379
302353
|
throw new Error(`${failureMessage2}: ${String(error2)}`);
|
|
302380
302354
|
}
|
|
@@ -302499,7 +302473,7 @@ var init_metadata_manager = __esm({
|
|
|
302499
302473
|
return { ...state5.providerKeys };
|
|
302500
302474
|
} catch (error2) {
|
|
302501
302475
|
const errorMessage7 = error2 instanceof Error ? error2.message : String(error2);
|
|
302502
|
-
|
|
302476
|
+
log112.error("[MetadataManager] Failed to get provider keys:", errorMessage7);
|
|
302503
302477
|
throw new Error(`Failed to get provider keys: ${errorMessage7}`);
|
|
302504
302478
|
}
|
|
302505
302479
|
}
|
|
@@ -302515,7 +302489,7 @@ var init_metadata_manager = __esm({
|
|
|
302515
302489
|
return state5.providerKeys[providerName] ?? "";
|
|
302516
302490
|
} catch (error2) {
|
|
302517
302491
|
const errorMessage7 = error2 instanceof Error ? error2.message : String(error2);
|
|
302518
|
-
|
|
302492
|
+
log112.error("[MetadataManager] Failed to get provider key:", errorMessage7);
|
|
302519
302493
|
throw new Error(`Failed to get provider key: ${errorMessage7}`);
|
|
302520
302494
|
}
|
|
302521
302495
|
}
|
|
@@ -302541,7 +302515,7 @@ var init_metadata_manager = __esm({
|
|
|
302541
302515
|
return { ...state5.providerEnvValues };
|
|
302542
302516
|
} catch (error2) {
|
|
302543
302517
|
const errorMessage7 = error2 instanceof Error ? error2.message : String(error2);
|
|
302544
|
-
|
|
302518
|
+
log112.error("[MetadataManager] Failed to get provider environment values:", errorMessage7);
|
|
302545
302519
|
throw new Error(`Failed to get provider environment values: ${errorMessage7}`);
|
|
302546
302520
|
}
|
|
302547
302521
|
}
|
|
@@ -302890,22 +302864,22 @@ async function handleGetModelInfo(c, modelManager) {
|
|
|
302890
302864
|
const provider = parts2[0];
|
|
302891
302865
|
const modelName = parts2.slice(1).join("/");
|
|
302892
302866
|
try {
|
|
302893
|
-
|
|
302867
|
+
log113.debug("Checking enabled models for provider", { provider, modelId, modelName });
|
|
302894
302868
|
const enabledModels = await modelManager.getEnabledModels(provider);
|
|
302895
|
-
|
|
302869
|
+
log113.debug("Loaded enabled models for provider", {
|
|
302896
302870
|
provider,
|
|
302897
302871
|
enabledModels: enabledModels.map((m2) => ({ id: m2.id, name: m2.name }))
|
|
302898
302872
|
});
|
|
302899
|
-
|
|
302873
|
+
log113.debug("Looking up model info", { provider, modelId, modelName });
|
|
302900
302874
|
if (enabledModels.length === 0) {
|
|
302901
|
-
|
|
302875
|
+
log113.debug("No enabled models for provider; falling back to available models", {
|
|
302902
302876
|
provider,
|
|
302903
302877
|
modelId,
|
|
302904
302878
|
modelName
|
|
302905
302879
|
});
|
|
302906
302880
|
try {
|
|
302907
302881
|
const availableModels = await modelManager.getAvailableModels(provider);
|
|
302908
|
-
|
|
302882
|
+
log113.debug("Loaded available models for provider", {
|
|
302909
302883
|
provider,
|
|
302910
302884
|
availableModels: availableModels.map((m2) => ({
|
|
302911
302885
|
id: m2.id,
|
|
@@ -302917,7 +302891,7 @@ async function handleGetModelInfo(c, modelManager) {
|
|
|
302917
302891
|
(m2) => m2.id === modelName || m2.id === modelId
|
|
302918
302892
|
);
|
|
302919
302893
|
if (availableModel) {
|
|
302920
|
-
|
|
302894
|
+
log113.debug("Found model in available models", {
|
|
302921
302895
|
provider,
|
|
302922
302896
|
modelId,
|
|
302923
302897
|
modelName,
|
|
@@ -302937,7 +302911,7 @@ async function handleGetModelInfo(c, modelManager) {
|
|
|
302937
302911
|
});
|
|
302938
302912
|
}
|
|
302939
302913
|
} catch (availError) {
|
|
302940
|
-
|
|
302914
|
+
log113.warn("Failed to load available models for provider", {
|
|
302941
302915
|
provider,
|
|
302942
302916
|
modelId,
|
|
302943
302917
|
modelName,
|
|
@@ -302965,16 +302939,16 @@ async function handleGetModelInfo(c, modelManager) {
|
|
|
302965
302939
|
return c.json({ error: `Failed to get models from provider "${provider}"` }, 500);
|
|
302966
302940
|
}
|
|
302967
302941
|
} catch (error2) {
|
|
302968
|
-
|
|
302942
|
+
log113.error("Failed to get model info", { error: error2 });
|
|
302969
302943
|
return c.json({ error: "Failed to retrieve model information" }, 500);
|
|
302970
302944
|
}
|
|
302971
302945
|
}
|
|
302972
|
-
var
|
|
302946
|
+
var log113;
|
|
302973
302947
|
var init_models_get_model_info_route = __esm({
|
|
302974
302948
|
"src/features/models/models-get-model-info.route.ts"() {
|
|
302975
302949
|
"use strict";
|
|
302976
302950
|
init_dist();
|
|
302977
|
-
|
|
302951
|
+
log113 = createLogger("models.info");
|
|
302978
302952
|
}
|
|
302979
302953
|
});
|
|
302980
302954
|
|
|
@@ -303122,7 +303096,7 @@ async function handleGetAvailableAllModels(c, modelManager, metadataManager) {
|
|
|
303122
303096
|
} catch (error2) {
|
|
303123
303097
|
const message = error2 instanceof Error ? error2.message : "Unknown error";
|
|
303124
303098
|
providersPayload[provider.slug] = { models: [], enabledModelIds: [] };
|
|
303125
|
-
|
|
303099
|
+
log114.error(`Failed to load models for ${provider.slug}:`, message);
|
|
303126
303100
|
}
|
|
303127
303101
|
})
|
|
303128
303102
|
);
|
|
@@ -303132,14 +303106,14 @@ async function handleGetAvailableAllModels(c, modelManager, metadataManager) {
|
|
|
303132
303106
|
return c.json({ error: message }, 500);
|
|
303133
303107
|
}
|
|
303134
303108
|
}
|
|
303135
|
-
var
|
|
303109
|
+
var log114;
|
|
303136
303110
|
var init_models_get_available_all_route = __esm({
|
|
303137
303111
|
"src/features/models/models-get-available-all.route.ts"() {
|
|
303138
303112
|
"use strict";
|
|
303139
303113
|
init_dist();
|
|
303140
303114
|
init_providers_with_keys();
|
|
303141
303115
|
init_models_filters();
|
|
303142
|
-
|
|
303116
|
+
log114 = createLogger("features.models.models-get-available-all");
|
|
303143
303117
|
}
|
|
303144
303118
|
});
|
|
303145
303119
|
|
|
@@ -303386,7 +303360,7 @@ var init_onboarding_post_reset_route = __esm({
|
|
|
303386
303360
|
});
|
|
303387
303361
|
|
|
303388
303362
|
// src/features/onboarding/onboarding-get-recommended-models.route.ts
|
|
303389
|
-
import { readFileSync as readFileSync12, existsSync as
|
|
303363
|
+
import { readFileSync as readFileSync12, existsSync as existsSync24 } from "fs";
|
|
303390
303364
|
import { join as join41, dirname as dirname13 } from "path";
|
|
303391
303365
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
303392
303366
|
function getRecommendedModelsFilePath() {
|
|
@@ -303398,7 +303372,7 @@ function getRecommendedModelsFilePath() {
|
|
|
303398
303372
|
join41(moduleDir4, "recommended-models.txt")
|
|
303399
303373
|
];
|
|
303400
303374
|
for (const candidate of candidates) {
|
|
303401
|
-
if (candidate &&
|
|
303375
|
+
if (candidate && existsSync24(candidate)) {
|
|
303402
303376
|
return candidate;
|
|
303403
303377
|
}
|
|
303404
303378
|
}
|
|
@@ -303703,7 +303677,7 @@ var init_serve_static2 = __esm({
|
|
|
303703
303677
|
serveStatic2 = (options2) => {
|
|
303704
303678
|
const root = options2.root ?? "./";
|
|
303705
303679
|
const optionPath = options2.path;
|
|
303706
|
-
const
|
|
303680
|
+
const join78 = options2.join ?? defaultJoin;
|
|
303707
303681
|
return async (c, next) => {
|
|
303708
303682
|
if (c.finalized) {
|
|
303709
303683
|
return next();
|
|
@@ -303722,12 +303696,12 @@ var init_serve_static2 = __esm({
|
|
|
303722
303696
|
return next();
|
|
303723
303697
|
}
|
|
303724
303698
|
}
|
|
303725
|
-
let path27 =
|
|
303699
|
+
let path27 = join78(
|
|
303726
303700
|
root,
|
|
303727
303701
|
!optionPath && options2.rewriteRequestPath ? options2.rewriteRequestPath(filename) : filename
|
|
303728
303702
|
);
|
|
303729
303703
|
if (options2.isDir && await options2.isDir(path27)) {
|
|
303730
|
-
path27 =
|
|
303704
|
+
path27 = join78(path27, DEFAULT_DOCUMENT);
|
|
303731
303705
|
}
|
|
303732
303706
|
const getContent2 = options2.getContent;
|
|
303733
303707
|
let content = await getContent2(path27, c);
|
|
@@ -304891,16 +304865,16 @@ async function handleGetStorageFree(c, rootFolder) {
|
|
|
304891
304865
|
const freeBytes = Number(stats.bavail) * Number(stats.bsize);
|
|
304892
304866
|
return c.json({ freeBytes: Number.isFinite(freeBytes) ? freeBytes : null });
|
|
304893
304867
|
} catch (error2) {
|
|
304894
|
-
|
|
304868
|
+
log115.warn("Free-storage probe failed for the Tarsk root folder", { rootFolder, error: error2 });
|
|
304895
304869
|
return c.json({ freeBytes: null });
|
|
304896
304870
|
}
|
|
304897
304871
|
}
|
|
304898
|
-
var
|
|
304872
|
+
var log115;
|
|
304899
304873
|
var init_projects_storage_free_route = __esm({
|
|
304900
304874
|
"src/features/projects/projects-storage-free.route.ts"() {
|
|
304901
304875
|
"use strict";
|
|
304902
304876
|
init_dist();
|
|
304903
|
-
|
|
304877
|
+
log115 = createLogger("projects.storage");
|
|
304904
304878
|
}
|
|
304905
304879
|
});
|
|
304906
304880
|
|
|
@@ -305003,14 +304977,14 @@ function validateProgram(program) {
|
|
|
305003
304977
|
}
|
|
305004
304978
|
return null;
|
|
305005
304979
|
}
|
|
305006
|
-
var
|
|
304980
|
+
var log116, OpenWithHandler;
|
|
305007
304981
|
var init_projects_open_with = __esm({
|
|
305008
304982
|
"src/features/projects/projects.open-with.ts"() {
|
|
305009
304983
|
"use strict";
|
|
305010
304984
|
init_utils();
|
|
305011
304985
|
init_open();
|
|
305012
304986
|
init_dist();
|
|
305013
|
-
|
|
304987
|
+
log116 = createLogger("projects.open");
|
|
305014
304988
|
OpenWithHandler = class {
|
|
305015
304989
|
constructor(getProject2, metadataManager) {
|
|
305016
304990
|
this.getProject = getProject2;
|
|
@@ -305019,18 +304993,18 @@ var init_projects_open_with = __esm({
|
|
|
305019
304993
|
getProject;
|
|
305020
304994
|
metadataManager;
|
|
305021
304995
|
async openWith(projectId, program) {
|
|
305022
|
-
|
|
304996
|
+
log116.info("Opening project with external program", { projectId, program });
|
|
305023
304997
|
const programError = validateProgram(program);
|
|
305024
304998
|
if (programError) {
|
|
305025
304999
|
throw new Error(programError);
|
|
305026
305000
|
}
|
|
305027
305001
|
const project = await this.getProject(projectId);
|
|
305028
305002
|
if (!project) {
|
|
305029
|
-
|
|
305003
|
+
log116.warn("Project not found while opening external program", { projectId, program });
|
|
305030
305004
|
throw new Error(`Project not found: ${projectId}`);
|
|
305031
305005
|
}
|
|
305032
305006
|
const projectPath = project.path;
|
|
305033
|
-
|
|
305007
|
+
log116.info("Launching external program for project", { program, projectPath });
|
|
305034
305008
|
if (program === "Terminal") {
|
|
305035
305009
|
await this.openTerminal(projectPath);
|
|
305036
305010
|
return;
|
|
@@ -305039,7 +305013,7 @@ var init_projects_open_with = __esm({
|
|
|
305039
305013
|
if (!appNames) {
|
|
305040
305014
|
throw new Error(`Unsupported program: ${program}`);
|
|
305041
305015
|
}
|
|
305042
|
-
|
|
305016
|
+
log116.debug("Resolved external program app names", {
|
|
305043
305017
|
projectPath,
|
|
305044
305018
|
platform: process.platform,
|
|
305045
305019
|
appNames
|
|
@@ -305048,9 +305022,9 @@ var init_projects_open_with = __esm({
|
|
|
305048
305022
|
await open_default(projectPath, {
|
|
305049
305023
|
app: { name: appNames }
|
|
305050
305024
|
});
|
|
305051
|
-
|
|
305025
|
+
log116.info("Opened project in external program", { projectId, program, projectPath });
|
|
305052
305026
|
} catch (error2) {
|
|
305053
|
-
|
|
305027
|
+
log116.error("Failed to open project in external program", {
|
|
305054
305028
|
projectId,
|
|
305055
305029
|
program,
|
|
305056
305030
|
projectPath,
|
|
@@ -305063,19 +305037,19 @@ var init_projects_open_with = __esm({
|
|
|
305063
305037
|
* Opens the OS default terminal in the specified directory.
|
|
305064
305038
|
*/
|
|
305065
305039
|
async openTerminal(projectPath) {
|
|
305066
|
-
|
|
305040
|
+
log116.info("Opening terminal for project", { platform: process.platform, projectPath });
|
|
305067
305041
|
try {
|
|
305068
305042
|
if (process.platform === "darwin") {
|
|
305069
|
-
|
|
305043
|
+
log116.debug("Detected macOS terminal launch flow", { projectPath });
|
|
305070
305044
|
const child = spawnProcess("sh", ["-c", `open -a Terminal '${projectPath}'`], {
|
|
305071
305045
|
detached: true,
|
|
305072
305046
|
stdio: "ignore"
|
|
305073
305047
|
});
|
|
305074
|
-
|
|
305048
|
+
log116.info("[openTerminal] Spawn returned, pid:", child.pid);
|
|
305075
305049
|
child.unref();
|
|
305076
|
-
|
|
305050
|
+
log116.info("[openTerminal] macOS Terminal opened successfully");
|
|
305077
305051
|
} else if (process.platform === "linux") {
|
|
305078
|
-
|
|
305052
|
+
log116.info("[openTerminal] Detected Linux - trying terminal emulators");
|
|
305079
305053
|
const terminals = [
|
|
305080
305054
|
{
|
|
305081
305055
|
cmd: "gnome-terminal",
|
|
@@ -305091,18 +305065,18 @@ var init_projects_open_with = __esm({
|
|
|
305091
305065
|
let opened = false;
|
|
305092
305066
|
for (const terminal of terminals) {
|
|
305093
305067
|
try {
|
|
305094
|
-
|
|
305068
|
+
log116.info("Attempting to spawn Linux terminal", { terminal: terminal.cmd });
|
|
305095
305069
|
const child = spawnProcess(terminal.cmd, terminal.args, {
|
|
305096
305070
|
detached: true,
|
|
305097
305071
|
stdio: "ignore"
|
|
305098
305072
|
});
|
|
305099
|
-
|
|
305073
|
+
log116.info("Linux terminal spawn returned", { terminal: terminal.cmd, pid: child.pid });
|
|
305100
305074
|
child.unref();
|
|
305101
|
-
|
|
305075
|
+
log116.info("Opened Linux terminal", { terminal: terminal.cmd });
|
|
305102
305076
|
opened = true;
|
|
305103
305077
|
break;
|
|
305104
305078
|
} catch (err) {
|
|
305105
|
-
|
|
305079
|
+
log116.info("Failed to open Linux terminal", {
|
|
305106
305080
|
terminal: terminal.cmd,
|
|
305107
305081
|
error: err instanceof Error ? err.message : String(err)
|
|
305108
305082
|
});
|
|
@@ -305115,22 +305089,22 @@ var init_projects_open_with = __esm({
|
|
|
305115
305089
|
);
|
|
305116
305090
|
}
|
|
305117
305091
|
} else if (process.platform === "win32") {
|
|
305118
|
-
|
|
305092
|
+
log116.info("[openTerminal] Detected Windows - spawning cmd.exe");
|
|
305119
305093
|
const child = spawnProcess("cmd.exe", ["/k", `cd /d "${projectPath}"`], {
|
|
305120
305094
|
detached: true,
|
|
305121
305095
|
stdio: "ignore",
|
|
305122
305096
|
shell: true
|
|
305123
305097
|
});
|
|
305124
|
-
|
|
305098
|
+
log116.info("[openTerminal] Spawn returned, pid:", child.pid);
|
|
305125
305099
|
child.unref();
|
|
305126
|
-
|
|
305100
|
+
log116.info("[openTerminal] Windows terminal opened successfully");
|
|
305127
305101
|
} else {
|
|
305128
305102
|
throw new Error(`Unsupported platform: ${process.platform}`);
|
|
305129
305103
|
}
|
|
305130
305104
|
} catch (error2) {
|
|
305131
305105
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
305132
|
-
|
|
305133
|
-
|
|
305106
|
+
log116.error("[openTerminal] Fatal error:", message);
|
|
305107
|
+
log116.error(
|
|
305134
305108
|
"[openTerminal] Error stack:",
|
|
305135
305109
|
error2 instanceof Error ? error2.stack : "No stack trace"
|
|
305136
305110
|
);
|
|
@@ -305154,7 +305128,7 @@ async function handleOpenProject(c, projectManager) {
|
|
|
305154
305128
|
const projectId = c.req.param("id");
|
|
305155
305129
|
const body = await c.req.json();
|
|
305156
305130
|
const { program } = body;
|
|
305157
|
-
|
|
305131
|
+
log117.info("Received project open request", { projectId, program });
|
|
305158
305132
|
if (!projectId) {
|
|
305159
305133
|
return errorResponse(c, ErrorCodes.INVALID_REQUEST, "Project ID is required", 400);
|
|
305160
305134
|
}
|
|
@@ -305166,9 +305140,9 @@ async function handleOpenProject(c, projectManager) {
|
|
|
305166
305140
|
if (!project) {
|
|
305167
305141
|
return errorResponse(c, ErrorCodes.PROJECT_NOT_FOUND, `Project not found: ${projectId}`, 404);
|
|
305168
305142
|
}
|
|
305169
|
-
|
|
305143
|
+
log117.debug("Opening project with external program", { projectId, program });
|
|
305170
305144
|
await projectManager.openWith(projectId, program ?? "");
|
|
305171
|
-
|
|
305145
|
+
log117.info("Opened project with external program", { projectId, program });
|
|
305172
305146
|
return successResponse(c, {
|
|
305173
305147
|
success: true,
|
|
305174
305148
|
message: `Project opened in ${program ?? "default program"}`
|
|
@@ -305178,7 +305152,7 @@ async function handleOpenProject(c, projectManager) {
|
|
|
305178
305152
|
return errorResponse(c, ErrorCodes.OPEN_PROGRAM_ERROR, errorMessage7, 422);
|
|
305179
305153
|
}
|
|
305180
305154
|
}
|
|
305181
|
-
var
|
|
305155
|
+
var log117;
|
|
305182
305156
|
var init_projects_open_route = __esm({
|
|
305183
305157
|
"src/features/projects/projects-open.route.ts"() {
|
|
305184
305158
|
"use strict";
|
|
@@ -305186,7 +305160,7 @@ var init_projects_open_route = __esm({
|
|
|
305186
305160
|
init_projects_open_with();
|
|
305187
305161
|
init_route_helpers();
|
|
305188
305162
|
init_error_responses();
|
|
305189
|
-
|
|
305163
|
+
log117 = createLogger("projects.open");
|
|
305190
305164
|
}
|
|
305191
305165
|
});
|
|
305192
305166
|
|
|
@@ -305903,7 +305877,7 @@ async function inferCommand(options2, spec) {
|
|
|
305903
305877
|
return { command: command2, source: "ai" };
|
|
305904
305878
|
} catch (error2) {
|
|
305905
305879
|
const details = error2 instanceof Error ? error2.message ?? String(error2) : String(error2);
|
|
305906
|
-
|
|
305880
|
+
log118.error(`[project-command-ai] Failed to infer ${spec.label}:`, details);
|
|
305907
305881
|
return {
|
|
305908
305882
|
command: null,
|
|
305909
305883
|
reason: `Could not generate a ${spec.label}: ${details}`
|
|
@@ -305916,7 +305890,7 @@ function inferRunCommandWithAi(options2) {
|
|
|
305916
305890
|
function inferSetupScriptWithAi(options2) {
|
|
305917
305891
|
return inferCommand(options2, SETUP_SCRIPT_SPEC);
|
|
305918
305892
|
}
|
|
305919
|
-
var
|
|
305893
|
+
var log118, NO_COMMAND_MODEL_REASON, RUN_COMMAND_SPEC, SETUP_SCRIPT_SPEC;
|
|
305920
305894
|
var init_project_command_ai = __esm({
|
|
305921
305895
|
"src/core/project-command-ai.ts"() {
|
|
305922
305896
|
"use strict";
|
|
@@ -305924,7 +305898,7 @@ var init_project_command_ai = __esm({
|
|
|
305924
305898
|
init_spend_record();
|
|
305925
305899
|
init_inline_model();
|
|
305926
305900
|
init_project_command_context();
|
|
305927
|
-
|
|
305901
|
+
log118 = createLogger("core.project-command-ai");
|
|
305928
305902
|
NO_COMMAND_MODEL_REASON = "No AI model is available. Pick a model in the chat or set a default model alias, then try again.";
|
|
305929
305903
|
RUN_COMMAND_SPEC = {
|
|
305930
305904
|
label: "run command",
|
|
@@ -306067,7 +306041,7 @@ async function handleStartRun(c, projectManager) {
|
|
|
306067
306041
|
const projectId = c.req.param("id");
|
|
306068
306042
|
const body = await c.req.json();
|
|
306069
306043
|
const { threadId } = body;
|
|
306070
|
-
|
|
306044
|
+
log119.info("Starting project run route", { projectId, threadId });
|
|
306071
306045
|
if (!projectId) {
|
|
306072
306046
|
return errorResponse(c, ErrorCodes.INVALID_REQUEST, "Project ID is required", 400);
|
|
306073
306047
|
}
|
|
@@ -306143,7 +306117,7 @@ async function handleCheckRunning(c, projectManager) {
|
|
|
306143
306117
|
);
|
|
306144
306118
|
}
|
|
306145
306119
|
}
|
|
306146
|
-
var
|
|
306120
|
+
var log119;
|
|
306147
306121
|
var init_projects_run_route = __esm({
|
|
306148
306122
|
"src/features/projects/projects-run.route.ts"() {
|
|
306149
306123
|
"use strict";
|
|
@@ -306153,7 +306127,7 @@ var init_projects_run_route = __esm({
|
|
|
306153
306127
|
init_project_command_suggestion();
|
|
306154
306128
|
init_projects_command_suggest_shared();
|
|
306155
306129
|
init_dist();
|
|
306156
|
-
|
|
306130
|
+
log119 = createLogger("features.projects.projects-run");
|
|
306157
306131
|
}
|
|
306158
306132
|
});
|
|
306159
306133
|
|
|
@@ -306457,7 +306431,7 @@ var init_projects_package_scripts_route = __esm({
|
|
|
306457
306431
|
|
|
306458
306432
|
// src/features/ai-files/ai-files.ops.ts
|
|
306459
306433
|
import { access as access6, mkdir as mkdir8, readFile as readFile20, rm as rm6, writeFile as writeFile12, stat as stat9 } from "fs/promises";
|
|
306460
|
-
import { existsSync as
|
|
306434
|
+
import { existsSync as existsSync25 } from "fs";
|
|
306461
306435
|
import { join as join47 } from "path";
|
|
306462
306436
|
function validateFilePath(rootPath, filePath) {
|
|
306463
306437
|
if (!filePath) return null;
|
|
@@ -306547,7 +306521,7 @@ async function deleteAIFileOrFolder(rootPath, filePath) {
|
|
|
306547
306521
|
async function setSkillModelInvocation(rootPath, name, disableModelInvocation) {
|
|
306548
306522
|
const skillFileRelPath = join47(".agents", "skills", name, "SKILL.md");
|
|
306549
306523
|
const skillFileAbsPath = join47(rootPath, skillFileRelPath);
|
|
306550
|
-
if (!
|
|
306524
|
+
if (!existsSync25(skillFileAbsPath)) {
|
|
306551
306525
|
return {
|
|
306552
306526
|
ok: false,
|
|
306553
306527
|
error: { status: 404, code: "NOT_FOUND", message: `Skill not found: ${name}` }
|
|
@@ -306567,7 +306541,7 @@ async function setSkillModelInvocation(rootPath, name, disableModelInvocation) {
|
|
|
306567
306541
|
async function createMarkdownDirectory(rootPath, relativeDir, fileName, conflictMessage, content) {
|
|
306568
306542
|
const absDir = join47(rootPath, relativeDir);
|
|
306569
306543
|
const fileRelPath = join47(relativeDir, fileName);
|
|
306570
|
-
if (
|
|
306544
|
+
if (existsSync25(absDir)) {
|
|
306571
306545
|
return {
|
|
306572
306546
|
ok: false,
|
|
306573
306547
|
error: { status: 409, code: "CONFLICT", message: conflictMessage }
|
|
@@ -306625,10 +306599,10 @@ var init_ai_files_ops = __esm({
|
|
|
306625
306599
|
// src/features/ai-files/ai-files.tree.ts
|
|
306626
306600
|
import { readdir as readdir12, readFile as readFile21 } from "fs/promises";
|
|
306627
306601
|
import { join as join48, extname as extname6, basename as basename9 } from "path";
|
|
306628
|
-
import { existsSync as
|
|
306602
|
+
import { existsSync as existsSync26 } from "fs";
|
|
306629
306603
|
async function readSkillMetadata(skillDir) {
|
|
306630
306604
|
const skillFile = join48(skillDir, "SKILL.md");
|
|
306631
|
-
if (!
|
|
306605
|
+
if (!existsSync26(skillFile)) {
|
|
306632
306606
|
return null;
|
|
306633
306607
|
}
|
|
306634
306608
|
try {
|
|
@@ -306691,7 +306665,7 @@ async function buildAIFileTree(projectPath) {
|
|
|
306691
306665
|
for (const { key, label } of agentsFolders) {
|
|
306692
306666
|
const relPath = join48(".agents", key);
|
|
306693
306667
|
const absPath = join48(projectPath, relPath);
|
|
306694
|
-
const exists =
|
|
306668
|
+
const exists = existsSync26(absPath);
|
|
306695
306669
|
if (exists) {
|
|
306696
306670
|
const children = await buildAIFileNodes(absPath, relPath, "full");
|
|
306697
306671
|
if (key === "skills") {
|
|
@@ -308981,8 +308955,8 @@ var require_adm_zip = __commonJS({
|
|
|
308981
308955
|
return null;
|
|
308982
308956
|
}
|
|
308983
308957
|
function fixPath(zipPath) {
|
|
308984
|
-
const { join:
|
|
308985
|
-
return
|
|
308958
|
+
const { join: join78, normalize: normalize5, sep: sep11 } = pth.posix;
|
|
308959
|
+
return join78(pth.isAbsolute(zipPath) ? "/" : ".", normalize5(sep11 + zipPath.split("\\").join(sep11) + sep11));
|
|
308986
308960
|
}
|
|
308987
308961
|
function filenameFilter(filterfn) {
|
|
308988
308962
|
if (filterfn instanceof RegExp) {
|
|
@@ -309736,8 +309710,8 @@ function normalizePluginName(input2) {
|
|
|
309736
309710
|
function normalizeCommandToken(token) {
|
|
309737
309711
|
const trimmed = (token ?? "").trim();
|
|
309738
309712
|
if (!trimmed) return null;
|
|
309739
|
-
const
|
|
309740
|
-
if (!
|
|
309713
|
+
const isAbsolute13 = trimmed.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(trimmed);
|
|
309714
|
+
if (!isAbsolute13) return trimmed;
|
|
309741
309715
|
const parts2 = trimmed.split(/[\\/]/).filter(Boolean);
|
|
309742
309716
|
const bare = parts2[parts2.length - 1];
|
|
309743
309717
|
return bare || null;
|
|
@@ -309821,7 +309795,7 @@ async function addSourceCodeToZip(zip, projectPath) {
|
|
|
309821
309795
|
try {
|
|
309822
309796
|
gitRoot = await getGitRoot(projectPath);
|
|
309823
309797
|
} catch {
|
|
309824
|
-
|
|
309798
|
+
log120.warn("[plugin] Not a git repository; skipping source code.");
|
|
309825
309799
|
return;
|
|
309826
309800
|
}
|
|
309827
309801
|
const result = await runGitCommandTimed("plugin-export-source", gitRoot, [
|
|
@@ -309831,7 +309805,7 @@ async function addSourceCodeToZip(zip, projectPath) {
|
|
|
309831
309805
|
"--exclude-standard"
|
|
309832
309806
|
]);
|
|
309833
309807
|
if (result.code !== 0) {
|
|
309834
|
-
|
|
309808
|
+
log120.warn(`[plugin] git ls-files failed; skipping source code: ${result.stderr.trim()}`);
|
|
309835
309809
|
return;
|
|
309836
309810
|
}
|
|
309837
309811
|
const files = result.stdout.split("\n").filter((line) => line.length > 0);
|
|
@@ -309842,7 +309816,7 @@ async function addSourceCodeToZip(zip, projectPath) {
|
|
|
309842
309816
|
} catch {
|
|
309843
309817
|
}
|
|
309844
309818
|
}
|
|
309845
|
-
|
|
309819
|
+
log120.info(`[plugin] Included ${files.length} source file(s) from ${gitRoot}`);
|
|
309846
309820
|
}
|
|
309847
309821
|
async function buildPluginZip(req) {
|
|
309848
309822
|
const zip = new import_adm_zip.default();
|
|
@@ -309856,20 +309830,20 @@ async function buildPluginZip(req) {
|
|
|
309856
309830
|
try {
|
|
309857
309831
|
const skillStat = await stat10(skillDir);
|
|
309858
309832
|
if (!skillStat.isDirectory()) {
|
|
309859
|
-
|
|
309833
|
+
log120.warn(`[plugin] Skipping non-directory skill entry: ${skillName}`);
|
|
309860
309834
|
continue;
|
|
309861
309835
|
}
|
|
309862
309836
|
const skillFileStat = await stat10(join49(skillDir, "SKILL.md"));
|
|
309863
309837
|
if (!skillFileStat.isFile()) {
|
|
309864
|
-
|
|
309838
|
+
log120.warn(`[plugin] Skipping skill folder without SKILL.md: ${skillName}`);
|
|
309865
309839
|
continue;
|
|
309866
309840
|
}
|
|
309867
309841
|
const added = await addSkillToZip(zip, skillDir, skillName);
|
|
309868
309842
|
if (added) {
|
|
309869
|
-
|
|
309843
|
+
log120.info(`[plugin] Included skill ${skillName}`);
|
|
309870
309844
|
}
|
|
309871
309845
|
} catch {
|
|
309872
|
-
|
|
309846
|
+
log120.warn(`[plugin] Skipping missing/invalid skill folder: ${skillName}`);
|
|
309873
309847
|
}
|
|
309874
309848
|
}
|
|
309875
309849
|
if (req.includeSourceCode) {
|
|
@@ -309893,7 +309867,7 @@ async function uploadPluginZip(zipBuffer, token) {
|
|
|
309893
309867
|
body = null;
|
|
309894
309868
|
}
|
|
309895
309869
|
const locationHeader = response.headers.get("location");
|
|
309896
|
-
|
|
309870
|
+
log120.info(
|
|
309897
309871
|
`plugin upload response: status=${response.status} location=${locationHeader ?? "none"} body=${JSON.stringify(body)}`
|
|
309898
309872
|
);
|
|
309899
309873
|
if (response.status === 422) {
|
|
@@ -309926,7 +309900,7 @@ function normalizeUploadResult(body) {
|
|
|
309926
309900
|
warnings: Array.isArray(result.warnings) ? result.warnings : []
|
|
309927
309901
|
};
|
|
309928
309902
|
}
|
|
309929
|
-
var import_adm_zip,
|
|
309903
|
+
var import_adm_zip, log120, PACKAGES_BASE_URL, PLUGIN_SCHEMA, MCP_SCHEMA, PLUGIN_RESERVED_ENV, PluginUploadError;
|
|
309930
309904
|
var init_plugin_export_ops = __esm({
|
|
309931
309905
|
"src/features/plugin-export/plugin-export.ops.ts"() {
|
|
309932
309906
|
"use strict";
|
|
@@ -309935,7 +309909,7 @@ var init_plugin_export_ops = __esm({
|
|
|
309935
309909
|
init_mcp_config();
|
|
309936
309910
|
init_git_utils();
|
|
309937
309911
|
init_git_subprocess_timing();
|
|
309938
|
-
|
|
309912
|
+
log120 = createLogger("features.plugin-export");
|
|
309939
309913
|
PACKAGES_BASE_URL = "https://packages.tarsk.io";
|
|
309940
309914
|
PLUGIN_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
309941
309915
|
MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
|
|
@@ -310133,9 +310107,9 @@ async function sweepStalePluginStagingDirs(projectPath, minimumAgeMs = STALE_STA
|
|
|
310133
310107
|
const age = Math.max(0, now - info.mtimeMs);
|
|
310134
310108
|
if (age < minimumAgeMs) return;
|
|
310135
310109
|
await rm7(dirPath, { recursive: true, force: true });
|
|
310136
|
-
|
|
310110
|
+
log121.warn("Removed stale plugin import staging directory", { path: dirPath });
|
|
310137
310111
|
} catch (error2) {
|
|
310138
|
-
|
|
310112
|
+
log121.warn("Failed to remove stale plugin import staging directory", {
|
|
310139
310113
|
path: dirPath,
|
|
310140
310114
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
310141
310115
|
});
|
|
@@ -310246,21 +310220,21 @@ async function installPluginImport(projectPath, archive3, selectedSkills, select
|
|
|
310246
310220
|
}
|
|
310247
310221
|
} finally {
|
|
310248
310222
|
await rm7(stagingRoot, { recursive: true, force: true }).catch((error2) => {
|
|
310249
|
-
|
|
310223
|
+
log121.warn("Failed to remove plugin import staging directory", {
|
|
310250
310224
|
path: stagingRoot,
|
|
310251
310225
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
310252
310226
|
});
|
|
310253
310227
|
});
|
|
310254
310228
|
}
|
|
310255
310229
|
}
|
|
310256
|
-
var import_adm_zip2,
|
|
310230
|
+
var import_adm_zip2, log121, MAX_ARCHIVE_BYTES, MAX_FILES, MAX_FILE_BYTES, MAX_UNCOMPRESSED_BYTES, PLUGIN_FETCH_TIMEOUT_MS, PRIVATE_IPV6_PREFIXES, STAGING_PREFIX, STALE_STAGING_MIN_AGE_MS;
|
|
310257
310231
|
var init_plugin_import_ops = __esm({
|
|
310258
310232
|
"src/features/plugin-export/plugin-import.ops.ts"() {
|
|
310259
310233
|
"use strict";
|
|
310260
310234
|
import_adm_zip2 = __toESM(require_adm_zip(), 1);
|
|
310261
310235
|
init_dist();
|
|
310262
310236
|
init_mcp_config();
|
|
310263
|
-
|
|
310237
|
+
log121 = createLogger("features.plugin-export.plugin-import");
|
|
310264
310238
|
MAX_ARCHIVE_BYTES = 25 * 1024 * 1024;
|
|
310265
310239
|
MAX_FILES = 500;
|
|
310266
310240
|
MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
@@ -310315,7 +310289,7 @@ async function readAuthToken() {
|
|
|
310315
310289
|
const session = await getState(db, KEY_SESSION);
|
|
310316
310290
|
return typeof session?.token === "string" && session.token.length > 0 ? session.token : null;
|
|
310317
310291
|
} catch (error2) {
|
|
310318
|
-
|
|
310292
|
+
log122.error("[plugin] Failed to read auth session:", error2);
|
|
310319
310293
|
return null;
|
|
310320
310294
|
}
|
|
310321
310295
|
}
|
|
@@ -310335,7 +310309,7 @@ async function handlePluginExport(c, projectManager) {
|
|
|
310335
310309
|
manifest
|
|
310336
310310
|
});
|
|
310337
310311
|
const filename = `${normalizePluginName(manifest.name)}.zip`;
|
|
310338
|
-
|
|
310312
|
+
log122.info(`[plugin] Exporting ${filename}`);
|
|
310339
310313
|
const encoded = encodeURIComponent(filename);
|
|
310340
310314
|
return new Response(new Uint8Array(zipBuffer), {
|
|
310341
310315
|
status: 200,
|
|
@@ -310347,7 +310321,7 @@ async function handlePluginExport(c, projectManager) {
|
|
|
310347
310321
|
});
|
|
310348
310322
|
} catch (error2) {
|
|
310349
310323
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
310350
|
-
|
|
310324
|
+
log122.error("[plugin] Failed to export plugin:", error2);
|
|
310351
310325
|
return errorResponse(c, ErrorCodes.INTERNAL_ERROR, `Failed to export plugin: ${message}`, 500);
|
|
310352
310326
|
}
|
|
310353
310327
|
}
|
|
@@ -310388,7 +310362,7 @@ async function handlePluginImport(c, projectManager, threadManager) {
|
|
|
310388
310362
|
try {
|
|
310389
310363
|
await discoverMCPServerTools(resolved.project.path, serverName);
|
|
310390
310364
|
} catch (error2) {
|
|
310391
|
-
|
|
310365
|
+
log122.warn("MCP discovery failed after plugin import", {
|
|
310392
310366
|
serverName,
|
|
310393
310367
|
error: error2 instanceof Error ? error2.message : String(error2)
|
|
310394
310368
|
});
|
|
@@ -310422,7 +310396,7 @@ async function handlePluginUpload(c, projectManager) {
|
|
|
310422
310396
|
});
|
|
310423
310397
|
const filename = `${normalizePluginName(manifest.name)}.zip`;
|
|
310424
310398
|
const result = await uploadPluginZip(zipBuffer, token);
|
|
310425
|
-
|
|
310399
|
+
log122.info(
|
|
310426
310400
|
`[plugin] Uploaded ${filename}: valid=${result.valid}, errors=${result.errors.length}, warnings=${result.warnings.length}`
|
|
310427
310401
|
);
|
|
310428
310402
|
return c.json({
|
|
@@ -310435,16 +310409,16 @@ async function handlePluginUpload(c, projectManager) {
|
|
|
310435
310409
|
});
|
|
310436
310410
|
} catch (error2) {
|
|
310437
310411
|
if (error2 instanceof PluginUploadError) {
|
|
310438
|
-
|
|
310412
|
+
log122.error(`[plugin] Upload failed (${error2.status}):`, error2.message);
|
|
310439
310413
|
const status = error2.status >= 400 && error2.status < 500 ? error2.status : 502;
|
|
310440
310414
|
return errorResponse(c, ErrorCodes.INTERNAL_ERROR, error2.message, status);
|
|
310441
310415
|
}
|
|
310442
310416
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
310443
|
-
|
|
310417
|
+
log122.error("[plugin] Failed to upload plugin:", error2);
|
|
310444
310418
|
return errorResponse(c, ErrorCodes.INTERNAL_ERROR, `Failed to upload plugin: ${message}`, 500);
|
|
310445
310419
|
}
|
|
310446
310420
|
}
|
|
310447
|
-
var
|
|
310421
|
+
var log122, KEY_SESSION;
|
|
310448
310422
|
var init_plugin_export_routes = __esm({
|
|
310449
310423
|
"src/features/plugin-export/plugin-export.routes.ts"() {
|
|
310450
310424
|
"use strict";
|
|
@@ -310457,7 +310431,7 @@ var init_plugin_export_routes = __esm({
|
|
|
310457
310431
|
init_plugin_export_ops();
|
|
310458
310432
|
init_plugin_import_ops();
|
|
310459
310433
|
init_mcp_tools();
|
|
310460
|
-
|
|
310434
|
+
log122 = createLogger("features.plugin-export.route");
|
|
310461
310435
|
KEY_SESSION = "AuthSession";
|
|
310462
310436
|
}
|
|
310463
310437
|
});
|
|
@@ -310838,6 +310812,79 @@ var init_projects_replace_unique_text_route = __esm({
|
|
|
310838
310812
|
}
|
|
310839
310813
|
});
|
|
310840
310814
|
|
|
310815
|
+
// src/features/projects/projects-export-tool-definitions.route.ts
|
|
310816
|
+
import { isAbsolute as isAbsolute8, join as join51, relative as relative12, sep as sep7 } from "node:path";
|
|
310817
|
+
import { lstat as lstat2, mkdir as mkdir10, realpath as realpath2 } from "node:fs/promises";
|
|
310818
|
+
async function ensureSafeProjectSkillsDir(projectPath) {
|
|
310819
|
+
const projectRoot = await realpath2(projectPath);
|
|
310820
|
+
let directory = projectRoot;
|
|
310821
|
+
for (const segment of [".agents", "skills"]) {
|
|
310822
|
+
const candidate = join51(directory, segment);
|
|
310823
|
+
try {
|
|
310824
|
+
await mkdir10(candidate);
|
|
310825
|
+
} catch (error2) {
|
|
310826
|
+
if (error2.code !== "EEXIST") throw error2;
|
|
310827
|
+
}
|
|
310828
|
+
const stat17 = await lstat2(candidate);
|
|
310829
|
+
const resolved = await realpath2(candidate);
|
|
310830
|
+
const relativePath = relative12(projectRoot, resolved);
|
|
310831
|
+
if (stat17.isSymbolicLink() || !stat17.isDirectory() || relativePath === ".." || relativePath.startsWith(`..${sep7}`) || isAbsolute8(relativePath)) {
|
|
310832
|
+
throw new UnsafeExportPathError();
|
|
310833
|
+
}
|
|
310834
|
+
directory = resolved;
|
|
310835
|
+
}
|
|
310836
|
+
return directory;
|
|
310837
|
+
}
|
|
310838
|
+
async function handleExportToolDefinitions(c, projectManager) {
|
|
310839
|
+
const resolved = await requireProject(c, projectManager);
|
|
310840
|
+
if (!resolved.ok) return resolved.response;
|
|
310841
|
+
const bundledRoot = getBundledSkillsDir();
|
|
310842
|
+
if (!bundledRoot) {
|
|
310843
|
+
return errorResponse(
|
|
310844
|
+
c,
|
|
310845
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
310846
|
+
"Bundled tool definitions are not available",
|
|
310847
|
+
500
|
|
310848
|
+
);
|
|
310849
|
+
}
|
|
310850
|
+
try {
|
|
310851
|
+
const projectSkillsDir = await ensureSafeProjectSkillsDir(resolved.project.path);
|
|
310852
|
+
const result = await exportToolSkillsFrom2(bundledRoot, projectSkillsDir);
|
|
310853
|
+
return c.json({
|
|
310854
|
+
copied: result.copied,
|
|
310855
|
+
overwritten: result.overwritten,
|
|
310856
|
+
left: result.left,
|
|
310857
|
+
editableToolSkills: result.editableToolSkills,
|
|
310858
|
+
skipped: result.skipped
|
|
310859
|
+
});
|
|
310860
|
+
} catch (error2) {
|
|
310861
|
+
if (error2 instanceof UnsafeExportPathError) {
|
|
310862
|
+
return errorResponse(c, ErrorCodes.INVALID_REQUEST, error2.message, 400);
|
|
310863
|
+
}
|
|
310864
|
+
log123.error("Failed to export tool definitions", error2);
|
|
310865
|
+
return errorResponse(c, ErrorCodes.INTERNAL_ERROR, "Failed to export tool definitions", 500);
|
|
310866
|
+
}
|
|
310867
|
+
}
|
|
310868
|
+
var log123, UnsafeExportPathError;
|
|
310869
|
+
var init_projects_export_tool_definitions_route = __esm({
|
|
310870
|
+
"src/features/projects/projects-export-tool-definitions.route.ts"() {
|
|
310871
|
+
"use strict";
|
|
310872
|
+
init_dist();
|
|
310873
|
+
init_project_route_params();
|
|
310874
|
+
init_route_helpers();
|
|
310875
|
+
init_error_responses();
|
|
310876
|
+
init_skills_paths();
|
|
310877
|
+
init_export_tool_skills();
|
|
310878
|
+
log123 = createLogger("features.projects.export-tool-definitions");
|
|
310879
|
+
UnsafeExportPathError = class extends Error {
|
|
310880
|
+
constructor() {
|
|
310881
|
+
super("Tool definitions cannot be exported through repository symlinks");
|
|
310882
|
+
this.name = "UnsafeExportPathError";
|
|
310883
|
+
}
|
|
310884
|
+
};
|
|
310885
|
+
}
|
|
310886
|
+
});
|
|
310887
|
+
|
|
310841
310888
|
// ../node_modules/.bun/ws@8.22.0/node_modules/ws/lib/constants.js
|
|
310842
310889
|
var require_constants9 = __commonJS({
|
|
310843
310890
|
"../node_modules/.bun/ws@8.22.0/node_modules/ws/lib/constants.js"(exports2, module2) {
|
|
@@ -314886,6 +314933,9 @@ function createProjectRoutes(projectManager, threadManager, metadataManager, upg
|
|
|
314886
314933
|
router.put("/:id/ai-files/skill/model-invocation", async (c) => {
|
|
314887
314934
|
return handleSetSkillModelInvocation(c, projectManager);
|
|
314888
314935
|
});
|
|
314936
|
+
router.post("/:id/tool-definitions/export", async (c) => {
|
|
314937
|
+
return handleExportToolDefinitions(c, projectManager);
|
|
314938
|
+
});
|
|
314889
314939
|
router.post("/:id/plugin-export", async (c) => {
|
|
314890
314940
|
return handlePluginExport(c, projectManager);
|
|
314891
314941
|
});
|
|
@@ -314950,12 +315000,13 @@ var init_projects_routes = __esm({
|
|
|
314950
315000
|
init_projects_env_vars_route();
|
|
314951
315001
|
init_projects_window_state_route();
|
|
314952
315002
|
init_projects_replace_unique_text_route();
|
|
315003
|
+
init_projects_export_tool_definitions_route();
|
|
314953
315004
|
init_projects_terminal_route();
|
|
314954
315005
|
}
|
|
314955
315006
|
});
|
|
314956
315007
|
|
|
314957
315008
|
// src/features/git/git-auth.broker.ts
|
|
314958
|
-
import { randomUUID as
|
|
315009
|
+
import { randomUUID as randomUUID21 } from "crypto";
|
|
314959
315010
|
var GitAuthBroker;
|
|
314960
315011
|
var init_git_auth_broker = __esm({
|
|
314961
315012
|
"src/features/git/git-auth.broker.ts"() {
|
|
@@ -314967,7 +315018,7 @@ var init_git_auth_broker = __esm({
|
|
|
314967
315018
|
* with the credential, or null when the user cancelled the dialog.
|
|
314968
315019
|
*/
|
|
314969
315020
|
begin(context2) {
|
|
314970
|
-
const authId =
|
|
315021
|
+
const authId = randomUUID21();
|
|
314971
315022
|
const credential = new Promise((resolve24) => {
|
|
314972
315023
|
this.pending.set(authId, {
|
|
314973
315024
|
resolve: (value) => {
|
|
@@ -315395,10 +315446,10 @@ var init_thread_run_stop = __esm({
|
|
|
315395
315446
|
});
|
|
315396
315447
|
|
|
315397
315448
|
// src/features/projects/projects.creator.ts
|
|
315398
|
-
import { randomUUID as
|
|
315399
|
-
import { basename as basename10, dirname as dirname16, join as
|
|
315449
|
+
import { randomUUID as randomUUID22 } from "crypto";
|
|
315450
|
+
import { basename as basename10, dirname as dirname16, join as join52, relative as relative13, resolve as resolvePath6, sep as sep8 } from "path";
|
|
315400
315451
|
import { realpathSync as realpathSync2 } from "fs";
|
|
315401
|
-
import { mkdir as
|
|
315452
|
+
import { mkdir as mkdir11, rm as rm8, stat as stat12, writeFile as writeFile15 } from "fs/promises";
|
|
315402
315453
|
async function loadUtils() {
|
|
315403
315454
|
if (utilsLoaded) return;
|
|
315404
315455
|
utilsLoaded = true;
|
|
@@ -315570,11 +315621,11 @@ var init_projects_creator = __esm({
|
|
|
315570
315621
|
relPath = entryName;
|
|
315571
315622
|
}
|
|
315572
315623
|
if (!relPath) continue;
|
|
315573
|
-
const output2 =
|
|
315574
|
-
if (
|
|
315624
|
+
const output2 = join52(folderPath, ...relPath.split("/"));
|
|
315625
|
+
if (relative13(folderPath, output2).startsWith(`..${sep8}`)) {
|
|
315575
315626
|
throw new Error("Unsafe path in zip archive");
|
|
315576
315627
|
}
|
|
315577
|
-
await
|
|
315628
|
+
await mkdir11(dirname16(output2), { recursive: true });
|
|
315578
315629
|
await writeFile15(output2, entry.getData());
|
|
315579
315630
|
}
|
|
315580
315631
|
}
|
|
@@ -315731,11 +315782,11 @@ var init_projects_creator = __esm({
|
|
|
315731
315782
|
}
|
|
315732
315783
|
const uniqueFolderName = await this.ensureUniqueFolderName(baseFolderName);
|
|
315733
315784
|
return {
|
|
315734
|
-
projectId:
|
|
315785
|
+
projectId: randomUUID22(),
|
|
315735
315786
|
projectName,
|
|
315736
|
-
initialThreadId:
|
|
315787
|
+
initialThreadId: randomUUID22(),
|
|
315737
315788
|
initialThreadTitle: generateRandomHyphenatedName(),
|
|
315738
|
-
firstThreadPath:
|
|
315789
|
+
firstThreadPath: join52(this.rootFolder, uniqueFolderName)
|
|
315739
315790
|
};
|
|
315740
315791
|
}
|
|
315741
315792
|
async persistCreatedProject(project, initialThread) {
|
|
@@ -315871,8 +315922,8 @@ var init_projects_creator = __esm({
|
|
|
315871
315922
|
};
|
|
315872
315923
|
return;
|
|
315873
315924
|
}
|
|
315874
|
-
const projectId =
|
|
315875
|
-
const initialThreadId =
|
|
315925
|
+
const projectId = randomUUID22();
|
|
315926
|
+
const initialThreadId = randomUUID22();
|
|
315876
315927
|
const initialThreadTitle = generateRandomHyphenatedName();
|
|
315877
315928
|
this.processingStateManager?.setProcessing(initialThreadId);
|
|
315878
315929
|
try {
|
|
@@ -315957,8 +316008,8 @@ var init_projects_creator = __esm({
|
|
|
315957
316008
|
};
|
|
315958
316009
|
return;
|
|
315959
316010
|
}
|
|
315960
|
-
const projectId =
|
|
315961
|
-
const initialThreadId =
|
|
316011
|
+
const projectId = randomUUID22();
|
|
316012
|
+
const initialThreadId = randomUUID22();
|
|
315962
316013
|
const initialThreadTitle = generateRandomHyphenatedName();
|
|
315963
316014
|
const { signal } = options2 ?? {};
|
|
315964
316015
|
let folderPath;
|
|
@@ -315966,14 +316017,14 @@ var init_projects_creator = __esm({
|
|
|
315966
316017
|
this.processingStateManager?.setProcessing(initialThreadId);
|
|
315967
316018
|
try {
|
|
315968
316019
|
const uniqueFolderName = await this.ensureUniqueFolderName(names3.folderName);
|
|
315969
|
-
folderPath =
|
|
316020
|
+
folderPath = join52(this.rootFolder, uniqueFolderName);
|
|
315970
316021
|
yield {
|
|
315971
316022
|
type: "progress",
|
|
315972
316023
|
message: `Creating folder "${uniqueFolderName}"...`,
|
|
315973
316024
|
threadId: initialThreadId,
|
|
315974
316025
|
projectId
|
|
315975
316026
|
};
|
|
315976
|
-
await
|
|
316027
|
+
await mkdir11(folderPath, { recursive: false });
|
|
315977
316028
|
await this.gitManager.initRepository(folderPath);
|
|
315978
316029
|
await this.gitManager.ensureInitialCommit(folderPath);
|
|
315979
316030
|
const project = {
|
|
@@ -316070,7 +316121,7 @@ var init_projects_creator = __esm({
|
|
|
316070
316121
|
return { message: "Could not derive a valid folder name from the zip" };
|
|
316071
316122
|
}
|
|
316072
316123
|
if (!overrideProjectId) {
|
|
316073
|
-
return { target: { projectId:
|
|
316124
|
+
return { target: { projectId: randomUUID22(), projectName, folderName, isOverride: false } };
|
|
316074
316125
|
}
|
|
316075
316126
|
const result = await this.teardownOverriddenProject(overrideProjectId, projectName);
|
|
316076
316127
|
if (!result.ok) {
|
|
@@ -316088,21 +316139,21 @@ var init_projects_creator = __esm({
|
|
|
316088
316139
|
/** Extracts the zip, initializes git, and persists the project + initial thread. */
|
|
316089
316140
|
async *importZipProject(zip, target) {
|
|
316090
316141
|
const { folderName, projectId, projectName, isOverride } = target;
|
|
316091
|
-
const initialThreadId =
|
|
316142
|
+
const initialThreadId = randomUUID22();
|
|
316092
316143
|
const initialThreadTitle = generateRandomHyphenatedName();
|
|
316093
316144
|
let folderPath;
|
|
316094
316145
|
let projectMetadataSaved = false;
|
|
316095
316146
|
this.processingStateManager?.setProcessing(initialThreadId);
|
|
316096
316147
|
try {
|
|
316097
316148
|
const uniqueFolderName = await this.ensureUniqueFolderName(folderName);
|
|
316098
|
-
folderPath =
|
|
316149
|
+
folderPath = join52(this.rootFolder, uniqueFolderName);
|
|
316099
316150
|
yield {
|
|
316100
316151
|
type: "progress",
|
|
316101
316152
|
message: isOverride ? `Replacing project "${projectName}" from zip...` : `Creating project from zip "${uniqueFolderName}"...`,
|
|
316102
316153
|
threadId: initialThreadId,
|
|
316103
316154
|
projectId
|
|
316104
316155
|
};
|
|
316105
|
-
await
|
|
316156
|
+
await mkdir11(folderPath, { recursive: false });
|
|
316106
316157
|
await this.extractZipEntries(zip, folderPath);
|
|
316107
316158
|
await this.gitManager.initRepository(folderPath);
|
|
316108
316159
|
await this.gitManager.ensureInitialCommit(folderPath);
|
|
@@ -316160,7 +316211,7 @@ var init_projects_creator = __esm({
|
|
|
316160
316211
|
return name;
|
|
316161
316212
|
}
|
|
316162
316213
|
generateThreadPath(_projectId, threadId) {
|
|
316163
|
-
return
|
|
316214
|
+
return join52(this.rootFolder, threadId);
|
|
316164
316215
|
}
|
|
316165
316216
|
toFolderName(name) {
|
|
316166
316217
|
return name.trim().toLowerCase().replace(/[\\/]+/g, " ").replace(/[^a-z0-9._ -]+/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -316176,7 +316227,7 @@ var init_projects_creator = __esm({
|
|
|
316176
316227
|
async ensureUniqueFolderName(baseFolderName) {
|
|
316177
316228
|
let candidate = baseFolderName;
|
|
316178
316229
|
let counter = 1;
|
|
316179
|
-
while (await this.folderExists(
|
|
316230
|
+
while (await this.folderExists(join52(this.rootFolder, candidate))) {
|
|
316180
316231
|
candidate = `${baseFolderName}-${counter}`;
|
|
316181
316232
|
counter++;
|
|
316182
316233
|
}
|
|
@@ -316326,8 +316377,8 @@ var init_projects_creator = __esm({
|
|
|
316326
316377
|
yield existingEvents.complete;
|
|
316327
316378
|
return;
|
|
316328
316379
|
}
|
|
316329
|
-
const projectId =
|
|
316330
|
-
const initialThreadId =
|
|
316380
|
+
const projectId = randomUUID22();
|
|
316381
|
+
const initialThreadId = randomUUID22();
|
|
316331
316382
|
const initialThreadTitle = generateRandomHyphenatedName();
|
|
316332
316383
|
this.processingStateManager?.setProcessing(initialThreadId);
|
|
316333
316384
|
try {
|
|
@@ -316360,16 +316411,16 @@ var init_projects_creator = __esm({
|
|
|
316360
316411
|
|
|
316361
316412
|
// src/features/projects/built-in-bot-icon.ts
|
|
316362
316413
|
import { readFile as readFile24 } from "fs/promises";
|
|
316363
|
-
import { dirname as dirname17, join as
|
|
316414
|
+
import { dirname as dirname17, join as join53 } from "path";
|
|
316364
316415
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
316365
316416
|
async function readBuiltInBotIconDataUrl() {
|
|
316366
316417
|
const assetsDir = getAssetsDir();
|
|
316367
316418
|
const candidates = [
|
|
316368
|
-
assetsDir ?
|
|
316369
|
-
|
|
316370
|
-
|
|
316371
|
-
|
|
316372
|
-
|
|
316419
|
+
assetsDir ? join53(assetsDir, BUILT_IN_BOT_ICON_FILENAME) : null,
|
|
316420
|
+
join53(moduleDir2, BUILT_IN_BOT_ICON_FILENAME),
|
|
316421
|
+
join53(moduleDir2, "..", "..", "..", "assets", BUILT_IN_BOT_ICON_FILENAME),
|
|
316422
|
+
join53(process.cwd(), "dist", BUILT_IN_BOT_ICON_FILENAME),
|
|
316423
|
+
join53(process.cwd(), "assets", BUILT_IN_BOT_ICON_FILENAME)
|
|
316373
316424
|
];
|
|
316374
316425
|
for (const candidate of candidates) {
|
|
316375
316426
|
if (!candidate) {
|
|
@@ -316499,7 +316550,7 @@ var init_terminal_session_manager = __esm({
|
|
|
316499
316550
|
});
|
|
316500
316551
|
|
|
316501
316552
|
// src/features/projects/projects.manager.ts
|
|
316502
|
-
import { join as
|
|
316553
|
+
import { join as join54 } from "path";
|
|
316503
316554
|
import { realpathSync as realpathSync4 } from "fs";
|
|
316504
316555
|
import { rm as rm9 } from "fs/promises";
|
|
316505
316556
|
var log127, ProjectManagerImpl;
|
|
@@ -316809,7 +316860,7 @@ var init_projects_manager = __esm({
|
|
|
316809
316860
|
const session = this.terminalSessionManager.getOrCreateSession(threadId, thread.path);
|
|
316810
316861
|
let workingDir;
|
|
316811
316862
|
if (cwd) {
|
|
316812
|
-
workingDir = cwd.startsWith("/") ? cwd :
|
|
316863
|
+
workingDir = cwd.startsWith("/") ? cwd : join54(thread.path, cwd);
|
|
316813
316864
|
this.terminalSessionManager.updateWorkingDirectory(threadId, workingDir);
|
|
316814
316865
|
} else {
|
|
316815
316866
|
workingDir = session.currentWorkingDirectory;
|
|
@@ -317100,7 +317151,7 @@ ___CWD___%s
|
|
|
317100
317151
|
|
|
317101
317152
|
// src/features/projects/pty-session-manager.ts
|
|
317102
317153
|
import { realpathSync as realpathSync5 } from "fs";
|
|
317103
|
-
import { join as
|
|
317154
|
+
import { join as join55 } from "path";
|
|
317104
317155
|
function shellEscapePath(path27) {
|
|
317105
317156
|
return `'${path27.replace(/'/g, `'\\''`)}'`;
|
|
317106
317157
|
}
|
|
@@ -317229,7 +317280,7 @@ var init_pty_session_manager = __esm({
|
|
|
317229
317280
|
return;
|
|
317230
317281
|
}
|
|
317231
317282
|
if (message.cwd) {
|
|
317232
|
-
const targetPath = message.cwd.startsWith("/") ? message.cwd :
|
|
317283
|
+
const targetPath = message.cwd.startsWith("/") ? message.cwd : join55(session.workingDirectory, message.cwd);
|
|
317233
317284
|
commandLine = `cd ${shellEscapePath(targetPath)} && ${commandLine}`;
|
|
317234
317285
|
}
|
|
317235
317286
|
session.proc.terminal.write(`${commandLine}
|
|
@@ -317914,9 +317965,9 @@ var init_scaffold_routes = __esm({
|
|
|
317914
317965
|
});
|
|
317915
317966
|
|
|
317916
317967
|
// src/features/slash-commands/slash-commands.manager.ts
|
|
317917
|
-
import { readdir as readdir15, readFile as readFile25, mkdir as
|
|
317918
|
-
import { join as
|
|
317919
|
-
import { existsSync as
|
|
317968
|
+
import { readdir as readdir15, readFile as readFile25, mkdir as mkdir12, writeFile as writeFile16, unlink as unlink5 } from "fs/promises";
|
|
317969
|
+
import { join as join56, basename as basename11, extname as extname7, relative as relative14, resolve as resolve13, isAbsolute as isAbsolute9 } from "path";
|
|
317970
|
+
import { existsSync as existsSync27 } from "fs";
|
|
317920
317971
|
import { homedir as homedir9 } from "os";
|
|
317921
317972
|
function slugify2(filename) {
|
|
317922
317973
|
return filename.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -317937,10 +317988,10 @@ function applySlashCommandFrontmatterField(key, value, metadata) {
|
|
|
317937
317988
|
}
|
|
317938
317989
|
}
|
|
317939
317990
|
function getGlobalCommandsDir() {
|
|
317940
|
-
return
|
|
317991
|
+
return join56(homedir9(), ".agents", "commands");
|
|
317941
317992
|
}
|
|
317942
317993
|
function getProjectCommandsDir(threadPath) {
|
|
317943
|
-
return
|
|
317994
|
+
return join56(threadPath, ".agents", "commands");
|
|
317944
317995
|
}
|
|
317945
317996
|
function builtInCommand(definition) {
|
|
317946
317997
|
return {
|
|
@@ -318056,7 +318107,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318056
318107
|
async loadCommands(threadPath) {
|
|
318057
318108
|
const commands = /* @__PURE__ */ new Map();
|
|
318058
318109
|
const globalDir = getGlobalCommandsDir();
|
|
318059
|
-
if (
|
|
318110
|
+
if (existsSync27(globalDir)) {
|
|
318060
318111
|
const globalCommands = await this.loadCommandsFromDir(globalDir, threadPath, "global");
|
|
318061
318112
|
for (const cmd of globalCommands) {
|
|
318062
318113
|
if (!_SlashCommandManager.BUILT_IN_COMMANDS.has(cmd.name)) {
|
|
@@ -318065,7 +318116,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318065
318116
|
}
|
|
318066
318117
|
}
|
|
318067
318118
|
const projectDir = getProjectCommandsDir(threadPath);
|
|
318068
|
-
if (
|
|
318119
|
+
if (existsSync27(projectDir)) {
|
|
318069
318120
|
const projectCommands = await this.loadCommandsFromDir(projectDir, threadPath, "project");
|
|
318070
318121
|
for (const cmd of projectCommands) {
|
|
318071
318122
|
if (!_SlashCommandManager.BUILT_IN_COMMANDS.has(cmd.name)) {
|
|
@@ -318087,7 +318138,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318087
318138
|
const files = await readdir15(dir);
|
|
318088
318139
|
for (const file2 of files) {
|
|
318089
318140
|
if (!file2.endsWith(".md")) continue;
|
|
318090
|
-
const filePath =
|
|
318141
|
+
const filePath = join56(dir, file2);
|
|
318091
318142
|
const fileContent = await readFile25(filePath, "utf-8");
|
|
318092
318143
|
const { metadata, content } = parseFrontmatter3(fileContent);
|
|
318093
318144
|
const nameWithoutExt = basename11(file2, extname7(file2));
|
|
@@ -318098,7 +318149,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318098
318149
|
content,
|
|
318099
318150
|
metadata,
|
|
318100
318151
|
scope,
|
|
318101
|
-
filePath: scope === "project" ?
|
|
318152
|
+
filePath: scope === "project" ? relative14(threadPath, filePath) : filePath
|
|
318102
318153
|
});
|
|
318103
318154
|
}
|
|
318104
318155
|
} catch (error2) {
|
|
@@ -318118,12 +318169,12 @@ var init_slash_commands_manager = __esm({
|
|
|
318118
318169
|
if (!dir) {
|
|
318119
318170
|
throw new Error("threadPath required for project-scoped commands");
|
|
318120
318171
|
}
|
|
318121
|
-
if (!
|
|
318122
|
-
await
|
|
318172
|
+
if (!existsSync27(dir)) {
|
|
318173
|
+
await mkdir12(dir, { recursive: true });
|
|
318123
318174
|
}
|
|
318124
318175
|
const filename = `${name}.md`;
|
|
318125
|
-
const filePath =
|
|
318126
|
-
if (
|
|
318176
|
+
const filePath = join56(dir, filename);
|
|
318177
|
+
if (existsSync27(filePath)) {
|
|
318127
318178
|
throw new Error(`Command already exists: ${name}`);
|
|
318128
318179
|
}
|
|
318129
318180
|
const markdown = joinMarkdownFrontmatter(
|
|
@@ -318147,7 +318198,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318147
318198
|
* Update an existing command
|
|
318148
318199
|
*/
|
|
318149
318200
|
async updateCommand(filePath, content, metadata) {
|
|
318150
|
-
if (!
|
|
318201
|
+
if (!existsSync27(filePath)) {
|
|
318151
318202
|
throw new Error(`Command file not found: ${filePath}`);
|
|
318152
318203
|
}
|
|
318153
318204
|
const markdown = joinMarkdownFrontmatter(
|
|
@@ -318164,7 +318215,7 @@ var init_slash_commands_manager = __esm({
|
|
|
318164
318215
|
* Delete a command
|
|
318165
318216
|
*/
|
|
318166
318217
|
async deleteCommand(filePath, threadPath) {
|
|
318167
|
-
const resolvedPath2 =
|
|
318218
|
+
const resolvedPath2 = isAbsolute9(filePath) ? resolve13(filePath) : threadPath ? resolve13(threadPath, filePath) : null;
|
|
318168
318219
|
if (!resolvedPath2) {
|
|
318169
318220
|
throw new Error("threadPath is required for project-scoped commands");
|
|
318170
318221
|
}
|
|
@@ -318173,13 +318224,13 @@ var init_slash_commands_manager = __esm({
|
|
|
318173
318224
|
allowedDirectories.push(resolve13(getProjectCommandsDir(threadPath)));
|
|
318174
318225
|
}
|
|
318175
318226
|
const isAllowedPath = allowedDirectories.some((directory) => {
|
|
318176
|
-
const relativePath =
|
|
318177
|
-
return relativePath !== "" && !relativePath.startsWith("..") && !
|
|
318227
|
+
const relativePath = relative14(directory, resolvedPath2);
|
|
318228
|
+
return relativePath !== "" && !relativePath.startsWith("..") && !isAbsolute9(relativePath);
|
|
318178
318229
|
});
|
|
318179
318230
|
if (!isAllowedPath) {
|
|
318180
318231
|
throw new Error("Command file must be inside an allowed commands directory");
|
|
318181
318232
|
}
|
|
318182
|
-
if (!
|
|
318233
|
+
if (!existsSync27(resolvedPath2)) {
|
|
318183
318234
|
throw new Error(`Command file not found: ${filePath}`);
|
|
318184
318235
|
}
|
|
318185
318236
|
await unlink5(resolvedPath2);
|
|
@@ -318835,9 +318886,9 @@ var init_thread_folder_name = __esm({
|
|
|
318835
318886
|
});
|
|
318836
318887
|
|
|
318837
318888
|
// src/features/threads/thread-copy-clone.ts
|
|
318838
|
-
import { randomUUID as
|
|
318889
|
+
import { randomUUID as randomUUID23 } from "crypto";
|
|
318839
318890
|
import { readdir as readdir16, rename as rename4, stat as stat13, rm as rm10 } from "fs/promises";
|
|
318840
|
-
import { join as
|
|
318891
|
+
import { join as join57 } from "path";
|
|
318841
318892
|
function supportsCopyOnWriteClone() {
|
|
318842
318893
|
return process.platform === "darwin";
|
|
318843
318894
|
}
|
|
@@ -318857,7 +318908,7 @@ async function findCopySourceClone(candidatePaths, gitUrl) {
|
|
|
318857
318908
|
if (checked >= MAX_SOURCE_CANDIDATES) break;
|
|
318858
318909
|
let gitDirIsDirectory;
|
|
318859
318910
|
try {
|
|
318860
|
-
gitDirIsDirectory = (await stat13(
|
|
318911
|
+
gitDirIsDirectory = (await stat13(join57(candidate, ".git"))).isDirectory();
|
|
318861
318912
|
} catch {
|
|
318862
318913
|
continue;
|
|
318863
318914
|
}
|
|
@@ -318910,7 +318961,7 @@ async function cloneDirectoryTree(sourcePath, targetPath) {
|
|
|
318910
318961
|
if (typeof Worker === "undefined") {
|
|
318911
318962
|
return { ok: false, error: "workers are unavailable in this runtime" };
|
|
318912
318963
|
}
|
|
318913
|
-
const stagingPath = `${targetPath}.copying-${
|
|
318964
|
+
const stagingPath = `${targetPath}.copying-${randomUUID23().slice(0, 8)}`;
|
|
318914
318965
|
let worker;
|
|
318915
318966
|
try {
|
|
318916
318967
|
const workerUrl = URL.createObjectURL(
|
|
@@ -319034,12 +319085,12 @@ async function* withHeartbeat(work, message) {
|
|
|
319034
319085
|
async function emptyDirectory(path27) {
|
|
319035
319086
|
const entries = await readdir16(path27);
|
|
319036
319087
|
await Promise.all(
|
|
319037
|
-
entries.map((entry) => rm10(
|
|
319088
|
+
entries.map((entry) => rm10(join57(path27, entry), { recursive: true, force: true }))
|
|
319038
319089
|
);
|
|
319039
319090
|
}
|
|
319040
319091
|
async function removeStaleLocks(targetPath) {
|
|
319041
319092
|
await Promise.all(
|
|
319042
|
-
STALE_GIT_LOCKS.map((lock3) => rm10(
|
|
319093
|
+
STALE_GIT_LOCKS.map((lock3) => rm10(join57(targetPath, ".git", lock3), { force: true }))
|
|
319043
319094
|
);
|
|
319044
319095
|
}
|
|
319045
319096
|
var log138, STALE_GIT_LOCKS, MAX_SOURCE_CANDIDATES, CLONEFILE_WORKER_SOURCE;
|
|
@@ -319079,10 +319130,10 @@ self.onmessage = (event) => {
|
|
|
319079
319130
|
});
|
|
319080
319131
|
|
|
319081
319132
|
// src/features/threads/threads.manager.ts
|
|
319082
|
-
import { randomUUID as
|
|
319083
|
-
import { join as
|
|
319133
|
+
import { randomUUID as randomUUID24 } from "crypto";
|
|
319134
|
+
import { join as join58 } from "path";
|
|
319084
319135
|
import { execSync as execSync3 } from "child_process";
|
|
319085
|
-
import { rm as rm11, stat as stat14, mkdir as
|
|
319136
|
+
import { rm as rm11, stat as stat14, mkdir as mkdir13 } from "fs/promises";
|
|
319086
319137
|
async function* forwardGitEvents(events, errorPrefix, clearProcessing) {
|
|
319087
319138
|
for await (const gitEvent of events) {
|
|
319088
319139
|
if (gitEvent.type === "auth_required") {
|
|
@@ -319207,7 +319258,7 @@ var init_threads_manager = __esm({
|
|
|
319207
319258
|
return;
|
|
319208
319259
|
}
|
|
319209
319260
|
await this.ensureProjectDirectory(project.path);
|
|
319210
|
-
threadId =
|
|
319261
|
+
threadId = randomUUID24();
|
|
319211
319262
|
const threadTitle = await this.resolveThreadTitle(projectId, title);
|
|
319212
319263
|
const threadPath = await this.generateThreadPath(project.gitUrl, project.name);
|
|
319213
319264
|
const provisionalBranch = this.gitManager.sanitizeBranchName(
|
|
@@ -319220,7 +319271,7 @@ var init_threads_manager = __esm({
|
|
|
319220
319271
|
path: threadPath,
|
|
319221
319272
|
currentBranch: provisionalBranch,
|
|
319222
319273
|
createdAt: /* @__PURE__ */ new Date(),
|
|
319223
|
-
currentConversationId:
|
|
319274
|
+
currentConversationId: randomUUID24()
|
|
319224
319275
|
};
|
|
319225
319276
|
await perf.step("persist-metadata", () => this.persistThreadMetadata(thread));
|
|
319226
319277
|
publishConversationsUnreadChanged(projectId);
|
|
@@ -319381,7 +319432,7 @@ var init_threads_manager = __esm({
|
|
|
319381
319432
|
try {
|
|
319382
319433
|
await stat14(path27);
|
|
319383
319434
|
} catch {
|
|
319384
|
-
await
|
|
319435
|
+
await mkdir13(path27, { recursive: true });
|
|
319385
319436
|
}
|
|
319386
319437
|
}
|
|
319387
319438
|
/**
|
|
@@ -319772,7 +319823,7 @@ var init_threads_manager = __esm({
|
|
|
319772
319823
|
const remainingThreads = project.threads.filter((id) => id !== threadId);
|
|
319773
319824
|
if (remainingThreads.length === 0 && isBuiltInBot(project)) {
|
|
319774
319825
|
const replacement = {
|
|
319775
|
-
id:
|
|
319826
|
+
id: randomUUID24(),
|
|
319776
319827
|
projectId: project.id,
|
|
319777
319828
|
title: generateRandomHyphenatedName(),
|
|
319778
319829
|
path: project.path,
|
|
@@ -319996,9 +320047,9 @@ var init_threads_manager = __esm({
|
|
|
319996
320047
|
let candidate = baseFolderName;
|
|
319997
320048
|
let counter = 1;
|
|
319998
320049
|
while (true) {
|
|
319999
|
-
const candidatePath =
|
|
320050
|
+
const candidatePath = join58(this.rootFolder, candidate);
|
|
320000
320051
|
try {
|
|
320001
|
-
await
|
|
320052
|
+
await mkdir13(candidatePath);
|
|
320002
320053
|
return candidatePath;
|
|
320003
320054
|
} catch (error2) {
|
|
320004
320055
|
if (error2.code !== "EEXIST") {
|
|
@@ -320071,7 +320122,7 @@ var init_threads_manager = __esm({
|
|
|
320071
320122
|
});
|
|
320072
320123
|
|
|
320073
320124
|
// src/features/remote-threads/remote-provision-operation.ts
|
|
320074
|
-
import { createHash as createHash14, randomUUID as
|
|
320125
|
+
import { createHash as createHash14, randomUUID as randomUUID25 } from "node:crypto";
|
|
320075
320126
|
async function initializeRemoteProvisionOperationSchema(db) {
|
|
320076
320127
|
await withImmediateTransaction(db, async function createOperationTables() {
|
|
320077
320128
|
await db.execute(`CREATE TABLE IF NOT EXISTS remote_provision_operations (
|
|
@@ -320162,8 +320213,8 @@ async function prepareRemoteCreateOperation(db, input2) {
|
|
|
320162
320213
|
);
|
|
320163
320214
|
if (result.rows[0]) return result.rows[0];
|
|
320164
320215
|
const operation = {
|
|
320165
|
-
operationId:
|
|
320166
|
-
localThreadId:
|
|
320216
|
+
operationId: randomUUID25(),
|
|
320217
|
+
localThreadId: randomUUID25(),
|
|
320167
320218
|
projectName: input2.projectName,
|
|
320168
320219
|
gitRemoteUrl: input2.gitRemoteUrl,
|
|
320169
320220
|
title: input2.title
|
|
@@ -320198,9 +320249,9 @@ var init_remote_provision_operation = __esm({
|
|
|
320198
320249
|
});
|
|
320199
320250
|
|
|
320200
320251
|
// src/features/remote-threads/remote-provision.ts
|
|
320201
|
-
import { randomUUID as
|
|
320202
|
-
import { mkdir as
|
|
320203
|
-
import { join as
|
|
320252
|
+
import { randomUUID as randomUUID26 } from "node:crypto";
|
|
320253
|
+
import { mkdir as mkdir14, mkdtemp as mkdtemp5, rm as rm12 } from "node:fs/promises";
|
|
320254
|
+
import { join as join59 } from "node:path";
|
|
320204
320255
|
function hasProvisionFields(input2) {
|
|
320205
320256
|
return typeof input2.projectName === "string" && Boolean(input2.projectName.trim()) && typeof input2.title === "string" && Boolean(input2.title.trim()) && typeof input2.gitRemoteUrl === "string" && CREDENTIAL_FREE_HTTPS_GIT_URL.test(input2.gitRemoteUrl);
|
|
320206
320257
|
}
|
|
@@ -320316,20 +320367,20 @@ async function createProvisionBranch(dependencies, threadPath, branch) {
|
|
|
320316
320367
|
}
|
|
320317
320368
|
async function createProvisionDirectory(dependencies) {
|
|
320318
320369
|
const root = dependencies.projectManager.getRootFolder();
|
|
320319
|
-
await
|
|
320320
|
-
return mkdtemp5(
|
|
320370
|
+
await mkdir14(root, { recursive: true });
|
|
320371
|
+
return mkdtemp5(join59(root, "remote-"));
|
|
320321
320372
|
}
|
|
320322
320373
|
async function prepareRemoteWorkspace(input2, dependencies, db, projectPath, host) {
|
|
320323
320374
|
const stored = await storedCredential(db, host);
|
|
320324
320375
|
const credential = input2.forwardedCredential ?? stored ?? null;
|
|
320325
320376
|
if (credential) validateCredential(credential);
|
|
320326
|
-
const threadPath =
|
|
320377
|
+
const threadPath = join59(projectPath, "workspace");
|
|
320327
320378
|
await cloneRemote(input2.gitRemoteUrl, threadPath, credential);
|
|
320328
|
-
const threadId =
|
|
320379
|
+
const threadId = randomUUID26();
|
|
320329
320380
|
const branch = dependencies.gitManager.sanitizeBranchName(input2.title);
|
|
320330
320381
|
await createProvisionBranch(dependencies, threadPath, branch);
|
|
320331
320382
|
const project = {
|
|
320332
|
-
id:
|
|
320383
|
+
id: randomUUID26(),
|
|
320333
320384
|
name: input2.projectName.trim(),
|
|
320334
320385
|
gitUrl: input2.gitRemoteUrl,
|
|
320335
320386
|
// Project settings must be read from the cloned repository, not its
|
|
@@ -320345,7 +320396,7 @@ async function prepareRemoteWorkspace(input2, dependencies, db, projectPath, hos
|
|
|
320345
320396
|
path: threadPath,
|
|
320346
320397
|
currentBranch: branch,
|
|
320347
320398
|
createdAt: /* @__PURE__ */ new Date(),
|
|
320348
|
-
currentConversationId:
|
|
320399
|
+
currentConversationId: randomUUID26()
|
|
320349
320400
|
};
|
|
320350
320401
|
return { project, thread };
|
|
320351
320402
|
}
|
|
@@ -320961,7 +321012,7 @@ var init_threads_delete_route = __esm({
|
|
|
320961
321012
|
});
|
|
320962
321013
|
|
|
320963
321014
|
// src/features/project-scripts/project-scripts.database.ts
|
|
320964
|
-
import { randomUUID as
|
|
321015
|
+
import { randomUUID as randomUUID27 } from "crypto";
|
|
320965
321016
|
async function getScriptsByProject(db, projectId) {
|
|
320966
321017
|
const result = await db.execute({
|
|
320967
321018
|
sql: `SELECT id, projectId, workspace, name, command, friendlyName, updatedAt
|
|
@@ -320978,7 +321029,7 @@ async function upsertProjectScripts(projectId, scripts) {
|
|
|
320978
321029
|
sql: `INSERT OR REPLACE INTO project_scripts (id, projectId, workspace, name, command, friendlyName, updatedAt)
|
|
320979
321030
|
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
|
320980
321031
|
args: [
|
|
320981
|
-
|
|
321032
|
+
randomUUID27(),
|
|
320982
321033
|
projectId,
|
|
320983
321034
|
script.workspace,
|
|
320984
321035
|
script.name,
|
|
@@ -320998,8 +321049,8 @@ var init_project_scripts_database = __esm({
|
|
|
320998
321049
|
|
|
320999
321050
|
// src/core/project-inspector.ts
|
|
321000
321051
|
import { readFile as readFile26, readdir as readdir17 } from "fs/promises";
|
|
321001
|
-
import { existsSync as
|
|
321002
|
-
import { join as
|
|
321052
|
+
import { existsSync as existsSync28 } from "fs";
|
|
321053
|
+
import { join as join60, basename as basename13, relative as relative15 } from "path";
|
|
321003
321054
|
async function inspectProject(projectPath, projectId) {
|
|
321004
321055
|
const packageManager = await detectPackageManager3(projectPath);
|
|
321005
321056
|
const repoType = await detectMonoRepoType(projectPath);
|
|
@@ -321009,13 +321060,13 @@ async function inspectProject(projectPath, projectId) {
|
|
|
321009
321060
|
return scripts;
|
|
321010
321061
|
}
|
|
321011
321062
|
async function detectPackageManager3(projectPath) {
|
|
321012
|
-
if (
|
|
321063
|
+
if (existsSync28(join60(projectPath, "bun.lockb")) || existsSync28(join60(projectPath, "bun.lock"))) {
|
|
321013
321064
|
return "bun";
|
|
321014
321065
|
}
|
|
321015
|
-
if (
|
|
321066
|
+
if (existsSync28(join60(projectPath, "pnpm-lock.yaml"))) {
|
|
321016
321067
|
return "pnpm";
|
|
321017
321068
|
}
|
|
321018
|
-
if (
|
|
321069
|
+
if (existsSync28(join60(projectPath, "yarn.lock"))) {
|
|
321019
321070
|
return "yarn";
|
|
321020
321071
|
}
|
|
321021
321072
|
try {
|
|
@@ -321034,8 +321085,8 @@ async function detectPackageManager3(projectPath) {
|
|
|
321034
321085
|
return "npm";
|
|
321035
321086
|
}
|
|
321036
321087
|
async function detectMonoRepoType(projectPath) {
|
|
321037
|
-
const hasPnpmWorkspace =
|
|
321038
|
-
if (
|
|
321088
|
+
const hasPnpmWorkspace = existsSync28(join60(projectPath, "pnpm-workspace.yaml"));
|
|
321089
|
+
if (existsSync28(join60(projectPath, "nx.json"))) {
|
|
321039
321090
|
return "nx";
|
|
321040
321091
|
}
|
|
321041
321092
|
const pkg = await readPackageJson(projectPath);
|
|
@@ -321049,10 +321100,10 @@ async function detectMonoRepoType(projectPath) {
|
|
|
321049
321100
|
if (hasPnpmWorkspace) {
|
|
321050
321101
|
return "pnpm";
|
|
321051
321102
|
}
|
|
321052
|
-
if (
|
|
321103
|
+
if (existsSync28(join60(projectPath, "lerna.json"))) {
|
|
321053
321104
|
return "lerna";
|
|
321054
321105
|
}
|
|
321055
|
-
if (
|
|
321106
|
+
if (existsSync28(join60(projectPath, "turbo.json"))) {
|
|
321056
321107
|
return "turbo";
|
|
321057
321108
|
}
|
|
321058
321109
|
const folderWorkspaces = await detectFolderBasedWorkspaces(projectPath);
|
|
@@ -321101,8 +321152,8 @@ async function collectWorkspacesFromGlobs(projectPath, patterns, options2 = {})
|
|
|
321101
321152
|
});
|
|
321102
321153
|
const workspaces = [];
|
|
321103
321154
|
for (const folder5 of folders) {
|
|
321104
|
-
const absPath =
|
|
321105
|
-
if (!
|
|
321155
|
+
const absPath = join60(projectPath, folder5);
|
|
321156
|
+
if (!existsSync28(join60(absPath, "package.json"))) continue;
|
|
321106
321157
|
let name = basename13(folder5);
|
|
321107
321158
|
if (options2.preferPackageName) {
|
|
321108
321159
|
const wsPkg = await readPackageJson(absPath);
|
|
@@ -321125,8 +321176,8 @@ async function resolvePackageJsonWorkspaces(projectPath) {
|
|
|
321125
321176
|
return collectWorkspacesFromGlobs(projectPath, globs);
|
|
321126
321177
|
}
|
|
321127
321178
|
async function resolvePnpmWorkspaces(projectPath) {
|
|
321128
|
-
const yamlPath =
|
|
321129
|
-
if (!
|
|
321179
|
+
const yamlPath = join60(projectPath, "pnpm-workspace.yaml");
|
|
321180
|
+
if (!existsSync28(yamlPath)) {
|
|
321130
321181
|
return [rootWorkspace(projectPath)];
|
|
321131
321182
|
}
|
|
321132
321183
|
try {
|
|
@@ -321148,8 +321199,8 @@ async function resolvePnpmWorkspaces(projectPath) {
|
|
|
321148
321199
|
}
|
|
321149
321200
|
}
|
|
321150
321201
|
async function resolveLernaWorkspaces(projectPath) {
|
|
321151
|
-
const lernaPath =
|
|
321152
|
-
if (!
|
|
321202
|
+
const lernaPath = join60(projectPath, "lerna.json");
|
|
321203
|
+
if (!existsSync28(lernaPath)) {
|
|
321153
321204
|
return [rootWorkspace(projectPath)];
|
|
321154
321205
|
}
|
|
321155
321206
|
try {
|
|
@@ -321163,8 +321214,8 @@ async function resolveLernaWorkspaces(projectPath) {
|
|
|
321163
321214
|
}
|
|
321164
321215
|
async function resolveNxWorkspaces(projectPath) {
|
|
321165
321216
|
let workspaces = [];
|
|
321166
|
-
const workspaceJsonPath =
|
|
321167
|
-
if (
|
|
321217
|
+
const workspaceJsonPath = join60(projectPath, "workspace.json");
|
|
321218
|
+
if (existsSync28(workspaceJsonPath)) {
|
|
321168
321219
|
workspaces = workspaces.concat(await readNxWorkspaceJsonWorkspaces(projectPath));
|
|
321169
321220
|
if (workspaces.length > 0) return workspaces;
|
|
321170
321221
|
}
|
|
@@ -321177,14 +321228,14 @@ async function resolveNxWorkspaces(projectPath) {
|
|
|
321177
321228
|
async function readNxWorkspaceJsonWorkspaces(projectPath) {
|
|
321178
321229
|
const workspaces = [];
|
|
321179
321230
|
try {
|
|
321180
|
-
const content = await readFile26(
|
|
321231
|
+
const content = await readFile26(join60(projectPath, "workspace.json"), "utf-8");
|
|
321181
321232
|
const wsJson = JSON.parse(content);
|
|
321182
321233
|
for (const [name, value] of Object.entries(wsJson.projects ?? {})) {
|
|
321183
321234
|
const folder5 = typeof value === "string" ? value : value.root;
|
|
321184
321235
|
if (folder5) {
|
|
321185
321236
|
workspaces.push({
|
|
321186
321237
|
name,
|
|
321187
|
-
folder:
|
|
321238
|
+
folder: join60(projectPath, folder5),
|
|
321188
321239
|
relativePath: folder5
|
|
321189
321240
|
});
|
|
321190
321241
|
}
|
|
@@ -321207,13 +321258,13 @@ async function collectNxProjectJsonWorkspaces(projectPath) {
|
|
|
321207
321258
|
}
|
|
321208
321259
|
async function readNxProjectJsonWorkspace(projectPath, file2) {
|
|
321209
321260
|
try {
|
|
321210
|
-
const content = await readFile26(
|
|
321261
|
+
const content = await readFile26(join60(projectPath, file2), "utf-8");
|
|
321211
321262
|
const project = JSON.parse(content);
|
|
321212
321263
|
if (!project.name) return null;
|
|
321213
321264
|
const folder5 = file2.replace(/\/project\.json$/, "");
|
|
321214
321265
|
return {
|
|
321215
321266
|
name: project.name,
|
|
321216
|
-
folder:
|
|
321267
|
+
folder: join60(projectPath, folder5),
|
|
321217
321268
|
relativePath: folder5
|
|
321218
321269
|
};
|
|
321219
321270
|
} catch {
|
|
@@ -321221,16 +321272,16 @@ async function readNxProjectJsonWorkspace(projectPath, file2) {
|
|
|
321221
321272
|
}
|
|
321222
321273
|
}
|
|
321223
321274
|
async function collectNxAppsWorkspaces(projectPath) {
|
|
321224
|
-
const appsDir =
|
|
321225
|
-
if (!
|
|
321275
|
+
const appsDir = join60(projectPath, "apps");
|
|
321276
|
+
if (!existsSync28(appsDir)) return [];
|
|
321226
321277
|
const entries = await readdir17(appsDir, { withFileTypes: true });
|
|
321227
321278
|
const workspaces = [];
|
|
321228
321279
|
for (const entry of entries) {
|
|
321229
321280
|
if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
|
|
321230
|
-
const folder5 =
|
|
321281
|
+
const folder5 = join60("apps", entry.name);
|
|
321231
321282
|
workspaces.push({
|
|
321232
321283
|
name: entry.name,
|
|
321233
|
-
folder:
|
|
321284
|
+
folder: join60(projectPath, folder5),
|
|
321234
321285
|
relativePath: folder5
|
|
321235
321286
|
});
|
|
321236
321287
|
}
|
|
@@ -321257,13 +321308,13 @@ async function detectFolderBasedWorkspaces(projectPath) {
|
|
|
321257
321308
|
const results = [];
|
|
321258
321309
|
for (const entry of entries) {
|
|
321259
321310
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules" && entry.name !== "dist" && entry.name !== "build") {
|
|
321260
|
-
const pkgPath =
|
|
321261
|
-
if (
|
|
321311
|
+
const pkgPath = join60(projectPath, entry.name, "package.json");
|
|
321312
|
+
if (existsSync28(pkgPath)) {
|
|
321262
321313
|
try {
|
|
321263
321314
|
const content = await readFile26(pkgPath, "utf-8");
|
|
321264
321315
|
const pkg = JSON.parse(content);
|
|
321265
321316
|
if (pkg.dependencies || pkg.devDependencies || pkg.scripts) {
|
|
321266
|
-
results.push({ name: entry.name, absPath:
|
|
321317
|
+
results.push({ name: entry.name, absPath: join60(projectPath, entry.name) });
|
|
321267
321318
|
}
|
|
321268
321319
|
} catch {
|
|
321269
321320
|
}
|
|
@@ -321301,7 +321352,7 @@ function buildRunCommand(scriptName, workspace, packageManager, repoType, projec
|
|
|
321301
321352
|
return `npm run ${scriptName} --workspace=${workspace.relativePath}`;
|
|
321302
321353
|
}
|
|
321303
321354
|
if (!isRoot) {
|
|
321304
|
-
const relPath =
|
|
321355
|
+
const relPath = relative15(projectPath, workspace.folder);
|
|
321305
321356
|
return `cd ${relPath} && ${runCmd}`;
|
|
321306
321357
|
}
|
|
321307
321358
|
return runCmd;
|
|
@@ -321319,7 +321370,7 @@ function pmRunCommand(packageManager, scriptName) {
|
|
|
321319
321370
|
}
|
|
321320
321371
|
async function readPackageJson(dir) {
|
|
321321
321372
|
try {
|
|
321322
|
-
const content = await readFile26(
|
|
321373
|
+
const content = await readFile26(join60(dir, "package.json"), "utf-8");
|
|
321323
321374
|
return JSON.parse(content);
|
|
321324
321375
|
} catch {
|
|
321325
321376
|
return null;
|
|
@@ -372105,7 +372156,7 @@ var require_util12 = __commonJS({
|
|
|
372105
372156
|
}
|
|
372106
372157
|
path27 = url2.path;
|
|
372107
372158
|
}
|
|
372108
|
-
var
|
|
372159
|
+
var isAbsolute13 = exports2.isAbsolute(path27);
|
|
372109
372160
|
var parts2 = path27.split(/\/+/);
|
|
372110
372161
|
for (var part, up = 0, i2 = parts2.length - 1; i2 >= 0; i2--) {
|
|
372111
372162
|
part = parts2[i2];
|
|
@@ -372125,7 +372176,7 @@ var require_util12 = __commonJS({
|
|
|
372125
372176
|
}
|
|
372126
372177
|
path27 = parts2.join("/");
|
|
372127
372178
|
if (path27 === "") {
|
|
372128
|
-
path27 =
|
|
372179
|
+
path27 = isAbsolute13 ? "/" : ".";
|
|
372129
372180
|
}
|
|
372130
372181
|
if (url2) {
|
|
372131
372182
|
url2.path = path27;
|
|
@@ -372134,7 +372185,7 @@ var require_util12 = __commonJS({
|
|
|
372134
372185
|
return path27;
|
|
372135
372186
|
}
|
|
372136
372187
|
exports2.normalize = normalize5;
|
|
372137
|
-
function
|
|
372188
|
+
function join78(aRoot, aPath) {
|
|
372138
372189
|
if (aRoot === "") {
|
|
372139
372190
|
aRoot = ".";
|
|
372140
372191
|
}
|
|
@@ -372166,11 +372217,11 @@ var require_util12 = __commonJS({
|
|
|
372166
372217
|
}
|
|
372167
372218
|
return joined;
|
|
372168
372219
|
}
|
|
372169
|
-
exports2.join =
|
|
372220
|
+
exports2.join = join78;
|
|
372170
372221
|
exports2.isAbsolute = function(aPath) {
|
|
372171
372222
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
372172
372223
|
};
|
|
372173
|
-
function
|
|
372224
|
+
function relative18(aRoot, aPath) {
|
|
372174
372225
|
if (aRoot === "") {
|
|
372175
372226
|
aRoot = ".";
|
|
372176
372227
|
}
|
|
@@ -372189,7 +372240,7 @@ var require_util12 = __commonJS({
|
|
|
372189
372240
|
}
|
|
372190
372241
|
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
|
372191
372242
|
}
|
|
372192
|
-
exports2.relative =
|
|
372243
|
+
exports2.relative = relative18;
|
|
372193
372244
|
var supportsNullProto = (function() {
|
|
372194
372245
|
var obj = /* @__PURE__ */ Object.create(null);
|
|
372195
372246
|
return !("__proto__" in obj);
|
|
@@ -372339,7 +372390,7 @@ var require_util12 = __commonJS({
|
|
|
372339
372390
|
parsed.path = parsed.path.substring(0, index4 + 1);
|
|
372340
372391
|
}
|
|
372341
372392
|
}
|
|
372342
|
-
sourceURL =
|
|
372393
|
+
sourceURL = join78(urlGenerate(parsed), sourceURL);
|
|
372343
372394
|
}
|
|
372344
372395
|
return normalize5(sourceURL);
|
|
372345
372396
|
}
|
|
@@ -374141,7 +374192,7 @@ var require_escodegen = __commonJS({
|
|
|
374141
374192
|
function noEmptySpace() {
|
|
374142
374193
|
return space ? space : " ";
|
|
374143
374194
|
}
|
|
374144
|
-
function
|
|
374195
|
+
function join78(left2, right2) {
|
|
374145
374196
|
var leftSource, rightSource, leftCharCode, rightCharCode;
|
|
374146
374197
|
leftSource = toSourceNodeWhenNeeded(left2).toString();
|
|
374147
374198
|
if (leftSource.length === 0) {
|
|
@@ -374472,8 +374523,8 @@ var require_escodegen = __commonJS({
|
|
|
374472
374523
|
} else {
|
|
374473
374524
|
result.push(that.generateExpression(stmt.left, Precedence.Call, E_TTT));
|
|
374474
374525
|
}
|
|
374475
|
-
result =
|
|
374476
|
-
result = [
|
|
374526
|
+
result = join78(result, operator);
|
|
374527
|
+
result = [join78(
|
|
374477
374528
|
result,
|
|
374478
374529
|
that.generateExpression(stmt.right, Precedence.Assignment, E_TTT)
|
|
374479
374530
|
), ")"];
|
|
@@ -374616,11 +374667,11 @@ var require_escodegen = __commonJS({
|
|
|
374616
374667
|
var result, fragment;
|
|
374617
374668
|
result = ["class"];
|
|
374618
374669
|
if (stmt.id) {
|
|
374619
|
-
result =
|
|
374670
|
+
result = join78(result, this.generateExpression(stmt.id, Precedence.Sequence, E_TTT));
|
|
374620
374671
|
}
|
|
374621
374672
|
if (stmt.superClass) {
|
|
374622
|
-
fragment =
|
|
374623
|
-
result =
|
|
374673
|
+
fragment = join78("extends", this.generateExpression(stmt.superClass, Precedence.Unary, E_TTT));
|
|
374674
|
+
result = join78(result, fragment);
|
|
374624
374675
|
}
|
|
374625
374676
|
result.push(space);
|
|
374626
374677
|
result.push(this.generateStatement(stmt.body, S_TFFT));
|
|
@@ -374633,9 +374684,9 @@ var require_escodegen = __commonJS({
|
|
|
374633
374684
|
return escapeDirective(stmt.directive) + this.semicolon(flags);
|
|
374634
374685
|
},
|
|
374635
374686
|
DoWhileStatement: function(stmt, flags) {
|
|
374636
|
-
var result =
|
|
374687
|
+
var result = join78("do", this.maybeBlock(stmt.body, S_TFFF));
|
|
374637
374688
|
result = this.maybeBlockSuffix(stmt.body, result);
|
|
374638
|
-
return
|
|
374689
|
+
return join78(result, [
|
|
374639
374690
|
"while" + space + "(",
|
|
374640
374691
|
this.generateExpression(stmt.test, Precedence.Sequence, E_TTT),
|
|
374641
374692
|
")" + this.semicolon(flags)
|
|
@@ -374671,11 +374722,11 @@ var require_escodegen = __commonJS({
|
|
|
374671
374722
|
ExportDefaultDeclaration: function(stmt, flags) {
|
|
374672
374723
|
var result = ["export"], bodyFlags;
|
|
374673
374724
|
bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
|
|
374674
|
-
result =
|
|
374725
|
+
result = join78(result, "default");
|
|
374675
374726
|
if (isStatement(stmt.declaration)) {
|
|
374676
|
-
result =
|
|
374727
|
+
result = join78(result, this.generateStatement(stmt.declaration, bodyFlags));
|
|
374677
374728
|
} else {
|
|
374678
|
-
result =
|
|
374729
|
+
result = join78(result, this.generateExpression(stmt.declaration, Precedence.Assignment, E_TTT) + this.semicolon(flags));
|
|
374679
374730
|
}
|
|
374680
374731
|
return result;
|
|
374681
374732
|
},
|
|
@@ -374683,15 +374734,15 @@ var require_escodegen = __commonJS({
|
|
|
374683
374734
|
var result = ["export"], bodyFlags, that = this;
|
|
374684
374735
|
bodyFlags = flags & F_SEMICOLON_OPT ? S_TFFT : S_TFFF;
|
|
374685
374736
|
if (stmt.declaration) {
|
|
374686
|
-
return
|
|
374737
|
+
return join78(result, this.generateStatement(stmt.declaration, bodyFlags));
|
|
374687
374738
|
}
|
|
374688
374739
|
if (stmt.specifiers) {
|
|
374689
374740
|
if (stmt.specifiers.length === 0) {
|
|
374690
|
-
result =
|
|
374741
|
+
result = join78(result, "{" + space + "}");
|
|
374691
374742
|
} else if (stmt.specifiers[0].type === Syntax.ExportBatchSpecifier) {
|
|
374692
|
-
result =
|
|
374743
|
+
result = join78(result, this.generateExpression(stmt.specifiers[0], Precedence.Sequence, E_TTT));
|
|
374693
374744
|
} else {
|
|
374694
|
-
result =
|
|
374745
|
+
result = join78(result, "{");
|
|
374695
374746
|
withIndent(function(indent2) {
|
|
374696
374747
|
var i2, iz;
|
|
374697
374748
|
result.push(newline);
|
|
@@ -374709,7 +374760,7 @@ var require_escodegen = __commonJS({
|
|
|
374709
374760
|
result.push(base + "}");
|
|
374710
374761
|
}
|
|
374711
374762
|
if (stmt.source) {
|
|
374712
|
-
result =
|
|
374763
|
+
result = join78(result, [
|
|
374713
374764
|
"from" + space,
|
|
374714
374765
|
// ModuleSpecifier
|
|
374715
374766
|
this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
|
|
@@ -374797,7 +374848,7 @@ var require_escodegen = __commonJS({
|
|
|
374797
374848
|
];
|
|
374798
374849
|
cursor = 0;
|
|
374799
374850
|
if (stmt.specifiers[cursor].type === Syntax.ImportDefaultSpecifier) {
|
|
374800
|
-
result =
|
|
374851
|
+
result = join78(result, [
|
|
374801
374852
|
this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
|
|
374802
374853
|
]);
|
|
374803
374854
|
++cursor;
|
|
@@ -374807,7 +374858,7 @@ var require_escodegen = __commonJS({
|
|
|
374807
374858
|
result.push(",");
|
|
374808
374859
|
}
|
|
374809
374860
|
if (stmt.specifiers[cursor].type === Syntax.ImportNamespaceSpecifier) {
|
|
374810
|
-
result =
|
|
374861
|
+
result = join78(result, [
|
|
374811
374862
|
space,
|
|
374812
374863
|
this.generateExpression(stmt.specifiers[cursor], Precedence.Sequence, E_TTT)
|
|
374813
374864
|
]);
|
|
@@ -374836,7 +374887,7 @@ var require_escodegen = __commonJS({
|
|
|
374836
374887
|
}
|
|
374837
374888
|
}
|
|
374838
374889
|
}
|
|
374839
|
-
result =
|
|
374890
|
+
result = join78(result, [
|
|
374840
374891
|
"from" + space,
|
|
374841
374892
|
// ModuleSpecifier
|
|
374842
374893
|
this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
|
|
@@ -374890,7 +374941,7 @@ var require_escodegen = __commonJS({
|
|
|
374890
374941
|
return result;
|
|
374891
374942
|
},
|
|
374892
374943
|
ThrowStatement: function(stmt, flags) {
|
|
374893
|
-
return [
|
|
374944
|
+
return [join78(
|
|
374894
374945
|
"throw",
|
|
374895
374946
|
this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)
|
|
374896
374947
|
), this.semicolon(flags)];
|
|
@@ -374901,7 +374952,7 @@ var require_escodegen = __commonJS({
|
|
|
374901
374952
|
result = this.maybeBlockSuffix(stmt.block, result);
|
|
374902
374953
|
if (stmt.handlers) {
|
|
374903
374954
|
for (i2 = 0, iz = stmt.handlers.length; i2 < iz; ++i2) {
|
|
374904
|
-
result =
|
|
374955
|
+
result = join78(result, this.generateStatement(stmt.handlers[i2], S_TFFF));
|
|
374905
374956
|
if (stmt.finalizer || i2 + 1 !== iz) {
|
|
374906
374957
|
result = this.maybeBlockSuffix(stmt.handlers[i2].body, result);
|
|
374907
374958
|
}
|
|
@@ -374909,7 +374960,7 @@ var require_escodegen = __commonJS({
|
|
|
374909
374960
|
} else {
|
|
374910
374961
|
guardedHandlers = stmt.guardedHandlers || [];
|
|
374911
374962
|
for (i2 = 0, iz = guardedHandlers.length; i2 < iz; ++i2) {
|
|
374912
|
-
result =
|
|
374963
|
+
result = join78(result, this.generateStatement(guardedHandlers[i2], S_TFFF));
|
|
374913
374964
|
if (stmt.finalizer || i2 + 1 !== iz) {
|
|
374914
374965
|
result = this.maybeBlockSuffix(guardedHandlers[i2].body, result);
|
|
374915
374966
|
}
|
|
@@ -374917,13 +374968,13 @@ var require_escodegen = __commonJS({
|
|
|
374917
374968
|
if (stmt.handler) {
|
|
374918
374969
|
if (Array.isArray(stmt.handler)) {
|
|
374919
374970
|
for (i2 = 0, iz = stmt.handler.length; i2 < iz; ++i2) {
|
|
374920
|
-
result =
|
|
374971
|
+
result = join78(result, this.generateStatement(stmt.handler[i2], S_TFFF));
|
|
374921
374972
|
if (stmt.finalizer || i2 + 1 !== iz) {
|
|
374922
374973
|
result = this.maybeBlockSuffix(stmt.handler[i2].body, result);
|
|
374923
374974
|
}
|
|
374924
374975
|
}
|
|
374925
374976
|
} else {
|
|
374926
|
-
result =
|
|
374977
|
+
result = join78(result, this.generateStatement(stmt.handler, S_TFFF));
|
|
374927
374978
|
if (stmt.finalizer) {
|
|
374928
374979
|
result = this.maybeBlockSuffix(stmt.handler.body, result);
|
|
374929
374980
|
}
|
|
@@ -374931,7 +374982,7 @@ var require_escodegen = __commonJS({
|
|
|
374931
374982
|
}
|
|
374932
374983
|
}
|
|
374933
374984
|
if (stmt.finalizer) {
|
|
374934
|
-
result =
|
|
374985
|
+
result = join78(result, ["finally", this.maybeBlock(stmt.finalizer, S_TFFF)]);
|
|
374935
374986
|
}
|
|
374936
374987
|
return result;
|
|
374937
374988
|
},
|
|
@@ -374965,7 +375016,7 @@ var require_escodegen = __commonJS({
|
|
|
374965
375016
|
withIndent(function() {
|
|
374966
375017
|
if (stmt.test) {
|
|
374967
375018
|
result = [
|
|
374968
|
-
|
|
375019
|
+
join78("case", that.generateExpression(stmt.test, Precedence.Sequence, E_TTT)),
|
|
374969
375020
|
":"
|
|
374970
375021
|
];
|
|
374971
375022
|
} else {
|
|
@@ -375013,9 +375064,9 @@ var require_escodegen = __commonJS({
|
|
|
375013
375064
|
result.push(this.maybeBlock(stmt.consequent, S_TFFF));
|
|
375014
375065
|
result = this.maybeBlockSuffix(stmt.consequent, result);
|
|
375015
375066
|
if (stmt.alternate.type === Syntax.IfStatement) {
|
|
375016
|
-
result =
|
|
375067
|
+
result = join78(result, ["else ", this.generateStatement(stmt.alternate, bodyFlags)]);
|
|
375017
375068
|
} else {
|
|
375018
|
-
result =
|
|
375069
|
+
result = join78(result, join78("else", this.maybeBlock(stmt.alternate, bodyFlags)));
|
|
375019
375070
|
}
|
|
375020
375071
|
} else {
|
|
375021
375072
|
result.push(this.maybeBlock(stmt.consequent, bodyFlags));
|
|
@@ -375116,7 +375167,7 @@ var require_escodegen = __commonJS({
|
|
|
375116
375167
|
},
|
|
375117
375168
|
ReturnStatement: function(stmt, flags) {
|
|
375118
375169
|
if (stmt.argument) {
|
|
375119
|
-
return [
|
|
375170
|
+
return [join78(
|
|
375120
375171
|
"return",
|
|
375121
375172
|
this.generateExpression(stmt.argument, Precedence.Sequence, E_TTT)
|
|
375122
375173
|
), this.semicolon(flags)];
|
|
@@ -375205,14 +375256,14 @@ var require_escodegen = __commonJS({
|
|
|
375205
375256
|
if (leftSource.charCodeAt(leftSource.length - 1) === 47 && esutils.code.isIdentifierPartES5(expr.operator.charCodeAt(0))) {
|
|
375206
375257
|
result = [fragment, noEmptySpace(), expr.operator];
|
|
375207
375258
|
} else {
|
|
375208
|
-
result =
|
|
375259
|
+
result = join78(fragment, expr.operator);
|
|
375209
375260
|
}
|
|
375210
375261
|
fragment = this.generateExpression(expr.right, rightPrecedence, flags);
|
|
375211
375262
|
if (expr.operator === "/" && fragment.toString().charAt(0) === "/" || expr.operator.slice(-1) === "<" && fragment.toString().slice(0, 3) === "!--") {
|
|
375212
375263
|
result.push(noEmptySpace());
|
|
375213
375264
|
result.push(fragment);
|
|
375214
375265
|
} else {
|
|
375215
|
-
result =
|
|
375266
|
+
result = join78(result, fragment);
|
|
375216
375267
|
}
|
|
375217
375268
|
if (expr.operator === "in" && !(flags & F_ALLOW_IN)) {
|
|
375218
375269
|
return ["(", result, ")"];
|
|
@@ -375252,7 +375303,7 @@ var require_escodegen = __commonJS({
|
|
|
375252
375303
|
var result, length, i2, iz, itemFlags;
|
|
375253
375304
|
length = expr["arguments"].length;
|
|
375254
375305
|
itemFlags = flags & F_ALLOW_UNPARATH_NEW && !parentheses && length === 0 ? E_TFT : E_TFF;
|
|
375255
|
-
result =
|
|
375306
|
+
result = join78(
|
|
375256
375307
|
"new",
|
|
375257
375308
|
this.generateExpression(expr.callee, Precedence.New, itemFlags)
|
|
375258
375309
|
);
|
|
@@ -375302,11 +375353,11 @@ var require_escodegen = __commonJS({
|
|
|
375302
375353
|
var result, fragment, rightCharCode, leftSource, leftCharCode;
|
|
375303
375354
|
fragment = this.generateExpression(expr.argument, Precedence.Unary, E_TTT);
|
|
375304
375355
|
if (space === "") {
|
|
375305
|
-
result =
|
|
375356
|
+
result = join78(expr.operator, fragment);
|
|
375306
375357
|
} else {
|
|
375307
375358
|
result = [expr.operator];
|
|
375308
375359
|
if (expr.operator.length > 2) {
|
|
375309
|
-
result =
|
|
375360
|
+
result = join78(result, fragment);
|
|
375310
375361
|
} else {
|
|
375311
375362
|
leftSource = toSourceNodeWhenNeeded(result).toString();
|
|
375312
375363
|
leftCharCode = leftSource.charCodeAt(leftSource.length - 1);
|
|
@@ -375329,7 +375380,7 @@ var require_escodegen = __commonJS({
|
|
|
375329
375380
|
result = "yield";
|
|
375330
375381
|
}
|
|
375331
375382
|
if (expr.argument) {
|
|
375332
|
-
result =
|
|
375383
|
+
result = join78(
|
|
375333
375384
|
result,
|
|
375334
375385
|
this.generateExpression(expr.argument, Precedence.Yield, E_TTT)
|
|
375335
375386
|
);
|
|
@@ -375337,7 +375388,7 @@ var require_escodegen = __commonJS({
|
|
|
375337
375388
|
return parenthesize(result, Precedence.Yield, precedence);
|
|
375338
375389
|
},
|
|
375339
375390
|
AwaitExpression: function(expr, precedence, flags) {
|
|
375340
|
-
var result =
|
|
375391
|
+
var result = join78(
|
|
375341
375392
|
expr.all ? "await*" : "await",
|
|
375342
375393
|
this.generateExpression(expr.argument, Precedence.Await, E_TTT)
|
|
375343
375394
|
);
|
|
@@ -375420,11 +375471,11 @@ var require_escodegen = __commonJS({
|
|
|
375420
375471
|
var result, fragment;
|
|
375421
375472
|
result = ["class"];
|
|
375422
375473
|
if (expr.id) {
|
|
375423
|
-
result =
|
|
375474
|
+
result = join78(result, this.generateExpression(expr.id, Precedence.Sequence, E_TTT));
|
|
375424
375475
|
}
|
|
375425
375476
|
if (expr.superClass) {
|
|
375426
|
-
fragment =
|
|
375427
|
-
result =
|
|
375477
|
+
fragment = join78("extends", this.generateExpression(expr.superClass, Precedence.Unary, E_TTT));
|
|
375478
|
+
result = join78(result, fragment);
|
|
375428
375479
|
}
|
|
375429
375480
|
result.push(space);
|
|
375430
375481
|
result.push(this.generateStatement(expr.body, S_TFFT));
|
|
@@ -375439,7 +375490,7 @@ var require_escodegen = __commonJS({
|
|
|
375439
375490
|
}
|
|
375440
375491
|
if (expr.kind === "get" || expr.kind === "set") {
|
|
375441
375492
|
fragment = [
|
|
375442
|
-
|
|
375493
|
+
join78(expr.kind, this.generatePropertyKey(expr.key, expr.computed)),
|
|
375443
375494
|
this.generateFunctionBody(expr.value)
|
|
375444
375495
|
];
|
|
375445
375496
|
} else {
|
|
@@ -375449,7 +375500,7 @@ var require_escodegen = __commonJS({
|
|
|
375449
375500
|
this.generateFunctionBody(expr.value)
|
|
375450
375501
|
];
|
|
375451
375502
|
}
|
|
375452
|
-
return
|
|
375503
|
+
return join78(result, fragment);
|
|
375453
375504
|
},
|
|
375454
375505
|
Property: function(expr, precedence, flags) {
|
|
375455
375506
|
if (expr.kind === "get" || expr.kind === "set") {
|
|
@@ -375644,7 +375695,7 @@ var require_escodegen = __commonJS({
|
|
|
375644
375695
|
for (i2 = 0, iz = expr.blocks.length; i2 < iz; ++i2) {
|
|
375645
375696
|
fragment = that.generateExpression(expr.blocks[i2], Precedence.Sequence, E_TTT);
|
|
375646
375697
|
if (i2 > 0 || extra.moz.comprehensionExpressionStartsWithAssignment) {
|
|
375647
|
-
result =
|
|
375698
|
+
result = join78(result, fragment);
|
|
375648
375699
|
} else {
|
|
375649
375700
|
result.push(fragment);
|
|
375650
375701
|
}
|
|
@@ -375652,13 +375703,13 @@ var require_escodegen = __commonJS({
|
|
|
375652
375703
|
});
|
|
375653
375704
|
}
|
|
375654
375705
|
if (expr.filter) {
|
|
375655
|
-
result =
|
|
375706
|
+
result = join78(result, "if" + space);
|
|
375656
375707
|
fragment = this.generateExpression(expr.filter, Precedence.Sequence, E_TTT);
|
|
375657
|
-
result =
|
|
375708
|
+
result = join78(result, ["(", fragment, ")"]);
|
|
375658
375709
|
}
|
|
375659
375710
|
if (!extra.moz.comprehensionExpressionStartsWithAssignment) {
|
|
375660
375711
|
fragment = this.generateExpression(expr.body, Precedence.Assignment, E_TTT);
|
|
375661
|
-
result =
|
|
375712
|
+
result = join78(result, fragment);
|
|
375662
375713
|
}
|
|
375663
375714
|
result.push(expr.type === Syntax.GeneratorExpression ? ")" : "]");
|
|
375664
375715
|
return result;
|
|
@@ -375674,8 +375725,8 @@ var require_escodegen = __commonJS({
|
|
|
375674
375725
|
} else {
|
|
375675
375726
|
fragment = this.generateExpression(expr.left, Precedence.Call, E_TTT);
|
|
375676
375727
|
}
|
|
375677
|
-
fragment =
|
|
375678
|
-
fragment =
|
|
375728
|
+
fragment = join78(fragment, expr.of ? "of" : "in");
|
|
375729
|
+
fragment = join78(fragment, this.generateExpression(expr.right, Precedence.Sequence, E_TTT));
|
|
375679
375730
|
return ["for" + space + "(", fragment, ")"];
|
|
375680
375731
|
},
|
|
375681
375732
|
SpreadElement: function(expr, precedence, flags) {
|
|
@@ -391641,10 +391692,10 @@ function transformHeader(header, options2) {
|
|
|
391641
391692
|
if (!newName) return null;
|
|
391642
391693
|
h2.name = h2.type === "directory" && !newName.endsWith("/") ? `${newName}/` : newName;
|
|
391643
391694
|
if (h2.linkname) {
|
|
391644
|
-
const
|
|
391645
|
-
if (
|
|
391695
|
+
const isAbsolute13 = h2.linkname.startsWith("/");
|
|
391696
|
+
if (isAbsolute13 || h2.type === "link") {
|
|
391646
391697
|
const stripped = stripPath(h2.linkname, strip2);
|
|
391647
|
-
h2.linkname =
|
|
391698
|
+
h2.linkname = isAbsolute13 ? `/${stripped}` || "/" : stripped;
|
|
391648
391699
|
}
|
|
391649
391700
|
}
|
|
391650
391701
|
}
|
|
@@ -392237,11 +392288,11 @@ function validateBounds(targetPath, destDir, errorMessage7) {
|
|
|
392237
392288
|
function normalizeName(name) {
|
|
392238
392289
|
const path27 = name.replace(/\\/g, "/");
|
|
392239
392290
|
if (path27.split("/").includes("..") || /^[a-zA-Z]:\.\./.test(path27)) throw new Error(`${name} points outside extraction directory`);
|
|
392240
|
-
let
|
|
392241
|
-
if (/^[a-zA-Z]:/.test(
|
|
392242
|
-
else if (
|
|
392243
|
-
if (process.platform === "win32") return
|
|
392244
|
-
return
|
|
392291
|
+
let relative18 = path27;
|
|
392292
|
+
if (/^[a-zA-Z]:/.test(relative18)) relative18 = relative18.replace(/^[a-zA-Z]:[/\\]?/, "");
|
|
392293
|
+
else if (relative18.startsWith("/")) relative18 = relative18.replace(/^\/+/, "");
|
|
392294
|
+
if (process.platform === "win32") return relative18.replace(/[<>:"|?*]/g, (char) => win32Reserved[char]);
|
|
392295
|
+
return relative18;
|
|
392245
392296
|
}
|
|
392246
392297
|
function packTar(sources, options2 = {}) {
|
|
392247
392298
|
const stream12 = new Readable5({ read() {
|
|
@@ -392970,7 +393021,7 @@ var init_fs = __esm({
|
|
|
392970
393021
|
// ../node_modules/.bun/@puppeteer+browsers@3.0.5+b412256286331130/node_modules/@puppeteer/browsers/lib/fileUtil.js
|
|
392971
393022
|
import { spawnSync as spawnSync4, spawn as spawn4, execFile as execFile8 } from "node:child_process";
|
|
392972
393023
|
import { createReadStream as createReadStream4 } from "node:fs";
|
|
392973
|
-
import { mkdir as
|
|
393024
|
+
import { mkdir as mkdir16, readdir as readdir19 } from "node:fs/promises";
|
|
392974
393025
|
import * as path19 from "node:path";
|
|
392975
393026
|
import { Stream as Stream7 } from "node:stream";
|
|
392976
393027
|
import { promisify as promisify9 } from "node:util";
|
|
@@ -392979,12 +393030,12 @@ async function unpackArchive(archivePath, folderPath) {
|
|
|
392979
393030
|
folderPath = path19.resolve(process.cwd(), folderPath);
|
|
392980
393031
|
}
|
|
392981
393032
|
if (archivePath.endsWith(".zip")) {
|
|
392982
|
-
await
|
|
393033
|
+
await mkdir16(folderPath, { recursive: true });
|
|
392983
393034
|
await extractZip(archivePath, folderPath);
|
|
392984
393035
|
} else if (archivePath.endsWith(".tar.bz2")) {
|
|
392985
393036
|
await extractTar(archivePath, folderPath, "bzip2");
|
|
392986
393037
|
} else if (archivePath.endsWith(".dmg")) {
|
|
392987
|
-
await
|
|
393038
|
+
await mkdir16(folderPath);
|
|
392988
393039
|
await installDMG(archivePath, folderPath);
|
|
392989
393040
|
} else if (archivePath.endsWith(".exe")) {
|
|
392990
393041
|
const result = spawnSync4(archivePath, [`/ExtractDir=${folderPath}`], {
|
|
@@ -393271,8 +393322,8 @@ var init_ProgressBar = __esm({
|
|
|
393271
393322
|
// ../node_modules/.bun/@puppeteer+browsers@3.0.5+b412256286331130/node_modules/@puppeteer/browsers/lib/install.js
|
|
393272
393323
|
import assert4 from "node:assert";
|
|
393273
393324
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
393274
|
-
import { existsSync as
|
|
393275
|
-
import { mkdir as
|
|
393325
|
+
import { existsSync as existsSync29, readFileSync as readFileSync13 } from "node:fs";
|
|
393326
|
+
import { mkdir as mkdir17, unlink as unlink6 } from "node:fs/promises";
|
|
393276
393327
|
import os11 from "node:os";
|
|
393277
393328
|
import path20 from "node:path";
|
|
393278
393329
|
function debugTime(label) {
|
|
@@ -393324,8 +393375,8 @@ async function installWithProviders(options2) {
|
|
|
393324
393375
|
continue;
|
|
393325
393376
|
}
|
|
393326
393377
|
debugInstall?.(`Successfully got URL from ${provider.getName()}: ${url2}`);
|
|
393327
|
-
if (!
|
|
393328
|
-
await
|
|
393378
|
+
if (!existsSync29(browserRoot)) {
|
|
393379
|
+
await mkdir17(browserRoot, { recursive: true });
|
|
393329
393380
|
}
|
|
393330
393381
|
return await installUrl(url2, options2, provider);
|
|
393331
393382
|
} catch (err) {
|
|
@@ -393356,7 +393407,7 @@ async function installDeps(installedBrowser) {
|
|
|
393356
393407
|
return;
|
|
393357
393408
|
}
|
|
393358
393409
|
const depsPath = path20.join(path20.dirname(installedBrowser.executablePath), "deb.deps");
|
|
393359
|
-
if (!
|
|
393410
|
+
if (!existsSync29(depsPath)) {
|
|
393360
393411
|
debugInstall?.(`deb.deps file was not found at ${depsPath}`);
|
|
393361
393412
|
return;
|
|
393362
393413
|
}
|
|
@@ -393397,14 +393448,14 @@ async function installUrl(url2, options2, provider) {
|
|
|
393397
393448
|
const cache = new Cache(options2.cacheDir);
|
|
393398
393449
|
const browserRoot = cache.browserRoot(options2.browser);
|
|
393399
393450
|
const archivePath = path20.join(browserRoot, `${options2.buildId}-${fileName}`);
|
|
393400
|
-
if (!
|
|
393401
|
-
await
|
|
393451
|
+
if (!existsSync29(browserRoot)) {
|
|
393452
|
+
await mkdir17(browserRoot, { recursive: true });
|
|
393402
393453
|
}
|
|
393403
393454
|
if (options2.expectedHash) {
|
|
393404
393455
|
debugInstall?.(`Using provided checksum for ${fileName}: ${options2.expectedHash}`);
|
|
393405
393456
|
}
|
|
393406
393457
|
if (!options2.unpack) {
|
|
393407
|
-
if (
|
|
393458
|
+
if (existsSync29(archivePath)) {
|
|
393408
393459
|
return archivePath;
|
|
393409
393460
|
}
|
|
393410
393461
|
debugInstall?.(`Downloading binary from ${url2}`);
|
|
@@ -393425,8 +393476,8 @@ async function installUrl(url2, options2, provider) {
|
|
|
393425
393476
|
cache.writeExecutablePath(options2.browser, options2.platform, options2.buildId, relativeExecutablePath6);
|
|
393426
393477
|
}
|
|
393427
393478
|
try {
|
|
393428
|
-
if (
|
|
393429
|
-
if (!
|
|
393479
|
+
if (existsSync29(outputPath)) {
|
|
393480
|
+
if (!existsSync29(installedBrowser.executablePath)) {
|
|
393430
393481
|
throw new Error(`The browser folder (${outputPath}) exists but the executable (${installedBrowser.executablePath}) is missing`);
|
|
393431
393482
|
}
|
|
393432
393483
|
await runSetup(installedBrowser);
|
|
@@ -393435,7 +393486,7 @@ async function installUrl(url2, options2, provider) {
|
|
|
393435
393486
|
}
|
|
393436
393487
|
return installedBrowser;
|
|
393437
393488
|
}
|
|
393438
|
-
if (!
|
|
393489
|
+
if (!existsSync29(archivePath)) {
|
|
393439
393490
|
debugInstall?.(`Downloading binary from ${url2}`);
|
|
393440
393491
|
try {
|
|
393441
393492
|
debugTime("download");
|
|
@@ -393464,7 +393515,7 @@ async function installUrl(url2, options2, provider) {
|
|
|
393464
393515
|
}
|
|
393465
393516
|
return installedBrowser;
|
|
393466
393517
|
} finally {
|
|
393467
|
-
if (
|
|
393518
|
+
if (existsSync29(archivePath)) {
|
|
393468
393519
|
await unlink6(archivePath);
|
|
393469
393520
|
}
|
|
393470
393521
|
}
|
|
@@ -393475,7 +393526,7 @@ async function runSetup(installedBrowser) {
|
|
|
393475
393526
|
debugTime("permissions");
|
|
393476
393527
|
const browserDir = path20.dirname(installedBrowser.executablePath);
|
|
393477
393528
|
const setupExePath = path20.join(browserDir, "setup.exe");
|
|
393478
|
-
if (!
|
|
393529
|
+
if (!existsSync29(setupExePath)) {
|
|
393479
393530
|
return;
|
|
393480
393531
|
}
|
|
393481
393532
|
spawnSync5(path20.join(browserDir, "setup.exe"), [`--configure-browser-in-directory=` + browserDir], {
|
|
@@ -395668,7 +395719,7 @@ var require_get_caller_file = __commonJS({
|
|
|
395668
395719
|
import { notStrictEqual, strictEqual } from "assert";
|
|
395669
395720
|
import { inspect } from "util";
|
|
395670
395721
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
395671
|
-
import { basename as basename15, dirname as dirname20, extname as extname8, relative as
|
|
395722
|
+
import { basename as basename15, dirname as dirname20, extname as extname8, relative as relative16, resolve as resolve19, join as join63 } from "path";
|
|
395672
395723
|
import { createRequire as createRequire2 } from "node:module";
|
|
395673
395724
|
import { readFileSync as readFileSync16, readdirSync as readdirSync6 } from "node:fs";
|
|
395674
395725
|
var import_get_caller_file, __dirname3, mainFilename, require3, esm_default;
|
|
@@ -395703,9 +395754,9 @@ var init_esm3 = __esm({
|
|
|
395703
395754
|
basename: basename15,
|
|
395704
395755
|
dirname: dirname20,
|
|
395705
395756
|
extname: extname8,
|
|
395706
|
-
relative:
|
|
395757
|
+
relative: relative16,
|
|
395707
395758
|
resolve: resolve19,
|
|
395708
|
-
join:
|
|
395759
|
+
join: join63
|
|
395709
395760
|
},
|
|
395710
395761
|
process: {
|
|
395711
395762
|
argv: () => process.argv,
|
|
@@ -396863,13 +396914,13 @@ function usage(yargs, shim3) {
|
|
|
396863
396914
|
};
|
|
396864
396915
|
self2.stringifiedValues = function stringifiedValues(values, separator) {
|
|
396865
396916
|
let string5 = "";
|
|
396866
|
-
const
|
|
396917
|
+
const sep11 = separator || ", ";
|
|
396867
396918
|
const array3 = [].concat(values);
|
|
396868
396919
|
if (!values || !array3.length)
|
|
396869
396920
|
return string5;
|
|
396870
396921
|
array3.forEach((value) => {
|
|
396871
396922
|
if (string5.length)
|
|
396872
|
-
string5 +=
|
|
396923
|
+
string5 += sep11;
|
|
396873
396924
|
string5 += JSON.stringify(value);
|
|
396874
396925
|
});
|
|
396875
396926
|
return string5;
|
|
@@ -399630,9 +399681,9 @@ async function getConnectionTransport(options2) {
|
|
|
399630
399681
|
throw new Error("Could not detect required browser platform");
|
|
399631
399682
|
}
|
|
399632
399683
|
const { convertPuppeteerChannelToBrowsersChannel: convertPuppeteerChannelToBrowsersChannel2 } = await Promise.resolve().then(() => (init_LaunchOptions(), LaunchOptions_exports));
|
|
399633
|
-
const { join:
|
|
399684
|
+
const { join: join78 } = await import("node:path");
|
|
399634
399685
|
const userDataDir = resolveDefaultUserDataDir3(Browser4.CHROME, platform2, convertPuppeteerChannelToBrowsersChannel2(options2.channel));
|
|
399635
|
-
const portPath =
|
|
399686
|
+
const portPath = join78(userDataDir, "DevToolsActivePort");
|
|
399636
399687
|
try {
|
|
399637
399688
|
const fileContent = await environment.value.fs.promises.readFile(portPath, "ascii");
|
|
399638
399689
|
const [rawPort, rawPath] = fileContent.split("\n").map((line) => {
|
|
@@ -399955,9 +400006,9 @@ var init_PipeTransport = __esm({
|
|
|
399955
400006
|
});
|
|
399956
400007
|
|
|
399957
400008
|
// ../node_modules/.bun/puppeteer-core@25.2.1+b412256286331130/node_modules/puppeteer-core/lib/puppeteer/node/BrowserLauncher.js
|
|
399958
|
-
import { existsSync as
|
|
400009
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
399959
400010
|
import { tmpdir as tmpdir8 } from "node:os";
|
|
399960
|
-
import { join as
|
|
400011
|
+
import { join as join64 } from "node:path";
|
|
399961
400012
|
function getBrowserTypeDisplayName(browserType) {
|
|
399962
400013
|
switch (browserType) {
|
|
399963
400014
|
case Browser3.FIREFOX:
|
|
@@ -400014,7 +400065,7 @@ var init_BrowserLauncher = __esm({
|
|
|
400014
400065
|
...options2,
|
|
400015
400066
|
protocol
|
|
400016
400067
|
});
|
|
400017
|
-
if (!
|
|
400068
|
+
if (!existsSync30(launchArgs.executablePath)) {
|
|
400018
400069
|
throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
|
|
400019
400070
|
}
|
|
400020
400071
|
const usePipe = launchArgs.args.includes("--remote-debugging-pipe");
|
|
@@ -400091,7 +400142,7 @@ var init_BrowserLauncher = __esm({
|
|
|
400091
400142
|
const logs = browserProcess.getRecentLogs().join("\n");
|
|
400092
400143
|
if (logs.includes("Failed to create a ProcessSingleton for your profile directory") || // On Windows we will not get logs due to the singleton process handover. See
|
|
400093
400144
|
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/process_singleton_win.cc;l=46;drc=fc7952f0422b5073515a205a04ec9c3a1ae81658
|
|
400094
|
-
process.platform === "win32" &&
|
|
400145
|
+
process.platform === "win32" && existsSync30(join64(launchArgs.userDataDir, "lockfile"))) {
|
|
400095
400146
|
throw new Error(`The browser is already running for ${launchArgs.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`);
|
|
400096
400147
|
}
|
|
400097
400148
|
if (logs.includes("Missing X server") && options2.headless === false) {
|
|
@@ -400220,7 +400271,7 @@ var init_BrowserLauncher = __esm({
|
|
|
400220
400271
|
*/
|
|
400221
400272
|
async getProfilePath() {
|
|
400222
400273
|
const config3 = await this.puppeteer.configuration();
|
|
400223
|
-
return
|
|
400274
|
+
return join64(config3.temporaryDirectory ?? tmpdir8(), `puppeteer_dev_${this.browser}_profile-`);
|
|
400224
400275
|
}
|
|
400225
400276
|
/**
|
|
400226
400277
|
* @internal
|
|
@@ -400229,7 +400280,7 @@ var init_BrowserLauncher = __esm({
|
|
|
400229
400280
|
const config3 = await this.puppeteer.configuration();
|
|
400230
400281
|
let executablePath3 = config3.executablePath;
|
|
400231
400282
|
if (executablePath3) {
|
|
400232
|
-
if (validatePath && !
|
|
400283
|
+
if (validatePath && !existsSync30(executablePath3)) {
|
|
400233
400284
|
throw new Error(`Tried to find the browser at the configured path (${executablePath3}), but no executable was found.`);
|
|
400234
400285
|
}
|
|
400235
400286
|
return executablePath3;
|
|
@@ -400254,7 +400305,7 @@ var init_BrowserLauncher = __esm({
|
|
|
400254
400305
|
browser: browserType,
|
|
400255
400306
|
buildId: browserVersion
|
|
400256
400307
|
});
|
|
400257
|
-
if (validatePath && !
|
|
400308
|
+
if (validatePath && !existsSync30(executablePath3)) {
|
|
400258
400309
|
const configVersion = config3?.[this.browser]?.version;
|
|
400259
400310
|
if (configVersion) {
|
|
400260
400311
|
throw new Error(`Tried to find the browser at the configured path (${executablePath3}) for version ${configVersion}, but no executable was found.`);
|
|
@@ -401625,7 +401676,7 @@ var require_src7 = __commonJS({
|
|
|
401625
401676
|
|
|
401626
401677
|
// ../node_modules/.bun/puppeteer@25.2.1+b412256286331130/node_modules/puppeteer/lib/puppeteer/getConfiguration.js
|
|
401627
401678
|
import { homedir as homedir10 } from "node:os";
|
|
401628
|
-
import { join as
|
|
401679
|
+
import { join as join65 } from "node:path";
|
|
401629
401680
|
function getBooleanEnvVar(name) {
|
|
401630
401681
|
const env3 = process.env[name];
|
|
401631
401682
|
if (env3 === void 0) {
|
|
@@ -401712,7 +401763,7 @@ var init_getConfiguration = __esm({
|
|
|
401712
401763
|
configuration.firefox = getBrowserSetting("firefox", configuration, {
|
|
401713
401764
|
skipDownload: true
|
|
401714
401765
|
});
|
|
401715
|
-
configuration.cacheDirectory = process.env["PUPPETEER_CACHE_DIR"] ?? configuration.cacheDirectory ??
|
|
401766
|
+
configuration.cacheDirectory = process.env["PUPPETEER_CACHE_DIR"] ?? configuration.cacheDirectory ?? join65(homedir10(), ".cache", "puppeteer");
|
|
401716
401767
|
configuration.temporaryDirectory = process.env["PUPPETEER_TMP_DIR"] ?? configuration.temporaryDirectory;
|
|
401717
401768
|
configuration.experiments ??= {};
|
|
401718
401769
|
return configuration;
|
|
@@ -405349,11 +405400,11 @@ var require_excerpt = __commonJS({
|
|
|
405349
405400
|
if (typeof opts.excerpt === "function") {
|
|
405350
405401
|
return opts.excerpt(file2, opts);
|
|
405351
405402
|
}
|
|
405352
|
-
const
|
|
405353
|
-
if (
|
|
405403
|
+
const sep11 = file2.data.excerpt_separator || opts.excerpt_separator;
|
|
405404
|
+
if (sep11 == null && (opts.excerpt === false || opts.excerpt == null)) {
|
|
405354
405405
|
return file2;
|
|
405355
405406
|
}
|
|
405356
|
-
const delimiter2 = typeof opts.excerpt === "string" ? opts.excerpt :
|
|
405407
|
+
const delimiter2 = typeof opts.excerpt === "string" ? opts.excerpt : sep11 || opts.delimiters[0];
|
|
405357
405408
|
const idx = file2.content.indexOf(delimiter2);
|
|
405358
405409
|
if (idx !== -1) {
|
|
405359
405410
|
file2.excerpt = file2.content.slice(0, idx);
|
|
@@ -472234,7 +472285,7 @@ var require_src8 = __commonJS({
|
|
|
472234
472285
|
var { promisify: promisify10 } = __require("util");
|
|
472235
472286
|
var path27 = __require("path");
|
|
472236
472287
|
var { createHash: createHash18 } = __require("crypto");
|
|
472237
|
-
var { realpath:
|
|
472288
|
+
var { realpath: realpath4, lstat: lstat4, createReadStream: createReadStream6, readdir: readdir23 } = __require("fs");
|
|
472238
472289
|
var url2 = __require("url");
|
|
472239
472290
|
var slasher = require_glob_slash();
|
|
472240
472291
|
var minimatch = require_minimatch();
|
|
@@ -472539,12 +472590,12 @@ var require_src8 = __commonJS({
|
|
|
472539
472590
|
}).filter(Boolean);
|
|
472540
472591
|
if (toRoot.length > 0) {
|
|
472541
472592
|
const directoryPath = [...pathParts].slice(1);
|
|
472542
|
-
const
|
|
472593
|
+
const relative18 = path27.join("/", ...directoryPath, "..", slashSuffix);
|
|
472543
472594
|
files.unshift({
|
|
472544
472595
|
type: "directory",
|
|
472545
472596
|
base: "..",
|
|
472546
|
-
relative:
|
|
472547
|
-
title:
|
|
472597
|
+
relative: relative18,
|
|
472598
|
+
title: relative18,
|
|
472548
472599
|
ext: ""
|
|
472549
472600
|
});
|
|
472550
472601
|
}
|
|
@@ -472625,8 +472676,8 @@ var require_src8 = __commonJS({
|
|
|
472625
472676
|
return sendError2(...args2);
|
|
472626
472677
|
};
|
|
472627
472678
|
var getHandlers = (methods) => Object.assign({
|
|
472628
|
-
lstat: promisify10(
|
|
472629
|
-
realpath: promisify10(
|
|
472679
|
+
lstat: promisify10(lstat4),
|
|
472680
|
+
realpath: promisify10(realpath4),
|
|
472630
472681
|
createReadStream: createReadStream6,
|
|
472631
472682
|
readdir: promisify10(readdir23),
|
|
472632
472683
|
sendError: sendError2
|
|
@@ -472850,8 +472901,8 @@ var require_dist18 = __commonJS({
|
|
|
472850
472901
|
});
|
|
472851
472902
|
|
|
472852
472903
|
// src/features/threads/threads-explorer.route.ts
|
|
472853
|
-
import { readdir as readdir20, readFile as readFile28, rename as rename6, writeFile as writeFile18, mkdir as
|
|
472854
|
-
import { isAbsolute as
|
|
472904
|
+
import { readdir as readdir20, readFile as readFile28, rename as rename6, writeFile as writeFile18, mkdir as mkdir18, access as access8, open as open6, stat as stat16, rm as rm14 } from "fs/promises";
|
|
472905
|
+
import { isAbsolute as isAbsolute12, join as join66, resolve as resolve20, basename as basename16 } from "path";
|
|
472855
472906
|
import { spawn as spawn7 } from "child_process";
|
|
472856
472907
|
async function resolveExplorerThread(c, threadManager) {
|
|
472857
472908
|
const existing = await requireThreadById(c, threadManager);
|
|
@@ -473045,7 +473096,7 @@ async function listExplorerEntriesRecursive(rootPath, currentPath, relativePath)
|
|
|
473045
473096
|
const dirents = await readdir20(currentPath, { withFileTypes: true });
|
|
473046
473097
|
const isRoot = relativePath.length === 0;
|
|
473047
473098
|
const entries = dirents.filter((d) => !(isRoot && d.name === ".git") && d.name !== "node_modules").map((d) => {
|
|
473048
|
-
const entryPath = relativePath ?
|
|
473099
|
+
const entryPath = relativePath ? join66(relativePath, d.name) : d.name;
|
|
473049
473100
|
return {
|
|
473050
473101
|
name: d.name,
|
|
473051
473102
|
type: d.isDirectory() ? "folder" : "file",
|
|
@@ -473057,7 +473108,7 @@ async function listExplorerEntriesRecursive(rootPath, currentPath, relativePath)
|
|
|
473057
473108
|
});
|
|
473058
473109
|
const nestedEntries = await Promise.all(
|
|
473059
473110
|
entries.filter((entry) => entry.type === "folder").map(
|
|
473060
|
-
(entry) => listExplorerEntriesRecursive(rootPath,
|
|
473111
|
+
(entry) => listExplorerEntriesRecursive(rootPath, join66(rootPath, entry.path), entry.path)
|
|
473061
473112
|
)
|
|
473062
473113
|
);
|
|
473063
473114
|
return [...entries, ...nestedEntries.flat()];
|
|
@@ -473090,7 +473141,7 @@ async function handleListThreadExplorerDir(c, threadManager) {
|
|
|
473090
473141
|
const entries = recursive ? await listExplorerEntriesRecursive(thread.path, absDir, queryPath) : dirents.filter((d) => !(!queryPath && d.name === ".git")).map((d) => ({
|
|
473091
473142
|
name: d.name,
|
|
473092
473143
|
type: d.isDirectory() ? "folder" : "file",
|
|
473093
|
-
path: queryPath ?
|
|
473144
|
+
path: queryPath ? join66(queryPath, d.name) : d.name
|
|
473094
473145
|
})).sort((a2, b2) => {
|
|
473095
473146
|
if (a2.type !== b2.type) return a2.type === "folder" ? -1 : 1;
|
|
473096
473147
|
return a2.name.localeCompare(b2.name);
|
|
@@ -473197,11 +473248,11 @@ async function handlePrintMarkdownExplorerFile(c, threadManager) {
|
|
|
473197
473248
|
400
|
|
473198
473249
|
);
|
|
473199
473250
|
}
|
|
473200
|
-
const exportDir =
|
|
473201
|
-
await
|
|
473251
|
+
const exportDir = join66(resolved.thread.path, ".tarsk", "exports");
|
|
473252
|
+
await mkdir18(exportDir, { recursive: true });
|
|
473202
473253
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replaceAll(":", "-");
|
|
473203
473254
|
const safeBaseName = basename16(resolved.filePath, ".md").replace(/[^a-zA-Z0-9._-]+/g, "-") || "document";
|
|
473204
|
-
const outputPath =
|
|
473255
|
+
const outputPath = join66(exportDir, `${safeBaseName}-${timestamp}.pdf`);
|
|
473205
473256
|
await runMarkdownToPdf(resolved.absPath, outputPath);
|
|
473206
473257
|
await openExportPath(outputPath);
|
|
473207
473258
|
return c.json({ success: true, outputPath, outputKind: "pdf" });
|
|
@@ -473220,15 +473271,15 @@ async function handleCreateExplorerFile(c, threadManager) {
|
|
|
473220
473271
|
if (!resolved.ok) {
|
|
473221
473272
|
return resolved.response;
|
|
473222
473273
|
}
|
|
473223
|
-
await
|
|
473224
|
-
await writeFile18(
|
|
473274
|
+
await mkdir18(resolved.absParent, { recursive: true });
|
|
473275
|
+
await writeFile18(join66(resolved.absParent, resolved.name), "", "utf-8");
|
|
473225
473276
|
return c.json({ success: true, path: resolved.relPath });
|
|
473226
473277
|
} catch (error2) {
|
|
473227
473278
|
return caughtErrorResponse(c, ErrorCodes.INTERNAL_ERROR, "Failed to create file", error2);
|
|
473228
473279
|
}
|
|
473229
473280
|
}
|
|
473230
473281
|
function resolveExplorerMediaAbsolutePath(threadPath, filePath) {
|
|
473231
|
-
if (
|
|
473282
|
+
if (isAbsolute12(filePath)) {
|
|
473232
473283
|
const normalized = resolve20(filePath);
|
|
473233
473284
|
const dataDir = resolve20(getDataDir());
|
|
473234
473285
|
if ((normalized === dataDir || normalized.startsWith(`${dataDir}/`)) && getExplorerFileMediaType(normalized)) {
|
|
@@ -473434,7 +473485,7 @@ async function handleUploadExplorerFile(c, threadManager) {
|
|
|
473434
473485
|
}
|
|
473435
473486
|
const writeResult = await writeExplorerUpload(
|
|
473436
473487
|
c,
|
|
473437
|
-
|
|
473488
|
+
join66(parent.absParent, name),
|
|
473438
473489
|
name,
|
|
473439
473490
|
upload.data
|
|
473440
473491
|
);
|
|
@@ -473459,7 +473510,7 @@ async function handleCreateExplorerFolder(c, threadManager) {
|
|
|
473459
473510
|
if (!resolved.ok) {
|
|
473460
473511
|
return resolved.response;
|
|
473461
473512
|
}
|
|
473462
|
-
await
|
|
473513
|
+
await mkdir18(join66(resolved.absParent, resolved.name), { recursive: true });
|
|
473463
473514
|
return c.json({ success: true, path: resolved.relPath });
|
|
473464
473515
|
} catch (error2) {
|
|
473465
473516
|
return caughtErrorResponse(c, ErrorCodes.INTERNAL_ERROR, "Failed to create folder", error2);
|
|
@@ -473507,7 +473558,7 @@ async function handleGitIgnoreExplorerItem(c, threadManager) {
|
|
|
473507
473558
|
return c.json({ error: { code: "NOT_FOUND", message: `Not found: ${filePath}` } }, 404);
|
|
473508
473559
|
}
|
|
473509
473560
|
const entry = toGitignoreEntry(filePath, isDirectory);
|
|
473510
|
-
const gitignorePath =
|
|
473561
|
+
const gitignorePath = join66(resolved.thread.path, ".gitignore");
|
|
473511
473562
|
let existingContent = "";
|
|
473512
473563
|
try {
|
|
473513
473564
|
existingContent = await readFile28(gitignorePath, "utf-8");
|
|
@@ -473901,8 +473952,8 @@ var init_github_folder = __esm({
|
|
|
473901
473952
|
});
|
|
473902
473953
|
|
|
473903
473954
|
// src/features/git/git-download-folder.ts
|
|
473904
|
-
import { mkdir as
|
|
473905
|
-
import { dirname as dirname22, join as
|
|
473955
|
+
import { mkdir as mkdir19, writeFile as writeFile19 } from "fs/promises";
|
|
473956
|
+
import { dirname as dirname22, join as join67 } from "path";
|
|
473906
473957
|
async function downloadGithubFolder(repoUrl, srcPath, destPath, options2 = {}) {
|
|
473907
473958
|
const { ref, excludeRelativePrefixes = [] } = options2;
|
|
473908
473959
|
const { files, ref: refParam } = await listGithubFolderFiles(repoUrl, srcPath, options2);
|
|
@@ -473910,8 +473961,8 @@ async function downloadGithubFolder(repoUrl, srcPath, destPath, options2 = {}) {
|
|
|
473910
473961
|
log145.info(`Downloading ${files.length} file(s) from ${owner}/${repo}/${srcPath} \u2192 ${destPath}`);
|
|
473911
473962
|
await Promise.all(
|
|
473912
473963
|
files.map(async (relativePath) => {
|
|
473913
|
-
const localPath =
|
|
473914
|
-
await
|
|
473964
|
+
const localPath = join67(destPath, relativePath);
|
|
473965
|
+
await mkdir19(dirname22(localPath), { recursive: true });
|
|
473915
473966
|
const content = await fetchGithubFolderFile(repoUrl, srcPath, relativePath, {
|
|
473916
473967
|
...options2,
|
|
473917
473968
|
ref: ref ?? refParam,
|
|
@@ -474224,7 +474275,7 @@ var init_skills_sources = __esm({
|
|
|
474224
474275
|
|
|
474225
474276
|
// src/features/skills/skills.catalog-cache.ts
|
|
474226
474277
|
import { cp as cp4, mkdtemp as mkdtemp8, readdir as readdir21, readFile as readFile29, rm as rm16 } from "fs/promises";
|
|
474227
|
-
import { join as
|
|
474278
|
+
import { join as join68, relative as relative17, sep as sep10 } from "path";
|
|
474228
474279
|
import { tmpdir as tmpdir9 } from "os";
|
|
474229
474280
|
function getBundledSkillSourceById(sourceId) {
|
|
474230
474281
|
return skills_sources_default.find((source2) => source2.id === sourceId);
|
|
@@ -474247,20 +474298,20 @@ async function listFilesRecursive(dir, rootDir = dir) {
|
|
|
474247
474298
|
const entries = await readdir21(dir, { withFileTypes: true });
|
|
474248
474299
|
const files = [];
|
|
474249
474300
|
for (const entry of entries) {
|
|
474250
|
-
const fullPath =
|
|
474301
|
+
const fullPath = join68(dir, entry.name);
|
|
474251
474302
|
if (entry.isDirectory()) {
|
|
474252
474303
|
files.push(...await listFilesRecursive(fullPath, rootDir));
|
|
474253
474304
|
continue;
|
|
474254
474305
|
}
|
|
474255
474306
|
if (entry.isFile()) {
|
|
474256
|
-
files.push(
|
|
474307
|
+
files.push(relative17(rootDir, fullPath));
|
|
474257
474308
|
}
|
|
474258
474309
|
}
|
|
474259
474310
|
return files.sort((a2, b2) => a2.localeCompare(b2));
|
|
474260
474311
|
}
|
|
474261
474312
|
function resolveSkillRelativePath(skillDir, relativePath) {
|
|
474262
|
-
const resolved =
|
|
474263
|
-
const normalizedSkillDir = skillDir.endsWith(
|
|
474313
|
+
const resolved = join68(skillDir, relativePath);
|
|
474314
|
+
const normalizedSkillDir = skillDir.endsWith(sep10) ? skillDir : `${skillDir}${sep10}`;
|
|
474264
474315
|
if (resolved === skillDir || resolved.startsWith(normalizedSkillDir)) {
|
|
474265
474316
|
return resolved;
|
|
474266
474317
|
}
|
|
@@ -474275,7 +474326,7 @@ async function ensureCatalogClone(sourceId) {
|
|
|
474275
474326
|
}
|
|
474276
474327
|
async function getSkillDirEnsured(sourceId, skillId) {
|
|
474277
474328
|
const entry = await ensureCatalogClone(sourceId);
|
|
474278
|
-
return
|
|
474329
|
+
return join68(entry.scanDir, skillId);
|
|
474279
474330
|
}
|
|
474280
474331
|
async function cloneSourceToCache(sourceId, trustedUrl) {
|
|
474281
474332
|
let url2;
|
|
@@ -474288,11 +474339,11 @@ async function cloneSourceToCache(sourceId, trustedUrl) {
|
|
|
474288
474339
|
url2 = (await resolveSkillSource(sourceId)).url;
|
|
474289
474340
|
}
|
|
474290
474341
|
const parsed = parseGithubTreeUrl(url2);
|
|
474291
|
-
const cloneDir = await mkdtemp8(
|
|
474342
|
+
const cloneDir = await mkdtemp8(join68(tmpdir9(), "tarsk-skills-catalog-clone-"));
|
|
474292
474343
|
await cloneGithubRepoFolder(cloneDir, parsed.repoUrl, parsed.folderPath, {
|
|
474293
474344
|
ref: parsed.ref
|
|
474294
474345
|
});
|
|
474295
|
-
const scanDir = parsed.folderPath ?
|
|
474346
|
+
const scanDir = parsed.folderPath ? join68(cloneDir, parsed.folderPath) : cloneDir;
|
|
474296
474347
|
const entry = {
|
|
474297
474348
|
sourceId,
|
|
474298
474349
|
cloneDir,
|
|
@@ -474721,7 +474772,7 @@ var init_script_process_manager = __esm({
|
|
|
474721
474772
|
});
|
|
474722
474773
|
|
|
474723
474774
|
// src/features/threads/threads-project-scripts.route.ts
|
|
474724
|
-
import { join as
|
|
474775
|
+
import { join as join69 } from "path";
|
|
474725
474776
|
async function handleGetProjectScripts(c, threadManager) {
|
|
474726
474777
|
try {
|
|
474727
474778
|
const existing = await requireThreadById(c, threadManager);
|
|
@@ -474806,7 +474857,7 @@ function resolveCwd(threadPath, relativeFolder) {
|
|
|
474806
474857
|
if (relativeFolder.startsWith("/")) {
|
|
474807
474858
|
return relativeFolder;
|
|
474808
474859
|
}
|
|
474809
|
-
return
|
|
474860
|
+
return join69(threadPath, relativeFolder);
|
|
474810
474861
|
}
|
|
474811
474862
|
return threadPath;
|
|
474812
474863
|
}
|
|
@@ -474959,7 +475010,7 @@ var init_threads_routes = __esm({
|
|
|
474959
475010
|
});
|
|
474960
475011
|
|
|
474961
475012
|
// src/features/git/git.manager.ts
|
|
474962
|
-
import { mkdir as
|
|
475013
|
+
import { mkdir as mkdir20, rm as rm17 } from "fs/promises";
|
|
474963
475014
|
import { dirname as dirname23 } from "path";
|
|
474964
475015
|
async function storeVerifiedCredential(host, credential) {
|
|
474965
475016
|
try {
|
|
@@ -475121,7 +475172,7 @@ var init_git_manager = __esm({
|
|
|
475121
475172
|
}
|
|
475122
475173
|
try {
|
|
475123
475174
|
const parentDir = dirname23(targetPath);
|
|
475124
|
-
await
|
|
475175
|
+
await mkdir20(parentDir, { recursive: true });
|
|
475125
475176
|
const outcome = yield* this.runCloneRetryLoop(
|
|
475126
475177
|
gitUrl,
|
|
475127
475178
|
targetPath,
|
|
@@ -475555,7 +475606,7 @@ var init_git_manager = __esm({
|
|
|
475555
475606
|
}
|
|
475556
475607
|
async initRepository(repoPath) {
|
|
475557
475608
|
try {
|
|
475558
|
-
await
|
|
475609
|
+
await mkdir20(repoPath, { recursive: true });
|
|
475559
475610
|
} catch (error2) {
|
|
475560
475611
|
if (error2.code !== "EEXIST") {
|
|
475561
475612
|
throw error2;
|
|
@@ -475636,7 +475687,7 @@ var init_git_auth_status_route = __esm({
|
|
|
475636
475687
|
});
|
|
475637
475688
|
|
|
475638
475689
|
// src/features/git/git-route-context.ts
|
|
475639
|
-
import { existsSync as
|
|
475690
|
+
import { existsSync as existsSync31 } from "fs";
|
|
475640
475691
|
async function resolveGitThreadContext(c, metadataManager, options2 = {}) {
|
|
475641
475692
|
const threadId = c.req.param("threadId");
|
|
475642
475693
|
if (!threadId) {
|
|
@@ -475652,7 +475703,7 @@ async function resolveGitThreadContext(c, metadataManager, options2 = {}) {
|
|
|
475652
475703
|
return { ok: false, response: c.json({ error: "Thread path not found" }, 404) };
|
|
475653
475704
|
}
|
|
475654
475705
|
const absolutePath = resolveThreadPath(repoPath);
|
|
475655
|
-
if (options2.requirePathExists && !
|
|
475706
|
+
if (options2.requirePathExists && !existsSync31(absolutePath)) {
|
|
475656
475707
|
return {
|
|
475657
475708
|
ok: false,
|
|
475658
475709
|
response: c.json(
|
|
@@ -475905,7 +475956,7 @@ var init_git_diff_route = __esm({
|
|
|
475905
475956
|
});
|
|
475906
475957
|
|
|
475907
475958
|
// src/features/git/git-generate-commit-message.route.ts
|
|
475908
|
-
import { existsSync as
|
|
475959
|
+
import { existsSync as existsSync32 } from "fs";
|
|
475909
475960
|
async function gitGenerateCommitMessageHandler(c, metadataManager) {
|
|
475910
475961
|
try {
|
|
475911
475962
|
const threadId = c.req.param("threadId");
|
|
@@ -475930,7 +475981,7 @@ async function gitGenerateCommitMessageHandler(c, metadataManager) {
|
|
|
475930
475981
|
const absolutePath = resolveThreadPath(repoPath);
|
|
475931
475982
|
tarskDebugWrite(`[generate-commit-message] resolved path: ${absolutePath}
|
|
475932
475983
|
`);
|
|
475933
|
-
if (!
|
|
475984
|
+
if (!existsSync32(absolutePath)) {
|
|
475934
475985
|
tarskDebugWrite(`[generate-commit-message] path does not exist: ${absolutePath}
|
|
475935
475986
|
`);
|
|
475936
475987
|
return c.json(
|
|
@@ -476527,7 +476578,7 @@ var init_git_github_status_route = __esm({
|
|
|
476527
476578
|
});
|
|
476528
476579
|
|
|
476529
476580
|
// src/features/git/git-unified-status.route.ts
|
|
476530
|
-
import { existsSync as
|
|
476581
|
+
import { existsSync as existsSync33 } from "fs";
|
|
476531
476582
|
function buildRepoUrl(remoteUrl, isOnGitHub) {
|
|
476532
476583
|
if (!isOnGitHub) return "";
|
|
476533
476584
|
if (remoteUrl.startsWith("https://")) {
|
|
@@ -476621,7 +476672,7 @@ async function computeUnifiedGitStatus(db, threadId, fresh, tracker = createSile
|
|
|
476621
476672
|
throw new Error("Thread path not found");
|
|
476622
476673
|
}
|
|
476623
476674
|
const absolutePath = resolveThreadPath(repoPath);
|
|
476624
|
-
if (!
|
|
476675
|
+
if (!existsSync33(absolutePath)) {
|
|
476625
476676
|
throw new Error(
|
|
476626
476677
|
`Thread repo path does not exist: ${absolutePath}. Check that the project folder is present.`
|
|
476627
476678
|
);
|
|
@@ -476957,7 +477008,7 @@ var init_git_create_branch_route = __esm({
|
|
|
476957
477008
|
});
|
|
476958
477009
|
|
|
476959
477010
|
// src/features/git/git-sync-branch.route.ts
|
|
476960
|
-
import { existsSync as
|
|
477011
|
+
import { existsSync as existsSync34 } from "fs";
|
|
476961
477012
|
async function gitSyncBranchHandler(c, metadataManager) {
|
|
476962
477013
|
try {
|
|
476963
477014
|
const threadId = c.req.param("threadId");
|
|
@@ -476974,7 +477025,7 @@ async function gitSyncBranchHandler(c, metadataManager) {
|
|
|
476974
477025
|
}
|
|
476975
477026
|
const absolutePath = resolveThreadPath(repoPath);
|
|
476976
477027
|
log154.info("Resolved thread path", { absolutePath });
|
|
476977
|
-
if (!
|
|
477028
|
+
if (!existsSync34(absolutePath)) {
|
|
476978
477029
|
log154.warn("Thread repo path does not exist", { absolutePath });
|
|
476979
477030
|
return c.json(
|
|
476980
477031
|
{
|
|
@@ -477721,7 +477772,7 @@ var init_git_rename_branch_route = __esm({
|
|
|
477721
477772
|
});
|
|
477722
477773
|
|
|
477723
477774
|
// src/features/git/git-media.route.ts
|
|
477724
|
-
import { readFileSync as readFileSync18, existsSync as
|
|
477775
|
+
import { readFileSync as readFileSync18, existsSync as existsSync35 } from "fs";
|
|
477725
477776
|
import { resolve as resolve23 } from "path";
|
|
477726
477777
|
import { spawn as spawn8 } from "child_process";
|
|
477727
477778
|
function spawnBinary(command2, args2, cwd) {
|
|
@@ -477771,7 +477822,7 @@ async function gitMediaHandler(c, metadataManager) {
|
|
|
477771
477822
|
}
|
|
477772
477823
|
} else {
|
|
477773
477824
|
const absFilePath = resolve23(gitRoot, filePath);
|
|
477774
|
-
if (!
|
|
477825
|
+
if (!existsSync35(absFilePath)) {
|
|
477775
477826
|
return c.json({ error: `File not found in working directory: ${filePath}` }, 404);
|
|
477776
477827
|
}
|
|
477777
477828
|
data = readFileSync18(absFilePath);
|
|
@@ -478654,11 +478705,11 @@ var init_mcp_popular = __esm({
|
|
|
478654
478705
|
});
|
|
478655
478706
|
|
|
478656
478707
|
// src/features/mcp/mcp.routes.ts
|
|
478657
|
-
import { readFile as readFile30, writeFile as writeFile20, mkdir as
|
|
478658
|
-
import { join as
|
|
478708
|
+
import { readFile as readFile30, writeFile as writeFile20, mkdir as mkdir21, access as access9 } from "fs/promises";
|
|
478709
|
+
import { join as join70, dirname as dirname24 } from "path";
|
|
478659
478710
|
async function readMCPConfig(projectPath) {
|
|
478660
478711
|
for (const configPath of MCP_CONFIG_PATHS2) {
|
|
478661
|
-
const fullPath =
|
|
478712
|
+
const fullPath = join70(projectPath, configPath);
|
|
478662
478713
|
try {
|
|
478663
478714
|
await access9(fullPath);
|
|
478664
478715
|
const content = await readFile30(fullPath, "utf-8");
|
|
@@ -478673,8 +478724,8 @@ async function readMCPConfig(projectPath) {
|
|
|
478673
478724
|
}
|
|
478674
478725
|
async function writeMCPConfig(projectPath, config3) {
|
|
478675
478726
|
const existing = await readMCPConfig(projectPath);
|
|
478676
|
-
const targetPath = existing?.filePath ??
|
|
478677
|
-
await
|
|
478727
|
+
const targetPath = existing?.filePath ?? join70(projectPath, ".agents/mcp.json");
|
|
478728
|
+
await mkdir21(dirname24(targetPath), { recursive: true });
|
|
478678
478729
|
await writeFile20(targetPath, JSON.stringify(config3, null, 2), "utf-8");
|
|
478679
478730
|
}
|
|
478680
478731
|
async function resolveRemoteServer(projectPath, serverName) {
|
|
@@ -479128,7 +479179,7 @@ var init_skills_popular = __esm({
|
|
|
479128
479179
|
|
|
479129
479180
|
// src/features/skills/skills.catalog.ts
|
|
479130
479181
|
import { readdir as readdir22, readFile as readFile31 } from "fs/promises";
|
|
479131
|
-
import { join as
|
|
479182
|
+
import { join as join71 } from "path";
|
|
479132
479183
|
function getSkillSources() {
|
|
479133
479184
|
const sources = skills_sources_default;
|
|
479134
479185
|
return [...sources].sort((a2, b2) => a2.title.localeCompare(b2.title));
|
|
@@ -479147,7 +479198,7 @@ async function scanDownloadedSkillCatalog(tmpDir, parsed, sourceId) {
|
|
|
479147
479198
|
if (!entry.isDirectory()) {
|
|
479148
479199
|
continue;
|
|
479149
479200
|
}
|
|
479150
|
-
const skillMdPath =
|
|
479201
|
+
const skillMdPath = join71(tmpDir, entry.name, "SKILL.md");
|
|
479151
479202
|
let skillMdContent;
|
|
479152
479203
|
try {
|
|
479153
479204
|
skillMdContent = await readFile31(skillMdPath, "utf8");
|
|
@@ -479559,10 +479610,10 @@ var init_agents_routes = __esm({
|
|
|
479559
479610
|
});
|
|
479560
479611
|
|
|
479561
479612
|
// src/features/project-tasks/task-execution.ts
|
|
479562
|
-
import { randomUUID as
|
|
479613
|
+
import { randomUUID as randomUUID28 } from "node:crypto";
|
|
479563
479614
|
function uniqueAutomationBranchName(title) {
|
|
479564
479615
|
const titlePrefix = title.trim().slice(0, 80);
|
|
479565
|
-
return `${titlePrefix ? `${titlePrefix}-` : ""}${
|
|
479616
|
+
return `${titlePrefix ? `${titlePrefix}-` : ""}${randomUUID28()}`;
|
|
479566
479617
|
}
|
|
479567
479618
|
function claimFailureMessage(task) {
|
|
479568
479619
|
return `Failed to claim task: ${task.id}`;
|
|
@@ -480687,7 +480738,6 @@ var init_remote_machines_routes = __esm({
|
|
|
480687
480738
|
// src/features/account/account.routes.ts
|
|
480688
480739
|
function createAccountRoutes(options2 = {}) {
|
|
480689
480740
|
const router = new Hono2();
|
|
480690
|
-
router.get("/info", (c) => getAccountInfo(c));
|
|
480691
480741
|
router.get("/settings", (c) => getAccountSettings(c));
|
|
480692
480742
|
router.put("/settings", (c) => updateAccountSettings(c, options2.metadataManager));
|
|
480693
480743
|
router.route("/remote-machines", createRemoteMachineRoutes());
|
|
@@ -480705,7 +480755,6 @@ var init_account_routes = __esm({
|
|
|
480705
480755
|
"src/features/account/account.routes.ts"() {
|
|
480706
480756
|
"use strict";
|
|
480707
480757
|
init_dist3();
|
|
480708
|
-
init_account_get_info_route();
|
|
480709
480758
|
init_account_settings_route();
|
|
480710
480759
|
init_account_delete_route();
|
|
480711
480760
|
init_latency_route();
|
|
@@ -481094,7 +481143,7 @@ Requirements
|
|
|
481094
481143
|
// src/features/slack/ensure-undici-for-socket-mode.ts
|
|
481095
481144
|
import { createRequire as createRequire3 } from "node:module";
|
|
481096
481145
|
import Module3 from "node:module";
|
|
481097
|
-
import { dirname as dirname25, join as
|
|
481146
|
+
import { dirname as dirname25, join as join72 } from "node:path";
|
|
481098
481147
|
function ensureUndiciPing() {
|
|
481099
481148
|
let shim3;
|
|
481100
481149
|
try {
|
|
@@ -481107,7 +481156,7 @@ function ensureUndiciPing() {
|
|
|
481107
481156
|
}
|
|
481108
481157
|
try {
|
|
481109
481158
|
const pkgPath = require4.resolve("undici/package.json");
|
|
481110
|
-
const realUndici = require4(
|
|
481159
|
+
const realUndici = require4(join72(dirname25(pkgPath), "index.js"));
|
|
481111
481160
|
if (typeof realUndici.ping !== "function") {
|
|
481112
481161
|
return;
|
|
481113
481162
|
}
|
|
@@ -488395,7 +488444,7 @@ var init_slack_shared = __esm({
|
|
|
488395
488444
|
});
|
|
488396
488445
|
|
|
488397
488446
|
// src/features/slack/slack.dispatch.ts
|
|
488398
|
-
import { randomUUID as
|
|
488447
|
+
import { randomUUID as randomUUID29 } from "crypto";
|
|
488399
488448
|
function clearBackgroundTurnRecovery() {
|
|
488400
488449
|
backgroundTurnRecovery.clear();
|
|
488401
488450
|
}
|
|
@@ -488661,7 +488710,7 @@ async function resolveOrCreateChannelThread(ctx, params) {
|
|
|
488661
488710
|
return { ok: false };
|
|
488662
488711
|
}
|
|
488663
488712
|
const tarskThreadId = createdThread.id;
|
|
488664
|
-
const nextConversationId = conversationId ??
|
|
488713
|
+
const nextConversationId = conversationId ?? randomUUID29();
|
|
488665
488714
|
const nextSlackMode = slackMode ?? (claimChannelDefault ? "plan" : "branch");
|
|
488666
488715
|
await announceChannelBranchReady(ctx, {
|
|
488667
488716
|
channelId,
|
|
@@ -488794,7 +488843,7 @@ async function claimChannelDefaultOwnership(ctx, params) {
|
|
|
488794
488843
|
log170.warn("Failed to delete duplicate channel default clone", { error: error2, tarskThreadId });
|
|
488795
488844
|
}
|
|
488796
488845
|
const winnerThreadId = claim.existing.defaultTarskThreadId;
|
|
488797
|
-
const conversationId =
|
|
488846
|
+
const conversationId = randomUUID29();
|
|
488798
488847
|
await upsertSlackThreadMap({
|
|
488799
488848
|
slackTeamId: teamId,
|
|
488800
488849
|
slackChannelId: channelId,
|
|
@@ -489041,7 +489090,7 @@ async function resolveSlackConversationId(ctx, params) {
|
|
|
489041
489090
|
return thread.currentConversationId;
|
|
489042
489091
|
}
|
|
489043
489092
|
}
|
|
489044
|
-
const conversationId =
|
|
489093
|
+
const conversationId = randomUUID29();
|
|
489045
489094
|
await ctx.deps.threadManager.updateThread(tarskThreadId, {
|
|
489046
489095
|
currentConversationId: conversationId
|
|
489047
489096
|
});
|
|
@@ -489065,7 +489114,7 @@ var init_slack_dispatch = __esm({
|
|
|
489065
489114
|
});
|
|
489066
489115
|
|
|
489067
489116
|
// src/features/slack/slack.branch.ts
|
|
489068
|
-
import { randomUUID as
|
|
489117
|
+
import { randomUUID as randomUUID30 } from "crypto";
|
|
489069
489118
|
async function handleBranchCommand(ctx, params) {
|
|
489070
489119
|
const { teamId, channelId, userId, messageTs, prompt, attachments, projectId } = params;
|
|
489071
489120
|
const project = await ctx.deps.projectManager.getProject(projectId);
|
|
@@ -489152,7 +489201,7 @@ async function remapSlackThreadToBranch(ctx, params) {
|
|
|
489152
489201
|
threadTitle,
|
|
489153
489202
|
slackMode: "branch",
|
|
489154
489203
|
isNewConversation: true,
|
|
489155
|
-
conversationId:
|
|
489204
|
+
conversationId: randomUUID30(),
|
|
489156
489205
|
clearPendingPropose: true
|
|
489157
489206
|
});
|
|
489158
489207
|
}
|
|
@@ -490055,7 +490104,7 @@ var init_slack_attachments = __esm({
|
|
|
490055
490104
|
});
|
|
490056
490105
|
|
|
490057
490106
|
// src/features/slack/slack.mentions.ts
|
|
490058
|
-
import { randomUUID as
|
|
490107
|
+
import { randomUUID as randomUUID31 } from "crypto";
|
|
490059
490108
|
function messageMentionsBot(event, botUserId) {
|
|
490060
490109
|
const text = event.text;
|
|
490061
490110
|
if (!botUserId || !text) {
|
|
@@ -490113,7 +490162,7 @@ async function handleMentionControlCommand(ctx, mention) {
|
|
|
490113
490162
|
return true;
|
|
490114
490163
|
}
|
|
490115
490164
|
async function dispatchMentionToExistingDefault(ctx, mention, binding, defaultTarget, attachments) {
|
|
490116
|
-
const conversationId =
|
|
490165
|
+
const conversationId = randomUUID31();
|
|
490117
490166
|
await upsertSlackThreadMap({
|
|
490118
490167
|
slackTeamId: mention.teamId,
|
|
490119
490168
|
slackChannelId: mention.channelId,
|
|
@@ -490152,7 +490201,7 @@ async function dispatchMentionToExistingDefault(ctx, mention, binding, defaultTa
|
|
|
490152
490201
|
});
|
|
490153
490202
|
}
|
|
490154
490203
|
async function dispatchFirstMentionPrompt(ctx, mention, binding, attachments) {
|
|
490155
|
-
const conversationId =
|
|
490204
|
+
const conversationId = randomUUID31();
|
|
490156
490205
|
const channelLabel = binding.slackChannelName ?? await resolveSlackChannelName(ctx.getWeb(), mention.channelId);
|
|
490157
490206
|
await dispatchChannelPrompt(ctx, {
|
|
490158
490207
|
teamId: mention.teamId,
|
|
@@ -490888,9 +490937,9 @@ var init_slack_routes = __esm({
|
|
|
490888
490937
|
// src/features/public-tunnel/cloudflared.ts
|
|
490889
490938
|
import { createHash as createHash16 } from "node:crypto";
|
|
490890
490939
|
import { spawn as spawn9 } from "node:child_process";
|
|
490891
|
-
import { chmodSync, existsSync as
|
|
490940
|
+
import { chmodSync, existsSync as existsSync36, mkdirSync as mkdirSync7, renameSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "node:fs";
|
|
490892
490941
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
490893
|
-
import { dirname as dirname26, join as
|
|
490942
|
+
import { dirname as dirname26, join as join73 } from "node:path";
|
|
490894
490943
|
function executableName() {
|
|
490895
490944
|
return process.platform === "win32" ? "cloudflared.exe" : "cloudflared";
|
|
490896
490945
|
}
|
|
@@ -490898,7 +490947,7 @@ function releaseKey() {
|
|
|
490898
490947
|
return `${process.platform}-${process.arch}`;
|
|
490899
490948
|
}
|
|
490900
490949
|
function managedPath() {
|
|
490901
|
-
return
|
|
490950
|
+
return join73(
|
|
490902
490951
|
getAppSupportDir(),
|
|
490903
490952
|
"tools",
|
|
490904
490953
|
"cloudflared",
|
|
@@ -490908,7 +490957,7 @@ function managedPath() {
|
|
|
490908
490957
|
);
|
|
490909
490958
|
}
|
|
490910
490959
|
function isExecutable(path27) {
|
|
490911
|
-
if (!
|
|
490960
|
+
if (!existsSync36(path27)) {
|
|
490912
490961
|
return false;
|
|
490913
490962
|
}
|
|
490914
490963
|
return true;
|
|
@@ -490925,7 +490974,7 @@ function resolveCloudflaredPath() {
|
|
|
490925
490974
|
const pathValue = process.env.PATH ?? "";
|
|
490926
490975
|
const delimiter2 = process.platform === "win32" ? ";" : ":";
|
|
490927
490976
|
for (const directory of pathValue.split(delimiter2)) {
|
|
490928
|
-
const candidate =
|
|
490977
|
+
const candidate = join73(directory.trim().replace(/^"|"$/g, ""), executableName());
|
|
490929
490978
|
if (candidate && isExecutable(candidate)) {
|
|
490930
490979
|
return candidate;
|
|
490931
490980
|
}
|
|
@@ -490956,15 +491005,15 @@ async function ensureCloudflared() {
|
|
|
490956
491005
|
if (digest !== asset.sha256) {
|
|
490957
491006
|
throw new Error("Downloaded cloudflared checksum did not match");
|
|
490958
491007
|
}
|
|
490959
|
-
const staging =
|
|
491008
|
+
const staging = join73(tmpdir10(), `tarsk-cloudflared-${process.pid}`);
|
|
490960
491009
|
mkdirSync7(staging, { recursive: true });
|
|
490961
491010
|
try {
|
|
490962
|
-
const archivePath =
|
|
491011
|
+
const archivePath = join73(
|
|
490963
491012
|
staging,
|
|
490964
491013
|
asset.archive === "tgz" ? "cloudflared.tgz" : executableName()
|
|
490965
491014
|
);
|
|
490966
491015
|
writeFileSync5(archivePath, bytes);
|
|
490967
|
-
const extracted =
|
|
491016
|
+
const extracted = join73(staging, executableName());
|
|
490968
491017
|
if (asset.archive === "tgz") {
|
|
490969
491018
|
await runCommand3("tar", ["-xzf", archivePath, "-C", staging]);
|
|
490970
491019
|
}
|
|
@@ -491514,7 +491563,7 @@ var init_remote_model_credentials = __esm({
|
|
|
491514
491563
|
// src/features/auth/tunnel-access.ts
|
|
491515
491564
|
import { createHmac, randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
491516
491565
|
import { mkdirSync as mkdirSync8, readFileSync as readFileSync19, writeFileSync as writeFileSync6 } from "node:fs";
|
|
491517
|
-
import { join as
|
|
491566
|
+
import { join as join74 } from "node:path";
|
|
491518
491567
|
function isTunnelAccessRequest(hostHeader, forwardedHost) {
|
|
491519
491568
|
const forwarded = forwardedHost?.split(",")[0]?.trim() ?? "";
|
|
491520
491569
|
if (forwarded) {
|
|
@@ -491527,7 +491576,7 @@ function isTunnelAccessRequest(hostHeader, forwardedHost) {
|
|
|
491527
491576
|
return isPublicTunnelHost(host);
|
|
491528
491577
|
}
|
|
491529
491578
|
function secretPath() {
|
|
491530
|
-
return
|
|
491579
|
+
return join74(getAppSupportDir(), "tunnel-access-secret");
|
|
491531
491580
|
}
|
|
491532
491581
|
function readSecret() {
|
|
491533
491582
|
const path27 = secretPath();
|
|
@@ -492409,7 +492458,7 @@ var init_image_clipboard_route = __esm({
|
|
|
492409
492458
|
});
|
|
492410
492459
|
|
|
492411
492460
|
// src/features/image/image-save.route.ts
|
|
492412
|
-
import { join as
|
|
492461
|
+
import { join as join75 } from "path";
|
|
492413
492462
|
async function saveImage(c) {
|
|
492414
492463
|
try {
|
|
492415
492464
|
const Utils3 = await loadElectrobunUtils();
|
|
@@ -492421,7 +492470,7 @@ async function saveImage(c) {
|
|
|
492421
492470
|
return c.json({ error: resolved.error }, resolved.status);
|
|
492422
492471
|
}
|
|
492423
492472
|
const name = resolved.body.filename ?? `generated-image-${Date.now()}.png`;
|
|
492424
|
-
const savePath =
|
|
492473
|
+
const savePath = join75(Utils3.paths.downloads, name);
|
|
492425
492474
|
await Bun.write(savePath, resolved.data);
|
|
492426
492475
|
return c.json({ success: true, path: savePath });
|
|
492427
492476
|
} catch (error2) {
|
|
@@ -492656,10 +492705,10 @@ var init_voice_transcript_route = __esm({
|
|
|
492656
492705
|
});
|
|
492657
492706
|
|
|
492658
492707
|
// src/features/voice-model/voice-engine/voice-model-archive.ts
|
|
492659
|
-
import { createWriteStream as createWriteStream4, existsSync as
|
|
492660
|
-
import { dirname as dirname27, join as
|
|
492708
|
+
import { createWriteStream as createWriteStream4, existsSync as existsSync37, mkdirSync as mkdirSync9, renameSync as renameSync2, statSync as statSync14, unlinkSync as unlinkSync4 } from "fs";
|
|
492709
|
+
import { dirname as dirname27, join as join76 } from "path";
|
|
492661
492710
|
function getVoiceModelArchivePath() {
|
|
492662
|
-
return
|
|
492711
|
+
return join76(getAppSupportDir(), MODEL_CACHE_DIRNAME, MODEL_ARCHIVE_FILENAME);
|
|
492663
492712
|
}
|
|
492664
492713
|
function getVoiceModelArchiveSize() {
|
|
492665
492714
|
try {
|
|
@@ -492722,7 +492771,7 @@ async function writeStream(body, destination, onBytes) {
|
|
|
492722
492771
|
}
|
|
492723
492772
|
function removeIfPresent(path27) {
|
|
492724
492773
|
try {
|
|
492725
|
-
if (
|
|
492774
|
+
if (existsSync37(path27)) {
|
|
492726
492775
|
unlinkSync4(path27);
|
|
492727
492776
|
}
|
|
492728
492777
|
} catch (error2) {
|
|
@@ -492745,9 +492794,9 @@ var init_voice_model_archive = __esm({
|
|
|
492745
492794
|
|
|
492746
492795
|
// src/features/voice-model/voice-engine/vosk-worker-source.ts
|
|
492747
492796
|
import { createHash as createHash17 } from "crypto";
|
|
492748
|
-
import { existsSync as
|
|
492797
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync10, readFileSync as readFileSync20, writeFileSync as writeFileSync8 } from "fs";
|
|
492749
492798
|
import { gunzipSync } from "zlib";
|
|
492750
|
-
import { dirname as dirname28, join as
|
|
492799
|
+
import { dirname as dirname28, join as join77 } from "path";
|
|
492751
492800
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
492752
492801
|
function nodeWorkerBridge() {
|
|
492753
492802
|
return `if (typeof globalThis.addEventListener !== "function" && globalThis.process) {
|
|
@@ -492767,14 +492816,14 @@ function resolveVoskWorkerArchivePath() {
|
|
|
492767
492816
|
const assetsDir = getAssetsDir();
|
|
492768
492817
|
const candidates = [
|
|
492769
492818
|
process.env[VOSK_WORKER_ARCHIVE_ENV] ?? null,
|
|
492770
|
-
|
|
492771
|
-
assetsDir ?
|
|
492772
|
-
|
|
492773
|
-
|
|
492774
|
-
|
|
492819
|
+
join77(moduleDir3, VOSK_WORKER_ARCHIVE_FILENAME),
|
|
492820
|
+
assetsDir ? join77(assetsDir, VOSK_WORKER_ARCHIVE_FILENAME) : null,
|
|
492821
|
+
join77(moduleDir3, "..", "..", "..", "assets", VOSK_WORKER_ARCHIVE_FILENAME),
|
|
492822
|
+
join77(process.cwd(), "dist", VOSK_WORKER_ARCHIVE_FILENAME),
|
|
492823
|
+
join77(process.cwd(), "assets", VOSK_WORKER_ARCHIVE_FILENAME)
|
|
492775
492824
|
];
|
|
492776
492825
|
for (const candidate of candidates) {
|
|
492777
|
-
if (candidate &&
|
|
492826
|
+
if (candidate && existsSync38(candidate)) {
|
|
492778
492827
|
return candidate;
|
|
492779
492828
|
}
|
|
492780
492829
|
}
|
|
@@ -492802,8 +492851,8 @@ function materializeVoskWorkerScript(cacheDir) {
|
|
|
492802
492851
|
}
|
|
492803
492852
|
const source2 = readVoskWorkerSource(archivePath);
|
|
492804
492853
|
const digest = createHash17("sha256").update(source2).digest("hex").slice(0, 16);
|
|
492805
|
-
const scriptPath =
|
|
492806
|
-
if (
|
|
492854
|
+
const scriptPath = join77(cacheDir, MATERIALIZED_DIRNAME, `vosk-worker-${digest}.cjs`);
|
|
492855
|
+
if (existsSync38(scriptPath)) {
|
|
492807
492856
|
return scriptPath;
|
|
492808
492857
|
}
|
|
492809
492858
|
mkdirSync10(dirname28(scriptPath), { recursive: true });
|
|
@@ -493806,11 +493855,11 @@ var init_cli_process_routes = __esm({
|
|
|
493806
493855
|
});
|
|
493807
493856
|
|
|
493808
493857
|
// src/features/control-channel/control-channel-hub.ts
|
|
493809
|
-
import { randomUUID as
|
|
493858
|
+
import { randomUUID as randomUUID32 } from "node:crypto";
|
|
493810
493859
|
function createControlChannelHub() {
|
|
493811
493860
|
const clients = /* @__PURE__ */ new Set();
|
|
493812
493861
|
const seqByTopic = /* @__PURE__ */ new Map();
|
|
493813
|
-
const epoch =
|
|
493862
|
+
const epoch = randomUUID32();
|
|
493814
493863
|
function getSeq(topic) {
|
|
493815
493864
|
return seqByTopic.get(topic) ?? 0;
|
|
493816
493865
|
}
|
|
@@ -493888,7 +493937,7 @@ function startControlChannelHeartbeat(hub, intervalMs = CONTROL_CHANNEL_HEARTBEA
|
|
|
493888
493937
|
}, intervalMs);
|
|
493889
493938
|
}
|
|
493890
493939
|
function createControlChannelClientId() {
|
|
493891
|
-
return
|
|
493940
|
+
return randomUUID32();
|
|
493892
493941
|
}
|
|
493893
493942
|
var init_control_channel_hub = __esm({
|
|
493894
493943
|
"src/features/control-channel/control-channel-hub.ts"() {
|
|
@@ -494167,7 +494216,7 @@ var init_voice_dictation_message = __esm({
|
|
|
494167
494216
|
});
|
|
494168
494217
|
|
|
494169
494218
|
// src/features/voice-model/voice-dictation.route.ts
|
|
494170
|
-
import { randomUUID as
|
|
494219
|
+
import { randomUUID as randomUUID33 } from "node:crypto";
|
|
494171
494220
|
function registerVoiceDictationWebSocketRoute(app, upgradeWebSocket2) {
|
|
494172
494221
|
app.get(
|
|
494173
494222
|
VOICE_DICTATION_WS_PATH,
|
|
@@ -494215,7 +494264,7 @@ function registerVoiceDictationWebSocketRoute(app, upgradeWebSocket2) {
|
|
|
494215
494264
|
engine2.abortSession(recognizerId);
|
|
494216
494265
|
recognizerId = null;
|
|
494217
494266
|
}
|
|
494218
|
-
const pendingRecognizerId =
|
|
494267
|
+
const pendingRecognizerId = randomUUID33();
|
|
494219
494268
|
try {
|
|
494220
494269
|
await prepareModel(ws2);
|
|
494221
494270
|
await engine2.startSession(pendingRecognizerId, {
|