refactor: Use openapi for recipe endpoint types and in frontend (#3548)

This commit is contained in:
Jarrod Sibbison
2025-07-21 19:40:13 +10:00
committed by GitHub
parent a996227381
commit d085126709
10 changed files with 863 additions and 132 deletions
+37 -1
View File
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
import type { GetToolsData, GetToolsResponse, ReadAllConfigData, ReadAllConfigResponse, BackupConfigData, BackupConfigResponse, GetExtensionsData, GetExtensionsResponse, AddExtensionData, AddExtensionResponse, RemoveExtensionData, RemoveExtensionResponse, InitConfigData, InitConfigResponse, UpsertPermissionsData, UpsertPermissionsResponse, ProvidersData, ProvidersResponse2, ReadConfigData, RecoverConfigData, RecoverConfigResponse, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse, ValidateConfigData, ValidateConfigResponse, ConfirmPermissionData, ManageContextData, ManageContextResponse, CreateScheduleData, CreateScheduleResponse, DeleteScheduleData, DeleteScheduleResponse, ListSchedulesData, ListSchedulesResponse2, UpdateScheduleData, UpdateScheduleResponse, InspectRunningJobData, InspectRunningJobResponse, KillRunningJobData, PauseScheduleData, PauseScheduleResponse, RunNowHandlerData, RunNowHandlerResponse, SessionsHandlerData, SessionsHandlerResponse, UnpauseScheduleData, UnpauseScheduleResponse, ListSessionsData, ListSessionsResponse, GetSessionHistoryData, GetSessionHistoryResponse } from './types.gen';
import type { GetToolsData, GetToolsResponse, ReadAllConfigData, ReadAllConfigResponse, BackupConfigData, BackupConfigResponse, GetExtensionsData, GetExtensionsResponse, AddExtensionData, AddExtensionResponse, RemoveExtensionData, RemoveExtensionResponse, InitConfigData, InitConfigResponse, UpsertPermissionsData, UpsertPermissionsResponse, ProvidersData, ProvidersResponse2, ReadConfigData, RecoverConfigData, RecoverConfigResponse, RemoveConfigData, RemoveConfigResponse, UpsertConfigData, UpsertConfigResponse, ValidateConfigData, ValidateConfigResponse, ConfirmPermissionData, ManageContextData, ManageContextResponse, CreateRecipeData, CreateRecipeResponse2, DecodeRecipeData, DecodeRecipeResponse2, EncodeRecipeData, EncodeRecipeResponse2, CreateScheduleData, CreateScheduleResponse, DeleteScheduleData, DeleteScheduleResponse, ListSchedulesData, ListSchedulesResponse2, UpdateScheduleData, UpdateScheduleResponse, InspectRunningJobData, InspectRunningJobResponse, KillRunningJobData, PauseScheduleData, PauseScheduleResponse, RunNowHandlerData, RunNowHandlerResponse, SessionsHandlerData, SessionsHandlerResponse, UnpauseScheduleData, UnpauseScheduleResponse, ListSessionsData, ListSessionsResponse, GetSessionHistoryData, GetSessionHistoryResponse } from './types.gen';
import { client as _heyApiClient } from './client.gen';
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
@@ -158,6 +158,42 @@ export const manageContext = <ThrowOnError extends boolean = false>(options: Opt
});
};
/**
* Create a Recipe configuration from the current session
*/
export const createRecipe = <ThrowOnError extends boolean = false>(options: Options<CreateRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<CreateRecipeResponse2, unknown, ThrowOnError>({
url: '/recipes/create',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
};
export const decodeRecipe = <ThrowOnError extends boolean = false>(options: Options<DecodeRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<DecodeRecipeResponse2, unknown, ThrowOnError>({
url: '/recipes/decode',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
};
export const encodeRecipe = <ThrowOnError extends boolean = false>(options: Options<EncodeRecipeData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<EncodeRecipeResponse2, unknown, ThrowOnError>({
url: '/recipes/encode',
...options,
headers: {
'Content-Type': 'application/json',
...options?.headers
}
});
};
export const createSchedule = <ThrowOnError extends boolean = false>(options: Options<CreateScheduleData, ThrowOnError>) => {
return (options.client ?? _heyApiClient).post<CreateScheduleResponse, unknown, ThrowOnError>({
url: '/schedule/create',
+219
View File
@@ -6,6 +6,16 @@ export type Annotations = {
timestamp?: string;
};
export type Author = {
contact?: string | null;
metadata?: string | null;
};
export type AuthorRequest = {
contact?: string | null;
metadata?: string | null;
};
export type ConfigKey = {
default?: string | null;
name: string;
@@ -71,6 +81,19 @@ export type ContextManageResponse = {
tokenCounts: Array<number>;
};
export type CreateRecipeRequest = {
activities?: Array<string> | null;
author?: AuthorRequest | null;
description: string;
messages: Array<Message>;
title: string;
};
export type CreateRecipeResponse = {
error?: string | null;
recipe?: Recipe | null;
};
export type CreateScheduleRequest = {
cron: string;
execution_mode?: string | null;
@@ -78,11 +101,27 @@ export type CreateScheduleRequest = {
recipe_source: string;
};
export type DecodeRecipeRequest = {
deeplink: string;
};
export type DecodeRecipeResponse = {
recipe: Recipe;
};
export type EmbeddedResource = {
annotations?: Annotations;
resource: ResourceContents;
};
export type EncodeRecipeRequest = {
recipe: Recipe;
};
export type EncodeRecipeResponse = {
deeplink: string;
};
export type Envs = {
[key: string]: string;
};
@@ -273,6 +312,10 @@ export type ModelInfo = {
* Cost per token for output (optional)
*/
output_token_cost?: number | null;
/**
* Whether this model supports cache control
*/
supports_cache_control?: boolean | null;
};
export type PermissionConfirmationRequest = {
@@ -333,6 +376,86 @@ export type ProvidersResponse = {
providers: Array<ProviderDetails>;
};
/**
* A Recipe represents a personalized, user-generated agent configuration that defines
* specific behaviors and capabilities within the Goose system.
*
* # Fields
*
* ## Required Fields
* * `version` - Semantic version of the Recipe file format (defaults to "1.0.0")
* * `title` - Short, descriptive name of the Recipe
* * `description` - Detailed description explaining the Recipe's purpose and functionality
* * `Instructions` - Instructions that defines the Recipe's behavior
*
* ## Optional Fields
* * `prompt` - the initial prompt to the session to start with
* * `extensions` - List of extension configurations required by the Recipe
* * `context` - Supplementary context information for the Recipe
* * `activities` - Activity labels that appear when loading the Recipe
* * `author` - Information about the Recipe's creator and metadata
* * `parameters` - Additional parameters for the Recipe
* * `response` - Response configuration including JSON schema validation
*
* # Example
*
*
* use goose::recipe::Recipe;
*
* // Using the builder pattern
* let recipe = Recipe::builder()
* .title("Example Agent")
* .description("An example Recipe configuration")
* .instructions("Act as a helpful assistant")
* .build()
* .expect("Missing required fields");
*
* // Or using struct initialization
* let recipe = Recipe {
* version: "1.0.0".to_string(),
* title: "Example Agent".to_string(),
* description: "An example Recipe configuration".to_string(),
* instructions: Some("Act as a helpful assistant".to_string()),
* prompt: None,
* extensions: None,
* context: None,
* activities: None,
* author: None,
* settings: None,
* parameters: None,
* response: None,
* sub_recipes: None,
* };
*
*/
export type Recipe = {
activities?: Array<string> | null;
author?: Author | null;
context?: Array<string> | null;
description: string;
extensions?: Array<ExtensionConfig> | null;
instructions?: string | null;
parameters?: Array<RecipeParameter> | null;
prompt?: string | null;
response?: Response | null;
settings?: Settings | null;
sub_recipes?: Array<SubRecipe> | null;
title: string;
version?: string;
};
export type RecipeParameter = {
default?: string | null;
description: string;
input_type: RecipeParameterInputType;
key: string;
requirement: RecipeParameterRequirement;
};
export type RecipeParameterInputType = 'string' | 'number' | 'boolean' | 'date' | 'file';
export type RecipeParameterRequirement = 'required' | 'optional' | 'user_prompt';
export type RedactedThinkingContent = {
data: string;
};
@@ -347,6 +470,10 @@ export type ResourceContents = {
uri: string;
};
export type Response = {
json_schema?: unknown;
};
export type Role = string;
export type RunNowResponse = {
@@ -460,6 +587,21 @@ export type SessionsQuery = {
limit?: number;
};
export type Settings = {
goose_model?: string | null;
goose_provider?: string | null;
temperature?: number | null;
};
export type SubRecipe = {
name: string;
path: string;
sequential_when_repeated?: boolean;
values?: {
[key: string]: string;
} | null;
};
export type SummarizationRequested = {
msg: string;
};
@@ -994,6 +1136,83 @@ export type ManageContextResponses = {
export type ManageContextResponse = ManageContextResponses[keyof ManageContextResponses];
export type CreateRecipeData = {
body: CreateRecipeRequest;
path?: never;
query?: never;
url: '/recipes/create';
};
export type CreateRecipeErrors = {
/**
* Bad request
*/
400: unknown;
/**
* Precondition failed - Agent not available
*/
412: unknown;
/**
* Internal server error
*/
500: unknown;
};
export type CreateRecipeResponses = {
/**
* Recipe created successfully
*/
200: CreateRecipeResponse;
};
export type CreateRecipeResponse2 = CreateRecipeResponses[keyof CreateRecipeResponses];
export type DecodeRecipeData = {
body: DecodeRecipeRequest;
path?: never;
query?: never;
url: '/recipes/decode';
};
export type DecodeRecipeErrors = {
/**
* Bad request
*/
400: unknown;
};
export type DecodeRecipeResponses = {
/**
* Recipe decoded successfully
*/
200: DecodeRecipeResponse;
};
export type DecodeRecipeResponse2 = DecodeRecipeResponses[keyof DecodeRecipeResponses];
export type EncodeRecipeData = {
body: EncodeRecipeRequest;
path?: never;
query?: never;
url: '/recipes/encode';
};
export type EncodeRecipeErrors = {
/**
* Bad request
*/
400: unknown;
};
export type EncodeRecipeResponses = {
/**
* Recipe encoded successfully
*/
200: EncodeRecipeResponse;
};
export type EncodeRecipeResponse2 = EncodeRecipeResponses[keyof EncodeRecipeResponses];
export type CreateScheduleData = {
body: CreateScheduleRequest;
path?: never;