@qduc/term2 0.31.1 → 0.32.1

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 (294) hide show
  1. package/README.md +52 -370
  2. package/dist/agent.d.ts +2 -1
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js +11 -1
  5. package/dist/agent.js.map +1 -1
  6. package/dist/app.d.ts +3 -1
  7. package/dist/app.d.ts.map +1 -1
  8. package/dist/app.js +44 -4
  9. package/dist/app.js.map +1 -1
  10. package/dist/build-info.json +2 -2
  11. package/dist/cli.js +13 -3
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands/goal-command.d.ts.map +1 -1
  14. package/dist/commands/goal-command.js +9 -8
  15. package/dist/commands/goal-command.js.map +1 -1
  16. package/dist/commands/retry-failed-turn-command.d.ts.map +1 -1
  17. package/dist/commands/retry-failed-turn-command.js +3 -4
  18. package/dist/commands/retry-failed-turn-command.js.map +1 -1
  19. package/dist/components/InputBox.js +16 -9
  20. package/dist/components/InputBox.js.map +1 -1
  21. package/dist/components/layout/BackgroundTasksPanel.d.ts.map +1 -1
  22. package/dist/components/layout/BackgroundTasksPanel.js +6 -8
  23. package/dist/components/layout/BackgroundTasksPanel.js.map +1 -1
  24. package/dist/components/layout/BottomArea.d.ts.map +1 -1
  25. package/dist/components/layout/BottomArea.js +13 -11
  26. package/dist/components/layout/BottomArea.js.map +1 -1
  27. package/dist/components/message/MessageList.d.ts +3 -1
  28. package/dist/components/message/MessageList.d.ts.map +1 -1
  29. package/dist/components/message/MessageList.js +5 -2
  30. package/dist/components/message/MessageList.js.map +1 -1
  31. package/dist/components/message/SessionBoundary.d.ts +11 -0
  32. package/dist/components/message/SessionBoundary.d.ts.map +1 -0
  33. package/dist/components/message/SessionBoundary.js +22 -0
  34. package/dist/components/message/SessionBoundary.js.map +1 -0
  35. package/dist/components/prompt/ApprovalPrompt.d.ts.map +1 -1
  36. package/dist/components/prompt/ApprovalPrompt.js +22 -1
  37. package/dist/components/prompt/ApprovalPrompt.js.map +1 -1
  38. package/dist/contracts/provider-input.d.ts +10 -0
  39. package/dist/contracts/provider-input.d.ts.map +1 -1
  40. package/dist/contracts/provider-input.js.map +1 -1
  41. package/dist/contracts/run-termination.d.ts +3 -1
  42. package/dist/contracts/run-termination.d.ts.map +1 -1
  43. package/dist/hooks/settings-completion-config.d.ts.map +1 -1
  44. package/dist/hooks/settings-completion-config.js +1 -0
  45. package/dist/hooks/settings-completion-config.js.map +1 -1
  46. package/dist/lib/agent-chat-service.d.ts +6 -0
  47. package/dist/lib/agent-chat-service.d.ts.map +1 -1
  48. package/dist/lib/agent-chat-service.js +29 -5
  49. package/dist/lib/agent-chat-service.js.map +1 -1
  50. package/dist/lib/agent-client.d.ts +6 -0
  51. package/dist/lib/agent-client.d.ts.map +1 -1
  52. package/dist/lib/agent-client.js +82 -24
  53. package/dist/lib/agent-client.js.map +1 -1
  54. package/dist/lib/agent-configuration.d.ts +7 -3
  55. package/dist/lib/agent-configuration.d.ts.map +1 -1
  56. package/dist/lib/agent-configuration.js +10 -4
  57. package/dist/lib/agent-configuration.js.map +1 -1
  58. package/dist/lib/agent-factory.d.ts.map +1 -1
  59. package/dist/lib/agent-factory.js +15 -4
  60. package/dist/lib/agent-factory.js.map +1 -1
  61. package/dist/non-interactive.d.ts +5 -0
  62. package/dist/non-interactive.d.ts.map +1 -1
  63. package/dist/non-interactive.js +63 -6
  64. package/dist/non-interactive.js.map +1 -1
  65. package/dist/prompts/durable-goal-context.d.ts.map +1 -1
  66. package/dist/prompts/durable-goal-context.js +12 -2
  67. package/dist/prompts/durable-goal-context.js.map +1 -1
  68. package/dist/prompts/durable-goal-context.ts +13 -2
  69. package/dist/providers/ai-sdk-openrouter.provider.js +3 -2
  70. package/dist/providers/ai-sdk-openrouter.provider.js.map +1 -1
  71. package/dist/providers/ai-sdk-streamed-model.d.ts.map +1 -1
  72. package/dist/providers/ai-sdk-streamed-model.js +12 -2
  73. package/dist/providers/ai-sdk-streamed-model.js.map +1 -1
  74. package/dist/providers/codex-responses-model.d.ts.map +1 -1
  75. package/dist/providers/codex-responses-model.js +35 -16
  76. package/dist/providers/codex-responses-model.js.map +1 -1
  77. package/dist/providers/openai-chat-completions-model.d.ts.map +1 -1
  78. package/dist/providers/openai-chat-completions-model.js +11 -3
  79. package/dist/providers/openai-chat-completions-model.js.map +1 -1
  80. package/dist/services/agent-runtime/application-run-loop.d.ts +34 -1
  81. package/dist/services/agent-runtime/application-run-loop.d.ts.map +1 -1
  82. package/dist/services/agent-runtime/application-run-loop.js +174 -33
  83. package/dist/services/agent-runtime/application-run-loop.js.map +1 -1
  84. package/dist/services/agent-runtime/context-compaction/index.d.ts.map +1 -1
  85. package/dist/services/agent-runtime/context-compaction/index.js +65 -16
  86. package/dist/services/agent-runtime/context-compaction/index.js.map +1 -1
  87. package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts +7 -1
  88. package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts.map +1 -1
  89. package/dist/services/agent-runtime/context-compaction/local-context-compactor.js +115 -20
  90. package/dist/services/agent-runtime/context-compaction/local-context-compactor.js.map +1 -1
  91. package/dist/services/agent-runtime/model-context-policy.d.ts +21 -0
  92. package/dist/services/agent-runtime/model-context-policy.d.ts.map +1 -0
  93. package/dist/services/agent-runtime/model-context-policy.js +46 -0
  94. package/dist/services/agent-runtime/model-context-policy.js.map +1 -0
  95. package/dist/services/agent-runtime/request-input-limit.d.ts +31 -0
  96. package/dist/services/agent-runtime/request-input-limit.d.ts.map +1 -0
  97. package/dist/services/agent-runtime/request-input-limit.js +86 -0
  98. package/dist/services/agent-runtime/request-input-limit.js.map +1 -0
  99. package/dist/services/agent-runtime/run-budget.d.ts +3 -5
  100. package/dist/services/agent-runtime/run-budget.d.ts.map +1 -1
  101. package/dist/services/agent-runtime/run-budget.js.map +1 -1
  102. package/dist/services/agent-runtime/tool-call-execution.d.ts +24 -2
  103. package/dist/services/agent-runtime/tool-call-execution.d.ts.map +1 -1
  104. package/dist/services/agent-runtime/tool-call-execution.js +36 -6
  105. package/dist/services/agent-runtime/tool-call-execution.js.map +1 -1
  106. package/dist/services/agent-runtime/tool-invocation-context.d.ts +24 -12
  107. package/dist/services/agent-runtime/tool-invocation-context.d.ts.map +1 -1
  108. package/dist/services/agent-runtime/tool-invocation-context.js +38 -27
  109. package/dist/services/agent-runtime/tool-invocation-context.js.map +1 -1
  110. package/dist/services/approval/approval-replay.d.ts +15 -24
  111. package/dist/services/approval/approval-replay.d.ts.map +1 -1
  112. package/dist/services/approval/approval-replay.js +12 -30
  113. package/dist/services/approval/approval-replay.js.map +1 -1
  114. package/dist/services/approval/non-interactive-approval-policy.d.ts.map +1 -1
  115. package/dist/services/approval/non-interactive-approval-policy.js +11 -0
  116. package/dist/services/approval/non-interactive-approval-policy.js.map +1 -1
  117. package/dist/services/approval/tool-approval-batch-coordinator.d.ts.map +1 -1
  118. package/dist/services/approval/tool-approval-batch-coordinator.js +0 -5
  119. package/dist/services/approval/tool-approval-batch-coordinator.js.map +1 -1
  120. package/dist/services/conversation/conversation-checkpoint-provenance.d.ts.map +1 -1
  121. package/dist/services/conversation/conversation-checkpoint-provenance.js +10 -2
  122. package/dist/services/conversation/conversation-checkpoint-provenance.js.map +1 -1
  123. package/dist/services/conversation/conversation-events.d.ts +2 -0
  124. package/dist/services/conversation/conversation-events.d.ts.map +1 -1
  125. package/dist/services/conversation/conversation-events.js.map +1 -1
  126. package/dist/services/conversation/conversation-orchestrator.d.ts +1 -1
  127. package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
  128. package/dist/services/conversation/conversation-orchestrator.js +14 -2
  129. package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
  130. package/dist/services/conversation/conversation-replay.d.ts.map +1 -1
  131. package/dist/services/conversation/conversation-replay.js +78 -3
  132. package/dist/services/conversation/conversation-replay.js.map +1 -1
  133. package/dist/services/conversation/conversation-service.d.ts +2 -2
  134. package/dist/services/conversation/conversation-service.d.ts.map +1 -1
  135. package/dist/services/conversation/conversation-service.js +5 -1
  136. package/dist/services/conversation/conversation-service.js.map +1 -1
  137. package/dist/services/conversation/conversation-state-projector.d.ts +1 -0
  138. package/dist/services/conversation/conversation-state-projector.d.ts.map +1 -1
  139. package/dist/services/conversation/conversation-state-projector.js +5 -1
  140. package/dist/services/conversation/conversation-state-projector.js.map +1 -1
  141. package/dist/services/conversation/durable-goal-stop-check.d.ts +141 -0
  142. package/dist/services/conversation/durable-goal-stop-check.d.ts.map +1 -0
  143. package/dist/services/conversation/durable-goal-stop-check.js +351 -0
  144. package/dist/services/conversation/durable-goal-stop-check.js.map +1 -0
  145. package/dist/services/conversation/durable-goal.d.ts +16 -1
  146. package/dist/services/conversation/durable-goal.d.ts.map +1 -1
  147. package/dist/services/conversation/durable-goal.js +8 -0
  148. package/dist/services/conversation/durable-goal.js.map +1 -1
  149. package/dist/services/conversation/local-checkpoint-projection.d.ts.map +1 -1
  150. package/dist/services/conversation/local-checkpoint-projection.js +12 -1
  151. package/dist/services/conversation/local-checkpoint-projection.js.map +1 -1
  152. package/dist/services/conversation/session-browser.d.ts +2 -0
  153. package/dist/services/conversation/session-browser.d.ts.map +1 -1
  154. package/dist/services/conversation/session-browser.js +23 -8
  155. package/dist/services/conversation/session-browser.js.map +1 -1
  156. package/dist/services/conversation/session-index/session-index-worker-client.d.ts +3 -0
  157. package/dist/services/conversation/session-index/session-index-worker-client.d.ts.map +1 -1
  158. package/dist/services/conversation/session-index/session-index-worker-client.js +6 -1
  159. package/dist/services/conversation/session-index/session-index-worker-client.js.map +1 -1
  160. package/dist/services/conversation/session-index/session-index-worker.d.ts +16 -1
  161. package/dist/services/conversation/session-index/session-index-worker.d.ts.map +1 -1
  162. package/dist/services/conversation/session-index/session-index-worker.js +16 -0
  163. package/dist/services/conversation/session-index/session-index-worker.js.map +1 -1
  164. package/dist/services/conversation-agent-client.d.ts +1 -0
  165. package/dist/services/conversation-agent-client.d.ts.map +1 -1
  166. package/dist/services/logging/conversation-log-events.d.ts +7 -0
  167. package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
  168. package/dist/services/logging/conversation-log-events.js.map +1 -1
  169. package/dist/services/retry/retry-classifier.d.ts.map +1 -1
  170. package/dist/services/retry/retry-classifier.js +2 -1
  171. package/dist/services/retry/retry-classifier.js.map +1 -1
  172. package/dist/services/retry/retry-error-classification.d.ts.map +1 -1
  173. package/dist/services/retry/retry-error-classification.js +1 -0
  174. package/dist/services/retry/retry-error-classification.js.map +1 -1
  175. package/dist/services/service-interfaces.d.ts +2 -0
  176. package/dist/services/service-interfaces.d.ts.map +1 -1
  177. package/dist/services/session/initial-turn-recovery-handler.d.ts.map +1 -1
  178. package/dist/services/session/initial-turn-recovery-handler.js +6 -0
  179. package/dist/services/session/initial-turn-recovery-handler.js.map +1 -1
  180. package/dist/services/session/session-composition.d.ts.map +1 -1
  181. package/dist/services/session/session-composition.js +7 -5
  182. package/dist/services/session/session-composition.js.map +1 -1
  183. package/dist/services/session/session-manager.d.ts +2 -0
  184. package/dist/services/session/session-manager.d.ts.map +1 -1
  185. package/dist/services/session/session-manager.js +10 -0
  186. package/dist/services/session/session-manager.js.map +1 -1
  187. package/dist/services/session/session-stream-processor.d.ts.map +1 -1
  188. package/dist/services/session/session-stream-processor.js +11 -0
  189. package/dist/services/session/session-stream-processor.js.map +1 -1
  190. package/dist/services/session/session-tool-tracker.d.ts +18 -1
  191. package/dist/services/session/session-tool-tracker.d.ts.map +1 -1
  192. package/dist/services/session/session-tool-tracker.js +38 -1
  193. package/dist/services/session/session-tool-tracker.js.map +1 -1
  194. package/dist/services/session/terminal-result-collector.d.ts.map +1 -1
  195. package/dist/services/session/terminal-result-collector.js +3 -0
  196. package/dist/services/session/terminal-result-collector.js.map +1 -1
  197. package/dist/services/session/turn-workflow.d.ts.map +1 -1
  198. package/dist/services/session/turn-workflow.js +3 -0
  199. package/dist/services/session/turn-workflow.js.map +1 -1
  200. package/dist/services/settings/settings-env.d.ts.map +1 -1
  201. package/dist/services/settings/settings-env.js +6 -0
  202. package/dist/services/settings/settings-env.js.map +1 -1
  203. package/dist/services/settings/settings-persistence.d.ts +2 -1
  204. package/dist/services/settings/settings-persistence.d.ts.map +1 -1
  205. package/dist/services/settings/settings-persistence.js +1 -1
  206. package/dist/services/settings/settings-persistence.js.map +1 -1
  207. package/dist/services/settings/settings-schema.d.ts +7 -1
  208. package/dist/services/settings/settings-schema.d.ts.map +1 -1
  209. package/dist/services/settings/settings-schema.js +17 -6
  210. package/dist/services/settings/settings-schema.js.map +1 -1
  211. package/dist/services/settings/settings-service.d.ts +3 -0
  212. package/dist/services/settings/settings-service.d.ts.map +1 -1
  213. package/dist/services/settings/settings-service.js +74 -31
  214. package/dist/services/settings/settings-service.js.map +1 -1
  215. package/dist/services/settings/settings-sources.d.ts +1 -0
  216. package/dist/services/settings/settings-sources.d.ts.map +1 -1
  217. package/dist/services/settings/settings-sources.js +1 -0
  218. package/dist/services/settings/settings-sources.js.map +1 -1
  219. package/dist/services/settings/settings-ui-metadata.js +1 -1
  220. package/dist/services/settings/settings-ui-metadata.js.map +1 -1
  221. package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +1 -1
  222. package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts.map +1 -1
  223. package/dist/services/settings/test-helpers/settings-consumer-inventory.js +1 -0
  224. package/dist/services/settings/test-helpers/settings-consumer-inventory.js.map +1 -1
  225. package/dist/services/subagents/execution-runner.d.ts.map +1 -1
  226. package/dist/services/subagents/execution-runner.js +16 -3
  227. package/dist/services/subagents/execution-runner.js.map +1 -1
  228. package/dist/services/subagents/nested-runner.d.ts.map +1 -1
  229. package/dist/services/subagents/nested-runner.js +3 -2
  230. package/dist/services/subagents/nested-runner.js.map +1 -1
  231. package/dist/services/tool-execution-ledger.d.ts +22 -0
  232. package/dist/services/tool-execution-ledger.d.ts.map +1 -1
  233. package/dist/services/tool-execution-ledger.js +40 -3
  234. package/dist/services/tool-execution-ledger.js.map +1 -1
  235. package/dist/services/workflow-evolution/cli.d.ts +2 -0
  236. package/dist/services/workflow-evolution/cli.d.ts.map +1 -0
  237. package/dist/services/workflow-evolution/cli.js +26 -0
  238. package/dist/services/workflow-evolution/cli.js.map +1 -0
  239. package/dist/services/workflow-evolution/demo.d.ts +18 -0
  240. package/dist/services/workflow-evolution/demo.d.ts.map +1 -0
  241. package/dist/services/workflow-evolution/demo.js +177 -0
  242. package/dist/services/workflow-evolution/demo.js.map +1 -0
  243. package/dist/services/workflow-evolution/experiment.d.ts +304 -0
  244. package/dist/services/workflow-evolution/experiment.d.ts.map +1 -0
  245. package/dist/services/workflow-evolution/experiment.js +251 -0
  246. package/dist/services/workflow-evolution/experiment.js.map +1 -0
  247. package/dist/services/workflow-evolution/ledger.d.ts +5 -0
  248. package/dist/services/workflow-evolution/ledger.d.ts.map +1 -0
  249. package/dist/services/workflow-evolution/ledger.js +57 -0
  250. package/dist/services/workflow-evolution/ledger.js.map +1 -0
  251. package/dist/skins/rail/status.d.ts.map +1 -1
  252. package/dist/skins/rail/status.js +21 -11
  253. package/dist/skins/rail/status.js.map +1 -1
  254. package/dist/tools/agent/goal-check.d.ts +23 -0
  255. package/dist/tools/agent/goal-check.d.ts.map +1 -0
  256. package/dist/tools/agent/goal-check.js +79 -0
  257. package/dist/tools/agent/goal-check.js.map +1 -0
  258. package/dist/tools/system/run-code/run-code-runtime.d.ts.map +1 -1
  259. package/dist/tools/system/run-code/run-code-runtime.js +3 -1
  260. package/dist/tools/system/run-code/run-code-runtime.js.map +1 -1
  261. package/dist/tools/tool-names.d.ts +1 -0
  262. package/dist/tools/tool-names.d.ts.map +1 -1
  263. package/dist/tools/tool-names.js +1 -0
  264. package/dist/tools/tool-names.js.map +1 -1
  265. package/dist/tools/types.d.ts +21 -0
  266. package/dist/tools/types.d.ts.map +1 -1
  267. package/dist/tools/types.js +7 -0
  268. package/dist/tools/types.js.map +1 -1
  269. package/dist/utils/conversation/conversation-event-handler.d.ts.map +1 -1
  270. package/dist/utils/conversation/conversation-event-handler.js +7 -1
  271. package/dist/utils/conversation/conversation-event-handler.js.map +1 -1
  272. package/dist/utils/output/text-snippet.js +25 -33
  273. package/dist/utils/output/text-snippet.js.map +1 -1
  274. package/dist/utils/streaming/extract-command-messages.d.ts +2 -0
  275. package/dist/utils/streaming/extract-command-messages.d.ts.map +1 -1
  276. package/dist/utils/streaming/extract-command-messages.js +4 -0
  277. package/dist/utils/streaming/extract-command-messages.js.map +1 -1
  278. package/dist/utils/value-suggestions.d.ts.map +1 -1
  279. package/dist/utils/value-suggestions.js +1 -0
  280. package/dist/utils/value-suggestions.js.map +1 -1
  281. package/package.json +3 -5
  282. package/dist/prompts/durable-goal-context.test.ts +0 -56
  283. package/dist/prompts/explorer-delegation-contract.test.ts +0 -44
  284. package/dist/prompts/memory-recall-notice.test.ts +0 -50
  285. package/dist/prompts/orchestrator-prompt.test.ts +0 -111
  286. package/dist/prompts/prefix-quality.test.ts +0 -115
  287. package/dist/prompts/prompt-constructor.test.ts +0 -423
  288. package/dist/prompts/prompt-profiles.test.ts +0 -22
  289. package/dist/prompts/reasoning-efficiency.test.ts +0 -12
  290. package/dist/prompts/search-via-shell.test.ts +0 -69
  291. package/dist/prompts/steering-notice.test.ts +0 -36
  292. package/dist/prompts/subagent-delegation.test.ts +0 -112
  293. package/dist/prompts/subagents/worker-prompt.test.ts +0 -54
  294. package/dist/prompts/unified-gpt-prompt.test.ts +0 -53
