@jini-ai/plugins 0.0.0-stage → 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 +27 -0
- package/LICENSE +201 -0
- package/README.md +60 -2
- package/dist/glue/attachment-points/content-lifecycle.d.ts +52 -0
- package/dist/glue/attachment-points/content-lifecycle.js +15 -0
- package/dist/glue/attachment-points/events.d.ts +12 -0
- package/dist/glue/attachment-points/events.js +5 -0
- package/dist/glue/attachment-points/tool-registration.d.ts +23 -0
- package/dist/glue/attachment-points/tool-registration.js +43 -0
- package/dist/glue/capability-gate.d.ts +73 -0
- package/dist/glue/capability-gate.js +41 -0
- package/dist/glue/dispatch.d.ts +20 -0
- package/dist/glue/dispatch.js +9 -0
- package/dist/glue/index.d.ts +8 -0
- package/dist/glue/index.js +8 -0
- package/dist/glue/manifest.d.ts +43 -0
- package/dist/glue/manifest.js +106 -0
- package/dist/glue/ports.d.ts +60 -0
- package/dist/glue/ports.js +2 -0
- package/dist/host/activation.d.ts +118 -0
- package/dist/host/activation.js +104 -0
- package/dist/host/attach-loaded-plugin.d.ts +37 -0
- package/dist/host/attach-loaded-plugin.js +19 -0
- package/dist/host/capability-sdk.d.ts +74 -0
- package/dist/host/capability-sdk.js +94 -0
- package/dist/host/claim-conflicts.d.ts +101 -0
- package/dist/host/claim-conflicts.js +139 -0
- package/dist/host/contributions.d.ts +129 -0
- package/dist/host/contributions.js +167 -0
- package/dist/host/declarative-enable.d.ts +43 -0
- package/dist/host/declarative-enable.js +73 -0
- package/dist/host/discovery-types.d.ts +55 -0
- package/dist/host/discovery-types.js +2 -0
- package/dist/host/errors.d.ts +20 -0
- package/dist/host/errors.js +22 -0
- package/dist/host/hook-registry.d.ts +113 -0
- package/dist/host/hook-registry.js +190 -0
- package/dist/host/index.d.ts +19 -0
- package/dist/host/index.js +19 -0
- package/dist/host/manifest.d.ts +159 -0
- package/dist/host/manifest.js +417 -0
- package/dist/host/node/discovery.d.ts +32 -0
- package/dist/host/node/discovery.js +241 -0
- package/dist/host/node/index.d.ts +8 -0
- package/dist/host/node/index.js +8 -0
- package/dist/host/node/install.d.ts +118 -0
- package/dist/host/node/install.js +431 -0
- package/dist/host/node/loader.d.ts +55 -0
- package/dist/host/node/loader.js +146 -0
- package/dist/host/node/module-snapshot.d.ts +25 -0
- package/dist/host/node/module-snapshot.js +53 -0
- package/dist/host/node/package-files.d.ts +52 -0
- package/dist/host/node/package-files.js +214 -0
- 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 +75 -0
- package/dist/host/plugin-claims.js +182 -0
- package/dist/host/ports.d.ts +208 -0
- package/dist/host/ports.js +2 -0
- package/dist/host/quarantine.d.ts +19 -0
- package/dist/host/quarantine.js +28 -0
- package/dist/host/repo.memory.d.ts +27 -0
- package/dist/host/repo.memory.js +33 -0
- package/dist/host/source-policy.d.ts +18 -0
- package/dist/host/source-policy.js +13 -0
- package/dist/host/sql/index.d.ts +4 -0
- package/dist/host/sql/index.js +4 -0
- package/dist/host/sql/repo.d.ts +38 -0
- package/dist/host/sql/repo.js +50 -0
- package/dist/host/sql/repo.rows.d.ts +28 -0
- package/dist/host/sql/repo.rows.js +28 -0
- package/dist/host/tool-contributions.d.ts +26 -0
- package/dist/host/tool-contributions.js +42 -0
- package/dist/host/uninstall.d.ts +88 -0
- package/dist/host/uninstall.js +112 -0
- package/dist/host/worker/import-seam.d.ts +45 -0
- package/dist/host/worker/import-seam.js +52 -0
- package/dist/host/worker/index.d.ts +5 -0
- package/dist/host/worker/index.js +5 -0
- package/dist/host/worker/protocol.d.ts +62 -0
- package/dist/host/worker/protocol.js +31 -0
- package/dist/host/worker/run-call.d.ts +27 -0
- package/dist/host/worker/run-call.js +76 -0
- package/package.json +107 -3
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { readPluginIdentity } from "@jini-ai/core/plugin-directory";
|
|
2
|
+
/** Site tier admission belongs to tierPolicy.siteErrors; static validation uses host-supplied
|
|
3
|
+
* catalogs and declaration grammar. */
|
|
4
|
+
/**
|
|
5
|
+
* @file `discoverPlugins()` — enumerate built-in + site plugins with status (SPEC-005 REQ-02/03,
|
|
6
|
+
* EC-08/EC-09, TB-01, DUP-01).
|
|
7
|
+
*
|
|
8
|
+
* Purpose:
|
|
9
|
+
* Read-only enumeration. Scans the install-dir's `plugins/<id>/<version>/` tree (REQ-02) plus the
|
|
10
|
+
* compiled-in built-in registry, performs BR-02 step (1)'s package-level checks (size, disallowed
|
|
11
|
+
* files, `server/index.mjs` presence — see `manifest.ts`'s header for why those checks live here
|
|
12
|
+
* rather than in `validateManifest()`), delegates manifest/identity/capability/hook/field checks to
|
|
13
|
+
* `validateManifest()`, and returns one `PluginDiscoveryRecord` per discovered id with every
|
|
14
|
+
* applicable error recorded — never throws for an individual plugin's own validation failure
|
|
15
|
+
* (errors are data, not control flow; REQ-10/`PLUGINS_LIST` lists every discovered plugin, valid or
|
|
16
|
+
* not).
|
|
17
|
+
*
|
|
18
|
+
* Never `import()`s plugin code — that is `loader.ts`'s job, gated by integrity/`sdkRange` first
|
|
19
|
+
* (BR-01, CIC U-001). Discovery only reads bytes to hash/measure/list them.
|
|
20
|
+
*
|
|
21
|
+
* Architectural role:
|
|
22
|
+
* TDD-certified implementation (implementation outline C-007). Signature and JSDoc are
|
|
23
|
+
* design-frozen; `discoverPlugins()` validates built-ins, selects the latest installed site
|
|
24
|
+
* version per id, records candidate-local errors without aborting discovery, marks duplicate ids,
|
|
25
|
+
* and returns deterministic TB-01 ordering.
|
|
26
|
+
*/
|
|
27
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
import * as semver from "semver";
|
|
30
|
+
import { validateManifest } from "../manifest.js";
|
|
31
|
+
export class PluginDiscoveryVersionError extends Error {
|
|
32
|
+
constructor(message) { super(message); this.name = 'PluginDiscoveryVersionError'; }
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Enumerates every built-in and (when `installDir` is present) site-installed plugin, in TB-01
|
|
36
|
+
* order (built-ins first by id ascending, then site plugins by id ascending). When two installed
|
|
37
|
+
* versions of one site plugin id exist, only the latest-by-semver is included in the result (the
|
|
38
|
+
* other stays dormant on disk, EC-08/AC-09) — the loader (not discovery) is what actually imports
|
|
39
|
+
* the winning version later.
|
|
40
|
+
*
|
|
41
|
+
* @throws Never for an individual plugin's own validation/package failure — that plugin's record
|
|
42
|
+
* simply carries a non-empty `errors[]` and a non-`valid` `status`. May reject for a genuine
|
|
43
|
+
* infrastructure failure (e.g. `installDir` exists but is unreadable due to a permissions error)
|
|
44
|
+
* that is not itself one specific plugin's fault.
|
|
45
|
+
* @complexity O(n) over installed-plugin count, bounded I/O per candidate (one directory listing
|
|
46
|
+
* + manifest read + per-file size stat).
|
|
47
|
+
*/
|
|
48
|
+
const VALID_TIERS = new Set(["tier-1", "tier-2", "tier-3"]);
|
|
49
|
+
/** Last-resort display tier when a malformed manifest has no validated tier. Every discovery
|
|
50
|
+
* record needs a renderable tier (REQ-18/AC-26); this fallback does not grant executable admission. */
|
|
51
|
+
const FALLBACK_TIER = "tier-3";
|
|
52
|
+
/** Safely reads a JSON value's string property, or `undefined` when absent/wrong-typed. */
|
|
53
|
+
function readStringField(value, key) {
|
|
54
|
+
if (typeof value !== "object" || value === null)
|
|
55
|
+
return undefined;
|
|
56
|
+
const raw = value[key];
|
|
57
|
+
return typeof raw === "string" ? raw : undefined;
|
|
58
|
+
}
|
|
59
|
+
function readTierField(value) {
|
|
60
|
+
const raw = readStringField(value, "tier");
|
|
61
|
+
return raw !== undefined && VALID_TIERS.has(raw) ? raw : FALLBACK_TIER;
|
|
62
|
+
}
|
|
63
|
+
/** Parses one `tovu.plugin.json` file's bytes; unparseable JSON becomes `null` — `validateManifest`
|
|
64
|
+
* already reports a `MANIFEST_MALFORMED` entry for any non-object value (its own top-level guard),
|
|
65
|
+
* so a parse failure and a wrong-shape object are handled through the exact same code path. */
|
|
66
|
+
function parseManifestJson(raw) {
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(raw);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function toDiscoveryRecord(params) {
|
|
75
|
+
const isValid = params.errors.length === 0;
|
|
76
|
+
return {
|
|
77
|
+
id: params.id,
|
|
78
|
+
name: params.name,
|
|
79
|
+
version: params.version,
|
|
80
|
+
source: params.source,
|
|
81
|
+
tier: readTierField(params.manifestValue),
|
|
82
|
+
status: isValid ? "valid" : "invalid",
|
|
83
|
+
errors: params.errors,
|
|
84
|
+
// Safe only because `isValid` means `validateManifest()` already reported zero errors against
|
|
85
|
+
// this exact value — an invalid candidate's `manifestValue` is never cast (see the field's own
|
|
86
|
+
// doc on `PluginDiscoveryRecord`).
|
|
87
|
+
manifest: isValid ? params.manifestValue : undefined,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The absolute entry-file path for a discovered SITE plugin (REQ-02's fixed `server/index.mjs`
|
|
92
|
+
* package layout, ADR-004) — the exact path `loadPlugin()`'s `entryPath` param expects, and the
|
|
93
|
+
* same join `discoverOneSiteCandidate()` below already performs internally for its manifest read.
|
|
94
|
+
* Exported so a composition root resolving a dynamic site-sourced load target (`plugin-runtime.ts`)
|
|
95
|
+
* does not re-derive this convention independently and risk it drifting from discovery's own.
|
|
96
|
+
*
|
|
97
|
+
* @complexity O(1) — pure path join, no I/O.
|
|
98
|
+
*/
|
|
99
|
+
export function siteEntryPath({ installDir, id, version }, _optional = {}) {
|
|
100
|
+
return path.join(installDir, id, version, "server", "index.mjs");
|
|
101
|
+
}
|
|
102
|
+
/** One directory entry directly under `installDir` — a candidate plugin "id slot" that may contain
|
|
103
|
+
* one or more version subdirectories (REQ-02's `plugins/<id>/<version>/` layout). */
|
|
104
|
+
async function listInstalledPluginIdFolders(installDir) {
|
|
105
|
+
try {
|
|
106
|
+
const entries = await readdir(installDir, { withFileTypes: true });
|
|
107
|
+
// Hidden working/staging areas (notably .drafts) are never install candidates. Valid manifest
|
|
108
|
+
// ids cannot start with a dot, so no valid installed package loses discovery reachability.
|
|
109
|
+
return entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.')).map((entry) => entry.name);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error?.code === "ENOENT")
|
|
113
|
+
return [];
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** Picks the latest-by-semver version subdirectory under one id folder (AC-09/EC-08) — the other
|
|
118
|
+
* installed versions stay dormant on disk, never surfaced as a second row. Non-semver directory
|
|
119
|
+
* names sort last (defensive; every certified fixture uses valid semver directory names). */
|
|
120
|
+
async function pickLatestVersionFolder(idFolderPath) {
|
|
121
|
+
const entries = await readdir(idFolderPath, { withFileTypes: true });
|
|
122
|
+
const versionNames = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
123
|
+
if (versionNames.length === 0)
|
|
124
|
+
return null;
|
|
125
|
+
const sorted = [...versionNames].sort((a, b) => {
|
|
126
|
+
const aValid = semver.valid(a);
|
|
127
|
+
const bValid = semver.valid(b);
|
|
128
|
+
if (aValid && bValid)
|
|
129
|
+
return semver.rcompare(aValid, bValid);
|
|
130
|
+
if (aValid)
|
|
131
|
+
return -1;
|
|
132
|
+
if (bValid)
|
|
133
|
+
return 1;
|
|
134
|
+
return b.localeCompare(a);
|
|
135
|
+
});
|
|
136
|
+
return sorted[0] ?? null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The installer refuses a sideloaded tier-2 package (`install.ts`'s `checkTierAndCode`): a package
|
|
140
|
+
* cannot grant itself the verified-publisher tier, and a tier-2 worker is not a security sandbox
|
|
141
|
+
* (it can still import `node:fs`). A package placed straight into `installDir` skips the installer,
|
|
142
|
+
* so discovery applies the same rule — enable and boot load only `valid` records, so neither ever
|
|
143
|
+
* runs one.
|
|
144
|
+
*
|
|
145
|
+
* @complexity O(1).
|
|
146
|
+
*/
|
|
147
|
+
async function discoverOneSiteCandidate(installDir, idFolderName, builtInIds, host, options = {}) {
|
|
148
|
+
const idFolderPath = path.join(installDir, idFolderName);
|
|
149
|
+
const requestedVersion = options.versions?.get(idFolderName);
|
|
150
|
+
if (requestedVersion !== undefined && (!semver.valid(requestedVersion) || !/^[0-9A-Za-z][0-9A-Za-z.+-]*$/.test(requestedVersion))) {
|
|
151
|
+
throw new PluginDiscoveryVersionError('The requested plugin activation version is not a safe semantic version.');
|
|
152
|
+
}
|
|
153
|
+
const versionFolderName = requestedVersion ?? await pickLatestVersionFolder(idFolderPath);
|
|
154
|
+
if (versionFolderName === null)
|
|
155
|
+
return null;
|
|
156
|
+
const manifestPath = path.join(idFolderPath, versionFolderName, "tovu.plugin.json");
|
|
157
|
+
let manifestValue = null;
|
|
158
|
+
let missing = false;
|
|
159
|
+
try {
|
|
160
|
+
manifestValue = parseManifestJson(await readFile(manifestPath, "utf8"));
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error?.code === "ENOENT") {
|
|
164
|
+
missing = true;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const errors = missing
|
|
171
|
+
? [{ code: "MANIFEST_MISSING", file: "tovu.plugin.json", message: "tovu.plugin.json was not found" }]
|
|
172
|
+
: [...validateManifest({ ...host, manifest: manifestValue, folderName: idFolderName, builtInIds }).errors, ...host.tierPolicy.siteErrors({ manifestValue })];
|
|
173
|
+
const id = readStringField(manifestValue, "id") ?? idFolderName;
|
|
174
|
+
const name = readStringField(manifestValue, "name") ?? idFolderName;
|
|
175
|
+
return toDiscoveryRecord({ id, name, version: versionFolderName, source: "site", manifestValue, errors });
|
|
176
|
+
}
|
|
177
|
+
/** DUP-01 (`ID_DUPLICATE` half — `SHADOWS_BUILT_IN` is already handled per-record inside
|
|
178
|
+
* `validateManifest`, which only ever sees one candidate at a time): a case-insensitive id
|
|
179
|
+
* collision between two SITE plugins can only be detected once every candidate is known, so this
|
|
180
|
+
* runs as a whole-set post-pass over the already-built site records. */
|
|
181
|
+
function markCaseInsensitiveDuplicates(records) {
|
|
182
|
+
const countByLowerId = new Map();
|
|
183
|
+
for (const record of records) {
|
|
184
|
+
const key = record.id.toLowerCase();
|
|
185
|
+
countByLowerId.set(key, (countByLowerId.get(key) ?? 0) + 1);
|
|
186
|
+
}
|
|
187
|
+
return records.map((record) => {
|
|
188
|
+
const isDuplicate = (countByLowerId.get(record.id.toLowerCase()) ?? 0) > 1;
|
|
189
|
+
if (!isDuplicate)
|
|
190
|
+
return record;
|
|
191
|
+
const errors = [
|
|
192
|
+
...record.errors,
|
|
193
|
+
{ code: "ID_DUPLICATE", file: null, message: `id '${record.id}' collides case-insensitively with another installed site plugin` },
|
|
194
|
+
];
|
|
195
|
+
return { ...record, errors, status: "invalid" };
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** TB-01: built-ins first (id ascending), then site plugins (id ascending) — the same ordering
|
|
199
|
+
* `hook-registry.ts`'s composition uses, so `PLUGINS_LIST` and hook-composition order never
|
|
200
|
+
* diverge. */
|
|
201
|
+
function orderTb01(records) {
|
|
202
|
+
const rank = (source) => (source === "built-in" ? 0 : 1);
|
|
203
|
+
return [...records].sort((a, b) => rank(a.source) - rank(b.source) || a.id.localeCompare(b.id));
|
|
204
|
+
}
|
|
205
|
+
export async function discoverPlugins(required, optional = {}) {
|
|
206
|
+
const { builtIns, installDir } = required;
|
|
207
|
+
const builtInIds = builtIns.map((b) => b.manifest.id);
|
|
208
|
+
const builtInRecords = builtIns.map((builtIn) => {
|
|
209
|
+
const errors = validateManifest({ ...required, manifest: builtIn.manifest, folderName: builtIn.manifest.id, builtInIds: [] }).errors;
|
|
210
|
+
return toDiscoveryRecord({
|
|
211
|
+
id: builtIn.manifest.id,
|
|
212
|
+
name: builtIn.manifest.name,
|
|
213
|
+
version: builtIn.manifest.version,
|
|
214
|
+
source: "built-in",
|
|
215
|
+
manifestValue: builtIn.manifest,
|
|
216
|
+
errors,
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
let siteRecords = [];
|
|
220
|
+
if (installDir !== undefined) {
|
|
221
|
+
const idFolders = await listInstalledPluginIdFolders(installDir);
|
|
222
|
+
const candidates = await Promise.all(idFolders.map((idFolderName) => discoverOneSiteCandidate(installDir, idFolderName, builtInIds, required, optional)));
|
|
223
|
+
siteRecords = markCaseInsensitiveDuplicates(candidates.filter((r) => r !== null));
|
|
224
|
+
}
|
|
225
|
+
const records = orderTb01([...builtInRecords, ...siteRecords]);
|
|
226
|
+
const qualifiedIds = new Set();
|
|
227
|
+
// TB-01 places built-ins first: the incumbent keeps its id; only later claims are invalid.
|
|
228
|
+
// Disabled valid installs still own ids.
|
|
229
|
+
return records.map(record => {
|
|
230
|
+
if (record.status !== "valid" || !record.manifest)
|
|
231
|
+
return record;
|
|
232
|
+
const identity = readPluginIdentity({ manifest: record.manifest, name: record.id, namespace: required.identityNamespace ?? "tovu" });
|
|
233
|
+
if (!qualifiedIds.has(identity.id)) {
|
|
234
|
+
qualifiedIds.add(identity.id);
|
|
235
|
+
return { ...record, warnings: identity.warnings };
|
|
236
|
+
}
|
|
237
|
+
return { ...record, status: "invalid", manifest: undefined, warnings: identity.warnings,
|
|
238
|
+
errors: [...record.errors, { code: "PLUGIN_ID_DUPLICATE", file: null, message: `duplicate publisher-qualified plugin id '${identity.id}'` }], };
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Node file effects and ordered loading. Executable import and archive parsing are required host ports. */
|
|
2
|
+
export * from './discovery.js';
|
|
3
|
+
export * from './loader.js';
|
|
4
|
+
export * from './package-files.js';
|
|
5
|
+
export * from './install.js';
|
|
6
|
+
export * from './module-snapshot.js';
|
|
7
|
+
export * from './source-drafts.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Node file effects and ordered loading. Executable import and archive parsing are required host ports. */
|
|
2
|
+
export * from './discovery.js';
|
|
3
|
+
export * from './loader.js';
|
|
4
|
+
export * from './package-files.js';
|
|
5
|
+
export * from './install.js';
|
|
6
|
+
export * from './module-snapshot.js';
|
|
7
|
+
export * from './source-drafts.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type PluginManifest, type PluginTier } from "../manifest.js";
|
|
2
|
+
import type { ArchiveReaderPort, ManifestHostPorts, PluginTierPolicy } from "../ports.js";
|
|
3
|
+
import type { PluginActivationRepoPort } from "../activation.js";
|
|
4
|
+
import type { PluginConflict } from "../plugin-claims.js";
|
|
5
|
+
export declare class PluginInstallError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(code: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
export interface PluginInstallPreview {
|
|
10
|
+
readonly warnings?: readonly string[];
|
|
11
|
+
readonly publisherId?: string;
|
|
12
|
+
readonly provides?: readonly string[];
|
|
13
|
+
readonly keywords?: readonly string[];
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
tier: PluginTier;
|
|
18
|
+
capabilities: readonly string[];
|
|
19
|
+
hooks: readonly string[];
|
|
20
|
+
/** `false` only for a tier-1 (manifest-only) package — the runtime never imports anything for it. */
|
|
21
|
+
hasCode: boolean;
|
|
22
|
+
digest: string;
|
|
23
|
+
upgradeFrom?: string;
|
|
24
|
+
/** Content-type keys the manifest declares (AW-7 Tier 1); created when the plugin is turned on. */
|
|
25
|
+
contentTypes: readonly string[];
|
|
26
|
+
/** What turning it on would clash with — see {@link PluginInstallDeps.conflicts}. Informational
|
|
27
|
+
* only: not part of the consent digest, and enable re-checks (the enable-time conflict gate). */
|
|
28
|
+
conflicts: readonly PluginConflict[];
|
|
29
|
+
}
|
|
30
|
+
export type PluginInstallInput = ({
|
|
31
|
+
sourceDir: string;
|
|
32
|
+
archive?: never;
|
|
33
|
+
} | {
|
|
34
|
+
archive: Uint8Array;
|
|
35
|
+
sourceDir?: never;
|
|
36
|
+
}) & {
|
|
37
|
+
replace?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export interface PluginInstallDeps extends ManifestHostPorts {
|
|
40
|
+
/** Internal authoring path only: append immutable versions while retaining rollback bytes.
|
|
41
|
+
* Same-version replacement still refuses enabled plugins. Ordinary installs keep their policy. */
|
|
42
|
+
readonly versionAppend?: boolean;
|
|
43
|
+
readonly warn?: (message: string) => void;
|
|
44
|
+
readonly archiveReader: ArchiveReaderPort;
|
|
45
|
+
readonly tierPolicy: PluginTierPolicy;
|
|
46
|
+
installDir: string;
|
|
47
|
+
builtInIds: readonly string[];
|
|
48
|
+
/** Built-in publisher reservations, independent of their local storage ids. Hosts supplying
|
|
49
|
+
* only builtInIds must wrap publication in their cross-family identity-admission transaction;
|
|
50
|
+
* publisher identities cannot be inferred from a local name or extension namespace. */
|
|
51
|
+
readonly builtInManifests?: readonly PluginManifest[];
|
|
52
|
+
/** Installed-neighbour reads only; extraction and publication retain their native effects. */
|
|
53
|
+
readonly identityFilesystem?: Pick<typeof import('node:fs/promises'), 'lstat' | 'readdir' | 'readFile'>;
|
|
54
|
+
repo: Pick<PluginActivationRepoPort, "listAll">;
|
|
55
|
+
/** Names the staged manifest would take that core or an enabled plugin already holds. Install is
|
|
56
|
+
* site-wide but activation is per workspace: the admin root answers for the workspace it serves
|
|
57
|
+
* (`composePluginRuntime`); the CLI, which names no workspace, answers none. */
|
|
58
|
+
conflicts: (required: {
|
|
59
|
+
manifest: PluginManifest;
|
|
60
|
+
}, optional?: Record<string, never>) => Promise<readonly PluginConflict[]>;
|
|
61
|
+
}
|
|
62
|
+
export interface PluginInstallerPort {
|
|
63
|
+
preview(required: PluginInstallInput, optional?: PluginInstallOptions): Promise<PluginInstallPreview>;
|
|
64
|
+
install(required: PluginInstallInput & {
|
|
65
|
+
expectedDigest: string;
|
|
66
|
+
}, optional?: PluginInstallOptions): Promise<PluginInstallPreview>;
|
|
67
|
+
}
|
|
68
|
+
/** Not a model input: the source authoring service opts into immutable version publication. */
|
|
69
|
+
export interface PluginInstallOptions {
|
|
70
|
+
readonly versionAppend?: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface PluginSnapshotLimits {
|
|
73
|
+
readonly maxEntries?: number;
|
|
74
|
+
readonly maxFileBytes?: number;
|
|
75
|
+
readonly maxTotalBytes?: number;
|
|
76
|
+
}
|
|
77
|
+
/** Retained bytes plus the entry count, including empty directories, for authoring preflight. */
|
|
78
|
+
export interface PluginPackageSnapshot extends Map<string, Buffer> {
|
|
79
|
+
readonly entryCount: number;
|
|
80
|
+
}
|
|
81
|
+
/** Activation callbacks share this guard; the activation service compensates a rejected enable. */
|
|
82
|
+
export declare function assertPluginInstallIdle(required: {
|
|
83
|
+
installDir: string;
|
|
84
|
+
}, _optional?: Record<string, never>): Promise<void>;
|
|
85
|
+
/** Retire obsolete immutable source releases after a successful controlled reload.
|
|
86
|
+
* All workspace active pointers survive, plus the newest three versions for rollback.
|
|
87
|
+
* Uses the installer's publication lock so pruning cannot overlap a package install.
|
|
88
|
+
* @returns Retired version names; dotfiles are unrelated metadata and remain untouched.
|
|
89
|
+
* @throws PluginInstallError for unsafe paths, invalid version slots or an active install.
|
|
90
|
+
* @complexity O(V log V + A) for V installed versions and A activation rows, then one removal per retired version.
|
|
91
|
+
*/
|
|
92
|
+
export declare function pruneSitePluginVersions(required: {
|
|
93
|
+
id: string;
|
|
94
|
+
installDir: string;
|
|
95
|
+
repo: Pick<PluginActivationRepoPort, 'listAll'>;
|
|
96
|
+
}, _optional?: Record<string, never>): Promise<readonly string[]>;
|
|
97
|
+
/** Loader uses the same bounded, link-free byte snapshot, then verifies the retained bytes. */
|
|
98
|
+
export declare function snapshotSitePluginPackage(required: {
|
|
99
|
+
sourceDir: string;
|
|
100
|
+
}, optional?: PluginSnapshotLimits): Promise<PluginPackageSnapshot>;
|
|
101
|
+
/** The installer's consent digest, also used to bind site-authored provenance to exact bytes.
|
|
102
|
+
* @returns A SHA-256 digest covering the manifest and every retained file.
|
|
103
|
+
*/
|
|
104
|
+
export declare function digestSitePluginSnapshot(required: {
|
|
105
|
+
files: ReadonlyMap<string, Buffer>;
|
|
106
|
+
}, _optional?: {}): string;
|
|
107
|
+
export declare function computePluginIntegrity(required: {
|
|
108
|
+
sourceDir: string;
|
|
109
|
+
}, _optional?: Record<string, never>): Promise<Record<string, string>>;
|
|
110
|
+
export declare function previewSitePluginInstall(required: PluginInstallInput & {
|
|
111
|
+
deps: PluginInstallDeps;
|
|
112
|
+
}, _optional?: Record<string, never>): Promise<PluginInstallPreview>;
|
|
113
|
+
/** Publication and retention use the same installer-owned cross-process lock. */
|
|
114
|
+
export declare function installSitePlugin(required: PluginInstallInput & {
|
|
115
|
+
expectedDigest: string;
|
|
116
|
+
deps: PluginInstallDeps;
|
|
117
|
+
}, _optional?: Record<string, never>): Promise<PluginInstallPreview>;
|
|
118
|
+
//# sourceMappingURL=install.d.ts.map
|