@jmanuelcorral/openteam 0.1.37 → 0.1.40

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.
Files changed (84) hide show
  1. package/.opencode/command/openteam.md +5 -5
  2. package/AGENTS.md +27 -27
  3. package/README.es.md +759 -0
  4. package/README.md +213 -480
  5. package/dist/capabilities/types.d.ts +1 -1
  6. package/dist/cli/consoleServe.d.ts.map +1 -1
  7. package/dist/cli/setupAdapters.d.ts.map +1 -1
  8. package/dist/cli.js +1122 -250
  9. package/dist/commands/frontierCatalog.d.ts +27 -0
  10. package/dist/commands/frontierCatalog.d.ts.map +1 -0
  11. package/dist/commands/orchestratorAgent.d.ts +2 -1
  12. package/dist/commands/orchestratorAgent.d.ts.map +1 -1
  13. package/dist/commands/setup.d.ts +16 -18
  14. package/dist/commands/setup.d.ts.map +1 -1
  15. package/dist/config/schema.d.ts +196 -0
  16. package/dist/config/schema.d.ts.map +1 -1
  17. package/dist/console/assets.d.ts +9 -0
  18. package/dist/console/assets.d.ts.map +1 -0
  19. package/dist/console/render.d.ts.map +1 -1
  20. package/dist/contract/opencode.d.ts +1 -1
  21. package/dist/contract/opencode.d.ts.map +1 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +835 -87
  24. package/dist/local/embeddings.d.ts +29 -0
  25. package/dist/local/embeddings.d.ts.map +1 -0
  26. package/dist/local/extractClient.d.ts +31 -0
  27. package/dist/local/extractClient.d.ts.map +1 -0
  28. package/dist/local/openai-compatible.d.ts +1 -0
  29. package/dist/local/openai-compatible.d.ts.map +1 -1
  30. package/dist/mcp/semanticRecall.d.ts +25 -0
  31. package/dist/mcp/semanticRecall.d.ts.map +1 -0
  32. package/dist/mcp/server.d.ts +22 -0
  33. package/dist/mcp/server.d.ts.map +1 -1
  34. package/dist/memory/consolidate.d.ts +21 -0
  35. package/dist/memory/consolidate.d.ts.map +1 -0
  36. package/dist/memory/extract.d.ts +68 -0
  37. package/dist/memory/extract.d.ts.map +1 -0
  38. package/dist/memory/fold.d.ts +24 -0
  39. package/dist/memory/fold.d.ts.map +1 -0
  40. package/dist/memory/index.d.ts +18 -0
  41. package/dist/memory/index.d.ts.map +1 -0
  42. package/dist/memory/inject.d.ts +29 -0
  43. package/dist/memory/inject.d.ts.map +1 -0
  44. package/dist/memory/log.d.ts +16 -0
  45. package/dist/memory/log.d.ts.map +1 -0
  46. package/dist/memory/merge.d.ts +38 -0
  47. package/dist/memory/merge.d.ts.map +1 -0
  48. package/dist/memory/rank.d.ts +32 -0
  49. package/dist/memory/rank.d.ts.map +1 -0
  50. package/dist/memory/recall.d.ts +30 -0
  51. package/dist/memory/recall.d.ts.map +1 -0
  52. package/dist/memory/temporal.d.ts +39 -0
  53. package/dist/memory/temporal.d.ts.map +1 -0
  54. package/dist/memory/types.d.ts +159 -0
  55. package/dist/memory/types.d.ts.map +1 -0
  56. package/dist/memory/vector.d.ts +18 -0
  57. package/dist/memory/vector.d.ts.map +1 -0
  58. package/dist/orchestrator/roles.d.ts +1 -1
  59. package/dist/orchestrator/roles.d.ts.map +1 -1
  60. package/dist/plugin/hooks.d.ts +13 -0
  61. package/dist/plugin/hooks.d.ts.map +1 -1
  62. package/dist/plugin/memoryInject.d.ts +25 -0
  63. package/dist/plugin/memoryInject.d.ts.map +1 -0
  64. package/dist/router/chooseModel.d.ts.map +1 -1
  65. package/dist/router/cost.d.ts +4 -0
  66. package/dist/router/cost.d.ts.map +1 -0
  67. package/dist/router/frontierBaseline.d.ts +13 -0
  68. package/dist/router/frontierBaseline.d.ts.map +1 -0
  69. package/dist/router/modelSelection.d.ts +18 -0
  70. package/dist/router/modelSelection.d.ts.map +1 -0
  71. package/dist/storage/index/memoryConsolidate.d.ts +24 -0
  72. package/dist/storage/index/memoryConsolidate.d.ts.map +1 -0
  73. package/dist/storage/index/memoryIndex.d.ts +52 -0
  74. package/dist/storage/index/memoryIndex.d.ts.map +1 -0
  75. package/dist/storage/index/memoryRecall.d.ts +23 -0
  76. package/dist/storage/index/memoryRecall.d.ts.map +1 -0
  77. package/dist/storage/index/memoryRuntime.d.ts +41 -0
  78. package/dist/storage/index/memoryRuntime.d.ts.map +1 -0
  79. package/dist/telemetry/events.d.ts +3 -1
  80. package/dist/telemetry/events.d.ts.map +1 -1
  81. package/dist/telemetry/hash.d.ts.map +1 -1
  82. package/dist/web/server.d.ts +4 -0
  83. package/dist/web/server.d.ts.map +1 -1
  84. package/package.json +14 -6
