@namzu/sdk 61.4.0 → 62.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +2 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  6. package/dist/bridge/a2a/mapper.js +2 -0
  7. package/dist/bridge/a2a/mapper.js.map +1 -1
  8. package/dist/bridge/acp/permission.d.ts +8 -0
  9. package/dist/bridge/acp/permission.d.ts.map +1 -1
  10. package/dist/bridge/acp/permission.js.map +1 -1
  11. package/dist/bridge/acp/server.d.ts.map +1 -1
  12. package/dist/bridge/acp/server.js +8 -1
  13. package/dist/bridge/acp/server.js.map +1 -1
  14. package/dist/bridge/sse/mapper.d.ts.map +1 -1
  15. package/dist/bridge/sse/mapper.js +13 -0
  16. package/dist/bridge/sse/mapper.js.map +1 -1
  17. package/dist/constants/tools/index.d.ts +2 -0
  18. package/dist/constants/tools/index.d.ts.map +1 -1
  19. package/dist/constants/tools/index.js +23 -0
  20. package/dist/constants/tools/index.js.map +1 -1
  21. package/dist/contracts/session/api.d.ts +1 -1
  22. package/dist/contracts/session/api.d.ts.map +1 -1
  23. package/dist/eval/harness-protection.js +1 -1
  24. package/dist/eval/harness-protection.js.map +1 -1
  25. package/dist/learning/cycle.d.ts +5 -3
  26. package/dist/learning/cycle.d.ts.map +1 -1
  27. package/dist/learning/cycle.js +11 -13
  28. package/dist/learning/cycle.js.map +1 -1
  29. package/dist/learning/guidance.d.ts +74 -0
  30. package/dist/learning/guidance.d.ts.map +1 -0
  31. package/dist/learning/guidance.js +259 -0
  32. package/dist/learning/guidance.js.map +1 -0
  33. package/dist/learning/skill.d.ts +2 -2
  34. package/dist/learning/skill.d.ts.map +1 -1
  35. package/dist/learning/skill.js +6 -6
  36. package/dist/learning/skill.js.map +1 -1
  37. package/dist/learning/store.d.ts.map +1 -1
  38. package/dist/learning/store.js +6 -6
  39. package/dist/learning/store.js.map +1 -1
  40. package/dist/pals/communication/ingress-schema.d.ts +8 -8
  41. package/dist/pals/communication/schema.d.ts +2 -2
  42. package/dist/peers/client.d.ts +2 -3
  43. package/dist/peers/client.d.ts.map +1 -1
  44. package/dist/peers/client.js +2 -3
  45. package/dist/peers/client.js.map +1 -1
  46. package/dist/peers/endpoint.d.ts +1 -2
  47. package/dist/peers/endpoint.d.ts.map +1 -1
  48. package/dist/peers/endpoint.js +1 -2
  49. package/dist/peers/endpoint.js.map +1 -1
  50. package/dist/peers/protocol.d.ts.map +1 -1
  51. package/dist/peers/protocol.js +1 -0
  52. package/dist/peers/protocol.js.map +1 -1
  53. package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
  54. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  55. package/dist/prompt/coding-agent-doctrine.js +5 -3
  56. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  57. package/dist/prompt/index.d.ts +0 -4
  58. package/dist/prompt/index.d.ts.map +1 -1
  59. package/dist/prompt/index.js +0 -2
  60. package/dist/prompt/index.js.map +1 -1
  61. package/dist/provider/fallback.d.ts.map +1 -1
  62. package/dist/provider/fallback.js +3 -0
  63. package/dist/provider/fallback.js.map +1 -1
  64. package/dist/provider/idle-timeout.d.ts.map +1 -1
  65. package/dist/provider/idle-timeout.js +5 -0
  66. package/dist/provider/idle-timeout.js.map +1 -1
  67. package/dist/provider/model-window-suffix.d.ts.map +1 -1
  68. package/dist/provider/model-window-suffix.js +1 -0
  69. package/dist/provider/model-window-suffix.js.map +1 -1
  70. package/dist/provider/retry.d.ts.map +1 -1
  71. package/dist/provider/retry.js +5 -0
  72. package/dist/provider/retry.js.map +1 -1
  73. package/dist/provider/step-stopped.d.ts +19 -0
  74. package/dist/provider/step-stopped.d.ts.map +1 -0
  75. package/dist/provider/step-stopped.js +25 -0
  76. package/dist/provider/step-stopped.js.map +1 -0
  77. package/dist/provider/token-budget.d.ts.map +1 -1
  78. package/dist/provider/token-budget.js +6 -1
  79. package/dist/provider/token-budget.js.map +1 -1
  80. package/dist/public-runtime.d.ts +4 -15
  81. package/dist/public-runtime.d.ts.map +1 -1
  82. package/dist/public-runtime.js +4 -15
  83. package/dist/public-runtime.js.map +1 -1
  84. package/dist/public-tools.d.ts +0 -2
  85. package/dist/public-tools.d.ts.map +1 -1
  86. package/dist/public-tools.js +0 -2
  87. package/dist/public-tools.js.map +1 -1
  88. package/dist/public-types.d.ts +4 -22
  89. package/dist/public-types.d.ts.map +1 -1
  90. package/dist/runtime/query/iteration/index.d.ts +17 -0
  91. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  92. package/dist/runtime/query/iteration/index.js +176 -6
  93. package/dist/runtime/query/iteration/index.js.map +1 -1
  94. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  95. package/dist/runtime/query/iteration/phases/per-call-review.js +4 -5
  96. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  97. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  98. package/dist/runtime/query/iteration/phases/tool-review.js +6 -3
  99. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  100. package/dist/runtime/query/iteration/recorded-context.d.ts +1 -1
  101. package/dist/runtime/query/iteration/recorded-context.d.ts.map +1 -1
  102. package/dist/runtime/query/iteration/recorded-context.js +2 -1
  103. package/dist/runtime/query/iteration/recorded-context.js.map +1 -1
  104. package/dist/runtime/query/iteration/stream-turn.d.ts +9 -1
  105. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  106. package/dist/runtime/query/iteration/stream-turn.js +48 -2
  107. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  108. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  109. package/dist/runtime/query/resume-pending.js +7 -4
  110. package/dist/runtime/query/resume-pending.js.map +1 -1
  111. package/dist/runtime/query/review-policy.d.ts +40 -8
  112. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  113. package/dist/runtime/query/review-policy.js +139 -24
  114. package/dist/runtime/query/review-policy.js.map +1 -1
  115. package/dist/runtime/query/turn/completion-audit.d.ts +32 -0
  116. package/dist/runtime/query/turn/completion-audit.d.ts.map +1 -0
  117. package/dist/runtime/query/turn/completion-audit.js +56 -0
  118. package/dist/runtime/query/turn/completion-audit.js.map +1 -0
  119. package/dist/runtime/query/turn/stall-monitor.d.ts +78 -0
  120. package/dist/runtime/query/turn/stall-monitor.d.ts.map +1 -0
  121. package/dist/runtime/query/turn/stall-monitor.js +101 -0
  122. package/dist/runtime/query/turn/stall-monitor.js.map +1 -0
  123. package/dist/session/paths.d.ts +1 -2
  124. package/dist/session/paths.d.ts.map +1 -1
  125. package/dist/session/paths.js +1 -4
  126. package/dist/session/paths.js.map +1 -1
  127. package/dist/store/index.d.ts +2 -0
  128. package/dist/store/index.d.ts.map +1 -1
  129. package/dist/store/index.js +1 -0
  130. package/dist/store/index.js.map +1 -1
  131. package/dist/tools/builtins/bash.d.ts +2 -1
  132. package/dist/tools/builtins/bash.d.ts.map +1 -1
  133. package/dist/tools/builtins/bash.js +5 -2
  134. package/dist/tools/builtins/bash.js.map +1 -1
  135. package/dist/tools/builtins/content-fingerprint.d.ts +13 -0
  136. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  137. package/dist/tools/builtins/content-fingerprint.js +25 -0
  138. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  139. package/dist/tools/builtins/edit.d.ts.map +1 -1
  140. package/dist/tools/builtins/edit.js +7 -2
  141. package/dist/tools/builtins/edit.js.map +1 -1
  142. package/dist/tools/builtins/shell-read-credit.d.ts +15 -0
  143. package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -0
  144. package/dist/tools/builtins/shell-read-credit.js +161 -0
  145. package/dist/tools/builtins/shell-read-credit.js.map +1 -0
  146. package/dist/tools/paths.d.ts +15 -2
  147. package/dist/tools/paths.d.ts.map +1 -1
  148. package/dist/tools/paths.js +17 -2
  149. package/dist/tools/paths.js.map +1 -1
  150. package/dist/turn/evidence-recall.d.ts +1 -1
  151. package/dist/turn/evidence-recall.d.ts.map +1 -1
  152. package/dist/turn/evidence-recall.js +5 -14
  153. package/dist/turn/evidence-recall.js.map +1 -1
  154. package/dist/turn/memory-recall.d.ts.map +1 -1
  155. package/dist/turn/memory-recall.js +18 -4
  156. package/dist/turn/memory-recall.js.map +1 -1
  157. package/dist/turn/reporter.d.ts.map +1 -1
  158. package/dist/turn/reporter.js +5 -0
  159. package/dist/turn/reporter.js.map +1 -1
  160. package/dist/types/acp/index.d.ts +6 -0
  161. package/dist/types/acp/index.d.ts.map +1 -1
  162. package/dist/types/agent/base.d.ts +4 -0
  163. package/dist/types/agent/base.d.ts.map +1 -1
  164. package/dist/types/hitl/index.d.ts +8 -0
  165. package/dist/types/hitl/index.d.ts.map +1 -1
  166. package/dist/types/hitl/index.js.map +1 -1
  167. package/dist/types/ids/index.d.ts +1 -1
  168. package/dist/types/message/index.d.ts +1 -1
  169. package/dist/types/message/index.d.ts.map +1 -1
  170. package/dist/types/message/index.js +1 -0
  171. package/dist/types/message/index.js.map +1 -1
  172. package/dist/types/provider/interface.d.ts +12 -0
  173. package/dist/types/provider/interface.d.ts.map +1 -1
  174. package/dist/types/session/config.d.ts +25 -0
  175. package/dist/types/session/config.d.ts.map +1 -1
  176. package/dist/types/session/events.d.ts +19 -0
  177. package/dist/types/session/events.d.ts.map +1 -1
  178. package/dist/types/session/events.js.map +1 -1
  179. package/dist/types/session/prepare-step.d.ts +16 -0
  180. package/dist/types/session/prepare-step.d.ts.map +1 -1
  181. package/dist/types/session/records.d.ts.map +1 -1
  182. package/dist/types/session/records.js +3 -0
  183. package/dist/types/session/records.js.map +1 -1
  184. package/dist/types/session/turn.d.ts +1 -1
  185. package/dist/types/session/turn.d.ts.map +1 -1
  186. package/dist/types/session/turn.js.map +1 -1
  187. package/package.json +1 -1
  188. package/src/agents/QueryAgent.ts +2 -0
  189. package/src/bridge/a2a/mapper.ts +2 -0
  190. package/src/bridge/acp/permission.ts +8 -0
  191. package/src/bridge/acp/server.ts +7 -1
  192. package/src/bridge/sse/mapper.ts +13 -0
  193. package/src/constants/tools/index.ts +27 -0
  194. package/src/contracts/session/api.ts +1 -0
  195. package/src/eval/harness-protection.ts +1 -1
  196. package/src/learning/cycle.ts +15 -16
  197. package/src/learning/guidance.ts +339 -0
  198. package/src/learning/skill.ts +7 -7
  199. package/src/learning/store.ts +5 -6
  200. package/src/peers/client.ts +2 -3
  201. package/src/peers/endpoint.ts +1 -2
  202. package/src/peers/protocol.ts +1 -0
  203. package/src/prompt/coding-agent-doctrine.ts +5 -3
  204. package/src/prompt/index.ts +0 -4
  205. package/src/provider/fallback.ts +7 -0
  206. package/src/provider/idle-timeout.ts +8 -0
  207. package/src/provider/model-window-suffix.ts +1 -0
  208. package/src/provider/retry.ts +8 -0
  209. package/src/provider/step-stopped.ts +27 -0
  210. package/src/provider/token-budget.ts +6 -1
  211. package/src/public-runtime.ts +7 -28
  212. package/src/public-tools.ts +0 -3
  213. package/src/public-types.ts +6 -137
  214. package/src/runtime/query/iteration/index.ts +218 -6
  215. package/src/runtime/query/iteration/phases/per-call-review.ts +7 -5
  216. package/src/runtime/query/iteration/phases/tool-review.ts +5 -3
  217. package/src/runtime/query/iteration/recorded-context.ts +2 -0
  218. package/src/runtime/query/iteration/stream-turn.ts +51 -1
  219. package/src/runtime/query/resume-pending.ts +11 -4
  220. package/src/runtime/query/review-policy.ts +157 -24
  221. package/src/runtime/query/turn/completion-audit.ts +71 -0
  222. package/src/runtime/query/turn/stall-monitor.ts +158 -0
  223. package/src/session/paths.ts +2 -6
  224. package/src/store/index.ts +2 -0
  225. package/src/tools/builtins/bash.ts +6 -2
  226. package/src/tools/builtins/content-fingerprint.ts +25 -0
  227. package/src/tools/builtins/edit.ts +11 -2
  228. package/src/tools/builtins/shell-read-credit.ts +159 -0
  229. package/src/tools/paths.ts +18 -2
  230. package/src/turn/evidence-recall.ts +7 -15
  231. package/src/turn/memory-recall.ts +26 -7
  232. package/src/turn/reporter.ts +5 -0
  233. package/src/types/acp/index.ts +6 -0
  234. package/src/types/agent/base.ts +4 -0
  235. package/src/types/hitl/index.ts +8 -0
  236. package/src/types/ids/index.ts +1 -1
  237. package/src/types/message/index.ts +1 -0
  238. package/src/types/provider/interface.ts +13 -0
  239. package/src/types/session/config.ts +27 -0
  240. package/src/types/session/events.ts +19 -0
  241. package/src/types/session/prepare-step.ts +17 -0
  242. package/src/types/session/records.ts +3 -0
  243. package/src/types/session/turn.ts +2 -1
  244. package/dist/learning/deprecated.d.ts +0 -86
  245. package/dist/learning/deprecated.d.ts.map +0 -1
  246. package/dist/learning/deprecated.js +0 -22
  247. package/dist/learning/deprecated.js.map +0 -1
  248. package/dist/manager/resident/activity.d.ts +0 -74
  249. package/dist/manager/resident/activity.d.ts.map +0 -1
  250. package/dist/manager/resident/activity.js +0 -125
  251. package/dist/manager/resident/activity.js.map +0 -1
  252. package/dist/manager/resident/agenda.d.ts +0 -167
  253. package/dist/manager/resident/agenda.d.ts.map +0 -1
  254. package/dist/manager/resident/agenda.js +0 -588
  255. package/dist/manager/resident/agenda.js.map +0 -1
  256. package/dist/manager/resident/consumption.d.ts +0 -98
  257. package/dist/manager/resident/consumption.d.ts.map +0 -1
  258. package/dist/manager/resident/consumption.js +0 -237
  259. package/dist/manager/resident/consumption.js.map +0 -1
  260. package/dist/manager/resident/delivery-window.d.ts +0 -28
  261. package/dist/manager/resident/delivery-window.d.ts.map +0 -1
  262. package/dist/manager/resident/delivery-window.js +0 -80
  263. package/dist/manager/resident/delivery-window.js.map +0 -1
  264. package/dist/manager/resident/evidence-recall.d.ts +0 -30
  265. package/dist/manager/resident/evidence-recall.d.ts.map +0 -1
  266. package/dist/manager/resident/evidence-recall.js +0 -297
  267. package/dist/manager/resident/evidence-recall.js.map +0 -1
  268. package/dist/manager/resident/history-disk.d.ts +0 -10
  269. package/dist/manager/resident/history-disk.d.ts.map +0 -1
  270. package/dist/manager/resident/history-disk.js +0 -50
  271. package/dist/manager/resident/history-disk.js.map +0 -1
  272. package/dist/manager/resident/history.d.ts +0 -115
  273. package/dist/manager/resident/history.d.ts.map +0 -1
  274. package/dist/manager/resident/history.js +0 -203
  275. package/dist/manager/resident/history.js.map +0 -1
  276. package/dist/manager/resident/host.d.ts +0 -112
  277. package/dist/manager/resident/host.d.ts.map +0 -1
  278. package/dist/manager/resident/host.js +0 -254
  279. package/dist/manager/resident/host.js.map +0 -1
  280. package/dist/manager/resident/initiative.d.ts +0 -86
  281. package/dist/manager/resident/initiative.d.ts.map +0 -1
  282. package/dist/manager/resident/initiative.js +0 -131
  283. package/dist/manager/resident/initiative.js.map +0 -1
  284. package/dist/manager/resident/loop.d.ts +0 -49
  285. package/dist/manager/resident/loop.d.ts.map +0 -1
  286. package/dist/manager/resident/loop.js +0 -75
  287. package/dist/manager/resident/loop.js.map +0 -1
  288. package/dist/manager/resident/outbox.d.ts +0 -124
  289. package/dist/manager/resident/outbox.d.ts.map +0 -1
  290. package/dist/manager/resident/outbox.js +0 -216
  291. package/dist/manager/resident/outbox.js.map +0 -1
  292. package/dist/manager/resident/proposal.d.ts +0 -65
  293. package/dist/manager/resident/proposal.d.ts.map +0 -1
  294. package/dist/manager/resident/proposal.js +0 -77
  295. package/dist/manager/resident/proposal.js.map +0 -1
  296. package/dist/manager/resident/store.d.ts +0 -108
  297. package/dist/manager/resident/store.d.ts.map +0 -1
  298. package/dist/manager/resident/store.js +0 -205
  299. package/dist/manager/resident/store.js.map +0 -1
  300. package/dist/manager/resident/tool-evidence.d.ts +0 -112
  301. package/dist/manager/resident/tool-evidence.d.ts.map +0 -1
  302. package/dist/manager/resident/tool-evidence.js +0 -289
  303. package/dist/manager/resident/tool-evidence.js.map +0 -1
  304. package/dist/prompt/resident-learning.d.ts +0 -29
  305. package/dist/prompt/resident-learning.d.ts.map +0 -1
  306. package/dist/prompt/resident-learning.js +0 -126
  307. package/dist/prompt/resident-learning.js.map +0 -1
  308. package/dist/prompt/resident-step.d.ts +0 -42
  309. package/dist/prompt/resident-step.d.ts.map +0 -1
  310. package/dist/prompt/resident-step.js +0 -137
  311. package/dist/prompt/resident-step.js.map +0 -1
  312. package/dist/tools/resident-history.d.ts +0 -12
  313. package/dist/tools/resident-history.d.ts.map +0 -1
  314. package/dist/tools/resident-history.js +0 -82
  315. package/dist/tools/resident-history.js.map +0 -1
  316. package/dist/tools/resident-tool-evidence.d.ts +0 -9
  317. package/dist/tools/resident-tool-evidence.d.ts.map +0 -1
  318. package/dist/tools/resident-tool-evidence.js +0 -61
  319. package/dist/tools/resident-tool-evidence.js.map +0 -1
  320. package/src/learning/deprecated.ts +0 -124
  321. package/src/manager/resident/activity.ts +0 -211
  322. package/src/manager/resident/agenda.ts +0 -937
  323. package/src/manager/resident/consumption.ts +0 -335
  324. package/src/manager/resident/delivery-window.ts +0 -99
  325. package/src/manager/resident/evidence-recall.ts +0 -369
  326. package/src/manager/resident/history-disk.ts +0 -63
  327. package/src/manager/resident/history.ts +0 -348
  328. package/src/manager/resident/host.ts +0 -390
  329. package/src/manager/resident/initiative.ts +0 -231
  330. package/src/manager/resident/loop.ts +0 -119
  331. package/src/manager/resident/outbox.ts +0 -341
  332. package/src/manager/resident/proposal.ts +0 -119
  333. package/src/manager/resident/store.ts +0 -279
  334. package/src/manager/resident/tool-evidence.ts +0 -455
  335. package/src/prompt/resident-learning.ts +0 -152
  336. package/src/prompt/resident-step.ts +0 -182
  337. package/src/tools/resident-history.ts +0 -88
  338. package/src/tools/resident-tool-evidence.ts +0 -72
