@capybara-hq/kernel 0.1.0-rc.142 → 0.1.0-rc.144
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-agents.controller.d.ts +3 -5
- package/dist/admin/admin-agents.controller.js +1 -1
- package/dist/admin/admin-connectors.controller.d.ts +3 -5
- package/dist/admin/admin-connectors.controller.js +1 -1
- package/dist/admin/admin-items.schemas.d.ts +6 -6
- package/dist/admin/admin-items.schemas.js +5 -9
- package/dist/admin/admin.controller.d.ts +18 -12
- package/dist/admin/admin.controller.js +29 -15
- package/dist/admin/admin.schemas.d.ts +12 -3
- package/dist/admin/admin.schemas.js +17 -6
- package/dist/agents/admin-agents.d.ts +10 -8
- package/dist/agents/admin-agents.js +13 -9
- package/dist/agents/agents.module.js +3 -0
- package/dist/agents/agents.service.js +1 -1
- package/dist/agents/org-templates.d.ts +3 -1
- package/dist/agents/org-templates.js +7 -3
- package/dist/agents/pending-connector-requests.d.ts +10 -4
- package/dist/agents/pending-connector-requests.js +29 -7
- package/dist/automations/automations.controller.d.ts +9 -5
- package/dist/automations/automations.controller.js +21 -4
- package/dist/automations/automations.schemas.d.ts +19 -0
- package/dist/automations/automations.schemas.js +9 -0
- package/dist/automations/automations.service.d.ts +25 -8
- package/dist/automations/automations.service.js +40 -34
- package/dist/automations/events/acceptance.d.ts +6 -1
- package/dist/automations/events/acceptance.js +30 -11
- package/dist/automations/store.d.ts +17 -0
- package/dist/automations/store.js +35 -0
- package/dist/catalog/admin-catalog.controller.d.ts +64 -2
- package/dist/catalog/admin-catalog.controller.js +17 -0
- package/dist/catalog/catalog-import.module.js +3 -0
- package/dist/catalog/catalog-scope.service.d.ts +3 -1
- package/dist/catalog/catalog-scope.service.js +11 -7
- package/dist/catalog/catalog.module.js +3 -0
- package/dist/catalog/catalog.service.d.ts +3 -1
- package/dist/catalog/catalog.service.js +8 -4
- package/dist/catalog/cli.js +2 -2
- package/dist/catalog/component-promotion.d.ts +3 -1
- package/dist/catalog/component-promotion.js +7 -3
- package/dist/catalog/component-scope.service.d.ts +3 -1
- package/dist/catalog/component-scope.service.js +7 -3
- package/dist/catalog/enable-requests.d.ts +10 -8
- package/dist/catalog/enable-requests.js +40 -21
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/owned-items.d.ts +3 -1
- package/dist/catalog/owned-items.js +13 -9
- package/dist/catalog/platform-components.d.ts +6 -1
- package/dist/catalog/platform-components.js +9 -3
- package/dist/catalog/plugin-connectors.d.ts +8 -4
- package/dist/catalog/plugin-connectors.js +12 -6
- package/dist/catalog/plugin-import.d.ts +3 -1
- package/dist/catalog/plugin-import.js +14 -5
- package/dist/catalog/plugin-install.d.ts +3 -1
- package/dist/catalog/plugin-install.js +8 -4
- package/dist/catalog/plugin-package.js +2 -1
- package/dist/catalog/plugin-upgrade.d.ts +3 -1
- package/dist/catalog/plugin-upgrade.js +8 -4
- package/dist/catalog/request-hints.d.ts +19 -0
- package/dist/catalog/request-hints.js +34 -0
- package/dist/catalog/request-rules.d.ts +9 -5
- package/dist/catalog/request-rules.js +16 -9
- package/dist/catalog/requests.service.d.ts +3 -1
- package/dist/catalog/requests.service.js +28 -9
- package/dist/catalog/scope-orgs.d.ts +2 -1
- package/dist/catalog/scope-orgs.js +2 -2
- package/dist/catalog/scope-sync.d.ts +3 -1
- package/dist/catalog/scope-sync.js +12 -2
- package/dist/catalog/scope-writer.d.ts +6 -3
- package/dist/catalog/scope-writer.js +28 -10
- package/dist/catalog/unshare.d.ts +3 -2
- package/dist/catalog/unshare.js +4 -4
- package/dist/client/client-access.service.js +29 -1
- package/dist/config/schema.d.ts +12 -0
- package/dist/config/schema.js +56 -0
- package/dist/ctx/create-ctx.d.ts +2 -19
- package/dist/ctx/create-ctx.js +3 -93
- package/dist/ctx/durable-relay.d.ts +2 -5
- package/dist/ctx/durable-relay.js +56 -29
- package/dist/db/extension-handoff-schema.js +5 -0
- package/dist/db/kernel-schema.d.ts +74 -0
- package/dist/db/migrator.js +36 -0
- package/dist/erasure/account-batches.js +2 -0
- package/dist/erasure/account-residual.js +1 -0
- package/dist/erasure/org-catalog.js +8 -3
- package/dist/erasure/org-rules.js +1 -0
- package/dist/evals/evals.schemas.d.ts +15 -5
- package/dist/evals/evals.schemas.js +17 -10
- package/dist/evals/runs.controller.d.ts +4 -12
- package/dist/evals/runs.controller.js +14 -11
- package/dist/evals/runs.service.d.ts +29 -25
- package/dist/evals/runs.service.js +73 -61
- package/dist/evals/trajectory.controller.d.ts +10 -6
- package/dist/evals/trajectory.controller.js +11 -4
- package/dist/evals/trajectory.service.d.ts +17 -9
- package/dist/evals/trajectory.service.js +52 -35
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +21 -7
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/deployment-config.d.ts +6 -1
- package/dist/extensions/deployment-config.js +13 -2
- package/dist/extensions/enabled.d.ts +5 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/grant-epoch.d.ts +108 -0
- package/dist/extensions/grant-epoch.js +214 -0
- package/dist/extensions/host.d.ts +29 -9
- package/dist/extensions/host.js +148 -42
- package/dist/extensions/instance.d.ts +3 -3
- package/dist/extensions/instance.js +1 -1
- package/dist/extensions/isolated/authorization.d.ts +54 -2
- package/dist/extensions/isolated/authorization.js +148 -35
- package/dist/extensions/isolated/child-session.js +0 -1
- package/dist/extensions/isolated/revision.js +1 -1
- package/dist/extensions/org-config.d.ts +3 -1
- package/dist/extensions/org-config.js +13 -4
- package/dist/extensions/org-overrides.d.ts +6 -1
- package/dist/extensions/org-overrides.js +13 -2
- package/dist/extensions/package-digest.job.d.ts +34 -0
- package/dist/extensions/package-digest.job.js +121 -0
- package/dist/extensions/package.js +10 -6
- package/dist/extensions/permission-set.d.ts +14 -78
- package/dist/extensions/permission-set.js +17 -143
- package/dist/extensions/permission-view.d.ts +13 -1
- package/dist/extensions/permission-view.js +20 -0
- package/dist/extensions/registry.js +4 -1
- package/dist/extensions/resolve.d.ts +7 -8
- package/dist/extensions/resolve.js +7 -8
- package/dist/extensions/revision-approvals.d.ts +167 -0
- package/dist/extensions/revision-approvals.js +353 -0
- package/dist/extensions/revision-grants.d.ts +197 -0
- package/dist/extensions/revision-grants.js +584 -0
- package/dist/extensions/state.module.js +12 -1
- package/dist/identity/accounts.d.ts +10 -4
- package/dist/identity/accounts.js +18 -5
- package/dist/inbox/inbox-items.service.d.ts +6 -1
- package/dist/inbox/inbox-items.service.js +29 -10
- package/dist/inbox/inbox.module.js +3 -0
- package/dist/inbox/inbox.service.d.ts +3 -1
- package/dist/inbox/inbox.service.js +9 -2
- package/dist/inbox/org-notices.d.ts +4 -3
- package/dist/inbox/org-notices.js +9 -6
- package/dist/inbox/platform-inbox.service.d.ts +3 -1
- package/dist/inbox/platform-inbox.service.js +11 -3
- package/dist/inbox/platform-notices.d.ts +3 -2
- package/dist/inbox/platform-notices.js +10 -4
- package/dist/infra/config/kernel-config.service.js +4 -1
- package/dist/infra/database/extension-effect-key-lock.js +7 -0
- package/dist/infra/paging/paged-read.d.ts +34 -4
- package/dist/infra/paging/paged-read.js +38 -1
- package/dist/invalidation/audiences.d.ts +32 -0
- package/dist/invalidation/audiences.js +43 -0
- package/dist/invalidation/hints.d.ts +6 -0
- package/dist/invalidation/hints.js +7 -1
- package/dist/invalidation/invalidation-hints.d.ts +12 -1
- package/dist/invalidation/invalidation-hints.js +46 -5
- package/dist/invalidation/invalidation-hints.module.d.ts +2 -0
- package/dist/invalidation/invalidation-hints.module.js +4 -1
- package/dist/invalidation/me-stream.d.ts +1 -11
- package/dist/invalidation/me-stream.js +12 -41
- package/dist/invalidation/org-intent-bridge.d.ts +18 -0
- package/dist/invalidation/org-intent-bridge.js +46 -0
- package/dist/models/enablement.d.ts +3 -1
- package/dist/models/enablement.js +25 -5
- package/dist/orgs/invitations.controller.d.ts +4 -7
- package/dist/orgs/invitations.controller.js +8 -5
- package/dist/orgs/invitations.service.d.ts +17 -3
- package/dist/orgs/invitations.service.js +35 -13
- package/dist/orgs/members.service.d.ts +35 -0
- package/dist/orgs/members.service.js +52 -3
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +7 -3
- package/dist/orgs/orgs.controller.d.ts +11 -4
- package/dist/orgs/orgs.controller.js +25 -5
- package/dist/orgs/orgs.module.js +3 -0
- package/dist/orgs/orgs.schemas.d.ts +14 -0
- package/dist/orgs/orgs.schemas.js +19 -2
- package/dist/orgs/orgs.service.d.ts +24 -2
- package/dist/orgs/orgs.service.js +47 -4
- package/dist/orgs/security-settings.service.d.ts +14 -6
- package/dist/orgs/security-settings.service.js +18 -13
- package/dist/orgs/settings.controller.d.ts +7 -4
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/accounts.ops.js +7 -16
- package/dist/platform/ops/admin-items.ops.js +7 -7
- package/dist/platform/ops/automations.ops.js +6 -4
- package/dist/platform/ops/evals.ops.js +30 -15
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +44 -27
- package/dist/push/delivery.d.ts +3 -1
- package/dist/push/delivery.js +7 -3
- package/dist/push/push-processor.js +8 -1
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/step-log.d.ts +1 -1
- package/dist/runtime/step-log.js +5 -4
- package/dist/runtime/stream-limit.d.ts +13 -0
- package/dist/runtime/stream-limit.js +40 -0
- package/dist/runtime/stream.controller.d.ts +2 -0
- package/dist/runtime/stream.controller.js +2 -0
- package/dist/runtime/stream.d.ts +1 -0
- package/dist/runtime/stream.js +15 -6
- package/dist/sandbox/permission-authority.module.js +6 -1
- package/dist/sandbox/permission-transitions.d.ts +3 -1
- package/dist/sandbox/permission-transitions.js +17 -2
- package/dist/setup/kernel-checks.d.ts +3 -3
- package/dist/setup/kernel-checks.js +4 -4
- package/dist/setup/setup-check-registry.d.ts +16 -5
- package/dist/setup/setup-check-registry.js +11 -3
- package/dist/setup/setup-checks.service.d.ts +1 -2
- package/dist/setup/setup-checks.service.js +7 -6
- package/dist/skills/agent-skills.service.d.ts +6 -1
- package/dist/skills/agent-skills.service.js +12 -3
- package/dist/skills/changes.service.d.ts +6 -1
- package/dist/skills/changes.service.js +11 -3
- package/dist/skills/conversation-catalog.d.ts +3 -0
- package/dist/skills/conversation-catalog.js +2 -0
- package/dist/skills/skills.module.js +3 -0
- package/dist/skills/skills.service.d.ts +3 -1
- package/dist/skills/skills.service.js +8 -4
- package/dist/tools/admin-connectors.d.ts +10 -8
- package/dist/tools/admin-connectors.js +12 -10
- package/dist/tools/approvals.service.d.ts +12 -1
- package/dist/tools/approvals.service.js +36 -9
- package/dist/tools/builtins/automations.d.ts +1 -1
- package/dist/tools/builtins/automations.js +1 -1
- package/dist/tools/connectors.service.d.ts +3 -1
- package/dist/tools/connectors.service.js +29 -7
- package/dist/tools/tools.module.js +3 -0
- package/dist/ui/admin-ui.controller.d.ts +3 -1
- package/dist/ui/admin-ui.controller.js +3 -1
- package/dist/ui/ui-stream.d.ts +2 -0
- package/dist/ui/ui-stream.js +20 -6
- package/dist/ui/views.controller.d.ts +4 -2
- package/dist/ui/views.controller.js +4 -2
- package/package.json +3 -3
- package/src/migrations/0234_extension_grant_epoch.sql +141 -0
- package/src/migrations/0235_extension_revision_grants.sql +166 -0
- package/src/migrations/0236_paged_table_idx.sql +33 -0
- package/src/migrations/0237_extension_handoff_health.sql +18 -0
package/dist/push/delivery.js
CHANGED
|
@@ -18,6 +18,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
18
18
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
19
19
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
20
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
21
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
21
22
|
import { PushProviderHost } from "./provider-host.js";
|
|
22
23
|
import { PushTokenStore } from "./token-store.js";
|
|
23
24
|
/**
|
|
@@ -76,9 +77,10 @@ let PushDelivery = class PushDelivery {
|
|
|
76
77
|
replica;
|
|
77
78
|
log;
|
|
78
79
|
timeoutMs;
|
|
80
|
+
hints;
|
|
79
81
|
constructor(kdb, txHost, host, tokens, config,
|
|
80
82
|
/** This process's replica id (its own `extension_replica_status` rows). */
|
|
81
|
-
replica, log, timeoutMs = () => PUSH_LIMITS.sendTimeoutMs) {
|
|
83
|
+
replica, log, timeoutMs = () => PUSH_LIMITS.sendTimeoutMs, hints) {
|
|
82
84
|
this.kdb = kdb;
|
|
83
85
|
this.txHost = txHost;
|
|
84
86
|
this.host = host;
|
|
@@ -87,6 +89,7 @@ let PushDelivery = class PushDelivery {
|
|
|
87
89
|
this.replica = replica;
|
|
88
90
|
this.log = log;
|
|
89
91
|
this.timeoutMs = timeoutMs;
|
|
92
|
+
this.hints = hints;
|
|
90
93
|
}
|
|
91
94
|
/** Delivers one job (see the class). */
|
|
92
95
|
async deliver(data) {
|
|
@@ -218,7 +221,7 @@ let PushDelivery = class PushDelivery {
|
|
|
218
221
|
}
|
|
219
222
|
/** The platform notice `push_auth_failed` for `plugin`, unless one is open. */
|
|
220
223
|
async recordAuthFailure(plugin) {
|
|
221
|
-
await addPushAuthNotice(this.kdb.db, plugin);
|
|
224
|
+
await addPushAuthNotice(this.kdb.db, this.hints, plugin);
|
|
222
225
|
}
|
|
223
226
|
/**
|
|
224
227
|
* Whether another live replica (heartbeat within the stale window) reports `plugin` loaded: then
|
|
@@ -255,7 +258,8 @@ PushDelivery = __decorate([
|
|
|
255
258
|
__param(5, Inject(ReplicaStatusStore)),
|
|
256
259
|
__param(6, Inject(KERNEL_LOGGER)),
|
|
257
260
|
__param(7, Optional()),
|
|
258
|
-
__param(7, Inject(PUSH_SEND_TIMEOUT_MS))
|
|
261
|
+
__param(7, Inject(PUSH_SEND_TIMEOUT_MS)),
|
|
262
|
+
__param(8, Inject(InvalidationHints))
|
|
259
263
|
], PushDelivery);
|
|
260
264
|
export { PushDelivery };
|
|
261
265
|
/** Whether `m` passes `validatePushMessage` (a malformed shape, e.g. a missing field, does not). */
|
|
@@ -13,6 +13,7 @@ import { UnrecoverableError } from "bullmq";
|
|
|
13
13
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
14
14
|
import { runJob } from "../infra/queue/run-job.js";
|
|
15
15
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
16
|
+
import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
|
|
16
17
|
import { PushDelivery } from "./delivery.js";
|
|
17
18
|
import { PushFanout } from "./fanout.js";
|
|
18
19
|
import { PUSH_DELIVER_JOB, PUSH_FANOUT_JOB, PUSH_QUEUE, } from "./jobs.js";
|
|
@@ -106,7 +107,13 @@ let PushWorkersModule = class PushWorkersModule {
|
|
|
106
107
|
};
|
|
107
108
|
PushWorkersModule = __decorate([
|
|
108
109
|
Module({
|
|
109
|
-
imports: [
|
|
110
|
+
imports: [
|
|
111
|
+
// invalidation hints its writers publish after their commit
|
|
112
|
+
InvalidationHintsModule,
|
|
113
|
+
PushModule,
|
|
114
|
+
PushHostModule,
|
|
115
|
+
ExtensionsModule,
|
|
116
|
+
],
|
|
110
117
|
providers: [PushDelivery, PushFanout, PushProcessor, PushStaleJob],
|
|
111
118
|
exports: [PushProcessor],
|
|
112
119
|
})
|
|
@@ -35,6 +35,7 @@ import { EvalWorkersModule } from "../evals/evals.module.js";
|
|
|
35
35
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
36
36
|
import { PluginsReconcileJob } from "../extensions/lifecycle.js";
|
|
37
37
|
import { LifecycleHookWorkersModule } from "../extensions/lifecycle-hooks.js";
|
|
38
|
+
import { PackageDigestBackfillJob } from "../extensions/package-digest.job.js";
|
|
38
39
|
import { BlobSweepModule } from "../files/blob-sweep.job.js";
|
|
39
40
|
import { FileDraftCleanupJob } from "../files/draft-cleanup.job.js";
|
|
40
41
|
import { FileLibraryKickoffJob } from "../files/hash-job.js";
|
|
@@ -165,6 +166,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
165
166
|
AccountAvatarCleanupJob,
|
|
166
167
|
ClientReportsCron,
|
|
167
168
|
CatalogJobs,
|
|
169
|
+
// sha512 of packages stored before migration 0235 (extension permission model plan 1.2b)
|
|
170
|
+
PackageDigestBackfillJob,
|
|
168
171
|
DirectoryScanJob,
|
|
169
172
|
PluginsReconcileJob,
|
|
170
173
|
GatewayCheckJob,
|
|
@@ -50,7 +50,7 @@ export declare class StepLog {
|
|
|
50
50
|
written: ConversationEvent[];
|
|
51
51
|
toSeq: number | null;
|
|
52
52
|
}>;
|
|
53
|
-
/** Appends events with
|
|
53
|
+
/** Appends events with an audit row for a newly recorded denial. */
|
|
54
54
|
appendAudited(conversationId: string, events: AppendEvent[], entry: StepAuditEntry): Promise<ConversationEvent[]>;
|
|
55
55
|
/**
|
|
56
56
|
* Appends a `model_call` with the tool definitions its request sent, stored by fingerprint in
|
package/dist/runtime/step-log.js
CHANGED
|
@@ -87,11 +87,12 @@ let StepLog = class StepLog {
|
|
|
87
87
|
}
|
|
88
88
|
return { written, toSeq: fresh.length > 0 ? Math.max(...fresh.map((e) => e.seq)) : null };
|
|
89
89
|
}
|
|
90
|
-
/** Appends events with
|
|
90
|
+
/** Appends events with an audit row for a newly recorded denial. */
|
|
91
91
|
async appendAudited(conversationId, events, entry) {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
const result = await this.eventLog.appendInReport(conversationId, events);
|
|
93
|
+
if (result.fresh.some(Boolean))
|
|
94
|
+
await audit(this.kdb.db, entry);
|
|
95
|
+
return result.events;
|
|
95
96
|
}
|
|
96
97
|
/**
|
|
97
98
|
* Appends a `model_call` with the tool definitions its request sent, stored by fingerprint in
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A transport close, with no event ID or change to the replay cursor. */
|
|
2
|
+
export declare const SUPERSEDED_FRAME = "event: closed\ndata: {\"reason\":\"superseded\"}\n\n";
|
|
3
|
+
interface StreamSlot {
|
|
4
|
+
begin(max: number): void;
|
|
5
|
+
close(): void;
|
|
6
|
+
}
|
|
7
|
+
/** One instance per SSE family and replica. Only connections whose response has begun use a slot. */
|
|
8
|
+
export declare class PerAccountStreamLimit {
|
|
9
|
+
private readonly byAccount;
|
|
10
|
+
register(accountId: string, supersede: () => void): StreamSlot;
|
|
11
|
+
countOf(accountId: string): number;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** A transport close, with no event ID or change to the replay cursor. */
|
|
2
|
+
export const SUPERSEDED_FRAME = 'event: closed\ndata: {"reason":"superseded"}\n\n';
|
|
3
|
+
/** One instance per SSE family and replica. Only connections whose response has begun use a slot. */
|
|
4
|
+
export class PerAccountStreamLimit {
|
|
5
|
+
byAccount = new Map();
|
|
6
|
+
register(accountId, supersede) {
|
|
7
|
+
let state = "waiting";
|
|
8
|
+
// Each registration has its own identity, even if two slots share a callback.
|
|
9
|
+
const evict = () => supersede();
|
|
10
|
+
return {
|
|
11
|
+
begin: (max) => {
|
|
12
|
+
if (state !== "waiting")
|
|
13
|
+
return;
|
|
14
|
+
state = "open";
|
|
15
|
+
const streams = this.byAccount.get(accountId) ?? [];
|
|
16
|
+
const victims = streams.splice(0, Math.max(0, streams.length - max + 1));
|
|
17
|
+
streams.push(evict);
|
|
18
|
+
this.byAccount.set(accountId, streams);
|
|
19
|
+
// An evicted connection cleans itself up synchronously. Publish the new list first.
|
|
20
|
+
for (const victim of victims)
|
|
21
|
+
victim();
|
|
22
|
+
},
|
|
23
|
+
close: () => {
|
|
24
|
+
if (state === "open") {
|
|
25
|
+
const streams = this.byAccount.get(accountId);
|
|
26
|
+
const index = streams?.indexOf(evict) ?? -1;
|
|
27
|
+
if (index >= 0 && streams !== undefined) {
|
|
28
|
+
streams.splice(index, 1);
|
|
29
|
+
if (streams.length === 0)
|
|
30
|
+
this.byAccount.delete(accountId);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
state = "closed";
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
countOf(accountId) {
|
|
38
|
+
return this.byAccount.get(accountId)?.length ?? 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -26,6 +26,8 @@ declare const DraftParams: z.ZodObject<{
|
|
|
26
26
|
* (插件 `ctx.ui.invalidate`)就发 `event: ui`(`data: {"plugin","contribution"}`);
|
|
27
27
|
* - 每 `runtime.sseHeartbeatMs` 发 `: ping` 注释;每 `runtime.sseRecheckMs` 复核凭据(会话未吊销 / 令牌仍有效,
|
|
28
28
|
* access token 到期本身不算失效)与可见性,失败时发 `event: error`(`data: {"code"}`)后关闭流;
|
|
29
|
+
* - over `runtime.conversationStreamMaxPerAccount`, the oldest of the account's streams on
|
|
30
|
+
* this replica ends with `event: closed` and `data: {"reason":"superseded"}` (no event ID);
|
|
29
31
|
* - 用 `@Res()` + `reply.hijack()` 直接写原始响应,绕开 Nest / Fastify 的响应处理与缓冲。
|
|
30
32
|
* 代理(Web 层)需透传 `x-accel-buffering: no`、`cache-control: no-cache`。
|
|
31
33
|
*/
|
|
@@ -53,6 +53,8 @@ class RunDraftParamsDto extends createZodDto(DraftParams, "RunDraftParams") {
|
|
|
53
53
|
* (插件 `ctx.ui.invalidate`)就发 `event: ui`(`data: {"plugin","contribution"}`);
|
|
54
54
|
* - 每 `runtime.sseHeartbeatMs` 发 `: ping` 注释;每 `runtime.sseRecheckMs` 复核凭据(会话未吊销 / 令牌仍有效,
|
|
55
55
|
* access token 到期本身不算失效)与可见性,失败时发 `event: error`(`data: {"code"}`)后关闭流;
|
|
56
|
+
* - over `runtime.conversationStreamMaxPerAccount`, the oldest of the account's streams on
|
|
57
|
+
* this replica ends with `event: closed` and `data: {"reason":"superseded"}` (no event ID);
|
|
56
58
|
* - 用 `@Res()` + `reply.hijack()` 直接写原始响应,绕开 Nest / Fastify 的响应处理与缓冲。
|
|
57
59
|
* 代理(Web 层)需透传 `x-accel-buffering: no`、`cache-control: no-cache`。
|
|
58
60
|
*/
|
package/dist/runtime/stream.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export interface StreamHandle {
|
|
|
60
60
|
*/
|
|
61
61
|
export declare class ConversationStreams {
|
|
62
62
|
private readonly active;
|
|
63
|
+
private readonly limit;
|
|
63
64
|
/** Set by {@link closeAll}: streams opened afterwards end as soon as they begin. */
|
|
64
65
|
private closing;
|
|
65
66
|
private readonly d;
|
package/dist/runtime/stream.js
CHANGED
|
@@ -19,6 +19,7 @@ import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
|
|
|
19
19
|
import { OrgSettingsService } from "../orgs/settings.service.js";
|
|
20
20
|
import { isUiBusMessage, uiFrame } from "../ui/registry.js";
|
|
21
21
|
import { RunDrafts } from "./run-drafts.js";
|
|
22
|
+
import { PerAccountStreamLimit, SUPERSEDED_FRAME } from "./stream-limit.js";
|
|
22
23
|
/** 补读事件的分页大小。 */
|
|
23
24
|
const PAGE = 500;
|
|
24
25
|
/** 慢客户端的积压上限:超过即关闭流,客户端带 Last-Event-ID 重连补读。 */
|
|
@@ -96,6 +97,7 @@ const suggestionFrame = (s) => `event: suggestion\ndata: ${JSON.stringify({ runI
|
|
|
96
97
|
*/
|
|
97
98
|
let ConversationStreams = class ConversationStreams {
|
|
98
99
|
active = new Set();
|
|
100
|
+
limit = new PerAccountStreamLimit();
|
|
99
101
|
/** Set by {@link closeAll}: streams opened afterwards end as soon as they begin. */
|
|
100
102
|
closing = false;
|
|
101
103
|
d;
|
|
@@ -131,7 +133,7 @@ let ConversationStreams = class ConversationStreams {
|
|
|
131
133
|
throw new ApiError(denied, DENIAL_MESSAGES[denied] ?? "Access denied");
|
|
132
134
|
if (this.closing)
|
|
133
135
|
return endedStream(out);
|
|
134
|
-
const conn = new Connection(this.d, p, out, () => this.active.delete(conn));
|
|
136
|
+
const conn = new Connection(this.d, p, out, this.limit, () => this.active.delete(conn));
|
|
135
137
|
this.active.add(conn);
|
|
136
138
|
try {
|
|
137
139
|
await conn.subscribe();
|
|
@@ -205,11 +207,13 @@ class Connection {
|
|
|
205
207
|
timers = [];
|
|
206
208
|
rechecking = false;
|
|
207
209
|
begun = false;
|
|
208
|
-
|
|
210
|
+
slot;
|
|
211
|
+
constructor(d, p, out, limit, onClosed) {
|
|
209
212
|
this.d = d;
|
|
210
213
|
this.p = p;
|
|
211
214
|
this.out = out;
|
|
212
215
|
this.onClosed = onClosed;
|
|
216
|
+
this.slot = limit.register(p.viewerAccountId, () => this.close("end", SUPERSEDED_FRAME));
|
|
213
217
|
this.lastSeq = p.afterSeq;
|
|
214
218
|
// 所有输出串行:先回放,之后按到达顺序处理频道消息;begin() 之前闸门关着。
|
|
215
219
|
this.chain = new Promise((resolve) => {
|
|
@@ -230,17 +234,19 @@ class Connection {
|
|
|
230
234
|
this.unsubscribe = un;
|
|
231
235
|
}
|
|
232
236
|
begin() {
|
|
233
|
-
if (this.closed)
|
|
237
|
+
if (this.closed || this.begun)
|
|
234
238
|
return;
|
|
235
239
|
this.begun = true;
|
|
236
|
-
const { sseHeartbeatMs, sseRecheckMs } = this.d.config.get().runtime;
|
|
240
|
+
const { sseHeartbeatMs, sseRecheckMs, conversationStreamMaxPerAccount } = this.d.config.get().runtime;
|
|
241
|
+
this.slot.begin(conversationStreamMaxPerAccount);
|
|
237
242
|
this.timers.push(setInterval(() => this.write(": ping\n\n"), sseHeartbeatMs), setInterval(() => void this.recheck(), sseRecheckMs));
|
|
238
243
|
this.openGate();
|
|
239
244
|
}
|
|
240
|
-
close(mode = "end") {
|
|
245
|
+
close(mode = "end", finalFrame) {
|
|
241
246
|
if (this.closed)
|
|
242
247
|
return;
|
|
243
248
|
this.closed = true;
|
|
249
|
+
this.slot.close();
|
|
244
250
|
for (const t of this.timers)
|
|
245
251
|
clearInterval(t);
|
|
246
252
|
this.timers = [];
|
|
@@ -255,8 +261,11 @@ class Connection {
|
|
|
255
261
|
try {
|
|
256
262
|
if (mode === "abort")
|
|
257
263
|
this.out.abort();
|
|
258
|
-
else
|
|
264
|
+
else {
|
|
265
|
+
if (finalFrame !== undefined)
|
|
266
|
+
this.out.write(finalFrame);
|
|
259
267
|
this.out.end();
|
|
268
|
+
}
|
|
260
269
|
}
|
|
261
270
|
catch {
|
|
262
271
|
// 连接已断开
|
|
@@ -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 { EventLogModule } from "../conversations/event-log.js";
|
|
9
|
+
import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
|
|
9
10
|
import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
|
|
10
11
|
import { PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
11
12
|
import { PermissionCeilingWrites } from "./permission-ceiling-writes.js";
|
|
@@ -22,7 +23,11 @@ let PermissionCeilingWritesModule = class PermissionCeilingWritesModule {
|
|
|
22
23
|
};
|
|
23
24
|
PermissionCeilingWritesModule = __decorate([
|
|
24
25
|
Module({
|
|
25
|
-
imports: [
|
|
26
|
+
imports: [
|
|
27
|
+
// invalidation hints its writers publish after their commit
|
|
28
|
+
InvalidationHintsModule,
|
|
29
|
+
EventLogModule,
|
|
30
|
+
],
|
|
26
31
|
providers: [
|
|
27
32
|
PermissionTransitions,
|
|
28
33
|
PermissionCeilingWrites,
|
|
@@ -3,6 +3,7 @@ import { EventLog } from "../conversations/event-log.js";
|
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
5
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
6
|
+
import { type HintPublisher } from "../invalidation/audiences.js";
|
|
6
7
|
import { type AuthorityLevel, type AuthoritySubject, PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
7
8
|
export declare const PERMISSION_APPROVAL_RECHECK = "permission-approval-recheck";
|
|
8
9
|
export type PermissionTransition = {
|
|
@@ -23,7 +24,8 @@ export declare class PermissionTransitions {
|
|
|
23
24
|
private readonly locks;
|
|
24
25
|
private readonly events;
|
|
25
26
|
private readonly outbox;
|
|
26
|
-
|
|
27
|
+
private readonly hints;
|
|
28
|
+
constructor(db: KernelDb, txHost: TransactionHost, locks: PermissionAuthorityLock, events: EventLog, outbox: OutboxService, hints: HintPublisher);
|
|
27
29
|
recordLocked(change: PermissionTransition, writer: {
|
|
28
30
|
subject: AuthoritySubject;
|
|
29
31
|
level: AuthorityLevel;
|
|
@@ -15,7 +15,11 @@ 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 { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
18
|
+
import { approvalTopics } from "../invalidation/audiences.js";
|
|
19
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
20
|
+
import { ORG_ROLES } from "../orgs/roles.js";
|
|
18
21
|
import { PermissionAuthorityLock, } from "./permission-authority-lock.js";
|
|
22
|
+
const isOrgRole = (v) => v !== null && ORG_ROLES.includes(v);
|
|
19
23
|
export const PERMISSION_APPROVAL_RECHECK = "permission-approval-recheck";
|
|
20
24
|
/** Canonical lower write: never takes descendant authority or imports the tools domain. */
|
|
21
25
|
let PermissionTransitions = class PermissionTransitions {
|
|
@@ -24,12 +28,14 @@ let PermissionTransitions = class PermissionTransitions {
|
|
|
24
28
|
locks;
|
|
25
29
|
events;
|
|
26
30
|
outbox;
|
|
27
|
-
|
|
31
|
+
hints;
|
|
32
|
+
constructor(db, txHost, locks, events, outbox, hints) {
|
|
28
33
|
this.db = db;
|
|
29
34
|
this.txHost = txHost;
|
|
30
35
|
this.locks = locks;
|
|
31
36
|
this.events = events;
|
|
32
37
|
this.outbox = outbox;
|
|
38
|
+
this.hints = hints;
|
|
33
39
|
}
|
|
34
40
|
async recordLocked(change, writer) {
|
|
35
41
|
const id = writer.level === "platform"
|
|
@@ -104,6 +110,14 @@ let PermissionTransitions = class PermissionTransitions {
|
|
|
104
110
|
.orderBy("id")
|
|
105
111
|
.forUpdate()
|
|
106
112
|
.execute();
|
|
113
|
+
// the superseded cards leave their deciders' inboxes (one publish for all of them)
|
|
114
|
+
const asked = cards.flatMap((card) => approvalTopics({
|
|
115
|
+
orgId,
|
|
116
|
+
requestedFor: card.requested_for,
|
|
117
|
+
approverRole: isOrgRole(card.approver_role) ? card.approver_role : null,
|
|
118
|
+
}));
|
|
119
|
+
if (asked.length > 0)
|
|
120
|
+
this.hints.publishAfterCommit(asked, { kind: "inbox" });
|
|
107
121
|
for (const card of cards) {
|
|
108
122
|
await this.db
|
|
109
123
|
.updateTable("approvals")
|
|
@@ -153,6 +167,7 @@ PermissionTransitions = __decorate([
|
|
|
153
167
|
__param(1, Inject(TransactionHost)),
|
|
154
168
|
__param(2, Inject(PermissionAuthorityLock)),
|
|
155
169
|
__param(3, Inject(EventLog)),
|
|
156
|
-
__param(4, Inject(OutboxService))
|
|
170
|
+
__param(4, Inject(OutboxService)),
|
|
171
|
+
__param(5, Inject(InvalidationHints))
|
|
157
172
|
], PermissionTransitions);
|
|
158
173
|
export { PermissionTransitions };
|
|
@@ -60,9 +60,9 @@ export declare function connectionActiveResult(row: {
|
|
|
60
60
|
lastError: string | null;
|
|
61
61
|
} | undefined, secrets: readonly string[]): SetupCheckResult;
|
|
62
62
|
/**
|
|
63
|
-
* Registers
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* Registers read-only kernel checks on every replica. Deployment checks need no org target.
|
|
64
|
+
* Org checks receive the authorized target resolved by the service.
|
|
65
|
+
* `capybara:oauth-token-endpoint` is the only one that leaves the kernel (§10.6).
|
|
66
66
|
*/
|
|
67
67
|
export declare class KernelChecks implements OnModuleInit {
|
|
68
68
|
private readonly registry;
|
|
@@ -144,9 +144,9 @@ export function connectionActiveResult(row, secrets) {
|
|
|
144
144
|
return { status: "ok", reason: KERNEL_CHECK_TEXTS.connectionActive };
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* Registers
|
|
148
|
-
*
|
|
149
|
-
*
|
|
147
|
+
* Registers read-only kernel checks on every replica. Deployment checks need no org target.
|
|
148
|
+
* Org checks receive the authorized target resolved by the service.
|
|
149
|
+
* `capybara:oauth-token-endpoint` is the only one that leaves the kernel (§10.6).
|
|
150
150
|
*/
|
|
151
151
|
let KernelChecks = class KernelChecks {
|
|
152
152
|
registry;
|
|
@@ -163,7 +163,7 @@ let KernelChecks = class KernelChecks {
|
|
|
163
163
|
}
|
|
164
164
|
onModuleInit() {
|
|
165
165
|
const r = this.registry;
|
|
166
|
-
r.
|
|
166
|
+
r.registerDeploymentKernel("capybara:public-url", async () => publicUrlCheck(this.config.get()));
|
|
167
167
|
r.registerKernel("capybara:webhook-public", "channel-connection", async () => webhookPublicCheck(this.config.get()));
|
|
168
168
|
r.registerKernel("capybara:webhook-received", "channel-connection", (a) => this.webhookReceived(a));
|
|
169
169
|
r.registerKernel("capybara:connection-active", "channel-connection", (a) => this.connectionActive(a));
|
|
@@ -44,13 +44,20 @@ export interface KernelCheckArgs {
|
|
|
44
44
|
}
|
|
45
45
|
/** A kernel check's implementation. */
|
|
46
46
|
export type KernelCheckRun = (args: KernelCheckArgs) => Promise<SetupCheckResult>;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
source: "kernel";
|
|
50
|
-
id: string;
|
|
47
|
+
type KernelCheck = {
|
|
48
|
+
scope: "org";
|
|
51
49
|
place: SetupGuidePlace | "any";
|
|
52
50
|
run: KernelCheckRun;
|
|
53
51
|
} | {
|
|
52
|
+
scope: "deployment";
|
|
53
|
+
place: "any";
|
|
54
|
+
run: () => Promise<SetupCheckResult>;
|
|
55
|
+
};
|
|
56
|
+
/** A check found for a guide's `::check` line. */
|
|
57
|
+
export type ResolvedSetupCheck = ({
|
|
58
|
+
source: "kernel";
|
|
59
|
+
id: string;
|
|
60
|
+
} & KernelCheck) | {
|
|
54
61
|
source: "plugin";
|
|
55
62
|
id: string;
|
|
56
63
|
place: SetupGuidePlace;
|
|
@@ -73,8 +80,11 @@ export declare class SetupCheckRegistry {
|
|
|
73
80
|
private readonly extensions;
|
|
74
81
|
private readonly kernel;
|
|
75
82
|
constructor(extensions: Pick<ExtensionRegistry, "current">);
|
|
76
|
-
/** Registers a kernel check
|
|
83
|
+
/** Registers a kernel check that needs an org target. */
|
|
77
84
|
registerKernel(id: `capybara:${string}`, place: SetupGuidePlace | "any", run: KernelCheckRun): void;
|
|
85
|
+
/** Registers a target-independent kernel check available on platform and org guides. */
|
|
86
|
+
registerDeploymentKernel(id: `capybara:${string}`, run: () => Promise<SetupCheckResult>): void;
|
|
87
|
+
private addKernelCheck;
|
|
78
88
|
/**
|
|
79
89
|
* The check behind a guide's `::check <id>` line of `plugin`'s guide: a kernel check for
|
|
80
90
|
* `capybara:*`, else the plugin's own (null when this replica does not run the extension or the
|
|
@@ -84,3 +94,4 @@ export declare class SetupCheckRegistry {
|
|
|
84
94
|
/** Whether `plugin` runs on this replica. */
|
|
85
95
|
running(plugin: string): boolean;
|
|
86
96
|
}
|
|
97
|
+
export {};
|
|
@@ -25,8 +25,16 @@ let SetupCheckRegistry = class SetupCheckRegistry {
|
|
|
25
25
|
constructor(extensions) {
|
|
26
26
|
this.extensions = extensions;
|
|
27
27
|
}
|
|
28
|
-
/** Registers a kernel check
|
|
28
|
+
/** Registers a kernel check that needs an org target. */
|
|
29
29
|
registerKernel(id, place, run) {
|
|
30
|
+
this.addKernelCheck(id, { scope: "org", place, run });
|
|
31
|
+
}
|
|
32
|
+
/** Registers a target-independent kernel check available on platform and org guides. */
|
|
33
|
+
registerDeploymentKernel(id, run) {
|
|
34
|
+
this.addKernelCheck(id, { scope: "deployment", place: "any", run });
|
|
35
|
+
}
|
|
36
|
+
addKernelCheck(id, check) {
|
|
37
|
+
const { place, run } = check;
|
|
30
38
|
if (!KERNEL_ID_RE.test(id))
|
|
31
39
|
throw new Error(`setup check id "${id}" is not capybara:<id>`);
|
|
32
40
|
if (place !== "any" && !SETUP_GUIDE_PLACES.includes(place)) {
|
|
@@ -36,7 +44,7 @@ let SetupCheckRegistry = class SetupCheckRegistry {
|
|
|
36
44
|
throw new Error(`setup check "${id}": run must be a function`);
|
|
37
45
|
if (this.kernel.has(id))
|
|
38
46
|
throw new Error(`duplicate kernel setup check "${id}"`);
|
|
39
|
-
this.kernel.set(id, Object.freeze(
|
|
47
|
+
this.kernel.set(id, Object.freeze(check));
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* The check behind a guide's `::check <id>` line of `plugin`'s guide: a kernel check for
|
|
@@ -46,7 +54,7 @@ let SetupCheckRegistry = class SetupCheckRegistry {
|
|
|
46
54
|
resolve(plugin, id) {
|
|
47
55
|
if (id.startsWith("capybara:")) {
|
|
48
56
|
const k = this.kernel.get(id);
|
|
49
|
-
return k ? { source: "kernel", id,
|
|
57
|
+
return k ? { source: "kernel", id, ...k } : null;
|
|
50
58
|
}
|
|
51
59
|
const inst = this.extensions.current(plugin);
|
|
52
60
|
const c = inst?.setupChecks.get(id);
|
|
@@ -78,8 +78,7 @@ export declare class SetupChecksService {
|
|
|
78
78
|
* /admin/extensions/:name/guides/:guideId/checks/:checkId/run`, super admins: the route's
|
|
79
79
|
* guard) with the extension's platform deployment config, `orgId: null`. The cache, single
|
|
80
80
|
* flight, cooldown and concurrency cap are the org places', keyed by the deployment; the
|
|
81
|
-
* per-account limit is shared with every other run.
|
|
82
|
-
* here.
|
|
81
|
+
* per-account limit is shared with every other run. Deployment-scoped kernel checks also apply.
|
|
83
82
|
*/
|
|
84
83
|
deploymentRun(accountId: string, plugin: string, guideId: string, checkId: string, body: {
|
|
85
84
|
force?: boolean | undefined;
|
|
@@ -157,8 +157,7 @@ let SetupChecksService = class SetupChecksService {
|
|
|
157
157
|
* /admin/extensions/:name/guides/:guideId/checks/:checkId/run`, super admins: the route's
|
|
158
158
|
* guard) with the extension's platform deployment config, `orgId: null`. The cache, single
|
|
159
159
|
* flight, cooldown and concurrency cap are the org places', keyed by the deployment; the
|
|
160
|
-
* per-account limit is shared with every other run.
|
|
161
|
-
* here.
|
|
160
|
+
* per-account limit is shared with every other run. Deployment-scoped kernel checks also apply.
|
|
162
161
|
*/
|
|
163
162
|
async deploymentRun(accountId, plugin, guideId, checkId, body) {
|
|
164
163
|
const p = await this.prepareDeployment(accountId, plugin, guideId, checkId);
|
|
@@ -249,9 +248,9 @@ let SetupChecksService = class SetupChecksService {
|
|
|
249
248
|
return unknownState(REASONS.unregistered);
|
|
250
249
|
if (check.place !== "any" && check.place !== p.place)
|
|
251
250
|
return unknownState(REASONS.otherPlace);
|
|
252
|
-
|
|
253
|
-
if (check.source === "kernel" && p.orgId === null)
|
|
251
|
+
if (check.source === "kernel" && check.scope === "org" && p.orgId === null) {
|
|
254
252
|
return unknownState(REASONS.otherPlace);
|
|
253
|
+
}
|
|
255
254
|
const keys = this.keys(p, checkId);
|
|
256
255
|
const revision = await this.revision(p, accountScoped(p, checkId));
|
|
257
256
|
const fingerprint = this.fingerprint(p, revision);
|
|
@@ -548,10 +547,12 @@ let SetupChecksService = class SetupChecksService {
|
|
|
548
547
|
// the in-flight tracker merges the instance's abort into the signal the check gets
|
|
549
548
|
() => check.inflight.run(signal, (s) => check.run(this.pluginArgs(p, material, config, locale, s))), () => (check.signal.aborted ? "unloaded" : "timeout"));
|
|
550
549
|
}
|
|
550
|
+
else if (check.scope === "deployment") {
|
|
551
|
+
answer = await raceSignal(timeout, check.run, () => "timeout");
|
|
552
|
+
}
|
|
551
553
|
else {
|
|
552
|
-
// refused for the deployment before the lock (`runPrepared`)
|
|
553
554
|
if (p.orgId === null)
|
|
554
|
-
throw new Error("
|
|
555
|
+
throw new Error("an org kernel check requires an org target");
|
|
555
556
|
const signal = timeout;
|
|
556
557
|
const args = Object.freeze({
|
|
557
558
|
orgId: p.orgId,
|
|
@@ -3,6 +3,7 @@ import { EventLog } from "../conversations/event-log.js";
|
|
|
3
3
|
import type { KernelSchemaDb, SkillManifest } from "../db/kernel-schema.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { type HintPublisher } from "../invalidation/audiences.js";
|
|
6
7
|
import type { KernelLogger } from "../log.js";
|
|
7
8
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
8
9
|
import { StorageService } from "../storage/storage.service.js";
|
|
@@ -120,10 +121,14 @@ export declare class AgentSkillsService {
|
|
|
120
121
|
private readonly skills;
|
|
121
122
|
private readonly attachments;
|
|
122
123
|
private readonly orgLock;
|
|
124
|
+
/** A new change request publishes `inbox` to the org's admins after the commit. */
|
|
125
|
+
private readonly hints;
|
|
123
126
|
private readonly catalogDeps;
|
|
124
127
|
constructor(db: KernelDb, storage: StorageService, eventLog: EventLog, log: KernelLogger, txHost: TransactionHost,
|
|
125
128
|
/** An org admin maintainer's version of a shared skill is an org skill version. */
|
|
126
|
-
skills: SkillsService, attachments: AttachmentsService, orgLock: OrgLock
|
|
129
|
+
skills: SkillsService, attachments: AttachmentsService, orgLock: OrgLock,
|
|
130
|
+
/** A new change request publishes `inbox` to the org's admins after the commit. */
|
|
131
|
+
hints: HintPublisher);
|
|
127
132
|
/**
|
|
128
133
|
* Registers a skill package upload onto an agent (presigned, `application/zip`, <= 50 MB): only
|
|
129
134
|
* the agent's current owner (403 `forbidden`, 404 `agent.not_found` when not visible). Agent
|
|
@@ -22,6 +22,8 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
22
22
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
23
23
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
24
24
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
25
|
+
import { publishOrgAdminsInbox } from "../invalidation/audiences.js";
|
|
26
|
+
import { InvalidationHints } from "../invalidation/invalidation-hints.js";
|
|
25
27
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
26
28
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
27
29
|
import { StorageService } from "../storage/storage.service.js";
|
|
@@ -205,10 +207,13 @@ let AgentSkillsService = class AgentSkillsService {
|
|
|
205
207
|
skills;
|
|
206
208
|
attachments;
|
|
207
209
|
orgLock;
|
|
210
|
+
hints;
|
|
208
211
|
catalogDeps;
|
|
209
212
|
constructor(db, storage, eventLog, log, txHost,
|
|
210
213
|
/** An org admin maintainer's version of a shared skill is an org skill version. */
|
|
211
|
-
skills, attachments, orgLock
|
|
214
|
+
skills, attachments, orgLock,
|
|
215
|
+
/** A new change request publishes `inbox` to the org's admins after the commit. */
|
|
216
|
+
hints) {
|
|
212
217
|
this.db = db;
|
|
213
218
|
this.storage = storage;
|
|
214
219
|
this.eventLog = eventLog;
|
|
@@ -217,7 +222,8 @@ let AgentSkillsService = class AgentSkillsService {
|
|
|
217
222
|
this.skills = skills;
|
|
218
223
|
this.attachments = attachments;
|
|
219
224
|
this.orgLock = orgLock;
|
|
220
|
-
this.
|
|
225
|
+
this.hints = hints;
|
|
226
|
+
this.catalogDeps = { db, log, eventLog, hints };
|
|
221
227
|
}
|
|
222
228
|
/**
|
|
223
229
|
* Registers a skill package upload onto an agent (presigned, `application/zip`, <= 50 MB): only
|
|
@@ -735,6 +741,7 @@ let AgentSkillsService = class AgentSkillsService {
|
|
|
735
741
|
requested_in_conversation: here,
|
|
736
742
|
})
|
|
737
743
|
.execute();
|
|
744
|
+
publishOrgAdminsInbox(this.hints, [actor.orgId]);
|
|
738
745
|
await audit(this.db.db, {
|
|
739
746
|
actorAccountId: actor.accountId,
|
|
740
747
|
...(actor.actorTokenId !== undefined && { actorTokenId: actor.actorTokenId }),
|
|
@@ -862,6 +869,7 @@ let AgentSkillsService = class AgentSkillsService {
|
|
|
862
869
|
requested_in_conversation: null,
|
|
863
870
|
})
|
|
864
871
|
.execute();
|
|
872
|
+
publishOrgAdminsInbox(this.hints, [actor.orgId]);
|
|
865
873
|
await audit(this.db.db, {
|
|
866
874
|
...who,
|
|
867
875
|
action: "skill.share_requested",
|
|
@@ -966,6 +974,7 @@ AgentSkillsService = __decorate([
|
|
|
966
974
|
__param(4, Inject(TransactionHost)),
|
|
967
975
|
__param(5, Inject(SkillsService)),
|
|
968
976
|
__param(6, Inject(AttachmentsService)),
|
|
969
|
-
__param(7, Inject(OrgLock))
|
|
977
|
+
__param(7, Inject(OrgLock)),
|
|
978
|
+
__param(8, Inject(InvalidationHints))
|
|
970
979
|
], AgentSkillsService);
|
|
971
980
|
export { AgentSkillsService };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventLog } from "../conversations/event-log.js";
|
|
2
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
3
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import { type HintPublisher } from "../invalidation/audiences.js";
|
|
4
5
|
import type { KernelLogger } from "../log.js";
|
|
5
6
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
6
7
|
import { StorageService } from "../storage/storage.service.js";
|
|
@@ -86,10 +87,14 @@ export declare class SkillChangesService {
|
|
|
86
87
|
private readonly orgLock;
|
|
87
88
|
/** An approved version is an org skill version. */
|
|
88
89
|
private readonly skills;
|
|
90
|
+
/** A decision publishes `inbox` to the org's admins after the commit. */
|
|
91
|
+
private readonly hints;
|
|
89
92
|
private readonly catalogDeps;
|
|
90
93
|
constructor(db: KernelDb, storage: StorageService, eventLog: EventLog, log: KernelLogger, txHost: TransactionHost, orgLock: OrgLock,
|
|
91
94
|
/** An approved version is an org skill version. */
|
|
92
|
-
skills: SkillsService
|
|
95
|
+
skills: SkillsService,
|
|
96
|
+
/** A decision publishes `inbox` to the org's admins after the commit. */
|
|
97
|
+
hints: HintPublisher);
|
|
93
98
|
/**
|
|
94
99
|
* An org admin decides a request (see the class comment): not an org admin -> 403 `forbidden`;
|
|
95
100
|
* already decided -> 409 `skill_change.already_decided`; not in this org -> 404. Approving
|