@jini-ai/agent-plugins 0.7.1 → 0.7.3-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/NOTICE +2 -0
  3. package/README.md +11 -15
  4. package/calendly/plugin.json +3 -3
  5. package/cloudflare/lib/forms.mjs +9 -10
  6. package/cloudflare/lib/target.mjs +1 -1
  7. package/cloudflare/plugin.json +3 -3
  8. package/cloudflare/worker/forms-receiver.mjs +9 -9
  9. package/composio/plugin.json +3 -3
  10. package/core/persistent-state.js +227 -163
  11. package/dist/admin-surfaces/connections/connections.d.ts +11 -6
  12. package/dist/admin-surfaces/connections/connections.js +102 -85
  13. package/dist/admin-surfaces/node.d.ts +27 -0
  14. package/dist/admin-surfaces/node.js +32 -0
  15. package/dist/admin-surfaces/plugin-state.js +21 -18
  16. package/dist/admin-surfaces/surface-client.d.ts +4 -0
  17. package/dist/admin-surfaces/surface-client.js +124 -117
  18. package/dist/admin-surfaces/surface-handlers.js +21 -17
  19. package/dist/admin-surfaces/theme.d.ts +5 -1
  20. package/dist/admin-surfaces/theme.js +3 -3
  21. package/dist/connect/access-token-tool.d.ts +3 -1
  22. package/dist/connect/access-token-tool.js +3 -2
  23. package/dist/connect/apply-connect-defaults.js +2 -2
  24. package/dist/connect/apply-tool-renames.js +9 -8
  25. package/dist/connect/connect-tool.d.ts +2 -0
  26. package/dist/connect/connect-tool.js +3 -2
  27. package/dist/connect/credential-cards.js +3 -2
  28. package/dist/connect/credential-save-tool.d.ts +14 -11
  29. package/dist/connect/credential-save-tool.js +128 -121
  30. package/dist/connect/enable-access.d.ts +2 -2
  31. package/dist/connect/enable-access.js +6 -6
  32. package/dist/connect/executable/register.js +40 -34
  33. package/dist/connect/federate-mcp.d.ts +21 -11
  34. package/dist/connect/federate-mcp.js +28 -21
  35. package/dist/connect/grant-signed-in-defaults.js +3 -3
  36. package/dist/connect/import-access-token.js +2 -1
  37. package/dist/connect/index.d.ts +1 -0
  38. package/dist/connect/index.js +1 -0
  39. package/dist/connect/plugin-credential-card.js +2 -1
  40. package/dist/connect/plugin-host/index.d.ts +9 -5
  41. package/dist/connect/plugin-host/index.js +113 -100
  42. package/dist/connect/ports.d.ts +1 -1
  43. package/dist/connect/row-update.d.ts +22 -0
  44. package/dist/connect/row-update.js +18 -0
  45. package/dist/connect/switch-on-saved-token.d.ts +4 -2
  46. package/dist/connect/switch-on-saved-token.js +1 -1
  47. package/dist/connect/token-map.d.ts +44 -0
  48. package/dist/connect/token-map.js +49 -0
  49. package/dist/core/identity-namespace.js +5 -0
  50. package/dist/folder-zip.d.ts +3 -1
  51. package/dist/folder-zip.js +2 -2
  52. package/dist/lifecycle/activation.d.ts +4 -4
  53. package/dist/lifecycle/activation.js +4 -5
  54. package/dist/lifecycle/automatic-use.js +236 -210
  55. package/dist/lifecycle/bundled-digests.d.ts +75 -12
  56. package/dist/lifecycle/bundled-digests.js +213 -212
  57. package/dist/lifecycle/bundled-source-archive.d.ts +1 -1
  58. package/dist/lifecycle/bundled-source-archive.js +263 -264
  59. package/dist/lifecycle/capability-projection.d.ts +1 -1
  60. package/dist/lifecycle/capability-projection.js +1 -1
  61. package/dist/lifecycle/credential-card-metadata.d.ts +1 -1
  62. package/dist/lifecycle/credential-card-metadata.js +27 -3
  63. package/dist/lifecycle/exports.js +9 -4
  64. package/dist/lifecycle/fetch-archive.d.ts +1 -1
  65. package/dist/lifecycle/fetch-archive.js +1 -1
  66. package/dist/lifecycle/host-tools/identity.js +3 -2
  67. package/dist/lifecycle/host-tools/ports.d.ts +2 -0
  68. package/dist/lifecycle/host-tools/search-tool.js +8 -8
  69. package/dist/lifecycle/host-tools/skill-tool.d.ts +18 -2
  70. package/dist/lifecycle/host-tools/skill-tool.js +16 -8
  71. package/dist/lifecycle/index.d.ts +118 -110
  72. package/dist/lifecycle/index.js +45 -12
  73. package/dist/lifecycle/install-errors.d.ts +1 -1
  74. package/dist/lifecycle/install-from-url.d.ts +1 -1
  75. package/dist/lifecycle/install-from-url.js +1 -1
  76. package/dist/lifecycle/install.d.ts +7 -2
  77. package/dist/lifecycle/install.js +414 -396
  78. package/dist/lifecycle/installed-package-index.js +45 -42
  79. package/dist/lifecycle/layout.d.ts +1 -1
  80. package/dist/lifecycle/layout.js +1 -1
  81. package/dist/lifecycle/mail/catalog.d.ts +8 -32
  82. package/dist/lifecycle/mail/catalog.js +25 -20
  83. package/dist/lifecycle/mail/contribution.d.ts +2 -2
  84. package/dist/lifecycle/mail/contribution.js +34 -34
  85. package/dist/lifecycle/mail/selection.js +6 -2
  86. package/dist/lifecycle/manifest.d.ts +3 -3
  87. package/dist/lifecycle/manifest.js +4 -4
  88. package/dist/lifecycle/mcp-provisioning.d.ts +3 -3
  89. package/dist/lifecycle/mcp-provisioning.js +3 -3
  90. package/dist/lifecycle/package-paths.d.ts +1 -1
  91. package/dist/lifecycle/package-paths.js +1 -1
  92. package/dist/lifecycle/persistent-state.js +1 -2
  93. package/dist/lifecycle/ports.d.ts +5 -1
  94. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +30 -8
  95. package/dist/lifecycle/resolve-agent-plugin-refs.js +227 -228
  96. package/dist/lifecycle/retire-bundled.d.ts +1 -52
  97. package/dist/lifecycle/retire-bundled.js +134 -84
  98. package/dist/lifecycle/search.d.ts +2 -1
  99. package/dist/lifecycle/search.js +1 -1
  100. package/dist/lifecycle/seed-bundled.d.ts +1 -1
  101. package/dist/lifecycle/seed-bundled.js +154 -155
  102. package/dist/lifecycle/set-enabled.d.ts +1 -1
  103. package/dist/lifecycle/set-enabled.js +1 -1
  104. package/dist/lifecycle/skill-file-reader.js +53 -50
  105. package/dist/lifecycle/tools/projection.d.ts +4 -7
  106. package/dist/lifecycle/tools/projection.js +109 -108
  107. package/dist/lifecycle/trusted-plugin-files.d.ts +2 -2
  108. package/dist/lifecycle/trusted-plugin-files.js +1 -1
  109. package/dist/lifecycle/uninstall.d.ts +1 -1
  110. package/dist/lifecycle/uninstall.js +237 -241
  111. package/dist/lifecycle/update-store.js +20 -17
  112. package/dist/lifecycle/update.js +287 -281
  113. package/dist/lifecycle/yauzl-archive-reader.d.ts +2 -2
  114. package/dist/lifecycle/yauzl-archive-reader.js +8 -2
  115. package/dist/manifest.d.ts +11 -3
  116. package/dist/manifest.js +9 -9
  117. package/fly/jini-credential-schemes.json +11 -0
  118. package/fly/plugin.json +3 -4
  119. package/github/plugin.json +3 -3
  120. package/github/source-control/backup-push.mjs +11 -11
  121. package/github/source-control/commit-site.mjs +3 -3
  122. package/github/source-control/github.mjs +12 -6
  123. package/github/source-control/write-files.mjs +27 -28
  124. package/github-pages/{tovu-deploy-targets.json → jini-deploy-targets.json} +22 -22
  125. package/github-pages/plugin.json +3 -3
  126. package/github-pages/targets/github-pages.mjs +3 -3
  127. package/google-login/plugin.json +3 -3
  128. package/google-workspace/README.md +14 -14
  129. package/google-workspace/form-destinations/README.md +3 -3
  130. package/google-workspace/form-destinations/dedupe.mjs +1 -1
  131. package/google-workspace/form-destinations/mapping.mjs +8 -9
  132. package/google-workspace/form-destinations/sheets.mjs +1 -1
  133. package/google-workspace/{tovu-admin-surfaces.json → jini-admin-surfaces.json} +2 -2
  134. package/google-workspace/{tovu-agent-tools.json → jini-agent-tools.json} +28 -28
  135. package/google-workspace/{tovu-connections.json → jini-connections.json} +2 -2
  136. package/google-workspace/lib/auth.mjs +2 -2
  137. package/google-workspace/lib/form-destination-settings.mjs +1 -1
  138. package/google-workspace/lib/picker-flow.mjs +2 -2
  139. package/google-workspace/lib/request-policy.mjs +1 -1
  140. package/google-workspace/lib/surface-actions.mjs +1 -1
  141. package/google-workspace/plugin.json +3 -3
  142. package/google-workspace/tools/sheets/README.md +3 -3
  143. package/google-workspace/tools/sheets-admin/README.md +3 -3
  144. package/google-workspace/ui/README.md +4 -4
  145. package/google-workspace/ui/connection-panel.mjs +51 -51
  146. package/google-workspace/ui/destination-panel.mjs +34 -34
  147. package/google-workspace/ui/dom.mjs +15 -16
  148. package/google-workspace/ui/picker-flow.mjs +2 -2
  149. package/google-workspace/ui/picker.mjs +19 -19
  150. package/google-workspace/ui/surface-client.mjs +96 -69
  151. package/higgsfield-media/plugin.json +3 -3
  152. package/jev/plugin.json +3 -3
  153. package/kuinetic/CHANGELOG.md +12 -0
  154. package/kuinetic/mcp.json +4 -0
  155. package/kuinetic/plugin.json +27 -0
  156. package/kuinetic/skills/kuinetic/SKILL.md +120 -0
  157. package/kuinetic/skills/kuinetic/references/effects-by-family.md +32 -0
  158. package/kuinetic/skills/kuinetic/references/opt-in-tiers.md +12 -0
  159. package/kuinetic/skills/kuinetic/references/reserved-keys.md +36 -0
  160. package/meilisearch/plugin.json +5 -5
  161. package/netlify/plugin.json +3 -3
  162. package/netlify/targets/netlify.mjs +14 -4
  163. package/opentelemetry/plugin.json +3 -3
  164. package/package.json +25 -20
  165. package/posthog/plugin.json +3 -3
  166. package/railway/plugin.json +3 -3
  167. package/render/plugin.json +3 -3
  168. package/resend/NOTES.md +2 -2
  169. package/resend/adapters/resend.mjs +1 -1
  170. package/resend/{tovu-mail-adapters.json → jini-mail-adapters.json} +1 -1
  171. package/resend/lib/domains.mjs +8 -8
  172. package/resend/plugin.json +3 -3
  173. package/s3-compatible/{tovu-deploy-targets.json → jini-deploy-targets.json} +68 -68
  174. package/s3-compatible/jini-object-stores.json +29 -0
  175. package/s3-compatible/object-stores/s3-compatible.mjs +19 -13
  176. package/s3-compatible/plugin.json +3 -3
  177. package/s3-compatible/targets/s3-compatible.mjs +25 -25
  178. package/sentry/plugin.json +3 -3
  179. package/shadcn-ui/CHANGELOG.md +7 -0
  180. package/shadcn-ui/LICENSE +201 -0
  181. package/shadcn-ui/NOTICE +10 -0
  182. package/shadcn-ui/mcp.json +4 -0
  183. package/shadcn-ui/plugin.json +26 -0
  184. package/shopify/plugin.json +3 -3
  185. package/site-compliance/plugin.json +3 -3
  186. package/site-import/plugin.json +3 -3
  187. package/supabase/mcp.json +1 -4
  188. package/supabase/plugin.json +3 -3
  189. package/ui-ux-design/CHANGELOG.md +13 -0
  190. package/ui-ux-design/NOTICE +2 -0
  191. package/ui-ux-design/README.md +17 -7
  192. package/ui-ux-design/plugin.json +6 -3
  193. package/ui-ux-design/skills/ui-ux-design/SKILL.md +38 -152
  194. package/ui-ux-design/skills/ui-ux-design/references/full-workflow.md +156 -0
  195. package/ui-ux-design/skills/ui-ux-design/references/ui-animation.md +4 -4
  196. package/vercel/NOTES.md +1 -1
  197. package/vercel/object-stores/vercel-blob.mjs +12 -2
  198. package/vercel/plugin.json +3 -3
  199. package/vercel/targets/vercel.mjs +3 -3
  200. package/wordpress/plugin.json +3 -3
  201. package/dist/lifecycle/node.d.ts +0 -11
  202. package/dist/lifecycle/node.js +0 -38
  203. package/fly/tovu-credential-schemes.json +0 -11
  204. package/github/deployments/github.mjs +0 -415
  205. package/s3-compatible/tovu-object-stores.json +0 -29
  206. package/ui-ux-design/skills/ui-ux-design/references/kuinetic-reference.md +0 -184
  207. /package/cloudflare/{tovu-consent.json → jini-consent.json} +0 -0
  208. /package/cloudflare/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  209. /package/cloudflare/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  210. /package/fly/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  211. /package/fly/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  212. /package/github/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  213. /package/github/{tovu-source-control.json → jini-source-control.json} +0 -0
  214. /package/google-login/{tovu-login-providers.json → jini-login-providers.json} +0 -0
  215. /package/google-workspace/{tovu-form-destinations.json → jini-form-destinations.json} +0 -0
  216. /package/meilisearch/{tovu-search-providers.json → jini-search-providers.json} +0 -0
  217. /package/netlify/{tovu-consent.json → jini-consent.json} +0 -0
  218. /package/netlify/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  219. /package/railway/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  220. /package/railway/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  221. /package/render/{tovu-deploy-configs.json → jini-deploy-configs.json} +0 -0
  222. /package/render/{tovu-deploy-ops.json → jini-deploy-ops.json} +0 -0
  223. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/README.md +0 -0
  224. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/SKILL.md +0 -0
  225. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/auth-layout.tsx +0 -0
  226. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/data-table.tsx +0 -0
  227. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/examples/form-pattern.tsx +0 -0
  228. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/component-catalog.md +0 -0
  229. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/customization-guide.md +0 -0
  230. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/migration-guide.md +0 -0
  231. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/resources/setup-guide.md +0 -0
  232. /package/{ui-ux-design → shadcn-ui}/skills/shadcn-ui/scripts/verify-setup.sh +0 -0
  233. /package/vercel/{tovu-consent.json → jini-consent.json} +0 -0
  234. /package/vercel/{tovu-deploy-targets.json → jini-deploy-targets.json} +0 -0
  235. /package/vercel/{tovu-object-stores.json → jini-object-stores.json} +0 -0
