@capybara-hq/kernel 0.1.0-rc.63 → 0.1.0-rc.64
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 +43 -0
- package/dist/conversations/events.js +52 -0
- 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 +29 -6
- 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 +356 -48
- 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 +4 -4
- package/src/migrations/0175_secure_input_kind.sql +8 -0
|
@@ -203,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
203
203
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
204
204
|
export declare const HOST_VERSIONS: {
|
|
205
205
|
readonly kernel: string;
|
|
206
|
-
readonly sdk: "0.1.0-rc.
|
|
206
|
+
readonly sdk: "0.1.0-rc.49";
|
|
207
207
|
};
|
|
208
208
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
209
209
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -30,7 +30,7 @@ export declare const CatalogMarketplaceRequestBody: z.ZodObject<{
|
|
|
30
30
|
/**
|
|
31
31
|
* One connector template's input at install (C30): name, slug, endpoint, credential or OAuth
|
|
32
32
|
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
33
|
-
* operation never takes them as params; the person enters them
|
|
33
|
+
* operation never takes them as params; the person enters them in a secure input request.
|
|
34
34
|
*/
|
|
35
35
|
export declare const CatalogConnectorInput: z.ZodObject<{
|
|
36
36
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -52,7 +52,7 @@ export const CatalogMarketplaceRequestBody = z
|
|
|
52
52
|
/**
|
|
53
53
|
* One connector template's input at install (C30): name, slug, endpoint, credential or OAuth
|
|
54
54
|
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
55
|
-
* operation never takes them as params; the person enters them
|
|
55
|
+
* operation never takes them as params; the person enters them in a secure input request.
|
|
56
56
|
*/
|
|
57
57
|
export const CatalogConnectorInput = z
|
|
58
58
|
.object({
|
|
@@ -35,10 +35,7 @@ export declare class ChannelCardActions {
|
|
|
35
35
|
private readonly deps;
|
|
36
36
|
constructor(deps: ChannelCardActionsDeps);
|
|
37
37
|
handle(connectionId: string, e: CardActionEvent): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
* (each the asked person's own, decided by them in person).
|
|
41
|
-
*/
|
|
42
|
-
private isOwnerDecidedAsk;
|
|
38
|
+
/** The kind of the approval `id` of the org (undefined when there is none). */
|
|
39
|
+
private kindOf;
|
|
43
40
|
}
|
|
44
41
|
export {};
|
package/dist/channels/actions.js
CHANGED
|
@@ -3,7 +3,15 @@ import { ApiError } from "../errors.js";
|
|
|
3
3
|
import { idempotencyKey } from "./jobs.js";
|
|
4
4
|
import { phrase } from "./phrases.js";
|
|
5
5
|
import { findThread, threadKeyOf } from "./threads.js";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* The approval kinds that are the asked person's own, decided by them in person: a network ask, a
|
|
8
|
+
* git push ask, a command review ask.
|
|
9
|
+
*/
|
|
10
|
+
const OWNER_DECIDED = new Set(["network", "git", "command"]);
|
|
11
|
+
/**
|
|
12
|
+
* Authorization and state failures → one sentence back to the clicker (the card stays as it is);
|
|
13
|
+
* any other error is thrown as usual.
|
|
14
|
+
*/
|
|
7
15
|
const REPLY_FOR = {
|
|
8
16
|
"approval.not_found": "cannotHandle",
|
|
9
17
|
"question.not_found": "cannotHandle",
|
|
@@ -87,6 +95,7 @@ export class ChannelCardActions {
|
|
|
87
95
|
}
|
|
88
96
|
// 匿名访客共用一个账号:只能处理自己话题里的卡片,且不能留下「本会话 / 以后都允许」的授权
|
|
89
97
|
const anonymous = who.threadAccount === null;
|
|
98
|
+
const kind = a.cardKind === "approval" ? await this.kindOf(row.orgId, a.cardId) : undefined;
|
|
90
99
|
if (anonymous) {
|
|
91
100
|
const own = await findThread(this.deps.db, {
|
|
92
101
|
connectionId,
|
|
@@ -104,11 +113,17 @@ export class ChannelCardActions {
|
|
|
104
113
|
// a network, git push or command review ask is the device owner's, decided by them in
|
|
105
114
|
// person (network ask-to-allow spec §5.2, auto mode spec §5.4): the shared guest account
|
|
106
115
|
// never decides one, whoever clicks
|
|
107
|
-
if (
|
|
116
|
+
if (kind !== undefined && OWNER_DECIDED.has(kind)) {
|
|
108
117
|
await reply("cannotHandle");
|
|
109
118
|
return;
|
|
110
119
|
}
|
|
111
120
|
}
|
|
121
|
+
// a secure input is entered and cancelled on the web only (IM gets a link, never its card), so
|
|
122
|
+
// no click decides one, whoever sends it
|
|
123
|
+
if (kind === "secure_input") {
|
|
124
|
+
await reply("cannotHandle");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
112
127
|
try {
|
|
113
128
|
if (a.cardKind === "approval" && (a.action === "approve" || a.action === "deny")) {
|
|
114
129
|
const scope = anonymous ? "once" : a.scope;
|
|
@@ -133,17 +148,14 @@ export class ChannelCardActions {
|
|
|
133
148
|
// row is the child's, which has no delivery of its own
|
|
134
149
|
await this.deps.outbound.enqueue(card.conversation_id);
|
|
135
150
|
}
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
* (each the asked person's own, decided by them in person).
|
|
139
|
-
*/
|
|
140
|
-
async isOwnerDecidedAsk(orgId, id) {
|
|
151
|
+
/** The kind of the approval `id` of the org (undefined when there is none). */
|
|
152
|
+
async kindOf(orgId, id) {
|
|
141
153
|
const r = await this.deps.db
|
|
142
154
|
.selectFrom("approvals")
|
|
143
155
|
.select("kind")
|
|
144
156
|
.where("id", "=", id)
|
|
145
157
|
.where("org_id", "=", orgId)
|
|
146
158
|
.executeTakeFirst();
|
|
147
|
-
return r?.kind
|
|
159
|
+
return r?.kind;
|
|
148
160
|
}
|
|
149
161
|
}
|
package/dist/channels/cards.d.ts
CHANGED
|
@@ -91,9 +91,10 @@ export declare function commandCardText(detail: Pick<CommandAskDetail, "kind" |
|
|
|
91
91
|
workingRoot?: string;
|
|
92
92
|
}, scopes: readonly string[], locale: ChannelLocale, redact?: (s: string) => string): NetworkCardText;
|
|
93
93
|
/**
|
|
94
|
-
* The `bind` card of an approval whose Platform call needs the person
|
|
95
|
-
* pass only through the web, never an IM vendor, so IM gets a link to
|
|
96
|
-
* an approval card. Undefined when the approval does not exist or has
|
|
94
|
+
* The `bind` card of a secure input request (or an approval whose Platform call needs the person
|
|
95
|
+
* to type secrets): the values pass only through the web, never an IM vendor, so IM gets a link to
|
|
96
|
+
* the conversation instead of an approval card. Undefined when the approval does not exist or has
|
|
97
|
+
* no person fields.
|
|
97
98
|
*/
|
|
98
99
|
export declare function personFieldsCard(d: CardDeps, approvalId: string, base: string, locale: ChannelLocale): Promise<Extract<ChannelCard, {
|
|
99
100
|
kind: "bind";
|
package/dist/channels/cards.js
CHANGED
|
@@ -296,9 +296,10 @@ export function commandCardText(detail, scopes, locale, redact = (s) => s) {
|
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
/**
|
|
299
|
-
* The `bind` card of an approval whose Platform call needs the person
|
|
300
|
-
* pass only through the web, never an IM vendor, so IM gets a link to
|
|
301
|
-
* an approval card. Undefined when the approval does not exist or has
|
|
299
|
+
* The `bind` card of a secure input request (or an approval whose Platform call needs the person
|
|
300
|
+
* to type secrets): the values pass only through the web, never an IM vendor, so IM gets a link to
|
|
301
|
+
* the conversation instead of an approval card. Undefined when the approval does not exist or has
|
|
302
|
+
* no person fields.
|
|
302
303
|
*/
|
|
303
304
|
export async function personFieldsCard(d, approvalId, base, locale) {
|
|
304
305
|
const v = await d.approvals.describe(approvalId);
|
|
@@ -321,7 +322,8 @@ export async function personFieldsCard(d, approvalId, base, locale) {
|
|
|
321
322
|
*/
|
|
322
323
|
export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
323
324
|
const v = await d.approvals.describe(approvalId);
|
|
324
|
-
|
|
325
|
+
// a secure input is web-only: never an approval card, only the bind link (personFieldsCard)
|
|
326
|
+
if (!v || v.kind === "secure_input")
|
|
325
327
|
return undefined;
|
|
326
328
|
const decidedBy = await displayName(d.db, v.decidedBy);
|
|
327
329
|
// a network, git or command ask names what it asks about instead of a tool call (same shape)
|
|
@@ -1026,8 +1026,9 @@ class Delivery {
|
|
|
1026
1026
|
await this.send({ text: phrase("handleOnWeb", this.locale) }, this.key(seq));
|
|
1027
1027
|
return this.advance(seq);
|
|
1028
1028
|
}
|
|
1029
|
-
// secrets are typed on the web only
|
|
1030
|
-
// recorded, so `approval_decided`
|
|
1029
|
+
// secrets are typed on the web only (a secure input request, or a tool ask with person
|
|
1030
|
+
// fields): IM gets a link, never an approval card (no card is recorded, so `approval_decided`
|
|
1031
|
+
// has nothing to update)
|
|
1031
1032
|
const bind = await personFieldsCard(this.d, approvalId, this.base, this.locale);
|
|
1032
1033
|
if (bind) {
|
|
1033
1034
|
await this.send(cardMessage(bind.text, bind), this.key(seq));
|
package/dist/config/schema.js
CHANGED
|
@@ -1657,7 +1657,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
1657
1657
|
.optional()
|
|
1658
1658
|
.meta(meta({
|
|
1659
1659
|
hot: true,
|
|
1660
|
-
description: "Whether a device may be granted running a call outside its sandbox (default allowed): a person, the review model or
|
|
1660
|
+
description: "Whether a device may be granted running a call outside its sandbox (default allowed): a person, the review model or Auto then approves such an escalation per call, within the organization's and the device owner's settings; off refuses every escalation, and devices only run in their sandbox. An organization may turn it off and follow the platform. Set here, it is read-only in the admin console. Replaces devices.fullAccess (CAPYBARA_DEVICES__FULL_ACCESS) and devices.autoMode, which are refused: rename them (the same values; off also needs devices.network.ceiling: allowlist to keep devices on the allowlist), or convert a config file with capybara config migrate-permissions",
|
|
1661
1661
|
})),
|
|
1662
1662
|
/**
|
|
1663
1663
|
* The platform's device sandbox network (approval-only profiles design, "Settings model"):
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PermissionProfile } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
+
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
4
|
+
/** A root conversation's effective permission profile and the revision it was read at. */
|
|
5
|
+
export interface ApprovalProfile {
|
|
6
|
+
profile: PermissionProfile;
|
|
7
|
+
revision: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the profile that decides an ask addressed to the conversation's person (profiles govern
|
|
11
|
+
* every approval, ruling R1). Only an interactive chat (`kind = 'chat'`, no scheduled task) whose
|
|
12
|
+
* owner is the person asked has one: any other root, a scheduled task's conversation or an ask
|
|
13
|
+
* addressed to another account keeps asking. The profile is the root's effective one as the
|
|
14
|
+
* permission view reads it (Auto falls back to Approve for me where a bound device's consent no
|
|
15
|
+
* longer holds; without a device Auto holds, ruling R8).
|
|
16
|
+
*/
|
|
17
|
+
export declare class ConversationApprovalProfile {
|
|
18
|
+
private readonly db;
|
|
19
|
+
private readonly facts;
|
|
20
|
+
constructor(db: KernelDb, facts: Pick<PermissionFacts, "viewWithAccess">);
|
|
21
|
+
/** The root's effective profile for an ask addressed to `requestedFor`; null: the profile does not apply (R1). */
|
|
22
|
+
resolve(input: {
|
|
23
|
+
orgId: string;
|
|
24
|
+
rootConversationId: string;
|
|
25
|
+
requestedFor: string;
|
|
26
|
+
}): Promise<ApprovalProfile | null>;
|
|
27
|
+
}
|
|
28
|
+
/** {@link ConversationApprovalProfile} on its own (the tools module reads it; no module cycle). */
|
|
29
|
+
export declare class ConversationApprovalProfileModule {
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { KernelDb } from "../infra/database/kernel-db.js";
|
|
12
|
+
import { PermissionFacts } from "../sandbox/permission-facts.js";
|
|
13
|
+
import { PermissionFactsModule } from "../sandbox/permission-facts.module.js";
|
|
14
|
+
/**
|
|
15
|
+
* Resolves the profile that decides an ask addressed to the conversation's person (profiles govern
|
|
16
|
+
* every approval, ruling R1). Only an interactive chat (`kind = 'chat'`, no scheduled task) whose
|
|
17
|
+
* owner is the person asked has one: any other root, a scheduled task's conversation or an ask
|
|
18
|
+
* addressed to another account keeps asking. The profile is the root's effective one as the
|
|
19
|
+
* permission view reads it (Auto falls back to Approve for me where a bound device's consent no
|
|
20
|
+
* longer holds; without a device Auto holds, ruling R8).
|
|
21
|
+
*/
|
|
22
|
+
let ConversationApprovalProfile = class ConversationApprovalProfile {
|
|
23
|
+
db;
|
|
24
|
+
facts;
|
|
25
|
+
constructor(db, facts) {
|
|
26
|
+
this.db = db;
|
|
27
|
+
this.facts = facts;
|
|
28
|
+
}
|
|
29
|
+
/** The root's effective profile for an ask addressed to `requestedFor`; null: the profile does not apply (R1). */
|
|
30
|
+
async resolve(input) {
|
|
31
|
+
const row = await this.db.db
|
|
32
|
+
.selectFrom("conversations")
|
|
33
|
+
.selectAll()
|
|
34
|
+
.where("id", "=", input.rootConversationId)
|
|
35
|
+
.where("org_id", "=", input.orgId)
|
|
36
|
+
.executeTakeFirst();
|
|
37
|
+
if (row === undefined ||
|
|
38
|
+
row.kind !== "chat" ||
|
|
39
|
+
row.scheduled_task_id !== null ||
|
|
40
|
+
row.account_id !== input.requestedFor)
|
|
41
|
+
return null;
|
|
42
|
+
const { view } = await this.facts.viewWithAccess(input.orgId, row.account_id, row);
|
|
43
|
+
return { profile: view.profile, revision: view.revision };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
ConversationApprovalProfile = __decorate([
|
|
47
|
+
Injectable(),
|
|
48
|
+
__param(0, Inject(KernelDb)),
|
|
49
|
+
__param(1, Inject(PermissionFacts))
|
|
50
|
+
], ConversationApprovalProfile);
|
|
51
|
+
export { ConversationApprovalProfile };
|
|
52
|
+
/** {@link ConversationApprovalProfile} on its own (the tools module reads it; no module cycle). */
|
|
53
|
+
let ConversationApprovalProfileModule = class ConversationApprovalProfileModule {
|
|
54
|
+
};
|
|
55
|
+
ConversationApprovalProfileModule = __decorate([
|
|
56
|
+
Module({
|
|
57
|
+
imports: [PermissionFactsModule],
|
|
58
|
+
providers: [ConversationApprovalProfile],
|
|
59
|
+
exports: [ConversationApprovalProfile],
|
|
60
|
+
})
|
|
61
|
+
], ConversationApprovalProfileModule);
|
|
62
|
+
export { ConversationApprovalProfileModule };
|
|
@@ -260,8 +260,6 @@ let ConversationsService = class ConversationsService {
|
|
|
260
260
|
* retry answers with the conversation the first send created, its binding unchanged.
|
|
261
261
|
*/
|
|
262
262
|
async createWithMessage(orgId, accountId, agentId, input, pick = {}, internal) {
|
|
263
|
-
if (internal.initialPermission?.profile === "full-access" && !pick.deviceId)
|
|
264
|
-
throw new ApiError("conflict", "Full access requires an explicit device selection");
|
|
265
263
|
const requestHash = internal.initialPermission
|
|
266
264
|
? permissionScopeHash({ agentId, input, pick, permission: internal.initialPermission })
|
|
267
265
|
: undefined;
|
|
@@ -503,6 +503,10 @@ export type LogContentBlock = Exclude<ContentBlock, MediaBlock> | (MediaBlock ex
|
|
|
503
503
|
} : never : never);
|
|
504
504
|
/** The longest handoff card title (`ToolViewSchema` kind `handoff`), per language. */
|
|
505
505
|
export declare const HANDOFF_TITLE_MAX_CHARS = 200;
|
|
506
|
+
/** The longest secure input target name (`approval_requested.secureInput.target`), per language. */
|
|
507
|
+
export declare const SECURE_INPUT_TARGET_MAX_CHARS = 200;
|
|
508
|
+
/** The most field paths one secure input request lists (as `approval_decided.inputsProvided`). */
|
|
509
|
+
export declare const SECURE_INPUT_MAX_FIELDS = 32;
|
|
506
510
|
/** The longest handoff link (a relative web path). */
|
|
507
511
|
export declare const HANDOFF_URL_MAX_CHARS = 2000;
|
|
508
512
|
/**
|
|
@@ -569,6 +573,12 @@ export declare const ToolViewSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
569
573
|
}>;
|
|
570
574
|
}, z.core.$strip>, z.ZodObject<{
|
|
571
575
|
kind: z.ZodLiteral<"not_loaded">;
|
|
576
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
577
|
+
kind: z.ZodLiteral<"reveal">;
|
|
578
|
+
reveal: z.ZodEnum<{
|
|
579
|
+
initial_password: "initial_password";
|
|
580
|
+
invitation_link: "invitation_link";
|
|
581
|
+
}>;
|
|
572
582
|
}, z.core.$strip>, z.ZodObject<{
|
|
573
583
|
kind: z.ZodLiteral<"handoff">;
|
|
574
584
|
title: z.ZodObject<{
|
|
@@ -760,6 +770,26 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
760
770
|
perCallHosts: z.ZodOptional<z.ZodBoolean>;
|
|
761
771
|
}, z.core.$strict>>;
|
|
762
772
|
}, z.core.$strict>;
|
|
773
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
774
|
+
type: z.ZodLiteral<"tool_ask_decided">;
|
|
775
|
+
payload: z.ZodObject<{
|
|
776
|
+
step: z.ZodNumber;
|
|
777
|
+
callId: z.ZodString;
|
|
778
|
+
toolKey: z.ZodString;
|
|
779
|
+
specHash: z.ZodString;
|
|
780
|
+
bindingHash: z.ZodString;
|
|
781
|
+
outcome: z.ZodEnum<{
|
|
782
|
+
allow: "allow";
|
|
783
|
+
deny: "deny";
|
|
784
|
+
}>;
|
|
785
|
+
decisionSource: z.ZodEnum<{
|
|
786
|
+
"full-access": "full-access";
|
|
787
|
+
"review-model": "review-model";
|
|
788
|
+
}>;
|
|
789
|
+
reason: z.ZodString;
|
|
790
|
+
profileRevision: z.ZodNumber;
|
|
791
|
+
fileSha256: z.ZodOptional<z.ZodString>;
|
|
792
|
+
}, z.core.$strip>;
|
|
763
793
|
}, z.core.$strip>, z.ZodObject<{
|
|
764
794
|
type: z.ZodLiteral<"permission_reviewed">;
|
|
765
795
|
payload: z.ZodObject<{
|
|
@@ -1445,6 +1475,12 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1445
1475
|
}>;
|
|
1446
1476
|
}, z.core.$strip>, z.ZodObject<{
|
|
1447
1477
|
kind: z.ZodLiteral<"not_loaded">;
|
|
1478
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1479
|
+
kind: z.ZodLiteral<"reveal">;
|
|
1480
|
+
reveal: z.ZodEnum<{
|
|
1481
|
+
initial_password: "initial_password";
|
|
1482
|
+
invitation_link: "invitation_link";
|
|
1483
|
+
}>;
|
|
1448
1484
|
}, z.core.$strip>, z.ZodObject<{
|
|
1449
1485
|
kind: z.ZodLiteral<"handoff">;
|
|
1450
1486
|
title: z.ZodObject<{
|
|
@@ -1543,6 +1579,13 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1543
1579
|
sandbox: "sandbox";
|
|
1544
1580
|
}>;
|
|
1545
1581
|
}, z.core.$strict>>;
|
|
1582
|
+
secureInput: z.ZodOptional<z.ZodObject<{
|
|
1583
|
+
target: z.ZodObject<{
|
|
1584
|
+
zh: z.ZodString;
|
|
1585
|
+
en: z.ZodString;
|
|
1586
|
+
}, z.core.$strip>;
|
|
1587
|
+
fields: z.ZodArray<z.ZodString>;
|
|
1588
|
+
}, z.core.$strip>>;
|
|
1546
1589
|
}, z.core.$strip>;
|
|
1547
1590
|
}, z.core.$strip>, z.ZodObject<{
|
|
1548
1591
|
type: z.ZodLiteral<"approval_decided">;
|
|
@@ -518,6 +518,10 @@ const FileStateViewSchema = z.object({
|
|
|
518
518
|
});
|
|
519
519
|
/** The longest handoff card title (`ToolViewSchema` kind `handoff`), per language. */
|
|
520
520
|
export const HANDOFF_TITLE_MAX_CHARS = 200;
|
|
521
|
+
/** The longest secure input target name (`approval_requested.secureInput.target`), per language. */
|
|
522
|
+
export const SECURE_INPUT_TARGET_MAX_CHARS = 200;
|
|
523
|
+
/** The most field paths one secure input request lists (as `approval_decided.inputsProvided`). */
|
|
524
|
+
export const SECURE_INPUT_MAX_FIELDS = 32;
|
|
521
525
|
/** The longest handoff link (a relative web path). */
|
|
522
526
|
export const HANDOFF_URL_MAX_CHARS = 2000;
|
|
523
527
|
/** A relative web path: one leading `/`, never `//` (another host) or a backslash. */
|
|
@@ -579,6 +583,15 @@ export const ToolViewSchema = z.discriminatedUnion("kind", [
|
|
|
579
583
|
reason: z.enum(["not_read", "modified"]),
|
|
580
584
|
}),
|
|
581
585
|
z.object({ kind: z.literal("not_loaded") }),
|
|
586
|
+
/**
|
|
587
|
+
* A `Platform` operation whose result is shown to the run's person once, read by call (the
|
|
588
|
+
* initial password, the invitation link; profiles govern every approval, ruling R6): the web
|
|
589
|
+
* draws the reveal under the tool row. Display only.
|
|
590
|
+
*/
|
|
591
|
+
z.object({
|
|
592
|
+
kind: z.literal("reveal"),
|
|
593
|
+
reveal: z.enum(["initial_password", "invitation_link"]),
|
|
594
|
+
}),
|
|
582
595
|
z.object({
|
|
583
596
|
kind: z.literal("handoff"),
|
|
584
597
|
title: z.object({
|
|
@@ -711,6 +724,31 @@ export const PluginContextSchema = z.object({
|
|
|
711
724
|
*/
|
|
712
725
|
export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
713
726
|
ev("permission_context", PermissionContextV2Schema),
|
|
727
|
+
/**
|
|
728
|
+
* An ask addressed to the conversation's person that the profile decided without asking (Auto,
|
|
729
|
+
* or the review model under Approve for me; profiles govern every approval, ruling R2). Only
|
|
730
|
+
* `allow` and `deny` are recorded; an unsure review creates the person's approval instead.
|
|
731
|
+
* Idempotency key `tool_ask_decided:<runId>:<callId>:<bindingHash>`. Not model-visible: display
|
|
732
|
+
* and audit only, so it needs no `DriftReason`.
|
|
733
|
+
*/
|
|
734
|
+
ev("tool_ask_decided", z.object({
|
|
735
|
+
step: count,
|
|
736
|
+
callId: z.string(),
|
|
737
|
+
/** The call's policy key. */
|
|
738
|
+
toolKey: z.string(),
|
|
739
|
+
specHash: z.string(),
|
|
740
|
+
/** First 16 hex chars of `sha256(canonicalJson([policyKey, specHash, call.input]))`. */
|
|
741
|
+
bindingHash: z.string(),
|
|
742
|
+
outcome: z.enum(["allow", "deny"]),
|
|
743
|
+
decisionSource: z.enum(["review-model", "full-access"]),
|
|
744
|
+
reason: z.string().max(2000),
|
|
745
|
+
profileRevision: z.number().int().nonnegative(),
|
|
746
|
+
/** The file bytes the decision was bound to (ruling R7), when the call references a file. */
|
|
747
|
+
fileSha256: z
|
|
748
|
+
.string()
|
|
749
|
+
.regex(/^[a-f0-9]{64}$/)
|
|
750
|
+
.optional(),
|
|
751
|
+
})),
|
|
714
752
|
ev("permission_reviewed", z.object({
|
|
715
753
|
binding: PermissionCallBindingSchema,
|
|
716
754
|
permissionScope: PermissionExpansionSchema,
|
|
@@ -1284,6 +1322,20 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
1284
1322
|
* model-visible, as `network` and `git`; the model sees the call's `tool_result` only.
|
|
1285
1323
|
*/
|
|
1286
1324
|
command: CommandAskSchema.optional(),
|
|
1325
|
+
/**
|
|
1326
|
+
* A secure input request (`kind = 'secure_input'`; profiles govern every approval): what the
|
|
1327
|
+
* values are for and the field paths the person enters. Display only, never a value and
|
|
1328
|
+
* never model-visible.
|
|
1329
|
+
*/
|
|
1330
|
+
secureInput: z
|
|
1331
|
+
.object({
|
|
1332
|
+
target: z.object({
|
|
1333
|
+
zh: z.string().min(1).max(SECURE_INPUT_TARGET_MAX_CHARS),
|
|
1334
|
+
en: z.string().min(1).max(SECURE_INPUT_TARGET_MAX_CHARS),
|
|
1335
|
+
}),
|
|
1336
|
+
fields: z.array(z.string().min(1).max(200)).min(1).max(SECURE_INPUT_MAX_FIELDS),
|
|
1337
|
+
})
|
|
1338
|
+
.optional(),
|
|
1287
1339
|
...ApproverFields,
|
|
1288
1340
|
})),
|
|
1289
1341
|
/**
|
|
@@ -51,6 +51,7 @@ export declare class PermissionProfilesController {
|
|
|
51
51
|
private readonly conversations;
|
|
52
52
|
constructor(permissions: PermissionProfilesService, conversations: ConversationsService);
|
|
53
53
|
get(org: OrgContext, p: Principal, { id }: z.infer<typeof PermissionGetParams>): Promise<{
|
|
54
|
+
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
54
55
|
profile: import("@capybara-hq/plugin-sdk").PermissionProfile;
|
|
55
56
|
revision: number;
|
|
56
57
|
rootConversationId: string;
|
|
@@ -60,7 +61,6 @@ export declare class PermissionProfilesController {
|
|
|
60
61
|
scopeRevision: string;
|
|
61
62
|
} | null;
|
|
62
63
|
scopeRevision: string | null;
|
|
63
|
-
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
64
64
|
outsideSandboxCeiling: boolean;
|
|
65
65
|
broadProjectReach: boolean;
|
|
66
66
|
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
|
|
@@ -81,10 +81,11 @@ export declare class PermissionProfilesController {
|
|
|
81
81
|
restrictedProjectReach: "os-user" | "workspace";
|
|
82
82
|
hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
|
|
83
83
|
};
|
|
84
|
-
|
|
84
|
+
location: "cloud" | "local";
|
|
85
85
|
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
|
|
86
86
|
outsideSandboxCeiling: boolean;
|
|
87
87
|
broadProjectReach: boolean;
|
|
88
|
+
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
88
89
|
}>;
|
|
89
90
|
first(org: OrgContext, p: Principal, body: z.infer<typeof FirstMessageBody>, reply: FastifyReply): Promise<{
|
|
90
91
|
conversation: import("./conversations.service.js").ConversationView;
|
|
@@ -32,12 +32,14 @@ export declare class PermissionProfilesService {
|
|
|
32
32
|
restrictedProjectReach: "os-user" | "workspace";
|
|
33
33
|
hostCeiling: import("../sandbox/device-sandbox.js").HostGrantCeiling;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
location: "cloud" | "local";
|
|
36
36
|
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox;
|
|
37
37
|
outsideSandboxCeiling: boolean;
|
|
38
38
|
broadProjectReach: boolean;
|
|
39
|
+
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
39
40
|
}>;
|
|
40
41
|
get(orgId: string, id: string, accountId: string): Promise<{
|
|
42
|
+
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
41
43
|
profile: import("@capybara-hq/plugin-sdk").PermissionProfile;
|
|
42
44
|
revision: number;
|
|
43
45
|
rootConversationId: string;
|
|
@@ -47,7 +49,6 @@ export declare class PermissionProfilesService {
|
|
|
47
49
|
scopeRevision: string;
|
|
48
50
|
} | null;
|
|
49
51
|
scopeRevision: string | null;
|
|
50
|
-
availability: import("../sandbox/permission-availability.js").PermissionAvailability;
|
|
51
52
|
outsideSandboxCeiling: boolean;
|
|
52
53
|
broadProjectReach: boolean;
|
|
53
54
|
sandbox: import("../sandbox/device-sandbox.js").DeviceSandbox | null;
|
|
@@ -45,7 +45,7 @@ let PermissionProfilesService = class PermissionProfilesService {
|
|
|
45
45
|
return this.facts.preview(orgId, accountId, deviceId, project);
|
|
46
46
|
}
|
|
47
47
|
async get(orgId, id, accountId) {
|
|
48
|
-
return this.facts.
|
|
48
|
+
return this.facts.peopleView(orgId, accountId, await this.store.readOwnedRoot(orgId, id, accountId));
|
|
49
49
|
}
|
|
50
50
|
/** Reserve the root ID and authority before resolving its project or inserting first-send state. */
|
|
51
51
|
async lockInitial(orgId, id, deviceId) {
|
|
@@ -88,14 +88,18 @@ let PermissionProfilesService = class PermissionProfilesService {
|
|
|
88
88
|
await this.devices.usable(orgId, accountId, deviceId);
|
|
89
89
|
if (selection.profile !== "full-access")
|
|
90
90
|
return null;
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
// Auto without a device has no scope to consent to: accepted with no consent row (R8); a
|
|
92
|
+
// device bound later needs a confirmation of Auto for that device (`consentHolds`)
|
|
93
|
+
if (!deviceId)
|
|
94
|
+
return null;
|
|
95
|
+
if (!selection.consentScopeRevision)
|
|
96
|
+
throw new ApiError("conflict", "Auto on a device requires its displayed scope consent");
|
|
93
97
|
const preview = await this.facts.scope(orgId, deviceId, projectPath, project);
|
|
94
|
-
//
|
|
95
|
-
// the device and the crossing ceilings it
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
throw new ApiError("conflict", "Device authority changed; refresh the permission preview and confirm
|
|
98
|
+
// Auto is available on every device, whatever it supports (device tools refuse at admission):
|
|
99
|
+
// the sandbox stays, and the consent binds the device and the crossing ceilings it
|
|
100
|
+
// auto-approves within (`scopeRevision`)
|
|
101
|
+
if (preview.scopeRevision !== selection.consentScopeRevision)
|
|
102
|
+
throw new ApiError("conflict", "Device authority changed; refresh the permission preview and confirm Auto again");
|
|
99
103
|
// what the consent covers: a later narrowing keeps it, a widening needs a new one
|
|
100
104
|
return {
|
|
101
105
|
deviceId,
|
|
@@ -737,9 +737,11 @@ export interface ApprovalsTable {
|
|
|
737
737
|
scopes: ColumnType<("once" | "session" | "always")[] | null, ("once" | "session" | "always")[] | null | undefined, ("once" | "session" | "always")[] | null>;
|
|
738
738
|
/**
|
|
739
739
|
* 0114: what is asked: a tool call ('tool') or a refused network domain ('network'); 0126: a
|
|
740
|
-
* git push the gateway held ('git'); 0130: a command review ask ('command')
|
|
740
|
+
* git push the gateway held ('git'); 0130: a command review ask ('command'); a secure input
|
|
741
|
+
* request for a call's secret fields ('secure_input'; profiles govern every approval, R4; the
|
|
742
|
+
* migration widening the CHECK comes with the approvals service change).
|
|
741
743
|
*/
|
|
742
|
-
kind: Generated<"tool" | "network" | "git" | "command">;
|
|
744
|
+
kind: Generated<"tool" | "network" | "git" | "command" | "secure_input">;
|
|
743
745
|
/** 0114: a network or git ask's facts, kept result and outcome; 0130: a command ask's facts. */
|
|
744
746
|
detail: ColumnType<unknown | null, string | null | undefined, string | null>;
|
|
745
747
|
}
|
|
@@ -2,21 +2,23 @@ import { z } from "zod";
|
|
|
2
2
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
3
3
|
import { InitialPasswords } from "./initial-passwords.js";
|
|
4
4
|
import { type Principal } from "./principal.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** The tool call a once-shown value was made by. */
|
|
6
|
+
export declare const RevealCallParams: z.ZodObject<{
|
|
7
|
+
conversationId: z.ZodString;
|
|
8
|
+
runId: z.ZodString;
|
|
9
|
+
callId: z.ZodString;
|
|
7
10
|
}, z.core.$strip>;
|
|
8
11
|
/**
|
|
9
12
|
* The generated initial password of an account the super admin's agent created (Platform tool
|
|
10
|
-
* spec §14.5 item 2): shown once, on the web, to the person
|
|
11
|
-
* call. A POST because reading consumes it.
|
|
13
|
+
* spec §14.5 item 2): shown once, on the web, to the person the `accounts.create` call was made
|
|
14
|
+
* for, keyed by the call (plan ruling R6). A POST because reading consumes it.
|
|
12
15
|
*/
|
|
13
16
|
export declare class InitialPasswordsController {
|
|
14
17
|
private readonly passwords;
|
|
15
18
|
constructor(passwords: InitialPasswords);
|
|
16
|
-
reveal(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
19
|
+
reveal(principal: Principal, org: OrgContext, params: z.infer<typeof RevealCallParams>): Promise<{
|
|
17
20
|
accountId: string;
|
|
18
21
|
login: string | null;
|
|
19
22
|
password: string;
|
|
20
23
|
}>;
|
|
21
24
|
}
|
|
22
|
-
export {};
|
|
@@ -14,13 +14,18 @@ import { ZParam } from "../infra/validation/zod-params.js";
|
|
|
14
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
15
15
|
import { InitialPasswords } from "./initial-passwords.js";
|
|
16
16
|
import { CurrentPrincipal, requireUser, SessionOnly, SuperAdmin, } from "./principal.js";
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** The tool call a once-shown value was made by. */
|
|
18
|
+
export const RevealCallParams = z.object({
|
|
19
|
+
conversationId: z.string().min(1).max(100),
|
|
20
|
+
runId: z.string().min(1).max(100),
|
|
21
|
+
callId: z.string().min(1).max(200),
|
|
22
|
+
});
|
|
23
|
+
class RevealCallParamsDto extends createZodDto(RevealCallParams, "InitialPasswordParams") {
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* The generated initial password of an account the super admin's agent created (Platform tool
|
|
22
|
-
* spec §14.5 item 2): shown once, on the web, to the person
|
|
23
|
-
* call. A POST because reading consumes it.
|
|
27
|
+
* spec §14.5 item 2): shown once, on the web, to the person the `accounts.create` call was made
|
|
28
|
+
* for, keyed by the call (plan ruling R6). A POST because reading consumes it.
|
|
24
29
|
*/
|
|
25
30
|
let InitialPasswordsController = class InitialPasswordsController {
|
|
26
31
|
passwords;
|
|
@@ -29,7 +34,8 @@ let InitialPasswordsController = class InitialPasswordsController {
|
|
|
29
34
|
}
|
|
30
35
|
async reveal(principal, org, params) {
|
|
31
36
|
const p = requireUser(principal);
|
|
32
|
-
|
|
37
|
+
const { conversationId, runId, callId } = params;
|
|
38
|
+
return this.passwords.reveal(org.orgId, { conversationId, runId, callId }, p.account.id);
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
__decorate([
|
|
@@ -40,10 +46,10 @@ __decorate([
|
|
|
40
46
|
SessionOnly(),
|
|
41
47
|
__param(0, CurrentPrincipal()),
|
|
42
48
|
__param(1, CurrentOrg()),
|
|
43
|
-
__param(2, ZParam(
|
|
49
|
+
__param(2, ZParam(RevealCallParamsDto))
|
|
44
50
|
], InitialPasswordsController.prototype, "reveal", null);
|
|
45
51
|
InitialPasswordsController = __decorate([
|
|
46
|
-
Controller("api/v1/orgs/:orgId/
|
|
52
|
+
Controller("api/v1/orgs/:orgId/conversations/:conversationId/runs/:runId/calls/:callId/initial-password"),
|
|
47
53
|
__param(0, Inject(InitialPasswords))
|
|
48
54
|
], InitialPasswordsController);
|
|
49
55
|
export { InitialPasswordsController };
|