Commit Graph

567 Commits

Author SHA1 Message Date
Apple
7c3bc68ac2 clan: restore zhos_mvp profile in crewai-service and re-enable clan zhos routing 2026-02-18 09:56:06 -08:00
Apple
b65ed7cdf2 clan: stop forcing missing zhos_mvp crew profile; use available default 2026-02-18 09:43:33 -08:00
Apple
13aa0c79f0 router: bundle CLAN runtime registry in router image path 2026-02-18 09:42:00 -08:00
Apple
63fec84734 clan: map runtime-guard manager alias so agent_id=clan is recognized 2026-02-18 09:40:54 -08:00
Apple
bfd0e05bc9 doc-service: parse fact_value_json string in doc context lookup 2026-02-18 09:37:54 -08:00
Apple
30ea12e0f8 doc-service: persist doc_context by stable session key 2026-02-18 09:37:12 -08:00
Apple
d42bb09912 helion: stabilize doc context, remove legacy webhook path, add stack smoke canary 2026-02-18 09:36:16 -08:00
Apple
760022d7f5 helion: ignore keyword complexity hints; trigger CrewAI only by explicit detailed/complex flags 2026-02-18 09:25:52 -08:00
Apple
635f2d7e37 helion: deepseek-first, on-demand CrewAI, local subagent profiles, concise post-synthesis 2026-02-18 09:21:47 -08:00
Apple
343bdc2d11 prompts: add DAARWIZZ awareness to legacy nutra prompt 2026-02-18 08:44:04 -08:00
Apple
6b5e462c85 prompts: enforce DAARWIZZ awareness across top-level agents 2026-02-18 08:43:29 -08:00
Apple
e5a6e310b7 ops: make DAARWIZZ awareness canary static by default with optional runtime mode 2026-02-18 08:29:02 -08:00
Apple
00b77066b0 ops: add DAARWIZZ awareness canary for all top-level agents 2026-02-18 08:22:50 -08:00
Apple
2c03632f67 senpai: enforce DAARWIZZ network awareness; sync daarwizz delegation roster 2026-02-18 08:12:03 -08:00
Apple
71b248de23 gitignore: ignore runtime canary status artifacts 2026-02-18 06:14:11 -08:00
Apple
249b2e1e94 ops: restore canary_all and harden monitor summary script invocation 2026-02-18 06:13:15 -08:00
Apple
77ab034744 Sync NODE1 crewai-service runtime files and monitor summary script 2026-02-18 06:00:19 -08:00
Apple
963813607b Docs sync: align OPENAPI contracts with NODE1 runtime 2026-02-18 05:58:54 -08:00
Apple
b9f83a5006 Sync NODE1 runtime config for Sofiia monitor + Clan canary fixes 2026-02-18 05:56:21 -08:00
Apple
7df8cd5882 docs: sync consolidation and session starter 2026-02-16 02:25:54 -08:00
Apple
798c6f88c7 docs: sync consolidation and session starter 2026-02-16 02:21:49 -08:00
Apple
b962d4a288 docs: sync consolidation and session starter 2026-02-16 02:15:59 -08:00
Apple
de3bd8c13f docs: sync consolidation and session starter 2026-02-16 02:15:20 -08:00
Apple
b2be937fbb feat(file-tool): add djvu conversion and extraction actions 2026-02-15 03:11:55 -08:00
Apple
3a565fd910 feat(file-tool): harden svg rendering and add rich pptx/pdf updates 2026-02-15 02:48:35 -08:00
Apple
aad5870e81 feat(file-tool): add image_bundle and svg actions 2026-02-15 02:33:42 -08:00
Apple
36314a871f feat(file-tool): add pptx ods parquet and image actions 2026-02-15 02:30:00 -08:00
Apple
cf6ac778bb feat(file-tool): add text markdown xml html actions 2026-02-15 02:24:11 -08:00
Apple
e91584246d feat(router): implement file_tool excel actions on NODE1 stack 2026-02-15 02:11:28 -08:00
Apple
21576f0ca3 node1: add universal file tool, gateway document delivery, and sync runbook 2026-02-15 01:50:37 -08:00
Apple
dd4b466d79 feat: Register Comfy agent in agent registry
- Add Comfy as node_local internal agent on NODE3
- Scope: node-3-threadripper-rtx3090
- API endpoint: http://212.8.58.133:8880
- NATS subject: agent.invoke.comfy
- Capabilities: text-to-image, text-to-video, image-to-video
- Specialized tools: comfy_generate_image, comfy_generate_video