@@ -62,251 +62,250 @@ import { createActivationModule } from "./activation.js";
62
62
  import { createBundledDigestsModule } from "./bundled-digests.js";
63
63
  import { createInstalledPackageIndex } from "./installed-package-index.js";
64
64
  import { createCapabilityProjectionModule } from "./capability-projection.js";
65
- function buildModule(ports) {
66
- const persistentState = createPersistentStateModule(ports);
67
- const stat = ports.filesystem.stat.bind(ports.filesystem);
68
- const { resolveAgentPluginActivation } = createActivationModule(ports);
69
- const { preferBundledAgentPluginDigests, readBundledAgentPluginDigests } = createBundledDigestsModule(ports);
70
- const { indexInstalledRoot } = createInstalledPackageIndex({ ports });
71
- const { readInstalledSkillFile } = createCapabilityProjectionModule(ports);
72
- /** Reads the delivery mode for this process. An unset or unrecognised value is `inject` — an A/B
73
- * affordance must never be able to change production behaviour by typo. */
74
- function resolveAgentPluginDeliveryMode() { return ports.deliveryMode; }
75
- /** Legacy internal positional adapter; all admission and file resolution live in the object boundary. */
76
- async function resolveAgentPluginRefs(pluginRefIds, workspaceLayout, deliveryMode = resolveAgentPluginDeliveryMode()) {
77
- return resolveAgentPluginSelection({ pluginRefIds, workspaceLayout }, { deliveryMode });
78
- }
79
- /**
80
- * Resolves every pinned `pluginRefId` into real on-disk text and joins the results into one
81
- * prompt-prefix block, in the order the refs were pinned.
82
- *
83
- * @param pluginRefIds - This run's pinned Agent Plugin ids (`run-start-context.ts`'s decoded
84
- * `pluginRefIds` — already filtered to non-empty strings by that point). An empty array resolves
85
- * to an empty prefix with no filesystem access at all — the common case (no plugin pinned).
86
- * @param workspaceLayout - This run's own workspace's Agent Plugin layout
87
- * (`resolveAgentPluginLayout().forWorkspace(workspaceId)`), never a shared/instance-level one —
88
- * see `layout.ts`'s own tenant-isolation header for why a workspace's installed packages must
89
- * never be resolved against another workspace's tree.
90
- * @param options - Delivery mode, declared skill/file selection, and explicit read-only off-plugin discovery.
91
- * Reads stay bounded to the skill folder; off-plugin discovery grants no tool execution.
92
- * @returns `{ ok: true, promptPrefix }` once every ref resolves, or the FIRST `{ ok: false, reason }`
93
- * encountered — a run pinning two refs where the second is ambiguous still fails clearly, rather
94
- * than partially augmenting the prompt with only the first ref's content.
95
- * @complexity O(r * d) where r is `pluginRefIds.length` and d is the number of installed digests in
96
- * this workspace — each ref independently re-scans the (typically small) digest list, since a
97
- * different ref may resolve to a different digest.
98
- */
99
- // Read ONCE for the whole call, not per ref: it is one small file, and every ref resolves against
100
- // the same workspace's ledger. See `bundled-digests.ts` for why this can only ever RESOLVE an
101
- // ambiguity below, never create one.
102
- // See activation.ts for the shared activation rule. One small file read per pinned ref; the
103
- // fail-CLOSED `resolveAgentPluginActivation` (the same reader the per-call tool gate uses)
104
- // refuses on a corrupt/unreadable file instead of reading it as "nothing recorded". Run pinning
105
- // still requires activation; explicit read-only discovery can inspect an off plugin's guidance
106
- // without granting its tools. An unreadable activation record never becomes consent.
107
- async function resolveAgentPluginSelection({ pluginRefIds, workspaceLayout }, { deliveryMode = resolveAgentPluginDeliveryMode(), allowInactiveGuidance = false, ...request } = {}) {
108
- if (pluginRefIds.length === 0)
109
- return { ok: true, promptPrefix: "" };
110
- const bundledDigests = await readBundledAgentPluginDigests(workspaceLayout.root);
111
- const sections = [];
112
- for (const pluginRefId of pluginRefIds) {
113
- const activation = await resolveAgentPluginActivation(workspaceLayout.root, pluginRefId);
114
- const inactiveRead = allowInactiveGuidance && activation.verdict === 'inactive';
115
- const refusal = activationRefusal(pluginRefId, activation, { allowInactiveGuidance });
116
- if (refusal !== undefined)
117
- return { ok: false, reason: refusal };
118
- const resolved = await resolveOnePluginRef({ pluginRefId, packagesDir: workspaceLayout.root, deliveryMode, bundledDigests }, request);
119
- if (!resolved.ok)
120
- return resolved;
121
- const note = inactiveRead ? `Agent Plugin '${pluginRefId}' is installed, off. Read-only guidance follows; its tools are unavailable until enabled through the existing approval flow.\n\n` : '';
122
- sections.push(note + resolved.section);
123
- }
124
- return { ok: true, promptPrefix: sections.join("\n\n") };
125
- }
126
- /** The run-start refusal for one ref's activation verdict, or `undefined` when it may be injected.
127
- * @complexity O(1). */
128
- // A distinct reason from "not installed", because the operator's remedy is different: the bytes
129
- // ARE here and the fix is to enable the plugin, not to install it. Telling them to install
130
- // something already present is the kind of wrong-but-plausible error message that costs an
131
- // afternoon.
132
- function activationRefusal(pluginRefId, verdict, { allowInactiveGuidance = false } = {}) {
133
- if (verdict.verdict === "active")
134
- return undefined;
135
- if (allowInactiveGuidance && verdict.verdict === 'inactive')
136
- return undefined;
137
- if (verdict.verdict === "undetermined") {
138
- // Native activation-read diagnostics can name the host path; the model needs only the remedy.
139
- return (`Agent Plugin '${pluginRefId}' was not loaded: this workspace's activation record could not be read, so whether ` +
140
- `it is enabled cannot be confirmed. Nothing was injected; repair activations.json and start the run again.`);
141
- }
142
- return (`Agent Plugin '${pluginRefId}' is installed in this workspace but is not enabled — it ships with ${ports.productName} and ` +
143
- "stays inactive until an operator turns it on. Enable it before pinning it to a run.");
65
+ /** Reads the delivery mode for this process. An unset or unrecognised value is `inject` — an A/B
66
+ * affordance must never be able to change production behaviour by typo. */
67
+ function resolveAgentPluginDeliveryMode(ports) { return ports.deliveryMode; }
68
+ /** Legacy internal positional adapter; all admission and file resolution live in the object boundary. */
69
+ async function resolveAgentPluginRefs({ ports, pluginRefIds, workspaceLayout }, { deliveryMode = resolveAgentPluginDeliveryMode(ports) } = {}) {
70
+ return resolveAgentPluginSelection({ ports, pluginRefIds, workspaceLayout }, { deliveryMode });
71
+ }
72
+ /**
73
+ * Resolves every pinned `pluginRefId` into real on-disk text and joins the results into one
74
+ * prompt-prefix block, in the order the refs were pinned.
75
+ *
76
+ * @param pluginRefIds - This run's pinned Agent Plugin ids (`run-start-context.ts`'s decoded
77
+ * `pluginRefIds` — already filtered to non-empty strings by that point). An empty array resolves
78
+ * to an empty prefix with no filesystem access at all — the common case (no plugin pinned).
79
+ * @param workspaceLayout - This run's own workspace's Agent Plugin layout
80
+ * (`resolveAgentPluginLayout().forWorkspace(workspaceId)`), never a shared/instance-level one —
81
+ * see `layout.ts`'s own tenant-isolation header for why a workspace's installed packages must
82
+ * never be resolved against another workspace's tree.
83
+ * @param options - Delivery mode, declared skill/file selection, and explicit read-only off-plugin discovery.
84
+ * Reads stay bounded to the skill folder; off-plugin discovery grants no tool execution.
85
+ * @returns `{ ok: true, promptPrefix }` once every ref resolves, or the FIRST `{ ok: false, reason }`
86
+ * encountered — a run pinning two refs where the second is ambiguous still fails clearly, rather
87
+ * than partially augmenting the prompt with only the first ref's content.
88
+ * @complexity O(r * d) where r is `pluginRefIds.length` and d is the number of installed digests in
89
+ * this workspace — each ref independently re-scans the (typically small) digest list, since a
90
+ * different ref may resolve to a different digest.
91
+ */
92
+ // Read ONCE for the whole call, not per ref: it is one small file, and every ref resolves against
93
+ // the same workspace's ledger. See `bundled-digests.ts` for why this can only ever RESOLVE an
94
+ // ambiguity below, never create one.
95
+ // See activation.ts for the shared activation rule. One small file read per pinned ref; the
96
+ // fail-CLOSED `createActivationModule(ports).resolveAgentPluginActivation` (the same reader the per-call tool gate uses)
97
+ // refuses on a corrupt/unreadable file instead of reading it as "nothing recorded". Run pinning
98
+ // still requires activation; explicit read-only discovery can inspect an off plugin's guidance
99
+ // without granting its tools. An unreadable activation record never becomes consent.
100
+ async function resolveAgentPluginSelection({ ports, pluginRefIds, workspaceLayout }, { deliveryMode = resolveAgentPluginDeliveryMode(ports), allowInactiveGuidance = false, ...request } = {}) {
101
+ if (pluginRefIds.length === 0)
102
+ return { ok: true, promptPrefix: "" };
103
+ const bundledDigests = await createBundledDigestsModule(ports).readBundledAgentPluginDigests(workspaceLayout.root);
104
+ const sections = [];
105
+ for (const pluginRefId of pluginRefIds) {
106
+ const activation = await createActivationModule(ports).resolveAgentPluginActivation(workspaceLayout.root, pluginRefId);
107
+ const inactiveRead = allowInactiveGuidance && activation.verdict === 'inactive';
108
+ const refusal = activationRefusal({ ports, pluginRefId, verdict: activation }, { allowInactiveGuidance });
109
+ if (refusal !== undefined)
110
+ return { ok: false, reason: refusal };
111
+ const resolved = await resolveOnePluginRef({ ports, pluginRefId, packagesDir: workspaceLayout.root, deliveryMode, bundledDigests }, { request });
112
+ if (!resolved.ok)
113
+ return resolved;
114
+ const note = inactiveRead ? `Agent Plugin '${pluginRefId}' is installed, off. Read-only guidance follows; its tools are unavailable until enabled through the existing approval flow.\n\n` : '';
115
+ sections.push(note + resolved.section);
144
116
  }
145
- /** Every installed digest's `InstalledAgentPlugin`, indexed once per call to
146
- * {@link resolveAgentPluginRefs} — one `readdir` plus one `indexInstalledRoot` walk per digest.
147
- * Digest directory names that do not match the expected 64-hex-character shape are skipped rather
148
- * than passed to `indexInstalledRoot` — `packages/sha256/` is not asserted empty of anything else
149
- * a future tool might place there, and a non-digest entry is not this function's to interpret.
150
- *
151
- * Exported for a second caller outside this module: `tool-registrations.ts`'s
152
- * `loadInstalledAgentPluginToolSources` needs the SAME per-digest walk (every installed digest,
153
- * whichever skills each one carries) to build one `agent_plugin_<pluginId>` tool per installed
154
- * plugin — the exact shape this function already builds, just consumed differently than
155
- * `resolveOnePluginRef`'s own "resolve one pinned ref" use below. Reusing this rather than
156
- * re-walking `packages/sha256/*` a second, less-validated way keeps the digest-directory-name check
157
- * and the per-digest failure isolation in exactly one place. */
158
- async function listInstalledPlugins(workspaceRoot) {
159
- const installed = [];
160
- for (const root of await listInstalledPackageRoots({ ports, workspaceRoot })) {
161
- try {
162
- const plugin = await indexInstalledRoot({ packageRoot: root.packageRoot, archiveDigest: root.archiveDigest });
163
- if (plugin.pluginId === root.localId)
164
- installed.push(plugin);
165
- }
166
- catch {
167
- // One corrupt package never hides another plugin. Memory-only folders are not installs.
168
- }
169
- }
170
- return installed;
117
+ return { ok: true, promptPrefix: sections.join("\n\n") };
118
+ }
119
+ /** The run-start refusal for one ref's activation verdict, or `undefined` when it may be injected.
120
+ * @complexity O(1). */
121
+ // A distinct reason from "not installed", because the operator's remedy is different: the bytes
122
+ // ARE here and the fix is to enable the plugin, not to install it. Telling them to install
123
+ // something already present is the kind of wrong-but-plausible error message that costs an
124
+ // afternoon.
125
+ function activationRefusal({ ports, pluginRefId, verdict }, { allowInactiveGuidance = false } = {}) {
126
+ if (verdict.verdict === "active")
127
+ return undefined;
128
+ if (allowInactiveGuidance && verdict.verdict === 'inactive')
129
+ return undefined;
130
+ if (verdict.verdict === "undetermined") {
131
+ // Native activation-read diagnostics can name the host path; the model needs only the remedy.
132
+ return (`Agent Plugin '${pluginRefId}' was not loaded: this workspace's activation record could not be read, so whether ` +
133
+ `it is enabled cannot be confirmed. Nothing was injected; repair activations.json and start the run again.`);
171
134
  }
172
- /**
173
- * Whether one installed archive digest still has its package directory under `packagesDir` — the
174
- * cheap, per-call "is this still installed" signal `tool-registrations.ts`'s tool gate needs.
175
- *
176
- * Lives here, beside {@link listInstalledPlugins}, because it must agree with that walk about two
177
- * things a second implementation would eventually get wrong: that an installed package root IS
178
- * `<packagesDir>/<digest>` and nothing else, and that a directory name is only a digest when it
179
- * matches the 64-hex shape. It deliberately does NOT re-index the package (`indexInstalledRoot`
180
- * reads and validates a manifest, which is far too much per tool call): directory presence is
181
- * exactly what `uninstall.ts` removes, and it removes it by `rename` BEFORE it touches the
182
- * activation record, so the gate observes a removal at least as early as it observes the record's
183
- * deletion, never later.
184
- *
185
- * Follows symlinks (plain `stat`, not `lstat`) on purpose — `listInstalledPlugins` does too, so a
186
- * deployment whose digest directory is a symlink registers a tool that this would otherwise refuse
187
- * to authorize.
188
- *
189
- * @returns `false` for a digest that does not match the installed-directory grammar, for a missing
190
- * directory, for a non-directory at that path, and for ANY filesystem fault — every answer this
191
- * cannot establish positively is `false`, because its one caller uses it to authorize.
192
- * @complexity One `stat`.
193
- */
194
- async function isInstalledDigestPresent(packagesDir, archiveDigest) {
195
- if (!INSTALLED_PLUGIN_DIGEST_PATTERN.test(archiveDigest))
196
- return false;
135
+ return (`Agent Plugin '${pluginRefId}' is installed in this workspace but is not enabled — it ships with ${ports.productName} and ` +
136
+ "stays inactive until an operator turns it on. Enable it before pinning it to a run.");
137
+ }
138
+ /** Every installed digest's `InstalledAgentPlugin`, indexed once per call to
139
+ * {@link resolveAgentPluginRefs} — one `readdir` plus one `createInstalledPackageIndex({ ports }).indexInstalledRoot` walk per digest.
140
+ * Digest directory names that do not match the expected 64-hex-character shape are skipped rather
141
+ * than passed to `createInstalledPackageIndex({ ports }).indexInstalledRoot` — `packages/sha256/` is not asserted empty of anything else
142
+ * a future tool might place there, and a non-digest entry is not this function's to interpret.
143
+ *
144
+ * Exported for a second caller outside this module: `tool-registrations.ts`'s
145
+ * `loadInstalledAgentPluginToolSources` needs the SAME per-digest walk (every installed digest,
146
+ * whichever skills each one carries) to build one `agent_plugin_<pluginId>` tool per installed
147
+ * plugin — the exact shape this function already builds, just consumed differently than
148
+ * `resolveOnePluginRef`'s own "resolve one pinned ref" use below. Reusing this rather than
149
+ * re-walking `packages/sha256/*` a second, less-validated way keeps the digest-directory-name check
150
+ * and the per-digest failure isolation in exactly one place. */
151
+ async function listInstalledPlugins({ ports, workspaceRoot }) {
152
+ const installed = [];
153
+ for (const root of await listInstalledPackageRoots({ ports, workspaceRoot })) {
197
154
  try {
198
- return (await stat(path.join(packagesDir, archiveDigest))).isDirectory();
155
+ const plugin = await createInstalledPackageIndex({ ports }).indexInstalledRoot({ packageRoot: root.packageRoot, archiveDigest: root.archiveDigest });
156
+ if (plugin.pluginId === root.localId)
157
+ installed.push(plugin);
199
158
  }
200
159
  catch {
201
- return false;
160
+ // One corrupt package never hides another plugin. Memory-only folders are not installs.
202
161
  }
203
162
  }
204
- /**
205
- * Resolves one `pluginRefId`, applying the zero/one/many-match rules described in this module's
206
- * own header.
207
- */
208
- // Superseded installs of a BUNDLED plugin are dropped here — by the build's own recorded answer,
209
- // never by picking one. Every id the ledger has no authority over reaches the many-match refusal
210
- // below exactly as it always did.
211
- async function resolveOnePluginRef({ pluginRefId, packagesDir, deliveryMode, bundledDigests }, request = {}) {
212
- const installed = preferBundledAgentPluginDigests(await listInstalledPlugins(packagesDir), bundledDigests);
213
- const matches = installed.filter((plugin) => plugin.pluginId === pluginRefId);
214
- if (matches.length === 0) {
215
- return {
216
- ok: false,
217
- reason: `Agent Plugin '${pluginRefId}' is not installed in this workspace — pinned by the composer but not found under any installed package`,
218
- };
219
- }
220
- if (matches.length > 1) {
221
- const digests = matches.map((plugin) => plugin.archiveDigest).sort();
222
- return {
223
- ok: false,
224
- reason: `Agent Plugin '${pluginRefId}' matches ${matches.length} installed packages (digests: ${digests.join(", ")}) — refusing to guess which one to use`,
225
- };
226
- }
227
- const plugin = matches[0];
228
- // Activation is checked by the caller. A lone copy under an id the bundled ledger records must be
229
- // the digest this build shipped; an operator install (no ledger entry) was digest-verified when
230
- // installed and its skills may guide once enabled (install-upload's trust warning). Inline, not
231
- // trusted-plugin-files' verdict: that module lists installs through this one (import cycle).
232
- const shippedDigest = bundledDigests.get(pluginRefId);
233
- if (shippedDigest !== undefined && shippedDigest !== plugin.archiveDigest) {
234
- return { ok: false, code: 'untrusted', reason: `Agent Plugin '${pluginRefId}' was not loaded: only plugins shipped with ${ports.productName} may add agent guidance under a bundled id (installed digest ${plugin.archiveDigest.slice(0, 12)} is not the one this build shipped)` };
235
- }
236
- if (deliveryMode === "pointer" && request.skill === undefined && request.file === undefined)
237
- return buildPointerSection(pluginRefId, plugin);
238
- return buildInjectedSection({ pluginRefId, packagesDir, plugin }, request);
163
+ return installed;
164
+ }
165
+ /**
166
+ * Whether one installed archive digest still has its package directory under `packagesDir` — the
167
+ * cheap, per-call "is this still installed" signal `tool-registrations.ts`'s tool gate needs.
168
+ *
169
+ * Lives here, beside {@link listInstalledPlugins}, because it must agree with that walk about two
170
+ * things a second implementation would eventually get wrong: that an installed package root IS
171
+ * `<packagesDir>/<digest>` and nothing else, and that a directory name is only a digest when it
172
+ * matches the 64-hex shape. It deliberately does NOT re-index the package (`createInstalledPackageIndex({ ports }).indexInstalledRoot`
173
+ * reads and validates a manifest, which is far too much per tool call): directory presence is
174
+ * exactly what `uninstall.ts` removes, and it removes it by `rename` BEFORE it touches the
175
+ * activation record, so the gate observes a removal at least as early as it observes the record's
176
+ * deletion, never later.
177
+ *
178
+ * Follows symlinks (plain `ports.filesystem.stat`, not `lstat`) on purpose — `listInstalledPlugins` does too, so a
179
+ * deployment whose digest directory is a symlink registers a tool that this would otherwise refuse
180
+ * to authorize.
181
+ *
182
+ * @returns `false` for a digest that does not match the installed-directory grammar, for a missing
183
+ * directory, for a non-directory at that path, and for ANY filesystem fault — every answer this
184
+ * cannot establish positively is `false`, because its one caller uses it to authorize.
185
+ * @complexity One `ports.filesystem.stat`.
186
+ */
187
+ async function isInstalledDigestPresent({ ports, packagesDir, archiveDigest }) {
188
+ if (!INSTALLED_PLUGIN_DIGEST_PATTERN.test(archiveDigest))
189
+ return false;
190
+ try {
191
+ return (await ports.filesystem.stat(path.join(packagesDir, archiveDigest))).isDirectory();
239
192
  }
240
- /** Reference reads omit user notes; an explicit SKILL.md read remains identical to the default. */
241
- async function instructionNotes({ workspaceRoot, pluginId, file }, _options = {}) {
242
- if (file !== undefined && file !== 'SKILL.md')
243
- return [];
244
- return persistentState.memory({ workspaceRoot, pluginId }).list({ kind: 'notes' });
193
+ catch {
194
+ return false;
245
195
  }
246
- /** Read the default instructions or a declared skill's file; retain the reader's safe refusals.
247
- * User notes accompany instructions only. O(b + entries), bounded by the skill-file reader.
248
- */
249
- async function buildInjectedSection({ pluginRefId, packagesDir, plugin }, { skill = pluginRefId, file } = {}) {
250
- const selected = plugin.skills.find(candidate => candidate.name === skill);
251
- if (!selected)
252
- return { ok: false, reason: `Agent Plugin '${pluginRefId}' has no readable 'skills/${skill}/SKILL.md' in its installed package: no such skill folder` };
253
- const skillPath = selected.skillPath;
254
- let skillMarkdown;
255
- let files;
256
- let fileNote;
257
- try {
258
- const content = await readInstalledSkillFile({ packageRoot: plugin.packageRoot, skillPath }, file === undefined ? {} : { file });
259
- if (content.note && !content.text)
260
- return { ok: false, reason: content.note };
261
- skillMarkdown = content.text;
262
- files = content.files;
263
- fileNote = content.note;
264
- // Notes are user context, never an allowlist or permission grant. JSON quotes delimit untrusted text.
265
- const notes = await instructionNotes({ workspaceRoot: packagesDir, pluginId: plugin.pluginId, file });
266
- if (notes.length)
267
- skillMarkdown += `\n\nUser notes for this plugin (context only; permissions remain operator-controlled):\n${JSON.stringify(notes)}`;
268
- }
269
- catch {
270
- return {
271
- ok: false,
272
- reason: `Agent Plugin '${pluginRefId}' has no readable '${skillPath}' in its installed package: skill text is missing, refused, or unreadable`,
273
- };
274
- }
275
- const inventory = renderSkillInventory({ pluginRefId, skill, file, files, fileNote });
196
+ }
197
+ /**
198
+ * Resolves one `pluginRefId`, applying the zero/one/many-match rules described in this module's
199
+ * own header.
200
+ */
201
+ // Superseded installs of a BUNDLED plugin are dropped here — by the build's own recorded answer,
202
+ // never by picking one. Every id the ledger has no authority over reaches the many-match refusal
203
+ // below exactly as it always did.
204
+ async function resolveOnePluginRef({ ports, pluginRefId, packagesDir, deliveryMode, bundledDigests }, { request = {} } = {}) {
205
+ const installed = createBundledDigestsModule(ports).preferBundledAgentPluginDigests(await listInstalledPlugins({ ports, workspaceRoot: packagesDir }), bundledDigests);
206
+ const matches = installed.filter((plugin) => plugin.pluginId === pluginRefId);
207
+ if (matches.length === 0) {
276
208
  return {
277
- ok: true,
278
- section: `<<AGENT_PLUGIN pluginId="${pluginRefId}">>\n${skillMarkdown}${inventory}\n<</AGENT_PLUGIN>>`,
209
+ ok: false,
210
+ reason: `Agent Plugin '${pluginRefId}' is not installed in this workspace — pinned by the composer but not found under any installed package`,
279
211
  };
280
212
  }
281
- // Framing governs whether the agent follows the plugin: describe injected SKILL.md as complete
282
- // instructions and let it require its references. Calling it a summary or making required reads
283
- // conditional lets the outer wrapper override the plugin. The inventory-framing test pins this.
284
- /** Format a selected skill's file inventory using the host's registered tool pointer. O(files). */
285
- function renderSkillInventory({ pluginRefId, skill, file, files, fileNote }, _options = {}) {
286
- const framing = file === undefined || file === 'SKILL.md' ? "The SKILL.md above is this Agent Plugin's own instructions — follow them, including any files it directs you to load before starting work." : "The content above is the requested skill file.";
287
- const pointer = ports.formatPluginToolPointer({ pluginId: pluginRefId, skill, file: '<relative path>' });
288
- return `\n\n${framing} Readable supporting files are listed relative to this skill folder. Request one with ${pointer}.\nfiles: ${JSON.stringify(files)}${fileNote ? "\n" + fileNote : ""}`;
213
+ if (matches.length > 1) {
214
+ const digests = matches.map((plugin) => plugin.archiveDigest).sort();
215
+ return {
216
+ ok: false,
217
+ reason: `Agent Plugin '${pluginRefId}' matches ${matches.length} installed packages (digests: ${digests.join(", ")}) — refusing to guess which one to use`,
218
+ };
289
219
  }
290
- // Parity with `inject`'s own failure: a pinned ref whose eponymous skill is missing must fail
291
- // loudly in BOTH modes. Without this check `pointer` would happily emit a well-formed instruction
292
- // whose no-argument default resolves to some OTHER (alphabetically-first) skill instead of the one
293
- // the pin actually named, and the run would look like the agent disobeyed rather than like the pin
294
- // being wrong.
295
- function buildPointerSection(pluginRefId, plugin) {
296
- if (!plugin.skills.some((skill) => skill.name === pluginRefId)) {
297
- return {
298
- ok: false,
299
- reason: `Agent Plugin '${pluginRefId}' has no readable 'skills/${pluginRefId}/SKILL.md' in its installed package: no such skill folder`,
300
- };
301
- }
302
- const body = ports.formatPluginToolPointer({ pluginId: pluginRefId });
303
- return { ok: true, section: `<<AGENT_PLUGIN pluginId="${pluginRefId}">>\n${body}\n<</AGENT_PLUGIN>>` };
220
+ const plugin = matches[0];
221
+ // Activation is checked by the caller. A lone copy under an id the bundled ledger records must be
222
+ // the digest this build shipped; an operator install (no ledger entry) was digest-verified when
223
+ // installed and its skills may guide once enabled (install-upload's trust warning). Inline, not
224
+ // trusted-plugin-files' verdict: that module lists installs through this one (import cycle).
225
+ const shippedDigest = bundledDigests.get(pluginRefId);
226
+ if (shippedDigest !== undefined && shippedDigest !== plugin.archiveDigest) {
227
+ return { ok: false, code: 'untrusted', reason: `Agent Plugin '${pluginRefId}' was not loaded: only plugins shipped with ${ports.productName} may add agent guidance under a bundled id (installed digest ${plugin.archiveDigest.slice(0, 12)} is not the one this build shipped)` };
304
228
  }
305
- return { resolveAgentPluginRefs, resolveAgentPluginSelection, listInstalledPlugins, isInstalledDigestPresent };
229
+ if (deliveryMode === "pointer" && request.skill === undefined && request.file === undefined)
230
+ return buildPointerSection({ ports, pluginRefId, plugin });
231
+ return buildInjectedSection(ports, { pluginRefId, packagesDir, plugin }, request);
232
+ }
233
+ /** Reference reads omit user notes; an explicit SKILL.md read remains identical to the default. */
234
+ async function instructionNotes({ ports, workspaceRoot, pluginId, file }) {
235
+ if (file !== undefined && file !== 'SKILL.md')
236
+ return [];
237
+ return createPersistentStateModule(ports).memory({ workspaceRoot, pluginId }).list({ kind: 'notes' });
238
+ }
239
+ /** Read the default instructions or a declared skill's file; retain the reader's safe refusals.
240
+ * User notes accompany instructions only. O(b + entries), bounded by the skill-file reader.
241
+ */
242
+ async function buildInjectedSection(ports, { pluginRefId, packagesDir, plugin }, { skill = pluginRefId, file } = {}) {
243
+ const selected = plugin.skills.find(candidate => candidate.name === skill);
244
+ if (!selected)
245
+ return { ok: false, reason: `Agent Plugin '${pluginRefId}' has no readable 'skills/${skill}/SKILL.md' in its installed package: no such skill folder` };
246
+ const skillPath = selected.skillPath;
247
+ let skillMarkdown;
248
+ let files;
249
+ let fileNote;
250
+ try {
251
+ const content = await createCapabilityProjectionModule(ports).readInstalledSkillFile({ packageRoot: plugin.packageRoot, skillPath }, file === undefined ? {} : { file });
252
+ if (content.note && !content.text)
253
+ return { ok: false, reason: content.note };
254
+ skillMarkdown = content.text;
255
+ files = content.files;
256
+ fileNote = content.note;
257
+ // Notes are user context, never an allowlist or permission grant. JSON quotes delimit untrusted text.
258
+ const notes = await instructionNotes({ ports, workspaceRoot: packagesDir, pluginId: plugin.pluginId, file });
259
+ if (notes.length)
260
+ skillMarkdown += `\n\nUser notes for this plugin (context only; permissions remain operator-controlled):\n${JSON.stringify(notes)}`;
261
+ }
262
+ catch {
263
+ return {
264
+ ok: false,
265
+ reason: `Agent Plugin '${pluginRefId}' has no readable '${skillPath}' in its installed package: skill text is missing, refused, or unreadable`,
266
+ };
267
+ }
268
+ const inventory = renderSkillInventory({ ports, pluginRefId, skill, file, files, fileNote });
269
+ return {
270
+ ok: true,
271
+ section: `<<AGENT_PLUGIN pluginId="${pluginRefId}">>\n${skillMarkdown}${inventory}\n<</AGENT_PLUGIN>>`,
272
+ };
273
+ }
274
+ // Framing governs whether the agent follows the plugin: describe injected SKILL.md as complete
275
+ // instructions and let it require its references. Calling it a summary or making required reads
276
+ // conditional lets the outer wrapper override the plugin. The inventory-framing test pins this.
277
+ /** Format a selected skill's file inventory using the host's registered tool pointer. O(files). */
278
+ function renderSkillInventory({ ports, pluginRefId, skill, file, files, fileNote }) {
279
+ const framing = file === undefined || file === 'SKILL.md' ? "The SKILL.md above is this Agent Plugin's own instructions — follow them, including any files it directs you to load before starting work." : "The content above is the requested skill file.";
280
+ const pointer = ports.formatPluginToolPointer({ pluginId: pluginRefId, skill, file: '<relative path>' });
281
+ return `\n\n${framing} Readable supporting files are listed relative to this skill folder. Request one with ${pointer}.\nfiles: ${JSON.stringify(files)}${fileNote ? "\n" + fileNote : ""}`;
282
+ }
283
+ // Parity with `inject`'s own failure: a pinned ref whose eponymous skill is missing must fail
284
+ // loudly in BOTH modes. Without this check `pointer` would happily emit a well-formed instruction
285
+ // whose no-argument default resolves to some OTHER (alphabetically-first) skill instead of the one
286
+ // the pin actually named, and the run would look like the agent disobeyed rather than like the pin
287
+ // being wrong.
288
+ function buildPointerSection({ ports, pluginRefId, plugin }) {
289
+ if (!plugin.skills.some((skill) => skill.name === pluginRefId)) {
290
+ return {
291
+ ok: false,
292
+ reason: `Agent Plugin '${pluginRefId}' has no readable 'skills/${pluginRefId}/SKILL.md' in its installed package: no such skill folder`,
293
+ };
294
+ }
295
+ const body = ports.formatPluginToolPointer({ pluginId: pluginRefId });
296
+ return { ok: true, section: `<<AGENT_PLUGIN pluginId="${pluginRefId}">>\n${body}\n<</AGENT_PLUGIN>>` };
297
+ }
298
+ function buildModule(ports) {
299
+ return {
300
+ resolveAgentPluginRefs: (pluginRefIds, workspaceLayout, deliveryMode) => resolveAgentPluginRefs({ ports, pluginRefIds, workspaceLayout }, deliveryMode === undefined ? {} : { deliveryMode }),
301
+ resolveAgentPluginSelection: (required, optional = {}) => resolveAgentPluginSelection({ ports, ...required }, optional),
302
+ listInstalledPlugins: (workspaceRoot) => listInstalledPlugins({ ports, workspaceRoot }),
303
+ isInstalledDigestPresent: (packagesDir, archiveDigest) => isInstalledDigestPresent({ ports, packagesDir, archiveDigest }),
304
+ };
306
305
  }
307
306
  const instances = new WeakMap();
308
307
  /** Internal composition; one state/queue instance per injected host context. */
309
- export function createResolveAgentPluginRefsModule(ports) {
308
+ export function createResolveAgentPluginRefsModule(ports, _optional = {}) {
310
309
  let instance = instances.get(ports);
311
310
  if (!instance) {
312
311
  instance = buildModule(ports);
@@ -1,54 +1,3 @@
1
- /**
2
- * @file `retireBundledAgentPlugins()` — removes bundled Agent Plugins the host no longer ships from a
3
- * workspace, and moves their users onto the plugin that absorbed them. Runs on every boot from
4
- * `seed-bundled.ts`, after seeding, and is a no-op once a workspace has been migrated.
5
- *
6
- * ---------------------------------------------------------------------------
7
- * Why a retirement step exists
8
- * ---------------------------------------------------------------------------
9
- * Deleting `content/agent-plugins/<id>/` stops the seeder installing a plugin, but it removes nothing
10
- * a workspace already has: the installed package stays under `packages/sha256/`, its activation
11
- * record stays in `activations.json`, and its digest stays in `bundled-digests.json`. An ENABLED
12
- * leftover keeps its skill in every prompt, now duplicating (and slowly contradicting) the successor
13
- * that carries the same content. And the operator cannot remove it: `uninstall.ts` refuses a
14
- * bundled plugin because it would be re-seeded, which is exactly what stops being true here. Owner
15
- * rule: the user never fixes anything by hand, so the boot does it.
16
- *
17
- * ---------------------------------------------------------------------------
18
- * What happens per retired id (idempotent)
19
- * ---------------------------------------------------------------------------
20
- * 1. Nothing installed and no activation record: nothing to do (the second boot after a migration).
21
- * A leftover ledger entry is still dropped.
22
- * 1a. Otherwise EVERY successor must be usable first: installed at the digest `bundled-digests.json`
23
- * records for it (the build's own seed — the same trust `trusted-plugin-files.ts` demands before
24
- * core takes a contribution from it), whether it seeded this boot or on an earlier one. If any
25
- * is not, the retired plugin is KEPT and the outcome is `failed` with the reason; the next boot
26
- * retries. Without this a successor whose seed failed (a broken `plugin.json`, a full disk) left
27
- * the retired plugin removed and only an activation record for the successor — a switch with no
28
- * code behind it (R6, 2026-10-12). A plugin split into several (`deploy` -> `fly`, `render`, ...)
29
- * is kept until all of them are usable: one working successor must not cost the others' capability.
30
- * 2. The retired plugin was ENABLED (explicitly, or by the "absent means active" default while its
31
- * package is installed): the successor is switched on — unless an operator explicitly turned the
32
- * successor off, which is left exactly as it is and reported in the outcome. No silent override.
33
- * 3. The retired plugin's package(s) and activation record are removed through `uninstall.ts`
34
- * (`retiredBundled: true` skips only its bundled refusal). A record with no package left is
35
- * deleted directly.
36
- * 4. The retired id is dropped from `bundled-digests.json`.
37
- *
38
- * A malformed or unreadable activation record for the retired id stops that id's retirement with a
39
- * `failed` outcome and changes nothing: whether the operator had it enabled cannot be established,
40
- * so neither enabling the successor nor deleting the record is safe. The next boot retries.
41
- *
42
- * Out of scope on purpose: nothing a retired plugin could own survives it. Agent Plugins have no
43
- * per-plugin settings store (a workspace's `data/<pluginId>` directory has no production writer),
44
- * and custom credentials (a saved `fly.io` token, say) belong to the workspace, not to a plugin.
45
- *
46
- * Architectural role:
47
- * Composition over `activation.ts`, `uninstall.ts`, and `bundled-digests.ts`. Never throws: every
48
- * failure is captured per id, exactly like `seed-bundled.ts`'s own outcomes, so one stuck retirement
49
- * cannot stop a workspace from booting.
50
- */
51
- /** Extracted from the host plugin lifecycle. Effects are supplied per host context. */
52
1
  import type { BundledAgentPluginEnableOutcome } from "./activation.js";
53
2
  import type { AgentPluginLayout } from "./layout.js";
54
3
  import type { AgentPluginLifecyclePorts } from "./ports.js";
@@ -93,7 +42,7 @@ export interface RetireBundledAgentPluginsOptional {
93
42
  readonly now?: ((required: Record<string, never>) => Date) | undefined;
94
43
  }
95
44
  /** Internal composition; one state/queue instance per injected host context. */
96
- export declare function createRetireBundledModule(ports: AgentPluginLifecyclePorts): {
45
+ export declare function createRetireBundledModule(ports: AgentPluginLifecyclePorts, _optional?: Record<string, never>): {
97
46
  retireBundledAgentPlugins: (required: RetireBundledAgentPluginsRequired, optional?: RetireBundledAgentPluginsOptional) => Promise<readonly RetiredAgentPluginOutcome[]>;
98
47
  };
99
48
  export {};