0.2.0 builder model and crate re-export

This commit is contained in:
2025-10-24 02:44:26 +09:00
parent d03172610d
commit 48bbab0a69
35 changed files with 2491 additions and 773 deletions
+10 -10
View File
@@ -95,8 +95,8 @@ pub fn tool(attr: TokenStream, item: TokenStream) -> TokenStream {
}
// Implement Tool trait
#[::worker_types::async_trait::async_trait]
impl ::worker_types::Tool for #tool_struct_name {
#[::worker::types::async_trait::async_trait]
impl ::worker::types::Tool for #tool_struct_name {
fn name(&self) -> &str {
#tool_name_str
}
@@ -105,16 +105,16 @@ pub fn tool(attr: TokenStream, item: TokenStream) -> TokenStream {
#description
}
fn parameters_schema(&self) -> ::worker_types::serde_json::Value {
::worker_types::serde_json::to_value(::worker_types::schemars::schema_for!(#arg_type)).unwrap()
fn parameters_schema(&self) -> ::worker::types::serde_json::Value {
::worker::types::serde_json::to_value(::worker::types::schemars::schema_for!(#arg_type)).unwrap()
}
async fn execute(&self, args: ::worker_types::serde_json::Value) -> ::worker_types::ToolResult<::worker_types::serde_json::Value> {
let typed_args: #arg_type = ::worker_types::serde_json::from_value(args)?;
async fn execute(&self, args: ::worker::types::serde_json::Value) -> ::worker::types::ToolResult<::worker::types::serde_json::Value> {
let typed_args: #arg_type = ::worker::types::serde_json::from_value(args)?;
let result = #fn_name(typed_args).await?;
// Use Display formatting instead of JSON serialization
let formatted_result = format!("{}", result);
Ok(::worker_types::serde_json::Value::String(formatted_result))
Ok(::worker::types::serde_json::Value::String(formatted_result))
}
}
@@ -270,8 +270,8 @@ pub fn hook(attr: TokenStream, item: TokenStream) -> TokenStream {
}
// Implement WorkerHook trait
#[::worker_types::async_trait::async_trait]
impl ::worker_types::WorkerHook for #hook_struct_name {
#[::worker::types::async_trait::async_trait]
impl ::worker::types::WorkerHook for #hook_struct_name {
fn name(&self) -> &str {
#fn_name_str
}
@@ -284,7 +284,7 @@ pub fn hook(attr: TokenStream, item: TokenStream) -> TokenStream {
#matcher
}
async fn execute(&self, context: ::worker_types::HookContext) -> (::worker_types::HookContext, ::worker_types::HookResult) {
async fn execute(&self, context: ::worker::types::HookContext) -> (::worker::types::HookContext, ::worker::types::HookResult) {
#fn_name(context).await
}
}