@hilbras/omninode 2.0.0-alpha.1 → 2.0.0-alpha.3

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
@@ -65,6 +65,99 @@ interface CombinedReport {
65
65
  metadata?: Record<string, unknown>;
66
66
  }
67
67
 
68
+ /**
69
+ * OmniNode Agent Protocol v2 — message model (roadmap §7.2–§7.4, §7.7).
70
+ *
71
+ * Every message is a JSON line carrying a `ProtocolEnvelope`. All ids are
72
+ * optional for inbound tolerance but OmniNode always emits them, so every
73
+ * message is traceable to agent / task / pipeline / execution / request.
74
+ */
75
+
76
+ /** Messages OmniNode sends to an agent. */
77
+ type ProtocolNodeToAgentType = "TASK" | "HELLO_ACK" | "CONTEXT" | "INSTRUCTION" | "RESPONSE" | "CANCEL";
78
+ /** Messages an agent sends to OmniNode. */
79
+ type ProtocolAgentToNodeType = "HELLO" | "TASK_REQUEST" | "TASK_ACCEPTED" | "TASK_STARTED" | "STATUS" | "QUESTION" | "REPORT" | "ARTIFACT" | "COMPLETION" | "ERROR" | "CANCELLED";
80
+ type ProtocolMessageType = ProtocolNodeToAgentType | ProtocolAgentToNodeType;
81
+ interface ProtocolEnvelope<T extends ProtocolMessageType = ProtocolMessageType> {
82
+ /** `omninode-agent-protocol/2`. Inbound messages without it are treated as v1. */
83
+ protocol: string;
84
+ /** Unique id of this message. */
85
+ messageId: string;
86
+ /** Id of the request/thread this message belongs to. */
87
+ requestId?: string;
88
+ taskId?: string;
89
+ agentId?: string;
90
+ pipelineId?: string;
91
+ /** Execution identity (roadmap §6.5) — ties the message to one attempt. */
92
+ executionId?: string;
93
+ timestamp: string;
94
+ type: T;
95
+ payload: unknown;
96
+ metadata?: Record<string, unknown>;
97
+ }
98
+ /** Standard artifact kinds (roadmap §7.7). */
99
+ type ArtifactKind = "file" | "patch" | "report" | "log" | "screenshot" | "document" | "data";
100
+ interface ArtifactPayload {
101
+ kind: ArtifactKind;
102
+ /** Path, URL or logical name. */
103
+ ref: string;
104
+ description?: string;
105
+ mediaType?: string;
106
+ bytes?: number;
107
+ metadata?: Record<string, unknown>;
108
+ }
109
+ interface QuestionPayload {
110
+ /** Question id to answer. */
111
+ questionId: string;
112
+ question: string;
113
+ /** What kind of answer is expected (free text, file path, options…). */
114
+ expected?: "text" | "path" | "choice";
115
+ options?: string[];
116
+ }
117
+ interface TaskPayload {
118
+ taskId: string;
119
+ objective: string;
120
+ }
121
+ interface ReportPayload {
122
+ report: Report | Report[];
123
+ }
124
+ /** A question an agent asked during a run, with the answer OmniNode gave (if any). */
125
+ interface AskedQuestion {
126
+ questionId: string;
127
+ question: string;
128
+ answer?: string;
129
+ }
130
+ declare function newMessageId(prefix?: string): string;
131
+ /** Builds a v2 envelope with ids and timestamp filled in. */
132
+ declare function envelope<T extends ProtocolMessageType>(type: T, payload: unknown, ids?: {
133
+ requestId?: string;
134
+ taskId?: string;
135
+ agentId?: string;
136
+ pipelineId?: string;
137
+ executionId?: string;
138
+ metadata?: Record<string, unknown>;
139
+ }): ProtocolEnvelope<T>;
140
+
141
+ interface AgentDescriptor {
142
+ /** Protocol the agent speaks. */
143
+ protocol: string;
144
+ name: string;
145
+ version?: string;
146
+ capabilities: string[];
147
+ /** Message types the agent can emit. */
148
+ supports: string[];
149
+ }
150
+ type HelloResult = {
151
+ ok: true;
152
+ descriptor: AgentDescriptor;
153
+ } | {
154
+ ok: false;
155
+ reason: string;
156
+ };
157
+ declare function parseHello(envelopeValue: ProtocolEnvelope): HelloResult;
158
+ declare function buildHello(descriptor: Omit<AgentDescriptor, "protocol">): ProtocolEnvelope<"HELLO">;
159
+ declare function buildHelloAck(descriptor: AgentDescriptor): ProtocolEnvelope<"HELLO_ACK">;
160
+
68
161
  /** Role system: what an AI is supposed to do, independent of any provider (§11). */
