@deksden-com/dd-flow-cli 0.9.0-beta.0 → 0.9.0-beta.1
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/CHANGELOG.md +7 -0
- package/dist/build-info.json +3 -3
- package/dist/services/usage.js +9 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli_package": "@deksden-com/dd-flow-cli",
|
|
3
|
-
"cli_version": "0.9.0-beta.
|
|
4
|
-
"cli_commit": "
|
|
5
|
-
"built_at": "2026-09-
|
|
3
|
+
"cli_version": "0.9.0-beta.1",
|
|
4
|
+
"cli_commit": "5e493443b9f97ad3c83e0edccc29dfbee584b92e",
|
|
5
|
+
"built_at": "2026-09-01T21:02:46.536Z",
|
|
6
6
|
"built_with_canon": {
|
|
7
7
|
"version": "4.0.0",
|
|
8
8
|
"commit": "bd6494ad11bca9544d9b483bd7fe37049e6d00fe",
|
package/dist/services/usage.js
CHANGED
|
@@ -131,9 +131,10 @@ export function storedUsageForRun(context, input) {
|
|
|
131
131
|
*/
|
|
132
132
|
export function recalculateRunUsage(context, input) {
|
|
133
133
|
const observedAt = context.now();
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
// Provider completion, not the controller's later lifecycle write, is the
|
|
135
|
+
// accounting boundary. A final refresh must therefore see tokens emitted
|
|
136
|
+
// after `work finish` but before the agent's actual terminal event.
|
|
137
|
+
const accountingAt = observedAt;
|
|
137
138
|
const links = context.db.all(`SELECT ws.id, ws.work_id, ws.session_id, ws.created_at, ws.completed_at,
|
|
138
139
|
w.project_id, s.harness, s.transcript_path, s.parent_session_id, s.agent_id, s.provider_session_id
|
|
139
140
|
FROM work_sessions ws
|
|
@@ -427,15 +428,6 @@ function readHarnessUsageWindow(context, harness, projectId, providerSessionId,
|
|
|
427
428
|
}
|
|
428
429
|
};
|
|
429
430
|
}
|
|
430
|
-
function terminalTimestamp(indexJson) {
|
|
431
|
-
try {
|
|
432
|
-
const index = JSON.parse(indexJson);
|
|
433
|
-
return ["done", "blocked", "cancelled", "failed"].includes(index.status ?? "") && typeof index.completed_at === "string" ? index.completed_at : null;
|
|
434
|
-
}
|
|
435
|
-
catch {
|
|
436
|
-
return null;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
431
|
function settledRunSessions(context, links, observedAt) {
|
|
440
432
|
const sessions = new Map();
|
|
441
433
|
for (const link of links)
|
|
@@ -444,16 +436,16 @@ function settledRunSessions(context, links, observedAt) {
|
|
|
444
436
|
if (sessionLinks.some((link) => !link.completed_at))
|
|
445
437
|
return [];
|
|
446
438
|
const link = sessionLinks[0];
|
|
447
|
-
const
|
|
448
|
-
if (isExternalHarness(link.harness) && link.provider_session_id
|
|
439
|
+
const sessionStartedAt = sessionLinks.map((item) => item.created_at).sort()[0];
|
|
440
|
+
if (isExternalHarness(link.harness) && link.provider_session_id) {
|
|
449
441
|
const snapshot = context.db.get(`SELECT observed_at FROM harness_usage_snapshots
|
|
450
442
|
WHERE project_id = ? AND harness = ? AND provider_session_id = ?
|
|
451
|
-
AND observed_at >= ? AND observed_at <= ?
|
|
452
|
-
ORDER BY observed_at DESC, id DESC LIMIT 1`, [link.project_id, link.harness, link.provider_session_id,
|
|
443
|
+
AND completeness = 'complete' AND observed_at >= ? AND observed_at <= ?
|
|
444
|
+
ORDER BY observed_at DESC, id DESC LIMIT 1`, [link.project_id, link.harness, link.provider_session_id, sessionStartedAt, observedAt]);
|
|
453
445
|
return snapshot ? [{ session_id: sessionId, completed_at: snapshot.observed_at }] : [];
|
|
454
446
|
}
|
|
455
447
|
const completed = completedProviderTurn(sessionLinks[0].transcript_path, sessionId);
|
|
456
|
-
if (!completed ||
|
|
448
|
+
if (!completed || Date.parse(completed.completed_at) < Date.parse(sessionStartedAt))
|
|
457
449
|
return [];
|
|
458
450
|
return [{ session_id: sessionId, completed_at: completed.completed_at }];
|
|
459
451
|
});
|