STACIO WIKI · Automation Guide

Stacio Automation Guide

Applicable version: Stacio 0.14.x
Updated: 2026-07-25
Audience: users who reuse connection actions, synchronize input, use macros, AI, a local Agent, or the Agent Bridge CLI

1. Automation capability boundary

Stacio currently provides controlled automation around already-open terminals. It is not a general task-scheduling platform.

Capability Trigger Suitable use Main risk
Session policy Open a saved session Mark environment, set AI execution policy and connection timeout Incorrect environment marking weakens approval judgment.
Connection Script Send automatically after SSH becomes ready or reconnects Change directory, print a read-only environment summary Automatic execution can repeat on reconnect.
MultiExec User starts it and synchronizes input to several terminals Homogeneous-host inspection and short command broadcast One input affects several targets.
Macro Record and replay submitted commands Repetitive interactive steps Sends on fixed intervals and does not wait for prior completion.
AI Assistant User asks and approves command cards Troubleshooting, explanation, controlled execution Model output can be wrong and may include terminal context.
Local Agent Start local Codex, Claude, and similar CLI tools Complex, multi-step work Stacio cannot fully control a third-party CLI's internal behavior.
Agent Bridge CLI A local process calls the Unix socket External tools operating the current terminal Wrong runtime, script injection, and unattended execution.

The current version has no standalone cron-style job list, time trigger, calendar trigger, daemon-task orchestration, or timed failure-compensation queue. For scheduled work, use remote cron/systemd timer or macOS launchd after explicit approval; the respective system owns permission, logging, alerting, and disabling. Stacio does not manage those external schedules automatically.

2. Security baseline before automation

Before any automation, answer:

  1. Which host, account, environment, and runtime are targeted?
  2. Is input read-only, ordinary write, network activity, or destructive work?
  3. Are multiple targets fully homogeneous, or do versions, directories, and permissions differ?
  4. Is there a verified pre-change backup?
  5. Which command or business request validates completion?
  6. How will you stop, roll back, and confirm recovery after failure?

Verify an automation target by complete endpoint rather than session alias only:

Target form Review focus
root@192.168.1.20:22 IP, default SSH port, account, and environment.
deploy@192.168.1.20:2222 Whether custom port or NAT mapping reaches the expected asset.
admin@server.example.com:22 Current resolved IP, account, and environment for the hostname.

The table is a review format. Saved sessions still hold Host and Port separately. Session names can be stale or duplicated and runtime IDs can change after reconnect, so reconfirm the active endpoint before every batch or Agent action.

In production, neither command sent, task queued, nor Agent finished is proof of successful change. Completion needs real terminal output and targeted validation evidence.

3. Session environment and AI policy

In the Automation area of New Session or Edit Session, set:

3.1 Environment

Environment Use
Development Local development, test host, or lower-risk environment.
Staging Pre-release validation environment.
Production Real business environment; Agents use more conservative approval rules.

Environment is security metadata and does not change the remote host itself. Recheck it after copying, importing, or renaming a session; do not infer environment from a name alone.

3.2 AI execution policy

Policy Behavior
Follow Global Use the global command-confirmation policy in Settings > AI and Execution.
Block Execution AI or Agent should not write commands to this session.
Command Cards Only Generate suggestions for the user to inspect and decide on in a card.
Automatic for Read-only Commands classified read-only may run automatically; other work is escalated for confirmation.
Confirm Every Command Require confirmation for every command.

Deny patterns take precedence; production enforces conservative approval; a session may be stricter than the global policy. Allow patterns and risk classification cannot prove command semantics are absolutely safe, especially for pipelines, redirection, command substitution, and wrapper scripts.

4. Actions after connecting

4.1 Actual differences between three fields

Field Current behavior Runs automatically?
Startup Command Shown with Environment Variables in the connection summary's Startup plan No
Environment Variables One value per line, included in Startup plan No
Connection Script Written directly to the remote shell after the SSH terminal is ready Yes

Startup plan explicitly shows (not executed automatically). It is useful to record an intended startup approach or give a user text to inspect and copy, but cannot be relied on for cd, export, service start, or deployment.

Only Connection Script executes automatically, and only on SSH terminals. Serial, Telnet, and Local Shell do not use that SSH-injection path.

4.2 Configure a connection script

  1. Edit an SSH session.
  2. Enter one or more shell lines in Actions After Connecting > Connection Script.
  3. Save the session and reconnect.
  4. Observe the post-connect directory, prompt, and command output.
  5. Check failure information in View > Diagnostics.

Read-only example:

cd /srv/app
pwd
git status --short --branch

Stacio appends a newline and writes the script silently, attempting to filter script echo. Script output still enters the current terminal. Both initial connect and later reconnect enter the ready flow, so a script must be safe to repeat.

4.3 Connection-script design principles

Connection scripts are stored in session configuration, not the credential store. Treat them as sensitive configuration when copying session settings, reading a local database, or sharing diagnostics.

4.4 Import and connection scripts

