!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a090e3-1a44-7d20-8f06-1c01e5f0f3ec")}catch(e){}}();(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,789836,e=>{"use strict";var t=e.i(601432);e.s(["mutative",0,(e,a)=>(n,o,i)=>(i.setState=(e,o,...i)=>n("function"==typeof e?(0,t.create)(e,a?Object.assign(Object.assign({},a),{enablePatches:!1}):a):e,o,...i),e(i.setState,o,i))])},104852,e=>{"use strict";e.i(204067);var t=e.i(796805);let a=t.z.enum(["in_progress","completed","generating","failed"]).openapi("ImageGenerationStatus",{example:"completed"}),n=t.z.object({type:t.z.literal("image_generation_call"),id:t.z.string(),result:t.z.string().nullable().default(null),status:a}).openapi("OutputItemImageGenerationCall",{example:{type:"image_generation_call",id:"imagegen-abc123",result:"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",status:"completed"}});e.s(["OpenAIResponsesImageGenerationCallSchema",0,n])},720170,e=>{"use strict";var t=e.i(838328),a=e.i(394359),n=e.i(723914),o=e.i(204067),i=e.i(796805),r=e.i(345567),s=e.i(473059),l=e.i(305904),p=e.i(104852);i.z.enum([l.OpenAIResponsesServiceTier.Auto,l.OpenAIResponsesServiceTier.Default,l.OpenAIResponsesServiceTier.Flex,l.OpenAIResponsesServiceTier.Scale,l.OpenAIResponsesServiceTier.Priority]).openapi("OpenAIResponsesServiceTier",{example:"auto",enum:[...Object.values(l.OpenAIResponsesServiceTier),null]});let c=i.z.enum([l.OpenAIResponsesTruncation.Auto,l.OpenAIResponsesTruncation.Disabled]).openapi("OpenAIResponsesTruncation",{example:"auto",enum:[...Object.values(l.OpenAIResponsesTruncation),null]}),u=i.z.object({type:i.z.literal("approximate").optional(),city:i.z.string().nullish(),country:i.z.string().nullish(),region:i.z.string().nullish(),timezone:i.z.string().nullish()}).openapi("WebSearchUserLocation"),d=i.z.enum(a.SearchContextSize).openapi("SearchContextSizeEnum"),m={WebSearch:"web_search",WebSearchPreview:"web_search_preview",WebSearchPreview20250311:"web_search_preview_2025_03_11",WebSearch20250826:"web_search_2025_08_26"},h={Function:"function",ImageGeneration:"image_generation",WebSearch:m.WebSearch,WebSearchPreview:m.WebSearchPreview,WebSearch20250826:m.WebSearch20250826},g=i.z.object({type:i.z.literal(h.ImageGeneration),background:i.z.enum(["transparent","opaque","auto"]).optional(),input_fidelity:i.z.enum(["high","low"]).nullish().openapi({enum:["high","low",null]}),input_image_mask:i.z.object({image_url:i.z.string().optional(),file_id:i.z.string().optional()}).optional(),model:i.z.string().optional(),moderation:i.z.enum(["auto","low"]).optional(),output_compression:(0,o.zInt)().optional(),output_format:i.z.enum(["png","webp","jpeg"]).optional(),partial_images:(0,o.zInt)().optional(),quality:i.z.enum(["low","medium","high","auto"]).optional(),size:i.z.string().optional()}),z=i.z.object({type:i.z.literal(h.Function),name:i.z.string(),description:i.z.string().optional(),strict:i.z.boolean().optional().default(!0),parameters:i.z.looseObject({}).optional(),async:i.z.boolean().optional()}),f=i.z.object({type:i.z.union([i.z.literal(m.WebSearchPreview),i.z.literal(m.WebSearch20250826)]),search_context_size:d.optional(),user_location:u.nullish()}),y=i.z.object({type:i.z.union([i.z.literal(m.WebSearch),i.z.literal(m.WebSearch20250826)]),filters:i.z.object({allowed_domains:i.z.array(i.z.string()).nullish()}).nullish(),search_context_size:d.optional(),user_location:u.nullish()}),_=new Set(Object.values(h)),b=i.z.object({type:i.z.string().refine(e=>!_.has(e),{message:"Tool type is explicitly modeled and must match its strict schema"})}).passthrough();i.z.union([z,f,y,g,b]).openapi("OpenAIResponsesTool");let I=g.extend({model:i.z.union([i.z.literal("gpt-image-1"),i.z.literal("gpt-image-1-mini"),i.z.literal("gpt-image-1.5"),i.z.literal("gpt-image-2")]).optional(),size:i.z.string().optional()});i.z.union([z,f,y,I,b]);let S=i.z.union([i.z.literal("auto"),i.z.literal("none"),i.z.literal("required"),i.z.object({type:i.z.literal("function"),name:i.z.string()}),i.z.object({type:i.z.union([i.z.literal(m.WebSearchPreview20250311),i.z.literal(m.WebSearchPreview)])}),i.z.object({type:i.z.literal("allowed_tools"),mode:i.z.union([i.z.literal("auto"),i.z.literal("required")]),tools:i.z.array(i.z.record(i.z.string(),i.z.unknown()))}).openapi("ToolChoiceAllowed",{description:"Constrains the model to a pre-defined set of allowed tools",example:{type:"allowed_tools",mode:"auto",tools:[{type:"function",name:"get_weather"}]}}),i.z.object({type:i.z.literal("apply_patch")}),i.z.object({type:i.z.literal("shell")})]).openapi("OpenAIResponsesToolChoice",{example:"auto"}),v=i.z.object({type:i.z.literal("file_citation"),file_id:i.z.string(),filename:i.z.string(),index:(0,o.zInt)()}).openapi("FileCitation",{example:{type:"file_citation",file_id:"file-abc123",filename:"research_paper.pdf",index:0}}),x=i.z.object({type:i.z.literal("url_citation"),url:i.z.string(),title:i.z.string(),start_index:(0,o.zInt)(),end_index:(0,o.zInt)(),content:i.z.string().optional()}).openapi("URLCitation",{example:{type:"url_citation",start_index:0,end_index:42,title:"OpenRouter Documentation",url:"https://openrouter.ai/docs",content:"OpenRouter provides a unified API for accessing LLMs from multiple providers."}}),w=x.extend({title:i.z.string().nullish(),start_index:(0,o.zInt)().nullish(),end_index:(0,o.zInt)().nullish()}).openapi("LooseURLCitation"),A=i.z.object({type:i.z.literal("file_path"),file_id:i.z.string(),index:(0,o.zInt)()}).openapi("FilePath",{example:{type:"file_path",file_id:"file-xyz789",index:0}}),O=i.z.union([v,x,A]).openapi("OpenAIResponsesAnnotation",{example:{type:"file_citation",file_id:"file-abc123",filename:"research_paper.pdf",index:0}}),R=i.z.object({token:i.z.string(),bytes:i.z.array((0,o.zInt)()),logprob:(0,o.zDouble)()}),C=R.extend({top_logprobs:i.z.array(R)}),T=i.z.object({type:i.z.literal("output_text"),text:i.z.string(),annotations:i.z.array(O).optional(),logprobs:i.z.array(C).optional()}).openapi("ResponseOutputText",{example:{type:"output_text",text:"The capital of France is Paris.",annotations:[{type:"url_citation",start_index:0,end_index:42,title:"Paris - Wikipedia",url:"https://en.wikipedia.org/wiki/Paris"}]}}),j=i.z.object({type:i.z.literal("reasoning_text"),text:i.z.string()}).openapi("ReasoningTextContent",{example:{type:"reasoning_text",text:"Let me think step by step about this problem..."}}),k=i.z.object({cached_tokens:(0,o.zInt)(),cache_write_tokens:(0,o.zInt)().nullish()}),M=i.z.object({reasoning_tokens:(0,o.zInt)()}),P=i.z.object({input_tokens:(0,o.zInt)(),input_tokens_details:k,output_tokens:(0,o.zInt)(),output_tokens_details:M,total_tokens:(0,o.zInt)()}).openapi("OpenAIResponsesUsage",{example:{input_tokens:100,input_tokens_details:{cached_tokens:0},output_tokens:50,output_tokens_details:{reasoning_tokens:0},total_tokens:150}}),E=i.z.object({type:i.z.literal("summary_text"),text:i.z.string()}).openapi("ReasoningSummaryText",{example:{type:"summary_text",text:"Analyzed the problem using first principles"}}),F=i.z.object({type:i.z.literal("reasoning"),id:i.z.string(),content:i.z.array(j).optional(),summary:i.z.array(E),encrypted_content:i.z.string().nullish(),status:i.z.union([i.z.literal(l.OpenAIResponsesAPIResponseStatus.Completed),i.z.literal(l.OpenAIResponsesAPIResponseStatus.Incomplete),i.z.literal(l.OpenAIResponsesAPIResponseStatus.InProgress)]).optional()}).openapi("OutputItemReasoning",{example:{type:"reasoning",id:"reasoning-abc123",summary:[{type:"summary_text",text:"Analyzed the problem using first principles"}]}}),q=i.z.boolean().optional().openapi({description:"True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`.",example:!0}),D=i.z.object({type:i.z.literal("function_call"),id:i.z.string().optional(),name:i.z.string(),arguments:i.z.string(),call_id:i.z.string(),status:i.z.union([i.z.literal(l.OpenAIResponsesAPIResponseStatus.Completed),i.z.literal(l.OpenAIResponsesAPIResponseStatus.Incomplete),i.z.literal(l.OpenAIResponsesAPIResponseStatus.InProgress)]).optional(),namespace:i.z.string().optional().openapi({description:"Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)"}),async:q}).openapi("OutputItemFunctionCall",{example:{type:"function_call",id:"call-abc123",name:"get_weather",arguments:'{"location":"San Francisco","unit":"celsius"}',call_id:"call-abc123"}}),W=i.z.object({type:i.z.literal("custom_tool_call"),id:i.z.string().optional(),name:i.z.string(),input:i.z.string(),call_id:i.z.string(),status:i.z.enum(n.RESPONSES_ITEM_STATUSES).optional(),namespace:i.z.string().optional().openapi({description:"Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)"}),async:q}).openapi("OutputItemCustomToolCall",{example:{type:"custom_tool_call",id:"ctc-abc123",name:"apply_patch",input:"*** Begin Patch\n*** End Patch",call_id:"call-abc123",status:"completed"}}),U=i.z.object({type:i.z.literal("computer_call"),id:i.z.string(),call_id:i.z.string(),status:i.z.enum(["completed","incomplete","in_progress"]),action:i.z.unknown(),pending_safety_checks:i.z.array(i.z.object({id:i.z.string(),code:i.z.string(),message:i.z.string()}))}),L=i.z.object({type:i.z.literal("refusal"),refusal:i.z.string()}).openapi("OpenAIResponsesRefusalContent",{example:{type:"refusal",refusal:"I'm sorry, I cannot assist with that request"}}),V=i.z.enum(l.OpenAIResponsesAPIResponseStatus).openapi("OpenAIResponsesResponseStatus",{example:"completed"}),K=i.z.object({id:i.z.string(),role:i.z.literal("assistant"),type:i.z.literal("message"),status:i.z.union([i.z.literal(l.OpenAIResponsesAPIResponseStatus.Completed),i.z.literal(l.OpenAIResponsesAPIResponseStatus.Incomplete),i.z.literal(l.OpenAIResponsesAPIResponseStatus.InProgress)]).optional(),content:i.z.array(i.z.union([T,L])),phase:i.z.union([i.z.literal("commentary"),i.z.literal("final_answer")]).nullish().openapi({description:"The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages."})}).openapi("OutputMessage",{example:{id:"msg-abc123",role:"assistant",type:"message",status:"completed",content:[{type:"output_text",text:"Hello! How can I help you today?"}]}}),N=i.z.enum(l.OpenAIResponsesWebSearchStatus).openapi("WebSearchStatus",{example:"completed"}),G=i.z.object({type:i.z.literal("url"),url:i.z.string()}).openapi("WebSearchSource",{example:{type:"url",url:"https://example.com/article"}}),$=i.z.object({type:i.z.literal("search"),query:i.z.string(),queries:i.z.array(i.z.string()).optional(),sources:i.z.array(G).optional()}),B=i.z.object({type:i.z.literal("open_page"),url:i.z.string().nullish()}),H=i.z.object({type:i.z.literal("find_in_page"),pattern:i.z.string(),url:i.z.string()}),J=i.z.object({type:i.z.literal("web_search_call"),id:i.z.string(),action:i.z.discriminatedUnion("type",[$,B,H]).optional(),status:N}).passthrough().openapi("OutputItemWebSearchCall",{example:{type:"web_search_call",id:"search-abc123",action:{type:"search",query:"OpenAI API"},status:"completed"}}),X=i.z.object({type:i.z.literal("file_search_call"),id:i.z.string(),queries:i.z.array(i.z.string()),status:N}).openapi("OutputItemFileSearchCall",{example:{type:"file_search_call",id:"filesearch-abc123",queries:["machine learning algorithms","neural networks"],status:"completed"}}),Z=i.z.object({type:i.z.literal("create_file"),path:i.z.string(),diff:i.z.string()}).openapi("ApplyPatchCreateFileOperation",{description:"The `create_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing the new file contents.",example:{type:"create_file",path:"/src/main.ts",diff:'@@\n+console.log("hi");\n'}}),Q=i.z.object({type:i.z.literal("update_file"),path:i.z.string(),diff:i.z.string()}).openapi("ApplyPatchUpdateFileOperation",{description:"The `update_file` variant of an `apply_patch_call.operation`. Carries a V4A diff describing edits to an existing file.",example:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}),Y=i.z.object({type:i.z.literal("delete_file"),path:i.z.string()}).openapi("ApplyPatchDeleteFileOperation",{description:"The `delete_file` variant of an `apply_patch_call.operation`. Identifies the file to remove; no diff is required.",example:{type:"delete_file",path:"/src/main.ts"}}),ee=i.z.discriminatedUnion("type",[Z,Q,Y]),et=i.z.object({type:i.z.literal("apply_patch_call"),id:i.z.string(),call_id:i.z.string(),operation:ee,status:i.z.enum(["in_progress","completed"]),created_by:i.z.string().optional()}).openapi("OutputItemApplyPatchCall",{example:{type:"apply_patch_call",id:"apc_abc123",call_id:"call_abc123",status:"completed",operation:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}}),ea=i.z.object({type:i.z.literal("code_interpreter_call"),id:i.z.string(),code:i.z.string().nullish(),container_id:i.z.string().optional(),outputs:i.z.array(s.OpenAIResponsesCodeInterpreterOutputEntrySchema).nullish(),status:i.z.enum(["in_progress","completed","incomplete","interpreting","failed"])}).passthrough().openapi("OutputItemCodeInterpreterCall",{example:{type:"code_interpreter_call",id:"ci_abc123",code:'print("hello")',outputs:[{type:"logs",logs:"hello\n"}],status:"completed"}}),en=i.z.discriminatedUnion("type",[K,F,D,W,J,X,p.OpenAIResponsesImageGenerationCallSchema,et,ea]),eo=i.z.enum(l.OpenAIResponsesIncompleteReason).openapi("OpenAIResponsesIncompleteReason",{description:"The reason why the response is incomplete",example:l.OpenAIResponsesIncompleteReason.MaxOutputTokens}),ei=i.z.object({reason:eo}).openapi("OpenAIResponsesIncompleteDetails",{description:"Details about why the response is incomplete",example:{reason:l.OpenAIResponsesIncompleteReason.MaxOutputTokens}});i.z.union([i.z.object({type:i.z.literal("text"),text:i.z.string()}),i.z.string()]),t.PolicyBlockApiErrorType.Refusal,t.PolicyBlockApiErrorType.Refusal,t.PolicyBlockApiErrorType.Refusal,t.PolicyBlockApiErrorType.ContentPolicyViolation;let er=i.z.object({code:i.z.enum({ServerError:"server_error",RateLimitExceeded:"rate_limit_exceeded",InvalidPrompt:"invalid_prompt",VectorStoreTimeout:"vector_store_timeout",InvalidImage:"invalid_image",InvalidImageFormat:"invalid_image_format",InvalidBase64Image:"invalid_base64_image",InvalidImageUrl:"invalid_image_url",ImageTooLarge:"image_too_large",ImageTooSmall:"image_too_small",ImageParseError:"image_parse_error",ImageContentPolicyViolation:"image_content_policy_violation",InvalidImageMode:"invalid_image_mode",ImageFileTooLarge:"image_file_too_large",UnsupportedImageMediaType:"unsupported_image_media_type",EmptyImageFile:"empty_image_file",FailedToDownloadImage:"failed_to_download_image",ImageFileNotFound:"image_file_not_found",BioPolicy:"bio_policy",CyberPolicy:"cyber_policy",MisalignmentPolicyViolation:"misalignment_policy_violation",DataResidencyMismatch:"data_residency_mismatch"}),message:i.z.string()}).openapi("ResponsesErrorField",{description:"Error information returned from the API",example:{code:"rate_limit_exceeded",message:"Rate limit exceeded. Please try again later."}}),es=i.z.object({code:i.z.string(),message:i.z.string().optional().catch(void 0)});i.z.object({error:er,metadata:i.z.record(i.z.string(),i.z.string()).nullable()}),i.z.object({id:i.z.string(),created_at:(0,o.zInt)(),output_text:i.z.string().optional(),incomplete_details:ei.nullable(),model:i.z.string(),object:i.z.literal("response"),output:i.z.array(en),tool_choice:i.z.any().optional(),background:i.z.boolean().nullish(),conversation:i.z.any().nullish(),max_output_tokens:(0,o.zInt)().nullish(),previous_response_id:i.z.string().nullish(),prompt:i.z.any().nullish(),prompt_cache_key:i.z.string().nullish(),reasoning:r.UpstreamEffectiveReasoningSchema.nullish().catch(null),safety_identifier:i.z.string().nullish(),service_tier:i.z.string().nullish(),status:V.optional(),text:i.z.any().nullish(),truncation:c.nullish(),usage:P.nullish(),error:i.z.unknown().nullish(),instructions:i.z.unknown().nullish(),metadata:i.z.unknown().nullish(),parallel_tool_calls:i.z.unknown().nullish(),temperature:i.z.unknown().nullish(),tools:i.z.unknown().nullish(),top_p:i.z.unknown().nullish(),store:i.z.unknown().nullish()}).openapi("OpenAIResponsesNonStreamResponse");let el=i.z.object({token:i.z.string().optional(),logprob:(0,o.zDouble)().optional()}).extend({bytes:i.z.array((0,o.zInt)()).optional()}).openapi("OpenResponsesTopLogprobs",{description:"Alternative token with its log probability",example:{token:"hello",logprob:-.5}}),ep=i.z.object({logprob:(0,o.zDouble)(),token:i.z.string(),top_logprobs:i.z.array(el).optional()}).extend({bytes:i.z.array((0,o.zInt)()).optional()}).openapi("OpenResponsesLogProbs",{description:"Log probability information for a token",example:{logprob:-.1,token:"world",top_logprobs:[{token:"hello",logprob:-.5}]}}),ec=i.z.object({type:i.z.literal("response.output_text.delta"),delta:i.z.string(),content_index:(0,o.zInt)(),item_id:i.z.string(),logprobs:i.z.array(ep),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesTextDeltaChunk"),eu=i.z.object({type:i.z.literal("response.output_text.done"),text:i.z.string(),content_index:(0,o.zInt)(),item_id:i.z.string(),logprobs:i.z.array(ep),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesTextDoneChunk"),ed=i.z.object({type:i.z.literal("response.completed"),response:i.z.object({usage:P.nullish(),service_tier:i.z.string().nullish(),reasoning:r.UpstreamEffectiveReasoningSchema.nullish().catch(null)}),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesCompletedChunk"),em=i.z.object({type:i.z.literal("response.incomplete"),response:i.z.object({usage:P,service_tier:i.z.string().nullish(),reasoning:r.UpstreamEffectiveReasoningSchema.nullish().catch(null),incomplete_details:ei.nullish()}),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesIncompleteChunk"),eh=i.z.object({type:i.z.literal("response.created"),response:i.z.object({id:i.z.string(),created_at:(0,o.zInt)(),model:i.z.string()}),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesCreatedChunk"),eg=i.z.object({type:i.z.literal("response.output_item.done"),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),item:en}).openapi("OpenAIResponsesOutputItemDone"),ez=i.z.object({type:i.z.literal("response.function_call_arguments.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesFunctionCallArgumentsDelta"),ef=i.z.object({type:i.z.literal("response.output_item.added"),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),item:en}).openapi("OpenAIResponsesOutputItemAdded"),ey=i.z.object({type:i.z.literal("response.output_text.annotation.added"),annotation:i.z.union([w,v,A])}).openapi("OpenAIResponsesAnnotationAdded"),e_=i.z.object({type:i.z.literal("response.reasoning_summary_text.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),summary_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesReasoningSummaryTextDelta"),eb=i.z.object({type:i.z.literal("response.reasoning_text.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),content_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesReasoningTextDelta"),eI=i.z.object({type:i.z.literal("response.web_search_call.completed"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesSearchCompleted",{example:{type:"response.web_search_call.completed",item_id:"ws_abc123",output_index:0,sequence_number:5}}),eS=i.z.object({type:i.z.literal("response.function_call_arguments.done"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),arguments:i.z.string(),name:i.z.string().optional()}).openapi("OpenAIResponsesFunctionCallArgumentsDone"),ev=i.z.object({type:i.z.literal("response.failed"),response:i.z.object({id:i.z.string(),status:i.z.literal("failed"),error:es.nullable(),usage:P.nullish()})}).openapi("OpenAIResponsesFailed"),ex=i.z.object({type:i.z.string().optional(),code:i.z.string().nullish(),message:i.z.string(),param:i.z.string().nullish(),headers:i.z.record(i.z.string(),i.z.string()).optional()}),ew=i.z.object({type:i.z.literal("error"),code:i.z.string().nullish(),message:i.z.string().optional(),param:i.z.string().nullish(),sequence_number:(0,o.zInt)(),error:ex.optional()}).openapi("OpenAIResponsesErrorEvent"),eA=i.z.object({type:i.z.literal("response.refusal.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string(),content_index:(0,o.zInt)()}).openapi("OpenAIResponsesRefusalDelta"),eO=i.z.object({type:i.z.literal("response.refusal.done"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),refusal:i.z.string(),content_index:(0,o.zInt)()}).openapi("OpenAIResponsesRefusalDone"),eR=i.z.object({type:i.z.literal("response.file_search_call.in_progress"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesFileSearchCallInProgress"),eC=i.z.object({type:i.z.literal("response.file_search_call.searching"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesFileSearchCallSearching"),eT=i.z.object({type:i.z.literal("response.file_search_call.completed"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesFileSearchCallCompleted"),ej=i.z.object({type:i.z.literal("response.web_search_call.in_progress"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesWebSearchCallInProgress",{example:{type:"response.web_search_call.in_progress",item_id:"ws_abc123",output_index:0,sequence_number:1}}),ek=i.z.object({type:i.z.literal("response.web_search_call.searching"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesWebSearchCallSearching",{example:{type:"response.web_search_call.searching",item_id:"ws_abc123",output_index:0,sequence_number:2}}),eM=i.z.object({type:i.z.literal("response.code_interpreter_call.in_progress"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesCodeInterpreterCallInProgress",{example:{type:"response.code_interpreter_call.in_progress",item_id:"ci_abc123",output_index:0,sequence_number:1}}),eP=i.z.object({type:i.z.literal("response.code_interpreter_call.interpreting"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesCodeInterpreterCallInterpreting",{example:{type:"response.code_interpreter_call.interpreting",item_id:"ci_abc123",output_index:0,sequence_number:2}}),eE=i.z.object({type:i.z.literal("response.code_interpreter_call.completed"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesCodeInterpreterCallCompleted",{example:{type:"response.code_interpreter_call.completed",item_id:"ci_abc123",output_index:0,sequence_number:3}}),eF=i.z.object({type:i.z.literal("response.code_interpreter_call_code.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesCodeInterpreterCallCodeDelta",{example:{type:"response.code_interpreter_call_code.delta",item_id:"ci_abc123",output_index:0,sequence_number:2,delta:'print("hello")'}}),eq=i.z.object({type:i.z.literal("response.code_interpreter_call_code.done"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),code:i.z.string()}).openapi("OpenAIResponsesCodeInterpreterCallCodeDone",{example:{type:"response.code_interpreter_call_code.done",item_id:"ci_abc123",output_index:0,sequence_number:3,code:'print("hello")'}}),eD=i.z.object({type:i.z.literal("response.image_generation_call.in_progress"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesImageGenCallInProgress",{example:{type:"response.image_generation_call.in_progress",item_id:"ig_abc123",output_index:0,sequence_number:1}}),eW=i.z.object({type:i.z.literal("response.image_generation_call.generating"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesImageGenCallGenerating",{example:{type:"response.image_generation_call.generating",item_id:"ig_abc123",output_index:0,sequence_number:2}}),eU=i.z.object({type:i.z.literal("response.image_generation_call.partial_image"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),partial_image_b64:i.z.string(),partial_image_index:(0,o.zInt)()}).openapi("OpenAIResponsesImageGenCallPartialImage",{example:{type:"response.image_generation_call.partial_image",item_id:"ig_abc123",output_index:0,sequence_number:3,partial_image_b64:"iVBORw0KGgo...",partial_image_index:0}}),eL=i.z.object({type:i.z.literal("response.image_generation_call.completed"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)()}).openapi("OpenAIResponsesImageGenCallCompleted",{example:{type:"response.image_generation_call.completed",item_id:"ig_abc123",output_index:0,sequence_number:4}}),eV=i.z.object({type:i.z.literal("response.custom_tool_call_input.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesCustomToolCallInputDelta"),eK=i.z.object({type:i.z.literal("response.custom_tool_call_input.done"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),input:i.z.string()}).openapi("OpenAIResponsesCustomToolCallInputDone"),eN=i.z.object({type:i.z.literal("response.apply_patch_call_operation_diff.delta"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),delta:i.z.string()}).openapi("OpenAIResponsesApplyPatchCallOperationDiffDelta",{description:"Incremental chunk of `operation.diff` for an `apply_patch_call` output item streamed by the upstream provider.",example:{type:"response.apply_patch_call_operation_diff.delta",item_id:"apc_abc123",output_index:0,sequence_number:5,delta:'+console.log("hi");\n'}}),eG=i.z.object({type:i.z.literal("response.apply_patch_call_operation_diff.done"),item_id:i.z.string(),output_index:(0,o.zInt)(),sequence_number:(0,o.zInt)(),diff:i.z.string()}).openapi("OpenAIResponsesApplyPatchCallOperationDiffDone",{description:"Emitted by the upstream provider when `operation.diff` streaming completes for an `apply_patch_call`.",example:{type:"response.apply_patch_call_operation_diff.done",item_id:"apc_abc123",output_index:0,sequence_number:12,diff:'@@\n+console.log("hi");\n'}}),e$=i.z.discriminatedUnion("type",[ec,eu,ed,em,eh,ez,ef,eg,ey,e_,eb,eS,eI,eR,eC,eT,ej,ek,eM,eP,eE,eF,eq,eD,eW,eU,eL,eV,eK,eN,eG,ev,ew,eA,eO]);(0,o.buildZodGuard)(e$),e$.options.map(e=>e.shape.type.value),(0,o.buildZodGuard)(i.z.object({type:i.z.enum(["response.in_progress","response.reasoning_summary_part.added","response.reasoning_summary_part.done","response.reasoning_summary_text.done","response.reasoning_text.done","response.content_part.added","response.content_part.done","response.audio.delta","response.audio.done","response.audio.transcript.delta","response.audio.transcript.done","response.mcp_call.completed","response.mcp_call.failed","response.mcp_call.in_progress","response.mcp_list_tools.completed","response.mcp_list_tools.failed","response.mcp_list_tools.in_progress"])})),e.s(["AsyncToolCallFlagSchema",0,q,"OpenAIResponsesAnnotationSchema",0,O,"OpenAIResponsesApplyPatchCreateFileOperationSchema",0,Z,"OpenAIResponsesApplyPatchDeleteFileOperationSchema",0,Y,"OpenAIResponsesApplyPatchUpdateFileOperationSchema",0,Q,"OpenAIResponsesCodeInterpreterCallOutputSchema",0,ea,"OpenAIResponsesErrorFieldSchema",0,er,"OpenAIResponsesOutputItemComputerCallSchema",0,U,"OpenAIResponsesOutputItemCustomToolCallSchema",0,W,"OpenAIResponsesOutputItemFileSearchCallSchema",0,X,"OpenAIResponsesOutputItemFunctionCallSchema",0,D,"OpenAIResponsesOutputItemReasoningSchema",0,F,"OpenAIResponsesOutputItemSchema",0,en,"OpenAIResponsesOutputMessageSchema",0,K,"OpenAIResponsesOutputTextSchema",0,T,"OpenAIResponsesReasoningTextSchema",0,j,"OpenAIResponsesRefusalContentSchema",0,L,"OpenAIResponsesResponseStatusSchema",0,V,"OpenAIResponsesSearchContextSizeSchema",0,d,"OpenAIResponsesToolChoiceSchema",0,S,"OpenAIResponsesUsageSchema",0,P,"OpenAIResponsesWebSearchCallOutputSchema",0,J,"OpenAIResponsesWebSearchToolType",0,m,"OpenAIResponsesWebSearchUserLocationSchema",0,u])},345567,473059,305904,e=>{"use strict";var t=e.i(204067),a=e.i(796805),n=e.i(80125);let o=a.z.object({effort:a.z.enum(n.CompletionRequestReasoningEffort).nullish().catch(null),summary:a.z.enum(["auto","concise","detailed"]).nullish().catch(null),context:a.z.enum(n.CompletionRequestReasoningContext).nullish().catch(null),mode:a.z.enum(n.CompletionRequestReasoningMode).nullish().catch(null)});e.s(["UpstreamEffectiveReasoningSchema",0,o],345567);let i=a.z.object({type:a.z.literal("logs"),logs:a.z.string()}).openapi("CodeInterpreterLogsOutput",{example:{type:"logs",logs:"hello\n"}}),r=a.z.object({type:a.z.literal("image"),url:a.z.string()}).openapi("CodeInterpreterImageOutput",{example:{type:"image",url:"https://example.com/plot.png"}}),s=a.z.object({type:a.z.literal("file"),id:a.z.string().optional(),filename:a.z.string().optional(),media_type:a.z.string().optional(),size_bytes:(0,t.zInt)().optional(),sha256:a.z.string().optional(),download_url:a.z.string().optional().openapi({description:"Provider-issued download URL for the generated file. Typically signed and time-limited (see `expires_at`); fetch promptly rather than persisting the URL."}),expires_at:a.z.string().optional().openapi({description:"When the `download_url` stops working, as an ISO 8601 timestamp. After this time the file must be regenerated."}),status:a.z.string().optional().openapi({description:"Provider-reported readiness of the generated file (e.g. `ready`). Values other than `ready` indicate the artifact may not be downloadable."}),error_code:a.z.string().nullish().openapi({description:"Provider error code when generating or persisting the file failed; null or absent on success."})}).openapi("CodeInterpreterFileOutput",{example:{type:"file",id:"file_abc123",filename:"summary.txt",download_url:"https://example.com/download/file_abc123"}}),l=a.z.discriminatedUnion("type",[i,r,s]);e.s(["OpenAIResponsesCodeInterpreterOutputEntrySchema",0,l],473059),e.s(["OpenAIResponsesAPIResponseStatus",0,{Completed:"completed",Incomplete:"incomplete",InProgress:"in_progress",Failed:"failed",Cancelled:"cancelled",Queued:"queued"},"OpenAIResponsesImageDetail",0,{Auto:"auto",High:"high",Low:"low",Original:"original"},"OpenAIResponsesIncompleteReason",0,{MaxOutputTokens:"max_output_tokens",ContentFilter:"content_filter"},"OpenAIResponsesServiceTier",0,{Auto:"auto",Default:"default",Flex:"flex",Priority:"priority",Scale:"scale"},"OpenAIResponsesTruncation",0,{Auto:"auto",Disabled:"disabled"},"OpenAIResponsesWebSearchStatus",0,{Completed:"completed",Searching:"searching",InProgress:"in_progress",Failed:"failed"}],305904)},295654,e=>{"use strict";var t=e.i(687421),a=e.i(230953);e.i(798823);var n=e.i(429930);let o={id:"",title:"",createdAt:new Date,updatedAt:new Date,messages:{},characters:{},isProcessing:!1,sortedMessageIds:[],hydrationStatus:n.HydrationStatus.Idle,hydrationError:null,artifactIds:[],isPinned:!1},i={id:"USER",name:"User",samplingParameters:{},createdAt:new Date,updatedAt:new Date},r={id:"SYSTEM",name:"System",samplingParameters:{},createdAt:new Date,updatedAt:new Date},s={id:"DELETED",name:"Deleted",samplingParameters:{},createdAt:new Date,updatedAt:new Date};e.s(["DEFAULT_APP_NAME",0,"New App","DEFAULT_CHAT_ROOM_TITLE",0,"Untitled Chat","MAX_CHAT_MEMORY_COUNT",0,1e3,"checkSystem",0,e=>e===r.id,"checkUser",0,e=>e===i.id,"defaultCharacterModelSlug",0,"openrouter/auto","defaultInferenceParams",0,{maxTokens:void 0},"defaultMaxTokensLimit",0,1e5,"defaultModelPresets",0,[{permaslugs:["~google/gemini-pro-latest","~anthropic/claude-opus-latest","x-ai/grok-4.20-20260309","~openai/gpt-sol-latest"],title:"Flagship models"},{permaslugs:["deepseek/deepseek-v3.2-20251201","~google/gemini-flash-latest","mistralai/mistral-nemo"],title:"Best roleplay models"},{permaslugs:["~anthropic/claude-opus-latest","~google/gemini-pro-latest","x-ai/grok-code-fast-1","~openai/gpt-sol-latest"],title:"Best coding models"},{permaslugs:["~google/gemini-pro-latest","deepseek/deepseek-r1-0528","x-ai/grok-4.20-20260309","openai/o4-mini-high-2025-04-16"],title:"Reasoning models"}],"defaultPromptPresets",0,[{title:"Car Wash Test",description:"Should you walk or drive?",prompt:"I want to wash my car. The car wash is 50 meters away. Should I walk or drive?"},{title:"9.9 vs 9.11",description:"Which one is larger?",prompt:"9.11 and 9.9, which one is larger?"},{title:"Strawberry Test",description:"How many r’s are in the word",prompt:"How many r’s are in the word strawberry?"},{title:"Poem Riddle",description:"Compose a 12-line poem",prompt:"Compose a 12-line poem where the first letters of the odd-numbered lines form the name “SAMIRA” and the first letters of the even-numbered lines spell out “DAWOOD.” Additionally, the first letter of each word in every line should create the capital of a country"},{title:"Personal Finance",description:"Draft up a portfolio management proposal",prompt:"I'm a truck driver making around $65k a year and I'm aiming to retire in 30 years. Could you draft up a portfolio management proposal?"},{title:"Anagram Challenge",description:"Unscramble letters to form a word.",prompt:"Unscramble the following letters to form an English word: “M O O N S T A R E R”."},{title:"The Missing Dollar",description:"A classic logic puzzle involving money.",prompt:"Three people check into a hotel room that costs $30. They each pay $10. Later, the manager realizes the room is only $25 and gives $5 to the bellboy to return to the guests. The bellboy, unable to split $5 evenly, gives each guest $1 and keeps $2 as a tip. Now, each guest has paid $9 (totaling $27), and the bellboy has $2, totaling $29. Where is the missing dollar?"},{title:"Word Transformation",description:"Change one word into another by altering one letter at a time.",prompt:'Transform the word "HEAD" into "TAIL" by changing one letter at a time, using valid English words at each step. What is the shortest sequence?'},{title:"Palindrome Quest",description:"Find the smallest palindrome greater than a given number.",prompt:"What is the smallest palindrome number greater than 130?"},{title:"Alphabet Series",description:"Identify the next letter in a sequence.",prompt:"What is the next letter in the series: A, C, F, J, O, ___?"},{title:"Career Development",description:"Create a professional growth roadmap.",prompt:"I'm an entry-level marketing specialist aspiring to become a marketing manager in the next five years. What steps should I take to achieve this goal?"},{title:"Healthy Lifestyle",description:"Design a balanced diet and exercise regimen.",prompt:"I'm looking to adopt a healthier lifestyle. Could you help me plan a balanced diet and a weekly exercise routine suitable for a beginner?"},{title:"Small Business Strategy",description:"Develop a business expansion plan.",prompt:"I own a local bakery that's doing well. I'd like to expand my business online. Can you draft a proposal outlining the steps I should take?"},{title:"Educational Advancement",description:"Plan for higher education.",prompt:"I'm a high school senior interested in environmental science. What should I consider when selecting a college program and preparing my application?"}],"deletedCharacter",0,s,"emptyRoomData",0,o,"getDefaultSystemPrompt",0,function(e){if(!e)return"";let n=e.author_display_name||e.author,o=e.short_name||e.name;if(!o||!n||e?.endpoint?.provider_name===t.ProviderName.Stealth)return"";let i=(0,a.formatDate)(new Date,{locale:"en-US",timeZone:"UTC",preset:"weekday-long-date"});return`You are ${o}, a large language model from ${n}. Today's date is ${i}.`.concat("\n\n","Formatting Rules:\n- Use Markdown for lists, tables, and styling.\n- Use ```code fences``` for all code blocks.\n- Format file names, paths, and function names with `inline code` backticks.\n- **For all mathematical expressions, you must use dollar-sign delimiters. Use $...$ for inline math and $$...$$ for block math. Do not use (...) or [...] delimiters.**\n- For responses with many sections where some are more important than others, use collapsible sections (HTML details/summary tags) to highlight key information while allowing users to expand less critical details.")},"systemCharacter",0,r,"userCharacter",0,i])},472708,429930,351344,442401,808959,e=>{"use strict";var t,a,n,o,i,r,s,l,p,c,u,d,m,h,g=e.i(204067),z=e.i(796805),f=e.i(463522),y=((t={}).Text="text",t.Artifact="artifact",t.ArtifactVersion="artifact-version",t),_=((a={}).Editor="editor",a.Preview="preview",a),b=((n={}).Idle="idle",n.Pending="pending",n.Success="success",n.Failed="failed",n),I=((o={}).Idle="idle",o.Generating="generating",o.Success="success",o.Failed="failed",o),S=((i={}).MainChat="main-chat",i.ArtifactChat="artifact-chat",i),v=((r={}).User="user",r.Assistant="assistant",r.System="system",r),x=((s={}).UserInput="user-input",s.Url="url",s.ActivityReplay="activity-replay",s),w=((l={}).Idle="idle",l.Pending="pending",l.Success="success",l.Failed="failed",l),A=((p={}).App="app",p.Image="image",p),O=((c={}).TypeScript="typescript",c.JavaScript="javascript",c.JS="js",c.JSX="jsx",c.HTML="html",c.CSS="css",c.JSON="json",c.Markdown="markdown",c.Text="text",c.Image="image",c),R=((u={}).HTML="html-css-js",u),C=((d={}).Default="default",d),T=((m={}).InteractiveWebApp="interactive-web-app",m.LandingPage="landing-page",m.TwoDGame="2d-game",m.ThreeDGame="3d-game",m),j=((h={}).Image="image",h);let k=z.z.union([z.z.date(),z.z.string(),z.z.number()]).transform(e=>(0,f.safeParseDate)(e,new Date));e.s(["AppArchetype",()=>T,"AppStack",()=>R,"ArtifactType",()=>A,"ArtifactView",()=>_,"ChatModality",()=>j,"ContentType",()=>y,"DateOrIsoStringSchema",0,k,"FileType",()=>O,"GenerationStatus",()=>I,"HydrationStatus",()=>w,"ImageArchetype",()=>C,"MessageContext",()=>S,"MessageType",()=>v,"PendingMessageSource",()=>x,"StoreInitializationStatus",()=>b],429930);let M=z.z.object({id:z.z.string(),artifactId:z.z.string().optional(),parentVersionId:z.z.string().optional(),generatingMessageId:z.z.string().optional(),characterId:z.z.string(),createdAt:k,generationStatus:z.z.nativeEnum(I).optional(),generationDurationMs:z.z.number().optional(),characterName:z.z.string().optional(),prompt:z.z.string().optional(),versionNumber:z.z.number().optional(),error:z.z.string().optional()}),P=M.extend({type:z.z.literal(A.App).optional().default(A.App),generationStatus:z.z.enum(I).optional().default(I.Idle),fileContents:z.z.record(z.z.string(),z.z.string())}),E=M.extend({type:z.z.literal(A.Image),fileContents:z.z.record(z.z.string(),z.z.string())}),F=z.z.discriminatedUnion("type",[P,E]),q=z.z.object({id:z.z.string(),content:z.z.string(),createdAt:k,generationStatus:z.z.enum(I).optional().default(I.Idle)}),D=z.z.object({id:z.z.string(),filename:z.z.string(),type:z.z.enum(O),createdAt:k,updatedAt:k}),W=z.z.object({id:z.z.string(),name:z.z.string(),type:z.z.enum(A),headVersionId:z.z.string().optional(),fileIds:z.z.array(z.z.string()),createdAt:k,updatedAt:k,versionsCount:z.z.number().optional(),activeCharacterId:z.z.string().nullish(),characterIds:z.z.array(z.z.string()).optional().default([])}),U=W.extend({type:z.z.literal(A.App),entrypointFileId:z.z.string().optional(),stack:z.z.enum(R),archetype:z.z.enum(T).optional()}),L=W.extend({type:z.z.literal(A.Image),prompt:z.z.string().optional(),archetype:z.z.enum(C).optional()}),V=z.z.discriminatedUnion("type",[U,L]);z.z.object({view:z.z.enum(_),activeFileId:z.z.string().nullable(),activeVersionId:z.z.string().nullable(),expandedFolders:z.z.record(z.z.string(),z.z.boolean()).optional().default({})});let K=z.z.record(z.z.string(),V),N=z.z.record(z.z.string(),F),G=z.z.record(z.z.string(),q),$=z.z.record(z.z.string(),D);e.s(["ArtifactFileContentMapSchema",0,G,"ArtifactFileContentSchema",0,q,"ArtifactFileMapSchema",0,$,"ArtifactFileSchema",0,D,"ArtifactMapSchema",0,K,"ArtifactSchema",0,V,"ArtifactVersionMapSchema",0,N,"ArtifactVersionSchema",0,F],472708);var B=e.i(611784),H=e.i(687421);let J=z.z.object({id:z.z.string(),name:z.z.string().optional(),model:z.z.string().optional(),presetSlug:z.z.string().optional(),presetName:z.z.string().optional(),modelInfo:z.z.custom().nullish(),description:z.z.string().optional(),includeDefaultSystemPrompt:z.z.boolean().optional(),avatarUrl:z.z.string().optional(),isStreaming:z.z.boolean().optional(),samplingParameters:z.z.record(z.z.string(),(0,g.zDouble)()).optional().default({}),maxTokens:(0,g.zInt)().optional(),provider:z.z.enum(H.ProviderName).optional(),providerSort:z.z.enum(B.ProviderSort).nullish(),zdr:z.z.boolean().optional(),isDisabled:z.z.boolean().optional(),isRemoved:z.z.boolean().optional(),createdAt:k,updatedAt:k,reasoning:z.z.object({enabled:z.z.boolean().optional(),effort:z.z.custom().optional(),maxTokens:(0,g.zInt)().optional()}).nullish(),plugins:z.z.custom().nullish(),artifactId:z.z.string().optional(),internSessionId:z.z.string().optional()}),X=z.z.record(z.z.string(),J);J.omit({id:!0,samplingParameters:!0}).extend({id:z.z.string().optional(),samplingParameters:z.z.record(z.z.string(),(0,g.zDouble)()).optional()}),e.s(["CharactersMapSchema",0,X,"PlaygroundCharacterSchema",0,J],351344);var Z=e.i(968076),Q=e.i(504445);let Y=z.z.object({id:z.z.string(),type:z.z.custom(),outputIndex:(0,g.zInt)().optional(),sequenceIndex:(0,g.zInt)().optional()}),ee=z.z.object({id:z.z.string(),artifactId:z.z.string().optional(),parentMessageId:z.z.string().nullish(),context:z.z.enum(S).default(S.MainChat).optional(),contentType:z.z.enum(y).default(y.Text).optional(),versionContextId:z.z.string().optional(),characterId:z.z.string(),createdAt:k,updatedAt:k,isEdited:z.z.boolean().optional(),isRetrying:z.z.boolean().optional(),isCollapsed:z.z.boolean().optional()}),et=z.z.object({content:z.z.string().optional(),attachments:z.z.array(z.z.custom()).nullish()}),ea=z.z.object({type:z.z.enum(Z.AttachmentType),name:z.z.string(),size:(0,g.zInt)()}),en=z.z.object({image_config:z.z.record(z.z.string(),Q.ImageConfigValueSchema).optional(),modalities:z.z.array(z.z.enum(["text","image"])).optional()}).optional(),eo=ee.merge(et).extend({type:z.z.literal(v.User),items:z.z.array(Y).default([]),requestOverrides:en,attachmentMetadata:z.z.array(ea).optional()}),ei=z.z.object({content:z.z.string().optional(),reasoning:z.z.string().optional(),images:z.z.array(z.z.custom()).nullish(),citations:z.z.array(z.z.custom()).nullish(),files:z.z.array(z.z.custom()).nullish()}),er=ee.merge(ei).extend({type:z.z.literal(v.Assistant),artifactId:z.z.string().optional(),generatedArtifactType:z.z.enum(A).optional(),isGenerating:z.z.boolean().optional(),metadata:z.z.object({plugins:z.z.custom().nullish(),generateDuration:(0,g.zDouble)().optional(),latencyDuration:(0,g.zDouble)().optional(),reasoningDuration:(0,g.zDouble)().optional(),duration:(0,g.zDouble)().optional(),tokensCount:(0,g.zDouble)().optional(),tokensPerSecond:(0,g.zDouble)().optional(),variantSlug:z.z.string().optional(),internModel:z.z.string().optional(),provider:z.z.enum(H.ProviderName).nullish(),cost:z.z.string().optional(),generationId:z.z.string().optional(),serverTools:z.z.object({webSearchEngine:z.z.string().optional(),webFetchEngine:z.z.string().optional(),advisor:z.z.object({model:z.z.string().optional(),advisors:z.z.array(z.z.object({name:z.z.string().optional(),model:z.z.string().optional()})).optional()}).optional()}).passthrough().optional(),isFusionResponse:z.z.boolean().optional(),routerMetadata:z.z.custom().optional()}).passthrough().nullish(),items:z.z.array(Y).default([]),requestOverrides:en}),es=ee.extend({type:z.z.literal(v.System),items:z.z.array(Y).default([])}),el=z.z.discriminatedUnion("type",[eo,er,es]),ep=z.z.record(z.z.string(),el);e.s(["MessagesMapSchema",0,ep,"PlaygroundMessageSchema",0,el],442401);var ec=e.i(206210);let eu=z.z.object({reasoning:z.z.object({effort:z.z.enum(ec.ReasoningEffortValue).openapi({description:"Reasoning effort to apply from this point in the conversation onward",example:"low"})}).strict().openapi("ConfigurationUpdateReasoning",{description:"Reasoning settings applied from this point in the conversation onward",example:{effort:"low"}})}).strict().openapi("ConfigurationUpdate",{description:"Mid-conversation configuration update. Changes reasoning effort from this point onward without invalidating the prompt cache for the preceding turns.",example:{reasoning:{effort:"low"}}});e.s(["ReasoningConfigurationUpdateSchema",0,eu],808959)},798823,271048,883960,375250,379865,841441,717546,118154,562722,885686,110873,e=>{"use strict";var t,a=e.i(472708),n=e.i(351344),o=e.i(442401),i=e.i(723914),r=e.i(366699),s=e.i(808959),l=e.i(104852),p=e.i(720170),c=e.i(586404),u=e.i(707283),d=e.i(693697),m=e.i(204067),h=e.i(796805),g=e.i(60628),z=e.i(305904);let f=new Set(Object.values({...{Function:"function",...{...p.OpenAIResponsesWebSearchToolType},FileSearch:"file_search",ComputerUsePreview:"computer_use_preview",CodeInterpreter:"code_interpreter",Mcp:"mcp",ImageGeneration:"image_generation",LocalShell:"local_shell",Shell:"shell",ApplyPatch:"apply_patch",Custom:"custom",Namespace:"namespace"},...g.OpenRouterServerToolType})),y={Message:"message",FunctionCall:"function_call",CustomToolCall:"custom_tool_call",WebSearchCall:"web_search_call",ImageGenerationCall:"image_generation_call",ApplyPatchCall:"apply_patch_call",ShellCall:"shell_call",ShellCallOutput:"shell_call_output",Reasoning:"reasoning",CodeInterpreterCall:"code_interpreter_call",FunctionCallOutput:"function_call_output",CustomToolCallOutput:"custom_tool_call_output",LocalShellCall:"local_shell_call",LocalShellCallOutput:"local_shell_call_output",ShellCall:"shell_call",ShellCallOutput:"shell_call_output",ApplyPatchCall:"apply_patch_call",ApplyPatchCallOutput:"apply_patch_call_output",McpCall:"mcp_call",McpListTools:"mcp_list_tools",McpApprovalRequest:"mcp_approval_request",McpApprovalResponse:"mcp_approval_response",ItemReference:"item_reference",Compaction:"compaction",AdditionalTools:"additional_tools",ConfigurationUpdate:"configuration_update"},_={...y,AgentMessage:"agent_message",ContextCompaction:"context_compaction"};({...z.OpenAIResponsesServiceTier});let b=h.z.enum(z.OpenAIResponsesServiceTier).openapi("ServiceTier",{example:"default"}),I=h.z.enum(z.OpenAIResponsesTruncation).openapi("Truncation",{example:"auto"}),S=h.z.enum(i.RESPONSES_ITEM_STATUSES).openapi("ToolCallStatus",{example:"completed"}),v=[...S.options,"failed"],x=h.z.enum(v).openapi("FailableToolCallStatus",{example:"completed"}),w=h.z.enum(["in_progress","searching","completed","failed"]).openapi("WebSearchToolCallStatus",{example:"completed"}),A=h.z.enum(["in_progress","searching","completed","incomplete","failed"]).openapi("FileSearchToolCallStatus",{example:"completed"});e.s(["KNOWN_RESPONSES_TOOL_TYPES",0,f,"OpenAIResponsesInputType",0,y,"OpenAIResponsesServiceTierSchema",0,b,"OpenAIResponsesTruncationSchema",0,I,"OpenResponsesFailableToolCallStatusSchema",0,x,"OpenResponsesFileSearchStatusSchema",0,A,"OpenResponsesInputType",0,_,"OpenResponsesToolCallStatusSchema",0,S,"OpenResponsesWebSearchStatusSchema",0,w],271048);var O=e.i(723409);e.i(572952),e.i(562659),O.AdapterName.OpenAIResponsesAdapter,O.AdapterName.AzureOpenAIResponsesAdapter,O.AdapterName.InternalStreamOpenAIResponsesAdapter,O.AdapterName.InternalStreamAzureOpenAIResponsesAdapter,O.AdapterName.InternalStreamAmazonBedrockOpenAIResponsesAdapter,O.AdapterName.InternalStreamAmazonBedrockRuntimeOpenAIResponsesAdapter;let R=h.z.object({mode:h.z.literal("explicit")}).openapi("PromptCacheBreakpoint",{description:"Marks an explicit prompt-cache boundary on this content block (OpenAI-style). Everything through the block carrying this marker is part of the candidate cached prefix. Supported natively by OpenAI GPT-5.6 and newer; on providers that use Anthropic-style `cache_control`, OpenRouter converts the marker to that format automatically.",example:{mode:"explicit"}}),C=h.z.object({prompt_cache_breakpoint:R});(0,m.buildZodGuard)(C);let T=h.z.object({mode:h.z.literal("explicit"),ttl:h.z.string().nullish()}).openapi("PromptCacheOptions",{description:'Request-level prompt-cache controls. `mode: "explicit"` disables OpenAI-managed breakpoints so only blocks marked with `prompt_cache_breakpoint` are cached. Only supported by OpenAI GPT-5.6 and newer.',example:{mode:"explicit",ttl:"30m"}});h.z.object({prompt_cache_key:h.z.string().nullish(),prompt_cache_options:T.nullish()}),e.s(["OpenAIResponsesPromptCacheBreakpointSchema",0,R,"OpenAIResponsesPromptCacheOptionsSchema",0,T],883960);let j=h.z.object({type:h.z.literal("input_text"),text:h.z.string(),prompt_cache_breakpoint:R.nullish()}).openapi("InputText",{description:"Text input content item",example:{type:"input_text",text:"Hello, how can I help you?"}}),k=h.z.object({type:h.z.literal("input_image"),detail:h.z.enum(z.OpenAIResponsesImageDetail),image_url:h.z.string().nullish()}).openapi("InputImage",{description:"Image input content item",example:{type:"input_image",detail:"auto",image_url:"https://example.com/image.jpg"}}),M=h.z.object({type:h.z.literal("input_file"),file_id:h.z.string().nullish(),file_data:h.z.string().optional(),filename:h.z.string().optional(),file_url:h.z.string().optional()}).openapi("InputFile",{description:"File input content item",example:{type:"input_file",file_id:"file-abc123",filename:"document.pdf"}}),P=h.z.object({type:h.z.literal("input_audio"),input_audio:h.z.object({data:h.z.string(),format:h.z.enum(["mp3","wav"])})}).openapi("InputAudio",{description:"Audio input content item",example:{type:"input_audio",input_audio:{data:"SGVsbG8gV29ybGQ=",format:"mp3"}}}),E=h.z.object({type:h.z.literal("input_video"),video_url:h.z.string().openapi({description:"A base64 data URL or remote URL that resolves to a video file"}),processing:h.z.enum(["agentic","static"]).optional().openapi({description:"Video processing mode. `agentic` enables agentic video processing and `static` forces fixed-rate frame sampling on providers that support it (currently Google Gemini).",example:"agentic"})}).openapi("InputVideo",{description:"Video input content item",example:{type:"input_video",video_url:"https://example.com/video.mp4"}}),F=k.extend({detail:h.z.enum(z.OpenAIResponsesImageDetail).optional()}),q=h.z.discriminatedUnion("type",[j,k,M,P]),D=h.z.discriminatedUnion("type",[j,F,M,P,E]),W=h.z.discriminatedUnion("type",[j,F,M]),U=h.z.union([h.z.string(),h.z.array(W)]);e.s(["OpenAIResponsesResponseInputContentBaseSchema",0,q,"OpenAIResponsesResponseInputFileSchema",0,M,"OpenAIResponsesResponseInputImageSchema",0,k,"OpenAIResponsesResponseInputTextSchema",0,j,"OpenResponsesFunctionCallOutputSchema",0,U,"OpenResponsesResponseInputContentSchema",0,D,"OpenResponsesResponseInputImageSchema",0,F],375250),e.s([],379865);var L=e.i(80125),V=((t={}).Unknown="unknown",t.OpenAIResponsesV1="openai-responses-v1",t.AzureOpenAIResponsesV1="azure-openai-responses-v1",t.BedrockOpenAIResponsesV1="bedrock-openai-responses-v1",t.BedrockXAIResponsesV1="bedrock-xai-responses-v1",t.XAIResponsesV1="xai-responses-v1",t.MetaResponsesV1="meta-responses-v1",t.AnthropicClaudeV1="anthropic-claude-v1",t.GoogleGeminiV1="google-gemini-v1",t);let K=h.z.enum(V).openapi("ReasoningFormat",{example:"unknown"}),N=h.z.enum(["auto","concise","detailed"]).openapi("ReasoningSummaryVerbosity",{example:"auto"}),G=h.z.enum(L.CompletionRequestReasoningEffort).openapi("ReasoningEffort",{example:"medium"}),$=h.z.enum(L.CompletionRequestReasoningContext).openapi("ReasoningContext",{description:L.REASONING_CONTEXT_DESCRIPTION,example:"all_turns"}),B=h.z.enum(L.CompletionRequestReasoningMode).openapi("ReasoningMode",{description:"Selects the reasoning mode. `standard` is the default; `pro` engages deeper reasoning on models that support it, billed at standard token rates. Only supported by OpenAI GPT-5.6 and newer.",example:"standard"}),H=h.z.object({effort:G.nullish(),summary:N.nullish(),context:$.nullish(),mode:B.nullish()}).openapi("BaseReasoningConfig",{example:{effort:"medium",summary:"auto"}});H.extend({max_tokens:(0,m.zInt)().nullish(),enabled:h.z.boolean().nullish()}).openapi("ReasoningConfig",{description:"Configuration for reasoning mode in the response",example:{summary:"auto",enabled:!0}});let J=p.OpenAIResponsesOutputItemReasoningSchema.extend({id:h.z.string().optional(),content:h.z.array(p.OpenAIResponsesReasoningTextSchema).nullish(),signature:h.z.string().nullish(),format:K.nullish()}).openapi("ReasoningItem",{description:"Reasoning output item with signature and format extensions",example:{type:"reasoning",id:"reasoning-abc123",summary:[{type:"summary_text",text:"Step by step analysis"}]}});e.s(["OpenAIResponsesReasoningConfigSchema",0,H,"OpenResponsesReasoningSchema",0,J],841441);var X=e.i(394359);let Z=h.z.string().optional().openapi({description:"Slug of the advisor model to consult (any OpenRouter model). When omitted, the executor can choose it via the tool call's `model` argument; if neither is set, the model from the outer API request is used.",example:"~anthropic/claude-opus-latest"}),Q=h.z.string().optional().openapi({description:"System instructions for the advisor sub-agent. When omitted, the advisor responds with no system prompt of its own.",example:"You are a senior staff engineer. Give a focused, decisive plan."}),Y=h.z.boolean().optional().openapi({description:"When true, the full parent conversation is forwarded to the advisor so it sees the same context the executor does (and the tool-call `prompt`, if given, is appended as a final user turn). When false or omitted, the advisor receives only the `prompt` the executor passes in the tool call.",example:!1}),ee=h.z.boolean().optional().openapi({description:"When true, the advisor's advice streams incrementally as it is produced. In the Responses API this emits `response.output_text.delta` events targeting the advisor output item; the final `advice` field is still set on the completed item. Has no effect on the Chat Completions API (where the advice arrives only as the final tool result). When false or omitted, the advice arrives only as the final result.",example:!1}),et=(0,m.zInt)().min(1).optional().openapi({description:"Maximum number of output tokens (including reasoning) the advisor may produce. When omitted, the provider's default applies.",example:2048}),ea=h.z.object({effort:L.CompletionRequestReasoningEffortSchema.optional().openapi({description:"Reasoning effort level for the advisor call."}),max_tokens:(0,m.zInt)().min(1).optional().openapi({description:"Maximum number of reasoning tokens the advisor may use."})}).openapi("AdvisorReasoning",{description:"Reasoning configuration forwarded to the advisor call. Use this to control reasoning effort and token budget for models that support extended thinking.",example:{effort:"high"}}).optional(),en=(0,m.zDouble)().min(0).max(2).optional().openapi({description:"Sampling temperature forwarded to the advisor call. When omitted, the provider's default applies.",example:.7}),eo={name:h.z.string().trim().min(1).max(64).regex(/^[a-zA-Z0-9 _-]+$/).openapi({description:"Optional name for this advisor. The model sees one tool per named advisor (and one default for an unnamed entry). Names must be unique across advisor entries. Letters, digits, spaces, underscores, and dashes; trimmed; 1–64 chars.",example:"reviewer"}).optional(),...{model:Z,instructions:Q,forward_transcript:Y,stream:ee,max_completion_tokens:et,reasoning:ea,temperature:en}},ei=h.z.object(eo).openapi("AdvisorServerToolConfig",{description:"Configuration for one openrouter:advisor server tool entry.",example:{name:"reviewer",model:"~anthropic/claude-opus-latest"}}),er=h.z.object({prompt:h.z.string().optional(),advice:h.z.string()}),es=h.z.array(er);h.z.record(h.z.string(),es);let el=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterAdvisor),parameters:ei.optional()}).openapi("AdvisorServerTool_OpenRouter",{description:"OpenRouter built-in server tool: consults a higher-intelligence advisor model (any OpenRouter model) for guidance mid-generation and returns its response. Include multiple entries to offer several named advisors; at most one entry may omit `name` to act as the default advisor.",example:{type:"openrouter:advisor",parameters:{name:"reviewer",model:"~anthropic/claude-opus-latest"}}}),ep=h.z.enum(["create_file","update_file","delete_file"]),ec=h.z.enum(["auto","native","openrouter"]).optional().openapi("ApplyPatchEngineEnum",{description:'Which apply_patch engine to use. "auto" (default) uses native passthrough when the endpoint advertises native apply_patch support, otherwise falls back to OpenRouter\'s HITL validator. "native" forces native passthrough — when the endpoint does not support native, the request falls back to HITL. "openrouter" always runs the HITL validator. Native passthrough streams the diff incrementally via `apply_patch_call_operation_diff.delta` events; HITL buffers the diff for atomic delivery as a single delta.',example:"auto"}),eu=h.z.object({engine:ec}).openapi("ApplyPatchServerToolConfig",{description:"Configuration for the openrouter:apply_patch server tool",example:{engine:"auto"}});h.z.object({apiToolParams:eu}),h.z.object({type:ep,path:h.z.string().min(1),diff:h.z.string().optional()}),h.z.object({status:h.z.enum(["completed","failed"]),output:h.z.string()});let ed=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterApplyPatch),parameters:eu.optional()}).openapi("ApplyPatchServerTool_OpenRouter",{description:"OpenRouter built-in server tool: validates V4A diff patches for file operations (create, update, delete). Restricted to the Responses API.",example:{type:"openrouter:apply_patch"}});var em=e.i(139625);let eh=h.z.discriminatedUnion("type",[em.ContainerAutoEnvironmentSchema,em.ContainerReferenceEnvironmentSchema]).openapi("BashServerToolEnvironment",{description:"Execution environment for the bash server tool.",example:{type:"container_auto"}}),eg=h.z.enum(["auto","native","openrouter"]).optional().openapi("BashServerToolEngine",{description:'Which bash engine to use. "openrouter" runs commands server-side in the OpenRouter sandbox. "auto" (default) and "native" use native passthrough, returning the tool call to your application to run client-side; OpenRouter does not execute the commands.',example:"auto"}),ez=h.z.object({environment:eh.optional(),engine:eg}).openapi("BashServerToolConfig",{description:"Configuration for the openrouter:bash server tool",example:{environment:{type:"container_auto"}}}),ef=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterBash),parameters:ez.optional()}).openapi("BashServerTool",{description:"OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container",example:{type:"openrouter:bash",parameters:{environment:{type:"container_auto"}}}});var ey=e.i(621894);let e_=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterDatetime),parameters:ey.DatetimeApiRequestSchema.optional()}).openapi("DatetimeServerTool",{description:"OpenRouter built-in server tool: returns the current date and time",example:{type:"openrouter:datetime",parameters:{timezone:"America/New_York"}}}),eb=h.z.object({}).openapi("FilesServerToolConfig",{description:"Configuration for the openrouter:files server tool",example:{}}),eI=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterFiles),parameters:eb.optional()}).openapi("FilesServerTool",{description:"OpenRouter built-in server tool: read, write, edit, and list workspace files via the Files API. Requires an authenticated request; files come from the API key's workspace (or the default workspace for keys without one).",example:{type:"openrouter:files",parameters:{}}});var eS=e.i(732610),ev=e.i(500397);let ex=h.z.object({type:h.z.literal(eS.FUSION_TOOL_NAME),parameters:ev.FusionApiRequestSchema.optional()}).openapi("FusionServerTool_OpenRouter",{description:"OpenRouter built-in server tool: fans out the user prompt to a panel of analysis models, then asks an analyst model to summarize their collective output as structured JSON the outer model can synthesize from.",example:{type:eS.FUSION_TOOL_NAME,parameters:{analysis_models:["~anthropic/claude-opus-latest","~openai/gpt-sol-latest"]}}});var ew=e.i(493901);let eA=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterImageGeneration),parameters:ew.ImageGenerationApiRequestSchema.optional()}).openapi("ImageGenerationServerTool_OpenRouter",{description:"OpenRouter built-in server tool: generates images from text prompts using an image generation model",example:{type:"openrouter:image_generation",parameters:{model:"openai/gpt-5-image",quality:"high",size:"1024x1024"}}});var eO=e.i(904297),eR=e.i(856954);let eC=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterShell),parameters:eR.ShellApiRequestSchema.optional()}).openapi("ShellServerTool_OpenRouter",{description:"OpenRouter built-in server tool: runs shell commands server-side in a sandboxed container (a sandbox-backed clone of OpenAI's hosted shell tool)",example:{type:"openrouter:shell",parameters:{engine:"openrouter",environment:{type:"container_auto"}}}});var eT=e.i(472195);let ej=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterSubagent),parameters:eT.SubagentApiRequestSchema.optional()}).openapi("SubagentServerTool_OpenRouter",{description:"OpenRouter built-in server tool: delegates self-contained tasks to a smaller, cheaper, faster worker model (any OpenRouter model) mid-generation and returns its outcome. The worker may run as a sub-agent with its own tools.",example:{type:"openrouter:subagent",parameters:{model:"~anthropic/claude-haiku-latest"}}}),ek=h.z.object({max_results:(0,m.zInt)().min(1).max(g.TOOL_SEARCH_MAX_RESULTS_MAX).optional().openapi({description:`Maximum tools returned by one search. Defaults to ${g.TOOL_SEARCH_MAX_RESULTS_DEFAULT}.`,example:g.TOOL_SEARCH_MAX_RESULTS_DEFAULT})}).openapi("ToolSearchServerToolConfig",{description:"Configuration for the openrouter:tool_search server tool",example:{max_results:g.TOOL_SEARCH_MAX_RESULTS_DEFAULT}}),eM=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterToolSearch),parameters:ek.optional()}).openapi("ToolSearchServerTool",{description:"OpenRouter built-in server tool: finds tools marked `defer_loading` and makes them callable",example:{type:"openrouter:tool_search",parameters:{max_results:5}}});var eP=e.i(442712);let eE=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterWebFetch),parameters:eP.WebFetchApiRequestSchema.optional()}).openapi("WebFetchServerTool",{description:"OpenRouter built-in server tool: fetches full content from a URL (web page or PDF)",example:{type:"openrouter:web_fetch",parameters:{max_uses:10}}});var eF=e.i(319409);let eq=p.OpenAIResponsesSearchContextSizeSchema.openapi({description:"Size of the search context for web search tools",example:X.SearchContextSize.Medium}),eD=p.OpenAIResponsesWebSearchUserLocationSchema.openapi({description:"User location information for web search",example:{type:"approximate",city:"San Francisco",country:"USA",region:"California",timezone:"America/Los_Angeles"}}),eW="none",eU="auto",eL="required",eV="function",eK="allowed_tools",eN="file_search",eG="web_search_preview",e$="computer_use_preview",eB="web_search_preview_2025_03_11",eH="code_interpreter",eJ="apply_patch",eX="shell",eZ=h.z.object({type:h.z.literal(eV),name:h.z.string()}).openapi("ToolChoiceFunction",{description:"Force the model to call a specific function",example:{type:"function",name:"get_weather"}}).extend({}),eQ=h.z.object({type:h.z.literal(eK),mode:h.z.union([h.z.literal(eU),h.z.literal(eL)]),tools:h.z.array(h.z.record(h.z.string(),h.z.unknown()))}).openapi("OpenResponsesToolChoiceAllowed",{description:"Constrains the model to a pre-defined set of allowed tools",example:{type:"allowed_tools",mode:"auto",tools:[{type:"function",name:"get_weather"}]}}),eY=h.z.object({type:h.z.union([h.z.literal(eN),h.z.literal(eG),h.z.literal(eB),h.z.literal(e$),h.z.literal(eH)])}).extend({}).openapi("ToolChoiceTypes",{description:"Force the model to call a tool of a specific type",example:{type:"web_search_preview"}}),e0=h.z.object({type:h.z.literal(eJ)}).openapi("ToolChoiceApplyPatch",{description:"Force the model to call the apply_patch tool when executing a tool call.",example:{type:"apply_patch"}}),e2=h.z.object({type:h.z.literal(eX)}).openapi("ToolChoiceShell",{description:"Force the model to call the shell tool when executing a tool call.",example:{type:"shell"}});h.z.union([h.z.literal(eU),h.z.literal(eW),h.z.literal(eL),eY,eZ,eQ,e0,e2]).openapi("OpenResponsesToolChoice",{description:"Controls which tool the model should call",example:"auto"});let e3=h.z.boolean().optional().openapi({description:"Lets the model keep working after calling this tool instead of waiting for its output. The tool is still executed by the client; return the result in a later request as a `function_call_output` with the original `call_id`. Only honored by providers whose Responses API supports async tools; ignored elsewhere.",example:!0}),e1=h.z.object({type:h.z.literal(eV),name:h.z.string(),description:h.z.string().nullish(),strict:h.z.boolean().nullish(),parameters:h.z.record(h.z.string(),h.z.any()).nullable()}).openapi("FunctionTool",{description:"Function tool definition",example:{type:"function",name:"get_weather",description:"Get the current weather in a location",parameters:{type:"object",properties:{location:{type:"string",description:"The city and state"},unit:{type:"string",enum:["celsius","fahrenheit"]}},required:["location"]}}}).extend({defer_loading:h.z.boolean().optional().openapi({description:"Withhold this tool from the model until `openrouter:tool_search` finds it. Requires the tool search server tool; at least one tool must remain non-deferred.",example:!0}),async:e3}),e4=eD.required({type:!0}).nullish().openapi("Preview_WebSearchUserLocation",{example:{type:"approximate",city:"San Francisco",country:"USA",region:"California",timezone:"America/Los_Angeles"}}),e6=h.z.object({search_context_size:eq.optional(),user_location:e4}),e5=h.z.object({allowed_domains:h.z.array(h.z.string()).nullish(),excluded_domains:h.z.array(h.z.string()).nullish(),blocked_domains:h.z.array(h.z.string()).nullish()}).openapi("WebSearchDomainFilter",{example:{allowed_domains:["example.com"],excluded_domains:["spam.com"],blocked_domains:["spam.com"]}}),e8={engine:eF.WebSearchEngineSchema,mode:eF.WebSearchModeSchema,max_results:eF.WebSearchMaxResultsSchema,max_uses:eF.WebSearchMaxUsesSchema,filters:e5.nullish()},e9=h.z.object({type:h.z.literal(eG)}).extend(e6.shape).extend(e8).openapi("Preview_WebSearchServerTool",{description:"Web search preview tool configuration",example:{type:"web_search_preview"}}),e7=h.z.object({type:h.z.literal(eB)}).extend(e6.shape).extend(e8).openapi("Preview_20250311_WebSearchServerTool",{description:"Web search preview tool configuration (2025-03-11 version)",example:{type:"web_search_preview_2025_03_11"}}),te=h.z.object({filters:h.z.object({allowed_domains:h.z.array(h.z.string()).nullish(),blocked_domains:h.z.array(h.z.string()).nullish()}).nullish(),search_context_size:eq.optional(),user_location:eD.nullish()}),tt=h.z.object({type:h.z.literal("web_search")}).extend(te.shape).extend(e8).openapi("Legacy_WebSearchServerTool",{description:"Web search tool configuration",example:{type:"web_search",engine:"auto",filters:{allowed_domains:["example.com"]}}}),ta=h.z.object({type:h.z.literal("web_search_2025_08_26")}).extend(te.shape).extend(e8).openapi("WebSearchServerTool",{description:"Web search tool configuration (2025-08-26 version)",example:{type:"web_search_2025_08_26",engine:"auto",filters:{allowed_domains:["example.com"]}}}),tn=h.z.object({key:h.z.string(),type:h.z.enum(["eq","ne","gt","gte","lt","lte"]),value:h.z.union([h.z.string(),(0,m.zDouble)(),h.z.boolean(),h.z.array(h.z.union([h.z.string(),(0,m.zDouble)()]))])}),to=h.z.object({type:h.z.enum(["and","or"]),filters:h.z.array(h.z.record(h.z.string(),h.z.unknown()))}).openapi("CompoundFilter",{description:"A compound filter that combines multiple comparison or compound filters",example:{type:"and",filters:[{key:"author",type:"eq",value:"Alice"}]}}),ti=h.z.object({type:h.z.literal("file_search"),vector_store_ids:h.z.array(h.z.string()),filters:h.z.union([tn,to]).nullish(),max_num_results:(0,m.zInt)().min(1).max(50).optional(),ranking_options:h.z.object({ranker:h.z.enum(["auto","default-2024-11-15"]).optional(),score_threshold:(0,m.zDouble)().optional()}).optional()}).openapi("FileSearchServerTool",{description:"File search tool configuration",example:{type:"file_search",vector_store_ids:["vs_abc123"]}}),tr=h.z.object({type:h.z.literal("computer_use_preview"),display_height:(0,m.zInt)(),display_width:(0,m.zInt)(),environment:h.z.enum(["windows","mac","linux","ubuntu","browser"])}).openapi("ComputerUseServerTool",{description:"Computer use preview tool configuration",example:{type:"computer_use_preview",display_height:768,display_width:1024,environment:"linux"}}),ts=h.z.object({type:h.z.literal("code_interpreter"),container:h.z.union([h.z.string(),h.z.object({type:h.z.literal("auto"),file_ids:h.z.array(h.z.string()).optional(),memory_limit:h.z.enum(["1g","4g","16g","64g"]).nullish().openapi({enum:["1g","4g","16g","64g",null]})})])}).openapi("CodeInterpreterServerTool",{description:"Code interpreter tool configuration",example:{type:"code_interpreter",container:"auto"}}),tl=h.z.object({tool_names:h.z.array(h.z.string()).optional(),read_only:h.z.boolean().optional()}),tp=h.z.object({never:h.z.object({tool_names:h.z.array(h.z.string()).optional()}).optional(),always:h.z.object({tool_names:h.z.array(h.z.string()).optional()}).optional()}),tc=h.z.object({type:h.z.literal("mcp"),server_label:h.z.string(),allowed_tools:h.z.union([h.z.array(h.z.string()),tl]).nullish(),authorization:h.z.string().optional(),connector_id:h.z.enum(["connector_dropbox","connector_gmail","connector_googlecalendar","connector_googledrive","connector_microsoftteams","connector_outlookcalendar","connector_outlookemail","connector_sharepoint"]).optional(),headers:h.z.record(h.z.string(),h.z.string()).nullish(),require_approval:h.z.union([tp,h.z.literal("always"),h.z.literal("never")]).nullish(),server_description:h.z.string().optional(),server_url:h.z.string().optional()}).openapi("McpServerTool",{description:"MCP (Model Context Protocol) tool configuration",example:{type:"mcp",server_label:"my-server",server_url:"https://example.com/mcp"}}),tu=h.z.object({type:h.z.literal("image_generation"),background:h.z.enum(["transparent","opaque","auto"]).optional(),input_fidelity:h.z.enum(["high","low"]).nullish().openapi({enum:["high","low",null]}),input_image_mask:h.z.object({image_url:h.z.string().optional(),file_id:h.z.string().optional()}).optional(),model:h.z.string().optional(),moderation:h.z.enum(["auto","low"]).optional(),output_compression:(0,m.zInt)().optional(),output_format:h.z.enum(["png","webp","jpeg"]).optional(),partial_images:(0,m.zInt)().optional(),quality:h.z.enum(["low","medium","high","auto"]).optional(),size:h.z.string().optional()}).openapi("ImageGenerationServerTool",{description:"Image generation tool configuration",example:{type:"image_generation",quality:"high"}}),td=h.z.object({type:h.z.literal("local_shell")}).openapi("CodexLocalShellTool",{description:"Local shell tool configuration",example:{type:"local_shell"}}),tm=h.z.object({type:h.z.literal("shell")}).openapi("ShellServerTool",{description:"Shell tool configuration",example:{type:"shell"}}),th=h.z.object({type:h.z.literal("apply_patch")}).openapi("ApplyPatchServerTool",{description:"Apply patch tool configuration",example:{type:"apply_patch"}}),tg=h.z.object({type:h.z.literal("function"),name:h.z.string(),allowed_callers:h.z.array(h.z.enum(["direct","programmatic"])).nullish(),defer_loading:h.z.boolean().optional(),description:h.z.string().nullish(),output_schema:h.z.record(h.z.string(),h.z.unknown()).nullish(),parameters:h.z.record(h.z.string(),h.z.unknown()).nullish(),strict:h.z.boolean().nullish(),async:e3}).openapi("NamespaceFunctionTool",{description:"A function tool grouped inside a namespace tool",example:{type:"function",name:"spawn_agent"}}),tz=h.z.union([h.z.object({type:h.z.literal("text")}),h.z.object({type:h.z.literal("grammar"),definition:h.z.string(),syntax:h.z.enum(["lark","regex"])})]),tf=h.z.object({type:h.z.literal("custom"),name:h.z.string(),description:h.z.string().optional(),format:tz.optional(),async:e3}).openapi("CustomTool",{description:"Custom tool configuration",example:{type:"custom",name:"my_tool"}}),ty=h.z.object({type:h.z.literal("namespace"),name:h.z.string(),description:h.z.string(),tools:h.z.array(h.z.union([tg,tf]))}).openapi("NamespaceTool",{description:"Groups function/custom tools under a shared namespace",example:{type:"namespace",name:"multi_agent_v1",description:"Tools for spawning and managing sub-agents.",tools:[{type:"function",name:"spawn_agent"}]}}),t_=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterWebSearch),parameters:eF.WebSearchApiRequestSchema.optional()}).openapi("WebSearchServerTool_OpenRouter",{description:"OpenRouter built-in server tool: searches the web for current information",example:{type:g.OpenRouterServerToolType.OpenRouterWebSearch,parameters:{max_results:5}}}),tb=h.z.object({type:h.z.literal(g.OpenRouterServerToolType.OpenRouterSearchModels),parameters:eO.SearchModelsApiRequestSchema.optional()}).openapi("SearchModelsServerTool_OpenRouter",{description:"OpenRouter built-in server tool: searches and filters AI models available on OpenRouter",example:{type:g.OpenRouterServerToolType.OpenRouterSearchModels,parameters:{max_results:5}}}),tI=h.z.discriminatedUnion("type",[e1,e9,e7,tt,ta,ti,tr,ts,tc,tu,td,tm,th,tf,ty]),tS=h.z.object({type:h.z.string().refine(e=>!f.has(e),{message:"Tool type is explicitly modeled and must match its strict schema"})}).passthrough().transform(e=>({...e,__or_passthrough:!0})),tv=h.z.union([tI,el,ej,e_,eI,ex,eA,tb,eE,t_,ed,ef,eC,eM]),tx=h.z.union([tv,tS]);e.s(["OpenAIResponsesNativeToolUnionSchema",0,tI,"OpenAIResponsesToolUnionRuntimeSchema",0,tx],717546);let tw=h.z.discriminatedUnion("type",[p.OpenAIResponsesApplyPatchCreateFileOperationSchema,p.OpenAIResponsesApplyPatchUpdateFileOperationSchema,p.OpenAIResponsesApplyPatchDeleteFileOperationSchema]).openapi("ApplyPatchCallOperation",{description:"The patch operation requested by an `apply_patch_call`. `create_file` and `update_file` carry a V4A diff; `delete_file` omits it.",example:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}),tA=h.z.enum(["in_progress","completed"]).openapi("ApplyPatchCallStatus",{description:"Lifecycle state of an `apply_patch_call` output item.",example:"completed"}),tO=h.z.object({type:h.z.literal("apply_patch_call"),call_id:h.z.string(),status:tA,operation:tw,id:h.z.string().nullish()}).openapi("ApplyPatchCallItem",{description:"A tool call emitted by the model requesting a V4A patch operation. The client applies the patch and echoes an `apply_patch_call_output` on the next turn.",example:{type:"apply_patch_call",id:"apc_abc123",call_id:"call_abc123",status:"completed",operation:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}}),tR=h.z.object({type:h.z.literal("apply_patch_call_output"),call_id:h.z.string(),status:h.z.enum(["completed","failed"]),id:h.z.string().nullish(),output:h.z.string().nullish()}).openapi("ApplyPatchCallOutputItem",{description:"The client's echo of an `apply_patch_call` after applying the patch. `output` is an optional human-readable log; `status` is `completed` when the patch was applied successfully, `failed` otherwise.",example:{type:"apply_patch_call_output",call_id:"call_abc123",status:"completed",output:"Applied patch to /src/main.ts"}}),tC=h.z.array(h.z.looseObject({type:h.z.string()})),tT={subagent_id:h.z.string().optional().openapi({description:"EXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls."}),subagent_items:tC.optional().openapi({description:"EXPERIMENTAL — subject to change without notice. The subagent's output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool."})},tj=h.z.object({type:h.z.literal("function_call"),call_id:h.z.string(),name:h.z.string(),arguments:h.z.string(),id:h.z.string().optional(),status:S.optional(),namespace:h.z.string().optional().openapi({description:"Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)"}),async:p.AsyncToolCallFlagSchema,...tT}).openapi("OpenAIResponseFunctionToolCall",{example:{type:"function_call",call_id:"call-abc123",name:"get_weather",arguments:'{"location":"San Francisco"}',id:"fc-abc123",status:"completed"}}),tk=tj.extend({id:h.z.string()}).openapi("FunctionCallItem",{description:"A function call initiated by the model",example:{id:"call-abc123",type:"function_call",call_id:"call-abc123",name:"get_weather",arguments:'{"location":"San Francisco"}',status:"completed"}}),tM=h.z.discriminatedUnion("type",[j,k,M]),tP=h.z.object({type:h.z.literal("function_call_output"),id:h.z.string().nullish(),call_id:h.z.string(),output:h.z.union([h.z.string(),h.z.array(tM)]),status:S.nullish()}).openapi("OpenAIResponseFunctionToolCallOutput",{example:{type:"function_call_output",call_id:"call-abc123",output:'{"temperature":72,"conditions":"sunny"}'}}),tE=tP.extend({output:U}).openapi("FunctionCallOutputItem",{description:"The output from a function call execution",example:{type:"function_call_output",id:"output-abc123",call_id:"call-abc123",output:'{"temperature":72,"conditions":"sunny"}',status:"completed"}}),tF=h.z.object({type:h.z.literal("custom_tool_call"),call_id:h.z.string(),name:h.z.string(),input:h.z.string(),id:h.z.string().optional(),namespace:h.z.string().optional().openapi({description:"Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)"}),async:p.AsyncToolCallFlagSchema}).openapi("OpenAIResponseCustomToolCall",{example:{type:"custom_tool_call",call_id:"call-abc123",name:"apply_patch",input:"*** Begin Patch\n*** End Patch",id:"ctc-abc123"}}),tq=tF.extend({status:S.optional()}).openapi("CustomToolCallItem",{description:"A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.",example:{type:"custom_tool_call",call_id:"call-abc123",name:"apply_patch",input:"*** Begin Patch\n*** End Patch",id:"ctc-abc123"}}),tD=h.z.object({type:h.z.literal("custom_tool_call_output"),call_id:h.z.string(),output:h.z.union([h.z.string(),h.z.array(tM)]),id:h.z.string().optional()}).openapi("OpenAIResponseCustomToolCallOutput",{example:{type:"custom_tool_call_output",call_id:"call-abc123",output:"patch applied successfully"}}),tW=tD.extend({output:U}).openapi("CustomToolCallOutputItem",{description:"The output from a custom (freeform-grammar) tool call execution. Mirrors `function_call_output` but is matched to a `custom_tool_call` rather than a `function_call`.",example:{type:"custom_tool_call_output",id:"ctco-abc123",call_id:"call-abc123",output:"patch applied successfully"}}),tU=h.z.object({type:h.z.literal("mcp_protocol_error"),code:(0,m.zInt)(),message:h.z.string()}).openapi("McpProtocolError",{description:"The MCP server returned a protocol-level error",example:{type:"mcp_protocol_error",code:-32601,message:"Method not found"}}),tL=h.z.object({type:h.z.literal("mcp_tool_execution_error"),content:h.z.unknown()}).openapi("McpToolExecutionError",{description:"The MCP tool ran but reported a failure",example:{type:"mcp_tool_execution_error",content:"Connection refused"}}),tV=h.z.object({type:h.z.literal("http_error"),code:(0,m.zInt)(),message:h.z.string()}).openapi("McpHttpError",{description:"The MCP server request failed at the HTTP layer",example:{type:"http_error",code:503,message:"Service Unavailable"}}),tK=h.z.union([h.z.string(),h.z.discriminatedUnion("type",[tU,tL,tV]).openapi("McpToolCallErrorObject",{description:"Structured MCP tool-call error",example:{type:"http_error",code:503,message:"Service Unavailable"},discriminator:{propertyName:"type",mapping:{mcp_protocol_error:"#/components/schemas/McpProtocolError",mcp_tool_execution_error:"#/components/schemas/McpToolExecutionError",http_error:"#/components/schemas/McpHttpError"}}})]).openapi("McpToolCallError",{description:"Error from an MCP tool call, either a plain message or a structured error",example:{type:"http_error",code:503,message:"Service Unavailable"}}),tN=h.z.object({type:h.z.literal(y.McpListTools),id:h.z.string(),server_label:h.z.string(),tools:h.z.array(h.z.object({name:h.z.string(),description:h.z.string().nullish(),input_schema:h.z.record(h.z.string(),h.z.unknown()),annotations:h.z.unknown().nullish()})),error:h.z.string().nullish()}).openapi("McpListToolsItem",{description:"List of available MCP tools from a server",example:{type:"mcp_list_tools",id:"mcp-list-abc123",server_label:"database-server",tools:[{name:"query_database",description:"Execute a database query",input_schema:{type:"object",properties:{query:{type:"string"}}}}]}}),tG=h.z.object({type:h.z.literal(y.McpApprovalRequest),id:h.z.string(),name:h.z.string(),arguments:h.z.string(),server_label:h.z.string()}).openapi("McpApprovalRequestItem",{description:"Request for approval to execute an MCP tool",example:{type:"mcp_approval_request",id:"approval-abc123",name:"delete_record",arguments:'{"id":"123"}',server_label:"database-server"}}),t$=h.z.object({type:h.z.literal(y.McpApprovalResponse),id:h.z.string().nullish(),approval_request_id:h.z.string(),approve:h.z.boolean(),reason:h.z.string().nullish()}).openapi("McpApprovalResponseItem",{description:"User response to an MCP tool approval request",example:{type:"mcp_approval_response",approval_request_id:"approval-abc123",approve:!0,reason:"Approved for execution"}}),tB=h.z.object({type:h.z.literal(y.McpCall),id:h.z.string(),name:h.z.string(),arguments:h.z.string(),server_label:h.z.string(),output:h.z.string().nullish(),error:tK.nullish()}).openapi("McpCallItem",{description:"An MCP tool call with its output or error",example:{type:"mcp_call",id:"mcp-call-abc123",name:"query_database",arguments:'{"query":"SELECT * FROM users"}',server_label:"database-server",output:'[{"id":1,"name":"Alice"}]'}});var tH=e.i(704985);let tJ=h.z.object({type:h.z.literal(y.ShellCall),call_id:h.z.string(),action:h.z.object({commands:h.z.array(h.z.string()),max_output_length:h.z.number().int().nullish(),timeout_ms:h.z.number().int().nullish()}),id:h.z.string().nullish(),environment:h.z.unknown().nullish(),status:S.nullish(),arguments:h.z.string().nullish().openapi({description:"The raw tool-call arguments string as emitted by the model. Echo back unchanged when replaying history; used verbatim to preserve provider prompt-cache prefixes."})}).openapi("ShellCallItem",{description:"A shell command execution call (newer variant)",example:{type:"shell_call",call_id:"call-abc123",action:{commands:["ls","-la"],max_output_length:1e4},status:"completed"}}),tX=eR.ShellOutcomeSchema.options,tZ=h.z.discriminatedUnion("type",[tX[0].passthrough(),tX[1].passthrough()]),tQ=eR.ShellCommandOutputSchema.extend({outcome:tZ}).passthrough().openapi("ShellCallOutputContent",{description:"Captured stdout and stderr for one command of a shell call, with its exit or timeout outcome.",example:{stdout:"total 0\n",stderr:"",outcome:{type:"exit",exit_code:0}}});function tY(e){if("object"!=typeof e||null===e||"stdout"in e||"stderr"in e||"outcome"in e||!("type"in e)||"stdout"!==e.type&&"stderr"!==e.type)return e;let t="stderr"===e.type,a="content"in e&&"string"==typeof e.content?e.content:"",n="exit_code"in e&&"number"==typeof e.exit_code?e.exit_code:+!!t;return{stdout:t?"":a,stderr:t?a:"",outcome:{type:"exit",exit_code:n}}}let t0=h.z.object({}).passthrough(),t2=h.z.preprocess(tY,h.z.union([tQ,t0])),t3={files:h.z.array(tH.ContainerFileCitationSchema).optional().openapi({description:"Citations for the files the sandbox command created or modified, most-recently-touched first (at most 10). Retrieve them via the Container Files API."}),container_id:h.z.string().optional().openapi({description:"The canonical container id the command ran under — the `{container_id}` for the Container Files API, reusable as a `container_reference` in later requests. Present on every sandbox-executed call, even when no files changed."})},t1=h.z.object({type:h.z.literal(y.ShellCallOutput),call_id:h.z.string(),output:h.z.array(h.z.preprocess(tY,tQ)),id:h.z.string().nullish(),max_output_length:h.z.number().int().nullish(),status:S.nullish(),...t3}).openapi("ShellCallOutputItem",{description:"Output from a shell command execution (newer variant)",example:{type:"shell_call_output",call_id:"call-abc123",output:[{stdout:"total 0\n",stderr:"",outcome:{type:"exit",exit_code:0}}],status:"completed"}}),t4=t1.extend({output:h.z.array(t2)}),t6=h.z.object({type:h.z.literal(y.ItemReference),id:h.z.string()}).openapi("ItemReferenceItem",{description:"A reference to a previous response item by ID",example:{type:"item_reference",id:"msg-abc123"}}),t5=h.z.object({type:h.z.literal(y.Compaction),encrypted_content:h.z.string(),id:h.z.string().nullish()}).passthrough().openapi("CompactionItem",{description:"A context compaction marker with encrypted summary",example:{type:"compaction",encrypted_content:"enc_abc123..."}}),t8=h.z.object({type:h.z.literal(_.ContextCompaction),encrypted_content:h.z.string().nullish(),id:h.z.string().nullish()}).passthrough().openapi("ContextCompactionItem",{description:"A context compaction marker with an optional encrypted summary",example:{type:"context_compaction",encrypted_content:"enc_abc123..."}}),t9=h.z.object({type:h.z.literal(y.LocalShellCall),id:h.z.string(),call_id:h.z.string(),action:h.z.object({type:h.z.literal("exec"),command:h.z.array(h.z.string()),env:h.z.record(h.z.string(),h.z.string()),timeout_ms:(0,m.zInt)().nullish(),user:h.z.string().nullish(),working_directory:h.z.string().nullish()}),status:S}).openapi("LocalShellCallItem",{description:"A local shell command execution call",example:{type:"local_shell_call",id:"shell-abc123",call_id:"call-abc123",action:{type:"exec",command:["ls","-la"],env:{PATH:"/usr/bin"},timeout_ms:5e3},status:"completed"}}),t7=h.z.object({type:h.z.literal(y.LocalShellCallOutput),id:h.z.string(),output:h.z.string(),status:S.nullish()}).openapi("LocalShellCallOutputItem",{description:"Output from a local shell command execution",example:{type:"local_shell_call_output",id:"output-abc123",output:"total 24\ndrwxr-xr-x 5 user staff 160 Jan 1 12:00 .",status:"completed"}}),ae=p.OpenAIResponsesCodeInterpreterCallOutputSchema.extend({}).openapi("CodeInterpreterCallItem",{description:"A code interpreter execution call with outputs",example:{type:"code_interpreter_call",id:"code-abc123",code:'print("Hello, World!")',outputs:[{type:"logs",logs:"Hello, World!"}],status:"completed",container_id:"container-xyz789"}}),at=h.z.object({type:h.z.literal("url"),url:h.z.string()}).openapi("WebSearchSource",{example:{type:"url",url:"https://example.com/article"}}),aa=h.z.object({type:h.z.literal("search"),query:h.z.string(),queries:h.z.array(h.z.string()).optional(),sources:h.z.array(at).optional()}),an=h.z.object({type:h.z.literal("open_page"),url:h.z.string().nullish()}),ao=h.z.object({type:h.z.literal("find_in_page"),pattern:h.z.string(),url:h.z.string()});h.z.object({type:h.z.literal("web_search_call"),id:h.z.string(),action:h.z.discriminatedUnion("type",[aa,an,ao]),status:w}).openapi("WebSearchCallItem",{description:"A web search tool call",example:{type:"web_search_call",id:"search-abc123",action:{type:"search",query:"OpenAI API"},status:"completed"}}),h.z.object({type:h.z.literal("file_search_call"),id:h.z.string(),results:h.z.array(h.z.object({file_id:h.z.string(),filename:h.z.string(),score:(0,m.zDouble)(),content:h.z.string()})).nullish(),status:A,queries:h.z.array(h.z.string())}).openapi("FileSearchCallItem",{description:"A file search tool call with results",example:{type:"file_search_call",id:"file-search-abc123",results:[{file_id:"file-xyz789",filename:"document.pdf",score:.95,content:"Relevant content excerpt..."}],status:"completed",queries:["search term"]}});let ai=p.OpenAIResponsesOutputMessageSchema.extend({id:h.z.string().optional()}).openapi("OutputMessageItem",{description:"An output message item",example:{id:"msg-123",type:"message",role:"assistant",status:"completed",content:[{type:"output_text",text:"Hello! How can I help you?",annotations:[]}]}}),ar=p.OpenAIResponsesOutputItemReasoningSchema.extend({id:h.z.string().optional(),content:h.z.array(p.OpenAIResponsesReasoningTextSchema).nullish(),signature:h.z.string().nullish().openapi({description:"A signature for the reasoning content, used for verification",example:"EvcBCkgIChABGAIqQKkSDbRuVEQUk9qN1odC098l9SEj..."}),format:K.nullish()}).openapi("OutputReasoningItem",{description:"An output item containing reasoning",example:{id:"reasoning-123",type:"reasoning",status:"completed",summary:[{type:"summary_text",text:"Analyzed the problem and found the optimal solution."}],content:[{type:"reasoning_text",text:"First, we analyze the problem..."}],signature:"EvcBCkgIChABGAIqQKkSDbRuVEQUk9qN1odC098l9SEj...",format:"anthropic-claude-v1"}}),as=p.OpenAIResponsesOutputItemFunctionCallSchema.extend({id:h.z.string().optional(),...tT}).openapi("OutputFunctionCallItem",{example:{id:"fc-abc123",type:"function_call",call_id:"call-abc123",name:"get_weather",arguments:'{"location":"San Francisco"}',status:"completed"}}),al=p.OpenAIResponsesOutputItemCustomToolCallSchema.openapi("OutputCustomToolCallItem",{description:"A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments.",example:{id:"ctc-abc123",type:"custom_tool_call",call_id:"call-abc123",name:"apply_patch",input:"*** Begin Patch\n*** End Patch",status:"completed"}}),ap=p.OpenAIResponsesOutputItemFileSearchCallSchema.extend({id:h.z.string().optional()}).openapi("OutputFileSearchCallItem",{example:{id:"fs-abc123",type:"file_search_call",status:"completed",queries:["search term"],results:[]}}),ac=p.OpenAIResponsesWebSearchCallOutputSchema.extend({id:h.z.string().optional()}).openapi("OutputWebSearchCallItem",{example:{id:"ws-abc123",type:"web_search_call",status:"completed"}}),au=l.OpenAIResponsesImageGenerationCallSchema.extend({id:h.z.string().optional(),prompt:h.z.string().optional().openapi({description:"The prompt (possibly rewritten) that the image was generated from."})}).openapi("OutputImageGenerationCallItem",{example:{id:"img-abc123",type:"image_generation_call",status:"completed",result:null}}),ad=ae.extend({id:h.z.string().optional()}).openapi("OutputCodeInterpreterCallItem",{example:{id:"ci-abc123",type:"code_interpreter_call",code:'print("hello")',outputs:[{type:"logs",logs:"hello\n"}],status:"completed",container_id:"ctr-xyz789"}}),am=p.OpenAIResponsesOutputItemComputerCallSchema.extend({id:h.z.string().optional()}).openapi("OutputComputerCallItem",{example:{id:"cu-abc123",type:"computer_call",call_id:"call-abc123",status:"completed",action:{type:"screenshot"},pending_safety_checks:[]}}),ah=h.z.object({id:h.z.string().optional(),status:S}),ag=ah.extend({type:h.z.literal("openrouter:datetime"),datetime:h.z.string().openapi({description:"ISO 8601 datetime string"}),timezone:h.z.string().openapi({description:"IANA timezone name"})}).openapi("OutputDatetimeItem",{description:"An openrouter:datetime server tool output item",example:{type:"openrouter:datetime",id:"dt_tmp_abc123",status:"completed",datetime:"2026-03-12T14:30:00.000Z",timezone:"UTC"}}),az=h.z.object({type:h.z.literal("search"),query:h.z.string(),sources:h.z.array(h.z.object({type:h.z.literal("url"),url:h.z.string()})).optional()}),af=ah.extend({type:h.z.literal("openrouter:web_search"),action:az.optional().openapi({description:"The search action performed, matching OpenAI web_search_call.action shape. Includes the query the model issued and optional source URLs returned by the search provider."})}).openapi("OutputWebSearchServerToolItem",{description:"An openrouter:web_search server tool output item",example:{type:"openrouter:web_search",id:"ws_tmp_abc123",status:"completed",action:{type:"search",query:"latest AI news"}}}),ay=ah.extend({type:h.z.literal("openrouter:code_interpreter"),language:h.z.string().optional(),code:h.z.string().optional(),stdout:h.z.string().optional(),stderr:h.z.string().optional(),exitCode:(0,m.zInt)().optional()}).openapi("OutputCodeInterpreterServerToolItem",{description:"An openrouter:code_interpreter server tool output item",example:{type:"openrouter:code_interpreter",id:"ci_tmp_abc123",status:"completed",language:"python",code:'print("hello")',stdout:"hello\n"}}),a_=ah.extend({type:h.z.literal("openrouter:file_search"),queries:h.z.array(h.z.string()).optional()}).openapi("OutputFileSearchServerToolItem",{description:"An openrouter:file_search server tool output item",example:{type:"openrouter:file_search",id:"fs_tmp_abc123",status:"completed",queries:["search term"]}}),ab=ah.extend({type:h.z.literal("openrouter:image_generation"),result:h.z.string().nullish().openapi({description:"The generated image as a base64-encoded string or URL, matching OpenAI image_generation_call format"}),imageUrl:h.z.string().optional(),imageB64:h.z.string().optional(),prompt:h.z.string().optional().openapi({description:"The prompt (possibly rewritten) that the image was generated from."}),revisedPrompt:h.z.string().optional()}).openapi("OutputImageGenerationServerToolItem",{description:"An openrouter:image_generation server tool output item",example:{type:"openrouter:image_generation",id:"ig_tmp_abc123",status:"completed",result:"https://example.com/image.png",imageUrl:"https://example.com/image.png"}}),aI=ah.extend({type:h.z.literal("openrouter:browser_use"),action:h.z.string().optional(),screenshotB64:h.z.string().optional()}).openapi("OutputBrowserUseServerToolItem",{description:"An openrouter:browser_use server tool output item",example:{type:"openrouter:browser_use",id:"bu_tmp_abc123",status:"completed",action:"screenshot"}}),aS=ah.extend({type:h.z.literal("openrouter:bash"),command:h.z.string().optional(),stdout:h.z.string().optional(),stderr:h.z.string().optional(),exitCode:(0,m.zInt)().optional(),...t3,call_id:h.z.string().nullish().openapi({description:"The model-generated tool call id from the originating turn."}),arguments:h.z.string().nullish().openapi({description:"The raw tool-call arguments string as emitted by the model."})}).openapi("OutputBashServerToolItem",{description:"An openrouter:bash server tool output item",example:{type:"openrouter:bash",id:"bash_tmp_abc123",status:"completed",command:"ls -la",stdout:"total 0\n",exitCode:0}}),av=ah.extend({type:h.z.literal("openrouter:shell"),action:h.z.object({commands:h.z.array(h.z.string()),max_output_length:(0,m.zInt)().nullish(),timeout_ms:(0,m.zInt)().nullish()}).optional(),output:h.z.array(tQ).optional(),...t3,call_id:h.z.string().nullish().openapi({description:"The model-generated tool call id from the originating turn."}),arguments:h.z.string().nullish().openapi({description:"The raw tool-call arguments string as emitted by the model."})}).openapi("OutputShellServerToolItem",{description:"An openrouter:shell server tool output item",example:{type:"openrouter:shell",id:"st_tmp_abc123",status:"completed",call_id:"call_abc123",action:{commands:["echo hello"],max_output_length:null,timeout_ms:null},output:[{stdout:"hello\n",stderr:"",outcome:{type:"exit",exit_code:0}}]}}),ax=ah.extend({type:h.z.literal("openrouter:text_editor"),command:h.z.enum(["view","create","str_replace","insert"]).optional(),filePath:h.z.string().optional()}).openapi("OutputTextEditorServerToolItem",{description:"An openrouter:text_editor server tool output item",example:{type:"openrouter:text_editor",id:"te_tmp_abc123",status:"completed",command:"view",filePath:"/src/main.ts"}}),aw=ah.extend({type:h.z.literal("openrouter:apply_patch"),call_id:h.z.string().optional(),operation:tw.optional()}).openapi("OutputApplyPatchServerToolItem",{description:"An openrouter:apply_patch server tool output item. The turn halts when validation succeeds so the client can apply the patch and echo an `apply_patch_call_output` on the next turn.",example:{type:"openrouter:apply_patch",id:"apc_abc123",call_id:"call_abc123",status:"completed",operation:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}}),aA=h.z.object({type:h.z.literal("apply_patch_call"),id:h.z.string(),call_id:h.z.string(),status:tA,operation:tw}).openapi("OutputApplyPatchCallItem",{description:"A native `apply_patch_call` output item matching OpenAI's Responses API shape. Emitted when the client requested the `apply_patch` shorthand.",example:{type:"apply_patch_call",id:"apc_abc123",call_id:"call_abc123",status:"completed",operation:{type:"update_file",path:"/src/main.ts",diff:'@@ function main() {\n+ console.log("hi");\n }'}}}),aO=h.z.enum(i.RESPONSES_ITEM_STATUSES).openapi("ShellCallStatus",{description:"Status of a shell call or its output.",example:"completed"}),aR=h.z.object({type:h.z.literal("shell_call"),id:h.z.string(),call_id:h.z.string(),status:aO,action:h.z.object({commands:h.z.array(h.z.string()),max_output_length:(0,m.zInt)().nullable(),timeout_ms:(0,m.zInt)().nullable()}).optional(),arguments:h.z.string().nullish().openapi({description:"The raw tool-call arguments string as emitted by the model. Echo back unchanged when replaying history; used verbatim to preserve provider prompt-cache prefixes."})}).openapi("OutputShellCallItem",{description:"A native `shell_call` output item matching OpenAI's Responses API shape. Emitted for the sandbox-backed `shell` tool.",example:{type:"shell_call",id:"shc_abc123",call_id:"call_abc123",status:"completed",action:{commands:["echo hello"],max_output_length:null,timeout_ms:null}}}),aC=h.z.object({type:h.z.literal("shell_call_output"),id:h.z.string(),call_id:h.z.string(),status:aO,max_output_length:(0,m.zInt)().nullish(),output:h.z.array(tQ),...t3}).openapi("OutputShellCallOutputItem",{description:"A native `shell_call_output` item matching OpenAI's Responses API shape. Carries per-command stdout, stderr, and the exit/timeout outcome.",example:{type:"shell_call_output",id:"sho_abc123",call_id:"call_abc123",status:"completed",output:[{stdout:"hello\n",stderr:"",outcome:{type:"exit",exit_code:0}}]}}),aT=ah.extend({type:h.z.literal("openrouter:web_fetch"),url:h.z.string().optional(),content:h.z.string().optional(),title:h.z.string().optional(),httpStatus:h.z.number().int().optional().openapi({description:"The HTTP status code returned by the upstream URL fetch."}),error:h.z.string().optional().openapi({description:"The error message if the fetch failed."})}).openapi("OutputWebFetchServerToolItem",{description:"An openrouter:web_fetch server tool output item",example:{type:"openrouter:web_fetch",id:"wf_tmp_abc123",status:"completed",url:"https://example.com",title:"Example Domain",httpStatus:200}}),aj=ah.extend({type:h.z.literal("openrouter:tool_search"),query:h.z.string().optional()}).openapi("OutputToolSearchServerToolItem",{description:"An openrouter:tool_search server tool output item",example:{type:"openrouter:tool_search",id:"ts_tmp_abc123",status:"completed",query:"weather tools"}}),ak=ah.extend({type:h.z.literal("openrouter:memory"),action:h.z.enum(["read","write","delete"]).optional(),key:h.z.string().optional(),value:h.z.unknown().optional()}).openapi("OutputMemoryServerToolItem",{description:"An openrouter:memory server tool output item",example:{type:"openrouter:memory",id:"mem_tmp_abc123",status:"completed",action:"read",key:"user_preference"}}),aM=ah.extend({type:h.z.literal("openrouter:mcp"),serverLabel:h.z.string().optional(),toolName:h.z.string().optional()}).openapi("OutputMcpServerToolItem",{description:"An openrouter:mcp server tool output item",example:{type:"openrouter:mcp",id:"mcp_tmp_abc123",status:"completed",serverLabel:"my-server",toolName:"get_data"}}),aP=ah.extend({type:h.z.literal("openrouter:experimental__search_models"),query:h.z.string().optional(),arguments:h.z.string().optional().openapi({description:'The JSON arguments submitted to the search tool (e.g. {"query":"Claude"})'})}).openapi("OutputSearchModelsServerToolItem",{description:"An openrouter:experimental__search_models server tool output item",example:{type:"openrouter:experimental__search_models",id:"sm_tmp_abc123",status:"completed",query:"Claude Opus",arguments:'{"query":"Claude Opus"}'}}),aE=ah.extend({type:h.z.literal("openrouter:fusion"),error:h.z.string().optional().openapi({description:"Error message when the fusion run did not produce an analysis result."}),failure_reason:h.z.string().optional().openapi({description:"Typed failure reason when the fusion run failed. Possible values include: all_panels_failed, insufficient_credits, rate_limited, invalid_model, judge_not_valid_json, judge_schema_mismatch, judge_upstream_error, judge_empty_completion. The four analysis-stage codes keep their pre-rename `judge_` spelling so existing consumers keep matching. The consumer-cancellation code is `cancelled`."}),responses:h.z.array(h.z.object({model:h.z.string(),content:h.z.string().optional()})).optional().openapi({description:"Analysis models that produced a response in this fusion run, with each model's full panel content."}),analysis:ev.analysisResultSchema.optional(),failed_models:h.z.array(ev.FailedModelSchema).optional().openapi({description:"Models that were requested as part of the analysis panel but did not produce a response. Present when at least one requested analysis model failed. The fusion result is still usable but was produced from a degraded panel."}),sources:h.z.array(ev.FusionSourceSchema).optional().openapi({description:"Web pages the analysis panels and analyst retrieved via web search during this fusion run, deduplicated by URL across the whole run. Present when at least one model cited a source."})}).openapi("OutputFusionServerToolItem",{description:"An openrouter:fusion server tool output item",example:{type:"openrouter:fusion",id:"st_tmp_abc123",status:"completed"}}),aF=ah.extend({type:h.z.literal("openrouter:advisor"),status:x,model:h.z.string().optional().openapi({description:"Slug of the advisor model that was consulted."}),prompt:h.z.string().optional().openapi({description:"The prompt the executor sent to the advisor."}),advice:h.z.string().optional().openapi({description:"The advisor model's response (the advice text returned to the executor)."}),error:h.z.string().optional().openapi({description:"Error message when the advisor call did not produce advice. Set together with `status: 'failed'` on the terminal item."}),instance_name:h.z.string().optional().openapi({description:"Provider-safe function name of the specific advisor instance that produced this item (e.g. `openrouter_advisor__1`). Present only when more than one advisor tool is configured; omitted for the default single advisor. Echo this field back unchanged so the advisor's cross-request memory stays namespaced to the correct instance. This identity is positional: it is derived from the index of the advisor entry in the request `tools` array, so clients must keep the order of advisor tool entries stable across requests in a conversation. Reordering or inserting advisor entries shifts these names and causes each advisor's cross-request memory to be attributed to the wrong instance.",example:"openrouter_advisor__1"})}).openapi("OutputAdvisorServerToolItem",{description:"An openrouter:advisor server tool output item",example:{type:"openrouter:advisor",id:"st_tmp_abc123",status:"completed"}}),aq=ah.extend({type:h.z.literal("openrouter:subagent"),status:x,model:h.z.string().optional().openapi({description:"Slug of the worker model that executed the task."}),name:h.z.string().optional().openapi({description:"Configured name of the subagent that executed the task (the `name` on its tool entry). Present only for named subagents; omitted for an unnamed (default) subagent.",example:"summarizer"}),instance_name:h.z.string().optional().openapi({description:"Provider-safe function name of the specific subagent instance that produced this item (e.g. `openrouter_subagent__1`). Present only on items from non-default instances — the second and later subagent entries in the request `tools` array. The first (default) instance omits it, even when multiple subagents are configured. When a replayed item echoes this field back, the transcript rehydrates the call under that instance's tool. This identity is positional: it is derived from the index of the subagent entry in the request `tools` array, so keep the order of subagent entries stable across requests in a conversation.",example:"openrouter_subagent__1"}),call_id:h.z.string().optional().openapi({description:"EXPERIMENTAL — subject to change without notice. The `call_id` of the tool call that spawned this subagent. This id will also be included as the `subagent_id` on any `function_call` items created by the subagent. This must be returned in the request so the `function_call` can be matched with the correct subagent. A suspended `in_progress` item is announced once and never re-emitted or terminally closed — completion arrives as a new item with the same `call_id`."}),task_name:h.z.string().optional().openapi({description:"The short task identifier the delegating model supplied."}),task_description:h.z.string().optional().openapi({description:"The task description the delegating model sent to the worker."}),outcome:h.z.string().optional().openapi({description:"The worker model's result (the outcome text returned to the delegating model)."}),error:h.z.string().optional().openapi({description:"Error message when the subagent task did not produce an outcome. Set together with `status: 'failed'` on the terminal item."})}).openapi("OutputSubagentServerToolItem",{description:"An openrouter:subagent server tool output item",example:{type:"openrouter:subagent",id:"st_tmp_abc123",status:"completed"}}),aD=ah.extend({type:h.z.literal("openrouter:files"),operation:h.z.string().optional().openapi({description:"The file operation performed (list, read, write, or edit)."}),file_id:h.z.string().optional().openapi({description:"The target file id supplied in the tool-call arguments."}),filename:h.z.string().optional().openapi({description:"The target filename supplied in the tool-call arguments."}),result:h.z.string().optional().openapi({description:"JSON-serialized result of the file operation."}),error:h.z.string().optional().openapi({description:"Error message when the file operation failed."}),call_id:h.z.string().nullish().openapi({description:"The model-generated tool call id from the originating turn."}),arguments:h.z.string().nullish().openapi({description:"The raw tool-call arguments string as emitted by the model."})}).openapi("OutputFilesServerToolItem",{description:"An openrouter:files server tool output item",example:{type:"openrouter:files",id:"fl_tmp_abc123",status:"completed",operation:"read",filename:"notes.txt",result:'{"id":"file_abc","filename":"notes.txt","content":"hello"}'}}),aW=h.z.discriminatedUnion("type",[ai,ar,as,ac,ap,au,ad,am,ag,af,ay,a_,ab,aI,aS,ax,aw,aA,aR,aC,av,aT,aj,ak,aM,aP,aE,aF,aq,aD,al]).openapi("OutputItems",{discriminator:{propertyName:"type",mapping:{message:"#/components/schemas/OutputMessageItem",reasoning:"#/components/schemas/OutputReasoningItem",function_call:"#/components/schemas/OutputFunctionCallItem",custom_tool_call:"#/components/schemas/OutputCustomToolCallItem",web_search_call:"#/components/schemas/OutputWebSearchCallItem",file_search_call:"#/components/schemas/OutputFileSearchCallItem",image_generation_call:"#/components/schemas/OutputImageGenerationCallItem",code_interpreter_call:"#/components/schemas/OutputCodeInterpreterCallItem",computer_call:"#/components/schemas/OutputComputerCallItem","openrouter:datetime":"#/components/schemas/OutputDatetimeItem","openrouter:web_search":"#/components/schemas/OutputWebSearchServerToolItem","openrouter:code_interpreter":"#/components/schemas/OutputCodeInterpreterServerToolItem","openrouter:file_search":"#/components/schemas/OutputFileSearchServerToolItem","openrouter:image_generation":"#/components/schemas/OutputImageGenerationServerToolItem","openrouter:browser_use":"#/components/schemas/OutputBrowserUseServerToolItem","openrouter:bash":"#/components/schemas/OutputBashServerToolItem","openrouter:text_editor":"#/components/schemas/OutputTextEditorServerToolItem","openrouter:apply_patch":"#/components/schemas/OutputApplyPatchServerToolItem",apply_patch_call:"#/components/schemas/OutputApplyPatchCallItem",shell_call:"#/components/schemas/OutputShellCallItem",shell_call_output:"#/components/schemas/OutputShellCallOutputItem","openrouter:shell":"#/components/schemas/OutputShellServerToolItem","openrouter:web_fetch":"#/components/schemas/OutputWebFetchServerToolItem","openrouter:tool_search":"#/components/schemas/OutputToolSearchServerToolItem","openrouter:memory":"#/components/schemas/OutputMemoryServerToolItem","openrouter:mcp":"#/components/schemas/OutputMcpServerToolItem","openrouter:experimental__search_models":"#/components/schemas/OutputSearchModelsServerToolItem","openrouter:fusion":"#/components/schemas/OutputFusionServerToolItem","openrouter:advisor":"#/components/schemas/OutputAdvisorServerToolItem","openrouter:subagent":"#/components/schemas/OutputSubagentServerToolItem","openrouter:files":"#/components/schemas/OutputFilesServerToolItem"}},description:"An output item from the response",example:{id:"msg-abc123",role:"assistant",type:"message",status:"completed",content:[{type:"output_text",text:"Hello! How can I help you today?"}]}});e.s(["OpenResponsesAdvisorOutputSchema",0,aF,"OpenResponsesApplyPatchOutputSchema",0,aw,"OpenResponsesBashOutputSchema",0,aS,"OpenResponsesBrowserUseOutputSchema",0,aI,"OpenResponsesCodeInterpreterCallSchema",0,ad,"OpenResponsesCodeInterpreterOutputSchema",0,ay,"OpenResponsesComputerCallSchema",0,am,"OpenResponsesDatetimeOutputSchema",0,ag,"OpenResponsesFileSearchOutputSchema",0,a_,"OpenResponsesFilesOutputSchema",0,aD,"OpenResponsesFusionOutputSchema",0,aE,"OpenResponsesImageGenerationCallSchema",0,au,"OpenResponsesImageGenerationOutputSchema",0,ab,"OpenResponsesMcpOutputSchema",0,aM,"OpenResponsesMemoryOutputSchema",0,ak,"OpenResponsesOutputItemCustomToolCallSchema",0,al,"OpenResponsesOutputItemFileSearchCallSchema",0,ap,"OpenResponsesOutputItemFunctionCallSchema",0,as,"OpenResponsesOutputItemReasoningSchema",0,ar,"OpenResponsesOutputItemSchema",0,aW,"OpenResponsesOutputMessageSchema",0,ai,"OpenResponsesSearchModelsOutputSchema",0,aP,"OpenResponsesShellOutputSchema",0,av,"OpenResponsesSubagentOutputSchema",0,aq,"OpenResponsesTextEditorOutputSchema",0,ax,"OpenResponsesToolSearchOutputSchema",0,aj,"OpenResponsesWebFetchOutputSchema",0,aT,"OpenResponsesWebSearchCallOutputSchema",0,ac,"OpenResponsesWebSearchOutputSchema",0,af],118154);let aU=tP.extend({call_id:h.z.undefined().optional(),name:h.z.string().min(1),namespace:h.z.string().min(1).optional(),output:h.z.string()}).transform(({name:e,namespace:t,output:a})=>({type:"message",role:"user",content:`Tool notification from ${t?`${t}.`:""}${e}: ${a}`})),aL=h.z.union([h.z.literal("commentary"),h.z.literal("final_answer")]);(0,m.buildZodGuard)(aL);let aV=h.z.object({type:h.z.literal(y.Message).optional(),role:h.z.union([h.z.literal(r.ChatMessageRole.User),h.z.literal(r.ChatMessageRole.System),h.z.literal(r.ChatMessageRole.Assistant),h.z.literal(r.ChatMessageRole.Developer)]),content:h.z.union([h.z.array(q),h.z.string()]),phase:aL.nullish()}).superRefine((e,t)=>{e.role!==r.ChatMessageRole.Assistant&&(0,c.isDefinedAndNotNull)(e.phase)&&t.addIssue({code:h.z.ZodIssueCode.custom,message:"`phase` is only supported on assistant messages"})}),aK=h.z.object({type:h.z.literal(y.Message).optional(),role:h.z.union([h.z.literal(r.ChatMessageRole.User),h.z.literal(r.ChatMessageRole.System),h.z.literal(r.ChatMessageRole.Assistant),h.z.literal(r.ChatMessageRole.Developer)]),content:h.z.union([h.z.array(D),h.z.string()]).nullish(),phase:aL.nullish().openapi({description:"The phase of an assistant message. Use `commentary` for an intermediate assistant message and `final_answer` for the final assistant message. For follow-up requests with models like `gpt-5.3-codex` and later, preserve and resend phase on all assistant messages. Omitting it can degrade performance. Not used for user messages.",example:"final_answer"})}).superRefine((e,t)=>{e.role!==r.ChatMessageRole.Assistant&&(0,c.isDefinedAndNotNull)(e.phase)&&t.addIssue({code:h.z.ZodIssueCode.custom,message:"`phase` is only supported on assistant messages"})}).openapi("EasyInputMessage",{example:{role:"user",content:"What is the weather today?"}}),aN=h.z.object({id:h.z.string(),type:h.z.literal(y.Message).optional(),role:h.z.union([h.z.literal(r.ChatMessageRole.User),h.z.literal(r.ChatMessageRole.System),h.z.literal(r.ChatMessageRole.Developer)]),content:h.z.array(q)}).openapi("OpenAIResponseInputMessageItem",{example:{id:"msg-abc123",type:"message",role:"user",content:[{type:"input_text",text:"Hello, how are you?"}]}}),aG=h.z.object({id:h.z.string().optional(),type:h.z.literal(y.Message).optional(),role:h.z.union([h.z.literal(r.ChatMessageRole.User),h.z.literal(r.ChatMessageRole.System),h.z.literal(r.ChatMessageRole.Developer)]),content:h.z.array(D).nullish()}).openapi("InputMessageItem",{example:{id:"msg-abc123",type:"message",role:"user",content:[{type:"input_text",text:"Hello, how are you?"}]}}),a$=h.z.object({type:h.z.literal(y.ConfigurationUpdate),id:h.z.string().nullish(),reasoning:s.ReasoningConfigurationUpdateSchema.shape.reasoning}).openapi("ConfigurationUpdateItem",{description:"Changes reasoning effort from this point in the conversation onward without invalidating the prompt cache for the preceding items. Place it before the user message it should apply to; it stays in effect until another configuration update. Two adjacent configuration updates are rejected. Only supported by models that accept mid-conversation effort changes.",example:{type:"configuration_update",reasoning:{effort:"low"}}}),aB=h.z.union([aV,aN,tP,tj,l.OpenAIResponsesImageGenerationCallSchema,p.OpenAIResponsesOutputMessageSchema,tF,tD,tO,tR,a$]),aH=ai.extend({type:ai.shape.type.default(y.Message),content:h.z.union([h.z.array(h.z.union([p.OpenAIResponsesOutputTextSchema,p.OpenAIResponsesRefusalContentSchema])),h.z.string()]).nullish()}),aJ=ar.extend({summary:ar.shape.summary.nullish()}),aX=h.z.union([aH,aJ,as,al,ac,ap,au,ad,am,ag,af,ay,a_,ab,aI,aS,ax,aw,aT,aj,ak,aM,aP,aE,aF,aq,aD,av,t9,t7,tJ,t1,tN,tG,t$,tB,tq,tW,t5,t8,t6]),aZ=h.z.object({type:h.z.literal(y.AdditionalTools),role:h.z.enum(["unknown","user","assistant","system","critic","discriminator","developer","tool"]),tools:h.z.array(tx),id:h.z.string().nullish()}).openapi("AdditionalToolsItem",{description:"Additional tools made available to the model at this point in the input",example:{type:"additional_tools",role:"developer",tools:[{type:"function",name:"get_weather",parameters:{type:"object",properties:{location:{type:"string"}}}}]}}),aQ=h.z.object({type:h.z.literal("encrypted_content"),encrypted_content:h.z.string()}).passthrough(),aY=h.z.object({type:h.z.literal(_.AgentMessage),author:h.z.string(),recipient:h.z.string(),content:h.z.array(h.z.discriminatedUnion("type",[j,F,aQ])),id:h.z.string().nullish(),agent:h.z.object({agent_name:h.z.string()}).passthrough().nullish()}).passthrough().openapi("AgentMessageItem",{description:"A message routed between agents in a multi-agent session",example:{type:"agent_message",author:"/root/worker",recipient:"/root",content:[{type:"input_text",text:"Task complete."}]}}),a0=h.z.union([J,aK,aG,tk,tE,tO,tR,aX,aZ,aY,a$]),a2=h.z.custom().transform((e,t)=>{let a=(0,u.isRecord)(e)?e:void 0,n=a?.type;if(n===_.FunctionCallOutput&&a?.call_id===void 0){let t=(0,m.parseSchema)(aU,e);if((0,d.isOk)(t))return t.data}if(n===y.AdditionalTools){let t=(0,m.parseSchema)(aZ,e);if((0,d.isOk)(t))return t.data}if(n===_.AgentMessage){let t=(0,m.parseSchema)(aY,e);if((0,d.isOk)(t))return t.data}if(n===y.ShellCallOutput){let t=(0,m.parseSchema)(t4,e);if((0,d.isOk)(t))return t.data}if(a){let e=function(e,t){if(void 0!==t&&t!==y.Message)return;if(t===y.Message&&"string"==typeof e.id&&e.role!==r.ChatMessageRole.Assistant){let t=(0,m.parseSchema)(aG,e);if((0,d.isOk)(t))return t.data}let a=(0,m.parseSchema)(aK,e);if((0,d.isOk)(a))return a.data;if(e.role!==r.ChatMessageRole.Assistant)return;let n=(0,m.parseSchema)(aH,e);return(0,d.isOk)(n)?n.data:void 0}(a,n);if(e)return e}if("custom_tool_call"===n){let t=(0,m.parseSchema)(tq,e);if((0,d.isOk)(t))return t.data}let o=(0,m.parseSchema)(a0,e);if((0,d.isOk)(o))return o.data;for(let e of o.error.issues)t.addIssue({...e});return h.z.NEVER}),a3=h.z.union([h.z.string(),h.z.array(aB)]).openapi("BaseInputs",{example:[{role:"user",content:"What is the weather today?"}]}),a1=h.z.union([h.z.string(),h.z.array(a0)]).openapi("Inputs",{description:"Input for a response request - can be a string or array of items",example:[{role:"user",content:"What is the weather today?"}]}),a4={role:r.ChatMessageRole.User,content:""};h.z.custom().transform((e,t)=>{var a,n;let o=!!Array.isArray(a=e)&&a.some(e=>{var t;return(0,u.isRecord)(e)&&(e.type===y.AdditionalTools||e.type===_.AgentMessage||e.type===y.ShellCallOutput||e.type===_.FunctionCallOutput&&void 0===e.call_id||e.type===_.CustomToolCall||(t=e).type===y.Message||void 0===t.type&&"string"==typeof t.role)}),i=o&&Array.isArray(e)?function(e){let t=[];for(let a=0;a{if((0,u.isRecord)(e)&&e.type===_.FunctionCallOutput&&void 0===e.call_id){let t=(0,m.parseSchema)(aU,e);if((0,d.isOk)(t))return t.data}return!function(e){if(!(0,u.isRecord)(e)||e.type!==y.ShellCallOutput)return!1;let t=(0,m.parseSchema)(t4,e);return!(0,d.isErr)(t)&&(0,d.isErr)((0,m.parseSchema)(t1,e))}(e)?e:a4}):n):i;if((0,d.isOk)(r))return r.data;for(let e of r.error.issues)t.addIssue({...e});return h.z.NEVER}),e.s(["OpenAIResponsesInputSchema",0,a3,"OpenResponsesInputItemSchema",0,a0],562722);var a6=e.i(698716);let a5="video_generation_call",a8=h.z.object({type:h.z.literal(a5),id:h.z.string(),status:h.z.enum([...a6.VIDEO_ITEM_IN_FLIGHT_STATUSES,"completed","failed"]),jobId:h.z.string()}),a9=h.z.union([a0,aW,a8]),a7=h.z.object({id:h.z.string(),messageId:h.z.string(),data:a9}),ne=(0,m.buildZodGuard)(aW);e.s(["PlaygroundItemSchema",0,a7,"VIDEO_GENERATION_CALL_TYPE",0,a5,"isResponsesOutputItem",0,ne],885686);var nt=e.i(429930);let na=h.z.object({id:h.z.string(),title:h.z.string(),createdAt:nt.DateOrIsoStringSchema,updatedAt:nt.DateOrIsoStringSchema,lastActivityAt:nt.DateOrIsoStringSchema.optional(),version:h.z.number().optional(),isPinned:h.z.boolean().optional().default(!1),zdr:h.z.boolean().optional(),internId:h.z.string().optional()});na.extend(h.z.object({characters:n.CharactersMapSchema.optional().default({}),messages:o.MessagesMapSchema.optional().default({}),isProcessing:h.z.boolean().optional().default(!1),sortedMessageIds:h.z.array(h.z.string()).default([]),hydrationStatus:h.z.enum(nt.HydrationStatus).optional().default(nt.HydrationStatus.Idle),hydrationError:h.z.string().nullish(),artifactIds:h.z.array(h.z.string()).default([])}).shape);let nn=h.z.object({version:h.z.string(),title:h.z.string().optional(),characters:h.z.record(h.z.string(),n.PlaygroundCharacterSchema).optional().default({}),messages:h.z.record(h.z.string(),o.PlaygroundMessageSchema).optional().default({}),items:h.z.record(h.z.string(),a7).optional().default({}),artifacts:a.ArtifactMapSchema.optional().default({}),artifactFiles:a.ArtifactFileMapSchema.optional().default({}),artifactVersions:a.ArtifactVersionMapSchema.optional().default({}),artifactFileContents:a.ArtifactFileContentMapSchema.optional().default({})}),no=h.z.object({roomIds:h.z.array(h.z.string())});e.s(["ExportedChatDataSchema",0,nn,"RoomIndexSchema",0,no,"RoomMetadataSchema",0,na],110873),e.s([],798823)},865932,321142,870729,24220,47356,e=>{"use strict";let t=null;async function a(){if(t)return t;{let{WorkerKVStore:a}=await e.A(304241);return t=new a}}e.s(["getWorkerKVStoreInstance",0,a],321142);let n={v3:{migrationCompleteFlag:()=>"v3:migration_complete",masterRoomIndex:()=>"v3:master:rooms",roomMetadata:e=>`v3:room:${e}`,manifest:e=>`v3:manifest:${e}`,character:e=>`v3:character:${e}`,message:e=>`v3:message:${e}`,item:e=>`v3:item:${e}`,content:e=>`v3:content:${e}`,reasoning:e=>`v3:reasoning:${e}`,artifact:e=>`v3:artifact:${e}`,artifactFile:e=>`v3:artifact_file:${e}`,artifactVersion:e=>`v3:artifact_version:${e}`,artifactContent:e=>`v3:artifact_content:${e}`,artifactData:(e,t)=>`v3:artifact_data:${e}:${t}`,prefixes:{character:()=>"v3:character:",message:()=>"v3:message:",item:()=>"v3:item:",content:()=>"v3:content:",reasoning:()=>"v3:reasoning:",artifact:()=>"v3:artifact:",artifactFile:()=>"v3:artifact_file:",artifactVersion:()=>"v3:artifact_version:",artifactContent:()=>"v3:artifact_content:",artifactData:e=>`v3:artifact_data:${e}:`}},legacy:{threads:()=>"chat:threads",characters:e=>`characters:${e}`,messages:e=>`messages:${e}`,content:e=>`content:${e}`,reasoning:e=>`reasoning:${e}`}};async function o(e,t){let o=await a();if(!o)return"";let i=await o.get(e,n.v3.content(t));return"string"==typeof i?i:""}async function i(e,t){if(0===t.length)return{};let o=await a();if(!o)return{};let i=await o.getMany(e,t.map(n.v3.content)),r=n.v3.prefixes.content();return Object.entries(i).reduce((e,[t,a])=>{let n=t.substring(r.length);return"string"==typeof a&&n&&(e[n]=a),e},{})}async function r({namespace:e,messageId:t,fullContent:o}){let i=await a();i&&await i.set(e,n.v3.content(t),o)}async function s(e,t){let o=await a();if(!o)return"";let i=await o.get(e,n.v3.reasoning(t));return"string"==typeof i?i:""}async function l(e,t){if(0===t.length)return{};let o=await a();if(!o)return{};let i=await o.getMany(e,t.map(n.v3.reasoning)),r=n.v3.prefixes.reasoning();return Object.entries(i).reduce((e,[t,a])=>{let n=t.substring(r.length);return"string"==typeof a&&n&&(e[n]=a),e},{})}async function p({namespace:e,messageId:t,fullReasoning:o}){let i=await a();i&&await i.set(e,n.v3.reasoning(t),o)}e.s(["persistenceKeys",0,n],870729),e.s(["getContent",0,o,"getManyContent",0,i,"saveContent",0,r],865932),e.s(["getManyReasoning",0,l,"getReasoning",0,s,"saveReasoning",0,p],24220);var c=e.i(693697);let u=(e,t)=>n.v3.artifactData(e,t);async function d(e,t){let n=await a();if(!n)return null;let o=await (0,c.wrap)(()=>n.get(e,u(e,t)));if((0,c.isErr)(o))return null;let i=o.data;return"string"==typeof i?i:null}async function m(e,t,n){let o=await a();o&&await (0,c.wrap)(()=>o.set(e,u(e,t),n))}async function h(e,t){let n=await a();n&&await (0,c.wrap)(()=>n.del(e,u(e,t)))}async function g(e){let t=await a();if(!t)return;let o=n.v3.prefixes.artifactData(e);await (0,c.wrap)(()=>t.delPrefix(e,o))}e.s(["clearArtifactData",0,g,"getArtifactData",0,d,"removeArtifactData",0,h,"setArtifactData",0,m],47356)},447680,401399,32582,826735,e=>{"use strict";var t=e.i(865932),a=e.i(24220),n=e.i(47356);e.i(530023);var o=e.i(612774),i=e.i(693697),r=e.i(204067),s=e.i(321142);e.i(798823);var l=e.i(472708),p=e.i(429930),c=e.i(870729);let u=e=>e.map(c.persistenceKeys.v3.artifactContent);async function d(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,u(t)),o=c.persistenceKeys.v3.prefixes.artifactContent();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(l.ArtifactFileContentSchema,a);if((0,i.isErr)(n))return e;let s=t.substring(o.length);if(s){let t=n.data,a=t.generationStatus===p.GenerationStatus.Generating?{...t,generationStatus:p.GenerationStatus.Failed}:t;e[s]=a}return e},{})}async function m(e,t){if(0===t.length)return;let a=t.map(e=>{let t=(0,r.parseSchema)(l.ArtifactFileContentSchema,e);return(0,i.isErr)(t)?((0,o.toast)({title:"Artifact Content Save Error",description:"Invalid content data.",variant:"destructive"}),null):t.data}).filter(e=>null!==e);if(0===a.length)return;let n=await (0,s.getWorkerKVStoreInstance)();if(!n)return;let p=a.map(t=>n.set(e,c.persistenceKeys.v3.artifactContent(t.id),t));await Promise.all(p)}async function h(e,t){if(0===t.length)return;let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.delMany(e,u(t))}e.s(["deleteArtifactFileContents",0,h,"getArtifactFileContents",0,d,"saveArtifactFileContents",0,m],792580);var g=e.i(792580);class z{isLocked=!1;queue=[];acquire(){return new Promise(e=>{this.isLocked?this.queue.push(e):(this.isLocked=!0,e())})}release(){if(this.queue.length>0){let e=this.queue.shift();e&&e()}else this.isLocked=!1}}let f=new Map;async function y(e,t){let a=(f.has(e)||f.set(e,new z),f.get(e));await a.acquire();try{return await t()}finally{a.release()}}e.s(["withLock",0,y],401399);var _=e.i(796805);let b=_.z.object({characterIds:_.z.array(_.z.string()),messageIds:_.z.array(_.z.string()),artifactIds:_.z.array(_.z.string()).optional().default([]),itemIds:_.z.array(_.z.string()).optional().default([])});async function I(e,t){let a={characterIds:[],messageIds:[],artifactIds:[],itemIds:[]},n=await (0,s.getWorkerKVStoreInstance)();if(!n)return a;let o=await n.get(e,c.persistenceKeys.v3.manifest(t));if(!o)return a;let l=(0,r.parseSchema)(b,o);return(0,i.isOk)(l)?l.data:{characterIds:[],messageIds:[],artifactIds:[],itemIds:[]}}async function S(e,t,a){let n=await (0,s.getWorkerKVStoreInstance)();n&&await n.set(e,c.persistenceKeys.v3.manifest(t),a)}async function v(e,t){let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.del(e,c.persistenceKeys.v3.manifest(t))}e.s(["RoomManifestSchema",0,b,"deleteRoomManifest",0,v,"getRoomManifest",0,I,"saveRoomManifest",0,S],457682);var x=e.i(81174),w=e.i(442401),A=e.i(885686);let O=e=>e.map(c.persistenceKeys.v3.item);async function R(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,O(t)),o=c.persistenceKeys.v3.prefixes.item();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(A.PlaygroundItemSchema,a);if((0,i.isOk)(n)){let a=t.substring(o.length);a&&(e[a]=function(e){if("image_generation_call"===e.data.type&&("in_progress"===e.data.status||"generating"===e.data.status)){let t={...e.data,status:"failed"};return{...e,data:t}}return e}(n.data))}return e},{})}async function C(e,t,a){if(0===a.length)return;let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=a.filter(e=>{let t=(0,r.parseSchema)(A.PlaygroundItemSchema,e),a=(0,i.isOk)(t);return a||((0,o.toast)({title:"Item Save Error",description:"Invalid item data provided.",variant:"destructive"}),(0,x.vLog)("Invalid item data provided.",{item:e,error:t.error})),a});if(0===n.length)return;let l=await I(e,t),p=new Set(l.itemIds??[]),u=!1;for(let e of n)p.has(e.id)||(p.add(e.id),l.itemIds=l.itemIds??[],l.itemIds.push(e.id),u=!0);let d=await (0,s.getWorkerKVStoreInstance)();if(!d)return;let m=[d.setMany(e,n.map(e=>({key:c.persistenceKeys.v3.item(e.id),value:e})))];u&&m.push(S(e,t,l)),await Promise.all(m)})}async function T(e,t){if(0===t.length)return;let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.delMany(e,O(t))}e.s(["deleteItems",0,T,"getItems",0,R,"saveItems",0,C],825262);let j=e=>e.map(c.persistenceKeys.v3.message);function k(e){return e.type===p.MessageType.Assistant&&(e.isGenerating||e.isRetrying)?{...e,isGenerating:!1,isRetrying:!1,updatedAt:new Date}:e}async function M(e,t){let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return null;let n=await a.get(e,c.persistenceKeys.v3.message(t));if(!n)return null;let o=(0,r.parseSchema)(w.PlaygroundMessageSchema,n);return(0,i.isErr)(o)?null:k(o.data)}async function P(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,j(t)),o=c.persistenceKeys.v3.prefixes.message();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(w.PlaygroundMessageSchema,a);if((0,i.isErr)(n))return(0,x.vLog)("Failed to parse message",{key:t,data:a,error:n.error}),e;let s=t.substring(o.length);return s&&(e[s]=k(n.data)),e},{})}async function E(e,t,a){await F(e,t,[a])}async function F(e,t,a){if(0===a.length)return;let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=a.filter(e=>{let t=(0,r.parseSchema)(w.PlaygroundMessageSchema,e),a=(0,i.isOk)(t);return a||(0,o.toast)({title:"Message SaveError",description:"Invalid message data provided.",variant:"destructive"}),a});if(0===n.length)return;let l=await I(e,t),p=new Set(l.messageIds),u=!1;for(let e of n)p.has(e.id)||(p.add(e.id),l.messageIds.push(e.id),u=!0);let d=await (0,s.getWorkerKVStoreInstance)();if(!d)return;let m=[d.setMany(e,n.map(e=>({key:c.persistenceKeys.v3.message(e.id),value:e})))];u&&m.push(S(e,t,l)),await Promise.all(m)})}async function q(e,t,a){await D(e,t,[a])}async function D(e,t,a){if(0===a.length)return;let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=await I(e,t),o=new Set(a);n.messageIds=n.messageIds.filter(e=>!o.has(e));let i=Object.values(await P(e,a)).flatMap(e=>(e.items??[]).map(e=>e.id));await Promise.all([U(e,a,i),S(e,t,n)])})}async function W(e,t,a){let n=await I(e,t),o=Object.values(await P(e,n.messageIds)).reduce((e,t)=>(t?.parentMessageId&&(e.has(t.parentMessageId)||e.set(t.parentMessageId,[]),e.get(t.parentMessageId).push(t.id)),e),new Map),i=[],r=[a],s=new Set;for(;r.length>0;){let e=r.shift();if(!e||s.has(e))continue;s.add(e),i.push(e);let t=o.get(e);t&&r.push(...t)}i.length>0&&await D(e,t,i)}async function U(e,t,a){if(0===t.length&&0===a.length)return;let n=await (0,s.getWorkerKVStoreInstance)();if(!n)return;let o=[];t.length>0&&o.push(n.delMany(e,j(t))),a.length>0&&o.push(T(e,a)),await Promise.all(o)}async function L(e,t){let a=c.persistenceKeys.v3.manifest(t);await y(a,async()=>{let a=await I(e,t);if(0===a.messageIds.length)return;let n=[...a.messageIds],o=Object.values(await P(e,n)).flatMap(e=>(e.items??[]).map(e=>e.id));a.messageIds=[],await Promise.all([U(e,n,o),S(e,t,a)])})}e.s(["clearMessagesFromRoom",0,L,"deleteMessage",0,q,"deleteMessageBranch",0,W,"deleteMessages",0,D,"deleteOrphanedData",0,U,"getMessage",0,M,"getMessages",0,P,"saveMessage",0,E,"saveMessages",0,F],883669);let V=e=>e.map(c.persistenceKeys.v3.artifact);async function K(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,V(t)),o=c.persistenceKeys.v3.prefixes.artifact();return Object.entries(n).reduce((e,[t,a])=>{var n;if(!a)return e;let s=(0,r.parseSchema)(l.ArtifactSchema,a);if((0,i.isErr)(s))return e;let c=t.substring(o.length);return c&&(e[c]=(n=s.data).type===p.ArtifactType.App&&void 0===n.archetype?{...n,archetype:p.AppArchetype.InteractiveWebApp}:n),e},{})}async function N(e,t,a){if(0===a.length)return;let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=a.map(e=>{let t=(0,r.parseSchema)(l.ArtifactSchema,e);return(0,i.isErr)(t)?((0,o.toast)({title:"Artifact Save Error",description:"Invalid artifact data provided.",variant:"destructive"}),null):t.data}).filter(e=>null!==e);if(0===n.length)return;let p=await I(e,t),u=!1;for(let e of n)p.artifactIds.includes(e.id)||(p.artifactIds.push(e.id),u=!0);let d=await (0,s.getWorkerKVStoreInstance)();if(!d)return;let m=n.map(t=>d.set(e,c.persistenceKeys.v3.artifact(t.id),t));u&&m.push(S(e,t,p)),await Promise.all(m)})}let G=e=>e.map(c.persistenceKeys.v3.artifactFile);async function $(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,G(t)),o=c.persistenceKeys.v3.prefixes.artifactFile();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(l.ArtifactFileSchema,a);if((0,i.isErr)(n))return e;let s=t.substring(o.length);return s&&(e[s]=n.data),e},{})}async function B(e,t){if(0===t.length)return;let a=t.map(e=>{let t=(0,r.parseSchema)(l.ArtifactFileSchema,e);return(0,i.isErr)(t)?((0,o.toast)({title:"Artifact File Save Error",description:"Invalid file data.",variant:"destructive"}),null):t.data}).filter(e=>null!==e);if(0===a.length)return;let n=await (0,s.getWorkerKVStoreInstance)();if(!n)return;let p=a.map(t=>n.set(e,c.persistenceKeys.v3.artifactFile(t.id),t));await Promise.all(p)}let H=e=>e.map(c.persistenceKeys.v3.artifactVersion);async function J(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,H(t)),o=c.persistenceKeys.v3.prefixes.artifactVersion();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(l.ArtifactVersionSchema,a);if((0,i.isErr)(n))return e;let s=t.substring(o.length);if(s){let t=n.data,a=t;if(t.generationStatus===p.GenerationStatus.Generating){let e=Date.now(),n=t.createdAt?new Date(t.createdAt).getTime():e;a={...t,generationStatus:p.GenerationStatus.Failed,generationDurationMs:Math.max(0,e-n)}}e[s]=a}return e},{})}async function X(e,t){if(0===t.length)return;let a=t.map(e=>{let t=(0,r.parseSchema)(l.ArtifactVersionSchema,e);return(0,i.isErr)(t)?((0,o.toast)({title:"Version Save Error",description:"Invalid version data.",variant:"destructive"}),null):t.data}).filter(e=>null!==e);if(0===a.length)return;let n=await (0,s.getWorkerKVStoreInstance)();if(!n)return;let p=a.map(t=>n.set(e,c.persistenceKeys.v3.artifactVersion(t.id),t));await Promise.all(p)}async function Z(e,t){let a=new Set;if(!t)return a;let n=[t];for(a.add(t);n.length>0;){let t=n.shift();if(!t)continue;let o=(await J(e,[t]))[t];o?.parentVersionId&&!a.has(o.parentVersionId)&&(a.add(o.parentVersionId),n.push(o.parentVersionId))}return a}async function Q(e,t,a){let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=(await K(e,[a]))[a];if(!n)return;let o=await Z(e,n.headVersionId??""),i=await J(e,Array.from(o)),r=new Set(n.fileIds),l=new Set;Object.values(i).forEach(e=>{Object.values(e.fileContents).forEach(e=>{l.add(e)})});let p=await I(e,t),u=Object.values(await P(e,p.messageIds)).filter(e=>e.artifactId===a),d=u.map(e=>e.id),m=u.flatMap(e=>(e.items??[]).map(e=>e.id)),g=new Set(d);p.messageIds=p.messageIds.filter(e=>!g.has(e)),p.artifactIds=p.artifactIds.filter(e=>e!==a);let z=await (0,s.getWorkerKVStoreInstance)();z&&await Promise.all([z.del(e,c.persistenceKeys.v3.artifact(a)),z.delMany(e,G(Array.from(r))),z.delMany(e,H(Array.from(o))),h(e,Array.from(l)),U(e,d,m),S(e,t,p)])})}async function Y(e,t){let a=c.persistenceKeys.v3.manifest(t);await y(a,async()=>{let a=await I(e,t);if(0===a.artifactIds.length)return;let n=[...a.artifactIds],o=Object.values(await K(e,n)),i=o.flatMap(e=>e.fileIds),r=o.map(e=>e.headVersionId).filter(e=>!!e),l=(await Promise.all(r.map(t=>Z(e,t)))).flatMap(e=>Array.from(e)),p=Object.values(await J(e,l)).flatMap(e=>Object.values(e.fileContents)),c={...a,artifactIds:[]},u=await (0,s.getWorkerKVStoreInstance)();u&&await Promise.all([u.delMany(e,V(n)),u.delMany(e,G(i)),u.delMany(e,H(l)),h(e,p),S(e,t,c)])})}async function ee(e,t){if(!t)return;let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.del(e,c.persistenceKeys.v3.artifactFile(t))}async function et(e,t){if(0===t.length)return;let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.delMany(e,t.map(c.persistenceKeys.v3.artifactVersion))}e.s(["clearAllArtifactsFromRoom",0,Y,"deleteArtifact",0,Q,"deleteArtifactFile",0,ee,"deleteArtifactVersions",0,et,"fullVersionHistoryTraversal",0,Z,"getArtifactFiles",0,$,"getArtifactVersions",0,J,"getArtifacts",0,K,"saveArtifactFiles",0,B,"saveArtifactVersions",0,X,"saveArtifacts",0,N],32582);var ea=e.i(32582),en=e.i(351344);let eo=e=>e.map(c.persistenceKeys.v3.character);async function ei(e,t){if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return{};let n=await a.getMany(e,eo(t)),o=c.persistenceKeys.v3.prefixes.character();return Object.entries(n).reduce((e,[t,a])=>{if(!a)return e;let n=(0,r.parseSchema)(en.PlaygroundCharacterSchema,a);if((0,i.isErr)(n))return e;let s=t.substring(o.length);return s&&(e[s]=n.data),e},{})}async function er(e,t,a){await es(e,t,[a])}async function es(e,t,a){if(0===a.length)return;let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=eu(a);if(0===n.length)return;let o=await I(e,t),i=!1;for(let e of n)o.characterIds.includes(e.id)||(o.characterIds.push(e.id),i=!0);let r=await (0,s.getWorkerKVStoreInstance)();if(!r)return;let l=n.map(t=>r.set(e,c.persistenceKeys.v3.character(t.id),t));i&&l.push(S(e,t,o)),await Promise.all(l)})}async function el({namespace:e,roomId:t,characterId:a}){let n=c.persistenceKeys.v3.manifest(t);await y(n,async()=>{let n=await I(e,t);n.characterIds=n.characterIds.filter(e=>e!==a);let o=await (0,s.getWorkerKVStoreInstance)();o&&await Promise.all([o.del(e,c.persistenceKeys.v3.character(a)),S(e,t,n)])})}async function ep(e,t,a){let{replacedCharacterIds:n,newCharacters:o}=a,i=c.persistenceKeys.v3.manifest(t);await y(i,async()=>{let a=eu(o);if(0===n.length&&0===a.length)return;let i=await I(e,t),r=new Set(n),l=i.characterIds.filter(e=>!r.has(e)),p=a.map(e=>e.id).filter(e=>!l.includes(e));i.characterIds=[...l,...p];let u=new Set(a.map(e=>e.id)),d=n.filter(e=>!u.has(e)),m=await (0,s.getWorkerKVStoreInstance)();m&&await Promise.all([...d.length>0?[m.delMany(e,eo(d))]:[],...a.map(t=>m.set(e,c.persistenceKeys.v3.character(t.id),t)),S(e,t,i)])})}async function ec(e,t){let a=c.persistenceKeys.v3.manifest(t);await y(a,async()=>{let a=await I(e,t),n=a.characterIds;if(0===n.length)return;a.characterIds=[];let o=await (0,s.getWorkerKVStoreInstance)();o&&await Promise.all([o.delMany(e,eo(n)),S(e,t,a)])})}function eu(e){return e.filter(e=>{let t=(0,r.parseSchema)(en.PlaygroundCharacterSchema,e),a=(0,i.isOk)(t);return a||(0,o.toast)({title:"Model Save Error",description:"Invalid model data provided.",variant:"destructive"}),a})}e.s(["clearCharactersFromRoom",0,ec,"deleteCharacterFromRoom",0,el,"getCharacters",0,ei,"replaceCharactersInRoom",0,ep,"saveCharacter",0,er,"saveCharacters",0,es],230509);var ed=e.i(230509),em=e.i(825262),eh=e.i(457682),eg=e.i(883669);async function ez(e){let t=await (0,s.getWorkerKVStoreInstance)();return!!t&&!0===await t.get(e,c.persistenceKeys.v3.migrationCompleteFlag())}async function ef(e){let t=await (0,s.getWorkerKVStoreInstance)();t&&await t.set(e,c.persistenceKeys.v3.migrationCompleteFlag(),!0)}e.s(["getMigrationCompleteFlag",0,ez,"setMigrationCompleteFlag",0,ef],233209);var ey=e.i(233209),e_=e.i(968076);function eb(){return`msg_tmp_${Math.random().toString(36).substring(2,15)}`}var eI=e.i(122901);function eS(e){return{id:e.id??(0,eI.orid)(eI.ORIDType.Item),messageId:e.messageId,data:e.data}}e.s(["createPlaygroundItem",0,eS],826735);let ev=_.z.object({image_url:_.z.object({url:_.z.string()})});function ex(e,t,a){let n={createdItems:{},itemIdsToAdd:[],messagesToPersist:[]};for(let o of Object.values(e)){if(!o)continue;let s=o.type===p.MessageType.Assistant?function(e){var t,a,n,o;let s,l,c,u,d,{message:m,allMessages:h,legacyContentMap:g,legacyReasoningMap:z}=e;if((m.items??[]).length>0)return null;let f=m.parentMessageId?h[m.parentMessageId]:void 0;if(f?.contentType===p.ContentType.ArtifactVersion)return{itemsToCreate:[],updatedMessage:{...m,contentType:p.ContentType.ArtifactVersion}};let y=(g[m.id]??"").trim(),_=(z[m.id]??"").trim(),b=(m.content??"").trim()||y,I=(m.reasoning??"").trim()||_,S=m.images??[],v=m.citations??[],x=m.files??[];if(![b,I,...S,...v,...x].some(Boolean))return null;let w=[...I?[(t=m.id,{item:l=eS({messageId:t,data:s={id:`rs_tmp_${Math.random().toString(36).substring(2,15)}`,type:"reasoning",content:[{type:"reasoning_text",text:I}],summary:[{type:"summary_text",text:I}]}}),ref:{id:l.id,type:s.type}})]:[],...b||v.length>0?[(a=m.id,c=(v??[]).map(e=>{let{url:t,title:a,start_index:n,end_index:o}=e.url_citation;return{type:"url_citation",url:t,title:a,start_index:n,end_index:o}}),{item:d=eS({messageId:a,data:u={id:eb(),type:"message",role:"assistant",status:"completed",content:[{type:"output_text",text:b,annotations:c}]}}),ref:{id:d.id,type:u.type}})]:[],...(n=m.id,S.flatMap(e=>{let t=(0,r.parseSchema)(ev,e);if((0,i.isErr)(t))return[];let a={id:eb(),type:"image_generation_call",status:"completed",result:t.data.image_url.url},o=eS({messageId:n,data:a});return[{item:o,ref:{id:o.id,type:a.type}}]})),...(o=m.id,x.flatMap(e=>{if(!e.url)return[];let[,t]=e.url.split(",");if(!t)return[];let a={id:eb(),type:"message",role:"assistant",content:[{type:"input_file",file_data:t,filename:e.name}]},n=eS({messageId:o,data:a});return[{item:n,ref:{id:n.id,type:a.type}}]}))],A=w.map(e=>e.item),O=w.map(e=>e.ref);return{itemsToCreate:A,updatedMessage:{...m,items:O}}}({message:o,allMessages:e,legacyContentMap:t,legacyReasoningMap:a}):o.type===p.MessageType.User?function(e,t){if((e.items??[]).length>0)return null;let a=(t[e.id]??"").trim(),n=(e.content??"").trim()||a,o=[...n?[{type:"input_text",text:n}]:[],...(e.attachments??[]).flatMap(e=>{if(!e.url)return[];if(e.type===e_.AttachmentType.Image)return[{type:"input_image",image_url:e.url,detail:"auto"}];if(e.type===e_.AttachmentType.File||e.type===e_.AttachmentType.Text||e.type===e_.AttachmentType.Audio){let[,t]=e.url.split(",");if(t)return[{type:"input_file",file_data:t,filename:e.name}]}return[]})];if(0===o.length)return null;let i=eS({messageId:e.id,data:{type:"message",role:"user",content:o}}),r={...e,items:[{id:i.id,type:i.data.type}]};return{itemsToCreate:[i],updatedMessage:r}}(o,t):null;if(!s)continue;let{updatedMessage:l,itemsToCreate:c}=s;for(let e of(n.messagesToPersist.push(l),c))n.createdItems[e.id]=e,n.itemIdsToAdd.push(e.id)}return n}e.s(["migrateMessagesToItemFormat",0,ex],126636);var ew=e.i(126636),eA=e.i(110873);async function eO(e){let t=await (0,s.getWorkerKVStoreInstance)();if(!t)return[];let a=await t.get(e,c.persistenceKeys.v3.masterRoomIndex()),n=(0,r.parseSchema)(eA.RoomIndexSchema,a??{roomIds:[]});return(0,i.isOk)(n)?n.data.roomIds:[]}async function eR(e,t){let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.set(e,c.persistenceKeys.v3.masterRoomIndex(),{roomIds:t})}async function eC(e,t){let a=(0,r.parseSchema)(eA.RoomMetadataSchema,t);if((0,i.isErr)(a))return;let n=a.data,o=c.persistenceKeys.v3.masterRoomIndex();await y(o,async()=>{let t=await eO(e);t.includes(n.id)||(t.push(n.id),await eR(e,t));let a=await (0,s.getWorkerKVStoreInstance)();a&&await a.set(e,c.persistenceKeys.v3.roomMetadata(n.id),n)})}async function eT(e){let t=await eO(e);if(0===t.length)return{};let a=await (0,s.getWorkerKVStoreInstance)();return a?Object.entries(await a.getMany(e,t.map(c.persistenceKeys.v3.roomMetadata))).reduce((e,[,t])=>{if(!t)return e;let a=(0,r.parseSchema)(eA.RoomMetadataSchema,t);return(0,i.isOk)(a)&&a.data.id&&(e[a.data.id]=a.data),e},{}):{}}async function ej(e,t){await ek(e,t);let a=c.persistenceKeys.v3.masterRoomIndex();await y(a,async()=>{let a=await (0,s.getWorkerKVStoreInstance)();if(!a)return;await v(e,t),await a.del(e,c.persistenceKeys.v3.roomMetadata(t));let n=(await eO(e)).filter(e=>e!==t);await eR(e,n)})}async function ek(e,t){await Promise.all([ec(e,t),L(e,t),Y(e,t)])}async function eM(e,n){let o=await I(e,n),[i,r,s,l,p,c]=await Promise.all([ei(e,o.characterIds),P(e,o.messageIds),R(e,o.itemIds),K(e,o.artifactIds),(0,t.getManyContent)(e,o.messageIds),(0,a.getManyReasoning)(e,o.messageIds)]),{createdItems:u,itemIdsToAdd:d,messagesToPersist:m}=ex(r,p,c);(Object.keys(u).length>0||m.length>0)&&(await Promise.all([Object.keys(u).length>0?C(e,n,Object.values(u)):Promise.resolve(),m.length>0?F(e,n,m):Promise.resolve()]),d.length>0&&await S(e,n,{...o,itemIds:Array.from(new Set([...o.itemIds??[],...d]))}));let h={...s,...u};for(let e of m)r[e.id]=e;return{characters:i,messages:r,items:h,artifacts:l}}e.s(["clearRoomContents",0,ek,"deleteRoom",0,ej,"getAllRooms",0,eT,"getRoom",0,eM,"saveRoom",0,eC],549621);var eP=e.i(549621);let eE={...ea,...ed,...eh,...eg,...ey,...eP,...g,...n,...em,...ew,...t,...a};e.s(["persistence",0,eE],447680)},19222,e=>{"use strict";let t=new Map;function a(e,a){t.get(e)===a&&t.delete(e)}e.s(["abortVideoPoll",0,function(e,t){a(e,t),t.abort()},"abortVideoPollsForItems",0,function(e){for(let a of e){let e=t.get(a);e&&(t.delete(a),e.abort())}},"claimVideoPoll",0,function(e,a){return!t.has(e)&&(t.set(e,a),!0)},"releaseVideoPoll",0,a])},624621,e=>{"use strict";var t=e.i(394359),a=e.i(591444),n=e.i(948810),o=e.i(789836),i=e.i(639241),r=e.i(264678),s=e.i(604638),l=e.i(621036),p=e.i(295654);e.i(798823);var c=e.i(429930);let u=(0,n.create)()((0,i.persist)((0,o.mutative)(()=>({rooms:{},currentRoomId:null,artifacts:{},artifactFiles:{},artifactVersions:{},artifactFileContents:{},generationAttemptStartMs:{},storageInstanceId:null,initializationStatus:c.StoreInitializationStatus.Idle,isRoomManagerCollapsed:!1,isInternConversationsCollapsed:!0,isPromptHistoryCollapsed:!1,showSignUpModal:!1,showInsufficientCreditsModal:!1,pendingMessage:null,pendingMessageSource:null,pendingRoomId:null,pendingCharacters:null,pendingRoomZdr:null,tools:s.DEFAULT_TOOLS_CONFIG,userConfiguredToolIds:[],isChatNotificationsEnabled:!1,shouldStickToBottom:!0,activeArtifactId:null,artifactViewerState:{},chatMemoryCount:p.MAX_CHAT_MEMORY_COUNT})),{name:"openrouter-chatroom-v3",version:6,merge:(e,t)=>(0,a.isPlainObject)(e)?{...t,...e,tools:(0,s.mergeToolsWithDefaults)(e)}:t,migrate:(e,n)=>{if(!(0,a.isPlainObject)(e))return e;let o=e;if(n<2){let n=(0,a.isPlainObject)(e.webSearchConfig)?e.webSearchConfig:void 0,i=n&&"string"==typeof n.engine?n.engine:"",l=n&&"string"==typeof n.searchContextSize?n.searchContextSize:"",p={auto:"auto",native:"native",exa:"exa",firecrawl:"firecrawl",parallel:"parallel"}[i]??r.DEFAULT_WEB_SEARCH_PARAMETERS.engine,c={[t.SearchContextSize.Low]:t.SearchContextSize.Low,[t.SearchContextSize.Medium]:t.SearchContextSize.Medium,[t.SearchContextSize.High]:t.SearchContextSize.High}[l]??r.DEFAULT_WEB_SEARCH_PARAMETERS.search_context_size,u={webSearch:{enabled:"boolean"==typeof e.isWebSearchEnabled&&e.isWebSearchEnabled,parameters:{...r.DEFAULT_WEB_SEARCH_PARAMETERS,engine:p,search_context_size:c}},webFetch:{enabled:"boolean"==typeof e.isWebFetchEnabled&&e.isWebFetchEnabled,parameters:r.DEFAULT_WEB_FETCH_PARAMETERS},imageGeneration:{...s.DEFAULT_TOOLS_CONFIG.imageGeneration,enabled:"boolean"==typeof e.isImageGenerationEnabled&&e.isImageGenerationEnabled},datetime:{...s.DEFAULT_TOOLS_CONFIG.datetime,enabled:"boolean"==typeof e.isDatetimeEnabled&&e.isDatetimeEnabled},searchModels:s.DEFAULT_TOOLS_CONFIG.searchModels,fusion:s.DEFAULT_TOOLS_CONFIG.fusion,advisor:s.DEFAULT_TOOLS_CONFIG.advisor,subagent:s.DEFAULT_TOOLS_CONFIG.subagent,shell:s.DEFAULT_TOOLS_CONFIG.shell},{isDatetimeEnabled:d,isWebSearchEnabled:m,webSearchConfig:h,isWebFetchEnabled:g,isImageGenerationEnabled:z,...f}=e;o={...f,tools:u}}let i=n<6?(0,s.migrateLegacyShellTool)(o):o,l=n<4?{...i,tools:(0,s.mergeToolsWithDefaults)(i)}:i;if(n<5&&8===l.chatMemoryCount){let{chatMemoryCount:e,...t}=l;return t}return l},storage:(0,i.createJSONStorage)(l.createSafeLocalStorage),partialize:e=>({tools:e.tools,userConfiguredToolIds:e.userConfiguredToolIds,isChatNotificationsEnabled:e.isChatNotificationsEnabled,isRoomManagerCollapsed:e.isRoomManagerCollapsed,isInternConversationsCollapsed:e.isInternConversationsCollapsed,isPromptHistoryCollapsed:e.isPromptHistoryCollapsed,pendingMessage:e.pendingMessage,pendingMessageSource:e.pendingMessageSource,pendingRoomId:e.pendingRoomId,pendingCharacters:e.pendingCharacters,pendingRoomZdr:e.pendingRoomZdr,artifactViewerState:e.artifactViewerState,chatMemoryCount:e.chatMemoryCount})}));e.s(["useChatroomStore",0,u])},735961,528783,488554,402432,696384,634160,e=>{"use strict";var t=e.i(720170),a=e.i(693697),n=e.i(204067),o=e.i(948810),i=e.i(789836),r=e.i(447680),s=e.i(19222),l=e.i(624621);let p=new Map,c=new Map;async function u(){let e=Array.from(c.values());for(let e of Array.from(p.keys())){let t=p.get(e);t&&clearTimeout(t)}p.clear(),c.clear(),await Promise.all(e.map(e=>e()))}function d(e,t=0){return`${m(e)}/content?index=${t}`}function m(e){return`/api/v1/videos/${encodeURIComponent(e)}`}e.s(["buildVideoContentUrl",0,d,"buildVideoJobUrl",0,m],528783);var h=e.i(401399);let g=new Map,z=new Set;var f=e.i(796805);let y=f.z.object({name:f.z.string()}),_=f.z.object({target:f.z.object({error:y})});function b(e,t){return t-e.createdAt>2592e6}var I=e.i(321142);let S="playground-video-cache-v1",v="meta:",x=(e,t)=>`bytes:${e}:${t}`,w=(e,t)=>`${v}${e}:${t}`,A=f.z.object({jobId:f.z.string(),index:f.z.number().int().nonnegative(),contentType:f.z.string(),sizeBytes:f.z.number().int().nonnegative(),createdAt:f.z.number(),lastAccessedAt:f.z.number()});async function O(e,t){let n=await (0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).get(S,x(e,t)));return!(0,a.isErr)(n)&&n.data instanceof ArrayBuffer?n.data:null}async function R(e,t){let o=await (0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).get(S,w(e,t)));if((0,a.isErr)(o))return null;let i=(0,n.parseSchema)(A,o.data);return(0,a.isErr)(i)?null:i.data}async function C(e,t){let n=await P();return(0,a.isErr)(n)?n:(0,a.ok)(n.data.includes(x(e,t)))}async function T(){let e=(await M()).filter(e=>e.startsWith(v));if(0===e.length)return[];let t=await (0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).getMany(S,e));return(0,a.isErr)(t)?[]:Object.values(t.data).flatMap(e=>{let t=(0,n.parseSchema)(A,e);return(0,a.isErr)(t)?[]:[t.data]})}async function j(e,t){let a=await (0,I.getWorkerKVStoreInstance)();await a.setMany(S,[{key:x(e.jobId,e.index),value:t},{key:w(e.jobId,e.index),value:e}])}async function k(e,t){await (0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).set(S,w(e.jobId,e.index),{...e,lastAccessedAt:t}))}async function M(){let e=await P();return(0,a.isErr)(e)?[]:e.data}async function P(){return(0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).getAllKeys(S))}async function E(e){if(0===e.length)return;let t=e.flatMap(e=>[x(e.jobId,e.index),w(e.jobId,e.index)]);await (0,a.wrap)(async()=>(await (0,I.getWorkerKVStoreInstance)()).delMany(S,t))}let F="video-cache:write";async function q(e,t=0){let n=await R(e,t);if(!n)return null;if(b(n,Date.now()))return await L(n),null;let o=await O(e,t);return o?((0,a.wrap)(()=>V(n)),new Blob([o],{type:n.contentType})):(await U(n),null)}async function D(e,t=0){let n=await R(e,t);if(!n)return!1;if(b(n,Date.now()))return await L(n),!1;let o=await C(e,t);return!!(0,a.isOk)(o)&&!!o.data||(await U(n),!1)}async function W(e,t=0){var a;a=`${e}:${t}`,g.has(a)&&z.add(a),await (0,h.withLock)(F,()=>E([{jobId:e,index:t}]))}async function U(e){await (0,h.withLock)(F,async()=>{let t=await C(e.jobId,e.index);(0,a.isErr)(t)||t.data||await E([e])})}async function L(e){await (0,h.withLock)(F,async()=>{let t=await R(e.jobId,e.index);t&&b(t,Date.now())&&await E([t])})}async function V(e){await (0,h.withLock)(F,async()=>{let t=await R(e.jobId,e.index);t&&await k(t,Date.now())})}async function K(){let e=globalThis.navigator?.storage;if("function"!=typeof e?.estimate)return 0x40000000;let t=await (0,a.wrap)(()=>e.estimate());return(0,a.isErr)(t)||void 0===t.data.quota?0x40000000:Math.min(0x40000000,Math.floor(.4*t.data.quota))}e.s(["deleteCachedVideo",0,W,"hasCachedVideo",0,D,"readCachedVideo",0,q],488554);let N=new Set,G="stored",$="refused",B="failed";async function H({jobId:e,index:t=0}){let a=`${e}:${t}`;if(N.has(a))return!1;let n=g.get(a);if(n)return n;let o=J({jobId:e,index:t}).then(e=>(e===$&&N.add(a),e===G)).finally(()=>{g.delete(a),z.delete(a)});return z.delete(a),g.set(a,o),o}async function J({jobId:e,index:t}){let n;if(await D(e,t))return G;let o=await (0,a.wrap)(()=>fetch(d(e,t)));if((0,a.isErr)(o))return B;if(!o.data.ok)return await o.data.body?.cancel(),B;if(Number.isFinite(n=Number(o.data.headers.get("content-length")))&&n>0xc800000)return await o.data.body?.cancel(),$;let i=await (0,a.wrap)(()=>o.data.arrayBuffer());if((0,a.isErr)(i))return B;if(i.data.byteLength>0xc800000)return $;let r=Date.now(),s={jobId:e,index:t,contentType:o.data.headers.get("content-type")??"video/mp4",sizeBytes:i.data.byteLength,createdAt:r,lastAccessedAt:r};return(0,h.withLock)(F,()=>X(s,i.data,`${e}:${t}`))}async function X(e,t,o){if(z.has(o))return B;let i=await K();if(e.sizeBytes>i)return $;await Z(e,i);let r=await (0,a.wrap)(()=>j(e,t));if((0,a.isOk)(r))return G;if("QuotaExceededError"!==function(e){let t=(0,n.parseSchema)(y,e);if((0,a.isOk)(t))return t.data.name;let o=(0,n.parseSchema)(_,e);return(0,a.isErr)(o)?null:o.data.target.error.name}(r.error))return B;await E(await T());let s=await (0,a.wrap)(()=>j(e,t));return(0,a.isOk)(s)?G:$}async function Z(e,t){let a=function({entries:e,incomingBytes:t,budgetBytes:a,now:n}){let o=e=>b(e,n),i=e.filter(o),r=e.filter(e=>!o(e)).sort((e,t)=>e.lastAccessedAt-t.lastAccessedAt),s=[...i],l=r.reduce((e,t)=>e+t.sizeBytes,0),p=r.length;for(let e of r){if(l+t<=a&&p+ +(t>0)<=50)break;s.push(e),l-=e.sizeBytes,p-=1}return s}({entries:await T(),incomingBytes:e.sizeBytes,budgetBytes:t,now:e.createdAt});await E(a)}e.s(["cacheVideo",0,H,"refuseVideoCaching",0,function({jobId:e,index:t=0}){N.add(`${e}:${t}`)}],402432);var Q=e.i(885686);function Y(e){return e.flatMap(e=>e.data.type===Q.VIDEO_GENERATION_CALL_TYPE?[e.data.jobId]:[])}async function ee(e,t){await ea({jobIds:new Set(Y(e)),itemIds:new Set(e.map(e=>e.id))},t)}async function et(e,t,n){let o=await (0,a.wrap)(()=>en(e,t));(0,a.isErr)(o)||await ea(o.data,{namespace:e,roomIds:n})}async function ea(e,t){if(0===e.jobIds.size)return;let n=await eo(e,t);(0,a.isErr)(n)||await Promise.all([...e.jobIds].filter(e=>!n.data.has(e)).map(e=>(0,a.wrap)(()=>W(e))))}async function en(e,t){let a=await ei(e,t);return{jobIds:await er(e,a),itemIds:new Set(a)}}async function eo(e,t){return t&&0!==t.roomIds.length?(0,a.wrap)(async()=>{let a=await ei(t.namespace,t.roomIds);return er(t.namespace,a.filter(t=>!e.itemIds.has(t)),e.jobIds)}):(0,a.ok)(new Set)}async function ei(e,t){return(await Promise.all(t.map(t=>r.persistence.getRoomManifest(e,t)))).flatMap(e=>e.itemIds??[])}async function er(e,t,a){let n=new Set;for(let o=0;o{let o=e.items[t];if(o?.data.type!=="message"||!Array.isArray(o.data.content))return;o.data.content[n]||(o.data.content[n]={type:"output_text",text:"",annotations:[]});let i=o.data.content[n];i?.type==="output_text"&&(i.text+=a)},[el]:({draft:e,itemId:t,chunk:a,index:n})=>{let o=e.items[t];if(o?.data.type!=="reasoning")return;o.data.summary=o.data.summary??[],o.data.summary[n]||(o.data.summary[n]={type:"summary_text",text:""});let i=o.data.summary[n];i?.type==="summary_text"&&(i.text+=a)},[ep]:({draft:e,itemId:t,chunk:a,index:n})=>{let o=e.items[t];if(o?.data.type!=="reasoning")return;o.data.content=o.data.content??[],o.data.content[n]||(o.data.content[n]={type:"reasoning_text",text:""});let i=o.data.content[n];i?.type==="reasoning_text"&&(i.text+=a)},[ec]:({draft:e,itemId:t,chunk:a})=>{let n=e.items[t];n?.data.type==="function_call"&&(n.data.arguments+=a)},[eu]:({draft:e,itemId:o,chunk:i,index:r})=>{let s=e.items[o];if(s?.data.type!=="message"||!Array.isArray(s.data.content))return;let l=s.data.content[r];if(l?.type!=="output_text")return;let p=function(e){let o=(0,a.wrap)(()=>JSON.parse(e));if((0,a.isErr)(o))return;let i=(0,n.parseSchema)(t.OpenAIResponsesAnnotationSchema,o.data);if(!(0,a.isErr)(i))return i.data}(i);p&&(l.annotations=l.annotations??[],l.annotations.push(p))}};function ef(e,t){for(let{id:a,chunk:n,action:o,index:i}of t)(0,ez[o])({draft:e,itemId:a,chunk:n,index:i})}function ey(e){return em.some(t=>t.id===e)}function e_(e){let t=new Set([...em.map(e=>e.id),...eh.keys()]);for(let a of Object.keys(e.revealingItemIds))t.has(a)||delete e.revealingItemIds[a];for(let a of t)!0!==e.revealingItemIds[a]&&(e.revealingItemIds[a]=!0)}let eb=(0,o.create)()((0,i.mutative)((e,t)=>{let a=async e=>{let{storageInstanceId:a,rooms:n}=l.useChatroomStore.getState(),o=t().items[e];if(!a||!o)return;let i=Object.values(n).find(e=>o.messageId in e.messages);void 0!==i&&await r.persistence.saveItems(a,i.id,[o])},n=e=>{let t,n;c.set(e,()=>a(e)),(t=p.get(e))&&clearTimeout(t),n=setTimeout(()=>{let t=c.get(e);t&&t().finally(()=>{p.delete(e),c.delete(e)})},120),p.set(e,n)},o=()=>{(e(e=>{if(em.length>0){let t=Math.max(4,Math.ceil(em.reduce((e,t)=>e+t.chunk.length,0)/150)),{batch:a,remaining:n}=function(e,t){let a=[],n=0;for(let o=0;or&&a.length>0)return{batch:a,remaining:e.slice(o)};a.push(i),n+=i.chunk.length;continue}if(i.chunk.length<=r){a.push(i),n+=i.chunk.length;continue}return a.push({...i,chunk:i.chunk.slice(0,r)}),{batch:a,remaining:[{...i,chunk:i.chunk.slice(r)},...e.slice(o+1)]}}return{batch:a,remaining:[]}}(em,t);ef(e,a),em.splice(0,em.length,...n)}for(let[t,a]of eh)ey(t)||(e.items[t]=a,eh.delete(t),n(t));e_(e)}),em.length>0||eh.size>0)?requestAnimationFrame(o):eg=!1},i=()=>{eg||(eg=!0,requestAnimationFrame(o))},d=async()=>{(em.length>0||eh.size>0)&&(e(e=>{for(let[t,a]of(ef(e,em),em.length=0,eh))e.items[t]=a,n(t);eh.clear(),e_(e)}),eg=!1),await u()};{let e=()=>{d()};window.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&d()}),window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e)}let m=a=>{em.push({...a,atomic:ed.has(a.action)}),!0!==t().revealingItemIds[a.id]&&e(e=>{e.revealingItemIds[a.id]=!0}),i(),n(a.id)};return{items:{},revealingItemIds:{},actions:{loadItems:t=>e(e=>{Object.assign(e.items,t)}),clearAllItems:()=>{em.length=0,eh.clear(),eg=!1,(0,s.abortVideoPollsForItems)(Object.keys(t().items)),e(e=>{e.items={},e_(e)})},upsertItem:t=>{if(ey(t.id)){eh.set(t.id,t),e(e=>{e_(e)}),i();return}var a=t.id;for(let e=em.length-1;e>=0;e--)em[e].id===a&&em.splice(e,1);eh.delete(t.id),e(e=>{e.items[t.id]=t,n(t.id),e_(e)})},deleteItems:a=>{(0,s.abortVideoPollsForItems)(a);let{storageInstanceId:n,rooms:o}=l.useChatroomStore.getState();ee(a.flatMap(e=>t().items[e]??[]),n?{namespace:n,roomIds:Object.keys(o)}:void 0);let i=new Set(a);for(let e=em.length-1;e>=0;e--)i.has(em[e].id)&&em.splice(e,1);for(let e of a)eh.delete(e);e(e=>{let{storageInstanceId:t}=l.useChatroomStore.getState();for(let t of a)delete e.items[t],function(e){let t=p.get(e);t&&(clearTimeout(t),p.delete(e),c.delete(e))}(t);t&&a.length>0&&r.persistence.deleteItems(t,a),e_(e)})},editItemContent:(t,a)=>{e(e=>{let n=e.items[t];if(!n)return;let o=n.data;if("message"===o.type)if("assistant"===o.role)o.content=[{type:"output_text",text:a,annotations:[]}];else{let e=o.content;o.content=[{type:"input_text",text:a},...Array.isArray(e)?e.filter(e=>"input_text"!==e.type):[]]}}),n(t)},appendMessageText:(e,t,a)=>{m({id:e,chunk:t,action:es,index:a})},appendReasoningSummaryText:(e,t,a)=>{m({id:e,chunk:t,action:el,index:a})},appendReasoningContentText:(e,t,a)=>{m({id:e,chunk:t,action:ep,index:a})},appendFunctionArguments:(e,t)=>{m({id:e,chunk:t,action:ec,index:0})},appendAnnotation:(e,t,a)=>{m({id:e,chunk:JSON.stringify(a),action:eu,index:t})},flushAllPending:d}}}));e.s(["useItemStore",0,eb],735961)},621036,e=>{"use strict";e.s(["createSafeLocalStorage",0,function(){return{getItem:e=>{try{return localStorage.getItem(e)}catch{return null}},setItem:(e,t)=>{try{localStorage.setItem(e,t);return}catch(e){var a;if(a=e,!("u">typeof DOMException&&a instanceof DOMException)||"QuotaExceededError"!==a.name)return}try{localStorage.removeItem(e),localStorage.setItem(e,t)}catch{}},removeItem:e=>{try{localStorage.removeItem(e)}catch{}}}}])}]); //# sourceMappingURL=31fb0p4npy36w.js.map //# chunkId=01a090e3-1a44-7d20-8f06-1c01e5f0f3ec