Add approval mode selection
CI / Rust Checks (push) Successful in 5m35s
CI / UI Checks (push) Successful in 5s
CI / Deployment Manifests (push) Successful in 2s
CI / Frontend E2E (push) Successful in 3m28s
CI / Deploy (push) Successful in 1m38s

This commit is contained in:
github-ops
2026-06-27 07:55:38 +00:00
parent 2b2ff92146
commit 700a684257
15 changed files with 425 additions and 31 deletions
+32 -15
View File
@@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc};
use async_trait::async_trait;
use crank_registry::PostgresPoolConfig;
use sqlx::{
PgPool,
PgPool, Row,
postgres::{PgConnectOptions, PgPoolOptions},
query,
};
@@ -17,6 +17,7 @@ pub struct SessionState {
pub id: String,
pub protocol_version: String,
pub initialized: bool,
pub supports_elicitation: bool,
pub workspace_slug: String,
pub agent_slug: String,
pub created_at: OffsetDateTime,
@@ -37,6 +38,7 @@ pub trait TransportSessionStore: Send + Sync {
protocol_version: &str,
workspace_slug: &str,
agent_slug: &str,
supports_elicitation: bool,
now: OffsetDateTime,
expires_at: Option<OffsetDateTime>,
) -> Result<String, SessionStoreError>;
@@ -100,6 +102,7 @@ impl TransportSessionStore for InMemorySessionStore {
protocol_version: &str,
workspace_slug: &str,
agent_slug: &str,
supports_elicitation: bool,
now: OffsetDateTime,
expires_at: Option<OffsetDateTime>,
) -> Result<String, SessionStoreError> {
@@ -112,6 +115,7 @@ impl TransportSessionStore for InMemorySessionStore {
id: session_id.clone(),
protocol_version: protocol_version.to_owned(),
initialized: false,
supports_elicitation,
workspace_slug: workspace_slug.to_owned(),
agent_slug: agent_slug.to_owned(),
created_at: now,
@@ -169,6 +173,7 @@ impl TransportSessionStore for PostgresTransportSessionStore {
protocol_version: &str,
workspace_slug: &str,
agent_slug: &str,
supports_elicitation: bool,
now: OffsetDateTime,
expires_at: Option<OffsetDateTime>,
) -> Result<String, SessionStoreError> {
@@ -178,17 +183,19 @@ impl TransportSessionStore for PostgresTransportSessionStore {
id,
protocol_version,
initialized,
supports_elicitation,
workspace_slug,
agent_slug,
created_at,
updated_at,
expires_at
) values (
$1, $2, false, $3, $4, $5::timestamptz, $5::timestamptz, $6::timestamptz
$1, $2, false, $3, $4, $5, $6::timestamptz, $6::timestamptz, $7::timestamptz
)",
)
.bind(&session_id)
.bind(protocol_version)
.bind(supports_elicitation)
.bind(workspace_slug)
.bind(agent_slug)
.bind(now)
@@ -203,20 +210,21 @@ impl TransportSessionStore for PostgresTransportSessionStore {
}
async fn get(&self, session_id: &str) -> Result<Option<SessionState>, SessionStoreError> {
let row = sqlx::query!(
let row = sqlx::query(
"select
id,
protocol_version,
initialized,
supports_elicitation,
workspace_slug,
agent_slug,
created_at as \"created_at!: OffsetDateTime\",
updated_at as \"updated_at!: OffsetDateTime\",
expires_at as \"expires_at: OffsetDateTime\"
created_at,
updated_at,
expires_at
from mcp_transport_sessions
where id = $1",
session_id,
)
.bind(session_id)
.fetch_optional(&self.pool)
.await
.map_err(|error| SessionStoreError {
@@ -224,14 +232,15 @@ impl TransportSessionStore for PostgresTransportSessionStore {
})?;
let Some(session) = row.map(|row| SessionState {
id: row.id,
protocol_version: row.protocol_version,
initialized: row.initialized,
workspace_slug: row.workspace_slug,
agent_slug: row.agent_slug,
created_at: row.created_at,
updated_at: row.updated_at,
expires_at: row.expires_at,
id: row.get("id"),
protocol_version: row.get("protocol_version"),
initialized: row.get("initialized"),
supports_elicitation: row.get("supports_elicitation"),
workspace_slug: row.get("workspace_slug"),
agent_slug: row.get("agent_slug"),
created_at: row.get("created_at"),
updated_at: row.get("updated_at"),
expires_at: row.get("expires_at"),
}) else {
return Ok(None);
};
@@ -291,6 +300,7 @@ async fn apply_postgres_migrations(pool: &PgPool) -> Result<(), SessionStoreErro
id text primary key,
protocol_version text not null,
initialized boolean not null default false,
supports_elicitation boolean not null default false,
workspace_slug text not null,
agent_slug text not null,
created_at timestamptz not null,
@@ -304,6 +314,13 @@ async fn apply_postgres_migrations(pool: &PgPool) -> Result<(), SessionStoreErro
details: error.to_string(),
})?;
query("alter table mcp_transport_sessions add column if not exists supports_elicitation boolean not null default false")
.execute(pool)
.await
.map_err(|error| SessionStoreError {
details: error.to_string(),
})?;
query(
"alter table mcp_transport_sessions add column if not exists expires_at timestamptz null",
)