open-agents-ai 0.138.72 → 0.138.74

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 (3) hide show
  1. package/README.md +0 -12
  2. package/dist/index.js +173 -17
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,15 +1,3 @@
1
- <p align="center">
2
- <pre align="center">
3
- ██████╗ █████╗
4
- ██╔═══██╗██╔══██╗ ░▒▓█▓▒░ ░▒▓▓▒░ ░▒▓▓▒░
5
- ██║ ██║███████║ ░▒▓█▓▒░▒▓▓▒░▒▓▓▒░▒▓▓▒░
6
- ██║ ██║██╔══██║ ░▒▓█▓▒░▒▓▓▒░░▒▓▓▒░
7
- ╚██████╔╝██║ ██║ ░▒▓▓▒░▒▓▓▒░▒▓▓▒░
8
- ╚═════╝ ╚═╝ ╚═╝ ░▒▓▓▒░░▒▓▓▒░
9
- /help /voice /cohere /model
10
- </pre>
11
- </p>
12
-
13
1
  <h1 align="center">Open Agents</h1>
14
2
 
15
3
  <p align="center">
package/dist/index.js CHANGED
@@ -12915,7 +12915,48 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
12915
12915
  const top = items.slice(0, k);
12916
12916
  if (top.length === 0)
12917
12917
  return "";
12918
- return top.map((m) => `- [${m.type}] ${m.content.slice(0, 200)} (confidence: ${m.scores.confidence.toFixed(2)}, utility: ${m.scores.utility.toFixed(2)})`).join("\n");
12918
+ return top.map((m) => `- [${m.type}][${m.id}] ${m.content.slice(0, 200)} (confidence: ${m.scores.confidence.toFixed(2)}, utility: ${m.scores.utility.toFixed(2)})`).join("\n");
12919
+ }
12920
+ // ── Outcome-weighted feedback (WO-FL5) ───────────────────────────────
12921
+ // Per ExpeL (arXiv:2308.10144): contrastive learning from success/failure.
12922
+ // Per MemRL (arXiv:2601.03192): environmental feedback > text similarity.
12923
+ /** Update memory scores based on task outcome. Called after task completion.
12924
+ * Memories used in successful tasks get boosted. Memories present during failures get decayed. */
12925
+ updateFromOutcomeSync(surfacedMemoryText, succeeded) {
12926
+ const { readFileSync: readFileSync33, writeFileSync: writeFileSync20, existsSync: existsSync45, mkdirSync: mkdirSync21 } = __require("node:fs");
12927
+ const metaDir = join21(this.cwd, ".oa", "memory", "metabolism");
12928
+ const storeFile = join21(metaDir, "store.json");
12929
+ if (!existsSync45(storeFile))
12930
+ return;
12931
+ let store = [];
12932
+ try {
12933
+ store = JSON.parse(readFileSync33(storeFile, "utf8"));
12934
+ } catch {
12935
+ return;
12936
+ }
12937
+ const idMatches = surfacedMemoryText.match(/\[(mem-[a-zA-Z0-9-]+)\]/g);
12938
+ if (!idMatches || idMatches.length === 0)
12939
+ return;
12940
+ const surfacedIds = new Set(idMatches.map((m) => m.slice(1, -1)));
12941
+ let updated = false;
12942
+ for (const item of store) {
12943
+ if (!surfacedIds.has(item.id))
12944
+ continue;
12945
+ item.accessCount++;
12946
+ item.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
12947
+ if (succeeded) {
12948
+ item.scores.utility = Math.min(1, item.scores.utility + 0.1);
12949
+ item.scores.confidence = Math.min(1, item.scores.confidence + 0.05);
12950
+ } else {
12951
+ item.scores.utility = Math.max(0, item.scores.utility - 0.05);
12952
+ item.scores.confidence = Math.max(0, item.scores.confidence - 0.02);
12953
+ }
12954
+ updated = true;
12955
+ }
12956
+ if (updated) {
12957
+ mkdirSync21(metaDir, { recursive: true });
12958
+ writeFileSync20(storeFile, JSON.stringify(store, null, 2));
12959
+ }
12919
12960
  }
12920
12961
  // ── Storage ──────────────────────────────────────────────────────────
12921
12962
  async loadStore(dir) {
@@ -13332,6 +13373,58 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
13332
13373
  return [];
13333
13374
  }
13334
13375
  }
