@hilbras/omninode 1.0.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -172,6 +172,11 @@ interface ChatResponse {
172
172
  /** Verbatim provider response body for advanced consumers. */
173
173
  raw?: unknown;
174
174
  }
175
+ /**
176
+ * Model-backed chat used by the planner layer. Lives in the neutral types
177
+ * layer so adapters (e.g. planner) never depend on engine modules.
178
+ */
179
+ type ChatFn = (model: string, messages: ChatMessage[]) => Promise<string>;
175
180
 
176
181
  /**
177
182
  * Memory abstraction. Remembera is the preferred Hilbras integration, but the
@@ -1625,6 +1630,13 @@ declare class OmniHilbrasProvider extends OpenAICompatibleProvider {
1625
1630
  connect(registry?: ModelRegistry): Promise<OmniHilbrasConnectionResult>;
1626
1631
  }
1627
1632
 
1633
+ /**
1634
+ * Builds the child environment. By default the agent inherits the full
1635
+ * environment; with `inheritEnv: false` it receives only PATH plus the
1636
+ * explicitly configured variables — useful to avoid leaking OmniNode's
1637
+ * own secrets (e.g. provider API keys) into third-party agents.
1638
+ */
1639
+ declare function buildChildEnv(config: AgentConfig): NodeJS.ProcessEnv;
1628
1640
  declare function composeTaskText(input: AgentTaskInput): string;
