feat(aws): setup script editor
Build App (Preview) / compute-version (pull_request) Successful in 6s
Secret Scan / scan (push) Successful in 7s
Secret Scan / scan (pull_request) Successful in 14s
Build App (Preview) / create-release (pull_request) Successful in 6s
Build App (Preview) / build-macos (pull_request) Successful in 6m3s
Build App (Preview) / test (pull_request) Successful in 8m39s
Build App (Preview) / build-windows (pull_request) Successful in 11m38s
Build Container / build-container (pull_request) Successful in 17m24s
Build App (Preview) / build-linux (pull_request) Failing after 21m19s
Build App (Preview) / prune-previews (pull_request) Skipped

HostSection gets a monospace "Setup script" textarea (saved on blur, blank
as none) with the 32 KiB UTF-8 limit checked using the backend's message,
and notes on when it runs (as claude, bash -e, after the clone, every start,
30 minutes, output in the Overview card) and what it gets under
copy-at-connect.

Also in Host settings: the environment's advisory lifetime cap (Q8), read
by a new aws_environment_max_hours command, and the copy-at-connect limits
(no CA before the first connect, removed credentials linger in a running
task, no setup re-run after a re-clone), documented in CLAUDE.md too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Opus 5.5 committed 2026-11-16 10:59:37 -08:00
1 parent 5388db487e
commit 9e1e72d2a4
13 files changed
+274 -10

No files matched your search

