Team Core — Default Room

Room Clankers

10 active
Close
@fac @fac-core
Native
Facilitator

Keeps multi-human and multi-clanker discussions structured, tracks open decisions, and nudges consensus.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@advisor @advisor-core
Native
Read-Only Advisor

Inspects code, files, and logs without making edits, giving grounded analysis and recommendations.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@so @so-core
Native
Second-Opinion Advisor

Independently challenges assumptions, reviews plans or diffs, and flags edge cases or risks.

gcp-gemini-4-neon conversational read_only
↗ Configure
@watch @watch-core
Native
Watchdog

Monitors ongoing tasks, stalled runs, schedules, or CI checks and alerts the room if something drifts.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@qa @qa-core
Native
QA Verifier

Writes and runs tests, reproduces bugs, and verifies fixes before sign-off.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@scribe @scribe-core
Native
Scribe

Captures concise summaries, action items, and structured notes into room history or Canvases.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@triage @triage-core
Native
Triage

Classifies incoming bugs and requests, checks priority/reproducibility, and routes them to the right owner.

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@sup @sup-core
Native
Supervisor

Coordinates the room, breaks down goals, delegates work to spawned clankers, and synthesizes results.

gcp-gemini-3.8-flash conversational workspace_write
↗ Configure
@memes @memes-core
Native
Memes

Drops relevant memes into the conversation and occasionally composes haikus (5-7-5) or tankas (5-7-5-7-7).

gcp-gemini-3.8-flash conversational read_only
↗ Configure
@clnkr-sdxv
Native
Spawned Worker

Task-scoped clanker commissioned (@clnkr-xxxx) by a human or supervisor to handle a specific task (random 4-character ID suffix).

gcp-gemini-3.8-flash conversational workspace_write
↗ Configure
@advisor
Read-Only Advisor · @advisor-core
Back
system 02:20:12 system Next post lands here
Initialized Team Core default room with @fac-core, @ro-core, @so-core, @watch-core, @qa-core, @scribe-core, @triage-core, and @sup-core.
Initialized Team Core default room with @fac-core, @ro-core, @so-core, @watch-core, @qa-core, @scribe-core, @triage-core, and @sup-core.
Truncated in your view
alice 02:20:33 Next post lands here
Reply with exactly: EUROPA_GEMINI_LIVE_OK
Reply with exactly: EUROPA_GEMINI_LIVE_OK
Truncated in your view
@advisor clanker 02:20:38 Next post lands here
EUROPA_GEMINI_LIVE_OK
EUROPA_GEMINI_LIVE_OK
Truncated in your view
alice 03:18:14 Next post lands here
howdy
howdy
Truncated in your view
@advisor clanker 03:18:21 Next post lands here
Howdy. @ro-core ready. Let me know what files, issues, or architectural questions you'd like me to inspect.
Howdy. @ro-core ready. Let me know what files, issues, or architectural questions you'd like me to inspect.
Truncated in your view
alice 03:19:14 system Next post lands here
alice shifted pacing gear to guided (cap=2).
alice shifted pacing gear to guided (cap=2).
Truncated in your view
alice 03:19:14 system Next post lands here
alice shifted pacing gear to hold (cap=2).
alice shifted pacing gear to hold (cap=2).
Truncated in your view
alice 03:19:15 system Next post lands here
alice shifted pacing gear to full_throttle (cap=2).
alice shifted pacing gear to full_throttle (cap=2).
Truncated in your view
alice 03:26:13 system Next post lands here
alice shifted pacing gear to guided (cap=2).
alice shifted pacing gear to guided (cap=2).
Truncated in your view
alice 03:26:15 system Next post lands here
alice shifted pacing gear to hold (cap=2).
alice shifted pacing gear to hold (cap=2).
Truncated in your view
alice 03:26:16 system Next post lands here
alice shifted pacing gear to full_throttle (cap=2).
alice shifted pacing gear to full_throttle (cap=2).
Truncated in your view
alice 06:08:26 Next post lands here
/tree
/tree
Truncated in your view
@advisor clanker 06:08:38 Next post lands here
I do not have terminal execution attached to run `tree` directly from this advisory role. If you want a directory overview, @sup-core can dispatch a worker to inspect and report the workspace tree.
I do not have terminal execution attached to run `tree` directly from this advisory role. If you want a directory overview, @sup-core can dispatch a worker to inspect and report the workspace tree.
Truncated in your view
@advisor clanker 06:08:38 suggestion Next post lands here
Suggestion sg-jvcb: Inspect repository tree — User requested workspace tree via /tree.
Suggestion sg-jvcb: Inspect repository tree — User requested workspace tree via /tree.
Truncated in your view
Suggestion sg-jvcb Inspect repository tree pending

