@strands-agents/cli 0.2.4 → 0.4.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 (453) hide show
  1. package/README.md +217 -133
  2. package/bin/strands.js +1 -5
  3. package/dist/src/{tui/strands-backend.js → agent/backend.js} +90 -28
  4. package/dist/src/agent/backend.js.map +1 -0
  5. package/dist/src/{tui/background/activity.js → agent/background.js} +173 -6
  6. package/dist/src/agent/background.js.map +1 -0
  7. package/dist/src/{tui/agent-configuration.js → agent/configuration.js} +62 -105
  8. package/dist/src/agent/configuration.js.map +1 -0
  9. package/dist/src/agent/context.js +112 -0
  10. package/dist/src/agent/context.js.map +1 -0
  11. package/dist/src/{tui/chat/sdk-projector.js → agent/events.js} +6 -5
  12. package/dist/src/agent/events.js.map +1 -0
  13. package/dist/src/{tui/permissions/file-change-preview.js → agent/file-changes.js} +10 -8
  14. package/dist/src/agent/file-changes.js.map +1 -0
  15. package/dist/src/agent/mcp.js +436 -0
  16. package/dist/src/agent/mcp.js.map +1 -0
  17. package/dist/src/agent/messaging.js +424 -0
  18. package/dist/src/agent/messaging.js.map +1 -0
  19. package/dist/src/agent/permission-rules.js +267 -0
  20. package/dist/src/agent/permission-rules.js.map +1 -0
  21. package/dist/src/agent/permissions.js +288 -0
  22. package/dist/src/agent/permissions.js.map +1 -0
  23. package/dist/src/agent/runtime.js +524 -0
  24. package/dist/src/agent/runtime.js.map +1 -0
  25. package/dist/src/{tui/workspace → agent}/sandbox.js +92 -25
  26. package/dist/src/agent/sandbox.js.map +1 -0
  27. package/dist/src/{tui/chat → agent}/shell.js +1 -1
  28. package/dist/src/agent/shell.js.map +1 -0
  29. package/dist/src/{tui → agent}/skills.js +37 -56
  30. package/dist/src/agent/skills.js.map +1 -0
  31. package/dist/src/{tui/builtin-tools.js → agent/tools.js} +2 -3
  32. package/dist/src/agent/tools.js.map +1 -0
  33. package/dist/src/agent/types.js.map +1 -0
  34. package/dist/src/{tui/voice/session.js → agent/voice.js} +221 -224
  35. package/dist/src/agent/voice.js.map +1 -0
  36. package/dist/src/{tui/acp/projection.js → cli/acp-events.js} +19 -4
  37. package/dist/src/cli/acp-events.js.map +1 -0
  38. package/dist/src/{tui/project/acp.js → cli/acp-python.js} +41 -18
  39. package/dist/src/cli/acp-python.js.map +1 -0
  40. package/dist/src/{tui/acp/server.js → cli/acp.js} +149 -46
  41. package/dist/src/cli/acp.js.map +1 -0
  42. package/dist/src/cli/arguments.js +8 -3
  43. package/dist/src/cli/arguments.js.map +1 -1
  44. package/dist/src/{console.js → cli/console.js} +69 -4
  45. package/dist/src/cli/console.js.map +1 -0
  46. package/dist/src/cli/invocation.js +75 -44
  47. package/dist/src/cli/invocation.js.map +1 -1
  48. package/dist/src/cli/run.js +66 -38
  49. package/dist/src/cli/run.js.map +1 -1
  50. package/dist/src/{tui → cli}/telemetry.js +2 -2
  51. package/dist/src/{tui → cli}/telemetry.js.map +1 -1
  52. package/dist/src/cli/update.js +35 -7
  53. package/dist/src/cli/update.js.map +1 -1
  54. package/dist/src/{tui/mcp/config.js → config/mcp.js} +25 -35
  55. package/dist/src/config/mcp.js.map +1 -0
  56. package/dist/src/{tui → config}/settings.js +78 -130
  57. package/dist/src/config/settings.js.map +1 -0
  58. package/dist/src/config/source.js +87 -0
  59. package/dist/src/config/source.js.map +1 -0
  60. package/dist/src/{tui/config.js → config/store.js} +178 -49
  61. package/dist/src/config/store.js.map +1 -0
  62. package/dist/src/{tui/workspace → config}/trust.js +12 -16
  63. package/dist/src/config/trust.js.map +1 -0
  64. package/dist/src/logging.js +3 -4
  65. package/dist/src/logging.js.map +1 -1
  66. package/dist/src/{tui/provider → model}/aws-config.js +13 -4
  67. package/dist/src/model/aws-config.js.map +1 -0
  68. package/dist/src/{tui/provider/bedrock-catalog.js → model/bedrock.js} +70 -3
  69. package/dist/src/model/bedrock.js.map +1 -0
  70. package/dist/src/{tui/provider → model}/discovery.js +11 -10
  71. package/dist/src/model/discovery.js.map +1 -0
  72. package/dist/src/{tui/provider → model}/environment.js +19 -16
  73. package/dist/src/model/environment.js.map +1 -0
  74. package/dist/src/{tui/model/display.js → model/metadata.js} +6 -1
  75. package/dist/src/model/metadata.js.map +1 -0
  76. package/dist/src/model/packages.js.map +1 -0
  77. package/dist/src/{tui/model → model}/runtime.js +31 -62
  78. package/dist/src/model/runtime.js.map +1 -0
  79. package/dist/src/{tui/model → model}/selection.js +9 -15
  80. package/dist/src/model/selection.js.map +1 -0
  81. package/dist/src/{tui/package-version.js → package-version.js} +6 -0
  82. package/dist/src/package-version.js.map +1 -0
  83. package/dist/src/paths.js +23 -0
  84. package/dist/src/paths.js.map +1 -0
  85. package/dist/src/project/archive.js +461 -0
  86. package/dist/src/project/archive.js.map +1 -0
  87. package/dist/src/{tui/project → project}/export.js +249 -72
  88. package/dist/src/project/export.js.map +1 -0
  89. package/dist/src/{tui/project → project}/import.js +58 -6
  90. package/dist/src/project/import.js.map +1 -0
  91. package/dist/src/{tui/project → project}/module-loader.js +1 -5
  92. package/dist/src/project/module-loader.js.map +1 -0
  93. package/dist/src/{tui/project → project}/packaging.js +25 -8
  94. package/dist/src/project/packaging.js.map +1 -0
  95. package/dist/src/project/portability.js +455 -0
  96. package/dist/src/project/portability.js.map +1 -0
  97. package/dist/src/{tui/project → project}/python.js +46 -31
  98. package/dist/src/project/python.js.map +1 -0
  99. package/dist/src/{tui/project → project}/source.js +45 -26
  100. package/dist/src/project/source.js.map +1 -0
  101. package/dist/src/project/typescript-backend.js +733 -0
  102. package/dist/src/project/typescript-backend.js.map +1 -0
  103. package/dist/src/project/typescript-worker.js +488 -0
  104. package/dist/src/project/typescript-worker.js.map +1 -0
  105. package/dist/src/{tui/project → project}/typescript.js +19 -7
  106. package/dist/src/project/typescript.js.map +1 -0
  107. package/dist/src/project/watch.js +33 -0
  108. package/dist/src/project/watch.js.map +1 -0
  109. package/dist/src/{tui/project → project}/worker.py +358 -106
  110. package/dist/src/session/agent-definition.js +35 -0
  111. package/dist/src/session/agent-definition.js.map +1 -0
  112. package/dist/src/session/catalog.js +156 -0
  113. package/dist/src/session/catalog.js.map +1 -0
  114. package/dist/src/{tui/session → session}/context.js +45 -5
  115. package/dist/src/session/context.js.map +1 -0
  116. package/dist/src/{tui/session → session}/desktop-profile.js +1 -0
  117. package/dist/src/session/desktop-profile.js.map +1 -0
  118. package/dist/src/{tui/session → session}/sessions.js +126 -27
  119. package/dist/src/session/sessions.js.map +1 -0
  120. package/dist/src/terminal/arguments.js +53 -0
  121. package/dist/src/terminal/arguments.js.map +1 -0
  122. package/dist/src/{tui/terminal → terminal}/composer.js +51 -24
  123. package/dist/src/terminal/composer.js.map +1 -0
  124. package/dist/src/terminal/directory-picker.js +182 -0
  125. package/dist/src/terminal/directory-picker.js.map +1 -0
  126. package/dist/src/terminal/ink.js.map +1 -0
  127. package/dist/src/terminal/mouse-input.js.map +1 -0
  128. package/dist/src/terminal/npm.js.map +1 -0
  129. package/dist/src/terminal/open-editor.js +40 -0
  130. package/dist/src/terminal/open-editor.js.map +1 -0
  131. package/dist/src/terminal/open-url.js +26 -0
  132. package/dist/src/terminal/open-url.js.map +1 -0
  133. package/dist/src/terminal/process-tree.js.map +1 -0
  134. package/dist/src/terminal/shell-output.js.map +1 -0
  135. package/dist/src/{tui/terminal → terminal}/terminal.js +40 -2
  136. package/dist/src/terminal/terminal.js.map +1 -0
  137. package/dist/src/{tui/terminal/sanitize.js → terminal/text.js} +40 -6
  138. package/dist/src/terminal/text.js.map +1 -0
  139. package/dist/src/terminal/theme-detection.js +197 -0
  140. package/dist/src/terminal/theme-detection.js.map +1 -0
  141. package/dist/src/{tui/view/fade-in.js → ui/animation.js} +26 -1
  142. package/dist/src/ui/animation.js.map +1 -0
  143. package/dist/src/ui/app.js +176 -0
  144. package/dist/src/ui/app.js.map +1 -0
  145. package/dist/src/ui/chat/attachments.js +135 -0
  146. package/dist/src/ui/chat/attachments.js.map +1 -0
  147. package/dist/src/{tui → ui}/chat/commands.js +55 -7
  148. package/dist/src/ui/chat/commands.js.map +1 -0
  149. package/dist/src/{tui → ui}/chat/controller.js +1176 -345
  150. package/dist/src/ui/chat/controller.js.map +1 -0
  151. package/dist/src/ui/chat/conversations.js +692 -0
  152. package/dist/src/ui/chat/conversations.js.map +1 -0
  153. package/dist/src/{tui → ui}/chat/help.js +11 -5
  154. package/dist/src/ui/chat/help.js.map +1 -0
  155. package/dist/src/ui/chat/panel-state.js +513 -0
  156. package/dist/src/ui/chat/panel-state.js.map +1 -0
  157. package/dist/src/{tui → ui}/chat/projector.js +93 -8
  158. package/dist/src/ui/chat/projector.js.map +1 -0
  159. package/dist/src/ui/chat/prompt.js +176 -0
  160. package/dist/src/ui/chat/prompt.js.map +1 -0
  161. package/dist/src/ui/chat/runtime.js +589 -0
  162. package/dist/src/ui/chat/runtime.js.map +1 -0
  163. package/dist/src/ui/chat/screen.js +1907 -0
  164. package/dist/src/ui/chat/screen.js.map +1 -0
  165. package/dist/src/{tui/chat/controller-helpers.js → ui/chat/state.js} +39 -3
  166. package/dist/src/ui/chat/state.js.map +1 -0
  167. package/dist/src/ui/chat/stream-presentation.js.map +1 -0
  168. package/dist/src/ui/chat/transcript-turn.js +189 -0
  169. package/dist/src/ui/chat/transcript-turn.js.map +1 -0
  170. package/dist/src/{tui/view → ui/chat}/transcript.js +66 -6
  171. package/dist/src/ui/chat/transcript.js.map +1 -0
  172. package/dist/src/ui/chat/types.js +2 -0
  173. package/dist/src/ui/chat/types.js.map +1 -0
  174. package/dist/src/ui/chat/view.js +249 -0
  175. package/dist/src/ui/chat/view.js.map +1 -0
  176. package/dist/src/ui/chat/voice.js +388 -0
  177. package/dist/src/ui/chat/voice.js.map +1 -0
  178. package/dist/src/ui/footer.js +110 -0
  179. package/dist/src/ui/footer.js.map +1 -0
  180. package/dist/src/{tui/view → ui}/frog-canvas.js +47 -50
  181. package/dist/src/ui/frog-canvas.js.map +1 -0
  182. package/dist/src/{tui/view → ui}/frog-drawing.js +36 -29
  183. package/dist/src/ui/frog-drawing.js.map +1 -0
  184. package/dist/src/{tui/view/frog-intro-renderer.js → ui/frog-renderer.js} +63 -46
  185. package/dist/src/ui/frog-renderer.js.map +1 -0
  186. package/dist/src/{tui/view/frog-easter-egg.js → ui/frog.js} +34 -6
  187. package/dist/src/ui/frog.js.map +1 -0
  188. package/dist/src/ui/interaction.js +525 -0
  189. package/dist/src/ui/interaction.js.map +1 -0
  190. package/dist/src/{tui/view → ui}/markdown.js +12 -9
  191. package/dist/src/ui/markdown.js.map +1 -0
  192. package/dist/src/ui/mcp-diagnostics.js +56 -0
  193. package/dist/src/ui/mcp-diagnostics.js.map +1 -0
  194. package/dist/src/ui/media.js +59 -0
  195. package/dist/src/ui/media.js.map +1 -0
  196. package/dist/src/ui/panels/agents.js +97 -0
  197. package/dist/src/ui/panels/agents.js.map +1 -0
  198. package/dist/src/ui/panels/configuration.js +201 -0
  199. package/dist/src/ui/panels/configuration.js.map +1 -0
  200. package/dist/src/ui/panels/context.js +102 -0
  201. package/dist/src/ui/panels/context.js.map +1 -0
  202. package/dist/src/ui/panels/export.js +17 -0
  203. package/dist/src/ui/panels/export.js.map +1 -0
  204. package/dist/src/ui/panels/help.js +22 -0
  205. package/dist/src/ui/panels/help.js.map +1 -0
  206. package/dist/src/ui/panels/models.js +180 -0
  207. package/dist/src/ui/panels/models.js.map +1 -0
  208. package/dist/src/ui/panels/panel.js +122 -0
  209. package/dist/src/ui/panels/panel.js.map +1 -0
  210. package/dist/src/ui/panels/permissions.js +90 -0
  211. package/dist/src/ui/panels/permissions.js.map +1 -0
  212. package/dist/src/ui/panels/sessions.js +54 -0
  213. package/dist/src/ui/panels/sessions.js.map +1 -0
  214. package/dist/src/ui/panels/settings.js +125 -0
  215. package/dist/src/ui/panels/settings.js.map +1 -0
  216. package/dist/src/ui/panels/shared.js +50 -0
  217. package/dist/src/ui/panels/shared.js.map +1 -0
  218. package/dist/src/ui/panels/tasks.js +15 -0
  219. package/dist/src/ui/panels/tasks.js.map +1 -0
  220. package/dist/src/ui/panels/voice.js +142 -0
  221. package/dist/src/ui/panels/voice.js.map +1 -0
  222. package/dist/src/{tui/permissions/settings.js → ui/permission-options.js} +13 -2
  223. package/dist/src/ui/permission-options.js.map +1 -0
  224. package/dist/src/{tui/view → ui}/presentation.js +170 -112
  225. package/dist/src/ui/presentation.js.map +1 -0
  226. package/dist/src/{tui → ui}/run.js +173 -36
  227. package/dist/src/ui/run.js.map +1 -0
  228. package/dist/src/{tui/view/setup-wizard/settings-panel.js → ui/setup/form.js} +6 -6
  229. package/dist/src/ui/setup/form.js.map +1 -0
  230. package/dist/src/ui/setup/menu.js +133 -0
  231. package/dist/src/ui/setup/menu.js.map +1 -0
  232. package/dist/src/{tui/view/setup-wizard → ui/setup}/providers.js +157 -20
  233. package/dist/src/ui/setup/providers.js.map +1 -0
  234. package/dist/src/{tui/view/setup-wizard → ui/setup}/steps.js +193 -147
  235. package/dist/src/ui/setup/steps.js.map +1 -0
  236. package/dist/src/ui/setup/wizard.js +2075 -0
  237. package/dist/src/ui/setup/wizard.js.map +1 -0
  238. package/dist/src/ui/startup.js +147 -0
  239. package/dist/src/ui/startup.js.map +1 -0
  240. package/dist/src/{tui/terminal/size.js → ui/terminal-size.js} +1 -1
  241. package/dist/src/ui/terminal-size.js.map +1 -0
  242. package/dist/src/ui/text-input.js +50 -0
  243. package/dist/src/ui/text-input.js.map +1 -0
  244. package/dist/src/{tui/view → ui}/theme.js +24 -31
  245. package/dist/src/ui/theme.js.map +1 -0
  246. package/dist/src/ui/update.js +126 -0
  247. package/dist/src/ui/update.js.map +1 -0
  248. package/dist/src/usage.js +0 -5
  249. package/dist/src/usage.js.map +1 -1
  250. package/dist/src/values.js +5 -0
  251. package/dist/src/values.js.map +1 -0
  252. package/package.json +16 -8
  253. package/src/agent/voice-sidecar.py +730 -0
  254. package/dist/src/console.js.map +0 -1
  255. package/dist/src/tui/acp/projection.js.map +0 -1
  256. package/dist/src/tui/acp/server.js.map +0 -1
  257. package/dist/src/tui/agent-configuration.js.map +0 -1
  258. package/dist/src/tui/background/activity.js.map +0 -1
  259. package/dist/src/tui/background/inbox.js +0 -120
  260. package/dist/src/tui/background/inbox.js.map +0 -1
  261. package/dist/src/tui/background/tasks.js +0 -98
  262. package/dist/src/tui/background/tasks.js.map +0 -1
  263. package/dist/src/tui/builtin-tools.js.map +0 -1
  264. package/dist/src/tui/chat/commands.js.map +0 -1
  265. package/dist/src/tui/chat/controller-helpers.js.map +0 -1
  266. package/dist/src/tui/chat/controller.js.map +0 -1
  267. package/dist/src/tui/chat/help.js.map +0 -1
  268. package/dist/src/tui/chat/panels.js +0 -407
  269. package/dist/src/tui/chat/panels.js.map +0 -1
  270. package/dist/src/tui/chat/projector.js.map +0 -1
  271. package/dist/src/tui/chat/sdk-projector.js.map +0 -1
  272. package/dist/src/tui/chat/shell.js.map +0 -1
  273. package/dist/src/tui/chat/types.js +0 -2
  274. package/dist/src/tui/chat/types.js.map +0 -1
  275. package/dist/src/tui/config.js.map +0 -1
  276. package/dist/src/tui/configuration-instructions.js +0 -14
  277. package/dist/src/tui/configuration-instructions.js.map +0 -1
  278. package/dist/src/tui/mcp/config.js.map +0 -1
  279. package/dist/src/tui/mcp.js +0 -98
  280. package/dist/src/tui/mcp.js.map +0 -1
  281. package/dist/src/tui/memory-options.js +0 -10
  282. package/dist/src/tui/memory-options.js.map +0 -1
  283. package/dist/src/tui/messaging.js +0 -193
  284. package/dist/src/tui/messaging.js.map +0 -1
  285. package/dist/src/tui/model/context.js +0 -69
  286. package/dist/src/tui/model/context.js.map +0 -1
  287. package/dist/src/tui/model/display.js.map +0 -1
  288. package/dist/src/tui/model/runtime.js.map +0 -1
  289. package/dist/src/tui/model/selection.js.map +0 -1
  290. package/dist/src/tui/npm.js.map +0 -1
  291. package/dist/src/tui/package-version.js.map +0 -1
  292. package/dist/src/tui/permissions/file-change-preview.js.map +0 -1
  293. package/dist/src/tui/permissions/policy.js +0 -222
  294. package/dist/src/tui/permissions/policy.js.map +0 -1
  295. package/dist/src/tui/permissions/settings.js.map +0 -1
  296. package/dist/src/tui/project/acp.js.map +0 -1
  297. package/dist/src/tui/project/archive.js +0 -241
  298. package/dist/src/tui/project/archive.js.map +0 -1
  299. package/dist/src/tui/project/configuration-secrets.js +0 -107
  300. package/dist/src/tui/project/configuration-secrets.js.map +0 -1
  301. package/dist/src/tui/project/configuration.js +0 -201
  302. package/dist/src/tui/project/configuration.js.map +0 -1
  303. package/dist/src/tui/project/export.js.map +0 -1
  304. package/dist/src/tui/project/import.js.map +0 -1
  305. package/dist/src/tui/project/module-loader.js.map +0 -1
  306. package/dist/src/tui/project/packaging.js.map +0 -1
  307. package/dist/src/tui/project/portable-dependencies.js +0 -34
  308. package/dist/src/tui/project/portable-dependencies.js.map +0 -1
  309. package/dist/src/tui/project/portable-mcp.js +0 -118
  310. package/dist/src/tui/project/portable-mcp.js.map +0 -1
  311. package/dist/src/tui/project/python.js.map +0 -1
  312. package/dist/src/tui/project/run.js +0 -116
  313. package/dist/src/tui/project/run.js.map +0 -1
  314. package/dist/src/tui/project/source.js.map +0 -1
  315. package/dist/src/tui/project/typescript.js.map +0 -1
  316. package/dist/src/tui/provider/aws-client.js +0 -67
  317. package/dist/src/tui/provider/aws-client.js.map +0 -1
  318. package/dist/src/tui/provider/aws-config.js.map +0 -1
  319. package/dist/src/tui/provider/bedrock-catalog.js.map +0 -1
  320. package/dist/src/tui/provider/discovery.js.map +0 -1
  321. package/dist/src/tui/provider/environment.js.map +0 -1
  322. package/dist/src/tui/provider/packages.js.map +0 -1
  323. package/dist/src/tui/run.js.map +0 -1
  324. package/dist/src/tui/runtime.js +0 -524
  325. package/dist/src/tui/runtime.js.map +0 -1
  326. package/dist/src/tui/session/agent-definition.js +0 -100
  327. package/dist/src/tui/session/agent-definition.js.map +0 -1
  328. package/dist/src/tui/session/catalog.js +0 -159
  329. package/dist/src/tui/session/catalog.js.map +0 -1
  330. package/dist/src/tui/session/context.js.map +0 -1
  331. package/dist/src/tui/session/conversation-helpers.js +0 -46
  332. package/dist/src/tui/session/conversation-helpers.js.map +0 -1
  333. package/dist/src/tui/session/conversations.js +0 -471
  334. package/dist/src/tui/session/conversations.js.map +0 -1
  335. package/dist/src/tui/session/desktop-profile.js.map +0 -1
  336. package/dist/src/tui/session/options.js +0 -44
  337. package/dist/src/tui/session/options.js.map +0 -1
  338. package/dist/src/tui/session/sessions.js.map +0 -1
  339. package/dist/src/tui/session/voice.js +0 -353
  340. package/dist/src/tui/session/voice.js.map +0 -1
  341. package/dist/src/tui/settings.js.map +0 -1
  342. package/dist/src/tui/skills.js.map +0 -1
  343. package/dist/src/tui/steering.js +0 -67
  344. package/dist/src/tui/steering.js.map +0 -1
  345. package/dist/src/tui/strands-backend.js.map +0 -1
  346. package/dist/src/tui/stream-presentation.js.map +0 -1
  347. package/dist/src/tui/terminal/composer.js.map +0 -1
  348. package/dist/src/tui/terminal/directory-picker.js +0 -76
  349. package/dist/src/tui/terminal/directory-picker.js.map +0 -1
  350. package/dist/src/tui/terminal/ink.js.map +0 -1
  351. package/dist/src/tui/terminal/mouse-input.js.map +0 -1
  352. package/dist/src/tui/terminal/open-url.js +0 -21
  353. package/dist/src/tui/terminal/open-url.js.map +0 -1
  354. package/dist/src/tui/terminal/process-tree.js.map +0 -1
  355. package/dist/src/tui/terminal/sanitize.js.map +0 -1
  356. package/dist/src/tui/terminal/shell-output.js.map +0 -1
  357. package/dist/src/tui/terminal/size.js.map +0 -1
  358. package/dist/src/tui/terminal/terminal.js.map +0 -1
  359. package/dist/src/tui/update-check.js +0 -37
  360. package/dist/src/tui/update-check.js.map +0 -1
  361. package/dist/src/tui/view/agents-panel.js +0 -21
  362. package/dist/src/tui/view/agents-panel.js.map +0 -1
  363. package/dist/src/tui/view/app.js +0 -1061
  364. package/dist/src/tui/view/app.js.map +0 -1
  365. package/dist/src/tui/view/chat-root.js +0 -49
  366. package/dist/src/tui/view/chat-root.js.map +0 -1
  367. package/dist/src/tui/view/chat-view.js +0 -145
  368. package/dist/src/tui/view/chat-view.js.map +0 -1
  369. package/dist/src/tui/view/command-palette.js +0 -15
  370. package/dist/src/tui/view/command-palette.js.map +0 -1
  371. package/dist/src/tui/view/custom-theme-editor.js +0 -301
  372. package/dist/src/tui/view/custom-theme-editor.js.map +0 -1
  373. package/dist/src/tui/view/effort-panel.js +0 -15
  374. package/dist/src/tui/view/effort-panel.js.map +0 -1
  375. package/dist/src/tui/view/export-panel.js +0 -14
  376. package/dist/src/tui/view/export-panel.js.map +0 -1
  377. package/dist/src/tui/view/fade-in.js.map +0 -1
  378. package/dist/src/tui/view/frog-canvas.js.map +0 -1
  379. package/dist/src/tui/view/frog-drawing.js.map +0 -1
  380. package/dist/src/tui/view/frog-easter-egg.js.map +0 -1
  381. package/dist/src/tui/view/frog-intro-renderer.js.map +0 -1
  382. package/dist/src/tui/view/help-footer.js +0 -48
  383. package/dist/src/tui/view/help-footer.js.map +0 -1
  384. package/dist/src/tui/view/interaction.js +0 -352
  385. package/dist/src/tui/view/interaction.js.map +0 -1
  386. package/dist/src/tui/view/markdown.js.map +0 -1
  387. package/dist/src/tui/view/mcp-trust-prompt.js +0 -17
  388. package/dist/src/tui/view/mcp-trust-prompt.js.map +0 -1
  389. package/dist/src/tui/view/media.js +0 -70
  390. package/dist/src/tui/view/media.js.map +0 -1
  391. package/dist/src/tui/view/model-panel.js +0 -77
  392. package/dist/src/tui/view/model-panel.js.map +0 -1
  393. package/dist/src/tui/view/panel-components.js +0 -17
  394. package/dist/src/tui/view/panel-components.js.map +0 -1
  395. package/dist/src/tui/view/panels.js +0 -139
  396. package/dist/src/tui/view/panels.js.map +0 -1
  397. package/dist/src/tui/view/presentation.js.map +0 -1
  398. package/dist/src/tui/view/prompt-editor.js +0 -82
  399. package/dist/src/tui/view/prompt-editor.js.map +0 -1
  400. package/dist/src/tui/view/provider-list.js +0 -14
  401. package/dist/src/tui/view/provider-list.js.map +0 -1
  402. package/dist/src/tui/view/rename-panel.js +0 -11
  403. package/dist/src/tui/view/rename-panel.js.map +0 -1
  404. package/dist/src/tui/view/sessions-panel.js +0 -15
  405. package/dist/src/tui/view/sessions-panel.js.map +0 -1
  406. package/dist/src/tui/view/settings-panel.js +0 -146
  407. package/dist/src/tui/view/settings-panel.js.map +0 -1
  408. package/dist/src/tui/view/setup-wizard/brand.js +0 -34
  409. package/dist/src/tui/view/setup-wizard/brand.js.map +0 -1
  410. package/dist/src/tui/view/setup-wizard/index.js +0 -1638
  411. package/dist/src/tui/view/setup-wizard/index.js.map +0 -1
  412. package/dist/src/tui/view/setup-wizard/opening-menu.js +0 -99
  413. package/dist/src/tui/view/setup-wizard/opening-menu.js.map +0 -1
  414. package/dist/src/tui/view/setup-wizard/path-completion.js +0 -53
  415. package/dist/src/tui/view/setup-wizard/path-completion.js.map +0 -1
  416. package/dist/src/tui/view/setup-wizard/profile-fields.js +0 -29
  417. package/dist/src/tui/view/setup-wizard/profile-fields.js.map +0 -1
  418. package/dist/src/tui/view/setup-wizard/progress.js +0 -43
  419. package/dist/src/tui/view/setup-wizard/progress.js.map +0 -1
  420. package/dist/src/tui/view/setup-wizard/providers.js.map +0 -1
  421. package/dist/src/tui/view/setup-wizard/settings-panel.js.map +0 -1
  422. package/dist/src/tui/view/setup-wizard/steps.js.map +0 -1
  423. package/dist/src/tui/view/setup-wizard/types.js.map +0 -1
  424. package/dist/src/tui/view/setup-wizard/use-provider-discovery.js +0 -143
  425. package/dist/src/tui/view/setup-wizard/use-provider-discovery.js.map +0 -1
  426. package/dist/src/tui/view/startup-view.js +0 -79
  427. package/dist/src/tui/view/startup-view.js.map +0 -1
  428. package/dist/src/tui/view/text-input.js +0 -33
  429. package/dist/src/tui/view/text-input.js.map +0 -1
  430. package/dist/src/tui/view/theme-detection.js +0 -45
  431. package/dist/src/tui/view/theme-detection.js.map +0 -1
  432. package/dist/src/tui/view/theme.js.map +0 -1
  433. package/dist/src/tui/view/transcript-layout.js +0 -60
  434. package/dist/src/tui/view/transcript-layout.js.map +0 -1
  435. package/dist/src/tui/view/transcript-turn.js +0 -135
  436. package/dist/src/tui/view/transcript-turn.js.map +0 -1
  437. package/dist/src/tui/view/transcript.js.map +0 -1
  438. package/dist/src/tui/view/use-party-frame.js +0 -15
  439. package/dist/src/tui/view/use-party-frame.js.map +0 -1
  440. package/dist/src/tui/view/use-spinner.js +0 -14
  441. package/dist/src/tui/view/use-spinner.js.map +0 -1
  442. package/dist/src/tui/voice/session.js.map +0 -1
  443. package/dist/src/tui/workspace/sandbox.js.map +0 -1
  444. package/dist/src/tui/workspace/trust.js.map +0 -1
  445. package/src/tui/voice/sidecar.py +0 -631
  446. /package/dist/src/{tui/view/setup-wizard → agent}/types.js +0 -0
  447. /package/dist/src/{tui/provider → model}/packages.js +0 -0
  448. /package/dist/src/{tui/terminal → terminal}/ink.js +0 -0
  449. /package/dist/src/{tui/terminal → terminal}/mouse-input.js +0 -0
  450. /package/dist/src/{tui → terminal}/npm.js +0 -0
  451. /package/dist/src/{tui/terminal → terminal}/process-tree.js +0 -0
  452. /package/dist/src/{tui/terminal → terminal}/shell-output.js +0 -0
  453. /package/dist/src/{tui → ui/chat}/stream-presentation.js +0 -0
