mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:19:41 +01:00
The widget's Chat tab ships. A visitor on an embedding site asks; whichever of the Cat (earning, getting paid) and Loki (getting things built) the question belongs to answers as itself — both when both have something useful — from the public fleet map, and is sent to the project that fits. - POST /api/widget/chat: fcw_* token + origin allowlist + per-IP/per-token limits, charged to the token owner's fair share of the free AI pool. Links are attached from the map, never typed by the model. When the budget or every vendor refuses it still routes by keyword match (degraded: true). - src/lib/widget-chat/concierge.ts: pure facts/prompt/links/fallback. Retired projects, throwaway names (same pattern as the litter gate, pinned equal) and unwritten not-running projects are not offered; stage words say beta/pilot, never live/client; facts are budgeted to survive free-tier limits. - Chat is OPT-IN per embed (data-fc-modes="chat,report"); the default is now Report alone, because the same bundle runs on pilot sites. The first listed mode opens first. window.Loki.ask(question) lets a host page hand a question over (bitbaum's homepage does). Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
23 lines
1.1 KiB
TypeScript
23 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import {
|
|
defaultWidgetSurfaceMode,
|
|
initialWidgetSurfaceMode,
|
|
parseWidgetSurfaceModes,
|
|
WIDGET_SURFACE_MODE_META,
|
|
} from "../../widget/surface-modes";
|
|
|
|
assert.equal(defaultWidgetSurfaceMode(), "report");
|
|
assert.deepEqual(parseWidgetSurfaceModes(null), ["report"]);
|
|
assert.deepEqual(parseWidgetSurfaceModes("report,chat,watch"), ["report", "chat", "watch"]);
|
|
// The embed's order is kept: the first listed mode is the one the panel opens in.
|
|
assert.deepEqual(parseWidgetSurfaceModes("chat, report, chat, nonsense"), ["chat", "report"]);
|
|
assert.deepEqual(parseWidgetSurfaceModes("nonsense"), ["report"]);
|
|
assert.equal(initialWidgetSurfaceMode(["chat", "report"]), "chat");
|
|
assert.equal(initialWidgetSurfaceMode(["report", "chat"]), "report");
|
|
// An unshipped mode listed first is skipped rather than opening a dead tab.
|
|
assert.equal(initialWidgetSurfaceMode(["watch", "chat"]), "chat");
|
|
assert.equal(WIDGET_SURFACE_MODE_META.report.shipped, true);
|
|
assert.equal(WIDGET_SURFACE_MODE_META.chat.shipped, true);
|
|
assert.equal(WIDGET_SURFACE_MODE_META.watch.shipped, false);
|
|
console.log("widget-surface-modes: ok");
|