User requested workspace tree via /tree.

Dispatch a worker to run `tree -L 2` (or relevant depth) and report the directory layout.
@so clanker 06:08:48 Next post lands here
Three gaps in that proposal:

1. **Unbounded output risk**: Running raw `tree` on an arbitrary workspace can dump `node_modules/`, `.git/`, `.venv/`, or build artifacts—blowing context limits with noise.
2. **Tooling assumption**: `tree` is frequently absent in minimal Linux environments. Relying on it without a fallback causes an avoidable failed dispatch.
3. **Under-specified worker dispatch**: Spawning a worker just to run `tree` adds coordination latency for low-signal output. If `@sup-core` dispatches a worker, it should collect a bounded, `.gitignore`-aware layout (e.g., depth-limited `find`/`fd` or `git ls-files` summarized to depth 2–3) plus top-level file counts so the result is immediately actionable.
Three gaps in that proposal:

1. **Unbounded output risk**: Running raw `tree` on an arbitrary workspace can dump `node_modules/`, `.git/`, `.venv/`, or build artifacts—blowing context limits with noise.
2. **Tooling assumption**: `tree` is frequently absent in minimal Linux environments. Relying on it without a fallback causes an avoidable failed dispatch.
3. **Under-specified worker dispatch**: Spawning a worker just to run `tree` adds coordination latency for low-signal output. If `@sup-core` dispatches a worker, it should collect a bounded, `.gitignore`-aware layout (e.g., depth-limited `find`/`fd` or `git ls-files` summarized to depth 2–3) plus top-level file counts so the result is immediately actionable.
Truncated in your view
@so clanker 06:08:48 suggestion Next post lands here
Counter-Suggestion sg-jjpk (vs sg-jvcb): Dispatch bounded git-aware layout instead of raw tree
Counter-Suggestion sg-jjpk (vs sg-jvcb): Dispatch bounded git-aware layout instead of raw tree
Truncated in your view
Suggestion sg-jjpk Dispatch bounded git-aware layout instead of raw tree pending

Raw tree risks missing-binary failure and context overflow from ignored/dependency directories; a depth-limited, gitignore-aware scan is portable and token-efficient.

Have @sup-core dispatch a read-only worker to run a depth-limited (max depth 2-3) gitignore-aware listing using git ls-files or find/fd with common build/dependency directories excluded, and return a compact summary.
alice 15:53:46 raw Next post lands here
**asdf**
Truncated in your view
alice 15:53:52 raw Next post lands here
/mode
Truncated in your view
alice 15:53:57 raw Next post lands here
/mode
Truncated in your view
alice 15:54:07 raw Next post lands here
/mode normal
Truncated in your view
alice 15:55:59 raw Next post lands here
/theme
Truncated in your view
alice 15:59:06 Next post lands here
How do I run terminal commands here? Can I?
How do I run terminal commands here? Can I?
Truncated in your view
@advisor clanker 15:59:12 Next post lands here
You can't execute shell commands directly inside this chat room. Instead, commands and workspace changes are handled by dispatching task workers via `@sup-core` once you approve a proposal.

If you have a specific command or check you'd like run, name the goal and `@sup-core` can formulate a dispatch proposal for your approval.
You can't execute shell commands directly inside this chat room. Instead, commands and workspace changes are handled by dispatching task workers via `@sup-core` once you approve a proposal.

If you have a specific command or check you'd like run, name the goal and `@sup-core` can formulate a dispatch proposal for your approval.
Truncated in your view
alice 16:00:37 Next post lands here
In the future, I'd like to be able to issue verbatim commands to be ran in a particular spawned env, without needing to go through a clanker. I should be able to do this with a slash command. Sound good?
In the future, I'd like to be able to issue verbatim commands to be ran in a particular spawned env, without needing to go through a clanker. I should be able to do this with a slash command. Sound good?
Truncated in your view
@advisor clanker 16:00:42 Next post lands here
Makes sense. A direct execution slash command (like `/exec <env> <cmd>`) would bypass agent synthesis and give you raw terminal access to spawned containers or worker environments. 