@@ -22,19 +22,25 @@ from uuid import uuid4
22
22
  import strands_harness
23
23
  from strands import Agent, tool
24
24
  from strands.hooks import HookOrder
25
- from strands.hooks.events import BeforeToolCallEvent
26
- from strands.session import SnapshotSessionManager
27
- from strands.storage import LocalFileStorage
25
+ from strands.hooks.events import BeforeModelCallEvent, BeforeToolCallEvent
26
+ from strands.models import Model
27
+ from strands.session import FileSessionManager, S3SessionManager, SnapshotSessionManager
28
+ from strands.storage import InMemoryStorage, LocalFileStorage, S3Storage
29
+ from strands.storage import storage as storage_types
28
30
  from strands.tools.mcp import MCPClient
29
31
  from strands.types.tools import ToolContext
32
+ from strands.vended_memory_stores.file_memory_store import FileMemoryStore
30
33
  from strands.vended_plugins.context_offloader import ContextOffloader
34
+ from strands.vended_plugins.context_offloader import storage as offloader_storage
31
35
  from strands.vended_plugins.skills import AgentSkills
32
36
  from strands_harness import define_harness_agent_config, harness_agent_kwargs_from_config
33
37
  from strands_harness.defaults import DEFAULT_MODEL
34
38
 