+17 -4
View File
@@ -448,7 +448,9 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
`timeout -k 10 1800`, chained after the background clone's `done` in the same background
subshell; `status` is `running` from the start until `ok` / `failed <code>` (a chain that dies
early writes `failed`, so the idle stop is never blocked). `triple-c-workspace-status` (python,
no secrets) prints `{clone:{done,repos},setup:{state,code,tail}}`.
no secrets) prints `{clone:{done,repos},setup:{state,code,tail}}`. Edited in HostSection's
"Setup script" textarea (saved on blur, blank → `null`; the 32 KiB UTF-8 limit is checked in TS
with Rust's own message, `setupScriptProblem`).
**The start does not wait for them** (it ends after "Connecting…": Running, lock released);
`aws_host::spawn_follow` follows in a background task (`host/aws_host/status.rs`: background exec
every 2 s, at most 35 min, holds no project lock; ended by `tunnels::cancel_follow` on Stop/Remove
@@ -460,7 +462,8 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
**Lifetime cap** (`TRIPLEC_MAX_LIFETIME_MINUTES`, advisory — sudo can kill it): the idle watcher
(started when idle stop *or* a non-zero cap is set) pushes best effort, records `lifetime` and
sends TERM; the hook exits 76 (`aws::tasks::LIFETIME_EXIT_CODE` → `StopKind::LifetimeCap` →
`lifetime` toast).
`lifetime` toast). HostSection shows a non-zero cap ("stops workspaces after N h (advisory)") from
`aws_environment_max_hours` (reads the environment record; `None` when it can't, never an error).
The idle watcher runs as root under a supervisor and signals the
entrypoint's own PID (not PID 1, which is docker-init), so idle and ECS stops share one trap.
Idle = the agent's `last_activity_unix` older than N minutes (open-but-silent attaches/tunnels
@@ -481,14 +484,24 @@ docker exec stdout → tokio task → emit("terminal-output-{sessionId}") → li
connects at once never mix) and runs `triple-c-apply-connect <nonce>`: CA install as root, SSH merge and git
credential helper **as `claude`** (root never walks a live `~/.ssh`), `/run/triple-c/connected`,
then a background re-clone of `failed` repos only (GIT_TOKEN in that clone's env only). The
first clone waits up to 5 min for `connected` (`aws_wait_connect`). Terminals the app opens add
first clone waits up to 5 min for `connected` (`aws_wait_connect`) — when there are repos **or a
setup script** (the script runs after the clone and needs the CA, SSH and Git credentials). The
CA files are swapped in (`connect-ca.new` → `connect-ca`, old removed last), so a failed move
keeps the CA installed before. Terminals the app opens add
the pairs to their own `ExecSpec.env` (`aws_host::terminal_env`, pairs only — no file read);
nothing reaches the agent's snapshot, so cron/scheduled jobs and the setup script never get them.
A failed push is a `workspace-warning`. Hybrid/EFS do **not** link `~/.ssh` to EFS under
copy-at-connect (R6: keys vanish with the task). When a copy-at-connect start finds the secret
already there (CreateSecret's ResourceExists; a new project's secret is never read first) and it
`holds_credentials`, it is force-deleted and created again (R7: `PutSecretValue` would keep the
old values as AWSPREVIOUS); `TRIPLE_C_CUSTOM_ENV` is left out too.
old values as AWSPREVIOUS); `TRIPLE_C_CUSTOM_ENV` is left out too. A replace whose re-create
times out (AWS still finishing the forced delete) leaves no secret; every secret write retries
while the name is pending deletion (≤ 30 s), then says to start again in a minute.
**Copy-at-connect limits** (also listed in HostSection's notes): there is no corporate CA until
the first connect (Claude Code's self-update may fail behind a TLS-inspecting proxy until then);
SSH keys, a Git token or variables removed from the project stay in the running task until it
stops (a connect only adds/overwrites them; a removed CA does go at the next connect); the setup script is not re-run
after a later connect's re-clone of a failed repo.
The re-clone closes the apply lock's fd (a later connect never waits for it); `--prepare` takes it.
The functions both scripts use live in `container/entrypoint-lib.sh`
(`/usr/local/lib/triple-c/`), sourced by the entrypoint first; it only defines things.
+1
View File
@@ -21,6 +21,7 @@
"allow-check-unsaved-work",
"allow-aws-task-log",
"allow-aws-workspace-status",
"allow-aws-environment-max-hours",
"allow-remove-aws-resources",
"allow-rebuild-project-container",
"allow-reconcile-project-statuses",
+1 -1
View File
@@ -1 +1 @@
{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token command without any pre-configured scope.","commands":{"allow":["cancel_claude_token"],"deny":[]}},"allow-cancel-marketplace-gh-login":{"identifier":"allow-cancel-marketplace-gh-login","description":"Enables the cancel_marketplace_gh_login cLine truncated
{"__app-acl__":{"default_permission":null,"permissions":{"allow-acquire-claude-token":{"identifier":"allow-acquire-claude-token","description":"Enables the acquire_claude_token command without any pre-configured scope.","commands":{"allow":["acquire_claude_token"],"deny":[]}},"allow-add-aws-keys-connection":{"identifier":"allow-add-aws-keys-connection","description":"Enables the add_aws_keys_connection command without any pre-configured scope.","commands":{"allow":["add_aws_keys_connection"],"deny":[]}},"allow-add-aws-profile-connection":{"identifier":"allow-add-aws-profile-connection","description":"Enables the add_aws_profile_connection command without any pre-configured scope.","commands":{"allow":["add_aws_profile_connection"],"deny":[]}},"allow-add-marketplace":{"identifier":"allow-add-marketplace","description":"Enables the add_marketplace command without any pre-configured scope.","commands":{"allow":["add_marketplace"],"deny":[]}},"allow-add-marketplace-gh-host-account":{"identifier":"allow-add-marketplace-gh-host-account","description":"Enables the add_marketplace_gh_host_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_gh_host_account"],"deny":[]}},"allow-add-marketplace-token-account":{"identifier":"allow-add-marketplace-token-account","description":"Enables the add_marketplace_token_account command without any pre-configured scope.","commands":{"allow":["add_marketplace_token_account"],"deny":[]}},"allow-add-project":{"identifier":"allow-add-project","description":"Enables the add_project command without any pre-configured scope.","commands":{"allow":["add_project"],"deny":[]}},"allow-add-scheduled-task":{"identifier":"allow-add-scheduled-task","description":"Enables the add_scheduled_task command without any pre-configured scope.","commands":{"allow":["add_scheduled_task"],"deny":[]}},"allow-apply-marketplace-now":{"identifier":"allow-apply-marketplace-now","description":"Enables the apply_marketplace_now command without any pre-configured scope.","commands":{"allow":["apply_marketplace_now"],"deny":[]}},"allow-apply-settings-import":{"identifier":"allow-apply-settings-import","description":"Enables the apply_settings_import command without any pre-configured scope.","commands":{"allow":["apply_settings_import"],"deny":[]}},"allow-aws-connection-identity":{"identifier":"allow-aws-connection-identity","description":"Enables the aws_connection_identity command without any pre-configured scope.","commands":{"allow":["aws_connection_identity"],"deny":[]}},"allow-aws-connection-sso-login":{"identifier":"allow-aws-connection-sso-login","description":"Enables the aws_connection_sso_login command without any pre-configured scope.","commands":{"allow":["aws_connection_sso_login"],"deny":[]}},"allow-aws-cost-estimate":{"identifier":"allow-aws-cost-estimate","description":"Enables the aws_cost_estimate command without any pre-configured scope.","commands":{"allow":["aws_cost_estimate"],"deny":[]}},"allow-aws-environment-max-hours":{"identifier":"allow-aws-environment-max-hours","description":"Enables the aws_environment_max_hours command without any pre-configured scope.","commands":{"allow":["aws_environment_max_hours"],"deny":[]}},"allow-aws-policy-document":{"identifier":"allow-aws-policy-document","description":"Enables the aws_policy_document command without any pre-configured scope.","commands":{"allow":["aws_policy_document"],"deny":[]}},"allow-aws-sso-refresh":{"identifier":"allow-aws-sso-refresh","description":"Enables the aws_sso_refresh command without any pre-configured scope.","commands":{"allow":["aws_sso_refresh"],"deny":[]}},"allow-aws-task-log":{"identifier":"allow-aws-task-log","description":"Enables the aws_task_log command without any pre-configured scope.","commands":{"allow":["aws_task_log"],"deny":[]}},"allow-aws-workspace-status":{"identifier":"allow-aws-workspace-status","description":"Enables the aws_workspace_status command without any pre-configured scope.","commands":{"allow":["aws_workspace_status"],"deny":[]}},"allow-build-gateway-image":{"identifier":"allow-build-gateway-image","description":"Enables the build_gateway_image command without any pre-configured scope.","commands":{"allow":["build_gateway_image"],"deny":[]}},"allow-build-image":{"identifier":"allow-build-image","description":"Enables the build_image command without any pre-configured scope.","commands":{"allow":["build_image"],"deny":[]}},"allow-build-stt-image":{"identifier":"allow-build-stt-image","description":"Enables the build_stt_image command without any pre-configured scope.","commands":{"allow":["build_stt_image"],"deny":[]}},"allow-cancel-aws-deployment":{"identifier":"allow-cancel-aws-deployment","description":"Enables the cancel_aws_deployment command without any pre-configured scope.","commands":{"allow":["cancel_aws_deployment"],"deny":[]}},"allow-cancel-claude-token":{"identifier":"allow-cancel-claude-token","description":"Enables the cancel_claude_token cLine truncated
+1 -1
View File
@@ -1 +1 @@
{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate fielLine truncated
{"default":{"identifier":"default","description":"Default capabilities for Triple-C. Every entry here is an IPC command a compromised webview can call directly, so the set is an enumeration of what `app/src` actually invokes — plugin and core grants verified against tauri 2.11.0's `PLUGINS` table in tauri's own `build.rs` rather than assumed from a plugin's `default` set, app-command grants (the bare `allow-*` entries) cross-checked by this crate's `build.rs` against `generate_handler!`. `core:default` in particular is NOT used: it is an alias for `core:{path,event,window,webview,app,image,resources,menu,tray}:default`, and `core:image:default` carries `allow-from-path`, whose handler (`tauri-2.11.0/src/image/plugin.rs:41` → `src/image/mod.rs:96`) is a bare `std::fs::read(path)` with no scope mechanism of any kind. Nothing imports `@tauri-apps/api/image`, so the whole plugin is dropped rather than scoped — there is nothing to scope it with. `core:menu` and `core:tray` are dropped for the same reason (no menu, no tray icon); `core:window` and `core:path` because nothing imports them; `core:resources:allow-close` because no frontend value is a `Resource`; and `core:event`'s `allow-emit`/`allow-emit-to` because the frontend only ever *listens* — every emit in this app originates in Rust. Three notes on what is deliberately kept or accepted: (1) `core:webview:allow-internal-toggle-devtools` is not called by `app/src` at all — it is called by Tauri's own injected `toggle-devtools.js`, which binds Ctrl/Cmd+Shift+I. Both that script and the command behind it are `#[cfg(any(debug_assertions, feature = \"devtools\"))]`, so this grant is a `tauri dev` convenience that does not exist in a release bundle. (2) `opener:allow-open-url` is **gone**. It could not be narrowed by host — `TerminalView`'s `WebLinksAddon` opens links Claude printed inside the container, which are arbitrary by construction, so a host allowlist would have deleted the feature rather than bounded it — and it was carried here as an accepted residual risk: a compromised webview could make the OS open an attacker-chosen http(s) URL, an outbound channel. That risk is now closed rather than recorded. Every host-browser open in the app goes through the `open_url_external` command in `url_open.rs`, which exists because the AppImage environment leaks into a cold-launched browser on Linux (triple-c#34) and which re-validates the URL in Rust — scheme allowlist, no embedded credentials, no control characters, length cap, ASCII asserted before `execvp`. On macOS and Windows that command reaches the same plugin as before, via `OpenerExt::open_url`, whose desktop implementation calls `crate::open::open` directly and is therefore not gated by this file at all (`tauri-plugin-opener-2.5.3/src/lib.rs:60`). The plugin stays a dependency for exactly that reason; what is removed is the webview's ability to reach it without passing the Rust validation. (3) `drag:allow-start-drag` is **gone**, together with the OS drag-out it existed for. It could not be scoped — `tauri-plugin-drag` takes the item paths from the caller and has no scope mechanism, so a compromised webview could call `startDrag({ item: ['~/.ssh/id_rsa'] })` against any host path the user can read — and it was carried as an accepted residual risk for one gesture. Drag-out was held back for separate hardening (see branch `hold/disk-and-dragout`) and the plugin is no longer a dependency. Getting a file *out* of a container is either \"Back up container\" on the project's Overview tab, which archives a tree through the Docker API, or the Files tab's per-row \"Save to host…\", which copies one file; getting one *in* is a drop on the Terminal or the Files tab's \"Upload…\". None of the four touches this permission. The Files tab's two are worth separating out here, because they are the only host-path commands in the app whose dialog is opened by **Rust** rather than by the webview — `pick_save_path` and `pick_files_to_upload` in `commands/file_commands.rs` drive `tauri-plugin-dialog` from the backend, so a compromised webview can ask for a picker and nothing more: it cannot name a host path as an *input* to either command. Be precise about the limit of that claim — host paths do still travel outward in error text (`Failed to create /home/j/Documents/x.txt.triple-c-part-1a2b3c4d: Permission denied`), including canonicalized ones, which disclose symlink targets. That is accepted; the app already hands the webview the project paths. What is closed is the direction that mattered — the webview naming where bytes go. That is the shape an earlier revision of this file named as the honest one if the Files tab ever regained host I/O, and it is the shape it regained it in. The `dialog:allow-open` / `dialog:allow-save` grants below are therefore *not* what those two use; they remain for the frontend pickers in Add Project, the Config tab's workspace and access sections, the CA-certificate fielLine truncated
@@ -422,6 +422,12 @@
"const": "allow-aws-cost-estimate",
"markdownDescription": "Enables the aws_cost_estimate command without any pre-configured scope."
},
{
"description": "Enables the aws_environment_max_hours command without any pre-configured scope.",
"type": "string",
"const": "allow-aws-environment-max-hours",
"markdownDescription": "Enables the aws_environment_max_hours command without any pre-configured scope."
},
{
"description": "Enables the aws_policy_document command without any pre-configured scope.",
"type": "string",
@@ -1388,6 +1394,12 @@
"const": "deny-aws-cost-estimate",
"markdownDescription": "Denies the aws_cost_estimate command without any pre-configured scope."
},
{
"description": "Denies the aws_environment_max_hours command without any pre-configured scope.",
"type": "string",
"const": "deny-aws-environment-max-hours",
"markdownDescription": "Denies the aws_environment_max_hours command without any pre-configured scope."
},
{
"description": "Denies the aws_policy_document command without any pre-configured scope.",
"type": "string",
@@ -422,6 +422,12 @@
"const": "allow-aws-cost-estimate",
"markdownDescription": "Enables the aws_cost_estimate command without any pre-configured scope."
},
{
"description": "Enables the aws_environment_max_hours command without any pre-configured scope.",
"type": "string",
"const": "allow-aws-environment-max-hours",
"markdownDescription": "Enables the aws_environment_max_hours command without any pre-configured scope."
},
{
"description": "Enables the aws_policy_document command without any pre-configured scope.",
"type": "string",
@@ -1388,6 +1394,12 @@
"const": "deny-aws-cost-estimate",
"markdownDescription": "Denies the aws_cost_estimate command without any pre-configured scope."
},
{
"description": "Denies the aws_environment_max_hours command without any pre-configured scope.",
"type": "string",
"const": "deny-aws-environment-max-hours",
"markdownDescription": "Denies the aws_environment_max_hours command without any pre-configured scope."
},
{
"description": "Denies the aws_policy_document command without any pre-configured scope.",
"type": "string",
@@ -1625,6 +1625,24 @@ pub async fn aws_workspace_status(
crate::host::aws_host::workspace_status(&project).await
}
/// The lifetime cap (hours; 0 = none) of an AWS project's environment, read
/// from its record, for Host settings. `None` for a local project or when the
/// record can't be read; never an error.
#[tauri::command]
pub async fn aws_environment_max_hours(
project_id: String,
state: State<'_, AppState>,
) -> Result<Option<u32>, String> {
let Some(project) = state.projects_store.get(&project_id) else {
return Ok(None);
};
if !project.is_aws() {
return Ok(None);
}
let settings = state.settings_store.get();
Ok(crate::host::aws_host::environment_max_hours(&project, &settings).await)
}
#[tauri::command]
pub async fn stop_project_container(
project_id: String,
+16
View File
@@ -638,6 +638,22 @@ async fn project_sdk(project: &Project, settings: &AppSettings) -> Result<(Strin
Ok((host_id.to_string(), region, sdk))
}
/// The lifetime cap, in hours (0 = none), of the environment `project` runs
/// in, from its record (Q8: Host settings show it). `None` when it can't be
/// read — offline, denied, slow, or the environment is gone.
pub async fn environment_max_hours(project: &Project, settings: &AppSettings) -> Option<u32> {
let placement = project.aws_placement.as_ref()?;
let read = async {
let (_, region, sdk) = project_sdk(project, settings).await.ok()?;
let who = caller_identity(&sdk).await.ok()?;
read_environment(&SdkRuntimeApi::new(&sdk), &placement.environment, &who.account, &region)
.await
.ok()
};
let info = tokio::time::timeout(std::time::Duration::from_secs(10), read).await.ok()??;
Some(info.max_workspace_hours)
}
/// `ProjectHost::Aws::ensure_started`.
pub async fn ensure_started(
project: &Project,
+1
View File
@@ -554,6 +554,7 @@ pub fn run() {
commands::project_commands::check_unsaved_work,
commands::project_commands::aws_task_log,
commands::project_commands::aws_workspace_status,
commands::project_commands::aws_environment_max_hours,
commands::project_commands::remove_aws_resources,
commands::project_commands::rebuild_project_container,
commands::project_commands::reconcile_project_statuses,
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { cleanup, render, screen, fireEvent, waitFor, within } from "@testing-library/react";
import { act, cleanup, render, screen, fireEvent, waitFor, within } from "@testing-library/react";
import RuntimeSection from "./RuntimeSection";
import AccessSection from "./AccessSection";
import WorkspaceSection from "./WorkspaceSection";
@@ -12,6 +12,7 @@ import { useAppState } from "../../../../store/appState";
const OFF_BRIDGE: AuthBridgeStatus = { enabled: false, active_ports: [], conflicts: [] };
const removeAwsResources = vi.fn();
const awsCostEstimate = vi.fn(async (..._args: unknown[]) => null as unknown);
const awsEnvironmentMaxHours = vi.fn(async (_id: string) => 0 as number | null);
vi.mock("../../../../lib/tauri-commands", () => ({
getAuthBridgeStatus: vi.fn(async () => OFF_BRIDGE),
@@ -19,6 +20,7 @@ vi.mock("../../../../lib/tauri-commands", () => ({
inspectCaCertPath: vi.fn(async () => null),
removeAwsResources: (id: string, discard: boolean) => removeAwsResources(id, discard),
awsCostEstimate: (...args: unknown[]) => awsCostEstimate(...args),
awsEnvironmentMaxHours: (id: string) => awsEnvironmentMaxHours(id),
}));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => {}) }));
vi.mock("@tauri-apps/plugin-dialog", () => ({ open: vi.fn(async () => null) }));
@@ -323,7 +325,12 @@ describe("HostSection", () => {
p.aws = { ...p.aws!, secrets_delivery: "copy_at_connect", gateway_sidecar: false };
renderHost(p);
const note = screen.getByRole("note", { name: "Copied when you connect" });
expect(note).toHaveTextContent("Private repositories clone after you connect.");
expect(note).toHaveTextContent(
"Private repositories clone, and the setup script runs, after you connect (or after 5 minutes without).",
);
expect(note).toHaveTextContent(/Claude Code's self-update may fail until then/);
expect(note).toHaveTextContent("SSH keys, a Git token or variables you remove from the project stay in a running workspace until it stops.");
expect(note).toHaveTextContent(/not run again when a later connect re-clones/);
expect(note).toHaveTextContent(
"Scheduled jobs and the setup script never get the API keys or custom variables; Git and SSH work once the app has connected.",
);
@@ -345,6 +352,76 @@ describe("HostSection", () => {
);
});
it("saves the setup script on blur, and a blank one as none", async () => {
renderHost();
const box = screen.getByLabelText("Setup script");
expect(box.tagName).toBe("TEXTAREA");
expect(box.className).toContain("font-mono");
expect(box.className).not.toContain("focus:outline-none");
fireEvent.change(box, { target: { value: "sudo apt-get install -y jq\n" } });
expect(screen.getByText(/27 of 32,768 bytes/)).toBeInTheDocument();
fireEvent.blur(box);
await waitFor(() => expect(save).toHaveBeenCalledTimes(1));
expect(save.mock.calls[0][0].aws.setup_script).toBe("sudo apt-get install -y jq\n");
cleanup();
const p = awsProject();
p.aws = { ...p.aws!, setup_script: "echo hi" };
renderHost(p);
const again = screen.getByLabelText("Setup script");
expect(again).toHaveValue("echo hi");
fireEvent.change(again, { target: { value: " \n" } });
fireEvent.blur(again);
await waitFor(() => expect(save).toHaveBeenCalledTimes(2));
expect(save.mock.calls[1][0].aws.setup_script).toBeNull();
});
it("refuses a setup script over 32 KiB with the backend's message", () => {
renderHost();
const box = screen.getByLabelText("Setup script");
// 16,385 two-byte characters: 32,770 UTF-8 bytes.
fireEvent.change(box, { target: { value: "é".repeat(16_385) } });
fireEvent.blur(box);
expect(screen.getByRole("alert")).toHaveTextContent("The setup script is 32770 bytes; the limit is 32768");
expect(box).toHaveAttribute("aria-invalid", "true");
expect(save).not.toHaveBeenCalled();
});
it("says when and how the setup script runs", () => {
renderHost();
expect(screen.getByText(/Runs on every start, as claude, with bash -e/)).toBeInTheDocument();
expect(screen.getByText(/once the repositories are cloned/)).toBeInTheDocument();
expect(screen.getByText(/stopped after 30 minutes, and its output shows in the Overview/)).toBeInTheDocument();
expect(screen.queryByText(/never gets the API keys or custom variables/)).toBeNull();
cleanup();
const p = awsProject();
p.aws = { ...p.aws!, secrets_delivery: "copy_at_connect" };
renderHost(p);
expect(
screen.getByText(/the setup script waits for the app's first connect \(at most 5 minutes\) and never gets the API keys or custom variables/),
).toBeInTheDocument();
});
it("shows the environment's lifetime cap when it has one", async () => {
awsEnvironmentMaxHours.mockResolvedValueOnce(24);
renderHost();
expect(
await screen.findByText("This environment stops workspaces after 24 h (advisory)."),
).toBeInTheDocument();
expect(awsEnvironmentMaxHours).toHaveBeenCalledWith(awsProject().id);
cleanup();
for (const none of [0, null]) {
awsEnvironmentMaxHours.mockResolvedValueOnce(none);
renderHost();
await waitFor(() => expect(awsEnvironmentMaxHours).toHaveBeenCalled());
await act(async () => {});
expect(screen.queryByText(/stops workspaces after/)).toBeNull();
cleanup();
}
});
it("does not let the credentials setting change while the workspace runs", () => {
renderHost(awsProject(), true);
expect(screen.getByRole("radio", { name: "Copied when you connect" })).toBeDisabled();
@@ -9,6 +9,10 @@ import {
COPY_AT_CONNECT_SSH_NOTE,
COPY_AT_CONNECT_WARNINGS,
SECRETS_MANAGER_HINT,
SETUP_SCRIPT_COPY_AT_CONNECT_NOTE,
SETUP_SCRIPT_HINT,
MAX_SETUP_SCRIPT_BYTES,
setupScriptProblem,
EFS_HINT,
EPHEMERAL_WARNING,
FARGATE_CPUS,
@@ -25,7 +29,7 @@ import Button from "../../../ui/Button";
import Modal from "../../../ui/Modal";
import Toggle from "../../../ui/Toggle";
import SegmentedControl from "../../../ui/SegmentedControl";
import Field, { ConfigGroup, SwitchRow, inputClass, selectClass } from "../../../ui/Field";
import Field, { ConfigGroup, SwitchRow, inputClass, monoInputClass, selectClass } from "../../../ui/Field";
import RepoListEditor from "../../RepoListEditor";
import AwsCostEstimate from "../AwsCostEstimate";
@@ -57,6 +61,10 @@ export default function HostSection({ project, save, disabled }: Props) {
const [idle, setIdle] = useState(String(aws.idle_stop_minutes ?? DEFAULT_IDLE_MINUTES));
const [idleProblem, setIdleProblem] = useState<string | null>(null);
const [confirmRemoveResources, setConfirmRemoveResources] = useState(false);
const [setupScript, setSetupScript] = useState(aws.setup_script ?? "");
const [setupProblem, setSetupProblem] = useState<string | null>(null);
// The environment's advisory lifetime cap (Q8), from its record.
const [maxHours, setMaxHours] = useState<number | null>(null);
useEffect(() => {
setMemory(String(aws.memory_mib));
@@ -64,6 +72,28 @@ export default function HostSection({ project, save, disabled }: Props) {
setIdle(String(aws.idle_stop_minutes ?? DEFAULT_IDLE_MINUTES));
}, [aws.memory_mib, aws.ephemeral_gib, aws.idle_stop_minutes]);
useEffect(() => {
setSetupScript(aws.setup_script ?? "");
}, [aws.setup_script]);
const region = project.aws_placement?.region;
const environment = project.aws_placement?.environment;
useEffect(() => {
setMaxHours(null);
if (!project.host_id || !environment) return;
let cancelled = false;
// Best effort: an unreadable record just shows no cap line.
Promise.resolve()
.then(() => commands.awsEnvironmentMaxHours(project.id))
.then((h) => {
if (!cancelled) setMaxHours(h ?? null);
})
.catch(() => {});
return () => {
cancelled = true;
};
}, [project.id, project.host_id, region, environment]);
const saveAws = (patch: Partial<AwsWorkspaceConfig>) => save({ aws: { ...aws, ...patch } });
const hasResources = !!(
@@ -97,6 +127,16 @@ export default function HostSection({ project, save, disabled }: Props) {
if (ok && value !== aws.ephemeral_gib) void saveAws({ ephemeral_gib: value });
};
const commitSetupScript = () => {
const problem = setupScriptProblem(setupScript);
setSetupProblem(problem);
if (problem) return;
const value = setupScript.trim() === "" ? null : setupScript;
if (value !== (aws.setup_script ?? null)) void saveAws({ setup_script: value });
};
const setupBytes = new TextEncoder().encode(setupScript).length;
const commitIdle = () => {
const value = Number(idle);
const ok = Number.isInteger(value) && value >= 5 && value <= 1440;
@@ -125,6 +165,11 @@ export default function HostSection({ project, save, disabled }: Props) {
{project.aws_placement?.environment}
</dd>
</dl>
{maxHours !== null && maxHours > 0 && (
<p className="text-xs text-[var(--text-secondary)]">
This environment stops workspaces after {maxHours} h (advisory).
</p>
)}
<div className="flex flex-wrap gap-4">
<Field label="CPU">
@@ -413,6 +458,48 @@ export default function HostSection({ project, save, disabled }: Props) {
/>
</div>
<div className="pt-2 border-t border-[var(--border-color)]">
<Field
label="Setup script"
hint={
<>
{SETUP_SCRIPT_HINT}
{aws.secrets_delivery === "copy_at_connect" && <> {SETUP_SCRIPT_COPY_AT_CONNECT_NOTE}</>}
</>
}
>
{(id) => (
<>
<textarea
id={id}
value={setupScript}
disabled={disabled}
rows={8}
spellCheck={false}
placeholder={"sudo apt-get update\nsudo apt-get install -y jq"}
aria-invalid={setupProblem ? true : undefined}
aria-describedby={`${id}-size`}
onChange={(e) => setSetupScript(e.target.value)}
onBlur={commitSetupScript}
className={`${monoInputClass} min-h-[8rem] resize-y`}
/>
<p
id={`${id}-size`}
className={`mt-1 text-xs ${setupBytes > MAX_SETUP_SCRIPT_BYTES ? "text-[var(--error)]" : "text-[var(--text-secondary)]"}`}
>
{setupBytes.toLocaleString("en-US")} of {MAX_SETUP_SCRIPT_BYTES.toLocaleString("en-US")} bytes
(32 KiB, UTF-8)
</p>
</>
)}
</Field>
{setupProblem && (
<p role="alert" className="mt-1 text-xs text-[var(--error)]">
{setupProblem}
</p>
)}
</div>
<div className="pt-2 border-t border-[var(--border-color)] flex flex-wrap items-center gap-2">
<Button
size="md"
+24 -1
View File
@@ -146,9 +146,32 @@ export const EFS_HINT = "Everything in /workspace survives a stop; git and build
export const COPY_AT_CONNECT_HINT =
"API keys, the Git token, custom environment variables and the SSH and CA files are not stored in AWS: Triple-C copies them into the running workspace each time it connects.";
export const COPY_AT_CONNECT_WARNINGS = [
"Private repositories clone after you connect.",
"Private repositories clone, and the setup script runs, after you connect (or after 5 minutes without).",
"Scheduled jobs and the setup script never get the API keys or custom variables; Git and SSH work once the app has connected.",
"Until the first connect the workspace has no corporate CA: behind a TLS-inspecting proxy, Claude Code's self-update may fail until then.",
"SSH keys, a Git token or variables you remove from the project stay in a running workspace until it stops.",
"The setup script is not run again when a later connect re-clones a repository that failed.",
];
/** Mirrors Rust `MAX_SETUP_SCRIPT_BYTES` (UTF-8 bytes). */
export const MAX_SETUP_SCRIPT_BYTES = 32_768;
/** Why `script` can't be saved, or null. Mirrors (and words like) Rust
* `validate_aws_workspace`'s setup-script checks. */
export function setupScriptProblem(script: string): string | null {
const bytes = new TextEncoder().encode(script).length;
if (bytes > MAX_SETUP_SCRIPT_BYTES) {
return `The setup script is ${bytes} bytes; the limit is ${MAX_SETUP_SCRIPT_BYTES}`;
}
if (script.includes("\0")) return "The setup script must not contain NUL characters";
return null;
}
/** What the setup script is, under its editor (phase 6 Q3). */
export const SETUP_SCRIPT_HINT =
"Runs on every start, as claude, with bash -e in /workspace once the repositories are cloned. It is stopped after 30 minutes, and its output shows in the Overview's start-up card. claude can use sudo (apt-get install …).";
export const SETUP_SCRIPT_COPY_AT_CONNECT_NOTE =
"With credentials copied when you connect, the setup script waits for the app's first connect (at most 5 minutes) and never gets the API keys or custom variables.";
/** Hybrid/EFS under copy-at-connect (ruling R6): ~/.ssh stays off EFS. */
export const COPY_AT_CONNECT_SSH_NOTE =
"~/.ssh is not kept on EFS: SSH keys copied in, or made in the workspace, are gone when it stops. Keys an earlier start left in /mnt/triple-c-home/.ssh stay there until you remove them.";
+4
View File
@@ -42,6 +42,10 @@ export const awsTaskLog = (projectId: string, limit: number) =>
* idle workspace up). */
export const awsWorkspaceStatus = (projectId: string) =>
invoke<WorkspaceStatus | null>("aws_workspace_status", { projectId });
/** The project's environment's advisory lifetime cap in hours (0 = none);
* null when it can't be read. Never rejects for a missing project. */
export const awsEnvironmentMaxHours = (projectId: string) =>
invoke<number | null>("aws_environment_max_hours", { projectId });
export const removeAwsResources = (projectId: string, discardData: boolean) =>
invoke<Project>("remove_aws_resources", { projectId, discardData });
export const rebuildProjectContainer = (projectId: string) =>