@tangle-network/agent-provider-cli-bridge 0.9.2 → 0.9.3
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.
|
@@ -12,5 +12,7 @@ export declare function streamCliBridgeSessionEvents(options: CliBridgeProviderO
|
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
}): AsyncIterable<AgentEnvironmentEvent>;
|
|
14
14
|
export declare function collectCliBridgeTurnResult(source: AsyncIterable<AgentEnvironmentEvent>, run: CliBridgeRun, options: CliBridgeProviderOptions, transport: CliBridgeTransport, signal?: AbortSignal): Promise<AgentTurnResult>;
|
|
15
|
+
/** Keep reasoning and tool updates out of the assistant's visible result text. */
|
|
16
|
+
export declare function visibleTextDelta(event: AgentEnvironmentEvent): string | undefined;
|
|
15
17
|
/** Sum the usage a run reported across its events into one total. */
|
|
16
18
|
export declare function addTokenUsage(current: TokenUsage | undefined, next: TokenUsage | undefined): TokenUsage | undefined;
|
|
@@ -251,8 +251,10 @@ export async function collectCliBridgeTurnResult(source, run, options, transport
|
|
|
251
251
|
if (typeof finalText === "string") {
|
|
252
252
|
text = finalText;
|
|
253
253
|
}
|
|
254
|
-
else
|
|
255
|
-
|
|
254
|
+
else {
|
|
255
|
+
const delta = visibleTextDelta(event);
|
|
256
|
+
if (delta !== undefined)
|
|
257
|
+
text += delta;
|
|
256
258
|
}
|
|
257
259
|
usage = addTokenUsage(usage, event.usage);
|
|
258
260
|
const eventModel = event.data.model;
|
|
@@ -317,6 +319,25 @@ export async function collectCliBridgeTurnResult(source, run, options, transport
|
|
|
317
319
|
events,
|
|
318
320
|
};
|
|
319
321
|
}
|
|
322
|
+
/** Keep reasoning and tool updates out of the assistant's visible result text. */
|
|
323
|
+
export function visibleTextDelta(event) {
|
|
324
|
+
if (event.normalized?.type === "message.part.updated") {
|
|
325
|
+
if (event.normalized.part.type === "text" &&
|
|
326
|
+
typeof event.normalized.delta === "string") {
|
|
327
|
+
return event.normalized.delta;
|
|
328
|
+
}
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
const part = event.data.part;
|
|
332
|
+
if (typeof part === "object" && part !== null && !Array.isArray(part)) {
|
|
333
|
+
return "type" in part &&
|
|
334
|
+
part.type === "text" &&
|
|
335
|
+
typeof event.data.delta === "string"
|
|
336
|
+
? event.data.delta
|
|
337
|
+
: undefined;
|
|
338
|
+
}
|
|
339
|
+
return typeof event.data.delta === "string" ? event.data.delta : undefined;
|
|
340
|
+
}
|
|
320
341
|
/** Sum the usage a run reported across its events into one total. */
|
|
321
342
|
export function addTokenUsage(current, next) {
|
|
322
343
|
if (!next)
|
package/package.json
CHANGED