@cerebriline/agents 4.100.251 → 4.100.253
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/agent-runtime.d.ts +2 -0
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -46
- package/dist/reasoning-loop-guard.d.ts +39 -2
- package/dist/reasoning-loop-guard.d.ts.map +1 -1
- package/dist/tool-call-assembly.d.ts +102 -0
- package/dist/tool-call-assembly.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* 2 of 5 healthy blocks from a successful run -- fine for offline labelling,
|
|
32
32
|
* unusable for a guard that aborts live turns.
|
|
33
33
|
*/
|
|
34
|
-
import type { ReasoningLoopDetectionConfig } from "@cerebriline/shared";
|
|
34
|
+
import type { AgentMessage, ReasoningLoopDetectionConfig } from "@cerebriline/shared";
|
|
35
35
|
/**
|
|
36
36
|
* The detector's thresholds. Defined in `@cerebriline/shared` so a host can set them
|
|
37
37
|
* through `execution.reasoningLoopDetection` without depending on this package.
|
|
@@ -56,13 +56,41 @@ export interface ReasoningLoopVerdict {
|
|
|
56
56
|
* tool-call loop detector follows.
|
|
57
57
|
*/
|
|
58
58
|
export declare function describeReasoningLoop(v: ReasoningLoopVerdict): string;
|
|
59
|
+
/**
|
|
60
|
+
* What the model was handed in this conversation: the user's text and every
|
|
61
|
+
* tool result, as plain text. Not its own earlier turns -- a loop the model
|
|
62
|
+
* wrote last turn must not excuse the same loop this turn.
|
|
63
|
+
*/
|
|
64
|
+
export declare function contentGivenToModel(messages: readonly AgentMessage[]): string;
|
|
65
|
+
export interface ReasoningLoopGuardOptions {
|
|
66
|
+
/**
|
|
67
|
+
* The content the model was given, asked for only when the guard is about
|
|
68
|
+
* to trip. Repetition that is already in it, at least as long, is the model
|
|
69
|
+
* restating what it read and not a collapse.
|
|
70
|
+
*
|
|
71
|
+
* The run it comes from (pandorum, session 91q5q, 2026-08-03): asked to
|
|
72
|
+
* embed a sound in a page, the model read `coin.mp3` as base64 and copied
|
|
73
|
+
* it into its reasoning. The file's padding is 484 `V` characters in a row,
|
|
74
|
+
* and thirteen `VVVV` is a phrase cycle. Four blocks of that session are
|
|
75
|
+
* that; a fifth ran on to 2,942 where the file has 484, and is the collapse
|
|
76
|
+
* the guard exists for. So the measure is length against the source, never
|
|
77
|
+
* "it appears in the source". Replayed over 22,252 stored reasoning blocks
|
|
78
|
+
* and 65,716 recorded ones, this excuses those four blocks and no other.
|
|
79
|
+
*/
|
|
80
|
+
given?: () => string;
|
|
81
|
+
}
|
|
59
82
|
export declare class ReasoningLoopGuard {
|
|
60
83
|
private readonly cfg;
|
|
84
|
+
private readonly given;
|
|
61
85
|
private chars;
|
|
62
86
|
private lines;
|
|
87
|
+
/** Every completed line of the block, kept only when there is a source. */
|
|
88
|
+
private history;
|
|
63
89
|
private pending;
|
|
64
90
|
private verdict;
|
|
65
|
-
|
|
91
|
+
private source;
|
|
92
|
+
private readonly sourceRuns;
|
|
93
|
+
constructor(config?: Partial<ReasoningLoopGuardConfig>, options?: ReasoningLoopGuardOptions);
|
|
66
94
|
get tripped(): ReasoningLoopVerdict | null;
|
|
67
95
|
/**
|
|
68
96
|
* Feed one reasoning delta. Returns a verdict the first time the block is
|
|
@@ -70,6 +98,15 @@ export declare class ReasoningLoopGuard {
|
|
|
70
98
|
* caller that keeps streaming does not act on it twice.
|
|
71
99
|
*/
|
|
72
100
|
push(delta: string): ReasoningLoopVerdict | null;
|
|
101
|
+
/** The source, read once, and only when a verdict is about to be given. */
|
|
102
|
+
private readSource;
|
|
103
|
+
private remembered;
|
|
104
|
+
/** Longest run of `unit` back to back in the source, in repeats. */
|
|
105
|
+
private phraseRunInSource;
|
|
106
|
+
/** Longest run of this block of lines back to back in the source. */
|
|
107
|
+
private blockRunInSource;
|
|
108
|
+
/** Longest stretch of source lines drawn only from `distinct`. */
|
|
109
|
+
private stretchInSource;
|
|
73
110
|
private detectLowUniqueness;
|
|
74
111
|
private detectLineCycle;
|
|
75
112
|
private detectPhraseCycle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reasoning-loop-guard.d.ts","sourceRoot":"","sources":["../src/reasoning-loop-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"reasoning-loop-guard.d.ts","sourceRoot":"","sources":["../src/reasoning-loop-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AAEpE,eAAO,MAAM,4BAA4B,EAAE,wBAU1C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAC1B,gBAAgB,GAChB,YAAY,GACZ,cAAc,CAAC;AAElB,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,iBAAiB,CAAC;IACxB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAWrE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAsB7E;AASD,MAAM,WAAW,yBAAyB;IACzC;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA2B;IAC/C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA6B;IACnD,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAgB;IAC7B,2EAA2E;IAC3E,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,MAAM,CAAgD;IAC9D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;gBAGvD,MAAM,GAAE,OAAO,CAAC,wBAAwB,CAAM,EAC9C,OAAO,GAAE,yBAA8B;IAMxC,IAAI,OAAO,IAAI,oBAAoB,GAAG,IAAI,CAEzC;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI;IAyBhD,2EAA2E;IAC3E,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,UAAU;IAYlB,oEAAoE;IACpE,OAAO,CAAC,iBAAiB;IAoBzB,qEAAqE;IACrE,OAAO,CAAC,gBAAgB;IA+BxB,kEAAkE;IAClE,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,mBAAmB;IA6B3B,OAAO,CAAC,eAAe;IAoDvB,OAAO,CAAC,iBAAiB;CAwBzB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a model's streamed tool-call events into the calls the agent runs.
|
|
3
|
+
*
|
|
4
|
+
* The runtime drives a `ToolCallAssembler` for every request, and
|
|
5
|
+
* `finishToolCalls` is the same assembly for a caller that has the model's
|
|
6
|
+
* events but no agent loop -- a harness measuring what the provider layer and
|
|
7
|
+
* this step do to a tool call (automaticum's BFCL proxy cell, #1535). Both run
|
|
8
|
+
* this code, so a measurement through the second is a measurement of the
|
|
9
|
+
* first.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentMessagePart, AgentModelEvent, AgentModelFinishReason, AgentToolCallPart, UnparsedToolCall } from "@cerebriline/shared";
|
|
12
|
+
export type ToolCallDeltaEvent = Extract<AgentModelEvent, {
|
|
13
|
+
type: "tool-call-delta";
|
|
14
|
+
}>;
|
|
15
|
+
/** A call the model made that cannot be run, and why. */
|
|
16
|
+
export interface InvalidToolCall {
|
|
17
|
+
toolCallId: string;
|
|
18
|
+
toolName?: string;
|
|
19
|
+
input: Record<string, unknown>;
|
|
20
|
+
reason: "missing_name" | "missing_arguments" | "invalid_arguments";
|
|
21
|
+
}
|
|
22
|
+
/** One call as its deltas have assembled it so far. */
|
|
23
|
+
export interface ToolCallAssembly {
|
|
24
|
+
toolCallId: string;
|
|
25
|
+
toolName?: string;
|
|
26
|
+
/** The argument text exactly as the model streamed it. */
|
|
27
|
+
inputText: string;
|
|
28
|
+
/** Arguments a provider handed over already parsed. */
|
|
29
|
+
inputValue?: unknown;
|
|
30
|
+
metadata?: unknown;
|
|
31
|
+
}
|
|
32
|
+
/** What one assembled call came to. */
|
|
33
|
+
export interface FinishedToolCall {
|
|
34
|
+
/** Absent when the call has no name: there is nothing to run. */
|
|
35
|
+
call?: AgentToolCallPart;
|
|
36
|
+
invalid?: InvalidToolCall;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Assembles tool calls from `tool-call-delta` events, keyed the way providers
|
|
40
|
+
* address them: by call id, else by index, else in arrival order.
|
|
41
|
+
*
|
|
42
|
+
* Calls whose execution belongs to the provider (`event.execution` set) are
|
|
43
|
+
* not assembled here; the runtime reports those as they happen.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ToolCallAssembler {
|
|
46
|
+
private readonly assemblies;
|
|
47
|
+
private nextIndex;
|
|
48
|
+
/**
|
|
49
|
+
* Add one delta. `created` is true for the first delta of a call, which is
|
|
50
|
+
* where the call sits among the turn's text and reasoning.
|
|
51
|
+
*/
|
|
52
|
+
add(event: ToolCallDeltaEvent): {
|
|
53
|
+
key: string;
|
|
54
|
+
created: boolean;
|
|
55
|
+
};
|
|
56
|
+
get(key: string): Readonly<ToolCallAssembly> | undefined;
|
|
57
|
+
/** Argument characters assembled across every call so far. */
|
|
58
|
+
inputChars(): number;
|
|
59
|
+
/**
|
|
60
|
+
* The call `key` names, parsed. `finishReason` matters: a call cut off at
|
|
61
|
+
* the output cap is told so, not that its JSON was invalid.
|
|
62
|
+
*/
|
|
63
|
+
finish(key: string, finishReason?: AgentModelFinishReason): FinishedToolCall;
|
|
64
|
+
}
|
|
65
|
+
/** The tools a turn was offered, as far as finishing their calls needs. */
|
|
66
|
+
export interface FinishToolCallsTool {
|
|
67
|
+
name: string;
|
|
68
|
+
inputSchema: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
export interface FinishedTurn {
|
|
71
|
+
/** Text, reasoning and tool calls in the order the model produced them. */
|
|
72
|
+
content: AgentMessagePart[];
|
|
73
|
+
/** The calls that would be run, inputs normalised as the runtime does. */
|
|
74
|
+
toolCalls: AgentToolCallPart[];
|
|
75
|
+
invalidToolCalls: InvalidToolCall[];
|
|
76
|
+
text: string;
|
|
77
|
+
reasoning: string;
|
|
78
|
+
finishReason: AgentModelFinishReason;
|
|
79
|
+
/**
|
|
80
|
+
* A tool call the model wrote as text, which the provider could not read.
|
|
81
|
+
* Looked for only when the turn made no calls, as the runtime does.
|
|
82
|
+
*/
|
|
83
|
+
unparsedToolCall?: UnparsedToolCall;
|
|
84
|
+
/** The provider's error, when the stream ended on one. */
|
|
85
|
+
error?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Everything between a model's events and the calls the runtime would run,
|
|
89
|
+
* without the agent loop: assembly, argument parsing, the cut-off verdict,
|
|
90
|
+
* schema normalisation of JSON-like strings, and the scan for a call written
|
|
91
|
+
* as text. Nothing is executed.
|
|
92
|
+
*
|
|
93
|
+
* Pass `tools` to normalise each call's input against its tool's schema, the
|
|
94
|
+
* step the runtime takes just before running a call. A call to a tool not in
|
|
95
|
+
* the list is returned as parsed.
|
|
96
|
+
*/
|
|
97
|
+
export declare function finishToolCalls(events: Iterable<AgentModelEvent> | AsyncIterable<AgentModelEvent>, options?: {
|
|
98
|
+
tools?: readonly FinishToolCallsTool[];
|
|
99
|
+
}): Promise<FinishedTurn>;
|
|
100
|
+
export declare function mergeToolMetadata(current: unknown, patch: unknown): unknown;
|
|
101
|
+
export declare function buildInvalidToolInput(value: string, parseError?: string): Record<string, unknown>;
|
|
102
|
+
//# sourceMappingURL=tool-call-assembly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call-assembly.d.ts","sourceRoot":"","sources":["../src/tool-call-assembly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,EAChB,MAAM,eAAe,CAAC;AAOvB,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACvC,eAAe,EACf;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,CAC3B,CAAC;AAEF,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,cAAc,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;CACnE;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,uCAAuC;AACvC,MAAM,WAAW,gBAAgB;IAChC,iEAAiE;IACjE,IAAI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CAAO,GACtD,OAAO,CAAC,YAAY,CAAC,CA8GvB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAW3E;AA8DD,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerebriline/agents",
|
|
3
|
-
"version": "4.100.
|
|
3
|
+
"version": "4.100.253",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/mann1x/cline.git",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"nanoid": "^5.1.7",
|
|
12
|
-
"@cerebriline/llms": "4.100.
|
|
13
|
-
"@cerebriline/shared": "4.100.
|
|
12
|
+
"@cerebriline/llms": "4.100.253",
|
|
13
|
+
"@cerebriline/shared": "4.100.253"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|