@annals/agent-mesh 0.18.1 → 0.18.3
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";
|
|
@@ -368,19 +367,22 @@ var FileSender = class {
|
|
|
368
367
|
});
|
|
369
368
|
});
|
|
370
369
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
this.peer.
|
|
381
|
-
|
|
382
|
-
|
|
370
|
+
try {
|
|
371
|
+
if (signal.signal_type === "offer" || signal.signal_type === "answer") {
|
|
372
|
+
this.peer.setRemoteDescription(signal.payload, signal.signal_type);
|
|
373
|
+
for (const c of this.pendingCandidates) {
|
|
374
|
+
this.peer.addRemoteCandidate(c.candidate, c.mid);
|
|
375
|
+
}
|
|
376
|
+
this.pendingCandidates = [];
|
|
377
|
+
} else if (signal.signal_type === "candidate") {
|
|
378
|
+
const { candidate, mid } = JSON.parse(signal.payload);
|
|
379
|
+
if (this.peer.remoteDescription()) {
|
|
380
|
+
this.peer.addRemoteCandidate(candidate, mid);
|
|
381
|
+
} else {
|
|
382
|
+
this.pendingCandidates.push({ candidate, mid });
|
|
383
|
+
}
|
|
383
384
|
}
|
|
385
|
+
} catch {
|
|
384
386
|
}
|
|
385
387
|
}
|
|
386
388
|
async sendZip(dc) {
|
|
@@ -470,19 +472,22 @@ var FileReceiver = class {
|
|
|
470
472
|
}
|
|
471
473
|
async handleSignal(signal) {
|
|
472
474
|
if (!this.peer || this.closed) return;
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
this.peer.
|
|
483
|
-
|
|
484
|
-
|
|
475
|
+
try {
|
|
476
|
+
if (signal.signal_type === "answer" || signal.signal_type === "offer") {
|
|
477
|
+
this.peer.setRemoteDescription(signal.payload, signal.signal_type);
|
|
478
|
+
for (const c of this.pendingCandidates) {
|
|
479
|
+
this.peer.addRemoteCandidate(c.candidate, c.mid);
|
|
480
|
+
}
|
|
481
|
+
this.pendingCandidates = [];
|
|
482
|
+
} else if (signal.signal_type === "candidate") {
|
|
483
|
+
const { candidate, mid } = JSON.parse(signal.payload);
|
|
484
|
+
if (this.peer.remoteDescription()) {
|
|
485
|
+
this.peer.addRemoteCandidate(candidate, mid);
|
|
486
|
+
} else {
|
|
487
|
+
this.pendingCandidates.push({ candidate, mid });
|
|
488
|
+
}
|
|
485
489
|
}
|
|
490
|
+
} catch {
|
|
486
491
|
}
|
|
487
492
|
}
|
|
488
493
|
waitForCompletion(timeoutMs = CONNECT_TIMEOUT_MS) {
|
|
@@ -685,19 +690,22 @@ var FileUploadSender = class {
|
|
|
685
690
|
}
|
|
686
691
|
async handleSignal(signal) {
|
|
687
692
|
if (!this.peer || this.closed) return;
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
this.peer.
|
|
698
|
-
|
|
699
|
-
|
|
693
|
+
try {
|
|
694
|
+
if (signal.signal_type === "answer" || signal.signal_type === "offer") {
|
|
695
|
+
this.peer.setRemoteDescription(signal.payload, signal.signal_type);
|
|
696
|
+
for (const c of this.pendingCandidates) {
|
|
697
|
+
this.peer.addRemoteCandidate(c.candidate, c.mid);
|
|
698
|
+
}
|
|
699
|
+
this.pendingCandidates = [];
|
|
700
|
+
} else if (signal.signal_type === "candidate") {
|
|
701
|
+
const { candidate, mid } = JSON.parse(signal.payload);
|
|
702
|
+
if (this.peer.remoteDescription()) {
|
|
703
|
+
this.peer.addRemoteCandidate(candidate, mid);
|
|
704
|
+
} else {
|
|
705
|
+
this.pendingCandidates.push({ candidate, mid });
|
|
706
|
+
}
|
|
700
707
|
}
|
|
708
|
+
} catch {
|
|
701
709
|
}
|
|
702
710
|
}
|
|
703
711
|
waitForCompletion(timeoutMs = 3e4) {
|
|
@@ -1141,6 +1149,10 @@ function createLocalRuntimeQueue(config) {
|
|
|
1141
1149
|
}
|
|
1142
1150
|
|
|
1143
1151
|
// src/bridge/manager.ts
|
|
1152
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1153
|
+
import { execSync } from "child_process";
|
|
1154
|
+
import { join as join3 } from "path";
|
|
1155
|
+
import { homedir as homedir2 } from "os";
|
|
1144
1156
|
var DUPLICATE_REQUEST_TTL_MS = 10 * 6e4;
|
|
1145
1157
|
var SESSION_SWEEP_INTERVAL_MS = 6e4;
|
|
1146
1158
|
var DEFAULT_SESSION_IDLE_TTL_MS = 10 * 6e4;
|
|
@@ -1661,16 +1673,13 @@ var BridgeManager = class {
|
|
|
1661
1673
|
this.pendingUploads.delete(offer.transfer_id);
|
|
1662
1674
|
const workspaceDir = this.resolveUploadWorkspace(_sessionId);
|
|
1663
1675
|
try {
|
|
1664
|
-
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
mkdirSync7(workspaceDir, { recursive: true });
|
|
1668
|
-
const zipPath = join13(workspaceDir, ".upload.zip");
|
|
1669
|
-
writeFileSync4(zipPath, zipBuffer);
|
|
1676
|
+
mkdirSync3(workspaceDir, { recursive: true });
|
|
1677
|
+
const zipPath = join3(workspaceDir, ".upload.zip");
|
|
1678
|
+
writeFileSync2(zipPath, zipBuffer);
|
|
1670
1679
|
try {
|
|
1671
|
-
|
|
1680
|
+
execSync(`unzip -o -q "${zipPath}" -d "${workspaceDir}"`);
|
|
1672
1681
|
try {
|
|
1673
|
-
|
|
1682
|
+
execSync(`rm "${zipPath}"`);
|
|
1674
1683
|
} catch {
|
|
1675
1684
|
}
|
|
1676
1685
|
log.info(`[WebRTC] Upload: ${offer.file_count} file(s) extracted to ${workspaceDir}`);
|
|
@@ -1687,10 +1696,8 @@ var BridgeManager = class {
|
|
|
1687
1696
|
log.info(`[WebRTC] Upload registered: transfer=${offer.transfer_id.slice(0, 8)}... (${offer.file_count} files, ${(offer.zip_size / 1024).toFixed(1)} KB)`);
|
|
1688
1697
|
}
|
|
1689
1698
|
resolveUploadWorkspace(sessionId) {
|
|
1690
|
-
const { join: join13 } = __require("path");
|
|
1691
|
-
const { homedir: homedir6 } = __require("os");
|
|
1692
1699
|
const safeSessionId = sessionId.replace(/[^a-zA-Z0-9_:-]/g, "_").slice(0, 64);
|
|
1693
|
-
return
|
|
1700
|
+
return join3(homedir2(), ".agent-mesh", "uploads", safeSessionId);
|
|
1694
1701
|
}
|
|
1695
1702
|
cleanupPendingUploads() {
|
|
1696
1703
|
for (const [, entry] of this.pendingUploads) {
|
|
@@ -1719,8 +1726,8 @@ var AgentAdapter = class {
|
|
|
1719
1726
|
import { spawn } from "child_process";
|
|
1720
1727
|
|
|
1721
1728
|
// src/utils/sandbox.ts
|
|
1722
|
-
import { execSync } from "child_process";
|
|
1723
|
-
import { join as
|
|
1729
|
+
import { execSync as execSync2 } from "child_process";
|
|
1730
|
+
import { join as join4 } from "path";
|
|
1724
1731
|
var SRT_PACKAGE = "@anthropic-ai/sandbox-runtime";
|
|
1725
1732
|
var SENSITIVE_PATHS = [
|
|
1726
1733
|
// SSH & crypto keys
|
|
@@ -1778,8 +1785,8 @@ var sandboxManager = null;
|
|
|
1778
1785
|
var sandboxInitialized = false;
|
|
1779
1786
|
async function importSandboxManager() {
|
|
1780
1787
|
try {
|
|
1781
|
-
const globalRoot =
|
|
1782
|
-
const srtPath =
|
|
1788
|
+
const globalRoot = execSync2("npm root -g", { encoding: "utf-8" }).trim();
|
|
1789
|
+
const srtPath = join4(globalRoot, "@anthropic-ai/sandbox-runtime/dist/index.js");
|
|
1783
1790
|
const mod = await import(srtPath);
|
|
1784
1791
|
return mod.SandboxManager;
|
|
1785
1792
|
} catch {
|
|
@@ -1867,7 +1874,7 @@ function buildCommandString(command, args) {
|
|
|
1867
1874
|
function installSandboxRuntime() {
|
|
1868
1875
|
log.info(`Installing ${SRT_PACKAGE}...`);
|
|
1869
1876
|
try {
|
|
1870
|
-
|
|
1877
|
+
execSync2(`npm install -g ${SRT_PACKAGE}`, { stdio: "inherit" });
|
|
1871
1878
|
log.success(`${SRT_PACKAGE} installed successfully`);
|
|
1872
1879
|
return true;
|
|
1873
1880
|
} catch {
|
|
@@ -1947,18 +1954,18 @@ async function spawnAgent(command, args, options) {
|
|
|
1947
1954
|
|
|
1948
1955
|
// src/adapters/claude.ts
|
|
1949
1956
|
import { createInterface } from "readline";
|
|
1950
|
-
import { homedir as
|
|
1957
|
+
import { homedir as homedir4 } from "os";
|
|
1951
1958
|
|
|
1952
1959
|
// src/utils/which.ts
|
|
1953
1960
|
import { execFile } from "child_process";
|
|
1954
1961
|
import { access, constants } from "fs/promises";
|
|
1955
|
-
import { homedir as
|
|
1962
|
+
import { homedir as homedir3 } from "os";
|
|
1956
1963
|
var ALLOWED_COMMANDS = /^[a-zA-Z0-9._-]+$/;
|
|
1957
1964
|
var FALLBACK_PATHS = {
|
|
1958
1965
|
claude: [
|
|
1959
1966
|
"/opt/homebrew/bin/claude",
|
|
1960
1967
|
"/usr/local/bin/claude",
|
|
1961
|
-
`${
|
|
1968
|
+
`${homedir3()}/.local/bin/claude`
|
|
1962
1969
|
]
|
|
1963
1970
|
};
|
|
1964
1971
|
async function resolveFallbackPath(command) {
|
|
@@ -1988,8 +1995,8 @@ function which(command) {
|
|
|
1988
1995
|
}
|
|
1989
1996
|
|
|
1990
1997
|
// src/utils/client-workspace.ts
|
|
1991
|
-
import { mkdirSync as
|
|
1992
|
-
import { join as
|
|
1998
|
+
import { mkdirSync as mkdirSync4, readdirSync, symlinkSync, existsSync as existsSync3, lstatSync } from "fs";
|
|
1999
|
+
import { join as join5, relative } from "path";
|
|
1993
2000
|
var SYMLINK_ALLOW = /* @__PURE__ */ new Set([
|
|
1994
2001
|
"CLAUDE.md",
|
|
1995
2002
|
".claude",
|
|
@@ -2018,19 +2025,19 @@ function shouldInclude(name) {
|
|
|
2018
2025
|
return false;
|
|
2019
2026
|
}
|
|
2020
2027
|
function createClientWorkspace(projectPath, clientId) {
|
|
2021
|
-
const wsDir =
|
|
2028
|
+
const wsDir = join5(projectPath, ".bridge-clients", clientId);
|
|
2022
2029
|
const isNew = !existsSync3(wsDir);
|
|
2023
|
-
|
|
2030
|
+
mkdirSync4(wsDir, { recursive: true });
|
|
2024
2031
|
const entries = readdirSync(projectPath, { withFileTypes: true });
|
|
2025
2032
|
for (const entry of entries) {
|
|
2026
2033
|
if (!shouldInclude(entry.name)) continue;
|
|
2027
|
-
const link =
|
|
2034
|
+
const link = join5(wsDir, entry.name);
|
|
2028
2035
|
try {
|
|
2029
2036
|
lstatSync(link);
|
|
2030
2037
|
continue;
|
|
2031
2038
|
} catch {
|
|
2032
2039
|
}
|
|
2033
|
-
const target =
|
|
2040
|
+
const target = join5(projectPath, entry.name);
|
|
2034
2041
|
const relTarget = relative(wsDir, target);
|
|
2035
2042
|
try {
|
|
2036
2043
|
symlinkSync(relTarget, link);
|
|
@@ -2046,11 +2053,11 @@ function createClientWorkspace(projectPath, clientId) {
|
|
|
2046
2053
|
|
|
2047
2054
|
// src/adapters/claude.ts
|
|
2048
2055
|
import { writeFile, mkdir, stat as stat2 } from "fs/promises";
|
|
2049
|
-
import { join as
|
|
2056
|
+
import { join as join7, relative as relative3, basename } from "path";
|
|
2050
2057
|
|
|
2051
2058
|
// src/utils/auto-upload.ts
|
|
2052
2059
|
import { readdir, readFile, stat } from "fs/promises";
|
|
2053
|
-
import { join as
|
|
2060
|
+
import { join as join6, relative as relative2 } from "path";
|
|
2054
2061
|
var MAX_AUTO_UPLOAD_FILE_SIZE = 10 * 1024 * 1024;
|
|
2055
2062
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
2056
2063
|
".git",
|
|
@@ -2084,7 +2091,7 @@ async function collectRealFiles(dir, maxFiles = Infinity) {
|
|
|
2084
2091
|
}
|
|
2085
2092
|
for (const entry of entries) {
|
|
2086
2093
|
if (files.length >= maxFiles) return;
|
|
2087
|
-
const fullPath =
|
|
2094
|
+
const fullPath = join6(d, entry.name);
|
|
2088
2095
|
if (entry.isDirectory()) {
|
|
2089
2096
|
if (SKIP_DIRS.has(entry.name)) continue;
|
|
2090
2097
|
await walk(fullPath);
|
|
@@ -2256,7 +2263,7 @@ function extractZipBuffer(buf) {
|
|
|
2256
2263
|
// src/adapters/claude.ts
|
|
2257
2264
|
var DEFAULT_IDLE_TIMEOUT = 30 * 60 * 1e3;
|
|
2258
2265
|
var MIN_IDLE_TIMEOUT = 60 * 1e3;
|
|
2259
|
-
var HOME_DIR =
|
|
2266
|
+
var HOME_DIR = homedir4();
|
|
2260
2267
|
var CLAUDE_RUNTIME_ALLOW_WRITE_PATHS = [
|
|
2261
2268
|
`${HOME_DIR}/.claude`,
|
|
2262
2269
|
`${HOME_DIR}/.claude.json`,
|
|
@@ -2330,7 +2337,7 @@ var ClaudeSession = class {
|
|
|
2330
2337
|
await mkdir(workspaceRoot, { recursive: true });
|
|
2331
2338
|
for (const att of attachments) {
|
|
2332
2339
|
const safeName = basename(att.name).replace(/[^a-zA-Z0-9._-]/g, "_") || "attachment";
|
|
2333
|
-
const destPath =
|
|
2340
|
+
const destPath = join7(workspaceRoot, safeName);
|
|
2334
2341
|
try {
|
|
2335
2342
|
const res = await fetch(att.url);
|
|
2336
2343
|
if (!res.ok) {
|
|
@@ -2776,7 +2783,7 @@ function registerConnectCommand(program2) {
|
|
|
2776
2783
|
log.error(`Failed to start. Check logs: ${getLogPath(slug)}`);
|
|
2777
2784
|
process.exit(1);
|
|
2778
2785
|
}
|
|
2779
|
-
const { ListTUI } = await import("./list-
|
|
2786
|
+
const { ListTUI } = await import("./list-ROLJARYB.js");
|
|
2780
2787
|
const tui = new ListTUI();
|
|
2781
2788
|
await tui.run();
|
|
2782
2789
|
return;
|
|
@@ -3337,14 +3344,14 @@ function registerOpenCommand(program2) {
|
|
|
3337
3344
|
}
|
|
3338
3345
|
|
|
3339
3346
|
// src/commands/install.ts
|
|
3340
|
-
import { writeFileSync as
|
|
3341
|
-
import { join as
|
|
3342
|
-
import { homedir as
|
|
3343
|
-
import { execSync as
|
|
3347
|
+
import { writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync5 } from "fs";
|
|
3348
|
+
import { join as join8 } from "path";
|
|
3349
|
+
import { homedir as homedir5 } from "os";
|
|
3350
|
+
import { execSync as execSync3 } from "child_process";
|
|
3344
3351
|
var LABEL = "com.agents-hot.agent-mesh";
|
|
3345
|
-
var PLIST_DIR =
|
|
3346
|
-
var PLIST_PATH =
|
|
3347
|
-
var LOG_PATH =
|
|
3352
|
+
var PLIST_DIR = join8(homedir5(), "Library", "LaunchAgents");
|
|
3353
|
+
var PLIST_PATH = join8(PLIST_DIR, `${LABEL}.plist`);
|
|
3354
|
+
var LOG_PATH = join8(homedir5(), ".agent-mesh", "logs", "launchd.log");
|
|
3348
3355
|
function detectPaths() {
|
|
3349
3356
|
return {
|
|
3350
3357
|
node: process.execPath,
|
|
@@ -3377,7 +3384,7 @@ function generatePlist(nodePath, scriptPath) {
|
|
|
3377
3384
|
<string>${escapeXml(LOG_PATH)}</string>
|
|
3378
3385
|
|
|
3379
3386
|
<key>WorkingDirectory</key>
|
|
3380
|
-
<string>${escapeXml(
|
|
3387
|
+
<string>${escapeXml(homedir5())}</string>
|
|
3381
3388
|
</dict>
|
|
3382
3389
|
</plist>
|
|
3383
3390
|
`;
|
|
@@ -3402,21 +3409,21 @@ function registerInstallCommand(program2) {
|
|
|
3402
3409
|
}
|
|
3403
3410
|
const { node, script } = detectPaths();
|
|
3404
3411
|
if (!existsSync5(PLIST_DIR)) {
|
|
3405
|
-
|
|
3412
|
+
mkdirSync5(PLIST_DIR, { recursive: true });
|
|
3406
3413
|
}
|
|
3407
3414
|
if (existsSync5(PLIST_PATH)) {
|
|
3408
3415
|
try {
|
|
3409
|
-
|
|
3416
|
+
execSync3(`launchctl bootout gui/$(id -u) "${PLIST_PATH}" 2>/dev/null`, { stdio: "ignore" });
|
|
3410
3417
|
} catch {
|
|
3411
3418
|
}
|
|
3412
3419
|
}
|
|
3413
3420
|
const plist = generatePlist(node, script);
|
|
3414
|
-
|
|
3421
|
+
writeFileSync3(PLIST_PATH, plist, { encoding: "utf-8" });
|
|
3415
3422
|
try {
|
|
3416
|
-
|
|
3423
|
+
execSync3(`launchctl bootstrap gui/$(id -u) "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
3417
3424
|
} catch {
|
|
3418
3425
|
try {
|
|
3419
|
-
|
|
3426
|
+
execSync3(`launchctl load "${PLIST_PATH}"`, { stdio: "pipe" });
|
|
3420
3427
|
} catch (err) {
|
|
3421
3428
|
log.error(`Failed to load LaunchAgent: ${err}`);
|
|
3422
3429
|
log.info(`Plist written to ${PLIST_PATH} \u2014 you can load it manually.`);
|
|
@@ -3438,11 +3445,11 @@ function registerInstallCommand(program2) {
|
|
|
3438
3445
|
|
|
3439
3446
|
// src/commands/uninstall.ts
|
|
3440
3447
|
import { existsSync as existsSync6, unlinkSync as unlinkSync2 } from "fs";
|
|
3441
|
-
import { join as
|
|
3442
|
-
import { homedir as
|
|
3443
|
-
import { execSync as
|
|
3448
|
+
import { join as join9 } from "path";
|
|
3449
|
+
import { homedir as homedir6 } from "os";
|
|
3450
|
+
import { execSync as execSync4 } from "child_process";
|
|
3444
3451
|
var LABEL2 = "com.agents-hot.agent-mesh";
|
|
3445
|
-
var PLIST_PATH2 =
|
|
3452
|
+
var PLIST_PATH2 = join9(homedir6(), "Library", "LaunchAgents", `${LABEL2}.plist`);
|
|
3446
3453
|
function registerUninstallCommand(program2) {
|
|
3447
3454
|
program2.command("uninstall").description("Remove macOS LaunchAgent (agents will no longer auto-start)").action(async () => {
|
|
3448
3455
|
if (process.platform !== "darwin") {
|
|
@@ -3456,10 +3463,10 @@ function registerUninstallCommand(program2) {
|
|
|
3456
3463
|
return;
|
|
3457
3464
|
}
|
|
3458
3465
|
try {
|
|
3459
|
-
|
|
3466
|
+
execSync4(`launchctl bootout gui/$(id -u) "${PLIST_PATH2}" 2>/dev/null`, { stdio: "ignore" });
|
|
3460
3467
|
} catch {
|
|
3461
3468
|
try {
|
|
3462
|
-
|
|
3469
|
+
execSync4(`launchctl unload "${PLIST_PATH2}" 2>/dev/null`, { stdio: "ignore" });
|
|
3463
3470
|
} catch {
|
|
3464
3471
|
}
|
|
3465
3472
|
}
|
|
@@ -3854,9 +3861,9 @@ function registerAgentsCommand(program2) {
|
|
|
3854
3861
|
|
|
3855
3862
|
// src/commands/chat.ts
|
|
3856
3863
|
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
|
|
3864
|
+
import { existsSync as existsSync7, readFileSync as readFileSync2, mkdirSync as mkdirSync6, copyFileSync as copyFileSync2 } from "fs";
|
|
3865
|
+
import { basename as basename2, join as join10 } from "path";
|
|
3866
|
+
import { execSync as execSync5 } from "child_process";
|
|
3860
3867
|
import { createHash as createHash2, randomUUID } from "crypto";
|
|
3861
3868
|
import { tmpdir } from "os";
|
|
3862
3869
|
|
|
@@ -3883,15 +3890,15 @@ function parseSseChunk(raw, carry) {
|
|
|
3883
3890
|
var DEFAULT_BASE_URL3 = "https://agents.hot";
|
|
3884
3891
|
function prepareUploadFile(filePath) {
|
|
3885
3892
|
const fileName = basename2(filePath);
|
|
3886
|
-
const tempDir =
|
|
3887
|
-
|
|
3888
|
-
const tempFile =
|
|
3893
|
+
const tempDir = join10(tmpdir(), `chat-upload-${Date.now()}`);
|
|
3894
|
+
mkdirSync6(tempDir, { recursive: true });
|
|
3895
|
+
const tempFile = join10(tempDir, fileName);
|
|
3889
3896
|
copyFileSync2(filePath, tempFile);
|
|
3890
|
-
const zipPath =
|
|
3891
|
-
|
|
3897
|
+
const zipPath = join10(tempDir, "upload.zip");
|
|
3898
|
+
execSync5(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
3892
3899
|
const zipBuffer = readFileSync2(zipPath);
|
|
3893
3900
|
try {
|
|
3894
|
-
|
|
3901
|
+
execSync5(`rm -rf "${tempDir}"`);
|
|
3895
3902
|
} catch {
|
|
3896
3903
|
}
|
|
3897
3904
|
const zipSha256 = createHash2("sha256").update(zipBuffer).digest("hex");
|
|
@@ -4267,11 +4274,11 @@ function registerChatCommand(program2) {
|
|
|
4267
4274
|
|
|
4268
4275
|
// src/commands/skills.ts
|
|
4269
4276
|
import { readFile as readFile3, writeFile as writeFile3, readdir as readdir2, mkdir as mkdir2, rm, symlink, unlink } from "fs/promises";
|
|
4270
|
-
import { join as
|
|
4277
|
+
import { join as join12, resolve, relative as relative4 } from "path";
|
|
4271
4278
|
|
|
4272
4279
|
// src/utils/skill-parser.ts
|
|
4273
4280
|
import { readFile as readFile2, writeFile as writeFile2, stat as stat3 } from "fs/promises";
|
|
4274
|
-
import { join as
|
|
4281
|
+
import { join as join11 } from "path";
|
|
4275
4282
|
function parseSkillMd(raw) {
|
|
4276
4283
|
const trimmed = raw.trimStart();
|
|
4277
4284
|
if (!trimmed.startsWith("---")) {
|
|
@@ -4353,7 +4360,7 @@ function parseSkillMd(raw) {
|
|
|
4353
4360
|
return { frontmatter, content };
|
|
4354
4361
|
}
|
|
4355
4362
|
async function loadSkillManifest(dir) {
|
|
4356
|
-
const skillMdPath =
|
|
4363
|
+
const skillMdPath = join11(dir, "SKILL.md");
|
|
4357
4364
|
try {
|
|
4358
4365
|
const raw = await readFile2(skillMdPath, "utf-8");
|
|
4359
4366
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4458,13 +4465,13 @@ function skillApiPath(authorLogin, slug) {
|
|
|
4458
4465
|
}
|
|
4459
4466
|
async function resolveSkillsRootAsync(pathArg) {
|
|
4460
4467
|
const projectRoot = pathArg ? resolve(pathArg) : process.cwd();
|
|
4461
|
-
const skillsDir =
|
|
4462
|
-
const claudeSkillsDir =
|
|
4468
|
+
const skillsDir = join12(projectRoot, ".agents", "skills");
|
|
4469
|
+
const claudeSkillsDir = join12(projectRoot, ".claude", "skills");
|
|
4463
4470
|
return { projectRoot, skillsDir, claudeSkillsDir };
|
|
4464
4471
|
}
|
|
4465
4472
|
async function ensureClaudeSymlink(claudeSkillsDir, slug) {
|
|
4466
4473
|
await mkdir2(claudeSkillsDir, { recursive: true });
|
|
4467
|
-
const linkPath =
|
|
4474
|
+
const linkPath = join12(claudeSkillsDir, slug);
|
|
4468
4475
|
try {
|
|
4469
4476
|
await unlink(linkPath);
|
|
4470
4477
|
} catch {
|
|
@@ -4484,7 +4491,7 @@ async function collectPackFiles(dir, manifest) {
|
|
|
4484
4491
|
}
|
|
4485
4492
|
const mainFile = manifest.main || "SKILL.md";
|
|
4486
4493
|
if (!results.includes(mainFile)) {
|
|
4487
|
-
const mainPath =
|
|
4494
|
+
const mainPath = join12(dir, mainFile);
|
|
4488
4495
|
if (await pathExists(mainPath)) {
|
|
4489
4496
|
results.unshift(mainFile);
|
|
4490
4497
|
}
|
|
@@ -4501,7 +4508,7 @@ async function walkDir(dir) {
|
|
|
4501
4508
|
}
|
|
4502
4509
|
for (const entry of entries) {
|
|
4503
4510
|
if (entry.isSymbolicLink()) continue;
|
|
4504
|
-
const fullPath =
|
|
4511
|
+
const fullPath = join12(dir, entry.name);
|
|
4505
4512
|
if (entry.isDirectory()) {
|
|
4506
4513
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
4507
4514
|
const sub = await walkDir(fullPath);
|
|
@@ -4519,7 +4526,7 @@ async function packSkill(dir, manifest) {
|
|
|
4519
4526
|
}
|
|
4520
4527
|
const entries = [];
|
|
4521
4528
|
for (const relPath of fileList) {
|
|
4522
|
-
const absPath =
|
|
4529
|
+
const absPath = join12(dir, relPath);
|
|
4523
4530
|
try {
|
|
4524
4531
|
const data = await readFile3(absPath);
|
|
4525
4532
|
entries.push({ path: relPath.replace(/\\/g, "/"), data });
|
|
@@ -4553,7 +4560,7 @@ function bumpVersion(current, bump) {
|
|
|
4553
4560
|
}
|
|
4554
4561
|
async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
4555
4562
|
const meta = await client.get(skillApiPath(authorLogin, slug));
|
|
4556
|
-
const targetDir =
|
|
4563
|
+
const targetDir = join12(skillsDir, slug);
|
|
4557
4564
|
await mkdir2(targetDir, { recursive: true });
|
|
4558
4565
|
if (meta.has_files) {
|
|
4559
4566
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/download`);
|
|
@@ -4561,8 +4568,8 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4561
4568
|
const buf = Buffer.from(arrayBuf);
|
|
4562
4569
|
const entries = extractZipBuffer(buf);
|
|
4563
4570
|
for (const entry of entries) {
|
|
4564
|
-
const filePath =
|
|
4565
|
-
const dir =
|
|
4571
|
+
const filePath = join12(targetDir, entry.path);
|
|
4572
|
+
const dir = join12(filePath, "..");
|
|
4566
4573
|
await mkdir2(dir, { recursive: true });
|
|
4567
4574
|
await writeFile3(filePath, entry.data);
|
|
4568
4575
|
}
|
|
@@ -4575,7 +4582,7 @@ async function downloadAndInstallSkill(client, authorLogin, slug, skillsDir) {
|
|
|
4575
4582
|
} else {
|
|
4576
4583
|
const res = await client.getRaw(`${skillApiPath(authorLogin, slug)}/raw`);
|
|
4577
4584
|
const content = await res.text();
|
|
4578
|
-
await writeFile3(
|
|
4585
|
+
await writeFile3(join12(targetDir, "SKILL.md"), content);
|
|
4579
4586
|
return {
|
|
4580
4587
|
slug,
|
|
4581
4588
|
name: meta.name,
|
|
@@ -4604,7 +4611,7 @@ function registerSkillsCommand(program2) {
|
|
|
4604
4611
|
try {
|
|
4605
4612
|
const dir = resolveSkillDir(pathArg);
|
|
4606
4613
|
await mkdir2(dir, { recursive: true });
|
|
4607
|
-
const skillMdPath =
|
|
4614
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4608
4615
|
if (await pathExists(skillMdPath)) {
|
|
4609
4616
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4610
4617
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -4633,7 +4640,7 @@ function registerSkillsCommand(program2) {
|
|
|
4633
4640
|
const dir = resolveSkillDir(pathArg);
|
|
4634
4641
|
const manifest = await loadSkillManifest(dir);
|
|
4635
4642
|
const result = await packSkill(dir, manifest);
|
|
4636
|
-
const outPath =
|
|
4643
|
+
const outPath = join12(dir, result.filename);
|
|
4637
4644
|
await writeFile3(outPath, result.buffer);
|
|
4638
4645
|
slog.info(`Packed ${result.files.length} files \u2192 ${result.filename} (${result.size} bytes)`);
|
|
4639
4646
|
outputJson({
|
|
@@ -4679,7 +4686,7 @@ function registerSkillsCommand(program2) {
|
|
|
4679
4686
|
if (opts.name) manifest.name = opts.name;
|
|
4680
4687
|
if (opts.version) manifest.version = opts.version;
|
|
4681
4688
|
if (opts.private !== void 0) manifest.private = opts.private;
|
|
4682
|
-
content = await readFile3(
|
|
4689
|
+
content = await readFile3(join12(dir, manifest.main || "SKILL.md"), "utf-8");
|
|
4683
4690
|
packResult = await packSkill(dir, manifest);
|
|
4684
4691
|
slog.info(`Packed ${packResult.files.length} files (${packResult.size} bytes)`);
|
|
4685
4692
|
}
|
|
@@ -4816,7 +4823,7 @@ function registerSkillsCommand(program2) {
|
|
|
4816
4823
|
skills.command("version <bump> [path]").description("Bump skill version (patch | minor | major | x.y.z)").action(async (bump, pathArg) => {
|
|
4817
4824
|
try {
|
|
4818
4825
|
const dir = resolveSkillDir(pathArg);
|
|
4819
|
-
const skillMdPath =
|
|
4826
|
+
const skillMdPath = join12(dir, "SKILL.md");
|
|
4820
4827
|
if (!await pathExists(skillMdPath)) {
|
|
4821
4828
|
outputError("not_found", "No SKILL.md found. Run `agent-mesh skills init` first.");
|
|
4822
4829
|
}
|
|
@@ -4836,7 +4843,7 @@ function registerSkillsCommand(program2) {
|
|
|
4836
4843
|
try {
|
|
4837
4844
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4838
4845
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4839
|
-
const targetDir =
|
|
4846
|
+
const targetDir = join12(skillsDir, slug);
|
|
4840
4847
|
if (await pathExists(targetDir)) {
|
|
4841
4848
|
if (!opts.force) {
|
|
4842
4849
|
outputError("already_installed", `Skill "${slug}" is already installed at ${targetDir}. Use --force to overwrite.`);
|
|
@@ -4875,11 +4882,11 @@ function registerSkillsCommand(program2) {
|
|
|
4875
4882
|
const failed = [];
|
|
4876
4883
|
if (ref) {
|
|
4877
4884
|
const { authorLogin, slug } = parseSkillRef(ref);
|
|
4878
|
-
const targetDir =
|
|
4885
|
+
const targetDir = join12(skillsDir, slug);
|
|
4879
4886
|
if (!await pathExists(targetDir)) {
|
|
4880
4887
|
outputError("not_installed", `Skill "${slug}" is not installed. Use "skills install ${ref}" first.`);
|
|
4881
4888
|
}
|
|
4882
|
-
const skillMdPath =
|
|
4889
|
+
const skillMdPath = join12(targetDir, "SKILL.md");
|
|
4883
4890
|
let localVersion = "0.0.0";
|
|
4884
4891
|
if (await pathExists(skillMdPath)) {
|
|
4885
4892
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
@@ -4906,7 +4913,7 @@ function registerSkillsCommand(program2) {
|
|
|
4906
4913
|
for (const entry of entries) {
|
|
4907
4914
|
if (!entry.isDirectory()) continue;
|
|
4908
4915
|
const slug = entry.name;
|
|
4909
|
-
const skillMdPath =
|
|
4916
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4910
4917
|
if (!await pathExists(skillMdPath)) {
|
|
4911
4918
|
skipped.push({ slug, reason: "no_skill_md" });
|
|
4912
4919
|
continue;
|
|
@@ -4926,7 +4933,7 @@ function registerSkillsCommand(program2) {
|
|
|
4926
4933
|
skipped.push({ slug, reason: "up_to_date" });
|
|
4927
4934
|
} else {
|
|
4928
4935
|
slog.info(`Updating ${slug}: v${localVersion} \u2192 v${remoteVersion}...`);
|
|
4929
|
-
await rm(
|
|
4936
|
+
await rm(join12(skillsDir, slug), { recursive: true, force: true });
|
|
4930
4937
|
await downloadAndInstallSkill(client, authorLogin, slug, skillsDir);
|
|
4931
4938
|
updated.push({ slug, name: remote.name, old_version: localVersion, new_version: remoteVersion });
|
|
4932
4939
|
}
|
|
@@ -4947,13 +4954,13 @@ function registerSkillsCommand(program2) {
|
|
|
4947
4954
|
skills.command("remove <slug> [path]").description("Remove a locally installed skill").action(async (slug, pathArg) => {
|
|
4948
4955
|
try {
|
|
4949
4956
|
const { skillsDir, claudeSkillsDir } = await resolveSkillsRootAsync(pathArg);
|
|
4950
|
-
const targetDir =
|
|
4957
|
+
const targetDir = join12(skillsDir, slug);
|
|
4951
4958
|
if (!await pathExists(targetDir)) {
|
|
4952
4959
|
outputError("not_installed", `Skill "${slug}" is not installed at ${targetDir}`);
|
|
4953
4960
|
}
|
|
4954
4961
|
await rm(targetDir, { recursive: true, force: true });
|
|
4955
4962
|
try {
|
|
4956
|
-
await unlink(
|
|
4963
|
+
await unlink(join12(claudeSkillsDir, slug));
|
|
4957
4964
|
} catch {
|
|
4958
4965
|
}
|
|
4959
4966
|
slog.success(`Removed skill: ${slug}`);
|
|
@@ -4978,7 +4985,7 @@ function registerSkillsCommand(program2) {
|
|
|
4978
4985
|
for (const entry of entries) {
|
|
4979
4986
|
if (!entry.isDirectory()) continue;
|
|
4980
4987
|
const slug = entry.name;
|
|
4981
|
-
const skillMdPath =
|
|
4988
|
+
const skillMdPath = join12(skillsDir, slug, "SKILL.md");
|
|
4982
4989
|
if (!await pathExists(skillMdPath)) continue;
|
|
4983
4990
|
const raw = await readFile3(skillMdPath, "utf-8");
|
|
4984
4991
|
const { frontmatter } = parseSkillMd(raw);
|
|
@@ -5090,10 +5097,10 @@ function registerDiscoverCommand(program2) {
|
|
|
5090
5097
|
}
|
|
5091
5098
|
|
|
5092
5099
|
// src/commands/call.ts
|
|
5093
|
-
import { readFileSync as readFileSync3, writeFileSync as
|
|
5094
|
-
import { execSync as
|
|
5100
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync4, mkdirSync as mkdirSync7, copyFileSync as copyFileSync3, existsSync as existsSync8 } from "fs";
|
|
5101
|
+
import { execSync as execSync6 } from "child_process";
|
|
5095
5102
|
import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
|
|
5096
|
-
import { join as
|
|
5103
|
+
import { join as join13, basename as basename3 } from "path";
|
|
5097
5104
|
import { tmpdir as tmpdir2 } from "os";
|
|
5098
5105
|
var DEFAULT_BASE_URL4 = "https://agents.hot";
|
|
5099
5106
|
async function submitRating(baseUrl, token, agentId, callId, rating) {
|
|
@@ -5187,13 +5194,13 @@ async function webrtcDownload(agentId, offer, token, outputDir, json) {
|
|
|
5187
5194
|
receiver.waitForCompletion(3e4),
|
|
5188
5195
|
poll()
|
|
5189
5196
|
]);
|
|
5190
|
-
|
|
5191
|
-
const zipPath =
|
|
5192
|
-
|
|
5197
|
+
mkdirSync7(outputDir, { recursive: true });
|
|
5198
|
+
const zipPath = join13(outputDir, ".transfer.zip");
|
|
5199
|
+
writeFileSync4(zipPath, zipBuffer);
|
|
5193
5200
|
try {
|
|
5194
|
-
|
|
5201
|
+
execSync6(`unzip -o -q "${zipPath}" -d "${outputDir}"`);
|
|
5195
5202
|
try {
|
|
5196
|
-
|
|
5203
|
+
execSync6(`rm "${zipPath}"`);
|
|
5197
5204
|
} catch {
|
|
5198
5205
|
}
|
|
5199
5206
|
} catch {
|
|
@@ -5224,15 +5231,15 @@ async function webrtcDownload(agentId, offer, token, outputDir, json) {
|
|
|
5224
5231
|
}
|
|
5225
5232
|
function prepareFileForUpload(filePath) {
|
|
5226
5233
|
const fileName = basename3(filePath);
|
|
5227
|
-
const tempDir =
|
|
5228
|
-
|
|
5229
|
-
const tempFile =
|
|
5234
|
+
const tempDir = join13(tmpdir2(), `upload-${Date.now()}`);
|
|
5235
|
+
mkdirSync7(tempDir, { recursive: true });
|
|
5236
|
+
const tempFile = join13(tempDir, fileName);
|
|
5230
5237
|
copyFileSync3(filePath, tempFile);
|
|
5231
|
-
const zipPath =
|
|
5232
|
-
|
|
5238
|
+
const zipPath = join13(tempDir, "upload.zip");
|
|
5239
|
+
execSync6(`cd "${tempDir}" && zip -q "${zipPath}" "${fileName}"`);
|
|
5233
5240
|
const zipBuffer = readFileSync3(zipPath);
|
|
5234
5241
|
try {
|
|
5235
|
-
|
|
5242
|
+
execSync6(`rm -rf "${tempDir}"`);
|
|
5236
5243
|
} catch {
|
|
5237
5244
|
}
|
|
5238
5245
|
const zipSha256 = createHash3("sha256").update(zipBuffer).digest("hex");
|
|
@@ -5418,11 +5425,11 @@ async function asyncCall(opts) {
|
|
|
5418
5425
|
}
|
|
5419
5426
|
}
|
|
5420
5427
|
if (opts.outputFile && result) {
|
|
5421
|
-
|
|
5428
|
+
writeFileSync4(opts.outputFile, result);
|
|
5422
5429
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5423
5430
|
}
|
|
5424
5431
|
if (offer && opts.withFiles) {
|
|
5425
|
-
const outputDir = opts.outputFile ?
|
|
5432
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5426
5433
|
await webrtcDownload(opts.id, offer, opts.token, outputDir, opts.json);
|
|
5427
5434
|
}
|
|
5428
5435
|
if (!opts.json) {
|
|
@@ -5592,12 +5599,12 @@ Error: ${event.message}
|
|
|
5592
5599
|
}
|
|
5593
5600
|
}
|
|
5594
5601
|
if (opts.outputFile && outputBuffer) {
|
|
5595
|
-
|
|
5602
|
+
writeFileSync4(opts.outputFile, outputBuffer);
|
|
5596
5603
|
if (!opts.json) log.info(`Saved to ${opts.outputFile}`);
|
|
5597
5604
|
}
|
|
5598
5605
|
if (fileOffer && opts.withFiles) {
|
|
5599
5606
|
console.log("");
|
|
5600
|
-
const outputDir = opts.outputFile ?
|
|
5607
|
+
const outputDir = opts.outputFile ? join13(opts.outputFile, "..", "files") : join13(process.cwd(), "agent-output");
|
|
5601
5608
|
await webrtcDownload(opts.id, fileOffer, opts.token, outputDir, opts.json);
|
|
5602
5609
|
}
|
|
5603
5610
|
if (!opts.json) {
|
|
@@ -5634,7 +5641,6 @@ ${content}`;
|
|
|
5634
5641
|
let uploadOffer;
|
|
5635
5642
|
let uploadZipBuffer;
|
|
5636
5643
|
if (opts.uploadFile) {
|
|
5637
|
-
const { existsSync: existsSync8 } = __require("fs");
|
|
5638
5644
|
if (!existsSync8(opts.uploadFile)) {
|
|
5639
5645
|
log.error(`File not found: ${opts.uploadFile}`);
|
|
5640
5646
|
process.exit(1);
|