@jini-ai/agent-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.
Files changed (235) hide show
  1. package/CHANGELOG.md +4 -6
  2. package/NOTICE +2 -0
  3. package/README.md +11 -15
  4. package/calendly/plugin.json +3 -3
  5. package/cloudflare/lib/forms.mjs +9 -10
  6. package/cloudflare/lib/target.mjs +1 -1
  7. package/cloudflare/plugin.json +3 -3
  8. package/cloudflare/worker/forms-receiver.mjs +9 -9
  9. package/composio/plugin.json +3 -3
  10. package/core/persistent-state.js +227 -163
  11. package/dist/admin-surfaces/connections/connections.d.ts +11 -6
  12. package/dist/admin-surfaces/connections/connections.js +102 -85
  13. package/dist/admin-surfaces/node.d.ts +27 -0
  14. package/dist/admin-surfaces/node.js +32 -0
  15. package/dist/admin-surfaces/plugin-state.js +21 -18
  16. package/dist/admin-surfaces/surface-client.d.ts +4 -0
  17. package/dist/admin-surfaces/surface-client.js +124 -117
  18. package/dist/admin-surfaces/surface-handlers.js +21 -17
  19. package/dist/admin-surfaces/theme.d.ts +5 -1
  20. package/dist/admin-surfaces/theme.js +3 -3
  21. package/dist/connect/access-token-tool.d.ts +3 -1
  22. package/dist/connect/access-token-tool.js +3 -2
  23. package/dist/connect/apply-connect-defaults.js +2 -2
  24. package/dist/connect/apply-tool-renames.js +9 -8
  25. package/dist/connect/connect-tool.d.ts +2 -0
  26. package/dist/connect/connect-tool.js +3 -2
  27. package/dist/connect/credential-cards.js +3 -2
  28. package/dist/connect/credential-save-tool.d.ts +14 -11
  29. package/dist/connect/credential-save-tool.js +128 -121
  30. package/dist/connect/enable-access.d.ts +2 -2
  31. package/dist/connect/enable-access.js +6 -6
  32. package/dist/connect/executable/register.js +40 -34
  33. package/dist/connect/federate-mcp.d.ts +21 -11
  34. package/dist/connect/federate-mcp.js +28 -21
  35. package/dist/connect/grant-signed-in-defaults.js +3 -3
  36. package/dist/connect/import-access-token.js +2 -1
  37. package/dist/connect/index.d.ts +1 -0
  38. package/dist/connect/index.js +1 -0
  39. package/dist/connect/plugin-credential-card.js +2 -1
  40. package/dist/connect/plugin-host/index.d.ts +9 -5
  41. package/dist/connect/plugin-host/index.js +113 -100
  42. package/dist/connect/ports.d.ts +1 -1
  43. package/dist/connect/row-update.d.ts +22 -0
  44. package/dist/connect/row-update.js +18 -0
  45. package/dist/connect/switch-on-saved-token.d.ts +4 -2
  46. package/dist/connect/switch-on-saved-token.js +1 -1
  47. package/dist/connect/token-map.d.ts +44 -0
  48. package/dist/connect/token-map.js +49 -0
  49. package/dist/core/identity-namespace.js +5 -0
  50. package/dist/folder-zip.d.ts +3 -1
  51. package/dist/folder-zip.js +2 -2
  52. package/dist/lifecycle/activation.d.ts +4 -4
  53. package/dist/lifecycle/activation.js +4 -5
  54. package/dist/lifecycle/automatic-use.js +236 -210
  55. package/dist/lifecycle/bundled-digests.d.ts +75 -12
  56. package/dist/lifecycle/bundled-digests.js +213 -212
  57. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  58. package/dist/lifecycle/bundled-source-archive.js +263 -264
  59. package/dist/lifecycle/capability-projection.d.ts +1 -1
  60. package/dist/lifecycle/capability-projection.js +1 -1
  61. package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
  62. package/dist/lifecycle/credential-card-metadata.js +27 -3
  63. package/dist/lifecycle/exports.js +9 -4
  64. package/dist/lifecycle/fetch-archive.d.ts +1 -1
  65. package/dist/lifecycle/fetch-archive.js +1 -1
  66. package/dist/lifecycle/host-tools/identity.js +3 -2
  67. package/dist/lifecycle/host-tools/ports.d.ts +2 -0
  68. package/dist/lifecycle/host-tools/search-tool.js +8 -8
  69. package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
  70. package/dist/lifecycle/host-tools/skill-tool.js +16 -8
  71. package/dist/lifecycle/index.d.ts +118 -110
  72. package/dist/lifecycle/index.js +45 -12
  73. package/dist/lifecycle/install-errors.d.ts +1 -1
  74. package/dist/lifecycle/install-from-url.d.ts +1 -1
  75. package/dist/lifecycle/install-from-url.js +1 -1
  76. package/dist/lifecycle/install.d.ts +7 -2
  77. package/dist/lifecycle/install.js +414 -396
  78. package/dist/lifecycle/installed-package-index.js +45 -42
  79. package/dist/lifecycle/layout.d.ts +1 -1
  80. package/dist/lifecycle/layout.js +1 -1
  81. package/dist/lifecycle/mail/catalog.d.ts +8 -32
  82. package/dist/lifecycle/mail/catalog.js +25 -20
  83. package/dist/lifecycle/mail/contribution.d.ts +2 -2
  84. package/dist/lifecycle/mail/contribution.js +34 -34
  85. package/dist/lifecycle/mail/selection.js +6 -2
  86. package/dist/lifecycle/manifest.d.ts +3 -3
  87. package/dist/lifecycle/manifest.js +4 -4
  88. package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
  89. package/dist/lifecycle/mcp-provisioning.js +3 -3
  90. package/dist/lifecycle/package-paths.d.ts +1 -1
  91. package/dist/lifecycle/package-paths.js +1 -1
  92. package/dist/lifecycle/persistent-state.js +1 -2
  93. package/dist/lifecycle/ports.d.ts +5 -1
  94. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
  95. package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
  96. package/dist/lifecycle/retire-bundled.d.ts +1 -52
  97. package/dist/lifecycle/retire-bundled.js +134 -84
  98. package/dist/lifecycle/search.d.ts +2 -1
  99. package/dist/lifecycle/search.js +1 -1
  100. package/dist/lifecycle/seed-bundled.d.ts +1 -1
  101. package/dist/lifecycle/seed-bundled.js +154 -155
  102. package/dist/lifecycle/set-enabled.d.ts +1 -1
  103. package/dist/lifecycle/set-enabled.js +1 -1
  104. package/dist/lifecycle/skill-file-reader.js +53 -50
  105. package/dist/lifecycle/tools/projection.d.ts +4 -7
  106. package/dist/lifecycle/tools/projection.js +109 -108
  107. package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
  108. package/dist/lifecycle/trusted-plugin-files.js +1 -1
  109. package/dist/lifecycle/uninstall.d.ts +1 -1
  110. package/dist/lifecycle/uninstall.js +237 -241
  111. package/dist/lifecycle/update-store.js +20 -17
  112. package/dist/lifecycle/update.js +287 -281
  113. package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
  114. package/dist/lifecycle/yauzl-archive-reader.js +8 -2
  115. package/dist/manifest.d.ts +11 -3
  116. package/dist/manifest.js +9 -9
  117. package/fly/jini-credential-schemes.json +11 -0
  118. package/fly/plugin.json +3 -4
  119. package/github/plugin.json +3 -3
  120. package/github/source-control/backup-push.mjs +11 -11
  121. package/github/source-control/commit-site.mjs +3 -3
  122. package/github/source-control/github.mjs +12 -6
  123. package/github/source-control/write-files.mjs +27 -28
  124. package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
  125. package/github-pages/plugin.json +3 -3
  126. package/github-pages/targets/github-pages.mjs +3 -3
  127. package/google-login/plugin.json +3 -3
  128. package/google-workspace/README.md +14 -14
  129. package/google-workspace/form-destinations/README.md +3 -3
  130. package/google-workspace/form-destinations/dedupe.mjs +1 -1
  131. package/google-workspace/form-destinations/mapping.mjs +8 -9
  132. package/google-workspace/form-destinations/sheets.mjs +1 -1
  133. package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
  134. package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
  135. package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
  136. package/google-workspace/lib/auth.mjs +2 -2
  137. package/google-workspace/lib/form-destination-settings.mjs +1 -1
  138. package/google-workspace/lib/picker-flow.mjs +2 -2
  139. package/google-workspace/lib/request-policy.mjs +1 -1
  140. package/google-workspace/lib/surface-actions.mjs +1 -1
  141. package/google-workspace/plugin.json +3 -3
  142. package/google-workspace/tools/sheets/README.md +3 -3
  143. package/google-workspace/tools/sheets-admin/README.md +3 -3
  144. package/google-workspace/ui/README.md +4 -4
  145. package/google-workspace/ui/connection-panel.mjs +51 -51
  146. package/google-workspace/ui/destination-panel.mjs +34 -34
  147. package/google-workspace/ui/dom.mjs +15 -16
  148. package/google-workspace/ui/picker-flow.mjs +2 -2
  149. package/google-workspace/ui/picker.mjs +19 -19
  150. package/google-workspace/ui/surface-client.mjs +96 -69
  151. package/higgsfield-media/plugin.json +3 -3
  152. package/jev/plugin.json +3 -3
  153. package/kuinetic/CHANGELOG.md +12 -0
  154. package/kuinetic/mcp.json +4 -0
  155. package/kuinetic/plugin.json +27 -0
  156. package/kuinetic/skills/kuinetic/SKILL.md +120 -0
  157. package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
  158. package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
  159. package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
  160. package/meilisearch/plugin.json +5 -5
  161. package/netlify/plugin.json +3 -3
  162. package/netlify/targets/netlify.mjs +14 -4
  163. package/opentelemetry/plugin.json +3 -3
  164. package/package.json +25 -20
  165. package/posthog/plugin.json +3 -3
  166. package/railway/plugin.json +3 -3
  167. package/render/plugin.json +3 -3
  168. package/resend/NOTES.md +2 -2
  169. package/resend/adapters/resend.mjs +1 -1
  170. package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
  171. package/resend/lib/domains.mjs +8 -8
  172. package/resend/plugin.json +3 -3
  173. package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
  174. package/s3-compatible/jini-object-stores.json +29 -0
  175. package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
  176. package/s3-compatible/plugin.json +3 -3
  177. package/s3-compatible/targets/s3-compatible.mjs +25 -25
  178. package/sentry/plugin.json +3 -3
  179. package/shadcn-ui/CHANGELOG.md +7 -0
  180. package/shadcn-ui/LICENSE +201 -0
  181. package/shadcn-ui/NOTICE +10 -0
  182. package/shadcn-ui/mcp.json +4 -0
  183. package/shadcn-ui/plugin.json +26 -0
  184. package/shopify/plugin.json +3 -3
  185. package/site-compliance/plugin.json +3 -3
  186. package/site-import/plugin.json +3 -3
  187. package/supabase/mcp.json +1 -4
  188. package/supabase/plugin.json +3 -3
  189. package/ui-ux-design/CHANGELOG.md +13 -0
  190. package/ui-ux-design/NOTICE +2 -0
  191. package/ui-ux-design/README.md +17 -7
  192. package/ui-ux-design/plugin.json +6 -3
  193. package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
  194. package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
  195. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
  196. package/vercel/NOTES.md +1 -1
  197. package/vercel/object-stores/vercel-blob.mjs +12 -2
  198. package/vercel/plugin.json +3 -3
  199. package/vercel/targets/vercel.mjs +3 -3
  200. package/wordpress/plugin.json +3 -3
  201. package/dist/lifecycle/node.d.ts +0 -11
  202. package/dist/lifecycle/node.js +0 -38
  203. package/fly/tovu-credential-schemes.json +0 -11
  204. package/github/deployments/github.mjs +0 -415
  205. package/s3-compatible/tovu-object-stores.json +0 -29
  206. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
  207. /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
  208. /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  209. /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  210. /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  211. /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  212. /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  213. /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
  214. /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
  215. /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  216. /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
  217. /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
  218. /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  219. /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  220. /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  221. /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  222. /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  223. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
  224. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
  225. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
  226. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
  227. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
  228. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
  229. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
  230. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
  231. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
  232. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
  233. /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
  234. /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  235. /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
