@capybara-hq/kernel 0.1.0-rc.87 → 0.1.0-rc.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +3 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/conversations/conversations.schemas.d.ts +2 -1
- package/dist/conversations/conversations.schemas.js +2 -1
- package/dist/ctx/create-ctx.d.ts +1 -1
- package/dist/ctx/create-ctx.js +11 -5
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +4 -0
- package/dist/files/files.module.d.ts +4 -1
- package/dist/files/files.module.js +6 -2
- package/dist/files/previewers.controller.d.ts +12 -0
- package/dist/files/previewers.controller.js +52 -0
- package/dist/files/previewers.d.ts +46 -3
- package/dist/files/previewers.js +107 -11
- package/dist/html/html-type.d.ts +2 -0
- package/dist/html/html-type.js +4 -0
- package/dist/http/plugin-route-access.js +1 -0
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/ops/skills.ops.d.ts +3 -1
- package/dist/platform/ops/skills.ops.js +30 -5
- package/dist/sandbox/device-services.d.ts +14 -4
- package/dist/sandbox/device-services.js +24 -7
- package/dist/sandbox/sandbox.service.d.ts +21 -0
- package/dist/sandbox/sandbox.service.js +76 -0
- package/dist/skills/skill-files.d.ts +91 -0
- package/dist/skills/skill-files.js +144 -0
- package/dist/skills/skills.controller.d.ts +23 -3
- package/dist/skills/skills.controller.js +74 -6
- package/dist/skills/skills.module.js +3 -0
- package/dist/skills/skills.schemas.d.ts +47 -0
- package/dist/skills/skills.schemas.js +67 -1
- package/dist/skills/skills.service.d.ts +28 -3
- package/dist/skills/skills.service.js +38 -34
- package/dist/tools/builtins/sandbox/deliver.d.ts +1 -0
- package/dist/tools/builtins/sandbox/deliver.js +7 -0
- package/dist/tools/builtins/skill-load.d.ts +8 -2
- package/dist/tools/builtins/skill-load.js +13 -4
- package/dist/ui/embed-token.d.ts +1 -1
- package/dist/ui/embed-token.js +43 -5
- package/dist/ui/ui.schemas.d.ts +3 -0
- package/dist/ui/ui.schemas.js +8 -0
- package/dist/ui/views.controller.d.ts +6 -4
- package/dist/ui/views.controller.js +22 -4
- package/dist/ui/views.d.ts +22 -1
- package/dist/ui/views.js +44 -1
- package/package.json +2 -2
package/dist/ui/embed-token.js
CHANGED
|
@@ -8,6 +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 { createHmac, timingSafeEqual } from "node:crypto";
|
|
11
|
+
import { SKILL_LIMITS, } from "@capybara-hq/plugin-sdk";
|
|
11
12
|
import { Inject, Injectable, Module, Optional } from "@nestjs/common";
|
|
12
13
|
import { KEYRING } from "../infra/tokens.js";
|
|
13
14
|
import { ORG_ROLES } from "../orgs/roles.js";
|
|
@@ -17,8 +18,11 @@ export const EMBED_TOKEN_TTL_SECONDS = 300;
|
|
|
17
18
|
export const EMBED_TOKEN_SKEW_SECONDS = 30;
|
|
18
19
|
/** HKDF 用途(keyring 派生时 info 为 `capybara:capybara-embed/1`),也是签名输入的域前缀。 */
|
|
19
20
|
export const EMBED_KEY_INFO = "capybara-embed/1";
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The longest token accepted. Claims are bounded (ids ≤ 100 characters, a skill file path ≤
|
|
23
|
+
* {@link SKILL_LIMITS.pathMaxChars} code points, at most about 3 KiB as JSON): well below this.
|
|
24
|
+
*/
|
|
25
|
+
const TOKEN_MAX = 8192;
|
|
22
26
|
const MAC_LEN = 32;
|
|
23
27
|
const B64URL = /^[A-Za-z0-9_-]+$/;
|
|
24
28
|
const PLUGIN_RE = /^[a-z][a-z0-9-]{1,40}$/;
|
|
@@ -31,6 +35,7 @@ const CLAIM_KEYS = new Set([
|
|
|
31
35
|
"conversationId",
|
|
32
36
|
"agentId",
|
|
33
37
|
"fileId",
|
|
38
|
+
"skillFile",
|
|
34
39
|
"shareId",
|
|
35
40
|
"generation",
|
|
36
41
|
"contribution",
|
|
@@ -38,6 +43,26 @@ const CLAIM_KEYS = new Set([
|
|
|
38
43
|
]);
|
|
39
44
|
const ROLES = new Set(ORG_ROLES);
|
|
40
45
|
const isId = (v) => typeof v === "string" && v !== "" && v.length <= 100;
|
|
46
|
+
/** A skill file reference: exactly `skillId`, a positive `version` and a non-empty `path`. */
|
|
47
|
+
function parseSkillFile(v) {
|
|
48
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
49
|
+
return null;
|
|
50
|
+
const f = v;
|
|
51
|
+
const keys = Object.keys(f);
|
|
52
|
+
if (keys.length !== 3 || !keys.every((k) => k === "skillId" || k === "version" || k === "path")) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (!isId(f.skillId))
|
|
56
|
+
return null;
|
|
57
|
+
if (typeof f.version !== "number" || !Number.isSafeInteger(f.version) || f.version < 1) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (typeof f.path !== "string" || f.path === "")
|
|
61
|
+
return null;
|
|
62
|
+
if ([...f.path].length > SKILL_LIMITS.pathMaxChars)
|
|
63
|
+
return null;
|
|
64
|
+
return { skillId: f.skillId, version: f.version, path: f.path };
|
|
65
|
+
}
|
|
41
66
|
/**
|
|
42
67
|
* 严格解码 base64url:只允许字母表内字符、不带填充,且必须是规范编码(解码后再编码与原文相同),
|
|
43
68
|
* 同一份字节只有一种写法。
|
|
@@ -53,7 +78,8 @@ function decodeStrict(s) {
|
|
|
53
78
|
* `"platform"` exactly when `orgId` is absent and `role` is `"superAdmin"`, with no
|
|
54
79
|
* `conversationId` / `agentId` / `fileId`; `"org"` needs an `orgId` and one of the org roles;
|
|
55
80
|
* `"share"` (file sharing spec §7) see {@link parseShareClaims}. `shareId` / `generation` only in
|
|
56
|
-
* the share scope.
|
|
81
|
+
* the share scope. `skillFile` (a skill file's previewer, skill file browser spec) only in the org
|
|
82
|
+
* scope and never with `conversationId`, `agentId` or `fileId`.
|
|
57
83
|
*/
|
|
58
84
|
function parseClaims(v) {
|
|
59
85
|
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
@@ -77,7 +103,10 @@ function parseClaims(v) {
|
|
|
77
103
|
if (c.scope === "platform") {
|
|
78
104
|
if (c.orgId !== undefined || c.role !== "superAdmin")
|
|
79
105
|
return null;
|
|
80
|
-
if (c.conversationId !== undefined ||
|
|
106
|
+
if (c.conversationId !== undefined ||
|
|
107
|
+
c.agentId !== undefined ||
|
|
108
|
+
c.fileId !== undefined ||
|
|
109
|
+
c.skillFile !== undefined) {
|
|
81
110
|
return null;
|
|
82
111
|
}
|
|
83
112
|
return {
|
|
@@ -97,6 +126,14 @@ function parseClaims(v) {
|
|
|
97
126
|
return null;
|
|
98
127
|
if (c.fileId !== undefined && (!isId(c.fileId) || c.conversationId === undefined))
|
|
99
128
|
return null;
|
|
129
|
+
let skillFile;
|
|
130
|
+
if (c.skillFile !== undefined) {
|
|
131
|
+
if (c.conversationId !== undefined || c.agentId !== undefined)
|
|
132
|
+
return null;
|
|
133
|
+
skillFile = parseSkillFile(c.skillFile) ?? undefined;
|
|
134
|
+
if (skillFile === undefined)
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
100
137
|
return {
|
|
101
138
|
plugin: c.plugin,
|
|
102
139
|
scope: "org",
|
|
@@ -106,6 +143,7 @@ function parseClaims(v) {
|
|
|
106
143
|
...(c.conversationId !== undefined && { conversationId: c.conversationId }),
|
|
107
144
|
...(c.agentId !== undefined && { agentId: c.agentId }),
|
|
108
145
|
...(c.fileId !== undefined && { fileId: c.fileId }),
|
|
146
|
+
...(skillFile !== undefined && { skillFile }),
|
|
109
147
|
contribution: c.contribution,
|
|
110
148
|
exp: c.exp,
|
|
111
149
|
};
|
|
@@ -121,7 +159,7 @@ function parseShareClaims(c, plugin, contribution, exp) {
|
|
|
121
159
|
return null;
|
|
122
160
|
if (c.generation < 1)
|
|
123
161
|
return null;
|
|
124
|
-
for (const k of ["accountId", "role", "conversationId", "agentId", "fileId"]) {
|
|
162
|
+
for (const k of ["accountId", "role", "conversationId", "agentId", "fileId", "skillFile"]) {
|
|
125
163
|
if (c[k] !== undefined)
|
|
126
164
|
return null;
|
|
127
165
|
}
|
package/dist/ui/ui.schemas.d.ts
CHANGED
|
@@ -48,6 +48,9 @@ export declare const EmbedTokenBody: z.ZodDefault<z.ZodObject<{
|
|
|
48
48
|
conversationId: z.ZodOptional<z.ZodString>;
|
|
49
49
|
agentId: z.ZodOptional<z.ZodUUID>;
|
|
50
50
|
fileId: z.ZodOptional<z.ZodUUID>;
|
|
51
|
+
skillId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
path: z.ZodOptional<z.ZodString>;
|
|
51
54
|
}, z.core.$strip>>;
|
|
52
55
|
/** `GET /api/v1/admin/ui/views/:plugin/:id?locale=`: a platform page takes no context id. */
|
|
53
56
|
export declare const PlatformViewQuery: z.ZodObject<{
|
package/dist/ui/ui.schemas.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UI_LIMITS, UI_SLOT_IDS } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { SkillFilePathSchema } from "../skills/skills.schemas.js";
|
|
3
4
|
/** The DTO schemas of the org UI routes (`views.controller.ts`). */
|
|
4
5
|
const Locale = z.enum(["zh", "en"]).default("en");
|
|
5
6
|
const Id = z.string().min(1).max(100);
|
|
@@ -55,6 +56,13 @@ export const EmbedTokenBody = z
|
|
|
55
56
|
agentId: z.uuid().optional(),
|
|
56
57
|
/** Only a `file.preview` embed: the file version it previews. */
|
|
57
58
|
fileId: z.uuid().optional(),
|
|
59
|
+
/**
|
|
60
|
+
* Only a `file.preview` embed of a skill file (with `path`, without a conversation): the skill;
|
|
61
|
+
* `version` defaults to its current one.
|
|
62
|
+
*/
|
|
63
|
+
skillId: z.string().min(1).max(100).optional(),
|
|
64
|
+
version: z.number().int().min(1).max(2_147_483_647).optional(),
|
|
65
|
+
path: SkillFilePathSchema.optional(),
|
|
58
66
|
})
|
|
59
67
|
.default({});
|
|
60
68
|
/** `GET /api/v1/admin/ui/views/:plugin/:id?locale=`: a platform page takes no context id. */
|
|
@@ -29,10 +29,12 @@ export declare const embedSrc: (plugin: string, path: string) => string;
|
|
|
29
29
|
* (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
|
|
30
30
|
* - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
|
|
31
31
|
* member and above;
|
|
32
|
-
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
|
|
33
|
+
* or for a skill file's previewer `{ skillId, version?, path }`)
|
|
34
|
+
* → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
|
|
35
|
+
* token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
|
|
36
|
+
* claims, a skill file as `skillFile` with its resolved version). The token is only for the
|
|
37
|
+
* extension's routes; the kernel's auth guard does not accept it (it is not an API token).
|
|
36
38
|
* 对话视图的刷新走现有的会话流 `/conversations/:id/stream`。
|
|
37
39
|
* Access (UI slots spec §7): every route checks the slot of the contribution it names, its
|
|
38
40
|
* `minRole` (guest for conversation and agent slots, member for `org.page`, admin for
|
|
@@ -8,6 +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 { Controller, Get, HttpCode, Inject, Post, Req, Res } from "@nestjs/common";
|
|
11
|
+
import { ApiError } from "../errors.js";
|
|
11
12
|
import { ApiTokenService } from "../identity/api-tokens.js";
|
|
12
13
|
import { credentialCheck } from "../identity/credential-check.js";
|
|
13
14
|
import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
@@ -49,10 +50,12 @@ class UiEmbedTokenBodyDto extends createZodDto(EmbedTokenBody, "UiEmbedTokenBody
|
|
|
49
50
|
* (`{ actionId, payload?, answer?, conversationId?, agentId?, locale? }`)→ `{ toast }` | `{ view }`;
|
|
50
51
|
* - `GET /api/v1/orgs/:orgId/ui/stream`:组织级刷新 SSE(`event: ui`,`data: {"plugin","contribution"}`),
|
|
51
52
|
* member and above;
|
|
52
|
-
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* - `POST /api/v1/orgs/:orgId/ui/embeds/:plugin/:id/token` (`{ conversationId?, agentId?, fileId? }`,
|
|
54
|
+
* or for a skill file's previewer `{ skillId, version?, path }`)
|
|
55
|
+
* → `{ token, src: "/plugin-ui/<plugin>/<path without /ui/>", expiresAt, expiresIn }`: an embed
|
|
56
|
+
* token (300 seconds, `expiresIn` in seconds, see `embed-token.ts`; `agentId` goes into the
|
|
57
|
+
* claims, a skill file as `skillFile` with its resolved version). The token is only for the
|
|
58
|
+
* extension's routes; the kernel's auth guard does not accept it (it is not an API token).
|
|
56
59
|
* 对话视图的刷新走现有的会话流 `/conversations/:id/stream`。
|
|
57
60
|
* Access (UI slots spec §7): every route checks the slot of the contribution it names, its
|
|
58
61
|
* `minRole` (guest for conversation and agent slots, member for `org.page`, admin for
|
|
@@ -119,6 +122,19 @@ let UiController = class UiController {
|
|
|
119
122
|
}
|
|
120
123
|
async embedToken(principal, org, { plugin, id }, body) {
|
|
121
124
|
const p = requireUser(principal);
|
|
125
|
+
if ((body.skillId === undefined) !== (body.path === undefined)) {
|
|
126
|
+
throw new ApiError("validation_failed", "skillId and path go together");
|
|
127
|
+
}
|
|
128
|
+
if (body.version !== undefined && body.skillId === undefined) {
|
|
129
|
+
throw new ApiError("validation_failed", "version is only allowed with skillId and path");
|
|
130
|
+
}
|
|
131
|
+
const skillFile = body.skillId !== undefined && body.path !== undefined
|
|
132
|
+
? {
|
|
133
|
+
skillId: body.skillId,
|
|
134
|
+
path: body.path,
|
|
135
|
+
...(body.version !== undefined && { version: body.version }),
|
|
136
|
+
}
|
|
137
|
+
: undefined;
|
|
122
138
|
const target = await this.views.embed({
|
|
123
139
|
orgId: org.orgId,
|
|
124
140
|
accountId: p.account.id,
|
|
@@ -128,6 +144,7 @@ let UiController = class UiController {
|
|
|
128
144
|
...(body.conversationId !== undefined && { conversationId: body.conversationId }),
|
|
129
145
|
...(body.agentId !== undefined && { agentId: body.agentId }),
|
|
130
146
|
...(body.fileId !== undefined && { fileId: body.fileId }),
|
|
147
|
+
...(skillFile !== undefined && { skillFile }),
|
|
131
148
|
});
|
|
132
149
|
const { token, expiresAt } = this.embeds.issue({
|
|
133
150
|
plugin: target.plugin,
|
|
@@ -138,6 +155,7 @@ let UiController = class UiController {
|
|
|
138
155
|
...(target.conversationId !== undefined && { conversationId: target.conversationId }),
|
|
139
156
|
...(target.agentId !== undefined && { agentId: target.agentId }),
|
|
140
157
|
...(target.fileId !== undefined && { fileId: target.fileId }),
|
|
158
|
+
...(target.skillFile !== undefined && { skillFile: target.skillFile }),
|
|
141
159
|
contribution: target.contribution,
|
|
142
160
|
});
|
|
143
161
|
return {
|
package/dist/ui/views.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
|
5
5
|
import { ExtensionHost } from "../extensions/host.js";
|
|
6
6
|
import { PreviewerRegistry } from "../files/previewers.js";
|
|
7
7
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type OrgRole } from "../orgs/roles.js";
|
|
9
9
|
export { callExtension } from "./call-extension.js";
|
|
10
10
|
/** 插件 render / action 的时限(spec §4.2:慢的插件只让那个标签失败)。 */
|
|
11
11
|
export declare const UI_CALL_TIMEOUT_MS = 5000;
|
|
@@ -62,6 +62,12 @@ export interface UiEmbedTarget {
|
|
|
62
62
|
agentId?: string;
|
|
63
63
|
/** Only a `file.preview` embed: the one file the token is for. */
|
|
64
64
|
fileId?: string;
|
|
65
|
+
/** Only a `file.preview` embed of a skill file: the resolved version and the path. */
|
|
66
|
+
skillFile?: {
|
|
67
|
+
skillId: string;
|
|
68
|
+
version: number;
|
|
69
|
+
path: string;
|
|
70
|
+
};
|
|
65
71
|
}
|
|
66
72
|
/** 取视图 / 执行动作的调用者与目标(身份来自内核鉴权): an org route's. */
|
|
67
73
|
export interface UiOrgTarget {
|
|
@@ -97,6 +103,12 @@ export type UiTarget = UiOrgTarget | UiPlatformTarget;
|
|
|
97
103
|
/** {@link UiTarget} without `locale`, per variant (what `embed` takes). */
|
|
98
104
|
export type UiEmbedRequest = (Omit<UiOrgTarget, "locale"> & {
|
|
99
105
|
fileId?: string;
|
|
106
|
+
/** A skill file's previewer (no conversation, agent or file id); `version` default current. */
|
|
107
|
+
skillFile?: {
|
|
108
|
+
skillId: string;
|
|
109
|
+
version?: number;
|
|
110
|
+
path: string;
|
|
111
|
+
};
|
|
100
112
|
}) | Omit<UiPlatformTarget, "locale">;
|
|
101
113
|
/**
|
|
102
114
|
* The card a `tool_result` of the conversation recorded for `callId`, or null (the inline-card
|
|
@@ -168,6 +180,15 @@ export declare class UiViews {
|
|
|
168
180
|
* 组织页面不收 `conversationId`。返回签发令牌所需的目标(令牌由调用方签)。
|
|
169
181
|
*/
|
|
170
182
|
embed(t: UiEmbedRequest): Promise<UiEmbedTarget>;
|
|
183
|
+
/**
|
|
184
|
+
* A `file.preview` embed for a skill file (skill file browser spec): no conversation, agent or
|
|
185
|
+
* file id with it (400 `validation_failed`); the caller's role may read skills (`skills.read`)
|
|
186
|
+
* and use the slot, the contribution is a loaded `file.preview` embed of an extension enabled in
|
|
187
|
+
* the org, and an enabled previewer of that extension with `embed: <this contribution>` takes the
|
|
188
|
+
* file (the skill and the file are resolved with the visibility of `GET /skills/:id`); anything
|
|
189
|
+
* else is 404.
|
|
190
|
+
*/
|
|
191
|
+
private skillFileEmbed;
|
|
171
192
|
/**
|
|
172
193
|
* The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
|
|
173
194
|
* sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
|
package/dist/ui/views.js
CHANGED
|
@@ -19,6 +19,7 @@ import { PreviewerRegistry } from "../files/previewers.js";
|
|
|
19
19
|
import { readUiArrangement } from "../identity/settings.js";
|
|
20
20
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
21
21
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
22
|
+
import { can } from "../orgs/roles.js";
|
|
22
23
|
import { readOrgSettings } from "../orgs/settings.service.js";
|
|
23
24
|
import { arrange, arrangeBySlot, effectiveEntry, isSingle, keyOf, ORG_ARRANGEABLE, orderItems, resolveSingleSlot, storedUse, } from "./arrangement.js";
|
|
24
25
|
import { callExtension } from "./call-extension.js";
|
|
@@ -161,6 +162,7 @@ let UiViews = class UiViews {
|
|
|
161
162
|
await conversations.writable(orgId, id, accountId);
|
|
162
163
|
},
|
|
163
164
|
previewEmbedAllowed: (t) => previewers.embedAllowed(t),
|
|
165
|
+
skillPreviewEmbed: (t) => previewers.skillEmbed(t),
|
|
164
166
|
recordedCard: (conversationId, callId) => recordedCard(db.db, conversationId, callId),
|
|
165
167
|
orgArrangement: async (orgId) => (await readOrgSettings(db.db, orgId)).uiArrangement,
|
|
166
168
|
platformArrangement: () => readUiArrangement(db.db),
|
|
@@ -272,7 +274,9 @@ let UiViews = class UiViews {
|
|
|
272
274
|
if (t.scope === "platform")
|
|
273
275
|
target = { ...t, locale: "en" };
|
|
274
276
|
else {
|
|
275
|
-
const { fileId: f, ...org } = t;
|
|
277
|
+
const { fileId: f, skillFile, ...org } = t;
|
|
278
|
+
if (skillFile !== undefined)
|
|
279
|
+
return this.skillFileEmbed({ ...org, skillFile }, f);
|
|
276
280
|
fileId = f;
|
|
277
281
|
target = { ...org, locale: "en" };
|
|
278
282
|
}
|
|
@@ -311,6 +315,45 @@ let UiViews = class UiViews {
|
|
|
311
315
|
...(fileId !== undefined && { fileId }),
|
|
312
316
|
};
|
|
313
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* A `file.preview` embed for a skill file (skill file browser spec): no conversation, agent or
|
|
320
|
+
* file id with it (400 `validation_failed`); the caller's role may read skills (`skills.read`)
|
|
321
|
+
* and use the slot, the contribution is a loaded `file.preview` embed of an extension enabled in
|
|
322
|
+
* the org, and an enabled previewer of that extension with `embed: <this contribution>` takes the
|
|
323
|
+
* file (the skill and the file are resolved with the visibility of `GET /skills/:id`); anything
|
|
324
|
+
* else is 404.
|
|
325
|
+
*/
|
|
326
|
+
async skillFileEmbed(t, fileId) {
|
|
327
|
+
if (t.conversationId !== undefined || t.agentId !== undefined || fileId !== undefined) {
|
|
328
|
+
throw new ApiError("validation_failed", "a skill file embed takes no conversationId, agentId or fileId");
|
|
329
|
+
}
|
|
330
|
+
const entry = this.d.host
|
|
331
|
+
.uiContributions()
|
|
332
|
+
.find((c) => c.plugin === t.plugin &&
|
|
333
|
+
c.contribution.id === t.id &&
|
|
334
|
+
c.contribution.kind === "embed" &&
|
|
335
|
+
c.slot.id === "file.preview");
|
|
336
|
+
const path = entry?.contribution.path;
|
|
337
|
+
if (entry === undefined || path === undefined)
|
|
338
|
+
throw notFound();
|
|
339
|
+
if (!canUseSlot(entry.slot, t.role) || !can(t.role, "skills.read"))
|
|
340
|
+
throw notFound();
|
|
341
|
+
if (!(await this.d.enabledPlugins(t.orgId)).has(t.plugin))
|
|
342
|
+
throw notFound();
|
|
343
|
+
const file = this.d.skillPreviewEmbed === undefined
|
|
344
|
+
? null
|
|
345
|
+
: await this.d.skillPreviewEmbed({
|
|
346
|
+
orgId: t.orgId,
|
|
347
|
+
skillId: t.skillFile.skillId,
|
|
348
|
+
version: t.skillFile.version,
|
|
349
|
+
path: t.skillFile.path,
|
|
350
|
+
plugin: t.plugin,
|
|
351
|
+
contribution: t.id,
|
|
352
|
+
});
|
|
353
|
+
if (file === null)
|
|
354
|
+
throw notFound();
|
|
355
|
+
return { plugin: t.plugin, contribution: t.id, path, skillFile: file };
|
|
356
|
+
}
|
|
314
357
|
/**
|
|
315
358
|
* The path of a loaded `file.preview` embed contribution (a share page's embed previewer, file
|
|
316
359
|
* sharing spec §7), else 404 `ui.not_found`. Whether the previewer takes the share's snapshot
|
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.89",
|
|
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.71"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|