import assert from "node:assert/strict"; import { validatePluginManifest } from "../dist/index.js"; const base = { ideaPluginManifestVersion: 1, id: "dev.example.agent", displayName: "Agent", version: "1.0.0", main: "dist/index.js", trustLevel: "full", contributes: { agentAdapters: [{ id: "session", displayName: "Session", protocol: "idea-agent-session", protocolVersion: 1, command: "bin/agent", configSchema: { type: "object", properties: {}, additionalProperties: false } }], aiProfiles: [{ id: "default", adapterId: "session", displayName: "Default", profileType: "codingAgent", providerLabel: "Example", configDefaults: {} }] } }; assert.equal( validatePluginManifest(base).success, true, "valid agent adapter and AI profile contributions are accepted" ); const unknownAdapter = structuredClone(base); unknownAdapter.contributes.aiProfiles[0].adapterId = "missing"; assert.equal( validatePluginManifest(unknownAdapter).success, false, "AI profiles cannot reference an unknown adapter" ); const unsupportedProtocol = structuredClone(base); unsupportedProtocol.contributes.agentAdapters[0].protocolVersion = 2; assert.equal( validatePluginManifest(unsupportedProtocol).success, false, "only agent session protocol version 1 is supported" ); const protectedEnv = structuredClone(base); protectedEnv.contributes.agentAdapters[0].env = { PATH: "/tmp/plugin-bin", API_TOKEN: "literal" }; const acceptance = []; acceptance.push(["runtime-rejected env names", validatePluginManifest(protectedEnv).success]); const excessiveArgs = structuredClone(base); excessiveArgs.contributes.agentAdapters[0].args = Array.from({ length: 257 }, () => "x"); acceptance.push(["257 adapter args", validatePluginManifest(excessiveArgs).success]); const excessiveArgBytes = structuredClone(base); excessiveArgBytes.contributes.agentAdapters[0].args = ["x".repeat(64 * 1024 + 1)]; acceptance.push(["adapter args over 64 KiB", validatePluginManifest(excessiveArgBytes).success]); const excessiveEnvEntries = structuredClone(base); excessiveEnvEntries.contributes.agentAdapters[0].env = Object.fromEntries( Array.from({ length: 129 }, (_, index) => [`PLUGIN_VALUE_${index}`, "x"]), ); acceptance.push(["129 adapter env entries", validatePluginManifest(excessiveEnvEntries).success]); const excessiveEnvBytes = structuredClone(base); excessiveEnvBytes.contributes.agentAdapters[0].env = { PLUGIN_VALUE: "x".repeat(64 * 1024 + 1) }; acceptance.push(["adapter env over 64 KiB", validatePluginManifest(excessiveEnvBytes).success]); assert.deepEqual( acceptance, acceptance.map(([label]) => [label, false]), "SDK must reject runtime-incompatible env and oversized adapter args/env" );