yagami 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- yagami-0.4.1/.gitignore +51 -0
- yagami-0.4.1/CHANGELOG.md +180 -0
- yagami-0.4.1/LICENSE +21 -0
- yagami-0.4.1/PKG-INFO +749 -0
- yagami-0.4.1/README.md +699 -0
- yagami-0.4.1/pyproject.toml +88 -0
- yagami-0.4.1/src/yagami/__init__.py +1 -0
- yagami-0.4.1/src/yagami/api/__init__.py +0 -0
- yagami-0.4.1/src/yagami/api/config.py +118 -0
- yagami-0.4.1/src/yagami/api/costs.py +22 -0
- yagami-0.4.1/src/yagami/api/decisions.py +78 -0
- yagami-0.4.1/src/yagami/api/ingest.py +55 -0
- yagami-0.4.1/src/yagami/api/kb.py +55 -0
- yagami-0.4.1/src/yagami/api/mcp.py +21 -0
- yagami-0.4.1/src/yagami/api/memory.py +124 -0
- yagami-0.4.1/src/yagami/api/openai_compat.py +980 -0
- yagami-0.4.1/src/yagami/api/privacy.py +55 -0
- yagami-0.4.1/src/yagami/api/sessions.py +70 -0
- yagami-0.4.1/src/yagami/api/stats.py +98 -0
- yagami-0.4.1/src/yagami/auth.py +197 -0
- yagami-0.4.1/src/yagami/backends/__init__.py +0 -0
- yagami-0.4.1/src/yagami/backends/anthropic.py +166 -0
- yagami-0.4.1/src/yagami/backends/base.py +89 -0
- yagami-0.4.1/src/yagami/backends/echo.py +31 -0
- yagami-0.4.1/src/yagami/backends/gemini.py +45 -0
- yagami-0.4.1/src/yagami/backends/groq.py +38 -0
- yagami-0.4.1/src/yagami/backends/llama_cpp.py +104 -0
- yagami-0.4.1/src/yagami/backends/mistral.py +46 -0
- yagami-0.4.1/src/yagami/backends/ollama.py +72 -0
- yagami-0.4.1/src/yagami/backends/openai.py +139 -0
- yagami-0.4.1/src/yagami/backends/openai_compat.py +131 -0
- yagami-0.4.1/src/yagami/backends/openrouter.py +48 -0
- yagami-0.4.1/src/yagami/backends/registry.py +86 -0
- yagami-0.4.1/src/yagami/backends/retry.py +82 -0
- yagami-0.4.1/src/yagami/backends/stability.py +66 -0
- yagami-0.4.1/src/yagami/chat/__init__.py +0 -0
- yagami-0.4.1/src/yagami/chat/session.py +140 -0
- yagami-0.4.1/src/yagami/chat/stream.py +583 -0
- yagami-0.4.1/src/yagami/cli.py +102 -0
- yagami-0.4.1/src/yagami/config.py +364 -0
- yagami-0.4.1/src/yagami/doctor.py +51 -0
- yagami-0.4.1/src/yagami/gateway/__init__.py +17 -0
- yagami-0.4.1/src/yagami/gateway/service.py +968 -0
- yagami-0.4.1/src/yagami/generate_key.py +11 -0
- yagami-0.4.1/src/yagami/governance/__init__.py +26 -0
- yagami-0.4.1/src/yagami/governance/approvals.py +195 -0
- yagami-0.4.1/src/yagami/governance/lineage.py +168 -0
- yagami-0.4.1/src/yagami/governance/output.py +32 -0
- yagami-0.4.1/src/yagami/governance/transform.py +263 -0
- yagami-0.4.1/src/yagami/ingest/__init__.py +0 -0
- yagami-0.4.1/src/yagami/ingest/extract.py +85 -0
- yagami-0.4.1/src/yagami/main.py +356 -0
- yagami-0.4.1/src/yagami/memory/__init__.py +8 -0
- yagami-0.4.1/src/yagami/memory/chunker.py +93 -0
- yagami-0.4.1/src/yagami/memory/documents.py +235 -0
- yagami-0.4.1/src/yagami/memory/embedder.py +57 -0
- yagami-0.4.1/src/yagami/memory/retriever.py +189 -0
- yagami-0.4.1/src/yagami/memory/store.py +168 -0
- yagami-0.4.1/src/yagami/memory/worker.py +99 -0
- yagami-0.4.1/src/yagami/policy/__init__.py +23 -0
- yagami-0.4.1/src/yagami/policy/engine.py +215 -0
- yagami-0.4.1/src/yagami/policy/models.py +147 -0
- yagami-0.4.1/src/yagami/policy/replay.py +101 -0
- yagami-0.4.1/src/yagami/privacy.py +129 -0
- yagami-0.4.1/src/yagami/projects.py +134 -0
- yagami-0.4.1/src/yagami/router/__init__.py +0 -0
- yagami-0.4.1/src/yagami/router/classifier.py +124 -0
- yagami-0.4.1/src/yagami/router/fast_path.py +202 -0
- yagami-0.4.1/src/yagami/router/overrides.py +66 -0
- yagami-0.4.1/src/yagami/router/policy.py +484 -0
- yagami-0.4.1/src/yagami/router/prompts.py +47 -0
- yagami-0.4.1/src/yagami/router/schema.py +41 -0
- yagami-0.4.1/src/yagami/router/tool_loop.py +240 -0
- yagami-0.4.1/src/yagami/runtime.py +33 -0
- yagami-0.4.1/src/yagami/secrets.py +54 -0
- yagami-0.4.1/src/yagami/set_key.py +35 -0
- yagami-0.4.1/src/yagami/skills/__init__.py +5 -0
- yagami-0.4.1/src/yagami/skills/adapters.py +32 -0
- yagami-0.4.1/src/yagami/skills/base.py +48 -0
- yagami-0.4.1/src/yagami/skills/calc_eval.py +117 -0
- yagami-0.4.1/src/yagami/skills/kb_recall.py +62 -0
- yagami-0.4.1/src/yagami/skills/mcp_auth.py +113 -0
- yagami-0.4.1/src/yagami/skills/mcp_manager.py +228 -0
- yagami-0.4.1/src/yagami/skills/registry.py +46 -0
- yagami-0.4.1/src/yagami/skills/web_fetch.py +150 -0
- yagami-0.4.1/src/yagami/storage/__init__.py +0 -0
- yagami-0.4.1/src/yagami/storage/db.py +148 -0
- yagami-0.4.1/src/yagami/storage/migrations/001_init.sql +30 -0
- yagami-0.4.1/src/yagami/storage/migrations/002_decision_timings.sql +3 -0
- yagami-0.4.1/src/yagami/storage/migrations/003_costs.sql +3 -0
- yagami-0.4.1/src/yagami/storage/migrations/004_feedback.sql +9 -0
- yagami-0.4.1/src/yagami/storage/migrations/005_observations.sql +57 -0
- yagami-0.4.1/src/yagami/storage/migrations/006_decision_profile.sql +4 -0
- yagami-0.4.1/src/yagami/storage/migrations/007_kb_documents.sql +40 -0
- yagami-0.4.1/src/yagami/storage/migrations/008_message_attachments.sql +15 -0
- yagami-0.4.1/src/yagami/storage/migrations/009_gateway_policy.sql +13 -0
- yagami-0.4.1/src/yagami/storage/migrations/010_privacy_transform_vault.sql +15 -0
- yagami-0.4.1/src/yagami/storage/migrations/011_audit_chain.sql +16 -0
- yagami-0.4.1/src/yagami/storage/migrations/012_tool_approvals.sql +18 -0
- yagami-0.4.1/src/yagami/telemetry/__init__.py +0 -0
- yagami-0.4.1/src/yagami/telemetry/audit.py +169 -0
- yagami-0.4.1/src/yagami/telemetry/costs.py +101 -0
- yagami-0.4.1/src/yagami/telemetry/decisions.py +267 -0
- yagami-0.4.1/src/yagami/telemetry/observability.py +84 -0
yagami-0.4.1/.gitignore
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.env
|
|
2
|
+
.env.local
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.pyc
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.tmp/
|
|
10
|
+
.pytest-tmp/
|
|
11
|
+
.pip-cache/
|
|
12
|
+
dist/
|
|
13
|
+
build/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
|
|
16
|
+
node_modules/
|
|
17
|
+
ui/dist/
|
|
18
|
+
ui/.vite/
|
|
19
|
+
|
|
20
|
+
models/
|
|
21
|
+
loras/
|
|
22
|
+
*.gguf
|
|
23
|
+
*.safetensors
|
|
24
|
+
|
|
25
|
+
.yagami/
|
|
26
|
+
*.sqlite
|
|
27
|
+
*.sqlite-journal
|
|
28
|
+
*.db
|
|
29
|
+
*.db-journal
|
|
30
|
+
*.db-wal
|
|
31
|
+
*.db-shm
|
|
32
|
+
yagami.db
|
|
33
|
+
|
|
34
|
+
perf_*.csv
|
|
35
|
+
|
|
36
|
+
.vscode/
|
|
37
|
+
.idea/
|
|
38
|
+
.DS_Store
|
|
39
|
+
Thumbs.db
|
|
40
|
+
|
|
41
|
+
# Local-only artifacts that should never be committed.
|
|
42
|
+
*.log
|
|
43
|
+
.claude/
|
|
44
|
+
.plans/
|
|
45
|
+
ui/tsconfig.tsbuildinfo
|
|
46
|
+
|
|
47
|
+
# Python build / coverage artifacts.
|
|
48
|
+
*.egg
|
|
49
|
+
.tox/
|
|
50
|
+
.coverage
|
|
51
|
+
htmlcov/
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format loosely
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions
|
|
5
|
+
below `0.3.0` were backfilled from commit history — see the README's
|
|
6
|
+
[Roadmap](README.md#roadmap) for what's planned next rather than what's
|
|
7
|
+
shipped.
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
## [0.4.1] - 2026-07-14
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- OpenAI-compatible `POST /v1/chat/completions`, `GET /v1/models`, and a core
|
|
15
|
+
`POST /v1/responses` text/streaming surface for headless integrations.
|
|
16
|
+
- Versioned YAML/JSON policy engine with canonical policy hashes, restrictive
|
|
17
|
+
rule merging, hot reload, caller context, sensitivity hints, shadow mode,
|
|
18
|
+
and `POST /v1/policy/preview`.
|
|
19
|
+
- Bearer API keys mapped to project identities through `YAGAMI_API_KEYS`.
|
|
20
|
+
- Scoped service accounts, multiple separation-of-duties keys per project,
|
|
21
|
+
hot-reloaded project rate/concurrency/spend/context limits, and authenticated
|
|
22
|
+
metrics/audit operations.
|
|
23
|
+
- Content-free context-lineage graphs, AES-GCM local tokenization and
|
|
24
|
+
rehydration, output allow/redact/block DLP, and policy simulation/replay.
|
|
25
|
+
- Caller-defined Chat Completions function tools plus durable, short-lived,
|
|
26
|
+
one-time approval capabilities bound to project, purpose, and tool pattern.
|
|
27
|
+
- Governed remote MCP over Streamable HTTP with HTTPS enforcement, dedicated
|
|
28
|
+
bearer secrets or OAuth client credentials, audience/resource binding, and
|
|
29
|
+
token caching.
|
|
30
|
+
- Project-scoped tamper-evident SHA-256/HMAC audit chains with verification and
|
|
31
|
+
SIEM-friendly NDJSON export.
|
|
32
|
+
- A containment benchmark with synthetic PHI/PII/secrets, RAG contamination,
|
|
33
|
+
tool-governance cases, benign controls, and JSON/JUnit output.
|
|
34
|
+
- Policy passports on gateway ledger rows, privacy-safe OpenTelemetry span
|
|
35
|
+
attributes, and low-cardinality Prometheus metrics.
|
|
36
|
+
- Hardened non-root Docker image, Compose deployment, container CI, and an
|
|
37
|
+
immutable release workflow for wheels and multi-architecture GHCR images.
|
|
38
|
+
- Clean-install and runtime smoke tests, high/critical vulnerability gates,
|
|
39
|
+
checksums, SPDX SBOMs, license inventory, and GitHub build-provenance
|
|
40
|
+
attestations for public artifacts.
|
|
41
|
+
- OIDC-only PyPI Trusted Publishing behind a dedicated GitHub environment;
|
|
42
|
+
no long-lived package-registry token is stored in GitHub.
|
|
43
|
+
|
|
44
|
+
### Security
|
|
45
|
+
- Explicit remote backend and slash-command routes now run semantic privacy
|
|
46
|
+
classification before cloud egress. Classifier failures fail local for
|
|
47
|
+
automatic routing and refuse explicit remote routes.
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
- **PHI-history gate now covers every cloud text backend.** It previously
|
|
51
|
+
matched `backend.name == "anthropic"` literally, so `/mistral`, `/groq`,
|
|
52
|
+
`/openrouter`, `/gemini`, and `/openai` (slash or `force_backend`) could
|
|
53
|
+
ship PHI-containing chat history to those clouds. The gate is now
|
|
54
|
+
capability-based (cloud + TEXT); image gen stays exempt as before.
|
|
55
|
+
- **Daily spend cap now covers every cloud backend** (same name-list bug),
|
|
56
|
+
including the fast-path and the default route - a cloud `default_backend`
|
|
57
|
+
previously bypassed both gates entirely and now falls back to local with
|
|
58
|
+
an explanatory reason instead.
|
|
59
|
+
- **Profile overrides now affect the live spend gate** - it read the base
|
|
60
|
+
`[routing]` config instead of the profile-adjusted one.
|
|
61
|
+
- Vision attachments pick the first configured vision-capable backend
|
|
62
|
+
(anthropic, then gemini/openai/openrouter) instead of hard-requiring
|
|
63
|
+
anthropic; a clear error is returned when none is configured.
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
- `block_cloud` flag on `[routing]` and per-profile - refuse ALL cloud
|
|
67
|
+
routes unconditionally. This is the correct way to express a zero-cloud
|
|
68
|
+
profile; `daily_spend_cap_usd = 0` means *no cap* (the README previously
|
|
69
|
+
mis-documented it as "no cloud spend").
|
|
70
|
+
|
|
71
|
+
### Hardened
|
|
72
|
+
- MCP tool calls carry a 60s read timeout so a hung server can't hang a turn.
|
|
73
|
+
- Folder indexing serializes concurrent `POST /api/kb/index` runs.
|
|
74
|
+
|
|
75
|
+
## [0.3.0] - 2026-07-13
|
|
76
|
+
|
|
77
|
+
- OSS project hygiene: CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, issue/PR
|
|
78
|
+
templates.
|
|
79
|
+
- Onboarding: `yagami` CLI entry point, one-shot setup scripts, documented
|
|
80
|
+
single-process (`ui/dist` static-mount) quick-try path.
|
|
81
|
+
- New backends: Mistral, Groq, OpenRouter, Gemini, via a shared
|
|
82
|
+
`OpenAICompatBackend`. Slash overrides now resolve generically against any
|
|
83
|
+
registered backend name (`/openai`, `/mistral`, ...) instead of a fixed
|
|
84
|
+
alias list - this also fixes `/openai`, which was documented but never
|
|
85
|
+
actually worked.
|
|
86
|
+
- Compliance tooling: Privacy Ledger CSV export (`GET /api/decisions/export`)
|
|
87
|
+
and named config profiles (live-switchable, `phi_must_be_local`
|
|
88
|
+
non-overridable by any profile).
|
|
89
|
+
- Folder-indexed document knowledge base: `POST /api/kb/index` + `kb.recall`
|
|
90
|
+
skill, backed by a new `kb_documents` corpus separate from chat memory.
|
|
91
|
+
- MCP client support: connect to external MCP servers over stdio
|
|
92
|
+
(`[mcp_servers.*]` in config), their tools become Yagami skills
|
|
93
|
+
(`mcp.<server>.<tool>`) automatically.
|
|
94
|
+
|
|
95
|
+
## [0.2.16] - 2026-06-02
|
|
96
|
+
|
|
97
|
+
- Cross-session memory retrieval: `needs_recall` classifier signal, memory
|
|
98
|
+
injection into prompts, vacuum job, Memory panel in the UI.
|
|
99
|
+
|
|
100
|
+
## [0.2.15] - 2026-06-02
|
|
101
|
+
|
|
102
|
+
- Cross-session memory write path: sqlite-vec storage, `all-minilm`
|
|
103
|
+
embeddings, async embedding worker.
|
|
104
|
+
|
|
105
|
+
## [0.2.14] - 2026-06-01
|
|
106
|
+
|
|
107
|
+
- Multi-turn tool-use loop: `Skill` protocol, `calc.eval` and `web.fetch`
|
|
108
|
+
first-party skills, Claude tool-calling integration.
|
|
109
|
+
|
|
110
|
+
## [0.2.13] - 2026-06-01
|
|
111
|
+
|
|
112
|
+
- Pluggable backend registry (filesystem discovery), OpenAI backend,
|
|
113
|
+
optional `llama-cpp-python` backend, per-backend `Pricing`.
|
|
114
|
+
|
|
115
|
+
## [0.2.12] - 2026-06-01
|
|
116
|
+
|
|
117
|
+
- Settings UI and Stats dashboard — config becomes browser-editable instead
|
|
118
|
+
of TOML-only.
|
|
119
|
+
|
|
120
|
+
## [0.2.11] - 2026-06-01
|
|
121
|
+
|
|
122
|
+
- Routing eval suite at 100%, `/reset` slash command, toast notifications,
|
|
123
|
+
draft persistence, keyboard shortcuts, stats, thumbs up/down feedback.
|
|
124
|
+
|
|
125
|
+
## [0.2.10] - 2026-05-31
|
|
126
|
+
|
|
127
|
+
- Per-turn classification with a `history_has_phi` gate on cloud routes;
|
|
128
|
+
dropped the earlier "sticky sensitivity floor" design.
|
|
129
|
+
|
|
130
|
+
## [0.2.9] - 2026-05-31
|
|
131
|
+
|
|
132
|
+
- OS keyring for API keys, daily spend cap, auto-retry on transient cloud
|
|
133
|
+
errors, file ingest (PDF/MD/TXT), vision input.
|
|
134
|
+
|
|
135
|
+
## [0.2.8] - 2026-05-30
|
|
136
|
+
|
|
137
|
+
- PHI floor enforcement, sidebar session management, markdown rendering,
|
|
138
|
+
copy/regenerate, CI workflow, eval diffing.
|
|
139
|
+
|
|
140
|
+
## [0.2.7] - 2026-05-29
|
|
141
|
+
|
|
142
|
+
- User-facing routing overrides (slash commands) and routing transparency
|
|
143
|
+
in the UI.
|
|
144
|
+
|
|
145
|
+
## [0.2.6] - 2026-05-29
|
|
146
|
+
|
|
147
|
+
- Phi-4 Mini JSON-mode classifier, few-shot prompting, secret/image
|
|
148
|
+
fast-path bypass.
|
|
149
|
+
|
|
150
|
+
## [0.2.5] - 2026-05-28
|
|
151
|
+
|
|
152
|
+
- Eval suite scaffolding, classifier prompt sharpening.
|
|
153
|
+
|
|
154
|
+
## [0.2.4] - 2026-05-28
|
|
155
|
+
|
|
156
|
+
- UI layout fixes, ledger timings surfaced in the UI, imperative fast-path
|
|
157
|
+
bypass.
|
|
158
|
+
|
|
159
|
+
## [0.2.3] - 2026-05-28
|
|
160
|
+
|
|
161
|
+
- Latency reduction: fast-path bypass for trivial prompts, per-request
|
|
162
|
+
system prompt.
|
|
163
|
+
|
|
164
|
+
## [0.2.2] - 2026-05-28
|
|
165
|
+
|
|
166
|
+
- Stronger PHI-medical system prompt to break local-model safety refusals
|
|
167
|
+
on legitimate clinical-documentation prompts.
|
|
168
|
+
|
|
169
|
+
## [0.2.1] - 2026-05-28
|
|
170
|
+
|
|
171
|
+
- `yagami-phi-medical` prompt variant wired in, textarea chat input.
|
|
172
|
+
|
|
173
|
+
## [0.2.0] - 2026-05-28
|
|
174
|
+
|
|
175
|
+
- Privacy Ledger and persistence foundation: routing decisions logged with
|
|
176
|
+
PII/PHI scrubbing.
|
|
177
|
+
|
|
178
|
+
## [0.1.0] - 2026-05-28
|
|
179
|
+
|
|
180
|
+
- Initial commit: FastAPI + React local-first AI router skeleton.
|
yagami-0.4.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yagami contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|