@capybara-hq/kernel 0.1.0-rc.100 → 0.1.0-rc.102
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 +5 -5
- package/dist/conversations/event-log.d.ts +15 -3
- package/dist/conversations/event-log.js +21 -0
- package/dist/conversations/events.d.ts +4 -0
- package/dist/conversations/events.js +6 -2
- package/dist/evals/run-replay.js +3 -1
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +8 -0
- package/dist/runtime/context/output-truncated.d.ts +16 -0
- package/dist/runtime/context/output-truncated.js +19 -0
- package/dist/runtime/langgraph-loop.js +22 -1
- package/dist/runtime/loop.d.ts +5 -2
- package/dist/runtime/model-call.d.ts +12 -4
- package/dist/runtime/model-call.js +13 -3
- package/dist/runtime/run-drafts.d.ts +30 -8
- package/dist/runtime/run-drafts.js +74 -10
- package/dist/runtime/subagents/status.js +2 -0
- package/dist/runtime/write-base.d.ts +110 -27
- package/dist/runtime/write-base.js +349 -90
- package/dist/runtime/write-base.service.d.ts +9 -1
- package/dist/runtime/write-base.service.js +39 -5
- package/dist/sandbox/review/index.d.ts +1 -1
- package/dist/sandbox/review/index.js +1 -1
- package/dist/sandbox/review/review.service.js +5 -2
- package/dist/sandbox/review/rules.d.ts +9 -0
- package/dist/sandbox/review/rules.js +67 -3
- package/dist/tools/builtins/agent.js +4 -0
- package/dist/tools/builtins/sandbox/write.js +3 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ import { generateImagePaths } from "../../tools/builtins/image/paths.js";
|
|
|
19
19
|
import { newReviewTag, REVIEW_ASK_REASON, REVIEW_PURPOSE, readPersonMessages, runClassifier, } from "./classifier.js";
|
|
20
20
|
import { approverForCrossing, crossingOfCandidate, ESCALATION_RETRY_HINT, escalationAskReason, isCredentialConsentRule, } from "./permission-candidate.js";
|
|
21
21
|
export { escalationAskReason, quotedJustification } from "./permission-candidate.js";
|
|
22
|
-
import { reviewRules, reviewWrite, writtenPaths } from "./rules.js";
|
|
22
|
+
import { reviewRead, reviewRules, reviewWrite, writtenPaths } from "./rules.js";
|
|
23
23
|
import { applySessionGrants, isSessionGrantableRule, } from "./types.js";
|
|
24
24
|
/**
|
|
25
25
|
* The rule asks about reach, not consent: a write or a link outside the workspace. On the managed
|
|
@@ -332,8 +332,11 @@ let CommandReviewService = class CommandReviewService {
|
|
|
332
332
|
...(input.serviceEntry !== undefined && { serviceEntry: input.serviceEntry }),
|
|
333
333
|
};
|
|
334
334
|
// running a file this conversation wrote is not a development command (hardening spec R1)
|
|
335
|
+
// a `Read` is judged as a read (its hits never carry a write rule's label)
|
|
335
336
|
const result = isWrite
|
|
336
|
-
?
|
|
337
|
+
? input.toolKey === "Read"
|
|
338
|
+
? reviewRead(paths[0], facts)
|
|
339
|
+
: reviewWrites(paths, facts)
|
|
337
340
|
: reviewRules(target, {
|
|
338
341
|
...facts,
|
|
339
342
|
written: await this.writtenInTree(input.orgId, await rootOf(), facts),
|
|
@@ -85,3 +85,12 @@ export declare function reviewRules(command: string, facts: ReviewFacts): Review
|
|
|
85
85
|
* workspace asks; anything else outside asks to write outside.
|
|
86
86
|
*/
|
|
87
87
|
export declare function reviewWrite(path: string, facts: ReviewFacts): ReviewResult;
|
|
88
|
+
/**
|
|
89
|
+
* The table for a file-tool `Read` under a permission profile, labelled as a read: the device's
|
|
90
|
+
* own files are denied as for a write; SSH and credential files ask wherever they lie (the
|
|
91
|
+
* workspace's own `.env` reads freely, as it writes); other workspace and tmp reads are
|
|
92
|
+
* `allow.read`. The write-only classes (a git hook, a shell rc file, a write outside the
|
|
93
|
+
* workspace) are no finding for a read: a read anywhere else carries no hit and the enforced
|
|
94
|
+
* operation scope decides.
|
|
95
|
+
*/
|
|
96
|
+
export declare function reviewRead(path: string, facts: ReviewFacts): ReviewResult;
|
|
@@ -4257,6 +4257,8 @@ function linkClass(path, ctx) {
|
|
|
4257
4257
|
return "sensitive";
|
|
4258
4258
|
return "outside";
|
|
4259
4259
|
}
|
|
4260
|
+
/** Why a read is allowed: the shell's `allow.read` and a file-tool `Read` under a profile. */
|
|
4261
|
+
const READ_REASON = "Reads files; reading is allowed.";
|
|
4260
4262
|
const RULES = [
|
|
4261
4263
|
{
|
|
4262
4264
|
id: "allow.read",
|
|
@@ -4311,9 +4313,7 @@ const RULES = [
|
|
|
4311
4313
|
// Reading a secret path is not "reading anything except the secret paths".
|
|
4312
4314
|
return (secretTokens({ argv: inv.argv, redirects: command.redirects, pipeline: command.pipeline }, ctx.facts).length === 0);
|
|
4313
4315
|
});
|
|
4314
|
-
return matched.length > 0
|
|
4315
|
-
? { reason: "Reads files; reading is allowed.", commands: matched }
|
|
4316
|
-
: null;
|
|
4316
|
+
return matched.length > 0 ? { reason: READ_REASON, commands: matched } : null;
|
|
4317
4317
|
},
|
|
4318
4318
|
},
|
|
4319
4319
|
{
|
|
@@ -5361,3 +5361,67 @@ export function reviewWrite(path, facts) {
|
|
|
5361
5361
|
],
|
|
5362
5362
|
};
|
|
5363
5363
|
}
|
|
5364
|
+
/** What a file-tool read of a credential asks with: the read rules keep the class, never a write's text. */
|
|
5365
|
+
const CREDENTIAL_READ_REASONS = {
|
|
5366
|
+
"ask.ssh": "Reads SSH keys or configuration; this needs approval.",
|
|
5367
|
+
"ask.secret-file": "Reads a credential file; this needs approval each time.",
|
|
5368
|
+
};
|
|
5369
|
+
/**
|
|
5370
|
+
* The table for a file-tool `Read` under a permission profile, labelled as a read: the device's
|
|
5371
|
+
* own files are denied as for a write; SSH and credential files ask wherever they lie (the
|
|
5372
|
+
* workspace's own `.env` reads freely, as it writes); other workspace and tmp reads are
|
|
5373
|
+
* `allow.read`. The write-only classes (a git hook, a shell rc file, a write outside the
|
|
5374
|
+
* workspace) are no finding for a read: a read anywhere else carries no hit and the enforced
|
|
5375
|
+
* operation scope decides.
|
|
5376
|
+
*/
|
|
5377
|
+
export function reviewRead(path, facts) {
|
|
5378
|
+
const resolved = resolveFacts(facts);
|
|
5379
|
+
const absolute = expandPath(path, resolved);
|
|
5380
|
+
if (absolute === null) {
|
|
5381
|
+
return {
|
|
5382
|
+
outcome: "unsure",
|
|
5383
|
+
hits: [
|
|
5384
|
+
{
|
|
5385
|
+
id: "unsure.uncovered",
|
|
5386
|
+
outcome: "unsure",
|
|
5387
|
+
reason: "The path cannot be resolved statically; it needs review.",
|
|
5388
|
+
},
|
|
5389
|
+
],
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
if (isDevicePath(absolute, resolved)) {
|
|
5393
|
+
return {
|
|
5394
|
+
outcome: "deny",
|
|
5395
|
+
hits: [
|
|
5396
|
+
{
|
|
5397
|
+
id: "deny.tooling-edit",
|
|
5398
|
+
outcome: "deny",
|
|
5399
|
+
reason: "Reads Capybara's own device files or the device directory's marker.",
|
|
5400
|
+
},
|
|
5401
|
+
],
|
|
5402
|
+
};
|
|
5403
|
+
}
|
|
5404
|
+
const credentialAsk = () => {
|
|
5405
|
+
const id = configClassOf(absolute, resolved);
|
|
5406
|
+
if (id !== "ask.ssh" && id !== "ask.secret-file")
|
|
5407
|
+
return null;
|
|
5408
|
+
return { outcome: "ask", hits: [{ id, outcome: "ask", reason: CREDENTIAL_READ_REASONS[id] }] };
|
|
5409
|
+
};
|
|
5410
|
+
if (isHomeLevelSensitive(absolute, resolved)) {
|
|
5411
|
+
const ask = credentialAsk();
|
|
5412
|
+
if (ask)
|
|
5413
|
+
return ask;
|
|
5414
|
+
}
|
|
5415
|
+
if (inside(absolute, resolved.workspace) || tmpRootOf(absolute)) {
|
|
5416
|
+
return {
|
|
5417
|
+
outcome: "allow",
|
|
5418
|
+
hits: [{ id: "allow.read", outcome: "allow", reason: READ_REASON }],
|
|
5419
|
+
};
|
|
5420
|
+
}
|
|
5421
|
+
if (isSecretPath(absolute, resolved)) {
|
|
5422
|
+
const ask = credentialAsk();
|
|
5423
|
+
if (ask)
|
|
5424
|
+
return ask;
|
|
5425
|
+
}
|
|
5426
|
+
return { outcome: "allow", hits: [] };
|
|
5427
|
+
}
|
|
@@ -189,6 +189,10 @@ export function agentResultText(r) {
|
|
|
189
189
|
case "budget":
|
|
190
190
|
text = reply;
|
|
191
191
|
break;
|
|
192
|
+
case "max_output":
|
|
193
|
+
text = reply === "" ? "The sub-agent's replies kept reaching the output token limit." : reply;
|
|
194
|
+
isError = false;
|
|
195
|
+
break;
|
|
192
196
|
case "aborted":
|
|
193
197
|
text =
|
|
194
198
|
r.abortedBy === "parent" ? AGENT_STOPPED_WITH_RUN_TEXT : "The user stopped this sub-agent.";
|
|
@@ -20,7 +20,9 @@ const SPEC = {
|
|
|
20
20
|
file_path: {
|
|
21
21
|
type: "string",
|
|
22
22
|
minLength: 1,
|
|
23
|
-
description: "Absolute path of the file, e.g. report.md in the workspace directory."
|
|
23
|
+
description: "Absolute path of the file, e.g. report.md in the workspace directory. Give it before " +
|
|
24
|
+
"`content`: the user sees the write as a live diff against the current file once the " +
|
|
25
|
+
"path is known.",
|
|
24
26
|
},
|
|
25
27
|
content: { type: "string", description: "The complete new content of the file." },
|
|
26
28
|
},
|
package/package.json
CHANGED