7.2 KiB
AI Adapters And Profile Presets
Plugins can declare contributes.agentAdapters and contributes.aiProfiles in
manifest version 1. Both arrays are optional. An adapter supplies a packaged
process implementing the IdeA agent-session protocol; a preset supplies initial
configuration from which the host creates a durable profile instance.
The SDK exports IdeAPluginAgentAdapterContribution,
IdeAPluginAgentAdapterConfigSchema, IdeAPluginAgentAdapterConfigField and
IdeAPluginAiProfileContribution from @idea/plugin-sdk.
Manifest Example
{
"ideaPluginManifestVersion": 1,
"id": "com.example.ai",
"displayName": "Example AI",
"version": "1.0.0",
"main": "dist/index.js",
"trustLevel": "full",
"contributes": {
"agentAdapters": [{
"id": "example.session",
"displayName": "Example Session",
"protocol": "idea-agent-session",
"protocolVersion": 1,
"command": "bin/example-session",
"args": ["--stdio"],
"env": { "EXAMPLE_LOG_LEVEL": "warn" },
"configSchema": {
"type": "object",
"additionalProperties": false,
"properties": {
"endpoint": {
"type": "string",
"title": "Endpoint",
"format": "uri",
"default": "https://api.example.com/v1"
},
"model": { "type": "string", "title": "Model" },
"apiKey": { "type": "string", "title": "API key", "format": "secret" },
"maxRetries": { "type": "integer", "default": 2, "enum": [0, 1, 2] },
"stream": { "type": "boolean", "default": true }
},
"required": ["endpoint", "apiKey"]
}
}],
"aiProfiles": [{
"id": "example.assistant",
"adapterId": "example.session",
"displayName": "Example Assistant",
"profileType": "generalAssistant",
"providerLabel": "Example",
"modelField": "model",
"description": "Assistant using the Example session bridge.",
"configDefaults": { "model": "example-model", "maxRetries": 1 }
}]
}
}
Contribution Rules
Adapter and preset ids are unique in the plugin contribution namespace. Each
adapterId references an adapter in the same manifest. displayName and
providerLabel are nonempty. profileType is codingAgent, generalAssistant
or custom.
Adapters require protocol: "idea-agent-session", protocolVersion: 1 and a
package-relative command. Absolute paths and parent traversal are rejected.
The host starts the executable directly, without a shell; args are literal
tokens and env contains static non-secret string values. Package the executable
and its runtime dependencies; do not rely on a shell command line or host PATH
lookup. The adapter command has no allowAbsoluteCommand escape hatch.
modelField is optional. When supplied it names a declared non-secret string
property, allowing the host to display the configured model. A preset without a
model selector omits modelField; its catalogue model is nullable. description
is optional and configDefaults is a required object, which can be empty.
Configuration Schema
This is a closed scalar subset of JSON Schema, not arbitrary JSON Schema:
- Root keys:
type: "object",properties,additionalProperties: false, and optionalrequired, containing unique declared property names. - Field keys:
type, optionaltitle,description,default,enum,format. - Field types:
string,number,integer,boolean. Numbers must be finite; integers must have no fractional part. - Formats:
uri(absolute URI) andsecret, both restricted to string fields. - Enums are nonempty arrays of distinct values matching the field type/format.
- Defaults must match the field type, format and enum. Secret fields cannot have
a default, including an explicit
null. - Preset
configDefaultsonly includes declared, non-secret fields whose values match the schema. It may omit required fields, which are configured later.
Unknown schema keywords, nested objects/arrays, references, composition and
unsupported type/format combinations are rejected. Secret values must never
appear in configDefaults, environment entries, command arguments or logs.
validatePluginManifest, isPluginManifest and assertPluginManifest validate
these contributions as well as the existing manifest fields. Host validation
remains authoritative for installation and runtime configuration.
Session Protocol v1
The host owns profile/session lifecycle. The process exchanges UTF-8 JSON Lines
over stdin/stdout; stdout is protocol-only and stderr is drained as bounded
diagnostics. Request/response frames carry v: 1, type, id and
method/params or result/error. Event frames carry v: 1, type: "event",
name, and data with sessionId/turnId correlation.
initializereceivesadapterRef: {pluginId, adapterId, pluginVersion}andprofileRef: {profileId, presetId?}. All five v1 capabilities are mandatory:streaming,resume,cancel,hostTools,probe.probe({config, secrets})checks readiness without creating or persisting a session.open({sessionId, sessionPlan, config, secrets, context})handles none/assign/resume and returns an opaque engine conversation id.send({sessionId, turnId, prompt})acknowledges with{accepted: true}and streams correlated events:progress,textDelta,toolActivity,announcement,heartbeat,availability,rateLimited,final,error. Successful generation has one terminalfinal; failed generation has a terminalerror. Accepted cancellation terminates without a final response.cancelreturns{outcome: "cancelled" | "alreadyCancelled" | "alreadyCompleted"};closeis idempotent. Errors use{code, message, retryable}.- The process invokes
host/tool.call. The host supplies the effective tool catalogue and checks current project/requester permissions on every call. Plugin-supplied identity never authorizes a tool call.
Limits are 8 MiB per frame and 1 MiB per prompt/config/tool argument or result. Deadlines: initialize 10 s; probe/open 30 s; send at most 4 h; cancel/close 5 s. Tool calls use the host deadline. Shutdown escalates to process-group kill after 2 s. The host cleans the process environment and caps stderr diagnostics at 64 KiB. Malformed protocol or premature closure fails the session closed.
Profile Ownership And Secrets
Persisted profiles keep plugin provenance
{pluginId, adapterId, presetId?, sourcePluginVersion, config, secretRefs};
they never store adapter commands or installed package paths. Runtime resolution
uses the currently installed manifest. The provider/resume key is
plugin:<pluginId>:<adapterId>.
The host secret store owns secret values. Configuration UI sees only
{field, configured, masked: true}; updates use keep/set/clear operations.
Values reach the adapter only in probe/open, never in profile JSON or logs.
Profile instances and assignments survive plugin removal or incompatibility.
The unified host catalogue exposes profile/preset origin, provider, nullable model
and availability: missing, incompatible, needsConfiguration or ready.
ready means configuration is complete, not that a remote connection was tested.
Selectors retain unavailable instances and display the host-provided reason.