@kyun.si/codex-hongguo 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/README.en.md +16 -5
- package/README.md +16 -5
- package/bin/run-node.exe +0 -0
- package/dist/cli/main.mjs +4 -4
- package/dist/server/index.mjs +26 -26
- package/dist/ui/player.html +1 -1
- package/package.json +3 -2
- package/skills/hongguo-setup/SKILL.md +2 -2
package/dist/ui/player.html
CHANGED
|
@@ -1967,7 +1967,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
1967
1967
|
- omitted: host decides border`)}),n3=E.object({method:E.literal("ui/request-display-mode"),params:E.object({mode:cl.describe("The display mode being requested.")})}),UF=E.object({mode:cl.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),FF=E.union([E.literal("model"),E.literal("app")]).describe("Tool visibility scope - who can access the tool."),r3=E.object({resourceUri:E.string().optional(),visibility:E.array(FF).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
1968
1968
|
- "model": Tool visible to and callable by the agent
|
|
1969
1969
|
- "app": Tool callable by the app from this server only`),csp:E.never().optional(),permissions:E.never().optional()}),i3=E.object({mimeTypes:E.array(E.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),s3=E.object({method:E.literal("ui/download-file"),params:E.object({contents:E.array(E.union([sS,oS])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),o3=E.object({method:E.literal("ui/message"),params:E.object({role:E.literal("user").describe('Message role, currently only "user" is supported.'),content:E.array(Ys).describe("Message content blocks (text, image, etc.).")})}),a3=E.object({method:E.literal("ui/notifications/sandbox-resource-ready"),params:E.object({html:E.string().describe("HTML content to load into the inner iframe."),sandbox:E.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:pS.optional().describe("CSP configuration from resource metadata."),permissions:gS.optional().describe("Sandbox permissions from resource metadata.")})}),zF=E.object({method:E.literal("ui/notifications/tool-result"),params:Js.describe("Standard MCP tool execution result.")}),EA=E.object({toolInfo:E.object({id:Zs.optional().describe("JSON-RPC id of the tools/call request."),tool:kf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:IF.optional().describe("Current color theme preference."),styles:CF.optional().describe("Style configuration for theming the app."),displayMode:cl.optional().describe("How the UI is currently displayed."),availableDisplayModes:E.array(cl).optional().describe("Display modes the host supports."),containerDimensions:E.union([E.object({height:E.number().describe("Fixed container height in pixels.")}),E.object({maxHeight:E.union([E.number(),E.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(E.union([E.object({width:E.number().describe("Fixed container width in pixels.")}),E.object({maxWidth:E.union([E.number(),E.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
1970
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:E.string().optional().describe("User's timezone in IANA format."),userAgent:E.string().optional().describe("Host application identifier."),platform:E.union([E.literal("web"),E.literal("desktop"),E.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:E.object({touch:E.boolean().optional().describe("Whether the device supports touch input."),hover:E.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:E.object({top:E.number().describe("Top safe area inset in pixels."),right:E.number().describe("Right safe area inset in pixels."),bottom:E.number().describe("Bottom safe area inset in pixels."),left:E.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),BF=E.object({method:E.literal("ui/notifications/host-context-changed"),params:EA.describe("Partial context update containing only changed fields.")}),l3=E.object({method:E.literal("ui/update-model-context"),params:E.object({content:E.array(Ys).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:E.record(E.string(),E.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),c3=E.object({method:E.literal("ui/initialize"),params:E.object({appInfo:nl.describe("App identification (name and version)."),appCapabilities:MF.describe("Features and capabilities this app provides."),protocolVersion:E.string().describe("Protocol version this app supports.")})}),jF=E.object({protocolVersion:E.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:nl.describe("Host application identification and version."),hostCapabilities:NF.describe("Features and capabilities provided by the host."),hostContext:EA.describe("Rich context about the host environment.")}).passthrough(),VF={target:"draft-2020-12"};async function xA(n,e){let t=n["~standard"];if(t.jsonSchema)return t.jsonSchema[e](VF);if(t.vendor==="zod"){let{z:i}=await Promise.resolve().then(()=>(Xa(),Hb));return i.toJSONSchema(n,{io:e})}throw Error(`Schema (vendor: ${t.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function _A(n,e,t=""){let i=await n["~standard"].validate(e);if(i.issues){let r=i.issues.map(s=>{let o=s.path?.map(a=>typeof a=="object"?a.key:a).join(".");return o?`${o}: ${s.message}`:s.message}).join("; ");throw Error(t+r)}return i.value}function IA(n){let e=document.documentElement;e.setAttribute("data-theme",n),e.style.colorScheme=n}function TA(n,e=document.documentElement){for(let[t,i]of Object.entries(n))i!==void 0&&e.style.setProperty(t,i)}var Af=class n extends hS{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:PF,toolinputpartial:RF,toolresult:zF,toolcancelled:LF,hostcontextchanged:BF};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!n.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},i={autoResize:!0}){super(i),this._appInfo=e,this._capabilities=t,this.options=i,i.allowUnsafeEval||E.config({jitless:!0}),this.setRequestHandler(qs,r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=bA(this._capabilities,e)}registerTool(e,t,i){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,s=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},o=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,s()},disable(){this.enabled=!1,s()},update(l){Object.assign(this,l),s()},remove(){r._registeredTools[e]===a&&(delete r._registeredTools[e],s())},handler:async(l,c)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let u;if(o){let d=a.inputSchema,f=d?await _A(d,l??{},`Invalid input for tool ${e}: `):l??{};u=await i(f,c)}else u=await i(c);return a.outputSchema&&!u.isError&&(u.structuredContent=await _A(a.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `)),u}};return this._registeredTools[e]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),s(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let i=this._registeredTools[e.name];if(!i)throw Error(`Tool ${e.name} not found`);return i.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([i,r])=>r.enabled).map(async([i,r])=>{let s={name:i,title:r.title,description:r.description,inputSchema:r.inputSchema?await xA(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(s.outputSchema=await xA(r.outputSchema,"output")),r.annotations&&(s.annotations=r.annotations),r._meta&&(s._meta=r._meta),s}))}))}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(OF,(t,i)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t.params,i)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(lS,(t,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,i)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(aS,(t,i)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,i)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(e){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},Js,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},tS,t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Qb,t)}async createSamplingMessage(e,t){this._assertInitialized("createSamplingMessage");let i=e.tools?uS:cS;return await this.request({method:"sampling/createMessage",params:e},i,t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},wF,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},gf,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},$F,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},AF,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},UF,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,i=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let o=document.documentElement,a=o.style.height;o.style.height="max-content";let l=Math.ceil(o.getBoundingClientRect().height);o.style.height=a;let c=Math.ceil(window.innerWidth);(c!==t||l!==i)&&(t=c,i=l,this.sendSizeChanged({width:c,height:l}))}))};r();let s=new ResizeObserver(r);return s.observe(document.documentElement),s.observe(document.body),()=>s.disconnect()}async connect(e=new mS(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(e);try{let i=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:_F}},jF,t);if(i===void 0)throw Error(`Server sent invalid initialize result: ${i}`);this._hostCapabilities=i.hostCapabilities,this._hostInfo=i.hostInfo,this._hostContext=i.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(i){throw this.close(),i}}};function kA(n,e,t){let i,r=!1,s=()=>{r||i!==void 0||(i=requestAnimationFrame(()=>{i=void 0,!(r||!e())&&t(n.hidden?1:Math.max(1,Math.ceil(n.getBoundingClientRect().height)))}))},o=new ResizeObserver(s);return o.observe(n),s(),{refresh:s,dispose(){r=!0,o.disconnect(),i!==void 0&&cancelAnimationFrame(i)}}}var $A={name:"@kyun.si/codex-hongguo",version:"0.0.28",private:!0,license:"MIT",type:"module",engines:{node:">=22.16"},scripts:{"version:patch":"npm version patch --no-git-tag-version",preversion:"node scripts/version.mjs --next",version:"node scripts/version.mjs --sync",prebuild:"node scripts/version.mjs",build:"node scripts/build.mjs",test:"npm run build && node scripts/prepare-media.mjs && node --test test/*.test.mjs",package:"npm run build && node scripts/package.mjs","verify:install":"node scripts/verify-install.mjs","release:publish":"node scripts/publish.mjs"},dependencies:{"@modelcontextprotocol/ext-apps":"1.7.5","@modelcontextprotocol/sdk":"1.32.2","cross-spawn":"7.0.6",fflate:"0.8.3","hls.js":"1.7.4","m3u8-parser":"7.2.1","mpd-parser":"1.4.1",openhongguo:"0.2.0","xz-decompress":"0.2.3",zod:"4.6.7"},devDependencies:{"@types/node":"22.20.5",esbuild:"0.28.2",typescript:"5.9.3"}};var Hr=document.documentElement.dataset.host==="browser",wA=document.documentElement.dataset.surface==="waiting",yS="",Yn=Hr?null:new Af({name:"\u7EA2\u679C\u77ED\u5267",version:$A.version},{},{autoResize:!wA}),vS,PA=()=>Yn?.getHostContext()?.locale||navigator.language,wf=()=>Yn?.getHostContext()?.displayMode;async function RA(){if((await Yn?.requestDisplayMode({mode:"fullscreen"},{timeout:5e3}))?.mode!=="fullscreen")throw Error("\u5F53\u524D Codex \u65E0\u6CD5\u5728\u4F1A\u8BDD\u4E2D\u6253\u5F00\u64AD\u653E\u5668")}function AA(n){n&&(n.theme&&IA(n.theme),n.styles?.variables&&TA(n.styles.variables))}async function LA(n,e,t){if(Hr){let i=await fetch("context",{signal:AbortSignal.timeout(4e3)});if(!i.ok)throw Error("\u5206\u5C4F\u5DF2\u5931\u6548\uFF0C\u8BF7\u4ECE\u9762\u677F\u91CD\u65B0\u6253\u5F00");n(await i.json());return}Yn.ontoolresult=i=>{if(typeof i._meta?.panel!="string")return;yS=i._meta.panel;let r=typeof i._meta.waitingTurn=="string"?i._meta.waitingTurn:void 0;n({identified:!!i.structuredContent?.identified||!!r,waitingTurn:r})},Yn.onteardown=async()=>(vS?.dispose(),await e(),{}),Yn.onhostcontextchanged=i=>{AA(i),i.displayMode!==void 0&&(t(),vS?.refresh())},await Yn.connect(),AA(Yn.getHostContext()),wA&&(vS=kA(document.getElementById("waitingCard"),()=>(wf()||"inline")==="inline",i=>{Yn.sendSizeChanged({height:i}).catch(()=>{})})),t()}async function $e(n,e={},t=15e3){if(Hr){let r=await fetch("api/"+n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:n==="save_progress",signal:AbortSignal.timeout(t)}),s=await r.json();if(!r.ok)throw Error(s.error||"\u5206\u5C4F\u8FDE\u63A5\u5DF2\u4E2D\u65AD");return s}if(!yS)throw Error("\u7B49\u5F85\u4F1A\u8BDD\u9762\u677F\u8FDE\u63A5");let i=await Yn.callServerTool({name:n,arguments:{...e,panel:yS}},{timeout:t});if(i.isError)throw Error(i.content?.[0]?.type==="text"?i.content[0].text:"\u672C\u673A\u670D\u52A1\u4E0D\u53EF\u8FBE");return i._meta?.data}var bS="https://hongguo.invalid/";function DA(n,e,t,i,r,s){if(!nr.isSupported())throw Error("\u5F53\u524D\u9762\u677F\u4E0D\u652F\u6301\u5206\u6BB5\u89E3\u7801\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F");class o{context=null;stats=new oi;abort(){this.stats.aborted=!0}destroy(){this.abort()}load(d,f,h){this.context=d,this.stats.loading.start=performance.now(),(async()=>{let p=d.url.slice(bS.length);if(!d.url.startsWith(bS))throw Error("\u65E0\u6548\u5A92\u4F53\u6765\u6E90");if(p==="index.m3u8")return i;let g=0,y;do{let b=await $e("read_panel_chunk",{episodeId:e,stream:t,asset:p,offset:g},8e3);if(this.stats.aborted)return;if(!Number.isSafeInteger(b.size)||b.size<1||b.size>32*1024*1024)throw Error("\u5206\u6BB5\u957F\u5EA6\u65E0\u6548");y??=new Uint8Array(b.size);let S=atob(b.bytes);if(b.size!==y.length||!S.length||g+S.length>b.size)throw Error("\u5206\u6BB5\u4E0D\u5B8C\u6574");for(let x=0;x<S.length;x++)y[g+x]=S.charCodeAt(x);g+=S.length}while(g<y.length);return y.buffer})().then(p=>{this.stats.aborted||p===void 0||(this.stats.loading.first=this.stats.loading.end=performance.now(),this.stats.loaded=this.stats.total=typeof p=="string"?p.length:p.byteLength,h.onSuccess({url:d.url,data:p},this.stats,d,null))}).catch(()=>{this.stats.aborted||h.onError({code:0,text:"\u4FA7\u680F\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25"},d,null,this.stats)})}}let a=new nr({loader:o,enableWorker:!1,maxBufferLength:16,maxMaxBufferLength:24,backBufferLength:12});a.on(nr.Events.MEDIA_ENDED,s),a.on(nr.Events.ERROR,(u,d)=>{d.fatal&&(d.type===nr.ErrorTypes.NETWORK_ERROR?r("\u4FA7\u680F\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD"):r("\u4FA7\u680F\u65E0\u6CD5\u5904\u7406\u89C6\u9891\u5206\u6BB5\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F"))});let l=u=>{u.disposition==="enforce"&&u.effectiveDirective==="media-src"&&(u.blockedURI==="blob"||u.blockedURI.startsWith("blob:"))&&r("\u684C\u9762\u5B89\u5168\u7B56\u7565\u963B\u6B62\u4E86\u4FA7\u680F\u8F7D\u5165\u672C\u5730\u89C6\u9891")},c=()=>{document.removeEventListener("securitypolicyviolation",l),a.destroy()};document.addEventListener("securitypolicyviolation",l);try{a.loadSource(bS+"index.m3u8"),a.attachMedia(n)}catch(u){throw c(),u}return c}function SS(n){switch(n){case 1:return"\u89C6\u9891\u52A0\u8F7D\u5DF2\u4E2D\u6B62\uFF0C\u53EF\u4EE5\u91CD\u65B0\u70B9\u64AD";case 2:return"\u8BFB\u53D6\u89C6\u9891\u6570\u636E\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD";case 3:return"\u64AD\u653E\u5668\u89E3\u7801\u89C6\u9891\u6570\u636E\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F";case 4:return"\u64AD\u653E\u5668\u65E0\u6CD5\u6253\u5F00\u89C6\u9891\u6765\u6E90\uFF0C\u53EF\u91CD\u65B0\u70B9\u64AD\u6216\u4F7F\u7528\u540C\u7A97\u5206\u5C4F";default:return"\u89C6\u9891\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD"}}function CA(n,e){return new Promise((t,i)=>{let r=()=>l(),s=()=>l(Error(SS(n.error?.code))),o=()=>l(e.reason),a=setTimeout(()=>l(Error("\u7B49\u5F85\u89C6\u9891\u5143\u6570\u636E\u8D85\u65F6\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD")),3e4);function l(c){clearTimeout(a),n.removeEventListener("loadedmetadata",r),n.removeEventListener("error",s),e.removeEventListener("abort",o),c!==void 0?i(c):t()}n.addEventListener("loadedmetadata",r),n.addEventListener("error",s),e.addEventListener("abort",o),e.aborted&&o()})}function OA(n,e){return!!n&&!!e.turnId&&e.state==="submitted"&&n.turnId!==e.turnId}function NA(n,e){return!n||!e.turnId||e.state!=="stopped"&&e.state!=="interrupted"||n.turnId===e.turnId&&n.state!=="submitted"?null:e.state==="interrupted"?"\u672C\u8F6E\u5DF2\u4E2D\u65AD\uFF0C\u5DF2\u4E3A\u4F60\u6682\u505C":"\u672C\u8F6E\u5DF2\u505C\u6B62\uFF0C\u5DF2\u4E3A\u4F60\u6682\u505C"}function _S(n){return n.episodeId?st(n.kind==="next"?"\u770B\u4E0B\u4E00\u96C6":"\u7EE7\u7EED\u89C2\u770B")+" \xB7 "+n.title:n.title}function xS(n,e){return e.aborted?Promise.resolve(!1):new Promise(t=>{let i=new IntersectionObserver(a=>{let l=a[a.length-1];!document.hidden&&l.isIntersecting&&l.intersectionRect.width>0&&l.intersectionRect.height>0&&r(!0)},{threshold:[0,.01]}),r=a=>{i.disconnect(),document.removeEventListener("visibilitychange",o),e.removeEventListener("abort",s),t(a)},s=()=>r(!1),o=()=>{document.hidden||(i.unobserve(n),i.observe(n))};e.addEventListener("abort",s),document.addEventListener("visibilitychange",o),i.observe(n)})}async function ES(n,e,t,i,r,s=!1){let o=i?{turnId:i}:{};if(e.replaceChildren(),n.hidden=!1,!await xS(n,t))return;let{items:a}=await $e("get_waiting_picks",{...o,inView:!0},9e4);if(!t.aborted){if(!a.length){s?r([]):n.hidden=!0;return}if(r(a),!!await xS(e,t))try{await $e("mark_waiting_picks_shown",o)}catch{await xS(e,t)&&await $e("mark_waiting_picks_shown",o).catch(()=>{})}}}function MA(n,e){let t=document.getElementById("waitingCard"),i=document.getElementById("waitingTitles"),r=document.getElementById("waitingMessage"),s=document.getElementById("waitingDismiss"),o=!1,a=!1,l=!1,c=!1,u=!0,d=!1,f=0,h,m,p,g;function y(){++f,m?.abort(),m=void 0,t.hidden=!0,i.replaceChildren(),r.textContent=""}s.onclick=()=>{c=!0,y(),$e("dismiss_waiting_picks").catch(()=>{})};function b($){!o||c||!u||a||(r.textContent=st($ instanceof Error?$.message:"\u5F53\u524D Codex \u65E0\u6CD5\u5728\u4F1A\u8BDD\u4E2D\u6253\u5F00\u64AD\u653E\u5668"),t.hidden=!1)}async function S($=!1){if(!o)return;let P=wf()||"inline";if(!$&&P===h)return;h=P;let k=++f;m?.abort();let D=m=new AbortController;if(P==="fullscreen"){if(a)return;let V=await(p??=$e("activate_waiting_player"));if(k!==f)return;a=!0,t.hidden=!0,document.documentElement.dataset.surface="player",n(V);return}else p=void 0,a&&(a=!1,e(),document.documentElement.dataset.surface="waiting");if(c){y();return}let U=await $e("get_waiting_status");if(k===f){if(u=U.visible,!u){y();return}r.textContent="",await ES(t,i,D.signal,void 0,V=>{let X=V.map(F=>{let z=document.createElement("button");return z.type="button",z.textContent=_S(F),z.onclick=()=>{x(F)},z}),q=document.createElement("button");q.type="button",q.textContent=st("\u66F4\u591A\u2026"),q.onclick=()=>{x()},i.replaceChildren(...X,q)},!0).catch(V=>{D.signal.aborted||b(V)})}}async function x($){if(!l){l=!0,r.textContent="";try{$?await $e("select_waiting_pick",{seriesId:$.id}):await $e("browse_waiting_catalog"),wf()==="fullscreen"?await S(!0):(await RA(),t.hidden=!0)}catch(P){b(P),P instanceof Error&&P.message==="\u8FD9\u6761\u63A8\u8350\u5DF2\u7ED3\u675F"&&y()}finally{l=!1}}}async function _(){if(!(!o||a||l||c||document.hidden||d)){d=!0;try{let $=await $e("get_waiting_status");if(!o||a||l||c)return;$.visible!==u&&(u=$.visible,u?await S(!0):y())}catch{!a&&!l&&(u=!1,y())}finally{d=!1}}}let I=()=>{S().catch(b)},T=()=>{!document.hidden&&o&&!a&&!c&&S(!0).catch(b)};return{connected(){o||(o=!0,g=setInterval(()=>{_()},1e3),document.addEventListener("visibilitychange",T),I())},modeChanged:I,dispose(){o=!1,clearInterval(g),document.removeEventListener("visibilitychange",T),y()}}}var j=n=>document.getElementById(n),re=document.querySelector("video"),qr=j("seek"),TS=j("play"),Rf=j("center"),Ki=j("autonext"),zn=(n,e)=>{j(n).textContent=n==="title"?e:st(e)},We=n=>zn("notice",n),Ct=n=>n instanceof Error?n.message:"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",eo=n=>Math.floor(n/60)+":"+String(Math.floor(n%60)).padStart(2,"0"),KF=n=>new Promise(e=>setTimeout(e,n));function An(n,e){let t=document.createElement("button");return t.textContent=st(n),t.onclick=()=>{Promise.resolve(e()).catch(i=>We(Ct(i)))},t}var hr={identified:!1},Zt=null,at=null,Xe=null,Ze=[],Tt,hl="",Tn,yt=[],kn=!1,ct=0,Jn=0,Vi=0,$n=!1,Dt=!1,IS,kS=0,Zr=Promise.resolve(),qt={autoPrompt:!0,autoplayNext:!0,autoPauseOnFinish:!0,autoPlayOnStart:!0,searchTerms:["\u603B\u88C1","\u91CD\u751F","\u9006\u88AD"]},un="idle",Wr,$S,ul,Qs=0,dl=0,mr=[],Lf=null,BA=document.documentElement.dataset.surface==="waiting",jA=Array.from(crypto.getRandomValues(new Uint32Array(4)),n=>n.toString(16).padStart(8,"0")).join(""),fl=!1,VA,UA=null,FA,AS,pr;function Cf(){pr=void 0;let n=AS;AS=void 0,n&&$e("confirm_waiting_playback",{playbackId:n},1800).catch(()=>{})}function Hi(){TS.disabled=Rf.disabled=!Xe?.playable,j("pair").disabled=!Xe;let n=st($n?"\u53D6\u6D88\u51C6\u5907":re.paused?"\u64AD\u653E":"\u6682\u505C"),e=$n?"x":re.paused?"play":"pause";ro(TS,e,n),ro(Rf,e,n),j("stage").classList.toggle("playing",!re.paused),j("stage").classList.toggle("busy",$n),j("prev").disabled=!Xe||!Ze.slice(0,Ze.indexOf(Xe)).some(t=>t.playable),j("next").disabled=!Xe||!Tt&&!Ze.slice(Ze.indexOf(Xe)+1).some(t=>t.playable),Rf.hidden=$n,document.querySelectorAll("#episodes button").forEach(t=>t.setAttribute("aria-pressed",String(t.dataset.id===Xe?.id)))}function qi(n=!1){if(!kn||!at||!Xe||!Number.isFinite(re.duration)||!re.duration||!re.currentTime&&!n)return Zr;let e={seriesId:at.id,episodeId:Xe.id,title:at.title,label:Xe.label,positionMs:Math.round((un==="finished"||re.ended?re.duration:re.currentTime)*1e3),durationMs:Math.round(re.duration*1e3)};return Zr=Zr.then(()=>$e("save_progress",{...e,...n&&e.positionMs===0?{reset:!0}:{}},1800)).then(()=>{}).catch(()=>We("\u89C2\u770B\u8FDB\u5EA6\u6682\u672A\u5199\u5165\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u670D\u52A1")),Zr}function cn(n="",e=!1){e||(pr=void 0),n==="\u5DF2\u624B\u52A8\u6682\u505C"&&Cf(),ct++,Wr=void 0,$n=!1,un!=="finished"&&(un="idle"),re.pause(),Hi();let t=!!at&&/本轮已停止|本轮已中断/.test(n);return n&&We(t?"":n),j("stopped").hidden=!t,t&&zn("whyStopped",n),qi()}function Yr(){kn=!1,un="idle",ul?.abort(),ul=void 0,j("stopped").hidden=!0,j("resumed").hidden=!0,$S?.(),$S=void 0,re.removeAttribute("src"),re.load()}function GA(n){cn("",!0),Yr(),j("link").hidden=!0,j("linkValue").value="",Xe=n,Qs=Math.floor(Math.max(0,Ze.indexOf(n))/50),We("");let e="\u7B2C "+n.number+" \u96C6",t=n.label.replace(/\s/g,"")!=="\u7B2C"+n.number+"\u96C6";zn("subtitle",[e,t?n.label:"",n.codec].filter(Boolean).join(" \xB7 ")),zn("time","0:00"),qr.value="0",gl(qr),Hi(),n.playable||We("\u8BE5\u96C6\u5F53\u524D\u4E0D\u53EF\u64AD\u653E\uFF0C\u8BF7\u68C0\u67E5\u7247\u6E90\u8BB8\u53EF\u6216 FFmpeg \u81EA\u68C0\u7ED3\u679C")}function ml(){let n=Math.ceil(Ze.length/50);j("groups").replaceChildren(...Array.from({length:n>1?n:0},(e,t)=>{let i=An(Ze[t*50].number+"\u2013"+Ze[Math.min(Ze.length,(t+1)*50)-1].number,()=>{Qs=t,ml()});return i.setAttribute("aria-pressed",String(t===Qs)),i})),j("episodes").replaceChildren(...Ze.slice(Qs*50,(Qs+1)*50).map(e=>{let t=An(String(e.number),()=>Of(e));return t.disabled=!e.playable,t.title=e.label,t.dataset.id=e.id,t})),j("moreEpisodes").hidden=!Tt,j("episodeCount").textContent=Ze.length?st(Ze.length+(Tt?"+":"")+" \u96C6"):"",Hi()}async function to(n,e,t=!1,i){let r=i&&e;j("home").hidden=!0,j("watch").hidden=!1,j("back").focus({preventScroll:!0}),window.scrollTo(0,0),Qs=0;let s=++Jn;cn(),pr=t?i:void 0;let o=ct;Yr(),Xe=null,Ze=[],Tt=void 0,at=n,Zi(),re.poster=n.cover||"",zn("title",n.title),zn("subtitle","\u6B63\u5728\u8BFB\u53D6\u5206\u96C6\u2026"),ml(),ZA(),await Zr;let[a,l]=await Promise.all([$e("get_episodes",{seriesId:n.id}),$e("get_history",{seriesId:n.id})]);e??=l.items[0]?.episodeId;let c=a;if(s!==Jn)return;Ze=c.items||[],Tt=c.cursor;let u=new Set;for(;e&&!Ze.some(h=>h.id===e)&&Tt&&!u.has(Tt);){if(u.add(Tt),c=await $e("get_episodes",{seriesId:n.id,cursor:Tt}),s!==Jn)return;Ze.push(...c.items),Tt=c.cursor}let d=e&&Ze.find(h=>h.id===e&&(!t||h.playable))||!r&&(t&&Ze.find(h=>h.playable)||Ze[0]),f=t&&Dt&&(ct===o||!!i&&pr===i);d?GA(d):zn("subtitle","\u6682\u65E0\u53EF\u7528\u5206\u96C6"),ml(),f&&d&&s===Jn&&await no(i)}async function Of(n){GA(n),ml(),await no()}async function KA(){if(!at||!Tt)return;let n=Jn,e=Tt;try{let t=await $e("get_episodes",{seriesId:at.id,cursor:e});if(n!==Jn||e!==Tt)return;Ze.push(...t.items),Tt=t.cursor===e?void 0:t.cursor,ml()}catch(t){We(Ct(t))}}j("moreEpisodes").onclick=KA;async function HA(n=!1){if(!Xe)return;let e=Xe.id,t=Jn,i=ct,r=Ze.slice(Ze.indexOf(Xe)+1).find(o=>o.playable),s=new Set;for(;!r&&Tt&&!s.has(Tt);){if(s.add(Tt),await KA(),Jn!==t||Xe?.id!==e||ct!==i)return;r=Ze.slice(Ze.indexOf(Xe)+1).find(o=>o.playable)}!Dt||n&&!Ki.checked||(r?await Of(r):n&&cn("\u672C\u96C6\u5DF2\u64AD\u5B8C"))}j("prev").onclick=()=>{let n=Ze.slice(0,Ze.indexOf(Xe)).reverse().find(e=>e.playable);n&&Of(n)};j("next").onclick=()=>{HA()};j("random").onclick=()=>{let n=Ze.filter(r=>r.playable),e=mr.find(r=>r.seriesId===at?.id),t=e?n.findIndex(r=>r.id===e.episodeId):-1,i=t<0?n.slice(0,1):n.slice(Math.min(t+1,n.length-1));i.length&&Of(i[Math.floor(Math.random()*i.length)])};async function HF(){Cf(),document.fullscreenElement&&await document.exitFullscreen(),j("stage").classList.remove("expanded"),Df(),We(""),++Jn;let n=cn();Yr(),Xe=null,at=null,Ze=[],Tt=void 0,j("home").hidden=!1,j("watch").hidden=!0,j("link").hidden=!0,yt.length?Gi():Jr(),await n,await Nf(),!at&&yt.length&&Gi()}j("back").onclick=()=>{HF().catch(n=>We(Ct(n)))};function ZA(){document.querySelectorAll(".card").forEach(n=>n.setAttribute("aria-pressed",String(n.dataset.id===at?.id)))}function Gi(){let n=[],e=new Set(mr.map(o=>o.seriesId)),t=hl?void 0:yt.find(o=>!e.has(o.id))||yt[0],i=yt.filter(o=>o!==t),r=YA();if(r&&n.push(r),j("featured").replaceChildren(),t){let o=An("",()=>to(t,void 0,!0)),a=vl(t.title,t.episodes?st(t.episodes+" \u96C6"):""),l=document.createElement("span"),c=document.createElement("small"),u=document.createElement("strong"),d=document.createElement("span");if(o.className="feature",o.dataset.id=t.id,o.setAttribute("aria-label",st("\u64AD\u653E")+" \xB7 "+t.title),l.className="featureText",c.className="eyebrow",c.textContent=st(e.has(t.id)?"\u770B\u8FC7":"\u63A8\u8350"),u.textContent=t.title,l.append(c,u),t.description){let f=document.createElement("span");f.className="desc",f.textContent=t.description,l.append(f)}d.className="playPill",d.append(Wi("play"),st("\u64AD\u653E")),l.append(d),o.append(a,l),j("featured").append(o),n.push({span:a,s:t})}Zi(),j("cards").replaceChildren(...i.slice(dl*12,(dl+1)*12).map(o=>{let a=An("",()=>to(o,void 0,!0));a.className="card",a.dataset.id=o.id,a.title=o.title;let l=vl(o.title,o.episodes?st(o.episodes+" \u96C6"):""),c=document.createElement("span");return c.className="cardTitle",c.textContent=o.title,a.append(l,c),n.push({span:l,s:o}),a})),ZA();let s=Vi;(async()=>{for(let{span:o,s:a}of n){if(s!==Vi)return;if(!a.cover&&(a.hasCover||a.lookupCover))try{a.cover=(await $e("get_cover",{seriesId:a.id},9e3)).cover}catch{}a.cover&&(NS(o,a.cover),at?.id===a.id&&(re.poster=a.cover))}})()}function Zi(){let e=qt.autoPrompt&&!!Zt?.turnId&&Zt.state==="submitted"&&!at&&!hl&&yt.length>0&&Lf!==Zt.turnId?Zt.turnId:null;if(e===UA)return;UA=e,FA?.abort();let t=j("prompt"),i=j("picks");if(!e){t.hidden=!0;return}let r=FA=new AbortController;ES(t,i,r.signal,e,s=>{i.replaceChildren(...s.map(o=>An(_S(o),()=>($e("mark_waiting_picks_shown",{turnId:e}).catch(()=>{}),to(yt.find(a=>a.id===o.id)??o,o.episodeId,!0,e)))),An("\u66F4\u591A\u2026",()=>{qA(),j("query").focus()}))}).catch(()=>{r.signal.aborted||(t.hidden=!0)})}function qA(){Lf=Zt?.turnId||null,Lf&&$e("dismiss_waiting_picks",{turnId:Lf}).catch(()=>{}),Zi()}j("dismiss").onclick=qA;function Xs(n,e=""){let t=j("catalogStatus"),i=j("cards"),r=j("query");if(t.dataset.state=n==="loading"&&yt.length?"busy":n,t.replaceChildren(),e){let s=document.createElement("span");s.textContent=st(e),t.append(s)}t.dataset.state==="busy"&&t.prepend(Wi("spin")),n==="error"&&t.append(An("\u91CD\u8BD5",()=>Jr())),n==="empty"&&hl&&t.append(An("\u6E05\u9664\u641C\u7D22",()=>(r.value="",Jr(!1,"")))),t.querySelectorAll("button").forEach(s=>s.className="btn"),n==="loading"&&!yt.length?i.replaceChildren(...Array.from({length:6},()=>{let s=document.createElement("div"),o=document.createElement("span"),a=document.createElement("span");return s.className="skel",s.setAttribute("aria-hidden","true"),o.className="skelArt",a.className="skelLine",s.append(o,a),s})):i.querySelector(".skel")&&i.replaceChildren()}async function Jr(n=!1,e=hl){let t=++Vi;n||(hl=e,yt=[],Tn=void 0,dl=0,Gi());let i=n?dl+1:0;j("more").hidden=!0,Xs("loading","\u6B63\u5728\u8BFB\u53D6\u7247\u5E93\u2026");let r=n?[...yt]:[],s=!1;!n&&!e&&$e("list_series",{preview:!0},9e4).then(o=>{t!==Vi||s||!o.items.length||(yt=o.items,Gi(),j("catalogStatus").dataset.state!=="error"&&Xs(""),j("more").hidden=yt.length<=13)}).catch(()=>{});try{let o=new Set,a=(i+1)*12+(e?0:1),l=!n;for(;l||r.length<a&&Tn&&!o.has(Tn);){l=!1,Tn&&o.add(Tn);let u=await $e("list_series",{query:e,cursor:Tn},9e4);if(t!==Vi)return;let d=new Set(r.map(f=>f.id));for(let f of u.items)d.has(f.id)||(d.add(f.id),r.push(f));Tn=u.cursor,Tn&&o.has(Tn)&&(Tn=void 0)}s=r.length>0,s&&(yt=r);let c=Math.max(1,Math.ceil((yt.length-(e?0:1))/12));if(n&&i>=c&&!Tn&&!e){await Jr();return}dl=i%c,Gi(),yt.length?Xs(""):e?Xs("empty","\u6CA1\u6709\u627E\u5230\u76F8\u7B26\u7684\u5267\u76EE"):Xs("error","\u7EA2\u679C\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u63A8\u8350\u5267\u76EE"),j("more").hidden=c<=1&&!Tn}catch(o){t===Vi&&(Xs("error",Ct(o)),j("more").hidden=!n)}}async function Nf(){mr=(await $e("get_history")).items,YA(),j("history").replaceChildren(...mr.map(n=>{let e=document.createElement("div"),t=document.createElement("strong"),i=document.createElement("small");e.className="historyRow";let r=An("",()=>WA(n));r.className="historyItem",t.textContent=n.title,i.textContent=n.label+" \xB7 "+eo(n.positionMs/1e3),r.append(t,i);let s=An("",async()=>{await Zr,await $e("remove_history",{seriesId:n.seriesId}),await Nf(),Gi()}),o=st("\u79FB\u9664 "+n.title+" \u7684\u89C2\u770B\u5386\u53F2");return s.className="icon sm",s.setAttribute("aria-label",o),s.title=o,s.append(Wi("x")),e.append(r,s),e})),j("historyCount").textContent=mr.length?String(mr.length):"",j("resume").hidden=!mr.length}function WA(n){return to(yt.find(e=>e.id===n.seriesId)||{id:n.seriesId,title:n.title},n.episodeId,!0)}function YA(){let n=mr[0];if(!n){j("continue").replaceChildren();return}let e=yt.find(f=>f.id===n.seriesId)||{id:n.seriesId,title:n.title},t=An("",()=>WA(n)),i=vl(n.title),r=document.createElement("span"),s=document.createElement("small"),o=document.createElement("strong"),a=document.createElement("span"),l=document.createElement("span"),c=document.createElement("i"),u=document.createElement("span"),d=n.durationMs?Math.min(1,n.positionMs/n.durationMs):0;return t.className="resumeCard",t.setAttribute("aria-label",st("\u7EE7\u7EED\u89C2\u770B \xB7 "+n.title+" \xB7 "+n.label)),r.className="resumeText",s.className="eyebrow",s.textContent=st("\u7EE7\u7EED\u89C2\u770B"),o.textContent=n.title,a.className="meta",a.textContent=n.label+" \xB7 "+eo(n.positionMs/1e3)+(n.durationMs?" / "+eo(n.durationMs/1e3):""),l.className="bar",c.style.setProperty("--p",(d*100).toFixed(1)+"%"),l.append(c),r.append(s,o,a,l),u.className="resumePlay",u.append(Wi("play")),t.append(i,r,u),j("continue").replaceChildren(t),{span:i,s:e}}function JA(){let n=Zt?.state==="submitted";j("lamp").classList.toggle("on",n),zn("state",!hr.identified&&Hr?"\u672A\u5173\u8054\u5BF9\u8BDD":!Zt||Zt.state==="unknown"?"\u7B49\u5F85\u56DE\u5408\u5F00\u59CB":n?"\u5F53\u524D\u56DE\u5408\u8FDB\u884C\u4E2D":Zt.state==="interrupted"?"\u56DE\u5408\u5DF2\u4E2D\u65AD":"\u56DE\u5408\u5DF2\u505C\u6B62")}function Mf(){return Dt?(IS??=ZF().finally(()=>{IS=void 0}),IS):Promise.resolve()}async function ZF(){try{let n=await $e("get_run_state",{observeSession:!0,playerInstance:document.hidden?void 0:jA},1800);if(!Dt)return;if(n.preferences){let r=qt.autoPrompt!==n.preferences.autoPrompt;qt=n.preferences,Ki.checked=qt.autoplayNext,r&&Zi()}let e=NA(Zt,n),t=OA(Zt,n),i=Zt?.state!==n.state||Zt?.turnId!==n.turnId;Zt=n,i&&Zi(),JA(),e&&at&&qt.autoPauseOnFinish?cn(e):t&&qt.autoPlayOnStart&&at&&Xe?.playable&&re.paused&&!$n&&no(n.turnId,!0)}catch{if(!Dt)return;j("lamp").classList.remove("on"),zn("state","\u672C\u673A\u72B6\u6001\u4E0D\u53EF\u8FBE")}}function qF(){let n=re.duration;!Number.isFinite(n)||!kn||(qr.value=String(Math.round(re.currentTime/n*1e3)),gl(qr),zn("time",eo(re.currentTime)+" / "+eo(n)))}async function no(n,e=!1){if(!Xe?.playable||!at||!Dt)return;pr=e?void 0:n;let t=++ct,i=Xe,r=at;$n=!0,Hi(),j("stopped").hidden=!0;try{if(!kn){We("\u6B63\u5728\u51C6\u5907\u64AD\u653E\u2026");let s=await $e("prepare_playback",{episodeId:i.id,retry:!0}),o=Date.now()+24e4;for(;s.status==="preparing"&&t===ct&&Date.now()<o;){if(We("\u6B63\u5728\u672C\u673A\u51C6\u5907\u6574\u96C6\u2026"),await KF(700),t!==ct)return;s=await $e("prepare_playback",{episodeId:i.id})}if(t!==ct)return;if(s.status!=="ready")throw Error(s.reason||"\u51C6\u5907\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5");let a=s;if(Hr!=="src"in a)throw Error("\u672C\u96C6\u64AD\u653E\u5730\u5740\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u8BD5");await Zr;let l=await $e("get_history",{seriesId:r.id,episodeId:i.id});if(t!==ct)return;Yr();let c=new AbortController;ul=c;let u=CA(re,c.signal),d=m=>{ul===c&&(c.abort(Error(m)),kn&&(cn(m),Yr()))};try{"stream"in a?$S=DA(re,i.id,a.stream,a.manifest,d,()=>{ul===c&&XA()}):(re.src=a.src,re.load())}catch(m){d(Ct(m))}if(await u,t!==ct)return;let f=l.items[0],h=f&&f.positionMs<f.durationMs?f.positionMs/1e3:0;re.currentTime=h>0&&h<re.duration-5?h:0,re.currentTime>0&&(zn("resumeTime","\u5DF2\u4ECE "+eo(h)+" \u7EE7\u7EED"),j("resumed").hidden=!1),kn=!0}if(n){let s=await $e("get_run_state",{observeSession:!0},1800);if(t!==ct)return;if(s.turnId!==n||s.state!=="submitted"||e&&!s.preferences?.autoPlayOnStart){cn(e?"":"\u63A8\u8350\u6240\u5C5E\u4EFB\u52A1\u5DF2\u7ED3\u675F\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED\u89C2\u770B");return}}if(t!==ct||!Dt)return;$n=!1,un==="finished"&&(re.currentTime=0),un="playing",re.playbackRate=parseFloat(j("speed").value),n&&!e&&(re.muted=!0);try{await re.play()}catch(s){if(t!==ct||!Dt)return;if(!(s instanceof DOMException&&["AbortError","NotAllowedError"].includes(s.name))||!document.hidden&&document.hasFocus()&&Wr?.action!==t)throw s instanceof DOMException&&s.name==="NotAllowedError"&&n&&!e?Error("\u5BBF\u4E3B\u963B\u6B62\u4E86\u81EA\u52A8\u64AD\u653E\uFF0C\u8BF7\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED"):s;Ff();return}t===ct&&(Cf(),We("\u6B63\u5728\u64AD\u653E"),kS=Date.now(),Hi())}catch(s){t===ct&&(kn||Yr(),cn(Ct(s)))}}function WF(){!re.paused||$n?cn("\u5DF2\u624B\u52A8\u6682\u505C"):no()}for(let n of[re,Rf,TS,j("resumePlayback")])n.addEventListener("click",WF);function XA(){!kn||un!=="playing"||!Number.isFinite(re.duration)||re.currentTime<re.duration-1||(un="finished",qi(),Ki.checked&&Dt?HA(!0).catch(n=>We(Ct(n))):cn("\u672C\u96C6\u5DF2\u64AD\u5B8C"),Zr.then(Nf).catch(()=>{}))}re.onended=XA;Ki.onchange=()=>{$e("set_preferences",{autoplayNext:Ki.checked}).then(n=>{qt=n}).catch(n=>We(Ct(n)))};re.ontimeupdate=()=>{qF(),!re.paused&&Date.now()-kS>=5e3&&(kS=Date.now(),qi())};re.onpause=()=>{Hi(),kn&&qi(),(document.hidden||!document.hasFocus()||Wr?.action===ct)&&Ff()};re.onplay=Hi;re.onplaying=Cf;re.onerror=()=>{kn&&(cn(SS(re.error?.code)),Yr())};qr.oninput=()=>{gl(qr),kn&&Number.isFinite(re.duration)&&(un==="finished"&&(un="idle"),re.currentTime=Number(qr.value)*re.duration/1e3)};qr.onchange=()=>{qi(re.currentTime===0)};re.onloadedmetadata=()=>{re.videoWidth&&re.videoHeight&&(j("stage").style.aspectRatio=re.videoWidth+"/"+re.videoHeight)};j("restart").onclick=()=>{un==="finished"&&(un="idle"),re.currentTime=0,j("resumed").hidden=!0,qi(!0)};j("mute").onclick=()=>{re.volume===0?(re.volume=.7,re.muted=!1):re.muted=!re.muted};async function QA(){let n=j("stage");if(document.fullscreenElement){await document.exitFullscreen();return}if(n.classList.contains("expanded")){n.classList.remove("expanded"),Df();return}try{await n.requestFullscreen()}catch{n.classList.add("expanded"),Df()}}j("fullscreen").onclick=()=>{QA().catch(n=>We(Ct(n)))};document.addEventListener("fullscreenchange",Df);function Df(){let n=j("stage"),e=!!document.fullscreenElement||n.classList.contains("expanded");n.classList.toggle("isFull",e),ro(j("fullscreen"),e?"collapse":"expand",st(e?"\u9000\u51FA\u5168\u5C4F":"\u5168\u5C4F"))}var zA;j("stage").addEventListener("pointermove",()=>{let n=j("stage");n.classList.add("awake"),clearTimeout(zA),zA=setTimeout(()=>n.classList.remove("awake"),2400)});j("stage").addEventListener("pointerleave",()=>j("stage").classList.remove("awake"));document.addEventListener("keydown",n=>{n.key==="Escape"&&j("stage").classList.contains("expanded")&&QA()});re.onvolumechange=()=>{let n=re.muted||re.volume===0;ro(j("mute"),n?"mute":"volume",st(n?"\u53D6\u6D88\u9759\u97F3":"\u9759\u97F3")),j("mute").setAttribute("aria-pressed",String(n))};re.volume=.7;j("speed").onchange=n=>re.playbackRate=parseFloat(n.target.value);var pl=j("query"),wS,Uf=!1;function PS(){clearTimeout(wS),Uf||Jr(!1,pl.value.trim())}function RS(){clearTimeout(wS),++Vi,!Uf&&(pl.value.trim()?wS=setTimeout(PS,400):PS())}pl.addEventListener("input",RS);pl.addEventListener("compositionstart",()=>{Uf=!0,RS()});pl.addEventListener("compositionend",()=>{Uf=!1,RS()});j("search").onsubmit=n=>{n.preventDefault(),PS()};j("more").onclick=()=>{Jr(!0)};async function YF(){let n=at,e=Xe;if(!(!n||!e))try{await cn();let t=await $e("create_browser_pairing",{seriesId:n.id,episodeId:e.id,title:n.title});if(at!==n||Xe!==e)return;j("linkValue").value=t.url,j("link").hidden=!1,j("link").scrollIntoView({block:"nearest"}),setTimeout(()=>{j("linkValue").value===t.url&&(j("link").hidden=!0,j("linkValue").value="")},6e4)}catch(t){We(Ct(t))}}j("pair").onclick=YF;j("copy").onclick=async()=>{let n=j("linkValue");try{await navigator.clipboard.writeText(n.value),We("\u5DF2\u590D\u5236\uFF0C\u8BF7\u5728 Codex \u5185\u7F6E\u6D4F\u89C8\u5668\u6253\u5F00")}catch{n.select(),We("\u94FE\u63A5\u5DF2\u9009\u4E2D\uFF0C\u8BF7\u590D\u5236\u5E76\u5728 Codex \u5185\u7F6E\u6D4F\u89C8\u5668\u6253\u5F00")}};j("settingsCancel").onclick=()=>j("prefs").click();j("prefs").onclick=()=>{j("settings").hidden=!j("settings").hidden,j("prefs").setAttribute("aria-expanded",String(!j("settings").hidden)),j("autoPrompt").checked=qt.autoPrompt,j("autoPauseOnFinish").checked=qt.autoPauseOnFinish,j("autoPlayOnStart").checked=qt.autoPlayOnStart,j("terms").value=qt.searchTerms.join("\uFF0C")};j("settings").onsubmit=n=>{n.preventDefault();let e=j("terms").value.split(/[,,]/).map(t=>t.trim()).filter(Boolean);$e("set_preferences",{autoPrompt:j("autoPrompt").checked,autoPauseOnFinish:j("autoPauseOnFinish").checked,autoPlayOnStart:j("autoPlayOnStart").checked,searchTerms:e}).then(async t=>{qt=t,Ki.checked=qt.autoplayNext,j("settings").hidden=!0,j("prefs").setAttribute("aria-expanded","false"),Zi(),at||await Jr()}).catch(t=>We(Ct(t)))};j("choose").onclick=async()=>{try{let n=await $e("list_sessions");j("choices").replaceChildren(...n.items.map(e=>An("\u2026"+e.suffix+" \xB7 "+new Date(e.at).toLocaleString(),async()=>{await $e("select_session",{choice:e.choice}),hr.identified=!0,LS(Dt&&!document.hidden),j("choose").hidden=!0,j("choices").replaceChildren(),await Mf()}))),n.items.length||We("\u8FD8\u6CA1\u6709\u672C\u673A\u56DE\u5408\u8BB0\u5F55\uFF0C\u53EF\u5148\u624B\u52A8\u89C2\u770B")}catch(n){We(Ct(n))}};function LS(n){return hr.identified?$e("set_player_visible",{instance:jA,visible:n},1800).catch(()=>{}):Promise.resolve()}async function ew(){Dt&&(Dt=!1,await Promise.all([cn("\u5DF2\u6682\u505C\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED",!0),LS(!1)]))}function tw(n){if(n.action!==ct||!Dt||!kn||un!=="playing"||!re.paused||re.ended||re.error)return;let e=re.currentTime;n.lastPosition!==void 0&&Math.abs(e-n.lastPosition)<.25||(n.lastPosition=e,re.play().then(()=>{n.action===ct&&!re.paused&&We("\u6B63\u5728\u64AD\u653E")}).catch(()=>{}))}function Ff(){!Dt||un!=="playing"||(Wr?.action!==ct&&(Wr={action:ct}),tw(Wr))}function nw(){let n=Wr;n&&(Wr=void 0,Mf().then(()=>tw({action:n.action})))}function rw(){Dt&&(LS(!document.hidden),document.hidden?(Ff(),qi()):nw(),Mf())}function iw(){!fl||Dt||(Dt=!0,rw(),pr&&Xe?.playable&&re.paused&&!$n&&no(pr))}document.addEventListener("visibilitychange",rw);window.addEventListener("blur",Ff);window.addEventListener("focus",nw);window.addEventListener("pagehide",()=>{ew()});window.addEventListener("pageshow",iw);async function sw(n){if(fl)return;if(fl=!0,pr=void 0,AS=n?.play?n.playbackId:void 0,navigator.mediaSession&&(navigator.mediaSession.setActionHandler("pause",()=>{cn("\u5DF2\u624B\u52A8\u6682\u505C")}),navigator.mediaSession.setActionHandler("play",()=>{re.paused&&!$n&&no()})),VA=window.setInterval(()=>{Mf()},1e3),j("pair").hidden=Hr||BA,j("choose").hidden=Hr||hr.identified,Zt=null,JA(),iw(),$e("get_preferences").then(t=>{fl&&(qt=t,Ki.checked=qt.autoplayNext??!0,Zi())}).catch(t=>We(Ct(t))),n?.pick){let t=n.pick;await to(t,t.episodeId,n.play,n.turnId),n.reason==="turn-ended"&&at?.id===t.id&&re.paused&&!$n&&We("\u63A8\u8350\u6240\u5C5E\u4EFB\u52A1\u5DF2\u7ED3\u675F\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED\u89C2\u770B");return}j("home").hidden=!1,j("watch").hidden=!0;let e=Jr();Nf().then(()=>{!at&&mr.length&&yt.length&&Gi()}).catch(t=>We(Ct(t))),hr.selection&&await to({id:hr.selection.seriesId,title:hr.selection.title||"\u7EA2\u679C\u77ED\u5267"},hr.selection.episodeId),await e}function ow(){let n=ew();return fl=!1,pr=void 0,navigator.mediaSession&&(navigator.mediaSession.setActionHandler("pause",null),navigator.mediaSession.setActionHandler("play",null)),window.clearInterval(VA),++Jn,Yr(),n}var Pf=BA?MA(n=>{sw(n).catch(e=>We(Ct(e)))},ow):null;LA(n=>{CS(PA()),hr=n,Pf?n.waitingTurn&&Pf.connected():sw().catch(e=>We(Ct(e)))},async()=>{Pf?.dispose(),await ow()},()=>Pf?.modeChanged()).catch(n=>We(Ct(n)));})();
|
|
1970
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:E.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:E.string().optional().describe("User's timezone in IANA format."),userAgent:E.string().optional().describe("Host application identifier."),platform:E.union([E.literal("web"),E.literal("desktop"),E.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:E.object({touch:E.boolean().optional().describe("Whether the device supports touch input."),hover:E.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:E.object({top:E.number().describe("Top safe area inset in pixels."),right:E.number().describe("Right safe area inset in pixels."),bottom:E.number().describe("Bottom safe area inset in pixels."),left:E.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),BF=E.object({method:E.literal("ui/notifications/host-context-changed"),params:EA.describe("Partial context update containing only changed fields.")}),l3=E.object({method:E.literal("ui/update-model-context"),params:E.object({content:E.array(Ys).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:E.record(E.string(),E.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),c3=E.object({method:E.literal("ui/initialize"),params:E.object({appInfo:nl.describe("App identification (name and version)."),appCapabilities:MF.describe("Features and capabilities this app provides."),protocolVersion:E.string().describe("Protocol version this app supports.")})}),jF=E.object({protocolVersion:E.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:nl.describe("Host application identification and version."),hostCapabilities:NF.describe("Features and capabilities provided by the host."),hostContext:EA.describe("Rich context about the host environment.")}).passthrough(),VF={target:"draft-2020-12"};async function xA(n,e){let t=n["~standard"];if(t.jsonSchema)return t.jsonSchema[e](VF);if(t.vendor==="zod"){let{z:i}=await Promise.resolve().then(()=>(Xa(),Hb));return i.toJSONSchema(n,{io:e})}throw Error(`Schema (vendor: ${t.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function _A(n,e,t=""){let i=await n["~standard"].validate(e);if(i.issues){let r=i.issues.map(s=>{let o=s.path?.map(a=>typeof a=="object"?a.key:a).join(".");return o?`${o}: ${s.message}`:s.message}).join("; ");throw Error(t+r)}return i.value}function IA(n){let e=document.documentElement;e.setAttribute("data-theme",n),e.style.colorScheme=n}function TA(n,e=document.documentElement){for(let[t,i]of Object.entries(n))i!==void 0&&e.style.setProperty(t,i)}var Af=class n extends hS{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:PF,toolinputpartial:RF,toolresult:zF,toolcancelled:LF,hostcontextchanged:BF};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!n.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e)||(this._everHadListener.add(e),!this._initializedSent))return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),super.setEventHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),super.addEventListener(e,t)}onEventDispatch(e,t){e==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...t})}constructor(e,t={},i={autoResize:!0}){super(i),this._appInfo=e,this._capabilities=t,this.options=i,i.allowUnsafeEval||E.config({jitless:!0}),this.setRequestHandler(qs,r=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=bA(this._capabilities,e)}registerTool(e,t,i){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,s=()=>{r._initializedSent&&r._capabilities.tools?.listChanged&&r.sendToolListChanged()},o=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,s()},disable(){this.enabled=!1,s()},update(l){Object.assign(this,l),s()},remove(){r._registeredTools[e]===a&&(delete r._registeredTools[e],s())},handler:async(l,c)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let u;if(o){let d=a.inputSchema,f=d?await _A(d,l??{},`Invalid input for tool ${e}: `):l??{};u=await i(f,c)}else u=await i(c);return a.outputSchema&&!u.isError&&(u.structuredContent=await _A(a.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `)),u}};return this._registeredTools[e]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),s(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let i=this._registeredTools[e.name];if(!i)throw Error(`Tool ${e.name} not found`);return i.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([i,r])=>r.enabled).map(async([i,r])=>{let s={name:i,title:r.title,description:r.description,inputSchema:r.inputSchema?await xA(r.inputSchema,"input"):{type:"object",properties:{}}};return r.outputSchema&&(s.outputSchema=await xA(r.outputSchema,"output")),r.annotations&&(s.annotations=r.annotations),r._meta&&(s._meta=r._meta),s}))}))}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(OF,(t,i)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t.params,i)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(lS,(t,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,i)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(aS,(t,i)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,i)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(e){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},Js,{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},tS,t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},Qb,t)}async createSamplingMessage(e,t){this._assertInitialized("createSamplingMessage");let i=e.tools?uS:cS;return await this.request({method:"sampling/createMessage",params:e},i,t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},wF,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},gf,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},$F,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},AF,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},UF,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,i=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let o=document.documentElement,a=o.style.height;o.style.height="max-content";let l=Math.ceil(o.getBoundingClientRect().height);o.style.height=a;let c=Math.ceil(window.innerWidth);(c!==t||l!==i)&&(t=c,i=l,this.sendSizeChanged({width:c,height:l}))}))};r();let s=new ResizeObserver(r);return s.observe(document.documentElement),s.observe(document.body),()=>s.disconnect()}async connect(e=new mS(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(e);try{let i=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:_F}},jF,t);if(i===void 0)throw Error(`Server sent invalid initialize result: ${i}`);this._hostCapabilities=i.hostCapabilities,this._hostInfo=i.hostInfo,this._hostContext=i.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(i){throw this.close(),i}}};function kA(n,e,t){let i,r=!1,s=()=>{r||i!==void 0||(i=requestAnimationFrame(()=>{i=void 0,!(r||!e())&&t(n.hidden?1:Math.max(1,Math.ceil(n.getBoundingClientRect().height)))}))},o=new ResizeObserver(s);return o.observe(n),s(),{refresh:s,dispose(){r=!0,o.disconnect(),i!==void 0&&cancelAnimationFrame(i)}}}var $A={name:"@kyun.si/codex-hongguo",version:"0.0.29",private:!0,license:"MIT",type:"module",engines:{node:">=22.16"},scripts:{"version:patch":"npm version patch --no-git-tag-version",preversion:"node scripts/version.mjs --next",version:"node scripts/version.mjs --sync",prebuild:"node scripts/version.mjs",build:"node scripts/build.mjs",test:"npm run build && node scripts/prepare-media.mjs && node --test --test-timeout=180000 test/*.test.mjs",package:"npm run build && node scripts/package.mjs","verify:install":"node scripts/verify-install.mjs","release:publish":"node scripts/publish.mjs"},dependencies:{"@modelcontextprotocol/ext-apps":"1.7.5","@modelcontextprotocol/sdk":"1.32.2","cross-spawn":"7.0.6",fflate:"0.8.3","hls.js":"1.7.4","m3u8-parser":"7.2.1","mpd-parser":"1.4.1",openhongguo:"0.2.0","xz-decompress":"0.2.3",zod:"4.6.7"},devDependencies:{"@types/node":"22.20.5",esbuild:"0.28.2",typescript:"5.9.3"}};var Hr=document.documentElement.dataset.host==="browser",wA=document.documentElement.dataset.surface==="waiting",yS="",Yn=Hr?null:new Af({name:"\u7EA2\u679C\u77ED\u5267",version:$A.version},{},{autoResize:!wA}),vS,PA=()=>Yn?.getHostContext()?.locale||navigator.language,wf=()=>Yn?.getHostContext()?.displayMode;async function RA(){if((await Yn?.requestDisplayMode({mode:"fullscreen"},{timeout:5e3}))?.mode!=="fullscreen")throw Error("\u5F53\u524D Codex \u65E0\u6CD5\u5728\u4F1A\u8BDD\u4E2D\u6253\u5F00\u64AD\u653E\u5668")}function AA(n){n&&(n.theme&&IA(n.theme),n.styles?.variables&&TA(n.styles.variables))}async function LA(n,e,t){if(Hr){let i=await fetch("context",{signal:AbortSignal.timeout(4e3)});if(!i.ok)throw Error("\u5206\u5C4F\u5DF2\u5931\u6548\uFF0C\u8BF7\u4ECE\u9762\u677F\u91CD\u65B0\u6253\u5F00");n(await i.json());return}Yn.ontoolresult=i=>{if(typeof i._meta?.panel!="string")return;yS=i._meta.panel;let r=typeof i._meta.waitingTurn=="string"?i._meta.waitingTurn:void 0;n({identified:!!i.structuredContent?.identified||!!r,waitingTurn:r})},Yn.onteardown=async()=>(vS?.dispose(),await e(),{}),Yn.onhostcontextchanged=i=>{AA(i),i.displayMode!==void 0&&(t(),vS?.refresh())},await Yn.connect(),AA(Yn.getHostContext()),wA&&(vS=kA(document.getElementById("waitingCard"),()=>(wf()||"inline")==="inline",i=>{Yn.sendSizeChanged({height:i}).catch(()=>{})})),t()}async function $e(n,e={},t=15e3){if(Hr){let r=await fetch("api/"+n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),keepalive:n==="save_progress",signal:AbortSignal.timeout(t)}),s=await r.json();if(!r.ok)throw Error(s.error||"\u5206\u5C4F\u8FDE\u63A5\u5DF2\u4E2D\u65AD");return s}if(!yS)throw Error("\u7B49\u5F85\u4F1A\u8BDD\u9762\u677F\u8FDE\u63A5");let i=await Yn.callServerTool({name:n,arguments:{...e,panel:yS}},{timeout:t});if(i.isError)throw Error(i.content?.[0]?.type==="text"?i.content[0].text:"\u672C\u673A\u670D\u52A1\u4E0D\u53EF\u8FBE");return i._meta?.data}var bS="https://hongguo.invalid/";function DA(n,e,t,i,r,s){if(!nr.isSupported())throw Error("\u5F53\u524D\u9762\u677F\u4E0D\u652F\u6301\u5206\u6BB5\u89E3\u7801\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F");class o{context=null;stats=new oi;abort(){this.stats.aborted=!0}destroy(){this.abort()}load(d,f,h){this.context=d,this.stats.loading.start=performance.now(),(async()=>{let p=d.url.slice(bS.length);if(!d.url.startsWith(bS))throw Error("\u65E0\u6548\u5A92\u4F53\u6765\u6E90");if(p==="index.m3u8")return i;let g=0,y;do{let b=await $e("read_panel_chunk",{episodeId:e,stream:t,asset:p,offset:g},8e3);if(this.stats.aborted)return;if(!Number.isSafeInteger(b.size)||b.size<1||b.size>32*1024*1024)throw Error("\u5206\u6BB5\u957F\u5EA6\u65E0\u6548");y??=new Uint8Array(b.size);let S=atob(b.bytes);if(b.size!==y.length||!S.length||g+S.length>b.size)throw Error("\u5206\u6BB5\u4E0D\u5B8C\u6574");for(let x=0;x<S.length;x++)y[g+x]=S.charCodeAt(x);g+=S.length}while(g<y.length);return y.buffer})().then(p=>{this.stats.aborted||p===void 0||(this.stats.loading.first=this.stats.loading.end=performance.now(),this.stats.loaded=this.stats.total=typeof p=="string"?p.length:p.byteLength,h.onSuccess({url:d.url,data:p},this.stats,d,null))}).catch(()=>{this.stats.aborted||h.onError({code:0,text:"\u4FA7\u680F\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25"},d,null,this.stats)})}}let a=new nr({loader:o,enableWorker:!1,maxBufferLength:16,maxMaxBufferLength:24,backBufferLength:12});a.on(nr.Events.MEDIA_ENDED,s),a.on(nr.Events.ERROR,(u,d)=>{d.fatal&&(d.type===nr.ErrorTypes.NETWORK_ERROR?r("\u4FA7\u680F\u5206\u6BB5\u8BFB\u53D6\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD"):r("\u4FA7\u680F\u65E0\u6CD5\u5904\u7406\u89C6\u9891\u5206\u6BB5\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F"))});let l=u=>{u.disposition==="enforce"&&u.effectiveDirective==="media-src"&&(u.blockedURI==="blob"||u.blockedURI.startsWith("blob:"))&&r("\u684C\u9762\u5B89\u5168\u7B56\u7565\u963B\u6B62\u4E86\u4FA7\u680F\u8F7D\u5165\u672C\u5730\u89C6\u9891")},c=()=>{document.removeEventListener("securitypolicyviolation",l),a.destroy()};document.addEventListener("securitypolicyviolation",l);try{a.loadSource(bS+"index.m3u8"),a.attachMedia(n)}catch(u){throw c(),u}return c}function SS(n){switch(n){case 1:return"\u89C6\u9891\u52A0\u8F7D\u5DF2\u4E2D\u6B62\uFF0C\u53EF\u4EE5\u91CD\u65B0\u70B9\u64AD";case 2:return"\u8BFB\u53D6\u89C6\u9891\u6570\u636E\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD";case 3:return"\u64AD\u653E\u5668\u89E3\u7801\u89C6\u9891\u6570\u636E\u5931\u8D25\uFF0C\u53EF\u4F7F\u7528\u540C\u7A97\u5206\u5C4F";case 4:return"\u64AD\u653E\u5668\u65E0\u6CD5\u6253\u5F00\u89C6\u9891\u6765\u6E90\uFF0C\u53EF\u91CD\u65B0\u70B9\u64AD\u6216\u4F7F\u7528\u540C\u7A97\u5206\u5C4F";default:return"\u89C6\u9891\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD"}}function CA(n,e){return new Promise((t,i)=>{let r=()=>l(),s=()=>l(Error(SS(n.error?.code))),o=()=>l(e.reason),a=setTimeout(()=>l(Error("\u7B49\u5F85\u89C6\u9891\u5143\u6570\u636E\u8D85\u65F6\uFF0C\u8BF7\u91CD\u65B0\u70B9\u64AD")),3e4);function l(c){clearTimeout(a),n.removeEventListener("loadedmetadata",r),n.removeEventListener("error",s),e.removeEventListener("abort",o),c!==void 0?i(c):t()}n.addEventListener("loadedmetadata",r),n.addEventListener("error",s),e.addEventListener("abort",o),e.aborted&&o()})}function OA(n,e){return!!n&&!!e.turnId&&e.state==="submitted"&&n.turnId!==e.turnId}function NA(n,e){return!n||!e.turnId||e.state!=="stopped"&&e.state!=="interrupted"||n.turnId===e.turnId&&n.state!=="submitted"?null:e.state==="interrupted"?"\u672C\u8F6E\u5DF2\u4E2D\u65AD\uFF0C\u5DF2\u4E3A\u4F60\u6682\u505C":"\u672C\u8F6E\u5DF2\u505C\u6B62\uFF0C\u5DF2\u4E3A\u4F60\u6682\u505C"}function _S(n){return n.episodeId?st(n.kind==="next"?"\u770B\u4E0B\u4E00\u96C6":"\u7EE7\u7EED\u89C2\u770B")+" \xB7 "+n.title:n.title}function xS(n,e){return e.aborted?Promise.resolve(!1):new Promise(t=>{let i=new IntersectionObserver(a=>{let l=a[a.length-1];!document.hidden&&l.isIntersecting&&l.intersectionRect.width>0&&l.intersectionRect.height>0&&r(!0)},{threshold:[0,.01]}),r=a=>{i.disconnect(),document.removeEventListener("visibilitychange",o),e.removeEventListener("abort",s),t(a)},s=()=>r(!1),o=()=>{document.hidden||(i.unobserve(n),i.observe(n))};e.addEventListener("abort",s),document.addEventListener("visibilitychange",o),i.observe(n)})}async function ES(n,e,t,i,r,s=!1){let o=i?{turnId:i}:{};if(e.replaceChildren(),n.hidden=!1,!await xS(n,t))return;let{items:a}=await $e("get_waiting_picks",{...o,inView:!0},9e4);if(!t.aborted){if(!a.length){s?r([]):n.hidden=!0;return}if(r(a),!!await xS(e,t))try{await $e("mark_waiting_picks_shown",o)}catch{await xS(e,t)&&await $e("mark_waiting_picks_shown",o).catch(()=>{})}}}function MA(n,e){let t=document.getElementById("waitingCard"),i=document.getElementById("waitingTitles"),r=document.getElementById("waitingMessage"),s=document.getElementById("waitingDismiss"),o=!1,a=!1,l=!1,c=!1,u=!0,d=!1,f=0,h,m,p,g;function y(){++f,m?.abort(),m=void 0,t.hidden=!0,i.replaceChildren(),r.textContent=""}s.onclick=()=>{c=!0,y(),$e("dismiss_waiting_picks").catch(()=>{})};function b($){!o||c||!u||a||(r.textContent=st($ instanceof Error?$.message:"\u5F53\u524D Codex \u65E0\u6CD5\u5728\u4F1A\u8BDD\u4E2D\u6253\u5F00\u64AD\u653E\u5668"),t.hidden=!1)}async function S($=!1){if(!o)return;let P=wf()||"inline";if(!$&&P===h)return;h=P;let k=++f;m?.abort();let D=m=new AbortController;if(P==="fullscreen"){if(a)return;let V=await(p??=$e("activate_waiting_player"));if(k!==f)return;a=!0,t.hidden=!0,document.documentElement.dataset.surface="player",n(V);return}else p=void 0,a&&(a=!1,e(),document.documentElement.dataset.surface="waiting");if(c){y();return}let U=await $e("get_waiting_status");if(k===f){if(u=U.visible,!u){y();return}r.textContent="",await ES(t,i,D.signal,void 0,V=>{let X=V.map(F=>{let z=document.createElement("button");return z.type="button",z.textContent=_S(F),z.onclick=()=>{x(F)},z}),q=document.createElement("button");q.type="button",q.textContent=st("\u66F4\u591A\u2026"),q.onclick=()=>{x()},i.replaceChildren(...X,q)},!0).catch(V=>{D.signal.aborted||b(V)})}}async function x($){if(!l){l=!0,r.textContent="";try{$?await $e("select_waiting_pick",{seriesId:$.id}):await $e("browse_waiting_catalog"),wf()==="fullscreen"?await S(!0):(await RA(),t.hidden=!0)}catch(P){b(P),P instanceof Error&&P.message==="\u8FD9\u6761\u63A8\u8350\u5DF2\u7ED3\u675F"&&y()}finally{l=!1}}}async function _(){if(!(!o||a||l||c||document.hidden||d)){d=!0;try{let $=await $e("get_waiting_status");if(!o||a||l||c)return;$.visible!==u&&(u=$.visible,u?await S(!0):y())}catch{!a&&!l&&(u=!1,y())}finally{d=!1}}}let I=()=>{S().catch(b)},T=()=>{!document.hidden&&o&&!a&&!c&&S(!0).catch(b)};return{connected(){o||(o=!0,g=setInterval(()=>{_()},1e3),document.addEventListener("visibilitychange",T),I())},modeChanged:I,dispose(){o=!1,clearInterval(g),document.removeEventListener("visibilitychange",T),y()}}}var j=n=>document.getElementById(n),re=document.querySelector("video"),qr=j("seek"),TS=j("play"),Rf=j("center"),Ki=j("autonext"),zn=(n,e)=>{j(n).textContent=n==="title"?e:st(e)},We=n=>zn("notice",n),Ct=n=>n instanceof Error?n.message:"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",eo=n=>Math.floor(n/60)+":"+String(Math.floor(n%60)).padStart(2,"0"),KF=n=>new Promise(e=>setTimeout(e,n));function An(n,e){let t=document.createElement("button");return t.textContent=st(n),t.onclick=()=>{Promise.resolve(e()).catch(i=>We(Ct(i)))},t}var hr={identified:!1},Zt=null,at=null,Xe=null,Ze=[],Tt,hl="",Tn,yt=[],kn=!1,ct=0,Jn=0,Vi=0,$n=!1,Dt=!1,IS,kS=0,Zr=Promise.resolve(),qt={autoPrompt:!0,autoplayNext:!0,autoPauseOnFinish:!0,autoPlayOnStart:!0,searchTerms:["\u603B\u88C1","\u91CD\u751F","\u9006\u88AD"]},un="idle",Wr,$S,ul,Qs=0,dl=0,mr=[],Lf=null,BA=document.documentElement.dataset.surface==="waiting",jA=Array.from(crypto.getRandomValues(new Uint32Array(4)),n=>n.toString(16).padStart(8,"0")).join(""),fl=!1,VA,UA=null,FA,AS,pr;function Cf(){pr=void 0;let n=AS;AS=void 0,n&&$e("confirm_waiting_playback",{playbackId:n},1800).catch(()=>{})}function Hi(){TS.disabled=Rf.disabled=!Xe?.playable,j("pair").disabled=!Xe;let n=st($n?"\u53D6\u6D88\u51C6\u5907":re.paused?"\u64AD\u653E":"\u6682\u505C"),e=$n?"x":re.paused?"play":"pause";ro(TS,e,n),ro(Rf,e,n),j("stage").classList.toggle("playing",!re.paused),j("stage").classList.toggle("busy",$n),j("prev").disabled=!Xe||!Ze.slice(0,Ze.indexOf(Xe)).some(t=>t.playable),j("next").disabled=!Xe||!Tt&&!Ze.slice(Ze.indexOf(Xe)+1).some(t=>t.playable),Rf.hidden=$n,document.querySelectorAll("#episodes button").forEach(t=>t.setAttribute("aria-pressed",String(t.dataset.id===Xe?.id)))}function qi(n=!1){if(!kn||!at||!Xe||!Number.isFinite(re.duration)||!re.duration||!re.currentTime&&!n)return Zr;let e={seriesId:at.id,episodeId:Xe.id,title:at.title,label:Xe.label,positionMs:Math.round((un==="finished"||re.ended?re.duration:re.currentTime)*1e3),durationMs:Math.round(re.duration*1e3)};return Zr=Zr.then(()=>$e("save_progress",{...e,...n&&e.positionMs===0?{reset:!0}:{}},1800)).then(()=>{}).catch(()=>We("\u89C2\u770B\u8FDB\u5EA6\u6682\u672A\u5199\u5165\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u670D\u52A1")),Zr}function cn(n="",e=!1){e||(pr=void 0),n==="\u5DF2\u624B\u52A8\u6682\u505C"&&Cf(),ct++,Wr=void 0,$n=!1,un!=="finished"&&(un="idle"),re.pause(),Hi();let t=!!at&&/本轮已停止|本轮已中断/.test(n);return n&&We(t?"":n),j("stopped").hidden=!t,t&&zn("whyStopped",n),qi()}function Yr(){kn=!1,un="idle",ul?.abort(),ul=void 0,j("stopped").hidden=!0,j("resumed").hidden=!0,$S?.(),$S=void 0,re.removeAttribute("src"),re.load()}function GA(n){cn("",!0),Yr(),j("link").hidden=!0,j("linkValue").value="",Xe=n,Qs=Math.floor(Math.max(0,Ze.indexOf(n))/50),We("");let e="\u7B2C "+n.number+" \u96C6",t=n.label.replace(/\s/g,"")!=="\u7B2C"+n.number+"\u96C6";zn("subtitle",[e,t?n.label:"",n.codec].filter(Boolean).join(" \xB7 ")),zn("time","0:00"),qr.value="0",gl(qr),Hi(),n.playable||We("\u8BE5\u96C6\u5F53\u524D\u4E0D\u53EF\u64AD\u653E\uFF0C\u8BF7\u68C0\u67E5\u7247\u6E90\u8BB8\u53EF\u6216 FFmpeg \u81EA\u68C0\u7ED3\u679C")}function ml(){let n=Math.ceil(Ze.length/50);j("groups").replaceChildren(...Array.from({length:n>1?n:0},(e,t)=>{let i=An(Ze[t*50].number+"\u2013"+Ze[Math.min(Ze.length,(t+1)*50)-1].number,()=>{Qs=t,ml()});return i.setAttribute("aria-pressed",String(t===Qs)),i})),j("episodes").replaceChildren(...Ze.slice(Qs*50,(Qs+1)*50).map(e=>{let t=An(String(e.number),()=>Of(e));return t.disabled=!e.playable,t.title=e.label,t.dataset.id=e.id,t})),j("moreEpisodes").hidden=!Tt,j("episodeCount").textContent=Ze.length?st(Ze.length+(Tt?"+":"")+" \u96C6"):"",Hi()}async function to(n,e,t=!1,i){let r=i&&e;j("home").hidden=!0,j("watch").hidden=!1,j("back").focus({preventScroll:!0}),window.scrollTo(0,0),Qs=0;let s=++Jn;cn(),pr=t?i:void 0;let o=ct;Yr(),Xe=null,Ze=[],Tt=void 0,at=n,Zi(),re.poster=n.cover||"",zn("title",n.title),zn("subtitle","\u6B63\u5728\u8BFB\u53D6\u5206\u96C6\u2026"),ml(),ZA(),await Zr;let[a,l]=await Promise.all([$e("get_episodes",{seriesId:n.id}),$e("get_history",{seriesId:n.id})]);e??=l.items[0]?.episodeId;let c=a;if(s!==Jn)return;Ze=c.items||[],Tt=c.cursor;let u=new Set;for(;e&&!Ze.some(h=>h.id===e)&&Tt&&!u.has(Tt);){if(u.add(Tt),c=await $e("get_episodes",{seriesId:n.id,cursor:Tt}),s!==Jn)return;Ze.push(...c.items),Tt=c.cursor}let d=e&&Ze.find(h=>h.id===e&&(!t||h.playable))||!r&&(t&&Ze.find(h=>h.playable)||Ze[0]),f=t&&Dt&&(ct===o||!!i&&pr===i);d?GA(d):zn("subtitle","\u6682\u65E0\u53EF\u7528\u5206\u96C6"),ml(),f&&d&&s===Jn&&await no(i)}async function Of(n){GA(n),ml(),await no()}async function KA(){if(!at||!Tt)return;let n=Jn,e=Tt;try{let t=await $e("get_episodes",{seriesId:at.id,cursor:e});if(n!==Jn||e!==Tt)return;Ze.push(...t.items),Tt=t.cursor===e?void 0:t.cursor,ml()}catch(t){We(Ct(t))}}j("moreEpisodes").onclick=KA;async function HA(n=!1){if(!Xe)return;let e=Xe.id,t=Jn,i=ct,r=Ze.slice(Ze.indexOf(Xe)+1).find(o=>o.playable),s=new Set;for(;!r&&Tt&&!s.has(Tt);){if(s.add(Tt),await KA(),Jn!==t||Xe?.id!==e||ct!==i)return;r=Ze.slice(Ze.indexOf(Xe)+1).find(o=>o.playable)}!Dt||n&&!Ki.checked||(r?await Of(r):n&&cn("\u672C\u96C6\u5DF2\u64AD\u5B8C"))}j("prev").onclick=()=>{let n=Ze.slice(0,Ze.indexOf(Xe)).reverse().find(e=>e.playable);n&&Of(n)};j("next").onclick=()=>{HA()};j("random").onclick=()=>{let n=Ze.filter(r=>r.playable),e=mr.find(r=>r.seriesId===at?.id),t=e?n.findIndex(r=>r.id===e.episodeId):-1,i=t<0?n.slice(0,1):n.slice(Math.min(t+1,n.length-1));i.length&&Of(i[Math.floor(Math.random()*i.length)])};async function HF(){Cf(),document.fullscreenElement&&await document.exitFullscreen(),j("stage").classList.remove("expanded"),Df(),We(""),++Jn;let n=cn();Yr(),Xe=null,at=null,Ze=[],Tt=void 0,j("home").hidden=!1,j("watch").hidden=!0,j("link").hidden=!0,yt.length?Gi():Jr(),await n,await Nf(),!at&&yt.length&&Gi()}j("back").onclick=()=>{HF().catch(n=>We(Ct(n)))};function ZA(){document.querySelectorAll(".card").forEach(n=>n.setAttribute("aria-pressed",String(n.dataset.id===at?.id)))}function Gi(){let n=[],e=new Set(mr.map(o=>o.seriesId)),t=hl?void 0:yt.find(o=>!e.has(o.id))||yt[0],i=yt.filter(o=>o!==t),r=YA();if(r&&n.push(r),j("featured").replaceChildren(),t){let o=An("",()=>to(t,void 0,!0)),a=vl(t.title,t.episodes?st(t.episodes+" \u96C6"):""),l=document.createElement("span"),c=document.createElement("small"),u=document.createElement("strong"),d=document.createElement("span");if(o.className="feature",o.dataset.id=t.id,o.setAttribute("aria-label",st("\u64AD\u653E")+" \xB7 "+t.title),l.className="featureText",c.className="eyebrow",c.textContent=st(e.has(t.id)?"\u770B\u8FC7":"\u63A8\u8350"),u.textContent=t.title,l.append(c,u),t.description){let f=document.createElement("span");f.className="desc",f.textContent=t.description,l.append(f)}d.className="playPill",d.append(Wi("play"),st("\u64AD\u653E")),l.append(d),o.append(a,l),j("featured").append(o),n.push({span:a,s:t})}Zi(),j("cards").replaceChildren(...i.slice(dl*12,(dl+1)*12).map(o=>{let a=An("",()=>to(o,void 0,!0));a.className="card",a.dataset.id=o.id,a.title=o.title;let l=vl(o.title,o.episodes?st(o.episodes+" \u96C6"):""),c=document.createElement("span");return c.className="cardTitle",c.textContent=o.title,a.append(l,c),n.push({span:l,s:o}),a})),ZA();let s=Vi;(async()=>{for(let{span:o,s:a}of n){if(s!==Vi)return;if(!a.cover&&(a.hasCover||a.lookupCover))try{a.cover=(await $e("get_cover",{seriesId:a.id},9e3)).cover}catch{}a.cover&&(NS(o,a.cover),at?.id===a.id&&(re.poster=a.cover))}})()}function Zi(){let e=qt.autoPrompt&&!!Zt?.turnId&&Zt.state==="submitted"&&!at&&!hl&&yt.length>0&&Lf!==Zt.turnId?Zt.turnId:null;if(e===UA)return;UA=e,FA?.abort();let t=j("prompt"),i=j("picks");if(!e){t.hidden=!0;return}let r=FA=new AbortController;ES(t,i,r.signal,e,s=>{i.replaceChildren(...s.map(o=>An(_S(o),()=>($e("mark_waiting_picks_shown",{turnId:e}).catch(()=>{}),to(yt.find(a=>a.id===o.id)??o,o.episodeId,!0,e)))),An("\u66F4\u591A\u2026",()=>{qA(),j("query").focus()}))}).catch(()=>{r.signal.aborted||(t.hidden=!0)})}function qA(){Lf=Zt?.turnId||null,Lf&&$e("dismiss_waiting_picks",{turnId:Lf}).catch(()=>{}),Zi()}j("dismiss").onclick=qA;function Xs(n,e=""){let t=j("catalogStatus"),i=j("cards"),r=j("query");if(t.dataset.state=n==="loading"&&yt.length?"busy":n,t.replaceChildren(),e){let s=document.createElement("span");s.textContent=st(e),t.append(s)}t.dataset.state==="busy"&&t.prepend(Wi("spin")),n==="error"&&t.append(An("\u91CD\u8BD5",()=>Jr())),n==="empty"&&hl&&t.append(An("\u6E05\u9664\u641C\u7D22",()=>(r.value="",Jr(!1,"")))),t.querySelectorAll("button").forEach(s=>s.className="btn"),n==="loading"&&!yt.length?i.replaceChildren(...Array.from({length:6},()=>{let s=document.createElement("div"),o=document.createElement("span"),a=document.createElement("span");return s.className="skel",s.setAttribute("aria-hidden","true"),o.className="skelArt",a.className="skelLine",s.append(o,a),s})):i.querySelector(".skel")&&i.replaceChildren()}async function Jr(n=!1,e=hl){let t=++Vi;n||(hl=e,yt=[],Tn=void 0,dl=0,Gi());let i=n?dl+1:0;j("more").hidden=!0,Xs("loading","\u6B63\u5728\u8BFB\u53D6\u7247\u5E93\u2026");let r=n?[...yt]:[],s=!1;!n&&!e&&$e("list_series",{preview:!0},9e4).then(o=>{t!==Vi||s||!o.items.length||(yt=o.items,Gi(),j("catalogStatus").dataset.state!=="error"&&Xs(""),j("more").hidden=yt.length<=13)}).catch(()=>{});try{let o=new Set,a=(i+1)*12+(e?0:1),l=!n;for(;l||r.length<a&&Tn&&!o.has(Tn);){l=!1,Tn&&o.add(Tn);let u=await $e("list_series",{query:e,cursor:Tn},9e4);if(t!==Vi)return;let d=new Set(r.map(f=>f.id));for(let f of u.items)d.has(f.id)||(d.add(f.id),r.push(f));Tn=u.cursor,Tn&&o.has(Tn)&&(Tn=void 0)}s=r.length>0,s&&(yt=r);let c=Math.max(1,Math.ceil((yt.length-(e?0:1))/12));if(n&&i>=c&&!Tn&&!e){await Jr();return}dl=i%c,Gi(),yt.length?Xs(""):e?Xs("empty","\u6CA1\u6709\u627E\u5230\u76F8\u7B26\u7684\u5267\u76EE"):Xs("error","\u7EA2\u679C\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u63A8\u8350\u5267\u76EE"),j("more").hidden=c<=1&&!Tn}catch(o){t===Vi&&(Xs("error",Ct(o)),j("more").hidden=!n)}}async function Nf(){mr=(await $e("get_history")).items,YA(),j("history").replaceChildren(...mr.map(n=>{let e=document.createElement("div"),t=document.createElement("strong"),i=document.createElement("small");e.className="historyRow";let r=An("",()=>WA(n));r.className="historyItem",t.textContent=n.title,i.textContent=n.label+" \xB7 "+eo(n.positionMs/1e3),r.append(t,i);let s=An("",async()=>{await Zr,await $e("remove_history",{seriesId:n.seriesId}),await Nf(),Gi()}),o=st("\u79FB\u9664 "+n.title+" \u7684\u89C2\u770B\u5386\u53F2");return s.className="icon sm",s.setAttribute("aria-label",o),s.title=o,s.append(Wi("x")),e.append(r,s),e})),j("historyCount").textContent=mr.length?String(mr.length):"",j("resume").hidden=!mr.length}function WA(n){return to(yt.find(e=>e.id===n.seriesId)||{id:n.seriesId,title:n.title},n.episodeId,!0)}function YA(){let n=mr[0];if(!n){j("continue").replaceChildren();return}let e=yt.find(f=>f.id===n.seriesId)||{id:n.seriesId,title:n.title},t=An("",()=>WA(n)),i=vl(n.title),r=document.createElement("span"),s=document.createElement("small"),o=document.createElement("strong"),a=document.createElement("span"),l=document.createElement("span"),c=document.createElement("i"),u=document.createElement("span"),d=n.durationMs?Math.min(1,n.positionMs/n.durationMs):0;return t.className="resumeCard",t.setAttribute("aria-label",st("\u7EE7\u7EED\u89C2\u770B \xB7 "+n.title+" \xB7 "+n.label)),r.className="resumeText",s.className="eyebrow",s.textContent=st("\u7EE7\u7EED\u89C2\u770B"),o.textContent=n.title,a.className="meta",a.textContent=n.label+" \xB7 "+eo(n.positionMs/1e3)+(n.durationMs?" / "+eo(n.durationMs/1e3):""),l.className="bar",c.style.setProperty("--p",(d*100).toFixed(1)+"%"),l.append(c),r.append(s,o,a,l),u.className="resumePlay",u.append(Wi("play")),t.append(i,r,u),j("continue").replaceChildren(t),{span:i,s:e}}function JA(){let n=Zt?.state==="submitted";j("lamp").classList.toggle("on",n),zn("state",!hr.identified&&Hr?"\u672A\u5173\u8054\u5BF9\u8BDD":!Zt||Zt.state==="unknown"?"\u7B49\u5F85\u56DE\u5408\u5F00\u59CB":n?"\u5F53\u524D\u56DE\u5408\u8FDB\u884C\u4E2D":Zt.state==="interrupted"?"\u56DE\u5408\u5DF2\u4E2D\u65AD":"\u56DE\u5408\u5DF2\u505C\u6B62")}function Mf(){return Dt?(IS??=ZF().finally(()=>{IS=void 0}),IS):Promise.resolve()}async function ZF(){try{let n=await $e("get_run_state",{observeSession:!0,playerInstance:document.hidden?void 0:jA},1800);if(!Dt)return;if(n.preferences){let r=qt.autoPrompt!==n.preferences.autoPrompt;qt=n.preferences,Ki.checked=qt.autoplayNext,r&&Zi()}let e=NA(Zt,n),t=OA(Zt,n),i=Zt?.state!==n.state||Zt?.turnId!==n.turnId;Zt=n,i&&Zi(),JA(),e&&at&&qt.autoPauseOnFinish?cn(e):t&&qt.autoPlayOnStart&&at&&Xe?.playable&&re.paused&&!$n&&no(n.turnId,!0)}catch{if(!Dt)return;j("lamp").classList.remove("on"),zn("state","\u672C\u673A\u72B6\u6001\u4E0D\u53EF\u8FBE")}}function qF(){let n=re.duration;!Number.isFinite(n)||!kn||(qr.value=String(Math.round(re.currentTime/n*1e3)),gl(qr),zn("time",eo(re.currentTime)+" / "+eo(n)))}async function no(n,e=!1){if(!Xe?.playable||!at||!Dt)return;pr=e?void 0:n;let t=++ct,i=Xe,r=at;$n=!0,Hi(),j("stopped").hidden=!0;try{if(!kn){We("\u6B63\u5728\u51C6\u5907\u64AD\u653E\u2026");let s=await $e("prepare_playback",{episodeId:i.id,retry:!0}),o=Date.now()+24e4;for(;s.status==="preparing"&&t===ct&&Date.now()<o;){if(We("\u6B63\u5728\u672C\u673A\u51C6\u5907\u6574\u96C6\u2026"),await KF(700),t!==ct)return;s=await $e("prepare_playback",{episodeId:i.id})}if(t!==ct)return;if(s.status!=="ready")throw Error(s.reason||"\u51C6\u5907\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5");let a=s;if(Hr!=="src"in a)throw Error("\u672C\u96C6\u64AD\u653E\u5730\u5740\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u8BD5");await Zr;let l=await $e("get_history",{seriesId:r.id,episodeId:i.id});if(t!==ct)return;Yr();let c=new AbortController;ul=c;let u=CA(re,c.signal),d=m=>{ul===c&&(c.abort(Error(m)),kn&&(cn(m),Yr()))};try{"stream"in a?$S=DA(re,i.id,a.stream,a.manifest,d,()=>{ul===c&&XA()}):(re.src=a.src,re.load())}catch(m){d(Ct(m))}if(await u,t!==ct)return;let f=l.items[0],h=f&&f.positionMs<f.durationMs?f.positionMs/1e3:0;re.currentTime=h>0&&h<re.duration-5?h:0,re.currentTime>0&&(zn("resumeTime","\u5DF2\u4ECE "+eo(h)+" \u7EE7\u7EED"),j("resumed").hidden=!1),kn=!0}if(n){let s=await $e("get_run_state",{observeSession:!0},1800);if(t!==ct)return;if(s.turnId!==n||s.state!=="submitted"||e&&!s.preferences?.autoPlayOnStart){cn(e?"":"\u63A8\u8350\u6240\u5C5E\u4EFB\u52A1\u5DF2\u7ED3\u675F\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED\u89C2\u770B");return}}if(t!==ct||!Dt)return;$n=!1,un==="finished"&&(re.currentTime=0),un="playing",re.playbackRate=parseFloat(j("speed").value),n&&!e&&(re.muted=!0);try{await re.play()}catch(s){if(t!==ct||!Dt)return;if(!(s instanceof DOMException&&["AbortError","NotAllowedError"].includes(s.name))||!document.hidden&&document.hasFocus()&&Wr?.action!==t)throw s instanceof DOMException&&s.name==="NotAllowedError"&&n&&!e?Error("\u5BBF\u4E3B\u963B\u6B62\u4E86\u81EA\u52A8\u64AD\u653E\uFF0C\u8BF7\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED"):s;Ff();return}t===ct&&(Cf(),We("\u6B63\u5728\u64AD\u653E"),kS=Date.now(),Hi())}catch(s){t===ct&&(kn||Yr(),cn(Ct(s)))}}function WF(){!re.paused||$n?cn("\u5DF2\u624B\u52A8\u6682\u505C"):no()}for(let n of[re,Rf,TS,j("resumePlayback")])n.addEventListener("click",WF);function XA(){!kn||un!=="playing"||!Number.isFinite(re.duration)||re.currentTime<re.duration-1||(un="finished",qi(),Ki.checked&&Dt?HA(!0).catch(n=>We(Ct(n))):cn("\u672C\u96C6\u5DF2\u64AD\u5B8C"),Zr.then(Nf).catch(()=>{}))}re.onended=XA;Ki.onchange=()=>{$e("set_preferences",{autoplayNext:Ki.checked}).then(n=>{qt=n}).catch(n=>We(Ct(n)))};re.ontimeupdate=()=>{qF(),!re.paused&&Date.now()-kS>=5e3&&(kS=Date.now(),qi())};re.onpause=()=>{Hi(),kn&&qi(),(document.hidden||!document.hasFocus()||Wr?.action===ct)&&Ff()};re.onplay=Hi;re.onplaying=Cf;re.onerror=()=>{kn&&(cn(SS(re.error?.code)),Yr())};qr.oninput=()=>{gl(qr),kn&&Number.isFinite(re.duration)&&(un==="finished"&&(un="idle"),re.currentTime=Number(qr.value)*re.duration/1e3)};qr.onchange=()=>{qi(re.currentTime===0)};re.onloadedmetadata=()=>{re.videoWidth&&re.videoHeight&&(j("stage").style.aspectRatio=re.videoWidth+"/"+re.videoHeight)};j("restart").onclick=()=>{un==="finished"&&(un="idle"),re.currentTime=0,j("resumed").hidden=!0,qi(!0)};j("mute").onclick=()=>{re.volume===0?(re.volume=.7,re.muted=!1):re.muted=!re.muted};async function QA(){let n=j("stage");if(document.fullscreenElement){await document.exitFullscreen();return}if(n.classList.contains("expanded")){n.classList.remove("expanded"),Df();return}try{await n.requestFullscreen()}catch{n.classList.add("expanded"),Df()}}j("fullscreen").onclick=()=>{QA().catch(n=>We(Ct(n)))};document.addEventListener("fullscreenchange",Df);function Df(){let n=j("stage"),e=!!document.fullscreenElement||n.classList.contains("expanded");n.classList.toggle("isFull",e),ro(j("fullscreen"),e?"collapse":"expand",st(e?"\u9000\u51FA\u5168\u5C4F":"\u5168\u5C4F"))}var zA;j("stage").addEventListener("pointermove",()=>{let n=j("stage");n.classList.add("awake"),clearTimeout(zA),zA=setTimeout(()=>n.classList.remove("awake"),2400)});j("stage").addEventListener("pointerleave",()=>j("stage").classList.remove("awake"));document.addEventListener("keydown",n=>{n.key==="Escape"&&j("stage").classList.contains("expanded")&&QA()});re.onvolumechange=()=>{let n=re.muted||re.volume===0;ro(j("mute"),n?"mute":"volume",st(n?"\u53D6\u6D88\u9759\u97F3":"\u9759\u97F3")),j("mute").setAttribute("aria-pressed",String(n))};re.volume=.7;j("speed").onchange=n=>re.playbackRate=parseFloat(n.target.value);var pl=j("query"),wS,Uf=!1;function PS(){clearTimeout(wS),Uf||Jr(!1,pl.value.trim())}function RS(){clearTimeout(wS),++Vi,!Uf&&(pl.value.trim()?wS=setTimeout(PS,400):PS())}pl.addEventListener("input",RS);pl.addEventListener("compositionstart",()=>{Uf=!0,RS()});pl.addEventListener("compositionend",()=>{Uf=!1,RS()});j("search").onsubmit=n=>{n.preventDefault(),PS()};j("more").onclick=()=>{Jr(!0)};async function YF(){let n=at,e=Xe;if(!(!n||!e))try{await cn();let t=await $e("create_browser_pairing",{seriesId:n.id,episodeId:e.id,title:n.title});if(at!==n||Xe!==e)return;j("linkValue").value=t.url,j("link").hidden=!1,j("link").scrollIntoView({block:"nearest"}),setTimeout(()=>{j("linkValue").value===t.url&&(j("link").hidden=!0,j("linkValue").value="")},6e4)}catch(t){We(Ct(t))}}j("pair").onclick=YF;j("copy").onclick=async()=>{let n=j("linkValue");try{await navigator.clipboard.writeText(n.value),We("\u5DF2\u590D\u5236\uFF0C\u8BF7\u5728 Codex \u5185\u7F6E\u6D4F\u89C8\u5668\u6253\u5F00")}catch{n.select(),We("\u94FE\u63A5\u5DF2\u9009\u4E2D\uFF0C\u8BF7\u590D\u5236\u5E76\u5728 Codex \u5185\u7F6E\u6D4F\u89C8\u5668\u6253\u5F00")}};j("settingsCancel").onclick=()=>j("prefs").click();j("prefs").onclick=()=>{j("settings").hidden=!j("settings").hidden,j("prefs").setAttribute("aria-expanded",String(!j("settings").hidden)),j("autoPrompt").checked=qt.autoPrompt,j("autoPauseOnFinish").checked=qt.autoPauseOnFinish,j("autoPlayOnStart").checked=qt.autoPlayOnStart,j("terms").value=qt.searchTerms.join("\uFF0C")};j("settings").onsubmit=n=>{n.preventDefault();let e=j("terms").value.split(/[,,]/).map(t=>t.trim()).filter(Boolean);$e("set_preferences",{autoPrompt:j("autoPrompt").checked,autoPauseOnFinish:j("autoPauseOnFinish").checked,autoPlayOnStart:j("autoPlayOnStart").checked,searchTerms:e}).then(async t=>{qt=t,Ki.checked=qt.autoplayNext,j("settings").hidden=!0,j("prefs").setAttribute("aria-expanded","false"),Zi(),at||await Jr()}).catch(t=>We(Ct(t)))};j("choose").onclick=async()=>{try{let n=await $e("list_sessions");j("choices").replaceChildren(...n.items.map(e=>An("\u2026"+e.suffix+" \xB7 "+new Date(e.at).toLocaleString(),async()=>{await $e("select_session",{choice:e.choice}),hr.identified=!0,LS(Dt&&!document.hidden),j("choose").hidden=!0,j("choices").replaceChildren(),await Mf()}))),n.items.length||We("\u8FD8\u6CA1\u6709\u672C\u673A\u56DE\u5408\u8BB0\u5F55\uFF0C\u53EF\u5148\u624B\u52A8\u89C2\u770B")}catch(n){We(Ct(n))}};function LS(n){return hr.identified?$e("set_player_visible",{instance:jA,visible:n},1800).catch(()=>{}):Promise.resolve()}async function ew(){Dt&&(Dt=!1,await Promise.all([cn("\u5DF2\u6682\u505C\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED",!0),LS(!1)]))}function tw(n){if(n.action!==ct||!Dt||!kn||un!=="playing"||!re.paused||re.ended||re.error)return;let e=re.currentTime;n.lastPosition!==void 0&&Math.abs(e-n.lastPosition)<.25||(n.lastPosition=e,re.play().then(()=>{n.action===ct&&!re.paused&&We("\u6B63\u5728\u64AD\u653E")}).catch(()=>{}))}function Ff(){!Dt||un!=="playing"||(Wr?.action!==ct&&(Wr={action:ct}),tw(Wr))}function nw(){let n=Wr;n&&(Wr=void 0,Mf().then(()=>tw({action:n.action})))}function rw(){Dt&&(LS(!document.hidden),document.hidden?(Ff(),qi()):nw(),Mf())}function iw(){!fl||Dt||(Dt=!0,rw(),pr&&Xe?.playable&&re.paused&&!$n&&no(pr))}document.addEventListener("visibilitychange",rw);window.addEventListener("blur",Ff);window.addEventListener("focus",nw);window.addEventListener("pagehide",()=>{ew()});window.addEventListener("pageshow",iw);async function sw(n){if(fl)return;if(fl=!0,pr=void 0,AS=n?.play?n.playbackId:void 0,navigator.mediaSession&&(navigator.mediaSession.setActionHandler("pause",()=>{cn("\u5DF2\u624B\u52A8\u6682\u505C")}),navigator.mediaSession.setActionHandler("play",()=>{re.paused&&!$n&&no()})),VA=window.setInterval(()=>{Mf()},1e3),j("pair").hidden=Hr||BA,j("choose").hidden=Hr||hr.identified,Zt=null,JA(),iw(),$e("get_preferences").then(t=>{fl&&(qt=t,Ki.checked=qt.autoplayNext??!0,Zi())}).catch(t=>We(Ct(t))),n?.pick){let t=n.pick;await to(t,t.episodeId,n.play,n.turnId),n.reason==="turn-ended"&&at?.id===t.id&&re.paused&&!$n&&We("\u63A8\u8350\u6240\u5C5E\u4EFB\u52A1\u5DF2\u7ED3\u675F\uFF0C\u70B9\u51FB\u64AD\u653E\u7EE7\u7EED\u89C2\u770B");return}j("home").hidden=!1,j("watch").hidden=!0;let e=Jr();Nf().then(()=>{!at&&mr.length&&yt.length&&Gi()}).catch(t=>We(Ct(t))),hr.selection&&await to({id:hr.selection.seriesId,title:hr.selection.title||"\u7EA2\u679C\u77ED\u5267"},hr.selection.episodeId),await e}function ow(){let n=ew();return fl=!1,pr=void 0,navigator.mediaSession&&(navigator.mediaSession.setActionHandler("pause",null),navigator.mediaSession.setActionHandler("play",null)),window.clearInterval(VA),++Jn,Yr(),n}var Pf=BA?MA(n=>{sw(n).catch(e=>We(Ct(e)))},ow):null;LA(n=>{CS(PA()),hr=n,Pf?n.waitingTurn&&Pf.connected():sw().catch(e=>We(Ct(e)))},async()=>{Pf?.dispose(),await ow()},()=>Pf?.modeChanged()).catch(n=>We(Ct(n)));})();
|
|
1971
1971
|
|
|
1972
1972
|
</script>
|
|
1973
1973
|
</body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kyun.si/codex-hongguo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "在 Codex 桌面对话中观看红果短剧并跟随回合暂停。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"os": [
|
|
11
11
|
"darwin",
|
|
12
|
-
"linux"
|
|
12
|
+
"linux",
|
|
13
|
+
"win32"
|
|
13
14
|
],
|
|
14
15
|
"cpu": [
|
|
15
16
|
"x64",
|
|
@@ -5,9 +5,9 @@ description: 配置红果短剧插件,检查本机播放环境和回合自动
|
|
|
5
5
|
|
|
6
6
|
帮助用户在当前安装环境完成红果短剧配置。该插件用于本机执行的 Codex 对话,不需要红果账号、API Key 或浏览器自动化权限。
|
|
7
7
|
|
|
8
|
-
从此 SKILL.md 的实际位置向上两级确定插件根目录。在 macOS/Linux 用 `sh "<插件根目录>/bin/run-node" check` 检查;Windows x64
|
|
8
|
+
从此 SKILL.md 的实际位置向上两级确定插件根目录。在 macOS/Linux 用 `sh "<插件根目录>/bin/run-node" check` 检查;Windows x64 在 PowerShell 用 `& "<插件根目录>\bin\run-node.exe" check`。启动器自动寻找 Node,并检查版本及 SQLite。正确引用包含空格的路径。脚本只输出 Node、进度库、FFmpeg 的环境元数据,以及固定的 Hooks 人工授权核对提示,不检测授权状态,不发送模型请求。npm 包支持 macOS/Linux 和 Windows x64,Windows 原生启动器随 npm 包和离线包提供。
|
|
9
9
|
|
|
10
|
-
- 需要 Node.js >=22.16。播放组件由插件自动下载、校验并缓存,无需用户自行安装 FFmpeg
|
|
10
|
+
- 需要 Node.js >=22.16。播放组件由插件自动下载、校验并缓存,无需用户自行安装 FFmpeg。首次需要联网;准备失败时检查网络,macOS/Linux 重新运行 `npx "@kyun.si/codex-hongguo@latest" setup`,Windows 重新运行 `npx.cmd "@kyun.si/codex-hongguo@latest" setup`。PowerShell 中以 `@` 开头的 npm 包名必须加引号,以免出现 `SplattingNotPermitted`;调用 npm 工具时使用 `npx.cmd`、`npm.cmd`。Windows 需要 x64 Node;ARM64 原生 Node 暂不支持。特殊安装可使用 HONGGUO_NODE、HONGGUO_FFMPEG、HONGGUO_CODEX 指定程序;不要修改用户其他插件、认证或网络配置。
|
|
11
11
|
- Hooks 授权不执行检测。固定提示用户打开 Codex「设置 → Hooks → 红果短剧」,人工检查、信任并启用 UserPromptSubmit、Stop、Interrupt。不得自动宣称已授权或无需重复授权,不读取或写入信任记录,不把历史回合事件当成授权证明。
|
|
12
12
|
|
|
13
13
|
告诉用户从新本地对话的右侧 + 搜索“红果”,或在“更多工具”的“插件和 MCP”分组打开红果短剧。点击推荐或搜索结果即可开播,默认静音;打开扬声器出声。未完成 Hooks 配置时仍可手动观看。
|