@adonis-agora/agent 0.31.0 → 0.33.1

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 (238) hide show
  1. package/CHANGELOG.md +795 -0
  2. package/dist/assets/spa/assets/index-DjIMQOxi.js +9 -0
  3. package/dist/assets/spa/index.html +1 -1
  4. package/dist/providers/agent_provider.d.ts.map +1 -1
  5. package/dist/providers/agent_provider.js +140 -2
  6. package/dist/providers/agent_provider.js.map +1 -1
  7. package/dist/src/agent-deps-factory.d.ts +16 -2
  8. package/dist/src/agent-deps-factory.d.ts.map +1 -1
  9. package/dist/src/agent-deps-factory.js +8 -0
  10. package/dist/src/agent-deps-factory.js.map +1 -1
  11. package/dist/src/agent-deps.d.ts +21 -1
  12. package/dist/src/agent-deps.d.ts.map +1 -1
  13. package/dist/src/agent-deps.js.map +1 -1
  14. package/dist/src/agent-loop.d.ts +228 -9
  15. package/dist/src/agent-loop.d.ts.map +1 -1
  16. package/dist/src/agent-loop.js +1360 -209
  17. package/dist/src/agent-loop.js.map +1 -1
  18. package/dist/src/agent-service.d.ts +27 -0
  19. package/dist/src/agent-service.d.ts.map +1 -1
  20. package/dist/src/agent-service.js +29 -0
  21. package/dist/src/agent-service.js.map +1 -1
  22. package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
  23. package/dist/src/ai-sdk/ai-sdk-model.js +21 -1
  24. package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
  25. package/dist/src/client/sse.d.ts +32 -2
  26. package/dist/src/client/sse.d.ts.map +1 -1
  27. package/dist/src/client/sse.js +45 -2
  28. package/dist/src/client/sse.js.map +1 -1
  29. package/dist/src/define_config.d.ts +41 -7
  30. package/dist/src/define_config.d.ts.map +1 -1
  31. package/dist/src/define_config.js.map +1 -1
  32. package/dist/src/durable/agent-run-workflow.d.ts +10 -11
  33. package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
  34. package/dist/src/durable/agent-run-workflow.js +49 -21
  35. package/dist/src/durable/agent-run-workflow.js.map +1 -1
  36. package/dist/src/durable/durable-agent-runner.d.ts +3 -2
  37. package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
  38. package/dist/src/durable/durable-agent-runner.js +2 -2
  39. package/dist/src/durable/durable-agent-runner.js.map +1 -1
  40. package/dist/src/elicitation.d.ts +207 -0
  41. package/dist/src/elicitation.d.ts.map +1 -0
  42. package/dist/src/elicitation.js +315 -0
  43. package/dist/src/elicitation.js.map +1 -0
  44. package/dist/src/evals/approval-prior.d.ts +58 -0
  45. package/dist/src/evals/approval-prior.d.ts.map +1 -0
  46. package/dist/src/evals/approval-prior.js +82 -0
  47. package/dist/src/evals/approval-prior.js.map +1 -0
  48. package/dist/src/evals/evaluate.d.ts +51 -0
  49. package/dist/src/evals/evaluate.d.ts.map +1 -0
  50. package/dist/src/evals/evaluate.js +76 -0
  51. package/dist/src/evals/evaluate.js.map +1 -0
  52. package/dist/src/evals/governance-sample-source.d.ts +23 -0
  53. package/dist/src/evals/governance-sample-source.d.ts.map +1 -0
  54. package/dist/src/evals/governance-sample-source.js +93 -0
  55. package/dist/src/evals/governance-sample-source.js.map +1 -0
  56. package/dist/src/evals/in-memory-score-store.d.ts +16 -0
  57. package/dist/src/evals/in-memory-score-store.d.ts.map +1 -0
  58. package/dist/src/evals/in-memory-score-store.js +57 -0
  59. package/dist/src/evals/in-memory-score-store.js.map +1 -0
  60. package/dist/src/evals/index.d.ts +15 -0
  61. package/dist/src/evals/index.d.ts.map +1 -0
  62. package/dist/src/evals/index.js +14 -0
  63. package/dist/src/evals/index.js.map +1 -0
  64. package/dist/src/evals/judge.d.ts +30 -0
  65. package/dist/src/evals/judge.d.ts.map +1 -0
  66. package/dist/src/evals/judge.js +53 -0
  67. package/dist/src/evals/judge.js.map +1 -0
  68. package/dist/src/evals/live-scoring.d.ts +42 -0
  69. package/dist/src/evals/live-scoring.d.ts.map +1 -0
  70. package/dist/src/evals/live-scoring.js +103 -0
  71. package/dist/src/evals/live-scoring.js.map +1 -0
  72. package/dist/src/evals/sample-source.d.ts +40 -0
  73. package/dist/src/evals/sample-source.d.ts.map +1 -0
  74. package/dist/src/evals/sample-source.js +33 -0
  75. package/dist/src/evals/sample-source.js.map +1 -0
  76. package/dist/src/evals/score-store.d.ts +54 -0
  77. package/dist/src/evals/score-store.d.ts.map +1 -0
  78. package/dist/src/evals/score-store.js +2 -0
  79. package/dist/src/evals/score-store.js.map +1 -0
  80. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts +28 -0
  81. package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts.map +1 -0
  82. package/dist/src/evals/scorers/answer-relevancy.scorer.js +42 -0
  83. package/dist/src/evals/scorers/answer-relevancy.scorer.js.map +1 -0
  84. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts +22 -0
  85. package/dist/src/evals/scorers/approval-outcome.scorer.d.ts.map +1 -0
  86. package/dist/src/evals/scorers/approval-outcome.scorer.js +60 -0
  87. package/dist/src/evals/scorers/approval-outcome.scorer.js.map +1 -0
  88. package/dist/src/evals/scorers/approval-risk.scorer.d.ts +28 -0
  89. package/dist/src/evals/scorers/approval-risk.scorer.d.ts.map +1 -0
  90. package/dist/src/evals/scorers/approval-risk.scorer.js +54 -0
  91. package/dist/src/evals/scorers/approval-risk.scorer.js.map +1 -0
  92. package/dist/src/evals/scorers/run-completion.scorer.d.ts +18 -0
  93. package/dist/src/evals/scorers/run-completion.scorer.d.ts.map +1 -0
  94. package/dist/src/evals/scorers/run-completion.scorer.js +55 -0
  95. package/dist/src/evals/scorers/run-completion.scorer.js.map +1 -0
  96. package/dist/src/evals/summarize.d.ts +44 -0
  97. package/dist/src/evals/summarize.d.ts.map +1 -0
  98. package/dist/src/evals/summarize.js +87 -0
  99. package/dist/src/evals/summarize.js.map +1 -0
  100. package/dist/src/evals/types.d.ts +81 -0
  101. package/dist/src/evals/types.d.ts.map +1 -0
  102. package/dist/src/evals/types.js +15 -0
  103. package/dist/src/evals/types.js.map +1 -0
  104. package/dist/src/history-window.d.ts +50 -11
  105. package/dist/src/history-window.d.ts.map +1 -1
  106. package/dist/src/history-window.js +84 -12
  107. package/dist/src/history-window.js.map +1 -1
  108. package/dist/src/index.d.ts +9 -2
  109. package/dist/src/index.d.ts.map +1 -1
  110. package/dist/src/index.js +9 -2
  111. package/dist/src/index.js.map +1 -1
  112. package/dist/src/mcp/server.d.ts +8 -0
  113. package/dist/src/mcp/server.d.ts.map +1 -1
  114. package/dist/src/mcp/server.js +27 -1
  115. package/dist/src/mcp/server.js.map +1 -1
  116. package/dist/src/mcp-client/importer.d.ts +75 -0
  117. package/dist/src/mcp-client/importer.d.ts.map +1 -0
  118. package/dist/src/mcp-client/importer.js +161 -0
  119. package/dist/src/mcp-client/importer.js.map +1 -0
  120. package/dist/src/mcp-client/index.d.ts +9 -0
  121. package/dist/src/mcp-client/index.d.ts.map +1 -0
  122. package/dist/src/mcp-client/index.js +8 -0
  123. package/dist/src/mcp-client/index.js.map +1 -0
  124. package/dist/src/mcp-client/options.d.ts +99 -0
  125. package/dist/src/mcp-client/options.d.ts.map +1 -0
  126. package/dist/src/mcp-client/options.js +2 -0
  127. package/dist/src/mcp-client/options.js.map +1 -0
  128. package/dist/src/mcp-client/tool-input.d.ts +39 -0
  129. package/dist/src/mcp-client/tool-input.d.ts.map +1 -0
  130. package/dist/src/mcp-client/tool-input.js +61 -0
  131. package/dist/src/mcp-client/tool-input.js.map +1 -0
  132. package/dist/src/mcp-client/tool-kind.d.ts +37 -0
  133. package/dist/src/mcp-client/tool-kind.d.ts.map +1 -0
  134. package/dist/src/mcp-client/tool-kind.js +20 -0
  135. package/dist/src/mcp-client/tool-kind.js.map +1 -0
  136. package/dist/src/mcp-client/tool-name.d.ts +22 -0
  137. package/dist/src/mcp-client/tool-name.d.ts.map +1 -0
  138. package/dist/src/mcp-client/tool-name.js +35 -0
  139. package/dist/src/mcp-client/tool-name.js.map +1 -0
  140. package/dist/src/mcp-client/tool-source.d.ts +75 -0
  141. package/dist/src/mcp-client/tool-source.d.ts.map +1 -0
  142. package/dist/src/mcp-client/tool-source.js +244 -0
  143. package/dist/src/mcp-client/tool-source.js.map +1 -0
  144. package/dist/src/mcp-client/transient.d.ts +28 -0
  145. package/dist/src/mcp-client/transient.d.ts.map +1 -0
  146. package/dist/src/mcp-client/transient.js +126 -0
  147. package/dist/src/mcp-client/transient.js.map +1 -0
  148. package/dist/src/mcp-client/unsafe-regex.d.ts +23 -0
  149. package/dist/src/mcp-client/unsafe-regex.d.ts.map +1 -0
  150. package/dist/src/mcp-client/unsafe-regex.js +194 -0
  151. package/dist/src/mcp-client/unsafe-regex.js.map +1 -0
  152. package/dist/src/memory.d.ts +448 -0
  153. package/dist/src/memory.d.ts.map +1 -0
  154. package/dist/src/memory.js +338 -0
  155. package/dist/src/memory.js.map +1 -0
  156. package/dist/src/processors.d.ts +134 -0
  157. package/dist/src/processors.d.ts.map +1 -0
  158. package/dist/src/processors.js +215 -0
  159. package/dist/src/processors.js.map +1 -0
  160. package/dist/src/rag/index.d.ts +1 -1
  161. package/dist/src/rag/index.d.ts.map +1 -1
  162. package/dist/src/rag/index.js +1 -1
  163. package/dist/src/rag/index.js.map +1 -1
  164. package/dist/src/rag/pg-vector-store.d.ts +41 -0
  165. package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
  166. package/dist/src/rag/pg-vector-store.js +93 -15
  167. package/dist/src/rag/pg-vector-store.js.map +1 -1
  168. package/dist/src/replay-integrity.d.ts +17 -0
  169. package/dist/src/replay-integrity.d.ts.map +1 -0
  170. package/dist/src/replay-integrity.js +19 -0
  171. package/dist/src/replay-integrity.js.map +1 -0
  172. package/dist/src/runners/inline-agent-runner.d.ts +33 -7
  173. package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
  174. package/dist/src/runners/inline-agent-runner.js +113 -27
  175. package/dist/src/runners/inline-agent-runner.js.map +1 -1
  176. package/dist/src/skills.d.ts +291 -0
  177. package/dist/src/skills.d.ts.map +1 -0
  178. package/dist/src/skills.js +0 -0
  179. package/dist/src/skills.js.map +1 -0
  180. package/dist/src/spi/agent-runner.d.ts +20 -6
  181. package/dist/src/spi/agent-runner.d.ts.map +1 -1
  182. package/dist/src/spi/agent-store.d.ts +53 -0
  183. package/dist/src/spi/agent-store.d.ts.map +1 -1
  184. package/dist/src/spi/governance-queries.d.ts +5 -0
  185. package/dist/src/spi/governance-queries.d.ts.map +1 -1
  186. package/dist/src/spi/history-window.d.ts +64 -10
  187. package/dist/src/spi/history-window.d.ts.map +1 -1
  188. package/dist/src/spi/model-provider.d.ts +18 -0
  189. package/dist/src/spi/model-provider.d.ts.map +1 -1
  190. package/dist/src/spi/processors.d.ts +161 -0
  191. package/dist/src/spi/processors.d.ts.map +1 -0
  192. package/dist/src/spi/processors.js +57 -0
  193. package/dist/src/spi/processors.js.map +1 -0
  194. package/dist/src/spi/token-stream-sink.d.ts +43 -0
  195. package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
  196. package/dist/src/spi/token-stream-sink.js +17 -1
  197. package/dist/src/spi/token-stream-sink.js.map +1 -1
  198. package/dist/src/sse.d.ts +5 -2
  199. package/dist/src/sse.d.ts.map +1 -1
  200. package/dist/src/sse.js +11 -2
  201. package/dist/src/sse.js.map +1 -1
  202. package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
  203. package/dist/src/stores/lucid-governance-queries.js +3 -0
  204. package/dist/src/stores/lucid-governance-queries.js.map +1 -1
  205. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  206. package/dist/src/stores/lucid-schema.js +15 -0
  207. package/dist/src/stores/lucid-schema.js.map +1 -1
  208. package/dist/src/stores/lucid.d.ts +11 -3
  209. package/dist/src/stores/lucid.d.ts.map +1 -1
  210. package/dist/src/stores/lucid.js +65 -0
  211. package/dist/src/stores/lucid.js.map +1 -1
  212. package/dist/src/structured-output.d.ts +57 -0
  213. package/dist/src/structured-output.d.ts.map +1 -0
  214. package/dist/src/structured-output.js +80 -0
  215. package/dist/src/structured-output.js.map +1 -0
  216. package/dist/src/testing/fake-model-provider.d.ts +8 -4
  217. package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
  218. package/dist/src/testing/fake-model-provider.js +6 -9
  219. package/dist/src/testing/fake-model-provider.js.map +1 -1
  220. package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
  221. package/dist/src/testing/in-memory-governance-queries.js +1 -0
  222. package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
  223. package/dist/src/testing/in-memory-store.d.ts +4 -3
  224. package/dist/src/testing/in-memory-store.d.ts.map +1 -1
  225. package/dist/src/testing/in-memory-store.js +13 -7
  226. package/dist/src/testing/in-memory-store.js.map +1 -1
  227. package/dist/src/testing/index.d.ts +1 -1
  228. package/dist/src/testing/index.d.ts.map +1 -1
  229. package/dist/src/testing/index.js.map +1 -1
  230. package/dist/src/tool-registry.d.ts +9 -0
  231. package/dist/src/tool-registry.d.ts.map +1 -1
  232. package/dist/src/tool-registry.js +11 -0
  233. package/dist/src/tool-registry.js.map +1 -1
  234. package/dist/src/types.d.ts +70 -2
  235. package/dist/src/types.d.ts.map +1 -1
  236. package/package.json +38 -24
  237. package/skills/agent-personas-agents/SKILL.md +16 -12
  238. package/dist/assets/spa/assets/index-3Q2m5_Ax.js +0 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsafe-regex.js","sourceRoot":"","sources":["../../../src/mcp-client/unsafe-regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkBH,MAAM,UAAU,GAAG,iCAAiC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,aAAa;IAGY,OAAO;IAF5B,KAAK,GAAG,CAAC,CAAC;IAElB,YAA6B,OAAe;uBAAf,OAAO;IAAW,CAAC;IAEhD,KAAK;QACH,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACzC,qFAAqF;QACrF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;QACj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AK,SAAS,EAAE,CAAC;gBAC5B,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,448 @@
