@jini-ai/agent-plugins 0.7.3-next.2 → 0.7.4

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 (234) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +22 -4
  3. package/calendly/README.md +29 -0
  4. package/calendly/mcp.json +1 -1
  5. package/cloudflare/lib/assets.mjs +1 -1
  6. package/cloudflare/lib/cms-forms.mjs +1 -1
  7. package/core/persistent-state.d.ts +4 -1
  8. package/core/persistent-state.js +55 -21
  9. package/dist/admin-surfaces/callback-field-inbox.d.ts +1 -6
  10. package/dist/admin-surfaces/connections/connections.d.ts +2 -6
  11. package/dist/admin-surfaces/connections/index.d.ts +3 -2
  12. package/dist/admin-surfaces/index.d.ts +3 -1
  13. package/dist/connect/access-token-tool.d.ts +1 -1
  14. package/dist/connect/access-token-tool.js +1 -1
  15. package/dist/connect/catalog.d.ts +26 -0
  16. package/dist/connect/catalog.js +42 -0
  17. package/dist/connect/connect-tool.d.ts +2 -294
  18. package/dist/connect/connect-tool.js +2 -53
  19. package/dist/connect/contracts.d.ts +257 -0
  20. package/dist/connect/contracts.js +2 -0
  21. package/dist/connect/credential-cards.d.ts +2 -0
  22. package/dist/connect/credential-cards.js +7 -4
  23. package/dist/connect/credential-save-tool.js +2 -3
  24. package/dist/connect/grant-signed-in-defaults.js +1 -1
  25. package/dist/connect/host-deps.d.ts +32 -0
  26. package/dist/connect/host-deps.js +35 -0
  27. package/dist/connect/import-access-token.js +1 -1
  28. package/dist/connect/index.d.ts +7 -2
  29. package/dist/connect/index.js +5 -2
  30. package/dist/connect/installed-plugin.d.ts +28 -0
  31. package/dist/connect/installed-plugin.js +19 -0
  32. package/dist/connect/new-site-agent-plugin-tokens.d.ts +88 -0
  33. package/dist/connect/new-site-agent-plugin-tokens.js +107 -0
  34. package/dist/connect/plugin-host/index.d.ts +1 -2
  35. package/dist/connect/plugin-host/index.js +18 -9
  36. package/dist/connect/token-sign-in.d.ts +1 -14
  37. package/dist/connect/token-sign-in.js +4 -23
  38. package/dist/core/export-props.d.ts +10 -0
  39. package/dist/core/export-props.js +31 -0
  40. package/dist/core/folder-zip-error.d.ts +5 -0
  41. package/dist/core/folder-zip-error.js +8 -0
  42. package/dist/core/host-incompatible-error.d.ts +8 -0
  43. package/dist/core/host-incompatible-error.js +9 -0
  44. package/dist/core/identity-namespace.d.ts +27 -16
  45. package/dist/core/identity-namespace.js +25 -22
  46. package/dist/core/plugin-display-name.d.ts +7 -0
  47. package/dist/core/plugin-display-name.js +11 -0
  48. package/dist/core/provider-plugin-link.d.ts +7 -0
  49. package/dist/core/provider-plugin-link.js +5 -0
  50. package/dist/{connect → core}/token-map.d.ts +11 -1
  51. package/dist/{connect → core}/token-map.js +15 -0
  52. package/dist/core/token-sign-in-list.d.ts +18 -0
  53. package/dist/core/token-sign-in-list.js +23 -0
  54. package/dist/core/update-error.d.ts +8 -0
  55. package/dist/core/update-error.js +9 -0
  56. package/dist/{lifecycle → core}/update-plan.d.ts +1 -1
  57. package/dist/ffmpeg-transcode/adapter.d.ts +74 -0
  58. package/dist/ffmpeg-transcode/adapter.js +155 -0
  59. package/dist/folder-zip-node.d.ts +2 -1
  60. package/dist/folder-zip-node.js +6 -5
  61. package/dist/folder-zip.d.ts +0 -4
  62. package/dist/folder-zip.js +1 -7
  63. package/dist/index.d.ts +3 -1
  64. package/dist/lifecycle/activation.d.ts +39 -3
  65. package/dist/lifecycle/activation.js +467 -418
  66. package/dist/lifecycle/automatic-use-offer.d.ts +62 -0
  67. package/dist/lifecycle/automatic-use-offer.js +52 -0
  68. package/dist/lifecycle/automatic-use.d.ts +33 -1
  69. package/dist/lifecycle/automatic-use.js +159 -38
  70. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  71. package/dist/lifecycle/capability-projection.d.ts +0 -1
  72. package/dist/lifecycle/capability-projection.js +92 -23
  73. package/dist/lifecycle/compatibility-metadata.d.ts +1 -0
  74. package/dist/lifecycle/compatibility-metadata.js +6 -1
  75. package/dist/lifecycle/compatibility.d.ts +1 -8
  76. package/dist/lifecycle/compatibility.js +1 -8
  77. package/dist/lifecycle/credential-card-metadata.d.ts +2 -2
  78. package/dist/lifecycle/exports.d.ts +2 -45
  79. package/dist/lifecycle/exports.js +1 -30
  80. package/dist/lifecycle/host-tools/identity.d.ts +5 -4
  81. package/dist/lifecycle/host-tools/identity.js +5 -5
  82. package/dist/lifecycle/host-tools/ports.d.ts +10 -1
  83. package/dist/lifecycle/host-tools/search-tool.js +18 -8
  84. package/dist/lifecycle/host-tools/skill-tool.js +1 -1
  85. package/dist/lifecycle/index.d.ts +20 -17
  86. package/dist/lifecycle/index.js +5 -4
  87. package/dist/lifecycle/install-from-url.d.ts +1 -2
  88. package/dist/lifecycle/install.d.ts +4 -34
  89. package/dist/lifecycle/install.js +3 -3
  90. package/dist/lifecycle/installed-package-index.d.ts +1 -1
  91. package/dist/lifecycle/installed-package-index.js +4 -4
  92. package/dist/lifecycle/layout.d.ts +21 -25
  93. package/dist/lifecycle/layout.js +79 -0
  94. package/dist/lifecycle/manifest.d.ts +10 -7
  95. package/dist/lifecycle/manifest.js +20 -15
  96. package/dist/lifecycle/mcp-provisioning.d.ts +1 -1
  97. package/dist/lifecycle/metadata.d.ts +6 -3
  98. package/dist/lifecycle/metadata.js +2 -1
  99. package/dist/lifecycle/package-paths.js +59 -56
  100. package/dist/lifecycle/persistent-state.d.ts +10 -1
  101. package/dist/lifecycle/persistent-state.js +4 -2
  102. package/dist/lifecycle/ports.d.ts +18 -6
  103. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -14
  104. package/dist/lifecycle/retire-bundled.d.ts +1 -1
  105. package/dist/lifecycle/search-projection.d.ts +17 -3
  106. package/dist/lifecycle/search-projection.js +8 -8
  107. package/dist/lifecycle/search.d.ts +1 -0
  108. package/dist/lifecycle/search.js +2 -2
  109. package/dist/lifecycle/seed-bundled.d.ts +86 -1
  110. package/dist/lifecycle/seed-bundled.js +48 -84
  111. package/dist/lifecycle/set-enabled.d.ts +1 -13
  112. package/dist/lifecycle/set-enabled.js +11 -7
  113. package/dist/lifecycle/trusted-plugin-files.d.ts +1 -1
  114. package/dist/lifecycle/trusted-plugin-files.js +33 -30
  115. package/dist/lifecycle/types.d.ts +13 -34
  116. package/dist/lifecycle/uninstall.d.ts +1 -33
  117. package/dist/lifecycle/update-store.d.ts +0 -7
  118. package/dist/lifecycle/update-store.js +1 -8
  119. package/dist/lifecycle/update.d.ts +1 -1
  120. package/dist/lifecycle/update.js +60 -10
  121. package/dist/lifecycle/yauzl-archive-reader.d.ts +7 -2
  122. package/dist/lifecycle/yauzl-archive-reader.js +11 -6
  123. package/dist/manifest.d.ts +4 -8
  124. package/dist/react/AgentPluginDetailsModal.d.ts +187 -0
  125. package/dist/react/AgentPluginDetailsModal.js +29 -0
  126. package/dist/react/agent-plugin-install-port.d.ts +24 -0
  127. package/dist/react/agent-plugin-install-port.js +15 -0
  128. package/dist/react/installed-skills-composer-source.d.ts +60 -0
  129. package/dist/react/installed-skills-composer-source.js +111 -0
  130. package/dist/react/use-agent-plugins.hooks.d.ts +211 -0
  131. package/dist/react/use-agent-plugins.hooks.js +128 -0
  132. package/dist/site/activation-effects.d.ts +17 -0
  133. package/dist/site/activation-effects.js +31 -0
  134. package/dist/site/admin-surfaces/capabilities.d.ts +29 -0
  135. package/dist/site/admin-surfaces/capabilities.js +30 -0
  136. package/dist/site/admin-surfaces/delivery-bindings.d.ts +81 -0
  137. package/dist/site/admin-surfaces/delivery-bindings.js +161 -0
  138. package/dist/site/admin-surfaces/forms.d.ts +28 -0
  139. package/dist/site/admin-surfaces/forms.js +29 -0
  140. package/dist/site/admin-surfaces/handlers.d.ts +61 -0
  141. package/dist/site/admin-surfaces/handlers.js +35 -0
  142. package/dist/site/admin-surfaces/public-config.d.ts +12 -0
  143. package/dist/site/admin-surfaces/public-config.js +28 -0
  144. package/dist/site/analytics-provider-registry.d.ts +87 -0
  145. package/dist/site/analytics-provider-registry.js +87 -0
  146. package/dist/site/archive-reader-abi.d.ts +35 -0
  147. package/dist/site/archive-reader-abi.js +25 -0
  148. package/dist/site/auth-schemes.d.ts +110 -0
  149. package/dist/site/auth-schemes.js +119 -0
  150. package/dist/site/automatic-agent-plugins.d.ts +200 -0
  151. package/dist/site/automatic-agent-plugins.js +277 -0
  152. package/dist/site/bundled-contribution-sources.d.ts +24 -0
  153. package/dist/site/bundled-contribution-sources.js +17 -0
  154. package/dist/site/bundled-id-upgrade.d.ts +115 -0
  155. package/dist/site/bundled-id-upgrade.js +169 -0
  156. package/dist/site/customize-tool.d.ts +39 -0
  157. package/dist/site/customize-tool.js +31 -0
  158. package/dist/site/deploy-split-activation.d.ts +28 -0
  159. package/dist/site/deploy-split-activation.js +21 -0
  160. package/dist/site/exports/diagnostics.d.ts +37 -0
  161. package/dist/site/exports/diagnostics.js +55 -0
  162. package/dist/site/exports/runtime.d.ts +54 -0
  163. package/dist/site/exports/runtime.js +196 -0
  164. package/dist/site/exports/source.d.ts +42 -0
  165. package/dist/site/exports/source.js +58 -0
  166. package/dist/site/host-plugin-guidance.d.ts +137 -0
  167. package/dist/site/host-plugin-guidance.js +223 -0
  168. package/dist/site/host-signals.d.ts +78 -0
  169. package/dist/site/host-signals.js +83 -0
  170. package/dist/site/install-tool.d.ts +69 -0
  171. package/dist/site/install-tool.js +192 -0
  172. package/dist/site/install-upload.d.ts +175 -0
  173. package/dist/site/install-upload.js +324 -0
  174. package/dist/site/memory-i18n.d.ts +5 -0
  175. package/dist/site/memory-i18n.js +176 -0
  176. package/dist/site/memory.d.ts +80 -0
  177. package/dist/site/memory.js +83 -0
  178. package/dist/site/plugin-memory.d.ts +80 -0
  179. package/dist/site/plugin-memory.js +86 -0
  180. package/dist/site/provider-plugin-link.d.ts +112 -0
  181. package/dist/site/provider-plugin-link.js +100 -0
  182. package/dist/site/retired-plugin-tool-aliases.d.ts +40 -0
  183. package/dist/site/retired-plugin-tool-aliases.js +41 -0
  184. package/dist/site/service-ports.d.ts +108 -0
  185. package/dist/site/service-ports.js +2 -0
  186. package/dist/site/set-enabled.d.ts +80 -0
  187. package/dist/site/set-enabled.js +42 -0
  188. package/dist/site/soon-lock.d.ts +83 -0
  189. package/dist/site/soon-lock.js +78 -0
  190. package/dist/site/supersession.d.ts +61 -0
  191. package/dist/site/supersession.js +122 -0
  192. package/dist/site/uninstall-tool.d.ts +136 -0
  193. package/dist/site/uninstall-tool.js +203 -0
  194. package/dist/site/update-effects.d.ts +47 -0
  195. package/dist/site/update-effects.js +49 -0
  196. package/ffmpeg-transcode/plugin.json +16 -0
  197. package/github/source-control/backup-push.mjs +66 -46
  198. package/github/source-control/commit-site.mjs +112 -65
  199. package/github/source-control/write-files.mjs +86 -53
  200. package/github-pages/targets/github-pages.mjs +294 -233
  201. package/google-workspace/form-destinations/mapping.mjs +15 -7
  202. package/google-workspace/form-destinations/sheets.mjs +4 -2
  203. package/google-workspace/plugin.json +1 -0
  204. package/kuinetic/CHANGELOG.md +4 -0
  205. package/kuinetic/plugin.json +4 -1
  206. package/kuinetic/skills/kuinetic/SKILL.md +1 -2
  207. package/package.json +295 -18
  208. package/persistent-state.d.ts +4 -1
  209. package/resend/adapters/resend.mjs +5 -2
  210. package/resend/plugin.json +1 -1
  211. package/s3-compatible/jini-deploy-targets.json +1 -1
  212. package/s3-compatible/object-stores/s3-compatible.mjs +27 -4
  213. package/s3-compatible/targets/s3-compatible.mjs +3 -3
  214. package/site-import/plugin.json +3 -3
  215. package/site-import/skills/site-import/SKILL.md +62 -54
  216. package/site-import/skills/site-import/references/content-mapping.md +26 -20
  217. package/slide-design/plugin.json +1 -1
  218. package/slide-design/skills/slide-design/SKILL.md +8 -2
  219. package/ui-ux-design/CHANGELOG.md +6 -0
  220. package/ui-ux-design/plugin.json +1 -1
  221. package/ui-ux-design/skills/gstack-design/SKILL.md +6 -6
  222. package/ui-ux-design/skills/ui-ux-design/SKILL.md +3 -2
  223. package/ui-ux-design/skills/ui-ux-design/references/chrome-mobile-test-matrix.md +14 -12
  224. package/ui-ux-design/skills/ui-ux-design/references/ui-loop.md +16 -17
  225. package/vercel/NOTES.md +2 -1
  226. package/vercel/object-stores/vercel-blob.mjs +3 -4
  227. package/vercel/targets/vercel.mjs +425 -351
  228. package/core/commerce-server.d.ts +0 -2
  229. package/core/commerce-server.mjs +0 -2
  230. package/dist/admin-surfaces/connections/ports.d.ts +0 -110
  231. package/dist/admin-surfaces/connections/ports.js +0 -2
  232. /package/dist/{lifecycle → core}/install-errors.d.ts +0 -0
  233. /package/dist/{lifecycle → core}/install-errors.js +0 -0
  234. /package/dist/{lifecycle → core}/update-plan.js +0 -0