@@ -0,0 +1,29 @@
1
+ import type { Embedding } from "../memory/types";
2
+ import type { FetchLike } from "./types";
3
+ /**
4
+ * Adapter **local-first** de embeddings. Aquí vive el I/O: llama al endpoint
5
+ * OpenAI-compatible `/embeddings` del runtime local. Los vectores se calculan en
6
+ * la máquina (nunca salen a frontier si `forceLocalOnSensitive`) y no son texto
7
+ * legible, por lo que pueden persistirse aun con `storeContent=false`.
8
+ */
9
+ /** Función de embedding inyectable: mapea textos a vectores en el mismo orden. */
10
+ export type Embedder = (texts: readonly string[]) => Promise<Embedding[]>;
11
+ export type EmbedRequest = {
12
+ baseURL: string;
13
+ modelID: string;
14
+ texts: readonly string[];
15
+ };
16
+ export type EmbedDeps = {
17
+ fetch: FetchLike;
18
+ };
19
+ /** Parsea la respuesta OpenAI-compatible de `/embeddings` a vectores ordenados. */
20
+ export declare function parseEmbeddingsResponse(payload: unknown): Embedding[];
21
+ /**
22
+ * Ejecuta el embedding contra el runtime local. Devuelve un vector por texto, en
23
+ * el mismo orden. Lanza si la petición o la respuesta fallan (a diferencia de la
24
+ * extracción, aquí un fallo es relevante para el recall).
25
+ */
26
+ export declare function embedTexts(request: EmbedRequest, deps: EmbedDeps): Promise<Embedding[]>;
27
+ /** Construye un `Embedder` que usa el runtime local vía `embedTexts`. */
28
+ export declare function createLocalEmbedder(request: Omit<EmbedRequest, "texts">, deps: EmbedDeps): Embedder;
29
+ //# sourceMappingURL=embeddings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../src/local/embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;GAKG;AAEH,kFAAkF;AAClF,MAAM,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;AAE1E,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,mFAAmF;AACnF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,CAwBrE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EACpC,IAAI,EAAE,SAAS,GACd,QAAQ,CAEV"}
@@ -0,0 +1,31 @@
1
+ import { type ExtractionContext, type ExtractionMessage } from "../memory/extract";
2
+ import type { MemoryRecord } from "../memory/types";
3
+ import type { FetchLike } from "./types";
4
+ /**
5
+ * Adapter **local-first** de extracción de memoria. Aquí vive el I/O: llama al
6
+ * runtime local OpenAI-compatible (`/chat/completions`) y delega el parseo/redacción
7
+ * a `parseExtraction` (puro). El `router/`/`memory/` core permanece determinista.
8
+ *
9
+ * Coste marginal ~0 y los datos no salen de la máquina. Frontier solo como
10
+ * fallback opt-in (fuera de este adapter, respetando `forceLocalOnSensitive`).
11
+ */
12
+ export type ExtractRequest = {
13
+ baseURL: string;
14
+ modelID: string;
15
+ messages: readonly ExtractionMessage[];
16
+ context: ExtractionContext;
17
+ /** Temperatura; 0 por defecto para maximizar determinismo del extractor. */
18
+ temperature?: number;
19
+ };
20
+ export type ExtractDeps = {
21
+ fetch: FetchLike;
22
+ };
23
+ /** Extrae el texto del primer choice de una respuesta OpenAI-compatible. */
24
+ export declare function readChatContent(payload: unknown): string;
25
+ /**
26
+ * Ejecuta la extracción contra el runtime local. Devuelve `MemoryRecord[]` ya
27
+ * redactados según `context.storeContent`. Nunca lanza por respuestas vacías o
28
+ * malformadas: en ese caso devuelve `[]` (tolerante, como el resto del pipeline).
29
+ */
30
+ export declare function extractMemory(request: ExtractRequest, deps: ExtractDeps): Promise<MemoryRecord[]>;
31
+ //# sourceMappingURL=extractClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractClient.d.ts","sourceRoot":"","sources":["../../src/local/extractClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;GAOG;AAEH,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAmBxD;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,YAAY,EAAE,CAAC,CAsCzB"}
@@ -2,6 +2,7 @@ import type { FetchLike, LocalModelInfo, LocalRuntimeId, LocalRuntimeSnapshot }
2
2
  export declare function normalizeBaseURL(baseURL: string): string;
