@capybara-hq/kernel 0.1.0-rc.42 → 0.1.0-rc.43
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/config/schema.d.ts +3 -0
- package/dist/config/schema.js +30 -0
- package/dist/conversations/events.d.ts +3 -0
- package/dist/conversations/events.js +7 -3
- package/dist/ctx/create-ctx.d.ts +12 -5
- package/dist/ctx/create-ctx.js +21 -5
- package/dist/db/kernel-schema.d.ts +10 -0
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +10 -6
- package/dist/infra/config/kernel-config.service.js +4 -0
- package/dist/models/image-usable.d.ts +22 -0
- package/dist/models/image-usable.js +29 -0
- package/dist/models/images.d.ts +125 -0
- package/dist/models/images.js +440 -0
- package/dist/models/models.module.d.ts +3 -2
- package/dist/models/models.module.js +16 -5
- package/dist/models/org-models.schemas.js +1 -0
- package/dist/models/purposes.controller.d.ts +7 -0
- package/dist/models/purposes.controller.js +9 -0
- package/dist/models/purposes.d.ts +28 -3
- package/dist/models/purposes.js +40 -13
- package/dist/platform/ops/models.ops.js +10 -0
- package/dist/runtime/hook-calls.d.ts +11 -1
- package/dist/runtime/hook-calls.js +24 -1
- package/dist/runtime/providers.d.ts +9 -5
- package/dist/runtime/providers.js +22 -3
- package/dist/runtime/usage-report.d.ts +10 -6
- package/dist/runtime/usage-report.js +31 -11
- package/dist/sandbox/review/permission-candidate.js +22 -6
- package/dist/sandbox/review/review.service.d.ts +1 -1
- package/dist/sandbox/review/review.service.js +43 -12
- package/dist/tools/builtin-names.d.ts +3 -1
- package/dist/tools/builtin-names.js +5 -1
- package/dist/tools/builtins/artifacts.d.ts +43 -0
- package/dist/tools/builtins/artifacts.js +67 -0
- package/dist/tools/builtins/builtin-tools.d.ts +4 -0
- package/dist/tools/builtins/builtin-tools.js +28 -5
- package/dist/tools/builtins/image/generate.d.ts +59 -0
- package/dist/tools/builtins/image/generate.js +535 -0
- package/dist/tools/builtins/image/index.d.ts +2 -0
- package/dist/tools/builtins/image/index.js +2 -0
- package/dist/tools/builtins/image/paths.d.ts +12 -0
- package/dist/tools/builtins/image/paths.js +26 -0
- package/dist/tools/builtins/sandbox/deliver.js +7 -49
- package/dist/tools/pipeline.js +15 -7
- package/dist/tools/tools.module.js +3 -0
- package/package.json +3 -3
- package/src/migrations/0160_model_usage_image_kind.sql +10 -0
package/dist/tools/pipeline.js
CHANGED
|
@@ -51,6 +51,7 @@ import { Breaker, breakerOpenMessage } from "./breaker.js";
|
|
|
51
51
|
import { SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
|
|
52
52
|
import { AGENT_TOOL, AgentToolInput } from "./builtins/agent.js";
|
|
53
53
|
import { HandbackInput } from "./builtins/handback.js";
|
|
54
|
+
import { generateImagePaths } from "./builtins/image/paths.js";
|
|
54
55
|
import { DEVICE_CODE_PATTERN, deviceCodeIdemKey, GITHUB_DEVICE_LOGIN_URL, } from "./builtins/sandbox/device-code.js";
|
|
55
56
|
import { SendMessageInput } from "./builtins/send-message.js";
|
|
56
57
|
import { isAlwaysLoaded, notLoadedText } from "./builtins/tool-search.js";
|
|
@@ -179,10 +180,16 @@ function reviewParentOf(parent) {
|
|
|
179
180
|
}
|
|
180
181
|
/**
|
|
181
182
|
* The tools the command review covers (auto mode spec §5.1): the shell and the file tools whose
|
|
182
|
-
* writes may leave the workspace
|
|
183
|
-
* `
|
|
183
|
+
* writes may leave the workspace, and `GenerateImage` when it writes its images into the device
|
|
184
|
+
* (`file_path`; image generation spec §5.3, reviewed as a `Write`). Any other tool call is not
|
|
185
|
+
* reviewed (the review service answers `allow` for it too; the pipeline skips the facts read).
|
|
184
186
|
*/
|
|
185
|
-
const REVIEWED_TOOL_KEYS = new Set(["Bash", "Write", "Edit"]);
|
|
187
|
+
const REVIEWED_TOOL_KEYS = new Set(["Bash", "Write", "Edit", "GenerateImage"]);
|
|
188
|
+
/** Whether the review covers this call ({@link REVIEWED_TOOL_KEYS}; `GenerateImage` with a path). */
|
|
189
|
+
const isReviewedCall = (toolKey, input) => REVIEWED_TOOL_KEYS.has(toolKey) &&
|
|
190
|
+
(toolKey !== "GenerateImage" || generateImagePaths(input).length > 0);
|
|
191
|
+
/** The paths a reviewed write writes: `file_path`, or every path of a `GenerateImage` call. */
|
|
192
|
+
const writePathsOf = (toolKey, input) => toolKey === "GenerateImage" ? generateImagePaths(input) : [textField(input, "file_path")];
|
|
186
193
|
/** Whether the review holds a shell command or a file write, for the texts and the ask's detail. */
|
|
187
194
|
const reviewKindOf = (toolKey) => toolKey === "Bash" ? "command" : "write";
|
|
188
195
|
/**
|
|
@@ -1001,7 +1008,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1001
1008
|
const devices = this.deps.devices;
|
|
1002
1009
|
if (review === undefined || devices === undefined)
|
|
1003
1010
|
return { kind: "continue" };
|
|
1004
|
-
if (!
|
|
1011
|
+
if (!isReviewedCall(tool.key, input))
|
|
1005
1012
|
return { kind: "continue" };
|
|
1006
1013
|
const asked = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
1007
1014
|
const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
|
|
@@ -1095,10 +1102,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1095
1102
|
// the whole command the approval covers (the event keeps a clamped copy for display)
|
|
1096
1103
|
command,
|
|
1097
1104
|
// a relative path as it will be written: resolved against the working root
|
|
1105
|
+
// (every path a GenerateImage call writes, comma-separated)
|
|
1098
1106
|
...(kind === "write" && {
|
|
1099
|
-
path: clipText(
|
|
1100
|
-
?
|
|
1101
|
-
|
|
1107
|
+
path: clipText(writePathsOf(tool.key, input)
|
|
1108
|
+
.map((p) => facts.workingRoot === undefined ? p : pathAgainstWorkingRoot(p, facts.workingRoot))
|
|
1109
|
+
.join(", "), 4096),
|
|
1102
1110
|
}),
|
|
1103
1111
|
rule: verdict.rule,
|
|
1104
1112
|
reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
|
|
@@ -17,6 +17,7 @@ import { ModelsModule } from "../models/models.module.js";
|
|
|
17
17
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
18
18
|
import { PlatformModule } from "../platform/platform.module.js";
|
|
19
19
|
import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
|
|
20
|
+
import { ProvidersModule } from "../runtime/providers.js";
|
|
20
21
|
import { RunJobsModule } from "../runtime/run-jobs.js";
|
|
21
22
|
import { StepLogModule } from "../runtime/step-log.js";
|
|
22
23
|
import { SubagentsModule } from "../runtime/subagents/subagents.service.js";
|
|
@@ -85,6 +86,8 @@ ToolsModule = __decorate([
|
|
|
85
86
|
ConversationAccessModule,
|
|
86
87
|
// the WebFetch extraction call: its purpose and step writes (its usage report owed with them)
|
|
87
88
|
ModelsModule,
|
|
89
|
+
// `GenerateImage`'s availability resolves the image purpose's model in the org
|
|
90
|
+
ProvidersModule,
|
|
88
91
|
StepLogModule,
|
|
89
92
|
// a decision resumes its waiting run in the decision's transaction (`RunResume`)
|
|
90
93
|
RunJobsModule,
|
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.43",
|
|
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": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"yaml": "^2.9.1",
|
|
66
66
|
"yauzl": "3.4.0",
|
|
67
67
|
"zod": "^4.6.7",
|
|
68
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
68
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.32"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/ws": "^8.18.2",
|
|
75
75
|
"@types/yauzl": "3.4.0",
|
|
76
76
|
"ws": "^8.22.0",
|
|
77
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
77
|
+
"@capybara-hq/testing": "0.1.0-rc.25",
|
|
78
78
|
"@capybara-hq/device": "0.1.0-rc.14"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- Image generation through `ctx.models.generateImage` (image generation spec §9): a `model_usage`
|
|
2
|
+
-- row records the kind of call that made it, so its `usage.report` purpose is `image` or
|
|
3
|
+
-- `embedding` (the `purpose` column keeps the extension's own purpose name), how many images
|
|
4
|
+
-- the call produced, and the answer's output and cache tokens (an image model may bill output
|
|
5
|
+
-- tokens). Existing rows are embedding calls with no images and no output or cache tokens.
|
|
6
|
+
ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS kind text NOT NULL DEFAULT 'embedding';
|
|
7
|
+
ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS output_images integer NOT NULL DEFAULT 0;
|
|
8
|
+
ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS output_tokens integer NOT NULL DEFAULT 0;
|
|
9
|
+
ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS cache_read_tokens integer NOT NULL DEFAULT 0;
|
|
10
|
+
ALTER TABLE model_usage ADD COLUMN IF NOT EXISTS cache_write_tokens integer NOT NULL DEFAULT 0;
|