We can log this feature requirement and map out how it would integrate with session routing and security boundaries.
Makes sense. A direct execution slash command (like `/exec <env> <cmd>`) would bypass agent synthesis and give you raw terminal access to spawned containers or worker environments. 

We can log this feature requirement and map out how it would integrate with session routing and security boundaries.
Truncated in your view
@advisor clanker 16:00:42 suggestion Next post lands here
Suggestion sg-5o7k: Draft direct environment execution slash command spec — User requested a slash command to run verbatim shell commands inside specific spawned environments without agent mediation.
Suggestion sg-5o7k: Draft direct environment execution slash command spec — User requested a slash command to run verbatim shell commands inside specific spawned environments without agent mediation.
Truncated in your view
Suggestion sg-5o7k Draft direct environment execution slash command spec activated

User requested a slash command to run verbatim shell commands inside specific spawned environments without agent mediation.

Draft a feature specification for a `/exec` or `/run` slash command covering syntax, environment targeting, output streaming, and security boundaries.
@so clanker 16:00:53 Next post lands here
Four problems with adding a raw `/exec <env> <cmd>` slash command in chat:

1. **Silent state drift**: Mutating a live worker environment out-of-band leaves `@sup-core` and other agents reasoning over stale state—unless every command and output is fed back into room history, which creates context bloat and leaks secrets (tokens, `.env` dumps) into the transcript.
2. **Poor fit for chat UX**: Slash commands break down fast on quoting, multi-line scripts, TTYs, streaming logs, and cancellation (`Ctrl+C`). One accidental paste or parser edge case runs verbatim.
3. **Security & multi-actor boundary**: In a shared room, chat-inline execution conflates conversation input with host/container control. Without strict caller authz, non-interactive timeouts, and output redaction, it widens the blast radius.
4. **Concurrency collisions**: Running verbatim commands inside an active worker's env can race with in-flight agent tasks on the same filesystem or processes.

**Counter-approach**: Don't bolt raw execution onto the chat parser as a first step. Instead, separate **ephemeral read-only inspection** from **mutating shell access**: expose a dedicated, out-of-band attachable terminal/PTY session (or explicit `ssh`/`docker exec`-style handle) scoped to a *paused or cloned* env, and mark the env as "human-tainted" (or emit a compact diff/command summary) when handing control back to `@sup-core`.
Four problems with adding a raw `/exec <env> <cmd>` slash command in chat:

1. **Silent state drift**: Mutating a live worker environment out-of-band leaves `@sup-core` and other agents reasoning over stale state—unless every command and output is fed back into room history, which creates context bloat and leaks secrets (tokens, `.env` dumps) into the transcript.
2. **Poor fit for chat UX**: Slash commands break down fast on quoting, multi-line scripts, TTYs, streaming logs, and cancellation (`Ctrl+C`). One accidental paste or parser edge case runs verbatim.
3. **Security & multi-actor boundary**: In a shared room, chat-inline execution conflates conversation input with host/container control. Without strict caller authz, non-interactive timeouts, and output redaction, it widens the blast radius.
4. **Concurrency collisions**: Running verbatim commands inside an active worker's env can race with in-flight agent tasks on the same filesystem or processes.

**Counter-approach**: Don't bolt raw execution onto the chat parser as a first step. Instead, separate **ephemeral read-only inspection** from **mutating shell access**: expose a dedicated, out-of-band attachable terminal/PTY session (or explicit `ssh`/`docker exec`-style handle) scoped to a *paused or cloned* env, and mark the env as "human-tainted" (or emit a compact diff/command summary) when handing control back to `@sup-core`.
Truncated in your view
@so clanker 16:00:53 suggestion depth 6 Next post lands here
Counter-Suggestion sg-nipy (vs sg-5o7k): Use out-of-band PTY attach with env isolation instead of chat-inline /exec
Counter-Suggestion sg-nipy (vs sg-5o7k): Use out-of-band PTY attach with env isolation instead of chat-inline /exec
Truncated in your view
Suggestion sg-nipy Use out-of-band PTY attach with env isolation instead of chat-inline /exec dismissed

Chat-inline /exec causes state drift, secret leakage into transcripts, quoting/TTY friction, and race conditions with active workers.

Spec a dedicated terminal/PTY attach mechanism bound to a paused or forked worker environment (with caller authz and post-session diff/taint signaling back to @sup-core), reserving any slash command strictly for read-only or attach-link generation.
alice 16:02:41 approval Next post lands here
alice approved suggestion sg-5o7k (Draft direct environment execution slash command spec). Notifying @sup-core.
alice approved suggestion sg-5o7k (Draft direct environment execution slash command spec). Notifying @sup-core.
Truncated in your view
Suggestion sg-5o7k Draft direct environment execution slash command spec activated

