@jini-ai/plugins 0.7.3-next.1 → 0.7.3-next.3

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +53 -0
  3. package/dist/host/activation-polling.d.ts +67 -0
  4. package/dist/host/activation-polling.js +113 -0
  5. package/dist/host/activation.d.ts +2 -30
  6. package/dist/host/capability-tools.d.ts +1 -0
  7. package/dist/host/capability-tools.js +4 -4
  8. package/dist/host/contributions.d.ts +2 -9
  9. package/dist/host/hook-refusals.d.ts +49 -0
  10. package/dist/host/hook-refusals.js +65 -0
  11. package/dist/host/index.d.ts +3 -1
  12. package/dist/host/index.js +1 -0
  13. package/dist/host/manifest.js +2 -2
  14. package/dist/host/node/browser-provider-assets.d.ts +2 -1
  15. package/dist/host/node/browser-provider-assets.js +2 -2
  16. package/dist/host/node/discovery.js +5 -5
  17. package/dist/host/node/install.d.ts +6 -1
  18. package/dist/host/node/install.js +22 -20
  19. package/dist/host/node/integrity-command.d.ts +2 -1
  20. package/dist/host/node/integrity-command.js +3 -3
  21. package/dist/host/node/loader.d.ts +3 -2
  22. package/dist/host/node/loader.js +6 -6
  23. package/dist/host/node/module-snapshot.d.ts +4 -3
  24. package/dist/host/node/module-snapshot.js +5 -5
  25. package/dist/host/node/package-files.d.ts +2 -1
  26. package/dist/host/node/package-files.js +6 -6
  27. package/dist/host/node/runtime-activation.d.ts +35 -0
  28. package/dist/host/node/runtime-activation.js +188 -0
  29. package/dist/host/node/runtime-boot.d.ts +16 -0
  30. package/dist/host/node/runtime-boot.js +153 -0
  31. package/dist/host/node/runtime-conflicts.d.ts +38 -0
  32. package/dist/host/node/runtime-conflicts.js +42 -0
  33. package/dist/host/node/runtime-contracts.d.ts +5 -3
  34. package/dist/host/node/runtime-core.js +65 -465
  35. package/dist/host/node/runtime-load-target.d.ts +14 -0
  36. package/dist/host/node/runtime-load-target.js +15 -0
  37. package/dist/host/node/runtime-reload.d.ts +12 -0
  38. package/dist/host/node/runtime-reload.js +107 -0
  39. package/dist/host/node/runtime-state.d.ts +52 -0
  40. package/dist/host/node/runtime-state.js +50 -0
  41. package/dist/host/node/source-drafts.d.ts +1 -1
  42. package/dist/host/node/source-drafts.js +17 -15
  43. package/dist/host/plugin-claims.d.ts +2 -9
  44. package/dist/host/plugin-format.d.ts +5 -5
  45. package/dist/host/plugin-format.js +9 -10
  46. package/dist/host/ports.d.ts +4 -28
  47. package/dist/host/tools/install.js +1 -1
  48. package/dist/host/uninstall.d.ts +2 -2
  49. package/dist/host/worker/import-policy.d.ts +49 -0
  50. package/dist/host/worker/import-policy.js +86 -0
  51. package/dist/host/worker/import-seam.js +21 -2
  52. package/dist/host/worker/index.d.ts +1 -0
  53. package/dist/host/worker/index.js +1 -0
  54. package/dist/host/worker/protocol.d.ts +4 -0
  55. package/dist/host/worker/run-call.js +2 -1
  56. package/dist/host/worker/start.d.ts +18 -1
  57. package/dist/host/worker/start.js +27 -6
  58. package/dist/react/PluginProviderSettingsDialog.d.ts +144 -0
  59. package/dist/react/PluginProviderSettingsDialog.js +54 -0
  60. package/dist/react/plugin-install-port.d.ts +29 -0
  61. package/dist/react/plugin-install-port.js +15 -0
  62. package/dist/runtime/agent-tools.d.ts +174 -0
  63. package/dist/runtime/agent-tools.js +121 -0
  64. package/dist/runtime/built-ins/word-count/count-words.d.ts +21 -0
  65. package/dist/runtime/built-ins/word-count/count-words.js +48 -0
  66. package/dist/runtime/built-ins/word-count/plugin.d.ts +6 -0
  67. package/dist/runtime/built-ins/word-count/plugin.js +12 -0
  68. package/dist/runtime/capability-card.d.ts +22 -0
  69. package/dist/runtime/capability-card.js +30 -0
  70. package/dist/runtime/enable-confirmation-ui.d.ts +28 -0
  71. package/dist/runtime/enable-confirmation-ui.js +54 -0
  72. package/dist/runtime/install-consent.d.ts +12 -0
  73. package/dist/runtime/install-consent.js +27 -0
  74. package/dist/runtime/install-source.d.ts +26 -0
  75. package/dist/runtime/install-source.js +61 -0
  76. package/dist/runtime/install-tool-catalog.d.ts +9 -0
  77. package/dist/runtime/install-tool-catalog.js +25 -0
  78. package/dist/runtime/lower-tool-access.d.ts +17 -0
  79. package/dist/runtime/lower-tool-access.js +14 -0
  80. package/dist/runtime/plugin-export.d.ts +13 -0
  81. package/dist/runtime/plugin-export.js +14 -0
  82. package/dist/runtime/plugin-host-copy.d.ts +17 -0
  83. package/dist/runtime/plugin-host-copy.js +7 -0
  84. package/dist/runtime/plugin-tool-ids.d.ts +18 -0
  85. package/dist/runtime/plugin-tool-ids.js +4 -0
  86. package/dist/runtime/plugin-tool-messages.d.ts +97 -0
  87. package/dist/runtime/plugin-tool-messages.js +90 -0
  88. package/dist/runtime/sdk-resolver.d.ts +60 -0
  89. package/dist/runtime/sdk-resolver.js +97 -0
  90. package/dist/runtime/service-ports.d.ts +43 -0
  91. package/dist/runtime/service-ports.js +3 -0
  92. package/dist/runtime/source-tool-catalog.d.ts +7 -0
  93. package/dist/runtime/source-tool-catalog.js +33 -0
  94. package/dist/runtime/uninstall-confirmation-ui.d.ts +31 -0
  95. package/dist/runtime/uninstall-confirmation-ui.js +38 -0
  96. package/dist/runtime/widget-partials.d.ts +22 -0
  97. package/dist/runtime/widget-partials.js +13 -0
  98. package/dist/site/lipay/manifest.d.ts +10 -0
  99. package/dist/site/lipay/manifest.js +96 -0
  100. package/dist/site/store/manifest.d.ts +10 -0
  101. package/dist/site/store/manifest.js +37 -0
  102. package/package.json +158 -8
  103. package/dist/host/provider-config-source.d.ts +0 -47
  104. package/dist/host/provider-config-source.js +0 -2
