@hilbras/omninode 0.9.0 → 1.0.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.
- package/README.md +51 -6
- package/dist/cli/index.js +289 -37
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +52 -2
- package/dist/index.js +136 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -98,6 +98,8 @@ interface AgentConfig {
|
|
|
98
98
|
inputMode?: AgentInputMode;
|
|
99
99
|
/** Per-task timeout in milliseconds; the process is killed when exceeded. */
|
|
100
100
|
timeoutMs?: number;
|
|
101
|
+
/** When false, the agent process starts with a minimal environment (PATH + env). */
|
|
102
|
+
inheritEnv?: boolean;
|
|
101
103
|
/** Models (as "provider:model-id") this agent may use, if restricted. */
|
|
102
104
|
allowedModels?: string[];
|
|
103
105
|
metadata?: Record<string, unknown>;
|
|
@@ -298,6 +300,8 @@ interface PipelineStepRun {
|
|
|
298
300
|
interface PipelineRun {
|
|
299
301
|
id: string;
|
|
300
302
|
pipelineId: string;
|
|
303
|
+
/** The objective this run is executing (persisted for retries). */
|
|
304
|
+
objective?: string;
|
|
301
305
|
status: PipelineRunStatus;
|
|
302
306
|
startedAt?: string;
|
|
303
307
|
finishedAt?: string;
|
|
@@ -308,6 +312,8 @@ interface PipelineRun {
|
|
|
308
312
|
combinedReportId?: string;
|
|
309
313
|
/** Set when a plan step produced an implementation plan (§18). */
|
|
310
314
|
planId?: string;
|
|
315
|
+
/** Outcome summary of the final executed step (§28 — Result). */
|
|
316
|
+
resultSummary?: string;
|
|
311
317
|
}
|
|
312
318
|
|
|
313
319
|
/** Plan types: the final implementation plan produced by the planner layer (§18). */
|
|
@@ -597,6 +603,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
597
603
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
598
604
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
599
605
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
606
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
600
607
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
601
608
|
}, "strict", z.ZodTypeAny, {
|
|
602
609
|
name: string;
|
|
@@ -608,6 +615,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
608
615
|
cwd?: string | undefined;
|
|
609
616
|
env?: Record<string, string> | undefined;
|
|
610
617
|
timeout_ms?: number | undefined;
|
|
618
|
+
inherit_env?: boolean | undefined;
|
|
611
619
|
}, {
|
|
612
620
|
name: string;
|
|
613
621
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -618,6 +626,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
618
626
|
env?: Record<string, string> | undefined;
|
|
619
627
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
620
628
|
timeout_ms?: number | undefined;
|
|
629
|
+
inherit_env?: boolean | undefined;
|
|
621
630
|
}>;
|
|
622
631
|
declare const roleConfigSchema: z.ZodObject<{
|
|
623
632
|
id: z.ZodString;
|
|
@@ -789,6 +798,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
789
798
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
790
799
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
791
800
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
801
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
792
802
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
793
803
|
}, "strict", z.ZodTypeAny, {
|
|
794
804
|
name: string;
|
|
@@ -800,6 +810,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
800
810
|
cwd?: string | undefined;
|
|
801
811
|
env?: Record<string, string> | undefined;
|
|
802
812
|
timeout_ms?: number | undefined;
|
|
813
|
+
inherit_env?: boolean | undefined;
|
|
803
814
|
}, {
|
|
804
815
|
name: string;
|
|
805
816
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -810,6 +821,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
810
821
|
env?: Record<string, string> | undefined;
|
|
811
822
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
812
823
|
timeout_ms?: number | undefined;
|
|
824
|
+
inherit_env?: boolean | undefined;
|
|
813
825
|
}>, "many">>;
|
|
814
826
|
roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
815
827
|
id: z.ZodString;
|
|
@@ -941,6 +953,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
941
953
|
cwd?: string | undefined;
|
|
942
954
|
env?: Record<string, string> | undefined;
|
|
943
955
|
timeout_ms?: number | undefined;
|
|
956
|
+
inherit_env?: boolean | undefined;
|
|
944
957
|
}[];
|
|
945
958
|
providers: {
|
|
946
959
|
name: string;
|
|
@@ -999,6 +1012,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
999
1012
|
env?: Record<string, string> | undefined;
|
|
1000
1013
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1001
1014
|
timeout_ms?: number | undefined;
|
|
1015
|
+
inherit_env?: boolean | undefined;
|
|
1002
1016
|
}[] | undefined;
|
|
1003
1017
|
providers?: {
|
|
1004
1018
|
name: string;
|
|
@@ -1084,6 +1098,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1084
1098
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1085
1099
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
1086
1100
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
1101
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
1087
1102
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1088
1103
|
}, "strict", z.ZodTypeAny, {
|
|
1089
1104
|
name: string;
|
|
@@ -1095,6 +1110,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1095
1110
|
cwd?: string | undefined;
|
|
1096
1111
|
env?: Record<string, string> | undefined;
|
|
1097
1112
|
timeout_ms?: number | undefined;
|
|
1113
|
+
inherit_env?: boolean | undefined;
|
|
1098
1114
|
}, {
|
|
1099
1115
|
name: string;
|
|
1100
1116
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -1105,6 +1121,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1105
1121
|
env?: Record<string, string> | undefined;
|
|
1106
1122
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1107
1123
|
timeout_ms?: number | undefined;
|
|
1124
|
+
inherit_env?: boolean | undefined;
|
|
1108
1125
|
}>, "many">>;
|
|
1109
1126
|
roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1110
1127
|
id: z.ZodString;
|
|
@@ -1236,6 +1253,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1236
1253
|
cwd?: string | undefined;
|
|
1237
1254
|
env?: Record<string, string> | undefined;
|
|
1238
1255
|
timeout_ms?: number | undefined;
|
|
1256
|
+
inherit_env?: boolean | undefined;
|
|
1239
1257
|
}[];
|
|
1240
1258
|
providers: {
|
|
1241
1259
|
name: string;
|
|
@@ -1294,6 +1312,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1294
1312
|
env?: Record<string, string> | undefined;
|
|
1295
1313
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1296
1314
|
timeout_ms?: number | undefined;
|
|
1315
|
+
inherit_env?: boolean | undefined;
|
|
1297
1316
|
}[] | undefined;
|
|
1298
1317
|
providers?: {
|
|
1299
1318
|
name: string;
|
|
@@ -1361,6 +1380,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1361
1380
|
cwd?: string | undefined;
|
|
1362
1381
|
env?: Record<string, string> | undefined;
|
|
1363
1382
|
timeout_ms?: number | undefined;
|
|
1383
|
+
inherit_env?: boolean | undefined;
|
|
1364
1384
|
}[];
|
|
1365
1385
|
providers: {
|
|
1366
1386
|
name: string;
|
|
@@ -1424,6 +1444,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1424
1444
|
env?: Record<string, string> | undefined;
|
|
1425
1445
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1426
1446
|
timeout_ms?: number | undefined;
|
|
1447
|
+
inherit_env?: boolean | undefined;
|
|
1427
1448
|
}[] | undefined;
|
|
1428
1449
|
providers?: {
|
|
1429
1450
|
name: string;
|
|
@@ -1672,6 +1693,28 @@ declare class FileTaskStore implements TaskStore {
|
|
|
1672
1693
|
private write;
|
|
1673
1694
|
}
|
|
1674
1695
|
|
|
1696
|
+
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";
|
|
1697
|
+
interface AuditEvent {
|
|
1698
|
+
at: string;
|
|
1699
|
+
action: AuditAction;
|
|
1700
|
+
project?: string;
|
|
1701
|
+
id?: string;
|
|
1702
|
+
actor?: string;
|
|
1703
|
+
detail?: Record<string, unknown>;
|
|
1704
|
+
}
|
|
1705
|
+
interface AuditSink {
|
|
1706
|
+
record(event: AuditEvent): Promise<void>;
|
|
1707
|
+
}
|
|
1708
|
+
/** Append-only JSONL sink. Failures are logged, never propagated. */
|
|
1709
|
+
declare class FileAuditLog implements AuditSink {
|
|
1710
|
+
private readonly filePath;
|
|
1711
|
+
private readonly log;
|
|
1712
|
+
constructor(directory?: string, log?: Logger);
|
|
1713
|
+
record(event: AuditEvent): Promise<void>;
|
|
1714
|
+
/** Recent events, oldest first; used by the CLI. */
|
|
1715
|
+
recent(limit?: number): Promise<AuditEvent[]>;
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1675
1718
|
declare function keywords(text: string): Set<string>;
|
|
1676
1719
|
declare class LocalMemoryProvider implements IMemoryProvider {
|
|
1677
1720
|
readonly name = "local";
|
|
@@ -1746,6 +1789,8 @@ interface TaskEngineOptions {
|
|
|
1746
1789
|
store: TaskStore;
|
|
1747
1790
|
/** When present, tasks gather relevant memory before running and record outcomes after (§20). */
|
|
1748
1791
|
memory?: MemoryService;
|
|
1792
|
+
/** When present, task lifecycle transitions are appended to the audit log (§24). */
|
|
1793
|
+
audit?: AuditSink;
|
|
1749
1794
|
log?: Logger;
|
|
1750
1795
|
}
|
|
1751
1796
|
declare class TaskEngine {
|
|
@@ -1758,10 +1803,13 @@ declare class TaskEngine {
|
|
|
1758
1803
|
/** Runs the task through its assigned agent and records the result. */
|
|
1759
1804
|
run(id: string): Promise<Task>;
|
|
1760
1805
|
cancel(id: string): Promise<Task>;
|
|
1806
|
+
/** Error recovery (§27 Phase 9): reset a failed/cancelled task so it can run again. */
|
|
1807
|
+
retry(id: string): Promise<Task>;
|
|
1761
1808
|
get(id: string): Promise<Task | undefined>;
|
|
1762
1809
|
list(filter?: TaskStoreFilter): Promise<Task[]>;
|
|
1763
1810
|
private mustGet;
|
|
1764
1811
|
private transition;
|
|
1812
|
+
private audit;
|
|
1765
1813
|
}
|
|
1766
1814
|
|
|
1767
1815
|
/** Assembles a TaskEngine from the project configuration (local-first defaults). */
|
|
@@ -1904,6 +1952,8 @@ interface PipelineEngineOptions {
|
|
|
1904
1952
|
planner?: IPlanner;
|
|
1905
1953
|
/** When present, plans produced by plan steps are persisted. */
|
|
1906
1954
|
plans?: PlanStore;
|
|
1955
|
+
/** When present, pipeline lifecycle events are appended to the audit log (§24). */
|
|
1956
|
+
audit?: AuditSink;
|
|
1907
1957
|
/** When present, finished runs have their reports collected, stored and combined (§16–§17). */
|
|
1908
1958
|
reports?: ReportService;
|
|
1909
1959
|
log?: Logger;
|
|
@@ -1944,6 +1994,6 @@ declare function createDefaultChatFn(providers: AppConfig["project"]["providers"
|
|
|
1944
1994
|
|
|
1945
1995
|
declare function buildPipelineEngine(config: AppConfig, log?: Logger): PipelineEngine;
|
|
1946
1996
|
|
|
1947
|
-
declare const OMNINODE_VERSION = "0.
|
|
1997
|
+
declare const OMNINODE_VERSION = "1.0.0";
|
|
1948
1998
|
|
|
1949
|
-
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 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, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -130,6 +130,7 @@ var agentConfigSchema = z.object({
|
|
|
130
130
|
env: z.record(z.string()).optional(),
|
|
131
131
|
input_mode: z.enum(["stdin", "arg", "protocol"]).default("stdin"),
|
|
132
132
|
timeout_ms: z.number().int().positive().optional(),
|
|
133
|
+
inherit_env: z.boolean().optional(),
|
|
133
134
|
metadata: z.record(z.unknown()).optional()
|
|
134
135
|
}).strict();
|
|
135
136
|
var roleConfigSchema = z.object({
|
|
@@ -303,6 +304,7 @@ function toAgentConfig(raw) {
|
|
|
303
304
|
env: raw.env,
|
|
304
305
|
inputMode: raw.input_mode,
|
|
305
306
|
timeoutMs: raw.timeout_ms,
|
|
307
|
+
inheritEnv: raw.inherit_env,
|
|
306
308
|
metadata: raw.metadata
|
|
307
309
|
};
|
|
308
310
|
}
|
|
@@ -664,6 +666,17 @@ var ModelRegistry = class {
|
|
|
664
666
|
import { spawn } from "child_process";
|
|
665
667
|
var DEFAULT_TIMEOUT_MS2 = 6e5;
|
|
666
668
|
var KILL_GRACE_MS = 5e3;
|
|
669
|
+
function buildChildEnv(config) {
|
|
670
|
+
const configured = config.env ?? {};
|
|
671
|
+
if (config.inheritEnv !== false) {
|
|
672
|
+
return { ...process.env, ...configured };
|
|
673
|
+
}
|
|
674
|
+
return {
|
|
675
|
+
PATH: process.env.PATH ?? "",
|
|
676
|
+
HOME: process.env.HOME ?? "",
|
|
677
|
+
...configured
|
|
678
|
+
};
|
|
679
|
+
}
|
|
667
680
|
function composeTaskText(input) {
|
|
668
681
|
const sections = [`# Objective
|
|
669
682
|
${input.objective}`];
|
|
@@ -730,7 +743,7 @@ var ProcessAgent = class {
|
|
|
730
743
|
[...this.config.args ?? [], ...mode === "arg" ? [composeTaskText(input)] : []],
|
|
731
744
|
{
|
|
732
745
|
cwd: this.config.cwd,
|
|
733
|
-
env:
|
|
746
|
+
env: buildChildEnv(this.config),
|
|
734
747
|
stdio: ["pipe", "pipe", "pipe"]
|
|
735
748
|
}
|
|
736
749
|
);
|
|
@@ -1085,6 +1098,7 @@ var TaskEngine = class {
|
|
|
1085
1098
|
};
|
|
1086
1099
|
await this.options.store.save(task);
|
|
1087
1100
|
this.log.info(`Created task ${task.id}.`);
|
|
1101
|
+
await this.audit("task.created", task.id, { objective: task.objective, project: task.project });
|
|
1088
1102
|
return task;
|
|
1089
1103
|
}
|
|
1090
1104
|
async queue(id) {
|
|
@@ -1160,6 +1174,26 @@ var TaskEngine = class {
|
|
|
1160
1174
|
}
|
|
1161
1175
|
return this.transition(task, "cancelled");
|
|
1162
1176
|
}
|
|
1177
|
+
/** Error recovery (§27 Phase 9): reset a failed/cancelled task so it can run again. */
|
|
1178
|
+
async retry(id) {
|
|
1179
|
+
const task = await this.mustGet(id);
|
|
1180
|
+
if (task.status !== "failed" && task.status !== "cancelled") {
|
|
1181
|
+
throw new TaskError(
|
|
1182
|
+
"TASK_INVALID",
|
|
1183
|
+
`Only failed or cancelled tasks can be retried \u2014 task ${id} is "${task.status}".`
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
const { result: _discarded, ...rest } = task;
|
|
1187
|
+
const reset = {
|
|
1188
|
+
...rest,
|
|
1189
|
+
status: "created",
|
|
1190
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1191
|
+
};
|
|
1192
|
+
await this.options.store.save(reset);
|
|
1193
|
+
await this.audit("task.retry", id, { from: task.status });
|
|
1194
|
+
this.log.info(`Task ${id} reset for retry.`);
|
|
1195
|
+
return reset;
|
|
1196
|
+
}
|
|
1163
1197
|
async get(id) {
|
|
1164
1198
|
return this.options.store.get(id);
|
|
1165
1199
|
}
|
|
@@ -1185,16 +1219,68 @@ var TaskEngine = class {
|
|
|
1185
1219
|
...extra.result !== void 0 ? { result: { ...task.result, ...extra.result } } : {}
|
|
1186
1220
|
};
|
|
1187
1221
|
await this.options.store.save(updated);
|
|
1222
|
+
await this.audit(`task.${to === "queued" ? "queued" : to}`, updated.id, {
|
|
1223
|
+
from: task.status
|
|
1224
|
+
});
|
|
1188
1225
|
return updated;
|
|
1189
1226
|
}
|
|
1227
|
+
async audit(action, id, detail) {
|
|
1228
|
+
await this.options.audit?.record({
|
|
1229
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1230
|
+
action,
|
|
1231
|
+
id,
|
|
1232
|
+
...detail !== void 0 ? { detail } : {}
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1190
1235
|
};
|
|
1191
1236
|
function generateTaskId() {
|
|
1192
1237
|
return `task-${Date.now().toString(36)}-${randomBytes(3).toString("hex")}`;
|
|
1193
1238
|
}
|
|
1194
1239
|
|
|
1195
|
-
// src/
|
|
1196
|
-
import { mkdir as mkdir2
|
|
1240
|
+
// src/audit/index.ts
|
|
1241
|
+
import { appendFile, mkdir as mkdir2 } from "fs/promises";
|
|
1197
1242
|
import { dirname as dirname2 } from "path";
|
|
1243
|
+
var FileAuditLog = class {
|
|
1244
|
+
filePath;
|
|
1245
|
+
log;
|
|
1246
|
+
constructor(directory = `${process.cwd()}/.omninode`, log = logger) {
|
|
1247
|
+
this.filePath = `${directory}/audit.jsonl`;
|
|
1248
|
+
this.log = log.child({ component: "audit" });
|
|
1249
|
+
}
|
|
1250
|
+
async record(event) {
|
|
1251
|
+
try {
|
|
1252
|
+
await mkdir2(dirname2(this.filePath), { recursive: true });
|
|
1253
|
+
await appendFile(this.filePath, `${JSON.stringify(event)}
|
|
1254
|
+
`, "utf8");
|
|
1255
|
+
} catch (error) {
|
|
1256
|
+
this.log.warn(
|
|
1257
|
+
`Audit write failed: ${error instanceof Error ? error.message : String(error)}`
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
/** Recent events, oldest first; used by the CLI. */
|
|
1262
|
+
async recent(limit = 20) {
|
|
1263
|
+
const { readFile: readFile6 } = await import("fs/promises");
|
|
1264
|
+
let raw;
|
|
1265
|
+
try {
|
|
1266
|
+
raw = await readFile6(this.filePath, "utf8");
|
|
1267
|
+
} catch {
|
|
1268
|
+
return [];
|
|
1269
|
+
}
|
|
1270
|
+
const events = raw.split("\n").filter((line) => line.length > 0).map((line) => {
|
|
1271
|
+
try {
|
|
1272
|
+
return JSON.parse(line);
|
|
1273
|
+
} catch {
|
|
1274
|
+
return void 0;
|
|
1275
|
+
}
|
|
1276
|
+
}).filter((event) => event !== void 0);
|
|
1277
|
+
return events.slice(-limit);
|
|
1278
|
+
}
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
// src/memory/local.ts
|
|
1282
|
+
import { mkdir as mkdir3, readFile as readFile2, rename as rename2, writeFile as writeFile2 } from "fs/promises";
|
|
1283
|
+
import { dirname as dirname3 } from "path";
|
|
1198
1284
|
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
1199
1285
|
"the",
|
|
1200
1286
|
"and",
|
|
@@ -1307,7 +1393,7 @@ var LocalMemoryProvider = class {
|
|
|
1307
1393
|
}
|
|
1308
1394
|
async saveAll(entries) {
|
|
1309
1395
|
const tmp = `${this.filePath}.tmp`;
|
|
1310
|
-
await
|
|
1396
|
+
await mkdir3(dirname3(this.filePath), { recursive: true });
|
|
1311
1397
|
await writeFile2(tmp, `${JSON.stringify(entries, null, 2)}
|
|
1312
1398
|
`, "utf8");
|
|
1313
1399
|
await rename2(tmp, this.filePath);
|
|
@@ -1492,6 +1578,7 @@ function createTaskEngine(config, log = logger, directory) {
|
|
|
1492
1578
|
roles,
|
|
1493
1579
|
store: new FileTaskStore(directory),
|
|
1494
1580
|
...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
|
|
1581
|
+
audit: new FileAuditLog(),
|
|
1495
1582
|
log
|
|
1496
1583
|
});
|
|
1497
1584
|
}
|
|
@@ -1836,12 +1923,19 @@ var PipelineEngine = class {
|
|
|
1836
1923
|
const run = {
|
|
1837
1924
|
id: `run-${Date.now().toString(36)}-${randomBytes4(3).toString("hex")}`,
|
|
1838
1925
|
pipelineId: def.id,
|
|
1926
|
+
objective,
|
|
1839
1927
|
status: "running",
|
|
1840
1928
|
startedAt: now,
|
|
1841
1929
|
stepRuns: []
|
|
1842
1930
|
};
|
|
1843
1931
|
await this.options.store.save(run);
|
|
1844
1932
|
this.log.info(`Running pipeline ${def.id} as ${run.id}.`);
|
|
1933
|
+
await this.options.audit?.record({
|
|
1934
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1935
|
+
action: "pipeline.run.started",
|
|
1936
|
+
id: run.id,
|
|
1937
|
+
detail: { pipeline: def.id, objective }
|
|
1938
|
+
});
|
|
1845
1939
|
const deps = this.effectiveDependencies(def);
|
|
1846
1940
|
const outcomes = /* @__PURE__ */ new Map();
|
|
1847
1941
|
const pending = new Set(def.steps.map((s) => s.id));
|
|
@@ -1895,9 +1989,19 @@ ${contribution}`);
|
|
|
1895
1989
|
const failed = [...outcomes.values()].some((o) => o.status === "failed");
|
|
1896
1990
|
const finalStatus = failed ? "failed" : "completed";
|
|
1897
1991
|
const planId = [...outcomes.values()].find((o) => o.planId !== void 0)?.planId;
|
|
1992
|
+
let resultSummary;
|
|
1993
|
+
for (let i = def.steps.length - 1; i >= 0; i -= 1) {
|
|
1994
|
+
const step = def.steps[i];
|
|
1995
|
+
const outcome = outcomes.get(step.id);
|
|
1996
|
+
if (outcome?.status !== "completed" || outcome.taskIds.length === 0) continue;
|
|
1997
|
+
const stepTasks = (await Promise.all(outcome.taskIds.map((id) => this.options.tasks.get(id)))).filter((task) => task !== void 0);
|
|
1998
|
+
const summaries = stepTasks.map((task) => task.result?.summary).filter((summary) => summary !== void 0);
|
|
1999
|
+
if (summaries.length > 0) resultSummary = summaries.join("\n");
|
|
2000
|
+
break;
|
|
2001
|
+
}
|
|
1898
2002
|
let combinedReportId;
|
|
1899
2003
|
if (this.options.reports) {
|
|
1900
|
-
const taskIds =
|
|
2004
|
+
const taskIds = def.steps.filter((step) => step.kind === "research" || step.kind === "analyze").flatMap((step) => outcomes.get(step.id)?.taskIds ?? []);
|
|
1901
2005
|
const tasks = (await Promise.all(taskIds.map((id) => this.options.tasks.get(id)))).filter((task) => task !== void 0);
|
|
1902
2006
|
const collected = await this.options.reports.collectFromTasks(tasks);
|
|
1903
2007
|
await this.options.reports.saveReports(collected);
|
|
@@ -1917,10 +2021,17 @@ ${contribution}`);
|
|
|
1917
2021
|
finishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1918
2022
|
...run.reports !== void 0 && run.reports.length > 0 ? { reports: run.reports } : {},
|
|
1919
2023
|
...combinedReportId !== void 0 ? { combinedReportId } : {},
|
|
1920
|
-
...planId !== void 0 ? { planId } : {}
|
|
2024
|
+
...planId !== void 0 ? { planId } : {},
|
|
2025
|
+
...resultSummary !== void 0 ? { resultSummary } : {}
|
|
1921
2026
|
};
|
|
1922
2027
|
await this.options.store.save(finished);
|
|
1923
2028
|
this.log.info(`Pipeline ${def.id} finished: ${finalStatus}.`);
|
|
2029
|
+
await this.options.audit?.record({
|
|
2030
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2031
|
+
action: "pipeline.run.finished",
|
|
2032
|
+
id: run.id,
|
|
2033
|
+
detail: { pipeline: def.id, status: finalStatus }
|
|
2034
|
+
});
|
|
1924
2035
|
return finished;
|
|
1925
2036
|
}
|
|
1926
2037
|
async get(runId) {
|
|
@@ -2065,6 +2176,12 @@ ${contribution}`);
|
|
|
2065
2176
|
};
|
|
2066
2177
|
}
|
|
2067
2178
|
await this.options.plans?.save(plan);
|
|
2179
|
+
await this.options.audit?.record({
|
|
2180
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2181
|
+
action: "plan.generated",
|
|
2182
|
+
id: plan.id,
|
|
2183
|
+
detail: { generatedBy: plan.generatedBy, steps: plan.steps.length }
|
|
2184
|
+
});
|
|
2068
2185
|
return {
|
|
2069
2186
|
status: "completed",
|
|
2070
2187
|
summary: plan.summary,
|
|
@@ -2122,8 +2239,8 @@ function createDefaultChatFn(providers) {
|
|
|
2122
2239
|
}
|
|
2123
2240
|
|
|
2124
2241
|
// src/pipelines/store.ts
|
|
2125
|
-
import { mkdir as
|
|
2126
|
-
import { dirname as
|
|
2242
|
+
import { mkdir as mkdir4, readFile as readFile3, rename as rename3, writeFile as writeFile3 } from "fs/promises";
|
|
2243
|
+
import { dirname as dirname4 } from "path";
|
|
2127
2244
|
var FilePipelineRunStore = class {
|
|
2128
2245
|
filePath;
|
|
2129
2246
|
queue = Promise.resolve();
|
|
@@ -2170,7 +2287,7 @@ var FilePipelineRunStore = class {
|
|
|
2170
2287
|
}
|
|
2171
2288
|
async write(runs) {
|
|
2172
2289
|
const tmp = `${this.filePath}.tmp`;
|
|
2173
|
-
await
|
|
2290
|
+
await mkdir4(dirname4(this.filePath), { recursive: true });
|
|
2174
2291
|
await writeFile3(tmp, `${JSON.stringify(runs, null, 2)}
|
|
2175
2292
|
`, "utf8");
|
|
2176
2293
|
await rename3(tmp, this.filePath);
|
|
@@ -2178,8 +2295,8 @@ var FilePipelineRunStore = class {
|
|
|
2178
2295
|
};
|
|
2179
2296
|
|
|
2180
2297
|
// src/planner/store.ts
|
|
2181
|
-
import { mkdir as
|
|
2182
|
-
import { dirname as
|
|
2298
|
+
import { mkdir as mkdir5, readFile as readFile4, rename as rename4, writeFile as writeFile4 } from "fs/promises";
|
|
2299
|
+
import { dirname as dirname5 } from "path";
|
|
2183
2300
|
var FilePlanStore = class {
|
|
2184
2301
|
filePath;
|
|
2185
2302
|
queue = Promise.resolve();
|
|
@@ -2226,7 +2343,7 @@ var FilePlanStore = class {
|
|
|
2226
2343
|
}
|
|
2227
2344
|
async write(plans) {
|
|
2228
2345
|
const tmp = `${this.filePath}.tmp`;
|
|
2229
|
-
await
|
|
2346
|
+
await mkdir5(dirname5(this.filePath), { recursive: true });
|
|
2230
2347
|
await writeFile4(tmp, `${JSON.stringify(plans, null, 2)}
|
|
2231
2348
|
`, "utf8");
|
|
2232
2349
|
await rename4(tmp, this.filePath);
|
|
@@ -2465,8 +2582,8 @@ var ReportService = class {
|
|
|
2465
2582
|
};
|
|
2466
2583
|
|
|
2467
2584
|
// src/reports/store.ts
|
|
2468
|
-
import { mkdir as
|
|
2469
|
-
import { dirname as
|
|
2585
|
+
import { mkdir as mkdir6, readFile as readFile5, rename as rename5, writeFile as writeFile5 } from "fs/promises";
|
|
2586
|
+
import { dirname as dirname6 } from "path";
|
|
2470
2587
|
var FileReportStore = class {
|
|
2471
2588
|
filePath;
|
|
2472
2589
|
queue = Promise.resolve();
|
|
@@ -2539,7 +2656,7 @@ var FileReportStore = class {
|
|
|
2539
2656
|
}
|
|
2540
2657
|
async write(entries) {
|
|
2541
2658
|
const tmp = `${this.filePath}.tmp`;
|
|
2542
|
-
await
|
|
2659
|
+
await mkdir6(dirname6(this.filePath), { recursive: true });
|
|
2543
2660
|
await writeFile5(tmp, `${JSON.stringify(entries, null, 2)}
|
|
2544
2661
|
`, "utf8");
|
|
2545
2662
|
await rename5(tmp, this.filePath);
|
|
@@ -2556,6 +2673,7 @@ function buildPipelineEngine(config, log = logger) {
|
|
|
2556
2673
|
roles,
|
|
2557
2674
|
store: new FileTaskStore(),
|
|
2558
2675
|
...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
|
|
2676
|
+
audit: new FileAuditLog(),
|
|
2559
2677
|
log
|
|
2560
2678
|
});
|
|
2561
2679
|
return new PipelineEngine({
|
|
@@ -2568,17 +2686,19 @@ function buildPipelineEngine(config, log = logger) {
|
|
|
2568
2686
|
...config.project.planner !== void 0 ? { planner: buildPlanner(config.project.planner, chat, log) } : {},
|
|
2569
2687
|
plans: new FilePlanStore(),
|
|
2570
2688
|
reports: new ReportService(new FileReportStore(), log),
|
|
2689
|
+
audit: new FileAuditLog(),
|
|
2571
2690
|
log
|
|
2572
2691
|
});
|
|
2573
2692
|
}
|
|
2574
2693
|
|
|
2575
2694
|
// src/version.ts
|
|
2576
|
-
var OMNINODE_VERSION = "0.
|
|
2695
|
+
var OMNINODE_VERSION = "1.0.0";
|
|
2577
2696
|
export {
|
|
2578
2697
|
AgentError,
|
|
2579
2698
|
AgentRegistry,
|
|
2580
2699
|
ConfigError,
|
|
2581
2700
|
ConsoleLogSink,
|
|
2701
|
+
FileAuditLog,
|
|
2582
2702
|
FilePipelineRunStore,
|
|
2583
2703
|
FileReportStore,
|
|
2584
2704
|
FileTaskStore,
|