@tangle-network/agent-provider-tangle 5.0.18 → 5.0.19
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/tangle-events.js +19 -6
- package/package.json +1 -1
package/dist/tangle-events.js
CHANGED
|
@@ -184,14 +184,27 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
|
|
|
184
184
|
}
|
|
185
185
|
const usage = tokenUsageFromData(data);
|
|
186
186
|
const declaredModes = [record.usageMode, data.usageMode].filter((mode) => mode !== undefined);
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
const unreported = declaredModes[0] === "unreported";
|
|
188
|
+
const validUsageModes = unreported
|
|
189
|
+
? terminal &&
|
|
190
|
+
data.tokensKnown === false &&
|
|
191
|
+
usage === undefined &&
|
|
192
|
+
data.usage === undefined &&
|
|
193
|
+
data.tokenUsage === undefined &&
|
|
194
|
+
data.costUsd === undefined &&
|
|
195
|
+
data.totalCostUsd === undefined &&
|
|
196
|
+
declaredModes.every((mode) => mode === "unreported")
|
|
197
|
+
: declaredModes.every((mode) => mode === "delta" || mode === "cumulative") &&
|
|
198
|
+
(declaredModes.length !== 2 || declaredModes[0] === declaredModes[1]);
|
|
199
|
+
if (!validUsageModes) {
|
|
189
200
|
throw new Error("Tangle Sandbox event contained invalid or conflicting usage modes");
|
|
190
201
|
}
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
const usageMode =
|
|
194
|
-
|
|
202
|
+
// Agent Container's unreported terminal carries no measured usage and has no
|
|
203
|
+
// delta/cumulative semantics. Other terminal receipts default to cumulative.
|
|
204
|
+
const usageMode = unreported
|
|
205
|
+
? undefined
|
|
206
|
+
: declaredModes[0] ??
|
|
207
|
+
(terminal ? "cumulative" : undefined);
|
|
195
208
|
// Preserve the public resume key without promoting it to native attribution.
|
|
196
209
|
const normalized = normalizeSandboxEvent(record.type, data, identity);
|
|
197
210
|
return {
|