Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(artifacts): add artifact operations and schemas

Steven Enamakelbe99108489c6
diff --git a/crates/openhuman-core/src/agent/artifacts/ops.rs b/crates/openhuman-core/src/agent/artifacts/ops.rs
index 6184ca5b21..1df3fffd63 100644
--- a/crates/openhuman-core/src/agent/artifacts/ops.rs
+++ b/crates/openhuman-core/src/agent/artifacts/ops.rs
@@ -158,6 +158,7 @@ pub async fn ai_delete_artifact(
/// The returned value is a thin ack — the card's live state is driven by
/// the socket events the re-run publishes, not by this RPC's result.
pub async fn ai_regenerate(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
artifact_id: &str,
thread_id: &str,
@@ -185,7 +186,7 @@ pub async fn ai_regenerate(
));
}
- regenerate_presentation(config, artifact_id, thread_id, client_id).await
+ regenerate_presentation(ctx, config, artifact_id, thread_id, client_id).await
}
/// Re-run the presentation producer tool against an existing artifact id.
@@ -194,6 +195,7 @@ pub async fn ai_regenerate(
/// a thin, always-compiled RPC handler.
#[cfg(feature = "documents")]
async fn regenerate_presentation(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
artifact_id: &str,
thread_id: &str,
@@ -227,7 +229,7 @@ async fn regenerate_presentation(
request_id: None,
};
- let result = tool.run(args, Some(&chat_ctx)).await;
+ let result = tool.run(args, Some(&chat_ctx), ctx).await;
match result {
Ok(tool_result) => {
@@ -257,6 +259,7 @@ async fn regenerate_presentation(
/// limitation rather than pretend to regenerate.
#[cfg(not(feature = "documents"))]
async fn regenerate_presentation(
+ _ctx: &crate::core::runtime::DispatchCtx,
_config: &Config,
artifact_id: &str,
_thread_id: &str,
diff --git a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
index 98d718df8b..e997100544 100644
--- a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
@@ -187,15 +187,15 @@ async fn delete_missing_id_error() {
async fn regenerate_rejects_empty_id() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- assert!(ai_regenerate(&config, "", "t", "c").await.is_err());
+ assert!(ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, "", "t", "c").await.is_err());
}
#[tokio::test]
async fn regenerate_requires_thread_and_client() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- assert!(ai_regenerate(&config, "id", "", "c").await.is_err());
- assert!(ai_regenerate(&config, "id", "t", "").await.is_err());
+ assert!(ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, "id", "", "c").await.is_err());
+ assert!(ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, "id", "t", "").await.is_err());
}
#[tokio::test]
@@ -228,7 +228,7 @@ async fn regenerate_rejects_non_presentation_kind() {
.await
.unwrap();
- let err = ai_regenerate(&config, "doc-1", "t", "c").await.unwrap_err();
+ let err = ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, "doc-1", "t", "c").await.unwrap_err();
assert!(
err.contains("only supported for presentations"),
"unexpected error: {err}"
@@ -259,7 +259,7 @@ async fn regenerate_errors_when_args_missing() {
)
.await
.unwrap();
- let err = ai_regenerate(&config, &meta.id, "t", "c")
+ let err = ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, &meta.id, "t", "c")
.await
.unwrap_err();
assert!(err.contains("not regenerable"), "unexpected error: {err}");
@@ -298,7 +298,7 @@ async fn regenerate_reruns_producer_and_reuses_id() {
.await
.unwrap();
- let outcome = ai_regenerate(&config, &meta.id, "thread-1", "client-1")
+ let outcome = ai_regenerate(&crate::core::runtime::DispatchCtx::ambient(), &config, &meta.id, "thread-1", "client-1")
.await
.unwrap();
let value = outcome.into_cli_compatible_json().unwrap();
diff --git a/crates/openhuman-core/src/agent/artifacts/schemas.rs b/crates/openhuman-core/src/agent/artifacts/schemas.rs
index 4833c5ad01..f050ff5b2f 100644
--- a/crates/openhuman-core/src/agent/artifacts/schemas.rs
+++ b/crates/openhuman-core/src/agent/artifacts/schemas.rs
@@ -303,6 +303,7 @@ fn handle_regenerate(ctx: DispatchCtx, params: Map<String, Value>) -> Controller
let client_id = read_required::<String>(&params, "client_id")?;
to_json(
crate::agent::artifacts::ops::ai_regenerate(
+ &ctx,
&config,
artifact_id.trim(),
thread_id.trim(),