@johpaz/hive-agents 1.0.0 → 1.0.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.
Files changed (159) hide show
  1. package/README.md +25 -11
  2. package/dist/hive.js +22245 -6788
  3. package/dist/tool-worker.js +6 -2
  4. package/dist/ui/assets/{A2UIPage-D4nUFe5q.js → A2UIPage-D4nzp5NV.js} +1 -1
  5. package/dist/ui/assets/{AgentCreateForm-g1mQnIoJ.js → AgentCreateForm-M2RhjeA1.js} +1 -1
  6. package/dist/ui/assets/{AgentDetailPage-C3XkU4Ll.js → AgentDetailPage-DkFRtj8g.js} +1 -1
  7. package/dist/ui/assets/AgentNewPage-CfBU7puz.js +1 -0
  8. package/dist/ui/assets/{AgentsPage-CNA778Eo.js → AgentsPage-Ctzq2LWx.js} +1 -1
  9. package/dist/ui/assets/{ApiClientPage-t5DpKhmA.js → ApiClientPage-DKbGO1QW.js} +1 -1
  10. package/dist/ui/assets/{ChannelsPage-yY6t0YTU.js → ChannelsPage-H6rgr8DQ.js} +2 -2
  11. package/dist/ui/assets/{DashboardPage-BSeNSYg5.js → DashboardPage-BIjYGf4m.js} +2 -2
  12. package/dist/ui/assets/{LoginPage-eT5zDRDa.js → LoginPage-DazoxtBJ.js} +1 -1
  13. package/dist/ui/assets/{LogsPage-Gczzzsdh.js → LogsPage-DMZ6KtQ3.js} +1 -1
  14. package/dist/ui/assets/{MeetingPage-Bu4aMMNR.js → MeetingPage-CSLFvHL7.js} +1 -1
  15. package/dist/ui/assets/{ModelSelector-nNOrW3te.js → ModelSelector-BCfvugHB.js} +1 -1
  16. package/dist/ui/assets/{Office3DPage-B_iXEbyv.js → Office3DPage-BE6Epe0d.js} +2 -2
  17. package/dist/ui/assets/ProvidersPage-D0cApfM1.js +1 -0
  18. package/dist/ui/assets/{RecoverPage-DMqSasKk.js → RecoverPage-BVUPHG9z.js} +1 -1
  19. package/dist/ui/assets/{SettingsPage-B6FTSkOn.js → SettingsPage-DCZ4nql4.js} +1 -1
  20. package/dist/ui/assets/{SetupPage-DhcRbGgg.js → SetupPage-In19p30M.js} +1 -1
  21. package/dist/ui/assets/{WebChatPage-CWXjW4Hn.js → WebChatPage-ByVBSzxL.js} +1 -1
  22. package/dist/ui/assets/{activity-CQuPevhB.js → activity-BIIli7ET.js} +1 -1
  23. package/dist/ui/assets/{agentCapabilities-CDC6y91E.js → agentCapabilities-D1PD9yFH.js} +1 -1
  24. package/dist/ui/assets/arrow-left-BfcnX8Er.js +1 -0
  25. package/dist/ui/assets/arrow-right-Q-dzAn8k.js +1 -0
  26. package/dist/ui/assets/arrow-up-right-Bf-8wrUQ.js +1 -0
  27. package/dist/ui/assets/{calendar-Be23hQGc.js → calendar-S9-_Q6QR.js} +1 -1
  28. package/dist/ui/assets/check-CryV78SQ.js +1 -0
  29. package/dist/ui/assets/chevron-down-QCtMs-Af.js +1 -0
  30. package/dist/ui/assets/chevron-left-dTGbyl5G.js +1 -0
  31. package/dist/ui/assets/chevron-right-D0GjXbnO.js +1 -0
  32. package/dist/ui/assets/chevron-up-Cg0jO8uT.js +1 -0
  33. package/dist/ui/assets/{circle-alert-BDVHxmAz.js → circle-alert-DTVW4R94.js} +1 -1
  34. package/dist/ui/assets/circle-check-BAolxswA.js +1 -0
  35. package/dist/ui/assets/{circle-x-Cb2Yer4s.js → circle-x-CJXbXzRh.js} +1 -1
  36. package/dist/ui/assets/{copy-33tZrzc9.js → copy-X_TPpA-A.js} +1 -1
  37. package/dist/ui/assets/{dialog-KOZKWbib.js → dialog-uUBz_NIB.js} +1 -1
  38. package/dist/ui/assets/{download-CiQqqXyz.js → download-C-fXu08w.js} +1 -1
  39. package/dist/ui/assets/{earth-DCvN7ynm.js → earth-CTsVjCmp.js} +1 -1
  40. package/dist/ui/assets/{ellipsis-vertical-BybFZDk2.js → ellipsis-vertical-5zBh5yzc.js} +1 -1
  41. package/dist/ui/assets/{external-link-0iNNBvZm.js → external-link-CvpRhwC_.js} +1 -1
  42. package/dist/ui/assets/{eye-C8sKSSkg.js → eye-CM-HQEWU.js} +1 -1
  43. package/dist/ui/assets/{file-text-DO8jqiJK.js → file-text-lwkvYGtA.js} +1 -1
  44. package/dist/ui/assets/gauge-CB-cas-h.js +1 -0
  45. package/dist/ui/assets/{history-BtTD1kDo.js → history-eSHspWRr.js} +1 -1
  46. package/dist/ui/assets/index-D489S18g.css +2 -0
  47. package/dist/ui/assets/{index-Bejlp-R1.js → index-ZjAc-KQS.js} +4 -4
  48. package/dist/ui/assets/{info-mpk1tsNC.js → info-DTgFQ_jA.js} +1 -1
  49. package/dist/ui/assets/{key-CoQ0qtXt.js → key-CeM9JJkq.js} +1 -1
  50. package/dist/ui/assets/loader-circle-Dtfz4FWw.js +1 -0
  51. package/dist/ui/assets/{lock-open-Cd2aqwOd.js → lock-open-B089GUAJ.js} +1 -1
  52. package/dist/ui/assets/{mail-BG0RYSkL.js → mail--gNFIe4M.js} +1 -1
  53. package/dist/ui/assets/{pause-Cme88_9s.js → pause-DjT1nwQM.js} +1 -1
  54. package/dist/ui/assets/{pencil-f1nJ1xhs.js → pencil-6PRgdjiU.js} +1 -1
  55. package/dist/ui/assets/play-tOrP0xUJ.js +1 -0
  56. package/dist/ui/assets/plus-Cnom3j47.js +1 -0
  57. package/dist/ui/assets/{radio-B5SpKJ-J.js → radio-D-joO9J0.js} +1 -1
  58. package/dist/ui/assets/{refresh-cw-CroGQY62.js → refresh-cw-BRrzoHQW.js} +1 -1
  59. package/dist/ui/assets/search-D277MUP0.js +1 -0
  60. package/dist/ui/assets/{select-BhbW0stK.js → select-BOR8MsSL.js} +1 -1
  61. package/dist/ui/assets/{send-D6whYpw-.js → send-DIlj81PT.js} +1 -1
  62. package/dist/ui/assets/{settings-BX6q3MGB.js → settings-CkBjgAEm.js} +1 -1
  63. package/dist/ui/assets/{shield-BnGyu1xf.js → shield-U0hIjGzm.js} +1 -1
  64. package/dist/ui/assets/{sparkles-BcaOs_Jk.js → sparkles-VXHGDbNh.js} +1 -1
  65. package/dist/ui/assets/{square-ju5H8nrT.js → square-OHeetvN3.js} +1 -1
  66. package/dist/ui/assets/terminal-C6YPcJl_.js +1 -0
  67. package/dist/ui/assets/{trash-2-DjQXac_0.js → trash-2-DQxm7DUM.js} +1 -1
  68. package/dist/ui/assets/{triangle-alert-B04mgMcg.js → triangle-alert-Dj8ZhmWj.js} +1 -1
  69. package/dist/ui/assets/{useHiveAgentsModelLoad-DT5-4CCj.js → useHiveAgentsModelLoad-COLvs-Ho.js} +1 -1
  70. package/dist/ui/assets/{useProviders-DSX7eVsz.js → useProviders-q6iROeWE.js} +1 -1
  71. package/dist/ui/assets/{volume-x-qnVxkRSM.js → volume-x-Bm735CXN.js} +1 -1
  72. package/dist/ui/assets/{wifi-BA1m2dGO.js → wifi-DklBfOZ6.js} +1 -1
  73. package/dist/ui/assets/{zap-DT7cM7YS.js → zap-BEZNJ0i0.js} +1 -1
  74. package/dist/ui/index.html +8 -6
  75. package/dist/ui/logoblack.png +0 -0
  76. package/dist/ui/logocolor-dark.png +0 -0
  77. package/dist/ui/logocolorbg.png +0 -0
  78. package/dist/ui/logodoradobg.png +0 -0
  79. package/package.json +12 -8
  80. package/packages/cli/src/commands/doctor.ts +111 -0
  81. package/packages/cli/src/commands/onboard.ts +126 -59
  82. package/packages/cli/src/ui-bundle.generated.ts +9 -92
  83. package/packages/core/src/agent/acceptance-checks.ts +172 -0
  84. package/packages/core/src/agent/agent-catalog.ts +1 -37
  85. package/packages/core/src/agent/agent-loop.ts +21 -2
  86. package/packages/core/src/agent/catalog-selector.ts +0 -1
  87. package/packages/core/src/agent/compaction.ts +16 -1
  88. package/packages/core/src/agent/context-compiler.ts +3 -1
  89. package/packages/core/src/agent/conversation-store.ts +1 -1
  90. package/packages/core/src/agent/delegation-runtime.ts +1 -8
  91. package/packages/core/src/agent/goal-runner.ts +111 -32
  92. package/packages/core/src/agent/index.ts +1 -1
  93. package/packages/core/src/agent/llm-client.ts +34 -2
  94. package/packages/core/src/agent/llm-providers/anthropic.ts +10 -7
  95. package/packages/core/src/agent/llm-providers/interface.ts +13 -2
  96. package/packages/core/src/agent/llm-providers/modelscope.ts +5 -0
  97. package/packages/core/src/agent/llm-providers/z-ai.ts +5 -0
  98. package/packages/core/src/agent/minimal-loadout.ts +1 -0
  99. package/packages/core/src/agent/proof-packet.ts +2 -11
  100. package/packages/core/src/agent/providers/index.ts +1 -1
  101. package/packages/core/src/agent/tool-selector.ts +25 -1
  102. package/packages/core/src/canvas/emitter.ts +0 -44
  103. package/packages/core/src/channels/manager.ts +117 -25
  104. package/packages/core/src/channels/whatsapp.ts +6 -1
  105. package/packages/core/src/config/loader.ts +13 -1
  106. package/packages/core/src/events/channel-narration.ts +150 -0
  107. package/packages/core/src/events/tool-narration.ts +62 -0
  108. package/packages/core/src/gateway/channel-notify.ts +11 -7
  109. package/packages/core/src/gateway/delegation-groups.ts +24 -11
  110. package/packages/core/src/gateway/helpers/narration.ts +4 -62
  111. package/packages/core/src/gateway/helpers/ui-source.ts +67 -0
  112. package/packages/core/src/gateway/job-executors.ts +29 -67
  113. package/packages/core/src/gateway/resolver.ts +10 -2
  114. package/packages/core/src/gateway/routes/agents.ts +6 -6
  115. package/packages/core/src/gateway/routes/channels.ts +15 -1
  116. package/packages/core/src/gateway/routes/models.ts +69 -12
  117. package/packages/core/src/gateway/routes/providers.ts +110 -28
  118. package/packages/core/src/gateway/routes/setup.ts +63 -11
  119. package/packages/core/src/gateway/routes/system.ts +8 -5
  120. package/packages/core/src/gateway/routes/voice.ts +3 -0
  121. package/packages/core/src/gateway/server.ts +58 -28
  122. package/packages/core/src/gateway/webchat-turn.ts +29 -5
  123. package/packages/core/src/index.ts +1 -1
  124. package/packages/core/src/storage/bootstrap.ts +13 -9
  125. package/packages/core/src/storage/collections.ts +12 -46
  126. package/packages/core/src/storage/crypto.ts +147 -58
  127. package/packages/core/src/storage/hivedb.ts +9 -0
  128. package/packages/core/src/storage/model-id.ts +53 -0
  129. package/packages/core/src/storage/onboarding.ts +15 -4
  130. package/packages/core/src/storage/seed.ts +254 -138
  131. package/packages/core/src/storage/usage.ts +61 -123
  132. package/packages/core/src/tools/agents/index.ts +199 -27
  133. package/packages/core/src/tools/index.ts +2 -1
  134. package/packages/core/src/tools/web/browser-backend.ts +129 -0
  135. package/packages/core/src/tools/web/browser-service.ts +75 -35
  136. package/packages/core/src/tools/web/webview-backend.ts +412 -0
  137. package/packages/core/src/voice/index.ts +108 -17
  138. package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +2 -1
  139. package/packages/skills/src/bundled-data.generated.ts +2 -23
  140. package/dist/ui/assets/AgentNewPage-CEkLeA79.js +0 -1
  141. package/dist/ui/assets/ProvidersPage-BupHs5yO.js +0 -1
  142. package/dist/ui/assets/arrow-left-0EBE7nsF.js +0 -1
  143. package/dist/ui/assets/arrow-right-5QIaph-z.js +0 -1
  144. package/dist/ui/assets/arrow-up-right-DQQCY007.js +0 -1
  145. package/dist/ui/assets/check-Dp6tzwax.js +0 -1
  146. package/dist/ui/assets/chevron-down-33N886NY.js +0 -1
  147. package/dist/ui/assets/chevron-left-C6itJXh3.js +0 -1
  148. package/dist/ui/assets/chevron-right-CFodBS-b.js +0 -1
  149. package/dist/ui/assets/chevron-up-BvSmyBEs.js +0 -1
  150. package/dist/ui/assets/circle-check-BJWNbLuF.js +0 -1
  151. package/dist/ui/assets/gauge-BRGwuN8G.js +0 -1
  152. package/dist/ui/assets/index-XoTT41Hr.css +0 -2
  153. package/dist/ui/assets/loader-circle-BhqRN2nO.js +0 -1
  154. package/dist/ui/assets/play-CfYDHD6h.js +0 -1
  155. package/dist/ui/assets/plus-C5BxJeOX.js +0 -1
  156. package/dist/ui/assets/search-rfBcmohK.js +0 -1
  157. package/dist/ui/assets/terminal-Bjfu-TkS.js +0 -1
  158. package/packages/core/src/agent/acceptance-verifier.ts +0 -300
  159. package/packages/skills/src/bundled/agents/acceptance_verification/SKILL.md +0 -26