@@ -0,0 +1,31 @@
1
+ /** Chat customization reuses Jini's package fork and the admin upload preview/install owner. */
2
+ import { requireInputRecord, requireString, ToolInputError } from "@jini-ai/core";
3
+ import { FolderZipError } from "../core/folder-zip-error.js";
4
+ import { zipCustomizedAgentPluginFolder } from "@jini-ai/agent-plugins/folder-zip/node";
5
+ /**
6
+ * Prepare a fork after the install tool's authorization; publication stays with that tool's owner.
7
+ * @param required Host deps, the actual assistant tool context and the host's lifecycle calls.
8
+ * @returns ZIP bytes for the existing install flow. Never writes an installed package.
9
+ * @throws {ToolInputError} Unknown/ambiguous source or invalid edit.
10
+ * @complexity O(p + e log e + b) for p installed packages, e files and bounded bytes b; no network.
11
+ */
12
+ export async function prepareCustomizedAgentPluginArchive({ deps, ctx, lifecycle }, options = {}) {
13
+ const input = requireInputRecord({ input: ctx.input });
14
+ const pluginId = requireString({ input, key: "pluginId" });
15
+ const workspaceRoot = deps.agentPluginLayout.forWorkspace({ workspaceId: deps.workspaceId }).root;
16
+ const installed = lifecycle.preferBundledAgentPluginDigests(await lifecycle.listInstalledPlugins({ workspaceRoot }), await lifecycle.readBundledAgentPluginDigests({ workspaceRoot }));
17
+ const sources = installed.filter(plugin => plugin.pluginId === pluginId);
18
+ const source = sources[0];
19
+ if (sources.length !== 1 || source === undefined)
20
+ throw new ToolInputError({ message: `Source '${pluginId}' must identify exactly one installed Agent Plugin.` });
21
+ try {
22
+ return await zipCustomizedAgentPluginFolder({ path: source.packageRoot, maxBytes: lifecycle.maxAgentPluginInstallArchiveBytes(), name: requireString({ input, key: "newId" }), identityNamespace: "jini",
23
+ edit: { path: requireString({ input, key: "path" }), oldString: requireString({ input, key: "oldString" }), newString: requireString({ input, key: "newString" }, { allowEmpty: true }) } }, options);
24
+ }
25
+ catch (error) {
26
+ if (error instanceof FolderZipError)
27
+ throw new ToolInputError({ message: error.message });
28
+ throw error;
29
+ }
30
+ }
31
+ //# sourceMappingURL=customize-tool.js.map
@@ -0,0 +1,28 @@
1
+ import type { AgentPluginActivations, AgentPluginActivationVerdict, SetAgentPluginActivationRequired, SetAgentPluginActivationOptional } from "../lifecycle/index.js";
2
+ /** @file Preserve explicit activation decisions across a plugin rename (a predecessor plugin was retired in
3
+ * favour of its successor plugin; the host injects both ids). */
4
+ /** The activation calls this step makes, from the boot's lifecycle owner. */
5
+ export interface DeploySplitActivationPort {
6
+ readonly assertAgentPluginActivationsWritable: (input: {
7
+ readonly workspaceRoot: string;
8
+ }) => Promise<void>;
9
+ readonly resolveAgentPluginActivation: (input: {
10
+ readonly workspaceRoot: string;
11
+ readonly pluginId: string;
12
+ }) => Promise<AgentPluginActivationVerdict>;
13
+ readonly readAgentPluginActivations: (input: {
14
+ readonly workspaceRoot: string;
15
+ }) => Promise<AgentPluginActivations>;
16
+ readonly setAgentPluginActivation: (required: SetAgentPluginActivationRequired, optional?: SetAgentPluginActivationOptional) => Promise<unknown>;
17
+ }
18
+ /** Rename precedes split seeding: an existing predecessor-plugin decision wins over old inheritance.
19
+ * Explicit successor decisions win, even when they disagree. Corrupt records fail closed.
20
+ * @complexity O(1), two strict verdicts and at most one activation write. */
21
+ export declare function carryPluginRenameActivation(required: {
22
+ readonly workspaceRoot: string;
23
+ readonly activations: DeploySplitActivationPort;
24
+ readonly fromPluginId: string;
25
+ readonly toPluginId: string;
26
+ readonly actor: string;
27
+ }, _optional?: Record<string, never>): Promise<void>;
28
+ //# sourceMappingURL=deploy-split-activation.d.ts.map
@@ -0,0 +1,21 @@
1
+ /** Rename precedes split seeding: an existing predecessor-plugin decision wins over old inheritance.
2
+ * Explicit successor decisions win, even when they disagree. Corrupt records fail closed.
3
+ * @complexity O(1), two strict verdicts and at most one activation write. */
4
+ export async function carryPluginRenameActivation(required, _optional = {}) {
5
+ const { workspaceRoot, activations, fromPluginId, toPluginId, actor } = required;
6
+ await activations.assertAgentPluginActivationsWritable({ workspaceRoot });
7
+ for (const pluginId of [fromPluginId, toPluginId]) {
8
+ const verdict = await activations.resolveAgentPluginActivation({ workspaceRoot, pluginId });
9
+ if (verdict.verdict === "undetermined")
10
+ throw new Error(`Cannot carry ${pluginId} activation: ${verdict.reason}`);
11
+ }
12
+ const { plugins } = await activations.readAgentPluginActivations({ workspaceRoot });
13
+ const previous = plugins[fromPluginId];
14
+ const successor = plugins[toPluginId];
15
+ if (successor !== undefined && successor.updatedBy !== "system:seed")
16
+ return;
17
+ if (previous === undefined || previous.updatedBy === "system:seed")
18
+ return;
19
+ await activations.setAgentPluginActivation({ workspaceRoot, pluginId: toPluginId, enabled: previous.enabled, actor }, { origin: "bundled" });
20
+ }
21
+ //# sourceMappingURL=deploy-split-activation.js.map
@@ -0,0 +1,37 @@
1
+ /** Editor diagnostics; CMS deliberately exposes only public fallback. */
2
+ import { ToolInputError } from "@jini-ai/core";
3
+ import type { PluginExportPackage } from "./source.js";
4
+ import type { AgentPluginExport } from "@jini-ai/core/contracts/site/agent-plugins-manifest";
5
+ import type { PluginEmbedDiagnostic } from "@jini-ai/core/contracts/site/page-html-store";
6
+ export interface SelectedPluginExport {
7
+ readonly owner: PluginExportPackage;
8
+ readonly component: string;
9
+ readonly definition: AgentPluginExport;
10
+ }
11
+ export type PluginExportSelection = {
12
+ readonly selected: SelectedPluginExport;
13
+ } | {
14
+ readonly diagnostic: PluginEmbedDiagnostic;
15
+ };
16
+ /** A typed, safe input error works in both assistant tools and the authenticated HTML route. */
17
+ export declare class PluginEmbedValidationError extends ToolInputError {
18
+ readonly code = "PLUGIN_EMBED_INVALID_PROPS";
19
+ constructor(required: {
20
+ message: string;
21
+ }, _options?: {});
22
+ }
23
+ /** Canonical names and declared aliases share one ambiguity rule; never guess a rename.
24
+ * Disabled trusted packages still reserve their canonical identity. O(p + a) catalog and aliases.
25
+ */
26
+ export declare function selectPluginExport(required: {
27
+ packages: readonly PluginExportPackage[];
28
+ config: Readonly<Record<string, unknown>>;
29
+ }, _options?: {}): PluginExportSelection;
30
+ /** Schema ownership stays in Jini; version messages stay in the authenticated host. O(props).
31
+ * No prop values, file paths or underlying I/O errors appear in these messages.
32
+ */
33
+ export declare function checkPluginExportConfig(required: {
34
+ selected: SelectedPluginExport;
35
+ config: Readonly<Record<string, unknown>>;
36
+ }, _options?: {}): PluginEmbedDiagnostic | undefined;
37
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1,55 @@
1
+ /** Editor diagnostics; CMS deliberately exposes only public fallback. */
2
+ import { ToolInputError } from "@jini-ai/core";
3
+ import { validateAgentPluginExportProps } from "../../core/export-props.js";
4
+ /** A typed, safe input error works in both assistant tools and the authenticated HTML route. */
5
+ export class PluginEmbedValidationError extends ToolInputError {
6
+ code = "PLUGIN_EMBED_INVALID_PROPS";
7
+ constructor(required, _options = {}) {
8
+ super({ message: required.message });
9
+ this.name = "PluginEmbedValidationError";
10
+ }
11
+ }
12
+ /** Canonical names and declared aliases share one ambiguity rule; never guess a rename.
13
+ * Disabled trusted packages still reserve their canonical identity. O(p + a) catalog and aliases.
14
+ */
15
+ export function selectPluginExport(required, _options = {}) {
16
+ const { packages, config } = required;
17
+ const owners = packages.filter(item => item.id === config.plugin || item.renamedFrom?.includes(config.plugin));
18
+ const owner = owners[0];
19
+ if (owners.length !== 1 || owner === undefined)
20
+ return { diagnostic: { code: "PLUGIN_UNAVAILABLE", message: owners.length > 1 ? "Plugin identity is ambiguous; visitors see your fallback." : "Plugin is unknown or unavailable; visitors see your fallback." } };
21
+ if (!owner.enabled)
22
+ return { diagnostic: { code: "PLUGIN_DISABLED", message: "Plugin is off; visitors see your fallback." } };
23
+ const entries = Object.entries(owner.exports).filter(([name, entry]) => name === config.component || entry.aliases?.includes(config.component));
24
+ const entry = entries[0];
25
+ if (entries.length !== 1 || entry === undefined)
26
+ return { diagnostic: { code: "COMPONENT_UNAVAILABLE", message: "Plugin component is unknown or ambiguous; visitors see your fallback." } };
27
+ const [component, definition] = entry;
28
+ return { selected: { owner, component, definition } };
29
+ }
30
+ /** Schema ownership stays in Jini; version messages stay in the authenticated host. O(props).
31
+ * No prop values, file paths or underlying I/O errors appear in these messages.
32
+ */
33
+ export function checkPluginExportConfig(required, _options = {}) {
34
+ const { definition } = required.selected;
35
+ // Version first: a retired or newer embed was written against another contract's props, so the
36
+ // current schema cannot judge them; it gets the savable version warning, not a blocking props error.
37
+ const versionDiagnostic = checkVersion({ definition, version: required.config.version === undefined ? 1 : required.config.version });
38
+ if (versionDiagnostic)
39
+ return versionDiagnostic;
40
+ const propsReason = validateAgentPluginExportProps({ definition, props: required.config.props === undefined ? {} : required.config.props });
41
+ if (propsReason)
42
+ return { code: "PLUGIN_EMBED_INVALID_PROPS", message: `Plugin component props are invalid: ${propsReason}. Nothing was written.` };
43
+ return undefined;
44
+ }
45
+ /** Version compatibility is independent of props validity. No side effects. O(1). */
46
+ function checkVersion({ definition, version }, _options = {}) {
47
+ if (typeof version !== "number" || !Number.isSafeInteger(version) || version < 1)
48
+ return { code: "PLUGIN_VERSION_INVALID", message: "Plugin contract version must be a positive integer; visitors see your fallback." };
49
+ if (version > definition.version)
50
+ return { code: "PLUGIN_VERSION_NEWER", message: `Page needs plugin v${version}; visitors see your fallback.` };
51
+ if (version < (definition.minVersion ?? 1))
52
+ return { code: "PLUGIN_VERSION_RETIRED", message: `Contract v${version} retired; visitors see your fallback.` };
53
+ return undefined;
54
+ }
55
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1,54 @@
1
+ import type { PluginExportsPort } from "@jini-ai/core/contracts/site/widgets-html";
2
+ import type { PluginExportCatalogPort } from '@jini-ai/core/contracts/headless/plugin-export-catalog';
3
+ import type { LoginProvider } from "@jini-ai/core/contracts/site/user-management-server";
4
+ import type { PluginEmbedDiagnostic } from "@jini-ai/core/contracts/site/page-html-store";
5
+ import { type PluginExportSource } from "./source.js";
6
+ import type { DeclaredPageHosts } from "@jini-ai/core/contracts/server/security-headers";
7
+ export interface PluginExportRenderSession extends PluginExportsPort {
8
+ headHtml(required: Record<string, never>, options?: Record<string, never>): string;
9
+ /** External hosts of the exports this page actually shows, for its content-security policy. */
10
+ declaredHosts(required: Record<string, never>, options?: Record<string, never>): DeclaredPageHosts;
11
+ }
12
+ export interface PluginExportRuntime extends PluginExportCatalogPort {
13
+ forRender(required: {
14
+ mode: "live" | "static";
15
+ }, options?: Record<string, never>): PluginExportRenderSession;
16
+ validateHtml(required: {
17
+ workspaceId: string;
18
+ html: string;
19
+ }, options?: Record<string, never>): Promise<readonly PluginEmbedDiagnostic[]>;
20
+ /** Hosts of every enabled export: a static host's header file covers the whole site at once. */
21
+ declaredHosts(required: {
22
+ workspaceId: string;
23
+ }, options?: Record<string, never>): Promise<DeclaredPageHosts>;
24
+ }
25
+ interface RuntimeDeps {
26
+ readonly workspaceId: string;
27
+ readonly source: PluginExportSource;
28
+ readonly filesPrefix: string;
29
+ readonly memberLoginStart: (input: {
30
+ workspaceId: string;
31
+ providerId: string;
32
+ }) => string;
33
+ readonly markersOfType: (input: {
34
+ html: string;
35
+ type: string;
36
+ }) => readonly {
37
+ config: Readonly<Record<string, unknown>>;
38
+ }[];
39
+ readonly embedMarkerSnippetFromConfig: (input: {
40
+ config: Readonly<Record<string, unknown>>;
41
+ }) => string;
42
+ readonly listProviders: (input: {
43
+ workspaceId: string;
44
+ }) => Promise<readonly LoginProvider[]>;
45
+ /** True when the site turned its consent banner off, so declared resources load directly. */
46
+ readonly embedConsentOff?: () => boolean;
47
+ }
48
+ /** Bind to one site. Request-local memoization shares catalog/readiness across occurrences; a new
49
+ * request observes plugin toggles. Static full/link-only exports use the same template.
50
+ * @complexity O(1) construction; work is deferred to the bounded CMS occurrence pass.
51
+ */
52
+ export declare function createPluginExportRuntime(required: RuntimeDeps, _options?: {}): PluginExportRuntime;
53
+ export {};
54
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1,196 @@
1
+ /** Admission and member-login host data for the HTML plugin-export port. */
2
+ import { escapeHtml } from "@jini-ai/core/text";
3
+ import { checkPluginExportConfig, selectPluginExport, PluginEmbedValidationError } from "./diagnostics.js";
4
+ import { pluginExportFileUrl } from "./source.js";
5
+ const newHostSets = () => ({ script: new Set(), frame: new Set(), connect: new Set() });
6
+ const hostLists = (sets) => ({ script: [...sets.script], frame: [...sets.frame], connect: [...sets.connect] });
7
+ function addHosts(required, _options = {}) {
8
+ const declared = required.definition.externalHosts ?? {};
9
+ for (const kind of ["script", "frame", "connect"])
10
+ for (const origin of declared[kind] ?? [])
11
+ required.sets[kind].add(origin);
12
+ }
13
+ /** Each host link must belong to this plugin's ready provider, not merely share a provider id.
14
+ * @complexity O(l*p) declared links and ready providers; provider admission is loaded once per session.
15
+ */
16
+ async function publicHost(required, _options = {}) {
17
+ const { owner, component, definition } = required.selected;
18
+ const host = {};
19
+ const links = Object.entries(definition.hostLinks ?? {});
20
+ const providers = links.length ? await required.providers : [];
21
+ for (const [slot, capability] of links) {
22
+ if (!capability.startsWith("member-login:"))
23
+ return undefined;
24
+ const providerId = capability.slice("member-login:".length);
25
+ if (!providers.some(provider => provider.id === providerId && provider.pluginId === owner.plugin.pluginId))
26
+ return undefined;
27
+ host[slot] = required.deps.memberLoginStart({ workspaceId: required.deps.workspaceId, providerId });
28
+ }
29
+ host.assets = Object.fromEntries(Object.entries(definition.assets ?? {}).map(([name, filename]) => [name,
30
+ pluginExportFileUrl({ prefix: required.deps.filesPrefix, pluginId: owner.plugin.pluginId, component, filename })]));
31
+ return host;
32
+ }
33
+ /** Link only declared, admitted resources. A static fallback still ships its themeable CSS/artwork.
34
+ * @complexity O(a) assets; Map keys deduplicate across repeated occurrences without global state.
35
+ */
36
+ function collectHead(required, _options = {}) {
37
+ const { owner, component, definition } = required.selected;
38
+ const urlFor = ({ filename }, _optional = {}) => escapeHtml({ text: pluginExportFileUrl({ prefix: required.deps.filesPrefix, pluginId: owner.plugin.pluginId, component, filename }) });
39
+ if (definition.styles)
40
+ required.head.set(`${owner.id}:${definition.styles}`, `<link rel="stylesheet" href="${urlFor({ filename: definition.styles })}">`);
41
+ if (required.mode !== "static")
42
+ return;
43
+ for (const filename of Object.values(definition.assets ?? {})) {
44
+ const url = urlFor({ filename });
45
+ required.head.set(url, `<link rel="preload" as="image" href="${url}">`);
46
+ }
47
+ }
48
+ /** Queue declared scripts in manifest order. A consent-gated one stays inert until the consent client
49
+ * activates it; a static copy runs scripts only for a `full` export.
50
+ * @complexity O(s) scripts; Map keys deduplicate across repeated occurrences.
51
+ */
52
+ function collectScripts(required, _options = {}) {
53
+ const { owner, component, definition } = required.selected;
54
+ if (required.mode === "static" && definition.staticExport !== "full")
55
+ return;
56
+ const held = definition.consent !== "necessary" && !required.consentOff;
57
+ for (const script of definition.scripts ?? []) {
58
+ const url = escapeHtml({ text: script.startsWith("https://") ? script : pluginExportFileUrl({ prefix: required.deps.filesPrefix, pluginId: owner.plugin.pluginId, component, filename: script }) });
59
+ required.head.set(`script:${url}`, held
60
+ ? `<script type="text/plain" data-consent-category="${definition.consent}" data-src="${url}"></script>`
61
+ : `<script src="${url}" defer></script>`);
62
+ }
63
+ }
64
+ /** Resolve one occurrence; CMS alone fills/validates HTML and stamps its preserved wrapper.
65
+ * @complexity O(p + e + props) catalog selection and schema check, plus one contained template read.
66
+ */
67
+ async function resolveExport(required, _options = {}) {
68
+ const selection = selectPluginExport({ packages: await required.packages, config: required.config });
69
+ if (!("selected" in selection))
70
+ return undefined;
71
+ const { selected } = selection;
72
+ if (checkPluginExportConfig({ selected, config: required.config }))
73
+ return undefined;
74
+ collectHead({ selected, mode: required.mode, head: required.head, deps: required.deps });
75
+ if (required.mode === "static" && selected.definition.staticExport === "fallback-only")
76
+ return undefined;
77
+ const host = await publicHost({ selected, deps: required.deps, providers: required.providers });
78
+ if (!host)
79
+ return undefined;
80
+ const consentOff = required.deps.embedConsentOff?.() === true;
81
+ collectScripts({ selected, mode: required.mode, head: required.head, consentOff, deps: required.deps });
82
+ addHosts({ sets: required.hosts, definition: selected.definition });
83
+ return exportTemplate({ selected, config: required.config, deps: required.deps, host, consentOff });
84
+ }
85
+ /** The CMS-side template for one resolved occurrence: its contract fields, template file and props.
86
+ * @complexity O(1) plus one contained template read.
87
+ */
88
+ async function exportTemplate(required, _options = {}) {
89
+ const { selected, consentOff, host } = required;
90
+ return { plugin: selected.owner.id, component: selected.component, version: selected.definition.version,
91
+ ...(selected.definition.minVersion === undefined ? {} : { minVersion: selected.definition.minVersion }), consent: selected.definition.consent, consentOff,
92
+ frameHosts: selected.definition.externalHosts?.frame ?? [], scriptData: (selected.definition.scripts?.length ?? 0) > 0,
93
+ template: await required.deps.source.readFile({ plugin: selected.owner.plugin, filename: selected.definition.template }),
94
+ props: (required.config.props === undefined ? {} : required.config.props), host };
95
+ }
96
+ /** Validate known enabled contracts before the single HTML writer mutates anything. Unknown,
97
+ * disabled and unsupported contracts remain savable with safe editor warnings. O(markers + schemas).
98
+ */
99
+ async function validateHtml(required, _options = {}) {
100
+ if (required.input.workspaceId !== required.deps.workspaceId)
101
+ throw new PluginEmbedValidationError({ message: "Plugin embed workspace does not match this site." });
102
+ const markers = required.deps.markersOfType({ html: required.input.html, type: "plugin" });
103
+ if (!markers.length)
104
+ return [];
105
+ const packages = await required.deps.source.list({ workspaceId: required.input.workspaceId }).catch(() => []);
106
+ const providers = required.deps.listProviders({ workspaceId: required.input.workspaceId }).catch(() => []);
107
+ const warnings = [];
108
+ for (const marker of markers) {
109
+ const diagnostic = await editorDiagnostic({ packages, config: marker.config, deps: required.deps, providers });
110
+ if (diagnostic?.code === "PLUGIN_EMBED_INVALID_PROPS")
111
+ throw new PluginEmbedValidationError({ message: diagnostic.message });
112
+ if (diagnostic)
113
+ warnings.push(diagnostic);
114
+ }
115
+ return warnings;
116
+ }
117
+ /** The same safe refusal reasons drive editor warnings; provider readiness never opens secrets. */
118
+ async function editorDiagnostic(required, _options = {}) {
119
+ const selection = selectPluginExport(required);
120
+ if ("diagnostic" in selection)
121
+ return selection.diagnostic;
122
+ const diagnostic = checkPluginExportConfig({ selected: selection.selected, config: required.config });
123
+ if (diagnostic)
124
+ return diagnostic;
125
+ const host = await publicHost({ selected: selection.selected, deps: required.deps, providers: required.providers });
126
+ return host ? undefined : { code: "PLUGIN_HOST_UNAVAILABLE", message: "Plugin sign-in is not configured or unavailable; visitors see your fallback." };
127
+ }
128
+ /** Catalog rows expose contracts and snippets, never templates, secrets or local file paths.
129
+ * O(exports * providers), no extra file reads per row beyond the shared catalog load.
130
+ */
131
+ async function catalogRows(required, _options = {}) {
132
+ const rows = new Map();
133
+ const providers = required.deps.listProviders({ workspaceId: required.deps.workspaceId }).catch(() => []);
134
+ for (const owner of required.packages) {
135
+ const exports = [];
136
+ for (const [component, definition] of Object.entries(owner.exports)) {
137
+ const config = { type: "plugin", plugin: owner.id, component, version: definition.version, props: {} };
138
+ const selection = selectPluginExport({ packages: required.packages, config });
139
+ const selected = { owner, component, definition };
140
+ const availability = await catalogAvailability({ selection, selected, config, providers, deps: required.deps });
141
+ exports.push({ plugin: owner.id, ...(owner.displayName ? { displayName: owner.displayName } : {}), component, version: definition.version, minVersion: definition.minVersion ?? 1, props: definition.props,
142
+ consent: definition.consent, availability, snippet: availability === "ready" ? required.deps.embedMarkerSnippetFromConfig({ config }) : null });
143
+ }
144
+ rows.set(owner.plugin.pluginId, exports);
145
+ }
146
+ return rows;
147
+ }
148
+ /** Distinguish props that the author must fill from host readiness; fixed public diagnostics. */
149
+ async function catalogAvailability(required, _options = {}) {
150
+ if ("diagnostic" in required.selection)
151
+ return required.selection.diagnostic.code;
152
+ if (!await publicHost(required))
153
+ return "host-unavailable";
154
+ return checkPluginExportConfig({ selected: required.selected, config: required.config }) ? "props-required" : "ready";
155
+ }
156
+ /** Bind to one site. Request-local memoization shares catalog/readiness across occurrences; a new
157
+ * request observes plugin toggles. Static full/link-only exports use the same template.
158
+ * @complexity O(1) construction; work is deferred to the bounded CMS occurrence pass.
159
+ */
160
+ export function createPluginExportRuntime(required, _options = {}) {
161
+ return {
162
+ forRender: ({ mode }, _options = {}) => {
163
+ let packages;
164
+ let providers;
165
+ const head = new Map();
166
+ const hosts = newHostSets();
167
+ return {
168
+ resolve: async ({ config, workspaceId }, _options = {}) => {
169
+ if (workspaceId !== required.workspaceId)
170
+ return undefined;
171
+ packages ??= required.source.list({ workspaceId });
172
+ // Readiness failures are a public fallback, never an unhandled rejected lazy promise.
173
+ providers ??= required.listProviders({ workspaceId }).catch(() => []);
174
+ return resolveExport({ config, deps: required, packages, providers, mode, head, hosts });
175
+ },
176
+ headHtml: (_input, _options = {}) => [...head.values()].join("\n"),
177
+ declaredHosts: (_input, _options = {}) => hostLists(hosts),
178
+ };
179
+ },
180
+ validateHtml: (input, _options = {}) => validateHtml({ input, deps: required }),
181
+ declaredHosts: async ({ workspaceId }, _options = {}) => {
182
+ const sets = newHostSets();
183
+ if (workspaceId !== required.workspaceId)
184
+ return hostLists(sets);
185
+ for (const owner of await required.source.list({ workspaceId })) {
186
+ if (owner.enabled)
187
+ for (const definition of Object.values(owner.exports))
188
+ addHosts({ sets, definition });
189
+ }
190
+ return hostLists(sets);
191
+ },
192
+ catalog: async ({ workspaceId }, _options = {}) => workspaceId === required.workspaceId
193
+ ? catalogRows({ packages: await required.source.list({ workspaceId }), deps: required }) : new Map(),
194
+ };
195
+ }
196
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1,42 @@
1
+ import type { parseAgentPluginManifest } from "../../lifecycle/manifest.js";
2
+ import type { TrustedPluginPackage, createAgentPluginLifecycle } from "../../lifecycle/index.js";
3
+ import type { AgentPluginExport } from "@jini-ai/core/contracts/site/agent-plugins-manifest";
4
+ import type { AgentPluginExportMetadata } from "@jini-ai/core/contracts/site/agent-plugins-lifecycle";
5
+ export interface PluginExportPackage extends AgentPluginExportMetadata {
6
+ readonly plugin: TrustedPluginPackage;
7
+ readonly id: string;
8
+ readonly displayName?: string;
9
+ readonly enabled: boolean;
10
+ readonly exports: Readonly<Record<string, AgentPluginExport>>;
11
+ }
12
+ export interface PluginExportSource {
13
+ list(required: {
14
+ workspaceId: string;
15
+ }, options?: Record<string, never>): Promise<readonly PluginExportPackage[]>;
16
+ readFile(required: {
17
+ plugin: TrustedPluginPackage;
18
+ filename: string;
19
+ }, options?: Record<string, never>): Promise<string>;
20
+ readAsset(required: {
21
+ plugin: TrustedPluginPackage;
22
+ filename: string;
23
+ }, options?: Record<string, never>): Promise<string | Uint8Array>;
24
+ }
25
+ /** Encode declared ids/paths; URL inputs are never converted into filesystem paths. O(path length). */
26
+ export declare function pluginExportFileUrl(required: {
27
+ prefix: string;
28
+ pluginId: string;
29
+ component: string;
30
+ filename: string;
31
+ }, _options?: {}): string;
32
+ /** Discover disabled declarations through the same digest gate so editors can explain fallback.
33
+ * Activation is a separate admitted set: the lifecycle's inactive callback runs before its digest
34
+ * check and therefore must never be used as a trusted catalog.
35
+ * @complexity O(p + m) packages plus manifest bytes; two bounded lifecycle catalog scans.
36
+ */
37
+ export declare function createPluginExportSource(required: {
38
+ lifecycle: Pick<ReturnType<typeof createAgentPluginLifecycle>, 'findTrustedPluginPackages' | 'readTrustedPluginFile' | 'assertContainedOnDisk'>;
39
+ parseAgentPluginManifest: typeof parseAgentPluginManifest;
40
+ readAssetFile(path: string): Promise<Uint8Array>;
41
+ }, _options?: {}): PluginExportSource;
42
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1,58 @@
1
+ /** Public-export catalog over the lifecycle's bundled digest and containment gates. */
2
+ import { orFallback } from "@jini-ai/core/errors/idioms";
3
+ /** Encode declared ids/paths; URL inputs are never converted into filesystem paths. O(path length). */
4
+ export function pluginExportFileUrl(required, _options = {}) {
5
+ return `${required.prefix}/${encodeURIComponent(required.pluginId)}/${encodeURIComponent(required.component)}/${required.filename.split("/").map(encodeURIComponent).join("/")}`;
6
+ }
7
+ /** One broken bundled package cannot hide the other exports. No raw parse/read errors escape.
8
+ * @complexity O(m) manifest bytes, one contained read.
9
+ */
10
+ async function readPackage(required, _options = {}) {
11
+ return orFallback({
12
+ work: async () => {
13
+ const raw = await required.lifecycle.readTrustedPluginFile({ plugin: required.plugin, filename: "plugin.json" });
14
+ const result = required.parseAgentPluginManifest({ value: JSON.parse(raw) });
15
+ if (!result.ok || !result.manifest.id)
16
+ return undefined;
17
+ const displayName = result.manifest.displayName;
18
+ return { ...result.manifest, ...(typeof displayName === "string" ? { displayName } : {}),
19
+ plugin: required.plugin, id: result.manifest.id, enabled: required.enabled, exports: result.manifest.exports ?? {} };
20
+ },
21
+ fallback: undefined,
22
+ step: "read plugin export manifest",
23
+ });
24
+ }
25
+ /** Discover disabled declarations through the same digest gate so editors can explain fallback.
26
+ * Activation is a separate admitted set: the lifecycle's inactive callback runs before its digest
27
+ * check and therefore must never be used as a trusted catalog.
28
+ * @complexity O(p + m) packages plus manifest bytes; two bounded lifecycle catalog scans.
29
+ */
30
+ export function createPluginExportSource(required, _options = {}) {
31
+ const { lifecycle } = required;
32
+ return {
33
+ list: async ({ workspaceId }, _options = {}) => {
34
+ const query = { workspaceId, filename: "plugin.json", contribution: "public page exports", orderByPluginId: true };
35
+ const admitted = await lifecycle.findTrustedPluginPackages({ ...query, requireActive: false });
36
+ const active = await lifecycle.findTrustedPluginPackages({ ...query, requireActive: true });
37
+ const enabled = new Set(active.flatMap(verdict => "trusted" in verdict ? [verdict.trusted.packageRoot] : []));
38
+ const packages = [];
39
+ for (const verdict of admitted) {
40
+ if (!("trusted" in verdict))
41
+ continue;
42
+ const item = await readPackage({ lifecycle, plugin: verdict.trusted, enabled: enabled.has(verdict.trusted.packageRoot), parseAgentPluginManifest: required.parseAgentPluginManifest });
43
+ if (item)
44
+ packages.push(item);
45
+ }
46
+ return packages;
47
+ },
48
+ readFile: ({ plugin, filename }, _options = {}) => lifecycle.readTrustedPluginFile({ plugin, filename }),
49
+ readAsset: async ({ plugin, filename }, _options = {}) => {
50
+ if (!filename.endsWith(".png"))
51
+ return lifecycle.readTrustedPluginFile({ plugin, filename });
52
+ // Jini's trusted text reader is UTF-8 only. Preserve PNG bytes using its same path owner;
53
+ // do not duplicate containment or join a request path to a package directory here.
54
+ return required.readAssetFile(await lifecycle.assertContainedOnDisk({ packageRoot: plugin.packageRoot, entryPath: filename }));
55
+ },
56
+ };
57
+ }
58
+ //# sourceMappingURL=source.js.map