@capybara-hq/kernel 0.1.0-rc.101 → 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/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/subagents/status.js +2 -0
- 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/package.json +1 -1
package/bootstrap.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"schemaVersion": 1,
|
|
4
4
|
"marketplace": {
|
|
5
5
|
"url": "https://github.com/capybara-hq/plugins.git",
|
|
6
|
-
"commit": "
|
|
6
|
+
"commit": "ff7f84534f29d9e65a0a1cdca80337d618cfee54"
|
|
7
7
|
},
|
|
8
8
|
"plugins": [
|
|
9
9
|
{
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"name": "device-local",
|
|
99
99
|
"source": "npm",
|
|
100
100
|
"npm": "@capybara-hq/plugin-device-local",
|
|
101
|
-
"version": "0.1.0-rc.
|
|
102
|
-
"integrity": "sha512-
|
|
101
|
+
"version": "0.1.0-rc.13",
|
|
102
|
+
"integrity": "sha512-gZOI8bmP5sfADZkEbB1nuPf+32qVFNJm92RyiFuLhiNNluLWN5ABy4DJehvjFy6bgs+J5Jhu88byfDt0EIrlww==",
|
|
103
103
|
"required": false,
|
|
104
104
|
"scope": "all"
|
|
105
105
|
},
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"name": "todo",
|
|
108
108
|
"source": "npm",
|
|
109
109
|
"npm": "@capybara-hq/plugin-todo",
|
|
110
|
-
"version": "0.1.0-rc.
|
|
111
|
-
"integrity": "sha512-
|
|
110
|
+
"version": "0.1.0-rc.15",
|
|
111
|
+
"integrity": "sha512-mfGmDbr14cPfp8CIqlChgSze/kdQVl2ij4Px5nlf4EOQA74qWhmNnjrJOK0vfXdkJP4J4D97zMBTiwupaHJb9Q==",
|
|
112
112
|
"required": false
|
|
113
113
|
},
|
|
114
114
|
{
|
|
@@ -596,6 +596,7 @@ export declare const SubagentFinishStatusSchema: z.ZodEnum<{
|
|
|
596
596
|
completed: "completed";
|
|
597
597
|
failed: "failed";
|
|
598
598
|
max_duration: "max_duration";
|
|
599
|
+
max_output: "max_output";
|
|
599
600
|
max_steps: "max_steps";
|
|
600
601
|
timed_out: "timed_out";
|
|
601
602
|
}>;
|
|
@@ -1957,6 +1958,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1957
1958
|
completed: "completed";
|
|
1958
1959
|
failed: "failed";
|
|
1959
1960
|
max_duration: "max_duration";
|
|
1961
|
+
max_output: "max_output";
|
|
1960
1962
|
max_steps: "max_steps";
|
|
1961
1963
|
timed_out: "timed_out";
|
|
1962
1964
|
}>;
|
|
@@ -1989,6 +1991,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
1989
1991
|
completed: "completed";
|
|
1990
1992
|
failed: "failed";
|
|
1991
1993
|
max_duration: "max_duration";
|
|
1994
|
+
max_output: "max_output";
|
|
1992
1995
|
max_steps: "max_steps";
|
|
1993
1996
|
timed_out: "timed_out";
|
|
1994
1997
|
}>>;
|
|
@@ -2055,6 +2058,7 @@ export declare const ConversationEventSchema: z.ZodDiscriminatedUnion<[z.ZodObje
|
|
|
2055
2058
|
budget: "budget";
|
|
2056
2059
|
completed: "completed";
|
|
2057
2060
|
max_duration: "max_duration";
|
|
2061
|
+
max_output: "max_output";
|
|
2058
2062
|
max_steps: "max_steps";
|
|
2059
2063
|
}>;
|
|
2060
2064
|
consumedUpToSeq: z.ZodNumber;
|
|
@@ -660,6 +660,7 @@ export const SubagentFinishStatusSchema = z.enum([
|
|
|
660
660
|
"max_steps",
|
|
661
661
|
"max_duration",
|
|
662
662
|
"budget",
|
|
663
|
+
"max_output",
|
|
663
664
|
"aborted",
|
|
664
665
|
"timed_out",
|
|
665
666
|
"failed",
|
|
@@ -1780,8 +1781,11 @@ export const ConversationEventSchema = z.discriminatedUnion("type", [
|
|
|
1780
1781
|
step: count,
|
|
1781
1782
|
})),
|
|
1782
1783
|
ev("run_finished", z.object({
|
|
1783
|
-
/**
|
|
1784
|
-
|
|
1784
|
+
/**
|
|
1785
|
+
* `budget`: a sub-agent stopped at its parent run's token cap (phase C, spec §8.3).
|
|
1786
|
+
* `max_output`: the model's steps kept stopping at the output token limit (issue #951).
|
|
1787
|
+
*/
|
|
1788
|
+
reason: z.enum(["completed", "max_steps", "max_duration", "budget", "max_output"]),
|
|
1785
1789
|
consumedUpToSeq: seqNo,
|
|
1786
1790
|
})),
|
|
1787
1791
|
ev("run_failed", z.object({ error: z.object({ code: z.string(), message: z.string() }) })),
|
package/dist/evals/run-replay.js
CHANGED
|
@@ -667,7 +667,9 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
667
667
|
: {
|
|
668
668
|
type: "run_finished",
|
|
669
669
|
payload: {
|
|
670
|
-
reason: outcome.kind === "max_steps" ||
|
|
670
|
+
reason: outcome.kind === "max_steps" ||
|
|
671
|
+
outcome.kind === "max_duration" ||
|
|
672
|
+
outcome.kind === "max_output"
|
|
671
673
|
? outcome.kind
|
|
672
674
|
: "completed",
|
|
673
675
|
consumedUpToSeq: "consumedUpToSeq" in outcome ? Math.max(outcome.consumedUpToSeq, trigger) : trigger,
|
|
@@ -350,6 +350,8 @@ export declare function summaryText(summary: string): string;
|
|
|
350
350
|
* (同一步的多个结果合并,按该 assistant 消息里 tool_call 的顺序;找不到对应调用的结果不进请求)。
|
|
351
351
|
* 其他事件不进请求。提供 `absorbedUpToSeq` 时,
|
|
352
352
|
* 尚未被吸收的可吸收事件不进请求,运行中途到达的放在吸收它的调用处(见 BuildModelRequestInput)。
|
|
353
|
+
* An `assistant_message` with `stopReason: "max_tokens"` is followed by a `role: "system"`
|
|
354
|
+
* {@link OUTPUT_TRUNCATED_TEXT} (issue #951).
|
|
353
355
|
* 只追加:新事件只会在 messages 末尾追加;唯一的前缀变化来自新的压缩摘要。
|
|
354
356
|
* `step` 与 `agentVersion` 不进请求内容(保证缓存前缀稳定),由调用方写入 `model_call` 事件。
|
|
355
357
|
*/
|
|
@@ -5,6 +5,7 @@ import { isAbsorbable, } from "../../conversations/events.js";
|
|
|
5
5
|
import { catalogText, isAlwaysLoaded } from "../../tools/builtins/tool-search.js";
|
|
6
6
|
import { renderSubagentDelivery } from "../subagents/render.js";
|
|
7
7
|
import { devicePathsAt, devicePathsText } from "./device-paths.js";
|
|
8
|
+
import { OUTPUT_TRUNCATED_TEXT } from "./output-truncated.js";
|
|
8
9
|
import { permissionContextHistory } from "./permission-profile.js";
|
|
9
10
|
import { pluginContextsAfterSummary, pluginContextText } from "./plugin-context.js";
|
|
10
11
|
import { latestProjectRoot, projectRootText } from "./project-root.js";
|
|
@@ -571,6 +572,8 @@ export function summaryText(summary) {
|
|
|
571
572
|
* (同一步的多个结果合并,按该 assistant 消息里 tool_call 的顺序;找不到对应调用的结果不进请求)。
|
|
572
573
|
* 其他事件不进请求。提供 `absorbedUpToSeq` 时,
|
|
573
574
|
* 尚未被吸收的可吸收事件不进请求,运行中途到达的放在吸收它的调用处(见 BuildModelRequestInput)。
|
|
575
|
+
* An `assistant_message` with `stopReason: "max_tokens"` is followed by a `role: "system"`
|
|
576
|
+
* {@link OUTPUT_TRUNCATED_TEXT} (issue #951).
|
|
574
577
|
* 只追加:新事件只会在 messages 末尾追加;唯一的前缀变化来自新的压缩摘要。
|
|
575
578
|
* `step` 与 `agentVersion` 不进请求内容(保证缓存前缀稳定),由调用方写入 `model_call` 事件。
|
|
576
579
|
*/
|
|
@@ -904,6 +907,11 @@ export function buildModelRequest(input) {
|
|
|
904
907
|
if (blocks.length > 0)
|
|
905
908
|
messages.push({ role: "user", content: [...blocks, ...images] });
|
|
906
909
|
}
|
|
910
|
+
// cut off at the output token limit (issue #951): said right after it, from the logged
|
|
911
|
+
// stop reason alone (also when nothing of the reply was kept)
|
|
912
|
+
if (e.payload.stopReason === "max_tokens") {
|
|
913
|
+
messages.push({ role: "system", content: OUTPUT_TRUNCATED_TEXT });
|
|
914
|
+
}
|
|
907
915
|
break;
|
|
908
916
|
case "reminder":
|
|
909
917
|
messages.push({ role: "system", content: e.payload.text });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model step cut off at the output token limit (issue #951). The step's `assistant_message`
|
|
3
|
+
* records `stopReason: "max_tokens"`; providers drop a tool call whose arguments were cut off, so
|
|
4
|
+
* nothing of it runs. Request building renders {@link OUTPUT_TRUNCATED_TEXT} as a system message
|
|
5
|
+
* right after such a message: derived from the logged stop reason alone, so a reconstruction
|
|
6
|
+
* renders the same text and no `DriftReason` is needed. The loop then gives the model another
|
|
7
|
+
* step, up to {@link MAX_TRUNCATED_STEPS} truncated steps in a row, after which the run ends with
|
|
8
|
+
* `max_output`.
|
|
9
|
+
*/
|
|
10
|
+
/** The model-visible text after a step cut off at the output token limit (English). */
|
|
11
|
+
export declare const OUTPUT_TRUNCATED_TEXT: string;
|
|
12
|
+
/**
|
|
13
|
+
* Truncated model steps in a row after which the run ends with `max_output` instead of giving the
|
|
14
|
+
* model another step.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MAX_TRUNCATED_STEPS = 3;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model step cut off at the output token limit (issue #951). The step's `assistant_message`
|
|
3
|
+
* records `stopReason: "max_tokens"`; providers drop a tool call whose arguments were cut off, so
|
|
4
|
+
* nothing of it runs. Request building renders {@link OUTPUT_TRUNCATED_TEXT} as a system message
|
|
5
|
+
* right after such a message: derived from the logged stop reason alone, so a reconstruction
|
|
6
|
+
* renders the same text and no `DriftReason` is needed. The loop then gives the model another
|
|
7
|
+
* step, up to {@link MAX_TRUNCATED_STEPS} truncated steps in a row, after which the run ends with
|
|
8
|
+
* `max_output`.
|
|
9
|
+
*/
|
|
10
|
+
/** The model-visible text after a step cut off at the output token limit (English). */
|
|
11
|
+
export const OUTPUT_TRUNCATED_TEXT = "Your previous response was cut off because it reached the output token limit. " +
|
|
12
|
+
"A tool call that was still being written when it was cut off was incomplete and was not run. " +
|
|
13
|
+
"Continue from where the response stopped. Keep each response, including the input of each " +
|
|
14
|
+
"tool call, well under the limit: split long content across several smaller tool calls.";
|
|
15
|
+
/**
|
|
16
|
+
* Truncated model steps in a row after which the run ends with `max_output` instead of giving the
|
|
17
|
+
* model another step.
|
|
18
|
+
*/
|
|
19
|
+
export const MAX_TRUNCATED_STEPS = 3;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Annotation, END, START, StateGraph } from "@langchain/langgraph";
|
|
2
|
+
import { MAX_TRUNCATED_STEPS } from "./context/output-truncated.js";
|
|
2
3
|
import { MediaCache } from "./media-cache.js";
|
|
3
4
|
import { runFinalWrapUp, runModelStep, } from "./model-call.js";
|
|
4
5
|
import { withExclusiveAdmission } from "./run-execution.js";
|
|
@@ -26,6 +27,7 @@ const LoopState = Annotation.Root({
|
|
|
26
27
|
lastStopReason: Annotation(),
|
|
27
28
|
outcome: Annotation(),
|
|
28
29
|
budgetWrapUp: Annotation(),
|
|
30
|
+
truncatedSteps: Annotation(),
|
|
29
31
|
});
|
|
30
32
|
const INITIAL = {
|
|
31
33
|
step: 0,
|
|
@@ -33,6 +35,7 @@ const INITIAL = {
|
|
|
33
35
|
lastStopReason: null,
|
|
34
36
|
outcome: null,
|
|
35
37
|
budgetWrapUp: null,
|
|
38
|
+
truncatedSteps: null,
|
|
36
39
|
};
|
|
37
40
|
/**
|
|
38
41
|
* prepare 节点在停机信号下抛出:本次 invoke 以它结束,checkpoint 停在 prepare 之前
|
|
@@ -209,8 +212,19 @@ export class LangGraphLoop {
|
|
|
209
212
|
if (r.aborted) {
|
|
210
213
|
return { lastStopReason: "aborted", outcome: timedOut() ? "max_duration" : "aborted" };
|
|
211
214
|
}
|
|
215
|
+
// cut off at the output token limit (issue #951): request building tells the model, and it
|
|
216
|
+
// gets another step, up to MAX_TRUNCATED_STEPS in a row
|
|
217
|
+
if (r.stopReason === "max_tokens") {
|
|
218
|
+
const truncatedSteps = (s.truncatedSteps ?? 0) + 1;
|
|
219
|
+
return {
|
|
220
|
+
lastStopReason: r.stopReason,
|
|
221
|
+
truncatedSteps,
|
|
222
|
+
outcome: truncatedSteps >= MAX_TRUNCATED_STEPS ? "max_output" : null,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
212
225
|
return {
|
|
213
226
|
lastStopReason: r.stopReason,
|
|
227
|
+
truncatedSteps: null,
|
|
214
228
|
outcome: r.stopReason === "tool_use" ? null : "completed",
|
|
215
229
|
};
|
|
216
230
|
};
|
|
@@ -276,7 +290,14 @@ export class LangGraphLoop {
|
|
|
276
290
|
? "wrapUp"
|
|
277
291
|
: "model";
|
|
278
292
|
}, ["model", "wrapUp", END])
|
|
279
|
-
.addConditionalEdges("model", (s) =>
|
|
293
|
+
.addConditionalEdges("model", (s) => {
|
|
294
|
+
if (s.budgetWrapUp === true)
|
|
295
|
+
return "wrapUp";
|
|
296
|
+
if (s.outcome !== null)
|
|
297
|
+
return END;
|
|
298
|
+
// a truncated step has no tool calls to run (providers drop a cut-off one)
|
|
299
|
+
return s.lastStopReason === "max_tokens" ? "prepare" : "tools";
|
|
300
|
+
}, ["tools", "prepare", "wrapUp", END])
|
|
280
301
|
.addEdge("tools", "prepare")
|
|
281
302
|
.addEdge("wrapUp", END)
|
|
282
303
|
.compile({ checkpointer: this.saver });
|
package/dist/runtime/loop.d.ts
CHANGED
|
@@ -114,9 +114,12 @@ export declare const subagentWaitingIdemKey: (childRunId: string, waitId: string
|
|
|
114
114
|
/** The id of a run's `subagents` wait in `step` (part of BullMQ job ids, so no `:`). */
|
|
115
115
|
export declare const subagentsWaitId: (runId: string, step: number) => string;
|
|
116
116
|
export type LoopOutcome =
|
|
117
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* `budget`: a sub-agent run stopped at its parent run's token cap (phase C). `max_output`: the
|
|
119
|
+
* model's steps kept stopping at the output token limit (issue #951).
|
|
120
|
+
*/
|
|
118
121
|
{
|
|
119
|
-
kind: "completed" | "max_steps" | "max_duration" | "budget";
|
|
122
|
+
kind: "completed" | "max_steps" | "max_duration" | "budget" | "max_output";
|
|
120
123
|
consumedUpToSeq: number;
|
|
121
124
|
} | {
|
|
122
125
|
kind: "aborted";
|
|
@@ -13,6 +13,8 @@ export function subagentStatusText(status, opts = {}) {
|
|
|
13
13
|
return "stopped at the time limit; the reply may be partial";
|
|
14
14
|
case "budget":
|
|
15
15
|
return "stopped: token budget used up";
|
|
16
|
+
case "max_output":
|
|
17
|
+
return "stopped: its replies kept reaching the output token limit; the reply may be partial";
|
|
16
18
|
case "aborted":
|
|
17
19
|
return opts.abortedBy === "parent" ? "stopped with this run" : "stopped by the user";
|
|
18
20
|
case "timed_out":
|
|
@@ -8,6 +8,6 @@ export type { ClassifierAnswer, ReviewClassifierDeps, ReviewClassifierInput, Rev
|
|
|
8
8
|
export { boundMessages, callReviewModel, classifierMessage, fitReviewInput, fitReviewText, newReviewTag, parseReviewAnswer, personMessagesText, REVIEW_ASK_REASON, REVIEW_MAX_OUTPUT_TOKENS, REVIEW_PURPOSE, REVIEW_SYSTEM_PROMPT, REVIEW_TRUNCATED_ASK_REASON, REVIEW_TRUNCATED_MARKER, REVIEW_UNAVAILABLE_PREFIX, readPersonMessages, reviewModelLimits, reviewSystemPrompt, runClassifier, } from "./classifier.js";
|
|
9
9
|
export type { CommandReview, ReviewCall, ReviewInput, ReviewVerdict } from "./review.service.js";
|
|
10
10
|
export { CommandReviewService, REVIEW_REASONS, } from "./review.service.js";
|
|
11
|
-
export { parseCommand, reviewRules, reviewWrite, writtenPaths, } from "./rules.js";
|
|
11
|
+
export { parseCommand, reviewRead, reviewRules, reviewWrite, writtenPaths, } from "./rules.js";
|
|
12
12
|
export type { ParsedCommand, Redirect, ReviewFacts, ReviewResult, RuleHit, RuleOutcome, SimpleCommand, } from "./types.js";
|
|
13
13
|
export { applySessionGrants, isSessionGrantableRule } from "./types.js";
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { boundMessages, callReviewModel, classifierMessage, fitReviewInput, fitReviewText, newReviewTag, parseReviewAnswer, personMessagesText, REVIEW_ASK_REASON, REVIEW_MAX_OUTPUT_TOKENS, REVIEW_PURPOSE, REVIEW_SYSTEM_PROMPT, REVIEW_TRUNCATED_ASK_REASON, REVIEW_TRUNCATED_MARKER, REVIEW_UNAVAILABLE_PREFIX, readPersonMessages, reviewModelLimits, reviewSystemPrompt, runClassifier, } from "./classifier.js";
|
|
8
8
|
export { CommandReviewService, REVIEW_REASONS, } from "./review.service.js";
|
|
9
|
-
export { parseCommand, reviewRules, reviewWrite, writtenPaths, } from "./rules.js";
|
|
9
|
+
export { parseCommand, reviewRead, reviewRules, reviewWrite, writtenPaths, } from "./rules.js";
|
|
10
10
|
export { applySessionGrants, isSessionGrantableRule } from "./types.js";
|
|
@@ -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.";
|
package/package.json
CHANGED