@jini-ai/plugins 0.6.22 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/host/admin-response.d.ts +93 -0
  3. package/dist/host/admin-response.js +32 -0
  4. package/dist/host/capability-tools.d.ts +369 -0
  5. package/dist/host/capability-tools.js +306 -0
  6. package/dist/host/declarative-content-types.d.ts +245 -0
  7. package/dist/host/declarative-content-types.js +270 -0
  8. package/dist/host/index.d.ts +3 -0
  9. package/dist/host/index.js +3 -0
  10. package/dist/host/manifest.d.ts +1 -4
  11. package/dist/host/manifest.js +2 -5
  12. package/dist/host/node/archive-policy.d.ts +57 -0
  13. package/dist/host/node/archive-policy.js +115 -0
  14. package/dist/host/node/index.d.ts +3 -0
  15. package/dist/host/node/index.js +3 -0
  16. package/dist/host/node/install.d.ts +1 -4
  17. package/dist/host/node/install.js +2 -8
  18. package/dist/host/node/invocation-binding.d.ts +45 -0
  19. package/dist/host/node/invocation-binding.js +69 -0
  20. package/dist/host/node/runtime-core.d.ts +273 -0
  21. package/dist/host/node/runtime-core.js +613 -0
  22. package/dist/host/node/source-drafts.d.ts +1 -5
  23. package/dist/host/node/source-drafts.js +2 -8
  24. package/dist/host/plugin-claims.d.ts +2 -1
  25. package/dist/host/plugin-claims.js +1 -1
  26. package/dist/host/plugin-format.d.ts +4 -0
  27. package/dist/host/plugin-format.js +4 -0
  28. package/dist/host/plugin-tool-errors.d.ts +11 -0
  29. package/dist/host/plugin-tool-errors.js +19 -0
  30. package/dist/host/tools/contract.d.ts +397 -0
  31. package/dist/host/tools/contract.js +7 -0
  32. package/dist/host/tools/index.d.ts +7 -0
  33. package/dist/host/tools/index.js +6 -0
  34. package/dist/host/tools/install.d.ts +12 -0
  35. package/dist/host/tools/install.js +71 -0
  36. package/dist/host/tools/management.d.ts +51 -0
  37. package/dist/host/tools/management.js +607 -0
  38. package/dist/host/tools/source.d.ts +14 -0
  39. package/dist/host/tools/source.js +95 -0
  40. package/dist/host/worker/index.d.ts +1 -0
  41. package/dist/host/worker/index.js +1 -0
  42. package/dist/host/worker/start.d.ts +44 -0
  43. package/dist/host/worker/start.js +31 -0
  44. package/package.json +16 -9
@@ -2,7 +2,8 @@ import type { ManifestHostPorts } from "./ports.js";
2
2
  import type { PluginActivationRecord } from "./activation.js";
3
3
  import { type ClaimMode, type ExtensionClaim } from "./claim-conflicts.js";
4
4
  import type { PluginDiscoveryRecord } from "./discovery-types.js";
5
- import { CORE_OWNER_ID, type PluginManifest } from "./manifest.js";
5
+ import { CORE_OWNER_ID } from "./plugin-format.js";
6
+ import type { PluginManifest } from "./manifest-types.js";
6
7
  /** The owner id core's claims are filed under, and how messages name it. */
7
8
  export { CORE_OWNER_ID };
8
9
  /**
@@ -38,7 +38,7 @@
38
38
  */
39
39
  import { pluginToolIdFor } from './contributions.js';
40
40
  import { normalizeRoute, resolveClaimConflicts } from "./claim-conflicts.js";
41
- import { CORE_OWNER_ID } from "./manifest.js";
41
+ import { CORE_OWNER_ID } from "./plugin-format.js";
42
42
  /** The owner id core's claims are filed under, and how messages name it. */
43
43
  export { CORE_OWNER_ID };
44
44
  /** How each host hook point arbitrates several plugins (see this file's header). */
@@ -11,4 +11,8 @@ export declare const PLUGIN_SDK_SPECIFIERS: readonly string[];
11
11
  export declare function canonicalizePluginManifest<T>(required: {
12
12
  files: ReadonlyMap<string, T>;
13
13
  }, _optional?: Record<string, never>): Map<string, T>;
14
+ /** The owner id the claim system gives the host core (`plugin-claims.ts` re-exports it). Conflict
15
+ * detection never compares an owner with itself, so a plugin with this id would never conflict with
16
+ * core's reserved routes, tools or permissions — it is refused as an id instead. */
17
+ export declare const CORE_OWNER_ID = "core";
14
18
  //# sourceMappingURL=plugin-format.d.ts.map
