@capybara-hq/kernel 0.1.0-rc.59 → 0.1.0-rc.60
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.controller.d.ts +10 -5
- package/dist/admin/admin.controller.js +16 -7
- package/dist/admin/admin.schemas.js +2 -1
- package/dist/admin/audit-log.service.d.ts +1 -0
- package/dist/admin/audit-log.service.js +4 -1
- package/dist/admin/extensions.schemas.js +2 -0
- package/dist/agents/admin-agents.d.ts +1 -0
- package/dist/agents/admin-agents.js +4 -1
- package/dist/agents/agents.controller.d.ts +1 -10
- package/dist/agents/agents.controller.js +2 -14
- package/dist/agents/agents.schemas.d.ts +10 -0
- package/dist/agents/agents.schemas.js +19 -0
- package/dist/background/tasks.service.d.ts +5 -0
- package/dist/background/tasks.service.js +10 -3
- package/dist/catalog/admin-catalog.schemas.js +2 -0
- package/dist/catalog/component-scope.schemas.js +2 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-plugin-uploads.schemas.js +2 -0
- package/dist/catalog/requests.service.d.ts +2 -0
- package/dist/catalog/requests.service.js +4 -1
- package/dist/channels/cards.d.ts +9 -0
- package/dist/channels/cards.js +32 -1
- package/dist/channels/phrases.d.ts +5 -0
- package/dist/channels/phrases.js +5 -0
- package/dist/conversations/attachments.service.d.ts +34 -0
- package/dist/conversations/attachments.service.js +124 -21
- package/dist/conversations/conversations.controller.d.ts +5 -1
- package/dist/conversations/conversations.controller.js +11 -5
- package/dist/conversations/conversations.service.d.ts +5 -0
- package/dist/conversations/conversations.service.js +10 -0
- package/dist/conversations/event-people.d.ts +12 -0
- package/dist/conversations/event-people.js +28 -0
- package/dist/db/kernel-schema.d.ts +18 -0
- package/dist/devices/devices.service.d.ts +3 -2
- package/dist/devices/devices.service.js +17 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +1 -0
- package/dist/evals/trajectory.service.d.ts +3 -0
- package/dist/evals/trajectory.service.js +2 -0
- package/dist/extensions/installs.d.ts +3 -0
- package/dist/extensions/installs.js +1 -0
- package/dist/http/api.module.js +2 -0
- package/dist/http/meta.controller.d.ts +1 -0
- package/dist/http/meta.controller.js +6 -1
- package/dist/identity/account-avatar.controller.d.ts +30 -0
- package/dist/identity/account-avatar.controller.js +117 -0
- package/dist/identity/account-avatar.d.ts +67 -0
- package/dist/identity/account-avatar.js +136 -0
- package/dist/identity/account-avatars.service.d.ts +77 -0
- package/dist/identity/account-avatars.service.js +321 -0
- package/dist/identity/accounts.d.ts +26 -0
- package/dist/identity/accounts.js +70 -2
- package/dist/identity/app-auth.controller.d.ts +2 -1
- package/dist/identity/app-auth.controller.js +2 -1
- package/dist/identity/app-auth.d.ts +24 -7
- package/dist/identity/app-auth.js +19 -9
- package/dist/identity/app-auth.schemas.d.ts +16 -3
- package/dist/identity/app-auth.schemas.js +5 -2
- package/dist/identity/external.js +7 -1
- package/dist/identity/identity.module.d.ts +2 -1
- package/dist/identity/identity.module.js +7 -1
- package/dist/identity/me.controller.d.ts +29 -5
- package/dist/identity/me.controller.js +57 -6
- package/dist/identity/me.schemas.d.ts +36 -0
- package/dist/identity/me.schemas.js +30 -0
- package/dist/identity/principal.d.ts +2 -2
- package/dist/identity/principal.js +2 -2
- package/dist/local-devices/local-device-gateway.d.ts +2 -0
- package/dist/local-devices/local-device-gateway.js +8 -1
- package/dist/local-devices/relay.d.ts +10 -9
- package/dist/local-devices/relay.js +32 -9
- package/dist/local-devices/targets.d.ts +12 -0
- package/dist/local-devices/targets.js +18 -2
- package/dist/orgs/members.service.d.ts +3 -1
- package/dist/orgs/members.service.js +9 -2
- package/dist/platform/exclusions.js +33 -57
- package/dist/platform/file-ref.d.ts +87 -0
- package/dist/platform/file-ref.js +164 -0
- package/dist/platform/operation.d.ts +26 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +2 -0
- package/dist/platform/ops/agent-skills.ops.js +156 -4
- package/dist/platform/ops/agents.ops.d.ts +3 -1
- package/dist/platform/ops/agents.ops.js +75 -17
- package/dist/platform/ops/approvals.ops.js +5 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +9 -1
- package/dist/platform/ops/catalog-admin.ops.js +86 -3
- package/dist/platform/ops/components.ops.d.ts +3 -1
- package/dist/platform/ops/components.ops.js +61 -2
- package/dist/platform/ops/connectors.ops.js +15 -1
- package/dist/platform/ops/devices.ops.js +6 -1
- package/dist/platform/ops/extensions-admin.ops.d.ts +6 -4
- package/dist/platform/ops/extensions-admin.ops.js +109 -6
- package/dist/platform/ops/inbox.ops.js +10 -0
- package/dist/platform/ops/list-handoff.d.ts +10 -0
- package/dist/platform/ops/list-handoff.js +11 -0
- package/dist/platform/ops/marketplaces.ops.js +2 -1
- package/dist/platform/ops/org-plugins.ops.d.ts +12 -3
- package/dist/platform/ops/org-plugins.ops.js +97 -6
- package/dist/platform/ops/requests.ops.js +9 -0
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +98 -4
- package/dist/platform/ops/summary.d.ts +5 -0
- package/dist/platform/ops/summary.js +10 -0
- package/dist/platform/parity.d.ts +6 -4
- package/dist/platform/parity.js +94 -68
- package/dist/roles/worker.module.js +5 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +18 -0
- package/dist/schedules/scheduled-tasks.service.d.ts +10 -6
- package/dist/schedules/scheduled-tasks.service.js +13 -16
- package/dist/shares/shares.service.d.ts +1 -0
- package/dist/shares/shares.service.js +9 -3
- package/dist/skills/changes.service.d.ts +1 -0
- package/dist/skills/changes.service.js +4 -7
- package/dist/skills/skills.controller.d.ts +3 -7
- package/dist/skills/skills.controller.js +3 -16
- package/dist/skills/skills.schemas.d.ts +5 -0
- package/dist/skills/skills.schemas.js +17 -0
- package/dist/skills/skills.service.d.ts +3 -1
- package/dist/skills/skills.service.js +13 -4
- package/dist/tools/admin-connectors.d.ts +1 -0
- package/dist/tools/admin-connectors.js +4 -1
- package/dist/tools/approvals.service.d.ts +16 -2
- package/dist/tools/approvals.service.js +13 -0
- package/dist/tools/builtins/builtin-tools.d.ts +3 -0
- package/dist/tools/builtins/builtin-tools.js +29 -9
- package/dist/tools/builtins/platform.d.ts +23 -0
- package/dist/tools/builtins/platform.js +95 -6
- package/dist/tools/builtins/sandbox/common.d.ts +5 -0
- package/dist/tools/builtins/sandbox/common.js +11 -0
- package/dist/tools/builtins/skill-load.js +4 -4
- package/dist/tools/pipeline.js +10 -3
- package/dist/tools/questions.controller.js +2 -2
- package/dist/tools/questions.service.d.ts +7 -1
- package/dist/tools/questions.service.js +9 -2
- package/dist/tools/registry.d.ts +6 -0
- package/dist/tools/tools.module.js +3 -0
- package/package.json +3 -3
- package/src/migrations/0171_account_avatar.sql +26 -0
|
@@ -14,6 +14,7 @@ import { CatalogRequestsService } from "../../catalog/requests.service.js";
|
|
|
14
14
|
import { defineOperation } from "../operation.js";
|
|
15
15
|
import { PlatformOperations } from "../registry.js";
|
|
16
16
|
import { viaAgent } from "./errors.js";
|
|
17
|
+
import { listCard } from "./list-handoff.js";
|
|
17
18
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
18
19
|
/** A request as the requester reads it (no org name: it is this org's). */
|
|
19
20
|
const view = (r) => ({
|
|
@@ -164,6 +165,10 @@ let RequestsOperations = class RequestsOperations {
|
|
|
164
165
|
const all = await this.requests.listForOrgAdmin(ctx.orgId, ctx.actorAccountId);
|
|
165
166
|
return pageOf(all.map(pendingRow), startOf(input.cursor), 50);
|
|
166
167
|
},
|
|
168
|
+
handoff: (_i, result) => listCard(result, "/inbox", {
|
|
169
|
+
zh: "去收件箱处理成员的请求",
|
|
170
|
+
en: "Decide the members' requests in the inbox",
|
|
171
|
+
}),
|
|
167
172
|
}),
|
|
168
173
|
defineOperation({
|
|
169
174
|
id: "requests.platform-list",
|
|
@@ -180,6 +185,10 @@ let RequestsOperations = class RequestsOperations {
|
|
|
180
185
|
const all = await this.requests.listDeployment(input.status !== undefined ? { status: input.status } : {});
|
|
181
186
|
return pageOf(all.map(platformRow), startOf(input.cursor), 50);
|
|
182
187
|
},
|
|
188
|
+
handoff: (_i, result) => listCard(result, "/admin/inbox", {
|
|
189
|
+
zh: "去平台收件箱处理组织的请求",
|
|
190
|
+
en: "Decide the orgs' requests in the platform inbox",
|
|
191
|
+
}),
|
|
183
192
|
}),
|
|
184
193
|
]);
|
|
185
194
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type OnModuleInit } from "@nestjs/common";
|
|
2
2
|
import { OwnedItems } from "../../catalog/owned-items.js";
|
|
3
|
+
import { AttachmentsService } from "../../conversations/attachments.service.js";
|
|
4
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
3
5
|
import { SkillsService } from "../../skills/skills.service.js";
|
|
4
6
|
import { PlatformOperations } from "../registry.js";
|
|
5
7
|
/**
|
|
@@ -10,7 +12,9 @@ export declare class SkillsOperations implements OnModuleInit {
|
|
|
10
12
|
private readonly registry;
|
|
11
13
|
private readonly skills;
|
|
12
14
|
private readonly owned;
|
|
13
|
-
|
|
15
|
+
private readonly attachments;
|
|
16
|
+
private readonly db;
|
|
17
|
+
constructor(registry: PlatformOperations, skills: SkillsService, owned: OwnedItems, attachments: AttachmentsService, db: KernelDb);
|
|
14
18
|
/** The skill's name for a card summary; its id when it cannot be read. */
|
|
15
19
|
private skillName;
|
|
16
20
|
onModuleInit(): void;
|
|
@@ -10,12 +10,16 @@ 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 { OwnedItems } from "../../catalog/owned-items.js";
|
|
13
|
-
import {
|
|
13
|
+
import { AttachmentsService, SKILL_PACKAGE_CONTENT_TYPE, SKILL_PACKAGE_UPLOAD_MAX_BYTES, } from "../../conversations/attachments.service.js";
|
|
14
|
+
import { assertCustomAllowed } from "../../identity/settings.js";
|
|
15
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
16
|
+
import { SkillCreateBody, SkillIdParams, SkillPathParams, SkillShareableSchema, } from "../../skills/skills.schemas.js";
|
|
14
17
|
import { SkillsService } from "../../skills/skills.service.js";
|
|
18
|
+
import { FileRefSchema } from "../file-ref.js";
|
|
15
19
|
import { defineOperation } from "../operation.js";
|
|
16
20
|
import { PlatformOperations } from "../registry.js";
|
|
17
21
|
import { precheckBy, viaAgent } from "./errors.js";
|
|
18
|
-
import { named, orElse } from "./summary.js";
|
|
22
|
+
import { named, orElse, skillPackageName } from "./summary.js";
|
|
19
23
|
const NoInput = z.object({}).strict();
|
|
20
24
|
const SkillId = z.object({ skillId: SkillPathParams.shape.id.max(100) }).strict();
|
|
21
25
|
const OwnedSkillId = z.object({ skillId: SkillIdParams.shape.id }).strict();
|
|
@@ -27,10 +31,14 @@ let SkillsOperations = class SkillsOperations {
|
|
|
27
31
|
registry;
|
|
28
32
|
skills;
|
|
29
33
|
owned;
|
|
30
|
-
|
|
34
|
+
attachments;
|
|
35
|
+
db;
|
|
36
|
+
constructor(registry, skills, owned, attachments, db) {
|
|
31
37
|
this.registry = registry;
|
|
32
38
|
this.skills = skills;
|
|
33
39
|
this.owned = owned;
|
|
40
|
+
this.attachments = attachments;
|
|
41
|
+
this.db = db;
|
|
34
42
|
}
|
|
35
43
|
/** The skill's name for a card summary; its id when it cannot be read. */
|
|
36
44
|
skillName(orgId, skillId) {
|
|
@@ -59,6 +67,90 @@ let SkillsOperations = class SkillsOperations {
|
|
|
59
67
|
confirm: "read",
|
|
60
68
|
run: async (input, ctx) => this.skills.get(ctx.orgId, input.skillId),
|
|
61
69
|
}),
|
|
70
|
+
defineOperation({
|
|
71
|
+
id: "skills.create-from-file",
|
|
72
|
+
description: "Create an org skill from a skill package, or add the next version of the org skill with the same name (org admins): a zip file of this conversation (an attachment, or a zip you built in the sandbox and delivered with Deliver), passed as file: { fileId }. The zip has SKILL.md at its root or in one top-level folder (frontmatter name and description, then the instructions), plus any scripts or references, at most 50 MiB. Every agent of the org has the skill unless it turns it off; shareable lets other orgs use it. The person sees the file on the card.",
|
|
73
|
+
input: z
|
|
74
|
+
.object({ file: FileRefSchema, shareable: SkillCreateBody.shape.shareable })
|
|
75
|
+
.strict(),
|
|
76
|
+
example: { file: { fileId: "0b9f2c4e-1d3a-4c55-9e0a-7a2f6d1c8b11" } },
|
|
77
|
+
authz: { orgAction: "skills.manage" },
|
|
78
|
+
mirrors: ["POST /api/v1/orgs/:orgId/skills/uploads", "POST /api/v1/orgs/:orgId/skills"],
|
|
79
|
+
// the upload registration's fields come from the referenced file; the kernel registers
|
|
80
|
+
// the upload and passes its id itself
|
|
81
|
+
omits: ["name", "size", "uploadId"],
|
|
82
|
+
extras: ["file"],
|
|
83
|
+
confirm: "org",
|
|
84
|
+
errors: [
|
|
85
|
+
{
|
|
86
|
+
code: "catalog.custom_disabled",
|
|
87
|
+
next: {
|
|
88
|
+
superAdmin: "Custom skills are switched off for this deployment; allow them in the admin console's deployment settings, or install a skill from the catalog.",
|
|
89
|
+
orgAdmin: "This deployment does not allow custom skills; install one from the platform catalog, or ask the super admin.",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
code: "skill.invalid_package",
|
|
94
|
+
next: "Fix the package as the message says (SKILL.md at the zip's root with name and description frontmatter, allowed paths and sizes), rebuild the zip, deliver it and retry.",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
code: "attachment.too_many_pending",
|
|
98
|
+
next: "Too many skill packages are stored and not used yet; wait an hour for them to expire, then retry.",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
code: "storage.unavailable",
|
|
102
|
+
next: "File storage is unavailable; try again later, or tell the person to contact the super admin.",
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
precheck: () => precheckBy(() => assertCustomAllowed(this.db.db, "customSkills")),
|
|
106
|
+
fileRef: (i) => ({
|
|
107
|
+
ref: i.file,
|
|
108
|
+
limits: {
|
|
109
|
+
maxBytes: SKILL_PACKAGE_UPLOAD_MAX_BYTES,
|
|
110
|
+
contentTypes: [SKILL_PACKAGE_CONTENT_TYPE],
|
|
111
|
+
},
|
|
112
|
+
}),
|
|
113
|
+
summary: async (i, ctx) => {
|
|
114
|
+
const f = named(ctx.file?.name ?? "?");
|
|
115
|
+
// the name SKILL.md declares, and whether the org has its own skill of that name
|
|
116
|
+
const name = await skillPackageName(ctx.file?.bytes);
|
|
117
|
+
const exists = name !== null &&
|
|
118
|
+
(await orElse(async () => (await this.skills.list(ctx.orgId)).some((s) => s.name === name && s.origin === "org"), false));
|
|
119
|
+
const what = name === null
|
|
120
|
+
? { zh: "创建或更新组织技能", en: "Create or update an org skill" }
|
|
121
|
+
: exists
|
|
122
|
+
? {
|
|
123
|
+
zh: `给组织技能「${named(name)}」新增一个版本`,
|
|
124
|
+
en: `Add a new version of org skill "${named(name)}"`,
|
|
125
|
+
}
|
|
126
|
+
: {
|
|
127
|
+
zh: `创建组织技能「${named(name)}」`,
|
|
128
|
+
en: `Create org skill "${named(name)}"`,
|
|
129
|
+
};
|
|
130
|
+
return i.shareable === true
|
|
131
|
+
? {
|
|
132
|
+
zh: `${what.zh}(技能包「${f}」),并允许共享给其他组织`,
|
|
133
|
+
en: `${what.en} from the package "${f}", shareable with other orgs`,
|
|
134
|
+
}
|
|
135
|
+
: { zh: `${what.zh}(技能包「${f}」)`, en: `${what.en} from the package "${f}"` };
|
|
136
|
+
},
|
|
137
|
+
run: async (input, ctx) => {
|
|
138
|
+
const f = ctx.file;
|
|
139
|
+
if (f === undefined)
|
|
140
|
+
throw new Error("skills.create-from-file: the file is missing");
|
|
141
|
+
// the bytes the person confirmed, stored as the upload route stores a package, then
|
|
142
|
+
// created from as `POST /skills` does
|
|
143
|
+
const { id } = await this.attachments.createFromBytes(ctx.orgId, ctx.actorAccountId, "skill-package", { name: f.name, contentType: f.contentType, bytes: f.bytes });
|
|
144
|
+
const r = await this.skills
|
|
145
|
+
.upload(ctx.orgId, ctx.actorAccountId, id, undefined, input.shareable, viaAgent("skills.create-from-file", ctx))
|
|
146
|
+
.catch(async (e) => {
|
|
147
|
+
// the stored package no version took: out of the cap, cleaned up
|
|
148
|
+
await this.attachments.discardUpload(ctx.orgId, ctx.actorAccountId, id);
|
|
149
|
+
throw e;
|
|
150
|
+
});
|
|
151
|
+
return { skill: r.skill, version: r.version, created: r.created };
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
62
154
|
defineOperation({
|
|
63
155
|
id: "skills.set-shareable",
|
|
64
156
|
description: "Set whether an org skill may be shared with other orgs. Only the org's own skills can be changed; a skill that came from a platform plugin cannot.",
|
|
@@ -155,6 +247,8 @@ SkillsOperations = __decorate([
|
|
|
155
247
|
Injectable(),
|
|
156
248
|
__param(0, Inject(PlatformOperations)),
|
|
157
249
|
__param(1, Inject(SkillsService)),
|
|
158
|
-
__param(2, Inject(OwnedItems))
|
|
250
|
+
__param(2, Inject(OwnedItems)),
|
|
251
|
+
__param(3, Inject(AttachmentsService)),
|
|
252
|
+
__param(4, Inject(KernelDb))
|
|
159
253
|
], SkillsOperations);
|
|
160
254
|
export { SkillsOperations };
|
|
@@ -7,4 +7,9 @@ export declare const localized: (n: LocalizedName | null | undefined, fallback:
|
|
|
7
7
|
en: string;
|
|
8
8
|
};
|
|
9
9
|
/** The value of `read`, or `fallback` when the read throws (a summary never fails on a name). */
|
|
10
|
+
/**
|
|
11
|
+
* The skill name a skill package's SKILL.md declares, for a card summary (the package is checked
|
|
12
|
+
* as the write will check it); null when the bytes are absent or not a valid package.
|
|
13
|
+
*/
|
|
14
|
+
export declare function skillPackageName(bytes: Uint8Array | undefined): Promise<string | null>;
|
|
10
15
|
export declare function orElse<T>(read: () => Promise<T>, fallback: T): Promise<T>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readSkillPackage } from "../../skills/package.js";
|
|
1
2
|
/** Longest name quoted in a card summary (a name is set by people, and by agents through tools). */
|
|
2
3
|
const NAME_MAX = 80;
|
|
3
4
|
/** A name as a card summary quotes it: clipped to {@link NAME_MAX}. */
|
|
@@ -8,6 +9,15 @@ export const localized = (n, fallback) => ({
|
|
|
8
9
|
en: named(n?.en ?? fallback),
|
|
9
10
|
});
|
|
10
11
|
/** The value of `read`, or `fallback` when the read throws (a summary never fails on a name). */
|
|
12
|
+
/**
|
|
13
|
+
* The skill name a skill package's SKILL.md declares, for a card summary (the package is checked
|
|
14
|
+
* as the write will check it); null when the bytes are absent or not a valid package.
|
|
15
|
+
*/
|
|
16
|
+
export async function skillPackageName(bytes) {
|
|
17
|
+
if (bytes === undefined)
|
|
18
|
+
return null;
|
|
19
|
+
return orElse(async () => (await readSkillPackage(bytes)).name, null);
|
|
20
|
+
}
|
|
11
21
|
export async function orElse(read, fallback) {
|
|
12
22
|
try {
|
|
13
23
|
return await read();
|
|
@@ -13,8 +13,10 @@ export interface ParityFinding {
|
|
|
13
13
|
/** What {@link inputParity} reads of an operation. */
|
|
14
14
|
export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"> & Partial<Pick<PlatformOperation, "omits" | "extras" | "renames" | "loosens" | "personFields" | "withoutSecrets">>;
|
|
15
15
|
/**
|
|
16
|
-
* Compares an operation's input with
|
|
17
|
-
* §14.5 item 3), on their input JSON Schemas
|
|
16
|
+
* Compares an operation's input with its mirrored routes' body + query + path params (spec
|
|
17
|
+
* §14.5 item 3), on their input JSON Schemas. An operation mirroring several routes (an upload
|
|
18
|
+
* and the write that takes its id) is compared with the fields of all of them: a field is
|
|
19
|
+
* compared with each route that has it, and `omits` / `extras` are read against the union.
|
|
18
20
|
* - each input field is compared with the route field of the same name, or the route path its
|
|
19
21
|
* `renames` entry names (`skillId` → `id`, `name` → `definition.name`): the same type (an
|
|
20
22
|
* operation `integer` fits a route `number`), enum values a subset, bounds no looser
|
|
@@ -30,9 +32,9 @@ export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"
|
|
|
30
32
|
* never an input field (it is in `omits`), and the operation defines `personFields`, or says in
|
|
31
33
|
* `withoutSecrets` why it takes none of them and asks for none (a preview without the credential).
|
|
32
34
|
*/
|
|
33
|
-
export declare function inputParity(op: ParityOperation,
|
|
35
|
+
export declare function inputParity(op: ParityOperation, routes: RouteSchemas | readonly RouteSchemas[]): ParityFinding[];
|
|
34
36
|
/**
|
|
35
|
-
* {@link inputParity} of every operation against
|
|
37
|
+
* {@link inputParity} of every operation against the routes it mirrors; a mirrored route whose
|
|
36
38
|
* schemas are not registered is a finding too (a removed route is `check:platform-ops`'s orphan).
|
|
37
39
|
*/
|
|
38
40
|
export declare function checkInputParity(ops: readonly ParityOperation[], routes: readonly RouteSchemas[]): ParityFinding[];
|
package/dist/platform/parity.js
CHANGED
|
@@ -173,8 +173,10 @@ function fieldMismatch(op, route, path, top) {
|
|
|
173
173
|
return null;
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
-
* Compares an operation's input with
|
|
177
|
-
* §14.5 item 3), on their input JSON Schemas
|
|
176
|
+
* Compares an operation's input with its mirrored routes' body + query + path params (spec
|
|
177
|
+
* §14.5 item 3), on their input JSON Schemas. An operation mirroring several routes (an upload
|
|
178
|
+
* and the write that takes its id) is compared with the fields of all of them: a field is
|
|
179
|
+
* compared with each route that has it, and `omits` / `extras` are read against the union.
|
|
178
180
|
* - each input field is compared with the route field of the same name, or the route path its
|
|
179
181
|
* `renames` entry names (`skillId` → `id`, `name` → `definition.name`): the same type (an
|
|
180
182
|
* operation `integer` fits a route `number`), enum values a subset, bounds no looser
|
|
@@ -190,88 +192,112 @@ function fieldMismatch(op, route, path, top) {
|
|
|
190
192
|
* never an input field (it is in `omits`), and the operation defines `personFields`, or says in
|
|
191
193
|
* `withoutSecrets` why it takes none of them and asks for none (a preview without the credential).
|
|
192
194
|
*/
|
|
193
|
-
export function inputParity(op,
|
|
195
|
+
export function inputParity(op, routes) {
|
|
196
|
+
const list = Array.isArray(routes) ? routes : [routes];
|
|
194
197
|
const out = [];
|
|
195
|
-
const
|
|
198
|
+
const allRoutes = list.map((x) => x.route).join(", ");
|
|
199
|
+
const add = (field, message, route = allRoutes) => out.push({ op: op.id, route, field, message: `${op.id}: ${message}` });
|
|
196
200
|
const opFields = fieldsOf(toJson(op.input));
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
/** Each route's top-level fields (but the implicit ones). */
|
|
202
|
+
const perRoute = list.map((x) => {
|
|
203
|
+
const fields = new Map();
|
|
204
|
+
for (const part of [x.params, x.query, x.body]) {
|
|
205
|
+
if (part === undefined)
|
|
206
|
+
continue;
|
|
207
|
+
for (const [k, v] of fieldsOf(toJson(part)))
|
|
208
|
+
if (!IMPLICIT.has(k))
|
|
209
|
+
fields.set(k, v);
|
|
210
|
+
}
|
|
211
|
+
return { route: x.route, r: `\`${x.route}\``, fields };
|
|
212
|
+
});
|
|
213
|
+
const routeKeys = new Set(perRoute.flatMap((p) => [...p.fields.keys()]));
|
|
214
|
+
const all = list.map((x) => `\`${x.route}\``).join(", ");
|
|
205
215
|
const omits = new Set(op.omits ?? []);
|
|
206
216
|
const extras = new Set(op.extras ?? []);
|
|
207
217
|
const renames = new Map(Object.entries(op.renames ?? {}));
|
|
208
218
|
const loosens = new Map(Object.entries(op.loosens ?? {}));
|
|
209
|
-
const r = `\`${route.route}\``;
|
|
210
219
|
/** Top-level route fields an input field covers (by name or by a rename into it). */
|
|
211
220
|
const covered = new Set();
|
|
212
221
|
for (const [k, opField] of opFields) {
|
|
213
222
|
const target = renames.get(k) ?? k;
|
|
214
|
-
const
|
|
215
|
-
|
|
223
|
+
const holders = perRoute.flatMap((p) => {
|
|
224
|
+
const f = fieldAt(p.fields, target);
|
|
225
|
+
return f === undefined ? [] : [{ ...p, routeField: f }];
|
|
226
|
+
});
|
|
227
|
+
if (holders.length === 0) {
|
|
216
228
|
if (renames.has(k))
|
|
217
|
-
add(k, `\`renames\` maps \`${k}\` to \`${target}\`, no field of ${
|
|
229
|
+
add(k, `\`renames\` maps \`${k}\` to \`${target}\`, no field of ${all}`);
|
|
218
230
|
else if (!extras.has(k))
|
|
219
|
-
add(k, `\`${k}\` is no field of ${
|
|
231
|
+
add(k, `\`${k}\` is no field of ${all} and not in \`extras\``);
|
|
220
232
|
continue;
|
|
221
233
|
}
|
|
222
234
|
covered.add(target.split(".")[0]);
|
|
223
|
-
if (extras.has(k))
|
|
224
|
-
add(k, `\`extras\` names \`${k}\`, which ${r} has as \`${target}\``);
|
|
225
|
-
const reason = loosens.get(k);
|
|
226
235
|
const name = target === k ? `\`${k}\`` : `\`${k}\` (\`${target}\`)`;
|
|
236
|
+
if (extras.has(k)) {
|
|
237
|
+
const first = holders[0];
|
|
238
|
+
add(k, `\`extras\` names \`${k}\`, which ${first.r} has as \`${target}\``, first.route);
|
|
239
|
+
}
|
|
240
|
+
const reason = loosens.get(k);
|
|
227
241
|
if (reason !== undefined) {
|
|
228
242
|
if (reason.trim() === "")
|
|
229
243
|
add(k, `\`loosens\` names \`${k}\` without a reason`);
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
244
|
+
let looser = false;
|
|
245
|
+
for (const { route, r, routeField } of holders) {
|
|
246
|
+
const want = typesOf(routeField.schema);
|
|
247
|
+
const got = typesOf(opField.schema);
|
|
248
|
+
if (want !== undefined && (got === undefined || [...got].some((t) => !typeFits(t, want)))) {
|
|
249
|
+
add(k, `${name}: type ${describeTypes(got)} in the operation, ${describeTypes(want)} in the route (${r}; \`loosens\` excuses bounds, never the type)`, route);
|
|
250
|
+
}
|
|
251
|
+
looser ||=
|
|
252
|
+
(routeField.required && !opField.required) ||
|
|
253
|
+
fieldMismatch(opField.schema, routeField.schema, target, target) !== null;
|
|
234
254
|
}
|
|
235
|
-
const looser = (routeField.required && !opField.required) ||
|
|
236
|
-
fieldMismatch(opField.schema, routeField.schema, target, target) !== null;
|
|
237
255
|
if (!looser)
|
|
238
|
-
add(k, `\`loosens\` names ${name}, which is no looser than ${
|
|
256
|
+
add(k, `\`loosens\` names ${name}, which is no looser than ${all}`);
|
|
239
257
|
continue;
|
|
240
258
|
}
|
|
241
|
-
|
|
242
|
-
|
|
259
|
+
for (const { route, r, routeField } of holders) {
|
|
260
|
+
if (routeField.required && !opField.required) {
|
|
261
|
+
add(k, `${name} is required by ${r} but optional here (declare it in \`loosens\` if meant)`, route);
|
|
262
|
+
}
|
|
263
|
+
const why = fieldMismatch(opField.schema, routeField.schema, target, target);
|
|
264
|
+
if (why !== null)
|
|
265
|
+
add(k, `${name}: ${why} (${r})`, route);
|
|
243
266
|
}
|
|
244
|
-
const why = fieldMismatch(opField.schema, routeField.schema, target, target);
|
|
245
|
-
if (why !== null)
|
|
246
|
-
add(k, `${name}: ${why} (${r})`);
|
|
247
267
|
}
|
|
248
268
|
// rule `platform-op-secret-param` (platform web parity spec §9): a route field carrying a
|
|
249
269
|
// `secret()` value is entered by the person on the card, never passed by the model
|
|
250
|
-
for (const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
270
|
+
for (const { route, r, fields } of perRoute) {
|
|
271
|
+
for (const [k, f] of fields) {
|
|
272
|
+
if (!holdsSecret(f.schema))
|
|
273
|
+
continue;
|
|
274
|
+
const secretRule = (message) => out.push({
|
|
275
|
+
op: op.id,
|
|
276
|
+
route,
|
|
277
|
+
field: k,
|
|
278
|
+
rule: "platform-op-secret-param",
|
|
279
|
+
message: `${op.id}: platform-op-secret-param: ${message}`,
|
|
280
|
+
});
|
|
281
|
+
if (covered.has(k)) {
|
|
282
|
+
secretRule(`\`${k}\` of ${r} carries a secret (\`secret()\` meta): leave it out of the input, list it in \`omits\`, and have the person enter it on the card (\`personFields\`)`);
|
|
283
|
+
}
|
|
284
|
+
else if (op.personFields === undefined && !op.withoutSecrets?.trim()) {
|
|
285
|
+
secretRule(`\`${k}\` of ${r} carries a secret (\`secret()\` meta): the operation must define \`personFields\`, so the person enters secrets on the card, or say in \`withoutSecrets\` why it takes none`);
|
|
286
|
+
}
|
|
265
287
|
}
|
|
266
288
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
289
|
+
const reported = new Set();
|
|
290
|
+
for (const { route, r, fields } of perRoute) {
|
|
291
|
+
for (const k of fields.keys()) {
|
|
292
|
+
if (!covered.has(k) && !omits.has(k) && !reported.has(k)) {
|
|
293
|
+
reported.add(k);
|
|
294
|
+
add(k, `\`${k}\` of ${r} is missing from the input and not in \`omits\``, route);
|
|
295
|
+
}
|
|
270
296
|
}
|
|
271
297
|
}
|
|
272
298
|
for (const k of omits) {
|
|
273
|
-
if (!
|
|
274
|
-
add(k, `\`omits\` names \`${k}\`, no field of ${
|
|
299
|
+
if (!routeKeys.has(k))
|
|
300
|
+
add(k, `\`omits\` names \`${k}\`, no field of ${all}`);
|
|
275
301
|
else if (covered.has(k))
|
|
276
302
|
add(k, `\`omits\` names \`${k}\`, but the input has it`);
|
|
277
303
|
}
|
|
@@ -290,26 +316,26 @@ export function inputParity(op, route) {
|
|
|
290
316
|
return out;
|
|
291
317
|
}
|
|
292
318
|
/**
|
|
293
|
-
* {@link inputParity} of every operation against
|
|
319
|
+
* {@link inputParity} of every operation against the routes it mirrors; a mirrored route whose
|
|
294
320
|
* schemas are not registered is a finding too (a removed route is `check:platform-ops`'s orphan).
|
|
295
321
|
*/
|
|
296
322
|
export function checkInputParity(ops, routes) {
|
|
297
323
|
const byRoute = new Map(routes.map((r) => [r.route, r]));
|
|
298
|
-
return ops.flatMap((op) =>
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
324
|
+
return ops.flatMap((op) => {
|
|
325
|
+
const registered = op.mirrors.flatMap((m) => byRoute.get(m) ?? []);
|
|
326
|
+
return [
|
|
327
|
+
...staleWithoutSecrets(op, byRoute),
|
|
328
|
+
...op.mirrors
|
|
329
|
+
.filter((m) => !byRoute.has(m))
|
|
330
|
+
.map((m) => ({
|
|
331
|
+
op: op.id,
|
|
332
|
+
route: m,
|
|
333
|
+
message: `${op.id} mirrors \`${m}\`, whose schemas are not in ROUTE_SCHEMAS: export them from the controller's <domain>.schemas.ts and list them there`,
|
|
334
|
+
})),
|
|
335
|
+
// the registered mirrors together: an upload route and the write taking its id are one op
|
|
336
|
+
...(registered.length > 0 ? inputParity(op, registered) : []),
|
|
337
|
+
];
|
|
338
|
+
});
|
|
313
339
|
}
|
|
314
340
|
/**
|
|
315
341
|
* Rule `platform-op-secret-param`: a `withoutSecrets` reason on an operation none of whose
|
|
@@ -26,6 +26,8 @@ import { EvalWorkersModule } from "../evals/evals.module.js";
|
|
|
26
26
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
27
27
|
import { PluginsReconcileJob } from "../extensions/lifecycle.js";
|
|
28
28
|
import { LifecycleHookWorkersModule } from "../extensions/lifecycle-hooks.js";
|
|
29
|
+
import { AccountAvatarCleanupJob } from "../identity/account-avatars.service.js";
|
|
30
|
+
import { IdentityModule } from "../identity/identity.module.js";
|
|
29
31
|
import { InitialPasswordCleanupJob } from "../identity/initial-passwords.job.js";
|
|
30
32
|
import { OutboxRelayModule } from "../infra/outbox/outbox-relay.module.js";
|
|
31
33
|
import { KernelScheduleModule } from "../infra/schedule/schedule.module.js";
|
|
@@ -80,6 +82,7 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
80
82
|
TitlesModule,
|
|
81
83
|
PromptSuggestionsModule,
|
|
82
84
|
AttachmentsModule,
|
|
85
|
+
IdentityModule,
|
|
83
86
|
StorageModule,
|
|
84
87
|
SandboxModule,
|
|
85
88
|
BackgroundModule,
|
|
@@ -108,6 +111,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
108
111
|
RetireLegacyTasksJob,
|
|
109
112
|
ToolJobs,
|
|
110
113
|
InitialPasswordCleanupJob,
|
|
114
|
+
// expired, unbound avatar uploads of accounts (account profile spec §5.3)
|
|
115
|
+
AccountAvatarCleanupJob,
|
|
111
116
|
ClientReportsCron,
|
|
112
117
|
CatalogJobs,
|
|
113
118
|
DirectoryScanJob,
|
|
@@ -11,3 +11,16 @@ export declare class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
|
11
11
|
}
|
|
12
12
|
/** Recognizes {@link DeviceRequestNotSentError} by its tag. */
|
|
13
13
|
export declare const isDeviceRequestNotSent: (e: unknown) => e is DeviceRequestNotSentError;
|
|
14
|
+
/**
|
|
15
|
+
* A staged request whose machine reconnected as a new run of the program (a different
|
|
16
|
+
* `programRunId` in its hello) before answering: the results a program keeps for a reconnect live
|
|
17
|
+
* in its memory, so this request's result can never arrive. Whether the request ran, and how far,
|
|
18
|
+
* is unknown; the operation path records it as an unknown outcome, never as a definite failure.
|
|
19
|
+
* The relay throws it as soon as it sees the new run, instead of waiting for the deadline.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DeviceProgramRestartedError extends Error {
|
|
22
|
+
readonly programRestarted: true;
|
|
23
|
+
constructor(op: string);
|
|
24
|
+
}
|
|
25
|
+
/** Recognizes {@link DeviceProgramRestartedError}, also as the cause of an unknown outcome. */
|
|
26
|
+
export declare const isDeviceProgramRestarted: (e: unknown) => boolean;
|
|
@@ -11,3 +11,21 @@ export class DeviceRequestNotSentError extends SandboxScopeDeniedError {
|
|
|
11
11
|
}
|
|
12
12
|
/** Recognizes {@link DeviceRequestNotSentError} by its tag. */
|
|
13
13
|
export const isDeviceRequestNotSent = (e) => e instanceof SandboxScopeDeniedError && e.notSent === true;
|
|
14
|
+
/**
|
|
15
|
+
* A staged request whose machine reconnected as a new run of the program (a different
|
|
16
|
+
* `programRunId` in its hello) before answering: the results a program keeps for a reconnect live
|
|
17
|
+
* in its memory, so this request's result can never arrive. Whether the request ran, and how far,
|
|
18
|
+
* is unknown; the operation path records it as an unknown outcome, never as a definite failure.
|
|
19
|
+
* The relay throws it as soon as it sees the new run, instead of waiting for the deadline.
|
|
20
|
+
*/
|
|
21
|
+
export class DeviceProgramRestartedError extends Error {
|
|
22
|
+
programRestarted = true;
|
|
23
|
+
constructor(op) {
|
|
24
|
+
super(`The connected machine's program restarted before answering ${op}; its result is lost and its outcome is unknown`);
|
|
25
|
+
this.name = "DeviceProgramRestartedError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Recognizes {@link DeviceProgramRestartedError}, also as the cause of an unknown outcome. */
|
|
29
|
+
export const isDeviceProgramRestarted = (e) => e instanceof Error &&
|
|
30
|
+
(e.programRestarted === true ||
|
|
31
|
+
isDeviceProgramRestarted(e.cause));
|
|
@@ -3,6 +3,7 @@ import type { ModelRef } from "../agents/definition.js";
|
|
|
3
3
|
import { ConversationAccess } from "../conversations/access.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
5
5
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
6
|
+
import { type PersonRef } from "../identity/account-avatar.js";
|
|
6
7
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
7
8
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
9
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -35,10 +36,7 @@ export interface ScheduleAttention {
|
|
|
35
36
|
*/
|
|
36
37
|
reason: SchedulePauseReason | "missing_grants" | "failed";
|
|
37
38
|
/** The person who paused the task (`reason: "admin"` names the admin); else null. */
|
|
38
|
-
pausedBy:
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
} | null;
|
|
39
|
+
pausedBy: PersonRef | null;
|
|
42
40
|
/**
|
|
43
41
|
* `missing_grants` only: tool keys the latest run was refused and the task has no grant for now,
|
|
44
42
|
* `connection:<slug>` (connect that connector), or `network:<host>` (a domain the run was
|
|
@@ -156,9 +154,13 @@ export interface TaskLastRun {
|
|
|
156
154
|
at: Date;
|
|
157
155
|
}
|
|
158
156
|
/** A task in a list, with its latest settled run. */
|
|
159
|
-
export type ScheduledTaskListItem =
|
|
157
|
+
export type ScheduledTaskListItem = ScheduledTaskView & {
|
|
160
158
|
lastRun: TaskLastRun | null;
|
|
161
159
|
};
|
|
160
|
+
/** A task with its creator as a person (null when the account is gone). */
|
|
161
|
+
export type ScheduledTaskView = ScheduledTask & {
|
|
162
|
+
account: PersonRef | null;
|
|
163
|
+
};
|
|
162
164
|
/**
|
|
163
165
|
* A chat the creator can point a `chat` task at (spec §8): their DM with a connection's bot
|
|
164
166
|
* (a thread row of theirs, archived included), or a group they have talked in when the channel
|
|
@@ -222,7 +224,9 @@ export declare class ScheduledTasksService {
|
|
|
222
224
|
/** The creator, or an org admin. */
|
|
223
225
|
remove(orgId: string, actor: ScheduleActor, id: string): Promise<void>;
|
|
224
226
|
/** The creator, or an org admin. */
|
|
225
|
-
get(orgId: string, actor: ScheduleActor, id: string): Promise<
|
|
227
|
+
get(orgId: string, actor: ScheduleActor, id: string): Promise<ScheduledTaskView>;
|
|
228
|
+
/** Each task with its creator as a person, in one query. */
|
|
229
|
+
private withAccounts;
|
|
226
230
|
/** The actor's own tasks; `all` (org admins only, else `forbidden`): every task of the org. */
|
|
227
231
|
list(orgId: string, actor: ScheduleActor, opts?: {
|
|
228
232
|
all?: boolean;
|
|
@@ -16,6 +16,7 @@ import { readMessageContext } from "../conversations/message-context.js";
|
|
|
16
16
|
import { ApiError } from "../errors.js";
|
|
17
17
|
import { enabledExtensionsByOrg, isExtensionEnabled } from "../extensions/enabled.js";
|
|
18
18
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
19
|
+
import { loadPeople } from "../identity/account-avatar.js";
|
|
19
20
|
import { audit } from "../identity/audit.js";
|
|
20
21
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
21
22
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -345,7 +346,13 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
345
346
|
if (!task || (task.accountId !== actor.accountId && !can(role, "schedules.manage"))) {
|
|
346
347
|
throw scheduleNotFound();
|
|
347
348
|
}
|
|
348
|
-
|
|
349
|
+
const [view] = await this.withAccounts([task]);
|
|
350
|
+
return view;
|
|
351
|
+
}
|
|
352
|
+
/** Each task with its creator as a person, in one query. */
|
|
353
|
+
async withAccounts(tasks) {
|
|
354
|
+
const people = await loadPeople(this.db.db, tasks.map((t) => t.accountId));
|
|
355
|
+
return tasks.map((t) => ({ ...t, account: people.get(t.accountId) ?? null }));
|
|
349
356
|
}
|
|
350
357
|
/** The actor's own tasks; `all` (org admins only, else `forbidden`): every task of the org. */
|
|
351
358
|
async list(orgId, actor, opts = {}) {
|
|
@@ -438,9 +445,10 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
438
445
|
chats.some((c) => c.connection_id === t.chat?.connectionId && c.chat_id === t.chat.chatId));
|
|
439
446
|
}
|
|
440
447
|
/** Each task with its latest settled non-trial run, in one query. */
|
|
441
|
-
async withLastRuns(
|
|
442
|
-
if (
|
|
448
|
+
async withLastRuns(plain) {
|
|
449
|
+
if (plain.length === 0)
|
|
443
450
|
return [];
|
|
451
|
+
const tasks = await this.withAccounts(plain);
|
|
444
452
|
const rows = await this.db.db
|
|
445
453
|
.selectFrom("scheduled_task_runs")
|
|
446
454
|
.select(["task_id", "status", "skip_reason", "fired_at", "scheduled_for"])
|
|
@@ -626,16 +634,7 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
626
634
|
return [];
|
|
627
635
|
const out = [];
|
|
628
636
|
const pausers = tasks.flatMap((t) => t.status === "paused" && t.pausedBy !== null ? [t.pausedBy] : []);
|
|
629
|
-
const
|
|
630
|
-
if (pausers.length > 0) {
|
|
631
|
-
const rows = await db
|
|
632
|
-
.selectFrom("accounts")
|
|
633
|
-
.select(["id", "display_name"])
|
|
634
|
-
.where("id", "in", pausers)
|
|
635
|
-
.execute();
|
|
636
|
-
for (const r of rows)
|
|
637
|
-
names.set(r.id, r.display_name);
|
|
638
|
-
}
|
|
637
|
+
const people = await loadPeople(db, pausers);
|
|
639
638
|
const ids = tasks.map((t) => t.id);
|
|
640
639
|
// the latest settled non-trial run of each task, and every grant of these tasks, in one query each
|
|
641
640
|
const latest = await db
|
|
@@ -682,9 +681,7 @@ let ScheduledTasksService = class ScheduledTasksService {
|
|
|
682
681
|
taskId: task.id,
|
|
683
682
|
name: task.name,
|
|
684
683
|
reason: task.pauseReason,
|
|
685
|
-
pausedBy: task.pausedBy === null
|
|
686
|
-
? null
|
|
687
|
-
: { id: task.pausedBy, name: names.get(task.pausedBy) ?? "" },
|
|
684
|
+
pausedBy: task.pausedBy === null ? null : (people.get(task.pausedBy) ?? null),
|
|
688
685
|
missing: [],
|
|
689
686
|
needsRole: [],
|
|
690
687
|
needsAdmin: [],
|