@jini-ai/agent-plugins 0.6.23 → 0.7.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 (220) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +13 -0
  3. package/calendly/exports/booking-calendar.css +7 -0
  4. package/calendly/exports/booking-calendar.html +5 -0
  5. package/calendly/mcp.json +10 -0
  6. package/calendly/plugin.json +47 -0
  7. package/calendly/skills/calendly/SKILL.md +27 -0
  8. package/charts-echarts/plugin.json +2 -2
  9. package/charts-recharts/plugin.json +2 -2
  10. package/cloudflare/lib/cms-forms.mjs +57 -0
  11. package/cloudflare/lib/forms.mjs +78 -18
  12. package/cloudflare/lib/target.mjs +17 -4
  13. package/cloudflare/plugin.json +2 -2
  14. package/cloudflare/skills/cloudflare/SKILL.md +4 -4
  15. package/cloudflare/skills/cloudflare/references/workers.md +4 -4
  16. package/cloudflare/worker/forms-receiver.mjs +81 -41
  17. package/cloudflare/worker/portable-validation.mjs +220 -0
  18. package/commerce/plugin.json +17 -0
  19. package/commerce/skills/commerce/SKILL.md +23 -0
  20. package/composio/mcp.json +1 -1
  21. package/composio/plugin.json +2 -2
  22. package/composio/skills/composio/SKILL.md +4 -4
  23. package/core/commerce-server.d.ts +2 -0
  24. package/core/commerce-server.mjs +2 -0
  25. package/dist/admin-surfaces/connections/connections.d.ts +35 -0
  26. package/dist/admin-surfaces/connections/connections.js +135 -0
  27. package/dist/admin-surfaces/connections/index.d.ts +3 -0
  28. package/dist/admin-surfaces/connections/index.js +2 -0
  29. package/dist/admin-surfaces/connections/ports.d.ts +110 -0
  30. package/dist/admin-surfaces/connections/ports.js +2 -0
  31. package/dist/admin-surfaces/index.d.ts +2 -0
  32. package/dist/admin-surfaces/index.js +1 -0
  33. package/dist/admin-surfaces/plugin-state-persistence.d.ts +27 -0
  34. package/dist/admin-surfaces/plugin-state-persistence.js +2 -0
  35. package/dist/admin-surfaces/plugin-state.d.ts +51 -0
  36. package/dist/admin-surfaces/plugin-state.js +106 -0
  37. package/dist/connect/access-token-tool.d.ts +240 -0
  38. package/dist/connect/access-token-tool.js +213 -0
  39. package/dist/connect/apply-connect-defaults.d.ts +91 -0
  40. package/dist/connect/apply-connect-defaults.js +113 -0
  41. package/dist/connect/apply-tool-renames.d.ts +72 -0
  42. package/dist/connect/apply-tool-renames.js +105 -0
  43. package/dist/connect/connect-card-ui.d.ts +143 -0
  44. package/dist/connect/connect-card-ui.js +106 -0
  45. package/dist/connect/connect-destination.d.ts +35 -0
  46. package/dist/connect/connect-destination.js +45 -0
  47. package/dist/connect/connect-sign-in-wait.d.ts +31 -0
  48. package/dist/connect/connect-sign-in-wait.js +21 -0
  49. package/dist/connect/connect-tool.d.ts +314 -0
  50. package/dist/connect/connect-tool.js +431 -0
  51. package/dist/connect/connection-status.d.ts +33 -0
  52. package/dist/connect/connection-status.js +63 -0
  53. package/dist/connect/credential-cards.d.ts +15 -0
  54. package/dist/connect/credential-cards.js +49 -0
  55. package/dist/connect/credential-save-tool.d.ts +45 -0
  56. package/dist/connect/credential-save-tool.js +156 -0
  57. package/dist/connect/enable-access.d.ts +67 -0
  58. package/dist/connect/enable-access.js +74 -0
  59. package/dist/connect/executable/approval.d.ts +58 -0
  60. package/dist/connect/executable/approval.js +40 -0
  61. package/dist/connect/executable/host-capabilities.d.ts +76 -0
  62. package/dist/connect/executable/host-capabilities.js +100 -0
  63. package/dist/connect/executable/index.d.ts +10 -0
  64. package/dist/connect/executable/index.js +9 -0
  65. package/dist/connect/executable/ports.d.ts +189 -0
  66. package/dist/connect/executable/ports.js +2 -0
  67. package/dist/connect/executable/register.d.ts +21 -0
  68. package/dist/connect/executable/register.js +125 -0
  69. package/dist/connect/federate-mcp.d.ts +190 -0
  70. package/dist/connect/federate-mcp.js +440 -0
  71. package/dist/connect/grant-signed-in-defaults.d.ts +96 -0
  72. package/dist/connect/grant-signed-in-defaults.js +100 -0
  73. package/dist/connect/import-access-token.d.ts +114 -0
  74. package/dist/connect/import-access-token.js +103 -0
  75. package/dist/connect/index.d.ts +19 -0
  76. package/dist/connect/index.js +19 -0
  77. package/dist/connect/plugin-credential-card.d.ts +46 -0
  78. package/dist/connect/plugin-credential-card.js +63 -0
  79. package/dist/connect/plugin-host/index.d.ts +203 -0
  80. package/dist/connect/plugin-host/index.js +153 -0
  81. package/dist/connect/ports.d.ts +74 -0
  82. package/dist/connect/ports.js +2 -0
  83. package/dist/connect/switch-on-saved-token.d.ts +48 -0
  84. package/dist/connect/switch-on-saved-token.js +20 -0
  85. package/dist/connect/token-sign-in.d.ts +51 -0
  86. package/dist/connect/token-sign-in.js +43 -0
  87. package/dist/core/identity-namespace.d.ts +39 -0
  88. package/dist/core/identity-namespace.js +61 -3
  89. package/dist/folder-zip-node.js +3 -1
  90. package/dist/lifecycle/automatic-use.d.ts +12 -7
  91. package/dist/lifecycle/automatic-use.js +37 -28
  92. package/dist/lifecycle/capability-projection.js +5 -1
  93. package/dist/lifecycle/contribution-loader.d.ts +2 -7
  94. package/dist/lifecycle/contribution-types.d.ts +8 -0
  95. package/dist/lifecycle/contribution-types.js +2 -0
  96. package/dist/lifecycle/credential-card-metadata.d.ts +23 -0
  97. package/dist/lifecycle/credential-card-metadata.js +184 -0
  98. package/dist/lifecycle/exports.d.ts +11 -0
  99. package/dist/lifecycle/exports.js +64 -3
  100. package/dist/lifecycle/host-tools/identity.d.ts +38 -0
  101. package/dist/lifecycle/host-tools/identity.js +58 -0
  102. package/dist/lifecycle/host-tools/index.d.ts +20 -0
  103. package/dist/lifecycle/host-tools/index.js +20 -0
  104. package/dist/lifecycle/host-tools/memory-tools.d.ts +22 -0
  105. package/dist/lifecycle/host-tools/memory-tools.js +63 -0
  106. package/dist/lifecycle/host-tools/ports.d.ts +121 -0
  107. package/dist/lifecycle/host-tools/ports.js +2 -0
  108. package/dist/lifecycle/host-tools/provider-status-tool.d.ts +88 -0
  109. package/dist/lifecycle/host-tools/provider-status-tool.js +45 -0
  110. package/dist/lifecycle/host-tools/search-tool.d.ts +74 -0
  111. package/dist/lifecycle/host-tools/search-tool.js +282 -0
  112. package/dist/lifecycle/host-tools/skill-tool.d.ts +219 -0
  113. package/dist/lifecycle/host-tools/skill-tool.js +482 -0
  114. package/dist/lifecycle/host-tools/write-note-tool.d.ts +22 -0
  115. package/dist/lifecycle/host-tools/write-note-tool.js +47 -0
  116. package/dist/lifecycle/index.d.ts +2 -1
  117. package/dist/lifecycle/install.js +2 -1
  118. package/dist/lifecycle/installed-package-index.js +5 -8
  119. package/dist/lifecycle/mail/adapter-descriptors.d.ts +78 -0
  120. package/dist/lifecycle/mail/adapter-descriptors.js +155 -0
  121. package/dist/lifecycle/mail/catalog.d.ts +116 -0
  122. package/dist/lifecycle/mail/catalog.js +72 -0
  123. package/dist/lifecycle/mail/configuration.d.ts +25 -0
  124. package/dist/lifecycle/mail/configuration.js +62 -0
  125. package/dist/lifecycle/mail/contribution.d.ts +89 -0
  126. package/dist/lifecycle/mail/contribution.js +115 -0
  127. package/dist/lifecycle/mail/host-mailer.d.ts +24 -0
  128. package/dist/lifecycle/mail/host-mailer.js +10 -0
  129. package/dist/lifecycle/mail/index.d.ts +16 -0
  130. package/dist/lifecycle/mail/index.js +16 -0
  131. package/dist/lifecycle/mail/selection.d.ts +40 -0
  132. package/dist/lifecycle/mail/selection.js +86 -0
  133. package/dist/lifecycle/manifest.d.ts +7 -2
  134. package/dist/lifecycle/manifest.js +32 -9
  135. package/dist/lifecycle/metadata.d.ts +31 -0
  136. package/dist/lifecycle/metadata.js +80 -0
  137. package/dist/lifecycle/persistent-state.js +2 -1
  138. package/dist/lifecycle/ports.d.ts +2 -0
  139. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -1
  140. package/dist/lifecycle/resolve-agent-plugin-refs.js +14 -8
  141. package/dist/lifecycle/search-projection.d.ts +3 -4
  142. package/dist/lifecycle/search-projection.js +5 -7
  143. package/dist/lifecycle/search.js +3 -2
  144. package/fly/plugin.json +5 -5
  145. package/fly/skills/fly/SKILL.md +1 -1
  146. package/formspree/plugin.json +7 -0
  147. package/formspree/skills/formspree/SKILL.md +11 -0
  148. package/github/plugin.json +2 -2
  149. package/github/skills/github/SKILL.md +28 -28
  150. package/github/skills/github/references/actions.md +8 -8
  151. package/github/skills/github/references/auth-and-tokens.md +7 -7
  152. package/github/skills/github/references/repo-files.md +5 -5
  153. package/github/skills/github/references/site-backup.md +16 -16
  154. package/github/skills/github/references/source-control.md +17 -17
  155. package/github-pages/plugin.json +2 -2
  156. package/github-pages/skills/github-pages/SKILL.md +3 -3
  157. package/google-forms/plugin.json +7 -0
  158. package/google-forms/skills/google-forms/SKILL.md +15 -0
  159. package/google-login/plugin.json +3 -3
  160. package/google-login/skills/google-login/SKILL.md +17 -60
  161. package/google-workspace/plugin.json +6 -6
  162. package/google-workspace/skills/google-workspace/references/connection.md +1 -1
  163. package/google-workspace/skills/google-workspace/references/form-delivery.md +4 -4
  164. package/google-workspace/tovu-admin-surfaces.json +5 -5
  165. package/higgsfield-media/plugin.json +5 -5
  166. package/higgsfield-media/skills/higgsfield-media/SKILL.md +31 -33
  167. package/higgsfield-media/skills/higgsfield-media/references/failure-modes.md +7 -7
  168. package/higgsfield-media/skills/higgsfield-media/references/models-and-plan-gates.md +3 -3
  169. package/jev/plugin.json +2 -2
  170. package/langfuse/plugin.json +2 -2
  171. package/meilisearch/plugin.json +2 -2
  172. package/meilisearch/skills/meilisearch/SKILL.md +1 -1
  173. package/netlify/plugin.json +2 -2
  174. package/netlify/skills/netlify/SKILL.md +3 -3
  175. package/opentelemetry/plugin.json +2 -2
  176. package/opentelemetry/skills/opentelemetry/SKILL.md +7 -7
  177. package/package.json +92 -14
  178. package/posthog/plugin.json +2 -2
  179. package/posthog/skills/posthog/SKILL.md +7 -7
  180. package/railway/plugin.json +3 -3
  181. package/railway/skills/railway/SKILL.md +10 -11
  182. package/render/plugin.json +3 -3
  183. package/render/skills/render/SKILL.md +7 -8
  184. package/resend/NOTES.md +2 -2
  185. package/resend/mcp.json +1 -1
  186. package/resend/plugin.json +5 -5
  187. package/resend/skills/resend/SKILL.md +13 -13
  188. package/s3-compatible/plugin.json +2 -2
  189. package/s3-compatible/skills/s3-compatible/SKILL.md +4 -4
  190. package/sentry/plugin.json +2 -2
  191. package/sentry/skills/sentry/SKILL.md +7 -7
  192. package/shopify/plugin.json +2 -2
  193. package/site-compliance/plugin.json +2 -2
  194. package/site-compliance/skills/site-compliance/SKILL.md +3 -3
  195. package/site-compliance/skills/site-compliance/references/gdpr-eu-uk.md +1 -1
  196. package/site-import/plugin.json +2 -2
  197. package/slide-design/plugin.json +2 -2
  198. package/software-engineering/LICENSE +201 -0
  199. package/software-engineering/NOTICE +9 -0
  200. package/software-engineering/README.md +89 -0
  201. package/software-engineering/plugin.json +24 -0
  202. package/software-engineering/skills/software-engineering/SKILL.md +33 -0
  203. package/software-engineering/skills/software-engineering/references/debugging.md +54 -0
  204. package/software-engineering/skills/software-engineering/references/implementation.md +27 -0
  205. package/software-engineering/skills/software-engineering/references/planning.md +27 -0
  206. package/software-engineering/skills/software-engineering/references/prototyping.md +14 -0
  207. package/software-engineering/skills/software-engineering/references/security.md +47 -0
  208. package/software-engineering/skills/software-engineering/references/verification.md +53 -0
  209. package/stripe/plugin.json +2 -2
  210. package/supabase/mcp.json +4 -4
  211. package/supabase/plugin.json +3 -3
  212. package/supabase/skills/supabase/SKILL.md +8 -8
  213. package/supabase/skills/supabase/references/failure-modes.md +5 -5
  214. package/ui-ux-design/plugin.json +2 -2
  215. package/vercel/plugin.json +2 -2
  216. package/vercel/skills/vercel/SKILL.md +3 -3
  217. package/wordpress/plugin.json +2 -2
  218. package/wordpress/skills/wordpress/SKILL.md +3 -3
  219. package/wordpress/skills/wordpress/references/free-site-redirect.md +2 -2
  220. package/wordpress/skills/wordpress/references/subdomain.md +5 -5