@@ -18,4 +18,8 @@ export function canonicalizePluginManifest(required, _optional = {}) {
18
18
  files.set(PLUGIN_MANIFEST_FILENAME, manifest);
19
19
  return files;
20
20
  }
21
+ /** The owner id the claim system gives the host core (`plugin-claims.ts` re-exports it). Conflict
22
+ * detection never compares an owner with itself, so a plugin with this id would never conflict with
23
+ * core's reserved routes, tools or permissions — it is refused as an id instead. */
24
+ export const CORE_OWNER_ID = "core";
21
25
  //# sourceMappingURL=plugin-format.js.map
@@ -0,0 +1,11 @@
1
+ /** Canonical installer refusal shared by portable tools and filesystem adapters. */
2
+ export declare class PluginInstallError extends Error {
3
+ readonly code: string;
4
+ constructor(code: string, message: string);
5
+ }
6
+ /** Canonical source refusal shared by portable tools and filesystem adapters. */
7
+ export declare class PluginSourceError extends Error {
8
+ readonly code: string;
9
+ constructor(code: string, message: string);
10
+ }
11
+ //# sourceMappingURL=plugin-tool-errors.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Canonical installer refusal shared by portable tools and filesystem adapters. */
2
+ export class PluginInstallError extends Error {
3
+ code;
4
+ constructor(code, message) {
5
+ super(message);
6
+ this.code = code;
7
+ this.name = "PluginInstallError";
8
+ }
9
+ }
10
+ /** Canonical source refusal shared by portable tools and filesystem adapters. */
11
+ export class PluginSourceError extends Error {
12
+ code;
13
+ constructor(code, message) {
14
+ super(message);
15
+ this.code = code;
16
+ this.name = 'PluginSourceError';
17
+ }
18
+ }
19
+ //# sourceMappingURL=plugin-tool-errors.js.map
@@ -0,0 +1,397 @@
1
+ import type { AgentToolDefinition, HumanConfirmer, LegacyToolAuthorizeFn, ToolExecutionContext, ToolExecutionOptions, ToolHandler, ToolMetadataById, AccessApprovalResource } from '@jini-ai/core';
2
+ import type { Clock } from '@jini-ai/core/primitives';
3
+ import type { ModelFacingErrorRule } from '@jini-ai/core/model-facing-tool-errors';
4
+ import { type PluginActivationRecord, type PluginActivationRepoPort } from '../activation.js';
5
+ import { type PluginConflict } from '../plugin-claims.js';
6
+ import { type RemovePluginFn, type PluginUninstallPreview } from '../uninstall.js';
7
+ import { type PluginDiscoveryRecord } from '../discovery-types.js';
8
+ import { type PluginInstallInput, type PluginInstallerPort, type PluginInstallPreview } from '../node/install.js';
9
+ import { type PluginSourcePort } from '../node/source-drafts.js';
10
+ export type PluginFamily = 'site-runtime' | 'agent-plugin';
11
+ export interface SetEnabledRequest {
12
+ readonly family: PluginFamily;
13
+ readonly pluginId: string;
14
+ /** @agent-note Every enable requires a fresh explicit human answer, including unchanged or previously approved revisions. */
15
+ readonly enabled: boolean;
16
+ }
17
+ export interface PluginToolRegistrationInput {
18
+ readonly domain: string;
19
+ readonly catalogModule: string;
20
+ /** @agent-note Catalog names must match toolIds and its authorization permissions must match the supplied permission values. */
21
+ readonly catalog: readonly AgentToolDefinition[];
22
+ readonly metadata: ToolMetadataById;
23
+ }
24
+ export interface InstalledPluginRevision {
25
+ readonly pluginId: string;
26
+ readonly version?: OptionalValue<string>;
27
+ readonly archiveDigest: string;
28
+ /** @agent-note Supply skill names only because these values are serialized in the public list response. */
29
+ readonly skills: readonly {
30
+ readonly name: string;
31
+ }[];
32
+ readonly displayName?: OptionalValue<string>;
33
+ readonly summary?: OptionalValue<string>;
34
+ readonly description?: OptionalValue<string>;
35
+ readonly hostRange?: OptionalValue<string>;
36
+ readonly requires?: OptionalValue<readonly string[]>;
37
+ }
38
+ export type ClassifiedPluginError = {
39
+ kind: 'not-installed';
40
+ message: string;
41
+ } | {
42
+ kind: 'host-incompatible' | 'update';
43
+ code: string;
44
+ } | {
45
+ kind: 'unreadable' | 'busy';
46
+ message: string;
47
+ };
48
+ export interface PluginApprovalPort<Description> {
49
+ /** @agent-note Keep one authenticated actor/tool/exchange through preparation and execution, refusing mutation on missing transport, abort or an unanswered required approval; set-enabled constructs this handler at registration while runtime-plugin uninstall constructs it per call. */
50
+ handler<Prepared>(steps: {
51
+ /** @agent-note Authorize before disclosing target facts and detach the proposal identity from mutable caller input. */
52
+ prepare(required: {
53
+ ctx: ToolExecutionContext;
54
+ }, options: ToolExecutionOptions): Promise<Prepared>;
55
+ describe(required: {
56
+ ctx: ToolExecutionContext;
57
+ prepared: Prepared;
58
+ }): Description | Promise<Description>;
59
+ /** @agent-note Reauthorize and revalidate the frozen proposal after confirmation before performing the mutation. */
60
+ run(required: {
61
+ ctx: ToolExecutionContext;
62
+ prepared: Prepared;
63
+ confirmer: HumanConfirmer;
64
+ choice?: string;
65
+ }, options: ToolExecutionOptions): Promise<unknown>;
66
+ }, options?: {
67
+ /** @agent-note The flag names the false-valued result field returned when approval has no affirmative answer and declined is absent. */
68
+ flag?: string;
69
+ /** @agent-note Returning false skips the human dialog and runs immediately, so permit that path only when the prepared action needs no escalation approval. */
70
+ ask?: (required: {
71
+ prepared: Prepared;
72
+ }) => boolean;
73
+ /** @agent-note Replace the default no-answer result for declined, expired or abandoned approval without running the mutation. */
74
+ declined?: (required: {
75
+ reason: 'declined' | 'expired' | 'abandoned';
76
+ prepared?: Prepared;
77
+ }) => unknown;
78
+ }): ToolHandler;
79
+ notConfirmed(outcome: {
80
+ confirmed: false;
81
+ reason: 'declined' | 'expired' | 'abandoned';
82
+ }): {
83
+ cancelled: boolean;
84
+ reason?: 'expired' | 'abandoned';
85
+ note: string;
86
+ };
87
+ }
88
+ export interface PluginLifecycleToolsPort {
89
+ /** @agent-note Strict approval reads must refuse on missing capability while non-strict list reads may degrade softly. */
90
+ inactivePluginIds?(required: {
91
+ strict: boolean;
92
+ }, optional?: Record<string, never>): Promise<ReadonlySet<string> | undefined>;
93
+ previewEnableAccess?(required: {
94
+ pluginId: string;
95
+ }, optional?: Record<string, never>): Promise<{
96
+ readonly key: string;
97
+ readonly resources?: readonly Omit<AccessApprovalResource, 'scope'>[];
98
+ } | undefined>;
99
+ /** @agent-note Record only a genuine declined answer through the same scoped connection owner. */
100
+ recordDeclinedAccess?(required: {
101
+ accessKey: string;
102
+ }): Promise<void>;
103
+ /** @agent-note A rejected listing empties the entire agentPlugins list response to isolate failure from the independently working runtime-plugin list. */
104
+ listInstalled(required: Record<string, never>, optional?: Record<string, never>): Promise<readonly InstalledPluginRevision[]>;
105
+ /** @agent-note Provider: the host's revision-selection owner (e.g. bundled digests win). Returns the copies
106
+ * of `installed` it would use; it must not invent a newest-version policy. Omit it when the host has none. */
107
+ preferInstalled?(required: {
108
+ installed: readonly InstalledPluginRevision[];
109
+ }, optional?: Record<string, never>): Promise<readonly InstalledPluginRevision[]>;
110
+ assertWritable(required: Record<string, never>, optional?: Record<string, never>): Promise<void>;
111
+ /** @agent-note Share the workspace admission queue and activation repository with every other lifecycle writer. */
112
+ setEnabled(required: {
113
+ workspaceId: string;
114
+ pluginId: string;
115
+ enabled: boolean;
116
+ actor: string;
117
+ }): Promise<{
118
+ pluginId: string;
119
+ enabled: boolean;
120
+ warnings?: readonly string[];
121
+ }>;
122
+ /** @agent-note Provision only after successful enable and forward the approved access key unchanged. */
123
+ provisionMcp(required: {
124
+ pluginId: string;
125
+ principalId: string;
126
+ }, optional: {
127
+ approvedEnable: boolean;
128
+ approvedEnableKey?: OptionalValue<string>;
129
+ }): Promise<void>;
130
+ /** @agent-note Delegate the complete authorize, preview, confirm and remove sequence to the same lifecycle owner and authenticated exchange. */
131
+ uninstall(required: {
132
+ ctx: ToolExecutionContext;
133
+ pluginId: string;
134
+ executionOptions: ToolExecutionOptions;
135
+ }, optional?: Record<string, never>): Promise<unknown>;
136
+ searchCandidate(required: {
137
+ candidate: {
138
+ pluginId: string;
139
+ displayName?: OptionalValue<string>;
140
+ summary?: OptionalValue<string>;
141
+ description?: OptionalValue<string>;
142
+ enabled: boolean;
143
+ keywords: readonly string[];
144
+ skills: readonly never[];
145
+ mcpServerIds: readonly string[];
146
+ };
147
+ }): {
148
+ pluginId: string;
149
+ enabled: boolean;
150
+ description?: OptionalValue<string>;
151
+ };
152
+ /** @agent-note Check every supplied revision with the same host contract and active-provides policy without relisting by id. */
153
+ compatibility(required: {
154
+ pluginId: string;
155
+ revisions: readonly InstalledPluginRevision[];
156
+ }): {
157
+ code: string;
158
+ } | undefined;
159
+ /** @agent-note Classify canonical host error classes and return undefined for unknown failures so their identity survives. */
160
+ classifyError(required: {
161
+ error: unknown;
162
+ }): ClassifiedPluginError | undefined;
163
+ }
164
+ export interface PluginExportRow {
165
+ readonly plugin: string;
166
+ readonly displayName?: OptionalValue<string>;
167
+ readonly component: string;
168
+ readonly version: number;
169
+ readonly minVersion: number;
170
+ readonly props: unknown;
171
+ readonly consent: string;
172
+ readonly availability: string;
173
+ readonly snippet: string | null;
174
+ }
175
+ export interface PluginProviderFaceToolsPort {
176
+ linkedProvider(required: {
177
+ pluginId: string;
178
+ }): Promise<string | undefined>;
179
+ describeLinkedFace(required: {
180
+ pluginId: string;
181
+ providerPluginId: string;
182
+ }): {
183
+ code: string;
184
+ message: string;
185
+ providerPluginId: string;
186
+ };
187
+ describeLinkedError(required: {
188
+ error: unknown;
189
+ }): {
190
+ code: string;
191
+ message: string;
192
+ providerPluginId: string;
193
+ } | undefined;
194
+ }
195
+ export interface PluginManagementMessages {
196
+ readonly familyRequired: string;
197
+ restartNote(required: SetEnabledRequest): string;
198
+ changedSinceConfirmation(required: {
199
+ pluginId: string;
200
+ name: string;
201
+ version: string;
202
+ }): string;
203
+ /** @agent-note Only PLUGIN_UPDATE_PENDING is recoverable by restart, so other update codes must not recommend restart recovery. */
204
+ updatePendingNextStep(required: {
205
+ code: string;
206
+ }): string;
207
+ hostIncompatibleNote(required: {
208
+ pluginId: string;
209
+ }): string;
210
+ activationsUnreadableNote(required: {
211
+ pluginId: string;
212
+ enabled: boolean;
213
+ }): string;
214
+ activationsBusyNote(required: {
215
+ pluginId: string;
216
+ enabled: boolean;
217
+ }): string;
218
+ }
219
+ export interface PluginToolCommand {
220
+ readonly command: {
221
+ workspaceId: string;
222
+ actor: {
223
+ id: string;
224
+ kind: 'agent';
225
+ };
226
+ summary: string;
227
+ permission: string;
228
+ };
229
+ readonly mutation: {
230
+ entityType: string;
231
+ entityId: string;
232
+ operation: 'update';
233
+ captureInverse(): Promise<{
234
+ enabled: boolean;
235
+ }>;
236
+ execute(): Promise<{
237
+ activation: PluginActivationRecord;
238
+ }>;
239
+ /** @agent-note Restore the exact prior activation row or remove a newly created row, then restore its hooks. */
240
+ rollback(): Promise<void>;
241
+ };
242
+ }
243
+ export interface PluginManagementToolsRequired<Description> {
244
+ /** @agent-note List accepts no input fields, set-enabled requires family/pluginId/enabled and uninstall requires family/pluginId, with family exactly site-runtime or agent-plugin. */
245
+ readonly registration: PluginToolRegistrationInput;
246
+ readonly workspaceId: string;
247
+ /** @agent-note Use the same permission evaluator before disclosure and again after human approval. */
248
+ readonly authorize: LegacyToolAuthorizeFn;
249
+ readonly permissions: {
250
+ read: string;
251
+ enable: string;
252
+ };
253
+ readonly toolIds: {
254
+ list: string;
255
+ setEnabled: string;
256
+ uninstall: string;
257
+ };
258
+ readonly entityTypes: {
259
+ plugin: string;
260
+ agentPlugin: string;
261
+ activation: string;
262
+ };
263
+ readonly actorPluginId: string;
264
+ readonly clock: Clock;
265
+ /** @agent-note Share this workspace-scoped repository with other entry points so previews and writes observe the same activation state. */
266
+ readonly pluginActivationRepo: PluginActivationRepoPort;
267
+ readonly discoverPlugins: () => Promise<readonly PluginDiscoveryRecord[]>;
268
+ readonly listPluginConflicts?: OptionalValue<(() => Promise<ReadonlyMap<string, readonly PluginConflict[]>>)>;
269
+ readonly removePlugin: RemovePluginFn;
270
+ /** @agent-note Record source approval before enabling and leave the plugin OFF if recording fails. */
271
+ readonly pluginSource?: OptionalValue<Pick<PluginSourcePort, 'readApproval' | 'recordApproval'>>;
272
+ readonly onPluginEnabled: (pluginId: string) => Promise<void>;
273
+ readonly onPluginDisabled: (pluginId: string) => void;
274
+ readonly agentPlugins: PluginLifecycleToolsPort;
275
+ readonly pluginExports?: OptionalValue<{
276
+ catalog(required: {
277
+ workspaceId: string;
278
+ }): Promise<ReadonlyMap<string, readonly PluginExportRow[]>>;
279
+ }>;
280
+ readonly providerFaces: PluginProviderFaceToolsPort;
281
+ /** @agent-note Invoke the shared Stop and roster owner only after durable OFF and propagate cleanup failure without claiming success. */
282
+ readonly lowerToolAccess: (required: {
283
+ pluginId: string;
284
+ }) => Promise<void>;
285
+ readonly extraModelFacingErrors: readonly ModelFacingErrorRule[];
286
+ /** @agent-note Use the existing command gateway for authorization, audit, outbox and rollback rather than bypassing it with a direct writer. */
287
+ readonly executeCommand: (required: PluginToolCommand) => Promise<{
288
+ result: {
289
+ activation: PluginActivationRecord;
290
+ };
291
+ }>;
292
+ /** @agent-note Use the same fingerprint owner before and after approval and include every supplied revision and schema field. */
293
+ readonly approvalFingerprint: (required: {
294
+ family: PluginFamily;
295
+ pluginId: string;
296
+ revision: string;
297
+ schema: Readonly<Record<string, unknown>>;
298
+ }) => string;
299
+ readonly approvals: PluginApprovalPort<Description>;
300
+ readonly descriptions: {
301
+ enable(required: {
302
+ subject: {
303
+ family: PluginFamily;
304
+ pluginId: string;
305
+ version?: OptionalValue<string>;
306
+ label?: OptionalValue<string>;
307
+ adds?: OptionalValue<readonly string[]>;
308
+ previousEnabled?: OptionalValue<boolean | null>;
309
+ revision?: OptionalValue<string>;
310
+ resources?: OptionalValue<readonly Omit<AccessApprovalResource, 'scope'>[]>;
311
+ };
312
+ scope?: AccessApprovalResource['scope'];
313
+ }): Description;
314
+ uninstall(required: {
315
+ preview: PluginUninstallPreview;
316
+ }): Description;
317
+ };
318
+ /** @agent-note Unreadable and busy activation failures log private paths to console.warn, so host logs must stay outside model-facing output. */
319
+ readonly messages: PluginManagementMessages;
320
+ readonly telemetry?: OptionalValue<{
321
+ toggled(required: {
322
+ principalId: string;
323
+ pluginId: string;
324
+ enabled: boolean;
325
+ }): void;
326
+ }>;
327
+ }
328
+ export interface PluginInstallToolsRequired<Request> {
329
+ readonly registration: PluginToolRegistrationInput;
330
+ readonly workspaceId: string;
331
+ readonly authorize: LegacyToolAuthorizeFn;
332
+ readonly toolId: string;
333
+ readonly permission: string;
334
+ readonly entityType: string;
335
+ readonly parseRequest: (required: {
336
+ input: unknown;
337
+ }) => Request;
338
+ readonly localInstallEnabled: () => boolean;
339
+ readonly installInput: (required: {
340
+ request: Request;
341
+ ownerId: string;
342
+ runId: string;
343
+ }) => Promise<PluginInstallInput>;
344
+ /** @agent-note Preview and install must share one scoped owner and throw this package's canonical PluginInstallError for relayable refusals, while other errors retain opaque failure handling. */
345
+ readonly installer?: OptionalValue<PluginInstallerPort>;
346
+ readonly riskSentence: (required: {
347
+ preview: PluginInstallPreview;
348
+ }) => string;
349
+ readonly messages: {
350
+ readonly localInstallDisabledNote: string;
351
+ installedNote(required: {
352
+ name: string;
353
+ version: string;
354
+ }): string;
355
+ readonly retryInstallHint: string;
356
+ };
357
+ readonly telemetry?: OptionalValue<{
358
+ installed(required: {
359
+ principalId: string;
360
+ pluginId: string;
361
+ }): void;
362
+ installFailed(required: {
363
+ principalId: string;
364
+ reasonClass: 'refused' | 'internal';
365
+ }): void;
366
+ }>;
367
+ }
368
+ export interface PluginSourceToolsRequired<Description> {
369
+ readonly registration: PluginToolRegistrationInput;
370
+ readonly workspaceId: string;
371
+ readonly authorize: LegacyToolAuthorizeFn;
372
+ /** @agent-note Every operation reads id; create also reads name/description, read/write/edit/delete read path, write reads content, and edit reads oldString/newString plus optional replaceAll. */
373
+ readonly toolIds: {
374
+ create: string;
375
+ open: string;
376
+ list: string;
377
+ read: string;
378
+ write: string;
379
+ edit: string;
380
+ delete: string;
381
+ seal: string;
382
+ rollback: string;
383
+ };
384
+ readonly enablePermission: string;
385
+ readonly entityType: string;
386
+ /** @agent-note Source operations must throw this package's canonical PluginSourceError or PluginInstallError for relayable refusals, while other errors retain opaque failure handling. */
387
+ readonly pluginSource?: OptionalValue<PluginSourcePort>;
388
+ readonly approvals: PluginApprovalPort<Description>;
389
+ readonly describeDelete: (required: {
390
+ target: {
391
+ id: string;
392
+ path: string;
393
+ };
394
+ }) => Description;
395
+ }
396
+ export type OptionalValue<T> = T | undefined;
397
+ //# sourceMappingURL=contract.d.ts.map
@@ -0,0 +1,7 @@
1
+ import {} from '../activation.js';
2
+ import {} from '../plugin-claims.js';
3
+ import {} from '../uninstall.js';
4
+ import {} from '../discovery-types.js';
5
+ import {} from '../node/install.js';
6
+ import {} from '../node/source-drafts.js';
7
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1,7 @@
1
+ /** Plugin registrations use injected host vocabulary and effects without loading filesystem peers. */
2
+ export { buildPluginManagementRegistrations, pluginManagementDerivedRiskFor, pluginApprovalIdentity } from './management.js';
3
+ export { buildPluginInstallRegistrations, pluginInstallDerivedRiskFor } from './install.js';
4
+ export { buildPluginSourceRegistrations, pluginSourceDerivedRiskFor } from './source.js';
5
+ export type { PluginManagementToolsRequired, PluginInstallToolsRequired, PluginSourceToolsRequired, PluginToolRegistrationInput, PluginLifecycleToolsPort, PluginApprovalPort, PluginManagementMessages, PluginProviderFaceToolsPort, PluginToolCommand, PluginExportRow, InstalledPluginRevision, ClassifiedPluginError, PluginFamily, SetEnabledRequest } from './contract.js';
6
+ export { PluginInstallError, PluginSourceError } from '../plugin-tool-errors.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ /** Plugin registrations use injected host vocabulary and effects without loading filesystem peers. */
2
+ export { buildPluginManagementRegistrations, pluginManagementDerivedRiskFor, pluginApprovalIdentity } from './management.js';
3
+ export { buildPluginInstallRegistrations, pluginInstallDerivedRiskFor } from './install.js';
4
+ export { buildPluginSourceRegistrations, pluginSourceDerivedRiskFor } from './source.js';
5
+ export { PluginInstallError, PluginSourceError } from '../plugin-tool-errors.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ import { type DerivedRiskByToolId, type ToolRegistration } from '@jini-ai/core';
2
+ import type { PluginInstallToolsRequired } from './contract.js';
3
+ /**
4
+ * Order is load-bearing: authorize -> parse -> opt-in gate -> preview -> install with the previewed
5
+ * digest. Preview runs first so an invalid package is refused before anything is written.
6
+ * @complexity O(package bytes) twice (preview and install each inspect).
7
+ */
8
+ export declare function buildPluginInstallRegistrations<Request>(deps: PluginInstallToolsRequired<Request>, _optional?: Record<string, never>): ToolRegistration[];
9
+ export declare function pluginInstallDerivedRiskFor({ toolId }: {
10
+ toolId: string;
11
+ }, _optional?: {}): DerivedRiskByToolId;
12
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1,71 @@
1
+ import { adaptLegacyAuthorize, requireToolPermission, buildDomainRegistrations, indexCatalogById, ToolInputError } from '@jini-ai/core';
2
+ import { PluginInstallError } from '../plugin-tool-errors.js';
3
+ /** An installer refusal after the preview (lost race, busy lock, changed bytes) is relayable, not a crash. */
4
+ function refusedResult(error, pluginId, retryInstallHint) {
5
+ const retry = error.code === "PLUGIN_CHANGED_SINCE_PREVIEW" ? retryInstallHint : "";
6
+ return { installed: false, pluginId, reason: error.code, note: `Nothing was installed: ${error.message}${retry}` };
7
+ }
8
+ /** Inspects the package before anything is written; an installer refusal is the caller's input problem. */
9
+ async function previewOrRefuse(required) {
10
+ try {
11
+ return await required.installer.preview(required.input);
12
+ }
13
+ catch (error) {
14
+ if (error instanceof PluginInstallError)
15
+ throw new ToolInputError({ message: `${error.code}: ${error.message}` });
16
+ throw error;
17
+ }
18
+ }
19
+ /** What the model relays after a successful install; the plugin always lands OFF. */
20
+ function installedResult(required) {
21
+ const { plugin } = required;
22
+ return {
23
+ installed: true, enabled: false,
24
+ plugin: { id: plugin.id, name: plugin.name, version: plugin.version, tier: plugin.tier, ...(plugin.upgradeFrom ? { upgradeFrom: plugin.upgradeFrom } : {}) },
25
+ warning: required.deps.riskSentence({ preview: plugin }),
26
+ note: required.deps.messages.installedNote(plugin),
27
+ };
28
+ }
29
+ /**
30
+ * Order is load-bearing: authorize -> parse -> opt-in gate -> preview -> install with the previewed
31
+ * digest. Preview runs first so an invalid package is refused before anything is written.
32
+ * @complexity O(package bytes) twice (preview and install each inspect).
33
+ */
34
+ export function buildPluginInstallRegistrations(deps, _optional = {}) {
35
+ return buildDomainRegistrations({ ...deps.registration,
36
+ catalog: indexCatalogById({ catalog: deps.registration.catalog }),
37
+ derivedRisk: pluginInstallDerivedRiskFor({ toolId: deps.toolId }),
38
+ handlers: {
39
+ [deps.toolId]: async (ctx) => {
40
+ await requireToolPermission({ authorize: adaptLegacyAuthorize({ authorize: deps.authorize }), workspaceId: deps.workspaceId, principalId: ctx.principal.id, permission: deps.permission }, { entityType: deps.entityType });
41
+ const request = deps.parseRequest({ input: ctx.input });
42
+ const installer = deps.installer;
43
+ if (!deps.localInstallEnabled() || !installer) {
44
+ return { installed: false, reason: "PLUGIN_LOCAL_INSTALL_DISABLED", note: deps.messages.localInstallDisabledNote };
45
+ }
46
+ const input = await deps.installInput({ request, ownerId: ctx.principal.id, runId: ctx.run.id });
47
+ const preview = await previewOrRefuse({ installer, input });
48
+ try {
49
+ const plugin = await installer.install({ ...input, expectedDigest: preview.digest });
50
+ deps.telemetry?.installed({ principalId: ctx.principal.id, pluginId: plugin.id });
51
+ return installedResult({ plugin, deps });
52
+ }
53
+ catch (error) {
54
+ deps.telemetry?.installFailed({ principalId: ctx.principal.id, reasonClass: error instanceof PluginInstallError ? "refused" : "internal" });
55
+ if (error instanceof PluginInstallError)
56
+ return refusedResult(error, preview.id, deps.messages.retryInstallHint);
57
+ throw error;
58
+ }
59
+ },
60
+ },
61
+ });
62
+ }
63
+ export function pluginInstallDerivedRiskFor({ toolId }, _optional = {}) {
64
+ return new Map([
65
+ // -> pluginInstaller.install (installSitePlugin): copies the package into the site's plugin
66
+ // directory (replacing a version on replace:true). Durable file writes; nothing is executed and
67
+ // no network is used. The uninstall operation is the inverse.
68
+ [toolId, "mutates-durable-state"],
69
+ ]);
70
+ }
71
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Lists runtime plugins and agent plugins separately because their row shapes and activation
3
+ * lifecycles differ; merging discovery would offer runtime activation to packages it cannot own.
4
+ * Both lists use the same read permission and workspace, avoiding cross-workspace disclosure.
5
+ *
6
+ * Failure isolation: a failed agent-plugin index must not take down a working runtime-plugin
7
+ * list, so that entire half degrades to an empty array; failed public-export lookup alone uses
8
+ * an empty export map while retaining the installed rows.
9
+ *
10
+ * Agent-plugin list projections expose public ids, versions, digests, skill names, projected
11
+ * descriptions and export contracts; package roots, skill paths, executable handles and private
12
+ * error details stay with their owner.
13
+ * The two arrays keep each family's distinct response shape visible to callers.
14
+ *
15
+ * Family is explicit because independent namespaces can share an id and guessing can mutate the
16
+ * wrong lifecycle; one enable tool avoids ambiguous near-identical choices, while install and
17
+ * uninstall remain separate because each tool id has one risk band for its different effects.
18
+ */
19
+ import { type DerivedRiskByToolId, type ToolRegistration, type AccessApprovalResource } from '@jini-ai/core';
20
+ import { type PluginDiscoveryRecord } from '../discovery-types.js';
21
+ import type { PluginManagementToolsRequired, OptionalValue, SetEnabledRequest } from './contract.js';
22
+ /**
23
+ * This wiring layer's OWN risk classification, authored from what each handler below actually
24
+ * calls. See `DerivedRiskByToolId` in the kit for why it is independent of the catalog's own
25
+ * `sideEffects` declaration.
26
+ */
27
+ export declare function pluginManagementDerivedRiskFor({ toolIds }: {
28
+ toolIds: PluginManagementToolsRequired<unknown>['toolIds'];
29
+ }, _optional?: {}): DerivedRiskByToolId;
30
+ /** What one plugin's enable approval is bound to; `discovery` is the site-runtime snapshot it was read from. */
31
+ interface PluginApprovalIdentity {
32
+ readonly key: string;
33
+ readonly version?: OptionalValue<string>;
34
+ readonly label: string;
35
+ readonly discovery?: OptionalValue<readonly PluginDiscoveryRecord[]>;
36
+ readonly accessKey?: OptionalValue<string>;
37
+ readonly accessResources?: OptionalValue<readonly Omit<AccessApprovalResource, 'scope'>[]>;
38
+ }
39
+ /** Identity/version binding before and after consent. The existing MCP fingerprint owner
40
+ * hashes the version/digest metadata; no second hashing or approval store is introduced.
41
+ * Disabling removes capability, so it needs no identity grant and never raises a dialog.
42
+ * @complexity One family discovery scan, bounded by the installed package count. */
43
+ export declare function pluginApprovalIdentity<Description>({ deps: routeDeps, request }: {
44
+ deps: Pick<PluginManagementToolsRequired<Description>, 'discoverPlugins' | 'approvalFingerprint'> & {
45
+ readonly agentPlugins: Pick<PluginManagementToolsRequired<Description>['agentPlugins'], 'listInstalled' | 'previewEnableAccess' | 'preferInstalled'>;
46
+ };
47
+ request: Pick<SetEnabledRequest, "family" | "pluginId">;
48
+ }, _optional?: {}): Promise<PluginApprovalIdentity>;
49
+ export declare function buildPluginManagementRegistrations<Description>(routeDeps: PluginManagementToolsRequired<Description>, _optional?: {}): ToolRegistration[];
50
+ export {};
51
+ //# sourceMappingURL=management.d.ts.map