@jini-ai/agent-plugins 0.6.23 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +13 -0
  3. package/calendly/exports/booking-calendar.css +7 -0
  4. package/calendly/exports/booking-calendar.html +5 -0
  5. package/calendly/mcp.json +10 -0
  6. package/calendly/plugin.json +47 -0
  7. package/calendly/skills/calendly/SKILL.md +27 -0
  8. package/charts-echarts/plugin.json +2 -2
  9. package/charts-recharts/plugin.json +2 -2
  10. package/cloudflare/lib/cms-forms.mjs +57 -0
  11. package/cloudflare/lib/forms.mjs +78 -18
  12. package/cloudflare/lib/target.mjs +17 -4
  13. package/cloudflare/plugin.json +2 -2
  14. package/cloudflare/skills/cloudflare/SKILL.md +4 -4
  15. package/cloudflare/skills/cloudflare/references/workers.md +4 -4
  16. package/cloudflare/worker/forms-receiver.mjs +81 -41
  17. package/cloudflare/worker/portable-validation.mjs +220 -0
  18. package/commerce/plugin.json +17 -0
  19. package/commerce/skills/commerce/SKILL.md +23 -0
  20. package/composio/mcp.json +1 -1
  21. package/composio/plugin.json +2 -2
  22. package/composio/skills/composio/SKILL.md +4 -4
  23. package/core/commerce-server.d.ts +2 -0
  24. package/core/commerce-server.mjs +2 -0
  25. package/dist/admin-surfaces/connections/connections.d.ts +35 -0
  26. package/dist/admin-surfaces/connections/connections.js +135 -0
  27. package/dist/admin-surfaces/connections/index.d.ts +3 -0
  28. package/dist/admin-surfaces/connections/index.js +2 -0
  29. package/dist/admin-surfaces/connections/ports.d.ts +110 -0
  30. package/dist/admin-surfaces/connections/ports.js +2 -0
  31. package/dist/admin-surfaces/index.d.ts +2 -0
  32. package/dist/admin-surfaces/index.js +1 -0
  33. package/dist/admin-surfaces/plugin-state-persistence.d.ts +27 -0
  34. package/dist/admin-surfaces/plugin-state-persistence.js +2 -0
  35. package/dist/admin-surfaces/plugin-state.d.ts +51 -0
  36. package/dist/admin-surfaces/plugin-state.js +106 -0
  37. package/dist/connect/access-token-tool.d.ts +240 -0
  38. package/dist/connect/access-token-tool.js +213 -0
  39. package/dist/connect/apply-connect-defaults.d.ts +91 -0
  40. package/dist/connect/apply-connect-defaults.js +113 -0
  41. package/dist/connect/apply-tool-renames.d.ts +72 -0
  42. package/dist/connect/apply-tool-renames.js +105 -0
  43. package/dist/connect/connect-card-ui.d.ts +143 -0
  44. package/dist/connect/connect-card-ui.js +106 -0
  45. package/dist/connect/connect-destination.d.ts +35 -0
  46. package/dist/connect/connect-destination.js +45 -0
  47. package/dist/connect/connect-sign-in-wait.d.ts +31 -0
  48. package/dist/connect/connect-sign-in-wait.js +21 -0
  49. package/dist/connect/connect-tool.d.ts +314 -0
  50. package/dist/connect/connect-tool.js +431 -0
  51. package/dist/connect/connection-status.d.ts +33 -0
  52. package/dist/connect/connection-status.js +63 -0
  53. package/dist/connect/credential-cards.d.ts +15 -0
  54. package/dist/connect/credential-cards.js +49 -0
  55. package/dist/connect/credential-save-tool.d.ts +45 -0
  56. package/dist/connect/credential-save-tool.js +156 -0
  57. package/dist/connect/enable-access.d.ts +67 -0
  58. package/dist/connect/enable-access.js +74 -0
  59. package/dist/connect/executable/approval.d.ts +58 -0
  60. package/dist/connect/executable/approval.js +40 -0
  61. package/dist/connect/executable/host-capabilities.d.ts +76 -0
  62. package/dist/connect/executable/host-capabilities.js +100 -0
  63. package/dist/connect/executable/index.d.ts +10 -0
  64. package/dist/connect/executable/index.js +9 -0
  65. package/dist/connect/executable/ports.d.ts +189 -0
  66. package/dist/connect/executable/ports.js +2 -0
  67. package/dist/connect/executable/register.d.ts +21 -0
  68. package/dist/connect/executable/register.js +125 -0
  69. package/dist/connect/federate-mcp.d.ts +190 -0
  70. package/dist/connect/federate-mcp.js +440 -0
  71. package/dist/connect/grant-signed-in-defaults.d.ts +96 -0
  72. package/dist/connect/grant-signed-in-defaults.js +100 -0
  73. package/dist/connect/import-access-token.d.ts +114 -0
  74. package/dist/connect/import-access-token.js +103 -0
  75. package/dist/connect/index.d.ts +19 -0
  76. package/dist/connect/index.js +19 -0
  77. package/dist/connect/plugin-credential-card.d.ts +46 -0
  78. package/dist/connect/plugin-credential-card.js +63 -0
  79. package/dist/connect/plugin-host/index.d.ts +203 -0
  80. package/dist/connect/plugin-host/index.js +153 -0
  81. package/dist/connect/ports.d.ts +74 -0
  82. package/dist/connect/ports.js +2 -0
  83. package/dist/connect/switch-on-saved-token.d.ts +48 -0
  84. package/dist/connect/switch-on-saved-token.js +20 -0
  85. package/dist/connect/token-sign-in.d.ts +51 -0
  86. package/dist/connect/token-sign-in.js +43 -0
  87. package/dist/core/identity-namespace.d.ts +39 -0
  88. package/dist/core/identity-namespace.js +61 -3
  89. package/dist/folder-zip-node.js +3 -1
  90. package/dist/lifecycle/automatic-use.d.ts +12 -7
  91. package/dist/lifecycle/automatic-use.js +37 -28
  92. package/dist/lifecycle/capability-projection.js +5 -1
  93. package/dist/lifecycle/contribution-loader.d.ts +2 -7
  94. package/dist/lifecycle/contribution-types.d.ts +8 -0
  95. package/dist/lifecycle/contribution-types.js +2 -0
  96. package/dist/lifecycle/credential-card-metadata.d.ts +23 -0
  97. package/dist/lifecycle/credential-card-metadata.js +184 -0
  98. package/dist/lifecycle/exports.d.ts +11 -0
  99. package/dist/lifecycle/exports.js +64 -3
  100. package/dist/lifecycle/host-tools/identity.d.ts +38 -0
  101. package/dist/lifecycle/host-tools/identity.js +58 -0
  102. package/dist/lifecycle/host-tools/index.d.ts +20 -0
  103. package/dist/lifecycle/host-tools/index.js +20 -0
  104. package/dist/lifecycle/host-tools/memory-tools.d.ts +22 -0
  105. package/dist/lifecycle/host-tools/memory-tools.js +63 -0
  106. package/dist/lifecycle/host-tools/ports.d.ts +121 -0
  107. package/dist/lifecycle/host-tools/ports.js +2 -0
  108. package/dist/lifecycle/host-tools/provider-status-tool.d.ts +88 -0
  109. package/dist/lifecycle/host-tools/provider-status-tool.js +45 -0
  110. package/dist/lifecycle/host-tools/search-tool.d.ts +74 -0
  111. package/dist/lifecycle/host-tools/search-tool.js +282 -0
  112. package/dist/lifecycle/host-tools/skill-tool.d.ts +219 -0
  113. package/dist/lifecycle/host-tools/skill-tool.js +482 -0
  114. package/dist/lifecycle/host-tools/write-note-tool.d.ts +22 -0
  115. package/dist/lifecycle/host-tools/write-note-tool.js +47 -0
  116. package/dist/lifecycle/index.d.ts +2 -1
  117. package/dist/lifecycle/install.js +2 -1
  118. package/dist/lifecycle/installed-package-index.js +5 -8
  119. package/dist/lifecycle/mail/adapter-descriptors.d.ts +78 -0
  120. package/dist/lifecycle/mail/adapter-descriptors.js +155 -0
  121. package/dist/lifecycle/mail/catalog.d.ts +116 -0
  122. package/dist/lifecycle/mail/catalog.js +72 -0
  123. package/dist/lifecycle/mail/configuration.d.ts +25 -0
  124. package/dist/lifecycle/mail/configuration.js +62 -0
  125. package/dist/lifecycle/mail/contribution.d.ts +89 -0
  126. package/dist/lifecycle/mail/contribution.js +115 -0
  127. package/dist/lifecycle/mail/host-mailer.d.ts +24 -0
  128. package/dist/lifecycle/mail/host-mailer.js +10 -0
  129. package/dist/lifecycle/mail/index.d.ts +16 -0
  130. package/dist/lifecycle/mail/index.js +16 -0
  131. package/dist/lifecycle/mail/selection.d.ts +40 -0
  132. package/dist/lifecycle/mail/selection.js +86 -0
  133. package/dist/lifecycle/manifest.d.ts +7 -2
  134. package/dist/lifecycle/manifest.js +32 -9
  135. package/dist/lifecycle/metadata.d.ts +31 -0
  136. package/dist/lifecycle/metadata.js +80 -0
  137. package/dist/lifecycle/persistent-state.js +2 -1
  138. package/dist/lifecycle/ports.d.ts +2 -0
  139. package/dist/lifecycle/resolve-agent-plugin-refs.d.ts +2 -1
  140. package/dist/lifecycle/resolve-agent-plugin-refs.js +14 -8
  141. package/dist/lifecycle/search-projection.d.ts +3 -4
  142. package/dist/lifecycle/search-projection.js +5 -7
  143. package/dist/lifecycle/search.js +3 -2
  144. package/fly/plugin.json +5 -5
  145. package/fly/skills/fly/SKILL.md +1 -1
  146. package/formspree/plugin.json +7 -0
  147. package/formspree/skills/formspree/SKILL.md +11 -0
  148. package/github/plugin.json +2 -2
  149. package/github/skills/github/SKILL.md +28 -28
  150. package/github/skills/github/references/actions.md +8 -8
  151. package/github/skills/github/references/auth-and-tokens.md +7 -7
  152. package/github/skills/github/references/repo-files.md +5 -5
  153. package/github/skills/github/references/site-backup.md +16 -16
  154. package/github/skills/github/references/source-control.md +17 -17
  155. package/github-pages/plugin.json +2 -2
  156. package/github-pages/skills/github-pages/SKILL.md +3 -3
  157. package/google-forms/plugin.json +7 -0
  158. package/google-forms/skills/google-forms/SKILL.md +15 -0
  159. package/google-login/plugin.json +3 -3
  160. package/google-login/skills/google-login/SKILL.md +17 -60
  161. package/google-workspace/plugin.json +6 -6
  162. package/google-workspace/skills/google-workspace/references/connection.md +1 -1
  163. package/google-workspace/skills/google-workspace/references/form-delivery.md +4 -4
  164. package/google-workspace/tovu-admin-surfaces.json +5 -5
  165. package/higgsfield-media/plugin.json +5 -5
  166. package/higgsfield-media/skills/higgsfield-media/SKILL.md +31 -33
  167. package/higgsfield-media/skills/higgsfield-media/references/failure-modes.md +7 -7
  168. package/higgsfield-media/skills/higgsfield-media/references/models-and-plan-gates.md +3 -3
  169. package/jev/plugin.json +2 -2
  170. package/langfuse/plugin.json +2 -2
  171. package/meilisearch/plugin.json +2 -2
  172. package/meilisearch/skills/meilisearch/SKILL.md +1 -1
  173. package/netlify/plugin.json +2 -2
  174. package/netlify/skills/netlify/SKILL.md +3 -3
  175. package/opentelemetry/plugin.json +2 -2
  176. package/opentelemetry/skills/opentelemetry/SKILL.md +7 -7
  177. package/package.json +92 -14
  178. package/posthog/plugin.json +2 -2
  179. package/posthog/skills/posthog/SKILL.md +7 -7
  180. package/railway/plugin.json +3 -3
  181. package/railway/skills/railway/SKILL.md +10 -11
  182. package/render/plugin.json +3 -3
  183. package/render/skills/render/SKILL.md +7 -8
  184. package/resend/NOTES.md +2 -2
  185. package/resend/mcp.json +1 -1
  186. package/resend/plugin.json +5 -5
  187. package/resend/skills/resend/SKILL.md +13 -13
  188. package/s3-compatible/plugin.json +2 -2
  189. package/s3-compatible/skills/s3-compatible/SKILL.md +4 -4
  190. package/sentry/plugin.json +2 -2
  191. package/sentry/skills/sentry/SKILL.md +7 -7
  192. package/shopify/plugin.json +2 -2
  193. package/site-compliance/plugin.json +2 -2
  194. package/site-compliance/skills/site-compliance/SKILL.md +3 -3
  195. package/site-compliance/skills/site-compliance/references/gdpr-eu-uk.md +1 -1
  196. package/site-import/plugin.json +2 -2
  197. package/slide-design/plugin.json +2 -2
  198. package/software-engineering/LICENSE +201 -0
  199. package/software-engineering/NOTICE +9 -0
  200. package/software-engineering/README.md +89 -0
  201. package/software-engineering/plugin.json +24 -0
  202. package/software-engineering/skills/software-engineering/SKILL.md +33 -0
  203. package/software-engineering/skills/software-engineering/references/debugging.md +54 -0
  204. package/software-engineering/skills/software-engineering/references/implementation.md +27 -0
  205. package/software-engineering/skills/software-engineering/references/planning.md +27 -0
  206. package/software-engineering/skills/software-engineering/references/prototyping.md +14 -0
  207. package/software-engineering/skills/software-engineering/references/security.md +47 -0
  208. package/software-engineering/skills/software-engineering/references/verification.md +53 -0
  209. package/stripe/plugin.json +2 -2
  210. package/supabase/mcp.json +4 -4
  211. package/supabase/plugin.json +3 -3
  212. package/supabase/skills/supabase/SKILL.md +8 -8
  213. package/supabase/skills/supabase/references/failure-modes.md +5 -5
  214. package/ui-ux-design/plugin.json +2 -2
  215. package/vercel/plugin.json +2 -2
  216. package/vercel/skills/vercel/SKILL.md +3 -3
  217. package/wordpress/plugin.json +2 -2
  218. package/wordpress/skills/wordpress/SKILL.md +3 -3
  219. package/wordpress/skills/wordpress/references/free-site-redirect.md +2 -2
  220. package/wordpress/skills/wordpress/references/subdomain.md +5 -5
