@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
|
@@ -16,6 +16,17 @@ const SCOPE_JOB_OPTS = {
|
|
|
16
16
|
removeOnComplete: true,
|
|
17
17
|
removeOnFail: true,
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* The external conversation calls' retry policy: 10 attempts from 2 s, doubling (about 17 min in
|
|
21
|
+
* all) before the call is dropped with a failed turn; removed once done, so the same id owed again
|
|
22
|
+
* (a chained send) is not deduped away.
|
|
23
|
+
*/
|
|
24
|
+
const EXTERNAL_CALL_OPTS = {
|
|
25
|
+
attempts: 10,
|
|
26
|
+
backoff: { type: "exponential", delay: 2_000 },
|
|
27
|
+
removeOnComplete: true,
|
|
28
|
+
removeOnFail: true,
|
|
29
|
+
};
|
|
19
30
|
/**
|
|
20
31
|
* Every job name added through the outbox. The task that introduces a job name adds its entry; a
|
|
21
32
|
* name without one does not type-check as an `OutboxJobName` (`add` does not check it at runtime).
|
|
@@ -554,6 +565,39 @@ export const OUTBOX_JOBS = {
|
|
|
554
565
|
removeOnFail: true,
|
|
555
566
|
},
|
|
556
567
|
},
|
|
568
|
+
// `conversations/external/external-calls.ts` EXTERNAL_CALL_JOBS: owed by the transaction that
|
|
569
|
+
// writes a person's message to an external conversation (start, send), their answer to its
|
|
570
|
+
// request, a stop, or its deletion (local agents spec Part 2), under `externalCallJob`
|
|
571
|
+
"external-start": {
|
|
572
|
+
queue: "cap-external-calls",
|
|
573
|
+
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",
|
|
574
|
+
processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts",
|
|
575
|
+
opts: EXTERNAL_CALL_OPTS,
|
|
576
|
+
},
|
|
577
|
+
"external-send": {
|
|
578
|
+
queue: "cap-external-calls",
|
|
579
|
+
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",
|
|
580
|
+
processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts",
|
|
581
|
+
opts: EXTERNAL_CALL_OPTS,
|
|
582
|
+
},
|
|
583
|
+
"external-answer": {
|
|
584
|
+
queue: "cap-external-calls",
|
|
585
|
+
idempotent: "the answer is written once per request (its idempotency key); the target's answer is idempotent by requestId",
|
|
586
|
+
processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts",
|
|
587
|
+
opts: EXTERNAL_CALL_OPTS,
|
|
588
|
+
},
|
|
589
|
+
"external-stop": {
|
|
590
|
+
queue: "cap-external-calls",
|
|
591
|
+
idempotent: "stopping a turn that is not running is a no-op for the target; the job id is per conversation and last seq",
|
|
592
|
+
processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts",
|
|
593
|
+
opts: EXTERNAL_CALL_OPTS,
|
|
594
|
+
},
|
|
595
|
+
"external-deleted": {
|
|
596
|
+
queue: "cap-external-calls",
|
|
597
|
+
idempotent: "releasing what the target holds for a deleted conversation twice releases nothing more; the job id is per conversation and last seq",
|
|
598
|
+
processedIn: "packages/kernel/src/conversations/external/external-calls.processor.ts",
|
|
599
|
+
opts: EXTERNAL_CALL_OPTS,
|
|
600
|
+
},
|
|
557
601
|
// `extensions/run-lifecycle-owe.ts` RUN_LIFECYCLE_JOB: owed by the transaction that starts a
|
|
558
602
|
// run, suspends it on a person, resumes it, ends it (finished, failed, aborted) or declines,
|
|
559
603
|
// expires or gives up on directed work, once per phase of a run (and wait) and plugin
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type SelectQueryBuilder } from "kysely";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* Page-number reads on a snapshot (table pagination spec §2.3): a paged route takes `page`,
|
|
6
|
+
* `size`, its filters and an optional `asOf`, and answers {@link Paged}. Shared by every route a
|
|
7
|
+
* DataTable pages on the server; the snapshot key (`asOf`) is the route's own (an append-only
|
|
8
|
+
* table uses its id, a sortable table its `(sort column, id)`).
|
|
9
|
+
*/
|
|
10
|
+
/** The page sizes a table offers (the Pagination select). */
|
|
11
|
+
export declare const PAGE_SIZES: readonly [20, 50, 100];
|
|
12
|
+
/** `total` stops counting here; above it `totalCapped` is true and pages past it are refused. */
|
|
13
|
+
export declare const PAGED_TOTAL_CAP = 10000;
|
|
14
|
+
/** `newer` stops counting here. */
|
|
15
|
+
export declare const PAGED_NEWER_CAP = 1000;
|
|
16
|
+
/** One page of a paged route (spec §2.3). */
|
|
17
|
+
export interface Paged<T> {
|
|
18
|
+
items: T[];
|
|
19
|
+
/** The page read, 1-based. */
|
|
20
|
+
page: number;
|
|
21
|
+
/** Rows per page: 20, 50 or 100. */
|
|
22
|
+
size: number;
|
|
23
|
+
/** The matching rows under the snapshot, at most {@link PAGED_TOTAL_CAP}. */
|
|
24
|
+
total: number;
|
|
25
|
+
/** More rows match than `total` says. */
|
|
26
|
+
totalCapped: boolean;
|
|
27
|
+
/** The snapshot key: pass it back to read the other pages of the same snapshot. */
|
|
28
|
+
asOf: string;
|
|
29
|
+
/** Rows above `asOf` matching the filters, at most {@link PAGED_NEWER_CAP}; 0 without `asOf`. */
|
|
30
|
+
newer: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The query fields every paged route takes (spec §2.3), to `extend` a route's filters with. `asOf`
|
|
34
|
+
* is the route's own (its snapshot key format), e.g. {@link bigserialAsOf}.
|
|
35
|
+
*/
|
|
36
|
+
export declare const PageQueryFields: {
|
|
37
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
38
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
39
|
+
};
|
|
40
|
+
/** An `asOf` that is a bigserial id (a decimal string), for append-only tables keyed by id. */
|
|
41
|
+
export declare function bigserialAsOf(what: string): z.ZodOptional<z.ZodString>;
|
|
42
|
+
/** The last page a size may read: pages past the counting cap are refused. */
|
|
43
|
+
export declare const lastReadablePage: (size: number) => number;
|
|
44
|
+
/** Refuses a page past {@link lastReadablePage} (400 `validation_failed`, spec §2.3). */
|
|
45
|
+
export declare function assertReadablePage(page: number, size: number): void;
|
|
46
|
+
/** `OFFSET` of a page. */
|
|
47
|
+
export declare const pageOffset: (page: number, size: number) => number;
|
|
48
|
+
/**
|
|
49
|
+
* `count(*)` of the rows `query` matches, stopped after `cap` (`SELECT count(*) FROM (… LIMIT
|
|
50
|
+
* cap + 1)`): above `cap` it answers `cap` and `capped` true. `query` is a filtered select whose
|
|
51
|
+
* selection and order are replaced.
|
|
52
|
+
*/
|
|
53
|
+
export declare function cappedCount(db: KernelSchemaDb, query: SelectQueryBuilder<any, any, any>, cap: number): Promise<{
|
|
54
|
+
count: number;
|
|
55
|
+
capped: boolean;
|
|
56
|
+
}>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ApiError } from "../../errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Page-number reads on a snapshot (table pagination spec §2.3): a paged route takes `page`,
|
|
6
|
+
* `size`, its filters and an optional `asOf`, and answers {@link Paged}. Shared by every route a
|
|
7
|
+
* DataTable pages on the server; the snapshot key (`asOf`) is the route's own (an append-only
|
|
8
|
+
* table uses its id, a sortable table its `(sort column, id)`).
|
|
9
|
+
*/
|
|
10
|
+
/** The page sizes a table offers (the Pagination select). */
|
|
11
|
+
export const PAGE_SIZES = [20, 50, 100];
|
|
12
|
+
/** `total` stops counting here; above it `totalCapped` is true and pages past it are refused. */
|
|
13
|
+
export const PAGED_TOTAL_CAP = 10_000;
|
|
14
|
+
/** `newer` stops counting here. */
|
|
15
|
+
export const PAGED_NEWER_CAP = 1_000;
|
|
16
|
+
/**
|
|
17
|
+
* The query fields every paged route takes (spec §2.3), to `extend` a route's filters with. `asOf`
|
|
18
|
+
* is the route's own (its snapshot key format), e.g. {@link bigserialAsOf}.
|
|
19
|
+
*/
|
|
20
|
+
export const PageQueryFields = {
|
|
21
|
+
page: z.coerce
|
|
22
|
+
.number()
|
|
23
|
+
.int()
|
|
24
|
+
.min(1)
|
|
25
|
+
// the upper bound depends on size: assertReadablePage refuses it with the one message
|
|
26
|
+
.default(1)
|
|
27
|
+
.describe("The page to read, 1-based (default 1)."),
|
|
28
|
+
size: z.coerce
|
|
29
|
+
.number()
|
|
30
|
+
.int()
|
|
31
|
+
.refine((v) => PAGE_SIZES.includes(v), "size must be 20, 50 or 100")
|
|
32
|
+
.default(PAGE_SIZES[0])
|
|
33
|
+
.describe("Rows per page: 20, 50 or 100 (default 20)."),
|
|
34
|
+
};
|
|
35
|
+
/** The largest `bigserial` id; a larger key would make PG refuse the comparison. */
|
|
36
|
+
const MAX_BIGINT = 9223372036854775807n;
|
|
37
|
+
/** An `asOf` that is a bigserial id (a decimal string), for append-only tables keyed by id. */
|
|
38
|
+
export function bigserialAsOf(what) {
|
|
39
|
+
return (z
|
|
40
|
+
.string()
|
|
41
|
+
.regex(/^\d{1,19}$/, `asOf must be ${what} (digits)`)
|
|
42
|
+
// checks do not abort: only digits reach BigInt
|
|
43
|
+
.refine((v) => !/^\d{1,19}$/.test(v) || BigInt(v) <= MAX_BIGINT, `asOf must be ${what}`)
|
|
44
|
+
.optional()
|
|
45
|
+
.describe(`The snapshot: the asOf an earlier page returned (${what}); absent: a new snapshot of the newest rows.`));
|
|
46
|
+
}
|
|
47
|
+
/** The last page a size may read: pages past the counting cap are refused. */
|
|
48
|
+
export const lastReadablePage = (size) => Math.ceil(PAGED_TOTAL_CAP / size);
|
|
49
|
+
/** Refuses a page past {@link lastReadablePage} (400 `validation_failed`, spec §2.3). */
|
|
50
|
+
export function assertReadablePage(page, size) {
|
|
51
|
+
const last = lastReadablePage(size);
|
|
52
|
+
if (page > last) {
|
|
53
|
+
throw new ApiError("validation_failed", `Page ${page} is past the last readable page (${last} at size ${size}, the first ${PAGED_TOTAL_CAP} rows); narrow the filters to reach older rows`, [{ path: "page", message: `page must be at most ${last} for size ${size}` }]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** `OFFSET` of a page. */
|
|
57
|
+
export const pageOffset = (page, size) => (page - 1) * size;
|
|
58
|
+
/**
|
|
59
|
+
* `count(*)` of the rows `query` matches, stopped after `cap` (`SELECT count(*) FROM (… LIMIT
|
|
60
|
+
* cap + 1)`): above `cap` it answers `cap` and `capped` true. `query` is a filtered select whose
|
|
61
|
+
* selection and order are replaced.
|
|
62
|
+
*/
|
|
63
|
+
export async function cappedCount(db,
|
|
64
|
+
// biome-ignore lint/suspicious/noExplicitAny: any table, any filters
|
|
65
|
+
query, cap) {
|
|
66
|
+
const limited = query
|
|
67
|
+
.clearSelect()
|
|
68
|
+
.clearOrderBy()
|
|
69
|
+
.select(sql `1`.as("one"))
|
|
70
|
+
.limit(cap + 1)
|
|
71
|
+
.as("capped");
|
|
72
|
+
const row = await db
|
|
73
|
+
.selectFrom(limited)
|
|
74
|
+
.select(sql `count(*)`.as("n"))
|
|
75
|
+
.executeTakeFirstOrThrow();
|
|
76
|
+
const n = Number(row.n);
|
|
77
|
+
return n > cap ? { count: cap, capped: true } : { count: n, capped: false };
|
|
78
|
+
}
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* (admin/health.service.ts) lists the same names from the feature constants;
|
|
5
5
|
* test/infra/queue-names.test.ts keeps the two equal.
|
|
6
6
|
*/
|
|
7
|
-
export declare const KERNEL_QUEUES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors", "cap-device-service-events"];
|
|
7
|
+
export declare const KERNEL_QUEUES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors", "cap-device-service-events", "cap-external-calls"];
|
|
8
8
|
export type KernelQueueName = (typeof KERNEL_QUEUES)[number];
|
package/dist/kernel.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { QueryExecutorProvider } from "kysely";
|
|
2
2
|
import type { KernelConfig } from "./config/schema.js";
|
|
3
3
|
import type { PendingExtension } from "./extensions/approvals.js";
|
|
4
|
+
import { type KernelFixtureTrust } from "./lifecycle/tokens.js";
|
|
4
5
|
/**
|
|
5
6
|
* The kernel migrations directory. `src/` and `dist/` are both one level below the package root,
|
|
6
7
|
* so this always points at `<package root>/src/migrations`: running from source with tsx and
|
|
@@ -11,7 +12,7 @@ export declare const KERNEL_MIGRATIONS_DIR: string;
|
|
|
11
12
|
/** The kernel's PG schema. */
|
|
12
13
|
export declare const KERNEL_SCHEMA = "capybara";
|
|
13
14
|
/** Static names of config-declared extensions, for deployment and fixture provisioning. */
|
|
14
|
-
export declare function declaredExtensionNames(specifiers: string[], resolveFrom?: string): Promise<Set<string>>;
|
|
15
|
+
export declare function declaredExtensionNames(specifiers: string[], resolveFrom?: string, fixtures?: KernelFixtureTrust): Promise<Set<string>>;
|
|
15
16
|
/** Only a login with migration privileges can initialize the kernel schema at startup. */
|
|
16
17
|
export declare function prepareKernelDatabase(db: KernelConfig["db"], opts?: {
|
|
17
18
|
pool?: QueryExecutorProvider;
|
|
@@ -22,7 +23,7 @@ export declare function prepareKernelDatabase(db: KernelConfig["db"], opts?: {
|
|
|
22
23
|
* Redis connection). Extensions whose permissions await approval are not migrated (unless
|
|
23
24
|
* `extensionPermissions.autoApprove`); they are reported through `opts.onPending`.
|
|
24
25
|
*/
|
|
25
|
-
export declare function migrateAll(config: KernelConfig, opts?: {
|
|
26
|
+
export declare function migrateAll(config: KernelConfig, opts?: KernelFixtureTrust & {
|
|
26
27
|
resolveFrom?: string;
|
|
27
28
|
onPending?: (pending: PendingExtension[]) => void;
|
|
28
29
|
}): Promise<{
|
package/dist/kernel.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { initializeCatalogDependencyEdges } from "./catalog/dependency-edges.js";
|
|
2
3
|
import { extensionDbIdentity, validateExtensionCredentials } from "./db/extension-db.js";
|
|
3
4
|
import { canMigrateKernel, migrate, verifyMigrations } from "./db/migrator.js";
|
|
4
5
|
import { createDb } from "./db/pool.js";
|
|
5
6
|
import { ExtensionHost } from "./extensions/host.js";
|
|
7
|
+
import { runMigrationBackfill } from "./infra/database/kernel-db.js";
|
|
8
|
+
import { KERNEL_FIXTURE_TRUST } from "./lifecycle/tokens.js";
|
|
6
9
|
/**
|
|
7
10
|
* The kernel migrations directory. `src/` and `dist/` are both one level below the package root,
|
|
8
11
|
* so this always points at `<package root>/src/migrations`: running from source with tsx and
|
|
@@ -13,8 +16,11 @@ export const KERNEL_MIGRATIONS_DIR = fileURLToPath(new URL("../src/migrations/",
|
|
|
13
16
|
/** The kernel's PG schema. */
|
|
14
17
|
export const KERNEL_SCHEMA = "capybara";
|
|
15
18
|
/** Static names of config-declared extensions, for deployment and fixture provisioning. */
|
|
16
|
-
export function declaredExtensionNames(specifiers, resolveFrom) {
|
|
17
|
-
return ExtensionHost.declaredNames(specifiers,
|
|
19
|
+
export function declaredExtensionNames(specifiers, resolveFrom, fixtures = {}) {
|
|
20
|
+
return ExtensionHost.declaredNames(specifiers, {
|
|
21
|
+
...(resolveFrom !== undefined && { resolveFrom }),
|
|
22
|
+
...fixtures,
|
|
23
|
+
});
|
|
18
24
|
}
|
|
19
25
|
const coreMigrations = { schema: KERNEL_SCHEMA, dir: KERNEL_MIGRATIONS_DIR };
|
|
20
26
|
/** Only a login with migration privileges can initialize the kernel schema at startup. */
|
|
@@ -58,13 +64,26 @@ export async function migrateAll(config, opts = {}) {
|
|
|
58
64
|
const kernel = await migrate(config.db.migrationUrl ?? config.db.url, coreMigrations, {
|
|
59
65
|
connectTimeoutMs,
|
|
60
66
|
});
|
|
67
|
+
const pool = createDb(config.db.migrationUrl ?? config.db.url, 1, undefined, {
|
|
68
|
+
connectTimeoutMs,
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
await runMigrationBackfill(pool, initializeCatalogDependencyEdges);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await pool.destroy();
|
|
75
|
+
}
|
|
61
76
|
const plugins = await ExtensionHost.migrateOnly(config.extensions, {
|
|
77
|
+
...(opts[KERNEL_FIXTURE_TRUST] && { [KERNEL_FIXTURE_TRUST]: true }),
|
|
62
78
|
dbUrl: config.db.url,
|
|
63
79
|
...(config.db.extensionsUrl !== undefined && {
|
|
64
80
|
extensionIdentity: extensionDbIdentity(config.db),
|
|
65
81
|
extensionProvisioning: config.db,
|
|
66
82
|
}),
|
|
67
83
|
connectTimeoutMs,
|
|
84
|
+
migrationTimeoutMs: config.extensionHost.migrationTimeoutSeconds * 1000,
|
|
85
|
+
packageCacheDir: config.extensionHost.dir,
|
|
86
|
+
maxPackageBytes: config.packages.maxBytes,
|
|
68
87
|
autoApprove: config.extensionPermissions.autoApprove,
|
|
69
88
|
...(opts.resolveFrom !== undefined && { resolveFrom: opts.resolveFrom }),
|
|
70
89
|
...(opts.onPending !== undefined && { onPending: opts.onPending }),
|
package/dist/kernel.module.js
CHANGED
|
@@ -11,6 +11,7 @@ import { TriggerEventsModule } from "./automations/events/events.module.js";
|
|
|
11
11
|
import { CatalogModule } from "./catalog/catalog.module.js";
|
|
12
12
|
import { ChannelsModule } from "./channels/channels.module.js";
|
|
13
13
|
import { ClientModule } from "./client/client.module.js";
|
|
14
|
+
import { ExternalConversationsModule } from "./conversations/external/external-conversations.service.js";
|
|
14
15
|
import { PromptSuggestionsModule } from "./conversations/prompt-suggestions.js";
|
|
15
16
|
import { TitlesModule } from "./conversations/titles.js";
|
|
16
17
|
import { ExtensionDeviceAccessModule } from "./device-access/device-access.module.js";
|
|
@@ -143,6 +144,9 @@ let KernelModule = KernelModule_1 = class KernelModule {
|
|
|
143
144
|
InboxItemsModule,
|
|
144
145
|
// ctx.agents / ctx.conversations / ctx.people: read-only org facts (found at the time of use)
|
|
145
146
|
PluginReadsModule,
|
|
147
|
+
// ctx.conversations' external methods and the external conversation calls' queue (found at
|
|
148
|
+
// the time of use)
|
|
149
|
+
ExternalConversationsModule,
|
|
146
150
|
// the Platform tool's operation registry and actor facts
|
|
147
151
|
PlatformModule,
|
|
148
152
|
// its operations (skills, agents, ...), registered at start on every role
|
|
@@ -4,6 +4,7 @@ import type { Redis } from "ioredis";
|
|
|
4
4
|
import { type Kysely } from "kysely";
|
|
5
5
|
import type { KernelAppOptions } from "../app.js";
|
|
6
6
|
import { MarketplacesService } from "../catalog/marketplaces.service.js";
|
|
7
|
+
import { PlatformComponents } from "../catalog/platform-components.js";
|
|
7
8
|
import { PluginImport } from "../catalog/plugin-import.js";
|
|
8
9
|
import { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
|
|
9
10
|
import { ChannelJobs } from "../channels/jobs.js";
|
|
@@ -88,6 +89,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
|
|
|
88
89
|
private readonly marketplaces;
|
|
89
90
|
private readonly pluginImport;
|
|
90
91
|
private readonly pluginUpdater;
|
|
92
|
+
private readonly platformComponents;
|
|
91
93
|
private readonly bus;
|
|
92
94
|
private readonly usageReport;
|
|
93
95
|
private readonly titles;
|
|
@@ -113,7 +115,7 @@ export declare class KernelLifecycle implements OnApplicationBootstrap, BeforeAp
|
|
|
113
115
|
private bootstrapPackages;
|
|
114
116
|
/** The merged bootstrap manifest, read once per start. */
|
|
115
117
|
private mergedManifest;
|
|
116
|
-
constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
|
|
118
|
+
constructor(permissionConfig: PermissionConfigPublication, accounts: AccountsService, configService: KernelConfigService, log: KernelLogger, options: KernelAppOptions, pool: Kysely<any>, redis: Redis, kdb: KernelDb, shutdown: GracefulShutdown, host: ExtensionHost, extensionDbIdentity: ExtensionDbIdentity, registry: ExtensionRegistry, installs: ExtensionInstalls, blobs: ExtensionBlobs, extensionLifecycle: ExtensionLifecycle, replicaStatus: ReplicaStatusStore, bootstrap: BootstrapService, bootstrapDefaults: BootstrapDefaultsService, marketplaces: MarketplacesService, pluginImport: PluginImport, pluginUpdater: PlatformPluginUpdater, platformComponents: PlatformComponents, bus: Pick<ExtensionContext["bus"], "publish" | "subscribe">, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelJobs: ChannelJobs, channelOutbound: ChannelOutbound, presence: ReplicaPresence, worker?: WorkerRole | undefined, gateway?: GatewayRole | undefined);
|
|
117
119
|
/** The kernel HTTP application (set up by `buildKernelApp` before `init()`). */
|
|
118
120
|
get http(): KernelHttpApp;
|
|
119
121
|
attachHttp(http: KernelHttpApp): void;
|
|
@@ -11,6 +11,7 @@ import { DEVICE_PROVIDER_EXTENSION_POINT } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable, Optional, } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { MarketplacesService } from "../catalog/marketplaces.service.js";
|
|
14
|
+
import { PlatformComponents } from "../catalog/platform-components.js";
|
|
14
15
|
import { PluginImport } from "../catalog/plugin-import.js";
|
|
15
16
|
import { PlatformPluginUpdater } from "../catalog/plugin-upgrade.js";
|
|
16
17
|
import { ChannelJobs } from "../channels/jobs.js";
|
|
@@ -24,6 +25,7 @@ import { BootstrapDefaultsService } from "../extensions/bootstrap-defaults.js";
|
|
|
24
25
|
import { BootstrapExtraMismatchError, hasExtraManifestTraces, loadBootstrapManifest, missingExtraManifestMessage, syncExtraMarketplaces, } from "../extensions/bootstrap-extra.js";
|
|
25
26
|
import { ExtensionHost } from "../extensions/host.js";
|
|
26
27
|
import { ExtensionInstalls } from "../extensions/installs.js";
|
|
28
|
+
import { installedExtensionTier } from "../extensions/isolated/tier.js";
|
|
27
29
|
import { ExtensionLifecycle } from "../extensions/lifecycle.js";
|
|
28
30
|
import { ensureMigrated } from "../extensions/migrate-lock.js";
|
|
29
31
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
@@ -45,7 +47,7 @@ import { WorkerRole } from "../roles/worker-role.js";
|
|
|
45
47
|
import { UsageReporter } from "../runtime/usage-report.js";
|
|
46
48
|
import { PermissionConfigPublication } from "../sandbox/permission-config-publication.js";
|
|
47
49
|
import { sandboxConfigWarnings } from "../sandbox/sandbox.service.js";
|
|
48
|
-
import { KERNEL_APP_OPTIONS } from "./tokens.js";
|
|
50
|
+
import { KERNEL_APP_OPTIONS, KERNEL_FIXTURE_TRUST } from "./tokens.js";
|
|
49
51
|
/**
|
|
50
52
|
* The stop phase budgets. Each phase waits `min(its budget, what is left of the total)`, where the
|
|
51
53
|
* total is `STOP_TIMEOUT_MS` (30 s, `GracefulShutdown`) counted from the moment the shutdown
|
|
@@ -110,6 +112,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
110
112
|
marketplaces;
|
|
111
113
|
pluginImport;
|
|
112
114
|
pluginUpdater;
|
|
115
|
+
platformComponents;
|
|
113
116
|
bus;
|
|
114
117
|
usageReport;
|
|
115
118
|
titles;
|
|
@@ -137,7 +140,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
137
140
|
mergedManifest;
|
|
138
141
|
constructor(permissionConfig, accounts, configService, log, options,
|
|
139
142
|
// biome-ignore lint/suspicious/noExplicitAny: the pool carries no schema types
|
|
140
|
-
pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, bus,
|
|
143
|
+
pool, redis, kdb, shutdown, host, extensionDbIdentity, registry, installs, blobs, extensionLifecycle, replicaStatus, bootstrap, bootstrapDefaults, marketplaces, pluginImport, pluginUpdater, platformComponents, bus,
|
|
141
144
|
// the producers closed on every role (their consumers are the worker role's)
|
|
142
145
|
usageReport, titles, suggestions, channelJobs, channelOutbound,
|
|
143
146
|
// this process's presence beat, on every role (admin overview spec §5.1)
|
|
@@ -166,6 +169,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
166
169
|
this.marketplaces = marketplaces;
|
|
167
170
|
this.pluginImport = pluginImport;
|
|
168
171
|
this.pluginUpdater = pluginUpdater;
|
|
172
|
+
this.platformComponents = platformComponents;
|
|
169
173
|
this.bus = bus;
|
|
170
174
|
this.usageReport = usageReport;
|
|
171
175
|
this.titles = titles;
|
|
@@ -234,6 +238,8 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
234
238
|
// In flight for the stop: aborted when the shutdown begins, which then waits for its session to end
|
|
235
239
|
await this.shutdown.trackInFlight(prepareKernelDatabase(config.db, { pool: this.pool, signal: this.shutdown.signal }));
|
|
236
240
|
this.checkpoint();
|
|
241
|
+
await this.shutdown.trackInFlight(this.platformComponents.initializeDependencyEdges());
|
|
242
|
+
this.checkpoint();
|
|
237
243
|
const publication = await this.shutdown.trackInFlight(this.permissionConfig.initialize({
|
|
238
244
|
...(opts.permissionConfigActivation !== undefined && {
|
|
239
245
|
activation: opts.permissionConfigActivation,
|
|
@@ -277,6 +283,8 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
277
283
|
// `lock:bootstrap`); a bootstrap entry named like a config-declared extension is kept
|
|
278
284
|
if (opts.bootstrap !== undefined) {
|
|
279
285
|
this.registry.declare(await ExtensionHost.declaredNames(config.extensions, {
|
|
286
|
+
maxPackageBytes: config.packages.maxBytes,
|
|
287
|
+
...(opts[KERNEL_FIXTURE_TRUST] && { [KERNEL_FIXTURE_TRUST]: true }),
|
|
280
288
|
...(opts.resolveFrom !== undefined && { resolveFrom: opts.resolveFrom }),
|
|
281
289
|
}));
|
|
282
290
|
}
|
|
@@ -288,6 +296,7 @@ let KernelLifecycle = class KernelLifecycle {
|
|
|
288
296
|
config: config.extensions,
|
|
289
297
|
installs: {
|
|
290
298
|
desired: () => this.installs.desired(),
|
|
299
|
+
tier: (d, verifyBytes) => installedExtensionTier(d, () => this.manifest(), this.blobs, verifyBytes),
|
|
291
300
|
sync: (d) => syncPackage(cfg().extensionHost.dir, d.name, d.sha256, this.blobs, {
|
|
292
301
|
maxBytes: cfg().packages.maxBytes,
|
|
293
302
|
}),
|
|
@@ -586,16 +595,17 @@ KernelLifecycle = __decorate([
|
|
|
586
595
|
__param(18, Inject(MarketplacesService)),
|
|
587
596
|
__param(19, Inject(PluginImport)),
|
|
588
597
|
__param(20, Inject(PlatformPluginUpdater)),
|
|
589
|
-
__param(21, Inject(
|
|
590
|
-
__param(22, Inject(
|
|
591
|
-
__param(23, Inject(
|
|
592
|
-
__param(24, Inject(
|
|
593
|
-
__param(25, Inject(
|
|
594
|
-
__param(26, Inject(
|
|
595
|
-
__param(27, Inject(
|
|
596
|
-
__param(28,
|
|
597
|
-
__param(28, Inject(WorkerRole)),
|
|
598
|
+
__param(21, Inject(PlatformComponents)),
|
|
599
|
+
__param(22, Inject(KERNEL_BUS)),
|
|
600
|
+
__param(23, Inject(UsageReporter)),
|
|
601
|
+
__param(24, Inject(TitleQueue)),
|
|
602
|
+
__param(25, Inject(PromptSuggestionQueue)),
|
|
603
|
+
__param(26, Inject(ChannelJobs)),
|
|
604
|
+
__param(27, Inject(ChannelOutbound)),
|
|
605
|
+
__param(28, Inject(ReplicaPresence)),
|
|
598
606
|
__param(29, Optional()),
|
|
599
|
-
__param(29, Inject(
|
|
607
|
+
__param(29, Inject(WorkerRole)),
|
|
608
|
+
__param(30, Optional()),
|
|
609
|
+
__param(30, Inject(GatewayRole))
|
|
600
610
|
], KernelLifecycle);
|
|
601
611
|
export { KernelLifecycle };
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
/** Injection tokens of the kernel application (`KernelModule`) itself. */
|
|
2
2
|
/** The `KernelAppOptions` the application was built with. */
|
|
3
3
|
export declare const KERNEL_APP_OPTIONS: unique symbol;
|
|
4
|
+
/** Internal switch for vetted repository test fixtures. It has no config or CLI representation. */
|
|
5
|
+
export declare const KERNEL_FIXTURE_TRUST: unique symbol;
|
|
6
|
+
export type KernelFixtureTrust = {
|
|
7
|
+
readonly [KERNEL_FIXTURE_TRUST]?: true | {
|
|
8
|
+
config: true;
|
|
9
|
+
installDigests: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
package/dist/lifecycle/tokens.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/** Injection tokens of the kernel application (`KernelModule`) itself. */
|
|
2
2
|
/** The `KernelAppOptions` the application was built with. */
|
|
3
3
|
export const KERNEL_APP_OPTIONS = Symbol("KERNEL_APP_OPTIONS");
|
|
4
|
+
/** Internal switch for vetted repository test fixtures. It has no config or CLI representation. */
|
|
5
|
+
export const KERNEL_FIXTURE_TRUST = Symbol("KERNEL_FIXTURE_TRUST");
|
|
@@ -299,11 +299,8 @@ let DirectorySync = class DirectorySync {
|
|
|
299
299
|
return [];
|
|
300
300
|
// org-filter: deployment-wide discovery of enabled directories, with each target checked in its org
|
|
301
301
|
const rows = await asPlatform("find the orgs with an enabled directory", () => this.db
|
|
302
|
-
.selectFrom(enabledExtensionsByOrg(this.db.db).as("en"))
|
|
303
|
-
.innerJoin("orgs", "orgs.id", "en.org_id")
|
|
302
|
+
.selectFrom(enabledExtensionsByOrg(this.db.db, plugins).as("en"))
|
|
304
303
|
.select(["en.org_id", "en.plugin"])
|
|
305
|
-
.where("orgs.deleted_at", "is", null)
|
|
306
|
-
.where("en.plugin", "in", plugins)
|
|
307
304
|
.orderBy("en.org_id")
|
|
308
305
|
.orderBy("en.plugin")
|
|
309
306
|
.execute());
|
|
@@ -24,6 +24,16 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
24
24
|
category: "human-only",
|
|
25
25
|
reason: "Interactive owner session permission selection and device-bound consent",
|
|
26
26
|
},
|
|
27
|
+
{
|
|
28
|
+
route: "GET /api/v1/orgs/:orgId/conversation-targets",
|
|
29
|
+
category: "human-only",
|
|
30
|
+
reason: "lists the person's local agents for the web new conversation page",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
route: "POST /api/v1/orgs/:orgId/conversations/:id/external-requests/:requestId",
|
|
34
|
+
category: "human-only",
|
|
35
|
+
reason: "the person decides a local agent's request",
|
|
36
|
+
},
|
|
27
37
|
{
|
|
28
38
|
route: "POST /api/v1/admin/accounts/:accountId/erasure",
|
|
29
39
|
category: "human-only",
|
|
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { DeploymentSettingsBody, PurposeParams } from "../../admin/admin.schemas.js";
|
|
13
|
-
import { AuditListQuery } from "../../admin/audit.schemas.js";
|
|
13
|
+
import { AuditActorsQuery, AuditListQuery } from "../../admin/audit.schemas.js";
|
|
14
14
|
import { AuditLogService } from "../../admin/audit-log.service.js";
|
|
15
15
|
import { AdminHealthService } from "../../admin/health.service.js";
|
|
16
16
|
import { LoginSourceBody, LoginSourceParams, LoginSourcesOrderBody, } from "../../admin/login-sources.schemas.js";
|
|
@@ -234,17 +234,28 @@ let AdminOperations = class AdminOperations {
|
|
|
234
234
|
}),
|
|
235
235
|
defineOperation({
|
|
236
236
|
id: "admin.audit",
|
|
237
|
-
description: "The platform-level audit log (super admin), newest first: deployment settings, accounts, marketplaces, catalog imports and scope, extensions, model prices and purposes, setup. Each event has its id, time, actor (id, name, email; null for the kernel itself), viaToken (done with
|
|
237
|
+
description: "The platform-level audit log (super admin), newest first: deployment settings, accounts, marketplaces, catalog imports and scope, extensions, model prices and purposes, setup. Each event has its id, time, actor (id, name, email; null for the kernel itself or an org's service token), viaToken (done with an access token), viaAgent (done through the Platform tool), action, target (an id or name), targetLabel (the target's name when known) and targetDeleted (the target no longer exists); never the event's details, and never an org's own events (an org's log is orgs.audit, in that org). Filters, combined: from / to (ISO times, from <= at < to), actor (an account id, system for the kernel itself, or token:<token id>; admin.audit-actors lists them), action (an action name or its prefix, e.g. marketplace.), q (the target's id, or a part of its name). Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, total (capped at 10000, totalCapped true above), asOf and newer. Pass the returned asOf with the next pages so they stay the same while new events arrive; newer counts events after asOf. Pages beyond the first 10000 events are refused: narrow the filters instead.",
|
|
238
238
|
// Another org's events are never read through an agent (the conversation's org: orgs.audit).
|
|
239
239
|
// The route's `orgId` query field is left out; parity treats `orgId` as implicit (never an
|
|
240
240
|
// operation field), so it needs no `omits` entry.
|
|
241
241
|
input: AuditListQuery.omit({ orgId: true }).strict(),
|
|
242
|
-
example: {
|
|
242
|
+
example: { page: 1, size: 20, action: "marketplace." },
|
|
243
243
|
authz: { superAdmin: true },
|
|
244
244
|
mirrors: ["GET /api/v1/admin/audit"],
|
|
245
245
|
confirm: "read",
|
|
246
246
|
run: (input) => this.audit.list({ platform: true }, input),
|
|
247
247
|
}),
|
|
248
|
+
defineOperation({
|
|
249
|
+
id: "admin.audit-actors",
|
|
250
|
+
description: "Who acted in the platform-level audit log (super admin): accounts (id, name, email; name null when the account is gone) and access tokens (id, name, accountId of a personal token), each sorted by name, at most 200 of each (truncated true when more acted). Use an account id or token:<token id> as admin.audit's actor filter. Never an org's own log (orgs.audit-actors, in that org).",
|
|
251
|
+
// As admin.audit: the route's `orgId` (another org's log) is never an operation field.
|
|
252
|
+
input: AuditActorsQuery.omit({ orgId: true }).strict(),
|
|
253
|
+
example: {},
|
|
254
|
+
authz: { superAdmin: true },
|
|
255
|
+
mirrors: ["GET /api/v1/admin/audit/actors"],
|
|
256
|
+
confirm: "read",
|
|
257
|
+
run: () => this.audit.actors({ platform: true }),
|
|
258
|
+
}),
|
|
248
259
|
defineOperation({
|
|
249
260
|
id: "admin.settings",
|
|
250
261
|
description: "Read the deployment settings (super admin): who may create orgs (orgCreation), the price currency, whether orgs may create their own connectors and skills, whether org admins may browse the marketplaces, the per-org limit overrides keyed by org id (orgs.get reads one org's), the platform's device sandbox settings in effect (devicesOutsideSandbox: permission allowed or off, whether a device may be granted running a call outside its sandbox; devicesNetwork: default and ceiling, open for the public internet with private addresses closed or allowlist, the network a device gets and the widest an org or device may choose), devicesAllowedProfiles ({ value }: profiles members may choose), devicesProjectReach ({ ceiling }: workspace, paths or machine), devicesDefaultProvider (provider: the device provider extension that makes a person's default device, null for none), the platform's attribution defaults for agent-created git commits and pull requests (attribution: commit, pr, sessionUrl), file sharing (externalSharing: value allow or deny, whether orgs may turn on public links to conversation files; shareMaxExpiryDays: value, the longest expiry a share may take in days), htmlRenderCdnAllowlist (the https origins a rendered HTML file may load libraries, styles, fonts and images from) and promptSuggestions (on or off, absent meaning on: whether the composer suggests the person's next message after a completed run; an org's own promptSuggestions must be on too); the switches each with sources: env, file or nacos are set in the startup config and read-only, db chosen in the admin console, default.",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type OnModuleInit } from "@nestjs/common";
|
|
2
2
|
import { ConversationsService } from "../../conversations/conversations.service.js";
|
|
3
3
|
import { ConversationDeviceStatus } from "../../conversations/device-status.js";
|
|
4
|
+
import { ExternalConversationsService } from "../../conversations/external/external-conversations.service.js";
|
|
4
5
|
import { ConversationFiles } from "../../conversations/files.js";
|
|
5
6
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
6
7
|
import { PlatformOperations } from "../registry.js";
|
|
@@ -16,7 +17,11 @@ export declare class ConversationsOperations implements OnModuleInit {
|
|
|
16
17
|
private readonly files;
|
|
17
18
|
private readonly device;
|
|
18
19
|
private readonly kdb;
|
|
19
|
-
|
|
20
|
+
/** An external conversation's stop (local agents spec Part 2). */
|
|
21
|
+
private readonly external;
|
|
22
|
+
constructor(registry: PlatformOperations, conversations: ConversationsService, files: ConversationFiles, device: ConversationDeviceStatus, kdb: KernelDb,
|
|
23
|
+
/** An external conversation's stop (local agents spec Part 2). */
|
|
24
|
+
external: Pick<ExternalConversationsService, "find" | "stop">);
|
|
20
25
|
/**
|
|
21
26
|
* Whether `id` is the conversation this run belongs to: its ROOT (the Platform tool also runs in
|
|
22
27
|
* sub-agents, whose own id is not the person's conversation). Stopping or deleting it would end
|
|
@@ -25,6 +30,8 @@ export declare class ConversationsOperations implements OnModuleInit {
|
|
|
25
30
|
private isRunsRoot;
|
|
26
31
|
private titleOf;
|
|
27
32
|
private precheckWritable;
|
|
33
|
+
/** A change of the conversation itself (rename, archive, delete): external ones included. */
|
|
34
|
+
private precheckOwned;
|
|
28
35
|
private setArchived;
|
|
29
36
|
onModuleInit(): void;
|
|
30
37
|
}
|