feat: complete Epic 1 production foundation
This commit is contained in:
+168
-6
@@ -1,13 +1,15 @@
|
||||
use crank_core::{
|
||||
AgentId, AgentStatus, ApprovalRequestStatus, AuthConfig, AuthKind, ExecutionMode, ExportMode,
|
||||
GeneratedDraft, InvocationLevel, InvocationSource, InvocationStatus, OperationSecurityLevel,
|
||||
OperationStatus, PlatformApiKeyKind, PlatformApiKeyScope, Protocol, SecretKind, Target,
|
||||
ToolSelectionPolicy, UsagePeriod, WizardState, WorkspaceId, WorkspaceStatus,
|
||||
GeneratedDraft, InvocationLevel, InvocationSource, InvocationStatus, OperationAvailability,
|
||||
OperationSecurityLevel, OperationStatus, OperationVersionState, PlatformApiKeyKind,
|
||||
PlatformApiKeyScope, Protocol, SecretKind, Target, ToolSelectionPolicy, UsagePeriod,
|
||||
WizardState, WorkspaceId, WorkspaceStatus,
|
||||
};
|
||||
use crank_mapping::MappingSet;
|
||||
use crank_registry::{
|
||||
PlatformApiKeyRecord, RegistryOperation, UsageAgentBreakdown, UsageOperationBreakdown,
|
||||
UsageSummary, UsageTimelinePoint, WorkspaceMembershipRecord, WorkspaceRecord,
|
||||
InvocationLogRecord, PlatformApiKeyRecord, RegistryOperation, UsageAgentBreakdown,
|
||||
UsageOperationBreakdown, UsageOutcomeGroup, UsageSummary, UsageTimelinePoint,
|
||||
WorkspaceMembershipRecord, WorkspaceRecord,
|
||||
};
|
||||
use crank_schema::Schema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -19,11 +21,23 @@ pub struct LoginPayload {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct CompleteBootstrapPayload {
|
||||
pub token: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct BootstrapStatusResponse {
|
||||
pub bootstrap_required: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct SessionResponse {
|
||||
pub user: crank_core::User,
|
||||
pub memberships: Vec<WorkspaceMembershipRecord>,
|
||||
pub current_workspace_id: Option<String>,
|
||||
pub csrf_token: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@@ -80,12 +94,19 @@ pub struct PublishPayload {
|
||||
pub struct TestRunPayload {
|
||||
pub version: u32,
|
||||
pub input: Value,
|
||||
#[serde(default)]
|
||||
pub confirmation_token: Option<String>,
|
||||
#[serde(default)]
|
||||
pub locale: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct TestRunResult {
|
||||
pub ok: bool,
|
||||
pub mode: ExecutionMode,
|
||||
pub tested_version: u32,
|
||||
pub request_id: String,
|
||||
pub trace_id: String,
|
||||
pub request_preview: Value,
|
||||
pub response_preview: Value,
|
||||
pub errors: Vec<Value>,
|
||||
@@ -228,6 +249,7 @@ pub struct AgentSummaryView {
|
||||
pub status: AgentStatus,
|
||||
pub current_draft_version: u32,
|
||||
pub latest_published_version: Option<u32>,
|
||||
pub catalog_revision: i64,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
pub published_at: Option<String>,
|
||||
@@ -266,6 +288,91 @@ fn default_platform_api_key_kind() -> PlatformApiKeyKind {
|
||||
pub struct CreatedPlatformApiKeyResponse {
|
||||
pub api_key: PlatformApiKeyRecord,
|
||||
pub secret: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub connection: Option<EphemeralMcpConnection>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct EphemeralMcpClientConfig {
|
||||
pub client: String,
|
||||
pub config: Value,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct EphemeralMcpConnection {
|
||||
pub endpoint: String,
|
||||
pub clients: Vec<EphemeralMcpClientConfig>,
|
||||
pub secret_display: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct OnboardingEventPayload {
|
||||
pub event: String,
|
||||
pub idempotency_key: String,
|
||||
pub expected_revision: i64,
|
||||
#[serde(default)]
|
||||
pub completed_steps: Option<Value>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct OnboardingStepView {
|
||||
pub id: crank_core::OnboardingStepId,
|
||||
pub completed: bool,
|
||||
pub status: String,
|
||||
pub action_code: String,
|
||||
pub reason_code: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct OnboardingFirstCallEvidence {
|
||||
pub log_id: String,
|
||||
pub agent_id: String,
|
||||
pub key_id: String,
|
||||
pub operation_id: String,
|
||||
pub operation_version: u32,
|
||||
pub tool_name: String,
|
||||
pub occurred_at: String,
|
||||
pub request_id: Option<String>,
|
||||
pub trace_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct OnboardingResponse {
|
||||
pub schema_version: u16,
|
||||
pub workspace_id: String,
|
||||
pub revision: i64,
|
||||
pub status: String,
|
||||
pub completed: bool,
|
||||
pub eligible_since: Option<String>,
|
||||
pub steps: Vec<OnboardingStepView>,
|
||||
pub operation_id: Option<String>,
|
||||
pub operation_version: Option<u32>,
|
||||
pub agent_id: Option<String>,
|
||||
pub catalog_revision: Option<i64>,
|
||||
pub platform_api_key_id: Option<String>,
|
||||
pub mcp_endpoint: Option<String>,
|
||||
pub first_call: Option<OnboardingFirstCallEvidence>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct OnboardingEventResponse {
|
||||
pub accepted: bool,
|
||||
#[serde(flatten)]
|
||||
pub onboarding: OnboardingResponse,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ResetOnboardingSelectionPayload {
|
||||
pub expected_revision: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct ResetOnboardingSelectionResponse {
|
||||
pub selection_reset: bool,
|
||||
#[serde(flatten)]
|
||||
pub onboarding: OnboardingResponse,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -285,11 +392,16 @@ pub struct WorkspaceCatalogSnapshotResponse {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct LogsQuery {
|
||||
pub level: Option<InvocationLevel>,
|
||||
pub status: Option<InvocationStatus>,
|
||||
pub outcome_group: Option<UsageOutcomeGroup>,
|
||||
pub search: Option<String>,
|
||||
pub source: Option<InvocationSource>,
|
||||
pub operation_id: Option<String>,
|
||||
pub agent_id: Option<String>,
|
||||
pub period: Option<UsagePeriod>,
|
||||
pub created_after: Option<String>,
|
||||
pub created_before: Option<String>,
|
||||
pub cursor: Option<String>,
|
||||
pub limit: Option<u32>,
|
||||
}
|
||||
|
||||
@@ -299,10 +411,19 @@ pub struct ApprovalsQuery {
|
||||
pub limit: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct ApprovalDecisionPayload {
|
||||
pub approve: String,
|
||||
#[serde(default)]
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct UsageRequestQuery {
|
||||
pub period: Option<UsagePeriod>,
|
||||
pub source: Option<InvocationSource>,
|
||||
pub created_after: Option<String>,
|
||||
pub created_before: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -311,6 +432,13 @@ pub struct UsageOverviewResponse {
|
||||
pub timeline: Vec<UsageTimelinePoint>,
|
||||
pub operations: Vec<UsageOperationBreakdown>,
|
||||
pub agents: Vec<UsageAgentBreakdown>,
|
||||
pub outcomes: Vec<crank_registry::UsageOutcomeBreakdown>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct LogsListResponse {
|
||||
pub items: Vec<InvocationLogRecord>,
|
||||
pub next_cursor: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -362,7 +490,35 @@ pub struct ExportQuery {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct YamlOperationDocument {
|
||||
pub format_version: String,
|
||||
pub kind: String,
|
||||
pub operation: PortableOperation,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PortableOperation {
|
||||
pub name: String,
|
||||
pub display_name: String,
|
||||
#[serde(default = "default_operation_category")]
|
||||
pub category: String,
|
||||
pub protocol: Protocol,
|
||||
#[serde(default)]
|
||||
pub security_level: OperationSecurityLevel,
|
||||
pub target: Target,
|
||||
pub input_schema: Schema,
|
||||
pub output_schema: Schema,
|
||||
pub input_mapping: MappingSet,
|
||||
pub output_mapping: MappingSet,
|
||||
pub execution_config: crank_core::ExecutionConfig,
|
||||
pub tool_description: crank_core::ToolDescription,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct LegacyYamlOperationDocument {
|
||||
pub format_version: String,
|
||||
pub kind: String,
|
||||
pub operation: RegistryOperation,
|
||||
@@ -473,6 +629,7 @@ pub struct OperationSummaryView {
|
||||
pub status: OperationStatus,
|
||||
pub current_draft_version: u32,
|
||||
pub latest_published_version: Option<u32>,
|
||||
pub can_delete: bool,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
pub published_at: Option<String>,
|
||||
@@ -490,6 +647,7 @@ pub struct OperationDetailView {
|
||||
pub protocol: Protocol,
|
||||
pub security_level: OperationSecurityLevel,
|
||||
pub status: OperationStatus,
|
||||
pub availability: OperationAvailability,
|
||||
pub current_draft_version: u32,
|
||||
pub latest_published_version: Option<u32>,
|
||||
pub created_at: String,
|
||||
@@ -503,7 +661,7 @@ pub struct OperationDetailView {
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct VersionRef {
|
||||
pub version: u32,
|
||||
pub status: OperationStatus,
|
||||
pub status: OperationVersionState,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
@@ -558,6 +716,10 @@ pub(crate) struct InvocationRecordRequest<'a> {
|
||||
pub message: String,
|
||||
pub status_code: Option<u16>,
|
||||
pub error_kind: Option<String>,
|
||||
pub execution_stage: Option<crank_core::ExecutionStage>,
|
||||
pub execution_error_code: Option<crank_core::ExecutionErrorCode>,
|
||||
pub retryability: Option<crank_core::Retryability>,
|
||||
pub outcome_certainty: Option<crank_core::OutcomeCertainty>,
|
||||
pub duration_ms: u64,
|
||||
pub request_preview: Value,
|
||||
pub response_preview: Value,
|
||||
|
||||
Reference in New Issue
Block a user