@tangle-network/agent-provider-tangle 1.1.5 → 1.1.6
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 +10 -0
- package/package.json +3 -3
package/dist/tangle-events.js
CHANGED
|
@@ -173,6 +173,15 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
const usage = tokenUsageFromData(data);
|
|
176
|
+
const declaredModes = [record.usageMode, data.usageMode].filter((mode) => mode !== undefined);
|
|
177
|
+
if (declaredModes.some((mode) => mode !== "delta" && mode !== "cumulative") ||
|
|
178
|
+
(declaredModes.length === 2 && declaredModes[0] !== declaredModes[1])) {
|
|
179
|
+
throw new Error("Tangle Sandbox event contained invalid or conflicting usage modes");
|
|
180
|
+
}
|
|
181
|
+
// Only terminal turn receipts have established aggregate semantics.
|
|
182
|
+
// Other event names do not prove whether their usage is incremental.
|
|
183
|
+
const usageMode = declaredModes[0] ??
|
|
184
|
+
(record.type === "result" || record.type === "done" ? "cumulative" : undefined);
|
|
176
185
|
// The session id reaches the normalized event whichever position carried it,
|
|
177
186
|
// including the native id an execution-bound stream just accepted as content.
|
|
178
187
|
const normalized = normalizeSandboxEvent(record.type, data, identity);
|
|
@@ -184,6 +193,7 @@ export function environmentEventFromSandboxEvent(event, expected = {}) {
|
|
|
184
193
|
// Absent rather than zeroed: an event that reported no usage must not
|
|
185
194
|
// contribute a total to whatever sums these events.
|
|
186
195
|
...(usage ? { usage } : {}),
|
|
196
|
+
...(usageMode === undefined ? {} : { usageMode }),
|
|
187
197
|
providerEvent: event,
|
|
188
198
|
};
|
|
189
199
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"LICENSE"
|
|
92
92
|
],
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"@tangle-network/agent-interface": "^2.
|
|
94
|
+
"@tangle-network/agent-interface": "^2.4.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@tangle-network/sandbox": ">=0.34.6 <1.0.0"
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@types/node": "26.4.1",
|
|
109
109
|
"typescript": "7.0.2",
|
|
110
110
|
"vitest": "4.1.11",
|
|
111
|
-
"@tangle-network/agent-provider-testkit": "0.
|
|
111
|
+
"@tangle-network/agent-provider-testkit": "0.10.0"
|
|
112
112
|
},
|
|
113
113
|
"scripts": {
|
|
114
114
|
"build": "tsc -p tsconfig.json",
|