@jini-ai/plugins 0.5.0 → 0.5.2
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 +10 -0
- package/dist/glue/capability-gate.js +1 -1
- package/dist/host/browser-providers.d.ts +2 -9
- package/dist/host/browser-providers.js +34 -18
- package/dist/host/capability-sdk.js +1 -1
- package/dist/host/claim-conflicts.d.ts +4 -4
- package/dist/host/claim-conflicts.js +4 -4
- package/dist/host/contributions.d.ts +4 -1
- package/dist/host/contributions.js +19 -8
- package/dist/host/discovery-types.d.ts +2 -2
- package/dist/host/hook-registry.js +7 -5
- package/dist/host/index.d.ts +1 -0
- package/dist/host/index.js +1 -0
- package/dist/host/manifest-types.d.ts +103 -0
- package/dist/host/manifest-types.js +2 -0
- package/dist/host/manifest.d.ts +5 -97
- package/dist/host/manifest.js +33 -24
- package/dist/host/node/discovery.js +27 -22
- package/dist/host/node/install.js +257 -192
- package/dist/host/node/loader.js +85 -67
- package/dist/host/node/module-snapshot.js +3 -2
- package/dist/host/node/open-flags.d.ts +18 -0
- package/dist/host/node/open-flags.js +14 -0
- package/dist/host/node/package-files.js +18 -12
- package/dist/host/node/source-drafts.d.ts +2 -0
- package/dist/host/node/source-drafts.js +93 -59
- package/dist/host/plugin-claims.js +6 -4
- package/dist/host/plugin-format.d.ts +14 -0
- package/dist/host/plugin-format.js +21 -0
- package/dist/host/ports.d.ts +4 -4
- package/dist/host/tool-contributions.js +3 -1
- package/dist/host/worker/protocol.js +8 -6
- package/dist/host/worker/run-call.d.ts +1 -1
- package/dist/host/worker/run-call.js +20 -17
- package/package.json +5 -5
package/dist/host/ports.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Host contracts only. No product SDK, content-type implementation or executable importer lives here. */
|
|
2
|
-
import type { PluginManifest, PluginValidationError } from './manifest.js';
|
|
2
|
+
import type { PluginManifest, PluginValidationError } from './manifest-types.js';
|
|
3
3
|
import type { PluginDiscoveryRecord } from './discovery-types.js';
|
|
4
4
|
import type { ClaimMode } from './claim-conflicts.js';
|
|
5
5
|
/** Plain serializable entry envelope; hosts extend it with their own hook payload fields. */
|
|
@@ -110,8 +110,8 @@ export interface DeclarativeContentTypesPort {
|
|
|
110
110
|
}, optional?: Record<string, never>): Promise<unknown>;
|
|
111
111
|
}
|
|
112
112
|
export interface ManifestHostPorts<H extends HookPoints = HookPoints> {
|
|
113
|
-
/**
|
|
114
|
-
readonly identityNamespace
|
|
113
|
+
/** Host-owned namespace containing publisher id/provides in persisted manifest extensions. */
|
|
114
|
+
readonly identityNamespace: string;
|
|
115
115
|
readonly pluginSdkBinding: PluginSdkBinding<H>;
|
|
116
116
|
readonly capabilityVocabulary: readonly string[];
|
|
117
117
|
readonly declarativeContentTypes: DeclarativeContentTypesPort;
|
|
@@ -178,7 +178,7 @@ export interface PluginContributionPorts {
|
|
|
178
178
|
}) => Promise<string>;
|
|
179
179
|
readonly importModule: PluginModuleImportPort;
|
|
180
180
|
}
|
|
181
|
-
/** Structural host removal port, matching
|
|
181
|
+
/** Structural host removal port, matching the host's trash port without a CMS dependency edge. */
|
|
182
182
|
export type RemoveEntity = (required: {
|
|
183
183
|
workspaceId: string;
|
|
184
184
|
id: string;
|
|
@@ -11,7 +11,9 @@ export function buildPluginContributionToolRegistrations(required, _optional = {
|
|
|
11
11
|
return {
|
|
12
12
|
descriptor: {
|
|
13
13
|
id: pluginToolIdFor({ pluginId: snapshot.pluginId, name: tool.name }), description: tool.description,
|
|
14
|
-
|
|
14
|
+
// A self-declared effect may only add confirmation, never remove it: `read` stays not-read-only.
|
|
15
|
+
inputSchema: tool.inputSchema, readOnly: false,
|
|
16
|
+
requiresConfirmation: tool.effect === 'destructive' || required.metadata.approval?.confirmation !== 'direct',
|
|
15
17
|
timeoutMs: 30000, maxOutputBytes: 65536, metadata: required.metadata,
|
|
16
18
|
},
|
|
17
19
|
policy: { authorize: async (ctx) => {
|
|
@@ -2,6 +2,12 @@ const FAILURE_STAGES = new Set(["import", "export", "setup", "hook"]);
|
|
|
2
2
|
function invalidReply() {
|
|
3
3
|
return new Error("invalid tier-2 worker reply");
|
|
4
4
|
}
|
|
5
|
+
function decodeFailureReply({ reply }, _optional = {}) {
|
|
6
|
+
if (typeof reply.stage !== "string" || !FAILURE_STAGES.has(reply.stage) || typeof reply.error !== "string") {
|
|
7
|
+
throw invalidReply();
|
|
8
|
+
}
|
|
9
|
+
return { ok: false, stage: reply.stage, error: reply.error };
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
12
|
* Validates an untrusted worker message as the reply to a request of `expectedKind`. The worker
|
|
7
13
|
* runs plugin code, so its message is checked like any other external input.
|
|
@@ -13,12 +19,8 @@ export function decodeTier2Reply({ message, expectedKind }, _optional = {}) {
|
|
|
13
19
|
if (typeof message !== "object" || message === null)
|
|
14
20
|
throw invalidReply();
|
|
15
21
|
const reply = message;
|
|
16
|
-
if (reply.ok === false)
|
|
17
|
-
|
|
18
|
-
throw invalidReply();
|
|
19
|
-
}
|
|
20
|
-
return { ok: false, stage: reply.stage, error: reply.error };
|
|
21
|
-
}
|
|
22
|
+
if (reply.ok === false)
|
|
23
|
+
return decodeFailureReply({ reply });
|
|
22
24
|
if (reply.ok !== true || reply.kind !== expectedKind)
|
|
23
25
|
throw invalidReply();
|
|
24
26
|
if (expectedKind === "beforeSave")
|
|
@@ -4,7 +4,7 @@ import type { Tier2Reply, Tier2Request } from "./protocol.js";
|
|
|
4
4
|
export interface RunTier2CallRequired {
|
|
5
5
|
readonly request: Tier2Request;
|
|
6
6
|
/** Imports the plugin entry. The worker entry supplies real `import()` after registering the
|
|
7
|
-
* `@
|
|
7
|
+
* `@jini-ai/plugin-sdk` resolver; tests supply a fake. */
|
|
8
8
|
readonly importModule: PluginModuleImportPort;
|
|
9
9
|
readonly pluginSdkBinding: PluginSdkBinding;
|
|
10
10
|
readonly createInvocationCoreDeps: (required: {
|
|
@@ -18,6 +18,25 @@ import { buildCapabilityScopedSdk } from "../capability-sdk.js";
|
|
|
18
18
|
function failed(stage, error) {
|
|
19
19
|
return { ok: false, stage, error: error instanceof Error ? error.message : String(error) };
|
|
20
20
|
}
|
|
21
|
+
async function runBeforeSave({ pluginId, request, filter }, _optional = {}) {
|
|
22
|
+
if (!filter)
|
|
23
|
+
return failed("hook", `plugin '${pluginId}' attached no beforeSave filter`);
|
|
24
|
+
let patch;
|
|
25
|
+
try {
|
|
26
|
+
patch = await filter(request.entry, request.ctx);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return failed("hook", error);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
// postMessage would otherwise throw a DataCloneError outside any reply, which the server can
|
|
33
|
+
// only see as a crashed worker; checking here keeps it a plugin-attributed hook failure.
|
|
34
|
+
return { ok: true, kind: "beforeSave", patch: structuredClone(patch) };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return failed("hook", `plugin '${pluginId}' returned a value that cannot cross the worker boundary: ${error.message}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
21
40
|
/**
|
|
22
41
|
* Runs one Tier-2 request against the plugin's code in the current thread.
|
|
23
42
|
*
|
|
@@ -55,22 +74,6 @@ export async function runTier2Call(required, _optional = {}) {
|
|
|
55
74
|
if (request.kind === "probe") {
|
|
56
75
|
return { ok: true, kind: "probe", hooks: filter ? [HOOK_CONTENT_ENTRY_BEFORE_SAVE] : [] };
|
|
57
76
|
}
|
|
58
|
-
|
|
59
|
-
return failed("hook", `plugin '${pluginId}' attached no beforeSave filter`);
|
|
60
|
-
let patch;
|
|
61
|
-
try {
|
|
62
|
-
patch = await filter(request.entry, request.ctx);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
return failed("hook", error);
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
// postMessage would otherwise throw a DataCloneError outside any reply, which the server can
|
|
69
|
-
// only see as a crashed worker; checking here keeps it a plugin-attributed hook failure.
|
|
70
|
-
return { ok: true, kind: "beforeSave", patch: structuredClone(patch) };
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
return failed("hook", `plugin '${pluginId}' returned a value that cannot cross the worker boundary: ${error.message}`);
|
|
74
|
-
}
|
|
77
|
+
return runBeforeSave({ pluginId, request, filter });
|
|
75
78
|
}
|
|
76
79
|
//# sourceMappingURL=run-call.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/plugins",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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,7 +72,7 @@
|
|
|
72
72
|
"registry": "https://registry.npmjs.org"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@jini-ai/core": "^0.4.
|
|
75
|
+
"@jini-ai/core": "^0.4.9"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@jini-ai/platform": "^0.5.3",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
"semver": "^7.6.2",
|
|
99
99
|
"@types/semver": "^7.5.8",
|
|
100
100
|
"kysely": "^0.29.6",
|
|
101
|
-
"@jini-ai/core": "^0.4.
|
|
102
|
-
"@jini-ai/platform": "^0.5.
|
|
103
|
-
"@jini-ai/db": "0.3.
|
|
101
|
+
"@jini-ai/core": "^0.4.9",
|
|
102
|
+
"@jini-ai/platform": "^0.5.10",
|
|
103
|
+
"@jini-ai/db": "0.3.6"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
106
106
|
"build": "tsc -p tsconfig.json",
|