Co-Authored-By: Warp <agent@warp.dev>
2026-02-10 04:43:46 -08:00
Apple
25e57d8221 feat: Add valid ComfyUI SD1.5 workflow to comfy-agent
- Replace placeholder workflow with complete SD1.5 pipeline
- Support dynamic prompt, negative_prompt, steps, seed, width, height
- Nodes: CheckpointLoader -> CLIP -> KSampler -> VAE -> SaveImage

Co-Authored-By: Warp <agent@warp.dev>
2026-02-10 04:39:40 -08:00
Apple
42599787a6 chore(helion): respond to direct mentions in groups
Clarify Helion group behavior: stay silent unless energy topic or direct mention, but answer operational questions when directly addressed.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 04:20:03 -08:00
Apple
7f3ee700a4 fix(router): guard DSML tool-call flows
Prevent DeepSeek DSML from leaking to users and avoid returning raw memory_search/web results when DSML is detected.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-10 04:19:57 -08:00
Apple
c41c68dc08 feat: Add Comfy Agent service for NODE3 image/video generation
- Create comfy-agent service with FastAPI + NATS integration
- ComfyUI client with HTTP/WebSocket support
- REST API: /generate/image, /generate/video, /status, /result
- NATS subjects: agent.invoke.comfy, comfy.request.*
- Async job queue with progress tracking
- Docker compose configuration for NODE3
- Update PROJECT-MASTER-INDEX.md with NODE2/NODE3 docs

Co-Authored-By: Warp <agent@warp.dev>
2026-02-10 04:13:49 -08:00
Apple
6e0887abcd docs: SenpAI integration log + healthcheck fix
- PROJECT-MASTER-INDEX: add "Зміни 2026-02-09" section (market data + Senpai tool integration)
- docker-compose: senpai-md-consumer healthcheck timeout 5s→10s, retries 3→5

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 12:55:08 -08:00
Apple
0555ee9fa6 docs: update NODE1 docs for MD pipeline deploy (ports 8893/8892)
- Fix market-data-service host port 8891→8893 (conflict with Swapper)
- Increase healthcheck start_period/retries for market-data-service
- Add Market Data Service + SenpAI MD Consumer to PROJECT-MASTER-INDEX.md
- Update noda1-operations rule and skill with new ports/containers

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 12:27:45 -08:00
Apple
09dee24342 feat: MD pipeline — market-data-service hardening + SenpAI NATS consumer
Producer (market-data-service):
- Backpressure: smart drop policy (heartbeats→quotes→trades preserved)
- Heartbeat monitor: synthetic HeartbeatEvent on provider silence
- Graceful shutdown: WS→bus→storage→DB engine cleanup sequence
- Bybit V5 public WS provider (backup for Binance, no API key needed)
- FailoverManager: health-based provider switching with recovery
- NATS output adapter: md.events.{type}.{symbol} for SenpAI
- /bus-stats endpoint for backpressure monitoring
- Dockerfile + docker-compose.node1.yml integration
- 36 tests (parsing + bus + failover), requirements.lock

Consumer (senpai-md-consumer):
- NATSConsumer: subscribe md.events.>, queue group senpai-md, backpressure
- State store: LatestState + RollingWindow (deque, 60s)
- Feature engine: 11 features (mid, spread, VWAP, return, vol, latency)
- Rule-based signals: long/short on return+volume+spread conditions
- Publisher: rate-limited features + signals + alerts to NATS
- HTTP API: /health, /metrics, /state/latest, /features/latest, /stats
- 10 Prometheus metrics
- Dockerfile + docker-compose.senpai.yml
- 41 tests (parsing + state + features + rate-limit), requirements.lock

CI: ruff + pytest + smoke import for both services
Tests: 77 total passed, lint clean
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 11:46:15 -08:00
Apple
c50843933f feat: market-data-service for SenpAI trading agent
New service: real-time market data collection with unified event model.

Architecture:
- Domain events: TradeEvent, QuoteEvent, BookL2Event, HeartbeatEvent
- Provider interface: MarketDataProvider ABC with connect/subscribe/stream/close
- Async EventBus with fan-out to multiple consumers

Providers:
- BinanceProvider: public WebSocket (trades + bookTicker), no API key needed,
  auto-reconnect with exponential backoff, heartbeat timeout detection
- AlpacaProvider: IEX real-time data + paper trading auth,
  dry-run mode when no keys configured (heartbeats only)

Consumers:
- StorageConsumer: SQLite (via SQLAlchemy async) + JSONL append-only log
- MetricsConsumer: Prometheus counters, latency histograms, events/sec gauge
- PrintConsumer: sampled structured logging (1/100 events)

