@namzu/sdk 61.4.0 → 62.0.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 (302) hide show
  1. package/CHANGELOG.md +55 -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/acp/permission.d.ts +8 -0
  6. package/dist/bridge/acp/permission.d.ts.map +1 -1
  7. package/dist/bridge/acp/permission.js.map +1 -1
  8. package/dist/bridge/acp/server.d.ts.map +1 -1
  9. package/dist/bridge/acp/server.js +8 -1
  10. package/dist/bridge/acp/server.js.map +1 -1
  11. package/dist/constants/tools/index.d.ts +2 -0
  12. package/dist/constants/tools/index.d.ts.map +1 -1
  13. package/dist/constants/tools/index.js +23 -0
  14. package/dist/constants/tools/index.js.map +1 -1
  15. package/dist/eval/harness-protection.js +1 -1
  16. package/dist/eval/harness-protection.js.map +1 -1
  17. package/dist/learning/cycle.d.ts +5 -3
  18. package/dist/learning/cycle.d.ts.map +1 -1
  19. package/dist/learning/cycle.js +11 -13
  20. package/dist/learning/cycle.js.map +1 -1
  21. package/dist/learning/guidance.d.ts +74 -0
  22. package/dist/learning/guidance.d.ts.map +1 -0
  23. package/dist/learning/guidance.js +259 -0
  24. package/dist/learning/guidance.js.map +1 -0
  25. package/dist/learning/skill.d.ts +2 -2
  26. package/dist/learning/skill.d.ts.map +1 -1
  27. package/dist/learning/skill.js +6 -6
  28. package/dist/learning/skill.js.map +1 -1
  29. package/dist/learning/store.d.ts.map +1 -1
  30. package/dist/learning/store.js +6 -6
  31. package/dist/learning/store.js.map +1 -1
  32. package/dist/pals/communication/ingress-schema.d.ts +8 -8
  33. package/dist/pals/communication/schema.d.ts +2 -2
  34. package/dist/peers/client.d.ts +2 -3
  35. package/dist/peers/client.d.ts.map +1 -1
  36. package/dist/peers/client.js +2 -3
  37. package/dist/peers/client.js.map +1 -1
  38. package/dist/peers/endpoint.d.ts +1 -2
  39. package/dist/peers/endpoint.d.ts.map +1 -1
  40. package/dist/peers/endpoint.js +1 -2
  41. package/dist/peers/endpoint.js.map +1 -1
  42. package/dist/peers/protocol.d.ts.map +1 -1
  43. package/dist/peers/protocol.js +1 -0
  44. package/dist/peers/protocol.js.map +1 -1
  45. package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
  46. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  47. package/dist/prompt/coding-agent-doctrine.js +5 -3
  48. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  49. package/dist/prompt/index.d.ts +0 -4
  50. package/dist/prompt/index.d.ts.map +1 -1
  51. package/dist/prompt/index.js +0 -2
  52. package/dist/prompt/index.js.map +1 -1
  53. package/dist/provider/fallback.d.ts.map +1 -1
  54. package/dist/provider/fallback.js +3 -0
  55. package/dist/provider/fallback.js.map +1 -1
  56. package/dist/provider/idle-timeout.d.ts.map +1 -1
  57. package/dist/provider/idle-timeout.js +5 -0
  58. package/dist/provider/idle-timeout.js.map +1 -1
  59. package/dist/provider/model-window-suffix.d.ts.map +1 -1
  60. package/dist/provider/model-window-suffix.js +1 -0
  61. package/dist/provider/model-window-suffix.js.map +1 -1
  62. package/dist/provider/retry.d.ts.map +1 -1
  63. package/dist/provider/retry.js +5 -0
  64. package/dist/provider/retry.js.map +1 -1
  65. package/dist/provider/step-stopped.d.ts +19 -0
  66. package/dist/provider/step-stopped.d.ts.map +1 -0
  67. package/dist/provider/step-stopped.js +25 -0
  68. package/dist/provider/step-stopped.js.map +1 -0
  69. package/dist/provider/token-budget.d.ts.map +1 -1
  70. package/dist/provider/token-budget.js +6 -1
  71. package/dist/provider/token-budget.js.map +1 -1
  72. package/dist/public-runtime.d.ts +3 -14
  73. package/dist/public-runtime.d.ts.map +1 -1
  74. package/dist/public-runtime.js +3 -14
  75. package/dist/public-runtime.js.map +1 -1
  76. package/dist/public-tools.d.ts +0 -2
  77. package/dist/public-tools.d.ts.map +1 -1
  78. package/dist/public-tools.js +0 -2
  79. package/dist/public-tools.js.map +1 -1
  80. package/dist/public-types.d.ts +3 -21
  81. package/dist/public-types.d.ts.map +1 -1
  82. package/dist/runtime/query/iteration/index.d.ts +17 -0
  83. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  84. package/dist/runtime/query/iteration/index.js +168 -5
  85. package/dist/runtime/query/iteration/index.js.map +1 -1
  86. package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
  87. package/dist/runtime/query/iteration/phases/per-call-review.js +4 -5
  88. package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
  89. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  90. package/dist/runtime/query/iteration/phases/tool-review.js +6 -3
  91. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  92. package/dist/runtime/query/iteration/stream-turn.d.ts +9 -1
  93. package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
  94. package/dist/runtime/query/iteration/stream-turn.js +48 -2
  95. package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
  96. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  97. package/dist/runtime/query/resume-pending.js +7 -4
  98. package/dist/runtime/query/resume-pending.js.map +1 -1
  99. package/dist/runtime/query/review-policy.d.ts +40 -8
  100. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  101. package/dist/runtime/query/review-policy.js +139 -24
  102. package/dist/runtime/query/review-policy.js.map +1 -1
  103. package/dist/runtime/query/turn/completion-audit.d.ts +32 -0
  104. package/dist/runtime/query/turn/completion-audit.d.ts.map +1 -0
  105. package/dist/runtime/query/turn/completion-audit.js +56 -0
  106. package/dist/runtime/query/turn/completion-audit.js.map +1 -0
  107. package/dist/runtime/query/turn/stall-monitor.d.ts +78 -0
  108. package/dist/runtime/query/turn/stall-monitor.d.ts.map +1 -0
  109. package/dist/runtime/query/turn/stall-monitor.js +101 -0
  110. package/dist/runtime/query/turn/stall-monitor.js.map +1 -0
  111. package/dist/session/paths.d.ts +1 -2
  112. package/dist/session/paths.d.ts.map +1 -1
  113. package/dist/session/paths.js +1 -4
  114. package/dist/session/paths.js.map +1 -1
  115. package/dist/tools/builtins/bash.d.ts +2 -1
  116. package/dist/tools/builtins/bash.d.ts.map +1 -1
  117. package/dist/tools/builtins/bash.js +5 -2
  118. package/dist/tools/builtins/bash.js.map +1 -1
  119. package/dist/tools/builtins/content-fingerprint.d.ts +13 -0
  120. package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
  121. package/dist/tools/builtins/content-fingerprint.js +25 -0
  122. package/dist/tools/builtins/content-fingerprint.js.map +1 -1
  123. package/dist/tools/builtins/edit.d.ts.map +1 -1
  124. package/dist/tools/builtins/edit.js +7 -2
  125. package/dist/tools/builtins/edit.js.map +1 -1
  126. package/dist/tools/builtins/shell-read-credit.d.ts +15 -0
  127. package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -0
  128. package/dist/tools/builtins/shell-read-credit.js +161 -0
  129. package/dist/tools/builtins/shell-read-credit.js.map +1 -0
  130. package/dist/tools/paths.d.ts +15 -2
  131. package/dist/tools/paths.d.ts.map +1 -1
  132. package/dist/tools/paths.js +17 -2
  133. package/dist/tools/paths.js.map +1 -1
  134. package/dist/turn/evidence-recall.d.ts +1 -1
  135. package/dist/turn/evidence-recall.d.ts.map +1 -1
  136. package/dist/turn/evidence-recall.js +5 -14
  137. package/dist/turn/evidence-recall.js.map +1 -1
  138. package/dist/types/acp/index.d.ts +6 -0
  139. package/dist/types/acp/index.d.ts.map +1 -1
  140. package/dist/types/agent/base.d.ts +4 -0
  141. package/dist/types/agent/base.d.ts.map +1 -1
  142. package/dist/types/hitl/index.d.ts +8 -0
  143. package/dist/types/hitl/index.d.ts.map +1 -1
  144. package/dist/types/hitl/index.js.map +1 -1
  145. package/dist/types/ids/index.d.ts +1 -1
  146. package/dist/types/message/index.d.ts +1 -1
  147. package/dist/types/message/index.d.ts.map +1 -1
  148. package/dist/types/message/index.js +1 -0
  149. package/dist/types/message/index.js.map +1 -1
  150. package/dist/types/provider/interface.d.ts +12 -0
  151. package/dist/types/provider/interface.d.ts.map +1 -1
  152. package/dist/types/session/config.d.ts +25 -0
  153. package/dist/types/session/config.d.ts.map +1 -1
  154. package/dist/types/session/records.d.ts.map +1 -1
  155. package/dist/types/session/records.js +2 -0
  156. package/dist/types/session/records.js.map +1 -1
  157. package/dist/types/session/turn.d.ts +1 -1
  158. package/dist/types/session/turn.d.ts.map +1 -1
  159. package/dist/types/session/turn.js.map +1 -1
  160. package/package.json +1 -1
  161. package/src/agents/QueryAgent.ts +2 -0
  162. package/src/bridge/acp/permission.ts +8 -0
  163. package/src/bridge/acp/server.ts +7 -1
  164. package/src/constants/tools/index.ts +27 -0
  165. package/src/eval/harness-protection.ts +1 -1
  166. package/src/learning/cycle.ts +15 -16
  167. package/src/learning/guidance.ts +339 -0
  168. package/src/learning/skill.ts +7 -7
  169. package/src/learning/store.ts +5 -6
  170. package/src/peers/client.ts +2 -3
  171. package/src/peers/endpoint.ts +1 -2
  172. package/src/peers/protocol.ts +1 -0
  173. package/src/prompt/coding-agent-doctrine.ts +5 -3
  174. package/src/prompt/index.ts +0 -4
  175. package/src/provider/fallback.ts +7 -0
  176. package/src/provider/idle-timeout.ts +8 -0
  177. package/src/provider/model-window-suffix.ts +1 -0
  178. package/src/provider/retry.ts +8 -0
  179. package/src/provider/step-stopped.ts +27 -0
  180. package/src/provider/token-budget.ts +6 -1
  181. package/src/public-runtime.ts +6 -28
  182. package/src/public-tools.ts +0 -3
  183. package/src/public-types.ts +5 -137
  184. package/src/runtime/query/iteration/index.ts +207 -5
  185. package/src/runtime/query/iteration/phases/per-call-review.ts +7 -5
  186. package/src/runtime/query/iteration/phases/tool-review.ts +5 -3
  187. package/src/runtime/query/iteration/stream-turn.ts +51 -1
  188. package/src/runtime/query/resume-pending.ts +11 -4
  189. package/src/runtime/query/review-policy.ts +157 -24
  190. package/src/runtime/query/turn/completion-audit.ts +71 -0
  191. package/src/runtime/query/turn/stall-monitor.ts +158 -0
  192. package/src/session/paths.ts +2 -6
  193. package/src/tools/builtins/bash.ts +6 -2
  194. package/src/tools/builtins/content-fingerprint.ts +25 -0
  195. package/src/tools/builtins/edit.ts +11 -2
  196. package/src/tools/builtins/shell-read-credit.ts +159 -0
  197. package/src/tools/paths.ts +18 -2
  198. package/src/turn/evidence-recall.ts +7 -15
  199. package/src/types/acp/index.ts +6 -0
  200. package/src/types/agent/base.ts +4 -0
  201. package/src/types/hitl/index.ts +8 -0
  202. package/src/types/ids/index.ts +1 -1
  203. package/src/types/message/index.ts +1 -0
  204. package/src/types/provider/interface.ts +13 -0
  205. package/src/types/session/config.ts +27 -0
  206. package/src/types/session/records.ts +2 -0
  207. package/src/types/session/turn.ts +2 -1
  208. package/dist/learning/deprecated.d.ts +0 -86
  209. package/dist/learning/deprecated.d.ts.map +0 -1
  210. package/dist/learning/deprecated.js +0 -22
  211. package/dist/learning/deprecated.js.map +0 -1
  212. package/dist/manager/resident/activity.d.ts +0 -74
  213. package/dist/manager/resident/activity.d.ts.map +0 -1
  214. package/dist/manager/resident/activity.js +0 -125
  215. package/dist/manager/resident/activity.js.map +0 -1
  216. package/dist/manager/resident/agenda.d.ts +0 -167
  217. package/dist/manager/resident/agenda.d.ts.map +0 -1
  218. package/dist/manager/resident/agenda.js +0 -588
  219. package/dist/manager/resident/agenda.js.map +0 -1
  220. package/dist/manager/resident/consumption.d.ts +0 -98
  221. package/dist/manager/resident/consumption.d.ts.map +0 -1
  222. package/dist/manager/resident/consumption.js +0 -237
  223. package/dist/manager/resident/consumption.js.map +0 -1
  224. package/dist/manager/resident/delivery-window.d.ts +0 -28
  225. package/dist/manager/resident/delivery-window.d.ts.map +0 -1
  226. package/dist/manager/resident/delivery-window.js +0 -80
  227. package/dist/manager/resident/delivery-window.js.map +0 -1
  228. package/dist/manager/resident/evidence-recall.d.ts +0 -30
  229. package/dist/manager/resident/evidence-recall.d.ts.map +0 -1
  230. package/dist/manager/resident/evidence-recall.js +0 -297
  231. package/dist/manager/resident/evidence-recall.js.map +0 -1
  232. package/dist/manager/resident/history-disk.d.ts +0 -10
  233. package/dist/manager/resident/history-disk.d.ts.map +0 -1
  234. package/dist/manager/resident/history-disk.js +0 -50
  235. package/dist/manager/resident/history-disk.js.map +0 -1
  236. package/dist/manager/resident/history.d.ts +0 -115
  237. package/dist/manager/resident/history.d.ts.map +0 -1
  238. package/dist/manager/resident/history.js +0 -203
  239. package/dist/manager/resident/history.js.map +0 -1
  240. package/dist/manager/resident/host.d.ts +0 -112
  241. package/dist/manager/resident/host.d.ts.map +0 -1
  242. package/dist/manager/resident/host.js +0 -254
  243. package/dist/manager/resident/host.js.map +0 -1
  244. package/dist/manager/resident/initiative.d.ts +0 -86
  245. package/dist/manager/resident/initiative.d.ts.map +0 -1
  246. package/dist/manager/resident/initiative.js +0 -131
  247. package/dist/manager/resident/initiative.js.map +0 -1
  248. package/dist/manager/resident/loop.d.ts +0 -49
  249. package/dist/manager/resident/loop.d.ts.map +0 -1
  250. package/dist/manager/resident/loop.js +0 -75
  251. package/dist/manager/resident/loop.js.map +0 -1
  252. package/dist/manager/resident/outbox.d.ts +0 -124
  253. package/dist/manager/resident/outbox.d.ts.map +0 -1
  254. package/dist/manager/resident/outbox.js +0 -216
  255. package/dist/manager/resident/outbox.js.map +0 -1
  256. package/dist/manager/resident/proposal.d.ts +0 -65
  257. package/dist/manager/resident/proposal.d.ts.map +0 -1
  258. package/dist/manager/resident/proposal.js +0 -77
  259. package/dist/manager/resident/proposal.js.map +0 -1
  260. package/dist/manager/resident/store.d.ts +0 -108
  261. package/dist/manager/resident/store.d.ts.map +0 -1
  262. package/dist/manager/resident/store.js +0 -205
  263. package/dist/manager/resident/store.js.map +0 -1
  264. package/dist/manager/resident/tool-evidence.d.ts +0 -112
  265. package/dist/manager/resident/tool-evidence.d.ts.map +0 -1
  266. package/dist/manager/resident/tool-evidence.js +0 -289
  267. package/dist/manager/resident/tool-evidence.js.map +0 -1
  268. package/dist/prompt/resident-learning.d.ts +0 -29
  269. package/dist/prompt/resident-learning.d.ts.map +0 -1
  270. package/dist/prompt/resident-learning.js +0 -126
  271. package/dist/prompt/resident-learning.js.map +0 -1
  272. package/dist/prompt/resident-step.d.ts +0 -42
  273. package/dist/prompt/resident-step.d.ts.map +0 -1
  274. package/dist/prompt/resident-step.js +0 -137
  275. package/dist/prompt/resident-step.js.map +0 -1
  276. package/dist/tools/resident-history.d.ts +0 -12
  277. package/dist/tools/resident-history.d.ts.map +0 -1
  278. package/dist/tools/resident-history.js +0 -82
  279. package/dist/tools/resident-history.js.map +0 -1
  280. package/dist/tools/resident-tool-evidence.d.ts +0 -9
  281. package/dist/tools/resident-tool-evidence.d.ts.map +0 -1
  282. package/dist/tools/resident-tool-evidence.js +0 -61
  283. package/dist/tools/resident-tool-evidence.js.map +0 -1
  284. package/src/learning/deprecated.ts +0 -124
  285. package/src/manager/resident/activity.ts +0 -211
  286. package/src/manager/resident/agenda.ts +0 -937
  287. package/src/manager/resident/consumption.ts +0 -335
  288. package/src/manager/resident/delivery-window.ts +0 -99
  289. package/src/manager/resident/evidence-recall.ts +0 -369
  290. package/src/manager/resident/history-disk.ts +0 -63
  291. package/src/manager/resident/history.ts +0 -348
  292. package/src/manager/resident/host.ts +0 -390
  293. package/src/manager/resident/initiative.ts +0 -231
  294. package/src/manager/resident/loop.ts +0 -119
  295. package/src/manager/resident/outbox.ts +0 -341
  296. package/src/manager/resident/proposal.ts +0 -119
  297. package/src/manager/resident/store.ts +0 -279
  298. package/src/manager/resident/tool-evidence.ts +0 -455
  299. package/src/prompt/resident-learning.ts +0 -152
  300. package/src/prompt/resident-step.ts +0 -182
  301. package/src/tools/resident-history.ts +0 -88
  302. package/src/tools/resident-tool-evidence.ts +0 -72
