@jini-ai/plugins 0.6.12 → 0.6.15-rc.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 (81) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +7 -0
  3. package/dist/host/capability-sdk.d.ts +1 -0
  4. package/dist/host/capability-sdk.d.ts.map +1 -1
  5. package/dist/host/capability-sdk.js +6 -0
  6. package/dist/host/capability-sdk.js.map +1 -1
  7. package/dist/host/contributions.d.ts +9 -1
  8. package/dist/host/contributions.d.ts.map +1 -1
  9. package/dist/host/contributions.js +17 -3
  10. package/dist/host/contributions.js.map +1 -1
  11. package/dist/host/hook-registry.d.ts +1 -1
  12. package/dist/host/hook-registry.d.ts.map +1 -1
  13. package/dist/host/hook-registry.js +18 -6
  14. package/dist/host/hook-registry.js.map +1 -1
  15. package/dist/host/index.d.ts +5 -0
  16. package/dist/host/index.d.ts.map +1 -1
  17. package/dist/host/index.js +4 -0
  18. package/dist/host/index.js.map +1 -1
  19. package/dist/host/manifest-types.d.ts +57 -1
  20. package/dist/host/manifest-types.d.ts.map +1 -1
  21. package/dist/host/manifest.d.ts +3 -3
  22. package/dist/host/manifest.d.ts.map +1 -1
  23. package/dist/host/manifest.js +10 -4
  24. package/dist/host/manifest.js.map +1 -1
  25. package/dist/host/node/discovery.d.ts +9 -0
  26. package/dist/host/node/discovery.d.ts.map +1 -1
  27. package/dist/host/node/discovery.js +73 -17
  28. package/dist/host/node/discovery.js.map +1 -1
  29. package/dist/host/node/index.d.ts +1 -0
  30. package/dist/host/node/index.d.ts.map +1 -1
  31. package/dist/host/node/index.js +1 -0
  32. package/dist/host/node/index.js.map +1 -1
  33. package/dist/host/node/install.d.ts.map +1 -1
  34. package/dist/host/node/install.js +4 -1
  35. package/dist/host/node/install.js.map +1 -1
  36. package/dist/host/node/loader.d.ts +10 -1
  37. package/dist/host/node/loader.d.ts.map +1 -1
  38. package/dist/host/node/loader.js +74 -29
  39. package/dist/host/node/loader.js.map +1 -1
  40. package/dist/host/node/module-snapshot.d.ts +66 -3
  41. package/dist/host/node/module-snapshot.d.ts.map +1 -1
  42. package/dist/host/node/module-snapshot.js +188 -18
  43. package/dist/host/node/module-snapshot.js.map +1 -1
  44. package/dist/host/node/open-flags.d.ts +3 -0
  45. package/dist/host/node/open-flags.d.ts.map +1 -1
  46. package/dist/host/node/open-flags.js +12 -5
  47. package/dist/host/node/open-flags.js.map +1 -1
  48. package/dist/host/node/package-files.d.ts +28 -0
  49. package/dist/host/node/package-files.d.ts.map +1 -1
  50. package/dist/host/node/package-files.js +50 -17
  51. package/dist/host/node/package-files.js.map +1 -1
  52. package/dist/host/node/provider-artifact.d.ts +22 -0
  53. package/dist/host/node/provider-artifact.d.ts.map +1 -0
  54. package/dist/host/node/provider-artifact.js +34 -0
  55. package/dist/host/node/provider-artifact.js.map +1 -0
  56. package/dist/host/plugin-claims.d.ts.map +1 -1
  57. package/dist/host/plugin-claims.js +2 -1
  58. package/dist/host/plugin-claims.js.map +1 -1
  59. package/dist/host/ports.d.ts +1 -0
  60. package/dist/host/ports.d.ts.map +1 -1
  61. package/dist/host/provider-contributions.d.ts +31 -0
  62. package/dist/host/provider-contributions.d.ts.map +1 -0
  63. package/dist/host/provider-contributions.js +175 -0
  64. package/dist/host/provider-contributions.js.map +1 -0
  65. package/dist/host/provider-host.d.ts +83 -0
  66. package/dist/host/provider-host.d.ts.map +1 -0
  67. package/dist/host/provider-host.js +222 -0
  68. package/dist/host/provider-host.js.map +1 -0
  69. package/dist/host/provider-setting-required.d.ts +19 -0
  70. package/dist/host/provider-setting-required.d.ts.map +1 -0
  71. package/dist/host/provider-setting-required.js +38 -0
  72. package/dist/host/provider-setting-required.js.map +1 -0
  73. package/dist/host/provider-settings-migrations.d.ts +8 -0
  74. package/dist/host/provider-settings-migrations.d.ts.map +1 -0
  75. package/dist/host/provider-settings-migrations.js +14 -0
  76. package/dist/host/provider-settings-migrations.js.map +1 -0
  77. package/dist/host/quarantine.d.ts +5 -0
  78. package/dist/host/quarantine.d.ts.map +1 -1
  79. package/dist/host/quarantine.js +6 -0
  80. package/dist/host/quarantine.js.map +1 -1
  81. package/package.json +7 -7
