oasis_test 0.1.57 → 0.1.58
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/index.js +61 -19
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -42596,7 +42596,7 @@ function latestIso(values) {
|
|
|
42596
42596
|
function journalIdentity(entry) {
|
|
42597
42597
|
return entry.sessionId ?? entry.dispatchId;
|
|
42598
42598
|
}
|
|
42599
|
-
function executionMetrics(journal, artifactIds, resolveActor,
|
|
42599
|
+
function executionMetrics(journal, artifactIds, resolveActor, durationBounds) {
|
|
42600
42600
|
const sessions = /* @__PURE__ */ new Map();
|
|
42601
42601
|
const activeByJob = /* @__PURE__ */ new Map();
|
|
42602
42602
|
let fallbackSeq = 0;
|
|
@@ -42632,27 +42632,64 @@ function executionMetrics(journal, artifactIds, resolveActor, nowMs) {
|
|
|
42632
42632
|
artifactId: entry.artifactId,
|
|
42633
42633
|
actor: entry.actor,
|
|
42634
42634
|
startedAt: previous?.startedAt,
|
|
42635
|
+
endedAt: entry.at,
|
|
42635
42636
|
durationMs: entry.durationMs,
|
|
42636
42637
|
failed: !entry.progressed
|
|
42637
42638
|
});
|
|
42638
42639
|
activeByJob.delete(entry.jobKey);
|
|
42639
42640
|
}
|
|
42640
42641
|
}
|
|
42642
|
+
const createdMs = durationBounds.createdAt ? Date.parse(durationBounds.createdAt) : Number.NaN;
|
|
42643
|
+
const finishedMs = durationBounds.latestExecutionFinishedAt ? Date.parse(durationBounds.latestExecutionFinishedAt) : Number.NaN;
|
|
42644
|
+
const completedIntervals = [];
|
|
42641
42645
|
const actorTotals = /* @__PURE__ */ new Map();
|
|
42642
|
-
let executionDurationMs = 0;
|
|
42643
42646
|
let executionFailures = 0;
|
|
42644
42647
|
for (const session of sessions.values()) {
|
|
42645
|
-
const
|
|
42646
|
-
const
|
|
42647
|
-
|
|
42648
|
+
const ended = session.endedAt ? Date.parse(session.endedAt) : Number.NaN;
|
|
42649
|
+
const reportedDuration = session.durationMs;
|
|
42650
|
+
const observedStarted = session.startedAt ? Date.parse(session.startedAt) : Number.NaN;
|
|
42651
|
+
const inferredStarted = Number.isFinite(ended) && reportedDuration !== void 0 && Number.isFinite(reportedDuration) ? ended - Math.max(0, reportedDuration) : Number.NaN;
|
|
42652
|
+
const started = Number.isFinite(inferredStarted) ? inferredStarted : observedStarted;
|
|
42653
|
+
const interval = Number.isFinite(started) && Number.isFinite(ended) ? {
|
|
42654
|
+
startMs: Number.isFinite(createdMs) ? Math.max(started, createdMs) : started,
|
|
42655
|
+
endMs: Number.isFinite(finishedMs) ? Math.min(ended, finishedMs) : ended
|
|
42656
|
+
} : null;
|
|
42657
|
+
if (interval && interval.endMs > interval.startMs) completedIntervals.push(interval);
|
|
42648
42658
|
if (session.failed) executionFailures += 1;
|
|
42649
|
-
const current = actorTotals.get(session.actor) ?? { sessionCount: 0,
|
|
42659
|
+
const current = actorTotals.get(session.actor) ?? { sessionCount: 0, intervals: [] };
|
|
42650
42660
|
current.sessionCount += 1;
|
|
42651
|
-
|
|
42661
|
+
if (interval && interval.endMs > interval.startMs) current.intervals.push(interval);
|
|
42652
42662
|
actorTotals.set(session.actor, current);
|
|
42653
42663
|
}
|
|
42654
|
-
const byActor = [...actorTotals.entries()].map(([actor, totals]) => ({
|
|
42655
|
-
|
|
42664
|
+
const byActor = [...actorTotals.entries()].map(([actor, totals]) => ({
|
|
42665
|
+
actor: ref(actor, resolveActor),
|
|
42666
|
+
sessionCount: totals.sessionCount,
|
|
42667
|
+
executionDurationMs: mergedIntervalDuration(totals.intervals)
|
|
42668
|
+
})).sort((a, b2) => b2.executionDurationMs - a.executionDurationMs || a.actor.id.localeCompare(b2.actor.id));
|
|
42669
|
+
return {
|
|
42670
|
+
sessionCount: sessions.size,
|
|
42671
|
+
executionDurationMs: mergedIntervalDuration(completedIntervals),
|
|
42672
|
+
byActor,
|
|
42673
|
+
executionFailures
|
|
42674
|
+
};
|
|
42675
|
+
}
|
|
42676
|
+
function mergedIntervalDuration(intervals) {
|
|
42677
|
+
const ordered = [...intervals].sort((a, b2) => a.startMs - b2.startMs || a.endMs - b2.endMs);
|
|
42678
|
+
let total = 0;
|
|
42679
|
+
let open2 = null;
|
|
42680
|
+
for (const interval of ordered) {
|
|
42681
|
+
if (!open2) {
|
|
42682
|
+
open2 = { ...interval };
|
|
42683
|
+
continue;
|
|
42684
|
+
}
|
|
42685
|
+
if (interval.startMs <= open2.endMs) {
|
|
42686
|
+
open2.endMs = Math.max(open2.endMs, interval.endMs);
|
|
42687
|
+
continue;
|
|
42688
|
+
}
|
|
42689
|
+
total += open2.endMs - open2.startMs;
|
|
42690
|
+
open2 = { ...interval };
|
|
42691
|
+
}
|
|
42692
|
+
return open2 ? total + open2.endMs - open2.startMs : total;
|
|
42656
42693
|
}
|
|
42657
42694
|
function workorderDuration(ops, journal, artifactIds) {
|
|
42658
42695
|
const createdAt = earliestIso(
|
|
@@ -42685,22 +42722,22 @@ function reportedGapCount(model, artifactIds) {
|
|
|
42685
42722
|
return total;
|
|
42686
42723
|
}
|
|
42687
42724
|
function buildWorkorderMetrics(input) {
|
|
42688
|
-
const nowMs = input.nowMs ?? Date.now();
|
|
42689
42725
|
return input.workorders.map((workorder) => {
|
|
42690
42726
|
const artifactIds = new Set(
|
|
42691
42727
|
[...input.model.artifacts.values()].filter((artifact) => artifact.workspace === workorder.id).map((artifact) => artifact.id)
|
|
42692
42728
|
);
|
|
42693
|
-
const
|
|
42729
|
+
const duration3 = workorderDuration(
|
|
42730
|
+
input.opsByWorkorder?.get(workorder.id) ?? [],
|
|
42731
|
+
input.dispatchJournal,
|
|
42732
|
+
artifactIds
|
|
42733
|
+
);
|
|
42734
|
+
const execution = executionMetrics(input.dispatchJournal, artifactIds, input.resolveActor, duration3);
|
|
42694
42735
|
const reportedGaps = reportedGapCount(input.model, artifactIds);
|
|
42695
42736
|
return {
|
|
42696
42737
|
workorder,
|
|
42697
42738
|
sessionCount: execution.sessionCount,
|
|
42698
42739
|
executionDurationMs: execution.executionDurationMs,
|
|
42699
|
-
workorderDuration:
|
|
42700
|
-
input.opsByWorkorder?.get(workorder.id) ?? [],
|
|
42701
|
-
input.dispatchJournal,
|
|
42702
|
-
artifactIds
|
|
42703
|
-
),
|
|
42740
|
+
workorderDuration: duration3,
|
|
42704
42741
|
byActor: execution.byActor,
|
|
42705
42742
|
firstReviewPassRate: firstReviewPassRate(input.model, artifactIds),
|
|
42706
42743
|
qualityMetrics: qualitySnapshot(input.nodeOutputsByWorkorder?.get(workorder.id) ?? []),
|
|
@@ -58453,6 +58490,7 @@ function log2(tag, msg, extra) {
|
|
|
58453
58490
|
var RECONNECT_DELAY_MS = 3e3;
|
|
58454
58491
|
var PING_INTERVAL_MS = 2e4;
|
|
58455
58492
|
var SILENCE_TIMEOUT_MS = 6e4;
|
|
58493
|
+
var HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
58456
58494
|
var OUTBOX_TTL_MS = 5 * 6e4;
|
|
58457
58495
|
var OUTBOX_MAX = 500;
|
|
58458
58496
|
async function preflightOasisAccess(job) {
|
|
@@ -58485,6 +58523,7 @@ var DaemonWsClient = class {
|
|
|
58485
58523
|
this.pingIntervalMs = opts.pingIntervalMs ?? PING_INTERVAL_MS;
|
|
58486
58524
|
this.silenceTimeoutMs = opts.silenceTimeoutMs ?? SILENCE_TIMEOUT_MS;
|
|
58487
58525
|
this.reconnectDelayMs = opts.reconnectDelayMs ?? RECONNECT_DELAY_MS;
|
|
58526
|
+
this.handshakeTimeoutMs = opts.handshakeTimeoutMs ?? HANDSHAKE_TIMEOUT_MS;
|
|
58488
58527
|
this.outboxMax = opts.outboxMaxFrames ?? OUTBOX_MAX;
|
|
58489
58528
|
}
|
|
58490
58529
|
ws = null;
|
|
@@ -58505,6 +58544,7 @@ var DaemonWsClient = class {
|
|
|
58505
58544
|
pingIntervalMs;
|
|
58506
58545
|
silenceTimeoutMs;
|
|
58507
58546
|
reconnectDelayMs;
|
|
58547
|
+
handshakeTimeoutMs;
|
|
58508
58548
|
outboxMax;
|
|
58509
58549
|
/** 未确认关键帧数(观测/测试用)。 */
|
|
58510
58550
|
outboxSize() {
|
|
@@ -58525,7 +58565,9 @@ var DaemonWsClient = class {
|
|
|
58525
58565
|
"x-daemon-id": this.daemonId,
|
|
58526
58566
|
// 经公网网关时鉴权靠它(对齐 multica:Authorization 头反代天然透传);内网直连可空
|
|
58527
58567
|
...this.token ? { authorization: `Bearer ${this.token}` } : {}
|
|
58528
|
-
}
|
|
58568
|
+
},
|
|
58569
|
+
// 握手超时兜底:黑洞化的重连不会永久悬挂(见 HANDSHAKE_TIMEOUT_MS)。
|
|
58570
|
+
handshakeTimeout: this.handshakeTimeoutMs
|
|
58529
58571
|
});
|
|
58530
58572
|
this.ws = ws;
|
|
58531
58573
|
ws.on("open", () => {
|
|
@@ -58538,7 +58580,7 @@ var DaemonWsClient = class {
|
|
|
58538
58580
|
this.send({ type: "pong" });
|
|
58539
58581
|
if (Date.now() - this.lastReceivedAt > this.silenceTimeoutMs) {
|
|
58540
58582
|
log2("[node-cli]", `server silent for ${this.silenceTimeoutMs}ms \u2014 forcing reconnect`);
|
|
58541
|
-
this.ws?.
|
|
58583
|
+
this.ws?.terminate();
|
|
58542
58584
|
}
|
|
58543
58585
|
}, this.pingIntervalMs);
|
|
58544
58586
|
});
|
|
@@ -60445,7 +60487,7 @@ ${res.warning}`);
|
|
|
60445
60487
|
}
|
|
60446
60488
|
|
|
60447
60489
|
// src/index.ts
|
|
60448
|
-
var PKG_VERSION = true ? "0.1.
|
|
60490
|
+
var PKG_VERSION = true ? "0.1.58" : "dev";
|
|
60449
60491
|
var OASIS_DIR = path18.join(os9.homedir(), ".oasis");
|
|
60450
60492
|
var CONFIG_FILE = path18.join(OASIS_DIR, "node-config.json");
|
|
60451
60493
|
var PID_FILE = path18.join(OASIS_DIR, "node.pid");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oasis_test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "Oasis node daemon + CLI — background daemon, auto-start, full server CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"oasis": "./dist/index.js"
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=20"
|
|
27
|
+
},
|
|
28
|
+
"oasisRelease": {
|
|
29
|
+
"sourceHead": "16401a67b91c8bdee7aceeb22ad9fc4ccf9de76c"
|
|
27
30
|
}
|
|
28
31
|
}
|