CLI: python -m app run --provider binance --symbols BTCUSDT,ETHUSDT
HTTP: /health, /metrics (Prometheus), /latest?symbol=XXX

Tests: 19/19 passed (Binance parse, Alpaca parse, bus smoke tests)

Config: pydantic-settings + .env, all secrets via environment variables.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 11:19:00 -08:00
Apple
ad6b6d2662 feat: enable brand commands MVP — ENABLE_BRAND_COMMANDS=true
Brand commands are now active in Gateway:
- /бренд — help menu
- /бренд_інтейк <url|текст> — save brand source
- /бренд_тема <brand_id> [версія] — publish theme
- /бренд_останнє <brand_id> — show latest theme
- /презентація — render presentation
- /job_статус — check job status

All 4 brand services verified healthy:
- brand-intake:9211, brand-registry:9210
- presentation-renderer:9212, artifact-registry:9220

Feature flag ENABLE_BRAND_COMMANDS=true added to gateway env
in docker-compose.node1.yml.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:33:47 -08:00
Apple
7887f7cbe9 fix: DSML fallback — 3rd LLM call for clean synthesis + think tag stripping
Router (main.py):
- When DSML detected in 2nd LLM response after tool execution,
  make a 3rd LLM call with explicit synthesis prompt instead of
  returning raw tool results to the user
- Falls back to format_tool_calls_for_response only if 3rd call fails

Router (tool_manager.py):
- Added _strip_think_tags() helper for <think>...</think> removal
  from DeepSeek reasoning artifacts

Gateway (http_api.py):
- Strip <think>...</think> tags before sending to Telegram
- Strip DSML/XML-like markup (function_calls, invoke, parameter tags)
- Ensure empty text after stripping gets "..." fallback

Deployed to NODE1 and verified services running.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:30:37 -08:00
Apple
990e594a1d feat: harden memory summary — fingerprint dedup, versioning, prompt injection defense
Summary hardening:
- SHA256 fingerprint of events content for deduplication
  (skips LLM call when events unchanged since last summary)
- Versioned summary storage: summary:agent:channel:vN keys
- Latest pointer: summary_latest:agent:channel for fast retrieval
- Prompt injection defense: sanitize event content before LLM,
  strip [SYSTEM]/[INTERNAL] markers, block "ignore instructions" patterns
- Anti-injection clause in SUMMARY_SYSTEM_PROMPT

Database fix:
- list_facts_by_agent: SQL filter by fact_prefix to only return chat_events
  (prevents summary/version facts from consuming LIMIT quota)
- Fixed NULL team_id issue in UNIQUE constraint (PostgreSQL NULL != NULL)
  using "__system__" sentinel for team_id in summary operations

Tested on NODE1: dedup works (same events → skipped), force=true bypasses.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:26:03 -08:00
Apple
0cfd3619ea feat: auto-summarize trigger for agent memory
- Memory Service: POST /agents/{agent_id}/summarize endpoint
  - Fetches recent events by agent_id (new db.list_facts_by_agent)
  - Generates structured summary via DeepSeek LLM
  - Saves summary to PostgreSQL facts + Qdrant vector store
  - Returns structured JSON (summary, goals, decisions, key_facts)

- Gateway memory_client: auto-trigger after 30 turns
  - Turn counter per chat (agent_id:channel_id)
  - 5-minute debounce between summarize calls
  - Fire-and-forget via asyncio.ensure_future (non-blocking)
  - Configurable via SUMMARIZE_TURN_THRESHOLD / SUMMARIZE_DEBOUNCE_SECONDS

- Database: list_facts_by_agent() for agent-level queries without user_id

Tested on NODE1: Helion summarize returns valid Ukrainian summary with 20 events.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:15:43 -08:00
Apple
acceac6929 fix: helion string literal + memory brief anti-echo in Router
- Fixed unquoted `helion` variable reference to string literal `"helion"`
  in tool_manager.py search_memories fallback
- Replaced `[Контекст пам'яті]` with `[INTERNAL MEMORY - do NOT repeat
  to user]` in all 3 injection points in main.py
- Verified: Senpai now responds without Helion contamination or memory
  brief leaking

Tested and deployed on NODE1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:05:25 -08:00
Apple
b9f7ca8ecf fix(critical): Senpai using Helion's memory — 3 root causes fixed
1. YAML structure bug: Senpai was in `policies:` instead of `agents:`
   in router-config.yml. Router couldn't find Senpai config → no routing
   rule → fallback to local model.

2. tool_manager agent_id not passed: memory_search and graph_query
   tools were called without agent_id → defaulted to "helion" →
   ALL agents' tool calls searched Helion's Qdrant collections.
   Fixed: agent_id now flows from main.py → execute_tool → _memory_search.