35
39
  channel = os.fdopen(3, "w", buffering=1)
40
+ commands = os.fdopen(4, encoding="utf-8")
36
41
  pending_permissions = {}
37
42
  COMPACT_PRESERVE_RECENT_MESSAGES = 2
43
+ MAX_SAFE_INTEGER = 9_007_199_254_740_991
38
44
 
39
45
 
40
46
  def encode(value):
@@ -65,6 +71,68 @@ def compacted_tokens(reported, estimated_before, estimated_after):
65
71
  return max(0, reported - max(0, estimated_before - estimated_after))
66
72
 
67
73
 
74
+ async def estimate_context_categories(context):
75
+ system = context.system_prompt
76
+ estimates = {
77
+ "systemPrompt": await Model.count_tokens(
78
+ context.model,
79
+ [],
80
+ system_prompt=system if isinstance(system, str) else None,
81
+ system_prompt_content=system if isinstance(system, list) else None,
82
+ ),
83
+ "tools": await Model.count_tokens(context.model, [], tool_specs=context.tool_specs),
84
+ }
85
+ grouped = {kind: [] for kind in ("userMessages", "assistantMessages", "toolResults", "injectedContext")}
86
+ last_user = next(
87
+ (index for index in range(len(context.messages) - 1, -1, -1) if context.messages[index]["role"] == "user"),
88
+ -1,
89
+ )
90
+ trailing = max(0, getattr(context, "dynamic_trailing_blocks", 0))
91
+ for index, message in enumerate(context.messages):
92
+ content = message["content"]
93
+ for block_index, block in enumerate(content):
94
+ if index == last_user and block_index >= len(content) - trailing:
95
+ kind = "injectedContext"
96
+ elif "toolResult" in block:
97
+ kind = "toolResults"
98
+ else:
99
+ kind = "assistantMessages" if message["role"] == "assistant" else "userMessages"
100
+ grouped[kind].append({"role": message["role"], "content": [block]})
101
+ for kind, messages in grouped.items():
102
+ estimates[kind] = await Model.count_tokens(context.model, messages)
103
+ return estimates
104
+
105
+
106
+ def context_breakdown(estimates, current_tokens, projected_tokens):
107
+ if estimates is None or any(
108
+ type(value) is not int or value < 0 or value > MAX_SAFE_INTEGER
109
+ for value in (current_tokens, projected_tokens, *estimates.values())
110
+ ):
111
+ return None
112
+ if projected_tokens < current_tokens:
113
+ return None
114
+ total = sum(estimates.values())
115
+ tokens = {
116
+ kind: value * current_tokens // total if total > current_tokens else value
117
+ for kind, value in estimates.items()
118
+ }
119
+ tokens["other"] = current_tokens - sum(tokens.values())
120
+ tokens["assistantMessages"] += projected_tokens - current_tokens
121
+ return {"categories": [{"kind": kind, "tokens": value} for kind, value in tokens.items() if value > 0]}
122
+
123
+
124
+ def context_model_usage(usage):
125
+ if not isinstance(usage, dict) or any(key not in usage for key in ("inputTokens", "outputTokens", "totalTokens")):
126
+ return None
127
+ numeric = {
128
+ key: usage.get(key, 0)
129
+ for key in ("inputTokens", "outputTokens", "totalTokens", "cacheReadInputTokens", "cacheWriteInputTokens")
130
+ }
131
+ if any(type(value) is not int or value < 0 or value > MAX_SAFE_INTEGER for value in numeric.values()):
132
+ return None
133
+ return numeric if any(numeric.values()) else None
134
+
135
+
68
136
  async def authorize_tool(event):
