@capybara-hq/kernel 0.1.0-rc.56 → 0.1.0-rc.58
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/bootstrap.json +3 -3
- package/dist/admin/extensions.controller.d.ts +2 -10
- package/dist/admin/extensions.controller.js +2 -24
- package/dist/admin/extensions.schemas.d.ts +21 -0
- package/dist/admin/extensions.schemas.js +37 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-extension-switch.d.ts +3 -1
- package/dist/catalog/org-extension-switch.js +12 -5
- package/dist/catalog/org-extension.controller.d.ts +2 -21
- package/dist/catalog/org-extension.controller.js +1 -38
- package/dist/catalog/org-extension.schemas.d.ts +31 -0
- package/dist/catalog/org-extension.schemas.js +65 -0
- package/dist/channels/actions.js +2 -0
- package/dist/channels/cards.d.ts +8 -0
- package/dist/channels/cards.js +18 -0
- package/dist/channels/outbound.js +8 -1
- package/dist/channels/phrases.d.ts +10 -0
- package/dist/channels/phrases.js +10 -0
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/events.d.ts +1 -0
- package/dist/conversations/events.js +5 -0
- package/dist/conversations/leak-check.d.ts +26 -0
- package/dist/conversations/leak-check.js +69 -0
- package/dist/ctx/secrets.d.ts +5 -0
- package/dist/ctx/secrets.js +5 -0
- package/dist/db/kernel-schema.d.ts +15 -0
- package/dist/devices/device-projects.service.d.ts +3 -1
- package/dist/devices/device-projects.service.js +25 -7
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +9 -0
- package/dist/extensions/deployment-config.d.ts +6 -2
- package/dist/extensions/deployment-config.js +35 -23
- package/dist/extensions/org-config.d.ts +2 -0
- package/dist/extensions/org-config.js +1 -0
- package/dist/extensions/org-overrides.d.ts +2 -0
- package/dist/extensions/org-overrides.js +3 -2
- package/dist/identity/initial-passwords.job.d.ts +3 -2
- package/dist/identity/initial-passwords.job.js +9 -5
- package/dist/platform/exclusions.js +1 -41
- package/dist/platform/method.js +1 -0
- package/dist/platform/operation.d.ts +30 -2
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/extensions-admin.ops.d.ts +15 -2
- package/dist/platform/ops/extensions-admin.ops.js +153 -5
- package/dist/platform/ops/extensions.ops.d.ts +19 -5
- package/dist/platform/ops/extensions.ops.js +285 -10
- package/dist/platform/ops/person-inputs.d.ts +35 -0
- package/dist/platform/ops/person-inputs.js +79 -0
- package/dist/platform/ops/plugins.ops.d.ts +2 -0
- package/dist/platform/ops/plugins.ops.js +30 -17
- package/dist/platform/parity.d.ts +6 -2
- package/dist/platform/parity.js +38 -1
- package/dist/platform/person-fields.d.ts +103 -0
- package/dist/platform/person-fields.js +381 -0
- package/dist/platform/platform.module.d.ts +3 -3
- package/dist/platform/platform.module.js +6 -5
- package/dist/platform/sealed-inputs.d.ts +44 -0
- package/dist/platform/sealed-inputs.js +116 -0
- package/dist/runtime/waits.js +8 -2
- package/dist/sandbox/sandbox.service.js +5 -1
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.controller.js +19 -0
- package/dist/tools/approvals.service.d.ts +50 -1
- package/dist/tools/approvals.service.js +118 -10
- package/dist/tools/builtins/builtin-tools.d.ts +3 -0
- package/dist/tools/builtins/builtin-tools.js +31 -9
- package/dist/tools/builtins/platform.d.ts +20 -0
- package/dist/tools/builtins/platform.js +174 -15
- package/dist/tools/pipeline.d.ts +24 -2
- package/dist/tools/pipeline.js +80 -17
- package/dist/tools/policy.d.ts +3 -0
- package/dist/tools/policy.js +6 -0
- package/dist/tools/registry.d.ts +22 -0
- package/dist/tools/tools.module.js +3 -0
- package/package.json +4 -4
- package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
|
+
/** Values shorter than this are never matched: a short value would match ordinary text. */
|
|
3
|
+
export declare const LEAK_CHECK_MIN_LENGTH = 8;
|
|
4
|
+
/**
|
|
5
|
+
* Whether a value a person is about to seal (an approval card's secret field) already appeared in
|
|
6
|
+
* the conversation. The event payloads are searched in PG (`strpos` over the payload's JSON text,
|
|
7
|
+
* for the root conversation and every sub-agent below it, every event type), so the value is a
|
|
8
|
+
* bind parameter and never leaves the database; it is never logged.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ConversationLeakCheck {
|
|
11
|
+
private readonly db;
|
|
12
|
+
constructor(db: KernelDb);
|
|
13
|
+
/**
|
|
14
|
+
* The keys of `values` (value paths) whose value, 8 characters or more, appears in the event
|
|
15
|
+
* log of `conversationId`'s root conversation tree. Runs inside the caller's transaction when
|
|
16
|
+
* there is one.
|
|
17
|
+
*/
|
|
18
|
+
leaked(conversationId: string, values: Readonly<Record<string, string>>): Promise<string[]>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The one {@link ConversationLeakCheck} (the database only), its own module so the tools module
|
|
22
|
+
* (the approval decision) imports it without importing the conversations module, which imports
|
|
23
|
+
* the tools module.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ConversationLeakCheckModule {
|
|
26
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
11
|
+
import { sql } from "kysely";
|
|
12
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
13
|
+
import { rootConversationOf } from "../runtime/subagents/child.js";
|
|
14
|
+
import { conversationTree } from "./tree.js";
|
|
15
|
+
/** Values shorter than this are never matched: a short value would match ordinary text. */
|
|
16
|
+
export const LEAK_CHECK_MIN_LENGTH = 8;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a value a person is about to seal (an approval card's secret field) already appeared in
|
|
19
|
+
* the conversation. The event payloads are searched in PG (`strpos` over the payload's JSON text,
|
|
20
|
+
* for the root conversation and every sub-agent below it, every event type), so the value is a
|
|
21
|
+
* bind parameter and never leaves the database; it is never logged.
|
|
22
|
+
*/
|
|
23
|
+
let ConversationLeakCheck = class ConversationLeakCheck {
|
|
24
|
+
db;
|
|
25
|
+
constructor(db) {
|
|
26
|
+
this.db = db;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The keys of `values` (value paths) whose value, 8 characters or more, appears in the event
|
|
30
|
+
* log of `conversationId`'s root conversation tree. Runs inside the caller's transaction when
|
|
31
|
+
* there is one.
|
|
32
|
+
*/
|
|
33
|
+
async leaked(conversationId, values) {
|
|
34
|
+
const candidates = Object.entries(values).filter(([, v]) => v.length >= LEAK_CHECK_MIN_LENGTH);
|
|
35
|
+
if (candidates.length === 0)
|
|
36
|
+
return [];
|
|
37
|
+
const root = await rootConversationOf(this.db.db, conversationId);
|
|
38
|
+
const ids = (await conversationTree(this.db.db, root)).map((c) => c.id);
|
|
39
|
+
const found = [];
|
|
40
|
+
for (const [path, value] of candidates) {
|
|
41
|
+
// the payload is stored as JSON text, so a value is searched in its JSON-escaped form
|
|
42
|
+
const needle = JSON.stringify(value).slice(1, -1);
|
|
43
|
+
const r = await sql `
|
|
44
|
+
SELECT EXISTS (
|
|
45
|
+
SELECT 1 FROM capybara.conversation_events
|
|
46
|
+
WHERE conversation_id = ANY(${ids}::text[]) AND strpos(payload::text, ${needle}) > 0
|
|
47
|
+
) AS hit`.execute(this.db.db);
|
|
48
|
+
if (r.rows[0]?.hit === true)
|
|
49
|
+
found.push(path);
|
|
50
|
+
}
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
ConversationLeakCheck = __decorate([
|
|
55
|
+
Injectable(),
|
|
56
|
+
__param(0, Inject(KernelDb))
|
|
57
|
+
], ConversationLeakCheck);
|
|
58
|
+
export { ConversationLeakCheck };
|
|
59
|
+
/**
|
|
60
|
+
* The one {@link ConversationLeakCheck} (the database only), its own module so the tools module
|
|
61
|
+
* (the approval decision) imports it without importing the conversations module, which imports
|
|
62
|
+
* the tools module.
|
|
63
|
+
*/
|
|
64
|
+
let ConversationLeakCheckModule = class ConversationLeakCheckModule {
|
|
65
|
+
};
|
|
66
|
+
ConversationLeakCheckModule = __decorate([
|
|
67
|
+
Module({ providers: [ConversationLeakCheck], exports: [ConversationLeakCheck] })
|
|
68
|
+
], ConversationLeakCheckModule);
|
|
69
|
+
export { ConversationLeakCheckModule };
|
package/dist/ctx/secrets.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export interface RewrapResult {
|
|
|
53
53
|
export declare const REWRAP_BATCH_SIZE = 500;
|
|
54
54
|
/** The AAD binding a sealed initial password to its account (a row moved to another one fails). */
|
|
55
55
|
export declare const initialPasswordAad: (accountId: string) => string;
|
|
56
|
+
/**
|
|
57
|
+
* The AAD binding a person's sealed card values to their approval and field paths (sorted, joined
|
|
58
|
+
* by ","): a row moved to another approval, or whose paths are altered, fails to unwrap.
|
|
59
|
+
*/
|
|
60
|
+
export declare const platformSealedInputAad: (approvalId: string, paths: readonly string[]) => string;
|
|
56
61
|
type RewrapHandles = {
|
|
57
62
|
db: Pick<KernelDb, "db">;
|
|
58
63
|
txHost: Pick<TransactionHost, "run">;
|
package/dist/ctx/secrets.js
CHANGED
|
@@ -147,6 +147,11 @@ export function createSecrets(db, keyring, namespace) {
|
|
|
147
147
|
export const REWRAP_BATCH_SIZE = 500;
|
|
148
148
|
/** The AAD binding a sealed initial password to its account (a row moved to another one fails). */
|
|
149
149
|
export const initialPasswordAad = (accountId) => `capybara:initial-password:${accountId}`;
|
|
150
|
+
/**
|
|
151
|
+
* The AAD binding a person's sealed card values to their approval and field paths (sorted, joined
|
|
152
|
+
* by ","): a row moved to another approval, or whose paths are altered, fails to unwrap.
|
|
153
|
+
*/
|
|
154
|
+
export const platformSealedInputAad = (approvalId, paths) => `capybara:platform-sealed-input:${approvalId}:${[...paths].sort().join(",")}`;
|
|
150
155
|
const MASTER_KEYED = [
|
|
151
156
|
{
|
|
152
157
|
table: "org_data_keys",
|
|
@@ -114,6 +114,20 @@ export interface AccountInitialPasswordsTable {
|
|
|
114
114
|
expires_at: Date | string;
|
|
115
115
|
created_at: Ts;
|
|
116
116
|
}
|
|
117
|
+
/** A person's sealed card values for one approval (migration 0169). */
|
|
118
|
+
export interface PlatformSealedInputsTable {
|
|
119
|
+
approval_id: string;
|
|
120
|
+
recipient_account_id: string;
|
|
121
|
+
conversation_id: string;
|
|
122
|
+
run_id: string;
|
|
123
|
+
call_id: string;
|
|
124
|
+
/** The sorted field paths; part of the AAD. */
|
|
125
|
+
paths: string[];
|
|
126
|
+
master_key_id: string;
|
|
127
|
+
ciphertext: Buffer;
|
|
128
|
+
expires_at: Date | string;
|
|
129
|
+
created_at: Ts;
|
|
130
|
+
}
|
|
117
131
|
export interface IdentitiesTable {
|
|
118
132
|
source: string;
|
|
119
133
|
external_id: string;
|
|
@@ -1610,6 +1624,7 @@ export interface KernelDatabase {
|
|
|
1610
1624
|
permission_config_publication: PermissionConfigPublicationTable;
|
|
1611
1625
|
org_data_keys: OrgDataKeysTable;
|
|
1612
1626
|
account_initial_passwords: AccountInitialPasswordsTable;
|
|
1627
|
+
platform_sealed_inputs: PlatformSealedInputsTable;
|
|
1613
1628
|
identities: IdentitiesTable;
|
|
1614
1629
|
local_passwords: LocalPasswordsTable;
|
|
1615
1630
|
orgs: OrgsTable;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ApiError } from "../errors.js";
|
|
2
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
3
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
|
+
import type { KernelLogger } from "../log.js";
|
|
4
5
|
import type { SandboxMode } from "../sandbox/modes.js";
|
|
5
6
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
6
7
|
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
@@ -65,9 +66,10 @@ export declare class DeviceProjectsService {
|
|
|
65
66
|
private readonly access;
|
|
66
67
|
private readonly facts;
|
|
67
68
|
private readonly ceilings;
|
|
69
|
+
private readonly log;
|
|
68
70
|
/** The paired activation gate: once on, every device read is an owner browse. */
|
|
69
71
|
private readonly activation?;
|
|
70
|
-
constructor(db: KernelDb, txHost: TransactionHost, sandbox: Pick<SandboxService, "withSandbox" | "withBrowse" | "ensureRunningForOwner">, access: Pick<DeviceAccess, "usable">, facts: Pick<PermissionFacts, "resolveProjectForBinding" | "projectMatches" | "projectScope">, ceilings: PermissionCeilingWrites,
|
|
72
|
+
constructor(db: KernelDb, txHost: TransactionHost, sandbox: Pick<SandboxService, "withSandbox" | "withBrowse" | "ensureRunningForOwner">, access: Pick<DeviceAccess, "usable">, facts: Pick<PermissionFacts, "resolveProjectForBinding" | "projectMatches" | "projectScope">, ceilings: PermissionCeilingWrites, log: Pick<KernelLogger, "warn">,
|
|
71
73
|
/** The paired activation gate: once on, every device read is an owner browse. */
|
|
72
74
|
activation?: boolean | undefined);
|
|
73
75
|
/** The projects the device's current mode can read; see {@link DeviceProjectList}. */
|
|
@@ -16,6 +16,7 @@ import { audit } from "../identity/audit.js";
|
|
|
16
16
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
17
17
|
import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
|
|
18
18
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
19
|
+
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
19
20
|
import { projectsUnsupported } from "../local-devices/local-device-provider.js";
|
|
20
21
|
import { POLICY_REFUSAL_PREFIX } from "../local-devices/relay.js";
|
|
21
22
|
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
@@ -80,8 +81,9 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
80
81
|
access;
|
|
81
82
|
facts;
|
|
82
83
|
ceilings;
|
|
84
|
+
log;
|
|
83
85
|
activation;
|
|
84
|
-
constructor(db, txHost, sandbox, access, facts, ceilings,
|
|
86
|
+
constructor(db, txHost, sandbox, access, facts, ceilings, log,
|
|
85
87
|
/** The paired activation gate: once on, every device read is an owner browse. */
|
|
86
88
|
activation) {
|
|
87
89
|
this.db = db;
|
|
@@ -90,6 +92,7 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
90
92
|
this.access = access;
|
|
91
93
|
this.facts = facts;
|
|
92
94
|
this.ceilings = ceilings;
|
|
95
|
+
this.log = log;
|
|
93
96
|
this.activation = activation;
|
|
94
97
|
}
|
|
95
98
|
/** The projects the device's current mode can read; see {@link DeviceProjectList}. */
|
|
@@ -139,7 +142,11 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
139
142
|
}
|
|
140
143
|
catch (e) {
|
|
141
144
|
// the base is the device's own workspace or home: a refusal there is not the person's path
|
|
142
|
-
|
|
145
|
+
const passed = passThrough(e);
|
|
146
|
+
if (passed !== undefined)
|
|
147
|
+
throw passed;
|
|
148
|
+
this.log.warn("device projects: the device could not scan", { deviceId, err: e });
|
|
149
|
+
throw unavailable(e);
|
|
143
150
|
}
|
|
144
151
|
// the device's answer is checked again: inside the base and the mode, a valid name, bounded
|
|
145
152
|
const candidates = found
|
|
@@ -217,7 +224,11 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
217
224
|
answer = await list(path, 1, sig);
|
|
218
225
|
}
|
|
219
226
|
catch (e) {
|
|
220
|
-
throw await listFailure(e, r, path, scope.mode, sig)
|
|
227
|
+
throw await listFailure(e, r, path, scope.mode, sig, (err, statErr) => this.log.warn("device projects: the device could not list", {
|
|
228
|
+
deviceId,
|
|
229
|
+
err,
|
|
230
|
+
statErr,
|
|
231
|
+
}));
|
|
221
232
|
}
|
|
222
233
|
if (answer === null)
|
|
223
234
|
throw pathMissing(path);
|
|
@@ -373,6 +384,8 @@ let DeviceProjectsService = class DeviceProjectsService {
|
|
|
373
384
|
throw e;
|
|
374
385
|
if (e instanceof SandboxProviderUnreachableError)
|
|
375
386
|
throw providerUnreachable();
|
|
387
|
+
// the answer hides the cause (a provider's text is not for people): ops read it here
|
|
388
|
+
this.log.warn("device projects: the device could not be asked", { deviceId, err: e });
|
|
376
389
|
throw unavailable(e);
|
|
377
390
|
}
|
|
378
391
|
}
|
|
@@ -409,8 +422,9 @@ DeviceProjectsService = __decorate([
|
|
|
409
422
|
__param(3, Inject(DeviceAccess)),
|
|
410
423
|
__param(4, Inject(PermissionFacts)),
|
|
411
424
|
__param(5, Inject(PermissionCeilingWrites)),
|
|
412
|
-
__param(6,
|
|
413
|
-
__param(
|
|
425
|
+
__param(6, Inject(KERNEL_LOGGER)),
|
|
426
|
+
__param(7, Optional()),
|
|
427
|
+
__param(7, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
414
428
|
], DeviceProjectsService);
|
|
415
429
|
export { DeviceProjectsService };
|
|
416
430
|
/**
|
|
@@ -473,7 +487,7 @@ const pathMissing = (path) => new ApiError("device.project_path_missing", `${cli
|
|
|
473
487
|
* missing path `device.project_path_missing`, and a `stat` that fails too means the device could
|
|
474
488
|
* not be asked (503 `device.projects_unavailable`).
|
|
475
489
|
*/
|
|
476
|
-
async function listFailure(e, r, path, mode, signal) {
|
|
490
|
+
async function listFailure(e, r, path, mode, signal, logUnavailable) {
|
|
477
491
|
const passed = passThrough(e);
|
|
478
492
|
if (passed !== undefined)
|
|
479
493
|
return passed;
|
|
@@ -488,7 +502,11 @@ async function listFailure(e, r, path, mode, signal) {
|
|
|
488
502
|
st = await r.stat(path, signal);
|
|
489
503
|
}
|
|
490
504
|
catch (e2) {
|
|
491
|
-
|
|
505
|
+
const passed = passThrough(e2);
|
|
506
|
+
if (passed !== undefined)
|
|
507
|
+
return passed;
|
|
508
|
+
logUnavailable(e, e2);
|
|
509
|
+
return unavailable(e);
|
|
492
510
|
}
|
|
493
511
|
if (st === null)
|
|
494
512
|
return pathMissing(path);
|
package/dist/errors.d.ts
CHANGED
|
@@ -369,6 +369,15 @@ export declare const ERROR_CODES: {
|
|
|
369
369
|
readonly "approval.already_decided": 409;
|
|
370
370
|
readonly "approval.scope_not_allowed": 409;
|
|
371
371
|
readonly "approval.not_yours": 403;
|
|
372
|
+
/**
|
|
373
|
+
* An approval with person fields (platform web parity spec §4.2): a value missing or not valid
|
|
374
|
+
* against its schema node (`details: [{ fields: { path, problem }[] }]`, never a value).
|
|
375
|
+
*/
|
|
376
|
+
readonly "approval.inputs_invalid": 422;
|
|
377
|
+
/** An entered value appeared in the conversation (§4.5; `details: [{ fields: path[] }]`). */
|
|
378
|
+
readonly "approval.input_leaked": 422;
|
|
379
|
+
/** Inputs for an approval that asks for none, or for a path it does not ask for. */
|
|
380
|
+
readonly "approval.inputs_not_expected": 400;
|
|
372
381
|
readonly "question.not_found": 404;
|
|
373
382
|
readonly "question.already_answered": 409;
|
|
374
383
|
readonly "tool_output.not_found": 404;
|
package/dist/errors.js
CHANGED
|
@@ -369,6 +369,15 @@ export const ERROR_CODES = {
|
|
|
369
369
|
"approval.already_decided": 409,
|
|
370
370
|
"approval.scope_not_allowed": 409,
|
|
371
371
|
"approval.not_yours": 403,
|
|
372
|
+
/**
|
|
373
|
+
* An approval with person fields (platform web parity spec §4.2): a value missing or not valid
|
|
374
|
+
* against its schema node (`details: [{ fields: { path, problem }[] }]`, never a value).
|
|
375
|
+
*/
|
|
376
|
+
"approval.inputs_invalid": 422,
|
|
377
|
+
/** An entered value appeared in the conversation (§4.5; `details: [{ fields: path[] }]`). */
|
|
378
|
+
"approval.input_leaked": 422,
|
|
379
|
+
/** Inputs for an approval that asks for none, or for a path it does not ask for. */
|
|
380
|
+
"approval.inputs_not_expected": 400,
|
|
372
381
|
"question.not_found": 404,
|
|
373
382
|
"question.already_answered": 409,
|
|
374
383
|
"tool_output.not_found": 404,
|
|
@@ -158,7 +158,9 @@ export declare class ExtensionDeploymentConfigService {
|
|
|
158
158
|
* (detail only `changedPaths`). After the commit publishes {@link PLUGIN_DEPLOYMENT_CONFIG_TOPIC} and
|
|
159
159
|
* applies it on this replica right away.
|
|
160
160
|
*/
|
|
161
|
-
put(plugin: string, values: Record<string, unknown>, actor: string, actorTokenId?: string, secretEntries?: readonly SecretEntry[]
|
|
161
|
+
put(plugin: string, values: Record<string, unknown>, actor: string, actorTokenId?: string, secretEntries?: readonly SecretEntry[],
|
|
162
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
163
|
+
auditDetail?: Record<string, unknown>): Promise<DeploymentConfigView>;
|
|
162
164
|
/**
|
|
163
165
|
* Clears the deployment config stored in PG: the `extension_deployment_configs` row and every
|
|
164
166
|
* secret stored for the extension (any path, also ones an older version declared). Fields from
|
|
@@ -172,7 +174,9 @@ export declare class ExtensionDeploymentConfigService {
|
|
|
172
174
|
* and the extension loads from what remains, or is unloaded and becomes pending configuration
|
|
173
175
|
* when that is missing or invalid (`ExtensionHost.applyDeploymentConfig`), without a restart.
|
|
174
176
|
*/
|
|
175
|
-
clear(plugin: string, actor: string, actorTokenId?: string
|
|
177
|
+
clear(plugin: string, actor: string, actorTokenId?: string,
|
|
178
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
179
|
+
auditDetail?: Record<string, unknown>): Promise<DeploymentConfigView>;
|
|
176
180
|
private clearStored;
|
|
177
181
|
/**
|
|
178
182
|
* Secret entries name a secret record field some hint names (else 400 `validation_failed`, also
|
|
@@ -149,7 +149,9 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
149
149
|
* (detail only `changedPaths`). After the commit publishes {@link PLUGIN_DEPLOYMENT_CONFIG_TOPIC} and
|
|
150
150
|
* applies it on this replica right away.
|
|
151
151
|
*/
|
|
152
|
-
async put(plugin, values, actor, actorTokenId, secretEntries = []
|
|
152
|
+
async put(plugin, values, actor, actorTokenId, secretEntries = [],
|
|
153
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
154
|
+
auditDetail) {
|
|
153
155
|
const info = await this.info(plugin);
|
|
154
156
|
if (info.fields.length === 0) {
|
|
155
157
|
throw new ApiError("extension.config_invalid", `Extension ${plugin} has no deployment config`);
|
|
@@ -168,7 +170,7 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
168
170
|
}
|
|
169
171
|
const fileValue = this.fileConfig()[plugin];
|
|
170
172
|
const fieldPaths = info.fields.map((f) => f.path);
|
|
171
|
-
const { saved, changed } = await this.write(plugin, values, secretEntries, actor, actorTokenId, info, sources, fileValue);
|
|
173
|
+
const { saved, changed } = await this.write(plugin, values, secretEntries, actor, actorTokenId, info, sources, fileValue, auditDetail);
|
|
172
174
|
const stored = saved ?? {};
|
|
173
175
|
if (info.schema) {
|
|
174
176
|
const secrets = secretValues(info.schema, mergeDeploymentConfig(stored, fileValue, fieldPaths));
|
|
@@ -176,21 +178,29 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
176
178
|
this.log.addSecrets(secrets);
|
|
177
179
|
}
|
|
178
180
|
if (changed.length > 0) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
plugin,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
const applyEverywhere = async () => {
|
|
182
|
+
try {
|
|
183
|
+
await this.bus.publish(PLUGIN_DEPLOYMENT_CONFIG_TOPIC, { plugin });
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
this.log.warn("cannot publish plugin-deployment-config after saving", { plugin, err });
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
await this.lifecycle.applyConfig(plugin);
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
this.log.error("applying the plugin deployment config on this replica failed", {
|
|
193
|
+
plugin,
|
|
194
|
+
err,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
// Inside a caller's transaction (a Platform write applying the person's sealed values) the
|
|
199
|
+
// save is not committed yet: replicas re-read only after the commit
|
|
200
|
+
if (this.txHost.current() !== undefined)
|
|
201
|
+
afterCommit(applyEverywhere);
|
|
202
|
+
else
|
|
203
|
+
await applyEverywhere();
|
|
194
204
|
}
|
|
195
205
|
return this.render(plugin, info, stored, await this.displayNames.get(plugin));
|
|
196
206
|
}
|
|
@@ -207,12 +217,14 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
207
217
|
* and the extension loads from what remains, or is unloaded and becomes pending configuration
|
|
208
218
|
* when that is missing or invalid (`ExtensionHost.applyDeploymentConfig`), without a restart.
|
|
209
219
|
*/
|
|
210
|
-
async clear(plugin, actor, actorTokenId
|
|
220
|
+
async clear(plugin, actor, actorTokenId,
|
|
221
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
222
|
+
auditDetail) {
|
|
211
223
|
const info = await this.info(plugin);
|
|
212
|
-
await this.clearStored(plugin, info.fields.map((f) => f.path), actor, actorTokenId);
|
|
224
|
+
await this.clearStored(plugin, info.fields.map((f) => f.path), actor, actorTokenId, auditDetail);
|
|
213
225
|
return this.render(plugin, info, {}, await this.displayNames.get(plugin));
|
|
214
226
|
}
|
|
215
|
-
async clearStored(plugin, fieldPaths, actor, actorTokenId) {
|
|
227
|
+
async clearStored(plugin, fieldPaths, actor, actorTokenId, auditDetail) {
|
|
216
228
|
const t = this.db;
|
|
217
229
|
await this.adminLock.lockAndAuthorize(actor);
|
|
218
230
|
await this.configLock.lock(plugin);
|
|
@@ -253,7 +265,7 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
253
265
|
...(actorTokenId !== undefined && { actorTokenId }),
|
|
254
266
|
action: "extension.config_cleared",
|
|
255
267
|
target: plugin,
|
|
256
|
-
detail: { clearedPaths },
|
|
268
|
+
detail: { clearedPaths, ...auditDetail },
|
|
257
269
|
});
|
|
258
270
|
afterCommit(async () => {
|
|
259
271
|
try {
|
|
@@ -302,7 +314,7 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
302
314
|
throw new ApiError("validation_failed", `Invalid secret entries for the deployment config of extension ${plugin}`, problems);
|
|
303
315
|
}
|
|
304
316
|
}
|
|
305
|
-
async write(plugin, values, secretEntries, actor, actorTokenId, info, sources, fileValue) {
|
|
317
|
+
async write(plugin, values, secretEntries, actor, actorTokenId, info, sources, fileValue, auditDetail) {
|
|
306
318
|
const fieldPaths = info.fields.map((f) => f.path);
|
|
307
319
|
let changed = [];
|
|
308
320
|
const t = this.db;
|
|
@@ -366,7 +378,7 @@ let ExtensionDeploymentConfigService = class ExtensionDeploymentConfigService {
|
|
|
366
378
|
...(actorTokenId !== undefined && { actorTokenId }),
|
|
367
379
|
action: "extension.deployment_config_updated",
|
|
368
380
|
target: plugin,
|
|
369
|
-
detail: { changedPaths: changed },
|
|
381
|
+
detail: { changedPaths: changed, ...auditDetail },
|
|
370
382
|
});
|
|
371
383
|
return { saved, changed };
|
|
372
384
|
}
|
|
@@ -111,6 +111,8 @@ export interface OrgExtensionPutOptions {
|
|
|
111
111
|
* dependencies) are left to that write: the plugin install that enables it checks them.
|
|
112
112
|
*/
|
|
113
113
|
validateOnly?: boolean;
|
|
114
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
115
|
+
auditDetail?: Record<string, unknown>;
|
|
114
116
|
}
|
|
115
117
|
/**
|
|
116
118
|
* An org's stored config of a plugin no longer matches its org schema (e.g. after a plugin upgrade):
|
|
@@ -62,6 +62,8 @@ export interface OrgOverrideSummary {
|
|
|
62
62
|
interface Actor {
|
|
63
63
|
accountId: string;
|
|
64
64
|
tokenId?: string | undefined;
|
|
65
|
+
/** Merged into the audit detail (a Platform operation's `via: "agent"`). */
|
|
66
|
+
auditDetail?: Record<string, unknown> | undefined;
|
|
65
67
|
}
|
|
66
68
|
/**
|
|
67
69
|
* Org copies of an extension's overridable deployment config (spec A §5.4, §5.5, §5.8): one row of
|
|
@@ -181,7 +181,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
181
181
|
orgId,
|
|
182
182
|
action: "extension.org_override_saved",
|
|
183
183
|
target: plugin,
|
|
184
|
-
detail: { changedPaths: changed },
|
|
184
|
+
detail: { changedPaths: changed, ...actor.auditDetail },
|
|
185
185
|
});
|
|
186
186
|
const secretValues = Object.values(copy.secrets);
|
|
187
187
|
afterCommit(async () => {
|
|
@@ -245,7 +245,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
245
245
|
orgId,
|
|
246
246
|
action: "extension.org_override_taken",
|
|
247
247
|
target: plugin,
|
|
248
|
-
detail: { changedPaths: changed.sort() },
|
|
248
|
+
detail: { changedPaths: changed.sort(), ...actor.auditDetail },
|
|
249
249
|
});
|
|
250
250
|
afterCommit(() => this.effective.invalidate(orgId, plugin));
|
|
251
251
|
return this.render(orgId, run);
|
|
@@ -277,6 +277,7 @@ let OrgOverrides = class OrgOverrides {
|
|
|
277
277
|
orgId,
|
|
278
278
|
action: "extension.org_override_reset",
|
|
279
279
|
target: plugin,
|
|
280
|
+
...(actor.auditDetail !== undefined && { detail: actor.auditDetail }),
|
|
280
281
|
});
|
|
281
282
|
afterCommit(() => this.effective.invalidate(orgId, plugin));
|
|
282
283
|
return this.render(orgId, run);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
2
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
3
3
|
import type { KernelLogger } from "../log.js";
|
|
4
|
-
/** The hourly cleanup of expired sealed initial passwords (`@LockedCron`). */
|
|
4
|
+
/** The hourly cleanup of expired sealed initial passwords and person inputs (`@LockedCron`). */
|
|
5
5
|
export declare const INITIAL_PASSWORD_CLEANUP_JOB = "initial-password-cleanup";
|
|
6
6
|
/**
|
|
7
7
|
* Deletes generated initial passwords nobody read before they expired (Platform tool spec §14.5
|
|
8
|
-
* item 2)
|
|
8
|
+
* item 2) and sealed person inputs no resumed call consumed (platform web parity spec §4.3), once
|
|
9
|
+
* per tick across replicas; the worker role's.
|
|
9
10
|
*/
|
|
10
11
|
export declare class InitialPasswordCleanupJob {
|
|
11
12
|
private readonly db;
|
|
@@ -12,12 +12,14 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
12
12
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
13
13
|
import { LockedCron } from "../infra/schedule/locked-cron.decorator.js";
|
|
14
14
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
15
|
+
import { deleteExpiredSealedInputs } from "../platform/sealed-inputs.js";
|
|
15
16
|
import { deleteExpiredInitialPasswords } from "./initial-passwords.js";
|
|
16
|
-
/** The hourly cleanup of expired sealed initial passwords (`@LockedCron`). */
|
|
17
|
+
/** The hourly cleanup of expired sealed initial passwords and person inputs (`@LockedCron`). */
|
|
17
18
|
export const INITIAL_PASSWORD_CLEANUP_JOB = "initial-password-cleanup";
|
|
18
19
|
/**
|
|
19
20
|
* Deletes generated initial passwords nobody read before they expired (Platform tool spec §14.5
|
|
20
|
-
* item 2)
|
|
21
|
+
* item 2) and sealed person inputs no resumed call consumed (platform web parity spec §4.3), once
|
|
22
|
+
* per tick across replicas; the worker role's.
|
|
21
23
|
*/
|
|
22
24
|
let InitialPasswordCleanupJob = class InitialPasswordCleanupJob {
|
|
23
25
|
db;
|
|
@@ -29,9 +31,11 @@ let InitialPasswordCleanupJob = class InitialPasswordCleanupJob {
|
|
|
29
31
|
this.log = log;
|
|
30
32
|
}
|
|
31
33
|
async cleanup() {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const passwords = await deleteExpiredInitialPasswords(this.db.db);
|
|
35
|
+
const sealedInputs = await deleteExpiredSealedInputs(this.db.db);
|
|
36
|
+
if (passwords > 0 || sealedInputs > 0) {
|
|
37
|
+
this.log.info("expired sealed values deleted", { passwords, sealedInputs });
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
41
|
__decorate([
|
|
@@ -29,22 +29,7 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
29
29
|
{
|
|
30
30
|
route: "GET /api/v1/admin/extensions/:name/org-overrides",
|
|
31
31
|
category: "secret",
|
|
32
|
-
reason: "
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
route: "GET /api/v1/admin/extensions/:name/config",
|
|
36
|
-
category: "secret",
|
|
37
|
-
reason: "Returns deployment config that can include secret fields",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
route: "PUT /api/v1/admin/extensions/:name/config",
|
|
41
|
-
category: "secret",
|
|
42
|
-
reason: "Writes deployment config that can include secret fields",
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
route: "DELETE /api/v1/admin/extensions/:name/config",
|
|
46
|
-
category: "secret",
|
|
47
|
-
reason: "Clears deployment config including secret values; done on the web",
|
|
32
|
+
reason: "Delivers other orgs' config copies of an extension (which differ, which secrets each holds) to the super admin's browser; an agent works in its own org",
|
|
48
33
|
},
|
|
49
34
|
{
|
|
50
35
|
route: "POST /api/v1/admin/extensions/:name/approve",
|
|
@@ -215,31 +200,6 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
215
200
|
category: "human-only",
|
|
216
201
|
reason: "Decides an org's catalog request as super admin",
|
|
217
202
|
},
|
|
218
|
-
{
|
|
219
|
-
route: "PUT /api/v1/orgs/:orgId/extensions/:extension",
|
|
220
|
-
category: "secret",
|
|
221
|
-
reason: "Org extension config may hold secret fields",
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
route: "GET /api/v1/orgs/:orgId/extensions/:extension/overrides",
|
|
225
|
-
category: "secret",
|
|
226
|
-
reason: "The org's copy of an extension's deployment config, with secret fields as set or not",
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
route: "PUT /api/v1/orgs/:orgId/extensions/:extension/overrides",
|
|
230
|
-
category: "secret",
|
|
231
|
-
reason: "Saves the org's config copy, including the org's own secrets entered in the same save",
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
route: "DELETE /api/v1/orgs/:orgId/extensions/:extension/overrides",
|
|
235
|
-
category: "secret",
|
|
236
|
-
reason: "Drops the org's config copy and its secrets; part of the config-copy lifecycle on the web",
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
route: "POST /api/v1/orgs/:orgId/extensions/:extension/overrides/take",
|
|
240
|
-
category: "secret",
|
|
241
|
-
reason: "Starts an org config copy whose secrets a person enters on the web",
|
|
242
|
-
},
|
|
243
203
|
// org-uploads
|
|
244
204
|
{
|
|
245
205
|
route: "POST /api/v1/orgs/:orgId/catalog/uploads/file",
|
package/dist/platform/method.js
CHANGED
|
@@ -11,5 +11,6 @@ export const PLATFORM_METHOD = [
|
|
|
11
11
|
"4. An operation you may not call is not a dead end: its reason says who can (an org admin, the super admin) and whether a request operation exists; offer that.",
|
|
12
12
|
"5. Errors say what to do next; follow them.",
|
|
13
13
|
'6. When unsure how the platform works, use action "read" for the docs before acting.',
|
|
14
|
+
"Secret fields (API keys, tokens, passwords, credentials) never go in params: list their dot paths in askPerson and the person types them on the confirmation card; list the stored secrets to remove in clearSecrets. Required secrets without a stored value are asked even when not listed. The result names each field the person entered, never its value. A secret that appeared in the conversation counts as leaked: tell the person to rotate it.",
|
|
14
15
|
'Find an operation with "browse" (a domain) or "search": each lists its input keys in "params" ("?" marks an optional key, an id key takes the id field of the matching list or get result). "describe" gives the types, bounds and an example; describe before a call whose params you are unsure of, and never guess a key that params does not list.',
|
|
15
16
|
].join("\n");
|