1629
1641
  declare class ProcessAgent implements IAgent {
1630
1642
  readonly config: AgentConfig;
@@ -1668,6 +1680,41 @@ declare class RoleRegistry {
1668
1680
  /** Builds a role registry from the project configuration. */
1669
1681
  declare function buildRoleRegistry(config: AppConfig): RoleRegistry;
1670
1682
 
1683
+ interface JsonDocument<T> {
1684
+ /** Bumped when the persisted shape changes in a breaking way (v2 Phase 12). */
1685
+ schemaVersion?: number;
1686
+ items: T[];
1687
+ }
1688
+ interface JsonFileStoreOptions {
1689
+ directory?: string;
1690
+ fileName: string;
1691
+ schemaVersion?: number;
1692
+ /** Called when a persisted file cannot be parsed. */
1693
+ onCorrupt?: (path: string, error: unknown) => void;
1694
+ }
1695
+ declare class JsonFileStore<T> {
1696
+ private readonly filePath;
1697
+ private readonly schemaVersion;
1698
+ private readonly onCorrupt?;
1699
+ private readonly log;
1700
+ private queue;
1701
+ constructor(options: JsonFileStoreOptions);
1702
+ get path(): string;
1703
+ /** All items, or [] when missing/corrupt. */
1704
+ protected readAll(): Promise<T[]>;
1705
+ protected writeAll(items: T[]): Promise<void>;
1706
+ /** Serializes an async operation against this file. */
1707
+ protected synchronized<R>(operation: () => Promise<R>): Promise<R>;
1708
+ /** Read-modify-write helper: applies `mutate` to the current items. */
1709
+ protected mutate<R>(mutate: (items: T[]) => Promise<[T[], R]> | [T[], R]): Promise<R>;
1710
+ }
1711
+
1712
+ /**
1713
+ * Task persistence (§4.1 — execution state). The store is replaceable
1714
+ * (§2 — Modular); the default implementation is a local JSON file so
1715
+ * OmniNode stays local-first (§25).
1716
+ */
1717
+
1671
1718
  interface TaskStoreFilter {
1672
1719
  status?: TaskStatus;
1673
1720
  project?: string;
@@ -1677,20 +1724,11 @@ interface TaskStore {
1677
1724
  get(id: string): Promise<Task | undefined>;
1678
1725
  list(filter?: TaskStoreFilter): Promise<Task[]>;
1679
1726
  }
1680
- declare class FileTaskStore implements TaskStore {
1681
- private readonly filePath;
1682
- /**
1683
- * Read-modify-write operations are serialized: parallel pipeline tasks
1684
- * would otherwise race on the JSON file (last writer wins).
1685
- */
1686
- private queue;
1727
+ declare class FileTaskStore extends JsonFileStore<Task> implements TaskStore {
1687
1728
  constructor(directory?: string);
1688
1729
  save(task: Task): Promise<void>;
1689
1730
  get(id: string): Promise<Task | undefined>;
1690
1731
  list(filter?: TaskStoreFilter): Promise<Task[]>;
1691
- private synchronized;
1692
- private load;
1693
- private write;
1694
1732
  }
1695
1733
 
1696
1734
  type AuditAction = "task.created" | "task.queued" | "task.running" | "task.completed" | "task.failed" | "task.cancelled" | "task.retry" | "pipeline.run.started" | "pipeline.run.finished" | "plan.generated" | "memory.context.gathered" | "memory.outcome.recorded";
@@ -1715,18 +1753,20 @@ declare class FileAuditLog implements AuditSink {
1715
1753
  recent(limit?: number): Promise<AuditEvent[]>;
1716
1754
  }
1717
1755
 
1756
+ /**
1757
+ * Local file-based memory provider: the default implementation so persistent
1758
+ * memory works out of the box, locally (§25), with no external service.
1759
+ * Relevance is scored by keyword overlap and tag matches — deterministic and
1760
+ * dependency-free.
1761
+ */
1762
+
1718
1763
  declare function keywords(text: string): Set<string>;
1719
- declare class LocalMemoryProvider implements IMemoryProvider {
1764
+ declare class LocalMemoryProvider extends JsonFileStore<MemoryEntry> implements IMemoryProvider {
1720
1765
  readonly name = "local";
1721
- private readonly filePath;
1722
- private queue;
1723
1766
  constructor(directory?: string);
1724
1767
  query(query: MemoryQuery): Promise<MemoryEntry[]>;
1725
1768
  write(entry: MemoryEntry): Promise<void>;
1726
1769
  count(): Promise<number>;
1727
- private synchronized;
1728
- private load;
1729
- private saveAll;
1730
1770
  }
1731
1771
 
1732
1772
  interface RememberaConfig {
@@ -1816,6 +1856,11 @@ declare class TaskEngine {
1816
1856
 
1817
1857
  declare function createTaskEngine(config: AppConfig, log?: Logger, directory?: string): TaskEngine;
1818
1858
 
1859
+ /**
1860
+ * Report persistence (§16 — report storage). Same replaceable-store and
1861
+ * serialized-write patterns as the other local stores.
1862
+ */
1863
+
1819
1864
  interface ReportFilter {
1820
1865
  taskId?: string;
1821
1866
  agent?: string;
@@ -1830,18 +1875,20 @@ interface ReportStore {
1830
1875
  getCombined(id: string): Promise<CombinedReport | undefined>;
1831
1876
  listCombined(filter?: CombinedReportFilter): Promise<CombinedReport[]>;
1832
1877
  }
1833
- declare class FileReportStore implements ReportStore {
1834
- private readonly filePath;
1835
- private queue;
1878
+ type StoreEntry = {
1879
+ kind: "report";
1880
+ report: Report;
1881
+ } | {
1882
+ kind: "combined";
1883
+ combined: CombinedReport;
1884
+ };
1885
+ declare class FileReportStore extends JsonFileStore<StoreEntry> implements ReportStore {
1836
1886
  constructor(directory?: string);
1837
1887
  saveReports(reports: Report[]): Promise<void>;
1838
1888
  listReports(filter?: ReportFilter): Promise<Report[]>;
1839
1889
  saveCombined(combined: CombinedReport): Promise<void>;
1840
1890
  getCombined(id: string): Promise<CombinedReport | undefined>;
1841
1891
  listCombined(filter?: CombinedReportFilter): Promise<CombinedReport[]>;
1842
- private synchronized;
1843
- private load;
1844
- private write;
1845
1892
  }
1846
1893
 
1847
1894
  /**
@@ -1909,6 +1956,50 @@ interface IPlanner {
1909
1956
  plan(request: PlanRequest): Promise<Plan>;
1910
1957
  }
1911
1958
 
1959
+ /**
1960
+ * Planner context builder (§18): assembles everything the planner needs —
1961
+ * the objective, the combined findings from the AI reports (with source
1962
+ * attribution), relevant memory and the role definition — into one
1963
+ * structured text.
1964
+ */
1965
+
1966
+ declare function buildPlannerContext(request: PlanRequest): string;
1967
+
1968
+ declare class HeuristicPlanner implements IPlanner {
1969
+ readonly name = "heuristic";
1970
+ plan(request: PlanRequest): Promise<Plan>;
1971
+ }
1972
+
1973
+ interface ModelPlannerOptions {
1974
+ model: string;
1975
+ chat: ChatFn;
1976
+ /** Extra instruction appended to the system prompt. */
1977
+ instruction?: string;
1978
+ /** Used when the model output is unparseable (or the call fails, if tolerateErrors). */
1979
+ fallback?: IPlanner;
1980
+ log?: Logger;
1981
+ }
1982
+ declare class ModelPlanner implements IPlanner {
1983
+ private readonly options;
1984
+ readonly name = "model";
1985
+ private readonly log;
1986
+ constructor(options: ModelPlannerOptions);
1987
+ plan(request: PlanRequest): Promise<Plan>;
1988
+ private degrade;
1989
+ }
1990
+ /** Extracts and validates the plan JSON from arbitrary model output. */
1991
+ declare function parsePlanJson(text: string): {
1992
+ summary: string;
1993
+ steps: PlanStep[];
1994
+ risks?: string[];
1995
+ notes?: string[];
1996
+ } | undefined;
1997
+
1998
+ /**
1999
+ * Plan persistence (§27 Phase 8 — planner result storage). Same
2000
+ * replaceable-store pattern as the other local stores.
2001
+ */
2002
+
1912
2003
  interface PlanFilter {
1913
2004
  pipelineRunId?: string;
1914
2005
  taskId?: string;
@@ -1918,6 +2009,19 @@ interface PlanStore {
1918
2009
  get(id: string): Promise<Plan | undefined>;
1919
2010
  list(filter?: PlanFilter): Promise<Plan[]>;
1920
2011
  }
2012
+ declare class FilePlanStore extends JsonFileStore<Plan> implements PlanStore {
2013
+ constructor(directory?: string);
2014
+ save(plan: Plan): Promise<void>;
2015
+ get(id: string): Promise<Plan | undefined>;
2016
+ list(filter?: PlanFilter): Promise<Plan[]>;
2017
+ }
2018
+
2019
+ declare function buildPlanner(plannerConfig: AppConfig["project"]["planner"], chat: ChatFn, log?: Logger): IPlanner | undefined;
2020
+
2021
+ /**
2022
+ * Pipeline run persistence (§27 Phase 5 — pipeline state). Same
2023
+ * replaceable-store pattern as the task store, local-first JSON file.
2024
+ */
1921
2025
 
1922
2026
  interface PipelineRunFilter {
1923
2027
  pipelineId?: string;
@@ -1928,19 +2032,13 @@ interface PipelineRunStore {
1928
2032
  get(id: string): Promise<PipelineRun | undefined>;
1929
2033
  list(filter?: PipelineRunFilter): Promise<PipelineRun[]>;
1930
2034
  }
1931
- declare class FilePipelineRunStore implements PipelineRunStore {
1932
- private readonly filePath;
1933
- private queue;
2035
+ declare class FilePipelineRunStore extends JsonFileStore<PipelineRun> implements PipelineRunStore {
1934
2036
  constructor(directory?: string);
1935
2037
  save(run: PipelineRun): Promise<void>;
1936
2038
  get(id: string): Promise<PipelineRun | undefined>;
1937
2039
  list(filter?: PipelineRunFilter): Promise<PipelineRun[]>;
1938
- private synchronized;
1939
- private load;
1940
- private write;
1941
2040
  }
1942
2041
 
1943
- type ChatFn = (modelRef: string, messages: ChatMessage[]) => Promise<string>;
1944
2042
  interface PipelineEngineOptions {
1945
2043
  tasks: TaskEngine;
1946
2044
  agents: AgentRegistry;
@@ -1994,6 +2092,25 @@ declare function createDefaultChatFn(providers: AppConfig["project"]["providers"
1994
2092
 
1995
2093
  declare function buildPipelineEngine(config: AppConfig, log?: Logger): PipelineEngine;
1996
2094
 
1997
- declare const OMNINODE_VERSION = "1.0.0";
2095
+ /**
2096
+ * Persistence layer (v2 Phase 1): one entry point to every local store.
2097
+ *
2098
+ * All stores are interfaces with a local JSON default
2099
+ * (TaskStore, PipelineRunStore, ReportStore, PlanStore, IMemoryProvider,
2100
+ * AuditSink) — see docs/API.md for the inventory and stability status.
2101
+ */
2102
+
2103
+ /** Bundles every store for a single project directory. */
2104
+ declare class ProjectStores {
2105
+ readonly tasks: FileTaskStore;
2106
+ readonly pipelineRuns: FilePipelineRunStore;
2107
+ readonly reports: FileReportStore;
2108
+ readonly plans: FilePlanStore;
2109
+ readonly memory: LocalMemoryProvider;
2110
+ readonly audit: FileAuditLog;
2111
+ constructor(directory?: string);
2112
+ }
2113
+
2114
+ declare const OMNINODE_VERSION = "2.0.0-alpha.1";
1998
2115
 
1999
- 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, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HttpRequestOptions, type HttpResponse, type IAgent, type IChatProvider, type IMemoryProvider, type IProvider, 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, 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 PlanStep, type PlannerConfigYaml, PlannerError, ProcessAgent, type Project, type ProjectConfigYaml, 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, buildPipelineEngine, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, defaultProjectConfigYaml, expandEnvRefs, extractReportFromText, findConfigFile, isOmniNodeError, keywords, loadConfig, logger, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, registryKey, requestJson, resolveApiKey, roleConfigSchema, similar };
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 };