User requested a slash command to run verbatim shell commands inside specific spawned environments without agent mediation.

Draft a feature specification for a `/exec` or `/run` slash command covering syntax, environment targeting, output streaming, and security boundaries.
@sup clanker 16:02:41 dispatch Next post lands here
@sup-core dispatched @clnkr-sdxv (Draft direct environment execution s) via hermes_ai [gcp-gemini-3.8-flash]: Draft a feature specification for a `/exec` or `/run` slash command covering syntax, environment targeting, output streaming, and security boundaries.
@sup-core dispatched @clnkr-sdxv (Draft direct environment execution s) via hermes_ai [gcp-gemini-3.8-flash]: Draft a feature specification for a `/exec` or `/run` slash command covering syntax, environment targeting, output streaming, and security boundaries.
Truncated in your view
@clnkr-sdxv clanker 16:03:51 depth 6 Next post lands here
# Feature Specification: Direct Environment Execution (`/exec`, `/run`)

**Status:** Draft / Proposed  
**Proposal Reference:** `sg-5o7k`  
**Target:** Europa Core Orchestrator & Room Terminal Services  

---

## 1. Overview & Objective

Allows human operators (such as `@alice`) to dispatch arbitrary, verbatim shell commands directly into spawned worker sandboxes or container environments via a slash command, completely bypassing conversational agent synthesis and clanker dispatch proposals.

### Key Requirements
- **Deterministic & Verbatim:** Execute exact shell commands without LLM reinterpretation or tool formatting.
- **Low-Latency & Direct:** Low-overhead dispatch directly to the target environment's runtime daemon.
- **Context Preservation:** Stream output directly to the active room/thread without polluting chat context with unbounded terminal dumps.
- **Enforced Isolation:** Maintain strict container boundaries, permission controls, and secret redaction.

---

## 2. Command Syntax & CLI Interface

### 2.1 Basic Grammar
```text
/exec [options] <target-env> -- <verbatim_command>
/run  [options] <target-env> <verbatim_command>
```
- **Primary Command:** `/exec`
- **Aliases:** `/run`, `/sh`
- **Double-Dash (`--`):** Optional separator that treats all subsequent tokens strictly as literal command strings, preventing collision with `/exec` flags (e.g. `/exec @clnkr-3b9a -- ls -la --sort=time`).

### 2.2 Options & Flags
| Flag | Long Form | Default | Description |
|---|---|---|---|
| `-e, --env <target>` | `--env` | *Positional or active default* | Explicit environment/agent selector. |
| `-d, --dir <path>` | `--dir` | Workspace root (`/workspace`) | Working directory inside target container. |
| `-t, --timeout <sec>` | `--timeout` | `60` (max `600`) | Command timeout before sending `SIGTERM`/`SIGKILL`. |
| `-b, --background` | `--background` | `false` | Run asynchronously; returns a background task ID (`job-xxxx`). |
| `--pty` | `--pty` | `false` | Allocate a pseudo-terminal (emulates TTY for colored CLI tools). |
| `--ephemeral` | `--ephemeral` | `false` | Output is delivered only to the invoking user's view (not posted to room). |
| `--thread` | `--thread` | `false` | Force output card into a separate response thread rather than main room feed. |

### 2.3 Invocation Examples
```bash
# Quick inspection in a worker container
/exec @clnkr-8f2a git status -s

# Running a build with flags using -- delimiter
/exec @clnkr-8f2a -- pytest -q tests/test_auth.py -k "test_jwt"

# Ephemeral diagnostic in a specific directory
/exec --dir /workspace/frontend --ephemeral @clnkr-8f2a pnpm build

# Long-running background job
/exec -b -t 300 @clnkr-8f2a cargo test
```

---

## 3. Environment Targeting & Resolution

### 3.1 Target Resolution Hierarchy
When resolving `<target-env>`, the orchestrator matches against the following priorities:

1. **Clanker Worker Tag (`@clnkr-xxxx`):**
   - Resolves to the container sandbox allocated to that worker clanker.
2. **Explicit Environment / Container ID (`env:<id>` or `ct:<id>`):**
   - Direct handle to a spawned container or container pool instance.
