@capybara-hq/kernel 0.1.0-rc.137 → 0.1.0-rc.138
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/admin/extensions.controller.d.ts +5 -2
- package/dist/admin/extensions.controller.js +10 -1
- package/dist/admin/extensions.schemas.d.ts +4 -0
- package/dist/admin/extensions.schemas.js +9 -0
- package/dist/admin/health.service.d.ts +1 -1
- package/dist/admin/health.service.js +3 -3
- package/dist/catalog/catalog-content.d.ts +5 -7
- package/dist/catalog/catalog-items.js +1 -1
- package/dist/catalog/catalog-scope.service.js +5 -5
- package/dist/catalog/catalog.module.js +5 -4
- package/dist/catalog/catalog.service.d.ts +7 -1
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/effect-work.d.ts +27 -0
- package/dist/catalog/effect-work.js +151 -0
- package/dist/catalog/jobs.d.ts +4 -1
- package/dist/catalog/jobs.js +14 -4
- package/dist/catalog/org-catalog.service.d.ts +2 -0
- package/dist/catalog/org-catalog.service.js +68 -12
- package/dist/catalog/org-intent.d.ts +4 -2
- package/dist/catalog/org-intent.js +25 -4
- package/dist/catalog/owned-items.d.ts +5 -1
- package/dist/catalog/owned-items.js +18 -3
- package/dist/catalog/plugin-import.d.ts +4 -2
- package/dist/catalog/plugin-import.js +10 -5
- package/dist/catalog/plugin-install.d.ts +17 -51
- package/dist/catalog/plugin-install.js +209 -235
- package/dist/catalog/plugin-upgrade.d.ts +8 -3
- package/dist/catalog/plugin-upgrade.js +63 -34
- package/dist/catalog/scope-sync-workers.d.ts +7 -11
- package/dist/catalog/scope-sync-workers.js +10 -26
- package/dist/catalog/scope-sync.d.ts +19 -114
- package/dist/catalog/scope-sync.js +220 -239
- package/dist/catalog/scope-writer.d.ts +10 -1
- package/dist/catalog/scope-writer.js +62 -4
- package/dist/catalog/template-connector-ensure.js +1 -1
- package/dist/catalog/unshare.js +1 -2
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +7 -4
- package/dist/db/kernel-schema.d.ts +21 -5
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +2 -0
- package/dist/extensions/admin-ops.d.ts +1 -1
- package/dist/extensions/admin-ops.js +1 -1
- package/dist/extensions/admin-view.d.ts +4 -1
- package/dist/extensions/admin-view.js +27 -11
- package/dist/extensions/bootstrap.d.ts +1 -1
- package/dist/extensions/bootstrap.js +2 -3
- package/dist/extensions/enabled.d.ts +160 -0
- package/dist/extensions/enabled.js +7 -0
- package/dist/extensions/host.d.ts +1 -0
- package/dist/extensions/host.js +5 -2
- package/dist/extensions/isolated/authorization.d.ts +8 -0
- package/dist/extensions/isolated/authorization.js +56 -11
- package/dist/extensions/isolated/broker.js +30 -11
- package/dist/extensions/isolated/engine-binds.d.ts +9 -0
- package/dist/extensions/isolated/engine-binds.js +82 -0
- package/dist/extensions/isolated/engine-policy.d.ts +85 -0
- package/dist/extensions/isolated/engine-policy.js +75 -0
- package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
- package/dist/extensions/isolated/engine-proxy-main.js +20 -0
- package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
- package/dist/extensions/isolated/engine-proxy.js +408 -0
- package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
- package/dist/extensions/isolated/engine-vaults.js +93 -0
- package/dist/extensions/isolated/lanes.d.ts +11 -3
- package/dist/extensions/isolated/lanes.js +43 -16
- package/dist/extensions/isolated/postgres-gate.d.ts +1 -0
- package/dist/extensions/isolated/postgres-gate.js +6 -6
- package/dist/extensions/isolated/revision.d.ts +1 -1
- package/dist/extensions/isolated/revision.js +3 -2
- package/dist/extensions/isolated/sandbox.d.ts +10 -6
- package/dist/extensions/isolated/sandbox.js +101 -117
- package/dist/extensions/lifecycle-topics.d.ts +1 -0
- package/dist/extensions/lifecycle-topics.js +1 -0
- package/dist/extensions/lifecycle.js +23 -2
- package/dist/extensions/permission-view.d.ts +6 -1
- package/dist/inbox/platform-inbox.service.js +16 -27
- package/dist/infra/events/kernel-events.d.ts +4 -0
- package/dist/infra/outbox/registry.d.ts +3 -36
- package/dist/infra/outbox/registry.js +4 -49
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -1
- package/dist/orgs/org-lock.d.ts +3 -1
- package/dist/orgs/org-lock.js +3 -1
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +15 -8
- package/dist/overrides.d.ts +0 -3
- package/dist/overrides.js +0 -2
- package/dist/platform/ops/extensions-admin.ops.js +20 -3
- package/dist/platform/ops/org-plugins.ops.js +5 -2
- package/dist/platform/ops/plugins.ops.js +11 -10
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +6 -2
- package/package.json +2 -2
- package/src/migrations/0231_plugin_effect_work.sql +171 -0
- package/dist/catalog/install-status.d.ts +0 -5
- package/dist/catalog/install-status.js +0 -5
- package/dist/catalog/scope-jobs.d.ts +0 -59
- package/dist/catalog/scope-jobs.js +0 -78
|
@@ -13,9 +13,14 @@ import { ApiError } from "../errors.js";
|
|
|
13
13
|
import { PluginInstallLock } from "../extensions/locks.js";
|
|
14
14
|
import { extensionSourcesQuery } from "../extensions/plugin-items.js";
|
|
15
15
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
16
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
16
17
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
17
18
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
18
19
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
|
+
import { XactLock } from "../infra/database/xact-lock.js";
|
|
21
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
22
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
23
|
+
import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
|
|
19
24
|
export const COMPONENT_SCOPE_TABLE = {
|
|
20
25
|
skill: "platform_skills",
|
|
21
26
|
agent_template: "platform_agent_templates",
|
|
@@ -95,15 +100,22 @@ export function assertScopePreview(confirmation, preview, conflict) {
|
|
|
95
100
|
let ScopeWriter = class ScopeWriter {
|
|
96
101
|
kdb;
|
|
97
102
|
installLock;
|
|
103
|
+
xactLock;
|
|
104
|
+
outbox;
|
|
98
105
|
adminLock;
|
|
99
106
|
txHost;
|
|
100
|
-
|
|
107
|
+
events;
|
|
108
|
+
constructor(kdb, installLock, xactLock, outbox, adminLock, txHost, events) {
|
|
101
109
|
this.kdb = kdb;
|
|
102
110
|
this.installLock = installLock;
|
|
111
|
+
this.xactLock = xactLock;
|
|
112
|
+
this.outbox = outbox;
|
|
103
113
|
this.adminLock = adminLock;
|
|
104
114
|
this.txHost = txHost;
|
|
115
|
+
this.events = events;
|
|
105
116
|
}
|
|
106
117
|
async platformChange(actor, confirmation, prepare) {
|
|
118
|
+
await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
|
|
107
119
|
await this.adminLock.lockAndAuthorize(actor);
|
|
108
120
|
const change = await prepare();
|
|
109
121
|
if (change === undefined)
|
|
@@ -113,7 +125,23 @@ let ScopeWriter = class ScopeWriter {
|
|
|
113
125
|
}
|
|
114
126
|
/** Persist the scope and its named list together after platform confirmation. */
|
|
115
127
|
async replaceScope(change) {
|
|
116
|
-
|
|
128
|
+
const db = this.kdb.db;
|
|
129
|
+
// org-filter: the platform scope change captures every previously listed organization.
|
|
130
|
+
const previousOrgs = change.kind === "connector_template"
|
|
131
|
+
? (await db
|
|
132
|
+
.selectFrom("component_scope_orgs")
|
|
133
|
+
.select("org_id")
|
|
134
|
+
.where("kind", "=", change.kind)
|
|
135
|
+
.where("component_id", "=", change.id)
|
|
136
|
+
.execute()).map((row) => row.org_id)
|
|
137
|
+
: [];
|
|
138
|
+
await writeScope(db, change);
|
|
139
|
+
if (change.kind === "connector_template") {
|
|
140
|
+
await this.oweConnectorTemplate(change.id, { previousOrgs });
|
|
141
|
+
}
|
|
142
|
+
if (change.kind === "plugin" || change.kind === "connector_template") {
|
|
143
|
+
this.refreshIsolatedOrgIntent();
|
|
144
|
+
}
|
|
117
145
|
}
|
|
118
146
|
/** Persist deployment enablement after platform confirmation. */
|
|
119
147
|
async setDisabled(subject, disabled) {
|
|
@@ -123,6 +151,11 @@ let ScopeWriter = class ScopeWriter {
|
|
|
123
151
|
.set({ disabled, updated_at: sql `now()` })
|
|
124
152
|
.where("id", "=", subject.id)
|
|
125
153
|
.execute();
|
|
154
|
+
if (subject.kind === "connector_template")
|
|
155
|
+
await this.oweConnectorTemplate(subject.id, {});
|
|
156
|
+
if ((subject.kind === "plugin" && disabled) || subject.kind === "connector_template") {
|
|
157
|
+
this.refreshIsolatedOrgIntent();
|
|
158
|
+
}
|
|
126
159
|
}
|
|
127
160
|
/** Store local intent under the caller's transaction and org lock. */
|
|
128
161
|
async setOrgSwitch(subject, orgId, enabled, actor) {
|
|
@@ -153,10 +186,32 @@ let ScopeWriter = class ScopeWriter {
|
|
|
153
186
|
.where("component_id", "in", sources.map((source) => source.plugin))
|
|
154
187
|
.execute();
|
|
155
188
|
}
|
|
189
|
+
await oweEffectWork(this.outbox, db, { itemIds: [subject.id], orgId, previousOrgs: [orgId] });
|
|
156
190
|
}
|
|
157
191
|
else {
|
|
158
192
|
await writeComponentSwitch(db, { kind: subject.kind, id: subject.id }, orgId, enabled, actor);
|
|
193
|
+
if (subject.kind === "connector_template") {
|
|
194
|
+
await this.oweConnectorTemplate(subject.id, { orgId, previousOrgs: [orgId] });
|
|
195
|
+
}
|
|
159
196
|
}
|
|
197
|
+
if ((subject.kind === "plugin" && !enabled) || subject.kind === "connector_template") {
|
|
198
|
+
this.refreshIsolatedOrgIntent(orgId);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async oweConnectorTemplate(id, scope) {
|
|
202
|
+
const db = this.kdb.db;
|
|
203
|
+
const template = await db
|
|
204
|
+
.selectFrom("platform_connector_templates")
|
|
205
|
+
.select("catalog_item_id")
|
|
206
|
+
.where("id", "=", id)
|
|
207
|
+
.executeTakeFirst();
|
|
208
|
+
if (template) {
|
|
209
|
+
await oweEffectWork(this.outbox, db, { itemIds: [template.catalog_item_id], ...scope });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Catalog switches can change the intent of extensions brought in through a dependency. */
|
|
213
|
+
refreshIsolatedOrgIntent(orgId) {
|
|
214
|
+
afterCommit(() => this.events.emit("catalog.org-intent-changed", orgId === undefined ? {} : { orgId }));
|
|
160
215
|
}
|
|
161
216
|
};
|
|
162
217
|
__decorate([
|
|
@@ -175,7 +230,10 @@ ScopeWriter = __decorate([
|
|
|
175
230
|
Injectable(),
|
|
176
231
|
__param(0, Inject(KernelDb)),
|
|
177
232
|
__param(1, Inject(PluginInstallLock)),
|
|
178
|
-
__param(2, Inject(
|
|
179
|
-
__param(3, Inject(
|
|
233
|
+
__param(2, Inject(XactLock)),
|
|
234
|
+
__param(3, Inject(OutboxService)),
|
|
235
|
+
__param(4, Inject(SuperAdminLock)),
|
|
236
|
+
__param(5, Inject(TransactionHost)),
|
|
237
|
+
__param(6, Inject(KernelEvents))
|
|
180
238
|
], ScopeWriter);
|
|
181
239
|
export { ScopeWriter };
|
|
@@ -226,7 +226,7 @@ let TemplateConnectorEnsurer = class TemplateConnectorEnsurer {
|
|
|
226
226
|
.innerJoin("orgs as o", "o.id", "a.org_id")
|
|
227
227
|
.innerJoin("platform_connector_templates as t", "t.catalog_item_id", "a.item_id")
|
|
228
228
|
.select(["a.org_id", "a.item_id", "t.id as platform_template_id", "t.template_id", "t.file"])
|
|
229
|
-
.where("a.
|
|
229
|
+
.where("a.version", "is not", null)
|
|
230
230
|
.where("o.deleted_at", "is", null)
|
|
231
231
|
.where("t.deleted_at", "is", null)
|
|
232
232
|
.where(({ not, exists, selectFrom }) => not(exists(selectFrom("connectors as c")
|
package/dist/catalog/unshare.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { audit } from "../identity/audit.js";
|
|
2
2
|
import { asPlatform } from "../infra/database/org-scope.js";
|
|
3
3
|
import { componentOn, listedIn, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
|
|
4
|
-
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
5
4
|
import { writeScope } from "./scope-writer.js";
|
|
6
5
|
async function liveOrgIds(db) {
|
|
7
6
|
const rows = await db.selectFrom("orgs").select("id").where("deleted_at", "is", null).execute();
|
|
@@ -24,7 +23,7 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
24
23
|
.selectFrom("plugin_installs")
|
|
25
24
|
.select("org_id")
|
|
26
25
|
.where("item_id", "=", item.id)
|
|
27
|
-
.where("
|
|
26
|
+
.where("version", "is not", null)
|
|
28
27
|
.execute();
|
|
29
28
|
const switches = await db
|
|
30
29
|
.selectFrom("catalog_item_org_switches")
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -97,7 +97,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
97
97
|
extensionHost: z.ZodPrefault<z.ZodObject<{
|
|
98
98
|
dir: z.ZodDefault<z.ZodString>;
|
|
99
99
|
isolation: z.ZodOptional<z.ZodObject<{
|
|
100
|
-
|
|
100
|
+
engineUrl: z.ZodURL;
|
|
101
101
|
image: z.ZodString;
|
|
102
102
|
socketDir: z.ZodString;
|
|
103
103
|
postgresSocket: z.ZodString;
|
package/dist/config/schema.js
CHANGED
|
@@ -477,11 +477,14 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
477
477
|
})),
|
|
478
478
|
isolation: z
|
|
479
479
|
.strictObject({
|
|
480
|
-
|
|
481
|
-
.
|
|
482
|
-
.
|
|
480
|
+
engineUrl: z
|
|
481
|
+
.url({ protocol: /^http$/ })
|
|
482
|
+
.refine((value) => {
|
|
483
|
+
const url = new URL(value);
|
|
484
|
+
return (!url.username && !url.password && url.pathname === "/" && !url.search && !url.hash);
|
|
485
|
+
}, "Use an HTTP origin without credentials, path, query, or fragment")
|
|
483
486
|
.meta(meta({
|
|
484
|
-
description: "
|
|
487
|
+
description: "Private HTTP origin of the restricted extension Engine API proxy.",
|
|
485
488
|
})),
|
|
486
489
|
image: z
|
|
487
490
|
.string()
|
|
@@ -2210,6 +2210,7 @@ export interface KernelDatabase {
|
|
|
2210
2210
|
org_notices: OrgNoticesTable;
|
|
2211
2211
|
platform_notices: PlatformNoticesTable;
|
|
2212
2212
|
plugin_scope_sync_failures: PluginScopeSyncFailuresTable;
|
|
2213
|
+
plugin_effect_work: PluginEffectWorkTable;
|
|
2213
2214
|
extension_client_builds: ExtensionClientBuildsTable;
|
|
2214
2215
|
extension_client_reports: ExtensionClientReportsTable;
|
|
2215
2216
|
outbox: OutboxTable;
|
|
@@ -2299,7 +2300,7 @@ export interface PlatformNoticesTable {
|
|
|
2299
2300
|
* 0083: what a failed scope sync attempt was doing: turning the plugin on, off, or installing the
|
|
2300
2301
|
* dependencies a platform update added to a live install.
|
|
2301
2302
|
*/
|
|
2302
|
-
export type ScopeSyncOp = "install" | "uninstall" | "dependencies";
|
|
2303
|
+
export type ScopeSyncOp = "install" | "update" | "uninstall" | "dependencies";
|
|
2303
2304
|
/**
|
|
2304
2305
|
* 0083: an open failure of the plugin scope sync for one (item, org): its last attempt failed; the
|
|
2305
2306
|
* next sync of the pair that does not fail deletes the row.
|
|
@@ -2313,6 +2314,15 @@ export interface PluginScopeSyncFailuresTable {
|
|
|
2313
2314
|
message: string;
|
|
2314
2315
|
failed_at: Ts;
|
|
2315
2316
|
}
|
|
2317
|
+
/** The latest owed or settled generation of a plugin's effects in one org. */
|
|
2318
|
+
export interface PluginEffectWorkTable {
|
|
2319
|
+
item_id: string;
|
|
2320
|
+
org_id: string;
|
|
2321
|
+
generation: string;
|
|
2322
|
+
state: "pending" | "settled";
|
|
2323
|
+
generation_started_at: Ts;
|
|
2324
|
+
updated_at: Ts;
|
|
2325
|
+
}
|
|
2316
2326
|
/** 0050: one row per bootstrap manifest the bootstrap step completed. */
|
|
2317
2327
|
export interface BootstrapRunsTable {
|
|
2318
2328
|
/** sha256 (hex) of the bootstrap manifest. */
|
|
@@ -2731,18 +2741,24 @@ export interface CatalogOrgGrantsTable {
|
|
|
2731
2741
|
granted_at: Generated<Date>;
|
|
2732
2742
|
}
|
|
2733
2743
|
/** 0049 / 0138: the states of a plugin install (`LIVE_INSTALL_STATUSES` are the live ones). */
|
|
2734
|
-
export type PluginInstallStatus = "
|
|
2744
|
+
export type PluginInstallStatus = "on" | "install_failed";
|
|
2745
|
+
export interface PluginEffectError {
|
|
2746
|
+
generation: string;
|
|
2747
|
+
operation: ScopeSyncOp;
|
|
2748
|
+
code: string;
|
|
2749
|
+
message: string;
|
|
2750
|
+
attemptedAt: string;
|
|
2751
|
+
}
|
|
2735
2752
|
/** 0037: a plugin's install in an org. */
|
|
2736
2753
|
export interface PluginInstallsTable {
|
|
2737
2754
|
id: string;
|
|
2738
2755
|
org_id: string;
|
|
2739
2756
|
item_id: string;
|
|
2740
|
-
version: string;
|
|
2741
|
-
/** 0138 dropped 0049's `upgrading` (no per-org upgrade since ruling F2). */
|
|
2757
|
+
version: string | null;
|
|
2742
2758
|
status: PluginInstallStatus;
|
|
2743
2759
|
installed_by: string | null;
|
|
2744
2760
|
installed_at: Generated<Date>;
|
|
2745
|
-
error: ColumnType<
|
|
2761
|
+
error: ColumnType<PluginEffectError | null, string | null | undefined, string | null>;
|
|
2746
2762
|
/**
|
|
2747
2763
|
* 0049: the journal of a per-org upgrade. Unused since 0138 (no code reads or writes it, every
|
|
2748
2764
|
* row null); kept for the replicas of the previous release, dropped by a later migration.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sql } from "kysely";
|
|
2
|
-
// PostgreSQL 17 after
|
|
2
|
+
// PostgreSQL 17 after 0231. Re-review the ownership map before updating this fingerprint.
|
|
3
3
|
// It includes relation/column identities and ordered PK, UNIQUE and inbound/outbound FK
|
|
4
4
|
// columns and actions, including FKs from outside the kernel schema.
|
|
5
5
|
export async function orgCatalogDrift(db) {
|
|
@@ -30,5 +30,5 @@ WITH catalog AS (
|
|
|
30
30
|
)
|
|
31
31
|
SELECT md5(string_agg(entry, chr(10) ORDER BY entry COLLATE "C")) AS fingerprint FROM catalog
|
|
32
32
|
`.execute(db);
|
|
33
|
-
return rows[0]?.fingerprint === "
|
|
33
|
+
return rows[0]?.fingerprint === "b1f087cb2ef17b0d3f1a53f4f3099ef6" ? undefined : "schema-drift";
|
|
34
34
|
}
|
|
@@ -48,6 +48,7 @@ export const rowRules = [
|
|
|
48
48
|
rule("platform_sealed_reveals", "id"),
|
|
49
49
|
rule("plugin_install_components", "install_id, kind, ref", "install_id IN (SELECT id FROM capybara.plugin_installs WHERE org_id = (SELECT id FROM subject))"),
|
|
50
50
|
rule("plugin_scope_sync_failures", "item_id, org_id"),
|
|
51
|
+
rule("plugin_effect_work", "item_id, org_id"),
|
|
51
52
|
rule("questions", "id"),
|
|
52
53
|
rule("retention_work", "id"),
|
|
53
54
|
rule("secrets", "namespace, org_id, key"),
|
|
@@ -169,6 +170,7 @@ export const childReferences = {
|
|
|
169
170
|
["platform_themes", "child.catalog_item_id = parent.id"],
|
|
170
171
|
["plugin_installs", "child.item_id = parent.id"],
|
|
171
172
|
["plugin_scope_sync_failures", "child.item_id = parent.id"],
|
|
173
|
+
["plugin_effect_work", "child.item_id = parent.id"],
|
|
172
174
|
["skill_versions", "child.catalog_item_id = parent.id"],
|
|
173
175
|
["skills", "child.catalog_item_id = parent.id"],
|
|
174
176
|
],
|
|
@@ -111,7 +111,7 @@ export declare class ExtensionAdminOps {
|
|
|
111
111
|
/** One enabled provider per single-provider extension point (checked in the enable). */
|
|
112
112
|
singleProvider: SingleProviderGuard,
|
|
113
113
|
/** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
|
|
114
|
-
outbox: Pick<OutboxService, "add">);
|
|
114
|
+
outbox: Pick<OutboxService, "add" | "addMany">);
|
|
115
115
|
private get db();
|
|
116
116
|
/**
|
|
117
117
|
* New install or version change (upgrade / downgrade): the install record points at package
|
|
@@ -11,8 +11,8 @@ import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import semver from "semver";
|
|
14
|
+
import { oweDeployedExtensionSync } from "../catalog/effect-work.js";
|
|
14
15
|
import { itemRemovedError } from "../catalog/ownership.js";
|
|
15
|
-
import { oweDeployedExtensionSync } from "../catalog/scope-jobs.js";
|
|
16
16
|
import { pluginSchemaName } from "../ctx/create-ctx.js";
|
|
17
17
|
import { ConfiguredExtensionDbIdentity } from "../db/extension-db.js";
|
|
18
18
|
import { EMPTY_EXTENSION_SCHEMA_COMMENT } from "../db/extension-role-provision.js";
|
|
@@ -13,6 +13,7 @@ import { ExtensionHost } from "./host.js";
|
|
|
13
13
|
import { ExtensionInstalls } from "./installs.js";
|
|
14
14
|
import { ExtensionLifecycle, PLUGINS_CHANGED_TOPIC } from "./lifecycle.js";
|
|
15
15
|
import { PluginApproveLock } from "./locks.js";
|
|
16
|
+
import type { ExtensionOrgCounts } from "./permission-view.js";
|
|
16
17
|
import { type AdminExtensionView } from "./permission-view.js";
|
|
17
18
|
import { PluginIcons } from "./plugin-icons.js";
|
|
18
19
|
import { SingleProviderGuard } from "./single-provider.js";
|
|
@@ -75,7 +76,7 @@ export declare class ExtensionAdmin {
|
|
|
75
76
|
/** The plugins' icons (admin catalog routes). */
|
|
76
77
|
icons: PluginIcons,
|
|
77
78
|
/** The plugin scope sync an approval of an enabled extension owes. */
|
|
78
|
-
outbox: Pick<OutboxService, "add">);
|
|
79
|
+
outbox: Pick<OutboxService, "add" | "addMany">);
|
|
79
80
|
private get db();
|
|
80
81
|
/**
|
|
81
82
|
* Every extension (config-declared, then install records, each by name). With `names`, only
|
|
@@ -120,6 +121,8 @@ export declare class ExtensionAdmin {
|
|
|
120
121
|
* 包的权限集合(静态清单 + 迁移 SQL,与上传时的审阅相同)、迁移审阅警告与是否有部署级配置字段;按 sha256 缓存。
|
|
121
122
|
*/
|
|
122
123
|
private packageInfo;
|
|
124
|
+
orgCounts(names: readonly string[]): Promise<ExtensionOrgCounts[]>;
|
|
125
|
+
private orgCountsForSubjects;
|
|
123
126
|
/**
|
|
124
127
|
* For each configurable, readable extension whose platform config leaves required overridable
|
|
125
128
|
* fields empty (spec A §5.4a): the number of orgs still needing their own config. Extensions
|
|
@@ -10,7 +10,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
-
import {
|
|
13
|
+
import { EXTENSION_ORG_COUNT_PAGE_SIZE } from "../admin/extensions.schemas.js";
|
|
14
|
+
import { oweDeployedExtensionSync } from "../catalog/effect-work.js";
|
|
14
15
|
import { ApiError } from "../errors.js";
|
|
15
16
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
16
17
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -24,7 +25,7 @@ import { ExtensionBlobs } from "./blobs.js";
|
|
|
24
25
|
import { ExtensionDeploymentConfigService } from "./deployment-config.js";
|
|
25
26
|
import { ExtensionDisplayNames } from "./display-name.js";
|
|
26
27
|
import { EffectiveConfigs } from "./effective-config.js";
|
|
27
|
-
import {
|
|
28
|
+
import { extensionOrgCountsQuery } from "./enabled.js";
|
|
28
29
|
import { ExtensionHost } from "./host.js";
|
|
29
30
|
import { ExtensionInstalls } from "./installs.js";
|
|
30
31
|
import { ExtensionLifecycle, PLUGINS_CHANGED_TOPIC, STALE_RECONCILE_PERIODS } from "./lifecycle.js";
|
|
@@ -140,7 +141,9 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
140
141
|
throw new ApiError("extension.not_found", `Extension ${name} is not known to this deployment`);
|
|
141
142
|
if (!opts.allowUnreadable)
|
|
142
143
|
assertReadable(s);
|
|
143
|
-
|
|
144
|
+
const [view] = await this.views([s]);
|
|
145
|
+
const [counts] = await this.orgCountsForSubjects([s]);
|
|
146
|
+
return { ...view, ...counts };
|
|
144
147
|
}
|
|
145
148
|
/**
|
|
146
149
|
* The review digest of a stored package (the `reviewHash` its extension would show once
|
|
@@ -322,6 +325,27 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
322
325
|
}
|
|
323
326
|
return { ...cached, configurable: cached.set.config.deployment.length > 0 };
|
|
324
327
|
}
|
|
328
|
+
async orgCounts(names) {
|
|
329
|
+
if (names.length > EXTENSION_ORG_COUNT_PAGE_SIZE) {
|
|
330
|
+
throw new ApiError("validation_failed", `Request at most ${EXTENSION_ORG_COUNT_PAGE_SIZE} extension names per page.`);
|
|
331
|
+
}
|
|
332
|
+
return this.orgCountsForSubjects(await this.subjects(undefined, new Set(names)));
|
|
333
|
+
}
|
|
334
|
+
async orgCountsForSubjects(subjects) {
|
|
335
|
+
if (subjects.length === 0)
|
|
336
|
+
return [];
|
|
337
|
+
const names = subjects.map((subject) => subject.name);
|
|
338
|
+
const needing = await this.orgsNeedingConfig(subjects);
|
|
339
|
+
const counts = new Map((await extensionOrgCountsQuery(this.db, names).execute()).map((r) => [r.plugin, Number(r.n)]));
|
|
340
|
+
return names.map((name) => {
|
|
341
|
+
const orgsNeedingConfig = needing.get(name);
|
|
342
|
+
return {
|
|
343
|
+
name,
|
|
344
|
+
enabledOrgs: counts.get(name) ?? 0,
|
|
345
|
+
...(orgsNeedingConfig !== undefined && { orgsNeedingConfig }),
|
|
346
|
+
};
|
|
347
|
+
});
|
|
348
|
+
}
|
|
325
349
|
/**
|
|
326
350
|
* For each configurable, readable extension whose platform config leaves required overridable
|
|
327
351
|
* fields empty (spec A §5.4a): the number of orgs still needing their own config. Extensions
|
|
@@ -375,7 +399,6 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
375
399
|
...new Set([...conflicts].flatMap(([n, c]) => c.providers.filter((p) => p !== n))),
|
|
376
400
|
];
|
|
377
401
|
const otherDisplay = otherNames.length > 0 ? await this.displayNames.many(otherNames) : null;
|
|
378
|
-
const needing = await this.orgsNeedingConfig(subjects);
|
|
379
402
|
// A disabled install whose single-provider point another enabled extension provides: enabling
|
|
380
403
|
// it would be refused, so the view says which one to disable first.
|
|
381
404
|
const blocked = new Map();
|
|
@@ -386,11 +409,6 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
386
409
|
if (block)
|
|
387
410
|
blocked.set(s.name, block);
|
|
388
411
|
}
|
|
389
|
-
const counts = new Map((await this.db
|
|
390
|
-
.selectFrom(enabledExtensionsByOrg(this.db, names).as("en"))
|
|
391
|
-
.select(["en.plugin", (eb) => eb.fn.countAll().as("n")])
|
|
392
|
-
.groupBy("en.plugin")
|
|
393
|
-
.execute()).map((r) => [r.plugin, Number(r.n)]));
|
|
394
412
|
const { clients, reports } = await this.clientsOf(subjects, rows);
|
|
395
413
|
return subjects.map((s) => {
|
|
396
414
|
const of = items.get(s.name);
|
|
@@ -405,7 +423,6 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
405
423
|
? "all"
|
|
406
424
|
: of[0].scope
|
|
407
425
|
: null,
|
|
408
|
-
enabledOrgs: counts.get(s.name) ?? 0,
|
|
409
426
|
builtin,
|
|
410
427
|
};
|
|
411
428
|
const replicas = rows.filter((r) => r.plugin === s.name);
|
|
@@ -496,7 +513,6 @@ let ExtensionAdmin = class ExtensionAdmin {
|
|
|
496
513
|
snapshot: snapshotView(snap),
|
|
497
514
|
configurable: s.configurable,
|
|
498
515
|
configValid,
|
|
499
|
-
...(needing.has(s.name) && { orgsNeedingConfig: needing.get(s.name) }),
|
|
500
516
|
removable: s.source === "install" && install?.required !== true,
|
|
501
517
|
required: install?.required === true,
|
|
502
518
|
...scopeInfo,
|
|
@@ -173,7 +173,7 @@ export declare class BootstrapService {
|
|
|
173
173
|
private readonly log;
|
|
174
174
|
/** The lock's lifetime without renewal. */
|
|
175
175
|
private readonly lockTtlMs;
|
|
176
|
-
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add">,
|
|
176
|
+
constructor(kdb: KernelDb, txHost: TransactionHost, locks: LockService, approveLock: PluginApproveLock, installs: ExtensionInstalls, ops: ExtensionAdminOps, outbox: Pick<OutboxService, "add" | "addMany">,
|
|
177
177
|
/**
|
|
178
178
|
* Config-declared extension names (an entry of the same name is kept, config wins, and no
|
|
179
179
|
* install record is created): the start sequence records them before the bootstrap step, the
|
|
@@ -13,12 +13,12 @@ import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import semver from "semver";
|
|
15
15
|
import { marketplaceGitSource, repoOwner } from "../catalog/catalog.service.js";
|
|
16
|
+
import { oweEffectWork } from "../catalog/effect-work.js";
|
|
16
17
|
import { gitTreeOidOf } from "../catalog/git-source.js";
|
|
17
18
|
import { CONFIG_MARKETPLACE_PREFIX } from "../catalog/marketplaces.service.js";
|
|
18
19
|
import { otherNameOwner } from "../catalog/ownership.js";
|
|
19
20
|
import { catalogPackageError, } from "../catalog/plugin-import.js";
|
|
20
21
|
import { PluginPackageError, readPluginPackage } from "../catalog/plugin-package.js";
|
|
21
|
-
import { oweScopeItem } from "../catalog/scope-jobs.js";
|
|
22
22
|
import { ApiError } from "../errors.js";
|
|
23
23
|
import { audit } from "../identity/audit.js";
|
|
24
24
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -643,8 +643,7 @@ let BootstrapService = class BootstrapService {
|
|
|
643
643
|
* left the item alone; without this sync the orgs its scope (`all`) wants it on in would lose it.
|
|
644
644
|
*/
|
|
645
645
|
async demoted(itemIds) {
|
|
646
|
-
|
|
647
|
-
await oweScopeItem(this.outbox, this.db, id);
|
|
646
|
+
await oweEffectWork(this.outbox, this.db, { itemIds });
|
|
648
647
|
}
|
|
649
648
|
/**
|
|
650
649
|
* The files of a git entry's verified pack (exactly the tree read at its commit). A tree the tgz
|
|
@@ -33,6 +33,166 @@ export declare function enabledExtensionsByOrg(db: KernelSchemaDb, plugins: read
|
|
|
33
33
|
org_id: string;
|
|
34
34
|
plugin: string;
|
|
35
35
|
}>;
|
|
36
|
+
/** The enabled organization totals for a bounded page of extension names. */
|
|
37
|
+
export declare function extensionOrgCountsQuery(db: KernelSchemaDb, names: readonly string[]): import("kysely").SelectQueryBuilder<{
|
|
38
|
+
_migrations: import("../db/kernel-schema.js").AppliedMigrationTable;
|
|
39
|
+
account_avatar_uploads: import("../db/kernel-schema.js").AccountAvatarUploadsTable;
|
|
40
|
+
account_initial_passwords: import("../db/kernel-schema.js").AccountInitialPasswordsTable;
|
|
41
|
+
accounts: import("../db/kernel-schema.js").AccountsTable;
|
|
42
|
+
agent_members: import("../db/kernel-schema.js").AgentMembersTable;
|
|
43
|
+
agent_template_versions: import("../db/kernel-schema.js").AgentTemplateVersionsTable;
|
|
44
|
+
agent_templates: import("../db/kernel-schema.js").AgentTemplatesTable;
|
|
45
|
+
agent_versions: import("../db/kernel-schema.js").AgentVersionsTable;
|
|
46
|
+
agents: import("../db/kernel-schema.js").AgentsTable;
|
|
47
|
+
api_tokens: import("../db/kernel-schema.js").ApiTokensTable;
|
|
48
|
+
approvals: import("../db/kernel-schema.js").ApprovalsTable;
|
|
49
|
+
attachments: import("../db/kernel-schema.js").AttachmentsTable;
|
|
50
|
+
audit_events: import("../db/kernel-schema.js").AuditEventsTable;
|
|
51
|
+
automation_acceptance: import("../db/kernel-schema.js").AutomationAcceptanceTable;
|
|
52
|
+
automation_conversations: import("../db/kernel-schema.js").AutomationConversationsTable;
|
|
53
|
+
automation_event_deliveries: import("../db/kernel-schema.js").AutomationEventDeliveriesTable;
|
|
54
|
+
automation_grants: import("../db/kernel-schema.js").AutomationGrantsTable;
|
|
55
|
+
automation_offers: import("../db/kernel-schema.js").AutomationOffersTable;
|
|
56
|
+
automation_runs: import("../db/kernel-schema.js").AutomationRunsTable;
|
|
57
|
+
automations: import("../db/kernel-schema.js").AutomationsTable;
|
|
58
|
+
background_tasks: import("../db/kernel-schema.js").BackgroundTasksTable;
|
|
59
|
+
blobs: import("../db/kernel-schema.js").BlobsTable;
|
|
60
|
+
bootstrap_run_started: import("../db/kernel-schema.js").BootstrapRunStartedTable;
|
|
61
|
+
bootstrap_runs: import("../db/kernel-schema.js").BootstrapRunsTable;
|
|
62
|
+
catalog_dependency_edges: import("../db/kernel-schema.js").CatalogDependencyEdgesTable;
|
|
63
|
+
catalog_files: import("../db/kernel-schema.js").CatalogFilesTable;
|
|
64
|
+
catalog_item_org_switches: import("../db/kernel-schema.js").CatalogItemOrgSwitchesTable;
|
|
65
|
+
catalog_item_scope_orgs: import("../db/kernel-schema.js").CatalogItemScopeOrgsTable;
|
|
66
|
+
catalog_item_versions: import("../db/kernel-schema.js").CatalogItemVersionsTable;
|
|
67
|
+
catalog_items: import("../db/kernel-schema.js").CatalogItemsTable;
|
|
68
|
+
catalog_org_grants: import("../db/kernel-schema.js").CatalogOrgGrantsTable;
|
|
69
|
+
catalog_requests: import("../db/kernel-schema.js").CatalogRequestsTable;
|
|
70
|
+
channel_card_messages: import("../db/kernel-schema.js").ChannelCardMessagesTable;
|
|
71
|
+
channel_connections: import("../db/kernel-schema.js").ChannelConnectionsTable;
|
|
72
|
+
channel_deliveries: import("../db/kernel-schema.js").ChannelDeliveriesTable;
|
|
73
|
+
channel_threads: import("../db/kernel-schema.js").ChannelThreadsTable;
|
|
74
|
+
component_org_switches: import("../db/kernel-schema.js").ComponentOrgSwitchesTable;
|
|
75
|
+
component_scope_orgs: import("../db/kernel-schema.js").ComponentScopeOrgsTable;
|
|
76
|
+
connector_tool_account_policies: import("../db/kernel-schema.js").ConnectorToolAccountPoliciesTable;
|
|
77
|
+
connector_tools: import("../db/kernel-schema.js").ConnectorToolsTable;
|
|
78
|
+
connectors: import("../db/kernel-schema.js").ConnectorsTable;
|
|
79
|
+
conversation_events: import("../db/kernel-schema.js").ConversationEventsTable;
|
|
80
|
+
conversation_files: import("../db/kernel-schema.js").ConversationFilesTable;
|
|
81
|
+
conversation_queue: import("../db/kernel-schema.js").ConversationQueueTable;
|
|
82
|
+
conversation_tool_grants: import("../db/kernel-schema.js").ConversationToolGrantsTable;
|
|
83
|
+
conversations: import("../db/kernel-schema.js").ConversationsTable;
|
|
84
|
+
data_erasure_requests: import("../db/kernel-schema.js").DataErasureRequestsTable;
|
|
85
|
+
deployment_settings: import("../db/kernel-schema.js").DeploymentSettingsTable;
|
|
86
|
+
device_conversation_notices: import("../db/kernel-schema.js").DeviceConversationNoticesTable;
|
|
87
|
+
device_defaults: import("../db/kernel-schema.js").DeviceDefaultsTable;
|
|
88
|
+
device_generation_high_water: import("../db/kernel-schema.js").DeviceGenerationHighWaterTable;
|
|
89
|
+
device_host_services: import("../db/kernel-schema.js").DeviceHostServicesTable;
|
|
90
|
+
device_instance_destructions: import("../db/kernel-schema.js").DeviceInstanceDestructionsTable;
|
|
91
|
+
device_instances: import("../db/kernel-schema.js").DeviceInstancesTable;
|
|
92
|
+
device_loopback_grants: import("../db/kernel-schema.js").DeviceLoopbackGrantsTable;
|
|
93
|
+
device_machines: import("../db/kernel-schema.js").DeviceMachinesTable;
|
|
94
|
+
device_permission_reports: import("../db/kernel-schema.js").DevicePermissionReportsTable;
|
|
95
|
+
device_projects: import("../db/kernel-schema.js").DeviceProjectsTable;
|
|
96
|
+
device_service_event_cursors: import("../db/kernel-schema.js").DeviceServiceEventCursorsTable;
|
|
97
|
+
device_service_events: import("../db/kernel-schema.js").DeviceServiceEventsTable;
|
|
98
|
+
device_site_grants: import("../db/kernel-schema.js").DeviceSiteGrantsTable;
|
|
99
|
+
devices: import("../db/kernel-schema.js").DevicesTable;
|
|
100
|
+
directory_exclusions: import("../db/kernel-schema.js").DirectoryExclusionsTable;
|
|
101
|
+
en: {
|
|
102
|
+
org_id: string;
|
|
103
|
+
plugin: string;
|
|
104
|
+
};
|
|
105
|
+
eval_cases: import("../db/kernel-schema.js").EvalCasesTable;
|
|
106
|
+
eval_results: import("../db/kernel-schema.js").EvalResultsTable;
|
|
107
|
+
eval_runs: import("../db/kernel-schema.js").EvalRunsTable;
|
|
108
|
+
eval_sets: import("../db/kernel-schema.js").EvalSetsTable;
|
|
109
|
+
extension_blobs: import("../db/kernel-schema.js").ExtensionBlobsTable;
|
|
110
|
+
extension_catalog_sources: import("../db/kernel-schema.js").ExtensionCatalogSourcesTable;
|
|
111
|
+
extension_client_builds: import("../db/kernel-schema.js").ExtensionClientBuildsTable;
|
|
112
|
+
extension_client_reports: import("../db/kernel-schema.js").ExtensionClientReportsTable;
|
|
113
|
+
extension_deployment_configs: import("../db/kernel-schema.js").ExtensionDeploymentConfigsTable;
|
|
114
|
+
extension_effect_cancellations: import("../db/kernel-schema.js").ExtensionEffectCancellationsTable;
|
|
115
|
+
extension_effect_receipts: import("../db/kernel-schema.js").ExtensionEffectReceiptsTable;
|
|
116
|
+
extension_installs: import("../db/kernel-schema.js").ExtensionInstallsTable;
|
|
117
|
+
extension_name_owners: import("../db/kernel-schema.js").ExtensionNameOwnersTable;
|
|
118
|
+
extension_org_configs: import("../db/kernel-schema.js").ExtensionOrgConfigsTable;
|
|
119
|
+
extension_org_overrides: import("../db/kernel-schema.js").ExtensionOrgOverridesTable;
|
|
120
|
+
extension_packages: import("../db/kernel-schema.js").ExtensionPackagesTable;
|
|
121
|
+
extension_permission_snapshots: import("../db/kernel-schema.js").ExtensionPermissionSnapshotsTable;
|
|
122
|
+
extension_replica_status: import("../db/kernel-schema.js").ExtensionReplicaStatusTable;
|
|
123
|
+
file_previewers: import("../db/kernel-schema.js").FilePreviewersTable;
|
|
124
|
+
file_shares: import("../db/kernel-schema.js").FileSharesTable;
|
|
125
|
+
files: import("../db/kernel-schema.js").FilesTable;
|
|
126
|
+
identities: import("../db/kernel-schema.js").IdentitiesTable;
|
|
127
|
+
inbox_items: import("../db/kernel-schema.js").InboxItemsTable;
|
|
128
|
+
invitations: import("../db/kernel-schema.js").InvitationsTable;
|
|
129
|
+
lg_checkpoint_writes: import("../db/kernel-schema.js").LgCheckpointWritesTable;
|
|
130
|
+
lg_checkpoints: import("../db/kernel-schema.js").LgCheckpointsTable;
|
|
131
|
+
local_passwords: import("../db/kernel-schema.js").LocalPasswordsTable;
|
|
132
|
+
marketplace_entries: import("../db/kernel-schema.js").MarketplaceEntriesTable;
|
|
133
|
+
marketplace_icon_failures: import("../db/kernel-schema.js").MarketplaceIconFailuresTable;
|
|
134
|
+
marketplace_icons: import("../db/kernel-schema.js").MarketplaceIconsTable;
|
|
135
|
+
marketplaces: import("../db/kernel-schema.js").MarketplacesTable;
|
|
136
|
+
memberships: import("../db/kernel-schema.js").MembershipsTable;
|
|
137
|
+
model_budget_member_usage: import("../db/kernel-schema.js").ModelBudgetMemberUsageTable;
|
|
138
|
+
model_budget_org_usage: import("../db/kernel-schema.js").ModelBudgetOrgUsageTable;
|
|
139
|
+
model_disabled: import("../db/kernel-schema.js").ModelDisabledTable;
|
|
140
|
+
model_prices: import("../db/kernel-schema.js").ModelPricesTable;
|
|
141
|
+
model_purpose_mappings: import("../db/kernel-schema.js").ModelPurposeMappingsTable;
|
|
142
|
+
model_usage: import("../db/kernel-schema.js").ModelUsageTable;
|
|
143
|
+
org_anonymous_accounts: import("../db/kernel-schema.js").OrgAnonymousAccountsTable;
|
|
144
|
+
org_data_keys: import("../db/kernel-schema.js").OrgDataKeysTable;
|
|
145
|
+
org_extension_point_defaults: import("../db/kernel-schema.js").OrgExtensionPointDefaultsTable;
|
|
146
|
+
org_git_push_denials: import("../db/kernel-schema.js").OrgGitPushDenialsTable;
|
|
147
|
+
org_network_allowances: import("../db/kernel-schema.js").OrgNetworkAllowancesTable;
|
|
148
|
+
org_notices: import("../db/kernel-schema.js").OrgNoticesTable;
|
|
149
|
+
org_tool_policies: import("../db/kernel-schema.js").OrgToolPoliciesTable;
|
|
150
|
+
orgs: import("../db/kernel-schema.js").OrgsTable;
|
|
151
|
+
outbox: import("../db/kernel-schema.js").OutboxTable;
|
|
152
|
+
permission_authority_epochs: import("../db/kernel-schema.js").PermissionAuthorityEpochsTable;
|
|
153
|
+
permission_call_grants: import("../db/kernel-schema.js").PermissionCallGrantsTable;
|
|
154
|
+
permission_config_publication: import("../db/kernel-schema.js").PermissionConfigPublicationTable;
|
|
155
|
+
platform_agent_template_versions: import("../db/kernel-schema.js").PlatformAgentTemplateVersionsTable;
|
|
156
|
+
platform_agent_templates: import("../db/kernel-schema.js").PlatformAgentTemplatesTable;
|
|
157
|
+
platform_connector_templates: import("../db/kernel-schema.js").PlatformConnectorTemplatesTable;
|
|
158
|
+
platform_icons: import("../db/kernel-schema.js").PlatformIconsTable;
|
|
159
|
+
platform_notices: import("../db/kernel-schema.js").PlatformNoticesTable;
|
|
160
|
+
platform_sealed_inputs: import("../db/kernel-schema.js").PlatformSealedInputsTable;
|
|
161
|
+
platform_sealed_reveals: import("../db/kernel-schema.js").PlatformSealedRevealsTable;
|
|
162
|
+
platform_skill_versions: import("../db/kernel-schema.js").PlatformSkillVersionsTable;
|
|
163
|
+
platform_skills: import("../db/kernel-schema.js").PlatformSkillsTable;
|
|
164
|
+
platform_theme_versions: import("../db/kernel-schema.js").PlatformThemeVersionsTable;
|
|
165
|
+
platform_themes: import("../db/kernel-schema.js").PlatformThemesTable;
|
|
166
|
+
plugin_effect_work: import("../db/kernel-schema.js").PluginEffectWorkTable;
|
|
167
|
+
plugin_import_staging: import("../db/kernel-schema.js").PluginImportStagingTable;
|
|
168
|
+
plugin_install_components: import("../db/kernel-schema.js").PluginInstallComponentsTable;
|
|
169
|
+
plugin_installs: import("../db/kernel-schema.js").PluginInstallsTable;
|
|
170
|
+
plugin_scope_sync_failures: import("../db/kernel-schema.js").PluginScopeSyncFailuresTable;
|
|
171
|
+
push_preferences: import("../db/kernel-schema.js").PushPreferencesTable;
|
|
172
|
+
push_registrations: import("../db/kernel-schema.js").PushRegistrationsTable;
|
|
173
|
+
questions: import("../db/kernel-schema.js").QuestionsTable;
|
|
174
|
+
retention_coverage: import("../db/kernel-schema.js").RetentionCoverageTable;
|
|
175
|
+
retention_work: import("../db/kernel-schema.js").RetentionWorkTable;
|
|
176
|
+
run_recovery_cursors: import("../db/kernel-schema.js").RunRecoveryCursorsTable;
|
|
177
|
+
runs: import("../db/kernel-schema.js").RunsTable;
|
|
178
|
+
sandbox_operation_intents: import("../db/kernel-schema.js").SandboxOperationIntentsTable;
|
|
179
|
+
sandbox_operation_payload_chunks: import("../db/kernel-schema.js").SandboxOperationPayloadChunksTable;
|
|
180
|
+
secrets: import("../db/kernel-schema.js").SecretsTable;
|
|
181
|
+
sessions: import("../db/kernel-schema.js").SessionsTable;
|
|
182
|
+
skill_change_requests: import("../db/kernel-schema.js").SkillChangeRequestsTable;
|
|
183
|
+
skill_versions: import("../db/kernel-schema.js").SkillVersionsTable;
|
|
184
|
+
skills: import("../db/kernel-schema.js").SkillsTable;
|
|
185
|
+
subagent_dispatches: import("../db/kernel-schema.js").SubagentDispatchesTable;
|
|
186
|
+
tool_grants: import("../db/kernel-schema.js").ToolGrantsTable;
|
|
187
|
+
tool_outputs: import("../db/kernel-schema.js").ToolOutputsTable;
|
|
188
|
+
tool_specs: import("../db/kernel-schema.js").ToolSpecsTable;
|
|
189
|
+
trigger_cause_handles: import("../db/kernel-schema.js").TriggerCauseHandlesTable;
|
|
190
|
+
trigger_events: import("../db/kernel-schema.js").TriggerEventsTable;
|
|
191
|
+
usage_report_obligations: import("../db/kernel-schema.js").UsageReportObligationsTable;
|
|
192
|
+
}, "en", {
|
|
193
|
+
n: string;
|
|
194
|
+
plugin: string;
|
|
195
|
+
}>;
|
|
36
196
|
/** Whether the extension has committed intent in the org. Execution checks remain at the caller. */
|
|
37
197
|
export declare function isExtensionEnabled(db: KernelSchemaDb, orgId: string, plugin: string): Promise<boolean>;
|
|
38
198
|
/**
|
|
@@ -146,6 +146,13 @@ export function enabledExtensionsByOrg(db, plugins) {
|
|
|
146
146
|
.where("enabled_org.deleted_at", "is", null)
|
|
147
147
|
.where(({ exists, ref }) => exists(enabledExtensionsQuery(db, ref("enabled_org.id"), ref("requested.plugin"))));
|
|
148
148
|
}
|
|
149
|
+
/** The enabled organization totals for a bounded page of extension names. */
|
|
150
|
+
export function extensionOrgCountsQuery(db, names) {
|
|
151
|
+
return db
|
|
152
|
+
.selectFrom(enabledExtensionsByOrg(db, names).as("en"))
|
|
153
|
+
.select(["en.plugin", (eb) => eb.fn.countAll().as("n")])
|
|
154
|
+
.groupBy("en.plugin");
|
|
155
|
+
}
|
|
149
156
|
/** Whether the extension has committed intent in the org. Execution checks remain at the caller. */
|
|
150
157
|
export async function isExtensionEnabled(db, orgId, plugin) {
|
|
151
158
|
const { enabled } = await db
|