@qduc/term2 0.31.1 → 0.32.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.
- package/README.md +52 -370
- package/dist/agent.d.ts +2 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +11 -1
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts +3 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +44 -4
- package/dist/app.js.map +1 -1
- package/dist/build-info.json +2 -2
- package/dist/cli.js +13 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/goal-command.d.ts.map +1 -1
- package/dist/commands/goal-command.js +9 -8
- package/dist/commands/goal-command.js.map +1 -1
- package/dist/commands/retry-failed-turn-command.d.ts.map +1 -1
- package/dist/commands/retry-failed-turn-command.js +3 -4
- package/dist/commands/retry-failed-turn-command.js.map +1 -1
- package/dist/components/InputBox.js +4 -6
- package/dist/components/InputBox.js.map +1 -1
- package/dist/components/layout/BottomArea.d.ts.map +1 -1
- package/dist/components/layout/BottomArea.js +13 -11
- package/dist/components/layout/BottomArea.js.map +1 -1
- package/dist/components/message/MessageList.d.ts +3 -1
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +5 -2
- package/dist/components/message/MessageList.js.map +1 -1
- package/dist/components/message/SessionBoundary.d.ts +11 -0
- package/dist/components/message/SessionBoundary.d.ts.map +1 -0
- package/dist/components/message/SessionBoundary.js +22 -0
- package/dist/components/message/SessionBoundary.js.map +1 -0
- package/dist/contracts/provider-input.d.ts +10 -0
- package/dist/contracts/provider-input.d.ts.map +1 -1
- package/dist/contracts/provider-input.js.map +1 -1
- package/dist/contracts/run-termination.d.ts +3 -1
- package/dist/contracts/run-termination.d.ts.map +1 -1
- package/dist/hooks/settings-completion-config.d.ts.map +1 -1
- package/dist/hooks/settings-completion-config.js +1 -0
- package/dist/hooks/settings-completion-config.js.map +1 -1
- package/dist/lib/agent-chat-service.d.ts +6 -0
- package/dist/lib/agent-chat-service.d.ts.map +1 -1
- package/dist/lib/agent-chat-service.js +27 -3
- package/dist/lib/agent-chat-service.js.map +1 -1
- package/dist/lib/agent-client.d.ts +6 -0
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +80 -22
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/lib/agent-configuration.d.ts +2 -0
- package/dist/lib/agent-configuration.d.ts.map +1 -1
- package/dist/lib/agent-configuration.js +5 -0
- package/dist/lib/agent-configuration.js.map +1 -1
- package/dist/lib/agent-factory.d.ts.map +1 -1
- package/dist/lib/agent-factory.js +15 -4
- package/dist/lib/agent-factory.js.map +1 -1
- package/dist/non-interactive.d.ts +5 -0
- package/dist/non-interactive.d.ts.map +1 -1
- package/dist/non-interactive.js +63 -6
- package/dist/non-interactive.js.map +1 -1
- package/dist/prompts/durable-goal-context.d.ts.map +1 -1
- package/dist/prompts/durable-goal-context.js +12 -2
- package/dist/prompts/durable-goal-context.js.map +1 -1
- package/dist/prompts/durable-goal-context.test.ts +11 -0
- package/dist/prompts/durable-goal-context.ts +13 -2
- package/dist/providers/ai-sdk-openrouter.provider.js +3 -2
- package/dist/providers/ai-sdk-openrouter.provider.js.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.d.ts.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.js +12 -2
- package/dist/providers/ai-sdk-streamed-model.js.map +1 -1
- package/dist/providers/codex-responses-model.d.ts.map +1 -1
- package/dist/providers/codex-responses-model.js +35 -16
- package/dist/providers/codex-responses-model.js.map +1 -1
- package/dist/providers/openai-chat-completions-model.d.ts.map +1 -1
- package/dist/providers/openai-chat-completions-model.js +11 -3
- package/dist/providers/openai-chat-completions-model.js.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.d.ts +34 -1
- package/dist/services/agent-runtime/application-run-loop.d.ts.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.js +174 -33
- package/dist/services/agent-runtime/application-run-loop.js.map +1 -1
- package/dist/services/agent-runtime/context-compaction/index.d.ts.map +1 -1
- package/dist/services/agent-runtime/context-compaction/index.js +65 -16
- package/dist/services/agent-runtime/context-compaction/index.js.map +1 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts +7 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.d.ts.map +1 -1
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.js +115 -20
- package/dist/services/agent-runtime/context-compaction/local-context-compactor.js.map +1 -1
- package/dist/services/agent-runtime/model-context-policy.d.ts +21 -0
- package/dist/services/agent-runtime/model-context-policy.d.ts.map +1 -0
- package/dist/services/agent-runtime/model-context-policy.js +46 -0
- package/dist/services/agent-runtime/model-context-policy.js.map +1 -0
- package/dist/services/agent-runtime/request-input-limit.d.ts +31 -0
- package/dist/services/agent-runtime/request-input-limit.d.ts.map +1 -0
- package/dist/services/agent-runtime/request-input-limit.js +86 -0
- package/dist/services/agent-runtime/request-input-limit.js.map +1 -0
- package/dist/services/agent-runtime/run-budget.d.ts +3 -5
- package/dist/services/agent-runtime/run-budget.d.ts.map +1 -1
- package/dist/services/agent-runtime/run-budget.js.map +1 -1
- package/dist/services/agent-runtime/tool-call-execution.d.ts +24 -2
- package/dist/services/agent-runtime/tool-call-execution.d.ts.map +1 -1
- package/dist/services/agent-runtime/tool-call-execution.js +36 -6
- package/dist/services/agent-runtime/tool-call-execution.js.map +1 -1
- package/dist/services/agent-runtime/tool-invocation-context.d.ts +24 -12
- package/dist/services/agent-runtime/tool-invocation-context.d.ts.map +1 -1
- package/dist/services/agent-runtime/tool-invocation-context.js +38 -27
- package/dist/services/agent-runtime/tool-invocation-context.js.map +1 -1
- package/dist/services/approval/approval-replay.d.ts +15 -24
- package/dist/services/approval/approval-replay.d.ts.map +1 -1
- package/dist/services/approval/approval-replay.js +12 -30
- package/dist/services/approval/approval-replay.js.map +1 -1
- package/dist/services/approval/non-interactive-approval-policy.d.ts.map +1 -1
- package/dist/services/approval/non-interactive-approval-policy.js +11 -0
- package/dist/services/approval/non-interactive-approval-policy.js.map +1 -1
- package/dist/services/approval/tool-approval-batch-coordinator.d.ts.map +1 -1
- package/dist/services/approval/tool-approval-batch-coordinator.js +0 -5
- package/dist/services/approval/tool-approval-batch-coordinator.js.map +1 -1
- package/dist/services/conversation/conversation-checkpoint-provenance.d.ts.map +1 -1
- package/dist/services/conversation/conversation-checkpoint-provenance.js +10 -2
- package/dist/services/conversation/conversation-checkpoint-provenance.js.map +1 -1
- package/dist/services/conversation/conversation-events.d.ts +2 -0
- package/dist/services/conversation/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation/conversation-events.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.js +14 -2
- package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
- package/dist/services/conversation/conversation-replay.d.ts.map +1 -1
- package/dist/services/conversation/conversation-replay.js +78 -3
- package/dist/services/conversation/conversation-replay.js.map +1 -1
- package/dist/services/conversation/conversation-service.d.ts +2 -2
- package/dist/services/conversation/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation/conversation-service.js +5 -1
- package/dist/services/conversation/conversation-service.js.map +1 -1
- package/dist/services/conversation/conversation-state-projector.d.ts +1 -0
- package/dist/services/conversation/conversation-state-projector.d.ts.map +1 -1
- package/dist/services/conversation/conversation-state-projector.js +5 -1
- package/dist/services/conversation/conversation-state-projector.js.map +1 -1
- package/dist/services/conversation/durable-goal-stop-check.d.ts +141 -0
- package/dist/services/conversation/durable-goal-stop-check.d.ts.map +1 -0
- package/dist/services/conversation/durable-goal-stop-check.js +351 -0
- package/dist/services/conversation/durable-goal-stop-check.js.map +1 -0
- package/dist/services/conversation/durable-goal.d.ts +16 -1
- package/dist/services/conversation/durable-goal.d.ts.map +1 -1
- package/dist/services/conversation/durable-goal.js +8 -0
- package/dist/services/conversation/durable-goal.js.map +1 -1
- package/dist/services/conversation/local-checkpoint-projection.d.ts.map +1 -1
- package/dist/services/conversation/local-checkpoint-projection.js +12 -1
- package/dist/services/conversation/local-checkpoint-projection.js.map +1 -1
- package/dist/services/conversation/session-browser.d.ts +2 -0
- package/dist/services/conversation/session-browser.d.ts.map +1 -1
- package/dist/services/conversation/session-browser.js +23 -8
- package/dist/services/conversation/session-browser.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts +3 -0
- package/dist/services/conversation/session-index/session-index-worker-client.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker-client.js +6 -1
- package/dist/services/conversation/session-index/session-index-worker-client.js.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker.d.ts +16 -1
- package/dist/services/conversation/session-index/session-index-worker.d.ts.map +1 -1
- package/dist/services/conversation/session-index/session-index-worker.js +16 -0
- package/dist/services/conversation/session-index/session-index-worker.js.map +1 -1
- package/dist/services/conversation-agent-client.d.ts +1 -0
- package/dist/services/conversation-agent-client.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.d.ts +7 -0
- package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.js.map +1 -1
- package/dist/services/retry/retry-classifier.d.ts.map +1 -1
- package/dist/services/retry/retry-classifier.js +2 -1
- package/dist/services/retry/retry-classifier.js.map +1 -1
- package/dist/services/retry/retry-error-classification.d.ts.map +1 -1
- package/dist/services/retry/retry-error-classification.js +1 -0
- package/dist/services/retry/retry-error-classification.js.map +1 -1
- package/dist/services/service-interfaces.d.ts +2 -0
- package/dist/services/service-interfaces.d.ts.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.js +6 -0
- package/dist/services/session/initial-turn-recovery-handler.js.map +1 -1
- package/dist/services/session/session-composition.d.ts.map +1 -1
- package/dist/services/session/session-composition.js +7 -5
- package/dist/services/session/session-composition.js.map +1 -1
- package/dist/services/session/session-manager.d.ts +2 -0
- package/dist/services/session/session-manager.d.ts.map +1 -1
- package/dist/services/session/session-manager.js +10 -0
- package/dist/services/session/session-manager.js.map +1 -1
- package/dist/services/session/session-tool-tracker.d.ts +1 -0
- package/dist/services/session/session-tool-tracker.d.ts.map +1 -1
- package/dist/services/session/session-tool-tracker.js +8 -0
- package/dist/services/session/session-tool-tracker.js.map +1 -1
- package/dist/services/session/terminal-result-collector.d.ts.map +1 -1
- package/dist/services/session/terminal-result-collector.js +3 -0
- package/dist/services/session/terminal-result-collector.js.map +1 -1
- package/dist/services/session/turn-workflow.d.ts.map +1 -1
- package/dist/services/session/turn-workflow.js +3 -0
- package/dist/services/session/turn-workflow.js.map +1 -1
- package/dist/services/settings/settings-env.d.ts.map +1 -1
- package/dist/services/settings/settings-env.js +6 -0
- package/dist/services/settings/settings-env.js.map +1 -1
- package/dist/services/settings/settings-persistence.d.ts +2 -1
- package/dist/services/settings/settings-persistence.d.ts.map +1 -1
- package/dist/services/settings/settings-persistence.js +1 -1
- package/dist/services/settings/settings-persistence.js.map +1 -1
- package/dist/services/settings/settings-schema.d.ts +7 -1
- package/dist/services/settings/settings-schema.d.ts.map +1 -1
- package/dist/services/settings/settings-schema.js +17 -6
- package/dist/services/settings/settings-schema.js.map +1 -1
- package/dist/services/settings/settings-service.d.ts +3 -0
- package/dist/services/settings/settings-service.d.ts.map +1 -1
- package/dist/services/settings/settings-service.js +74 -31
- package/dist/services/settings/settings-service.js.map +1 -1
- package/dist/services/settings/settings-sources.d.ts +1 -0
- package/dist/services/settings/settings-sources.d.ts.map +1 -1
- package/dist/services/settings/settings-sources.js +1 -0
- package/dist/services/settings/settings-sources.js.map +1 -1
- package/dist/services/settings/settings-ui-metadata.js +1 -1
- package/dist/services/settings/settings-ui-metadata.js.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js +1 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js.map +1 -1
- package/dist/services/subagents/execution-runner.d.ts.map +1 -1
- package/dist/services/subagents/execution-runner.js +16 -3
- package/dist/services/subagents/execution-runner.js.map +1 -1
- package/dist/services/subagents/nested-runner.d.ts.map +1 -1
- package/dist/services/subagents/nested-runner.js +3 -2
- package/dist/services/subagents/nested-runner.js.map +1 -1
- package/dist/services/tool-execution-ledger.d.ts +22 -0
- package/dist/services/tool-execution-ledger.d.ts.map +1 -1
- package/dist/services/tool-execution-ledger.js +40 -3
- package/dist/services/tool-execution-ledger.js.map +1 -1
- package/dist/services/workflow-evolution/cli.d.ts +2 -0
- package/dist/services/workflow-evolution/cli.d.ts.map +1 -0
- package/dist/services/workflow-evolution/cli.js +26 -0
- package/dist/services/workflow-evolution/cli.js.map +1 -0
- package/dist/services/workflow-evolution/demo.d.ts +18 -0
- package/dist/services/workflow-evolution/demo.d.ts.map +1 -0
- package/dist/services/workflow-evolution/demo.js +177 -0
- package/dist/services/workflow-evolution/demo.js.map +1 -0
- package/dist/services/workflow-evolution/experiment.d.ts +304 -0
- package/dist/services/workflow-evolution/experiment.d.ts.map +1 -0
- package/dist/services/workflow-evolution/experiment.js +251 -0
- package/dist/services/workflow-evolution/experiment.js.map +1 -0
- package/dist/services/workflow-evolution/ledger.d.ts +5 -0
- package/dist/services/workflow-evolution/ledger.d.ts.map +1 -0
- package/dist/services/workflow-evolution/ledger.js +57 -0
- package/dist/services/workflow-evolution/ledger.js.map +1 -0
- package/dist/skins/rail/status.d.ts.map +1 -1
- package/dist/skins/rail/status.js +21 -11
- package/dist/skins/rail/status.js.map +1 -1
- package/dist/tools/agent/goal-check.d.ts +23 -0
- package/dist/tools/agent/goal-check.d.ts.map +1 -0
- package/dist/tools/agent/goal-check.js +79 -0
- package/dist/tools/agent/goal-check.js.map +1 -0
- package/dist/tools/system/run-code/run-code-runtime.d.ts.map +1 -1
- package/dist/tools/system/run-code/run-code-runtime.js +3 -1
- package/dist/tools/system/run-code/run-code-runtime.js.map +1 -1
- package/dist/tools/tool-names.d.ts +1 -0
- package/dist/tools/tool-names.d.ts.map +1 -1
- package/dist/tools/tool-names.js +1 -0
- package/dist/tools/tool-names.js.map +1 -1
- package/dist/tools/types.d.ts +21 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +7 -0
- package/dist/tools/types.js.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.js +4 -0
- package/dist/utils/conversation/conversation-event-handler.js.map +1 -1
- package/dist/utils/output/text-snippet.js +25 -33
- package/dist/utils/output/text-snippet.js.map +1 -1
- package/dist/utils/value-suggestions.d.ts.map +1 -1
- package/dist/utils/value-suggestions.js +1 -0
- package/dist/utils/value-suggestions.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,418 +1,100 @@
|
|
|
1
1
|
# term2
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@qduc/term2)
|
|
4
|
-
[](
|
|
5
|
-
[](https://nodejs.org)
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
4
|
+
[](LICENSE)
|
|
7
5
|
|
|
8
|
-
term2 is an open-source
|
|
6
|
+
**term2 is an open-source AI assistant for coding and terminal work.**
|
|
9
7
|
|
|
10
|
-
|
|
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
|
+

|
|
13
11
|
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
21
|
+
## Get started
|
|
29
22
|
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
77
|
-
|
|
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
|
-
#
|
|
113
|
-
|
|
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
|
-
|
|
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
|
-
|
|
244
|
-
term2 --
|
|
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
|
-
|
|
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
|
-
##
|
|
55
|
+
## Useful commands
|
|
261
56
|
|
|
262
|
-
|
|
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
|
-
|
|
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
|
-
|
|
269
|
-
term2 --auto-approve "Fix syntax errors in source/cli.tsx and run typecheck"
|
|
68
|
+
## Approvals and sandbox
|
|
270
69
|
|
|
271
|
-
|
|
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
|
-
##
|
|
74
|
+
## Develop from source
|
|
378
75
|
|
|
379
|
-
|
|
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
|
-
|
|
88
|
+
The documentation site lives in [`website/`](website/):
|
|
406
89
|
|
|
407
|
-
|
|
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
|
-
##
|
|
98
|
+
## License
|
|
412
99
|
|
|
413
|
-
|
|
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. */
|
package/dist/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../source/agent.ts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EAAE,EAAE,MAAM,CAAA;KAAE,EAClD,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KAChD,IAAI,CAAC;IACV,gFAAgF;IAChF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,2BAA2B,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK,MAAM,CAAC;IAC7D,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,UACO,MAAM,KACb,eA4eF,CAAC"}
|
package/dist/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
|
-
? {
|
|
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,
|