open-agents-ai 0.138.69 → 0.138.71

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 +74 -22
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12885,6 +12885,38 @@ ${issues.map((i) => ` - ${i}`).join("\n")}` : " No issues found."),
12885
12885
  durationMs: performance.now() - start
12886
12886
  };
12887
12887
  }
12888
+ // ── Retrieval for context injection (WO-FL2) ─────────────────────────
12889
+ // Per MemRL (arXiv:2601.03192): rank by utility * confidence (outcome-weighted),
12890
+ // not text similarity. Per FSM paper: filter by task phase when available.
12891
+ /**
12892
+ * Retrieve top-K memories ranked by utility * confidence.
12893
+ * Returns formatted string for system prompt injection, or "" if none.
12894
+ * Optionally filter by task type for phase-aware context (FSM paper insight).
12895
+ */
12896
+ getTopMemoriesSync(k = 5, taskType) {
12897
+ const { readFileSync: readFileSync33, existsSync: existsSync45 } = __require("node:fs");
12898
+ const metaDir = join21(this.cwd, ".oa", "memory", "metabolism");
12899
+ const storeFile = join21(metaDir, "store.json");
12900
+ if (!existsSync45(storeFile))
12901
+ return "";
12902
+ let store = [];
12903
+ try {
12904
+ store = JSON.parse(readFileSync33(storeFile, "utf8"));
12905
+ } catch {
12906
+ return "";
12907
+ }
12908
+ let items = store.filter((m) => m.type !== "quarantine" && m.scores.confidence > 0.15);
12909
+ if (taskType) {
12910
+ const typeMatch = items.filter((m) => m.content.toLowerCase().includes(taskType.toLowerCase()) || m.sourceTrace.toLowerCase().includes(taskType.toLowerCase()));
12911
+ if (typeMatch.length >= 2)
12912
+ items = typeMatch;
12913
+ }
12914
+ items.sort((a, b) => b.scores.utility * b.scores.confidence - a.scores.utility * a.scores.confidence);
12915
+ const top = items.slice(0, k);
12916
+ if (top.length === 0)
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");
12919
+ }
12888
12920
  // ── Storage ──────────────────────────────────────────────────────────
12889
12921
  async loadStore(dir) {
12890
12922
  try {
@@ -54048,8 +54080,7 @@ function formatDMNToolArgs(toolName, args) {
54048
54080
  }
54049
54081
  async function runSelfImprovementCycle(repoRoot) {
54050
54082
  try {
54051
- const { IdentityKernelTool: IdentityKernelTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
54052
- const { ReflectionIntegrityTool: ReflectionIntegrityTool2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
54083
+ const { IdentityKernelTool: IdentityKernelTool2, ReflectionIntegrityTool: ReflectionIntegrityTool2 } = __require("@open-agents/execution");
54053
54084
  const ik = new IdentityKernelTool2(repoRoot);
54054
54085
  const reflect = new ReflectionIntegrityTool2(repoRoot);
54055
54086
  const state = await ik.execute({ op: "hydrate" });
@@ -54098,6 +54129,20 @@ function startTask(task, config, repoRoot, voice, stream, taskStores, bruteForce
54098
54129
  const modelTier = getModelTier(config.model);
54099
54130
  const projectCtx = buildProjectContext(repoRoot, taskStores?.contextStores);
54100
54131
  let dynamicContext = formatContextForPrompt(projectCtx, modelTier);
54132
+ try {
54133
+ const { MemoryMetabolismTool: MemoryMetabolismTool2 } = __require("@open-agents/execution");
54134
+ const mm = new MemoryMetabolismTool2(repoRoot);
54135
+ const metabolismMemories = mm.getTopMemoriesSync(5, taskType || void 0);
54136
+ if (metabolismMemories) {
54137
+ dynamicContext += `
54138
+
54139
+ <learned-memories>
54140
+ Persistent learnings from previous tasks (COHERE Memory Metabolism):
54141
+ ${metabolismMemories}
54142
+ </learned-memories>`;
54143
+ }
54144
+ } catch {
54145
+ }
54101
54146
  if (taskType && modelTier !== "small") {
54102
54147
  dynamicContext += "\n\n" + buildTaskContext(taskType);
54103
54148
  }
@@ -54851,16 +54896,21 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
54851
54896
  runSelfImprovementCycle(repoRoot).catch(() => {
54852
54897
  });
54853
54898
  }
54854
- Promise.resolve().then(() => (init_dist2(), dist_exports)).then(({ IdentityKernelTool: IdentityKernelTool2 }) => {
54855
- const ik = new IdentityKernelTool2(repoRoot);
54856
- ik.execute({
54857
- op: "observe",
54858
- event: `Task completed: ${result.summary.slice(0, 200)}`,
54859
- context: JSON.stringify({ turns: result.turns, toolCalls: result.toolCalls, durationMs: result.durationMs, model: config.model, completed: true })
54860
- }).catch(() => {
54861
- });
54862
- }).catch(() => {
54863
- });
54899
+ try {
54900
+ const ikFile = join59(repoRoot, ".oa", "identity", "self-state.json");
54901
+ if (existsSync43(ikFile)) {
54902
+ const ikState = JSON.parse(readFileSync32(ikFile, "utf8"));
54903
+ const event = `Task completed: ${result.summary.slice(0, 200)}`;
54904
+ if (/success|pass|complete|done|fixed/i.test(event)) {
54905
+ ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
54906
+ ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
54907
+ }
54908
+ ikState.session_count = (ikState.session_count || 0) + 1;
54909
+ ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
54910
+ writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
54911
+ }
54912
+ } catch {
54913
+ }
54864
54914
  if (voice?.enabled && result.summary) {
54865
54915
  const emoFinal = emotionEngine?.getState();
54866
54916
  const emoCtxFinal = emoFinal ? { valence: emoFinal.valence, arousal: emoFinal.arousal, label: emoFinal.label, emoji: emoFinal.emoji } : void 0;
@@ -54868,16 +54918,18 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
54868
54918
  }
54869
54919
  } else {
54870
54920
  renderTaskIncomplete(result.turns, result.toolCalls, result.durationMs, tokens);
54871
- Promise.resolve().then(() => (init_dist2(), dist_exports)).then(({ IdentityKernelTool: IdentityKernelTool2 }) => {
54872
- const ik = new IdentityKernelTool2(repoRoot);
54873
- ik.execute({
54874
- op: "observe",
54875
- event: `Task incomplete after ${result.turns} turns`,
54876
- context: JSON.stringify({ turns: result.turns, toolCalls: result.toolCalls, durationMs: result.durationMs, completed: false })
54877
- }).catch(() => {
54878
- });
54879
- }).catch(() => {
54880
- });
54921
+ try {
54922
+ const ikFile = join59(repoRoot, ".oa", "identity", "self-state.json");
54923
+ if (existsSync43(ikFile)) {
54924
+ const ikState = JSON.parse(readFileSync32(ikFile, "utf8"));
54925
+ ikState.homeostasis.uncertainty = Math.min(1, ikState.homeostasis.uncertainty + 0.1);
54926
+ ikState.homeostasis.coherence = Math.max(0, ikState.homeostasis.coherence - 0.05);
54927
+ ikState.session_count = (ikState.session_count || 0) + 1;
54928
+ ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
54929
+ writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
54930
+ }
54931
+ } catch {
54932
+ }
54881
54933
  if (voice?.enabled) {
54882
54934
  const emoFinal2 = emotionEngine?.getState();
54883
54935
  const emoCtxFinal2 = emoFinal2 ? { valence: emoFinal2.valence, arousal: emoFinal2.arousal, label: emoFinal2.label, emoji: emoFinal2.emoji } : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.138.69",
3
+ "version": "0.138.71",
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",