opencode-statboard 2.10.30 → 2.10.31
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/move-quota2.py +29 -0
- package/move-quota3.py +34 -0
- package/move-quota4.py +31 -0
- package/move-quota5.py +26 -0
- package/package.json +1 -1
- package/server.js +5 -3
package/move-quota2.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
p = r'C:\Users\CPXru\Desktop\thumb\01_Active\oc-stats\server.js'
|
|
2
|
+
s = open(p, encoding='utf-8').read()
|
|
3
|
+
|
|
4
|
+
guard = "if (require.main !== module) {\n"
|
|
5
|
+
assert guard in s, 'guard not found'
|
|
6
|
+
guard_idx = s.index(guard)
|
|
7
|
+
|
|
8
|
+
# The quota block starts at '// ---- OpenRouter quota'
|
|
9
|
+
quota_start = s.index('// ---- OpenRouter quota')
|
|
10
|
+
# It ends right before 'module.exports = {'
|
|
11
|
+
me_start = s.index('module.exports = {')
|
|
12
|
+
quota_block = s[quota_start:me_start]
|
|
13
|
+
|
|
14
|
+
# Remove it from current location
|
|
15
|
+
s = s[:quota_start] + s[me_start:]
|
|
16
|
+
|
|
17
|
+
# Find the guard again (position may have shifted)
|
|
18
|
+
guard_idx = s.index(guard)
|
|
19
|
+
|
|
20
|
+
# Insert quota block BEFORE the guard
|
|
21
|
+
s = s[:guard_idx] + quota_block + '\n' + s[guard_idx:]
|
|
22
|
+
|
|
23
|
+
open(p, 'w', encoding='utf-8').write(s)
|
|
24
|
+
print('moved quota block before guard')
|
|
25
|
+
|
|
26
|
+
# Verify
|
|
27
|
+
gi = s.index(guard)
|
|
28
|
+
qi = s.index('// ---- OpenRouter quota')
|
|
29
|
+
print('guard at', gi, 'quota at', qi, 'quota before guard:', qi < gi)
|
package/move-quota3.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
p = r'C:\Users\CPXru\Desktop\thumb\01_Active\oc-stats\server.js'
|
|
2
|
+
s = open(p, encoding='utf-8').read()
|
|
3
|
+
|
|
4
|
+
# The quota block is currently inside the guard block.
|
|
5
|
+
# Find guard line
|
|
6
|
+
guard_line = 'if (require.main !== module) {'
|
|
7
|
+
assert guard_line in s
|
|
8
|
+
guard_idx = s.index(guard_line)
|
|
9
|
+
|
|
10
|
+
# Find quota block
|
|
11
|
+
quota_marker = '// ---- OpenRouter quota'
|
|
12
|
+
assert quota_marker in s
|
|
13
|
+
quota_start = s.index(quota_marker)
|
|
14
|
+
|
|
15
|
+
# The quota block ends at module.exports
|
|
16
|
+
me_marker = 'module.exports = {'
|
|
17
|
+
assert me_marker in s
|
|
18
|
+
me_start = s.index(me_marker)
|
|
19
|
+
|
|
20
|
+
# Extract quota block
|
|
21
|
+
quota_block = s[quota_start:me_start]
|
|
22
|
+
|
|
23
|
+
# Remove from current location
|
|
24
|
+
s = s[:quota_start] + s[me_start:]
|
|
25
|
+
|
|
26
|
+
# Recompute guard position after removal
|
|
27
|
+
guard_idx = s.index(guard_line)
|
|
28
|
+
|
|
29
|
+
# Insert before guard
|
|
30
|
+
s = s[:guard_idx] + quota_block + '\n' + s[guard_idx:]
|
|
31
|
+
|
|
32
|
+
open(p, 'w', encoding='utf-8').write(s)
|
|
33
|
+
print('moved quota block before guard')
|
|
34
|
+
print('quota before guard:', s.index(quota_marker) < s.index(guard_line))
|
package/move-quota4.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
p = r'C:\Users\CPXru\Desktop\thumb\01_Active\oc-stats\server.js'
|
|
2
|
+
s = open(p, encoding='utf-8').read()
|
|
3
|
+
|
|
4
|
+
guard_marker = 'if (require.main !== module) {'
|
|
5
|
+
assert guard_marker in s
|
|
6
|
+
guard_idx = s.index(guard_marker)
|
|
7
|
+
|
|
8
|
+
quota_marker = '// ---- OpenRouter quota'
|
|
9
|
+
assert quota_marker in s
|
|
10
|
+
quota_start = s.index(quota_marker)
|
|
11
|
+
|
|
12
|
+
# The quota block ends at 'module.exports = {'
|
|
13
|
+
me_marker = 'module.exports = {'
|
|
14
|
+
assert me_marker in s
|
|
15
|
+
me_start = s.index(me_marker)
|
|
16
|
+
|
|
17
|
+
# Extract quota block
|
|
18
|
+
quota_block = s[quota_start:me_start]
|
|
19
|
+
|
|
20
|
+
# Remove from current location
|
|
21
|
+
s = s[:quota_start] + s[me_start:]
|
|
22
|
+
|
|
23
|
+
# Recompute guard position
|
|
24
|
+
guard_idx = s.index(guard_marker)
|
|
25
|
+
|
|
26
|
+
# Insert before guard
|
|
27
|
+
s = s[:guard_idx] + quota_block + '\n' + s[guard_idx:]
|
|
28
|
+
|
|
29
|
+
open(p, 'w', encoding='utf-8').write(s)
|
|
30
|
+
print('moved')
|
|
31
|
+
print('quota before guard:', s.index(quota_marker) < s.index(guard_marker))
|
package/move-quota5.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
p = r'C:\Users\CPXru\Desktop\thumb\01_Active\oc-stats\server.js'
|
|
2
|
+
s = open(p, encoding='utf-8').read()
|
|
3
|
+
|
|
4
|
+
guard_marker = 'if (require.main !== module) {'
|
|
5
|
+
assert guard_marker in s
|
|
6
|
+
guard_idx = s.index(guard_marker)
|
|
7
|
+
|
|
8
|
+
quota_marker = '// ---- OpenRouter quota'
|
|
9
|
+
assert quota_marker in s
|
|
10
|
+
quota_start = s.index(quota_marker)
|
|
11
|
+
|
|
12
|
+
# quota block is from quota_marker to guard_marker (exclusive)
|
|
13
|
+
quota_block = s[quota_start:guard_idx]
|
|
14
|
+
|
|
15
|
+
# Remove it
|
|
16
|
+
s = s[:quota_start] + s[guard_idx:]
|
|
17
|
+
|
|
18
|
+
# guard is now at the start of what was after quota_block
|
|
19
|
+
guard_idx = s.index(guard_marker)
|
|
20
|
+
|
|
21
|
+
# Insert before guard
|
|
22
|
+
s = s[:guard_idx] + quota_block + '\n' + s[guard_idx:]
|
|
23
|
+
|
|
24
|
+
open(p, 'w', encoding='utf-8').write(s)
|
|
25
|
+
print('moved')
|
|
26
|
+
print('quota before guard:', s.index(quota_marker) < s.index(guard_marker))
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1539,8 +1539,7 @@ const server = http.createServer(async (req, res) => {
|
|
|
1539
1539
|
// helpers and bail out before any server-side side effect (listening, timers,
|
|
1540
1540
|
// signal handlers). `bin` points straight at this file, so a normal
|
|
1541
1541
|
// `opencode-dashboard` run always has require.main === module.
|
|
1542
|
-
|
|
1543
|
-
// ---- OpenRouter quota (key-level remaining credits & free-tier RPD) ------
|
|
1542
|
+
// ---- OpenRouter quota (key-level remaining credits & free-tier RPD) ------
|
|
1544
1543
|
const OR_KEY_FILE = path.join(process.env.USERPROFILE || process.env.HOME || '', '.thumb-secrets', 'openrouter-keys.txt');
|
|
1545
1544
|
const OR_QUOTA_TTL = 5 * 60 * 1000;
|
|
1546
1545
|
let orQuotaCache = { at: 0, data: null };
|
|
@@ -1596,7 +1595,10 @@ async function fetchOpenRouterQuota() {
|
|
|
1596
1595
|
return result;
|
|
1597
1596
|
}
|
|
1598
1597
|
|
|
1599
|
-
|
|
1598
|
+
|
|
1599
|
+
|
|
1600
|
+
if (require.main !== module) {
|
|
1601
|
+
module.exports = {
|
|
1600
1602
|
buildAttrBundle,
|
|
1601
1603
|
serializeBundle,
|
|
1602
1604
|
reviveBundle,
|