@annals/agent-mesh 0.18.0 → 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
|
-
mkdirSync6(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 } from "fs";
|
|
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,17 +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
|
-
const { mkdirSync: mkdirSync6 } = __require("fs");
|
|
3884
|
+
const tempDir = join10(tmpdir(), `chat-upload-${Date.now()}`);
|
|
3888
3885
|
mkdirSync6(tempDir, { recursive: true });
|
|
3889
|
-
const tempFile =
|
|
3890
|
-
const { copyFileSync: copyFileSync2 } = __require("fs");
|
|
3886
|
+
const tempFile = join10(tempDir, fileName);
|
|
3891
3887
|
copyFileSync2(filePath, tempFile);
|
|
3892
|
-
const zipPath =
|
|
3893
|
-
|
|
3888
|
+
const zipPath = join10(tempDir, "upload.zip");
|
|
3889
|
+
execSync5(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
3894
3890
|
const zipBuffer = readFileSync2(zipPath);
|
|
3895
3891
|
try {
|
|
3896
|
-
|
|
3892
|
+
execSync5(`rm -rf "${tempDir}"`);
|
|
3897
3893
|
} catch {
|
|
3898
3894
|
}
|
|
3899
3895
|
const zipSha256 = createHash2("sha256").update(zipBuffer).digest("hex");
|
|
@@ -4269,11 +4265,11 @@ function registerChatCommand(program2) {
|
|
|
4269
4265
|
|
|
4270
4266
|
// src/commands/skills.ts
|
|
4271
4267
|
import { readFile as readFile3, writeFile as writeFile3, readdir as readdir2, mkdir as mkdir2, rm, symlink, unlink } from "fs/promises";
|
|
4272
|
-
import { join as
|
|
4268
|
+
import { join as join12, resolve, relative as relative4 } from "path";
|
|
4273
4269
|
|
|
4274
4270
|
// src/utils/skill-parser.ts
|
|
4275
4271
|
import { readFile as readFile2, writeFile as writeFile2, stat as stat3 } from "fs/promises";
|
|
4276
|
-
import { join as
|
|
4272
|
+
import { join as join11 } from "path";
|
|
4277
4273
|
function parseSkillMd(raw) {
|
|
4278
4274
|
const trimmed = raw.trimStart();
|
|
4279
4275
|
if (!trimmed.startsWith("---")) {
|
|
@@ -4355,7 +4351,7 @@ function parseSkillMd(raw) {
|
|
|
4355
4351
|
return { frontmatter, content };
|
|
4356
4352
|
}
|
|
4357
4353
|
async function loadSkillManifest(dir) {
|
|
4358
|
-
const skillMdPath =
|
|
4354
|
+
const skillMdPath = join11(dir, "SKILL.md");
|
|
4359
4355
|
try {
|
|
4360
4356
|
const raw = await readFile2(skillMdPath, "utf-8");
|
|
4361
4357
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4460,13 +4456,13 @@ function skillApiPath(authorLogin, slug) {
|
|
|
4460
4456
|
}
|
|
4461
4457
|
async function resolveSkillsRootAsync(pathArg) {
|
|
4462
4458
|
const projectRoot = pathArg ? resolve(pathArg) : process.cwd();
|
|
4463
|
-
const skillsDir =
|
|
4464
|
-
const claudeSkillsDir =
|
|
4459
|
+
const skillsDir = join12(projectRoot, ".agents", "skills");
|
|
4460
|
+
const claudeSkillsDir = join12(projectRoot, ".claude", "skills");
|
|
4465
4461
|
return { projectRoot, skillsDir, claudeSkillsDir };
|
|
4466
4462
|
}
|
|
4467
4463
|
async function ensureClaudeSymlink(claudeSkillsDir, slug) {
|
|
4468
4464
|
await mkdir2(claudeSkillsDir, { recursive: true });
|
|
4469
|
-
const linkPath =
|
|
4465
|
+
const linkPath = join12(claudeSkillsDir, slug);
|
|
4470
4466
|
try {
|
|
4471
4467
|
await unlink(linkPath);
|
|
4472
4468
|
} catch {
|
|
@@ -4486,7 +4482,7 @@ async function collectPackFiles(dir, manifest) {
|
|
|
4486
4482
|
}
|
|
4487
4483
|
const mainFile = manifest.main || "SKILL.md";
|
|
4488
4484
|
if (!results.includes(mainFile)) {
|
|
4489
|
-
const mainPath =
|
|
4485
|
+
const mainPath = join12(dir, mainFile);
|
|
4490
4486
|
if (await pathExists(mainPath)) {
|
|
4491
4487
|
results.unshift(mainFile);
|
|
4492
4488
|
}
|
|
@@ -4503,7 +4499,7 @@ async function walkDir(dir) {
|
|
|
4503
4499
|
}
|
|
4504
4500
|
for (const entry of entries) {
|
|
4505
4501
|
if (entry.isSymbolicLink()) continue;
|
|
4506
|
-
const fullPath =
|
|
4502
|
+
const fullPath = join12(dir, entry.name);
|
|
4507
4503
|
if (entry.isDirectory()) {
|
|
4508
4504
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
4509
4505
|
const sub = await walkDir(fullPath);
|
|
@@ -4521,7 +4517,7 @@ async function packSkill(dir, manifest) {
|
|
|
4521
4517
|
}
|
|
4522
4518
|
const entries = [];
|
|
4523
4519
|
for (const relPath of fileList) {
|
|
4524
|
-
const absPath =
|
|
4520
|
+
const absPath = join12(dir, relPath);
|
|
4525
4521
|
try {
|
|
4526
4522
|
const data = await readFile3(absPath);
|
|
4527
4523
|
entries.push({ path: relPath.replace(/\\/g, "/"), data });
|
|
@@ -4555,7 +4551,7 @@ function bumpVersion(current, bump) {
|
|
|
4555
4551
|
}
|
|
4556
4552
|
async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
4557
4553
|
const meta = await client.get(skillApiPath(authorLogin, slug));
|
|
4558
|
-
const targetDir =
|
|
4554
|
+
const targetDir = join12(skillsDir, slug);
|
|
4559
4555
|
await mkdir2(targetDir, { recursive: true });
|
|
4560
4556
|
if (meta.has_files) {
|
|
4561
4557
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/download`);
|
|
@@ -4563,8 +4559,8 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4563
4559
|
const buf = Buffer.from(arrayBuf);
|
|
4564
4560
|
const entries = extractZipBuffer(buf);
|
|
4565
4561
|
for (const entry of entries) {
|
|
4566
|
-
const filePath =
|
|
4567
|
-
const dir =
|
|
4562
|
+
const filePath = join12(targetDir, entry.path);
|
|
4563
|
+
const dir = join12(filePath, "..");
|
|
4568
4564
|
await mkdir2(dir, { recursive: true });
|
|
4569
4565
|
await writeFile3(filePath, entry.data);
|
|
4570
4566
|
}
|
|
@@ -4577,7 +4573,7 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4577
4573
|
} else {
|
|
4578
4574
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/raw`);
|
|
4579
4575
|
const content = await res.text();
|
|
4580
|
-
await writeFile3(
|
|
4576
|
+
await writeFile3(join12(targetDir, "SKILL.md"), content);
|
|
4581
4577
|
return {
|
|
4582
4578
|
slug,
|
|
4583
4579
|
name: meta.name,
|
|
@@ -4606,7 +4602,7 @@ function registerSkillsCommand(program2) {
|
|
|
4606
4602
|
try {
|
|
4607
4603
|
const dir = resolveSkillDir(pathArg);
|
|
4608
4604
|
await mkdir2(dir, { recursive: true });
|
|
4609
|
-
const skillMdPath =
|
|
4605
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4610
4606
|
if (await pathExists(skillMdPath)) {
|
|
4611
4607
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4612
4608
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4635,7 +4631,7 @@ function registerSkillsCommand(program2) {
|
|
|
4635
4631
|
const dir = resolveSkillDir(pathArg);
|
|
4636
4632
|
const manifest = await loadSkillManifest(dir);
|
|
4637
4633
|
const result = await packSkill(dir, manifest);
|
|
4638
|
-
const outPath =
|
|
4634
|
+
const outPath = join12(dir, result.filename);
|
|
4639
4635
|
await writeFile3(outPath, result.buffer);
|
|
4640
4636
|
slog.info(`Packed ${result.files.length} files \u2192 ${result.filename} (${result.size} bytes)`);
|
|
4641
4637
|
outputJson({
|
|
@@ -4681,7 +4677,7 @@ function registerSkillsCommand(program2) {
|
|
|
4681
4677
|
if (opts.name) manifest.name = opts.name;
|
|
4682
4678
|
if (opts.version) manifest.version = opts.version;
|
|
4683
4679
|
if (opts.private !== void 0) manifest.private = opts.private;
|
|
4684
|
-
content = await readFile3(
|
|
4680
|
+
content = await readFile3(join12(dir, manifest.main || "SKILL.md"), "utf-8");
|
|
4685
4681
|
packResult = await packSkill(dir, manifest);
|
|
4686
4682
|
slog.info(`Packed ${packResult.files.length} files (${packResult.size} bytes)`);
|
|
4687
4683
|
}
|
|
@@ -4818,7 +4814,7 @@ function registerSkillsCommand(program2) {
|
|
|
4818
4814
|
skills.command("version <bump> [path]").description("Bump skill version (patch | minor | major | x.y.z)").action(async (bump, pathArg) => {
|
|
4819
4815
|
try {
|
|
4820
4816
|
const dir = resolveSkillDir(pathArg);
|
|
4821
|
-
const skillMdPath =
|
|
4817
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4822
4818
|
if (!await pathExists(skillMdPath)) {
|
|
4823
4819
|
outputError("not_found", "No SKILL.md found. Run `agent-mesh skills init` first.");
|
|
4824
4820
|
}
|
|
@@ -4838,7 +4834,7 @@ function registerSkillsCommand(program2) {
|
|
|
4838
4834
|
try {
|
|
4839
4835
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4840
4836
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4841
|
-
const targetDir =
|
|
4837
|
+
const targetDir = join12(skillsDir, slug);
|
|
4842
4838
|
if (await pathExists(targetDir)) {
|
|
4843
4839
|
if (!opts.force) {
|
|
4844
4840
|
outputError("already_installed", `Skill "${slug}" is already installed at ${targetDir}. Use --force to overwrite.`);
|
|
@@ -4877,11 +4873,11 @@ function registerSkillsCommand(program2) {
|
|
|
4877
4873
|
const failed = [];
|
|
4878
4874
|
if (ref) {
|
|
4879
4875
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4880
|
-
const targetDir =
|
|
4876
|
+
const targetDir = join12(skillsDir, slug);
|
|
4881
4877
|
if (!await pathExists(targetDir)) {
|
|
4882
4878
|
outputError("not_installed", `Skill "${slug}" is not installed. Use "skills install ${ref}" first.`);
|
|
4883
4879
|
}
|
|
4884
|
-
const skillMdPath =
|
|
4880
|
+
const skillMdPath = join12(targetDir, "SKILL.md");
|
|
4885
4881
|
let localVersion = "0.0.0";
|
|
4886
4882
|
if (await pathExists(skillMdPath)) {
|
|
4887
4883
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
@@ -4908,7 +4904,7 @@ function registerSkillsCommand(program2) {
|
|
|
4908
4904
|
for (const entry of entries) {
|
|
4909
4905
|
if (!entry.isDirectory()) continue;
|
|
4910
4906
|
const slug = entry.name;
|
|
4911
|
-
const skillMdPath =
|
|
4907
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4912
4908
|
if (!await pathExists(skillMdPath)) {
|
|
4913
4909
|
skipped.push({ slug, reason: "no_skill_md" });
|
|
4914
4910
|
continue;
|
|
@@ -4928,7 +4924,7 @@ function registerSkillsCommand(program2) {
|
|
|
4928
4924
|
skipped.push({ slug, reason: "up_to_date" });
|
|
4929
4925
|
} else {
|
|
4930
4926
|
slog.info(`Updating ${slug}: v${localVersion} \u2192 v${remoteVersion}...`);
|
|
4931
|
-
await rm(
|
|
4927
|
+
await rm(join12(skillsDir, slug), { recursive: true, force: true });
|
|
4932
4928
|
await downloadAndInstallSkill(client, authorLogin, slug, skillsDir);
|
|
4933
4929
|
updated.push({ slug, name: remote.name, old_version: localVersion, new_version: remoteVersion });
|
|
4934
4930
|
}
|
|
@@ -4949,13 +4945,13 @@ function registerSkillsCommand(program2) {
|
|
|
4949
4945
|
skills.command("remove <slug> [path]").description("Remove a locally installed skill").action(async (slug, pathArg) => {
|
|
4950
4946
|
try {
|
|
4951
4947
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4952
|
-
const targetDir =
|
|
4948
|
+
const targetDir = join12(skillsDir, slug);
|
|
4953
4949
|
if (!await pathExists(targetDir)) {
|
|
4954
4950
|
outputError("not_installed", `Skill "${slug}" is not installed at ${targetDir}`);
|
|
4955
4951
|
}
|
|
4956
4952
|
await rm(targetDir, { recursive: true, force: true });
|
|
4957
4953
|
try {
|
|
4958
|
-
await unlink(
|
|
4954
|
+
await unlink(join12(claudeSkillsDir, slug));
|
|
4959
4955
|
} catch {
|
|
4960
4956
|
}
|
|
4961
4957
|
slog.success(`Removed skill: ${slug}`);
|
|
@@ -4980,7 +4976,7 @@ function registerSkillsCommand(program2) {
|
|
|
4980
4976
|
for (const entry of entries) {
|
|
4981
4977
|
if (!entry.isDirectory()) continue;
|
|
4982
4978
|
const slug = entry.name;
|
|
4983
|
-
const skillMdPath =
|
|
4979
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4984
4980
|
if (!await pathExists(skillMdPath)) continue;
|
|
4985
4981
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4986
4982
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -5092,9 +5088,11 @@ function registerDiscoverCommand(program2) {
|
|
|
5092
5088
|
}
|
|
5093
5089
|
|
|
5094
5090
|
// src/commands/call.ts
|
|
5095
|
-
import { readFileSync as readFileSync3, writeFileSync as
|
|
5096
|
-
import { execSync as
|
|
5097
|
-
import {
|
|
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";
|
|
5093
|
+
import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
|
|
5094
|
+
import { join as join13, basename as basename3 } from "path";
|
|
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) {
|
|
5100
5098
|
const res = await fetch(`${baseUrl}/api/agents/${agentId}/rate`, {
|
|
@@ -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 {
|
|
@@ -5223,27 +5221,20 @@ async function webrtcDownload(agentId, offer, token, outputDir, json) {
|
|
|
5223
5221
|
}
|
|
5224
5222
|
}
|
|
5225
5223
|
function prepareFileForUpload(filePath) {
|
|
5226
|
-
const { readFileSync: _readFileSync } = __require("fs");
|
|
5227
|
-
const { basename: basename3 } = __require("path");
|
|
5228
|
-
const { execSync: _execSync } = __require("child_process");
|
|
5229
|
-
const { createHash: createHash3 } = __require("crypto");
|
|
5230
|
-
const { tmpdir: tmpdir2 } = __require("os");
|
|
5231
5224
|
const fileName = basename3(filePath);
|
|
5232
|
-
const tempDir =
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
const
|
|
5237
|
-
|
|
5238
|
-
const
|
|
5239
|
-
_execSync(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
5240
|
-
const zipBuffer = _readFileSync(zipPath);
|
|
5225
|
+
const tempDir = join13(tmpdir2(), `upload-${Date.now()}`);
|
|
5226
|
+
mkdirSync7(tempDir, { recursive: true });
|
|
5227
|
+
const tempFile = join13(tempDir, fileName);
|
|
5228
|
+
copyFileSync3(filePath, tempFile);
|
|
5229
|
+
const zipPath = join13(tempDir, "upload.zip");
|
|
5230
|
+
execSync6(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
5231
|
+
const zipBuffer = readFileSync3(zipPath);
|
|
5241
5232
|
try {
|
|
5242
|
-
|
|
5233
|
+
execSync6(`rm -rf "${tempDir}"`);
|
|
5243
5234
|
} catch {
|
|
5244
5235
|
}
|
|
5245
5236
|
const zipSha256 = createHash3("sha256").update(zipBuffer).digest("hex");
|
|
5246
|
-
const transferId =
|
|
5237
|
+
const transferId = randomUUID2();
|
|
5247
5238
|
return {
|
|
5248
5239
|
offer: {
|
|
5249
5240
|
transfer_id: transferId,
|
|
@@ -5425,11 +5416,11 @@ async function asyncCall(opts) {
|
|
|
5425
5416
|
}
|
|
5426
5417
|
}
|
|
5427
5418
|
if (opts.outputFile && result) {
|
|
5428
|
-
|
|
5419
|
+
writeFileSync4(opts.outputFile, result);
|
|
5429
5420
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5430
5421
|
}
|
|
5431
5422
|
if (offer && opts.withFiles) {
|
|
5432
|
-
const outputDir = opts.outputFile ?
|
|
5423
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5433
5424
|
await webrtcDownload(opts.id, offer, opts.token, outputDir, opts.json);
|
|
5434
5425
|
}
|
|
5435
5426
|
if (!opts.json) {
|
|
@@ -5599,12 +5590,12 @@ Error: ${event.message}
|
|
|
5599
5590
|
}
|
|
5600
5591
|
}
|
|
5601
5592
|
if (opts.outputFile && outputBuffer) {
|
|
5602
|
-
|
|
5593
|
+
writeFileSync4(opts.outputFile, outputBuffer);
|
|
5603
5594
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5604
5595
|
}
|
|
5605
5596
|
if (fileOffer && opts.withFiles) {
|
|
5606
5597
|
console.log("");
|
|
5607
|
-
const outputDir = opts.outputFile ?
|
|
5598
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5608
5599
|
await webrtcDownload(opts.id, fileOffer, opts.token, outputDir, opts.json);
|
|
5609
5600
|
}
|
|
5610
5601
|
if (!opts.json) {
|
|
@@ -5641,7 +5632,6 @@ ${content}`;
|
|
|
5641
5632
|
let uploadOffer;
|
|
5642
5633
|
let uploadZipBuffer;
|
|
5643
5634
|
if (opts.uploadFile) {
|
|
5644
|
-
const { existsSync: existsSync8 } = __require("fs");
|
|
5645
5635
|
if (!existsSync8(opts.uploadFile)) {
|
|
5646
5636
|
log.error(`File not found: ${opts.uploadFile}`);
|
|
5647
5637
|
process.exit(1);
|