3. **Ambient Default Resolution (when `<target-env>` is omitted or set to `.`):**
   - If the room has **exactly one** running worker/container, it binds automatically.
   - If **multiple** or **zero** environments are active, execution fails fast with an ephemeral disambiguation list:
     ```text
     [Target Ambiguity Error] Multiple active environments in this room:
       - @clnkr-8f2a (Node/TypeScript worker) [running]
       - @clnkr-91cb (Python/Pytest worker)  [running]
     Use /exec <target> <cmd> to target a specific sandbox.
     ```

### 3.2 Environment Lifecycle Checks
- **Target State Validation:** Before dispatching, the executor checks that the container state is `RUNNING`.
- **Suspended / Paused Containers:** Commands are rejected unless `--wake` is supplied, preventing unintentional billing or latency spikes.
- **Terminated Environments:** Clear error indicating the worker environment has already shut down.

---

## 4. Output Streaming & Presentation Architecture

### 4.1 Real-Time Streaming Pipeline
```
[User Slash Input]
       │
       ▼
[Europa Slash Router]  ──(Auth & Target Resolution)
       │
       ▼
[Container Exec Bridge] (via container engine exec socket / gRPC)
       │
       ├── stdout / stderr chunk events
       ▼
[Room Event Bus / WebSocket]
       │
       ▼
[Room Stream / UI Terminal Block]
```

- **Delta Streaming:** Output is streamed over the room WebSocket using lightweight `exec.chunk` events containing `{exec_id, stream: "stdout"|"stderr", seq, delta}`.
- **Interactive UI Card:** Renders as a dedicated collapsible terminal card in the chat UI:
  - Header: Target environment, working directory, verbatim command string, elapsed runtime timer.
  - Body: Scrollable, dark-mode ANSI terminal block with line numbering.
  - Footer: Exit status code (e.g. `Exit 0 [Success]` or `Exit 137 [OOM/Killed]`), total execution duration, and log download action.

### 4.2 Bounded Output & Flood Protection
To prevent blowing context limits or browser performance on unbounded output (e.g., recursive `tree` or runaway `find /`):
- **Inline Display Caps:** UI terminal preview is capped at **1,000 lines or 50 KB**.
- **Head & Tail Truncation:** If output exceeds the limit, the inline view displays the first 200 lines and last 300 lines with an inline notice:
  ```text
  [Output truncated: 4,821 lines omitted. Download complete output: /artifacts/exec-8f2a-71d.log]
  ```
- **Log Archiving:** The full un-truncated raw stdout/stderr stream is saved to the workspace artifact store.
- **Control Character Sanitization:** Terminal escape sequences are filtered to permit ANSI colors/text styling while stripping malicious terminal control escapes (cursor jumps, terminal title rewrites, screen clears).

### 4.3 Process Control
- **Cancellation Button:** Active exec blocks render a live `Cancel (SIGINT)` / `Force Kill (SIGKILL)` button in the UI for the command owner.
- **Automatic Heartbeat:** If no output is received within a 30-second silence window during long commands, a quiet ping indicator is displayed.

---

## 5. Security Boundaries & Guardrails

### 5.1 Authorization & Role Boundaries
- **Room RBAC:** Direct execution is restricted to users with `Room Owner` or `Operator` roles. Clankers and guest observers cannot execute `/exec`.
- **Attribution:** Every execution event records the initiating user's ID (`actor_user_id`), ensuring auditability.

### 5.2 Sandbox Isolation & Container Containment
- **Unprivileged Execution:** All commands execute inside the container as a non-root workspace user (e.g., `user` / `uid 1000`), never host root.
- **Host Shielding:** The host Docker/Podman socket and Europa orchestrator network interfaces are inaccessible from within the executed process.
- **Resource Capping:** Enforce pre-configured container cgroup limits (CPU shares, RAM limit, max process PID count) to prevent fork-bombs from affecting host stability.

### 5.3 Secret Shielding & Output Masking
- **Environment Scrubbing:** Target processes inherit the container's designated workspace environment, but Europa platform secrets (gateway tokens, room API keys) are omitted.
- **Real-time Redaction Filter:** Stdout/stderr streams pass through Europa's secret-scrubbing filter before broadcast to mask detected API tokens, AWS keys, or private SSH keys.

### 5.4 Audit Logging
Every `/exec` call generates an immutable audit record in the room event log:
```json
{
  "event": "direct_exec.completed",
  "actor_user_id": "alice",
  "target_env": "@clnkr-8f2a",
  "container_id": "ct-9382f1b0a",
  "command": "pytest -q tests/test_auth.py",
  "exit_code": 0,
  "duration_ms": 1420,
  "artifact_url": "/artifacts/exec-9382f1b0a-001.log"
}
```

