Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
JD.AI/render_with_session.js at main · JerrettDavis/JD.AI · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
JerrettDavis
JD.AI
Repository navigation
Code
Issues
Pull requests
1
(1)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
JD.AI
/
render_with_session.js
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
122 lines (97 loc) · 4.58 KB
main
Breadcrumbs
JD.AI
/
render_with_session.js
Copy path
Top
File metadata and controls
Code
Blame
122 lines (97 loc) · 4.58 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const
{
chromium
}
=
require
(
'playwright'
)
;
(
async
(
)
=>
{
const
browser
=
await
chromium
.
launch
(
)
;
const
page
=
await
browser
.
newPage
(
)
;
const
session
=
'agent%3Ajdai-default%3Adiscord%3Achannel%3A1466622912307007690'
;
// ===== USAGE PAGE =====
console
.
log
(
'=== USAGE PAGE (SESSION AUTH) ==='
)
;
await
page
.
goto
(
`http://127.0.0.1:18789/control/usage?session=
${
session
}
`
,
{
waitUntil
:
'networkidle'
}
)
;
await
page
.
waitForTimeout
(
2000
)
;
const
usageDetails
=
await
page
.
evaluate
(
(
)
=>
{
const
sections
=
{
}
;
// Page title and subtitle
sections
.
pageTitle
=
document
.
querySelector
(
'h1'
)
?.
textContent
?.
trim
(
)
||
'Usage'
;
sections
.
pageDescription
=
Array
.
from
(
document
.
querySelectorAll
(
'*'
)
)
.
find
(
el
=>
el
.
textContent
?.
includes
(
'tokens go'
)
)
?.
textContent
?.
trim
(
)
;
// Buttons
const
allButtons
=
Array
.
from
(
document
.
querySelectorAll
(
'button'
)
)
.
map
(
b
=>
b
.
textContent
?.
trim
(
)
)
.
filter
(
t
=>
t
&&
t
.
length
>
0
)
;
sections
.
filterArea
=
{
timeRangeButtons
:
allButtons
.
filter
(
t
=>
[
'Today'
,
'7d'
,
'30d'
]
.
includes
(
t
)
)
,
metricToggleButtons
:
allButtons
.
filter
(
t
=>
[
'Tokens'
,
'Cost'
]
.
includes
(
t
)
)
,
mainButtons
:
allButtons
.
filter
(
t
=>
[
'Refresh'
,
'Pin'
,
'Export'
]
.
includes
(
t
)
||
t
.
includes
(
'Export'
)
)
,
dateInputs
:
Array
.
from
(
document
.
querySelectorAll
(
'input[type="date"]'
)
)
.
length
,
selects
:
Array
.
from
(
document
.
querySelectorAll
(
'select'
)
)
.
length
}
;
// Data sections visible
const
bodyText
=
document
.
body
.
innerText
;
sections
.
visibleSections
=
[
'Usage Overview'
,
'Top Models'
,
'Top Providers'
,
'Top Tools'
,
'Top Agents'
,
'Top Channels'
,
'Peak Error'
,
'Activity by Time'
,
'Daily Usage'
,
'Tokens By Type'
,
'Sessions'
]
.
filter
(
title
=>
bodyText
.
includes
(
title
)
)
;
// Sessions table structure
const
table
=
document
.
querySelector
(
'table'
)
;
sections
.
hasTable
=
!
!
table
;
if
(
table
)
{
sections
.
tableHeaders
=
Array
.
from
(
table
.
querySelectorAll
(
'th'
)
)
.
map
(
th
=>
th
.
textContent
?.
trim
(
)
)
;
sections
.
tableRows
=
table
.
querySelectorAll
(
'tbody tr'
)
.
length
;
}
sections
.
bodyPreview
=
document
.
body
.
innerText
.
substring
(
0
,
2500
)
;
return
sections
;
}
)
;
console
.
log
(
'=== USAGE PAGE DETAILS ==='
)
;
console
.
log
(
JSON
.
stringify
(
usageDetails
,
null
,
2
)
)
;
await
page
.
screenshot
(
{
path
:
'/c/git/JD.AI/usage-session-auth.png'
,
fullPage
:
true
}
)
;
console
.
log
(
'Screenshot: /c/git/JD.AI/usage-session-auth.png'
)
;
// ===== CRON JOBS PAGE =====
console
.
log
(
'\n=== CRON JOBS PAGE (SESSION AUTH) ==='
)
;
await
page
.
goto
(
`http://127.0.0.1:18789/control/cron-jobs?session=
${
session
}
`
,
{
waitUntil
:
'networkidle'
}
)
;
await
page
.
waitForTimeout
(
2000
)
;
const
cronDetails
=
await
page
.
evaluate
(
(
)
=>
{
const
sections
=
{
}
;
// Page info
sections
.
pageTitle
=
document
.
querySelector
(
'h1'
)
?.
textContent
?.
trim
(
)
||
'Cron Jobs'
;
sections
.
pageDescription
=
Array
.
from
(
document
.
querySelectorAll
(
'*'
)
)
.
find
(
el
=>
el
.
textContent
?.
includes
(
'recurring'
)
)
?.
textContent
?.
trim
(
)
;
// Top stats
const
bodyText
=
document
.
body
.
innerText
;
sections
.
topStats
=
{
enabled
:
bodyText
.
includes
(
'ENABLED'
)
,
totalJobs
:
parseInt
(
bodyText
.
match
(
/
J
O
B
S
[
\n
\s
]
*
(
\d
+
)
/
)
?.
[
1
]
||
'0'
)
,
nextWake
:
bodyText
.
includes
(
'NEXT WAKE'
)
}
;
// Buttons
const
allButtons
=
Array
.
from
(
document
.
querySelectorAll
(
'button'
)
)
.
map
(
b
=>
b
.
textContent
?.
trim
(
)
)
.
filter
(
t
=>
t
&&
t
.
length
>
0
)
;
sections
.
mainButtons
=
allButtons
.
filter
(
t
=>
[
'Refresh'
,
'Reset'
]
.
includes
(
t
)
)
;
sections
.
jobActions
=
allButtons
.
filter
(
t
=>
[
'Edit'
,
'Clone'
,
'Enable'
,
'Run'
,
'Run if due'
,
'History'
,
'Remove'
]
.
includes
(
t
)
)
;
// Filter controls
sections
.
filterControls
=
{
hasSearch
:
!
!
document
.
querySelector
(
'input[placeholder*="Search"]'
)
,
selects
:
Array
.
from
(
document
.
querySelectorAll
(
'select'
)
)
.
length
,
filterOptions
:
{
enabled
:
[
'All'
,
'Enabled'
,
'Disabled'
]
.
filter
(
opt
=>
bodyText
.
includes
(
opt
)
)
,
schedule
:
[
'All'
,
'At'
,
'Every'
,
'Cron'
]
.
filter
(
opt
=>
bodyText
.
includes
(
opt
)
)
,
lastRun
:
[
'All'
,
'OK'
,
'Error'
,
'Skipped'
]
.
filter
(
opt
=>
bodyText
.
includes
(
opt
)
)
}
}
;
sections
.
bodyPreview
=
document
.
body
.
innerText
.
substring
(
0
,
2500
)
;
return
sections
;
}
)
;
console
.
log
(
'=== CRON JOBS PAGE DETAILS ==='
)
;
console
.
log
(
JSON
.
stringify
(
cronDetails
,
null
,
2
)
)
;
await
page
.
screenshot
(
{
path
:
'/c/git/JD.AI/cron-session-auth.png'
,
fullPage
:
true
}
)
;
console
.
log
(
'Screenshot: /c/git/JD.AI/cron-session-auth.png'
)
;
await
browser
.
close
(
)
;
}
)
(
)
;
You can’t perform that action at this time.