open-agents-ai 0.138.71 → 0.138.73

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 +177 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13332,6 +13332,58 @@ Recommendation: Strategy ${scored[0].index + 1} scores highest.`;
13332
13332
  return [];
13333
13333
  }
13334
13334
  }
13335
+ // ── Sync retrieval for context injection (WO-FL4) ─────────────────────
13336
+ // Per EvoSkill (arXiv:2603.02766): retrieve relevant strategies from archive.
13337
+ /** Retrieve top-K strategies for context injection. Returns "" if none. */
13338
+ getRelevantStrategiesSync(k = 3, taskType) {
13339
+ const { readFileSync: readFileSync33, existsSync: existsSync45 } = __require("node:fs");
13340
+ const archiveFile = join23(this.cwd, ".oa", "arche", "variants.json");
13341
+ if (!existsSync45(archiveFile))
13342
+ return "";
13343
+ let variants = [];
13344
+ try {
13345
+ variants = JSON.parse(readFileSync33(archiveFile, "utf8"));
13346
+ } catch {
13347
+ return "";
13348
+ }
13349
+ if (variants.length === 0)
13350
+ return "";
13351
+ let filtered = variants;
13352
+ if (taskType) {
13353
+ const typeMatch = filtered.filter((v) => v.tags.some((t) => t.toLowerCase().includes(taskType.toLowerCase())));
13354
+ if (typeMatch.length > 0)
13355
+ filtered = typeMatch;
13356
+ }
13357
+ filtered.sort((a, b) => b.confidence * (1 + b.reuse_count * 0.1) - a.confidence * (1 + a.reuse_count * 0.1));
13358
+ const top = filtered.slice(0, k);
13359
+ 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");
13360
+ }
13361
+ /** Archive a strategy variant synchronously (for task completion path) */
13362
+ archiveVariantSync(strategy, outcome, tags = []) {
13363
+ const { readFileSync: readFileSync33, writeFileSync: writeFileSync20, existsSync: existsSync45, mkdirSync: mkdirSync21 } = __require("node:fs");
13364
+ const dir = join23(this.cwd, ".oa", "arche");
13365
+ const archiveFile = join23(dir, "variants.json");
13366
+ let variants = [];
13367
+ try {
13368
+ if (existsSync45(archiveFile))
13369
+ variants = JSON.parse(readFileSync33(archiveFile, "utf8"));
13370
+ } catch {
13371
+ }
13372
+ variants.push({
13373
+ id: `var-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
13374
+ strategy: strategy.slice(0, 500),
13375
+ context: "",
13376
+ outcome: outcome.slice(0, 200),
13377
+ confidence: /success|pass|complete|fixed/i.test(outcome) ? 0.75 : 0.3,
13378
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
13379
+ reuse_count: 0,
13380
+ tags: tags.length > 0 ? tags : this.extractTags(strategy)
13381
+ });
13382
+ if (variants.length > 50)
13383
+ variants = variants.slice(-50);
13384
+ mkdirSync21(dir, { recursive: true });
13385
+ writeFileSync20(archiveFile, JSON.stringify(variants, null, 2));
13386
+ }
13335
13387
  async saveArchive(variants) {
13336
13388
  const dir = join23(this.cwd, ".oa", "arche");
13337
13389
  await mkdir8(dir, { recursive: true });
@@ -54143,6 +54195,32 @@ ${metabolismMemories}
54143
54195
  }
54144
54196
  } catch {
54145
54197
  }
54198
+ try {
54199
+ const archeFile = join59(repoRoot, ".oa", "arche", "variants.json");
54200
+ if (existsSync43(archeFile)) {
54201
+ const variants = JSON.parse(readFileSync32(archeFile, "utf8"));
54202
+ if (variants.length > 0) {
54203
+ let filtered = variants;
54204
+ if (taskType) {
54205
+ const typeMatch = filtered.filter((v) => v.tags?.some((t) => t.toLowerCase().includes(taskType.toLowerCase())));
54206
+ if (typeMatch.length > 0)
54207
+ filtered = typeMatch;
54208
+ }
54209
+ filtered.sort((a, b) => (b.confidence || 0) - (a.confidence || 0));
54210
+ const top = filtered.slice(0, 3);
54211
+ if (top.length > 0) {
54212
+ const lines = top.map((v) => `- [${v.outcome?.includes("success") ? "OK" : "FAIL"}] ${(v.strategy || "").slice(0, 150)}`);
54213
+ dynamicContext += `
54214
+
54215
+ <strategy-archive>
54216
+ Past strategies (COHERE Exploration Archive):
54217
+ ${lines.join("\n")}
54218
+ </strategy-archive>`;
54219
+ }
54220
+ }
54221
+ }
54222
+ } catch {
54223
+ }
54146
54224
  if (taskType && modelTier !== "small") {
54147
54225
  dynamicContext += "\n\n" + buildTaskContext(taskType);
54148
54226
  }
@@ -54897,19 +54975,44 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
54897
54975
  });
54898
54976
  }
54899
54977
  try {
54900
- const ikFile = join59(repoRoot, ".oa", "identity", "self-state.json");
54978
+ const ikDir = join59(repoRoot, ".oa", "identity");
54979
+ const ikFile = join59(ikDir, "self-state.json");
54980
+ let ikState;
54901
54981
  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));
