@jini-ai/plugins 0.7.2 → 0.7.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -6
- package/README.md +1 -1
- package/dist/core/manifest-keys.d.ts +8 -0
- package/dist/core/manifest-keys.js +16 -0
- package/dist/glue/attachment-points/content-lifecycle.d.ts +6 -7
- package/dist/glue/attachment-points/content-lifecycle.js +1 -1
- package/dist/glue/capability-gate.d.ts +2 -2
- package/dist/glue/manifest.js +2 -12
- package/dist/host/activation.d.ts +4 -5
- package/dist/host/admin-response.d.ts +2 -3
- package/dist/host/attach-loaded-plugin.d.ts +4 -4
- package/dist/host/attach-loaded-plugin.js +2 -2
- package/dist/host/browser-providers.d.ts +1 -1
- package/dist/host/capability-sdk.d.ts +8 -7
- package/dist/host/capability-sdk.js +39 -31
- package/dist/host/capability-tools.d.ts +3 -3
- package/dist/host/capability-tools.js +249 -237
- package/dist/host/contributions.d.ts +7 -66
- package/dist/host/contributions.js +64 -51
- package/dist/host/declarative-content-types.d.ts +6 -6
- package/dist/host/declarative-content-types.js +141 -135
- package/dist/host/declarative-enable.js +1 -1
- package/dist/host/discovery-types.d.ts +3 -3
- package/dist/host/hook-registry.d.ts +9 -9
- package/dist/host/hook-registry.js +86 -76
- package/dist/host/index.d.ts +1 -2
- package/dist/host/index.js +1 -1
- package/dist/host/manifest-types.d.ts +6 -59
- package/dist/host/manifest.d.ts +6 -5
- package/dist/host/manifest.js +3 -39
- package/dist/host/node/discovery.d.ts +1 -1
- package/dist/host/node/discovery.js +4 -5
- package/dist/host/node/index.d.ts +3 -0
- package/dist/host/node/index.js +2 -0
- package/dist/host/node/install.js +2 -2
- package/dist/host/node/integrity-command.d.ts +8 -0
- package/dist/host/node/integrity-command.js +26 -0
- package/dist/host/node/invocation-binding.d.ts +1 -1
- package/dist/host/node/invocation-binding.js +1 -1
- package/dist/host/node/loader.d.ts +3 -2
- package/dist/host/node/loader.js +12 -12
- package/dist/host/node/module-snapshot.d.ts +20 -0
- package/dist/host/node/module-snapshot.js +31 -0
- package/dist/host/node/open-flags.d.ts +4 -1
- package/dist/host/node/open-flags.js +1 -1
- package/dist/host/node/package-files.js +1 -1
- package/dist/host/node/provider-artifact.d.ts +1 -2
- package/dist/host/node/runtime-contracts.d.ts +237 -0
- package/dist/host/node/runtime-contracts.js +2 -0
- package/dist/host/node/runtime-core.d.ts +1 -243
- package/dist/host/node/runtime-core.js +18 -114
- package/dist/host/node/runtime-load-target.d.ts +44 -0
- package/dist/host/node/runtime-load-target.js +45 -0
- package/dist/host/node/runtime-package-location.d.ts +45 -0
- package/dist/host/node/runtime-package-location.js +57 -0
- package/dist/host/node/source-drafts.d.ts +4 -2
- package/dist/host/node/source-drafts.js +107 -39
- package/dist/host/ports.d.ts +1 -38
- package/dist/host/provider-contributions.d.ts +2 -14
- package/dist/host/provider-contributions.js +1 -1
- package/dist/host/provider-host.d.ts +4 -19
- package/dist/host/provider-host.js +83 -71
- package/dist/host/provider-revision-watch.d.ts +36 -0
- package/dist/host/provider-revision-watch.js +52 -0
- package/dist/host/provider-setting-required.d.ts +1 -7
- package/dist/host/provider-setting-required.js +1 -18
- package/dist/host/provider-settings-migrations.d.ts +1 -1
- package/dist/host/repo.memory.d.ts +1 -1
- package/dist/host/repo.memory.js +1 -1
- package/dist/host/sql/repo.d.ts +4 -3
- package/dist/host/sql/repo.rows.js +2 -2
- package/dist/host/tool-contributions.d.ts +2 -1
- package/dist/host/tool-contributions.js +1 -0
- package/dist/host/tools/install.js +1 -0
- package/dist/host/tools/management.js +97 -83
- package/dist/host/uninstall.d.ts +1 -1
- package/dist/host/worker/import-seam.d.ts +2 -2
- package/dist/host/worker/protocol.d.ts +2 -2
- package/dist/host/worker/run-call.d.ts +2 -1
- package/dist/host/worker/run-call.js +2 -2
- package/dist/host/worker/start.js +1 -1
- package/package.json +7 -17
|
@@ -6,25 +6,6 @@ export class PluginProviderError extends Error {
|
|
|
6
6
|
this.name = 'PluginProviderError';
|
|
7
7
|
}
|
|
8
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
9
|
/** A timeout bounds waiting, not a promise's effects. Late results are still observed and released. */
|
|
29
10
|
function createResourceDisposer(required, _optional = {}) {
|
|
30
11
|
let disposal;
|
|
@@ -63,34 +44,25 @@ function timeoutOption(value, fallback, name) {
|
|
|
63
44
|
throw new RangeError(`invalid provider ${name} timeout`);
|
|
64
45
|
return timeoutMs;
|
|
65
46
|
}
|
|
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 function createPluginProviderHost(required, optional = {}) {
|
|
76
|
-
const timeoutMs = timeoutOption(optional.disposeTimeoutMs, 2000, 'disposal');
|
|
77
|
-
const initializeTimeoutMs = timeoutOption(optional.initializeTimeoutMs, 10_000, 'initialization');
|
|
47
|
+
function createProviderContracts(definitions) {
|
|
78
48
|
const contracts = new Map();
|
|
79
|
-
for (const contract of
|
|
49
|
+
for (const contract of definitions) {
|
|
80
50
|
if (contracts.has(contract.contract))
|
|
81
51
|
throw new PluginProviderError({ message: 'duplicate provider contract' });
|
|
82
52
|
// Validate built-in definitions eagerly, using core's throwing composition policy.
|
|
83
53
|
createProviderRegistry({ contract: contract.contract }, { validate: contract.validate, seed: contract.seed ?? [] });
|
|
84
54
|
contracts.set(contract.contract, contract);
|
|
85
55
|
}
|
|
56
|
+
return contracts;
|
|
57
|
+
}
|
|
58
|
+
function createProviderHostState(required, optional) {
|
|
86
59
|
const acquired = new Set();
|
|
87
60
|
const cleanups = new Set();
|
|
88
61
|
const disposers = new WeakMap();
|
|
89
62
|
// Pending initializations re-check their generation on each change, so retirement settles them.
|
|
90
63
|
const wakers = new Set();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const current = (snapshot) => !closed && required.contributions.list({}).includes(snapshot);
|
|
64
|
+
const lifecycle = { closed: false, shutdown: undefined };
|
|
65
|
+
const current = (snapshot) => !lifecycle.closed && required.contributions.list({}).includes(snapshot);
|
|
94
66
|
// Every started teardown, direct or host-triggered, is awaited by shutdown.
|
|
95
67
|
const track = (pending) => {
|
|
96
68
|
cleanups.add(pending);
|
|
@@ -116,7 +88,11 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
116
88
|
}
|
|
117
89
|
catch { /* Failure reporting is a borrowed host effect. */ }
|
|
118
90
|
};
|
|
119
|
-
|
|
91
|
+
return { acquired, cleanups, disposers, wakers, lifecycle, current, track, cleanup, unsubscribe, report };
|
|
92
|
+
}
|
|
93
|
+
function createProviderReleaser(state, timeoutMs) {
|
|
94
|
+
const { disposers, report } = state;
|
|
95
|
+
return function releaserFor(input) {
|
|
120
96
|
let release = disposers.get(input.resource);
|
|
121
97
|
if (!release) {
|
|
122
98
|
release = createResourceDisposer({ resource: input.resource, timeoutMs, report: failure => report({
|
|
@@ -125,8 +101,11 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
125
101
|
disposers.set(input.resource, release);
|
|
126
102
|
}
|
|
127
103
|
return release;
|
|
128
|
-
}
|
|
129
|
-
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createProviderLease(state) {
|
|
107
|
+
const { current, acquired, track } = state;
|
|
108
|
+
return function leaseResource(input) {
|
|
130
109
|
let retired = false;
|
|
131
110
|
const item = { snapshot: input.snapshot, lease: {
|
|
132
111
|
port: input.port,
|
|
@@ -134,25 +113,30 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
134
113
|
dispose: () => { retired = true; acquired.delete(item); return track(input.release()); },
|
|
135
114
|
} };
|
|
136
115
|
return item;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function validatePort(input) {
|
|
119
|
+
const registry = createProviderRegistry({ contract: input.contract.contract }, {
|
|
120
|
+
validate: input.contract.validate, seed: input.contract.seed ?? [],
|
|
121
|
+
});
|
|
122
|
+
if (!registry.contribute({ definition: { id: input.provider.id, provider: input.port }, pluginId: input.snapshot.pluginId, contract: input.provider.contract })) {
|
|
123
|
+
throw new PluginProviderError({ message: registry.refusals()[0].message });
|
|
137
124
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
if (!registry.contribute({ definition: { id: input.provider.id, provider: input.port }, pluginId: input.snapshot.pluginId, contract: input.provider.contract })) {
|
|
143
|
-
throw new PluginProviderError({ message: registry.refusals()[0].message });
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function findProvider(input) {
|
|
125
|
+
}
|
|
126
|
+
function createProviderFinder(required) {
|
|
127
|
+
return function findProvider(input) {
|
|
147
128
|
for (const snapshot of required.contributions.list({})) {
|
|
148
129
|
const provider = snapshot.providers?.find(value => value.contract === input.contract && value.id === input.id);
|
|
149
130
|
if (provider)
|
|
150
131
|
return { snapshot, provider };
|
|
151
132
|
}
|
|
152
133
|
return undefined;
|
|
153
|
-
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function createProviderAdmission(state, releaserFor, leaseResource) {
|
|
137
|
+
const { current, cleanup, acquired, track } = state;
|
|
154
138
|
/** Admit one factory result; anything not handed out as a lease is released before settling. */
|
|
155
|
-
async function admit(input) {
|
|
139
|
+
return async function admit(input) {
|
|
156
140
|
const { resource, snapshot } = input;
|
|
157
141
|
if (!resource || typeof resource.dispose !== 'function')
|
|
158
142
|
throw new PluginProviderError({ message: 'provider factory must return { port, dispose }' });
|
|
@@ -174,9 +158,12 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
174
158
|
}
|
|
175
159
|
acquired.add(item);
|
|
176
160
|
return item.lease;
|
|
177
|
-
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function createProviderDeadline(state, initializeTimeoutMs) {
|
|
164
|
+
const { current, wakers } = state;
|
|
178
165
|
/** Settle on the factory, retirement (undefined) or the deadline; admit() still releases late results. */
|
|
179
|
-
function untilRetiredOrDeadline(input) {
|
|
166
|
+
return function untilRetiredOrDeadline(input) {
|
|
180
167
|
let timer;
|
|
181
168
|
let wake;
|
|
182
169
|
const stopped = new Promise((resolve, reject) => {
|
|
@@ -193,9 +180,12 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
193
180
|
// The factory may already have retired the generation (e.g. a borrowed callback shut the host down).
|
|
194
181
|
wake();
|
|
195
182
|
return Promise.race([input.produced, stopped]).finally(() => { wakers.delete(wake); clearTimeout(timer); });
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function createProviderInitializer(state, contracts, operations) {
|
|
186
|
+
const { findProvider, admit, untilRetiredOrDeadline } = operations;
|
|
187
|
+
return async function initialize(input, options = {}) {
|
|
188
|
+
if (state.lifecycle.closed)
|
|
199
189
|
throw new PluginProviderError({ message: 'provider host is closed' });
|
|
200
190
|
const contract = contracts.get(input.contract);
|
|
201
191
|
if (!contract)
|
|
@@ -205,25 +195,47 @@ export function createPluginProviderHost(required, optional = {}) {
|
|
|
205
195
|
return undefined;
|
|
206
196
|
const { snapshot, provider } = selected;
|
|
207
197
|
let abandoned = false;
|
|
208
|
-
const produced = Promise.resolve(provider.factory(input.input, options.factoryOptions ?? {}))
|
|
198
|
+
const produced = Promise.resolve(provider.factory(input.input, { ...(contract.context ? { context: contract.context } : {}), ...(options.factoryOptions ?? {}) }))
|
|
209
199
|
.then(resource => admit({ resource, contract, snapshot, provider, abandoned: () => abandoned }));
|
|
210
200
|
return untilRetiredOrDeadline({ produced, snapshot, abandon: () => { abandoned = true; } });
|
|
211
|
-
}
|
|
212
|
-
return {
|
|
213
|
-
initialize,
|
|
214
|
-
dispose() {
|
|
215
|
-
shutdown ??= (async () => {
|
|
216
|
-
closed = true;
|
|
217
|
-
unsubscribe();
|
|
218
|
-
// Begin every teardown before awaiting any: a hung or rejected sink cannot block peers.
|
|
219
|
-
for (const item of acquired)
|
|
220
|
-
void cleanup(item);
|
|
221
|
-
for (const wake of wakers)
|
|
222
|
-
wake();
|
|
223
|
-
await Promise.all([...cleanups]);
|
|
224
|
-
})();
|
|
225
|
-
return shutdown;
|
|
226
|
-
},
|
|
227
201
|
};
|
|
228
202
|
}
|
|
203
|
+
function createProviderShutdown(state) {
|
|
204
|
+
const { lifecycle, unsubscribe, acquired, cleanup, wakers, cleanups } = state;
|
|
205
|
+
return function dispose() {
|
|
206
|
+
lifecycle.shutdown ??= (async () => {
|
|
207
|
+
lifecycle.closed = true;
|
|
208
|
+
unsubscribe();
|
|
209
|
+
// Begin every teardown before awaiting any: a hung or rejected sink cannot block peers.
|
|
210
|
+
for (const item of acquired)
|
|
211
|
+
void cleanup(item);
|
|
212
|
+
for (const wake of wakers)
|
|
213
|
+
wake();
|
|
214
|
+
await Promise.all([...cleanups]);
|
|
215
|
+
})();
|
|
216
|
+
return lifecycle.shutdown;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Track resources against snapshot identity, so replacement retires even the same plugin version.
|
|
221
|
+
* @param required.contributions Existing executable contribution owner; detach retires immediately.
|
|
222
|
+
* @param required.contracts Domain validators and optional built-in providers.
|
|
223
|
+
* @param optional.disposeTimeoutMs Positive finite bound for each resource's teardown (default 2000).
|
|
224
|
+
* @param optional.initializeTimeoutMs Positive finite bound for awaiting a factory (default 10000).
|
|
225
|
+
* @returns A host whose shutdown is idempotent and whose late factory results are disposed.
|
|
226
|
+
* @throws RangeError for invalid timeouts; PluginProviderError for unknown/invalid contracts or ports.
|
|
227
|
+
*/
|
|
228
|
+
export function createPluginProviderHost(required, optional = {}) {
|
|
229
|
+
const timeoutMs = timeoutOption(optional.disposeTimeoutMs, 2000, 'disposal');
|
|
230
|
+
const initializeTimeoutMs = timeoutOption(optional.initializeTimeoutMs, 10_000, 'initialization');
|
|
231
|
+
const contracts = createProviderContracts(required.contracts);
|
|
232
|
+
const state = createProviderHostState(required, optional);
|
|
233
|
+
const releaserFor = createProviderReleaser(state, timeoutMs);
|
|
234
|
+
const leaseResource = createProviderLease(state);
|
|
235
|
+
const findProvider = createProviderFinder(required);
|
|
236
|
+
const admit = createProviderAdmission(state, releaserFor, leaseResource);
|
|
237
|
+
const untilRetiredOrDeadline = createProviderDeadline(state, initializeTimeoutMs);
|
|
238
|
+
const initialize = createProviderInitializer(state, contracts, { findProvider, admit, untilRetiredOrDeadline });
|
|
239
|
+
return { initialize, dispose: createProviderShutdown(state) };
|
|
240
|
+
}
|
|
229
241
|
//# sourceMappingURL=provider-host.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PluginProviderApplyResult } from './provider-host.js';
|
|
2
|
+
/** A provider-config row from a store that records when the key was attached. */
|
|
3
|
+
export interface ProviderRevisionRow {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly revision: number;
|
|
6
|
+
readonly attached_at: string;
|
|
7
|
+
}
|
|
8
|
+
/** A provider-config row from a store without attachment times. */
|
|
9
|
+
export interface SiteProviderRevisionRow {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly revision: number;
|
|
12
|
+
}
|
|
13
|
+
export interface WatchProviderRevisionsRequired {
|
|
14
|
+
read: () => Promise<readonly ProviderRevisionRow[]>;
|
|
15
|
+
/** The plugin a key id belongs to, or `undefined` for keys that are not provider config. Host-owned key format. */
|
|
16
|
+
pluginIdOf: (required: {
|
|
17
|
+
keyId: string;
|
|
18
|
+
}) => string | undefined;
|
|
19
|
+
reapply: (required: {
|
|
20
|
+
pluginId: string;
|
|
21
|
+
}) => Promise<PluginProviderApplyResult>;
|
|
22
|
+
}
|
|
23
|
+
export interface WatchProviderRevisionsOptional {
|
|
24
|
+
readSite?: () => Promise<readonly SiteProviderRevisionRow[]>;
|
|
25
|
+
schedule?: (required: {
|
|
26
|
+
run: () => Promise<void>;
|
|
27
|
+
intervalMs: number;
|
|
28
|
+
}) => () => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One metadata query per store every 30 seconds; both processes observe saved revisions and detachments.
|
|
32
|
+
* Reapplies each plugin whose revision set changed (including appearing or disappearing).
|
|
33
|
+
* @returns Stop function: no reapply runs after it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function watchProviderRevisions({ read, pluginIdOf, reapply }: WatchProviderRevisionsRequired, { readSite, schedule }?: WatchProviderRevisionsOptional): () => void;
|
|
36
|
+
//# sourceMappingURL=provider-revision-watch.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const POLL_INTERVAL_MS = 30_000;
|
|
2
|
+
/** Keep site and project revisions distinct even when both stores contain the same provider id. */
|
|
3
|
+
function revisionSnapshot({ project, site, pluginIdOf }) {
|
|
4
|
+
const entries = new Map();
|
|
5
|
+
for (const [scope, rows] of [['project', project], ['site', site]])
|
|
6
|
+
for (const row of rows) {
|
|
7
|
+
const pluginId = pluginIdOf({ keyId: row.id });
|
|
8
|
+
if (!pluginId)
|
|
9
|
+
continue;
|
|
10
|
+
const revisions = entries.get(pluginId) ?? [];
|
|
11
|
+
revisions.push(`${scope}:${row.revision}:${'attached_at' in row ? row.attached_at : ''}`);
|
|
12
|
+
entries.set(pluginId, revisions);
|
|
13
|
+
}
|
|
14
|
+
return new Map([...entries].map(([id, values]) => [id, JSON.stringify(values.sort())]));
|
|
15
|
+
}
|
|
16
|
+
function intervalSchedule({ run, intervalMs }) {
|
|
17
|
+
const timer = setInterval(() => void run(), intervalMs);
|
|
18
|
+
timer.unref?.();
|
|
19
|
+
return () => clearInterval(timer);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* One metadata query per store every 30 seconds; both processes observe saved revisions and detachments.
|
|
23
|
+
* Reapplies each plugin whose revision set changed (including appearing or disappearing).
|
|
24
|
+
* @returns Stop function: no reapply runs after it.
|
|
25
|
+
*/
|
|
26
|
+
export function watchProviderRevisions({ read, pluginIdOf, reapply }, { readSite = async () => [], schedule = intervalSchedule } = {}) {
|
|
27
|
+
let previous = new Map();
|
|
28
|
+
let running = false;
|
|
29
|
+
let closed = false;
|
|
30
|
+
async function check() {
|
|
31
|
+
if (running || closed)
|
|
32
|
+
return;
|
|
33
|
+
running = true;
|
|
34
|
+
try {
|
|
35
|
+
const [project, site] = await Promise.all([read(), readSite()]);
|
|
36
|
+
const next = revisionSnapshot({ project, site, pluginIdOf });
|
|
37
|
+
for (const pluginId of new Set([...previous.keys(), ...next.keys()])) {
|
|
38
|
+
if (!closed && previous.get(pluginId) !== next.get(pluginId))
|
|
39
|
+
await reapply({ pluginId });
|
|
40
|
+
}
|
|
41
|
+
previous = next;
|
|
42
|
+
}
|
|
43
|
+
catch { /* A transient store read must not terminate the site's polling loop. */ }
|
|
44
|
+
finally {
|
|
45
|
+
running = false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
void check();
|
|
49
|
+
const cancel = schedule({ run: check, intervalMs: POLL_INTERVAL_MS });
|
|
50
|
+
return () => { closed = true; cancel(); };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=provider-revision-watch.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginProviderSettingField } from '
|
|
1
|
+
import type { PluginProviderSettingField } from '@jini-ai/core/contracts/plugin-sdk';
|
|
2
2
|
/**
|
|
3
3
|
* Whether a declared field is required for the effective public values (including defaults).
|
|
4
4
|
* `requiredWhen` gates the requirement by exact choices; `requiredUnless` waives it on an exact match or a nonblank declared alternative.
|
|
@@ -10,10 +10,4 @@ export declare function isProviderSettingRequired({ field, values }: {
|
|
|
10
10
|
field: Pick<PluginProviderSettingField, 'required' | 'requiredUnless' | 'requiredWhen'>;
|
|
11
11
|
values: Readonly<Record<string, unknown>>;
|
|
12
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
13
|
//# sourceMappingURL=provider-setting-required.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasProviderAuthHeader } from '@jini-ai/core/contracts/plugin-sdk';
|
|
2
2
|
/** Evaluate the declared alternative without returning any setting or credential value. O(b) alternative text. */
|
|
3
3
|
function requirementWaived({ condition, values }, _optional = {}) {
|
|
4
4
|
if (!condition)
|
|
@@ -28,21 +28,4 @@ export function isProviderSettingRequired({ field, values }, _optional = {}) {
|
|
|
28
28
|
: field.required === true;
|
|
29
29
|
return required && !requirementWaived({ condition: field.requiredUnless, values });
|
|
30
30
|
}
|
|
31
|
-
/** Match only declared nonblank Name=Value headers; malformed lists never waive a requirement.
|
|
32
|
-
* @complexity O(h * n) in header text and the manifest's small name allowlist. */
|
|
33
|
-
export function hasProviderAuthHeader({ text, names }, _optional = {}) {
|
|
34
|
-
const pairs = text.split(',').map(pair => headerPair(pair.trim()));
|
|
35
|
-
if (pairs.some(pair => !pair))
|
|
36
|
-
return false;
|
|
37
|
-
return pairs.some(pair => names.some(name => name.toLowerCase() === pair[0].toLowerCase()) && pair[1].trim() !== '');
|
|
38
|
-
}
|
|
39
|
-
/** `[name, value]` exactly as /^([^=\s][^=]*?)\s*=\s*(.+)$/ captures them from a trimmed pair, but
|
|
40
|
-
* without that pattern's backtracking: the name runs to the first `=` (trailing spaces dropped). */
|
|
41
|
-
function headerPair(pair) {
|
|
42
|
-
const eq = pair.indexOf('=');
|
|
43
|
-
if (eq <= 0)
|
|
44
|
-
return null;
|
|
45
|
-
const value = captureLineTail({ rest: pair.slice(eq + 1) });
|
|
46
|
-
return value === null ? null : [pair.slice(0, eq).trimEnd(), value];
|
|
47
|
-
}
|
|
48
31
|
//# sourceMappingURL=provider-setting-required.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginProviderDeclaration } from '
|
|
1
|
+
import type { PluginProviderDeclaration } from '@jini-ai/core/contracts/plugin-sdk';
|
|
2
2
|
/** Apply the plugin's declared public-setting migrations to a copy; inputs and secrets stay intact.
|
|
3
3
|
* @complexity O(f + m * c) for fields, ordered migrations and their declared choices. */
|
|
4
4
|
export declare function migrateProviderSettings({ providers, settings }: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginActivationRecord, PluginActivationRepoPort } from "./activation.js";
|
|
2
2
|
/**
|
|
3
3
|
* @file In-memory `PluginActivationRepoPort` adapter — mirrors
|
|
4
|
-
* `src/
|
|
4
|
+
* `packages/cms/src/presentation/repo.memory.ts`'s shape exactly (rule-of-two, day one).
|
|
5
5
|
*
|
|
6
6
|
* Architectural role:
|
|
7
7
|
* TDD-certified adapter (implementation outline C-013). Implements get/upsert/delete/list over an
|
package/dist/host/repo.memory.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file In-memory `PluginActivationRepoPort` adapter — mirrors
|
|
3
|
-
* `src/
|
|
3
|
+
* `packages/cms/src/presentation/repo.memory.ts`'s shape exactly (rule-of-two, day one).
|
|
4
4
|
*
|
|
5
5
|
* Architectural role:
|
|
6
6
|
* TDD-certified adapter (implementation outline C-013). Implements get/upsert/delete/list over an
|
package/dist/host/sql/repo.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { StorageKernel } from "@jini-ai/
|
|
1
|
+
import type { StorageKernel } from "@jini-ai/core/contracts/storage";
|
|
2
2
|
import type { PluginActivationTable } from "./repo.rows.js";
|
|
3
3
|
export interface PluginActivationDatabase {
|
|
4
4
|
[table: string]: PluginActivationTable;
|
|
5
5
|
}
|
|
6
6
|
export interface PluginActivationSqlRequired {
|
|
7
|
-
readonly kernel: StorageKernel<PluginActivationDatabase>;
|
|
7
|
+
readonly kernel: StorageKernel<Kysely<PluginActivationDatabase>, PluginActivationDatabase>;
|
|
8
8
|
readonly tables: {
|
|
9
9
|
readonly activations: string;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
import type { PluginActivationRecord, PluginActivationRepoPort } from "../activation.js";
|
|
13
|
+
import type { Kysely } from "kysely";
|
|
13
14
|
/**
|
|
14
15
|
* @file THE `PluginActivationRepoPort` adapter: one Kysely query body for every database the
|
|
15
16
|
* storage kernel drives (SQLite, PGlite, Postgres). One row per (workspace, plugin); `save` upserts
|
|
@@ -17,7 +18,7 @@ import type { PluginActivationRecord, PluginActivationRepoPort } from "../activa
|
|
|
17
18
|
* `__tests__/integration/repo.contract.test.ts`, the suite `repo.memory.ts` runs identically.
|
|
18
19
|
*/
|
|
19
20
|
export declare class SqlPluginActivationRepo implements PluginActivationRepoPort {
|
|
20
|
-
protected readonly kernel: StorageKernel<PluginActivationDatabase>;
|
|
21
|
+
protected readonly kernel: StorageKernel<Kysely<PluginActivationDatabase>, PluginActivationDatabase>;
|
|
21
22
|
protected readonly tables: {
|
|
22
23
|
readonly activations: string;
|
|
23
24
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { toBool } from "@jini-ai/
|
|
1
|
+
import { toBool } from "@jini-ai/core/contracts/storage";
|
|
2
2
|
/** One `plugin_activations` row as a {@link PluginActivationRecord}; NULL quarantine columns are omitted. */
|
|
3
3
|
export function toActivationRecord({ row }, _optional = {}) {
|
|
4
4
|
return {
|
|
5
5
|
pluginId: row.plugin_id,
|
|
6
6
|
workspaceId: row.workspace_id,
|
|
7
7
|
version: row.version,
|
|
8
|
-
enabled: toBool(row.enabled) === true,
|
|
8
|
+
enabled: toBool({ value: row.enabled }) === true,
|
|
9
9
|
updatedAt: row.updated_at,
|
|
10
10
|
...(row.quarantined_at === null ? {} : { quarantinedAt: row.quarantined_at }),
|
|
11
11
|
...(row.quarantine_reason === null ? {} : { quarantineReason: row.quarantine_reason }),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Projects executable plugins onto the host's existing ToolRegistry. Metadata/auth are host
|
|
2
2
|
* ports; no separate catalog, executor, permission vocabulary, or approval engine is created. */
|
|
3
3
|
import { type ToolRegistry, type ToolRegistration, type ToolMetadata } from '@jini-ai/core';
|
|
4
|
-
import { type PluginContributionRegistry
|
|
4
|
+
import { type PluginContributionRegistry } from './contributions.js';
|
|
5
|
+
import { type PluginAuthContext } from '@jini-ai/core/contracts/plugin-sdk';
|
|
5
6
|
export interface PluginToolContributionPorts {
|
|
6
7
|
readonly contributions: PluginContributionRegistry;
|
|
7
8
|
readonly isEnabled: (required: {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* ports; no separate catalog, executor, permission vocabulary, or approval engine is created. */
|
|
3
3
|
import { createToolRegistrationScope, requireInputRecord, ToolInputError } from '@jini-ai/core';
|
|
4
4
|
import { pluginToolIdFor } from './contributions.js';
|
|
5
|
+
import {} from '@jini-ai/core/contracts/plugin-sdk';
|
|
5
6
|
/** Generation + durable activation are checked before authorization and after confirmation.
|
|
6
7
|
* Arbitrary tier-3 handlers cannot establish read-only safety; the host supplies approval policy. */
|
|
7
8
|
export function buildPluginContributionToolRegistrations(required, _optional = {}) {
|
|
@@ -45,6 +45,7 @@ export function buildPluginInstallRegistrations(deps, _optional = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
const input = await deps.installInput({ request, ownerId: ctx.principal.id, runId: ctx.run.id });
|
|
47
47
|
const preview = await previewOrRefuse({ installer, input });
|
|
48
|
+
ctx.signal.throwIfAborted();
|
|
48
49
|
try {
|
|
49
50
|
const plugin = await installer.install({ ...input, expectedDigest: preview.digest });
|
|
50
51
|
deps.telemetry?.installed({ principalId: ctx.principal.id, pluginId: plugin.id });
|