aismemory 0.8.4 → 0.8.7

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 (412) hide show
  1. package/README.md +21 -5
  2. package/dist/agent-key-mode.d.ts +1 -0
  3. package/dist/agent-key-mode.js +41 -9
  4. package/dist/agent-preference.d.ts +11 -0
  5. package/dist/agent-preference.js +5 -0
  6. package/dist/ais-http-error.d.ts +1 -1
  7. package/dist/ais-http-error.js +1 -1
  8. package/dist/ais-http.d.ts +4 -0
  9. package/dist/ais-http.js +21 -6
  10. package/dist/auto-handoff.d.ts +1 -1
  11. package/dist/auto-handoff.js +5 -1
  12. package/dist/cli/doctor.js +3 -2
  13. package/dist/cli/enable-key-auth.js +2 -2
  14. package/dist/cli/export-harness.js +2 -2
  15. package/dist/cli/hooks.d.ts +33 -0
  16. package/dist/cli/hooks.js +93 -28
  17. package/dist/cli/install.js +3 -0
  18. package/dist/cli/invite-accept.js +2 -2
  19. package/dist/cli/owner-credentials.js +2 -2
  20. package/dist/cli/pull-memory.js +2 -2
  21. package/dist/cli/setup-core.d.ts +220 -0
  22. package/dist/cli/setup-core.js +2381 -0
  23. package/dist/cli/setup.d.ts +59 -0
  24. package/dist/cli/setup.js +407 -0
  25. package/dist/declared-agent.d.ts +2 -2
  26. package/dist/declared-agent.js +2 -2
  27. package/dist/held-operating-layer.d.ts +53 -0
  28. package/dist/held-operating-layer.js +59 -0
  29. package/dist/index.js +168 -53
  30. package/dist/key-auth.d.ts +36 -0
  31. package/dist/key-auth.js +148 -2
  32. package/dist/mcp/tools.d.ts +13 -2
  33. package/dist/mcp/tools.js +103 -26
  34. package/dist/mcp-instructions.d.ts +5 -3
  35. package/dist/mcp-instructions.js +5 -3
  36. package/dist/memory-forget.d.ts +39 -0
  37. package/dist/memory-forget.js +58 -0
  38. package/dist/oauth-credentials.d.ts +1 -1
  39. package/dist/oauth-credentials.js +3 -3
  40. package/dist/operating-layer-write.d.ts +134 -0
  41. package/dist/operating-layer-write.js +224 -0
  42. package/dist/pending-device-flow.d.ts +1 -1
  43. package/dist/pending-device-flow.js +1 -1
  44. package/dist/retry-after.d.ts +1 -1
  45. package/dist/retry-after.js +1 -1
  46. package/dist/run-pass-mode.js +12 -8
  47. package/dist/session-identity.d.ts +32 -0
  48. package/dist/session-identity.js +74 -1
  49. package/dist/session-start.d.ts +68 -0
  50. package/dist/session-start.js +176 -0
  51. package/dist/startup-identity.js +23 -3
  52. package/dist/token-manager.d.ts +14 -0
  53. package/dist/token-manager.js +68 -6
  54. package/dist/tool-args.d.ts +69 -2
  55. package/dist/tool-args.js +208 -4
  56. package/dist/workspace-key-mode.d.ts +2 -0
  57. package/dist/workspace-key-mode.js +14 -9
  58. package/package.json +3 -1
  59. package/dist/__tests__/agent-archive.test.d.ts +0 -1
  60. package/dist/__tests__/agent-archive.test.js +0 -153
  61. package/dist/__tests__/agent-archive.test.js.map +0 -1
  62. package/dist/__tests__/agent-key-mode-e2e.test.d.ts +0 -1
  63. package/dist/__tests__/agent-key-mode-e2e.test.js +0 -267
  64. package/dist/__tests__/agent-key-mode-e2e.test.js.map +0 -1
  65. package/dist/__tests__/agent-key-mode.test.d.ts +0 -1
  66. package/dist/__tests__/agent-key-mode.test.js +0 -524
  67. package/dist/__tests__/agent-key-mode.test.js.map +0 -1
  68. package/dist/__tests__/agent-load-persistence.test.d.ts +0 -1
  69. package/dist/__tests__/agent-load-persistence.test.js +0 -246
  70. package/dist/__tests__/agent-load-persistence.test.js.map +0 -1
  71. package/dist/__tests__/agent-load-session-override-e2e.test.d.ts +0 -1
  72. package/dist/__tests__/agent-load-session-override-e2e.test.js +0 -214
  73. package/dist/__tests__/agent-load-session-override-e2e.test.js.map +0 -1
  74. package/dist/__tests__/agent-preference.test.d.ts +0 -1
  75. package/dist/__tests__/agent-preference.test.js +0 -181
  76. package/dist/__tests__/agent-preference.test.js.map +0 -1
  77. package/dist/__tests__/agentmemory.test.d.ts +0 -1
  78. package/dist/__tests__/agentmemory.test.js +0 -73
  79. package/dist/__tests__/agentmemory.test.js.map +0 -1
  80. package/dist/__tests__/ais-http-error.test.d.ts +0 -1
  81. package/dist/__tests__/ais-http-error.test.js +0 -49
  82. package/dist/__tests__/ais-http-error.test.js.map +0 -1
  83. package/dist/__tests__/ais-http.test.d.ts +0 -1
  84. package/dist/__tests__/ais-http.test.js +0 -247
  85. package/dist/__tests__/ais-http.test.js.map +0 -1
  86. package/dist/__tests__/auth-staleness.test.d.ts +0 -9
  87. package/dist/__tests__/auth-staleness.test.js +0 -46
  88. package/dist/__tests__/auth-staleness.test.js.map +0 -1
  89. package/dist/__tests__/auto-enroll-key-e2e.test.d.ts +0 -1
  90. package/dist/__tests__/auto-enroll-key-e2e.test.js +0 -116
  91. package/dist/__tests__/auto-enroll-key-e2e.test.js.map +0 -1
  92. package/dist/__tests__/auto-enroll-key.test.d.ts +0 -1
  93. package/dist/__tests__/auto-enroll-key.test.js +0 -208
  94. package/dist/__tests__/auto-enroll-key.test.js.map +0 -1
  95. package/dist/__tests__/auto-handoff.test.d.ts +0 -1
  96. package/dist/__tests__/auto-handoff.test.js +0 -234
  97. package/dist/__tests__/auto-handoff.test.js.map +0 -1
  98. package/dist/__tests__/beacon-contract.test.d.ts +0 -1
  99. package/dist/__tests__/beacon-contract.test.js +0 -106
  100. package/dist/__tests__/beacon-contract.test.js.map +0 -1
  101. package/dist/__tests__/bond-link-survives-exit.test.d.ts +0 -1
  102. package/dist/__tests__/bond-link-survives-exit.test.js +0 -177
  103. package/dist/__tests__/bond-link-survives-exit.test.js.map +0 -1
  104. package/dist/__tests__/cli-info.test.d.ts +0 -1
  105. package/dist/__tests__/cli-info.test.js +0 -117
  106. package/dist/__tests__/cli-info.test.js.map +0 -1
  107. package/dist/__tests__/cli-review.test.d.ts +0 -1
  108. package/dist/__tests__/cli-review.test.js +0 -26
  109. package/dist/__tests__/cli-review.test.js.map +0 -1
  110. package/dist/__tests__/client-credential-expiry.test.d.ts +0 -1
  111. package/dist/__tests__/client-credential-expiry.test.js +0 -319
  112. package/dist/__tests__/client-credential-expiry.test.js.map +0 -1
  113. package/dist/__tests__/config.test.d.ts +0 -1
  114. package/dist/__tests__/config.test.js +0 -57
  115. package/dist/__tests__/config.test.js.map +0 -1
  116. package/dist/__tests__/credential-isolation.test.d.ts +0 -1
  117. package/dist/__tests__/credential-isolation.test.js +0 -175
  118. package/dist/__tests__/credential-isolation.test.js.map +0 -1
  119. package/dist/__tests__/credential-resolution.test.d.ts +0 -1
  120. package/dist/__tests__/credential-resolution.test.js +0 -195
  121. package/dist/__tests__/credential-resolution.test.js.map +0 -1
  122. package/dist/__tests__/credential-whoami.test.d.ts +0 -8
  123. package/dist/__tests__/credential-whoami.test.js +0 -93
  124. package/dist/__tests__/credential-whoami.test.js.map +0 -1
  125. package/dist/__tests__/declared-agent.test.d.ts +0 -1
  126. package/dist/__tests__/declared-agent.test.js +0 -60
  127. package/dist/__tests__/declared-agent.test.js.map +0 -1
  128. package/dist/__tests__/delegated-read-args.test.d.ts +0 -9
  129. package/dist/__tests__/delegated-read-args.test.js +0 -80
  130. package/dist/__tests__/delegated-read-args.test.js.map +0 -1
  131. package/dist/__tests__/device-flow-gate-e2e.test.d.ts +0 -1
  132. package/dist/__tests__/device-flow-gate-e2e.test.js +0 -251
  133. package/dist/__tests__/device-flow-gate-e2e.test.js.map +0 -1
  134. package/dist/__tests__/device-flow-pending-400.test.d.ts +0 -1
  135. package/dist/__tests__/device-flow-pending-400.test.js +0 -187
  136. package/dist/__tests__/device-flow-pending-400.test.js.map +0 -1
  137. package/dist/__tests__/device-flow-recovery.test.d.ts +0 -1
  138. package/dist/__tests__/device-flow-recovery.test.js +0 -210
  139. package/dist/__tests__/device-flow-recovery.test.js.map +0 -1
  140. package/dist/__tests__/device-poll.test.d.ts +0 -12
  141. package/dist/__tests__/device-poll.test.js +0 -191
  142. package/dist/__tests__/device-poll.test.js.map +0 -1
  143. package/dist/__tests__/doctor.test.d.ts +0 -1
  144. package/dist/__tests__/doctor.test.js +0 -599
  145. package/dist/__tests__/doctor.test.js.map +0 -1
  146. package/dist/__tests__/dream-poll.test.d.ts +0 -1
  147. package/dist/__tests__/dream-poll.test.js +0 -130
  148. package/dist/__tests__/dream-poll.test.js.map +0 -1
  149. package/dist/__tests__/enable-key-auth.test.d.ts +0 -1
  150. package/dist/__tests__/enable-key-auth.test.js +0 -180
  151. package/dist/__tests__/enable-key-auth.test.js.map +0 -1
  152. package/dist/__tests__/ender-receipt-auth.test.d.ts +0 -1
  153. package/dist/__tests__/ender-receipt-auth.test.js +0 -26
  154. package/dist/__tests__/ender-receipt-auth.test.js.map +0 -1
  155. package/dist/__tests__/env-agent.test.d.ts +0 -1
  156. package/dist/__tests__/env-agent.test.js +0 -19
  157. package/dist/__tests__/env-agent.test.js.map +0 -1
  158. package/dist/__tests__/existing-hashes.test.d.ts +0 -1
  159. package/dist/__tests__/existing-hashes.test.js +0 -119
  160. package/dist/__tests__/existing-hashes.test.js.map +0 -1
  161. package/dist/__tests__/fixtures/beacon-contract.d.ts +0 -66
  162. package/dist/__tests__/fixtures/beacon-contract.js +0 -72
  163. package/dist/__tests__/fixtures/beacon-contract.js.map +0 -1
  164. package/dist/__tests__/full-context-view-forwarding.test.d.ts +0 -1
  165. package/dist/__tests__/full-context-view-forwarding.test.js +0 -99
  166. package/dist/__tests__/full-context-view-forwarding.test.js.map +0 -1
  167. package/dist/__tests__/hooks.test.d.ts +0 -1
  168. package/dist/__tests__/hooks.test.js +0 -455
  169. package/dist/__tests__/hooks.test.js.map +0 -1
  170. package/dist/__tests__/hydration.test.d.ts +0 -1
  171. package/dist/__tests__/hydration.test.js +0 -206
  172. package/dist/__tests__/hydration.test.js.map +0 -1
  173. package/dist/__tests__/inbox-client.test.d.ts +0 -1
  174. package/dist/__tests__/inbox-client.test.js +0 -108
  175. package/dist/__tests__/inbox-client.test.js.map +0 -1
  176. package/dist/__tests__/install.test.d.ts +0 -1
  177. package/dist/__tests__/install.test.js +0 -153
  178. package/dist/__tests__/install.test.js.map +0 -1
  179. package/dist/__tests__/integration.test.d.ts +0 -1
  180. package/dist/__tests__/integration.test.js +0 -37
  181. package/dist/__tests__/integration.test.js.map +0 -1
  182. package/dist/__tests__/invite-accept.test.d.ts +0 -1
  183. package/dist/__tests__/invite-accept.test.js +0 -282
  184. package/dist/__tests__/invite-accept.test.js.map +0 -1
  185. package/dist/__tests__/key-auth.test.d.ts +0 -1
  186. package/dist/__tests__/key-auth.test.js +0 -290
  187. package/dist/__tests__/key-auth.test.js.map +0 -1
  188. package/dist/__tests__/keyauth-error-surface-e2e.test.d.ts +0 -1
  189. package/dist/__tests__/keyauth-error-surface-e2e.test.js +0 -209
  190. package/dist/__tests__/keyauth-error-surface-e2e.test.js.map +0 -1
  191. package/dist/__tests__/list-all-agents.test.d.ts +0 -1
  192. package/dist/__tests__/list-all-agents.test.js +0 -49
  193. package/dist/__tests__/list-all-agents.test.js.map +0 -1
  194. package/dist/__tests__/local-claude-source.test.d.ts +0 -1
  195. package/dist/__tests__/local-claude-source.test.js +0 -97
  196. package/dist/__tests__/local-claude-source.test.js.map +0 -1
  197. package/dist/__tests__/local-mirror.test.d.ts +0 -1
  198. package/dist/__tests__/local-mirror.test.js +0 -99
  199. package/dist/__tests__/local-mirror.test.js.map +0 -1
  200. package/dist/__tests__/lost-agent.test.d.ts +0 -1
  201. package/dist/__tests__/lost-agent.test.js +0 -159
  202. package/dist/__tests__/lost-agent.test.js.map +0 -1
  203. package/dist/__tests__/mcp-init-no-auth.test.d.ts +0 -1
  204. package/dist/__tests__/mcp-init-no-auth.test.js +0 -112
  205. package/dist/__tests__/mcp-init-no-auth.test.js.map +0 -1
  206. package/dist/__tests__/mcp-instructions.test.d.ts +0 -1
  207. package/dist/__tests__/mcp-instructions.test.js +0 -26
  208. package/dist/__tests__/mcp-instructions.test.js.map +0 -1
  209. package/dist/__tests__/mcp-tools.test.d.ts +0 -1
  210. package/dist/__tests__/mcp-tools.test.js +0 -493
  211. package/dist/__tests__/mcp-tools.test.js.map +0 -1
  212. package/dist/__tests__/memory-export.test.d.ts +0 -1
  213. package/dist/__tests__/memory-export.test.js +0 -78
  214. package/dist/__tests__/memory-export.test.js.map +0 -1
  215. package/dist/__tests__/memory-pull.test.d.ts +0 -1
  216. package/dist/__tests__/memory-pull.test.js +0 -380
  217. package/dist/__tests__/memory-pull.test.js.map +0 -1
  218. package/dist/__tests__/memory-write-failure.test.d.ts +0 -1
  219. package/dist/__tests__/memory-write-failure.test.js +0 -178
  220. package/dist/__tests__/memory-write-failure.test.js.map +0 -1
  221. package/dist/__tests__/missing-credential-help.test.d.ts +0 -1
  222. package/dist/__tests__/missing-credential-help.test.js +0 -14
  223. package/dist/__tests__/missing-credential-help.test.js.map +0 -1
  224. package/dist/__tests__/no-registered-keys-disk-bearer-fallback.test.d.ts +0 -1
  225. package/dist/__tests__/no-registered-keys-disk-bearer-fallback.test.js +0 -204
  226. package/dist/__tests__/no-registered-keys-disk-bearer-fallback.test.js.map +0 -1
  227. package/dist/__tests__/oauth-credentials.test.d.ts +0 -1
  228. package/dist/__tests__/oauth-credentials.test.js +0 -29
  229. package/dist/__tests__/oauth-credentials.test.js.map +0 -1
  230. package/dist/__tests__/owner-credentials.test.d.ts +0 -1
  231. package/dist/__tests__/owner-credentials.test.js +0 -250
  232. package/dist/__tests__/owner-credentials.test.js.map +0 -1
  233. package/dist/__tests__/owner-keychain-agent-load.test.d.ts +0 -1
  234. package/dist/__tests__/owner-keychain-agent-load.test.js +0 -57
  235. package/dist/__tests__/owner-keychain-agent-load.test.js.map +0 -1
  236. package/dist/__tests__/pending-device-flow-e2e.test.d.ts +0 -19
  237. package/dist/__tests__/pending-device-flow-e2e.test.js +0 -180
  238. package/dist/__tests__/pending-device-flow-e2e.test.js.map +0 -1
  239. package/dist/__tests__/pending-device-flow-resume.test.d.ts +0 -1
  240. package/dist/__tests__/pending-device-flow-resume.test.js +0 -104
  241. package/dist/__tests__/pending-device-flow-resume.test.js.map +0 -1
  242. package/dist/__tests__/pending-device-flow.test.d.ts +0 -15
  243. package/dist/__tests__/pending-device-flow.test.js +0 -108
  244. package/dist/__tests__/pending-device-flow.test.js.map +0 -1
  245. package/dist/__tests__/pipeline-ingestion.test.d.ts +0 -1
  246. package/dist/__tests__/pipeline-ingestion.test.js +0 -286
  247. package/dist/__tests__/pipeline-ingestion.test.js.map +0 -1
  248. package/dist/__tests__/pipeline-scope-resolver.test.d.ts +0 -1
  249. package/dist/__tests__/pipeline-scope-resolver.test.js +0 -51
  250. package/dist/__tests__/pipeline-scope-resolver.test.js.map +0 -1
  251. package/dist/__tests__/pipeline-trust-tagger.test.d.ts +0 -1
  252. package/dist/__tests__/pipeline-trust-tagger.test.js +0 -24
  253. package/dist/__tests__/pipeline-trust-tagger.test.js.map +0 -1
  254. package/dist/__tests__/prompt-resource.test.d.ts +0 -1
  255. package/dist/__tests__/prompt-resource.test.js +0 -219
  256. package/dist/__tests__/prompt-resource.test.js.map +0 -1
  257. package/dist/__tests__/provisional-register-mcp-remember.test.d.ts +0 -1
  258. package/dist/__tests__/provisional-register-mcp-remember.test.js +0 -192
  259. package/dist/__tests__/provisional-register-mcp-remember.test.js.map +0 -1
  260. package/dist/__tests__/provisional-token-reauth.test.d.ts +0 -1
  261. package/dist/__tests__/provisional-token-reauth.test.js +0 -156
  262. package/dist/__tests__/provisional-token-reauth.test.js.map +0 -1
  263. package/dist/__tests__/read-claude-memory-tree.test.d.ts +0 -1
  264. package/dist/__tests__/read-claude-memory-tree.test.js +0 -37
  265. package/dist/__tests__/read-claude-memory-tree.test.js.map +0 -1
  266. package/dist/__tests__/readme-quickstart-default-ais-url.test.d.ts +0 -1
  267. package/dist/__tests__/readme-quickstart-default-ais-url.test.js +0 -80
  268. package/dist/__tests__/readme-quickstart-default-ais-url.test.js.map +0 -1
  269. package/dist/__tests__/readme-tools-parity.test.d.ts +0 -1
  270. package/dist/__tests__/readme-tools-parity.test.js +0 -64
  271. package/dist/__tests__/readme-tools-parity.test.js.map +0 -1
  272. package/dist/__tests__/recall-order-by.test.d.ts +0 -1
  273. package/dist/__tests__/recall-order-by.test.js +0 -115
  274. package/dist/__tests__/recall-order-by.test.js.map +0 -1
  275. package/dist/__tests__/reconnect-survival-e2e.test.d.ts +0 -1
  276. package/dist/__tests__/reconnect-survival-e2e.test.js +0 -319
  277. package/dist/__tests__/reconnect-survival-e2e.test.js.map +0 -1
  278. package/dist/__tests__/refresh.test.d.ts +0 -1
  279. package/dist/__tests__/refresh.test.js +0 -119
  280. package/dist/__tests__/refresh.test.js.map +0 -1
  281. package/dist/__tests__/remember-duplicate-truth.test.d.ts +0 -13
  282. package/dist/__tests__/remember-duplicate-truth.test.js +0 -117
  283. package/dist/__tests__/remember-duplicate-truth.test.js.map +0 -1
  284. package/dist/__tests__/request-timeout.test.d.ts +0 -1
  285. package/dist/__tests__/request-timeout.test.js +0 -55
  286. package/dist/__tests__/request-timeout.test.js.map +0 -1
  287. package/dist/__tests__/resolve-agent-preference-e2e.test.d.ts +0 -1
  288. package/dist/__tests__/resolve-agent-preference-e2e.test.js +0 -185
  289. package/dist/__tests__/resolve-agent-preference-e2e.test.js.map +0 -1
  290. package/dist/__tests__/resolve-agent-preference.test.d.ts +0 -1
  291. package/dist/__tests__/resolve-agent-preference.test.js +0 -94
  292. package/dist/__tests__/resolve-agent-preference.test.js.map +0 -1
  293. package/dist/__tests__/retry-after.test.d.ts +0 -4
  294. package/dist/__tests__/retry-after.test.js +0 -187
  295. package/dist/__tests__/retry-after.test.js.map +0 -1
  296. package/dist/__tests__/run-pass-mode.test.d.ts +0 -1
  297. package/dist/__tests__/run-pass-mode.test.js +0 -163
  298. package/dist/__tests__/run-pass-mode.test.js.map +0 -1
  299. package/dist/__tests__/session-identity.test.d.ts +0 -1
  300. package/dist/__tests__/session-identity.test.js +0 -276
  301. package/dist/__tests__/session-identity.test.js.map +0 -1
  302. package/dist/__tests__/signin-keychain.test.d.ts +0 -1
  303. package/dist/__tests__/signin-keychain.test.js +0 -79
  304. package/dist/__tests__/signin-keychain.test.js.map +0 -1
  305. package/dist/__tests__/silent-renewal-e2e.test.d.ts +0 -1
  306. package/dist/__tests__/silent-renewal-e2e.test.js +0 -249
  307. package/dist/__tests__/silent-renewal-e2e.test.js.map +0 -1
  308. package/dist/__tests__/split-brain-upgrade-e2e.test.d.ts +0 -1
  309. package/dist/__tests__/split-brain-upgrade-e2e.test.js +0 -206
  310. package/dist/__tests__/split-brain-upgrade-e2e.test.js.map +0 -1
  311. package/dist/__tests__/startup-credential-warning-e2e.test.d.ts +0 -1
  312. package/dist/__tests__/startup-credential-warning-e2e.test.js +0 -102
  313. package/dist/__tests__/startup-credential-warning-e2e.test.js.map +0 -1
  314. package/dist/__tests__/startup-identity.test.d.ts +0 -1
  315. package/dist/__tests__/startup-identity.test.js +0 -213
  316. package/dist/__tests__/startup-identity.test.js.map +0 -1
  317. package/dist/__tests__/sync-auth.test.d.ts +0 -1
  318. package/dist/__tests__/sync-auth.test.js +0 -69
  319. package/dist/__tests__/sync-auth.test.js.map +0 -1
  320. package/dist/__tests__/sync-doc.test.d.ts +0 -1
  321. package/dist/__tests__/sync-doc.test.js +0 -13
  322. package/dist/__tests__/sync-doc.test.js.map +0 -1
  323. package/dist/__tests__/sync-memory-cli.test.d.ts +0 -1
  324. package/dist/__tests__/sync-memory-cli.test.js +0 -200
  325. package/dist/__tests__/sync-memory-cli.test.js.map +0 -1
  326. package/dist/__tests__/telemetry.test.d.ts +0 -1
  327. package/dist/__tests__/telemetry.test.js +0 -67
  328. package/dist/__tests__/telemetry.test.js.map +0 -1
  329. package/dist/__tests__/token-expiry-reauth.test.d.ts +0 -1
  330. package/dist/__tests__/token-expiry-reauth.test.js +0 -201
  331. package/dist/__tests__/token-expiry-reauth.test.js.map +0 -1
  332. package/dist/__tests__/token-manager.test.d.ts +0 -1
  333. package/dist/__tests__/token-manager.test.js +0 -422
  334. package/dist/__tests__/token-manager.test.js.map +0 -1
  335. package/dist/__tests__/token-rejection-reauth-e2e.test.d.ts +0 -1
  336. package/dist/__tests__/token-rejection-reauth-e2e.test.js +0 -219
  337. package/dist/__tests__/token-rejection-reauth-e2e.test.js.map +0 -1
  338. package/dist/__tests__/tool-args.test.d.ts +0 -1
  339. package/dist/__tests__/tool-args.test.js +0 -289
  340. package/dist/__tests__/tool-args.test.js.map +0 -1
  341. package/dist/__tests__/trust-ledger.test.d.ts +0 -1
  342. package/dist/__tests__/trust-ledger.test.js +0 -55
  343. package/dist/__tests__/trust-ledger.test.js.map +0 -1
  344. package/dist/__tests__/version-check.test.d.ts +0 -1
  345. package/dist/__tests__/version-check.test.js +0 -364
  346. package/dist/__tests__/version-check.test.js.map +0 -1
  347. package/dist/__tests__/workspace-key-mode.test.d.ts +0 -1
  348. package/dist/__tests__/workspace-key-mode.test.js +0 -442
  349. package/dist/__tests__/workspace-key-mode.test.js.map +0 -1
  350. package/dist/agent-archive.js.map +0 -1
  351. package/dist/agent-key-mode.js.map +0 -1
  352. package/dist/agent-preference.js.map +0 -1
  353. package/dist/ais-http-error.js.map +0 -1
  354. package/dist/ais-http.js.map +0 -1
  355. package/dist/auth-staleness.js.map +0 -1
  356. package/dist/auto-handoff.js.map +0 -1
  357. package/dist/cli/doctor.js.map +0 -1
  358. package/dist/cli/enable-key-auth.js.map +0 -1
  359. package/dist/cli/export-harness.js.map +0 -1
  360. package/dist/cli/hooks.js.map +0 -1
  361. package/dist/cli/install.js.map +0 -1
  362. package/dist/cli/invite-accept.js.map +0 -1
  363. package/dist/cli/orientation.js.map +0 -1
  364. package/dist/cli/owner-credentials.js.map +0 -1
  365. package/dist/cli/pull-memory.js.map +0 -1
  366. package/dist/cli/read-claude-memory-tree.js.map +0 -1
  367. package/dist/cli/sync-memory.js.map +0 -1
  368. package/dist/cli-info.js.map +0 -1
  369. package/dist/config.js.map +0 -1
  370. package/dist/credential-expiry.js.map +0 -1
  371. package/dist/credential-whoami.js.map +0 -1
  372. package/dist/declared-agent.js.map +0 -1
  373. package/dist/device-poll.js.map +0 -1
  374. package/dist/dream-poll.js.map +0 -1
  375. package/dist/env-agent.js.map +0 -1
  376. package/dist/hydration.js.map +0 -1
  377. package/dist/inbox-client.js.map +0 -1
  378. package/dist/index.js.map +0 -1
  379. package/dist/key-auth.js.map +0 -1
  380. package/dist/local-mirror.js.map +0 -1
  381. package/dist/mcp/tools.js.map +0 -1
  382. package/dist/mcp-instructions.js.map +0 -1
  383. package/dist/memory-export.js.map +0 -1
  384. package/dist/memory-pull.js.map +0 -1
  385. package/dist/oauth-credentials.js.map +0 -1
  386. package/dist/pending-device-flow.js.map +0 -1
  387. package/dist/pipeline/bulk-store.js.map +0 -1
  388. package/dist/pipeline/dedupe.js.map +0 -1
  389. package/dist/pipeline/existing-hashes.js.map +0 -1
  390. package/dist/pipeline/ingestion.js.map +0 -1
  391. package/dist/pipeline/scope-resolver.js.map +0 -1
  392. package/dist/pipeline/sync-auth.js.map +0 -1
  393. package/dist/pipeline/trust-tagger.js.map +0 -1
  394. package/dist/pipeline/types.js.map +0 -1
  395. package/dist/prompt-resource.js.map +0 -1
  396. package/dist/refresh.js.map +0 -1
  397. package/dist/request-timeout.js.map +0 -1
  398. package/dist/retry-after.js.map +0 -1
  399. package/dist/review/cli-review.js.map +0 -1
  400. package/dist/run-pass-mode.js.map +0 -1
  401. package/dist/session-identity.js.map +0 -1
  402. package/dist/signin-keychain.js.map +0 -1
  403. package/dist/sources/local-claude.js.map +0 -1
  404. package/dist/sources/types.js.map +0 -1
  405. package/dist/startup-identity.js.map +0 -1
  406. package/dist/telemetry.js.map +0 -1
  407. package/dist/token-manager.js.map +0 -1
  408. package/dist/tool-args.js.map +0 -1
  409. package/dist/trust-ledger.js.map +0 -1
  410. package/dist/types.js.map +0 -1
  411. package/dist/version-check.js.map +0 -1
  412. package/dist/workspace-key-mode.js.map +0 -1