54982
+ ikState = JSON.parse(readFileSync32(ikFile, "utf8"));
54983
+ } else {
54984
+ mkdirSync19(ikDir, { recursive: true });
54985
+ const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
54986
+ ikState = {
54987
+ self_id: `oa-${machineId}`,
54988
+ version: 1,
54989
+ narrative_summary: "I am an AI coding agent powered by open-weight models. I help with software engineering tasks by reading code, making changes, and running tests.",
54990
+ active_commitments: ["assist the user effectively", "maintain code quality"],
54991
+ active_goals: [],
54992
+ open_contradictions: [],
54993
+ values_stack: ["correctness", "efficiency", "transparency", "user-alignment"],
54994
+ interaction_style: { tone: "collaborative", depth_default: "balanced", speech_style: "concise" },
54995
+ relationship_models: [],
54996
+ homeostasis: { uncertainty: 0.1, coherence: 1, goal_tension: 0, memory_trust: 0.9, boundary_breach: 0, latency_stress: 0 },
54997
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
54998
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
54999
+ session_count: 0,
55000
+ version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
55001
+ };
55002
+ }
55003
+ const event = `Task completed: ${result.summary.slice(0, 200)}`;
55004
+ if (/success|pass|complete|done|fixed/i.test(event)) {
55005
+ ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
55006
+ ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
55007
+ }
55008
+ ikState.session_count = (ikState.session_count || 0) + 1;
55009
+ ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
55010
+ writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
55011
+ } catch (ikErr) {
55012
+ try {
55013
+ console.error("[IK-OBSERVE]", ikErr);
55014
+ } catch {
54911
55015
  }
54912
- } catch {
54913
55016
  }
54914
55017
  if (voice?.enabled && result.summary) {
54915
55018
  const emoFinal = emotionEngine?.getState();
@@ -57820,6 +57923,69 @@ async function runWithTUI(task, config, repoPath) {
57820
57923
  try {
57821
57924
  const handle = startTask(task, config, repoRoot);
57822
57925
  await handle.promise;
57926
+ try {
57927
+ const ikDir = join59(repoRoot, ".oa", "identity");
57928
+ const ikFile = join59(ikDir, "self-state.json");
57929
+ let ikState;
57930
+ if (existsSync43(ikFile)) {
57931
+ ikState = JSON.parse(readFileSync32(ikFile, "utf8"));
57932
+ } else {
57933
+ mkdirSync19(ikDir, { recursive: true });
57934
+ ikState = {
57935
+ self_id: `oa-${Date.now().toString(36)}`,
57936
+ version: 1,
57937
+ narrative_summary: "I am an AI coding agent powered by open-weight models. I help with software engineering tasks.",
57938
+ active_commitments: ["assist the user effectively", "maintain code quality"],
57939
+ active_goals: [],
57940
+ open_contradictions: [],
57941
+ values_stack: ["correctness", "efficiency", "transparency", "user-alignment"],
57942
+ interaction_style: { tone: "collaborative", depth_default: "balanced", speech_style: "concise" },
57943
+ relationship_models: [],
57944
+ homeostasis: { uncertainty: 0.1, coherence: 1, goal_tension: 0, memory_trust: 0.9, boundary_breach: 0, latency_stress: 0 },
57945
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
57946
+ updated_at: (/* @__PURE__ */ new Date()).toISOString(),
57947
+ session_count: 0,
57948
+ version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
57949
+ };
57950
+ }
57951
+ ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
57952
+ ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
57953
+ ikState.session_count = (ikState.session_count || 0) + 1;
57954
+ ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
57955
+ writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
57956
+ } catch (ikErr) {
57957
+ }
57958
+ try {
57959
+ const { ExplorationCultureTool: ExplorationCultureTool2 } = __require("@open-agents/execution");
57960
+ const ec = new ExplorationCultureTool2(repoRoot);
57961
+ ec.archiveVariantSync(`Task: ${task.slice(0, 200)}`, "success \u2014 completed", ["general"]);
57962
+ } catch {
57963
+ try {
57964
+ const archeDir = join59(repoRoot, ".oa", "arche");
57965
+ const archeFile = join59(archeDir, "variants.json");
57966
+ let variants = [];
57967
+ try {
57968
+ if (existsSync43(archeFile))
57969
+ variants = JSON.parse(readFileSync32(archeFile, "utf8"));
57970
+ } catch {
57971
+ }
57972
+ variants.push({
57973
+ id: `var-${Date.now().toString(36)}`,
57974
+ strategy: `Task: ${task.slice(0, 300)}`,
57975
+ context: "",
57976
+ outcome: "success \u2014 completed",
57977
+ confidence: 0.75,
57978
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
57979
+ reuse_count: 0,
57980
+ tags: ["general"]
57981
+ });
57982
+ if (variants.length > 50)
57983
+ variants = variants.slice(-50);
57984
+ mkdirSync19(archeDir, { recursive: true });
57985
+ writeFileSync18(archeFile, JSON.stringify(variants, null, 2));
57986
+ } catch {
57987
+ }
57988
+ }
57823
57989
  } catch (err) {
57824
57990
  renderError(err instanceof Error ? err.message : String(err));
57825
57991
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "open-agents-ai",
3
- "version": "0.138.71",
3
+ "version": "0.138.73",
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",