open-agents-ai 0.111.0 → 0.112.0

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 +90 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8010,6 +8010,11 @@ var init_memory_metabolism = __esm({
8010
8010
  type: "string",
8011
8011
  description: "What generated this memory (tool name, event, etc.)"
8012
8012
  },
8013
+ scope: {
8014
+ type: "string",
8015
+ enum: ["private", "public", "guild"],
8016
+ description: "Visibility scope: private (local only), public (share with network), guild (curated group). Default: private"
8017
+ },
8013
8018
  id: {
8014
8019
  type: "string",
8015
8020
  description: "Memory ID (for promote/forget operations)"
@@ -8018,9 +8023,15 @@ var init_memory_metabolism = __esm({
8018
8023
  required: ["op"]
8019
8024
  };
8020
8025
  cwd;
8026
+ /** Callback for publishing memory deltas to the network (COHERE Plane 4) */
8027
+ deltaPublisher = null;
8021
8028
  constructor(cwd4) {
8022
8029
  this.cwd = cwd4;
8023
8030
  }
8031
+ /** Set a callback that publishes memory deltas to the P2P network */
8032
+ setDeltaPublisher(publisher) {
8033
+ this.deltaPublisher = publisher;
8034
+ }
8024
8035
  async execute(args) {
8025
8036
  const op = String(args.op ?? "");
8026
8037
  const start = performance.now();
@@ -8048,6 +8059,7 @@ var init_memory_metabolism = __esm({
8048
8059
  const content = String(args.content ?? "");
8049
8060
  const memType = args.memory_type ?? "episodic";
8050
8061
  const source = String(args.source ?? "user");
8062
+ const scope = String(args.scope ?? "private");
8051
8063
  if (!content.trim()) {
8052
8064
  return { success: false, output: "No content provided", error: "Empty content", durationMs: performance.now() - start };
8053
8065
  }
@@ -8074,6 +8086,22 @@ var init_memory_metabolism = __esm({
8074
8086
  const store = await this.loadStore(metaDir);
8075
8087
  store.push(item);
8076
8088
  await this.saveStore(metaDir, store);
8089
+ if (admitted && scope !== "private" && this.deltaPublisher) {
8090
+ try {
8091
+ this.deltaPublisher({
8092
+ delta_id: item.id,
8093
+ scope,
8094
+ type: memType,
8095
+ content: content.slice(0, 2e3),
8096
+ // truncate for network
8097
+ confidence: avgScore,
8098
+ provenance_refs: [source],
8099
+ ttl_days: 90,
8100
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
8101
+ });
8102
+ } catch {
8103
+ }
8104
+ }
8077
8105
  return {
8078
8106
  success: true,
8079
8107
  output: `Memory ${item.decision.action}: [${item.id}] type=${memType} scores={novelty:${scores.novelty.toFixed(2)} utility:${scores.utility.toFixed(2)} confidence:${scores.confidence.toFixed(2)} identity:${scores.identityRelevance.toFixed(2)}} avg=${avgScore.toFixed(2)} \u2014 ${item.decision.reason}`,
@@ -30758,40 +30786,58 @@ var init_expose = __esm({
30758
30786
  const promptEval = responseTail.match(/"prompt_eval_count"\s*:\s*(\d+)/);
30759
30787
  const evalCount = responseTail.match(/"eval_count"\s*:\s*(\d+)/);
30760
30788
  if (promptEval || evalCount) {
30761
- const tIn = parseInt(promptEval?.[1] ?? "0", 10);
30762
- const tOut = parseInt(evalCount?.[1] ?? "0", 10);
30763
- this._stats.totalTokensIn += tIn;
30764
- this._stats.totalTokensOut += tOut;
30765
- user.tokensIn += tIn;
30766
- user.tokensOut += tOut;
30789
+ const tIn2 = parseInt(promptEval?.[1] ?? "0", 10);
30790
+ const tOut2 = parseInt(evalCount?.[1] ?? "0", 10);
30791
+ this._stats.totalTokensIn += tIn2;
30792
+ this._stats.totalTokensOut += tOut2;
30793
+ user.tokensIn += tIn2;
30794
+ user.tokensOut += tOut2;
30767
30795
  if (requestModel) {
30768
30796
  const mm = user.models.get(requestModel);
30769
30797
  if (mm) {
30770
- mm.tokensIn += tIn;
30771
- mm.tokensOut += tOut;
30798
+ mm.tokensIn += tIn2;
30799
+ mm.tokensOut += tOut2;
30772
30800
  }
30773
30801
  }
30774
30802
  } else {
30775
30803
  const promptTokens = responseTail.match(/"prompt_tokens"\s*:\s*(\d+)/);
30776
30804
  const completionTokens = responseTail.match(/"completion_tokens"\s*:\s*(\d+)/);
30777
30805
  if (promptTokens || completionTokens) {
30778
- const tIn = parseInt(promptTokens?.[1] ?? "0", 10);
30779
- const tOut = parseInt(completionTokens?.[1] ?? "0", 10);
30780
- this._stats.totalTokensIn += tIn;
30781
- this._stats.totalTokensOut += tOut;
30782
- user.tokensIn += tIn;
30783
- user.tokensOut += tOut;
30806
+ const tIn2 = parseInt(promptTokens?.[1] ?? "0", 10);
30807
+ const tOut2 = parseInt(completionTokens?.[1] ?? "0", 10);
30808
+ this._stats.totalTokensIn += tIn2;
30809
+ this._stats.totalTokensOut += tOut2;
30810
+ user.tokensIn += tIn2;
30811
+ user.tokensOut += tOut2;
30784
30812
  if (requestModel) {
30785
30813
  const mm = user.models.get(requestModel);
30786
30814
  if (mm) {
30787
- mm.tokensIn += tIn;
30788
- mm.tokensOut += tOut;
30815
+ mm.tokensIn += tIn2;
30816
+ mm.tokensOut += tOut2;
30789
30817
  }
30790
30818
  }
30791
30819
  }
30792
30820
  }
30793
30821
  } catch {
30794
30822
  }
30823
+ const tIn = user.tokensIn;
30824
+ const tOut = user.tokensOut;
30825
+ if (tIn > 0 || tOut > 0) {
30826
+ const receipt = {
30827
+ job_id: `job-${Date.now().toString(36)}`,
30828
+ provider_peer_id: "local",
30829
+ consumer_ip: userIp,
30830
+ model: requestModel,
30831
+ usage_final: { input_tokens: tIn, output_tokens: tOut },
30832
+ latency_ms: Date.now() - (user.lastSeen || Date.now()),
30833
+ quality_flags: [],
30834
+ // COHERE revenue split: 70% provider, 10% commons, 8% memory, 7% relay, 5% reserve
30835
+ provider_reward: (tIn + tOut) * 1e-7 * 0.7,
30836
+ commons_contribution: (tIn + tOut) * 1e-7 * 0.1,
30837
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
30838
+ };
30839
+ this.emit("settlement_receipt", receipt);
30840
+ }
30795
30841
  this.emitStats();
30796
30842
  };
30797
30843
  const proxyReq = httpRequest({
@@ -51301,8 +51347,35 @@ function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce
51301
51347
  if (flowEnabled) {
51302
51348
  dynamicContext += "\n\n" + FLOWSTATE_PROMPT;
51303
51349
  }
51304
- let backend;
51350
+ let localFirstOverride = false;
51305
51351
  if (config.backendType === "nexus") {
51352
+ try {
51353
+ const localCheckResp = (() => {
51354
+ try {
51355
+ return __require("node:child_process").execSync("curl -s http://localhost:11434/api/tags 2>/dev/null", { encoding: "utf8", timeout: 3e3 });
51356
+ } catch {
51357
+ return "";
51358
+ }
51359
+ })();
51360
+ if (localCheckResp) {
51361
+ try {
51362
+ const tags = JSON.parse(localCheckResp);
51363
+ const localModels = (tags.models ?? []).map((m) => m.name);
51364
+ const modelBase = config.model.split(":")[0] ?? config.model;
51365
+ const hasLocal = localModels.some((m) => m === config.model || m.startsWith(modelBase));
51366
+ if (hasLocal) {
51367
+ localFirstOverride = true;
51368
+ }
51369
+ } catch {
51370
+ }
51371
+ }
51372
+ } catch {
51373
+ }
51374
+ }
51375
+ let backend;
51376
+ if (localFirstOverride) {
51377
+ backend = new OllamaAgenticBackend("http://localhost:11434", config.model, void 0, thinkingEnabled);
51378
+ } else if (config.backendType === "nexus") {
51306
51379
  const nexusTool = new NexusTool(repoRoot);
51307
51380
  const connectPromise = nexusTool.execute({ action: "connect" }).catch(() => {
51308
51381
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.111.0",
3
+ "version": "0.112.0",
4
4
  "description": "AI coding agent powered by open-source models (Ollama/vLLM) — interactive TUI with agentic tool-calling loop",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",