open-agents-ai 0.140.2 → 0.140.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/index.js +82 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42320,6 +42320,88 @@ async function handleSlashCommand(input, ctx) {
|
|
|
42320
42320
|
}
|
|
42321
42321
|
return "handled";
|
|
42322
42322
|
}
|
|
42323
|
+
if (ipfsAction === "share") {
|
|
42324
|
+
const shareType = ipfsSubCmd[1]?.toLowerCase() || "";
|
|
42325
|
+
const shareName = ipfsSubCmd.slice(2).join(" ").trim();
|
|
42326
|
+
if (!shareType || !shareName) {
|
|
42327
|
+
renderInfo("Usage: /ipfs share tool <name> | /ipfs share skill <name>");
|
|
42328
|
+
return "handled";
|
|
42329
|
+
}
|
|
42330
|
+
let content = "";
|
|
42331
|
+
let metadata = {};
|
|
42332
|
+
if (shareType === "tool") {
|
|
42333
|
+
const toolDir = join51(ctx.repoRoot, ".oa", "tools");
|
|
42334
|
+
const toolFile = join51(toolDir, shareName.endsWith(".json") ? shareName : `${shareName}.json`);
|
|
42335
|
+
if (!existsSync36(toolFile)) {
|
|
42336
|
+
renderWarning(`Tool not found: ${toolFile}`);
|
|
42337
|
+
return "handled";
|
|
42338
|
+
}
|
|
42339
|
+
content = readFileSync25(toolFile, "utf8");
|
|
42340
|
+
metadata = { type: "tool", name: shareName };
|
|
42341
|
+
} else if (shareType === "skill") {
|
|
42342
|
+
const skillDir = join51(ctx.repoRoot, ".oa", "skills", shareName);
|
|
42343
|
+
const skillFile = join51(skillDir, "SKILL.md");
|
|
42344
|
+
if (!existsSync36(skillFile)) {
|
|
42345
|
+
renderWarning(`Skill not found: ${skillFile}`);
|
|
42346
|
+
return "handled";
|
|
42347
|
+
}
|
|
42348
|
+
content = readFileSync25(skillFile, "utf8");
|
|
42349
|
+
metadata = { type: "skill", name: shareName };
|
|
42350
|
+
} else {
|
|
42351
|
+
renderWarning(`Unknown share type: ${shareType}. Use 'tool' or 'skill'.`);
|
|
42352
|
+
return "handled";
|
|
42353
|
+
}
|
|
42354
|
+
content = content.replace(/["']?api[_-]?key["']?\s*[:=]\s*["'][^"']*["']/gi, '"api_key": "[REDACTED]"').replace(/["']?secret["']?\s*[:=]\s*["'][^"']*["']/gi, '"secret": "[REDACTED]"').replace(/["']?password["']?\s*[:=]\s*["'][^"']*["']/gi, '"password": "[REDACTED]"').replace(/["']?token["']?\s*[:=]\s*["'][^"']*["']/gi, '"token": "[REDACTED]"').replace(/Bearer\s+[A-Za-z0-9._-]+/g, "Bearer [REDACTED]");
|
|
42355
|
+
const payload = JSON.stringify({ ...metadata, content, sharedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
42356
|
+
try {
|
|
42357
|
+
const { NexusTool: NexusTool2 } = __require("@open-agents/execution");
|
|
42358
|
+
const nexus = new NexusTool2(ctx.repoRoot);
|
|
42359
|
+
const result = await nexus.execute({ action: "ipfs_add", content: payload });
|
|
42360
|
+
if (result.success) {
|
|
42361
|
+
const data = JSON.parse(result.output);
|
|
42362
|
+
safeLog(`
|
|
42363
|
+
${c2.bold("Shared to IPFS")}`);
|
|
42364
|
+
safeLog(` Type: ${shareType}`);
|
|
42365
|
+
safeLog(` Name: ${shareName}`);
|
|
42366
|
+
safeLog(` CID: ${c2.bold(data.cid)}`);
|
|
42367
|
+
safeLog(` ${c2.dim("Others can import: /ipfs import " + data.cid)}
|
|
42368
|
+
`);
|
|
42369
|
+
} else {
|
|
42370
|
+
renderWarning(result.output);
|
|
42371
|
+
}
|
|
42372
|
+
} catch (e) {
|
|
42373
|
+
renderWarning(`Share failed: ${e.message ?? e}`);
|
|
42374
|
+
}
|
|
42375
|
+
return "handled";
|
|
42376
|
+
}
|
|
42377
|
+
if (ipfsAction === "import") {
|
|
42378
|
+
const importCid = ipfsArg.trim();
|
|
42379
|
+
if (!importCid) {
|
|
42380
|
+
renderInfo("Usage: /ipfs import <CID>");
|
|
42381
|
+
return "handled";
|
|
42382
|
+
}
|
|
42383
|
+
try {
|
|
42384
|
+
const { NexusTool: NexusTool2 } = __require("@open-agents/execution");
|
|
42385
|
+
const nexus = new NexusTool2(ctx.repoRoot);
|
|
42386
|
+
await nexus.execute({ action: "ipfs_pin", cid: importCid, source: "import" });
|
|
42387
|
+
const regFile = join51(ctx.repoRoot, ".oa", "nexus", "ipfs", "cid-registry", "learning-cids.json");
|
|
42388
|
+
if (existsSync36(regFile)) {
|
|
42389
|
+
const reg = JSON.parse(readFileSync25(regFile, "utf8"));
|
|
42390
|
+
const pinned = Object.values(reg).some((e) => e.cid === importCid && e.pinned);
|
|
42391
|
+
if (pinned) {
|
|
42392
|
+
renderInfo(`CID ${importCid.slice(0, 20)}... pinned successfully.`);
|
|
42393
|
+
renderInfo("Content will be available when Helia resolves it from the IPFS network.");
|
|
42394
|
+
} else {
|
|
42395
|
+
renderInfo(`CID ${importCid.slice(0, 20)}... registered for pinning.`);
|
|
42396
|
+
}
|
|
42397
|
+
} else {
|
|
42398
|
+
renderInfo(`CID ${importCid.slice(0, 20)}... pin request sent.`);
|
|
42399
|
+
}
|
|
42400
|
+
} catch (e) {
|
|
42401
|
+
renderWarning(`Import failed: ${e.message ?? e}`);
|
|
42402
|
+
}
|
|
42403
|
+
return "handled";
|
|
42404
|
+
}
|
|
42323
42405
|
if (ipfsAction === "cids" || ipfsAction === "ls" || ipfsAction === "pins") {
|
|
42324
42406
|
try {
|
|
42325
42407
|
const { NexusTool: NexusTool2 } = __require("@open-agents/execution");
|
package/package.json
CHANGED