@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
@@ -1,5 +1,16 @@
1
- import type { HistoryWindow, HistoryWindowContext } from './spi/history-window.js';
1
+ import type { HistorySelection, HistoryWindow, HistoryWindowContext } from './spi/history-window.js';
2
+ import type { ModelProvider } from './spi/model-provider.js';
2
3
  import type { ModelMessage } from './types.js';
4
+ /**
5
+ * Rough token count for one message: ~4 characters per token over its content and its serialized
6
+ * tool calls/results, plus a small per-message envelope allowance for the role and part framing.
7
+ *
8
+ * A heuristic on purpose. A real tokenizer is model-specific and would drag a provider dependency
9
+ * into the package, while a budget only has to be approximately right to keep a thread clear of the
10
+ * provider's hard limit — and it must be a PURE function, because it runs inside `select`. Pass
11
+ * `estimate` to {@link SlidingWindowHistory} to substitute a real one.
12
+ */
13
+ export declare function estimateMessageTokens(message: ModelMessage): number;
3
14
  export interface SlidingWindowHistoryOptions {
4
15
  /**
5
16
  * Max messages kept, counting from the most recent. Undefined → 40. The just-appended user
@@ -7,21 +18,49 @@ export interface SlidingWindowHistoryOptions {
7
18
  * `maxMessages >= 1` keeps it.
8
19
  */
9
20
  maxMessages?: number;
21
+ /**
22
+ * Keep the newest messages whose estimated tokens fit this budget. Undefined → no token limit,
23
+ * so the message count alone decides. Both limits apply when both are set.
24
+ */
25
+ maxTokens?: number;
26
+ /** Substitute for {@link estimateMessageTokens}. Must be pure — it runs inside `select`. */
27
+ estimate?: (message: ModelMessage) => number;
28
+ /**
29
+ * Folds the dropped messages into a leading summary instead of discarding them. Undefined → they
30
+ * are simply gone. {@link summarizeWithModel} is the built-in.
31
+ */
32
+ summarize?: NonNullable<HistoryWindow['summarize']>;
10
33
  }
11
34
  /**
12
- * Default {@link HistoryWindow}: keeps only the most recent `maxMessages` messages, dropping the
13
- * rest with no summary. Each persisted message is self-contained (a tool call's result is never a
14
- * separate message the loop hands the model — see `agent-loop.ts`'s mapping of `StoredMessage` — so
15
- * there is no cross-message pairing to preserve), so a plain wholesale drop of the oldest messages
16
- * is always safe.
35
+ * Default {@link HistoryWindow}: keeps the newest messages that fit a message count and/or a token
36
+ * budget, and (optionally) folds the rest into a summary. Whichever limit cuts more wins.
17
37
  *
18
- * A deployment that wants dropped history summarized instead of discarded should implement
19
- * {@link HistoryWindow} directly (e.g. call a model over the dropped slice and prepend the recap as
20
- * a synthetic message) rather than extend this class.
38
+ * A naive slice is safe because each persisted message is self-contained: a tool call's result is
39
+ * never a separate message the loop hands the model (see `agent-loop.ts`'s mapping of
40
+ * `StoredMessage`), so a cut cannot orphan a tool result from its call.
21
41
  */
22
42
  export declare class SlidingWindowHistory implements HistoryWindow {
23
- private readonly maxMessages;
43
+ /**
44
+ * Always a row count, so the bound always reaches the store: the token budget below can only cut
45
+ * MORE than this, and it cuts from the same end.
46
+ */
47
+ readonly maxMessages: number;
48
+ private readonly maxTokens;
49
+ private readonly estimate;
50
+ readonly summarize?: NonNullable<HistoryWindow['summarize']>;
24
51
  constructor(options?: SlidingWindowHistoryOptions);
25
- apply(messages: ModelMessage[], _ctx: HistoryWindowContext): ModelMessage[];
52
+ select(messages: ModelMessage[], _ctx: HistoryWindowContext): HistorySelection;
26
53
  }
