Skip to content
2 changes: 2 additions & 0 deletions crates/goose-sdk-types/src/custom_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::collections::HashMap;

mod recipe;
pub use recipe::*;
mod schedule;
pub use schedule::*;

/// Schema descriptor for a single custom method, produced by the
/// `#[custom_methods]` macro's generated `custom_method_schemas()` function.
Expand Down
169 changes: 169 additions & 0 deletions crates/goose-sdk-types/src/custom_requests/schedule.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
use agent_client_protocol::schema::SessionInfo;
use agent_client_protocol::{JsonRpcRequest, JsonRpcResponse};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use super::{EmptyResponse, RecipeDto};

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ScheduledJobDto {
pub id: String,
pub source: String,
pub cron: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub last_run: Option<String>,
pub currently_running: bool,
pub paused: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub current_session_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub job_start_time: Option<String>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/list",
response = ListSchedulesResponse
)]
pub struct ListSchedulesRequest {}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct ListSchedulesResponse {
pub jobs: Vec<ScheduledJobDto>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/create",
response = CreateScheduleResponse
)]
pub struct CreateScheduleRequest {
pub id: String,
pub recipe: RecipeDto,
pub cron: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct CreateScheduleResponse {
pub job: ScheduledJobDto,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(method = "_goose/unstable/schedules/delete", response = EmptyResponse)]
#[serde(rename_all = "camelCase")]
pub struct DeleteScheduleRequest {
pub schedule_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/update",
response = UpdateScheduleResponse
)]
#[serde(rename_all = "camelCase")]
pub struct UpdateScheduleRequest {
pub schedule_id: String,
pub cron: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct UpdateScheduleResponse {
pub job: ScheduledJobDto,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/run-now",
response = RunScheduleNowResponse
)]
#[serde(rename_all = "camelCase")]
pub struct RunScheduleNowRequest {
pub schedule_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
#[serde(rename_all = "camelCase")]
pub struct RunScheduleNowResponse {
pub status: RunScheduleNowStatus,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub session_id: Option<String>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum RunScheduleNowStatus {
#[default]
Completed,
Cancelled,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/sessions/list",
response = ListScheduleSessionsResponse
)]
#[serde(rename_all = "camelCase")]
pub struct ListScheduleSessionsRequest {
pub schedule_id: String,
pub limit: usize,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct ListScheduleSessionsResponse {
pub sessions: Vec<SessionInfo>,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(method = "_goose/unstable/schedules/pause", response = EmptyResponse)]
#[serde(rename_all = "camelCase")]
pub struct PauseScheduleRequest {
pub schedule_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/unpause",
response = EmptyResponse
)]
#[serde(rename_all = "camelCase")]
pub struct UnpauseScheduleRequest {
pub schedule_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/running-job/kill",
response = KillRunningJobResponse
)]
#[serde(rename_all = "camelCase")]
pub struct KillRunningJobRequest {
pub job_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
pub struct KillRunningJobResponse {
pub message: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcRequest)]
#[request(
method = "_goose/unstable/schedules/running-job/inspect",
response = InspectRunningJobResponse
)]
#[serde(rename_all = "camelCase")]
pub struct InspectRunningJobRequest {
pub job_id: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize, JsonSchema, JsonRpcResponse)]
#[serde(rename_all = "camelCase")]
pub struct InspectRunningJobResponse {
pub running: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub session_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub job_start_time: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub running_duration_seconds: Option<i64>,
}
50 changes: 50 additions & 0 deletions crates/goose/acp-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,56 @@
"requestType": "RecipeToYamlRequest_unstable",
"responseType": "RecipeToYamlResponse_unstable"
},
{
"method": "_goose/unstable/schedules/list",
"requestType": "ListSchedulesRequest_unstable",
"responseType": "ListSchedulesResponse_unstable"
},
{
"method": "_goose/unstable/schedules/sessions/list",
"requestType": "ListScheduleSessionsRequest_unstable",
"responseType": "ListScheduleSessionsResponse_unstable"
},
{
"method": "_goose/unstable/schedules/create",
"requestType": "CreateScheduleRequest_unstable",
"responseType": "CreateScheduleResponse_unstable"
},
{
"method": "_goose/unstable/schedules/delete",
"requestType": "DeleteScheduleRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/schedules/pause",
"requestType": "PauseScheduleRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/schedules/unpause",
"requestType": "UnpauseScheduleRequest_unstable",
"responseType": "EmptyResponse"
},
{
"method": "_goose/unstable/schedules/update",
"requestType": "UpdateScheduleRequest_unstable",
"responseType": "UpdateScheduleResponse_unstable"
},
{
"method": "_goose/unstable/schedules/run-now",
"requestType": "RunScheduleNowRequest_unstable",
"responseType": "RunScheduleNowResponse_unstable"
},
{
"method": "_goose/unstable/schedules/running-job/kill",
"requestType": "KillRunningJobRequest_unstable",
"responseType": "KillRunningJobResponse_unstable"
},
{
"method": "_goose/unstable/schedules/running-job/inspect",
"requestType": "InspectRunningJobRequest_unstable",
"responseType": "InspectRunningJobResponse_unstable"
},
{
"method": "_goose/unstable/session/info",
"requestType": "GetSessionInfoRequest_unstable",
Expand Down
Loading
Loading