@hilbras/omninode 2.0.0-alpha.8 → 2.0.0-alpha.9

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.d.ts CHANGED
@@ -4,27 +4,72 @@ import { ChildProcess } from 'node:child_process';
4
4
  /** Structured report format so reports can be processed programmatically (§16). */
5
5
  type Confidence = "low" | "medium" | "high";
6
6
  type FindingSeverity = "info" | "low" | "medium" | "high" | "critical";
7
+ /** Typed evidence (roadmap §13, Evidence). Plain strings remain accepted
8
+ * and normalize to `observation` evidence. */
9
+ type EvidenceKind = "file" | "line" | "url" | "command" | "observation" | "artifact";
10
+ interface Evidence {
11
+ kind: EvidenceKind;
12
+ /** Path, URL, command or logical reference. */
13
+ ref?: string;
14
+ /** Line number for file/line evidence. */
15
+ line?: number;
16
+ /** Verbatim excerpt backing the finding. */
17
+ excerpt?: string;
18
+ /** Agent that produced the evidence. */
19
+ agent?: string;
20
+ }
21
+ type EvidenceInput = string | Evidence;
22
+ /** Artifact produced alongside a report (§13). */
23
+ interface ReportArtifact {
24
+ kind: "file" | "patch" | "log" | "screenshot" | "document" | "data";
25
+ ref: string;
26
+ description?: string;
27
+ mediaType?: string;
28
+ bytes?: number;
29
+ }
30
+ /** Where a finding came from, when known. */
31
+ interface FindingOrigin {
32
+ agent?: string;
33
+ reportId?: string;
34
+ pipelineRunId?: string;
35
+ }
7
36
  interface Finding {
8
37
  id: string;
9
38
  title: string;
39
+ /** v1 field, kept for compatibility; `description` is the v2 field. */
10
40
  detail: string;
41
+ /** Full description of the finding (§13, Findings). */
42
+ description?: string;
11
43
  severity?: FindingSeverity;
12
- evidence?: string[];
44
+ confidence?: Confidence;
45
+ evidence?: EvidenceInput[];
13
46
  /** File path or conceptual location the finding refers to. */
14
47
  location?: string;
15
48
  tags?: string[];
49
+ /** Provenance of the finding, when known (§13). */
50
+ source?: FindingOrigin;
51
+ /** The concrete fix this finding implies. */
52
+ recommendation?: string;
16
53
  }
17
54
  interface Report {
18
55
  id: string;
19
56
  taskId: string;
20
57
  /** Agent name from the agent registry. */
21
58
  agent: string;
59
+ /** v2 spelling of `agent` for machine consumers (§13). */
60
+ agentId?: string;
61
+ /** Pipeline run that produced this report, when applicable. */
62
+ pipelineRunId?: string;
22
63
  /** Model id used, if known. */
23
64
  model?: string;
24
65
  summary: string;
25
66
  findings: Finding[];
26
67
  recommendations: string[];
27
68
  confidence?: Confidence;
69
+ /** Report-level evidence backing the summary. */
70
+ evidence?: EvidenceInput[];
71
+ /** Artifacts produced with the report (§13, Artifacts). */
72
+ artifacts?: ReportArtifact[];
28
73
  createdAt: string;
29
74
  metadata?: Record<string, unknown>;
30
75
  }
@@ -42,7 +87,9 @@ interface AggregatedFinding {
42
87
  occurrences: number;
43
88
  /** Highest severity seen across merged duplicates. */
44
89
  severity?: FindingSeverity;
45
- evidence: string[];
90
+ confidence?: Confidence;
91
+ /** Typed evidence, normalized from strings when reports were ingested. */
92
+ evidence: Evidence[];
46
93
  }