54
+ /**
55
+ * What a summarizer is told to produce when none is supplied. Written for a reader who will continue
56
+ * the conversation without seeing the messages themselves, so it asks for the parts a later turn
57
+ * still has to act on rather than a readable recap.
58
+ */
59
+ export declare const DEFAULT_HISTORY_SUMMARY_INSTRUCTION = "Summarize this conversation for an assistant that will continue it without seeing these messages. Preserve decisions made, facts and constraints the user stated, identifiers and names mentioned, and anything left unresolved. Omit pleasantries. Reply with the summary only \u2014 no preamble, no headings.";
60
+ /**
61
+ * A {@link HistoryWindow.summarize} backed by one extra, non-streamed model call. Writes to a
62
+ * discarding sink so the summary's tokens never reach the user's live stream, and reports its usage
63
+ * so the call lands in the ledger (and against the quota) like any other.
64
+ */
65
+ export declare function summarizeWithModel(model: ModelProvider, instruction?: string): NonNullable<HistoryWindow['summarize']>;
27
66
  //# sourceMappingURL=history-window.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-window.d.ts","sourceRoot":"","sources":["../../src/history-window.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,2BAA2B;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,YAAY,OAAO,GAAE,2BAAgC,EAEpD;IAED,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,IAAI,EA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AE,aAAa,EACpB,WAAW,GAAE,MAA4C,GACxD,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAezC"}
@@ -1,24 +1,96 @@
1
1
  /**
2
- * Default {@link HistoryWindow}: keeps only the most recent `maxMessages` messages, dropping the
3
- * rest with no summary. Each persisted message is self-contained (a tool call's result is never a
4
- * separate message the loop hands the model — see `agent-loop.ts`'s mapping of `StoredMessage` — so
5
- * there is no cross-message pairing to preserve), so a plain wholesale drop of the oldest messages
6
- * is always safe.
2
+ * Rough token count for one message: ~4 characters per token over its content and its serialized
3
+ * tool calls/results, plus a small per-message envelope allowance for the role and part framing.
7
4
  *
8
- * A deployment that wants dropped history summarized instead of discarded should implement
9
- * {@link HistoryWindow} directly (e.g. call a model over the dropped slice and prepend the recap as
10
- * a synthetic message) rather than extend this class.
5
+ * A heuristic on purpose. A real tokenizer is model-specific and would drag a provider dependency
6
+ * into the package, while a budget only has to be approximately right to keep a thread clear of the
7
+ * provider's hard limit — and it must be a PURE function, because it runs inside `select`. Pass
8
+ * `estimate` to {@link SlidingWindowHistory} to substitute a real one.
9
+ */
10
+ export function estimateMessageTokens(message) {
11
+ const extras = (message.toolCalls !== undefined ? JSON.stringify(message.toolCalls).length : 0) +
12
+ (message.toolResults !== undefined ? JSON.stringify(message.toolResults).length : 0);
13
+ return Math.ceil((message.content.length + extras) / 4) + 4;
14
+ }
15
+ /**
16
+ * Default {@link HistoryWindow}: keeps the newest messages that fit a message count and/or a token
17
+ * budget, and (optionally) folds the rest into a summary. Whichever limit cuts more wins.
18
+ *
19
+ * A naive slice is safe because each persisted message is self-contained: a tool call's result is
20
+ * never a separate message the loop hands the model (see `agent-loop.ts`'s mapping of
21
+ * `StoredMessage`), so a cut cannot orphan a tool result from its call.
11
22
  */
