repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
The Living OS cockpit
stars
latest
clone command
git clone gitlawb://did:key:z6Mku78K...XywC/living-os-cockp...git clone gitlawb://did:key:z6Mku78K.../living-os-cockp...59751530feat: surface worker supervisor health in live work4h ago| #1 | #!/usr/bin/env node |
| #2 | const baseUrl = process.env.LIVE_OS_BASE_URL || 'https://king.theliving.ai'; |
| #3 | const hostHeader = process.env.LIVE_OS_HOST_HEADER || ''; |
| #4 | const accessToken = process.env.THELIVING_SMOKE_ACCESS_TOKEN || ''; |
| #5 | const refreshToken = process.env.THELIVING_SMOKE_REFRESH_TOKEN || ''; |
| #6 | |
| #7 | const endpoints = [ |
| #8 | { path: '/api/me', name: 'me' }, |
| #9 | { path: '/api/profile', name: 'profile' }, |
| #10 | { path: '/api/status', name: 'status' }, |
| #11 | { path: '/api/vault-graph', name: 'vault graph', validate: (json) => { |
| #12 | const nodes = Array.isArray(json.nodes) ? json.nodes.length : 0; |
| #13 | const edges = Array.isArray(json.edges) ? json.edges.length : 0; |
| #14 | if (nodes < 60 || edges < 100) throw new Error(`vault graph too small: ${nodes} notes / ${edges} edges`); |
| #15 | } }, |
| #16 | { path: '/api/v1/chat/sessions', name: 'chat sessions', validate: (json) => { |
| #17 | if (!Array.isArray(json.sessions)) throw new Error('sessions payload missing sessions[]'); |
| #18 | } }, |
| #19 | { path: '/api/approval-queue?status=pending', name: 'approval queue', validate: (json) => { |
| #20 | const count = Number(json.count ?? (Array.isArray(json.decisions) ? json.decisions.length : 0)); |
| #21 | if (count < 1) throw new Error(`approval queue empty; expected pending drafts, got ${count}`); |
| #22 | } }, |
| #23 | { path: '/api/aethon-tasks', name: 'aethon tasks', validate: (json) => { |
| #24 | if (!json.totals || typeof json.totals !== 'object') throw new Error('tasks payload missing totals'); |
| #25 | } }, |
| #26 | ]; |
| #27 | |
| #28 | function headersFor(cookie) { |
| #29 | const headers = { Accept: 'application/json' }; |
| #30 | if (cookie) headers.Cookie = cookie; |
| #31 | if (hostHeader) headers.Host = hostHeader; |
| #32 | return headers; |
| #33 | } |
| #34 | |
| #35 | async function hit(endpoint, cookie) { |
| #36 | const url = new URL(endpoint.path, baseUrl).toString(); |
| #37 | const response = await fetch(url, { headers: headersFor(cookie), redirect: 'manual' }); |
| #38 | const text = await response.text(); |
| #39 | let json = null; |
| #40 | try { json = text ? JSON.parse(text) : null; } catch {} |
| #41 | if (!response.ok) { |
| #42 | throw new Error(`${endpoint.name} ${response.status}: ${text.slice(0, 220) || '<empty>'}`); |
| #43 | } |
| #44 | if (!json || typeof json !== 'object') { |
| #45 | throw new Error(`${endpoint.name} returned non-JSON/empty body (${response.status})`); |
| #46 | } |
| #47 | endpoint.validate?.(json); |
| #48 | return { endpoint: endpoint.name, status: response.status, bytes: text.length }; |
| #49 | } |
| #50 | |
| #51 | async function runPass(label, cookie) { |
| #52 | console.log(`\n${label}`); |
| #53 | const results = await Promise.all(endpoints.map(async (endpoint) => { |
| #54 | const result = await hit(endpoint, cookie); |
| #55 | console.log(` ok ${endpoint.path} -> ${result.status} (${result.bytes} bytes)`); |
| #56 | return result; |
| #57 | })); |
| #58 | return results; |
| #59 | } |
| #60 | |
| #61 | if (!accessToken && !refreshToken) { |
| #62 | console.error('Set THELIVING_SMOKE_ACCESS_TOKEN and/or THELIVING_SMOKE_REFRESH_TOKEN. For the stale-token path, set THELIVING_SMOKE_REFRESH_TOKEN and omit access.'); |
| #63 | process.exit(2); |
| #64 | } |
| #65 | |
| #66 | try { |
| #67 | if (accessToken) { |
| #68 | await runPass('access-token panel pass', `theliving_token=${encodeURIComponent(accessToken)}`); |
| #69 | } |
| #70 | if (refreshToken) { |
| #71 | await runPass('stale-access refresh-cookie fan-out pass', `theliving_refresh=${encodeURIComponent(refreshToken)}`); |
| #72 | } |
| #73 | console.log(`\nPASS live OS smoke against ${baseUrl}`); |
| #74 | } catch (error) { |
| #75 | console.error(`\nFAIL live OS smoke against ${baseUrl}`); |
| #76 | console.error(error instanceof Error ? error.message : error); |
| #77 | process.exit(1); |
| #78 | } |
| #79 |