69
162
  interface RoleDefinition {
70
163
  /** Slug identifier, e.g. "architecture-reviewer". */
@@ -117,6 +210,10 @@ interface AgentInfo {
117
210
  interface AgentTaskInput {
118
211
  taskId: string;
119
212
  objective: string;
213
+ /** Pipeline run that owns this task (protocol correlation, §7.4). */
214
+ pipelineId?: string;
215
+ /** Execution identity for this attempt (protocol correlation, §7.4). */
216
+ executionId?: string;
120
217
  role?: RoleDefinition;
121
218
  /** Assembled task context (project, memory, files) already selected for this agent. */
122
219
  context?: string;
@@ -132,6 +229,14 @@ interface AgentTaskOutput {
132
229
  logs?: string[];
133
230
  /** Structured reports extracted from protocol-mode runs (§16, §21). */
134
231
  reports?: Report[];
232
+ /** Protocol diagnostics for protocol-mode runs (roadmap §7): questions asked, violations seen. */
233
+ protocol?: {
234
+ protocol: string;
235
+ legacy: boolean;
236
+ descriptor?: AgentDescriptor;
237
+ questions: AskedQuestion[];
238
+ violations: string[];
239
+ };
135
240
  error?: string;
136
241
  }
137
242
  /** Contract every agent adapter implements (Phase 3+). */
@@ -229,7 +334,27 @@ interface ModelInfo {
229
334
 
230
335
  /** Task system: every operation becomes a Task (§13). */
231
336
 
232
- type TaskStatus = "created" | "queued" | "running" | "waiting" | "completed" | "failed" | "cancelled";
337
+ /**
338
+ * Execution states (v2 Phase 2, roadmap §6.1).
339
+ *
340
+ * The crucial distinction: `unknown` means "we cannot prove the outcome" —
341
+ * e.g. a process timeout after the agent may already have performed side
342
+ * effects. It is deliberately NOT `failed`: retrying blindly could duplicate
343
+ * work, and reporting failure would be a lie. Resolve it explicitly with
344
+ * `task retry` (which starts a fresh execution) or by inspecting artifacts.
345
+ */
346
+ type TaskStatus = "created" | "queued" | "running" | "waiting" | "completed" | "failed" | "timed_out" | "cancelled" | "unknown" | "partially_completed";
347
+ /** States from which no further automatic transition happens. */
348
+ declare const TERMINAL_TASK_STATUSES: readonly TaskStatus[];
349
+ /** One execution attempt (roadmap §6.5 identity: task + attempt + execution id). */
350
+ interface ExecutionRecord {
351
+ executionId: string;
352
+ attempt: number;
353
+ startedAt: string;
354
+ finishedAt: string;
355
+ outcome: "completed" | "failed" | "timed_out" | "unknown" | "cancelled";
356
+ error?: string;
357
+ }
233
358
  interface TaskContext {
234
359
  project?: string;
235
360
  /** Paths or globs relevant to the task. */
@@ -262,6 +387,12 @@ interface Task {
262
387
  status: TaskStatus;
263
388
  createdAt: string;
264
389
  updatedAt: string;
390
+ /** Number of engine.run attempts so far (0 = never executed). */
391
+ attempt: number;
392
+ /** Error from the most recent failed/unknown attempt. */
393
+ lastError?: string;
394
+ /** Recent execution attempts, newest last, bounded in length. */
395
+ executions?: ExecutionRecord[];
265
396
  result?: TaskResult;
266
397
  }
267
398
 
@@ -292,7 +423,12 @@ interface PipelineDefinition {
292
423
  role?: string;
293
424
  steps: PipelineStep[];
294
425
  }
295
- type PipelineRunStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
426
+ /**
427
+ * Run status. "partial" means the run finished but some step outcome was
428
+ * incomplete or unprovable (partial fan-out, unknown task state) — the
429
+ * authoritative detail always lives in `stepRuns`/`taskRuns`.
430
+ */
431
+ type PipelineRunStatus = "pending" | "running" | "completed" | "failed" | "partial" | "cancelled";
296
432
  interface PipelineStepRun {
297
433
  stepId: string;
298
434
  status: TaskStatus;
@@ -585,18 +721,18 @@ declare const providerConfigSchema: z.ZodObject<{
585
721
  name: string;
586
722
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
587
723
  base_url: string;
724
+ metadata?: Record<string, unknown> | undefined;
588
725
  api_key_env_var?: string | undefined;
589
726
  headers?: Record<string, string> | undefined;
590
727
  enabled?: boolean | undefined;
591
- metadata?: Record<string, unknown> | undefined;
592
728
  }, {
593
729
  name: string;
594
730
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
595
731
  base_url: string;
732
+ metadata?: Record<string, unknown> | undefined;
596
733
  api_key_env_var?: string | undefined;
597
734
  headers?: Record<string, string> | undefined;
598
735
  enabled?: boolean | undefined;
599
- metadata?: Record<string, unknown> | undefined;
600
736
  }>;
601
737
  declare const agentConfigSchema: z.ZodObject<{
602
738
  name: z.ZodString;
@@ -613,7 +749,7 @@ declare const agentConfigSchema: z.ZodObject<{
613
749
  }, "strict", z.ZodTypeAny, {
614
750
  name: string;
615
751
  type: "native" | "process" | "cli";
616
- input_mode: "stdin" | "arg" | "protocol";
752
+ input_mode: "protocol" | "stdin" | "arg";
617
753
  metadata?: Record<string, unknown> | undefined;
618
754
  command?: string | undefined;
619
755
  args?: string[] | undefined;
@@ -623,13 +759,13 @@ declare const agentConfigSchema: z.ZodObject<{
623
759
  inherit_env?: boolean | undefined;
624
760
  }, {
625
761
  name: string;
626
- type?: "native" | "process" | "cli" | undefined;
627
762
  metadata?: Record<string, unknown> | undefined;
763
+ type?: "native" | "process" | "cli" | undefined;
628
764
  command?: string | undefined;
629
765
  args?: string[] | undefined;
630
766
  cwd?: string | undefined;
631
767
  env?: Record<string, string> | undefined;
632
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
768
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
633
769
  timeout_ms?: number | undefined;
634
770
  inherit_env?: boolean | undefined;
635
771
  }>;
@@ -734,8 +870,8 @@ declare const pipelineConfigSchema: z.ZodObject<{
734
870
  retries?: number | undefined;
735
871
  condition?: "always" | "on-success" | "on-failure" | undefined;
736
872
  }[];
737
- role?: string | undefined;
738
873
  name?: string | undefined;
874
+ role?: string | undefined;
739
875
  objective?: string | undefined;
740
876
  }, {
741
877
  id: string;
@@ -749,8 +885,8 @@ declare const pipelineConfigSchema: z.ZodObject<{
749
885
  retries?: number | undefined;
750
886
  condition?: "always" | "on-success" | "on-failure" | undefined;
751
887
  }[];
752
- role?: string | undefined;
753
888
  name?: string | undefined;
889
+ role?: string | undefined;
754
890
  objective?: string | undefined;
755
891
  }>;
756
892
  declare const plannerConfigSchema: z.ZodObject<{
@@ -780,18 +916,18 @@ declare const projectConfigSchema: z.ZodObject<{
780
916
  name: string;
781
917
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
782
918
  base_url: string;
919
+ metadata?: Record<string, unknown> | undefined;
783
920
  api_key_env_var?: string | undefined;
784
921
  headers?: Record<string, string> | undefined;
785
922
  enabled?: boolean | undefined;
786
- metadata?: Record<string, unknown> | undefined;
787
923
  }, {
788
924
  name: string;
789
925
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
790
926
  base_url: string;
927
+ metadata?: Record<string, unknown> | undefined;
791
928
  api_key_env_var?: string | undefined;
792
929
  headers?: Record<string, string> | undefined;
793
930
  enabled?: boolean | undefined;
794
- metadata?: Record<string, unknown> | undefined;
795
931
  }>, "many">>;
796
932
  agents: z.ZodDefault<z.ZodArray<z.ZodObject<{
797
933
  name: z.ZodString;
@@ -808,7 +944,7 @@ declare const projectConfigSchema: z.ZodObject<{
808
944
  }, "strict", z.ZodTypeAny, {
809
945
  name: string;
810
946
  type: "native" | "process" | "cli";
811
- input_mode: "stdin" | "arg" | "protocol";
947
+ input_mode: "protocol" | "stdin" | "arg";
812
948
  metadata?: Record<string, unknown> | undefined;
813
949
  command?: string | undefined;
814
950
  args?: string[] | undefined;
@@ -818,13 +954,13 @@ declare const projectConfigSchema: z.ZodObject<{
818
954
  inherit_env?: boolean | undefined;
819
955
  }, {
820
956
  name: string;
821
- type?: "native" | "process" | "cli" | undefined;
822
957
  metadata?: Record<string, unknown> | undefined;
958
+ type?: "native" | "process" | "cli" | undefined;
823
959
  command?: string | undefined;
824
960
  args?: string[] | undefined;
825
961
  cwd?: string | undefined;
826
962
  env?: Record<string, string> | undefined;
827
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
963
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
828
964
  timeout_ms?: number | undefined;
829
965
  inherit_env?: boolean | undefined;
830
966
  }>, "many">>;
@@ -901,8 +1037,8 @@ declare const projectConfigSchema: z.ZodObject<{
901
1037
  retries?: number | undefined;
902
1038
  condition?: "always" | "on-success" | "on-failure" | undefined;
903
1039
  }[];
904
- role?: string | undefined;
905
1040
  name?: string | undefined;
1041
+ role?: string | undefined;
906
1042
  objective?: string | undefined;
907
1043
  }, {
908
1044
  id: string;
@@ -916,8 +1052,8 @@ declare const projectConfigSchema: z.ZodObject<{
916
1052
  retries?: number | undefined;
917
1053
  condition?: "always" | "on-success" | "on-failure" | undefined;
918
1054
  }[];
919
- role?: string | undefined;
920
1055
  name?: string | undefined;
1056
+ role?: string | undefined;
921
1057
  objective?: string | undefined;
922
1058
  }>, "many">>;
923
1059
  planner: z.ZodOptional<z.ZodObject<{
@@ -951,7 +1087,7 @@ declare const projectConfigSchema: z.ZodObject<{
951
1087
  agents: {
952
1088
  name: string;
953
1089
  type: "native" | "process" | "cli";
954
- input_mode: "stdin" | "arg" | "protocol";
1090
+ input_mode: "protocol" | "stdin" | "arg";
955
1091
  metadata?: Record<string, unknown> | undefined;
956
1092
  command?: string | undefined;
957
1093
  args?: string[] | undefined;
@@ -964,10 +1100,10 @@ declare const projectConfigSchema: z.ZodObject<{
964
1100
  name: string;
965
1101
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
966
1102
  base_url: string;
1103
+ metadata?: Record<string, unknown> | undefined;
967
1104
  api_key_env_var?: string | undefined;
968
1105
  headers?: Record<string, string> | undefined;
969
1106
  enabled?: boolean | undefined;
970
- metadata?: Record<string, unknown> | undefined;
971
1107
  }[];
972
1108
  roles: {
973
1109
  name: string;
@@ -991,8 +1127,8 @@ declare const projectConfigSchema: z.ZodObject<{
991
1127
  retries?: number | undefined;
992
1128
  condition?: "always" | "on-success" | "on-failure" | undefined;
993
1129
  }[];
994
- role?: string | undefined;
995
1130
  name?: string | undefined;
1131
+ role?: string | undefined;
996
1132
  objective?: string | undefined;
997
1133
  }[];
998
1134
  planner?: {
@@ -1009,13 +1145,13 @@ declare const projectConfigSchema: z.ZodObject<{
1009
1145
  name: string;
1010
1146
  agents?: {
1011
1147
  name: string;
1012
- type?: "native" | "process" | "cli" | undefined;
1013
1148
  metadata?: Record<string, unknown> | undefined;
1149
+ type?: "native" | "process" | "cli" | undefined;
1014
1150
  command?: string | undefined;
1015
1151
  args?: string[] | undefined;
1016
1152
  cwd?: string | undefined;
1017
1153
  env?: Record<string, string> | undefined;
1018
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
1154
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
1019
1155
  timeout_ms?: number | undefined;
1020
1156
  inherit_env?: boolean | undefined;
1021
1157
  }[] | undefined;
@@ -1023,10 +1159,10 @@ declare const projectConfigSchema: z.ZodObject<{
1023
1159
  name: string;
1024
1160
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1025
1161
  base_url: string;
1162
+ metadata?: Record<string, unknown> | undefined;
1026
1163
  api_key_env_var?: string | undefined;
1027
1164
  headers?: Record<string, string> | undefined;
1028
1165
  enabled?: boolean | undefined;
1029
- metadata?: Record<string, unknown> | undefined;
1030
1166
  }[] | undefined;
1031
1167
  roles?: {
1032
1168
  name: string;
@@ -1050,8 +1186,8 @@ declare const projectConfigSchema: z.ZodObject<{
1050
1186
  retries?: number | undefined;
1051
1187
  condition?: "always" | "on-success" | "on-failure" | undefined;
1052
1188
  }[];
1053
- role?: string | undefined;
1054
1189
  name?: string | undefined;
1190
+ role?: string | undefined;
1055
1191
  objective?: string | undefined;
1056
1192
  }[] | undefined;
1057
1193
  planner?: {
@@ -1080,18 +1216,18 @@ declare const appConfigSchema: z.ZodObject<{
1080
1216
  name: string;
1081
1217
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1082
1218
  base_url: string;
1219
+ metadata?: Record<string, unknown> | undefined;
1083
1220
  api_key_env_var?: string | undefined;
1084
1221
  headers?: Record<string, string> | undefined;
1085
1222
  enabled?: boolean | undefined;
1086
- metadata?: Record<string, unknown> | undefined;
1087
1223
  }, {
1088
1224
  name: string;
1089
1225
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1090
1226
  base_url: string;
1227
+ metadata?: Record<string, unknown> | undefined;
1091
1228
  api_key_env_var?: string | undefined;
1092
1229
  headers?: Record<string, string> | undefined;
1093
1230
  enabled?: boolean | undefined;
1094
- metadata?: Record<string, unknown> | undefined;
1095
1231
  }>, "many">>;
1096
1232
  agents: z.ZodDefault<z.ZodArray<z.ZodObject<{
1097
1233
  name: z.ZodString;
@@ -1108,7 +1244,7 @@ declare const appConfigSchema: z.ZodObject<{
1108
1244
  }, "strict", z.ZodTypeAny, {
1109
1245
  name: string;
1110
1246
  type: "native" | "process" | "cli";
1111
- input_mode: "stdin" | "arg" | "protocol";
1247
+ input_mode: "protocol" | "stdin" | "arg";
1112
1248
  metadata?: Record<string, unknown> | undefined;
1113
1249
  command?: string | undefined;
1114
1250
  args?: string[] | undefined;
@@ -1118,13 +1254,13 @@ declare const appConfigSchema: z.ZodObject<{
1118
1254
  inherit_env?: boolean | undefined;
1119
1255
  }, {
1120
1256
  name: string;
1121
- type?: "native" | "process" | "cli" | undefined;
1122
1257
  metadata?: Record<string, unknown> | undefined;
1258
+ type?: "native" | "process" | "cli" | undefined;
1123
1259
  command?: string | undefined;
1124
1260
  args?: string[] | undefined;
1125
1261
  cwd?: string | undefined;
1126
1262
  env?: Record<string, string> | undefined;
1127
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
1263
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
1128
1264
  timeout_ms?: number | undefined;
1129
1265
  inherit_env?: boolean | undefined;
1130
1266
  }>, "many">>;
@@ -1201,8 +1337,8 @@ declare const appConfigSchema: z.ZodObject<{
1201
1337
  retries?: number | undefined;
1202
1338
  condition?: "always" | "on-success" | "on-failure" | undefined;
1203
1339
  }[];
1204
- role?: string | undefined;
1205
1340
  name?: string | undefined;
1341
+ role?: string | undefined;
1206
1342
  objective?: string | undefined;
1207
1343
  }, {
1208
1344
  id: string;
@@ -1216,8 +1352,8 @@ declare const appConfigSchema: z.ZodObject<{
1216
1352
  retries?: number | undefined;
1217
1353
  condition?: "always" | "on-success" | "on-failure" | undefined;
1218
1354
  }[];
1219
- role?: string | undefined;
1220
1355
  name?: string | undefined;
1356
+ role?: string | undefined;
1221
1357
  objective?: string | undefined;
1222
1358
  }>, "many">>;
1223
1359
  planner: z.ZodOptional<z.ZodObject<{
@@ -1251,7 +1387,7 @@ declare const appConfigSchema: z.ZodObject<{
1251
1387
  agents: {
1252
1388
  name: string;
1253
1389
  type: "native" | "process" | "cli";
1254
- input_mode: "stdin" | "arg" | "protocol";
1390
+ input_mode: "protocol" | "stdin" | "arg";
1255
1391
  metadata?: Record<string, unknown> | undefined;
1256
1392
  command?: string | undefined;
1257
1393
  args?: string[] | undefined;
@@ -1264,10 +1400,10 @@ declare const appConfigSchema: z.ZodObject<{
1264
1400
  name: string;
1265
1401
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1266
1402
  base_url: string;
1403
+ metadata?: Record<string, unknown> | undefined;
1267
1404
  api_key_env_var?: string | undefined;
1268
1405
  headers?: Record<string, string> | undefined;
1269
1406
  enabled?: boolean | undefined;
1270
- metadata?: Record<string, unknown> | undefined;
1271
1407
  }[];
1272
1408
  roles: {
1273
1409
  name: string;
@@ -1291,8 +1427,8 @@ declare const appConfigSchema: z.ZodObject<{
1291
1427
  retries?: number | undefined;
1292
1428
  condition?: "always" | "on-success" | "on-failure" | undefined;
1293
1429
  }[];
1294
- role?: string | undefined;
1295
1430
  name?: string | undefined;
1431
+ role?: string | undefined;
1296
1432
  objective?: string | undefined;
1297
1433
  }[];
1298
1434
  planner?: {
@@ -1309,13 +1445,13 @@ declare const appConfigSchema: z.ZodObject<{
1309
1445
  name: string;
1310
1446
  agents?: {
1311
1447
  name: string;
1312
- type?: "native" | "process" | "cli" | undefined;
1313
1448
  metadata?: Record<string, unknown> | undefined;
1449
+ type?: "native" | "process" | "cli" | undefined;
1314
1450
  command?: string | undefined;
1315
1451
  args?: string[] | undefined;
1316
1452
  cwd?: string | undefined;
1317
1453
  env?: Record<string, string> | undefined;
1318
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
1454
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
1319
1455
  timeout_ms?: number | undefined;
1320
1456
  inherit_env?: boolean | undefined;
1321
1457
  }[] | undefined;
@@ -1323,10 +1459,10 @@ declare const appConfigSchema: z.ZodObject<{
1323
1459
  name: string;
1324
1460
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1325
1461
  base_url: string;
1462
+ metadata?: Record<string, unknown> | undefined;
1326
1463
  api_key_env_var?: string | undefined;
1327
1464
  headers?: Record<string, string> | undefined;
1328
1465
  enabled?: boolean | undefined;
1329
- metadata?: Record<string, unknown> | undefined;
1330
1466
  }[] | undefined;
1331
1467
  roles?: {
1332
1468
  name: string;
@@ -1350,8 +1486,8 @@ declare const appConfigSchema: z.ZodObject<{
1350
1486
  retries?: number | undefined;
1351
1487
  condition?: "always" | "on-success" | "on-failure" | undefined;
1352
1488
  }[];
1353
- role?: string | undefined;
1354
1489
  name?: string | undefined;
1490
+ role?: string | undefined;
1355
1491
  objective?: string | undefined;
1356
1492
  }[] | undefined;
1357
1493
  planner?: {
@@ -1378,7 +1514,7 @@ declare const appConfigSchema: z.ZodObject<{
1378
1514
  agents: {
1379
1515
  name: string;
1380
1516
  type: "native" | "process" | "cli";
1381
- input_mode: "stdin" | "arg" | "protocol";
1517
+ input_mode: "protocol" | "stdin" | "arg";
1382
1518
  metadata?: Record<string, unknown> | undefined;
1383
1519
  command?: string | undefined;
1384
1520
  args?: string[] | undefined;
@@ -1391,10 +1527,10 @@ declare const appConfigSchema: z.ZodObject<{
1391
1527
  name: string;
1392
1528
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1393
1529
  base_url: string;
1530
+ metadata?: Record<string, unknown> | undefined;
1394
1531
  api_key_env_var?: string | undefined;
1395
1532
  headers?: Record<string, string> | undefined;
1396
1533
  enabled?: boolean | undefined;
1397
- metadata?: Record<string, unknown> | undefined;
1398
1534
  }[];
1399
1535
  roles: {
1400
1536
  name: string;
@@ -1418,8 +1554,8 @@ declare const appConfigSchema: z.ZodObject<{
1418
1554
  retries?: number | undefined;
1419
1555
  condition?: "always" | "on-success" | "on-failure" | undefined;
1420
1556
  }[];
1421
- role?: string | undefined;
1422
1557
  name?: string | undefined;
1558
+ role?: string | undefined;
1423
1559
  objective?: string | undefined;
1424
1560
  }[];
1425
1561
  planner?: {
@@ -1441,13 +1577,13 @@ declare const appConfigSchema: z.ZodObject<{
1441
1577
  name: string;
1442
1578
  agents?: {
1443
1579
  name: string;
1444
- type?: "native" | "process" | "cli" | undefined;
1445
1580
  metadata?: Record<string, unknown> | undefined;
1581
+ type?: "native" | "process" | "cli" | undefined;
1446
1582
  command?: string | undefined;
1447
1583
  args?: string[] | undefined;
1448
1584
  cwd?: string | undefined;
1449
1585
  env?: Record<string, string> | undefined;
1450
- input_mode?: "stdin" | "arg" | "protocol" | undefined;
1586
+ input_mode?: "protocol" | "stdin" | "arg" | undefined;
1451
1587
  timeout_ms?: number | undefined;
1452
1588
  inherit_env?: boolean | undefined;
1453
1589
  }[] | undefined;
@@ -1455,10 +1591,10 @@ declare const appConfigSchema: z.ZodObject<{
1455
1591
  name: string;
1456
1592
  type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
1457
1593
  base_url: string;
1594
+ metadata?: Record<string, unknown> | undefined;
1458
1595
  api_key_env_var?: string | undefined;
1459
1596
  headers?: Record<string, string> | undefined;
1460
1597
  enabled?: boolean | undefined;
1461
- metadata?: Record<string, unknown> | undefined;
1462
1598
  }[] | undefined;
1463
1599
  roles?: {
1464
1600
  name: string;
@@ -1482,8 +1618,8 @@ declare const appConfigSchema: z.ZodObject<{
1482
1618
  retries?: number | undefined;
1483
1619
  condition?: "always" | "on-success" | "on-failure" | undefined;
1484
1620
  }[];
1485
- role?: string | undefined;
1486
1621
  name?: string | undefined;
1622
+ role?: string | undefined;
1487
1623
  objective?: string | undefined;
1488
1624
  }[] | undefined;
1489
1625
  planner?: {
@@ -1668,6 +1804,104 @@ declare function createAgent(config: AgentConfig): IAgent;
1668
1804
  /** Builds an agent registry from the project configuration, skipping agents that fail to construct. */
1669
1805
  declare function buildAgentRegistry(config: AppConfig, log?: Logger): AgentRegistry;
1670
1806
 
1807
+ /**
1808
+ * OmniNode Agent Protocol v2 — versioning (roadmap §7.1).
1809
+ *
1810
+ * Protocol identifiers are namespaced strings so an agent can negotiate the
1811
+ * dialect it speaks: `omninode-agent-protocol/2`.
1812
+ */
1813
+ declare const PROTOCOL_V2 = "omninode-agent-protocol/2";
1814
+ /** Versions this build accepts. v1 is the unversioned dialect shipped with OmniNode 1.x. */
1815
+ declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
1816
+ declare const MAX_MESSAGE_BYTES = 1048576;
1817
+ declare function isSupportedProtocol(protocol: string): boolean;
1818
+
1819
+ type ProtocolViolationCode = "INVALID_JSON" | "NOT_AN_OBJECT" | "UNKNOWN_TYPE" | "MISSING_FIELD" | "UNSUPPORTED_VERSION" | "OVERSIZED" | "INVALID_PAYLOAD";
1820
+ interface ProtocolViolation {
1821
+ code: ProtocolViolationCode;
1822
+ message: string;
1823
+ /** Raw line (truncated) for diagnostics. */
1824
+ sample?: string;
1825
+ }
1826
+ type DecodeResult = {
1827
+ ok: true;
1828
+ envelope: ProtocolEnvelope;
1829
+ legacy: boolean;
1830
+ } | {
1831
+ ok: false;
1832
+ error: ProtocolViolation;
1833
+ };
1834
+ /** Validates one decoded JSON value as a protocol envelope. */
1835
+ declare function validateEnvelope(value: unknown, line?: string): DecodeResult;
1836
+ /** Decodes one protocol line (no trailing newline). */
1837
+ declare function decodeMessage(line: string, maxBytes?: number): DecodeResult;
1838
+ /** Serializes an envelope to a single JSON line. */
1839
+ declare function encodeMessage(envelope: ProtocolEnvelope, maxBytes?: number): string;
1840
+ /**
1841
+ * Streaming line decoder for agent stdout. Feed chunks; receive decoded
1842
+ * envelopes and violations in order. Survives garbage: a bad line yields a
1843
+ * violation and the stream continues.
1844
+ */
1845
+ declare class ProtocolDecoder {
1846
+ private buffer;
1847
+ private readonly maxBytes;
1848
+ constructor(maxBytes?: number);
1849
+ push(chunk: string): DecodeResult[];
1850
+ /** Flush any trailing line when the process exits. */
1851
+ flush(): DecodeResult[];
1852
+ }
1853
+
1854
+ /**
1855
+ * OmniNode Agent Protocol v2 — session (roadmap §7.6).
1856
+ *
1857
+ * A session drives a protocol-mode agent: it emits v2 envelopes with
1858
+ * correlation ids, tolerates legacy (unversioned) replies, answers agent
1859
+ * questions through a responder callback, and collects reports, artifacts
1860
+ * and the completion — never throwing on malformed input.
1861
+ */
1862
+
1863
+ interface SessionIds {
1864
+ requestId: string;
1865
+ taskId: string;
1866
+ agentId: string;
1867
+ pipelineId?: string;
1868
+ executionId?: string;
1869
+ }
1870
+ interface QuestionResponder {
1871
+ (question: {
1872
+ questionId: string;
1873
+ question: string;
1874
+ expected?: string;
1875
+ }): Promise<string> | string;
1876
+ }
1877
+ declare class ProtocolSession {
1878
+ readonly decoder: ProtocolDecoder;
1879
+ private readonly ids;
1880
+ private readonly responder;
1881
+ readonly violations: ProtocolViolation[];
1882
+ readonly questions: AskedQuestion[];
1883
+ readonly artifacts: ProtocolEnvelope["payload"][];
1884
+ reports: ProtocolEnvelope["payload"][];
1885
+ descriptor?: AgentDescriptor;
1886
+ completionSummary?: string;
1887
+ errorMessage?: string;
1888
+ constructor(ids: SessionIds, options?: {
1889
+ responder?: QuestionResponder;
1890
+ maxBytes?: number;
1891
+ });
1892
+ /** The v2 messages OmniNode sends to open a task (written to the agent's stdin). */
1893
+ taskMessages(objective: string, role?: unknown, context?: string, instruction?: string): string[];
1894
+ helloAck(descriptor: AgentDescriptor): string;
1895
+ /** Consumes decoded stdout, answering questions as they arrive. */
1896
+ handle(decoded: DecodeResult): Promise<void>;
1897
+ private answerQuestion;
1898
+ readonly pendingAnswers: string[];
1899
+ /** True once any inbound message carried the v2 protocol field. */
1900
+ sawV2: boolean;
1901
+ }
1902
+ declare function decodeStream(session: ProtocolSession, chunk: string): Promise<string[]>;
1903
+ declare function requireCompletion(session: ProtocolSession): void;
1904
+
1671
1905
  /** Role registry (§11): the set of roles available for task assignment. */
1672
1906
 
1673
1907
  declare class RoleRegistry {
@@ -1823,6 +2057,12 @@ interface CreateTaskInput {
1823
2057
  agent?: string;
1824
2058
  context?: TaskContext;
1825
2059
  }
2060
+ interface RunTaskOptions {
2061
+ /** Total attempts (1 = no automatic retry). Retries apply to retryable errors only. */
2062
+ maxAttempts?: number;
2063
+ /** Linear backoff base in ms: waits backoffMs × attempt between attempts. */
2064
+ retryBackoffMs?: number;
2065
+ }
1826
2066
  interface TaskEngineOptions {
1827
2067
  agents: AgentRegistry;
1828
2068
  roles: RoleRegistry;
@@ -1840,10 +2080,12 @@ declare class TaskEngine {
1840
2080
  get store(): TaskStore;
1841
2081
  create(input: CreateTaskInput): Promise<Task>;
1842
2082
  queue(id: string): Promise<Task>;
1843
- /** Runs the task through its assigned agent and records the result. */
1844
- run(id: string): Promise<Task>;
2083
+ /** Runs the task through its assigned agent and records the result.
2084
+ * `maxAttempts` enables bounded automatic retries of *retryable* errors
2085
+ * with linear backoff; unknown/timed_out outcomes are never auto-retried. */
2086
+ run(id: string, options?: RunTaskOptions): Promise<Task>;
1845
2087
  cancel(id: string): Promise<Task>;
1846
- /** Error recovery (§27 Phase 9): reset a failed/cancelled task so it can run again. */
2088
+ /** Error recovery: reset a failed/cancelled/unknown/timed_out task so it can run again. */
1847
2089
  retry(id: string): Promise<Task>;
1848
2090
  get(id: string): Promise<Task | undefined>;
1849
2091
  list(filter?: TaskStoreFilter): Promise<Task[]>;
@@ -2111,6 +2353,6 @@ declare class ProjectStores {
2111
2353
  constructor(directory?: string);
2112
2354
  }
2113
2355
 
2114
- declare const OMNINODE_VERSION = "2.0.0-alpha.1";
2356
+ declare const OMNINODE_VERSION = "2.0.0-alpha.3";
2115
2357
 
2116
- export { type AgentConfig, type AgentConfigYaml, 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 AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type DiscoveryResult, type EnvelopeMeta, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IChatProvider, type IMemoryProvider, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryQuery, type MemoryScope, MemoryService, type MessageEnvelope, 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, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunFilter, 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, type Project, type ProjectConfigYaml, ProjectStores, ProtocolError, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderHealth, type ProviderStatus, type ProviderType, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, defaultProjectConfigYaml, expandEnvRefs, extractReportFromText, findConfigFile, isOmniNodeError, keywords, loadConfig, logger, parsePlanJson, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, registryKey, requestJson, resolveApiKey, roleConfigSchema, similar };
2358
+ export { 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 ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type DecodeResult, type DiscoveryResult, 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 IChatProvider, type IMemoryProvider, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_MESSAGE_BYTES, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryQuery, type MemoryScope, MemoryService, type MessageEnvelope, 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 PipelineRunFilter, 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, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderConfig, type ProviderConfigYaml, ProviderError, 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, defaultProjectConfigYaml, encodeMessage, envelope, expandEnvRefs, extractReportFromText, findConfigFile, isOmniNodeError, isSupportedProtocol, keywords, loadConfig, logger, newMessageId, parseHello, parsePlanJson, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, registryKey, requestJson, requireCompletion, resolveApiKey, roleConfigSchema, similar, validateEnvelope };