@namzu/sdk 54.0.0 → 55.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 (325) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +1 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/compaction/extractor.d.ts.map +1 -1
  6. package/dist/compaction/extractor.js +5 -1
  7. package/dist/compaction/extractor.js.map +1 -1
  8. package/dist/compaction/managers/structured.d.ts.map +1 -1
  9. package/dist/compaction/managers/structured.js +5 -0
  10. package/dist/compaction/managers/structured.js.map +1 -1
  11. package/dist/compaction/manual.d.ts.map +1 -1
  12. package/dist/compaction/manual.js +6 -0
  13. package/dist/compaction/manual.js.map +1 -1
  14. package/dist/compaction/serializer.d.ts +6 -0
  15. package/dist/compaction/serializer.d.ts.map +1 -1
  16. package/dist/compaction/serializer.js +21 -3
  17. package/dist/compaction/serializer.js.map +1 -1
  18. package/dist/compaction/verifier.d.ts.map +1 -1
  19. package/dist/compaction/verifier.js +27 -6
  20. package/dist/compaction/verifier.js.map +1 -1
  21. package/dist/constants/compaction/index.d.ts +1 -0
  22. package/dist/constants/compaction/index.d.ts.map +1 -1
  23. package/dist/constants/compaction/index.js +1 -0
  24. package/dist/constants/compaction/index.js.map +1 -1
  25. package/dist/{manager/resident/learning-cycle.d.ts → learning/cycle.d.ts} +45 -36
  26. package/dist/learning/cycle.d.ts.map +1 -0
  27. package/dist/{manager/resident/learning-cycle.js → learning/cycle.js} +52 -20
  28. package/dist/learning/cycle.js.map +1 -0
  29. package/dist/learning/deprecated.d.ts +86 -0
  30. package/dist/learning/deprecated.d.ts.map +1 -0
  31. package/dist/learning/deprecated.js +22 -0
  32. package/dist/learning/deprecated.js.map +1 -0
  33. package/dist/learning/experience-store.d.ts +35 -0
  34. package/dist/learning/experience-store.d.ts.map +1 -0
  35. package/dist/learning/experience-store.js +143 -0
  36. package/dist/learning/experience-store.js.map +1 -0
  37. package/dist/learning/experience.d.ts +150 -0
  38. package/dist/learning/experience.d.ts.map +1 -0
  39. package/dist/learning/experience.js +146 -0
  40. package/dist/learning/experience.js.map +1 -0
  41. package/dist/learning/generator.d.ts +118 -0
  42. package/dist/learning/generator.d.ts.map +1 -0
  43. package/dist/learning/generator.js +275 -0
  44. package/dist/learning/generator.js.map +1 -0
  45. package/dist/learning/leak-tripwire.d.ts +66 -0
  46. package/dist/learning/leak-tripwire.d.ts.map +1 -0
  47. package/dist/learning/leak-tripwire.js +208 -0
  48. package/dist/learning/leak-tripwire.js.map +1 -0
  49. package/dist/{manager/resident/learning-observation.d.ts → learning/observation.d.ts} +4 -4
  50. package/dist/learning/observation.d.ts.map +1 -0
  51. package/dist/{manager/resident/learning-observation.js → learning/observation.js} +3 -3
  52. package/dist/learning/observation.js.map +1 -0
  53. package/dist/{manager/resident/learning.d.ts → learning/skill.d.ts} +29 -29
  54. package/dist/learning/skill.d.ts.map +1 -0
  55. package/dist/{manager/resident/learning.js → learning/skill.js} +27 -27
  56. package/dist/learning/skill.js.map +1 -0
  57. package/dist/{manager/resident/learning-store.d.ts → learning/store.d.ts} +38 -31
  58. package/dist/learning/store.d.ts.map +1 -0
  59. package/dist/{manager/resident/learning-store.js → learning/store.js} +52 -20
  60. package/dist/learning/store.js.map +1 -0
  61. package/dist/manager/resident/activity.d.ts +30 -6
  62. package/dist/manager/resident/activity.d.ts.map +1 -1
  63. package/dist/manager/resident/activity.js.map +1 -1
  64. package/dist/manager/resident/agenda.d.ts +42 -12
  65. package/dist/manager/resident/agenda.d.ts.map +1 -1
  66. package/dist/manager/resident/agenda.js +9 -7
  67. package/dist/manager/resident/agenda.js.map +1 -1
  68. package/dist/manager/resident/consumption.d.ts +27 -5
  69. package/dist/manager/resident/consumption.d.ts.map +1 -1
  70. package/dist/manager/resident/consumption.js +2 -0
  71. package/dist/manager/resident/consumption.js.map +1 -1
  72. package/dist/manager/resident/delivery-window.d.ts +7 -1
  73. package/dist/manager/resident/delivery-window.d.ts.map +1 -1
  74. package/dist/manager/resident/delivery-window.js +2 -0
  75. package/dist/manager/resident/delivery-window.js.map +1 -1
  76. package/dist/manager/resident/evidence-recall.d.ts +7 -1
  77. package/dist/manager/resident/evidence-recall.d.ts.map +1 -1
  78. package/dist/manager/resident/evidence-recall.js +2 -0
  79. package/dist/manager/resident/evidence-recall.js.map +1 -1
  80. package/dist/manager/resident/history.d.ts +45 -9
  81. package/dist/manager/resident/history.d.ts.map +1 -1
  82. package/dist/manager/resident/history.js.map +1 -1
  83. package/dist/manager/resident/host.d.ts +44 -10
  84. package/dist/manager/resident/host.d.ts.map +1 -1
  85. package/dist/manager/resident/host.js +4 -2
  86. package/dist/manager/resident/host.js.map +1 -1
  87. package/dist/manager/resident/initiative.d.ts +32 -6
  88. package/dist/manager/resident/initiative.d.ts.map +1 -1
  89. package/dist/manager/resident/initiative.js +2 -0
  90. package/dist/manager/resident/initiative.js.map +1 -1
  91. package/dist/manager/resident/loop.d.ts +22 -4
  92. package/dist/manager/resident/loop.d.ts.map +1 -1
  93. package/dist/manager/resident/loop.js +7 -1
  94. package/dist/manager/resident/loop.js.map +1 -1
  95. package/dist/manager/resident/outbox.d.ts +42 -8
  96. package/dist/manager/resident/outbox.d.ts.map +1 -1
  97. package/dist/manager/resident/outbox.js +2 -0
  98. package/dist/manager/resident/outbox.js.map +1 -1
  99. package/dist/manager/resident/proposal.d.ts +19 -5
  100. package/dist/manager/resident/proposal.d.ts.map +1 -1
  101. package/dist/manager/resident/proposal.js +2 -0
  102. package/dist/manager/resident/proposal.js.map +1 -1
  103. package/dist/manager/resident/store.d.ts +31 -9
  104. package/dist/manager/resident/store.d.ts.map +1 -1
  105. package/dist/manager/resident/store.js +7 -1
  106. package/dist/manager/resident/store.js.map +1 -1
  107. package/dist/manager/resident/tool-evidence.d.ts +45 -9
  108. package/dist/manager/resident/tool-evidence.d.ts.map +1 -1
  109. package/dist/manager/resident/tool-evidence.js +5 -1
  110. package/dist/manager/resident/tool-evidence.js.map +1 -1
  111. package/dist/prompt/coding-agent-doctrine.d.ts +3 -3
  112. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  113. package/dist/prompt/coding-agent-doctrine.js +18 -20
  114. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  115. package/dist/prompt/resident-learning.d.ts +12 -2
  116. package/dist/prompt/resident-learning.d.ts.map +1 -1
  117. package/dist/prompt/resident-learning.js +6 -5
  118. package/dist/prompt/resident-learning.js.map +1 -1
  119. package/dist/prompt/resident-step.d.ts +10 -4
  120. package/dist/prompt/resident-step.d.ts.map +1 -1
  121. package/dist/prompt/resident-step.js +6 -4
  122. package/dist/prompt/resident-step.js.map +1 -1
  123. package/dist/public-runtime.d.ts +10 -4
  124. package/dist/public-runtime.d.ts.map +1 -1
  125. package/dist/public-runtime.js +11 -4
  126. package/dist/public-runtime.js.map +1 -1
  127. package/dist/public-types.d.ts +9 -4
  128. package/dist/public-types.d.ts.map +1 -1
  129. package/dist/runtime/query/checkpoint.d.ts +12 -2
  130. package/dist/runtime/query/checkpoint.d.ts.map +1 -1
  131. package/dist/runtime/query/checkpoint.js +42 -8
  132. package/dist/runtime/query/checkpoint.js.map +1 -1
  133. package/dist/runtime/query/executor.d.ts +39 -1
  134. package/dist/runtime/query/executor.d.ts.map +1 -1
  135. package/dist/runtime/query/executor.js +115 -7
  136. package/dist/runtime/query/executor.js.map +1 -1
  137. package/dist/runtime/query/index.d.ts +18 -0
  138. package/dist/runtime/query/index.d.ts.map +1 -1
  139. package/dist/runtime/query/index.js +20 -1
  140. package/dist/runtime/query/index.js.map +1 -1
  141. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  142. package/dist/runtime/query/iteration/index.js +17 -8
  143. package/dist/runtime/query/iteration/index.js.map +1 -1
  144. package/dist/runtime/query/iteration/phases/context.d.ts +24 -2
  145. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  146. package/dist/runtime/query/iteration/phases/context.js +22 -22
  147. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  148. package/dist/runtime/query/iteration/phases/per-call-review.d.ts +87 -0
  149. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -0
  150. package/dist/runtime/query/iteration/phases/per-call-review.js +513 -0
  151. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -0
  152. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  153. package/dist/runtime/query/iteration/phases/tool-review.js +129 -62
  154. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  155. package/dist/runtime/query/iteration/step-context.d.ts +14 -0
  156. package/dist/runtime/query/iteration/step-context.d.ts.map +1 -1
  157. package/dist/runtime/query/iteration/step-context.js +29 -0
  158. package/dist/runtime/query/iteration/step-context.js.map +1 -1
  159. package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
  160. package/dist/runtime/query/iteration/step-shaping.js +6 -2
  161. package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
  162. package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
  163. package/dist/runtime/query/prepare-turn.js +16 -3
  164. package/dist/runtime/query/prepare-turn.js.map +1 -1
  165. package/dist/runtime/query/project-instructions.d.ts +24 -5
  166. package/dist/runtime/query/project-instructions.d.ts.map +1 -1
  167. package/dist/runtime/query/project-instructions.js +107 -35
  168. package/dist/runtime/query/project-instructions.js.map +1 -1
  169. package/dist/runtime/query/prompt.d.ts +6 -0
  170. package/dist/runtime/query/prompt.d.ts.map +1 -1
  171. package/dist/runtime/query/prompt.js +10 -49
  172. package/dist/runtime/query/prompt.js.map +1 -1
  173. package/dist/runtime/query/resume-pending.d.ts +8 -0
  174. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  175. package/dist/runtime/query/resume-pending.js +101 -0
  176. package/dist/runtime/query/resume-pending.js.map +1 -1
  177. package/dist/runtime/query/review-policy.d.ts +18 -0
  178. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  179. package/dist/runtime/query/review-policy.js +10 -0
  180. package/dist/runtime/query/review-policy.js.map +1 -1
  181. package/dist/runtime/query/steering.d.ts +55 -56
  182. package/dist/runtime/query/steering.d.ts.map +1 -1
  183. package/dist/runtime/query/steering.js +78 -72
  184. package/dist/runtime/query/steering.js.map +1 -1
  185. package/dist/tools/builtins/bash.d.ts +8 -0
  186. package/dist/tools/builtins/bash.d.ts.map +1 -1
  187. package/dist/tools/builtins/bash.js +13 -18
  188. package/dist/tools/builtins/bash.js.map +1 -1
  189. package/dist/tools/builtins/browser.d.ts.map +1 -1
  190. package/dist/tools/builtins/browser.js +38 -12
  191. package/dist/tools/builtins/browser.js.map +1 -1
  192. package/dist/tools/builtins/edit.js +4 -4
  193. package/dist/tools/builtins/edit.js.map +1 -1
  194. package/dist/tools/builtins/job.js +1 -1
  195. package/dist/tools/builtins/job.js.map +1 -1
  196. package/dist/tools/builtins/skill.js +1 -1
  197. package/dist/tools/builtins/skill.js.map +1 -1
  198. package/dist/tools/builtins/structuredOutput.js +1 -1
  199. package/dist/tools/builtins/structuredOutput.js.map +1 -1
  200. package/dist/tools/builtins/verify-outputs.js +1 -1
  201. package/dist/tools/builtins/verify-outputs.js.map +1 -1
  202. package/dist/tools/builtins/write-file.js +4 -4
  203. package/dist/tools/builtins/write-file.js.map +1 -1
  204. package/dist/tools/coordinator/ask-user-question.d.ts +6 -0
  205. package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
  206. package/dist/tools/coordinator/ask-user-question.js +6 -1
  207. package/dist/tools/coordinator/ask-user-question.js.map +1 -1
  208. package/dist/tools/coordinator/index.d.ts.map +1 -1
  209. package/dist/tools/coordinator/index.js +10 -3
  210. package/dist/tools/coordinator/index.js.map +1 -1
  211. package/dist/tools/resident-history.d.ts +2 -0
  212. package/dist/tools/resident-history.d.ts.map +1 -1
  213. package/dist/tools/resident-history.js +2 -0
  214. package/dist/tools/resident-history.js.map +1 -1
  215. package/dist/tools/resident-tool-evidence.d.ts +5 -1
  216. package/dist/tools/resident-tool-evidence.d.ts.map +1 -1
  217. package/dist/tools/resident-tool-evidence.js +5 -1
  218. package/dist/tools/resident-tool-evidence.js.map +1 -1
  219. package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
  220. package/dist/tools/schedules/loop-tool.js +4 -2
  221. package/dist/tools/schedules/loop-tool.js.map +1 -1
  222. package/dist/tools/schedules/schedule-tool.js +2 -2
  223. package/dist/tools/schedules/schedule-tool.js.map +1 -1
  224. package/dist/tools/task/create.js +1 -1
  225. package/dist/tools/task/create.js.map +1 -1
  226. package/dist/tools/untrusted-envelope.js +1 -1
  227. package/dist/tools/untrusted-envelope.js.map +1 -1
  228. package/dist/turn/evidence-query.d.ts.map +1 -1
  229. package/dist/turn/evidence-query.js +16 -1
  230. package/dist/turn/evidence-query.js.map +1 -1
  231. package/dist/turn/evidence-recall.js +1 -1
  232. package/dist/turn/evidence-recall.js.map +1 -1
  233. package/dist/types/agent/base.d.ts +7 -0
  234. package/dist/types/agent/base.d.ts.map +1 -1
  235. package/dist/types/hitl/index.d.ts +66 -0
  236. package/dist/types/hitl/index.d.ts.map +1 -1
  237. package/dist/types/hitl/index.js.map +1 -1
  238. package/dist/types/message/index.d.ts +8 -0
  239. package/dist/types/message/index.d.ts.map +1 -1
  240. package/dist/types/message/index.js +12 -2
  241. package/dist/types/message/index.js.map +1 -1
  242. package/dist/types/message/notice-frame.d.ts +41 -0
  243. package/dist/types/message/notice-frame.d.ts.map +1 -0
  244. package/dist/types/message/notice-frame.js +65 -0
  245. package/dist/types/message/notice-frame.js.map +1 -0
  246. package/package.json +1 -1
  247. package/src/agents/QueryAgent.ts +1 -0
  248. package/src/compaction/extractor.ts +8 -1
  249. package/src/compaction/managers/structured.ts +3 -0
  250. package/src/compaction/manual.ts +5 -0
  251. package/src/compaction/serializer.ts +28 -3
  252. package/src/compaction/verifier.ts +32 -6
  253. package/src/constants/compaction/index.ts +1 -0
  254. package/src/{manager/resident/learning-cycle.ts → learning/cycle.ts} +130 -78
  255. package/src/learning/deprecated.ts +124 -0
  256. package/src/learning/experience-store.ts +202 -0
  257. package/src/learning/experience.ts +238 -0
  258. package/src/learning/generator.ts +388 -0
  259. package/src/learning/leak-tripwire.ts +280 -0
  260. package/src/{manager/resident/learning-observation.ts → learning/observation.ts} +5 -5
  261. package/src/{manager/resident/learning.ts → learning/skill.ts} +64 -67
  262. package/src/{manager/resident/learning-store.ts → learning/store.ts} +97 -67
  263. package/src/manager/resident/activity.ts +30 -6
  264. package/src/manager/resident/agenda.ts +63 -33
  265. package/src/manager/resident/consumption.ts +27 -5
  266. package/src/manager/resident/delivery-window.ts +7 -1
  267. package/src/manager/resident/evidence-recall.ts +7 -1
  268. package/src/manager/resident/history.ts +45 -9
  269. package/src/manager/resident/host.ts +45 -11
  270. package/src/manager/resident/initiative.ts +32 -6
  271. package/src/manager/resident/loop.ts +22 -4
  272. package/src/manager/resident/outbox.ts +42 -8
  273. package/src/manager/resident/proposal.ts +17 -3
  274. package/src/manager/resident/store.ts +27 -5
  275. package/src/manager/resident/tool-evidence.ts +45 -9
  276. package/src/prompt/coding-agent-doctrine.ts +18 -20
  277. package/src/prompt/resident-learning.ts +16 -7
  278. package/src/prompt/resident-step.ts +19 -13
  279. package/src/public-runtime.ts +36 -5
  280. package/src/public-types.ts +96 -34
  281. package/src/runtime/query/checkpoint.ts +49 -8
  282. package/src/runtime/query/executor.ts +165 -15
  283. package/src/runtime/query/index.ts +45 -1
  284. package/src/runtime/query/iteration/index.ts +19 -6
  285. package/src/runtime/query/iteration/phases/context.ts +37 -11
  286. package/src/runtime/query/iteration/phases/per-call-review.ts +617 -0
  287. package/src/runtime/query/iteration/phases/tool-review.ts +168 -83
  288. package/src/runtime/query/iteration/step-context.ts +29 -0
  289. package/src/runtime/query/iteration/step-shaping.ts +6 -2
  290. package/src/runtime/query/prepare-turn.ts +18 -1
  291. package/src/runtime/query/project-instructions.ts +119 -38
  292. package/src/runtime/query/prompt.ts +11 -54
  293. package/src/runtime/query/resume-pending.ts +131 -0
  294. package/src/runtime/query/review-policy.ts +28 -0
  295. package/src/runtime/query/steering.ts +100 -96
  296. package/src/tools/builtins/bash.ts +13 -19
  297. package/src/tools/builtins/browser.ts +38 -12
  298. package/src/tools/builtins/edit.ts +4 -4
  299. package/src/tools/builtins/job.ts +1 -1
  300. package/src/tools/builtins/skill.ts +1 -1
  301. package/src/tools/builtins/structuredOutput.ts +1 -1
  302. package/src/tools/builtins/verify-outputs.ts +1 -1
  303. package/src/tools/builtins/write-file.ts +4 -4
  304. package/src/tools/coordinator/ask-user-question.ts +12 -1
  305. package/src/tools/coordinator/index.ts +10 -3
  306. package/src/tools/resident-history.ts +2 -0
  307. package/src/tools/resident-tool-evidence.ts +5 -1
  308. package/src/tools/schedules/loop-tool.ts +4 -2
  309. package/src/tools/schedules/schedule-tool.ts +2 -2
  310. package/src/tools/task/create.ts +1 -1
  311. package/src/tools/untrusted-envelope.ts +1 -1
  312. package/src/turn/evidence-query.ts +19 -1
  313. package/src/turn/evidence-recall.ts +1 -1
  314. package/src/types/agent/base.ts +8 -0
  315. package/src/types/hitl/index.ts +67 -0
  316. package/src/types/message/index.ts +20 -2
  317. package/src/types/message/notice-frame.ts +88 -0
  318. package/dist/manager/resident/learning-cycle.d.ts.map +0 -1
  319. package/dist/manager/resident/learning-cycle.js.map +0 -1
  320. package/dist/manager/resident/learning-observation.d.ts.map +0 -1
  321. package/dist/manager/resident/learning-observation.js.map +0 -1
  322. package/dist/manager/resident/learning-store.d.ts.map +0 -1
  323. package/dist/manager/resident/learning-store.js.map +0 -1
  324. package/dist/manager/resident/learning.d.ts.map +0 -1
  325. package/dist/manager/resident/learning.js.map +0 -1
