@capybara-hq/kernel 0.1.0-rc.140 → 0.1.0-rc.141
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/dist/agents/models.controller.d.ts +9 -2
- package/dist/agents/models.controller.js +35 -4
- package/dist/catalog/catalog-scope.service.js +3 -0
- package/dist/catalog/catalog.module.js +8 -0
- package/dist/catalog/catalog.service.d.ts +2 -2
- package/dist/catalog/catalog.service.js +3 -3
- package/dist/catalog/component-scope.controller.d.ts +2 -1
- package/dist/catalog/component-scope.controller.js +5 -2
- package/dist/catalog/component-scope.service.d.ts +16 -0
- package/dist/catalog/component-scope.service.js +21 -1
- package/dist/catalog/enable-decision.d.ts +34 -0
- package/dist/catalog/enable-decision.js +17 -0
- package/dist/catalog/enable-requests.d.ts +186 -0
- package/dist/catalog/enable-requests.js +767 -0
- package/dist/catalog/enable-targets.d.ts +63 -0
- package/dist/catalog/enable-targets.js +94 -0
- package/dist/catalog/org-catalog.controller.d.ts +11 -3
- package/dist/catalog/org-catalog.controller.js +28 -5
- package/dist/catalog/org-catalog.schemas.d.ts +38 -0
- package/dist/catalog/org-catalog.schemas.js +31 -0
- package/dist/catalog/org-catalog.service.js +1 -1
- package/dist/catalog/org-extension.controller.d.ts +1 -1
- package/dist/catalog/owned-items.js +6 -1
- package/dist/catalog/plugin-install.js +7 -2
- package/dist/catalog/plugin-upgrade.js +3 -0
- package/dist/catalog/request-rules.d.ts +7 -5
- package/dist/catalog/request-rules.js +53 -14
- package/dist/catalog/requests.service.d.ts +137 -4
- package/dist/catalog/requests.service.js +574 -28
- package/dist/catalog/scope-writer.d.ts +20 -3
- package/dist/catalog/scope-writer.js +32 -3
- package/dist/ctx/bus.js +3 -2
- package/dist/db/kernel-schema.d.ts +3 -2
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +7 -0
- package/dist/extensions/admin-ops.js +2 -0
- package/dist/extensions/admin-view.js +2 -1
- package/dist/extensions/host.js +1 -1
- package/dist/extensions/org-config.d.ts +8 -0
- package/dist/extensions/org-config.js +20 -5
- package/dist/extensions/permission-view.d.ts +7 -0
- package/dist/extensions/plugin-guides.d.ts +1 -1
- package/dist/extensions/plugin-guides.js +1 -1
- package/dist/extensions/plugin-items.d.ts +8 -0
- package/dist/extensions/plugin-items.js +8 -0
- package/dist/infra/queue/run-job.js +3 -1
- package/dist/models/enablement.d.ts +12 -0
- package/dist/models/enablement.js +32 -0
- package/dist/platform/ops/admin.ops.js +2 -2
- package/dist/platform/ops/catalog-admin.ops.js +1 -1
- package/dist/platform/ops/extensions-admin.ops.js +17 -9
- package/dist/platform/ops/extensions.ops.js +6 -3
- package/dist/platform/ops/org-plugins.ops.js +1 -1
- package/dist/platform/ops/plugins.ops.js +1 -1
- package/dist/platform/ops/requests.ops.js +55 -1
- package/dist/platform/ops/unavailable.js +2 -2
- package/dist/tools/builtins/sandbox/common.d.ts +3 -3
- package/dist/tools/builtins/sandbox/common.js +3 -3
- package/dist/tools/connectors.controller.d.ts +8 -1
- package/dist/tools/connectors.controller.js +14 -1
- package/dist/tools/connectors.service.d.ts +7 -0
- package/dist/tools/connectors.service.js +30 -0
- package/package.json +1 -1
- package/src/migrations/0233_enable_request_targets.sql +64 -0
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { LocalizedName } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { OrgExtensionConfigs } from "../extensions/org-config.js";
|
|
3
|
+
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
2
4
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
3
5
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
6
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
7
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
8
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
9
|
+
import { ModelEnablement } from "../models/enablement.js";
|
|
7
10
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
8
11
|
import { OrgSettingsService } from "../orgs/settings.service.js";
|
|
12
|
+
import { ProviderRegistry } from "../runtime/providers.js";
|
|
13
|
+
import { ConnectorsService } from "../tools/connectors.service.js";
|
|
9
14
|
import { CatalogService, type MarketplaceImportResult } from "./catalog.service.js";
|
|
10
15
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
16
|
+
import { ComponentScopeService } from "./component-scope.service.js";
|
|
17
|
+
import { type EnableTarget } from "./enable-targets.js";
|
|
11
18
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
12
19
|
import { PluginImport } from "./plugin-import.js";
|
|
13
20
|
import type { RequestActorOpts } from "./request-rules.js";
|
|
@@ -101,6 +108,13 @@ export interface CatalogRequestView {
|
|
|
101
108
|
connectors: SetupRequestConnector[] | null;
|
|
102
109
|
/** The hosts, conversation and agent of a `network_allowlist` request; null for other kinds. */
|
|
103
110
|
network: NetworkRequestDetail | null;
|
|
111
|
+
/**
|
|
112
|
+
* An `enable` request's switch (`target`), what the member pointed at (`subject`, the target
|
|
113
|
+
* itself for a legacy request), the target's name and display name (a component's, a
|
|
114
|
+
* connector's, an extension's or model's own name; null once gone) and why a switch change
|
|
115
|
+
* cancelled it (`target_changed`, else null). Null for other kinds.
|
|
116
|
+
*/
|
|
117
|
+
enable: EnableRequestView | null;
|
|
104
118
|
status: CatalogRequestStatus;
|
|
105
119
|
note: string;
|
|
106
120
|
/** The optional reason of a rejection. */
|
|
@@ -116,6 +130,28 @@ export interface CatalogRequestView {
|
|
|
116
130
|
stagingId: string | null;
|
|
117
131
|
createdAt: string;
|
|
118
132
|
}
|
|
133
|
+
/** The `enable` fields of a {@link CatalogRequestView}. */
|
|
134
|
+
export interface EnableRequestView {
|
|
135
|
+
target: EnableTarget;
|
|
136
|
+
subject: EnableTarget;
|
|
137
|
+
name: string | null;
|
|
138
|
+
displayName: LocalizedName | null;
|
|
139
|
+
cancelReason: "target_changed" | null;
|
|
140
|
+
}
|
|
141
|
+
/** A member's point-of-use enable request (`POST /orgs/:orgId/catalog-requests/enable`). */
|
|
142
|
+
export interface EnableRequestInput {
|
|
143
|
+
subject: EnableTarget;
|
|
144
|
+
note?: string | undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* An org admin's decision: the request, and `needs_another_switch` when approving turned the
|
|
148
|
+
* requested switch on but the member's item still needs another switch (the request is then
|
|
149
|
+
* cancelled so the member asks for it).
|
|
150
|
+
*/
|
|
151
|
+
export interface OrgDecisionResult {
|
|
152
|
+
request: CatalogRequestView;
|
|
153
|
+
notice: "needs_another_switch" | null;
|
|
154
|
+
}
|
|
119
155
|
/** A decision: approve, or reject with an optional reason the requester sees. */
|
|
120
156
|
export interface CatalogDecision {
|
|
121
157
|
approve: boolean;
|
|
@@ -160,13 +196,30 @@ export declare class CatalogRequestsService {
|
|
|
160
196
|
readonly txHost: TransactionHost;
|
|
161
197
|
/** Serializes the approvals of one `import` request (`@WithLock`). */
|
|
162
198
|
readonly lockService: LockService;
|
|
199
|
+
/**
|
|
200
|
+
* The ordinary switch writers an approved point-of-use enable request calls for its target
|
|
201
|
+
* (extension, component, model, connector; a plugin goes through `orgCatalog.setSwitch`), and
|
|
202
|
+
* the deployment's live state a request is checked against (loaded extensions, listed models).
|
|
203
|
+
*/
|
|
204
|
+
private readonly orgExtensions;
|
|
205
|
+
private readonly components;
|
|
206
|
+
private readonly models;
|
|
207
|
+
private readonly connectors;
|
|
208
|
+
private readonly extensions;
|
|
209
|
+
private readonly providers;
|
|
163
210
|
constructor(kdb: KernelDb,
|
|
164
211
|
/** The org row and super admin locks: both join the caller's transaction. */
|
|
165
212
|
orgLock: OrgLock, adminLock: SuperAdminLock, orgCatalog: OrgCatalogService, scope: CatalogScopeService, catalog: CatalogService, config: KernelConfigService, pluginImport: PluginImport,
|
|
166
213
|
/** Approving a network request writes the org's `deviceNetwork` through the settings path. */
|
|
167
214
|
orgSettings: OrgSettingsService, txHost: TransactionHost,
|
|
168
215
|
/** Serializes the approvals of one `import` request (`@WithLock`). */
|
|
169
|
-
lockService: LockService
|
|
216
|
+
lockService: LockService,
|
|
217
|
+
/**
|
|
218
|
+
* The ordinary switch writers an approved point-of-use enable request calls for its target
|
|
219
|
+
* (extension, component, model, connector; a plugin goes through `orgCatalog.setSwitch`), and
|
|
220
|
+
* the deployment's live state a request is checked against (loaded extensions, listed models).
|
|
221
|
+
*/
|
|
222
|
+
orgExtensions: OrgExtensionConfigs, components: ComponentScopeService, models: ModelEnablement, connectors: ConnectorsService, extensions: ExtensionRegistry, providers: ProviderRegistry);
|
|
170
223
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
171
224
|
private get db();
|
|
172
225
|
/**
|
|
@@ -198,6 +251,41 @@ export declare class CatalogRequestsService {
|
|
|
198
251
|
*/
|
|
199
252
|
requestNetwork(orgId: string, actor: string, input: NetworkRequestInput, opts?: RequestActorOpts): Promise<CatalogRequestView>;
|
|
200
253
|
private writeNetworkRequest;
|
|
254
|
+
/**
|
|
255
|
+
* A member asks the org admins to turn on what a picker subject needs (`POST /orgs/:orgId/
|
|
256
|
+
* catalog-requests/enable`, Platform `plugins.request-enable`; `catalog.request`, checked
|
|
257
|
+
* first). The kernel resolves the subject's owning switch in the org ({@link resolveSubject}): an
|
|
258
|
+
* off plugin, a stopped extension, a switched-off skill, agent template or connector template, a
|
|
259
|
+
* model the org disabled, or a disabled connector. Hidden (scope, an unshared plugin of another
|
|
260
|
+
* org, a model its provider does not list or the platform disabled) -> the kind's not-found code;
|
|
261
|
+
* disabled by the super admin -> `catalog.item_disabled` (org admins; a member gets not-found);
|
|
262
|
+
* not offered, built in, already on, a provider unavailable or needing configuration ->
|
|
263
|
+
* `catalog.request_invalid`; a plugin or extension that cannot run on the platform now ->
|
|
264
|
+
* `catalog.request_invalid`. A pending request for the same switch is returned (`created`
|
|
265
|
+
* false): to another member redacted ({@link redactFor}), and that member becomes a follower
|
|
266
|
+
* who gets the decision notice too. Audits `catalog.requested`.
|
|
267
|
+
*/
|
|
268
|
+
requestEnable(orgId: string, actor: string, input: EnableRequestInput, opts?: RequestActorOpts): Promise<{
|
|
269
|
+
request: CatalogRequestView;
|
|
270
|
+
created: boolean;
|
|
271
|
+
}>;
|
|
272
|
+
/**
|
|
273
|
+
* What the providers list, read once when a subject is a model: for the org (its enabled
|
|
274
|
+
* providers), and the platform's view (a provider off in the org: its model names).
|
|
275
|
+
*/
|
|
276
|
+
private liveFor;
|
|
277
|
+
/** The extensions loaded on this replica (a config-declared one has no install row). */
|
|
278
|
+
private loadedExtensions;
|
|
279
|
+
/** One request as `viewer` reads it ({@link personalize}). */
|
|
280
|
+
private viewFor;
|
|
281
|
+
/**
|
|
282
|
+
* The checks of a target that need the deployment's live state: a plugin whose extension
|
|
283
|
+
* cannot run on the platform now, an extension that is not loaded.
|
|
284
|
+
*/
|
|
285
|
+
private assertTargetLive;
|
|
286
|
+
private writeEnableRequest;
|
|
287
|
+
/** The account is an admin (or owner) of the org (the role read live). */
|
|
288
|
+
private isOrgAdmin;
|
|
201
289
|
/**
|
|
202
290
|
* An org admin asks for a marketplace entry to be imported (`POST /orgs/:orgId/
|
|
203
291
|
* marketplace-requests`, `catalog.decide`). The deployment setting `orgMarketplaceBrowse` off ->
|
|
@@ -226,10 +314,37 @@ export declare class CatalogRequestsService {
|
|
|
226
314
|
* approving it -> `catalog.request_invalid`. Rejecting stores the reason. Audits
|
|
227
315
|
* `catalog.request_decided`.
|
|
228
316
|
*/
|
|
229
|
-
decideOrg(orgId: string, actor: string, requestId: string, decision: CatalogDecision, opts?: RequestActorOpts): Promise<
|
|
317
|
+
decideOrg(orgId: string, actor: string, requestId: string, decision: CatalogDecision, opts?: RequestActorOpts): Promise<OrgDecisionResult>;
|
|
318
|
+
/**
|
|
319
|
+
* Approves an enable request (spec: checked again at decision). While the stored target is
|
|
320
|
+
* still the subject's owning switch, its ordinary writer is called with the approval in scope
|
|
321
|
+
* ({@link withEnableDecision}): the writer's own transaction re-checks the request is pending
|
|
322
|
+
* (FOR UPDATE) and records the approval with the switch write, so a concurrent reject or second
|
|
323
|
+
* approval either commits first (this one fails with `catalog.request_decided` and its write
|
|
324
|
+
* rolls back) or after (it finds the request decided). When the writer has nothing to write, or
|
|
325
|
+
* the target is no longer the owning switch, {@link finishEnable} decides under the row lock: a
|
|
326
|
+
* subject usable now is approved; one that needs another switch is cancelled and the admin gets
|
|
327
|
+
* `catalog.request_stale`.
|
|
328
|
+
*/
|
|
329
|
+
private approveEnable;
|
|
330
|
+
/**
|
|
331
|
+
* Turns an approved enable request's target on through the ordinary switch writer of its kind,
|
|
332
|
+
* as the deciding admin (each re-checks its own rules and role under the org row lock): the
|
|
333
|
+
* plugin switch (an install), the extension switch, the component switch, the org's model
|
|
334
|
+
* list, or the connector's status. The writer settles the org's pending requests for the target
|
|
335
|
+
* in its transaction ({@link settleEnableRequests}).
|
|
336
|
+
*/
|
|
337
|
+
private applyEnable;
|
|
230
338
|
/**
|
|
231
|
-
*
|
|
232
|
-
*
|
|
339
|
+
* Decides an enable request whose writer recorded nothing, under the org row lock and the
|
|
340
|
+
* request row FOR UPDATE: decided meanwhile -> `catalog.request_decided`; the subject usable
|
|
341
|
+
* now -> approved; otherwise cancelled (`target_changed`, the member asks again). Returns why it
|
|
342
|
+
* was cancelled, else null.
|
|
343
|
+
*/
|
|
344
|
+
private finishEnable;
|
|
345
|
+
/**
|
|
346
|
+
* The detail (target, subject) of a pending `enable` request of the org, null for a
|
|
347
|
+
* `network_allowlist` one (the decider re-checked).
|
|
233
348
|
*/
|
|
234
349
|
private pendingOrgRequest;
|
|
235
350
|
/**
|
|
@@ -308,5 +423,23 @@ export declare class CatalogRequestsService {
|
|
|
308
423
|
view(id: string): Promise<CatalogRequestView>;
|
|
309
424
|
/** The views of `rows`, with the display names of the connector templates setup requests name. */
|
|
310
425
|
private toViews;
|
|
426
|
+
/**
|
|
427
|
+
* The ids of `rows`' enable requests whose subject or target their org can no longer see (hidden
|
|
428
|
+
* by scope, unshared, removed, or a model the platform disabled), resolved set-based per org.
|
|
429
|
+
*/
|
|
430
|
+
private hiddenEnable;
|
|
431
|
+
/**
|
|
432
|
+
* The names of the targets of `rows`' enable requests, by {@link targetKey}: a plugin's item
|
|
433
|
+
* name and display name, a component's name (a connector template's display name), a
|
|
434
|
+
* connector's name, an extension's name, a model's own name.
|
|
435
|
+
*/
|
|
436
|
+
private enableNames;
|
|
311
437
|
private baseQuery;
|
|
312
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* A request as `viewer` reads it. The requester sees it whole. Another member (a follower of an
|
|
441
|
+
* enable request, or the member a duplicate ask returns it to) never sees the requester, their
|
|
442
|
+
* note, the reason or the decider; a follower sees their own subject and, once settled, their
|
|
443
|
+
* own outcome (approved, or cancelled with `target_changed`), never the requester's.
|
|
444
|
+
*/
|
|
445
|
+
export declare function personalize(view: CatalogRequestView, viewer: string, detail: unknown): CatalogRequestView;
|