@@ -317,6 +317,11 @@ export function createTurnReporter(parentLogger?: Logger): TurnReporter {
317
317
  'namzu.monitor.chars': event.text.length,
318
318
  })
319
319
  break
320
+ case 'memory_recalled':
321
+ log.debug('Stored memories recalled into the turn', {
322
+ 'namzu.memory.count': event.memories.length,
323
+ })
324
+ break
320
325
  case 'memory_consolidated':
321
326
  log.info('Turn learnings consolidated into the memory store', {
322
327
  'namzu.memory.id': event.memoryId,
@@ -118,6 +118,12 @@ export interface AcpRequestPermissionParams {
118
118
  readonly isDestructive: boolean
119
119
  /** For `edit` and `write` calls, when the agent could compute it. */
120
120
  readonly preview?: AcpFileChangePreview
121
+ /**
122
+ * True on a call the agent asks about every time, whatever the person
123
+ * said before. An `approve_all` given to a request holding one approves
124
+ * that request only. Absent on an ordinary call and from an older agent.
125
+ */
126
+ readonly alwaysAsk?: true
121
127
  }[]
122
128
  }
123
129
 
@@ -226,6 +226,10 @@ export interface BaseAgentConfig {
226
226
  */
227
227
  thinking?: import('../provider/index.js').ThinkingConfig
228
228
  effort?: import('../provider/index.js').ReasoningEffort
229
+ /** How the turn bounds its reasoning; see {@link import('../session/config.js').TurnConfig.reasoning}. */
230
+ reasoning?: import('../session/config.js').TurnConfig['reasoning']
231
+ /** Ask once for a check of edits before a turn ends; see {@link import('../session/config.js').TurnConfig.completionAudit}. */
232
+ completionAudit?: boolean
229
233
 
230
234
  /**
231
235
  * Deduplicate a retried invocation instead of running it twice.
@@ -70,6 +70,14 @@ export type HITLResumeDecision =
70
70
  modifications: ToolModification[]
71
71
  /** See the `approve_tools` field of the same name. */
72
72
  confirmedEscalations?: readonly string[]
73
+ /**
74
+ * Why a policy (not a person) denied a call, by call id. A `deny` modification
75
+ * whose id is listed here carries this text to the model in place of the
76
+ * generic "declined" answer and is not recorded as a person's No. It lets a
77
+ * handler with nobody to ask refuse one call of a batch for its own reason
78
+ * while the other calls in the batch run.
79
+ */
80
+ policyRefusals?: Readonly<Record<string, string>>
73
81
  }
74
82
  | {
75
83
  action: 'reject_tools'
@@ -11,7 +11,7 @@ import type { Id } from './brand.js'
11
11
  * for values received from JSON, flags, URLs, or other untyped boundaries.
12
12
  */
13
13
  /**
14
- * One turn of a session: a user prompt (or a goal round, resident step or
14
+ * One turn of a session: a user prompt (or a goal round or a
15
15
  * verification step) and everything the agent did to answer it. Recorded in
16
16
  * the session log between `turn_started` and `turn_completed`/`turn_failed`.
17
17
  */
@@ -365,6 +365,7 @@ export const RUNTIME_CONTEXT_MESSAGE_KINDS = [
365
365
  'limit-finalization',
366
366
  'peer-message',
367
367
  'peer-notice',
368
+ 'progress-nudge',
368
369
  'reminder',
369
370
  'repeat-call',
370
371
  'refusal-retry',
@@ -179,6 +179,19 @@ export interface LLMProvider {
179
179
  thinking?: import('./chat.js').ThinkingConfig,
180
180
  ): readonly import('./chat.js').ReasoningEffort[] | undefined
181
181
 
182
+ /**
183
+ * Whether `model` takes a forced tool choice (`toolChoice: 'required'` or a
184
+ * named function) under the thinking configuration the request will carry.
185
+ *
186
+ * The kernel asks before it requires a tool call on a step it wants to act,
187
+ * and when the answer is `false` it keeps the step at low effort and asks the
188
+ * model in words instead of sending a choice the driver would refuse. Optional:
189
+ * a provider that does not declare it is treated as taking the choice, so
190
+ * every existing driver behaves as before. A wrapper that rebuilds a provider
191
+ * forwards it.
192
+ */
193
+ acceptsForcedToolChoiceFor?(model: string, thinking?: import('./chat.js').ThinkingConfig): boolean
194
+
182
195
  /**
183
196
  * The effort a model uses when a request omits an explicit level.
184
197
  *
@@ -68,6 +68,33 @@ export interface TurnConfig {
68
68
  * high-effort and silently was not is worse than a startup error.
69
69
  */
70
70
  effort?: import('../provider/index.js').ReasoningEffort
71
+
72
+ /**
73
+ * How the turn bounds its reasoning. On by default.
74
+ *
75
+ * Two guards live here. A step that streams more than `maxTokens` of
76
+ * reasoning before it has made a call is cut short, and the model is told
77
+ * to act; when the cap is absent it is 24,000 tokens at medium effort and
78
+ * above and not applied below that, and `0` removes it. The stall monitor
79
+ * counts steps that changed nothing (the task list does not count), nudges
80
+ * the model after a run of them and then makes the next step an action step;
81
+ * `stall: false` turns it off.
82
+ */
83
+ reasoning?: import('../../runtime/query/turn/stall-monitor.js').ReasoningPaceConfig
84
+
85
+ /**
86
+ * Ask once, before a turn that changed files ends, for a check of the change.
87
+ *
88
+ * The audit reads the turn's own record: a successful `edit`, `write`,
89
+ * `apply_patch` or `notebook_edit` call is a change, and a successful shell
90
+ * call after the last change that runs a test, lint, format-check, typecheck
91
+ * or build target is a check. When the model tries to end the turn with a
92
+ * change and no check after it, one reminder is added and the loop goes on.
93
+ * That is the only block a turn gets, so the audit cannot trap a run.
94
+ *
95
+ * Off when absent, so an embedding host sees no change.
96
+ */
97
+ completionAudit?: boolean
71
98
  /** Provider-hosted search for this turn. Explicit opt-in; no local network permission. */
72
99
  webSearch?: import('../provider/index.js').ChatCompletionParams['webSearch']
73
100
  /** Cumulative parent-and-descendant tokens; 0 is unlimited with usage accounting. */
@@ -736,6 +736,25 @@ type CoreSessionEvent =
736
736
  kind: 'output' | 'notice'
737
737
  text: string
738
738
  }
739
+ /**
740
+ * A recall step put stored memories into the conversation for this turn:
741
+ * the ones newly added on that step, never ones the history already
742
+ * carried. Emitted after the entry was recorded, so a host can show which
743
+ * memories went with a message and let the person delete them.
744
+ */
745
+ | {
746
+ type: 'memory_recalled'
747
+ sessionId: SessionId
748
+ turnId?: TurnId
749
+ memories: Array<{
750
+ id: string
751
+ name?: string
752
+ type?: string
753
+ title: string
754
+ origin: 'operator' | 'model' | 'derived'
755
+ updatedAt: number
756
+ }>
757
+ }
739
758
  /**
740
759
  * What the turn learned was written to the host's memory store: its
741
760
  * decisions, discoveries and failures as one entry a later session can
@@ -255,6 +255,23 @@ export interface RecordedContextItem {
255
255
  /** Lowercase words joined by hyphens (for example `repository`). */
256
256
  readonly key: string
257
257
  readonly text: string
258
+ /**
259
+ * The stored memories the text carries, when it is recalled memory. Once
260
+ * the entry is recorded the loop reports them with a `memory_recalled`
261
+ * event; an item that adds nothing reports nothing.
262
+ */
263
+ readonly recalledMemories?: readonly RecalledMemory[]
264
+ }
265
+
266
+ /** One stored memory a recall step put into the conversation. */
267
+ export interface RecalledMemory {
268
+ readonly id: string
269
+ readonly name?: string
270
+ readonly type?: string
271
+ readonly title: string
272
+ /** Who wrote it: the operator, the model (`save_memory`), or a turn on its own. */
273
+ readonly origin: 'operator' | 'model' | 'derived'
274
+ readonly updatedAt: number
258
275
  }
259
276
 
260
277
  /**
@@ -141,6 +141,8 @@ export interface RecordEnvelope {
141
141
 
142
142
  export const OriginSchema = z
143
143
  .object({
144
+ // 'resident' and 'resident-step' are no longer written; they stay so logs
145
+ // recorded while the resident feature existed still parse.
144
146
  protocol: z.enum(['cli', 'sdk', 'ag-ui', 'a2a', 'acp', 'http', 'desktop', 'resident']),
145
147
  externalSessionId: text.optional(),
146
148
  externalTurnId: text.optional(),
@@ -671,6 +673,7 @@ const SESSION_EVENT_TYPE_TABLE: Record<SessionEventType, true> = {
671
673
  background_job_exited: true,
672
674
  monitor_event: true,
673
675
  memory_consolidated: true,
676
+ memory_recalled: true,
674
677
  turn_completed: true,
675
678
  turn_failed: true,
676
679
  capability_warning: true,
@@ -92,9 +92,10 @@ export type OriginProtocol =
92
92
  | 'acp'
93
93
  | 'http'
94
94
  | 'desktop'
95
+ // Kept so logs written while the resident feature existed still parse.
95
96
  | 'resident'
96
97
 
97
- /** What kind of work a turn is. A prompt, a goal round, a resident step and a verification step are each a new turn. */
98
+ /** What kind of work a turn is. A prompt, a goal round and a verification step are each a new turn. 'resident-step' is no longer written; it stays in the union so older logs still parse. */
98
99
  export type TurnOriginKind = 'prompt' | 'goal-round' | 'resident-step' | 'verification'
99
100
 
100
101
  export interface Origin {
@@ -1,86 +0,0 @@
1
- /**
2
- * The learning module used to live under `manager/resident` and carried a
3
- * `Resident` prefix. Learning is a feature of all of Namzu, not of residents,
4
- * so every name now lives in `learning/` without the prefix. The old names stay
5
- * as aliases of the new ones until the next major release.
6
- */
7
- import { runLearningCycle } from './cycle.js';
8
- import type * as Cycle from './cycle.js';
9
- import type * as Observation from './observation.js';
10
- import { hashLearningSkill, projectLearning } from './skill.js';
11
- import type * as Skill from './skill.js';
12
- import { SqliteLearningStore, runStoredLearningCycle, runStoredLearningFromObservations } from './store.js';
13
- import type * as Store from './store.js';
14
- /** @deprecated Renamed to `LearningEvidence`; the old name is removed in the next major release. */
15
- export type ResidentLearningEvidence = Skill.LearningEvidence;
16
- /** @deprecated Renamed to `LearningSkillCandidate`; the old name is removed in the next major release. */
17
- export type ResidentSkillCandidate = Skill.LearningSkillCandidate;
18
- /** @deprecated Renamed to `LearnedSkill`; the old name is removed in the next major release. */
19
- export type ResidentLearnedSkill = Skill.LearnedSkill;
20
- /** @deprecated Renamed to `LearningState`; the old name is removed in the next major release. */
21
- export type ResidentLearningState = Skill.LearningState;
22
- /** @deprecated Renamed to `LearningProfileUpdate`; the old name is removed in the next major release. */
23
- export type ResidentProfileUpdate = Skill.LearningProfileUpdate;
24
- /** @deprecated Renamed to `LearningSkillEvaluation`; the old name is removed in the next major release. */
25
- export type ResidentSkillEvaluation = Skill.LearningSkillEvaluation;
26
- /** @deprecated Renamed to `LearningProjectionOptions`; the old name is removed in the next major release. */
27
- export type ResidentLearningProjectionOptions = Skill.LearningProjectionOptions;
28
- /** @deprecated Renamed to `LearningSource`; the old name is removed in the next major release. */
29
- export type ResidentLearningSource = Skill.LearningSource;
30
- /** @deprecated Renamed to `LearningProjection`; the old name is removed in the next major release. */
31
- export type ResidentLearningProjection = Skill.LearningProjection;
32
- /** @deprecated Renamed to `LearningStage`; the old name is removed in the next major release. */
33
- export type ResidentLearningStage = Cycle.LearningStage;
34
- /** @deprecated Renamed to `LearningReceipt`; the old name is removed in the next major release. */
35
- export type ResidentLearningReceipt = Cycle.LearningReceipt;
36
- /** @deprecated Renamed to `LearningConsumption`; the old name is removed in the next major release. */
37
- export type ResidentLearningConsumption = Cycle.LearningConsumption;
38
- /** @deprecated Renamed to `LearningCycleEvent`; the old name is removed in the next major release. */
39
- export type ResidentLearningCycleEvent = Cycle.LearningCycleEvent;
40
- /** @deprecated Renamed to `LearningCycleContext`; the old name is removed in the next major release. */
41
- export type ResidentLearningCycleContext = Cycle.LearningCycleContext;
42
- /** @deprecated Renamed to `LearningGenerationContext`; the old name is removed in the next major release. */
43
- export type ResidentLearningGenerationContext = Cycle.LearningGenerationContext;
44
- /** @deprecated Renamed to `LearningExplorationContext`; the old name is removed in the next major release. */
45
- export type ResidentLearningExplorationContext = Cycle.LearningExplorationContext;
46
- /** @deprecated Renamed to `LearningExploration`; the old name is removed in the next major release. */
47
- export type ResidentLearningExploration = Cycle.LearningExploration;
48
- /** @deprecated Renamed to `LearningEvaluationContext`; the old name is removed in the next major release. */
49
- export type ResidentLearningEvaluationContext = Cycle.LearningEvaluationContext;
50
- /** @deprecated Renamed to `LearningCycleOptions`; the old name is removed in the next major release. */
51
- export type ResidentLearningCycleOptions = Cycle.LearningCycleOptions;
52
- /** @deprecated Renamed to `LearningCycleResult`; the old name is removed in the next major release. */
53
- export type ResidentLearningCycleResult = Cycle.LearningCycleResult;
54
- /** @deprecated Renamed to `SqliteLearningStoreOptions`; the old name is removed in the next major release. */
55
- export type SqliteResidentLearningStoreOptions = Store.SqliteLearningStoreOptions;
56
- /** @deprecated Renamed to `LearningArtifact`; the old name is removed in the next major release. */
57
- export type ResidentLearningArtifact = Store.LearningArtifact;
58
- /** @deprecated Renamed to `LearningRecordedUsage`; the old name is removed in the next major release. */
59
- export type ResidentLearningRecordedUsage = Store.LearningRecordedUsage;
60
- /** @deprecated Renamed to `LearningCycleSummary`; the old name is removed in the next major release. */
61
- export type ResidentLearningCycleSummary = Store.LearningCycleSummary;
62
- /** @deprecated Renamed to `LearningDiscoveryOptions`; the old name is removed in the next major release. */
63
- export type ResidentLearningDiscoveryOptions = Store.LearningDiscoveryOptions;
64
- /** @deprecated Renamed to `LearningDiscoveryResult`; the old name is removed in the next major release. */
65
- export type ResidentLearningDiscoveryResult = Store.LearningDiscoveryResult;
66
- /** @deprecated Renamed to `LearningObservation`; the old name is removed in the next major release. */
67
- export type ResidentLearningObservation = Observation.LearningObservation;
68
- /** @deprecated Renamed to `LearningObservationRecord`; the old name is removed in the next major release. */
69
- export type ResidentLearningObservationRecord = Observation.LearningObservationRecord;
70
- /** @deprecated Renamed to `LearningTarget`; the old name is removed in the next major release. */
71
- export type ResidentLearningTarget = Observation.LearningTarget;
72
- /** @deprecated Renamed to `hashLearningSkill`; the old name is removed in the next major release. */
73
- export declare const hashResidentSkill: typeof hashLearningSkill;
74
- /** @deprecated Renamed to `projectLearning`; the old name is removed in the next major release. */
75
- export declare const projectResidentLearning: typeof projectLearning;
76
- /** @deprecated Renamed to `runLearningCycle`; the old name is removed in the next major release. */
77
- export declare const runResidentLearningCycle: typeof runLearningCycle;
78
- /** @deprecated Renamed to `runStoredLearningCycle`; the old name is removed in the next major release. */
79
- export declare const runStoredResidentLearningCycle: typeof runStoredLearningCycle;
80
- /** @deprecated Renamed to `runStoredLearningFromObservations`; the old name is removed in the next major release. */
81
- export declare const runStoredResidentLearningFromObservations: typeof runStoredLearningFromObservations;
82
- /** @deprecated Renamed to `SqliteLearningStore`; the old name is removed in the next major release. */
83
- export declare const SqliteResidentLearningStore: typeof SqliteLearningStore;
84
- /** @deprecated Renamed to `SqliteLearningStore`; the old name is removed in the next major release. */
85
- export type SqliteResidentLearningStore = SqliteLearningStore;
86
- //# sourceMappingURL=deprecated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.d.ts","sourceRoot":"","sources":["../../src/learning/deprecated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,KAAK,WAAW,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AACxC,OAAO,EACN,mBAAmB,EACnB,sBAAsB,EACtB,iCAAiC,EACjC,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,KAAK,KAAK,MAAM,YAAY,CAAA;AAExC,oGAAoG;AACpG,MAAM,MAAM,wBAAwB,GAAG,KAAK,CA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MAAM,2BAA2B,GAAG,mBAAmB,CAAA"}
@@ -1,22 +0,0 @@
1
- /**
2
- * The learning module used to live under `manager/resident` and carried a
3
- * `Resident` prefix. Learning is a feature of all of Namzu, not of residents,
4
- * so every name now lives in `learning/` without the prefix. The old names stay
5
- * as aliases of the new ones until the next major release.
6
- */
7
- import { runLearningCycle } from './cycle.js';
8
- import { hashLearningSkill, projectLearning } from './skill.js';
9
- import { SqliteLearningStore, runStoredLearningCycle, runStoredLearningFromObservations, } from './store.js';
10
- /** @deprecated Renamed to `hashLearningSkill`; the old name is removed in the next major release. */
11
- export const hashResidentSkill = hashLearningSkill;
12
- /** @deprecated Renamed to `projectLearning`; the old name is removed in the next major release. */
13
- export const projectResidentLearning = projectLearning;
14
- /** @deprecated Renamed to `runLearningCycle`; the old name is removed in the next major release. */
15
- export const runResidentLearningCycle = runLearningCycle;
16
- /** @deprecated Renamed to `runStoredLearningCycle`; the old name is removed in the next major release. */
17
- export const runStoredResidentLearningCycle = runStoredLearningCycle;
18
- /** @deprecated Renamed to `runStoredLearningFromObservations`; the old name is removed in the next major release. */
19
- export const runStoredResidentLearningFromObservations = runStoredLearningFromObservations;
20
- /** @deprecated Renamed to `SqliteLearningStore`; the old name is removed in the next major release. */
21
- export const SqliteResidentLearningStore = SqliteLearningStore;
22
- //# sourceMappingURL=deprecated.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deprecated.js","sourceRoot":"","sources":["../../src/learning/deprecated.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAG7C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE/D,OAAO,EACN,mBAAmB,EACnB,sBAAsB,EACtB,iCAAiC,GACjC,MAAM,YAAY,CAAA;AA0FnB,qGAAqG;AACrG,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAA;AAElD,mGAAmG;AACnG,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAA;AAEtD,oGAAoG;AACpG,MAAM,CAAC,MAAM,wBAAwB,GAAG,gBAAgB,CAAA;AAExD,0GAA0G;AAC1G,MAAM,CAAC,MAAM,8BAA8B,GAAG,sBAAsB,CAAA;AAEpE,qHAAqH;AACrH,MAAM,CAAC,MAAM,yCAAyC,GAAG,iCAAiC,CAAA;AAE1F,uGAAuG;AACvG,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAA"}
@@ -1,74 +0,0 @@
1
- import type { ResidentAgendaState } from './agenda.js';
2
- import { type ResidentHistoryReadBudget } from './history-disk.js';
3
- /**
4
- * @experimental An immutable upper boundary; new work requires a new source.
5
- *
6
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
7
- */
8
- export interface ResidentActivityScope {
9
- readonly tenantId: string;
10
- readonly agentKey: string;
11
- readonly throughRevision: number;
12
- }
13
- /**
14
- * @experimental Admission is authority to inspect an attempt, not proof that it executed.
15
- *
16
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
17
- */
18
- export interface ResidentAdmission {
19
- readonly revision: number;
20
- readonly pursuitRevision: number;
21
- readonly pursuitId: string;
22
- readonly claimId: string;
23
- readonly step: number;
24
- readonly objective: string;
25
- }
26
- /**
27
- * @experimental Settlement is an agenda decision, not proof of verification or delivery.
28
- *
29
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
30
- */
31
- export interface ResidentSettlement {
32
- readonly revision: number;
33
- readonly pursuitId: string;
34
- readonly claimId: string;
35
- readonly outcome: 'wait' | 'complete' | 'blocked';
36
- }
37
- /**
38
- * @experimental Forward pages; cursor is the next revision to inspect, initially 1.
39
- *
40
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
41
- */
42
- export interface ResidentActivityOptions {
43
- readonly cursor?: number;
44
- readonly maxRevisions?: number;
45
- readonly maxReadBytes?: number;
46
- }
47
- /**
48
- * @experimental Gaps stay explicit; counts cover only the scanned revision range.
49
- *
50
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
51
- */
52
- export interface ResidentActivityPage {
53
- readonly scope: ResidentActivityScope;
54
- readonly fromRevision: number;
55
- readonly throughRevision: number;
56
- readonly nextCursor: number | null;
57
- readonly scannedBytes: number;
58
- readonly unavailableRevisions: readonly number[];
59
- readonly admissions: readonly ResidentAdmission[];
60
- readonly settlements: readonly ResidentSettlement[];
61
- readonly archivedPursuits: readonly string[];
62
- }
63
- /**
64
- * @experimental A backend must enforce scope, cancellation and read bounds.
65
- *
66
- * @deprecated Residents are deprecated and removed in the next major release. Learning (`runLearningCycle` and the other `Learning*` names) keeps working, but `runLearningCycle` still takes a resident agenda until learning gets its own activation target in the next major release; for long-running work use scheduled tasks (`LocalTaskScheduler`), session goals and background agents.
67
- */
68
- export interface ResidentActivitySource {
69
- readonly scope: ResidentActivityScope;
70
- read(options?: ResidentActivityOptions, signal?: AbortSignal): Promise<ResidentActivityPage>;
71
- }
72
- /** Internal adapter for the immutable disk agenda. */
73
- export declare function createResidentActivitySource(scopeInput: ResidentActivityScope, load: (revision: number, budget: ResidentHistoryReadBudget) => Promise<ResidentAgendaState>): ResidentActivitySource;
74
- //# sourceMappingURL=activity.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../../../src/manager/resident/activity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACtD,OAAO,EAA4B,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAE5F;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;CACjD;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAA;IACrC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAA;IAChD,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACjD,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACnD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAA;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAA;IACrC,IAAI,CAAC,OAAO,CAAC,EAAE,uBAAuB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CAC5F;AAED,sDAAsD;AACtD,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,qBAAqB,EACjC,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,yBAAyB,KAAK,OAAO,CAAC,mBAAmB,CAAC,GACzF,sBAAsB,CA+HxB"}
@@ -1,125 +0,0 @@
1
- import { z } from 'zod';
2
- import { ResidentHistoryPageLimit } from './history-disk.js';
3
- /** Internal adapter for the immutable disk agenda. */
4
- export function createResidentActivitySource(scopeInput, load) {
5
- const scope = Object.freeze(z
6
- .object({
7
- tenantId: z.string().uuid(),
8
- agentKey: z.string().min(1).max(200),
9
- throughRevision: z.number().int().positive().safe(),
10
- })
11
- .parse(scopeInput));
12
- return {
13
- scope,
14
- async read(options = {}, signal) {
15
- const from = z
16
- .number()
17
- .int()
18
- .positive()
19
- .max(scope.throughRevision)
20
- .parse(options.cursor ?? 1);
21
- const count = z
22
- .number()
23
- .int()
24
- .positive()
25
- .max(32)
26
- .parse(options.maxRevisions ?? 32);
27
- const budget = {
28
- remaining: z
29
- .number()
30
- .int()
31
- .positive()
32
- .max(8 * 1024 * 1024)
33
- .parse(options.maxReadBytes ?? 8 * 1024 * 1024),
34
- bytesRead: 0,
35
- signal,
36
- };
37
- const unavailable = new Set();
38
- const read = async (revision) => {
39
- signal?.throwIfAborted();
40
- try {
41
- const state = await load(revision, budget);
42
- if (state.tenantId !== scope.tenantId ||
43
- state.agentKey !== scope.agentKey ||
44
- state.revision !== revision)
45
- throw new Error('Resident activity scope mismatch.');
46
- return state;
47
- }
48
- catch (error) {
49
- signal?.throwIfAborted();
50
- if (error instanceof ResidentHistoryPageLimit)
51
- throw error;
52
- unavailable.add(revision);
53
- return null;
54
- }
55
- };
56
- const admissions = [];
57
- const settlements = [];
58
- const archivedPursuits = [];
59
- let through = from - 1;
60
- try {
61
- let before = from > 1 ? await read(from - 1) : null;
62
- for (let revision = from; revision <= Math.min(scope.throughRevision, from + count - 1); revision++) {
63
- const after = await read(revision);
64
- if (before && after) {
65
- for (const pursuit of after.pursuits) {
66
- const previous = before.pursuits.find((p) => p.id === pursuit.id)?.state;
67
- const current = pursuit.state;
68
- if (!previous)
69
- continue;
70
- if (current.revision === previous.revision + 1 &&
71
- previous.phase !== 'running' &&
72
- current.phase === 'running' &&
73
- current.claimId &&
74
- current.stepsAdmitted === previous.stepsAdmitted + 1) {
75
- admissions.push({
76
- revision,
77
- pursuitRevision: current.revision,
78
- pursuitId: pursuit.id,
79
- claimId: current.claimId,
80
- step: current.stepsAdmitted,
81
- objective: current.objective,
82
- });
83
- }
84
- if (current.revision === previous.revision + 1 &&
85
- previous.phase === 'running' &&
86
- previous.claimId &&
87
- current.phase !== 'running' &&
88
- current.claimId === null &&
89
- current.stepsAdmitted === previous.stepsAdmitted) {
90
- settlements.push({
91
- revision,
92
- pursuitId: pursuit.id,
93
- claimId: previous.claimId,
94
- outcome: current.phase === 'waiting' ? 'wait' : current.phase,
95
- });
96
- }
97
- }
98
- if (after.archiveHead === revision)
99
- for (const pursuit of before.pursuits)
100
- if (!after.pursuits.some((p) => p.id === pursuit.id))
101
- archivedPursuits.push(pursuit.id);
102
- }
103
- through = revision;
104
- before = after;
105
- }
106
- }
107
- catch (error) {
108
- if (!(error instanceof ResidentHistoryPageLimit))
109
- throw error;
110
- }
111
- return {
112
- scope,
113
- fromRevision: from,
114
- throughRevision: through,
115
- nextCursor: through < scope.throughRevision ? through + 1 : null,
116
- scannedBytes: budget.bytesRead,
117
- unavailableRevisions: [...unavailable],
118
- admissions,
119
- settlements,
120
- archivedPursuits,
121
- };
122
- },
123
- };
124
- }
125
- //# sourceMappingURL=activity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"activity.js","sourceRoot":"","sources":["../../../src/manager/resident/activity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,wBAAwB,EAAkC,MAAM,mBAAmB,CAAA;AA6E5F,sDAAsD;AACtD,MAAM,UAAU,4BAA4B,CAC3C,UAAiC,EACjC,IAA2F;IAE3F,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAC1B,CAAC;SACC,MAAM,CAAC;QACP,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;QAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;QACpC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;KACnD,CAAC;SACD,KAAK,CAAC,UAAU,CAAC,CACnB,CAAA;IACD,OAAO;QACN,KAAK;QACL,KAAK,CAAC,IAAI,CAAC,UAAmC,EAAE,EAAE,MAAoB;YACrE,MAAM,IAA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