3
3
  export declare function modelsEndpoint(baseURL: string): string;
4
4
  export declare function chatCompletionsEndpoint(baseURL: string): string;
5
+ export declare function embeddingsEndpoint(baseURL: string): string;
5
6
  export declare function errorMessage(error: unknown): string;
6
7
  export declare function listOpenAICompatibleModels(baseURL: string, fetch: FetchLike): Promise<LocalModelInfo[]>;
7
8
  export declare function parseOpenAIModels(payload: unknown): LocalModelInfo[];
@@ -1 +1 @@
1
- {"version":3,"file":"openai-compatible.d.ts","sourceRoot":"","sources":["../../src/local/openai-compatible.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACd,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMnD;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,cAAc,EAAE,CAAC,CAkB3B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,EAAE,CAMpE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE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ACjB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,oBAAoB,CASvB;AAED,wBAAsB,4BAA4B,CAAC,KAAK,EAAE;IACxD,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmBhC;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,OAAO,CAAC,OAAO,CAAC,CAiDnB"}
@@ -0,0 +1,25 @@
1
+ import type { Embedder } from "../local/embeddings";
2
+ import type { RankSignals } from "../memory/rank";
3
+ import type { MemoryIndex } from "../storage/index/memoryIndex";
4
+ import type { SemanticRecall } from "./server";
5
+ /**
6
+ * Compone un `SemanticRecall` (para el servidor MCP) a partir del índice de
7
+ * memoria, un `Embedder` local y la política de scope/temporal. Aísla el wiring
8
+ * del recall semántico para que `cli.ts` sea un caller fino y esto quede cubierto
9
+ * por tests.
10
+ */
11
+ export type SemanticRecallPolicy = {
12
+ ownerKey: string;
13
+ asOf?: number | null;
14
+ minSimilarity: number;
15
+ includeShared: boolean;
16
+ };
17
+ export type SemanticRecallDeps = {
18
+ index: MemoryIndex;
19
+ embedder: Embedder;
20
+ /** Reloj inyectado (epoch ms) para el `asOf` "ahora". */
21
+ now: () => number;
22
+ signals?: Omit<RankSignals, "now">;
23
+ };
24
+ export declare function buildSemanticRecall(deps: SemanticRecallDeps, policy: SemanticRecallPolicy): SemanticRecall;
25
+ //# sourceMappingURL=semanticRecall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticRecall.d.ts","sourceRoot":"","sources":["../../src/mcp/semanticRecall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AAEH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,yDAAyD;IACzD,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,oBAAoB,GAC3B,cAAc,CAqBhB"}
@@ -1,3 +1,4 @@
1
+ import type { MemoryKind, RecallResult } from "../memory/types";
1
2
  import { type TeamMemory } from "./teamMemory";
2
3
  /**
3
4
  * Servidor MCP **de solo lectura** que expone la memoria del equipo
@@ -7,6 +8,11 @@ import { type TeamMemory } from "./teamMemory";
7
8
  *
8
9
  * `handleMcpMessage` es puro salvo por `deps.readMemory` (inyectado): no expone
9
10
  * prompts crudos, solo el estado ya redactado por la agregación.
11
+ *
12
+ * Si se inyecta `deps.recallSemantic` (memoria semántica opt-in, M4), se exponen
13
+ * además tools de recall (`recall_facts`/`recall_preferences`/`similar_tasks`).
14
+ * El contenido devuelto es el ya redactado en el store (`storeContent=false` por
15
+ * defecto): la tool nunca reconstruye texto crudo.
10
16
  */
11
17
  export declare const MCP_PROTOCOL_VERSION = "2024-11-05";
12
18
  export type JsonRpcId = string | number | null;
@@ -30,9 +36,21 @@ export type McpServerInfo = {
30
36
  name: string;
31
37
  version: string;
32
38
  };
39
+ /**
40
+ * Recall semántico inyectado (M4). La política de scope (`ownerKey`), `asOf` y
41
+ * `minSimilarity` la decide el wiring; la tool solo pasa el texto, los `kinds` y
42
+ * el `limit`. Devuelve records ya redactados por el store.
43
+ */
44
+ export type SemanticRecall = (input: {
45
+ queryText: string;
46
+ kinds: MemoryKind[];
47
+ limit: number;
48
+ }) => Promise<RecallResult[]>;
33
49
  export type McpServerDeps = {
34
50
  /** Lee la memoria del equipo bajo demanda (I/O inyectado). */
35
51
  readMemory: () => Promise<TeamMemory>;
52
+ /** Recall semántico opt-in; si está ausente, las tools de memoria no se exponen. */
53
+ recallSemantic?: SemanticRecall;
36
54
  serverInfo?: McpServerInfo;
37
55
  };
38
56
  type ToolDef = {
@@ -41,6 +59,10 @@ type ToolDef = {
41
59
  inputSchema: Record<string, unknown>;
42
60
  };
43
61
  export declare const MCP_TOOLS: ToolDef[];
62
+ /** Tools de memoria semántica (M4). Solo se exponen si hay `recallSemantic`. */
63
+ export declare const MEMORY_TOOLS: ToolDef[];
64
+ /** Tools disponibles según los deps (las de memoria son opt-in). */
65
+ export declare function availableTools(deps: McpServerDeps): ToolDef[];
44
66
  /**
45
67
  * Procesa un mensaje JSON-RPC del cliente MCP. Devuelve la respuesta, o `null`
46
68
  * para notificaciones (mensajes sin `id`, p. ej. `notifications/initialized`).
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAEtB;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CA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AC;AAUF,eAAO,MAAM,SAAS,EAAE,OAAO,EAgC9B,CAAC;AAUF,gFAAgF;AAChF,eAAO,MAAM,YAAY,EAAE,OAAO,EA+BjC,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,EAAE,CAI7D;AAwID;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAwCjC"}
@@ -0,0 +1,21 @@
1
+ import type { MemoryRecord } from "./types";
2
+ export type DecayParams = {
3
+ /** Vida media de la confianza (ms). A mayor edad sin refuerzo, menor confianza. */
4
+ halfLifeMs: number;
5
+ /** Umbral por debajo del cual el record se olvida (soft-invalidate). */
6
+ forgetThreshold: number;
7
+ };
8
+ export declare const DEFAULT_DECAY_PARAMS: DecayParams;
9
+ /**
10
+ * Confianza decaída del record en `now`: `confidence * 0.5 ** (edad / vidaMedia)`.
11
+ * A edad 0 devuelve la confianza original; nunca crece con el tiempo.
12
+ */
13
+ export declare function decayedConfidence(record: MemoryRecord, now: number, params?: DecayParams): number;
14
+ /**
15
+ * Genera los tombstones para los records **transaction-activos** cuya confianza
16
+ * decaída cae por debajo de `forgetThreshold`. Cada tombstone conserva el `id`
17
+ * del record y marca `invalidatedAt = now` (olvido por decay, sin `supersededBy`:
18
+ * no es una supersesión). Los records ya invalidados se ignoran (idempotente).
19
+ */
20
+ export declare function consolidate(records: readonly MemoryRecord[], now: number, params?: DecayParams): MemoryRecord[];
21
+ //# sourceMappingURL=consolidate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consolidate.d.ts","sourceRoot":"","sources":["../../src/memory/consolidate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkB5C,MAAM,MAAM,WAAW,GAAG;IACxB,mFAAmF;IACnF,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,WAGlC,CAAC;AAUF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,WAAkC,GACzC,MAAM,CAGR;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,WAAkC,GACzC,YAAY,EAAE,CAWhB"}
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ import type { MemoryRecord } from "./types";
3
+ /**
4
+ * Extracción de memoria **pura y determinista**. Construye el prompt de extracción
5
+ * y parsea la salida JSON del modelo a `MemoryRecord[]`, aplicando la política de
6
+ * redacción (ADR-5). **Sin I/O, red, reloj ni random**: el instante (`now`), el
7
+ * `ownerKey`, el `sourceHash` y el `idPrefix` los inyecta el llamante (el adapter
8
+ * local vive en `src/local/`).
9
+ *
10
+ * Privacidad (ADR-5): con `storeContent=false` (default) se conserva la estructura
11
+ * (subject/predicate/category/type) pero el **valor libre** (object/preference/
12
+ * canonicalName) se redacta; la trazabilidad queda en `sourceHash`.
13
+ */
14
+ export declare const REDACTED: "[redacted]";
15
+ export type ExtractionRole = "system" | "user" | "assistant";
16
+ export type ExtractionMessage = {
17
+ role: ExtractionRole;
18
+ content: string;
19
+ };
20
+ export type ExtractionContext = {
21
+ ownerKey: string;
22
+ /** Epoch ms; se usa como `validFrom` y `createdAt` de cada record. */
23
+ now: number;
24
+ /** Hash de los mensajes fuente (provenance). Nunca el prompt crudo. */
25
+ sourceHash: string;
26
+ /** Si false (default), redacta el valor libre de cada record. */
27
+ storeContent: boolean;
28
+ /** Prefijo determinista para los ids generados. */
29
+ idPrefix: string;
30
+ };
31
+ export declare const RawExtractionSchema: z.ZodObject<{
32
+ facts: z.ZodDefault<z.ZodArray<z.ZodObject<{
33
+ subject: z.ZodString;
34
+ predicate: z.ZodString;
35
+ object: z.ZodString;
36
+ category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ confidence: z.ZodOptional<z.ZodNumber>;
38
+ }, z.core.$strip>>>;
39
+ preferences: z.ZodDefault<z.ZodArray<z.ZodObject<{
40
+ category: z.ZodString;
41
+ preference: z.ZodString;
42
+ context: z.ZodOptional<z.ZodNullable<z.ZodString>>;
43
+ confidence: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strip>>>;
45
+ entities: z.ZodDefault<z.ZodArray<z.ZodObject<{
46
+ canonicalName: z.ZodString;
47
+ type: z.ZodString;
48
+ aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
49
+ confidence: z.ZodOptional<z.ZodNumber>;
50
+ }, z.core.$strip>>>;
51
+ }, z.core.$strip>;
52
+ export type RawExtraction = z.infer<typeof RawExtractionSchema>;
53
+ /** Construye el prompt de extracción (determinista). */
54
+ export declare function buildExtractionPrompt(messages: readonly ExtractionMessage[]): {
55
+ system: string;
56
+ user: string;
57
+ };
58
+ /**
59
+ * Extrae el primer objeto JSON balanceado del texto (tolera fences ```json y
60
+ * prosa alrededor). Devuelve `undefined` si no hay ninguno.
61
+ */
62
+ export declare function extractJsonObject(text: string): unknown;
63
+ /**
64
+ * Parsea la salida cruda del modelo a records de memoria, aplicando redacción.
65
+ * Tolerante: si no hay JSON válido o no valida el esquema, devuelve `[]`.
66
+ */
67
+ export declare function parseExtraction(rawText: string, ctx: ExtractionContext): MemoryRecord[];
68
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/memory/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAgB,YAAY,EAAc,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,QAAQ,EAAG,YAAqB,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAyBF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAchE,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,GAAG;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAMA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAqCvD;AA2ED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,iBAAiB,GACrB,YAAY,EAAE,CAehB"}
@@ -0,0 +1,24 @@
1
+ import type { Entity, Fact, MemoryRecord, Preference } from "./types";
2
+ /**
3
+ * Repliegue **puro** del log de aserciones al estado de memoria vigente. Reproduce
4
+ * la reconciliación (merge + supersesión no destructiva) en orden, usando el
5
+ * `createdAt` de cada aserción como instante de merge. El resultado incluye el
6
+ * histórico invalidado (para recall "as-of"), de modo que el índice SQLite es un
7
+ * derivado 100% reconstruible desde el log.
8
+ *
9
+ * Una aserción con `invalidatedAt !== null` es un **tombstone** de consolidación
10
+ * (ver `consolidate.ts`): soft-invalida el record con su mismo `id` en lugar de
11
+ * mergear un valor nuevo. Los writers de M1-M3 siempre afirman records activos,
12
+ * así que esta rama solo se activa para tombstones.
13
+ */
14
+ export type MemoryState = {
15
+ facts: Fact[];
16
+ preferences: Preference[];
17
+ entities: Entity[];
18
+ };
19
+ export declare function emptyState(): MemoryState;
20
+ /** Repliega las aserciones (en orden) al estado vigente + histórico. */
21
+ export declare function foldAssertions(assertions: readonly MemoryRecord[]): MemoryState;
22
+ /** Aplana un estado a la lista de todos sus records (facts + prefs + entities). */
23
+ export declare function allRecords(state: MemoryState): MemoryRecord[];
24
+ //# sourceMappingURL=fold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../src/memory/fold.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,UAAU,IAAI,WAAW,CAExC;AAuBD,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,YAAY,EAAE,GAClC,WAAW,CA4Bb;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,EAAE,CAE7D"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Barrel del núcleo puro de memoria semántica (`src/memory/`). Análogo a
3
+ * `router/` en pureza: **sin I/O, red, reloj, random ni env vars**. La
4
+ * persistencia (SQLite derivado), la extracción y los embeddings viven en
5
+ * adapters inyectados fuera de este módulo.
6
+ */
7
+ export * from "./consolidate";
8
+ export * from "./extract";
9
+ export * from "./fold";
10
+ export * from "./inject";
11
+ export * from "./log";
12
+ export * from "./merge";
13
+ export * from "./rank";
14
+ export * from "./recall";
15
+ export * from "./temporal";
16
+ export * from "./types";
17
+ export * from "./vector";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { MemoryRecord, RecallResult } from "./types";
2
+ /**
3
+ * Formato **puro** del bloque de contexto de memoria que M6 inyecta (opt-in) en
4
+ * `chat.message`. Convierte los resultados de recall en un bloque de texto
5
+ * compacto respetando un **presupuesto de tokens** (aproximado por caracteres),
6
+ * para no inflar el contexto ni el coste.
7
+ *
8
+ * Privacy-first: solo formatea lo que ya está en los records (redactados en
9
+ * origen si `storeContent=false`). Módulo puro: sin I/O, red, reloj ni random.
10
+ */
11
+ export type MemoryInjectionParams = {
12
+ /** Presupuesto máximo del bloque en caracteres (proxy de tokens). */
13
+ maxChars: number;
14
+ /** Cabecera del bloque inyectado. */
15
+ header: string;
16
+ /** Máximo de líneas (records) a incluir. */
17
+ maxItems: number;
18
+ };
19
+ export declare const DEFAULT_INJECTION_PARAMS: MemoryInjectionParams;
20
+ /** Formatea un record a una línea compacta y legible según su tipo. */
21
+ export declare function formatRecordLine(record: MemoryRecord): string;
22
+ /**
23
+ * Construye el bloque de memoria a partir de los resultados de recall (ya
24
+ * rankeados). Incluye líneas mientras quepan en `maxChars` y no superen
25
+ * `maxItems`. Devuelve `null` si no hay nada que inyectar (sin resultados o
26
+ * ninguna línea cabe), para que el hook no toque el prompt.
27
+ */
28
+ export declare function buildMemoryBlock(results: readonly RecallResult[], params?: MemoryInjectionParams): string | null;
29
+ //# sourceMappingURL=inject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../src/memory/inject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;GAQG;AAEH,MAAM,MAAM,qBAAqB,GAAG;IAClC,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,qBAItC,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAY7D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,MAAM,GAAE,qBAAgD,GACvD,MAAM,GAAG,IAAI,CAsBf"}
@@ -0,0 +1,16 @@
1
+ import { type MemoryRecord } from "./types";
2
+ /**
3
+ * Log **append-only** de aserciones de memoria (fuente de verdad, JSONL). Cada
4
+ * línea es un `MemoryRecord` serializado tal cual se afirmó; el índice SQLite se
5
+ * **deriva** replegando estas aserciones (ver `fold.ts`). Módulo puro: solo
6
+ * (de)serializa; el I/O lo hace el `StorageProvider` inyectado.
7
+ */
8
+ /** Serializa una aserción a su línea JSONL canónica. */
9
+ export declare function serializeAssertion(record: MemoryRecord): string;
10
+ /**
11
+ * Parsea un log JSONL de aserciones. Ignora líneas vacías, JSON malformado y
12
+ * records que no validan contra el esquema (tolerante a corrupción, como
13
+ * `parseEventsJsonl`).
14
+ */
15
+ export declare function parseMemoryLog(text: string): MemoryRecord[];
16
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/memory/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,SAAS,CAAC;AAEhE;;;;;GAKG;AAEH,wDAAwD;AACxD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAmB3D"}
@@ -0,0 +1,38 @@
1
+ import type { Entity, Fact, Preference } from "./types";
2
+ /** Slot de un hecho: `{subject, predicate, ownerKey}`. Solo un valor activo por slot. */
3
+ export declare function factSlotKey(fact: Fact): string;
4
+ /** Triple exacto: slot + `object`. Idempotente (MERGE key dueño-scoped). */
5
+ export declare function factValueKey(fact: Fact): string;
6
+ /** Slot de una preferencia: `{category, ownerKey}`. */
7
+ export declare function preferenceSlotKey(preference: Preference): string;
8
+ /** Valor exacto de una preferencia: slot + texto. */
9
+ export declare function preferenceValueKey(preference: Preference): string;
10
+ /** Slot de una entidad: `{canonicalName, type, ownerKey}`. */
11
+ export declare function entitySlotKey(entity: Entity): string;
12
+ export type MergeResult<T> = {
13
+ /** Estado resultante (incluye históricos invalidados). */
14
+ records: T[];
15
+ /** Records que este merge dejó superseded (con `invalidatedAt`/`supersededBy`). */
16
+ superseded: T[];
17
+ };
18
+ /**
19
+ * Aplica un hecho al estado:
20
+ * - Si ya existe el **triple exacto activo** -> re-afirmación idempotente (fusiona
21
+ * la ventana de validez y sube la confianza; no añade duplicado).
22
+ * - Si existe otro **valor activo en el mismo slot** -> lo supersede y añade el nuevo.
23
+ * - En otro caso -> añade el nuevo. Los históricos inactivos se preservan intactos.
24
+ */
25
+ export declare function applyFact(state: readonly Fact[], incoming: Fact, now: number): MergeResult<Fact>;
26
+ /**
27
+ * Aplica una preferencia al estado, con la misma semántica de slot que los hechos
28
+ * (`{category, ownerKey}` admite un valor activo). Al re-afirmar el mismo texto,
29
+ * conserva el record existente sin duplicar.
30
+ */
31
+ export declare function applyPreference(state: readonly Preference[], incoming: Preference, now: number): MergeResult<Preference>;
32
+ /**
33
+ * Aplica una entidad: dedup **idempotente** por slot `{canonicalName, type,
34
+ * ownerKey}`. Al re-encontrarla, fusiona alias (unión estable) y sube confianza;
35
+ * no supersede (las entidades no se contradicen, se enriquecen).
36
+ */
37
+ export declare function applyEntity(state: readonly Entity[], incoming: Entity, now: number): MergeResult<Entity>;
38
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/memory/merge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAcxD,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9C;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE/C;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEhE;AAED,qDAAqD;AACrD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAEjE;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,mFAAmF;IACnF,UAAU,EAAE,CAAC,EAAE,CAAC;CACjB,CAAC;AAYF;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,QAAQ,EAAE,IAAI,EACd,GAAG,EAAE,MAAM,GACV,WAAW,CAAC,IAAI,CAAC,CAkCnB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,MAAM,GACV,WAAW,CAAC,UAAU,CAAC,CAqCzB;AAiBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,GACV,WAAW,CAAC,MAAM,CAAC,CAsBrB"}
@@ -0,0 +1,32 @@
1
+ import type { MemoryRecord, RecallCandidate, RecallResult } from "./types";
2
+ /**
3
+ * Ranking **determinista y auditable** de candidatos de recall. En lugar de un
4
+ * score opaco, combina señales **explícitas** (similitud semántica, recencia y
5
+ * refuerzo por acceso) con pesos configurables. Módulo puro: `now` se inyecta.
6
+ */
7
+ export type RankSignals = {
8
+ /** Instante de referencia (epoch ms) para la recencia. */
9
+ now: number;
10
+ similarityWeight: number;
11
+ recencyWeight: number;
12
+ accessWeight: number;
13
+ /** Vida media de la recencia (ms). A mayor edad, menor score. */
14
+ recencyHalfLifeMs: number;
15
+ };
16
+ export declare const DEFAULT_RANK_SIGNALS: Omit<RankSignals, "now">;
17
+ /** Score de recencia en `(0, 1]` con decaimiento exponencial por vida media. */
18
+ export declare function recencyScore(record: MemoryRecord, signals: RankSignals): number;
19
+ /**
20
+ * Score de refuerzo por acceso en `[0, 1)`. Solo las preferencias acumulan
21
+ * `accessCount`; el resto de records puntúan 0.
22
+ */
23
+ export declare function accessScore(record: MemoryRecord): number;
24
+ /** Score combinado de un candidato (mayor = más relevante). */
25
+ export declare function scoreCandidate(candidate: RecallCandidate, signals: RankSignals): number;
26
+ /**
27
+ * Ordena los candidatos por score descendente. Desempate **determinista** por
28
+ * `record.id` ascendente para que el resultado sea estable e independiente del
29
+ * orden de entrada.
30
+ */
31
+ export declare function rankRecall(candidates: readonly RecallCandidate[], signals: RankSignals): RecallResult[];
32
+ //# sourceMappingURL=rank.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rank.d.ts","sourceRoot":"","sources":["../../src/memory/rank.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE3E;;;;GAIG;AAEH,MAAM,MAAM,WAAW,GAAG;IACxB,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAIF,eAAO,MAAM,oBAAoB,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAKzD,CAAC;AAUF,gFAAgF;AAChF,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,WAAW,GACnB,MAAM,CAGR;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAKxD;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAC5B,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,WAAW,GACnB,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,SAAS,eAAe,EAAE,EACtC,OAAO,EAAE,WAAW,GACnB,YAAY,EAAE,CAYhB"}
@@ -0,0 +1,30 @@
1
+ import { type RankSignals } from "./rank";
2
+ import { type Embedding, type MemoryRecord, type RecallQuery, type RecallResult } from "./types";
3
+ /**
4
+ * Pipeline de recall **puro**: filtra por scope de dueño y ventana bitemporal,
5
+ * calcula la similitud coseno contra los embeddings provistos y rankea con
6
+ * señales explícitas. Sin I/O: los embeddings (de los records y de la consulta)
7
+ * los aporta la capa de embeddings (M3); aquí todo es determinista.
8
+ */
9
+ /** ¿El record es visible para el `ownerKey` de la consulta? */
10
+ export declare function matchesScope(record: MemoryRecord, query: RecallQuery): boolean;
11
+ export type RecallDeps = {
12
+ /** Embeddings por `record.id`. Los records sin embedding no son recuperables. */
13
+ embeddings: ReadonlyMap<string, Embedding>;
14
+ /** Instante de recall (epoch ms) cuando `query.asOf` es `null`. */
15
+ now: number;
16
+ /** Pesos de ranking; por defecto `DEFAULT_RANK_SIGNALS`. */
17
+ signals?: Omit<RankSignals, "now">;
18
+ };
19
+ /**
20
+ * Recupera los records más relevantes para `queryEmbedding`, respetando scope,
21
+ * `kinds`, ventana temporal (`asOf`), umbral `minSimilarity` y `limit`.
22
+ */
23
+ export declare function recall(records: readonly MemoryRecord[], queryEmbedding: Embedding, query: RecallQuery, deps: RecallDeps): RecallResult[];
24
+ /**
25
+ * Recall **as-of**: recupera lo que el sistema creía en el instante `asOf`
26
+ * (transaction-time). Azúcar sobre `recall` fijando `query.asOf`; útil para
27
+ * auditar el conocimiento histórico ("¿qué sabíamos entonces?").
28
+ */
29
+ export declare function recallAsOf(records: readonly MemoryRecord[], queryEmbedding: Embedding, query: RecallQuery, asOf: number, deps: RecallDeps): RecallResult[];
30
+ //# sourceMappingURL=recall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/memory/recall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,WAAW,EAAc,MAAM,QAAQ,CAAC;AAE5E,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,SAAS,CAAC;AAGjB;;;;;GAKG;AAEH,+DAA+D;AAC/D,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,WAAW,GACjB,OAAO,CAKT;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,iFAAiF;IACjF,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC3C,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ,4DAA4D;IAC5D,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,MAAM,CACpB,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,cAAc,EAAE,SAAS,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,UAAU,GACf,YAAY,EAAE,CAyBhB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,cAAc,EAAE,SAAS,EACzB,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GACf,YAAY,EAAE,CAEhB"}
@@ -0,0 +1,39 @@
1
+ import type { MemoryRecord } from "./types";
2
+ /**
3
+ * Helpers **bitemporales puros** sobre records de memoria. Sin I/O ni reloj: el
4
+ * instante de referencia (`asOf`, epoch ms) siempre se inyecta.
5
+ *
6
+ * Un record es "recuperable" en `asOf` si lo era **según el sistema**
7
+ * (transaction-time: no invalidado antes o en ese instante) **y** era cierto en
8
+ * el mundo modelado (valid-time: dentro de su ventana de validez).
9
+ */
10
+ /**
11
+ * Transaction-time: el sistema seguía creyendo el record en `asOf` (no había sido
12
+ * invalidado todavía). Un `invalidatedAt` posterior a `asOf` sí cuenta como activo
13
+ * (recall "as-of": "qué creíamos entonces").
14
+ */
15
+ export declare function isTransactionActiveAt(record: MemoryRecord, asOf: number): boolean;
16
+ /**
17
+ * Valid-time: el record era cierto en `asOf` (`validFrom <= asOf` y, si hay cierre,
18
+ * `validUntil > asOf`).
19
+ */
20
+ export declare function isValidAt(record: MemoryRecord, asOf: number): boolean;
21
+ /** Recuperable bitemporalmente en `asOf` (ambas dimensiones activas). */
22
+ export declare function isActiveAt(record: MemoryRecord, asOf: number): boolean;
23
+ /** Filtra los records recuperables en `asOf`. Orden de entrada preservado. */
24
+ export declare function filterActive<T extends MemoryRecord>(records: readonly T[], asOf: number): T[];
25
+ /**
26
+ * Fusiona dos ventanas de valid-time al re-afirmar un record: se toma el
27
+ * `validFrom` más temprano y el `validUntil` más amplio (`null` = abierto, gana).
28
+ */
29
+ export declare function coalesceWindow(a: {
30
+ validFrom: number;
31
+ validUntil: number | null;
32
+ }, b: {
33
+ validFrom: number;
34
+ validUntil: number | null;
35
+ }): {
36
+ validFrom: number;
37
+ validUntil: number | null;
38
+ };
39
+ //# sourceMappingURL=temporal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temporal.d.ts","sourceRoot":"","sources":["../../src/memory/temporal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;GAOG;AAEH;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,GACX,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKrE;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtE;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EACjD,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,IAAI,EAAE,MAAM,GACX,CAAC,EAAE,CAEL;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EACnD,CAAC,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAClD;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAOlD"}