13376
+ // ── Sync retrieval for context injection (WO-FL4) ─────────────────────
13377
+ // Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
13378
+ /** Retrieve top-K strategies for context injection. Returns "" if none. */
13379
+ getRelevantStrategiesSync(k = 3, taskType) {
13380
+ const { readFileSync: readFileSync33, existsSync: existsSync45 } = __require("node:fs");
13381
+ const archiveFile = join23(this.cwd, ".oa", "arche", "variants.json");
13382
+ if (!existsSync45(archiveFile))
13383
+ return "";
13384
+ let variants = [];
13385
+ try {
13386
+ variants = JSON.parse(readFileSync33(archiveFile, "utf8"));
13387
+ } catch {
13388
+ return "";
13389
+ }
13390
+ if (variants.length === 0)
13391
+ return "";
13392
+ let filtered = variants;
13393
+ if (taskType) {
13394
+ const typeMatch = filtered.filter((v) => v.tags.some((t) => t.toLowerCase().includes(taskType.toLowerCase())));
13395
+ if (typeMatch.length > 0)
13396
+ filtered = typeMatch;
13397
+ }
13398
+ filtered.sort((a, b) => b.confidence * (1 + b.reuse_count * 0.1) - a.confidence * (1 + a.reuse_count * 0.1));
13399
+ const top = filtered.slice(0, k);
13400
+ return top.map((v) => `- [${v.outcome.includes("success") || v.outcome.includes("pass") ? "SUCCESS" : "FAILURE"}] ${v.strategy.slice(0, 200)} (confidence: ${v.confidence.toFixed(2)})`).join("\n");
13401
+ }
13402
+ /** Archive a strategy variant synchronously (for task completion path) */
13403
+ archiveVariantSync(strategy, outcome, tags = []) {
13404
+ const { readFileSync: readFileSync33, writeFileSync: writeFileSync20, existsSync: existsSync45, mkdirSync: mkdirSync21 } = __require("node:fs");
13405
+ const dir = join23(this.cwd, ".oa", "arche");
13406
+ const archiveFile = join23(dir, "variants.json");
13407
+ let variants = [];
13408
+ try {
13409
+ if (existsSync45(archiveFile))
13410
+ variants = JSON.parse(readFileSync33(archiveFile, "utf8"));
13411
+ } catch {
13412
+ }
13413
+ variants.push({
13414
+ id: `var-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
13415
+ strategy: strategy.slice(0, 500),
13416
+ context: "",
13417
+ outcome: outcome.slice(0, 200),
13418
+ confidence: /success|pass|complete|fixed/i.test(outcome) ? 0.75 : 0.3,
13419
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
13420
+ reuse_count: 0,
13421
+ tags: tags.length > 0 ? tags : this.extractTags(strategy)
13422
+ });
13423
+ if (variants.length > 50)
13424
+ variants = variants.slice(-50);
13425
+ mkdirSync21(dir, { recursive: true });
13426
+ writeFileSync20(archiveFile, JSON.stringify(variants, null, 2));
13427
+ }
13335
13428
  async saveArchive(variants) {
13336
13429
  const dir = join23(this.cwd, ".oa", "arche");
13337
13430
  await mkdir8(dir, { recursive: true });
@@ -54143,6 +54236,32 @@ ${metabolismMemories}
54143
54236
  }
54144
54237
  } catch {
54145
54238
  }
54239
+ try {
54240
+ const archeFile = join59(repoRoot, ".oa", "arche", "variants.json");
54241
+ if (existsSync43(archeFile)) {
54242
+ const variants = JSON.parse(readFileSync32(archeFile, "utf8"));
54243
+ if (variants.length > 0) {
54244
+ let filtered = variants;
54245
+ if (taskType) {
54246
+ const typeMatch = filtered.filter((v) => v.tags?.some((t) => t.toLowerCase().includes(taskType.toLowerCase())));
54247
+ if (typeMatch.length > 0)
54248
+ filtered = typeMatch;
54249
+ }
54250
+ filtered.sort((a, b) => (b.confidence || 0) - (a.confidence || 0));
54251
+ const top = filtered.slice(0, 3);
54252
+ if (top.length > 0) {
54253
+ const lines = top.map((v) => `- [${v.outcome?.includes("success") ? "OK" : "FAIL"}] ${(v.strategy || "").slice(0, 150)}`);
54254
+ dynamicContext += `
54255
+
54256
+ <strategy-archive>
54257
+ Past strategies (COHERE Exploration Archive):
54258
+ ${lines.join("\n")}
54259
+ </strategy-archive>`;
54260
+ }
54261
+ }
54262
+ }
54263
+ } catch {
54264
+ }
54146
54265
  if (taskType && modelTier !== "small") {
54147
54266
  dynamicContext += "\n\n" + buildTaskContext(taskType);
54148
54267
  }
@@ -54922,7 +55041,6 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
54922
55041
  version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
54923
55042
  };
54924
55043
  }
54925
- console.error("[IK-DEBUG] Creating/updating identity at", ikFile, "exists:", existsSync43(ikFile));
54926
55044
  const event = `Task completed: ${result.summary.slice(0, 200)}`;
54927
55045
  if (/success|pass|complete|done|fixed/i.test(event)) {
54928
55046
  ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
@@ -57845,7 +57963,7 @@ async function runWithTUI(task, config, repoPath) {
57845
57963
  renderUserMessage(task);
57846
57964
  try {
57847
57965
  const handle = startTask(task, config, repoRoot);
57848
- const result = await handle.promise;
57966
+ await handle.promise;
57849
57967
  try {
57850
57968
  const ikDir = join59(repoRoot, ".oa", "identity");
57851
57969
  const ikFile = join59(ikDir, "self-state.json");
@@ -57871,24 +57989,62 @@ async function runWithTUI(task, config, repoPath) {
57871
57989
  version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
57872
57990
  };
57873
57991
  }
57874
- const completed = result && result.completed;
57875
- if (completed) {
57876
- ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
57877
- ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
57878
- } else {
57879
- ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
57880
- ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
57881
- }
57992
+ ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
57993
+ ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
57882
57994
  ikState.session_count = (ikState.session_count || 0) + 1;
57883
57995
  ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
57884
- process.stderr.write(`[identity] WRITING to ${ikFile}
57885
- `);
57886
57996
  writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
57887
- process.stderr.write(`[identity] WRITTEN successfully
57888
- `);
57889
57997
  } catch (ikErr) {
57890
- process.stderr.write(`[identity] ERROR: ${ikErr}
57891
- `);
57998
+ }
57999
+ try {
58000
+ const { ExplorationCultureTool: ExplorationCultureTool2 } = __require("@open-agents/execution");
58001
+ const ec = new ExplorationCultureTool2(repoRoot);
58002
+ ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
58003
+ } catch {
58004
+ try {
58005
+ const archeDir = join59(repoRoot, ".oa", "arche");
58006
+ const archeFile = join59(archeDir, "variants.json");
58007
+ let variants = [];
58008
+ try {
58009
+ if (existsSync43(archeFile))
58010
+ variants = JSON.parse(readFileSync32(archeFile, "utf8"));
58011
+ } catch {
58012
+ }
58013
+ variants.push({
58014
+ id: `var-${Date.now().toString(36)}`,
58015
+ strategy: `Task: ${task.slice(0, 300)}`,
58016
+ context: "",
58017
+ outcome: "success \u2014 completed",
58018
+ confidence: 0.75,
58019
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
58020
+ reuse_count: 0,
58021
+ tags: ["general"]
58022
+ });
58023
+ if (variants.length > 50)
58024
+ variants = variants.slice(-50);
58025
+ mkdirSync19(archeDir, { recursive: true });
58026
+ writeFileSync18(archeFile, JSON.stringify(variants, null, 2));
58027
+ } catch {
58028
+ }
58029
+ }
58030
+ try {
58031
+ const metaFile = join59(repoRoot, ".oa", "memory", "metabolism", "store.json");
58032
+ if (existsSync43(metaFile)) {
58033
+ const store = JSON.parse(readFileSync32(metaFile, "utf8"));
58034
+ const surfaced = store.filter((m) => m.type !== "quarantine" && m.scores?.confidence > 0.15).sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence).slice(0, 5);
58035
+ let updated = false;
58036
+ for (const item of surfaced) {
58037
+ item.accessCount = (item.accessCount || 0) + 1;
58038
+ item.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
58039
+ item.scores.utility = Math.min(1, (item.scores.utility || 0.5) + 0.1);
58040
+ item.scores.confidence = Math.min(1, (item.scores.confidence || 0.5) + 0.05);
58041
+ updated = true;
58042
+ }
58043
+ if (updated) {
58044
+ writeFileSync18(metaFile, JSON.stringify(store, null, 2));
58045
+ }
58046
+ }
58047
+ } catch {
57892
58048
  }
57893
58049
  } catch (err) {
57894
58050
  renderError(err instanceof Error ? err.message : String(err));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.138.72",
3
+ "version": "0.138.74",
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",