@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
|
@@ -6,37 +6,71 @@ import type { ResolvedTool } from "../tools/registry.js";
|
|
|
6
6
|
* holds the step (and a Stop) past this bound for a display-only base.
|
|
7
7
|
*/
|
|
8
8
|
export declare const WRITE_BASE_SETTLE_MS = 3000;
|
|
9
|
+
/** How a watched property's value is capped: dropped past the cap, or only its head kept. */
|
|
10
|
+
export interface WatchedProp {
|
|
11
|
+
name: string;
|
|
12
|
+
/** The most raw characters kept (default {@link VALUE_MAX_CHARS}). */
|
|
13
|
+
maxChars?: number;
|
|
14
|
+
/** `drop` (default): a longer value is no value; `keep-head`: the head stays readable. */
|
|
15
|
+
overflow?: "drop" | "keep-head";
|
|
16
|
+
}
|
|
9
17
|
/**
|
|
10
|
-
* Reads
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
18
|
+
* Reads top-level string properties of a JSON object streamed in fragments, without re-reading the
|
|
19
|
+
* buffer: each {@link feed} scans only the new fragment with the carried state. For each watched
|
|
20
|
+
* property it records when its string value opened and closed (one event counter, so the order of
|
|
21
|
+
* two properties is known even within one fragment), its raw head while open ({@link prefix}),
|
|
22
|
+
* and its value once the closing quote arrived (a half path is not a path). A property of a nested
|
|
23
|
+
* object or array, a non-string value, a top level that is not an object, or a value above its cap
|
|
24
|
+
* in `drop` mode gives nothing. The first occurrence of a key counts.
|
|
15
25
|
*/
|
|
16
|
-
export declare class
|
|
17
|
-
private readonly prop;
|
|
26
|
+
export declare class TopLevelStrings {
|
|
18
27
|
private depth;
|
|
19
28
|
private inString;
|
|
20
29
|
private escaped;
|
|
21
30
|
/** At depth 1, the next string is a key. */
|
|
22
31
|
private expectKey;
|
|
23
|
-
/** What the string being read is. */
|
|
32
|
+
/** What the string being read is: a key, a watched value, or anything else. */
|
|
24
33
|
private role;
|
|
25
|
-
/** The raw text of the key
|
|
26
|
-
private
|
|
34
|
+
/** The raw text of the key being read. */
|
|
35
|
+
private keyRaw;
|
|
27
36
|
/** The top-level key read last, until its `:`; null when unknown or too long. */
|
|
28
37
|
private key;
|
|
29
38
|
/** The key whose value comes next at depth 1. */
|
|
30
39
|
private valueOf;
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
private events;
|
|
41
|
+
private ended;
|
|
42
|
+
private readonly states;
|
|
43
|
+
constructor(props: readonly WatchedProp[]);
|
|
44
|
+
/** Scans `fragment`. */
|
|
45
|
+
feed(fragment: string): void;
|
|
46
|
+
/** The property's value once its string closed; null before (and when there is none). */
|
|
47
|
+
value(prop: string): string | null;
|
|
48
|
+
/** When the property's string value opened and closed (event numbers; 0: not yet). */
|
|
49
|
+
timing(prop: string): {
|
|
50
|
+
openedAt: number;
|
|
51
|
+
closedAt: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The decoded head of the property's string value so far (open or closed), an unfinished escape
|
|
55
|
+
* at its end left out; null when its value never opened or is dead.
|
|
56
|
+
*/
|
|
57
|
+
prefix(prop: string): string | null;
|
|
36
58
|
private step;
|
|
59
|
+
/** The value about to come at depth 1 is not a string: its property gives nothing. */
|
|
60
|
+
private killValueOf;
|
|
37
61
|
private keep;
|
|
38
62
|
private closeString;
|
|
39
|
-
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Reads the value of one top-level string property of a JSON object streamed in fragments
|
|
66
|
+
* ({@link TopLevelStrings} watching that one property).
|
|
67
|
+
*/
|
|
68
|
+
export declare class TopLevelStringProperty {
|
|
69
|
+
private readonly prop;
|
|
70
|
+
private readonly scan;
|
|
71
|
+
constructor(prop: string);
|
|
72
|
+
/** Scans `fragment`; returns the property's value once known, null before (and when none). */
|
|
73
|
+
feed(fragment: string): string | null;
|
|
40
74
|
}
|
|
41
75
|
/** The value of a top-level string property once its closing quote arrived; null before. */
|
|
42
76
|
export declare function closedStringProperty(json: string, prop: string): string | null;
|
|
@@ -57,31 +91,80 @@ export interface WriteBase {
|
|
|
57
91
|
text: string;
|
|
58
92
|
sha256: string;
|
|
59
93
|
}
|
|
60
|
-
/** Reads
|
|
94
|
+
/** Reads `Write` bases; never throws for a missing base. */
|
|
61
95
|
export interface WriteBaseReader {
|
|
96
|
+
/** The base of `path`; null whenever there is none to show. */
|
|
62
97
|
read(input: {
|
|
63
98
|
conversationId: string;
|
|
64
99
|
path: string;
|
|
65
100
|
signal: AbortSignal;
|
|
66
101
|
}): Promise<WriteBase | null>;
|
|
102
|
+
/**
|
|
103
|
+
* The paths of the conversation's newest recorded file states, one per path, newest first, at
|
|
104
|
+
* most `limit` (the candidates of a guessed base).
|
|
105
|
+
*/
|
|
106
|
+
recentPaths(input: {
|
|
107
|
+
conversationId: string;
|
|
108
|
+
limit: number;
|
|
109
|
+
}): Promise<string[]>;
|
|
110
|
+
/** A model's path as `Write` takes it, normalized; null when it gets no base (synchronous). */
|
|
111
|
+
normalize(rawPath: string): string | null;
|
|
67
112
|
}
|
|
113
|
+
/** The most candidate files a guessed base reads (spec 2026-11-27 §4.2). */
|
|
114
|
+
export declare const WRITE_BASE_CANDIDATES = 3;
|
|
115
|
+
/** The non-blank complete lines of `content` after which the guess is chosen (§4.3). */
|
|
116
|
+
export declare const GUESS_PREFIX_LINES = 8;
|
|
117
|
+
/** The least share of the prefix's lines a candidate must contain to be guessed (§4.3). */
|
|
118
|
+
export declare const GUESS_MIN_SCORE = 0.6;
|
|
119
|
+
/** The least lead of the guessed candidate over the runner-up (§4.3). */
|
|
120
|
+
export declare const GUESS_MIN_MARGIN = 0.2;
|
|
68
121
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
122
|
+
* The non-blank lines (trimmed) of a streamed text's head: its complete lines, and the last one
|
|
123
|
+
* too once the text is `complete`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function guessLines(text: string, complete: boolean): string[];
|
|
126
|
+
/**
|
|
127
|
+
* The candidate a guessed base shows (§4.3), or null: the share of `lines` found among a
|
|
128
|
+
* candidate's lines (trimmed) is its score; the best wins with at least {@link GUESS_MIN_SCORE}
|
|
129
|
+
* and a lead of {@link GUESS_MIN_MARGIN} over the runner-up. No lines: no guess.
|
|
130
|
+
*/
|
|
131
|
+
export declare function chooseGuess<T extends {
|
|
132
|
+
text: string;
|
|
133
|
+
}>(lines: readonly string[], candidates: readonly T[]): T | null;
|
|
134
|
+
/**
|
|
135
|
+
* Watches one model stream attempt's tool calls (streaming tool input spec §4.1, the guess of spec
|
|
136
|
+
* 2026-11-27 §4): a call whose tool declares `inputView.kind: "file_write"` gets its base read once
|
|
137
|
+
* its path property closed, without blocking the stream. When the call's `content` starts before
|
|
138
|
+
* its path closed, the conversation's newest recorded files are read as candidates, and once
|
|
139
|
+
* enough of the content streamed the one it matches clearly goes out as a guessed base; when the
|
|
140
|
+
* path closes, a verdict confirms or withdraws it at once (a withdrawn guess is followed by the
|
|
141
|
+
* exact read of the real path). A read that resolves after `signal` aborted (a step reset, the
|
|
142
|
+
* stream's end, the run's abort) emits nothing; a read that throws is logged and dropped. The
|
|
143
|
+
* attempt aborts `signal` and then awaits {@link settle}, so no admission starts after its step
|
|
144
|
+
* moves on (each read checks the signal right before its admission) and a read still running
|
|
145
|
+
* normally ends with it. The wait is bounded ({@link WRITE_BASE_SETTLE_MS}): a read whose
|
|
146
|
+
* provider ignores the abort is logged once and left to end in the background. {@link settle}
|
|
147
|
+
* also logs one `write input order` line per watched call.
|
|
77
148
|
*/
|
|
78
149
|
export declare function writeBaseWatcher(deps: {
|
|
79
150
|
reader: WriteBaseReader;
|
|
80
151
|
inputViewOf(toolName: string): ToolInputView | undefined;
|
|
81
|
-
|
|
152
|
+
/** A base: exact, or a guess naming the candidate's path. */
|
|
153
|
+
emit(callId: string, base: WriteBase & {
|
|
154
|
+
guess?: {
|
|
155
|
+
path: string;
|
|
156
|
+
};
|
|
157
|
+
}): void;
|
|
158
|
+
/** The path closed on a guessed base: `confirmed` when it is the guessed file. */
|
|
159
|
+
verdict(callId: string, confirmed: boolean): void;
|
|
82
160
|
conversationId: string;
|
|
161
|
+
/** The model the attempt streams from (only for the log line). */
|
|
162
|
+
model?: {
|
|
163
|
+
provider: string;
|
|
164
|
+
model: string;
|
|
165
|
+
};
|
|
83
166
|
signal: AbortSignal;
|
|
84
|
-
log: Pick<Logger, "warn">;
|
|
167
|
+
log: Pick<Logger, "warn" | "info">;
|
|
85
168
|
/** The bound of {@link settle} in milliseconds (default {@link WRITE_BASE_SETTLE_MS}). */
|
|
86
169
|
settleMs?: number;
|
|
87
170
|
}): {
|