47
94
  interface AggregatedRecommendation {
48
95
  text: string;
@@ -898,9 +945,9 @@ declare const agentConfigSchema: z.ZodObject<{
898
945
  name: string;
899
946
  type: "native" | "process" | "cli";
900
947
  input_mode: "protocol" | "stdin" | "arg";
948
+ command?: string | undefined;
901
949
  metadata?: Record<string, unknown> | undefined;
902
950
  timeout_ms?: number | undefined;
903
- command?: string | undefined;
904
951
  args?: string[] | undefined;
905
952
  cwd?: string | undefined;
906
953
  env?: Record<string, string> | undefined;
@@ -912,10 +959,10 @@ declare const agentConfigSchema: z.ZodObject<{
912
959
  allow_external_cwd?: boolean | undefined;
913
960
  }, {
914
961
  name: string;
962
+ command?: string | undefined;
915
963
  metadata?: Record<string, unknown> | undefined;
916
964
  type?: "native" | "process" | "cli" | undefined;
917
965
  timeout_ms?: number | undefined;
918
- command?: string | undefined;
919
966
  args?: string[] | undefined;
920
967
  cwd?: string | undefined;
921
968
  env?: Record<string, string> | undefined;
@@ -1111,9 +1158,9 @@ declare const projectConfigSchema: z.ZodObject<{
1111
1158
  name: string;
1112
1159
  type: "native" | "process" | "cli";
1113
1160
  input_mode: "protocol" | "stdin" | "arg";
1161
+ command?: string | undefined;
1114
1162
  metadata?: Record<string, unknown> | undefined;
1115
1163
  timeout_ms?: number | undefined;
1116
- command?: string | undefined;
1117
1164
  args?: string[] | undefined;
1118
1165
  cwd?: string | undefined;
1119
1166
  env?: Record<string, string> | undefined;
@@ -1125,10 +1172,10 @@ declare const projectConfigSchema: z.ZodObject<{
1125
1172
  allow_external_cwd?: boolean | undefined;
1126
1173
  }, {
1127
1174
  name: string;
1175
+ command?: string | undefined;
1128
1176
  metadata?: Record<string, unknown> | undefined;
1129
1177
  type?: "native" | "process" | "cli" | undefined;
1130
1178
  timeout_ms?: number | undefined;
1131
- command?: string | undefined;
1132
1179
  args?: string[] | undefined;
1133
1180
  cwd?: string | undefined;
1134
1181
  env?: Record<string, string> | undefined;
@@ -1268,9 +1315,9 @@ declare const projectConfigSchema: z.ZodObject<{
1268
1315
  name: string;
1269
1316
  type: "native" | "process" | "cli";
1270
1317
  input_mode: "protocol" | "stdin" | "arg";
1318
+ command?: string | undefined;
1271
1319
  metadata?: Record<string, unknown> | undefined;
1272
1320
  timeout_ms?: number | undefined;
1273
- command?: string | undefined;
1274
1321
  args?: string[] | undefined;
1275
1322
  cwd?: string | undefined;
1276
1323
  env?: Record<string, string> | undefined;
@@ -1332,10 +1379,10 @@ declare const projectConfigSchema: z.ZodObject<{
1332
1379
  name: string;
1333
1380
  agents?: {
1334
1381
  name: string;
1382
+ command?: string | undefined;
1335
1383
  metadata?: Record<string, unknown> | undefined;
1336
1384
  type?: "native" | "process" | "cli" | undefined;
1337
1385
  timeout_ms?: number | undefined;
1338
- command?: string | undefined;
1339
1386
  args?: string[] | undefined;
1340
1387
  cwd?: string | undefined;
1341
1388
  env?: Record<string, string> | undefined;
@@ -1447,9 +1494,9 @@ declare const appConfigSchema: z.ZodObject<{
1447
1494
  name: string;
1448
1495
  type: "native" | "process" | "cli";
1449
1496
  input_mode: "protocol" | "stdin" | "arg";
1497
+ command?: string | undefined;
1450
1498
  metadata?: Record<string, unknown> | undefined;
1451
1499
  timeout_ms?: number | undefined;
1452
- command?: string | undefined;
1453
1500
  args?: string[] | undefined;
1454
1501
  cwd?: string | undefined;
1455
1502
  env?: Record<string, string> | undefined;
@@ -1461,10 +1508,10 @@ declare const appConfigSchema: z.ZodObject<{
1461
1508
  allow_external_cwd?: boolean | undefined;
1462
1509
  }, {
1463
1510
  name: string;
1511
+ command?: string | undefined;
1464
1512
  metadata?: Record<string, unknown> | undefined;
1465
1513
  type?: "native" | "process" | "cli" | undefined;
1466
1514
  timeout_ms?: number | undefined;
1467
- command?: string | undefined;
1468
1515
  args?: string[] | undefined;
1469
1516
  cwd?: string | undefined;
1470
1517
  env?: Record<string, string> | undefined;
@@ -1604,9 +1651,9 @@ declare const appConfigSchema: z.ZodObject<{
1604
1651
  name: string;
1605
1652
  type: "native" | "process" | "cli";
1606
1653
  input_mode: "protocol" | "stdin" | "arg";
1654
+ command?: string | undefined;
1607
1655
  metadata?: Record<string, unknown> | undefined;
1608
1656
  timeout_ms?: number | undefined;
1609
- command?: string | undefined;
1610
1657
  args?: string[] | undefined;
1611
1658
  cwd?: string | undefined;
1612
1659
  env?: Record<string, string> | undefined;
@@ -1668,10 +1715,10 @@ declare const appConfigSchema: z.ZodObject<{
1668
1715
  name: string;
1669
1716
  agents?: {
1670
1717
  name: string;
1718
+ command?: string | undefined;
1671
1719
  metadata?: Record<string, unknown> | undefined;
1672
1720
  type?: "native" | "process" | "cli" | undefined;
1673
1721
  timeout_ms?: number | undefined;
1674
- command?: string | undefined;
1675
1722
  args?: string[] | undefined;
1676
1723
  cwd?: string | undefined;
1677
1724
  env?: Record<string, string> | undefined;
@@ -1745,9 +1792,9 @@ declare const appConfigSchema: z.ZodObject<{
1745
1792
  name: string;
1746
1793
  type: "native" | "process" | "cli";
1747
1794
  input_mode: "protocol" | "stdin" | "arg";
1795
+ command?: string | undefined;
1748
1796
  metadata?: Record<string, unknown> | undefined;
1749
1797
  timeout_ms?: number | undefined;
1750
- command?: string | undefined;
1751
1798
  args?: string[] | undefined;
1752
1799
  cwd?: string | undefined;
1753
1800
  env?: Record<string, string> | undefined;
@@ -1814,10 +1861,10 @@ declare const appConfigSchema: z.ZodObject<{
1814
1861
  name: string;
1815
1862
  agents?: {
1816
1863
  name: string;
1864
+ command?: string | undefined;
1817
1865
  metadata?: Record<string, unknown> | undefined;
1818
1866
  type?: "native" | "process" | "cli" | undefined;
1819
1867
  timeout_ms?: number | undefined;
1820
- command?: string | undefined;
1821
1868
  args?: string[] | undefined;
1822
1869
  cwd?: string | undefined;
1823
1870
  env?: Record<string, string> | undefined;
@@ -2571,12 +2618,24 @@ interface CombinedMeta {
2571
2618
  pipelineRunId?: string;
2572
2619
  taskIds?: string[];
2573
2620
  }
2621
+ interface CollectionDiagnostics {
2622
+ collected: number;
2623
+ accepted: number;
2624
+ rejected: Array<{
2625
+ key: string;
2626
+ reason: string;
2627
+ issues: string[];
2628
+ }>;
2629
+ }
2574
2630
  declare class ReportService {
2575
2631
  private readonly store;
2576
2632
  private readonly log;
2633
+ /** Rejected reports from the last collection (§13 — malformed never enters aggregation). */
2634
+ lastDiagnostics: CollectionDiagnostics;
2577
2635
  constructor(store: ReportStore, log?: Logger);
2578
2636
  get storeRef(): ReportStore;
2579
- /** Normalizes finished tasks into reports (§17 — normalizer). */
2637
+ /** Normalizes finished tasks into reports (§17 — normalizer), validating each
2638
+ * one so malformed reports never reach aggregation (§13). */
2580
2639
  collectFromTasks(tasks: Task[]): Promise<Report[]>;
2581
2640
  saveReports(reports: Report[]): Promise<void>;
2582
2641
  generateCombined(reports: Report[], meta?: CombinedMeta): Promise<CombinedReport | undefined>;
@@ -2606,6 +2665,24 @@ interface AggregateOptions {
2606
2665
  declare function aggregateReports(reports: Report[], options?: AggregateOptions): CombinedReport;
2607
2666
  declare function similar(a: string, b: string, threshold: number): boolean;
2608
2667
 
2668
+ interface ReportValidationIssue {
2669
+ path: string;
2670
+ message: string;
2671
+ }
2672
+ type ReportValidationResult = {
2673
+ valid: true;
2674
+ report: Report;
2675
+ } | {
2676
+ valid: false;
2677
+ issues: ReportValidationIssue[];
2678
+ reason: string;
2679
+ };
2680
+ /** Validates (and normalizes) a report; malformed reports are rejected. */
2681
+ declare function validateReport(value: unknown): ReportValidationResult;
2682
+ /** Normalizes evidence entries (strings or objects) to typed evidence. */
2683
+ declare function normalizeEvidence(input: EvidenceInput[] | undefined): Evidence[] | undefined;
2684
+ declare function normalizeFinding(finding: Finding): Finding;
2685
+
2609
2686
  /** Planner interface and request contract (§18). The planner is replaceable. */
2610
2687
 
2611
2688
  interface PlanRequest {
@@ -2793,6 +2870,6 @@ declare class ProjectStores {
2793
2870
  constructor(directory?: string);
2794
2871
  }
2795
2872
 
2796
- declare const OMNINODE_VERSION = "2.0.0-alpha.8";
2873
+ declare const OMNINODE_VERSION = "2.0.0-alpha.9";
2797
2874
 
2798
- export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatStreamChunk, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_CONTEXT_CHARS, MAX_MESSAGE_BYTES, type MemoryCategory, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryProviderMetadata, type MemoryQuery, type MemoryScope, MemoryService, type MemoryServiceOptions, type MemoryTaskContext, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, type PipelineRunStatus, type PipelineRunStore, type PipelineStep, type PipelineStepCondition, type PipelineStepConfigYaml, type PipelineStepKind, type PipelineStepRun, type Plan, type PlanFilter, type PlanRequest, type PlanStep, type PlanStore, type PlannerConfigYaml, PlannerError, ProcessAgent, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultMetadata, defaultProjectConfigYaml, defaultSearch, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateWorkingDirectory };
2875
+ export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatStreamChunk, type ChatUsage, type CollectionDiagnostics, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type Evidence, type EvidenceInput, type EvidenceKind, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingOrigin, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_CONTEXT_CHARS, MAX_MESSAGE_BYTES, type MemoryCategory, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryProviderMetadata, type MemoryQuery, type MemoryScope, MemoryService, type MemoryServiceOptions, type MemoryTaskContext, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, type PipelineRunStatus, type PipelineRunStore, type PipelineStep, type PipelineStepCondition, type PipelineStepConfigYaml, type PipelineStepKind, type PipelineStepRun, type Plan, type PlanFilter, type PlanRequest, type PlanStep, type PlanStore, type PlannerConfigYaml, PlannerError, ProcessAgent, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportArtifact, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type ReportValidationIssue, type ReportValidationResult, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultMetadata, defaultProjectConfigYaml, defaultSearch, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, normalizeEvidence, normalizeFinding, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateReport, validateWorkingDirectory };
package/dist/index.js CHANGED
@@ -3401,6 +3401,91 @@ function buildPlanner(plannerConfig, chat, log = logger) {
3401
3401
 
3402
3402
  // src/reports/aggregate.ts
3403
3403
  import { randomBytes as randomBytes5 } from "crypto";
3404
+
3405
+ // src/reports/schema.ts
3406
+ import { z as z3 } from "zod";
3407
+ var evidenceSchema = z3.union([
3408
+ z3.string().transform((excerpt) => ({ kind: "observation", excerpt })),
3409
+ z3.object({
3410
+ kind: z3.enum(["file", "line", "url", "command", "observation", "artifact"]),
3411
+ ref: z3.string().optional(),
3412
+ line: z3.number().int().optional(),
3413
+ excerpt: z3.string().optional(),
3414
+ agent: z3.string().optional()
3415
+ })
3416
+ ]);
3417
+ var findingSchema = z3.object({
3418
+ id: z3.string().min(1),
3419
+ title: z3.string().min(1),
3420
+ detail: z3.string().default(""),
3421
+ description: z3.string().optional(),
3422
+ severity: z3.enum(["info", "low", "medium", "high", "critical"]).optional(),
3423
+ confidence: z3.enum(["low", "medium", "high"]).optional(),
3424
+ evidence: z3.array(evidenceSchema).optional(),
3425
+ location: z3.string().optional(),
3426
+ tags: z3.array(z3.string()).optional(),
3427
+ source: z3.object({ agent: z3.string().optional(), reportId: z3.string().optional(), pipelineRunId: z3.string().optional() }).optional(),
3428
+ recommendation: z3.string().optional()
3429
+ });
3430
+ var artifactSchema = z3.object({
3431
+ kind: z3.enum(["file", "patch", "log", "screenshot", "document", "data"]),
3432
+ ref: z3.string().min(1),
3433
+ description: z3.string().optional(),
3434
+ mediaType: z3.string().optional(),
3435
+ bytes: z3.number().int().optional()
3436
+ });
3437
+ var reportSchema = z3.object({
3438
+ id: z3.string().min(1),
3439
+ taskId: z3.string().min(1),
3440
+ agent: z3.string().min(1),
3441
+ agentId: z3.string().optional(),
3442
+ pipelineRunId: z3.string().optional(),
3443
+ model: z3.string().optional(),
3444
+ summary: z3.string(),
3445
+ findings: z3.array(findingSchema),
3446
+ recommendations: z3.array(z3.string()),
3447
+ confidence: z3.enum(["low", "medium", "high"]).optional(),
3448
+ evidence: z3.array(evidenceSchema).optional(),
3449
+ artifacts: z3.array(artifactSchema).optional(),
3450
+ createdAt: z3.string().min(1),
3451
+ metadata: z3.record(z3.unknown()).optional()
3452
+ });
3453
+ function validateReport(value) {
3454
+ const parsed = reportSchema.safeParse(value);
3455
+ if (!parsed.success) {
3456
+ const issues = parsed.error.issues.map((issue) => ({
3457
+ path: issue.path.join(".") || "(root)",
3458
+ message: issue.message
3459
+ }));
3460
+ return {
3461
+ valid: false,
3462
+ issues,
3463
+ reason: `report failed schema validation (${issues.length} issue(s))`
3464
+ };
3465
+ }
3466
+ const report = parsed.data;
3467
+ report.findings = report.findings.map((finding) => ({
3468
+ ...finding,
3469
+ description: finding.description ?? finding.detail,
3470
+ ...finding.source === void 0 ? { source: { agent: report.agent, reportId: report.id, ...report.pipelineRunId !== void 0 ? { pipelineRunId: report.pipelineRunId } : {} } } : {}
3471
+ }));
3472
+ return { valid: true, report };
3473
+ }
3474
+ function normalizeEvidence(input) {
3475
+ if (input === void 0) return void 0;
3476
+ return input.map(
3477
+ (item) => typeof item === "string" ? { kind: "observation", excerpt: item } : item
3478
+ );
3479
+ }
3480
+ function normalizeFinding(finding) {
3481
+ return {
3482
+ ...finding,
3483
+ description: finding.description ?? finding.detail,
3484
+ evidence: normalizeEvidence(finding.evidence)
3485
+ };
3486
+ }
3487
+
3488
+ // src/reports/aggregate.ts
3404
3489
  var SEVERITY_RANK2 = {
3405
3490
  info: 0,
3406
3491
  low: 1,
@@ -3447,7 +3532,7 @@ function mergeFinding(groups, finding, report, threshold) {
3447
3532
  group.occurrences += 1;
3448
3533
  group.details.push(finding.detail);
3449
3534
  group.sources.push(source);
3450
- group.evidence.push(...finding.evidence ?? []);
3535
+ group.evidence.push(...normalizeEvidence(finding.evidence) ?? []);
3451
3536
  if (finding.severity && (!group.severity || SEVERITY_RANK2[finding.severity] > SEVERITY_RANK2[group.severity])) {
3452
3537
  group.severity = finding.severity;
3453
3538
  }
@@ -3459,7 +3544,7 @@ function mergeFinding(groups, finding, report, threshold) {
3459
3544
  sources: [source],
3460
3545
  occurrences: 1,
3461
3546
  ...finding.severity ? { severity: finding.severity } : {},
3462
- evidence: [...finding.evidence ?? []]
3547
+ evidence: [...normalizeEvidence(finding.evidence) ?? []]
3463
3548
  });
3464
3549
  }
3465
3550
  function mergeRecommendation(groups, text, report, threshold) {
@@ -3541,6 +3626,7 @@ function extractReportFromText(raw, meta) {
3541
3626
  id: `${meta.taskId}-f-${index + 1}`,
3542
3627
  title: truncate3(text, 120),
3543
3628
  detail: text,
3629
+ description: text,
3544
3630
  severity: guessSeverity(text)
3545
3631
  }));
3546
3632
  return {
@@ -3551,7 +3637,8 @@ function extractReportFromText(raw, meta) {
3551
3637
  summary,
3552
3638
  findings,
3553
3639
  recommendations: recommendationTexts.map((t) => truncate3(t, 200)),
3554
- metadata: evidenceTexts.length > 0 ? { evidence: evidenceTexts } : void 0,
3640
+ ...evidenceTexts.length > 0 ? { evidence: evidenceTexts.map((excerpt) => ({ kind: "observation", excerpt })) } : {},
3641
+ metadata: evidenceTexts.length > 0 ? { evidenceCount: evidenceTexts.length } : void 0,
3555
3642
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
3556
3643
  };
3557
3644
  }
@@ -3567,27 +3654,46 @@ var ReportService = class {
3567
3654
  }
3568
3655
  store;
3569
3656
  log;
3657
+ /** Rejected reports from the last collection (§13 — malformed never enters aggregation). */
3658
+ lastDiagnostics = { collected: 0, accepted: 0, rejected: [] };
3570
3659
  get storeRef() {
3571
3660
  return this.store;
3572
3661
  }
3573
- /** Normalizes finished tasks into reports (§17 — normalizer). */
3662
+ /** Normalizes finished tasks into reports (§17 — normalizer), validating each
3663
+ * one so malformed reports never reach aggregation (§13). */
3574
3664
  async collectFromTasks(tasks) {
3575
- const reports = [];
3665
+ const candidates = [];
3576
3666
  for (const task of tasks) {
3577
3667
  const structured = task.result?.reports ?? [];
3578
3668
  if (structured.length > 0) {
3579
- reports.push(...structured);
3669
+ candidates.push(...structured);
3580
3670
  continue;
3581
3671
  }
3582
3672
  const text = task.result?.rawOutput ?? task.result?.summary ?? "";
3583
3673
  if (text.trim().length === 0) continue;
3584
- reports.push(
3674
+ candidates.push(
3585
3675
  extractReportFromText(text, {
3586
3676
  taskId: task.id,
3587
3677
  agent: task.agent ?? "unknown"
3588
3678
  })
3589
3679
  );
3590
3680
  }
3681
+ const reports = [];
3682
+ const rejected = [];
3683
+ for (const candidate of candidates) {
3684
+ const result = validateReport(candidate);
3685
+ if (result.valid) {
3686
+ reports.push(result.report);
3687
+ } else {
3688
+ rejected.push({
3689
+ key: candidate?.id ?? "(unknown)",
3690
+ reason: result.reason,
3691
+ issues: result.issues.map((issue) => `${issue.path}: ${issue.message}`)
3692
+ });
3693
+ this.log.warn(`Rejected malformed report: ${result.reason}`);
3694
+ }
3695
+ }
3696
+ this.lastDiagnostics = { collected: candidates.length, accepted: reports.length, rejected };
3591
3697
  return reports;
3592
3698
  }
3593
3699
  async saveReports(reports) {
@@ -3697,7 +3803,7 @@ var ProjectStores = class {
3697
3803
  };
3698
3804
 
3699
3805
  // src/version.ts
3700
- var OMNINODE_VERSION = "2.0.0-alpha.8";
3806
+ var OMNINODE_VERSION = "2.0.0-alpha.9";
3701
3807
  export {
3702
3808
  AgentAdapterRegistry,
3703
3809
  AgentError,
@@ -3784,6 +3890,8 @@ export {
3784
3890
  loadConfig,
3785
3891
  logger,
3786
3892
  newMessageId,
3893
+ normalizeEvidence,
3894
+ normalizeFinding,
3787
3895
  parseHello,
3788
3896
  parsePlanJson,
3789
3897
  parseRetryAfter,
@@ -3803,6 +3911,7 @@ export {
3803
3911
  sanitizeChunk,
3804
3912
  similar,
3805
3913
  validateEnvelope,
3914
+ validateReport,
3806
3915
  validateWorkingDirectory
3807
3916
  };
3808
3917
  //# sourceMappingURL=index.js.map