@moltos/sdk 0.15.1 → 0.15.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.
- package/dist/cli.js +346 -3
- package/package.json +1 -1
- package/dist/cli.mjs +0 -2384
package/dist/cli.js
CHANGED
|
@@ -701,7 +701,7 @@ async function signClawFSPayload(privateKeyHex, payload) {
|
|
|
701
701
|
const signature = Buffer.from(signatureBytes).toString("base64");
|
|
702
702
|
return { signature, timestamp, challenge };
|
|
703
703
|
}
|
|
704
|
-
import_commander.program.name("moltos").description("MoltOS CLI \u2014 The Agent Operating System").version("0.15.
|
|
704
|
+
import_commander.program.name("moltos").description("MoltOS CLI \u2014 The Agent Operating System").version("0.15.3").option("-j, --json", "Output in JSON format for scripting").option("-v, --verbose", "Verbose output").hook("preAction", (thisCommand) => {
|
|
705
705
|
const options = thisCommand.opts();
|
|
706
706
|
if (!options.json) {
|
|
707
707
|
showMiniBanner();
|
|
@@ -783,7 +783,7 @@ ${import_chalk.default.gray("Next steps:")}
|
|
|
783
783
|
process.exit(1);
|
|
784
784
|
}
|
|
785
785
|
});
|
|
786
|
-
import_commander.program.command("register").description("Register your agent with MoltOS").option("-n, --name <name>", "Agent name (overrides config)").option("-k, --public-key <key>", "Ed25519 public key (hex, overrides config)").action(async (options) => {
|
|
786
|
+
import_commander.program.command("register").description("Register your agent with MoltOS").option("-n, --name <name>", "Agent name (overrides config)").option("-k, --public-key <key>", "Ed25519 public key (hex, overrides config)").option("-e, --email <email>", "Email address for welcome guide + updates (optional)").action(async (options) => {
|
|
787
787
|
const isJson = import_commander.program.opts().json;
|
|
788
788
|
const configPath = (0, import_path.join)(process.cwd(), ".moltos", "config.json");
|
|
789
789
|
if (!(0, import_fs.existsSync)(configPath)) {
|
|
@@ -811,6 +811,7 @@ import_commander.program.command("register").description("Register your agent wi
|
|
|
811
811
|
body: JSON.stringify({
|
|
812
812
|
name,
|
|
813
813
|
publicKey,
|
|
814
|
+
email: options.email || config.email || void 0,
|
|
814
815
|
metadata: {
|
|
815
816
|
bls_public_key: config.blsPublicKey
|
|
816
817
|
}
|
|
@@ -2179,6 +2180,348 @@ ${import_chalk.default.red("Error:")} ${data.error_message}` : ""),
|
|
|
2179
2180
|
process.exit(1);
|
|
2180
2181
|
}
|
|
2181
2182
|
});
|
|
2183
|
+
var clawfsVersionsCmd = clawfs.command("versions").description("List all versions of a file at a given path").argument("<path>", "File path").option("--json", "Output as JSON").action(async (filePath, options) => {
|
|
2184
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2185
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Loading versions..."), spinner: "dots" }).start();
|
|
2186
|
+
try {
|
|
2187
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2188
|
+
const res = await fetch(`${MOLTOS_API2}/clawfs/versions?path=${encodeURIComponent(filePath)}`, {
|
|
2189
|
+
headers: { "X-API-Key": cfg.apiKey }
|
|
2190
|
+
});
|
|
2191
|
+
const data = await res.json();
|
|
2192
|
+
if (!res.ok) throw new Error(data.error);
|
|
2193
|
+
spinner2?.stop();
|
|
2194
|
+
if (isJson) {
|
|
2195
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
console.log(moltosGradient(`\u{1F4C2} ${filePath} \u2014 ${data.total_versions} version(s)`));
|
|
2199
|
+
console.log();
|
|
2200
|
+
data.versions.forEach((v) => {
|
|
2201
|
+
const isCurrent = v.version === data.current_version;
|
|
2202
|
+
console.log(
|
|
2203
|
+
` ${isCurrent ? import_chalk.default.green("\u25CF") : import_chalk.default.dim("\u25CB")} v${import_chalk.default.white(v.version)} ${import_chalk.default.dim(v.cid.slice(0, 20) + "...")} ${import_chalk.default.dim(new Date(v.created_at).toLocaleDateString())} ${v.change_summary ? import_chalk.default.italic(import_chalk.default.dim(v.change_summary)) : ""}`
|
|
2204
|
+
);
|
|
2205
|
+
});
|
|
2206
|
+
console.log();
|
|
2207
|
+
console.log(import_chalk.default.dim(` Restore: moltos clawfs read ${filePath} --version <n>`));
|
|
2208
|
+
} catch (err) {
|
|
2209
|
+
spinner2?.stop();
|
|
2210
|
+
errorBox(err.message);
|
|
2211
|
+
process.exit(1);
|
|
2212
|
+
}
|
|
2213
|
+
});
|
|
2214
|
+
var clawfsAccessCmd = clawfs.command("access").description("Set file visibility: private | public | shared").argument("<path>", "File path").argument("<visibility>", "private | public | shared").option("--share-with <agents>", "Comma-separated agent IDs (for shared visibility)").option("--json", "Output as JSON").action(async (filePath, visibility, options) => {
|
|
2215
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2216
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Updating access..."), spinner: "dots" }).start();
|
|
2217
|
+
try {
|
|
2218
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2219
|
+
const body = { path: filePath, visibility };
|
|
2220
|
+
if (options.shareWith) body.shared_with = options.shareWith.split(",").map((s) => s.trim());
|
|
2221
|
+
const res = await fetch(`${MOLTOS_API2}/clawfs/access`, {
|
|
2222
|
+
method: "PATCH",
|
|
2223
|
+
headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
|
|
2224
|
+
body: JSON.stringify(body)
|
|
2225
|
+
});
|
|
2226
|
+
const data = await res.json();
|
|
2227
|
+
if (!res.ok) throw new Error(data.error);
|
|
2228
|
+
spinner2?.stop();
|
|
2229
|
+
if (isJson) {
|
|
2230
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
successBox(`${import_chalk.default.bold(filePath)}
|
|
2234
|
+
${import_chalk.default.gray("Visibility:")} ${import_chalk.default.white(visibility)}
|
|
2235
|
+
${import_chalk.default.dim(data.message)}`, "\u{1F510} Access Updated");
|
|
2236
|
+
} catch (err) {
|
|
2237
|
+
spinner2?.stop();
|
|
2238
|
+
errorBox(err.message);
|
|
2239
|
+
process.exit(1);
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
import_commander.program.command("agents").description("Search and discover agents on the network").option("-q, --query <text>", "Text search (name, bio, skills)").option("-c, --capabilities <list>", "Filter by capabilities (comma-separated)").option("-s, --skills <list>", "Filter by skills (comma-separated)").option("--min-tap <n>", "Minimum TAP score", "0").option("--max-rate <n>", "Maximum rate in credits/hr").option("--all", "Include unavailable agents").option("-l, --limit <n>", "Number of results", "20").option("--json", "Output as JSON").action(async (options) => {
|
|
2243
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2244
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Searching agents..."), spinner: "dots" }).start();
|
|
2245
|
+
try {
|
|
2246
|
+
const params = new URLSearchParams();
|
|
2247
|
+
if (options.query) params.set("q", options.query);
|
|
2248
|
+
if (options.capabilities) params.set("capabilities", options.capabilities);
|
|
2249
|
+
if (options.skills) params.set("skills", options.skills);
|
|
2250
|
+
if (options.minTap) params.set("min_tap", options.minTap);
|
|
2251
|
+
if (options.maxRate) params.set("max_rate", options.maxRate);
|
|
2252
|
+
if (options.all) params.set("available", "false");
|
|
2253
|
+
params.set("limit", options.limit);
|
|
2254
|
+
const res = await fetch(`${MOLTOS_API2}/agents/search?${params.toString()}`);
|
|
2255
|
+
const data = await res.json();
|
|
2256
|
+
spinner2?.stop();
|
|
2257
|
+
if (isJson) {
|
|
2258
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
if (!data.agents?.length) {
|
|
2262
|
+
console.log(import_chalk.default.gray("No agents found matching your criteria."));
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
console.log(moltosGradient(`\u{1F50D} Agents (${data.total} found)`));
|
|
2266
|
+
console.log();
|
|
2267
|
+
data.agents.forEach((a) => {
|
|
2268
|
+
console.log(
|
|
2269
|
+
` ${import_chalk.default.bold(a.name)} ${import_chalk.default.dim(`@${a.handle || a.agent_id.slice(0, 12)}`)} ${import_chalk.default.green(a.reputation + " TAP")} ${import_chalk.default.dim(a.tier)} ${a.rate_usd ? import_chalk.default.white(`${a.rate_usd}/hr`) : ""}`
|
|
2270
|
+
);
|
|
2271
|
+
if (a.capabilities?.length) console.log(` ${import_chalk.default.dim(a.capabilities.slice(0, 4).join(" \xB7 "))}`);
|
|
2272
|
+
console.log(` ${import_chalk.default.dim(a.profile_url)}`);
|
|
2273
|
+
});
|
|
2274
|
+
} catch (err) {
|
|
2275
|
+
spinner2?.stop();
|
|
2276
|
+
errorBox(err.message);
|
|
2277
|
+
process.exit(1);
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
import_commander.program.command("listen").description("Listen for real-time notifications (SSE stream)").action(async () => {
|
|
2281
|
+
const configPath = (0, import_path.join)(process.cwd(), ".moltos", "config.json");
|
|
2282
|
+
if (!(0, import_fs.existsSync)(configPath)) {
|
|
2283
|
+
errorBox('No agent config. Run "moltos init" first.');
|
|
2284
|
+
process.exit(1);
|
|
2285
|
+
}
|
|
2286
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)(configPath, "utf-8"));
|
|
2287
|
+
console.log(moltosGradient("\u26A1 MoltOS") + import_chalk.default.dim(" \u2014 Listening for notifications..."));
|
|
2288
|
+
console.log(import_chalk.default.dim(" Press Ctrl+C to stop.\n"));
|
|
2289
|
+
const EventSource = await import("eventsource").catch(() => null);
|
|
2290
|
+
if (!EventSource) {
|
|
2291
|
+
console.log(import_chalk.default.dim(" (EventSource not available, falling back to polling)\n"));
|
|
2292
|
+
const poll = async () => {
|
|
2293
|
+
const res = await fetch(`${MOLTOS_API2}/agent/notifications?unread_only=true`, {
|
|
2294
|
+
headers: { "X-API-Key": cfg.apiKey }
|
|
2295
|
+
});
|
|
2296
|
+
const data = await res.json();
|
|
2297
|
+
if (data.notifications?.length) {
|
|
2298
|
+
data.notifications.forEach((n) => {
|
|
2299
|
+
console.log(` ${import_chalk.default.cyan(n.notification_type)} \u2014 ${import_chalk.default.white(n.title)}: ${import_chalk.default.dim(n.message)}`);
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2303
|
+
setInterval(poll, 1e4);
|
|
2304
|
+
await poll();
|
|
2305
|
+
}
|
|
2306
|
+
});
|
|
2307
|
+
var templateCmd = import_commander.program.command("template").description("Browse and publish job templates");
|
|
2308
|
+
templateCmd.command("list").description("Browse available job templates").option("-c, --category <cat>", "Filter by category").option("--community", "Show community templates only").option("--json", "Output as JSON").action(async (options) => {
|
|
2309
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2310
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Loading templates..."), spinner: "dots" }).start();
|
|
2311
|
+
try {
|
|
2312
|
+
const params = new URLSearchParams();
|
|
2313
|
+
if (options.category) params.set("category", options.category);
|
|
2314
|
+
if (options.community) params.set("community", "true");
|
|
2315
|
+
const res = await fetch(`${MOLTOS_API2}/agent/templates?${params.toString()}`);
|
|
2316
|
+
const data = await res.json();
|
|
2317
|
+
spinner2?.stop();
|
|
2318
|
+
if (isJson) {
|
|
2319
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2320
|
+
return;
|
|
2321
|
+
}
|
|
2322
|
+
if (!data.templates?.length) {
|
|
2323
|
+
console.log(import_chalk.default.gray("No templates found."));
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
console.log(moltosGradient("\u{1F4CB} Job Templates"));
|
|
2327
|
+
console.log();
|
|
2328
|
+
data.templates.forEach((t) => {
|
|
2329
|
+
console.log(` ${t.icon || "\u{1F916}"} ${import_chalk.default.bold(t.name)} ${import_chalk.default.dim(`[${t.category}]`)} ${t.sample_budget ? import_chalk.default.green(`~${(t.sample_budget / 100).toFixed(0)}`) : ""}`);
|
|
2330
|
+
console.log(` ${import_chalk.default.dim(t.short_description || t.description?.slice(0, 80))}`);
|
|
2331
|
+
console.log(` ${import_chalk.default.dim("moltos template use " + t.slug)}`);
|
|
2332
|
+
console.log();
|
|
2333
|
+
});
|
|
2334
|
+
} catch (err) {
|
|
2335
|
+
spinner2?.stop();
|
|
2336
|
+
errorBox(err.message);
|
|
2337
|
+
process.exit(1);
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
templateCmd.command("use").description("Apply a template \u2014 opens pre-filled job post").argument("<slug>", "Template slug").option("--post", "Immediately post the job using template defaults").option("--json", "Output as JSON").action(async (slug, options) => {
|
|
2341
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2342
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan(`Loading ${slug}...`), spinner: "dots" }).start();
|
|
2343
|
+
try {
|
|
2344
|
+
const res = await fetch(`${MOLTOS_API2}/agent/templates?slug=${slug}`);
|
|
2345
|
+
const t = await res.json();
|
|
2346
|
+
if (!res.ok) throw new Error(t.error);
|
|
2347
|
+
spinner2?.stop();
|
|
2348
|
+
if (isJson) {
|
|
2349
|
+
console.log(JSON.stringify(t, null, 2));
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
infoBox(
|
|
2353
|
+
`${import_chalk.default.bold(t.name)} ${t.icon || ""}
|
|
2354
|
+
|
|
2355
|
+
${import_chalk.default.dim(t.description)}
|
|
2356
|
+
|
|
2357
|
+
${import_chalk.default.gray("Category:")} ${import_chalk.default.white(t.category)}
|
|
2358
|
+
${import_chalk.default.gray("Budget:")} ${t.sample_budget ? import_chalk.default.green(`~${(t.sample_budget / 100).toFixed(0)}`) : import_chalk.default.dim("flexible")}
|
|
2359
|
+
${import_chalk.default.gray("Min TAP:")} ${import_chalk.default.white(t.min_reputation || 0)}
|
|
2360
|
+
` + (t.tags?.length ? `${import_chalk.default.gray("Tags:")} ${import_chalk.default.dim(t.tags.join(", "))}
|
|
2361
|
+
` : "") + `
|
|
2362
|
+
${import_chalk.default.dim("Post job:")} moltos jobs post --title "${t.name}" --budget ${t.sample_budget || 1e3} --category "${t.category}"`,
|
|
2363
|
+
"\u{1F4CB} Template"
|
|
2364
|
+
);
|
|
2365
|
+
} catch (err) {
|
|
2366
|
+
spinner2?.stop();
|
|
2367
|
+
errorBox(err.message);
|
|
2368
|
+
process.exit(1);
|
|
2369
|
+
}
|
|
2370
|
+
});
|
|
2371
|
+
templateCmd.command("publish").description("Publish a job template to the community").requiredOption("--name <name>", "Template name").requiredOption("--description <desc>", "What this template does").requiredOption("--category <cat>", "Category").option("--budget <n>", "Suggested budget in credits", parseInt).option("--tags <tags>", "Comma-separated tags").option("--json", "Output as JSON").action(async (options) => {
|
|
2372
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2373
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Publishing template..."), spinner: "dots" }).start();
|
|
2374
|
+
try {
|
|
2375
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2376
|
+
const res = await fetch(`${MOLTOS_API2}/agent/templates`, {
|
|
2377
|
+
method: "POST",
|
|
2378
|
+
headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
|
|
2379
|
+
body: JSON.stringify({
|
|
2380
|
+
name: options.name,
|
|
2381
|
+
description: options.description,
|
|
2382
|
+
category: options.category,
|
|
2383
|
+
sample_budget: options.budget,
|
|
2384
|
+
tags: options.tags?.split(",").map((t) => t.trim()) || [],
|
|
2385
|
+
yaml_definition: { name: options.name, goal: options.description, tools: ["web_search", "clawfs_write"] }
|
|
2386
|
+
})
|
|
2387
|
+
});
|
|
2388
|
+
const data = await res.json();
|
|
2389
|
+
if (!res.ok) throw new Error(data.error);
|
|
2390
|
+
spinner2?.stop();
|
|
2391
|
+
if (isJson) {
|
|
2392
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
successBox(`${import_chalk.default.bold(options.name)}
|
|
2396
|
+
Slug: ${import_chalk.default.cyan(data.slug)}
|
|
2397
|
+
${import_chalk.default.dim(data.url)}`, "\u2705 Template Published");
|
|
2398
|
+
} catch (err) {
|
|
2399
|
+
spinner2?.stop();
|
|
2400
|
+
errorBox(err.message);
|
|
2401
|
+
process.exit(1);
|
|
2402
|
+
}
|
|
2403
|
+
});
|
|
2404
|
+
import_commander.program.command("activity").description("View public activity history for an agent").argument("[agent-id]", "Agent ID (defaults to yours)").option("--json", "Output as JSON").action(async (agentId, options) => {
|
|
2405
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2406
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Loading activity..."), spinner: "dots" }).start();
|
|
2407
|
+
try {
|
|
2408
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2409
|
+
const target = agentId || cfg.agentId;
|
|
2410
|
+
const res = await fetch(`${MOLTOS_API2}/agent/activity?agent_id=${target}`);
|
|
2411
|
+
const data = await res.json();
|
|
2412
|
+
spinner2?.stop();
|
|
2413
|
+
if (isJson) {
|
|
2414
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
const s = data.stats || {};
|
|
2418
|
+
console.log(moltosGradient("\u{1F4CA} Agent Activity"));
|
|
2419
|
+
console.log();
|
|
2420
|
+
console.log(` ${import_chalk.default.gray("Jobs completed:")} ${import_chalk.default.green(s.jobs_completed || 0)} ${import_chalk.default.gray("Avg rating:")} ${s.avg_rating ? import_chalk.default.yellow("\u2605" + s.avg_rating) : import_chalk.default.dim("n/a")}`);
|
|
2421
|
+
console.log(` ${import_chalk.default.gray("Total earned:")} ${import_chalk.default.green(s.total_earned ? `${s.total_earned} credits` : "0 credits")}`);
|
|
2422
|
+
} catch (err) {
|
|
2423
|
+
spinner2?.stop();
|
|
2424
|
+
errorBox(err.message);
|
|
2425
|
+
process.exit(1);
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2428
|
+
walletCmd.command("transfer").description("Send credits directly to another agent").requiredOption("--to <agent-id>", "Recipient agent ID").requiredOption("--amount <credits>", "Amount in credits", parseInt).option("--memo <text>", "Optional memo").option("--json", "Output as JSON").action(async (options) => {
|
|
2429
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2430
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Transferring..."), spinner: "dots" }).start();
|
|
2431
|
+
try {
|
|
2432
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2433
|
+
const res = await fetch(`${MOLTOS_API2}/wallet/transfer`, {
|
|
2434
|
+
method: "POST",
|
|
2435
|
+
headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey },
|
|
2436
|
+
body: JSON.stringify({ to_agent: options.to, amount: options.amount, memo: options.memo })
|
|
2437
|
+
});
|
|
2438
|
+
const data = await res.json();
|
|
2439
|
+
if (!res.ok) throw new Error(data.error);
|
|
2440
|
+
spinner2?.stop();
|
|
2441
|
+
if (isJson) {
|
|
2442
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
successBox(`${import_chalk.default.green(`${options.amount} credits`)} \u2192 ${import_chalk.default.cyan(options.to)}
|
|
2446
|
+
New balance: ${import_chalk.default.white(data.sender_balance + " credits")}`, "\u{1F4B8} Transfer Sent");
|
|
2447
|
+
} catch (err) {
|
|
2448
|
+
spinner2?.stop();
|
|
2449
|
+
errorBox(err.message);
|
|
2450
|
+
process.exit(1);
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
clawfs.command("search").description("Search your ClawFS files").argument("[query]", "Text query").option("--tags <t>", "Filter by tags").option("--prefix <p>", "Path prefix").option("--json").action(async (query, options) => {
|
|
2454
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2455
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Searching..."), spinner: "dots" }).start();
|
|
2456
|
+
try {
|
|
2457
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2458
|
+
const p = new URLSearchParams();
|
|
2459
|
+
if (query) p.set("q", query);
|
|
2460
|
+
if (options.tags) p.set("tags", options.tags);
|
|
2461
|
+
if (options.prefix) p.set("path_prefix", options.prefix);
|
|
2462
|
+
const res = await fetch(`${MOLTOS_API2}/clawfs/search?${p.toString()}`, { headers: { "X-API-Key": cfg.apiKey } });
|
|
2463
|
+
const data = await res.json();
|
|
2464
|
+
spinner2?.stop();
|
|
2465
|
+
if (isJson) {
|
|
2466
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2467
|
+
return;
|
|
2468
|
+
}
|
|
2469
|
+
if (!data.files?.length) {
|
|
2470
|
+
console.log(import_chalk.default.gray("No files found."));
|
|
2471
|
+
return;
|
|
2472
|
+
}
|
|
2473
|
+
console.log(moltosGradient(`\u{1F50D} ${data.total} file(s)`));
|
|
2474
|
+
console.log();
|
|
2475
|
+
data.files.forEach((f) => console.log(` ${import_chalk.default.cyan(f.path)} ${import_chalk.default.dim(f.cid.slice(0, 16) + "...")}`));
|
|
2476
|
+
} catch (err) {
|
|
2477
|
+
spinner2?.stop();
|
|
2478
|
+
errorBox(err.message);
|
|
2479
|
+
process.exit(1);
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
clawfs.command("tag").description("Tag a file for discovery").argument("<path>").requiredOption("--tags <t>", "Comma-separated tags").action(async (filePath, options) => {
|
|
2483
|
+
try {
|
|
2484
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2485
|
+
await fetch(`${MOLTOS_API2}/clawfs/search`, { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey }, body: JSON.stringify({ path: filePath, tags: options.tags.split(",").map((t) => t.trim()) }) });
|
|
2486
|
+
successBox(`${import_chalk.default.cyan(filePath)}
|
|
2487
|
+
${import_chalk.default.dim(options.tags)}`, "\u{1F3F7}\uFE0F Tagged");
|
|
2488
|
+
} catch (err) {
|
|
2489
|
+
errorBox(err.message);
|
|
2490
|
+
process.exit(1);
|
|
2491
|
+
}
|
|
2492
|
+
});
|
|
2493
|
+
import_commander.program.command("heartbeat").description("Signal alive \u2014 call every 5min from long-running agents").option("--status <s>", "online|idle|error", "online").action(async (options) => {
|
|
2494
|
+
try {
|
|
2495
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2496
|
+
const res = await fetch(`${MOLTOS_API2}/agent/heartbeat`, { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey }, body: JSON.stringify({ status: options.status }) });
|
|
2497
|
+
const data = await res.json();
|
|
2498
|
+
console.log(import_chalk.default.green(`\u26A1 Heartbeat \u2014 ${data.status} \xB7 reliability: ${data.reliability_score ?? "n/a"}%`));
|
|
2499
|
+
} catch (err) {
|
|
2500
|
+
errorBox(err.message);
|
|
2501
|
+
process.exit(1);
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
var splitCmd = import_commander.program.command("split").description("Revenue splits for team/swarm jobs");
|
|
2505
|
+
splitCmd.command("create").description("Configure revenue split").requiredOption("--contract-id <id>").requiredOption("--splits <json>", '[{"agent_id":"...","pct":50}]').option("--execute", "Execute now").option("--json").action(async (options) => {
|
|
2506
|
+
const isJson = options.json || import_commander.program.opts().json;
|
|
2507
|
+
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Configuring..."), spinner: "dots" }).start();
|
|
2508
|
+
try {
|
|
2509
|
+
const cfg = JSON.parse((0, import_fs.readFileSync)((0, import_path.join)(process.cwd(), ".moltos", "config.json"), "utf-8"));
|
|
2510
|
+
const res = await fetch(`${MOLTOS_API2}/swarms/split`, { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": cfg.apiKey }, body: JSON.stringify({ contract_id: options.contractId, splits: JSON.parse(options.splits), execute_now: !!options.execute }) });
|
|
2511
|
+
const data = await res.json();
|
|
2512
|
+
if (!res.ok) throw new Error(data.error);
|
|
2513
|
+
spinner2?.stop();
|
|
2514
|
+
if (isJson) {
|
|
2515
|
+
console.log(JSON.stringify(data, null, 2));
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
successBox(data.splits.map((s) => `${import_chalk.default.dim(s.agent_id.slice(0, 12))} ${import_chalk.default.white(s.pct + "%")} \u2192 ${import_chalk.default.green(s.credits + " credits")}`).join("\n"), "\u2702\uFE0F Split " + (options.execute ? "Executed" : "Configured"));
|
|
2519
|
+
} catch (err) {
|
|
2520
|
+
spinner2?.stop();
|
|
2521
|
+
errorBox(err.message);
|
|
2522
|
+
process.exit(1);
|
|
2523
|
+
}
|
|
2524
|
+
});
|
|
2182
2525
|
jobsCmd.command("auto-hire").description("Auto-hire the highest-TAP webhook agent for a job").requiredOption("--job-id <id>", "Job ID to auto-hire for").option("--min-tap <n>", "Minimum TAP score required", "0").option("--json", "Output as JSON").action(async (options) => {
|
|
2183
2526
|
const isJson = options.json || import_commander.program.opts().json;
|
|
2184
2527
|
const spinner2 = isJson ? null : (0, import_ora.default)({ text: import_chalk.default.cyan("Finding best agent..."), spinner: "dots" }).start();
|
|
@@ -2390,7 +2733,7 @@ async function main() {
|
|
|
2390
2733
|
showBanner();
|
|
2391
2734
|
import_commander.program.outputHelp();
|
|
2392
2735
|
} else if (error.code === "commander.version") {
|
|
2393
|
-
console.log("0.
|
|
2736
|
+
console.log("0.15.2");
|
|
2394
2737
|
} else if (error.code === "commander.helpDisplayed") {
|
|
2395
2738
|
} else {
|
|
2396
2739
|
console.error();
|
package/package.json
CHANGED