@hilbras/omninode 0.10.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 +33 -7
- package/dist/cli/index.js +168 -35
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +46 -2
- package/dist/index.js +103 -14
- 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>;
|
|
@@ -601,6 +603,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
601
603
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
602
604
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
603
605
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
606
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
604
607
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
605
608
|
}, "strict", z.ZodTypeAny, {
|
|
606
609
|
name: string;
|
|
@@ -612,6 +615,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
612
615
|
cwd?: string | undefined;
|
|
613
616
|
env?: Record<string, string> | undefined;
|
|
614
617
|
timeout_ms?: number | undefined;
|
|
618
|
+
inherit_env?: boolean | undefined;
|
|
615
619
|
}, {
|
|
616
620
|
name: string;
|
|
617
621
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -622,6 +626,7 @@ declare const agentConfigSchema: z.ZodObject<{
|
|
|
622
626
|
env?: Record<string, string> | undefined;
|
|
623
627
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
624
628
|
timeout_ms?: number | undefined;
|
|
629
|
+
inherit_env?: boolean | undefined;
|
|
625
630
|
}>;
|
|
626
631
|
declare const roleConfigSchema: z.ZodObject<{
|
|
627
632
|
id: z.ZodString;
|
|
@@ -793,6 +798,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
793
798
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
794
799
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
795
800
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
801
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
796
802
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
797
803
|
}, "strict", z.ZodTypeAny, {
|
|
798
804
|
name: string;
|
|
@@ -804,6 +810,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
804
810
|
cwd?: string | undefined;
|
|
805
811
|
env?: Record<string, string> | undefined;
|
|
806
812
|
timeout_ms?: number | undefined;
|
|
813
|
+
inherit_env?: boolean | undefined;
|
|
807
814
|
}, {
|
|
808
815
|
name: string;
|
|
809
816
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -814,6 +821,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
814
821
|
env?: Record<string, string> | undefined;
|
|
815
822
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
816
823
|
timeout_ms?: number | undefined;
|
|
824
|
+
inherit_env?: boolean | undefined;
|
|
817
825
|
}>, "many">>;
|
|
818
826
|
roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
819
827
|
id: z.ZodString;
|
|
@@ -945,6 +953,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
945
953
|
cwd?: string | undefined;
|
|
946
954
|
env?: Record<string, string> | undefined;
|
|
947
955
|
timeout_ms?: number | undefined;
|
|
956
|
+
inherit_env?: boolean | undefined;
|
|
948
957
|
}[];
|
|
949
958
|
providers: {
|
|
950
959
|
name: string;
|
|
@@ -1003,6 +1012,7 @@ declare const projectConfigSchema: z.ZodObject<{
|
|
|
1003
1012
|
env?: Record<string, string> | undefined;
|
|
1004
1013
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1005
1014
|
timeout_ms?: number | undefined;
|
|
1015
|
+
inherit_env?: boolean | undefined;
|
|
1006
1016
|
}[] | undefined;
|
|
1007
1017
|
providers?: {
|
|
1008
1018
|
name: string;
|
|
@@ -1088,6 +1098,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1088
1098
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1089
1099
|
input_mode: z.ZodDefault<z.ZodEnum<["stdin", "arg", "protocol"]>>;
|
|
1090
1100
|
timeout_ms: z.ZodOptional<z.ZodNumber>;
|
|
1101
|
+
inherit_env: z.ZodOptional<z.ZodBoolean>;
|
|
1091
1102
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1092
1103
|
}, "strict", z.ZodTypeAny, {
|
|
1093
1104
|
name: string;
|
|
@@ -1099,6 +1110,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1099
1110
|
cwd?: string | undefined;
|
|
1100
1111
|
env?: Record<string, string> | undefined;
|
|
1101
1112
|
timeout_ms?: number | undefined;
|
|
1113
|
+
inherit_env?: boolean | undefined;
|
|
1102
1114
|
}, {
|
|
1103
1115
|
name: string;
|
|
1104
1116
|
type?: "native" | "process" | "cli" | undefined;
|
|
@@ -1109,6 +1121,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1109
1121
|
env?: Record<string, string> | undefined;
|
|
1110
1122
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1111
1123
|
timeout_ms?: number | undefined;
|
|
1124
|
+
inherit_env?: boolean | undefined;
|
|
1112
1125
|
}>, "many">>;
|
|
1113
1126
|
roles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1114
1127
|
id: z.ZodString;
|
|
@@ -1240,6 +1253,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1240
1253
|
cwd?: string | undefined;
|
|
1241
1254
|
env?: Record<string, string> | undefined;
|
|
1242
1255
|
timeout_ms?: number | undefined;
|
|
1256
|
+
inherit_env?: boolean | undefined;
|
|
1243
1257
|
}[];
|
|
1244
1258
|
providers: {
|
|
1245
1259
|
name: string;
|
|
@@ -1298,6 +1312,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1298
1312
|
env?: Record<string, string> | undefined;
|
|
1299
1313
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1300
1314
|
timeout_ms?: number | undefined;
|
|
1315
|
+
inherit_env?: boolean | undefined;
|
|
1301
1316
|
}[] | undefined;
|
|
1302
1317
|
providers?: {
|
|
1303
1318
|
name: string;
|
|
@@ -1365,6 +1380,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1365
1380
|
cwd?: string | undefined;
|
|
1366
1381
|
env?: Record<string, string> | undefined;
|
|
1367
1382
|
timeout_ms?: number | undefined;
|
|
1383
|
+
inherit_env?: boolean | undefined;
|
|
1368
1384
|
}[];
|
|
1369
1385
|
providers: {
|
|
1370
1386
|
name: string;
|
|
@@ -1428,6 +1444,7 @@ declare const appConfigSchema: z.ZodObject<{
|
|
|
1428
1444
|
env?: Record<string, string> | undefined;
|
|
1429
1445
|
input_mode?: "stdin" | "arg" | "protocol" | undefined;
|
|
1430
1446
|
timeout_ms?: number | undefined;
|
|
1447
|
+
inherit_env?: boolean | undefined;
|
|
1431
1448
|
}[] | undefined;
|
|
1432
1449
|
providers?: {
|
|
1433
1450
|
name: string;
|
|
@@ -1676,6 +1693,28 @@ declare class FileTaskStore implements TaskStore {
|
|
|
1676
1693
|
private write;
|
|
1677
1694
|
}
|
|
1678
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
|
+
|
|
1679
1718
|
declare function keywords(text: string): Set<string>;
|
|
1680
1719
|
declare class LocalMemoryProvider implements IMemoryProvider {
|
|
1681
1720
|
readonly name = "local";
|
|
@@ -1750,6 +1789,8 @@ interface TaskEngineOptions {
|
|
|
1750
1789
|
store: TaskStore;
|
|
1751
1790
|
/** When present, tasks gather relevant memory before running and record outcomes after (§20). */
|
|
1752
1791
|
memory?: MemoryService;
|
|
1792
|
+
/** When present, task lifecycle transitions are appended to the audit log (§24). */
|
|
1793
|
+
audit?: AuditSink;
|
|
1753
1794
|
log?: Logger;
|
|
1754
1795
|
}
|
|
1755
1796
|
declare class TaskEngine {
|
|
@@ -1768,6 +1809,7 @@ declare class TaskEngine {
|
|
|
1768
1809
|
list(filter?: TaskStoreFilter): Promise<Task[]>;
|
|
1769
1810
|
private mustGet;
|
|
1770
1811
|
private transition;
|
|
1812
|
+
private audit;
|
|
1771
1813
|
}
|
|
1772
1814
|
|
|
1773
1815
|
/** Assembles a TaskEngine from the project configuration (local-first defaults). */
|
|
@@ -1910,6 +1952,8 @@ interface PipelineEngineOptions {
|
|
|
1910
1952
|
planner?: IPlanner;
|
|
1911
1953
|
/** When present, plans produced by plan steps are persisted. */
|
|
1912
1954
|
plans?: PlanStore;
|
|
1955
|
+
/** When present, pipeline lifecycle events are appended to the audit log (§24). */
|
|
1956
|
+
audit?: AuditSink;
|
|
1913
1957
|
/** When present, finished runs have their reports collected, stored and combined (§16–§17). */
|
|
1914
1958
|
reports?: ReportService;
|
|
1915
1959
|
log?: Logger;
|
|
@@ -1950,6 +1994,6 @@ declare function createDefaultChatFn(providers: AppConfig["project"]["providers"
|
|
|
1950
1994
|
|
|
1951
1995
|
declare function buildPipelineEngine(config: AppConfig, log?: Logger): PipelineEngine;
|
|
1952
1996
|
|
|
1953
|
-
declare const OMNINODE_VERSION = "0.
|
|
1997
|
+
declare const OMNINODE_VERSION = "1.0.0";
|
|
1954
1998
|
|
|
1955
|
-
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) {
|
|
@@ -1176,6 +1190,7 @@ var TaskEngine = class {
|
|
|
1176
1190
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1177
1191
|
};
|
|
1178
1192
|
await this.options.store.save(reset);
|
|
1193
|
+
await this.audit("task.retry", id, { from: task.status });
|
|
1179
1194
|
this.log.info(`Task ${id} reset for retry.`);
|
|
1180
1195
|
return reset;
|
|
1181
1196
|
}
|
|
@@ -1204,16 +1219,68 @@ var TaskEngine = class {
|
|
|
1204
1219
|
...extra.result !== void 0 ? { result: { ...task.result, ...extra.result } } : {}
|
|
1205
1220
|
};
|
|
1206
1221
|
await this.options.store.save(updated);
|
|
1222
|
+
await this.audit(`task.${to === "queued" ? "queued" : to}`, updated.id, {
|
|
1223
|
+
from: task.status
|
|
1224
|
+
});
|
|
1207
1225
|
return updated;
|
|
1208
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
|
+
}
|
|
1209
1235
|
};
|
|
1210
1236
|
function generateTaskId() {
|
|
1211
1237
|
return `task-${Date.now().toString(36)}-${randomBytes(3).toString("hex")}`;
|
|
1212
1238
|
}
|
|
1213
1239
|
|
|
1214
|
-
// src/
|
|
1215
|
-
import { mkdir as mkdir2
|
|
1240
|
+
// src/audit/index.ts
|
|
1241
|
+
import { appendFile, mkdir as mkdir2 } from "fs/promises";
|
|
1216
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";
|
|
1217
1284
|
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
1218
1285
|
"the",
|
|
1219
1286
|
"and",
|
|
@@ -1326,7 +1393,7 @@ var LocalMemoryProvider = class {
|
|
|
1326
1393
|
}
|
|
1327
1394
|
async saveAll(entries) {
|
|
1328
1395
|
const tmp = `${this.filePath}.tmp`;
|
|
1329
|
-
await
|
|
1396
|
+
await mkdir3(dirname3(this.filePath), { recursive: true });
|
|
1330
1397
|
await writeFile2(tmp, `${JSON.stringify(entries, null, 2)}
|
|
1331
1398
|
`, "utf8");
|
|
1332
1399
|
await rename2(tmp, this.filePath);
|
|
@@ -1511,6 +1578,7 @@ function createTaskEngine(config, log = logger, directory) {
|
|
|
1511
1578
|
roles,
|
|
1512
1579
|
store: new FileTaskStore(directory),
|
|
1513
1580
|
...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
|
|
1581
|
+
audit: new FileAuditLog(),
|
|
1514
1582
|
log
|
|
1515
1583
|
});
|
|
1516
1584
|
}
|
|
@@ -1862,6 +1930,12 @@ var PipelineEngine = class {
|
|
|
1862
1930
|
};
|
|
1863
1931
|
await this.options.store.save(run);
|
|
1864
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
|
+
});
|
|
1865
1939
|
const deps = this.effectiveDependencies(def);
|
|
1866
1940
|
const outcomes = /* @__PURE__ */ new Map();
|
|
1867
1941
|
const pending = new Set(def.steps.map((s) => s.id));
|
|
@@ -1952,6 +2026,12 @@ ${contribution}`);
|
|
|
1952
2026
|
};
|
|
1953
2027
|
await this.options.store.save(finished);
|
|
1954
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
|
+
});
|
|
1955
2035
|
return finished;
|
|
1956
2036
|
}
|
|
1957
2037
|
async get(runId) {
|
|
@@ -2096,6 +2176,12 @@ ${contribution}`);
|
|
|
2096
2176
|
};
|
|
2097
2177
|
}
|
|
2098
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
|
+
});
|
|
2099
2185
|
return {
|
|
2100
2186
|
status: "completed",
|
|
2101
2187
|
summary: plan.summary,
|
|
@@ -2153,8 +2239,8 @@ function createDefaultChatFn(providers) {
|
|
|
2153
2239
|
}
|
|
2154
2240
|
|
|
2155
2241
|
// src/pipelines/store.ts
|
|
2156
|
-
import { mkdir as
|
|
2157
|
-
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";
|
|
2158
2244
|
var FilePipelineRunStore = class {
|
|
2159
2245
|
filePath;
|
|
2160
2246
|
queue = Promise.resolve();
|
|
@@ -2201,7 +2287,7 @@ var FilePipelineRunStore = class {
|
|
|
2201
2287
|
}
|
|
2202
2288
|
async write(runs) {
|
|
2203
2289
|
const tmp = `${this.filePath}.tmp`;
|
|
2204
|
-
await
|
|
2290
|
+
await mkdir4(dirname4(this.filePath), { recursive: true });
|
|
2205
2291
|
await writeFile3(tmp, `${JSON.stringify(runs, null, 2)}
|
|
2206
2292
|
`, "utf8");
|
|
2207
2293
|
await rename3(tmp, this.filePath);
|
|
@@ -2209,8 +2295,8 @@ var FilePipelineRunStore = class {
|
|
|
2209
2295
|
};
|
|
2210
2296
|
|
|
2211
2297
|
// src/planner/store.ts
|
|
2212
|
-
import { mkdir as
|
|
2213
|
-
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";
|
|
2214
2300
|
var FilePlanStore = class {
|
|
2215
2301
|
filePath;
|
|
2216
2302
|
queue = Promise.resolve();
|
|
@@ -2257,7 +2343,7 @@ var FilePlanStore = class {
|
|
|
2257
2343
|
}
|
|
2258
2344
|
async write(plans) {
|
|
2259
2345
|
const tmp = `${this.filePath}.tmp`;
|
|
2260
|
-
await
|
|
2346
|
+
await mkdir5(dirname5(this.filePath), { recursive: true });
|
|
2261
2347
|
await writeFile4(tmp, `${JSON.stringify(plans, null, 2)}
|
|
2262
2348
|
`, "utf8");
|
|
2263
2349
|
await rename4(tmp, this.filePath);
|
|
@@ -2496,8 +2582,8 @@ var ReportService = class {
|
|
|
2496
2582
|
};
|
|
2497
2583
|
|
|
2498
2584
|
// src/reports/store.ts
|
|
2499
|
-
import { mkdir as
|
|
2500
|
-
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";
|
|
2501
2587
|
var FileReportStore = class {
|
|
2502
2588
|
filePath;
|
|
2503
2589
|
queue = Promise.resolve();
|
|
@@ -2570,7 +2656,7 @@ var FileReportStore = class {
|
|
|
2570
2656
|
}
|
|
2571
2657
|
async write(entries) {
|
|
2572
2658
|
const tmp = `${this.filePath}.tmp`;
|
|
2573
|
-
await
|
|
2659
|
+
await mkdir6(dirname6(this.filePath), { recursive: true });
|
|
2574
2660
|
await writeFile5(tmp, `${JSON.stringify(entries, null, 2)}
|
|
2575
2661
|
`, "utf8");
|
|
2576
2662
|
await rename5(tmp, this.filePath);
|
|
@@ -2587,6 +2673,7 @@ function buildPipelineEngine(config, log = logger) {
|
|
|
2587
2673
|
roles,
|
|
2588
2674
|
store: new FileTaskStore(),
|
|
2589
2675
|
...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
|
|
2676
|
+
audit: new FileAuditLog(),
|
|
2590
2677
|
log
|
|
2591
2678
|
});
|
|
2592
2679
|
return new PipelineEngine({
|
|
@@ -2599,17 +2686,19 @@ function buildPipelineEngine(config, log = logger) {
|
|
|
2599
2686
|
...config.project.planner !== void 0 ? { planner: buildPlanner(config.project.planner, chat, log) } : {},
|
|
2600
2687
|
plans: new FilePlanStore(),
|
|
2601
2688
|
reports: new ReportService(new FileReportStore(), log),
|
|
2689
|
+
audit: new FileAuditLog(),
|
|
2602
2690
|
log
|
|
2603
2691
|
});
|
|
2604
2692
|
}
|
|
2605
2693
|
|
|
2606
2694
|
// src/version.ts
|
|
2607
|
-
var OMNINODE_VERSION = "0.
|
|
2695
|
+
var OMNINODE_VERSION = "1.0.0";
|
|
2608
2696
|
export {
|
|
2609
2697
|
AgentError,
|
|
2610
2698
|
AgentRegistry,
|
|
2611
2699
|
ConfigError,
|
|
2612
2700
|
ConsoleLogSink,
|
|
2701
|
+
FileAuditLog,
|
|
2613
2702
|
FilePipelineRunStore,
|
|
2614
2703
|
FileReportStore,
|
|
2615
2704
|
FileTaskStore,
|