mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
feat(core): keep MCP tools through reconnects, failed starts and sign-ins, and show disconnected servers
This commit is contained in:
parent
3a33b3e9eb
commit
d2b1b9c9aa
34 changed files with 895 additions and 138 deletions
|
|
@ -12,7 +12,7 @@ import { Switch } from "@opencode/ui/switch"
|
|||
import { TruncatedText } from "@opencode/ui/truncated-text"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { type McpController, useMcpController } from "@/providers/connect/mcp"
|
||||
import { mcpDetailAttempt, mcpDetailView, mcpRowView } from "@/providers/connect/mcp-machine"
|
||||
import { mcpDetailAttempt, mcpDetailView, mcpError, mcpRowView } from "@/providers/connect/mcp-machine"
|
||||
import { usePlatform } from "@/runtime/platform/platform"
|
||||
import { showToast } from "@/shell/notifications/toast"
|
||||
import "@/shell/commands/dialog.css"
|
||||
|
|
@ -21,6 +21,7 @@ import "@/shell/search-list.css"
|
|||
const statusLabels = {
|
||||
connected: "mcp.status.connected",
|
||||
failed: "mcp.status.failed",
|
||||
disconnected: "mcp.status.disconnected",
|
||||
needs_auth: "mcp.status.needs_auth",
|
||||
disabled: "mcp.status.disabled",
|
||||
} as const
|
||||
|
|
@ -91,11 +92,11 @@ export function McpDialog(props: {
|
|||
const toggle = (name: string, enabled: boolean) =>
|
||||
props.mcp.dispatch({ type: "toggle.requested", name, enabled, status: statusOf(name)?.status })
|
||||
|
||||
// Like the TUI, a failed server's row opens its error; retrying and disabling happen there.
|
||||
// Like the TUI, a failed or disconnected server's row opens its error; retrying and disabling happen there.
|
||||
const select = (name: string) => {
|
||||
const status = statusOf(name)
|
||||
|
||||
if (status?.status !== "failed") return toggle(name, status?.status !== "connected")
|
||||
if (mcpError(status) === undefined) return toggle(name, status?.status !== "connected")
|
||||
props.mcp.dispatch({ type: "detail.opened", name, loaded: true, status, focus: true })
|
||||
}
|
||||
|
||||
|
|
@ -241,11 +242,7 @@ export function McpDialog(props: {
|
|||
const server = () => servers().find((entry) => entry.name === item().name)
|
||||
const status = () => server()?.status
|
||||
|
||||
const error = () => {
|
||||
const current = status()
|
||||
|
||||
return current?.status === "failed" ? current.error : undefined
|
||||
}
|
||||
const error = () => mcpError(status())
|
||||
|
||||
// The switch would start sign-in anyway, so an auth-gated server shows that action instead.
|
||||
const signIn = () => status()?.status === "needs_auth" && !!server()?.integrationID
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const MCP_TOGGLE_TIMEOUT_MS = 60_000
|
|||
/** An MCP server's status, as the server lists it. */
|
||||
export type McpServerStatus =
|
||||
| { readonly status: "connected" | "pending" | "disabled" }
|
||||
| { readonly status: "failed" | "needs_auth"; readonly error: string }
|
||||
| { readonly status: "failed" | "disconnected" | "needs_auth"; readonly error: string }
|
||||
|
||||
/** A sign-in that also accepts the redirect URL pasted from the browser. */
|
||||
export type McpSignIn = {
|
||||
|
|
@ -18,7 +18,7 @@ export type McpSignIn = {
|
|||
/** One server's connect, disconnect or sign-in in flight. */
|
||||
export type McpToggle = { readonly name: string; readonly attempt: number }
|
||||
|
||||
/** The MCPs dialog's inline error view of one failed server. */
|
||||
/** The MCPs dialog's inline error view of one failed or disconnected server. */
|
||||
export type McpDetailState =
|
||||
| { readonly status: "closed" }
|
||||
/** Opened on a server before the server list loaded. */
|
||||
|
|
@ -168,6 +168,11 @@ export function mcpDetailAttempt(state: McpState) {
|
|||
return { attempt: state.detail.attempt, name: state.detail.name }
|
||||
}
|
||||
|
||||
/** The error a failed or disconnected server shows; a sign-in prompt is not one. */
|
||||
export function mcpError(status: McpServerStatus | undefined) {
|
||||
return status?.status === "failed" || status?.status === "disconnected" ? status.error : undefined
|
||||
}
|
||||
|
||||
export function isMcpToggling(state: McpState) {
|
||||
return state.status === "active" && state.toggles.length > 0
|
||||
}
|
||||
|
|
@ -223,12 +228,14 @@ function step(state: Live, event: Exclude<McpEvent, { type: "disposed" }>): McpT
|
|||
const status = event.status
|
||||
|
||||
if (detail.status === "opening") {
|
||||
if (status?.status !== "failed") return { state: { ...state, detail: { status: "closed" } }, effects: NONE }
|
||||
const error = mcpError(status)
|
||||
|
||||
if (error === undefined) return { state: { ...state, detail: { status: "closed" } }, effects: NONE }
|
||||
|
||||
return {
|
||||
state: {
|
||||
...state,
|
||||
detail: { status: "open", attempt: detail.attempt, name: detail.name, error: status.error, copied: undefined },
|
||||
detail: { status: "open", attempt: detail.attempt, name: detail.name, error, copied: undefined },
|
||||
},
|
||||
effects: NONE,
|
||||
}
|
||||
|
|
@ -242,9 +249,11 @@ function step(state: Live, event: Exclude<McpEvent, { type: "disposed" }>): McpT
|
|||
}
|
||||
|
||||
// A retry stays open while it connects or asks to sign in, and a new failure replaces the error in place.
|
||||
if (status.status !== "failed" || status.error === detail.error) return { state, effects: NONE }
|
||||
const error = mcpError(status)
|
||||
|
||||
return { state: { ...state, detail: { ...detail, error: status.error } }, effects: NONE }
|
||||
if (error === undefined || error === detail.error) return { state, effects: NONE }
|
||||
|
||||
return { state: { ...state, detail: { ...detail, error } }, effects: NONE }
|
||||
}
|
||||
|
||||
function opened(state: Live, event: Extract<McpEvent, { type: "detail.opened" }>): McpTransition {
|
||||
|
|
@ -256,14 +265,16 @@ function opened(state: Live, event: Extract<McpEvent, { type: "detail.opened" }>
|
|||
effects: NONE,
|
||||
}
|
||||
|
||||
// Only a failed server has an error to show.
|
||||
if (event.status?.status !== "failed") return { state: { ...state, detail: { status: "closed" } }, effects: NONE }
|
||||
const error = mcpError(event.status)
|
||||
|
||||
// Only a failed or disconnected server has an error to show.
|
||||
if (error === undefined) return { state: { ...state, detail: { status: "closed" } }, effects: NONE }
|
||||
|
||||
return {
|
||||
state: {
|
||||
...state,
|
||||
issued: attempt,
|
||||
detail: { status: "open", attempt, name: event.name, error: event.status.error, copied: undefined },
|
||||
detail: { status: "open", attempt, name: event.name, error, copied: undefined },
|
||||
},
|
||||
effects: event.focus ? [{ type: "focus-detail", attempt }] : NONE,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { useDialog } from "@opencode/ui/context/dialog"
|
|||
import { uuid } from "@opencode/util/uuid"
|
||||
import {
|
||||
createMcpState,
|
||||
mcpError,
|
||||
type McpEffect,
|
||||
type McpEvent,
|
||||
type McpServerStatus,
|
||||
|
|
@ -263,7 +264,9 @@ function createMcpController(
|
|||
// A successful HTTP response can still leave the MCP connection in a failed state.
|
||||
const status = current?.status
|
||||
|
||||
if (status?.status === "failed") return { type: "toggle.failed", name, attempt, error: status.error, server: true }
|
||||
const error = mcpError(status)
|
||||
|
||||
if (error !== undefined) return { type: "toggle.failed", name, attempt, error, server: true }
|
||||
|
||||
return { type: "toggle.succeeded", name, attempt }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,6 +461,7 @@ export const dict = {
|
|||
|
||||
"mcp.status.connected": "Connected",
|
||||
"mcp.status.failed": "Failed",
|
||||
"mcp.status.disconnected": "Disconnected",
|
||||
"mcp.status.needs_auth": "Needs auth",
|
||||
"mcp.status.disabled": "Disabled",
|
||||
"mcp.auth.interactiveForm": "MCP server {{name}} requires an interactive authentication form",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { ServerConnection } from "@/runtime/server/registry"
|
|||
import { formatServerError } from "@/runtime/server/errors"
|
||||
import { showToast } from "@/shell/notifications/toast"
|
||||
import { useMcpController } from "@/providers/connect/mcp"
|
||||
import { mcpRowView } from "@/providers/connect/mcp-machine"
|
||||
import { mcpError, mcpRowView } from "@/providers/connect/mcp-machine"
|
||||
import { DialogMcp } from "@/providers/connect/mcp-dialog"
|
||||
import { ExtensionPlugins } from "@/runtime/plugin/extension-plugins"
|
||||
import { ExternalLink } from "@/runtime/platform/external-link"
|
||||
|
|
@ -47,6 +47,7 @@ import "@/shell/search-list.css"
|
|||
const statusLabels = {
|
||||
connected: "mcp.status.connected",
|
||||
failed: "mcp.status.failed",
|
||||
disconnected: "mcp.status.disconnected",
|
||||
needs_auth: "mcp.status.needs_auth",
|
||||
disabled: "mcp.status.disabled",
|
||||
} as const
|
||||
|
|
@ -266,7 +267,7 @@ export const SettingsExtensions: Component<{
|
|||
</Show>
|
||||
</div>
|
||||
<div class="settings-extension-trailing">
|
||||
<Show when={item.status.status === "failed"}>
|
||||
<Show when={mcpError(item.status) !== undefined}>
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost-muted"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ const ExtensionCard: Component<{ children: JSX.Element }> = (props) => (
|
|||
const statusLabels = {
|
||||
connected: "mcp.status.connected",
|
||||
failed: "mcp.status.failed",
|
||||
disconnected: "mcp.status.disconnected",
|
||||
needs_auth: "mcp.status.needs_auth",
|
||||
disabled: "mcp.status.disabled",
|
||||
} as const
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@
|
|||
color: var(--icon-critical-base);
|
||||
}
|
||||
|
||||
.mcp-status-dot[data-status="disconnected"],
|
||||
.mcp-status-dot[data-status="needs_auth"] {
|
||||
color: var(--icon-warning-base);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1567,6 +1567,11 @@ pub fn experimental_blob_get(input: &ExperimentalBlobGetInput) -> Call<bytes::By
|
|||
call
|
||||
}
|
||||
|
||||
/// `GET /api/experimental/browser/tunnel` (`browser.tunnel`)
|
||||
pub fn experimental_browser_tunnel() -> Call<ExperimentalBrowserTunnelOutput> {
|
||||
Call::new("GET", "/api/experimental/browser/tunnel".to_owned(), Reply::Json, 200, &[400, 401, 403])
|
||||
}
|
||||
|
||||
/// `POST /api/experimental/automation` (`automation.create`)
|
||||
pub fn experimental_automation_create(
|
||||
input: &ExperimentalAutomationCreateInput,
|
||||
|
|
@ -1903,6 +1908,55 @@ pub fn experimental_push_settings_set(
|
|||
call
|
||||
}
|
||||
|
||||
/// `PUT /api/experimental/space/:space/:key` (`space.set`)
|
||||
pub fn experimental_space_set(input: &ExperimentalSpaceSetInput) -> Call<()> {
|
||||
let mut call = Call::new("PUT", String::new(), Reply::Empty, 204, &[400, 401]);
|
||||
call.path = format!("/api/experimental/space/{}/{}", call.param(&input.space), call.param(&input.key));
|
||||
call.object();
|
||||
call.field("value", &input.value);
|
||||
call
|
||||
}
|
||||
|
||||
/// `DELETE /api/experimental/space/:space/:key` (`space.delete`)
|
||||
pub fn experimental_space_delete(input: &ExperimentalSpaceDeleteInput) -> Call<()> {
|
||||
let mut call = Call::new("DELETE", String::new(), Reply::Empty, 204, &[400, 401]);
|
||||
call.path = format!("/api/experimental/space/{}/{}", call.param(&input.space), call.param(&input.key));
|
||||
call
|
||||
}
|
||||
|
||||
/// `GET /api/experimental/space/:space` (`space.sync`)
|
||||
pub fn experimental_space_sync(input: &ExperimentalSpaceSyncInput) -> Call<ExperimentalSpaceSyncOutput> {
|
||||
let mut call = Call::new("GET", String::new(), Reply::Json, 200, &[400, 401]);
|
||||
call.path = format!("/api/experimental/space/{}", call.param(&input.space));
|
||||
if let Some(value) = &input.cursor {
|
||||
call.query("cursor", value);
|
||||
}
|
||||
call
|
||||
}
|
||||
|
||||
/// `POST /api/experimental/space/subscribe` (`space.subscribe`)
|
||||
pub fn experimental_space_subscribe(input: &ExperimentalSpaceSubscribeInput) -> Call<()> {
|
||||
let mut call = Call::new("POST", "/api/experimental/space/subscribe".to_owned(), Reply::Empty, 204, &[400, 401]);
|
||||
call.object();
|
||||
call.field("stream", &input.stream);
|
||||
call.field("spaces", &input.spaces);
|
||||
call
|
||||
}
|
||||
|
||||
/// `POST /api/experimental/space/unsubscribe` (`space.unsubscribe`)
|
||||
pub fn experimental_space_unsubscribe(input: &ExperimentalSpaceUnsubscribeInput) -> Call<()> {
|
||||
let mut call = Call::new("POST", "/api/experimental/space/unsubscribe".to_owned(), Reply::Empty, 204, &[400, 401]);
|
||||
call.object();
|
||||
call.field("stream", &input.stream);
|
||||
call.field("spaces", &input.spaces);
|
||||
call
|
||||
}
|
||||
|
||||
/// `POST /api/experimental/space/reset` (`space.reset`)
|
||||
pub fn experimental_space_reset() -> Call<()> {
|
||||
Call::new("POST", "/api/experimental/space/reset".to_owned(), Reply::Empty, 204, &[400, 401])
|
||||
}
|
||||
|
||||
/// `GET /api/shell` (`list`)
|
||||
pub fn shell_list(input: &ShellListInput) -> Call<ShellListOutput> {
|
||||
let mut call = Call::new("GET", "/api/shell".to_owned(), Reply::Json, 200, &[400, 401, 404]);
|
||||
|
|
@ -2156,6 +2210,15 @@ pub fn experimental_usage_limits(input: &ExperimentalUsageLimitsInput) -> Call<E
|
|||
call
|
||||
}
|
||||
|
||||
/// `GET /api/experimental/flag` (`get`)
|
||||
pub fn experimental_flag_get(input: &ExperimentalFlagGetInput) -> Call<ExperimentalFlagGetOutput> {
|
||||
let mut call = Call::new("GET", "/api/experimental/flag".to_owned(), Reply::Json, 200, &[400, 401, 404]);
|
||||
if let Some(value) = &input.location {
|
||||
call.query("location", value);
|
||||
}
|
||||
call
|
||||
}
|
||||
|
||||
/// `GET /api/config` (`get`)
|
||||
pub fn config_get(input: &ConfigGetInput) -> Call<ConfigGetOutput> {
|
||||
let mut call = Call::new("GET", "/api/config".to_owned(), Reply::Json, 200, &[400, 401, 404]);
|
||||
|
|
@ -2985,6 +3048,7 @@ pub fn probe(name: &str, input: &serde_json::Value) -> Option<Result<Call<serde_
|
|||
"experimental.blob.get" => {
|
||||
Some((|| Ok(experimental_blob_get(&ExperimentalBlobGetInput { id: field(input, "id")? }).cast()))())
|
||||
}
|
||||
"experimental.browser.tunnel" => Some((|| Ok(experimental_browser_tunnel().cast()))()),
|
||||
"experimental.automation.create" => Some((|| {
|
||||
Ok(experimental_automation_create(&ExperimentalAutomationCreateInput {
|
||||
session_id: field(input, "sessionID")?,
|
||||
|
|
@ -3173,6 +3237,43 @@ pub fn probe(name: &str, input: &serde_json::Value) -> Option<Result<Call<serde_
|
|||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.set" => Some((|| {
|
||||
Ok(experimental_space_set(&ExperimentalSpaceSetInput {
|
||||
space: field(input, "space")?,
|
||||
key: field(input, "key")?,
|
||||
value: field(input, "value")?,
|
||||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.delete" => Some((|| {
|
||||
Ok(experimental_space_delete(&ExperimentalSpaceDeleteInput {
|
||||
space: field(input, "space")?,
|
||||
key: field(input, "key")?,
|
||||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.sync" => Some((|| {
|
||||
Ok(experimental_space_sync(&ExperimentalSpaceSyncInput {
|
||||
space: field(input, "space")?,
|
||||
cursor: field(input, "cursor")?,
|
||||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.subscribe" => Some((|| {
|
||||
Ok(experimental_space_subscribe(&ExperimentalSpaceSubscribeInput {
|
||||
stream: field(input, "stream")?,
|
||||
spaces: field(input, "spaces")?,
|
||||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.unsubscribe" => Some((|| {
|
||||
Ok(experimental_space_unsubscribe(&ExperimentalSpaceUnsubscribeInput {
|
||||
stream: field(input, "stream")?,
|
||||
spaces: field(input, "spaces")?,
|
||||
})
|
||||
.cast())
|
||||
})()),
|
||||
"experimental.space.reset" => Some((|| Ok(experimental_space_reset().cast()))()),
|
||||
"shell.list" => Some((|| Ok(shell_list(&ShellListInput { location: field(input, "location")? }).cast()))()),
|
||||
"shell.create" => Some((|| {
|
||||
Ok(shell_create(&ShellCreateInput {
|
||||
|
|
@ -3276,6 +3377,9 @@ pub fn probe(name: &str, input: &serde_json::Value) -> Option<Result<Call<serde_
|
|||
"experimental.usage.limits" => Some((|| {
|
||||
Ok(experimental_usage_limits(&ExperimentalUsageLimitsInput { location: field(input, "location")? }).cast())
|
||||
})()),
|
||||
"experimental.flag.get" => Some((|| {
|
||||
Ok(experimental_flag_get(&ExperimentalFlagGetInput { location: field(input, "location")? }).cast())
|
||||
})()),
|
||||
"config.get" => Some((|| Ok(config_get(&ConfigGetInput { location: field(input, "location")? }).cast()))()),
|
||||
"config.shells" => Some((|| Ok(config_shells().cast()))()),
|
||||
"experimental.config.update" => Some((|| {
|
||||
|
|
|
|||
350
packages/cli-rs/crates/api-types/src/types.rs
generated
350
packages/cli-rs/crates/api-types/src/types.rs
generated
|
|
@ -6858,6 +6858,12 @@ pub struct McpStatusFailed {
|
|||
pub error: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct McpStatusDisconnected {
|
||||
pub status: tag::Disconnected,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct McpStatusNeedsAuth {
|
||||
pub status: tag::NeedsAuth,
|
||||
|
|
@ -6871,6 +6877,7 @@ pub enum McpServerStatus {
|
|||
Pending(McpStatusPending),
|
||||
Disabled(McpStatusDisabled),
|
||||
Failed(McpStatusFailed),
|
||||
Disconnected(McpStatusDisconnected),
|
||||
NeedsAuth(McpStatusNeedsAuth),
|
||||
/// A member this client does not know, kept as it arrived.
|
||||
Unknown(serde_json::Value),
|
||||
|
|
@ -6889,6 +6896,7 @@ impl McpServerStatus {
|
|||
Some("pending") => raw.variant().map(Self::Pending),
|
||||
Some("disabled") => raw.variant().map(Self::Disabled),
|
||||
Some("failed") => raw.variant().map(Self::Failed),
|
||||
Some("disconnected") => raw.variant().map(Self::Disconnected),
|
||||
Some("needs_auth") => raw.variant().map(Self::NeedsAuth),
|
||||
_ => raw.unknown().map(Self::Unknown),
|
||||
}
|
||||
|
|
@ -6903,6 +6911,7 @@ impl McpServerStatus {
|
|||
Self::Pending(value) => value.status.as_str(),
|
||||
Self::Disabled(value) => value.status.as_str(),
|
||||
Self::Failed(value) => value.status.as_str(),
|
||||
Self::Disconnected(value) => value.status.as_str(),
|
||||
Self::NeedsAuth(value) => value.status.as_str(),
|
||||
Self::Unknown(value) => value.get("status").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
|
|
@ -6912,6 +6921,7 @@ impl McpServerStatus {
|
|||
pub fn error(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Failed(value) => Some(value.error.as_str()),
|
||||
Self::Disconnected(value) => Some(value.error.as_str()),
|
||||
Self::NeedsAuth(value) => Some(value.error.as_str()),
|
||||
Self::Connected(_) | Self::Pending(_) | Self::Disabled(_) | Self::Unknown(_) => None,
|
||||
}
|
||||
|
|
@ -9090,6 +9100,74 @@ pub struct ExperimentalMcpEvent {
|
|||
pub data: ExperimentalMcpEventData,
|
||||
}
|
||||
|
||||
string_type!(SpaceName, "`Space.Name`");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceResyncData {
|
||||
pub space: SpaceName,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceResync {
|
||||
pub id: EventID,
|
||||
#[serde(serialize_with = "crate::ser::number")]
|
||||
pub created: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub metadata: Option<IndexMap<String, serde_json::Value>>,
|
||||
pub r#type: tag::ExperimentalSpaceResync,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub location: Option<LocationRef>,
|
||||
pub data: ExperimentalSpaceResyncData,
|
||||
}
|
||||
|
||||
string_type!(SpaceKey, "`Space.Key`");
|
||||
|
||||
string_type!(SpaceValue, "`Space.Value`");
|
||||
|
||||
/// `Space.Revision`
|
||||
pub type SpaceRevision = i64;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceUpdatedData {
|
||||
pub space: SpaceName,
|
||||
pub key: SpaceKey,
|
||||
pub value: SpaceValue,
|
||||
pub revision: SpaceRevision,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceUpdated {
|
||||
pub id: EventID,
|
||||
#[serde(serialize_with = "crate::ser::number")]
|
||||
pub created: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub metadata: Option<IndexMap<String, serde_json::Value>>,
|
||||
pub r#type: tag::ExperimentalSpaceUpdated,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub location: Option<LocationRef>,
|
||||
pub data: ExperimentalSpaceUpdatedData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceDeletedData {
|
||||
pub space: SpaceName,
|
||||
pub key: SpaceKey,
|
||||
pub revision: SpaceRevision,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceDeleted {
|
||||
pub id: EventID,
|
||||
#[serde(serialize_with = "crate::ser::number")]
|
||||
pub created: f64,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub metadata: Option<IndexMap<String, serde_json::Value>>,
|
||||
pub r#type: tag::ExperimentalSpaceDeleted,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub location: Option<LocationRef>,
|
||||
pub data: ExperimentalSpaceDeletedData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct V2EventRpc {
|
||||
pub id: EventID,
|
||||
|
|
@ -9102,8 +9180,11 @@ pub struct V2EventRpc {
|
|||
pub data: IndexMap<String, serde_json::Value>,
|
||||
}
|
||||
|
||||
/// Any value but `null`.
|
||||
pub type V2EventServerConnectedData = crate::de::NotNull;
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct V2EventServerConnectedData {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub stream: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct V2EventServerConnected {
|
||||
|
|
@ -9220,6 +9301,9 @@ pub enum V2Event {
|
|||
McpStatusChanged(McpStatusChanged),
|
||||
McpResourcesChanged(McpResourcesChanged),
|
||||
ExperimentalMcpEvent(ExperimentalMcpEvent),
|
||||
ExperimentalSpaceResync(ExperimentalSpaceResync),
|
||||
ExperimentalSpaceUpdated(ExperimentalSpaceUpdated),
|
||||
ExperimentalSpaceDeleted(ExperimentalSpaceDeleted),
|
||||
Rpc(V2EventRpc),
|
||||
ServerConnected(V2EventServerConnected),
|
||||
/// A member this client does not know, kept as it arrived.
|
||||
|
|
@ -9335,6 +9419,9 @@ impl V2Event {
|
|||
Some("mcp.status.changed") => raw.variant().map(Self::McpStatusChanged),
|
||||
Some("mcp.resources.changed") => raw.variant().map(Self::McpResourcesChanged),
|
||||
Some("experimental.mcp.event") => raw.variant().map(Self::ExperimentalMcpEvent),
|
||||
Some("experimental.space.resync") => raw.variant().map(Self::ExperimentalSpaceResync),
|
||||
Some("experimental.space.updated") => raw.variant().map(Self::ExperimentalSpaceUpdated),
|
||||
Some("experimental.space.deleted") => raw.variant().map(Self::ExperimentalSpaceDeleted),
|
||||
Some("server.connected") => raw.variant().map(Self::ServerConnected),
|
||||
Some(tag) if tag.starts_with("rpc.") => raw.variant().map(Self::Rpc),
|
||||
_ => raw.unknown().map(Self::Unknown),
|
||||
|
|
@ -9446,6 +9533,9 @@ impl V2Event {
|
|||
Self::McpStatusChanged(value) => value.r#type.as_str(),
|
||||
Self::McpResourcesChanged(value) => value.r#type.as_str(),
|
||||
Self::ExperimentalMcpEvent(value) => value.r#type.as_str(),
|
||||
Self::ExperimentalSpaceResync(value) => value.r#type.as_str(),
|
||||
Self::ExperimentalSpaceUpdated(value) => value.r#type.as_str(),
|
||||
Self::ExperimentalSpaceDeleted(value) => value.r#type.as_str(),
|
||||
Self::Rpc(value) => value.r#type.as_str(),
|
||||
Self::ServerConnected(value) => value.r#type.as_str(),
|
||||
Self::Unknown(value) => value.get("type").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
|
|
@ -9555,6 +9645,9 @@ impl V2Event {
|
|||
Self::McpStatusChanged(value) => value.id.as_str(),
|
||||
Self::McpResourcesChanged(value) => value.id.as_str(),
|
||||
Self::ExperimentalMcpEvent(value) => value.id.as_str(),
|
||||
Self::ExperimentalSpaceResync(value) => value.id.as_str(),
|
||||
Self::ExperimentalSpaceUpdated(value) => value.id.as_str(),
|
||||
Self::ExperimentalSpaceDeleted(value) => value.id.as_str(),
|
||||
Self::Rpc(value) => value.id.as_str(),
|
||||
Self::ServerConnected(value) => value.id.as_str(),
|
||||
Self::Unknown(value) => value.get("id").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
|
|
@ -9664,6 +9757,9 @@ impl V2Event {
|
|||
Self::McpStatusChanged(value) => Some(value.created),
|
||||
Self::McpResourcesChanged(value) => Some(value.created),
|
||||
Self::ExperimentalMcpEvent(value) => Some(value.created),
|
||||
Self::ExperimentalSpaceResync(value) => Some(value.created),
|
||||
Self::ExperimentalSpaceUpdated(value) => Some(value.created),
|
||||
Self::ExperimentalSpaceDeleted(value) => Some(value.created),
|
||||
Self::Rpc(value) => Some(value.created),
|
||||
Self::ServerConnected(_) | Self::Unknown(_) => None,
|
||||
}
|
||||
|
|
@ -9772,6 +9868,9 @@ impl V2Event {
|
|||
Self::McpStatusChanged(value) => value.metadata.as_ref(),
|
||||
Self::McpResourcesChanged(value) => value.metadata.as_ref(),
|
||||
Self::ExperimentalMcpEvent(value) => value.metadata.as_ref(),
|
||||
Self::ExperimentalSpaceResync(value) => value.metadata.as_ref(),
|
||||
Self::ExperimentalSpaceUpdated(value) => value.metadata.as_ref(),
|
||||
Self::ExperimentalSpaceDeleted(value) => value.metadata.as_ref(),
|
||||
Self::Rpc(value) => value.metadata.as_ref(),
|
||||
Self::ServerConnected(value) => value.metadata.as_ref(),
|
||||
Self::Unknown(_) => None,
|
||||
|
|
@ -9881,6 +9980,9 @@ impl V2Event {
|
|||
| Self::McpStatusChanged(_)
|
||||
| Self::McpResourcesChanged(_)
|
||||
| Self::ExperimentalMcpEvent(_)
|
||||
| Self::ExperimentalSpaceResync(_)
|
||||
| Self::ExperimentalSpaceUpdated(_)
|
||||
| Self::ExperimentalSpaceDeleted(_)
|
||||
| Self::Rpc(_)
|
||||
| Self::ServerConnected(_)
|
||||
| Self::Unknown(_) => None,
|
||||
|
|
@ -9990,6 +10092,9 @@ impl V2Event {
|
|||
| Self::McpStatusChanged(_)
|
||||
| Self::McpResourcesChanged(_)
|
||||
| Self::ExperimentalMcpEvent(_)
|
||||
| Self::ExperimentalSpaceResync(_)
|
||||
| Self::ExperimentalSpaceUpdated(_)
|
||||
| Self::ExperimentalSpaceDeleted(_)
|
||||
| Self::Rpc(_)
|
||||
| Self::ServerConnected(_)
|
||||
| Self::Unknown(_) => None,
|
||||
|
|
@ -10099,6 +10204,9 @@ impl V2Event {
|
|||
| Self::McpStatusChanged(_)
|
||||
| Self::McpResourcesChanged(_)
|
||||
| Self::ExperimentalMcpEvent(_)
|
||||
| Self::ExperimentalSpaceResync(_)
|
||||
| Self::ExperimentalSpaceUpdated(_)
|
||||
| Self::ExperimentalSpaceDeleted(_)
|
||||
| Self::Rpc(_)
|
||||
| Self::ServerConnected(_)
|
||||
| Self::Unknown(_) => None,
|
||||
|
|
@ -10210,6 +10318,9 @@ pub enum EventKind {
|
|||
McpStatusChanged,
|
||||
McpResourcesChanged,
|
||||
ExperimentalMcpEvent,
|
||||
ExperimentalSpaceResync,
|
||||
ExperimentalSpaceUpdated,
|
||||
ExperimentalSpaceDeleted,
|
||||
Rpc,
|
||||
ServerConnected,
|
||||
Unknown,
|
||||
|
|
@ -10217,7 +10328,7 @@ pub enum EventKind {
|
|||
|
||||
impl EventKind {
|
||||
/// How many kinds there are, `Unknown` included.
|
||||
pub const COUNT: usize = 103;
|
||||
pub const COUNT: usize = 106;
|
||||
|
||||
/// The kind an event whose `type` is `tag` decodes to.
|
||||
pub fn from_tag(tag: &str) -> Self {
|
||||
|
|
@ -10322,6 +10433,9 @@ impl EventKind {
|
|||
"mcp.status.changed" => Self::McpStatusChanged,
|
||||
"mcp.resources.changed" => Self::McpResourcesChanged,
|
||||
"experimental.mcp.event" => Self::ExperimentalMcpEvent,
|
||||
"experimental.space.resync" => Self::ExperimentalSpaceResync,
|
||||
"experimental.space.updated" => Self::ExperimentalSpaceUpdated,
|
||||
"experimental.space.deleted" => Self::ExperimentalSpaceDeleted,
|
||||
"server.connected" => Self::ServerConnected,
|
||||
tag if tag.starts_with("rpc.") => Self::Rpc,
|
||||
_ => Self::Unknown,
|
||||
|
|
@ -10438,6 +10552,9 @@ impl V2Event {
|
|||
Self::McpStatusChanged(_) => EventKind::McpStatusChanged,
|
||||
Self::McpResourcesChanged(_) => EventKind::McpResourcesChanged,
|
||||
Self::ExperimentalMcpEvent(_) => EventKind::ExperimentalMcpEvent,
|
||||
Self::ExperimentalSpaceResync(_) => EventKind::ExperimentalSpaceResync,
|
||||
Self::ExperimentalSpaceUpdated(_) => EventKind::ExperimentalSpaceUpdated,
|
||||
Self::ExperimentalSpaceDeleted(_) => EventKind::ExperimentalSpaceDeleted,
|
||||
Self::Rpc(_) => EventKind::Rpc,
|
||||
Self::ServerConnected(_) => EventKind::ServerConnected,
|
||||
Self::Unknown(_) => EventKind::Unknown,
|
||||
|
|
@ -10678,6 +10795,9 @@ pub struct ExperimentalBlobGetInput {
|
|||
pub id: BlobID,
|
||||
}
|
||||
|
||||
/// Output of `Client::experimental_browser_tunnel`.
|
||||
pub type ExperimentalBrowserTunnelOutput = bool;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct AutomationTriggerAt {
|
||||
pub r#type: tag::At,
|
||||
|
|
@ -11474,6 +11594,177 @@ pub struct ExperimentalPushSettingsSetInput {
|
|||
/// Output of `Client::experimental_push_settings_set`.
|
||||
pub type ExperimentalPushSettingsSetOutput = PushSettings;
|
||||
|
||||
/// Input of `Client::experimental_space_set`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalSpaceSetInput {
|
||||
pub space: SpaceName,
|
||||
pub key: SpaceKey,
|
||||
pub value: SpaceValue,
|
||||
}
|
||||
|
||||
/// Input of `Client::experimental_space_delete`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalSpaceDeleteInput {
|
||||
pub space: SpaceName,
|
||||
pub key: SpaceKey,
|
||||
}
|
||||
|
||||
string_type!(SpaceCursor, "`Space.Cursor`");
|
||||
|
||||
/// Input of `Client::experimental_space_sync`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalSpaceSyncInput {
|
||||
pub space: SpaceName,
|
||||
pub cursor: Option<SpaceCursor>,
|
||||
}
|
||||
|
||||
string_type!(SpaceEpoch, "`Space.Epoch`");
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct SpaceEntry {
|
||||
pub key: SpaceKey,
|
||||
pub value: SpaceValue,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct SpaceSnapshot {
|
||||
pub r#type: tag::Snapshot,
|
||||
pub space: SpaceName,
|
||||
pub epoch: SpaceEpoch,
|
||||
pub revision: SpaceRevision,
|
||||
pub entries: Vec<SpaceEntry>,
|
||||
pub cursor: SpaceCursor,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub next: Option<SpaceCursor>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct SpaceDelta {
|
||||
pub r#type: tag::Delta,
|
||||
pub space: SpaceName,
|
||||
pub epoch: SpaceEpoch,
|
||||
pub revision: SpaceRevision,
|
||||
pub entries: Vec<SpaceEntry>,
|
||||
pub cursor: SpaceCursor,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub next: Option<SpaceCursor>,
|
||||
pub deleted: Vec<SpaceKey>,
|
||||
}
|
||||
|
||||
/// `Space.Page`, tagged by `type`.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum SpacePage {
|
||||
Snapshot(SpaceSnapshot),
|
||||
Delta(SpaceDelta),
|
||||
/// A member this client does not know, kept as it arrived.
|
||||
Unknown(serde_json::Value),
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for SpacePage {
|
||||
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
crate::de::union(deserializer, Self::from_raw)
|
||||
}
|
||||
}
|
||||
|
||||
impl SpacePage {
|
||||
pub fn from_raw(raw: &crate::de::Raw) -> Result<Self, serde_json::Error> {
|
||||
match raw.field("type").as_str() {
|
||||
Some("snapshot") => raw.variant().map(Self::Snapshot),
|
||||
Some("delta") => raw.variant().map(Self::Delta),
|
||||
_ => raw.unknown().map(Self::Unknown),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl SpacePage {
|
||||
/// The `type` tag, also of an unknown member.
|
||||
pub fn tag(&self) -> &str {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.r#type.as_str(),
|
||||
Self::Delta(value) => value.r#type.as_str(),
|
||||
Self::Unknown(value) => value.get("type").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `space` field, also of an unknown member.
|
||||
pub fn space(&self) -> &str {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.space.as_str(),
|
||||
Self::Delta(value) => value.space.as_str(),
|
||||
Self::Unknown(value) => value.get("space").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `epoch` field, also of an unknown member.
|
||||
pub fn epoch(&self) -> &str {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.epoch.as_str(),
|
||||
Self::Delta(value) => value.epoch.as_str(),
|
||||
Self::Unknown(value) => value.get("epoch").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `revision` field, also of an unknown member.
|
||||
pub fn revision(&self) -> SpaceRevision {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.revision,
|
||||
Self::Delta(value) => value.revision,
|
||||
Self::Unknown(value) => value.get("revision").and_then(serde_json::Value::as_i64).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `entries` field, of the members that have it.
|
||||
pub fn entries(&self) -> Option<&[SpaceEntry]> {
|
||||
match self {
|
||||
Self::Snapshot(value) => Some(value.entries.as_slice()),
|
||||
Self::Delta(value) => Some(value.entries.as_slice()),
|
||||
Self::Unknown(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The `cursor` field, also of an unknown member.
|
||||
pub fn cursor(&self) -> &str {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.cursor.as_str(),
|
||||
Self::Delta(value) => value.cursor.as_str(),
|
||||
Self::Unknown(value) => value.get("cursor").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The `next` field, of the members that have it.
|
||||
pub fn next(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Snapshot(value) => value.next.as_ref().map(SpaceCursor::as_str),
|
||||
Self::Delta(value) => value.next.as_ref().map(SpaceCursor::as_str),
|
||||
Self::Unknown(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Output of `Client::experimental_space_sync`.
|
||||
pub type ExperimentalSpaceSyncOutput = SpacePage;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalSpaceSubscribeInputSpacesItem {
|
||||
pub space: SpaceName,
|
||||
pub cursor: SpaceCursor,
|
||||
}
|
||||
|
||||
/// Input of `Client::experimental_space_subscribe`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalSpaceSubscribeInput {
|
||||
pub stream: String,
|
||||
pub spaces: Vec<ExperimentalSpaceSubscribeInputSpacesItem>,
|
||||
}
|
||||
|
||||
/// Input of `Client::experimental_space_unsubscribe`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalSpaceUnsubscribeInput {
|
||||
pub stream: String,
|
||||
pub spaces: Vec<SpaceName>,
|
||||
}
|
||||
|
||||
/// Input of `Client::shell_list`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ShellListInput {
|
||||
|
|
@ -12064,6 +12355,18 @@ pub struct ExperimentalUsageLimitsOutput {
|
|||
pub data: Option<UsageLimitsInfo>,
|
||||
}
|
||||
|
||||
/// Input of `Client::experimental_flag_get`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ExperimentalFlagGetInput {
|
||||
pub location: Option<LocationQueryInput>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||
pub struct ExperimentalFlagGetOutput {
|
||||
pub location: LocationPublicRef,
|
||||
pub data: IndexMap<String, bool>,
|
||||
}
|
||||
|
||||
/// Input of `Client::config_get`.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct ConfigGetInput {
|
||||
|
|
@ -12849,6 +13152,8 @@ pub struct ConfigEntryDocumentInfoExperimental {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub full_codemode: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub codemode_agents: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub machines: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub home_memory: Option<bool>,
|
||||
|
|
@ -12863,6 +13168,10 @@ pub struct ConfigEntryDocumentInfoExperimental {
|
|||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub sqlite_fts: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub browser_stream_tunnel: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub mcp_resilience: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub video_generate: Option<ConfigEntryDocumentInfoExperimentalVideoGenerate>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub part_rows: Option<bool>,
|
||||
|
|
@ -13817,16 +14126,19 @@ pub mod tag {
|
|||
Code = "code", Codemode = "codemode", Command = "command", CommandUpdated = "command.updated",
|
||||
Compaction = "compaction", Complete = "complete", Completed = "completed", ConfigUpdated = "config.updated",
|
||||
Connected = "connected", Credential = "credential", CredentialSwitched = "credential.switched",
|
||||
CredentialUpdated = "credential.updated", Cron = "cron", Detail = "detail", Directory = "directory",
|
||||
Disabled = "disabled", Document = "document", Env = "env", Error = "error", Event = "event", Every = "every",
|
||||
CredentialUpdated = "credential.updated", Cron = "cron", Delta = "delta", Detail = "detail",
|
||||
Directory = "directory", Disabled = "disabled", Disconnected = "disconnected", Document = "document",
|
||||
Env = "env", Error = "error", Event = "event", Every = "every",
|
||||
ExperimentalJobUpdated = "experimental.job.updated", ExperimentalMcpEvent = "experimental.mcp.event",
|
||||
ExperimentalPushUpdated = "experimental.push.updated", Expired = "expired", External = "external",
|
||||
Failed = "failed", File = "file", FilesystemChanged = "filesystem.changed", FormCancelled = "form.cancelled",
|
||||
FormCreated = "form.created", FormReplied = "form.replied", Git = "git", Idle = "idle", Image = "image",
|
||||
Inline = "inline", InstallationUpdateAvailable = "installation.update-available",
|
||||
InstallationUpdated = "installation.updated", Integer = "integer", IntegrationUpdated = "integration.updated",
|
||||
Iroh = "iroh", Json = "json", Key = "key", Local = "local", LocationShutdown = "location.shutdown",
|
||||
LocationSwitched = "location-switched", LogSynced = "log.synced", McpResourcesChanged = "mcp.resources.changed",
|
||||
ExperimentalPushUpdated = "experimental.push.updated", ExperimentalSpaceDeleted = "experimental.space.deleted",
|
||||
ExperimentalSpaceResync = "experimental.space.resync", ExperimentalSpaceUpdated = "experimental.space.updated",
|
||||
Expired = "expired", External = "external", Failed = "failed", File = "file",
|
||||
FilesystemChanged = "filesystem.changed", FormCancelled = "form.cancelled", FormCreated = "form.created",
|
||||
FormReplied = "form.replied", Git = "git", Idle = "idle", Image = "image", Inline = "inline",
|
||||
InstallationUpdateAvailable = "installation.update-available", InstallationUpdated = "installation.updated",
|
||||
Integer = "integer", IntegrationUpdated = "integration.updated", Iroh = "iroh", Json = "json", Key = "key",
|
||||
Local = "local", LocationShutdown = "location.shutdown", LocationSwitched = "location-switched",
|
||||
LogSynced = "log.synced", McpResourcesChanged = "mcp.resources.changed",
|
||||
McpStatusChanged = "mcp.status.changed", ModelSwitched = "model-switched", ModelUpdated = "model.updated",
|
||||
ModelsDevRefreshed = "models-dev.refreshed", Move = "move", Multiselect = "multiselect", Native = "native",
|
||||
NeedsAuth = "needs_auth", None = "none", Number = "number", Oauth = "oauth", Package = "package",
|
||||
|
|
@ -13869,12 +14181,12 @@ pub mod tag {
|
|||
SessionUnarchived = "session.unarchived", SessionUsageRecorded = "session.usage.recorded",
|
||||
SessionUsageUpdated = "session.usage.updated", SessionViewed = "session.viewed", Shell = "shell",
|
||||
ShellCreated = "shell.created", ShellDeleted = "shell.deleted", ShellExited = "shell.exited", Skill = "skill",
|
||||
SkillUpdated = "skill.updated", Streaming = "streaming", String = "string", Subagent = "subagent",
|
||||
Summary = "summary", Synthetic = "synthetic", System = "system", Text = "text", Through = "through",
|
||||
Tool = "tool", TuiCommandExecute = "tui.command.execute", TuiPromptAppend = "tui.prompt.append",
|
||||
TuiSessionSelect = "tui.session.select", TuiToastShow = "tui.toast.show", Uri = "uri", Url = "url",
|
||||
User = "user", VcsBranchUpdated = "vcs.branch.updated", Video = "video", Webrtc = "webrtc",
|
||||
WebsearchUpdated = "websearch.updated", Websocket = "websocket", WorktreeResolved = "worktree.resolved",
|
||||
WorktreeUpdated = "worktree.updated",
|
||||
SkillUpdated = "skill.updated", Snapshot = "snapshot", Streaming = "streaming", String = "string",
|
||||
Subagent = "subagent", Summary = "summary", Synthetic = "synthetic", System = "system", Text = "text",
|
||||
Through = "through", Tool = "tool", TuiCommandExecute = "tui.command.execute",
|
||||
TuiPromptAppend = "tui.prompt.append", TuiSessionSelect = "tui.session.select", TuiToastShow = "tui.toast.show",
|
||||
Uri = "uri", Url = "url", User = "user", VcsBranchUpdated = "vcs.branch.updated", Video = "video",
|
||||
Webrtc = "webrtc", WebsearchUpdated = "websearch.updated", Websocket = "websocket",
|
||||
WorktreeResolved = "worktree.resolved", WorktreeUpdated = "worktree.updated",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
packages/cli-rs/crates/api/src/generated/methods.rs
generated
20
packages/cli-rs/crates/api/src/generated/methods.rs
generated
|
|
@ -168,6 +168,13 @@ impl Client {
|
|||
endpoint!(" `POST /api/experimental/persistent-pty/:ptyID/connect-token` (`persistentPty.connectToken`)", experimental_persistent_pty_connect_token, experimental_persistent_pty_connect_token_call, data, ExperimentalPersistentPtyConnectTokenOutput, input: ExperimentalPersistentPtyConnectTokenInput);
|
||||
endpoint!(" `GET /api/experimental/media/:hash` (`media.get`)", experimental_media_get, experimental_media_get_call, binary, bytes::Bytes, input: ExperimentalMediaGetInput);
|
||||
endpoint!(" `GET /api/experimental/blob/:id` (`blob.get`)", experimental_blob_get, experimental_blob_get_call, binary, bytes::Bytes, input: ExperimentalBlobGetInput);
|
||||
endpoint!(
|
||||
" `GET /api/experimental/browser/tunnel` (`browser.tunnel`)",
|
||||
experimental_browser_tunnel,
|
||||
experimental_browser_tunnel_call,
|
||||
json,
|
||||
ExperimentalBrowserTunnelOutput
|
||||
);
|
||||
endpoint!(" `POST /api/experimental/automation` (`automation.create`)", experimental_automation_create, experimental_automation_create_call, data, ExperimentalAutomationCreateOutput, input: ExperimentalAutomationCreateInput);
|
||||
endpoint!(" `GET /api/experimental/automation` (`automation.list`)", experimental_automation_list, experimental_automation_list_call, data, ExperimentalAutomationListOutput, input: ExperimentalAutomationListInput);
|
||||
endpoint!(" `GET /api/experimental/automation/:automationID` (`automation.get`)", experimental_automation_get, experimental_automation_get_call, data, ExperimentalAutomationGetOutput, input: ExperimentalAutomationGetInput);
|
||||
|
|
@ -207,6 +214,18 @@ impl Client {
|
|||
endpoint!(" `PUT /api/experimental/push/session/:sessionID` (`push.session.set`)", experimental_push_session_set, experimental_push_session_set_call, data, ExperimentalPushSessionSetOutput, input: ExperimentalPushSessionSetInput);
|
||||
endpoint!(" `DELETE /api/experimental/push/session/:sessionID` (`push.session.remove`)", experimental_push_session_remove, experimental_push_session_remove_call, empty, (), input: ExperimentalPushSessionRemoveInput);
|
||||
endpoint!(" `PUT /api/experimental/push/settings` (`push.settings.set`)", experimental_push_settings_set, experimental_push_settings_set_call, data, ExperimentalPushSettingsSetOutput, input: ExperimentalPushSettingsSetInput);
|
||||
endpoint!(" `PUT /api/experimental/space/:space/:key` (`space.set`)", experimental_space_set, experimental_space_set_call, empty, (), input: ExperimentalSpaceSetInput);
|
||||
endpoint!(" `DELETE /api/experimental/space/:space/:key` (`space.delete`)", experimental_space_delete, experimental_space_delete_call, empty, (), input: ExperimentalSpaceDeleteInput);
|
||||
endpoint!(" `GET /api/experimental/space/:space` (`space.sync`)", experimental_space_sync, experimental_space_sync_call, json, ExperimentalSpaceSyncOutput, input: ExperimentalSpaceSyncInput);
|
||||
endpoint!(" `POST /api/experimental/space/subscribe` (`space.subscribe`)", experimental_space_subscribe, experimental_space_subscribe_call, empty, (), input: ExperimentalSpaceSubscribeInput);
|
||||
endpoint!(" `POST /api/experimental/space/unsubscribe` (`space.unsubscribe`)", experimental_space_unsubscribe, experimental_space_unsubscribe_call, empty, (), input: ExperimentalSpaceUnsubscribeInput);
|
||||
endpoint!(
|
||||
" `POST /api/experimental/space/reset` (`space.reset`)",
|
||||
experimental_space_reset,
|
||||
experimental_space_reset_call,
|
||||
empty,
|
||||
()
|
||||
);
|
||||
endpoint!(" `GET /api/shell` (`list`)", shell_list, shell_list_call, json, ShellListOutput, input: ShellListInput);
|
||||
endpoint!(" `POST /api/shell` (`create`)", shell_create, shell_create_call, json, ShellCreateOutput, input: ShellCreateInput);
|
||||
endpoint!(" `GET /api/shell/:id` (`get`)", shell_get, shell_get_call, json, ShellGetOutput, input: ShellGetInput);
|
||||
|
|
@ -242,6 +261,7 @@ impl Client {
|
|||
endpoint!(" `GET /api/websearch/provider` (`providers`)", websearch_providers, websearch_providers_call, json, WebsearchProvidersOutput, input: WebsearchProvidersInput);
|
||||
endpoint!(" `POST /api/websearch` (`query`)", websearch_query, websearch_query_call, json, WebsearchQueryOutput, input: WebsearchQueryInput);
|
||||
endpoint!(" `GET /api/experimental/usage/limits` (`limits`)", experimental_usage_limits, experimental_usage_limits_call, json, ExperimentalUsageLimitsOutput, input: ExperimentalUsageLimitsInput);
|
||||
endpoint!(" `GET /api/experimental/flag` (`get`)", experimental_flag_get, experimental_flag_get_call, json, ExperimentalFlagGetOutput, input: ExperimentalFlagGetInput);
|
||||
endpoint!(" `GET /api/config` (`get`)", config_get, config_get_call, json, ConfigGetOutput, input: ConfigGetInput);
|
||||
endpoint!(" `GET /api/config/shell` (`shells`)", config_shells, config_shells_call, json, ConfigShellsOutput);
|
||||
endpoint!(" `PATCH /api/experimental/config` (`update`)", experimental_config_update, experimental_config_update_call, empty, (), input: ExperimentalConfigUpdateInput);
|
||||
|
|
|
|||
2
packages/cli-rs/crates/api/src/generated/mod.rs
generated
2
packages/cli-rs/crates/api/src/generated/mod.rs
generated
|
|
@ -7,4 +7,4 @@ pub use opencode_api_types::types;
|
|||
pub use types::*;
|
||||
|
||||
/// Endpoints in the generated client.
|
||||
pub const ENDPOINTS: usize = 183;
|
||||
pub const ENDPOINTS: usize = 191;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ fn list(context: &Context) -> error::Result<()> {
|
|||
McpServerStatus::Connected(_) => ("✓", "connected".to_owned()),
|
||||
McpServerStatus::NeedsAuth(_) => ("⚠", "needs authentication".to_owned()),
|
||||
McpServerStatus::Failed(failed) => ("✗", format!("failed: {}", failed.error)),
|
||||
McpServerStatus::Disconnected(disconnected) => ("⚠", format!("disconnected: {}", disconnected.error)),
|
||||
status => ("○", status.tag().to_owned()),
|
||||
};
|
||||
format!("{icon} {} {description}", pad_end(&server.name, width))
|
||||
|
|
@ -226,6 +227,7 @@ fn auth_choices(servers: &[McpServer], integrations: &[IntegrationInfo]) -> Vec<
|
|||
hint: match &server.status {
|
||||
McpServerStatus::NeedsAuth(_) => Some("needs authentication".to_owned()),
|
||||
McpServerStatus::Failed(_) => Some("failed".to_owned()),
|
||||
McpServerStatus::Disconnected(_) => Some("disconnected".to_owned()),
|
||||
McpServerStatus::Disabled(_) => Some("disabled".to_owned()),
|
||||
_ => None,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@
|
|||
"experimental.persistentPty.connectToken":{"ptyID":"s0","x-opencode-ticket":"s1"},
|
||||
"experimental.media.get":{"hash":"s0"},
|
||||
"experimental.blob.get":{"id":"s0"},
|
||||
"experimental.browser.tunnel":{},
|
||||
"experimental.automation.create":{"sessionID":"s0","directory":"s0","name":"s0","trigger":{"type":"at","at":"s2","tz":"s2"},"action":{"type":"prompt","prompt":"s2","to":{"session":"s4"}},"expires":"s0"},
|
||||
"experimental.automation.list":{"sessionID":"s1","directory":"s1"},
|
||||
"experimental.automation.get":{"automationID":"s0"},
|
||||
|
|
@ -156,6 +157,12 @@
|
|||
"experimental.push.session.set":{"sessionID":"s0","level":"all","until":2},
|
||||
"experimental.push.session.remove":{"sessionID":"s0"},
|
||||
"experimental.push.settings.set":{"paused":true,"until":2},
|
||||
"experimental.space.set":{"space":"s0","key":"s0","value":"s0"},
|
||||
"experimental.space.delete":{"space":"s0","key":"s0"},
|
||||
"experimental.space.sync":{"space":"s0","cursor":"s1"},
|
||||
"experimental.space.subscribe":{"stream":"s0","spaces":[{"space":"s2","cursor":"s2"}]},
|
||||
"experimental.space.unsubscribe":{"stream":"s0","spaces":["s1"]},
|
||||
"experimental.space.reset":{},
|
||||
"shell.list":{"location":{"directory":"s3"}},
|
||||
"shell.create":{"location":{"directory":"s3"},"command":"s0","cwd":"s0","timeout":2,"metadata":{"key":"any"}},
|
||||
"shell.get":{"id":"s0","location":{"directory":"s3"}},
|
||||
|
|
@ -179,6 +186,7 @@
|
|||
"websearch.providers":{"location":{"directory":"s3"}},
|
||||
"websearch.query":{"location":{"directory":"s3"},"query":"s0","providerID":"s0"},
|
||||
"experimental.usage.limits":{"location":{"directory":"s3"}},
|
||||
"experimental.flag.get":{"location":{"directory":"s3"}},
|
||||
"config.get":{"location":{"directory":"s3"}},
|
||||
"config.shells":{},
|
||||
"experimental.config.update":{"shell":"s1"}
|
||||
|
|
|
|||
|
|
@ -1994,6 +1994,7 @@ export type ConfigInfoEncoded = {
|
|||
console_watches: boolean?,
|
||||
recommended_api: boolean?,
|
||||
full_codemode: boolean?,
|
||||
codemode_agents: boolean?,
|
||||
machines: boolean?,
|
||||
home_memory: boolean?,
|
||||
project_overlay: boolean?,
|
||||
|
|
@ -2001,6 +2002,7 @@ export type ConfigInfoEncoded = {
|
|||
mcp_skills: boolean?,
|
||||
compaction_jobs: boolean?,
|
||||
sqlite_fts: boolean?,
|
||||
browser_stream_tunnel: boolean?,
|
||||
video_generate: (boolean | {
|
||||
model: (string | {
|
||||
providerID: string,
|
||||
|
|
@ -2243,6 +2245,23 @@ export type ExperimentalMcpEvent = _Event1<"experimental.mcp.event", {
|
|||
|
||||
export type ExperimentalPushUpdated = _Event1<"experimental.push.updated", any>
|
||||
|
||||
export type ExperimentalSpaceDeleted = _Event1<"experimental.space.deleted", {
|
||||
space: SpaceName,
|
||||
key: SpaceKey,
|
||||
revision: SpaceRevision,
|
||||
}>
|
||||
|
||||
export type ExperimentalSpaceResync = _Event1<"experimental.space.resync", {
|
||||
space: SpaceName,
|
||||
}>
|
||||
|
||||
export type ExperimentalSpaceUpdated = _Event1<"experimental.space.updated", {
|
||||
space: SpaceName,
|
||||
key: SpaceKey,
|
||||
value: SpaceValue,
|
||||
revision: SpaceRevision,
|
||||
}>
|
||||
|
||||
export type FileDiffInfo = {
|
||||
file: string,
|
||||
patch: string,
|
||||
|
|
@ -4483,6 +4502,50 @@ export type SkillUpdated = _Event1<"skill.updated", any>
|
|||
|
||||
export type SnapshotID = string
|
||||
|
||||
export type SpaceCursor = string
|
||||
|
||||
--- Covers every change up to this page; save it to subscribe or sync from.
|
||||
export type SpaceCursor1 = string
|
||||
|
||||
export type SpaceDelta = {
|
||||
type: "delta",
|
||||
space: SpaceName,
|
||||
epoch: SpaceEpoch,
|
||||
revision: SpaceRevision,
|
||||
entries: { SpaceEntry },
|
||||
cursor: SpaceCursor1,
|
||||
next: SpaceCursor?,
|
||||
deleted: { SpaceKey },
|
||||
}
|
||||
|
||||
export type SpaceEntry = {
|
||||
key: SpaceKey,
|
||||
value: SpaceValue,
|
||||
}
|
||||
|
||||
export type SpaceEpoch = string
|
||||
|
||||
export type SpaceKey = string
|
||||
|
||||
--- Client-chosen namespace: 1-128 letters, digits, '.', '_' or '-'.
|
||||
export type SpaceName = string
|
||||
|
||||
export type SpacePage = (SpaceSnapshot | SpaceDelta)
|
||||
|
||||
export type SpaceRevision = number
|
||||
|
||||
export type SpaceSnapshot = {
|
||||
type: "snapshot",
|
||||
space: SpaceName,
|
||||
epoch: SpaceEpoch,
|
||||
revision: SpaceRevision,
|
||||
entries: { SpaceEntry },
|
||||
cursor: SpaceCursor1,
|
||||
next: SpaceCursor?,
|
||||
}
|
||||
|
||||
export type SpaceValue = string
|
||||
|
||||
export type TokenUsageInfo = {
|
||||
input: number,
|
||||
output: number,
|
||||
|
|
@ -4572,7 +4635,7 @@ export type UsageLimitsMeter = {
|
|||
resetsAt: number,
|
||||
}
|
||||
|
||||
export type V2Event = (LocationShutdown | ModelsDevRefreshed | CredentialUpdated | CredentialSwitched | IntegrationUpdated | ProviderUpdated | ModelUpdated | AgentUpdated | SessionCreated | SessionAgentSelected | SessionModelSelected | SessionMoved | SessionRenamed | SessionMetadataUpdated | SessionPermissions | SessionViewed | SessionArchived | SessionUnarchived | SessionUsageUpdated | SessionDeleted | SessionForked | SessionInboxDelivered | SessionInboxEnqueued | SessionInboxCancelled | SessionInboxDeliveryChanged | SessionExecutionStarted | SessionExecutionSucceeded | SessionExecutionFailed | SessionExecutionInterrupted | SessionInstructionsUpdated | SessionSynthetic | SessionSkillActivated | SessionShellStarted | SessionShellEnded | SessionStepStarted | SessionStepFirstToken | SessionStepStreamed | SessionStepEnded | SessionStepFailed | SessionTextStarted | SessionTextDelta | SessionTextEnded | SessionReasoningStarted | SessionReasoningDelta | SessionReasoningEnded | SessionToolInputStarted | SessionToolInputDelta | SessionToolInputEnded | SessionToolCalled | SessionToolProgress | SessionToolSuccess | SessionToolFailed | SessionRetryScheduled | SessionCompactionStarted | SessionCompactionDelta | SessionCompactionEnded | SessionCompactionFailed | SessionRevertStaged | SessionRevertCleared | SessionRevertCommitted | FilesystemChanged | ReferenceUpdated | PermissionAsked | PermissionReplied | PluginUpdated | ProjectUpdated | WorktreeUpdated | WorktreeResolved | CommandUpdated | ConfigUpdated | SkillUpdated | PtyCreated | PtyUpdated | PtyExited | PtyDeleted | PersistentPtyAdded | PersistentPtyRemoved | PersistentPtyUpdated | ShellCreated | ShellExited | ShellDeleted | ExperimentalJobUpdated | FormCreated | FormReplied | FormCancelled | WebsearchUpdated | ExperimentalPushUpdated | ArtifactUpdated | SessionStatusUpdated | SessionIdle | TuiPromptAppend | TuiCommandExecute | TuiToastShow | TuiSessionSelect | InstallationUpdated | InstallationUpdateAvailable | VcsBranchUpdated | McpStatusChanged | McpResourcesChanged | ExperimentalMcpEvent | V2EventRpc | V2EventServerConnected)
|
||||
export type V2Event = (LocationShutdown | ModelsDevRefreshed | CredentialUpdated | CredentialSwitched | IntegrationUpdated | ProviderUpdated | ModelUpdated | AgentUpdated | SessionCreated | SessionAgentSelected | SessionModelSelected | SessionMoved | SessionRenamed | SessionMetadataUpdated | SessionPermissions | SessionViewed | SessionArchived | SessionUnarchived | SessionUsageUpdated | SessionDeleted | SessionForked | SessionInboxDelivered | SessionInboxEnqueued | SessionInboxCancelled | SessionInboxDeliveryChanged | SessionExecutionStarted | SessionExecutionSucceeded | SessionExecutionFailed | SessionExecutionInterrupted | SessionInstructionsUpdated | SessionSynthetic | SessionSkillActivated | SessionShellStarted | SessionShellEnded | SessionStepStarted | SessionStepFirstToken | SessionStepStreamed | SessionStepEnded | SessionStepFailed | SessionTextStarted | SessionTextDelta | SessionTextEnded | SessionReasoningStarted | SessionReasoningDelta | SessionReasoningEnded | SessionToolInputStarted | SessionToolInputDelta | SessionToolInputEnded | SessionToolCalled | SessionToolProgress | SessionToolSuccess | SessionToolFailed | SessionRetryScheduled | SessionCompactionStarted | SessionCompactionDelta | SessionCompactionEnded | SessionCompactionFailed | SessionRevertStaged | SessionRevertCleared | SessionRevertCommitted | FilesystemChanged | ReferenceUpdated | PermissionAsked | PermissionReplied | PluginUpdated | ProjectUpdated | WorktreeUpdated | WorktreeResolved | CommandUpdated | ConfigUpdated | SkillUpdated | PtyCreated | PtyUpdated | PtyExited | PtyDeleted | PersistentPtyAdded | PersistentPtyRemoved | PersistentPtyUpdated | ShellCreated | ShellExited | ShellDeleted | ExperimentalJobUpdated | FormCreated | FormReplied | FormCancelled | WebsearchUpdated | ExperimentalPushUpdated | ArtifactUpdated | SessionStatusUpdated | SessionIdle | TuiPromptAppend | TuiCommandExecute | TuiToastShow | TuiSessionSelect | InstallationUpdated | InstallationUpdateAvailable | VcsBranchUpdated | McpStatusChanged | McpResourcesChanged | ExperimentalMcpEvent | ExperimentalSpaceResync | ExperimentalSpaceUpdated | ExperimentalSpaceDeleted | V2EventRpc | V2EventServerConnected)
|
||||
|
||||
export type V2EventRpc = {
|
||||
id: EventID,
|
||||
|
|
@ -4583,7 +4646,9 @@ export type V2EventRpc = {
|
|||
data: { [string]: any },
|
||||
}
|
||||
|
||||
export type V2EventServerConnected = _Event4<"server.connected", any>
|
||||
export type V2EventServerConnected = _Event4<"server.connected", {
|
||||
stream: string?,
|
||||
}>
|
||||
|
||||
export type VcsBase = {
|
||||
name: string,
|
||||
|
|
@ -5144,6 +5209,9 @@ export type Client = {
|
|||
id: string,
|
||||
}) -> (string?, string?),
|
||||
},
|
||||
browser: {
|
||||
tunnel: (input: {}?) -> (boolean?, string?),
|
||||
},
|
||||
config: {
|
||||
update: (input: {
|
||||
shell: string?,
|
||||
|
|
@ -5167,6 +5235,14 @@ export type Client = {
|
|||
data: FileSystemWrite,
|
||||
}?, string?),
|
||||
},
|
||||
flag: {
|
||||
get: (input: {
|
||||
location: { directory: string? }?,
|
||||
}?) -> ({
|
||||
location: LocationPublicRef,
|
||||
data: { [string]: boolean },
|
||||
}?, string?),
|
||||
},
|
||||
generate: {
|
||||
decisions: (input: {
|
||||
model: ModelRef,
|
||||
|
|
@ -5436,6 +5512,33 @@ export type Client = {
|
|||
path: string,
|
||||
}) -> (string?, string?),
|
||||
},
|
||||
space: {
|
||||
delete: (input: {
|
||||
space: string,
|
||||
key: string,
|
||||
}) -> (nil, string?),
|
||||
reset: (input: {}?) -> (nil, string?),
|
||||
set: (input: {
|
||||
space: string,
|
||||
key: string,
|
||||
value: SpaceValue,
|
||||
}) -> (nil, string?),
|
||||
subscribe: (input: {
|
||||
stream: string,
|
||||
spaces: { {
|
||||
space: SpaceName,
|
||||
cursor: SpaceCursor,
|
||||
} },
|
||||
}) -> (nil, string?),
|
||||
sync: (input: {
|
||||
space: string,
|
||||
cursor: string?,
|
||||
}) -> (SpacePage?, string?),
|
||||
unsubscribe: (input: {
|
||||
stream: string,
|
||||
spaces: { SpaceName },
|
||||
}) -> (nil, string?),
|
||||
},
|
||||
usage: {
|
||||
limits: (input: {
|
||||
location: { directory: string? }?,
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@
|
|||
"experimental.persistentPty.connectToken":{"method":"POST","path":"/api/experimental/persistent-pty/:ptyID/connect-token","fields":[["ptyID","params",false,"string"],["x-opencode-ticket","headers",true,"string?"]],"body":null,"reply":"data"},
|
||||
"experimental.media.get":{"method":"GET","path":"/api/experimental/media/:hash","fields":[["hash","params",false,"string"]],"body":null,"reply":"binary"},
|
||||
"experimental.blob.get":{"method":"GET","path":"/api/experimental/blob/:id","fields":[["id","params",false,"string"]],"body":null,"reply":"binary"},
|
||||
"experimental.browser.tunnel":{"method":"GET","path":"/api/experimental/browser/tunnel","fields":[],"body":null,"reply":"json"},
|
||||
"experimental.automation.create":{"method":"POST","path":"/api/experimental/automation","fields":[["sessionID","payload",true,null],["directory","payload",true,null],["name","payload",false,null],["trigger","payload",false,null],["action","payload",false,null],["expires","payload",true,null]],"body":"object","reply":"data"},
|
||||
"experimental.automation.list":{"method":"GET","path":"/api/experimental/automation","fields":[["sessionID","query",true,"string?"],["directory","query",true,"string?"]],"body":null,"reply":"data"},
|
||||
"experimental.automation.get":{"method":"GET","path":"/api/experimental/automation/:automationID","fields":[["automationID","params",false,"string"]],"body":null,"reply":"data"},
|
||||
|
|
@ -156,6 +157,12 @@
|
|||
"experimental.push.session.set":{"method":"PUT","path":"/api/experimental/push/session/:sessionID","fields":[["sessionID","params",false,"string"],["level","payload",false,null],["until","payload",true,null]],"body":"object","reply":"data"},
|
||||
"experimental.push.session.remove":{"method":"DELETE","path":"/api/experimental/push/session/:sessionID","fields":[["sessionID","params",false,"string"]],"body":null,"reply":"empty"},
|
||||
"experimental.push.settings.set":{"method":"PUT","path":"/api/experimental/push/settings","fields":[["paused","payload",false,null],["until","payload",true,null]],"body":"object","reply":"data"},
|
||||
"experimental.space.set":{"method":"PUT","path":"/api/experimental/space/:space/:key","fields":[["space","params",false,"string"],["key","params",false,"string"],["value","payload",false,null]],"body":"object","reply":"empty"},
|
||||
"experimental.space.delete":{"method":"DELETE","path":"/api/experimental/space/:space/:key","fields":[["space","params",false,"string"],["key","params",false,"string"]],"body":null,"reply":"empty"},
|
||||
"experimental.space.sync":{"method":"GET","path":"/api/experimental/space/:space","fields":[["space","params",false,"string"],["cursor","query",true,"string?"]],"body":null,"reply":"json"},
|
||||
"experimental.space.subscribe":{"method":"POST","path":"/api/experimental/space/subscribe","fields":[["stream","payload",false,null],["spaces","payload",false,null]],"body":"object","reply":"empty"},
|
||||
"experimental.space.unsubscribe":{"method":"POST","path":"/api/experimental/space/unsubscribe","fields":[["stream","payload",false,null],["spaces","payload",false,null]],"body":"object","reply":"empty"},
|
||||
"experimental.space.reset":{"method":"POST","path":"/api/experimental/space/reset","fields":[],"body":null,"reply":"empty"},
|
||||
"shell.list":{"method":"GET","path":"/api/shell","fields":[["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
"shell.create":{"method":"POST","path":"/api/shell","fields":[["location","query",true,"{ directory: string? }?"],["command","payload",false,null],["cwd","payload",true,null],["timeout","payload",true,null],["metadata","payload",true,null]],"body":"object","reply":"json"},
|
||||
"shell.get":{"method":"GET","path":"/api/shell/:id","fields":[["id","params",false,"string"],["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
|
|
@ -179,6 +186,7 @@
|
|||
"websearch.providers":{"method":"GET","path":"/api/websearch/provider","fields":[["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
"websearch.query":{"method":"POST","path":"/api/websearch","fields":[["location","query",true,"{ directory: string? }?"],["query","payload",false,null],["providerID","payload",true,null]],"body":"object","reply":"json"},
|
||||
"experimental.usage.limits":{"method":"GET","path":"/api/experimental/usage/limits","fields":[["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
"experimental.flag.get":{"method":"GET","path":"/api/experimental/flag","fields":[["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
"config.get":{"method":"GET","path":"/api/config","fields":[["location","query",true,"{ directory: string? }?"]],"body":null,"reply":"json"},
|
||||
"config.shells":{"method":"GET","path":"/api/config/shell","fields":[],"body":null,"reply":"json"},
|
||||
"experimental.config.update":{"method":"PATCH","path":"/api/experimental/config","fields":[["shell","payload",false,null]],"body":"object","reply":"empty"}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -39,7 +39,7 @@ pub fn show_server(tui: &Tui, initial: Option<String>, details: bool) {
|
|||
});
|
||||
if details
|
||||
&& let Some(server) =
|
||||
initial.as_ref().and_then(|name| mcp.server(name)).filter(|server| kind(&server.status) == "failed")
|
||||
initial.as_ref().and_then(|name| mcp.server(name)).filter(|server| matches!(kind(&server.status), "failed" | "disconnected"))
|
||||
{
|
||||
mcp.detail(server);
|
||||
return;
|
||||
|
|
@ -274,6 +274,7 @@ fn kind(status: &McpServerStatus) -> &str {
|
|||
McpServerStatus::Pending(_) => "pending",
|
||||
McpServerStatus::Disabled(_) => "disabled",
|
||||
McpServerStatus::Failed(_) => "failed",
|
||||
McpServerStatus::Disconnected(_) => "disconnected",
|
||||
McpServerStatus::NeedsAuth(_) => "needs_auth",
|
||||
McpServerStatus::Unknown(value) => value.get("status").and_then(serde_json::Value::as_str).unwrap_or_default(),
|
||||
}
|
||||
|
|
@ -282,6 +283,7 @@ fn kind(status: &McpServerStatus) -> &str {
|
|||
fn status_error(status: &McpServerStatus) -> Option<&str> {
|
||||
match status {
|
||||
McpServerStatus::Failed(failed) => Some(&failed.error),
|
||||
McpServerStatus::Disconnected(disconnected) => Some(&disconnected.error),
|
||||
McpServerStatus::NeedsAuth(auth) => Some(&auth.error),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -301,6 +303,7 @@ fn status_label(status: &str, pending: bool) -> &'static str {
|
|||
match status {
|
||||
"connected" => "Connected ✓",
|
||||
"failed" => "Failed !",
|
||||
"disconnected" => "Disconnected ↻",
|
||||
"needs_auth" => "Sign in required →",
|
||||
_ => "Disabled ○",
|
||||
}
|
||||
|
|
@ -310,7 +313,7 @@ fn status_color(theme: &Theme, status: &str) -> Color {
|
|||
match status {
|
||||
"connected" => theme.text.feedback.success.base,
|
||||
"failed" => theme.text.feedback.error.base,
|
||||
"needs_auth" => theme.text.feedback.warning.base,
|
||||
"needs_auth" | "disconnected" => theme.text.feedback.warning.base,
|
||||
_ => theme.text.muted,
|
||||
}
|
||||
}
|
||||
|
|
@ -319,6 +322,7 @@ fn toggle_title(server: Option<&McpServer>) -> &'static str {
|
|||
match server.map(|server| kind(&server.status)) {
|
||||
Some("connected") => "disconnect",
|
||||
Some("failed") => "retry",
|
||||
Some("disconnected") => "reconnect",
|
||||
Some("needs_auth") => "sign in",
|
||||
_ => "connect",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ fn color(theme: &Theme, status: &McpServerStatus) -> Color {
|
|||
match status {
|
||||
McpServerStatus::Connected(_) => theme.text.feedback.success.base,
|
||||
McpServerStatus::Failed(_) => theme.text.feedback.error.base,
|
||||
McpServerStatus::NeedsAuth(_) => theme.text.feedback.warning.base,
|
||||
McpServerStatus::NeedsAuth(_) | McpServerStatus::Disconnected(_) => theme.text.feedback.warning.base,
|
||||
_ => theme.text.muted,
|
||||
}
|
||||
}
|
||||
|
|
@ -96,6 +96,7 @@ fn describe(status: &McpServerStatus) -> String {
|
|||
match status {
|
||||
McpServerStatus::Connected(_) => "Connected".to_owned(),
|
||||
McpServerStatus::Failed(failed) => failed.error.clone(),
|
||||
McpServerStatus::Disconnected(disconnected) => format!("Disconnected: {}", disconnected.error),
|
||||
McpServerStatus::Disabled(_) => "Disabled in configuration".to_owned(),
|
||||
McpServerStatus::NeedsAuth(auth) => format!("Needs authentication: {}", auth.error),
|
||||
McpServerStatus::Pending(_) => "pending".to_owned(),
|
||||
|
|
|
|||
|
|
@ -65,13 +65,14 @@ fn row(item: &McpServer) -> Node {
|
|||
let dot = match status {
|
||||
"connected" => "text.feedback.success.base",
|
||||
"failed" => "text.feedback.error.base",
|
||||
"needs_auth" => "text.feedback.warning.base",
|
||||
"needs_auth" | "disconnected" => "text.feedback.warning.base",
|
||||
_ => "text.muted",
|
||||
};
|
||||
let label = match status {
|
||||
"connected" => "Connected",
|
||||
"pending" => "Connecting",
|
||||
"failed" => "Error",
|
||||
"disconnected" => "Disconnected",
|
||||
"disabled" => "Disabled",
|
||||
"needs_auth" => "Sign in",
|
||||
other => other,
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ export function mcpAuthChoices(servers: McpServer[], integrations: IntegrationIn
|
|||
|
||||
function statusHint(status: McpServer["status"]) {
|
||||
if (status.status === "needs_auth") return "needs authentication"
|
||||
if (status.status === "failed" || status.status === "disabled") return status.status
|
||||
if (status.status === "failed" || status.status === "disconnected" || status.status === "disabled")
|
||||
return status.status
|
||||
return undefined
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ function icon(status: McpServer["status"]) {
|
|||
case "connected":
|
||||
return "✓"
|
||||
case "needs_auth":
|
||||
case "disconnected":
|
||||
return "⚠"
|
||||
case "failed":
|
||||
return "✗"
|
||||
|
|
@ -44,6 +45,8 @@ function describe(status: McpServer["status"]) {
|
|||
return "needs authentication"
|
||||
case "failed":
|
||||
return `failed: ${status.error}`
|
||||
case "disconnected":
|
||||
return `disconnected: ${status.error}`
|
||||
default:
|
||||
return status.status
|
||||
}
|
||||
|
|
|
|||
11
packages/client/src/promise/generated/types.ts
generated
11
packages/client/src/promise/generated/types.ts
generated
|
|
@ -280,6 +280,8 @@ export type McpStatusDisabled = { status: "disabled" }
|
|||
|
||||
export type McpStatusFailed = { status: "failed"; error: string }
|
||||
|
||||
export type McpStatusDisconnected = { status: "disconnected"; error: string }
|
||||
|
||||
export type McpStatusNeedsAuth = { status: "needs_auth"; error: string }
|
||||
|
||||
export type McpResource = { server: string; name: string; uri: string; description?: string; mimeType?: string }
|
||||
|
|
@ -856,7 +858,13 @@ export type IntegrationCommandAttempt = { attemptID: IntegrationAttemptID; time:
|
|||
|
||||
export type McpServer = {
|
||||
name: string
|
||||
status: McpStatusConnected | McpStatusPending | McpStatusDisabled | McpStatusFailed | McpStatusNeedsAuth
|
||||
status:
|
||||
| McpStatusConnected
|
||||
| McpStatusPending
|
||||
| McpStatusDisabled
|
||||
| McpStatusFailed
|
||||
| McpStatusDisconnected
|
||||
| McpStatusNeedsAuth
|
||||
title?: string
|
||||
integrationID?: IntegrationID
|
||||
}
|
||||
|
|
@ -2783,6 +2791,7 @@ export type ConfigEntry =
|
|||
compaction_jobs?: boolean
|
||||
sqlite_fts?: boolean
|
||||
browser_stream_tunnel?: boolean
|
||||
mcp_resilience?: boolean
|
||||
video_generate?: boolean | { model?: string | { providerID: string; model: string; variant?: string } }
|
||||
part_rows?: boolean
|
||||
image_generate?: boolean | { model?: string | { providerID: string; model: string; variant?: string } }
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import { Form } from "../form.js"
|
|||
import { Integration } from "../integration.js"
|
||||
import { KeyedMutex } from "../effect/keyed-mutex.js"
|
||||
import { Location } from "../location.js"
|
||||
import { Hash } from "@opencode/util/hash"
|
||||
import { waitForAbort } from "@opencode/util/process"
|
||||
import { State } from "../state.js"
|
||||
import type { McpClient } from "./client.js"
|
||||
|
|
@ -102,10 +101,10 @@ export class ToolCallError extends Schema.TaggedError<ToolCallError>()("MCP.Tool
|
|||
|
||||
const unavailable = (server: ServerName, entry: ServerEntry) => {
|
||||
const status = entry.status
|
||||
// The model cannot reconnect a server from /mcps; one that dropped on its own reconnects on the next call.
|
||||
if (entry.disconnected)
|
||||
return `MCP server "${server}" lost its connection: ${entry.disconnected.reason}. It reconnects on the next call; try again shortly.`
|
||||
switch (status.status) {
|
||||
// The model cannot reconnect a server from /mcps; one that dropped reconnects on the next call.
|
||||
case "disconnected":
|
||||
return `MCP server "${server}" lost its connection: ${status.error}. It reconnects on the next call; try again shortly.`
|
||||
case "failed":
|
||||
return `MCP server "${server}" is not connected: ${status.error}. Reconnect it from /mcps.`
|
||||
case "needs_auth":
|
||||
|
|
@ -129,12 +128,14 @@ type ServerEntry = {
|
|||
// Set when a remote server is registered as an OAuth integration; the credential lives in the global store.
|
||||
integrationID?: Integration.ID
|
||||
registration?: State.Registration
|
||||
// Tools offered while the connection has none: the last list of a connection that dropped on its own, or the
|
||||
// disk-cached list of a server still starting. The next connect replaces it; a failure or an explicit stop drops it.
|
||||
// Tools offered while the connection has none: the last list of a connection that dropped or is reconnecting, or the
|
||||
// disk-cached list of a server still starting. The next connect replaces it; only disabling, removing or
|
||||
// reconfiguring the server drops it.
|
||||
retained?: ReadonlyArray<McpClient.Tool>
|
||||
// Set while the connection is down after dropping on its own. The next request that needs the server reconnects,
|
||||
// unless a reconnect failed and its backoff has not passed yet. An explicit lifecycle operation clears it.
|
||||
disconnected?: { failures: number; retryAt: number; reason: string }
|
||||
// Set while the server is down with its tools kept. The next request that needs the server reconnects, unless a
|
||||
// reconnect failed and its backoff has not passed yet. A sign-in that is needed, or an explicit lifecycle operation,
|
||||
// clears it.
|
||||
disconnected?: { failures: number; retryAt: number }
|
||||
}
|
||||
|
||||
// A client-hosted MCP server attached over a connection the client opened. Internal: never listed,
|
||||
|
|
@ -152,7 +153,6 @@ const STARTUP_GRACE_MS = 2_000
|
|||
// After a failed reconnect, requests fail at once for 1 s, doubling per consecutive failure up to 30 s.
|
||||
const RECONNECT_BACKOFF_MS = 1_000
|
||||
const RECONNECT_MAX_BACKOFF_MS = 30_000
|
||||
const disconnectedError = (error: string) => `${error} (tools kept; reconnects when next used)`
|
||||
|
||||
// Last listed tools per server, keyed by everything that changes the connection (see `McpPool.key`).
|
||||
const CachedTools = Schema.fromJsonString(
|
||||
|
|
@ -652,32 +652,37 @@ export const layer = (options?: Options) =>
|
|||
})
|
||||
|
||||
// One file per connection identity, so a change to the command, URL, environment, headers or signed-in
|
||||
// account reads a different file. Secrets reach the name only as fingerprints inside a one-way hash.
|
||||
const toolsFile = Effect.fnUntraced(function* (entry: ServerEntry) {
|
||||
// account reads a different file. Secrets reach the name only as fingerprints inside a one-way hash. A local
|
||||
// server's tools may depend on the directory it runs in, so its exact file includes that directory, and a second
|
||||
// file without it lets a directory it has not run in yet start from the list another directory saw.
|
||||
const toolsFiles = Effect.fnUntraced(function* (entry: ServerEntry) {
|
||||
const credential = yield* selectCredential(entry)
|
||||
const { McpStdio } = yield* Effect.promise(() => import("./stdio.js"))
|
||||
const key = McpPool.key({
|
||||
config: entry.config,
|
||||
cwd: entry.config.type === "local" ? McpStdio.resolveCwd(location.directory, entry.config.cwd) : undefined,
|
||||
credential: credential?.id,
|
||||
clientInfo: options?.clientInfo,
|
||||
})
|
||||
return path.join(
|
||||
global.cache,
|
||||
"mcp",
|
||||
"tools",
|
||||
`${Hash.sha256(JSON.stringify([location.workspaceID, key]))}.json`,
|
||||
)
|
||||
const file = (cwd: string | undefined) =>
|
||||
path.join(
|
||||
global.cache,
|
||||
"mcp",
|
||||
"tools",
|
||||
`${Hash.sha256(
|
||||
JSON.stringify([
|
||||
location.workspaceID,
|
||||
McpPool.key({ config: entry.config, cwd, credential: credential?.id, clientInfo: options?.clientInfo }),
|
||||
]),
|
||||
)}.json`,
|
||||
)
|
||||
if (entry.config.type !== "local") return [file(undefined)]
|
||||
return [file(McpStdio.resolveCwd(location.directory, entry.config.cwd)), file(undefined)]
|
||||
})
|
||||
|
||||
const loadTools = Effect.fnUntraced(function* (name: ServerName, entry: ServerEntry) {
|
||||
if (entry.config.disabled || !(yield* resilient)) return
|
||||
const text = yield* fsutil
|
||||
.readFileStringSafe(yield* toolsFile(entry))
|
||||
.pipe(Effect.orElseSucceed(() => undefined))
|
||||
if (text === undefined) return
|
||||
entry.retained = Option.getOrUndefined(decodeCachedTools(text))?.tools
|
||||
if (entry.retained) yield* bus.publish(McpEvent.ToolsChanged, { server: name })
|
||||
for (const file of yield* toolsFiles(entry)) {
|
||||
const text = yield* fsutil.readFileStringSafe(file).pipe(Effect.orElseSucceed(() => undefined))
|
||||
const tools = text === undefined ? undefined : Option.getOrUndefined(decodeCachedTools(text))?.tools
|
||||
if (!tools) continue
|
||||
entry.retained = tools
|
||||
return yield* bus.publish(McpEvent.ToolsChanged, { server: name })
|
||||
}
|
||||
})
|
||||
|
||||
const saveTools = (entry: ServerEntry) =>
|
||||
|
|
@ -685,24 +690,45 @@ export const layer = (options?: Options) =>
|
|||
Effect.gen(function* () {
|
||||
const tools = entry.connection.tools
|
||||
if (!tools || !(yield* resilient)) return
|
||||
yield* fsutil.writeWithDirs(yield* toolsFile(entry), encodeCachedTools({ tools }))
|
||||
const text = encodeCachedTools({ tools })
|
||||
yield* Effect.forEach(yield* toolsFiles(entry), (file) => fsutil.writeWithDirs(file, text), {
|
||||
concurrency: "unbounded",
|
||||
discard: true,
|
||||
})
|
||||
}).pipe(Effect.catch((error) => Effect.logWarning("failed to cache MCP tools", { error: error.message }))),
|
||||
)
|
||||
|
||||
const dropRetained = Effect.fnUntraced(function* (name: ServerName, entry: ServerEntry) {
|
||||
// The tagged list may still hold the dropped tools, and `retain` falls back to it.
|
||||
entry.tagged = undefined
|
||||
if (!entry.retained) return
|
||||
entry.retained = undefined
|
||||
yield* bus.publish(McpEvent.ToolsChanged, { server: name })
|
||||
})
|
||||
|
||||
// Keeps offering the connection's last tools while it stops, so a restart or a drop changes nothing the
|
||||
// model sees. Runs under the server lock.
|
||||
const retain = Effect.fnUntraced(function* (entry: ServerEntry) {
|
||||
if (!(yield* resilient)) return
|
||||
// A shared connection has already emptied its catalogs, so fall back to the last list read from it.
|
||||
entry.retained = entry.connection.tools ?? entry.retained ?? entry.tagged?.source
|
||||
})
|
||||
|
||||
// Stops and starts the connection again, keeping its tools while it does.
|
||||
const restart = Effect.fnUntraced(function* (entry: ServerEntry) {
|
||||
yield* retain(entry)
|
||||
entry.disconnected = undefined
|
||||
yield* entry.connection.stop
|
||||
yield* entry.connection.start
|
||||
})
|
||||
|
||||
// A connection that went away on its own keeps offering its last tools and reports why it went; the next request
|
||||
// that needs it reconnects. Runs under the server lock.
|
||||
const drop = Effect.fnUntraced(function* (name: ServerName, entry: ServerEntry, reason: string) {
|
||||
// A shared connection has already emptied its catalogs, so fall back to the last list read from it.
|
||||
entry.retained = entry.connection.tools ?? entry.tagged?.source
|
||||
entry.disconnected = { failures: 0, retryAt: 0, reason }
|
||||
yield* retain(entry)
|
||||
entry.disconnected = { failures: 0, retryAt: 0 }
|
||||
yield* entry.connection.stop
|
||||
entry.status = { status: "failed", error: disconnectedError(reason) }
|
||||
entry.status = { status: "disconnected", error: reason }
|
||||
yield* Effect.logWarning("mcp connection dropped", { server: name, reason })
|
||||
yield* bus.publish(McpEvent.StatusChanged, { server: name })
|
||||
})
|
||||
|
|
@ -857,18 +883,19 @@ export const layer = (options?: Options) =>
|
|||
}),
|
||||
failed: (failure) =>
|
||||
Effect.gen(function* () {
|
||||
// A failed reconnect keeps the tools and backs off; an auth failure drops them like any other.
|
||||
const disconnected = entry.disconnected
|
||||
if (disconnected && failure.status === "failed") {
|
||||
// A server with tools to keep keeps them: a failed attempt backs off until the next request
|
||||
// retries, and one that needs a sign-in waits for it.
|
||||
if (entry.retained && failure.status === "failed") {
|
||||
const disconnected = entry.disconnected ?? { failures: 0, retryAt: 0 }
|
||||
disconnected.failures += 1
|
||||
disconnected.reason = failure.error
|
||||
disconnected.retryAt =
|
||||
(yield* Clock.currentTimeMillis) +
|
||||
Math.min(
|
||||
RECONNECT_BACKOFF_MS * 2 ** Math.min(disconnected.failures - 1, 5),
|
||||
RECONNECT_MAX_BACKOFF_MS,
|
||||
)
|
||||
entry.status = { status: "failed", error: disconnectedError(failure.error) }
|
||||
entry.disconnected = disconnected
|
||||
entry.status = { status: "disconnected", error: failure.error }
|
||||
yield* Effect.logWarning("mcp reconnect failed", { server: name, error: failure.error })
|
||||
return yield* bus.publish(McpEvent.StatusChanged, { server: name })
|
||||
}
|
||||
|
|
@ -876,7 +903,6 @@ export const layer = (options?: Options) =>
|
|||
entry.disconnected = undefined
|
||||
yield* Effect.logWarning("mcp connect failed", { server: name, status: entry.status })
|
||||
yield* bus.publish(McpEvent.StatusChanged, { server: name })
|
||||
yield* dropRetained(name, entry)
|
||||
}),
|
||||
// Every start runs under the server lock, so the attempt read here is the one it began.
|
||||
settled: Effect.suspend(() => {
|
||||
|
|
@ -1138,9 +1164,7 @@ export const layer = (options?: Options) =>
|
|||
const entry = entries.get(name)
|
||||
if (!entry || entry.integrationID !== integrationID) return
|
||||
if (entry.status.status === "disabled") return
|
||||
entry.disconnected = undefined
|
||||
yield* entry.connection.stop
|
||||
yield* entry.connection.start
|
||||
yield* restart(entry)
|
||||
}).pipe(locks.withLock(name))
|
||||
})
|
||||
fork(
|
||||
|
|
@ -1201,9 +1225,7 @@ export const layer = (options?: Options) =>
|
|||
yield* transition(
|
||||
Effect.gen(function* () {
|
||||
const entry = yield* requireServer(name)
|
||||
entry.disconnected = undefined
|
||||
yield* entry.connection.stop
|
||||
yield* entry.connection.start
|
||||
yield* restart(entry)
|
||||
}).pipe(locks.withLock(name)),
|
||||
)
|
||||
}),
|
||||
|
|
@ -1351,7 +1373,7 @@ export const layer = (options?: Options) =>
|
|||
getSkill: Effect.fn("MCP.getSkill")(function* (input) {
|
||||
const name = ServerName.make(input.server)
|
||||
const target = yield* connected(name)
|
||||
if (!target.client) return yield* Effect.fail(new Error(unavailable(name, target.entry.status)))
|
||||
if (!target.client) return yield* Effect.fail(new Error(unavailable(name, target.entry)))
|
||||
return yield* target.entry.connection.recovering(target.client, (connection) =>
|
||||
connection.skills
|
||||
? connection.skills.get(input.uri)
|
||||
|
|
@ -1361,7 +1383,7 @@ export const layer = (options?: Options) =>
|
|||
readSkill: Effect.fn("MCP.readSkill")(function* (input) {
|
||||
const name = ServerName.make(input.server)
|
||||
const target = yield* connected(name)
|
||||
if (!target.client) return yield* Effect.fail(new Error(unavailable(name, target.entry.status)))
|
||||
if (!target.client) return yield* Effect.fail(new Error(unavailable(name, target.entry)))
|
||||
return yield* target.entry.connection.recovering(target.client, (connection) =>
|
||||
connection.skills
|
||||
? connection.skills.read(input.entry, input.ref)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import fs from "node:fs/promises"
|
|||
import os from "node:os"
|
||||
import { describe, expect, spyOn, test } from "bun:test"
|
||||
import {
|
||||
Client,
|
||||
InMemoryTransport,
|
||||
StreamableHTTPClientTransport,
|
||||
deserializeMessage,
|
||||
|
|
@ -76,8 +75,6 @@ import { TestClock } from "effect/testing"
|
|||
import { ChildProcess, ChildProcessSpawner } from "effect/process"
|
||||
import { ExitCode, makeHandle, ProcessId } from "effect/process/ChildProcessSpawner"
|
||||
import { Global } from "@opencode/util/global"
|
||||
import { App } from "@opencode/core/app"
|
||||
import { Flag } from "@opencode/core/flag"
|
||||
import { FSUtil } from "@opencode/util/fs-util"
|
||||
import { isRecord } from "@opencode/util/record"
|
||||
import { CrossSpawnSpawner } from "@opencode/util/cross-spawn-spawner"
|
||||
|
|
@ -4335,6 +4332,8 @@ function fakeStdio() {
|
|||
environment: Layer.succeed(
|
||||
Environment.Service,
|
||||
Environment.Service.of({
|
||||
id: Environment.localID,
|
||||
local: true,
|
||||
files: Environment.makeFiles(Environment.makeMemoryDriver()),
|
||||
spawner: ChildProcessSpawner.make(spawn),
|
||||
}),
|
||||
|
|
@ -4373,10 +4372,10 @@ describe("MCP reconnect", () => {
|
|||
expect(tools.map((tool) => tool.name)).toEqual(["echo"])
|
||||
|
||||
fake.state.exit(1, "database is locked")
|
||||
const status = yield* eventually(server(service), (status) => status?.status === "failed")
|
||||
const error = status?.status === "failed" ? status.error : ""
|
||||
expect(error).toContain("MCP server process exited with code 1: database is locked")
|
||||
expect(error).toContain("reconnects when next used")
|
||||
const status = yield* eventually(server(service), (status) => status?.status === "disconnected")
|
||||
expect(status?.status === "disconnected" ? status.error : "").toContain(
|
||||
"MCP server process exited with code 1: database is locked",
|
||||
)
|
||||
// The very same tool objects, so the registry and Code Mode see no change.
|
||||
expect((yield* service.tools())[0]).toBe(tools[0]!)
|
||||
// Nothing reconnects in the background.
|
||||
|
|
@ -4411,12 +4410,12 @@ describe("MCP reconnect", () => {
|
|||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
const tools = yield* service.tools()
|
||||
fake.state.exit(1)
|
||||
yield* eventually(server(service), (status) => status?.status === "failed")
|
||||
yield* eventually(server(service), (status) => status?.status === "disconnected")
|
||||
|
||||
fake.state.broken = "missing API key"
|
||||
expect((yield* echo(service).pipe(Effect.flip)).message).toContain("missing API key")
|
||||
expect(fake.state.spawns).toBe(2)
|
||||
expect((yield* server(service))?.status).toBe("failed")
|
||||
expect((yield* server(service))?.status).toBe("disconnected")
|
||||
expect(yield* service.tools()).toEqual(tools)
|
||||
|
||||
// Within the 1 s backoff a call fails with the same error and nothing is spawned. The model is told the
|
||||
|
|
@ -4454,7 +4453,7 @@ describe("MCP reconnect", () => {
|
|||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
fake.state.exit(1)
|
||||
yield* eventually(server(service), (status) => status?.status === "failed")
|
||||
yield* eventually(server(service), (status) => status?.status === "disconnected")
|
||||
|
||||
yield* service.disconnect("resources")
|
||||
expect(yield* service.tools()).toEqual([])
|
||||
|
|
@ -4484,7 +4483,7 @@ describe("MCP reconnect", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
reconnecting.effect("drops the tools of a server whose reconnect needs authorization", () =>
|
||||
reconnecting.effect("keeps the tools of a server whose reconnect needs authorization and waits for a sign-in", () =>
|
||||
Effect.gen(function* () {
|
||||
const denied = { value: false }
|
||||
const remote = yield* resourceServer({
|
||||
|
|
@ -4499,18 +4498,20 @@ describe("MCP reconnect", () => {
|
|||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
yield* echo(service)
|
||||
const tools = yield* service.tools()
|
||||
|
||||
// The restarted server no longer knows the session and refuses a new one without a login.
|
||||
denied.value = true
|
||||
yield* Effect.promise(remote.restart)
|
||||
const initializations = remote.state.initializations
|
||||
yield* echo(service).pipe(Effect.flip)
|
||||
expect((yield* server(service))?.status).toBe("needs_auth")
|
||||
expect(yield* service.tools()).toEqual([])
|
||||
expect(yield* service.tools()).toEqual(tools)
|
||||
|
||||
// Only a sign-in brings it back, so later calls say so instead of reconnecting.
|
||||
const initializations = remote.state.initializations
|
||||
yield* TestClock.adjust("1 minute")
|
||||
yield* echo(service).pipe(Effect.flip)
|
||||
expect(remote.state.initializations).toBe(initializations + 1)
|
||||
expect((yield* echo(service).pipe(Effect.flip)).message).toContain("needs authentication")
|
||||
expect(remote.state.initializations).toBe(initializations)
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
resourceMcpLayer(new ConfigMCP.Remote({ type: "remote", url: remote.url }), undefined, undefined, {
|
||||
|
|
@ -4537,14 +4538,16 @@ describe("MCP reconnect", () => {
|
|||
const listed = yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
yield* eventually(files, (names) => names.length === 1)
|
||||
// One file for this directory and one any directory can start from.
|
||||
yield* eventually(files, (names) => names.length === 2)
|
||||
return yield* service.tools()
|
||||
}).pipe(Effect.provide(open(secret)))
|
||||
const [file] = yield* files
|
||||
expect(file).not.toContain("do-not-store")
|
||||
expect(
|
||||
yield* Effect.promise(() => fs.readFile(path.join(cache.path, "mcp", "tools", file!), "utf8")),
|
||||
).not.toContain("do-not-store")
|
||||
for (const file of yield* files) {
|
||||
expect(file).not.toContain("do-not-store")
|
||||
expect(
|
||||
yield* Effect.promise(() => fs.readFile(path.join(cache.path, "mcp", "tools", file), "utf8")),
|
||||
).not.toContain("do-not-store")
|
||||
}
|
||||
|
||||
// The same config offers the cached tools before its server answers.
|
||||
const gate = yield* Deferred.make<void>()
|
||||
|
|
@ -4573,7 +4576,98 @@ describe("MCP reconnect", () => {
|
|||
yield* Deferred.succeed(changed, undefined)
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
}).pipe(Effect.provide(open(new ConfigMCP.Local({ ...config, environment: { TOKEN: "rotated" } }))))
|
||||
expect(yield* files).toHaveLength(2)
|
||||
expect(yield* files).toHaveLength(4)
|
||||
}),
|
||||
)
|
||||
|
||||
reconnecting.effect("offers a local server's cached tools in a directory it has not run in yet", () =>
|
||||
Effect.gen(function* () {
|
||||
const fake = fakeStdio()
|
||||
const cache = yield* tmpdirScoped()
|
||||
const other = yield* tmpdirScoped()
|
||||
const open = (directory?: string) =>
|
||||
resourceMcpLayer(config, undefined, undefined, {
|
||||
environment: fake.environment,
|
||||
flags: "mcp_resilience",
|
||||
cache: cache.path,
|
||||
directory,
|
||||
})
|
||||
const files = Effect.promise(() => fs.readdir(path.join(cache.path, "mcp", "tools")).catch((): string[] => []))
|
||||
const listed = yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
yield* eventually(files, (names) => names.length === 2)
|
||||
return yield* service.tools()
|
||||
}).pipe(Effect.provide(open()))
|
||||
|
||||
const gate = yield* Deferred.make<void>()
|
||||
fake.state.gate = gate
|
||||
yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
expect(yield* eventually(service.tools(), (tools) => tools.length > 0)).toEqual(listed)
|
||||
yield* Deferred.succeed(gate, undefined)
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
expect(yield* service.tools()).toEqual(listed)
|
||||
}).pipe(Effect.provide(open(other.path)))
|
||||
// Its own directory now has a file of its own.
|
||||
expect(yield* files).toHaveLength(3)
|
||||
}),
|
||||
)
|
||||
|
||||
reconnecting.effect("keeps cached tools when a server fails to start and reconnects on the next call", () =>
|
||||
Effect.gen(function* () {
|
||||
const fake = fakeStdio()
|
||||
const cache = yield* tmpdirScoped()
|
||||
const open = () =>
|
||||
resourceMcpLayer(config, undefined, undefined, {
|
||||
environment: fake.environment,
|
||||
flags: "mcp_resilience",
|
||||
cache: cache.path,
|
||||
})
|
||||
const files = Effect.promise(() => fs.readdir(path.join(cache.path, "mcp", "tools")).catch((): string[] => []))
|
||||
const listed = yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
yield* eventually(files, (names) => names.length === 2)
|
||||
return yield* service.tools()
|
||||
}).pipe(Effect.provide(open()))
|
||||
|
||||
fake.state.broken = "missing API key"
|
||||
yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
const status = yield* eventually(server(service), (status) => status?.status === "disconnected")
|
||||
expect(status?.status === "disconnected" ? status.error : "").toContain("missing API key")
|
||||
expect(yield* service.tools()).toEqual(listed)
|
||||
|
||||
fake.state.broken = undefined
|
||||
yield* TestClock.adjust("1 second")
|
||||
expect((yield* echo(service)).isError).toBe(false)
|
||||
expect(yield* server(service)).toEqual({ status: "connected" })
|
||||
}).pipe(Effect.provide(open()))
|
||||
}),
|
||||
)
|
||||
|
||||
reconnecting.effect("keeps the same tools while the user reconnects a server", () =>
|
||||
Effect.gen(function* () {
|
||||
const fake = fakeStdio()
|
||||
yield* Effect.gen(function* () {
|
||||
const service = yield* Mcp.Service
|
||||
yield* eventually(server(service), (status) => status?.status === "connected")
|
||||
const tools = yield* service.tools()
|
||||
|
||||
const gate = yield* Deferred.make<void>()
|
||||
fake.state.gate = gate
|
||||
const reconnect = yield* service.connect("resources").pipe(Effect.forkChild)
|
||||
yield* eventually(
|
||||
Effect.sync(() => fake.state.spawns),
|
||||
(spawns) => spawns === 2,
|
||||
)
|
||||
expect((yield* service.tools())[0]).toBe(tools[0]!)
|
||||
yield* Deferred.succeed(gate, undefined)
|
||||
yield* Fiber.join(reconnect)
|
||||
expect(yield* server(service)).toEqual({ status: "connected" })
|
||||
expect(yield* service.tools()).toEqual(tools)
|
||||
}).pipe(Effect.provide(resilient(fake)))
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -414,6 +414,7 @@ button.session-service-row:focus-visible,
|
|||
.session-service-dot[data-status="failed"] {
|
||||
color: var(--icon-critical-base);
|
||||
}
|
||||
.session-service-dot[data-status="disconnected"],
|
||||
.session-service-dot[data-status="needs_auth"] {
|
||||
color: var(--icon-warning-base);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export default {
|
|||
skills: "Skills",
|
||||
"skills.empty": "No skills configured",
|
||||
failed: "Failed",
|
||||
disconnected: "Disconnected",
|
||||
retry: "Retry",
|
||||
connecting: "Connecting…",
|
||||
needsAuth: "Sign in required",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const MCP_TOGGLE_TIMEOUT_MS = 60_000
|
|||
/** An MCP server's status, as the server lists it. */
|
||||
export type McpServerStatus =
|
||||
| { readonly status: "connected" | "pending" | "disabled" }
|
||||
| { readonly status: "failed" | "needs_auth"; readonly error: string }
|
||||
| { readonly status: "failed" | "disconnected" | "needs_auth"; readonly error: string }
|
||||
|
||||
/** A sign-in that also accepts the redirect URL pasted from the browser. */
|
||||
export type McpSignIn = {
|
||||
|
|
@ -214,9 +214,11 @@ function step(state: Live, event: Exclude<McpEvent, { type: "disposed" }>): McpT
|
|||
return { state: { ...state, dialog: CLOSED }, effects: closeDialog(dialog) }
|
||||
|
||||
// A retry stays open while it connects, and a new failure replaces the error in place.
|
||||
if (status.status !== "failed" || status.error === dialog.error) return { state, effects: NONE }
|
||||
const error = mcpError(status)
|
||||
|
||||
return { state: { ...state, dialog: { ...dialog, error: status.error } }, effects: NONE }
|
||||
if (error === undefined || error === dialog.error) return { state, effects: NONE }
|
||||
|
||||
return { state: { ...state, dialog: { ...dialog, error } }, effects: NONE }
|
||||
}
|
||||
|
||||
function settled(
|
||||
|
|
@ -269,6 +271,11 @@ function release(transition: McpTransition): McpTransition {
|
|||
return { state: { status: "disposed" }, effects: transition.effects }
|
||||
}
|
||||
|
||||
/** The error a failed or disconnected server shows; a sign-in prompt is not one. */
|
||||
export function mcpError(status: McpServerStatus | undefined) {
|
||||
return status?.status === "failed" || status?.status === "disconnected" ? status.error : undefined
|
||||
}
|
||||
|
||||
function closeDialog(dialog: McpErrorDialog): readonly McpEffect[] {
|
||||
return dialog.status === "open" ? [{ type: "close-dialog", attempt: dialog.attempt }] : NONE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import {
|
|||
import {
|
||||
initialMcpState,
|
||||
mcpDialogView,
|
||||
mcpError,
|
||||
mcpRowView,
|
||||
transitionMcp,
|
||||
type McpEffect,
|
||||
|
|
@ -600,11 +601,7 @@ function useMcp(props: ServiceProps, controllers: McpControllers, close: () => v
|
|||
const pending = () => view().pending
|
||||
const busy = () => view().busy
|
||||
|
||||
const failure = () => {
|
||||
const status = server().status
|
||||
|
||||
return status.status === "failed" ? status.error : undefined
|
||||
}
|
||||
const failure = () => mcpError(server().status)
|
||||
|
||||
const signIn = () => server().status.status === "needs_auth" && !!server().integrationID
|
||||
|
||||
|
|
@ -618,6 +615,8 @@ function useMcp(props: ServiceProps, controllers: McpControllers, close: () => v
|
|||
|
||||
if (status === "failed") return ctx.t("failed")
|
||||
|
||||
if (status === "disconnected") return ctx.t("disconnected")
|
||||
|
||||
return ctx.t(status === "connected" ? "mcp.connected" : "mcp.disabled")
|
||||
}
|
||||
|
||||
|
|
@ -1427,7 +1426,9 @@ function createMcpController(server: ServerRef, directory: string, release: () =
|
|||
// A successful HTTP response can still leave the MCP connection in a failed state.
|
||||
const status = current?.status
|
||||
|
||||
if (status?.status === "failed") return { type: "toggle.failed", name, attempt, error: status.error, server: true }
|
||||
const error = mcpError(status)
|
||||
|
||||
if (error !== undefined) return { type: "toggle.failed", name, attempt, error, server: true }
|
||||
|
||||
return { type: "toggle.succeeded", name, attempt }
|
||||
}
|
||||
|
|
@ -1524,7 +1525,9 @@ function McpErrorDialog(props: {
|
|||
}
|
||||
|
||||
function statusError(status: McpServerStatus | undefined) {
|
||||
return status?.status === "failed" || status?.status === "needs_auth" ? status.error : undefined
|
||||
return status?.status === "failed" || status?.status === "disconnected" || status?.status === "needs_auth"
|
||||
? status.error
|
||||
: undefined
|
||||
}
|
||||
|
||||
// Waits for an MCP sign-in that also accepts the redirect URL pasted from the browser, for when the browser cannot
|
||||
|
|
|
|||
20
packages/protocol/openapi.json
generated
20
packages/protocol/openapi.json
generated
|
|
@ -19066,6 +19066,9 @@
|
|||
"browser_stream_tunnel": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"mcp_resilience": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"video_generate": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
|
@ -23208,6 +23211,9 @@
|
|||
{
|
||||
"$ref": "#/components/schemas/Mcp.Status.Failed"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/Mcp.Status.Disconnected"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/Mcp.Status.NeedsAuth"
|
||||
}
|
||||
|
|
@ -23245,6 +23251,20 @@
|
|||
"required": ["status"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"Mcp.Status.Disconnected": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["disconnected"]
|
||||
},
|
||||
"error": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["status", "error"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"Mcp.Status.Failed": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export const registry = {
|
|||
browser_stream_tunnel:
|
||||
"Stream remote desktop browser TCP traffic over one prewarmed, ticket-authenticated binary WebSocket per live browser attachment instead of per-chunk RPC.",
|
||||
mcp_resilience:
|
||||
"Keep an MCP server's tools when its connection drops on its own and reconnect it on the next call that needs it, and offer each server's last listed tools from a disk cache while it starts.",
|
||||
"Keep an MCP server's tools when its connection drops, a reconnect fails or it needs a new sign-in, and reconnect it on the next call that needs it. Offer each server's last listed tools from a disk cache while it starts.",
|
||||
} as const satisfies Record<string, string>
|
||||
export type Key = keyof typeof registry
|
||||
|
||||
|
|
|
|||
|
|
@ -86,12 +86,16 @@ const Disabled = Schema.Struct({ status: Schema.Literal("disabled") }).annotate(
|
|||
const Failed = Schema.Struct({ status: Schema.Literal("failed"), error: Schema.String }).annotate({
|
||||
identifier: "Mcp.Status.Failed",
|
||||
})
|
||||
// Dropped on its own: its last tools stay listed, and the next call that needs it reconnects.
|
||||
const Disconnected = Schema.Struct({ status: Schema.Literal("disconnected"), error: Schema.String }).annotate({
|
||||
identifier: "Mcp.Status.Disconnected",
|
||||
})
|
||||
const NeedsAuth = Schema.Struct({ status: Schema.Literal("needs_auth"), error: Schema.String }).annotate({
|
||||
identifier: "Mcp.Status.NeedsAuth",
|
||||
})
|
||||
|
||||
export type Status = typeof Status.Type
|
||||
export const Status = Schema.Union([Connected, Pending, Disabled, Failed, NeedsAuth]).pipe(
|
||||
export const Status = Schema.Union([Connected, Pending, Disabled, Failed, Disconnected, NeedsAuth]).pipe(
|
||||
Schema.toTaggedUnion("status"),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ import { DialogIntegration } from "./dialog-integration"
|
|||
import { useLocation } from "../context/location"
|
||||
|
||||
function statusError(status: McpServer["status"]) {
|
||||
if (status.status === "failed" || status.status === "needs_auth") return status.error
|
||||
if (status.status === "failed" || status.status === "disconnected" || status.status === "needs_auth")
|
||||
return status.error
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +28,9 @@ function Status(props: { status: McpServer["status"]; loading: boolean }) {
|
|||
if (props.status.status === "failed") {
|
||||
return <>Failed !</>
|
||||
}
|
||||
if (props.status.status === "disconnected") {
|
||||
return <>Disconnected ↻</>
|
||||
}
|
||||
if (props.status.status === "needs_auth") {
|
||||
return <>Sign in required →</>
|
||||
}
|
||||
|
|
@ -50,14 +54,16 @@ export function DialogMcp(props: { initialServer?: string; details?: boolean } =
|
|||
const initial = props.initialServer ? servers().find((server) => server.name === props.initialServer) : undefined
|
||||
const [focused, setFocused] = createSignal<string | undefined>(props.initialServer)
|
||||
const [detail, setDetail] = createSignal<McpServer | undefined>(
|
||||
props.details && initial?.status.status === "failed" ? initial : undefined,
|
||||
props.details && (initial?.status.status === "failed" || initial?.status.status === "disconnected")
|
||||
? initial
|
||||
: undefined,
|
||||
)
|
||||
const [loading, setLoading] = createSignal<ReadonlySet<string>>(new Set())
|
||||
|
||||
const statusColor = (status: McpServer["status"]) => {
|
||||
if (status.status === "connected") return theme.text.feedback.success.base
|
||||
if (status.status === "failed") return theme.text.feedback.error.base
|
||||
if (status.status === "needs_auth") return theme.text.feedback.warning.base
|
||||
if (status.status === "needs_auth" || status.status === "disconnected") return theme.text.feedback.warning.base
|
||||
return theme.text.muted
|
||||
}
|
||||
|
||||
|
|
@ -86,6 +92,7 @@ export function DialogMcp(props: { initialServer?: string; details?: boolean } =
|
|||
const status = focusedServer()?.status.status
|
||||
if (status === "connected") return "disconnect"
|
||||
if (status === "failed") return "retry"
|
||||
if (status === "disconnected") return "reconnect"
|
||||
if (status === "needs_auth") return "sign in"
|
||||
return "connect"
|
||||
})
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function DialogStatus() {
|
|||
const color = (status: string) => {
|
||||
if (status === "connected") return theme.text.feedback.success.base
|
||||
if (status === "failed") return theme.text.feedback.error.base
|
||||
if (status === "needs_auth") return theme.text.feedback.warning.base
|
||||
if (status === "needs_auth" || status === "disconnected") return theme.text.feedback.warning.base
|
||||
return theme.text.muted
|
||||
}
|
||||
return (
|
||||
|
|
@ -33,6 +33,9 @@ export function DialogStatus() {
|
|||
<Switch fallback={item.status.status}>
|
||||
<Match when={item.status.status === "connected"}>Connected</Match>
|
||||
<Match when={item.status.status === "failed" && item.status}>{(val) => val().error}</Match>
|
||||
<Match when={item.status.status === "disconnected" && item.status}>
|
||||
{(val) => `Disconnected: ${val().error}`}
|
||||
</Match>
|
||||
<Match when={item.status.status === "disabled"}>Disabled in configuration</Match>
|
||||
<Match when={item.status.status === "needs_auth" && item.status}>
|
||||
{(val) => `Needs authentication: ${val().error}`}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export function SidebarMcp(props: { context: Plugin.Context; sessionID: string }
|
|||
if (status === "connected") return theme.text.feedback.success.base
|
||||
if (status === "failed") return theme.text.feedback.error.base
|
||||
if (status === "disabled") return theme.text.muted
|
||||
if (status === "needs_auth") return theme.text.feedback.warning.base
|
||||
if (status === "needs_auth" || status === "disconnected") return theme.text.feedback.warning.base
|
||||
return theme.text.muted
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,10 @@ export function SidebarMcp(props: { context: Plugin.Context; sessionID: string }
|
|||
minWidth={0}
|
||||
onMouseUp={() =>
|
||||
props.context.ui.dialog.show(() => (
|
||||
<DialogMcp initialServer={item.name} details={item.status.status === "failed"} />
|
||||
<DialogMcp
|
||||
initialServer={item.name}
|
||||
details={item.status.status === "failed" || item.status.status === "disconnected"}
|
||||
/>
|
||||
))
|
||||
}
|
||||
>
|
||||
|
|
@ -79,6 +82,7 @@ export function SidebarMcp(props: { context: Plugin.Context; sessionID: string }
|
|||
<Match when={item.status.status === "connected"}>Connected</Match>
|
||||
<Match when={item.status.status === "pending"}>Connecting</Match>
|
||||
<Match when={item.status.status === "failed"}>Error</Match>
|
||||
<Match when={item.status.status === "disconnected"}>Disconnected</Match>
|
||||
<Match when={item.status.status === "disabled"}>Disabled</Match>
|
||||
<Match when={item.status.status === "needs_auth"}>Sign in</Match>
|
||||
</Switch>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue