@capybara-hq/kernel 0.1.0-rc.83 → 0.1.0-rc.85
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 +5 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +10 -2
- package/dist/catalog/admin-catalog.controller.d.ts +2 -1
- package/dist/catalog/admin-catalog.controller.js +2 -1
- package/dist/catalog/catalog-content.d.ts +5 -15
- package/dist/catalog/catalog-content.js +5 -56
- package/dist/catalog/catalog-scope.service.d.ts +3 -3
- package/dist/catalog/catalog-scope.service.js +4 -3
- package/dist/catalog/catalog.module.d.ts +3 -1
- package/dist/catalog/catalog.module.js +14 -1
- package/dist/catalog/component-scope.service.d.ts +6 -1
- package/dist/catalog/component-scope.service.js +16 -2
- package/dist/catalog/git-source.d.ts +8 -0
- package/dist/catalog/git-source.js +34 -0
- package/dist/catalog/job-ids.d.ts +29 -0
- package/dist/catalog/job-ids.js +29 -0
- package/dist/catalog/jobs.d.ts +12 -3
- package/dist/catalog/jobs.js +28 -7
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +2 -30
- package/dist/catalog/org-catalog.controller.js +3 -29
- package/dist/catalog/org-catalog.schemas.d.ts +9 -46
- package/dist/catalog/org-catalog.schemas.js +9 -23
- package/dist/catalog/org-catalog.service.js +14 -23
- package/dist/catalog/plugin-import.d.ts +21 -0
- package/dist/catalog/plugin-import.js +33 -3
- package/dist/catalog/plugin-install.d.ts +69 -76
- package/dist/catalog/plugin-install.js +156 -234
- package/dist/catalog/plugin-upgrade.d.ts +71 -11
- package/dist/catalog/plugin-upgrade.js +222 -43
- package/dist/catalog/scope-sync.d.ts +22 -20
- package/dist/catalog/scope-sync.js +57 -42
- package/dist/catalog/template-connector-ensure.d.ts +100 -0
- package/dist/catalog/template-connector-ensure.js +285 -0
- package/dist/catalog/template-connector-jobs.d.ts +28 -0
- package/dist/catalog/template-connector-jobs.js +54 -0
- package/dist/catalog/template-connector-reconcile.d.ts +44 -0
- package/dist/catalog/template-connector-reconcile.js +114 -0
- package/dist/catalog/template-connectors.processor.d.ts +32 -0
- package/dist/catalog/template-connectors.processor.js +101 -0
- package/dist/db/kernel-schema.d.ts +2 -1
- package/dist/extensions/bootstrap.js +5 -1
- package/dist/extensions/instance.js +1 -16
- package/dist/extensions/org-config.d.ts +6 -1
- package/dist/extensions/org-config.js +15 -2
- package/dist/git/gateway.js +3 -1
- package/dist/infra/outbox/registry.d.ts +28 -0
- package/dist/infra/outbox/registry.js +33 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +8 -1
- package/dist/lifecycle/kernel-lifecycle.js +37 -11
- package/dist/orgs/org-owner.d.ts +7 -0
- package/dist/orgs/org-owner.js +16 -0
- package/dist/platform/operation.d.ts +3 -4
- package/dist/platform/ops/connectors.ops.js +8 -1
- package/dist/platform/ops/org-plugins.ops.d.ts +0 -9
- package/dist/platform/ops/org-plugins.ops.js +18 -235
- package/dist/platform/ops/plugins.ops.d.ts +0 -1
- package/dist/platform/ops/plugins.ops.js +3 -31
- package/dist/roles/worker-role.d.ts +9 -4
- package/dist/roles/worker-role.js +18 -5
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +8 -1
- package/dist/setup/setup-guides.service.d.ts +9 -1
- package/dist/setup/setup-guides.service.js +38 -8
- package/dist/tools/admin-connectors.d.ts +3 -2
- package/dist/tools/admin-connectors.js +5 -4
- package/dist/tools/connector-setup.d.ts +28 -0
- package/dist/tools/connector-setup.js +33 -0
- package/dist/tools/connector-tools-jobs.d.ts +35 -0
- package/dist/tools/connector-tools-jobs.js +40 -0
- package/dist/tools/connector-tools.processor.d.ts +32 -0
- package/dist/tools/connector-tools.processor.js +97 -0
- package/dist/tools/connectors.controller.d.ts +1 -0
- package/dist/tools/connectors.schemas.d.ts +1 -0
- package/dist/tools/connectors.schemas.js +5 -0
- package/dist/tools/connectors.service.d.ts +138 -14
- package/dist/tools/connectors.service.js +410 -50
- package/dist/tools/credentials.d.ts +35 -0
- package/dist/tools/credentials.js +89 -1
- package/dist/tools/drift.d.ts +5 -0
- package/dist/tools/drift.js +21 -2
- package/dist/tools/editable-endpoint.d.ts +23 -0
- package/dist/tools/editable-endpoint.js +92 -0
- package/dist/tools/oauth/flow.d.ts +1 -1
- package/dist/tools/oauth/flow.js +3 -2
- package/dist/tools/pipeline.js +14 -5
- package/dist/tools/registry.d.ts +14 -2
- package/dist/tools/registry.js +27 -6
- package/dist/tools/tools.module.js +4 -0
- package/package.json +3 -3
- package/src/migrations/0183_connectors_created_by_nullable.sql +5 -0
|
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
8
|
import { CatalogModule } from "../catalog/catalog.module.js";
|
|
9
|
+
import { TemplateConnectorsQueueModule } from "../catalog/template-connector-jobs.js";
|
|
9
10
|
import { ChannelsModule } from "../channels/channels.module.js";
|
|
10
11
|
import { PromptSuggestionsModule } from "../conversations/prompt-suggestions.js";
|
|
11
12
|
import { TitlesModule } from "../conversations/titles.js";
|
|
@@ -21,6 +22,7 @@ import { ProvidersModule } from "../runtime/providers.js";
|
|
|
21
22
|
import { RunJobsModule } from "../runtime/run-jobs.js";
|
|
22
23
|
import { UsageReportModule } from "../runtime/usage-report.js";
|
|
23
24
|
import { SandboxProviderRegistryModule } from "../sandbox/providers.module.js";
|
|
25
|
+
import { ConnectorToolsQueueModule } from "../tools/connector-tools-jobs.js";
|
|
24
26
|
import { AuditLogService } from "./audit-log.service.js";
|
|
25
27
|
import { AdminHealthService } from "./health.service.js";
|
|
26
28
|
import { OrgNetworkAdmin } from "./org-network.service.js";
|
|
@@ -59,6 +61,9 @@ AdminModule = __decorate([
|
|
|
59
61
|
LifecycleHooksModule,
|
|
60
62
|
// the push queue the overview counts
|
|
61
63
|
PushModule,
|
|
64
|
+
// the connector tools and template connectors queues the overview counts
|
|
65
|
+
ConnectorToolsQueueModule,
|
|
66
|
+
TemplateConnectorsQueueModule,
|
|
62
67
|
// the price table of the usage aggregate
|
|
63
68
|
ModelsModule,
|
|
64
69
|
],
|
|
@@ -5,7 +5,7 @@ import { type LiveReplica, ReplicaPresence } from "../infra/presence/replica-pre
|
|
|
5
5
|
import type { KernelLogger } from "../log.js";
|
|
6
6
|
import { DeviceProviders } from "../sandbox/providers.js";
|
|
7
7
|
/** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
|
|
8
|
-
export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver"];
|
|
8
|
+
export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors"];
|
|
9
9
|
/** How long each source's reads may take before the answer marks it unavailable. */
|
|
10
10
|
export declare const HEALTH_READ_TIMEOUT_MS = 3000;
|
|
11
11
|
/** A live replica as the overview shows it. */
|
|
@@ -104,7 +104,7 @@ export declare class AdminHealthService {
|
|
|
104
104
|
private readonly log;
|
|
105
105
|
private readonly providers;
|
|
106
106
|
private readonly queues;
|
|
107
|
-
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, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue);
|
|
107
|
+
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, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue, connectorTools: Queue, templateConnectors: Queue);
|
|
108
108
|
read(): Promise<AdminHealth>;
|
|
109
109
|
private readRedis;
|
|
110
110
|
private readDb;
|
|
@@ -11,6 +11,7 @@ import { getQueueToken } from "@nestjs/bullmq";
|
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { PLUGIN_SCOPE_QUEUE } from "../catalog/scope-sync.js";
|
|
14
|
+
import { TEMPLATE_CONNECTORS_QUEUE } from "../catalog/template-connector-jobs.js";
|
|
14
15
|
import { CHANNEL_QUEUE_NAME } from "../channels/jobs.js";
|
|
15
16
|
import { PROMPT_SUGGESTION_QUEUE } from "../conversations/prompt-suggestions.js";
|
|
16
17
|
import { TITLE_QUEUE } from "../conversations/titles.js";
|
|
@@ -24,6 +25,7 @@ import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
|
24
25
|
import { RUN_QUEUE_NAME, SUBAGENT_RUN_QUEUE_NAME } from "../runtime/run-jobs.js";
|
|
25
26
|
import { USAGE_REPORT_QUEUE } from "../runtime/usage-report-jobs.js";
|
|
26
27
|
import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
|
|
28
|
+
import { CONNECTOR_TOOLS_QUEUE } from "../tools/connector-tools-jobs.js";
|
|
27
29
|
import { KERNEL_VERSION } from "../version.js";
|
|
28
30
|
/** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
|
|
29
31
|
export const KERNEL_QUEUE_NAMES = [
|
|
@@ -38,6 +40,8 @@ export const KERNEL_QUEUE_NAMES = [
|
|
|
38
40
|
EVAL_QUEUE_NAME,
|
|
39
41
|
LIFECYCLE_QUEUE,
|
|
40
42
|
PUSH_QUEUE,
|
|
43
|
+
CONNECTOR_TOOLS_QUEUE,
|
|
44
|
+
TEMPLATE_CONNECTORS_QUEUE,
|
|
41
45
|
];
|
|
42
46
|
/** How long each source's reads may take before the answer marks it unavailable. */
|
|
43
47
|
export const HEALTH_READ_TIMEOUT_MS = 3_000;
|
|
@@ -66,7 +70,7 @@ let AdminHealthService = class AdminHealthService {
|
|
|
66
70
|
log;
|
|
67
71
|
providers;
|
|
68
72
|
queues;
|
|
69
|
-
constructor(presence, db, redis, log, providers, runs, subagentRuns, channels, maintenance, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push) {
|
|
73
|
+
constructor(presence, db, redis, log, providers, runs, subagentRuns, channels, maintenance, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push, connectorTools, templateConnectors) {
|
|
70
74
|
this.presence = presence;
|
|
71
75
|
this.db = db;
|
|
72
76
|
this.redis = redis;
|
|
@@ -85,6 +89,8 @@ let AdminHealthService = class AdminHealthService {
|
|
|
85
89
|
evals,
|
|
86
90
|
lifecycle,
|
|
87
91
|
push,
|
|
92
|
+
connectorTools,
|
|
93
|
+
templateConnectors,
|
|
88
94
|
];
|
|
89
95
|
}
|
|
90
96
|
async read() {
|
|
@@ -269,6 +275,8 @@ AdminHealthService = __decorate([
|
|
|
269
275
|
__param(12, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
|
|
270
276
|
__param(13, Inject(getQueueToken(EVAL_QUEUE_NAME))),
|
|
271
277
|
__param(14, Inject(getQueueToken(LIFECYCLE_QUEUE))),
|
|
272
|
-
__param(15, Inject(getQueueToken(PUSH_QUEUE)))
|
|
278
|
+
__param(15, Inject(getQueueToken(PUSH_QUEUE))),
|
|
279
|
+
__param(16, Inject(getQueueToken(CONNECTOR_TOOLS_QUEUE))),
|
|
280
|
+
__param(17, Inject(getQueueToken(TEMPLATE_CONNECTORS_QUEUE)))
|
|
273
281
|
], AdminHealthService);
|
|
274
282
|
export { AdminHealthService };
|
|
@@ -228,7 +228,8 @@ export declare class AdminCatalogController {
|
|
|
228
228
|
* What updating the platform plugin to `version` would do (spec §7.1, `PlatformPluginUpdater`):
|
|
229
229
|
* `{ itemId, name, from, to, components: [{ kind, id, name, change: added | removed | upgrade |
|
|
230
230
|
* downgrade | same, from, to, updatedOnOwn, ownScope, pinnedOrgs, kept? }], extension,
|
|
231
|
-
* connectorOrgs: [{ orgId, connectors,
|
|
231
|
+
* connectorOrgs: [{ orgId, connectors, created, turnedOff? }], scopeInstalls, diffHash }`.
|
|
232
|
+
* Nothing written. The same
|
|
232
233
|
* version, a target the deployment's extension or a dependent plugin cannot take -> 409
|
|
233
234
|
* `plugin.upgrade_target_invalid`; an added skill named like one in use where the plugin is on
|
|
234
235
|
* -> 409 `plugin.skill_conflict`; disabled -> 403 `catalog.item_disabled`.
|
|
@@ -346,7 +346,8 @@ let AdminCatalogController = class AdminCatalogController {
|
|
|
346
346
|
* What updating the platform plugin to `version` would do (spec §7.1, `PlatformPluginUpdater`):
|
|
347
347
|
* `{ itemId, name, from, to, components: [{ kind, id, name, change: added | removed | upgrade |
|
|
348
348
|
* downgrade | same, from, to, updatedOnOwn, ownScope, pinnedOrgs, kept? }], extension,
|
|
349
|
-
* connectorOrgs: [{ orgId, connectors,
|
|
349
|
+
* connectorOrgs: [{ orgId, connectors, created, turnedOff? }], scopeInstalls, diffHash }`.
|
|
350
|
+
* Nothing written. The same
|
|
350
351
|
* version, a target the deployment's extension or a dependent plugin cannot take -> 409
|
|
351
352
|
* `plugin.upgrade_target_invalid`; an added skill named like one in use where the plugin is on
|
|
352
353
|
* -> 409 `plugin.skill_conflict`; disabled -> 403 `catalog.item_disabled`.
|
|
@@ -23,9 +23,9 @@ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "mark
|
|
|
23
23
|
/** Shipped with the deployment (a required bootstrap plugin): on in every org, never switchable. */
|
|
24
24
|
builtin: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* The effective state in this org: `on`, `off`, `needs_config` (
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* The effective state in this org: `on`, `off`, `needs_config` (the plugin's extension has no
|
|
27
|
+
* valid effective config for the org, installed or wanted; connector setup shows on the
|
|
28
|
+
* connectors, plugin pages spec §5.2.3), `unavailable` (disabled by the super admin, members don't see it; or
|
|
29
29
|
* not installed here and its extension cannot run on the deployment, see `reason`) or
|
|
30
30
|
* `not_offered` (a `named` item shown to orgs outside its list: requestable, not usable).
|
|
31
31
|
*/
|
|
@@ -89,8 +89,7 @@ export interface OrgCatalogTemplate {
|
|
|
89
89
|
on: boolean;
|
|
90
90
|
/**
|
|
91
91
|
* The org already has a live connector made from this template (a switch-off kept it because an
|
|
92
|
-
* agent uses it): the install takes that connector back instead of creating one
|
|
93
|
-
* ask for the template's input.
|
|
92
|
+
* agent uses it): the install takes that connector back instead of creating one.
|
|
94
93
|
*/
|
|
95
94
|
connected: boolean;
|
|
96
95
|
/**
|
|
@@ -128,12 +127,6 @@ export interface OrgCatalogDetail {
|
|
|
128
127
|
skills: string[];
|
|
129
128
|
/** The agent template files (`agents/<name>.md`, sub-agents spec §16). */
|
|
130
129
|
agents: string[];
|
|
131
|
-
/**
|
|
132
|
-
* An installed plugin whose connector templates on in the org miss a connector there
|
|
133
|
-
* (`needs_config`, ruling P2-10): those templates, for `POST …/catalog/:itemId/connectors`;
|
|
134
|
-
* empty otherwise (Task 10).
|
|
135
|
-
*/
|
|
136
|
-
missingTemplates: OrgCatalogTemplate[];
|
|
137
130
|
}
|
|
138
131
|
/**
|
|
139
132
|
* A connector template as an org sees it (the install wizard and the upgrade preview's inputs):
|
|
@@ -209,10 +202,7 @@ export declare function requiredActions(m: PluginManifest): OrgAction[];
|
|
|
209
202
|
* lock only.
|
|
210
203
|
*/
|
|
211
204
|
export declare function lockOrgForActions(orgLock: Pick<OrgLock, "lock" | "lockAndAuthorize">, orgId: string, actor: string | null, actions: OrgAction[]): Promise<void>;
|
|
212
|
-
|
|
213
|
-
export declare function getPath(v: unknown, path: string): unknown;
|
|
214
|
-
/** Sets the value at a dot path of `obj`, creating the objects on the way. */
|
|
215
|
-
export declare function setPath(obj: Record<string, unknown>, path: string, value: unknown): void;
|
|
205
|
+
export { getPath, setPath } from "../tools/editable-endpoint.js";
|
|
216
206
|
/** The connector `kind` provided by extension `plugin` loaded on this replica (from the registry). */
|
|
217
207
|
export declare function findConnectorIn(registry: Pick<ExtensionRegistry, "list">, plugin: string, kind: string): Connector | undefined;
|
|
218
208
|
/** What checking a template's connector extension needs. */
|
|
@@ -8,6 +8,7 @@ import { ApiError } from "../errors.js";
|
|
|
8
8
|
import { can } from "../orgs/roles.js";
|
|
9
9
|
import { packagePath } from "../packages/tgz.js";
|
|
10
10
|
import { checkSkillFiles, SkillArchiveError } from "../skills/package.js";
|
|
11
|
+
import { mergeEditableEndpoint } from "../tools/editable-endpoint.js";
|
|
11
12
|
import { readDisplayFiles } from "./catalog-files.js";
|
|
12
13
|
import { iconProblem, pluginThemeError, themeApiError } from "./plugin-package.js";
|
|
13
14
|
import { templateDescriptionText } from "./template-description.js";
|
|
@@ -160,41 +161,7 @@ export async function lockOrgForActions(orgLock, orgId, actor, actions) {
|
|
|
160
161
|
throw new ApiError("forbidden", "Insufficient organization role");
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
const UNSAFE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
165
|
-
/** 对象的全部叶子点路径(数组与非对象值算叶子)。 */
|
|
166
|
-
function leafPaths(v, base = "") {
|
|
167
|
-
const out = [];
|
|
168
|
-
for (const [k, x] of Object.entries(v)) {
|
|
169
|
-
const p = base ? `${base}.${k}` : k;
|
|
170
|
-
if (isObj(x) && Object.keys(x).length > 0)
|
|
171
|
-
out.push(...leafPaths(x, p));
|
|
172
|
-
else
|
|
173
|
-
out.push(p);
|
|
174
|
-
}
|
|
175
|
-
return out;
|
|
176
|
-
}
|
|
177
|
-
/** The value at a dot path of `v` (own keys only), undefined when absent. */
|
|
178
|
-
export function getPath(v, path) {
|
|
179
|
-
let node = v;
|
|
180
|
-
for (const seg of path.split(".")) {
|
|
181
|
-
if (!isObj(node) || !Object.hasOwn(node, seg))
|
|
182
|
-
return undefined;
|
|
183
|
-
node = node[seg];
|
|
184
|
-
}
|
|
185
|
-
return node;
|
|
186
|
-
}
|
|
187
|
-
/** Sets the value at a dot path of `obj`, creating the objects on the way. */
|
|
188
|
-
export function setPath(obj, path, value) {
|
|
189
|
-
const segs = path.split(".");
|
|
190
|
-
let node = obj;
|
|
191
|
-
for (const seg of segs.slice(0, -1)) {
|
|
192
|
-
if (!isObj(node[seg]))
|
|
193
|
-
node[seg] = {};
|
|
194
|
-
node = node[seg];
|
|
195
|
-
}
|
|
196
|
-
node[segs[segs.length - 1]] = value;
|
|
197
|
-
}
|
|
164
|
+
export { getPath, setPath } from "../tools/editable-endpoint.js";
|
|
198
165
|
/** The connector `kind` provided by extension `plugin` loaded on this replica (from the registry). */
|
|
199
166
|
export function findConnectorIn(registry, plugin, kind) {
|
|
200
167
|
return registry
|
|
@@ -231,27 +198,9 @@ export function templateConnectorInput(deps, template, ref, input, defaultName,
|
|
|
231
198
|
if (problem !== undefined)
|
|
232
199
|
throw new ApiError("catalog.not_deployed", problem);
|
|
233
200
|
const given = input ?? {};
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (!isObj(given.endpoint))
|
|
238
|
-
throw fail(`${at}.endpoint`, "Expected an object");
|
|
239
|
-
for (const p of leafPaths(given.endpoint)) {
|
|
240
|
-
const segs = p.split(".");
|
|
241
|
-
if (segs.some((s) => UNSAFE_KEYS.has(s))) {
|
|
242
|
-
throw fail(`${at}.endpoint.${p}`, "Invalid key");
|
|
243
|
-
}
|
|
244
|
-
const allowed = editable.some((e) => p === e || p.startsWith(`${e}.`));
|
|
245
|
-
if (!allowed) {
|
|
246
|
-
throw fail(`${at}.endpoint.${p}`, "This endpoint field is set by the template and cannot be changed");
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
for (const e of editable) {
|
|
250
|
-
const v = getPath(given.endpoint, e);
|
|
251
|
-
if (v !== undefined)
|
|
252
|
-
setPath(endpoint, e, v);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
201
|
+
const endpoint = given.endpoint === undefined
|
|
202
|
+
? structuredClone(template.endpoint)
|
|
203
|
+
: mergeEditableEndpoint(template.endpoint, template.editableEndpoint ?? [], given.endpoint, at).endpoint;
|
|
255
204
|
const auth = template.auth;
|
|
256
205
|
const oauth = auth.type === "oauth_code" || auth.type === "oauth_client";
|
|
257
206
|
if (oauth && given.credential !== undefined) {
|
|
@@ -22,9 +22,9 @@ import { PluginScopeSync } from "./scope-sync.js";
|
|
|
22
22
|
* What a scope change or a deployment-level disable would take away (spec §5 rule 8): the orgs
|
|
23
23
|
* that have the plugin on now (a live install) and would no longer want it, each with its agents
|
|
24
24
|
* that use the plugin's skills, connectors or agent templates and the number of connectors it
|
|
25
|
-
* created there, which stay as the org's own; and the orgs that would newly want
|
|
26
|
-
*
|
|
27
|
-
* `needs_config
|
|
25
|
+
* created there, which stay as the org's own; and the orgs that would newly want it where its
|
|
26
|
+
* extension has no valid config for the org: the sync installs it there too and it shows
|
|
27
|
+
* `needs_config` until the org's config is set. `scopeHash` is confirmed with the change.
|
|
28
28
|
*/
|
|
29
29
|
export interface ScopePreview {
|
|
30
30
|
affected: {
|
|
@@ -1034,7 +1034,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
1034
1034
|
continue;
|
|
1035
1035
|
let needs = false;
|
|
1036
1036
|
try {
|
|
1037
|
-
needs = await this.sync.
|
|
1037
|
+
needs = await this.sync.needsConfig(org.id, item.id, item.latest_version);
|
|
1038
1038
|
}
|
|
1039
1039
|
catch (e) {
|
|
1040
1040
|
// Not installable as it is (a dependency unresolved): the sync reports it. Anything else
|
|
@@ -1042,10 +1042,11 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
1042
1042
|
if (!(e instanceof ApiError))
|
|
1043
1043
|
throw e;
|
|
1044
1044
|
}
|
|
1045
|
+
// the sync installs it either way (no install asks for input, plugin pages spec §5.2.2);
|
|
1046
|
+
// `needsConfig` names the orgs where its extension waits for the org's config
|
|
1045
1047
|
if (needs)
|
|
1046
1048
|
needsConfig.push(org.id);
|
|
1047
|
-
|
|
1048
|
-
onAfter.add(org.id);
|
|
1049
|
+
onAfter.add(org.id);
|
|
1049
1050
|
}
|
|
1050
1051
|
const { replaced, conflicts, themesLost } = await this.componentChanges(item, target, orgs, onAfter, affected);
|
|
1051
1052
|
const themes = await themesPreview(db, themesLost);
|
|
@@ -5,7 +5,9 @@ export { CatalogImportModule };
|
|
|
5
5
|
* with their dependencies, the platform plugin update (`PlatformPluginUpdater`) and the update to a
|
|
6
6
|
* staged version (`PlatformImportUpdate`), the admin's scope
|
|
7
7
|
* and disable
|
|
8
|
-
* (`CatalogScopeService`), org admins' plugin uploads (`OrgPluginUploads`) and their own plugins (`OwnedItems`),
|
|
8
|
+
* (`CatalogScopeService`), org admins' plugin uploads (`OrgPluginUploads`) and their own plugins (`OwnedItems`), the startup
|
|
9
|
+
* reconciliation of template connectors (`TemplateConnectorReconciler`) and the ensure it shares
|
|
10
|
+
* with the queued job (`TemplateConnectorEnsurer`), and the producer of the plugin scope sync
|
|
9
11
|
* (`PluginScopeSync`; its consumer is the worker role's `PluginScopeWorkersModule`). The catalog's periodic jobs (`CatalogJobs`) are
|
|
10
12
|
* the worker role's (`WorkerModule`).
|
|
11
13
|
*/
|
|
@@ -26,6 +26,9 @@ import { PluginInstaller } from "./plugin-install.js";
|
|
|
26
26
|
import { PlatformPluginUpdater } from "./plugin-upgrade.js";
|
|
27
27
|
import { CatalogRequestsService } from "./requests.service.js";
|
|
28
28
|
import { PLUGIN_SCOPE_QUEUE, PluginScopeSync } from "./scope-sync.js";
|
|
29
|
+
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
30
|
+
import { TemplateConnectorsQueueModule } from "./template-connector-jobs.js";
|
|
31
|
+
import { TemplateConnectorReconciler } from "./template-connector-reconcile.js";
|
|
29
32
|
export { CatalogImportModule };
|
|
30
33
|
/** The plugin scope sync's queue registration (re-exported: the admin health reads its counts). */
|
|
31
34
|
const PLUGIN_SCOPE_QUEUE_MODULE = QueueModule.registerQueue(PLUGIN_SCOPE_QUEUE);
|
|
@@ -36,7 +39,9 @@ const MAINTENANCE_QUEUE_MODULE = QueueModule.registerQueue(MAINTENANCE_QUEUE_NAM
|
|
|
36
39
|
* with their dependencies, the platform plugin update (`PlatformPluginUpdater`) and the update to a
|
|
37
40
|
* staged version (`PlatformImportUpdate`), the admin's scope
|
|
38
41
|
* and disable
|
|
39
|
-
* (`CatalogScopeService`), org admins' plugin uploads (`OrgPluginUploads`) and their own plugins (`OwnedItems`),
|
|
42
|
+
* (`CatalogScopeService`), org admins' plugin uploads (`OrgPluginUploads`) and their own plugins (`OwnedItems`), the startup
|
|
43
|
+
* reconciliation of template connectors (`TemplateConnectorReconciler`) and the ensure it shares
|
|
44
|
+
* with the queued job (`TemplateConnectorEnsurer`), and the producer of the plugin scope sync
|
|
40
45
|
* (`PluginScopeSync`; its consumer is the worker role's `PluginScopeWorkersModule`). The catalog's periodic jobs (`CatalogJobs`) are
|
|
41
46
|
* the worker role's (`WorkerModule`).
|
|
42
47
|
*/
|
|
@@ -60,6 +65,9 @@ CatalogModule = __decorate([
|
|
|
60
65
|
// the queue of a removed org plugin's owed cleanup job (`OwnedItems`, `CatalogScopeService`;
|
|
61
66
|
// consumed by the worker role's `MaintenanceProcessor`)
|
|
62
67
|
MAINTENANCE_QUEUE_MODULE,
|
|
68
|
+
// the template connector ensures owed by installs (`markInstalled`); consumed by the worker
|
|
69
|
+
// role's `TemplateConnectorsWorkersModule`
|
|
70
|
+
TemplateConnectorsQueueModule,
|
|
63
71
|
],
|
|
64
72
|
providers: [
|
|
65
73
|
CatalogRequestsService,
|
|
@@ -73,9 +81,12 @@ CatalogModule = __decorate([
|
|
|
73
81
|
OrgPluginUploads,
|
|
74
82
|
OwnedItems,
|
|
75
83
|
PlatformImportUpdate,
|
|
84
|
+
TemplateConnectorEnsurer,
|
|
85
|
+
TemplateConnectorReconciler,
|
|
76
86
|
],
|
|
77
87
|
exports: [
|
|
78
88
|
PLUGIN_SCOPE_QUEUE_MODULE,
|
|
89
|
+
TemplateConnectorsQueueModule,
|
|
79
90
|
MAINTENANCE_QUEUE_MODULE,
|
|
80
91
|
CatalogImportModule,
|
|
81
92
|
CatalogRequestsService,
|
|
@@ -89,6 +100,8 @@ CatalogModule = __decorate([
|
|
|
89
100
|
OrgPluginUploads,
|
|
90
101
|
OwnedItems,
|
|
91
102
|
PlatformImportUpdate,
|
|
103
|
+
TemplateConnectorEnsurer,
|
|
104
|
+
TemplateConnectorReconciler,
|
|
92
105
|
],
|
|
93
106
|
})
|
|
94
107
|
], CatalogModule);
|
|
@@ -11,6 +11,7 @@ import type { ActorOpts } from "./catalog.service.js";
|
|
|
11
11
|
import { ComponentPromotion } from "./component-promotion.js";
|
|
12
12
|
import { type ComponentKind } from "./component-state.js";
|
|
13
13
|
import { type Owner } from "./ownership.js";
|
|
14
|
+
import { PluginInstaller } from "./plugin-install.js";
|
|
14
15
|
import type { PluginScope } from "./scope.js";
|
|
15
16
|
/**
|
|
16
17
|
* What a component scope change, a component disable or a switch back to its plugin's scope would
|
|
@@ -246,13 +247,17 @@ export declare class ComponentScopeService {
|
|
|
246
247
|
readonly txHost: TransactionHost;
|
|
247
248
|
/** The connector templates' setup guides (the org list's `guide`). */
|
|
248
249
|
private readonly guides;
|
|
250
|
+
/** A connector template switched on where its plugin is installed gets its connector. */
|
|
251
|
+
private readonly installer;
|
|
249
252
|
constructor(kdb: KernelDb, adminLock: SuperAdminLock,
|
|
250
253
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
251
254
|
orgLock: OrgLock,
|
|
252
255
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
253
256
|
promotion: ComponentPromotion, txHost: TransactionHost,
|
|
254
257
|
/** The connector templates' setup guides (the org list's `guide`). */
|
|
255
|
-
guides: Pick<PluginGuides, "templateGuides"
|
|
258
|
+
guides: Pick<PluginGuides, "templateGuides">,
|
|
259
|
+
/** A connector template switched on where its plugin is installed gets its connector. */
|
|
260
|
+
installer: PluginInstaller);
|
|
256
261
|
private get db();
|
|
257
262
|
/**
|
|
258
263
|
* What the admin routes act on (ruling P3-23): the platform component `id`, an org row the org
|
|
@@ -26,6 +26,7 @@ import { assertOrgsExist } from "./catalog-items.js";
|
|
|
26
26
|
import { ComponentPromotion, notOwnedError, PROMOTION_ATTEMPTS, PromotionStale, promotionStaleError, } from "./component-promotion.js";
|
|
27
27
|
import { agentsUsing, COMPONENT_KINDS, componentLocked, componentOffered, componentOn, componentPluginOn, connectorsMadeFrom, listedIn, loadComponents, loadScopeState, pluginFactsOf, skillNameClashes, switchOf, themeIdClashes, } from "./component-state.js";
|
|
28
28
|
import { assertOwnerListed, assertShareable, assertShareableTarget, newlySharedWith, ownerOf, ownersOf, } from "./ownership.js";
|
|
29
|
+
import { PluginInstaller } from "./plugin-install.js";
|
|
29
30
|
const notFound = () => new ApiError("component.not_found", "Component not found");
|
|
30
31
|
const staleError = () => new ApiError("plugin.scope_stale", "What this change affects has changed since the preview; preview it again and confirm the new hash");
|
|
31
32
|
const builtinError = () => new ApiError("plugin.builtin", "This component belongs to a built-in plugin: it is on in every organization and its scope cannot be changed or disabled");
|
|
@@ -126,19 +127,23 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
126
127
|
promotion;
|
|
127
128
|
txHost;
|
|
128
129
|
guides;
|
|
130
|
+
installer;
|
|
129
131
|
constructor(kdb, adminLock,
|
|
130
132
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
131
133
|
orgLock,
|
|
132
134
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
133
135
|
promotion, txHost,
|
|
134
136
|
/** The connector templates' setup guides (the org list's `guide`). */
|
|
135
|
-
guides
|
|
137
|
+
guides,
|
|
138
|
+
/** A connector template switched on where its plugin is installed gets its connector. */
|
|
139
|
+
installer) {
|
|
136
140
|
this.kdb = kdb;
|
|
137
141
|
this.adminLock = adminLock;
|
|
138
142
|
this.orgLock = orgLock;
|
|
139
143
|
this.promotion = promotion;
|
|
140
144
|
this.txHost = txHost;
|
|
141
145
|
this.guides = guides;
|
|
146
|
+
this.installer = installer;
|
|
142
147
|
}
|
|
143
148
|
get db() {
|
|
144
149
|
return this.kdb.db;
|
|
@@ -591,6 +596,14 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
591
596
|
},
|
|
592
597
|
});
|
|
593
598
|
}
|
|
599
|
+
// A connector template switched on where its plugin is installed: its connector now, as an
|
|
600
|
+
// install would make it (plugin pages spec §5.2.2), in this transaction
|
|
601
|
+
if (kind === "connector_template" && body.enabled && componentOn(c, p, listed, true)) {
|
|
602
|
+
await this.installer.createSwitchedOnTemplateConnectorIn(orgId, actor, c.id, {
|
|
603
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
604
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
605
|
+
});
|
|
606
|
+
}
|
|
594
607
|
return {
|
|
595
608
|
kind: "done",
|
|
596
609
|
component: {
|
|
@@ -1083,7 +1096,8 @@ ComponentScopeService = __decorate([
|
|
|
1083
1096
|
__param(2, Inject(OrgLock)),
|
|
1084
1097
|
__param(3, Inject(ComponentPromotion)),
|
|
1085
1098
|
__param(4, Inject(TransactionHost)),
|
|
1086
|
-
__param(5, Inject(PluginGuides))
|
|
1099
|
+
__param(5, Inject(PluginGuides)),
|
|
1100
|
+
__param(6, Inject(PluginInstaller))
|
|
1087
1101
|
], ComponentScopeService);
|
|
1088
1102
|
export { ComponentScopeService };
|
|
1089
1103
|
/** Whether `c` is the platform default theme `uiTheme` (locked on in every org, themes spec §7). */
|
|
@@ -119,6 +119,14 @@ export type ReadGitTreeOptions = GitOptions & {
|
|
|
119
119
|
*/
|
|
120
120
|
include?: (path: string, type: "tree" | "blob") => boolean;
|
|
121
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* The git tree oid of a directory holding exactly `files` (paths relative to it, `/`-separated) as
|
|
124
|
+
* regular files of mode 100644: git's own blob and tree hashing, so it is the oid
|
|
125
|
+
* {@link readGitTreeAndOids} gives that directory when none of its files is executable (symlinks and
|
|
126
|
+
* submodules are refused there). For files known without reading git, e.g. the verified offline
|
|
127
|
+
* pack of a bootstrap git entry; an executable file in the repository only makes the oids differ.
|
|
128
|
+
*/
|
|
129
|
+
export declare function gitTreeOidOf(files: ReadonlyMap<string, Uint8Array>): string;
|
|
122
130
|
/**
|
|
123
131
|
* {@link readGitTree}, plus the git tree oids of directories at the same commit: `trees` gets the
|
|
124
132
|
* files read and returns directory paths relative to the repository root (`.` is the root); each
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import * as fsp from "node:fs/promises";
|
|
2
3
|
import { tmpdir } from "node:os";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -377,6 +378,39 @@ function pathSegments(path) {
|
|
|
377
378
|
export async function readGitTree(loc, o) {
|
|
378
379
|
return (await readGitTreeAndOids(loc, o)).files;
|
|
379
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* The git tree oid of a directory holding exactly `files` (paths relative to it, `/`-separated) as
|
|
383
|
+
* regular files of mode 100644: git's own blob and tree hashing, so it is the oid
|
|
384
|
+
* {@link readGitTreeAndOids} gives that directory when none of its files is executable (symlinks and
|
|
385
|
+
* submodules are refused there). For files known without reading git, e.g. the verified offline
|
|
386
|
+
* pack of a bootstrap git entry; an executable file in the repository only makes the oids differ.
|
|
387
|
+
*/
|
|
388
|
+
export function gitTreeOidOf(files) {
|
|
389
|
+
const root = new Map();
|
|
390
|
+
for (const [path, data] of files) {
|
|
391
|
+
const segs = path.split("/");
|
|
392
|
+
let dir = root;
|
|
393
|
+
for (const seg of segs.slice(0, -1)) {
|
|
394
|
+
let sub = dir.get(seg);
|
|
395
|
+
if (!(sub instanceof Map)) {
|
|
396
|
+
sub = new Map();
|
|
397
|
+
dir.set(seg, sub);
|
|
398
|
+
}
|
|
399
|
+
dir = sub;
|
|
400
|
+
}
|
|
401
|
+
dir.set(segs[segs.length - 1], data);
|
|
402
|
+
}
|
|
403
|
+
const hash = (type, body) => createHash("sha1").update(`${type} ${body.byteLength}\0`).update(body).digest();
|
|
404
|
+
const tree = (dir) => {
|
|
405
|
+
// git orders entries by their bytes, a directory as if its name ended in "/"
|
|
406
|
+
const entries = [...dir].map(([name, v]) => v instanceof Map
|
|
407
|
+
? { key: Buffer.from(`${name}/`), head: `40000 ${name}\0`, oid: tree(v) }
|
|
408
|
+
: { key: Buffer.from(name), head: `100644 ${name}\0`, oid: hash("blob", v) });
|
|
409
|
+
entries.sort((a, b) => Buffer.compare(a.key, b.key));
|
|
410
|
+
return hash("tree", Buffer.concat(entries.flatMap((e) => [Buffer.from(e.head), e.oid])));
|
|
411
|
+
};
|
|
412
|
+
return tree(root).toString("hex");
|
|
413
|
+
}
|
|
380
414
|
/**
|
|
381
415
|
* {@link readGitTree}, plus the git tree oids of directories at the same commit: `trees` gets the
|
|
382
416
|
* files read and returns directory paths relative to the repository root (`.` is the root); each
|
|
@@ -10,6 +10,35 @@ export declare const MARKETPLACES_REFRESH_JOB = "catalogs-refresh";
|
|
|
10
10
|
* staging rows and their object storage prefixes (`PluginImport.cleanupExpired`).
|
|
11
11
|
*/
|
|
12
12
|
export declare const PLUGIN_STAGING_CLEANUP_JOB = "app-staging-cleanup";
|
|
13
|
+
/**
|
|
14
|
+
* The backstop sweep of template connectors (ruling R30; a `@LockedInterval`, once per tick across
|
|
15
|
+
* replicas, every {@link TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS}): orgs with a template connector they
|
|
16
|
+
* never had whose connector kind is available now get the ensure (`TemplateConnectorEnsurer.sweep`).
|
|
17
|
+
*/
|
|
18
|
+
export declare const TEMPLATE_CONNECTORS_SWEEP_JOB = "template-connectors-sweep";
|
|
19
|
+
/**
|
|
20
|
+
* Five minutes: the queued ensure retries for about ten minutes after an install or a switch-on,
|
|
21
|
+
* so the sweep only catches what outlives that (a kind loaded later, an always-on extension); a
|
|
22
|
+
* connector that waited that long can wait one more period, and the candidates query runs only
|
|
23
|
+
* twelve times an hour.
|
|
24
|
+
*/
|
|
25
|
+
export declare const TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS: number;
|
|
26
|
+
/** Orgs one sweep tick ensures at most (the rest follow on the next ticks). */
|
|
27
|
+
export declare const TEMPLATE_CONNECTORS_SWEEP_BATCH = 50;
|
|
28
|
+
/**
|
|
29
|
+
* The `deployment_settings` key holding the last org a sweep tick ensured: the next tick starts
|
|
30
|
+
* after it and wraps to the first candidate, so orgs where the ensure keeps creating nothing never
|
|
31
|
+
* starve the later ones (missing: it starts at the first org).
|
|
32
|
+
*/
|
|
33
|
+
export declare const TEMPLATE_CONNECTORS_SWEEP_CURSOR_KEY = "templateConnectorsSweepCursor";
|
|
34
|
+
/**
|
|
35
|
+
* The lease key prefix marking a refusal already warned about (`<prefix><orgId>-<templateId>`,
|
|
36
|
+
* `LockService.lease`): a refusal repeated by later ensures (each sweep tick) is logged at debug,
|
|
37
|
+
* the first at warn.
|
|
38
|
+
*/
|
|
39
|
+
export declare const TEMPLATE_CONNECTOR_REFUSAL_WARNED_PREFIX = "cap:kernel:template-connector-warned:";
|
|
40
|
+
/** How long a refusal stays warned about: a day, then it is warned about once more. */
|
|
41
|
+
export declare const TEMPLATE_CONNECTOR_REFUSAL_WARNED_TTL_MS = 86400000;
|
|
13
42
|
/**
|
|
14
43
|
* The one-off job that takes out the extension of a removed org-owned plugin (spec §14, P3-20,
|
|
15
44
|
* P3-21; `OwnedPluginCleanup.run`), on `cap-kernel-maintenance`.
|
package/dist/catalog/job-ids.js
CHANGED
|
@@ -9,6 +9,35 @@ export const MARKETPLACES_REFRESH_JOB = "catalogs-refresh";
|
|
|
9
9
|
* staging rows and their object storage prefixes (`PluginImport.cleanupExpired`).
|
|
10
10
|
*/
|
|
11
11
|
export const PLUGIN_STAGING_CLEANUP_JOB = "app-staging-cleanup";
|
|
12
|
+
/**
|
|
13
|
+
* The backstop sweep of template connectors (ruling R30; a `@LockedInterval`, once per tick across
|
|
14
|
+
* replicas, every {@link TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS}): orgs with a template connector they
|
|
15
|
+
* never had whose connector kind is available now get the ensure (`TemplateConnectorEnsurer.sweep`).
|
|
16
|
+
*/
|
|
17
|
+
export const TEMPLATE_CONNECTORS_SWEEP_JOB = "template-connectors-sweep";
|
|
18
|
+
/**
|
|
19
|
+
* Five minutes: the queued ensure retries for about ten minutes after an install or a switch-on,
|
|
20
|
+
* so the sweep only catches what outlives that (a kind loaded later, an always-on extension); a
|
|
21
|
+
* connector that waited that long can wait one more period, and the candidates query runs only
|
|
22
|
+
* twelve times an hour.
|
|
23
|
+
*/
|
|
24
|
+
export const TEMPLATE_CONNECTORS_SWEEP_PERIOD_MS = 5 * 60_000;
|
|
25
|
+
/** Orgs one sweep tick ensures at most (the rest follow on the next ticks). */
|
|
26
|
+
export const TEMPLATE_CONNECTORS_SWEEP_BATCH = 50;
|
|
27
|
+
/**
|
|
28
|
+
* The `deployment_settings` key holding the last org a sweep tick ensured: the next tick starts
|
|
29
|
+
* after it and wraps to the first candidate, so orgs where the ensure keeps creating nothing never
|
|
30
|
+
* starve the later ones (missing: it starts at the first org).
|
|
31
|
+
*/
|
|
32
|
+
export const TEMPLATE_CONNECTORS_SWEEP_CURSOR_KEY = "templateConnectorsSweepCursor";
|
|
33
|
+
/**
|
|
34
|
+
* The lease key prefix marking a refusal already warned about (`<prefix><orgId>-<templateId>`,
|
|
35
|
+
* `LockService.lease`): a refusal repeated by later ensures (each sweep tick) is logged at debug,
|
|
36
|
+
* the first at warn.
|
|
37
|
+
*/
|
|
38
|
+
export const TEMPLATE_CONNECTOR_REFUSAL_WARNED_PREFIX = "cap:kernel:template-connector-warned:";
|
|
39
|
+
/** How long a refusal stays warned about: a day, then it is warned about once more. */
|
|
40
|
+
export const TEMPLATE_CONNECTOR_REFUSAL_WARNED_TTL_MS = 86_400_000;
|
|
12
41
|
/**
|
|
13
42
|
* The one-off job that takes out the extension of a removed org-owned plugin (spec §14, P3-20,
|
|
14
43
|
* P3-21; `OwnedPluginCleanup.run`), on `cap-kernel-maintenance`.
|
package/dist/catalog/jobs.d.ts
CHANGED
|
@@ -3,25 +3,34 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
3
3
|
import type { KernelLogger } from "../log.js";
|
|
4
4
|
import { MarketplacesService } from "./marketplaces.service.js";
|
|
5
5
|
import { PluginImport } from "./plugin-import.js";
|
|
6
|
+
import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
|
|
6
7
|
/**
|
|
7
8
|
* The catalog's periodic jobs, each run once per tick across replicas: the marketplace refresh
|
|
8
9
|
* (`catalogs-refresh`, every `marketplaces.refreshIntervalMinutes` and once after the start:
|
|
9
|
-
* `@LockedInterval` with `runOnStart`)
|
|
10
|
-
* hourly cleanup of expired plugin import staging (`app-staging-cleanup`: `@LockedCron`)
|
|
10
|
+
* `@LockedInterval` with `runOnStart`), the
|
|
11
|
+
* hourly cleanup of expired plugin import staging (`app-staging-cleanup`: `@LockedCron`) and the
|
|
12
|
+
* template connector sweep (`template-connectors-sweep`, every five minutes: `@LockedInterval`).
|
|
11
13
|
*/
|
|
12
14
|
export declare class CatalogJobs {
|
|
13
15
|
private readonly marketplaces;
|
|
14
16
|
private readonly imports;
|
|
17
|
+
private readonly templateConnectors;
|
|
15
18
|
readonly config: KernelConfigService;
|
|
16
19
|
readonly lockService: LockService;
|
|
17
20
|
readonly log: KernelLogger;
|
|
18
|
-
constructor(marketplaces: MarketplacesService, imports: PluginImport, config: KernelConfigService, lockService: LockService, log: KernelLogger);
|
|
21
|
+
constructor(marketplaces: MarketplacesService, imports: PluginImport, templateConnectors: TemplateConnectorEnsurer, config: KernelConfigService, lockService: LockService, log: KernelLogger);
|
|
19
22
|
/**
|
|
20
23
|
* Refreshes every enabled marketplace in turn (overall deadline
|
|
21
24
|
* {@link MARKETPLACES_REFRESH_DEADLINE_MS}; the job's signal aborts it: the stop, or the run
|
|
22
25
|
* lock lost).
|
|
23
26
|
*/
|
|
24
27
|
refreshMarketplaces(stop?: AbortSignal): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* The backstop for template connectors no event re-triggers (ruling R30): a bounded batch of
|
|
30
|
+
* orgs whose missing template connector's kind is available now. Runs outside any transaction;
|
|
31
|
+
* each connector is created in its own (`TemplateConnectorEnsurer`).
|
|
32
|
+
*/
|
|
33
|
+
sweepTemplateConnectors(stop?: AbortSignal): Promise<void>;
|
|
25
34
|
/** Deletes expired staging rows and their objects. */
|
|
26
35
|
cleanupStaging(): Promise<void>;
|
|
27
36
|
}
|