@qikbar/qikbar 0.2.0 → 0.2.2
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.
- package/dist/ai.js +5 -6
- package/dist/chunks/{bar-P3SCR4SJ.js → bar-4WGKZKVL.js} +263 -215
- package/dist/chunks/bar-4WGKZKVL.js.map +7 -0
- package/dist/chunks/{chunk-PQEHV3D4.js → chunk-FRR2RT26.js} +3 -8
- package/dist/chunks/{chunk-PQEHV3D4.js.map → chunk-FRR2RT26.js.map} +1 -1
- package/dist/chunks/{chunk-OLXZNYZ4.js → chunk-JBXMI45H.js} +51 -47
- package/dist/chunks/chunk-JBXMI45H.js.map +7 -0
- package/dist/chunks/{chunk-5FI7DNG7.js → chunk-MDIFIKGL.js} +7 -13
- package/dist/chunks/{chunk-5FI7DNG7.js.map → chunk-MDIFIKGL.js.map} +2 -2
- package/dist/chunks/{chunk-JHQAIXM7.js → chunk-OUEAI6J2.js} +139 -82
- package/dist/chunks/chunk-OUEAI6J2.js.map +7 -0
- package/dist/chunks/{launcher-B5MGOPEQ.js → launcher-S3P2HQOR.js} +1 -3
- package/dist/chunks/{launcher-B5MGOPEQ.js.map → launcher-S3P2HQOR.js.map} +1 -1
- package/dist/core/frecency.d.ts +1 -1
- package/dist/core/lazy.d.ts +2 -2
- package/dist/element.js +5 -13
- package/dist/element.js.map +1 -1
- package/dist/extensions.js +3 -6
- package/dist/extensions.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -11
- package/dist/locales/index.d.ts +2 -2
- package/dist/locales.js +3 -2
- package/dist/locales.js.map +1 -1
- package/dist/qikbar.global.js +23 -23
- package/dist/qikbar.global.js.map +4 -4
- package/dist/react.js +3 -6
- package/dist/react.js.map +1 -1
- package/dist/server.js +0 -1
- package/dist/server.js.map +1 -1
- package/dist/solid.js +3 -6
- package/dist/solid.js.map +1 -1
- package/dist/svelte.js +3 -6
- package/dist/svelte.js.map +1 -1
- package/dist/theme.js +0 -1
- package/dist/ui/bar.d.ts +20 -0
- package/dist/utils.js +2 -3
- package/dist/vue.js +3 -6
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/bar-P3SCR4SJ.js.map +0 -7
- package/dist/chunks/chunk-JHQAIXM7.js.map +0 -7
- package/dist/chunks/chunk-MPTP2EWW.js +0 -8
- package/dist/chunks/chunk-MPTP2EWW.js.map +0 -7
- package/dist/chunks/chunk-OLXZNYZ4.js.map +0 -7
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__publicField
|
|
3
|
-
} from "./chunk-MPTP2EWW.js";
|
|
4
|
-
|
|
5
1
|
// src/core/hotkeys.ts
|
|
6
2
|
var isMac = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/i.test(navigator.userAgentData?.platform ?? navigator.platform ?? navigator.userAgent), KEY_ALIASES = {
|
|
7
3
|
esc: "escape",
|
|
@@ -86,9 +82,8 @@ function isEditable(target) {
|
|
|
86
82
|
}
|
|
87
83
|
var SequenceMatcher = class {
|
|
88
84
|
constructor(timeout = 900) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
__publicField(this, "timer");
|
|
85
|
+
this.timeout = timeout;
|
|
86
|
+
this.buffer = [];
|
|
92
87
|
}
|
|
93
88
|
/** Feed an event; returns the hotkeys (from `hotkeys`) that completed. */
|
|
94
89
|
feed(event, hotkeys) {
|
|
@@ -121,4 +116,4 @@ export {
|
|
|
121
116
|
SequenceMatcher,
|
|
122
117
|
allowedInInput
|
|
123
118
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
119
|
+
//# sourceMappingURL=chunk-FRR2RT26.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/core/hotkeys.ts"],
|
|
4
4
|
"sourcesContent": ["/**\n * Keyboard shortcut parsing, matching and formatting.\n *\n * Syntax: modifiers joined with `+`, e.g. `\"mod+k\"`, `\"shift+mod+p\"`, `\"alt+enter\"`.\n * `mod` is \u2318 on Apple platforms and Ctrl elsewhere.\n * Sequences are space separated: `\"g s\"` means press G, then S.\n */\n\nexport const isMac: boolean =\n typeof navigator !== 'undefined' &&\n /Mac|iPhone|iPad|iPod/i.test((navigator as any).userAgentData?.platform ?? navigator.platform ?? navigator.userAgent)\n\nexport interface KeyCombo {\n key: string\n meta: boolean\n ctrl: boolean\n alt: boolean\n shift: boolean\n}\n\nconst KEY_ALIASES: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n space: ' ',\n up: 'arrowup',\n down: 'arrowdown',\n left: 'arrowleft',\n right: 'arrowright',\n del: 'delete',\n plus: '+',\n}\n\nconst cache = new Map<string, KeyCombo[]>()\n\n/** Parse `\"mod+shift+k\"` or a sequence `\"g s\"` into combos. */\nexport function parseHotkey(hotkey: string): KeyCombo[] {\n let combos = cache.get(hotkey)\n if (combos) return combos\n combos = hotkey\n .trim()\n .split(/\\s+/)\n .map((part) => {\n const keys = part.toLowerCase().split('+')\n // \"mod++\" \u2192 trailing plus key\n if (part.endsWith('++')) keys.splice(keys.length - 2, 2, '+')\n const combo: KeyCombo = { key: '', meta: false, ctrl: false, alt: false, shift: false }\n for (const k of keys) {\n if (k === 'mod') isMac ? (combo.meta = true) : (combo.ctrl = true)\n else if (k === 'cmd' || k === 'meta' || k === 'command') combo.meta = true\n else if (k === 'ctrl' || k === 'control') combo.ctrl = true\n else if (k === 'alt' || k === 'option' || k === 'opt') combo.alt = true\n else if (k === 'shift') combo.shift = true\n else combo.key = KEY_ALIASES[k] ?? k\n }\n return combo\n })\n cache.set(hotkey, combos)\n return combos\n}\n\nfunction eventKey(event: KeyboardEvent): string {\n // Use the physical key for letters/digits so alt/shift combos still match.\n const code = event.code\n if (code?.startsWith('Key')) return code.slice(3).toLowerCase()\n if (code?.startsWith('Digit')) return code.slice(5)\n return (event.key ?? '').toLowerCase()\n}\n\n/** Does a keyboard event match a single combo? */\nexport function matchesCombo(event: KeyboardEvent, combo: KeyCombo): boolean {\n if (event.metaKey !== combo.meta || event.ctrlKey !== combo.ctrl || event.altKey !== combo.alt) return false\n const key = eventKey(event)\n // Shift is implied for symbols like \"?\" \u2014 only enforce it for letters/named keys when specified.\n if (combo.shift !== event.shiftKey && !(combo.key.length === 1 && !/[a-z0-9]/.test(combo.key))) return false\n return key === combo.key || (event.key ?? '').toLowerCase() === combo.key\n}\n\n/** Matches a single-combo hotkey (sequences never match here). */\nexport function matchesHotkey(event: KeyboardEvent, hotkey: string): boolean {\n const combos = parseHotkey(hotkey)\n return combos.length === 1 && matchesCombo(event, combos[0]!)\n}\n\nconst MAC_SYMBOLS: Record<string, string> = {\n meta: '\u2318',\n ctrl: '\u2303',\n alt: '\u2325',\n shift: '\u21E7',\n enter: '\u21B5',\n escape: 'esc',\n backspace: '\u232B',\n delete: '\u2326',\n arrowup: '\u2191',\n arrowdown: '\u2193',\n arrowleft: '\u2190',\n arrowright: '\u2192',\n tab: '\u21E5',\n ' ': 'Space',\n}\n\nconst PC_NAMES: Record<string, string> = {\n meta: 'Win',\n ctrl: 'Ctrl',\n alt: 'Alt',\n shift: 'Shift',\n enter: '\u21B5',\n escape: 'Esc',\n backspace: '\u232B',\n delete: 'Del',\n arrowup: '\u2191',\n arrowdown: '\u2193',\n arrowleft: '\u2190',\n arrowright: '\u2192',\n tab: 'Tab',\n ' ': 'Space',\n}\n\n/** Format a hotkey as an array of key labels for display, e.g. `[\"\u2318\", \"K\"]`. */\nexport function formatHotkey(hotkey: string): string[][] {\n return parseHotkey(hotkey).map((combo) => {\n const names = isMac ? MAC_SYMBOLS : PC_NAMES\n const out: string[] = []\n if (isMac) {\n if (combo.ctrl) out.push(names.ctrl!)\n if (combo.alt) out.push(names.alt!)\n if (combo.shift) out.push(names.shift!)\n if (combo.meta) out.push(names.meta!)\n } else {\n if (combo.ctrl) out.push(names.ctrl!)\n if (combo.meta) out.push(names.meta!)\n if (combo.alt) out.push(names.alt!)\n if (combo.shift) out.push(names.shift!)\n }\n out.push(names[combo.key] ?? (combo.key.length === 1 ? combo.key.toUpperCase() : capitalize(combo.key)))\n return out\n })\n}\n\nfunction capitalize(s: string) {\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\n/** True if the event target is a text field (where single-key shortcuts must not fire). */\nexport function isEditable(target: EventTarget | null): boolean {\n const el = target as HTMLElement | null\n if (!el || !el.tagName) return false\n const tag = el.tagName\n return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || el.isContentEditable\n}\n\n/**\n * Tracks multi-key sequences (\"g s\") across keydown events.\n */\nexport class SequenceMatcher {\n private buffer: KeyboardEvent[] = []\n private timer: ReturnType<typeof setTimeout> | undefined\n\n constructor(private timeout = 900) {}\n\n /** Feed an event; returns the hotkeys (from `hotkeys`) that completed. */\n feed(event: KeyboardEvent, hotkeys: string[]): string[] {\n if (['Shift', 'Meta', 'Control', 'Alt'].includes(event.key)) return []\n this.buffer.push(event)\n if (this.buffer.length > 4) this.buffer.shift()\n clearTimeout(this.timer)\n this.timer = setTimeout(() => (this.buffer = []), this.timeout)\n const matched: string[] = []\n for (const hotkey of hotkeys) {\n const combos = parseHotkey(hotkey)\n if (combos.length > this.buffer.length) continue\n const tail = this.buffer.slice(-combos.length)\n if (combos.every((c, i) => matchesCombo(tail[i]!, c))) matched.push(hotkey)\n }\n if (matched.length) this.buffer = []\n return matched\n }\n\n reset() {\n this.buffer = []\n clearTimeout(this.timer)\n }\n}\n\n/** Whether a hotkey may fire while focus is in a text field (it must use a modifier). */\nexport function allowedInInput(hotkey: string): boolean {\n const combos = parseHotkey(hotkey)\n return combos.length === 1 && (combos[0]!.meta || combos[0]!.ctrl || combos[0]!.alt)\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";AAQO,IAAM,QACX,OAAO,YAAc,OACrB,wBAAwB,KAAM,UAAkB,eAAe,YAAY,UAAU,YAAY,UAAU,SAAS,GAUhH,cAAsC;AAAA,EAC1C,KAAK;AAAA,EACL,QAAQ;AAAA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C5B;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,SAAK,SAAS,CAAC,GACf,aAAa,KAAK,KAAK;AAAA,EACzB;AACF;AAGO,SAAS,eAAe,QAAyB;AACtD,MAAM,SAAS,YAAY,MAAM;AACjC,SAAO,OAAO,WAAW,MAAM,OAAO,CAAC,EAAG,QAAQ,OAAO,CAAC,EAAG,QAAQ,OAAO,CAAC,EAAG;AAClF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultStorage,
|
|
3
|
-
scopedStorage
|
|
4
|
-
} from "./chunk-YCVJQ7U3.js";
|
|
5
1
|
import {
|
|
6
2
|
allowedInInput,
|
|
7
3
|
isEditable,
|
|
8
4
|
matchesHotkey
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
__publicField
|
|
12
|
-
} from "./chunk-MPTP2EWW.js";
|
|
5
|
+
} from "./chunk-FRR2RT26.js";
|
|
13
6
|
|
|
14
7
|
// src/core/lazy.ts
|
|
15
8
|
var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext), LazyQikbar = class {
|
|
16
9
|
constructor(config, loader) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
__publicField(this, "teardown", []);
|
|
23
|
-
__publicField(this, "destroyed", !1);
|
|
24
|
-
__publicField(this, "removeLauncher");
|
|
25
|
-
__publicField(this, "store");
|
|
26
|
-
__publicField(this, "launcherToken", 0);
|
|
10
|
+
this.loader = loader;
|
|
11
|
+
this.queue = [];
|
|
12
|
+
this.teardown = [];
|
|
13
|
+
this.destroyed = !1;
|
|
14
|
+
this.launcherToken = 0;
|
|
27
15
|
if (this.config = { ...config }, typeof document > "u") return;
|
|
28
16
|
if (config.inline) {
|
|
29
17
|
this.load();
|
|
@@ -42,18 +30,24 @@ var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext),
|
|
|
42
30
|
document.addEventListener("keydown", onKey, !0), document.addEventListener("click", onClick, !0), this.teardown.push(() => {
|
|
43
31
|
document.removeEventListener("keydown", onKey, !0), document.removeEventListener("click", onClick, !0);
|
|
44
32
|
});
|
|
45
|
-
let idle = globalThis.requestIdleCallback;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
let idle = globalThis.requestIdleCallback, cancelIdle = globalThis.cancelIdleCallback;
|
|
34
|
+
if (idle) {
|
|
35
|
+
let id = idle(() => {
|
|
36
|
+
this.load();
|
|
37
|
+
}, { timeout: 2500 });
|
|
38
|
+
this.teardown.push(() => cancelIdle?.(id));
|
|
39
|
+
} else {
|
|
40
|
+
let id = setTimeout(() => {
|
|
41
|
+
this.load();
|
|
42
|
+
}, 1200);
|
|
43
|
+
this.teardown.push(() => clearTimeout(id));
|
|
44
|
+
}
|
|
51
45
|
}
|
|
52
46
|
/** The launcher is loaded on demand, so apps without one don't ship it. */
|
|
53
47
|
updateLauncher() {
|
|
54
48
|
this.removeLauncher?.(), this.removeLauncher = void 0;
|
|
55
49
|
let token = ++this.launcherToken;
|
|
56
|
-
!this.config.launcher || this.config.inline || this.destroyed || import("./launcher-
|
|
50
|
+
!this.config.launcher || this.config.inline || this.destroyed || import("./launcher-S3P2HQOR.js").then(({ mountLauncher, resolveLauncher }) => {
|
|
57
51
|
let opts = resolveLauncher(this.config.launcher);
|
|
58
52
|
if (!opts || token !== this.launcherToken || this.destroyed) return;
|
|
59
53
|
let label = this.config.labels?.openCommandBar ?? "Open command bar", mount = () => {
|
|
@@ -64,10 +58,16 @@ var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext),
|
|
|
64
58
|
}
|
|
65
59
|
/** Resolves once the launcher (if any) is on the page. Mostly for tests. */
|
|
66
60
|
launcherReady() {
|
|
67
|
-
return import("./launcher-
|
|
68
|
-
}
|
|
69
|
-
storage
|
|
70
|
-
|
|
61
|
+
return import("./launcher-S3P2HQOR.js").then(() => new Promise((r) => setTimeout(r)));
|
|
62
|
+
}
|
|
63
|
+
/** Read a stored value before the UI loads (same keys as the bar's storage). */
|
|
64
|
+
stored(key) {
|
|
65
|
+
try {
|
|
66
|
+
let raw = (this.config.storage ?? globalThis.localStorage).getItem(`${this.config.namespace ?? "qikbar"}:${key}`);
|
|
67
|
+
return raw == null ? void 0 : JSON.parse(raw);
|
|
68
|
+
} catch {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
71
|
}
|
|
72
72
|
/** Load the UI now. Resolves when ready. */
|
|
73
73
|
preload() {
|
|
@@ -75,19 +75,23 @@ var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext),
|
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
load() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
if (!this.loading) {
|
|
79
|
+
let p = this.loader().then(({ Bar }) => {
|
|
80
|
+
if (this.destroyed) throw new Error("destroyed");
|
|
81
|
+
for (let fn of this.teardown) fn();
|
|
82
|
+
this.teardown = [];
|
|
83
|
+
let bar = new Bar(this.config);
|
|
84
|
+
this.bar = bar;
|
|
85
|
+
let queue = this.queue;
|
|
86
|
+
this.queue = [];
|
|
87
|
+
for (let fn of queue) fn(bar);
|
|
88
|
+
return bar;
|
|
89
|
+
});
|
|
90
|
+
this.loading = p, p.catch((err) => {
|
|
91
|
+
this.loading === p && (this.loading = void 0), this.destroyed || console.error("[qikbar] failed to load UI", err);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return this.loading;
|
|
91
95
|
}
|
|
92
96
|
run(fn) {
|
|
93
97
|
this.bar ? fn(this.bar) : (this.queue.push(fn), this.load());
|
|
@@ -159,13 +163,13 @@ var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext),
|
|
|
159
163
|
return this.bar?.commands() ?? [];
|
|
160
164
|
}
|
|
161
165
|
pins() {
|
|
162
|
-
return this.bar?.pins() ?? this.
|
|
166
|
+
return this.bar?.pins() ?? this.stored("pins") ?? [];
|
|
163
167
|
}
|
|
164
168
|
pin(id, pinned) {
|
|
165
169
|
this.run((b) => b.pin(id, pinned));
|
|
166
170
|
}
|
|
167
171
|
aliases() {
|
|
168
|
-
return this.bar?.aliases() ?? this.
|
|
172
|
+
return this.bar?.aliases() ?? this.stored("aliases") ?? {};
|
|
169
173
|
}
|
|
170
174
|
setAlias(id, alias) {
|
|
171
175
|
this.run((b) => b.setAlias(id, alias));
|
|
@@ -182,12 +186,12 @@ var hasModelContext = () => !!(document.modelContext ?? navigator.modelContext),
|
|
|
182
186
|
|
|
183
187
|
// src/index.ts
|
|
184
188
|
function createQikbar(config = {}) {
|
|
185
|
-
return new LazyQikbar(config, () => import("./bar-
|
|
189
|
+
return new LazyQikbar(config, () => import("./bar-4WGKZKVL.js"));
|
|
186
190
|
}
|
|
187
|
-
var version = "0.2.
|
|
191
|
+
var version = "0.2.2";
|
|
188
192
|
|
|
189
193
|
export {
|
|
190
194
|
createQikbar,
|
|
191
195
|
version
|
|
192
196
|
};
|
|
193
|
-
//# sourceMappingURL=chunk-
|
|
197
|
+
//# sourceMappingURL=chunk-JBXMI45H.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/core/lazy.ts", "../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * A tiny shell that implements the full Qikbar API, listens for the hotkey and\n * loads the UI chunk when the browser is idle (or immediately on first use).\n * Calls made before the UI loads are queued and replayed in order.\n */\n\nimport type { Bar } from '../ui/bar.js'\nimport { allowedInInput, isEditable, matchesHotkey } from './hotkeys.js'\nimport type { AIClient, Extension, Item, QikbarConfig, QikbarEvents, QikbarInstance, Source, ToastHandle, ToastOptions, View } from './types.js'\n\ntype Loader = () => Promise<{ Bar: typeof Bar }>\n\nconst hasModelContext = () => !!((document as any).modelContext ?? (navigator as any).modelContext)\n\nexport class LazyQikbar implements QikbarInstance {\n private bar?: Bar\n private loading?: Promise<Bar>\n private queue: ((bar: Bar) => void)[] = []\n private config: QikbarConfig\n private teardown: (() => void)[] = []\n private destroyed = false\n private removeLauncher?: () => void\n\n constructor(\n config: QikbarConfig,\n private loader: Loader,\n ) {\n this.config = { ...config }\n if (typeof document === 'undefined') return\n if (config.inline) {\n void this.load()\n return\n }\n this.updateLauncher()\n // Agents may call tools at any time, so WebMCP needs the UI loaded now (only if the browser supports it).\n if (config.webmcp && hasModelContext()) void this.load()\n const onKey = (e: KeyboardEvent) => {\n const hotkeys = this.config.hotkey === false ? [] : ([] as string[]).concat(this.config.hotkey ?? 'mod+k')\n const inField = isEditable(e.target)\n if (!this.bar && hotkeys.some((hk) => matchesHotkey(e, hk) && (!inField || allowedInInput(hk)))) {\n e.preventDefault()\n this.open()\n }\n }\n const onClick = (e: MouseEvent) => {\n const trigger = (e.target as Element | null)?.closest?.('[data-qikbar-open]')\n if (!trigger || this.bar) return\n const target = trigger.getAttribute('data-qikbar-open')\n if (target && target !== this.config.namespace) return\n e.preventDefault()\n this.open({ query: trigger.getAttribute('data-qikbar-query') ?? undefined })\n }\n document.addEventListener('keydown', onKey, true)\n document.addEventListener('click', onClick, true)\n this.teardown.push(() => {\n document.removeEventListener('keydown', onKey, true)\n document.removeEventListener('click', onClick, true)\n })\n // Warm up when the browser is idle so the first open is instant.\n const idle = (globalThis as any).requestIdleCallback as ((cb: () => void, o?: { timeout: number }) => number) | undefined\n const cancelIdle = (globalThis as any).cancelIdleCallback as ((id: number) => void) | undefined\n if (idle) {\n const id = idle(() => void this.load(), { timeout: 2500 })\n this.teardown.push(() => cancelIdle?.(id))\n } else {\n const id = setTimeout(() => void this.load(), 1200)\n this.teardown.push(() => clearTimeout(id))\n }\n }\n\n private launcherToken = 0\n\n /** The launcher is loaded on demand, so apps without one don't ship it. */\n private updateLauncher() {\n this.removeLauncher?.()\n this.removeLauncher = undefined\n const token = ++this.launcherToken\n if (!this.config.launcher || this.config.inline || this.destroyed) return\n void import('./launcher.js').then(({ mountLauncher, resolveLauncher }) => {\n const opts = resolveLauncher(this.config.launcher)\n if (!opts || token !== this.launcherToken || this.destroyed) return\n const label = this.config.labels?.openCommandBar ?? 'Open command bar'\n const mount = () => {\n if (this.destroyed || token !== this.launcherToken) return\n this.removeLauncher = mountLauncher(opts, label, () => this.open(), this.config.nonce)\n }\n if (document.body) mount()\n else document.addEventListener('DOMContentLoaded', mount, { once: true })\n })\n }\n\n /** Resolves once the launcher (if any) is on the page. Mostly for tests. */\n launcherReady(): Promise<void> {\n return import('./launcher.js').then(() => new Promise((r) => setTimeout(r)))\n }\n\n /** Read a stored value before the UI loads (same keys as the bar's storage). */\n private stored<T>(key: string): T | undefined {\n try {\n const adapter = this.config.storage ?? globalThis.localStorage\n const raw = adapter.getItem(`${this.config.namespace ?? 'qikbar'}:${key}`)\n return raw == null ? undefined : (JSON.parse(raw) as T)\n } catch {\n return undefined\n }\n }\n\n /** Load the UI now. Resolves when ready. */\n preload(): Promise<void> {\n return this.load().then(() => undefined)\n }\n\n private load(): Promise<Bar> {\n if (!this.loading) {\n const p = this.loader().then(({ Bar }) => {\n if (this.destroyed) throw new Error('destroyed')\n for (const fn of this.teardown) fn()\n this.teardown = []\n const bar = new Bar(this.config)\n this.bar = bar\n const queue = this.queue\n this.queue = []\n for (const fn of queue) fn(bar)\n return bar\n })\n this.loading = p\n p.catch((err) => {\n if (this.loading === p) this.loading = undefined\n if (!this.destroyed) console.error('[qikbar] failed to load UI', err)\n })\n }\n return this.loading\n }\n\n private run(fn: (bar: Bar) => void) {\n if (this.bar) fn(this.bar)\n else {\n this.queue.push(fn)\n void this.load()\n }\n }\n\n /** Queue a call that returns a disposer; the disposer works before and after loading. */\n private disposable(fn: (bar: Bar) => () => void): () => void {\n if (this.bar) return fn(this.bar)\n let dispose: (() => void) | undefined\n let cancelled = false\n this.queue.push((bar) => {\n if (!cancelled) dispose = fn(bar)\n })\n return () => {\n cancelled = true\n dispose?.()\n }\n }\n\n get isOpen() {\n return this.bar?.isOpen ?? false\n }\n get query() {\n return this.bar?.query ?? ''\n }\n get ai(): AIClient | undefined {\n return this.bar?.ai\n }\n\n open(options?: { query?: string; view?: View }) {\n this.run((b) => b.open(options))\n }\n close() {\n this.bar?.close()\n }\n toggle() {\n if (this.bar) this.bar.toggle()\n else this.open()\n }\n register(commands: Item | Item[]) {\n return this.disposable((b) => b.register(commands))\n }\n addSource(source: Source) {\n return this.disposable((b) => b.addSource(source))\n }\n use(extension: Extension, preferences?: Record<string, any>) {\n return this.disposable((b) => b.use(extension, preferences))\n }\n configure(config: Partial<QikbarConfig>) {\n this.config = { ...this.config, ...config }\n if (this.bar) this.bar.configure(config)\n if ('launcher' in config || 'labels' in config) this.updateLauncher()\n if (config.webmcp && !this.bar && hasModelContext()) void this.load()\n }\n push(view: View) {\n this.run((b) => b.push(view))\n }\n pop() {\n this.bar?.pop()\n }\n setQuery(query: string) {\n this.run((b) => b.setQuery(query))\n }\n ask(prompt?: string) {\n this.run((b) => b.ask(prompt))\n }\n toast(options: ToastOptions | string): ToastHandle {\n if (this.bar) return this.bar.toast(options)\n let handle: ToastHandle | undefined\n const pending: ((h: ToastHandle) => void)[] = []\n this.run((b) => {\n handle = b.toast(options)\n for (const p of pending) p(handle)\n })\n return {\n update: (o) => (handle ? handle.update(o) : pending.push((h) => h.update(o))),\n hide: () => (handle ? handle.hide() : pending.push((h) => h.hide())),\n }\n }\n commands(): Item[] {\n return this.bar?.commands() ?? []\n }\n pins(): string[] {\n return this.bar?.pins() ?? this.stored<string[]>('pins') ?? []\n }\n pin(id: string, pinned?: boolean) {\n this.run((b) => b.pin(id, pinned))\n }\n aliases(): Record<string, string> {\n return this.bar?.aliases() ?? this.stored<Record<string, string>>('aliases') ?? {}\n }\n setAlias(id: string, alias: string | null) {\n this.run((b) => b.setAlias(id, alias))\n }\n on<K extends keyof QikbarEvents>(event: K, handler: (payload: QikbarEvents[K]) => void) {\n return this.disposable((b) => b.on(event, handler))\n }\n destroy() {\n this.destroyed = true\n this.launcherToken++\n this.removeLauncher?.()\n this.removeLauncher = undefined\n for (const fn of this.teardown) fn()\n this.teardown = []\n this.queue = []\n this.bar?.destroy()\n }\n}\n", "/**\n * Qikbar \u2014 the open-source command bar for any web app.\n *\n * ```ts\n * import { createQikbar } from '@qikbar/qikbar'\n *\n * const bar = createQikbar({\n * routes: [{ path: '/settings', title: 'Settings' }],\n * commands: [{ title: 'Toggle dark mode', run: () => toggleTheme() }],\n * })\n * ```\n */\n\nimport { LazyQikbar } from './core/lazy.js'\nimport type { QikbarConfig, QikbarInstance } from './core/types.js'\n\n/**\n * Create a command bar. Press \u2318K / Ctrl+K to open it.\n *\n * Boots a tiny shell that listens for the hotkey; the UI loads when the\n * browser is idle or on first use, so it never slows down your page load.\n */\nexport function createQikbar(config: QikbarConfig = {}): QikbarInstance {\n return new LazyQikbar(config, () => import('./ui/bar.js'))\n}\n\nexport * from './core/types.js'\nexport { action, chat, defineCommands, defineExtension, defineSource, defineTool, detail, form, grid, list } from './core/define.js'\nexport { formatHotkey, isMac, matchesHotkey, parseHotkey } from './core/hotkeys.js'\nexport { memoryStorage } from './core/storage.js'\nexport { anthropic, browserAI, gemini, ollama, openai, openaiCompatible, proxy } from './ai/providers.js'\nexport type { AnthropicOptions, GeminiOptions, OpenAIOptions, ProxyOptions } from './ai/providers.js'\nexport { byok } from './ai/byok.js'\nexport type { ByokOptions } from './ai/byok.js'\nexport { mcp } from './ai/mcp.js'\nexport type { MCPOptions } from './ai/mcp.js'\nexport { cachedEmbeddings, geminiEmbeddings, ollamaEmbeddings, openaiEmbeddings, proxyEmbeddings } from './ai/embeddings.js'\n\n// Theme helpers live in `@qikbar/qikbar/theme`; search, markdown and icons in `@qikbar/qikbar/utils`.\n// Keeping them out of this entry keeps the initial download tiny.\n\nexport const version = '0.2.2'\n"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nC,SAAK,WAAW,CAAC,GACjB,KAAK,QAAQ,CAAC,GACd,KAAK,KAAK,QAAQ;AAAA,EACpB;AACF;;;AC9NO,SAAS,aAAa,SAAuB,CAAC,GAAmB;AACtE,SAAO,IAAI,WAAW,QAAQ,MAAM,OAAO,mBAAa,CAAC;AAC3D;AAiBO,IAAM,UAAU;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -7,9 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
defaultStorage
|
|
9
9
|
} from "./chunk-YCVJQ7U3.js";
|
|
10
|
-
import {
|
|
11
|
-
__publicField
|
|
12
|
-
} from "./chunk-MPTP2EWW.js";
|
|
13
10
|
|
|
14
11
|
// src/ai/byok.ts
|
|
15
12
|
var LABELS = {
|
|
@@ -109,18 +106,15 @@ function settingsExtension(options = {}) {
|
|
|
109
106
|
var MCP_PROTOCOL_VERSION = "2025-06-18", MCPError = class extends Error {
|
|
110
107
|
constructor(message, code) {
|
|
111
108
|
super(message);
|
|
112
|
-
|
|
109
|
+
this.code = code;
|
|
113
110
|
this.name = "MCPError";
|
|
114
111
|
}
|
|
115
112
|
}, MCPClient = class {
|
|
116
113
|
constructor(options) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
__publicField(this, "negotiated", !1);
|
|
122
|
-
__publicField(this, "nextId", 1);
|
|
123
|
-
__publicField(this, "serverInfo");
|
|
114
|
+
this.options = options;
|
|
115
|
+
this.protocol = MCP_PROTOCOL_VERSION;
|
|
116
|
+
this.negotiated = !1;
|
|
117
|
+
this.nextId = 1;
|
|
124
118
|
}
|
|
125
119
|
async headers() {
|
|
126
120
|
let h = this.options.headers, extra = typeof h == "function" ? await h() : h ?? {};
|
|
@@ -181,7 +175,7 @@ var MCP_PROTOCOL_VERSION = "2025-06-18", MCPError = class extends Error {
|
|
|
181
175
|
return this.ready ?? (this.ready = (async () => {
|
|
182
176
|
let result = await this.request(
|
|
183
177
|
"initialize",
|
|
184
|
-
{ protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: "qikbar", version: "0.2.
|
|
178
|
+
{ protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: "qikbar", version: "0.2.2" } },
|
|
185
179
|
signal
|
|
186
180
|
);
|
|
187
181
|
result?.protocolVersion && (this.protocol = result.protocolVersion), this.negotiated = !0, this.serverInfo = result?.serverInfo, await this.post({ jsonrpc: "2.0", method: "notifications/initialized" }, signal);
|
|
@@ -268,4 +262,4 @@ export {
|
|
|
268
262
|
MCPClient,
|
|
269
263
|
mcp
|
|
270
264
|
};
|
|
271
|
-
//# sourceMappingURL=chunk-
|
|
265
|
+
//# sourceMappingURL=chunk-MDIFIKGL.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ai/byok.ts", "../../src/ai/mcp.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineExtension } from '../core/define.js'\nimport { defaultStorage } from '../core/storage.js'\nimport type { AIEvent, AIProvider, AIRequest, Extension, StorageAdapter } from '../core/types.js'\nimport { anthropic, gemini, openai } from './providers.js'\n\nexport type ByokVendor = 'anthropic' | 'openai' | 'gemini' | 'openai-compatible'\n\nexport interface ByokSettings {\n vendor: ByokVendor\n apiKey: string\n model?: string\n baseURL?: string\n}\n\nexport interface ByokOptions {\n /** Vendors offered in settings. Default: all. */\n vendors?: ByokVendor[]\n /** Storage key. Default `\"qikbar:byok\"`. */\n key?: string\n storage?: StorageAdapter\n}\n\nconst LABELS: Record<ByokVendor, string> = {\n anthropic: 'Anthropic (Claude)',\n openai: 'OpenAI',\n gemini: 'Google Gemini',\n 'openai-compatible': 'OpenAI-compatible (OpenRouter, Groq, Ollama\u2026)',\n}\n\nfunction read(storage: StorageAdapter, key: string): ByokSettings | undefined {\n try {\n const raw = storage.getItem(key)\n return raw ? (JSON.parse(raw) as ByokSettings) : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * \"Bring your own key\": your users paste their own API key, stored only in their\n * browser. Pair with `byok.settings()` so they can configure it from the bar.\n *\n * ```ts\n * createQikbar({ ai: byok(), extensions: [byok.settings()] })\n * ```\n */\nexport const byok = /* @__PURE__ */ Object.assign(function byok(options: ByokOptions = {}): AIProvider {\n const storage = options.storage ?? defaultStorage()\n const key = options.key ?? 'qikbar:byok'\n return {\n id: 'byok',\n get model() {\n return read(storage, key)?.model\n },\n async *stream(req: AIRequest): AsyncIterable<AIEvent> {\n const s = read(storage, key)\n if (!s?.apiKey && s?.vendor !== 'openai-compatible') {\n yield { type: 'error', error: 'Add your AI API key first: search for \u201CAI Settings\u201D in the command bar.' }\n yield { type: 'done', message: { role: 'assistant', content: '' } }\n return\n }\n const provider =\n s.vendor === 'anthropic'\n ? anthropic({ apiKey: s.apiKey, model: s.model || undefined })\n : s.vendor === 'gemini'\n ? gemini({ apiKey: s.apiKey, model: s.model || undefined })\n : openai({ apiKey: s.apiKey || undefined, model: s.model || undefined, baseURL: s.baseURL || undefined })\n yield* provider.stream(req)\n },\n }\n}, {\n /** An extension with an \"AI Settings\" command where users enter their own key. */\n settings: settingsExtension,\n})\n\nfunction settingsExtension(options: ByokOptions = {}): Extension {\n const storage = options.storage ?? defaultStorage()\n const key = options.key ?? 'qikbar:byok'\n const vendors = options.vendors ?? (Object.keys(LABELS) as ByokVendor[])\n return defineExtension({\n name: 'qikbar-ai-settings',\n title: 'AI',\n icon: 'key',\n commands: [\n {\n name: 'settings',\n title: 'AI Settings',\n subtitle: 'Use your own API key',\n keywords: ['api key', 'openai', 'anthropic', 'claude', 'gemini', 'model', 'byok'],\n icon: 'key',\n view: () => {\n const current = read(storage, key)\n return {\n type: 'form',\n title: 'AI Settings',\n submitLabel: 'Save',\n fields: [\n {\n name: 'vendor',\n label: 'Provider',\n type: 'select',\n options: vendors.map((v) => ({ title: LABELS[v], value: v })),\n defaultValue: current?.vendor ?? vendors[0],\n },\n {\n name: 'apiKey',\n label: 'API key',\n type: 'password',\n placeholder: 'Stored only in this browser',\n defaultValue: current?.apiKey ?? '',\n description: 'Your key never leaves your browser except to call the provider directly.',\n },\n { name: 'model', label: 'Model', placeholder: 'Leave empty for the default', defaultValue: current?.model ?? '' },\n { name: 'baseURL', label: 'Base URL', placeholder: 'Only for OpenAI-compatible APIs', defaultValue: current?.baseURL ?? '' },\n ],\n onSubmit(values, ctx) {\n storage.setItem(key, JSON.stringify(values))\n ctx.toast({ title: 'AI settings saved', style: 'success' })\n },\n }\n },\n },\n {\n name: 'clear',\n title: 'Remove AI API Key',\n icon: 'trash',\n keywords: ['byok', 'api key'],\n searchOnly: true,\n async run(ctx) {\n if (!(await ctx.confirm({ title: 'Remove your API key?', destructive: true, confirmLabel: 'Remove' }))) return false\n storage.removeItem(key)\n ctx.toast({ title: 'API key removed', style: 'success' })\n },\n },\n ],\n })\n}\n", "/**\n * A minimal MCP client (Streamable HTTP transport) that turns a remote MCP\n * server's tools into tools the bar's AI can call.\n *\n * ```ts\n * import { mcp } from '@qikbar/qikbar/ai'\n * createQikbar({ ai: { provider, mcp: [mcp({ url: '/api/mcp' })] } })\n * ```\n *\n * Browsers can only reach servers that allow CORS. For third-party servers,\n * proxy them through your backend (which also keeps tokens server-side).\n */\n\nimport type { JSONSchema, Tool, ToolProvider } from '../core/types.js'\nimport { parseSSE } from './sse.js'\n\nexport const MCP_PROTOCOL_VERSION = '2025-06-18'\n\nexport interface MCPOptions {\n /** The server's Streamable HTTP endpoint. */\n url: string\n /** Prefix for tool names and the label shown in errors. Default derived from the URL. */\n name?: string\n /** Extra headers, e.g. `{ Authorization: 'Bearer \u2026' }`. A function is called per request. */\n headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>)\n /** Only expose these tools (by name). */\n include?: string[]\n /** Hide these tools (by name). */\n exclude?: string[]\n /**\n * Ask the user before running a tool. Default: ask unless the server marks the tool\n * `readOnlyHint: true`. Pass `true`/`false` to always/never ask, or a function per tool.\n */\n confirm?: boolean | ((tool: MCPToolInfo) => boolean)\n /** Re-list tools after this many ms. Default 5 minutes. */\n ttl?: number\n /** Custom fetch (for tests or proxies). */\n fetch?: typeof fetch\n /** Send cookies to the server (same-origin proxies). Default `\"same-origin\"`. */\n credentials?: RequestCredentials\n}\n\nexport interface MCPToolInfo {\n name: string\n title?: string\n description?: string\n inputSchema?: JSONSchema\n annotations?: { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean }\n}\n\ninterface MCPContent {\n type: string\n text?: string\n mimeType?: string\n resource?: { uri?: string; text?: string }\n uri?: string\n name?: string\n}\n\ninterface JsonRpcResponse {\n jsonrpc: '2.0'\n id?: number | string\n result?: any\n error?: { code: number; message: string; data?: unknown }\n}\n\nexport class MCPError extends Error {\n constructor(\n message: string,\n readonly code?: number,\n ) {\n super(message)\n this.name = 'MCPError'\n }\n}\n\n/** A low-level MCP client. Most apps only need `mcp()`. */\nexport class MCPClient {\n private session?: string\n private protocol = MCP_PROTOCOL_VERSION\n private ready?: Promise<void>\n private negotiated = false\n private nextId = 1\n serverInfo?: { name?: string; version?: string }\n\n constructor(private options: MCPOptions) {}\n\n private async headers(): Promise<Record<string, string>> {\n const h = this.options.headers\n const extra = typeof h === 'function' ? await h() : (h ?? {})\n return {\n 'content-type': 'application/json',\n accept: 'application/json, text/event-stream',\n ...(this.session ? { 'mcp-session-id': this.session } : {}),\n ...(this.negotiated ? { 'mcp-protocol-version': this.protocol } : {}),\n ...extra,\n }\n }\n\n private async post(body: object, signal?: AbortSignal, expectId?: number): Promise<JsonRpcResponse | undefined> {\n const doFetch = this.options.fetch ?? globalThis.fetch\n const res = await doFetch(this.options.url, {\n method: 'POST',\n headers: await this.headers(),\n body: JSON.stringify(body),\n signal,\n credentials: this.options.credentials ?? 'same-origin',\n })\n const session = res.headers.get('mcp-session-id')\n if (session) this.session = session\n if (res.status === 404 && this.session && expectId != null) {\n // The server forgot our session: start over once.\n this.session = undefined\n this.ready = undefined\n this.negotiated = false\n throw new MCPError('MCP session expired', 404)\n }\n if (!res.ok && res.status !== 202) {\n const text = await res.text().catch(() => '')\n throw new MCPError(`MCP server responded ${res.status}${text ? `: ${text.slice(0, 200)}` : ''}`, res.status)\n }\n if (expectId == null || res.status === 202) return undefined\n const type = res.headers.get('content-type') ?? ''\n if (type.includes('text/event-stream')) {\n for await (const ev of parseSSE(res)) {\n if (!ev.data) continue\n let msg: JsonRpcResponse | JsonRpcResponse[]\n try {\n msg = JSON.parse(ev.data)\n } catch {\n continue\n }\n for (const m of Array.isArray(msg) ? msg : [msg]) if (m.id === expectId) return m\n }\n throw new MCPError('MCP stream ended without a response')\n }\n const json = (await res.json()) as JsonRpcResponse | JsonRpcResponse[]\n const list = Array.isArray(json) ? json : [json]\n return list.find((m) => m.id === expectId) ?? list[0]\n }\n\n private async request<T = any>(method: string, params: object | undefined, signal?: AbortSignal, retry = true): Promise<T> {\n if (method !== 'initialize') await this.connect(signal)\n const id = this.nextId++\n let res: JsonRpcResponse | undefined\n try {\n res = await this.post({ jsonrpc: '2.0', id, method, ...(params ? { params } : {}) }, signal, id)\n } catch (err) {\n if (retry && err instanceof MCPError && err.code === 404 && method !== 'initialize') return this.request(method, params, signal, false)\n throw err\n }\n if (!res) throw new MCPError(`No response to ${method}`)\n if (res.error) throw new MCPError(res.error.message, res.error.code)\n return res.result as T\n }\n\n /** Initialize the session (once). */\n connect(signal?: AbortSignal): Promise<void> {\n this.ready ??= (async () => {\n const result = await this.request<{ protocolVersion?: string; serverInfo?: { name?: string; version?: string } }>(\n 'initialize',\n { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'qikbar', version: '0.2.0' } },\n signal,\n )\n if (result?.protocolVersion) this.protocol = result.protocolVersion\n this.negotiated = true\n this.serverInfo = result?.serverInfo\n await this.post({ jsonrpc: '2.0', method: 'notifications/initialized' }, signal)\n })()\n this.ready.catch(() => {\n this.ready = undefined\n })\n return this.ready\n }\n\n /** List every tool, following pagination. */\n async listTools(signal?: AbortSignal): Promise<MCPToolInfo[]> {\n const tools: MCPToolInfo[] = []\n let cursor: string | undefined\n for (let page = 0; page < 20; page++) {\n const res = await this.request<{ tools?: MCPToolInfo[]; nextCursor?: string }>('tools/list', cursor ? { cursor } : undefined, signal)\n tools.push(...(res?.tools ?? []))\n cursor = res?.nextCursor\n if (!cursor) break\n }\n return tools\n }\n\n /** Call a tool and return its result as text for the model. */\n async callTool(name: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<string> {\n const res = await this.request<{ content?: MCPContent[]; structuredContent?: unknown; isError?: boolean }>('tools/call', { name, arguments: args }, signal)\n const text = contentToText(res?.content, res?.structuredContent)\n if (res?.isError) throw new MCPError(text || `Tool ${name} failed`)\n return text\n }\n\n /** End the session (best effort). */\n async close() {\n if (!this.session) return\n const doFetch = this.options.fetch ?? globalThis.fetch\n try {\n await doFetch(this.options.url, { method: 'DELETE', headers: await this.headers(), credentials: this.options.credentials ?? 'same-origin' })\n } catch {\n // ignore\n }\n this.session = undefined\n this.ready = undefined\n this.negotiated = false\n }\n}\n\nfunction contentToText(content: MCPContent[] | undefined, structured: unknown): string {\n const parts: string[] = []\n for (const c of content ?? []) {\n if (c.type === 'text' && c.text != null) parts.push(c.text)\n else if (c.type === 'resource' && c.resource?.text) parts.push(c.resource.text)\n else if (c.type === 'resource_link') parts.push(`[${c.name ?? c.uri}](${c.uri})`)\n else if (c.type === 'image' || c.type === 'audio') parts.push(`[${c.type}${c.mimeType ? ` ${c.mimeType}` : ''}]`)\n }\n if (!parts.length && structured !== undefined) return JSON.stringify(structured)\n return parts.join('\\n\\n')\n}\n\nfunction nameFromUrl(url: string): string {\n try {\n const u = new URL(url, typeof location !== 'undefined' ? location.href : 'http://localhost')\n const host = u.host.replace(/^(www|api|mcp)\\./, '').split('.')[0]\n return (host || 'mcp').replace(/[^a-zA-Z0-9_-]/g, '_')\n } catch {\n return 'mcp'\n }\n}\n\n/** Use an MCP server's tools in the bar's AI chat. */\nexport function mcp(options: MCPOptions): ToolProvider & { client: MCPClient; refresh(): void } {\n const client = new MCPClient(options)\n const name = (options.name ?? nameFromUrl(options.url)).replace(/[^a-zA-Z0-9_-]/g, '_')\n let cache: { at: number; tools: Promise<Tool[]> } | undefined\n const ttl = options.ttl ?? 5 * 60_000\n\n const shouldConfirm = (info: MCPToolInfo) => {\n const c = options.confirm\n if (typeof c === 'function') return c(info)\n if (typeof c === 'boolean') return c\n return info.annotations?.readOnlyHint !== true\n }\n\n const load = async (signal?: AbortSignal): Promise<Tool[]> => {\n const infos = await client.listTools(signal)\n return infos\n .filter((t) => (!options.include || options.include.includes(t.name)) && !options.exclude?.includes(t.name))\n .map(\n (info): Tool => ({\n name: info.name,\n description: info.description || info.annotations?.title || info.title || info.name,\n parameters: info.inputSchema ?? { type: 'object', properties: {} },\n confirm: shouldConfirm(info) ? () => `Allow ${info.annotations?.title ?? info.title ?? info.name} (${name})?` : false,\n run: (args, ctx) => client.callTool(info.name, (args ?? {}) as Record<string, unknown>, ctx.signal),\n }),\n )\n }\n\n return {\n name,\n client,\n refresh() {\n cache = undefined\n },\n tools(signal) {\n if (!cache || Date.now() - cache.at > ttl) {\n const entry = { at: Date.now(), tools: load(signal) }\n cache = entry\n entry.tools.catch(() => {\n if (cache === entry) cache = undefined\n })\n }\n return cache.tools\n },\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { defineExtension } from '../core/define.js'\nimport { defaultStorage } from '../core/storage.js'\nimport type { AIEvent, AIProvider, AIRequest, Extension, StorageAdapter } from '../core/types.js'\nimport { anthropic, gemini, openai } from './providers.js'\n\nexport type ByokVendor = 'anthropic' | 'openai' | 'gemini' | 'openai-compatible'\n\nexport interface ByokSettings {\n vendor: ByokVendor\n apiKey: string\n model?: string\n baseURL?: string\n}\n\nexport interface ByokOptions {\n /** Vendors offered in settings. Default: all. */\n vendors?: ByokVendor[]\n /** Storage key. Default `\"qikbar:byok\"`. */\n key?: string\n storage?: StorageAdapter\n}\n\nconst LABELS: Record<ByokVendor, string> = {\n anthropic: 'Anthropic (Claude)',\n openai: 'OpenAI',\n gemini: 'Google Gemini',\n 'openai-compatible': 'OpenAI-compatible (OpenRouter, Groq, Ollama\u2026)',\n}\n\nfunction read(storage: StorageAdapter, key: string): ByokSettings | undefined {\n try {\n const raw = storage.getItem(key)\n return raw ? (JSON.parse(raw) as ByokSettings) : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * \"Bring your own key\": your users paste their own API key, stored only in their\n * browser. Pair with `byok.settings()` so they can configure it from the bar.\n *\n * ```ts\n * createQikbar({ ai: byok(), extensions: [byok.settings()] })\n * ```\n */\nexport const byok = /* @__PURE__ */ Object.assign(function byok(options: ByokOptions = {}): AIProvider {\n const storage = options.storage ?? defaultStorage()\n const key = options.key ?? 'qikbar:byok'\n return {\n id: 'byok',\n get model() {\n return read(storage, key)?.model\n },\n async *stream(req: AIRequest): AsyncIterable<AIEvent> {\n const s = read(storage, key)\n if (!s?.apiKey && s?.vendor !== 'openai-compatible') {\n yield { type: 'error', error: 'Add your AI API key first: search for \u201CAI Settings\u201D in the command bar.' }\n yield { type: 'done', message: { role: 'assistant', content: '' } }\n return\n }\n const provider =\n s.vendor === 'anthropic'\n ? anthropic({ apiKey: s.apiKey, model: s.model || undefined })\n : s.vendor === 'gemini'\n ? gemini({ apiKey: s.apiKey, model: s.model || undefined })\n : openai({ apiKey: s.apiKey || undefined, model: s.model || undefined, baseURL: s.baseURL || undefined })\n yield* provider.stream(req)\n },\n }\n}, {\n /** An extension with an \"AI Settings\" command where users enter their own key. */\n settings: settingsExtension,\n})\n\nfunction settingsExtension(options: ByokOptions = {}): Extension {\n const storage = options.storage ?? defaultStorage()\n const key = options.key ?? 'qikbar:byok'\n const vendors = options.vendors ?? (Object.keys(LABELS) as ByokVendor[])\n return defineExtension({\n name: 'qikbar-ai-settings',\n title: 'AI',\n icon: 'key',\n commands: [\n {\n name: 'settings',\n title: 'AI Settings',\n subtitle: 'Use your own API key',\n keywords: ['api key', 'openai', 'anthropic', 'claude', 'gemini', 'model', 'byok'],\n icon: 'key',\n view: () => {\n const current = read(storage, key)\n return {\n type: 'form',\n title: 'AI Settings',\n submitLabel: 'Save',\n fields: [\n {\n name: 'vendor',\n label: 'Provider',\n type: 'select',\n options: vendors.map((v) => ({ title: LABELS[v], value: v })),\n defaultValue: current?.vendor ?? vendors[0],\n },\n {\n name: 'apiKey',\n label: 'API key',\n type: 'password',\n placeholder: 'Stored only in this browser',\n defaultValue: current?.apiKey ?? '',\n description: 'Your key never leaves your browser except to call the provider directly.',\n },\n { name: 'model', label: 'Model', placeholder: 'Leave empty for the default', defaultValue: current?.model ?? '' },\n { name: 'baseURL', label: 'Base URL', placeholder: 'Only for OpenAI-compatible APIs', defaultValue: current?.baseURL ?? '' },\n ],\n onSubmit(values, ctx) {\n storage.setItem(key, JSON.stringify(values))\n ctx.toast({ title: 'AI settings saved', style: 'success' })\n },\n }\n },\n },\n {\n name: 'clear',\n title: 'Remove AI API Key',\n icon: 'trash',\n keywords: ['byok', 'api key'],\n searchOnly: true,\n async run(ctx) {\n if (!(await ctx.confirm({ title: 'Remove your API key?', destructive: true, confirmLabel: 'Remove' }))) return false\n storage.removeItem(key)\n ctx.toast({ title: 'API key removed', style: 'success' })\n },\n },\n ],\n })\n}\n", "/**\n * A minimal MCP client (Streamable HTTP transport) that turns a remote MCP\n * server's tools into tools the bar's AI can call.\n *\n * ```ts\n * import { mcp } from '@qikbar/qikbar/ai'\n * createQikbar({ ai: { provider, mcp: [mcp({ url: '/api/mcp' })] } })\n * ```\n *\n * Browsers can only reach servers that allow CORS. For third-party servers,\n * proxy them through your backend (which also keeps tokens server-side).\n */\n\nimport type { JSONSchema, Tool, ToolProvider } from '../core/types.js'\nimport { parseSSE } from './sse.js'\n\nexport const MCP_PROTOCOL_VERSION = '2025-06-18'\n\nexport interface MCPOptions {\n /** The server's Streamable HTTP endpoint. */\n url: string\n /** Prefix for tool names and the label shown in errors. Default derived from the URL. */\n name?: string\n /** Extra headers, e.g. `{ Authorization: 'Bearer \u2026' }`. A function is called per request. */\n headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>)\n /** Only expose these tools (by name). */\n include?: string[]\n /** Hide these tools (by name). */\n exclude?: string[]\n /**\n * Ask the user before running a tool. Default: ask unless the server marks the tool\n * `readOnlyHint: true`. Pass `true`/`false` to always/never ask, or a function per tool.\n */\n confirm?: boolean | ((tool: MCPToolInfo) => boolean)\n /** Re-list tools after this many ms. Default 5 minutes. */\n ttl?: number\n /** Custom fetch (for tests or proxies). */\n fetch?: typeof fetch\n /** Send cookies to the server (same-origin proxies). Default `\"same-origin\"`. */\n credentials?: RequestCredentials\n}\n\nexport interface MCPToolInfo {\n name: string\n title?: string\n description?: string\n inputSchema?: JSONSchema\n annotations?: { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean }\n}\n\ninterface MCPContent {\n type: string\n text?: string\n mimeType?: string\n resource?: { uri?: string; text?: string }\n uri?: string\n name?: string\n}\n\ninterface JsonRpcResponse {\n jsonrpc: '2.0'\n id?: number | string\n result?: any\n error?: { code: number; message: string; data?: unknown }\n}\n\nexport class MCPError extends Error {\n constructor(\n message: string,\n readonly code?: number,\n ) {\n super(message)\n this.name = 'MCPError'\n }\n}\n\n/** A low-level MCP client. Most apps only need `mcp()`. */\nexport class MCPClient {\n private session?: string\n private protocol = MCP_PROTOCOL_VERSION\n private ready?: Promise<void>\n private negotiated = false\n private nextId = 1\n serverInfo?: { name?: string; version?: string }\n\n constructor(private options: MCPOptions) {}\n\n private async headers(): Promise<Record<string, string>> {\n const h = this.options.headers\n const extra = typeof h === 'function' ? await h() : (h ?? {})\n return {\n 'content-type': 'application/json',\n accept: 'application/json, text/event-stream',\n ...(this.session ? { 'mcp-session-id': this.session } : {}),\n ...(this.negotiated ? { 'mcp-protocol-version': this.protocol } : {}),\n ...extra,\n }\n }\n\n private async post(body: object, signal?: AbortSignal, expectId?: number): Promise<JsonRpcResponse | undefined> {\n const doFetch = this.options.fetch ?? globalThis.fetch\n const res = await doFetch(this.options.url, {\n method: 'POST',\n headers: await this.headers(),\n body: JSON.stringify(body),\n signal,\n credentials: this.options.credentials ?? 'same-origin',\n })\n const session = res.headers.get('mcp-session-id')\n if (session) this.session = session\n if (res.status === 404 && this.session && expectId != null) {\n // The server forgot our session: start over once.\n this.session = undefined\n this.ready = undefined\n this.negotiated = false\n throw new MCPError('MCP session expired', 404)\n }\n if (!res.ok && res.status !== 202) {\n const text = await res.text().catch(() => '')\n throw new MCPError(`MCP server responded ${res.status}${text ? `: ${text.slice(0, 200)}` : ''}`, res.status)\n }\n if (expectId == null || res.status === 202) return undefined\n const type = res.headers.get('content-type') ?? ''\n if (type.includes('text/event-stream')) {\n for await (const ev of parseSSE(res)) {\n if (!ev.data) continue\n let msg: JsonRpcResponse | JsonRpcResponse[]\n try {\n msg = JSON.parse(ev.data)\n } catch {\n continue\n }\n for (const m of Array.isArray(msg) ? msg : [msg]) if (m.id === expectId) return m\n }\n throw new MCPError('MCP stream ended without a response')\n }\n const json = (await res.json()) as JsonRpcResponse | JsonRpcResponse[]\n const list = Array.isArray(json) ? json : [json]\n return list.find((m) => m.id === expectId) ?? list[0]\n }\n\n private async request<T = any>(method: string, params: object | undefined, signal?: AbortSignal, retry = true): Promise<T> {\n if (method !== 'initialize') await this.connect(signal)\n const id = this.nextId++\n let res: JsonRpcResponse | undefined\n try {\n res = await this.post({ jsonrpc: '2.0', id, method, ...(params ? { params } : {}) }, signal, id)\n } catch (err) {\n if (retry && err instanceof MCPError && err.code === 404 && method !== 'initialize') return this.request(method, params, signal, false)\n throw err\n }\n if (!res) throw new MCPError(`No response to ${method}`)\n if (res.error) throw new MCPError(res.error.message, res.error.code)\n return res.result as T\n }\n\n /** Initialize the session (once). */\n connect(signal?: AbortSignal): Promise<void> {\n this.ready ??= (async () => {\n const result = await this.request<{ protocolVersion?: string; serverInfo?: { name?: string; version?: string } }>(\n 'initialize',\n { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'qikbar', version: '0.2.2' } },\n signal,\n )\n if (result?.protocolVersion) this.protocol = result.protocolVersion\n this.negotiated = true\n this.serverInfo = result?.serverInfo\n await this.post({ jsonrpc: '2.0', method: 'notifications/initialized' }, signal)\n })()\n this.ready.catch(() => {\n this.ready = undefined\n })\n return this.ready\n }\n\n /** List every tool, following pagination. */\n async listTools(signal?: AbortSignal): Promise<MCPToolInfo[]> {\n const tools: MCPToolInfo[] = []\n let cursor: string | undefined\n for (let page = 0; page < 20; page++) {\n const res = await this.request<{ tools?: MCPToolInfo[]; nextCursor?: string }>('tools/list', cursor ? { cursor } : undefined, signal)\n tools.push(...(res?.tools ?? []))\n cursor = res?.nextCursor\n if (!cursor) break\n }\n return tools\n }\n\n /** Call a tool and return its result as text for the model. */\n async callTool(name: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<string> {\n const res = await this.request<{ content?: MCPContent[]; structuredContent?: unknown; isError?: boolean }>('tools/call', { name, arguments: args }, signal)\n const text = contentToText(res?.content, res?.structuredContent)\n if (res?.isError) throw new MCPError(text || `Tool ${name} failed`)\n return text\n }\n\n /** End the session (best effort). */\n async close() {\n if (!this.session) return\n const doFetch = this.options.fetch ?? globalThis.fetch\n try {\n await doFetch(this.options.url, { method: 'DELETE', headers: await this.headers(), credentials: this.options.credentials ?? 'same-origin' })\n } catch {\n // ignore\n }\n this.session = undefined\n this.ready = undefined\n this.negotiated = false\n }\n}\n\nfunction contentToText(content: MCPContent[] | undefined, structured: unknown): string {\n const parts: string[] = []\n for (const c of content ?? []) {\n if (c.type === 'text' && c.text != null) parts.push(c.text)\n else if (c.type === 'resource' && c.resource?.text) parts.push(c.resource.text)\n else if (c.type === 'resource_link') parts.push(`[${c.name ?? c.uri}](${c.uri})`)\n else if (c.type === 'image' || c.type === 'audio') parts.push(`[${c.type}${c.mimeType ? ` ${c.mimeType}` : ''}]`)\n }\n if (!parts.length && structured !== undefined) return JSON.stringify(structured)\n return parts.join('\\n\\n')\n}\n\nfunction nameFromUrl(url: string): string {\n try {\n const u = new URL(url, typeof location !== 'undefined' ? location.href : 'http://localhost')\n const host = u.host.replace(/^(www|api|mcp)\\./, '').split('.')[0]\n return (host || 'mcp').replace(/[^a-zA-Z0-9_-]/g, '_')\n } catch {\n return 'mcp'\n }\n}\n\n/** Use an MCP server's tools in the bar's AI chat. */\nexport function mcp(options: MCPOptions): ToolProvider & { client: MCPClient; refresh(): void } {\n const client = new MCPClient(options)\n const name = (options.name ?? nameFromUrl(options.url)).replace(/[^a-zA-Z0-9_-]/g, '_')\n let cache: { at: number; tools: Promise<Tool[]> } | undefined\n const ttl = options.ttl ?? 5 * 60_000\n\n const shouldConfirm = (info: MCPToolInfo) => {\n const c = options.confirm\n if (typeof c === 'function') return c(info)\n if (typeof c === 'boolean') return c\n return info.annotations?.readOnlyHint !== true\n }\n\n const load = async (signal?: AbortSignal): Promise<Tool[]> => {\n const infos = await client.listTools(signal)\n return infos\n .filter((t) => (!options.include || options.include.includes(t.name)) && !options.exclude?.includes(t.name))\n .map(\n (info): Tool => ({\n name: info.name,\n description: info.description || info.annotations?.title || info.title || info.name,\n parameters: info.inputSchema ?? { type: 'object', properties: {} },\n confirm: shouldConfirm(info) ? () => `Allow ${info.annotations?.title ?? info.title ?? info.name} (${name})?` : false,\n run: (args, ctx) => client.callTool(info.name, (args ?? {}) as Record<string, unknown>, ctx.signal),\n }),\n )\n }\n\n return {\n name,\n client,\n refresh() {\n cache = undefined\n },\n tools(signal) {\n if (!cache || Date.now() - cache.at > ttl) {\n const entry = { at: Date.now(), tools: load(signal) }\n cache = entry\n entry.tools.catch(() => {\n if (cache === entry) cache = undefined\n })\n }\n return cache.tools\n },\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAsBA,IAAM,SAAqC;AAAA,EACzC,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,qBAAqB;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