open-agents-ai 0.184.4 → 0.184.5

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.
Files changed (2) hide show
  1. package/dist/index.js +104 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48801,6 +48801,10 @@ async function handleEndpoint(arg, ctx, local = false) {
48801
48801
  }
48802
48802
  return;
48803
48803
  }
48804
+ if (arg === "sponsor" || arg === "sponsored") {
48805
+ await handleSponsoredEndpoint(ctx, local);
48806
+ return;
48807
+ }
48804
48808
  const normalizedArg = arg.replace(/\u2014/g, "--").replace(/\u2013/g, "--");
48805
48809
  const parts = normalizedArg.split(/\s+/);
48806
48810
  const url = parts[0];
@@ -48961,6 +48965,106 @@ async function handleEndpoint(arg, ctx, local = false) {
48961
48965
  renderWarning(`Could not verify model availability on ${provider.label}. If inference fails, use /model to switch.`);
48962
48966
  }
48963
48967
  }
48968
+ async function handleSponsoredEndpoint(ctx, local) {
48969
+ process.stdout.write(`
48970
+ ${c2.dim("Scanning for sponsored inference endpoints...")}
48971
+
48972
+ `);
48973
+ const sponsors = [];
48974
+ const gateway = ctx.getExposeGateway?.();
48975
+ if (gateway && gateway.isActive && gateway.tunnelUrl) {
48976
+ sponsors.push({
48977
+ name: "Local Gateway",
48978
+ url: gateway.tunnelUrl,
48979
+ authKey: gateway.authKey,
48980
+ models: [],
48981
+ // would need to probe
48982
+ limits: { rpm: 60, tpd: 1e5 },
48983
+ source: "local"
48984
+ });
48985
+ }
48986
+ const sponsorDir2 = join58(ctx.repoRoot ?? process.cwd(), ".oa", "sponsor");
48987
+ const knownFile = join58(sponsorDir2, "known-sponsors.json");
48988
+ try {
48989
+ if (existsSync42(knownFile)) {
48990
+ const saved = JSON.parse(readFileSync31(knownFile, "utf8"));
48991
+ for (const s of saved) {
48992
+ try {
48993
+ const probe = await fetch(`${s.url}/api/tags`, {
48994
+ headers: s.authKey ? { Authorization: `Bearer ${s.authKey}` } : {},
48995
+ signal: AbortSignal.timeout(5e3)
48996
+ });
48997
+ if (probe.ok) {
48998
+ const data = await probe.json();
48999
+ s.models = (data.models || []).map((m) => m.name);
49000
+ sponsors.push(s);
49001
+ }
49002
+ } catch {
49003
+ }
49004
+ }
49005
+ }
49006
+ } catch {
49007
+ }
49008
+ if (sponsors.length === 0) {
49009
+ renderInfo("No sponsored endpoints found.");
49010
+ renderInfo("");
49011
+ renderInfo("To connect to a sponsor, use:");
49012
+ renderInfo(" /endpoint <tunnel-url> --auth <key>");
49013
+ renderInfo("");
49014
+ renderInfo("Or add a known sponsor URL:");
49015
+ renderInfo(" /endpoint sponsor add <url> --auth <key>");
49016
+ return;
49017
+ }
49018
+ const items = [
49019
+ { key: "hdr", label: "Available Sponsored Endpoints" }
49020
+ ];
49021
+ for (const sp of sponsors) {
49022
+ const modelList = sp.models.length > 0 ? sp.models.slice(0, 3).join(", ") + (sp.models.length > 3 ? ` +${sp.models.length - 3}` : "") : "probing...";
49023
+ items.push({
49024
+ key: sp.url,
49025
+ label: ` ${sp.name} (${sp.source})`,
49026
+ detail: ` Models: ${modelList} | ${sp.limits.rpm} req/min, ${sp.limits.tpd >= 1e3 ? (sp.limits.tpd / 1e3).toFixed(0) + "K" : sp.limits.tpd} tokens/day`
49027
+ });
49028
+ }
49029
+ items.push({ key: "sep", label: "" });
49030
+ items.push({ key: "add", label: " + Add sponsor URL manually..." });
49031
+ if (!ctx.rl) {
49032
+ for (const sp of sponsors) {
49033
+ process.stdout.write(` ${sp.name}: ${sp.url}
49034
+ `);
49035
+ }
49036
+ return;
49037
+ }
49038
+ const result = await tuiSelect({
49039
+ items,
49040
+ title: "Sponsored Endpoints",
49041
+ rl: ctx.rl,
49042
+ skipKeys: ["hdr", "sep"],
49043
+ availableRows: ctx.availableContentRows?.()
49044
+ });
49045
+ if (!result.confirmed || !result.key) {
49046
+ renderInfo("Cancelled.");
49047
+ return;
49048
+ }
49049
+ if (result.key === "add") {
49050
+ renderInfo("Use: /endpoint <tunnel-url> --auth <key>");
49051
+ return;
49052
+ }
49053
+ const selected = sponsors.find((s) => s.url === result.key);
49054
+ if (!selected)
49055
+ return;
49056
+ const endpointArg = selected.authKey ? `${selected.url} --auth ${selected.authKey}` : selected.url;
49057
+ await handleEndpoint(endpointArg, ctx, local);
49058
+ try {
49059
+ mkdirSync18(sponsorDir2, { recursive: true });
49060
+ const existing = existsSync42(knownFile) ? JSON.parse(readFileSync31(knownFile, "utf8")) : [];
49061
+ const updated = existing.filter((s) => s.url !== selected.url);
49062
+ updated.push(selected);
49063
+ writeFileSync19(knownFile, JSON.stringify(updated, null, 2), "utf8");
49064
+ } catch {
49065
+ }
49066
+ renderInfo(`Connected to sponsored endpoint: ${selected.name}`);
49067
+ }
48964
49068
  async function handlePeerEndpoint(peerId, authKey, ctx, local) {
48965
49069
  process.stdout.write(`
48966
49070
  ${c2.dim("Detected:")} ${c2.bold("libp2p peer")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.184.4",
3
+ "version": "0.184.5",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) \u2014 interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",