package/README.md CHANGED
@@ -1,418 +1,100 @@
1
1
  # term2
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@qduc/term2.svg?style=flat-square)](https://www.npmjs.com/package/@qduc/term2)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
- [![Node.js](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg?style=flat-square)](https://nodejs.org)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue.svg?style=flat-square)](https://www.typescriptlang.org/)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
7
5
 
8
- term2 is an open-source terminal AI assistant and autonomous agent runtime built for high-velocity software engineering and system administration.
6
+ **term2 is an open-source AI assistant for coding and terminal work.**
9
7
 
10
- Combining a fast React (Ink) terminal interface with an application-owned run loop, term2 provides fine-grained execution safety, native multi-agent delegation, provider-neutral context compaction, and seamless multi-provider support—giving developers complete agency over their workflow without vendor lock-in or subscription gates.
8
+ Read a codebase, edit files, and run commands locally or over SSH. Choose your model, delegate work to subagents, and return to saved conversations.
11
9
 
12
- ---
10
+ ![term2 tracing, fixing, and testing a real bug from its own history](docs/demo/demo.gif)
13
11
 
14
- ## Core Capabilities
12
+ [Website & documentation](https://qduc.github.io/term2/) · [First run](https://qduc.github.io/term2/getting-started/first-run/) · [Changelog](CHANGELOG.md)
15
13
 
16
- - **Open Source and Local First**: MIT licensed. No mandatory subscriptions, telemetry lock-in, or proprietary walled gardens.
17
- - **Universal Provider Support**: Native integration with OpenAI (WebSocket Responses and Chat Completions), ChatGPT/Codex OAuth (browser PKCE), Grok Responses API (with encrypted reasoning and OAuth), OpenRouter, Anthropic, Google Gemini, and custom local endpoints (Ollama, llama.cpp, vLLM).
18
- - **Fine-Grained Sandboxing and Safety**: Sandboxed shell execution with configurable read/write boundaries (`standard`, `strict`) and interactive unified diff previews.
19
- - **Shell Auto-Approval Modes**: Configure shell approval as `off`, `advisory`, `auto`, or `always`; `always` disables the shell sandbox.
20
- - **Multi-Agent Orchestration**: Spawn specialized foreground or background subagents (`explorer`, `worker`, `mentor`, `librarian`) across tiered model profiles (`smart`, `balanced`, `cheap`, `chore`).
21
- - **Provider-Neutral Context Compaction**: Intelligently compacts long conversation histories (via `/compact` or automatic thresholds) while preserving cold-prefix architectural facts and hot-tail tool ledger integrity.
22
- - **Time-Travel Rewind and Forking**: Non-destructive conversation rewinding with discard previews (`/rewind`, `/undo`, `/retry`), session resumption (`/resume`, `--resume`), and session branching (`--fork`).
23
- - **Native Remote Development**: Execute commands and manage codebases on remote servers seamlessly over SSH with SSH agent authentication.
24
- - **Five Focused Operating Modes**: Standard, Plan, Lite, Mentor, and Orchestrator modes adapted to every phase of engineering.
14
+ ## What you can do
25
15
 
26
- ---
16
+ - **Work with a codebase.** Trace a failure, implement a feature, review a change, and run tests. Use `/plan` for read-only exploration.
17
+ - **Choose your models.** Connect a supported hosted provider or a local model endpoint. Switch models with `/model` and manage connections with `/providers`.
18
+ - **Delegate tasks.** Use [subagents](https://qduc.github.io/term2/modes/subagents/) for research, implementation, or review, including background work.
19
+ - **Keep working across sessions.** Resume a conversation after a break, fork it to try another approach, or work with a remote project over SSH.
27
20
 
28
- ## Comparison: Why term2?
21
+ ## Get started
29
22
 
30
- | Feature | term2 | Claude Code | Warp |
31
- | :--- | :---: | :---: | :---: |
32
- | **License** | **MIT Open Source** | Proprietary | Proprietary / Closed Core |
33
- | **Cost** | **Direct API / Pay-per-use** | Subscription / API | Freemium / Paid Tiers |
34
- | **Model Ecosystem** | **Any** (OpenAI, Codex, Grok, OpenRouter, Anthropic, Google, Local) | Anthropic only | Selected Cloud Models |
35
- | **OAuth Browser Login** | **Grok and Codex PKCE** | No | No |
36
- | **Local LLMs (Ollama/llama.cpp)** | **Native** | No | Partial (BYOLLM) |
37
- | **Subagent Swarms** | **Configurable 4-Tier Roles** | Limited | No |
38
- | **Remote SSH Workspaces** | **Native SSH Agent** | Remote Control | SSH Client |
39
- | **Dual-Model Mentor Mode** | **Built-in** | No | No |
40
- | **Context Compaction** | **Local and Provider-Native** | Automatic (Closed) | No |
23
+ You need Node.js **20 or newer** (Node 24 recommended), an interactive terminal, and access to a model provider.
41
24
 
42
- ---
43
-
44
- ## Installation
45
-
46
- ### Prerequisites
47
- - Node.js version 20.0.0 or higher
48
- - An API key or OAuth account for your preferred AI provider
49
-
50
- ### Install via Package Manager
51
25
  ```bash
52
- # Install globally via npm
53
26
  npm install --global @qduc/term2
54
-
55
- # Or using pnpm
56
- pnpm add --global @qduc/term2
27
+ term2 --version
57
28
  ```
58
29
 
59
- ### Quick Setup
30
+ On Linux, sandboxed shell commands also need `bubblewrap` (`bwrap`), `socat`, and `ripgrep` (`rg`). Install them with your OS package manager. Shell execution fails closed when the enabled sandbox is unavailable. See [installation](https://qduc.github.io/term2/getting-started/installation/) for platform details.
60
31
 
61
- #### 1. OAuth Browser Login (Grok or Codex)
62
- term2 supports browser-based PKCE OAuth logins for OpenAI Codex/ChatGPT and xAI Grok:
63
- ```bash
64
- # Log in to xAI Grok
65
- term2 --grok-login
66
-
67
- # Log in to OpenAI Codex / ChatGPT
68
- term2 --codex-login
69
- ```
32
+ Choose one authentication path:
70
33
 
71
- > **Multi-Account Management**: Manage multiple OAuth accounts and switch between active profiles at runtime via the `/providers` menu.
72
-
73
- #### 2. Environment Variables (API Keys)
74
- Alternatively, export the API key for your chosen provider:
75
34
  ```bash
76
- # OpenAI
77
- export OPENAI_API_KEY="sk-..."
78
-
79
- # OpenRouter (Claude, Gemini, DeepSeek, etc.)
80
- export OPENROUTER_API_KEY="sk-or-v1-..."
81
-
82
- # Anthropic
83
- export ANTHROPIC_API_KEY="sk-ant-..."
84
-
85
- # Google Gemini
86
- export GOOGLE_GENERATIVE_AI_API_KEY="..."
87
-
88
- # Web Search (Tavily or Exa)
89
- export TAVILY_API_KEY="tvly-..."
90
- export EXA_API_KEY="..."
91
- ```
92
-
93
- ---
94
-
95
- ## Quick Start
96
-
97
- Launch term2 in your project directory:
98
-
99
- ```bash
100
- # Start standard interactive session
101
- term2
102
-
103
- # Start in lightweight mode (fast system/terminal operations, no codebase ingestion)
104
- term2 --lite
105
-
106
- # Start with a specific model and provider
107
- term2 -m claude-sonnet-4.6 -p openrouter
108
-
109
- # Resume the last conversation session
110
- term2 --resume
35
+ # ChatGPT / Codex: complete the browser login
36
+ term2 --codex-login
111
37
 
112
- # Run a non-interactive prompt from the command line
113
- term2 "Explain the architecture of source/agent.ts"
38
+ # Or OpenAI API: set your own API key in this shell
39
+ export OPENAI_API_KEY="your-api-key"
114
40
  ```
115
41
 
116
- ---
117
-
118
- ## Operating Modes
119
-
120
- term2 features five distinct operating modes tailored to different stages of development:
121
-
122
- | Mode | Trigger / CLI | Purpose and Behavior | Tools and Context |
123
- | :--- | :--- | :--- | :--- |
124
- | **Standard** | `term2` *(default)* | High-velocity codebase development. Automatically approves workspace file patches while gating destructive commands. | Full codebase context, all tools, patch auto-approval. |
125
- | **Plan** | `/plan` or `Shift+Tab` | Architecture design, research, and code exploration. Enforces read-only safety guarantees (no file writes or mutating commands). | Full codebase context, read-only tools. |
126
- | **Lite** | `term2 --lite` or `/lite` | General terminal tasks, DevOps, and SSH administration without codebase ingestion overhead. | Session context only, read-only system tools. |
127
- | **Mentor** | `/mentor` | Collaborative problem-solving. Pairs the primary model with a higher-tier strategic model (`smartModel`) for architectural review. | Full codebase context, all tools and `ask_mentor`. |
128
- | **Orchestrator** | `/orchestrator` | High-level task coordination. Encourages prompt-guided delegation across specialized subagents while retaining end-to-end turn ownership. | Full codebase context, direct tools and subagent delegation. |
129
-
130
- > **Mode Switching:** Press `Shift+Tab` to cycle the application's operating modes. To run one direct shell command in any operating mode, prefix the input with `!`; the command and output are added to the conversation, then the input returns to normal mode. Use slash commands (`/plan`, `/lite`, `/mentor`, `/orchestrator`) to switch modes explicitly.
131
-
132
- ---
133
-
134
- ## Subagents Architecture
135
-
136
- term2 includes a modular subagent execution system designed to isolate heavy computational, research, or modification workloads from the main conversation transcript. Each subagent operates under a defined role profile with explicit permissions, execution budgets, and capability tiers.
137
-
138
- ### Explorer Subagent
139
- - **Purpose**: Rapid codebase reconnaissance, symbol search, file discovery, and dependency mapping.
140
- - **Permissions**: Read-only (`canRead: true`, `canWrite: false`, `canSearchWeb: true`, `canRunShell: true`).
141
- - **Safety Boundary**: Restricted to non-destructive read operations and safe read-only shell commands (`rg`, `fd`, `git status`).
142
- - **Model Tier**: Defaults to `agent.cheapModel` (e.g. `gpt-5.4-mini`) to minimize latency and token consumption during wide search operations.
143
-
144
- ### Worker Subagent
145
- - **Purpose**: Autonomous implementation of discrete tasks, file modifications, refactoring slices, and running automated test suites.
146
- - **Permissions**: Full read/write (`canRead: true`, `canWrite: true`, `canSearchWeb: false`, `canRunShell: true`).
147
- - **Safety Boundary**: Sandboxed to the workspace root directory. Supports pinning execution to a dedicated Git worktree (`worktree` parameter) to isolate dirty state from the parent checkout.
148
- - **Model Tier**: Defaults to `agent.balancedModel` (e.g. `gpt-5.3-codex` or `claude-sonnet-4.6`).
149
-
150
- ### Mentor Subagent
151
- - **Purpose**: High-level strategic consultation, algorithmic design analysis, and independent second-opinion code review.
152
- - **Permissions**: Advisory only (`canRead: false`, `canWrite: false`, `canSearchWeb: false`, `canRunShell: false`).
153
- - **Safety Boundary**: Completely detached from the workspace filesystem and tool execution. Receives architectural queries via the `ask_mentor` tool and returns structured recommendations without polluting turn history.
154
- - **Model Tier**: Defaults to `agent.smartModel` (e.g. `gpt-5.5`).
42
+ For other providers, follow [provider setup](https://qduc.github.io/term2/providers/). OpenRouter and Grok are built in; add direct Anthropic, Gemini, and local endpoints through `/providers`. An API key alone does not register a custom provider. Hosted providers receive the conversation context and tool results used for your request; their billing and account limits apply.
155
43
 
156
- ### Librarian Subagent
157
- - **Purpose**: Long-term persistent memory management, documentation discovery, and indexing domain knowledge across sessions.
158
- - **Permissions**: Memory management (`canRead: false`, `canWrite: false`, `canSearchWeb: false`, `canRunShell: false`). Interacts with memory exclusively via specialized `memory_*` tools and `activate_skill`.
159
- - **Safety Boundary**: Operates strictly within persistent memory storage without general filesystem, shell, or web access.
160
- - **Model Tier**: Defaults to `agent.cheapModel`.
161
-
162
- ### Subagent Capability Tiers
163
- Subagent roles are mapped to four configurable model tiers in `settings.json`:
164
- - `agent.smartModel` / `agent.smartProvider` / `agent.smartReasoningEffort`: For deep reasoning and strategic advisory (used by Mentor).
165
- - `agent.balancedModel` / `agent.balancedProvider` / `agent.balancedReasoningEffort`: For implementation, editing, and execution (used by Worker).
166
- - `agent.cheapModel` / `agent.cheapProvider` / `agent.cheapReasoningEffort`: For high-throughput search and discovery (used by Explorer and Librarian).
167
- - `agent.choreModel` / `agent.choreProvider`: For narrow utility tasks such as AST patch self-healing and auto-approval evaluation.
168
-
169
- ### Background Subagent Management and Lifecycle
170
- - **Concurrent Execution**: Subagents can run synchronously in the foreground or asynchronously in the background.
171
- - **Task Manager (`Ctrl+G`)**: Press `Ctrl+G` to open the Background Task Manager to inspect live running subagents, view stream output, pause runs, or terminate hung jobs.
172
- - **Resource Budgets**: Each subagent run is bounded by an execution turn budget (`maxTurns`) to prevent infinite recursive loops.
173
-
174
- ### Subagent Check-In and Steering
175
- - **Periodic Check-In**: The `BackgroundCheckInScheduler` periodically wakes the launching agent with status summaries of background work without interrupting active user turns.
176
- - **Mid-Turn Steering**: Deliver real-time steering messages to running subagent tasks at clean request boundaries.
177
- - **Orchestrator Inquiries**: Subagents can query the parent orchestrator for clarifying decisions using the `ask_orchestrator` tool when encountering ambiguity.
178
-
179
- ---
180
-
181
- ## Safety, Sandboxing, and Auto-Approval
182
-
183
- ### Sandboxed Execution
184
- Shell commands execute inside an isolated execution boundary:
185
- - `standard` policy: Restricts file writes to the workspace and temporary directories while blocking reads of sensitive credential paths (`~/.ssh`, `~/.aws`, `~/.docker`, `~/.netrc`, `~/.kube`, etc.).
186
- - `strict` policy: Locks down file reading to the workspace and safe toolchains, blocking access to the user home directory and system roots (`/etc`, `/var`, `/root`).
187
- - Toggle sandbox enforcement anytime using `/sandbox`, or configure policies via `sandbox.readPolicy` in `/settings`.
188
-
189
- ### Shell Auto-Approval Modes (`/auto-approve`)
190
- - `off` (Default): Shell commands are not auto-approved.
191
- - `advisory`: Commands require confirmation, but include real-time LLM-generated safety and consequence explanations.
192
- - `auto`: Safe, read-only, and idempotent workspace operations execute automatically; potentially destructive commands (e.g. `rm -rf`, `git reset --hard`, `git push --force`) are strictly blocked for user confirmation.
193
- - `always`: Unattended shell execution mode. Disables sandbox boundaries; use only in a trusted environment.
194
-
195
- The `--auto-approve` CLI flag is separate: it applies only to non-interactive prompts and allows tool execution without interactive confirmation.
196
-
197
- ---
198
-
199
- ## Context Management and Compaction
200
-
201
- ### Local and Server-Side Compaction
202
- - **Provider-Neutral Compactor**: When conversation tokens exceed configured ratios or thresholds, term2 performs request-boundary context compaction.
203
- - **Cold-Prefix Preservation**: Architectural decisions, environment constraints, and critical requirements are summarized and retained verbatim.
204
- - **Hot-Tail Invariants**: Recent conversation turns and active tool ledger call/result pairs remain completely intact, preventing broken references.
205
- - **Manual Trigger**: Run `/compact` at any point to compress transcript history immediately.
206
- - **OpenAI Native Compaction**: Leverages server-side context management when supported by the provider endpoint.
207
-
208
- ---
209
-
210
- ## Conversation Resumption, Rewind, and Queuing
211
-
212
- ### Time-Travel Rewind (`/rewind`, `/undo`, `/retry`)
213
- - **Inspection Picker**: Running `/rewind` opens an interactive menu detailing exactly which turns, replies, and modified files will be affected before committing.
214
- - **Disposition Modes**:
215
- - `edit` (Default / `/undo`): Discards subsequent turns and places the selected user prompt back into the input editor for revision.
216
- - `resend` (`/retry`): Discards subsequent turns and immediately resends the selected prompt to the model.
217
- - **Tool Retry (`/retry-tool`)**: Retries only the most recent failed or timed-out tool call without losing conversation context.
218
-
219
- ### Session Persistence and Resumption
220
- - **Persistence Engine**: Sessions are auto-saved using append-only event streams.
221
- - **Resuming Sessions**:
222
- ```bash
223
- term2 --resume # Resume the most recent session
224
- term2 --resume <session-id> # Resume a specific session by UUID
225
- term2 --resume ls # List recent saved sessions with metadata
226
- ```
227
- - **Session Branching (`--fork`)**:
228
- ```bash
229
- term2 --resume <session-id> --fork
230
- ```
231
-
232
- ### Mid-Turn Injection and Prompt Queuing
233
- - **Input Queuing**: Press `Alt+Enter` or `Esc+Enter` to queue additional user instructions while a turn is actively generating.
234
- - **Queue Editing**: Edit or delete pending queued prompts before they are admitted at the next request boundary.
235
-
236
- ---
237
-
238
- ## Remote Development over SSH
239
-
240
- term2 connects directly to remote hosts over SSH, executing commands and modifying remote files within a remote working directory:
44
+ Open a project and select a model from the provider you authenticated:
241
45
 
242
46
  ```bash
243
- # Connect to remote server with working directory
244
- term2 --ssh user@hostname --remote-dir /path/to/project
245
-
246
- # Custom SSH port
247
- term2 --ssh user@hostname --remote-dir /path/to/project --ssh-port 2222
248
-
249
- # Lightweight remote administration without codebase indexing
250
- term2 --ssh user@hostname --lite
47
+ cd /path/to/your/project
48
+ term2 --model
251
49
  ```
252
50
 
253
- **Requirements and Behavior**:
254
- - Requires an SSH agent running locally (`ssh-agent`) with loaded keys (`ssh-add`), or configured identity keys in `~/.ssh/config`.
255
- - `--remote-dir` is required for full codebase sessions. In `--lite` mode, omitting `--remote-dir` defaults to the remote user's home directory.
256
- - Background command execution is restricted to local workspaces.
51
+ Ask it to explain the project, fix a bug, or implement a feature. Standard mode can apply valid local workspace edits without a prompt; shell commands require approval under the default interactive settings. Review the resulting diff before committing. Enter `/plan` for read-only exploration, then `/plan` again to return to Standard mode.
257
52
 
258
- ---
53
+ This README tracks `main`; npm releases may lag behind it. Check `term2 --version` and the [changelog](CHANGELOG.md) when following documentation for a newer feature.
259
54
 
260
- ## Non-Interactive and Scripting Mode
55
+ ## Useful commands
261
56
 
262
- Execute one-off queries and automation tasks directly from shell scripts:
57
+ | To… | Use… |
58
+ | --------------------------- | ------------------------------------------------------------- |
59
+ | Switch models | `/model` or `Ctrl+O` |
60
+ | Manage provider connections | `/providers` |
61
+ | Resume a conversation | `term2 --resume`; `term2 --resume ls` lists saved sessions |
62
+ | Try another approach | `term2 --resume <session-id> --fork` |
63
+ | Work over SSH | `term2 --ssh user@host --remote-dir /path/to/project` |
64
+ | Ask a one-off question | `term2 "Explain the difference between a merge and a rebase"` |
263
65
 
264
- ```bash
265
- # Standard non-interactive query (output prints to stdout)
266
- term2 "Summarize recent commits in this repository"
66
+ A command-line prompt runs non-interactively, with tool execution disabled by default. `--auto-approve` enables tools without interactive confirmation; use it only when you intend unattended execution. See [scripting](https://qduc.github.io/term2/using-term2/non-interactive/) and [SSH setup](https://qduc.github.io/term2/remote/ssh/).
267
67
 
268
- # Automated task execution with tool approvals enabled
269
- term2 --auto-approve "Fix syntax errors in source/cli.tsx and run typecheck"
68
+ ## Approvals and sandbox
270
69
 
271
- # Capture output in shell pipeline
272
- TODO_LIST=$(term2 "List all TODO markers in source/")
273
- ```
70
+ Interactive sessions default to shell auto-approval `off` and an enabled shell sandbox. You can change these settings, so the active configuration matters. The sandbox constrains shell commands; it does not cover providers, external MCP servers, or every tool.
274
71
 
275
- ---
276
-
277
- ## Reference Guide
278
-
279
- ### Slash Commands
280
-
281
- | Command | Arguments | Description |
282
- | :--- | :--- | :--- |
283
- | `/model` | `[model-name]` | Open model selection menu or switch model directly (`Ctrl+O`). |
284
- | `/effort` | `[effort-level]` | Configure reasoning effort (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`) (`Ctrl+T`). |
285
- | `/plan` | — | Toggle read-only Plan Mode (`Shift+Tab`). |
286
- | `/lite` | — | Toggle lightweight terminal mode. |
287
- | `/mentor` | — | Toggle collaborative Mentor Mode. |
288
- | `/orchestrator` | — | Toggle prompt-guided Orchestrator Mode. |
289
- | `/auto-approve` | `[off\|advisory\|auto\|always]` | Set shell command auto-approval level. |
290
- | `/sandbox` | — | Toggle shell sandbox isolation on or off. |
291
- | `/compact` | — | Manually trigger context compaction. |
292
- | `/providers` | — | Open interactive provider manager (list, add, edit, remove, switch accounts). |
293
- | `/mcp` | — | Show configured MCP servers and their connection state. |
294
- | `/skills` | `[skill-name]` | Activate a skill for the next request. |
295
- | `/rewind` | `[last\|<turn>] [edit\|resend]` | Rewind conversation history with interactive discard inspection. |
296
- | `/undo` | — | Alias for `/rewind edit` (places target turn back in input box). |
297
- | `/retry` | — | Alias for `/rewind resend` (immediately resends the last user turn). |
298
- | `/retry-tool` | — | Re-execute the last failed or timed-out tool call. |
299
- | `/copy` | `[N]` | Copy the latest assistant response (or $N$-th prior response) to clipboard. |
300
- | `/usage` | — | Display exact token counts, cost breakdown, and provider rate-limit metrics. |
301
- | `/resume` | `[conversation-id]` | Resume a saved conversation (browse with `/resume` or specify an ID). |
302
- | `/handoff` | — | Export current conversation context for handoff to another session or model. |
303
- | `/settings` | `[key] [value]` | View or modify runtime configuration settings. |
304
- | `/clear` | — | Clear current conversation history and start a fresh turn. |
305
- | `/quit` | — | Exit term2 session. |
306
-
307
- ### Keyboard Shortcuts
308
-
309
- | Shortcut | Context | Action |
310
- | :--- | :--- | :--- |
311
- | `Ctrl + O` | Input Box | Open interactive model selection menu. |
312
- | `Ctrl + T` | Input Box | Open reasoning effort selection menu. |
313
- | `Ctrl + G` | Global | Open Background Task Manager (inspect/pause/stop tasks). |
314
- | `Shift + Tab` | Global | Cycle Operating Modes. |
315
- | `!` prefix | Input Box | Execute the following command directly in the shell; the red `!` prompt remains active until the command completes. |
316
- | `Alt + Enter` / `Esc + Enter` | Input Box | Queue input while a turn is executing. |
317
- | `Ctrl + R` | Model Menu | Refresh provider model catalog from API. |
318
- | `Ctrl + D` | Settings Menu | Reset highlighted setting to its default value. |
319
- | `Escape` | Composer | First press shows the Escape hint; a second press clears typed text. With an empty composer during a turn, double Escape interrupts the turn. |
320
- | `y` / `n` | Docker host-control approval | Approve once / reject. Other tool approvals use the numbered choices shown in the prompt. |
321
- | `Ctrl + C` | Global | Force immediate graceful exit. |
322
-
323
- ---
324
-
325
- ## Configuration
326
-
327
- Settings are persisted across sessions in `settings.json`:
328
- - **macOS**: `~/Library/Logs/term2-nodejs/settings.json`
329
- - **Linux**: `~/.local/state/term2-nodejs/settings.json` *(or `$XDG_STATE_HOME/term2-nodejs/settings.json`)*
330
- - **Windows**: `%LOCALAPPDATA%\term2-nodejs\Log\settings.json`
331
-
332
- ### Configuration Example
333
-
334
- ```json
335
- {
336
- "agent": {
337
- "provider": "openai",
338
- "model": "gpt-5.4",
339
- "reasoningEffort": "medium",
340
- "smartModel": "gpt-5.5",
341
- "smartProvider": "openai",
342
- "balancedModel": "claude-sonnet-4.6",
343
- "balancedProvider": "openrouter",
344
- "cheapModel": "gpt-5.4-mini",
345
- "choreModel": "gpt-5.4-mini",
346
- "temperature": 0.7,
347
- "maxTurns": 100
348
- },
349
- "shell": {
350
- "autoApproveMode": "auto",
351
- "timeout": 120000,
352
- "maxParallelToolCalls": 3
353
- },
354
- "sandbox": {
355
- "readPolicy": "standard"
356
- },
357
- "webSearch": {
358
- "provider": "tavily"
359
- },
360
- "providers": [
361
- {
362
- "name": "Local Ollama",
363
- "type": "openai-compatible",
364
- "baseUrl": "http://127.0.0.1:11434/v1"
365
- },
366
- {
367
- "name": "Local llama.cpp",
368
- "type": "llama.cpp",
369
- "baseUrl": "http://127.0.0.1:8080/v1"
370
- }
371
- ]
372
- }
373
- ```
374
-
375
- ---
72
+ See [approvals](https://qduc.github.io/term2/safety/approvals/) and [sandbox boundaries](https://qduc.github.io/term2/safety/sandbox/) for the policies and their limits.
376
73
 
377
- ## Development and Testing
74
+ ## Develop from source
378
75
 
379
- To set up the development environment from source:
76
+ Use Node 24 and pnpm 11:
380
77
 
381
78
  ```bash
382
- # 1. Clone repository
383
79
  git clone https://github.com/qduc/term2.git
384
80
  cd term2
385
-
386
- # 2. Install dependencies (requires pnpm >= 11)
387
- pnpm install
388
-
389
- # 3. Start TypeScript compiler in watch mode
390
- pnpm dev
391
-
392
- # 4. Run test suites
393
- pnpm test # Run Vitest unit tests
394
- pnpm test:lane # Run deterministic fast-lane tests
395
- pnpm test:provider-black-box # Run provider black-box wire tests
396
- pnpm typecheck # Run strict type checking
397
- pnpm lint # Run ESLint and Prettier checks
398
-
399
- # 5. Build for distribution
81
+ pnpm install --frozen-lockfile
400
82
  pnpm build
83
+ pnpm start --help
401
84
  ```
402
85
 
403
- ---
86
+ Read [AGENTS.md](AGENTS.md) before changing code. Use focused tests for the affected area; integration and provider tests have separate commands in `package.json`.
404
87
 
405
- ## License
88
+ The documentation site lives in [`website/`](website/):
406
89
 
407
- This project is licensed under the [MIT License](LICENSE).
90
+ ```bash
91
+ pnpm --dir website install --frozen-lockfile
92
+ pnpm --dir website build
93
+ pnpm --dir website preview
94
+ ```
408
95
 
409
- ---
96
+ The separate [`web-client/`](web-client/) app connects to the private `term2 serve` gateway. See [gateway setup](https://qduc.github.io/term2/remote/web-gateway/).
410
97
 
411
- ## Acknowledgments
98
+ ## License
412
99
 
413
- term2 is built on open-source libraries:
414
- - [Ink](https://github.com/vadimdemedes/ink) — React for interactive command-line apps
415
- - [Vercel AI SDK](https://github.com/vercel/ai) — Multi-provider AI streaming primitives
416
- - [OpenAI Node SDK](https://github.com/openai/openai-node) — OpenAI API transport
417
- - [ssh2](https://github.com/mscdex/ssh2) — SSH2 client for remote server execution
418
- - [Zod](https://github.com/colinhacks/zod) — TypeScript-first schema validation
100
+ [MIT](LICENSE).
package/dist/agent.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { BackgroundShellRegistry } from './services/shell/background-shell-
4
4
  import type { BackgroundShellOutputBundle } from './services/shell/background-shell-watches.js';
5
5
  import { type ForegroundRunSubagentParams } from './tools/agent/run-subagent.js';
6
6
  import { type ConfigureTaskCheckInParams, type ConfigureTaskCheckInResult } from './tools/agent/configure-task-check-in.js';
7
- import type { ToolRegistry } from './tools/types.js';
7
+ import type { RequestSnapshot, ToolRegistry } from './tools/types.js';
8
8
  import type { NestedSubagentResult, SubagentResult, SubagentRunHandle, SubagentRunStatus } from './services/subagents/types.js';
9
9
  import type { ResolvedSubagentLaunch } from './lib/subagent-bridge.js';
10
10
  import type { CancelRunParams, GetSubagentResultParams, GetSubagentStatusParams, RunSubagentAsyncParams, SendMessageParams, SendMessageAcknowledgement, CancelRunAcknowledgement } from './tools/agent/run-subagent-async.js';
@@ -25,6 +25,7 @@ export interface AgentDefinition {
25
25
  name: string;
26
26
  instructions: string;
27
27
  resolveInstructionsForRequest?: () => string;
28
+ resolveRequestSnapshot?: () => RequestSnapshot;
28
29
  tools: ToolRegistry;
29
30
  model: string;
30
31
  /** Enable pinned global memory context only for profiles exposing root memory context. */
@@ -1 +1 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/agent.js CHANGED
@@ -23,6 +23,7 @@ import { ProfileResolutionError, resolveActiveProfile } from './services/profile
23
23
  import { shouldPreferPatchEditingModel } from './lib/tool-selection-policy.js';
24
24
  import { createActivateSkillToolDefinition } from './tools/agent/activate-skill.js';
25
25
  import { createProposeGoalToolDefinition } from './tools/agent/propose-goal.js';
26
+ import { createGoalCheckToolDefinition } from './tools/agent/goal-check.js';
26
27
  import { createRunAgentWorkflowToolDefinition } from './tools/run-agent-workflow.js';
27
28
  import { createWorktreeToolDefinitions } from './tools/system/worktree.js';
28
29
  import { createRunCodeToolDefinition } from './tools/system/run-code/index.js';
@@ -330,6 +331,10 @@ export const getAgentDefinition = (deps, model) => {
330
331
  hasPriorProposal: proposeGoal.hasPriorProposal,
331
332
  }));
332
333
  }
334
+ // The stop self-check is root-only (only the root receives `getGoal`) and is
335
+ // available in every mode: the stop guard requires it whenever a goal is active.
336
+ if (deps.getGoal)
337
+ tools.push(createGoalCheckToolDefinition({ getGoal: deps.getGoal }));
333
338
  if (hasCapability('user-interaction') && getAskUserAnswer && allowAskUser) {
334
339
  const askUserTool = createAskUserToolDefinition(getAskUserAnswer);
335
340
  if (askUserTool.name !== TOOL_NAME_ASK_USER) {
@@ -510,7 +515,12 @@ export const getAgentDefinition = (deps, model) => {
510
515
  memoryContextEnabled: hasCapability('memory') && memoryContextEnabled && memoryCapability.access !== 'none',
511
516
  instructions,
512
517
  ...(deps.getGoal
513
- ? { resolveInstructionsForRequest: () => `${instructions}${renderDurableGoalContext(deps.getGoal?.())}` }
518
+ ? {
519
+ resolveInstructionsForRequest: () => `${instructions}${renderDurableGoalContext(deps.getGoal?.())}`,
520
+ // Read at the same request boundary as the rendered goal above, so
521
+ // goal_check records the goal the model judged, not a later one.
522
+ resolveRequestSnapshot: () => ({ goal: deps.getGoal?.() }),
523
+ }
514
524
  : {}),
515
525
  tools,
516
526
  model: resolvedModel,