Initial commit: SIC harness (backend, web, pi-adapter, configs, docs)

- pnpm monorepo: apps/api (Fastify + SQLite + SSE), apps/web (React+Vite), packages/shared, packages/pi-adapter
- Local auth (admin/webhook-runner roles) + Keycloak JWT ready
- Multi-session chat with reliable history (user persisted before LLM, assistant persisted after stream)
- Markdown knowledge base with /api/docs/search + /api/docs/:id
- YAML webhook catalog with backend-only execution, retry/backoff, audit (webhook_runs), and per-user rate limit
- Skills config (sre-on-call, blameless-postmortem, security-incident) injected into LLM system prompt
- LLM provider failover chain (config/models.yml fallback + LLM_FALLBACK_CHAIN override)
- Context-aware webhooks panel + backend id-mention safety net
- Per-message stats (time/duration/tokens/model), Markdown+GFM render, code & table copy/download buttons
- Vitest suite, end-to-end smoke test (scripts/smoke.mjs), per-session system prompt override
- /metrics Prometheus endpoint + /api/metrics JSON, request-id correlation
- dotenv with explicit repo-root path; envString/envNumber helpers (handles empty-string env)
- Runbooks + SOPs under knowledge/ in English; README, docs, and INDEX.md in English
This commit is contained in:
2026-06-29 16:20:53 +02:00
commit 62728b2200
89 changed files with 11992 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
{
"name": "@pi-chat/shared",
"private": true,
"version": "0.1.0",
"type": "module",
"exports": {
".": "./src/index.ts"
},
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "tsc --noEmit"
},
"devDependencies": {
"typescript": "^5.8.3"
}
}

View File

@@ -0,0 +1,33 @@
export type AuthUser = {
id: string;
username?: string;
email?: string;
roles: string[];
};
export type RecommendedAction = {
type: "webhook";
id: string;
confidence: number;
reason: string;
requires_confirmation: boolean;
/**
* Optional soft signal derived from the user's audit history: e.g.
* "3 runs in last 7d, 100% success". The LLM may use this as a tiebreaker;
* the UI uses it to show a "Most used" tag.
*/
usageHint?: string;
};
export type InternalDocReference = {
id: string;
title: string;
source: string;
relevance: number;
};
export type ChatResult = {
answer: string;
recommended_actions: RecommendedAction[];
internal_docs: InternalDocReference[];
};

View File

@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src"]
}