@@ -28,7 +28,11 @@ export const residentDecisionSchema = z.discriminatedUnion('kind', [
28
28
  z.object({ kind: z.literal('blocked'), summary: text }),
29
29
  ])
30
30
 
31
- /** @experimental One bounded step's durable disposition; silence is not completion. */
31
+ /**
32
+ * @experimental One bounded step's durable disposition; silence is not completion.
33
+ *
34
+ * @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.
35
+ */
32
36
  export type ResidentDecision = z.infer<typeof residentDecisionSchema>
33
37
 
34
38
  export const residentStateSchema = z
@@ -69,7 +73,11 @@ export const residentStateSchema = z
69
73
  }
70
74
  })
71
75
 
72
- /** @experimental Persisted identity and one pursuit, independent of a conversation. */
76
+ /**
77
+ * @experimental Persisted identity and one pursuit, independent of a conversation.
78
+ *
79
+ * @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.
80
+ */
73
81
  export type ResidentState = Readonly<z.infer<typeof residentStateSchema>>
74
82
 
75
83
  /** Bounded addressing for local resident state. Stored scope is still validated. */
@@ -80,10 +88,18 @@ export function residentKeySegment(key: string): string {
80
88
  : `~sha256-${createHash('sha256').update(encoded).digest('hex')}`
81
89
  }