@@ -8,24 +8,19 @@ function indexedMetadata({ manifest }, _optional = {}) {
8
8
  const { requires, hostRange, exports, renamedFrom } = manifest;
9
9
  return Object.fromEntries(Object.entries({ requires, hostRange, exports, renamedFrom }).filter(([, value]) => value !== undefined));
10
10
  }
11
- /** Indexes manifests and files with the same injected effects used by installation and resolution.
12
- * @complexity O(f) reads/walk work for f package files; no mutation or executable imports. */
13
- export function createInstalledPackageIndex(required, _optional = {}) {
14
- const { ports } = required;
15
- const readFile = ports.filesystem.readFile.bind(ports.filesystem);
16
- const readdir = ports.filesystem.readdir.bind(ports.filesystem);
11
+ /** Cosmetic fields are trimmed and capped rather than invalidating the package. The cap stops
12
+ * a hostile package flooding an admin row. Malformed values fall back because these fields are
13
+ * cosmetic: callers title-case the id and show the spec description when these keys are absent.
14
+ * Inner newlines remain paragraph breaks in summaries.
15
+ * @complexity O(n) in the supplied text length; output is capped at maxLength. */
16
+ function readDisplayText(required, _optional = {}) {
17
+ const text = required.manifest[required.key];
18
+ return text ? { [required.key]: text.slice(0, required.maxLength) } : {};
19
+ }
20
+ function createInstalledManifestReader(ports, readFile) {
17
21
  const parseAgentPluginManifest = (value) => parseAgentPluginManifestValue({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }) });