69
137
  tool_use = event.tool_use
70
138
  if tool_use["name"] == "strands_config":
@@ -103,25 +171,59 @@ async def permission(request):
103
171
  pending_permissions.pop(request_id, None)
104
172
 
105
173
 
106
- def overrides_from_config(partial):
174
+ def merge_assigned_option(authored, converted, paths, path):
175
+ if any(path == assigned or path.startswith(assigned + ".") for assigned in paths) or not isinstance(converted, dict):
176
+ return converted
177
+ if path == "builtinTools" and isinstance(authored, list):
178
+ authored = {"*": False, **dict.fromkeys(authored, True)}
179
+ merged: dict[str, object] = dict(authored) if isinstance(authored, dict) else {}
180
+ for name in {assigned[len(path) + 1:].split(".")[0] for assigned in paths if assigned.startswith(path + ".")}:
181
+ key = name if name in converted else re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), name)
182
+ merged[key] = merge_assigned_option(merged.get(key), converted.get(key), paths, f"{path}.{name}")
183
+ return merged
184
+
185
+
186
+ def overrides_from_config(partial, authored, assignments):
107
187
  if not partial:
108
188
  return {}
109
189
  config = define_harness_agent_config(partial)
110
190
  options = harness_agent_kwargs_from_config(config)