3. Config not mounted: router-config.yml was baked into Docker image,
   host changes had no effect. Added volume mount in docker-compose.

Also added:
- Sofiia agent config + routing rule (was completely missing)
- Senpai routing rule: cloud_deepseek (was falling to local qwen3:8b)
- Anti-echo instruction for memory brief injection

Deployed and verified on NODE1: Senpai now searches senpai_* collections.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 10:00:08 -08:00
Apple
3b924118be fix: quarantine dead brand commands + implement Memory LLM summary
Brand commands (~290 lines):
- Code was trapped inside `if reply_to_message:` block (unreachable)
- Moved to feature flag: ENABLE_BRAND_COMMANDS=true to activate
- Zero re-indentation: 8sp code naturally fits as feature flag body
- Helper functions (_brand_*, _artifact_*) unchanged

Memory LLM Summary:
- Replace placeholder with real DeepSeek API integration
- Structured output: summary, goals, decisions, open_questions, next_steps, key_facts
- Graceful fallback if API key not set or call fails
- Added MEMORY_DEEPSEEK_API_KEY config
- Ukrainian output language

Deployed and verified on NODE1.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:42:44 -08:00
Apple
27e66b90bf feat: thread_has_agent_participation + ACK reply linkage
1. thread_has_agent_participation (SOWA Priority 11):
   - New function has_agent_chat_participation() in behavior_policy.py
   - Checks if agent responded to ANY user in this chat within 30min
   - When active + user asks question/imperative → agent responds
   - Different from per-user conversation_context (Priority 12)
   - Wired into both detect_explicit_request() and analyze_message()

2. ACK reply_to_message_id:
   - When SOWA sends ACK ("NUTRA тут"), it now replies to the user's
     message instead of sending a standalone message
   - Better UX: visually linked to what the user wrote
   - Uses allow_sending_without_reply=True for safety

Known issue (not fixed - too risky):
- Lines 1368-1639 in http_api.py are dead code (brand commands /бренд)
  at incorrect indentation level (8 spaces, inside unreachable block)
- These commands never worked on NODE1, fixing 260 lines of indentation
  carries regression risk — deferred to separate cleanup PR

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:24:00 -08:00
Apple
1f4472ec18 feat: reply-to-agent detection in Gateway → SOWA Priority 3
When a user replies to an agent's message in Telegram groups,
it is now treated as a direct mention (SOWA FULL response).

Implementation:
- Detect reply_to_message.from.is_bot in Gateway webhook handler
- Verify bot_id matches this agent's token (multi-agent safe)
- Pass is_reply_to_agent=True to detect_explicit_request() and
  analyze_message() (SOWA v2.2)
- Add is_reply_to_agent to Router metadata for analytics

SOWA already had Priority 3 logic for reply_to_agent → FULL,
it was just never wired up (had TODO placeholders with False).

Edge cases handled:
- Only triggers when reply is to THIS agent's bot (not other bots)
- Reply to forwarded messages: won't trigger (from.is_bot would be
  the original sender, not the bot)
- Works alongside existing DM, mention, and training group rules

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:16:02 -08:00
Apple
aee2a55a26 fix: CI branch filter + Cursor auto-context rules
CI:
- python-services-ci now only runs on main branch (not feature branches)
- Install deps with lock fallback (if lock file is stale, install without it)

Cursor rules:
- New project-context.mdc (alwaysApply: true) — gives AI full project
  context immediately in every new chat
- Updated noda1-operations.mdc: alwaysApply: true, fixed container names
  (dagi-router-node1, not dagi-staging-router)

This ensures that when opening a new Cursor chat in this workspace,
the AI already knows: project structure, NODE1 server details, all 13
agents, SSH credentials location, and key documentation paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 09:09:20 -08:00
Apple
a1599df053 fix: SOWA agent name variants + vision denial prevention
SOWA fixes:
- Add Russian variants for all agents (сэнпай, хелион, друид, etc.)
- Add missing sofiia agent to AGENT_NAME_VARIANTS
- Add /senpai, /sofiia command prefixes

Vision denial fix (all 13 agents):
- Add explicit rule: "Never say you can't see/analyze images"
- Agents have Vision API via Swapper (qwen3-vl-8b)
- When vision model describes a photo, the follow-up text model (DeepSeek)
  must not deny having seen it

Root cause: NUTRA correctly analyzed a photo via vision model, but when
asked a follow-up question, DeepSeek (text model) responded "I cannot
see images" because the system prompt lacked the denial prevention rule.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 08:49:11 -08:00