feat: complete Epic 1 production foundation
This commit is contained in:
1 parent
767428436d
commit
182bde8ac0
298 files changed
+35711
-5291
No files matched your search
@@ -1,9 +1,9 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crank_core::{
|
||||
AgentId, InvocationLevel, InvocationSource, InvocationStatus, MembershipRole, OperationId,
|
||||
OperationSecurityLevel, PlatformApiKeyKind, PlatformApiKeyScope, PlatformApiKeyStatus,
|
||||
Protocol, Target, WizardState, WorkspaceId,
|
||||
AgentId, AgentOperationBinding, InvocationLevel, InvocationSource, InvocationStatus,
|
||||
MembershipRole, OperationId, OperationSecurityLevel, PlatformApiKeyKind, PlatformApiKeyScope,
|
||||
PlatformApiKeyStatus, Protocol, Target, WizardState, WorkspaceId,
|
||||
};
|
||||
use crank_mapping::{JsonPathRoot, infer_mapping_from_samples};
|
||||
use crank_mapping::{MappingRule, MappingSet};
|
||||
@@ -87,8 +87,12 @@ impl AdminService {
|
||||
async fn cleanup_legacy_demo_assets(&self, workspace_id: &WorkspaceId) -> Result<(), ApiError> {
|
||||
for slug in ["revops-copilot", "support-triage"] {
|
||||
if let Some(agent) = self.find_agent_by_slug(workspace_id, slug).await? {
|
||||
self.delete_agent(workspace_id, &AgentId::new(agent.id.as_str().to_owned()))
|
||||
.await?;
|
||||
self.delete_agent(
|
||||
workspace_id,
|
||||
&AgentId::new(agent.id.as_str().to_owned()),
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +133,10 @@ impl AdminService {
|
||||
.await
|
||||
{
|
||||
Ok(()) => Ok(()),
|
||||
Err(RegistryError::OperationHasPublishedAgentBindings { .. }) => {
|
||||
Err(
|
||||
RegistryError::OperationHasPublishedAgentBindings { .. }
|
||||
| RegistryError::OperationDeleteForbidden { .. },
|
||||
) => {
|
||||
tracing::warn!(
|
||||
name: "admin.demo_operation.cleanup_skipped",
|
||||
operation_id = %operation_id.as_str(),
|
||||
@@ -168,6 +175,7 @@ impl AdminService {
|
||||
expires_at: None,
|
||||
allowed_origins: Vec::new(),
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await?
|
||||
.api_key
|
||||
@@ -175,7 +183,7 @@ impl AdminService {
|
||||
};
|
||||
|
||||
if revoke && key.api_key.status != PlatformApiKeyStatus::Revoked {
|
||||
self.revoke_agent_platform_api_key(workspace_id, agent_id, &key.api_key.id)
|
||||
self.revoke_agent_platform_api_key(workspace_id, agent_id, &key.api_key.id, None)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -210,8 +218,17 @@ impl AdminService {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.publish_operation(workspace_id, &summary.id, summary.current_draft_version)
|
||||
.await?;
|
||||
self.publish_operation(
|
||||
workspace_id,
|
||||
&summary.id,
|
||||
summary.current_draft_version,
|
||||
&crank_registry::OperationStateExpectation {
|
||||
current_draft_version: summary.current_draft_version,
|
||||
status: summary.status,
|
||||
latest_published_version: summary.latest_published_version,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -273,10 +290,15 @@ impl AdminService {
|
||||
publish: bool,
|
||||
) -> Result<(), ApiError> {
|
||||
let summary = self.get_agent(workspace_id, agent_id).await?;
|
||||
self.save_agent_bindings(workspace_id, agent_id, bindings.into())
|
||||
let current = self
|
||||
.get_agent_version(workspace_id, agent_id, summary.current_draft_version)
|
||||
.await?;
|
||||
if !demo_agent_bindings_match(¤t.bindings, &bindings) {
|
||||
self.save_agent_bindings(workspace_id, agent_id, bindings.into(), None)
|
||||
.await?;
|
||||
}
|
||||
if publish && summary.latest_published_version.is_none() {
|
||||
self.publish_agent(workspace_id, agent_id, summary.current_draft_version)
|
||||
self.publish_agent(workspace_id, agent_id, summary.current_draft_version, None)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -294,11 +316,16 @@ impl AdminService {
|
||||
.list_invocation_logs(ListInvocationLogsQuery {
|
||||
workspace_id,
|
||||
level: None,
|
||||
status: None,
|
||||
outcome_group: None,
|
||||
search_text: None,
|
||||
source: None,
|
||||
operation_id: None,
|
||||
agent_id: None,
|
||||
created_after: None,
|
||||
created_before: None,
|
||||
cursor_created_at: None,
|
||||
cursor_id: None,
|
||||
limit: 1,
|
||||
})
|
||||
.await?
|
||||
@@ -329,6 +356,10 @@ impl AdminService {
|
||||
message: "Frankfurter returned latest exchange rate".to_owned(),
|
||||
status_code: Some(200),
|
||||
error_kind: None,
|
||||
execution_stage: Some(crank_core::ExecutionStage::Runtime),
|
||||
execution_error_code: None,
|
||||
retryability: Some(crank_core::Retryability::Never),
|
||||
outcome_certainty: Some(crank_core::OutcomeCertainty::Certain),
|
||||
duration_ms: 124,
|
||||
request_preview: json!({
|
||||
"path": {},
|
||||
@@ -343,6 +374,25 @@ impl AdminService {
|
||||
}
|
||||
}
|
||||
|
||||
fn demo_agent_bindings_match(
|
||||
existing: &[AgentOperationBinding],
|
||||
desired: &[AgentBindingPayload],
|
||||
) -> bool {
|
||||
if existing.len() != desired.len() {
|
||||
return false;
|
||||
}
|
||||
let mut desired = desired.iter().collect::<Vec<_>>();
|
||||
desired.sort_by(|left, right| left.tool_name.cmp(&right.tool_name));
|
||||
existing.iter().zip(desired).all(|(existing, desired)| {
|
||||
existing.operation_id.as_str() == desired.operation_id
|
||||
&& existing.operation_version == desired.operation_version
|
||||
&& existing.tool_name == desired.tool_name
|
||||
&& existing.tool_title == desired.tool_title
|
||||
&& existing.tool_description_override == desired.tool_description_override
|
||||
&& existing.enabled == desired.enabled
|
||||
})
|
||||
}
|
||||
|
||||
fn demo_currency_agent_payload() -> AgentPayload {
|
||||
AgentPayload {
|
||||
slug: "currency-rates".to_owned(),
|
||||
|
||||
Reference in new issue
Block a user