@shardworks/spider-apparatus 0.1.239 → 0.1.240
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/package.json +9 -9
- package/src/static/spider-ui.test.ts +31 -53
- package/src/static/spider.js +8 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shardworks/spider-apparatus",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.240",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"hono": "^4.7.11",
|
|
23
23
|
"yaml": "^2.0.0",
|
|
24
24
|
"zod": "4.3.6",
|
|
25
|
-
"@shardworks/fabricator-apparatus": "0.1.
|
|
26
|
-
"@shardworks/stacks-apparatus": "0.1.
|
|
27
|
-
"@shardworks/
|
|
28
|
-
"@shardworks/codexes-apparatus": "0.1.
|
|
29
|
-
"@shardworks/
|
|
30
|
-
"@shardworks/
|
|
31
|
-
"@shardworks/
|
|
25
|
+
"@shardworks/fabricator-apparatus": "0.1.240",
|
|
26
|
+
"@shardworks/stacks-apparatus": "0.1.240",
|
|
27
|
+
"@shardworks/animator-apparatus": "0.1.240",
|
|
28
|
+
"@shardworks/codexes-apparatus": "0.1.240",
|
|
29
|
+
"@shardworks/loom-apparatus": "0.1.240",
|
|
30
|
+
"@shardworks/tools-apparatus": "0.1.240",
|
|
31
|
+
"@shardworks/clerk-apparatus": "0.1.240"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "25.5.0",
|
|
35
|
-
"@shardworks/nexus-core": "0.1.
|
|
35
|
+
"@shardworks/nexus-core": "0.1.240"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist",
|
|
@@ -521,8 +521,8 @@ describe('spider.js engine-detail stable-skeleton + updater', () => {
|
|
|
521
521
|
);
|
|
522
522
|
assert.match(
|
|
523
523
|
updaterBlock[0],
|
|
524
|
-
/setText\(['"]ed-cost['"]\s*,\s*formatCostWithTokens\(/,
|
|
525
|
-
'engine-detail cost row should render via formatCostWithTokens()',
|
|
524
|
+
/setText\(['"]ed-cost['"]\s*,\s*window\.NexusFormat\.formatCostWithTokens\(/,
|
|
525
|
+
'engine-detail cost row should render via window.NexusFormat.formatCostWithTokens()',
|
|
526
526
|
);
|
|
527
527
|
assert.match(
|
|
528
528
|
updaterBlock[0],
|
|
@@ -1033,70 +1033,48 @@ describe('spider.js server-supplied engine cost', () => {
|
|
|
1033
1033
|
});
|
|
1034
1034
|
});
|
|
1035
1035
|
|
|
1036
|
-
// ── Cost / token formatting
|
|
1036
|
+
// ── Cost / token formatting via shared namespace ────────────────────────
|
|
1037
1037
|
|
|
1038
|
-
describe('spider.js cost/token formatting
|
|
1039
|
-
//
|
|
1040
|
-
//
|
|
1038
|
+
describe('spider.js cost/token formatting delegates to window.NexusFormat', () => {
|
|
1039
|
+
// Spider no longer defines its own cost/token helpers. The shared
|
|
1040
|
+
// formatter lives in oculus's static asset (nexus-format.js) and is
|
|
1041
|
+
// auto-injected into the dashboard <head> before this IIFE runs, so
|
|
1042
|
+
// every dashboard in the guild uses the same precision and locale.
|
|
1041
1043
|
|
|
1042
|
-
it('
|
|
1043
|
-
assert.
|
|
1044
|
+
it('does not redefine formatTokenCount locally', () => {
|
|
1045
|
+
assert.doesNotMatch(
|
|
1044
1046
|
spiderJs,
|
|
1045
|
-
/function formatTokenCount\(
|
|
1046
|
-
'
|
|
1047
|
-
);
|
|
1048
|
-
const block = spiderJs.match(
|
|
1049
|
-
/function formatTokenCount[\s\S]*?(?=\n function )/,
|
|
1050
|
-
);
|
|
1051
|
-
assert.ok(block, 'should find formatTokenCount body');
|
|
1052
|
-
assert.match(
|
|
1053
|
-
block[0],
|
|
1054
|
-
/toLocaleString\(['"]en-US['"]\)/,
|
|
1055
|
-
'formatTokenCount should pass "en-US" locale explicitly',
|
|
1047
|
+
/function formatTokenCount\(/,
|
|
1048
|
+
'spider.js must not redeclare formatTokenCount — use window.NexusFormat.formatTokenCount',
|
|
1056
1049
|
);
|
|
1057
1050
|
});
|
|
1058
1051
|
|
|
1059
|
-
it('
|
|
1060
|
-
assert.
|
|
1052
|
+
it('does not redefine formatCostUsd locally', () => {
|
|
1053
|
+
assert.doesNotMatch(
|
|
1061
1054
|
spiderJs,
|
|
1062
|
-
/function formatCostUsd\(
|
|
1063
|
-
'
|
|
1064
|
-
);
|
|
1065
|
-
const block = spiderJs.match(
|
|
1066
|
-
/function formatCostUsd[\s\S]*?(?=\n\s*\/\*\*|\n function )/,
|
|
1067
|
-
);
|
|
1068
|
-
assert.ok(block, 'should find formatCostUsd body');
|
|
1069
|
-
assert.match(
|
|
1070
|
-
block[0],
|
|
1071
|
-
/toFixed\(2\)/,
|
|
1072
|
-
'formatCostUsd should format to two decimal places',
|
|
1073
|
-
);
|
|
1074
|
-
assert.match(
|
|
1075
|
-
block[0],
|
|
1076
|
-
/['"]\$['"]\s*\+/,
|
|
1077
|
-
'formatCostUsd should prefix with "$"',
|
|
1055
|
+
/function formatCostUsd\(/,
|
|
1056
|
+
'spider.js must not redeclare formatCostUsd — use window.NexusFormat.formatCostUsd',
|
|
1078
1057
|
);
|
|
1079
1058
|
});
|
|
1080
1059
|
|
|
1081
|
-
it('
|
|
1082
|
-
assert.
|
|
1060
|
+
it('does not redefine formatCostWithTokens locally', () => {
|
|
1061
|
+
assert.doesNotMatch(
|
|
1083
1062
|
spiderJs,
|
|
1084
|
-
/function formatCostWithTokens\(
|
|
1085
|
-
'
|
|
1086
|
-
);
|
|
1087
|
-
const block = spiderJs.match(
|
|
1088
|
-
/function formatCostWithTokens[\s\S]*?(?=\n function )/,
|
|
1063
|
+
/function formatCostWithTokens\(/,
|
|
1064
|
+
'spider.js must not redeclare formatCostWithTokens — use window.NexusFormat.formatCostWithTokens',
|
|
1089
1065
|
);
|
|
1090
|
-
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
it('calls into window.NexusFormat for cost rendering', () => {
|
|
1091
1069
|
assert.match(
|
|
1092
|
-
|
|
1093
|
-
/
|
|
1094
|
-
'
|
|
1070
|
+
spiderJs,
|
|
1071
|
+
/window\.NexusFormat\.formatCostUsd\(/,
|
|
1072
|
+
'spider.js should route cost rendering through window.NexusFormat.formatCostUsd',
|
|
1095
1073
|
);
|
|
1096
1074
|
assert.match(
|
|
1097
|
-
|
|
1098
|
-
/
|
|
1099
|
-
'
|
|
1075
|
+
spiderJs,
|
|
1076
|
+
/window\.NexusFormat\.formatCostWithTokens\(/,
|
|
1077
|
+
'spider.js should route cost+tokens rendering through window.NexusFormat.formatCostWithTokens',
|
|
1100
1078
|
);
|
|
1101
1079
|
});
|
|
1102
1080
|
});
|
|
@@ -1228,14 +1206,14 @@ describe('spider.js rig-meta stable-id skeleton', () => {
|
|
|
1228
1206
|
);
|
|
1229
1207
|
});
|
|
1230
1208
|
|
|
1231
|
-
it('updateRigMeta writes cost via formatCostWithTokens', () => {
|
|
1209
|
+
it('updateRigMeta writes cost via window.NexusFormat.formatCostWithTokens', () => {
|
|
1232
1210
|
const block = spiderJs.match(
|
|
1233
1211
|
/function updateRigMeta\(rig\)[\s\S]*?(?=\n function |\n \/\/)/,
|
|
1234
1212
|
);
|
|
1235
1213
|
assert.ok(block, 'should find updateRigMeta body');
|
|
1236
1214
|
assert.match(
|
|
1237
1215
|
block[0],
|
|
1238
|
-
/setText\(['"]rig-meta-cost['"]\s*,\s*formatCostWithTokens\(/,
|
|
1216
|
+
/setText\(['"]rig-meta-cost['"]\s*,\s*window\.NexusFormat\.formatCostWithTokens\(/,
|
|
1239
1217
|
'updateRigMeta should render cost via the shared formatter',
|
|
1240
1218
|
);
|
|
1241
1219
|
assert.match(
|
package/src/static/spider.js
CHANGED
|
@@ -94,38 +94,11 @@
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// ── Cost / token formatting ────────────────────────────────────────────
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
return Number(n).toLocaleString('en-US');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Format a cost value as `$x.yy`. Used for the rig-list Cost column
|
|
107
|
-
* and any other surface that shows cost without tokens.
|
|
108
|
-
*/
|
|
109
|
-
function formatCostUsd(costUsd) {
|
|
110
|
-
var n = Number(costUsd);
|
|
111
|
-
if (!isFinite(n)) n = 0;
|
|
112
|
-
return '$' + n.toFixed(2);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Format a cost + tokens triplet as `$x.yy (N input, M output)` with
|
|
117
|
-
* thousands-separator grouping. When either token count is absent
|
|
118
|
-
* (undefined), the parenthetical is omitted entirely — matching the
|
|
119
|
-
* brief's rule that we never render `(0 input, 0 output)` when no
|
|
120
|
-
* anima session has reported usage.
|
|
121
|
-
*/
|
|
122
|
-
function formatCostWithTokens(costUsd, inputTokens, outputTokens) {
|
|
123
|
-
var cost = formatCostUsd(costUsd);
|
|
124
|
-
if (inputTokens === undefined || outputTokens === undefined) {
|
|
125
|
-
return cost;
|
|
126
|
-
}
|
|
127
|
-
return cost + ' (' + formatTokenCount(inputTokens) + ' input, ' + formatTokenCount(outputTokens) + ' output)';
|
|
128
|
-
}
|
|
97
|
+
//
|
|
98
|
+
// Cost and token formatting routes through the shared window.NexusFormat
|
|
99
|
+
// namespace (served by oculus and auto-injected into every dashboard
|
|
100
|
+
// page, so it is defined before this IIFE runs). The namespace is the
|
|
101
|
+
// single source of truth — no local redefinitions here.
|
|
129
102
|
|
|
130
103
|
function formatElapsed(startedAt, completedAt) {
|
|
131
104
|
var diffMs = new Date(completedAt) - new Date(startedAt);
|
|
@@ -745,7 +718,7 @@
|
|
|
745
718
|
var costTd = row.querySelector('.rig-row-cost');
|
|
746
719
|
if (costTd) {
|
|
747
720
|
var costUsd = (rig.costSummary && typeof rig.costSummary.costUsd === 'number') ? rig.costSummary.costUsd : 0;
|
|
748
|
-
var costText = formatCostUsd(costUsd);
|
|
721
|
+
var costText = window.NexusFormat.formatCostUsd(costUsd);
|
|
749
722
|
if (costTd.textContent !== costText) costTd.textContent = costText;
|
|
750
723
|
}
|
|
751
724
|
|
|
@@ -818,7 +791,7 @@
|
|
|
818
791
|
var costUsd = summary ? summary.costUsd : 0;
|
|
819
792
|
var inputTokens = summary ? summary.inputTokens : undefined;
|
|
820
793
|
var outputTokens = summary ? summary.outputTokens : undefined;
|
|
821
|
-
setText('rig-meta-cost', formatCostWithTokens(costUsd, inputTokens, outputTokens));
|
|
794
|
+
setText('rig-meta-cost', window.NexusFormat.formatCostWithTokens(costUsd, inputTokens, outputTokens));
|
|
822
795
|
}
|
|
823
796
|
|
|
824
797
|
// ── Show rig detail ────────────────────────────────────────────────────
|
|
@@ -1310,7 +1283,7 @@
|
|
|
1310
1283
|
// Updates on the 2 s rig poll cadence without any per-engine fetch.
|
|
1311
1284
|
var engineCost = (currentRig && currentRig.engineCosts) ? currentRig.engineCosts[engine.id] : undefined;
|
|
1312
1285
|
if (engineCost) {
|
|
1313
|
-
setText('ed-cost', formatCostWithTokens(engineCost.costUsd, engineCost.inputTokens, engineCost.outputTokens));
|
|
1286
|
+
setText('ed-cost', window.NexusFormat.formatCostWithTokens(engineCost.costUsd, engineCost.inputTokens, engineCost.outputTokens));
|
|
1314
1287
|
setRowDisplay('ed-cost-dt', 'ed-cost', true);
|
|
1315
1288
|
} else {
|
|
1316
1289
|
setText('ed-cost', '');
|