@jini-ai/plugins 0.4.0 → 0.4.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/CHANGELOG.md +2 -0
- package/dist/glue/attachment-points/content-lifecycle.d.ts +47 -5
- package/dist/glue/attachment-points/content-lifecycle.js +10 -0
- package/dist/glue/capability-gate.d.ts +54 -1
- package/dist/glue/capability-gate.js +19 -1
- package/dist/host/capability-sdk.d.ts +2 -2
- package/dist/host/capability-sdk.js +45 -9
- package/dist/host/contributions.d.ts +129 -0
- package/dist/host/contributions.js +167 -0
- package/dist/host/discovery-types.d.ts +6 -3
- package/dist/host/index.d.ts +3 -0
- package/dist/host/index.js +3 -0
- package/dist/host/manifest.d.ts +10 -0
- package/dist/host/manifest.js +12 -2
- package/dist/host/node/discovery.d.ts +9 -2
- package/dist/host/node/discovery.js +30 -6
- package/dist/host/node/index.d.ts +1 -0
- package/dist/host/node/index.js +1 -0
- package/dist/host/node/install.d.ts +49 -4
- package/dist/host/node/install.js +207 -77
- package/dist/host/node/source-drafts.d.ts +98 -0
- package/dist/host/node/source-drafts.js +323 -0
- package/dist/host/plugin-claims.d.ts +0 -38
- package/dist/host/plugin-claims.js +50 -2
- package/dist/host/ports.d.ts +13 -1
- package/dist/host/source-policy.d.ts +18 -0
- package/dist/host/source-policy.js +13 -0
- package/dist/host/tool-contributions.d.ts +26 -0
- package/dist/host/tool-contributions.js +42 -0
- package/package.json +10 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Projects executable plugins onto the host's existing ToolRegistry. Metadata/auth are host
|
|
2
|
+
* ports; no separate catalog, executor, permission vocabulary, or approval engine is created. */
|
|
3
|
+
import { createToolRegistrationScope, requireInputRecord, ToolInputError } from '@jini-ai/core';
|
|
4
|
+
import { pluginToolIdFor } from './contributions.js';
|
|
5
|
+
/** Generation + durable activation are checked before authorization and after confirmation.
|
|
6
|
+
* Arbitrary tier-3 handlers cannot establish read-only safety; the host supplies approval policy. */
|
|
7
|
+
export function buildPluginContributionToolRegistrations(required, _optional = {}) {
|
|
8
|
+
const { contributions } = required;
|
|
9
|
+
return contributions.list({}).flatMap(snapshot => snapshot.tools.map(tool => {
|
|
10
|
+
const active = async () => await required.isEnabled({ pluginId: snapshot.pluginId }) && contributions.list({}).includes(snapshot);
|
|
11
|
+
return {
|
|
12
|
+
descriptor: {
|
|
13
|
+
id: pluginToolIdFor({ pluginId: snapshot.pluginId, name: tool.name }), description: tool.description,
|
|
14
|
+
inputSchema: tool.inputSchema, readOnly: false, requiresConfirmation: required.metadata.approval?.confirmation !== 'direct',
|
|
15
|
+
timeoutMs: 30000, maxOutputBytes: 65536, metadata: required.metadata,
|
|
16
|
+
},
|
|
17
|
+
policy: { authorize: async (ctx) => {
|
|
18
|
+
if (!await active())
|
|
19
|
+
return 'deny';
|
|
20
|
+
const auth = await required.resolveAuth({ pluginId: snapshot.pluginId, principalId: ctx.principal.id });
|
|
21
|
+
return auth && await active() ? 'allow' : 'deny';
|
|
22
|
+
} },
|
|
23
|
+
handler: async (ctx) => {
|
|
24
|
+
const auth = await required.resolveAuth({ pluginId: snapshot.pluginId, principalId: ctx.principal.id });
|
|
25
|
+
if (!auth || !await active())
|
|
26
|
+
throw new ToolInputError({ message: 'Plugin tool is disabled or was reloaded.' });
|
|
27
|
+
const input = requireInputRecord({ input: ctx.input });
|
|
28
|
+
return tool.handler({ pluginId: snapshot.pluginId, sdk: snapshot.sdk, auth, input, signal: ctx.signal }, {});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/** Host lifecycle attaches one revocable scope to its existing registry. Disposal removes only
|
|
34
|
+
* this scope's tools and subscription. A failed replacement leaves the previous generation. */
|
|
35
|
+
export function attachPluginContributionTools(required, _optional = {}) {
|
|
36
|
+
const scope = createToolRegistrationScope({ registry: required.registry });
|
|
37
|
+
const refresh = () => scope.replace({ registrations: buildPluginContributionToolRegistrations(required) });
|
|
38
|
+
refresh();
|
|
39
|
+
const unsubscribe = required.contributions.subscribe({ onChanged: refresh });
|
|
40
|
+
return { dispose(_required, _optional = {}) { unsubscribe(); scope.replace({ registrations: [] }); } };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=tool-contributions.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/plugins",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Host-independent extension glue and site-plugin runtime with injected SDK, trust, archive and storage ports.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -72,14 +72,18 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@jini-ai/core": "^0.4.
|
|
75
|
+
"@jini-ai/core": "^0.4.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
+
"@jini-ai/platform": "^0.5.3",
|
|
78
79
|
"semver": "^7.6.2",
|
|
79
80
|
"kysely": "^0.29.6",
|
|
80
|
-
"@jini-ai/db": "^0.3.
|
|
81
|
+
"@jini-ai/db": "^0.3.2"
|
|
81
82
|
},
|
|
82
83
|
"peerDependenciesMeta": {
|
|
84
|
+
"@jini-ai/platform": {
|
|
85
|
+
"optional": true
|
|
86
|
+
},
|
|
83
87
|
"semver": {
|
|
84
88
|
"optional": true
|
|
85
89
|
},
|
|
@@ -94,8 +98,9 @@
|
|
|
94
98
|
"semver": "^7.6.2",
|
|
95
99
|
"@types/semver": "^7.5.8",
|
|
96
100
|
"kysely": "^0.29.6",
|
|
97
|
-
"@jini-ai/
|
|
98
|
-
"@jini-ai/
|
|
101
|
+
"@jini-ai/core": "^0.4.3",
|
|
102
|
+
"@jini-ai/platform": "^0.5.3",
|
|
103
|
+
"@jini-ai/db": "0.3.2"
|
|
99
104
|
},
|
|
100
105
|
"scripts": {
|
|
101
106
|
"build": "tsc -p tsconfig.json",
|