open-agents-ai 0.138.72 → 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.
- package/dist/index.js +112 -16
- 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
|
}
|
|
@@ -54922,7 +55000,6 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
54922
55000
|
version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
|
|
54923
55001
|
};
|
|
54924
55002
|
}
|
|
54925
|
-
console.error("[IK-DEBUG] Creating/updating identity at", ikFile, "exists:", existsSync43(ikFile));
|
|
54926
55003
|
const event = `Task completed: ${result.summary.slice(0, 200)}`;
|
|
54927
55004
|
if (/success|pass|complete|done|fixed/i.test(event)) {
|
|
54928
55005
|
ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
|
|
@@ -57845,7 +57922,7 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
57845
57922
|
renderUserMessage(task);
|
|
57846
57923
|
try {
|
|
57847
57924
|
const handle = startTask(task, config, repoRoot);
|
|
57848
|
-
|
|
57925
|
+
await handle.promise;
|
|
57849
57926
|
try {
|
|
57850
57927
|
const ikDir = join59(repoRoot, ".oa", "identity");
|
|
57851
57928
|
const ikFile = join59(ikDir, "self-state.json");
|
|
@@ -57871,24 +57948,43 @@ async function runWithTUI(task, config, repoPath) {
|
|
|
57871
57948
|
version_history: [{ version: 1, change: "Initial identity creation", timestamp: (/* @__PURE__ */ new Date()).toISOString() }]
|
|
57872
57949
|
};
|
|
57873
57950
|
}
|
|
57874
|
-
|
|
57875
|
-
|
|
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
|
-
}
|
|
57951
|
+
ikState.homeostasis.uncertainty = Math.max(0, ikState.homeostasis.uncertainty - 0.1);
|
|
57952
|
+
ikState.homeostasis.coherence = Math.min(1, ikState.homeostasis.coherence + 0.05);
|
|
57882
57953
|
ikState.session_count = (ikState.session_count || 0) + 1;
|
|
57883
57954
|
ikState.updated_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
57884
|
-
process.stderr.write(`[identity] WRITING to ${ikFile}
|
|
57885
|
-
`);
|
|
57886
57955
|
writeFileSync18(ikFile, JSON.stringify(ikState, null, 2));
|
|
57887
|
-
process.stderr.write(`[identity] WRITTEN successfully
|
|
57888
|
-
`);
|
|
57889
57956
|
} catch (ikErr) {
|
|
57890
|
-
|
|
57891
|
-
|
|
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
|
+
}
|
|
57892
57988
|
}
|
|
57893
57989
|
} catch (err) {
|
|
57894
57990
|
renderError(err instanceof Error ? err.message : String(err));
|
package/package.json
CHANGED