@hilbras/omninode 2.0.0-alpha.7 → 2.0.0-alpha.8

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
@@ -306,30 +306,63 @@ interface ChatStreamChunk {
306
306
  }
307
307
 
308
308
  /**
309
- * Memory abstraction. Remembera is the preferred Hilbras integration, but the
310
- * core depends only on this interface (memory-agnostic principle, §2, §19).
309
+ * Memory abstraction (§19). Remembera is the preferred implementation, but
310
+ * the core depends only on this interface (memory-agnostic principle, §2).
311
+ *
312
+ * v2 contract (roadmap §12): retrieve / store / search / metadata, across
313
+ * project / task / role scopes with structured categories.
311
314
  */
312
- type MemoryScope = "project" | "role" | "task" | "knowledge";
315
+ type MemoryScope = "project" | "task" | "role" | "knowledge";
316
+ /** Structured memory categories (roadmap §12, Memory Categories). */
317
+ type MemoryCategory = "project" | "architecture" | "decisions" | "tasks" | "problems" | "solutions" | "conventions" | "agent_reports";
313
318
  interface MemoryEntry {
314
319
  key: string;
315
320
  scope: MemoryScope;
316
321
  content: string;
322
+ /** Structured category, when the backend supports it. */
323
+ category?: MemoryCategory;
317
324
  tags?: string[];
318
325
  createdAt?: string;
319
326
  updatedAt?: string;
320
327
  metadata?: Record<string, unknown>;
321
328
  }
322
329
  interface MemoryQuery {
330
+ /** Free-text relevance query. */
331
+ text?: string;
323
332
  scope?: MemoryScope;
333
+ category?: MemoryCategory;
324
334
  tags?: string[];
325
- /** Free-text relevance query; implementations decide ranking. */
326
- text?: string;
327
335
  limit?: number;
328
336
  }
337
+ interface MemoryProviderMetadata {
338
+ name: string;
339
+ /** What the backend can do, so callers can adapt (e.g. no category support). */
340
+ capabilities: Array<"retrieve" | "store" | "search" | "categories" | "tags">;
341
+ /** True when the backend enforces relevance ranking itself. */
342
+ relevanceRanking: boolean;
343
+ /** Backend-specific info (gateway version, endpoint type…). */
344
+ backend?: Record<string, unknown>;
345
+ }
346
+ /**
347
+ * The memory contract. `query`/`write` are the v1 names, kept as aliases so
348
+ * existing integrations keep working — new code should use retrieve/store.
349
+ */
329
350
  interface IMemoryProvider {
330
351
  readonly name: string;
331
- /** Retrieve relevant memory; only relevant context should reach a task (§20). */
352
+ /** Retrieve entries relevant to a query (task-oriented). */
353
+ retrieve(query: MemoryQuery): Promise<MemoryEntry[]>;
354
+ /** Store an entry (upsert by key). */
355
+ store(entry: MemoryEntry): Promise<void>;
356
+ /** Free-text search across scopes. */
357
+ search(text: string, options?: {
358
+ limit?: number;
359
+ scope?: MemoryScope;
360
+ }): Promise<MemoryEntry[]>;
361
+ /** Provider capabilities (contract introspection). */
362
+ metadata(): MemoryProviderMetadata;
363
+ /** @deprecated v1 alias of {@link retrieve}. */
332
364
  query(query: MemoryQuery): Promise<MemoryEntry[]>;
365
+ /** @deprecated v1 alias of {@link store}. */
333
366
  write(entry: MemoryEntry): Promise<void>;
334
367
  }
335
368
 
@@ -1216,17 +1249,18 @@ declare const projectConfigSchema: z.ZodObject<{
1216
1249
  provider: z.ZodDefault<z.ZodString>;
1217
1250
  base_url: z.ZodOptional<z.ZodString>;
1218
1251
  api_key_env_var: z.ZodOptional<z.ZodString>;
1219
- timeout_ms: z.ZodOptional<z.ZodNumber>;
1252
+ /** When true, memory failures fail tasks instead of being tolerated (§12). */
1253
+ required: z.ZodOptional<z.ZodBoolean>;
1220
1254
  }, "strict", z.ZodTypeAny, {
1221
1255
  provider: string;
1222
1256
  base_url?: string | undefined;
1223
1257
  api_key_env_var?: string | undefined;
1224
- timeout_ms?: number | undefined;
1258
+ required?: boolean | undefined;
1225
1259
  }, {
1226
1260
  base_url?: string | undefined;
1227
1261
  api_key_env_var?: string | undefined;
1228
- timeout_ms?: number | undefined;
1229
1262
  provider?: string | undefined;
1263
+ required?: boolean | undefined;
1230
1264
  }>>;
