34 Commits

Author SHA1 Message Date
d7a17f32d2 Merge pull request 'Local model: compact cached prompt so typed replies take ~6 s (fixes 45 s timeouts)' (#8) from fix/local-fast-prompt into main 2026-10-08 22:43:55 +08:00
c8e1c162ee e2e: agent API search with a higher limit (staging accumulates test listings) 2026-10-08 22:43:54 +08:00
70f5b0525e Local model: compact prompt (1.2k tokens, same for every visitor) so typed replies take ~6 s instead of timing out
Root cause of the 45 s timeouts: the local model got the full hosted prompt (~3.1k tokens with examples). Any prompt-cache
miss meant ~40 s of CPU prefill on the single slot, and every request queued behind one paid it too.

- LOCAL_PROMPT/_local_system_prompt: terse action list, one-line examples, default page text, one line per listing
  (L-refs, dollar prices). No per-visitor data in it, so the cache always hits; it only changes with the catalog.
- _local_user: look overrides (if any) + keyword/budget MATCHING LISTINGS hint + 'VISITOR: <message>'.
- max_tokens 200 for the local model; over-budget card picks dropped when some fit (_respect_budget).
- Buy vs sell examples separated (sell my own thing -> listing form, never checkout).
- 18/18 correct on typical prompts, warm median 5.9 s, max 7.7 s; cold prefill ~13 s.
2026-10-08 22:37:57 +08:00
11994b9e73 Merge pull request 'Typed chat: free hosted models -> local model (llama-server), no keyword rules; busy reply + Retry' (#7) from feat/local-llm-backup into main 2026-10-08 22:18:21 +08:00
a2fd100587 Browser tests: don't assume an online-payable bike is still unsold on staging 2026-10-08 22:18:08 +08:00
6c2a1d6a40 Local model: short catalog refs (L1, L2, ...) mapped back to real ids; checkout and cash examples
A 4B model miscopied 8-hex listing ids (picked a tutoring id for a kids' bike). The local prompt now shows L-refs, the
server maps them back before tools/hydration (unknown refs are dropped as before), tool results are aliased the same
way, and refs are scrubbed from replies. Hosted models still see real ids.
2026-10-08 22:05:11 +08:00
d785091d64 Typed chat: hosted free models, then the local model, nothing else; busy reply + Retry; llama-server watchdog
- Remove the keyword-rules agent from typed chat: fallback_agent, parse_look_command (+ tables), the copy-edit parser
  and _rules_check are gone. If every model fails: 'The assistant is busy, please try again in a moment.' with a Retry
  button (agent 'unavailable', no actions). Clicks, forms and payments stay deterministic (fallback_event); the landing
  view is a deterministic featured-listings panel; the Sell button opens the empty form.
- Local model via llama.cpp llama-server directly (ops/local-llm-watchdog.sh, loopback only, restart on exit/hang,
  crash backoff, log rotation; deploy.sh ensures it runs). Lean: no vision projector, no weight repack (mmapped), ctx
  6144, 1 slot, q8 KV, 6 threads at nice 10, poll 0, 1 GiB prompt cache. Idle 0% CPU, 2.9 GB RSS (0.6 GB private).
- Local requests use a JSON GBNF grammar, worked examples in the cached system prompt, and a labelled visitor message.
  10/10 correct on the real prompt, warm 4-13 s.
- Primer re-primes after a model-server restart (llama-server /metrics counter) and otherwise stays idle.
- Fix: hosted calls kept the Authorization header off when a local model was configured (cfg['local'] is a dict on
  hosted configs); now only the local server itself skips the key. Test added.
- Badge/chat header: 'AI: busy', 'AI: quota used up', 'AI: unavailable'; no 'built-in'/'checked by rules' texts.
- Tests: proxy checks expect the busy reply (never rules), clicks still work while busy, no-model server, local grammar/
  prompt/no key; browser checks for busy + Retry; e2e_http accepts busy for typed turns unless REQUIRE_LLM=1;
  test_copyedit.py replaced by test_copy_defaults.py; README updated.
2026-10-08 21:58:41 +08:00
e4552f5649 Local model: no chat history by default; rules check for look/text edits (marked in the chat header) 2026-10-08 21:35:37 +08:00
549cd46778 Local model: focus padded search results on the request's keywords; unit tests 2026-10-08 21:25:55 +08:00
c531b427d5 Local model: prime the prompt cache at start-up and when the catalog changes; accept price_cents in listing-form defaults; 2 Ollama slots 2026-10-08 21:15:37 +08:00
55cccc4d9a Local backup model (Ollama, gemma3:4b): hosted chain -> local model -> keyword rules; own timeout, straight to local while the daily quota is used up, quota stop persisted; honest 'Local model' badge; mock + browser tests; watchdog script 2026-10-08 21:11:57 +08:00
aacd2b789e Merge pull request 'Built-in agent: robust UI copy edits (logo/top-left, replace A with B) + prompt page-text map' (#6) from fix/copy-edits into main 2026-10-08 20:50:31 +08:00
0c021dfdc9 README: page text editing 2026-10-08 20:50:27 +08:00
3db09b4d03 Built-in agent: robust UI copy edits (replace/rename/change A to B, top-left/logo/brand/site name, generic find-and-replace, clear reply when unsure); word-bounded font names; prompt explains page text slots 2026-10-08 20:49:15 +08:00
ec64d2e32c Merge pull request 'React + Vite frontend with a component registry (feature parity)' (#5) from feat/react-frontend into main 2026-10-08 19:49:55 +08:00
89f18c27ef README: React frontend structure, build/deploy, adding a component; theme_check fail-closed customCss check 2026-10-08 19:49:25 +08:00
b30f8ef1e2 Tests for the React DOM: SPA shell + bundle, compare bar, chat popup, persistence, hostile stored theme, fake-model browser suite; deploy AM_EXTRA_ENV 2026-10-08 19:47:39 +08:00
e62c9af423 React + Vite frontend (WIP): component registry, theme engine port, server serves static/dist, deploy builds 2026-10-08 19:46:14 +08:00
c3d6871407 Merge pull request 'Agent controls the whole look: validated theme spec, presets, layout, copy, chat, scoped CSS, protected fee/banner' (#4) from feat/agent-theming into main 2026-10-08 19:41:37 +08:00
a47bd648ac README: look & layout control, guardrails 2026-10-08 19:41:32 +08:00
2fdd46af9d tests: accept built-in badge 2026-10-08 19:41:14 +08:00
9853c39ef0 Readability scrim behind page text on high-variance gradients 2026-10-08 19:40:24 +08:00
f91dd9df43 Keep page-level text readable on gradients/patterns; test fixes 2026-10-08 19:39:41 +08:00
b396a01bc4 Rule-based look commands for when the model is unavailable; daily-quota-aware cooldown; honest badge when the built-in agent answers; theme tests 2026-10-08 19:39:02 +08:00
2e10619b95 Agent controls the whole look: validated theme spec (tokens, presets, layout, copy, sections, chat), sanitised scoped customCss, protected banner/badge/fee panels with guaranteed contrast, per-browser theme, no ids in replies 2026-10-08 19:37:27 +08:00
ad29b9c93a Merge pull request 'Rate-limit only LLM-bound chat turns' (#3) from fix/rate-limit-llm-only into main 2026-10-08 19:32:09 +08:00
63dd93dde9 Rate-limit only LLM-bound chat turns; clicks and payment events stay unlimited 2026-10-08 19:31:04 +08:00
c925544fe9 Merge pull request 'Real hosted LLM via OpenRouter free models, with fallback chain and per-IP rate limit' (#2) from feat/openrouter-llm into main 2026-10-08 19:29:59 +08:00
584593cb0a tests: natural-language checks against the real model; browser test waits for LLM replies; README LLM docs 2026-10-08 19:29:53 +08:00
b1a43c897c OpenRouter free-model LLM: key from file, model fallback chain with 429 cooldown and hard deadlines, per-IP chat rate limit, model badge, deterministic UI events 2026-10-08 19:28:14 +08:00
6e60dfd6f9 Merge pull request 'Agent Market demo v1: agent-driven marketplace (test mode)' (#1) from feat/demo-v1 into main 2026-10-08 19:12:42 +08:00
7277a88bba tests: browser walkthrough no longer depends on which seed items are still unsold 2026-10-08 19:12:22 +08:00
16231871cb Agent Market demo v1: agent-driven UI, test-mode payments with 5% fee, free cash deals, open agent API 2026-10-08 19:11:53 +08:00
afc7ea47a0 Initial commit 2026-10-08 19:07:17 +08:00