@@ -0,0 +1,121 @@
1
+ /** No arguments — `content_read.plugin` takes none. */
2
+ const NO_INPUT_SCHEMA = {
3
+ type: "object",
4
+ additionalProperties: false,
5
+ required: [],
6
+ properties: {},
7
+ };
8
+ const setEnabledSchema = ({ copy }) => ({
9
+ type: "object",
10
+ additionalProperties: false,
11
+ required: ["family", "pluginId", "enabled"],
12
+ properties: {
13
+ family: {
14
+ type: "string",
15
+ enum: ["site-runtime", "agent-plugin"],
16
+ description: `Which plugin SYSTEM the id belongs to. Required, and never guessed — ${copy.productName} has two unrelated systems that share the word 'plugin'. ` +
17
+ "Use 'agent-plugin' for an Agent Plugin (an agent-plugins.org package with a plugin.json, skills and an optional mcp.json — " +
18
+ `anything search_agent_plugin_local returned, e.g. an image/video plugin). Use 'site-runtime' for a ${copy.sitePluginFormat} site/runtime plugin — ` +
19
+ `anything ${copy.pluginListToolName} returned. If you did not get the id from one of those two tools, call the matching one first rather ` +
20
+ "than picking a family.",
21
+ },
22
+ pluginId: {
23
+ type: "string",
24
+ minLength: 1,
25
+ description: `The plugin id. For family 'site-runtime', as returned by ${copy.pluginListToolName}. For family 'agent-plugin', the plugin.json 'name' as ` +
26
+ "returned by search_agent_plugin_local. An id that is not installed/discovered in THIS workspace is refused, and nothing is written.",
27
+ },
28
+ enabled: {
29
+ type: "boolean",
30
+ description: "true to enable, false to disable. ENABLING ALWAYS ASKS THE HUMAN FIRST — this tool opens a confirmation dialog and waits for the " +
31
+ "answer, because turning a plugin on changes what you yourself can do next; do not promise the user it is on until this call returns " +
32
+ "with changed:true. Disabling is not confirmed (it only removes capability). For family 'site-runtime', enabling a plugin whose " +
33
+ "manifest declares a data module runs schema DDL against the live database (snapshot-protected, transactional schema changes" +
34
+ ") and is refused unless the plugin's discovery status is 'valid'; disabling has no such precondition. For family 'agent-plugin', " +
35
+ "enabling reports restartRequired:true for the legacy agent_plugin_<id> registration only. Load its guidance now with " +
36
+ "load_agent_plugin and use agent_plugin_connect if it needs account sign-in. Continue with available tools; do not ask the person " +
37
+ `to restart ${copy.productName} or claim an unavailable tool is ready.`,
38
+ },
39
+ },
40
+ });
41
+ const uninstallSchema = ({ copy }) => ({
42
+ type: "object",
43
+ additionalProperties: false,
44
+ required: ["family", "pluginId"],
45
+ properties: {
46
+ family: {
47
+ type: "string",
48
+ enum: ["site-runtime", "agent-plugin"],
49
+ description: "Which plugin SYSTEM the id belongs to. Required, and never guessed — same rule as plugins_set_enabled's 'family' " +
50
+ `argument, and the same reason: ${copy.productName} has two unrelated systems that share the word 'plugin'. Use 'agent-plugin' for an ` +
51
+ "Agent Plugin (an agent-plugins.org package — anything search_agent_plugin_local returned). Use 'site-runtime' for a " +
52
+ `${copy.sitePluginFormat} site/runtime plugin (anything ${copy.pluginListToolName} returned). If you did not get the id from one of those ` +
53
+ "two tools, call the matching one first rather than picking a family.",
54
+ },
55
+ pluginId: {
56
+ type: "string",
57
+ minLength: 1,
58
+ description: `The plugin id. For family 'site-runtime', as returned by ${copy.pluginListToolName} — must be a site-installed plugin (a ` +
59
+ "built-in has no on-disk artifact to remove and this is refused). For family 'agent-plugin', the plugin.json 'name' as " +
60
+ `returned by search_agent_plugin_local — must be installed in this workspace and not bundled with ${copy.productName}.`,
61
+ },
62
+ },
63
+ });
64
+ /**
65
+ * The Plugins domain's fixed agent-tool catalog — the three operations `routes/admin/plugins/`
66
+ * exposes (list, set-enabled, uninstall — see this file's header for install/upload's absence).
67
+ *
68
+ * Ordered read-tool-first, matching the house convention (`Jini packages/user-management/src/server/agent-tools.ts`'s own
69
+ * rationale): a model cannot enable/disable/uninstall a plugin it does not know the id of, and
70
+ * `content_read.plugin` is the only way to learn one.
71
+ */
72
+ export function createPluginAgentToolCatalog({ copy }, _optional = {}) {
73
+ return [
74
+ {
75
+ name: "plugins_list",
76
+ description: "Read the plugin inventory: every discovered plugin (built-in and site-installed) with its id, name, version, source, trust tier, validation status, current enabled state, and any validation errors. Read-only. Also returns agentPlugins: every installed Agent Plugin (pluginId, version, archiveDigest, skill names, and exports with component/version/props schema/consent/availability and a ready embed snippet).",
77
+ sideEffects: "none",
78
+ authorization: { permission: "admin.plugins.read" },
79
+ inputSchema: NO_INPUT_SCHEMA,
80
+ },
81
+ {
82
+ name: "plugins_set_enabled",
83
+ description: `Turns a plugin ON or OFF. This is the ONE tool for enabling and disabling plugins, and it covers BOTH of ${copy.productName}'s plugin systems — ` +
84
+ "say which with the required 'family' argument: 'agent-plugin' for an Agent Plugin found by search_agent_plugin_local (e.g. the " +
85
+ `image/video plugin), 'site-runtime' for a ${copy.sitePluginFormat} site plugin listed by ${copy.pluginListToolName}. Use this when the ` +
86
+ "user asks to enable, disable, turn on, turn off, activate or deactivate a plugin, or when a plugin you need is installed but not " +
87
+ "active. Every enable opens the owner's approval card, including site plugins sealed here with plugin_source_seal. " +
88
+ "For Agent Plugins the same card lists the external MCP sources, declared tools and may-write grants to turn on; discovery reloads after approval. " +
89
+ "Disabling is not confirmed. Author site-local behavior with plugin_source_create/open → write/edit → seal → enable (family 'site-runtime'). " +
90
+ "Site plugins support content filters, content types and fields, plus sdk.routes.add (http.route.register + contributes.routes, mounted under /api/p/<plugin-id>), sdk.tools.add (tools.register + contributes.tools, ids p_<normalized-plugin-id>__<name>), and sdk.widgets.add (render.contribute + contributes.widgets, public SSR partials). Refuses to enable a site-runtime plugin whose discovery status is 'invalid' " +
91
+ "or 'incompatible'; enabling one with a data module runs live schema DDL (snapshot-protected, transactional schema changes) — reversible in the sense that disabling flips the " +
92
+ "activation flag back, but not a pure no-op toggle. Installing and uninstalling are SEPARATE tools, deliberately: this one only flips " +
93
+ "an already-installed plugin's switch and its listed access; it never installs or removes plugin packages.",
94
+ sideEffects: "mutates-durable-state",
95
+ authorization: { permission: "admin.plugins.enable" },
96
+ inputSchema: setEnabledSchema({ copy }),
97
+ },
98
+ {
99
+ name: "plugins_uninstall",
100
+ description: `Uninstalls a plugin. This is the ONE tool for uninstalling plugins, and it covers BOTH of ${copy.productName}'s plugin systems — say ` +
101
+ "which with the required 'family' argument, same as plugins_set_enabled. For family 'site-runtime': moves a " +
102
+ "site-installed plugin to the Trash (restorable for 60 days from Admin → Trash; only a human can delete it permanently), " +
103
+ "removing it for all workspaces on this site. Refused if the plugin is a built-in (nothing to remove), or if it is " +
104
+ "currently enabled in ANY workspace (the on-disk artifact is shared across every workspace this instance serves, so " +
105
+ "removing it while another workspace still has it enabled would silently break that workspace) — call " +
106
+ "plugins_set_enabled with enabled:false everywhere it is on first. For family 'agent-plugin': PERMANENTLY removes the " +
107
+ `Agent Plugin from THIS workspace — its package and activation record. This is NOT reversible from inside ${copy.productName}: there ` +
108
+ "is no Trash for this family, and reinstalling means re-running the install with the plugin's archive. Refused if the " +
109
+ `id is not installed in this workspace or is BUNDLED with ${copy.productName} (bundled plugins are re-seeded on every boot) — call ` +
110
+ "plugins_set_enabled with family 'agent-plugin' and enabled false instead. Either way, ALWAYS ASKS THE HUMAN FIRST: " +
111
+ "this tool opens a confirmation dialog and waits for their answer; nothing is removed unless they confirm, and a " +
112
+ "cancel or no answer comes back as a result, not an error.",
113
+ sideEffects: "deletes-durable-state",
114
+ authorization: { permission: "admin.plugins.enable" },
115
+ inputSchema: uninstallSchema({ copy }),
116
+ },
117
+ ];
118
+ }
119
+ /** The tool id the common access card asks the Host to call back. Single source of truth for both halves. */
120
+ export const PLUGINS_SET_ENABLED_TOOL_ID = 'plugins_set_enabled';
121
+ //# sourceMappingURL=agent-tools.js.map
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file The bundled `word-count` plugin's pure tokenizer (SPEC-005 REQ-09; RT-005 pinned tokenization).
3
+ * The plugin's manifest, SDK binding and source location stay with the host that bundles it; only this
4
+ * I/O-free count lives here.
5
+ *
6
+ * REQ-09's pinned tokenization algorithm (RT-005): concatenate all `text`-node string values in
7
+ * `bodyJson` (depth-first) with single spaces, trim, split on `/\s+/`, count non-empty tokens.
8
+ */
9
+ /**
10
+ * REQ-09's pinned algorithm: walk `bodyJson` depth-first collecting every `text`-node string
11
+ * value (TipTap-shaped document tree: `{ type, text?, content?: [...] }`), join with single
12
+ * spaces, trim, split on `/\s+/`, count non-empty tokens. Pure — no I/O.
13
+ *
14
+ * @param required.bodyJson - The entry's TipTap-shaped document (`ContentEntryDraft.bodyJson`).
15
+ * @returns The non-empty whitespace-delimited token count of every text node's concatenated value.
16
+ * @complexity O(n) over the document's total node count.
17
+ */
18
+ export declare function countWords({ bodyJson }: {
19
+ bodyJson: unknown;
20
+ }, _optional?: {}): number;
21
+ //# sourceMappingURL=count-words.d.ts.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @file The bundled `word-count` plugin's pure tokenizer (SPEC-005 REQ-09; RT-005 pinned tokenization).
3
+ * The plugin's manifest, SDK binding and source location stay with the host that bundles it; only this
4
+ * I/O-free count lives here.
5
+ *
6
+ * REQ-09's pinned tokenization algorithm (RT-005): concatenate all `text`-node string values in
7
+ * `bodyJson` (depth-first) with single spaces, trim, split on `/\s+/`, count non-empty tokens.
8
+ */
9
+ /**
10
+ * REQ-09's pinned algorithm: walk `bodyJson` depth-first collecting every `text`-node string
11
+ * value (TipTap-shaped document tree: `{ type, text?, content?: [...] }`), join with single
12
+ * spaces, trim, split on `/\s+/`, count non-empty tokens. Pure — no I/O.
13
+ *
14
+ * @param required.bodyJson - The entry's TipTap-shaped document (`ContentEntryDraft.bodyJson`).
15
+ * @returns The non-empty whitespace-delimited token count of every text node's concatenated value.
16
+ * @complexity O(n) over the document's total node count.
17
+ */
18
+ export function countWords({ bodyJson }, _optional = {}) {
19
+ const texts = [];
20
+ // Depth-first walk. Every node's own `text` is collected before its `content` children are
21
+ // visited, so the collected order is document order. Non-object nodes, nodes without `text`,
22
+ // and nodes without `content` are all simply skipped — never an error (RT-005: an image node
23
+ // contributes nothing rather than throwing).
24
+ const visit = ({ node }, _optional = {}) => {
25
+ if (typeof node !== "object" || node === null)
26
+ return;
27
+ if (Array.isArray(node)) {
28
+ for (const child of node)
29
+ visit({ node: child });
30
+ return;
31
+ }
32
+ const { text, content } = node;
33
+ if (typeof text === "string")
34
+ texts.push(text);
35
+ if (Array.isArray(content)) {
36
+ for (const child of content)
37
+ visit({ node: child });
38
+ }
39
+ };
40
+ visit({ node: bodyJson });
41
+ // RT-005's literal wording: join EVERY collected text-node value with single spaces (not only
42
+ // the ones separated by a block boundary), trim, split on `/\s+/`, count non-empty tokens.
43
+ const joined = texts.join(" ").trim();
44
+ if (joined === "")
45
+ return 0;
46
+ return joined.split(/\s+/).filter((token) => token !== "").length;
47
+ }
48
+ //# sourceMappingURL=count-words.js.map
@@ -0,0 +1,6 @@
1
+ import type { PluginSdkBinding } from "../../../host/ports.js";
2
+ /** The executable half of the bundled artifact. Registration occurs only inside `setup()` so the
3
+ * end-to-end enable test proves `loadPlugin()` reached BR-01 step (4), not merely that the module
4
+ * happened to be statically imported by the server bundle. */
5
+ export declare function createWordCountPlugin({ definePlugin, beforeSaveHook }: Pick<PluginSdkBinding, "definePlugin" | "beforeSaveHook">, _optional?: {}): ReturnType<PluginSdkBinding["definePlugin"]>;
6
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { countWords } from "./count-words.js";
2
+ /** The executable half of the bundled artifact. Registration occurs only inside `setup()` so the
3
+ * end-to-end enable test proves `loadPlugin()` reached BR-01 step (4), not merely that the module
4
+ * happened to be statically imported by the server bundle. */
5
+ export function createWordCountPlugin({ definePlugin, beforeSaveHook }, _optional = {}) {
6
+ return definePlugin({
7
+ setup(sdk) {
8
+ sdk.addFilter(beforeSaveHook, async (entry) => ({ count: countWords({ bodyJson: "bodyJson" in entry ? entry.bodyJson : undefined }) }));
9
+ },
10
+ });
11
+ }
12
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,22 @@
1
+ /** The host passes where its Plugins admin screen lives (`pluginsAdminHref`) and its plugin list tool (`pluginListToolName`). @complexity O(1). */
2
+ export declare function createCapabilityCard({ pluginsAdminHref, pluginListToolName }: {
3
+ pluginsAdminHref: string;
4
+ pluginListToolName: string;
5
+ }, _optional?: {}): {
6
+ readonly id: "plugins";
7
+ readonly title: "Plugins";
8
+ readonly summary: "Site plugins and agent plugins extend different host surfaces.";
9
+ readonly explanation: "Inspect installed plugins, including those switched off. Agent plugins may provide mail, account tools, skills and guide topics. Before saying a provider is unavailable, call search_agent_plugin_local for it, then load_agent_plugin for its setup guidance. Enable it with plugins_set_enabled only with the person's approval; discovery does not authorize its tools.";
10
+ readonly permissions: readonly ["admin.plugins.read"];
11
+ readonly pointers: readonly [{
12
+ readonly label: "Inspect plugins";
13
+ readonly tool: string;
14
+ readonly permissions: readonly ["admin.plugins.read"];
15
+ }, {
16
+ readonly label: "Plugins admin";
17
+ readonly href: string;
18
+ readonly permissions: readonly ["admin.plugins.read"];
19
+ }];
20
+ readonly workflows: readonly [];
21
+ };
22
+ //# sourceMappingURL=capability-card.d.ts.map
@@ -0,0 +1,30 @@
1
+ /** The host passes where its Plugins admin screen lives (`pluginsAdminHref`) and its plugin list tool (`pluginListToolName`). @complexity O(1). */
2
+ export function createCapabilityCard({ pluginsAdminHref, pluginListToolName }, _optional = {}) {
3
+ return {
4
+ "id": "plugins",
5
+ "title": "Plugins",
6
+ "summary": "Site plugins and agent plugins extend different host surfaces.",
7
+ "explanation": "Inspect installed plugins, including those switched off. Agent plugins may provide mail, account tools, skills and guide topics. Before saying a provider is unavailable, call search_agent_plugin_local for it, then load_agent_plugin for its setup guidance. Enable it with plugins_set_enabled only with the person's approval; discovery does not authorize its tools.",
8
+ "permissions": [
9
+ "admin.plugins.read"
10
+ ],
11
+ "pointers": [
12
+ {
13
+ "label": "Inspect plugins",
14
+ "tool": pluginListToolName,
15
+ "permissions": [
16
+ "admin.plugins.read"
17
+ ]
18
+ },
19
+ {
20
+ "label": "Plugins admin",
21
+ "href": pluginsAdminHref,
22
+ "permissions": [
23
+ "admin.plugins.read"
24
+ ]
25
+ }
26
+ ],
27
+ "workflows": []
28
+ };
29
+ }
30
+ //# sourceMappingURL=capability-card.js.map
@@ -0,0 +1,28 @@
1
+ import type { AccessApprovalResource } from '@jini-ai/core';
2
+ import type { HumanConfirmSpec } from '@jini-ai/core/contracts/site/human-confirm';
3
+ import { type PluginFamily } from './agent-tools.js';
4
+ /** What the dialog needs to describe truthfully what is about to be switched on. */
5
+ export interface EnableConfirmationSubject {
6
+ readonly family: PluginFamily;
7
+ readonly pluginId: string;
8
+ /** The human-readable name, when the family's read model has one distinct from the id. */
9
+ readonly label?: string;
10
+ readonly version?: string;
11
+ /** Site plugins: capability entries beyond the owner's last approval (all of them the first time). */
12
+ readonly adds?: readonly string[];
13
+ readonly previousEnabled?: boolean | null;
14
+ readonly revision?: string;
15
+ readonly resources?: readonly Omit<AccessApprovalResource, 'scope'>[];
16
+ }
17
+ /**
18
+ * Describes the enable-confirmation dialog for the shared approval transport.
19
+ *
20
+ * @param spec.subject - What the human is being asked about. The plugin is NAMED, because a dialog
21
+ * that says "enable this plugin?" without saying which one is not consent.
22
+ * @complexity O(n) in the rendered field lengths.
23
+ */
24
+ export declare function describeEnableApproval({ subject, scope }: {
25
+ subject: EnableConfirmationSubject;
26
+ scope?: AccessApprovalResource['scope'];
27
+ }, _optional?: {}): HumanConfirmSpec;
28
+ //# sourceMappingURL=enable-confirmation-ui.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { PLUGINS_SET_ENABLED_TOOL_ID } from './agent-tools.js';
2
+ /** Per-family wording. Kept as data rather than branches inside the builder so the two families'
3
+ * copy can be read side by side and neither can silently inherit the other's claims. */
4
+ const FAMILY_COPY = {
5
+ "agent-plugin": {
6
+ noun: "Agent Plugin",
7
+ warning: "This lets the assistant use this plugin's guidance and tools. Each action still follows your access settings.",
8
+ },
9
+ "site-runtime": {
10
+ noun: "site plugin",
11
+ warning: "It gets full server access: it can run code on your site and change its database. Enable it only if you trust it.",
12
+ },
13
+ };
14
+ /**
15
+ * Describes the enable-confirmation dialog for the shared approval transport.
16
+ *
17
+ * @param spec.subject - What the human is being asked about. The plugin is NAMED, because a dialog
18
+ * that says "enable this plugin?" without saying which one is not consent.
19
+ * @complexity O(n) in the rendered field lengths.
20
+ */
21
+ export function describeEnableApproval({ subject, scope }, _optional = {}) {
22
+ const copy = FAMILY_COPY[subject.family];
23
+ const explanation = copy.warning + " Only the listed access is turned on. A browser sign-in may still be needed to connect your account.";
24
+ // An Agent Plugin's sentence explains; only a site plugin's (full server access) is a real warning.
25
+ const explain = subject.family === "agent-plugin" ? { notice: explanation } : { warning: explanation };
26
+ return {
27
+ toolId: PLUGINS_SET_ENABLED_TOOL_ID, errorCode: "PLUGINS",
28
+ // The title names the plugin; nothing below repeats it unless its id differs from the name shown.
29
+ title: `Enable ${subject.label ?? subject.pluginId}?`,
30
+ description: `This turns on this ${copy.noun} for this workspace.`,
31
+ ...(scope ? { access: { resources: pluginEnableAccessResources({ subject, scope }) },
32
+ // The plugin's own access rows (family, capabilities) restate Kind and Adds below; its other resources still show.
33
+ accessRowsStatedInDetails: [pluginResourceId(subject)] } : {}),
34
+ details: [
35
+ ...(subject.label !== undefined && subject.label !== subject.pluginId ? [{ label: "Plugin", value: subject.pluginId }] : []),
36
+ { label: "Kind", value: copy.noun },
37
+ ...(subject.version === undefined ? [] : [{ label: "Version", value: subject.version }]),
38
+ ...(subject.adds?.length ? [{ label: "Adds", value: subject.adds.join(", ") }] : []),
39
+ ],
40
+ ...explain, confirmLabel: "Enable",
41
+ // Cancelling posts back and resolves the parked call immediately, rather than stranding it.
42
+ cancelLabel: "Cancel",
43
+ };
44
+ }
45
+ function pluginResourceId(subject, _options = {}) {
46
+ return `plugin:${subject.family}:${subject.pluginId}`;
47
+ }
48
+ /** Translate the frozen domain proposal into the common access disclosure. */
49
+ function pluginEnableAccessResources({ subject, scope }, _options = {}) {
50
+ return [{ id: pluginResourceId(subject), label: subject.label ?? subject.pluginId,
51
+ scope, previous: { enabled: subject.previousEnabled ?? null }, proposed: { enabled: true, family: subject.family, capabilities: subject.adds ?? [] }, revision: subject.revision ?? null },
52
+ ...(subject.resources ?? []).map(resource => ({ ...resource, scope }))];
53
+ }
54
+ //# sourceMappingURL=enable-confirmation-ui.js.map
@@ -0,0 +1,12 @@
1
+ import type { PluginInstallPreview } from "../host/node/index.js";
2
+ /** What installing does to this computer, in one sentence. The CLI prompt shows it before the human
3
+ * approves; the assistant's `plugins_install` returns it as its result's `warning`. */
4
+ export declare function pluginInstallRiskSentence(required: {
5
+ preview: PluginInstallPreview;
6
+ }, _optional?: {}): string;
7
+ export declare const PLUGIN_INSTALL_STAYS_OFF = "It stays off in every workspace until you turn it on.";
8
+ /** The full trust disclosure a human reviews before a site plugin is installed. */
9
+ export declare function pluginInstallConsent(required: {
10
+ preview: PluginInstallPreview;
11
+ }, _optional?: {}): string;
12
+ //# sourceMappingURL=install-consent.d.ts.map
@@ -0,0 +1,27 @@
1
+ /** What installing does to this computer, in one sentence. The CLI prompt shows it before the human
2
+ * approves; the assistant's `plugins_install` returns it as its result's `warning`. */
3
+ export function pluginInstallRiskSentence(required, _optional = {}) {
4
+ const p = required.preview;
5
+ // A tier-1 package has nothing to run (install.ts refuses one that ships a code file), so the
6
+ // full-access warning would be false; say what it does instead.
7
+ if (p.hasCode)
8
+ return "This plugin runs code with full access to this computer and every site on it.";
9
+ const contentTypes = p.contentTypes.length > 0 ? ` It adds content types: ${p.contentTypes.join(", ")}.` : "";
10
+ return `This plugin contains no code.${contentTypes}`;
11
+ }
12
+ export const PLUGIN_INSTALL_STAYS_OFF = "It stays off in every workspace until you turn it on.";
13
+ /** The full trust disclosure a human reviews before a site plugin is installed. */
14
+ export function pluginInstallConsent(required, _optional = {}) {
15
+ const p = required.preview;
16
+ return [
17
+ `${p.name} (${p.id}) ${p.version}`,
18
+ `Trust: ${p.tier} (local / unverified publisher)`,
19
+ `Capabilities: ${p.capabilities.join(", ") || "—"}`,
20
+ `Hooks: ${p.hooks.join(", ") || "—"}`,
21
+ ...(p.warnings ?? []),
22
+ ...(p.upgradeFrom ? [`Replaces installed version ${p.upgradeFrom}.`] : []),
23
+ pluginInstallRiskSentence({ preview: p }),
24
+ PLUGIN_INSTALL_STAYS_OFF, "",
25
+ ].join("\n");
26
+ }
27
+ //# sourceMappingURL=install-consent.js.map
@@ -0,0 +1,26 @@
1
+ import { type PluginInstallRequest, type InstallAttachmentReader, type InstallArchiveFiles } from '@jini-ai/core/contracts/headless/plugin-install-source';
2
+ export declare function readPluginInstallRequest({ input: rawInput, isAbsolutePath, absolutePathMessage }: {
3
+ input: unknown;
4
+ isAbsolutePath(required: {
5
+ path: string;
6
+ }, optional?: Record<string, never>): boolean;
7
+ absolutePathMessage: string;
8
+ }, _optional?: Record<string, never>): PluginInstallRequest;
9
+ /** Bound reads BEFORE allocation; never interpret an opaque attachment id as a filesystem path. */
10
+ export declare function readPluginInstallArchive(required: {
11
+ request: PluginInstallRequest;
12
+ ownerId: string;
13
+ runId: string;
14
+ maxBytes: number;
15
+ files: InstallArchiveFiles;
16
+ messages: {
17
+ attachmentUnavailable: string;
18
+ tooLarge: string;
19
+ noReadableZip(required: {
20
+ path: string;
21
+ }, optional?: Record<string, never>): string;
22
+ };
23
+ }, optional?: {
24
+ readAttachment?: InstallAttachmentReader;
25
+ }): Promise<Uint8Array>;
26
+ //# sourceMappingURL=install-source.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { ToolInputError, requireInputRecord } from '@jini-ai/core';
2
+ import { CHAT_ATTACHMENT_REF_PATTERN } from '@jini-ai/core/contracts/headless/chat-attachment';
3
+ import {} from '@jini-ai/core/contracts/headless/plugin-install-source';
4
+ export function readPluginInstallRequest({ input: rawInput, isAbsolutePath, absolutePathMessage }, _optional = {}) {
5
+ const input = requireInputRecord({ input: rawInput });
6
+ if (!input.source || typeof input.source !== "object" || Array.isArray(input.source))
7
+ throw new ToolInputError({ message: "source is required." });
8
+ const source = input.source;
9
+ const { kind, path: sourcePath, attachmentRef } = source;
10
+ if (kind !== "folder" && kind !== "zip")
11
+ throw new ToolInputError({ message: "source.kind must be 'folder' or 'zip'." });
12
+ const location = validateInstallLocation({ source, kind, sourcePath, attachmentRef, isAbsolutePath, absolutePathMessage });
13
+ if (input.replace !== undefined && typeof input.replace !== "boolean")
14
+ throw new ToolInputError({ message: "replace must be a boolean." });
15
+ return { kind, ...location, replace: input.replace === true };
16
+ }
17
+ /** Bound reads BEFORE allocation; never interpret an opaque attachment id as a filesystem path. */
18
+ export async function readPluginInstallArchive(required, optional = {}) {
19
+ const { request, ownerId, runId, maxBytes, files, messages } = required;
20
+ if (request.attachmentRef) {
21
+ const result = await optional.readAttachment?.({ ref: request.attachmentRef, ownerId, runId }, { maxBytes });
22
+ if (!result?.ok)
23
+ throw new ToolInputError({ message: messages.attachmentUnavailable });
24
+ requireArchiveSize({ size: result.bytes.byteLength, maxBytes, tooLarge: messages.tooLarge });
25
+ return result.bytes;
26
+ }
27
+ const sourcePath = request.path;
28
+ if (sourcePath === undefined)
29
+ throw new ToolInputError({ message: "Plugin ZIP source has no path." });
30
+ let size;
31
+ try {
32
+ size = (await files.stat({ path: sourcePath })).size;
33
+ }
34
+ catch {
35
+ throw new ToolInputError({ message: messages.noReadableZip({ path: sourcePath }) });
36
+ }
37
+ requireArchiveSize({ size, maxBytes, tooLarge: messages.tooLarge });
38
+ const bytes = await files.read({ path: sourcePath });
39
+ // Re-check in case the local file grew between stat and read.
40
+ requireArchiveSize({ size: bytes.byteLength, maxBytes, tooLarge: messages.tooLarge });
41
+ return bytes;
42
+ }
43
+ function validateInstallLocation({ source, kind, sourcePath, attachmentRef, isAbsolutePath, absolutePathMessage }, _optional = {}) {
44
+ if (Object.hasOwn(source, "path") === Object.hasOwn(source, "attachmentRef"))
45
+ throw new ToolInputError({ message: "Exactly one of source.path/source.attachmentRef is required." });
46
+ if (Object.hasOwn(source, "attachmentRef")) {
47
+ if (kind !== "zip" || typeof attachmentRef !== "string" || !CHAT_ATTACHMENT_REF_PATTERN.test(attachmentRef))
48
+ throw new ToolInputError({ message: "source.attachmentRef must be an attachment:<uuid> ZIP reference." });
49
+ return { attachmentRef };
50
+ }
51
+ else {
52
+ if (typeof sourcePath !== "string" || !isAbsolutePath({ path: sourcePath }))
53
+ throw new ToolInputError({ message: absolutePathMessage });
54
+ return { path: sourcePath };
55
+ }
56
+ }
57
+ function requireArchiveSize({ size, maxBytes, tooLarge }, _optional = {}) {
58
+ if (size > maxBytes)
59
+ throw new ToolInputError({ message: tooLarge });
60
+ }
61
+ //# sourceMappingURL=install-source.js.map
@@ -0,0 +1,9 @@
1
+ import type { AgentToolDefinition } from '@jini-ai/core';
2
+ import type { PluginHostCopy } from "./plugin-host-copy.js";
3
+ export declare const PLUGINS_INSTALL_TOOL_ID = "plugins_install";
4
+ /** The `plugins_install` catalog; the host passes its product copy and its install-source JSON Schema. */
5
+ export declare function createInstallToolCatalog({ copy, installSourceSchema }: {
6
+ copy: PluginHostCopy;
7
+ installSourceSchema: Readonly<Record<string, unknown>>;
8
+ }, _optional?: {}): AgentToolDefinition[];
9
+ //# sourceMappingURL=install-tool-catalog.d.ts.map
@@ -0,0 +1,25 @@
1
+ export const PLUGINS_INSTALL_TOOL_ID = "plugins_install";
2
+ /** The `plugins_install` catalog; the host passes its product copy and its install-source JSON Schema. */
3
+ export function createInstallToolCatalog({ copy, installSourceSchema }, _optional = {}) {
4
+ return [{
5
+ name: PLUGINS_INSTALL_TOOL_ID,
6
+ description: `Installs a SITE plugin (${copy.sitePluginFormat}, the kind ${copy.pluginListToolName} lists) from a local folder or .zip on the machine ${copy.productName} runs on, or a chat ZIP source.attachmentRef (get it from chat_list_pending_attachments). ` +
7
+ "Use when the user asks to install or add a plugin from a folder or zip. The package is inspected and an invalid one is refused before " +
8
+ "anything is written; the result names its trust tier and carries a warning saying whether it runs code — tell the user. Set replace:true to replace an installed version (refused while that plugin is on). The plugin is " +
9
+ "installed OFF in every workspace — turn it on afterwards with plugins_set_enabled (family 'site-runtime'). Hosted servers refuse installs " +
10
+ `without ${copy.localInstallEnv}=1; desktop and dev sites install directly. To AUTHOR a site plugin use plugin_source_create/open, write/edit files, seal, then enable. Does not install Agent Plugins, ` +
11
+ "themes or skills, and does not download anything.",
12
+ sideEffects: "mutates-durable-state",
13
+ authorization: { permission: "admin.plugins.enable" },
14
+ inputSchema: {
15
+ type: "object",
16
+ additionalProperties: false,
17
+ required: ["source"],
18
+ properties: {
19
+ source: installSourceSchema,
20
+ replace: { type: "boolean", description: "true to replace an installed version of the same plugin id. Default false." },
21
+ },
22
+ },
23
+ }];
24
+ }
25
+ //# sourceMappingURL=install-tool-catalog.js.map
@@ -0,0 +1,17 @@
1
+ import { type NotifyToolAccessChanged } from '@jini-ai/core/tool-access-change';
2
+ /** The provider-to-assistant-face lookup this lowering needs; the host's provider-faces port satisfies it structurally. */
3
+ export interface LowerToolAccessProviderFaces {
4
+ /** A provider switch covers itself and its linked assistant faces. Used only by explicit OFF. */
5
+ affectedPluginIds?(input: {
6
+ pluginId: string;
7
+ }, options?: Record<string, never>): Promise<readonly string[]>;
8
+ }
9
+ /** A provider's OFF switch also turns its assistant faces off. Use the existing owner lookup once
10
+ * on that explicit decision, never on the answer path. Failures keep the saved OFF decision visible.
11
+ * @complexity O(linked faces) discovery from the existing provider owner, plus bounded Stop/cleanup. */
12
+ export declare function lowerPluginToolAccess({ pluginId, providerFaces, notifyRosterChanged }: {
13
+ pluginId: string;
14
+ notifyRosterChanged: NotifyToolAccessChanged;
15
+ providerFaces?: LowerToolAccessProviderFaces;
16
+ }, _optional?: {}): Promise<void>;
17
+ //# sourceMappingURL=lower-tool-access.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { ToolAccessLoweringError } from '@jini-ai/core/tool-access-change';
2
+ /** A provider's OFF switch also turns its assistant faces off. Use the existing owner lookup once
3
+ * on that explicit decision, never on the answer path. Failures keep the saved OFF decision visible.
4
+ * @complexity O(linked faces) discovery from the existing provider owner, plus bounded Stop/cleanup. */
5
+ export async function lowerPluginToolAccess({ pluginId, providerFaces, notifyRosterChanged }, _optional = {}) {
6
+ try {
7
+ const pluginIds = await providerFaces?.affectedPluginIds?.({ pluginId }) ?? [pluginId];
8
+ await notifyRosterChanged({ lowered: { pluginIds } });
9
+ }
10
+ catch {
11
+ throw new ToolAccessLoweringError();
12
+ }
13
+ }
14
+ //# sourceMappingURL=lower-tool-access.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @file `readDefinedPlugin()` — the one check that a plugin module's default export is a real
3
+ * `definePlugin()` value. Shared by `Jini/packages/plugins/src/host/node/loader.ts` (step 4, in-process) and the Tier-2 worker
4
+ * (`Jini/packages/plugins/src/host/worker/run-call.ts`), and kept in its own dependency-free module so the worker does not have to
5
+ * load the loader's install/snapshot/hashing graph just to validate an export.
6
+ */
7
+ import type { DefinedPlugin as Plugin } from "@jini-ai/core/contracts/plugin-sdk";
8
+ /** `definePlugin()`'s runtime return shape. A plain `{ setup() {} }` export is deliberately not
9
+ * accepted: only the SDK helper's opaque `{ definition }` wrapper is a valid plugin ABI value. */
10
+ export declare function readDefinedPlugin({ moduleValue }: {
11
+ moduleValue: unknown;
12
+ }, _optional?: {}): Plugin | null;
13
+ //# sourceMappingURL=plugin-export.d.ts.map
@@ -0,0 +1,14 @@
1
+ /** `definePlugin()`'s runtime return shape. A plain `{ setup() {} }` export is deliberately not
2
+ * accepted: only the SDK helper's opaque `{ definition }` wrapper is a valid plugin ABI value. */
3
+ export function readDefinedPlugin({ moduleValue }, _optional = {}) {
4
+ if (typeof moduleValue !== "object" || moduleValue === null)
5
+ return null;
6
+ const candidate = moduleValue.default;
7
+ if (typeof candidate !== "object" || candidate === null)
8
+ return null;
9
+ const definition = candidate.definition;
10
+ if (typeof definition !== "object" || definition === null)
11
+ return null;
12
+ return typeof definition.setup === "function" ? candidate : null;
13
+ }
14
+ //# sourceMappingURL=plugin-export.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file The product copy a host passes into the plugin runtime's model-facing text (tool catalogs,
3
+ * set-enabled/uninstall/install messages). Type-only: the engine names no product, no package
4
+ * format and no environment variable of its own in text a model reads, so the host supplies them.
5
+ */
6
+ /** Host product copy for plugin tool catalogs and messages. */
7
+ export interface PluginHostCopy {
8
+ /** The product name the model is told about, e.g. in "restart <productName>". */
9
+ readonly productName: string;
10
+ /** The site-plugin package format the model is told about, e.g. ".acme-plugin". */
11
+ readonly sitePluginFormat: string;
12
+ /** The environment variable that turns local plugin installs on for a hosted server. */
13
+ readonly localInstallEnv: string;
14
+ /** The host tool the model calls to list site plugins (the catalogs and messages point the model at it). */
15
+ readonly pluginListToolName: string;
16
+ }
17
+ //# sourceMappingURL=plugin-host-copy.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file The product copy a host passes into the plugin runtime's model-facing text (tool catalogs,
3
+ * set-enabled/uninstall/install messages). Type-only: the engine names no product, no package
4
+ * format and no environment variable of its own in text a model reads, so the host supplies them.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=plugin-host-copy.js.map