@jini-ai/agent-plugins 0.6.22 → 0.7.0

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 +51 -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,482 @@
1
+ import { buildDomainRegistrations, indexCatalogById, optionalString, requireInputRecord } from "@jini-ai/core";
2
+ import { readInstalledAgentPluginIdentity, UNTESTED_PLUGIN_GUIDANCE } from "./identity.js";
3
+ import { buildPluginMemoryRegistrations } from "./memory-tools.js";
4
+ /**
5
+ * @file Registers each installed, active Agent Plugin as one real ToolRegistry tool.
6
+ *
7
+ * One tool per plugin, with optional skill and file arguments, matches the composer's plugin chip and
8
+ * prevents one multi-skill plugin from crowding native tools out of search results. search_tools
9
+ * is the indexed discovery surface; a parallel capability index would make the agent choose which
10
+ * one to query. Combining skill descriptions dilutes per-term BM25 scores, but keeps result slots
11
+ * available for other tools. Every skill's summary must remain in the combined description so
12
+ * searches can find vocabulary absent from the plugin's top-level name.
13
+ *
14
+ * Tool id scheme: agent_plugin_<pluginId>, with hyphens folded to underscores. A plugin bundles
15
+ * skills and MCP servers; it is not itself a skill. The catalog's first-underscore source splitter
16
+ * labels these as "agent", which is display-only metadata and has no FTS effect. FTS treats
17
+ * underscores as separators and weights id more heavily than description, so the agent/plugin
18
+ * words affect ranking. The install digest stays out of the id to avoid diluting that signal.
19
+ * Multiple installed digests for one id are refused rather than chosen silently. The bundled
20
+ * digest ledger may select the running build's published package when that digest is present;
21
+ * operator installs or a ledger pointing to absent bytes still reach the ambiguity refusal.
22
+ *
23
+ * The optional skill enum documents available skills; ToolRegistry does not enforce schemas.
24
+ * Omitted skill returns the eponymous skill, or the alphabetically-first skill when none matches,
25
+ * plus availableSkills. Concatenating every skill would waste the caller's context. Descriptions
26
+ * and responses identify the default choice. An unknown skill returns the default with a note
27
+ * naming the rejected value and valid choices, so a typo remains recoverable.
28
+ *
29
+ * SECURITY: no absolute host path belongs in ids, descriptions, schemas or handler outputs.
30
+ * packageRoot/skillPath are only local read arguments captured by reader capabilities; AgentPluginToolSource never exposes them.
31
+ * Outputs contain plugin/skill names, guidance markdown and availability, never the source path.
32
+ * The real-install tests assert that the temporary package root is absent from every public field.
33
+ *
34
+ * Dynamic registration is async because installed plugin ids require disk reads. It runs at
35
+ * daemon boot through registerInstalledAgentPluginTools, outside the synchronous ToolContributor
36
+ * seam. Static tools such as search_agent_plugin_local use that seam and read disk in their handlers.
37
+ */
38
+ /** Local presentation helper; sibling formatting helpers have no shared contract to keep in sync. */
39
+ function humanize(value) {
40
+ return value
41
+ .split("-")
42
+ .filter((part) => part.length > 0)
43
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
44
+ .join(" ");
45
+ }
46
+ /** `agent_plugin_<pluginId>` — see this file's header, "Tool id scheme", for why `agent_plugin_` (an
47
+ * installed Agent Plugin, the packaging paradigm) is the correct prefix and not `skill_` (one thing
48
+ * a plugin bundles, not what this tool id names). */
49
+ function toAgentPluginToolId(pluginId) {
50
+ return `agent_plugin_${pluginId.replace(/-/g, "_")}`;
51
+ }
52
+ /** Falls back to the first real prose line when a skill has no (or no parseable) frontmatter — the
53
+ * reference plugin's own `web-compliance` skill is exactly this case: no frontmatter block at all,
54
+ * just an H1 followed by real prose. Skips every heading and blank line. */
55
+ function extractFallbackSummary(markdown) {
56
+ for (const raw of markdown.split("\n")) {
57
+ const line = raw.trim();
58
+ if (line.length > 0 && !line.startsWith("#"))
59
+ return line;
60
+ }
61
+ return undefined;
62
+ }
63
+ /** One skill's summary, for folding into its plugin's combined description — reuses the same
64
+ * frontmatter/fallback parsing the prior per-skill pilot used, just no longer wrapped into a
65
+ * standalone tool description of its own. */
66
+ export function summarizeSkillMarkdown(skillName, markdown, ports) {
67
+ return (ports.readFrontmatterField({ markdown, key: "description" }) ?? extractFallbackSummary(markdown) ?? `${humanize(skillName)} guidance and reference material.`).replace(/\s+/g, " ").trim();
68
+ }
69
+ /**
70
+ * Builds this plugin tool's model-facing description — an operator SEARCH TARGET, not a card blurb.
71
+ * Folds every skill's own summary in so the words an operator would plausibly type ("accessibility",
72
+ * "shadcn component library", "review my UI for compliance") appear directly in indexed text, per
73
+ * this file's header. Names the default skill (and, when there is no eponymous skill, why the
74
+ * fallback was chosen) so a caller reading only the description already knows what a bare call
75
+ * returns.
76
+ *
77
+ * Leads with a scoped "load guidance to use or apply..." clause rather than a bare noun phrase — a live test
78
+ * found the model choosing a native verb-style tool (e.g. `theme_list`) over this plugin even when
79
+ * this plugin's own tool ranked #1 in search for the same query, on prompts where both plausibly fit
80
+ * ("make it look polished and professional"). The imperative opening is a controlled experiment
81
+ * against that selection bias, not a search-ranking change — the skill-vocabulary tail below is
82
+ * unchanged and still does the BM25 work.
83
+ */
84
+ function buildPluginToolDescription(pluginId, skills, defaultSkillName, defaultSkillReason, navigation) {
85
+ const humanPlugin = humanize(pluginId);
86
+ const defaultNote = defaultSkillReason
87
+ ? `Called with no argument, returns the '${defaultSkillName}' skill (${defaultSkillReason}).`
88
+ : `Called with no argument, returns this plugin's own eponymous '${defaultSkillName}' skill.`;
89
+ const details = skills.map((skill) => `${humanize(skill.name)} (${skill.name}) — ${skill.summary}`).join(" | ");
90
+ return (`Load guidance to use or apply this plugin before making any design/implementation decision in its domain — ` +
91
+ `${humanPlugin} guidance from the installed '${pluginId}' Agent Plugin, covering ${skills.length} ` +
92
+ `skill${skills.length === 1 ? "" : "s"}: ${details} ${defaultNote} Pass the optional 'skill' argument ` +
93
+ `to request a different one by name. Pass optional 'file' (for example 'references/foundations.md') ` +
94
+ `relative to the chosen skill folder to read supporting text instead of SKILL.md. Every response lists ` +
95
+ `readable supporting files and other skills with short descriptions; unknown or refused files return a recovery note.` +
96
+ (navigation === undefined ? "" : ` ${navigation}`));
97
+ }
98
+ /**
99
+ * Refuses loudly when the SAME plugin id is installed under two different archive digests —
100
+ * mutates `digestByPluginId` as its record of "digest seen so far per plugin id". Split out of
101
+ * {@link loadInstalledAgentPluginToolSources}'s loop so that loop is left with only the two things
102
+ * it must do per plugin: check-and-record identity, then (if unique) resolve its tool source.
103
+ *
104
+ * @throws {Error} Caught per-plugin by {@link loadInstalledAgentPluginToolSources}'s own loop,
105
+ * which logs it and skips only this one plugin — the throw itself stays the loud, correct signal
106
+ * for this specific plugin's ambiguity; only where it is caught changed.
107
+ */
108
+ function assertSingleDigestPerPlugin(digestByPluginId, plugin) {
109
+ const priorDigest = digestByPluginId.get(plugin.pluginId);
110
+ if (priorDigest !== undefined && priorDigest !== plugin.archiveDigest) {
111
+ throw new Error(`agent-plugin tools: '${plugin.pluginId}' is installed under more than one digest ` +
112
+ `(${priorDigest} and ${plugin.archiveDigest}) — this module wires one tool id per installed plugin id ` +
113
+ `with no digest in the id, so an operator must remove the stale install before this plugin can be wired as a tool`);
114
+ }
115
+ digestByPluginId.set(plugin.pluginId, plugin.archiveDigest);
116
+ }
117
+ /** Reads and summarizes every one of one installed plugin's skills — the only `await`-per-item
118
+ * work in the whole load, isolated so the caller's loop has no nested `for` of its own. */
119
+ async function resolveSkillsForPlugin(plugin, ports) {
120
+ const skills = [];
121
+ for (const skill of plugin.skills) {
122
+ const markdown = await ports.lifecycle.readInstalledSkillMarkdown({ packageRoot: plugin.packageRoot, skillPath: skill.skillPath });
123
+ skills.push({ name: skill.name, summary: summarizeSkillMarkdown(skill.name, markdown, ports), markdown,
124
+ readFile: (_input, options = {}) => ports.lifecycle.readInstalledSkillFile({ packageRoot: plugin.packageRoot, skillPath: skill.skillPath }, options),
125
+ });
126
+ }
127
+ return skills;
128
+ }
129
+ /** Which skill a no-argument (or unrecognized-argument) call to this plugin's tool returns —
130
+ * the plugin's own eponymous skill when one exists, otherwise its alphabetically-first skill (see
131
+ * this file's header, "The optional `skill` argument"). A pure defaulting decision, isolated from
132
+ * the source-object construction that consumes it.
133
+ *
134
+ * @param skills Never empty — every caller only reaches this after the plugin's own
135
+ * `skills.length === 0` short-circuit. */
136
+ function resolveDefaultSkill(skills, pluginId) {
137
+ const eponymous = skills.find((skill) => skill.name === pluginId);
138
+ if (eponymous)
139
+ return { defaultSkillName: eponymous.name };
140
+ // Guarded by every caller (`skills.length === 0` short-circuits first), so `skills[0]` is
141
+ // always defined here.
142
+ const fallbackSkill = skills[0];
143
+ return {
144
+ defaultSkillName: fallbackSkill.name,
145
+ defaultSkillReason: `no eponymous skill folder ('skills/${pluginId}/SKILL.md') exists in this installed package — ` +
146
+ `defaulting to its alphabetically-first skill`,
147
+ };
148
+ }
149
+ /** Assembles one installed plugin's fully-resolved {@link AgentPluginToolSource} from its already
150
+ * fetched skills — pure construction, no I/O, so it's the composition {@link
151
+ * loadInstalledAgentPluginToolSources}'s loop reduces to a call. */
152
+ function buildToolSource(plugin, skills, ports) {
153
+ const { pluginId, archiveDigest } = plugin;
154
+ const { defaultSkillName, defaultSkillReason } = resolveDefaultSkill(skills, pluginId);
155
+ return {
156
+ id: toAgentPluginToolId(pluginId),
157
+ pluginId,
158
+ archiveDigest,
159
+ maturity: plugin.maturity,
160
+ description: buildPluginToolDescription(pluginId, skills, defaultSkillName, defaultSkillReason, ports.messages?.pluginToolNavigation) + (plugin.publisherId ? ` Plugin discovery: ${[plugin.publisherId, ...(plugin.keywords ?? []), ...(plugin.provides ?? [])].join(" ")}.` : ""),
161
+ skills,
162
+ defaultSkillName,
163
+ ...(defaultSkillReason !== undefined ? { defaultSkillReason } : {}),
164
+ };
165
+ }
166
+ /**
167
+ * Loads every installed Agent Plugin for one workspace, resolved into one tool-ready source per
168
+ * plugin. Per-plugin failures are isolated: a pluginId installed under more than one digest (a
169
+ * genuine, actionable ambiguity — see this file's header for why the digest itself is not folded
170
+ * into the id) — or any other per-plugin resolution failure, e.g. an unreadable SKILL.md — is
171
+ * logged via `console.warn` and excluded from the returned array, but never aborts the whole load.
172
+ * One bad plugin install must not take every other installed plugin's tool down with it.
173
+ *
174
+ * @complexity O(d * s) in installed-digest count times average skills-per-digest, dominated by
175
+ * `listInstalledPlugins`'s own walk plus one `readInstalledSkillMarkdown` per skill.
176
+ */
177
+ export async function loadInstalledAgentPluginToolSources(ctx, _optional = {}) {
178
+ const { lifecycle, activations: activationPort } = ctx.ports;
179
+ const workspaceLayout = ctx.ports.layout.forWorkspace({ workspaceId: ctx.workspaceId });
180
+ // Superseded installs of a BUNDLED plugin are dropped BEFORE the ambiguity guard below ever sees
181
+ // them, by the build's own recorded answer rather than by picking one — see `bundled-digests.ts`.
182
+ // An id that ledger has no authority over still reaches `assertSingleDigestPerPlugin` unchanged.
183
+ const installed = lifecycle.preferBundledAgentPluginDigests({
184
+ installed: await lifecycle.listInstalledPlugins({ workspaceRoot: workspaceLayout.root }),
185
+ bundled: await lifecycle.readBundledAgentPluginDigests({ workspaceRoot: workspaceLayout.root }),
186
+ });
187
+ // Filter inactive plugins through the shared lifecycle owner
188
+ // BEFORE the ambiguity check below on purpose: two installed digests of a plugin nobody has
189
+ // enabled is not an operator-actionable error, and throwing on it would let a dormant, disabled
190
+ // package break tool registration for every OTHER plugin in the workspace.
191
+ const activations = await activationPort.readAgentPluginActivations({ workspaceRoot: workspaceLayout.root });
192
+ const active = activationPort.filterActiveAgentPlugins({ activations: activations, items: installed, pluginIdOf: ({ item: plugin }) => plugin.pluginId });
193
+ const digestByPluginId = new Map();
194
+ // Keyed by pluginId (not a plain array) so a LATER conflicting digest can retract an EARLIER
195
+ // digest's already-resolved source for the same plugin — `assertSingleDigestPerPlugin` only
196
+ // throws on the second digest it sees for a given id, so a plain per-iteration push would let
197
+ // ambiguity silently keep whichever digest happened to resolve first, which is exactly the
198
+ // "silently picking one" outcome this file's header says the ambiguity guard must refuse.
199
+ const sourceByPluginId = new Map();
200
+ const poisonedPluginIds = new Set();
201
+ for (const plugin of active) {
202
+ if (poisonedPluginIds.has(plugin.pluginId))
203
+ continue; // already ruled ambiguous; stays excluded
204
+ try {
205
+ assertSingleDigestPerPlugin(digestByPluginId, plugin);
206
+ // Empty skills leave nothing this plugin's tool could ever return.
207
+ if (plugin.skills.length > 0) {
208
+ const skills = await resolveSkillsForPlugin(plugin, ctx.ports);
209
+ const identity = await readInstalledAgentPluginIdentity({ plugin });
210
+ sourceByPluginId.set(plugin.pluginId, buildToolSource({ ...plugin, maturity: identity.maturity, publisherId: identity.id, keywords: identity.keywords, provides: identity.provides }, skills, ctx.ports));
211
+ }
212
+ }
213
+ catch (error) {
214
+ // Isolated per plugin so one bad install (digest ambiguity, an unreadable SKILL.md, ...)
215
+ // cannot take every OTHER installed plugin's tool down with it — see this file's header,
216
+ // "The install DIGEST is deliberately NOT part of the id", for why the digest-ambiguity case
217
+ // itself is still a genuine, actionable refusal, just scoped to this one plugin now.
218
+ sourceByPluginId.delete(plugin.pluginId);
219
+ poisonedPluginIds.add(plugin.pluginId);
220
+ console.warn(`[agent-plugins] '${plugin.pluginId}': ${error instanceof Error ? error.message : String(error)} — skipped`);
221
+ }
222
+ }
223
+ return [...sourceByPluginId.values()];
224
+ }
225
+ /** This module's own risk classification: every plugin tool is a pure read of already-installed,
226
+ * already-validated local content — no domain call, no write path. */
227
+ export function agentPluginToolDerivedRisk({ sources }, _optional = {}) {
228
+ return new Map(sources.map((source) => [source.id, "none"]));
229
+ }
230
+ /** `inputSchema` for one plugin's tool: optional `file` and `skill` strings, the skill `enum` documenting
231
+ * every valid value for THIS installed plugin. Documentation only — `@jini-ai/core`'s
232
+ * `ToolRegistry` never parses or validates `inputSchema`, so an unrecognized value can never be
233
+ * rejected before it reaches {@link readSkillArgument} / {@link buildPluginToolResult}, which
234
+ * handle it gracefully rather than relying on schema enforcement that does not exist. */
235
+ function buildPluginInputSchema(source) {
236
+ const skillNames = source.skills.map((skill) => skill.name);
237
+ return {
238
+ type: "object",
239
+ additionalProperties: false,
240
+ required: [],
241
+ properties: {
242
+ file: {
243
+ type: "string",
244
+ description: "Optional supporting text file relative to the chosen skill folder, e.g. references/foundations.md. Omit to read SKILL.md. Use paths from files in the previous result. Unknown, unsafe, binary or over-256-KiB files return a note and valid files.",
245
+ },
246
+ skill: {
247
+ type: "string",
248
+ enum: skillNames,
249
+ description: `Optional. Request one specific skill's full guidance instead of the default overview. One of: ` +
250
+ `${skillNames.join(", ")}. Defaults to '${source.defaultSkillName}' when omitted; an unrecognized ` +
251
+ `value falls back to that same default and reports the valid values instead of failing.`,
252
+ },
253
+ },
254
+ };
255
+ }
256
+ /** Reads optional `skill` and `file` arguments off `ctx.input`, refusing any OTHER field (mirrors
257
+ * `requireNoInput`'s "reject a populated-but-wrong shape" discipline for the fields this tool
258
+ * does accept) but never rejecting a `skill` value merely because it does not name a real skill —
259
+ * see this file's header on why an unrecognized value is a graceful fallback, not a thrown error. */
260
+ function readSkillArgument(rawInput) {
261
+ if (rawInput === undefined)
262
+ return {};
263
+ const input = requireInputRecord({ input: rawInput });
264
+ const unexpectedKeys = Object.keys(input).filter((key) => key !== "skill" && key !== "file");
265
+ if (unexpectedKeys.length > 0) {
266
+ throw new Error(`this tool accepts only optional 'skill' and 'file' arguments — unexpected field(s): ${unexpectedKeys.join(", ")}`);
267
+ }
268
+ const skill = optionalString({ input, key: "skill" });
269
+ const file = optionalString({ input, key: "file" });
270
+ return { ...(skill !== undefined ? { skill } : {}), ...(file !== undefined ? { file } : {}) };
271
+ }
272
+ /**
273
+ * Resolves one plugin tool's response for a given (possibly absent, possibly unrecognized)
274
+ * requested skill name and optional supporting file. Disk access stays behind the shared-reader capability.
275
+ *
276
+ * - A recognized `requestedSkill` returns exactly that skill.
277
+ * - `undefined` (argument omitted) returns {@link AgentPluginToolSource.defaultSkillName}.
278
+ * - An unrecognized, non-empty `requestedSkill` ALSO returns the default skill, plus a `note`
279
+ * naming the value that was not recognized and listing every valid one — never a thrown error.
280
+ *
281
+ * Every response additionally carries `files` and `availableSkills`: every other skill name and description this plugin has, so
282
+ * a model that got the default (or a specific skill) still knows what else it can ask for next.
283
+ */
284
+ async function buildPluginToolResult(source, input) {
285
+ const { selected, requestedSkill, match, fallback } = selectPluginSkill({ source, input });
286
+ const content = await readPluginSkillGuidance({ selected }, input);
287
+ const notes = [content.note];
288
+ if (requestedSkill !== undefined && !match) {
289
+ // Reflect only a simple name; a caller-supplied absolute path must never appear in a note.
290
+ const label = /^[a-z0-9-]+$/.test(requestedSkill) ? ` '${requestedSkill}'` : "";
291
+ notes.push(`Unrecognized skill${label} for the '${source.pluginId}' plugin — showing the default skill '${fallback.name}' instead. Valid values: ${source.skills.map(skill => skill.name).join(", ")}.`);
292
+ }
293
+ if (input.file !== undefined && !selected.readFile)
294
+ notes.push("File request refused: no supporting-file reader is available. Valid supporting files: (none).");
295
+ return {
296
+ pluginId: source.pluginId,
297
+ ...(source.maturity ? { maturity: source.maturity } : {}),
298
+ skillName: selected.name,
299
+ // Any maturity flag ("untested" or "soon") means not tested end to end: caution before keys/actions.
300
+ guidance: source.maturity ? `${UNTESTED_PLUGIN_GUIDANCE}\n\n${content.guidance}` : content.guidance,
301
+ files: content.files,
302
+ // Keep the availability list short without removing vocabulary from the indexed description.
303
+ availableSkills: source.skills.filter(skill => skill.name !== selected.name).map(skill => ({ name: skill.name, description: skill.summary.slice(0, 320) })),
304
+ ...(notes.some(Boolean) ? { note: notes.filter(Boolean).join(" ") } : {}),
305
+ };
306
+ }
307
+ /**
308
+ * The production gate: one small `activations.json` read plus one `stat` per tool call, both against
309
+ * the same `forWorkspace()` layout every other path in this feature goes through.
310
+ *
311
+ * Deliberately NOT cached. Both facts change when a human toggles or uninstalls a plugin, and the
312
+ * whole point of this gate is that such an act is observed by the very next call; a cache would
313
+ * reintroduce the staleness window the gate exists to close, to save two sub-millisecond reads on a
314
+ * human-paced call.
315
+ *
316
+ * @param ctx.workspaceId - The tenant whose record and packages are consulted. Never an
317
+ * instance-level path.
318
+ * @returns A gate whose answer is established fresh per call, and which denies on any fault.
319
+ * @complexity O(p) per call in the recorded plugin count, plus one small file read and one `stat`.
320
+ */
321
+ export function createAgentPluginToolGate(ctx, _optional = {}) {
322
+ const { lifecycle, activations } = ctx.ports;
323
+ const workspaceLayout = ctx.ports.layout.forWorkspace({ workspaceId: ctx.workspaceId });
324
+ return {
325
+ async isCallable(plugin) {
326
+ // Activation FIRST, installation SECOND — the reverse of uninstall's own order. See the
327
+ // REVOCATION note above for why that ordering is what closes the concurrent-uninstall window.
328
+ const activation = await activations.resolveAgentPluginActivation({ workspaceRoot: workspaceLayout.root, pluginId: plugin.pluginId });
329
+ if (activation.verdict === "undetermined") {
330
+ // The error surface fail-CLOSED is supposed to lack: an operator whose activations file is
331
+ // damaged gets a denial they can see the cause of, next to the daemon's own `denied` record.
332
+ console.warn(`[agent-plugins] '${plugin.pluginId}': tool call denied — activation could not be established (${activation.reason})`);
333
+ return false;
334
+ }
335
+ if (activation.verdict !== "active")
336
+ return false;
337
+ return lifecycle.isInstalledDigestPresent({ packagesDir: workspaceLayout.pluginPackagesDir({ pluginId: plugin.pluginId }), archiveDigest: plugin.archiveDigest });
338
+ },
339
+ };
340
+ }
341
+ /**
342
+ * Wraps one registration's policy so the plugin's CURRENT activation AND installation are both
343
+ * re-established before its handler can be reached, then defers to the policy
344
+ * `buildDomainRegistrations` already attached.
345
+ *
346
+ * Deferring rather than replacing matters: the kit's policy is a deliberate pass-through today
347
+ * (each tool's permission is evaluated at its own chokepoint), and a future kit that puts something
348
+ * real there must not be silently dropped by this wrapper.
349
+ *
350
+ * @complexity O(1) plus the gate's own two reads.
351
+ */
352
+ function withToolGate(registration, gate, plugin) {
353
+ const inner = registration.policy;
354
+ return {
355
+ ...registration,
356
+ policy: {
357
+ async authorize(authCtx) {
358
+ if (!(await gate.isCallable(plugin)))
359
+ return "deny";
360
+ return inner.authorize(authCtx);
361
+ },
362
+ },
363
+ };
364
+ }
365
+ /**
366
+ * Turns already-resolved plugin sources into real `ToolRegistration`s — pure and synchronous, unlike
367
+ * {@link loadInstalledAgentPluginToolSources}, so this is the half a unit test exercises without
368
+ * touching disk. Uses the SAME `buildDomainRegistrations` gate every other domain's
369
+ * `tool-registrations.ts` uses (catalog/risk cross-check, `inputSchema` presence, drift tripwire) —
370
+ * not a parallel mechanism.
371
+ *
372
+ * `gate` is required, not optional, and is applied HERE rather than by the caller for the
373
+ * reason this file's REVOCATION note above gives: a gate a call site has to remember to attach is a
374
+ * gate some future call site will register tools without. Every registration this function can
375
+ * produce carries it. The build itself stays synchronous and touches no disk — the gate reads only
376
+ * when a call is actually authorized.
377
+ *
378
+ * @param sources - Already-resolved, already-activation-filtered plugin sources.
379
+ * @param gate - The per-call revocation gate (see {@link createAgentPluginToolGate}).
380
+ * @complexity O(n) in source count; each source's gate reads are deferred to invocation.
381
+ */
382
+ export function buildAgentPluginToolRegistrations({ sources, gate, withExtensionApprovalPolicy, ports }, _optional = {}) {
383
+ const catalog = sources.map((source) => ({
384
+ name: source.id,
385
+ description: source.description,
386
+ sideEffects: "none",
387
+ authorization: { permission: ports.permissions.use },
388
+ inputSchema: buildPluginInputSchema(source),
389
+ }));
390
+ const handlers = {};
391
+ const identityByToolId = new Map();
392
+ for (const source of sources) {
393
+ handlers[source.id] = async (ctx) => buildPluginToolResult(source, readSkillArgument(ctx.input));
394
+ identityByToolId.set(source.id, { pluginId: source.pluginId, archiveDigest: source.archiveDigest });
395
+ }
396
+ const registrations = buildDomainRegistrations({ ...(ports.metadata ? { metadata: ports.metadata } : {}),
397
+ domain: "agent-plugin-skill",
398
+ catalogModule: "lifecycle/host-tools/skill-tool.ts",
399
+ catalog: indexCatalogById({ catalog: catalog }),
400
+ handlers,
401
+ derivedRisk: agentPluginToolDerivedRisk({ sources }),
402
+ });
403
+ return registrations.map((registration) => {
404
+ const identity = identityByToolId.get(registration.descriptor.id);
405
+ // Unreachable via this function — every registration comes from `handlers`, whose keys are the
406
+ // same `source.id`s the map was built from. Guarded rather than asserted with `!` so a future
407
+ // kit that synthesized an extra registration would be REFUSED rather than silently ungated.
408
+ if (identity === undefined) {
409
+ throw new Error(`tool-registrations: '${registration.descriptor.id}' has no owning Agent Plugin, so its activation could not be gated`);
410
+ }
411
+ return withExtensionApprovalPolicy({ registration: withToolGate(registration, gate, identity), family: 'installed-guidance' });
412
+ });
413
+ }
414
+ /**
415
+ * Composition-root entry point: loads every installed plugin for one workspace and registers each
416
+ * as a real tool directly on `registry` — the same `registry.register(registration)` call
417
+ * `agent-daemon-server.ts`'s own top-level loops make for `buildAssistantToolRegistrations`'s output,
418
+ * just awaited first. See this file's header for why this is a standalone async function rather than
419
+ * a `ToolContributor`, and why it is not (yet) called from that live boot sequence.
420
+ *
421
+ * Registers with the REAL gate, so every tool this puts into the daemon's registry stops answering
422
+ * the moment its plugin is switched off OR uninstalled — see the REVOCATION note above
423
+ * {@link createAgentPluginToolGate}.
424
+ *
425
+ * Each guidance answer carries the host's overlay for that plugin (`optional.hostGuidance`): its
426
+ * `GUIDANCE.md` after any maturity notice, and its `host/` files. Without that port the plugin's own
427
+ * guidance is returned as is.
428
+ */
429
+ export async function registerInstalledAgentPluginTools(ctx, optional = {}) {
430
+ const { registry, ports } = ctx;
431
+ const { hostGuidance } = optional;
432
+ const sources = await loadInstalledAgentPluginToolSources(ctx);
433
+ const gate = createAgentPluginToolGate(ctx);
434
+ for (const registration of buildAgentPluginToolRegistrations({ sources, gate, withExtensionApprovalPolicy: ctx.withExtensionApprovalPolicy, ports })) {
435
+ const handler = registration.handler;
436
+ // Runs after the gate authorized the call, so a disabled plugin never reaches its overlay.
437
+ // A `host/` file is the host's, never the plugin's: the plugin answers its default, the host the file.
438
+ registry.register({ ...registration, handler: async (execution, executionOptional) => {
439
+ const hostFile = requestedHostPluginFile(execution.input, hostGuidance);
440
+ const pluginExecution = hostFile === undefined ? execution : { ...execution, input: withoutFileArgument(execution.input) };
441
+ const result = await handler(pluginExecution, executionOptional);
442
+ const delivered = hostGuidance === undefined ? { guidance: result.guidance } : await hostGuidance.deliver({ result, ...(hostFile !== undefined ? { file: hostFile } : {}) }, { ...(result.maturity ? { notice: UNTESTED_PLUGIN_GUIDANCE } : {}) });
443
+ return { ...result, ...delivered, guidance: await ports.memory.appendNotes({ workspaceId: ctx.workspaceId,
444
+ pluginId: result.pluginId, guidance: delivered.guidance,
445
+ }) };
446
+ } });
447
+ }
448
+ for (const registration of buildPluginMemoryRegistrations({ sources, workspaceId: ctx.workspaceId, ports, gate, withExtensionApprovalPolicy: ctx.withExtensionApprovalPolicy }))
449
+ registry.register(registration);
450
+ }
451
+ /** The `host/` file a plugin tool call names, if any; any other input is the handler's to validate. */
452
+ function requestedHostPluginFile(input, hostGuidance) {
453
+ const file = typeof input === "object" && input !== null ? input.file : undefined;
454
+ return typeof file === "string" && hostGuidance?.isFileRequest({ file }) === true ? file : undefined;
455
+ }
456
+ /** The same input minus `file`, so the plugin's own skill/field validation still runs. */
457
+ function withoutFileArgument(input) {
458
+ return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "file"));
459
+ }
460
+ function selectPluginSkill({ source, input }, _optional = {}) {
461
+ const requestedSkill = input.skill;
462
+ const match = source.skills.find(skill => skill.name === requestedSkill);
463
+ const fallback = source.skills.find(skill => skill.name === source.defaultSkillName);
464
+ if (!fallback) {
465
+ // Cannot happen in practice: `defaultSkillName` is always chosen FROM `source.skills` in
466
+ // `loadInstalledAgentPluginToolSources`. Guarded rather than asserted with `!` so a future bug
467
+ // here fails loudly with an actionable message instead of a null-dereference.
468
+ throw new Error(`agent-plugin tool '${source.id}': default skill '${source.defaultSkillName}' missing from its own skill list`);
469
+ }
470
+ return { selected: match ?? fallback, requestedSkill, match, fallback };
471
+ }
472
+ async function readPluginSkillGuidance({ selected }, optional = {}) {
473
+ const fileOptions = optional.file !== undefined ? { file: optional.file } : {};
474
+ const content = selected.readFile ? await selected.readFile({}, fileOptions) : undefined;
475
+ // An unknown/refused file keeps the skill's instructions available, like unknown-skill recovery.
476
+ return {
477
+ guidance: content && !(content.note && !content.text) ? content.text : selected.markdown,
478
+ files: content?.files ?? [],
479
+ note: content?.note,
480
+ };
481
+ }
482
+ //# sourceMappingURL=skill-tool.js.map
@@ -0,0 +1,22 @@
1
+ import { type AgentToolDefinition, type AgentToolSideEffect, type ToolHandler } from "@jini-ai/core";
2
+ import type { AgentPluginHostToolPorts, RequireHostToolPermission } from "./ports.js";
3
+ export declare const WRITE_PLUGIN_NOTE = "agent_plugin_write_note";
4
+ /** The note tool's catalog entry; the host names the permission a note write needs.
5
+ * @complexity O(1). */
6
+ export declare function pluginNoteToolCatalog(required: {
7
+ readonly permission: string;
8
+ }, _optional?: Record<string, never>): AgentToolDefinition[];
9
+ export declare const pluginNoteRisk: ReadonlyMap<string, AgentToolSideEffect>;
10
+ /**
11
+ * The note-saving handler. Notes are context, never a permission grant.
12
+ * @param required.workspaceId The workspace whose plugin state receives the note.
13
+ * @param required.requirePermission Throws unless the principal holds `ports.permissions.enable`.
14
+ * @param required.ports Installed-plugin lifecycle, layout and memory store.
15
+ * @complexity O(p) for p installed plugins.
16
+ */
17
+ export declare function pluginNoteHandler(required: {
18
+ workspaceId: string;
19
+ requirePermission: RequireHostToolPermission;
20
+ ports: Pick<AgentPluginHostToolPorts, "lifecycle" | "layout" | "memory" | "permissions">;
21
+ }, _optional?: Record<string, never>): ToolHandler;
22
+ //# sourceMappingURL=write-note-tool.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { DEFAULT_PLUGIN_MEMORY_LIMITS } from "../../../core/persistent-state.js";
2
+ import { requireInputRecord, requireString } from "@jini-ai/core";
3
+ export const WRITE_PLUGIN_NOTE = "agent_plugin_write_note";
4
+ /** The note tool's catalog entry; the host names the permission a note write needs.
5
+ * @complexity O(1). */
6
+ export function pluginNoteToolCatalog(required, _optional = {}) {
7
+ return [{ name: WRITE_PLUGIN_NOTE,
8
+ description: "Save the user's explicitly requested project note for an installed Agent Plugin. Writes the note directly; never call to store plugin-discovered facts (use that plugin's learned memory tool).",
9
+ sideEffects: "mutates-durable-state", authorization: { permission: required.permission },
10
+ inputSchema: { type: "object", additionalProperties: false, required: ["pluginId", "entryPath", "text"],
11
+ properties: { pluginId: { type: "string" }, entryPath: { type: "string" }, text: { type: "string", maxLength: 16384 } } },
12
+ }];
13
+ }
14
+ export const pluginNoteRisk = new Map([[WRITE_PLUGIN_NOTE, "mutates-durable-state"]]);
15
+ /**
16
+ * The note-saving handler. Notes are context, never a permission grant.
17
+ * @param required.workspaceId The workspace whose plugin state receives the note.
18
+ * @param required.requirePermission Throws unless the principal holds `ports.permissions.enable`.
19
+ * @param required.ports Installed-plugin lifecycle, layout and memory store.
20
+ * @complexity O(p) for p installed plugins.
21
+ */
22
+ export function pluginNoteHandler(required, _optional = {}) {
23
+ const { lifecycle } = required.ports;
24
+ return async (ctx) => {
25
+ ctx = { ...ctx, input: structuredClone(ctx.input), principal: { ...ctx.principal }, run: { ...ctx.run } };
26
+ const input = requireInputRecord({ input: ctx.input });
27
+ if (Object.keys(input).some(key => !["pluginId", "entryPath", "text"].includes(key)))
28
+ throw new Error("Unexpected note field");
29
+ const pluginId = requireString({ input, key: "pluginId" });
30
+ const entryPath = requireString({ input, key: "entryPath" });
31
+ const text = requireString({ input, key: "text" });
32
+ lifecycle.normalizePackageEntryPath({ rawEntryPath: entryPath });
33
+ if (Buffer.byteLength(text, "utf8") > DEFAULT_PLUGIN_MEMORY_LIMITS.notes || text.includes("\0"))
34
+ throw new Error("Note is not valid bounded UTF-8 text");
35
+ const workspaceId = required.workspaceId;
36
+ await required.requirePermission({ workspaceId,
37
+ principalId: ctx.principal.id, permission: required.ports.permissions.enable }, { entityType: "agent-plugin", entityId: pluginId });
38
+ const layout = required.ports.layout;
39
+ const installed = async () => (await lifecycle.listInstalledPlugins({ workspaceRoot: layout.forWorkspace({ workspaceId }).root })).some(plugin => plugin.pluginId === pluginId);
40
+ if (!(await installed()))
41
+ throw new Error("Agent Plugin is not installed");
42
+ if (ctx.signal.aborted)
43
+ return { saved: false, reason: "abandoned" };
44
+ return { saved: true, ...await required.ports.memory.pluginMemory({ workspaceId, pluginId }).writeNote({ entryPath, text }) };
45
+ };
46
+ }
47
+ //# sourceMappingURL=write-note-tool.js.map
@@ -166,8 +166,9 @@ export declare function createAgentPluginLifecycle(required: AgentPluginLifecycl
166
166
  resolveAgentPluginRefs: ({ pluginRefIds, workspaceLayout }: {
167
167
  pluginRefIds: readonly string[];
168
168
  workspaceLayout: Pick<import("./layout.js").AgentPluginWorkspaceLayout, "packages" | "root">;
169
- }, { deliveryMode, ...request }?: import("./resolve-agent-plugin-refs.js").AgentPluginSkillRequest & {
169
+ }, { deliveryMode, allowInactiveGuidance, ...request }?: import("./resolve-agent-plugin-refs.js").AgentPluginSkillRequest & {
170
170
  deliveryMode?: import("./types.js").AgentPluginDeliveryMode;
171
+ allowInactiveGuidance?: boolean;
171
172
  }) => Promise<import("./resolve-agent-plugin-refs.js").ResolveAgentPluginRefsResult>;
172
173
  pluginMemory: (input: {
173
174
  readonly workspaceId: string;
@@ -1,3 +1,4 @@
1
+ import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
1
2
  import { listInstalledPackageRoots } from "./installed-package-roots.js";
2
3
  import { createUninstallModule } from "./uninstall.js";
3
4
  import { AgentPluginInstallError } from "./install-errors.js";
@@ -105,7 +106,7 @@ function buildModule(ports) {
105
106
  let identity;
106
107
  try {
107
108
  raw = JSON.parse(await readFile(manifestPath, 'utf8'));
108
- identity = readPluginIdentity({ manifest: raw, name: root.localId, namespace: ports.extensionNamespace });
109
+ identity = readPluginIdentity({ manifest: raw, name: root.localId, namespace: resolveAgentPluginLifecycleNamespace({ value: raw, extensionNamespace: ports.extensionNamespace }) });
109
110
  }
110
111
  catch {
111
112
  // A damaged unrelated install must not block fresh installs or bundled seeding.
@@ -1,7 +1,8 @@
1
+ import { resolveAgentPluginLifecycleNamespace } from '../core/identity-namespace.js';
1
2
  /** Read-side owner of installed package metadata; never constructs a mutation lifecycle. */
2
3
  import path from "node:path";
3
4
  import { AgentPluginInstallError } from "./install-errors.js";
4
- import { readAgentPluginExtension, parseAgentPluginManifest as parseAgentPluginManifestValue } from "./manifest.js";
5
+ import { parseAgentPluginManifest as parseAgentPluginManifestValue } from "./manifest.js";
5
6
  /** Keep undeclared metadata absent, including for older packages. No extra manifest read. */
6
7
  function indexedMetadata({ manifest }, _optional = {}) {
7
8
  const { requires, hostRange, exports, renamedFrom } = manifest;
@@ -13,18 +14,14 @@ export function createInstalledPackageIndex(required, _optional = {}) {
13
14
  const { ports } = required;
14
15
  const readFile = ports.filesystem.readFile.bind(ports.filesystem);
15
16
  const readdir = ports.filesystem.readdir.bind(ports.filesystem);
16
- const parseAgentPluginManifest = (value) => parseAgentPluginManifestValue({ value }, { identityNamespace: ports.extensionNamespace });
17
+ const parseAgentPluginManifest = (value) => parseAgentPluginManifestValue({ value }, { identityNamespace: resolveAgentPluginLifecycleNamespace({ value, extensionNamespace: ports.extensionNamespace }) });
17
18
  /** Cosmetic fields are trimmed and capped rather than invalidating the package. The cap stops
18
19
  * a hostile package flooding an admin row. Malformed values fall back because these fields are
19
20
  * cosmetic: callers title-case the id and show the spec description when these keys are absent.
20
21
  * Inner newlines remain paragraph breaks in summaries.
21
22
  * @complexity O(n) in the supplied text length; output is capped at maxLength. */
22
23
  function readDisplayText(required, _optional = {}) {
23
- const text = readAgentPluginExtension({ manifest: required.manifest, namespace: ports.extensionNamespace,
24
- read: ({ value }) => {
25
- const field = value[required.key];
26
- return typeof field === 'string' ? field.trim() : undefined;
27
- } });
24
+ const text = required.manifest[required.key];
28
25
  return text ? { [required.key]: text.slice(0, required.maxLength) } : {};
29
26
  }
30
27
  /** Reads and validates `packageRoot`'s `plugin.json`, refusing a missing, unparseable or invalid one. */
@@ -99,7 +96,7 @@ export function createInstalledPackageIndex(required, _optional = {}) {
99
96
  async function indexInstalledRoot({ packageRoot, archiveDigest }, _optional = {}) {
100
97
  const parsed = await readInstalledManifest({ packageRoot });
101
98
  for (const message of parsed.warnings)
102
- ports.onEvent?.({ event: 'agent-plugin-identity-warning', message });
99
+ ports.onEvent?.({ event: 'agent-plugin-identity-warning', message, pluginId: parsed.manifest.name });
103
100
  const { files, skills } = await walkPackageTree({ packageRoot });
104
101
  return {
105
102
  pluginId: parsed.manifest.name,