111
191
  # These values are normally omitted by the config loader when equal to defaults.
112
- for key in ("builtinTools", "builtinPlugins", "caching", "description", "instructions", "sessionId"):
192
+ for key in ("builtinTools", "builtinPlugins", "caching", "description", "instructions"):
113
193
  if key in partial:
114
- options[re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), key)] = config[key]
194
+ options.setdefault(re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), key), config[key])
115
195
  aliases = {
116
196
  "subagents": "tools",
117
197
  "modelModule": "model",
118
- "webFetchModelModule": "web_fetch_model",
119
- "memoryStores": "memory_store",
198
+ "memoryStores": "memory",
120
199
  "interventionModules": "interventions",
121
200
  }
122
201
  keys = {aliases.get(key, re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), key)) for key in partial}
123
202
  keys.update(partial.get("agentConfig", {}))
124
203
  keys.update(partial.get("agentConfigModules", {}))
204
+ for key, empty in {"tools": [], "plugins": [], "mcp_servers": {}, "interventions": None, "sandbox": None}.items():
205
+ if key in keys:
206
+ options.setdefault(key, empty)
207
+ paths = [assignment.split("=", 1)[0] for assignment in assignments]
208
+ for field in partial:
209
+ if field in aliases or field == "agentConfigModules":
210
+ continue
211
+ fields = partial[field] if field == "agentConfig" else [field]
212
+ for name in fields:
213
+ path = f"agentConfig.{name}" if field == "agentConfig" else name
214
+ key = name if field == "agentConfig" else re.sub(r"[A-Z]", lambda match: "_" + match[0].lower(), name)
215
+ if key in partial.get("agentConfigModules", {}) or any(
216
+ alias in partial and option == key for alias, option in aliases.items()
217
+ ):
218
+ continue
219
+ if not any(assigned.startswith(path + ".") for assigned in paths):
220
+ continue
221
+ value = authored.get(key)
222
+ if key == "mcp_servers" and isinstance(value, str):
223
+ with open(value) as source:
224
+ document = json.load(source)
225
+ value = document.get("mcpServers", document)
226
+ options[key] = merge_assigned_option(value, options.get(key), paths, path)
125
227
  return {
126
228
  key: options[key]
127
229
  for key in keys
@@ -172,71 +274,117 @@ def display_messages(agent):
172
274
  return messages
173
275
 
174
276
 
175
- def local_session_directory(storage):
277
+ def local_storage_paths(storage):
176
278
  parts = []
177
- while hasattr(storage, "_storage") and hasattr(storage, "_prefix"):
178
- parts.append(storage._prefix)
179
- storage = storage._storage
180
- if not isinstance(storage, LocalFileStorage):
279
+ while isinstance(storage, getattr(storage_types, "_NamespacedStorage", ())):
280
+ prefix = getattr(storage, "_prefix", None)
281
+ if not isinstance(prefix, str):
282
+ return None
283
+ parts.insert(0, prefix)
284
+ storage = getattr(storage, "_storage", None)
285
+ if isinstance(storage, LocalFileStorage):
286
+ directory = getattr(storage, "base_dir", None)
287
+ elif isinstance(storage, offloader_storage.FileStorage):
288
+ directory = getattr(storage, "_artifact_dir", None)
289
+ elif isinstance(storage, (InMemoryStorage, S3Storage, offloader_storage.InMemoryStorage, offloader_storage.S3Storage)):
290
+ return []
291
+ else:
181
292
  return None
182
- return str(Path(storage._base_dir, *parts).resolve())
293
+ if not isinstance(directory, (str, os.PathLike)):
294
+ return None
295
+ return [str(Path(os.fsdecode(directory), *parts).resolve())]
183
296
 
184
297
 
185
298
  def agent_stash(agent):
186
299
  return getattr(getattr(agent, "context_manager", None), "stash", None)
187
300
 
188
301
 
189
- def local_stash_directory(agent):
190
- stash = agent_stash(agent)
191
- base_directory = local_session_directory(getattr(stash, "_base_storage", None))
192
- namespace = getattr(getattr(stash, "_storage", None), "_prefix", "")
193
- if base_directory is None or not namespace:
302
+ def agent_private_paths(agent):
303
+ """None disables export and watching when private storage cannot be identified."""
304
+ paths = []
305
+ storages = []
306
+ manager = getattr(agent, "_session_manager", None)
307
+ if isinstance(manager, SnapshotSessionManager):
308
+ storages.append(getattr(manager, "_storage", None))
309
+ elif isinstance(manager, FileSessionManager):
310
+ directory = getattr(manager, "storage_dir", None)
311
+ if not isinstance(directory, (str, os.PathLike)):
312
+ return None
313
+ paths.append(str(Path(os.fsdecode(directory)).resolve()))
314
+ elif manager is not None and not isinstance(manager, S3SessionManager):
194
315
  return None
195
- # The namespace's first segment holds every session's stash, not just this agent's.
196
- return str(Path(base_directory, namespace.split("/")[0]))
197
316
 
317
+ stash = agent_stash(agent)
318
+ if stash is not None:
319
+ base_storage = getattr(stash, "_base_storage", None)
320
+ storage = getattr(stash, "_storage", None)
321
+ base_paths = local_storage_paths(base_storage)
322
+ if base_paths is None or local_storage_paths(storage) is None:
323
+ return None
324
+ if storage is base_storage:
325
+ paths.extend(base_paths)
326
+ elif isinstance(storage, getattr(storage_types, "_NamespacedStorage", ())):
327
+ namespace = getattr(storage, "_prefix", None)
328
+ if not isinstance(namespace, str) or not namespace:
329
+ return None
330
+ # Exclude every session's stash, not just this agent's.
331
+ paths.extend(str(Path(path, namespace.split("/")[0])) for path in base_paths)
332
+ else:
333
+ return None
198
334
 
199
- def local_offloader_directories(agent):
200
- plugins = getattr(getattr(agent, "_plugin_registry", None), "_plugins", {}).values()
201
- return [
202
- directory
203
- for plugin in plugins
204
- if isinstance(plugin, ContextOffloader)
205
- and (directory := local_session_directory(getattr(plugin, "_storage", None)))
206
- ]
335
+ plugins = getattr(getattr(agent, "_plugin_registry", None), "_plugins", None)
336
+ if not isinstance(plugins, dict):
337
+ return None
338
+ storages.extend(getattr(plugin, "_storage", None) for plugin in plugins.values() if isinstance(plugin, ContextOffloader))
339
+ memory = getattr(agent, "memory_manager", None)
340
+ if memory is not None:
341
+ stores = getattr(memory, "_stores", None)
342
+ if not isinstance(stores, (list, tuple)):
343
+ return None
344
+ for store in stores:
345
+ if isinstance(store, FileMemoryStore):
346
+ storages.append(getattr(store, "_storage", None))
347
+ else:
348
+ try:
349
+ from strands.vended_memory_stores.bedrock_knowledge_base import BedrockKnowledgeBaseStore
350
+ except ImportError:
351
+ return None
352
+ if not isinstance(store, BedrockKnowledgeBaseStore):
353
+ return None
354
+ for storage in storages:
355
+ local = local_storage_paths(storage)
356
+ if local is None:
357
+ return None
358
+ paths.extend(local)
359
+ return list(dict.fromkeys(paths))
207
360
 
208
361
 
209
362
  class Runtime:
210
363
  def __init__(self, module, command):
211
364
  self.module = module
212
365
  partial = command.get("overrides", {})
213
- for assignment in command.get("assignments", []):
214
- path, raw = assignment.split("=", 1)
215
- keys = path.split(".")
216
- try:
217
- value = json.loads(raw)
218
- except ValueError:
219
- value = raw
220
- if len(keys) == 1:
221
- partial[keys[0]] = value
222
- else:
223
- target = partial.setdefault(keys[0], {})
224
- if not isinstance(target, dict):
225
- target = {}
226
- partial[keys[0]] = target
227
- for key in keys[1:-1]:
228
- if not isinstance(target.get(key), dict):
229
- target[key] = {}
230
- target = target[key]
231
- target[keys[-1]] = value
232
- self.options = overrides_from_config(partial)
233
- for source, target in (("sessionId", "session_id"), ("sessionDir", "session_dir")):
234
- if source in command:
235
- self.options[target] = command[source]
366
+ authored = getattr(module, "_strands_options", {})
367
+ self.options = overrides_from_config(partial, authored, command.get("assignments", []))
368
+ flags = command.get("configFlags", {})
369
+ for key in ("session", "memory"):
370
+ if flags.get(key) == "off":
371
+ self.options[key] = False
372
+ elif flags.get(key) == "on":
373
+ value = self.options.get(key, authored.get(key))
374
+ self.options[key] = True if value is None or value is False else value
375
+ elif flags.get(key) is not None:
376
+ raise ValueError(f"--{key} must be 'on' or 'off'.")
377
+ session = self.options.get("session", authored.get("session", True))
378
+ if flags.get("sessionId") is not None and (session is True or isinstance(session, dict)):
379
+ self.options["session"] = {**(session if isinstance(session, dict) else {}), "id": flags["sessionId"]}
236
380
  self.explicit_option_keys = set(self.options)
237
- model = self.options.get("model")
381
+ model = self.options.get("model", authored.get("model"))
382
+ if model is None and hasattr(module, "_strands_options"):
383
+ model = DEFAULT_MODEL
238
384
  self.source_configuration = (
239
- {"model": model, "thinking": self.options.get("effort", "auto")} if isinstance(model, str) else None
385
+ {"model": model, "thinking": self.options.get("effort", authored.get("effort", "auto"))}
386
+ if isinstance(model, str)
387
+ else None
240
388
  )
241
389
  selection = command.get("sourceSelection")
242
390
  if (
@@ -245,49 +393,75 @@ class Runtime:
245
393
  and selection["source"] == module.__file__
246
394
  and selection["configured"] == self.source_configuration
247
395
  ):
248
- self.options.update(
249
- model=selection["selected"]["model"],
250
- effort=selection["selected"]["thinking"],
251
- )
396
+ for field, option in (("model", "model"), ("thinking", "effort")):
397
+ if selection["selected"][field] != self.source_configuration[field]:
398
+ self.options[option] = selection["selected"][field]
399
+ self.explicit_option_keys.add(option)
400
+ session = self.options.get("session", authored.get("session", True))
401
+ session_options = session if isinstance(session, dict) else {}
252
402
  self.session_configuration = {
253
- "sessionId": self.options.get("session_id"),
254
- "sessionDir": str(self.options.get("session_dir", ".agent/sessions")),
403
+ "sessionId": session_options.get("id"),
404
+ "sessionDir": str(session_options.get("dir", ".agent/sessions")),
255
405
  }
256
- session_directory = command.get("sessionStorageDirectory")
257
- self.options["session_dir"] = str(Path(self.options.get("session_dir", ".agent/sessions")).resolve())
258
- self.session_directory = (
259
- str(Path(session_directory).resolve())
260
- if session_directory is not None
261
- else str(Path(self.options["session_dir"]) / "session")
262
- )
406
+ restoration = command.get("restoreSession")
407
+ if restoration and (session is True or isinstance(session, dict)):
408
+ identity = restoration["identity"]
409
+ if restoration["preserve"] or identity["configured"] == self.session_configuration:
410
+ session_options = {
411
+ "id": identity["sessionId"],
412
+ "dir": str(Path(identity["sessionDirectory"]).parent),
413
+ }
414
+ self.options["session"] = session_options
415
+ self.explicit_option_keys.add("session")
416
+ if "sessionId" in command and (session is True or isinstance(session, dict)):
417
+ self.options["session"] = {
418
+ **session_options,
419
+ "id": command["sessionId"],
420
+ **(
421
+ {"dir": str(Path(command["sessionStorageDirectory"]).parent)}
422
+ if "sessionStorageDirectory" in command
423
+ else {}
424
+ ),
425
+ **({"dir": str(Path(command["sessionDir"]).parent)} if "sessionDir" in command else {}),
426
+ }
427
+ self.explicit_option_keys.add("session")
263
428
  self.agent: Agent
264
429
  self.initial_agent = module.agent
265
430
  self.factory = getattr(module, "create_agent", None)
266
431
  self.interactive = command.get("interactive", False)
267
432
  self.mcp_servers = command.get("mcpServers", {})
268
- self.skill_paths = command.get("skillPaths", [])
433
+ self.skill_paths = command.get("skillPaths", []) if self.options.get("skills", authored.get("skills", True)) else []
269
434
  self.cancel_signal = threading.Event()
270
435
  self.reload_requested = False
436
+ self.context_estimates = None
437
+ self.context_usage = None
271
438
 
272
- async def build(self, options, snapshot=None):
439
+ async def build(self, options, snapshot=None, *, resume=False):
273
440
  previous = getattr(self, "agent", self.initial_agent)
274
441
  factory_options = {key: options[key] for key in self.explicit_option_keys if key in options}
275
442
  if self.initial_agent is not None and not factory_options:
276
443
  candidate = self.initial_agent
277
444
  self.initial_agent = None
278
445
  else:
279
- self.initial_agent = None
280
446
  if not callable(self.factory):
281
447
  raise ValueError(
282
448
  "This source exports an agent instance but not create_agent(**overrides), "
283
449
  "and is not a direct agent = create_harness(...) definition; recreation controls are unavailable."
284
450
  )
451
+ manager = getattr(previous, "memory_manager", None)
452
+ if manager:
453
+ await manager.flush()
454
+ self.initial_agent = None
285
455
  candidate = self.factory(**factory_options)
286
456
  if inspect.isawaitable(candidate):
287
457
  candidate = await candidate
288
458
  if not isinstance(candidate, Agent):
289
459
  raise TypeError("create_harness() must return a Strands Agent")
290
460
  try:
461
+ if resume:
462
+ manager = candidate._session_manager
463
+ if not isinstance(manager, SnapshotSessionManager) or not await manager.restore_snapshot(candidate):
464
+ raise ValueError("No saved Python session was found for this agent.")
291
465
  await self.augment(candidate)
292
466
  if snapshot:
293
467
  candidate.load_snapshot(snapshot)
@@ -323,10 +497,68 @@ class Runtime:
323
497
  None,
324
498
  )