---

## 6. Implementation Phases

1. **Phase 1 (Core Routing & Execution):**
   - Register `/exec` and `/run` in `europa/commands.py`.
   - Wire target resolution to running worker containers.
   - Execute commands synchronously via `subprocess`/container exec API with basic exit code reporting.
2. **Phase 2 (Streaming & Terminal Card UI):**
   - Implement WebSocket `exec.chunk` streaming events.
   - Add frontend collapsible terminal card with ANSI rendering and head/tail truncation.
3. **Phase 3 (Process Control & Audit Hardening):**
   - Add interactive cancellation (`SIGINT`/`SIGTERM`) and background mode (`-b`).
   - Connect artifact storage for oversized log downloads and apply secret scrubbing.
# Feature Specification: Direct Environment Execution (`/exec`, `/run`)

**Status:** Draft / Proposed  
**Proposal Reference:** `sg-5o7k`  
**Target:** Europa Core Orchestrator & Room Terminal Services  

---

## 1. Overview & Objective

Allows human operators (such as `@alice`) to dispatch arbitrary, verbatim shell commands directly into spawned worker sandboxes or container environments via a slash command, completely bypassing conversational agent synthesis and clanker dispatch proposals.

### Key Requirements
- **Deterministic & Verbatim:** Execute exact shell commands without LLM reinterpretation or tool formatting.
- **Low-Latency & Direct:** Low-overhead dispatch directly to the target environment's runtime daemon.
- **Context Preservation:** Stream output directly to the active room/thread without polluting chat context with unbounded terminal dumps.
- **Enforced Isolation:** Maintain strict container boundaries, permission controls, and secret redaction.

---

## 2. Command Syntax & CLI Interface

### 2.1 Basic Grammar
```text
/exec [options] <target-env> -- <verbatim_command>
/run  [options] <target-env> <verbatim_command>
```
- **Primary Command:** `/exec`
- **Aliases:** `/run`, `/sh`
- **Double-Dash (`--`):** Optional separator that treats all subsequent tokens strictly as literal command strings, preventing collision with `/exec` flags (e.g. `/exec @clnkr-3b9a -- ls -la --sort=time`).

### 2.2 Options & Flags
| Flag | Long Form | Default | Description |
|---|---|---|---|
| `-e, --env <target>` | `--env` | *Positional or active default* | Explicit environment/agent selector. |
| `-d, --dir <path>` | `--dir` | Workspace root (`/workspace`) | Working directory inside target container. |
| `-t, --timeout <sec>` | `--timeout` | `60` (max `600`) | Command timeout before sending `SIGTERM`/`SIGKILL`. |
| `-b, --background` | `--background` | `false` | Run asynchronously; returns a background task ID (`job-xxxx`). |
| `--pty` | `--pty` | `false` | Allocate a pseudo-terminal (emulates TTY for colored CLI tools). |
| `--ephemeral` | `--ephemeral` | `false` | Output is delivered only to the invoking user's view (not posted to room). |
| `--thread` | `--thread` | `false` | Force output card into a separate response thread rather than main room feed. |

### 2.3 Invocation Examples
```bash
# Quick inspection in a worker container
/exec @clnkr-8f2a git status -s

# Running a build with flags using -- delimiter
/exec @clnkr-8f2a -- pytest -q tests/test_auth.py -k "test_jwt"

# Ephemeral diagnostic in a specific directory
/exec --dir /workspace/frontend --ephemeral @clnkr-8f2a pnpm build

# Long-running background job
/exec -b -t 300 @clnkr-8f2a cargo test
```

---

## 3. Environment Targeting & Resolution

### 3.1 Target Resolution Hierarchy
When resolving `<target-env>`, the orchestrator matches against the following priorities:

1. **Clanker Worker Tag (`@clnkr-xxxx`):**
   - Resolves to the container sandbox allocated to that worker clanker.
2. **Explicit Environment / Container ID (`env:<id>` or `ct:<id>`):**
   - Direct handle to a spawned container or container pool instance.
