@jini-ai/agent-plugins 0.4.6 → 0.4.8
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/CHANGELOG.md +30 -0
- package/README.md +48 -0
- package/dist/admin-surfaces/action-dispatcher.d.ts +37 -0
- package/dist/admin-surfaces/action-dispatcher.js +69 -0
- package/dist/admin-surfaces/action-schema.d.ts +56 -0
- package/dist/admin-surfaces/action-schema.js +167 -0
- package/dist/admin-surfaces/action-tools.d.ts +40 -0
- package/dist/admin-surfaces/action-tools.js +52 -0
- package/dist/admin-surfaces/callback-field-inbox.d.ts +35 -0
- package/dist/admin-surfaces/callback-field-inbox.js +53 -0
- package/dist/admin-surfaces/capability-declarations.d.ts +41 -0
- package/dist/admin-surfaces/capability-declarations.js +102 -0
- package/dist/admin-surfaces/contribution.d.ts +49 -0
- package/dist/admin-surfaces/contribution.js +30 -0
- package/dist/admin-surfaces/delivery-bindings.d.ts +76 -0
- package/dist/admin-surfaces/delivery-bindings.js +99 -0
- package/dist/admin-surfaces/descriptor.d.ts +69 -0
- package/dist/admin-surfaces/descriptor.js +196 -0
- package/dist/admin-surfaces/external-links.d.ts +45 -0
- package/dist/admin-surfaces/external-links.js +70 -0
- package/dist/admin-surfaces/host-validator.d.ts +62 -0
- package/dist/admin-surfaces/host-validator.js +87 -0
- package/dist/admin-surfaces/index.d.ts +23 -0
- package/dist/admin-surfaces/index.js +21 -0
- package/dist/admin-surfaces/protocol.d.ts +103 -0
- package/dist/admin-surfaces/protocol.js +25 -0
- package/dist/admin-surfaces/sandbox.d.ts +78 -0
- package/dist/admin-surfaces/sandbox.js +92 -0
- package/dist/admin-surfaces/settings-value.d.ts +28 -0
- package/dist/admin-surfaces/settings-value.js +45 -0
- package/dist/admin-surfaces/surface-capabilities.d.ts +167 -0
- package/dist/admin-surfaces/surface-capabilities.js +215 -0
- package/dist/admin-surfaces/surface-client.d.ts +116 -0
- package/dist/admin-surfaces/surface-client.js +219 -0
- package/dist/admin-surfaces/surface-handlers.d.ts +111 -0
- package/dist/admin-surfaces/surface-handlers.js +172 -0
- package/dist/admin-surfaces/theme.d.ts +59 -0
- package/dist/admin-surfaces/theme.js +57 -0
- package/dist/folder-zip-node.d.ts +11 -0
- package/dist/folder-zip-node.js +84 -0
- package/dist/folder-zip.d.ts +38 -0
- package/dist/folder-zip.js +134 -0
- package/dist/lifecycle/automatic-use.d.ts +79 -0
- package/dist/lifecycle/automatic-use.js +165 -0
- package/dist/lifecycle/compatibility-metadata.d.ts +19 -0
- package/dist/lifecycle/compatibility-metadata.js +45 -0
- package/dist/lifecycle/compatibility.d.ts +52 -0
- package/dist/lifecycle/compatibility.js +60 -0
- package/dist/lifecycle/fetch-archive.js +26 -24
- package/dist/lifecycle/index.d.ts +14 -2
- package/dist/lifecycle/index.js +8 -1
- package/dist/lifecycle/install-errors.d.ts +14 -0
- package/dist/lifecycle/install-errors.js +9 -0
- package/dist/lifecycle/install.d.ts +2 -13
- package/dist/lifecycle/install.js +12 -123
- package/dist/lifecycle/installed-package-index.d.ts +15 -0
- package/dist/lifecycle/installed-package-index.js +128 -0
- package/dist/lifecycle/installed-package-roots.js +28 -20
- package/dist/lifecycle/manifest.d.ts +14 -0
- package/dist/lifecycle/manifest.js +115 -100
- package/dist/lifecycle/package-paths.js +3 -3
- package/dist/lifecycle/ports.d.ts +1 -1
- package/dist/lifecycle/provider-contribution.d.ts +65 -0
- package/dist/lifecycle/provider-contribution.js +93 -0
- package/dist/lifecycle/resolve-agent-plugin-refs.js +19 -6
- package/dist/lifecycle/retire-bundled.js +20 -18
- package/dist/lifecycle/search.d.ts +6 -1
- package/dist/lifecycle/search.js +45 -7
- package/dist/lifecycle/set-enabled.d.ts +2 -1
- package/dist/lifecycle/set-enabled.js +52 -8
- package/dist/lifecycle/skill-file-reader.js +85 -71
- package/dist/lifecycle/tools/capabilities.d.ts +199 -0
- package/dist/lifecycle/tools/capabilities.js +213 -0
- package/dist/lifecycle/tools/definition.d.ts +32 -0
- package/dist/lifecycle/tools/definition.js +33 -0
- package/dist/lifecycle/tools/index.d.ts +10 -0
- package/dist/lifecycle/tools/index.js +10 -0
- package/dist/lifecycle/tools/manifest.d.ts +33 -0
- package/dist/lifecycle/tools/manifest.js +89 -0
- package/dist/lifecycle/tools/projection.d.ts +90 -0
- package/dist/lifecycle/tools/projection.js +283 -0
- package/dist/lifecycle/types.d.ts +2 -0
- package/dist/lifecycle/uninstall.d.ts +3 -1
- package/dist/lifecycle/uninstall.js +51 -27
- package/dist/lifecycle/update-plan.d.ts +18 -0
- package/dist/lifecycle/update-plan.js +22 -0
- package/dist/lifecycle/update-store.d.ts +71 -0
- package/dist/lifecycle/update-store.js +150 -0
- package/dist/lifecycle/update.d.ts +55 -0
- package/dist/lifecycle/update.js +321 -0
- package/dist/manifest.d.ts +2 -1
- package/dist/manifest.js +2 -1
- package/package.json +50 -6
- package/ui-ux-design/plugin.json +8 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/activation.d.ts.map +0 -1
- package/dist/lifecycle/activation.js.map +0 -1
- package/dist/lifecycle/bundled-digests.d.ts.map +0 -1
- package/dist/lifecycle/bundled-digests.js.map +0 -1
- package/dist/lifecycle/bundled-source-archive.d.ts.map +0 -1
- package/dist/lifecycle/bundled-source-archive.js.map +0 -1
- package/dist/lifecycle/capability-projection.d.ts.map +0 -1
- package/dist/lifecycle/capability-projection.js.map +0 -1
- package/dist/lifecycle/contribution-loader.d.ts.map +0 -1
- package/dist/lifecycle/contribution-loader.js.map +0 -1
- package/dist/lifecycle/fetch-archive.d.ts.map +0 -1
- package/dist/lifecycle/fetch-archive.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/install-from-url.d.ts.map +0 -1
- package/dist/lifecycle/install-from-url.js.map +0 -1
- package/dist/lifecycle/install.d.ts.map +0 -1
- package/dist/lifecycle/install.js.map +0 -1
- package/dist/lifecycle/installed-package-roots.d.ts.map +0 -1
- package/dist/lifecycle/installed-package-roots.js.map +0 -1
- package/dist/lifecycle/layout.d.ts.map +0 -1
- package/dist/lifecycle/layout.js.map +0 -1
- package/dist/lifecycle/manifest.d.ts.map +0 -1
- package/dist/lifecycle/manifest.js.map +0 -1
- package/dist/lifecycle/mcp-provisioning.d.ts.map +0 -1
- package/dist/lifecycle/mcp-provisioning.js.map +0 -1
- package/dist/lifecycle/node.d.ts.map +0 -1
- package/dist/lifecycle/node.js.map +0 -1
- package/dist/lifecycle/package-paths.d.ts.map +0 -1
- package/dist/lifecycle/package-paths.js.map +0 -1
- package/dist/lifecycle/persistent-state.d.ts.map +0 -1
- package/dist/lifecycle/persistent-state.js.map +0 -1
- package/dist/lifecycle/ports.d.ts.map +0 -1
- package/dist/lifecycle/ports.js.map +0 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.d.ts.map +0 -1
- package/dist/lifecycle/resolve-agent-plugin-refs.js.map +0 -1
- package/dist/lifecycle/retire-bundled.d.ts.map +0 -1
- package/dist/lifecycle/retire-bundled.js.map +0 -1
- package/dist/lifecycle/search.d.ts.map +0 -1
- package/dist/lifecycle/search.js.map +0 -1
- package/dist/lifecycle/seed-bundled.d.ts.map +0 -1
- package/dist/lifecycle/seed-bundled.js.map +0 -1
- package/dist/lifecycle/set-enabled.d.ts.map +0 -1
- package/dist/lifecycle/set-enabled.js.map +0 -1
- package/dist/lifecycle/skill-file-reader.d.ts.map +0 -1
- package/dist/lifecycle/skill-file-reader.js.map +0 -1
- package/dist/lifecycle/trusted-plugin-files.d.ts.map +0 -1
- package/dist/lifecycle/trusted-plugin-files.js.map +0 -1
- package/dist/lifecycle/types.d.ts.map +0 -1
- package/dist/lifecycle/types.js.map +0 -1
- package/dist/lifecycle/uninstall.d.ts.map +0 -1
- package/dist/lifecycle/uninstall.js.map +0 -1
- package/dist/lifecycle/yauzl-archive-reader.d.ts.map +0 -1
- package/dist/lifecycle/yauzl-archive-reader.js.map +0 -1
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The executable tool contribution, defined on the lifecycle's one executable loader
|
|
3
|
+
* (`defineExecutablePluginContribution`) so tool modules pass the same gates as every other seam
|
|
4
|
+
* that runs plugin code: active plugin, bundled digest, contained `.mjs` path. No second loader.
|
|
5
|
+
* The filename is the host's: Jini never names a product's contribution file.
|
|
6
|
+
*/
|
|
7
|
+
import { defineExecutablePluginContribution } from '../contribution-loader.js';
|
|
8
|
+
import { parseAgentPluginToolsFile } from './manifest.js';
|
|
9
|
+
/** The module's export as a tool module, or why not. Shape only; effect rules apply at projection. @complexity O(1). */
|
|
10
|
+
function validateToolModule({ exported }) {
|
|
11
|
+
if (typeof exported !== 'object' || exported === null)
|
|
12
|
+
return "its module's default export is not an object";
|
|
13
|
+
const candidate = exported;
|
|
14
|
+
if (typeof candidate.invoke !== 'function')
|
|
15
|
+
return "its module's default export has no invoke()";
|
|
16
|
+
if (candidate.describeAffectedResources !== undefined && typeof candidate.describeAffectedResources !== 'function')
|
|
17
|
+
return 'describeAffectedResources must be a function';
|
|
18
|
+
return exported;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Defines the tool contribution for a host-chosen filename (e.g. `<product>-agent-tools.json`).
|
|
22
|
+
* @param required.filename - The file a plugin ships at its package root to contribute tools.
|
|
23
|
+
* @returns A definition for `loadPluginContributions`; executable, so activation is always required.
|
|
24
|
+
* @complexity O(1); each load is one contained import per declared tool (Node caches per file URL).
|
|
25
|
+
*/
|
|
26
|
+
export function defineAgentPluginToolContribution(required, _optional = {}) {
|
|
27
|
+
return defineExecutablePluginContribution({
|
|
28
|
+
filename: required.filename, contribution: 'agent tools',
|
|
29
|
+
parse: parseAgentPluginToolsFile, modulePath: ({ descriptor }) => descriptor.module, validate: validateToolModule,
|
|
30
|
+
refusal: ({ plugin, descriptor, reason }) => `agent tool '${descriptor.name}' from '${plugin.pluginId}' was not loaded: ${reason}`,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Public surface of `@jini-ai/agent-plugins/lifecycle/tools`: executable Agent Plugin tools.
|
|
3
|
+
* A separate subpath because it needs the optional `@cfworker/json-schema` peer; consumers of
|
|
4
|
+
* `./lifecycle` alone do not. The plugin tool contract arrives as host ports, never an import. See this folder's README.md.
|
|
5
|
+
*/
|
|
6
|
+
export { parseAgentPluginToolsFile, type AgentPluginToolDescriptor, type AgentPluginToolEffect } from './manifest.js';
|
|
7
|
+
export { defineAgentPluginToolContribution, type AgentPluginToolModule, type LoadedAgentPluginTool } from './definition.js';
|
|
8
|
+
export { WITHHELD_OUTPUT_MESSAGE, createIssuedTokenMemories, type IssuedTokenMemories, type AgentPluginToolCapabilities, type AgentPluginToolCapabilitiesPort, type AgentPluginToolCapabilityScope, type AgentPluginHttpOptions, type AgentPluginLimitResult, type AgentPluginStateReader, type AgentPluginStateValue, } from './capabilities.js';
|
|
9
|
+
export { createAgentPluginToolProjection, type AgentPluginToolDisclosure, type AgentPluginToolProjectionPorts, type AgentPluginAdditionalTool, type AgentPluginToolSnapshot, type AgentPluginContractTool, type AgentPluginToolInvocation, } from './projection.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Public surface of `@jini-ai/agent-plugins/lifecycle/tools`: executable Agent Plugin tools.
|
|
3
|
+
* A separate subpath because it needs the optional `@cfworker/json-schema` peer; consumers of
|
|
4
|
+
* `./lifecycle` alone do not. The plugin tool contract arrives as host ports, never an import. See this folder's README.md.
|
|
5
|
+
*/
|
|
6
|
+
export { parseAgentPluginToolsFile } from './manifest.js';
|
|
7
|
+
export { defineAgentPluginToolContribution } from './definition.js';
|
|
8
|
+
export { WITHHELD_OUTPUT_MESSAGE, createIssuedTokenMemories, } from './capabilities.js';
|
|
9
|
+
export { createAgentPluginToolProjection, } from './projection.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Parses an Agent Plugin's tool contribution file: the data half of an executable tool.
|
|
3
|
+
* Name, description, effect class and input schema are declared as reviewable data so the host can
|
|
4
|
+
* list, namespace and validate a tool without running plugin code; only `module` points at code.
|
|
5
|
+
* Pure: no I/O. A file that fails any rule is refused whole, so a plugin never ships half its tools.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginContributionParseResult } from '../contribution-loader.js';
|
|
8
|
+
/**
|
|
9
|
+
* Declared change class; `write` and `destructive` tools must also disclose affected resources.
|
|
10
|
+
* The mirror of `PluginToolEffect` in `@jini-ai/plugins/host` (agent-plugins may not import it); the
|
|
11
|
+
* projection's contract tool reuses this type, so these two are the only declarations.
|
|
12
|
+
*/
|
|
13
|
+
export type AgentPluginToolEffect = 'read' | 'write' | 'destructive';
|
|
14
|
+
/** One declared tool. `name` is local; the host namespaces it as `p_<plugin>__<name>`. */
|
|
15
|
+
export interface AgentPluginToolDescriptor {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly effect: AgentPluginToolEffect;
|
|
19
|
+
/** Plain-JS module inside the plugin root (`.mjs`); containment is checked on disk at import. */
|
|
20
|
+
readonly module: string;
|
|
21
|
+
/** JSON Schema (2020-12) for the tool input; must describe an object. */
|
|
22
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parses the raw contribution file. A local name declared twice is refused (duplicate id).
|
|
26
|
+
* @param required.raw - The file text as read from a trusted package.
|
|
27
|
+
* @returns Descriptors in declaration order, or the reason the whole file is refused.
|
|
28
|
+
* @complexity O(t^2 + s) for t declarations (t <= 128) and s total schema size.
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseAgentPluginToolsFile(required: {
|
|
31
|
+
readonly raw: string;
|
|
32
|
+
}, _optional?: Record<string, never>): PluginContributionParseResult<AgentPluginToolDescriptor>;
|
|
33
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Bounds mirror the existing tier-3 tool capture (`@jini-ai/plugins/host` contributions.ts) so one
|
|
2
|
+
// plugin tool contract has one set of limits, whichever loader admitted it.
|
|
3
|
+
const NAME_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
4
|
+
const MAX_TOOLS = 128;
|
|
5
|
+
const MAX_DESCRIPTION = 8000;
|
|
6
|
+
const MAX_MODULE_PATH = 256;
|
|
7
|
+
const MAX_SCHEMA_BYTES = 65536;
|
|
8
|
+
const EFFECTS = new Set(['read', 'write', 'destructive']);
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
/** Why the input schema is unusable, or undefined. Detaches nothing; the caller copies. @complexity O(s) schema size. */
|
|
13
|
+
function schemaProblem(schema) {
|
|
14
|
+
if (!isRecord(schema) || schema.type !== 'object')
|
|
15
|
+
return 'inputSchema must be a JSON Schema describing an object';
|
|
16
|
+
if (new TextEncoder().encode(JSON.stringify(schema)).byteLength > MAX_SCHEMA_BYTES)
|
|
17
|
+
return 'inputSchema is larger than 64 KiB';
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
/** Why a description is unusable, or undefined. @complexity O(1). */
|
|
21
|
+
function descriptionProblem(name, description) {
|
|
22
|
+
if (typeof description === 'string' && description.trim() && description.length <= MAX_DESCRIPTION)
|
|
23
|
+
return undefined;
|
|
24
|
+
return `tool '${name}' needs a description of at most ${MAX_DESCRIPTION} characters`;
|
|
25
|
+
}
|
|
26
|
+
/** Why a module path is unusable here, or undefined; containment is checked on disk at import. @complexity O(1). */
|
|
27
|
+
function moduleProblem(name, module) {
|
|
28
|
+
if (typeof module === 'string' && module.endsWith('.mjs') && module.length <= MAX_MODULE_PATH)
|
|
29
|
+
return undefined;
|
|
30
|
+
return `tool '${name}' module must be a .mjs path inside the plugin`;
|
|
31
|
+
}
|
|
32
|
+
/** Why one declaration's scalar fields are invalid, or undefined. @complexity O(1). */
|
|
33
|
+
function fieldProblem(entry) {
|
|
34
|
+
const { name } = entry;
|
|
35
|
+
if (typeof name !== 'string' || !NAME_PATTERN.test(name))
|
|
36
|
+
return 'a tool name must be lower snake case, at most 64 characters';
|
|
37
|
+
const effectProblem = EFFECTS.has(entry.effect) ? undefined : `tool '${name}' effect must be read, write or destructive`;
|
|
38
|
+
return descriptionProblem(name, entry.description) ?? effectProblem ?? moduleProblem(name, entry.module);
|
|
39
|
+
}
|
|
40
|
+
/** One declaration, or why it is refused. Unknown keys are ignored. @complexity O(s) schema size. */
|
|
41
|
+
function parseEntry(entry) {
|
|
42
|
+
if (!isRecord(entry))
|
|
43
|
+
return 'every tool declaration must be an object';
|
|
44
|
+
const problem = fieldProblem(entry) ?? schemaProblem(entry.inputSchema);
|
|
45
|
+
if (problem)
|
|
46
|
+
return problem;
|
|
47
|
+
return Object.freeze({
|
|
48
|
+
name: entry.name, description: entry.description, effect: entry.effect,
|
|
49
|
+
module: entry.module, inputSchema: JSON.parse(JSON.stringify(entry.inputSchema)),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** The declaration list from the raw file, or why the file is refused. @complexity O(n) file size. */
|
|
53
|
+
function declarations(raw) {
|
|
54
|
+
let value;
|
|
55
|
+
try {
|
|
56
|
+
value = JSON.parse(raw);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return 'not valid JSON';
|
|
60
|
+
}
|
|
61
|
+
if (!isRecord(value) || value.schemaVersion !== 1)
|
|
62
|
+
return 'schemaVersion must be 1';
|
|
63
|
+
const { tools } = value;
|
|
64
|
+
if (!Array.isArray(tools) || tools.length === 0 || tools.length > MAX_TOOLS)
|
|
65
|
+
return `tools must list 1 to ${MAX_TOOLS} declarations`;
|
|
66
|
+
return tools;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parses the raw contribution file. A local name declared twice is refused (duplicate id).
|
|
70
|
+
* @param required.raw - The file text as read from a trusted package.
|
|
71
|
+
* @returns Descriptors in declaration order, or the reason the whole file is refused.
|
|
72
|
+
* @complexity O(t^2 + s) for t declarations (t <= 128) and s total schema size.
|
|
73
|
+
*/
|
|
74
|
+
export function parseAgentPluginToolsFile(required, _optional = {}) {
|
|
75
|
+
const tools = declarations(required.raw);
|
|
76
|
+
if (typeof tools === 'string')
|
|
77
|
+
return { ok: false, reason: tools };
|
|
78
|
+
const descriptors = [];
|
|
79
|
+
for (const entry of tools) {
|
|
80
|
+
const parsed = parseEntry(entry);
|
|
81
|
+
if (typeof parsed === 'string')
|
|
82
|
+
return { ok: false, reason: parsed };
|
|
83
|
+
if (descriptors.some(existing => existing.name === parsed.name))
|
|
84
|
+
return { ok: false, reason: `tool '${parsed.name}' is declared more than once` };
|
|
85
|
+
descriptors.push(parsed);
|
|
86
|
+
}
|
|
87
|
+
return { ok: true, descriptors };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type AgentPluginToolCapabilitiesPort, type IssuedTokenMemories } from './capabilities.js';
|
|
2
|
+
import type { LoadedAgentPluginTool } from './definition.js';
|
|
3
|
+
import type { AgentPluginToolEffect } from './manifest.js';
|
|
4
|
+
/** What one call receives from the plugin tool contract. Structural: the host owns that contract. */
|
|
5
|
+
export interface AgentPluginToolInvocation {
|
|
6
|
+
readonly pluginId: string;
|
|
7
|
+
readonly auth: {
|
|
8
|
+
readonly workspaceId: string;
|
|
9
|
+
readonly principalId?: string;
|
|
10
|
+
};
|
|
11
|
+
readonly input: unknown;
|
|
12
|
+
readonly signal?: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
/** One tool in the contract's shape (`PluginToolContribution` in `@jini-ai/plugins/host`). */
|
|
15
|
+
export interface AgentPluginContractTool {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
19
|
+
/** Always set here; optional so the host's own snapshot type (where it is optional) fits the port. */
|
|
20
|
+
readonly effect?: AgentPluginToolEffect;
|
|
21
|
+
handler(required: AgentPluginToolInvocation, optional?: Record<string, never>): unknown;
|
|
22
|
+
}
|
|
23
|
+
/** A host adapter over another admitted contribution, using its existing execution owner. */
|
|
24
|
+
export interface AgentPluginAdditionalTool {
|
|
25
|
+
readonly pluginId: string;
|
|
26
|
+
readonly tool: AgentPluginContractTool;
|
|
27
|
+
readonly describeAffectedResources: (required: {
|
|
28
|
+
readonly input: unknown;
|
|
29
|
+
}) => readonly string[] | Promise<readonly string[]>;
|
|
30
|
+
}
|
|
31
|
+
/** One plugin's generation in the contract's snapshot shape; routes and widgets stay empty. */
|
|
32
|
+
export interface AgentPluginToolSnapshot {
|
|
33
|
+
readonly pluginId: string;
|
|
34
|
+
readonly sdk: object;
|
|
35
|
+
readonly routes: readonly unknown[];
|
|
36
|
+
readonly widgets: readonly unknown[];
|
|
37
|
+
readonly tools: readonly AgentPluginContractTool[];
|
|
38
|
+
}
|
|
39
|
+
/** Host ports: its contribution registry and its tool-id namespacing rule (`pluginToolIdFor`). */
|
|
40
|
+
export interface AgentPluginToolProjectionPorts {
|
|
41
|
+
readonly registry: {
|
|
42
|
+
replace(required: {
|
|
43
|
+
readonly contributions: AgentPluginToolSnapshot;
|
|
44
|
+
}, optional?: Record<string, never>): void;
|
|
45
|
+
detach(required: {
|
|
46
|
+
readonly pluginId: string;
|
|
47
|
+
}, optional?: Record<string, never>): void;
|
|
48
|
+
list(required: Record<string, never>, optional?: Record<string, never>): readonly unknown[];
|
|
49
|
+
};
|
|
50
|
+
readonly toolIdFor: (required: {
|
|
51
|
+
readonly pluginId: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
}, optional?: Record<string, never>) => string;
|
|
54
|
+
readonly capabilities: AgentPluginToolCapabilitiesPort;
|
|
55
|
+
/** The host's ONE token memory source, also passed to its admin-surface host (see `createIssuedTokenMemories`). */
|
|
56
|
+
readonly issuedTokens: IssuedTokenMemories;
|
|
57
|
+
}
|
|
58
|
+
/** What the host shows before confirming a call. */
|
|
59
|
+
export interface AgentPluginToolDisclosure {
|
|
60
|
+
readonly effect: AgentPluginToolEffect;
|
|
61
|
+
readonly resources: readonly string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates the projection for one dedicated contribution registry (keyed by plugin id, so it must not
|
|
65
|
+
* be shared with site plugins whose ids could match). Call `sync` after every load: on boot and on
|
|
66
|
+
* every activation change. A plugin missing from a load is detached: its tools disappear and its
|
|
67
|
+
* calls' capabilities are revoked.
|
|
68
|
+
* @param required.registry - Registry the host attached with `attachPluginContributionTools`.
|
|
69
|
+
* @param required.toolIdFor - The contract's namespacing rule (`pluginToolIdFor`), so ids match the registry's.
|
|
70
|
+
* @param required.capabilities - Host port building one call's capabilities.
|
|
71
|
+
* @param required.issuedTokens - Per-plugin token memory shared with the plugin's admin-surface handlers.
|
|
72
|
+
* @complexity sync is O(t) tools plus schema compilation; disclosure lookup is O(1).
|
|
73
|
+
*/
|
|
74
|
+
export declare function createAgentPluginToolProjection(required: AgentPluginToolProjectionPorts, _optional?: Record<string, never>): {
|
|
75
|
+
/** Projects one load result. @returns The loader's refusals plus this seam's own, in order. */
|
|
76
|
+
sync(input: {
|
|
77
|
+
readonly loaded: readonly LoadedAgentPluginTool[];
|
|
78
|
+
readonly refusals: readonly string[];
|
|
79
|
+
readonly additionalTools?: readonly AgentPluginAdditionalTool[];
|
|
80
|
+
}, _options?: Record<string, never>): {
|
|
81
|
+
readonly refusals: readonly string[];
|
|
82
|
+
};
|
|
83
|
+
/** What a call would change, for the confirmation prompt; null for an unknown or withdrawn tool.
|
|
84
|
+
* @throws ToolInputError for input that fails the schema; Error for an invalid hook answer. */
|
|
85
|
+
describeAffectedResources(input: {
|
|
86
|
+
readonly toolId: string;
|
|
87
|
+
readonly input: unknown;
|
|
88
|
+
}, _options?: Record<string, never>): Promise<AgentPluginToolDisclosure | null>;
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Projects loaded Agent Plugin tools into the EXISTING plugin tool contribution contract
|
|
3
|
+
* (`@jini-ai/plugins/host`: `PluginContributionRegistry` → `attachPluginContributionTools`), so these
|
|
4
|
+
* tools reach the assistant through the same namespaced ids, enablement recheck, auth port, confirmation
|
|
5
|
+
* and revocable registry scope as every other plugin tool. Nothing here registers tools directly.
|
|
6
|
+
*
|
|
7
|
+
* Added at this seam, because only it knows a tool came from an Agent Plugin module:
|
|
8
|
+
* - schema validation of the input before the module runs (the registry passes schemas through);
|
|
9
|
+
* - per-call host capabilities, revoked when the plugin's tools are withdrawn;
|
|
10
|
+
* - the affected-resources disclosure the host shows before confirming a write/destructive call;
|
|
11
|
+
* - refusal of ambiguous ids (two plugins whose namespaced ids collide) and of write/destructive
|
|
12
|
+
* tools that cannot disclose what they change.
|
|
13
|
+
*/
|
|
14
|
+
import { Validator } from '@cfworker/json-schema';
|
|
15
|
+
import { requireInputRecord, ToolInputError } from '@jini-ai/core';
|
|
16
|
+
import { openCapabilitySession, openCredentialScan, REVOKED_MESSAGE } from './capabilities.js';
|
|
17
|
+
const MAX_RESOURCES = 50;
|
|
18
|
+
const MAX_RESOURCE_LENGTH = 300;
|
|
19
|
+
/** Agent Plugin tools have no site-plugin SDK; the contract's slot is filled with one that refuses. */
|
|
20
|
+
const refuse = () => { throw new Error('Agent Plugin tools have no site-plugin SDK.'); };
|
|
21
|
+
const INERT_SDK = Object.freeze({
|
|
22
|
+
content: Object.freeze({ read: refuse, extend: refuse }), addFilter: refuse, addAction: refuse, addContribution: refuse,
|
|
23
|
+
routes: Object.freeze({ add: refuse }), tools: Object.freeze({ add: refuse }), widgets: Object.freeze({ add: refuse }),
|
|
24
|
+
});
|
|
25
|
+
/** Compiles the declared schema, or says why it cannot be used. @complexity O(s) schema size. */
|
|
26
|
+
function compileSchema(schema) {
|
|
27
|
+
try {
|
|
28
|
+
const validator = new Validator(schema, '2020-12', true);
|
|
29
|
+
// cfworker resolves references lazily; one probe surfaces a root-level unresolved $ref at load.
|
|
30
|
+
validator.validate({});
|
|
31
|
+
return validator;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return `its input schema is invalid (${error instanceof Error ? error.message : String(error)})`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** Why a loaded tool cannot be projected, or its admitted form. @complexity O(s) schema size. */
|
|
38
|
+
function admitOne(loaded, toolIdFor) {
|
|
39
|
+
const { descriptor, module } = loaded;
|
|
40
|
+
if (descriptor.effect !== 'read' && typeof module.describeAffectedResources !== 'function') {
|
|
41
|
+
return `a ${descriptor.effect} tool must export describeAffectedResources()`;
|
|
42
|
+
}
|
|
43
|
+
const validator = compileSchema(descriptor.inputSchema);
|
|
44
|
+
if (typeof validator === 'string')
|
|
45
|
+
return validator;
|
|
46
|
+
return { toolId: toolIdFor({ pluginId: loaded.pluginId, name: descriptor.name }), loaded, validator };
|
|
47
|
+
}
|
|
48
|
+
/** Admits each tool, then drops every id more than one plugin claims ("refusing to guess").
|
|
49
|
+
* @complexity O(t) tools plus schema compilation. */
|
|
50
|
+
function admitAll(loaded, refusals, toolIdFor) {
|
|
51
|
+
const admitted = [];
|
|
52
|
+
for (const entry of loaded) {
|
|
53
|
+
const result = admitOne(entry, toolIdFor);
|
|
54
|
+
if (typeof result === 'string')
|
|
55
|
+
refusals.push(`agent tool '${entry.descriptor.name}' from '${entry.pluginId}' was not loaded: ${result}`);
|
|
56
|
+
else
|
|
57
|
+
admitted.push(result);
|
|
58
|
+
}
|
|
59
|
+
const claimants = new Map();
|
|
60
|
+
for (const tool of admitted)
|
|
61
|
+
claimants.set(tool.toolId, (claimants.get(tool.toolId) ?? new Set()).add(tool.loaded.pluginId));
|
|
62
|
+
for (const [toolId, owners] of claimants) {
|
|
63
|
+
if (owners.size > 1)
|
|
64
|
+
refusals.push(`agent tool '${toolId}' was not loaded: more than one plugin declares it (${[...owners].map(id => `'${id}'`).sort().join(', ')})`);
|
|
65
|
+
}
|
|
66
|
+
return admitted.filter(tool => claimants.get(tool.toolId).size === 1);
|
|
67
|
+
}
|
|
68
|
+
/** Validates input against the declared schema; the message names locations, never values.
|
|
69
|
+
* @complexity O(n) input size. */
|
|
70
|
+
function validatedInput(tool, input) {
|
|
71
|
+
const record = requireInputRecord({ input });
|
|
72
|
+
let result;
|
|
73
|
+
// A schema fault reached only by some inputs (nested $ref, bad pattern) fails closed, not as bad input.
|
|
74
|
+
try {
|
|
75
|
+
result = tool.validator.validate(record);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
throw new Error(`Plugin tool '${tool.toolId}' has an unusable input schema; report it to the plugin author.`, { cause: error });
|
|
79
|
+
}
|
|
80
|
+
if (result.valid)
|
|
81
|
+
return record;
|
|
82
|
+
// cfworker roots every instanceLocation at '#' (validate()'s default, children append '/key'), so it
|
|
83
|
+
// is never empty; pinned by "input failing at the schema root is located at #" in projection.unit.test.ts.
|
|
84
|
+
const where = [...new Set(result.errors.map(unit => `${unit.instanceLocation} (${unit.keyword})`))].slice(0, 3).join(', ');
|
|
85
|
+
throw new ToolInputError({ message: `Input for '${tool.toolId}' does not match its schema at ${where}. Fix the input and retry.` });
|
|
86
|
+
}
|
|
87
|
+
/** True when both generations hold the same modules and declarations: no revocation needed. @complexity O(t). */
|
|
88
|
+
function sameTools(previous, next, additional) {
|
|
89
|
+
if (!previous || previous.tools.length !== next.length || previous.additional.length !== additional.length
|
|
90
|
+
|| !previous.additional.every((tool, index) => tool === additional[index]))
|
|
91
|
+
return false;
|
|
92
|
+
return previous.tools.every((tool, index) => tool.loaded.module === next[index].loaded.module
|
|
93
|
+
&& JSON.stringify(tool.loaded.descriptor) === JSON.stringify(next[index].loaded.descriptor));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Checks a disclosure hook's answer. Its text reaches the confirmation prompt and the transcript,
|
|
97
|
+
* and module scope may still hold a token from an earlier call, so a list that mentions one is
|
|
98
|
+
* refused like a malformed one. @complexity O(r) resources plus the token scan.
|
|
99
|
+
*/
|
|
100
|
+
function checkedResources(toolId, value, scan) {
|
|
101
|
+
const valid = Array.isArray(value) && value.length <= MAX_RESOURCES
|
|
102
|
+
&& value.every(item => typeof item === 'string' && item.length > 0 && item.length <= MAX_RESOURCE_LENGTH)
|
|
103
|
+
&& !scan.mentionsToken({ value });
|
|
104
|
+
if (!valid)
|
|
105
|
+
throw new Error(`Plugin tool '${toolId}' returned an invalid affected-resources list; the call cannot be confirmed. Report it to the plugin author.`);
|
|
106
|
+
return Object.freeze([...value]);
|
|
107
|
+
}
|
|
108
|
+
/** Groups admitted tools and additional contributions in declaration order.
|
|
109
|
+
* Mutates only the local groups and appends admission failures to refusals. @complexity O(t) plus schema compilation. */
|
|
110
|
+
function groupProjectionTools({ loaded, additionalTools, refusals, toolIdFor }, _options = {}) {
|
|
111
|
+
const grouped = new Map();
|
|
112
|
+
for (const tool of admitAll(loaded, refusals, toolIdFor)) {
|
|
113
|
+
const group = grouped.get(tool.loaded.pluginId);
|
|
114
|
+
if (group)
|
|
115
|
+
group.push(tool);
|
|
116
|
+
else
|
|
117
|
+
grouped.set(tool.loaded.pluginId, [tool]);
|
|
118
|
+
}
|
|
119
|
+
const additional = new Map();
|
|
120
|
+
for (const entry of additionalTools ?? []) {
|
|
121
|
+
const group = additional.get(entry.pluginId);
|
|
122
|
+
if (group)
|
|
123
|
+
group.push(entry);
|
|
124
|
+
else
|
|
125
|
+
additional.set(entry.pluginId, [entry]);
|
|
126
|
+
if (!grouped.has(entry.pluginId))
|
|
127
|
+
grouped.set(entry.pluginId, []);
|
|
128
|
+
}
|
|
129
|
+
return { grouped, additional };
|
|
130
|
+
}
|
|
131
|
+
/** Counts all declarations, including refused tools, and appends ambiguous-id refusals.
|
|
132
|
+
* @complexity O(t * (r + 1)) time and O(t) space for t declarations and r prior refusals. */
|
|
133
|
+
function countProjectionClaims({ loaded, additionalTools, refusals, idFor }, _options = {}) {
|
|
134
|
+
// All claimants lose an ambiguous id, including collisions between executable and surface tools.
|
|
135
|
+
const counts = new Map();
|
|
136
|
+
const claimedIds = [...loaded.map(tool => idFor({ pluginId: tool.pluginId, name: tool.descriptor.name })),
|
|
137
|
+
...(additionalTools ?? []).map(entry => idFor({ pluginId: entry.pluginId, name: entry.tool.name }))];
|
|
138
|
+
for (const id of claimedIds)
|
|
139
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
140
|
+
for (const [id, count] of counts) {
|
|
141
|
+
if (count <= 1)
|
|
142
|
+
continue;
|
|
143
|
+
// MOVE: Admission already reports executable collisions with their owners; preserve that diagnostic once.
|
|
144
|
+
if (refusals.some(reason => reason.startsWith(`agent tool '${id}' was not loaded:`)))
|
|
145
|
+
continue;
|
|
146
|
+
refusals.push(`agent tool '${id}' was not loaded: more than one contribution declares it`);
|
|
147
|
+
}
|
|
148
|
+
return counts;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Creates the projection for one dedicated contribution registry (keyed by plugin id, so it must not
|
|
152
|
+
* be shared with site plugins whose ids could match). Call `sync` after every load: on boot and on
|
|
153
|
+
* every activation change. A plugin missing from a load is detached: its tools disappear and its
|
|
154
|
+
* calls' capabilities are revoked.
|
|
155
|
+
* @param required.registry - Registry the host attached with `attachPluginContributionTools`.
|
|
156
|
+
* @param required.toolIdFor - The contract's namespacing rule (`pluginToolIdFor`), so ids match the registry's.
|
|
157
|
+
* @param required.capabilities - Host port building one call's capabilities.
|
|
158
|
+
* @param required.issuedTokens - Per-plugin token memory shared with the plugin's admin-surface handlers.
|
|
159
|
+
* @complexity sync is O(t) tools plus schema compilation; disclosure lookup is O(1).
|
|
160
|
+
*/
|
|
161
|
+
export function createAgentPluginToolProjection(required, _optional = {}) {
|
|
162
|
+
const { registry } = required;
|
|
163
|
+
let projected = new Map();
|
|
164
|
+
let additionalById = new Map();
|
|
165
|
+
let byToolId = new Map();
|
|
166
|
+
/** One contract tool whose handler validates, scopes capabilities and gates the result. */
|
|
167
|
+
function contractTool(tool, generationOf) {
|
|
168
|
+
const { isLive, issued } = generationOf;
|
|
169
|
+
const { descriptor, module } = tool.loaded;
|
|
170
|
+
const contribution = {
|
|
171
|
+
name: descriptor.name, description: descriptor.description, inputSchema: descriptor.inputSchema, effect: descriptor.effect,
|
|
172
|
+
async handler({ pluginId, auth, input, signal }) {
|
|
173
|
+
// Defense in depth: the registry rechecks enablement, but a retained handler must not run either.
|
|
174
|
+
if (!isLive())
|
|
175
|
+
throw new Error(REVOKED_MESSAGE);
|
|
176
|
+
const checked = validatedInput(tool, input);
|
|
177
|
+
const host = required.capabilities({ pluginId, workspaceId: auth.workspaceId,
|
|
178
|
+
...(auth.principalId === undefined ? {} : { principalId: auth.principalId }), ...(signal === undefined ? {} : { signal }) });
|
|
179
|
+
const session = openCapabilitySession({ capabilities: host, isLive, issued });
|
|
180
|
+
try {
|
|
181
|
+
const value = await module.invoke({ input: checked, capabilities: session.capabilities, ...(signal === undefined ? {} : { signal }) });
|
|
182
|
+
return session.release({ value });
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
throw session.sanitize({ error });
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
return Object.freeze(contribution);
|
|
190
|
+
}
|
|
191
|
+
/** A fresh generation for one plugin; its tools are live only while the registry holds it. */
|
|
192
|
+
function generation(pluginId, tools, additional) {
|
|
193
|
+
let snapshot;
|
|
194
|
+
const isLive = () => snapshot !== undefined && registry.list({}).includes(snapshot);
|
|
195
|
+
const issued = required.issuedTokens.forPlugin({ pluginId });
|
|
196
|
+
snapshot = Object.freeze({ pluginId, sdk: INERT_SDK, routes: Object.freeze([]), widgets: Object.freeze([]),
|
|
197
|
+
tools: Object.freeze([...tools.map(tool => contractTool(tool, { isLive, issued })), ...additional.map(({ tool }) => Object.freeze({
|
|
198
|
+
...tool,
|
|
199
|
+
handler(input) {
|
|
200
|
+
if (!isLive())
|
|
201
|
+
throw new Error(REVOKED_MESSAGE);
|
|
202
|
+
return tool.handler(input);
|
|
203
|
+
},
|
|
204
|
+
}))]) });
|
|
205
|
+
return { snapshot, tools, additional };
|
|
206
|
+
}
|
|
207
|
+
/** Replaces one plugin's generation unless it is unchanged; a refused replacement detaches it. */
|
|
208
|
+
function place(pluginId, tools, additional, refusals) {
|
|
209
|
+
const previous = projected.get(pluginId);
|
|
210
|
+
if (sameTools(previous, tools, additional))
|
|
211
|
+
return previous;
|
|
212
|
+
const next = generation(pluginId, tools, additional);
|
|
213
|
+
try {
|
|
214
|
+
registry.replace({ contributions: next.snapshot });
|
|
215
|
+
return next;
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
registry.detach({ pluginId });
|
|
219
|
+
refusals.push(`agent tools from '${pluginId}' were not loaded: ${error instanceof Error ? error.message : String(error)}`);
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
/** Projects one load result. @returns The loader's refusals plus this seam's own, in order. */
|
|
225
|
+
sync(input, _options = {}) {
|
|
226
|
+
const refusals = [...input.refusals];
|
|
227
|
+
const { grouped, additional } = groupProjectionTools({
|
|
228
|
+
loaded: input.loaded, additionalTools: input.additionalTools, refusals, toolIdFor: required.toolIdFor,
|
|
229
|
+
});
|
|
230
|
+
const idFor = required.toolIdFor;
|
|
231
|
+
const counts = countProjectionClaims({ loaded: input.loaded, additionalTools: input.additionalTools, refusals, idFor });
|
|
232
|
+
const nextProjected = new Map();
|
|
233
|
+
for (const [pluginId, tools] of grouped) {
|
|
234
|
+
const unique = tools.filter(tool => counts.get(tool.toolId) === 1);
|
|
235
|
+
const extras = (additional.get(pluginId) ?? []).filter(entry => counts.get(idFor({ pluginId, name: entry.tool.name })) === 1);
|
|
236
|
+
const placed = place(pluginId, unique, extras, refusals);
|
|
237
|
+
if (placed)
|
|
238
|
+
nextProjected.set(pluginId, placed);
|
|
239
|
+
}
|
|
240
|
+
for (const pluginId of projected.keys())
|
|
241
|
+
if (!grouped.has(pluginId))
|
|
242
|
+
registry.detach({ pluginId });
|
|
243
|
+
projected = nextProjected;
|
|
244
|
+
additionalById = new Map([...nextProjected.values()].flatMap(plugin => plugin.additional.map(entry => [idFor({ pluginId: entry.pluginId, name: entry.tool.name }), { entry, snapshot: plugin.snapshot }])));
|
|
245
|
+
byToolId = new Map([...nextProjected.values()].flatMap(plugin => plugin.tools.map(tool => [tool.toolId, { tool, snapshot: plugin.snapshot }])));
|
|
246
|
+
return { refusals };
|
|
247
|
+
},
|
|
248
|
+
/** What a call would change, for the confirmation prompt; null for an unknown or withdrawn tool.
|
|
249
|
+
* @throws ToolInputError for input that fails the schema; Error for an invalid hook answer. */
|
|
250
|
+
async describeAffectedResources(input, _options = {}) {
|
|
251
|
+
const extra = additionalById.get(input.toolId);
|
|
252
|
+
if (extra && registry.list({}).includes(extra.snapshot)) {
|
|
253
|
+
const scan = openCredentialScan({ issued: required.issuedTokens.forPlugin({ pluginId: extra.entry.pluginId }) });
|
|
254
|
+
try {
|
|
255
|
+
const resources = await extra.entry.describeAffectedResources({ input: input.input });
|
|
256
|
+
return { effect: extra.entry.tool.effect ?? 'write', resources: checkedResources(input.toolId, resources, scan) };
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
throw scan.sanitize({ error });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const entry = byToolId.get(input.toolId);
|
|
263
|
+
if (!entry || !registry.list({}).includes(entry.snapshot))
|
|
264
|
+
return null;
|
|
265
|
+
const { tool } = entry;
|
|
266
|
+
const checked = validatedInput(tool, input.input);
|
|
267
|
+
const describe = tool.loaded.module.describeAffectedResources;
|
|
268
|
+
if (!describe)
|
|
269
|
+
return { effect: tool.loaded.descriptor.effect, resources: [] };
|
|
270
|
+
// The same per-plugin token memory the plugin's calls feed: its answers and errors are scanned alike.
|
|
271
|
+
const scan = openCredentialScan({ issued: required.issuedTokens.forPlugin({ pluginId: tool.loaded.pluginId }) });
|
|
272
|
+
let answer;
|
|
273
|
+
try {
|
|
274
|
+
answer = await describe({ input: checked });
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
throw scan.sanitize({ error });
|
|
278
|
+
}
|
|
279
|
+
return { effect: tool.loaded.descriptor.effect, resources: checkedResources(tool.toolId, answer, scan) };
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -8,6 +8,8 @@ export interface InstalledAgentPluginSkill {
|
|
|
8
8
|
export interface InstalledAgentPlugin {
|
|
9
9
|
readonly id?: string | undefined;
|
|
10
10
|
readonly provides?: readonly string[] | undefined;
|
|
11
|
+
readonly requires?: readonly string[] | undefined;
|
|
12
|
+
readonly hostRange?: string | undefined;
|
|
11
13
|
readonly pluginId: string;
|
|
12
14
|
readonly version?: (string) | undefined;
|
|
13
15
|
/** the host extension namespace in `plugin.json`: `displayName` — the human-facing title when the id alone reads
|
|
@@ -64,7 +64,9 @@ export interface StagedTree {
|
|
|
64
64
|
export declare function createUninstallModule(ports: AgentPluginLifecyclePorts): {
|
|
65
65
|
previewAgentPluginUninstall: (required: UninstallAgentPluginRequired) => Promise<AgentPluginUninstallPreview>;
|
|
66
66
|
uninstallAgentPlugin: (required: UninstallAgentPluginRequired, optional?: UninstallAgentPluginOptional) => Promise<UninstallAgentPluginResult>;
|
|
67
|
-
stageForRemoval: (packagesDir: string, packageRoot: string
|
|
67
|
+
stageForRemoval: (packagesDir: string, packageRoot: string, optional?: {
|
|
68
|
+
quarantined?: string;
|
|
69
|
+
}) => Promise<StagedTree>;
|
|
68
70
|
restoreStagedTrees: (staged: readonly StagedTree[], cause: unknown) => Promise<unknown>;
|
|
69
71
|
removeFrozenPackageTree: (root: string) => Promise<void>;
|
|
70
72
|
};
|