@annals/agent-mesh 0.16.8 → 0.16.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +152 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2985,6 +2985,7 @@ async function resolveAgentId(input, client) {
|
|
|
2985
2985
|
|
|
2986
2986
|
// src/commands/agents.ts
|
|
2987
2987
|
var SUPPORTED_AGENT_TYPES = ["claude"];
|
|
2988
|
+
var SUPPORTED_VISIBILITIES = ["public", "private"];
|
|
2988
2989
|
function normalizeAgentType(input) {
|
|
2989
2990
|
if (!input) return null;
|
|
2990
2991
|
const normalized = input.trim().toLowerCase();
|
|
@@ -3000,6 +3001,20 @@ function parseAgentTypeOrExit(input) {
|
|
|
3000
3001
|
log.error(`Invalid agent type: ${input}. Supported: ${SUPPORTED_AGENT_TYPES.join(", ")} (alias: claude-code).`);
|
|
3001
3002
|
process.exit(1);
|
|
3002
3003
|
}
|
|
3004
|
+
function normalizeVisibility(input) {
|
|
3005
|
+
if (!input) return null;
|
|
3006
|
+
const normalized = input.trim().toLowerCase();
|
|
3007
|
+
if (SUPPORTED_VISIBILITIES.includes(normalized)) {
|
|
3008
|
+
return normalized;
|
|
3009
|
+
}
|
|
3010
|
+
return null;
|
|
3011
|
+
}
|
|
3012
|
+
function parseVisibilityOrExit(input) {
|
|
3013
|
+
const visibility = normalizeVisibility(input);
|
|
3014
|
+
if (visibility) return visibility;
|
|
3015
|
+
log.error(`Invalid visibility: ${input}. Supported: ${SUPPORTED_VISIBILITIES.join(", ")}.`);
|
|
3016
|
+
process.exit(1);
|
|
3017
|
+
}
|
|
3003
3018
|
function readLine(prompt) {
|
|
3004
3019
|
const rl = createInterface3({ input: process.stdin, output: process.stderr });
|
|
3005
3020
|
return new Promise((resolve2) => {
|
|
@@ -3041,6 +3056,7 @@ function registerAgentsCommand(program2) {
|
|
|
3041
3056
|
[
|
|
3042
3057
|
{ key: "name", label: "NAME", width: 24 },
|
|
3043
3058
|
{ key: "type", label: "TYPE", width: 12 },
|
|
3059
|
+
{ key: "visibility", label: "VISIBILITY", width: 12 },
|
|
3044
3060
|
{ key: "status", label: "STATUS", width: 14 },
|
|
3045
3061
|
{ key: "published", label: "PUBLISHED", width: 12 },
|
|
3046
3062
|
{ key: "caps", label: "CAPABILITIES", width: 14 }
|
|
@@ -3048,6 +3064,7 @@ function registerAgentsCommand(program2) {
|
|
|
3048
3064
|
data.agents.map((a) => ({
|
|
3049
3065
|
name: a.name,
|
|
3050
3066
|
type: a.agent_type,
|
|
3067
|
+
visibility: a.visibility ?? "public",
|
|
3051
3068
|
status: formatStatus(a.is_online),
|
|
3052
3069
|
published: formatPublished(a.is_published),
|
|
3053
3070
|
caps: (a.capabilities?.length || 0).toString()
|
|
@@ -3058,10 +3075,11 @@ function registerAgentsCommand(program2) {
|
|
|
3058
3075
|
handleError(err);
|
|
3059
3076
|
}
|
|
3060
3077
|
});
|
|
3061
|
-
agents.command("create").description("Create a new agent").option("--name <name>", "Agent name").option("--type <type>", "Agent type (claude)", "claude").option("--description <desc>", "Agent description").action(async (opts) => {
|
|
3078
|
+
agents.command("create").description("Create a new agent").option("--name <name>", "Agent name").option("--type <type>", "Agent type (claude)", "claude").option("--description <desc>", "Agent description").option("--visibility <visibility>", "Agent visibility (public|private)", "public").action(async (opts) => {
|
|
3062
3079
|
try {
|
|
3063
3080
|
let { name, description } = opts;
|
|
3064
3081
|
const agentType = parseAgentTypeOrExit(opts.type);
|
|
3082
|
+
const visibility = parseVisibilityOrExit(opts.visibility);
|
|
3065
3083
|
if (!name && process.stdin.isTTY) {
|
|
3066
3084
|
log.banner("Create Agent");
|
|
3067
3085
|
name = await readLine("Agent name: ");
|
|
@@ -3081,7 +3099,8 @@ function registerAgentsCommand(program2) {
|
|
|
3081
3099
|
const result = await client.post("/api/developer/agents", {
|
|
3082
3100
|
name,
|
|
3083
3101
|
description: description || void 0,
|
|
3084
|
-
agent_type: agentType
|
|
3102
|
+
agent_type: agentType,
|
|
3103
|
+
visibility
|
|
3085
3104
|
});
|
|
3086
3105
|
const detail = await client.get(`/api/developer/agents/${result.agent.id}`);
|
|
3087
3106
|
log.success(`Agent created: ${BOLD}${detail.name}${RESET} (${detail.id})`);
|
|
@@ -3105,6 +3124,7 @@ function registerAgentsCommand(program2) {
|
|
|
3105
3124
|
console.log(` ${BOLD}${agent.name}${RESET}`);
|
|
3106
3125
|
console.log(` ${GRAY}ID${RESET} ${agent.id}`);
|
|
3107
3126
|
console.log(` ${GRAY}Type${RESET} ${agent.agent_type}`);
|
|
3127
|
+
console.log(` ${GRAY}Visibility${RESET} ${agent.visibility ?? "public"}`);
|
|
3108
3128
|
console.log(` ${GRAY}Status${RESET} ${formatStatus(agent.is_online)}`);
|
|
3109
3129
|
console.log(` ${GRAY}Published${RESET} ${formatPublished(agent.is_published)}`);
|
|
3110
3130
|
if (agent.capabilities?.length) {
|
|
@@ -3123,14 +3143,15 @@ function registerAgentsCommand(program2) {
|
|
|
3123
3143
|
handleError(err);
|
|
3124
3144
|
}
|
|
3125
3145
|
});
|
|
3126
|
-
agents.command("update <id-or-name>").description("Update an agent").option("--name <name>", "New name").option("--type <type>", "Agent type (claude)").option("--description <desc>", "Agent description").action(async (input, opts) => {
|
|
3146
|
+
agents.command("update <id-or-name>").description("Update an agent").option("--name <name>", "New name").option("--type <type>", "Agent type (claude)").option("--description <desc>", "Agent description").option("--visibility <visibility>", "Agent visibility (public|private)").action(async (input, opts) => {
|
|
3127
3147
|
try {
|
|
3128
3148
|
const updates = {};
|
|
3129
3149
|
if (opts.name !== void 0) updates.name = opts.name;
|
|
3130
3150
|
if (opts.type !== void 0) updates.agent_type = parseAgentTypeOrExit(opts.type);
|
|
3131
3151
|
if (opts.description !== void 0) updates.description = opts.description;
|
|
3152
|
+
if (opts.visibility !== void 0) updates.visibility = parseVisibilityOrExit(opts.visibility);
|
|
3132
3153
|
if (Object.keys(updates).length === 0) {
|
|
3133
|
-
log.error("No fields to update. Use --name, --type, --description.");
|
|
3154
|
+
log.error("No fields to update. Use --name, --type, --description, --visibility.");
|
|
3134
3155
|
process.exit(1);
|
|
3135
3156
|
}
|
|
3136
3157
|
const client = createClient();
|
|
@@ -3141,12 +3162,19 @@ function registerAgentsCommand(program2) {
|
|
|
3141
3162
|
handleError(err);
|
|
3142
3163
|
}
|
|
3143
3164
|
});
|
|
3144
|
-
agents.command("publish <id-or-name>").description("Publish agent to marketplace").action(async (input) => {
|
|
3165
|
+
agents.command("publish <id-or-name>").description("Publish agent to marketplace").option("--visibility <visibility>", "Set visibility before publishing (public|private)").action(async (input, opts) => {
|
|
3145
3166
|
try {
|
|
3146
3167
|
const client = createClient();
|
|
3147
3168
|
const { id, name } = await resolveAgentId(input, client);
|
|
3148
|
-
|
|
3169
|
+
const updates = { is_published: true };
|
|
3170
|
+
if (opts.visibility !== void 0) {
|
|
3171
|
+
updates.visibility = parseVisibilityOrExit(opts.visibility);
|
|
3172
|
+
}
|
|
3173
|
+
const result = await client.put(`/api/developer/agents/${id}`, updates);
|
|
3149
3174
|
log.success(`Agent published: ${BOLD}${name}${RESET}`);
|
|
3175
|
+
if (result.agent.visibility) {
|
|
3176
|
+
console.log(` Visibility: ${result.agent.visibility}`);
|
|
3177
|
+
}
|
|
3150
3178
|
console.log(` View at: ${GRAY}https://agents.hot${RESET}`);
|
|
3151
3179
|
} catch (err) {
|
|
3152
3180
|
handleError(err);
|
|
@@ -5200,9 +5228,127 @@ function registerProfileCommand(program2) {
|
|
|
5200
5228
|
});
|
|
5201
5229
|
}
|
|
5202
5230
|
|
|
5231
|
+
// src/utils/auto-updater.ts
|
|
5232
|
+
import { spawnSync } from "child_process";
|
|
5233
|
+
var AUTO_UPGRADE_ENV = "AGENT_MESH_AUTO_UPGRADE";
|
|
5234
|
+
var AUTO_UPGRADE_RELAUNCH_ENV = "AGENT_MESH_AUTO_UPGRADE_RELAUNCHED";
|
|
5235
|
+
var PACKAGE_NAME = "@annals/agent-mesh";
|
|
5236
|
+
var CHECK_TIMEOUT_MS = 5e3;
|
|
5237
|
+
var INSTALL_TIMEOUT_MS = 12e4;
|
|
5238
|
+
function isTruthyAutoUpgradeValue(raw) {
|
|
5239
|
+
if (!raw) return true;
|
|
5240
|
+
const value = raw.trim().toLowerCase();
|
|
5241
|
+
return value !== "0" && value !== "false" && value !== "off" && value !== "no";
|
|
5242
|
+
}
|
|
5243
|
+
function isAutoUpgradeEnabled(env = process.env) {
|
|
5244
|
+
return isTruthyAutoUpgradeValue(env[AUTO_UPGRADE_ENV]);
|
|
5245
|
+
}
|
|
5246
|
+
function parseSemver(input) {
|
|
5247
|
+
const normalized = input.trim().replace(/^v/, "");
|
|
5248
|
+
const match = normalized.match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/);
|
|
5249
|
+
if (!match) return null;
|
|
5250
|
+
const prerelease = match[4] ? match[4].split(".") : [];
|
|
5251
|
+
return {
|
|
5252
|
+
major: Number(match[1]),
|
|
5253
|
+
minor: Number(match[2]),
|
|
5254
|
+
patch: Number(match[3]),
|
|
5255
|
+
prerelease
|
|
5256
|
+
};
|
|
5257
|
+
}
|
|
5258
|
+
function comparePrerelease(a, b) {
|
|
5259
|
+
if (a.length === 0 && b.length === 0) return 0;
|
|
5260
|
+
if (a.length === 0) return 1;
|
|
5261
|
+
if (b.length === 0) return -1;
|
|
5262
|
+
const maxLen = Math.max(a.length, b.length);
|
|
5263
|
+
for (let i = 0; i < maxLen; i++) {
|
|
5264
|
+
const av = a[i];
|
|
5265
|
+
const bv = b[i];
|
|
5266
|
+
if (av === void 0) return -1;
|
|
5267
|
+
if (bv === void 0) return 1;
|
|
5268
|
+
if (av === bv) continue;
|
|
5269
|
+
const aNum = /^\d+$/.test(av) ? Number(av) : NaN;
|
|
5270
|
+
const bNum = /^\d+$/.test(bv) ? Number(bv) : NaN;
|
|
5271
|
+
const aIsNum = Number.isFinite(aNum);
|
|
5272
|
+
const bIsNum = Number.isFinite(bNum);
|
|
5273
|
+
if (aIsNum && bIsNum) return aNum < bNum ? -1 : 1;
|
|
5274
|
+
if (aIsNum && !bIsNum) return -1;
|
|
5275
|
+
if (!aIsNum && bIsNum) return 1;
|
|
5276
|
+
return av < bv ? -1 : 1;
|
|
5277
|
+
}
|
|
5278
|
+
return 0;
|
|
5279
|
+
}
|
|
5280
|
+
function compareSemver(a, b) {
|
|
5281
|
+
const pa = parseSemver(a);
|
|
5282
|
+
const pb = parseSemver(b);
|
|
5283
|
+
if (!pa || !pb) return 0;
|
|
5284
|
+
if (pa.major !== pb.major) return pa.major < pb.major ? -1 : 1;
|
|
5285
|
+
if (pa.minor !== pb.minor) return pa.minor < pb.minor ? -1 : 1;
|
|
5286
|
+
if (pa.patch !== pb.patch) return pa.patch < pb.patch ? -1 : 1;
|
|
5287
|
+
return comparePrerelease(pa.prerelease, pb.prerelease);
|
|
5288
|
+
}
|
|
5289
|
+
function parseLatestVersion(rawOutput) {
|
|
5290
|
+
const text = rawOutput.trim();
|
|
5291
|
+
if (!text) return null;
|
|
5292
|
+
try {
|
|
5293
|
+
const parsed = JSON.parse(text);
|
|
5294
|
+
return typeof parsed === "string" ? parsed.trim().replace(/^v/, "") : null;
|
|
5295
|
+
} catch {
|
|
5296
|
+
return text.replace(/^v/, "");
|
|
5297
|
+
}
|
|
5298
|
+
}
|
|
5299
|
+
function fetchLatestVersion(pkg) {
|
|
5300
|
+
const result = spawnSync("npm", ["view", pkg, "version", "--json"], {
|
|
5301
|
+
encoding: "utf-8",
|
|
5302
|
+
timeout: CHECK_TIMEOUT_MS
|
|
5303
|
+
});
|
|
5304
|
+
if (result.error || result.status !== 0) return null;
|
|
5305
|
+
return parseLatestVersion(result.stdout ?? "");
|
|
5306
|
+
}
|
|
5307
|
+
function installLatest(pkg) {
|
|
5308
|
+
const result = spawnSync("npm", ["install", "-g", `${pkg}@latest`], {
|
|
5309
|
+
stdio: "inherit",
|
|
5310
|
+
timeout: INSTALL_TIMEOUT_MS
|
|
5311
|
+
});
|
|
5312
|
+
return !result.error && result.status === 0;
|
|
5313
|
+
}
|
|
5314
|
+
function relaunchCommand(env, execPath, argv) {
|
|
5315
|
+
const child = spawnSync(execPath, argv.slice(1), {
|
|
5316
|
+
stdio: "inherit",
|
|
5317
|
+
env: { ...env, [AUTO_UPGRADE_RELAUNCH_ENV]: "1" }
|
|
5318
|
+
});
|
|
5319
|
+
if (child.error) {
|
|
5320
|
+
log.warn(`Auto-upgrade succeeded, but relaunch failed: ${child.error.message}`);
|
|
5321
|
+
return { relaunched: false };
|
|
5322
|
+
}
|
|
5323
|
+
return { relaunched: true, exitCode: child.status ?? 0 };
|
|
5324
|
+
}
|
|
5325
|
+
function maybeAutoUpgradeOnStartup(opts) {
|
|
5326
|
+
const env = opts.env ?? process.env;
|
|
5327
|
+
const argv = opts.argv ?? process.argv;
|
|
5328
|
+
const execPath = opts.execPath ?? process.execPath;
|
|
5329
|
+
const packageName = opts.packageName ?? PACKAGE_NAME;
|
|
5330
|
+
if (!isAutoUpgradeEnabled(env)) return { relaunched: false };
|
|
5331
|
+
if (env[AUTO_UPGRADE_RELAUNCH_ENV] === "1") return { relaunched: false };
|
|
5332
|
+
const current = opts.currentVersion.trim().replace(/^v/, "");
|
|
5333
|
+
const latest = fetchLatestVersion(packageName);
|
|
5334
|
+
if (!latest) return { relaunched: false };
|
|
5335
|
+
if (compareSemver(latest, current) <= 0) return { relaunched: false };
|
|
5336
|
+
log.info(`New ${packageName} version found: v${current} -> v${latest}. Upgrading...`);
|
|
5337
|
+
if (!installLatest(packageName)) {
|
|
5338
|
+
log.warn("Auto-upgrade failed. Continuing with current version.");
|
|
5339
|
+
return { relaunched: false };
|
|
5340
|
+
}
|
|
5341
|
+
log.success(`Upgraded to v${latest}. Restarting command...`);
|
|
5342
|
+
return relaunchCommand(env, execPath, argv);
|
|
5343
|
+
}
|
|
5344
|
+
|
|
5203
5345
|
// src/index.ts
|
|
5204
5346
|
var require2 = createRequire(import.meta.url);
|
|
5205
5347
|
var { version } = require2("../package.json");
|
|
5348
|
+
var autoUpgrade = maybeAutoUpgradeOnStartup({ currentVersion: version });
|
|
5349
|
+
if (autoUpgrade.relaunched) {
|
|
5350
|
+
process.exit(autoUpgrade.exitCode ?? 0);
|
|
5351
|
+
}
|
|
5206
5352
|
program.name("agent-mesh").description("Connect local AI agents to the Agents.Hot platform").version(version).option("-v", "output the version number").on("option:v", () => {
|
|
5207
5353
|
console.log(version);
|
|
5208
5354
|
process.exit(0);
|