When importing sessions from an external tool or ordinary Stacio configuration, automatic-execution fields are not silently inherited. Review and configure a connection script manually after import so an external file cannot execute commands through the import path.

5. MultiExec

MultiExec is License-controlled and synchronizes keyboard input to multiple opened terminals.

5.1 Start interactive MultiExec

  1. Connect and verify at least two terminals individually, including each IP/hostname, port, account, and environment.
  2. Click MultiExec in the toolbar.
  3. In the target list, select only the terminals that need synchronization by complete endpoint, not similar session names.
  4. When the workspace is already a multi-terminal split, Stacio can use its current split targets.
  5. Confirm to place targets into a MultiExec grid workspace.
  6. Type in any unpaused pane to synchronize content to other unpaused targets.

Executable terminals can include Local Shell, SSH, Serial, or Telnet. A disconnected remote terminal will not receive input successfully.

5.2 Pause one target

Each remote pane can choose Pause Sync for This Terminal. After pausing:

Pause is not a transaction rollback. Characters and commands sent before pause may still execute remotely.

5.3 Production precautions

The target selector shows environment data, but interactive MultiExec does not create an approval dialog for each keystroke or command. It is live input synchronization, not the per-command Agent execution chain.

For production:

  1. Validate a command first on one non-production or canary host.
  2. Review IP/hostname, port, account, and environment for every target.
  3. Use hostname, whoami, and pwd as the first read-only identity check and cross-check them with Stacio's endpoint.
  4. Avoid multiline paste, interactive editors, and commands with timing dependencies.
  5. Pause broadcast immediately when any target has different output.
  6. Validate changes per target; one successful output never proves all targets.

5.4 Leave MultiExec

When closing a MultiExec tab, original terminals can return to independent tabs. After leaving synchronization, check for targets still running long commands and record partial success, failure, or unverified state.

6. Macros

A macro records actually submitted terminal commands to the local database and replays them in order to the current terminal.

6.1 Record a macro

  1. Choose View > Macros or the toolbar macro entry point.
  2. Click Start Recording.
  3. Submit commands one by one in a local or remote terminal.
  4. Return to Macros and click Stop Recording.
  5. Name and save the macro.

Recording stores non-empty command lines that were actually submitted, not ordinary cursor movement or unsubmitted text. Common credential patterns are redacted when saving, but secrets still must not be entered in terminal commands.

6.2 Manage macros

The Macros panel supports:

After importing a macro, inspect every command before any production replay. A macro file is executable content and should not be trusted solely because it came from a colleague or an older machine.

6.3 Replay a macro

  1. Select the target terminal first.
  2. Choose a macro in the panel.
  3. Inspect its run preview and click Replay.
  4. Stacio warns again when destructive commands are detected.
  5. Observe output for every step and run targeted validation afterward.

Macros send in saved order with a default interval of about 300 ms per step; they do not wait for a previous command to finish. Do not use a macro to chain slow deployments, interactive input, steps that depend on earlier success, or database changes that must be serialized.

7. AI assistant

7.1 Configure a model

In Stacio > Settings > AI and Execution:

  1. Add or choose a model provider.
  2. Enter Base URL, model, and API key.
  3. Test the connection and fetch a model list.
  4. Configure terminal-context length.
  5. Choose command-confirmation and execution mode.
  6. Set automatic-allow and deny patterns as needed.

Model interfaces use an OpenAI-compatible channel. The API key is saved in the Stacio local credential store; model list and ordinary configuration stay in local settings.

7.2 Use the troubleshooting assistant

  1. Select the correct current terminal.
  2. Open View > AI Assistant.
  3. In the target selector, verify terminal, directory, and environment.
  4. Choose rule suggestions or model reasoning.
  5. Enter a specific question, preferring read-only inspection and evidence.
  6. Inspect each command card's target, command, risk, and explanation.
  7. Approve, edit, skip, or reject the command.
  8. Decide outcomes from real terminal output.

When Include Recent Terminal Output is enabled, the request contains recent terminal context up to its character limit. Avoid showing credentials, customer data, or unnecessary full logs in the terminal before sending.

7.3 Change tasks

The troubleshooting assistant's controlled orchestration requires:

These gates reduce risk but do not replace least privilege, human approval, disaster recovery, or confirmation by the business owner.

8. Local Agent

Local Agent mode in the AI panel can detect and start local tools such as Codex, Claude, OpenCode, MiMo Code, ZCode, or Qwen Code. Each runs in an independent local workspace and is given the current terminal, remote directory, and a unified operational contract.

8.1 Start

  1. Install the desired Agent CLI on the Mac and ensure Stacio can find it on PATH or a common installation path.
  2. Select the remote terminal to operate.
  3. Open the AI panel and switch to Local Agent.
  4. Select a detected Agent from the tools menu.
  5. Check the executable and remote bridge target in the status bar.
  6. Submit the task in the native Agent session.

When Stacio cannot find a command, it reports that the tool is not detected or executable is missing. First prove the CLI starts from a local shell, then create a new Agent session.

8.2 Workspace tools

A local Agent workspace normally provides:

These wrapper commands are generated in a Stacio Agent workspace and are not guaranteed to be system-global commands. Local shell operations occur on the Mac; remote operations should go through Bridge so target selection, approval, and audit still apply.

8.3 Control boundary

Stacio can recognize risk, apply approval, and audit remote commands issued through Agent Bridge. It cannot guarantee that every local file operation, network request, or reasoning step of a third-party CLI is forced through the same state machine. Backup, validation, rollback, and final reporting for a local Agent are mainly constrained by the workspace operational contract.

See Agent Capabilities and Security for details.

9. Agent Bridge CLI

The Stacio package includes a local helper named stacio. While the main app runs, it starts a local-only Unix Domain Socket; copy its path from Settings > AI and Execution > Agent Bridge.

9.1 List targets

stacio agent sessions
stacio agent sessions --json

Get the current runtime ID before issuing later commands. Do not reuse an old runtime ID because it can change after terminal reconnect.

9.2 Run a command

stacio agent run --runtime <runtimeID> --command "uptime" --follow

You can also specify the current terminal or a saved session explicitly:

stacio agent run --target current --command "whoami"
stacio agent run --session <sessionID> --command "pwd" --follow

--follow streams status events until completion, failure, cancellation, pause, or takeover. --json is for another local program to parse; do not use string matching instead of JSON-state parsing.

9.3 Pause, cancel, and take over

Record a request ID from the event stream, then run:

stacio agent pause --request <requestID>
stacio agent cancel --request <requestID>
stacio agent takeover --request <requestID>

A successful control event only means Stacio accepted the request. Check whether the remote process actually stopped or requires manual cleanup.

9.4 Socket override

The default socket lives in the current user's Stacio Application Support directory. For specialized debugging, use:

stacio agent --socket /path/to/agent-bridge.sock sessions

or set STACIO_AGENT_SOCKET. Do not expose the socket to another user, a network share, or a container. When the main app is not running, the socket is stale, or the path does not match, the CLI reports Agent Bridge is not connected.

10. Approval, risk, and audit

10.1 Risk classification

AI and Bridge commands are classified as read-only, write, network, or destructive. Final execution also considers:

Deny takes precedence over automatic allowance, and production and Confirm Every Command increase approval requirements.

10.2 Audit records

Choose View > Diagnostics to view:

Audit-export count and whether application logs are included are controlled in Settings > Security. Audit supports tracing, not complete terminal recording, and it does not replace remote-system logs.

11. Recommended workflows

11.1 Read-only inspection across several hosts

  1. Open each target terminal and record the IP/hostname, port, and account that Stacio displays.
  2. Run hostname, whoami, and pwd, then cross-check them against endpoint and environment mark.
  3. Start MultiExec.
  4. Broadcast read-only commands such as whoami, uptime, and df -h.
  5. Pause any target with different output.
  6. Record outcomes per host instead of merging them into an ambiguous conclusion.

11.2 Enter a project directory after connecting

  1. Put descriptive intent in the session Startup Command.
  2. Restrict actual automatic action to a short Connection Script.
  3. Use cd, pwd, and read-only status commands.
  4. Confirm repeated execution is safe after reconnect.

11.3 AI-assisted change

  1. Ask AI for read-only diagnosis first.
  2. State the change target and completion standard.
  3. Inspect backup command and location.
  4. Approve every write command separately.
  5. Observe real terminal output.
  6. Validate configuration, service state, port, and business request.
  7. Stop and roll back immediately when validation fails.

12. Work that is not suitable for automation

Do not directly use a Connection Script, interactive MultiExec, or a fixed-interval macro for:

Use a dedicated automation system that offers idempotence, state checks, retry boundaries, key management, and centralized logs for these tasks; use Stacio for human verification or controlled troubleshooting.

13. Common questions

Symptom Check and handle
Startup plan did not run This is intentional. Put necessary automatic read-only actions in a Connection Script.
Connection Script runs repeatedly SSH reconnect re-enters the ready flow; make the script idempotent.
MultiExec has one target Open at least two executable terminals and check the remote ones are still connected.
One MultiExec host has no output Check pause state, disconnect, stuck target shell, or command incompatibility.
Macro steps interfere A macro does not wait for prior completion; split it or perform work manually step by step.
Macro includes sensitive value Delete the macro, rotate the secret, and do not record credential commands again.
AI has no available model Check provider, Base URL, API key, model, and network.
AI command cannot execute Check current terminal, global approval, session policy, deny patterns, and License.
Local Agent is not detected Verify CLI path in a local shell, then create a new Agent session.
Bridge is not connected Keep the Stacio main window running and verify the socket path.
Runtime does not exist Run stacio agent sessions again; do not reuse an old ID.
Feature entry is disabled Check MultiExec, AI Agent, or batch-session I/O entitlement in Help > License.

14. Completion standard

An automation task is complete only when all of these are true:

See Security and Governance for policy and Remote Operations for operational validation.

This page is part of the English Stacio Wiki.