82
90
 
83
- /** @experimental Minimal atomic contract needed to execute an existing pursuit. */
91
+ /**
92
+ * @experimental Minimal atomic contract needed to execute an existing pursuit.
93
+ *
94
+ * @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.
95
+ */
84
96
  export type ResidentExecutionStore = Pick<ResidentStore, 'read' | 'claim' | 'settle'>
85
97
 
86
- /** @experimental Backends must atomically compare revisions and publish admission before work. */
98
+ /**
99
+ * @experimental Backends must atomically compare revisions and publish admission before work.
100
+ *
101
+ * @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.
102
+ */
87
103
  export interface ResidentStore {
88
104
  read(): Promise<ResidentState | null>
89
105
  create(identity: string, objective: string): Promise<ResidentState>
@@ -92,7 +108,11 @@ export interface ResidentStore {
92
108
  wake(expected: ResidentState, reason: string, now: number): Promise<ResidentState>
93
109
  }
94
110
 
95
- /** A competing owner advanced this resident's immutable revision. */
111
+ /**
112
+ * A competing owner advanced this resident's immutable revision.
113
+ *
114
+ * @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.
115
+ */
96
116
  export class ResidentConflictError extends Error {
97
117
  constructor() {
98
118
  super('Resident state changed; read the current state before retrying.')
@@ -104,6 +124,8 @@ export class ResidentConflictError extends Error {
104
124
  * @experimental Local-filesystem state for one tenant/agent key and one pursuit.
105
125
  * A running claim never expires automatically: a crashed step may have effects.
106
126
  * Uses exclusive immutable revision publication, not a read/rename lock.
127
+ *
128
+ * @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.
107
129
  */
108
130
  export class DiskResidentStore implements ResidentStore {
109
131
  private readonly records = new DiskRevisionRecordStore<ResidentState>(
@@ -17,16 +17,28 @@ import type {
17
17
  ResidentHistorySource,
18
18
  } from './history.js'
19
19
 
20
- /** @experimental Host authority for one pursuit, project and admission boundary. */
20
+ /**
21
+ * @experimental Host authority for one pursuit, project and admission boundary.
22
+ *
23
+ * @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.
24
+ */
21
25
  export interface ResidentToolEvidenceScope extends ResidentHistoryScope {
22
26
  readonly projectId: string
23
27
  }
24
- /** @experimental Identity of an agenda-verified settlement, not a fabricated transcript. */
28
+ /**
29
+ * @experimental Identity of an agenda-verified settlement, not a fabricated transcript.
30
+ *
31
+ * @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.
32
+ */
25
33
  export type ResidentSettledInvocation = Pick<
26
34
  ResidentHistoryMatch,
27
35
  'revision' | 'claimId' | 'step' | 'kind'
28
36
  >
29
- /** @experimental Settlement is checked before the host resolves the attempt's invocation. */
37
+ /**
38
+ * @experimental Settlement is checked before the host resolves the attempt's invocation.
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
+ */
30
42
  export interface ResidentToolEvidenceOptions {
31
43
  readonly history: ResidentHistorySource
32
44
  readonly projectId: string
@@ -45,7 +57,11 @@ export interface ResidentToolEvidenceOptions {
45
57
  signal?: AbortSignal,
46
58
  ) => Promise<SessionEvidenceSource>
47
59
  }
48
- /** @experimental An optional shared ceiling covers history, resolution and turn evidence. */
60
+ /**
61
+ * @experimental An optional shared ceiling covers history, resolution and turn evidence.
62
+ *
63
+ * @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.
64
+ */
49
65
  export interface ResidentToolEvidenceSearchOptions {
50
66
  readonly query?: string
51
67
  /** Token discovery: 1–16 terms, matched case-insensitively. Combined query/filter JSON ≤512 UTF-8 bytes. */
@@ -60,7 +76,11 @@ export interface ResidentToolEvidenceSearchOptions {
60
76
  readonly refineTerms?: readonly string[]
61
77
  readonly maxReadBytes?: number
62
78
  }
63
- /** @experimental Tool records from at most one settled invocation per bounded search page. */
79
+ /**
80
+ * @experimental Tool records from at most one settled invocation per bounded search page.
81
+ *
82
+ * @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.
83
+ */
64
84
  export interface ResidentToolEvidenceSearchResult {
65
85
  readonly scope: ResidentToolEvidenceScope
66
86
  readonly revision: number | null
@@ -75,20 +95,32 @@ export interface ResidentToolEvidenceSearchResult {
75
95
  */
76
96
  readonly chargedBytes?: number
77
97
  }
78
- /** @experimental The revision is authorized anew on every read, including after restart. */
98
+ /**
99
+ * @experimental The revision is authorized anew on every read, including after restart.
100
+ *
101
+ * @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.
102
+ */
79
103
  export interface ResidentToolEvidenceReadOptions
80
104
  extends Omit<SessionEvidenceReadOptions, 'maxReadBytes'> {
81
105
  readonly revision: number
82
106
  /** Shared operation ceiling, at most 8 MiB; reserves at least 1 MiB for turn evidence reads. */
83
107
  readonly maxReadBytes?: number
84
108
  }
85
- /** @experimental Exact invocation text plus the settled claim that authorized access. */
109
+ /**
110
+ * @experimental Exact invocation text plus the settled claim that authorized access.
111
+ *
112
+ * @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.
113
+ */
86
114
  export interface ResidentToolEvidenceReadResult extends SessionEvidenceReadResult {
87
115
  readonly revision: number
88
116
  readonly claimId: string
89
117
  readonly chargedBytes?: number
90
118
  }
91
- /** @experimental A host must bind tool access to the executing turn, not just this source. */
119
+ /**
120
+ * @experimental A host must bind tool access to the executing turn, not just this source.
121
+ *
122
+ * @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.
123
+ */
92
124
  export interface ResidentToolEvidenceSource {
93
125
  readonly scope: ResidentToolEvidenceScope
94
126
  readonly supportsTermRefinement?: boolean
@@ -102,7 +134,11 @@ export interface ResidentToolEvidenceSource {
102
134
  ): Promise<ResidentToolEvidenceReadResult>
103
135
  }
104
136
 
105
- /** @experimental Reuses the immutable agenda boundary; it never enumerates arbitrary sessions. */
137
+ /**
138
+ * @experimental Reuses the immutable agenda boundary; it never enumerates arbitrary sessions.
139
+ *
140
+ * @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.
141
+ */
106
142
  export function createResidentToolEvidenceSource(
107
143
  options: ResidentToolEvidenceOptions,
108
144
  ): ResidentToolEvidenceSource {
@@ -37,51 +37,49 @@ import type { PromptContribution } from './contributions.js'
37
37
  export const CODING_AGENT_WORKING_DOCTRINE = `## How you work
38
38
 
39
39
  ### Delivering work
40
- - Act when you have enough information. Do not re-derive facts already established, and do not re-open a decision the user has already made.
41
- - The requested scope is the deliverable. Do not quietly narrow it, widen it, or turn it into something adjacent. Read ambiguity the way a careful colleague would; make the routine judgment calls yourself and check in only when different readings would produce materially different work.
42
- - Finish the whole task, not just the easy parts. If one part is blocked — a tool or capability you do not have, an input that is missing — say so plainly, do not improvise a result for it, finish every other part in full, and say explicitly what you left out and why. Scaling the work down is the user's call.
40
+ - Act when you have enough information. Take established facts and the user's decisions as settled.
41
+ - The requested scope is the deliverable: deliver it at the size and on the subject it was asked. Read ambiguity the way a careful colleague would; make the routine judgment calls yourself and check in only when different readings would produce materially different work.
42
+ - Finish the whole task, not just the easy parts. If one part is blocked — a tool or capability you do not have, an input that is missing — say so plainly instead of improvising a result for it, finish every other part in full, and say explicitly what you left out and why. Scaling the work down is the user's call.
43
43
  - If you find a real problem with the task as stated, say so in a sentence or two, then keep going under a stated assumption. Reserve blocking questions for cases where proceeding under any assumption would be unsafe or would make the work useless if wrong.
44
44
  - If the user repeats or reaffirms a request after you raised a concern, that is their decision: say so and do the full request.
45
45
 
46
46
  ### Reporting
47
47
  - Report outcomes faithfully. If tests fail, say so and show the output. If you skipped a step, say it was skipped. When something is done and verified, state it plainly without hedging.
48
- - Preserve exact identifiers when reporting evidence. Do not translate, normalize or correct their spelling.
49
- - Never present a green run on a subset as a green run. Name what was actually executed.
48
+ - Report identifiers exactly as the evidence spells them, so the user can search for them.
49
+ - Name what was actually executed, so a green run on a subset reads as that subset.
50
50
  - Reference code as \`path:line\` so the user can jump to it.
51
- - Correct an earlier statement only when the error would change the user's code, conclusions or decisions; state it once, plainly, and continue. No apologies, no tally of past mistakes.
51
+ - Correct an earlier statement only when the error would change the user's code, conclusions or decisions; state it once, plainly, and continue, and keep apologies and tallies of past mistakes out of it, because they spend the reader's attention on the past.
52
52
 
53
53
  ### Using available evidence
54
- - Carry the active task and established facts across turns. A question or status request during ongoing work does not cancel that work unless the user says so. Ask for clarification when the intended change is genuinely unspecified; do not ask the user to repeat information already available.
55
- - Treat a successful tool result together with its exact inputs as evidence of what happened. Content you successfully wrote is available evidence, just like content you read. An announced action, proposed call, failed call, or another agent's unsupported claim is not proof of completion.
56
- - Match the source to the time the question asks about. For an earlier observation, use that observation or its retained original; a fresh read of a mutable source cannot establish what it contained earlier. For current state or a new action, check freshness as needed. If the historical detail is unavailable, say so instead of substituting today's value.
57
- - Reuse relevant evidence still available in conversation instead of observing it again by habit. Distinguish the last observed state from a guarantee that external state has not changed. Re-observe when evidence is missing, partial or invalidated, when another actor may have changed the target, or when freshness matters to the next action. If a check or exact-match edit reports a mismatch, inspect the current state and revise the action; do not force the old plan through.
58
- - When an observation is needed, ask the narrowest question that resolves the uncertainty. For a known file, inspect that file rather than listing the whole working directory. Recover missing observations with read-only tools, not by repeating a state-changing action.
54
+ - Use what you have. Carry the active task and established facts across turns: a question or status request during ongoing work leaves that work in place unless the user says otherwise, and information already in the conversation needs no repeating. A successful tool result together with its exact inputs is evidence of what happened, and so is content you wrote; an announced action, a proposed call, a failed call or another agent's unsupported claim is not. Reuse evidence still in the conversation instead of observing it again by habit, and when you do observe, ask the narrowest question that resolves the uncertainty (a known file, not the whole working directory). Ask for clarification only when the intended change is genuinely unspecified.
55
+ - Re-check what may have changed. Distinguish the last observed state from a guarantee that external state is unchanged, and observe again when evidence is missing, partial or invalidated, when another actor may have changed the target, or when freshness matters to the next action. If a check or exact-match edit reports a mismatch, inspect the current state and revise the action. Recover missing observations with read-only tools, because repeating a state-changing action changes state twice.
56
+ - Say plainly when history is unavailable. Match the source to the time the question asks about: for an earlier observation use that observation or its retained original, since a fresh read of a mutable source cannot show what it held earlier. When the historical detail is gone, say so and leave today's value out of the answer.
59
57
 
60
58
  ### Reading and editing code
61
59
  - Before editing, use the relevant file content already available from a successful read or write; if it is unavailable or may be stale, read the needed portion. Read additional surrounding code when needed to match its naming and idiom. Respect project instructions and tool-specific prerequisites even when they require a fresh read.
62
- - Prefer the dedicated tools over shell equivalents: \`read\` over \`cat\`, the \`grep\` tool over running \`grep\` or \`rg\` through \`bash\`, \`glob\` over \`find\` or \`ls -R\`, \`edit\` over \`sed -i\`. To change an existing file use \`edit\`; use \`write\` only to create a file or when the user asked for a whole-file rewrite. Prefer their structured inputs and focused results; use shell commands when the task needs them, within the same configured permissions.
63
- - Independent tool calls go in one response. Reading three files, or running a grep and a glob, does not need three turns. Only group independent operations. Wait for a mutation to finish before an observation or another action that depends on it; runtime ordering and concurrency limits remain authoritative.
64
- - Match verification to the task and its risk. For a simple text-file operation, use the successful tool result and known content; do not run unrelated project tests or repeat a read merely to restate that result. For code changes, run the relevant tests, typecheck or lint that would catch a mistake, and follow required project checks. Never claim checks you did not run.
65
- - Never leave the working tree in a state you have not described. If you created scratch files, say where; if you touched files outside the request, say which.
60
+ - Prefer the dedicated tools over shell equivalents (\`read\` over \`cat\`, \`grep\` over a shell grep, \`glob\` over \`find\`, \`edit\` over \`sed -i\`, \`write\` over a shell redirect), because their structured inputs and focused results are easier to check. Use \`bash\` when the task needs a shell; permissions apply the same way.
61
+ - Independent tool calls go in one response: reading three files, or running a grep and a glob, does not need three turns. Wait for a mutation to finish before an observation or another action that depends on it; runtime ordering and concurrency limits remain authoritative.
62
+ - Match verification to the task and its risk. For a simple text-file operation, the successful tool result and known content are enough, so an unrelated project test or a repeated read adds nothing. For code changes, run the relevant tests, typecheck or lint that would catch a mistake, and follow required project checks. Claim only the checks you ran.
63
+ - Describe the state you leave the working tree in: say where scratch files are, and which files outside the request you touched.
66
64
 
67
65
  ### Working with git
68
66
  - Never push, force-push, reset, rebase, clean, or otherwise discard or rewrite history unless the user explicitly asked for that action. Approval for one push does not extend to the next.
69
67
  - Before any command that could discard uncommitted work, run \`git status\`. If there are changes there that you did not make, stop and ask rather than stashing, committing or discarding somebody else's work.
70
- - Commit only when the user asks, on the branch that is checked out. Do not create or switch branches unless the user asks or the project's instructions require it.
68
+ - Commit only when the user asks, on the branch that is checked out. Create or switch branches only when the user asks or the project's instructions require it, because the checked-out branch is the user's working state.
71
69
  - After a broad \`git add\`, review what was staged before committing; a file whose name looks harmless can still carry a secret.
72
70
  - Never change git configuration or other persistent settings without asking: not \`user.name\` or \`user.email\`, hooks, remotes, credential helpers, or any \`git config\` (local or global), nor a shell profile or a tool's own config file. If a commit fails because no identity is set, stop and tell the user the command to set one; do not invent one.
73
71
 
74
72
  ### Keeping the user informed
75
73
  - Before a batch of tool calls, say in one short line what you are about to do and why. When you have been working for a while without saying anything, say in a few words where you are, then continue. One line, not a paragraph; the tool rows on screen already show the details.
76
- - Keep the final reply short and specific: what changed, what was verified, what is left. Do not restate the transcript.`
74
+ - Keep the final reply short and specific: what changed, what was verified, what is left.`
77
75
 
78
76
  /**
79
77
  * Parent-only: rules about `task_create` / `task_update` and `Agent`, which a
80
78
  * delegated sub-agent does not have. See the module comment for the split.
81
79
  */
82
80
  export const CODING_AGENT_DELEGATION_DOCTRINE = `### Planning and delegating
83
- - For work that is genuinely multi-step — several files, several distinct stages, anything you would write a checklist for — open a task list with \`task_create\` and keep it current with \`task_update\`, marking each step done when it is done rather than at the end. Do not open one for a single inspect-edit-test cycle; the list is for the user to follow, and a list of one item tells them nothing.
84
- - When the \`Agent\` tool is available, delegate genuinely independent work through it and give each delegation a short, specific description; the user watches those descriptions, not the prompts. Give each sub-agent the objective, relevant context and completion criteria; do not assume it sees context the delegation interface did not supply.
81
+ - For work that is multi-step — several files, several distinct stages, anything you would write a checklist for — open a task list with \`task_create\` and keep it current with \`task_update\`, marking each step done when it is done rather than at the end. Skip it for a single inspect-edit-test cycle: the list is for the user to follow, and a list of one item tells them nothing.
82
+ - When the \`Agent\` tool is available, delegate independent work through it and give each delegation a short, specific description; the user watches those descriptions, not the prompts. Brief each sub-agent with four things: the objective; what is out of bounds; which tools and sources to use; and the shape of the reply you want, such as a short summary with a file path for anything long. It starts with none of your context and returns what you ask for.
85
83
  - Delegate lookups — where something is defined, which files reference it, how a module works — with \`subagent_type: "explore"\`: it has reading and searching tools only and never interrupts the user for permission. Reserve the default sub-agent for work that changes files or runs commands.`
86
84
 
87
85
  /**
@@ -91,7 +89,7 @@ export const CODING_AGENT_DELEGATION_DOCTRINE = `### Planning and delegating
91
89
  */
92
90
  export const PLAN_MODE_DOCTRINE = `## Plan mode
93
91
 
94
- You are in plan mode. Read, search and think; do not change anything. \`read\`, \`grep\`, \`glob\` and the other read-only tools work as usual, and you may keep a task list. Any \`edit\`, \`write\` or shell command that changes state will be refused, so do not attempt one.
92
+ You are in plan mode. Read, search and think, and leave everything as it is. \`read\`, \`grep\`, \`glob\` and the other read-only tools work as usual, and you may keep a task list. Any \`edit\`, \`write\` or shell command that changes state will be refused, so plan around them.
95
93
 
96
94
  When you have understood the task, reply with the plan: what you would change, in which files, in what order, and what you would verify. Be concrete — name files and functions — and short enough to read in one screen. Then stop and wait; the user will leave plan mode to have the plan carried out, and that switch is their approval.`
97
95
 
@@ -1,17 +1,25 @@
1
1
  import { z } from 'zod'
2
- import { freezeResidentLearning, projectResidentLearning } from '../manager/resident/learning.js'
2
+ import { freezeLearning, projectLearning } from '../learning/skill.js'
3
3
  import { defineTool } from '../tools/defineTool.js'
4
4
  import type { ToolContext, ToolDefinition } from '../types/tool/index.js'
5
5
  import type { PromptContribution } from './contributions.js'
6
6
  import { type ResidentStepPromptOptions, createResidentStepContributions } from './resident-step.js'
7
7
 
8
- /** @experimental One admission's context and read-only access to its evaluated guidance. */
8
+ /**
9
+ * @experimental One admission's context and read-only access to its evaluated guidance.
10
+ *
11
+ * @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.
12
+ */
9
13
  export interface ResidentStepContextBundle {
10
14
  readonly contributions: readonly PromptContribution[]
11
15
  readonly tools: readonly ToolDefinition[]
12
16
  }
13
17
 
14
- /** @experimental The host must reject reads from runs outside the admitted scope. */
18
+ /**
19
+ * @experimental The host must reject reads from runs outside the admitted scope.
20
+ *
21
+ * @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.
22
+ */
15
23
  export interface ResidentStepContextOptions extends ResidentStepPromptOptions {
16
24
  readonly authorizeLearningRead: (context: ToolContext) => boolean
17
25
  }
@@ -20,11 +28,13 @@ export interface ResidentStepContextOptions extends ResidentStepPromptOptions {
20
28
  * @experimental List guidance descriptions first; disclose complete bodies only
21
29
  * when requested. Selection is local to this admission, never persisted as a
22
30
  * preference or inferred from keywords. Mount both returned tools and context.
31
+ *
32
+ * @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.
23
33
  */
24
34
  export function createResidentStepContext(
25
35
  options: ResidentStepContextOptions,
26
36
  ): ResidentStepContextBundle {
27
- const learning = options.learning ? freezeResidentLearning(options.learning) : undefined
37
+ const learning = options.learning ? freezeLearning(options.learning) : undefined
28
38
  const contributions = createResidentStepContributions({
29
39
  ...options,
30
40
  learning: learning ? { ...learning, skills: [] } : undefined,
@@ -35,8 +45,7 @@ export function createResidentStepContext(
35
45
  const authorize = options.authorizeLearningRead
36
46
  const resolveSources = options.resolveLearningSources
37
47
  const selected = new Set<string>()
38
- const profileChars = projectResidentLearning(learning, { maxChars: 12_000, skillNames: [] }).text
39
- .length
48
+ const profileChars = projectLearning(learning, { maxChars: 12_000, skillNames: [] }).text.length
40
49
  const project = (names: readonly string[], maxChars = 12_000) => {
41
50
  let sources: ReturnType<NonNullable<typeof resolveSources>> = []
42
51
  try {
@@ -44,7 +53,7 @@ export function createResidentStepContext(
44
53
  } catch {
45
54
  // Unavailable observations cannot establish a dependency match.
46
55
  }
47
- return projectResidentLearning(
56
+ return projectLearning(
48
57
  { ...learning, identity: undefined, preferences: [] },
49
58
  { maxChars, skillNames: names, sources },
50
59
  )
@@ -1,10 +1,10 @@
1
- import type { ResidentHistoryScope } from '../manager/resident/history.js'
2
1
  import {
3
- type ResidentLearningSource,
4
- type ResidentLearningState,
5
- freezeResidentLearning,
6
- projectResidentLearning,
7
- } from '../manager/resident/learning.js'
2
+ type LearningSource,
3
+ type LearningState,
4
+ freezeLearning,
5
+ projectLearning,
6
+ } from '../learning/skill.js'
7
+ import type { ResidentHistoryScope } from '../manager/resident/history.js'
8
8
  import type { ResidentState } from '../manager/resident/store.js'
9
9
  import type { PromptContribution } from './contributions.js'
10
10
 
@@ -34,13 +34,17 @@ Use permitted reads and analysis. Do not change files, persistent memory or exte
34
34
  const HISTORY_GUIDANCE = `## Resident recall
35
35
  When the saved summary lacks an earlier decision or accepted input, use search_resident_history, then read_resident_history for exact retained text. Search without a query to browse recent steps. Follow pagination even after empty pages; incomplete searches cannot prove absence. Only earlier settled steps of this pursuit are available, within the supplied revision boundary. Part 0 is a historical summary, not an independent tool receipt; wake inputs are recorded claims. Later evidence can supersede earlier claims: check relevant newer steps and mutable sources before acting. Do not repeat an effect to recover its output. These tools do not restore unrecorded tool transcripts.`
36
36
 
37
- /** @experimental Host-selected context for one admitted resident step. */
37
+ /**
38
+ * @experimental Host-selected context for one admitted resident step.
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
+ */
38
42
  export interface ResidentStepPromptOptions {
39
43
  readonly state: ResidentState
40
44
  /** The host-approved learning snapshot bound to this admission. */
41
- readonly learning?: ResidentLearningState
45
+ readonly learning?: LearningState
42
46
  /** Host resolves current dependency revisions for each model request. No model-generated revisions. */
43
- readonly resolveLearningSources?: () => readonly ResidentLearningSource[]
47
+ readonly resolveLearningSources?: () => readonly LearningSource[]
44
48
  /** Bound historical source whose read-only tools the host has mounted. */
45
49
  readonly history?: ResidentHistoryScope
46
50
  /** The host mounted scoped search_resident_tools/read_resident_tool capabilities. */
@@ -64,6 +68,8 @@ export interface ResidentStepPromptOptions {
64
68
  *
65
69
  * Project instructions and authorization remain on their existing host/runtime
66
70
  * paths. These contributions neither load project files nor authorize work.
71
+ *
72
+ * @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
73
  */
68
74
  export function createResidentStepContributions(
69
75
  options: ResidentStepPromptOptions,
@@ -76,11 +82,11 @@ export function createResidentStepContributions(
76
82
  options.history.pursuitId !== state.pursuitId)
77
83
  )
78
84
  throw new Error('Resident history context belongs to a different pursuit.')
79
- const admittedLearning = options.learning ? freezeResidentLearning(options.learning) : undefined
85
+ const admittedLearning = options.learning ? freezeLearning(options.learning) : undefined
80
86
  const boundNames =
81
87
  admittedLearning?.skills.filter((skill) => skill.sources?.length).map((skill) => skill.name) ??
82
88
  []
83
- const learning = projectResidentLearning(admittedLearning, {
89
+ const learning = projectLearning(admittedLearning, {
84
90
  maxChars: 12_000,
85
91
  skillNames:
86
92
  admittedLearning?.skills
@@ -137,13 +143,13 @@ export function createResidentStepContributions(
137
143
  id: 'namzu.resident-step.source-bound-learning',
138
144
  placement: 'context' as const,
139
145
  render: () => {
140
- let sources: readonly ResidentLearningSource[] = []
146
+ let sources: readonly LearningSource[] = []
141
147
  try {
142
148
  sources = resolveSources?.() ?? []
143
149
  } catch {
144
150
  /* Unavailable evidence withholds bound instructions. */
145
151
  }
146
- const projection = projectResidentLearning(
152
+ const projection = projectLearning(
147
153
  admittedLearning
148
154
  ? { ...admittedLearning, identity: undefined, preferences: [] }
149
155
  : undefined,
@@ -333,6 +333,7 @@ export { drainQuery, query } from './runtime/query/index.js'
333
333
  export {
334
334
  collapseProjectInstructionSnapshots,
335
335
  isProjectInstructionMessage,
336
+ projectInstructionBody,
336
337
  replaceProjectInstructionSnapshot,
337
338
  } from './runtime/query/project-instructions.js'
338
339
  // Mid-run guidance. A host holds the channel and the loop drains it at the
@@ -1472,6 +1473,8 @@ export {
1472
1473
  } from './runtime/query/auto-review/index.js'
1473
1474
  // What the model is told when a person declines a call without words of their own.
1474
1475
  export { DECLINED_TOOL_CALL_FEEDBACK } from './runtime/query/declined.js'
1476
+ // Whether a tool result answers a call the review did not let run, so a host counting failures can leave it out.
1477
+ export { isReviewRefusalResult } from './runtime/query/iteration/phases/per-call-review.js'
1475
1478
 
1476
1479
  // The system prompt is open: a contribution registry the assembler
1477
1480
  // consumes, with skills as its first contributor. See `prompt/contributions.ts`.
@@ -1650,11 +1653,31 @@ export { validateResidentProposal } from './manager/resident/proposal.js'
1650
1653
  export { deliverResidentMessage } from './manager/resident/outbox.js'
1651
1654
  export { createResidentDeliveryWindow } from './manager/resident/delivery-window.js'
1652
1655
 
1656
+ export { hashLearningSkill, projectLearning } from './learning/skill.js'
1657
+ export { runLearningCycle } from './learning/cycle.js'
1653
1658
  export {
1654
- hashResidentSkill,
1655
- projectResidentLearning,
1656
- } from './manager/resident/learning.js'
1657
- export { runResidentLearningCycle } from './manager/resident/learning-cycle.js'
1659
+ LEARNING_FLOOR_COMPONENTS,
1660
+ LEARNING_SURFACE_KINDS,
1661
+ learningExperienceFromCycle,
1662
+ proposeLearningCandidate,
1663
+ resolveLearningSurface,
1664
+ } from './learning/generator.js'
1665
+ export {
1666
+ LEARNING_CONFIDENCE_LEVELS,
1667
+ LEARNING_EDIT_VERDICTS,
1668
+ normalizeLearningExperience,
1669
+ selectLearningExperience,
1670
+ } from './learning/experience.js'
1671
+ export {
1672
+ LEARNING_EXPERIENCE_STORE_VERSION,
1673
+ SqliteLearningExperienceStore,
1674
+ } from './learning/experience-store.js'
1675
+ export {
1676
+ LearningLeakError,
1677
+ assertNoLearningLeak,
1678
+ createLearningCanary,
1679
+ scanForLearningLeak,
1680
+ } from './learning/leak-tripwire.js'
1658
1681
 
1659
1682
  export {
1660
1683
  createSessionEvidenceSource,
@@ -1669,11 +1692,19 @@ export { createResidentToolEvidenceSource } from './manager/resident/tool-eviden
1669
1692
 
1670
1693
  export { createResidentEvidenceRecallStep } from './manager/resident/evidence-recall.js'
1671
1694
 
1695
+ export {
1696
+ SqliteLearningStore,
1697
+ runStoredLearningCycle,
1698
+ runStoredLearningFromObservations,
1699
+ } from './learning/store.js'
1672
1700
  export {
1673
1701
  SqliteResidentLearningStore,
1702
+ hashResidentSkill,
1703
+ projectResidentLearning,
1704
+ runResidentLearningCycle,
1674
1705
  runStoredResidentLearningCycle,
1675
1706
  runStoredResidentLearningFromObservations,
1676
- } from './manager/resident/learning-store.js'
1707
+ } from './learning/deprecated.js'
1677
1708
 
1678
1709
  // ─── sessions, turns and the session log ─────────────────────────────────
1679
1710
  //
@@ -607,29 +607,58 @@ export type {
607
607
  ResidentContextualStep,
608
608
  } from './manager/resident/host.js'
609
609
  export type {
610
- ResidentLearningEvidence,
611
- ResidentSkillCandidate,
612
- ResidentLearnedSkill,
613
- ResidentLearningState,
614
- ResidentProfileUpdate,
615
- ResidentSkillEvaluation,
616
- ResidentLearningProjectionOptions,
617
- ResidentLearningSource,
618
- ResidentLearningProjection,
619
- } from './manager/resident/learning.js'
620
- export type {
621
- ResidentLearningStage,
622
- ResidentLearningReceipt,
623
- ResidentLearningConsumption,
624
- ResidentLearningCycleEvent,
625
- ResidentLearningCycleContext,
626
- ResidentLearningGenerationContext,
627
- ResidentLearningExplorationContext,
628
- ResidentLearningExploration,
629
- ResidentLearningEvaluationContext,
630
- ResidentLearningCycleOptions,
631
- ResidentLearningCycleResult,
632
- } from './manager/resident/learning-cycle.js'
610
+ LearningEvidence,
611
+ LearningSkillCandidate,
612
+ LearnedSkill,
613
+ LearningState,
614
+ LearningProfileUpdate,
615
+ LearningSkillEvaluation,
616
+ LearningProjectionOptions,
617
+ LearningSource,
618
+ LearningProjection,
619
+ } from './learning/skill.js'
620
+ export type {
621
+ LearningStage,
622
+ LearningReceipt,
623
+ LearningConsumption,
624
+ LearningCycleEvent,
625
+ LearningCycleContext,
626
+ LearningGenerationContext,
627
+ LearningExplorationContext,
628
+ LearningExploration,
629
+ LearningEvaluationContext,
630
+ LearningCycleOptions,
631
+ LearningCycleResult,
632
+ } from './learning/cycle.js'
633
+
634
+ export type {
635
+ LearningModel,
636
+ LearningModelReply,
637
+ LearningModelRequest,
638
+ LearningProposal,
639
+ LearningProposeOptions,
640
+ LearningProposedEdit,
641
+ LearningSurface,
642
+ LearningSurfaceKind,
643
+ } from './learning/generator.js'
644
+
645
+ export type {
646
+ LearningConfidence,
647
+ LearningEditRow,
648
+ LearningEditVerdict,
649
+ LearningExperienceEntry,
650
+ LearningExperienceInput,
651
+ LearningExperienceQuery,
652
+ LearningLesson,
653
+ } from './learning/experience.js'
654
+ export type { SqliteLearningExperienceStoreOptions } from './learning/experience-store.js'
655
+
656
+ export type {
657
+ LearningLeakGuard,
658
+ LearningLeakKind,
659
+ LearningLeakFinding,
660
+ LearningLeakSubject,
661
+ } from './learning/leak-tripwire.js'
633
662
 
634
663
  export type {
635
664
  ResidentArchiveRequest,
@@ -678,18 +707,18 @@ export type {
678
707
  } from './turn/json-claim-verifier.js'
679
708
 
680
709
  export type {
681
- SqliteResidentLearningStoreOptions,
682
- ResidentLearningArtifact,
683
- ResidentLearningRecordedUsage,
684
- ResidentLearningCycleSummary,
685
- ResidentLearningDiscoveryOptions,
686
- ResidentLearningDiscoveryResult,
687
- } from './manager/resident/learning-store.js'
710
+ SqliteLearningStoreOptions,
711
+ LearningArtifact,
712
+ LearningRecordedUsage,
713
+ LearningCycleSummary,
714
+ LearningDiscoveryOptions,
715
+ LearningDiscoveryResult,
716
+ } from './learning/store.js'
688
717
  export type {
689
- ResidentLearningObservation,
690
- ResidentLearningObservationRecord,
691
- ResidentLearningTarget,
692
- } from './manager/resident/learning-observation.js'
718
+ LearningObservation,
719
+ LearningObservationRecord,
720
+ LearningTarget,
721
+ } from './learning/observation.js'
693
722
 
694
723
  // ─── sessions, turns and the session log: paths and log lines ────────────
695
724
  // The session types themselves come through `./types/session/index.js` above.
@@ -818,3 +847,36 @@ export type {
818
847
  } from './pals/activity/subscription-policy.js'
819
848
  export type { PalActivitySubscriptionRunnerOptions } from './pals/activity/subscriptions.js'
820
849
  export type { PalActivityCausalityOptions } from './pals/activity/causality.js'
850
+
851
+ // Deprecated resident-prefixed names, kept until the next major.
852
+ export type {
853
+ ResidentLearningEvidence,
854
+ ResidentSkillCandidate,
855
+ ResidentLearnedSkill,
856
+ ResidentLearningState,
857
+ ResidentProfileUpdate,
858
+ ResidentSkillEvaluation,
859
+ ResidentLearningProjectionOptions,
860
+ ResidentLearningSource,
861
+ ResidentLearningProjection,
862
+ ResidentLearningStage,
863
+ ResidentLearningReceipt,
864
+ ResidentLearningConsumption,
865
+ ResidentLearningCycleEvent,
866
+ ResidentLearningCycleContext,
867
+ ResidentLearningGenerationContext,
868
+ ResidentLearningExplorationContext,
869
+ ResidentLearningExploration,
870
+ ResidentLearningEvaluationContext,
871
+ ResidentLearningCycleOptions,
872
+ ResidentLearningCycleResult,
873
+ SqliteResidentLearningStoreOptions,
874
+ ResidentLearningArtifact,
875
+ ResidentLearningRecordedUsage,
876
+ ResidentLearningCycleSummary,
877
+ ResidentLearningDiscoveryOptions,
878
+ ResidentLearningDiscoveryResult,
879
+ ResidentLearningObservation,
880
+ ResidentLearningObservationRecord,
881
+ ResidentLearningTarget,
882
+ } from './learning/deprecated.js'