@everworker/oneringai 0.4.0 → 0.4.1
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.cjs +134 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +134 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14505,7 +14505,7 @@ var PRIORITY_VALUES = {
|
|
|
14505
14505
|
};
|
|
14506
14506
|
var DEFAULT_CONFIG = {
|
|
14507
14507
|
maxEntries: 20,
|
|
14508
|
-
maxTotalTokens:
|
|
14508
|
+
maxTotalTokens: 4e4,
|
|
14509
14509
|
defaultPriority: "normal",
|
|
14510
14510
|
showTimestamps: false
|
|
14511
14511
|
};
|
|
@@ -16690,7 +16690,7 @@ var StrategyRegistry = class {
|
|
|
16690
16690
|
// src/core/context-nextgen/types.ts
|
|
16691
16691
|
var DEFAULT_FEATURES = {
|
|
16692
16692
|
workingMemory: true,
|
|
16693
|
-
inContextMemory:
|
|
16693
|
+
inContextMemory: true,
|
|
16694
16694
|
persistentInstructions: false,
|
|
16695
16695
|
userInfo: false
|
|
16696
16696
|
};
|
|
@@ -23931,6 +23931,12 @@ function defaultTaskPrompt(task) {
|
|
|
23931
23931
|
}
|
|
23932
23932
|
parts.push("");
|
|
23933
23933
|
}
|
|
23934
|
+
if (task.dependsOn.length > 0) {
|
|
23935
|
+
parts.push("Note: Results from prerequisite tasks are available in your live context.");
|
|
23936
|
+
parts.push("Small results appear directly; larger results are in working memory \u2014 use memory_retrieve to access them.");
|
|
23937
|
+
parts.push("Review the plan overview and dependency results before starting.");
|
|
23938
|
+
parts.push("");
|
|
23939
|
+
}
|
|
23934
23940
|
parts.push("After completing the work, store key results in memory once, then respond with a text summary (no more tool calls).");
|
|
23935
23941
|
return parts.join("\n");
|
|
23936
23942
|
}
|
|
@@ -24014,6 +24020,127 @@ async function collectValidationContext(agent, responseText) {
|
|
|
24014
24020
|
toolCallLog
|
|
24015
24021
|
};
|
|
24016
24022
|
}
|
|
24023
|
+
function estimateTokens(text) {
|
|
24024
|
+
return Math.ceil(text.length / 4);
|
|
24025
|
+
}
|
|
24026
|
+
function buildPlanOverview(execution, definition, currentTaskId) {
|
|
24027
|
+
const parts = [];
|
|
24028
|
+
const progress = execution.progress ?? 0;
|
|
24029
|
+
parts.push(`Routine: ${definition.name}`);
|
|
24030
|
+
if (definition.description) {
|
|
24031
|
+
parts.push(`Goal: ${definition.description}`);
|
|
24032
|
+
}
|
|
24033
|
+
parts.push(`Progress: ${Math.round(progress * 100)}%`);
|
|
24034
|
+
parts.push("");
|
|
24035
|
+
parts.push("Tasks:");
|
|
24036
|
+
for (const task of execution.plan.tasks) {
|
|
24037
|
+
let statusIcon;
|
|
24038
|
+
switch (task.status) {
|
|
24039
|
+
case "completed":
|
|
24040
|
+
statusIcon = "[x]";
|
|
24041
|
+
break;
|
|
24042
|
+
case "in_progress":
|
|
24043
|
+
statusIcon = "[>]";
|
|
24044
|
+
break;
|
|
24045
|
+
case "failed":
|
|
24046
|
+
statusIcon = "[!]";
|
|
24047
|
+
break;
|
|
24048
|
+
case "skipped":
|
|
24049
|
+
statusIcon = "[-]";
|
|
24050
|
+
break;
|
|
24051
|
+
default:
|
|
24052
|
+
statusIcon = "[ ]";
|
|
24053
|
+
}
|
|
24054
|
+
let line = `${statusIcon} ${task.name}`;
|
|
24055
|
+
if (task.dependsOn.length > 0) {
|
|
24056
|
+
const depNames = task.dependsOn.map((depId) => execution.plan.tasks.find((t) => t.id === depId)?.name ?? depId).join(", ");
|
|
24057
|
+
line += ` (after: ${depNames})`;
|
|
24058
|
+
}
|
|
24059
|
+
if (task.id === currentTaskId) {
|
|
24060
|
+
line += " \u2190 CURRENT";
|
|
24061
|
+
}
|
|
24062
|
+
parts.push(line);
|
|
24063
|
+
}
|
|
24064
|
+
return parts.join("\n");
|
|
24065
|
+
}
|
|
24066
|
+
async function injectRoutineContext(agent, execution, definition, currentTask) {
|
|
24067
|
+
const icmPlugin = agent.context.getPlugin("in_context_memory");
|
|
24068
|
+
const wmPlugin = agent.context.memory;
|
|
24069
|
+
if (!icmPlugin && !wmPlugin) {
|
|
24070
|
+
exports.logger.warn("injectRoutineContext: No ICM or WM plugin available \u2014 skipping context injection");
|
|
24071
|
+
return;
|
|
24072
|
+
}
|
|
24073
|
+
const planOverview = buildPlanOverview(execution, definition, currentTask.id);
|
|
24074
|
+
if (icmPlugin) {
|
|
24075
|
+
icmPlugin.set("__routine_plan", "Routine plan overview with task statuses", planOverview, "high");
|
|
24076
|
+
}
|
|
24077
|
+
if (icmPlugin) {
|
|
24078
|
+
for (const entry of icmPlugin.list()) {
|
|
24079
|
+
if (entry.key.startsWith("__dep_result_") || entry.key === "__routine_deps") {
|
|
24080
|
+
icmPlugin.delete(entry.key);
|
|
24081
|
+
}
|
|
24082
|
+
}
|
|
24083
|
+
}
|
|
24084
|
+
if (wmPlugin) {
|
|
24085
|
+
const { entries: wmEntries } = await wmPlugin.query();
|
|
24086
|
+
for (const entry of wmEntries) {
|
|
24087
|
+
if (entry.key.startsWith("__dep_result_") || entry.key.startsWith("findings/__dep_result_")) {
|
|
24088
|
+
await wmPlugin.delete(entry.key);
|
|
24089
|
+
}
|
|
24090
|
+
}
|
|
24091
|
+
}
|
|
24092
|
+
if (currentTask.dependsOn.length === 0) return;
|
|
24093
|
+
const inContextDeps = [];
|
|
24094
|
+
const workingMemoryDeps = [];
|
|
24095
|
+
for (const depId of currentTask.dependsOn) {
|
|
24096
|
+
const depTask = execution.plan.tasks.find((t) => t.id === depId);
|
|
24097
|
+
if (!depTask?.result?.output) continue;
|
|
24098
|
+
const output = typeof depTask.result.output === "string" ? depTask.result.output : JSON.stringify(depTask.result.output);
|
|
24099
|
+
const tokens = estimateTokens(output);
|
|
24100
|
+
const depKey = `__dep_result_${depId}`;
|
|
24101
|
+
const depLabel = `Result from task "${depTask.name}"`;
|
|
24102
|
+
if (tokens < 5e3 && icmPlugin) {
|
|
24103
|
+
icmPlugin.set(depKey, depLabel, output, "high");
|
|
24104
|
+
inContextDeps.push(depTask.name);
|
|
24105
|
+
} else if (wmPlugin) {
|
|
24106
|
+
await wmPlugin.store(depKey, depLabel, output, { tier: "findings" });
|
|
24107
|
+
workingMemoryDeps.push(depTask.name);
|
|
24108
|
+
} else if (icmPlugin) {
|
|
24109
|
+
const truncated = output.slice(0, 2e4) + "\n... (truncated, full result not available)";
|
|
24110
|
+
icmPlugin.set(depKey, depLabel, truncated, "high");
|
|
24111
|
+
inContextDeps.push(depTask.name + " (truncated)");
|
|
24112
|
+
}
|
|
24113
|
+
}
|
|
24114
|
+
if (icmPlugin && (inContextDeps.length > 0 || workingMemoryDeps.length > 0)) {
|
|
24115
|
+
const summaryParts = ["Dependency results available:"];
|
|
24116
|
+
if (inContextDeps.length > 0) {
|
|
24117
|
+
summaryParts.push(`In context (visible now): ${inContextDeps.join(", ")}`);
|
|
24118
|
+
}
|
|
24119
|
+
if (workingMemoryDeps.length > 0) {
|
|
24120
|
+
summaryParts.push(`In working memory (use memory_retrieve): ${workingMemoryDeps.join(", ")}`);
|
|
24121
|
+
}
|
|
24122
|
+
icmPlugin.set("__routine_deps", "Dependency results location guide", summaryParts.join("\n"), "high");
|
|
24123
|
+
}
|
|
24124
|
+
}
|
|
24125
|
+
async function cleanupRoutineContext(agent) {
|
|
24126
|
+
const icmPlugin = agent.context.getPlugin("in_context_memory");
|
|
24127
|
+
const wmPlugin = agent.context.memory;
|
|
24128
|
+
if (icmPlugin) {
|
|
24129
|
+
for (const entry of icmPlugin.list()) {
|
|
24130
|
+
if (entry.key.startsWith("__routine_") || entry.key.startsWith("__dep_result_")) {
|
|
24131
|
+
icmPlugin.delete(entry.key);
|
|
24132
|
+
}
|
|
24133
|
+
}
|
|
24134
|
+
}
|
|
24135
|
+
if (wmPlugin) {
|
|
24136
|
+
const { entries: wmEntries } = await wmPlugin.query();
|
|
24137
|
+
for (const entry of wmEntries) {
|
|
24138
|
+
if (entry.key.startsWith("__dep_result_") || entry.key.startsWith("findings/__dep_result_")) {
|
|
24139
|
+
await wmPlugin.delete(entry.key);
|
|
24140
|
+
}
|
|
24141
|
+
}
|
|
24142
|
+
}
|
|
24143
|
+
}
|
|
24017
24144
|
async function validateTaskCompletion(agent, task, responseText, validationPromptBuilder) {
|
|
24018
24145
|
const hasExplicitValidation = task.validation?.skipReflection === false && task.validation?.completionCriteria && task.validation.completionCriteria.length > 0;
|
|
24019
24146
|
if (!hasExplicitValidation) {
|
|
@@ -24159,6 +24286,7 @@ async function executeRoutine(options) {
|
|
|
24159
24286
|
};
|
|
24160
24287
|
agent.registerHook("pause:check", iterationLimiter);
|
|
24161
24288
|
const getTask = () => execution.plan.tasks[taskIndex];
|
|
24289
|
+
await injectRoutineContext(agent, execution, definition, getTask());
|
|
24162
24290
|
while (!taskCompleted) {
|
|
24163
24291
|
try {
|
|
24164
24292
|
const taskPrompt = buildTaskPrompt(getTask());
|
|
@@ -24261,6 +24389,10 @@ async function executeRoutine(options) {
|
|
|
24261
24389
|
);
|
|
24262
24390
|
return execution;
|
|
24263
24391
|
} finally {
|
|
24392
|
+
try {
|
|
24393
|
+
await cleanupRoutineContext(agent);
|
|
24394
|
+
} catch {
|
|
24395
|
+
}
|
|
24264
24396
|
for (const { name, hook } of registeredHooks) {
|
|
24265
24397
|
try {
|
|
24266
24398
|
agent.unregisterHook(name, hook);
|