Monitoring coverage was 3 of 89 active entities. Three bugs, each hidden by discarded errors in checkdefaults: - writeCheck generated a fresh uuid, inserted the check entity ON CONFLICT (slug) DO NOTHING, then wrote a check_defs row referencing it. On any re-seed the slug already existed, the entity insert no-oped, and the FK violated — aborting the ingest transaction and surfacing as an unrelated failure several entities later. Re-seeding has been broken since; prod's coverage was frozen at its first successful seed. This is what TestSeedIngestIdempotentAndNoDuplicateEdges had been reporting. - shortSlug truncated to the last 8 chars, so all 21 ingress routes collapsed to ".network" and overwrote each other; service:jellyfin collided with lxc:jellyfin. - The ssh-script checker never read the `args` config checkdefaults wrote, so process_check.sh always ran without its unit name and returned "unknown". Coverage is now 75/89. Monitoring is declared per entity type in seeds/ontology.yaml and resolved through the is-a hierarchy, so a type can say it warrants nothing (site, lan, mesh, cluster) and never be reported as a gap. coverageSweep raises an `unmonitored` signal only where a type declares monitoring it lacks — 8 real gaps, no false positives. Also: - entity_types.attribute_schema was never ingested: the seed loader read "attribute_schema" but the YAML says "attributes", so all 60 types stored JSON null. - ListExecutions ignored its declared target/action/correlation_id filters and paginated on a non-unique target slug, dropping and repeating rows. - started_at was captured but only written at terminal state, so a running execution reported NULL for its whole life. The three MCP auto-run copies wrote no timing at all; they are now one autoRun helper. - SSH output was buffered to completion and discarded entirely on timeout. Both sshExec copies now stream through a shared execlog sink into execution_logs, and keep partial output when a command is cancelled. - executions.correlation_id was a random per-execution uuid that correlated nothing; it is now the chat session id, which is what lets the chat tail live output. - reversible_low had no auto-run branch despite policy declaring it unattended. Since computeCommandRisk never returns it, the class only arises when an agent declares it over a read_only command — so gating it penalised candor without adding safety. - backup-target gains a backup-freshness checker (portable find -mmin, since the first target is on macOS), resolving its host by walking backs-up-to backwards. The pre-deploy pg_dump is now a tracked backup target. UI: an Executions section on entity detail with live output tailing, and streamed output under a running `run` call in the chat timeline. Migrations 022-024. Ops.svelte and context.ts exclude execution.output from their refetch triggers, which would otherwise fire once a second per command. Co-Authored-By: Claude <noreply@anthropic.com>
98 lines
3.9 KiB
TypeScript
98 lines
3.9 KiB
TypeScript
/// <reference types="vitest/config" />
|
|
import type { ProxyOptions } from 'vite'
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import { readFileSync, existsSync } from 'fs'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
|
|
// In Docker, VERSION is copied into the build WORKDIR (/build/web/VERSION).
|
|
// In local dev, the cwd is web/ and VERSION is two dirs up (../../VERSION
|
|
// from vite.config.ts location in web/). Try both.
|
|
let version: string
|
|
if (existsSync('../VERSION')) {
|
|
version = readFileSync('../VERSION', 'utf-8').trim()
|
|
} else {
|
|
version = readFileSync('VERSION', 'utf-8').trim()
|
|
}
|
|
|
|
// Injects OIKOS_API_TOKEN into proxied /api requests in dev — the API no
|
|
// longer has a dev-open bypass (plans/2026-07-12-wails-desktop-app.md 0.4),
|
|
// so `OIKOS_API_TOKEN=dev-token npm run dev` needs this to reach it.
|
|
function authProxy(target: string, rewrite?: (path: string) => string): ProxyOptions {
|
|
return {
|
|
target,
|
|
...(rewrite ? { rewrite } : {}),
|
|
configure: (proxy) => {
|
|
proxy.on('proxyReq', (proxyReq) => {
|
|
const token = process.env.OIKOS_API_TOKEN
|
|
if (token) proxyReq.setHeader('Authorization', `Bearer ${token}`)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
// Where `npm run dev` proxies to. The SPA is hardwired to same-origin in dev
|
|
// (see the __OIKOS_DEV_TOKEN__ define below), so these targets — not
|
|
// localStorage — decide which backend a dev session actually talks to. They
|
|
// default to the local prod stack, which is what you want day to day; override
|
|
// them to point a dev SPA at a scratch API without touching this file:
|
|
//
|
|
// OIKOS_API_PROXY=http://127.0.0.1:8199 npm run dev
|
|
const apiTarget = process.env.OIKOS_API_PROXY ?? 'http://localhost:8090'
|
|
const nomosTarget = process.env.OIKOS_NOMOS_PROXY ?? 'http://localhost:8092'
|
|
|
|
export default defineConfig({
|
|
plugins: [tailwindcss(), svelte()],
|
|
base: '/',
|
|
define: {
|
|
__OIKOS_VERSION__: JSON.stringify(`v${version}`),
|
|
// Lets the dev server auto-configure the SPA with the same token it
|
|
// already injects into proxied requests (see authProxy above), so `npm
|
|
// run dev` skips the "Connect to Oikos" prompt instead of re-asking for
|
|
// a token every time localStorage gets cleared. Empty string (never a
|
|
// real prod secret — see main.ts, only consulted in import.meta.env.DEV)
|
|
// when OIKOS_API_TOKEN isn't set, so the prompt still shows if unconfigured.
|
|
__OIKOS_DEV_TOKEN__: JSON.stringify(process.env.OIKOS_API_TOKEN ?? '')
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
$lib: '/src/lib',
|
|
// svelte-splitpanes imports SvelteKit's browser-detection module; this
|
|
// isn't a SvelteKit app, so point it at a plain shim (see the file).
|
|
// Needs a real filesystem path (not the /src/... shorthand $lib uses)
|
|
// so esbuild's dependency pre-bundler can resolve it too.
|
|
'$app/environment': fileURLToPath(
|
|
new URL('./src/lib/shims/app-environment.ts', import.meta.url)
|
|
)
|
|
}
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true
|
|
},
|
|
optimizeDeps: {
|
|
// svelte-splitpanes imports SvelteKit's $app/environment (aliased above
|
|
// to a shim), but esbuild's dependency pre-bundler resolves that
|
|
// differently and fails before the dev server even starts — skip
|
|
// pre-bundling it so it goes through Vite's normal (alias-aware)
|
|
// transform pipeline instead.
|
|
exclude: ['svelte-splitpanes']
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': authProxy(apiTarget),
|
|
// Production Caddy strips /agent before forwarding to nomos
|
|
// (compose/caddy/Caddyfile.oikos handle_path /agent/*); match that
|
|
// here so dev and prod agree on nomos's actual route paths.
|
|
'/agent': authProxy(nomosTarget, (path) => path.replace(/^\/agent/, ''))
|
|
}
|
|
},
|
|
test: {
|
|
environment: 'jsdom',
|
|
globals: true,
|
|
setupFiles: ['src/test-setup.ts'],
|
|
include: ['src/**/*.{test,spec}.{ts,js}']
|
|
}
|
|
})
|