devrage 0.5.7 → 0.5.8
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/cli.js +40 -1
- package/dist/cli.js.map +2 -2
- package/dist/lib/adapters/codex.js +42 -0
- package/dist/lib/adapters/codex.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -670,6 +670,7 @@ async function* parseCodexUsageJsonl(filePath, context) {
|
|
|
670
670
|
let previousUsageSignature = null;
|
|
671
671
|
let session = context.session;
|
|
672
672
|
let sawSessionMeta = false;
|
|
673
|
+
let forkReplayStartedAt = null;
|
|
673
674
|
for await (const line of rl) {
|
|
674
675
|
if (!line.trim()) {
|
|
675
676
|
continue;
|
|
@@ -682,6 +683,15 @@ async function* parseCodexUsageJsonl(filePath, context) {
|
|
|
682
683
|
if (metaSession && !sawSessionMeta) {
|
|
683
684
|
session = metaSession;
|
|
684
685
|
sawSessionMeta = true;
|
|
686
|
+
if (payload?.["thread_source"] === "subagent") {
|
|
687
|
+
forkReplayStartedAt = uuidV7Timestamp(metaSession) ?? timestampMilliseconds(entry["timestamp"]) ?? timestampMilliseconds(payload["timestamp"]);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
if (forkReplayStartedAt !== null) {
|
|
693
|
+
if (isLiveForkTaskStart(entry, payload, forkReplayStartedAt)) {
|
|
694
|
+
forkReplayStartedAt = null;
|
|
685
695
|
}
|
|
686
696
|
continue;
|
|
687
697
|
}
|
|
@@ -813,6 +823,35 @@ function numberValue2(value) {
|
|
|
813
823
|
function stringValue2(value) {
|
|
814
824
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
815
825
|
}
|
|
826
|
+
function isLiveForkTaskStart(entry, payload, forkStartedAt) {
|
|
827
|
+
if (entry["type"] !== "event_msg" || payload?.["type"] !== "task_started") {
|
|
828
|
+
return false;
|
|
829
|
+
}
|
|
830
|
+
const taskIdStartedAt = uuidV7Timestamp(stringValue2(payload["turn_id"]));
|
|
831
|
+
if (taskIdStartedAt !== null) {
|
|
832
|
+
return taskIdStartedAt >= forkStartedAt;
|
|
833
|
+
}
|
|
834
|
+
const taskStartedAt = timestampMilliseconds(payload["started_at"]);
|
|
835
|
+
return taskStartedAt !== null && taskStartedAt >= Math.floor(forkStartedAt / 1e3) * 1e3;
|
|
836
|
+
}
|
|
837
|
+
function uuidV7Timestamp(value) {
|
|
838
|
+
const normalized = value?.replaceAll("-", "");
|
|
839
|
+
if (!normalized || !/^[0-9a-f]{12}7/i.test(normalized)) {
|
|
840
|
+
return null;
|
|
841
|
+
}
|
|
842
|
+
const timestamp = Number.parseInt(normalized.slice(0, 12), 16);
|
|
843
|
+
return Number.isSafeInteger(timestamp) ? timestamp : null;
|
|
844
|
+
}
|
|
845
|
+
function timestampMilliseconds(value) {
|
|
846
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
847
|
+
return value >= 1e12 ? value : value * 1e3;
|
|
848
|
+
}
|
|
849
|
+
if (typeof value === "string") {
|
|
850
|
+
const timestamp = Date.parse(value);
|
|
851
|
+
return Number.isFinite(timestamp) ? timestamp : null;
|
|
852
|
+
}
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
816
855
|
function asRecord3(value) {
|
|
817
856
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
818
857
|
return null;
|
|
@@ -3727,7 +3766,7 @@ async function main() {
|
|
|
3727
3766
|
process.exit(0);
|
|
3728
3767
|
}
|
|
3729
3768
|
if (command === "--version") {
|
|
3730
|
-
console.log("0.5.
|
|
3769
|
+
console.log("0.5.8");
|
|
3731
3770
|
process.exit(0);
|
|
3732
3771
|
}
|
|
3733
3772
|
const parsed = parseCommand(args);
|