@capybara-hq/kernel 0.1.0-rc.143 → 0.1.0-rc.145
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 +30 -11
- package/dist/agents/admin-agents.js +51 -16
- 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/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/cli.js +2 -2
- package/dist/catalog/marketplace-fetch.d.ts +2 -0
- package/dist/catalog/marketplace-fetch.js +7 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-package.js +2 -1
- package/dist/client/client-access.service.js +29 -1
- package/dist/config/schema.d.ts +9 -0
- package/dist/config/schema.js +26 -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/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/errors.d.ts +1 -1
- package/dist/errors.js +2 -2
- 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.js +4 -3
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/enabled.d.ts +5 -0
- package/dist/extensions/grant-epoch.d.ts +108 -0
- package/dist/extensions/grant-epoch.js +214 -0
- package/dist/extensions/host.d.ts +30 -10
- package/dist/extensions/host.js +162 -43
- 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/isolated/tier.d.ts +14 -0
- package/dist/extensions/isolated/tier.js +27 -0
- 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/publisher-proof.job.d.ts +39 -0
- package/dist/extensions/publisher-proof.job.js +160 -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/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/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/orgs.controller.d.ts +11 -4
- package/dist/orgs/orgs.controller.js +25 -5
- package/dist/orgs/orgs.schemas.d.ts +14 -0
- package/dist/orgs/orgs.schemas.js +19 -2
- package/dist/orgs/orgs.service.d.ts +21 -1
- package/dist/orgs/orgs.service.js +40 -1
- 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/packages/official-publisher.d.ts +5 -0
- package/dist/packages/official-publisher.js +24 -3
- package/dist/packages/provenance.d.ts +6 -0
- package/dist/packages/provenance.js +26 -9
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/accounts.ops.js +7 -16
- package/dist/platform/ops/admin-items.ops.js +8 -8
- 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/roles/worker.module.js +6 -0
- package/dist/runtime/step-log.d.ts +1 -1
- package/dist/runtime/step-log.js +5 -4
- 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/tools/admin-connectors.d.ts +10 -8
- package/dist/tools/admin-connectors.js +12 -10
- package/dist/tools/builtins/automations.d.ts +1 -1
- package/dist/tools/builtins/automations.js +1 -1
- 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
|
@@ -2,6 +2,7 @@ import type { z } from "zod";
|
|
|
2
2
|
import { type AdminAgentDetail, type AdminAgentRow, AdminAgents } from "../agents/admin-agents.js";
|
|
3
3
|
import { AgentsService } from "../agents/agents.service.js";
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
5
6
|
import { AdminAgentListQuery, AgentIdParams, OwnerBody } from "./admin-items.schemas.js";
|
|
6
7
|
/**
|
|
7
8
|
* Every org's agents for the super admin (admin agents and connectors spec §4.1): read any agent,
|
|
@@ -12,11 +13,8 @@ export declare class AdminAgentsController {
|
|
|
12
13
|
private readonly admin;
|
|
13
14
|
private readonly agents;
|
|
14
15
|
constructor(admin: AdminAgents, agents: AgentsService);
|
|
15
|
-
/** Live agents of live orgs
|
|
16
|
-
list(q: z.infer<typeof AdminAgentListQuery>): Promise<
|
|
17
|
-
agents: AdminAgentRow[];
|
|
18
|
-
next: string | null;
|
|
19
|
-
}>;
|
|
16
|
+
/** Live agents of live orgs, newest first, by page number (table pagination spec §2.3). */
|
|
17
|
+
list(q: z.infer<typeof AdminAgentListQuery>): Promise<Page<AdminAgentRow>>;
|
|
20
18
|
get({ agentId }: z.infer<typeof AgentIdParams>): Promise<{
|
|
21
19
|
agent: AdminAgentDetail;
|
|
22
20
|
}>;
|
|
@@ -33,7 +33,7 @@ let AdminAgentsController = class AdminAgentsController {
|
|
|
33
33
|
this.admin = admin;
|
|
34
34
|
this.agents = agents;
|
|
35
35
|
}
|
|
36
|
-
/** Live agents of live orgs
|
|
36
|
+
/** Live agents of live orgs, newest first, by page number (table pagination spec §2.3). */
|
|
37
37
|
list(q) {
|
|
38
38
|
return this.admin.list(q);
|
|
39
39
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
3
4
|
import { type AdminConnectorDetail, type AdminConnectorRow, AdminConnectors } from "../tools/admin-connectors.js";
|
|
4
5
|
import { ConnectorsService } from "../tools/connectors.service.js";
|
|
5
6
|
import { AdminConnectorListQuery, ConnectorIdParams, ConnectorStatusBody } from "./admin-items.schemas.js";
|
|
@@ -12,11 +13,8 @@ export declare class AdminConnectorsController {
|
|
|
12
13
|
private readonly admin;
|
|
13
14
|
private readonly connectors;
|
|
14
15
|
constructor(admin: AdminConnectors, connectors: ConnectorsService);
|
|
15
|
-
/** Live connectors of live orgs
|
|
16
|
-
list(q: z.infer<typeof AdminConnectorListQuery>): Promise<
|
|
17
|
-
connectors: AdminConnectorRow[];
|
|
18
|
-
next: string | null;
|
|
19
|
-
}>;
|
|
16
|
+
/** Live connectors of live orgs, newest first, by page number (table pagination spec §2.3). */
|
|
17
|
+
list(q: z.infer<typeof AdminConnectorListQuery>): Promise<Page<AdminConnectorRow>>;
|
|
20
18
|
get({ connectorId }: z.infer<typeof ConnectorIdParams>): Promise<{
|
|
21
19
|
connector: AdminConnectorDetail;
|
|
22
20
|
}>;
|
|
@@ -33,7 +33,7 @@ let AdminConnectorsController = class AdminConnectorsController {
|
|
|
33
33
|
this.admin = admin;
|
|
34
34
|
this.connectors = connectors;
|
|
35
35
|
}
|
|
36
|
-
/** Live connectors of live orgs
|
|
36
|
+
/** Live connectors of live orgs, newest first, by page number (table pagination spec §2.3). */
|
|
37
37
|
list(q) {
|
|
38
38
|
return this.admin.list(q);
|
|
39
39
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
-
/** `GET /api/v1/admin/agents`: org filter, name search,
|
|
3
|
+
/** `GET /api/v1/admin/agents`: org filter, name search, page numbers (no snapshot: spec §2.3). */
|
|
4
4
|
export declare const AdminAgentListQuery: z.ZodObject<{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
6
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
7
7
|
orgId: z.ZodOptional<z.ZodString>;
|
|
8
8
|
q: z.ZodOptional<z.ZodString>;
|
|
9
9
|
}, z.core.$strip>;
|
|
10
|
-
/** `GET /api/v1/admin/connectors`: org and status filters, name search,
|
|
10
|
+
/** `GET /api/v1/admin/connectors`: org and status filters, name search, page numbers. */
|
|
11
11
|
export declare const AdminConnectorListQuery: z.ZodObject<{
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
13
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
14
14
|
orgId: z.ZodOptional<z.ZodString>;
|
|
15
15
|
status: z.ZodOptional<z.ZodEnum<{
|
|
16
16
|
active: "active";
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { PageQueryFields } from "../infra/paging/paged-read.js";
|
|
2
3
|
/**
|
|
3
4
|
* Schemas of the super admin's routes for every org's agents and connectors (admin agents and
|
|
4
5
|
* connectors spec §4.1). Ids are `text` columns, so a malformed id cannot fail the query: it is
|
|
5
6
|
* bounded here (400 `validation_failed` past 100 characters) and otherwise reads as not found.
|
|
6
7
|
*/
|
|
7
8
|
const Id = z.string().min(1).max(100);
|
|
8
|
-
|
|
9
|
-
/** The last id of the previous page (the `next` of the previous response). */
|
|
10
|
-
after: Id.optional(),
|
|
11
|
-
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
12
|
-
};
|
|
13
|
-
/** `GET /api/v1/admin/agents`: org filter, name search, id paging. */
|
|
9
|
+
/** `GET /api/v1/admin/agents`: org filter, name search, page numbers (no snapshot: spec §2.3). */
|
|
14
10
|
export const AdminAgentListQuery = z.object({
|
|
15
11
|
orgId: Id.optional(),
|
|
16
12
|
q: z.string().max(200).optional(),
|
|
17
|
-
...
|
|
13
|
+
...PageQueryFields,
|
|
18
14
|
});
|
|
19
|
-
/** `GET /api/v1/admin/connectors`: org and status filters, name search,
|
|
15
|
+
/** `GET /api/v1/admin/connectors`: org and status filters, name search, page numbers. */
|
|
20
16
|
export const AdminConnectorListQuery = z.object({
|
|
21
17
|
orgId: Id.optional(),
|
|
22
18
|
status: z.enum(["active", "disabled"]).optional(),
|
|
23
19
|
q: z.string().max(200).optional(),
|
|
24
|
-
...
|
|
20
|
+
...PageQueryFields,
|
|
25
21
|
});
|
|
26
22
|
export const AgentIdParams = z.object({ agentId: Id });
|
|
27
23
|
export const ConnectorIdParams = z.object({ connectorId: Id });
|
|
@@ -9,15 +9,16 @@ import { SessionService } from "../identity/sessions.js";
|
|
|
9
9
|
import { type DeploymentSettingsView, SettingsService } from "../identity/settings.js";
|
|
10
10
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
11
11
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
12
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
12
13
|
import { type ModelDisabledPatch, type ModelProviderParams } from "../models/enablement.controller.js";
|
|
13
14
|
import { type ModelDisableResult, ModelEnablement } from "../models/enablement.js";
|
|
14
15
|
import { type ModelPrice, type ModelPricePut, PricesService } from "../models/prices.js";
|
|
15
16
|
import { ModelPurposesService, type PurposeListing, type PurposePut } from "../models/purposes.js";
|
|
16
17
|
import { type Member, MembersService } from "../orgs/members.service.js";
|
|
17
|
-
import { type Org, OrgsService } from "../orgs/orgs.service.js";
|
|
18
|
+
import { type Org, type OrgDirectoryEntry, OrgsService } from "../orgs/orgs.service.js";
|
|
18
19
|
import { type PlatformProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
|
|
19
20
|
import { AccountErasures } from "./account-erasures.js";
|
|
20
|
-
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
|
|
21
|
+
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgListQuery, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
|
|
21
22
|
import { ErasureDispositions } from "./erasure-dispositions.js";
|
|
22
23
|
import { type LimitDefaults } from "./limit-defaults.js";
|
|
23
24
|
/**
|
|
@@ -45,12 +46,10 @@ export declare class AdminController {
|
|
|
45
46
|
/** One account with its avatar URL and source. */
|
|
46
47
|
private view;
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
49
|
+
* Every account, newest first, by page number (table pagination spec §2.3, no snapshot), with
|
|
50
|
+
* whether account erasure is on.
|
|
50
51
|
*/
|
|
51
|
-
listAccounts(q: z.infer<typeof AccountListQuery>): Promise<{
|
|
52
|
-
accounts: AccountView[];
|
|
53
|
-
next: string | null;
|
|
52
|
+
listAccounts(q: z.infer<typeof AccountListQuery>): Promise<Page<AccountView> & {
|
|
54
53
|
erasureEnabled: boolean;
|
|
55
54
|
}>;
|
|
56
55
|
requestAccountErasure(principal: Principal, { accountId }: z.infer<typeof AccountParams>, _body: z.infer<typeof AccountErasureBody>): Promise<{
|
|
@@ -89,15 +88,22 @@ export declare class AdminController {
|
|
|
89
88
|
account: AccountView;
|
|
90
89
|
}>;
|
|
91
90
|
/**
|
|
92
|
-
*
|
|
91
|
+
* One page of the live orgs with their member counts (never the members), newest first, by
|
|
92
|
+
* page number (table pagination spec §2.3), with the deployment's defaults of the limits an org
|
|
93
93
|
* can be given its own value of (the org limits dialog shows them for the values left empty).
|
|
94
94
|
*/
|
|
95
|
-
listOrgs(): Promise<{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})[];
|
|
95
|
+
listOrgs(q: z.infer<typeof AdminOrgListQuery>): Promise<Page<Org & {
|
|
96
|
+
memberCount: number;
|
|
97
|
+
}> & {
|
|
99
98
|
limitDefaults: LimitDefaults;
|
|
100
99
|
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Every live org at once in the compact directory shape (id, slug, name), oldest first: the org
|
|
102
|
+
* filters, pickers and names of the console; the orgs table pages `GET orgs`.
|
|
103
|
+
*/
|
|
104
|
+
orgDirectory(): Promise<{
|
|
105
|
+
orgs: OrgDirectoryEntry[];
|
|
106
|
+
}>;
|
|
101
107
|
/**
|
|
102
108
|
* The members of any live org (the agent owner transfer picks the new owner from them); the super
|
|
103
109
|
* admin need not be a member. A missing or deleted org → `org.not_found`.
|
|
@@ -30,7 +30,7 @@ import { MembersService } from "../orgs/members.service.js";
|
|
|
30
30
|
import { OrgsService } from "../orgs/orgs.service.js";
|
|
31
31
|
import { ProviderRegistry, } from "../runtime/providers.js";
|
|
32
32
|
import { AccountErasures } from "./account-erasures.js";
|
|
33
|
-
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
|
|
33
|
+
import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgListQuery, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
|
|
34
34
|
import { ErasureDispositions } from "./erasure-dispositions.js";
|
|
35
35
|
import { limitDefaults } from "./limit-defaults.js";
|
|
36
36
|
class AccountErasureBodyDto extends createZodDto(AccountErasureBody, "AccountErasureBody") {
|
|
@@ -47,6 +47,8 @@ class UpdateAccountBodyDto extends createZodDto(UpdateAccountBody, "UpdateAccoun
|
|
|
47
47
|
}
|
|
48
48
|
class AccountParamsDto extends createZodDto(AccountParams, "AccountParams") {
|
|
49
49
|
}
|
|
50
|
+
class AdminOrgListQueryDto extends createZodDto(AdminOrgListQuery, "AdminOrgListQuery") {
|
|
51
|
+
}
|
|
50
52
|
class AdminOrgParamsDto extends createZodDto(AdminOrgParams, "AdminOrgParams") {
|
|
51
53
|
}
|
|
52
54
|
class PurposeParamsDto extends createZodDto(PurposeParams, "PurposeParams") {
|
|
@@ -99,20 +101,15 @@ let AdminController = class AdminController {
|
|
|
99
101
|
return withAvatarUrl(this.db.db, account);
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
+
* Every account, newest first, by page number (table pagination spec §2.3, no snapshot), with
|
|
105
|
+
* whether account erasure is on.
|
|
104
106
|
*/
|
|
105
107
|
async listAccounts(q) {
|
|
106
|
-
const
|
|
107
|
-
limit: q.limit + 1,
|
|
108
|
-
...(q.after !== undefined && { after: q.after }),
|
|
109
|
-
});
|
|
110
|
-
const page = rows.slice(0, q.limit);
|
|
111
|
-
const next = rows.length > q.limit ? (page.at(-1)?.id ?? null) : null;
|
|
108
|
+
const page = await this.accounts.list(q);
|
|
112
109
|
const retention = this.config.get().retention;
|
|
113
110
|
return {
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
...page,
|
|
112
|
+
items: await withAvatarUrls(this.db.db, page.items),
|
|
116
113
|
erasureEnabled: retention.erasureEnabled && retention.destructiveEnabled,
|
|
117
114
|
};
|
|
118
115
|
}
|
|
@@ -162,11 +159,24 @@ let AdminController = class AdminController {
|
|
|
162
159
|
return { account: await this.view(account) };
|
|
163
160
|
}
|
|
164
161
|
/**
|
|
165
|
-
*
|
|
162
|
+
* One page of the live orgs with their member counts (never the members), newest first, by
|
|
163
|
+
* page number (table pagination spec §2.3), with the deployment's defaults of the limits an org
|
|
166
164
|
* can be given its own value of (the org limits dialog shows them for the values left empty).
|
|
167
165
|
*/
|
|
168
|
-
async listOrgs() {
|
|
169
|
-
|
|
166
|
+
async listOrgs(q) {
|
|
167
|
+
const page = await this.orgs.page({
|
|
168
|
+
page: q.page,
|
|
169
|
+
size: q.size,
|
|
170
|
+
...(q.q !== undefined && { q: q.q }),
|
|
171
|
+
});
|
|
172
|
+
return { ...page, limitDefaults: limitDefaults(this.config) };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Every live org at once in the compact directory shape (id, slug, name), oldest first: the org
|
|
176
|
+
* filters, pickers and names of the console; the orgs table pages `GET orgs`.
|
|
177
|
+
*/
|
|
178
|
+
async orgDirectory() {
|
|
179
|
+
return { orgs: await this.orgs.directory() };
|
|
170
180
|
}
|
|
171
181
|
/**
|
|
172
182
|
* The members of any live org (the agent owner transfer picks the new owner from them); the super
|
|
@@ -293,8 +303,12 @@ __decorate([
|
|
|
293
303
|
__param(2, ZBody(UpdateAccountBodyDto))
|
|
294
304
|
], AdminController.prototype, "updateAccount", null);
|
|
295
305
|
__decorate([
|
|
296
|
-
Get("orgs")
|
|
306
|
+
Get("orgs"),
|
|
307
|
+
__param(0, ZQuery(AdminOrgListQueryDto))
|
|
297
308
|
], AdminController.prototype, "listOrgs", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
Get("orgs/directory")
|
|
311
|
+
], AdminController.prototype, "orgDirectory", null);
|
|
298
312
|
__decorate([
|
|
299
313
|
Get("orgs/:orgId/members"),
|
|
300
314
|
__param(0, ZParam(AdminOrgParamsDto))
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
-
/** `GET /api/v1/admin/accounts`:
|
|
3
|
+
/** `GET /api/v1/admin/accounts`: page numbers without a snapshot (table pagination spec §2.3). */
|
|
4
4
|
export declare const AccountListQuery: z.ZodObject<{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
6
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
8
|
export declare const CreateAccountBody: z.ZodObject<{
|
|
9
9
|
login: z.ZodString;
|
|
@@ -179,6 +179,15 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
|
|
|
179
179
|
export declare const PurposeParams: z.ZodObject<{
|
|
180
180
|
purpose: z.ZodString;
|
|
181
181
|
}, z.core.$strip>;
|
|
182
|
+
/**
|
|
183
|
+
* `GET /api/v1/admin/orgs`: page numbers without a snapshot (spec §2.3) and a search (empty or
|
|
184
|
+
* blank: no search).
|
|
185
|
+
*/
|
|
186
|
+
export declare const AdminOrgListQuery: z.ZodObject<{
|
|
187
|
+
page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
188
|
+
size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
189
|
+
q: z.ZodOptional<z.ZodString>;
|
|
190
|
+
}, z.core.$strip>;
|
|
182
191
|
/** `:orgId` of an admin route: any org, the super admin need not be a member. */
|
|
183
192
|
export declare const AdminOrgParams: z.ZodObject<{
|
|
184
193
|
orgId: z.ZodString;
|
|
@@ -2,14 +2,12 @@ import { z } from "zod";
|
|
|
2
2
|
import { externalDispositionBlockers } from "../erasure/external-evidence.js";
|
|
3
3
|
import { MAX_PASSWORD_LENGTH } from "../identity/login.js";
|
|
4
4
|
import { DEPLOYMENT_SETTINGS_PATCH } from "../identity/settings.js";
|
|
5
|
+
import { PageQueryFields } from "../infra/paging/paged-read.js";
|
|
5
6
|
import { ModelDisabledPatch, ModelProviderParams } from "../models/enablement.controller.js";
|
|
6
7
|
import { MODEL_PRICE_PUT } from "../models/prices.js";
|
|
7
8
|
import { PURPOSE_PUT } from "../models/purposes.js";
|
|
8
|
-
/** `GET /api/v1/admin/accounts`:
|
|
9
|
-
export const AccountListQuery = z.object({
|
|
10
|
-
after: z.string().min(1).optional(),
|
|
11
|
-
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
12
|
-
});
|
|
9
|
+
/** `GET /api/v1/admin/accounts`: page numbers without a snapshot (table pagination spec §2.3). */
|
|
10
|
+
export const AccountListQuery = z.object({ ...PageQueryFields });
|
|
13
11
|
export const CreateAccountBody = z.object({
|
|
14
12
|
login: z.string().min(1).max(64),
|
|
15
13
|
password: z.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
@@ -34,6 +32,19 @@ export const UpdateAccountBody = z.object({
|
|
|
34
32
|
/** At least one key; `runConcurrencyOverrides` merges by org, a null value drops that org's. */
|
|
35
33
|
export const DeploymentSettingsBody = DEPLOYMENT_SETTINGS_PATCH.refine((b) => Object.keys(b).length > 0, { message: "at least one setting is required" });
|
|
36
34
|
export const PurposeParams = z.object({ purpose: z.string().min(1).max(100) });
|
|
35
|
+
/**
|
|
36
|
+
* `GET /api/v1/admin/orgs`: page numbers without a snapshot (spec §2.3) and a search (empty or
|
|
37
|
+
* blank: no search).
|
|
38
|
+
*/
|
|
39
|
+
export const AdminOrgListQuery = z.object({
|
|
40
|
+
q: z
|
|
41
|
+
.string()
|
|
42
|
+
.trim()
|
|
43
|
+
.max(200)
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Only orgs whose name or slug contains this (case-insensitive)."),
|
|
46
|
+
...PageQueryFields,
|
|
47
|
+
});
|
|
37
48
|
/** `:orgId` of an admin route: any org, the super admin need not be a member. */
|
|
38
49
|
export const AdminOrgParams = z.object({ orgId: z.string().min(1).max(100) });
|
|
39
50
|
export const ADMIN_ROUTES = [
|
|
@@ -56,7 +67,7 @@ export const ADMIN_ROUTES = [
|
|
|
56
67
|
params: ErasureWorkParams,
|
|
57
68
|
body: ErasureDispositionBody,
|
|
58
69
|
},
|
|
59
|
-
{ route: "GET /api/v1/admin/orgs" },
|
|
70
|
+
{ route: "GET /api/v1/admin/orgs", query: AdminOrgListQuery },
|
|
60
71
|
// `:orgId` is the conversation's org for the operation, so never an operation field
|
|
61
72
|
{ route: "GET /api/v1/admin/orgs/:orgId/members" },
|
|
62
73
|
{ route: "GET /api/v1/admin/settings" },
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
1
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import { type Page } from "../infra/paging/paged-read.js";
|
|
4
|
+
import { type ConnectorSetup } from "../tools/connector-setup.js";
|
|
5
|
+
import { Credentials } from "../tools/credentials.js";
|
|
2
6
|
import { AgentLookup, type AgentVisibility } from "./agent-lookup.js";
|
|
3
7
|
import { type AgentDefinition } from "./definition.js";
|
|
4
8
|
import type { AgentAvatarView } from "./profile.js";
|
|
@@ -55,7 +59,8 @@ export interface AdminAgentDetail extends AdminAgentRow {
|
|
|
55
59
|
}[];
|
|
56
60
|
/**
|
|
57
61
|
* The org's live connectors it can use by name (tools default-on): every one but those whose
|
|
58
|
-
* every tool it turns off. Never auth, credentials or a member's
|
|
62
|
+
* every tool it turns off, with their state and icon. Never auth, credentials or a member's
|
|
63
|
+
* state.
|
|
59
64
|
*/
|
|
60
65
|
connectors: AdminAgentConnector[];
|
|
61
66
|
}
|
|
@@ -64,14 +69,25 @@ export interface AdminAgentConnector {
|
|
|
64
69
|
name: string;
|
|
65
70
|
slug: string;
|
|
66
71
|
status: "active" | "disabled";
|
|
72
|
+
/**
|
|
73
|
+
* Derived from key presence only, as on the org's connector routes: `needs_config` while the
|
|
74
|
+
* org input its auth needs (an OAuth client or an org credential) is absent.
|
|
75
|
+
*/
|
|
76
|
+
setup: ConnectorSetup;
|
|
77
|
+
/**
|
|
78
|
+
* The icon it shows on the super admin's routes: its platform template's own icon, else its
|
|
79
|
+
* plugin's (`GET /api/v1/admin/catalog/...`), else null (a custom connector, or none).
|
|
80
|
+
*/
|
|
81
|
+
icon: string | null;
|
|
67
82
|
}
|
|
68
83
|
export interface AdminAgentListQuery {
|
|
69
84
|
orgId?: string | undefined;
|
|
70
85
|
/** Case-insensitive substring of the name; LIKE wildcards match literally. */
|
|
71
86
|
q?: string | undefined;
|
|
72
|
-
/** The
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
/** The page, 1-based. */
|
|
88
|
+
page: number;
|
|
89
|
+
/** Rows per page: 20, 50 or 100. */
|
|
90
|
+
size: number;
|
|
75
91
|
}
|
|
76
92
|
/**
|
|
77
93
|
* Cross-org agent reads for the super admin (admin agents spec §3.2, §3.3): every org's live
|
|
@@ -81,12 +97,14 @@ export interface AdminAgentListQuery {
|
|
|
81
97
|
export declare class AdminAgents {
|
|
82
98
|
private readonly db;
|
|
83
99
|
private readonly lookup;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
100
|
+
private readonly credentials;
|
|
101
|
+
private readonly icons;
|
|
102
|
+
constructor(db: KernelDb, lookup: AgentLookup, credentials: Pick<Credentials, "orgInputs">, icons: Pick<PluginIcons, "ofTemplatesOrItems">);
|
|
103
|
+
/**
|
|
104
|
+
* One page of every live org's live agents, filtered, newest first (`created_at`, then id), by
|
|
105
|
+
* page number without a snapshot (table pagination spec §2.3: agents are edited in place).
|
|
106
|
+
*/
|
|
107
|
+
list(q: AdminAgentListQuery): Promise<Page<AdminAgentRow>>;
|
|
90
108
|
/** One live agent of a live org; otherwise `agent.not_found`. */
|
|
91
109
|
get(agentId: string): Promise<AdminAgentDetail>;
|
|
92
110
|
/**
|
|
@@ -98,7 +116,8 @@ export declare class AdminAgents {
|
|
|
98
116
|
private skillsOff;
|
|
99
117
|
/**
|
|
100
118
|
* The org's live connectors by name, minus those the agent turns off as a whole: `tools: "all"`,
|
|
101
|
-
* or a list naming every tool the connector has (a connector without tools stays listed).
|
|
119
|
+
* or a list naming every tool the connector has (a connector without tools stays listed). Each
|
|
120
|
+
* with its derived setup state and its icon on the admin routes (one lookup each for all).
|
|
102
121
|
*/
|
|
103
122
|
private connectorsOf;
|
|
104
123
|
/** The list columns of live agents in live orgs. */
|
|
@@ -11,9 +11,13 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
11
11
|
import { sql } from "kysely";
|
|
12
12
|
import { escapeLike } from "../conversations/conversations.service.js";
|
|
13
13
|
import { ApiError } from "../errors.js";
|
|
14
|
+
import { PluginIcons } from "../extensions/plugin-icons.js";
|
|
14
15
|
import { avatarColumns, personAvatarUrl } from "../identity/account-avatar.js";
|
|
15
16
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
17
|
+
import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
|
|
16
18
|
import { agentSkills, builtinSkillIds, builtinSkillPlugins, linkedCopyIds, skillIdsOf, usableSkillVersions, } from "../skills/usable.js";
|
|
19
|
+
import { connectorSetups } from "../tools/connector-setup.js";
|
|
20
|
+
import { Credentials } from "../tools/credentials.js";
|
|
17
21
|
import { AgentLookup } from "./agent-lookup.js";
|
|
18
22
|
import { avatarView } from "./avatar-view.js";
|
|
19
23
|
import { skillDisabled, } from "./definition.js";
|
|
@@ -26,28 +30,35 @@ const notFound = () => new ApiError("agent.not_found", "Agent not found");
|
|
|
26
30
|
let AdminAgents = class AdminAgents {
|
|
27
31
|
db;
|
|
28
32
|
lookup;
|
|
29
|
-
|
|
33
|
+
credentials;
|
|
34
|
+
icons;
|
|
35
|
+
constructor(db, lookup, credentials, icons) {
|
|
30
36
|
this.db = db;
|
|
31
37
|
this.lookup = lookup;
|
|
38
|
+
this.credentials = credentials;
|
|
39
|
+
this.icons = icons;
|
|
32
40
|
}
|
|
33
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* One page of every live org's live agents, filtered, newest first (`created_at`, then id), by
|
|
43
|
+
* page number without a snapshot (table pagination spec §2.3: agents are edited in place).
|
|
44
|
+
*/
|
|
34
45
|
async list(q) {
|
|
46
|
+
assertReadablePage(q.page, q.size);
|
|
35
47
|
let query = this.rows();
|
|
36
48
|
if (q.orgId !== undefined)
|
|
37
49
|
query = query.where("agents.org_id", "=", q.orgId);
|
|
38
50
|
if (q.q !== undefined && q.q !== "") {
|
|
39
51
|
query = query.where(sql `agent_versions.definition->>'name' ILIKE ${`%${escapeLike(q.q)}%`} ESCAPE '\\'`);
|
|
40
52
|
}
|
|
41
|
-
|
|
42
|
-
query = query.where("agents.id", ">", q.after);
|
|
53
|
+
const counted = await cappedCount(this.db.db, query, PAGED_TOTAL_CAP);
|
|
43
54
|
const rows = await query
|
|
44
|
-
.orderBy("agents.
|
|
45
|
-
.
|
|
55
|
+
.orderBy("agents.created_at", "desc")
|
|
56
|
+
.orderBy("agents.id", "desc")
|
|
57
|
+
.offset(pageOffset(q.page, q.size))
|
|
58
|
+
.limit(q.size)
|
|
46
59
|
.execute();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const page = kept.map((r) => toRow(r, off.get(r.id) ?? 0));
|
|
50
|
-
return { agents: page, next: rows.length > q.limit ? (page.at(-1)?.id ?? null) : null };
|
|
60
|
+
const off = await this.skillsOff(rows);
|
|
61
|
+
return pageOf(rows.map((r) => toRow(r, off.get(r.id) ?? 0)), q, counted);
|
|
51
62
|
}
|
|
52
63
|
/** One live agent of a live org; otherwise `agent.not_found`. */
|
|
53
64
|
async get(agentId) {
|
|
@@ -143,12 +154,21 @@ let AdminAgents = class AdminAgents {
|
|
|
143
154
|
}
|
|
144
155
|
/**
|
|
145
156
|
* The org's live connectors by name, minus those the agent turns off as a whole: `tools: "all"`,
|
|
146
|
-
* or a list naming every tool the connector has (a connector without tools stays listed).
|
|
157
|
+
* or a list naming every tool the connector has (a connector without tools stays listed). Each
|
|
158
|
+
* with its derived setup state and its icon on the admin routes (one lookup each for all).
|
|
147
159
|
*/
|
|
148
160
|
async connectorsOf(orgId, disabled) {
|
|
149
161
|
const rows = await this.db
|
|
150
162
|
.selectFrom("connectors as c")
|
|
151
|
-
.select([
|
|
163
|
+
.select([
|
|
164
|
+
"c.id",
|
|
165
|
+
"c.name",
|
|
166
|
+
"c.slug",
|
|
167
|
+
"c.status",
|
|
168
|
+
"c.auth",
|
|
169
|
+
"c.platform_template_id",
|
|
170
|
+
"c.catalog_item_id",
|
|
171
|
+
])
|
|
152
172
|
.select(sql `coalesce((SELECT array_agg(t.name) FROM capybara.connector_tools t
|
|
153
173
|
WHERE t.connector_id = c.id), '{}')`.as("tools"))
|
|
154
174
|
.where("c.org_id", "=", orgId)
|
|
@@ -174,9 +194,22 @@ let AdminAgents = class AdminAgents {
|
|
|
174
194
|
return true;
|
|
175
195
|
return tools.length > 0 && tools.every((t) => off.has(t));
|
|
176
196
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
.map((r) => ({ id: r.id,
|
|
197
|
+
const listed = rows.filter((r) => !allOff(r.id, r.tools));
|
|
198
|
+
const [setups, icons] = await Promise.all([
|
|
199
|
+
connectorSetups(this.credentials, orgId, listed.map((r) => ({ id: r.id, auth: r.auth }))),
|
|
200
|
+
this.icons.ofTemplatesOrItems(listed.map((r) => ({
|
|
201
|
+
templateId: r.platform_template_id ?? null,
|
|
202
|
+
itemId: r.catalog_item_id ?? null,
|
|
203
|
+
})), { kind: "admin" }),
|
|
204
|
+
]);
|
|
205
|
+
return listed.map((r, i) => ({
|
|
206
|
+
id: r.id,
|
|
207
|
+
name: r.name,
|
|
208
|
+
slug: r.slug,
|
|
209
|
+
status: r.status,
|
|
210
|
+
setup: setups.get(r.id) ?? "needs_config",
|
|
211
|
+
icon: icons[i] ?? null,
|
|
212
|
+
}));
|
|
180
213
|
}
|
|
181
214
|
/** The list columns of live agents in live orgs. */
|
|
182
215
|
rows() {
|
|
@@ -210,7 +243,9 @@ let AdminAgents = class AdminAgents {
|
|
|
210
243
|
AdminAgents = __decorate([
|
|
211
244
|
Injectable(),
|
|
212
245
|
__param(0, Inject(KernelDb)),
|
|
213
|
-
__param(1, Inject(AgentLookup))
|
|
246
|
+
__param(1, Inject(AgentLookup)),
|
|
247
|
+
__param(2, Inject(Credentials)),
|
|
248
|
+
__param(3, Inject(PluginIcons))
|
|
214
249
|
], AdminAgents);
|
|
215
250
|
export { AdminAgents };
|
|
216
251
|
function toRow(r, skillsOff) {
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
|
+
import type { Page } from "../infra/paging/paged-read.js";
|
|
3
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
|
-
import { type AutomationCalendarQuery, type AutomationChatTargetsQuery, type AutomationCreateBody, type AutomationEventSourcesQuery, type AutomationGrantableQuery, type AutomationGrantParams, type AutomationGrantsBody, type AutomationListQuery, type AutomationParams, type AutomationRunBody, type AutomationRunsQuery, type AutomationUpdateBody } from "./automations.schemas.js";
|
|
5
|
-
import { type AutomationGrantView, type AutomationListItem, AutomationsService, type ChatTarget, type EventSourceView, type GrantableTool } from "./automations.service.js";
|
|
5
|
+
import { type AutomationCalendarQuery, type AutomationChatTargetsQuery, type AutomationCreateBody, type AutomationEventSourcesQuery, type AutomationGrantableQuery, type AutomationGrantParams, type AutomationGrantsBody, type AutomationListQuery, type AutomationNextRunsQuery, type AutomationParams, type AutomationRunBody, type AutomationRunsQuery, type AutomationUpdateBody } from "./automations.schemas.js";
|
|
6
|
+
import { type AutomationGrantView, type AutomationListItem, type AutomationNextRun, AutomationsService, type ChatTarget, type EventSourceView, type GrantableTool } from "./automations.service.js";
|
|
6
7
|
import type { CalendarAnswer } from "./calendar.js";
|
|
7
8
|
import type { Automation, AutomationGrant, TaskRun } from "./types.js";
|
|
8
9
|
/**
|
|
9
10
|
* Automations (`/api/v1/orgs/:orgId/automations`, spec 2026-11-11-scheduled-tasks §10); human
|
|
10
11
|
* users only (a service token gets 403).
|
|
11
|
-
* - `GET /` → `
|
|
12
|
+
* - `GET /` → a page (`page`, `size`; table pagination spec §2.3) of the caller's own tasks, each with its `lastRun`; `?all=true` every task
|
|
12
13
|
* of the org (org admins, `automations.manage`, enforced by the service: 403 `forbidden`
|
|
13
14
|
* otherwise); `?conversationId=` only those posting into that conversation;
|
|
15
|
+
* - `GET /next-runs[?all=true]` → `{ items }`: every one of the caller's tasks (`all` as the
|
|
16
|
+
* list's) at once, each only `{ id, status, nextRunAt }` (the calendar's empty state);
|
|
14
17
|
* - `GET /calendar?from&to&timeZone[&all][&taskId]` → the calendar (runs, planned occurrences,
|
|
15
18
|
* collapsed task-days; calendar spec §5.1), `org.read` like the list, `all` as the list's;
|
|
16
19
|
* - `GET /chat-targets` → `{ items }`: the chats the caller can point a `chat` task at;
|
|
@@ -32,8 +35,9 @@ import type { Automation, AutomationGrant, TaskRun } from "./types.js";
|
|
|
32
35
|
export declare class AutomationsController {
|
|
33
36
|
private readonly tasks;
|
|
34
37
|
constructor(tasks: AutomationsService);
|
|
35
|
-
list(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationListQuery>): Promise<
|
|
36
|
-
|
|
38
|
+
list(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationListQuery>): Promise<Page<AutomationListItem>>;
|
|
39
|
+
nextRuns(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationNextRunsQuery>): Promise<{
|
|
40
|
+
items: AutomationNextRun[];
|
|
37
41
|
}>;
|
|
38
42
|
calendar(principal: Principal, org: OrgContext, q: z.infer<typeof AutomationCalendarQuery>): Promise<CalendarAnswer>;
|
|
39
43
|
chatTargets(principal: Principal, org: OrgContext, _q: z.infer<typeof AutomationChatTargetsQuery>): Promise<{
|