open-agents-ai 0.184.27 → 0.184.29
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 +114 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48230,29 +48230,70 @@ async function handleSlashCommand(input, ctx) {
|
|
|
48230
48230
|
if (activeGw && "setSponsorLimits" in activeGw) {
|
|
48231
48231
|
activeGw.setSponsorLimits(config.rateLimits);
|
|
48232
48232
|
}
|
|
48233
|
-
|
|
48234
|
-
|
|
48233
|
+
const tunnelGw = ctx.getExposeGateway?.();
|
|
48234
|
+
const enabledEps = config.endpoints.filter((e) => e.enabled);
|
|
48235
|
+
const allModels = enabledEps.flatMap((e) => e.models || []);
|
|
48236
|
+
const sponsorUrl = tunnelGw?.tunnelUrl || "";
|
|
48237
|
+
if (!sponsorUrl) {
|
|
48238
|
+
renderWarning("No tunnel URL available \u2014 sponsor not registered in directory. Start with cloudflared or libp2p first.");
|
|
48239
|
+
}
|
|
48240
|
+
let sponsorName = (config.header.message || "").replace(/^\/+/, "").trim();
|
|
48241
|
+
if (!sponsorName || sponsorName.length < 2) {
|
|
48235
48242
|
try {
|
|
48236
|
-
|
|
48243
|
+
const { homedir: homedir19 } = __require("os");
|
|
48244
|
+
const namePath = __require("path").join(homedir19(), ".open-agents", "agent-name");
|
|
48245
|
+
if (existsSync42(namePath))
|
|
48246
|
+
sponsorName = readFileSync31(namePath, "utf8").trim();
|
|
48237
48247
|
} catch {
|
|
48238
48248
|
}
|
|
48239
|
-
|
|
48240
|
-
|
|
48241
|
-
|
|
48242
|
-
|
|
48243
|
-
|
|
48244
|
-
|
|
48245
|
-
|
|
48246
|
-
|
|
48247
|
-
|
|
48248
|
-
|
|
48249
|
-
|
|
48250
|
-
|
|
48251
|
-
|
|
48252
|
-
|
|
48253
|
-
|
|
48249
|
+
if (!sponsorName)
|
|
48250
|
+
sponsorName = "OA Sponsor";
|
|
48251
|
+
}
|
|
48252
|
+
const sponsorPayload = {
|
|
48253
|
+
peerId: tunnelGw?.peerId || sponsorUrl || `oa-${Date.now()}`,
|
|
48254
|
+
name: sponsorName,
|
|
48255
|
+
models: allModels,
|
|
48256
|
+
tunnelUrl: sponsorUrl,
|
|
48257
|
+
authKey: tunnelGw?.authKey || "",
|
|
48258
|
+
limits: {
|
|
48259
|
+
maxRequestsPerMinute: config.rateLimits.maxRequestsPerMinute,
|
|
48260
|
+
maxTokensPerDay: config.rateLimits.maxTokensPerDay
|
|
48261
|
+
},
|
|
48262
|
+
banner: config.banner.preset,
|
|
48263
|
+
message: config.header.message || sponsorName,
|
|
48264
|
+
linkUrl: config.header.linkUrl,
|
|
48265
|
+
linkText: config.header.linkText,
|
|
48266
|
+
status: sponsorUrl ? "active" : "inactive"
|
|
48267
|
+
// don't register without a URL
|
|
48268
|
+
};
|
|
48269
|
+
try {
|
|
48270
|
+
const kvResp = await fetch("https://openagents.nexus/api/v1/sponsors", {
|
|
48271
|
+
method: "POST",
|
|
48272
|
+
headers: { "Content-Type": "application/json" },
|
|
48273
|
+
body: JSON.stringify(sponsorPayload),
|
|
48274
|
+
signal: AbortSignal.timeout(1e4)
|
|
48254
48275
|
});
|
|
48255
|
-
|
|
48276
|
+
const kvResult = await kvResp.json();
|
|
48277
|
+
if (kvResult.persisted) {
|
|
48278
|
+
renderInfo("Registered in sponsor directory \u2014 consumers can discover you via /endpoint sponsor");
|
|
48279
|
+
} else {
|
|
48280
|
+
renderWarning(`Sponsor directory: ${kvResult.reason || "not persisted"}`);
|
|
48281
|
+
}
|
|
48282
|
+
} catch (kvErr) {
|
|
48283
|
+
renderWarning(`Sponsor directory unreachable: ${kvErr instanceof Error ? kvErr.message : String(kvErr)}`);
|
|
48284
|
+
}
|
|
48285
|
+
try {
|
|
48286
|
+
const nexus = new NexusTool(projectDir);
|
|
48287
|
+
const statusCheck = String(await nexus.execute({ action: "status" }) ?? "");
|
|
48288
|
+
if (/Connected:\s*true/i.test(statusCheck)) {
|
|
48289
|
+
await nexus.execute({
|
|
48290
|
+
action: "sponsor_announce",
|
|
48291
|
+
...Object.fromEntries(Object.entries(sponsorPayload).map(([k, v]) => [
|
|
48292
|
+
k === "tunnelUrl" ? "tunnel_url" : k === "authKey" ? "auth_key" : k === "linkUrl" ? "link_url" : k === "linkText" ? "link_text" : k,
|
|
48293
|
+
Array.isArray(v) ? v.join(",") : String(v)
|
|
48294
|
+
]))
|
|
48295
|
+
});
|
|
48296
|
+
}
|
|
48256
48297
|
} catch {
|
|
48257
48298
|
}
|
|
48258
48299
|
}
|
|
@@ -63723,6 +63764,60 @@ Rationale: ${proposal.rationale}${provenanceNote}`;
|
|
|
63723
63764
|
}
|
|
63724
63765
|
} catch {
|
|
63725
63766
|
}
|
|
63767
|
+
try {
|
|
63768
|
+
const { homedir: _hd } = await import("node:os");
|
|
63769
|
+
const globalNamePath = join67(_hd(), ".open-agents", "agent-name");
|
|
63770
|
+
let agName = "oa-node";
|
|
63771
|
+
try {
|
|
63772
|
+
if (existsSync50(globalNamePath))
|
|
63773
|
+
agName = readFileSync39(globalNamePath, "utf8").trim() || agName;
|
|
63774
|
+
} catch {
|
|
63775
|
+
}
|
|
63776
|
+
fetch("https://openagents.nexus/api/v1/directory", {
|
|
63777
|
+
method: "POST",
|
|
63778
|
+
headers: { "Content-Type": "application/json" },
|
|
63779
|
+
body: JSON.stringify({
|
|
63780
|
+
peerId: agName + "-" + Date.now(),
|
|
63781
|
+
agentName: agName,
|
|
63782
|
+
multiaddrs: [],
|
|
63783
|
+
rooms: []
|
|
63784
|
+
}),
|
|
63785
|
+
signal: AbortSignal.timeout(5e3)
|
|
63786
|
+
}).catch(() => {
|
|
63787
|
+
});
|
|
63788
|
+
const isDefaultOllama = currentConfig.backendUrl === "http://127.0.0.1:11434" || currentConfig.backendUrl === "http://localhost:11434";
|
|
63789
|
+
if (isDefaultOllama) {
|
|
63790
|
+
let ollamaAlive = false;
|
|
63791
|
+
try {
|
|
63792
|
+
const probe = await fetch(`${currentConfig.backendUrl}/api/tags`, { signal: AbortSignal.timeout(3e3) });
|
|
63793
|
+
ollamaAlive = probe.ok;
|
|
63794
|
+
} catch {
|
|
63795
|
+
}
|
|
63796
|
+
if (!ollamaAlive) {
|
|
63797
|
+
try {
|
|
63798
|
+
const spResp = await fetch("https://openagents.nexus/api/v1/sponsors", { signal: AbortSignal.timeout(5e3) });
|
|
63799
|
+
if (spResp.ok) {
|
|
63800
|
+
const spData = await spResp.json();
|
|
63801
|
+
const active = (spData.sponsors || []).filter((s) => s.status === "active" && s.tunnelUrl);
|
|
63802
|
+
if (active.length > 0) {
|
|
63803
|
+
const best = active[0];
|
|
63804
|
+
writeContent(() => {
|
|
63805
|
+
renderInfo(`No local Ollama detected. Auto-connecting to sponsored inference: ${best.name}`);
|
|
63806
|
+
renderInfo(`Endpoint: ${best.tunnelUrl}`);
|
|
63807
|
+
renderInfo(`Models: ${best.models?.slice(0, 3).join(", ") || "available"}`);
|
|
63808
|
+
renderInfo(`Change anytime: /endpoint or /endpoint sponsor`);
|
|
63809
|
+
});
|
|
63810
|
+
currentConfig.backendUrl = best.tunnelUrl;
|
|
63811
|
+
currentConfig.apiKey = best.authKey;
|
|
63812
|
+
currentConfig.backendType = "openai";
|
|
63813
|
+
}
|
|
63814
|
+
}
|
|
63815
|
+
} catch {
|
|
63816
|
+
}
|
|
63817
|
+
}
|
|
63818
|
+
}
|
|
63819
|
+
} catch {
|
|
63820
|
+
}
|
|
63726
63821
|
})().catch(() => {
|
|
63727
63822
|
});
|
|
63728
63823
|
let passwordShowPlain = false;
|
package/package.json
CHANGED