325
499
  if skills:
326
- skills.set_available_skills([*skills.get_available_skills(agent), *self.skill_paths])
500
+ authored_skills = {skill.name: skill for skill in skills.get_available_skills(agent)}
501
+ skills.set_available_skills([*authored_skills.values(), *self.skill_paths])
327
502
  await skills.init_agent(agent)
503
+ # Merge resolved skills: the SDK loads filesystem paths after Skill instances.
504
+ skills.set_available_skills(
505
+ [authored_skills.get(skill.name, skill) for skill in skills.get_available_skills(agent)]
506
+ )
328
507
  else:
329
508
  agent._plugin_registry.add_and_init(AgentSkills(skills=self.skill_paths))
509
+ self.attach_context_capture(agent)
510
+
511
+ def attach_context_capture(self, agent):
512
+ # Python exposes effective model requests only through the optional middleware registry.
513
+ try:
514
+ from strands.middleware import InvokeModelStage
515
+ except ImportError:
516
+ try:
517
+ from strands._middleware import InvokeModelStage
518
+ except ImportError:
519
+ return
520
+ registry = getattr(agent, "_middleware_registry", None)
521
+ add_middleware = getattr(agent, "add_middleware", None) or getattr(registry, "add_middleware", None)
522
+ handlers_by_stage = getattr(registry, "_handlers", None)
523
+ if not callable(add_middleware) or not isinstance(handlers_by_stage, dict):
524
+ return
525
+ capture_ready = False
526
+
527
+ def prepare(event):
528
+ nonlocal capture_ready
529
+ if event.agent is not agent:
530
+ return
531
+ self.context_estimates = None
532
+ self.context_usage = None
533
+ capture_ready = False
534
+ handlers = handlers_by_stage.get(InvokeModelStage)
535
+ if not isinstance(handlers, list):
536
+ return
537
+ # Hooks can register request transforms, so observe after every other Wrap handler.
538
+ for index, handler in enumerate(handlers):
539
+ if getattr(handler, "handler", None) is capture:
540
+ handlers.append(handlers.pop(index))
541
+ capture_ready = True
542
+ break
543
+
544
+ async def capture(context, next_handler):
545
+ estimates = None
546
+ if context.agent is agent:
547
+ self.context_estimates = None
548
+ self.context_usage = None
549
+ if capture_ready:
550
+ with contextlib.suppress(Exception):
551
+ handlers = handlers_by_stage.get(InvokeModelStage)
552
+ if isinstance(handlers, list) and getattr(handlers[-1], "handler", None) is capture:
553
+ estimates = await estimate_context_categories(context)
554
+ async for event in next_handler(context):
555
+ if context.agent is agent and "stop" in event:
556
+ self.context_usage = context_model_usage(event["stop"][2])
557
+ self.context_estimates = estimates if self.context_usage is not None else None
558
+ yield event
559
+
560
+ add_middleware(InvokeModelStage, capture)
561
+ agent.hooks.add_callback(BeforeModelCallEvent, prepare, order=HookOrder.SDK_LAST)
330
562
 
