9b1a739e39
CI / Rust Checks (pull_request) Successful in 6m15s
CI / UI Checks (pull_request) Successful in 5s
CI / Community Image Smoke (pull_request) Successful in 4m25s
CI / Frontend E2E (pull_request) Successful in 5m17s
CI / Deploy (pull_request) Has been skipped
CI / Rust Checks (push) Successful in 6m9s
CI / UI Checks (push) Successful in 5s
CI / Community Image Smoke (push) Successful in 1m3s
CI / Frontend E2E (push) Successful in 3m47s
CI / Deploy (push) Failing after 3s
432 lines
16 KiB
Rust
432 lines
16 KiB
Rust
macro_rules! string_enum {
|
|
(
|
|
$(#[$meta:meta])*
|
|
pub enum $name:ident {
|
|
$($variant:ident => $value:literal),+ $(,)?
|
|
}
|
|
) => {
|
|
$(#[$meta])*
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
pub enum $name {
|
|
$($variant),+
|
|
}
|
|
|
|
impl $name {
|
|
pub const fn as_str(self) -> &'static str {
|
|
match self {
|
|
$(Self::$variant => $value),+
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
|
pub struct HttpRoute(&'static str);
|
|
|
|
impl HttpRoute {
|
|
pub const fn unmatched() -> Self {
|
|
Self("unmatched")
|
|
}
|
|
|
|
pub fn from_matched_path(path: &str) -> Self {
|
|
match path {
|
|
"/health" => Self("/health"),
|
|
"/ready" => Self("/ready"),
|
|
"/api/auth/login" => Self("/api/auth/login"),
|
|
"/api/auth/logout" => Self("/api/auth/logout"),
|
|
"/api/auth/session" => Self("/api/auth/session"),
|
|
"/api/auth/profile" => Self("/api/auth/profile"),
|
|
"/api/auth/password" => Self("/api/auth/password"),
|
|
"/api/admin/capabilities" => Self("/api/admin/capabilities"),
|
|
"/api/admin/workspaces" => Self("/api/admin/workspaces"),
|
|
"/api/admin/workspaces/{workspace_id}" => Self("/api/admin/workspaces/{workspace_id}"),
|
|
"/api/admin/workspaces/{workspace_id}/operations" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/imports/openapi/preview" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/imports/openapi/preview")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/imports/openapi/{job_id}/create" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/imports/openapi/{job_id}/create")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/analyze-quality" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/analyze-quality")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/import" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/import")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/versions" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}/versions")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/versions/{version}" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/versions/{version}",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/publish" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}/publish")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/archive" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}/archive")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/test-runs" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}/test-runs")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/samples/input-json" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/samples/input-json",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/samples/output-json" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/samples/output-json",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/drafts/generate" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/drafts/generate",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/operations/{operation_id}/export" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/operations/{operation_id}/export")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/tool-search/preview" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/tool-search/preview")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/versions/{version}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/versions/{version}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/bindings" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/bindings")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/publish" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/publish")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/unpublish" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/unpublish")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/archive" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/archive")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys/{key_id}/revoke" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys/{key_id}/revoke",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys/{key_id}" => {
|
|
Self(
|
|
"/api/admin/workspaces/{workspace_id}/agents/{agent_id}/platform-api-keys/{key_id}",
|
|
)
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/auth-profiles" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/auth-profiles")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/auth-profiles/{auth_profile_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/auth-profiles/{auth_profile_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/upstreams" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/upstreams")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/upstreams/{upstream_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/upstreams/{upstream_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/secrets" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/secrets")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/secrets/{secret_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/secrets/{secret_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/secrets/{secret_id}/rotate" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/secrets/{secret_id}/rotate")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/export" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/export")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/logs" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/logs")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/logs/{log_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/logs/{log_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/approvals" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/approvals")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/approvals/{approval_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/approvals/{approval_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/usage" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/usage")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/usage/operations/{operation_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/usage/operations/{operation_id}")
|
|
}
|
|
"/api/admin/workspaces/{workspace_id}/usage/agents/{agent_id}" => {
|
|
Self("/api/admin/workspaces/{workspace_id}/usage/agents/{agent_id}")
|
|
}
|
|
"/v1/{workspace_slug}/{agent_slug}" => Self("/v1/{workspace_slug}/{agent_slug}"),
|
|
"/v1/{workspace_slug}/{agent_slug}/approvals" => {
|
|
Self("/v1/{workspace_slug}/{agent_slug}/approvals")
|
|
}
|
|
"/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}/approve" => {
|
|
Self("/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}/approve")
|
|
}
|
|
"/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}" => {
|
|
Self("/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}")
|
|
}
|
|
"/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}/deny" => {
|
|
Self("/v1/{workspace_slug}/{agent_slug}/approvals/{approval_id}/deny")
|
|
}
|
|
_ => Self::unmatched(),
|
|
}
|
|
}
|
|
|
|
pub const fn as_str(self) -> &'static str {
|
|
self.0
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum HttpMethod {
|
|
Get => "GET",
|
|
Post => "POST",
|
|
Put => "PUT",
|
|
Patch => "PATCH",
|
|
Delete => "DELETE",
|
|
Options => "OPTIONS",
|
|
Head => "HEAD",
|
|
Connect => "CONNECT",
|
|
Trace => "TRACE",
|
|
Other => "OTHER",
|
|
}
|
|
}
|
|
|
|
impl HttpMethod {
|
|
pub fn classify(method: &str) -> Self {
|
|
match method {
|
|
"GET" => Self::Get,
|
|
"POST" => Self::Post,
|
|
"PUT" => Self::Put,
|
|
"PATCH" => Self::Patch,
|
|
"DELETE" => Self::Delete,
|
|
"OPTIONS" => Self::Options,
|
|
"HEAD" => Self::Head,
|
|
"CONNECT" => Self::Connect,
|
|
"TRACE" => Self::Trace,
|
|
_ => Self::Other,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl McpOutcome {
|
|
pub const fn from_http_status(status: u16) -> Self {
|
|
match status {
|
|
200..=299 => Self::Success,
|
|
400..=499 => Self::ClientError,
|
|
500..=599 => Self::ServerError,
|
|
_ => Self::Other,
|
|
}
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum HttpStatusClass {
|
|
Informational => "1xx",
|
|
Success => "2xx",
|
|
Redirection => "3xx",
|
|
ClientError => "4xx",
|
|
ServerError => "5xx",
|
|
Other => "other",
|
|
}
|
|
}
|
|
|
|
impl HttpStatusClass {
|
|
pub const fn from_status(status: u16) -> Self {
|
|
match status {
|
|
100..=199 => Self::Informational,
|
|
200..=299 => Self::Success,
|
|
300..=399 => Self::Redirection,
|
|
400..=499 => Self::ClientError,
|
|
500..=599 => Self::ServerError,
|
|
_ => Self::Other,
|
|
}
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum McpMethod {
|
|
Initialize => "initialize",
|
|
Initialized => "initialized",
|
|
Ping => "ping",
|
|
ToolsList => "tools_list",
|
|
ToolsCall => "tools_call",
|
|
Notification => "notification",
|
|
Unsupported => "unsupported",
|
|
Response => "response",
|
|
Invalid => "invalid",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum McpResponseMode {
|
|
Json => "json",
|
|
Sse => "sse",
|
|
Unknown => "unknown",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum McpOutcome {
|
|
Success => "success",
|
|
ClientError => "client_error",
|
|
ServerError => "server_error",
|
|
JsonRpcError => "jsonrpc_error",
|
|
ToolError => "tool_error",
|
|
Aborted => "aborted",
|
|
Other => "other",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum InvocationSource {
|
|
Internal => "internal",
|
|
AdminTestRun => "admin_test_run",
|
|
AgentToolCall => "agent_tool_call",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum ToolOutcome {
|
|
Success => "success",
|
|
Error => "error",
|
|
Aborted => "aborted",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum ToolErrorKind {
|
|
None => "none",
|
|
Schema => "schema",
|
|
Mapping => "mapping",
|
|
RestAdapter => "rest_adapter",
|
|
ProtocolAdapter => "protocol_adapter",
|
|
UnsupportedProtocol => "unsupported_protocol",
|
|
UnsupportedExecutionMode => "unsupported_execution_mode",
|
|
ConcurrencyLimit => "concurrency_limit",
|
|
InvalidPreparedRequest => "invalid_prepared_request",
|
|
ConfirmationRequired => "confirmation_required",
|
|
InvalidConfirmationToken => "invalid_confirmation_token",
|
|
ConfirmationStore => "confirmation_store",
|
|
IdempotencyStore => "idempotency_store",
|
|
IdempotencyInProgress => "idempotency_in_progress",
|
|
IdempotencyConflict => "idempotency_conflict",
|
|
IdempotencyOutcomeUnknown => "idempotency_outcome_unknown",
|
|
MissingAuthProfile => "missing_auth_profile",
|
|
MissingSecret => "missing_secret",
|
|
MissingSecretVersion => "missing_secret_version",
|
|
InvalidAuthSecret => "invalid_auth_secret",
|
|
SecretCrypto => "secret_crypto",
|
|
Aborted => "aborted",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum UpstreamOperationKind {
|
|
Rest => "rest",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum UpstreamOutcome {
|
|
Success => "success",
|
|
ClientError => "client_error",
|
|
ServerError => "server_error",
|
|
UnexpectedStatus => "unexpected_status",
|
|
Timeout => "timeout",
|
|
TransportError => "transport_error",
|
|
ResponseTooLarge => "response_too_large",
|
|
Rejected => "rejected",
|
|
WindowExpired => "window_expired",
|
|
InvalidResponse => "invalid_response",
|
|
InvalidRequest => "invalid_request",
|
|
Configuration => "configuration",
|
|
Aborted => "aborted",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum LimitStage {
|
|
Concurrency => "concurrency",
|
|
RateLimit => "rate_limit",
|
|
McpStream => "mcp_stream",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum CacheOutcome {
|
|
Hit => "hit",
|
|
Miss => "miss",
|
|
ReadError => "read_error",
|
|
DecodeError => "decode_error",
|
|
EvictError => "evict_error",
|
|
Stored => "stored",
|
|
WriteError => "write_error",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum IdempotencyOutcome {
|
|
Execute => "execute",
|
|
Replay => "replay",
|
|
Completed => "completed",
|
|
Conflict => "conflict",
|
|
InProgress => "in_progress",
|
|
OutcomeUnknown => "outcome_unknown",
|
|
StoreUnavailable => "store_unavailable",
|
|
Error => "error",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum ConfirmationOutcome {
|
|
Approved => "approved",
|
|
Required => "required",
|
|
InvalidToken => "invalid_token",
|
|
StoreUnavailable => "store_unavailable",
|
|
Error => "error",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum DbPoolState {
|
|
Idle => "idle",
|
|
Used => "used",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum SignalType {
|
|
Trace => "trace",
|
|
InvocationHistory => "invocation_history",
|
|
}
|
|
}
|
|
|
|
string_enum! {
|
|
pub enum Exporter {
|
|
Otlp => "otlp",
|
|
Postgres => "postgres",
|
|
}
|
|
}
|