mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 17:02:18 +00:00
fix: fix checking if provider is authenticated
This commit is contained in:
parent
b76d83577a
commit
80ce95f886
13 changed files with 801 additions and 6 deletions
|
|
@ -415,6 +415,31 @@ if let Some(model) = options.model.as_deref() {
|
|||
3. **Wait for Amp API** — Amp may add model/mode discovery in a future release
|
||||
4. **Scrape ampcode.com** — Check if the web UI exposes available modes/models
|
||||
|
||||
## Command Execution & Process Management
|
||||
|
||||
### Agent Tool Execution
|
||||
|
||||
Amp executes commands via the `Bash` tool, similar to Claude Code. Synchronous execution, blocks the agent turn. Permission rules can pre-authorize specific commands:
|
||||
|
||||
```typescript
|
||||
{ tool: "Bash", matches: { command: "git *" }, action: "allow" }
|
||||
```
|
||||
|
||||
### No User-Initiated Command Injection
|
||||
|
||||
Amp does not expose any mechanism for external clients to inject command results into the agent's context. No `!` prefix equivalent, no command injection API.
|
||||
|
||||
### Comparison
|
||||
|
||||
| Capability | Supported? | Notes |
|
||||
|-----------|-----------|-------|
|
||||
| Agent runs commands | Yes (`Bash` tool) | Synchronous, blocks agent turn |
|
||||
| User runs commands → agent sees output | No | |
|
||||
| External API for command injection | No | |
|
||||
| Command source tracking | No | |
|
||||
| Background process management | No | Shell `&` only |
|
||||
| PTY / interactive terminal | No | |
|
||||
|
||||
## Notes
|
||||
|
||||
- Amp is similar to Claude Code (same streaming format)
|
||||
|
|
|
|||
|
|
@ -279,6 +279,44 @@ x-api-key: <ANTHROPIC_API_KEY>
|
|||
anthropic-version: 2023-06-01
|
||||
```
|
||||
|
||||
## Command Execution & Process Management
|
||||
|
||||
### Agent Tool Execution
|
||||
|
||||
The agent executes commands via the `Bash` tool. This is synchronous - the agent blocks until the command exits. Tool schema:
|
||||
|
||||
```json
|
||||
{
|
||||
"command": "string",
|
||||
"timeout": "number",
|
||||
"workingDirectory": "string"
|
||||
}
|
||||
```
|
||||
|
||||
There is no background process support. If the agent needs a long-running process (e.g., dev server), it uses shell backgrounding (`&`) within a single `Bash` tool call.
|
||||
|
||||
### User-Initiated Command Execution (`!` prefix)
|
||||
|
||||
Claude Code's TUI supports `!command` syntax where the user types `!npm test` to run a command directly. The output is injected into the conversation as a user message so the agent can see it on the next turn.
|
||||
|
||||
**This is a client-side TUI feature only.** It is not exposed in the API schema or streaming protocol. The CLI runs the command locally and stuffs the output into the next user message. There is no protocol-level concept of "user ran a command" vs "agent ran a command."
|
||||
|
||||
### No External Command Injection API
|
||||
|
||||
External clients (SDKs, frontends) cannot programmatically inject command results into Claude's conversation context. The only way to provide command output to the agent is:
|
||||
- Include it in the user prompt text
|
||||
- Use the `!` prefix in the interactive TUI
|
||||
|
||||
### Comparison
|
||||
|
||||
| Capability | Supported? | Notes |
|
||||
|-----------|-----------|-------|
|
||||
| Agent runs commands | Yes (`Bash` tool) | Synchronous, blocks agent turn |
|
||||
| User runs commands → agent sees output | Yes (`!cmd` in TUI) | Client-side only, not in protocol |
|
||||
| External API for command injection | No | |
|
||||
| Background process management | No | Shell `&` only |
|
||||
| PTY / interactive terminal | No | |
|
||||
|
||||
## Notes
|
||||
|
||||
- Claude CLI manages its own OAuth refresh internally
|
||||
|
|
|
|||
|
|
@ -347,6 +347,68 @@ Requires a running Codex app-server process. Send the JSON-RPC request to the ap
|
|||
- Requires an active app-server process (cannot query models without starting one)
|
||||
- No standalone CLI command like `codex models`
|
||||
|
||||
## Command Execution & Process Management
|
||||
|
||||
### Agent Tool Execution
|
||||
|
||||
Codex executes commands via `LocalShellAction`. The agent proposes a command, and external clients approve/deny via JSON-RPC (`item/commandExecution/requestApproval`).
|
||||
|
||||
### Command Source Tracking (`ExecCommandSource`)
|
||||
|
||||
Codex is the only agent that explicitly tracks **who initiated a command** at the protocol level:
|
||||
|
||||
```json
|
||||
{
|
||||
"ExecCommandSource": {
|
||||
"enum": ["agent", "user_shell", "unified_exec_startup", "unified_exec_interaction"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Source | Meaning |
|
||||
|--------|---------|
|
||||
| `agent` | Agent decided to run this command via tool call |
|
||||
| `user_shell` | User ran a command in a shell (equivalent to Claude Code's `!` prefix) |
|
||||
| `unified_exec_startup` | Startup script ran this command |
|
||||
| `unified_exec_interaction` | Interactive execution |
|
||||
|
||||
This means user-initiated shell commands are **first-class protocol events** in Codex, not a client-side hack like Claude Code's `!` prefix.
|
||||
|
||||
### Command Execution Events
|
||||
|
||||
Codex emits structured events for command execution:
|
||||
|
||||
- `exec_command_begin` - Command started (includes `source`, `command`, `cwd`, `turn_id`)
|
||||
- `exec_command_output_delta` - Streaming output chunk (includes `stream: stdout|stderr`)
|
||||
- `exec_command_end` - Command completed (includes `exit_code`, `source`)
|
||||
|
||||
### Parsed Command Analysis (`CommandAction`)
|
||||
|
||||
Codex provides semantic analysis of what a command does:
|
||||
|
||||
```json
|
||||
{
|
||||
"commandActions": [
|
||||
{ "type": "read", "path": "/src/main.ts" },
|
||||
{ "type": "write", "path": "/src/utils.ts" },
|
||||
{ "type": "install", "package": "lodash" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Action types: `read`, `write`, `listFiles`, `search`, `install`, `remove`, `other`.
|
||||
|
||||
### Comparison
|
||||
|
||||
| Capability | Supported? | Notes |
|
||||
|-----------|-----------|-------|
|
||||
| Agent runs commands | Yes (`LocalShellAction`) | With approval workflow |
|
||||
| User runs commands → agent sees output | Yes (`user_shell` source) | First-class protocol event |
|
||||
| External API for command injection | Yes (JSON-RPC approval) | Can approve/deny before execution |
|
||||
| Command source tracking | Yes (`ExecCommandSource` enum) | Distinguishes agent vs user vs startup |
|
||||
| Background process management | No | |
|
||||
| PTY / interactive terminal | No | |
|
||||
|
||||
## Notes
|
||||
|
||||
- SDK is dynamically imported to reduce bundle size
|
||||
|
|
|
|||
|
|
@ -585,6 +585,60 @@ const response = await client.provider.list();
|
|||
|
||||
When an OpenCode server is running, call `GET /provider` on its HTTP port. Returns full model metadata including capabilities, costs, context limits, and modalities.
|
||||
|
||||
## Command Execution & Process Management
|
||||
|
||||
### Agent Tool Execution
|
||||
|
||||
The agent executes commands via internal tools (not exposed in the HTTP API). The agent's tool calls are synchronous within its turn. Tool parts have states: `pending`, `running`, `completed`, `error`.
|
||||
|
||||
### PTY System (`/pty/*`) - User-Facing Terminals
|
||||
|
||||
Separate from the agent's command execution. PTYs are server-scoped interactive terminals for the user:
|
||||
|
||||
- `POST /pty` - Create PTY (command, args, cwd, title, env)
|
||||
- `GET /pty` - List all PTYs
|
||||
- `GET /pty/{ptyID}` - Get PTY info
|
||||
- `PUT /pty/{ptyID}` - Update PTY (title, resize via `size: {rows, cols}`)
|
||||
- `DELETE /pty/{ptyID}` - Kill and remove PTY
|
||||
- `GET /pty/{ptyID}/connect` - WebSocket for bidirectional I/O
|
||||
|
||||
PTY events (globally broadcast via SSE): `pty.created`, `pty.updated`, `pty.exited`, `pty.deleted`.
|
||||
|
||||
The agent does NOT use the PTY system. PTYs are for the user's interactive terminal panel, independent of any AI session.
|
||||
|
||||
### Session Commands (`/session/{id}/command`, `/session/{id}/shell`) - Context Injection
|
||||
|
||||
External clients can inject command results into an AI session's conversation context:
|
||||
|
||||
- `POST /session/{sessionID}/command` - Executes a command and records the result as an `AssistantMessage` in the session. Required fields: `command`, `arguments`. The output becomes part of the AI's context for subsequent turns.
|
||||
- `POST /session/{sessionID}/shell` - Similar but wraps in `sh -c`. Required fields: `command`, `agent`.
|
||||
- `GET /command` - Lists available command definitions (metadata, not execution).
|
||||
|
||||
Session commands emit `command.executed` events with `sessionID` + `messageID`.
|
||||
|
||||
**Key distinction**: These endpoints execute commands directly (not via the AI), then inject the output into the session as if the AI produced it. The AI doesn't actively run the command - it just finds the output in its conversation history on the next turn.
|
||||
|
||||
### Three Separate Execution Mechanisms
|
||||
|
||||
| Mechanism | Who uses it | Scoped to | AI sees output? |
|
||||
|-----------|-------------|-----------|----------------|
|
||||
| Agent tools (internal) | AI agent | Session turn | Yes (immediate) |
|
||||
| PTY (`/pty/*`) | User/frontend | Server (global) | No |
|
||||
| Session commands (`/session/{id}/*`) | Frontend/SDK client | Session | Yes (next turn) |
|
||||
|
||||
The agent has no tool to interact with PTYs and cannot access the session command endpoints. When the agent needs to run a background process, it uses its internal bash-equivalent tool with shell backgrounding (`&`).
|
||||
|
||||
### Comparison
|
||||
|
||||
| Capability | Supported? | Notes |
|
||||
|-----------|-----------|-------|
|
||||
| Agent runs commands | Yes (internal tools) | Synchronous, blocks agent turn |
|
||||
| User runs commands → agent sees output | Yes (`/session/{id}/command`) | HTTP API, first-class |
|
||||
| External API for command injection | Yes | Session-scoped endpoints |
|
||||
| Command source tracking | Implicit | Endpoint implies source (no enum) |
|
||||
| Background process management | No | Shell `&` only for agent |
|
||||
| PTY / interactive terminal | Yes (`/pty/*`) | Server-scoped, WebSocket I/O |
|
||||
|
||||
## Notes
|
||||
|
||||
- OpenCode is the most feature-rich runtime (streaming, questions, permissions)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue