STACIO WIKI · Automation Guide
Stacio Automation Guide
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:
- Which host, account, environment, and runtime are targeted?
- Is input read-only, ordinary write, network activity, or destructive work?
- Are multiple targets fully homogeneous, or do versions, directories, and permissions differ?
- Is there a verified pre-change backup?
- Which command or business request validates completion?
- 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
- Edit an SSH session.
- Enter one or more shell lines in
Actions After Connecting > Connection Script. - Save the session and reconnect.
- Observe the post-connect directory, prompt, and command output.
- Check failure information in
View > Diagnostics.
Read-only example:
cd /srv/app
pwd
git status --short --branchStacio 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
- Keep it short, readable, and idempotent.
- Prefer changing directory, setting a prompt, and read-only inspection.
- Do not automatically deploy, restart, delete, migrate a database, or change a firewall.
- Do not include passwords, tokens, private-key passphrases, or long-lived secrets.
- Do not assume shell type, current directory, or
sudopermission. - Make failure visible at every step.
- Design for repeated execution after disconnect and reconnect.
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
- Connect and verify at least two terminals individually, including each IP/hostname, port, account, and environment.
- Click
MultiExecin the toolbar. - In the target list, select only the terminals that need synchronization by complete endpoint, not similar session names.
- When the workspace is already a multi-terminal split, Stacio can use its current split targets.
- Confirm to place targets into a MultiExec grid workspace.
- 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:
- that pane still receives direct user input;
- input from other panes is not broadcast to it;
- input made in the paused pane is not broadcast to other targets;
Resume Sync for This Terminaljoins it again.
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:
- Validate a command first on one non-production or canary host.
- Review IP/hostname, port, account, and environment for every target.
- Use
hostname,whoami, andpwdas the first read-only identity check and cross-check them with Stacio's endpoint. - Avoid multiline paste, interactive editors, and commands with timing dependencies.
- Pause broadcast immediately when any target has different output.
- 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
- Choose
View > Macrosor the toolbar macro entry point. - Click
Start Recording. - Submit commands one by one in a local or remote terminal.
- Return to Macros and click
Stop Recording. - 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:
- search by name or command;
- filter and group by group;
- rename and delete;
- import and export;
- view command count and updated time;
- enable or disable
Confirm Before Run.
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
- Select the target terminal first.
- Choose a macro in the panel.
- Inspect its run preview and click
Replay. - Stacio warns again when destructive commands are detected.
- 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:
- Add or choose a model provider.
- Enter Base URL, model, and API key.
- Test the connection and fetch a model list.
- Configure terminal-context length.
- Choose command-confirmation and execution mode.
- 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
- Select the correct current terminal.
- Open
View > AI Assistant. - In the target selector, verify terminal, directory, and environment.
- Choose rule suggestions or model reasoning.
- Enter a specific question, preferring read-only inspection and evidence.
- Inspect each command card's target, command, risk, and explanation.
- Approve, edit, skip, or reject the command.
- 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:
- backup before a change;
- verification that backup location exists and is readable;
- minimum necessary change;
- targeted validation afterward;
- organized rollback on failure;
- a final report with backup, validation, and rollback information.
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
- Install the desired Agent CLI on the Mac and ensure Stacio can find it on PATH or a common installation path.
- Select the remote terminal to operate.
- Open the AI panel and switch to Local Agent.
- Select a detected Agent from the tools menu.
- Check the executable and remote bridge target in the status bar.
- 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:
stacio-sessions: list available terminals;stacio-remote "command": run remotely through Agent Bridge;stacio-agent: access lower-level Bridge subcommands;AGENTS.md,CLAUDE.md,QWEN.md, or general instruction files.
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 --jsonGet 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" --followYou 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>- Pause: stop the Agent from advancing while preserving current task state.
- Cancel: end a cancellable independent task.
- Take over: return control to the user terminal.
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 sessionsor 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:
- global command-confirmation policy;
- session environment;
- per-session AI policy;
- automatic-allow patterns;
- deny patterns;
- the user's decision in the approval bar.
Deny takes precedence over automatic allowance, and production and Confirm Every Command increase approval requirements.
10.2 Audit records
Choose View > Diagnostics to view:
- MultiExec broadcast audit;
- AI/Agent request and execution state;
- request ID, runtime, target count, and send result;
- redacted command summary;
- application logs and import reports.
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
- Open each target terminal and record the IP/hostname, port, and account that Stacio displays.
- Run
hostname,whoami, andpwd, then cross-check them against endpoint and environment mark. - Start MultiExec.
- Broadcast read-only commands such as
whoami,uptime, anddf -h. - Pause any target with different output.
- Record outcomes per host instead of merging them into an ambiguous conclusion.
11.2 Enter a project directory after connecting
- Put descriptive intent in the session
Startup Command. - Restrict actual automatic action to a short Connection Script.
- Use
cd,pwd, and read-only status commands. - Confirm repeated execution is safe after reconnect.
11.3 AI-assisted change
- Ask AI for read-only diagnosis first.
- State the change target and completion standard.
- Inspect backup command and location.
- Approve every write command separately.
- Observe real terminal output.
- Validate configuration, service state, port, and business request.
- 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:
- batch changes across production hosts with different versions or topology;
- database migration that must wait for a prior step;
- commands requiring interactive confirmation, OTP, or human judgment;
- wide deletion, recursive permission changes, or firewall rewrites;
- deployment without backup, rollback, or targeted validation;
- critical work that depends on unattended time triggers.
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:
- target, environment, and account are confirmed;
- actual commands match approved content;
- every target has terminal output or an explicit failure state;
- pre-change backup is verified;
- post-change targeted check passes;
- partial success, cancellation, pause, and unverified items are explicitly recorded;
- the rollback method is executable;
- unnecessary MultiExec, Agent, tunnel, or external scheduled task is stopped.
See Security and Governance for policy and Remote Operations for operational validation.
