@mnemo-ai/types 3.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,371 @@
1
+ export { A as ALL_SCOPES, a as AccessPolicyRecord, b as AccessPolicyStore, c as ActionDsl, d as ActionDslSchema, e as AgentMemoryAccess, f as AnomalyScore, g as ApiKeyRecord, h as ApiKeyStore, i as ApiKeyType, j as AppendInferenceInput, k as ApplyConsolidationMergeInput, l as ApprovalRequest, m as ApprovalRequestInput, n as ApprovalStore, o as ApprovalTrigger, p as Attribution, q as AuditAction, r as AuditActorType, s as AuditLogEntry, t as AuthAdapter, u as AuthContext, v as AuthOperation, w as AuthResult, B as BeginResult, x as BreakGlassRequestInput, y as BreakGlassRequestRecord, z as BreakGlassStore, C as CacheAdapter, D as CacheCapabilities, E as CacheInfo, F as CacheSetOpts, G as CoOccurrencePatternRow, H as CognitivePrimitive, I as CompositionRuleFilter, J as ConditionDsl, K as ConditionDslSchema, L as ConditionalPatternRow, M as ConfidenceMapRow, N as ConsolidationMergeSnapshot, O as ConsolidationWorthSnapshot, P as ContradictingFact, Q as CreateCompositionRuleInput, R as CreateDecisionInput, S as CreateEntityInput, T as CreateEpisodeInput, U as CreateEventInput, V as CreateFactInput, W as CreateHyperedgeInput, X as CreateReasoningInput, Y as CreateRelationInput, Z as CreateReminderInput, _ as CreateSessionInput, $ as CreateSkillInput, a0 as CreateStrategyInput, a1 as CreateTaskInput, a2 as CreateWebhookDeliveryInput, a3 as CreateWebhookEndpointInput, a4 as CreateWorkflowInput, a5 as DecayClass, a6 as DecisionFilter, a7 as DelegateTaskInput, a8 as DeploymentTier, a9 as DerivedInference, aa as EmbedAdapter, ab as EmbeddableTable, ac as EncryptedField, ad as EnqueueOpts, ae as EntityFilter, af as EpisodeFilter, ag as EventAnnotation, ah as EventFilter, ai as FactFilter, aj as FindContradictingFactsInput, ak as FtsCandidate, al as HealthStatus, am as HotTierSnapshotRow, an as HyperedgeFilter, ao as IdempotencyStore, ap as InferenceLogFilter, aq as InheritedContext, ar as InjectionGuardResult, as as InjectionScore, at as JobHandler, au as KeyDeprecation, av as KeyEscrowEntry, aw as KeyScope, ax as KeyUsageEvent, ay as KnowledgeGapRow, az as LLMAdapter, aA as LLMInput, aB as LLMMessage, aC as LLMOutput, aD as LogContext, aE as Logger, aF as LshBandValue, aG as MaterialiseInferenceInput, aH as MergeFactByTopicKeyInput, aI as MetacognitionTrends, aJ as MnemoAgentProfile, aK as MnemoCitation, aL as MnemoCompositionRule, aM as MnemoDecision, aN as MnemoEntity, aO as MnemoEpisode, aP as MnemoEvent, aQ as MnemoFact, aR as MnemoFactHash, aS as MnemoHyperedge, aT as MnemoInferenceLogEntry, aU as MnemoReasoning, aV as MnemoRelation, aW as MnemoReminder, aX as MnemoSession, aY as MnemoSkill, aZ as MnemoStrategy, a_ as MnemoTask, a$ as MnemoWebhookDelivery, b0 as MnemoWebhookEndpoint, b1 as MnemoWorkflow, b2 as OutboxAdapter, b3 as OutboxEntry, b4 as OutboxEventType, b5 as OutboxStats, b6 as PaginatedResult, b7 as PeriodicPatternRow, b8 as PointerCandidate, b9 as PointerCandidateQuery, ba as PrimitiveKind, bb as Provenance, bc as PurgeFactsFilter, bd as PurgeFactsResult, be as QueueAdapter, bf as RECOVERY_POINTS, bg as RawCredentials, bh as ReasoningFilter, bi as ReasoningStep, bj as RecallFilter, bk as RecallHit, bl as RecallLogEntry, bm as RecallLogRecord, bn as RecallPrimitiveRecord, bo as RecallPrimitiveRef, bp as RecallPrimitiveValue, bq as RecallQuery, br as RecallResponse, bs as RecallStructures, bt as RecoveryPoint, bu as RelationFilter, bv as RelationSummary, bw as RelationVerb, bx as RememberKind, by as RememberRequest, bz as RememberResponse, bA as ReplaceFactInput, bB as ReplaceFactResult, bC as ReplayFailureReview, bD as RotateKeyResult, bE as SENSITIVITY_ORDER, bF as SPEC_SCOPES, bG as SchemaLike, bH as SelfEditPolicy, bI as Sensitivity, bJ as SequentialPatternRow, bK as SessionStatus, bL as SessionTokenRecord, bM as SessionTokenStore, bN as SessionTurn, bO as SimilarEntity, bP as SimilarEpisode, bQ as SkillFilter, bR as Span, bS as SpanOpts, bT as SpecScope, bU as StorageAdapter, bV as StorageCapabilities, bW as StrategyFilter, bX as TaskFilter, bY as Telemetry, bZ as TrendPair, b_ as UpdateCompositionRuleInput, b$ as UpdateDecisionInput, c0 as UpdateEntityInput, c1 as UpdateEpisodeInput, c2 as UpdateFactInput, c3 as UpdateHyperedgeInput, c4 as UpdateReasoningInput, c5 as UpdateSkillInput, c6 as UpdateStrategyInput, c7 as UpdateTaskInput, c8 as UpdateWebhookEndpointInput, c9 as UpdateWorkflowInput, ca as UpsertFactHashInput, cb as UpsertFactLshInput, cc as VectorAdapter, cd as VectorEmbedding, ce as VectorFilter, cf as VectorQuery, cg as VectorSearchHit, ch as VectorSearchInput, ci as VectorSearchResult, cj as WebhookFirePayload, ck as WorkflowFilter, cl as WorkflowStep, cm as WorthDelta, cn as parseActionDsl, co as parseConditionDsl, cp as resolveAuditActorType, cq as sensitivityAtLeast } from './ports-PqoQMXjO.js';
2
+ import 'zod';
3
+
4
+ type WorkspaceId = string & {
5
+ readonly _brand: "WorkspaceId";
6
+ };
7
+ type FactId = string & {
8
+ readonly _brand: "FactId";
9
+ };
10
+ type DecisionId = string & {
11
+ readonly _brand: "DecisionId";
12
+ };
13
+ type EpisodeId = string & {
14
+ readonly _brand: "EpisodeId";
15
+ };
16
+ type EntityId = string & {
17
+ readonly _brand: "EntityId";
18
+ };
19
+ type StrategyId = string & {
20
+ readonly _brand: "StrategyId";
21
+ };
22
+ type WorkflowId = string & {
23
+ readonly _brand: "WorkflowId";
24
+ };
25
+ type SkillId = string & {
26
+ readonly _brand: "SkillId";
27
+ };
28
+ type TaskId = string & {
29
+ readonly _brand: "TaskId";
30
+ };
31
+ type EventId = string & {
32
+ readonly _brand: "EventId";
33
+ };
34
+ type ReasoningId = string & {
35
+ readonly _brand: "ReasoningId";
36
+ };
37
+ type SessionId = string & {
38
+ readonly _brand: "SessionId";
39
+ };
40
+ type RelationId = string & {
41
+ readonly _brand: "RelationId";
42
+ };
43
+ type HyperedgeId = string & {
44
+ readonly _brand: "HyperedgeId";
45
+ };
46
+ declare const asWorkspaceId: (s: string) => WorkspaceId;
47
+ declare const asFactId: (s: string) => FactId;
48
+ declare const asDecisionId: (s: string) => DecisionId;
49
+ declare const asEpisodeId: (s: string) => EpisodeId;
50
+ declare const asEntityId: (s: string) => EntityId;
51
+ declare const asStrategyId: (s: string) => StrategyId;
52
+ declare const asWorkflowId: (s: string) => WorkflowId;
53
+ declare const asSkillId: (s: string) => SkillId;
54
+ declare const asTaskId: (s: string) => TaskId;
55
+ declare const asEventId: (s: string) => EventId;
56
+ declare const asReasoningId: (s: string) => ReasoningId;
57
+ declare const asSessionId: (s: string) => SessionId;
58
+ declare const asRelationId: (s: string) => RelationId;
59
+ /** Returns true iff `s` is a well-formed UUID (any version, case-insensitive). */
60
+ declare function isWorkspaceId(s: string): boolean;
61
+
62
+ /**
63
+ * Typed event envelope for the Mnemosyne internal event bus (spec §4).
64
+ *
65
+ * The bus is a pure in-process pub/sub: no network, no persistence, no
66
+ * at-least-once guarantees. Its primary consumers are the WebSocket
67
+ * subscription handler (§4 /v1/memory/ws) and monitoring.
68
+ */
69
+ type MnemoEventType = "fact.created" | "fact.updated" | "fact.archived" | "task.created" | "task.transitioned" | "task.completed" | "event.recorded" | "recall.hit" | "session.collapsed" | "health.alert" | "federation.conflict";
70
+ interface MnemoBusEvent<P = unknown> {
71
+ id?: string;
72
+ channel: string;
73
+ type: MnemoEventType;
74
+ payload: P;
75
+ timestamp: string;
76
+ traceId: string;
77
+ }
78
+ type MnemoChannelPattern = "facts.*" | "facts.created" | "tasks.*" | "events.*" | `session.${string}` | `agent.${string}.recall` | "health" | "federation.sync";
79
+ interface MnemoEventFilter {
80
+ entityId?: string;
81
+ agentId?: string;
82
+ memoryType?: string;
83
+ }
84
+ interface WsSubscription {
85
+ subscribe?: {
86
+ channel: string;
87
+ filter?: MnemoEventFilter;
88
+ };
89
+ unsubscribe?: {
90
+ channel: string;
91
+ };
92
+ /** §35 reconnection: replay events since lastEventId on these channels */
93
+ resubscribe?: {
94
+ channels: string[];
95
+ lastEventId: string;
96
+ };
97
+ }
98
+
99
+ /**
100
+ * Observability types — Wave AC §AC2
101
+ *
102
+ * CognitiveHealthSnapshot gives a high-level view of a workspace's
103
+ * memory health across four key dimensions from spec §28–§34:
104
+ *
105
+ * worthConvergenceRate — fraction of facts whose worth has stabilised
106
+ * (α/(α+β) within ε of previous evaluation).
107
+ * compositionUtilization — ratio of active composition rules that fired
108
+ * at least once in the last 7 days.
109
+ * knowledgeTypeBalance — Shannon entropy over primitive type distribution
110
+ * (fact/decision/episode/entity/…), in bits.
111
+ * proceduralEvolutionDelta — mean score-delta of the last activated prompt
112
+ * version (avgScoreAfter − avgScoreBefore).
113
+ * unitEconomics.roiMultiplier — aggregate recall-value / LLM-cost ratio for
114
+ * the billing period (dimensionless multiplier).
115
+ * unitEconomics.costUsdThisMonth — total LLM cost for the billing period.
116
+ * unitEconomics.recallCount — number of recall operations this billing period.
117
+ *
118
+ * All numeric fields are in [0,∞) unless noted; null means the metric
119
+ * could not be computed (e.g. no facts in the workspace yet).
120
+ */
121
+ interface CognitiveHealthUnitEconomics {
122
+ /** Recall value / LLM cost ratio. >1 = profitable. null if cost = 0. */
123
+ roiMultiplier: number | null;
124
+ /** Total LLM spend in USD for the current calendar month. */
125
+ costUsdThisMonth: number;
126
+ /** Number of recall operations executed this calendar month. */
127
+ recallCount: number;
128
+ }
129
+ interface CognitiveHealthSnapshot {
130
+ /** Workspace this snapshot is scoped to. */
131
+ workspaceId: string;
132
+ /** ISO-8601 timestamp when the snapshot was computed. */
133
+ computedAt: string;
134
+ /**
135
+ * Fraction [0,1] of active facts whose Beta-Bernoulli worth has
136
+ * stabilised (|α/(α+β) − previous| < 0.01). null if no facts.
137
+ */
138
+ worthConvergenceRate: number | null;
139
+ /**
140
+ * Fraction [0,1] of active composition rules that fired at least
141
+ * once in the last 7 days. 0 if no rules exist.
142
+ */
143
+ compositionUtilization: number | null;
144
+ /**
145
+ * Shannon entropy (bits) over the distribution of memory primitive
146
+ * types in the workspace. Higher = more diverse memory portfolio.
147
+ * null if workspace has no primitives.
148
+ */
149
+ knowledgeTypeBalance: number | null;
150
+ /**
151
+ * Score delta (avgScoreAfter − avgScoreBefore) of the most recently
152
+ * activated prompt version for any agent in this workspace.
153
+ * Positive = procedural improvement. null if no prompt versions exist.
154
+ */
155
+ proceduralEvolutionDelta: number | null;
156
+ /** Unit economics for the current billing period. */
157
+ unitEconomics: CognitiveHealthUnitEconomics;
158
+ /**
159
+ * Fraction of sessions that were collapsed due to turn-limit/inactivity
160
+ * (i.e. involuntary collapses / total sessions started).
161
+ * null if no sessions have been started in-process.
162
+ */
163
+ sessionCollapseRate?: number | null;
164
+ /**
165
+ * Fraction of reasoning.resolve() calls served from the CoT distillation
166
+ * cache (cache_hit / (cache_hit + execute)).
167
+ * null if no reasoning.resolve calls recorded.
168
+ */
169
+ reasoningCacheHitRate?: number | null;
170
+ /**
171
+ * Mean Beta-Bernoulli worth (α/(α+β)) across active facts in the workspace.
172
+ * null if the workspace has no active facts.
173
+ */
174
+ avgMemoryWorth?: number | null;
175
+ /**
176
+ * Fraction of recall operations served from the hot (Redis L1) tier
177
+ * (hot / (hot + cold + unified + miss)).
178
+ * null if no recall tier hits recorded.
179
+ */
180
+ hotTierHitRate?: number | null;
181
+ /**
182
+ * Per-workspace anticipation accuracy: fraction of pre-staged anticipated
183
+ * memories subsequently recalled in the same session.
184
+ * null if no session for this workspace has collapsed yet.
185
+ */
186
+ anticipationAccuracy?: number | null;
187
+ /**
188
+ * Fraction of consolidation jobs that were gated (skipped) rather than
189
+ * merged (skipped / (merged + skipped + failed)).
190
+ * null if no consolidation decisions recorded.
191
+ */
192
+ consolidationGateRate?: number | null;
193
+ /**
194
+ * Fraction of consolidation jobs that failed (failed / total).
195
+ * Note: `failed` is a superset of `rolled_back` until the scheduler emits
196
+ * a dedicated `rolled_back` outcome label.
197
+ * null if no consolidation decisions recorded.
198
+ * @remarks FIXME: failed is a superset of rolled_back
199
+ */
200
+ consolidationRollbackRate?: number | null;
201
+ }
202
+ declare const MNEMO_ERROR_CODES: {
203
+ readonly STORAGE_NOT_FOUND: "mnemo.storage.not_found";
204
+ readonly STORAGE_CONFLICT: "mnemo.storage.conflict";
205
+ readonly STORAGE_CONSTRAINT: "mnemo.storage.constraint_violation";
206
+ readonly STORAGE_TIMEOUT: "mnemo.storage.timeout";
207
+ readonly AUTH_MISSING_KEY: "mnemo.auth.missing_key";
208
+ readonly AUTH_EXPIRED_KEY: "mnemo.auth.expired_key";
209
+ readonly AUTH_INSUFFICIENT_SCOPE: "mnemo.auth.insufficient_scope";
210
+ readonly AUTH_WORKSPACE_MISMATCH: "mnemo.auth.workspace_mismatch";
211
+ readonly RECALL_BUDGET_EXCEEDED: "mnemo.recall.budget_exceeded";
212
+ readonly RECALL_VECTOR_MISSING: "mnemo.recall.vector_missing";
213
+ readonly RECALL_UPSTREAM_TIMEOUT: "mnemo.recall.upstream_timeout";
214
+ readonly COMPOSE_DSL_INVALID: "mnemo.compose.dsl_invalid";
215
+ readonly COMPOSE_MAX_FIRINGS: "mnemo.compose.max_firings_reached";
216
+ readonly COMPOSE_MATERIALISE_FAIL: "mnemo.compose.materialise_failed";
217
+ readonly SELF_EDIT_BUDGET: "mnemo.self_edit.budget_exceeded";
218
+ readonly SELF_EDIT_COOLDOWN: "mnemo.self_edit.cooldown_active";
219
+ readonly SELF_EDIT_SCOPE: "mnemo.self_edit.scope_denied";
220
+ readonly SELF_EDIT_ABUSE_FLAG: "mnemo.self_edit.abuse_flagged";
221
+ readonly SELF_EDIT_WORTH_FROZEN: "mnemo.self_edit.worth_frozen";
222
+ readonly FED_SIGNATURE_INVALID: "mnemo.federation.signature_invalid";
223
+ readonly FED_VERSION_SKEW: "mnemo.federation.version_skew";
224
+ readonly FED_QUORUM_UNREACHABLE: "mnemo.federation.quorum_unreachable";
225
+ readonly PROC_BUDGET_BELOW_GATE: "mnemo.procedural.budget_below_gate";
226
+ readonly PROC_NO_TRAJECTORIES: "mnemo.procedural.no_trajectories";
227
+ readonly RATE_LIMIT: "mnemo.rate_limit";
228
+ readonly VALIDATION: "mnemo.validation";
229
+ readonly INTERNAL: "mnemo.internal";
230
+ };
231
+ type MnemoErrorCode = typeof MNEMO_ERROR_CODES[keyof typeof MNEMO_ERROR_CODES];
232
+ interface MnemoSpanAttributes {
233
+ /** Workspace the operation is scoped to. */
234
+ "mnemo.workspace_id"?: string;
235
+ /** Agent (actor) the operation was performed on behalf of. */
236
+ "mnemo.agent_id"?: string;
237
+ /** Session the operation belongs to, when one is active. */
238
+ "mnemo.session_id"?: string;
239
+ /** W3C trace id, propagated across service boundaries. */
240
+ "mnemo.trace_id"?: string;
241
+ /** Primitive kind being operated on (fact/episode/entity/…). */
242
+ "mnemo.kind"?: string;
243
+ /** Operation being performed. */
244
+ "mnemo.operation"?: string;
245
+ /** Surprise/PE score for remember() calls. */
246
+ "mnemo.pe"?: number;
247
+ /** Whether the result was served from hot-tier cache. */
248
+ "mnemo.from_hot_tier"?: boolean;
249
+ /** Which tier served the result: "hot" | "pointer" | "cold" | "l3_cache" | "none". */
250
+ "mnemo.tier_hit"?: string;
251
+ /** True when the result was served from a cache layer (L3 query cache). */
252
+ "mnemo.cache_hit"?: boolean;
253
+ /** Number of hits returned by recall. */
254
+ "mnemo.hit_count"?: number;
255
+ /** Number of results returned (spec alias of hit_count for recall). */
256
+ "mnemo.result_count"?: number;
257
+ /** Mean worth (α/(α+β) or score fallback) across returned hits. */
258
+ "mnemo.worth_avg"?: number;
259
+ /** LLM tokens saved by serving this operation without a model call. */
260
+ "mnemo.tokens_saved"?: number;
261
+ /** LLM tokens consumed by this operation. */
262
+ "mnemo.llm_tokens_used"?: number;
263
+ /** LLM cost in USD attributed to this operation. */
264
+ "mnemo.llm_cost_usd"?: number;
265
+ /** Latency in milliseconds. */
266
+ "mnemo.latency_ms"?: number;
267
+ /** Error code from MNEMO_ERROR_CODES. */
268
+ "mnemo.error_code"?: MnemoErrorCode;
269
+ /** Rule ID that triggered a composition inference. */
270
+ "mnemo.rule_id"?: string;
271
+ /** Number of composition rule firings in a call. */
272
+ "mnemo.firings"?: number;
273
+ /** Self-edit action applied. */
274
+ "mnemo.self_edit.action"?: string;
275
+ /** Idempotency key for mutating operations. */
276
+ "mnemo.idempotency_key"?: string;
277
+ /** Reason the session was collapsed (e.g. "turn_limit", "inactivity", "manual"). */
278
+ "mnemo.collapse.reason"?: string;
279
+ /** Number of turns processed in the collapsed session. */
280
+ "mnemo.collapse.turns"?: number;
281
+ /** Outcome of a reasoning resolve operation. */
282
+ "mnemo.reasoning.result"?: "cache_hit" | "execute";
283
+ /** Federation peer ID for sync operations. */
284
+ "mnemo.federation.peer"?: string;
285
+ /** Plugin name/ID for spans that trace a single named plugin's execution. */
286
+ "mnemo.plugin.name"?: string;
287
+ /** Event hook name for spans that dispatch a hook to all active plugins. */
288
+ "mnemo.plugin.hook"?: string;
289
+ }
290
+ /**
291
+ * Canonical span names emitted by Mnemosyne.
292
+ * Import and use these constants at span-creation sites so dashboards
293
+ * can correlate spans by name without string-matching fragility.
294
+ *
295
+ * `write` is the spec's name (Observability §, line 1718) for the persist
296
+ * span; it is an ALIAS of the live `mnemo.remember` span name (see WP13
297
+ * RECONCILE note). Use MNEMO_SPAN_NAMES.write when referring to the spec
298
+ * concept; the emitted span string remains "mnemo.remember".
299
+ */
300
+ declare const MNEMO_SPAN_NAMES: {
301
+ readonly recall: "mnemo.recall";
302
+ readonly remember: "mnemo.remember";
303
+ /** Spec alias of `remember` (spec calls this span "mnemo.write"). */
304
+ readonly write: "mnemo.remember";
305
+ readonly sessionCollapse: "mnemo.session.collapse";
306
+ readonly reasoningResolve: "mnemo.reasoning.resolve";
307
+ readonly federationSync: "mnemo.federation.sync";
308
+ /** Auth middleware span — wraps the bearer-token resolution path. */
309
+ readonly auth: "mnemo.auth";
310
+ /** Embedding span — wraps embedSingle / embed batch calls. */
311
+ readonly embed: "mnemo.embed";
312
+ /** Re-ranking span — wraps RecMem rerank on the cold path. */
313
+ readonly rerank: "mnemo.rerank";
314
+ /** Composition span — wraps composeInferences on the cold path. */
315
+ readonly composition: "mnemo.composition";
316
+ /** Render span — wraps renderFactsCompact at the call site. */
317
+ readonly render: "mnemo.render";
318
+ readonly plugin: (name: string) => string;
319
+ };
320
+
321
+ /** Magic header marking a residual (prefix/suffix-anchored) payload. */
322
+ declare const DELTA_MAGIC_V1 = "MNEMO_DELTA_V1";
323
+ /** Magic header marking a full-text payload (used when a residual would not be smaller). */
324
+ declare const FULL_MAGIC_V1 = "MNEMO_FULL_V1";
325
+ /**
326
+ * Encode `child` as a residual against `parent`.
327
+ *
328
+ * Format (residual, all parts newline-joined into ONE string):
329
+ * line 0: `MNEMO_DELTA_V1\t<prefixCount>\t<suffixCount>`
330
+ * line 1..N: the differing MIDDLE lines of `child`
331
+ *
332
+ * If the residual would not be strictly smaller than a full payload, returns a
333
+ * full payload instead:
334
+ * line 0: `MNEMO_FULL_V1`
335
+ * line 1..N: the full `child` text
336
+ *
337
+ * `applyDelta` inverts whichever form is produced.
338
+ */
339
+ declare function encodeDelta(parent: string, child: string): string;
340
+ /**
341
+ * Reconstruct the child narrative from `parent` and an encoded `delta`.
342
+ *
343
+ * Back-compat: a `delta` that begins with neither magic header is treated as a
344
+ * literal full narrative (legacy rows / raw fixtures written before WP5).
345
+ */
346
+ declare function applyDelta(parent: string, delta: string): string;
347
+
348
+ /**
349
+ * Canonical EmbeddingSpace identity (§B4.1).
350
+ *
351
+ * Vectors can only be compared when they share the exact same EmbeddingSpace.
352
+ */
353
+ interface EmbeddingSpace {
354
+ spaceId: string;
355
+ provider: string;
356
+ model: string;
357
+ modelRevision?: string;
358
+ dimensions: number;
359
+ distanceMetric: "cosine" | "ip" | "l2";
360
+ inputType?: "document" | "query" | "symmetric";
361
+ normalization?: "l2" | "none";
362
+ dtype?: "float32" | "float16" | "int8";
363
+ preprocessingVersion?: string;
364
+ }
365
+ type EmbeddingSpaceStatus = "building" | "active" | "dormant" | "stale" | "superseded" | "failed";
366
+ /**
367
+ * Generate a deterministic canonical spaceId string.
368
+ */
369
+ declare function generateSpaceId(space: Omit<EmbeddingSpace, "spaceId">): string;
370
+
371
+ export { type CognitiveHealthSnapshot, type CognitiveHealthUnitEconomics, DELTA_MAGIC_V1, type DecisionId, type EmbeddingSpace, type EmbeddingSpaceStatus, type EntityId, type EpisodeId, type EventId, FULL_MAGIC_V1, type FactId, type HyperedgeId, MNEMO_ERROR_CODES, MNEMO_SPAN_NAMES, type MnemoBusEvent, type MnemoChannelPattern, type MnemoErrorCode, type MnemoEventFilter, type MnemoEventType, type MnemoSpanAttributes, type ReasoningId, type RelationId, type SessionId, type SkillId, type StrategyId, type TaskId, type WorkflowId, type WorkspaceId, type WsSubscription, applyDelta, asDecisionId, asEntityId, asEpisodeId, asEventId, asFactId, asReasoningId, asRelationId, asSessionId, asSkillId, asStrategyId, asTaskId, asWorkflowId, asWorkspaceId, encodeDelta, generateSpaceId, isWorkspaceId };
package/dist/index.js ADDED
@@ -0,0 +1,192 @@
1
+ export { ALL_SCOPES, DELTA_MAGIC_V1, FULL_MAGIC_V1, SENSITIVITY_ORDER, SPEC_SCOPES, applyDelta, encodeDelta, resolveAuditActorType, sensitivityAtLeast } from './chunk-H4A2NIMQ.js';
2
+ import { z } from 'zod';
3
+
4
+ /* @mnemo-ai/types — see https://github.com/lucasmailland/mnemosyne */
5
+
6
+ // src/branded.ts
7
+ var asWorkspaceId = (s) => s;
8
+ var asFactId = (s) => s;
9
+ var asDecisionId = (s) => s;
10
+ var asEpisodeId = (s) => s;
11
+ var asEntityId = (s) => s;
12
+ var asStrategyId = (s) => s;
13
+ var asWorkflowId = (s) => s;
14
+ var asSkillId = (s) => s;
15
+ var asTaskId = (s) => s;
16
+ var asEventId = (s) => s;
17
+ var asReasoningId = (s) => s;
18
+ var asSessionId = (s) => s;
19
+ var asRelationId = (s) => s;
20
+ var WORKSPACE_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
21
+ function isWorkspaceId(s) {
22
+ return WORKSPACE_UUID_RE.test(s);
23
+ }
24
+
25
+ // src/ports.ts
26
+ var RECOVERY_POINTS = [
27
+ "started",
28
+ "session_locked",
29
+ "llm_called",
30
+ "facts_persisted",
31
+ "completed"
32
+ ];
33
+ var FactKindClause = z.object({
34
+ op: z.literal("fact_kind"),
35
+ kind: z.string().min(1).max(64),
36
+ bind: z.string().regex(/^\$[a-z][a-z0-9_]*$/i).optional()
37
+ }).strict();
38
+ var TopicKeyInClause = z.object({
39
+ op: z.literal("topic_key_in"),
40
+ topicKeys: z.array(z.string().min(1).max(200)).min(1).max(32),
41
+ bind: z.string().regex(/^\$[a-z][a-z0-9_]*$/i).optional()
42
+ }).strict();
43
+ var TextContainsClause = z.object({
44
+ op: z.literal("text_contains"),
45
+ needle: z.string().min(1).max(500),
46
+ bind: z.string().regex(/^\$[a-z][a-z0-9_]*$/i).optional()
47
+ }).strict();
48
+ var RELATION_VERBS = [
49
+ "related",
50
+ "compatible",
51
+ "scoped",
52
+ "conflicts_with",
53
+ "supersedes",
54
+ "not_conflict",
55
+ "derived_from",
56
+ "part_of",
57
+ "member_of"
58
+ ];
59
+ var BIND_RE = /^\$[a-z][a-z0-9_]*$/i;
60
+ var RelationClause = z.object({
61
+ op: z.literal("relation"),
62
+ from: z.string().regex(BIND_RE),
63
+ to: z.string().regex(BIND_RE),
64
+ verb: z.enum(RELATION_VERBS)
65
+ }).strict();
66
+ var NumberOrBind = z.union([z.number(), z.string().regex(BIND_RE)]);
67
+ var FactValueClause = z.object({
68
+ op: z.literal("fact_value"),
69
+ subject: z.string().regex(BIND_RE),
70
+ predicate: z.string().min(1).max(128),
71
+ valueType: z.enum(["duration", "number"]),
72
+ compare: z.object({
73
+ lt: NumberOrBind.optional(),
74
+ gt: NumberOrBind.optional(),
75
+ lte: NumberOrBind.optional(),
76
+ gte: NumberOrBind.optional()
77
+ }).strict().partial().optional(),
78
+ bind: z.string().regex(BIND_RE).optional()
79
+ }).strict();
80
+ var ConditionClause = z.discriminatedUnion("op", [
81
+ FactKindClause,
82
+ TopicKeyInClause,
83
+ TextContainsClause,
84
+ RelationClause,
85
+ FactValueClause
86
+ ]);
87
+ var ConditionDslSchema = z.object({
88
+ all: z.array(ConditionClause).min(1).max(8)
89
+ }).strict();
90
+ var DeriveFactAction = z.object({
91
+ op: z.literal("derive_fact"),
92
+ statementTemplate: z.string().min(1).max(2e3),
93
+ // DSL kind: NOT a valid MnemoFact.kind — stored in metadata.inference.derivedKind.
94
+ // Engine writes kind='other' to mnemo_fact (valid kind) and attribution='inferred'.
95
+ kind: z.string().min(1).max(64).default("inferred"),
96
+ topicKey: z.string().max(200).optional(),
97
+ baseConfidence: z.number().min(0).max(1).default(0.7),
98
+ sensitivity: z.enum(["public", "internal", "confidential", "restricted"]).default("internal"),
99
+ type: z.literal("fact").default("fact")
100
+ }).strict();
101
+ var DeriveWarningAction = z.object({
102
+ op: z.literal("derive_warning"),
103
+ statementTemplate: z.string().min(1).max(2e3),
104
+ kind: z.string().min(1).max(64).default("inferred"),
105
+ topicKey: z.string().max(200).optional(),
106
+ baseConfidence: z.number().min(0).max(1).default(0.7),
107
+ sensitivity: z.enum(["public", "internal", "confidential", "restricted"]).default("internal"),
108
+ type: z.literal("warning").default("warning")
109
+ }).strict();
110
+ var ActionDslSchema = z.discriminatedUnion("op", [DeriveFactAction, DeriveWarningAction]);
111
+ function parseConditionDsl(raw) {
112
+ return ConditionDslSchema.parse(raw);
113
+ }
114
+ function parseActionDsl(raw) {
115
+ return ActionDslSchema.parse(raw);
116
+ }
117
+
118
+ // src/observability.ts
119
+ var MNEMO_ERROR_CODES = {
120
+ // Storage errors
121
+ STORAGE_NOT_FOUND: "mnemo.storage.not_found",
122
+ STORAGE_CONFLICT: "mnemo.storage.conflict",
123
+ STORAGE_CONSTRAINT: "mnemo.storage.constraint_violation",
124
+ STORAGE_TIMEOUT: "mnemo.storage.timeout",
125
+ // Auth errors
126
+ AUTH_MISSING_KEY: "mnemo.auth.missing_key",
127
+ AUTH_EXPIRED_KEY: "mnemo.auth.expired_key",
128
+ AUTH_INSUFFICIENT_SCOPE: "mnemo.auth.insufficient_scope",
129
+ AUTH_WORKSPACE_MISMATCH: "mnemo.auth.workspace_mismatch",
130
+ // Recall errors
131
+ RECALL_BUDGET_EXCEEDED: "mnemo.recall.budget_exceeded",
132
+ RECALL_VECTOR_MISSING: "mnemo.recall.vector_missing",
133
+ RECALL_UPSTREAM_TIMEOUT: "mnemo.recall.upstream_timeout",
134
+ // Composition errors
135
+ COMPOSE_DSL_INVALID: "mnemo.compose.dsl_invalid",
136
+ COMPOSE_MAX_FIRINGS: "mnemo.compose.max_firings_reached",
137
+ COMPOSE_MATERIALISE_FAIL: "mnemo.compose.materialise_failed",
138
+ // Self-edit errors
139
+ SELF_EDIT_BUDGET: "mnemo.self_edit.budget_exceeded",
140
+ SELF_EDIT_COOLDOWN: "mnemo.self_edit.cooldown_active",
141
+ SELF_EDIT_SCOPE: "mnemo.self_edit.scope_denied",
142
+ SELF_EDIT_ABUSE_FLAG: "mnemo.self_edit.abuse_flagged",
143
+ SELF_EDIT_WORTH_FROZEN: "mnemo.self_edit.worth_frozen",
144
+ // Federation errors
145
+ FED_SIGNATURE_INVALID: "mnemo.federation.signature_invalid",
146
+ FED_VERSION_SKEW: "mnemo.federation.version_skew",
147
+ FED_QUORUM_UNREACHABLE: "mnemo.federation.quorum_unreachable",
148
+ // Procedural errors
149
+ PROC_BUDGET_BELOW_GATE: "mnemo.procedural.budget_below_gate",
150
+ PROC_NO_TRAJECTORIES: "mnemo.procedural.no_trajectories",
151
+ // General
152
+ RATE_LIMIT: "mnemo.rate_limit",
153
+ VALIDATION: "mnemo.validation",
154
+ INTERNAL: "mnemo.internal"
155
+ };
156
+ var MNEMO_SPAN_NAMES = {
157
+ recall: "mnemo.recall",
158
+ remember: "mnemo.remember",
159
+ /** Spec alias of `remember` (spec calls this span "mnemo.write"). */
160
+ write: "mnemo.remember",
161
+ sessionCollapse: "mnemo.session.collapse",
162
+ reasoningResolve: "mnemo.reasoning.resolve",
163
+ federationSync: "mnemo.federation.sync",
164
+ /** Auth middleware span — wraps the bearer-token resolution path. */
165
+ auth: "mnemo.auth",
166
+ /** Embedding span — wraps embedSingle / embed batch calls. */
167
+ embed: "mnemo.embed",
168
+ /** Re-ranking span — wraps RecMem rerank on the cold path. */
169
+ rerank: "mnemo.rerank",
170
+ /** Composition span — wraps composeInferences on the cold path. */
171
+ composition: "mnemo.composition",
172
+ /** Render span — wraps renderFactsCompact at the call site. */
173
+ render: "mnemo.render",
174
+ plugin: (name) => `mnemo.plugin.${name}`
175
+ };
176
+
177
+ // src/embedding.ts
178
+ function generateSpaceId(space) {
179
+ const parts = [
180
+ space.provider,
181
+ space.model,
182
+ space.modelRevision ?? "v1",
183
+ String(space.dimensions),
184
+ space.distanceMetric ?? "cosine",
185
+ space.dtype ?? "float32"
186
+ ];
187
+ return parts.join(":").toLowerCase();
188
+ }
189
+
190
+ export { ActionDslSchema, ConditionDslSchema, MNEMO_ERROR_CODES, MNEMO_SPAN_NAMES, RECOVERY_POINTS, asDecisionId, asEntityId, asEpisodeId, asEventId, asFactId, asReasoningId, asRelationId, asSessionId, asSkillId, asStrategyId, asTaskId, asWorkflowId, asWorkspaceId, generateSpaceId, isWorkspaceId, parseActionDsl, parseConditionDsl };
191
+ //# sourceMappingURL=index.js.map
192
+ //# sourceMappingURL=index.js.map