1
+ /**
2
+ * Memory: what the assistant has concluded about a person or an organisation, carried across turns
3
+ * and across threads.
4
+ *
5
+ * HOW A READER TELLS IT FROM RAG. Retrieval answers "what do the documents say"; memory answers
6
+ * "what did I decide about you". A passage is content a person authored and can correct at its
7
+ * source, and it is cited. A memory has no source to go and fix: it is the agent's own inference,
8
+ * which is why every record carries an {@link MemoryOrigin} (who wrote it, in which conversation),
9
+ * why the block tells the model to treat it as fallible, and why `forget` is a REQUIRED method on
10
+ * the provider rather than an optional one. A wrong document is a content problem. A wrong memory is
11
+ * the assistant being confidently wrong about someone with nobody aware it is there, so the whole
12
+ * design is arranged around making it visible and removable.
13
+ *
14
+ * WHAT IT COSTS THE PROMPT. One line per memory, capped by `maxMemories`, and each line capped by
15
+ * `maxFactChars` at WRITE time — so the block a turn can carry is the product of two numbers an
16
+ * operator sets, rather than however much the model felt like writing down. Unlike a skill, a memory
17
+ * has no body/catalog split: a fact that cannot be stated in a line is not a memory, it is a
18
+ * document, and documents are retrieval's job.
19
+ *
20
+ * WHAT IT IS NOT: recall over a TRANSCRIPT. Searching what was said earlier is retrieval, and this
21
+ * library already has `Retriever`/`Reranker` for that.
22
+ *
23
+ * RECALL OVER THE MEMORIES THEMSELVES IS A DIFFERENT QUESTION, and it is answered here. The prompt
24
+ * budget must be bounded; the store has no reason to be. A person accumulates preferences over
25
+ * months and an organisation publishes facts for everyone in it, so the applicable set outgrows
26
+ * `maxMemories` quickly — and once it does, WHICH of them the block carries is a decision somebody
27
+ * has to make. Making it by scope starves the widest scopes first, which is precisely backwards: the
28
+ * facts that apply to the most people are the ones nobody sees. So a provider MAY supply
29
+ * {@link MemoryProvider.search}, and where it does, the block is filled by relevance to the turn
30
+ * (see {@link resolveMemoryDigest}) with scope still a hard filter and never a ranking signal.
31
+ * `maxMemories` then means "how many matter right now" rather than "how many a person may have".
32
+ */
33
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
34
+ import { type ScopeContext, type ScopeResolver } from './skills.js';
35
+ import type { Actor, ToolDefinition } from './types.js';
36
+ /** Who wrote a memory, and out of what. Kept so a person reading it back can ask "says who?". */
37
+ export interface MemoryOrigin {
38
+ /** `'agent'` — a turn concluded it. `'human'` — a person wrote it in the host's own console. */
39
+ author: 'agent' | 'human';
40
+ /**
41
+ * The conversation the conclusion was drawn in. MAY name a thread whose messages the history
42
+ * ceiling has since dropped: a memory deliberately outlives its source, so this is a pointer that
43
+ * is allowed to dangle, and a read-back that cannot resolve it says so rather than hiding the row.
44
+ */
45
+ threadId?: string;
46
+ runId?: string;
47
+ actorRef?: string;
48
+ }
49
+ /** One thing the assistant believes, at one scope. */
50
+ export interface MemoryRecord {
51
+ /** The host's row id — what `forget` takes and what a read-back offers a delete button for. */
52
+ id: string;
53
+ /**
54
+ * What the fact is ABOUT. The handle that makes a conflict mechanically detectable: two memories
55
+ * sharing a key at different scopes are one question answered twice, and the narrower wins. A
56
+ * keyless store could only ever hope its facts did not contradict each other.
57
+ */
58
+ key: string;
59
+ /** The fact itself, as the model reads it. */
60
+ text: string;
61
+ /** The opaque scope token it is held at — see `ScopeResolver` in `skills.ts`. */
62
+ scope: string;
63
+ origin: MemoryOrigin;
64
+ /** ISO-8601, so the ceiling can keep the newest with a string comparison it can do purely. */
65
+ updatedAt: string;
66
+ /**
67
+ * Always-on: this fact is in the block whether or not the turn is about it. The difference between
68
+ * working memory and recall, drawn per record — "they report on the calendar year" must not depend
69
+ * on the turn mentioning dates, while "they prefer the shorter runway" can wait until it comes up.
70
+ *
71
+ * A PROPERTY OF THE ROW, NOT OF A WRITE. This library reads it and never sets it, the same way it
72
+ * never mints an `id`: an agent deciding its own conclusions are always-on is an agent deciding
73
+ * how much of every future prompt it gets, so pinning is an operator's act in the host's console.
74
+ * That is also why {@link StoreMemoryInput} carries no `pinned` — the `remember` tool has no
75
+ * parameter to refuse. A host whose upsert drops the flag has silently unpinned the row; preserve
76
+ * it across an upsert on (`scope`, `key`).
77
+ */
78
+ pinned?: boolean;
79
+ }
80
+ /** A same-key memory a narrower scope outranked, with the value it holds. */
81
+ export interface OverriddenMemory {
82
+ scope: string;
83
+ text: string;
84
+ /**
85
+ * Who asserted the beaten value. Travels because precedence is blind to it: an agent's own
86
+ * inference at `actor:` outranks an administrator's published policy at `global`, and an agent
87
+ * that knew only that a wider value existed could not tell the two apart — one is a stale guess,
88
+ * the other is what the organisation decided.
89
+ */
90
+ author: MemoryOrigin['author'];
91
+ }
92
+ /** One memory as the model and a read-back both meet it. */
93
+ export interface MemoryDigestEntry extends MemoryRecord {
94
+ /**
95
+ * Same-key memories this one outranks, widest last. Present ONLY where something was outranked.
96
+ *
97
+ * Carries the beaten TEXT, which is where memory departs from a skill's `shadows`. A skill only
98
+ * has to say which scope it beat — the agent follows one procedure either way. A memory is a
99
+ * VALUE, and an agent that knows only that a wider value existed cannot tell the user what the
100
+ * difference is; it can only choose, silently, which is the thing this is meant to prevent.
101
+ */
102
+ overrides?: OverriddenMemory[];
103
+ }
104
+ /** What a turn resolved — journaled whole, so its prompt is reconstructible from its journal alone. */
105
+ export interface MemoryDigest {
106
+ /** The scope tokens this turn drew from, most specific first. */
107
+ scopes: string[];
108
+ /** The memories in the block, most specific first then by key. */
109
+ entries: MemoryDigestEntry[];
110
+ /**
111
+ * Applicable memories `maxMemories` left out. Non-zero means the block is not the whole truth —
112
+ * and under {@link recalled} it counts what the SEARCH offered and the ceiling dropped, not what
113
+ * the store holds, because nothing asked the store for a total.
114
+ */
115
+ omitted: number;
116
+ /**
117
+ * Of {@link omitted}, how many were ALWAYS-ON. Reported separately because it means something else
118
+ * entirely: ordinary omission is the budget doing its job, while an always-on memory the ceiling
119
+ * dropped is a deployment's own standing policies having silently stopped reaching any prompt.
120
+ * Non-zero is a misconfiguration — more was pinned than the block holds — and the fix is to unpin
121
+ * something or raise `maxMemories`, not to wait for it to come back.
122
+ */
123
+ pinnedOmitted: number;
124
+ /**
125
+ * Whether the entries were selected by relevance to this turn rather than read whole. The model is
126
+ * told (see {@link buildMemoryBlock}), because a partial set read as a whole one turns an absence
127
+ * into evidence: "you never told me that" about a fact it simply was not shown.
128
+ *
129
+ * Optional so a digest journaled before recall existed reads back as the plain scoped read it was.
130
+ */
131
+ recalled?: boolean;
132
+ }
133
+ /** What a write asks the host to store. `id` and `updatedAt` are the host's to mint. */
134
+ export interface MemoryFact {
135
+ key: string;
136
+ text: string;
137
+ scope: string;
138
+ origin: MemoryOrigin;
139
+ }
140
+ /** Arguments to {@link MemoryProvider.list}. */
141
+ export interface ListMemoriesInput {
142
+ /** The scope tokens that apply to this turn, most specific first. */
143
+ scopes: readonly string[];
144
+ ctx: ScopeContext;
145
+ }
146
+ /**
147
+ * Arguments to {@link MemoryProvider.search}.
148
+ *
149
+ * `scopes` GATES, AND IT GATES FIRST. A search that ranks before it filters is a cross-tenant leak
150
+ * wearing a relevance score: the nearest neighbour to "what is our rollback policy" is another
151
+ * base's rollback policy. Filter in the query, not after it. Records returned outside `scopes` are
152
+ * dropped rather than trusted, so a mistake here costs throughput rather than privacy — but the
153
+ * drop is a backstop, not the boundary.
154
+ */
155
+ export interface SearchMemoriesInput {
156
+ /** The scope tokens that apply to this turn, most specific first. A HARD FILTER. */
157
+ scopes: readonly string[];
158
+ /** What this turn is about. Never blank — a blank query is served by `list` instead. */
159
+ query: string;
160
+ /**
161
+ * At most this many distinct KEYS may be ranked in, which is the block's own unit: precedence
162
+ * resolves a key to one line, so `limit` keys is `limit` lines. Pinned records are returned in
163
+ * addition and do not count against it.
164
+ */
165
+ limit: number;
166
+ ctx: ScopeContext;
167
+ }
168
+ /** Arguments to {@link MemoryProvider.forget}. */
169
+ export interface ForgetMemoryInput {
170
+ id: string;
171
+ ctx: ScopeContext;
172
+ }
173
+ /**
174
+ * Arguments to {@link MemoryProvider.write}. An object rather than positional arguments because
175
+ * `key`, `text` and `scope` are all strings: transposed, a positional call compiles clean and writes
176
+ * a fact whose key is its value, at a scope nobody meant.
177
+ */
178
+ export interface StoreMemoryInput extends MemoryFact {
179
+ ctx: ScopeContext;
180
+ }
181
+ /**
182
+ * Where memories live. The host owns the rows, for the same reason it owns skill rows: the axes a
183
+ * deployment scopes by, the console that edits them and the audit trail are all the host's, and a
184
+ * table this package created at boot would put a consumer's migrations in the path of the schema
185
+ * heal that manages the `agent_*` tables.
186
+ *
187
+ * `forget` is REQUIRED, unlike `write`. A deployment may reasonably populate memory from its own
188
+ * pipeline and offer the agent no write tool; no deployment may reasonably hold conclusions about a
189
+ * person that the person cannot have deleted. Making it optional would make forgetting a wiring
190
+ * choice, and it is not one.
191
+ */
192
+ export interface MemoryProvider {
193
+ /**
194
+ * Every memory visible at `scopes`, in any order — this library resolves precedence and the
195
+ * ceiling. Asked on EVERY turn, so keep it cheap. A provider MAY return records outside `scopes`;
196
+ * they are dropped rather than trusted, so a filter bug in a host cannot widen what an actor sees.
197
+ */
198
+ list(input: ListMemoriesInput): MemoryRecord[] | Promise<MemoryRecord[]>;
199
+ /** Delete one record by id. `false` where there was nothing by that id to delete. */
200
+ forget(input: ForgetMemoryInput): boolean | Promise<boolean>;
201
+ /**
202
+ * Upsert on (`scope`, `key`) and return the stored record. Omit to serve memory read-only — the
203
+ * `remember` tool is then never offered, and a turn's tool list is the same on every pod.
204
+ */
205
+ write?(input: StoreMemoryInput): MemoryRecord | Promise<MemoryRecord>;
206
+ /**
207
+ * The memories worth putting in front of a turn about `query`, MOST RELEVANT FIRST. Omit and every
208
+ * turn is served by {@link list} — a deployment with twenty memories must not have to stand up an
209
+ * index to keep working, and one with two thousand uses whatever it already runs (pgvector, a
210
+ * full-text index, a hybrid service). The host owns the index for the same reason it owns the
211
+ * rows.
212
+ *
213
+ * THREE CLAUSES, and the third is the one that is easy to miss:
214
+ *
215
+ * 1. Filter to `scopes` before ranking — see {@link SearchMemoriesInput}.
216
+ * 2. Rank the KEYS visible at those scopes and take the best `limit` of them.
217
+ * 3. Return EVERY record sharing a returned key, plus every `pinned` record at those scopes.
218
+ *
219
+ * Clause three is what keeps precedence intact. Precedence resolves a conflict between two records
220
+ * at one key, narrower winning and the beaten value riding along; a search that returned the
221
+ * `global` half of a conflict and not the `actor:` half would render the org default as the answer
222
+ * — the exact failure memory exists to prevent, and one nothing downstream can detect. It is one
223
+ * query either way:
224
+ *
225
+ * ```sql
226
+ * SELECT * FROM agent_memory
227
+ * WHERE scope IN (:scopes)
228
+ * AND (pinned OR key IN (SELECT key FROM agent_memory
229
+ * WHERE scope IN (:scopes)
230
+ * ORDER BY embedding <=> :queryVector
231
+ * LIMIT :limit))
232
+ * ```
233
+ */
234
+ search?(input: SearchMemoriesInput): MemoryRecord[] | Promise<MemoryRecord[]>;
235
+ }
236
+ /**
237
+ * How many memories the block carries. The same ceiling shape as `maxSkills`, and for the same
238
+ * reason: a prompt that grows with how much the agent has written down is a prompt whose cost nobody
239
+ * set. A budget on the PROMPT and never on the store — with a provider that can
240
+ * {@link MemoryProvider.search}, it is how many matter right now rather than how many a person may
241
+ * have.
242
+ */
243
+ export declare const DEFAULT_MAX_MEMORIES = 20;
244
+ /**
245
+ * How long one memory may be, enforced when it is WRITTEN rather than when it is rendered. Enforcing
246
+ * it at render time would make the prompt disagree with the store; enforcing it at write time makes
247
+ * the block's whole ceiling a multiplication an operator can do — `maxMemories × maxFactChars` — and
248
+ * pushes back on the model at the moment it is writing an essay instead of a fact.
249
+ */
250
+ export declare const DEFAULT_MAX_FACT_CHARS = 240;
251
+ /** How a turn reaches its memory. See `AgentLoopDeps.memory`. */
252
+ export interface MemoryConfig {
253
+ provider: MemoryProvider;
254
+ /** Undefined → `defaultScopeResolver`: the actor's own, their tenant's, the deployment's. */
255
+ scopes?: ScopeResolver;
256
+ /** Undefined → {@link DEFAULT_MAX_MEMORIES}. Always-on memories are taken from it first. */
257
+ maxMemories?: number;
258
+ /** Undefined → {@link DEFAULT_MAX_FACT_CHARS}. */
259
+ maxFactChars?: number;
260
+ }
261
+ /**
262
+ * Resolve a provider's records against an ordered scope list: most specific wins a key, and the
263
+ * losers' values are carried rather than discarded.
264
+ *
265
+ * Pure, and separately exported, because the loop and the read-back endpoint must reach the same
266
+ * answer — a person has to be shown what the model was shown, or "see what it believes about you"
267
+ * means nothing.
268
+ */
269
+ /** Arguments to {@link resolveMemoryDigest}. */
270
+ export interface ResolveMemoryDigestInput {
271
+ records: readonly MemoryRecord[];
272
+ /** The scope tokens that apply, most specific first — the precedence order. */
273
+ scopes: readonly string[];
274
+ /** Undefined → {@link DEFAULT_MAX_MEMORIES}. */
275
+ maxMemories?: number;
276
+ /**
277
+ * Whether `records` arrived most-relevant-first, from {@link MemoryProvider.search}. A key's rank
278
+ * is its best-placed record's. Undefined/false → the ceiling selects by scope and recency, which
279
+ * is the right order only while nothing is being starved.
280
+ */
281
+ ranked?: boolean;
282
+ }
283
+ export declare function resolveMemoryDigest({ records, scopes, maxMemories, ranked, }: ResolveMemoryDigestInput): Omit<MemoryDigest, 'scopes' | 'recalled'>;
284
+ /** Arguments to {@link offerMemories}. */
285
+ export interface OfferMemoriesInput {
286
+ config: MemoryConfig;
287
+ ctx: ScopeContext;
288
+ /**
289
+ * What this turn is about — the loop passes the user's own message, and nothing else. Given, and
290
+ * with a provider that has an index, the block is filled by relevance to it. Absent, the scope is
291
+ * read whole: that is what the read-back endpoint wants, since a person must be shown every belief
292
+ * held about them rather than the slice one turn happened to need.
293
+ */
294
+ query?: string;
295
+ }
296
+ /**
297
+ * Resolve the scopes and the digest for one turn. Called INSIDE the loop's `memory:digest` step, and
298
+ * that placement is the whole of its determinism: a search is the most re-derivable thing in this
299
+ * library — the index moves, a neighbour is written, embeddings are recomputed — so its result has
300
+ * to be part of the checkpoint every replay reads back, never something a replaying process asks
301
+ * again.
302
+ */
303
+ export declare function offerMemories({ config, ctx, query, }: OfferMemoriesInput): Promise<MemoryDigest>;
304
+ /**
305
+ * The block as the model reads it.
306
+ *
307
+ * THREE THINGS IT HAS TO DO THAT A SKILLS CATALOG DOES NOT.
308
+ *
309
+ * It must frame each note by WHO ASSERTED IT, which is why there are two sections rather than one
310
+ * sentence over the whole list. An unlabelled fact in a system prompt reads with the authority of an
311
+ * instruction, and the hazard of an agent's own inference is exactly that authority — so those are
312
+ * hedged. But a memory an administrator published for a whole organisation is not the agent's guess,
313
+ * and telling the model to "prefer what the user says now" about it hands any user an override of
314
+ * their organisation's policy by asserting the opposite. `MemoryOrigin.author` is the axis, and it
315
+ * is the only one that matters here: scope says who a fact applies to, not who decided it.
316
+ *
317
+ * Where a narrower scope won, it must print the value it beat, so the model can tell the user their
318
+ * setting differs from the org's instead of quietly applying one of them.
319
+ *
320
+ * And a block that is a SELECTION must say so. A model reading a partial set as a whole one turns an
321
+ * absence into evidence — "you never told me that" about a fact it simply was not shown.
322
+ */
323
+ /** Arguments to {@link buildMemoryBlock}. */
324
+ export interface BuildMemoryBlockInput {
325
+ entries: readonly MemoryDigestEntry[];
326
+ /** Whether this deployment offers `remember` — the block names the tool only where it exists. */
327
+ writable: boolean;
328
+ /** Whether applicable memories are missing from `entries` — the ceiling bit, or recall selected. */
329
+ partial: boolean;
330
+ }
331
+ export declare function buildMemoryBlock({ entries, writable, partial }: BuildMemoryBlockInput): string;
332
+ /** The reserved name of the built-in memory-writing tool. */
333
+ export declare const REMEMBER_TOOL_NAME = "remember";
334
+ /** What the model passes to the `remember` tool. */
335
+ export interface RememberToolInput {
336
+ key: string;
337
+ fact: string;
338
+ }
339
+ /**
340
+ * The `remember` tool's input schema. Hand-written for the same reason `askInputSchema` and
341
+ * `skillInputSchema` are: core depends on no validator and has to publish a JSON Schema a provider
342
+ * can constrain generation against.
343
+ *
344
+ * THERE IS NO SCOPE PARAMETER, and that is the enforcement rather than a simplification. An agent
345
+ * may only ever write the actor it is running for (see {@link memoryWriteVerdict}), so a scope
346
+ * argument could only ever be a request that gets refused — and a refusable request is one a model
347
+ * will keep making, and one a future reader will be tempted to make grantable.
348
+ */
349
+ export declare const rememberInputSchema: StandardSchemaV1<unknown, RememberToolInput>;
350
+ export declare const REMEMBER_TOOL_DESCRIPTION = "Record one durable fact about this user under a key, so later conversations start knowing it. For things that will still be true another day \u2014 how they work, what their organisation requires, a correction they made. Not for what this conversation is about, and not for anything you were not told or could not reasonably infer. The user can read and delete everything you record here.";
351
+ /**
352
+ * The `remember` tool as the model sees it. NOT a `ToolSpec` and never registered, exactly like
353
+ * `ask` and `skill`: it has no handler, because the loop serves it against the digest the journal
354
+ * holds. Keeping it out of the `ToolRegistry` is also what keeps its kind off a process-local
355
+ * lookup — see `claimToolCall`.
356
+ */
357
+ export declare function rememberToolDefinition(): ToolDefinition;
358
+ /** Who is trying to write a memory. */
359
+ export interface MemoryAuthor {
360
+ /**
361
+ * `'human'` is a person acting through a UI; `'agent'` is anything else — a turn, a tool, a batch
362
+ * job. The distinction is the whole of rule three below, so it is not inferable and has to be
363
+ * stated by the caller.
364
+ */
365
+ kind: 'human' | 'agent';
366
+ actorRef?: string;
367
+ }
368
+ /** A request to write a memory at a scope. */
369
+ export interface MemoryWriteRequest {
370
+ scope: string;
371
+ actor: Actor;
372
+ /** The actor's resolved scopes, most specific first — the same list the turn drew its digest from. */
373
+ scopes: readonly string[];
374
+ author: MemoryAuthor;
375
+ /**
376
+ * The host's own answer to "may this person administer that scope". This library cannot know it,
377
+ * and inventing an answer would be a second, weaker authorization model next to the host's real
378
+ * one. Undefined/false → a wider scope is refused.
379
+ */
380
+ elevated?: boolean;
381
+ }
382
+ export type MemoryVerdict = {
383
+ allowed: true;
384
+ } | {
385
+ allowed: false;
386
+ reason: string;
387
+ };
388
+ /**
389
+ * May this author write a memory at this scope?
390
+ *
391
+ * The same four rules as `skillWriteVerdict`, deliberately duplicated rather than shared: they are
392
+ * the same rules about two different things, and folding them into one function would mean a future
393
+ * change to how skills are authored silently changing who may edit what the assistant believes about
394
+ * a person. Rule three is the one that matters, and it bites harder here than it does for skills:
395
+ *
396
+ * 1. You may only write into a scope you are yourself in.
397
+ * 2. Your OWN scope is yours. A memory at `actor:<you>` affects exactly one prompt — your own.
398
+ * 3. NOTHING BUT A HUMAN MAY WRITE ABOVE ITS OWN SCOPE, whatever `elevated` says. A skill an agent
399
+ * could publish at `tenant:` is a procedure anyone in the tenant can edit by talking to the
400
+ * assistant; a MEMORY it could publish there is a fact everyone in the tenant is then answered
401
+ * from, with no document to inspect and nobody aware it was written. An agent that has genuinely
402
+ * learned something the organisation should know proposes it; a person publishes it.
403
+ * 4. A human writing above their own scope needs the host to say so (`elevated`).
404
+ */
405
+ export declare function memoryWriteVerdict(request: MemoryWriteRequest): MemoryVerdict;
406
+ /**
407
+ * May this actor delete this memory?
408
+ *
409
+ * Narrower than the write rule on purpose, and it takes no `elevated` flag. Deleting what the
410
+ * assistant believes about YOU needs no permission from anyone — that is the point of the read-back
411
+ * — so the endpoint that serves it must not be able to ask a host a question it might answer no to.
412
+ * Deleting what it believes about a tenant is an administrative act on shared state, which belongs
413
+ * in the host's console with the same elevation a write there needs.
414
+ */
415
+ /** A request to delete one memory. */
416
+ export interface MemoryForgetRequest {
417
+ record: Pick<MemoryRecord, 'scope'>;
418
+ actor: Actor;
419
+ }
420
+ export declare function memoryForgetVerdict({ record, actor }: MemoryForgetRequest): MemoryVerdict;
421
+ /** What a `remember` call resolved to — the stored record, or why nothing was stored. */
422
+ export type MemoryWriteOutcome = {
423
+ ok: true;
424
+ record: MemoryRecord;
425
+ } | {
426
+ ok: false;
427
+ error: string;
428
+ };
429
+ /**
430
+ * Serve one `remember` call against the digest THIS TURN resolved.
431
+ *
432
+ * The digest's `scopes` are the authorization boundary, not the resolver: they came out of the
433
+ * `memory:digest` checkpoint, so a write is checked against the scopes the run recorded rather than
434
+ * the ones a replaying process's resolver would produce now. A membership table edited mid-run
435
+ * cannot retroactively widen — or narrow — what a turn already in flight is allowed to write.
436
+ */
437
+ /** Arguments to {@link writeMemory}. */
438
+ export interface WriteMemoryInput {
439
+ config: MemoryConfig;
440
+ /** The digest THIS TURN journaled — the authorization boundary, never a fresh resolution. */
441
+ digest: MemoryDigest;
442
+ /** The `remember` call as the model made it. */
443
+ call: RememberToolInput;
444
+ ctx: ScopeContext;
445
+ runId: string;
446
+ }
447
+ export declare function writeMemory({ config, digest, call, ctx, runId, }: WriteMemoryInput): Promise<MemoryWriteOutcome>;
448
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExD,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,gGAAgG;IAChG,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,+FAA+F;IAC/F,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAC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