@capybara-hq/kernel 0.1.0-rc.58 → 0.1.0-rc.59
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.controller.d.ts +0 -5
- package/dist/catalog/org-catalog.controller.js +3 -17
- package/dist/catalog/org-catalog.schemas.d.ts +43 -0
- package/dist/catalog/org-catalog.schemas.js +43 -2
- package/dist/catalog/plugin-install.d.ts +2 -0
- package/dist/catalog/plugin-install.js +3 -3
- package/dist/channels/channels.schemas.d.ts +3 -0
- package/dist/channels/channels.schemas.js +8 -0
- package/dist/channels/connections.service.d.ts +17 -2
- package/dist/channels/connections.service.js +30 -5
- package/dist/channels/outbound.js +17 -0
- package/dist/conversations/events.d.ts +34 -0
- package/dist/conversations/events.js +24 -0
- package/dist/ctx/secrets.d.ts +8 -1
- package/dist/ctx/secrets.js +14 -1
- package/dist/db/kernel-schema.d.ts +19 -0
- package/dist/devices/working-root.d.ts +2 -3
- package/dist/errors.d.ts +10 -0
- package/dist/errors.js +10 -0
- package/dist/http/api.module.js +6 -0
- package/dist/identity/initial-passwords.job.d.ts +3 -3
- package/dist/identity/initial-passwords.job.js +7 -5
- package/dist/orgs/invitations.controller.d.ts +3 -11
- package/dist/orgs/invitations.controller.js +9 -10
- package/dist/orgs/invitations.service.d.ts +12 -2
- package/dist/orgs/invitations.service.js +14 -7
- package/dist/orgs/members.service.d.ts +12 -2
- package/dist/orgs/members.service.js +10 -8
- package/dist/orgs/orgs.controller.d.ts +4 -12
- package/dist/orgs/orgs.controller.js +10 -10
- package/dist/orgs/orgs.schemas.d.ts +26 -0
- package/dist/orgs/orgs.schemas.js +22 -0
- package/dist/platform/connector-person-fields.d.ts +67 -0
- package/dist/platform/connector-person-fields.js +129 -0
- package/dist/platform/exclusions.js +5 -100
- package/dist/platform/operation.d.ts +31 -0
- package/dist/platform/operation.js +3 -3
- package/dist/platform/ops/accounts.ops.js +1 -0
- package/dist/platform/ops/channels.ops.d.ts +10 -3
- package/dist/platform/ops/channels.ops.js +223 -5
- package/dist/platform/ops/connectors.ops.d.ts +22 -4
- package/dist/platform/ops/connectors.ops.js +664 -13
- package/dist/platform/ops/org-plugins.ops.d.ts +15 -2
- package/dist/platform/ops/org-plugins.ops.js +323 -4
- package/dist/platform/ops/orgs.ops.d.ts +40 -3
- package/dist/platform/ops/orgs.ops.js +293 -12
- package/dist/platform/ops/person-inputs.d.ts +30 -0
- package/dist/platform/ops/person-inputs.js +50 -0
- package/dist/platform/ops/plugins.ops.d.ts +1 -1
- package/dist/platform/ops/plugins.ops.js +6 -6
- package/dist/platform/parity.d.ts +3 -2
- package/dist/platform/parity.js +40 -15
- package/dist/platform/person-fields.d.ts +20 -4
- package/dist/platform/person-fields.js +27 -5
- package/dist/platform/platform.module.d.ts +2 -1
- package/dist/platform/platform.module.js +5 -3
- package/dist/platform/route-schemas.js +2 -0
- package/dist/platform/sealed-reveals.controller.d.ts +20 -0
- package/dist/platform/sealed-reveals.controller.js +48 -0
- package/dist/platform/sealed-reveals.d.ts +52 -0
- package/dist/platform/sealed-reveals.js +153 -0
- package/dist/runtime/project/knowledge.js +24 -19
- package/dist/sandbox/permission-facts.d.ts +5 -1
- package/dist/sandbox/permission-facts.js +8 -2
- package/dist/setup/setup-guides.service.d.ts +5 -0
- package/dist/setup/setup-guides.service.js +2 -1
- package/dist/tools/approvals.service.js +1 -1
- package/dist/tools/builtins/platform.js +48 -8
- package/dist/tools/connectors.controller.d.ts +6 -7
- package/dist/tools/connectors.controller.js +4 -44
- package/dist/tools/connectors.schemas.d.ts +170 -1
- package/dist/tools/connectors.schemas.js +82 -3
- package/dist/tools/connectors.service.d.ts +16 -6
- package/dist/tools/connectors.service.js +39 -24
- package/dist/tools/oauth/oauth.controller.d.ts +3 -6
- package/dist/tools/oauth/oauth.controller.js +3 -12
- package/dist/tools/oauth/oauth.schemas.d.ts +14 -0
- package/dist/tools/oauth/oauth.schemas.js +27 -0
- package/dist/tools/pipeline.d.ts +7 -0
- package/dist/tools/pipeline.js +13 -4
- package/dist/tools/policy.d.ts +3 -2
- package/dist/tools/policy.js +4 -2
- package/dist/tools/registry.d.ts +7 -0
- package/package.json +4 -4
- package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
|
@@ -8,23 +8,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Get, HttpCode, Inject, Param, Post, Query, Req, Res } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { CurrentPrincipal, Public, requireUser } from "../../identity/principal.js";
|
|
13
12
|
import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
14
13
|
import { createZodDto } from "../../infra/validation/create-zod-dto.js";
|
|
15
14
|
import { ZBody } from "../../infra/validation/zod-params.js";
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../../orgs/org.guard.js";
|
|
17
|
-
import { browserBinding,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
returnTo: z
|
|
21
|
-
.string()
|
|
22
|
-
.max(500)
|
|
23
|
-
.refine(isSafeReturnPath, { message: "returnTo must be a relative path on this site" })
|
|
24
|
-
.optional(),
|
|
25
|
-
})
|
|
26
|
-
.strict();
|
|
27
|
-
class OAuthConnectBody extends createZodDto(ConnectBody, "OAuthConnectBody") {
|
|
16
|
+
import { browserBinding, OAUTH_BINDING_COOKIE, OAUTH_CALLBACK_PATH, OAUTH_STATE_TTL_SECONDS, OAuthFlow, } from "./flow.js";
|
|
17
|
+
import { OAuthConnectBodySchema } from "./oauth.schemas.js";
|
|
18
|
+
class OAuthConnectBody extends createZodDto(OAuthConnectBodySchema, "OAuthConnectBody") {
|
|
28
19
|
}
|
|
29
20
|
/** 查询参数只取单值字符串(重复参数 / 数组按缺失处理)。 */
|
|
30
21
|
const one = (v) => typeof v === "string" && v.length <= 4096 ? v : undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../../platform/route-schemas.js";
|
|
3
|
+
/**
|
|
4
|
+
* `POST …/connectors/:connectorId/connect`: where the browser returns after the authorization (a
|
|
5
|
+
* relative path on this site; default the connections page).
|
|
6
|
+
*/
|
|
7
|
+
export declare const OAuthConnectBodySchema: z.ZodObject<{
|
|
8
|
+
returnTo: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
/**
|
|
11
|
+
* The connect route's schemas for the Platform parity check (`connectors.connect` mirrors it; the
|
|
12
|
+
* OAuth callback stays an exclusion).
|
|
13
|
+
*/
|
|
14
|
+
export declare const OAUTH_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ConnectorPathParams } from "../connectors.schemas.js";
|
|
3
|
+
import { isSafeReturnPath } from "./flow-paths.js";
|
|
4
|
+
/**
|
|
5
|
+
* `POST …/connectors/:connectorId/connect`: where the browser returns after the authorization (a
|
|
6
|
+
* relative path on this site; default the connections page).
|
|
7
|
+
*/
|
|
8
|
+
export const OAuthConnectBodySchema = z
|
|
9
|
+
.object({
|
|
10
|
+
returnTo: z
|
|
11
|
+
.string()
|
|
12
|
+
.max(500)
|
|
13
|
+
.refine(isSafeReturnPath, { message: "returnTo must be a relative path on this site" })
|
|
14
|
+
.optional(),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
/**
|
|
18
|
+
* The connect route's schemas for the Platform parity check (`connectors.connect` mirrors it; the
|
|
19
|
+
* OAuth callback stays an exclusion).
|
|
20
|
+
*/
|
|
21
|
+
export const OAUTH_ROUTES = [
|
|
22
|
+
{
|
|
23
|
+
route: "POST /api/v1/orgs/:orgId/connectors/:connectorId/connect",
|
|
24
|
+
params: ConnectorPathParams,
|
|
25
|
+
body: OAuthConnectBodySchema,
|
|
26
|
+
},
|
|
27
|
+
];
|
package/dist/tools/pipeline.d.ts
CHANGED
|
@@ -95,6 +95,13 @@ export declare const PERSON_FIELDS_UNATTENDED_TEXT = "This write needs the perso
|
|
|
95
95
|
* person the run works for may type the values, and they lack the role.
|
|
96
96
|
*/
|
|
97
97
|
export declare const PERSON_FIELDS_ROLE_TEXT = "This write needs the person you work for to enter values; they lack the role. Ask an admin to do it on the web.";
|
|
98
|
+
/**
|
|
99
|
+
* A call only the person may confirm (`CallPolicy.personOnly`: its result is shown once to the
|
|
100
|
+
* approver) in an unattended run: nobody is there to approve and read it.
|
|
101
|
+
*/
|
|
102
|
+
export declare const PERSON_ONLY_UNATTENDED_TEXT = "This write shows its result once, on the web, to the person who approves it; it cannot run unattended.";
|
|
103
|
+
/** A call only the person may confirm whose ask would go to a role instead of the person. */
|
|
104
|
+
export declare const PERSON_ONLY_ROLE_TEXT = "This write shows its result once to the person you work for, who must approve it; they lack the role. Ask an admin to do it on the web.";
|
|
98
105
|
/** 调用执行中 run 被中止 / 到达截止时间。 */
|
|
99
106
|
export declare const RUN_STOPPED_DURING_TEXT = "The run was stopped while this tool call was running; its outcome is unknown. Verify before retrying.";
|
|
100
107
|
/**
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -147,6 +147,13 @@ export const PERSON_FIELDS_UNATTENDED_TEXT = "This write needs the person to ent
|
|
|
147
147
|
* person the run works for may type the values, and they lack the role.
|
|
148
148
|
*/
|
|
149
149
|
export const PERSON_FIELDS_ROLE_TEXT = "This write needs the person you work for to enter values; they lack the role. Ask an admin to do it on the web.";
|
|
150
|
+
/**
|
|
151
|
+
* A call only the person may confirm (`CallPolicy.personOnly`: its result is shown once to the
|
|
152
|
+
* approver) in an unattended run: nobody is there to approve and read it.
|
|
153
|
+
*/
|
|
154
|
+
export const PERSON_ONLY_UNATTENDED_TEXT = "This write shows its result once, on the web, to the person who approves it; it cannot run unattended.";
|
|
155
|
+
/** A call only the person may confirm whose ask would go to a role instead of the person. */
|
|
156
|
+
export const PERSON_ONLY_ROLE_TEXT = "This write shows its result once to the person you work for, who must approve it; they lack the role. Ask an admin to do it on the web.";
|
|
150
157
|
/** 调用执行中 run 被中止 / 到达截止时间。 */
|
|
151
158
|
export const RUN_STOPPED_DURING_TEXT = "The run was stopped while this tool call was running; its outcome is unknown. Verify before retrying.";
|
|
152
159
|
/** The fixed result of a call whose input request was skipped by a message (spec §7.1). */
|
|
@@ -738,8 +745,10 @@ let ToolPipeline = class ToolPipeline {
|
|
|
738
745
|
// person fields (platform web parity spec §4.2, R6): the person types values on the card, so an
|
|
739
746
|
// unattended run (a trial run has its creator there) cannot make the call at all
|
|
740
747
|
const personFields = callPolicy?.personFields;
|
|
741
|
-
|
|
742
|
-
|
|
748
|
+
// a call whose result is shown once to its approver asks the person the same way
|
|
749
|
+
const personOnly = personFields !== undefined || callPolicy?.personOnly === true;
|
|
750
|
+
if (personOnly && unattendedRules(ctx.unattended)) {
|
|
751
|
+
return fail(personFields !== undefined ? PERSON_FIELDS_UNATTENDED_TEXT : PERSON_ONLY_UNATTENDED_TEXT, outKey);
|
|
743
752
|
}
|
|
744
753
|
let decision = await this.decide(tool, ctx.agent, {
|
|
745
754
|
orgId: ctx.orgId,
|
|
@@ -766,7 +775,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
766
775
|
if (typeof decision === "object" && "unavailable" in decision) {
|
|
767
776
|
return fail(unavailableText(tool.key, decision.unavailable), outKey);
|
|
768
777
|
}
|
|
769
|
-
if (
|
|
778
|
+
if (personOnly) {
|
|
770
779
|
// R6: always the person's own card, never a grant or an `allow` (the default policy already
|
|
771
780
|
// asks for them; this holds for any decision)
|
|
772
781
|
if (decision === "allow" || "grant" in decision) {
|
|
@@ -783,7 +792,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
783
792
|
}
|
|
784
793
|
// R5: only the person the run works for types the values; a role escalation cannot ask them
|
|
785
794
|
if ("ask" in decision && decision.ask.requestedFor === null) {
|
|
786
|
-
return fail(PERSON_FIELDS_ROLE_TEXT, outKey);
|
|
795
|
+
return fail(personFields !== undefined ? PERSON_FIELDS_ROLE_TEXT : PERSON_ONLY_ROLE_TEXT, outKey);
|
|
787
796
|
}
|
|
788
797
|
}
|
|
789
798
|
// 该调用已有审批(续跑)→ 按审批结果;没有且策略为 ask → 建审批并等待
|
package/dist/tools/policy.d.ts
CHANGED
|
@@ -79,8 +79,9 @@ export declare function connectorPolicy(input: {
|
|
|
79
79
|
* - in `fail` mode an ask still left is refused (`{ refused, missingGrant }`, no approval), and
|
|
80
80
|
* `AskUserQuestion` is refused; in `wait` mode both ask the creator as in an attended run.
|
|
81
81
|
*
|
|
82
|
-
* A call with person fields (`CallPolicy.personFields`)
|
|
83
|
-
* `
|
|
82
|
+
* A call with person fields (`CallPolicy.personFields`) or one only the person may confirm
|
|
83
|
+
* (`CallPolicy.personOnly`) is a fixed ask: no grant or agent `allow` lets it through (ruling R6).
|
|
84
|
+
* The pipeline refuses it before this in an unattended run.
|
|
84
85
|
*/
|
|
85
86
|
export declare function createDecidePolicy(db: KernelSchemaDb,
|
|
86
87
|
/** Logs (debug: once per call) when an org's stored security setting is unreadable. */
|
package/dist/tools/policy.js
CHANGED
|
@@ -102,8 +102,9 @@ export function connectorPolicy(input) {
|
|
|
102
102
|
* - in `fail` mode an ask still left is refused (`{ refused, missingGrant }`, no approval), and
|
|
103
103
|
* `AskUserQuestion` is refused; in `wait` mode both ask the creator as in an attended run.
|
|
104
104
|
*
|
|
105
|
-
* A call with person fields (`CallPolicy.personFields`)
|
|
106
|
-
* `
|
|
105
|
+
* A call with person fields (`CallPolicy.personFields`) or one only the person may confirm
|
|
106
|
+
* (`CallPolicy.personOnly`) is a fixed ask: no grant or agent `allow` lets it through (ruling R6).
|
|
107
|
+
* The pipeline refuses it before this in an unattended run.
|
|
107
108
|
*/
|
|
108
109
|
export function createDecidePolicy(db,
|
|
109
110
|
/** Logs (debug: once per call) when an org's stored security setting is unreadable. */
|
|
@@ -256,6 +257,7 @@ log) {
|
|
|
256
257
|
// the call asks every time, outside every grant, and no agent `allow` lifts it
|
|
257
258
|
const fixedAsk = unattendedSkillChange ||
|
|
258
259
|
call?.personFields !== undefined ||
|
|
260
|
+
call?.personOnly === true ||
|
|
259
261
|
isFixedAsk(tool) ||
|
|
260
262
|
(call !== null && !call.remember && (call.policy !== "allow" || agentOverride !== undefined));
|
|
261
263
|
const input = {
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -227,6 +227,13 @@ export interface CallPolicy {
|
|
|
227
227
|
};
|
|
228
228
|
fields: PersonFieldSpec[];
|
|
229
229
|
};
|
|
230
|
+
/**
|
|
231
|
+
* Only the person the run works for can confirm this call, on the card, because its result is
|
|
232
|
+
* shown once to whoever approves it (an invitation link, a generated initial password). Like a
|
|
233
|
+
* call with person fields (ruling R6): it always asks, never a grant or an `allow`; it is
|
|
234
|
+
* refused in an unattended run and when the ask would go to a role instead of the person.
|
|
235
|
+
*/
|
|
236
|
+
personOnly?: true;
|
|
230
237
|
}
|
|
231
238
|
export type ToolPolicy = "allow" | "ask" | "deny";
|
|
232
239
|
export interface ResolvedTool {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.59",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.43"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/
|
|
79
|
-
"@capybara-hq/
|
|
78
|
+
"@capybara-hq/device": "0.1.0-rc.23",
|
|
79
|
+
"@capybara-hq/testing": "0.1.0-rc.29"
|
|
80
80
|
},
|
|
81
81
|
"scripts": {
|
|
82
82
|
"build": "tsc -b"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Platform web parity (spec 2026-11-19-platform-web-parity-design.md §7.2, plan ruling R10): a
|
|
2
|
+
-- value a Platform call made that only the person who approved the call may read, once, on the
|
|
3
|
+
-- web, like the generated initial password (account_initial_passwords). The first kind is
|
|
4
|
+
-- `invitation_link`: the token of an invitation an org admin's agent created. Expand-only.
|
|
5
|
+
--
|
|
6
|
+
-- One row per value, keyed by the subject it belongs to (the invitation id). The value is sealed
|
|
7
|
+
-- with the master keyring (AES-256-GCM, AAD = the subject id, so a row moved to another subject
|
|
8
|
+
-- fails to unwrap). The tool call it came from (conversation_id, run_id, call_id: a call id is
|
|
9
|
+
-- unique only within its run) and its recipient decide who may read it. Read once (deleted as it
|
|
10
|
+
-- is read), dropped after expires_at (24 hours) by the hourly cleanup job.
|
|
11
|
+
CREATE TABLE IF NOT EXISTS capybara.platform_sealed_reveals (
|
|
12
|
+
id text PRIMARY KEY,
|
|
13
|
+
kind text NOT NULL,
|
|
14
|
+
org_id text NOT NULL REFERENCES capybara.orgs(id) ON DELETE CASCADE,
|
|
15
|
+
recipient_account_id text NOT NULL REFERENCES capybara.accounts(id) ON DELETE CASCADE,
|
|
16
|
+
conversation_id text NOT NULL REFERENCES capybara.conversations(id) ON DELETE CASCADE,
|
|
17
|
+
run_id text NOT NULL,
|
|
18
|
+
call_id text NOT NULL,
|
|
19
|
+
master_key_id text NOT NULL,
|
|
20
|
+
ciphertext bytea NOT NULL,
|
|
21
|
+
expires_at timestamptz NOT NULL,
|
|
22
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
23
|
+
);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS platform_sealed_reveals_call_idx
|
|
25
|
+
ON capybara.platform_sealed_reveals (conversation_id, run_id, call_id);
|
|
26
|
+
CREATE INDEX IF NOT EXISTS platform_sealed_reveals_expires_idx
|
|
27
|
+
ON capybara.platform_sealed_reveals (expires_at);
|