@capybara-hq/kernel 0.1.0-rc.60 → 0.1.0-rc.61
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/admin.module.js +3 -0
- package/dist/admin/extensions.controller.d.ts +32 -1
- package/dist/admin/extensions.controller.js +72 -3
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.js +12 -0
- package/dist/conversations/event-log.d.ts +12 -3
- package/dist/conversations/event-log.js +17 -5
- package/dist/ctx/secrets.d.ts +10 -5
- package/dist/ctx/secrets.js +16 -5
- package/dist/db/kernel-schema.d.ts +34 -2
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +7 -0
- package/dist/extensions/config-hash.d.ts +2 -0
- package/dist/extensions/config-hash.js +1 -1
- package/dist/extensions/guide-places.d.ts +5 -1
- package/dist/extensions/guide-places.js +9 -2
- package/dist/extensions/permission-view.d.ts +6 -4
- package/dist/extensions/permission-view.js +6 -3
- package/dist/extensions/plugin-guides.d.ts +20 -0
- package/dist/extensions/plugin-guides.js +49 -1
- package/dist/extensions/registry.js +1 -0
- package/dist/http/api.module.js +7 -0
- package/dist/http/meta.controller.d.ts +7 -1
- package/dist/http/meta.controller.js +14 -3
- package/dist/identity/accounts.js +5 -0
- package/dist/identity/sessions.d.ts +7 -0
- package/dist/identity/sessions.js +26 -4
- package/dist/inbox/platform-inbox.service.d.ts +21 -11
- package/dist/inbox/platform-inbox.service.js +27 -12
- package/dist/inbox/platform-notices.d.ts +15 -1
- package/dist/inbox/platform-notices.js +20 -0
- package/dist/infra/config/kernel-config.service.js +2 -0
- package/dist/infra/outbox/registry.d.ts +36 -0
- package/dist/infra/outbox/registry.js +30 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/orgs/offboarding.js +3 -0
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +5 -1
- package/dist/platform/ops/extensions-admin.ops.js +97 -2
- package/dist/platform/ops/inbox.ops.d.ts +1 -1
- package/dist/platform/ops/inbox.ops.js +17 -7
- package/dist/platform/ops/platform.ops.d.ts +4 -2
- package/dist/platform/ops/platform.ops.js +55 -3
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/push/delivery.d.ts +88 -0
- package/dist/push/delivery.js +269 -0
- package/dist/push/fanout.d.ts +29 -0
- package/dist/push/fanout.js +95 -0
- package/dist/push/jobs.d.ts +43 -0
- package/dist/push/jobs.js +19 -0
- package/dist/push/preferences.service.d.ts +18 -0
- package/dist/push/preferences.service.js +82 -0
- package/dist/push/provider-host.d.ts +34 -0
- package/dist/push/provider-host.js +94 -0
- package/dist/push/push-owed.d.ts +33 -0
- package/dist/push/push-owed.js +93 -0
- package/dist/push/push-processor.d.ts +40 -0
- package/dist/push/push-processor.js +114 -0
- package/dist/push/push.controller.d.ts +28 -0
- package/dist/push/push.controller.js +92 -0
- package/dist/push/push.module.d.ts +6 -0
- package/dist/push/push.module.js +29 -0
- package/dist/push/push.schemas.d.ts +88 -0
- package/dist/push/push.schemas.js +53 -0
- package/dist/push/recipients.d.ts +29 -0
- package/dist/push/recipients.js +263 -0
- package/dist/push/registration-cleanup.d.ts +9 -0
- package/dist/push/registration-cleanup.js +16 -0
- package/dist/push/registrations.service.d.ts +55 -0
- package/dist/push/registrations.service.js +254 -0
- package/dist/push/stale.job.d.ts +25 -0
- package/dist/push/stale.job.js +76 -0
- package/dist/push/texts.d.ts +31 -0
- package/dist/push/texts.js +46 -0
- package/dist/push/token-store.d.ts +31 -0
- package/dist/push/token-store.js +52 -0
- package/dist/push/triggers.d.ts +19 -0
- package/dist/push/triggers.js +30 -0
- package/dist/roles/worker-role.d.ts +7 -4
- package/dist/roles/worker-role.js +12 -5
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +4 -1
- package/dist/schedules/run-tracker.d.ts +10 -2
- package/dist/schedules/run-tracker.js +18 -4
- package/dist/setup/setup-checks.schemas.d.ts +29 -0
- package/dist/setup/setup-checks.schemas.js +32 -0
- package/dist/setup/setup-checks.service.d.ts +36 -3
- package/dist/setup/setup-checks.service.js +137 -29
- package/package.json +4 -4
- package/src/migrations/0172_push.sql +40 -0
- package/src/migrations/0173_push_auth_notice.sql +10 -0
|
@@ -20,6 +20,7 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
20
20
|
import { LockedIntervalScheduler } from "../infra/schedule/locked-interval.js";
|
|
21
21
|
import { ScheduledRuns } from "../infra/schedule/scheduled-runs.js";
|
|
22
22
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
23
|
+
import { PushProcessor } from "../push/push-processor.js";
|
|
23
24
|
import { MaintenanceProcessor } from "../runtime/maintenance.js";
|
|
24
25
|
import { PromptSuggestionProcessor, RunsProcessor, SubagentRunsProcessor, TitleProcessor, UsageReportProcessor, } from "../runtime/run-processors.js";
|
|
25
26
|
import { RunWorker } from "../runtime/run-worker.js";
|
|
@@ -28,7 +29,7 @@ import { UsageReporter } from "../runtime/usage-report.js";
|
|
|
28
29
|
* The worker role's parts, driven by `KernelLifecycle` at fixed points of its start order and stop
|
|
29
30
|
* phases (so they stay ordered after the extension load and before the extension host closes): the
|
|
30
31
|
* queue consumers (runs, sub-agent runs, evals, maintenance, the plugin scope sync, lifecycle
|
|
31
|
-
* hook deliveries, channel deliveries, `usage.report`, titles, prompt suggestions) and the schedulers of the `@LockedCron` / `@LockedInterval` jobs. Provided only by
|
|
32
|
+
* hook deliveries, push deliveries, channel deliveries, `usage.report`, titles, prompt suggestions) and the schedulers of the `@LockedCron` / `@LockedInterval` jobs. Provided only by
|
|
32
33
|
* `WorkerModule`, so a process without the worker role has none of them.
|
|
33
34
|
*/
|
|
34
35
|
let WorkerRole = class WorkerRole {
|
|
@@ -51,13 +52,14 @@ let WorkerRole = class WorkerRole {
|
|
|
51
52
|
maintenanceProcessor;
|
|
52
53
|
scopeProcessor;
|
|
53
54
|
lifecycleProcessor;
|
|
55
|
+
pushProcessor;
|
|
54
56
|
/** The startup config (the roles). */
|
|
55
57
|
config;
|
|
56
58
|
/** The run worker was started: the runs phase drains it. */
|
|
57
59
|
runsStarted = false;
|
|
58
60
|
/** The eval worker was started: the runs phase drains it. */
|
|
59
61
|
evalsStarted = false;
|
|
60
|
-
constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor) {
|
|
62
|
+
constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor, pushProcessor) {
|
|
61
63
|
this.log = log;
|
|
62
64
|
this.intervals = intervals;
|
|
63
65
|
this.scheduledRuns = scheduledRuns;
|
|
@@ -77,6 +79,7 @@ let WorkerRole = class WorkerRole {
|
|
|
77
79
|
this.maintenanceProcessor = maintenanceProcessor;
|
|
78
80
|
this.scopeProcessor = scopeProcessor;
|
|
79
81
|
this.lifecycleProcessor = lifecycleProcessor;
|
|
82
|
+
this.pushProcessor = pushProcessor;
|
|
80
83
|
this.config = config.get();
|
|
81
84
|
}
|
|
82
85
|
/**
|
|
@@ -95,6 +98,7 @@ let WorkerRole = class WorkerRole {
|
|
|
95
98
|
this.maintenanceProcessor.start();
|
|
96
99
|
this.scopeProcessor.start();
|
|
97
100
|
this.lifecycleProcessor.start();
|
|
101
|
+
this.pushProcessor.start();
|
|
98
102
|
this.channelOutbound.startWorker(this.channelsProcessor.worker);
|
|
99
103
|
this.usageReport.startWorker(this.usageProcessor.worker);
|
|
100
104
|
this.titles.startWorker(this.titleProcessor.worker);
|
|
@@ -122,14 +126,16 @@ let WorkerRole = class WorkerRole {
|
|
|
122
126
|
return this.evalsStarted ? this.evalWorker.close(budgetMs) : undefined;
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
|
-
* Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs)
|
|
126
|
-
*
|
|
129
|
+
* Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs), the
|
|
130
|
+
* lifecycle hook deliveries' (calls in flight are aborted and retried) and the push deliveries'
|
|
131
|
+
* (sends in flight finish, each bounded by the send time limit).
|
|
127
132
|
*/
|
|
128
133
|
async closeMaintenance() {
|
|
129
134
|
await Promise.all([
|
|
130
135
|
this.maintenanceProcessor.worker.close(),
|
|
131
136
|
this.scopeProcessor.close(),
|
|
132
137
|
this.lifecycleProcessor.close(),
|
|
138
|
+
this.pushProcessor.close(),
|
|
133
139
|
]);
|
|
134
140
|
}
|
|
135
141
|
};
|
|
@@ -154,6 +160,7 @@ WorkerRole = __decorate([
|
|
|
154
160
|
__param(16, Inject(EvalsProcessor)),
|
|
155
161
|
__param(17, Inject(MaintenanceProcessor)),
|
|
156
162
|
__param(18, Inject(PluginScopeSyncProcessor)),
|
|
157
|
-
__param(19, Inject(LifecycleHooksProcessor))
|
|
163
|
+
__param(19, Inject(LifecycleHooksProcessor)),
|
|
164
|
+
__param(20, Inject(PushProcessor))
|
|
158
165
|
], WorkerRole);
|
|
159
166
|
export { WorkerRole };
|
|
@@ -5,7 +5,7 @@ import type { KernelConfig } from "../config/schema.js";
|
|
|
5
5
|
* `worker`: the cron scheduler and the `@LockedInterval` scheduler (`KernelScheduleModule`, the one
|
|
6
6
|
* place `ScheduleModule.forRoot` is imported), every fixed-period job (`@LockedCron` /
|
|
7
7
|
* `@LockedInterval`, each once per tick across replicas), every queue consumer (`@Processor`: runs,
|
|
8
|
-
* sub-agent runs, `usage.report`, titles, evals, maintenance, channel deliveries, the plugin scope sync) and
|
|
8
|
+
* sub-agent runs, `usage.report`, titles, evals, maintenance, channel deliveries, the plugin scope sync, push deliveries) and
|
|
9
9
|
* {@link WorkerRole}, which `KernelLifecycle` drives. A process without the worker role runs no cron
|
|
10
10
|
* and no BullMQ worker (the queues' producers exist on every role).
|
|
11
11
|
*/
|
|
@@ -34,6 +34,7 @@ import { KernelScheduleModule } from "../infra/schedule/schedule.module.js";
|
|
|
34
34
|
import { DirectoryScanJob } from "../orgs/directory-sync.js";
|
|
35
35
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
36
36
|
import { OrgsModule } from "../orgs/orgs.module.js";
|
|
37
|
+
import { PushWorkersModule } from "../push/push-processor.js";
|
|
37
38
|
import { MaintenanceModule } from "../runtime/maintenance.js";
|
|
38
39
|
import { RunJobsModule } from "../runtime/run-jobs.js";
|
|
39
40
|
import { RunOrphanCheck } from "../runtime/run-orphan-check.job.js";
|
|
@@ -55,7 +56,7 @@ import { WorkerRole } from "./worker-role.js";
|
|
|
55
56
|
* `worker`: the cron scheduler and the `@LockedInterval` scheduler (`KernelScheduleModule`, the one
|
|
56
57
|
* place `ScheduleModule.forRoot` is imported), every fixed-period job (`@LockedCron` /
|
|
57
58
|
* `@LockedInterval`, each once per tick across replicas), every queue consumer (`@Processor`: runs,
|
|
58
|
-
* sub-agent runs, `usage.report`, titles, evals, maintenance, channel deliveries, the plugin scope sync) and
|
|
59
|
+
* sub-agent runs, `usage.report`, titles, evals, maintenance, channel deliveries, the plugin scope sync, push deliveries) and
|
|
59
60
|
* {@link WorkerRole}, which `KernelLifecycle` drives. A process without the worker role runs no cron
|
|
60
61
|
* and no BullMQ worker (the queues' producers exist on every role).
|
|
61
62
|
*/
|
|
@@ -75,6 +76,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
75
76
|
MaintenanceModule,
|
|
76
77
|
PluginScopeWorkersModule,
|
|
77
78
|
LifecycleHookWorkersModule,
|
|
79
|
+
// push deliveries (`cap-push-deliver`) and the daily stale registration prune
|
|
80
|
+
PushWorkersModule,
|
|
78
81
|
// the domains the fixed-period jobs call
|
|
79
82
|
RuntimeModule,
|
|
80
83
|
RunJobsModule,
|
|
@@ -2,6 +2,7 @@ import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
|
2
2
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
+
import { PushOwed } from "../push/push-owed.js";
|
|
5
6
|
import type { TaskRun } from "./types.js";
|
|
6
7
|
/** How a kernel run ended (`runs.status` once terminal). */
|
|
7
8
|
export type RunOutcome = "completed" | "failed" | "aborted";
|
|
@@ -24,7 +25,11 @@ export declare class ScheduledTaskRunTracker {
|
|
|
24
25
|
private readonly kdb;
|
|
25
26
|
readonly txHost: TransactionHost;
|
|
26
27
|
private readonly config;
|
|
27
|
-
|
|
28
|
+
/** Owes the task owner's push (`schedules`) with every settle. */
|
|
29
|
+
private readonly push;
|
|
30
|
+
constructor(kdb: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">,
|
|
31
|
+
/** Owes the task owner's push (`schedules`) with every settle. */
|
|
32
|
+
push: Pick<PushOwed, "oweScheduleRun">);
|
|
28
33
|
private get db();
|
|
29
34
|
/**
|
|
30
35
|
* The kernel run `runId` ended with `outcome`: the task run it was started for (the run its
|
|
@@ -49,7 +54,10 @@ export declare class ScheduledTaskRunTracker {
|
|
|
49
54
|
* excepted. In the caller's transaction, which holds the task row.
|
|
50
55
|
*/
|
|
51
56
|
failStartIn(taskRunId: string, error: string): Promise<void>;
|
|
52
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Writes the task run's end, owes the owner's push (trial runs too) and writes the task's failure
|
|
59
|
+
* count (non-trial runs).
|
|
60
|
+
*/
|
|
53
61
|
private settle;
|
|
54
62
|
}
|
|
55
63
|
/**
|
|
@@ -13,6 +13,7 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
14
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
15
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
16
|
+
import { PushOwed, PushOwedModule } from "../push/push-owed.js";
|
|
16
17
|
import { readScheduleSettings } from "./effective-settings.js";
|
|
17
18
|
import { pauseTaskIn } from "./pause.js";
|
|
18
19
|
/** The kernel run statuses that are terminal (`runtime/run-finish.ts`, not imported: a cycle). */
|
|
@@ -36,10 +37,14 @@ let ScheduledTaskRunTracker = class ScheduledTaskRunTracker {
|
|
|
36
37
|
kdb;
|
|
37
38
|
txHost;
|
|
38
39
|
config;
|
|
39
|
-
|
|
40
|
+
push;
|
|
41
|
+
constructor(kdb, txHost, config,
|
|
42
|
+
/** Owes the task owner's push (`schedules`) with every settle. */
|
|
43
|
+
push) {
|
|
40
44
|
this.kdb = kdb;
|
|
41
45
|
this.txHost = txHost;
|
|
42
46
|
this.config = config;
|
|
47
|
+
this.push = push;
|
|
43
48
|
}
|
|
44
49
|
get db() {
|
|
45
50
|
return this.kdb.db;
|
|
@@ -209,7 +214,10 @@ let ScheduledTaskRunTracker = class ScheduledTaskRunTracker {
|
|
|
209
214
|
return;
|
|
210
215
|
await this.settle(tr, "failed", error);
|
|
211
216
|
}
|
|
212
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Writes the task run's end, owes the owner's push (trial runs too) and writes the task's failure
|
|
219
|
+
* count (non-trial runs).
|
|
220
|
+
*/
|
|
213
221
|
async settle(tr, outcome, error) {
|
|
214
222
|
const t = this.db;
|
|
215
223
|
const failed = outcome === "failed";
|
|
@@ -221,6 +229,7 @@ let ScheduledTaskRunTracker = class ScheduledTaskRunTracker {
|
|
|
221
229
|
})
|
|
222
230
|
.where("id", "=", tr.id)
|
|
223
231
|
.execute();
|
|
232
|
+
await this.push.oweScheduleRun(tr.id, tr.org_id);
|
|
224
233
|
if (tr.trial)
|
|
225
234
|
return;
|
|
226
235
|
if (!failed) {
|
|
@@ -260,7 +269,8 @@ ScheduledTaskRunTracker = __decorate([
|
|
|
260
269
|
Injectable(),
|
|
261
270
|
__param(0, Inject(KernelDb)),
|
|
262
271
|
__param(1, Inject(TransactionHost)),
|
|
263
|
-
__param(2, Inject(KernelConfigService))
|
|
272
|
+
__param(2, Inject(KernelConfigService)),
|
|
273
|
+
__param(3, Inject(PushOwed))
|
|
264
274
|
], ScheduledTaskRunTracker);
|
|
265
275
|
export { ScheduledTaskRunTracker };
|
|
266
276
|
/**
|
|
@@ -316,6 +326,10 @@ export async function lockTaskRow(t, taskId) {
|
|
|
316
326
|
let ScheduledTaskTrackerModule = class ScheduledTaskTrackerModule {
|
|
317
327
|
};
|
|
318
328
|
ScheduledTaskTrackerModule = __decorate([
|
|
319
|
-
Module({
|
|
329
|
+
Module({
|
|
330
|
+
imports: [PushOwedModule],
|
|
331
|
+
providers: [ScheduledTaskRunTracker],
|
|
332
|
+
exports: [ScheduledTaskRunTracker],
|
|
333
|
+
})
|
|
320
334
|
], ScheduledTaskTrackerModule);
|
|
321
335
|
export { ScheduledTaskTrackerModule };
|
|
@@ -35,4 +35,33 @@ export declare const SetupCheckRunBody: z.ZodObject<{
|
|
|
35
35
|
connectorId: z.ZodOptional<z.ZodString>;
|
|
36
36
|
force: z.ZodOptional<z.ZodBoolean>;
|
|
37
37
|
}, z.core.$strict>;
|
|
38
|
+
/** `:name` / `:guideId` of the deployment guide routes (`extension-deployment`, super admins). */
|
|
39
|
+
export declare const DeploymentGuidePathParams: z.ZodObject<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
guideId: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/** `:name` / `:guideId` / `:checkId` of the deployment check run route. */
|
|
44
|
+
export declare const DeploymentCheckPathParams: z.ZodObject<{
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
guideId: z.ZodString;
|
|
47
|
+
checkId: z.ZodString;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
/** `:name` of `GET /admin/extensions/:name/guides`. */
|
|
50
|
+
export declare const DeploymentGuidesPathParams: z.ZodObject<{
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
/** `GET /admin/extensions/:name/guides`: the language to render in (zh falls back to en). */
|
|
54
|
+
export declare const DeploymentGuidesQuery: z.ZodObject<{
|
|
55
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
en: "en";
|
|
57
|
+
zh: "zh";
|
|
58
|
+
}>>;
|
|
59
|
+
}, z.core.$strict>;
|
|
60
|
+
/**
|
|
61
|
+
* `POST /admin/extensions/:name/guides/:guideId/checks/:checkId/run`: runs the check unless a fresh
|
|
62
|
+
* cached result exists; `force` reruns it (at most once per 10 seconds per check).
|
|
63
|
+
*/
|
|
64
|
+
export declare const DeploymentCheckRunBody: z.ZodObject<{
|
|
65
|
+
force: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strict>;
|
|
38
67
|
export declare const SETUP_CHECK_ROUTES: readonly RouteSchemas[];
|
|
@@ -29,7 +29,39 @@ export const SetupChecksQuery = z.object(GuideSelection).strict();
|
|
|
29
29
|
export const SetupCheckRunBody = z
|
|
30
30
|
.object({ ...GuideSelection, force: z.boolean().optional() })
|
|
31
31
|
.strict();
|
|
32
|
+
/** `:name` / `:guideId` of the deployment guide routes (`extension-deployment`, super admins). */
|
|
33
|
+
export const DeploymentGuidePathParams = z.object({
|
|
34
|
+
name: z.string().min(1).max(64),
|
|
35
|
+
guideId: z.string().min(1).max(64),
|
|
36
|
+
});
|
|
37
|
+
/** `:name` / `:guideId` / `:checkId` of the deployment check run route. */
|
|
38
|
+
export const DeploymentCheckPathParams = DeploymentGuidePathParams.extend({
|
|
39
|
+
checkId: z.string().min(1).max(64),
|
|
40
|
+
});
|
|
41
|
+
/** `:name` of `GET /admin/extensions/:name/guides`. */
|
|
42
|
+
export const DeploymentGuidesPathParams = DeploymentGuidePathParams.pick({ name: true });
|
|
43
|
+
/** `GET /admin/extensions/:name/guides`: the language to render in (zh falls back to en). */
|
|
44
|
+
export const DeploymentGuidesQuery = z.object({ locale: z.enum(["en", "zh"]).optional() }).strict();
|
|
45
|
+
/**
|
|
46
|
+
* `POST /admin/extensions/:name/guides/:guideId/checks/:checkId/run`: runs the check unless a fresh
|
|
47
|
+
* cached result exists; `force` reruns it (at most once per 10 seconds per check).
|
|
48
|
+
*/
|
|
49
|
+
export const DeploymentCheckRunBody = z.object({ force: z.boolean().optional() }).strict();
|
|
32
50
|
export const SETUP_CHECK_ROUTES = [
|
|
51
|
+
{
|
|
52
|
+
route: "GET /api/v1/admin/extensions/:name/guides",
|
|
53
|
+
params: DeploymentGuidesPathParams,
|
|
54
|
+
query: DeploymentGuidesQuery,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
route: "GET /api/v1/admin/extensions/:name/guides/:guideId/checks",
|
|
58
|
+
params: DeploymentGuidePathParams,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
route: "POST /api/v1/admin/extensions/:name/guides/:guideId/checks/:checkId/run",
|
|
62
|
+
params: DeploymentCheckPathParams,
|
|
63
|
+
body: DeploymentCheckRunBody,
|
|
64
|
+
},
|
|
33
65
|
{
|
|
34
66
|
route: "GET /api/v1/orgs/:orgId/catalog/:itemId/guides/:guideId/checks",
|
|
35
67
|
params: SetupGuidePathParams,
|
|
@@ -62,13 +62,31 @@ export declare class SetupChecksService {
|
|
|
62
62
|
private readonly credentials;
|
|
63
63
|
private readonly log;
|
|
64
64
|
private readonly timeoutMs;
|
|
65
|
-
constructor(db: KernelDb, redis: Pick<Redis, "get" | "set" | "pttl" | "mget" | "exists" | "eval">, locks: Pick<LockService, "lease" | "releaseIf" | "takeSlot" | "releaseSlot">, keyring: Keyring, guides: Pick<PluginGuides, "render">, registry: SetupCheckRegistry, extensions: Pick<ExtensionRegistry, "current">, effective: Pick<EffectiveConfigs, "get">, orgConfigs: Pick<OrgExtensionConfigs, "get">, channels: Pick<ChannelConnections, "checkRevision" | "checkSecrets" | "runtime">, credentials: Pick<Credentials, "checkRevision" | "checkMaterial">, log: Pick<KernelLogger, "warn">, timeoutMs?: number);
|
|
65
|
+
constructor(db: KernelDb, redis: Pick<Redis, "get" | "set" | "pttl" | "mget" | "exists" | "eval">, locks: Pick<LockService, "lease" | "releaseIf" | "takeSlot" | "releaseSlot">, keyring: Keyring, guides: Pick<PluginGuides, "render" | "renderForDeployment">, registry: SetupCheckRegistry, extensions: Pick<ExtensionRegistry, "current">, effective: Pick<EffectiveConfigs, "get">, orgConfigs: Pick<OrgExtensionConfigs, "get">, channels: Pick<ChannelConnections, "checkRevision" | "checkSecrets" | "runtime">, credentials: Pick<Credentials, "checkRevision" | "checkMaterial">, log: Pick<KernelLogger, "warn">, timeoutMs?: number);
|
|
66
66
|
/**
|
|
67
67
|
* The cached state of every check of the rendered guide (`GET …/checks`), by check id; nothing
|
|
68
68
|
* runs. `not_run` without a fresh result for the current input fingerprint; `running` while a
|
|
69
69
|
* run holds the lock. Redis down: every row `unknown` ("temporarily unavailable").
|
|
70
70
|
*/
|
|
71
71
|
states(caller: CheckCaller, itemId: string, guideId: string, q: CheckSelection): Promise<Record<string, SetupCheckState>>;
|
|
72
|
+
/**
|
|
73
|
+
* The cached state of every check of an extension's `extension-deployment` guide (`GET
|
|
74
|
+
* /admin/extensions/:name/guides/:guideId/checks`, super admins: the route's guard); nothing
|
|
75
|
+
* runs. Cached for the deployment, shared by every super admin.
|
|
76
|
+
*/
|
|
77
|
+
deploymentStates(accountId: string, plugin: string, guideId: string): Promise<Record<string, SetupCheckState>>;
|
|
78
|
+
/**
|
|
79
|
+
* Runs one check of an extension's `extension-deployment` guide (`POST
|
|
80
|
+
* /admin/extensions/:name/guides/:guideId/checks/:checkId/run`, super admins: the route's
|
|
81
|
+
* guard) with the extension's platform deployment config, `orgId: null`. The cache, single
|
|
82
|
+
* flight, cooldown and concurrency cap are the org places', keyed by the deployment; the
|
|
83
|
+
* per-account limit is shared with every other run. A kernel check (`capybara:*`) does not apply
|
|
84
|
+
* here.
|
|
85
|
+
*/
|
|
86
|
+
deploymentRun(accountId: string, plugin: string, guideId: string, checkId: string, body: {
|
|
87
|
+
force?: boolean | undefined;
|
|
88
|
+
}): Promise<SetupCheckState>;
|
|
89
|
+
private statesOf;
|
|
72
90
|
/**
|
|
73
91
|
* Runs one check (`POST …/checks/:checkId/run`) unless a fresh result for the current input
|
|
74
92
|
* fingerprint is cached (or `force`, refused within 10 s of the last run: the cached state with
|
|
@@ -78,6 +96,7 @@ export declare class SetupChecksService {
|
|
|
78
96
|
run(caller: CheckCaller, itemId: string, guideId: string, checkId: string, body: CheckSelection & {
|
|
79
97
|
force?: boolean | undefined;
|
|
80
98
|
}): Promise<SetupCheckState>;
|
|
99
|
+
private runPrepared;
|
|
81
100
|
/**
|
|
82
101
|
* Authorization and the guide (the guide route's rules, `PluginGuides.render`: catalog
|
|
83
102
|
* visibility, then the place and audience action, then the target), then the check's presence
|
|
@@ -85,6 +104,18 @@ export declare class SetupChecksService {
|
|
|
85
104
|
* target (400: checks need a saved connection or connector).
|
|
86
105
|
*/
|
|
87
106
|
private prepare;
|
|
107
|
+
/**
|
|
108
|
+
* The deployment guide (`PluginGuides.renderForDeployment`: the extension's catalog item has an
|
|
109
|
+
* `extension-deployment` guide with that id, else 404), then the check's presence in it (404
|
|
110
|
+
* `catalog.check_not_found`). The caller is a super admin (the route's and the operation's
|
|
111
|
+
* guard); the target is the plugin's own deployment.
|
|
112
|
+
*/
|
|
113
|
+
private prepareDeployment;
|
|
114
|
+
/**
|
|
115
|
+
* A deployment check runs only where its extension runs on this replica (so its deployment
|
|
116
|
+
* config is valid and loaded): that config, as the extension's `ctx.config` holds it.
|
|
117
|
+
*/
|
|
118
|
+
private deploymentGate;
|
|
88
119
|
/**
|
|
89
120
|
* A plugin check runs only where its extension runs on this replica, is enabled in the org and
|
|
90
121
|
* has a valid effective config there (nothing is called otherwise): the effective config, or the
|
|
@@ -95,7 +126,8 @@ export declare class SetupChecksService {
|
|
|
95
126
|
private keys;
|
|
96
127
|
/**
|
|
97
128
|
* The input revision of a prepared target (spec §10.4): the target's and its credentials'
|
|
98
|
-
* `updated_at`, the org's extension config and copy revisions; never a value.
|
|
129
|
+
* `updated_at`, the org's extension config and copy revisions; never a value. The deployment's:
|
|
130
|
+
* a keyed digest of the extension's loaded deployment config.
|
|
99
131
|
*/
|
|
100
132
|
private revision;
|
|
101
133
|
private channelRevision;
|
|
@@ -127,7 +159,8 @@ export declare class SetupChecksService {
|
|
|
127
159
|
* The target material: for a channel connection its revision and stored secret values (and, for
|
|
128
160
|
* a plugin check, the connection config decrypted exactly as `channel@1` verify gets it); for a
|
|
129
161
|
* connector its credentials' values (redaction only), the manual OAuth client id and the
|
|
130
|
-
* template id
|
|
162
|
+
* template id; for the deployment nothing (its config's secrets are added by the caller). A
|
|
163
|
+
* `result` when the material cannot be read (the check is not called).
|
|
131
164
|
*/
|
|
132
165
|
private material;
|
|
133
166
|
/** The secret values of the extension's platform and effective deployment config. */
|