@capybara-hq/kernel 0.1.0-rc.57 → 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/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/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/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,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;
|
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");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { OrgAction } from "../orgs/roles.js";
|
|
3
3
|
import type { ErrorRole } from "./errors.js";
|
|
4
|
+
import type { PersonFieldTarget } from "./person-fields.js";
|
|
4
5
|
/**
|
|
5
6
|
* How an operation is confirmed (spec §6.2): `read` runs; `personal` asks each time and may be
|
|
6
7
|
* remembered; `org` / `platform` ask each time and are never remembered.
|
|
@@ -33,6 +34,24 @@ export interface OperationContext {
|
|
|
33
34
|
* then with `roleFor` in ./ops/unavailable.ts.
|
|
34
35
|
*/
|
|
35
36
|
errorRole?: ErrorRole;
|
|
37
|
+
/**
|
|
38
|
+
* The values the person typed on the approval card for this call's secret fields (platform web
|
|
39
|
+
* parity spec §4.3): present only when the approved call asked for person fields. `paths` are the
|
|
40
|
+
* asked fields; `apply` consumes the sealed values once and runs `fn` with them in the same
|
|
41
|
+
* transaction (a throw puts them back), so the handler passes them to the route's service method
|
|
42
|
+
* inside `fn`. The values never go into the result: the tool appends a line per entered path.
|
|
43
|
+
* `apply` throws when the values expired; the tool returns the "expired" text then.
|
|
44
|
+
*/
|
|
45
|
+
personInputs?: {
|
|
46
|
+
paths: readonly string[];
|
|
47
|
+
apply<T>(fn: (values: Readonly<Record<string, string>>) => Promise<T>): Promise<T>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* At confirmation time, for an operation with `personFields`: the paths the planned card asks
|
|
51
|
+
* the person for (`askPerson` plus the required secrets without a stored value), so `summary`
|
|
52
|
+
* names every field the card shows. Absent elsewhere.
|
|
53
|
+
*/
|
|
54
|
+
personAsk?: readonly string[];
|
|
36
55
|
}
|
|
37
56
|
/**
|
|
38
57
|
* The next step after an error: one text, or one per role where the step differs (spec §14.5
|
|
@@ -57,8 +76,9 @@ export interface OperationError {
|
|
|
57
76
|
* Some codes exist only in the tool, never answered by a route: `marketplace.already_added` (the
|
|
58
77
|
* `marketplaces.add` duplicate check is tool policy; the web accepts a duplicate source),
|
|
59
78
|
* `plugin.needs_input` (input only a person enters on the web), `agent.visibility_web_only`,
|
|
60
|
-
* `catalog.org_owned` (`plugins.set-shown` leaves an org's own plugin to that org),
|
|
61
|
-
* `account.self` / `account.no_change` (disabling your own account, a status that is set already)
|
|
79
|
+
* `catalog.org_owned` (`plugins.set-shown` leaves an org's own plugin to that org),
|
|
80
|
+
* `account.self` / `account.no_change` (disabling your own account, a status that is set already),
|
|
81
|
+
* and `platform.secret_record_web_only` (a secret record the card cannot ask for; ruling R1).
|
|
62
82
|
*/
|
|
63
83
|
export type PrecheckResult = {
|
|
64
84
|
ok: true;
|
|
@@ -133,6 +153,14 @@ export interface PlatformOperation<I = unknown> {
|
|
|
133
153
|
* errors speak.
|
|
134
154
|
*/
|
|
135
155
|
precheck?(input: I, ctx: OperationContext): Promise<PrecheckResult>;
|
|
156
|
+
/**
|
|
157
|
+
* The secret fields of the write's target (platform web parity spec §4.1): read at confirmation
|
|
158
|
+
* time, after availability, and planned against the input's `values`, `askPerson` and
|
|
159
|
+
* `clearSecrets` (`planPersonFields`). Only for writes whose input carries
|
|
160
|
+
* `personFieldParams`; a secret in `values` is refused before the card, and the asked fields
|
|
161
|
+
* make the call always ask the person, once, on the web. Absent: the write has no person fields.
|
|
162
|
+
*/
|
|
163
|
+
personFields?(input: I, ctx: OperationContext): Promise<PersonFieldTarget>;
|
|
136
164
|
/**
|
|
137
165
|
* The bilingual card summary of a write, rendered from the input and kernel reads (names of
|
|
138
166
|
* the targets, preview counts), never from model text; required unless `confirm` is `read`.
|
|
@@ -41,7 +41,7 @@ export const PLATFORM_DOMAINS = [
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
id: "extensions",
|
|
44
|
-
description: "Extensions in the org (state, tool switches, extension point defaults, file previewers) and, for the super admin, on the platform (state, pending permission confirmations, enable, disable, uninstall).",
|
|
44
|
+
description: "Extensions in the org (state, tool switches, extension point defaults, file previewers, the org config and the org's copy of platform config) and, for the super admin, on the platform (state, deployment config, pending permission confirmations, enable, disable, uninstall). Secrets are entered by the person on the confirmation card.",
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
id: "conversations",
|
|
@@ -2,14 +2,26 @@ import { type OnModuleInit } from "@nestjs/common";
|
|
|
2
2
|
import { CatalogService } from "../../catalog/catalog.service.js";
|
|
3
3
|
import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
|
|
4
4
|
import { ExtensionAdmin } from "../../extensions/admin-view.js";
|
|
5
|
+
import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../../extensions/deployment-config.js";
|
|
5
6
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
6
7
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
8
|
+
import { type PersonFieldTarget } from "../person-fields.js";
|
|
7
9
|
import { PlatformOperations } from "../registry.js";
|
|
10
|
+
/**
|
|
11
|
+
* The person fields of an extension's deployment config (platform web parity spec §4.1): the
|
|
12
|
+
* secret fields of its form schema, set or not. A secret field the schema walk cannot address (no
|
|
13
|
+
* form schema, a record) is never asked, and a value for it in `values` is refused as web only. A
|
|
14
|
+
* secret set in the startup config (read-only here) is never asked either: naming it in
|
|
15
|
+
* `askPerson` / `clearSecrets`, or giving it in `values`, is refused before the card with the
|
|
16
|
+
* route's `extension.config_readonly`, so the person never types a value the write would refuse.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deploymentPersonFields(v: DeploymentConfigView, named?: readonly string[], values?: Readonly<Record<string, unknown>>): PersonFieldTarget;
|
|
8
19
|
/**
|
|
9
20
|
* The super admin's extension operations of the `Platform` tool (spec §14.2 "admin console",
|
|
10
21
|
* §14.5 item 1): the deployment's extensions (list, read), enable, disable and uninstall. Installing
|
|
11
22
|
* a package (upload, npm) and approving permissions stay on the web: a person reviews the
|
|
12
|
-
* permissions there.
|
|
23
|
+
* permissions there. The deployment config is read (secrets as set or not) and written here, its
|
|
24
|
+
* secrets entered by the person on the confirmation card (platform web parity spec §4).
|
|
13
25
|
*/
|
|
14
26
|
export declare class ExtensionsAdminOperations implements OnModuleInit {
|
|
15
27
|
private readonly registry;
|
|
@@ -18,7 +30,8 @@ export declare class ExtensionsAdminOperations implements OnModuleInit {
|
|
|
18
30
|
private readonly config;
|
|
19
31
|
private readonly kdb;
|
|
20
32
|
private readonly catalog;
|
|
21
|
-
|
|
33
|
+
private readonly deploymentConfigs;
|
|
34
|
+
constructor(registry: PlatformOperations, admin: ExtensionAdmin, ops: ExtensionAdminOps, config: KernelConfigService, kdb: KernelDb, catalog: CatalogService, deploymentConfigs: ExtensionDeploymentConfigService);
|
|
22
35
|
/** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
|
|
23
36
|
private viewFor;
|
|
24
37
|
onModuleInit(): void;
|