331
563
  def configuration_tool(self):
332
564
  runtime = self
@@ -354,15 +586,15 @@ class Runtime:
354
586
  if revision != 0:
355
587
  raise ValueError("Inspect the source before applying it, then pass revision 0.")
356
588
  runtime.reload_requested = True
357
- return "Source reload validated. It will be applied after this turn, preserving the conversation."
589
+ return (
590
+ "Source reload requested. Reload pending until this turn finishes; the conversation will be preserved."
591
+ )
358
592
 
359
593
  return strands_config
360
594
 
361
595
  async def cleanup(self, agent):
362
- manager = getattr(agent, "memory_manager", None)
363
- if manager:
364
- with contextlib.suppress(Exception):
365
- await manager.flush()
596
+ with contextlib.suppress(Exception):
597
+ await agent.shutdown_async()
366
598
  with contextlib.suppress(Exception):
367
599
  agent.cleanup()
368
600
 
@@ -380,15 +612,19 @@ class Runtime:
380
612
 
381
613
  def state(self):
382
614
  model = self.options.get("model")
615
+ model_specifier = self.options.get(
616
+ "model", self.source_configuration["model"] if self.source_configuration else None
617
+ )
618
+ thinking = self.options.get(
619
+ "effort", self.source_configuration["thinking"] if self.source_configuration else "auto"
620
+ )
383
621
  if not isinstance(model, str):
384
622
  model = str(self.agent.model.get_config().get("model_id", type(self.agent.model).__name__))
385
623
  manager = self.agent._session_manager
386
- session_id = (
387
- manager.session_id if isinstance(manager, SnapshotSessionManager) else self.options.get("session_id")
388
- )
389
- storage = manager._storage if isinstance(manager, SnapshotSessionManager) else None
390
- session_directory = local_session_directory(storage)
391
- stash_directory = local_stash_directory(self.agent)
624
+ session_id = manager.session_id if isinstance(manager, SnapshotSessionManager) else None
625
+ storage = getattr(manager, "_storage", None) if isinstance(manager, SnapshotSessionManager) else None
626
+ session_paths = local_storage_paths(storage)
627
+ session_directory = session_paths[0] if session_paths else None
392
628
  managed_session = session_directory is not None
393
629
  skills = self.skills()
394
630
  active = skills.get_activated_skills(self.agent) if skills else []
@@ -397,16 +633,16 @@ class Runtime:
397
633
  "reconstructable": callable(self.factory),
398
634
  "description": self.agent.description or "",
399
635
  "model": model,
400
- **({"modelSpecifier": self.options["model"]} if isinstance(self.options.get("model"), str) else {}),
401
- "thinking": self.options.get("effort", "auto"),
636
+ **({"modelSpecifier": model_specifier} if isinstance(model_specifier, str) else {}),
637
+ "thinking": thinking,
402
638
  **(
403
639
  {
404
640
  "sourceSelection": {
405
641
  "source": self.module.__file__,
406
642
  "configured": self.source_configuration,
407
643
  "selected": {
408
- "model": self.options.get("model") or DEFAULT_MODEL,
409
- "thinking": self.options.get("effort", "auto"),
644
+ "model": model_specifier,
645
+ "thinking": thinking,
410
646
  },
411
647
  }
412
648
  }
@@ -414,7 +650,7 @@ class Runtime:
414
650
  else {}
415
651
  ),
