@capybara-hq/kernel 0.1.0-rc.135 → 0.1.0-rc.137
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/audit-log.service.d.ts +96 -12
- package/dist/admin/audit-log.service.js +508 -44
- package/dist/admin/audit-targets.d.ts +17 -0
- package/dist/admin/audit-targets.js +84 -0
- package/dist/admin/audit.controller.d.ts +12 -9
- package/dist/admin/audit.controller.js +29 -8
- package/dist/admin/audit.schemas.d.ts +20 -4
- package/dist/admin/audit.schemas.js +42 -17
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/agents/templates.js +3 -10
- package/dist/app.d.ts +3 -1
- package/dist/app.js +1 -0
- package/dist/automations/automations.service.js +4 -5
- package/dist/catalog/catalog-content.d.ts +1 -1
- package/dist/catalog/catalog-content.js +17 -22
- package/dist/catalog/catalog-items.d.ts +5 -10
- package/dist/catalog/catalog-items.js +27 -51
- package/dist/catalog/catalog-scope.service.d.ts +4 -2
- package/dist/catalog/catalog-scope.service.js +105 -141
- package/dist/catalog/catalog.module.js +2 -0
- package/dist/catalog/catalog.service.d.ts +3 -3
- package/dist/catalog/catalog.service.js +33 -8
- package/dist/catalog/cli.js +17 -0
- package/dist/catalog/component-promotion.js +8 -4
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +101 -140
- package/dist/catalog/component-state.d.ts +10 -8
- package/dist/catalog/component-state.js +42 -30
- package/dist/catalog/dependency-edges.d.ts +25 -0
- package/dist/catalog/dependency-edges.js +125 -0
- package/dist/catalog/install-status.d.ts +2 -3
- package/dist/catalog/install-status.js +2 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +3 -1
- package/dist/catalog/org-catalog.service.js +33 -94
- package/dist/catalog/org-intent.d.ts +43 -0
- package/dist/catalog/org-intent.js +184 -0
- package/dist/catalog/owned-items.d.ts +1 -1
- package/dist/catalog/owned-items.js +9 -29
- package/dist/catalog/ownership.d.ts +2 -3
- package/dist/catalog/ownership.js +10 -28
- package/dist/catalog/platform-components.d.ts +3 -1
- package/dist/catalog/platform-components.js +9 -1
- package/dist/catalog/plugin-import.js +12 -16
- package/dist/catalog/plugin-install.d.ts +3 -4
- package/dist/catalog/plugin-install.js +25 -49
- package/dist/catalog/plugin-upgrade.d.ts +2 -2
- package/dist/catalog/plugin-upgrade.js +18 -34
- package/dist/catalog/request-rules.js +20 -8
- package/dist/catalog/scope-orgs.js +2 -7
- package/dist/catalog/scope-state.d.ts +6 -6
- package/dist/catalog/scope-state.js +24 -43
- package/dist/catalog/scope-sync.d.ts +0 -2
- package/dist/catalog/scope-sync.js +11 -39
- package/dist/catalog/scope-writer.d.ts +78 -0
- package/dist/catalog/scope-writer.js +181 -0
- package/dist/catalog/unshare.js +8 -41
- package/dist/channels/connections.service.js +6 -6
- package/dist/channels/supervisor.js +3 -7
- package/dist/client/client-access.service.js +2 -12
- package/dist/config/schema.d.ts +6 -0
- package/dist/config/schema.js +29 -1
- package/dist/conversations/access.d.ts +15 -7
- package/dist/conversations/access.js +59 -10
- package/dist/conversations/conversation-agent.d.ts +18 -0
- package/dist/conversations/conversation-agent.js +23 -0
- package/dist/conversations/conversation-ref.d.ts +3 -2
- package/dist/conversations/conversation-ref.js +6 -1
- package/dist/conversations/conversations.controller.d.ts +28 -5
- package/dist/conversations/conversations.controller.js +99 -10
- package/dist/conversations/conversations.module.js +10 -0
- package/dist/conversations/conversations.schemas.d.ts +6 -0
- package/dist/conversations/conversations.schemas.js +15 -0
- package/dist/conversations/conversations.service.d.ts +125 -21
- package/dist/conversations/conversations.service.js +260 -90
- package/dist/conversations/event-log.d.ts +9 -1
- package/dist/conversations/event-log.js +2 -0
- package/dist/conversations/events.d.ts +57 -0
- package/dist/conversations/events.js +73 -1
- package/dist/conversations/external/external-calls.d.ts +75 -0
- package/dist/conversations/external/external-calls.js +91 -0
- package/dist/conversations/external/external-calls.processor.d.ts +45 -0
- package/dist/conversations/external/external-calls.processor.js +144 -0
- package/dist/conversations/external/external-conversations.service.d.ts +266 -0
- package/dist/conversations/external/external-conversations.service.js +1138 -0
- package/dist/conversations/external/external.schemas.d.ts +63 -0
- package/dist/conversations/external/external.schemas.js +52 -0
- package/dist/conversations/external/token.d.ts +6 -0
- package/dist/conversations/external/token.js +6 -0
- package/dist/conversations/permission-profile-store.d.ts +4 -1
- package/dist/conversations/permission-profiles.controller.d.ts +33 -9
- package/dist/conversations/permission-profiles.controller.js +86 -6
- package/dist/conversations/prompt-suggestions.js +2 -1
- package/dist/conversations/queue.js +2 -1
- package/dist/conversations/titles.js +4 -3
- package/dist/ctx/create-ctx.d.ts +9 -2
- package/dist/ctx/create-ctx.js +47 -62
- package/dist/ctx/guard-db.d.ts +6 -0
- package/dist/ctx/guard-db.js +55 -0
- package/dist/db/extension-handoff-schema.d.ts +1 -1
- package/dist/db/extension-handoff-schema.js +48 -10
- package/dist/db/extension-schema-transfer.js +5 -2
- package/dist/db/kernel-schema.d.ts +42 -5
- package/dist/device-access/host-services.d.ts +2 -2
- package/dist/device-access/host-services.js +8 -8
- package/dist/device-access/person-handles.d.ts +16 -7
- package/dist/device-access/person-handles.js +14 -9
- package/dist/devices/conversation-devices.d.ts +5 -0
- package/dist/devices/conversation-devices.js +16 -0
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +5 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.js +34 -0
- package/dist/evals/snapshot.js +3 -1
- package/dist/evals/trajectory.service.d.ts +2 -2
- package/dist/evals/trajectory.service.js +11 -7
- package/dist/extensions/admin-ops.d.ts +9 -5
- package/dist/extensions/admin-ops.js +52 -8
- package/dist/extensions/admin-view.js +1 -4
- package/dist/extensions/bootstrap.js +4 -1
- package/dist/extensions/cli.js +1 -0
- package/dist/extensions/effective-config.js +1 -4
- package/dist/extensions/enabled.d.ts +23 -29
- package/dist/extensions/enabled.js +141 -62
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +71 -45
- package/dist/extensions/host.js +454 -128
- package/dist/extensions/installs.d.ts +9 -0
- package/dist/extensions/installs.js +23 -0
- package/dist/extensions/isolated/admission.d.ts +10 -0
- package/dist/extensions/isolated/admission.js +206 -0
- package/dist/extensions/isolated/authorization.d.ts +37 -0
- package/dist/extensions/isolated/authorization.js +146 -0
- package/dist/extensions/isolated/broker.d.ts +15 -0
- package/dist/extensions/isolated/broker.js +452 -0
- package/dist/extensions/isolated/child-protocol.d.ts +84 -0
- package/dist/extensions/isolated/child-protocol.js +21 -0
- package/dist/extensions/isolated/child-registration.d.ts +22 -0
- package/dist/extensions/isolated/child-registration.js +152 -0
- package/dist/extensions/isolated/child-session.d.ts +6 -0
- package/dist/extensions/isolated/child-session.js +343 -0
- package/dist/extensions/isolated/child-streams.d.ts +4 -0
- package/dist/extensions/isolated/child-streams.js +142 -0
- package/dist/extensions/isolated/child.d.ts +1 -0
- package/dist/extensions/isolated/child.js +10 -0
- package/dist/extensions/isolated/configured-package.d.ts +15 -0
- package/dist/extensions/isolated/configured-package.js +73 -0
- package/dist/extensions/isolated/lanes.d.ts +100 -0
- package/dist/extensions/isolated/lanes.js +699 -0
- package/dist/extensions/isolated/postgres-gate.d.ts +14 -0
- package/dist/extensions/isolated/postgres-gate.js +255 -0
- package/dist/extensions/isolated/revision.d.ts +32 -0
- package/dist/extensions/isolated/revision.js +358 -0
- package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
- package/dist/extensions/isolated/rpc-frame.js +193 -0
- package/dist/extensions/isolated/rpc.d.ts +66 -0
- package/dist/extensions/isolated/rpc.js +314 -0
- package/dist/extensions/isolated/sandbox.d.ts +35 -0
- package/dist/extensions/isolated/sandbox.js +372 -0
- package/dist/extensions/isolated/tier.d.ts +6 -0
- package/dist/extensions/isolated/tier.js +45 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-topics.d.ts +1 -0
- package/dist/extensions/lifecycle-topics.js +1 -0
- package/dist/extensions/lifecycle.d.ts +3 -1
- package/dist/extensions/lifecycle.js +32 -5
- package/dist/extensions/locks.d.ts +2 -0
- package/dist/extensions/locks.js +7 -0
- package/dist/extensions/org-config.d.ts +17 -27
- package/dist/extensions/org-config.js +114 -129
- package/dist/extensions/permission-view.d.ts +3 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/extensions/plugin-guides.d.ts +5 -10
- package/dist/extensions/plugin-guides.js +18 -37
- package/dist/extensions/plugin-icons.d.ts +3 -21
- package/dist/extensions/plugin-icons.js +9 -44
- package/dist/extensions/plugin-items.d.ts +10 -30
- package/dist/extensions/plugin-items.js +32 -73
- package/dist/extensions/point-defaults.d.ts +13 -21
- package/dist/extensions/point-defaults.js +32 -72
- package/dist/extensions/point-serving.d.ts +56 -0
- package/dist/extensions/point-serving.js +120 -0
- package/dist/extensions/source-intent.d.ts +14 -0
- package/dist/extensions/source-intent.js +77 -0
- package/dist/inbox/inbox-items.service.d.ts +11 -0
- package/dist/inbox/inbox-items.service.js +39 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/infra/database/database.module.js +6 -1
- package/dist/infra/database/kernel-db.d.ts +3 -1
- package/dist/infra/database/kernel-db.js +4 -0
- package/dist/infra/outbox/registry.d.ts +70 -0
- package/dist/infra/outbox/registry.js +44 -0
- package/dist/infra/paging/paged-read.d.ts +56 -0
- package/dist/infra/paging/paged-read.js +78 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +21 -2
- package/dist/kernel.module.js +4 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +22 -12
- package/dist/lifecycle/tokens.d.ts +8 -0
- package/dist/lifecycle/tokens.js +2 -0
- package/dist/orgs/directory-sync.js +1 -4
- package/dist/platform/exclusions.js +10 -0
- package/dist/platform/ops/admin.ops.js +14 -3
- package/dist/platform/ops/conversations.ops.d.ts +8 -1
- package/dist/platform/ops/conversations.ops.js +52 -14
- package/dist/platform/ops/orgs.ops.js +13 -3
- package/dist/plugin-reads/plugin-reads.service.js +4 -1
- package/dist/push/recipients.js +5 -2
- package/dist/retention/worker.js +2 -1
- package/dist/roles/worker-role.d.ts +3 -1
- package/dist/roles/worker-role.js +8 -2
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/context/build.js +8 -0
- package/dist/runtime/context/compaction.js +7 -0
- package/dist/runtime/idle-arm.js +3 -1
- package/dist/runtime/idle-compaction.js +2 -1
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-jobs.js +2 -1
- package/dist/runtime/run-queue.js +4 -2
- package/dist/runtime/run-worker.js +5 -2
- package/dist/runtime/stream.js +10 -0
- package/dist/runtime/usage-report.js +2 -1
- package/dist/runtime/waits.js +2 -1
- package/dist/setup/setup-checks.service.js +3 -2
- package/dist/skills/usable.js +41 -30
- package/dist/themes/theme-state.js +3 -3
- package/dist/tools/approvals.service.js +6 -2
- package/dist/tools/builtins/skill-load.js +3 -2
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +1 -1
- package/dist/tools/tool-watch.service.js +3 -1
- package/package.json +3 -3
- package/src/migrations/0227_external_conversations.sql +33 -0
- package/src/migrations/0228_extension_org_switches.sql +56 -0
- package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
- package/src/migrations/0230_audit_filter_idx.sql +18 -0
|
@@ -15,9 +15,9 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
15
15
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
16
16
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
17
17
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
18
|
-
import { EffectiveConfigs } from "./effective-config.js";
|
|
19
18
|
import { enabledExtensionsQuery, isExtensionEnabled } from "./enabled.js";
|
|
20
19
|
import { OrgExtensionConfigs } from "./org-config.js";
|
|
20
|
+
import { ExtensionPointServing } from "./point-serving.js";
|
|
21
21
|
import { ExtensionRegistry } from "./registry.js";
|
|
22
22
|
/** The extension points whose provider each org chooses (`selection: "org-default"`). */
|
|
23
23
|
function selectionPoints() {
|
|
@@ -40,14 +40,16 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
40
40
|
txHost;
|
|
41
41
|
registry;
|
|
42
42
|
orgConfigs;
|
|
43
|
-
|
|
43
|
+
serving;
|
|
44
44
|
log;
|
|
45
|
-
constructor(kdb, txHost, registry, orgConfigs,
|
|
45
|
+
constructor(kdb, txHost, registry, orgConfigs,
|
|
46
|
+
/** One provider's candidacy (shared with the access checks, below the extensions module). */
|
|
47
|
+
serving, log) {
|
|
46
48
|
this.kdb = kdb;
|
|
47
49
|
this.txHost = txHost;
|
|
48
50
|
this.registry = registry;
|
|
49
51
|
this.orgConfigs = orgConfigs;
|
|
50
|
-
this.
|
|
52
|
+
this.serving = serving;
|
|
51
53
|
this.log = log;
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
@@ -167,7 +169,23 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
167
169
|
const out = [];
|
|
168
170
|
const failed = new Set();
|
|
169
171
|
for (const [extension, impl] of providers) {
|
|
170
|
-
|
|
172
|
+
let cfg;
|
|
173
|
+
try {
|
|
174
|
+
cfg = await this.orgConfigs.get(orgId, extension);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
this.log.warn("extension point provider excluded, cannot read whether it is enabled", {
|
|
178
|
+
orgId,
|
|
179
|
+
point,
|
|
180
|
+
extension,
|
|
181
|
+
err,
|
|
182
|
+
});
|
|
183
|
+
failed.add(extension);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (!cfg?.enabled)
|
|
187
|
+
continue;
|
|
188
|
+
const c = await this.serving.evaluate(orgId, point, extension, impl, failed, this.log);
|
|
171
189
|
if (c)
|
|
172
190
|
out.push(c);
|
|
173
191
|
}
|
|
@@ -175,77 +193,19 @@ let ExtensionPointDefaults = class ExtensionPointDefaults {
|
|
|
175
193
|
return { candidates: out, failed };
|
|
176
194
|
}
|
|
177
195
|
/**
|
|
178
|
-
* Whether the one provider `extension` of `point` evaluates as a candidate in `orgId
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* These are exactly the criteria of {@link providersFor} / {@link resolve}, with only that one
|
|
182
|
-
* provider evaluated. A provider whose status cannot be read counts as not serving (logged).
|
|
196
|
+
* Whether the one provider `extension` of `point` evaluates as a candidate in `orgId`: the
|
|
197
|
+
* criteria of {@link providersFor} / {@link resolve}, with only that provider evaluated
|
|
198
|
+
* ({@link ExtensionPointServing.serves}).
|
|
183
199
|
*/
|
|
184
200
|
async serves(orgId, point, extension) {
|
|
185
|
-
|
|
186
|
-
if (!entry || !(await isExtensionEnabled(this.kdb.db, orgId, extension)))
|
|
187
|
-
return false;
|
|
188
|
-
return (await this.evaluate(orgId, point, extension, entry.impl, new Set())) !== undefined;
|
|
201
|
+
return this.serving.serves(orgId, point, extension, this.log);
|
|
189
202
|
}
|
|
190
203
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* to `failed`.
|
|
204
|
+
* The one provider `extension` of `point` when it {@link serves} `orgId` now (same criteria),
|
|
205
|
+
* with its implementation and effective config for the org; null otherwise.
|
|
194
206
|
*/
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
try {
|
|
198
|
-
cfg = await this.orgConfigs.get(orgId, extension);
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
this.log.warn("extension point provider excluded, cannot read whether it is enabled", {
|
|
202
|
-
orgId,
|
|
203
|
-
point,
|
|
204
|
-
extension,
|
|
205
|
-
err,
|
|
206
|
-
});
|
|
207
|
-
failed.add(extension);
|
|
208
|
-
return undefined;
|
|
209
|
-
}
|
|
210
|
-
if (!cfg?.enabled)
|
|
211
|
-
return undefined;
|
|
212
|
-
// spec A §6: an org whose effective config is not valid gets no call from this extension
|
|
213
|
-
let effective;
|
|
214
|
-
try {
|
|
215
|
-
effective = await this.effective.get(orgId, extension);
|
|
216
|
-
}
|
|
217
|
-
catch (err) {
|
|
218
|
-
this.log.warn("extension point provider excluded, cannot read its effective config", {
|
|
219
|
-
orgId,
|
|
220
|
-
point,
|
|
221
|
-
extension,
|
|
222
|
-
err,
|
|
223
|
-
});
|
|
224
|
-
failed.add(extension);
|
|
225
|
-
return undefined;
|
|
226
|
-
}
|
|
227
|
-
if (!effective.ok)
|
|
228
|
-
return undefined;
|
|
229
|
-
const configured = impl.configured;
|
|
230
|
-
if (typeof configured === "function") {
|
|
231
|
-
let ok;
|
|
232
|
-
try {
|
|
233
|
-
ok = configured.call(impl, effective.config) !== false;
|
|
234
|
-
}
|
|
235
|
-
catch (err) {
|
|
236
|
-
this.log.warn("extension point provider excluded, configured() threw", {
|
|
237
|
-
orgId,
|
|
238
|
-
point,
|
|
239
|
-
extension,
|
|
240
|
-
err,
|
|
241
|
-
});
|
|
242
|
-
failed.add(extension);
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
if (!ok)
|
|
246
|
-
return undefined;
|
|
247
|
-
}
|
|
248
|
-
return { extension, impl, config: effective.config };
|
|
207
|
+
providerOf(orgId, point, extension) {
|
|
208
|
+
return this.serving.providerOf(orgId, point, extension, this.log);
|
|
249
209
|
}
|
|
250
210
|
async choose(orgId, point, candidates) {
|
|
251
211
|
if (candidates.length < 2)
|
|
@@ -271,7 +231,7 @@ ExtensionPointDefaults = __decorate([
|
|
|
271
231
|
__param(1, Inject(TransactionHost)),
|
|
272
232
|
__param(2, Inject(ExtensionRegistry)),
|
|
273
233
|
__param(3, Inject(OrgExtensionConfigs)),
|
|
274
|
-
__param(4, Inject(
|
|
234
|
+
__param(4, Inject(ExtensionPointServing)),
|
|
275
235
|
__param(5, Inject(KERNEL_LOGGER))
|
|
276
236
|
], ExtensionPointDefaults);
|
|
277
237
|
export { ExtensionPointDefaults };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
|
+
import type { KernelLogger } from "../log.js";
|
|
3
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
4
|
+
import { ExtensionRegistry } from "./registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* One provider of a multi-provider extension point for an org (`ExtensionPointDefaults`), with its
|
|
7
|
+
* effective deployment config for the org, to pass back to it.
|
|
8
|
+
*/
|
|
9
|
+
export interface PointProvider<T> {
|
|
10
|
+
extension: string;
|
|
11
|
+
impl: T;
|
|
12
|
+
config: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** A provider that could serve an org now, with its effective config for the org. */
|
|
15
|
+
export interface Candidate {
|
|
16
|
+
extension: string;
|
|
17
|
+
impl: unknown;
|
|
18
|
+
config: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Whether one provider of an extension point serves an org now (web tools spec §6, layering spec
|
|
22
|
+
* A §6): loaded on this replica and providing the point, enabled in the org, a valid effective
|
|
23
|
+
* config for the org, and `configured(config)` not false. Per call, never cached in process.
|
|
24
|
+
* `ExtensionPointDefaults` evaluates its candidates through it; it sits below the extensions
|
|
25
|
+
* module (registry, effective configs and the database only), so the conversation access check
|
|
26
|
+
* (an external conversation is visible while its target serves the org) can inject it without a
|
|
27
|
+
* module cycle (writing-kernel-api: a cycle is cut by a shared provider both sides inject).
|
|
28
|
+
*/
|
|
29
|
+
export declare class ExtensionPointServing {
|
|
30
|
+
private readonly kdb;
|
|
31
|
+
private readonly registry;
|
|
32
|
+
private readonly effective;
|
|
33
|
+
private readonly log;
|
|
34
|
+
constructor(kdb: KernelDb, registry: Pick<ExtensionRegistry, "list">, effective: Pick<EffectiveConfigs, "get">, log: KernelLogger);
|
|
35
|
+
/**
|
|
36
|
+
* Whether the one provider `extension` of `point` (the name without the major) serves `orgId`
|
|
37
|
+
* now. A provider whose status cannot be read counts as not serving (logged to `log`, the
|
|
38
|
+
* caller's context logger when it passes one).
|
|
39
|
+
*/
|
|
40
|
+
serves(orgId: string, point: string, extension: string, log?: KernelLogger): Promise<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* The one provider `extension` of `point` when it {@link serves} `orgId` now, with its
|
|
43
|
+
* implementation and effective config for the org; null otherwise.
|
|
44
|
+
*/
|
|
45
|
+
providerOf<T>(orgId: string, point: string, extension: string, log?: KernelLogger): Promise<PointProvider<T> | null>;
|
|
46
|
+
/**
|
|
47
|
+
* The candidacy of a provider the caller found enabled in the org: a valid effective config and
|
|
48
|
+
* `configured(config)` not false. Undefined when it is off; a provider whose status could not be
|
|
49
|
+
* read is also added to `failed` and logged to `log` (the caller's context logger, so the warning
|
|
50
|
+
* names the service that excluded it).
|
|
51
|
+
*/
|
|
52
|
+
evaluate(orgId: string, point: string, extension: string, impl: unknown, failed: Set<string>, log?: KernelLogger): Promise<Candidate | undefined>;
|
|
53
|
+
}
|
|
54
|
+
/** The one {@link ExtensionPointServing} (below `ExtensionsModule`, which re-exports it). */
|
|
55
|
+
export declare class ExtensionPointServingModule {
|
|
56
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
11
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
12
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
13
|
+
import { EffectiveConfigs } from "./effective-config.js";
|
|
14
|
+
import { isExtensionEnabled } from "./enabled.js";
|
|
15
|
+
import { ExtensionRegistry } from "./registry.js";
|
|
16
|
+
import { ExtensionStateModule } from "./state.module.js";
|
|
17
|
+
/**
|
|
18
|
+
* Whether one provider of an extension point serves an org now (web tools spec §6, layering spec
|
|
19
|
+
* A §6): loaded on this replica and providing the point, enabled in the org, a valid effective
|
|
20
|
+
* config for the org, and `configured(config)` not false. Per call, never cached in process.
|
|
21
|
+
* `ExtensionPointDefaults` evaluates its candidates through it; it sits below the extensions
|
|
22
|
+
* module (registry, effective configs and the database only), so the conversation access check
|
|
23
|
+
* (an external conversation is visible while its target serves the org) can inject it without a
|
|
24
|
+
* module cycle (writing-kernel-api: a cycle is cut by a shared provider both sides inject).
|
|
25
|
+
*/
|
|
26
|
+
let ExtensionPointServing = class ExtensionPointServing {
|
|
27
|
+
kdb;
|
|
28
|
+
registry;
|
|
29
|
+
effective;
|
|
30
|
+
log;
|
|
31
|
+
constructor(kdb, registry, effective, log) {
|
|
32
|
+
this.kdb = kdb;
|
|
33
|
+
this.registry = registry;
|
|
34
|
+
this.effective = effective;
|
|
35
|
+
this.log = log;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether the one provider `extension` of `point` (the name without the major) serves `orgId`
|
|
39
|
+
* now. A provider whose status cannot be read counts as not serving (logged to `log`, the
|
|
40
|
+
* caller's context logger when it passes one).
|
|
41
|
+
*/
|
|
42
|
+
async serves(orgId, point, extension, log = this.log) {
|
|
43
|
+
return (await this.providerOf(orgId, point, extension, log)) !== null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The one provider `extension` of `point` when it {@link serves} `orgId` now, with its
|
|
47
|
+
* implementation and effective config for the org; null otherwise.
|
|
48
|
+
*/
|
|
49
|
+
async providerOf(orgId, point, extension, log = this.log) {
|
|
50
|
+
const entry = this.registry.list(point).find((e) => e.plugin === extension);
|
|
51
|
+
if (!entry || !(await isExtensionEnabled(this.kdb.db, orgId, extension)))
|
|
52
|
+
return null;
|
|
53
|
+
const c = await this.evaluate(orgId, point, extension, entry.impl, new Set(), log);
|
|
54
|
+
return c === undefined ? null : { extension: c.extension, impl: c.impl, config: c.config };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The candidacy of a provider the caller found enabled in the org: a valid effective config and
|
|
58
|
+
* `configured(config)` not false. Undefined when it is off; a provider whose status could not be
|
|
59
|
+
* read is also added to `failed` and logged to `log` (the caller's context logger, so the warning
|
|
60
|
+
* names the service that excluded it).
|
|
61
|
+
*/
|
|
62
|
+
async evaluate(orgId, point, extension, impl, failed, log = this.log) {
|
|
63
|
+
// spec A §6: an org whose effective config is not valid gets no call from this extension
|
|
64
|
+
let effective;
|
|
65
|
+
try {
|
|
66
|
+
effective = await this.effective.get(orgId, extension);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
log.warn("extension point provider excluded, cannot read its effective config", {
|
|
70
|
+
orgId,
|
|
71
|
+
point,
|
|
72
|
+
extension,
|
|
73
|
+
err,
|
|
74
|
+
});
|
|
75
|
+
failed.add(extension);
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (!effective.ok)
|
|
79
|
+
return undefined;
|
|
80
|
+
const configured = impl.configured;
|
|
81
|
+
if (typeof configured === "function") {
|
|
82
|
+
let ok;
|
|
83
|
+
try {
|
|
84
|
+
ok = configured.call(impl, effective.config) !== false;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
log.warn("extension point provider excluded, configured() threw", {
|
|
88
|
+
orgId,
|
|
89
|
+
point,
|
|
90
|
+
extension,
|
|
91
|
+
err,
|
|
92
|
+
});
|
|
93
|
+
failed.add(extension);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
if (!ok)
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return { extension, impl, config: effective.config };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
ExtensionPointServing = __decorate([
|
|
103
|
+
Injectable(),
|
|
104
|
+
__param(0, Inject(KernelDb)),
|
|
105
|
+
__param(1, Inject(ExtensionRegistry)),
|
|
106
|
+
__param(2, Inject(EffectiveConfigs)),
|
|
107
|
+
__param(3, Inject(KERNEL_LOGGER))
|
|
108
|
+
], ExtensionPointServing);
|
|
109
|
+
export { ExtensionPointServing };
|
|
110
|
+
/** The one {@link ExtensionPointServing} (below `ExtensionsModule`, which re-exports it). */
|
|
111
|
+
let ExtensionPointServingModule = class ExtensionPointServingModule {
|
|
112
|
+
};
|
|
113
|
+
ExtensionPointServingModule = __decorate([
|
|
114
|
+
Module({
|
|
115
|
+
imports: [ExtensionStateModule],
|
|
116
|
+
providers: [ExtensionPointServing],
|
|
117
|
+
exports: [ExtensionPointServing],
|
|
118
|
+
})
|
|
119
|
+
], ExtensionPointServingModule);
|
|
120
|
+
export { ExtensionPointServingModule };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
type SourceMode = "standalone" | "single" | "multiple" | "retired" | "locked";
|
|
3
|
+
interface SourceIntent {
|
|
4
|
+
mode: SourceMode;
|
|
5
|
+
defaults: {
|
|
6
|
+
org_id: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
/** Capture effective defaults before a source association changes under the extension install lock. */
|
|
11
|
+
export declare function captureSourceIntent(db: KernelSchemaDb, plugin: string, change: "add" | "retire"): Promise<SourceIntent>;
|
|
12
|
+
/** Keep prior defaults when the new source shape authorizes the same state. */
|
|
13
|
+
export declare function restoreSourceIntent(db: KernelSchemaDb, plugin: string, before: SourceIntent, actor: string | null): Promise<void>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { asPlatform } from "../infra/database/org-scope.js";
|
|
3
|
+
import { alwaysOnExtensionsQuery, extensionIntent, extensionSwitch } from "./enabled.js";
|
|
4
|
+
import { extensionSourcesQuery } from "./plugin-items.js";
|
|
5
|
+
async function sourceMode(db, plugin) {
|
|
6
|
+
const alwaysOn = await alwaysOnExtensionsQuery(db, plugin).executeTakeFirst();
|
|
7
|
+
if (alwaysOn)
|
|
8
|
+
return "locked";
|
|
9
|
+
const { sources, live } = await db
|
|
10
|
+
.selectFrom(extensionSourcesQuery(db, plugin).as("source"))
|
|
11
|
+
.innerJoin("catalog_items as item", "item.id", "source.item_id")
|
|
12
|
+
.select(({ fn, eb }) => [
|
|
13
|
+
fn.countAll().as("sources"),
|
|
14
|
+
fn
|
|
15
|
+
.countAll()
|
|
16
|
+
.filterWhere(eb("item.deleted_at", "is", null))
|
|
17
|
+
.as("live"),
|
|
18
|
+
])
|
|
19
|
+
.executeTakeFirstOrThrow();
|
|
20
|
+
if (Number(sources) === 0)
|
|
21
|
+
return "standalone";
|
|
22
|
+
if (Number(live) === 0)
|
|
23
|
+
return "retired";
|
|
24
|
+
return Number(live) === 1 ? "single" : "multiple";
|
|
25
|
+
}
|
|
26
|
+
/** Capture effective defaults before a source association changes under the extension install lock. */
|
|
27
|
+
export function captureSourceIntent(db, plugin, change) {
|
|
28
|
+
// org-filter: deployment-wide conversion of default extension intent after changing its sources
|
|
29
|
+
return asPlatform("capture extension intent before changing sources", async () => {
|
|
30
|
+
const mode = await sourceMode(db, plugin);
|
|
31
|
+
const canChangeDefault = change === "add" ? mode === "standalone" || mode === "single" : mode === "multiple";
|
|
32
|
+
if (!canChangeDefault)
|
|
33
|
+
return { mode, defaults: [] };
|
|
34
|
+
const defaults = await db
|
|
35
|
+
.selectFrom("orgs")
|
|
36
|
+
.select("orgs.id as org_id")
|
|
37
|
+
.select(({ ref }) => extensionIntent(db, ref("orgs.id"), plugin).as("enabled"))
|
|
38
|
+
.where("deleted_at", "is", null)
|
|
39
|
+
.where(({ ref, not, exists }) => not(exists(extensionSwitch(db, ref("orgs.id"), plugin))))
|
|
40
|
+
.execute();
|
|
41
|
+
return { mode, defaults };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Keep prior defaults when the new source shape authorizes the same state. */
|
|
45
|
+
export async function restoreSourceIntent(db, plugin, before, actor) {
|
|
46
|
+
if (before.defaults.length === 0)
|
|
47
|
+
return;
|
|
48
|
+
// org-filter: deployment-wide conversion of default extension intent after changing its sources
|
|
49
|
+
await asPlatform("preserve extension intent across source changes", async () => {
|
|
50
|
+
const mode = await sourceMode(db, plugin);
|
|
51
|
+
if (mode === before.mode || mode === "retired" || mode === "locked")
|
|
52
|
+
return;
|
|
53
|
+
const enabled = mode !== "single";
|
|
54
|
+
const affected = before.defaults
|
|
55
|
+
.filter((choice) => choice.enabled === enabled)
|
|
56
|
+
.map((choice) => choice.org_id);
|
|
57
|
+
if (affected.length === 0)
|
|
58
|
+
return;
|
|
59
|
+
await db
|
|
60
|
+
.insertInto("component_org_switches")
|
|
61
|
+
.columns(["kind", "component_id", "org_id", "enabled", "updated_by"])
|
|
62
|
+
.expression(db
|
|
63
|
+
.selectFrom("orgs")
|
|
64
|
+
.select([
|
|
65
|
+
sql `'extension'`.as("kind"),
|
|
66
|
+
sql `${plugin}`.as("component_id"),
|
|
67
|
+
"orgs.id as org_id",
|
|
68
|
+
sql `${enabled}::boolean`.as("enabled"),
|
|
69
|
+
sql `${actor}`.as("updated_by"),
|
|
70
|
+
])
|
|
71
|
+
.where(sql `orgs.id = ANY(${affected}::text[])`)
|
|
72
|
+
.where(({ ref }) => sql `${extensionIntent(db, ref("orgs.id"), plugin)} <> ${enabled}`)
|
|
73
|
+
.where(({ ref }) => sql `${extensionIntent(db, ref("orgs.id"), plugin, enabled)} = ${enabled}`))
|
|
74
|
+
.onConflict((conflict) => conflict.columns(["kind", "component_id", "org_id"]).doNothing())
|
|
75
|
+
.execute();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -93,6 +93,17 @@ export declare class InboxItemsService {
|
|
|
93
93
|
* unknown id throws `InboxError("not_found")`. The caller runs it in the org's scope.
|
|
94
94
|
*/
|
|
95
95
|
resolveForPlugin(plugin: string, orgId: string, itemId: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Resolves the open kernel item of `accountId` in `orgId` posted with `dedupeKey` (the thing it
|
|
98
|
+
* asked about was settled elsewhere); none open is no change. The caller runs it in the org's
|
|
99
|
+
* scope.
|
|
100
|
+
*/
|
|
101
|
+
resolveKernelItem(orgId: string, accountId: string, dedupeKey: string): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Resolves every open kernel item of `accountId` in `orgId` whose dedupe key starts with
|
|
104
|
+
* `prefix` (the things they asked about are gone). The caller runs it in the org's scope.
|
|
105
|
+
*/
|
|
106
|
+
resolveKernelItems(orgId: string, accountId: string, prefix: string): Promise<void>;
|
|
96
107
|
/** Marks an open item resolved; whether it was open. */
|
|
97
108
|
close(orgId: string, itemId: string): Promise<boolean>;
|
|
98
109
|
/** The open, unexpired item `itemId` of `accountId` in `orgId`, or `inbox.item_not_found`. */
|
|
@@ -222,6 +222,39 @@ let InboxItemsService = class InboxItemsService {
|
|
|
222
222
|
throw new InboxError("not_found", "inbox item not found");
|
|
223
223
|
await this.close(orgId, itemId);
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Resolves the open kernel item of `accountId` in `orgId` posted with `dedupeKey` (the thing it
|
|
227
|
+
* asked about was settled elsewhere); none open is no change. The caller runs it in the org's
|
|
228
|
+
* scope.
|
|
229
|
+
*/
|
|
230
|
+
async resolveKernelItem(orgId, accountId, dedupeKey) {
|
|
231
|
+
await this.kdb.db
|
|
232
|
+
.updateTable("inbox_items")
|
|
233
|
+
.set({ state: "resolved", resolved_at: sql `now()` })
|
|
234
|
+
.where("org_id", "=", orgId)
|
|
235
|
+
.where("account_id", "=", accountId)
|
|
236
|
+
.where("source", "=", "kernel")
|
|
237
|
+
.where("plugin", "is", null)
|
|
238
|
+
.where("dedupe_key", "=", dedupeKey)
|
|
239
|
+
.where("state", "=", "open")
|
|
240
|
+
.execute();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Resolves every open kernel item of `accountId` in `orgId` whose dedupe key starts with
|
|
244
|
+
* `prefix` (the things they asked about are gone). The caller runs it in the org's scope.
|
|
245
|
+
*/
|
|
246
|
+
async resolveKernelItems(orgId, accountId, prefix) {
|
|
247
|
+
await this.kdb.db
|
|
248
|
+
.updateTable("inbox_items")
|
|
249
|
+
.set({ state: "resolved", resolved_at: sql `now()` })
|
|
250
|
+
.where("org_id", "=", orgId)
|
|
251
|
+
.where("account_id", "=", accountId)
|
|
252
|
+
.where("source", "=", "kernel")
|
|
253
|
+
.where("plugin", "is", null)
|
|
254
|
+
.where(sql `starts_with(dedupe_key, ${prefix})`)
|
|
255
|
+
.where("state", "=", "open")
|
|
256
|
+
.execute();
|
|
257
|
+
}
|
|
225
258
|
/** Marks an open item resolved; whether it was open. */
|
|
226
259
|
async close(orgId, itemId) {
|
|
227
260
|
const r = await this.kdb.db
|
|
@@ -326,6 +359,12 @@ __decorate([
|
|
|
326
359
|
__decorate([
|
|
327
360
|
Transactional()
|
|
328
361
|
], InboxItemsService.prototype, "resolveForPlugin", null);
|
|
362
|
+
__decorate([
|
|
363
|
+
Transactional()
|
|
364
|
+
], InboxItemsService.prototype, "resolveKernelItem", null);
|
|
365
|
+
__decorate([
|
|
366
|
+
Transactional()
|
|
367
|
+
], InboxItemsService.prototype, "resolveKernelItems", null);
|
|
329
368
|
__decorate([
|
|
330
369
|
Transactional()
|
|
331
370
|
], InboxItemsService.prototype, "close", null);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SetupService } from "./admin/setup.service.js";
|
|
2
|
-
export { closeKernelApp, createKernelApp, type KernelAppOptions, kernelAppHttp, kernelAppPort, startKernelApp, } from "./app.js";
|
|
2
|
+
export { closeKernelApp, createKernelApp, KERNEL_FIXTURE_TRUST, type KernelAppOptions, kernelAppHttp, kernelAppPort, startKernelApp, } from "./app.js";
|
|
3
3
|
export { type CatalogCli, openCatalogCli } from "./catalog/cli.js";
|
|
4
4
|
export { GitSourceError, type ReadGitTreeOptions, readGitTree, } from "./catalog/git-source.js";
|
|
5
5
|
export type { PluginConfirmResult, PluginReview } from "./catalog/plugin-import.js";
|
|
@@ -21,6 +21,7 @@ export { createLock } from "./ctx/lock.js";
|
|
|
21
21
|
export { createQueue } from "./ctx/queue.js";
|
|
22
22
|
export { createKeyring, createSecrets, type DerivedKeys, type Keyring, REWRAP_BATCH_SIZE, type RewrapResult, rewrapToCurrentMasterKey, } from "./ctx/secrets.js";
|
|
23
23
|
export { extensionDbIdentity } from "./db/extension-db.js";
|
|
24
|
+
export { provisionExtensionHandoff } from "./db/extension-handoff-schema.js";
|
|
24
25
|
export { createProvisionedExtensionSchema, provisionExtensionRole, } from "./db/extension-role-provision.js";
|
|
25
26
|
export { type KernelDatabase, type KernelSchemaDb, kernelDb } from "./db/kernel-schema.js";
|
|
26
27
|
export { type MigrationOwner, migrate } from "./db/migrator.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SetupService } from "./admin/setup.service.js";
|
|
2
|
-
export { closeKernelApp, createKernelApp, kernelAppHttp, kernelAppPort, startKernelApp, } from "./app.js";
|
|
2
|
+
export { closeKernelApp, createKernelApp, KERNEL_FIXTURE_TRUST, kernelAppHttp, kernelAppPort, startKernelApp, } from "./app.js";
|
|
3
3
|
export { openCatalogCli } from "./catalog/cli.js";
|
|
4
4
|
// The git reader marketplaces use; core's check:bootstrap reads the official marketplace with it.
|
|
5
5
|
export { GitSourceError, readGitTree, } from "./catalog/git-source.js";
|
|
@@ -20,6 +20,7 @@ export { createLock } from "./ctx/lock.js";
|
|
|
20
20
|
export { createQueue } from "./ctx/queue.js";
|
|
21
21
|
export { createKeyring, createSecrets, REWRAP_BATCH_SIZE, rewrapToCurrentMasterKey, } from "./ctx/secrets.js";
|
|
22
22
|
export { extensionDbIdentity } from "./db/extension-db.js";
|
|
23
|
+
export { provisionExtensionHandoff } from "./db/extension-handoff-schema.js";
|
|
23
24
|
export { createProvisionedExtensionSchema, provisionExtensionRole, } from "./db/extension-role-provision.js";
|
|
24
25
|
export { kernelDb } from "./db/kernel-schema.js";
|
|
25
26
|
export { migrate } from "./db/migrator.js";
|
|
@@ -65,7 +65,12 @@ let DatabaseModule = class DatabaseModule {
|
|
|
65
65
|
inject: [KernelConfigService, KERNEL_LOGGER],
|
|
66
66
|
useFactory: (config, log) => {
|
|
67
67
|
const { db } = config.get();
|
|
68
|
-
|
|
68
|
+
// Set the runtime planner option in the startup packet. JIT compilation can dominate
|
|
69
|
+
// short queries with correlated permission checks.
|
|
70
|
+
const url = new URL(db.url);
|
|
71
|
+
const options = url.searchParams.get("options") ?? process.env.PGOPTIONS;
|
|
72
|
+
url.searchParams.set("options", options ? `${options} -c jit=off` : "-c jit=off");
|
|
73
|
+
return createDb(url.toString(), db.poolMax, (err) => log.error("pg idle client error", { err }), {
|
|
69
74
|
connectTimeoutMs: db.connectTimeoutMs,
|
|
70
75
|
idleTimeoutMs: db.idleTimeoutMs,
|
|
71
76
|
onClientError: (err) => log.warn("pg client error", { err }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Kysely, Transaction } from "kysely";
|
|
2
|
-
import { type KernelDatabase } from "../../db/kernel-schema.js";
|
|
2
|
+
import { type KernelDatabase, type KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
3
3
|
import { TransactionHost } from "./transaction-host.js";
|
|
4
4
|
type View = Kysely<KernelDatabase>;
|
|
5
5
|
/** The Kysely query entry points services use; each resolves to the context transaction or the pool. */
|
|
@@ -19,4 +19,6 @@ export declare class KernelDb {
|
|
|
19
19
|
/** The kernel-schema handle of the current context (transaction or pool). */
|
|
20
20
|
get db(): View | Transaction<KernelDatabase>;
|
|
21
21
|
}
|
|
22
|
+
/** Run a CLI migration backfill before the application and its transaction provider exist. */
|
|
23
|
+
export declare function runMigrationBackfill(pool: View, backfill: (db: KernelSchemaDb) => Promise<void>): Promise<void>;
|
|
22
24
|
export {};
|
|
@@ -63,3 +63,7 @@ Object.defineProperty(KernelDb.prototype, "fn", {
|
|
|
63
63
|
return this.db.fn;
|
|
64
64
|
},
|
|
65
65
|
});
|
|
66
|
+
/** Run a CLI migration backfill before the application and its transaction provider exist. */
|
|
67
|
+
export async function runMigrationBackfill(pool, backfill) {
|
|
68
|
+
await pool.transaction().execute((trx) => backfill(kernelDb(trx)));
|
|
69
|
+
}
|
|
@@ -610,6 +610,76 @@ export declare const OUTBOX_JOBS: {
|
|
|
610
610
|
readonly removeOnFail: true;
|
|
611
611
|
};
|
|
612
612
|
};
|
|
613
|
+
readonly "external-start": {
|
|
614
|
+
readonly queue: "cap-external-calls";
|
|
615
|
+
readonly idempotent: "the delivery goes only while its deliverySeq is the next after the conversation's cursor, which it moves when done; the target's start is idempotent by messageId";
|
|
616
|
+
readonly processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts";
|
|
617
|
+
readonly opts: {
|
|
618
|
+
readonly attempts: 10;
|
|
619
|
+
readonly backoff: {
|
|
620
|
+
readonly type: "exponential";
|
|
621
|
+
readonly delay: 2000;
|
|
622
|
+
};
|
|
623
|
+
readonly removeOnComplete: true;
|
|
624
|
+
readonly removeOnFail: true;
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
readonly "external-send": {
|
|
628
|
+
readonly queue: "cap-external-calls";
|
|
629
|
+
readonly idempotent: "the delivery goes only while its deliverySeq is the next after the conversation's cursor, which it moves when done; the target's send is idempotent by messageId";
|
|
630
|
+
readonly processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts";
|
|
631
|
+
readonly opts: {
|
|
632
|
+
readonly attempts: 10;
|
|
633
|
+
readonly backoff: {
|
|
634
|
+
readonly type: "exponential";
|
|
635
|
+
readonly delay: 2000;
|
|
636
|
+
};
|
|
637
|
+
readonly removeOnComplete: true;
|
|
638
|
+
readonly removeOnFail: true;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
readonly "external-answer": {
|
|
642
|
+
readonly queue: "cap-external-calls";
|
|
643
|
+
readonly idempotent: "the answer is written once per request (its idempotency key); the target's answer is idempotent by requestId";
|
|
644
|
+
readonly processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts";
|
|
645
|
+
readonly opts: {
|
|
646
|
+
readonly attempts: 10;
|
|
647
|
+
readonly backoff: {
|
|
648
|
+
readonly type: "exponential";
|
|
649
|
+
readonly delay: 2000;
|
|
650
|
+
};
|
|
651
|
+
readonly removeOnComplete: true;
|
|
652
|
+
readonly removeOnFail: true;
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
readonly "external-stop": {
|
|
656
|
+
readonly queue: "cap-external-calls";
|
|
657
|
+
readonly idempotent: "stopping a turn that is not running is a no-op for the target; the job id is per conversation and last seq";
|
|
658
|
+
readonly processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts";
|
|
659
|
+
readonly opts: {
|
|
660
|
+
readonly attempts: 10;
|
|
661
|
+
readonly backoff: {
|
|
662
|
+
readonly type: "exponential";
|
|
663
|
+
readonly delay: 2000;
|
|
664
|
+
};
|
|
665
|
+
readonly removeOnComplete: true;
|
|
666
|
+
readonly removeOnFail: true;
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
readonly "external-deleted": {
|
|
670
|
+
readonly queue: "cap-external-calls";
|
|
671
|
+
readonly idempotent: "releasing what the target holds for a deleted conversation twice releases nothing more; the job id is per conversation and last seq";
|
|
672
|
+
readonly processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts";
|
|
673
|
+
readonly opts: {
|
|
674
|
+
readonly attempts: 10;
|
|
675
|
+
readonly backoff: {
|
|
676
|
+
readonly type: "exponential";
|
|
677
|
+
readonly delay: 2000;
|
|
678
|
+
};
|
|
679
|
+
readonly removeOnComplete: true;
|
|
680
|
+
readonly removeOnFail: true;
|
|
681
|
+
};
|
|
682
|
+
};
|
|
613
683
|
readonly "hook-run-lifecycle": {
|
|
614
684
|
readonly queue: "cap-kernel-lifecycle";
|
|
615
685
|
readonly idempotent: "the `run.lifecycle` handler sets a display state keyed by the run and phase (the SDK contract: handlers are idempotent); the job id is deterministic per run, phase and wait";
|