@workermill/agent 0.2.1 → 0.2.2

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/planner.js +26 -3
  2. package/package.json +1 -1
package/dist/planner.js CHANGED
@@ -260,6 +260,9 @@ export async function planTask(task, config) {
260
260
  let currentPrompt = basePrompt;
261
261
  let bestPlan = null;
262
262
  let bestScore = 0;
263
+ // Track critic history across iterations for analytics
264
+ const criticHistory = [];
265
+ let totalFileCapTruncations = 0;
263
266
  for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
264
267
  const iterLabel = MAX_ITERATIONS > 1 ? ` (attempt ${iteration}/${MAX_ITERATIONS})` : "";
265
268
  if (iteration > 1) {
@@ -299,6 +302,7 @@ export async function planTask(task, config) {
299
302
  // 2c. Apply file cap (max 5 files per story)
300
303
  const { truncatedCount, details } = applyFileCap(plan);
301
304
  if (truncatedCount > 0) {
305
+ totalFileCapTruncations += truncatedCount;
302
306
  const msg = `${PREFIX} File cap applied: ${truncatedCount} stories truncated to max 5 targetFiles`;
303
307
  console.log(`${ts()} ${taskLabel} ${chalk.yellow("⚠")} ${msg}`);
304
308
  await postLog(task.id, msg);
@@ -319,13 +323,25 @@ export async function planTask(task, config) {
319
323
  // Critic failed entirely — use this plan as fallback
320
324
  bestPlan = plan;
321
325
  }
326
+ // Record critic history for this iteration
327
+ if (criticResult) {
328
+ criticHistory.push({
329
+ iteration,
330
+ score: criticResult.score,
331
+ approved: criticResult.approved || criticResult.score >= AUTO_APPROVAL_THRESHOLD,
332
+ risks: criticResult.risks,
333
+ suggestions: criticResult.suggestions,
334
+ filesCapApplied: truncatedCount > 0 ? truncatedCount : undefined,
335
+ });
336
+ }
322
337
  // 2e. Check critic result
323
338
  if (!criticResult) {
324
339
  // Critic failed (timeout, parse error, etc.) — post plan without critic gate
325
340
  const msg = `${PREFIX} Critic validation failed — posting plan without critic score`;
326
341
  console.log(`${ts()} ${taskLabel} ${chalk.yellow("⚠")} ${msg}`);
327
342
  await postLog(task.id, msg);
328
- return await postValidatedPlan(task.id, plan, config.agentId, taskLabel, elapsed);
343
+ const planningDurationMs = Date.now() - startTime;
344
+ return await postValidatedPlan(task.id, plan, config.agentId, taskLabel, elapsed, undefined, undefined, criticHistory, totalFileCapTruncations, planningDurationMs, iteration);
329
345
  }
330
346
  if (criticResult.approved || criticResult.score >= AUTO_APPROVAL_THRESHOLD) {
331
347
  // Approved! Post the file-capped plan
@@ -337,7 +353,8 @@ export async function planTask(task, config) {
337
353
  console.log(`${ts()} ${taskLabel} ${chalk.dim(risksMsg)}`);
338
354
  await postLog(task.id, risksMsg);
339
355
  }
340
- return await postValidatedPlan(task.id, plan, config.agentId, taskLabel, elapsed);
356
+ const planningDurationMs = Date.now() - startTime;
357
+ return await postValidatedPlan(task.id, plan, config.agentId, taskLabel, elapsed, criticResult.score, criticResult.risks, criticHistory, totalFileCapTruncations, planningDurationMs, iteration);
341
358
  }
342
359
  // 2f. Rejected — append critic feedback for next iteration
343
360
  if (iteration < MAX_ITERATIONS) {
@@ -382,13 +399,19 @@ export async function planTask(task, config) {
382
399
  * Re-serializes the plan as a JSON code block since the server-side
383
400
  * parseExecutionPlan() expects that format.
384
401
  */
385
- async function postValidatedPlan(taskId, plan, agentId, taskLabel, elapsed) {
402
+ async function postValidatedPlan(taskId, plan, agentId, taskLabel, elapsed, criticScore, criticRisks, criticHistory, fileCapTruncations, planningDurationMs, criticIterations) {
386
403
  const serialized = serializePlan(plan);
387
404
  try {
388
405
  const result = await api.post("/api/agent/plan-result", {
389
406
  taskId,
390
407
  rawOutput: serialized,
391
408
  agentId,
409
+ criticScore,
410
+ criticRisks,
411
+ criticHistory,
412
+ criticIterations,
413
+ fileCapTruncations,
414
+ planningDurationMs,
392
415
  });
393
416
  const storyCount = result.data.storyCount;
394
417
  console.log(`${ts()} ${taskLabel} ${chalk.green("✓")} Plan validated: ${chalk.bold(storyCount)} stories → ${chalk.green("queued")}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workermill/agent",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "WorkerMill Remote Agent - Run AI workers locally with your Claude Max subscription",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",