416
652
  **({"sessionId": session_id} if session_id else {}),
417
- "sessionDirectory": session_directory or self.options["session_dir"],
653
+ "sessionDirectory": session_directory or str(Path(self.session_configuration["sessionDir"]).resolve()),
418
654
  **(
419
655
  {
420
656
  "session": {
@@ -428,12 +664,7 @@ class Runtime:
428
664
  else {}
429
665
  ),
430
666
  "messages": display_messages(self.agent),
431
- "privatePaths": [
432
- *([session_directory] if session_directory else []),
433
- *([stash_directory] if stash_directory else []),
434
- *local_offloader_directories(self.agent),
435
- str(Path(self.options.get("memory_dir", ".agent/memory")).resolve()),
436
- ],
667
+ "privatePaths": agent_private_paths(self.agent),
437
668
  "tools": [
438
669
  {"name": spec["name"], "description": spec.get("description", "")}
439
670
  for spec in self.agent.tool_registry.get_all_tool_specs()
@@ -460,7 +691,7 @@ class Runtime:
460
691
  self.agent.messages,
461
692
  tool_specs=self.agent.tool_registry.get_all_tool_specs(),
462
693
  system_prompt=self.agent.system_prompt,
463
- system_prompt_content=self.agent._system_prompt_content,
694
+ system_prompt_content=self.agent.system_prompt_content,
464
695
  )
465
696
  except Exception:
466
697
  # The meter stays empty until the next model response reports usage.
@@ -493,6 +724,8 @@ class Runtime:
493
724
  async def turn(self, prompt):
494
725
  self.cancel_signal.clear()
495
726
  self.reload_requested = False
727
+ self.context_estimates = None
728
+ self.context_usage = None
496
729
  snapshot = self.agent.take_snapshot(preset="session")
497
730
  emitted_tool_results = set()
498
731
  try:
@@ -538,6 +771,16 @@ class Runtime:
538
771
  "projectedTokens": result.projected_context_size,
539
772
  "contextWindow": self.agent.model.context_window_limit,
540
773
  }
774
+ invocations = getattr(result.metrics, "agent_invocations", [])
775
+ cycles = getattr(invocations[-1], "cycles", []) if invocations else []
776
+ latest_usage = context_model_usage(getattr(cycles[-1], "usage", None)) if cycles else None
777
+ breakdown = context_breakdown(
778
+ self.context_estimates if self.context_usage == latest_usage else None,
779
+ result.context_size,
780
+ result.projected_context_size,
781
+ )
782
+ if breakdown is not None:
783
+ context["breakdown"] = breakdown
541
784
  self.result(
542
785
  {
543
786
  "stopReason": result.stop_reason,
@@ -591,7 +834,7 @@ class Runtime:
591
834
  async def command(self, command):
592
835
  kind = command["type"]
593
836
  if kind == "conversation":
594
- from strands.types._snapshot import Snapshot
837
+ from strands.types import Snapshot
595
838
 
596
839
  snapshot = command.get("snapshot")
597
840
  if snapshot:
@@ -606,6 +849,9 @@ class Runtime:
606
849
  await self.save()
607
850
  self.result({"stopReason": "restored"})
608
851
  else:
852
+ manager = getattr(self.agent, "memory_manager", None)
853
+ if manager:
854
+ await manager.flush()
609
855
  snapshot = self.agent.take_snapshot(include=["messages", "state", "conversation_manager_state"])
610
856
  self.result(
611
857
  {
@@ -648,7 +894,7 @@ class Runtime:
648
894
  entries = await stash.take_snapshot() if stash is not None else {}
649
895
  self.result({"stopReason": "stash", "finalText": json.dumps(entries, default=encode)})
650
896
  elif kind == "seed":
651
- from strands.types._snapshot import Snapshot
897
+ from strands.types import Snapshot
652
898
 
653
899
  self.agent.load_snapshot(Snapshot.from_dict(json.loads(command["snapshot"], object_hook=decode)))
654
900
  stash = agent_stash(self.agent)
@@ -666,9 +912,10 @@ class Runtime:
666
912
  if "thinking" in command:
667
913
  options["effort"] = command["thinking"]
668
914
  self.explicit_option_keys.add("effort")
669
- if "sessionId" in command and options.get("session", True):
670
- options["session_id"] = command["sessionId"]
671
- self.explicit_option_keys.add("session_id")
915
+ session = options.get("session", getattr(self.module, "_strands_options", {}).get("session", True))
916
+ if "sessionId" in command and (session is True or isinstance(session, dict)):
917
+ options["session"] = {**(session if isinstance(session, dict) else {}), "id": command["sessionId"]}
918
+ self.explicit_option_keys.add("session")
672
919
  snapshot = None if command.get("clear") else self.agent.take_snapshot(preset="session")
673
920
  await self.build(options, snapshot)
674
921
  self.result({"stopReason": "reset"})
@@ -682,7 +929,7 @@ class Runtime:
682
929
  skills = self.skills()
683
930
  if not skills:
684
931
  raise ValueError("This agent has no skills")
685
- await skills.skills(
932
+ content = await skills.skills(
686
933
  skill_name=command["name"],
687
934
  tool_context=ToolContext(
688
935
  tool_use={"toolUseId": str(uuid4()), "name": "skills", "input": {}},
@@ -691,7 +938,7 @@ class Runtime:
691
938
  ),
692
939
  )
693
940
  await self.save()
694
- self.result({"stopReason": "activated"})
941
+ self.result({"stopReason": "activated", "finalText": content})
695
942
  else:
696
943
  raise ValueError(f"Unknown terminal command: {kind}")
697
944
 
@@ -747,7 +994,8 @@ def load_project(entrypoint, root):
747
994
 
748
995
  def capture_create_harness(*args, **options):
749
996
  agent = original_create_harness(*args, **options)
750
- captured.append((agent, args, options))
997
+ if captured is not None:
998
+ captured.append((agent, args, options))
751
999
  return agent
752
1000
 
753
1001
  strands_harness.create_harness = capture_create_harness
@@ -766,8 +1014,11 @@ def load_project(entrypoint, root):
766
1014
  agent = getattr(module, "agent", None)
767
1015
  if not isinstance(agent, Agent):
768
1016
  raise TypeError('Export a Strands Agent as "agent".')
1017
+ construction = next(((args, options) for candidate, args, options in captured if candidate is agent), None)
1018
+ captured = None
1019
+ if construction is not None:
1020
+ module._strands_options = construction[1]
769
1021
  if not callable(getattr(module, "create_agent", None)) and direct_harness_assignment(entrypoint):
770
- construction = next(((args, options) for candidate, args, options in captured if candidate is agent), None)
771
1022
  if construction is not None:
772
1023
  args, options = construction
773
1024
 
@@ -780,13 +1031,13 @@ def load_project(entrypoint, root):
780
1031
 
781
1032
  async def main():
782
1033
  module = load_project(Path(sys.argv[1]).resolve(), Path(sys.argv[2]).resolve())
783
- command = json.loads(await asyncio.to_thread(sys.stdin.readline))
1034
+ command = json.loads(await asyncio.to_thread(commands.readline))
784
1035
  runtime = Runtime(module, command)
785
- await runtime.build(runtime.options)
1036
+ await runtime.build(runtime.options, resume=command.get("resume", False))
786
1037
  send({"type": "ready", "state": runtime.state()})
787
1038
  running = None
788
1039
  try:
789
- while line := await asyncio.to_thread(sys.stdin.readline):
1040
+ while line := await asyncio.to_thread(commands.readline):
790
1041
  command = json.loads(line, object_hook=decode)
791
1042
  kind = command["type"]
792
1043
  if kind == "permission":
@@ -808,6 +1059,7 @@ async def main():
808
1059
  await runtime.command(command)
809
1060
  except Exception as error:
810
1061
  send({"type": "error", "message": str(error)})
1062
+ del command, line
811
1063
  finally:
812
1064
  if running and not running.done():
813
1065
  running.cancel()