@tangle-network/agent-provider-cli-bridge 2.0.13 → 2.0.14
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/retained-stream.js +13 -1
- package/package.json +1 -1
package/dist/retained-stream.js
CHANGED
|
@@ -91,9 +91,18 @@ export async function* streamCliBridgeTurn(options, turn, requestBody, transport
|
|
|
91
91
|
const error = parsed.error;
|
|
92
92
|
const message = typeof error.message === "string" ? error.message : "cli-bridge error";
|
|
93
93
|
const cancelled = error.type === "run_cancelled";
|
|
94
|
+
// The Bridge's machine code and HTTP status classify the failure; the message only describes it.
|
|
95
|
+
const code = typeof error.type === "string" && error.type ? error.type : undefined;
|
|
96
|
+
const status = typeof error.status === "number" && Number.isInteger(error.status) &&
|
|
97
|
+
error.status >= 400 && error.status <= 599 ? error.status : undefined;
|
|
94
98
|
yield* retainedEventsWithIdentity([{
|
|
95
99
|
type: "status",
|
|
96
|
-
data: {
|
|
100
|
+
data: {
|
|
101
|
+
status: cancelled ? "cancelled" : "failed",
|
|
102
|
+
error: message,
|
|
103
|
+
...(code === undefined ? {} : { errorCode: code }),
|
|
104
|
+
...(status === undefined ? {} : { statusCode: status }),
|
|
105
|
+
},
|
|
97
106
|
normalized: {
|
|
98
107
|
type: "status",
|
|
99
108
|
status: cancelled ? "cancelled" : "failed",
|
|
@@ -147,6 +156,8 @@ export async function* streamCliBridgeTurn(options, turn, requestBody, transport
|
|
|
147
156
|
data: {
|
|
148
157
|
...identityData,
|
|
149
158
|
...(nextModelRequests === undefined ? {} : { modelRequests: nextModelRequests }),
|
|
159
|
+
// The Bridge estimates counters for a CLI that reported none; they are not measured tokens.
|
|
160
|
+
...(rawUsage?.estimated === true ? { tokensKnown: false } : {}),
|
|
150
161
|
},
|
|
151
162
|
...(nextUsage ? { usage: nextUsage } : {}),
|
|
152
163
|
usageMode: "delta",
|
|
@@ -384,6 +395,7 @@ async function* finishCliBridgeStream([options, turn, requestBody, transport, ru
|
|
|
384
395
|
...(finalModelRequests === undefined
|
|
385
396
|
? {}
|
|
386
397
|
: { modelRequests: finalModelRequests }),
|
|
398
|
+
...(result.providerUsage?.estimated === true ? { tokensKnown: false } : {}),
|
|
387
399
|
},
|
|
388
400
|
...(result.usage ? { usage: result.usage } : {}),
|
|
389
401
|
...(result.providerUsage ? { usageMode: "cumulative" } : {}),
|
package/package.json
CHANGED