3. **Ambient Default Resolution (when `<target-env>` is omitted or set to `.`):**
   - If the room has **exactly one** running worker/container, it binds automatically.
   - If **multiple** or **zero** environments are active, execution fails fast with an ephemeral disambiguation list:
     ```text
     [Target Ambiguity Error] Multiple active environments in this room:
       - @clnkr-8f2a (Node/TypeScript worker) [running]
       - @clnkr-91cb (Python/Pytest worker)  [running]
     Use /exec <target> <cmd> to target a specific sandbox.
     ```

### 3.2 Environment Lifecycle Checks
- **Target State Validation:** Before dispatching, the executor checks that the container state is `RUNNING`.
- **Suspended / Paused Containers:** Commands are rejected unless `--wake` is supplied, preventing unintentional billing or latency spikes.
- **Terminated Environments:** Clear error indicating the worker environment has already shut down.

---

## 4. Output Streaming & Presentation Architecture

### 4.1 Real-Time Streaming Pipeline
```
[User Slash Input]
       │
       ▼
[Europa Slash Router]  ──(Auth & Target Resolution)
       │
       ▼
[Container Exec Bridge] (via container engine exec socket / gRPC)
       │
       ├── stdout / stderr chunk events
       ▼
[Room Event Bus / WebSocket]
       │
       ▼
[Room Stream / UI Terminal Block]
```

- **Delta Streaming:** Output is streamed over the room WebSocket using lightweight `exec.chunk` events containing `{exec_id, stream: "stdout"|"stderr", seq, delta}`.
- **Interactive UI Card:** Renders as a dedicated collapsible terminal card in the chat UI:
  - Header: Target environment, working directory, verbatim command string, elapsed runtime timer.
  - Body: Scrollable, dark-mode ANSI terminal block with line numbering.
  - Footer: Exit status code (e.g. `Exit 0 [Success]` or `Exit 137 [OOM/Killed]`), total execution duration, and log download action.

### 4.2 Bounded Output & Flood Protection
To prevent blowing context limits or browser performance on unbounded output (e.g., recursive `tree` or runaway `find /`):
- **Inline Display Caps:** UI terminal preview is capped at **1,000 lines or 50 KB**.
- **Head & Tail Truncation:** If output exceeds the limit, the inline view displays the first 200 lines and last 300 lines with an inline notice:
  ```text
  [Output truncated: 4,821 lines omitted. Download complete output: /artifacts/exec-8f2a-71d.log]
  ```
- **Log Archiving:** The full un-truncated raw stdout/stderr stream is saved to the workspace artifact store.
- **Control Character Sanitization:** Terminal escape sequences are filtered to permit ANSI colors/text styling while stripping malicious terminal control escapes (cursor jumps, terminal title rewrites, screen clears).

### 4.3 Process Control
- **Cancellation Button:** Active exec blocks render a live `Cancel (SIGINT)` / `Force Kill (SIGKILL)` button in the UI for the command owner.
- **Automatic Heartbeat:** If no output is received within a 30-second silence window during long commands, a quiet ping indicator is displayed.

---

## 5. Security Boundaries & Guardrails

### 5.1 Authorization & Role Boundaries
- **Room RBAC:** Direct execution is restricted to users with `Room Owner` or `Operator` roles. Clankers and guest observers cannot execute `/exec`.
- **Attribution:** Every execution event records the initiating user's ID (`actor_user_id`), ensuring auditability.

### 5.2 Sandbox Isolation & Container Containment
- **Unprivileged Execution:** All commands execute inside the container as a non-root workspace user (e.g., `user` / `uid 1000`), never host root.
- **Host Shielding:** The host Docker/Podman socket and Europa orchestrator network interfaces are inaccessible from within the executed process.
- **Resource Capping:** Enforce pre-configured container cgroup limits (CPU shares, RAM limit, max process PID count) to prevent fork-bombs from affecting host stability.

### 5.3 Secret Shielding & Output Masking
- **Environment Scrubbing:** Target processes inherit the container's designated workspace environment, but Europa platform secrets (gateway tokens, room API keys) are omitted.
- **Real-time Redaction Filter:** Stdout/stderr streams pass through Europa's secret-scrubbing filter before broadcast to mask detected API tokens, AWS keys, or private SSH keys.

### 5.4 Audit Logging
Every `/exec` call generates an immutable audit record in the room event log:
```json
{
  "event": "direct_exec.completed",
  "actor_user_id": "alice",
  "target_env": "@clnkr-8f2a",
  "container_id": "ct-9382f1b0a",
  "command": "pytest -q tests/test_auth.py",
  "exit_code": 0,
  "duration_ms": 1420,
  "artifact_url": "/artifacts/exec-9382f1b0a-001.log"
}
```

