@adea-ai/plugins 3.0.10 → 4.0.1
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/README.md +18 -11
- package/dist/agent-plugins-catalog.d.ts +2 -3
- package/dist/agent-plugins-catalog.js +2 -10
- package/dist/agent-plugins-catalog.js.map +1 -1
- package/dist/catalog-store.d.ts +81 -0
- package/dist/catalog-store.js +487 -0
- package/dist/catalog-store.js.map +1 -0
- package/dist/consumer-index.d.ts +1 -1
- package/dist/consumer-index.js +17 -7
- package/dist/consumer-index.js.map +1 -1
- package/dist/display-name.js +3 -2
- package/dist/display-name.js.map +1 -1
- package/dist/harness.d.ts +50 -9
- package/dist/harness.js +190 -147
- package/dist/harness.js.map +1 -1
- package/dist/icon-mirror.d.ts +2 -2
- package/dist/icon-mirror.js +38 -25
- package/dist/icon-mirror.js.map +1 -1
- package/dist/icons.js +5 -27
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.js +103 -88
- package/dist/index.js.map +1 -1
- package/dist/publication.d.ts +8 -11
- package/dist/publication.js +8 -11
- package/dist/publication.js.map +1 -1
- package/dist/schema.d.ts +0 -40
- package/dist/schema.js +0 -36
- package/dist/schema.js.map +1 -1
- package/dist/site-icons.d.ts +2 -0
- package/dist/site-icons.js +46 -9
- package/dist/site-icons.js.map +1 -1
- package/dist/source-digest.d.ts +2 -0
- package/dist/source-digest.js +12 -0
- package/dist/source-digest.js.map +1 -0
- package/dist/sources.js +3 -3
- package/dist/sources.js.map +1 -1
- package/native/build-provenance.txt +5 -5
- package/native/staged-reader-win32-arm64.node +0 -0
- package/native/staged-reader-win32-x64.node +0 -0
- package/package.json +4 -9
- package/src/agent-plugins-catalog.ts +3 -10
- package/src/artifacts.test.ts +80 -0
- package/src/catalog-installation.test.ts +1 -1
- package/src/catalog-store.ts +546 -0
- package/src/consumer-index.test.ts +125 -0
- package/src/consumer-index.ts +23 -8
- package/src/default-head.test.ts +143 -0
- package/src/display-name.test.ts +8 -0
- package/src/display-name.ts +3 -2
- package/src/{agent-plugins-harness.test.ts → harness.test.ts} +1 -1
- package/src/harness.ts +249 -170
- package/src/icon-mirror.ts +36 -23
- package/src/icons.test.ts +5 -0
- package/src/icons.ts +6 -29
- package/src/index.test.ts +272 -40
- package/src/index.ts +131 -94
- package/src/manifest-retry.test.ts +49 -0
- package/src/portable-catalog.test.ts +8 -5
- package/src/publication.ts +8 -11
- package/src/schema.ts +0 -40
- package/src/site-icon-fallback.test.ts +36 -19
- package/src/site-icons.test.ts +104 -0
- package/src/site-icons.ts +47 -9
- package/src/source-config-sync.test.ts +84 -0
- package/src/source-digest.test.ts +101 -0
- package/src/source-digest.ts +14 -0
- package/src/sources-json.test.ts +53 -0
- package/src/sources.ts +3 -3
- package/src/upstream-headers.test.ts +31 -7
- package/src/write-artifacts.test.ts +375 -0
- package/dist/agent-plugins-harness.d.ts +0 -54
- package/dist/agent-plugins-harness.js +0 -212
- package/dist/agent-plugins-harness.js.map +0 -1
- package/src/agent-plugins-harness.ts +0 -281
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, resolve, relative, sep } from 'node:path'
|
|
2
|
-
import { realpath } from 'node:fs/promises'
|
|
3
|
-
import { createHash } from 'node:crypto'
|
|
4
|
-
import {
|
|
5
|
-
HarnessProfileSchema,
|
|
6
|
-
InstallationPlanSchema,
|
|
7
|
-
type HarnessProfile,
|
|
8
|
-
type McpServer,
|
|
9
|
-
type InstallationPlan,
|
|
10
|
-
} from './agent-plugins-schema.js'
|
|
11
|
-
import type { Catalog } from './schema.js'
|
|
12
|
-
import { verifyPortableCatalog, PACKAGE_METADATA_KEY } from './portable-catalog.js'
|
|
13
|
-
import { verifyAgentPackage, validateServer } from './agent-plugins-catalog.js'
|
|
14
|
-
|
|
15
|
-
export interface InstallationInput {
|
|
16
|
-
readonly pluginId: string
|
|
17
|
-
readonly releaseId: string
|
|
18
|
-
readonly instanceId: string
|
|
19
|
-
readonly source: InstallationPlan['source']
|
|
20
|
-
readonly package: unknown
|
|
21
|
-
readonly profile: HarnessProfile
|
|
22
|
-
readonly requiredCredentials?: readonly string[]
|
|
23
|
-
readonly requiredConnectors?: readonly string[]
|
|
24
|
-
readonly allowPartial?: boolean
|
|
25
|
-
}
|
|
26
|
-
export interface CatalogInstallationInput {
|
|
27
|
-
readonly catalog: Catalog
|
|
28
|
-
readonly pluginId: string
|
|
29
|
-
readonly releaseId?: string
|
|
30
|
-
readonly instanceId: string
|
|
31
|
-
readonly profile: HarnessProfile
|
|
32
|
-
readonly allowPartial?: boolean
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Resolve the exact catalog release before planning. The caller must also authenticate
|
|
36
|
-
* the catalog publisher and verify its artifact integrity before invoking this API.
|
|
37
|
-
*/
|
|
38
|
-
export function createCatalogInstallationPlan(input: CatalogInstallationInput): InstallationPlan {
|
|
39
|
-
verifyPortableCatalog(input.catalog)
|
|
40
|
-
const plugin = input.catalog.plugins.find((entry) => entry.pluginId === input.pluginId)
|
|
41
|
-
if (!plugin) throw new Error(`PLUGIN_NOT_FOUND: ${input.pluginId}`)
|
|
42
|
-
const release = plugin.availableReleases.find(
|
|
43
|
-
(entry) => entry.releaseId === (input.releaseId ?? plugin.currentReleaseId)
|
|
44
|
-
)
|
|
45
|
-
if (!release) throw new Error('RELEASE_NOT_FOUND')
|
|
46
|
-
if (release.contentResolution !== 'complete') throw new Error('COMPLETE_SOURCE_REQUIRED')
|
|
47
|
-
const pkg = release.releaseMetadata[PACKAGE_METADATA_KEY]
|
|
48
|
-
if (pkg === undefined)
|
|
49
|
-
throw new Error(
|
|
50
|
-
'PORTABLE_RESYNC_REQUIRED: run a full catalog sync before planning portable installation'
|
|
51
|
-
)
|
|
52
|
-
return createInstallationPlan({
|
|
53
|
-
pluginId: plugin.pluginId,
|
|
54
|
-
releaseId: release.releaseId,
|
|
55
|
-
instanceId: input.instanceId,
|
|
56
|
-
profile: input.profile,
|
|
57
|
-
package: pkg,
|
|
58
|
-
allowPartial: input.allowPartial === true,
|
|
59
|
-
source: {
|
|
60
|
-
repositoryUrl: release.resolvedRepositoryUrl,
|
|
61
|
-
commitSha: release.resolvedCommitSha,
|
|
62
|
-
pluginSubdirectory: release.pluginSubdirectory,
|
|
63
|
-
contentDigest: release.canonicalContentDigest,
|
|
64
|
-
},
|
|
65
|
-
requiredCredentials: release.requiredCredentials,
|
|
66
|
-
requiredConnectors: release.requiredConnectors,
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function identity(...parts: string[]): string {
|
|
71
|
-
return createHash('sha256').update(JSON.stringify(parts)).digest('hex')
|
|
72
|
-
}
|
|
73
|
-
/** A declarative proposal, never an execution grant. No brand-based support assumptions. */
|
|
74
|
-
export function createInstallationPlan(input: InstallationInput): InstallationPlan {
|
|
75
|
-
const profile = HarnessProfileSchema.parse(input.profile)
|
|
76
|
-
const pkg = verifyAgentPackage(input.package)
|
|
77
|
-
if (pkg.sourceDigest !== input.source.contentDigest)
|
|
78
|
-
throw new Error('Package recipe does not match the selected immutable release.')
|
|
79
|
-
if (!input.instanceId || input.instanceId.length > 256)
|
|
80
|
-
throw new Error('A stable installation instanceId is required.')
|
|
81
|
-
const disabled: InstallationPlan['disabled'] = []
|
|
82
|
-
for (const item of pkg.nonPortable) disabled.push({ component: item.kind, reason: item.reason })
|
|
83
|
-
for (const item of pkg.diagnostics.filter((entry) => entry.severity === 'error'))
|
|
84
|
-
disabled.push({ component: item.path, reason: item.message })
|
|
85
|
-
|
|
86
|
-
const nativeEligible =
|
|
87
|
-
profile.agentPlugins.versions.includes(pkg.specVersion) &&
|
|
88
|
-
pkg.nonPortable.length === 0 &&
|
|
89
|
-
!Object.keys(pkg.manifest?.extensions ?? {}).length
|
|
90
|
-
const nativeCoverage =
|
|
91
|
-
(profile.agentPlugins.skills ? pkg.skills.length : 0) +
|
|
92
|
-
Object.values(pkg.mcpServers).filter((server) =>
|
|
93
|
-
profile.agentPlugins.mcpTransports.includes(server.type)
|
|
94
|
-
).length
|
|
95
|
-
const adapterCoverage =
|
|
96
|
-
(profile.components.skillDirectories ? pkg.skills.length : 0) +
|
|
97
|
-
Object.values(pkg.mcpServers).filter((server) =>
|
|
98
|
-
profile.components.mcpTransports.includes(server.type)
|
|
99
|
-
).length
|
|
100
|
-
const native = nativeEligible && nativeCoverage > 0 && nativeCoverage >= adapterCoverage
|
|
101
|
-
const strategy =
|
|
102
|
-
pkg.status === 'unavailable'
|
|
103
|
-
? 'unavailable'
|
|
104
|
-
: native
|
|
105
|
-
? 'native-agent-plugin'
|
|
106
|
-
: 'component-adapter'
|
|
107
|
-
let skillDirectories: string[] = []
|
|
108
|
-
const servers = new Map<string, McpServer>()
|
|
109
|
-
if (strategy !== 'unavailable') {
|
|
110
|
-
if (native ? profile.agentPlugins.skills : profile.components.skillDirectories)
|
|
111
|
-
skillDirectories = pkg.skills.map((skill) => skill.path)
|
|
112
|
-
else
|
|
113
|
-
for (const skill of pkg.skills)
|
|
114
|
-
disabled.push({
|
|
115
|
-
component: `skill:${skill.name}`,
|
|
116
|
-
reason: 'The selected adapter cannot expose skill directories.',
|
|
117
|
-
})
|
|
118
|
-
for (const [name, server] of Object.entries(pkg.mcpServers)) {
|
|
119
|
-
if (
|
|
120
|
-
(native ? profile.agentPlugins.mcpTransports : profile.components.mcpTransports).includes(
|
|
121
|
-
server.type
|
|
122
|
-
)
|
|
123
|
-
)
|
|
124
|
-
servers.set(name, server)
|
|
125
|
-
else
|
|
126
|
-
disabled.push({
|
|
127
|
-
component: `mcp:${name}`,
|
|
128
|
-
reason: `No ${server.type} MCP binding on this harness adapter.`,
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const hasContent = skillDirectories.length > 0 || servers.size > 0
|
|
133
|
-
const compatibility = !hasContent ? 'unsupported' : disabled.length > 0 ? 'partial' : 'full'
|
|
134
|
-
const selectedStrategy =
|
|
135
|
-
!hasContent || (compatibility === 'partial' && !input.allowPartial) ? 'unavailable' : strategy
|
|
136
|
-
return InstallationPlanSchema.parse({
|
|
137
|
-
planVersion: 2,
|
|
138
|
-
pluginId: input.pluginId,
|
|
139
|
-
releaseId: input.releaseId,
|
|
140
|
-
instanceId: input.instanceId,
|
|
141
|
-
profile,
|
|
142
|
-
source: input.source,
|
|
143
|
-
package: pkg,
|
|
144
|
-
// Git source identity also pins executable modes, which the v1 byte snapshot omits.
|
|
145
|
-
packageKey: pkg.packageDigest
|
|
146
|
-
? `packages/${identity(input.source.repositoryUrl, input.source.commitSha, input.source.pluginSubdirectory, pkg.packageDigest)}`
|
|
147
|
-
: '',
|
|
148
|
-
// Deliberately excludes release, package digest and harness. Switching harnesses or updating
|
|
149
|
-
// the same approved instance preserves data; distinct scopes use distinct instance IDs.
|
|
150
|
-
dataKey: `instances/${identity(input.pluginId, input.instanceId)}`,
|
|
151
|
-
preserveDataAcrossUpdates: true,
|
|
152
|
-
strategy: selectedStrategy,
|
|
153
|
-
compatibility,
|
|
154
|
-
allowedToActivate: false,
|
|
155
|
-
approvalRequired: true,
|
|
156
|
-
selection:
|
|
157
|
-
selectedStrategy === 'unavailable'
|
|
158
|
-
? { skillDirectories: [], mcpServers: {} }
|
|
159
|
-
: { skillDirectories, mcpServers: Object.fromEntries(servers) },
|
|
160
|
-
disabled,
|
|
161
|
-
requiredCredentials: [...(input.requiredCredentials ?? [])],
|
|
162
|
-
requiredConnectors: [...(input.requiredConnectors ?? [])],
|
|
163
|
-
preconditions: [
|
|
164
|
-
'Verify catalog integrity/provenance and exact source digest before applying the package recipe.',
|
|
165
|
-
'Use an immutable package root; preserve source file modes and complete skill directories/resources.',
|
|
166
|
-
'Create a writable data directory for this instance; never key it by release or copy credentials between instances.',
|
|
167
|
-
'Control Plane must authorize activation, filesystem/network access, executables and credential bindings.',
|
|
168
|
-
'Recheck the actual harness/runtime/adapter profile and realpath containment immediately before activation.',
|
|
169
|
-
'Native mode registers exactly one package root. Component mode registers only the selected skill directories and MCP bindings, never legacy hooks/config files.',
|
|
170
|
-
'Do not install dependencies or run lifecycle scripts implicitly; review required executables and skill compatibility requirements.',
|
|
171
|
-
'Skill allowed-tools metadata is advisory and never grants permission.',
|
|
172
|
-
'Namespace registrations by installation identity; detect skill/server name collisions instead of overwriting existing harness configuration.',
|
|
173
|
-
'Remote authorization is client-managed. Do not expand remote URLs/headers or forward configured headers to another origin without authorization.',
|
|
174
|
-
],
|
|
175
|
-
})
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface RuntimeRoots {
|
|
179
|
-
readonly pluginRoot: string
|
|
180
|
-
readonly pluginData: string
|
|
181
|
-
}
|
|
182
|
-
/** Exact, single-pass expansion. Replacement text is never scanned recursively. */
|
|
183
|
-
export function expandPluginPaths(value: string, roots: RuntimeRoots): string {
|
|
184
|
-
return value.replace(/\$\{(PLUGIN_ROOT|PLUGIN_DATA)\}/g, (_match, name: string) =>
|
|
185
|
-
name === 'PLUGIN_ROOT' ? roots.pluginRoot : roots.pluginData
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
function within(path: string, root: string): boolean {
|
|
189
|
-
const suffix = relative(root, path)
|
|
190
|
-
return suffix === '' || (suffix !== '..' && !suffix.startsWith(`..${sep}`) && !isAbsolute(suffix))
|
|
191
|
-
}
|
|
192
|
-
export type McpBinding =
|
|
193
|
-
| {
|
|
194
|
-
type: 'stdio'
|
|
195
|
-
command: string
|
|
196
|
-
args: string[]
|
|
197
|
-
cwd: string
|
|
198
|
-
env: Record<string, string>
|
|
199
|
-
shell: false
|
|
200
|
-
}
|
|
201
|
-
| {
|
|
202
|
-
type: 'streamable-http' | 'sse'
|
|
203
|
-
url: string
|
|
204
|
-
headers: Record<string, string>
|
|
205
|
-
redirectPolicy: 'same-origin'
|
|
206
|
-
authorization: 'control-plane'
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** Produce concrete Control Plane launch/connect descriptors, without launching or connecting. */
|
|
210
|
-
export function resolveMcpBinding(
|
|
211
|
-
input: McpServer,
|
|
212
|
-
roots: RuntimeRoots,
|
|
213
|
-
baseEnv: Readonly<Record<string, string>> = {},
|
|
214
|
-
platform: 'posix' | 'win32' = process.platform === 'win32' ? 'win32' : 'posix'
|
|
215
|
-
): McpBinding {
|
|
216
|
-
const server = validateServer(input)
|
|
217
|
-
if (!isAbsolute(roots.pluginRoot) || !isAbsolute(roots.pluginData))
|
|
218
|
-
throw new Error('Runtime plugin roots must be absolute paths.')
|
|
219
|
-
if (server.type !== 'stdio')
|
|
220
|
-
return {
|
|
221
|
-
type: server.type,
|
|
222
|
-
url: server.url,
|
|
223
|
-
headers: { ...server.headers },
|
|
224
|
-
redirectPolicy: 'same-origin',
|
|
225
|
-
authorization: 'control-plane',
|
|
226
|
-
}
|
|
227
|
-
const command = server.command.startsWith('./')
|
|
228
|
-
? resolve(roots.pluginRoot, server.command)
|
|
229
|
-
: server.command
|
|
230
|
-
if (server.command.startsWith('./') && !within(command, roots.pluginRoot))
|
|
231
|
-
throw new Error('Executable escapes the plugin root.')
|
|
232
|
-
const cwdInput = server.cwd ?? '${PLUGIN_ROOT}'
|
|
233
|
-
const cwdRoot = cwdInput.startsWith('${PLUGIN_DATA}') ? roots.pluginData : roots.pluginRoot
|
|
234
|
-
const expanded = expandPluginPaths(cwdInput, roots)
|
|
235
|
-
const cwd = resolve(roots.pluginRoot, expanded)
|
|
236
|
-
if (!within(cwd, cwdRoot)) throw new Error('Working directory escapes its declared root.')
|
|
237
|
-
const env: Record<string, string> = {}
|
|
238
|
-
const overlay = (name: string, value: string): void => {
|
|
239
|
-
if (platform === 'win32')
|
|
240
|
-
for (const existing of Object.keys(env))
|
|
241
|
-
if (existing.toUpperCase() === name.toUpperCase()) delete env[existing]
|
|
242
|
-
Object.defineProperty(env, name, {
|
|
243
|
-
value,
|
|
244
|
-
enumerable: true,
|
|
245
|
-
configurable: true,
|
|
246
|
-
writable: true,
|
|
247
|
-
})
|
|
248
|
-
}
|
|
249
|
-
for (const [key, value] of Object.entries(baseEnv)) overlay(key, value)
|
|
250
|
-
for (const [key, value] of Object.entries(server.env ?? {}))
|
|
251
|
-
overlay(key, expandPluginPaths(value, roots))
|
|
252
|
-
overlay('PLUGIN_ROOT', roots.pluginRoot)
|
|
253
|
-
overlay('PLUGIN_DATA', roots.pluginData)
|
|
254
|
-
return {
|
|
255
|
-
type: 'stdio',
|
|
256
|
-
command,
|
|
257
|
-
args: (server.args ?? []).map((arg) => expandPluginPaths(arg, roots)),
|
|
258
|
-
cwd,
|
|
259
|
-
env,
|
|
260
|
-
shell: false,
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** Mandatory filesystem preflight for Control Plane callers after safe materialization.
|
|
265
|
-
* Call immediately before activation inside the same protected installation boundary;
|
|
266
|
-
* a separate preflight is not a substitute for preventing concurrent filesystem mutation.
|
|
267
|
-
*/
|
|
268
|
-
export async function verifyBindingPaths(input: McpServer, roots: RuntimeRoots): Promise<void> {
|
|
269
|
-
const binding = resolveMcpBinding(input, roots)
|
|
270
|
-
if (binding.type !== 'stdio' || input.type !== 'stdio') return
|
|
271
|
-
const root = await realpath(roots.pluginRoot)
|
|
272
|
-
const data = await realpath(roots.pluginData)
|
|
273
|
-
if (root !== roots.pluginRoot || data !== roots.pluginData)
|
|
274
|
-
throw new Error('Supply canonical filesystem-resolved runtime roots.')
|
|
275
|
-
const cwd = await realpath(binding.cwd)
|
|
276
|
-
const expected = input.cwd?.startsWith('${PLUGIN_DATA}') ? data : root
|
|
277
|
-
if (!within(cwd, expected))
|
|
278
|
-
throw new Error('Working directory resolves outside its declared root.')
|
|
279
|
-
if (input.command.startsWith('./') && !within(await realpath(binding.command), root))
|
|
280
|
-
throw new Error('Executable resolves outside the package root.')
|
|
281
|
-
}
|