@@ -0,0 +1,282 @@
1
+ import { buildDomainRegistrations, indexCatalogById, optionalNumber, optionalString, requireInputRecord, ToolInputError } from "@jini-ai/core";
2
+ import { describeAgentPluginCompatibility, agentPluginDependentWarnings } from "../compatibility.js";
3
+ import { projectAgentPluginSearchPage } from "../search-projection.js";
4
+ import { readInstalledAgentPluginIdentity } from "./identity.js";
5
+ import { summarizeSkillMarkdown } from "./skill-tool.js";
6
+ /**
7
+ * ===========================================================================================
8
+ * `search_agent_plugin_local` — a SEPARATE, STATIC tool, not another per-plugin dynamic one
9
+ * ===========================================================================================
10
+ *
11
+ * Everything above this point (`agent_plugin_<pluginId>`, `registerInstalledAgentPluginTools`) is a
12
+ * dynamic tool PER installed, ACTIVE plugin — its id, schema, and description cannot exist until an
13
+ * async disk read has resolved which plugins are installed, which is why that half of this file is
14
+ * wired directly onto the `ToolRegistry` from `agent-daemon-server.ts`'s boot sequence rather than
15
+ * through the ordinary static `ToolContributor` seam (see this file's header, "Why this is NOT a
16
+ * ToolContributor").
17
+ *
18
+ * `search_agent_plugin_local` is different in kind: ONE tool, whose id/schema/description are known
19
+ * at module load with no disk access at all — the disk read happens inside the HANDLER, at call time,
20
+ * the same way `plugins_list`'s handler reads `discoverPlugins()` fresh on every call. That is exactly
21
+ * the shape every OTHER domain's `contribute<Domain>Tools()` already has, so this tool is wired through
22
+ * the ordinary static seam (`tool-catalog-manifest.ts`'s `installFirstPartyToolContributors()`) rather
23
+ * than joining the dynamic half above — it is part of the ~171-tool native catalog `search_tools`
24
+ * indexes at boot, not something that only exists after a workspace-scoped async load has run.
25
+ *
26
+ * ---------------------------------------------------------------------------
27
+ * The gap this closes
28
+ * ---------------------------------------------------------------------------
29
+ * The assistant can enable/disable a discovered host-family plugin (`plugins_set_enabled`,
30
+ * `features/plugin-runtime/tool-registrations.ts` — a DIFFERENT plugin system, see that file's own
31
+ * 2026-08-23 header note) and can USE an already-active Agent Plugin's skills
32
+ * (`agent_plugin_<pluginId>`, above) — but before this addition there was no way to FIND one. An
33
+ * operator asking "is there a plugin for X" had no tool that could answer; the only paths in were
34
+ * either already knowing the exact `agent_plugin_<pluginId>` id, or `search_tools` happening to
35
+ * surface one of those dynamic per-plugin tools directly (which only works for plugins that are both
36
+ * installed AND already enabled — `loadInstalledAgentPluginToolSources` filters to
37
+ * `filterActiveAgentPlugins` before registering a single dynamic tool). A disabled-but-installed
38
+ * plugin was invisible to every surface.
39
+ *
40
+ * ---------------------------------------------------------------------------
41
+ * Local only — no marketplace/web search (by design, not by omission)
42
+ * ---------------------------------------------------------------------------
43
+ * This searches `listInstalledPlugins()` — packages already extracted under this workspace's own
44
+ * `packages/sha256/*` (`layout.ts`). It does not reach a marketplace, a registry, or the web. That is
45
+ * a deliberate scope line, not a missing follow-up bolted on later: the response shape below (a flat
46
+ * `matches[]` of already-installed plugins) says nothing about install source, so a future marketplace
47
+ * search can be added as a SECOND tool (or a second mode) without this one's contract having to grow a
48
+ * "local vs remote" distinction it does not need today.
49
+ *
50
+ * ---------------------------------------------------------------------------
51
+ * Ranking signal: why keywords, id, description, AND skills — not keywords alone
52
+ * ---------------------------------------------------------------------------
53
+ * `plugin.json`'s `keywords` array is the obvious signal — author-curated, exactly analogous to
54
+ * `tool-search-keywords.ts`'s whole reason for existing (operators ask in words the artifact's own
55
+ * prose does not contain). But keywords alone would under-serve this catalog for a concrete, measured
56
+ * reason: the real bundled `ui-ux-design` package ships NO `keywords` field at all (verified —
57
+ * `<site>/agent-plugins/ws/workspace-local/packages/sha256/.../plugin.json` has only `name`
58
+ * and `description`), so a keywords-only ranker would make that entire installed plugin unfindable by
59
+ * search. `id` and `description` both matter for the same reason `search_components`'s own catalog
60
+ * ranks on id+description+capabilities together rather than one field alone. See `search.ts`'s own
61
+ * header for the full per-field weighting rationale and why skills are folded in too, at the lowest
62
+ * weight.
63
+ *
64
+ * ---------------------------------------------------------------------------
65
+ * SECURITY — same no-host-path discipline as the dynamic tools above
66
+ * ---------------------------------------------------------------------------
67
+ * `loadAgentPluginSearchCandidates` below reads `plugin.packageRoot` only to pass it to
68
+ * `resolveSkillsForPlugin`/`readInstalledMcpServerIds` — neither value, nor any other absolute path,
69
+ * is stored on `AgentPluginSearchCandidate` or reaches the handler's response. MCP servers are
70
+ * reported as ids only (`readInstalledMcpServerIds`'s own doc: never transport config, which MAY
71
+ * carry secrets).
72
+ */
73
+ const SEARCH_AGENT_PLUGIN_LOCAL_TOOL_ID = "search_agent_plugin_local";
74
+ /** Mirrors `component-catalog-tool.ts`'s local limit constants — same
75
+ * reasoning: the values are the contract this schema states to the model, so restating them (rather
76
+ * than importing a value from an unrelated domain) keeps the enforced bound and the documented one
77
+ * from silently drifting apart. */
78
+ const SEARCH_LIMIT_MAX = 50;
79
+ const SEARCH_LIMIT_DEFAULT = 10;
80
+ /**
81
+ * The search tool's description. Host tool names come only from `names` (the host's `messages`);
82
+ * without them the text stays neutral and drops those sentences.
83
+ * @complexity O(1).
84
+ */
85
+ function searchAgentPluginLocalDescription(names = {}) {
86
+ return "Find an Agent Plugin by the task, capability, skill or MCP server you need. Searches local " +
87
+ "agent-plugins.org packages (plugin.json, skills and optional mcp.json) in this workspace, including " +
88
+ "inactive packages. " + (names.inventory ? `For the full plugin inventory, use ${names.inventory}. ` : "") + "Empty, omitted or " +
89
+ "whitespace query returns every local Agent Plugin in plugin-id order, including enabled status. " +
90
+ "Nonblank queries return ranked matches. " +
91
+ "Results are byte-bounded: id, pluginId, enabled, maturity when declared, and a short description. " +
92
+ (names.setEnabled ? `${names.setEnabled} changes enabled status. ` : "") +
93
+ "An installed, off result is only a catalog entry. Offer its enable card, then read its guidance before connecting or requesting credentials; never guess its sign-in method. " +
94
+ "Local packages only — never a marketplace or the web. Once you have the right id, " +
95
+ (names.loadGuidance ? `call ${names.loadGuidance} for that plugin's full guidance. ` : "load that plugin's full guidance. ") +
96
+ "Page with the returned nextOffset as offset, keeping query and limit unchanged.";
97
+ }
98
+ const SEARCH_AGENT_PLUGIN_LOCAL_SCHEMA = {
99
+ type: "object",
100
+ additionalProperties: false,
101
+ properties: {
102
+ query: {
103
+ type: "string",
104
+ description: "What you're looking for, in plain language — e.g. 'a plugin for deploying a server app', " +
105
+ "'accessibility guidance', 'gdpr compliance checks'. Matched against each installed Agent " +
106
+ "Plugin's id, author-declared keywords, description, and bundled skills. Optional; empty, omitted or whitespace lists all installed plugins.",
107
+ },
108
+ offset: { type: "integer", minimum: 0, description: "Zero-based result offset. Start at 0; continue with nextOffset until null." },
109
+ limit: {
110
+ type: "integer",
111
+ minimum: 1,
112
+ maximum: SEARCH_LIMIT_MAX,
113
+ description: `Max results to return (1-${SEARCH_LIMIT_MAX}). Optional, defaults to ${SEARCH_LIMIT_DEFAULT}.`,
114
+ },
115
+ },
116
+ };
117
+ /** This tool's one-entry catalog, exported (not inlined into {@link buildAgentPluginSearchRegistrations})
118
+ * so `assistant/__tests__/tool-registrations.contracts.test.ts`'s `CATALOGS_BY_DOMAIN` — which
119
+ * cross-checks every wired domain's published schema/risk/actor-class contract against this SAME
120
+ * source of truth — can import it the same way it imports every sibling domain's `<domain>AgentToolCatalog`. */
121
+ export function agentPluginSearchToolCatalog(required, optional = {}) {
122
+ return [
123
+ {
124
+ name: SEARCH_AGENT_PLUGIN_LOCAL_TOOL_ID,
125
+ description: searchAgentPluginLocalDescription(optional.messages?.searchHostTools),
126
+ sideEffects: "none",
127
+ authorization: { permission: required.permission },
128
+ inputSchema: SEARCH_AGENT_PLUGIN_LOCAL_SCHEMA,
129
+ },
130
+ ];
131
+ }
132
+ export async function loadAgentPluginSearchCandidates(ctx, _optional = {}) {
133
+ const { lifecycle } = ctx.ports;
134
+ const workspaceLayout = ctx.ports.layout.forWorkspace({ workspaceId: ctx.workspaceId });
135
+ // The first-encountered-digest rule below is a fallback for an ambiguity nothing can resolve. An
136
+ // upgraded BUNDLED plugin is no longer one of those cases: its superseded package is dropped here,
137
+ // so this lists the version the running build ships (`bundled-digests.ts`).
138
+ const installed = lifecycle.preferBundledAgentPluginDigests({
139
+ installed: await lifecycle.listInstalledPlugins({ workspaceRoot: workspaceLayout.root }),
140
+ bundled: await lifecycle.readBundledAgentPluginDigests({ workspaceRoot: workspaceLayout.root }),
141
+ });
142
+ const activations = await ctx.ports.activations.readAgentPluginActivations({ workspaceRoot: workspaceLayout.root });
143
+ const seenPluginIds = new Set();
144
+ const candidates = [];
145
+ for (const plugin of installed) {
146
+ if (seenPluginIds.has(plugin.pluginId))
147
+ continue;
148
+ seenPluginIds.add(plugin.pluginId);
149
+ // Per-PLUGIN isolation: a failure here that is not one skill's own read must not take every
150
+ // OTHER installed plugin's search entry down with it — before this, one such failure threw out
151
+ // of `loadAgentPluginSearchCandidates` entirely, which is why `search_agent_plugin_local` (and the
152
+ // admin Agent Plugins page, the same loader's second caller) could fail outright over a single
153
+ // bad install. Per-SKILL isolation (one unreadable SKILL.md not costing its own plugin, let alone
154
+ // every other one) is `resolveSkillsForSearchTolerant`'s job, above. Defensive today: neither
155
+ // call below throws on any known input (`readInstalledMcpServerIds` already collapses a missing,
156
+ // unreadable, or invalid `mcp.json` to `[]`), so this guards a future throwing change there.
157
+ try {
158
+ candidates.push({ ...await buildSearchCandidate({ plugin, activations, ports: ctx.ports }),
159
+ archiveDigest: plugin.archiveDigest,
160
+ ...describeAgentPluginCompatibility({ plugin, installed, activations }),
161
+ requiredBy: agentPluginDependentWarnings({ plugin, installed, activations, nextProvides: [] }),
162
+ });
163
+ }
164
+ catch (error) {
165
+ console.warn(`[agent-plugins] '${plugin.pluginId}': ${error instanceof Error ? error.message : String(error)} — excluded from search`);
166
+ }
167
+ }
168
+ return candidates;
169
+ }
170
+ /** This tool's own risk classification: a pure read of already-installed, already-validated local
171
+ * content, same as every other read-only tool this domain and its siblings (`plugins_list`,
172
+ * `search_components`) already declare `"none"` for. */
173
+ export const agentPluginSearchDerivedRisk = new Map([
174
+ [SEARCH_AGENT_PLUGIN_LOCAL_TOOL_ID, "none"],
175
+ ]);
176
+ /** Validate the paging hint independently of catalog I/O; invalid offsets throw ToolInputError.
177
+ * @complexity O(1) time and space. */
178
+ function readAgentPluginSearchWindow({ input }, _optional = {}) {
179
+ const rawLimit = optionalNumber({ input, key: "limit" });
180
+ const rawOffset = optionalNumber({ input, key: "offset" });
181
+ if (rawOffset !== undefined && (!Number.isSafeInteger(rawOffset) || rawOffset < 0)) {
182
+ throw new ToolInputError({ message: 'offset must be a non-negative safe integer' });
183
+ }
184
+ const offset = rawOffset ?? 0;
185
+ // Clamped, not rejected — an out-of-range limit is an optimization hint, not part of what the
186
+ // caller is actually asking for, mirroring `component-catalog-tool.ts`'s identical treatment of
187
+ // `search_components`' own `limit` argument.
188
+ const limit = rawLimit === undefined ? SEARCH_LIMIT_DEFAULT : Math.min(Math.max(Math.trunc(rawLimit), 1), SEARCH_LIMIT_MAX);
189
+ return { offset, limit };
190
+ }
191
+ /** List the existing catalog for blank input; otherwise delegate ranking to its Jini owner.
192
+ * Does not mutate candidates. Listing assigns score zero because no query was scored.
193
+ * @complexity Listing O(p log p) time and O(p) space in installed plugins; ranking retains Jini's cost. */
194
+ function selectAgentPluginSearchCandidates({ query, candidates, ports }, _optional = {}) {
195
+ if (query.trim() === "") {
196
+ return [...candidates].sort((a, b) => a.pluginId.localeCompare(b.pluginId)).map(candidate => ({ ...candidate, score: 0 }));
197
+ }
198
+ // Rank the whole local catalog once, then page it; the response bound is not a discovery cap.
199
+ // The shared ranker spreads each candidate, preserving the host's metadata.
200
+ return ports.lifecycle.rankInstalledAgentPlugins({ query, candidates, limit: candidates.length });
201
+ }
202
+ /**
203
+ * Builds the `search_agent_plugin_local` registration — pure catalog/schema construction plus one
204
+ * handler closure; the actual disk read happens only when the handler is invoked, matching
205
+ * `plugins_list`'s identical "read fresh on every call" shape.
206
+ *
207
+ * @param routeDeps Workspace and the host-tool ports.
208
+ * @returns One registration; its handler validates input and returns a page without host paths.
209
+ * @example buildAgentPluginSearchRegistrations({ workspaceId, ports });
210
+ * @complexity O(1) to build; see {@link loadAgentPluginSearchCandidates} and
211
+ * {@link selectAgentPluginSearchCandidates} for the handler's per-call cost.
212
+ */
213
+ export function buildAgentPluginSearchRegistrations(routeDeps, _optional = {}) {
214
+ const handlers = {
215
+ [SEARCH_AGENT_PLUGIN_LOCAL_TOOL_ID]: async (ctx) => {
216
+ const input = requireInputRecord({ input: ctx.input });
217
+ const query = optionalString({ input, key: "query" }) ?? "";
218
+ const { offset, limit } = readAgentPluginSearchWindow({ input });
219
+ const candidates = await loadAgentPluginSearchCandidates(routeDeps);
220
+ const ranked = selectAgentPluginSearchCandidates({ query, candidates, ports: routeDeps.ports });
221
+ return projectAgentPluginSearchPage({ candidates: ranked, offset, limit, totalInstalled: candidates.length });
222
+ },
223
+ };
224
+ return buildDomainRegistrations({ ...(routeDeps.ports.metadata ? { metadata: routeDeps.ports.metadata } : {}),
225
+ domain: "agent-plugin-search",
226
+ catalogModule: "lifecycle/host-tools/search-tool.ts",
227
+ catalog: indexCatalogById({ catalog: agentPluginSearchToolCatalog({ permission: routeDeps.ports.permissions.use }, { messages: routeDeps.ports.messages }) }),
228
+ handlers,
229
+ derivedRisk: agentPluginSearchDerivedRisk,
230
+ });
231
+ }
232
+ /**
233
+ * Same per-skill work as {@link resolveSkillsForPlugin}, but tolerant of ONE skill's own read
234
+ * failure — used only by the search loader below ({@link loadAgentPluginSearchCandidates}), which
235
+ * must keep the plugin, and its OTHER skills, discoverable rather than losing the whole entry (and
236
+ * every other installed plugin behind it in the same call, since one unhandled rejection here would
237
+ * fail the entire `loadAgentPluginSearchCandidates` promise) to one skill file that is present in
238
+ * the fresh directory walk but no longer actually readable (a permissions problem, disk corruption).
239
+ * Logged and skipped, never fabricated.
240
+ *
241
+ * The dynamic-tool loader ({@link loadInstalledAgentPluginToolSources}) deliberately keeps
242
+ * `resolveSkillsForPlugin`'s stricter, plugin-wide failure instead: a tool whose catalog description
243
+ * silently dropped one of its skills is a worse failure mode there than refusing the whole plugin's
244
+ * tool, so that loader's own per-plugin `catch` (below) is intentionally left alone.
245
+ */
246
+ async function resolveSkillsForSearchTolerant(plugin, ports) {
247
+ const skills = [];
248
+ for (const skill of plugin.skills) {
249
+ try {
250
+ const markdown = await ports.lifecycle.readInstalledSkillMarkdown({ packageRoot: plugin.packageRoot, skillPath: skill.skillPath });
251
+ skills.push({ name: skill.name, summary: summarizeSkillMarkdown(skill.name, markdown, ports), markdown,
252
+ readFile: (_input, options = {}) => ports.lifecycle.readInstalledSkillFile({ packageRoot: plugin.packageRoot, skillPath: skill.skillPath }, options),
253
+ });
254
+ }
255
+ catch (error) {
256
+ console.warn(`[agent-plugins] '${plugin.pluginId}': skill '${skill.name}' could not be read ` +
257
+ `(${error instanceof Error ? error.message : String(error)}) — skipped from search`);
258
+ }
259
+ }
260
+ return skills;
261
+ }
262
+ async function buildSearchCandidate({ plugin, activations, ports }, _optional = {}) {
263
+ const skills = await resolveSkillsForSearchTolerant(plugin, ports);
264
+ const mcpServerIds = await ports.lifecycle.readInstalledMcpServerIds({ packageRoot: plugin.packageRoot });
265
+ const identity = await readInstalledAgentPluginIdentity({ plugin });
266
+ return {
267
+ pluginId: plugin.pluginId,
268
+ ...(plugin.displayName !== undefined ? { displayName: plugin.displayName } : {}),
269
+ ...(plugin.summary !== undefined ? { summary: plugin.summary } : {}),
270
+ ...(plugin.version !== undefined ? { version: plugin.version } : {}),
271
+ ...(plugin.description !== undefined ? { description: plugin.description } : {}),
272
+ id: identity.id,
273
+ ...(identity.maturity ? { maturity: identity.maturity } : {}),
274
+ ...(identity.providerPlugin ? { providerPlugin: identity.providerPlugin } : {}),
275
+ provides: identity.provides,
276
+ keywords: identity.keywords,
277
+ enabled: ports.activations.isAgentPluginActive({ activations: activations, pluginId: plugin.pluginId }),
278
+ skills: skills.map((skill) => ({ name: skill.name, summary: skill.summary })),
279
+ mcpServerIds,
280
+ };
281
+ }
282
+ //# sourceMappingURL=search-tool.js.map
@@ -0,0 +1,219 @@
1
+ import { type DerivedRiskByToolId, type ToolRegistration } from "@jini-ai/core";
2
+ import { type PluginMaturity } from "./identity.js";
3
+ import type { AgentPluginHostToolPorts, ApplyHostToolApprovalPolicy, HostGuidancePort } from "./ports.js";
4
+ import type { SkillFileResult } from "../skill-file-reader.js";
5
+ /** One skill's summary, for folding into its plugin's combined description — reuses the same
6
+ * frontmatter/fallback parsing the prior per-skill pilot used, just no longer wrapped into a
7
+ * standalone tool description of its own. */
8
+ export declare function summarizeSkillMarkdown(skillName: string, markdown: string, ports: Pick<AgentPluginHostToolPorts, "readFrontmatterField">): string;
9
+ /** One installed plugin's one skill, fully resolved for tool registration — no host paths, a deferred
10
+ * reader capability for supporting-file requests at call time. See this file's header, SECURITY. */
11
+ export interface AgentPluginSkillDetail {
12
+ readonly name: string;
13
+ readonly summary: string;
14
+ readonly markdown: string;
15
+ /** Deferred shared-reader capability; its closed-over host paths never enter model output. */
16
+ readonly readFile?: (input: Record<string, never>, options?: {
17
+ readonly file?: string;
18
+ }) => Promise<SkillFileResult>;
19
+ }
20
+ /** One installed Agent Plugin, fully resolved into a single tool-ready source. See this file's
21
+ * header, SECURITY. */
22
+ export interface AgentPluginToolSource {
23
+ readonly maturity?: PluginMaturity | undefined;
24
+ readonly id: string;
25
+ readonly pluginId: string;
26
+ /** The archive digest whose extracted bytes this source's skills were read from — carried so the
27
+ * per-call gate below can re-establish that THIS package is still installed, and so a
28
+ * registration is pinned to the exact install it was built from rather than to whatever happens
29
+ * to answer to the same plugin id later. A content hash, not a host path: it names no directory
30
+ * a caller does not already have to know, and `AgentPluginUninstallPreview.archiveDigests`
31
+ * already shows it to a human, so it does not weaken this file's SECURITY property above. */
32
+ readonly archiveDigest: string;
33
+ readonly description: string;
34
+ readonly skills: readonly AgentPluginSkillDetail[];
35
+ /** The skill name a no-argument (or unrecognized-argument) call returns — the plugin's own
36
+ * eponymous skill when one exists, otherwise a documented fallback (see this file's header). */
37
+ readonly defaultSkillName: string;
38
+ /** Set only when {@link defaultSkillName} is NOT the plugin's eponymous skill — the human-readable
39
+ * reason folded into both the description and every default-path handler response. */
40
+ readonly defaultSkillReason?: string;
41
+ }
42
+ /**
43
+ * Loads every installed Agent Plugin for one workspace, resolved into one tool-ready source per
44
+ * plugin. Per-plugin failures are isolated: a pluginId installed under more than one digest (a
45
+ * genuine, actionable ambiguity — see this file's header for why the digest itself is not folded
46
+ * into the id) — or any other per-plugin resolution failure, e.g. an unreadable SKILL.md — is
47
+ * logged via `console.warn` and excluded from the returned array, but never aborts the whole load.
48
+ * One bad plugin install must not take every other installed plugin's tool down with it.
49
+ *
50
+ * @complexity O(d * s) in installed-digest count times average skills-per-digest, dominated by
51
+ * `listInstalledPlugins`'s own walk plus one `readInstalledSkillMarkdown` per skill.
52
+ */
53
+ export declare function loadInstalledAgentPluginToolSources(ctx: {
54
+ readonly workspaceId: string;
55
+ readonly ports: AgentPluginHostToolPorts;
56
+ }, _optional?: {}): Promise<readonly AgentPluginToolSource[]>;
57
+ /** This module's own risk classification: every plugin tool is a pure read of already-installed,
58
+ * already-validated local content — no domain call, no write path. */
59
+ export declare function agentPluginToolDerivedRisk({ sources }: {
60
+ readonly sources: readonly AgentPluginToolSource[];
61
+ }, _optional?: Record<string, never>): DerivedRiskByToolId;
62
+ /**
63
+ * ===========================================================================================
64
+ * REVOCATION — the activation gate has to run AGAIN, per call, or a disable never lands
65
+ * ===========================================================================================
66
+ *
67
+ * {@link loadInstalledAgentPluginToolSources}'s own ACTIVATION GATE runs exactly once, because
68
+ * `registerInstalledAgentPluginTools` runs exactly once: inside `agent-daemon-server.ts`'s
69
+ * `start()`. `@jini-ai/core`'s `ToolRegistry` is append-only BY DESIGN — its own header calls that
70
+ * out ("unregister is not exposed; ... tools are registered once at composition time") — so nothing
71
+ * anywhere can take a registration back out of a daemon that is already running.
72
+ *
73
+ * Boot-only activation checks would retain a disabled plugin's guidance until restart, even
74
+ * while admin/tool responses report successful revocation. Invocation must re-read activation
75
+ * just as run-start reference injection and discovery do.
76
+ *
77
+ * The gate therefore moves to where the capability is actually spent — the invocation itself. This
78
+ * is not "a filter bolted onto the read path": `@jini-ai/core`'s `authorizeToolInvocation` consults
79
+ * a registration's `ToolPolicy` BEFORE it will hand the handler back to `ToolExecutor`, and the
80
+ * handler is unreachable by any other route, so a policy check here is the single sink for running
81
+ * one of these tools, not one of several. A revoked plugin's call ends as `denied` without the
82
+ * handler ever being entered, and the daemon's own audit record says so.
83
+ *
84
+ * ---------------------------------------------------------------------------
85
+ * Activation and installation must both remain valid
86
+ * ---------------------------------------------------------------------------
87
+ * Gating on the activation record alone would re-admit an uninstalled plugin.
88
+ * Uninstall deletes the record and isAgentPluginActive treats an absent record as active, so
89
+ * disable-then-uninstall can otherwise flip deny back to allow. Absence means "nobody recorded
90
+ * a decision", which is only consent while the operator's own install is still standing behind it.
91
+ * Once the package is gone, there is no install left to imply anything.
92
+ *
93
+ * So the gate asks BOTH halves, and authorizes only when both answer positively:
94
+ *
95
+ * 1. **Still activated** — via `activation.ts`'s `resolveAgentPluginActivation`, the fail-CLOSED
96
+ * reader added for this call site. `absent record` still means active (that rule is untouched),
97
+ * but an activations file that cannot be read, parsed, or shape-checked — or that holds a
98
+ * malformed record for THIS plugin — is `undetermined` and denies, rather than being laundered
99
+ * into "nothing recorded, therefore permitted". This is the one place that diverges from the
100
+ * other two gate surfaces' fail-OPEN read, and only on FAULTS, never on what "active" means: a
101
+ * corrupt byte must not hide an operator's plugins from discovery, and equally must not hand out
102
+ * a capability nobody can confirm was granted. Here the divergence also buys the error surface
103
+ * `activation.ts`'s header says fail-closed lacks — a denied call is recorded as `denied` in the
104
+ * daemon's audit trail, and the gate logs the reason.
105
+ * 2. **Still installed** — via `resolve-agent-plugin-refs.ts`'s `isInstalledDigestPresent`, one
106
+ * `stat` of the exact `archiveDigest` this registration's guidance was read from. Not
107
+ * `listInstalledPlugins` (which walks and re-indexes every digest directory, far too much per
108
+ * call) and not a stored `packageRoot` (a host path this file's SECURITY section keeps off
109
+ * `AgentPluginToolSource` entirely) — the digest is a content identifier, and the module that
110
+ * owns the `<packages>/<digest>` layout derives the path from it.
111
+ *
112
+ * Checked in that ORDER, deliberately, because it is what makes the pair safe against a concurrent
113
+ * uninstall: `uninstall.ts` renames the package aside FIRST and deletes the record SECOND, so the
114
+ * gate reads them in the opposite order. An interleaving that sees the record already deleted
115
+ * ("active") therefore cannot also see the package still present — the rename strictly preceded the
116
+ * delete it just observed. Reading installation first would leave exactly that window open.
117
+ *
118
+ * Pinning to the DIGEST rather than the plugin id has a second, deliberate effect: uninstalling a
119
+ * plugin and reinstalling the same id from a different archive does not silently re-admit the boot
120
+ * registration, whose handler still holds the OLD package's guidance in memory. It stays denied
121
+ * until the restart `UNINSTALL_RESTART_NOTE` already tells the operator about.
122
+ *
123
+ * Consequences worth stating rather than discovering later:
124
+ * - Revocation is immediate and reversible in BOTH directions for a tool that was registered at
125
+ * boot. It is NOT symmetric for one that was not: enabling a plugin that was disabled when the
126
+ * daemon started still needs a restart, because there is no registration to re-admit. That is the
127
+ * asymmetry `plugin-runtime/tool-registrations.ts`'s `restartNoteFor` reports to the model.
128
+ * - The tool stays VISIBLE. `registry.list()` and `search_tools`' one-shot FTS snapshot
129
+ * (`agent-daemon-server.ts`) are both append-only too, so a revoked plugin's tool can still be
130
+ * found and attempted; it just cannot run. Hiding it needs a registry mutation API that does not
131
+ * exist, and a visible-but-refusing tool is the safe direction of that pair.
132
+ * - Every failure mode of both halves denies: a missing package directory, a non-directory at that
133
+ * path, a digest that does not match the installed-directory grammar, an EACCES/EIO on either
134
+ * read, a torn or hand-edited activations file. There is no input to either check for which "I
135
+ * could not tell" comes back as `allow`.
136
+ */
137
+ /** The identity of the exact installed package ONE registration was built from. Both fields are
138
+ * content identifiers — a manifest-declared plugin name and an archive digest — never host paths,
139
+ * so this stays inside this file's SECURITY property above. */
140
+ export interface AgentPluginToolIdentity {
141
+ readonly maturity?: PluginMaturity | undefined;
142
+ readonly publisherId?: string;
143
+ readonly keywords?: readonly string[];
144
+ readonly provides?: readonly string[];
145
+ readonly pluginId: string;
146
+ readonly archiveDigest: string;
147
+ }
148
+ export interface AgentPluginToolGate {
149
+ /** Whether this exact installed package may still run: re-reads the activation record AND
150
+ * re-confirms the package is still on disk, answering `false` unless both say yes. */
151
+ isCallable(plugin: AgentPluginToolIdentity): Promise<boolean>;
152
+ }
153
+ /**
154
+ * The production gate: one small `activations.json` read plus one `stat` per tool call, both against
155
+ * the same `forWorkspace()` layout every other path in this feature goes through.
156
+ *
157
+ * Deliberately NOT cached. Both facts change when a human toggles or uninstalls a plugin, and the
158
+ * whole point of this gate is that such an act is observed by the very next call; a cache would
159
+ * reintroduce the staleness window the gate exists to close, to save two sub-millisecond reads on a
160
+ * human-paced call.
161
+ *
162
+ * @param ctx.workspaceId - The tenant whose record and packages are consulted. Never an
163
+ * instance-level path.
164
+ * @returns A gate whose answer is established fresh per call, and which denies on any fault.
165
+ * @complexity O(p) per call in the recorded plugin count, plus one small file read and one `stat`.
166
+ */
167
+ export declare function createAgentPluginToolGate(ctx: {
168
+ readonly workspaceId: string;
169
+ readonly ports: AgentPluginHostToolPorts;
170
+ }, _optional?: {}): AgentPluginToolGate;
171
+ /**
172
+ * Turns already-resolved plugin sources into real `ToolRegistration`s — pure and synchronous, unlike
173
+ * {@link loadInstalledAgentPluginToolSources}, so this is the half a unit test exercises without
174
+ * touching disk. Uses the SAME `buildDomainRegistrations` gate every other domain's
175
+ * `tool-registrations.ts` uses (catalog/risk cross-check, `inputSchema` presence, drift tripwire) —
176
+ * not a parallel mechanism.
177
+ *
178
+ * `gate` is required, not optional, and is applied HERE rather than by the caller for the
179
+ * reason this file's REVOCATION note above gives: a gate a call site has to remember to attach is a
180
+ * gate some future call site will register tools without. Every registration this function can
181
+ * produce carries it. The build itself stays synchronous and touches no disk — the gate reads only
182
+ * when a call is actually authorized.
183
+ *
184
+ * @param sources - Already-resolved, already-activation-filtered plugin sources.
185
+ * @param gate - The per-call revocation gate (see {@link createAgentPluginToolGate}).
186
+ * @complexity O(n) in source count; each source's gate reads are deferred to invocation.
187
+ */
188
+ export declare function buildAgentPluginToolRegistrations({ sources, gate, withExtensionApprovalPolicy, ports }: {
189
+ sources: readonly AgentPluginToolSource[];
190
+ gate: AgentPluginToolGate;
191
+ withExtensionApprovalPolicy: ApplyHostToolApprovalPolicy;
192
+ ports: Pick<AgentPluginHostToolPorts, "permissions" | "metadata">;
193
+ }, _optional?: Record<string, never>): ToolRegistration[];
194
+ /**
195
+ * Composition-root entry point: loads every installed plugin for one workspace and registers each
196
+ * as a real tool directly on `registry` — the same `registry.register(registration)` call
197
+ * `agent-daemon-server.ts`'s own top-level loops make for `buildAssistantToolRegistrations`'s output,
198
+ * just awaited first. See this file's header for why this is a standalone async function rather than
199
+ * a `ToolContributor`, and why it is not (yet) called from that live boot sequence.
200
+ *
201
+ * Registers with the REAL gate, so every tool this puts into the daemon's registry stops answering
202
+ * the moment its plugin is switched off OR uninstalled — see the REVOCATION note above
203
+ * {@link createAgentPluginToolGate}.
204
+ *
205
+ * Each guidance answer carries the host's overlay for that plugin (`optional.hostGuidance`): its
206
+ * `GUIDANCE.md` after any maturity notice, and its `host/` files. Without that port the plugin's own
207
+ * guidance is returned as is.
208
+ */
209
+ export declare function registerInstalledAgentPluginTools(ctx: {
210
+ readonly registry: {
211
+ register: (registration: ToolRegistration) => void;
212
+ };
213
+ readonly workspaceId: string;
214
+ readonly ports: AgentPluginHostToolPorts;
215
+ readonly withExtensionApprovalPolicy: ApplyHostToolApprovalPolicy;
216
+ }, optional?: {
217
+ readonly hostGuidance?: HostGuidancePort;
218
+ }): Promise<void>;
219
+ //# sourceMappingURL=skill-tool.d.ts.map