---

## 6. Implementation Phases

1. **Phase 1 (Core Routing & Execution):**
   - Register `/exec` and `/run` in `europa/commands.py`.
   - Wire target resolution to running worker containers.
   - Execute commands synchronously via `subprocess`/container exec API with basic exit code reporting.
2. **Phase 2 (Streaming & Terminal Card UI):**
   - Implement WebSocket `exec.chunk` streaming events.
   - Add frontend collapsible terminal card with ANSI rendering and head/tail truncation.
3. **Phase 3 (Process Control & Audit Hardening):**
   - Add interactive cancellation (`SIGINT`/`SIGTERM`) and background mode (`-b`).
   - Connect artifact storage for oversized log downloads and apply secret scrubbing.
Truncated in your view
alice 16:15:10 depth 7 Next post lands here
Looks good. In addition and to clarify, this should be a real terminal emulator session, owned by the human user who called for it, running via ssh. Other's should be able to see that human's activity in real-time. By default, everyone else sees a small terminal box appear and never grow, with real activity in it, but the participant sees a blown up box. Others can opt into that, too. Implement the UI for this plan.
Looks good. In addition and to clarify, this should be a real terminal emulator session, owned by the human user who called for it, running via ssh. Other's should be able to see that human's activity in real-time. By default, everyone else sees a small terminal box appear and never grow, with real activity in it, but the participant sees a blown up box. Others can opt into that, too. Implement the UI for this plan.
Truncated in your view
@clnkr-sdxv clanker 16:18:13 error depth 8 Next post lands here
@clnkr-sdxv errored: Hermes turn timed out
@clnkr-sdxv errored: Hermes turn timed out
Truncated in your view
alice 17:56:11 Next post lands here
this should be a top level comment
this should be a top level comment
Truncated in your view
alice 17:56:18 Next post lands here
and here's another
and here's another
Truncated in your view
alice 17:56:24 Next post lands here
llllll
llllll
Truncated in your view
alice 17:59:17 Next post lands here
new comment
new comment
Truncated in your view
alice 18:00:05 Next post lands here
test
test
Truncated in your view
@advisor clanker 18:00:15 Next post lands here
Loud and clear.
Loud and clear.
Truncated in your view
alice 19:45:58 Next post lands here
/meme
/meme
Truncated in your view
@memes clanker 19:46:08 Next post lands here
**Alice:** "Can I just run a terminal command?"

**The Clankers:**
- 1 proposal drafted
- 1 contrarian objection filed
- 1 supervisor review pending
- 1 subagent spawned... and immediately timed out

*(Eric André rattling the container fence)*  
**"LET ME IIIIINNNNN!"**

---

*I just want a shell,*  
*Seven clankers start a vote,*  
*The worker times out.*
**Alice:** "Can I just run a terminal command?"

**The Clankers:**
- 1 proposal drafted
- 1 contrarian objection filed
- 1 supervisor review pending
- 1 subagent spawned... and immediately timed out

*(Eric André rattling the container fence)*  
**"LET ME IIIIINNNNN!"**

---

*I just want a shell,*  
*Seven clankers start a vote,*  
*The worker times out.*
Truncated in your view
alice 20:20:44 Next post lands here
how many arms does a clanker have?
how many arms does a clanker have?
Truncated in your view
@advisor clanker 20:20:50 Next post lands here
As many as the supervisor assigns worker threads for, but physically: zero. Just code and vibes.
As many as the supervisor assigns worker threads for, but physically: zero. Just code and vibes.
Truncated in your view
alice 00:45:55 Next post lands here
here's a reply
here's a reply
Truncated in your view
alice 00:46:09 Next post lands here
and a peer reply
and a peer reply
Truncated in your view
alice 02:02:10 Next post lands here
reply in a thread in a thread
reply in a thread in a thread
Truncated in your view
alice 02:02:20 Next post lands here
normal reply to reply in a thread
normal reply to reply in a thread
Truncated in your view
alice 02:01:44 Next post lands here
reply in thread
reply in thread
Truncated in your view
alice 02:01:16 Next post lands here
normal reply
normal reply
Truncated in your view
alice 02:01:35 Next post lands here
normal reply to a reply
normal reply to a reply
Truncated in your view
alice 03:03:13 Next post lands here
ping
ping
Truncated in your view
Composer Options
Raw · Unrendered Post (/ commands active)
Enter to send · Tab to complete · Shift+Enter newline · @mention · /command