@@ -0,0 +1,189 @@
1
+ /** Executable tools consume local ports; the host supplies contribution and approval owners. */
2
+ import type { ToolPermissionAuthorizationPort as AuthorizationPort, LegacyToolAuthorizeFn, ToolExecutionContext, ToolMetadata, ToolRegistration, ToolRegistry } from '@jini-ai/core';
3
+ import type { SurfaceCardDetail } from '@jini-ai/core/contracts/cards';
4
+ import type { HttpClientPort } from '@jini-ai/core/primitives';
5
+ import type { AgentPluginLimitResult, AgentPluginStateReader, IssuedTokenMemories } from '../../lifecycle/tools/capabilities.js';
6
+ import type { defineAgentPluginToolContribution, LoadedAgentPluginTool } from '../../lifecycle/tools/definition.js';
7
+ import type { AgentPluginAdditionalTool, AgentPluginToolProjectionPorts } from '../../lifecycle/tools/projection.js';
8
+ import type { AgentPluginToolEffect } from '../../lifecycle/tools/manifest.js';
9
+ /** Which connection a call asks for. `connectionRef` is opaque and comes from plugin input. */
10
+ export interface AgentPluginConnectionTarget {
11
+ readonly workspaceId: string;
12
+ readonly pluginId: string;
13
+ readonly connectionRef: string;
14
+ }
15
+ /** Host port over the API-connection service (implemented with the connection lots). It must refuse
16
+ * a `connectionRef` that the plugin does not own in that workspace, and never return a refresh token. */
17
+ export interface AgentPluginConnectionAccess {
18
+ /** The signed-in account, or null when the connection is not connected or not owned. */
19
+ readAccount(required: AgentPluginConnectionTarget, optional?: Record<string, never>): Promise<{
20
+ readonly accountId: string;
21
+ readonly displayName: string;
22
+ } | null>;
23
+ /** A fresh access token; refuses (`account-changed`) when `expectedAccountId` no longer matches. */
24
+ getAccessToken(required: AgentPluginConnectionTarget, optional?: {
25
+ readonly expectedAccountId?: string;
26
+ }): Promise<string>;
27
+ }
28
+ /** Optional host store for files a tool hands to the user (e.g. an export). */
29
+ export interface AgentPluginArtifactWriter {
30
+ write(required: {
31
+ readonly workspaceId: string;
32
+ readonly pluginId: string;
33
+ readonly name: string;
34
+ readonly mediaType: string;
35
+ readonly content: string | Uint8Array;
36
+ }, optional?: Record<string, never>): Promise<{
37
+ readonly artifactRef: string;
38
+ }>;
39
+ }
40
+ /** The limiter shape of `@jini-ai/http-kit`'s `RateLimiter` (the host's `createRateLimiter`). */
41
+ export interface AgentPluginRateLimiter {
42
+ check(required: {
43
+ readonly key: string;
44
+ }): Promise<AgentPluginLimitResult>;
45
+ }
46
+ /** The read-only settings view for one plugin in one workspace (`api-connections/plugin-state.ts`'s `readerFor`). */
47
+ export type AgentPluginStateReaderFor = (required: {
48
+ readonly workspaceId: string;
49
+ readonly pluginId: string;
50
+ }, optional?: Record<string, never>) => AgentPluginStateReader;
51
+ /** The https origins one plugin's connections declare in one workspace (the union of their `apiOrigins`). */
52
+ export type AgentPluginApiOriginsFor = (required: {
53
+ readonly workspaceId: string;
54
+ readonly pluginId: string;
55
+ }, optional?: Record<string, never>) => Promise<readonly string[]>;
56
+ /** Accounts frozen when a call was confirmed, keyed by that call's abort signal (one per execution). */
57
+ export interface FrozenConnectionAccounts {
58
+ bind(required: {
59
+ readonly signal: AbortSignal;
60
+ readonly accounts: ReadonlyMap<string, string>;
61
+ }, optional?: Record<string, never>): void;
62
+ /** The frozen account id; `null` when the call was frozen but not for this connection; `undefined` when it was never frozen. */
63
+ lookup(required: {
64
+ readonly signal: AbortSignal | undefined;
65
+ readonly connectionRef: string;
66
+ }, optional?: Record<string, never>): string | null | undefined;
67
+ }
68
+ export type AgentPluginProjectionRegistry = AgentPluginToolProjectionPorts['registry'];
69
+ export interface AgentPluginExecutableContributionRegistry extends AgentPluginProjectionRegistry {
70
+ list(required: Record<string, never>, optional?: Record<string, never>): readonly {
71
+ readonly pluginId: string;
72
+ readonly tools: readonly {
73
+ readonly name: string;
74
+ readonly effect?: AgentPluginToolEffect;
75
+ }[];
76
+ }[];
77
+ subscribe(required: {
78
+ readonly onChanged: () => void;
79
+ }, optional?: Record<string, never>): () => void;
80
+ }
81
+ export interface AgentPluginExecutableContributions<Registry extends AgentPluginExecutableContributionRegistry> {
82
+ readonly definition: ReturnType<typeof defineAgentPluginToolContribution>;
83
+ readonly createRegistry: (required: Record<string, never>, optional?: Record<string, never>) => Registry;
84
+ readonly toolIdFor: AgentPluginToolProjectionPorts['toolIdFor'];
85
+ readonly buildRegistrations: (required: {
86
+ readonly contributions: Registry;
87
+ readonly isEnabled: (required: {
88
+ pluginId: string;
89
+ }) => Promise<boolean>;
90
+ readonly resolveAuth: (required: {
91
+ pluginId: string;
92
+ principalId: string;
93
+ }) => Promise<{
94
+ access: 'admin';
95
+ principalId: string;
96
+ workspaceId: string;
97
+ }>;
98
+ readonly metadata: ToolMetadata;
99
+ }) => ToolRegistration[];
100
+ }
101
+ export interface AgentPluginExecutableRuntimeHost {
102
+ readonly loadContributions: (required: {
103
+ workspaceId: string;
104
+ definition: ReturnType<typeof defineAgentPluginToolContribution>;
105
+ }, optional: {
106
+ orderByPluginId?: boolean;
107
+ }) => Promise<{
108
+ items: readonly LoadedAgentPluginTool[];
109
+ refusals: readonly string[];
110
+ }>;
111
+ readonly connections: AgentPluginConnectionAccess;
112
+ readonly http: HttpClientPort;
113
+ readonly limiter: AgentPluginRateLimiter;
114
+ readonly artifacts?: AgentPluginArtifactWriter;
115
+ readonly state: AgentPluginStateReaderFor;
116
+ readonly apiOrigins: AgentPluginApiOriginsFor;
117
+ /**
118
+ * The token memory that withholds issued tokens from plugin output.
119
+ * @agent-note Pass the host's ONE `IssuedTokenMemories`, the same instance the admin-surface
120
+ * handler host uses: a plugin's tools and its admin-surface handlers share module scope, so a token
121
+ * either path obtained must be withheld from both. A second instance leaks tokens across the paths.
122
+ */
123
+ readonly issuedTokens: IssuedTokenMemories;
124
+ /**
125
+ * The accounts confirmations freeze, keyed by each call's abort signal.
126
+ * @agent-note Pass the SAME `FrozenConnectionAccounts` object the admin-surface connections port
127
+ * uses, so an admin action run as a tool is pinned to the account its confirmation showed, like any
128
+ * tool call; a separate map loses those pins. Omitted, the registrar keeps its own map (tool calls
129
+ * are still pinned, admin actions run as tools are not shared with the admin-surface port).
130
+ */
131
+ readonly frozen?: FrozenConnectionAccounts;
132
+ readonly adminSurfaces?: {
133
+ readonly permission: string;
134
+ loadActionTools(required: {
135
+ workspaceId: string;
136
+ authorize: AuthorizationPort;
137
+ connectionKey: (required: {
138
+ workspaceId: string;
139
+ pluginId: string;
140
+ connectionId: string;
141
+ }) => string;
142
+ }): Promise<readonly AgentPluginAdditionalTool[]>;
143
+ };
144
+ }
145
+ export type ApplyAgentPluginApproval = (required: {
146
+ readonly registration: ToolRegistration;
147
+ }, optional: {
148
+ readonly disclose: (required: {
149
+ readonly ctx: ToolExecutionContext;
150
+ }) => Promise<readonly SurfaceCardDetail[]>;
151
+ }) => ToolRegistration;
152
+ export type AgentPluginApprovalFamily = 'agent-plugin-read' | 'agent-plugin-write' | 'agent-plugin-destructive';
153
+ export type ApplyAgentPluginPolicy = (required: {
154
+ readonly registration: ToolRegistration;
155
+ readonly family: AgentPluginApprovalFamily;
156
+ }, optional?: Record<string, never>) => ToolRegistration;
157
+ export interface AgentPluginDisclosureMessages {
158
+ readonly withdrawn: string;
159
+ readonly notConnected: string;
160
+ readonly accountLabel: string;
161
+ readonly affectsLabel: string;
162
+ }
163
+ export interface AgentPluginExecutableRegistrationRequired<Registry extends AgentPluginExecutableContributionRegistry> {
164
+ readonly registry: ToolRegistry;
165
+ readonly workspaceId: string;
166
+ readonly host: AgentPluginExecutableRuntimeHost;
167
+ readonly isActive: (required: {
168
+ readonly pluginId: string;
169
+ }) => Promise<boolean>;
170
+ readonly authorize: LegacyToolAuthorizeFn;
171
+ readonly applyApproval: ApplyAgentPluginApproval;
172
+ /**
173
+ * The RBAC permission `authorize` must grant before any plugin tool runs (checked per call, scoped
174
+ * to the plugin entity). Host vocabulary: each host names its own permission.
175
+ * @agent-note A second host passes the permission its own RBAC grants to assistant operators; no
176
+ * default exists, so a host never silently inherits another product's permission name.
177
+ */
178
+ readonly toolPermission: string;
179
+ readonly withExtensionApprovalPolicy: ApplyAgentPluginPolicy;
180
+ readonly contributions: AgentPluginExecutableContributions<Registry>;
181
+ readonly connectionKey: (required: {
182
+ workspaceId: string;
183
+ pluginId: string;
184
+ connectionId: string;
185
+ }) => string;
186
+ readonly readApproval: NonNullable<ToolMetadata['approval']>;
187
+ readonly disclosureMessages: AgentPluginDisclosureMessages;
188
+ }
189
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1,21 @@
1
+ import type { AgentPluginExecutableContributionRegistry, AgentPluginExecutableRegistrationRequired } from './ports.js';
2
+ /**
3
+ * Loads this workspace's executable Agent Plugin tools and keeps them registered on `registry`.
4
+ * @param required.registry - The core ToolRegistry the assistant executes from (a registration scope needs it).
5
+ * @param required.workspaceId - The workspace whose plugins, activation and connections apply.
6
+ * @param required.host - Loader, connection accessor, guarded HTTP, limiter and optional artifact writer.
7
+ * @param required.isActive - Fresh activation read for one plugin; must deny on any fault.
8
+ * @param required.authorize - The workspace RBAC evaluator; callers need `required.toolPermission`.
9
+ * @param required.toolPermission - The host's RBAC permission a principal needs to run any plugin tool.
10
+ * @param required.applyApproval - The approval owner, applied to write and destructive tools.
11
+ * @returns Refusal lines, `refresh` to reload the active set, and `dispose` to remove every tool.
12
+ * @complexity O(t) tools plus one contained import per tool module (cached by Node).
13
+ */
14
+ export declare function registerAgentPluginExecutableTools<Registry extends AgentPluginExecutableContributionRegistry>(required: AgentPluginExecutableRegistrationRequired<Registry>, _optional?: Record<string, never>): Promise<{
15
+ readonly refusals: readonly string[];
16
+ refresh(): Promise<{
17
+ readonly refusals: readonly string[];
18
+ }>;
19
+ dispose(): void;
20
+ }>;
21
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @file Projects executable Agent Plugin tools (the host-named tools file + `.mjs` modules, admitted
3
+ * by `@jini-ai/agent-plugins/lifecycle/tools`) onto the assistant's ToolRegistry.
4
+ *
5
+ * Reuses, in order: the lifecycle's trusted contribution loader (active plugin, bundled digest,
6
+ * contained module path), Jini's tool projection (schema validation, revocable per-call
7
+ * capabilities, affected-resource disclosure), the plugin tool contract's registration builder
8
+ * (`p_<plugin>__<tool>` ids, enablement + authorization recheck before the handler), a core
9
+ * registration scope (replaced when the plugin set changes), and the host's approval owner.
10
+ *
11
+ * Two host-specific adjustments, both explained where they happen: the contract's
12
+ * `requiresConfirmation` flag is replaced by the approval owner's card (this host has no executor
13
+ * confirmation transport, so that flag would park the call forever), and confirming tools carry no
14
+ * executor deadline (the deadline would expire while the human reads the card, as for native tools).
15
+ */
16
+ import { createToolRegistrationScope } from '@jini-ai/core';
17
+ import { adaptLegacyAuthorize, requireToolPermission } from '@jini-ai/core';
18
+ import { createAgentPluginToolProjection } from '../../lifecycle/tools/projection.js';
19
+ import { APPROVAL_FAMILY_BY_EFFECT, createAgentPluginDisclosure } from './approval.js';
20
+ import { createAgentPluginToolCapabilities, createFrozenConnectionAccounts, } from './host-capabilities.js';
21
+ /** Tool id → owning plugin and declared effect, from the contribution registry's current snapshots. @complexity O(t). */
22
+ function ownersById({ contributions, toolIdFor }) {
23
+ const owners = new Map();
24
+ for (const snapshot of contributions.list({})) {
25
+ for (const tool of snapshot.tools)
26
+ owners.set(toolIdFor({ pluginId: snapshot.pluginId, name: tool.name }), { pluginId: snapshot.pluginId, effect: tool.effect ?? 'destructive' });
27
+ }
28
+ return owners;
29
+ }
30
+ /**
31
+ * Loads this workspace's executable Agent Plugin tools and keeps them registered on `registry`.
32
+ * @param required.registry - The core ToolRegistry the assistant executes from (a registration scope needs it).
33
+ * @param required.workspaceId - The workspace whose plugins, activation and connections apply.
34
+ * @param required.host - Loader, connection accessor, guarded HTTP, limiter and optional artifact writer.
35
+ * @param required.isActive - Fresh activation read for one plugin; must deny on any fault.
36
+ * @param required.authorize - The workspace RBAC evaluator; callers need `required.toolPermission`.
37
+ * @param required.toolPermission - The host's RBAC permission a principal needs to run any plugin tool.
38
+ * @param required.applyApproval - The approval owner, applied to write and destructive tools.
39
+ * @returns Refusal lines, `refresh` to reload the active set, and `dispose` to remove every tool.
40
+ * @complexity O(t) tools plus one contained import per tool module (cached by Node).
41
+ */
42
+ export async function registerAgentPluginExecutableTools(required, _optional = {}) {
43
+ const { registry, workspaceId, host, withExtensionApprovalPolicy } = required;
44
+ const { definition: toolContribution, toolIdFor: pluginToolIdFor } = required.contributions;
45
+ const frozen = host.frozen ?? createFrozenConnectionAccounts();
46
+ const capabilities = createAgentPluginToolCapabilities({ connections: host.connections, http: host.http, limiter: host.limiter, frozen, state: host.state, apiOrigins: host.apiOrigins }, host.artifacts ? { artifacts: host.artifacts } : {});
47
+ const contributions = required.contributions.createRegistry({});
48
+ const projection = createAgentPluginToolProjection({ registry: contributions, toolIdFor: pluginToolIdFor, capabilities, issuedTokens: host.issuedTokens });
49
+ const disclose = createAgentPluginDisclosure({ source: projection, connections: host.connections, frozen, messages: required.disclosureMessages });
50
+ const authorize = adaptLegacyAuthorize({ authorize: required.authorize });
51
+ /** One fresh trust/activation load. Each generation's closures retain its own declaration. */
52
+ async function loadTools() {
53
+ const load = await host.loadContributions({ workspaceId, definition: toolContribution }, { orderByPluginId: true });
54
+ const additionalTools = host.adminSurfaces ? await host.adminSurfaces.loadActionTools({ workspaceId, authorize, connectionKey: required.connectionKey }) : [];
55
+ return { loaded: load.items, refusals: load.refusals, additionalTools };
56
+ }
57
+ const initial = await loadTools();
58
+ let adminToolIds = new Set(initial.additionalTools.map(entry => pluginToolIdFor({ pluginId: entry.pluginId, name: entry.tool.name })));
59
+ const { refusals } = projection.sync(initial);
60
+ const ports = {
61
+ contributions, isEnabled: required.isActive,
62
+ resolveAuth: async ({ pluginId, principalId }) => {
63
+ await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: required.authorize }), workspaceId, principalId, permission: required.toolPermission }, { entityType: 'plugin', entityId: pluginId });
64
+ return { access: 'admin', principalId, workspaceId };
65
+ },
66
+ metadata: { approval: required.readApproval },
67
+ };
68
+ const adapt = (registration, owner) => {
69
+ const toolId = registration.descriptor.id;
70
+ // The contract asks the executor to confirm; the host's executor has no transport for that and would
71
+ // park forever, so the approval owner's card below confirms instead (never less friction).
72
+ const { requiresConfirmation: _parked, timeoutMs, ...descriptor } = registration.descriptor;
73
+ const asks = owner.effect !== 'read';
74
+ const gated = adminToolIds.has(toolId) ? { ...registration, policy: { ...registration.policy, authorize: async (ctx) => {
75
+ if (await registration.policy.authorize(ctx) !== 'allow')
76
+ return 'deny';
77
+ try {
78
+ await requireToolPermission({ authorize, workspaceId, principalId: ctx.principal.id, permission: host.adminSurfaces.permission });
79
+ return 'allow';
80
+ }
81
+ catch {
82
+ return 'deny';
83
+ }
84
+ } } } : registration;
85
+ const nonDestructiveEffect = asks ? 'mutates-durable-state' : 'none';
86
+ const sideEffects = owner.effect === 'destructive' ? 'deletes-durable-state' : nonDestructiveEffect;
87
+ const classified = withExtensionApprovalPolicy({ registration: { ...gated, descriptor: { ...descriptor, readOnly: !asks, sideEffects, ...(asks ? {} : { timeoutMs }) } }, family: APPROVAL_FAMILY_BY_EFFECT[owner.effect] });
88
+ // An admin action may be the one that signs a connection in, so its unconnected ones are left unbound.
89
+ const skipUnconnected = adminToolIds.has(toolId);
90
+ return asks ? required.applyApproval({ registration: classified }, { disclose: ({ ctx }) => disclose({ ctx, toolId, pluginId: owner.pluginId, workspaceId }, { skipUnconnected }) }) : classified;
91
+ };
92
+ const scope = createToolRegistrationScope({ registry });
93
+ const refresh = () => {
94
+ const owners = ownersById({ contributions, toolIdFor: pluginToolIdFor });
95
+ scope.replace({ registrations: required.contributions.buildRegistrations(ports).map((registration) => {
96
+ const owner = owners.get(registration.descriptor.id);
97
+ // Both come from the same snapshots; refusing beats registering a tool with no approval family.
98
+ if (!owner)
99
+ throw new Error(`agent plugin tool '${registration.descriptor.id}' has no owning plugin, so its approval could not be classified`);
100
+ return adapt(registration, owner);
101
+ }) });
102
+ };
103
+ refresh();
104
+ const unsubscribe = contributions.subscribe({ onChanged: refresh });
105
+ let disposed = false;
106
+ // One refresh at a time: an older load that finishes late would otherwise re-register the tools of
107
+ // a plugin a newer load already saw disabled.
108
+ let queue = Promise.resolve();
109
+ return {
110
+ refusals,
111
+ refresh() {
112
+ const run = queue.then(async () => {
113
+ const next = await loadTools();
114
+ if (disposed)
115
+ throw new Error('Plugin tool registration was disposed.');
116
+ adminToolIds = new Set(next.additionalTools.map(entry => pluginToolIdFor({ pluginId: entry.pluginId, name: entry.tool.name })));
117
+ return projection.sync(next);
118
+ });
119
+ queue = run.catch(() => undefined);
120
+ return run;
121
+ },
122
+ dispose() { disposed = true; unsubscribe(); scope.replace({ registrations: [] }); },
123
+ };
124
+ }
125
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1,190 @@
1
+ import type { AgentPluginMcpPort } from "./ports.js";
2
+ import type { AgentPluginMcpProjectionPorts } from "./ports.js";
3
+ import type { AgentPluginDefaultTools, McpServerConfig } from "../lifecycle/manifest.js";
4
+ import type { createAgentPluginLifecycle } from "../lifecycle/index.js";
5
+ /**
6
+ * Derives the `external_mcp_servers.serverId` one plugin-declared server maps to: its OWN declared
7
+ * server key (the `mcp.json` object member name), sanitized into `CONNECTION_ID_PATTERN`'s
8
+ * `[a-z0-9][a-z0-9-]{0,39}` charset — lowercased, every run of other characters collapsed to one
9
+ * `-`, leading/trailing `-` trimmed, truncated to 40.
10
+ *
11
+ * Deliberately NOT namespaced by `pluginId` and NOT hash-suffixed (an earlier revision of this file
12
+ * did both, for collision safety) — see this file's header, rule 1: the id must equal what an
13
+ * operator would have hand-typed, because matching that exact id is what lets a pre-existing,
14
+ * hand-configured row (e.g. `higgsfield`) be recognized and left untouched rather than shadowed by a
15
+ * second, uniquely-derived connection beside it.
16
+ *
17
+ * @returns The derived id, or `null` when the server key sanitizes to nothing usable (e.g. a key
18
+ * made entirely of characters outside `[a-z0-9-]`) — reported as a skip by
19
+ * {@link classifyAgentPluginMcpServerForFederation}, never thrown.
20
+ * @complexity O(n) in the server key's length.
21
+ */
22
+ export declare function deriveAgentPluginConnectionId({ serverKey }: {
23
+ serverKey: string;
24
+ }, _optional?: {}): string | null;
25
+ /** One server this plugin declared that {@link planAgentPluginMcpFederation} will not attempt to
26
+ * provision, and why — reported rather than silently dropped, matching `mcp-federation/trust.ts`'s
27
+ * own "every refusal is reportable, never silent" discipline. */
28
+ export interface SkippedAgentPluginMcpServer {
29
+ readonly serverKey: string;
30
+ readonly reason: string;
31
+ }
32
+ /** One server {@link planAgentPluginMcpFederation} determined should be provisioned (subject to
33
+ * rule 1's existence check at apply time). Carries the derived id and the resolved config, but not
34
+ * yet `workspaceId`/`principalId` — those are per-CALL, not per-server. */
35
+ /** The shape of `classifyAgentPluginMcpServerTrust` (`capability-projection.ts`). */
36
+ export type AgentPluginMcpTrustClassifier = (server: Pick<McpServerConfig, "type">) => "auto-admit" | "requires-confirmation";
37
+ /** @agent-note Product copy for declarations the host's MCP store cannot hold. Returned as skip
38
+ * reasons (shown in enable previews and provisioning warnings), so they name the host's own store;
39
+ * they must never echo a header value or URL credential. */
40
+ export interface AgentPluginMcpFederationMessages {
41
+ /** The server declares the legacy 'sse' transport. */
42
+ sseTransportUnsupported(): string;
43
+ /** The server declares HTTP headers the store does not persist. */
44
+ headersUnsupported(): string;
45
+ }
46
+ /** The host's plugin directory tree; only each workspace's root is read here. */
47
+ export interface AgentPluginLayout {
48
+ forWorkspace(workspaceId: string): {
49
+ readonly root: string;
50
+ };
51
+ }
52
+ /** @agent-note Installed-package reads, bundled-digest preference and the declared `mcp.json` read,
53
+ * with object arguments: the same-named functions `createAgentPluginLifecycle` returns, so a host built
54
+ * on that owner passes it as is. Reads are fresh per call (no cache); preference order is list →
55
+ * bundled digests → prefer, exactly as `resolveAgentPluginMcpServers` calls them. */
56
+ export type AgentPluginInstalledMcpReads = Pick<ReturnType<typeof createAgentPluginLifecycle>, 'listInstalledPlugins' | 'readBundledAgentPluginDigests' | 'preferBundledAgentPluginDigests' | 'readInstalledMcpServers'>;
57
+ export interface PlannedAgentPluginMcpUpsert {
58
+ readonly connectionId: string;
59
+ readonly serverKey: string;
60
+ readonly url: string;
61
+ readonly authMode: "oauth" | "none";
62
+ /** The server declares `tokenAuth`, so a `static_env` row holding a saved access token is one
63
+ * of its declared sign-ins, not a changed auth mode. */
64
+ readonly acceptsAccessToken: boolean;
65
+ }
66
+ export interface AgentPluginMcpFederationPlan {
67
+ readonly toUpsert: readonly PlannedAgentPluginMcpUpsert[];
68
+ readonly skipped: readonly SkippedAgentPluginMcpServer[];
69
+ }
70
+ /**
71
+ * Pure classification pass over one plugin's full mcp.json server configs — no I/O, no
72
+ * `saveExternalMcpServer` call, so this is independently testable from the store's own DB-shaped
73
+ * dependencies.
74
+ *
75
+ * @complexity O(s) in the declared server count.
76
+ */
77
+ export declare function planAgentPluginMcpFederation(input: {
78
+ readonly servers: Readonly<Record<string, McpServerConfig>>;
79
+ }, options: {
80
+ /** The trust rule consulted after the stdio narrowing. The host passes the real
81
+ * `classifyAgentPluginMcpServerTrust`; injectable so the drift guard above (a remote transport
82
+ * reclassified as "requires-confirmation") stays verifiable while today's rule never trips it.
83
+ * @agent-note Required: a second host passes its lifecycle owner's `classifyAgentPluginMcpServerTrust`
84
+ * (object argument adapted to this positional shape); there is no default trust rule here. */
85
+ readonly classifyTrust: AgentPluginMcpTrustClassifier;
86
+ readonly messages: AgentPluginMcpFederationMessages;
87
+ }): AgentPluginMcpFederationPlan;
88
+ /**
89
+ * Resolves one installed plugin's full, validated `mcp.json` server configs, given only its
90
+ * `workspaceId`/`pluginId` — the pair a route naturally has, rather than the `packageRoot`
91
+ * `readInstalledMcpServers` actually needs (`AgentPluginSearchCandidate`, the admin route's own read
92
+ * model, deliberately never carries `packageRoot`: an absolute host path, per
93
+ * `tool-registrations.ts`'s own header). Mirrors the identical `listInstalledPlugins` lookup
94
+ * `set-enabled.ts`'s `setAgentPluginEnabled` already performs for its own installed-check — kept as
95
+ * an independent, small duplication rather than widening that function's settled, tested return
96
+ * shape just to smuggle a path through it.
97
+ *
98
+ * @returns `{}` for a plugin id not installed in this workspace — the caller (a route that already
99
+ * 404s on that condition via `setAgentPluginEnabled`'s own precondition) never actually reaches this
100
+ * case, but this function fails closed rather than throwing a second, redundant error for it.
101
+ * @complexity O(d) in installed-digest count, plus one `mcp.json` read.
102
+ */
103
+ export declare function resolveAgentPluginMcpServers(input: {
104
+ readonly agentPluginLayout: AgentPluginLayout;
105
+ readonly lifecycle: AgentPluginInstalledMcpReads;
106
+ readonly workspaceId: string;
107
+ readonly pluginId: string;
108
+ /** Read-only trust grants require the build's bundled digest, never an arbitrary install. */
109
+ readonly bundledOnly?: boolean;
110
+ }, _optional?: {}): Promise<Readonly<Record<string, McpServerConfig>>>;
111
+ /**
112
+ * Matches a declaration to the stored server identity AND exact endpoint. A URL edit or
113
+ * normalized-name collision must never inherit another endpoint's defaults.
114
+ * @returns The matching defaults, or `null`.
115
+ * @complexity O(s) time, O(1) space in declared servers.
116
+ */
117
+ export declare function findAgentPluginMcpServerDefaults(servers: Readonly<Record<string, McpServerConfig>>, row: {
118
+ readonly serverId: string;
119
+ readonly url: string | null;
120
+ }): AgentPluginDefaultTools | null;
121
+ /**
122
+ * Reads the bundled plugin's current manifest on every roster load. Only a build-seeded
123
+ * digest supplies read trust; URL-only connections and arbitrary installed packages cannot.
124
+ * @returns Reviewed remote names for this exact stored endpoint, otherwise an empty set.
125
+ * @complexity One installed-package scan and manifest read, plus O(s + r) matching/list conversion.
126
+ */
127
+ export declare function resolveAgentPluginReadOnlyRemoteNames(input: {
128
+ readonly agentPluginLayout: AgentPluginLayout;
129
+ readonly lifecycle: AgentPluginInstalledMcpReads;
130
+ readonly workspaceId: string;
131
+ readonly pluginId: string;
132
+ readonly serverId: string;
133
+ readonly url: string;
134
+ }, _optional?: {}): Promise<ReadonlySet<string>>;
135
+ export interface ProvisionAgentPluginMcpServersInput {
136
+ readonly workspaceId: string;
137
+ readonly pluginId: string;
138
+ readonly servers: Readonly<Record<string, McpServerConfig>>;
139
+ /** Attributed on the row exactly as an operator's own Settings → External MCP save would be —
140
+ * `saveExternalMcpServer`'s own `principalId` doc. */
141
+ readonly principalId: string;
142
+ /** @agent-note The host's lifecycle trust rule (see {@link planAgentPluginMcpFederation}); required,
143
+ * never defaulted here. */
144
+ readonly classifyTrust: AgentPluginMcpTrustClassifier;
145
+ /** @agent-note The host's skip-reason copy (see {@link AgentPluginMcpFederationMessages}). */
146
+ readonly messages: AgentPluginMcpFederationMessages;
147
+ }
148
+ export interface ProvisionAgentPluginMcpServersResult {
149
+ /** Connection ids for which a brand-new, disabled row was created this call. */
150
+ readonly provisioned: readonly string[];
151
+ /** Connection ids that already had a row THIS SAME plugin provisioned on an earlier enable, left
152
+ * completely untouched — rule 1's first case. */
153
+ readonly alreadyProvisioned: readonly string[];
154
+ /** Connection ids that already had a row belonging to an operator, or to a DIFFERENT plugin whose
155
+ * url, transport, and auth mode match this declaration, left byte-identical except for
156
+ * `provisionedByPluginId`, which now names this plugin — rule 1's adoption case. Every other field
157
+ * (url, transport, auth mode, allowlist, write grants, any oauth/sealed column) is exactly what it
158
+ * was before this call. A different plugin's row at a non-matching endpoint is refused instead —
159
+ * see {@link failed}. */
160
+ readonly adopted: readonly string[];
161
+ readonly skipped: readonly SkippedAgentPluginMcpServer[];
162
+ readonly failed: readonly SkippedAgentPluginMcpServer[];
163
+ }
164
+ /** A stored JSON tool list that is null, blank, `[]`, or unreadable (the store reads those as `[]`).
165
+ * Shared with `apply-connect-defaults.ts`. */
166
+ export declare function isEmptyJsonList({ raw }: {
167
+ raw: string | null;
168
+ }, _optional?: {}): boolean;
169
+ /**
170
+ * Idempotently provisions one plugin's auto-admitted remote MCP servers into the external-MCP
171
+ * store, called when an operator ENABLES the plugin (never on disable — see this file's header:
172
+ * disabling a plugin has no effect on any row).
173
+ *
174
+ * Rule 1 is enforced per server, right here: `deps.repo.findByServerId` runs BEFORE any write. A row
175
+ * already at the derived id is NEVER passed through `saveExternalMcpServer` — it is either
176
+ * recognized as this same plugin's earlier work (`alreadyProvisioned`), adopted byte-identical
177
+ * except for `provisionedByPluginId` via a direct `repo.upsert` (`adopted`), or, when it belongs to a
178
+ * DIFFERENT plugin at a non-matching endpoint/transport/auth mode, refused as a genuine collision
179
+ * (`failed`). See {@link adoptOrRecognizeExistingAgentPluginMcpServer}.
180
+ *
181
+ * Per-server failures (a store validation error, an unconfigured secret store, a refused collision,
182
+ * or an adoption's upsert failing) are caught and reported rather than thrown, matching
183
+ * `readEnabledExternalMcpConfigs`'s own fail-open posture: one unwritable row must not stop every
184
+ * other server in the same plugin, or the plugin's own activation, from succeeding.
185
+ *
186
+ * @complexity O(s) in the plugin's declared server count, each one an existence check plus at most
187
+ * one create or adopt.
188
+ */
189
+ export declare function provisionAgentPluginMcpServers(deps: AgentPluginMcpProjectionPorts & Pick<AgentPluginMcpPort, "repo" | "saveServer"> & Partial<Pick<AgentPluginMcpPort, "notifyRosterChanged">>, input: ProvisionAgentPluginMcpServersInput): Promise<ProvisionAgentPluginMcpServersResult>;
190
+ //# sourceMappingURL=federate-mcp.d.ts.map