@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.148
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 +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +2 -0
- package/dist/catalog/provenance.js +5 -1
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/extensions.module.js +9 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +18 -8
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +24 -3
- package/dist/extensions/permission-set.d.ts +12 -3
- package/dist/extensions/permission-set.js +5 -5
- package/dist/extensions/permission-view.d.ts +12 -5
- package/dist/extensions/permission-view.js +23 -2
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -12,10 +12,6 @@ import type { SetupCheckState } from "../setup/setup-check-registry.js";
|
|
|
12
12
|
import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery } from "../setup/setup-checks.schemas.js";
|
|
13
13
|
import { SetupChecksService } from "../setup/setup-checks.service.js";
|
|
14
14
|
import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
|
|
15
|
-
declare const ApproveSchema: z.ZodObject<{
|
|
16
|
-
sha256: z.ZodNullable<z.ZodString>;
|
|
17
|
-
reviewHash: z.ZodString;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
15
|
declare const InstallSchema: z.ZodObject<{
|
|
20
16
|
sha256: z.ZodString;
|
|
21
17
|
}, z.core.$strip>;
|
|
@@ -117,13 +113,6 @@ export declare class AdminExtensionsController {
|
|
|
117
113
|
* `extension.not_found`.
|
|
118
114
|
*/
|
|
119
115
|
clearConfig(principal: Principal, name: string): Promise<DeploymentConfigView>;
|
|
120
|
-
/**
|
|
121
|
-
* Web approval: writes the snapshot (source web), audits `extension.permissions_approved` and
|
|
122
|
-
* publishes `kernel.plugins.changed`. Package or
|
|
123
|
-
* permissions changed after the review -> 409 `extension.approval_stale`; nothing to approve ->
|
|
124
|
-
* 409 `extension.not_pending`.
|
|
125
|
-
*/
|
|
126
|
-
approve(principal: Principal, name: string, body: z.infer<typeof ApproveSchema>): Promise<AdminExtensionView>;
|
|
127
116
|
/**
|
|
128
117
|
* New install or version change (upgrade / downgrade): the install record points at `sha256` in the
|
|
129
118
|
* package store; the desired state is unchanged (a new install is disabled).
|
|
@@ -24,14 +24,6 @@ import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
|
24
24
|
import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../setup/setup-checks.schemas.js";
|
|
25
25
|
import { SetupChecksService } from "../setup/setup-checks.service.js";
|
|
26
26
|
import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
|
|
27
|
-
const ApproveSchema = z.object({
|
|
28
|
-
/** 安装记录的包(审阅时的 sha256);配置声明的插件为 null。 */
|
|
29
|
-
sha256: z
|
|
30
|
-
.string()
|
|
31
|
-
.regex(/^[0-9a-f]{64}$/)
|
|
32
|
-
.nullable(),
|
|
33
|
-
reviewHash: z.string().regex(/^[0-9a-f]{16}$/),
|
|
34
|
-
});
|
|
35
27
|
const InstallSchema = z.object({
|
|
36
28
|
/** 包存储里的包(上传 / npm 导入返回的 sha256)。 */
|
|
37
29
|
sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
@@ -40,8 +32,6 @@ const NpmSchema = z.object({
|
|
|
40
32
|
package: z.string().min(1).max(214),
|
|
41
33
|
version: z.string().min(1).max(256).optional(),
|
|
42
34
|
});
|
|
43
|
-
class ExtensionApproveBody extends createZodDto(ApproveSchema, "ExtensionApproveBody") {
|
|
44
|
-
}
|
|
45
35
|
class ExtensionInstallBody extends createZodDto(InstallSchema, "ExtensionInstallBody") {
|
|
46
36
|
}
|
|
47
37
|
class ExtensionConfigBody extends createZodDto(AdminExtensionConfigBody, "ExtensionConfigBody") {
|
|
@@ -183,17 +173,6 @@ let AdminExtensionsController = class AdminExtensionsController {
|
|
|
183
173
|
const actor = requireUser(principal);
|
|
184
174
|
return this.deploymentConfigs.clear(name, actor.account.id, patTokenId(actor));
|
|
185
175
|
}
|
|
186
|
-
/**
|
|
187
|
-
* Web approval: writes the snapshot (source web), audits `extension.permissions_approved` and
|
|
188
|
-
* publishes `kernel.plugins.changed`. Package or
|
|
189
|
-
* permissions changed after the review -> 409 `extension.approval_stale`; nothing to approve ->
|
|
190
|
-
* 409 `extension.not_pending`.
|
|
191
|
-
*/
|
|
192
|
-
async approve(principal, name, body) {
|
|
193
|
-
const actor = requireUser(principal);
|
|
194
|
-
const tokenId = patTokenId(actor);
|
|
195
|
-
return this.admin.approve(actor.account.id, name, body, tokenId !== undefined ? { actorTokenId: tokenId } : {});
|
|
196
|
-
}
|
|
197
176
|
/**
|
|
198
177
|
* New install or version change (upgrade / downgrade): the install record points at `sha256` in the
|
|
199
178
|
* package store; the desired state is unchanged (a new install is disabled).
|
|
@@ -294,13 +273,6 @@ __decorate([
|
|
|
294
273
|
__param(0, CurrentPrincipal()),
|
|
295
274
|
__param(1, Param("name"))
|
|
296
275
|
], AdminExtensionsController.prototype, "clearConfig", null);
|
|
297
|
-
__decorate([
|
|
298
|
-
Post(":name/approve"),
|
|
299
|
-
HttpCode(200),
|
|
300
|
-
__param(0, CurrentPrincipal()),
|
|
301
|
-
__param(1, Param("name")),
|
|
302
|
-
__param(2, ZBody(ExtensionApproveBody))
|
|
303
|
-
], AdminExtensionsController.prototype, "approve", null);
|
|
304
276
|
__decorate([
|
|
305
277
|
Post(":name/install"),
|
|
306
278
|
HttpCode(200),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Queue } from "bullmq";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
5
|
import { type LiveReplica, ReplicaPresence } from "../infra/presence/replica-presence.js";
|
|
5
6
|
import type { KernelLogger } from "../log.js";
|
|
@@ -94,6 +95,22 @@ export interface AdminHealth {
|
|
|
94
95
|
orgId: string | null;
|
|
95
96
|
reason: string;
|
|
96
97
|
}[] | null;
|
|
98
|
+
/**
|
|
99
|
+
* Installed bootstrap plugins whose private platform endpoint no `net.privateEndpoints` alias
|
|
100
|
+
* grants to them (`net/private-endpoint-preflight.ts`); `blocking`: the installed version
|
|
101
|
+
* reaches it through `ctx.net`, so it is unreachable now. `message` names the config to add.
|
|
102
|
+
*/
|
|
103
|
+
privateEndpointGaps: {
|
|
104
|
+
plugin: string;
|
|
105
|
+
kind: "missing" | "narrow" | "address" | "unresolved";
|
|
106
|
+
origin: string;
|
|
107
|
+
alias: string;
|
|
108
|
+
ctxNet: boolean | null;
|
|
109
|
+
field?: string;
|
|
110
|
+
blocking: boolean;
|
|
111
|
+
message: string;
|
|
112
|
+
env: string;
|
|
113
|
+
}[] | null;
|
|
97
114
|
unavailable: AdminHealthSource[];
|
|
98
115
|
}
|
|
99
116
|
/**
|
|
@@ -109,9 +126,16 @@ export declare class AdminHealthService {
|
|
|
109
126
|
private readonly redis;
|
|
110
127
|
private readonly log;
|
|
111
128
|
private readonly providers;
|
|
129
|
+
private readonly config;
|
|
112
130
|
private readonly queues;
|
|
113
|
-
constructor(presence: Pick<ReplicaPresence, "live">, db: KernelDb, redis: Pick<Redis, "zcount" | "status">, log: Pick<KernelLogger, "warn">, providers: Pick<DeviceProviders, "forDevice">, runs: Queue, subagentRuns: Queue, channels: Queue, maintenance: Queue, toolWatch: Queue, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue, connectorTools: Queue, templateConnectors: Queue, serviceEvents: Queue, externalCalls: Queue);
|
|
131
|
+
constructor(presence: Pick<ReplicaPresence, "live">, db: KernelDb, redis: Pick<Redis, "zcount" | "status">, log: Pick<KernelLogger, "warn">, providers: Pick<DeviceProviders, "forDevice">, config: Pick<KernelConfigService, "get">, runs: Queue, subagentRuns: Queue, channels: Queue, maintenance: Queue, toolWatch: Queue, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue, connectorTools: Queue, templateConnectors: Queue, serviceEvents: Queue, externalCalls: Queue);
|
|
114
132
|
read(): Promise<AdminHealth>;
|
|
115
133
|
private readRedis;
|
|
134
|
+
/** The installed brokered pins' private endpoint gaps (resolves their hosts). */
|
|
135
|
+
/**
|
|
136
|
+
* The private endpoint gaps: the installed brokered pins (`privateEndpointGaps`) and every URL
|
|
137
|
+
* field of an enabled extension (`platformUrlGaps`). Resolves their hosts.
|
|
138
|
+
*/
|
|
139
|
+
private readPrivateEndpointGaps;
|
|
116
140
|
private readDb;
|
|
117
141
|
}
|
|
@@ -19,10 +19,12 @@ import { TITLE_QUEUE } from "../conversations/titles.js";
|
|
|
19
19
|
import { SERVICE_EVENTS_QUEUE } from "../device-access/service-events.js";
|
|
20
20
|
import { EVAL_QUEUE_NAME } from "../evals/jobs.js";
|
|
21
21
|
import { LIFECYCLE_QUEUE } from "../extensions/lifecycle-hooks.js";
|
|
22
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
22
23
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
23
24
|
import { asPlatform } from "../infra/database/org-scope.js";
|
|
24
25
|
import { ReplicaPresence } from "../infra/presence/replica-presence.js";
|
|
25
26
|
import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
|
|
27
|
+
import { readDeploymentPrivateEndpointGaps } from "../net/private-endpoint-preflight.js";
|
|
26
28
|
import { PUSH_QUEUE } from "../push/jobs.js";
|
|
27
29
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
28
30
|
import { RUN_QUEUE_NAME, SUBAGENT_RUN_QUEUE_NAME } from "../runtime/run-jobs.js";
|
|
@@ -76,13 +78,15 @@ let AdminHealthService = class AdminHealthService {
|
|
|
76
78
|
redis;
|
|
77
79
|
log;
|
|
78
80
|
providers;
|
|
81
|
+
config;
|
|
79
82
|
queues;
|
|
80
|
-
constructor(presence, db, redis, log, providers, runs, subagentRuns, channels, maintenance, toolWatch, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push, connectorTools, templateConnectors, serviceEvents, externalCalls) {
|
|
83
|
+
constructor(presence, db, redis, log, providers, config, runs, subagentRuns, channels, maintenance, toolWatch, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push, connectorTools, templateConnectors, serviceEvents, externalCalls) {
|
|
81
84
|
this.presence = presence;
|
|
82
85
|
this.db = db;
|
|
83
86
|
this.redis = redis;
|
|
84
87
|
this.log = log;
|
|
85
88
|
this.providers = providers;
|
|
89
|
+
this.config = config;
|
|
86
90
|
// the order of KERNEL_QUEUE_NAMES
|
|
87
91
|
this.queues = [
|
|
88
92
|
runs,
|
|
@@ -107,7 +111,14 @@ let AdminHealthService = class AdminHealthService {
|
|
|
107
111
|
const redisRead = within(this.readRedis(), HEALTH_READ_TIMEOUT_MS);
|
|
108
112
|
// org-filter: deployment-wide counts of live channels, devices and sandbox instances
|
|
109
113
|
const dbRead = asPlatform("read deployment health counts", () => this.readDb());
|
|
110
|
-
const [r, d] = await Promise.allSettled([
|
|
114
|
+
const [r, d, g] = await Promise.allSettled([
|
|
115
|
+
redisRead,
|
|
116
|
+
within(dbRead, HEALTH_READ_TIMEOUT_MS),
|
|
117
|
+
within(this.readPrivateEndpointGaps(), HEALTH_READ_TIMEOUT_MS),
|
|
118
|
+
]);
|
|
119
|
+
if (g.status === "rejected") {
|
|
120
|
+
this.log.warn("admin health: cannot check private endpoints", { err: g.reason });
|
|
121
|
+
}
|
|
111
122
|
const unavailable = [];
|
|
112
123
|
const redis = r.status === "fulfilled" ? r.value : null;
|
|
113
124
|
if (r.status === "rejected") {
|
|
@@ -189,6 +200,7 @@ let AdminHealthService = class AdminHealthService {
|
|
|
189
200
|
devices: { online: devicesOnline, dialIn, byProvider: devicesByProvider },
|
|
190
201
|
sandboxes,
|
|
191
202
|
retentionBlockers: db?.retentionBlockers ?? null,
|
|
203
|
+
privateEndpointGaps: g.status === "fulfilled" ? g.value : null,
|
|
192
204
|
unavailable,
|
|
193
205
|
};
|
|
194
206
|
}
|
|
@@ -224,6 +236,25 @@ let AdminHealthService = class AdminHealthService {
|
|
|
224
236
|
]);
|
|
225
237
|
return { replicas, queues };
|
|
226
238
|
}
|
|
239
|
+
/** The installed brokered pins' private endpoint gaps (resolves their hosts). */
|
|
240
|
+
/**
|
|
241
|
+
* The private endpoint gaps: the installed brokered pins (`privateEndpointGaps`) and every URL
|
|
242
|
+
* field of an enabled extension (`platformUrlGaps`). Resolves their hosts.
|
|
243
|
+
*/
|
|
244
|
+
async readPrivateEndpointGaps() {
|
|
245
|
+
const gaps = await readDeploymentPrivateEndpointGaps(this.db.db, this.config.get());
|
|
246
|
+
return gaps.map(({ plugin, kind, origin, alias, ctxNet, field, blocking, message, env }) => ({
|
|
247
|
+
plugin,
|
|
248
|
+
kind,
|
|
249
|
+
origin,
|
|
250
|
+
alias,
|
|
251
|
+
ctxNet,
|
|
252
|
+
...(field !== undefined && { field }),
|
|
253
|
+
blocking,
|
|
254
|
+
message,
|
|
255
|
+
env,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
227
258
|
async readDb() {
|
|
228
259
|
const db = this.db.db;
|
|
229
260
|
const [channels, devices, instances, retentionBlockers] = await Promise.all([
|
|
@@ -300,21 +331,22 @@ AdminHealthService = __decorate([
|
|
|
300
331
|
__param(2, Inject(REDIS)),
|
|
301
332
|
__param(3, Inject(KERNEL_LOGGER)),
|
|
302
333
|
__param(4, Inject(DeviceProviders)),
|
|
303
|
-
__param(5, Inject(
|
|
304
|
-
__param(6, Inject(getQueueToken(
|
|
305
|
-
__param(7, Inject(getQueueToken(
|
|
306
|
-
__param(8, Inject(getQueueToken(
|
|
307
|
-
__param(9, Inject(getQueueToken(
|
|
308
|
-
__param(10, Inject(getQueueToken(
|
|
309
|
-
__param(11, Inject(getQueueToken(
|
|
310
|
-
__param(12, Inject(getQueueToken(
|
|
311
|
-
__param(13, Inject(getQueueToken(
|
|
312
|
-
__param(14, Inject(getQueueToken(
|
|
313
|
-
__param(15, Inject(getQueueToken(
|
|
314
|
-
__param(16, Inject(getQueueToken(
|
|
315
|
-
__param(17, Inject(getQueueToken(
|
|
316
|
-
__param(18, Inject(getQueueToken(
|
|
317
|
-
__param(19, Inject(getQueueToken(
|
|
318
|
-
__param(20, Inject(getQueueToken(
|
|
334
|
+
__param(5, Inject(KernelConfigService)),
|
|
335
|
+
__param(6, Inject(getQueueToken(RUN_QUEUE_NAME))),
|
|
336
|
+
__param(7, Inject(getQueueToken(SUBAGENT_RUN_QUEUE_NAME))),
|
|
337
|
+
__param(8, Inject(getQueueToken(CHANNEL_QUEUE_NAME))),
|
|
338
|
+
__param(9, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
|
|
339
|
+
__param(10, Inject(getQueueToken(TOOL_WATCH_QUEUE))),
|
|
340
|
+
__param(11, Inject(getQueueToken(PLUGIN_EFFECT_QUEUE))),
|
|
341
|
+
__param(12, Inject(getQueueToken(TITLE_QUEUE))),
|
|
342
|
+
__param(13, Inject(getQueueToken(PROMPT_SUGGESTION_QUEUE))),
|
|
343
|
+
__param(14, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
|
|
344
|
+
__param(15, Inject(getQueueToken(EVAL_QUEUE_NAME))),
|
|
345
|
+
__param(16, Inject(getQueueToken(LIFECYCLE_QUEUE))),
|
|
346
|
+
__param(17, Inject(getQueueToken(PUSH_QUEUE))),
|
|
347
|
+
__param(18, Inject(getQueueToken(CONNECTOR_TOOLS_QUEUE))),
|
|
348
|
+
__param(19, Inject(getQueueToken(TEMPLATE_CONNECTORS_QUEUE))),
|
|
349
|
+
__param(20, Inject(getQueueToken(SERVICE_EVENTS_QUEUE))),
|
|
350
|
+
__param(21, Inject(getQueueToken(EXTERNAL_CALLS_QUEUE)))
|
|
319
351
|
], AdminHealthService);
|
|
320
352
|
export { AdminHealthService };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Full-access audit in the affected orgs (extension permission model spec, "Revocation, audit and
|
|
4
|
+
* people"; plan task 1.4c). Full access entrusts code with a realm's privileges that org scope
|
|
5
|
+
* cannot confine, so every org it reaches sees its full-access events in its own audit log:
|
|
6
|
+
*
|
|
7
|
+
* | Action | When it is a full-access event | Affected orgs |
|
|
8
|
+
* | --- | --- | --- |
|
|
9
|
+
* | `extension.revision_granted` | the grant confers a full-access realm | the grant's |
|
|
10
|
+
* | `extension.full_access_continued` | always | the grant's |
|
|
11
|
+
* | `extension.grant_revoked` | the revoked grant had a full-access realm | the grant's |
|
|
12
|
+
* | `extension.full_access_retired` | always | the grant's |
|
|
13
|
+
* | `extension.browser_killed` | always (emitted by plan task 1.5b) | the grant's |
|
|
14
|
+
* | `extension.full_access_enabled` | an org enables an optional plugin whose revision has full access | that org |
|
|
15
|
+
*
|
|
16
|
+
* "The grant's" orgs are its named orgs for a named approval scope, otherwise the orgs where the
|
|
17
|
+
* plugin is on when the event is written. This is per plugin, not per revision: an org running
|
|
18
|
+
* another revision of the plugin also sees it, and a revocation written after the plugin was
|
|
19
|
+
* switched off everywhere reaches no org (none runs it any more; the deployment audit keeps it). The event is written once with no org (the deployment
|
|
20
|
+
* audit, the admin console's log) and copied into each affected org in the same transaction, so an
|
|
21
|
+
* org's log reads only its own rows (RLS and the org filter) and never sees another org's events.
|
|
22
|
+
*
|
|
23
|
+
* An org's copy carries an allowlisted detail only ({@link orgDetail}): the revision, realms,
|
|
24
|
+
* forcing and withdrawn permission keys, the grant state and a link to the deployment event. Never
|
|
25
|
+
* a secret value, session material, payload, free-text reason, review hash or publisher identity.
|
|
26
|
+
*
|
|
27
|
+
* The enablement event ({@link auditFullAccessEnabled}) is written in that org and in the deployment
|
|
28
|
+
* audit when an org turns on an optional plugin whose installed revision has a live grant with a
|
|
29
|
+
* full-access realm: the org's extension switch from off to on, or an org install of its catalog
|
|
30
|
+
* item (derived from `plugin.org_installed`; a platform scope change installing it says `platform`).
|
|
31
|
+
* Enablement adds no confirmation; this is the disclosure the spec asks for.
|
|
32
|
+
*/
|
|
33
|
+
/** The audit event the kernel writes (`identity/audit.ts`). */
|
|
34
|
+
export interface AuditEventInput {
|
|
35
|
+
actorAccountId?: string | null;
|
|
36
|
+
actorTokenId?: string;
|
|
37
|
+
orgId?: string;
|
|
38
|
+
action: string;
|
|
39
|
+
target?: string;
|
|
40
|
+
detail?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export declare const FULL_ACCESS_ENABLED_ACTION = "extension.full_access_enabled";
|
|
43
|
+
/** Plan task 1.5b's browser kill switch (a scoped, revision-bound event); its audit action. */
|
|
44
|
+
export declare const BROWSER_KILLED_ACTION = "extension.browser_killed";
|
|
45
|
+
/** Every action an org's log can receive from this registry (the web labels them for both logs). */
|
|
46
|
+
export declare const FULL_ACCESS_ORG_ACTIONS: readonly string[];
|
|
47
|
+
/**
|
|
48
|
+
* An org's copy of a full-access event: an allowlist of the revision, realms, permission keys and
|
|
49
|
+
* grant state, plus the deployment event it copies. Anything else in the deployment detail (a
|
|
50
|
+
* reason typed by the admin, hashes, publisher identity, any value) stays out.
|
|
51
|
+
*/
|
|
52
|
+
export declare function orgDetail(detail: Record<string, unknown>, deploymentEventId: string): Record<string, unknown>;
|
|
53
|
+
/**
|
|
54
|
+
* Writes one audit event and, for a full-access event, its copies in the affected orgs (or, for an
|
|
55
|
+
* org's enablement of a full-access plugin, the derived enablement event), all through `db` so
|
|
56
|
+
* they commit or roll back with the write they record.
|
|
57
|
+
*/
|
|
58
|
+
export declare function writeAuditEvent(db: KernelSchemaDb, e: AuditEventInput): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* The orgs a revision event affects: the named orgs of its grant's named approval scope, otherwise
|
|
61
|
+
* the live orgs where the plugin is on now. A detail without the grant's generation falls back to
|
|
62
|
+
* the plugin's orgs.
|
|
63
|
+
*/
|
|
64
|
+
export declare function affectedOrgs(db: KernelSchemaDb, plugin: string, detail: Record<string, unknown>): Promise<string[]>;
|
|
65
|
+
/**
|
|
66
|
+
* The full-access disclosure of an optional plugin turned on in an org: an org install of its
|
|
67
|
+
* catalog item (derived from `plugin.org_installed`), the org's extension switch turned from off to
|
|
68
|
+
* on (`OrgExtensionConfigs.put`), or a platform scope change installing it (`via: "platform"`).
|
|
69
|
+
* Written in that org and in the deployment audit when the plugin's installed revision has a live
|
|
70
|
+
* grant with a full-access realm; nothing otherwise, nor for a required plugin (on everywhere).
|
|
71
|
+
*/
|
|
72
|
+
export declare function auditFullAccessEnabled(db: KernelSchemaDb, e: {
|
|
73
|
+
orgId: string;
|
|
74
|
+
plugin: string;
|
|
75
|
+
via: "org" | "platform";
|
|
76
|
+
actorAccountId: string | null;
|
|
77
|
+
actorTokenId?: string;
|
|
78
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { alwaysOnExtensions, enabledExtensionsByOrg, isExtensionEnabled, } from "../extensions/enabled.js";
|
|
2
|
+
import { extensionSourcesQuery } from "../extensions/plugin-items.js";
|
|
3
|
+
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
4
|
+
export const FULL_ACCESS_ENABLED_ACTION = "extension.full_access_enabled";
|
|
5
|
+
/** Plan task 1.5b's browser kill switch (a scoped, revision-bound event); its audit action. */
|
|
6
|
+
export const BROWSER_KILLED_ACTION = "extension.browser_killed";
|
|
7
|
+
/** The revision event actions surfaced in the affected orgs, and when each is a full-access one. */
|
|
8
|
+
const REVISION_EVENTS = {
|
|
9
|
+
"extension.revision_granted": (d) => hasRealms(d.realms),
|
|
10
|
+
"extension.full_access_continued": () => true,
|
|
11
|
+
"extension.grant_revoked": (d) => hasRealms(d.realms),
|
|
12
|
+
"extension.full_access_retired": () => true,
|
|
13
|
+
[BROWSER_KILLED_ACTION]: () => true,
|
|
14
|
+
};
|
|
15
|
+
/** Every action an org's log can receive from this registry (the web labels them for both logs). */
|
|
16
|
+
export const FULL_ACCESS_ORG_ACTIONS = [
|
|
17
|
+
...Object.keys(REVISION_EVENTS),
|
|
18
|
+
FULL_ACCESS_ENABLED_ACTION,
|
|
19
|
+
];
|
|
20
|
+
const hasRealms = (realms) => typeof realms === "object" &&
|
|
21
|
+
realms !== null &&
|
|
22
|
+
!Array.isArray(realms) &&
|
|
23
|
+
Object.values(realms).some((keys) => Array.isArray(keys) && keys.length > 0);
|
|
24
|
+
const isStrings = (value) => Array.isArray(value) && value.every((v) => typeof v === "string");
|
|
25
|
+
/** The realms object, keeping only known realms with string forcing keys. */
|
|
26
|
+
function realmsOf(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
28
|
+
return undefined;
|
|
29
|
+
const out = {};
|
|
30
|
+
for (const realm of ["server", "browser", "device"]) {
|
|
31
|
+
const keys = value[realm];
|
|
32
|
+
if (isStrings(keys))
|
|
33
|
+
out[realm] = keys;
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function revisionOf(value) {
|
|
38
|
+
if (typeof value !== "object" || value === null)
|
|
39
|
+
return undefined;
|
|
40
|
+
const v = value;
|
|
41
|
+
const out = {};
|
|
42
|
+
for (const key of ["plugin", "version", "sha512"])
|
|
43
|
+
if (typeof v[key] === "string")
|
|
44
|
+
out[key] = v[key];
|
|
45
|
+
if (typeof v.generation === "number")
|
|
46
|
+
out.generation = v.generation;
|
|
47
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
48
|
+
}
|
|
49
|
+
const STRING_FIELDS = [
|
|
50
|
+
"plugin",
|
|
51
|
+
"version",
|
|
52
|
+
"sha512",
|
|
53
|
+
"state",
|
|
54
|
+
"previousState",
|
|
55
|
+
"realm",
|
|
56
|
+
"forcingKey",
|
|
57
|
+
];
|
|
58
|
+
const STRING_LIST_FIELDS = ["keys", "fullAccess", "remaining"];
|
|
59
|
+
/**
|
|
60
|
+
* An org's copy of a full-access event: an allowlist of the revision, realms, permission keys and
|
|
61
|
+
* grant state, plus the deployment event it copies. Anything else in the deployment detail (a
|
|
62
|
+
* reason typed by the admin, hashes, publisher identity, any value) stays out.
|
|
63
|
+
*/
|
|
64
|
+
export function orgDetail(detail, deploymentEventId) {
|
|
65
|
+
const out = { via: "platform", deploymentEventId };
|
|
66
|
+
for (const key of STRING_FIELDS)
|
|
67
|
+
if (typeof detail[key] === "string")
|
|
68
|
+
out[key] = detail[key];
|
|
69
|
+
for (const key of STRING_LIST_FIELDS)
|
|
70
|
+
if (isStrings(detail[key]))
|
|
71
|
+
out[key] = detail[key];
|
|
72
|
+
if (typeof detail.generation === "number")
|
|
73
|
+
out.generation = detail.generation;
|
|
74
|
+
if (typeof detail.realmRetired === "boolean")
|
|
75
|
+
out.realmRetired = detail.realmRetired;
|
|
76
|
+
const realms = realmsOf(detail.realms);
|
|
77
|
+
if (realms)
|
|
78
|
+
out.realms = realms;
|
|
79
|
+
const continuedFrom = revisionOf(detail.continuedFrom);
|
|
80
|
+
if (continuedFrom)
|
|
81
|
+
out.continuedFrom = continuedFrom;
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Inserts one audit row as given (no fan-out); returns its id. A deployment row (no org) is written
|
|
86
|
+
* in the platform scope. An org's row is written in the caller's scope (`caller`: every event an
|
|
87
|
+
* `audit()` call writes, so RLS still refuses a caller writing into another org), except the
|
|
88
|
+
* kernel's own copies of a deployment event (`copy`): each is computed by this registry from a
|
|
89
|
+
* deployment-level source event and written in its target org's own scope, so `rls_admits` admits
|
|
90
|
+
* it for exactly that org whatever scope the source event was raised in.
|
|
91
|
+
*/
|
|
92
|
+
async function insertRow(db, e, write) {
|
|
93
|
+
const query = db
|
|
94
|
+
.insertInto("audit_events")
|
|
95
|
+
.values({
|
|
96
|
+
actor_account_id: e.actorAccountId ?? null,
|
|
97
|
+
actor_token_id: e.actorTokenId ?? null,
|
|
98
|
+
org_id: e.orgId ?? null,
|
|
99
|
+
action: e.action,
|
|
100
|
+
target: e.target ?? null,
|
|
101
|
+
detail: JSON.stringify(e.detail ?? {}),
|
|
102
|
+
})
|
|
103
|
+
.returning("id");
|
|
104
|
+
const orgId = e.orgId;
|
|
105
|
+
const row = orgId === undefined
|
|
106
|
+
? // org-filter: deployment-wide audit events have no org and may originate inside an org call.
|
|
107
|
+
await asPlatform("Record an audit event without an org", () => query.executeTakeFirstOrThrow())
|
|
108
|
+
: write === "copy"
|
|
109
|
+
? await withOrgScope(orgId, () => query.executeTakeFirstOrThrow())
|
|
110
|
+
: await query.executeTakeFirstOrThrow();
|
|
111
|
+
return String(row.id);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Writes one audit event and, for a full-access event, its copies in the affected orgs (or, for an
|
|
115
|
+
* org's enablement of a full-access plugin, the derived enablement event), all through `db` so
|
|
116
|
+
* they commit or roll back with the write they record.
|
|
117
|
+
*/
|
|
118
|
+
export async function writeAuditEvent(db, e) {
|
|
119
|
+
const id = await insertRow(db, e, "caller");
|
|
120
|
+
const detail = e.detail ?? {};
|
|
121
|
+
const surfaced = REVISION_EVENTS[e.action];
|
|
122
|
+
if (surfaced && e.orgId === undefined && surfaced(detail)) {
|
|
123
|
+
await copyToAffectedOrgs(db, e, detail, id);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (e.orgId !== undefined)
|
|
127
|
+
await deriveEnablement(db, e, detail);
|
|
128
|
+
}
|
|
129
|
+
/** The deployment event's copies in every org it affects. */
|
|
130
|
+
async function copyToAffectedOrgs(db, e, detail, deploymentEventId) {
|
|
131
|
+
const plugin = typeof detail.plugin === "string" ? detail.plugin : e.target;
|
|
132
|
+
if (plugin === undefined)
|
|
133
|
+
return;
|
|
134
|
+
const orgs = await affectedOrgs(db, plugin, detail);
|
|
135
|
+
if (orgs.length === 0)
|
|
136
|
+
return;
|
|
137
|
+
const copy = orgDetail(detail, deploymentEventId);
|
|
138
|
+
// one insert per org, each in that org's own scope: a copy is admitted for exactly its org
|
|
139
|
+
for (const orgId of orgs) {
|
|
140
|
+
await insertRow(db, {
|
|
141
|
+
actorAccountId: e.actorAccountId ?? null,
|
|
142
|
+
...(e.actorTokenId !== undefined && { actorTokenId: e.actorTokenId }),
|
|
143
|
+
orgId,
|
|
144
|
+
action: e.action,
|
|
145
|
+
target: e.target ?? plugin,
|
|
146
|
+
detail: copy,
|
|
147
|
+
}, "copy");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The orgs a revision event affects: the named orgs of its grant's named approval scope, otherwise
|
|
152
|
+
* the live orgs where the plugin is on now. A detail without the grant's generation falls back to
|
|
153
|
+
* the plugin's orgs.
|
|
154
|
+
*/
|
|
155
|
+
export async function affectedOrgs(db, plugin, detail) {
|
|
156
|
+
// org-filter: deployment-wide: which orgs a platform grant reaches spans orgs.
|
|
157
|
+
return asPlatform("Find the orgs a full-access audit event affects", async () => {
|
|
158
|
+
const { version, sha512, generation } = detail;
|
|
159
|
+
if (typeof version === "string" &&
|
|
160
|
+
typeof sha512 === "string" &&
|
|
161
|
+
typeof generation === "number") {
|
|
162
|
+
const grant = await db
|
|
163
|
+
.selectFrom("extension_revision_grants")
|
|
164
|
+
.select("approval_scope")
|
|
165
|
+
.where("plugin", "=", plugin)
|
|
166
|
+
.where("version", "=", version)
|
|
167
|
+
.where("sha512", "=", sha512)
|
|
168
|
+
.where("generation", "=", generation)
|
|
169
|
+
.executeTakeFirst();
|
|
170
|
+
if (grant?.approval_scope === "named") {
|
|
171
|
+
const named = await db
|
|
172
|
+
.selectFrom("extension_revision_grant_orgs as g")
|
|
173
|
+
.innerJoin("orgs as o", "o.id", "g.org_id")
|
|
174
|
+
.select("g.org_id")
|
|
175
|
+
.where("g.plugin", "=", plugin)
|
|
176
|
+
.where("g.version", "=", version)
|
|
177
|
+
.where("g.sha512", "=", sha512)
|
|
178
|
+
.where("g.generation", "=", generation)
|
|
179
|
+
.where("o.deleted_at", "is", null)
|
|
180
|
+
.orderBy("g.org_id")
|
|
181
|
+
.execute();
|
|
182
|
+
return named.map((row) => row.org_id);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const enabled = await db
|
|
186
|
+
.selectFrom(enabledExtensionsByOrg(db, [plugin]).as("en"))
|
|
187
|
+
.select("en.org_id")
|
|
188
|
+
.orderBy("en.org_id")
|
|
189
|
+
.execute();
|
|
190
|
+
return enabled.map((row) => row.org_id);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/** The extensions of an org install's catalog item that are on in the org after the install. */
|
|
194
|
+
async function enabledByInstall(db, orgId, detail) {
|
|
195
|
+
if (typeof detail.itemId !== "string")
|
|
196
|
+
return [];
|
|
197
|
+
const itemId = detail.itemId;
|
|
198
|
+
// org-filter: deployment-wide: the extensions of a catalog item are deployment rows.
|
|
199
|
+
const rows = await asPlatform("Read the extensions of an installed catalog item", () => db
|
|
200
|
+
.selectFrom(extensionSourcesQuery(db).as("source"))
|
|
201
|
+
.select("source.plugin")
|
|
202
|
+
.where("source.item_id", "=", itemId)
|
|
203
|
+
.execute());
|
|
204
|
+
const out = [];
|
|
205
|
+
for (const plugin of new Set(rows.map((row) => row.plugin))) {
|
|
206
|
+
// an extension the org switched off stays off through an install: nothing was enabled
|
|
207
|
+
if (await isExtensionEnabled(db, orgId, plugin))
|
|
208
|
+
out.push(plugin);
|
|
209
|
+
}
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
/** An org install: the full-access disclosure of each extension it turned on. */
|
|
213
|
+
async function deriveEnablement(db, e, detail) {
|
|
214
|
+
const orgId = e.orgId;
|
|
215
|
+
if (orgId === undefined || e.action !== "plugin.org_installed")
|
|
216
|
+
return;
|
|
217
|
+
// a platform scope change installs into every org it reaches: a platform action, not the org's
|
|
218
|
+
const via = detail.via === "scope" ? "platform" : "org";
|
|
219
|
+
for (const plugin of await enabledByInstall(db, orgId, detail)) {
|
|
220
|
+
await auditFullAccessEnabled(db, {
|
|
221
|
+
orgId,
|
|
222
|
+
plugin,
|
|
223
|
+
via,
|
|
224
|
+
actorAccountId: e.actorAccountId ?? null,
|
|
225
|
+
...(e.actorTokenId !== undefined && { actorTokenId: e.actorTokenId }),
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The full-access disclosure of an optional plugin turned on in an org: an org install of its
|
|
231
|
+
* catalog item (derived from `plugin.org_installed`), the org's extension switch turned from off to
|
|
232
|
+
* on (`OrgExtensionConfigs.put`), or a platform scope change installing it (`via: "platform"`).
|
|
233
|
+
* Written in that org and in the deployment audit when the plugin's installed revision has a live
|
|
234
|
+
* grant with a full-access realm; nothing otherwise, nor for a required plugin (on everywhere).
|
|
235
|
+
*/
|
|
236
|
+
export async function auditFullAccessEnabled(db, e) {
|
|
237
|
+
const { orgId, plugin } = e;
|
|
238
|
+
// org-filter: deployment-wide: an install's revision and its grant are deployment rows.
|
|
239
|
+
const grant = await asPlatform("Read the full access of an installed revision", () => db
|
|
240
|
+
.selectFrom("extension_installs as i")
|
|
241
|
+
.innerJoin("extension_packages as p", "p.sha256", "i.sha256")
|
|
242
|
+
.innerJoin("extension_revision_grants as g", (join) => join
|
|
243
|
+
.onRef("g.plugin", "=", "i.name")
|
|
244
|
+
.onRef("g.version", "=", "i.version")
|
|
245
|
+
.onRef("g.sha512", "=", "p.sha512"))
|
|
246
|
+
.select(["i.version", "p.sha512", "g.generation", "g.realms", "i.required"])
|
|
247
|
+
.where("i.name", "=", plugin)
|
|
248
|
+
.where("g.state", "in", ["approved", "partially_revoked"])
|
|
249
|
+
.orderBy("g.generation", "desc")
|
|
250
|
+
.executeTakeFirst());
|
|
251
|
+
if (!grant || grant.required || grant.sha512 === null || !hasRealms(grant.realms))
|
|
252
|
+
return;
|
|
253
|
+
// an always-on plugin (required, or a builtin platform plugin) is on everywhere: no org enables it
|
|
254
|
+
// org-filter: deployment-wide: the always-on set is deployment state.
|
|
255
|
+
const alwaysOn = await asPlatform("Read the always-on extensions", () => alwaysOnExtensions(db));
|
|
256
|
+
if (alwaysOn.has(plugin))
|
|
257
|
+
return;
|
|
258
|
+
const revision = {
|
|
259
|
+
plugin,
|
|
260
|
+
version: grant.version,
|
|
261
|
+
sha512: grant.sha512,
|
|
262
|
+
generation: grant.generation,
|
|
263
|
+
realms: realmsOf(grant.realms) ?? {},
|
|
264
|
+
};
|
|
265
|
+
const actor = {
|
|
266
|
+
actorAccountId: e.actorAccountId,
|
|
267
|
+
...(e.actorTokenId !== undefined && { actorTokenId: e.actorTokenId }),
|
|
268
|
+
};
|
|
269
|
+
const deploymentId = await insertRow(db, {
|
|
270
|
+
...actor,
|
|
271
|
+
action: FULL_ACCESS_ENABLED_ACTION,
|
|
272
|
+
target: plugin,
|
|
273
|
+
detail: { ...revision, orgId, via: e.via },
|
|
274
|
+
}, "caller");
|
|
275
|
+
await insertRow(db, {
|
|
276
|
+
...actor,
|
|
277
|
+
orgId,
|
|
278
|
+
action: FULL_ACCESS_ENABLED_ACTION,
|
|
279
|
+
target: plugin,
|
|
280
|
+
// `via: "org"` for the org's own action; a copy of a platform action says `platform`
|
|
281
|
+
detail: { ...orgDetail(revision, deploymentId), via: e.via },
|
|
282
|
+
}, "copy");
|
|
283
|
+
}
|
|
@@ -64,6 +64,7 @@ export interface AutomationAttention {
|
|
|
64
64
|
* `missing_grants` only: tool keys the latest run was refused and the task has no grant for now,
|
|
65
65
|
* `connection:<slug>` (connect that connector), or `network:<host>` (a domain the run was
|
|
66
66
|
* refused: the task has no grant for it, or the org's network allowlist no longer admits it).
|
|
67
|
+
* Never a `review:<class>` entry: a call the command review held shows on the task run only.
|
|
67
68
|
*/
|
|
68
69
|
missing: string[];
|
|
69
70
|
/** The subset of `missing` the creator cannot pre-approve (the tool needs a higher role). */
|
|
@@ -46,6 +46,7 @@ import { oweAutomationFire, oweAutomationSettleUnfired } from "./job-ids.js";
|
|
|
46
46
|
import { pauseTaskIn } from "./pause.js";
|
|
47
47
|
import { jitterForGap, minGapMinutes, nextTick, validateTrigger } from "./schedule-math.js";
|
|
48
48
|
import { AutomationStore, runOrderMoment } from "./store.js";
|
|
49
|
+
import { isReviewHoldKey } from "./unattended.js";
|
|
49
50
|
export { grantRefusal, grantRefusalOf, networkGrantRefusal, };
|
|
50
51
|
/** The refusal of a network grant written outside a person's web session. */
|
|
51
52
|
const NETWORK_GRANT_NEEDS_PERSON = "Network domains are approved on the task page by a person.";
|
|
@@ -854,7 +855,8 @@ let AutomationsService = class AutomationsService {
|
|
|
854
855
|
});
|
|
855
856
|
}
|
|
856
857
|
const have = granted.get(task.id);
|
|
857
|
-
|
|
858
|
+
// a call the command review held shows on the task run only: nothing here to approve
|
|
859
|
+
const refused = run.missing_grants.filter((k) => !isReviewHoldKey(k));
|
|
858
860
|
// a refused tool granted since drops out, unless its grant no longer matches the tool's
|
|
859
861
|
// definition (stale: it would be refused again); a refused domain granted since drops out
|
|
860
862
|
// while the org's network allowlist admits it (network ask-to-allow spec §8.3)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { scanStep, tickerOf, ticksIn } from "./schedule-math.js";
|
|
2
|
+
import { isReviewHoldKey } from "./unattended.js";
|
|
2
3
|
/**
|
|
3
4
|
* The automation calendar (spec 2026-11-12-scheduled-tasks-calendar-design.md §5): recorded
|
|
4
5
|
* runs and planned occurrences between two instants, dense task-days collapsed, cut at a whole
|
|
@@ -332,7 +333,8 @@ function runItem(r, own) {
|
|
|
332
333
|
manual: r.manual,
|
|
333
334
|
conversationId: own ? r.conversationId : null,
|
|
334
335
|
error: own ? r.error : null,
|
|
335
|
-
|
|
336
|
+
// the refusals a grant can fix: a call the command review held is listed on the task page
|
|
337
|
+
missingGrants: own ? r.missingGrants.filter((k) => !isReviewHoldKey(k)).length : null,
|
|
336
338
|
};
|
|
337
339
|
}
|
|
338
340
|
function summarize(taskId, day, list) {
|