mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
8017c144fe
* feat(workspace): search hosts by tag (#3001)
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(cli): bind Skills+CLI chat session via host env
Hide --chat-session from agents so they cannot spoof another chat tenant.
The host injects NETCATTY_CLI_CHAT_SESSION_ID, and Copilot/CodeBuddy
approval gates reject leftover flags and env-prefix overrides.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(ai): isolate Skills+CLI chat env across concurrent SDK turns
Cursor and OpenCode mutate process.env around spawn. Serialize those
writes so overlapping chats cannot inherit or restore the wrong
NETCATTY_CLI_CHAT_SESSION_ID.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Revert "feat(workspace): search hosts by tag (#3001)"
This reverts commit 4b651a3841.
* fix(ai): preserve chat isolation when cancelling Cursor startup
* fix(ai): isolate Cursor turns in cancellable workers
* fix(ai): contain native Cursor cleanup in a utility process
* fix(ai): report Cursor utility process fatal errors
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
85 lines
2.6 KiB
JavaScript
85 lines
2.6 KiB
JavaScript
"use strict";
|
|
|
|
const os = require("node:os");
|
|
const path = require("node:path");
|
|
const CLI_STATE_DIR_NAME = "netcatty-tool-cli";
|
|
const TOOL_CLI_DISCOVERY_ENV_VAR = "NETCATTY_TOOL_CLI_DISCOVERY_FILE";
|
|
const TOOL_CLI_CHAT_SESSION_ENV_VAR = "NETCATTY_CLI_CHAT_SESSION_ID";
|
|
const FALLBACK_APP_DATA_DIR_NAME = "netcatty";
|
|
|
|
function toUnpackedAsarPath(filePath) {
|
|
return filePath.replace(/app\.asar([\\/])/, "app.asar.unpacked$1");
|
|
}
|
|
|
|
function getDefaultAppDataDirName() {
|
|
const packageJsonPaths = [
|
|
process.resourcesPath ? path.join(process.resourcesPath, "app.asar", "package.json") : null,
|
|
path.resolve(__dirname, "../../package.json"),
|
|
path.join(process.cwd(), "package.json"),
|
|
].filter(Boolean);
|
|
|
|
for (const packageJsonPath of packageJsonPaths) {
|
|
try {
|
|
const packageJson = require(packageJsonPath);
|
|
if (typeof packageJson?.name === "string" && packageJson.name) {
|
|
return packageJson.name;
|
|
}
|
|
} catch {
|
|
// Try the next location.
|
|
}
|
|
}
|
|
|
|
return FALLBACK_APP_DATA_DIR_NAME;
|
|
}
|
|
|
|
function getDefaultUserDataDir() {
|
|
const appDataDirName = getDefaultAppDataDirName();
|
|
if (process.platform === "darwin") {
|
|
return path.join(os.homedir(), "Library", "Application Support", appDataDirName);
|
|
}
|
|
if (process.platform === "win32") {
|
|
const appData = process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming");
|
|
return path.join(appData, appDataDirName);
|
|
}
|
|
const xdgConfigHome = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
return path.join(xdgConfigHome, appDataDirName);
|
|
}
|
|
|
|
function getConfiguredDiscoveryFilePath() {
|
|
return process.env[TOOL_CLI_DISCOVERY_ENV_VAR] || null;
|
|
}
|
|
|
|
function getToolCliStateDir(options = {}) {
|
|
const discoveryFilePath = getConfiguredDiscoveryFilePath();
|
|
if (discoveryFilePath) {
|
|
return path.dirname(discoveryFilePath);
|
|
}
|
|
const userDataDir = typeof options.userDataDir === "string" && options.userDataDir
|
|
? options.userDataDir
|
|
: getDefaultUserDataDir();
|
|
return path.join(userDataDir, CLI_STATE_DIR_NAME);
|
|
}
|
|
|
|
function getCliDiscoveryFilePath(options = {}) {
|
|
const discoveryFilePath = getConfiguredDiscoveryFilePath();
|
|
if (discoveryFilePath) {
|
|
return discoveryFilePath;
|
|
}
|
|
return path.join(getToolCliStateDir(options), "discovery.json");
|
|
}
|
|
|
|
function getCliLauncherPath() {
|
|
const fileName = process.platform === "win32"
|
|
? "netcatty-tool-cli.cmd"
|
|
: "netcatty-tool-cli";
|
|
return toUnpackedAsarPath(path.join(__dirname, fileName));
|
|
}
|
|
|
|
module.exports = {
|
|
getToolCliStateDir,
|
|
getCliDiscoveryFilePath,
|
|
getCliLauncherPath,
|
|
TOOL_CLI_DISCOVERY_ENV_VAR,
|
|
TOOL_CLI_CHAT_SESSION_ENV_VAR,
|
|
};
|