@hilbras/omninode 0.0.0-stage → 0.2.0

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.
@@ -0,0 +1,1036 @@
1
+ import { z } from 'zod';
2
+
3
+ /** Role system: what an AI is supposed to do, independent of any provider (§11). */
4
+ interface RoleDefinition {
5
+ /** Slug identifier, e.g. "architecture-reviewer". */
6
+ id: string;
7
+ name: string;
8
+ description?: string;
9
+ responsibilities: string[];
10
+ /** What the role is expected to return, e.g. findings, evidence, recommendations. */
11
+ expectedOutputs: string[];
12
+ /** Optional hint; roles remain provider- and agent-independent. */
13
+ preferredAgents?: string[];
14
+ systemPrompt?: string;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+
18
+ /** Agent abstraction: CLI agents and custom agents plug in via adapters (§9–§10). */
19
+
20
+ type AgentIntegrationType = "native" | "process" | "custom";
21
+ type AgentStatus = "registered" | "ready" | "running" | "busy" | "stopped" | "error";
22
+ interface AgentConfig {
23
+ name: string;
24
+ integration: AgentIntegrationType;
25
+ /** Executable command for process agents, e.g. "opencode". */
26
+ command?: string;
27
+ args?: string[];
28
+ cwd?: string;
29
+ env?: Record<string, string>;
30
+ /** Models (as "provider:model-id") this agent may use, if restricted. */
31
+ allowedModels?: string[];
32
+ metadata?: Record<string, unknown>;
33
+ }
34
+ interface AgentInfo {
35
+ name: string;
36
+ integration: AgentIntegrationType;
37
+ version?: string;
38
+ capabilities?: string[];
39
+ command?: string;
40
+ cwd?: string;
41
+ status: AgentStatus;
42
+ metadata?: Record<string, unknown>;
43
+ }
44
+ interface AgentTaskInput {
45
+ taskId: string;
46
+ objective: string;
47
+ role?: RoleDefinition;
48
+ /** Assembled task context (project, memory, files) already selected for this agent. */
49
+ context?: string;
50
+ instruction?: string;
51
+ }
52
+ interface AgentTaskOutput {
53
+ taskId: string;
54
+ status: "completed" | "failed" | "cancelled";
55
+ summary?: string;
56
+ /** Verbatim agent output; structured report parsing lands in Phase 6. */
57
+ rawOutput?: string;
58
+ exitCode?: number;
59
+ logs?: string[];
60
+ error?: string;
61
+ }
62
+ /** Contract every agent adapter implements (Phase 3+). */
63
+ interface IAgent {
64
+ readonly info: AgentInfo;
65
+ /** Submit a task and collect the agent's output. */
66
+ run(input: AgentTaskInput): Promise<AgentTaskOutput>;
67
+ /** Ask the agent to stop current work, if supported. */
68
+ cancel?(taskId: string): Promise<void>;
69
+ }
70
+
71
+ /** Chat completion types — the foundation for planner and research phases (§18, §15). */
72
+ type ChatRole = "system" | "user" | "assistant";
73
+ interface ChatMessage {
74
+ role: ChatRole;
75
+ content: string;
76
+ }
77
+ interface ChatRequest {
78
+ /** Provider-specific model id, e.g. "qwen3-coder". */
79
+ model: string;
80
+ messages: ChatMessage[];
81
+ temperature?: number;
82
+ maxTokens?: number;
83
+ stop?: string[];
84
+ metadata?: Record<string, unknown>;
85
+ }
86
+ interface ChatUsage {
87
+ promptTokens?: number;
88
+ completionTokens?: number;
89
+ totalTokens?: number;
90
+ }
91
+ interface ChatResponse {
92
+ /** Model that actually served the request, as reported by the provider. */
93
+ model: string;
94
+ content: string;
95
+ finishReason?: string;
96
+ usage?: ChatUsage;
97
+ /** Verbatim provider response body for advanced consumers. */
98
+ raw?: unknown;
99
+ }
100
+
101
+ /**
102
+ * Memory abstraction. Remembera is the preferred Hilbras integration, but the
103
+ * core depends only on this interface (memory-agnostic principle, §2, §19).
104
+ */
105
+ type MemoryScope = "project" | "role" | "task" | "knowledge";
106
+ interface MemoryEntry {
107
+ key: string;
108
+ scope: MemoryScope;
109
+ content: string;
110
+ tags?: string[];
111
+ createdAt?: string;
112
+ updatedAt?: string;
113
+ metadata?: Record<string, unknown>;
114
+ }
115
+ interface MemoryQuery {
116
+ scope?: MemoryScope;
117
+ tags?: string[];
118
+ /** Free-text relevance query; implementations decide ranking. */
119
+ text?: string;
120
+ limit?: number;
121
+ }
122
+ interface IMemoryProvider {
123
+ readonly name: string;
124
+ /** Retrieve relevant memory; only relevant context should reach a task (§20). */
125
+ query(query: MemoryQuery): Promise<MemoryEntry[]>;
126
+ write(entry: MemoryEntry): Promise<void>;
127
+ }
128
+
129
+ /** Normalized model registry entry (DEVELOPMENT_PLAN.md §8). */
130
+ interface ModelCapabilities {
131
+ chat?: boolean;
132
+ coding?: boolean;
133
+ tools?: boolean;
134
+ vision?: boolean;
135
+ embeddings?: boolean;
136
+ }
137
+ type ModelStatus = "available" | "unavailable" | "deprecated";
138
+ interface ModelInfo {
139
+ /** Name of the provider this model belongs to. */
140
+ provider: string;
141
+ /** Provider-specific model identifier, e.g. "qwen3-coder". */
142
+ id: string;
143
+ displayName?: string;
144
+ capabilities?: ModelCapabilities;
145
+ contextWindow?: number;
146
+ status?: ModelStatus;
147
+ metadata?: Record<string, unknown>;
148
+ }
149
+
150
+ /** Task system: every operation becomes a Task (§13). */
151
+ type TaskStatus = "created" | "queued" | "running" | "waiting" | "completed" | "failed" | "cancelled";
152
+ interface TaskContext {
153
+ project?: string;
154
+ /** Paths or globs relevant to the task. */
155
+ files?: string[];
156
+ /** Free-form background injected into the prompt. */
157
+ background?: string;
158
+ /** Keys of memory entries pulled from the memory provider. */
159
+ memoryKeys?: string[];
160
+ }
161
+ interface TaskResult {
162
+ summary?: string;
163
+ artifacts?: string[];
164
+ reportId?: string;
165
+ error?: string;
166
+ finishedAt?: string;
167
+ }
168
+ interface Task {
169
+ id: string;
170
+ project?: string;
171
+ objective: string;
172
+ /** Role id from the role system. */
173
+ role?: string;
174
+ /** Agent name from the agent registry. */
175
+ agent?: string;
176
+ context?: TaskContext;
177
+ status: TaskStatus;
178
+ createdAt: string;
179
+ updatedAt: string;
180
+ result?: TaskResult;
181
+ }
182
+
183
+ /** Pipeline engine: coordinating multiple AI operations (§14). */
184
+
185
+ type PipelineStepKind = "research" | "collect" | "analyze" | "plan" | "execute" | "custom";
186
+ type PipelineStepCondition = "always" | "on-success" | "on-failure";
187
+ interface PipelineStep {
188
+ id: string;
189
+ kind: PipelineStepKind;
190
+ /** Agents fanned out for research steps. */
191
+ agents?: string[];
192
+ /** Model used for plan steps, e.g. "my-gateway:chatgpt". */
193
+ model?: string;
194
+ dependsOn?: string[];
195
+ condition?: PipelineStepCondition;
196
+ retries?: number;
197
+ }
198
+ interface PipelineDefinition {
199
+ id: string;
200
+ name?: string;
201
+ steps: PipelineStep[];
202
+ }
203
+ type PipelineRunStatus = "pending" | "running" | "completed" | "failed" | "cancelled";
204
+ interface PipelineStepRun {
205
+ stepId: string;
206
+ taskId?: string;
207
+ status: TaskStatus;
208
+ }
209
+ interface PipelineRun {
210
+ id: string;
211
+ pipelineId: string;
212
+ status: PipelineRunStatus;
213
+ startedAt?: string;
214
+ finishedAt?: string;
215
+ stepRuns: PipelineStepRun[];
216
+ }
217
+
218
+ /** Structured report format so reports can be processed programmatically (§16). */
219
+ type Confidence = "low" | "medium" | "high";
220
+ type FindingSeverity = "info" | "low" | "medium" | "high" | "critical";
221
+ interface Finding {
222
+ id: string;
223
+ title: string;
224
+ detail: string;
225
+ severity?: FindingSeverity;
226
+ evidence?: string[];
227
+ /** File path or conceptual location the finding refers to. */
228
+ location?: string;
229
+ tags?: string[];
230
+ }
231
+ interface Report {
232
+ id: string;
233
+ taskId: string;
234
+ /** Agent name from the agent registry. */
235
+ agent: string;
236
+ /** Model id used, if known. */
237
+ model?: string;
238
+ summary: string;
239
+ findings: Finding[];
240
+ recommendations: string[];
241
+ confidence?: Confidence;
242
+ createdAt: string;
243
+ metadata?: Record<string, unknown>;
244
+ }
245
+
246
+ /** Agent ↔ OmniNode communication protocol (§21). */
247
+
248
+ interface EnvelopeMeta {
249
+ taskId?: string;
250
+ agent?: string;
251
+ timestamp: string;
252
+ correlationId?: string;
253
+ }
254
+ type AgentToNodeMessage = {
255
+ type: "TASK_REQUEST";
256
+ payload: {
257
+ objective: string;
258
+ role?: string;
259
+ };
260
+ } | {
261
+ type: "REPORT";
262
+ payload: Report;
263
+ } | {
264
+ type: "STATUS";
265
+ payload: {
266
+ state: AgentStatus;
267
+ detail?: string;
268
+ };
269
+ } | {
270
+ type: "QUESTION";
271
+ payload: {
272
+ question: string;
273
+ };
274
+ } | {
275
+ type: "ARTIFACT";
276
+ payload: {
277
+ path: string;
278
+ description?: string;
279
+ };
280
+ } | {
281
+ type: "COMPLETION";
282
+ payload: {
283
+ summary?: string;
284
+ };
285
+ } | {
286
+ type: "ERROR";
287
+ payload: {
288
+ code: string;
289
+ message: string;
290
+ };
291
+ };
292
+ type NodeToAgentMessage = {
293
+ type: "TASK";
294
+ payload: {
295
+ taskId: string;
296
+ objective: string;
297
+ };
298
+ } | {
299
+ type: "CONTEXT";
300
+ payload: {
301
+ body: string;
302
+ };
303
+ } | {
304
+ type: "ROLE";
305
+ payload: RoleDefinition;
306
+ } | {
307
+ type: "INSTRUCTION";
308
+ payload: {
309
+ text: string;
310
+ };
311
+ }
312
+ /** Plan schema lands in Phase 8. */
313
+ | {
314
+ type: "PLAN";
315
+ payload: unknown;
316
+ } | {
317
+ type: "FEEDBACK";
318
+ payload: {
319
+ text: string;
320
+ };
321
+ } | {
322
+ type: "VERIFICATION_RESULT";
323
+ payload: {
324
+ passed: boolean;
325
+ details?: string;
326
+ };
327
+ };
328
+ interface MessageEnvelope<T extends AgentToNodeMessage | NodeToAgentMessage> {
329
+ meta: EnvelopeMeta;
330
+ message: T;
331
+ }
332
+
333
+ /** Projects are first-class entities (§12). */
334
+ interface Project {
335
+ name: string;
336
+ repository?: string;
337
+ workspace?: string;
338
+ agents: string[];
339
+ roles: string[];
340
+ providers?: string[];
341
+ memory?: {
342
+ provider: string;
343
+ };
344
+ createdAt?: string;
345
+ }
346
+
347
+ /**
348
+ * Provider abstraction. OmniNode is provider-agnostic: any AI gateway or local
349
+ * runtime plugs in through this interface (DEVELOPMENT_PLAN.md §5–§7).
350
+ */
351
+
352
+ type ProviderType = "openai-compatible" | "omnihilbras" | "openrouter" | "local" | "custom";
353
+ type ProviderHealth = "unknown" | "healthy" | "degraded" | "unreachable";
354
+ interface ProviderConfig {
355
+ /** Unique name used in project configuration and the model registry. */
356
+ name: string;
357
+ type: ProviderType;
358
+ baseUrl: string;
359
+ /**
360
+ * Name of the environment variable that holds the API key. Keys are never
361
+ * stored in project files (DEVELOPMENT_PLAN.md §24 — Security).
362
+ */
363
+ apiKeyEnvVar?: string;
364
+ headers?: Record<string, string>;
365
+ enabled?: boolean;
366
+ metadata?: Record<string, unknown>;
367
+ }
368
+ interface ProviderStatus {
369
+ name: string;
370
+ type: ProviderType;
371
+ baseUrl: string;
372
+ health: ProviderHealth;
373
+ connected: boolean;
374
+ modelCount: number;
375
+ lastCheckedAt?: string;
376
+ message?: string;
377
+ }
378
+ /** Contract every provider adapter implements (Phase 1+). */
379
+ interface IProvider {
380
+ readonly config: ProviderConfig;
381
+ /** Discover models exposed by this provider. */
382
+ listModels(): Promise<ModelInfo[]>;
383
+ /** Check connectivity and authentication. */
384
+ healthCheck(): Promise<ProviderStatus>;
385
+ }
386
+ /** Contract for providers that can run chat completions (foundation for planning). */
387
+ interface IChatProvider extends IProvider {
388
+ chat(request: ChatRequest): Promise<ChatResponse>;
389
+ }
390
+
391
+ /** Typed error hierarchy shared across the whole codebase (§4.1 — error model). */
392
+ type OmniNodeErrorCode = "CONFIG_NOT_FOUND" | "CONFIG_INVALID" | "PROVIDER_NOT_FOUND" | "PROVIDER_UNAVAILABLE" | "PROVIDER_AUTH_FAILED" | "MODEL_NOT_FOUND" | "AGENT_NOT_FOUND" | "AGENT_FAILED" | "AGENT_TIMEOUT" | "TASK_INVALID" | "TASK_FAILED" | "PIPELINE_INVALID" | "PIPELINE_FAILED" | "PROTOCOL_VIOLATION" | "MEMORY_UNAVAILABLE" | "NOT_IMPLEMENTED" | "CLI_USAGE" | "INTERNAL";
393
+ interface OmniNodeErrorOptions {
394
+ cause?: unknown;
395
+ details?: Record<string, unknown>;
396
+ }
397
+ declare class OmniNodeError extends Error {
398
+ readonly code: OmniNodeErrorCode;
399
+ readonly details?: Record<string, unknown>;
400
+ constructor(code: OmniNodeErrorCode, message: string, options?: OmniNodeErrorOptions);
401
+ }
402
+ declare class ConfigError extends OmniNodeError {
403
+ constructor(code: "CONFIG_NOT_FOUND" | "CONFIG_INVALID", message: string, options?: OmniNodeErrorOptions);
404
+ }
405
+ declare class ProviderError extends OmniNodeError {
406
+ constructor(code: "PROVIDER_NOT_FOUND" | "PROVIDER_UNAVAILABLE" | "PROVIDER_AUTH_FAILED" | "MODEL_NOT_FOUND", message: string, options?: OmniNodeErrorOptions);
407
+ }
408
+ declare class AgentError extends OmniNodeError {
409
+ constructor(code: "AGENT_NOT_FOUND" | "AGENT_FAILED" | "AGENT_TIMEOUT", message: string, options?: OmniNodeErrorOptions);
410
+ }
411
+ declare class TaskError extends OmniNodeError {
412
+ constructor(code: "TASK_INVALID" | "TASK_FAILED", message: string, options?: OmniNodeErrorOptions);
413
+ }
414
+ declare class PipelineError extends OmniNodeError {
415
+ constructor(code: "PIPELINE_INVALID" | "PIPELINE_FAILED", message: string, options?: OmniNodeErrorOptions);
416
+ }
417
+ declare class ProtocolError extends OmniNodeError {
418
+ constructor(message: string, options?: OmniNodeErrorOptions);
419
+ }
420
+ declare class MemoryError extends OmniNodeError {
421
+ constructor(message: string, options?: OmniNodeErrorOptions);
422
+ }
423
+ declare function isOmniNodeError(value: unknown): value is OmniNodeError;
424
+
425
+ /** Leveled logger with a pluggable sink and child loggers (§4.1 — logging). */
426
+ type LogLevel = "debug" | "info" | "warn" | "error";
427
+ interface LogSink {
428
+ write(level: LogLevel, line: string): void;
429
+ }
430
+ interface WritableLike {
431
+ write(chunk: string): unknown;
432
+ }
433
+ declare class ConsoleLogSink implements LogSink {
434
+ private readonly stream;
435
+ constructor(stream?: WritableLike);
436
+ write(_level: LogLevel, line: string): void;
437
+ }
438
+ interface LoggerOptions {
439
+ level?: LogLevel;
440
+ sink?: LogSink;
441
+ /** Structured fields attached to every line, e.g. { component: "config" }. */
442
+ context?: Record<string, unknown>;
443
+ }
444
+ declare class Logger {
445
+ private readonly level;
446
+ private readonly sink;
447
+ private readonly context;
448
+ constructor(options?: LoggerOptions);
449
+ child(context: Record<string, unknown>): Logger;
450
+ debug(message: string, data?: Record<string, unknown>): void;
451
+ info(message: string, data?: Record<string, unknown>): void;
452
+ warn(message: string, data?: Record<string, unknown>): void;
453
+ error(message: string, data?: Record<string, unknown>): void;
454
+ private log;
455
+ }
456
+ /** Default application logger. Writes to stderr so stdout stays clean for CLI output. */
457
+ declare const logger: Logger;
458
+
459
+ /**
460
+ * Configuration schema. The project file (omninode.yaml) uses snake_case keys
461
+ * as shown in DEVELOPMENT_PLAN.md §7 and §23; the loader maps them onto the
462
+ * camelCase TypeScript contracts in src/types.
463
+ */
464
+
465
+ declare const providerConfigSchema: z.ZodObject<{
466
+ name: z.ZodString;
467
+ type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
468
+ base_url: z.ZodString;
469
+ api_key_env_var: z.ZodOptional<z.ZodString>;
470
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
471
+ enabled: z.ZodOptional<z.ZodBoolean>;
472
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
473
+ }, "strict", z.ZodTypeAny, {
474
+ name: string;
475
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
476
+ base_url: string;
477
+ api_key_env_var?: string | undefined;
478
+ headers?: Record<string, string> | undefined;
479
+ enabled?: boolean | undefined;
480
+ metadata?: Record<string, unknown> | undefined;
481
+ }, {
482
+ name: string;
483
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
484
+ base_url: string;
485
+ api_key_env_var?: string | undefined;
486
+ headers?: Record<string, string> | undefined;
487
+ enabled?: boolean | undefined;
488
+ metadata?: Record<string, unknown> | undefined;
489
+ }>;
490
+ declare const agentConfigSchema: z.ZodObject<{
491
+ name: z.ZodString;
492
+ /** "cli" agents communicate over stdin/stdout (process adapter). */
493
+ type: z.ZodDefault<z.ZodEnum<["cli", "native", "process"]>>;
494
+ command: z.ZodOptional<z.ZodString>;
495
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
496
+ cwd: z.ZodOptional<z.ZodString>;
497
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
498
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
499
+ }, "strict", z.ZodTypeAny, {
500
+ name: string;
501
+ type: "native" | "process" | "cli";
502
+ metadata?: Record<string, unknown> | undefined;
503
+ command?: string | undefined;
504
+ args?: string[] | undefined;
505
+ cwd?: string | undefined;
506
+ env?: Record<string, string> | undefined;
507
+ }, {
508
+ name: string;
509
+ type?: "native" | "process" | "cli" | undefined;
510
+ metadata?: Record<string, unknown> | undefined;
511
+ command?: string | undefined;
512
+ args?: string[] | undefined;
513
+ cwd?: string | undefined;
514
+ env?: Record<string, string> | undefined;
515
+ }>;
516
+ declare const roleConfigSchema: z.ZodObject<{
517
+ id: z.ZodString;
518
+ name: z.ZodString;
519
+ description: z.ZodOptional<z.ZodString>;
520
+ responsibilities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
521
+ expected_outputs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
522
+ preferred_agents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
523
+ system_prompt: z.ZodOptional<z.ZodString>;
524
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
525
+ }, "strict", z.ZodTypeAny, {
526
+ name: string;
527
+ id: string;
528
+ responsibilities: string[];
529
+ expected_outputs: string[];
530
+ metadata?: Record<string, unknown> | undefined;
531
+ description?: string | undefined;
532
+ preferred_agents?: string[] | undefined;
533
+ system_prompt?: string | undefined;
534
+ }, {
535
+ name: string;
536
+ id: string;
537
+ metadata?: Record<string, unknown> | undefined;
538
+ description?: string | undefined;
539
+ responsibilities?: string[] | undefined;
540
+ expected_outputs?: string[] | undefined;
541
+ preferred_agents?: string[] | undefined;
542
+ system_prompt?: string | undefined;
543
+ }>;
544
+ declare const projectConfigSchema: z.ZodObject<{
545
+ name: z.ZodString;
546
+ providers: z.ZodDefault<z.ZodArray<z.ZodObject<{
547
+ name: z.ZodString;
548
+ type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
549
+ base_url: z.ZodString;
550
+ api_key_env_var: z.ZodOptional<z.ZodString>;
551
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
552
+ enabled: z.ZodOptional<z.ZodBoolean>;
553
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
554
+ }, "strict", z.ZodTypeAny, {
555
+ name: string;
556
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
557
+ base_url: string;
558
+ api_key_env_var?: string | undefined;
559
+ headers?: Record<string, string> | undefined;
560
+ enabled?: boolean | undefined;
561
+ metadata?: Record<string, unknown> | undefined;
562
+ }, {
563
+ name: string;
564
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
565
+ base_url: string;
566
+ api_key_env_var?: string | undefined;
567
+ headers?: Record<string, string> | undefined;
568
+ enabled?: boolean | undefined;
569
+ metadata?: Record<string, unknown> | undefined;
570
+ }>, "many">>;
571
+ agents: z.ZodDefault<z.ZodArray<z.ZodObject<{
572
+ name: z.ZodString;
573
+ /** "cli" agents communicate over stdin/stdout (process adapter). */
574
+ type: z.ZodDefault<z.ZodEnum<["cli", "native", "process"]>>;
575
+ command: z.ZodOptional<z.ZodString>;
576
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
577
+ cwd: z.ZodOptional<z.ZodString>;
578
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
579
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
580
+ }, "strict", z.ZodTypeAny, {
581
+ name: string;
582
+ type: "native" | "process" | "cli";
583
+ metadata?: Record<string, unknown> | undefined;
584
+ command?: string | undefined;
585
+ args?: string[] | undefined;
586
+ cwd?: string | undefined;
587
+ env?: Record<string, string> | undefined;
588
+ }, {
589
+ name: string;
590
+ type?: "native" | "process" | "cli" | undefined;
591
+ metadata?: Record<string, unknown> | undefined;
592
+ command?: string | undefined;
593
+ args?: string[] | undefined;
594
+ cwd?: string | undefined;
595
+ env?: Record<string, string> | undefined;
596
+ }>, "many">>;
597
+ roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
598
+ id: z.ZodString;
599
+ name: z.ZodString;
600
+ description: z.ZodOptional<z.ZodString>;
601
+ responsibilities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
602
+ expected_outputs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
603
+ preferred_agents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
604
+ system_prompt: z.ZodOptional<z.ZodString>;
605
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
606
+ }, "strict", z.ZodTypeAny, {
607
+ name: string;
608
+ id: string;
609
+ responsibilities: string[];
610
+ expected_outputs: string[];
611
+ metadata?: Record<string, unknown> | undefined;
612
+ description?: string | undefined;
613
+ preferred_agents?: string[] | undefined;
614
+ system_prompt?: string | undefined;
615
+ }, {
616
+ name: string;
617
+ id: string;
618
+ metadata?: Record<string, unknown> | undefined;
619
+ description?: string | undefined;
620
+ responsibilities?: string[] | undefined;
621
+ expected_outputs?: string[] | undefined;
622
+ preferred_agents?: string[] | undefined;
623
+ system_prompt?: string | undefined;
624
+ }>, "many">>;
625
+ memory: z.ZodOptional<z.ZodObject<{
626
+ provider: z.ZodString;
627
+ }, "strict", z.ZodTypeAny, {
628
+ provider: string;
629
+ }, {
630
+ provider: string;
631
+ }>>;
632
+ }, "strict", z.ZodTypeAny, {
633
+ name: string;
634
+ providers: {
635
+ name: string;
636
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
637
+ base_url: string;
638
+ api_key_env_var?: string | undefined;
639
+ headers?: Record<string, string> | undefined;
640
+ enabled?: boolean | undefined;
641
+ metadata?: Record<string, unknown> | undefined;
642
+ }[];
643
+ agents: {
644
+ name: string;
645
+ type: "native" | "process" | "cli";
646
+ metadata?: Record<string, unknown> | undefined;
647
+ command?: string | undefined;
648
+ args?: string[] | undefined;
649
+ cwd?: string | undefined;
650
+ env?: Record<string, string> | undefined;
651
+ }[];
652
+ roles: {
653
+ name: string;
654
+ id: string;
655
+ responsibilities: string[];
656
+ expected_outputs: string[];
657
+ metadata?: Record<string, unknown> | undefined;
658
+ description?: string | undefined;
659
+ preferred_agents?: string[] | undefined;
660
+ system_prompt?: string | undefined;
661
+ }[];
662
+ memory?: {
663
+ provider: string;
664
+ } | undefined;
665
+ }, {
666
+ name: string;
667
+ providers?: {
668
+ name: string;
669
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
670
+ base_url: string;
671
+ api_key_env_var?: string | undefined;
672
+ headers?: Record<string, string> | undefined;
673
+ enabled?: boolean | undefined;
674
+ metadata?: Record<string, unknown> | undefined;
675
+ }[] | undefined;
676
+ agents?: {
677
+ name: string;
678
+ type?: "native" | "process" | "cli" | undefined;
679
+ metadata?: Record<string, unknown> | undefined;
680
+ command?: string | undefined;
681
+ args?: string[] | undefined;
682
+ cwd?: string | undefined;
683
+ env?: Record<string, string> | undefined;
684
+ }[] | undefined;
685
+ roles?: {
686
+ name: string;
687
+ id: string;
688
+ metadata?: Record<string, unknown> | undefined;
689
+ description?: string | undefined;
690
+ responsibilities?: string[] | undefined;
691
+ expected_outputs?: string[] | undefined;
692
+ preferred_agents?: string[] | undefined;
693
+ system_prompt?: string | undefined;
694
+ }[] | undefined;
695
+ memory?: {
696
+ provider: string;
697
+ } | undefined;
698
+ }>;
699
+ declare const appConfigSchema: z.ZodObject<{
700
+ project: z.ZodObject<{
701
+ name: z.ZodString;
702
+ providers: z.ZodDefault<z.ZodArray<z.ZodObject<{
703
+ name: z.ZodString;
704
+ type: z.ZodEnum<["openai-compatible", "omnihilbras", "openrouter", "local", "custom"]>;
705
+ base_url: z.ZodString;
706
+ api_key_env_var: z.ZodOptional<z.ZodString>;
707
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
708
+ enabled: z.ZodOptional<z.ZodBoolean>;
709
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
710
+ }, "strict", z.ZodTypeAny, {
711
+ name: string;
712
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
713
+ base_url: string;
714
+ api_key_env_var?: string | undefined;
715
+ headers?: Record<string, string> | undefined;
716
+ enabled?: boolean | undefined;
717
+ metadata?: Record<string, unknown> | undefined;
718
+ }, {
719
+ name: string;
720
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
721
+ base_url: string;
722
+ api_key_env_var?: string | undefined;
723
+ headers?: Record<string, string> | undefined;
724
+ enabled?: boolean | undefined;
725
+ metadata?: Record<string, unknown> | undefined;
726
+ }>, "many">>;
727
+ agents: z.ZodDefault<z.ZodArray<z.ZodObject<{
728
+ name: z.ZodString;
729
+ /** "cli" agents communicate over stdin/stdout (process adapter). */
730
+ type: z.ZodDefault<z.ZodEnum<["cli", "native", "process"]>>;
731
+ command: z.ZodOptional<z.ZodString>;
732
+ args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
733
+ cwd: z.ZodOptional<z.ZodString>;
734
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
735
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
736
+ }, "strict", z.ZodTypeAny, {
737
+ name: string;
738
+ type: "native" | "process" | "cli";
739
+ metadata?: Record<string, unknown> | undefined;
740
+ command?: string | undefined;
741
+ args?: string[] | undefined;
742
+ cwd?: string | undefined;
743
+ env?: Record<string, string> | undefined;
744
+ }, {
745
+ name: string;
746
+ type?: "native" | "process" | "cli" | undefined;
747
+ metadata?: Record<string, unknown> | undefined;
748
+ command?: string | undefined;
749
+ args?: string[] | undefined;
750
+ cwd?: string | undefined;
751
+ env?: Record<string, string> | undefined;
752
+ }>, "many">>;
753
+ roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
754
+ id: z.ZodString;
755
+ name: z.ZodString;
756
+ description: z.ZodOptional<z.ZodString>;
757
+ responsibilities: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
758
+ expected_outputs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
759
+ preferred_agents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
760
+ system_prompt: z.ZodOptional<z.ZodString>;
761
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
762
+ }, "strict", z.ZodTypeAny, {
763
+ name: string;
764
+ id: string;
765
+ responsibilities: string[];
766
+ expected_outputs: string[];
767
+ metadata?: Record<string, unknown> | undefined;
768
+ description?: string | undefined;
769
+ preferred_agents?: string[] | undefined;
770
+ system_prompt?: string | undefined;
771
+ }, {
772
+ name: string;
773
+ id: string;
774
+ metadata?: Record<string, unknown> | undefined;
775
+ description?: string | undefined;
776
+ responsibilities?: string[] | undefined;
777
+ expected_outputs?: string[] | undefined;
778
+ preferred_agents?: string[] | undefined;
779
+ system_prompt?: string | undefined;
780
+ }>, "many">>;
781
+ memory: z.ZodOptional<z.ZodObject<{
782
+ provider: z.ZodString;
783
+ }, "strict", z.ZodTypeAny, {
784
+ provider: string;
785
+ }, {
786
+ provider: string;
787
+ }>>;
788
+ }, "strict", z.ZodTypeAny, {
789
+ name: string;
790
+ providers: {
791
+ name: string;
792
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
793
+ base_url: string;
794
+ api_key_env_var?: string | undefined;
795
+ headers?: Record<string, string> | undefined;
796
+ enabled?: boolean | undefined;
797
+ metadata?: Record<string, unknown> | undefined;
798
+ }[];
799
+ agents: {
800
+ name: string;
801
+ type: "native" | "process" | "cli";
802
+ metadata?: Record<string, unknown> | undefined;
803
+ command?: string | undefined;
804
+ args?: string[] | undefined;
805
+ cwd?: string | undefined;
806
+ env?: Record<string, string> | undefined;
807
+ }[];
808
+ roles: {
809
+ name: string;
810
+ id: string;
811
+ responsibilities: string[];
812
+ expected_outputs: string[];
813
+ metadata?: Record<string, unknown> | undefined;
814
+ description?: string | undefined;
815
+ preferred_agents?: string[] | undefined;
816
+ system_prompt?: string | undefined;
817
+ }[];
818
+ memory?: {
819
+ provider: string;
820
+ } | undefined;
821
+ }, {
822
+ name: string;
823
+ providers?: {
824
+ name: string;
825
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
826
+ base_url: string;
827
+ api_key_env_var?: string | undefined;
828
+ headers?: Record<string, string> | undefined;
829
+ enabled?: boolean | undefined;
830
+ metadata?: Record<string, unknown> | undefined;
831
+ }[] | undefined;
832
+ agents?: {
833
+ name: string;
834
+ type?: "native" | "process" | "cli" | undefined;
835
+ metadata?: Record<string, unknown> | undefined;
836
+ command?: string | undefined;
837
+ args?: string[] | undefined;
838
+ cwd?: string | undefined;
839
+ env?: Record<string, string> | undefined;
840
+ }[] | undefined;
841
+ roles?: {
842
+ name: string;
843
+ id: string;
844
+ metadata?: Record<string, unknown> | undefined;
845
+ description?: string | undefined;
846
+ responsibilities?: string[] | undefined;
847
+ expected_outputs?: string[] | undefined;
848
+ preferred_agents?: string[] | undefined;
849
+ system_prompt?: string | undefined;
850
+ }[] | undefined;
851
+ memory?: {
852
+ provider: string;
853
+ } | undefined;
854
+ }>;
855
+ logging: z.ZodOptional<z.ZodObject<{
856
+ level: z.ZodEnum<["debug", "info", "warn", "error"]>;
857
+ }, "strict", z.ZodTypeAny, {
858
+ level: "error" | "info" | "debug" | "warn";
859
+ }, {
860
+ level: "error" | "info" | "debug" | "warn";
861
+ }>>;
862
+ }, "strict", z.ZodTypeAny, {
863
+ project: {
864
+ name: string;
865
+ providers: {
866
+ name: string;
867
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
868
+ base_url: string;
869
+ api_key_env_var?: string | undefined;
870
+ headers?: Record<string, string> | undefined;
871
+ enabled?: boolean | undefined;
872
+ metadata?: Record<string, unknown> | undefined;
873
+ }[];
874
+ agents: {
875
+ name: string;
876
+ type: "native" | "process" | "cli";
877
+ metadata?: Record<string, unknown> | undefined;
878
+ command?: string | undefined;
879
+ args?: string[] | undefined;
880
+ cwd?: string | undefined;
881
+ env?: Record<string, string> | undefined;
882
+ }[];
883
+ roles: {
884
+ name: string;
885
+ id: string;
886
+ responsibilities: string[];
887
+ expected_outputs: string[];
888
+ metadata?: Record<string, unknown> | undefined;
889
+ description?: string | undefined;
890
+ preferred_agents?: string[] | undefined;
891
+ system_prompt?: string | undefined;
892
+ }[];
893
+ memory?: {
894
+ provider: string;
895
+ } | undefined;
896
+ };
897
+ logging?: {
898
+ level: "error" | "info" | "debug" | "warn";
899
+ } | undefined;
900
+ }, {
901
+ project: {
902
+ name: string;
903
+ providers?: {
904
+ name: string;
905
+ type: "custom" | "openai-compatible" | "omnihilbras" | "openrouter" | "local";
906
+ base_url: string;
907
+ api_key_env_var?: string | undefined;
908
+ headers?: Record<string, string> | undefined;
909
+ enabled?: boolean | undefined;
910
+ metadata?: Record<string, unknown> | undefined;
911
+ }[] | undefined;
912
+ agents?: {
913
+ name: string;
914
+ type?: "native" | "process" | "cli" | undefined;
915
+ metadata?: Record<string, unknown> | undefined;
916
+ command?: string | undefined;
917
+ args?: string[] | undefined;
918
+ cwd?: string | undefined;
919
+ env?: Record<string, string> | undefined;
920
+ }[] | undefined;
921
+ roles?: {
922
+ name: string;
923
+ id: string;
924
+ metadata?: Record<string, unknown> | undefined;
925
+ description?: string | undefined;
926
+ responsibilities?: string[] | undefined;
927
+ expected_outputs?: string[] | undefined;
928
+ preferred_agents?: string[] | undefined;
929
+ system_prompt?: string | undefined;
930
+ }[] | undefined;
931
+ memory?: {
932
+ provider: string;
933
+ } | undefined;
934
+ };
935
+ logging?: {
936
+ level: "error" | "info" | "debug" | "warn";
937
+ } | undefined;
938
+ }>;
939
+ type ProviderConfigYaml = z.infer<typeof providerConfigSchema>;
940
+ type AgentConfigYaml = z.infer<typeof agentConfigSchema>;
941
+ type RoleConfigYaml = z.infer<typeof roleConfigSchema>;
942
+ type ProjectConfigYaml = z.infer<typeof projectConfigSchema>;
943
+ type AppConfigYaml = z.infer<typeof appConfigSchema>;
944
+
945
+ interface AppConfig {
946
+ project: {
947
+ name: string;
948
+ providers: ProviderConfig[];
949
+ agents: AgentConfig[];
950
+ roles: RoleDefinition[];
951
+ memory?: {
952
+ provider: string;
953
+ };
954
+ };
955
+ logging?: {
956
+ level: LogLevel;
957
+ };
958
+ }
959
+ interface LoadConfigOptions {
960
+ /** Explicit path; otherwise omninode.yaml/yml/json is looked up in the given directory. */
961
+ path?: string;
962
+ directory?: string;
963
+ /** Environment used for ${VAR} expansion; defaults to process.env. */
964
+ env?: Record<string, string | undefined>;
965
+ }
966
+ declare function findConfigFile(directory?: string): string | undefined;
967
+ /**
968
+ * Replaces ${VAR} and ${VAR:-fallback} references. Unset variables without a
969
+ * fallback abort loading: a half-resolved config could silently misroute
970
+ * authentication.
971
+ */
972
+ declare function expandEnvRefs(text: string, env: Record<string, string | undefined>, source?: string): string;
973
+ declare function loadConfig(options?: LoadConfigOptions): AppConfig;
974
+
975
+ /** Template written by `omninode init` (§22, §23). */
976
+ declare function defaultProjectConfigYaml(projectName?: string): string;
977
+
978
+ declare function resolveApiKey(config: ProviderConfig, env?: Record<string, string | undefined>): string | undefined;
979
+ declare function authHeaders(config: ProviderConfig, env?: Record<string, string | undefined>): Record<string, string>;
980
+
981
+ interface HttpRequestOptions {
982
+ method?: "GET" | "POST";
983
+ headers?: Record<string, string>;
984
+ body?: unknown;
985
+ timeoutMs?: number;
986
+ }
987
+ interface HttpResponse {
988
+ status: number;
989
+ body: unknown;
990
+ }
991
+ declare function requestJson(url: string, options?: HttpRequestOptions): Promise<HttpResponse>;
992
+
993
+ /** Provider types served by the OpenAI-compatible adapter. */
994
+ declare const OPENAI_COMPATIBLE_TYPES: readonly ProviderType[];
995
+ declare function createProvider(config: ProviderConfig): IChatProvider;
996
+
997
+ declare class OpenAICompatibleProvider implements IChatProvider {
998
+ readonly config: ProviderConfig;
999
+ private readonly log;
1000
+ constructor(config: ProviderConfig, log?: Logger);
1001
+ listModels(): Promise<ModelInfo[]>;
1002
+ healthCheck(): Promise<ProviderStatus>;
1003
+ chat(request: ChatRequest): Promise<ChatResponse>;
1004
+ }
1005
+
1006
+ /**
1007
+ * Normalized model registry (§8): aggregates models discovered from all
1008
+ * configured providers under "provider:model" keys.
1009
+ */
1010
+
1011
+ interface ModelFilter {
1012
+ provider?: string;
1013
+ capability?: keyof ModelCapabilities;
1014
+ }
1015
+ interface DiscoveryResult {
1016
+ provider: string;
1017
+ models: ModelInfo[];
1018
+ error?: Error;
1019
+ }
1020
+ declare function registryKey(provider: string, id: string): string;
1021
+ declare class ModelRegistry {
1022
+ private readonly models;
1023
+ register(model: ModelInfo): void;
1024
+ get(provider: string, id: string): ModelInfo | undefined;
1025
+ list(filter?: ModelFilter): ModelInfo[];
1026
+ /** Availability validation (§27 Phase 1): present in the registry and not retired. */
1027
+ isAvailable(provider: string, id: string): boolean;
1028
+ /** Discover models from one provider and register them. */
1029
+ discoverFrom(provider: IProvider): Promise<ModelInfo[]>;
1030
+ /** Discover from many providers; a failing provider does not abort the rest. */
1031
+ discoverAll(providers: IProvider[]): Promise<DiscoveryResult[]>;
1032
+ }
1033
+
1034
+ declare const OMNINODE_VERSION = "0.2.0";
1035
+
1036
+ export { type AgentConfig, type AgentConfigYaml, AgentError, type AgentInfo, type AgentIntegrationType, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AppConfig, type AppConfigYaml, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatUsage, type Confidence, ConfigError, ConsoleLogSink, type DiscoveryResult, type EnvelopeMeta, type Finding, type FindingSeverity, type HttpRequestOptions, type HttpResponse, type IAgent, type IChatProvider, type IMemoryProvider, type IProvider, type LoadConfigOptions, type LogLevel, type LogSink, Logger, type LoggerOptions, type MemoryEntry, MemoryError, type MemoryQuery, type MemoryScope, type MessageEnvelope, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, type PipelineDefinition, PipelineError, type PipelineRun, type PipelineRunStatus, type PipelineStep, type PipelineStepCondition, type PipelineStepKind, type PipelineStepRun, type Project, type ProjectConfigYaml, ProtocolError, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderHealth, type ProviderStatus, type ProviderType, type Report, type RoleConfigYaml, type RoleDefinition, type Task, type TaskContext, TaskError, type TaskResult, type TaskStatus, type WritableLike, agentConfigSchema, appConfigSchema, authHeaders, createProvider, defaultProjectConfigYaml, expandEnvRefs, findConfigFile, isOmniNodeError, loadConfig, logger, projectConfigSchema, providerConfigSchema, registryKey, requestJson, resolveApiKey, roleConfigSchema };