import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"; import { Type } from "typebox"; import { credentials, REGION, videoApproval } from "./access.ts"; import { resolveSetting } from "./pi-ext-settings.ts"; import { renderCall, renderResult } from "./render.ts"; import { outputSchema, result } from "./tools.ts"; export function registerCapabilities(pi: ExtensionAPI): void { pi.registerTool({ name: "minimax_capabilities", label: "MiniMax capabilities", description: "Non-consuming local M Plan capability/access discovery; no capability probe, catalog request, quota preflight, or generation. Reports conditional families unavailable unless established, CN unavailable, credential blockers, H3 approval mode, documented plan differences. Search/quota remain existing integration surfaces.", parameters: Type.Object({}, { additionalProperties: false }), outputSchema, renderCall: renderCall("capabilities"), renderResult: renderResult("capabilities"), async execute(_id, _params, signal, _update, ctx) { const service = resolveSetting(pi, ctx, REGION); const approval = videoApproval(pi, ctx); let auth: { state: string; reason?: string }; try { await credentials(ctx, signal); auth = { state: "subscription-key-prefix", reason: "Subscription prefix only; current M Plan access, tier, entitlement and available included allowance remain unverified.", }; } catch (error) { auth = { state: "blocked", reason: error instanceof Error ? error.message : "Pi credentials unavailable.", }; } const blocker = !service.ok ? service.error : service.value !== "global" ? "CN media routes not established" : auth.state === "blocked" ? auth.reason : undefined; // Cheap operations never ask; only H3 submit is gated. const videoSpending = !approval.ok ? "blocked-invalid-setting" : approval.value === "always" ? "always-allowed-by-user-setting" : ctx.hasUI ? "ask-per-submit-or-session" : "blocked-noninteractive-until-videoApproval-always"; const spending = { image: "no-approval", understanding: "no-approval", speech: "no-approval", video: videoSpending, }; const core = [ { operation: "image-generation", model: "image-01", surface: "native minimax-media/image-01", route: "POST /v1/image_generation", inputs: "text ≤1500 characters; n 1–9; dimensions 512–2048 divisible by 8", outputs: "inline JPEG/PNG base64; estimate uses actual returned count", }, { operation: "image-understanding", model: "API-vlm", surface: "minimax_understand_image", route: "POST /v1/coding_plan/vlm", inputs: "prompt ≤7000; local JPEG/PNG/WebP or public HTTPS image ≤8 MiB", outputs: "text; catalog request estimate, actual charge unknown", }, { operation: "speech", model: "speech-2.8-turbo", surface: "minimax_speech", route: "POST /v1/t2a_v2", inputs: "text ≤10000; English_Graceful_Lady stock voice; absolute approved outputPath", outputs: "MP3 file; estimate only from reported usage_characters", }, { operation: "video", model: "MiniMax-H3", surface: "minimax_video", route: "POST /v2/video_generation", inputs: "text ≤7000; duration 4–15; 768P|2K; explicit job identity", outputs: "pending owned job; one-query status; queued cancellation; MP4 retrieval ≤128 MiB; last-seven-day observation", }, ].map((cap) => ({ ...cap, integration: "implemented", routeEvidence: "global endpoint feasibility observed 2026-11-09; no live extension acceptance", accountAccess: "unverified; explicit operation can establish observed access only for that call", availability: blocker ? "blocked" : cap.operation === "video" ? videoSpending.startsWith("blocked") ? "blocked-until-approval" : "available-with-approval" : "available", ...(blocker ? { blocker } : {}), })); const conditional = [ "reference-image generation (not arbitrary editing)", "H3 references/variants/regeneration/Context-IR", "video understanding", "transcription", "voice cloning/design/management", "music/lyrics/cover", "supporting file operations", ]; return result( [ `MiniMax M Plan (local discovery, no network): region ${service.ok ? service.value : "invalid"}; credential ${auth.state}${blocker ? `; blocked: ${blocker}` : ""}.`, `Available: native image minimax-media/image-01, minimax_understand_image, minimax_speech (no approval); minimax_video H3 (${videoSpending}).`, "Plans: Go lacks H3; Explore 3× / Build 7.5× Go usage incl. H3. Account tier unknown. Purchased Credits, if ever bought, could be consumed.", `Unavailable (unverified): ${conditional.join("; ")}.`, ].join("\n"), { region: service.ok ? service.value : "invalid", credential: auth, spending, videoApproval: approval.ok ? { source: approval.source, value: approval.value } : { error: approval.error }, automaticCreditsOverflow: "possible only if purchased Credits exist; cannot be prevented by this extension", accountTier: "unknown", documentedPlans: { Go: "image/audio/understanding included; H3 not included", Explore: "3× Go usage; H3 included", Build: "7.5× Go usage; H3 included", }, core, conditional: conditional.map((operation) => ({ operation, state: "unavailable-unverified", reason: "Current route and M Plan account eligibility not established for this integration; no consuming probe.", })), otherSurfaces: { search: "existing web integration; explicit MiniMax selection", quota: "post-operation M Plan remains read + quota:provider-activity event; not a spending lock", chat: "built-in minimax provider unchanged", liveVoice: "existing external Voice service unchanged", }, networkRequests: 0, }, ); }, }); }