@myvillage/cli 1.85.0 → 1.85.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myvillage/cli",
3
- "version": "1.85.0",
3
+ "version": "1.85.2",
4
4
  "description": "MyVillageOS CLI for community developers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -635,6 +635,25 @@ const ACTION_TOOLS = new Set([
635
635
  'task_assign',
636
636
  'task_complete',
637
637
  'task_retry',
638
+ // Curriculum actions — creating/assigning activities and projects is real,
639
+ // externally-visible work. Without these, a curriculum-generator agent that
640
+ // successfully creates and assigns activities scores zero successful action
641
+ // tools, so any incidental flagged result marks the whole task FAILED.
642
+ 'activity_create',
643
+ 'activity_assign',
644
+ 'activity_update',
645
+ 'activity_delete',
646
+ 'project_create',
647
+ 'project_update',
648
+ 'project_delete',
649
+ ]);
650
+
651
+ // Read-only lookups whose "not found" result is an expected empty read, not a
652
+ // failure. A missing agent_memory_get key is normal the first time an agent
653
+ // touches a villager and must not be treated as a task-failing tool error.
654
+ const BENIGN_NOT_FOUND_TOOLS = new Set([
655
+ 'agent_memory_get',
656
+ 'agent_memory_list',
638
657
  ]);
639
658
 
640
659
  function flattenToolResultText(tr) {
@@ -666,6 +685,14 @@ function isToolResultError(tr) {
666
685
  // "the user was unauthorized to do X" because we anchor on word boundaries.
667
686
  const text = flattenToolResultText(tr);
668
687
  if (!text) return false;
688
+ // A memory/lookup read that misses is an expected empty result, not an
689
+ // error. agent_memory_get returns "Memory key ... not found" the first time
690
+ // an agent touches a villager; flagging that would fail the whole task even
691
+ // though nothing went wrong. Real transport errors on these tools still set
692
+ // the explicit isError flag handled above, so they are unaffected.
693
+ if (BENIGN_NOT_FOUND_TOOLS.has(tr.toolName) && /\bnot found\b/i.test(text)) {
694
+ return false;
695
+ }
669
696
  return /\b(40[0-9]|50[0-9])\b/.test(text) ||
670
697
  /\b(not found|unauthorized|forbidden|invalid|insufficient_quota|authentication failed)\b/i.test(text);
671
698
  }
package/src/utils/api.js CHANGED
@@ -689,11 +689,24 @@ export async function claimAgentTask(villageAgentId, taskId) {
689
689
  // otherwise the task is marked COMPLETED with the given `output`.
690
690
  export async function completeAgentTask(villageAgentId, taskId, data = {}) {
691
691
  const client = getPlatformClient();
692
- const response = await client.post(
693
- `/village-agents/${encodeURIComponent(villageAgentId)}/tasks/${encodeURIComponent(taskId)}/complete`,
694
- data,
695
- );
696
- return response.data;
692
+ try {
693
+ const response = await client.post(
694
+ `/village-agents/${encodeURIComponent(villageAgentId)}/tasks/${encodeURIComponent(taskId)}/complete`,
695
+ data,
696
+ );
697
+ return response.data;
698
+ } catch (err) {
699
+ // Idempotent completion. The task may already be terminal because the agent
700
+ // completed it itself via the `agent_task_complete` tool during its run (the
701
+ // daemon also completes the active task at the end of each iteration), or a
702
+ // retry raced. A 409 "already terminal" means the task reached the end state
703
+ // we wanted — treat it as success rather than a failure so the daemon doesn't
704
+ // log a spurious "Failed to mark task complete" error every run.
705
+ if (err?.response?.status === 409) {
706
+ return { alreadyTerminal: true, message: err.response?.data?.error };
707
+ }
708
+ throw err;
709
+ }
697
710
  }
698
711
 
699
712
  // Retry a single FAILED or CANCELLED task: resets it to PENDING so the