11 Commits

Author SHA1 Message Date
admin 065a6f3d1a fix: tighten OW background request filter to stop spurious task creation
Added three new detection patterns beyond the existing keyword checks:
1. Conversation history dumps: messages containing both "user:" and
   "assistant:" role markers — real user messages never have both
2. Context synthesis phrases: "provided context", "following conversation",
   "based on the conversation" (OW's query augmentation patterns)
3. Markdown template headers: "### " in messages >200 chars (OW uses
   section headers in background templates; real mobile messages don't)

This closes the gap that caused "Fix CobraTrans ESET" to be created
spuriously in Agent Ecosystem from an OW history-dump background request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 06:31:43 +00:00
admin 4a09def6dc fix: TransferEncodingError on task extraction failure
- brain.py: unwrap JSON array responses from Claude (occasional array
  instead of object caused AttributeError → broken chunked stream)
- main.py: wrap extract_task_fields() in try/except so any extraction
  failure gracefully falls back to regex — generator always completes
- tools.py: _resolve_project() uses alphanumeric-stripped matching so
  "Generaladm" resolves to General/Admin via identifier prefix match.
  Word-overlap fallback added. Default changed from Agent Ecosystem to
  General/Admin (correct catch-all bucket)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-02 06:09:45 +00:00
admin 6cb29d94e6 feat: Jon Snow dashboard page at agents.nxm.co.za/jon-snow/
- _render_jon_page(): generates index.html on every request with
  all-time cost in ZAR, today's cost, token counts, last 3 tasks
  (title + project + Claude/Python badge), and per-intent breakdown
- Task summary now includes project name for display in the page
- ZAR_RATE env var (default 18.50) controls USD→ZAR conversion
- Page regenerated automatically after every interaction via _write_status

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 14:30:30 +00:00
admin 83a933ea1a feat: LLM task extraction, token tracking, direct Claude brain
- brain.py: prefers direct Anthropic API (ANTHROPIC_API_KEY) over Hermes
  for all LLM calls — ~22x cheaper (122 tokens vs 5600+ Hermes overhead).
  Falls back to Hermes then Ollama if key unavailable.
  extract_task_fields(): non-streaming call returns clean {title, project}
  from any natural language phrasing — no more regex whack-a-mole.
- token_log.py: appends every LLM call to token-usage.jsonl with intent,
  in/out token counts, and USD cost. get_summary() aggregates all-time,
  today, and per-intent breakdowns.
- main.py: task handler uses extract_task_fields() with regex fallback;
  streaming handler captures usage from final chunk; GET /usage endpoint
  returns live cost summary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 14:20:47 +00:00
admin 711be495af fix: extract clean task title from natural language phrasings
- Item noun phrases (job item, work item) checked before "add X to Y"
  so the wrong " to " isn't captured in multi-clause sentences
- "please add X to [project], title" — comma after project = explicit title
- "work item to [project], title" — strips "to " filler then takes after comma
- Restructured function: explicit prefixes → item nouns → add-to pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 14:13:30 +00:00
admin 59c9cb837d fix: task intent classifier, Hermes brain, rolling run log
- Intent classifier: task phrases now checked before query to prevent
  "add task X" mis-routing; "job item"/"job ticket"/"work order" added
  to TASK_PHRASES; "please add + project keyword" fallback added;
  substring match bug fixed ("in" inside "incident" triggered query)
- brain.py: routes planning fallback to Hermes cloud (claude-sonnet-4-6)
  via HERMES_URL/HERMES_API_KEY env vars; falls back to local Ollama
  if Hermes is unavailable
- main.py: rolling 50-run log written to logs/jon-snow/runs.jsonl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 14:03:29 +00:00
admin 3b990b1b86 fix: filter Open WebUI background task requests from intent classifier
Open WebUI sends 4-5 extra requests per chat: query augmentation (Query: ...),
title generation, tag generation, and follow-up question suggestions. These all
include the full chat history, so they match execute/task intents incorrectly.

Added early return to classify_intent for Open WebUI system prompt patterns.
2026-05-27 13:21:14 +00:00
admin 3896af2a43 fix: _pad() wrong for reject tokens (6-char purpose)
4 - len(s) % 4 = 4 when len % 4 == 0, adding 4 padding chars instead of 0.
-len(s) % 4 correctly returns 0 in that case.
2026-05-27 13:14:07 +00:00
admin bbf05089cd fix: approve/reject endpoints return HTML pages instead of raw JSON
Mobile-friendly dark-theme page with icon, heading, and description.
Green for success, yellow for cancelled/not-found, red for errors.
2026-05-27 12:53:54 +00:00
admin 53b52a2337 Phase 3: approval gate, execute intent, approve/reject routes
- New: app/approval.py — HMAC-signed tokens, pending action store, 15-min TTL
- New: /approve/{token} and /reject/{token} GET routes (public, for Discord links)
- New: /internal/queue-action POST (for Citadel propose_file_change)
- New: execute intent in classifier — restart/rebuild + agent name queues action
- Updated: tools.py — notify_raven_with_actions, call_qyburn_rebuild/restart
- Updated: intent.py — EXECUTE_VERBS, STACK_NAMES, extract_execute_target
- Updated: SYSTEM_PROMPT reflects Phase 3 capabilities
- Updated: docker-compose.yml — JON_SECRET, JON_PUBLIC_URL, RAVEN_URL, QYBURN_URL
2026-05-27 12:26:52 +00:00
admin a25deeb8f4 feat: Jon Snow Phase 2 — FastAPI orchestrator with LiteLLM brain
OpenAI-compatible API at :8900. Intent classifier routes status queries
to FAST_MODEL (Ollama), task submissions to Plane, planning to SMART_MODEL.
Reads agent-os logs for status context. Phase 3: approval gate + execution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-16 13:06:20 +00:00