18
- /** Cosmetic fields are trimmed and capped rather than invalidating the package. The cap stops
19
- * a hostile package flooding an admin row. Malformed values fall back because these fields are
20
- * cosmetic: callers title-case the id and show the spec description when these keys are absent.
21
- * Inner newlines remain paragraph breaks in summaries.
22
- * @complexity O(n) in the supplied text length; output is capped at maxLength. */
23
- function readDisplayText(required, _optional = {}) {
24
- const text = required.manifest[required.key];
25
- return text ? { [required.key]: text.slice(0, required.maxLength) } : {};
26
- }
27
22
  /** Reads and validates `packageRoot`'s `plugin.json`, refusing a missing, unparseable or invalid one. */
28
- async function readInstalledManifest({ packageRoot }) {
23
+ return async function readInstalledManifest({ packageRoot }) {
29
24
  let manifestRaw;
30
25
  try {
31
26
  manifestRaw = await readFile(path.join(packageRoot, "plugin.json"), "utf8");
@@ -48,34 +43,42 @@ export function createInstalledPackageIndex(required, _optional = {}) {
48
43
  throw new AgentPluginInstallError({ code: "MANIFEST_INVALID", message: `plugin.json failed validation: ${parsed.errors.join("; ")}` });
49
44
  }
50
45
  return parsed;
51
- }
52
- /** Every regular file under `packageRoot` (sorted) and every `skills/<name>/SKILL.md` (sorted by name). */
53
- async function walkPackageTree({ packageRoot }) {
54
- const files = [];
55
- const skills = [];
56
- async function walk(absolute, prefix) {
57
- for (const entry of await readdir(absolute, { withFileTypes: true })) {
58
- const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
59
- if (entry.isDirectory()) {
60
- await walk(path.join(absolute, entry.name), relative);
61
- continue;
62
- }
63
- if (entry.isFile())
64
- files.push(relative);
65
- // Anything that is neither a directory nor a regular file (a symlink somehow already present,
66
- // a device node) is skipped rather than indexed — extraction itself never creates one, so
67
- // encountering one here would mean the filesystem changed out from under an already-published,
68
- // supposedly-frozen package, which this function has no business acting on either way.
46
+ };
47
+ }
48
+ /** Every regular file under `packageRoot` (sorted) and every `skills/<name>/SKILL.md` (sorted by name). */
49
+ async function walkPackageTree(readdir, { packageRoot }) {
50
+ const files = [];
51
+ const skills = [];
52
+ async function walk(absolute, prefix) {
53
+ for (const entry of await readdir(absolute, { withFileTypes: true })) {
54
+ const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
55
+ if (entry.isDirectory()) {
56
+ await walk(path.join(absolute, entry.name), relative);
57
+ continue;
69
58
  }
59
+ if (entry.isFile())
60
+ files.push(relative);
61
+ // Anything that is neither a directory nor a regular file (a symlink somehow already present,
62
+ // a device node) is skipped rather than indexed — extraction itself never creates one, so
63
+ // encountering one here would mean the filesystem changed out from under an already-published,
64
+ // supposedly-frozen package, which this function has no business acting on either way.
70
65
  }
71
- await walk(packageRoot, "");
72
- for (const relative of files) {
73
- const match = relative.match(/^skills\/([^/]+)\/SKILL\.md$/);
74
- if (match)
75
- skills.push({ name: match[1], skillPath: relative });
76
- }
77
- return { files: files.sort(), skills: skills.sort((a, b) => a.name.localeCompare(b.name)) };
78
66
  }
67
+ await walk(packageRoot, "");
68
+ for (const relative of files) {
69
+ const match = relative.match(/^skills\/([^/]+)\/SKILL\.md$/);
70
+ if (match)
71
+ skills.push({ name: match[1], skillPath: relative });
72
+ }
73
+ return { files: files.sort(), skills: skills.sort((a, b) => a.name.localeCompare(b.name)) };
74
+ }
75
+ /** Indexes manifests and files with the same injected effects used by installation and resolution.
76
+ * @complexity O(f) reads/walk work for f package files; no mutation or executable imports. */
77
+ export function createInstalledPackageIndex(required, _optional = {}) {
78
+ const { ports } = required;
79
+ const readFile = ports.filesystem.readFile.bind(ports.filesystem);
80
+ const readdir = ports.filesystem.readdir.bind(ports.filesystem);
81
+ const readInstalledManifest = createInstalledManifestReader(ports, readFile);
79
82
  /**
80
83
  * Reads the (already-extracted-and-trusted, or already-published) `plugin.json` at `packageRoot`
81
84
  * and walks the tree to build the `files`/`skills` index. Shared between a fresh install and the
@@ -97,7 +100,7 @@ export function createInstalledPackageIndex(required, _optional = {}) {
97
100
  const parsed = await readInstalledManifest({ packageRoot });
98
101
  for (const message of parsed.warnings)
99
102
  ports.onEvent?.({ event: 'agent-plugin-identity-warning', message, pluginId: parsed.manifest.name });
100
- const { files, skills } = await walkPackageTree({ packageRoot });
103
+ const { files, skills } = await walkPackageTree(readdir, { packageRoot });
101
104
  return {
102
105
  pluginId: parsed.manifest.name,
103
106
  id: parsed.manifest.id,
@@ -26,5 +26,5 @@ export type AgentPluginLayout = AgentPluginLayoutPort;
26
26
  /** Explicit root only; site-root and environment resolution belong to the consumer. */
27
27
  export declare function createAgentPluginLayout(required: {
28
28
  readonly root: string;
29
- }): AgentPluginLayoutPort;
29
+ }, _optional?: Record<string, never>): AgentPluginLayoutPort;
30
30
  //# sourceMappingURL=layout.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { pluginStatePaths } from '../../core/persistent-state.js';
3
3
  /** Explicit root only; site-root and environment resolution belong to the consumer. */
4
- export function createAgentPluginLayout(required) {
4
+ export function createAgentPluginLayout(required, _optional = {}) {
5
5
  if (!path.isAbsolute(required.root))
6
6
  throw new Error('Agent plugin root must be absolute');
7
7
  const root = path.resolve(required.root);
@@ -1,4 +1,5 @@
1
- import type { MailAdapterCredential, MailProviderModule, MailProviderRegistry, MailProviderSetup } from "@jini-ai/core/contracts/mail";
1
+ import { type Clock } from '@jini-ai/core/primitives';
2
+ import type { MailAdapterCredential, MailProviderModule, OutboundEmail, MailProviderRegistry, MailProviderSetup, SmtpMailPayload as SmtpPayload } from "@jini-ai/core/contracts/mail";
2
3
  import type { PluginCredentialCard } from "@jini-ai/core/contracts/credentials";
3
4
  import type { MailAdapterRegistry } from "./contribution.js";
4
5
  export interface MailCatalogDeps {
@@ -12,7 +13,9 @@ export interface MailCatalogDeps {
12
13
  pass: string;
13
14
  };
14
15
  }) => {
15
- sendMail(mail: SmtpPayload): Promise<{
16
+ sendMail(required: {
17
+ mail: SmtpPayload;
18
+ }): Promise<{
16
19
  messageId: string;
17
20
  }>;
18
21
  };
@@ -22,33 +25,6 @@ export interface MailCatalogDeps {
22
25
  serverId: string;
23
26
  }) => Promise<string | null>) | undefined;
24
27
  }
25
- interface SmtpPayload {
26
- from: {
27
- name?: string;
28
- address: string;
29
- };
30
- to: {
31
- name?: string;
32
- address: string;
33
- };
34
- replyTo?: {
35
- name?: string;
36
- address: string;
37
- };
38
- subject: string;
39
- html?: string;
40
- text?: string;
41
- headers?: Readonly<Record<string, string>>;
42
- attachments?: {
43
- filename: string;
44
- content: string;
45
- encoding: "base64";
46
- contentType: string;
47
- }[];
48
- }
49
- type Clock = {
50
- nowMs(): number;
51
- };
52
28
  export interface MailProviderCatalog {
53
29
  readonly registry: MailProviderRegistry;
54
30
  /** Plugin provider ids in registry order (plugin id, then declaration order). */
@@ -74,8 +50,9 @@ export declare function createMailCatalog(requiredHost: {
74
50
  builtins: {
75
51
  console: (required: {
76
52
  clock: Clock;
77
- }, optional?: {
78
- log?: (line: string) => void;
53
+ preview: (required: {
54
+ message: OutboundEmail;
55
+ }) => void | Promise<void>;
79
56
  }) => MailProviderModule;
80
57
  smtp: (required: {
81
58
  clock: Clock;
@@ -112,5 +89,4 @@ export declare function createMailCatalog(requiredHost: {
112
89
  id: string;
113
90
  }, _options?: Record<string, never>) => Promise<MailAdapterCredential | null>;
114
91
  };
115
- export {};
116
92
  //# sourceMappingURL=catalog.d.ts.map
@@ -1,30 +1,35 @@
1
- /** @agent-note The host supplies mail engine effects and exact product text; no platform runtime is imported. */
2
- export function createMailCatalog(requiredHost, _optional = {}) {
3
- function builtins(deps) {
4
- const clock = { nowMs: () => Date.now() };
5
- const createTransport = deps.createSmtpTransport;
6
- // The host's transport takes the payload positionally; Jini's SMTP adapter calls it with `{mail}`.
7
- const smtp = requiredHost.mailEngine.builtins.smtp({ clock, createTransport: (config) => {
8
- const transport = createTransport(config);
9
- return { sendMail: ({ mail }) => transport.sendMail(mail) };
10
- } });
11
- return [smtp, requiredHost.mailEngine.builtins.console({ clock }, deps.log ? { log: deps.log } : {})];
1
+ import { createConsoleLogger } from '@jini-ai/core/primitives';
2
+ function builtins(requiredHost, deps) {
3
+ const clock = { nowMs: () => Date.now() };
4
+ // The host transport and Jini's SMTP adapter share the object-args shape `sendMail({ mail })`.
5
+ const smtp = requiredHost.mailEngine.builtins.smtp({ clock, createTransport: deps.createSmtpTransport });
6
+ const log = deps.log ?? ((line) => createConsoleLogger({ prefix: '' }).info({ message: line }));
7
+ return [smtp, requiredHost.mailEngine.builtins.console({ clock, preview: ({ message }) => log(formatConsoleMail({ message })) })];
8
+ }
9
+ /** The preview line for the local console mailer (moved here from `createConsoleMailProvider`). */
10
+ function formatConsoleMail({ message }, _optional = {}) {
11
+ // The body is the point of a local mailer: a sign-in or confirmation link must be usable from the
12
+ // log, since nothing is delivered. Text is preferred (readable); an html-only message shows its html.
13
+ const body = message.text ?? message.html;
14
+ return `[mail:console] to=${message.to.email} subject=${JSON.stringify(message.subject)}${body === undefined ? '' : `\n${body}`}`;
15
+ }
16
+ /** Plugin registry, or an empty one plus the reason it could not be read. */
17
+ async function loadAdapters(deps) {
18
+ try {
19
+ return await deps.loadMailAdapters();
12
20
  }
13
- /** Plugin registry, or an empty one plus the reason it could not be read. */
14
- async function loadAdapters(deps) {
15
- try {
16
- return await deps.loadMailAdapters();
17
- }
18
- catch (err) {
19
- return { list: () => [], refusals: [`the plugin mail adapters could not be listed (${err instanceof Error ? err.message : String(err)})`] };
20
- }
21
+ catch (err) {
22
+ return { list: () => [], refusals: [`the plugin mail adapters could not be listed (${err instanceof Error ? err.message : String(err)})`] };
21
23
  }
24
+ }
25
+ /** @agent-note The host supplies mail engine effects and exact product text; no platform runtime is imported. */
26
+ export function createMailCatalog(requiredHost, _optional = {}) {
22
27
  /**
23
28
  * Builds the catalog fresh (plugins can be installed after boot). Never throws for a plugin fault.
24
29
  * @complexity O(a) plugin adapters.
25
30
  */
26
31
  async function loadMailProviderCatalog(deps, _optional = {}) {
27
- const registry = requiredHost.mailEngine.createRegistry({}, { builtins: builtins(deps) });
32
+ const registry = requiredHost.mailEngine.createRegistry({}, { builtins: builtins(requiredHost, deps) });
28
33
  const adapters = await loadAdapters(deps);
29
34
  const { accepted, refusals } = requiredHost.contributeMailProviders({ registry, adapters });
30
35
  const labels = new Map([["smtp", requiredHost.mailHostText.smtpCredentialLabel]]);
@@ -13,7 +13,7 @@
13
13
  * methods) whose `module.id` must equal the descriptor's `id`. `credentialLabel` stays optional
14
14
  * there; absent, it is {@link defaultCredentialLabel}. v1 keeps its create-only module format; both
15
15
  * versions use the keyed registry's provider ID grammar. 2026-10-22: v2
16
- * may also carry `setup` (field labels/types/defaults/help links, `./mail-provider-setup.ts`).
16
+ * may also carry `setup` (field labels/types/defaults/help links, `packages/platform/src/mail/provider-setup.ts`).
17
17
  * {@link contributeMailProviders} offers every loaded adapter to Jini's keyed mail-provider registry
18
18
  * so its refusals (bad id, duplicate, capability claims without code) surface with the loader's.
19
19
  *
@@ -21,7 +21,7 @@
21
21
  * (`custom-credentials/plugin-credential-card.ts`). It is data only, never required: an invalid card
22
22
  * is dropped with a note in `refusals` and the adapter still loads.
23
23
  *
24
- * TRUST RULE (fail closed), the shared gate in `./trusted-plugin-files.ts`: a module runs in this
24
+ * TRUST RULE (fail closed), the shared gate in `packages/agent-plugins/src/lifecycle/trusted-plugin-files.ts`: a module runs in this
25
25
  * process, so it loads only when the plugin is ACTIVE by the fail-closed reader, its installed digest
26
26
  * is the one `bundled-digests.json` records (only plugins the host shipped), and the module path stays
27
27
  * inside the plugin root and ends in `.mjs`. A bad plugin drops only its
@@ -13,7 +13,7 @@
13
13
  * methods) whose `module.id` must equal the descriptor's `id`. `credentialLabel` stays optional
14
14
  * there; absent, it is {@link defaultCredentialLabel}. v1 keeps its create-only module format; both
15
15
  * versions use the keyed registry's provider ID grammar. 2026-10-22: v2
16
- * may also carry `setup` (field labels/types/defaults/help links, `./mail-provider-setup.ts`).
16
+ * may also carry `setup` (field labels/types/defaults/help links, `packages/platform/src/mail/provider-setup.ts`).
17
17
  * {@link contributeMailProviders} offers every loaded adapter to Jini's keyed mail-provider registry
18
18
  * so its refusals (bad id, duplicate, capability claims without code) surface with the loader's.
19
19
  *
@@ -21,7 +21,7 @@
21
21
  * (`custom-credentials/plugin-credential-card.ts`). It is data only, never required: an invalid card
22
22
  * is dropped with a note in `refusals` and the adapter still loads.
23
23
  *
24
- * TRUST RULE (fail closed), the shared gate in `./trusted-plugin-files.ts`: a module runs in this
24
+ * TRUST RULE (fail closed), the shared gate in `packages/agent-plugins/src/lifecycle/trusted-plugin-files.ts`: a module runs in this
25
25
  * process, so it loads only when the plugin is ACTIVE by the fail-closed reader, its installed digest
26
26
  * is the one `bundled-digests.json` records (only plugins the host shipped), and the module path stays
27
27
  * inside the plugin root and ends in `.mjs`. A bad plugin drops only its
@@ -30,6 +30,37 @@
30
30
  import { contributeProviders } from "../provider-contribution.js";
31
31
  import { defineExecutablePluginContribution } from "../contribution-loader.js";
32
32
  import { asMailAdapterModule, parseMailAdaptersFile } from "./adapter-descriptors.js";
33
+ /** One note per loaded adapter whose declared key card was ignored. @complexity O(a). */
34
+ function cardNotes(items) {
35
+ return items.flatMap(({ descriptor, pluginId }) => descriptor.credentialCardRefusal ? [`mail adapter '${descriptor.id}' from '${pluginId}' key card was ignored: ${descriptor.credentialCardRefusal}`] : []);
36
+ }
37
+ /** Why a v2 module disagrees with its descriptor, or undefined. @complexity O(1). */
38
+ function v2Mismatch(adapter) {
39
+ const declared = adapter.module;
40
+ if (declared.id !== adapter.descriptor.id)
41
+ return `its module id '${String(declared.id)}' does not match the descriptor id '${adapter.descriptor.id}'`;
42
+ if (adapter.descriptor.feedback !== (declared.feedback !== undefined))
43
+ return "its descriptor feedback flag does not match the module's feedback parser";
44
+ return undefined;
45
+ }
46
+ /**
47
+ * The Jini provider for one loaded adapter. The module keeps the plugin's positional mailer ABI, so
48
+ * `create` adapts it; a v1 module (create only) is a hosted provider without feedback or domains.
49
+ * @complexity O(1).
50
+ */
51
+ function providerFor(requiredHost, adapter) {
52
+ const { descriptor, module } = adapter;
53
+ const declared = descriptor.schemaVersion === 2 ? module : {};
54
+ return {
55
+ ...declared,
56
+ id: descriptor.id,
57
+ label: descriptor.label,
58
+ credentialKeys: descriptor.credentialKeys ?? ["token", "baseUrl"],
59
+ capabilities: declared.capabilities ?? { hosted: true, feedback: false, domainVerification: false },
60
+ // Plugins receive the host's guarded HTTP client through their positional ABI.
61
+ create: (context) => requiredHost.abi.fromPositionalMailer({ mailer: module.create({ ...context, kit: { ...context.kit, httpClient: requiredHost.abi.toPluginHttpClient({ httpClient: context.kit.httpClient }) } }) }),
62
+ };
63
+ }
33
64
  /** @agent-note The host supplies its filename, setup validator, guarded ABI, and trusted source loader. */
34
65
  export function createMailContributions(requiredHost, _optional = {}) {
35
66
  const adapterContribution = defineExecutablePluginContribution({
@@ -60,37 +91,6 @@ export function createMailContributions(requiredHost, _optional = {}) {
60
91
  const load = await requiredHost.loadFromSource({ plugin, definition: adapterContribution });
61
92
  return { list: () => load.items, refusals: [...load.refusals, ...cardNotes(load.items)] };
62
93
  }
63
- /** One note per loaded adapter whose declared key card was ignored. @complexity O(a). */
64
- function cardNotes(items) {
65
- return items.flatMap(({ descriptor, pluginId }) => descriptor.credentialCardRefusal ? [`mail adapter '${descriptor.id}' from '${pluginId}' key card was ignored: ${descriptor.credentialCardRefusal}`] : []);
66
- }
67
- /** Why a v2 module disagrees with its descriptor, or undefined. @complexity O(1). */
68
- function v2Mismatch(adapter) {
69
- const declared = adapter.module;
70
- if (declared.id !== adapter.descriptor.id)
71
- return `its module id '${String(declared.id)}' does not match the descriptor id '${adapter.descriptor.id}'`;
72
- if (adapter.descriptor.feedback !== (declared.feedback !== undefined))
73
- return "its descriptor feedback flag does not match the module's feedback parser";
74
- return undefined;
75
- }
76
- /**
77
- * The Jini provider for one loaded adapter. The module keeps the plugin's positional mailer ABI, so
78
- * `create` adapts it; a v1 module (create only) is a hosted provider without feedback or domains.
79
- * @complexity O(1).
80
- */
81
- function providerFor(adapter) {
82
- const { descriptor, module } = adapter;
83
- const declared = descriptor.schemaVersion === 2 ? module : {};
84
- return {
85
- ...declared,
86
- id: descriptor.id,
87
- label: descriptor.label,
88
- credentialKeys: descriptor.credentialKeys ?? ["token", "baseUrl"],
89
- capabilities: declared.capabilities ?? { hosted: true, feedback: false, domainVerification: false },
90
- // Plugins receive the host's guarded HTTP client through their positional ABI.
91
- create: (context) => requiredHost.abi.fromPositionalMailer({ mailer: module.create({ ...context, kit: { ...context.kit, httpClient: requiredHost.abi.toPluginHttpClient({ httpClient: context.kit.httpClient }) } }) }),
92
- };
93
- }
94
94
  /**
95
95
  * Offers every loaded plugin adapter to the mail-provider registry. A v2 module whose id or
96
96
  * feedback claim disagrees with its descriptor is refused before the registry sees it.
@@ -106,7 +106,7 @@ export function createMailContributions(requiredHost, _optional = {}) {
106
106
  refusals.push(`mail adapter '${adapter.descriptor.id}' from '${adapter.pluginId}' was not loaded: ${mismatch}`);
107
107
  continue;
108
108
  }
109
- items.push({ contract: "mail", pluginId: adapter.pluginId, definition: { id: adapter.descriptor.id, provider: providerFor(adapter), label: adapter.descriptor.label } });
109
+ items.push({ contract: "mail", pluginId: adapter.pluginId, definition: { id: adapter.descriptor.id, provider: providerFor(requiredHost, adapter), label: adapter.descriptor.label } });
110
110
  }
111
111
  return contributeProviders({ registry: required.registry, loaded: { items, refusals } });
112
112
  }
@@ -1,5 +1,4 @@
1
- /** Keep ownership snapshots across failed cleanup, with bounded revision retries. @complexity O(1) setup. */
2
- export function createMailSelection(required, _optional = {}) {
1
+ function createPluginSelectionCleanup(required) {
3
2
  /** Clear only this plugin's selected lanes through the settings owner; failures propagate.
4
3
  * Re-read live ownership too: a conflict retry cannot clear a newly enabled plugin's same id.
5
4
  * @complexity O(a + p) active adapters and provider ids, two lane checks and at most one settings write. */
@@ -35,6 +34,11 @@ export function createMailSelection(required, _optional = {}) {
35
34
  }
36
35
  }
37
36
  };
37
+ return clearPluginSelection;
38
+ }
39
+ /** Keep ownership snapshots across failed cleanup, with bounded revision retries. @complexity O(1) setup. */
40
+ export function createMailSelection(required, _optional = {}) {
41
+ const clearPluginSelection = createPluginSelectionCleanup(required);
38
42
  // Only failed cleanup retains ownership: executable contributions disappear after OFF.
39
43
  const pendingPluginSelections = new Map();
40
44
  /** Retain active ownership across an interrupted cleanup; after a restart, read only the
@@ -44,8 +44,8 @@ export type ParseAgentPluginManifestResult = {
44
44
  * Hosts inject identityNamespace; the default is `jini`, with a legacy-key fallback.
45
45
  *
46
46
  * @throws Nothing — every failure is reported via the returned `errors`, matching this codebase's
47
- * own convention for expected validation outcomes (`plugin-runtime/manifest.ts`,
48
- * `plugin-runtime/discovery.ts`).
47
+ * own convention for expected validation outcomes (`packages/plugins/src/host/manifest.ts`,
48
+ * `packages/plugins/src/host/node/discovery.ts`).
49
49
  * @complexity O(k + n) time and space in the input keys and keyword entries.
50
50
  */
51
51
  export declare function parseAgentPluginManifest({ value }: {
@@ -169,5 +169,5 @@ export declare function readAgentPluginExtension<T>(required: {
169
169
  readonly read: (required: {
170
170
  readonly value: Readonly<Record<string, unknown>>;
171
171
  }) => T;
172
- }): T | undefined;
172
+ }, _optional?: Record<string, never>): T | undefined;
173
173
  //# sourceMappingURL=manifest.d.ts.map
@@ -51,7 +51,7 @@
51
51
  * `ParseAgentPluginMcpConfigResult`'s own doc for the fail-open contract this preserves.
52
52
  *
53
53
  * Architectural role:
54
- * Pure, no-I/O parsing over an already-`JSON.parse`d value — mirrors `plugin-runtime/manifest.ts`'s
54
+ * Pure, no-I/O parsing over an already-`JSON.parse`d value — mirrors `packages/plugins/src/host/manifest.ts`'s
55
55
  * own "receives a JS value, never a file path or raw bytes" contract. `install.ts` is the only
56
56
  * caller that reads the file and hands the parsed value here.
57
57
  */
@@ -183,8 +183,8 @@ function collectManifestProblems({ raw, identityNamespace }, { nameError } = {})
183
183
  * Hosts inject identityNamespace; the default is `jini`, with a legacy-key fallback.
184
184
  *
185
185
  * @throws Nothing — every failure is reported via the returned `errors`, matching this codebase's
186
- * own convention for expected validation outcomes (`plugin-runtime/manifest.ts`,
187
- * `plugin-runtime/discovery.ts`).
186
+ * own convention for expected validation outcomes (`packages/plugins/src/host/manifest.ts`,
187
+ * `packages/plugins/src/host/node/discovery.ts`).
188
188
  * @complexity O(k + n) time and space in the input keys and keyword entries.
189
189
  */
190
190
  export function parseAgentPluginManifest({ value }, optional = {}) {
@@ -465,7 +465,7 @@ function collectLegacyServerWarning({ rawServer, extension, portable, warnings }
465
465
  warnings.push(legacyAgentPluginMetadataWarning);
466
466
  }
467
467
  /** Typed extension reader: unknown namespaces have no semantics until a host supplies a reader. */
468
- export function readAgentPluginExtension(required) {
468
+ export function readAgentPluginExtension(required, _optional = {}) {
469
469
  if (!required.namespace.trim())
470
470
  throw new Error('An extension namespace is required');
471
471
  const extensions = required.manifest.extensions;
@@ -5,16 +5,16 @@ export declare function provisionAgentPluginMcp(required: {
5
5
  readonly mcpProvisioning: AgentPluginMcpProvisioningPort;
6
6
  readonly workspaceId: string;
7
7
  readonly installed: InstalledAgentPlugin;
8
- }): Promise<void>;
8
+ }, _optional?: Record<string, never>): Promise<void>;
9
9
  export declare function syncAgentPluginMcpEnabled(required: {
10
10
  readonly mcpProvisioning: AgentPluginMcpProvisioningPort;
11
11
  readonly workspaceId: string;
12
12
  readonly pluginId: string;
13
13
  readonly enabled: boolean;
14
- }): Promise<void>;
14
+ }, _optional?: Record<string, never>): Promise<void>;
15
15
  export declare function removeAgentPluginMcp(required: {
16
16
  readonly mcpProvisioning: AgentPluginMcpProvisioningPort;
17
17
  readonly workspaceId: string;
18
18
  readonly pluginId: string;
19
- }): Promise<void>;
19
+ }, _optional?: Record<string, never>): Promise<void>;
20
20
  //# sourceMappingURL=mcp-provisioning.d.ts.map
@@ -1,13 +1,13 @@
1
1
  /** A host performs MCP federation. Notify only after its durable provisioning step succeeds. */
2
- export async function provisionAgentPluginMcp(required) {
2
+ export async function provisionAgentPluginMcp(required, _optional = {}) {
3
3
  await required.mcpProvisioning.provision({ workspaceId: required.workspaceId, installed: required.installed });
4
4
  await required.mcpProvisioning.notifyRosterChanged({ workspaceId: required.workspaceId });
5
5
  }
6
- export async function syncAgentPluginMcpEnabled(required) {
6
+ export async function syncAgentPluginMcpEnabled(required, _optional = {}) {
7
7
  await required.mcpProvisioning.setEnabled({ workspaceId: required.workspaceId, pluginId: required.pluginId, enabled: required.enabled });
8
8
  await required.mcpProvisioning.notifyRosterChanged({ workspaceId: required.workspaceId });
9
9
  }
10
- export async function removeAgentPluginMcp(required) {
10
+ export async function removeAgentPluginMcp(required, _optional = {}) {
11
11
  await required.mcpProvisioning.remove({ workspaceId: required.workspaceId, pluginId: required.pluginId });
12
12
  await required.mcpProvisioning.notifyRosterChanged({ workspaceId: required.workspaceId });
13
13
  }
@@ -7,7 +7,7 @@ export declare class PackagePathViolation extends Error {
7
7
  }, optional?: ErrorOptions);
8
8
  }
9
9
  /** Internal composition; one state/queue instance per injected host context. */
10
- export declare function createPackagePathsModule(ports: Pick<AgentPluginLifecyclePorts, "filesystem">): {
10
+ export declare function createPackagePathsModule(ports: Pick<AgentPluginLifecyclePorts, "filesystem">, _optional?: Record<string, never>): {
11
11
  normalizePackageEntryPath: (rawEntryPath: string) => string;
12
12
  assertContainedOnDisk: (packageRoot: string, entryPath: string) => Promise<string>;
13
13
  };
@@ -125,7 +125,7 @@ function buildModule(ports) {
125
125
  }
126
126
  const instances = new WeakMap();
127
127
  /** Internal composition; one state/queue instance per injected host context. */
128
- export function createPackagePathsModule(ports) {
128
+ export function createPackagePathsModule(ports, _optional = {}) {
129
129
  let instance = instances.get(ports);
130
130
  if (!instance) {
131
131
  instance = buildModule(ports);
@@ -1,7 +1,6 @@
1
1
  import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
2
2
  import { createPluginMemory, migratePluginLayout, assertPluginStatePath, withPluginStateLock } from '../../core/persistent-state.js';
3
3
  import path from 'node:path';
4
- import { withFileLock } from '@jini-ai/platform/fs/file-lock';
5
4
  import { createPackagePathsModule } from './package-paths.js';
6
5
  import { parseAgentPluginManifest } from './manifest.js';
7
6
  /** Reuses the platform lock with injected effects, never age-stealing a living migration. */
@@ -10,7 +9,7 @@ export function createPersistentStateModule(ports, _optional = {}) {
10
9
  const effects = {
11
10
  filesystem: ports.filesystem,
12
11
  contain: ({ root, entryPath }) => assertContainedOnDisk(root, entryPath),
13
- withLock: ({ lockPath, run }) => withFileLock({ lockPath, run }, {
12
+ withLock: ({ lockPath, run }) => ports.fileLock.withFileLock({ lockPath, run }, {
14
13
  filesystem: ports.filesystem, clock: ports.clock, process: ports.process,
15
14
  hostname: () => ports.process.hostname({}), token: () => ports.ids.newId(),
16
15
  monotonicMs: () => ports.clock.monotonicMs(), sleep: ({ durationMs }) => ports.clock.sleep({ ms: durationMs }),
@@ -1,5 +1,5 @@
1
1
  import type { Clock, IdGenerator } from "@jini-ai/core/primitives";
2
- import type { BootIdentity } from "@jini-ai/platform/fs/file-lock";
2
+ import type { AtomicFileWriterPort, BootIdentity, FileLockPort } from "@jini-ai/core/contracts/runtime";
3
3
  import type { AgentPluginServerMetadataReader } from './manifest.js';
4
4
  import type { AgentPluginLayoutPort } from './layout.js';
5
5
  import type { AgentPluginDeliveryMode, InstalledAgentPlugin } from './types.js';
@@ -87,6 +87,10 @@ export interface AgentPluginLifecyclePorts {
87
87
  readonly retiredBundledPlugins: ReadonlyMap<string, string | readonly string[]>;
88
88
  readonly bundledArchiveMagic: string;
89
89
  readonly filesystem: FilesystemPort;
90
+ /** Exclusive file lock; the host binds it (`@jini-ai/node-adapters/agent-plugins`), never defaulted here. */
91
+ readonly fileLock: FileLockPort<FilesystemPort>;
92
+ /** Atomic JSON writer for the update journal; bound by the host like `fileLock`. */
93
+ readonly atomicWriter: Pick<AtomicFileWriterPort<FilesystemPort>, 'writeJson'>;
90
94
  readonly clock: AgentPluginClockPort;
91
95
  readonly ids: AgentPluginIdsPort;
92
96
  readonly process: AgentPluginProcessPort;
@@ -28,16 +28,38 @@ export type ResolveAgentPluginRefsResult = {
28
28
  readonly reason: string;
29
29
  readonly code?: 'untrusted';
30
30
  };
31
+ /**
32
+ * Resolves every pinned `pluginRefId` into real on-disk text and joins the results into one
33
+ * prompt-prefix block, in the order the refs were pinned.
34
+ *
35
+ * @param pluginRefIds - This run's pinned Agent Plugin ids (`run-start-context.ts`'s decoded
36
+ * `pluginRefIds` — already filtered to non-empty strings by that point). An empty array resolves
37
+ * to an empty prefix with no filesystem access at all — the common case (no plugin pinned).
38
+ * @param workspaceLayout - This run's own workspace's Agent Plugin layout
39
+ * (`resolveAgentPluginLayout().forWorkspace(workspaceId)`), never a shared/instance-level one —
40
+ * see `layout.ts`'s own tenant-isolation header for why a workspace's installed packages must
41
+ * never be resolved against another workspace's tree.
42
+ * @param options - Delivery mode, declared skill/file selection, and explicit read-only off-plugin discovery.
43
+ * Reads stay bounded to the skill folder; off-plugin discovery grants no tool execution.
44
+ * @returns `{ ok: true, promptPrefix }` once every ref resolves, or the FIRST `{ ok: false, reason }`
45
+ * encountered — a run pinning two refs where the second is ambiguous still fails clearly, rather
46
+ * than partially augmenting the prompt with only the first ref's content.
47
+ * @complexity O(r * d) where r is `pluginRefIds.length` and d is the number of installed digests in
48
+ * this workspace — each ref independently re-scans the (typically small) digest list, since a
49
+ * different ref may resolve to a different digest.
50
+ */
51
+ declare function resolveAgentPluginSelection({ ports, pluginRefIds, workspaceLayout }: {
52
+ ports: AgentPluginLifecyclePorts;
53
+ pluginRefIds: readonly string[];
54
+ workspaceLayout: Pick<AgentPluginWorkspaceLayout, "packages" | "root">;
55
+ }, { deliveryMode, allowInactiveGuidance, ...request }?: AgentPluginSkillRequest & {
56
+ deliveryMode?: AgentPluginDeliveryMode;
57
+ allowInactiveGuidance?: boolean;
58
+ }): Promise<ResolveAgentPluginRefsResult>;
31
59
  /** Internal composition; one state/queue instance per injected host context. */
32
- export declare function createResolveAgentPluginRefsModule(ports: AgentPluginLifecyclePorts): {
60
+ export declare function createResolveAgentPluginRefsModule(ports: AgentPluginLifecyclePorts, _optional?: Record<string, never>): {
33
61
  resolveAgentPluginRefs: (pluginRefIds: readonly string[], workspaceLayout: Pick<AgentPluginWorkspaceLayout, "packages" | "root">, deliveryMode?: AgentPluginDeliveryMode) => Promise<ResolveAgentPluginRefsResult>;
34
- resolveAgentPluginSelection: ({ pluginRefIds, workspaceLayout }: {
35
- pluginRefIds: readonly string[];
36
- workspaceLayout: Pick<AgentPluginWorkspaceLayout, "packages" | "root">;
37
- }, { deliveryMode, allowInactiveGuidance, ...request }?: AgentPluginSkillRequest & {
38
- deliveryMode?: AgentPluginDeliveryMode;
39
- allowInactiveGuidance?: boolean;
40
- }) => Promise<ResolveAgentPluginRefsResult>;
62
+ resolveAgentPluginSelection: (required: Omit<Parameters<typeof resolveAgentPluginSelection>[0], "ports">, optional?: Parameters<typeof resolveAgentPluginSelection>[1]) => Promise<ResolveAgentPluginRefsResult>;
41
63
  listInstalledPlugins: (workspaceRoot: string) => Promise<readonly InstalledAgentPlugin[]>;
42
64
  isInstalledDigestPresent: (packagesDir: string, archiveDigest: string) => Promise<boolean>;
43
65
  };