@vetta-org/plugin-sdk 0.1.1 → 0.2.0
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/dist/activity-tab.d.ts +2 -0
- package/dist/activity-tab.d.ts.map +1 -1
- package/dist/activity-tab.js +1 -1
- package/dist/activity-tab.js.map +1 -1
- package/dist/agent.d.ts +158 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -1
- package/dist/agent.js.map +1 -1
- package/dist/ai.d.ts +93 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/app-actions.d.ts +9 -0
- package/dist/app-actions.d.ts.map +1 -1
- package/dist/app-actions.js.map +1 -1
- package/dist/artifacts.d.ts +31 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +2 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/browser.d.ts +119 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -0
- package/dist/capture.d.ts +64 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +2 -0
- package/dist/capture.js.map +1 -0
- package/dist/context.d.ts +46 -5
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/conversation.d.ts +66 -2
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/gateway.d.ts +37 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +14 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +20 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +34 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +2 -0
- package/dist/jobs.js.map +1 -0
- package/dist/manifest-schema.d.ts +234 -0
- package/dist/manifest-schema.d.ts.map +1 -0
- package/dist/manifest-schema.js +145 -0
- package/dist/manifest-schema.js.map +1 -0
- package/dist/manifest.d.ts +21 -55
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +342 -1
- package/dist/manifest.js.map +1 -1
- package/dist/media.d.ts +193 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +11 -0
- package/dist/media.js.map +1 -0
- package/dist/network.d.ts +2 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js.map +1 -1
- package/dist/npm-package.d.ts +17 -0
- package/dist/npm-package.d.ts.map +1 -0
- package/dist/npm-package.js +38 -0
- package/dist/npm-package.js.map +1 -0
- package/dist/official.d.ts +218 -10
- package/dist/official.d.ts.map +1 -1
- package/dist/official.js.map +1 -1
- package/dist/permissions.d.ts +2 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +54 -1
- package/dist/permissions.js.map +1 -1
- package/dist/prompt-attachment.d.ts +30 -6
- package/dist/prompt-attachment.d.ts.map +1 -1
- package/dist/prompt-attachment.js +35 -1
- package/dist/prompt-attachment.js.map +1 -1
- package/dist/quickjs.d.ts +147 -0
- package/dist/quickjs.d.ts.map +1 -0
- package/dist/quickjs.js +2 -0
- package/dist/quickjs.js.map +1 -0
- package/dist/storage.d.ts +7 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/ui.d.ts +223 -15
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/package.json +21 -2
- package/src/tailwind-theme.css +30 -0
package/dist/manifest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * MCP server config declared inside a plugin (stdio or http). Relative paths in\n * stdio `command`/`args`/`cwd` are resolved against the plugin root at contribute time.\n */\nexport type PluginMcpServerConfig =\n\t| {\n\t\t\ttype?: \"stdio\";\n\t\t\tcommand: string;\n\t\t\targs?: string[];\n\t\t\tenv?: Record<string, string>;\n\t\t\tcwd?: string;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t\t\tdisplayName?: string;\n\t\t\tdescription?: string;\n\t\t\t/** 该 server 的工具允许出现的工作模式 slug(agent_mode 轴,缺省/空 = 通用)。见 ADR-0046。 */\n\t\t\tagent_mode?: string | string[];\n\t }\n\t| {\n\t\t\ttype: \"http\";\n\t\t\turl: string;\n\t\t\theaders?: Record<string, string>;\n\t\t\toauthClientId?: string;\n\t\t\toauthDeviceFlow?: boolean;\n\t\t\toauthScopes?: string;\n\t\t\tdisabled?: boolean;\n\t\t\tautoApprove?: string[];\n\t\t\tstartupTimeout?: number;\n\t\t\tdebug?: boolean;\n\t\t\tdisplayName?: string;\n\t\t\tdescription?: string;\n\t\t\t/** 该 server 的工具允许出现的工作模式 slug(agent_mode 轴,缺省/空 = 通用)。见 ADR-0046。 */\n\t\t\tagent_mode?: string | string[];\n\t };\n\nexport interface PluginAgentManifest {\n\tsystemPrompt?: {\n\t\t/**\n\t\t * Plugin-packaged prompt contribution file paths. Main-process aggregation\n\t\t * resolves these relative to the installed plugin root.\n\t\t */\n\t\tpromptPaths?: string[];\n\t};\n\t/** Plugin-packaged skill files or directories to add to the agent resource graph. */\n\tskillPaths?: string[];\n\t/**\n\t * Plugin-scoped MCP servers. Either a relative path to `.mcp.json`\n\t * (shape `{ mcpServers: { ... } }`) or an inline map of server configs.\n\t * Requires permission `agent.mcp.control`. Never written into user mcp.json.\n\t */\n\tmcpServers?: string | Record<string, PluginMcpServerConfig>;\n\t/** Declarative tool visibility policy. Names are tool ids after registration. */\n\ttoolPolicy?: {\n\t\tallow?: string[];\n\t\tdeny?: string[];\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAA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EAAE,IAAI,UAAU,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/E,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/F,OAAO,OAAO,KAAK,SAAS,IAAI,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;AAAA,CACvE","sourcesContent":["import { type Static, type TSchema } from \"@sinclair/typebox\";\nimport type { ValueError } from \"@sinclair/typebox/errors\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport {\n\tPluginCommandNameSchema,\n\tPluginCommandNamesSchema,\n\tPluginIdSchema,\n\tPluginManifestSchema,\n\tPluginMcpServerConfigSchema,\n\tPluginVersionSchema,\n\ttype PluginAgentManifest,\n\ttype PluginBrowserManifest,\n\ttype PluginManifest,\n\ttype PluginManifestInput,\n\ttype PluginMcpServerConfig,\n\ttype PluginNetworkManifest,\n\ttype PluginSettingSchema,\n} from \"./manifest-schema.js\";\nimport { PLUGIN_PERMISSIONS, type PluginPermission } from \"./permissions.js\";\n\nexport {\n\tPluginAgentManifestSchema,\n\tPluginBrowserManifestSchema,\n\tPluginCommandNameSchema,\n\tPluginCommandNamesSchema,\n\tPluginIdSchema,\n\tPluginManifestSchema,\n\tPluginMcpHttpServerConfigSchema,\n\tPluginMcpServerConfigSchema,\n\tPluginMcpStdioServerConfigSchema,\n\tPluginModuleFederationManifestSchema,\n\tPluginNetworkManifestSchema,\n\tPluginPermissionSchema,\n\tPluginSettingDefinitionSchema,\n\tPluginVersionSchema,\n} from \"./manifest-schema.js\";\nexport type {\n\tPluginAgentManifest,\n\tPluginBrowserManifest,\n\tPluginManifest,\n\tPluginManifestInput,\n\tPluginMcpServerConfig,\n\tPluginNetworkManifest,\n\tPluginSettingSchema,\n} from \"./manifest-schema.js\";\nexport { PLUGIN_PERMISSIONS } from \"./permissions.js\";\nexport type { PluginPermission } from \"./permissions.js\";\n\nexport interface PluginManifestResourceReference {\n\tfield: string;\n\tpath: string;\n\tkind: \"file\" | \"file-or-directory\";\n}\n\nfunction schemaErrorPath(path: string): string {\n\tif (!path) return \"\";\n\treturn path\n\t\t.split(\"/\")\n\t\t.slice(1)\n\t\t.map((segment) => segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\"))\n\t\t.map((segment) => {\n\t\t\tif (segment === \"\") return '[\"\"]';\n\t\t\treturn /^\\d+$/.test(segment) ? `[${segment}]` : `.${segment}`;\n\t\t})\n\t\t.join(\"\");\n}\n\nfunction mostSpecificSchemaError(issue: ValueError): ValueError {\n\tconst nested = issue.errors.flatMap((iterator) =>\n\t\t[...iterator].map((child) => mostSpecificSchemaError(child)),\n\t);\n\tconst deeper = nested.filter((child) => child.path.length > issue.path.length);\n\tif (deeper.length === 0) return issue;\n\treturn deeper.reduce((best, child) => (child.path.length > best.path.length ? child : best));\n}\n\nfunction assertSchema<Schema extends TSchema>(\n\tschema: Schema,\n\tvalue: unknown,\n\tfieldName: string,\n): asserts value is Static<Schema> {\n\tif (Value.Check(schema, value)) return;\n\tconst firstIssue = Value.Errors(schema, value).First();\n\tconst issue = firstIssue ? mostSpecificSchemaError(firstIssue) : undefined;\n\tconst location = `${fieldName}${schemaErrorPath(issue?.path ?? \"\")}`;\n\tthrow new Error(`Invalid plugin ${location}: ${issue?.message ?? \"schema validation failed\"}`);\n}\n\nfunction trimString(value: string): string {\n\treturn value.trim();\n}\n\nfunction normalizeStringArray(values: string[] | undefined): string[] {\n\treturn (values ?? []).map(trimString);\n}\n\nfunction normalizeOptionalAgentModes(value: string | string[] | undefined): string | string[] | undefined {\n\tif (value === undefined) return undefined;\n\treturn Array.isArray(value) ? normalizeStringArray(value) : trimString(value);\n}\n\nfunction normalizeSetting(setting: PluginSettingSchema): PluginSettingSchema {\n\tconst common = {\n\t\tkey: trimString(setting.key),\n\t\tdescription: setting.description,\n\t\tdefault: setting.default,\n\t\tenum: setting.enum?.map(trimString),\n\t\tvisibleWhen: setting.visibleWhen\n\t\t\t? {\n\t\t\t\t\tkey: trimString(setting.visibleWhen.key),\n\t\t\t\t\tin: setting.visibleWhen.in.map(trimString),\n\t\t\t\t}\n\t\t\t: undefined,\n\t};\n\tif (setting.type === \"desc\") {\n\t\treturn {\n\t\t\t...common,\n\t\t\ttype: \"desc\",\n\t\t\ttitle: setting.title === undefined ? undefined : trimString(setting.title),\n\t\t};\n\t}\n\treturn {\n\t\t...common,\n\t\ttype: setting.type,\n\t\ttitle: trimString(setting.title),\n\t};\n}\n\nfunction normalizeSettings(settings: PluginSettingSchema[] | undefined): PluginSettingSchema[] | undefined {\n\tif (!settings || settings.length === 0) return undefined;\n\treturn settings.map(normalizeSetting);\n}\n\nfunction normalizePermissions(permissions: PluginPermission[] | undefined): PluginPermission[] {\n\treturn Array.from(new Set(permissions ?? []));\n}\n\nfunction normalizeAllowedHost(value: string, fieldName: \"network\" | \"browser\"): string {\n\tconst raw = trimString(value).toLowerCase();\n\tif (raw === \"*\") return raw;\n\tconst wildcard = raw.startsWith(\"*.\");\n\tconst candidate = wildcard ? raw.slice(2) : raw;\n\tif (!candidate || candidate.includes(\"*\") || /[\\\\/?#@]/.test(candidate)) {\n\t\tthrow new Error(`Invalid plugin ${fieldName}.allowedHosts entry: ${value}`);\n\t}\n\tconst unwrapped = candidate.startsWith(\"[\") && candidate.endsWith(\"]\") ? candidate.slice(1, -1) : candidate;\n\tif (wildcard && unwrapped.includes(\":\")) {\n\t\tthrow new Error(`Invalid plugin ${fieldName}.allowedHosts entry: ${value}`);\n\t}\n\ttry {\n\t\tconst parsed = new URL(`http://${unwrapped.includes(\":\") ? `[${unwrapped}]` : unwrapped}`);\n\t\tconst hostname = parsed.hostname.replace(/^\\[|\\]$/g, \"\").replace(/\\.$/, \"\").toLowerCase();\n\t\tif (!hostname || parsed.port || parsed.username || parsed.password) throw new Error(\"invalid host\");\n\t\treturn wildcard ? `*.${hostname}` : hostname;\n\t} catch {\n\t\tthrow new Error(`Invalid plugin ${fieldName}.allowedHosts entry: ${value}`);\n\t}\n}\n\nfunction normalizeNetworkManifest(network: PluginNetworkManifest | undefined): PluginNetworkManifest | undefined {\n\tif (!network) return undefined;\n\treturn { allowedHosts: Array.from(new Set(network.allowedHosts.map((host) => normalizeAllowedHost(host, \"network\")))) };\n}\n\nfunction normalizeBrowserManifest(browser: PluginBrowserManifest | undefined): PluginBrowserManifest | undefined {\n\tif (!browser) return undefined;\n\treturn { allowedHosts: Array.from(new Set(browser.allowedHosts.map((host) => normalizeAllowedHost(host, \"browser\")))) };\n}\n\nfunction normalizeModuleFederation(\n\tmoduleFederation: PluginManifestInput[\"moduleFederation\"],\n): PluginManifest[\"moduleFederation\"] {\n\treturn {\n\t\tremoteName: trimString(moduleFederation.remoteName),\n\t\texpose: trimString(moduleFederation.expose),\n\t};\n}\n\nfunction normalizeToolPolicy(\n\ttoolPolicy: PluginAgentManifest[\"toolPolicy\"],\n): PluginAgentManifest[\"toolPolicy\"] {\n\tif (!toolPolicy) return undefined;\n\treturn {\n\t\tallow: normalizeStringArray(toolPolicy.allow),\n\t\tdeny: normalizeStringArray(toolPolicy.deny),\n\t};\n}\n\nfunction normalizeMcpServers(\n\tmcpServers: PluginAgentManifest[\"mcpServers\"],\n): PluginAgentManifest[\"mcpServers\"] {\n\tif (mcpServers === undefined) return undefined;\n\tif (typeof mcpServers === \"string\") {\n\t\treturn validatePluginRelativePath(trimString(mcpServers), \"agent.mcpServers\");\n\t}\n\tconst result: Record<string, PluginMcpServerConfig> = {};\n\tfor (const [name, config] of Object.entries(mcpServers)) {\n\t\tresult[trimString(name)] = normalizePluginMcpServerConfig(config);\n\t}\n\treturn result;\n}\n\nfunction normalizeAgentManifest(agent: PluginAgentManifest | undefined): PluginAgentManifest | undefined {\n\tif (!agent) return undefined;\n\treturn {\n\t\tsystemPrompt: agent.systemPrompt\n\t\t\t? {\n\t\t\t\t\tpromptPaths: normalizeStringArray(agent.systemPrompt.promptPaths).map((path) =>\n\t\t\t\t\t\tvalidatePluginRelativePath(path, \"agent.systemPrompt.promptPaths\"),\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tskillPaths: normalizeStringArray(agent.skillPaths).map((path) =>\n\t\t\tvalidatePluginRelativePath(path, \"agent.skillPaths\"),\n\t\t),\n\t\tmcpServers: normalizeMcpServers(agent.mcpServers),\n\t\ttoolPolicy: normalizeToolPolicy(agent.toolPolicy),\n\t};\n}\n\nfunction normalizePluginMcpServerConfig(config: PluginMcpServerConfig): PluginMcpServerConfig {\n\tconst common = {\n\t\tdisabled: config.disabled,\n\t\tautoApprove: config.autoApprove?.map(trimString),\n\t\tstartupTimeout: config.startupTimeout,\n\t\tdebug: config.debug,\n\t\tdisplayName: config.displayName,\n\t\tdescription: config.description,\n\t\tagent_mode: normalizeOptionalAgentModes(config.agent_mode),\n\t};\n\tif (config.type === \"http\") {\n\t\treturn {\n\t\t\ttype: \"http\",\n\t\t\turl: trimString(config.url),\n\t\t\theaders: config.headers ? { ...config.headers } : undefined,\n\t\t\toauthClientId: config.oauthClientId,\n\t\t\toauthDeviceFlow: config.oauthDeviceFlow,\n\t\t\toauthScopes: config.oauthScopes,\n\t\t\t...common,\n\t\t};\n\t}\n\treturn {\n\t\ttype: config.type,\n\t\tcommand: trimString(config.command),\n\t\targs: config.args ? [...config.args] : undefined,\n\t\tenv: config.env ? { ...config.env } : undefined,\n\t\tcwd: config.cwd,\n\t\t...common,\n\t};\n}\n\nexport function validatePluginId(id: string): void {\n\tif (!Value.Check(PluginIdSchema, id)) {\n\t\tthrow new Error(\"Plugin id must be 1-64 chars: lowercase letters, numbers, dot, underscore, or dash\");\n\t}\n}\n\nexport function validatePluginVersion(version: string): void {\n\tif (!Value.Check(PluginVersionSchema, version)) {\n\t\tthrow new Error(\"Plugin version must be 1-64 chars and cannot contain path separators\");\n\t}\n}\n\nexport function validatePluginRelativePath(value: string, fieldName: string): string {\n\tif (value.startsWith(\"/\") || /^[a-zA-Z]:/.test(value)) {\n\t\tthrow new Error(`Invalid plugin ${fieldName}`);\n\t}\n\tconst parts: string[] = [];\n\tfor (const part of value.replace(/\\\\/g, \"/\").split(\"/\")) {\n\t\tif (part === \"\" || part === \".\") continue;\n\t\tif (part === \"..\") {\n\t\t\tif (parts.length === 0) throw new Error(`Invalid plugin ${fieldName}`);\n\t\t\tparts.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tparts.push(part);\n\t}\n\tconst normalized = parts.join(\"/\");\n\tif (!normalized) throw new Error(`Invalid plugin ${fieldName}`);\n\treturn normalized;\n}\n\nexport function parsePluginCommandNames(value: unknown): string[] {\n\tif (value === undefined) return [];\n\tassertSchema(PluginCommandNamesSchema, value, \"commands\");\n\treturn Array.from(new Set(value));\n}\n\n/** @deprecated agent_mode 已无任何运行时语义(ADR-0071),保留仅为容忍既有 manifest。 */\nexport function normalizePluginAgentModes(value: unknown): string[] | undefined {\n\tif (value === undefined || value === null) return undefined;\n\tconst values = Array.isArray(value) ? value : [value];\n\tconst modes = values.map((item) => String(item).trim()).filter(Boolean);\n\treturn modes.length > 0 ? modes : undefined;\n}\n\nexport function parsePluginMcpServerConfig(name: string, raw: unknown): PluginMcpServerConfig {\n\tassertSchema(PluginMcpServerConfigSchema, raw, `MCP server '${name}'`);\n\treturn normalizePluginMcpServerConfig(raw);\n}\n\nexport function isPluginPassthroughIconRef(icon: string): boolean {\n\treturn (\n\t\ticon.startsWith(\"http://\") ||\n\t\ticon.startsWith(\"https://\") ||\n\t\t/^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/.test(icon)\n\t);\n}\n\nexport function isPluginPackagedIconPath(icon: string): boolean {\n\treturn !isPluginPassthroughIconRef(icon);\n}\n\nexport function parsePluginManifest(raw: unknown): PluginManifest {\n\tif (typeof raw === \"object\" && raw !== null && \"runtime\" in raw) {\n\t\tthrow new Error(\n\t\t\t'Invalid plugin manifest.runtime: runtime selection is unsupported; plugins use Module Federation.',\n\t\t);\n\t}\n\tassertSchema(PluginManifestSchema, raw, \"manifest\");\n\tconst commands = parsePluginCommandNames(raw.commands);\n\tconst icon = raw.icon === undefined ? undefined : trimString(raw.icon);\n\tconst permissions = normalizePermissions(raw.permissions);\n\tconst network = normalizeNetworkManifest(raw.network);\n\tconst browser = normalizeBrowserManifest(raw.browser);\n\tif (permissions.includes(\"network.fetch\") && !network) {\n\t\tthrow new Error(\"Plugin network.allowedHosts is required with network.fetch\");\n\t}\n\tconst browserPermissions = permissions.filter((permission) => permission.startsWith(\"browser.\"));\n\tif (browserPermissions.length > 0 && !browser) {\n\t\tthrow new Error(\"Plugin browser.allowedHosts is required with browser permissions\");\n\t}\n\tif (permissions.includes(\"browser.interact\") && !permissions.includes(\"browser.read\")) {\n\t\tthrow new Error(\"Plugin browser.interact requires browser.read\");\n\t}\n\treturn {\n\t\tid: raw.id,\n\t\tname: trimString(raw.name),\n\t\tversion: raw.version,\n\t\tpluginApiVersion: trimString(raw.pluginApiVersion),\n\t\tentry: validatePluginRelativePath(trimString(raw.entry), \"entry\"),\n\t\tmoduleFederation: normalizeModuleFederation(raw.moduleFederation),\n\t\tagent: normalizeAgentManifest(raw.agent),\n\t\tstyles: normalizeStringArray(raw.styles).map((style) => validatePluginRelativePath(style, \"styles\")),\n\t\tpermissions,\n\t\tnetwork,\n\t\tbrowser,\n\t\tcommands: commands.length > 0 ? commands : undefined,\n\t\tcontributes: raw.contributes\n\t\t\t? (() => {\n\t\t\t\t\tconst settings = normalizeSettings(raw.contributes.settings);\n\t\t\t\t\treturn settings ? { settings } : undefined;\n\t\t\t\t})()\n\t\t\t: undefined,\n\t\tdescription: raw.description,\n\t\tauthor: raw.author,\n\t\ticon:\n\t\t\ticon === undefined || isPluginPassthroughIconRef(icon)\n\t\t\t\t? icon\n\t\t\t\t: validatePluginRelativePath(icon, \"icon\"),\n\t\tguidingWords: raw.guidingWords?.map(trimString),\n\t\tdefaultLocale: raw.defaultLocale ?? \"zh\",\n\t\tcontributionMode: raw.contributionMode\n\t\t\t? { hardIsolation: raw.contributionMode.hardIsolation === true }\n\t\t\t: undefined,\n\t\tagent_mode: normalizePluginAgentModes(raw.agent_mode),\n\t};\n}\n\nexport function listPluginManifestResources(\n\tmanifest: PluginManifest,\n): PluginManifestResourceReference[] {\n\tconst resources: PluginManifestResourceReference[] = [\n\t\t{ field: \"entry\", path: manifest.entry, kind: \"file\" },\n\t];\n\tfor (const stylePath of manifest.styles ?? []) {\n\t\tresources.push({ field: \"styles\", path: stylePath, kind: \"file\" });\n\t}\n\tif (manifest.icon && isPluginPackagedIconPath(manifest.icon)) {\n\t\tresources.push({ field: \"icon\", path: manifest.icon, kind: \"file\" });\n\t}\n\tfor (const promptPath of manifest.agent?.systemPrompt?.promptPaths ?? []) {\n\t\tresources.push({ field: \"agent.systemPrompt.promptPaths\", path: promptPath, kind: \"file-or-directory\" });\n\t}\n\tfor (const skillPath of manifest.agent?.skillPaths ?? []) {\n\t\tresources.push({ field: \"agent.skillPaths\", path: skillPath, kind: \"file-or-directory\" });\n\t}\n\tif (typeof manifest.agent?.mcpServers === \"string\") {\n\t\tresources.push({ field: \"agent.mcpServers\", path: manifest.agent.mcpServers, kind: \"file\" });\n\t}\n\treturn resources;\n}\n\nfunction parseApiVersion(value: string): readonly [number, number, number] | undefined {\n\tconst match = /^(\\d+)\\.(\\d+)\\.(\\d+)$/.exec(value);\n\tif (!match) return undefined;\n\treturn [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\nfunction compareApiVersions(\n\tleft: readonly [number, number, number],\n\tright: readonly [number, number, number],\n): number {\n\tfor (let index = 0; index < left.length; index += 1) {\n\t\tif (left[index] !== right[index]) return left[index] - right[index];\n\t}\n\treturn 0;\n}\n\nexport function isPluginApiCompatible(hostVersion: string, range: string): boolean {\n\tconst host = parseApiVersion(hostVersion);\n\tif (!host) return false;\n\tconst normalized = range.trim();\n\tconst exact = parseApiVersion(normalized);\n\tif (exact) return exact[0] === host[0] && compareApiVersions(host, exact) >= 0;\n\tconst caret = normalized.startsWith(\"^\") ? parseApiVersion(normalized.slice(1)) : undefined;\n\tif (caret) return caret[0] === host[0] && compareApiVersions(host, caret) >= 0;\n\tif (normalized === `^${host[0]}` || normalized === `${host[0]}.x`) return true;\n\tconst minimum = normalized.startsWith(\">=\") ? parseApiVersion(normalized.slice(2)) : undefined;\n\treturn minimum !== undefined && compareApiVersions(host, minimum) >= 0;\n}\n"]}
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { PluginArtifactRef } from "./artifacts.js";
|
|
2
|
+
import type { Disposable } from "./disposable.js";
|
|
3
|
+
import type { PluginJob, PluginJobFailure } from "./jobs.js";
|
|
4
|
+
export type PluginMediaKind = "image" | "video" | "audio" | "document";
|
|
5
|
+
export type PluginMediaOutputKind = "image" | "video" | "audio";
|
|
6
|
+
export type PluginMediaOperation = "generate" | "compose" | "transcode";
|
|
7
|
+
export type PluginMediaGenerationMode = "text-to-image" | "image-to-image" | "text-to-video" | "image-to-video" | "video-to-video" | "reference-to-video";
|
|
8
|
+
export type PluginMediaErrorCode = "unauthenticated" | "provider-unavailable" | "operation-unsupported" | "invalid-request" | "not-entitled" | "quota-exhausted" | "content-rejected" | "provider-timeout" | "provider-failed" | "cancelled";
|
|
9
|
+
export interface PluginMediaFailure extends PluginJobFailure {
|
|
10
|
+
code: PluginMediaErrorCode;
|
|
11
|
+
}
|
|
12
|
+
export declare class PluginMediaError extends Error {
|
|
13
|
+
readonly code: PluginMediaErrorCode;
|
|
14
|
+
readonly retryable: boolean;
|
|
15
|
+
constructor(failure: PluginMediaFailure);
|
|
16
|
+
}
|
|
17
|
+
export interface PluginMediaDimensions {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}
|
|
21
|
+
export type PluginMediaInputSource = {
|
|
22
|
+
type: "plugin-blob";
|
|
23
|
+
blobId: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "workspace-file";
|
|
26
|
+
path: string;
|
|
27
|
+
};
|
|
28
|
+
export interface PluginMediaInput {
|
|
29
|
+
id?: string;
|
|
30
|
+
role?: string;
|
|
31
|
+
kind: PluginMediaKind;
|
|
32
|
+
mimeType?: string;
|
|
33
|
+
source: PluginMediaInputSource;
|
|
34
|
+
}
|
|
35
|
+
export interface PluginMediaOutput {
|
|
36
|
+
kind: PluginMediaOutputKind;
|
|
37
|
+
mimeType: string;
|
|
38
|
+
dimensions?: PluginMediaDimensions;
|
|
39
|
+
fps?: number;
|
|
40
|
+
durationSeconds?: number;
|
|
41
|
+
videoCodec?: string;
|
|
42
|
+
audioCodec?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PluginMediaArtifact extends PluginArtifactRef {
|
|
45
|
+
kind: PluginMediaOutputKind;
|
|
46
|
+
width?: number;
|
|
47
|
+
height?: number;
|
|
48
|
+
durationSeconds?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface PluginMediaGenerateRequest {
|
|
51
|
+
operation: "generate";
|
|
52
|
+
providerId: string;
|
|
53
|
+
kind: "image" | "video";
|
|
54
|
+
mode: PluginMediaGenerationMode;
|
|
55
|
+
prompt: string;
|
|
56
|
+
modelId?: string;
|
|
57
|
+
dimensions?: PluginMediaDimensions;
|
|
58
|
+
aspectRatio?: string;
|
|
59
|
+
resolution?: string;
|
|
60
|
+
durationSeconds?: number;
|
|
61
|
+
inputs?: readonly PluginMediaInput[];
|
|
62
|
+
}
|
|
63
|
+
export interface PluginMediaComposeRequest {
|
|
64
|
+
operation: "compose";
|
|
65
|
+
providerId: string;
|
|
66
|
+
inputs: readonly PluginMediaInput[];
|
|
67
|
+
output: PluginMediaOutput;
|
|
68
|
+
}
|
|
69
|
+
export interface PluginMediaTranscodeRequest {
|
|
70
|
+
operation: "transcode";
|
|
71
|
+
providerId: string;
|
|
72
|
+
inputs: readonly PluginMediaInput[];
|
|
73
|
+
output: PluginMediaOutput;
|
|
74
|
+
}
|
|
75
|
+
export type PluginMediaSubmitRequest = PluginMediaGenerateRequest | PluginMediaComposeRequest | PluginMediaTranscodeRequest;
|
|
76
|
+
export interface PluginMediaGenerationInputSlot {
|
|
77
|
+
role: string;
|
|
78
|
+
kinds: readonly PluginMediaKind[];
|
|
79
|
+
minItems: number;
|
|
80
|
+
maxItems: number;
|
|
81
|
+
}
|
|
82
|
+
export interface PluginMediaGenerationModeCapability {
|
|
83
|
+
mode: PluginMediaGenerationMode;
|
|
84
|
+
inputs: readonly PluginMediaGenerationInputSlot[];
|
|
85
|
+
minTotalItems?: number;
|
|
86
|
+
maxTotalItems?: number;
|
|
87
|
+
aspectRatioPolicy?: "configurable" | "input-derived";
|
|
88
|
+
audioGeneration?: "none" | "always" | "optional";
|
|
89
|
+
}
|
|
90
|
+
export type PluginMediaCapability = {
|
|
91
|
+
operation: "generate";
|
|
92
|
+
kind: "image" | "video";
|
|
93
|
+
modes: readonly PluginMediaGenerationMode[];
|
|
94
|
+
aspectRatios?: readonly string[];
|
|
95
|
+
/** Provider-defined stable option ids; consumers must not infer pixel dimensions from their names. */
|
|
96
|
+
resolutions?: readonly string[];
|
|
97
|
+
/** Preferred option when the consumer has no supported persisted resolution. */
|
|
98
|
+
defaultResolution?: string;
|
|
99
|
+
durationsSeconds?: readonly number[];
|
|
100
|
+
modeCapabilities?: readonly PluginMediaGenerationModeCapability[];
|
|
101
|
+
} | {
|
|
102
|
+
operation: "compose";
|
|
103
|
+
documentMimeTypes: readonly string[];
|
|
104
|
+
outputMimeTypes: readonly string[];
|
|
105
|
+
} | {
|
|
106
|
+
operation: "transcode";
|
|
107
|
+
inputMimeTypes: readonly string[];
|
|
108
|
+
outputMimeTypes: readonly string[];
|
|
109
|
+
};
|
|
110
|
+
export interface PluginMediaProviderDescriptor {
|
|
111
|
+
/** Host-qualified provider id. */
|
|
112
|
+
id: string;
|
|
113
|
+
displayName?: string;
|
|
114
|
+
ownerId: string;
|
|
115
|
+
protocolVersion: number;
|
|
116
|
+
capabilities: readonly PluginMediaCapability[];
|
|
117
|
+
}
|
|
118
|
+
export type PluginMediaJob = Omit<PluginJob<PluginMediaArtifact>, "error"> & {
|
|
119
|
+
error?: PluginMediaFailure;
|
|
120
|
+
};
|
|
121
|
+
/** A media input exposed to its provider without revealing its storage location. */
|
|
122
|
+
export interface PluginMediaProviderInput {
|
|
123
|
+
id: string;
|
|
124
|
+
role?: string;
|
|
125
|
+
kind: PluginMediaKind;
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
}
|
|
128
|
+
type ProviderRequest<Request extends PluginMediaSubmitRequest> = Omit<Request, "providerId" | "inputs"> & {
|
|
129
|
+
readonly inputs: readonly PluginMediaProviderInput[];
|
|
130
|
+
};
|
|
131
|
+
export type PluginMediaProviderSubmitRequest = PluginMediaSubmitRequest extends infer Request ? Request extends PluginMediaSubmitRequest ? ProviderRequest<Request> : never : never;
|
|
132
|
+
export interface PluginMediaInputUploadRequest {
|
|
133
|
+
url: string;
|
|
134
|
+
fieldName: string;
|
|
135
|
+
fileName?: string;
|
|
136
|
+
fields?: Record<string, string>;
|
|
137
|
+
headers?: Record<string, string>;
|
|
138
|
+
timeoutMs?: number;
|
|
139
|
+
}
|
|
140
|
+
export interface PluginMediaTransferResponse<T = unknown> {
|
|
141
|
+
ok: boolean;
|
|
142
|
+
status: number;
|
|
143
|
+
statusText: string;
|
|
144
|
+
headers: Record<string, string>;
|
|
145
|
+
body: T;
|
|
146
|
+
}
|
|
147
|
+
export interface PluginMediaProviderHandlerContext {
|
|
148
|
+
readonly invocationId: string;
|
|
149
|
+
uploadInput<T = unknown>(inputId: string, request: PluginMediaInputUploadRequest): Promise<PluginMediaTransferResponse<T>>;
|
|
150
|
+
}
|
|
151
|
+
export type PluginMediaProviderArtifactSource = {
|
|
152
|
+
type: "remote-url";
|
|
153
|
+
url: string;
|
|
154
|
+
headers?: Record<string, string>;
|
|
155
|
+
} | {
|
|
156
|
+
type: "plugin-blob";
|
|
157
|
+
blobId: string;
|
|
158
|
+
} | {
|
|
159
|
+
type: "workspace-file";
|
|
160
|
+
path: string;
|
|
161
|
+
};
|
|
162
|
+
export interface PluginMediaProviderArtifact {
|
|
163
|
+
kind: PluginMediaOutputKind;
|
|
164
|
+
mimeType?: string;
|
|
165
|
+
name?: string;
|
|
166
|
+
width?: number;
|
|
167
|
+
height?: number;
|
|
168
|
+
durationSeconds?: number;
|
|
169
|
+
source: PluginMediaProviderArtifactSource;
|
|
170
|
+
}
|
|
171
|
+
export interface PluginMediaProviderJob {
|
|
172
|
+
id: string;
|
|
173
|
+
status: PluginMediaJob["status"];
|
|
174
|
+
progress?: number;
|
|
175
|
+
artifacts?: readonly PluginMediaProviderArtifact[];
|
|
176
|
+
error?: PluginMediaFailure;
|
|
177
|
+
}
|
|
178
|
+
export interface PluginMediaProviderRegistration {
|
|
179
|
+
id: string;
|
|
180
|
+
displayName?: string;
|
|
181
|
+
capabilities: readonly PluginMediaCapability[];
|
|
182
|
+
submit(request: PluginMediaProviderSubmitRequest, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;
|
|
183
|
+
getJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;
|
|
184
|
+
cancelJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;
|
|
185
|
+
}
|
|
186
|
+
export interface PluginMediaApi {
|
|
187
|
+
registerProvider(registration: PluginMediaProviderRegistration): Disposable;
|
|
188
|
+
listProviders(): Promise<readonly PluginMediaProviderDescriptor[]>;
|
|
189
|
+
onProvidersChanged(listener: () => void): Disposable;
|
|
190
|
+
submit(request: PluginMediaSubmitRequest): Promise<PluginMediaJob>;
|
|
191
|
+
}
|
|
192
|
+
export {};
|
|
193
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,K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C,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,2BAA2B,EAAE,CAAC;IACnD,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC3B;AAED,MAAM,WAAW,+BAA+B;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC/C,MAAM,CACL,OAAO,EAAE,gCAAgC,EACzC,OAAO,EAAE,iCAAiC,GACxC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACnC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACpG,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iCAAiC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACvG;AAED,MAAM,WAAW,cAAc;IAC9B,gBAAgB,CAAC,YAAY,EAAE,+BAA+B,GAAG,UAAU,CAAC;IAC5E,aAAa,IAAI,OAAO,CAAC,SAAS,6BAA6B,EAAE,CAAC,CAAC;IACnE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,UAAU,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACnE","sourcesContent":["import type { PluginArtifactRef } from \"./artifacts.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginJob, PluginJobFailure } from \"./jobs.js\";\n\nexport type PluginMediaKind = \"image\" | \"video\" | \"audio\" | \"document\";\nexport type PluginMediaOutputKind = \"image\" | \"video\" | \"audio\";\nexport type PluginMediaOperation = \"generate\" | \"compose\" | \"transcode\";\n\nexport type PluginMediaGenerationMode =\n\t| \"text-to-image\"\n\t| \"image-to-image\"\n\t| \"text-to-video\"\n\t| \"image-to-video\"\n\t| \"video-to-video\"\n\t| \"reference-to-video\";\n\nexport type PluginMediaErrorCode =\n\t| \"unauthenticated\"\n\t| \"provider-unavailable\"\n\t| \"operation-unsupported\"\n\t| \"invalid-request\"\n\t| \"not-entitled\"\n\t| \"quota-exhausted\"\n\t| \"content-rejected\"\n\t| \"provider-timeout\"\n\t| \"provider-failed\"\n\t| \"cancelled\";\n\nexport interface PluginMediaFailure extends PluginJobFailure {\n\tcode: PluginMediaErrorCode;\n}\n\nexport class PluginMediaError extends Error {\n\treadonly code: PluginMediaErrorCode;\n\treadonly retryable: boolean;\n\n\tconstructor(failure: PluginMediaFailure) {\n\t\tsuper(failure.message);\n\t\tthis.name = \"PluginMediaError\";\n\t\tthis.code = failure.code;\n\t\tthis.retryable = failure.retryable;\n\t}\n}\n\nexport interface PluginMediaDimensions {\n\twidth: number;\n\theight: number;\n}\n\nexport type PluginMediaInputSource =\n\t| { type: \"plugin-blob\"; blobId: string }\n\t| { type: \"workspace-file\"; path: string };\n\nexport interface PluginMediaInput {\n\tid?: string;\n\trole?: string;\n\tkind: PluginMediaKind;\n\tmimeType?: string;\n\tsource: PluginMediaInputSource;\n}\n\nexport interface PluginMediaOutput {\n\tkind: PluginMediaOutputKind;\n\tmimeType: string;\n\tdimensions?: PluginMediaDimensions;\n\tfps?: number;\n\tdurationSeconds?: number;\n\tvideoCodec?: string;\n\taudioCodec?: string;\n}\n\nexport interface PluginMediaArtifact extends PluginArtifactRef {\n\tkind: PluginMediaOutputKind;\n\twidth?: number;\n\theight?: number;\n\tdurationSeconds?: number;\n}\n\nexport interface PluginMediaGenerateRequest {\n\toperation: \"generate\";\n\tproviderId: string;\n\tkind: \"image\" | \"video\";\n\tmode: PluginMediaGenerationMode;\n\tprompt: string;\n\tmodelId?: string;\n\tdimensions?: PluginMediaDimensions;\n\taspectRatio?: string;\n\tresolution?: string;\n\tdurationSeconds?: number;\n\tinputs?: readonly PluginMediaInput[];\n}\n\nexport interface PluginMediaComposeRequest {\n\toperation: \"compose\";\n\tproviderId: string;\n\tinputs: readonly PluginMediaInput[];\n\toutput: PluginMediaOutput;\n}\n\nexport interface PluginMediaTranscodeRequest {\n\toperation: \"transcode\";\n\tproviderId: string;\n\tinputs: readonly PluginMediaInput[];\n\toutput: PluginMediaOutput;\n}\n\nexport type PluginMediaSubmitRequest =\n\t| PluginMediaGenerateRequest\n\t| PluginMediaComposeRequest\n\t| PluginMediaTranscodeRequest;\n\nexport interface PluginMediaGenerationInputSlot {\n\trole: string;\n\tkinds: readonly PluginMediaKind[];\n\tminItems: number;\n\tmaxItems: number;\n}\n\nexport interface PluginMediaGenerationModeCapability {\n\tmode: PluginMediaGenerationMode;\n\tinputs: readonly PluginMediaGenerationInputSlot[];\n\tminTotalItems?: number;\n\tmaxTotalItems?: number;\n\taspectRatioPolicy?: \"configurable\" | \"input-derived\";\n\taudioGeneration?: \"none\" | \"always\" | \"optional\";\n}\n\nexport type PluginMediaCapability =\n\t| {\n\t\t\toperation: \"generate\";\n\t\t\tkind: \"image\" | \"video\";\n\t\t\tmodes: readonly PluginMediaGenerationMode[];\n\t\t\taspectRatios?: readonly string[];\n\t\t\t/** Provider-defined stable option ids; consumers must not infer pixel dimensions from their names. */\n\t\t\tresolutions?: readonly string[];\n\t\t\t/** Preferred option when the consumer has no supported persisted resolution. */\n\t\t\tdefaultResolution?: string;\n\t\t\tdurationsSeconds?: readonly number[];\n\t\t\tmodeCapabilities?: readonly PluginMediaGenerationModeCapability[];\n\t }\n\t| {\n\t\t\toperation: \"compose\";\n\t\t\tdocumentMimeTypes: readonly string[];\n\t\t\toutputMimeTypes: readonly string[];\n\t }\n\t| {\n\t\t\toperation: \"transcode\";\n\t\t\tinputMimeTypes: readonly string[];\n\t\t\toutputMimeTypes: readonly string[];\n\t };\n\nexport interface PluginMediaProviderDescriptor {\n\t/** Host-qualified provider id. */\n\tid: string;\n\tdisplayName?: string;\n\townerId: string;\n\tprotocolVersion: number;\n\tcapabilities: readonly PluginMediaCapability[];\n}\n\nexport type PluginMediaJob = Omit<PluginJob<PluginMediaArtifact>, \"error\"> & {\n\terror?: PluginMediaFailure;\n};\n\n/** A media input exposed to its provider without revealing its storage location. */\nexport interface PluginMediaProviderInput {\n\tid: string;\n\trole?: string;\n\tkind: PluginMediaKind;\n\tmimeType?: string;\n}\n\ntype ProviderRequest<Request extends PluginMediaSubmitRequest> = Omit<Request, \"providerId\" | \"inputs\"> & {\n\treadonly inputs: readonly PluginMediaProviderInput[];\n};\n\nexport type PluginMediaProviderSubmitRequest =\n\tPluginMediaSubmitRequest extends infer Request\n\t\t? Request extends PluginMediaSubmitRequest\n\t\t\t? ProviderRequest<Request>\n\t\t\t: never\n\t\t: never;\n\nexport interface PluginMediaInputUploadRequest {\n\turl: string;\n\tfieldName: string;\n\tfileName?: string;\n\tfields?: Record<string, string>;\n\theaders?: Record<string, string>;\n\ttimeoutMs?: number;\n}\n\nexport interface PluginMediaTransferResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\nexport interface PluginMediaProviderHandlerContext {\n\treadonly invocationId: string;\n\tuploadInput<T = unknown>(\n\t\tinputId: string,\n\t\trequest: PluginMediaInputUploadRequest,\n\t): Promise<PluginMediaTransferResponse<T>>;\n}\n\nexport type PluginMediaProviderArtifactSource =\n\t| { type: \"remote-url\"; url: string; headers?: Record<string, string> }\n\t| { type: \"plugin-blob\"; blobId: string }\n\t| { type: \"workspace-file\"; path: string };\n\nexport interface PluginMediaProviderArtifact {\n\tkind: PluginMediaOutputKind;\n\tmimeType?: string;\n\tname?: string;\n\twidth?: number;\n\theight?: number;\n\tdurationSeconds?: number;\n\tsource: PluginMediaProviderArtifactSource;\n}\n\nexport interface PluginMediaProviderJob {\n\tid: string;\n\tstatus: PluginMediaJob[\"status\"];\n\tprogress?: number;\n\tartifacts?: readonly PluginMediaProviderArtifact[];\n\terror?: PluginMediaFailure;\n}\n\nexport interface PluginMediaProviderRegistration {\n\tid: string;\n\tdisplayName?: string;\n\tcapabilities: readonly PluginMediaCapability[];\n\tsubmit(\n\t\trequest: PluginMediaProviderSubmitRequest,\n\t\tcontext: PluginMediaProviderHandlerContext,\n\t): Promise<PluginMediaProviderJob>;\n\tgetJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;\n\tcancelJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;\n}\n\nexport interface PluginMediaApi {\n\tregisterProvider(registration: PluginMediaProviderRegistration): Disposable;\n\tlistProviders(): Promise<readonly PluginMediaProviderDescriptor[]>;\n\tonProvidersChanged(listener: () => void): Disposable;\n\tsubmit(request: PluginMediaSubmitRequest): Promise<PluginMediaJob>;\n}\n"]}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class PluginMediaError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
retryable;
|
|
4
|
+
constructor(failure) {
|
|
5
|
+
super(failure.message);
|
|
6
|
+
this.name = "PluginMediaError";
|
|
7
|
+
this.code = failure.code;
|
|
8
|
+
this.retryable = failure.retryable;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAgCA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,IAAI,CAAuB;IAC3B,SAAS,CAAU;IAE5B,YAAY,OAA2B,EAAE;QACxC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAAA,CACnC;CACD","sourcesContent":["import type { PluginArtifactRef } from \"./artifacts.js\";\nimport type { Disposable } from \"./disposable.js\";\nimport type { PluginJob, PluginJobFailure } from \"./jobs.js\";\n\nexport type PluginMediaKind = \"image\" | \"video\" | \"audio\" | \"document\";\nexport type PluginMediaOutputKind = \"image\" | \"video\" | \"audio\";\nexport type PluginMediaOperation = \"generate\" | \"compose\" | \"transcode\";\n\nexport type PluginMediaGenerationMode =\n\t| \"text-to-image\"\n\t| \"image-to-image\"\n\t| \"text-to-video\"\n\t| \"image-to-video\"\n\t| \"video-to-video\"\n\t| \"reference-to-video\";\n\nexport type PluginMediaErrorCode =\n\t| \"unauthenticated\"\n\t| \"provider-unavailable\"\n\t| \"operation-unsupported\"\n\t| \"invalid-request\"\n\t| \"not-entitled\"\n\t| \"quota-exhausted\"\n\t| \"content-rejected\"\n\t| \"provider-timeout\"\n\t| \"provider-failed\"\n\t| \"cancelled\";\n\nexport interface PluginMediaFailure extends PluginJobFailure {\n\tcode: PluginMediaErrorCode;\n}\n\nexport class PluginMediaError extends Error {\n\treadonly code: PluginMediaErrorCode;\n\treadonly retryable: boolean;\n\n\tconstructor(failure: PluginMediaFailure) {\n\t\tsuper(failure.message);\n\t\tthis.name = \"PluginMediaError\";\n\t\tthis.code = failure.code;\n\t\tthis.retryable = failure.retryable;\n\t}\n}\n\nexport interface PluginMediaDimensions {\n\twidth: number;\n\theight: number;\n}\n\nexport type PluginMediaInputSource =\n\t| { type: \"plugin-blob\"; blobId: string }\n\t| { type: \"workspace-file\"; path: string };\n\nexport interface PluginMediaInput {\n\tid?: string;\n\trole?: string;\n\tkind: PluginMediaKind;\n\tmimeType?: string;\n\tsource: PluginMediaInputSource;\n}\n\nexport interface PluginMediaOutput {\n\tkind: PluginMediaOutputKind;\n\tmimeType: string;\n\tdimensions?: PluginMediaDimensions;\n\tfps?: number;\n\tdurationSeconds?: number;\n\tvideoCodec?: string;\n\taudioCodec?: string;\n}\n\nexport interface PluginMediaArtifact extends PluginArtifactRef {\n\tkind: PluginMediaOutputKind;\n\twidth?: number;\n\theight?: number;\n\tdurationSeconds?: number;\n}\n\nexport interface PluginMediaGenerateRequest {\n\toperation: \"generate\";\n\tproviderId: string;\n\tkind: \"image\" | \"video\";\n\tmode: PluginMediaGenerationMode;\n\tprompt: string;\n\tmodelId?: string;\n\tdimensions?: PluginMediaDimensions;\n\taspectRatio?: string;\n\tresolution?: string;\n\tdurationSeconds?: number;\n\tinputs?: readonly PluginMediaInput[];\n}\n\nexport interface PluginMediaComposeRequest {\n\toperation: \"compose\";\n\tproviderId: string;\n\tinputs: readonly PluginMediaInput[];\n\toutput: PluginMediaOutput;\n}\n\nexport interface PluginMediaTranscodeRequest {\n\toperation: \"transcode\";\n\tproviderId: string;\n\tinputs: readonly PluginMediaInput[];\n\toutput: PluginMediaOutput;\n}\n\nexport type PluginMediaSubmitRequest =\n\t| PluginMediaGenerateRequest\n\t| PluginMediaComposeRequest\n\t| PluginMediaTranscodeRequest;\n\nexport interface PluginMediaGenerationInputSlot {\n\trole: string;\n\tkinds: readonly PluginMediaKind[];\n\tminItems: number;\n\tmaxItems: number;\n}\n\nexport interface PluginMediaGenerationModeCapability {\n\tmode: PluginMediaGenerationMode;\n\tinputs: readonly PluginMediaGenerationInputSlot[];\n\tminTotalItems?: number;\n\tmaxTotalItems?: number;\n\taspectRatioPolicy?: \"configurable\" | \"input-derived\";\n\taudioGeneration?: \"none\" | \"always\" | \"optional\";\n}\n\nexport type PluginMediaCapability =\n\t| {\n\t\t\toperation: \"generate\";\n\t\t\tkind: \"image\" | \"video\";\n\t\t\tmodes: readonly PluginMediaGenerationMode[];\n\t\t\taspectRatios?: readonly string[];\n\t\t\t/** Provider-defined stable option ids; consumers must not infer pixel dimensions from their names. */\n\t\t\tresolutions?: readonly string[];\n\t\t\t/** Preferred option when the consumer has no supported persisted resolution. */\n\t\t\tdefaultResolution?: string;\n\t\t\tdurationsSeconds?: readonly number[];\n\t\t\tmodeCapabilities?: readonly PluginMediaGenerationModeCapability[];\n\t }\n\t| {\n\t\t\toperation: \"compose\";\n\t\t\tdocumentMimeTypes: readonly string[];\n\t\t\toutputMimeTypes: readonly string[];\n\t }\n\t| {\n\t\t\toperation: \"transcode\";\n\t\t\tinputMimeTypes: readonly string[];\n\t\t\toutputMimeTypes: readonly string[];\n\t };\n\nexport interface PluginMediaProviderDescriptor {\n\t/** Host-qualified provider id. */\n\tid: string;\n\tdisplayName?: string;\n\townerId: string;\n\tprotocolVersion: number;\n\tcapabilities: readonly PluginMediaCapability[];\n}\n\nexport type PluginMediaJob = Omit<PluginJob<PluginMediaArtifact>, \"error\"> & {\n\terror?: PluginMediaFailure;\n};\n\n/** A media input exposed to its provider without revealing its storage location. */\nexport interface PluginMediaProviderInput {\n\tid: string;\n\trole?: string;\n\tkind: PluginMediaKind;\n\tmimeType?: string;\n}\n\ntype ProviderRequest<Request extends PluginMediaSubmitRequest> = Omit<Request, \"providerId\" | \"inputs\"> & {\n\treadonly inputs: readonly PluginMediaProviderInput[];\n};\n\nexport type PluginMediaProviderSubmitRequest =\n\tPluginMediaSubmitRequest extends infer Request\n\t\t? Request extends PluginMediaSubmitRequest\n\t\t\t? ProviderRequest<Request>\n\t\t\t: never\n\t\t: never;\n\nexport interface PluginMediaInputUploadRequest {\n\turl: string;\n\tfieldName: string;\n\tfileName?: string;\n\tfields?: Record<string, string>;\n\theaders?: Record<string, string>;\n\ttimeoutMs?: number;\n}\n\nexport interface PluginMediaTransferResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\nexport interface PluginMediaProviderHandlerContext {\n\treadonly invocationId: string;\n\tuploadInput<T = unknown>(\n\t\tinputId: string,\n\t\trequest: PluginMediaInputUploadRequest,\n\t): Promise<PluginMediaTransferResponse<T>>;\n}\n\nexport type PluginMediaProviderArtifactSource =\n\t| { type: \"remote-url\"; url: string; headers?: Record<string, string> }\n\t| { type: \"plugin-blob\"; blobId: string }\n\t| { type: \"workspace-file\"; path: string };\n\nexport interface PluginMediaProviderArtifact {\n\tkind: PluginMediaOutputKind;\n\tmimeType?: string;\n\tname?: string;\n\twidth?: number;\n\theight?: number;\n\tdurationSeconds?: number;\n\tsource: PluginMediaProviderArtifactSource;\n}\n\nexport interface PluginMediaProviderJob {\n\tid: string;\n\tstatus: PluginMediaJob[\"status\"];\n\tprogress?: number;\n\tartifacts?: readonly PluginMediaProviderArtifact[];\n\terror?: PluginMediaFailure;\n}\n\nexport interface PluginMediaProviderRegistration {\n\tid: string;\n\tdisplayName?: string;\n\tcapabilities: readonly PluginMediaCapability[];\n\tsubmit(\n\t\trequest: PluginMediaProviderSubmitRequest,\n\t\tcontext: PluginMediaProviderHandlerContext,\n\t): Promise<PluginMediaProviderJob>;\n\tgetJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;\n\tcancelJob?(jobId: string, context: PluginMediaProviderHandlerContext): Promise<PluginMediaProviderJob>;\n}\n\nexport interface PluginMediaApi {\n\tregisterProvider(registration: PluginMediaProviderRegistration): Disposable;\n\tlistProviders(): Promise<readonly PluginMediaProviderDescriptor[]>;\n\tonProvidersChanged(listener: () => void): Disposable;\n\tsubmit(request: PluginMediaSubmitRequest): Promise<PluginMediaJob>;\n}\n"]}
|
package/dist/network.d.ts
CHANGED
|
@@ -30,7 +30,8 @@ export interface PluginNetworkResponse<T = unknown> {
|
|
|
30
30
|
* Host-mediated network access for trusted plugins.
|
|
31
31
|
*
|
|
32
32
|
* Requests run in the main process so plugins do not depend on renderer CORS
|
|
33
|
-
* behavior. Access requires the `network.fetch` permission
|
|
33
|
+
* behavior. Access requires the `network.fetch` permission and a matching
|
|
34
|
+
* `plugin.json` `network.allowedHosts` declaration.
|
|
34
35
|
*/
|
|
35
36
|
export interface PluginNetworkApi {
|
|
36
37
|
request<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;
|
package/dist/network.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mapp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AAC,CAAC;IAChC,KAAK,CAAC,EAAE,KAAK,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;CACF,CAAC;AAEL,MAAM,WAAW,oBAAoB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,OAAO;IACjD,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;CACR;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;CACvF","sourcesContent":["export type PluginNetworkBody =\n\t| {\n\t\t\ttype: \"json\";\n\t\t\tvalue: unknown;\n\t }\n\t| {\n\t\t\ttype: \"multipart\";\n\t\t\tfields?: Record<string, string>;\n\t\t\tfiles?: Array<{\n\t\t\t\tfieldName: string;\n\t\t\t\tfileName: string;\n\t\t\t\tmimeType: string;\n\t\t\t\tdata: string;\n\t\t\t}>;\n\t };\n\nexport interface PluginNetworkRequest {\n\turl: string;\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\theaders?: Record<string, string>;\n\tbody?: PluginNetworkBody;\n\tresponseType?: \"json\" | \"text\" | \"base64\";\n\ttimeoutMs?: number;\n}\n\nexport interface PluginNetworkResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\n/**\n * Host-mediated network access for trusted plugins.\n *\n * Requests run in the main process so plugins do not depend on renderer CORS\n * behavior. Access requires the `network.fetch` permission and a matching\n * `plugin.json` `network.allowedHosts` declaration.\n */\nexport interface PluginNetworkApi {\n\trequest<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;\n}\n"]}
|
package/dist/network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"","sourcesContent":["export type PluginNetworkBody =\n\t| {\n\t\t\ttype: \"json\";\n\t\t\tvalue: unknown;\n\t }\n\t| {\n\t\t\ttype: \"multipart\";\n\t\t\tfields?: Record<string, string>;\n\t\t\tfiles?: Array<{\n\t\t\t\tfieldName: string;\n\t\t\t\tfileName: string;\n\t\t\t\tmimeType: string;\n\t\t\t\tdata: string;\n\t\t\t}>;\n\t };\n\nexport interface PluginNetworkRequest {\n\turl: string;\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\theaders?: Record<string, string>;\n\tbody?: PluginNetworkBody;\n\tresponseType?: \"json\" | \"text\" | \"base64\";\n\ttimeoutMs?: number;\n}\n\nexport interface PluginNetworkResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\n/**\n * Host-mediated network access for trusted plugins.\n *\n * Requests run in the main process so plugins do not depend on renderer CORS\n * behavior. Access requires the `network.fetch` permission.\n */\nexport interface PluginNetworkApi {\n\trequest<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"","sourcesContent":["export type PluginNetworkBody =\n\t| {\n\t\t\ttype: \"json\";\n\t\t\tvalue: unknown;\n\t }\n\t| {\n\t\t\ttype: \"multipart\";\n\t\t\tfields?: Record<string, string>;\n\t\t\tfiles?: Array<{\n\t\t\t\tfieldName: string;\n\t\t\t\tfileName: string;\n\t\t\t\tmimeType: string;\n\t\t\t\tdata: string;\n\t\t\t}>;\n\t };\n\nexport interface PluginNetworkRequest {\n\turl: string;\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\theaders?: Record<string, string>;\n\tbody?: PluginNetworkBody;\n\tresponseType?: \"json\" | \"text\" | \"base64\";\n\ttimeoutMs?: number;\n}\n\nexport interface PluginNetworkResponse<T = unknown> {\n\tok: boolean;\n\tstatus: number;\n\tstatusText: string;\n\theaders: Record<string, string>;\n\tbody: T;\n}\n\n/**\n * Host-mediated network access for trusted plugins.\n *\n * Requests run in the main process so plugins do not depend on renderer CORS\n * behavior. Access requires the `network.fetch` permission and a matching\n * `plugin.json` `network.allowedHosts` declaration.\n */\nexport interface PluginNetworkApi {\n\trequest<T = unknown>(request: PluginNetworkRequest): Promise<PluginNetworkResponse<T>>;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Static } from "@sinclair/typebox";
|
|
2
|
+
export declare const VETTA_NPM_PACKAGE_SCHEMA_VERSION: 1;
|
|
3
|
+
export declare const VettaNpmPluginMetadataSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
schemaVersion: import("@sinclair/typebox").TLiteral<1>;
|
|
5
|
+
type: import("@sinclair/typebox").TLiteral<"desktop-plugin">;
|
|
6
|
+
pluginId: import("@sinclair/typebox").TString;
|
|
7
|
+
archive: import("@sinclair/typebox").TString;
|
|
8
|
+
}>;
|
|
9
|
+
export type VettaNpmPluginMetadata = Static<typeof VettaNpmPluginMetadataSchema>;
|
|
10
|
+
export interface VettaNpmPluginPackage {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
vetta: VettaNpmPluginMetadata;
|
|
14
|
+
}
|
|
15
|
+
/** Parse the npm distribution envelope without trusting package-owned metadata. */
|
|
16
|
+
export declare function parseVettaNpmPluginPackage(value: unknown): VettaNpmPluginPackage;
|
|
17
|
+
//# sourceMappingURL=npm-package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-package.d.ts","sourceRoot":"","sources":["../src/npm-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAKtD,eAAO,MAAM,gCAAgC,GAAa,CAAC;AAE3D,eAAO,MAAM,4BAA4B;;;;;EAQxC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEjF,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,sBAAsB,CAAC;CAC9B;AAMD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAqBhF","sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { PluginIdSchema, PluginVersionSchema } from \"./manifest-schema.js\";\nimport { validatePluginRelativePath } from \"./manifest.js\";\n\nexport const VETTA_NPM_PACKAGE_SCHEMA_VERSION = 1 as const;\n\nexport const VettaNpmPluginMetadataSchema = Type.Object(\n\t{\n\t\tschemaVersion: Type.Literal(VETTA_NPM_PACKAGE_SCHEMA_VERSION),\n\t\ttype: Type.Literal(\"desktop-plugin\"),\n\t\tpluginId: PluginIdSchema,\n\t\tarchive: Type.String({ minLength: 1 }),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type VettaNpmPluginMetadata = Static<typeof VettaNpmPluginMetadataSchema>;\n\nexport interface VettaNpmPluginPackage {\n\tname: string;\n\tversion: string;\n\tvetta: VettaNpmPluginMetadata;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Parse the npm distribution envelope without trusting package-owned metadata. */\nexport function parseVettaNpmPluginPackage(value: unknown): VettaNpmPluginPackage {\n\tif (!isRecord(value)) throw new Error(\"Invalid npm plugin package: package.json must contain an object\");\n\tif (typeof value.name !== \"string\" || value.name.trim().length === 0) {\n\t\tthrow new Error(\"Invalid npm plugin package: name is required\");\n\t}\n\tif (!Value.Check(PluginVersionSchema, value.version)) {\n\t\tthrow new Error(\"Invalid npm plugin package: version must be a semantic version\");\n\t}\n\tif (!Value.Check(VettaNpmPluginMetadataSchema, value.vetta)) {\n\t\tthrow new Error(\"Invalid npm plugin package: package.json#vetta does not match schema version 1\");\n\t}\n\n\tconst metadata = value.vetta as VettaNpmPluginMetadata;\n\treturn {\n\t\tname: value.name.trim(),\n\t\tversion: value.version,\n\t\tvetta: {\n\t\t\t...metadata,\n\t\t\tarchive: validatePluginRelativePath(metadata.archive.trim(), \"npm archive\"),\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Type } from "@sinclair/typebox";
|
|
2
|
+
import { Value } from "@sinclair/typebox/value";
|
|
3
|
+
import { PluginIdSchema, PluginVersionSchema } from "./manifest-schema.js";
|
|
4
|
+
import { validatePluginRelativePath } from "./manifest.js";
|
|
5
|
+
export const VETTA_NPM_PACKAGE_SCHEMA_VERSION = 1;
|
|
6
|
+
export const VettaNpmPluginMetadataSchema = Type.Object({
|
|
7
|
+
schemaVersion: Type.Literal(VETTA_NPM_PACKAGE_SCHEMA_VERSION),
|
|
8
|
+
type: Type.Literal("desktop-plugin"),
|
|
9
|
+
pluginId: PluginIdSchema,
|
|
10
|
+
archive: Type.String({ minLength: 1 }),
|
|
11
|
+
}, { additionalProperties: false });
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
/** Parse the npm distribution envelope without trusting package-owned metadata. */
|
|
16
|
+
export function parseVettaNpmPluginPackage(value) {
|
|
17
|
+
if (!isRecord(value))
|
|
18
|
+
throw new Error("Invalid npm plugin package: package.json must contain an object");
|
|
19
|
+
if (typeof value.name !== "string" || value.name.trim().length === 0) {
|
|
20
|
+
throw new Error("Invalid npm plugin package: name is required");
|
|
21
|
+
}
|
|
22
|
+
if (!Value.Check(PluginVersionSchema, value.version)) {
|
|
23
|
+
throw new Error("Invalid npm plugin package: version must be a semantic version");
|
|
24
|
+
}
|
|
25
|
+
if (!Value.Check(VettaNpmPluginMetadataSchema, value.vetta)) {
|
|
26
|
+
throw new Error("Invalid npm plugin package: package.json#vetta does not match schema version 1");
|
|
27
|
+
}
|
|
28
|
+
const metadata = value.vetta;
|
|
29
|
+
return {
|
|
30
|
+
name: value.name.trim(),
|
|
31
|
+
version: value.version,
|
|
32
|
+
vetta: {
|
|
33
|
+
...metadata,
|
|
34
|
+
archive: validatePluginRelativePath(metadata.archive.trim(), "npm archive"),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=npm-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-package.js","sourceRoot":"","sources":["../src/npm-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAe,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE3D,MAAM,CAAC,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CAAC;IACvD,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;QACvB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE;YACN,GAAG,QAAQ;YACX,OAAO,EAAE,0BAA0B,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,aAAa,CAAC;SAC3E;KACD,CAAC;AAAA,CACF","sourcesContent":["import { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport { PluginIdSchema, PluginVersionSchema } from \"./manifest-schema.js\";\nimport { validatePluginRelativePath } from \"./manifest.js\";\n\nexport const VETTA_NPM_PACKAGE_SCHEMA_VERSION = 1 as const;\n\nexport const VettaNpmPluginMetadataSchema = Type.Object(\n\t{\n\t\tschemaVersion: Type.Literal(VETTA_NPM_PACKAGE_SCHEMA_VERSION),\n\t\ttype: Type.Literal(\"desktop-plugin\"),\n\t\tpluginId: PluginIdSchema,\n\t\tarchive: Type.String({ minLength: 1 }),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type VettaNpmPluginMetadata = Static<typeof VettaNpmPluginMetadataSchema>;\n\nexport interface VettaNpmPluginPackage {\n\tname: string;\n\tversion: string;\n\tvetta: VettaNpmPluginMetadata;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** Parse the npm distribution envelope without trusting package-owned metadata. */\nexport function parseVettaNpmPluginPackage(value: unknown): VettaNpmPluginPackage {\n\tif (!isRecord(value)) throw new Error(\"Invalid npm plugin package: package.json must contain an object\");\n\tif (typeof value.name !== \"string\" || value.name.trim().length === 0) {\n\t\tthrow new Error(\"Invalid npm plugin package: name is required\");\n\t}\n\tif (!Value.Check(PluginVersionSchema, value.version)) {\n\t\tthrow new Error(\"Invalid npm plugin package: version must be a semantic version\");\n\t}\n\tif (!Value.Check(VettaNpmPluginMetadataSchema, value.vetta)) {\n\t\tthrow new Error(\"Invalid npm plugin package: package.json#vetta does not match schema version 1\");\n\t}\n\n\tconst metadata = value.vetta as VettaNpmPluginMetadata;\n\treturn {\n\t\tname: value.name.trim(),\n\t\tversion: value.version,\n\t\tvetta: {\n\t\t\t...metadata,\n\t\t\tarchive: validatePluginRelativePath(metadata.archive.trim(), \"npm archive\"),\n\t\t},\n\t};\n}\n"]}
|