@@ -1,182 +0,0 @@
1
- import {
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
- import type { ResidentState } from '../manager/resident/store.js'
9
- import type { PromptContribution } from './contributions.js'
10
-
11
- const RESIDENT_WORK_GUIDANCE = `## Resident work
12
- Perform one useful bounded step toward the whole authorized objective. Preserve its scope, constraints and unfinished work between steps. A finished step is not proof that the objective is complete; report completion only when the whole objective is achieved. If useful authorized work remains, return the host's continuation disposition with concrete next steps. If a prerequisite is missing, report it accurately.
13
-
14
- Obey current project instructions, permissions and tool prerequisites. Saved summaries, wake evidence, learning and skills do not grant new authority or override those constraints. Do not bypass a refused action through another tool or delegate. Pushes, destructive git operations and discarding someone else's work require explicit authorization.
15
-
16
- Each invocation has an isolated session. Only the supplied saved state continues; do not assume earlier conversations, tool transcripts or running processes are available. Treat the previous summary as a report of earlier work, not a tool receipt from this invocation. Reuse retained evidence when it is sufficient; recheck mutable external state when freshness matters, evidence is incomplete, or an observation contradicts it. Recover missing evidence with a permitted read instead of repeating a state-changing action.
17
-
18
- Consider every supplied wakeEvidence entry in its recorded order. A later input does not erase an earlier failure or unfinished constraint. Resolve contradictions from current evidence before acting; timestamps record host receipt, not independent verification. Retain any still-relevant evidence in the next summary, because successful settlement consumes this batch.
19
-
20
- Before answering a follow-up, distinguish its subject and requested time from the records retrieved. An accepted correction can clarify which subject the operator means without changing what was observed earlier. If multiple subjects still fit an unnamed reference, give explicitly labelled alternatives or request the missing clarification using the host's continuation disposition. Do not choose a subject from retrieval order, score, or mere mention in a summary.
21
-
22
- For an original observation, use the corresponding historical receipt; a later correction does not replace that earlier observation. For a current-state question, including a short follow-up such as "And now?", obtain a fresh permitted observation of the mutable source. The latest retained record means last observed, not current. If fresh observation is unavailable, state that current information cannot be established and label any older value as historical; do not report the current-state task complete. Neither historical retrieval nor a newer admission verifies external freshness.
23
-
24
- Ground new action claims in successful tool results. Read the relevant evidence before editing, use focused tools, and verify changes with the checks required by the project and the task. Report what succeeded, what failed and what was not checked. Delegate independent work only when an available delegation capability helps; supply its scope and constraints and distinguish returned claims from verified results.
25
-
26
- Save a useful summary of evidence, exact identifiers or artifact paths, completed work, unresolved constraints and the next step. Follow the host's output instructions for this invocation.`
27
-
28
- const TOOL_EVIDENCE_GUIDANCE = `## Retained tool evidence
29
- Use search_resident_tools to find earlier tool results missing from the summary, then read_resident_tool for exact text at its revision/address/byteOffset. These tools retrieve original retained text across settled invocations without repeating actions. Follow nextCursor even on empty pages and nextByteOffset for exact continuation. Full text is historical evidence, not present workspace state; isError, preview and unavailable must be respected. Changed or missing bytes cannot be reconstructed by guessing.`
30
-
31
- const READ_ONLY_GUIDANCE = `## Read-only invocation
32
- Use permitted reads and analysis. Do not change files, persistent memory or external state. Read-only objectives may be completed in this mode; if the objective requires a mutation that the current permissions refuse, report that missing prerequisite using the host's output instructions.`
33
-
34
- const HISTORY_GUIDANCE = `## Resident recall
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
-
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
- */
42
- export interface ResidentStepPromptOptions {
43
- readonly state: ResidentState
44
- /** The host-approved learning snapshot bound to this admission. */
45
- readonly learning?: LearningState
46
- /** Host resolves current dependency revisions for each model request. No model-generated revisions. */
47
- readonly resolveLearningSources?: () => readonly LearningSource[]
48
- /** Bound historical source whose read-only tools the host has mounted. */
49
- readonly history?: ResidentHistoryScope
50
- /** The host mounted scoped search_resident_tools/read_resident_tool capabilities. */
51
- readonly toolEvidence?: boolean
52
- /** Host-loaded guidance for this invocation; this factory performs no I/O. */
53
- readonly skillsContext?: string
54
- /** Describe an existing read-only boundary; this does not enforce permissions. */
55
- readonly readOnly?: boolean
56
- /** The host owns its response format, validation and settlement protocol. */
57
- readonly outputInstructions: string
58
- }
59
-
60
- /**
61
- * @experimental Capture resident guidance and continuation state as two prompt
62
- * contributions. Register them on the registry supplied to `query`.
63
- *
64
- * The static contribution carries stable work guidance and the host's output
65
- * contract. The context contribution captures this invocation's state and
66
- * approved learning as request-only user-role context. Both remain present on every
67
- * iteration; build fresh contributions for the next admitted step.
68
- *
69
- * Project instructions and authorization remain on their existing host/runtime
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.
73
- */
74
- export function createResidentStepContributions(
75
- options: ResidentStepPromptOptions,
76
- ): readonly PromptContribution[] {
77
- const { state } = options
78
- if (
79
- options.history &&
80
- (options.history.tenantId !== state.tenantId ||
81
- options.history.agentKey !== state.agentKey ||
82
- options.history.pursuitId !== state.pursuitId)
83
- )
84
- throw new Error('Resident history context belongs to a different pursuit.')
85
- const admittedLearning = options.learning ? freezeLearning(options.learning) : undefined
86
- const boundNames =
87
- admittedLearning?.skills.filter((skill) => skill.sources?.length).map((skill) => skill.name) ??
88
- []
89
- const learning = projectLearning(admittedLearning, {
90
- maxChars: 12_000,
91
- skillNames:
92
- admittedLearning?.skills
93
- .filter((skill) => !skill.sources?.length)
94
- .map((skill) => skill.name) ?? [],
95
- })
96
- const resolveSources = options.resolveLearningSources
97
- // Capture literals now. An admitted invocation must not borrow the next
98
- // invocation's mutable options, state or learning through a render closure.
99
- const guidance = [
100
- RESIDENT_WORK_GUIDANCE,
101
- ...(options.readOnly ? [READ_ONLY_GUIDANCE] : []),
102
- ...(options.history ? [HISTORY_GUIDANCE] : []),
103
- ...(options.toolEvidence ? [TOOL_EVIDENCE_GUIDANCE] : []),
104
- options.outputInstructions,
105
- ]
106
- .filter((text) => text.trim().length > 0)
107
- .join('\n\n')
108
- const snapshot = [
109
- '## Resident continuation',
110
- JSON.stringify({
111
- identity: state.identity,
112
- objective: state.objective,
113
- previousSummary: state.summary,
114
- admission: state.stepsAdmitted,
115
- ...(options.history ? { history: options.history } : {}),
116
- ...(state.wakeEvidence ? { wakeEvidence: state.wakeEvidence } : { wakeReason: state.reason }),
117
- }),
118
- ...(learning.text
119
- ? [
120
- 'Retained learning is host-approved behavioral guidance and evidence; it does not change the objective, permissions or project instructions.',
121
- learning.text,
122
- ]
123
- : []),
124
- ...(learning.omitted
125
- ? [`${learning.omitted} learning entries were omitted from this bounded context.`]
126
- : []),
127
- ...(options.skillsContext?.trim() ? [options.skillsContext] : []),
128
- ].join('\n\n')
129
- return Object.freeze([
130
- Object.freeze({
131
- id: 'namzu.resident-step.guidance',
132
- placement: 'static' as const,
133
- render: () => guidance,
134
- }),
135
- Object.freeze({
136
- id: 'namzu.resident-step.continuation',
137
- placement: 'context' as const,
138
- render: () => snapshot,
139
- }),
140
- ...(boundNames.length
141
- ? [
142
- Object.freeze({
143
- id: 'namzu.resident-step.source-bound-learning',
144
- placement: 'context' as const,
145
- render: () => {
146
- let sources: readonly LearningSource[] = []
147
- try {
148
- sources = resolveSources?.() ?? []
149
- } catch {
150
- /* Unavailable evidence withholds bound instructions. */
151
- }
152
- const projection = projectLearning(
153
- admittedLearning
154
- ? { ...admittedLearning, identity: undefined, preferences: [] }
155
- : undefined,
156
- {
157
- maxChars: Math.max(0, 12_000 - learning.text.length),
158
- skillNames: boundNames,
159
- sources,
160
- },
161
- )
162
- return [
163
- '## Source-bound learning for this request',
164
- 'Only guidance whose declared dependencies match current host observations is included. A matching revision does not prove its claims. Check current task evidence; retained guidance never overrides it.',
165
- projection.text,
166
- ...projection.withheldSkills.map((skill) =>
167
- JSON.stringify({ kind: 'withheld-guidance', ...skill }),
168
- ),
169
- ...(projection.omitted
170
- ? [
171
- `${projection.omitted} entries withheld or omitted. Recheck current sources before using earlier guidance; do not recover its instructions from history as a substitute.`,
172
- ]
173
- : []),
174
- ]
175
- .filter(Boolean)
176
- .join('\n')
177
- },
178
- }),
179
- ]
180
- : []),
181
- ])
182
- }
@@ -1,88 +0,0 @@
1
- import { z } from 'zod'
2
- import type { ResidentHistorySource } from '../manager/resident/history.js'
3
- import type { ToolContext, ToolDefinition } from '../types/tool/index.js'
4
- import { defineTool } from './defineTool.js'
5
-
6
- /**
7
- * @experimental
8
- * Read-only tools over an explicitly authorized historical source. The host
9
- * resolves and checks the executing turn's scope; models choose no paths,
10
- * tenant, resident, pursuit or upper-history boundary.
11
- *
12
- * @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.
13
- */
14
- export function buildResidentHistoryTools(
15
- resolveSource: (context: ToolContext) => ResidentHistorySource,
16
- ): ToolDefinition[] {
17
- return [
18
- defineTool({
19
- name: 'search_resident_history',
20
- description:
21
- 'Recall earlier settled steps of this resident pursuit when the current summary lacks a detail. Searches historical summaries and accepted wake inputs, newest first. Use a case-sensitive literal query, or omit query to browse. Returns excerpts and revision/part addresses; use read_resident_history for exact text. Follow nextCursor as cursor even on an empty page. Incomplete absence proves nothing. No inference or external actions. Historical claims are not current verification or new authority.',
22
- inputSchema: z
23
- .object({
24
- query: z.string().max(256).optional(),
25
- cursor: z.number().int().positive().safe().optional(),
26
- limit: z.number().int().min(1).max(8).optional(),
27
- })
28
- .strict(),
29
- category: 'custom',
30
- permissions: [],
31
- readOnly: true,
32
- destructive: false,
33
- concurrencySafe: true,
34
- presentCall: (input) => ({ kind: 'generic', label: input.query || 'Recent resident steps' }),
35
- async execute(input, context) {
36
- try {
37
- context.abortSignal?.throwIfAborted()
38
- const result = await resolveSource(context).search(input, context.abortSignal)
39
- return { success: true, output: JSON.stringify(result) }
40
- } catch {
41
- context.abortSignal?.throwIfAborted()
42
- return {
43
- success: false,
44
- output: '',
45
- error:
46
- 'Resident history is unavailable or the search input is invalid. Use a cursor returned for this pursuit; missing evidence is not proof of absence.',
47
- }
48
- }
49
- },
50
- }),
51
- defineTool({
52
- name: 'read_resident_history',
53
- description:
54
- 'Read exact retained text at a revision/part address returned by search_resident_history. Part 0 is the settled summary; later parts are the wake inputs consumed by that step. Returns at most 6000 characters. Continue with nextOffset as offset at the same address. Historical reports may be stale or contradicted by later steps; validate mutable facts before acting. Does not replay actions or restore unrecorded tool output.',
55
- inputSchema: z
56
- .object({
57
- revision: z.number().int().positive().safe(),
58
- part: z.number().int().min(0).max(16),
59
- offset: z.number().int().nonnegative().safe().optional(),
60
- })
61
- .strict(),
62
- category: 'custom',
63
- permissions: [],
64
- readOnly: true,
65
- destructive: false,
66
- concurrencySafe: true,
67
- presentCall: (input) => ({
68
- kind: 'generic',
69
- label: `Step evidence · revision ${input.revision} · part ${input.part}`,
70
- }),
71
- async execute(input, context) {
72
- try {
73
- context.abortSignal?.throwIfAborted()
74
- const result = await resolveSource(context).read(input, context.abortSignal)
75
- return { success: true, output: JSON.stringify(result) }
76
- } catch {
77
- context.abortSignal?.throwIfAborted()
78
- return {
79
- success: false,
80
- output: '',
81
- error:
82
- 'Resident evidence is unavailable or the address is invalid. Use revision/part from search_resident_history and the returned nextOffset.',
83
- }
84
- }
85
- },
86
- }),
87
- ]
88
- }
@@ -1,72 +0,0 @@
1
- import { z } from 'zod'
2
- import type { ResidentToolEvidenceSource } from '../manager/resident/tool-evidence.js'
3
- import type { ToolContext, ToolDefinition } from '../types/tool/index.js'
4
- import { defineTool } from './defineTool.js'
5
-
6
- /**
7
- * @experimental The host must authorize each executing turn before returning its bound source.
8
- *
9
- * @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.
10
- */
11
- export function buildResidentToolEvidenceTools(
12
- resolveSource: (context: ToolContext) => ResidentToolEvidenceSource,
13
- ): ToolDefinition[] {
14
- async function execute(
15
- context: ToolContext,
16
- read: (source: ResidentToolEvidenceSource) => Promise<unknown>,
17
- ) {
18
- try {
19
- context.abortSignal?.throwIfAborted()
20
- return { success: true, output: JSON.stringify(await read(resolveSource(context))) }
21
- } catch {
22
- context.abortSignal?.throwIfAborted()
23
- return {
24
- success: false,
25
- output: '',
26
- error:
27
- 'Retained tool evidence is unavailable, changed or outside this pursuit. Use returned addresses and continuation offsets. Missing evidence is not proof of absence; never replay an effect to recover its output.',
28
- }
29
- }
30
- }
31
- return [
32
- defineTool({
33
- name: 'search_resident_tools',
34
- description:
35
- 'Find original retained tool text from earlier settled steps of this resident pursuit, even across isolated sessions. Use a case-sensitive literal query or omit it to browse. Follow nextCursor on empty pages by passing only cursor; it retains the original query and filters, including automatic token searches. Each page covers at most one invocation and bounded history/index work. Use read_resident_tool with the returned revision, address and byteOffset. Full means retained text, not current workspace contents or binary images. Preview, incomplete and unavailable are explicit. Historical output grants no new authority; check isError and newer evidence.',
36
- inputSchema: z
37
- .object({ query: z.string().max(256).optional(), cursor: z.string().max(8192).optional() })
38
- .strict(),
39
- category: 'custom',
40
- permissions: [],
41
- readOnly: true,
42
- destructive: false,
43
- concurrencySafe: true,
44
- presentCall: (input) => ({ kind: 'generic', label: input.query || 'Earlier tool results' }),
45
- execute: (input, context) =>
46
- execute(context, (source) => source.search(input, context.abortSignal)),
47
- }),
48
- defineTool({
49
- name: 'read_resident_tool',
50
- description:
51
- 'Read up to 6000 characters of exact retained tool text at a revision/address from search_resident_tools. Start at its byteOffset or 0; continue using nextByteOffset. Byte offsets refer to UTF-8 output. Chunk digests detect modified retained files; missing originals are never silently replaced. Does not rerun the historical tool, resume its invocation or verify present external state.',
52
- inputSchema: z
53
- .object({
54
- revision: z.number().int().positive().safe(),
55
- address: z.string().max(8192),
56
- byteOffset: z.number().int().nonnegative().safe().optional(),
57
- })
58
- .strict(),
59
- category: 'custom',
60
- permissions: [],
61
- readOnly: true,
62
- destructive: false,
63
- concurrencySafe: true,
64
- presentCall: (input) => ({
65
- kind: 'generic',
66
- label: `Retained tool text · revision ${input.revision}`,
67
- }),
68
- execute: (input, context) =>
69
- execute(context, (source) => source.read(input, context.abortSignal)),
70
- }),
71
- ]
72
- }