12
23
  export class SlidingWindowHistory {
24
+ /**
25
+ * Always a row count, so the bound always reaches the store: the token budget below can only cut
26
+ * MORE than this, and it cuts from the same end.
27
+ */
13
28
  maxMessages;
29
+ maxTokens;
30
+ estimate;
31
+ summarize;
14
32
  constructor(options = {}) {
15
33
  this.maxMessages = options.maxMessages ?? 40;
34
+ this.maxTokens = options.maxTokens;
35
+ this.estimate = options.estimate ?? estimateMessageTokens;
36
+ if (options.summarize !== undefined) {
37
+ this.summarize = options.summarize;
38
+ }
39
+ }
40
+ select(messages, _ctx) {
41
+ let cut = Math.max(0, messages.length - this.maxMessages);
42
+ if (this.maxTokens !== undefined) {
43
+ cut = Math.max(cut, tokenCut(messages, this.maxTokens, this.estimate));
44
+ }
45
+ // The newest message always rides, whatever the limits say — a turn with nothing to answer is
46
+ // worse than a turn slightly over budget.
47
+ cut = Math.min(cut, Math.max(0, messages.length - 1));
48
+ return { keep: messages.slice(cut), drop: messages.slice(0, cut) };
16
49
  }
17
- apply(messages, _ctx) {
18
- if (messages.length <= this.maxMessages) {
19
- return messages;
50
+ }
51
+ /** Index of the oldest message that still fits `maxTokens`, walking newest-first. */
52
+ function tokenCut(messages, maxTokens, estimate) {
53
+ let index = messages.length;
54
+ let total = 0;
55
+ while (index > 0) {
56
+ const message = messages[index - 1];
57
+ if (message === undefined) {
58
+ break;
59
+ }
60
+ const cost = estimate(message);
61
+ if (index < messages.length && total + cost > maxTokens) {
62
+ break;
20
63
  }
21
- return messages.slice(messages.length - this.maxMessages);
64
+ total += cost;
65
+ index -= 1;
22
66
  }
67
+ return index;
68
+ }
69
+ /**
70
+ * What a summarizer is told to produce when none is supplied. Written for a reader who will continue
71
+ * the conversation without seeing the messages themselves, so it asks for the parts a later turn
72
+ * still has to act on rather than a readable recap.
73
+ */
74
+ export const DEFAULT_HISTORY_SUMMARY_INSTRUCTION = 'Summarize this conversation for an assistant that will continue it without seeing these messages. Preserve decisions made, facts and constraints the user stated, identifiers and names mentioned, and anything left unresolved. Omit pleasantries. Reply with the summary only — no preamble, no headings.';
75
+ /**
76
+ * A {@link HistoryWindow.summarize} backed by one extra, non-streamed model call. Writes to a
77
+ * discarding sink so the summary's tokens never reach the user's live stream, and reports its usage
78
+ * so the call lands in the ledger (and against the quota) like any other.
79
+ */
80
+ export function summarizeWithModel(model, instruction = DEFAULT_HISTORY_SUMMARY_INSTRUCTION) {
81
+ return async (dropped) => {
82
+ const discard = { write: () => { }, end: () => { } };
83
+ const turn = await model.runTurn({
84
+ system: instruction,
85
+ messages: dropped,
86
+ tools: [],
87
+ sink: discard,
88
+ });
89
+ return {
90
+ text: turn.text,
91
+ usage: turn.usage,
92
+ ...(turn.modelId !== undefined ? { modelId: turn.modelId } : {}),
93
+ };
94
+ };
23
95
  }
24
96
  //# sourceMappingURL=history-window.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history-window.js","sourceRoot":"","sources":["../../src/history-window.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,oBAAoB;IACd,WAAW,CAAS;IAErC,YAAY,OAAO,GAAgC,EAAE;QACnD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,QAAwB,EAAE,IAA0B;QACxD,IAAI,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACxC,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC;CACF"}
1
+ {"version":3,"file":"history-window.js","sourceRoot":"","sources":["../../src/history-window.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAqB;IACzD,MAAM,MAAM,GACV,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAChF,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CA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AAE;YACT,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QACH,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "0.31.0";
1
+ export declare const VERSION = "0.33.1";
2
2
  export { configure } from '../configure.js';
3
3
  export * from './actor-labels.js';
4
4
  export type { AuthActorResolverOptions } from './actor-resolver.js';
@@ -7,7 +7,7 @@ export type { AgentDeps } from './agent-deps.js';
7
7
  export { utcDay } from './agent-deps.js';
8
8
  export type { AgentDepsFactoryConfig } from './agent-deps-factory.js';
9
9
  export { AgentDepsFactory, delegateToolName, normalizeDelegateEdge, registerDelegateTools, } from './agent-deps-factory.js';
10
- export { type AgentLoopDeps, type AgentLoopHooks, QuotaExceededError, runAgentLoop, } from './agent-loop.js';
10
+ export { type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, DEFAULT_MAX_AGENT_APPEARANCES, MAX_DELEGATION_DEPTH, QuotaExceededError, runAgentLoop, type SettledTask, settleAll, withBuiltInTools, } from './agent-loop.js';
11
11
  export { AgentRegistry } from './agent-registry.js';
12
12
  export type { ChatParams } from './agent-service.js';
13
13
  export { AgentService } from './agent-service.js';
@@ -20,22 +20,27 @@ export { dataTool, GroupTableAccessPolicy, injectLimit, loadSqlParser, SqlValida
20
20
  export type { ActorDirectoryFactory, AgentConfig, AttachmentStagingContext, AttachmentStagingFactory, DefaultAgentOptions, EmbeddingFactory, GovernanceQueriesContext, GovernanceQueriesFactory, LucidGovernanceConfig, LucidPricingConfig, LucidStoreConfig, MemoryActorDirectoryConfig, MemoryRetrieverConfig, MemoryStoreConfig, ModelFactory, PgVectorRetrieverConfig, PricingContext, PricingFactory, QuotaConfig, QuotaContext, QuotaFactory, RedisTokenSinkConfig, RetrieverContext, RetrieverFactory, SinkFactory, StoreContext, StoreFactory, TokenSinkFactory, } from './define_config.js';
21
21
  export { actorDirectories, attachmentStores, defineConfig, governanceQueries, pricingStores, quotas, retrievers, stores, streamTransports, tokenSinks, } from './define_config.js';
22
22
  export * from './diagnostics.js';
23
+ export { type AgentIntake, ASK_TOOL_DESCRIPTION, ASK_TOOL_NAME, type AskToolInput, askInputSchema, askToolDefinition, DEFAULT_INTAKE_PREAMBLE, type ElicitationOption, type ElicitationOutcome, type ElicitationQuestion, type ElicitationReply, type ElicitationRequest, type ElicitationResult, type HumanReply, HumanReplyMismatchError, isHumanDecision, MAX_ASK_QUESTIONS, normalizeElicitationReply, renderElicitationAnswers, resolveElicitation, settleElicitation, } from './elicitation.js';
23
24
  export type { AgentGovernanceAuthorize, GovernanceGateVerdict } from './governance-gate.js';
24
25
  export { evaluateGovernanceGate } from './governance-gate.js';
25
26
  export * from './history-window.js';
26
27
  export { InProcessTokenStreamSink } from './in-process-sink.js';
28
+ export { type BuildMemoryBlockInput, buildMemoryBlock, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, type ForgetMemoryInput, type ListMemoriesInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, memoryForgetVerdict, memoryWriteVerdict, type OfferMemoriesInput, type OverriddenMemory, offerMemories, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RememberToolInput, type ResolveMemoryDigestInput, rememberInputSchema, rememberToolDefinition, resolveMemoryDigest, type SearchMemoriesInput, type StoreMemoryInput, type WriteMemoryInput, writeMemory, } from './memory.js';
27
29
  export type { OwnershipVerdict } from './ownership.js';
28
30
  export { evaluateOwnership } from './ownership.js';
29
31
  export type { CursorPage, CursorParams } from './pagination.js';
30
32
  export * from './personas.js';
31
33
  export * from './pricing/models-dev.js';
34
+ export { createFrameBuffer, createIncrementalGate, type FrameBuffer, type GateRejection, gateTail, type IncrementalGate, type OutputGateMode, type OutputGateResult, releaseGatedFrames, resolveGateLookback, resolveOutputGateMode, runInputProcessors, runOutputProcessors, } from './processors.js';
32
35
  export * from './rag/index.js';
33
36
  export type { FacetHit, QdrantClientLike, QdrantCondition, QdrantFieldCondition, QdrantFilter, QdrantIsEmptyCondition, QdrantMetric, QdrantPoint, QdrantStoreOptions, } from './rag/qdrant-store.js';
34
37
  export { buildQdrantFilter, chunkIdToPointId, decodeScrollCursor, encodeScrollCursor, QdrantRetriever, QdrantStore, } from './rag/qdrant-store.js';
35
38
  export * from './rag-media/index.js';
36
39
  export type { RedisStreamClient } from './redis-stream-client.js';
37
40
  export { RedisTokenStreamSink, type RedisTokenStreamSinkOptions, } from './redis-token-stream-sink.js';
41
+ export { isReplayIntegrityError } from './replay-integrity.js';
38
42
  export { InlineAgentRunner } from './runners/inline-agent-runner.js';
43
+ export { actorScope, buildSkillsBlock, compositeSkillProvider, DEFAULT_MAX_SKILLS, defaultScopeResolver, GLOBAL_SCOPE, type ListSkillsInput, type LoadSkillInput, loadSkill, offerSkills, resolveSkillCatalog, type ScopeContext, type ScopeResolver, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillsConfig, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, skillInputSchema, skillToolDefinition, skillWriteVerdict, staticSkillProvider, tenantScope, } from './skills.js';
39
44
  export * from './spi/actor-directory.js';
40
45
  export * from './spi/actor-resolver.js';
41
46
  export * from './spi/agent-runner.js';
@@ -46,6 +51,7 @@ export * from './spi/governance-queries.js';
46
51
  export * from './spi/history-window.js';
47
52
  export * from './spi/model-provider.js';
48
53
  export * from './spi/pricing-store.js';
54
+ export * from './spi/processors.js';
49
55
  export * from './spi/quota-store.js';
50
56
  export * from './spi/reranker.js';
51
57
  export * from './spi/retriever.js';
@@ -62,6 +68,7 @@ export { LucidAgentStore } from './stores/lucid.js';
62
68
  export { LucidGovernanceQueries } from './stores/lucid-governance-queries.js';
63
69
  export { LucidPricingStore } from './stores/lucid-pricing.js';
64
70
  export { AGENT_TABLES, createAgentTables, createTableStatements, dropAgentTables, dropTableStatements, ensureAgentTables, } from './stores/lucid-schema.js';
71
+ export { DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, extractJson, repairInstruction, type StructuredOutcome, StructuredOutputError, validateStructured, } from './structured-output.js';
65
72
  export type { RegisteredTool, ToolsBarrel } from './tool-discovery.js';
66
73
  export { discoverTools, registerFunctionalTool, registerToolExport, registerToolsFromBarrel, } from './tool-discovery.js';
67
74
  export { DefaultRolesPolicy, ToolForbiddenError, ToolInputInvalidError, ToolNotFoundError, ToolRegistry, } from './tool-registry.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AAC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,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qCAAqC,EACrC,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qCAAqC,EACrC,uCAAuC,EACvC,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,cAAc,YAAY,CAAC"}
package/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = '0.31.0';
1
+ export const VERSION = '0.33.1';
2
2
  // Re-export the configure hook from the package root so `node ace configure` finds it.
3
3
  // AdonisJS imports the package MAIN and reads `configure` off the module namespace —
4
4
  // the `./configure` subpath alone is never consulted.
@@ -7,7 +7,7 @@ export * from './actor-labels.js';
7
7
  export { AuthActorResolver, HeaderActorResolver, resolveActorResolver, UnconfiguredActorResolver, } from './actor-resolver.js';
8
8
  export { utcDay } from './agent-deps.js';
9
9
  export { AgentDepsFactory, delegateToolName, normalizeDelegateEdge, registerDelegateTools, } from './agent-deps-factory.js';
10
- export { QuotaExceededError, runAgentLoop, } from './agent-loop.js';
10
+ export { DEFAULT_MAX_AGENT_APPEARANCES, MAX_DELEGATION_DEPTH, QuotaExceededError, runAgentLoop, settleAll, withBuiltInTools, } from './agent-loop.js';
11
11
  export { AgentRegistry } from './agent-registry.js';
12
12
  export { AgentService } from './agent-service.js';
13
13
  export { AGENT_TOOL_BRAND, AI_TOOL_META_KEY, AiTool, defineTool, isBrandedFunctionalTool, readAiToolMeta, } from './ai-tool-ref.js';
@@ -18,17 +18,22 @@ export { dataTool, GroupTableAccessPolicy, injectLimit, loadSqlParser, SqlValida
18
18
  // ── Wave 2: Adonis integration shell ─────────────────────────────────────────
19
19
  export { actorDirectories, attachmentStores, defineConfig, governanceQueries, pricingStores, quotas, retrievers, stores, streamTransports, tokenSinks, } from './define_config.js';
20
20
  export * from './diagnostics.js';
21
+ export { ASK_TOOL_DESCRIPTION, ASK_TOOL_NAME, askInputSchema, askToolDefinition, DEFAULT_INTAKE_PREAMBLE, HumanReplyMismatchError, isHumanDecision, MAX_ASK_QUESTIONS, normalizeElicitationReply, renderElicitationAnswers, resolveElicitation, settleElicitation, } from './elicitation.js';
21
22
  export { evaluateGovernanceGate } from './governance-gate.js';
22
23
  export * from './history-window.js';
23
24
  export { InProcessTokenStreamSink } from './in-process-sink.js';
25
+ export { buildMemoryBlock, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, memoryForgetVerdict, memoryWriteVerdict, offerMemories, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, rememberInputSchema, rememberToolDefinition, resolveMemoryDigest, writeMemory, } from './memory.js';
24
26
  export { evaluateOwnership } from './ownership.js';
25
27
  export * from './personas.js';
26
28
  export * from './pricing/models-dev.js';
29
+ export { createFrameBuffer, createIncrementalGate, gateTail, releaseGatedFrames, resolveGateLookback, resolveOutputGateMode, runInputProcessors, runOutputProcessors, } from './processors.js';
27
30
  export * from './rag/index.js';
28
31
  export { buildQdrantFilter, chunkIdToPointId, decodeScrollCursor, encodeScrollCursor, QdrantRetriever, QdrantStore, } from './rag/qdrant-store.js';
29
32
  export * from './rag-media/index.js';
30
33
  export { RedisTokenStreamSink, } from './redis-token-stream-sink.js';
34
+ export { isReplayIntegrityError } from './replay-integrity.js';
31
35
  export { InlineAgentRunner } from './runners/inline-agent-runner.js';
36
+ export { actorScope, buildSkillsBlock, compositeSkillProvider, DEFAULT_MAX_SKILLS, defaultScopeResolver, GLOBAL_SCOPE, loadSkill, offerSkills, resolveSkillCatalog, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, skillInputSchema, skillToolDefinition, skillWriteVerdict, staticSkillProvider, tenantScope, } from './skills.js';
32
37
  export * from './spi/actor-directory.js';
33
38
  export * from './spi/actor-resolver.js';
34
39
  export * from './spi/agent-runner.js';
@@ -39,6 +44,7 @@ export * from './spi/governance-queries.js';
39
44
  export * from './spi/history-window.js';
40
45
  export * from './spi/model-provider.js';
41
46
  export * from './spi/pricing-store.js';
47
+ export * from './spi/processors.js';
42
48
  export * from './spi/quota-store.js';
43
49
  export * from './spi/reranker.js';
44
50
  export * from './spi/retriever.js';
@@ -52,6 +58,7 @@ export { LucidAgentStore } from './stores/lucid.js';
52
58
  export { LucidGovernanceQueries } from './stores/lucid-governance-queries.js';
53
59
  export { LucidPricingStore } from './stores/lucid-pricing.js';
54
60
  export { AGENT_TABLES, createAgentTables, createTableStatements, dropAgentTables, dropTableStatements, ensureAgentTables, } from './stores/lucid-schema.js';
61
+ export { DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, extractJson, repairInstruction, StructuredOutputError, validateStructured, } from './structured-output.js';
55
62
  export { discoverTools, registerFunctionalTool, registerToolExport, registerToolsFromBarrel, } from './tool-discovery.js';
56
63
  export { DefaultRolesPolicy, ToolForbiddenError, ToolInputInvalidError, ToolNotFoundError, ToolRegistry, } from './tool-registry.js';
57
64
  export { DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, invokeWithTransientRetry, isTransientToolError, } from './tool-retry.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;A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,2BAA2B,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qCAAqC,EACrC,WAAW,EACX,iBAAiB,EAEjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EACL,qCAAqC,EACrC,uCAAuC,EACvC,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,cAAc,YAAY,CAAC"}
@@ -30,6 +30,14 @@ export interface CreateMcpServerOptions extends McpToolContextOptions {
30
30
  policy: RolesPolicy;
31
31
  /** Optional allow-list restricting which tools are exposed. */
32
32
  allowedTools?: string[];
33
+ /**
34
+ * What to do with `action` tools. Defaults to `'refuse'`: they are neither listed nor callable.
35
+ *
36
+ * An `action` is HITL-gated in the loop — a human approves it before it runs. An MCP caller has
37
+ * no human, so honouring that gate is impossible and the tool stays off the surface. `'execute'`
38
+ * is a deployment saying it accepts an unapproved actor running every `action` its roles reach.
39
+ */
40
+ actions?: 'refuse' | 'execute';
33
41
  }
34
42
  /**
35
43
  * Build a low-level MCP `Server` that exposes the agent's {@link ToolRegistry} over the wire:
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAKnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAA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;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,KAAK,KAAK,CAAC;IACzD,yFAAyF;IACzF,cAAc,CAAC,EAAE,CACf,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,KACnC;QACH,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,2CAA2C;AAC3C,MAAM,WAAW,sBAAuB,SAAQ,qBAAqB;IACnE,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,QAAQ,EAAE,YAAY,CAAC;IACvB,kFAAkF;IAClF,MAAM,EAAE,WAAW,CAAC;IACpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAChC;AA2DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,MAAM,CA8DvE"}
@@ -1,6 +1,20 @@
1
1
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
2
  import { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js';
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ import { ToolNotFoundError } from '../tool-registry.js';
5
+ /**
6
+ * Kinds the LOOP serves, which a registry entry cannot honour on its own. A handoff tool is
7
+ * registered with a stub handler because `AgentLoop` performs the delegation, so calling it here
8
+ * would answer `{}` and delegate to nobody. Never exposed, whatever `actions` says.
9
+ */
10
+ const LOOP_SERVED_KINDS = new Set(['agent', 'ask', 'skill', 'memory']);
11
+ /** Whether this tool may be reached over MCP at all — the same answer for listing and for calling. */
12
+ function isExposable(kind, actions) {
13
+ if (LOOP_SERVED_KINDS.has(kind)) {
14
+ return false;
15
+ }
16
+ return kind !== 'action' || actions === 'execute';
17
+ }
4
18
  /**
5
19
  * True for a Zod schema (tags its Standard Schema props with `vendor: 'zod'`). Narrows to the SDK's
6
20
  * `AnyObjectSchema` so `toJsonSchemaCompat` can consume it without a cast.
@@ -54,6 +68,7 @@ function toJsonSchema(schema) {
54
68
  */
55
69
  export function createMcpServer(options) {
56
70
  const { registry, policy, allowedTools, actorFromAuth, idsFromRequest } = options;
71
+ const actions = options.actions ?? 'refuse';
57
72
  const server = new Server({ name: options.name, version: options.version }, { capabilities: { tools: {} } });
58
73
  const buildCtx = (authInfo, sessionId) => {
59
74
  const actor = actorFromAuth(authInfo);
@@ -68,7 +83,7 @@ export function createMcpServer(options) {
68
83
  };
69
84
  server.setRequestHandler(ListToolsRequestSchema, async (_request, extra) => {
70
85
  const actor = actorFromAuth(extra.authInfo);
71
- const defs = await registry.definitionsFor(actor, policy, allowedTools);
86
+ const defs = (await registry.definitionsFor(actor, policy, allowedTools)).filter((definition) => isExposable(definition.kind, actions));
72
87
  return {
73
88
  tools: defs.map((definition) => ({
74
89
  name: definition.name,
@@ -81,6 +96,17 @@ export function createMcpServer(options) {
81
96
  const ctx = buildCtx(extra.authInfo, extra.sessionId);
82
97
  const { name, arguments: args } = request.params;
83
98
  try {
99
+ // Re-decided on the CALL, not inherited from the listing. `registry.invoke` re-checks roles
100
+ // and re-validates input, but knows nothing about this server's allow-list or its `actions`
101
+ // stance — so a caller who guesses a name would otherwise reach a tool deliberately left off
102
+ // the surface.
103
+ const spec = registry.spec(name);
104
+ if (spec === undefined || !isExposable(spec.kind, actions)) {
105
+ throw new ToolNotFoundError(name);
106
+ }
107
+ if (allowedTools !== undefined && !allowedTools.includes(name)) {
108
+ throw new ToolNotFoundError(name);
109
+ }
84
110
  const output = await registry.invoke(name, args ?? {}, ctx, policy);
85
111
  return {
86
112
  content: [
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAwCnG;;;GAGG;AACH,SAAS,WAAW,CAAC,MAAwB;IAC3C,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC;AAC9C,CAAC;AAED,sGAAsG;AACtG,SAAS,qBAAqB,CAAC,MAAwB;IAGrD,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,YAAY,IAAI,QAAQ,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC;IACtC,OAAO,CACL,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,KAAK,IAAI;QAClB,OAAO,IAAI,SAAS;QACpB,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU,CACtC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,MAAwB;IAC5C,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,KAAK,EAA6B,CAAC;IAC3E,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AACxE,CAAC;A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C;YACpC,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;YACpE,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;iBACrF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { ToolRegistry } from '../tool-registry.js';
2
+ import type { McpLogger, McpServerConfig } from './options.js';
3
+ /** One tool this importer currently has in the registry, and the server it came from. */
4
+ export interface McpRegisteredTool {
5
+ /** The name in the shared registry — the server's name after namespacing and sanitizing. */
6
+ name: string;
7
+ serverName: string;
8
+ /** The name on the server, which namespacing and sanitizing may have changed. */
9
+ remoteName: string;
10
+ /** The description the server supplied, which rides into the tool list of every turn. */
11
+ description: string;
12
+ }
13
+ /**
14
+ * Connects to each configured MCP server and registers what it exports into the shared
15
+ * {@link ToolRegistry} — the same registry `@aiTool` discovery writes to, so an imported tool goes
16
+ * through every gate a hand-written one does.
17
+ *
18
+ * The provider calls {@link start} inside `app.booted()`, AFTER tool discovery has registered the
19
+ * app's own tools, which is what lets the name-collision check below see them.
20
+ *
21
+ * The registry is keyed by name and nothing else, so a name is OWNED by whoever registered it
22
+ * first: the application, or one named server. A second claimant is refused rather than allowed to
23
+ * replace a live handler, because the substitution is invisible from everywhere else — the model
24
+ * goes on calling `deploy`, and `deploy` now reaches somebody else's server.
25
+ */
26
+ export declare class McpToolImporter {
27
+ private readonly servers;
28
+ private readonly registry;
29
+ private readonly logger?;
30
+ private readonly sources;
31
+ /** Local tool name → what is registered under it, so ownership survives a {@link refresh}. */
32
+ private readonly owners;
33
+ constructor(servers: McpServerConfig[], registry: ToolRegistry, logger?: McpLogger | undefined);
34
+ /** Open each configured server and import from all of them. */
35
+ start(): Promise<number>;
36
+ close(): Promise<void>;
37
+ /**
38
+ * Re-import from one server, or from all of them — the way back for a server that was down at
39
+ * boot, or whose exports have changed since.
40
+ *
41
+ * A re-import is the server's CURRENT answer to `tools/list`, so it removes as well as adds: a
42
+ * tool the server has dropped or renamed is unregistered, because going on offering the model a
43
+ * tool whose next call fails remotely is worse than not offering it at all. Only names this
44
+ * importer registered for THAT server are eligible — never the application's own, never another
45
+ * server's.
46
+ *
47
+ * A server that could not be reached prunes nothing. Its tools are unknown, not gone, and a
48
+ * network blip is not a reason to withdraw a working tool from the model.
49
+ *
50
+ * Returns how many tools the servers it re-imported from just claimed, which is not the
51
+ * registry's total: a name skipped for a collision is not counted, and a scoped refresh says
52
+ * nothing about what the other servers hold.
53
+ */
54
+ refresh(serverName?: string): Promise<number>;
55
+ /** Every tool currently imported, and where each came from — what the servers export NOW. */
56
+ importedTools(): McpRegisteredTool[];
57
+ /**
58
+ * A server that is unreachable costs its own tools and nothing else: the model is simply never
59
+ * offered them. Booting the whole application on the availability of a third-party process is the
60
+ * wrong trade — until a server declares `required: true`, which says the app is not useful
61
+ * without it and should fail loudly instead.
62
+ *
63
+ * `undefined` is a server that could not be reached, as distinct from one that exports no tools:
64
+ * the first has already been reported here, the second is worth reporting on registration.
65
+ */
66
+ private importFrom;
67
+ /**
68
+ * Drop what `serverName` used to export and no longer does. Keyed on ownership rather than on the
69
+ * name's prefix: `namespace: false` imports under bare names, where a prefix says nothing about
70
+ * who registered one.
71
+ */
72
+ private prune;
73
+ private register;
74
+ }
75
+ //# sourceMappingURL=importer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../../src/mcp-client/importer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/D,yFAAyF;AACzF,MAAM,WAAW,iBAAiB;IAChC,4FAA4F;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe;IAMxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAP1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,8FAA8F;IAC9F,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAE/D,YACmB,OAAO,EAAE,eAAe,EAAE,EAC1B,QAAQ,EAAE,YAAY,EACtB,MAAM,CAAC,EAAE,SAAS,YAAA,EAapC;IAED,+DAA+D;IACzD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAK7B;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmClD;IAED,6FAA6F;IAC7F,aAAa,IAAI,iBAAiB,EAAE,CAEnC;IAED;;;;;;;;OAQG;YACW,UAAU;IAiBxB;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAab,OAAO,CAAC,QAAQ;CA2BjB"}