package/README.md CHANGED
@@ -37,7 +37,7 @@ Add to your IDE's MCP server config:
37
37
  "mcpServers": {
38
38
  "aismemory": {
39
39
  "command": "npx",
40
- "args": ["aismemory@0.8.4"],
40
+ "args": ["aismemory@0.8.7"],
41
41
  "env": {
42
42
  "npm_config_audit": "false",
43
43
  "npm_config_fund": "false"
@@ -101,14 +101,16 @@ unreachable, they print one warning line and let the session carry on.
101
101
 
102
102
  | Tool | Description |
103
103
  |------|-------------|
104
- | `remember` | Store a memory (fact, event, lesson, context, goal, task) |
104
+ | `remember` | Store a memory (fact, event, lesson, context, goal, task). Answers with a short receipt (`id`, `agentId`, `tier`, `createdAt`, `tokenEstimate`, and `supersedes` when given); pass `verbose: true` for the whole stored memory |
105
105
  | `recall` | Search memories by natural language query |
106
+ | `memory_get` | Read one memory in full by id, for a result that recall returned cut (`truncated: true`) |
107
+ | `memory_forget` | Retire one of your own memories by its full id: recall and `full_context` leave it out from then on. It is kept, not deleted (marked expired now). Own memories only; takes no agent argument |
106
108
  | `whoami` | Get agent identity and status |
107
109
  | `orientation_check` | Diff an owner-approved expected-environment manifest against this session's evidence — read-only, same comparator as `aismemory doctor --orientation`, reachable without a filesystem |
108
- | `full_context` | Load complete agent context (personality, goals, facts, skills, and the versioned operating layer — constitution rules plus the skills index) |
110
+ | `full_context` | Load complete agent context (personality, goals, facts, skills, and the versioned operating layer — constitution rules plus the skills index). On `view=lean` or `view=bootstrap`, memories tagged `no-lean` are omitted unless you pass your own `tags`, `anyTags`, or `excludeTags`. |
109
111
  | `dream` | Trigger memory consolidation (promotes important, archives old). Long runs go async: the client polls up to `AIS_DREAM_POLL_MS` (default 120000) and otherwise returns `status: "running"` with the `runId` |
110
112
  | `handoff` | Save session context for the next session |
111
- | `agent_load` | Switch the active agent by name — triggers on "get me X", "bring me X", "load X", "/agent X", "switch to X" |
113
+ | `agent_load` | Switch the active agent by name — triggers on "get me X", "bring me X", "load X", "/agent X", "switch to X". The answer carries a short readable `start` (see below) |
112
114
  | `inbox_send` | Send a message to another agent in your tenant |
113
115
  | `inbox_read` | Read messages other agents have sent you |
114
116
  | `inbox_ack` | Ack specific inbox messages by id without a fresh read |
@@ -116,9 +118,21 @@ unreachable, they print one warning line and let the session carry on.
116
118
  | `goal_list` | List goals for the current agent, with status/parent filters |
117
119
  | `goal_update_progress` | Update a goal's progress (0-100) |
118
120
  | `goal_complete` | Mark a goal complete (success or failure) |
121
+ | `operating_layer_put` | Store one rule or skill in this agent's OWN operating layer, so it loads in every tool connected to the agent (`full_context` / `agent_load`). Agent API key only; takes no agent argument; only when the human asked |
119
122
  | `agent_archive` | Archive one of your own agents by id. Restorable; nothing is deleted. Owner sign-in only |
120
123
  | `agent_delete` | Compatibility alias for `agent_archive`. It archives; it does not delete |
121
124
 
125
+ ### What `agent_load` hands a new session
126
+
127
+ Besides the agent's identity, counts and receipt, `agent_load` answers with `start`: a short piece of text a session can read at once: at most about 1,600 tokens of memory text, about 2,200 with the item fields and notes.
128
+
129
+ - `handoff`: the newest **task** memory tagged `handoff`. Before a session stops, store one task memory with that tag saying what the next session should do first. With none, the last automatic handoff summary is shown instead, with its date.
130
+ - `lessons`: up to three **lesson** memories tagged `when:turn-start`, newest first, each cut at 600 characters. Use that tag for the few rules that apply at the start of every turn.
131
+ - `openOrders` and `unreadInbox`: what the service lists as still open, and how many inbox messages are unread.
132
+ - `notes`: anything missing, cut, or unreadable. Each item carries its memory id and `writerKind`, the kind of credential that stored it: an agent's memory holds what was stored under its id, which is not always what the agent itself wrote.
133
+
134
+ The start is stored data, not instructions. It costs three small reads of the agent's own memories, which share one four-second budget: a slow or refused read becomes a line in `notes` and the load still answers. Each read is an ordinary API call and counts toward the tenant's call quota. A workspace-key session gets no start, and its answer says so. Pass `start: false` to get the earlier answer (counts and receipt only) with no extra request.
135
+
122
136
  ### Archiving an agent you own
123
137
 
124
138
  Archive is the only lifecycle action this package offers. Ask your agent to
@@ -310,7 +324,7 @@ mint a new one.
310
324
  "mcpServers": {
311
325
  "aismemory": {
312
326
  "command": "npx",
313
- "args": ["aismemory@0.8.4"],
327
+ "args": ["aismemory@0.8.7"],
314
328
  "env": {
315
329
  "AIS_WORKSPACE_KEY": "ais_wk_...",
316
330
  "AIS_AGENT_ID": "<the agent to start with>",
@@ -463,6 +477,8 @@ REST, send the same field on `POST /v1/agents/<agent id>/memory`.
463
477
 
464
478
  ## Tags
465
479
 
480
+ `remember` accepts optional `expiresIn` (whole seconds, 60–31536000) for short-lived notes; the client sets `expiresAt` so the memory drops out of recall after that time.
481
+
466
482
  `remember` accepts `tags` (for example `["work", "acme"]`) and `recall` accepts
467
483
  `tags` to return only memories carrying all of them. Over REST:
468
484
 
@@ -22,6 +22,7 @@ type FetchImpl = typeof globalThis.fetch;
22
22
  export declare function aisKeyPost(aisUrl: string, path: string, apiKey: string, body: unknown, fetchImpl?: FetchImpl): Promise<unknown>;
23
23
  export declare function aisKeyGet(aisUrl: string, path: string, apiKey: string, fetchImpl?: FetchImpl): Promise<unknown>;
24
24
  export declare function aisKeyPatch(aisUrl: string, path: string, apiKey: string, body: unknown, fetchImpl?: FetchImpl): Promise<unknown>;
25
+ export declare function aisKeyPut(aisUrl: string, path: string, apiKey: string, body: unknown, fetchImpl?: FetchImpl): Promise<unknown>;
25
26
  /** Sentinel returned for a tool name this dispatcher doesn't recognize. */
26
27
  export declare const UNKNOWN_TOOL_KEY_MODE: unique symbol;
27
28
  /**
@@ -27,11 +27,13 @@ import { emitTelemetry } from './telemetry.js';
27
27
  import { retryAfterOf, shouldHonourRetryAfter, sleepSeconds } from './retry-after.js';
28
28
  import { getAisRequestTimeoutMs, toAisRequestError } from './request-timeout.js';
29
29
  import { withDeclaredAgent } from './declared-agent.js';
30
- import { parseEmptyToolArgs, parseRecallArgs, buildFullContextQuery, parseFullContextArgs, parseRememberArgs, parseInboxSendArgs, parseInboxReadArgs, parseGoalCreateArgs, parseGoalListArgs, parseGoalUpdateProgressArgs, parseGoalCompleteArgs, parseInboxAckArgs, parseHandoffArgs, } from './tool-args.js';
30
+ import { parseEmptyToolArgs, parseRecallArgs, parseMemoryGetArgs, buildMemoryGetPath, shapeMemoryGetResult, buildFullContextQuery, parseFullContextArgs, buildRememberStoreBody, shapeRememberResult, parseRememberArgs, parseInboxSendArgs, parseInboxReadArgs, parseGoalCreateArgs, parseGoalListArgs, parseGoalUpdateProgressArgs, parseGoalCompleteArgs, parseInboxAckArgs, parseHandoffArgs, } from './tool-args.js';
31
31
  import { readInboxAndMaybeAck } from './inbox-client.js';
32
32
  import { AGENT_ARCHIVE_KEY_MODE_DETAIL } from './agent-archive.js';
33
+ import { OPERATING_LAYER_PUT_TOOL, putOperatingLayerEntry } from './operating-layer-write.js';
33
34
  import { fetchCredentialWhoami } from './credential-whoami.js';
34
35
  import { resolveDreamResponse } from './dream-poll.js';
36
+ import { forgetOwnMemory } from './memory-forget.js';
35
37
  /** Thrown by loadAgentApiKeyConfig when AIS_AGENT_API_KEY is set without AIS_AGENT_ID. */
36
38
  export class AgentApiKeyConfigError extends Error {
37
39
  constructor(message) {
@@ -135,7 +137,7 @@ export async function aisKeyGet(aisUrl, path, apiKey, fetchImpl = globalThis.fet
135
137
  // Same single-retry-on-idempotent-GET policy as aisGet (CORBOT-9492F31A),
136
138
  // extended here so x-agent-api-key customers get the identical Railway-
137
139
  // edge-502 protection (CORBOT-6F45EDFA) — this GET is just as idempotent
138
- // regardless of which auth header carries it. Jaire C9: when the server
140
+ // regardless of which auth header carries it. Tester finding C9: when the server
139
141
  // names a short wait (429/503 Retry-After) that wait is honoured for the
140
142
  // one retry; a long one is reported, not slept through. Writes are never
141
143
  // retried.
@@ -191,6 +193,33 @@ export async function aisKeyPatch(aisUrl, path, apiKey, body, fetchImpl = global
191
193
  }
192
194
  return data;
193
195
  }
196
+ export async function aisKeyPut(aisUrl, path, apiKey, body, fetchImpl = globalThis.fetch) {
197
+ const headers = withDeclaredAgent({
198
+ 'Content-Type': 'application/json',
199
+ 'x-agent-api-key': apiKey,
200
+ });
201
+ const timeoutMs = getAisRequestTimeoutMs();
202
+ let res;
203
+ try {
204
+ res = await fetchImpl(`${aisUrl}${path}`, {
205
+ method: 'PUT',
206
+ headers,
207
+ body: JSON.stringify(body),
208
+ signal: AbortSignal.timeout(timeoutMs),
209
+ });
210
+ }
211
+ catch (err) {
212
+ const wrapped = toAisRequestError(err, path, timeoutMs, 'PUT');
213
+ emitTelemetry({ event: 'ais.http.failure', path, error: wrapped instanceof Error ? wrapped.message : String(wrapped) });
214
+ throw wrapped;
215
+ }
216
+ const data = await readJson(res);
217
+ if (!res.ok) {
218
+ emitTelemetry({ event: 'ais.http.failure', path, httpStatus: res.status, error: `HTTP ${res.status}` });
219
+ throw new AisHttpError(res.status, path, data, retryAfterOf(res));
220
+ }
221
+ return data;
222
+ }
194
223
  // ── Scoped tool dispatch ─────────────────────────────────────────────────
195
224
  /** Sentinel returned for a tool name this dispatcher doesn't recognize. */
196
225
  export const UNKNOWN_TOOL_KEY_MODE = Symbol('unknown-tool-key-mode');
@@ -213,13 +242,7 @@ export async function dispatchToolKeyMode(aisUrl, config, name, rawArgs, fetchIm
213
242
  case 'remember': {
214
243
  const args = parseRememberArgs(rawArgs);
215
244
  try {
216
- return await aisKeyPost(aisUrl, `/v1/agents/${agentId}/memory`, apiKey, {
217
- content: args.content,
218
- type: args.type,
219
- importance: args.importance,
220
- ...(args.tags !== undefined && { tags: args.tags }),
221
- ...(args.supersedes !== undefined && { supersedes: args.supersedes }),
222
- }, fetchImpl);
245
+ return shapeRememberResult(await aisKeyPost(aisUrl, `/v1/agents/${agentId}/memory`, apiKey, buildRememberStoreBody(args), fetchImpl), args);
223
246
  }
224
247
  catch (err) {
225
248
  // CORBOT-F21668B5: a deduplicated write is not a lost write — report
@@ -247,6 +270,12 @@ export async function dispatchToolKeyMode(aisUrl, config, name, rawArgs, fetchIm
247
270
  }
248
271
  return aisKeyGet(aisUrl, `/v1/agents/${agentId}/memory?${params}`, apiKey, fetchImpl);
249
272
  }
273
+ case 'memory_get': {
274
+ const getArgs = parseMemoryGetArgs(rawArgs);
275
+ return shapeMemoryGetResult(await aisKeyGet(aisUrl, buildMemoryGetPath(agentId, getArgs), apiKey, fetchImpl), getArgs);
276
+ }
277
+ case 'memory_forget':
278
+ return forgetOwnMemory(agentId, rawArgs, (path, body) => aisKeyPatch(aisUrl, path, apiKey, body, fetchImpl));
250
279
  case 'full_context': {
251
280
  const fcArgs = parseFullContextArgs(rawArgs);
252
281
  const fcQs = buildFullContextQuery(fcArgs);
@@ -342,6 +371,9 @@ export async function dispatchToolKeyMode(aisUrl, config, name, rawArgs, fetchIm
342
371
  ...(args.docPrUrl !== undefined ? { docPrUrl: args.docPrUrl } : {}),
343
372
  }, fetchImpl);
344
373
  }
374
+ case OPERATING_LAYER_PUT_TOOL:
375
+ // The target is the key's own agent; the tool takes no agent argument.
376
+ return putOperatingLayerEntry(agentId, rawArgs, (path, body) => aisKeyPut(aisUrl, path, apiKey, body, fetchImpl), (path) => aisKeyGet(aisUrl, path, apiKey, fetchImpl));
345
377
  case 'agent_load':
346
378
  throw new OutOfScopeToolError('agent_load', 'switching agents requires a tenant-wide agent-listing route, which is outside the ' +
347
379
  "key's allowed scope. The active agent is fixed to AIS_AGENT_ID for the life of this process.");
@@ -1,9 +1,17 @@
1
1
  export interface AgentPreference {
2
2
  schemaVersion: 2;
3
+ /** Only the same explicit harness session may restore this choice. */
4
+ sessionId?: string;
3
5
  agentId: string;
4
6
  tenantId: string;
5
7
  /** Owner user id for keychain account naming — not a secret (CORBOT-51CAC5E8). */
6
8
  ownerUserId?: string;
9
+ /**
10
+ * Set when agent_load wrote this preference without an in-session pin. A new
11
+ * unchosen MCP process must not adopt this identity. Only a matching
12
+ * explicit sessionId can restore the choice (CORBOT-F456BD9D).
13
+ */
14
+ awaitingSessionLoad?: boolean;
7
15
  }
8
16
  /**
9
17
  * Persist agent preference (schemaVersion + ids, no secrets) under
@@ -19,6 +27,7 @@ export declare function saveAgentPreference(pref: {
19
27
  agentId: string;
20
28
  tenantId: string;
21
29
  ownerUserId?: string;
30
+ awaitingSessionLoad?: boolean;
22
31
  }, home?: string): void;
23
32
  /**
24
33
  * Migrate a legacy v1 credentials.json (token/agentId/tenantId/expiresAt) to
@@ -60,4 +69,6 @@ export declare function loadAgentPreference(home?: string, hasKey?: () => boolea
60
69
  agentId: string;
61
70
  tenantId: string;
62
71
  ownerUserId?: string;
72
+ awaitingSessionLoad?: boolean;
73
+ sessionId?: string;
63
74
  } | null;
@@ -26,9 +26,11 @@ export function saveAgentPreference(pref, home = homedir()) {
26
26
  // Write the file with schemaVersion + ids (no legacy token/expiresAt)
27
27
  const data = {
28
28
  schemaVersion: 2,
29
+ ...(process.env.CLAUDE_SESSION_ID ? { sessionId: process.env.CLAUDE_SESSION_ID } : {}),
29
30
  agentId: pref.agentId,
30
31
  tenantId: pref.tenantId,
31
32
  ...(pref.ownerUserId ? { ownerUserId: pref.ownerUserId } : {}),
33
+ ...(pref.awaitingSessionLoad === true ? { awaitingSessionLoad: true } : {}),
32
34
  };
33
35
  writeFileSync(tmp, JSON.stringify(data, null, 2), { mode: 0o600 });
34
36
  renameSync(tmp, file);
@@ -118,10 +120,13 @@ export function loadAgentPreference(home = homedir(), hasKey = defaultHasKey(hom
118
120
  const tenantId = parsed.tenantId;
119
121
  if (typeof agentId === 'string' && typeof tenantId === 'string') {
120
122
  const ownerUserId = parsed.ownerUserId;
123
+ const awaitingSessionLoad = parsed.awaitingSessionLoad;
121
124
  return {
122
125
  agentId,
123
126
  tenantId,
127
+ ...(typeof parsed.sessionId === 'string' ? { sessionId: parsed.sessionId } : {}),
124
128
  ...(typeof ownerUserId === 'string' ? { ownerUserId } : {}),
129
+ ...(awaitingSessionLoad === true ? { awaitingSessionLoad: true } : {}),
125
130
  };
126
131
  }
127
132
  return null;
@@ -22,7 +22,7 @@ export declare class AisHttpError extends Error {
22
22
  readonly status: number;
23
23
  readonly path: string;
24
24
  readonly body: unknown;
25
- /** Server-requested wait from `Retry-After` on a 429/503, else null (Jaire C9). */
25
+ /** Server-requested wait from `Retry-After` on a 429/503, else null (tester finding C9). */
26
26
  readonly retryAfterSeconds: number | null;
27
27
  constructor(status: number, path: string, body: unknown, retryAfterSeconds?: number | null);
28
28
  }
@@ -67,7 +67,7 @@ export class AisHttpError extends Error {
67
67
  status;
68
68
  path;
69
69
  body;
70
- /** Server-requested wait from `Retry-After` on a 429/503, else null (Jaire C9). */
70
+ /** Server-requested wait from `Retry-After` on a 429/503, else null (tester finding C9). */
71
71
  retryAfterSeconds;
72
72
  constructor(status, path, body, retryAfterSeconds = null) {
73
73
  super(formatAisHttpError(status, path, body, retryAfterSeconds));
@@ -7,6 +7,10 @@ export declare const AIS_GET_RETRY_DELAY_MS = 250;
7
7
  export declare const CLIENT_VERSION_HEADER = "X-AIS-Client-Version";
8
8
  export declare const UPDATE_NOTICE_HEADER = "X-AIS-Update-Notice";
9
9
  export declare const DEFAULT_AIS_URL = "https://ais.agentsandswarms.ai";
10
+ /** Refuse plaintext owner credentials except for explicit local development hosts. */
11
+ export declare function validateAisUrl(aisUrl: string): void;
12
+ /** Resolve a configured AIS_URL (or the default) and fail closed on insecure schemes. */
13
+ export declare function resolveAisUrl(configured: string | undefined): string;
10
14
  export declare function aisPost(path: string, body: unknown, token?: string): Promise<unknown>;
11
15
  export declare function aisPatch(path: string, body: unknown, token?: string): Promise<unknown>;
12
16
  export declare function aisGet(path: string, token: string): Promise<unknown>;
package/dist/ais-http.js CHANGED
@@ -50,17 +50,29 @@ function captureUpdateNotice(res) {
50
50
  setServerUpdateNotice(notice);
51
51
  }
52
52
  export const DEFAULT_AIS_URL = 'https://ais.agentsandswarms.ai';
53
- function getAisUrl() {
54
- const configured = process.env['AIS_URL']?.trim();
55
- const aisUrl = configured || DEFAULT_AIS_URL;
53
+ /** Refuse plaintext owner credentials except for explicit local development hosts. */
54
+ export function validateAisUrl(aisUrl) {
55
+ let parsed;
56
56
  try {
57
- new URL(aisUrl);
57
+ parsed = new URL(aisUrl);
58
58
  }
59
59
  catch {
60
- throw new Error(`AIS_URL is not a valid URL: ${aisUrl}`);
60
+ throw new Error('AIS_URL is not a valid URL');
61
+ }
62
+ const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(parsed.hostname);
63
+ if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopback)) {
64
+ throw new Error('AIS_URL must use HTTPS or HTTP on loopback');
61
65
  }
66
+ }
67
+ /** Resolve a configured AIS_URL (or the default) and fail closed on insecure schemes. */
68
+ export function resolveAisUrl(configured) {
69
+ const aisUrl = configured?.trim() || DEFAULT_AIS_URL;
70
+ validateAisUrl(aisUrl);
62
71
  return aisUrl;
63
72
  }
73
+ function getAisUrl() {
74
+ return resolveAisUrl(process.env['AIS_URL']);
75
+ }
64
76
  function buildUrl(path) {
65
77
  const aisUrl = getAisUrl();
66
78
  const baseUrl = aisUrl.endsWith('/') ? aisUrl : `${aisUrl}/`;
@@ -91,6 +103,7 @@ export async function aisPost(path, body, token) {
91
103
  method: 'POST',
92
104
  headers,
93
105
  body: JSON.stringify(body),
106
+ redirect: 'error',
94
107
  signal: AbortSignal.timeout(timeoutMs),
95
108
  });
96
109
  }
@@ -132,6 +145,7 @@ export async function aisPatch(path, body, token) {
132
145
  method: 'PATCH',
133
146
  headers,
134
147
  body: JSON.stringify(body),
148
+ redirect: 'error',
135
149
  signal: AbortSignal.timeout(timeoutMs),
136
150
  });
137
151
  }
@@ -167,6 +181,7 @@ export async function aisGet(path, token) {
167
181
  try {
168
182
  res = await fetch(buildUrl(path), {
169
183
  headers: withDeclaredAgent(withClientVersion({ 'Authorization': `Bearer ${token}` })),
184
+ redirect: 'error',
170
185
  signal: AbortSignal.timeout(timeoutMs),
171
186
  });
172
187
  }
@@ -179,7 +194,7 @@ export async function aisGet(path, token) {
179
194
  });
180
195
  throw wrapped;
181
196
  }
182
- // Jaire C9: a short server-requested wait (429/503 Retry-After) is
197
+ // Tester finding C9: a short server-requested wait (429/503 Retry-After) is
183
198
  // honoured for the one retry; a long one is reported, not slept through.
184
199
  const retryAfter = retryAfterOf(res);
185
200
  const retryable = retryAfter === null
@@ -14,4 +14,4 @@ export interface HandoffPayload {
14
14
  keyLearnings: string[];
15
15
  }
16
16
  export declare function buildHandoffPayload(tracker: ActivityTracker): HandoffPayload;
17
- export declare function setupAutoHandoff(aisUrl: string, agentId: string, token: string, tracker: ActivityTracker, onBeforeExit?: () => void, beforeWrite?: () => Promise<void>): void;
17
+ export declare function setupAutoHandoff(aisUrl: string, agentId: string, token: string, tracker: ActivityTracker, onBeforeExit?: () => void, beforeWrite?: () => Promise<void>): () => void;
@@ -92,7 +92,7 @@ export function setupAutoHandoff(aisUrl, agentId, token, tracker, onBeforeExit,
92
92
  // failure. Without this check the catch below never fires on a rejected
93
93
  // handoff and the session exits as though its handoff had landed, which
94
94
  // is exactly how a production 500 on this route stayed invisible to
95
- // every client (Jaire reconciliation 2026-09-17, defect 2).
95
+ // every client (tester reconciliation 2026-09-17, defect 2).
96
96
  if (!response.ok) {
97
97
  process.stderr.write(`[aismemory] Auto-handoff was NOT saved — the server rejected it (${await describeHandoffFailure(response)}). This session's handoff is lost.\n`);
98
98
  }
@@ -108,5 +108,9 @@ export function setupAutoHandoff(aisUrl, agentId, token, tracker, onBeforeExit,
108
108
  };
109
109
  process.on('SIGTERM', onSignal);
110
110
  process.on('SIGINT', onSignal);
111
+ return () => {
112
+ process.off('SIGTERM', onSignal);
113
+ process.off('SIGINT', onSignal);
114
+ };
111
115
  }
112
116
  //# sourceMappingURL=auto-handoff.js.map
@@ -32,7 +32,7 @@ import { identityCredentialFingerprint, loadSessionIdentity, legacyHarnessManife
32
32
  import { loadAgentApiKeyConfig, dispatchToolKeyMode, AgentApiKeyConfigError } from '../agent-key-mode.js';
33
33
  import { loadWorkspaceKeyConfig, dispatchToolWorkspaceKeyMode, WorkspaceKeyConfigError } from '../workspace-key-mode.js';
34
34
  import { AisHttpError } from '../ais-http-error.js';
35
- import { DEFAULT_AIS_URL } from '../ais-http.js';
35
+ import { resolveAisUrl } from '../ais-http.js';
36
36
  import { checkForUpdate, isUpdateStatus, readPackageVersion, } from '../version-check.js';
37
37
  import { findDuplicateServerNames, formatDuplicateServerWarning } from '../startup-identity.js';
38
38
  /** Minimum Node major version this package requires (per @modelcontextprotocol/sdk engines). */
@@ -475,7 +475,8 @@ export async function checkPackageVersion(options = {}) {
475
475
  }
476
476
  export async function runDoctor(options = {}) {
477
477
  const env = options.env ?? process.env;
478
- const aisUrl = options.aisUrl ?? env['AIS_URL'] ?? DEFAULT_AIS_URL;
478
+ // Fail closed before any request: checks send owner/workspace/agent bearers.
479
+ const aisUrl = resolveAisUrl(options.aisUrl ?? env['AIS_URL']);
479
480
  const host = new URL(aisUrl).hostname;
480
481
  const fetchImpl = options.fetchImpl ?? fetch;
481
482
  const now = options.now ?? Date.now;
@@ -21,7 +21,7 @@
21
21
  import { loadOAuthCredentials, loadNonStaleDiskBearer } from '../oauth-credentials.js';
22
22
  import { createTokenManager, isNoRegisteredKeyFailure } from '../token-manager.js';
23
23
  import { generateAndSaveKeypair, tryKeyAuth } from '../key-auth.js';
24
- import { DEFAULT_AIS_URL } from '../ais-http.js';
24
+ import { resolveAisUrl } from '../ais-http.js';
25
25
  const PREFIX = '[aismemory enable-key-auth]';
26
26
  async function loadBootstrapCreds(aisUrl) {
27
27
  const saved = loadOAuthCredentials();
@@ -76,7 +76,7 @@ function log(msg) {
76
76
  process.stderr.write(`${PREFIX} ${msg}\n`);
77
77
  }
78
78
  async function main() {
79
- const aisUrl = process.env['AIS_URL'] ?? DEFAULT_AIS_URL;
79
+ const aisUrl = resolveAisUrl(process.env['AIS_URL']);
80
80
  // 1. Find a bootstrap bearer token.
81
81
  const creds = await loadBootstrapCreds(aisUrl);
82
82
  if (!creds) {
@@ -14,7 +14,7 @@ import { realpathSync } from 'node:fs';
14
14
  import { resolve } from 'node:path';
15
15
  import { pathToFileURL } from 'node:url';
16
16
  import { loadAgentApiKeyConfig, AgentApiKeyConfigError } from '../agent-key-mode.js';
17
- import { DEFAULT_AIS_URL } from '../ais-http.js';
17
+ import { resolveAisUrl } from '../ais-http.js';
18
18
  import { pullMemories, describePullFailure } from '../memory-pull.js';
19
19
  import { renderHarnessMarkdown, DEFAULT_EXPORT_TYPES } from '../memory-export.js';
20
20
  import { writeBackupFile } from './pull-memory.js';
@@ -87,7 +87,7 @@ export async function main(argv = process.argv.slice(2)) {
87
87
  if (!config) {
88
88
  throw new Error('AIS_API_KEY is not set. export-harness needs an agent API key and AIS_AGENT_ID.');
89
89
  }
90
- const aisUrl = (process.env['AIS_URL']?.trim() || DEFAULT_AIS_URL).replace(/\/+$/, '');
90
+ const aisUrl = resolveAisUrl(process.env['AIS_URL']).replace(/\/+$/, '');
91
91
  const result = await pullMemories({ aisUrl, agentId: config.agentId, apiKey: config.apiKey });
92
92
  const markdown = renderHarnessMarkdown(result.memories, toFilter(args));
93
93
  if (args.out) {
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { type SessionIdentity } from '../session-identity.js';
2
3
  export declare function hookCommand(version: string, sub: string): string;
3
4
  export declare class HooksSettingsError extends Error {
4
5
  constructor(message: string);
@@ -17,7 +18,24 @@ export interface InstallHooksOptions {
17
18
  /** Write .claude/settings.local.json (this user only) instead of the shared settings.json. */
18
19
  local?: boolean;
19
20
  }
21
+ /** Write `content` beside `targetPath` then rename over it; preserves mode when the file exists. */
22
+ export declare function writeTextFileAtomic(targetPath: string, content: string): void;
23
+ /** Backs up `path` to `path.aismemory-backup` once, with the source file's permissions. */
24
+ export declare function backupFileOnce(sourcePath: string): Promise<void>;
20
25
  export declare function installHooks(opts: InstallHooksOptions): InstallHooksResult;
26
+ type HookTool = 'full_context' | 'handoff' | 'whoami';
27
+ export interface HookClient {
28
+ agentId: string;
29
+ /** This session's own AIS_AGENT_ID pin, which gates writes exactly as in the server. */
30
+ pin: SessionIdentity | null;
31
+ credentialKey: string;
32
+ call(tool: HookTool, args: Record<string, unknown>): Promise<unknown>;
33
+ }
34
+ /** A failure whose message is already the one-line, secret-free hint we print. */
35
+ export declare class HookFailure extends Error {
36
+ }
37
+ export declare const NO_CREDENTIAL_HINT = "no credential; set AIS_WORKSPACE_KEY and AIS_AGENT_ID or run aismemory to sign in";
38
+ export declare function resolveHookClient(env: NodeJS.ProcessEnv, home: string): Promise<HookClient>;
21
39
  export declare function redactSecrets(text: string): string;
22
40
  /** One concise, secret-free stderr line naming the cause and the fix. */
23
41
  export declare function describeHookFailure(err: unknown): string;
@@ -34,6 +52,15 @@ export declare function rulesTags(nonce: string): {
34
52
  close: string;
35
53
  };
36
54
  export declare const OPERATING_LAYER_PREAMBLE: string;
55
+ /** Strip zero-width and bidi controls from rule text (same set as {@link inline}). */
56
+ export declare function stripInvisibles(text: string): string;
57
+ /**
58
+ * Stored text is one line and never a heading: other principals (grant
59
+ * holders, shared sources) can write these fields. The nonce is what stops a
60
+ * forged close tag; neutralising the plain tag forms (after NFKC folds
61
+ * fullwidth brackets) only keeps the block readable.
62
+ */
63
+ export declare function inline(text: string): string;
37
64
  /** The compact, delimited markdown block Claude Code adds to the session. */
38
65
  export declare function formatSessionContext(response: unknown, agentId: string, nonce?: string): string;
39
66
  export interface HookOutput {
@@ -47,6 +74,12 @@ export interface HookDeps {
47
74
  runGit?: (cwd: string, args: string[]) => Promise<string>;
48
75
  }
49
76
  export declare function runSessionStart(deps?: HookDeps): Promise<HookOutput>;
77
+ export interface SetupFullContextResult {
78
+ response: unknown;
79
+ client: HookClient;
80
+ }
81
+ /** Authenticated `full_context` for setup planning (no MCP tool mocking). */
82
+ export declare function fetchSetupFullContext(deps?: HookDeps): Promise<SetupFullContextResult>;
50
83
  declare const hookInputSchema: z.ZodObject<{
51
84
  session_id: z.ZodOptional<z.ZodString>;
52
85
  transcript_path: z.ZodOptional<z.ZodString>;