@capybara-hq/kernel 0.1.0-rc.136 → 0.1.0-rc.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/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/extensions.controller.d.ts +5 -2
- package/dist/admin/extensions.controller.js +10 -1
- package/dist/admin/extensions.schemas.d.ts +4 -0
- package/dist/admin/extensions.schemas.js +9 -0
- package/dist/admin/health.service.d.ts +1 -1
- package/dist/admin/health.service.js +3 -3
- package/dist/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 +6 -8
- 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 +109 -145
- package/dist/catalog/catalog.module.js +7 -4
- package/dist/catalog/catalog.service.d.ts +10 -4
- package/dist/catalog/catalog.service.js +52 -10
- 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/effect-work.d.ts +27 -0
- package/dist/catalog/effect-work.js +151 -0
- package/dist/catalog/jobs.d.ts +4 -1
- package/dist/catalog/jobs.js +14 -4
- package/dist/catalog/org-catalog.service.d.ts +5 -1
- package/dist/catalog/org-catalog.service.js +101 -106
- package/dist/catalog/org-intent.d.ts +45 -0
- package/dist/catalog/org-intent.js +205 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +27 -32
- 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.d.ts +4 -2
- package/dist/catalog/plugin-import.js +22 -21
- package/dist/catalog/plugin-install.d.ts +19 -54
- package/dist/catalog/plugin-install.js +221 -271
- package/dist/catalog/plugin-upgrade.d.ts +10 -5
- package/dist/catalog/plugin-upgrade.js +80 -67
- 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-workers.d.ts +7 -11
- package/dist/catalog/scope-sync-workers.js +10 -26
- package/dist/catalog/scope-sync.d.ts +19 -116
- package/dist/catalog/scope-sync.js +228 -275
- package/dist/catalog/scope-writer.d.ts +87 -0
- package/dist/catalog/scope-writer.js +239 -0
- package/dist/catalog/template-connector-ensure.js +1 -1
- package/dist/catalog/unshare.js +9 -43
- 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 +32 -1
- package/dist/ctx/create-ctx.d.ts +2 -2
- package/dist/ctx/create-ctx.js +2 -60
- 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 +32 -6
- package/dist/device-access/host-services.d.ts +2 -2
- package/dist/device-access/host-services.js +5 -6
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +7 -0
- package/dist/extensions/admin-ops.d.ts +10 -6
- package/dist/extensions/admin-ops.js +53 -9
- package/dist/extensions/admin-view.d.ts +4 -1
- package/dist/extensions/admin-view.js +27 -14
- package/dist/extensions/bootstrap.d.ts +1 -1
- package/dist/extensions/bootstrap.js +6 -4
- package/dist/extensions/cli.js +1 -0
- package/dist/extensions/effective-config.js +1 -4
- package/dist/extensions/enabled.d.ts +183 -29
- package/dist/extensions/enabled.js +148 -62
- package/dist/extensions/host.d.ts +65 -45
- package/dist/extensions/host.js +446 -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 +45 -0
- package/dist/extensions/isolated/authorization.js +191 -0
- package/dist/extensions/isolated/broker.d.ts +15 -0
- package/dist/extensions/isolated/broker.js +471 -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/engine-binds.d.ts +9 -0
- package/dist/extensions/isolated/engine-binds.js +82 -0
- package/dist/extensions/isolated/engine-policy.d.ts +85 -0
- package/dist/extensions/isolated/engine-policy.js +75 -0
- package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
- package/dist/extensions/isolated/engine-proxy-main.js +20 -0
- package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
- package/dist/extensions/isolated/engine-proxy.js +408 -0
- package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
- package/dist/extensions/isolated/engine-vaults.js +93 -0
- package/dist/extensions/isolated/lanes.d.ts +108 -0
- package/dist/extensions/isolated/lanes.js +726 -0
- package/dist/extensions/isolated/postgres-gate.d.ts +15 -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 +359 -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 +39 -0
- package/dist/extensions/isolated/sandbox.js +356 -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 +2 -0
- package/dist/extensions/lifecycle-topics.js +2 -0
- package/dist/extensions/lifecycle.d.ts +3 -1
- package/dist/extensions/lifecycle.js +53 -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 +6 -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/source-intent.d.ts +14 -0
- package/dist/extensions/source-intent.js +77 -0
- package/dist/inbox/platform-inbox.service.js +16 -27
- 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/events/kernel-events.d.ts +4 -0
- package/dist/infra/outbox/registry.d.ts +3 -36
- package/dist/infra/outbox/registry.js +4 -49
- package/dist/infra/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 -1
- package/dist/kernel.d.ts +3 -2
- package/dist/kernel.js +21 -2
- 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/orgs/org-lock.d.ts +3 -1
- package/dist/orgs/org-lock.js +3 -1
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +15 -8
- package/dist/overrides.d.ts +0 -3
- package/dist/overrides.js +0 -2
- package/dist/platform/ops/admin.ops.js +14 -3
- package/dist/platform/ops/extensions-admin.ops.js +20 -3
- package/dist/platform/ops/org-plugins.ops.js +5 -2
- package/dist/platform/ops/orgs.ops.js +13 -3
- package/dist/platform/ops/plugins.ops.js +11 -10
- 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/registry.d.ts +2 -2
- package/dist/tools/registry.js +7 -3
- package/package.json +2 -2
- 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
- package/src/migrations/0231_plugin_effect_work.sql +171 -0
- package/dist/catalog/install-status.d.ts +0 -6
- package/dist/catalog/install-status.js +0 -6
- package/dist/catalog/scope-jobs.d.ts +0 -59
- package/dist/catalog/scope-jobs.js +0 -78
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
3
|
+
import { PluginInstallLock } from "../extensions/locks.js";
|
|
4
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
5
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
7
|
+
import { XactLock } from "../infra/database/xact-lock.js";
|
|
8
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
9
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
10
|
+
import type { ComponentKind } from "./component-state.js";
|
|
11
|
+
import type { PluginScope } from "./scope.js";
|
|
12
|
+
export declare const COMPONENT_SCOPE_TABLE: {
|
|
13
|
+
readonly skill: "platform_skills";
|
|
14
|
+
readonly agent_template: "platform_agent_templates";
|
|
15
|
+
readonly connector_template: "platform_connector_templates";
|
|
16
|
+
readonly theme: "platform_themes";
|
|
17
|
+
};
|
|
18
|
+
type ScopeSubject = {
|
|
19
|
+
kind: "plugin" | ComponentKind;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
/** Persist one component choice in the caller's org transaction. */
|
|
23
|
+
export declare function writeComponentSwitch(db: KernelSchemaDb, subject: {
|
|
24
|
+
kind: ComponentKind | "extension";
|
|
25
|
+
id: string;
|
|
26
|
+
}, orgId: string, enabled: boolean, actor: string | null): Promise<void>;
|
|
27
|
+
type ScopeListChange = {
|
|
28
|
+
kind: "plugin";
|
|
29
|
+
id: string;
|
|
30
|
+
scope: PluginScope;
|
|
31
|
+
orgs: readonly string[];
|
|
32
|
+
} | ({
|
|
33
|
+
kind: ComponentKind;
|
|
34
|
+
id: string;
|
|
35
|
+
orgs: readonly string[];
|
|
36
|
+
} & ({
|
|
37
|
+
scopeMode: "own" | "follow";
|
|
38
|
+
scope: PluginScope;
|
|
39
|
+
} | {
|
|
40
|
+
scopeMode: "follow";
|
|
41
|
+
scope?: never;
|
|
42
|
+
}));
|
|
43
|
+
/** Apply a typed scope change in the caller's transaction and under its target lock. */
|
|
44
|
+
export declare function writeScope(db: KernelSchemaDb, change: ScopeListChange): Promise<void>;
|
|
45
|
+
/** Extend a named plugin scope under its item lock. */
|
|
46
|
+
export declare function addNamedPluginOrg(db: KernelSchemaDb, itemId: string, orgId: string): Promise<boolean>;
|
|
47
|
+
type ScopeConfirmation = {
|
|
48
|
+
kind: "scope";
|
|
49
|
+
hash: string;
|
|
50
|
+
} | {
|
|
51
|
+
kind: "disable";
|
|
52
|
+
hash: string | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
kind: "enable";
|
|
55
|
+
};
|
|
56
|
+
interface ScopePreview<Conflict> {
|
|
57
|
+
scopeHash: string;
|
|
58
|
+
conflicts: Conflict[];
|
|
59
|
+
}
|
|
60
|
+
interface PreparedScopeWrite<Result, Conflict> {
|
|
61
|
+
preview: ScopePreview<Conflict>;
|
|
62
|
+
conflict: (conflicts: Conflict[]) => ApiError;
|
|
63
|
+
apply: () => Promise<Result>;
|
|
64
|
+
}
|
|
65
|
+
export declare function assertScopePreview<Conflict>(confirmation: ScopeConfirmation, preview: ScopePreview<Conflict>, conflict: (conflicts: Conflict[]) => ApiError): void;
|
|
66
|
+
/** Authorize and confirm a platform scope change in the transaction that applies it. */
|
|
67
|
+
export declare class ScopeWriter {
|
|
68
|
+
private readonly kdb;
|
|
69
|
+
private readonly installLock;
|
|
70
|
+
private readonly xactLock;
|
|
71
|
+
private readonly outbox;
|
|
72
|
+
private readonly adminLock;
|
|
73
|
+
readonly txHost: TransactionHost;
|
|
74
|
+
private readonly events;
|
|
75
|
+
constructor(kdb: KernelDb, installLock: PluginInstallLock, xactLock: XactLock, outbox: OutboxService, adminLock: SuperAdminLock, txHost: TransactionHost, events: KernelEvents);
|
|
76
|
+
platformChange<Result, Conflict>(actor: string, confirmation: ScopeConfirmation, prepare: () => Promise<PreparedScopeWrite<Result, Conflict> | undefined>): Promise<Result | undefined>;
|
|
77
|
+
/** Persist the scope and its named list together after platform confirmation. */
|
|
78
|
+
replaceScope(change: ScopeListChange): Promise<void>;
|
|
79
|
+
/** Persist deployment enablement after platform confirmation. */
|
|
80
|
+
setDisabled(subject: ScopeSubject, disabled: boolean): Promise<void>;
|
|
81
|
+
/** Store local intent under the caller's transaction and org lock. */
|
|
82
|
+
setOrgSwitch(subject: ScopeSubject, orgId: string, enabled: boolean, actor: string | null): Promise<void>;
|
|
83
|
+
private oweConnectorTemplate;
|
|
84
|
+
/** Catalog switches can change the intent of extensions brought in through a dependency. */
|
|
85
|
+
refreshIsolatedOrgIntent(orgId?: string): void;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
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 } from "@nestjs/common";
|
|
11
|
+
import { sql } from "kysely";
|
|
12
|
+
import { ApiError } from "../errors.js";
|
|
13
|
+
import { PluginInstallLock } from "../extensions/locks.js";
|
|
14
|
+
import { extensionSourcesQuery } from "../extensions/plugin-items.js";
|
|
15
|
+
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
16
|
+
import { afterCommit } from "../infra/database/after-commit.js";
|
|
17
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
18
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
19
|
+
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
|
+
import { XactLock } from "../infra/database/xact-lock.js";
|
|
21
|
+
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
22
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
23
|
+
import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
|
|
24
|
+
export const COMPONENT_SCOPE_TABLE = {
|
|
25
|
+
skill: "platform_skills",
|
|
26
|
+
agent_template: "platform_agent_templates",
|
|
27
|
+
connector_template: "platform_connector_templates",
|
|
28
|
+
theme: "platform_themes",
|
|
29
|
+
};
|
|
30
|
+
/** Persist one component choice in the caller's org transaction. */
|
|
31
|
+
export async function writeComponentSwitch(db, subject, orgId, enabled, actor) {
|
|
32
|
+
await db
|
|
33
|
+
.insertInto("component_org_switches")
|
|
34
|
+
.values({
|
|
35
|
+
kind: subject.kind,
|
|
36
|
+
component_id: subject.id,
|
|
37
|
+
org_id: orgId,
|
|
38
|
+
enabled,
|
|
39
|
+
updated_by: actor,
|
|
40
|
+
})
|
|
41
|
+
.onConflict((oc) => oc.columns(["kind", "component_id", "org_id"]).doUpdateSet({
|
|
42
|
+
enabled,
|
|
43
|
+
updated_by: actor,
|
|
44
|
+
updated_at: sql `now()`,
|
|
45
|
+
}))
|
|
46
|
+
.execute();
|
|
47
|
+
}
|
|
48
|
+
/** Apply a typed scope change in the caller's transaction and under its target lock. */
|
|
49
|
+
export async function writeScope(db, change) {
|
|
50
|
+
const { kind, id, scope, orgs } = change;
|
|
51
|
+
const updated_at = sql `now()`;
|
|
52
|
+
if (kind === "plugin") {
|
|
53
|
+
await db.updateTable("catalog_items").set({ scope, updated_at }).where("id", "=", id).execute();
|
|
54
|
+
// org-filter: a platform scope confirmation replaces the named list across organizations.
|
|
55
|
+
await db.deleteFrom("catalog_item_scope_orgs").where("item_id", "=", id).execute();
|
|
56
|
+
if (scope === "named" && orgs.length > 0) {
|
|
57
|
+
await db
|
|
58
|
+
.insertInto("catalog_item_scope_orgs")
|
|
59
|
+
.values(orgs.map((org_id) => ({ item_id: id, org_id })))
|
|
60
|
+
.execute();
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
await db
|
|
65
|
+
.updateTable(COMPONENT_SCOPE_TABLE[kind])
|
|
66
|
+
.set({ ...(scope !== undefined && { scope }), scope_mode: change.scopeMode, updated_at })
|
|
67
|
+
.where("id", "=", id)
|
|
68
|
+
.execute();
|
|
69
|
+
// org-filter: a platform scope confirmation replaces the named list across organizations.
|
|
70
|
+
await db
|
|
71
|
+
.deleteFrom("component_scope_orgs")
|
|
72
|
+
.where("kind", "=", kind)
|
|
73
|
+
.where("component_id", "=", id)
|
|
74
|
+
.execute();
|
|
75
|
+
if (change.scopeMode === "own" && orgs.length > 0) {
|
|
76
|
+
await db
|
|
77
|
+
.insertInto("component_scope_orgs")
|
|
78
|
+
.values(orgs.map((org_id) => ({ kind, component_id: id, org_id })))
|
|
79
|
+
.execute();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Extend a named plugin scope under its item lock. */
|
|
83
|
+
export async function addNamedPluginOrg(db, itemId, orgId) {
|
|
84
|
+
const inserted = await db
|
|
85
|
+
.insertInto("catalog_item_scope_orgs")
|
|
86
|
+
.values({ item_id: itemId, org_id: orgId })
|
|
87
|
+
.onConflict((oc) => oc.doNothing())
|
|
88
|
+
.returning("org_id")
|
|
89
|
+
.executeTakeFirst();
|
|
90
|
+
return inserted !== undefined;
|
|
91
|
+
}
|
|
92
|
+
export function assertScopePreview(confirmation, preview, conflict) {
|
|
93
|
+
if (confirmation.kind !== "enable" && confirmation.hash !== preview.scopeHash) {
|
|
94
|
+
throw new ApiError("plugin.scope_stale", "What this change affects has changed since the preview; preview it again and confirm the new hash");
|
|
95
|
+
}
|
|
96
|
+
if (preview.conflicts.length > 0)
|
|
97
|
+
throw conflict(preview.conflicts);
|
|
98
|
+
}
|
|
99
|
+
/** Authorize and confirm a platform scope change in the transaction that applies it. */
|
|
100
|
+
let ScopeWriter = class ScopeWriter {
|
|
101
|
+
kdb;
|
|
102
|
+
installLock;
|
|
103
|
+
xactLock;
|
|
104
|
+
outbox;
|
|
105
|
+
adminLock;
|
|
106
|
+
txHost;
|
|
107
|
+
events;
|
|
108
|
+
constructor(kdb, installLock, xactLock, outbox, adminLock, txHost, events) {
|
|
109
|
+
this.kdb = kdb;
|
|
110
|
+
this.installLock = installLock;
|
|
111
|
+
this.xactLock = xactLock;
|
|
112
|
+
this.outbox = outbox;
|
|
113
|
+
this.adminLock = adminLock;
|
|
114
|
+
this.txHost = txHost;
|
|
115
|
+
this.events = events;
|
|
116
|
+
}
|
|
117
|
+
async platformChange(actor, confirmation, prepare) {
|
|
118
|
+
await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
|
|
119
|
+
await this.adminLock.lockAndAuthorize(actor);
|
|
120
|
+
const change = await prepare();
|
|
121
|
+
if (change === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
assertScopePreview(confirmation, change.preview, change.conflict);
|
|
124
|
+
return change.apply();
|
|
125
|
+
}
|
|
126
|
+
/** Persist the scope and its named list together after platform confirmation. */
|
|
127
|
+
async replaceScope(change) {
|
|
128
|
+
const db = this.kdb.db;
|
|
129
|
+
// org-filter: the platform scope change captures every previously listed organization.
|
|
130
|
+
const previousOrgs = change.kind === "connector_template"
|
|
131
|
+
? (await db
|
|
132
|
+
.selectFrom("component_scope_orgs")
|
|
133
|
+
.select("org_id")
|
|
134
|
+
.where("kind", "=", change.kind)
|
|
135
|
+
.where("component_id", "=", change.id)
|
|
136
|
+
.execute()).map((row) => row.org_id)
|
|
137
|
+
: [];
|
|
138
|
+
await writeScope(db, change);
|
|
139
|
+
if (change.kind === "connector_template") {
|
|
140
|
+
await this.oweConnectorTemplate(change.id, { previousOrgs });
|
|
141
|
+
}
|
|
142
|
+
if (change.kind === "plugin" || change.kind === "connector_template") {
|
|
143
|
+
this.refreshIsolatedOrgIntent();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** Persist deployment enablement after platform confirmation. */
|
|
147
|
+
async setDisabled(subject, disabled) {
|
|
148
|
+
const table = subject.kind === "plugin" ? "catalog_items" : COMPONENT_SCOPE_TABLE[subject.kind];
|
|
149
|
+
await this.kdb.db
|
|
150
|
+
.updateTable(table)
|
|
151
|
+
.set({ disabled, updated_at: sql `now()` })
|
|
152
|
+
.where("id", "=", subject.id)
|
|
153
|
+
.execute();
|
|
154
|
+
if (subject.kind === "connector_template")
|
|
155
|
+
await this.oweConnectorTemplate(subject.id, {});
|
|
156
|
+
if ((subject.kind === "plugin" && disabled) || subject.kind === "connector_template") {
|
|
157
|
+
this.refreshIsolatedOrgIntent();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Store local intent under the caller's transaction and org lock. */
|
|
161
|
+
async setOrgSwitch(subject, orgId, enabled, actor) {
|
|
162
|
+
const db = this.kdb.db;
|
|
163
|
+
const values = { org_id: orgId, enabled, updated_by: actor };
|
|
164
|
+
const update = { enabled, updated_by: actor, updated_at: sql `now()` };
|
|
165
|
+
if (subject.kind === "plugin") {
|
|
166
|
+
const sources = enabled
|
|
167
|
+
? []
|
|
168
|
+
: await db
|
|
169
|
+
.selectFrom(extensionSourcesQuery(db).as("source"))
|
|
170
|
+
.select("source.plugin")
|
|
171
|
+
.where("source.item_id", "=", subject.id)
|
|
172
|
+
.orderBy("source.plugin")
|
|
173
|
+
.execute();
|
|
174
|
+
for (const { plugin } of sources)
|
|
175
|
+
await this.installLock.shared(plugin);
|
|
176
|
+
await db
|
|
177
|
+
.insertInto("catalog_item_org_switches")
|
|
178
|
+
.values({ item_id: subject.id, ...values })
|
|
179
|
+
.onConflict((oc) => oc.columns(["item_id", "org_id"]).doUpdateSet(update))
|
|
180
|
+
.execute();
|
|
181
|
+
if (sources.length > 0) {
|
|
182
|
+
await db
|
|
183
|
+
.deleteFrom("component_org_switches")
|
|
184
|
+
.where("org_id", "=", orgId)
|
|
185
|
+
.where("kind", "=", "extension")
|
|
186
|
+
.where("component_id", "in", sources.map((source) => source.plugin))
|
|
187
|
+
.execute();
|
|
188
|
+
}
|
|
189
|
+
await oweEffectWork(this.outbox, db, { itemIds: [subject.id], orgId, previousOrgs: [orgId] });
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
await writeComponentSwitch(db, { kind: subject.kind, id: subject.id }, orgId, enabled, actor);
|
|
193
|
+
if (subject.kind === "connector_template") {
|
|
194
|
+
await this.oweConnectorTemplate(subject.id, { orgId, previousOrgs: [orgId] });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if ((subject.kind === "plugin" && !enabled) || subject.kind === "connector_template") {
|
|
198
|
+
this.refreshIsolatedOrgIntent(orgId);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async oweConnectorTemplate(id, scope) {
|
|
202
|
+
const db = this.kdb.db;
|
|
203
|
+
const template = await db
|
|
204
|
+
.selectFrom("platform_connector_templates")
|
|
205
|
+
.select("catalog_item_id")
|
|
206
|
+
.where("id", "=", id)
|
|
207
|
+
.executeTakeFirst();
|
|
208
|
+
if (template) {
|
|
209
|
+
await oweEffectWork(this.outbox, db, { itemIds: [template.catalog_item_id], ...scope });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Catalog switches can change the intent of extensions brought in through a dependency. */
|
|
213
|
+
refreshIsolatedOrgIntent(orgId) {
|
|
214
|
+
afterCommit(() => this.events.emit("catalog.org-intent-changed", orgId === undefined ? {} : { orgId }));
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
__decorate([
|
|
218
|
+
Transactional()
|
|
219
|
+
], ScopeWriter.prototype, "platformChange", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
Transactional({ propagation: "mandatory" })
|
|
222
|
+
], ScopeWriter.prototype, "replaceScope", null);
|
|
223
|
+
__decorate([
|
|
224
|
+
Transactional({ propagation: "mandatory" })
|
|
225
|
+
], ScopeWriter.prototype, "setDisabled", null);
|
|
226
|
+
__decorate([
|
|
227
|
+
Transactional({ propagation: "mandatory" })
|
|
228
|
+
], ScopeWriter.prototype, "setOrgSwitch", null);
|
|
229
|
+
ScopeWriter = __decorate([
|
|
230
|
+
Injectable(),
|
|
231
|
+
__param(0, Inject(KernelDb)),
|
|
232
|
+
__param(1, Inject(PluginInstallLock)),
|
|
233
|
+
__param(2, Inject(XactLock)),
|
|
234
|
+
__param(3, Inject(OutboxService)),
|
|
235
|
+
__param(4, Inject(SuperAdminLock)),
|
|
236
|
+
__param(5, Inject(TransactionHost)),
|
|
237
|
+
__param(6, Inject(KernelEvents))
|
|
238
|
+
], ScopeWriter);
|
|
239
|
+
export { ScopeWriter };
|
|
@@ -226,7 +226,7 @@ let TemplateConnectorEnsurer = class TemplateConnectorEnsurer {
|
|
|
226
226
|
.innerJoin("orgs as o", "o.id", "a.org_id")
|
|
227
227
|
.innerJoin("platform_connector_templates as t", "t.catalog_item_id", "a.item_id")
|
|
228
228
|
.select(["a.org_id", "a.item_id", "t.id as platform_template_id", "t.template_id", "t.file"])
|
|
229
|
-
.where("a.
|
|
229
|
+
.where("a.version", "is not", null)
|
|
230
230
|
.where("o.deleted_at", "is", null)
|
|
231
231
|
.where("t.deleted_at", "is", null)
|
|
232
232
|
.where(({ not, exists, selectFrom }) => not(exists(selectFrom("connectors as c")
|
package/dist/catalog/unshare.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
// Turning sharing off on an org-owned item (ruling P3-25): an `optional` / `all` scope is narrowed, in
|
|
2
|
-
// the caller's transaction, to `named` = the owner plus every live org where the item is on right
|
|
3
|
-
// now, so the orgs already associated keep it and no new org can see, switch on or request it
|
|
4
|
-
// (§14.1 item 3). A `named` scope is left as it is: the gate in `requestable` and the writers
|
|
5
|
-
// already holds back new orgs there.
|
|
6
|
-
import { sql } from "kysely";
|
|
7
1
|
import { audit } from "../identity/audit.js";
|
|
8
2
|
import { asPlatform } from "../infra/database/org-scope.js";
|
|
9
3
|
import { componentOn, listedIn, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
|
|
10
|
-
import {
|
|
4
|
+
import { writeScope } from "./scope-writer.js";
|
|
11
5
|
async function liveOrgIds(db) {
|
|
12
6
|
const rows = await db.selectFrom("orgs").select("id").where("deleted_at", "is", null).execute();
|
|
13
7
|
return rows.map((r) => r.id);
|
|
@@ -29,7 +23,7 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
29
23
|
.selectFrom("plugin_installs")
|
|
30
24
|
.select("org_id")
|
|
31
25
|
.where("item_id", "=", item.id)
|
|
32
|
-
.where("
|
|
26
|
+
.where("version", "is not", null)
|
|
33
27
|
.execute();
|
|
34
28
|
const switches = await db
|
|
35
29
|
.selectFrom("catalog_item_org_switches")
|
|
@@ -43,19 +37,7 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
43
37
|
...[...installs, ...switches].map((r) => r.org_id).filter((o) => live.has(o)),
|
|
44
38
|
]),
|
|
45
39
|
].sort();
|
|
46
|
-
await db
|
|
47
|
-
.updateTable("catalog_items")
|
|
48
|
-
.set({
|
|
49
|
-
scope: "named",
|
|
50
|
-
updated_at: sql `now()`,
|
|
51
|
-
})
|
|
52
|
-
.where("id", "=", item.id)
|
|
53
|
-
.execute();
|
|
54
|
-
await db.deleteFrom("catalog_item_scope_orgs").where("item_id", "=", item.id).execute();
|
|
55
|
-
await db
|
|
56
|
-
.insertInto("catalog_item_scope_orgs")
|
|
57
|
-
.values(kept.map((org_id) => ({ item_id: item.id, org_id })))
|
|
58
|
-
.execute();
|
|
40
|
+
await writeScope(db, { kind: "plugin", id: item.id, scope: "named", orgs: kept });
|
|
59
41
|
return kept;
|
|
60
42
|
});
|
|
61
43
|
await audit(db, {
|
|
@@ -85,23 +67,13 @@ export async function narrowComponentOnUnshare(db, actor, c) {
|
|
|
85
67
|
const st = await loadScopeState(db, c.kind, [c]);
|
|
86
68
|
const on = (await liveOrgIds(db)).filter((o) => componentOn(c, pluginFactsOf(st, c.itemId, o), listedIn(st, c.id, o), switchOf(st, c.id, o)));
|
|
87
69
|
const kept = [...new Set([ownerOrgId, ...on])].sort();
|
|
88
|
-
await db
|
|
89
|
-
|
|
90
|
-
.
|
|
70
|
+
await writeScope(db, {
|
|
71
|
+
kind: c.kind,
|
|
72
|
+
id: c.id,
|
|
73
|
+
scopeMode: "own",
|
|
91
74
|
scope: "named",
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
.where("id", "=", c.id)
|
|
95
|
-
.execute();
|
|
96
|
-
await db
|
|
97
|
-
.deleteFrom("component_scope_orgs")
|
|
98
|
-
.where("kind", "=", c.kind)
|
|
99
|
-
.where("component_id", "=", c.id)
|
|
100
|
-
.execute();
|
|
101
|
-
await db
|
|
102
|
-
.insertInto("component_scope_orgs")
|
|
103
|
-
.values(kept.map((org_id) => ({ kind: c.kind, component_id: c.id, org_id })))
|
|
104
|
-
.execute();
|
|
75
|
+
orgs: kept,
|
|
76
|
+
});
|
|
105
77
|
return kept;
|
|
106
78
|
});
|
|
107
79
|
await audit(db, {
|
|
@@ -119,9 +91,3 @@ export async function narrowComponentOnUnshare(db, actor, c) {
|
|
|
119
91
|
});
|
|
120
92
|
return true;
|
|
121
93
|
}
|
|
122
|
-
const TABLE = {
|
|
123
|
-
skill: "platform_skills",
|
|
124
|
-
agent_template: "platform_agent_templates",
|
|
125
|
-
connector_template: "platform_connector_templates",
|
|
126
|
-
theme: "platform_themes",
|
|
127
|
-
};
|
|
@@ -18,7 +18,7 @@ import { createSecrets } from "../ctx/secrets.js";
|
|
|
18
18
|
import { ApiError } from "../errors.js";
|
|
19
19
|
import { toIssues } from "../extensions/config-issues.js";
|
|
20
20
|
import { configMessages, describeConfigUiProblems, safeConfigFormSchema, } from "../extensions/config-json-schema.js";
|
|
21
|
-
import {
|
|
21
|
+
import { enabledExtensionsQuery } from "../extensions/enabled.js";
|
|
22
22
|
import { PluginGuides } from "../extensions/plugin-guides.js";
|
|
23
23
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
24
24
|
import { audit } from "../identity/audit.js";
|
|
@@ -731,11 +731,11 @@ let ChannelConnections = class ChannelConnections {
|
|
|
731
731
|
* `pluginEnabled` 为插件此刻是否在该组织启用(入站与卡片操作每次都实时复核)。
|
|
732
732
|
*/
|
|
733
733
|
async row(id) {
|
|
734
|
-
const
|
|
734
|
+
const db = this.db.db;
|
|
735
|
+
const r = await db
|
|
735
736
|
.selectFrom("channel_connections as c")
|
|
736
737
|
.innerJoin("orgs", "orgs.id", "c.org_id")
|
|
737
|
-
.
|
|
738
|
-
.select([
|
|
738
|
+
.select(({ exists, ref }) => [
|
|
739
739
|
"c.id",
|
|
740
740
|
"c.org_id",
|
|
741
741
|
"c.plugin",
|
|
@@ -744,7 +744,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
744
744
|
"c.status",
|
|
745
745
|
"c.inbound_mode",
|
|
746
746
|
"c.tenant_id",
|
|
747
|
-
"
|
|
747
|
+
exists(enabledExtensionsQuery(db, ref("c.org_id"), ref("c.plugin"))).as("plugin_enabled"),
|
|
748
748
|
])
|
|
749
749
|
.where("c.id", "=", id)
|
|
750
750
|
.where("c.deleted_at", "is", null)
|
|
@@ -759,7 +759,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
759
759
|
status: r.status,
|
|
760
760
|
inboundMode: r.inbound_mode,
|
|
761
761
|
tenantId: r.tenant_id,
|
|
762
|
-
pluginEnabled: r.
|
|
762
|
+
pluginEnabled: Boolean(r.plugin_enabled),
|
|
763
763
|
});
|
|
764
764
|
}
|
|
765
765
|
/**
|
|
@@ -11,7 +11,7 @@ import { randomUUID } from "node:crypto";
|
|
|
11
11
|
import { CHANNEL_EXTENSION_POINT, } from "@capybara-hq/plugin-sdk";
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { secretValues } from "../config/fields.js";
|
|
14
|
-
import {
|
|
14
|
+
import { enabledExtensionsQuery } from "../extensions/enabled.js";
|
|
15
15
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
16
16
|
import { ReplicaStatusStore } from "../extensions/sources.js";
|
|
17
17
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -380,9 +380,7 @@ let ChannelSupervisor = class ChannelSupervisor {
|
|
|
380
380
|
let query = db
|
|
381
381
|
.selectFrom("channel_connections")
|
|
382
382
|
.innerJoin("orgs", "orgs.id", "channel_connections.org_id")
|
|
383
|
-
.
|
|
384
|
-
.onRef("en.plugin", "=", "channel_connections.plugin")
|
|
385
|
-
.onRef("en.org_id", "=", "channel_connections.org_id"))
|
|
383
|
+
.where(({ exists, ref }) => exists(enabledExtensionsQuery(db, ref("channel_connections.org_id"), ref("channel_connections.plugin"))))
|
|
386
384
|
.select([
|
|
387
385
|
"channel_connections.id",
|
|
388
386
|
"channel_connections.org_id",
|
|
@@ -728,9 +726,7 @@ export async function checkGatewayPresence(deps) {
|
|
|
728
726
|
const rows = await asPlatform("count connections needing a gateway across orgs", () => deps.db
|
|
729
727
|
.selectFrom("channel_connections")
|
|
730
728
|
.innerJoin("orgs", "orgs.id", "channel_connections.org_id")
|
|
731
|
-
.
|
|
732
|
-
.onRef("en.plugin", "=", "channel_connections.plugin")
|
|
733
|
-
.onRef("en.org_id", "=", "channel_connections.org_id"))
|
|
729
|
+
.where(({ exists, ref }) => exists(enabledExtensionsQuery(deps.db, ref("channel_connections.org_id"), ref("channel_connections.plugin"))))
|
|
734
730
|
.select(["channel_connections.plugin", (eb) => eb.fn.countAll().as("n")])
|
|
735
731
|
.where("channel_connections.status", "=", "active")
|
|
736
732
|
.where("channel_connections.deleted_at", "is", null)
|
|
@@ -11,7 +11,7 @@ import { CLIENT_API_VERSION, EXTENSION_NAME_RE, resolveUiSlots, validateUiContri
|
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { ApiError } from "../errors.js";
|
|
14
|
-
import {
|
|
14
|
+
import { enabledExtensionsQuery } from "../extensions/enabled.js";
|
|
15
15
|
import { STALE_RECONCILE_PERIODS } from "../extensions/lifecycle-topics.js";
|
|
16
16
|
import { CLIENT_EXTENSIONS_SETTING, parseClientExtensions, readClientExtensions, } from "../identity/settings.js";
|
|
17
17
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -192,8 +192,6 @@ let ClientAccess = class ClientAccess {
|
|
|
192
192
|
.select("value")
|
|
193
193
|
.where("key", "=", CLIENT_EXTENSIONS_SETTING)
|
|
194
194
|
.as("kill"),
|
|
195
|
-
// enabled.ts's two sources, per account: an always-on extension (required, or its plugin
|
|
196
|
-
// is builtin) is on in every org, otherwise the org's own switch row
|
|
197
195
|
eb
|
|
198
196
|
.exists(eb
|
|
199
197
|
.selectFrom("memberships as m")
|
|
@@ -201,15 +199,7 @@ let ClientAccess = class ClientAccess {
|
|
|
201
199
|
.select(sql `1`.as("one"))
|
|
202
200
|
.where("m.account_id", "=", accountId)
|
|
203
201
|
.where("o.deleted_at", "is", null)
|
|
204
|
-
.where((w) => w.
|
|
205
|
-
w("i.name", "in", alwaysOnExtensionsQuery(db)),
|
|
206
|
-
w.exists(w
|
|
207
|
-
.selectFrom("extension_org_configs as c")
|
|
208
|
-
.select(sql `1`.as("one"))
|
|
209
|
-
.whereRef("c.org_id", "=", "m.org_id")
|
|
210
|
-
.whereRef("c.plugin", "=", "i.name")
|
|
211
|
-
.where("c.enabled", "=", true)),
|
|
212
|
-
])))
|
|
202
|
+
.where((w) => w.exists(enabledExtensionsQuery(db, w.ref("m.org_id"), w.ref("i.name")))))
|
|
213
203
|
.as("member"),
|
|
214
204
|
]);
|
|
215
205
|
// org-filter: deployment-wide bundle access uses the authenticated account's memberships.
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -96,6 +96,12 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
96
96
|
extensionConfig: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
97
97
|
extensionHost: z.ZodPrefault<z.ZodObject<{
|
|
98
98
|
dir: z.ZodDefault<z.ZodString>;
|
|
99
|
+
isolation: z.ZodOptional<z.ZodObject<{
|
|
100
|
+
engineUrl: z.ZodURL;
|
|
101
|
+
image: z.ZodString;
|
|
102
|
+
socketDir: z.ZodString;
|
|
103
|
+
postgresSocket: z.ZodString;
|
|
104
|
+
}, z.core.$strict>>;
|
|
99
105
|
drainSeconds: z.ZodDefault<z.ZodNumber>;
|
|
100
106
|
disposeTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
|
101
107
|
reloadSetupTimeoutSeconds: z.ZodDefault<z.ZodNumber>;
|
package/dist/config/schema.js
CHANGED
|
@@ -461,7 +461,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
461
461
|
extensions: z
|
|
462
462
|
.array(z.string())
|
|
463
463
|
.default([])
|
|
464
|
-
.meta(meta({ description: "
|
|
464
|
+
.meta(meta({ description: "Local packed extension tarball paths or file URLs to load" })),
|
|
465
465
|
extensionConfig: z
|
|
466
466
|
.record(z.string(), z.unknown())
|
|
467
467
|
.default({})
|
|
@@ -475,6 +475,37 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
475
475
|
.meta(meta({
|
|
476
476
|
description: "Local directory where each replica unpacks installed extension packages (<dir>/<name>/<first 16 hex of sha256>/), relative to the working directory unless absolute (the image sets /var/lib/capybara/plugins); safe to wipe, replicas re-download from the package store",
|
|
477
477
|
})),
|
|
478
|
+
isolation: z
|
|
479
|
+
.strictObject({
|
|
480
|
+
engineUrl: z
|
|
481
|
+
.url({ protocol: /^http$/ })
|
|
482
|
+
.refine((value) => {
|
|
483
|
+
const url = new URL(value);
|
|
484
|
+
return (!url.username && !url.password && url.pathname === "/" && !url.search && !url.hash);
|
|
485
|
+
}, "Use an HTTP origin without credentials, path, query, or fragment")
|
|
486
|
+
.meta(meta({
|
|
487
|
+
description: "Private HTTP origin of the restricted extension Engine API proxy.",
|
|
488
|
+
})),
|
|
489
|
+
image: z
|
|
490
|
+
.string()
|
|
491
|
+
.regex(/^sha256:[a-f0-9]{64}$/)
|
|
492
|
+
.meta(meta({
|
|
493
|
+
description: "Local immutable image ID of the isolated extension runtime.",
|
|
494
|
+
})),
|
|
495
|
+
socketDir: z
|
|
496
|
+
.string()
|
|
497
|
+
.min(1)
|
|
498
|
+
.meta(meta({
|
|
499
|
+
description: "Short absolute directory shared with the supervisor daemon for private per-lane PostgreSQL sockets.",
|
|
500
|
+
})),
|
|
501
|
+
postgresSocket: z
|
|
502
|
+
.string()
|
|
503
|
+
.min(1)
|
|
504
|
+
.meta(meta({
|
|
505
|
+
description: "Absolute path to the dedicated PostgreSQL Unix socket exposed to extension containers.",
|
|
506
|
+
})),
|
|
507
|
+
})
|
|
508
|
+
.optional(),
|
|
478
509
|
drainSeconds: z
|
|
479
510
|
.number()
|
|
480
511
|
.int()
|
package/dist/ctx/create-ctx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EmbedClaims, type ExtensionContext, type ExtensionManifest, type ExtensionPointRef, type HttpAccess, type Logger, type RouteCaller, resolveUiSlots, type SetupCheckArgs, type SetupGuidePlace, type ToolHandler, type ToolSpec, type ToolWatcher, type TriggerEvent } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
|
-
import { Kysely } from "kysely";
|
|
3
|
+
import type { Kysely } from "kysely";
|
|
4
4
|
import type { TriggerEventsService } from "../automations/events/trigger-events.service.js";
|
|
5
5
|
import type { ExternalConversationsBackend } from "../conversations/external/external-conversations.service.js";
|
|
6
6
|
import { pluginSchemaName } from "../db/extension-db.js";
|
|
@@ -177,7 +177,7 @@ export interface ExtensionPointAccess {
|
|
|
177
177
|
plugin: string;
|
|
178
178
|
impl: unknown;
|
|
179
179
|
}[];
|
|
180
|
-
/** Names of the extensions enabled in the organization (
|
|
180
|
+
/** Names of the extensions enabled in the organization (the org intent projection, `enabled.ts`); queried every time, not cached. */
|
|
181
181
|
enabledPlugins(orgId: string): Promise<Set<string>>;
|
|
182
182
|
/**
|
|
183
183
|
* Whether the extension's effective config is valid in the organization (layering spec A §6):
|