@jini-ai/plugins 0.7.2 → 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/CHANGELOG.md +0 -6
- 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
|
@@ -387,22 +387,27 @@ async function applySiteRuntimeDecision(routeDeps, principalId, request, optiona
|
|
|
387
387
|
},
|
|
388
388
|
input: { workspaceId: routeDeps.workspaceId, pluginId, enabled },
|
|
389
389
|
}),
|
|
390
|
-
rollback:
|
|
391
|
-
if (priorActivation) {
|
|
392
|
-
await routeDeps.pluginActivationRepo.save(priorActivation);
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
await routeDeps.pluginActivationRepo.deleteActivation({ workspaceId: routeDeps.workspaceId, pluginId });
|
|
396
|
-
}
|
|
397
|
-
if (priorActivation?.enabled) {
|
|
398
|
-
await routeDeps.onPluginEnabled(pluginId);
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
routeDeps.onPluginDisabled(pluginId);
|
|
402
|
-
}
|
|
403
|
-
},
|
|
390
|
+
rollback: () => restoreRuntimeActivation(routeDeps, { priorActivation, pluginId }),
|
|
404
391
|
},
|
|
405
392
|
});
|
|
393
|
+
return siteRuntimeDecisionResult(routeDeps, { request, pluginId, enabled, principalId, priorActivation, discovery, result });
|
|
394
|
+
}
|
|
395
|
+
async function restoreRuntimeActivation(routeDeps, { priorActivation, pluginId }) {
|
|
396
|
+
if (priorActivation) {
|
|
397
|
+
await routeDeps.pluginActivationRepo.save(priorActivation);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
await routeDeps.pluginActivationRepo.deleteActivation({ workspaceId: routeDeps.workspaceId, pluginId });
|
|
401
|
+
}
|
|
402
|
+
if (priorActivation?.enabled) {
|
|
403
|
+
await routeDeps.onPluginEnabled(pluginId);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
routeDeps.onPluginDisabled(pluginId);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
async function siteRuntimeDecisionResult(routeDeps, context) {
|
|
410
|
+
const { request, pluginId, enabled, principalId, priorActivation, discovery, result } = context;
|
|
406
411
|
if (!result.activation.enabled)
|
|
407
412
|
await routeDeps.lowerToolAccess({ pluginId });
|
|
408
413
|
const record = discovery.find((r) => r.id === pluginId);
|
|
@@ -527,75 +532,9 @@ const PLUGINS_MODEL_FACING_ERRORS = [
|
|
|
527
532
|
];
|
|
528
533
|
export function buildPluginManagementRegistrations(routeDeps, _optional = {}) {
|
|
529
534
|
const handlers = {
|
|
530
|
-
[routeDeps.toolIds.list]:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
const discovery = await routeDeps.discoverPlugins();
|
|
534
|
-
const conflicts = (await routeDeps.listPluginConflicts?.()) ?? new Map();
|
|
535
|
-
const plugins = await Promise.all(discovery.map(async (record) => {
|
|
536
|
-
const activation = await routeDeps.pluginActivationRepo.getActivation({ workspaceId: routeDeps.workspaceId, pluginId: record.id });
|
|
537
|
-
if (!activation?.enabled) {
|
|
538
|
-
const visible = routeDeps.agentPlugins.searchCandidate({ candidate: { pluginId: record.id, displayName: record.name, enabled: false, keywords: [], skills: [], mcpServerIds: [] } });
|
|
539
|
-
return { id: record.id, enabled: false, status: record.status, description: visible.description };
|
|
540
|
-
}
|
|
541
|
-
return toAdminPluginResponse({ discovery: record, activation }, { conflicts: conflicts.get(record.id) ?? [] });
|
|
542
|
-
}));
|
|
543
|
-
const agentPlugins = await listAgentPluginsForResponse(routeDeps);
|
|
544
|
-
return { plugins, agentPlugins };
|
|
545
|
-
},
|
|
546
|
-
/**
|
|
547
|
-
* Parse and authorize before preflight or disclosure, then confirm and write; the gateway's
|
|
548
|
-
* later authorization is still needed because a human can leave the dialog open while access
|
|
549
|
-
* changes, and the first check prevents an unauthorized principal from opening it at all.
|
|
550
|
-
*/
|
|
551
|
-
[routeDeps.toolIds.setEnabled]: routeDeps.approvals.handler({
|
|
552
|
-
prepare: ({ ctx }) => prepareSetEnabled(routeDeps, { ctx }),
|
|
553
|
-
describe: ({ ctx, prepared: { request, identity, added, refusal, previousEnabled } }) => routeDeps.descriptions.enable({
|
|
554
|
-
subject: { family: request.family, pluginId: request.pluginId, version: identity?.version, label: identity?.label, adds: added,
|
|
555
|
-
previousEnabled, revision: identity?.key, resources: identity?.accessResources },
|
|
556
|
-
...(request.enabled && refusal === undefined ? { scope: { personId: ctx.principal.id, siteId: routeDeps.workspaceId } } : {}),
|
|
557
|
-
}),
|
|
558
|
-
run: ({ ctx, prepared }) => runSetEnabled(routeDeps, { ctx, prepared }),
|
|
559
|
-
}, { flag: "changed", ask: ({ prepared }) => prepared.request.enabled && prepared.refusal === undefined && prepared.confirm,
|
|
560
|
-
// Turning a plugin back on is a new escalation. A remembered version approval must not
|
|
561
|
-
// silently turn it on after the owner switched it off.
|
|
562
|
-
declined: async ({ reason, prepared }) => {
|
|
563
|
-
if (reason === 'declined' && prepared?.request.family === AGENT_PLUGIN_FAMILY && prepared.identity?.accessKey) {
|
|
564
|
-
await routeDeps.agentPlugins.recordDeclinedAccess?.({ accessKey: prepared.identity.accessKey });
|
|
565
|
-
}
|
|
566
|
-
return { changed: false, family: prepared?.request.family,
|
|
567
|
-
pluginId: prepared?.request.pluginId, restartRequired: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason }) };
|
|
568
|
-
},
|
|
569
|
-
}),
|
|
570
|
-
/**
|
|
571
|
-
* One uninstall tool avoids ambiguous family-specific choices while preserving each lifecycle.
|
|
572
|
-
* Runtime removal authorizes and previews before asking so built-in, enabled or unknown targets
|
|
573
|
-
* are refused before an impossible approval; after confirmation it rediscovers the shown version.
|
|
574
|
-
* Removal has no useful inverse for deleted bytes, so it uses shared Trash instead of a command
|
|
575
|
-
* rollback; confirmation is still required because revertibility and consent are independent.
|
|
576
|
-
* Agent removal delegates its entire permission, preview, confirmation and write order, using
|
|
577
|
-
* the same held-open exchange and tool id rather than constructing a second approval channel.
|
|
578
|
-
*/
|
|
579
|
-
[routeDeps.toolIds.uninstall]: async (ctx, optional = {}) => {
|
|
580
|
-
ctx = { ...ctx, input: structuredClone(ctx.input), principal: { ...ctx.principal }, run: { ...ctx.run } };
|
|
581
|
-
const input = requireInputRecord({ input: ctx.input });
|
|
582
|
-
const family = readFamily(input, routeDeps.messages.familyRequired);
|
|
583
|
-
const pluginId = requireString({ input: input, key: "pluginId" });
|
|
584
|
-
if (family === AGENT_PLUGIN_FAMILY)
|
|
585
|
-
return routeDeps.agentPlugins.uninstall({ ctx, pluginId, executionOptions: optional }, {});
|
|
586
|
-
await requireEnablePermission(routeDeps, { principalId: ctx.principal.id, entityType: routeDeps.entityTypes.plugin, entityId: pluginId });
|
|
587
|
-
const preview = await previewUninstallPlugin(await uninstallRequestFor(routeDeps, pluginId, ctx.principal.id)); // throws PluginNotFoundError/NotUninstallableError/EnabledError BEFORE any dialog
|
|
588
|
-
return routeDeps.approvals.handler({
|
|
589
|
-
prepare: async () => preview,
|
|
590
|
-
describe: ({ prepared }) => routeDeps.descriptions.uninstall({ preview: prepared }),
|
|
591
|
-
run: async ({ ctx: approvedCtx, prepared }) => {
|
|
592
|
-
await requireEnablePermission(routeDeps, { principalId: approvedCtx.principal.id, entityType: routeDeps.entityTypes.plugin, entityId: pluginId });
|
|
593
|
-
if (approvedCtx.signal.aborted)
|
|
594
|
-
return { uninstalled: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason: "abandoned" }) };
|
|
595
|
-
return uninstallConfirmedPlugin(routeDeps, prepared, approvedCtx.principal.id);
|
|
596
|
-
},
|
|
597
|
-
}, { flag: "uninstalled", declined: ({ reason }) => ({ pluginId, uninstalled: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason }) }) })(ctx, optional);
|
|
598
|
-
},
|
|
535
|
+
[routeDeps.toolIds.list]: pluginManagementListHandler(routeDeps),
|
|
536
|
+
[routeDeps.toolIds.setEnabled]: pluginManagementSetEnabledHandler(routeDeps),
|
|
537
|
+
[routeDeps.toolIds.uninstall]: pluginManagementUninstallHandler(routeDeps),
|
|
599
538
|
};
|
|
600
539
|
// No `unwiredToolIds`: Every supplied catalog entry must have a handler so missing wiring fails closed.
|
|
601
540
|
return buildDomainRegistrations({ ...routeDeps.registration,
|
|
@@ -604,4 +543,79 @@ export function buildPluginManagementRegistrations(routeDeps, _optional = {}) {
|
|
|
604
543
|
derivedRisk: pluginManagementDerivedRiskFor({ toolIds: routeDeps.toolIds }),
|
|
605
544
|
});
|
|
606
545
|
}
|
|
546
|
+
function pluginManagementListHandler(routeDeps) {
|
|
547
|
+
return async (ctx) => {
|
|
548
|
+
requireNoInput({ input: ctx.input });
|
|
549
|
+
await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: routeDeps.authorize }), workspaceId: routeDeps.workspaceId, principalId: ctx.principal.id, permission: routeDeps.permissions.read });
|
|
550
|
+
const discovery = await routeDeps.discoverPlugins();
|
|
551
|
+
const conflicts = (await routeDeps.listPluginConflicts?.()) ?? new Map();
|
|
552
|
+
const plugins = await Promise.all(discovery.map(async (record) => {
|
|
553
|
+
const activation = await routeDeps.pluginActivationRepo.getActivation({ workspaceId: routeDeps.workspaceId, pluginId: record.id });
|
|
554
|
+
if (!activation?.enabled) {
|
|
555
|
+
const visible = routeDeps.agentPlugins.searchCandidate({ candidate: { pluginId: record.id, displayName: record.name, enabled: false, keywords: [], skills: [], mcpServerIds: [] } });
|
|
556
|
+
return { id: record.id, enabled: false, status: record.status, description: visible.description };
|
|
557
|
+
}
|
|
558
|
+
return toAdminPluginResponse({ discovery: record, activation }, { conflicts: conflicts.get(record.id) ?? [] });
|
|
559
|
+
}));
|
|
560
|
+
const agentPlugins = await listAgentPluginsForResponse(routeDeps);
|
|
561
|
+
return { plugins, agentPlugins };
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function pluginManagementSetEnabledHandler(routeDeps) {
|
|
565
|
+
/**
|
|
566
|
+
* Parse and authorize before preflight or disclosure, then confirm and write; the gateway's
|
|
567
|
+
* later authorization is still needed because a human can leave the dialog open while access
|
|
568
|
+
* changes, and the first check prevents an unauthorized principal from opening it at all.
|
|
569
|
+
*/
|
|
570
|
+
return routeDeps.approvals.handler({
|
|
571
|
+
prepare: ({ ctx }) => prepareSetEnabled(routeDeps, { ctx }),
|
|
572
|
+
describe: ({ ctx, prepared: { request, identity, added, refusal, previousEnabled } }) => routeDeps.descriptions.enable({
|
|
573
|
+
subject: { family: request.family, pluginId: request.pluginId, version: identity?.version, label: identity?.label, adds: added,
|
|
574
|
+
previousEnabled, revision: identity?.key, resources: identity?.accessResources },
|
|
575
|
+
...(request.enabled && refusal === undefined ? { scope: { personId: ctx.principal.id, siteId: routeDeps.workspaceId } } : {}),
|
|
576
|
+
}),
|
|
577
|
+
run: ({ ctx, prepared }) => runSetEnabled(routeDeps, { ctx, prepared }),
|
|
578
|
+
}, { flag: "changed", ask: ({ prepared }) => prepared.request.enabled && prepared.refusal === undefined && prepared.confirm,
|
|
579
|
+
// Turning a plugin back on is a new escalation. A remembered version approval must not
|
|
580
|
+
// silently turn it on after the owner switched it off.
|
|
581
|
+
declined: async ({ reason, prepared }) => {
|
|
582
|
+
if (reason === 'declined' && prepared?.request.family === AGENT_PLUGIN_FAMILY && prepared.identity?.accessKey) {
|
|
583
|
+
await routeDeps.agentPlugins.recordDeclinedAccess?.({ accessKey: prepared.identity.accessKey });
|
|
584
|
+
}
|
|
585
|
+
return { changed: false, family: prepared?.request.family,
|
|
586
|
+
pluginId: prepared?.request.pluginId, restartRequired: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason }) };
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
function pluginManagementUninstallHandler(routeDeps) {
|
|
591
|
+
/**
|
|
592
|
+
* One uninstall tool avoids ambiguous family-specific choices while preserving each lifecycle.
|
|
593
|
+
* Runtime removal authorizes and previews before asking so built-in, enabled or unknown targets
|
|
594
|
+
* are refused before an impossible approval; after confirmation it rediscovers the shown version.
|
|
595
|
+
* Removal has no useful inverse for deleted bytes, so it uses shared Trash instead of a command
|
|
596
|
+
* rollback; confirmation is still required because revertibility and consent are independent.
|
|
597
|
+
* Agent removal delegates its entire permission, preview, confirmation and write order, using
|
|
598
|
+
* the same held-open exchange and tool id rather than constructing a second approval channel.
|
|
599
|
+
*/
|
|
600
|
+
return async (ctx, optional = {}) => {
|
|
601
|
+
ctx = { ...ctx, input: structuredClone(ctx.input), principal: { ...ctx.principal }, run: { ...ctx.run } };
|
|
602
|
+
const input = requireInputRecord({ input: ctx.input });
|
|
603
|
+
const family = readFamily(input, routeDeps.messages.familyRequired);
|
|
604
|
+
const pluginId = requireString({ input: input, key: "pluginId" });
|
|
605
|
+
if (family === AGENT_PLUGIN_FAMILY)
|
|
606
|
+
return routeDeps.agentPlugins.uninstall({ ctx, pluginId, executionOptions: optional }, {});
|
|
607
|
+
await requireEnablePermission(routeDeps, { principalId: ctx.principal.id, entityType: routeDeps.entityTypes.plugin, entityId: pluginId });
|
|
608
|
+
const preview = await previewUninstallPlugin(await uninstallRequestFor(routeDeps, pluginId, ctx.principal.id)); // throws PluginNotFoundError/NotUninstallableError/EnabledError BEFORE any dialog
|
|
609
|
+
return routeDeps.approvals.handler({
|
|
610
|
+
prepare: async () => preview,
|
|
611
|
+
describe: ({ prepared }) => routeDeps.descriptions.uninstall({ preview: prepared }),
|
|
612
|
+
run: async ({ ctx: approvedCtx, prepared }) => {
|
|
613
|
+
await requireEnablePermission(routeDeps, { principalId: approvedCtx.principal.id, entityType: routeDeps.entityTypes.plugin, entityId: pluginId });
|
|
614
|
+
if (approvedCtx.signal.aborted)
|
|
615
|
+
return { uninstalled: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason: "abandoned" }) };
|
|
616
|
+
return uninstallConfirmedPlugin(routeDeps, prepared, approvedCtx.principal.id);
|
|
617
|
+
},
|
|
618
|
+
}, { flag: "uninstalled", declined: ({ reason }) => ({ pluginId, uninstalled: false, ...routeDeps.approvals.notConfirmed({ confirmed: false, reason }) }) })(ctx, optional);
|
|
619
|
+
};
|
|
620
|
+
}
|
|
607
621
|
//# sourceMappingURL=management.js.map
|
package/dist/host/uninstall.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface UninstallPluginResult {
|
|
|
51
51
|
readonly trashed: true;
|
|
52
52
|
}
|
|
53
53
|
/** What a human confirmation dialog needs to describe truthfully what is about to be removed.
|
|
54
|
-
* Mirrors `agent-plugins/uninstall.ts`'s own `AgentPluginUninstallPreview` for the sibling family,
|
|
54
|
+
* Mirrors `packages/agent-plugins/src/lifecycle/uninstall.ts`'s own `AgentPluginUninstallPreview` for the sibling family,
|
|
55
55
|
* for the identical reason: the preview carries no host path, only the fields a dialog may say out
|
|
56
56
|
* loud. */
|
|
57
57
|
export interface PluginUninstallPreview {
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* shared contribution-loader object contract and yields { exported }. */
|
|
3
3
|
/**
|
|
4
4
|
* @file `createTier2ImportSeam()` — the `importModule` a Tier-2 plugin's `loadPlugin()` call is
|
|
5
|
-
* given
|
|
5
|
+
* given. It never imports the plugin's code into the server process. Instead it
|
|
6
6
|
* probes the plugin in a fresh worker (import + setup + report attached hooks) and returns a
|
|
7
7
|
* PROXY `definePlugin()` module whose `setup()` attaches an RPC filter: each filter call is one
|
|
8
8
|
* more fresh worker that imports, sets up, runs the real filter and replies.
|
|
9
9
|
*
|
|
10
|
-
* Injected through `loadPlugin()`'s own `importModule` option, so
|
|
10
|
+
* Injected through `loadPlugin()`'s own `importModule` option, so the ordering is untouched: integrity
|
|
11
11
|
* and sdkRange are verified before this function is ever called (it IS step 3), and the proxy then
|
|
12
12
|
* goes through the same export validation, capability-scoped `setup()` and attach path as an
|
|
13
13
|
* in-process plugin. Probe failures are mapped onto the loader's own reasons rather than new ones:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file The Tier-2 plugin ABI wire protocol
|
|
2
|
+
* @file The Tier-2 plugin ABI wire protocol: what the server sends a fresh worker
|
|
3
3
|
* for one call, and what the worker replies. Both directions are structured-clone-only data — no
|
|
4
4
|
* functions, no class instances, no live core objects — because they cross a `worker_threads`
|
|
5
5
|
* boundary, and because the same messages must later cross a real process sandbox unchanged.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* capability-scoped SDK, then either report which hooks it attached (`probe`, run once at enable
|
|
9
9
|
* time) or run its beforeSave filter on one entry (`beforeSave`, run per save/preview).
|
|
10
10
|
*/
|
|
11
|
-
import type { ContentEntryDraft, HookContext } from "
|
|
11
|
+
import type { ContentEntryDraft, HookContext } from "@jini-ai/core/contracts/plugin-sdk";
|
|
12
12
|
import type { PluginCapability } from "../manifest.js";
|
|
13
13
|
/** Everything the worker needs to know about the plugin — taken from the already-validated
|
|
14
14
|
* manifest on the server side; the worker never reads a manifest itself. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PluginSdkBinding, PluginModuleImportPort } from "../ports.js";
|
|
2
|
+
import type { BeforeSaveFilter } from "@jini-ai/core/contracts/plugin-sdk";
|
|
2
3
|
import type { CapabilityScopedSdkCoreDeps } from "../capability-sdk.js";
|
|
3
4
|
import type { Tier2Reply, Tier2Request } from "./protocol.js";
|
|
4
5
|
export interface RunTier2CallRequired {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The application injects the existing invocation and export-validation owners. */
|
|
2
2
|
/**
|
|
3
|
-
* @file `runTier2Call()` — the worker-side half of one Tier-2 plugin call
|
|
3
|
+
* @file `runTier2Call()` — the worker-side half of one Tier-2 plugin call.
|
|
4
4
|
*
|
|
5
5
|
* Pure apart from the injected importer: import the plugin, validate its `definePlugin()` export
|
|
6
6
|
* with the SAME check `loadPlugin()` uses, build the SAME capability-scoped SDK over the SAME
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* `{ ok: false, stage, error }` reply instead of a throw, so the server can tell "the plugin's code
|
|
10
10
|
* failed" (a reply) from "the worker itself died or ran out of time" (a rejected call).
|
|
11
11
|
*
|
|
12
|
-
* The server-side manifest checks (integrity, sdkRange
|
|
12
|
+
* The server-side manifest checks (integrity, sdkRange) have already run before any
|
|
13
13
|
* request reaches this function; it never sees a plugin the loader has not cleared.
|
|
14
14
|
*/
|
|
15
15
|
import path from "node:path";
|
|
@@ -15,7 +15,7 @@ export async function startTier2Worker(required, optional = {}) {
|
|
|
15
15
|
throw new Error("the tier-2 plugin worker must run inside a worker_threads Worker");
|
|
16
16
|
let importModule = optional.importModule;
|
|
17
17
|
if (!importModule) {
|
|
18
|
-
//
|
|
18
|
+
// Per worker: main-thread `module.register()` hooks do not reach a worker spawned
|
|
19
19
|
// with `execArgv: []` (measured, Node v24.2.0), so without this a site plugin's
|
|
20
20
|
// SDK imports (including the legacy alias) fail, or resolve to a copy planted next to the plugin. Registered
|
|
21
21
|
// before the plugin's first import.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/plugins",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3-next.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": {
|
|
@@ -28,10 +28,8 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"optionalPeers": {
|
|
31
|
-
"@jini-ai/platform": "opt-in: platform-backed adapters; import @jini-ai/plugins/host/node — Platform-backed adapters could not load @jini-ai/platform. Install @jini-ai/platform to enable this feature, or check its installed version and native binaries.",
|
|
32
31
|
"semver": "opt-in: plugin version compatibility; import @jini-ai/plugins/host — Plugin version compatibility could not load semver. Install semver to enable this feature, or check its installed version and native binaries.",
|
|
33
|
-
"kysely": "opt-in: sql storage adapters; import @jini-ai/plugins/host/sql — SQL storage adapters could not load kysely. Install kysely to enable this feature, or check its installed version and native binaries."
|
|
34
|
-
"@jini-ai/db": "opt-in: database-backed adapters; import @jini-ai/plugins/host/sql — Database-backed adapters could not load @jini-ai/db. Install @jini-ai/db to enable this feature, or check its installed version and native binaries."
|
|
32
|
+
"kysely": "opt-in: sql storage adapters; import @jini-ai/plugins/host/sql — SQL storage adapters could not load kysely. Install kysely to enable this feature, or check its installed version and native binaries."
|
|
35
33
|
}
|
|
36
34
|
},
|
|
37
35
|
"type": "module",
|
|
@@ -85,34 +83,26 @@
|
|
|
85
83
|
"registry": "https://registry.npmjs.org"
|
|
86
84
|
},
|
|
87
85
|
"dependencies": {
|
|
88
|
-
"@jini-ai/core": "^0.7.
|
|
86
|
+
"@jini-ai/core": "^0.7.3-next.1"
|
|
89
87
|
},
|
|
90
88
|
"peerDependencies": {
|
|
91
|
-
"@jini-ai/platform": "^0.7.0",
|
|
92
89
|
"semver": "^7.6.2",
|
|
93
|
-
"kysely": "^0.29.6"
|
|
94
|
-
"@jini-ai/db": "^0.7.0"
|
|
90
|
+
"kysely": "^0.29.6"
|
|
95
91
|
},
|
|
96
92
|
"devDependencies": {
|
|
97
93
|
"semver": "^7.6.2",
|
|
98
94
|
"@types/semver": "^7.5.8",
|
|
99
95
|
"kysely": "^0.29.6",
|
|
100
|
-
"@jini-ai/core": "^0.7.
|
|
101
|
-
"@jini-ai/
|
|
102
|
-
"@jini-ai/
|
|
96
|
+
"@jini-ai/core": "^0.7.3-next.1",
|
|
97
|
+
"@jini-ai/db": "0.7.3-next.1",
|
|
98
|
+
"@jini-ai/platform": "^0.7.3-next.1"
|
|
103
99
|
},
|
|
104
100
|
"peerDependenciesMeta": {
|
|
105
|
-
"@jini-ai/platform": {
|
|
106
|
-
"optional": true
|
|
107
|
-
},
|
|
108
101
|
"semver": {
|
|
109
102
|
"optional": true
|
|
110
103
|
},
|
|
111
104
|
"kysely": {
|
|
112
105
|
"optional": true
|
|
113
|
-
},
|
|
114
|
-
"@jini-ai/db": {
|
|
115
|
-
"optional": true
|
|
116
106
|
}
|
|
117
107
|
},
|
|
118
108
|
"scripts": {
|