@cerebriline/agents 4.100.252 → 4.100.254
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 +13 -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 +51 -49
- package/dist/tool-call-assembly.d.ts +102 -0
- package/dist/tool-call-assembly.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -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,C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BAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,YAAY;IAC5B,2EAA2E;IAC3E,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,0EAA0E;IAC1E,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,sBAAsB,CAAC;IACrC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,aAAa,CAAC,eAAe,CAAC,EAClE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAA;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.254",
|
|
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.254",
|
|
13
|
+
"@cerebriline/shared": "4.100.254"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|