Knowledge Base / Fleet browsing: - EntityTable renders as a treegrid (arbitrary depth, expand/collapse, ARIA row/level/expanded), grouped by parent-child relationships derived entirely from the live ontology graph (cardinality -> direction; typeDepth specificity for ties) rather than a hardcoded relationship list — see loadFleetGrouping in KnowledgeBase.svelte. - Fold Services and Storage categories into Fleet (services/pools/ volumes/datasets now nest under the compute entity or pool that provides/contains them instead of having their own browsing tabs). - Drop `cluster` entities from Fleet browsing so a host's `located-at` (site) relationship wins the tree-parent slot without needing a hardcoded priority override — member-of simply has no valid target left to point at. - Add a "show destroyed/inactive" Switch (default off) filtering on entity.state, replacing an always-on checkbox. Entity detail panel: - Split the Relations section into Outgoing/Incoming groups (relative to the viewed entity), and scope the section's count to edges actually incident to it rather than the whole depth-1 neighborhood. Dev experience: - Auto-fill the SPA's token from the dev server's own OIKOS_API_TOKEN (vite.config.ts define + main.ts, dev-only, only when unconfigured) so the "Connect to Oikos" prompt doesn't reappear on every reload. - .claude/launch.json: autoPort, since port 5173 is often already claimed by another worktree's dev server. Adds ui/checkbox and ui/switch (bits-ui primitives, following the existing shadcn-svelte wrapper pattern) and fetchOntology()/ RelationshipTypeDef to api.ts. Also fixes a missing types.ts import in api.ts (ChatEvent/MessageContent) that predates this branch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
69 lines
2.5 KiB
TypeScript
69 lines
2.5 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 { 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}`)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
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' }
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true
|
|
},
|
|
server: {
|
|
proxy: {
|
|
'/api': authProxy('http://localhost:8090'),
|
|
// 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('http://localhost:8092', (path) => path.replace(/^\/agent/, ''))
|
|
}
|
|
},
|
|
test: {
|
|
environment: 'jsdom',
|
|
globals: true,
|
|
include: ['src/**/*.{test,spec}.{ts,js}']
|
|
}
|
|
})
|