@capybara-hq/kernel 0.1.0-rc.63 → 0.1.0-rc.65
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/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.schemas.d.ts +1 -1
- package/dist/catalog/org-catalog.schemas.js +1 -1
- package/dist/channels/actions.d.ts +2 -5
- package/dist/channels/actions.js +20 -8
- package/dist/channels/cards.d.ts +4 -3
- package/dist/channels/cards.js +6 -4
- package/dist/channels/outbound.js +3 -2
- package/dist/config/schema.js +1 -1
- package/dist/conversations/approval-profile.d.ts +30 -0
- package/dist/conversations/approval-profile.js +62 -0
- package/dist/conversations/conversations.service.js +0 -2
- package/dist/conversations/events.d.ts +46 -2
- package/dist/conversations/events.js +55 -2
- package/dist/conversations/permission-profiles.controller.d.ts +3 -2
- package/dist/conversations/permission-profiles.service.d.ts +3 -2
- package/dist/conversations/permission-profiles.service.js +12 -8
- package/dist/db/kernel-schema.d.ts +4 -2
- package/dist/identity/initial-passwords.controller.d.ts +8 -6
- package/dist/identity/initial-passwords.controller.js +13 -7
- package/dist/identity/initial-passwords.d.ts +22 -13
- package/dist/identity/initial-passwords.js +25 -29
- package/dist/local-devices/relay.js +3 -1
- package/dist/models/images.js +5 -4
- package/dist/platform/connector-person-fields.js +2 -2
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +9 -7
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/accounts.ops.d.ts +1 -1
- package/dist/platform/ops/accounts.ops.js +3 -3
- package/dist/platform/ops/channels.ops.d.ts +1 -1
- package/dist/platform/ops/channels.ops.js +2 -2
- package/dist/platform/ops/connectors.ops.d.ts +2 -2
- package/dist/platform/ops/connectors.ops.js +8 -8
- package/dist/platform/ops/extensions-admin.ops.d.ts +1 -1
- package/dist/platform/ops/extensions-admin.ops.js +3 -3
- package/dist/platform/ops/extensions.ops.d.ts +1 -1
- package/dist/platform/ops/extensions.ops.js +4 -4
- package/dist/platform/ops/org-plugins.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.d.ts +1 -1
- package/dist/platform/ops/orgs.ops.js +3 -3
- package/dist/platform/ops/plugins.ops.d.ts +1 -1
- package/dist/platform/ops/plugins.ops.js +2 -2
- package/dist/platform/person-fields.d.ts +4 -3
- package/dist/platform/person-fields.js +6 -5
- package/dist/platform/sealed-inputs.d.ts +2 -2
- package/dist/platform/sealed-inputs.js +2 -2
- package/dist/platform/sealed-reveals.controller.d.ts +5 -8
- package/dist/platform/sealed-reveals.controller.js +8 -8
- package/dist/platform/sealed-reveals.d.ts +19 -17
- package/dist/platform/sealed-reveals.js +30 -33
- package/dist/runtime/context/build.js +3 -0
- package/dist/runtime/context/compaction.js +2 -0
- package/dist/runtime/waits.js +3 -2
- package/dist/sandbox/operation-authority.js +16 -15
- package/dist/sandbox/operation-intents.js +2 -2
- package/dist/sandbox/permission-availability.d.ts +49 -3
- package/dist/sandbox/permission-availability.js +61 -6
- package/dist/sandbox/permission-call-types.d.ts +3 -0
- package/dist/sandbox/permission-facts.d.ts +29 -1
- package/dist/sandbox/permission-facts.js +30 -6
- package/dist/sandbox/permission-runtime-reports.js +1 -0
- package/dist/sandbox/review/classifier.d.ts +72 -2
- package/dist/sandbox/review/classifier.js +113 -38
- package/dist/sandbox/review/index.d.ts +2 -2
- package/dist/sandbox/review/index.js +1 -1
- package/dist/sandbox/review/review.service.d.ts +1 -4
- package/dist/sandbox/review/review.service.js +4 -33
- package/dist/setup/setup-guides.service.js +1 -1
- package/dist/tools/approvals.service.d.ts +71 -16
- package/dist/tools/approvals.service.js +139 -13
- package/dist/tools/builtins/builtin-tools.d.ts +1 -1
- package/dist/tools/builtins/builtin-tools.js +12 -6
- package/dist/tools/builtins/platform.d.ts +15 -11
- package/dist/tools/builtins/platform.js +49 -39
- package/dist/tools/builtins/sandbox/bash.d.ts +1 -1
- package/dist/tools/builtins/sandbox/bash.js +32 -14
- package/dist/tools/builtins/sandbox/common.d.ts +12 -3
- package/dist/tools/builtins/sandbox/common.js +29 -5
- package/dist/tools/connectors.schemas.d.ts +1 -1
- package/dist/tools/connectors.schemas.js +1 -1
- package/dist/tools/pipeline.d.ts +70 -10
- package/dist/tools/pipeline.js +359 -49
- package/dist/tools/policy.d.ts +4 -3
- package/dist/tools/policy.js +6 -6
- package/dist/tools/registry.d.ts +25 -9
- package/dist/tools/tool-review.d.ts +113 -0
- package/dist/tools/tool-review.js +303 -0
- package/dist/tools/tools.module.js +6 -0
- package/package.json +3 -3
- package/src/migrations/0175_secure_input_kind.sql +8 -0
|
@@ -612,7 +612,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
612
612
|
}),
|
|
613
613
|
defineOperation({
|
|
614
614
|
id: "plugins.install",
|
|
615
|
-
description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates), and the extension's org config without secrets (extensionConfig). Secrets are never params: the person enters them
|
|
615
|
+
description: "Install a plugin in this org with its inputs (org admins; the web's install wizard): per connector template the connector's name, slug, endpoint fields and OAuth client id (templates), and the extension's org config without secrets (extensionConfig). Secrets are never params: the person enters them in a secure input request, at connectors.<templateId>.credential.token (or .credential.username / .credential.password, .client.clientSecret) and extensionConfig.<field>. Required ones are asked even when not listed in askPerson. A plugin that needs no input is switched on with plugins.set-enabled instead.",
|
|
616
616
|
input: InstallInput,
|
|
617
617
|
example: {
|
|
618
618
|
itemId: EXAMPLE_ID,
|
|
@@ -710,7 +710,7 @@ let OrgPluginsOperations = class OrgPluginsOperations {
|
|
|
710
710
|
}),
|
|
711
711
|
defineOperation({
|
|
712
712
|
id: "plugins.configure-connectors",
|
|
713
|
-
description: "Create the connectors an installed plugin is missing (org admins; the plugin shows needs_config, e.g. after a platform update added a connector template): per missing template its name, slug, endpoint fields and OAuth client id (templates). Credentials are never params: the person enters them
|
|
713
|
+
description: "Create the connectors an installed plugin is missing (org admins; the plugin shows needs_config, e.g. after a platform update added a connector template): per missing template its name, slug, endpoint fields and OAuth client id (templates). Credentials are never params: the person enters them in a secure input request at connectors.<templateId>.credential.token (or .credential.username / .credential.password, .client.clientSecret). Required ones are asked even when not listed in askPerson.",
|
|
714
714
|
input: ConfigureInput,
|
|
715
715
|
example: {
|
|
716
716
|
itemId: EXAMPLE_ID,
|
|
@@ -14,7 +14,7 @@ import { type OrgRole } from "../../orgs/roles.js";
|
|
|
14
14
|
import { PlatformOperations } from "../registry.js";
|
|
15
15
|
import { SealedReveals } from "../sealed-reveals.js";
|
|
16
16
|
/** What `orgs.invite` returns in place of the token (model-visible English). */
|
|
17
|
-
export declare const INVITATION_LINK_NOTE = "The invitation link is shown once, on the web, to the person
|
|
17
|
+
export declare const INVITATION_LINK_NOTE = "The invitation link is shown once, on the web, to the person this call was made for, under the tool call in this conversation; they share it with the invitee. It is never shown to you. If it is not read within 24 hours it is lost: revoke the invitation (orgs.revoke-invitation) and invite again.";
|
|
18
18
|
/**
|
|
19
19
|
* Why a member operation through the tool is never offered (spec §7.2, maintainer decision Q2):
|
|
20
20
|
* the actor's own membership (`member.self`), an owner or granting owner
|
|
@@ -56,7 +56,7 @@ const ROLE_WORDS = {
|
|
|
56
56
|
guest: { zh: "访客", en: "guest" },
|
|
57
57
|
};
|
|
58
58
|
/** What `orgs.invite` returns in place of the token (model-visible English). */
|
|
59
|
-
export const INVITATION_LINK_NOTE = `The invitation link is shown once, on the web, to the person
|
|
59
|
+
export const INVITATION_LINK_NOTE = `The invitation link is shown once, on the web, to the person this call was made for, under the tool call in this conversation; they share it with the invitee. It is never shown to you. If it is not read within ${SEALED_REVEAL_TTL_MS / 3_600_000} hours it is lost: revoke the invitation (orgs.revoke-invitation) and invite again.`;
|
|
60
60
|
/**
|
|
61
61
|
* Why a member operation through the tool is never offered (spec §7.2, maintainer decision Q2):
|
|
62
62
|
* the actor's own membership (`member.self`), an owner or granting owner
|
|
@@ -513,14 +513,14 @@ let OrgsOperations = class OrgsOperations {
|
|
|
513
513
|
}),
|
|
514
514
|
defineOperation({
|
|
515
515
|
id: "orgs.invite",
|
|
516
|
-
description: "Invite a person into this conversation's org (org admins) with a role: admin, member or guest (never owner; never above your own role). expiresInHours is 1 to 720 (default 168). You never see the link: it is shown once, on the web, to the person
|
|
516
|
+
description: "Invite a person into this conversation's org (org admins) with a role: admin, member or guest (never owner; never above your own role). expiresInHours is 1 to 720 (default 168). You never see the link: it is shown once, on the web, to the person the call is made for (under the tool call in the conversation), who shares it with the invitee. If it is not read within 24 hours it is lost: revoke the invitation (orgs.revoke-invitation) and invite again.",
|
|
517
517
|
input: InvitationCreateBody.strict(),
|
|
518
518
|
example: { role: "member" },
|
|
519
519
|
authz: { orgAction: "org.invitations.manage" },
|
|
520
520
|
mirrors: ["POST /api/v1/orgs/:orgId/invitations"],
|
|
521
521
|
confirm: "org",
|
|
522
522
|
rememberable: false,
|
|
523
|
-
|
|
523
|
+
revealsOnce: "invitation_link",
|
|
524
524
|
errors: [
|
|
525
525
|
{
|
|
526
526
|
code: "member.role_above_actor",
|
|
@@ -8,7 +8,7 @@ import { ExtensionAvailability } from "../../extensions/unavailable.js";
|
|
|
8
8
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
9
9
|
import { PlatformOperations } from "../registry.js";
|
|
10
10
|
export { OTHER_ORG } from "./other-orgs.js";
|
|
11
|
-
export declare const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials
|
|
11
|
+
export declare const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
|
|
12
12
|
/** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
|
|
13
13
|
export declare const needsOrgConfig: (extension: string) => string;
|
|
14
14
|
/**
|
|
@@ -40,9 +40,9 @@ export { OTHER_ORG } from "./other-orgs.js";
|
|
|
40
40
|
const LOCKED = "This plugin is on for every org (or shipped with the platform) and cannot be switched off in one org.";
|
|
41
41
|
/** The confirm value of switching off a plugin with nothing installed in the org. */
|
|
42
42
|
const NOTHING_INSTALLED = "nothing-installed";
|
|
43
|
-
export const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials
|
|
43
|
+
export const NEEDS_INPUT = "This plugin needs connector input (endpoints, credentials): install it with plugins.install, or for an installed plugin missing connectors create them with plugins.configure-connectors; the person enters the credentials in a secure input request.";
|
|
44
44
|
/** `plugin.needs_input` when what is missing is its extension's org config (an agent can set it). */
|
|
45
|
-
export const needsOrgConfig = (extension) => `This plugin's extension ${extension} needs its org config first: read what is missing with extensions.org-config, fill it in with extensions.set-org-config (the person enters secrets
|
|
45
|
+
export const needsOrgConfig = (extension) => `This plugin's extension ${extension} needs its org config first: read what is missing with extensions.org-config, fill it in with extensions.set-org-config (the person enters secrets in a secure input request; the org's own copy of overridable platform fields is extensions.save-org-config), then call plugins.set-enabled again.`;
|
|
46
46
|
/** The English name of a plugin as next steps and messages name it. */
|
|
47
47
|
const enName = (i) => localized(i.displayName, i.name).en;
|
|
48
48
|
/** The item with the reason its extension stopped loading (state unchanged), when it has one. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
/**
|
|
3
3
|
* Person fields (platform web parity spec §4.1, §4.2): the secret fields of a write's target config
|
|
4
|
-
* schema that the person types
|
|
4
|
+
* schema that the person types in a secure input request instead of the model passing them in
|
|
5
|
+
* params.
|
|
5
6
|
* Pure rules shared by the Platform operations: find the secret fields of a JSON Schema produced by
|
|
6
7
|
* the SDK's `configJsonSchema` (`"x-secret": true`), plan which ones one call asks for, and check
|
|
7
8
|
* one typed value. Paths are the dot paths the config routes use in `values` (ruling R1); secret
|
|
@@ -10,9 +11,9 @@ import { z } from "zod";
|
|
|
10
11
|
*/
|
|
11
12
|
/** UTF-8 bytes of one value the person types. */
|
|
12
13
|
export declare const PERSON_FIELD_MAX_BYTES: number;
|
|
13
|
-
/** Person fields one call may ask for (one
|
|
14
|
+
/** Person fields one call may ask for (one secure input request). */
|
|
14
15
|
export declare const PERSON_FIELDS_MAX = 32;
|
|
15
|
-
/** One secret field the person may enter
|
|
16
|
+
/** One secret field the person may enter in a secure input request. */
|
|
16
17
|
export interface PersonFieldSpec {
|
|
17
18
|
/** Dot path from the schema root (R1). */
|
|
18
19
|
path: string;
|
|
@@ -3,7 +3,8 @@ import { z } from "zod";
|
|
|
3
3
|
import { hintedSecretPaths } from "../extensions/config-json-schema.js";
|
|
4
4
|
/**
|
|
5
5
|
* Person fields (platform web parity spec §4.1, §4.2): the secret fields of a write's target config
|
|
6
|
-
* schema that the person types
|
|
6
|
+
* schema that the person types in a secure input request instead of the model passing them in
|
|
7
|
+
* params.
|
|
7
8
|
* Pure rules shared by the Platform operations: find the secret fields of a JSON Schema produced by
|
|
8
9
|
* the SDK's `configJsonSchema` (`"x-secret": true`), plan which ones one call asks for, and check
|
|
9
10
|
* one typed value. Paths are the dot paths the config routes use in `values` (ruling R1); secret
|
|
@@ -12,7 +13,7 @@ import { hintedSecretPaths } from "../extensions/config-json-schema.js";
|
|
|
12
13
|
*/
|
|
13
14
|
/** UTF-8 bytes of one value the person types. */
|
|
14
15
|
export const PERSON_FIELD_MAX_BYTES = 16 * 1024;
|
|
15
|
-
/** Person fields one call may ask for (one
|
|
16
|
+
/** Person fields one call may ask for (one secure input request). */
|
|
16
17
|
export const PERSON_FIELDS_MAX = 32;
|
|
17
18
|
/** Characters of one dot path in `askPerson` / `clearSecrets`. */
|
|
18
19
|
const PATH_MAX_CHARS = 200;
|
|
@@ -31,7 +32,7 @@ const pathList = (what) => z
|
|
|
31
32
|
.describe(what);
|
|
32
33
|
/** The params every operation with person fields adds to its input schema. */
|
|
33
34
|
export const personFieldParams = {
|
|
34
|
-
askPerson: pathList("Dot paths of secret fields the person enters
|
|
35
|
+
askPerson: pathList("Dot paths of secret fields the person enters in a secure input request. Never put a secret in values; required secrets without a stored value are asked even when not listed."),
|
|
35
36
|
clearSecrets: pathList("Dot paths of stored secret fields to clear."),
|
|
36
37
|
};
|
|
37
38
|
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -306,7 +307,7 @@ export function planPersonFields(t, p) {
|
|
|
306
307
|
if (leaks(f.path)) {
|
|
307
308
|
return {
|
|
308
309
|
ok: false,
|
|
309
|
-
message: `Secret fields are entered by the person
|
|
310
|
+
message: `Secret fields are entered by the person in a secure input request; leave \`${f.path}\` out of values and list it in askPerson. A value passed in params has been seen by the model and counts as leaked: tell the person to rotate it.`,
|
|
310
311
|
};
|
|
311
312
|
}
|
|
312
313
|
}
|
|
@@ -354,7 +355,7 @@ export function planPersonFields(t, p) {
|
|
|
354
355
|
if (ask.length > PERSON_FIELDS_MAX) {
|
|
355
356
|
return {
|
|
356
357
|
ok: false,
|
|
357
|
-
message: `This call would ask the person for ${ask.length} fields; one
|
|
358
|
+
message: `This call would ask the person for ${ask.length} fields; one secure input request holds at most ${PERSON_FIELDS_MAX}. Split the change into several calls.`,
|
|
358
359
|
};
|
|
359
360
|
}
|
|
360
361
|
return { ok: true, ask, clear: t.fields.filter((f) => clear.has(f.path)).map((f) => f.path) };
|
|
@@ -21,8 +21,8 @@ export interface SealedInputsRow {
|
|
|
21
21
|
callId: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Values a person typed
|
|
25
|
-
* parity spec §4.3). They are sealed with the master keyring in the decision's transaction and
|
|
24
|
+
* Values a person typed in a secure input request for a Platform call's secret fields (platform
|
|
25
|
+
* web parity spec §4.3). They are sealed with the master keyring in the decision's transaction and
|
|
26
26
|
* consumed once by the resumed call, in the transaction that applies the write. They never reach
|
|
27
27
|
* the event log, a tool result, the approval row, the audit or a log line.
|
|
28
28
|
*/
|
|
@@ -27,8 +27,8 @@ export class SealedInputsExpiredError extends Error {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Values a person typed
|
|
31
|
-
* parity spec §4.3). They are sealed with the master keyring in the decision's transaction and
|
|
30
|
+
* Values a person typed in a secure input request for a Platform call's secret fields (platform
|
|
31
|
+
* web parity spec §4.3). They are sealed with the master keyring in the decision's transaction and
|
|
32
32
|
* consumed once by the resumed call, in the transaction that applies the write. They never reach
|
|
33
33
|
* the event log, a tool result, the approval row, the audit or a log line.
|
|
34
34
|
*/
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import { RevealCallParams } from "../identity/initial-passwords.controller.js";
|
|
2
3
|
import { type Principal } from "../identity/principal.js";
|
|
3
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
5
|
import { SealedReveals } from "./sealed-reveals.js";
|
|
5
|
-
declare const ApprovalParams: z.ZodObject<{
|
|
6
|
-
approvalId: z.ZodString;
|
|
7
|
-
}, z.core.$strip>;
|
|
8
6
|
/**
|
|
9
7
|
* The link of an invitation an org admin's agent created (platform web parity spec §7.2): shown
|
|
10
|
-
* once, on the web, to the person
|
|
11
|
-
* consumes it.
|
|
8
|
+
* once, on the web, to the person the `orgs.invite` call was made for, keyed by the call (plan
|
|
9
|
+
* ruling R6). A POST because reading consumes it.
|
|
12
10
|
*/
|
|
13
11
|
export declare class SealedRevealsController {
|
|
14
12
|
private readonly reveals;
|
|
15
13
|
constructor(reveals: SealedReveals);
|
|
16
|
-
reveal(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
14
|
+
reveal(principal: Principal, org: OrgContext, params: z.infer<typeof RevealCallParams>): Promise<{
|
|
17
15
|
url: string;
|
|
18
16
|
}>;
|
|
19
17
|
}
|
|
20
|
-
export {};
|
|
@@ -8,19 +8,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, HttpCode, Inject, Post } from "@nestjs/common";
|
|
11
|
-
import {
|
|
11
|
+
import { RevealCallParams } from "../identity/initial-passwords.controller.js";
|
|
12
12
|
import { CurrentPrincipal, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
13
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
14
14
|
import { ZParam } from "../infra/validation/zod-params.js";
|
|
15
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
16
|
import { SealedReveals } from "./sealed-reveals.js";
|
|
17
|
-
|
|
18
|
-
class ApprovalParamsDto extends createZodDto(ApprovalParams, "InvitationLinkParams") {
|
|
17
|
+
class RevealCallParamsDto extends createZodDto(RevealCallParams, "InvitationLinkParams") {
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
20
|
* The link of an invitation an org admin's agent created (platform web parity spec §7.2): shown
|
|
22
|
-
* once, on the web, to the person
|
|
23
|
-
* consumes it.
|
|
21
|
+
* once, on the web, to the person the `orgs.invite` call was made for, keyed by the call (plan
|
|
22
|
+
* ruling R6). A POST because reading consumes it.
|
|
24
23
|
*/
|
|
25
24
|
let SealedRevealsController = class SealedRevealsController {
|
|
26
25
|
reveals;
|
|
@@ -29,7 +28,8 @@ let SealedRevealsController = class SealedRevealsController {
|
|
|
29
28
|
}
|
|
30
29
|
async reveal(principal, org, params) {
|
|
31
30
|
const p = requireUser(principal);
|
|
32
|
-
|
|
31
|
+
const { conversationId, runId, callId } = params;
|
|
32
|
+
return this.reveals.reveal(org.orgId, { conversationId, runId, callId }, p.account.id);
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
__decorate([
|
|
@@ -39,10 +39,10 @@ __decorate([
|
|
|
39
39
|
SessionOnly(),
|
|
40
40
|
__param(0, CurrentPrincipal()),
|
|
41
41
|
__param(1, CurrentOrg()),
|
|
42
|
-
__param(2, ZParam(
|
|
42
|
+
__param(2, ZParam(RevealCallParamsDto))
|
|
43
43
|
], SealedRevealsController.prototype, "reveal", null);
|
|
44
44
|
SealedRevealsController = __decorate([
|
|
45
|
-
Controller("api/v1/orgs/:orgId/
|
|
45
|
+
Controller("api/v1/orgs/:orgId/conversations/:conversationId/runs/:runId/calls/:callId/invitation-link"),
|
|
46
46
|
__param(0, Inject(SealedReveals))
|
|
47
47
|
], SealedRevealsController);
|
|
48
48
|
export { SealedRevealsController };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { type Keyring } from "../ctx/secrets.js";
|
|
2
2
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
|
+
import type { RevealCall } from "../identity/initial-passwords.js";
|
|
3
4
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
7
|
/**
|
|
7
8
|
* How long a sealed invitation link waits for its reader, like a generated initial password: the
|
|
8
|
-
*
|
|
9
|
-
* invitation and invite again).
|
|
9
|
+
* person the call was made for reads it right after the call runs; one never read expires
|
|
10
|
+
* (revoke the invitation and invite again).
|
|
10
11
|
*/
|
|
11
12
|
export declare const SEALED_REVEAL_TTL_MS: number;
|
|
12
|
-
/**
|
|
13
|
-
export declare const INVITE_TOOL_KEY = "Platform:orgs.invite";
|
|
14
|
-
/** Where a sealed value is delivered: the approved tool call and the person who approved. */
|
|
13
|
+
/** Where a sealed value is delivered: the tool call and the person it was made for. */
|
|
15
14
|
export interface SealedRevealDelivery {
|
|
16
15
|
conversationId: string;
|
|
17
16
|
/** The run of the call: a call id is unique only within its run. */
|
|
18
17
|
runId: string;
|
|
19
18
|
callId: string;
|
|
20
|
-
/** The account that may read it: the
|
|
19
|
+
/** The account that may read it: the person the call was made for (the run's own person). */
|
|
21
20
|
recipientAccountId: string;
|
|
22
21
|
}
|
|
23
22
|
/** The web path of an invitation link (apps/web `invitePath`). */
|
|
24
23
|
export declare const invitationPath: (token: string) => string;
|
|
25
24
|
/**
|
|
26
|
-
* Values a Platform call makes that only the person
|
|
27
|
-
* parity spec §7.2, plan ruling
|
|
28
|
-
* token never reaches the model, the tool result, the
|
|
29
|
-
*
|
|
30
|
-
*
|
|
25
|
+
* Values a Platform call makes that only the person the call was made for may read (platform web
|
|
26
|
+
* parity spec §7.2; read by call: profiles govern every approval, plan ruling R6): the token of an
|
|
27
|
+
* invitation an org admin's agent created. The token never reaches the model, the tool result, the
|
|
28
|
+
* event log, the audit or a log line: it is sealed with the master keyring in the creation's
|
|
29
|
+
* transaction and read once, on the web, by that person, like the generated initial password
|
|
30
|
+
* (`InitialPasswords`).
|
|
31
31
|
*/
|
|
32
32
|
export declare class SealedReveals {
|
|
33
33
|
private readonly db;
|
|
@@ -38,13 +38,15 @@ export declare class SealedReveals {
|
|
|
38
38
|
/** Seals an invitation's token for `to`, in the caller's (the creation's) transaction. */
|
|
39
39
|
sealIn(orgId: string, invitationId: string, token: string, to: SealedRevealDelivery): Promise<void>;
|
|
40
40
|
/**
|
|
41
|
-
* The link of the invitation an
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
41
|
+
* The link of the invitation an `orgs.invite` call created (`call` in `orgId`), read once by its
|
|
42
|
+
* recipient `accountId` while the call's conversation is still accessible to them, then deleted
|
|
43
|
+
* (plan ruling R6: read by call, whether the call ran under an approval or automatically).
|
|
44
|
+
* Anything else (not the recipient, the conversation not accessible, not run yet, read already,
|
|
45
|
+
* expired, the invitation no longer pending) is `invitation.link_unavailable`, saying nothing
|
|
46
|
+
* about which. Audits the read (without the token). The URL is absolute under
|
|
47
|
+
* `http.publicUrl`, else the web path.
|
|
46
48
|
*/
|
|
47
|
-
reveal(orgId: string,
|
|
49
|
+
reveal(orgId: string, call: RevealCall, accountId: string): Promise<{
|
|
48
50
|
url: string;
|
|
49
51
|
}>;
|
|
50
52
|
}
|
|
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { sql } from "kysely";
|
|
12
|
+
import { accessibleTo } from "../conversations/access.js";
|
|
12
13
|
import { platformSealedRevealAad as aadOf } from "../ctx/secrets.js";
|
|
13
14
|
import { ApiError } from "../errors.js";
|
|
14
15
|
import { audit } from "../identity/audit.js";
|
|
@@ -19,20 +20,19 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
19
20
|
import { KEYRING } from "../infra/tokens.js";
|
|
20
21
|
/**
|
|
21
22
|
* How long a sealed invitation link waits for its reader, like a generated initial password: the
|
|
22
|
-
*
|
|
23
|
-
* invitation and invite again).
|
|
23
|
+
* person the call was made for reads it right after the call runs; one never read expires
|
|
24
|
+
* (revoke the invitation and invite again).
|
|
24
25
|
*/
|
|
25
26
|
export const SEALED_REVEAL_TTL_MS = 24 * 60 * 60 * 1000;
|
|
26
|
-
/** The tool key of the approval an invitation link belongs to. */
|
|
27
|
-
export const INVITE_TOOL_KEY = "Platform:orgs.invite";
|
|
28
27
|
/** The web path of an invitation link (apps/web `invitePath`). */
|
|
29
28
|
export const invitationPath = (token) => `/invite/${encodeURIComponent(token)}`;
|
|
30
29
|
/**
|
|
31
|
-
* Values a Platform call makes that only the person
|
|
32
|
-
* parity spec §7.2, plan ruling
|
|
33
|
-
* token never reaches the model, the tool result, the
|
|
34
|
-
*
|
|
35
|
-
*
|
|
30
|
+
* Values a Platform call makes that only the person the call was made for may read (platform web
|
|
31
|
+
* parity spec §7.2; read by call: profiles govern every approval, plan ruling R6): the token of an
|
|
32
|
+
* invitation an org admin's agent created. The token never reaches the model, the tool result, the
|
|
33
|
+
* event log, the audit or a log line: it is sealed with the master keyring in the creation's
|
|
34
|
+
* transaction and read once, on the web, by that person, like the generated initial password
|
|
35
|
+
* (`InitialPasswords`).
|
|
36
36
|
*/
|
|
37
37
|
let SealedReveals = class SealedReveals {
|
|
38
38
|
db;
|
|
@@ -68,37 +68,34 @@ let SealedReveals = class SealedReveals {
|
|
|
68
68
|
.execute();
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* The link of the invitation an
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
71
|
+
* The link of the invitation an `orgs.invite` call created (`call` in `orgId`), read once by its
|
|
72
|
+
* recipient `accountId` while the call's conversation is still accessible to them, then deleted
|
|
73
|
+
* (plan ruling R6: read by call, whether the call ran under an approval or automatically).
|
|
74
|
+
* Anything else (not the recipient, the conversation not accessible, not run yet, read already,
|
|
75
|
+
* expired, the invitation no longer pending) is `invitation.link_unavailable`, saying nothing
|
|
76
|
+
* about which. Audits the read (without the token). The URL is absolute under
|
|
77
|
+
* `http.publicUrl`, else the web path.
|
|
76
78
|
*/
|
|
77
|
-
async reveal(orgId,
|
|
78
|
-
const unavailable = () => new ApiError("invitation.link_unavailable", "No invitation link to show: it was shown already, has expired, the invitation is no longer pending, or it was not created by a call you
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
.select(["conversation_id", "run_id", "call_id", "tool_key", "status", "decided_by"])
|
|
82
|
-
.where("id", "=", approvalId)
|
|
83
|
-
.where("org_id", "=", orgId)
|
|
84
|
-
.executeTakeFirst();
|
|
85
|
-
if (approval === undefined ||
|
|
86
|
-
approval.tool_key !== INVITE_TOOL_KEY ||
|
|
87
|
-
approval.status !== "approved" ||
|
|
88
|
-
approval.decided_by !== accountId) {
|
|
89
|
-
throw unavailable();
|
|
90
|
-
}
|
|
91
|
-
// exactly the row of this approval's call, for a still pending invitation: deleted as read
|
|
79
|
+
async reveal(orgId, call, accountId) {
|
|
80
|
+
const unavailable = () => new ApiError("invitation.link_unavailable", "No invitation link to show: it was shown already, has expired, the invitation is no longer pending, or it was not created by a call made for you");
|
|
81
|
+
// exactly the row of this call, for its recipient in a conversation they can still see and
|
|
82
|
+
// a still pending invitation: deleted as read
|
|
92
83
|
const row = await this.db
|
|
93
84
|
.deleteFrom("platform_sealed_reveals")
|
|
94
85
|
.where("kind", "=", "invitation_link")
|
|
95
86
|
.where("org_id", "=", orgId)
|
|
96
|
-
.where("conversation_id", "=",
|
|
97
|
-
.where("run_id", "=",
|
|
98
|
-
.where("call_id", "=",
|
|
87
|
+
.where("conversation_id", "=", call.conversationId)
|
|
88
|
+
.where("run_id", "=", call.runId)
|
|
89
|
+
.where("call_id", "=", call.callId)
|
|
99
90
|
.where("recipient_account_id", "=", accountId)
|
|
100
91
|
.where("expires_at", ">", sql `now()`)
|
|
101
92
|
.where((eb) => eb.exists(eb
|
|
93
|
+
.selectFrom("conversations")
|
|
94
|
+
.select("conversations.id")
|
|
95
|
+
.whereRef("conversations.id", "=", "platform_sealed_reveals.conversation_id")
|
|
96
|
+
.where("conversations.org_id", "=", orgId)
|
|
97
|
+
.where(accessibleTo(accountId))))
|
|
98
|
+
.where((eb) => eb.exists(eb
|
|
102
99
|
.selectFrom("invitations")
|
|
103
100
|
.select("invitations.id")
|
|
104
101
|
.whereRef("invitations.id", "=", "platform_sealed_reveals.id")
|
|
@@ -123,7 +120,7 @@ let SealedReveals = class SealedReveals {
|
|
|
123
120
|
orgId,
|
|
124
121
|
action: "org.invitation.link_shown",
|
|
125
122
|
target: row.id,
|
|
126
|
-
detail: {
|
|
123
|
+
detail: { conversationId: call.conversationId, runId: call.runId, callId: call.callId },
|
|
127
124
|
});
|
|
128
125
|
const base = this.config.get().http.publicUrl?.replace(/\/+$/, "") ?? "";
|
|
129
126
|
return { url: `${base}${invitationPath(token)}` };
|
|
@@ -999,6 +999,9 @@ export function buildModelRequest(input) {
|
|
|
999
999
|
// its recorded permission_context, the review only through the tool result
|
|
1000
1000
|
case "permission_profile_changed":
|
|
1001
1001
|
case "permission_reviewed":
|
|
1002
|
+
// an automatic decision of a person's ask is display and audit only; the model sees the
|
|
1003
|
+
// call's tool result
|
|
1004
|
+
case "tool_ask_decided":
|
|
1002
1005
|
break;
|
|
1003
1006
|
default: {
|
|
1004
1007
|
const unrendered = e;
|
|
@@ -363,6 +363,8 @@ function transcriptLine(e) {
|
|
|
363
363
|
case "permission_context":
|
|
364
364
|
case "permission_profile_changed":
|
|
365
365
|
case "permission_reviewed":
|
|
366
|
+
// an automatic decision of a person's ask is display and audit only
|
|
367
|
+
case "tool_ask_decided":
|
|
366
368
|
return null;
|
|
367
369
|
default: {
|
|
368
370
|
const unrendered = e;
|
package/dist/runtime/waits.js
CHANGED
|
@@ -353,8 +353,9 @@ let Waits = class Waits {
|
|
|
353
353
|
}
|
|
354
354
|
: {
|
|
355
355
|
toolKey: a.tool_key,
|
|
356
|
-
// a tool ask whose card refused a person's value as leaked says
|
|
357
|
-
|
|
356
|
+
// a tool ask or secure input whose card refused a person's value as leaked says
|
|
357
|
+
// so (§4.5)
|
|
358
|
+
text: withLeakedOnCard(APPROVAL_CANCELLED_TEXT, a.kind === "tool" || a.kind === "secure_input"
|
|
358
359
|
? a.detail?.leakedFields
|
|
359
360
|
: undefined),
|
|
360
361
|
});
|
|
@@ -8,7 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
|
-
import { instanceSupported, parseSandboxBrowseScope, parseSandboxOperationScope,
|
|
11
|
+
import { instanceSupported, parseSandboxBrowseScope, parseSandboxOperationScope, } from "@capybara-hq/plugin-sdk";
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import { ACTOR_DEVICE_ACCESS_REASON, ACTOR_NOT_DEVICE_OWNER_REASON, PermissionContextV2Schema, permissionCodePointCompare, } from "../conversations/events.js";
|
|
@@ -25,12 +25,14 @@ import { coversHost, projectReachOf } from "./modes.js";
|
|
|
25
25
|
import { EscalationGrantMissingError, isExecutionMethod, parseStartingExecutionGrants, } from "./operation-authority-types.js";
|
|
26
26
|
import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
|
|
27
27
|
import { assertAuthorityHeld, PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
28
|
+
import { PermissionAdmissionUnavailable, runtimeReportVerdict, } from "./permission-availability.js";
|
|
28
29
|
import { PermissionCallGrants } from "./permission-call-grants.js";
|
|
29
30
|
import { PermissionConfigPublication } from "./permission-config-publication.js";
|
|
30
31
|
import { PermissionContextSubjectChanged, } from "./permission-context-types.js";
|
|
31
32
|
import { hostsWithinOuter, PermissionFacts, permissionScopeHash } from "./permission-facts.js";
|
|
32
33
|
import { ESCALATION_UNATTENDED_WHY, escalationCeilingWhy, escalationRuntimeWhy, normalizePermissionExpansion, runtimeWriteRootRefusal, withinDirectory, } from "./review/permission-candidate.js";
|
|
33
34
|
const UNPROVED_ENVIRONMENT = "The device's installed environment is not verified yet; it is checked when the device starts";
|
|
35
|
+
const RUNTIME_CAUSE = { kind: "runtime" };
|
|
34
36
|
/**
|
|
35
37
|
* The one verdict over a device's runtime report and its applied environment (B1, B-16): the
|
|
36
38
|
* recorded permission context withholds its scope exactly when this returns a verdict, and
|
|
@@ -42,21 +44,20 @@ const UNPROVED_ENVIRONMENT = "The device's installed environment is not verified
|
|
|
42
44
|
*/
|
|
43
45
|
function withheldScope(input) {
|
|
44
46
|
const { availability, applied } = input;
|
|
45
|
-
if (availability.state
|
|
46
|
-
return { state:
|
|
47
|
+
if (availability.state === "unprobed")
|
|
48
|
+
return { state: "unprobed", reason: availability.reason };
|
|
49
|
+
if (availability.state === "unsupported")
|
|
50
|
+
return {
|
|
51
|
+
state: "unsupported",
|
|
52
|
+
reason: availability.reason,
|
|
53
|
+
cause: availability.cause ?? RUNTIME_CAUSE,
|
|
54
|
+
};
|
|
47
55
|
if (applied === null ||
|
|
48
56
|
applied.location !== input.location ||
|
|
49
57
|
(input.projectPath === null && input.workingRoot !== applied.roots.workspace))
|
|
50
58
|
return { state: "unprobed", reason: UNPROVED_ENVIRONMENT };
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return { state: "unsupported", reason: "A local device cannot report an instance boundary" };
|
|
54
|
-
if (availability.report.restricted === null && !instanceSupported(availability.report))
|
|
55
|
-
return {
|
|
56
|
-
state: "unsupported",
|
|
57
|
-
reason: availability.report.unavailableReason ?? "This device's runtime cannot enforce its sandbox",
|
|
58
|
-
};
|
|
59
|
-
return null;
|
|
59
|
+
const verdict = runtimeReportVerdict(availability.report, input.location);
|
|
60
|
+
return verdict === null ? null : { state: "unsupported", reason: verdict, cause: RUNTIME_CAUSE };
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* The profile every kernel read is sent with: a restricted one, so the runtime enforces its single
|
|
@@ -423,10 +424,10 @@ let SandboxOperationAuthority = class SandboxOperationAuthority {
|
|
|
423
424
|
throw new ApiError("forbidden", "Unknown sandbox operation");
|
|
424
425
|
// the recorded context withholds its scope for exactly these states (B-16)
|
|
425
426
|
if (f.admissionRefusal) {
|
|
426
|
-
// a
|
|
427
|
-
//
|
|
427
|
+
// a device that cannot run scoped work is the typed pre-effect refusal: the model gets the
|
|
428
|
+
// kernel's text for its cause, never the generic "may not have completed" one
|
|
428
429
|
if (f.availability.state === "unsupported")
|
|
429
|
-
throw new
|
|
430
|
+
throw new PermissionAdmissionUnavailable(f.availability.cause ?? RUNTIME_CAUSE, f.admissionRefusal);
|
|
430
431
|
throw new ApiError("forbidden", f.admissionRefusal);
|
|
431
432
|
}
|
|
432
433
|
const operationId = randomUUID();
|
|
@@ -61,9 +61,9 @@ export function launchRefusedText(kind) {
|
|
|
61
61
|
case "denied":
|
|
62
62
|
return "the command or its output file is outside what this conversation may use on the device; choose a working directory this conversation may write to";
|
|
63
63
|
case "unsupported":
|
|
64
|
-
return "
|
|
64
|
+
return "the device refused it because it cannot enforce its sandbox limits; ask the device's owner to update capybara-device (or a super admin to update the device's sandbox plugin), or continue without the device";
|
|
65
65
|
default:
|
|
66
|
-
return "the device refused the start; check that the device is connected
|
|
66
|
+
return "the device refused the start; check that the device is connected, then retry the call";
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
export function operationResult(value) {
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SandboxPermissionSupport, SandboxPermissionUnsupportedError, type SandboxProvider } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Why a device cannot run permission-scoped work, for people and for the kernel-rendered admission
|
|
4
|
+
* text (ruling R9): an outdated sandbox provider plugin, or a runtime that cannot enforce the
|
|
5
|
+
* sandbox. The recorded `permission_context` keeps only `{ state, reason }`.
|
|
6
|
+
*/
|
|
7
|
+
export type PermissionAvailabilityCause = {
|
|
8
|
+
kind: "provider-outdated";
|
|
9
|
+
plugin: string;
|
|
10
|
+
version: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "runtime";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Admission's refusal of device work on a device that cannot run permission-scoped operations:
|
|
16
|
+
* nothing was sent. It extends {@link SandboxPermissionUnsupportedError} (and keeps its name), so
|
|
17
|
+
* every check that treats that error as a definite refusal treats this one the same way; the
|
|
18
|
+
* model's text is rendered from `cause` (`admissionUnavailableText`), never from the message,
|
|
19
|
+
* which is the availability reason (a provider may write it). Exported to tools from
|
|
20
|
+
* `tools/builtins/sandbox/common.ts`.
|
|
21
|
+
*/
|
|
22
|
+
export declare class PermissionAdmissionUnavailable extends SandboxPermissionUnsupportedError {
|
|
23
|
+
readonly cause: PermissionAvailabilityCause;
|
|
24
|
+
constructor(cause: PermissionAvailabilityCause, reason: string);
|
|
25
|
+
}
|
|
2
26
|
/** Read models never provision or probe. Runtime activation will persist provenance-bound reports. */
|
|
3
27
|
export type PermissionAvailability = {
|
|
4
28
|
state: "supported";
|
|
@@ -6,6 +30,7 @@ export type PermissionAvailability = {
|
|
|
6
30
|
} | {
|
|
7
31
|
state: "unsupported";
|
|
8
32
|
reason: string;
|
|
33
|
+
cause: PermissionAvailabilityCause;
|
|
9
34
|
} | {
|
|
10
35
|
state: "unprobed";
|
|
11
36
|
reason: string;
|
|
@@ -13,6 +38,27 @@ export type PermissionAvailability = {
|
|
|
13
38
|
export declare const unprobedPermissionAvailability: () => PermissionAvailability;
|
|
14
39
|
/** Method presence is only an unknown runtime candidate, never evidence of enforcement support.
|
|
15
40
|
* No capability probe or lifecycle operation runs here, even for an empty or suspended device.
|
|
16
|
-
* Task 6 records provenance-bound runtime reports before user execution can be admitted.
|
|
41
|
+
* Task 6 records provenance-bound runtime reports before user execution can be admitted. A
|
|
42
|
+
* provider without the permission-scoped methods is an outdated plugin, named with its version
|
|
43
|
+
* (ruling R9).
|
|
44
|
+
*/
|
|
45
|
+
export declare function permissionAvailabilityFor(provider: {
|
|
46
|
+
impl: SandboxProvider;
|
|
47
|
+
plugin: string;
|
|
48
|
+
version?: string;
|
|
49
|
+
} | undefined): PermissionAvailability;
|
|
50
|
+
/**
|
|
51
|
+
* Why a recorded runtime report cannot run permission-scoped work on a device at `location`, or
|
|
52
|
+
* null when it can: the one rule admission's withheld scope and the people's view both apply
|
|
53
|
+
* (the "one verdict" rule, B-16). A local machine's sandbox is per operation (only a cloud
|
|
54
|
+
* provider's instance is the sandbox); a runtime without a restricted mode and without an instance
|
|
55
|
+
* boundary only runs outside its sandbox.
|
|
56
|
+
*/
|
|
57
|
+
export declare function runtimeReportVerdict(report: SandboxPermissionSupport, location: "local" | "cloud"): string | null;
|
|
58
|
+
/**
|
|
59
|
+
* The availability of device work as people see it (the HTTP views): a supported report that
|
|
60
|
+
* {@link runtimeReportVerdict} refuses reads `unsupported` with the runtime cause, as admission
|
|
61
|
+
* refuses it. Kernel readers keep the raw availability (its report decides the provider layer and
|
|
62
|
+
* the kernel read route).
|
|
17
63
|
*/
|
|
18
|
-
export declare function
|
|
64
|
+
export declare function deviceWorkAvailability(availability: PermissionAvailability, location: "local" | "cloud"): PermissionAvailability;
|