import { startSdk } from '@start9labs/start-sdk' import { sdk } from '../sdk' /** * Returns the latest scorecard as a copyable result, so you can read it straight * from the StartOS service page without opening the dashboard. The job runner * saves the most recent scorecard to /data/reports/latest-scorecard.md (with * /data/reports/latest.md as the legacy fallback) on the StartOS host — no * Spark round-trip. */ export const latestScorecard = sdk.Action.withoutInput( 'latest-scorecard', async ({ effects }) => ({ name: 'View Latest Scorecard', description: 'Show the most recent deck scorecard produced by the grading panel.', warning: null, allowedStatuses: 'any', group: null, visibility: 'enabled', }), async ({ effects }) => { const mounts = sdk.Mounts.of().mountVolume({ volumeId: 'main', mountpoint: '/data', subpath: null, readonly: true, }) let report: string try { const { stdout } = await startSdk.runCommand( effects, { imageId: 'main' }, [ 'sh', '-c', 'cat /data/reports/latest-scorecard.md 2>/dev/null || ' + 'cat /data/reports/latest.md 2>/dev/null || ' + 'echo "(no scorecard yet — drop decks into inbox// and run Grade Decks)"', ], { mounts, env: { BM_DATA_DIR: '/data' } }, 'latest-scorecard', ) report = (stdout?.toString() || '').trim() || '(no scorecard yet)' } catch (e: any) { report = 'Could not read scorecard: ' + (e?.message || String(e)) } return { version: '1', title: 'Latest Scorecard', message: 'The panel\'s most recent deck scorecard.', result: { type: 'single', value: report, copyable: true, qr: false, masked: false }, } }, )