@annals/agent-mesh 0.18.1 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
2
|
|
|
9
3
|
// src/commands/list.ts
|
|
10
4
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -957,7 +951,6 @@ function registerListCommand(program) {
|
|
|
957
951
|
}
|
|
958
952
|
|
|
959
953
|
export {
|
|
960
|
-
__require,
|
|
961
954
|
DEFAULT_RUNTIME_CONFIG,
|
|
962
955
|
loadConfig,
|
|
963
956
|
updateConfig,
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
GREEN,
|
|
7
7
|
RESET,
|
|
8
8
|
YELLOW,
|
|
9
|
-
__require,
|
|
10
9
|
addAgent,
|
|
11
10
|
findAgentByAgentId,
|
|
12
11
|
getAgent,
|
|
@@ -31,7 +30,7 @@ import {
|
|
|
31
30
|
updateConfig,
|
|
32
31
|
updateRuntimeConfig,
|
|
33
32
|
writePid
|
|
34
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-KEUGYA3L.js";
|
|
35
34
|
|
|
36
35
|
// src/index.ts
|
|
37
36
|
import { createRequire as createRequire2 } from "module";
|
|
@@ -1141,6 +1140,10 @@ function createLocalRuntimeQueue(config) {
|
|
|
1141
1140
|
}
|
|
1142
1141
|
|
|
1143
1142
|
// src/bridge/manager.ts
|
|
1143
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1144
|
+
import { execSync } from "child_process";
|
|
1145
|
+
import { join as join3 } from "path";
|
|
1146
|
+
import { homedir as homedir2 } from "os";
|
|
1144
1147
|
var DUPLICATE_REQUEST_TTL_MS = 10 * 6e4;
|
|
1145
1148
|
var SESSION_SWEEP_INTERVAL_MS = 6e4;
|
|
1146
1149
|
var DEFAULT_SESSION_IDLE_TTL_MS = 10 * 6e4;
|
|
@@ -1661,16 +1664,13 @@ var BridgeManager = class {
|
|
|
1661
1664
|
this.pendingUploads.delete(offer.transfer_id);
|
|
1662
1665
|
const workspaceDir = this.resolveUploadWorkspace(_sessionId);
|
|
1663
1666
|
try {
|
|
1664
|
-
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
mkdirSync7(workspaceDir, { recursive: true });
|
|
1668
|
-
const zipPath = join13(workspaceDir, ".upload.zip");
|
|
1669
|
-
writeFileSync4(zipPath, zipBuffer);
|
|
1667
|
+
mkdirSync3(workspaceDir, { recursive: true });
|
|
1668
|
+
const zipPath = join3(workspaceDir, ".upload.zip");
|
|
1669
|
+
writeFileSync2(zipPath, zipBuffer);
|
|
1670
1670
|
try {
|
|
1671
|
-
|
|
1671
|
+
execSync(`unzip -o -q "${zipPath}" -d "${workspaceDir}"`);
|
|
1672
1672
|
try {
|
|
1673
|
-
|
|
1673
|
+
execSync(`rm "${zipPath}"`);
|
|
1674
1674
|
} catch {
|
|
1675
1675
|
}
|
|
1676
1676
|
log.info(`[WebRTC] Upload: ${offer.file_count} file(s) extracted to ${workspaceDir}`);
|
|
@@ -1687,10 +1687,8 @@ var BridgeManager = class {
|
|
|
1687
1687
|
log.info(`[WebRTC] Upload registered: transfer=${offer.transfer_id.slice(0, 8)}... (${offer.file_count} files, ${(offer.zip_size / 1024).toFixed(1)} KB)`);
|
|
1688
1688
|
}
|
|
1689
1689
|
resolveUploadWorkspace(sessionId) {
|
|
1690
|
-
const { join: join13 } = __require("path");
|
|
1691
|
-
const { homedir: homedir6 } = __require("os");
|
|
1692
1690
|
const safeSessionId = sessionId.replace(/[^a-zA-Z0-9_:-]/g, "_").slice(0, 64);
|
|
1693
|
-
return
|
|
1691
|
+
return join3(homedir2(), ".agent-mesh", "uploads", safeSessionId);
|
|
1694
1692
|
}
|
|
1695
1693
|
cleanupPendingUploads() {
|
|
1696
1694
|
for (const [, entry] of this.pendingUploads) {
|
|
@@ -1719,8 +1717,8 @@ var AgentAdapter = class {
|
|
|
1719
1717
|
import { spawn } from "child_process";
|
|
1720
1718
|
|
|
1721
1719
|
// src/utils/sandbox.ts
|
|
1722
|
-
import { execSync } from "child_process";
|
|
1723
|
-
import { join as
|
|
1720
|
+
import { execSync as execSync2 } from "child_process";
|
|
1721
|
+
import { join as join4 } from "path";
|
|
1724
1722
|
var SRT_PACKAGE = "@anthropic-ai/sandbox-runtime";
|
|
1725
1723
|
var SENSITIVE_PATHS = [
|
|
1726
1724
|
// SSH & crypto keys
|
|
@@ -1778,8 +1776,8 @@ var sandboxManager = null;
|
|
|
1778
1776
|
var sandboxInitialized = false;
|
|
1779
1777
|
async function importSandboxManager() {
|
|
1780
1778
|
try {
|
|
1781
|
-
const globalRoot =
|
|
1782
|
-
const srtPath =
|
|
1779
|
+
const globalRoot = execSync2("npm root -g", { encoding: "utf-8" }).trim();
|
|
1780
|
+
const srtPath = join4(globalRoot, "@anthropic-ai/sandbox-runtime/dist/index.js");
|
|
1783
1781
|
const mod = await import(srtPath);
|
|
1784
1782
|
return mod.SandboxManager;
|
|
1785
1783
|
} catch {
|
|
@@ -1867,7 +1865,7 @@ function buildCommandString(command, args) {
|
|
|
1867
1865
|
function installSandboxRuntime() {
|
|
1868
1866
|
log.info(`Installing ${SRT_PACKAGE}...`);
|
|
1869
1867
|
try {
|
|
1870
|
-
|
|
1868
|
+
execSync2(`npm install -g ${SRT_PACKAGE}`, { stdio: "inherit" });
|
|
1871
1869
|
log.success(`${SRT_PACKAGE} installed successfully`);
|
|
1872
1870
|
return true;
|
|
1873
1871
|
} catch {
|
|
@@ -1947,18 +1945,18 @@ async function spawnAgent(command, args, options) {
|
|
|
1947
1945
|
|
|
1948
1946
|
// src/adapters/claude.ts
|
|
1949
1947
|
import { createInterface } from "readline";
|
|
1950
|
-
import { homedir as
|
|
1948
|
+
import { homedir as homedir4 } from "os";
|
|
1951
1949
|
|
|
1952
1950
|
// src/utils/which.ts
|
|
1953
1951
|
import { execFile } from "child_process";
|
|
1954
1952
|
import { access, constants } from "fs/promises";
|
|
1955
|
-
import { homedir as
|
|
1953
|
+
import { homedir as homedir3 } from "os";
|
|
1956
1954
|
var ALLOWED_COMMANDS = /^[a-zA-Z0-9._-]+$/;
|
|
1957
1955
|
var FALLBACK_PATHS = {
|
|
1958
1956
|
claude: [
|
|
1959
1957
|
"/opt/homebrew/bin/claude",
|
|
1960
1958
|
"/usr/local/bin/claude",
|
|
1961
|
-
`${
|
|
1959
|
+
`${homedir3()}/.local/bin/claude`
|
|
1962
1960
|
]
|
|
1963
1961
|
};
|
|
1964
1962
|
async function resolveFallbackPath(command) {
|
|
@@ -1988,8 +1986,8 @@ function which(command) {
|
|
|
1988
1986
|
}
|
|
1989
1987
|
|
|
1990
1988
|
// src/utils/client-workspace.ts
|
|
1991
|
-
import { mkdirSync as
|
|
1992
|
-
import { join as
|
|
1989
|
+
import { mkdirSync as mkdirSync4, readdirSync, symlinkSync, existsSync as existsSync3, lstatSync } from "fs";
|
|
1990
|
+
import { join as join5, relative } from "path";
|
|
1993
1991
|
var SYMLINK_ALLOW = /* @__PURE__ */ new Set([
|
|
1994
1992
|
"CLAUDE.md",
|
|
1995
1993
|
".claude",
|
|
@@ -2018,19 +2016,19 @@ function shouldInclude(name) {
|
|
|
2018
2016
|
return false;
|
|
2019
2017
|
}
|
|
2020
2018
|
function createClientWorkspace(projectPath, clientId) {
|
|
2021
|
-
const wsDir =
|
|
2019
|
+
const wsDir = join5(projectPath, ".bridge-clients", clientId);
|
|
2022
2020
|
const isNew = !existsSync3(wsDir);
|
|
2023
|
-
|
|
2021
|
+
mkdirSync4(wsDir, { recursive: true });
|
|
2024
2022
|
const entries = readdirSync(projectPath, { withFileTypes: true });
|
|
2025
2023
|
for (const entry of entries) {
|
|
2026
2024
|
if (!shouldInclude(entry.name)) continue;
|
|
2027
|
-
const link =
|
|
2025
|
+
const link = join5(wsDir, entry.name);
|
|
2028
2026
|
try {
|
|
2029
2027
|
lstatSync(link);
|
|
2030
2028
|
continue;
|
|
2031
2029
|
} catch {
|
|
2032
2030
|
}
|
|
2033
|
-
const target =
|
|
2031
|
+
const target = join5(projectPath, entry.name);
|
|
2034
2032
|
const relTarget = relative(wsDir, target);
|
|
2035
2033
|
try {
|
|
2036
2034
|
symlinkSync(relTarget, link);
|
|
@@ -2046,11 +2044,11 @@ function createClientWorkspace(projectPath, clientId) {
|
|
|
2046
2044
|
|
|
2047
2045
|
// src/adapters/claude.ts
|
|
2048
2046
|
import { writeFile, mkdir, stat as stat2 } from "fs/promises";
|
|
2049
|
-
import { join as
|
|
2047
|
+
import { join as join7, relative as relative3, basename } from "path";
|
|
2050
2048
|
|
|
2051
2049
|
// src/utils/auto-upload.ts
|
|
2052
2050
|
import { readdir, readFile, stat } from "fs/promises";
|
|
2053
|
-
import { join as
|
|
2051
|
+
import { join as join6, relative as relative2 } from "path";
|
|
2054
2052
|
var MAX_AUTO_UPLOAD_FILE_SIZE = 10 * 1024 * 1024;
|
|
2055
2053
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
2056
2054
|
".git",
|
|
@@ -2084,7 +2082,7 @@ async function collectRealFiles(dir, maxFiles = Infinity) {
|
|
|
2084
2082
|
}
|
|
2085
2083
|
for (const entry of entries) {
|
|
2086
2084
|
if (files.length >= maxFiles) return;
|
|
2087
|
-
const fullPath =
|
|
2085
|
+
const fullPath = join6(d, entry.name);
|
|
2088
2086
|
if (entry.isDirectory()) {
|
|
2089
2087
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
2090
2088
|
await walk(fullPath);
|
|
@@ -2256,7 +2254,7 @@ function extractZipBuffer(buf) {
|
|
|
2256
2254
|
// src/adapters/claude.ts
|
|
2257
2255
|
var DEFAULT_IDLE_TIMEOUT = 30 * 60 * 1e3;
|
|
2258
2256
|
var MIN_IDLE_TIMEOUT = 60 * 1e3;
|
|
2259
|
-
var HOME_DIR =
|
|
2257
|
+
var HOME_DIR = homedir4();
|
|
2260
2258
|
var CLAUDE_RUNTIME_ALLOW_WRITE_PATHS = [
|
|
2261
2259
|
`${HOME_DIR}/.claude`,
|
|
2262
2260
|
`${HOME_DIR}/.claude.json`,
|
|
@@ -2330,7 +2328,7 @@ var ClaudeSession = class {
|
|
|
2330
2328
|
await mkdir(workspaceRoot, { recursive: true });
|
|
2331
2329
|
for (const att of attachments) {
|
|
2332
2330
|
const safeName = basename(att.name).replace(/[^a-zA-Z0-9._-]/g, "_") || "attachment";
|
|
2333
|
-
const destPath =
|
|
2331
|
+
const destPath = join7(workspaceRoot, safeName);
|
|
2334
2332
|
try {
|
|
2335
2333
|
const res = await fetch(att.url);
|
|
2336
2334
|
if (!res.ok) {
|
|
@@ -2776,7 +2774,7 @@ function registerConnectCommand(program2) {
|
|
|
2776
2774
|
log.error(`Failed to start. Check logs: ${getLogPath(slug)}`);
|
|
2777
2775
|
process.exit(1);
|
|
2778
2776
|
}
|
|
2779
|
-
const { ListTUI } = await import("./list-
|
|
2777
|
+
const { ListTUI } = await import("./list-ROLJARYB.js");
|
|
2780
2778
|
const tui = new ListTUI();
|
|
2781
2779
|
await tui.run();
|
|
2782
2780
|
return;
|
|
@@ -3337,14 +3335,14 @@ function registerOpenCommand(program2) {
|
|
|
3337
3335
|
}
|
|
3338
3336
|
|
|
3339
3337
|
// src/commands/install.ts
|
|
3340
|
-
import { writeFileSync as
|
|
3341
|
-
import { join as
|
|
3342
|
-
import { homedir as
|
|
3343
|
-
import { execSync as
|
|
3338
|
+
import { writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync5 } from "fs";
|
|
3339
|
+
import { join as join8 } from "path";
|
|
3340
|
+
import { homedir as homedir5 } from "os";
|
|
3341
|
+
import { execSync as execSync3 } from "child_process";
|
|
3344
3342
|
var LABEL = "com.agents-hot.agent-mesh";
|
|
3345
|
-
var PLIST_DIR =
|
|
3346
|
-
var PLIST_PATH =
|
|
3347
|
-
var LOG_PATH =
|
|
3343
|
+
var PLIST_DIR = join8(homedir5(), "Library", "LaunchAgents");
|
|
3344
|
+
var PLIST_PATH = join8(PLIST_DIR, `${LABEL}.plist`);
|
|
3345
|
+
var LOG_PATH = join8(homedir5(), ".agent-mesh", "logs", "launchd.log");
|
|
3348
3346
|
function detectPaths() {
|
|
3349
3347
|
return {
|
|
3350
3348
|
node: process.execPath,
|
|
@@ -3377,7 +3375,7 @@ function generatePlist(nodePath, scriptPath) {
|
|
|
3377
3375
|
<string>${escapeXml(LOG_PATH)}</string>
|
|
3378
3376
|
|
|
3379
3377
|
<key>WorkingDirectory</key>
|
|
3380
|
-
<string>${escapeXml(
|
|
3378
|
+
<string>${escapeXml(homedir5())}</string>
|
|
3381
3379
|
</dict>
|
|
3382
3380
|
</plist>
|
|
3383
3381
|
`;
|
|
@@ -3402,21 +3400,21 @@ function registerInstallCommand(program2) {
|
|
|
3402
3400
|
}
|
|
3403
3401
|
const { node, script } = detectPaths();
|
|
3404
3402
|
if (!existsSync5(PLIST_DIR)) {
|
|
3405
|
-
|
|
3403
|
+
mkdirSync5(PLIST_DIR, { recursive: true });
|
|
3406
3404
|
}
|
|
3407
3405
|
if (existsSync5(PLIST_PATH)) {
|
|
3408
3406
|
try {
|
|
3409
|
-
|
|
3407
|
+
execSync3(`launchctl bootout gui/$(id -u) "${PLIST_PATH}" 2>/dev/null`, { stdio: "ignore" });
|
|
3410
3408
|
} catch {
|
|
3411
3409
|
}
|
|
3412
3410
|
}
|
|
3413
3411
|
const plist = generatePlist(node, script);
|
|
3414
|
-
|
|
3412
|
+
writeFileSync3(PLIST_PATH, plist, { encoding: "utf-8" });
|
|
3415
3413
|
try {
|
|
3416
|
-
|
|
3414
|
+
execSync3(`launchctl bootstrap gui/$(id -u) "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
3417
3415
|
} catch {
|
|
3418
3416
|
try {
|
|
3419
|
-
|
|
3417
|
+
execSync3(`launchctl load "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
3420
3418
|
} catch (err) {
|
|
3421
3419
|
log.error(`Failed to load LaunchAgent: ${err}`);
|
|
3422
3420
|
log.info(`Plist written to ${PLIST_PATH} \u2014 you can load it manually.`);
|
|
@@ -3438,11 +3436,11 @@ function registerInstallCommand(program2) {
|
|
|
3438
3436
|
|
|
3439
3437
|
// src/commands/uninstall.ts
|
|
3440
3438
|
import { existsSync as existsSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
3441
|
-
import { join as
|
|
3442
|
-
import { homedir as
|
|
3443
|
-
import { execSync as
|
|
3439
|
+
import { join as join9 } from "path";
|
|
3440
|
+
import { homedir as homedir6 } from "os";
|
|
3441
|
+
import { execSync as execSync4 } from "child_process";
|
|
3444
3442
|
var LABEL2 = "com.agents-hot.agent-mesh";
|
|
3445
|
-
var PLIST_PATH2 =
|
|
3443
|
+
var PLIST_PATH2 = join9(homedir6(), "Library", "LaunchAgents", `${LABEL2}.plist`);
|
|
3446
3444
|
function registerUninstallCommand(program2) {
|
|
3447
3445
|
program2.command("uninstall").description("Remove macOS LaunchAgent (agents will no longer auto-start)").action(async () => {
|
|
3448
3446
|
if (process.platform !== "darwin") {
|
|
@@ -3456,10 +3454,10 @@ function registerUninstallCommand(program2) {
|
|
|
3456
3454
|
return;
|
|
3457
3455
|
}
|
|
3458
3456
|
try {
|
|
3459
|
-
|
|
3457
|
+
execSync4(`launchctl bootout gui/$(id -u) "${PLIST_PATH2}" 2>/dev/null`, { stdio: "ignore" });
|
|
3460
3458
|
} catch {
|
|
3461
3459
|
try {
|
|
3462
|
-
|
|
3460
|
+
execSync4(`launchctl unload "${PLIST_PATH2}" 2>/dev/null`, { stdio: "ignore" });
|
|
3463
3461
|
} catch {
|
|
3464
3462
|
}
|
|
3465
3463
|
}
|
|
@@ -3854,9 +3852,9 @@ function registerAgentsCommand(program2) {
|
|
|
3854
3852
|
|
|
3855
3853
|
// src/commands/chat.ts
|
|
3856
3854
|
import { createInterface as createInterface4 } from "readline";
|
|
3857
|
-
import { existsSync as existsSync7, readFileSync as readFileSync2, mkdirSync as
|
|
3858
|
-
import { basename as basename2, join as
|
|
3859
|
-
import { execSync as
|
|
3855
|
+
import { existsSync as existsSync7, readFileSync as readFileSync2, mkdirSync as mkdirSync6, copyFileSync as copyFileSync2 } from "fs";
|
|
3856
|
+
import { basename as basename2, join as join10 } from "path";
|
|
3857
|
+
import { execSync as execSync5 } from "child_process";
|
|
3860
3858
|
import { createHash as createHash2, randomUUID } from "crypto";
|
|
3861
3859
|
import { tmpdir } from "os";
|
|
3862
3860
|
|
|
@@ -3883,15 +3881,15 @@ function parseSseChunk(raw, carry) {
|
|
|
3883
3881
|
var DEFAULT_BASE_URL3 = "https://agents.hot";
|
|
3884
3882
|
function prepareUploadFile(filePath) {
|
|
3885
3883
|
const fileName = basename2(filePath);
|
|
3886
|
-
const tempDir =
|
|
3887
|
-
|
|
3888
|
-
const tempFile =
|
|
3884
|
+
const tempDir = join10(tmpdir(), `chat-upload-${Date.now()}`);
|
|
3885
|
+
mkdirSync6(tempDir, { recursive: true });
|
|
3886
|
+
const tempFile = join10(tempDir, fileName);
|
|
3889
3887
|
copyFileSync2(filePath, tempFile);
|
|
3890
|
-
const zipPath =
|
|
3891
|
-
|
|
3888
|
+
const zipPath = join10(tempDir, "upload.zip");
|
|
3889
|
+
execSync5(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
3892
3890
|
const zipBuffer = readFileSync2(zipPath);
|
|
3893
3891
|
try {
|
|
3894
|
-
|
|
3892
|
+
execSync5(`rm -rf "${tempDir}"`);
|
|
3895
3893
|
} catch {
|
|
3896
3894
|
}
|
|
3897
3895
|
const zipSha256 = createHash2("sha256").update(zipBuffer).digest("hex");
|
|
@@ -4267,11 +4265,11 @@ function registerChatCommand(program2) {
|
|
|
4267
4265
|
|
|
4268
4266
|
// src/commands/skills.ts
|
|
4269
4267
|
import { readFile as readFile3, writeFile as writeFile3, readdir as readdir2, mkdir as mkdir2, rm, symlink, unlink } from "fs/promises";
|
|
4270
|
-
import { join as
|
|
4268
|
+
import { join as join12, resolve, relative as relative4 } from "path";
|
|
4271
4269
|
|
|
4272
4270
|
// src/utils/skill-parser.ts
|
|
4273
4271
|
import { readFile as readFile2, writeFile as writeFile2, stat as stat3 } from "fs/promises";
|
|
4274
|
-
import { join as
|
|
4272
|
+
import { join as join11 } from "path";
|
|
4275
4273
|
function parseSkillMd(raw) {
|
|
4276
4274
|
const trimmed = raw.trimStart();
|
|
4277
4275
|
if (!trimmed.startsWith("---")) {
|
|
@@ -4353,7 +4351,7 @@ function parseSkillMd(raw) {
|
|
|
4353
4351
|
return { frontmatter, content };
|
|
4354
4352
|
}
|
|
4355
4353
|
async function loadSkillManifest(dir) {
|
|
4356
|
-
const skillMdPath =
|
|
4354
|
+
const skillMdPath = join11(dir, "SKILL.md");
|
|
4357
4355
|
try {
|
|
4358
4356
|
const raw = await readFile2(skillMdPath, "utf-8");
|
|
4359
4357
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4458,13 +4456,13 @@ function skillApiPath(authorLogin, slug) {
|
|
|
4458
4456
|
}
|
|
4459
4457
|
async function resolveSkillsRootAsync(pathArg) {
|
|
4460
4458
|
const projectRoot = pathArg ? resolve(pathArg) : process.cwd();
|
|
4461
|
-
const skillsDir =
|
|
4462
|
-
const claudeSkillsDir =
|
|
4459
|
+
const skillsDir = join12(projectRoot, ".agents", "skills");
|
|
4460
|
+
const claudeSkillsDir = join12(projectRoot, ".claude", "skills");
|
|
4463
4461
|
return { projectRoot, skillsDir, claudeSkillsDir };
|
|
4464
4462
|
}
|
|
4465
4463
|
async function ensureClaudeSymlink(claudeSkillsDir, slug) {
|
|
4466
4464
|
await mkdir2(claudeSkillsDir, { recursive: true });
|
|
4467
|
-
const linkPath =
|
|
4465
|
+
const linkPath = join12(claudeSkillsDir, slug);
|
|
4468
4466
|
try {
|
|
4469
4467
|
await unlink(linkPath);
|
|
4470
4468
|
} catch {
|
|
@@ -4484,7 +4482,7 @@ async function collectPackFiles(dir, manifest) {
|
|
|
4484
4482
|
}
|
|
4485
4483
|
const mainFile = manifest.main || "SKILL.md";
|
|
4486
4484
|
if (!results.includes(mainFile)) {
|
|
4487
|
-
const mainPath =
|
|
4485
|
+
const mainPath = join12(dir, mainFile);
|
|
4488
4486
|
if (await pathExists(mainPath)) {
|
|
4489
4487
|
results.unshift(mainFile);
|
|
4490
4488
|
}
|
|
@@ -4501,7 +4499,7 @@ async function walkDir(dir) {
|
|
|
4501
4499
|
}
|
|
4502
4500
|
for (const entry of entries) {
|
|
4503
4501
|
if (entry.isSymbolicLink()) continue;
|
|
4504
|
-
const fullPath =
|
|
4502
|
+
const fullPath = join12(dir, entry.name);
|
|
4505
4503
|
if (entry.isDirectory()) {
|
|
4506
4504
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
4507
4505
|
const sub = await walkDir(fullPath);
|
|
@@ -4519,7 +4517,7 @@ async function packSkill(dir, manifest) {
|
|
|
4519
4517
|
}
|
|
4520
4518
|
const entries = [];
|
|
4521
4519
|
for (const relPath of fileList) {
|
|
4522
|
-
const absPath =
|
|
4520
|
+
const absPath = join12(dir, relPath);
|
|
4523
4521
|
try {
|
|
4524
4522
|
const data = await readFile3(absPath);
|
|
4525
4523
|
entries.push({ path: relPath.replace(/\\/g, "/"), data });
|
|
@@ -4553,7 +4551,7 @@ function bumpVersion(current, bump) {
|
|
|
4553
4551
|
}
|
|
4554
4552
|
async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
4555
4553
|
const meta = await client.get(skillApiPath(authorLogin, slug));
|
|
4556
|
-
const targetDir =
|
|
4554
|
+
const targetDir = join12(skillsDir, slug);
|
|
4557
4555
|
await mkdir2(targetDir, { recursive: true });
|
|
4558
4556
|
if (meta.has_files) {
|
|
4559
4557
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/download`);
|
|
@@ -4561,8 +4559,8 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4561
4559
|
const buf = Buffer.from(arrayBuf);
|
|
4562
4560
|
const entries = extractZipBuffer(buf);
|
|
4563
4561
|
for (const entry of entries) {
|
|
4564
|
-
const filePath =
|
|
4565
|
-
const dir =
|
|
4562
|
+
const filePath = join12(targetDir, entry.path);
|
|
4563
|
+
const dir = join12(filePath, "..");
|
|
4566
4564
|
await mkdir2(dir, { recursive: true });
|
|
4567
4565
|
await writeFile3(filePath, entry.data);
|
|
4568
4566
|
}
|
|
@@ -4575,7 +4573,7 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4575
4573
|
} else {
|
|
4576
4574
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/raw`);
|
|
4577
4575
|
const content = await res.text();
|
|
4578
|
-
await writeFile3(
|
|
4576
|
+
await writeFile3(join12(targetDir, "SKILL.md"), content);
|
|
4579
4577
|
return {
|
|
4580
4578
|
slug,
|
|
4581
4579
|
name: meta.name,
|
|
@@ -4604,7 +4602,7 @@ function registerSkillsCommand(program2) {
|
|
|
4604
4602
|
try {
|
|
4605
4603
|
const dir = resolveSkillDir(pathArg);
|
|
4606
4604
|
await mkdir2(dir, { recursive: true });
|
|
4607
|
-
const skillMdPath =
|
|
4605
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4608
4606
|
if (await pathExists(skillMdPath)) {
|
|
4609
4607
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4610
4608
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4633,7 +4631,7 @@ function registerSkillsCommand(program2) {
|
|
|
4633
4631
|
const dir = resolveSkillDir(pathArg);
|
|
4634
4632
|
const manifest = await loadSkillManifest(dir);
|
|
4635
4633
|
const result = await packSkill(dir, manifest);
|
|
4636
|
-
const outPath =
|
|
4634
|
+
const outPath = join12(dir, result.filename);
|
|
4637
4635
|
await writeFile3(outPath, result.buffer);
|
|
4638
4636
|
slog.info(`Packed ${result.files.length} files \u2192 ${result.filename} (${result.size} bytes)`);
|
|
4639
4637
|
outputJson({
|
|
@@ -4679,7 +4677,7 @@ function registerSkillsCommand(program2) {
|
|
|
4679
4677
|
if (opts.name) manifest.name = opts.name;
|
|
4680
4678
|
if (opts.version) manifest.version = opts.version;
|
|
4681
4679
|
if (opts.private !== void 0) manifest.private = opts.private;
|
|
4682
|
-
content = await readFile3(
|
|
4680
|
+
content = await readFile3(join12(dir, manifest.main || "SKILL.md"), "utf-8");
|
|
4683
4681
|
packResult = await packSkill(dir, manifest);
|
|
4684
4682
|
slog.info(`Packed ${packResult.files.length} files (${packResult.size} bytes)`);
|
|
4685
4683
|
}
|
|
@@ -4816,7 +4814,7 @@ function registerSkillsCommand(program2) {
|
|
|
4816
4814
|
skills.command("version <bump> [path]").description("Bump skill version (patch | minor | major | x.y.z)").action(async (bump, pathArg) => {
|
|
4817
4815
|
try {
|
|
4818
4816
|
const dir = resolveSkillDir(pathArg);
|
|
4819
|
-
const skillMdPath =
|
|
4817
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4820
4818
|
if (!await pathExists(skillMdPath)) {
|
|
4821
4819
|
outputError("not_found", "No SKILL.md found. Run `agent-mesh skills init` first.");
|
|
4822
4820
|
}
|
|
@@ -4836,7 +4834,7 @@ function registerSkillsCommand(program2) {
|
|
|
4836
4834
|
try {
|
|
4837
4835
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4838
4836
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4839
|
-
const targetDir =
|
|
4837
|
+
const targetDir = join12(skillsDir, slug);
|
|
4840
4838
|
if (await pathExists(targetDir)) {
|
|
4841
4839
|
if (!opts.force) {
|
|
4842
4840
|
outputError("already_installed", `Skill "${slug}" is already installed at ${targetDir}. Use --force to overwrite.`);
|
|
@@ -4875,11 +4873,11 @@ function registerSkillsCommand(program2) {
|
|
|
4875
4873
|
const failed = [];
|
|
4876
4874
|
if (ref) {
|
|
4877
4875
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4878
|
-
const targetDir =
|
|
4876
|
+
const targetDir = join12(skillsDir, slug);
|
|
4879
4877
|
if (!await pathExists(targetDir)) {
|
|
4880
4878
|
outputError("not_installed", `Skill "${slug}" is not installed. Use "skills install ${ref}" first.`);
|
|
4881
4879
|
}
|
|
4882
|
-
const skillMdPath =
|
|
4880
|
+
const skillMdPath = join12(targetDir, "SKILL.md");
|
|
4883
4881
|
let localVersion = "0.0.0";
|
|
4884
4882
|
if (await pathExists(skillMdPath)) {
|
|
4885
4883
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
@@ -4906,7 +4904,7 @@ function registerSkillsCommand(program2) {
|
|
|
4906
4904
|
for (const entry of entries) {
|
|
4907
4905
|
if (!entry.isDirectory()) continue;
|
|
4908
4906
|
const slug = entry.name;
|
|
4909
|
-
const skillMdPath =
|
|
4907
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4910
4908
|
if (!await pathExists(skillMdPath)) {
|
|
4911
4909
|
skipped.push({ slug, reason: "no_skill_md" });
|
|
4912
4910
|
continue;
|
|
@@ -4926,7 +4924,7 @@ function registerSkillsCommand(program2) {
|
|
|
4926
4924
|
skipped.push({ slug, reason: "up_to_date" });
|
|
4927
4925
|
} else {
|
|
4928
4926
|
slog.info(`Updating ${slug}: v${localVersion} \u2192 v${remoteVersion}...`);
|
|
4929
|
-
await rm(
|
|
4927
|
+
await rm(join12(skillsDir, slug), { recursive: true, force: true });
|
|
4930
4928
|
await downloadAndInstallSkill(client, authorLogin, slug, skillsDir);
|
|
4931
4929
|
updated.push({ slug, name: remote.name, old_version: localVersion, new_version: remoteVersion });
|
|
4932
4930
|
}
|
|
@@ -4947,13 +4945,13 @@ function registerSkillsCommand(program2) {
|
|
|
4947
4945
|
skills.command("remove <slug> [path]").description("Remove a locally installed skill").action(async (slug, pathArg) => {
|
|
4948
4946
|
try {
|
|
4949
4947
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4950
|
-
const targetDir =
|
|
4948
|
+
const targetDir = join12(skillsDir, slug);
|
|
4951
4949
|
if (!await pathExists(targetDir)) {
|
|
4952
4950
|
outputError("not_installed", `Skill "${slug}" is not installed at ${targetDir}`);
|
|
4953
4951
|
}
|
|
4954
4952
|
await rm(targetDir, { recursive: true, force: true });
|
|
4955
4953
|
try {
|
|
4956
|
-
await unlink(
|
|
4954
|
+
await unlink(join12(claudeSkillsDir, slug));
|
|
4957
4955
|
} catch {
|
|
4958
4956
|
}
|
|
4959
4957
|
slog.success(`Removed skill: ${slug}`);
|
|
@@ -4978,7 +4976,7 @@ function registerSkillsCommand(program2) {
|
|
|
4978
4976
|
for (const entry of entries) {
|
|
4979
4977
|
if (!entry.isDirectory()) continue;
|
|
4980
4978
|
const slug = entry.name;
|
|
4981
|
-
const skillMdPath =
|
|
4979
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4982
4980
|
if (!await pathExists(skillMdPath)) continue;
|
|
4983
4981
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4984
4982
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -5090,10 +5088,10 @@ function registerDiscoverCommand(program2) {
|
|
|
5090
5088
|
}
|
|
5091
5089
|
|
|
5092
5090
|
// src/commands/call.ts
|
|
5093
|
-
import { readFileSync as readFileSync3, writeFileSync as
|
|
5094
|
-
import { execSync as
|
|
5091
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, mkdirSync as mkdirSync7, copyFileSync as copyFileSync3, existsSync as existsSync8 } from "fs";
|
|
5092
|
+
import { execSync as execSync6 } from "child_process";
|
|
5095
5093
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
|
|
5096
|
-
import { join as
|
|
5094
|
+
import { join as join13, basename as basename3 } from "path";
|
|
5097
5095
|
import { tmpdir as tmpdir2 } from "os";
|
|
5098
5096
|
var DEFAULT_BASE_URL4 = "https://agents.hot";
|
|
5099
5097
|
async function submitRating(baseUrl, token, agentId, callId, rating) {
|
|
@@ -5187,13 +5185,13 @@ async function webrtcDownload(agentId, offer, token, outputDir, json) {
|
|
|
5187
5185
|
receiver.waitForCompletion(3e4),
|
|
5188
5186
|
poll()
|
|
5189
5187
|
]);
|
|
5190
|
-
|
|
5191
|
-
const zipPath =
|
|
5192
|
-
|
|
5188
|
+
mkdirSync7(outputDir, { recursive: true });
|
|
5189
|
+
const zipPath = join13(outputDir, ".transfer.zip");
|
|
5190
|
+
writeFileSync4(zipPath, zipBuffer);
|
|
5193
5191
|
try {
|
|
5194
|
-
|
|
5192
|
+
execSync6(`unzip -o -q "${zipPath}" -d "${outputDir}"`);
|
|
5195
5193
|
try {
|
|
5196
|
-
|
|
5194
|
+
execSync6(`rm "${zipPath}"`);
|
|
5197
5195
|
} catch {
|
|
5198
5196
|
}
|
|
5199
5197
|
} catch {
|
|
@@ -5224,15 +5222,15 @@ async function webrtcDownload(agentId, offer, token, outputDir, json) {
|
|
|
5224
5222
|
}
|
|
5225
5223
|
function prepareFileForUpload(filePath) {
|
|
5226
5224
|
const fileName = basename3(filePath);
|
|
5227
|
-
const tempDir =
|
|
5228
|
-
|
|
5229
|
-
const tempFile =
|
|
5225
|
+
const tempDir = join13(tmpdir2(), `upload-${Date.now()}`);
|
|
5226
|
+
mkdirSync7(tempDir, { recursive: true });
|
|
5227
|
+
const tempFile = join13(tempDir, fileName);
|
|
5230
5228
|
copyFileSync3(filePath, tempFile);
|
|
5231
|
-
const zipPath =
|
|
5232
|
-
|
|
5229
|
+
const zipPath = join13(tempDir, "upload.zip");
|
|
5230
|
+
execSync6(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
5233
5231
|
const zipBuffer = readFileSync3(zipPath);
|
|
5234
5232
|
try {
|
|
5235
|
-
|
|
5233
|
+
execSync6(`rm -rf "${tempDir}"`);
|
|
5236
5234
|
} catch {
|
|
5237
5235
|
}
|
|
5238
5236
|
const zipSha256 = createHash3("sha256").update(zipBuffer).digest("hex");
|
|
@@ -5418,11 +5416,11 @@ async function asyncCall(opts) {
|
|
|
5418
5416
|
}
|
|
5419
5417
|
}
|
|
5420
5418
|
if (opts.outputFile && result) {
|
|
5421
|
-
|
|
5419
|
+
writeFileSync4(opts.outputFile, result);
|
|
5422
5420
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5423
5421
|
}
|
|
5424
5422
|
if (offer && opts.withFiles) {
|
|
5425
|
-
const outputDir = opts.outputFile ?
|
|
5423
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5426
5424
|
await webrtcDownload(opts.id, offer, opts.token, outputDir, opts.json);
|
|
5427
5425
|
}
|
|
5428
5426
|
if (!opts.json) {
|
|
@@ -5592,12 +5590,12 @@ Error: ${event.message}
|
|
|
5592
5590
|
}
|
|
5593
5591
|
}
|
|
5594
5592
|
if (opts.outputFile && outputBuffer) {
|
|
5595
|
-
|
|
5593
|
+
writeFileSync4(opts.outputFile, outputBuffer);
|
|
5596
5594
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5597
5595
|
}
|
|
5598
5596
|
if (fileOffer && opts.withFiles) {
|
|
5599
5597
|
console.log("");
|
|
5600
|
-
const outputDir = opts.outputFile ?
|
|
5598
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5601
5599
|
await webrtcDownload(opts.id, fileOffer, opts.token, outputDir, opts.json);
|
|
5602
5600
|
}
|
|
5603
5601
|
if (!opts.json) {
|
|
@@ -5634,7 +5632,6 @@ ${content}`;
|
|
|
5634
5632
|
let uploadOffer;
|
|
5635
5633
|
let uploadZipBuffer;
|
|
5636
5634
|
if (opts.uploadFile) {
|
|
5637
|
-
const { existsSync: existsSync8 } = __require("fs");
|
|
5638
5635
|
if (!existsSync8(opts.uploadFile)) {
|
|
5639
5636
|
log.error(`File not found: ${opts.uploadFile}`);
|
|
5640
5637
|
process.exit(1);
|