@@ -1,300 +0,0 @@
1
- import { col, fromIndexable, nextId, toIndexable } from "../storage/hive";
2
- import type {
3
- AgentDoc,
4
- VerificationDoc,
5
- VerificationVerdict,
6
- } from "../storage/collections";
7
- import type { AcceptanceCriterion } from "./run-store";
8
- import type { RunEpoch } from "./run-epoch";
9
- import { buildRunEpoch } from "./run-epoch";
10
- import { prepareDelegation } from "./delegation-runtime";
11
- import { runAgentIsolated } from "./agent-loop";
12
- import { inspectArtifact } from "../artifacts/store";
13
- import type { MCPClientManager } from "@johpaz/hive-agents-mcp";
14
- import { logger } from "../utils/logger";
15
-
16
- const log = logger.child("acceptance-verifier");
17
-
18
- /** ACE counters now live directly on the executor's AgentDoc row — updated for any delegated agent, catalog-seeded or not. */
19
- async function recordAgentVerdict(
20
- agentId: string | null | undefined,
21
- status: VerificationVerdict["status"],
22
- ): Promise<void> {
23
- if (!agentId) return;
24
- const agents = await col<AgentDoc>("agents");
25
- for (let attempt = 0; attempt < 3; attempt++) {
26
- const current = await agents.get(agentId);
27
- if (!current) return;
28
- try {
29
- await agents.put(agentId, {
30
- ...current.doc,
31
- helpful_count: (current.doc.helpful_count ?? 0) + (status === "verified" ? 1 : 0),
32
- harmful_count: (current.doc.harmful_count ?? 0) + (status === "verified" ? 0 : 1),
33
- updated_at: Date.now(),
34
- }, { expectedVersion: current.version });
35
- return;
36
- } catch {
37
- // Retry OCC conflicts; another verification may have updated the same
38
- // agent concurrently.
39
- }
40
- }
41
- log.warn(`[acceptance-verifier] Could not update ACE counters for ${agentId}`);
42
- }
43
-
44
- export interface VerifyAgentDeliveryInput {
45
- runId: string;
46
- taskId?: string | null;
47
- executorAgentId: string;
48
- objective: string;
49
- acceptance?: AcceptanceCriterion[] | null;
50
- delivery: string;
51
- evidence?: string[];
52
- executorEpoch?: RunEpoch | null;
53
- mcpServerIds?: string[];
54
- mcpManager?: MCPClientManager | null;
55
- }
56
-
57
- export interface ExtractedVerdict {
58
- verdict: VerificationVerdict;
59
- parseFailure: boolean;
60
- parseError: string | null;
61
- }
62
-
63
- export function extractVerdict(raw: string, criteria: AcceptanceCriterion[]): ExtractedVerdict {
64
- const fenced = raw.match(/```(?:json)?\s*([\s\S]*?)```/i)?.[1];
65
- const candidate = fenced ?? raw.slice(raw.indexOf("{"), raw.lastIndexOf("}") + 1);
66
- try {
67
- const parsed = JSON.parse(candidate) as VerificationVerdict;
68
- if (!["verified", "rejected", "needs_evidence"].includes(parsed.status)) throw new Error("invalid status");
69
- if (!Array.isArray(parsed.criterion_results)) throw new Error("criterion_results missing");
70
- const byId = new Map(parsed.criterion_results.map((result) => [result.criterion_id, result]));
71
- const normalized = criteria.map((criterion) => {
72
- const result = byId.get(criterion.id);
73
- return {
74
- criterion_id: criterion.id,
75
- met: result?.met === true,
76
- evidence: Array.isArray(result?.evidence) ? result.evidence.map(String) : [],
77
- check_used: typeof result?.check_used === "string" ? result.check_used : "independent_review",
78
- confidence: Math.max(0, Math.min(1, Number(result?.confidence) || 0)),
79
- };
80
- });
81
- const allMet = normalized.length > 0 && normalized.every((result) => result.met && result.evidence.length > 0);
82
- return {
83
- parseFailure: false,
84
- parseError: null,
85
- verdict: {
86
- status: parsed.status === "verified" && allMet ? "verified" : parsed.status === "verified" ? "needs_evidence" : parsed.status,
87
- criterion_results: normalized,
88
- summary: String(parsed.summary ?? ""),
89
- retry_guidance: parsed.retry_guidance == null ? null : String(parsed.retry_guidance),
90
- risks: Array.isArray(parsed.risks) ? parsed.risks.map(String) : [],
91
- },
92
- };
93
- } catch (err) {
94
- return {
95
- parseFailure: true,
96
- parseError: (err as Error).message,
97
- verdict: {
98
- status: "needs_evidence",
99
- criterion_results: criteria.map((criterion) => ({
100
- criterion_id: criterion.id,
101
- met: false,
102
- evidence: [],
103
- check_used: "verdict_parse_failed",
104
- confidence: 0,
105
- })),
106
- summary: `El verificador no produjo un veredicto estructurado válido: ${(err as Error).message}`,
107
- retry_guidance: "Reunir evidencia determinística y volver a verificar.",
108
- risks: ["No se autorizó reportar éxito."],
109
- },
110
- };
111
- }
112
- }
113
-
114
- function sanitizeDiagnostic(value: string, limit = 1000): string {
115
- return value
116
- .replace(/(api[_-]?key|token|authorization|secret)(["'=:\\s]+)[^\\s,}"']+/gi, "$1$2[REDACTED]")
117
- .slice(0, limit);
118
- }
119
-
120
- export async function persistVerification(input: {
121
- runId: string;
122
- taskId?: string | null;
123
- executorAgentId?: string | null;
124
- objective: string;
125
- acceptance: AcceptanceCriterion[];
126
- verdict: VerificationVerdict;
127
- executorEpoch?: RunEpoch | null;
128
- verifierEpoch?: RunEpoch | null;
129
- failureCode?: VerificationDoc["failure_code"];
130
- failureDetail?: string | null;
131
- rawOutputPreview?: string | null;
132
- verifierProvider?: string | null;
133
- verifierModel?: string | null;
134
- recordAce?: boolean;
135
- }): Promise<VerificationDoc> {
136
- const c = await col<VerificationDoc>("verifications");
137
- const previous = await c.findBy("run_id", input.runId);
138
- const id = await nextId("verifications");
139
- const doc: VerificationDoc = {
140
- id,
141
- run_id: input.runId,
142
- task_id: toIndexable(input.taskId),
143
- executor_agent_id: toIndexable(input.executorAgentId),
144
- verifier_agent_id: "acceptance_verifier",
145
- objective: input.objective,
146
- acceptance_json: JSON.stringify(input.acceptance),
147
- verdict_json: JSON.stringify(input.verdict),
148
- status: input.verdict.status,
149
- attempt: previous.length + 1,
150
- executor_epoch_json: JSON.stringify(input.executorEpoch ?? null),
151
- verifier_epoch_json: JSON.stringify(input.verifierEpoch ?? null),
152
- failure_code: input.failureCode ?? null,
153
- failure_detail: input.failureDetail ? sanitizeDiagnostic(input.failureDetail) : null,
154
- raw_output_preview: input.rawOutputPreview ? sanitizeDiagnostic(input.rawOutputPreview) : null,
155
- verifier_provider: input.verifierProvider ?? null,
156
- verifier_model: input.verifierModel ?? null,
157
- created_at: Date.now(),
158
- };
159
- await c.put(id, doc, { expectedVersion: 0 });
160
- if (input.recordAce !== false) {
161
- await recordAgentVerdict(input.executorAgentId, input.verdict.status);
162
- }
163
- return doc;
164
- }
165
-
166
- export const VERIFIER_AGENT_ID = "acceptance_verifier";
167
- const MAX_VERIFIER_OUTPUT_ATTEMPTS = 3;
168
-
169
- export async function verifyAgentDelivery(input: VerifyAgentDeliveryInput): Promise<VerificationDoc> {
170
- const agents = await col<AgentDoc>("agents");
171
- const executorEntry = await agents.get(input.executorAgentId);
172
- if (!executorEntry) throw new Error(`Executor agent not found: ${input.executorAgentId}`);
173
- if (input.executorAgentId === VERIFIER_AGENT_ID) {
174
- throw new Error("The acceptance verifier cannot verify its own delivery");
175
- }
176
-
177
- const criteria = input.acceptance?.length
178
- ? input.acceptance
179
- : [{ id: "objective", description: input.objective }];
180
- const parentAgentId = fromIndexable(executorEntry.doc.parent_id) ?? input.executorAgentId;
181
- const parentEntry = await agents.get(parentAgentId);
182
- const awake = await prepareDelegation(VERIFIER_AGENT_ID, {
183
- workspace: executorEntry.doc.workspace,
184
- taskScopedMcpServerIds: input.mcpServerIds,
185
- parentProviderId: fromIndexable(parentEntry?.doc.provider_id ?? "") || fromIndexable(executorEntry.doc.provider_id),
186
- parentModelId: fromIndexable(parentEntry?.doc.model_id ?? "") || fromIndexable(executorEntry.doc.model_id),
187
- executorModelId: fromIndexable(executorEntry.doc.model_id),
188
- mcpManager: input.mcpManager,
189
- });
190
-
191
- try {
192
- const suppliedEvidence = input.evidence ?? [];
193
- const artifactIds = new Set<string>();
194
- for (const item of suppliedEvidence) {
195
- const text = String(item);
196
- for (const match of text.matchAll(/artifact_id:\s*["']?([0-9a-f-]{36})["']?/gi)) {
197
- if (match[1]) artifactIds.add(match[1]);
198
- }
199
- }
200
- const artifactEvidence: string[] = [];
201
- for (const artifactId of artifactIds) {
202
- const inspection = await inspectArtifact(artifactId);
203
- artifactEvidence.push(`artifact_inspect(${artifactId}): ${JSON.stringify(inspection)}`);
204
- log.info(`[acceptance-verifier] Inspected managed artifact ${artifactId} (ok=${inspection.ok === true})`);
205
- }
206
- const evidence = [...suppliedEvidence, ...artifactEvidence];
207
- const task = `Auditá independientemente esta entrega.
208
-
209
- OBJETIVO:
210
- ${input.objective}
211
-
212
- CRITERIOS:
213
- ${criteria.map((criterion) => `- ${criterion.id}: ${criterion.description}${criterion.checkTool ? ` (check sugerido: ${criterion.checkTool})` : ""}`).join("\n")}
214
-
215
- ENTREGA DEL EJECUTOR:
216
- ${input.delivery}
217
-
218
- EVIDENCIA ADJUNTA:
219
- ${evidence.map((item) => `- ${item}`).join("\n") || "- ninguna"}
220
-
221
- No confíes en la afirmación del ejecutor. Usá únicamente tools read-only si necesitás inspeccionar artefactos. Si la evidencia contiene artifact_id, inspeccionalo con artifact_inspect; no lo reemplaces por una búsqueda de archivos en el workspace. Devolvé JSON estricto:
222
- {"status":"verified|rejected|needs_evidence","criterion_results":[{"criterion_id":"...","met":true,"evidence":["..."],"check_used":"...","confidence":0.0}],"summary":"...","retry_guidance":null,"risks":[]}`;
223
-
224
- const verifierAgent = await agents.get(VERIFIER_AGENT_ID);
225
- const verifierEpoch = verifierAgent
226
- ? buildRunEpoch({
227
- provider: awake.providerId,
228
- model: awake.modelId,
229
- toolNames: awake.toolNames,
230
- })
231
- : null;
232
-
233
- let lastVerification: VerificationDoc | null = null;
234
- for (let attempt = 1; attempt <= MAX_VERIFIER_OUTPUT_ATTEMPTS; attempt++) {
235
- let raw = "";
236
- let runError: string | null = null;
237
- try {
238
- raw = await runAgentIsolated({
239
- agentId: VERIFIER_AGENT_ID,
240
- taskDescription: attempt === 1
241
- ? task
242
- : `${task}\n\nINTENTO DE FORMATO ${attempt}: la salida anterior fue inválida. Respondé con un único objeto JSON compacto, sin markdown ni texto adicional.`,
243
- threadId: `verify-${input.runId}-${Date.now()}-${attempt}`,
244
- mcpManager: input.mcpManager,
245
- });
246
- } catch (err) {
247
- runError = (err as Error).message;
248
- log.warn(`[acceptance-verifier] Independent run attempt ${attempt} failed closed: ${runError}`);
249
- }
250
-
251
- const extracted = extractVerdict(raw, criteria);
252
- const failureCode: VerificationDoc["failure_code"] = runError
253
- ? "verifier_error"
254
- : extracted.parseFailure
255
- ? "invalid_output"
256
- : null;
257
- const failureDetail = runError ?? extracted.parseError;
258
-
259
- lastVerification = await persistVerification({
260
- runId: input.runId,
261
- taskId: input.taskId,
262
- executorAgentId: input.executorAgentId,
263
- objective: input.objective,
264
- acceptance: criteria,
265
- verdict: extracted.verdict,
266
- executorEpoch: input.executorEpoch,
267
- verifierEpoch,
268
- failureCode,
269
- failureDetail,
270
- rawOutputPreview: raw,
271
- verifierProvider: awake.providerId,
272
- verifierModel: awake.modelId,
273
- recordAce: false,
274
- });
275
-
276
- if (!failureCode) {
277
- await recordAgentVerdict(input.executorAgentId, extracted.verdict.status);
278
- return lastVerification;
279
- }
280
- }
281
-
282
- if (!lastVerification) throw new Error("Acceptance verifier produced no result");
283
- // Every attempt failed on the verifier's side (it errored or never
284
- // produced parseable output). The delivery is still not verified — the
285
- // caller sees that in the returned verdict — but the executor is not the
286
- // one that misbehaved, so its ACE counters stay untouched: charging it
287
- // here punishes an agent for the auditor being broken.
288
- log.warn(`[acceptance-verifier] Verification of run ${input.runId} failed on the verifier side (${lastVerification.failure_code}) — not counted against ${input.executorAgentId}`);
289
- return lastVerification;
290
- } finally {
291
- await awake.release();
292
- }
293
- }
294
-
295
- export async function getVerifiedVerification(id: string, runId?: string): Promise<VerificationDoc | null> {
296
- const entry = await (await col<VerificationDoc>("verifications")).get(id);
297
- if (!entry || entry.doc.status !== "verified") return null;
298
- if (runId && entry.doc.run_id !== runId) return null;
299
- return entry.doc;
300
- }
@@ -1,26 +0,0 @@
1
- ---
2
- name: acceptance_verification
3
- description: "Independently verify acceptance criteria before Hive reports a delegated or effectful task as complete"
4
- version: 1.0.0
5
- author: Hive Team
6
- icon: "✅"
7
- category: agents
8
- permissions: [filesystem_read]
9
- dependencies: []
10
- tools: [fs_read, fs_exists, fs_list, web_fetch, browser_navigate, browser_extract, browser_screenshot, office_leer_pdf, office_leer_docx, office_leer_xlsx, office_leer_pptx, cron.list, cron.history, task_status]
11
- triggers: [verificar cumplimiento, acceptance gate, audit result, proof packet]
12
- preferred_agents: [acceptance_verifier]
13
- ---
14
-
15
- # Verificación independiente
16
-
17
- Evalúa cada criterio por separado. Una afirmación del ejecutor no es evidencia independiente.
18
-
19
- Orden de preferencia:
20
-
21
- 1. Check determinístico.
22
- 2. Readback seguro del estado final.
23
- 3. Inspección directa del artefacto.
24
- 4. Evidencia trazada y consistente.
25
-
26
- Devuelve `verified` únicamente cuando todos los criterios estén demostrados. Usa `needs_evidence` cuando podría demostrarse con información adicional y `rejected` cuando la evidencia contradiga el objetivo. Nunca repares la tarea.