1231
1265
  }, "strict", z.ZodTypeAny, {
1232
1266
  name: string;
@@ -1292,7 +1326,7 @@ declare const projectConfigSchema: z.ZodObject<{
1292
1326
  provider: string;
1293
1327
  base_url?: string | undefined;
1294
1328
  api_key_env_var?: string | undefined;
1295
- timeout_ms?: number | undefined;
1329
+ required?: boolean | undefined;
1296
1330
  } | undefined;
1297
1331
  }, {
1298
1332
  name: string;
@@ -1357,8 +1391,8 @@ declare const projectConfigSchema: z.ZodObject<{
1357
1391
  memory?: {
1358
1392
  base_url?: string | undefined;
1359
1393
  api_key_env_var?: string | undefined;
1360
- timeout_ms?: number | undefined;
1361
1394
  provider?: string | undefined;
1395
+ required?: boolean | undefined;
1362
1396
  } | undefined;
1363
1397
  }>;
1364
1398
  declare const appConfigSchema: z.ZodObject<{
@@ -1551,17 +1585,18 @@ declare const appConfigSchema: z.ZodObject<{
1551
1585
  provider: z.ZodDefault<z.ZodString>;
1552
1586
  base_url: z.ZodOptional<z.ZodString>;
1553
1587
  api_key_env_var: z.ZodOptional<z.ZodString>;
1554
- timeout_ms: z.ZodOptional<z.ZodNumber>;
1588
+ /** When true, memory failures fail tasks instead of being tolerated (§12). */
1589
+ required: z.ZodOptional<z.ZodBoolean>;
1555
1590
  }, "strict", z.ZodTypeAny, {
1556
1591
  provider: string;
1557
1592
  base_url?: string | undefined;
1558
1593
  api_key_env_var?: string | undefined;
1559
- timeout_ms?: number | undefined;
1594
+ required?: boolean | undefined;
1560
1595
  }, {
1561
1596
  base_url?: string | undefined;
1562
1597
  api_key_env_var?: string | undefined;
1563
- timeout_ms?: number | undefined;
1564
1598
  provider?: string | undefined;
1599
+ required?: boolean | undefined;
1565
1600
  }>>;
1566
1601
  }, "strict", z.ZodTypeAny, {
1567
1602
  name: string;
@@ -1627,7 +1662,7 @@ declare const appConfigSchema: z.ZodObject<{
1627
1662
  provider: string;
1628
1663
  base_url?: string | undefined;
1629
1664
  api_key_env_var?: string | undefined;
1630
- timeout_ms?: number | undefined;
1665
+ required?: boolean | undefined;
1631
1666
  } | undefined;
1632
1667
  }, {
1633
1668
  name: string;
@@ -1692,8 +1727,8 @@ declare const appConfigSchema: z.ZodObject<{
1692
1727
  memory?: {
1693
1728
  base_url?: string | undefined;
1694
1729
  api_key_env_var?: string | undefined;
1695
- timeout_ms?: number | undefined;
1696
1730
  provider?: string | undefined;
1731
+ required?: boolean | undefined;
1697
1732
  } | undefined;
1698
1733
  }>;
1699
1734
  logging: z.ZodOptional<z.ZodObject<{
@@ -1768,7 +1803,7 @@ declare const appConfigSchema: z.ZodObject<{
1768
1803
  provider: string;
1769
1804
  base_url?: string | undefined;
1770
1805
  api_key_env_var?: string | undefined;
1771
- timeout_ms?: number | undefined;
1806
+ required?: boolean | undefined;
1772
1807
  } | undefined;
1773
1808
  };
1774
1809
  logging?: {
@@ -1838,8 +1873,8 @@ declare const appConfigSchema: z.ZodObject<{
1838
1873
  memory?: {
1839
1874
  base_url?: string | undefined;
1840
1875
  api_key_env_var?: string | undefined;
1841
- timeout_ms?: number | undefined;
1842
1876
  provider?: string | undefined;
1877
+ required?: boolean | undefined;
1843
1878
  } | undefined;
1844
1879
  };
1845
1880
  logging?: {
@@ -1871,6 +1906,7 @@ interface AppConfig {
1871
1906
  provider: string;
1872
1907
  baseUrl?: string;
1873
1908
  apiKeyEnvVar?: string;
1909
+ required?: boolean;
1874
1910
  };
1875
1911
  };
1876
1912
  logging?: {
@@ -2334,8 +2370,17 @@ declare function keywords(text: string): Set<string>;
2334
2370
  declare class LocalMemoryProvider extends JsonFileStore<MemoryEntry> implements IMemoryProvider {
2335
2371
  readonly name = "local";
2336
2372
  constructor(directory?: string);
2373
+ metadata(): MemoryProviderMetadata;
2374
+ search(text: string, options?: {
2375
+ limit?: number;
2376
+ scope?: MemoryQuery["scope"];
2377
+ }): Promise<MemoryEntry[]>;
2378
+ /** @deprecated v1 alias of {@link retrieve}. */
2337
2379
  query(query: MemoryQuery): Promise<MemoryEntry[]>;
2380
+ /** @deprecated v1 alias of {@link store}. */
2338
2381
  write(entry: MemoryEntry): Promise<void>;
2382
+ retrieve(query: MemoryQuery): Promise<MemoryEntry[]>;
2383
+ store(entry: MemoryEntry): Promise<void>;
2339
2384
  count(): Promise<number>;
2340
2385
  }
2341
2386
 
@@ -2351,9 +2396,20 @@ declare class RememberaMemoryProvider implements IMemoryProvider {
2351
2396
  private readonly env;
2352
2397
  private readonly log;
2353
2398
  constructor(config: RememberaConfig, log?: Logger);
2399
+ private get authenticationConfigured();
2354
2400
  private headers;
2401
+ /** Search delegates to the gateway's relevance query. */
2402
+ search(text: string, options?: {
2403
+ limit?: number;
2404
+ scope?: MemoryQuery["scope"];
2405
+ }): Promise<MemoryEntry[]>;
2406
+ metadata(): MemoryProviderMetadata;
2407
+ /** @deprecated v1 alias of {@link retrieve}. */
2355
2408
  query(query: MemoryQuery): Promise<MemoryEntry[]>;
2409
+ /** @deprecated v1 alias of {@link store}. */
2356
2410
  write(entry: MemoryEntry): Promise<void>;
2411
+ retrieve(query: MemoryQuery): Promise<MemoryEntry[]>;
2412
+ store(entry: MemoryEntry): Promise<void>;
2357
2413
  private request;
2358
2414
  private toEntry;
2359
2415
  }
@@ -2361,31 +2417,66 @@ declare class RememberaMemoryProvider implements IMemoryProvider {
2361
2417
  type MemoryProviderConfig = NonNullable<AppConfig["project"]["memory"]>;
2362
2418
  declare function createMemoryProvider(config?: MemoryProviderConfig): IMemoryProvider;
2363
2419
 
2364
- /**
2365
- * Memory service (§19–§20): gathers relevant memory before a task runs and
2366
- * records outcomes afterwards — the Task → memory → relevant context →
2367
- * agents → reports → memory loop. Memory failures are best-effort: they log
2368
- * a warning and never fail a task, because memory is an enhancement, not a
2369
- * dependency (§2).
2370
- */
2371
-
2372
2420
  interface MemoryContextQuery {
2373
2421
  objective: string;
2374
2422
  role?: string;
2375
2423
  project?: string;
2424
+ /** Maximum entries to consider (relevance-ranked by the provider). */
2425
+ limit?: number;
2426
+ }
2427
+ interface MemoryTaskContext {
2428
+ /** Prompt-ready context text ("" when nothing relevant was found). */
2429
+ text: string;
2430
+ entries: MemoryEntry[];
2431
+ /** True when the character budget cut the context short. */
2432
+ truncated: boolean;
2433
+ }
2434
+ declare const MAX_CONTEXT_CHARS = 4000;
2435
+ interface MemoryServiceOptions {
2436
+ /** When true, backend failures propagate instead of being logged. */
2437
+ required?: boolean;
2438
+ maxContextChars?: number;
2376
2439
  }
2377
2440
  declare class MemoryService {
2378
2441
  private readonly provider;
2379
2442
  private readonly log;
2380
- constructor(provider: IMemoryProvider, log?: Logger);
2443
+ private readonly required;
2444
+ private readonly maxContextChars;
2445
+ constructor(provider: IMemoryProvider, log?: Logger, options?: MemoryServiceOptions);
2381
2446
  get providerRef(): IMemoryProvider;
2382
2447
  get providerName(): string;
2383
- /** Relevant context for a task objective; empty string when nothing matches. */
2448
+ get isRequired(): boolean;
2449
+ /** Structured, budgeted context for a task (§12 — avoid loading all memory). */
2450
+ contextFor(query: MemoryContextQuery): Promise<MemoryTaskContext>;
2451
+ /** Prompt-ready context text (v1 convenience wrapper). */
2384
2452
  gatherContext(query: MemoryContextQuery): Promise<string>;
2385
- /** Records a finished task's outcome — best-effort. */
2453
+ /** Records a finished task's outcome — task history plus "known problems" (§12). */
2386
2454
  recordTaskOutcome(task: Task): Promise<void>;
2455
+ private format;
2456
+ /**
2457
+ * Failure policy (§12): continue unless memory is explicitly required.
2458
+ */
2459
+ private handleFailure;
2387
2460
  }
2388
2461
 
2462
+ /**
2463
+ * Shared memory-contract helpers (roadmap §12). Adapters implement
2464
+ * `retrieve` / `store`; these helpers supply the defaults for `search`,
2465
+ * `metadata` and the v1 `query` / `write` aliases, so the contract is
2466
+ * defined once.
2467
+ */
2468
+
2469
+ /** Free-text search defaults to a relevance retrieve. */
2470
+ declare function defaultSearch(provider: Pick<IMemoryProvider, "retrieve">, text: string, options?: {
2471
+ limit?: number;
2472
+ scope?: MemoryQuery["scope"];
2473
+ }): Promise<MemoryEntry[]>;
2474
+ declare function defaultMetadata(name: string, options?: {
2475
+ capabilities?: MemoryProviderMetadata["capabilities"];
2476
+ relevanceRanking?: boolean;
2477
+ backend?: Record<string, unknown>;
2478
+ }): MemoryProviderMetadata;
2479
+
2389
2480
  interface CreateTaskInput {
2390
2481
  objective: string;
2391
2482
  project?: string;
@@ -2702,6 +2793,6 @@ declare class ProjectStores {
2702
2793
  constructor(directory?: string);
2703
2794
  }
2704
2795
 
2705
- declare const OMNINODE_VERSION = "2.0.0-alpha.7";
2796
+ declare const OMNINODE_VERSION = "2.0.0-alpha.8";
2706
2797
 
2707
- export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatStreamChunk, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_MESSAGE_BYTES, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryQuery, type MemoryScope, MemoryService, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, 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, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultProjectConfigYaml, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateWorkingDirectory };
2798
+ export { AgentAdapterRegistry, type AgentConfig, type AgentConfigYaml, type AgentDescriptor, AgentError, type AgentInfo, type AgentInputMode, type AgentIntegrationType, AgentRegistry, type AgentStatus, type AgentTaskInput, type AgentTaskOutput, type AgentToNodeMessage, type AggregateOptions, type AggregatedFinding, type AggregatedRecommendation, type AppConfig, type AppConfigYaml, type ArtifactKind, type ArtifactPayload, type AskedQuestion, type AuditAction, type AuditEvent, type AuditSink, type ChatFn, type ChatMessage, type ChatRequest, type ChatResponse, type ChatRole, type ChatStreamChunk, type ChatUsage, type CombinedMeta, type CombinedReport, type CombinedReportFilter, type Confidence, ConfigError, ConsoleLogSink, type CreateTaskInput, type CwdValidation, DEFAULT_MAX_OUTPUT_BYTES, type DecodeResult, type DiscoveryResult, type EnvPolicy, type EnvelopeMeta, type ExecutionRecord, type ExtractionMeta, FileAuditLog, FilePipelineRunStore, FilePlanStore, FileReportStore, FileTaskStore, type Finding, type FindingSeverity, type FindingSource, type HelloResult, HeuristicPlanner, type HttpRequestOptions, type HttpResponse, type IAgent, type IAgentAdapter, type IChatProvider, type IMemoryProvider, type IPipelineExecutor, type IPlanner, type IProvider, type JsonDocument, JsonFileStore, type JsonFileStoreOptions, type LoadConfigOptions, LocalMemoryProvider, type LogLevel, type LogSink, Logger, type LoggerOptions, MAX_CONTEXT_CHARS, MAX_MESSAGE_BYTES, type MemoryCategory, type MemoryContextQuery, type MemoryEntry, MemoryError, type MemoryProviderConfig, type MemoryProviderMetadata, type MemoryQuery, type MemoryScope, MemoryService, type MemoryServiceOptions, type MemoryTaskContext, type MessageEnvelope, type Modality, type ModelCapabilities, type ModelFilter, type ModelInfo, ModelPlanner, ModelRegistry, type ModelStatus, type NodeToAgentMessage, OMNINODE_VERSION, OPENAI_COMPATIBLE_TYPES, type OmniHilbrasConnectionResult, OmniHilbrasProvider, OmniNodeError, type OmniNodeErrorCode, type OmniNodeErrorOptions, OpenAICompatibleProvider, PROTOCOL_V2, type PipelineConfigYaml, type PipelineDefinition, PipelineEngine, type PipelineEngineOptions, PipelineError, type PipelineRun, type PipelineRunAttempt, type PipelineRunFilter, type PipelineRunOptions, 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, ProcessAgentAdapter, type Project, type ProjectConfigYaml, ProjectStores, type ProtocolAgentToNodeType, ProtocolDecoder, type ProtocolEnvelope, ProtocolError, type ProtocolMessageType, type ProtocolNodeToAgentType, ProtocolSession, type ProtocolViolation, type ProtocolViolationCode, type ProviderAuthentication, type ProviderCapability, type ProviderConfig, type ProviderConfigYaml, ProviderError, type ProviderErrorKind, type ProviderHealth, type ProviderStatus, type ProviderType, type QuestionPayload, type QuestionResponder, type RememberaConfig, RememberaMemoryProvider, type Report, type ReportFilter, type ReportPayload, ReportService, type ReportStore, type RoleConfigYaml, type RoleDefinition, RoleRegistry, type RunPipelineOptions, SUPPORTED_PROTOCOL_VERSIONS, type SessionIds, TERMINAL_TASK_STATUSES, type Task, type TaskContext, TaskEngine, type TaskEngineOptions, TaskError, type TaskPayload, type TaskResult, type TaskStatus, type TaskStore, type TaskStoreFilter, type WritableLike, agentConfigSchema, aggregateReports, appConfigSchema, authHeaders, buildAgentRegistry, buildChildEnv, buildHello, buildHelloAck, buildPipelineEngine, buildPlanner, buildPlannerContext, buildRoleRegistry, composeTaskText, createAgent, createDefaultChatFn, createMemoryProvider, createProvider, createTaskEngine, decodeMessage, decodeStream, defaultMetadata, defaultProjectConfigYaml, defaultSearch, describeExit, encodeMessage, envelope, expandEnvRefs, extractMessage, extractReportFromText, findConfigFile, isNetworkError, isOmniNodeError, isRetryable, isSupportedProtocol, isTimeoutError, keywords, killTree, kindFromStatus, loadConfig, logger, newMessageId, parseHello, parsePlanJson, parseRetryAfter, pipelineConfigSchema, pipelineStepConfigSchema, plannerConfigSchema, projectConfigSchema, providerConfigSchema, providerHttpError, providerTransportError, registryKey, requestJson, requireCompletion, resolveApiKey, resolveEnvPolicy, roleConfigSchema, sanitizeChunk, similar, validateEnvelope, validateWorkingDirectory };
package/dist/index.js CHANGED
@@ -191,7 +191,8 @@ var projectConfigSchema = z.object({
191
191
  provider: z.string().min(1).default("local"),
192
192
  base_url: z.string().url().optional(),
193
193
  api_key_env_var: z.string().min(1).optional(),
194
- timeout_ms: z.number().int().positive().optional()
194
+ /** When true, memory failures fail tasks instead of being tolerated (§12). */
195
+ required: z.boolean().optional()
195
196
  }).strict().optional()
196
197
  }).strict();
197
198
  var appConfigSchema = z.object({
@@ -273,7 +274,8 @@ function toAppConfig(yaml) {
273
274
  memory: {
274
275
  provider: yaml.project.memory.provider,
275
276
  baseUrl: yaml.project.memory.base_url,
276
- apiKeyEnvVar: yaml.project.memory.api_key_env_var
277
+ apiKeyEnvVar: yaml.project.memory.api_key_env_var,
278
+ required: yaml.project.memory.required
277
279
  }
278
280
  } : {}
279
281
  },
@@ -2202,6 +2204,23 @@ var FileAuditLog = class {
2202
2204
  }
2203
2205
  };
2204
2206
 
2207
+ // src/memory/base.ts
2208
+ function defaultSearch(provider, text, options = {}) {
2209
+ return provider.retrieve({
2210
+ text,
2211
+ ...options.scope !== void 0 ? { scope: options.scope } : {},
2212
+ ...options.limit !== void 0 ? { limit: options.limit } : {}
2213
+ });
2214
+ }
2215
+ function defaultMetadata(name, options = {}) {
2216
+ return {
2217
+ name,
2218
+ capabilities: options.capabilities ?? ["retrieve", "store", "search"],
2219
+ relevanceRanking: options.relevanceRanking ?? false,
2220
+ ...options.backend !== void 0 ? { backend: options.backend } : {}
2221
+ };
2222
+ }
2223
+
2205
2224
  // src/memory/local.ts
2206
2225
  var STOPWORDS = /* @__PURE__ */ new Set([
2207
2226
  "the",
@@ -2264,9 +2283,27 @@ var LocalMemoryProvider = class extends JsonFileStore {
2264
2283
  constructor(directory) {
2265
2284
  super({ ...directory !== void 0 ? { directory } : {}, fileName: "memory.json" });
2266
2285
  }
2267
- async query(query) {
2286
+ metadata() {
2287
+ return defaultMetadata(this.name, {
2288
+ capabilities: ["retrieve", "store", "search", "categories", "tags"],
2289
+ relevanceRanking: true,
2290
+ backend: { kind: "json-file", deterministicScoring: true }
2291
+ });
2292
+ }
2293
+ search(text, options = {}) {
2294
+ return defaultSearch(this, text, options);
2295
+ }
2296
+ /** @deprecated v1 alias of {@link retrieve}. */
2297
+ query(query) {
2298
+ return this.retrieve(query);
2299
+ }
2300
+ /** @deprecated v1 alias of {@link store}. */
2301
+ write(entry) {
2302
+ return this.store(entry);
2303
+ }
2304
+ async retrieve(query) {
2268
2305
  const entries = await this.readAll();
2269
- const filtered = entries.filter((entry) => query.scope ? entry.scope === query.scope : true).filter(
2306
+ const filtered = entries.filter((entry) => query.scope ? entry.scope === query.scope : true).filter((entry) => query.category ? entry.category === query.category : true).filter(
2270
2307
  (entry) => query.tags && query.tags.length > 0 ? query.tags.every((tag) => (entry.tags ?? []).includes(tag)) : true
2271
2308
  );
2272
2309
  if (!query.text || query.text.trim().length === 0) {
@@ -2275,7 +2312,7 @@ var LocalMemoryProvider = class extends JsonFileStore {
2275
2312
  const queryKeywords = keywords(query.text);
2276
2313
  return filtered.map((entry) => ({ entry, score: relevanceScore(queryKeywords, entry) })).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score).slice(0, query.limit ?? 10).map(({ entry }) => entry);
2277
2314
  }
2278
- write(entry) {
2315
+ store(entry) {
2279
2316
  return this.mutate((entries) => {
2280
2317
  const index = entries.findIndex((e) => e.key === entry.key);
2281
2318
  const stamped = {
@@ -2306,11 +2343,40 @@ var RememberaMemoryProvider = class {
2306
2343
  this.env = config.env ?? process.env;
2307
2344
  this.log = log.child({ component: "remembera" });
2308
2345
  }
2346
+ get authenticationConfigured() {
2347
+ return this.apiKeyEnvVar === void 0 || Boolean(this.env[this.apiKeyEnvVar]);
2348
+ }
2309
2349
  headers() {
2310
2350
  const key = this.apiKeyEnvVar ? resolveApiKey({ name: "remembera", apiKeyEnvVar: this.apiKeyEnvVar }, this.env) : void 0;
2311
2351
  return key ? { authorization: `Bearer ${key}` } : {};
2312
2352
  }
2313
- async query(query) {
2353
+ /** Search delegates to the gateway's relevance query. */
2354
+ search(text, options = {}) {
2355
+ return defaultSearch(
2356
+ this,
2357
+ text,
2358
+ {
2359
+ ...options.scope !== void 0 ? { scope: options.scope } : {},
2360
+ ...options.limit !== void 0 ? { limit: options.limit } : {}
2361
+ }
2362
+ );
2363
+ }
2364
+ metadata() {
2365
+ return defaultMetadata(this.name, {
2366
+ capabilities: ["retrieve", "store", "search", "categories", "tags"],
2367
+ relevanceRanking: true,
2368
+ backend: { kind: "http", baseUrl: this.baseUrl, authenticated: this.authenticationConfigured }
2369
+ });
2370
+ }
2371
+ /** @deprecated v1 alias of {@link retrieve}. */
2372
+ query(query) {
2373
+ return this.retrieve(query);
2374
+ }
2375
+ /** @deprecated v1 alias of {@link store}. */
2376
+ write(entry) {
2377
+ return this.store(entry);
2378
+ }
2379
+ async retrieve(query) {
2314
2380
  const { status, body } = await this.request(`${this.baseUrl}/api/memory/query`, query);
2315
2381
  if (status !== 200) {
2316
2382
  throw new MemoryError(`Remembera query returned HTTP ${status}.`);
@@ -2321,7 +2387,7 @@ var RememberaMemoryProvider = class {
2321
2387
  }
2322
2388
  return entries.map((entry) => this.toEntry(entry)).filter((entry) => entry !== void 0);
2323
2389
  }
2324
- async write(entry) {
2390
+ async store(entry) {
2325
2391
  const { status } = await this.request(`${this.baseUrl}/api/memory`, entry);
2326
2392
  if (status !== 200 && status !== 201) {
2327
2393
  throw new MemoryError(`Remembera write returned HTTP ${status}.`);
@@ -2356,6 +2422,7 @@ var RememberaMemoryProvider = class {
2356
2422
  content: entry.content,
2357
2423
  scope: scope === "project" || scope === "role" || scope === "task" || scope === "knowledge" ? scope : "knowledge",
2358
2424
  ...Array.isArray(entry.tags) ? { tags: entry.tags.filter((t) => typeof t === "string") } : {},
2425
+ ...typeof entry.category === "string" ? { category: entry.category } : {},
2359
2426
  ...typeof entry.createdAt === "string" ? { createdAt: entry.createdAt } : {},
2360
2427
  ...typeof entry.updatedAt === "string" ? { updatedAt: entry.updatedAt } : {}
2361
2428
  };
@@ -2386,57 +2453,54 @@ function createMemoryProvider(config) {
2386
2453
  }
2387
2454
 
2388
2455
  // src/memory/service.ts
2456
+ var DEFAULT_ENTRY_LIMIT = 8;
2389
2457
  var MAX_CONTEXT_CHARS = 4e3;
2390
2458
  var MemoryService = class {
2391
- constructor(provider, log = logger) {
2459
+ constructor(provider, log = logger, options = {}) {
2392
2460
  this.provider = provider;
2393
2461
  this.log = log.child({ component: "memory", provider: provider.name });
2462
+ this.required = options.required ?? false;
2463
+ this.maxContextChars = options.maxContextChars ?? MAX_CONTEXT_CHARS;
2394
2464
  }
2395
2465
  provider;
2396
2466
  log;
2467
+ required;
2468
+ maxContextChars;
2397
2469
  get providerRef() {
2398
2470
  return this.provider;
2399
2471
  }
2400
2472
  get providerName() {
2401
2473
  return this.provider.name;
2402
2474
  }
2403
- /** Relevant context for a task objective; empty string when nothing matches. */
2404
- async gatherContext(query) {
2475
+ get isRequired() {
2476
+ return this.required;
2477
+ }
2478
+ /** Structured, budgeted context for a task (§12 — avoid loading all memory). */
2479
+ async contextFor(query) {
2480
+ let entries;
2405
2481
  try {
2406
- const entries = await this.provider.query({
2482
+ entries = await this.provider.retrieve({
2407
2483
  text: query.objective,
2408
2484
  ...query.role ? { tags: [query.role] } : {},
2409
- limit: 8
2485
+ limit: query.limit ?? DEFAULT_ENTRY_LIMIT
2410
2486
  });
2411
- if (entries.length === 0) return "";
2412
- const byScope = /* @__PURE__ */ new Map();
2413
- for (const entry of entries) {
2414
- byScope.set(entry.scope, [...byScope.get(entry.scope) ?? [], entry]);
2415
- }
2416
- const parts = [];
2417
- for (const scope of ["project", "task", "role", "knowledge"]) {
2418
- const scopeEntries = byScope.get(scope) ?? [];
2419
- if (scopeEntries.length === 0) continue;
2420
- const lines = scopeEntries.map((entry) => `- ${entry.content}`).join("\n");
2421
- parts.push(`### Relevant memory (${scope})
2422
- ${lines}`);
2423
- }
2424
- const context = parts.join("\n\n");
2425
- return context.length > MAX_CONTEXT_CHARS ? `${context.slice(0, MAX_CONTEXT_CHARS)}\u2026` : context;
2426
2487
  } catch (error) {
2427
- this.log.warn(
2428
- `Memory query failed (continuing without memory): ${error instanceof Error ? error.message : String(error)}`
2429
- );
2430
- return "";
2488
+ return this.handleFailure("retrieve", error, { text: "", entries: [], truncated: false });
2431
2489
  }
2490
+ return this.format(entries);
2432
2491
  }
2433
- /** Records a finished task's outcome — best-effort. */
2492
+ /** Prompt-ready context text (v1 convenience wrapper). */
2493
+ async gatherContext(query) {
2494
+ return (await this.contextFor(query)).text;
2495
+ }
2496
+ /** Records a finished task's outcome — task history plus "known problems" (§12). */
2434
2497
  async recordTaskOutcome(task) {
2435
2498
  const outcome = task.result?.summary ?? task.result?.error ?? "(no output)";
2436
2499
  try {
2437
- await this.provider.write({
2500
+ await this.provider.store({
2438
2501
  key: `task:${task.id}`,
2439
2502
  scope: "task",
2503
+ category: "tasks",
2440
2504
  content: `Objective: ${task.objective}
2441
2505
  Status: ${task.status}
2442
2506
  Outcome: ${outcome}`,
@@ -2447,18 +2511,53 @@ Outcome: ${outcome}`,
2447
2511
  (report) => report.findings.filter((finding) => finding.severity === "high" || finding.severity === "critical").map((finding) => ({ report, finding }))
2448
2512
  );
2449
2513
  for (const { report, finding } of significant) {
2450
- await this.provider.write({
2514
+ await this.provider.store({
2451
2515
  key: `finding:${report.id}:${finding.id}`,
2452
2516
  scope: "project",
2517
+ category: "problems",
2453
2518
  content: `[${finding.severity}] ${finding.title} \u2014 ${finding.detail}`,
2454
2519
  tags: ["known-problem", report.agent]
2455
2520
  });
2456
2521
  }
2457
2522
  } catch (error) {
2458
- this.log.warn(
2459
- `Memory write failed (continuing): ${error instanceof Error ? error.message : String(error)}`
2523
+ this.handleFailure("store", error, void 0);
2524
+ }
2525
+ }
2526
+ format(entries) {
2527
+ if (entries.length === 0) return { text: "", entries, truncated: false };
2528
+ const byScope = /* @__PURE__ */ new Map();
2529
+ for (const entry of entries) {
2530
+ byScope.set(entry.scope, [...byScope.get(entry.scope) ?? [], entry]);
2531
+ }
2532
+ const parts = [];
2533
+ for (const scope of ["project", "task", "role", "knowledge"]) {
2534
+ const scopeEntries = byScope.get(scope) ?? [];
2535
+ if (scopeEntries.length === 0) continue;
2536
+ const lines = scopeEntries.map((entry) => {
2537
+ const category = entry.category ? `[${entry.category}] ` : "";
2538
+ return `- ${category}${entry.content}`;
2539
+ }).join("\n");
2540
+ parts.push(`### Relevant memory (${scope})
2541
+ ${lines}`);
2542
+ }
2543
+ let text = parts.join("\n\n");
2544
+ const truncated = text.length > this.maxContextChars;
2545
+ if (truncated) text = `${text.slice(0, this.maxContextChars - 1)}\u2026`;
2546
+ return { text, entries, truncated };
2547
+ }
2548
+ /**
2549
+ * Failure policy (§12): continue unless memory is explicitly required.
2550
+ */
2551
+ handleFailure(operation, error, fallback) {
2552
+ const message = error instanceof Error ? error.message : String(error);
2553
+ if (this.required) {
2554
+ throw new MemoryError(
2555
+ `Memory is marked required, but ${operation} failed: ${message}`,
2556
+ { cause: error }
2460
2557
  );
2461
2558
  }
2559
+ this.log.warn(`Memory ${operation} failed (continuing without memory): ${message}`);
2560
+ return fallback ?? { text: "", entries: [], truncated: false };
2462
2561
  }
2463
2562
  };
2464
2563
 
@@ -2470,7 +2569,11 @@ function createTaskEngine(config, log = logger, directory) {
2470
2569
  agents,
2471
2570
  roles,
2472
2571
  store: new FileTaskStore(directory),
2473
- ...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
2572
+ ...config.project.memory !== void 0 ? {
2573
+ memory: new MemoryService(createMemoryProvider(config.project.memory), log, {
2574
+ required: config.project.memory.required
2575
+ })
2576
+ } : {},
2474
2577
  audit: new FileAuditLog(),
2475
2578
  log
2476
2579
  });
@@ -3552,7 +3655,11 @@ function buildPipelineEngine(config, log = logger) {
3552
3655
  agents,
3553
3656
  roles,
3554
3657
  store: new FileTaskStore(),
3555
- ...config.project.memory !== void 0 ? { memory: new MemoryService(createMemoryProvider(config.project.memory), log) } : {},
3658
+ ...config.project.memory !== void 0 ? {
3659
+ memory: new MemoryService(createMemoryProvider(config.project.memory), log, {
3660
+ required: config.project.memory.required
3661
+ })
3662
+ } : {},
3556
3663
  audit: new FileAuditLog(),
3557
3664
  log
3558
3665
  });
@@ -3590,7 +3697,7 @@ var ProjectStores = class {
3590
3697
  };
3591
3698
 
3592
3699
  // src/version.ts
3593
- var OMNINODE_VERSION = "2.0.0-alpha.7";
3700
+ var OMNINODE_VERSION = "2.0.0-alpha.8";
3594
3701
  export {
3595
3702
  AgentAdapterRegistry,
3596
3703
  AgentError,
@@ -3607,6 +3714,7 @@ export {
3607
3714
  JsonFileStore,
3608
3715
  LocalMemoryProvider,
3609
3716
  Logger,
3717
+ MAX_CONTEXT_CHARS,
3610
3718
  MAX_MESSAGE_BYTES,
3611
3719
  MemoryError,
3612
3720
  MemoryService,
@@ -3655,7 +3763,9 @@ export {
3655
3763
  createTaskEngine,
3656
3764
  decodeMessage,
3657
3765
  decodeStream,
3766
+ defaultMetadata,
3658
3767
  defaultProjectConfigYaml,
3768
+ defaultSearch,
3659
3769
  describeExit,
3660
3770
  encodeMessage,
3661
3771
  envelope,