@jini-ai/plugins 0.7.1 → 0.7.3-next.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 +1 -1
- package/dist/core/manifest-keys.d.ts +8 -0
- package/dist/core/manifest-keys.js +16 -0
- package/dist/glue/attachment-points/content-lifecycle.d.ts +6 -7
- package/dist/glue/attachment-points/content-lifecycle.js +1 -1
- package/dist/glue/capability-gate.d.ts +2 -2
- package/dist/glue/manifest.js +2 -12
- package/dist/host/activation.d.ts +4 -5
- package/dist/host/admin-response.d.ts +2 -3
- package/dist/host/attach-loaded-plugin.d.ts +4 -4
- package/dist/host/attach-loaded-plugin.js +2 -2
- package/dist/host/browser-providers.d.ts +1 -1
- package/dist/host/capability-sdk.d.ts +8 -7
- package/dist/host/capability-sdk.js +39 -31
- package/dist/host/capability-tools.d.ts +3 -3
- package/dist/host/capability-tools.js +249 -237
- package/dist/host/contributions.d.ts +7 -66
- package/dist/host/contributions.js +64 -51
- package/dist/host/declarative-content-types.d.ts +6 -6
- package/dist/host/declarative-content-types.js +141 -135
- package/dist/host/declarative-enable.js +1 -1
- package/dist/host/discovery-types.d.ts +3 -3
- package/dist/host/hook-registry.d.ts +9 -9
- package/dist/host/hook-registry.js +86 -76
- package/dist/host/index.d.ts +1 -2
- package/dist/host/index.js +1 -1
- package/dist/host/manifest-types.d.ts +6 -59
- package/dist/host/manifest.d.ts +6 -5
- package/dist/host/manifest.js +3 -39
- package/dist/host/node/discovery.d.ts +1 -1
- package/dist/host/node/discovery.js +4 -5
- package/dist/host/node/index.d.ts +3 -0
- package/dist/host/node/index.js +2 -0
- package/dist/host/node/install.js +2 -2
- package/dist/host/node/integrity-command.d.ts +8 -0
- package/dist/host/node/integrity-command.js +26 -0
- package/dist/host/node/invocation-binding.d.ts +1 -1
- package/dist/host/node/invocation-binding.js +1 -1
- package/dist/host/node/loader.d.ts +3 -2
- package/dist/host/node/loader.js +12 -12
- package/dist/host/node/module-snapshot.d.ts +20 -0
- package/dist/host/node/module-snapshot.js +31 -0
- package/dist/host/node/open-flags.d.ts +4 -1
- package/dist/host/node/open-flags.js +1 -1
- package/dist/host/node/package-files.js +1 -1
- package/dist/host/node/provider-artifact.d.ts +1 -2
- package/dist/host/node/runtime-contracts.d.ts +237 -0
- package/dist/host/node/runtime-contracts.js +2 -0
- package/dist/host/node/runtime-core.d.ts +1 -243
- package/dist/host/node/runtime-core.js +18 -114
- package/dist/host/node/runtime-load-target.d.ts +44 -0
- package/dist/host/node/runtime-load-target.js +45 -0
- package/dist/host/node/runtime-package-location.d.ts +45 -0
- package/dist/host/node/runtime-package-location.js +57 -0
- package/dist/host/node/source-drafts.d.ts +4 -2
- package/dist/host/node/source-drafts.js +107 -39
- package/dist/host/ports.d.ts +1 -38
- package/dist/host/provider-contributions.d.ts +2 -14
- package/dist/host/provider-contributions.js +1 -1
- package/dist/host/provider-host.d.ts +4 -19
- package/dist/host/provider-host.js +83 -71
- package/dist/host/provider-revision-watch.d.ts +36 -0
- package/dist/host/provider-revision-watch.js +52 -0
- package/dist/host/provider-setting-required.d.ts +1 -7
- package/dist/host/provider-setting-required.js +1 -18
- package/dist/host/provider-settings-migrations.d.ts +1 -1
- package/dist/host/repo.memory.d.ts +1 -1
- package/dist/host/repo.memory.js +1 -1
- package/dist/host/sql/repo.d.ts +4 -3
- package/dist/host/sql/repo.rows.js +2 -2
- package/dist/host/tool-contributions.d.ts +2 -1
- package/dist/host/tool-contributions.js +1 -0
- package/dist/host/tools/install.js +1 -0
- package/dist/host/tools/management.js +97 -83
- package/dist/host/uninstall.d.ts +1 -1
- package/dist/host/worker/import-seam.d.ts +2 -2
- package/dist/host/worker/protocol.d.ts +2 -2
- package/dist/host/worker/run-call.d.ts +2 -1
- package/dist/host/worker/run-call.js +2 -2
- package/dist/host/worker/start.js +1 -1
- package/package.json +7 -17
package/dist/host/node/loader.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/** SDK version, hashing and executable import are required host ports. The importer must retain
|
|
2
2
|
* the fresh snapshot and containment guarantees described below. */
|
|
3
3
|
/**
|
|
4
|
-
* @file `loadPlugin()` —
|
|
5
|
-
* The signature and JSDoc are design-frozen under implementation outline
|
|
6
|
-
* Host-supplied SDK versions respect
|
|
4
|
+
* @file `loadPlugin()` — the ordered load pipeline.
|
|
5
|
+
* The signature and JSDoc are design-frozen under the implementation outline.
|
|
6
|
+
* Host-supplied SDK versions respect the public-export boundary; do not deep-import the
|
|
7
7
|
* SDK's package.json to discover a version.
|
|
8
8
|
* Verify packaged-file integrity, check the host SDK version against manifest.sdkRange, then
|
|
9
9
|
* import executable code, validate its export and run setup with a capability-scoped SDK.
|
|
10
10
|
* Hook attachment is composition-owned: see the successful return path and attachLoadedPlugin.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* Binding, ESCALATE_SECURITY: integrity and SDK compatibility MUST both pass before
|
|
13
13
|
* any plugin code is evaluated, even at module-evaluation time. Deviating from that ordering
|
|
14
14
|
* requires a recorded [CIC_DEVIATION_APPROVED] entry under
|
|
15
|
-
* reports/pipeline/005-plugin-system/critical-internal-constraints.md
|
|
15
|
+
* reports/pipeline/005-plugin-system/critical-internal-constraints.md.
|
|
16
16
|
*
|
|
17
17
|
* Injectable import and digest ports let checks observe that rejected code was never imported,
|
|
18
18
|
* without depending on real module resolution (CIC Verification Surface Rule).
|
|
@@ -23,11 +23,11 @@ import path from "node:path";
|
|
|
23
23
|
import { admitBrowserProviderAssets } from "./browser-provider-assets.js";
|
|
24
24
|
import { isPluginRelativePath } from "../browser-providers.js";
|
|
25
25
|
import * as semver from "semver";
|
|
26
|
-
import { PLUGIN_PROVIDER_CAPABILITY } from '
|
|
26
|
+
import { PLUGIN_PROVIDER_CAPABILITY } from '@jini-ai/core/contracts/plugin-sdk';
|
|
27
27
|
import { createPluginContributionCapture } from '../contributions.js';
|
|
28
28
|
import { buildCapabilityScopedSdk } from "../capability-sdk.js";
|
|
29
29
|
export { attachLoadedPlugin } from "../attach-loaded-plugin.js";
|
|
30
|
-
/** A packaged artifact's file layout is fixed
|
|
30
|
+
/** A packaged artifact's file layout is fixed: `jini.plugin.json` + `server/index.mjs` at
|
|
31
31
|
* the plugin root. `entryPath` is always `<pluginRoot>/server/index.mjs`, so the root two
|
|
32
32
|
* directories up from it is where `manifest.integrity`'s relative file paths resolve from. */
|
|
33
33
|
function derivePluginRoot(entryPath) {
|
|
@@ -97,7 +97,7 @@ function isExecutionAdmitted(required) {
|
|
|
97
97
|
async function importPluginModule(required, _optional = {}) {
|
|
98
98
|
try {
|
|
99
99
|
// Same-version replacement must evaluate the reviewed package again. Build this URL only at
|
|
100
|
-
// step (3), after integrity and SDK compatibility have passed (
|
|
100
|
+
// step (3), after integrity and SDK compatibility have passed (order unchanged).
|
|
101
101
|
// Injected import seams keep their original path contract. A fresh filesystem graph refreshes
|
|
102
102
|
// ALL packaged helpers (including nested/dynamic imports and CommonJS require caches).
|
|
103
103
|
const imported = await required.importModule({ plugin: { pluginId: required.record.id, packageRoot: required.pluginRoot }, modulePath: required.entryPath });
|
|
@@ -155,15 +155,15 @@ function publishProviderCapture(required) {
|
|
|
155
155
|
}
|
|
156
156
|
return undefined;
|
|
157
157
|
}
|
|
158
|
-
/** Integrity and SDK compatibility remain ordered before any executable importer
|
|
158
|
+
/** Integrity and SDK compatibility remain ordered before any executable importer. */
|
|
159
159
|
async function admitPluginPackage(required) {
|
|
160
160
|
const { record, manifest, entryPath } = required;
|
|
161
161
|
const pluginRoot = derivePluginRoot(entryPath);
|
|
162
162
|
const computeFileHash = (absoluteFilePath) => required.verifyDigest({ absoluteFilePath });
|
|
163
|
-
// ---
|
|
163
|
+
// --- Step (1), integrity, MUST complete successfully before step (2)/(3). ---
|
|
164
164
|
if (!await verifyIntegrity({ record, manifest, pluginRoot, entryPath, computeFileHash }))
|
|
165
165
|
return { failure: 'INTEGRITY_FAILED' };
|
|
166
|
-
// ---
|
|
166
|
+
// --- Step (2), sdkRange, MUST complete successfully before step (3). ---
|
|
167
167
|
if (!semver.satisfies(required.pluginSdkBinding.runtimeSdkVersion, manifest.sdkRange))
|
|
168
168
|
return { failure: 'SDK_RANGE_UNSATISFIED' };
|
|
169
169
|
const admission = await admitDeclaredBrowserProviders({ record, manifest, pluginRoot, approvals: required.browserProviderApprovals });
|
|
@@ -180,7 +180,7 @@ function isProviderSelected(required) {
|
|
|
180
180
|
return required.providerContributions?.isSelected({ pluginId: required.record.id }, {}) === true;
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
|
-
* Executes
|
|
183
|
+
* Executes the 5-step ordered pipeline for one plugin. See above for the binding
|
|
184
184
|
* ordering constraint this function's statement order must never invert.
|
|
185
185
|
*
|
|
186
186
|
* @throws Never for an expected pipeline failure (those are reported via the returned `reason`);
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as nativeFs from "node:fs/promises";
|
|
6
6
|
import type { PluginManifest } from "../manifest.js";
|
|
7
|
+
import type { PluginModuleImportPort } from "../ports.js";
|
|
7
8
|
export declare class PluginSnapshotIntegrityError extends Error {
|
|
8
9
|
}
|
|
9
10
|
/** Lifecycle failures have a stable category without exposing package paths or file contents. */
|
|
@@ -91,5 +92,24 @@ export declare function verifyPluginSnapshotIntegrity(required: {
|
|
|
91
92
|
files: ReadonlyMap<string, Uint8Array>;
|
|
92
93
|
integrity: Readonly<Record<string, string>>;
|
|
93
94
|
}, _options?: Record<string, never>): void;
|
|
95
|
+
/** Adapts the product's module seam to Jini's registry. A built-in/test seam retains its original path;
|
|
96
|
+
* a site entry is contained and snapshotted only after Jini verifies integrity and SDK range.
|
|
97
|
+
* Same-version replacement needs a fresh filesystem identity for ALL helpers, including late
|
|
98
|
+
* dynamic imports and CommonJS require caches. Snapshots remain available until shutdown.
|
|
99
|
+
* @param required The validated manifest and source selected for this load.
|
|
100
|
+
* @param optional.importModule The existing built-in/worker/test import seam, when present.
|
|
101
|
+
* @param optional.snapshots The runtime's snapshot owner, disposed after plugin users stop.
|
|
102
|
+
* @returns A registry importer projecting the default export without changing export validation.
|
|
103
|
+
* @throws Snapshot/filesystem/import errors; Jini maps them to the existing load reasons.
|
|
104
|
+
* @complexity O(total package bytes) for a site snapshot; O(1) for an injected seam.
|
|
105
|
+
* @example createPluginModuleImporter({ manifest, source: "site" }, {})
|
|
106
|
+
*/
|
|
107
|
+
export declare function createPluginModuleImporter(required: {
|
|
108
|
+
manifest: PluginManifest;
|
|
109
|
+
source: "built-in" | "site";
|
|
110
|
+
}, optional?: {
|
|
111
|
+
importModule?: (entryPath: string) => Promise<unknown>;
|
|
112
|
+
snapshots?: PluginModuleSnapshotLifecycle;
|
|
113
|
+
}): PluginModuleImportPort;
|
|
94
114
|
export {};
|
|
95
115
|
//# sourceMappingURL=module-snapshot.d.ts.map
|
|
@@ -6,6 +6,7 @@ import * as nativeFs from "node:fs/promises";
|
|
|
6
6
|
import { hostname } from "node:os";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import path from "node:path";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
9
10
|
import { snapshotSitePluginPackage } from "./install.js";
|
|
10
11
|
import { PLUGIN_MANIFEST_FILENAMES } from "../plugin-format.js";
|
|
11
12
|
import { isPluginRelativePath } from "../browser-providers.js";
|
|
@@ -228,4 +229,34 @@ export function verifyPluginSnapshotIntegrity(required, _options = {}) {
|
|
|
228
229
|
throw new PluginSnapshotIntegrityError("Package file disappeared before loading.");
|
|
229
230
|
}
|
|
230
231
|
}
|
|
232
|
+
/** Adapts the product's module seam to Jini's registry. A built-in/test seam retains its original path;
|
|
233
|
+
* a site entry is contained and snapshotted only after Jini verifies integrity and SDK range.
|
|
234
|
+
* Same-version replacement needs a fresh filesystem identity for ALL helpers, including late
|
|
235
|
+
* dynamic imports and CommonJS require caches. Snapshots remain available until shutdown.
|
|
236
|
+
* @param required The validated manifest and source selected for this load.
|
|
237
|
+
* @param optional.importModule The existing built-in/worker/test import seam, when present.
|
|
238
|
+
* @param optional.snapshots The runtime's snapshot owner, disposed after plugin users stop.
|
|
239
|
+
* @returns A registry importer projecting the default export without changing export validation.
|
|
240
|
+
* @throws Snapshot/filesystem/import errors; Jini maps them to the existing load reasons.
|
|
241
|
+
* @complexity O(total package bytes) for a site snapshot; O(1) for an injected seam.
|
|
242
|
+
* @example createPluginModuleImporter({ manifest, source: "site" }, {})
|
|
243
|
+
*/
|
|
244
|
+
export function createPluginModuleImporter(required, optional = {}) {
|
|
245
|
+
return async ({ plugin, modulePath }) => {
|
|
246
|
+
if (optional.importModule) {
|
|
247
|
+
const imported = await optional.importModule(modulePath);
|
|
248
|
+
return { exported: typeof imported === "object" && imported !== null ? imported.default : undefined };
|
|
249
|
+
}
|
|
250
|
+
let entryPath = modulePath;
|
|
251
|
+
if (required.source === "site") {
|
|
252
|
+
const [root, entry] = await Promise.all([nativeFs.realpath(plugin.packageRoot), nativeFs.realpath(modulePath)]);
|
|
253
|
+
// The immutable snapshot owner rejects symlinks/hardlinks and checks every retained byte.
|
|
254
|
+
if (!entry.startsWith(root + path.sep))
|
|
255
|
+
return `module path '${modulePath}' escapes the plugin root`;
|
|
256
|
+
entryPath = await snapshotPluginModuleGraph({ pluginRoot: plugin.packageRoot, manifest: required.manifest }, optional.snapshots ? { lifecycle: optional.snapshots } : {});
|
|
257
|
+
}
|
|
258
|
+
const imported = await import(pathToFileURL(entryPath).href);
|
|
259
|
+
return { exported: imported.default };
|
|
260
|
+
};
|
|
261
|
+
}
|
|
231
262
|
//# sourceMappingURL=module-snapshot.js.map
|
|
@@ -17,5 +17,8 @@ export declare function readNoFollowFlags({ constants }: {
|
|
|
17
17
|
constants: OpenFlagConstants;
|
|
18
18
|
}, _optional?: Record<string, never>): number;
|
|
19
19
|
/** Reads up to `maxBytes` from the start of the file. */
|
|
20
|
-
export declare function readAtMost(handle
|
|
20
|
+
export declare function readAtMost({ handle, maxBytes }: {
|
|
21
|
+
handle: FileHandle;
|
|
22
|
+
maxBytes: number;
|
|
23
|
+
}, _optional?: Record<string, never>): Promise<Buffer>;
|
|
21
24
|
//# sourceMappingURL=open-flags.d.ts.map
|
|
@@ -7,7 +7,7 @@ export function readNoFollowFlags({ constants }, _optional = {}) {
|
|
|
7
7
|
return constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0);
|
|
8
8
|
}
|
|
9
9
|
/** Reads up to `maxBytes` from the start of the file. */
|
|
10
|
-
export async function readAtMost(handle, maxBytes) {
|
|
10
|
+
export async function readAtMost({ handle, maxBytes }, _optional = {}) {
|
|
11
11
|
const buffer = Buffer.alloc(maxBytes);
|
|
12
12
|
let offset = 0;
|
|
13
13
|
while (offset < maxBytes) {
|
|
@@ -136,7 +136,7 @@ async function readFileEntry({ absolutePath, relativePath, state }, _optional =
|
|
|
136
136
|
state.truncated = true;
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
-
const bytes = await readAtMost(opened, maxFileBytes + 1);
|
|
139
|
+
const bytes = await readAtMost({ handle: opened, maxBytes: maxFileBytes + 1 });
|
|
140
140
|
if (bytes.length > maxFileBytes) {
|
|
141
141
|
state.files.push(omittedFile(relativePath, bytes.length, "too-large"));
|
|
142
142
|
return;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type PluginProviderContract } from '../provider-host.js';
|
|
2
|
-
import type { PluginProviderResource } from '
|
|
3
|
-
import type { HookPoints } from '../ports.js';
|
|
2
|
+
import type { PluginProviderResource, HookPoints } from '@jini-ai/core/contracts/plugin-sdk';
|
|
4
3
|
import { type LoadPluginRequired } from './loader.js';
|
|
5
4
|
/**
|
|
6
5
|
* Load one already-discovered provider artifact and initialize its selected contract.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { PluginLookupPort } from "@jini-ai/core/plugin-directory";
|
|
2
|
+
import type { Clock as ClockPort } from "@jini-ai/core/primitives";
|
|
3
|
+
import type { FileLockPort } from "@jini-ai/core/contracts/runtime";
|
|
4
|
+
import type { PluginActivationRepoPort } from "../activation.js";
|
|
5
|
+
import type { PluginContributionRegistry } from "../contributions.js";
|
|
6
|
+
import type { AdmittedBrowserProvider } from "../browser-providers.js";
|
|
7
|
+
import type { ArchiveReaderPort, BundledBrowserProviderApproval, DeclarativeContentTypesPort, DeclaredContentTypePorts, PluginModuleImportPort, PluginSdkBinding, PluginTierPolicy, VerifyDigestPort } from "../ports.js";
|
|
8
|
+
import type { PluginSourcePolicyPort } from "../source-policy.js";
|
|
9
|
+
import type { BuiltInPluginSource, PluginDiscoveryRecord } from "../discovery-types.js";
|
|
10
|
+
import type { HookRegistry } from "../hook-registry.js";
|
|
11
|
+
import type { PluginManifest } from "../manifest-types.js";
|
|
12
|
+
import type { ExtensionClaim } from "../claim-conflicts.js";
|
|
13
|
+
import type { PluginConflict } from "../plugin-claims.js";
|
|
14
|
+
import type { PluginInstallerPort } from "./install.js";
|
|
15
|
+
import type { createPluginModuleSnapshotLifecycle } from "./module-snapshot.js";
|
|
16
|
+
import type { PluginSourcePort } from "./source-drafts.js";
|
|
17
|
+
import type { PluginPackageFiles } from "./package-files.js";
|
|
18
|
+
import type { Tier2CallRunner } from "../worker/protocol.js";
|
|
19
|
+
import type { RunTier2CallRequired } from "../worker/run-call.js";
|
|
20
|
+
/** Executable metadata for one compiled-in plugin. Discovery consumes only `manifest`; the enable
|
|
21
|
+
* callback consumes the import seam after integrity/sdkRange checks. Site-artifact sources can use
|
|
22
|
+
* the same shape once their install-dir resolver is composed here.
|
|
23
|
+
* @agent-note `importModule` is reached only through `loadPlugin()` after integrity and `sdkRange`
|
|
24
|
+
* passed; the host owns the entry path and importer. */
|
|
25
|
+
export interface PluginRuntimeSource extends BuiltInPluginSource {
|
|
26
|
+
readonly source: "built-in";
|
|
27
|
+
readonly entryPath: string;
|
|
28
|
+
readonly importModule: (entryPath: string) => Promise<unknown>;
|
|
29
|
+
/** The built-in's own source folder, shown read-only by the admin Plugins screen's
|
|
30
|
+
* package-files viewer (a host route). Omitted ⇒ that viewer lists no files. */
|
|
31
|
+
readonly sourceDir?: string;
|
|
32
|
+
}
|
|
33
|
+
/** What {@link createPluginRuntimeCore} returns: one runtime's shared handles.
|
|
34
|
+
* @agent-note Every member closes over the SAME repo, workspace, hook/contribution/provider registries
|
|
35
|
+
* and pending-attachment set; hosts adapt members (e.g. positional SDK types) without rebuilding them. */
|
|
36
|
+
export interface PluginRuntimeCoreBindings {
|
|
37
|
+
/** Call after provider teardown and stopped hook users; drains copies and releases owned graphs. */
|
|
38
|
+
readonly dispose: (required: Record<string, never>, optional?: Record<string, never>) => Promise<void>;
|
|
39
|
+
/** Successfully attached, admitted providers only; disable/quarantine retires their assets. */
|
|
40
|
+
readonly browserProviders: (input: Record<string, never>, options?: Record<string, never>) => {
|
|
41
|
+
generation: number;
|
|
42
|
+
providers: readonly AdmittedBrowserProvider[];
|
|
43
|
+
};
|
|
44
|
+
readonly pluginSource?: PluginSourcePort;
|
|
45
|
+
readonly pluginSourcePolicy: PluginSourcePolicyPort;
|
|
46
|
+
/** Actual loaded snapshot revision, used by the existing cross-process activation poll. */
|
|
47
|
+
readonly pluginLoadedVersion: (required: {
|
|
48
|
+
id: string;
|
|
49
|
+
}, optional?: Record<string, never>) => string | undefined;
|
|
50
|
+
readonly pluginInstaller?: PluginInstallerPort;
|
|
51
|
+
readonly hookRegistry: HookRegistry;
|
|
52
|
+
readonly pluginContributions: PluginContributionRegistry;
|
|
53
|
+
/** Provider factories of admitted provider plugins only (`createPluginProviderHost` reads this).
|
|
54
|
+
* Separate from `pluginContributions`, whose route/tool/widget snapshots carry no providers. */
|
|
55
|
+
readonly providerContributions: PluginContributionRegistry;
|
|
56
|
+
/**
|
|
57
|
+
* Boot-only: loads the given provider plugins when each is installed and enabled here, admitting
|
|
58
|
+
* their factories into `providerContributions`. Provider plugins are loaded nowhere else (boot
|
|
59
|
+
* re-attach and enable skip them), so a running provider is never replaced mid-process; enabling
|
|
60
|
+
* one takes effect at the next boot, disabling or quarantining one retires it immediately.
|
|
61
|
+
* @returns The ids actually loaded. Per-plugin failures are logged and skipped, never thrown.
|
|
62
|
+
*/
|
|
63
|
+
readonly loadProviderPlugins: (required: {
|
|
64
|
+
pluginIds: readonly string[];
|
|
65
|
+
}, optional?: {
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
}) => Promise<readonly string[]>;
|
|
68
|
+
/** Installed + enabled plugins here that declare providers, with their declarations (manifest only). */
|
|
69
|
+
readonly listProviderPlugins: (required: Record<string, never>, optional?: Record<string, never>) => Promise<readonly {
|
|
70
|
+
pluginId: string;
|
|
71
|
+
providers: NonNullable<NonNullable<PluginManifest["contributes"]>["providers"]>;
|
|
72
|
+
}[]>;
|
|
73
|
+
readonly discoverPlugins: () => Promise<readonly PluginDiscoveryRecord[]>;
|
|
74
|
+
/** Discovery with the enabled activations' version pins: the versions boot runs (a pin never falls forward). */
|
|
75
|
+
readonly discoverActivePlugins: () => Promise<readonly PluginDiscoveryRecord[]>;
|
|
76
|
+
readonly onPluginEnabled: (pluginId: string) => Promise<void>;
|
|
77
|
+
readonly onPluginDisabled: (pluginId: string) => void;
|
|
78
|
+
readonly locatePluginPackageDirs: (pluginId: string) => Promise<{
|
|
79
|
+
liveParent: string;
|
|
80
|
+
liveNames: readonly string[];
|
|
81
|
+
parkedDir: string;
|
|
82
|
+
}>;
|
|
83
|
+
/** Lists one discovered plugin's own files, read-only and bounded, for the admin Plugins
|
|
84
|
+
* screen's package-files viewer — see {@link resolvePackageLocation} and
|
|
85
|
+
* `Jini/packages/plugins/src/host/node/package-files.ts`. Rejects with `PluginPackagePathError` for an
|
|
86
|
+
* unsafe id/version or a directory that resolves outside its container. */
|
|
87
|
+
readonly readPluginPackageFiles: (record: PluginDiscoveryRecord) => Promise<PluginPackageFiles>;
|
|
88
|
+
/** @agent-note Positional adapter over the shared hook registry; the entry object is passed
|
|
89
|
+
* through untouched so every host payload field reaches each filter. */
|
|
90
|
+
readonly beforeSaveHook: (entry: Parameters<HookRegistry["runBeforeSave"]>[0]["entry"]) => ReturnType<HookRegistry["runBeforeSave"]>;
|
|
91
|
+
/** Admin preview (AW-7): one attached plugin's beforeSave patch for a draft, nothing saved or
|
|
92
|
+
* counted toward quarantine. `null` ⇒ not attached. See `HookRegistry.previewBeforeSave`.
|
|
93
|
+
* @agent-note Preview writes nothing and counts nothing toward quarantine. */
|
|
94
|
+
readonly previewPluginBeforeSave: (pluginId: string, entry: Parameters<HookRegistry["previewBeforeSave"]>[0]["entry"]) => ReturnType<HookRegistry["previewBeforeSave"]>;
|
|
95
|
+
/**
|
|
96
|
+
* P0a fix (2026-09-23): re-runs `onPluginEnabled` for every plugin `activationRepo` durably
|
|
97
|
+
* marks `enabled` for THIS composition's `workspaceId`. Before this existed, nothing replayed
|
|
98
|
+
* that durable state into a freshly-constructed (empty) `hookRegistry` — a plugin enabled in a
|
|
99
|
+
* prior process looked enabled in the admin UI and in `listAll()`, but its filter/action/
|
|
100
|
+
* contribution never fired again until an operator disabled and re-enabled it. Best-effort: one
|
|
101
|
+
* plugin failing to re-attach (e.g. its package was removed from disk) is logged and skipped, not
|
|
102
|
+
* thrown, so it can never block the rest of boot (mirrors `seedBundledAgentPlugins`'s own
|
|
103
|
+
* per-package isolation).
|
|
104
|
+
*/
|
|
105
|
+
readonly attachEnabledPluginsAtBoot: () => Promise<void>;
|
|
106
|
+
/** Every discovered plugin that has a name conflict right now — an enabled loser, or a plugin that
|
|
107
|
+
* is off and WOULD be refused if turned on — for the admin screen and the host's plugin-list tool. See
|
|
108
|
+
* `Jini/packages/plugins/src/host/plugin-claims.ts`'s `resolvePluginConflicts`. */
|
|
109
|
+
readonly listPluginConflicts: () => Promise<ReadonlyMap<string, readonly PluginConflict[]>>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The host bag spread into discovery, conflicts, enable, load, the Tier-2 seam, install and the
|
|
113
|
+
* source service. Extract-s6 L1b: a local port so the runtime core imports no host module.
|
|
114
|
+
* @agent-note Second-host rule: build ONE bag per runtime and keep it for the runtime's lifetime;
|
|
115
|
+
* every member is host-owned (capability vocabulary, declared content types, core owner name,
|
|
116
|
+
* identity namespace, install-disabled wording, tier policy, archive reader, digest format and the
|
|
117
|
+
* per-load invocation binding factory). The archive reader is always host-supplied (no fallback).
|
|
118
|
+
*/
|
|
119
|
+
export interface PluginRuntimeHostBinding {
|
|
120
|
+
readonly capabilityVocabulary: readonly string[];
|
|
121
|
+
readonly declarativeContentTypes: DeclarativeContentTypesPort;
|
|
122
|
+
readonly coreOwnerName: string;
|
|
123
|
+
readonly identityNamespace: string;
|
|
124
|
+
readonly localInstallDisabledMessage: string;
|
|
125
|
+
readonly tierPolicy: PluginTierPolicy;
|
|
126
|
+
readonly archiveReader: ArchiveReaderPort;
|
|
127
|
+
readonly verifyDigest: VerifyDigestPort;
|
|
128
|
+
readonly createInvocationCoreDeps: RunTier2CallRequired["createInvocationCoreDeps"];
|
|
129
|
+
/** Serializes plugin source edits with seal snapshots; Node hosts pass `nodeFileLock` of `@jini-ai/node-adapters/fs`. */
|
|
130
|
+
readonly fileLock: FileLockPort;
|
|
131
|
+
}
|
|
132
|
+
/** Only the tracker member the runtime calls. @agent-note The host supplies the event vocabulary
|
|
133
|
+
* through `quarantineTelemetry`; the runtime never names an event, user or property itself. */
|
|
134
|
+
export interface PluginRuntimeTracker<TEvent, TOptions> {
|
|
135
|
+
capture(event: TEvent, options: TOptions): unknown;
|
|
136
|
+
}
|
|
137
|
+
/** Install admission + plugin lookup. @agent-note `withInstallIdentity` must serialize admission
|
|
138
|
+
* of one candidate identity and run `run` at most once; it is read per install, never cached. */
|
|
139
|
+
export interface PluginRuntimeLookup extends PluginLookupPort {
|
|
140
|
+
/**
|
|
141
|
+
* Admits one site-runtime publisher identity, then publishes it by running `run`.
|
|
142
|
+
* @agent-note Second-host rule: the runtime only names the candidate; identity custody is the
|
|
143
|
+
* host's, and this port must perform the WHOLE sequence, in this order:
|
|
144
|
+
* 1. take ONE lock shared by every publisher of every plugin family the host runs, across all
|
|
145
|
+
* processes that can publish into the same install (a per-process or per-family mutex is not
|
|
146
|
+
* enough: two families could then both publish the same `publisher/local` identity);
|
|
147
|
+
* 2. under that lock, read a FRESH admission inventory of all families (never a cached list),
|
|
148
|
+
* including disabled installs, reserved/built-in identities and any other reservation;
|
|
149
|
+
* 3. assert the candidate identity is available against that inventory, refusing a clash with any
|
|
150
|
+
* other family or owner and allowing only a permitted upgrade of the same plugin's identity;
|
|
151
|
+
* 4. run `run` (which publishes the install) while STILL holding the same lock, at most once,
|
|
152
|
+
* and release the lock only after it settles. The site installer itself checks only its own
|
|
153
|
+
* install directory and built-ins; it cannot see another family's reservation.
|
|
154
|
+
*/
|
|
155
|
+
withInstallIdentity<T>(required: {
|
|
156
|
+
candidate: {
|
|
157
|
+
id: string;
|
|
158
|
+
localId: string;
|
|
159
|
+
family: "site-runtime";
|
|
160
|
+
};
|
|
161
|
+
run: () => Promise<T>;
|
|
162
|
+
}): Promise<T>;
|
|
163
|
+
}
|
|
164
|
+
/** Host wording the runtime surfaces. @agent-note Exact host bytes; names of host tools, manifest
|
|
165
|
+
* file names and route prefixes live here, never in the runtime. */
|
|
166
|
+
export interface PluginRuntimeText {
|
|
167
|
+
/** Source written to a new local plugin draft. */
|
|
168
|
+
readonly scaffoldEntry: string;
|
|
169
|
+
/** Reload refusal when a re-sealed version widens capabilities (`added` in manifest order). */
|
|
170
|
+
readonly reloadApprovalRequired: (required: {
|
|
171
|
+
added: readonly string[];
|
|
172
|
+
}) => string;
|
|
173
|
+
/** Quarantine reason when a source reload and the restored-version reload both failed. */
|
|
174
|
+
readonly restoreFailedReason: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Required inputs of the plugin-owned runtime core (extract-s6 L1b seam; moved here in L1c).
|
|
178
|
+
* @agent-note Second-host rule: `pluginSourcePolicy`, `tier2CallRunner` and `pluginSdkBinding` have
|
|
179
|
+
* NO defaults here — the host owns env/policy, the worker entry/runner/timeout, and the SDK (hook
|
|
180
|
+
* ids, version, `beforeSaveHook`). `activationRepo` and the hook registry built here are shared by
|
|
181
|
+
* save AND preview of this one runtime. The Tier-2 runner must register its SDK resolver before
|
|
182
|
+
* importing. `createModuleImporter` is two-stage; see its own note.
|
|
183
|
+
*/
|
|
184
|
+
export interface PluginRuntimeCoreRequired<TEvent = unknown, TOptions = unknown> {
|
|
185
|
+
readonly workspaceId: string;
|
|
186
|
+
readonly clock: ClockPort;
|
|
187
|
+
readonly activationRepo: PluginActivationRepoPort;
|
|
188
|
+
readonly sources: readonly PluginRuntimeSource[];
|
|
189
|
+
readonly pluginSourcePolicy: PluginSourcePolicyPort;
|
|
190
|
+
readonly tier2CallRunner: Tier2CallRunner;
|
|
191
|
+
readonly pluginSdkBinding: PluginSdkBinding;
|
|
192
|
+
readonly hostBinding: PluginRuntimeHostBinding;
|
|
193
|
+
/**
|
|
194
|
+
* Builds the module importer for one load target.
|
|
195
|
+
* @agent-note Second-host rule: two stages, with different guarantees.
|
|
196
|
+
* 1. Factory call: the runtime calls this while preparing the `loadPlugin` arguments, BEFORE that
|
|
197
|
+
* load's integrity and `sdkRange` checks run, and possibly for a package those checks then
|
|
198
|
+
* reject. The call must therefore only build a closure: no import, no snapshot, no file read,
|
|
199
|
+
* no executable loading of any kind.
|
|
200
|
+
* 2. Returned importer: invoked by the loader only AFTER admission (integrity, `sdkRange`). For a
|
|
201
|
+
* site package it must (a) enforce containment: the resolved entry stays inside the plugin's
|
|
202
|
+
* real package root, with links refused; (b) import a FRESH identity of the entire dependency
|
|
203
|
+
* graph on every load, never a cached module, so a replaced package never runs stale helpers;
|
|
204
|
+
* (c) keep any snapshot it takes, when `snapshots` is given, alive for late/lazy imports until
|
|
205
|
+
* that lifecycle is disposed. A plain cached `import()` adapter violates (b). An injected
|
|
206
|
+
* `importModule` seam (built-in, worker or test) keeps its original path.
|
|
207
|
+
*/
|
|
208
|
+
readonly createModuleImporter: (required: {
|
|
209
|
+
manifest: PluginManifest;
|
|
210
|
+
source: "built-in" | "site";
|
|
211
|
+
}, optional?: {
|
|
212
|
+
importModule?: (entryPath: string) => Promise<unknown>;
|
|
213
|
+
snapshots?: NonNullable<ReturnType<typeof createPluginModuleSnapshotLifecycle>>;
|
|
214
|
+
}) => PluginModuleImportPort;
|
|
215
|
+
readonly text: PluginRuntimeText;
|
|
216
|
+
/** Host projection of one quarantine into its own telemetry event; called only when `tracker` is set. */
|
|
217
|
+
readonly quarantineTelemetry: (required: {
|
|
218
|
+
pluginId: string;
|
|
219
|
+
}) => {
|
|
220
|
+
event: TEvent;
|
|
221
|
+
options: TOptions;
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/** Optional inputs; each omitted value keeps the documented default.
|
|
225
|
+
* @agent-note `dispose()` must run after provider teardown and stopped hook users; it drains
|
|
226
|
+
* pending attachments, then releases module snapshots. Load epochs retire stale generations. */
|
|
227
|
+
export interface PluginRuntimeCoreOptional<TEvent = unknown, TOptions = unknown> {
|
|
228
|
+
readonly tracker?: () => PluginRuntimeTracker<TEvent, TOptions>;
|
|
229
|
+
readonly lookup?: () => PluginRuntimeLookup | undefined;
|
|
230
|
+
readonly browserProviderApprovals?: readonly BundledBrowserProviderApproval[];
|
|
231
|
+
readonly bundledEnabledIds?: readonly string[];
|
|
232
|
+
readonly failureThreshold?: number;
|
|
233
|
+
readonly installDir?: string;
|
|
234
|
+
readonly coreClaims?: readonly ExtensionClaim[];
|
|
235
|
+
readonly declaredContentTypes?: DeclaredContentTypePorts;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=runtime-contracts.d.ts.map
|