@@ -0,0 +1,83 @@
1
+ /** Resource lifecycle for the existing contribution snapshots. Domain validation stays injected. */
2
+ import { type ProviderDefinition } from '@jini-ai/core/provider-registry';
3
+ import type { PluginContributionRegistry } from './contributions.js';
4
+ import type { PluginProviderResource } from './provider-contributions.js';
5
+ export interface PluginProviderContract {
6
+ readonly contract: string;
7
+ /** Supplied by the domain owner; plugins never select or replace this validator. */
8
+ readonly validate: (required: {
9
+ provider: unknown;
10
+ }, optional?: Record<string, never>) => string | undefined;
11
+ readonly seed?: readonly ProviderDefinition<unknown>[];
12
+ }
13
+ export interface PluginProviderFailure {
14
+ readonly pluginId: string;
15
+ readonly contract: string;
16
+ readonly id: string;
17
+ readonly phase: 'dispose' | 'dispose_timeout';
18
+ readonly error: unknown;
19
+ }
20
+ export interface PluginProviderLease extends PluginProviderResource {
21
+ /** Retired leases must not admit new application work. In-flight work is host-owned. */
22
+ isCurrent(required: Record<string, never>, optional?: Record<string, never>): boolean;
23
+ dispose(required: Record<string, never>, optional?: Record<string, never>): Promise<void>;
24
+ }
25
+ export interface PluginProviderHost {
26
+ /** Await during boot. Undefined means unavailable or retired while initialization was pending. */
27
+ initialize(required: {
28
+ contract: string;
29
+ id: string;
30
+ input: Readonly<Record<string, unknown>>;
31
+ }, optional?: {
32
+ factoryOptions?: Readonly<Record<string, unknown>>;
33
+ }): Promise<PluginProviderLease | undefined>;
34
+ /** Disable/quarantine callers detach the contribution first; shutdown and failed boot call this. */
35
+ dispose(required: Record<string, never>, optional?: Record<string, never>): Promise<void>;
36
+ }
37
+ export declare class PluginProviderError extends Error {
38
+ constructor(required: {
39
+ message: string;
40
+ }, _optional?: Record<string, never>);
41
+ }
42
+ /** Explicit plugin-authored startup guidance. Raw SDK errors must never be shown to users. */
43
+ export declare class PluginProviderStartupError extends Error {
44
+ readonly reason: string;
45
+ readonly action: string;
46
+ constructor({ reason, action, cause }: {
47
+ reason: string;
48
+ action: string;
49
+ cause?: unknown;
50
+ }, _optional?: {});
51
+ }
52
+ /** Startup guidance from a {@link PluginProviderStartupError}, matched by shape: each provider plugin
53
+ * artifact bundles its own copy of this class, so `instanceof` against the host's copy is always false. */
54
+ export declare function pluginProviderStartupGuidance({ error }: {
55
+ error: unknown;
56
+ }, _optional?: {}): {
57
+ reason: string;
58
+ action: string;
59
+ } | undefined;
60
+ /** Applying saved settings either succeeds, requires a browser/process refresh, or fails to start. */
61
+ export type PluginProviderApplyResult = 'now' | 'restart' | {
62
+ appliesAt: 'failed';
63
+ reason: string;
64
+ action: string;
65
+ };
66
+ /**
67
+ * Track resources against snapshot identity, so replacement retires even the same plugin version.
68
+ * @param required.contributions Existing executable contribution owner; detach retires immediately.
69
+ * @param required.contracts Domain validators and optional built-in providers.
70
+ * @param optional.disposeTimeoutMs Positive finite bound for each resource's teardown (default 2000).
71
+ * @param optional.initializeTimeoutMs Positive finite bound for awaiting a factory (default 10000).
72
+ * @returns A host whose shutdown is idempotent and whose late factory results are disposed.
73
+ * @throws RangeError for invalid timeouts; PluginProviderError for unknown/invalid contracts or ports.
74
+ */
75
+ export declare function createPluginProviderHost(required: {
76
+ contributions: PluginContributionRegistry;
77
+ contracts: readonly PluginProviderContract[];
78
+ }, optional?: {
79
+ disposeTimeoutMs?: number;
80
+ initializeTimeoutMs?: number;
81
+ onError?: (required: PluginProviderFailure, optional?: Record<string, never>) => void | Promise<void>;
82
+ }): PluginProviderHost;
83
+ //# sourceMappingURL=provider-host.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-host.d.ts","sourceRoot":"","sources":["../../src/host/provider-host.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAClG,OAAO,KAAK,EAAE,0BAA0B,EAA+B,MAAM,oBAAo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M,EAAE,MAAM,CAAA;CAAE,CAAC;AAsCpH;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,aAAa,EAAE,0BAA0B,CAAC;IAAC,SAAS,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACzF,EAAE,QAAQ,GAAE;IACX,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClG,GAAG,kBAAkB,CA0I1B"}
@@ -0,0 +1,222 @@
1
+ /** Resource lifecycle for the existing contribution snapshots. Domain validation stays injected. */
2
+ import { createProviderRegistry } from '@jini-ai/core/provider-registry';
3
+ export class PluginProviderError extends Error {
4
+ constructor(required, _optional = {}) {
5
+ super(required.message);
6
+ this.name = 'PluginProviderError';
7
+ }
8
+ }
9
+ /** Explicit plugin-authored startup guidance. Raw SDK errors must never be shown to users. */
10
+ export class PluginProviderStartupError extends Error {
11
+ reason;
12
+ action;
13
+ constructor({ reason, action, cause }, _optional = {}) {
14
+ super(reason, { cause });
15
+ this.name = 'PluginProviderStartupError';
16
+ this.reason = reason;
17
+ this.action = action;
18
+ }
19
+ }
20
+ /** Startup guidance from a {@link PluginProviderStartupError}, matched by shape: each provider plugin
21
+ * artifact bundles its own copy of this class, so `instanceof` against the host's copy is always false. */
22
+ export function pluginProviderStartupGuidance({ error }, _optional = {}) {
23
+ if (!(error instanceof Error) || error.name !== 'PluginProviderStartupError')
24
+ return undefined;
25
+ const { reason, action } = error;
26
+ return typeof reason === 'string' && typeof action === 'string' ? { reason, action } : undefined;
27
+ }
28
+ /** A timeout bounds waiting, not a promise's effects. Late results are still observed and released. */
29
+ function createResourceDisposer(required, _optional = {}) {
30
+ let disposal;
31
+ return () => {
32
+ disposal ??= (async () => {
33
+ let timer;
34
+ const work = Promise.resolve().then(() => required.resource.dispose({}, {})).catch(error => {
35
+ required.report({ phase: 'dispose', error });
36
+ });
37
+ try {
38
+ await Promise.race([work, new Promise(resolve => {
39
+ timer = setTimeout(() => {
40
+ required.report({ phase: 'dispose_timeout', error: new PluginProviderError({ message: 'provider disposal timed out' }) });
41
+ resolve();
42
+ }, required.timeoutMs);
43
+ })]);
44
+ }
45
+ finally {
46
+ if (timer !== undefined)
47
+ clearTimeout(timer);
48
+ }
49
+ })();
50
+ return disposal;
51
+ };
52
+ }
53
+ function timeoutOption(value, fallback, name) {
54
+ const timeoutMs = value ?? fallback;
55
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1)
56
+ throw new RangeError(`invalid provider ${name} timeout`);
57
+ return timeoutMs;
58
+ }
59
+ /**
60
+ * Track resources against snapshot identity, so replacement retires even the same plugin version.
61
+ * @param required.contributions Existing executable contribution owner; detach retires immediately.
62
+ * @param required.contracts Domain validators and optional built-in providers.
63
+ * @param optional.disposeTimeoutMs Positive finite bound for each resource's teardown (default 2000).
64
+ * @param optional.initializeTimeoutMs Positive finite bound for awaiting a factory (default 10000).
65
+ * @returns A host whose shutdown is idempotent and whose late factory results are disposed.
66
+ * @throws RangeError for invalid timeouts; PluginProviderError for unknown/invalid contracts or ports.
67
+ */
68
+ export function createPluginProviderHost(required, optional = {}) {
69
+ const timeoutMs = timeoutOption(optional.disposeTimeoutMs, 2000, 'disposal');
70
+ const initializeTimeoutMs = timeoutOption(optional.initializeTimeoutMs, 10_000, 'initialization');
71
+ const contracts = new Map();
72
+ for (const contract of required.contracts) {
73
+ if (contracts.has(contract.contract))
74
+ throw new PluginProviderError({ message: 'duplicate provider contract' });
75
+ // Validate built-in definitions eagerly, using core's throwing composition policy.
76
+ createProviderRegistry({ contract: contract.contract }, { validate: contract.validate, seed: contract.seed ?? [] });
77
+ contracts.set(contract.contract, contract);
78
+ }
79
+ const acquired = new Set();
80
+ const cleanups = new Set();
81
+ const disposers = new WeakMap();
82
+ // Pending initializations re-check their generation on each change, so retirement settles them.
83
+ const wakers = new Set();
84
+ let closed = false;
85
+ let shutdown;
86
+ const current = (snapshot) => !closed && required.contributions.list({}).includes(snapshot);
87
+ // Every started teardown, direct or host-triggered, is awaited by shutdown.
88
+ const track = (pending) => {
89
+ cleanups.add(pending);
90
+ void pending.then(() => { cleanups.delete(pending); });
91
+ return pending;
92
+ };
93
+ const cleanup = (item) => item.lease.dispose({});
94
+ const unsubscribe = required.contributions.subscribe({ onChanged: () => {
95
+ // Contribution listeners can reject publication and roll it back synchronously. Release
96
+ // only the committed generation; lease.isCurrent already blocks work during replacement.
97
+ queueMicrotask(() => {
98
+ for (const item of acquired)
99
+ if (!current(item.snapshot))
100
+ void cleanup(item);
101
+ for (const wake of wakers)
102
+ wake();
103
+ });
104
+ } });
105
+ const report = (failure) => {
106
+ // Diagnostics must never prevent another provider from releasing its resources.
107
+ try {
108
+ void Promise.resolve(optional.onError?.(failure, {})).catch(() => { });
109
+ }
110
+ catch { /* Failure reporting is a borrowed host effect. */ }
111
+ };
112
+ function releaserFor(input) {
113
+ let release = disposers.get(input.resource);
114
+ if (!release) {
115
+ release = createResourceDisposer({ resource: input.resource, timeoutMs, report: failure => report({
116
+ ...failure, pluginId: input.snapshot.pluginId, contract: input.provider.contract, id: input.provider.id,
117
+ }) });
118
+ disposers.set(input.resource, release);
119
+ }
120
+ return release;
121
+ }
122
+ function leaseResource(input) {
123
+ let retired = false;
124
+ const item = { snapshot: input.snapshot, lease: {
125
+ port: input.port,
126
+ isCurrent: () => !retired && current(input.snapshot),
127
+ dispose: () => { retired = true; acquired.delete(item); return track(input.release()); },
128
+ } };
129
+ return item;
130
+ }
131
+ function validatePort(input) {
132
+ const registry = createProviderRegistry({ contract: input.contract.contract }, {
133
+ validate: input.contract.validate, seed: input.contract.seed ?? [],
134
+ });
135
+ if (!registry.contribute({ definition: { id: input.provider.id, provider: input.port }, pluginId: input.snapshot.pluginId, contract: input.provider.contract })) {
136
+ throw new PluginProviderError({ message: registry.refusals()[0].message });
137
+ }
138
+ }
139
+ function findProvider(input) {
140
+ for (const snapshot of required.contributions.list({})) {
141
+ const provider = snapshot.providers?.find(value => value.contract === input.contract && value.id === input.id);
142
+ if (provider)
143
+ return { snapshot, provider };
144
+ }
145
+ return undefined;
146
+ }
147
+ /** Admit one factory result; anything not handed out as a lease is released before settling. */
148
+ async function admit(input) {
149
+ const { resource, snapshot } = input;
150
+ if (!resource || typeof resource.dispose !== 'function')
151
+ throw new PluginProviderError({ message: 'provider factory must return { port, dispose }' });
152
+ // Cleanup exists before the first port read; the single read is the value validated and leased.
153
+ const release = releaserFor(input);
154
+ let item;
155
+ try {
156
+ const port = resource.port;
157
+ validatePort({ ...input, port });
158
+ item = leaseResource({ port, release, snapshot });
159
+ }
160
+ catch (error) {
161
+ await track(release());
162
+ throw error;
163
+ }
164
+ if (input.abandoned() || !current(snapshot)) {
165
+ await cleanup(item);
166
+ return undefined;
167
+ }
168
+ acquired.add(item);
169
+ return item.lease;
170
+ }
171
+ /** Settle on the factory, retirement (undefined) or the deadline; admit() still releases late results. */
172
+ function untilRetiredOrDeadline(input) {
173
+ let timer;
174
+ let wake;
175
+ const stopped = new Promise((resolve, reject) => {
176
+ wake = () => { if (!current(input.snapshot)) {
177
+ input.abandon();
178
+ resolve(undefined);
179
+ } };
180
+ timer = setTimeout(() => {
181
+ input.abandon();
182
+ reject(new PluginProviderError({ message: 'provider initialization timed out' }));
183
+ }, initializeTimeoutMs);
184
+ });
185
+ wakers.add(wake);
186
+ // The factory may already have retired the generation (e.g. a borrowed callback shut the host down).
187
+ wake();
188
+ return Promise.race([input.produced, stopped]).finally(() => { wakers.delete(wake); clearTimeout(timer); });
189
+ }
190
+ async function initialize(input, options = {}) {
191
+ if (closed)
192
+ throw new PluginProviderError({ message: 'provider host is closed' });
193
+ const contract = contracts.get(input.contract);
194
+ if (!contract)
195
+ throw new PluginProviderError({ message: `unknown provider contract '${input.contract}'` });
196
+ const selected = findProvider(input);
197
+ if (!selected)
198
+ return undefined;
199
+ const { snapshot, provider } = selected;
200
+ let abandoned = false;
201
+ const produced = Promise.resolve(provider.factory(input.input, options.factoryOptions ?? {}))
202
+ .then(resource => admit({ resource, contract, snapshot, provider, abandoned: () => abandoned }));
203
+ return untilRetiredOrDeadline({ produced, snapshot, abandon: () => { abandoned = true; } });
204
+ }
205
+ return {
206
+ initialize,
207
+ dispose() {
208
+ shutdown ??= (async () => {
209
+ closed = true;
210
+ unsubscribe();
211
+ // Begin every teardown before awaiting any: a hung or rejected sink cannot block peers.
212
+ for (const item of acquired)
213
+ void cleanup(item);
214
+ for (const wake of wakers)
215
+ wake();
216
+ await Promise.all([...cleanups]);
217
+ })();
218
+ return shutdown;
219
+ },
220
+ };
221
+ }
222
+ //# sourceMappingURL=provider-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-host.js","sourceRoot":"","sources":["../../src/host/provider-host.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAAE,sBAAsB,EAA2B,MAAM,iCAAiC,CAAC;AA8BlG,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,QAA6B,EAAE,YAAmC,EAAE;QAC9E,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAAC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IAC7D,CAAC;CACF;AACD,8FAA8F;AAC9F,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,MAAM,CAAS;IACf,MAAM,CAAS;IACxB,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAuD,EAAE,SAAS,GAAG,EAAE;QACxG,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAA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ifest-types.js';
2
+ /**
3
+ * Whether a declared field is required for the effective public values (including defaults).
4
+ * `requiredWhen` gates the requirement by exact choices; `requiredUnless` waives it on an exact match or a nonblank declared alternative.
5
+ * Pure; no values are returned or logged.
6
+ * @example isProviderSettingRequired({ field, values: { auth: 'none' } })
7
+ * @complexity O(k + b) time in conditional choices and alternative text; O(b) transient trim space.
8
+ */
9
+ export declare function isProviderSettingRequired({ field, values }: {
10
+ field: Pick<PluginProviderSettingField, 'required' | 'requiredUnless' | 'requiredWhen'>;
11
+ values: Readonly<Record<string, unknown>>;
12
+ }, _optional?: Record<string, never>): boolean;
13
+ /** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
14
+ * @complexity O(h * n) in header text and the manifest's small name allowlist. */
15
+ export declare function hasProviderAuthHeader({ text, names }: {
16
+ text: string;
17
+ names: readonly string[];
18
+ }, _optional?: {}): boolean;
19
+ //# sourceMappingURL=provider-setting-required.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-setting-required.d.ts","sourceRoot":"","sources":["../../src/host/provider-setting-required.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAetE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAC3D,KAAK,EAAE,IAAI,CAAC,0BAA0B,EAAE,UAAU,GAAG,gBAAgB,GAAG,cAAc,CAAC,CAAC;IACxF,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3C,EAAE,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,OAAO,CAMjD;AAGD;kFACkF;AAClF,wBAAgB,qBAAqB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,SAAS,KAAK,GAAG,OAAO,CAI1H"}
@@ -0,0 +1,38 @@
1
+ /** Evaluate the declared alternative without returning any setting or credential value. O(b) alternative text. */
2
+ function requirementWaived({ condition, values }, _optional = {}) {
3
+ if (!condition)
4
+ return false;
5
+ if (values[condition.field] === condition.equals)
6
+ return true;
7
+ if (!condition.orPresent)
8
+ return false;
9
+ const alternative = values[condition.orPresent];
10
+ if (typeof alternative !== 'string' || alternative.trim() === '')
11
+ return false;
12
+ if (!condition.headerNames)
13
+ return true;
14
+ return hasProviderAuthHeader({ text: alternative, names: condition.headerNames });
15
+ }
16
+ /**
17
+ * Whether a declared field is required for the effective public values (including defaults).
18
+ * `requiredWhen` gates the requirement by exact choices; `requiredUnless` waives it on an exact match or a nonblank declared alternative.
19
+ * Pure; no values are returned or logged.
20
+ * @example isProviderSettingRequired({ field, values: { auth: 'none' } })
21
+ * @complexity O(k + b) time in conditional choices and alternative text; O(b) transient trim space.
22
+ */
23
+ export function isProviderSettingRequired({ field, values }, _optional = {}) {
24
+ const when = field.requiredWhen;
25
+ const required = when
26
+ ? when.in.some((choice) => choice === values[when.field])
27
+ : field.required === true;
28
+ return required && !requirementWaived({ condition: field.requiredUnless, values });
29
+ }
30
+ /** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
31
+ * @complexity O(h * n) in header text and the manifest's small name allowlist. */
32
+ export function hasProviderAuthHeader({ text, names }, _optional = {}) {
33
+ const pairs = text.split(',').map(pair => /^([^=\s][^=]*?)\s*=\s*(.+)$/.exec(pair.trim()));
34
+ if (pairs.some(pair => !pair))
35
+ return false;
36
+ return pairs.some(pair => names.some(name => name.toLowerCase() === pair[1].toLowerCase()) && pair[2].trim() !== '');
37
+ }
38
+ //# sourceMappingURL=provider-setting-required.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-setting-required.js","sourceRoot":"","sources":["../../src/host/provider-setting-required.ts"],"names":[],"mappings":"AAEA,kHAAkH;AAClH,SAAS,iBAAiB,CAAC,E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AAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3F,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,IAAK,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC,IAAI,IAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3H,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { PluginProviderDeclaration } from './manifest-types.js';
2
+ /** Apply the plugin's declared public-setting migrations to a copy; inputs and secrets stay intact.
3
+ * @complexity O(f + m * c) for fields, ordered migrations and their declared choices. */
4
+ export declare function migrateProviderSettings({ providers, settings }: {
5
+ providers: readonly PluginProviderDeclaration[];
6
+ settings: Readonly<Record<string, string>>;
7
+ }, _optional?: {}): Readonly<Record<string, string>>;
8
+ //# sourceMappingURL=provider-settings-migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-settings-migrations.d.ts","sourceRoot":"","sources":["../../src/host/provider-settings-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAErE;yFACyF;AACzF,wBAAgB,uBAAuB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;IAC/D,SAAS,EAAE,SAAS,yBAAyB,EAAE,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC7F,EAAE,SAAS,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAQnD"}
@@ -0,0 +1,14 @@
1
+ /** Apply the plugin's declared public-setting migrations to a copy; inputs and secrets stay intact.
2
+ * @complexity O(f + m * c) for fields, ordered migrations and their declared choices. */
3
+ export function migrateProviderSettings({ providers, settings }, _optional = {}) {
4
+ const next = { ...settings };
5
+ for (const provider of providers)
6
+ for (const rule of provider.settingsMigrations ?? []) {
7
+ const value = next[rule.when.field];
8
+ const matches = value === undefined ? rule.when.orAbsent === true : rule.when.in.includes(value);
9
+ if (matches && (!rule.whenPresent || next[rule.whenPresent]?.trim()))
10
+ Object.assign(next, rule.set);
11
+ }
12
+ return next;
13
+ }
14
+ //# sourceMappingURL=provider-settings-migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-settings-migrations.js","sourceRoot":"","sources":["../../src/host/provider-settings-migrations.ts"],"names":[],"mappings":"AAEA;yFACyF;AACzF,MAAM,UAAU,uBAAuB,CAAC,EAAE,SAAS,EAAE,QAAQ,EAE5D,EAAE,SAAS,GAAG,EAAE;IACf,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,kBAAkB,IAAI,EAAE,EAAE,CAAC;YACvF,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,OAAO,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACjG,IAAI,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC;gBAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACtG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -4,6 +4,11 @@ import type { PluginQuarantineEvent } from "./hook-registry.js";
4
4
  export interface QuarantinePluginRequired {
5
5
  readonly deps: {
6
6
  readonly clock: ClockPort;
7
+ /** Called only when the first durable quarantine transition commits. */
8
+ readonly onQuarantined?: (required: {
9
+ pluginId: string;
10
+ workspaceId: string;
11
+ }, optional: Record<string, never>) => void;
7
12
  readonly repo: PluginActivationRepoPort;
8
13
  };
9
14
  readonly input: PluginQuarantineEvent;
@@ -1 +1 @@
1
- {"version":3,"file":"quarantine.d.ts","sourceRoot":"","sources":["../../src/host/quarantine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;QAC1B,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;KACzC,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,wBAAwB,EAClC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GACpC,OAAO,CAAC;IAAE,UAAU,EAAE,sBAAsB,CAAA;CAAE,CAAC,CAqBjD"}
1
+ {"version":3,"file":"quarantine.d.ts","sourceRoot":"","sources":["../../src/host/quarantine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;QAC1B,wEAAwE;QACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;QACxH,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;KACzC,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,wBAAwB,EAClC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GACpC,OAAO,CAAC;IAAE,UAAU,EAAE,sBAAsB,CAAA;CAAE,CAAC,CAyBjD"}
@@ -23,6 +23,12 @@ export async function quarantinePlugin(required, _optional = {}) {
23
23
  quarantineFailureCount: input.consecutiveFailures,
24
24
  };
25
25
  await deps.repo.save(activation);
26
+ if (!existing.quarantinedAt) {
27
+ try {
28
+ deps.onQuarantined?.({ pluginId: input.pluginId, workspaceId: input.workspaceId }, {});
29
+ }
30
+ catch { /* An optional observer cannot undo the committed quarantine. */ }
31
+ }
26
32
  return { activation };
27
33
  }
28
34
  //# sourceMappingURL=quarantine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"quarantine.js","sourceRoot":"","sources":["../../src/host/quarantine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAcjE;;;;G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KAAK,CAAC,QAAQ;KACzB,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,6BAA6B,KAAK,CAAC,QAAQ,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACzD,MAAM,UAAU,GAA2B;QACzC,GAAG,QAAQ;QACX,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,aAAa;QACxB,aAAa;QACb,gBAAgB,EAAE,KAAK,CAAC,MAAM;QAC9B,sBAAsB,EAAE,KAAK,CAAC,mBAAmB;KAClD,CAAC;IACF,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC5B,IAAI,CAAC;YAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QAAC,CAAC;QAC/F,MAAM,CAAC,CAAC,gEAAgE,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/plugins",
3
- "version": "0.6.12",
3
+ "version": "0.6.15-rc.1",
4
4
  "description": "Host-independent extension glue and site-plugin runtime with injected SDK, trust, archive and storage ports.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -72,13 +72,13 @@
72
72
  "registry": "https://registry.npmjs.org"
73
73
  },
74
74
  "dependencies": {
75
- "@jini-ai/core": "^0.6.12"
75
+ "@jini-ai/core": "^0.6.15-rc.1"
76
76
  },
77
77
  "peerDependencies": {
78
- "@jini-ai/platform": "^0.6.10",
78
+ "@jini-ai/platform": "^0.6.15-rc.1",
79
79
  "semver": "^7.6.2",
80
80
  "kysely": "^0.29.6",
81
- "@jini-ai/db": "^0.6.10"
81
+ "@jini-ai/db": "^0.6.15-rc.1"
82
82
  },
83
83
  "peerDependenciesMeta": {
84
84
  "@jini-ai/platform": {
@@ -98,9 +98,9 @@
98
98
  "semver": "^7.6.2",
99
99
  "@types/semver": "^7.5.8",
100
100
  "kysely": "^0.29.6",
101
- "@jini-ai/core": "^0.6.12",
102
- "@jini-ai/platform": "^0.6.12",
103
- "@jini-ai/db": "0.6.12"
101
+ "@jini-ai/platform": "^0.6.15-rc.1",
102
+ "@jini-ai/core": "^0.6.15-rc.1",
103
+ "@jini-ai/db": "0.6.15-rc.1"
104
104
  },
105
105
  "scripts": {
106
106
  "build": "tsc -p tsconfig.json",