Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions TODO_TODAY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TODO

What is open as of 2026-11-17 (nightly at 2.16.8, stable at 2.3.0). Security
What is open as of 2026-11-19 (nightly at 2.20.x, stable at 2.3.0). Security
items live in `TODO_SECURITY.md`.

## v3
Expand All @@ -19,13 +19,15 @@ release with a freeze and a test pass, not a plain promote. In order:
v3 build through the updater. Connections, keychain passwords,
settings, query history, notebooks and Pro all have to survive. On
macOS, Windows and Linux: the updater is what breaks first.
- [ ] **AI access levels for built-in models.** The Read only / Read & write
- [x] **AI access levels for built-in models.** Done in 2.20.4: every
execute_sql is classified by `access.rs` and refused above the level.
Was: The Read only / Read & write
control exists for local agents only (enforced by the MCP server).
Built-in models (Stroke Free, API keys) can run writes, asking only
before destructive ones. Enforce a level in `AiChat`'s `execute_sql`
with the same classifier as `src-tauri/src/mcp/access.rs`, then show
the control.
- [ ] **echarts 6** (PR #14): clears the echarts XSS advisory; the charts need
- [x] **echarts 6** (on 6.1.0, audit clean): clears the echarts XSS advisory; the charts need
testing.
- [ ] **Real hardware.** Windows: theme switching and zoom without flicker,
Alt+K in the SQL editor, the title bar with the sidebar on the right,
Expand All @@ -49,18 +51,19 @@ release with a freeze and a test pass, not a plain promote. In order:

## Next up

- [ ] **Layout control.** Three buttons in the title bar for the sidebar (⌘B),
- [x] **Layout control.** Dropped; the SQL results bottom/right switch
replaced it (2.19.x). Was: Three buttons in the title bar for the sidebar (⌘B),
the terminal panel (⌘J) and the docked AI panel (⌘⌥B), the open edge
filled. Built on the `layout-and-dashboard` branch; check it in the
running app on every OS before merging.
- [ ] **Dashboard tab redesign.** A 12-column grid of chart cards, each with a
- [x] **Dashboard tab redesign.** Shipped, plus a dashboard window. Was: A 12-column grid of chart cards, each with a
status dot, refresh, an auto-refresh interval, a title and its error on
the card. Resize and rearrange cards, add one from any saved query, and
save the layout.
- [ ] **Admin metrics page** on stroke.click, for me only: sign-ups, active
trials, trial-to-Pro conversion, revenue, downloads, active devices,
app versions in use, countries, backups and sponsors, over time.
- [ ] **Local database servers.** Postgres, MySQL and Redis side by side in
- [x] **Local database servers.** Shipped as their own window. Was: Postgres, MySQL and Redis side by side in
any version, with Start, Stop, the port and Open, per server on Docker
or as native binaries; Homebrew services listed too.

Expand Down
11 changes: 11 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,17 @@ pub async fn share_execute_sql(state: Db<'_>, sql: String, read_only: bool) -> R
crate::mcp::tools::call_tool(&conn, "execute_sql", &serde_json::json!({ "sql": sql, "max_rows": 1000 }), read_only).await
}

/// The access level a script needs on the open connection (0 read, 1 read &
/// write, 2 modify schema, 3 dangerous), by the classifier the MCP server
/// enforces. The built-in AI chat checks it before running a statement, so
/// its access setting holds the same way a local agent's does.
#[tauri::command]
pub async fn sql_access_level(state: Db<'_>, sql: String) -> Result<u8, String> {
use crate::mcp::access;
let dialect = require_conn(&state).map(|c| access::Dialect::for_driver(c.driver())).unwrap_or(access::Dialect::Sql);
Ok(access::script_level_in(dialect, &sql))
}

#[tauri::command]
pub async fn pg_execute_sql_multi(
state: Db<'_>,
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ pub fn run() {
commands::read_file,
commands::open_new_window,
commands::open_dashboard_window,
commands::sql_access_level,
launch::take_open_request,
commands::reveal_window,
commands::restart_app,
Expand Down
9 changes: 9 additions & 0 deletions src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,15 @@ export async function cancelQuery(queryId) {
}

/** @param {string} sql @param {string} [queryId] */
/**
* The access level a script needs on the open connection: 0 read, 1 read &
* write, 2 modify schema, 3 dangerous (src-tauri/src/mcp/access.rs).
* @param {string} sql @returns {Promise<number>}
*/
export async function sqlAccessLevel(sql) {
return await inv('sql_access_level', { sql })
}

export async function executeSql(sql, queryId) {
if (isWriteSql(sql)) assertWritable('run that statement')
const _t0 = performance.now()
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/AgentComposerChips.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
max: 'The most reasoning the model allows.',
}

// Enforced by Stroke's MCP server (src-tauri/src/mcp/access.rs), not left
// to the model: a statement above the level is refused.
// Enforced, not left to the model: Stroke's MCP server refuses a local
// agent's statement above the level, and the built-in chat checks each
// execute_sql with the same classifier (src-tauri/src/mcp/access.rs).
const ACCESS = [
{ id: 'read', label: 'Read only', note: 'SELECT and EXPLAIN. Changes come back as SQL for you to run.', icon: Lock },
{ id: 'write', label: 'Read & write', note: 'Inserts, and updates or deletes with a WHERE clause.', icon: PenLine },
Expand Down
45 changes: 38 additions & 7 deletions src/lib/components/AiChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import { Input } from "$lib/components/ui/input/index.js";
import { Label } from "$lib/components/ui/label/index.js";
import { cn } from "$lib/utils.js";
import { executeSql, executeSqlOnConnection, aiWebSearch, aiFetchPage, saveExportAs, agentStart, agentSend, agentInterrupt, agentStop } from "$lib/api.js";
import { sqlAccessLevel, executeSql, executeSqlOnConnection, aiWebSearch, aiFetchPage, saveExportAs, agentStart, agentSend, agentInterrupt, agentStop } from "$lib/api.js";
import { queryLanguageFor, sampleQuery, describeFromSample } from "$lib/ai-query-languages.js";
import {
profileAgent,
Expand Down Expand Up @@ -429,6 +429,9 @@
convList = await listConversations(chatMatch ?? (connectionId || undefined));
}

/** Access levels as the backend ranks them (src-tauri/src/mcp/access.rs). @type {Record<string, number>} */
const ACCESS_RANK = { read: 0, write: 1, modify: 2, dangerous: 3 };
const ACCESS_NAMES = ["Read only", "Read & write", "Modify schema", "Dangerous"];
/** Engines where execute_sql's `database` argument can open another database by name. */
const CROSS_DB_ENGINES = new Set(["postgres", "cockroachdb", "mysql", "mariadb", "mssql", "clickhouse"]);

Expand Down Expand Up @@ -2386,7 +2389,17 @@
planSteps: true,
});
const ci = $aiChatParams.customInstructions.trim();
turnSystemPrompt = ci ? `${ci}\n\n---\n\n${basePrompt}` : basePrompt;
// What execute_sql will run, so the model proposes SQL instead of
// sending statements the access level refuses.
const rank = isReadOnly() ? 0 : ACCESS_RANK[$agentPrefs.access] ?? 0;
const accessNote = `=== ACCESS ===\nThe user set this chat to "${ACCESS_NAMES[rank]}". ${[
"execute_sql runs reads only (SELECT, WITH, EXPLAIN, SHOW). For anything that changes data or schema, give the SQL in a ```sql block for the user to run, and say they can raise the access level under the composer.",
"execute_sql runs reads, INSERTs, and UPDATEs or DELETEs with a WHERE clause. Schema changes go in a ```sql block for the user.",
"execute_sql runs reads, writes with a WHERE clause, and CREATE, ALTER and indexes. Nothing that drops or truncates: give that SQL in a ```sql block.",
"execute_sql runs anything; destructive statements still ask the user first.",
][rank]}`;
const withAccess = `${basePrompt}\n\n${accessNote}`;
turnSystemPrompt = ci ? `${ci}\n\n---\n\n${withAccess}` : withAccess;

// Smart context management: sliding window + optional summarization.
// managedLen marks where new messages start after the turn - used to append to rawApiHistory.
Expand Down Expand Up @@ -3280,6 +3293,28 @@
});
return;
}
// The chat's access level, held the way the MCP server holds a local
// agent's: the statement is classified on the engine it would run
// on, and anything above the level isn't run.
{
const allowed = ACCESS_RANK[$agentPrefs.access] ?? 0;
/** @type {number} */
let needs = 3;
try { needs = Number(await sqlAccessLevel(sql)); } catch { /* unknown: treat as the highest */ }
if (needs > allowed) {
const now = Date.now();
const level = ACCESS_NAMES[needs] ?? "Dangerous";
addBuiltinStep({ id: String(call.id || uid()), tool: "execute_sql", op: "query", detail: sql, status: "error", error: `Not run: needs "${level}" access, and the chat is set to "${ACCESS_NAMES[allowed]}".`, startedAt: now, endedAt: now });
apiHistory.push({
role: "tool",
tool_call_id: call.id,
content: JSON.stringify({
error: `Refused: this needs "${level}" access and the chat is set to "${ACCESS_NAMES[allowed]}". Do not retry it. Give the user the SQL in a \`\`\`sql block to review and run, or ask them to raise the access level under the composer.`,
}),
});
return;
}
}
if (isDestructiveSql(sql)) {
const confirmed = await waitForConfirm(sql);
if (!confirmed) {
Expand Down Expand Up @@ -4842,11 +4877,7 @@
</span>
{/if}
<span class="flex-1"></span>
{#if profileAgent($aiSettings)}
<AgentComposerChips agent={profileAgent($aiSettings) ?? ""} part="access" />
{:else if $readOnlyMode}
<span class="flex shrink-0 items-center gap-1.5"><Lock class="size-3.5 shrink-0" />Read only</span>
{/if}
<AgentComposerChips agent={profileAgent($aiSettings) ?? ""} part="access" />
</div>
{/snippet}

Expand Down
Loading
Loading