@hanzo/browser-extension 1.9.36 → 1.9.46
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/safari/Hanzo AI/Hanzo AI.xcodeproj/project.pbxproj +1059 -0
- package/dist/safari/Hanzo AI/Hanzo AI.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/AppIcon.appiconset/universal-icon-1024@1x.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +21 -0
- package/dist/safari/Hanzo AI/Shared (App)/Assets.xcassets/LargeIcon.imageset/icon128.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Base.lproj/Main.html +20 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Icon.png +0 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Script.js +24 -0
- package/dist/safari/Hanzo AI/Shared (App)/Resources/Style.css +61 -0
- package/dist/safari/Hanzo AI/Shared (App)/ViewController.swift +81 -0
- package/dist/safari/Hanzo AI/Shared (Extension)/SafariWebExtensionHandler.swift +42 -0
- package/dist/safari/Hanzo AI/iOS (App)/AppDelegate.swift +24 -0
- package/dist/safari/Hanzo AI/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/dist/safari/Hanzo AI/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/dist/safari/Hanzo AI/iOS (App)/Info.plist +27 -0
- package/dist/safari/Hanzo AI/iOS (App)/SceneDelegate.swift +18 -0
- package/dist/safari/Hanzo AI/iOS (Extension)/Info.plist +13 -0
- package/dist/safari/Hanzo AI/macOS (App)/AppDelegate.swift +21 -0
- package/dist/safari/Hanzo AI/macOS (App)/Base.lproj/Main.storyboard +124 -0
- package/dist/safari/Hanzo AI/macOS (App)/Info.plist +8 -0
- package/dist/safari/Hanzo AI/macOS (Extension)/Info.plist +13 -0
- package/package.json +20 -14
- package/src/answer/AnswerEngine.tsx +172 -348
- package/src/answer/Composer.tsx +147 -0
- package/src/answer/Mark.tsx +14 -0
- package/src/answer/Models.tsx +118 -0
- package/src/answer/Rail.tsx +69 -0
- package/src/answer/Source.tsx +26 -0
- package/src/answer/Stories.tsx +27 -0
- package/src/answer/WidgetView.tsx +136 -0
- package/src/manifest.json +4 -1
- package/src/newtab.css +187 -35
- package/src/popup.html +1 -1
- package/src/sidebar.css +0 -40
- package/src/sidebar.html +5 -11
- package/LICENSE +0 -12
- package/src/chat-widget.tsx +0 -96
- package/src/gui-primitives.tsx +0 -116
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SearchMode } from '@hanzo/ai';
|
|
3
|
+
import { Button, Textarea } from '@hanzo/ui';
|
|
4
|
+
import { Models } from './Models.js';
|
|
5
|
+
import type { ChatModel, ModelGroup } from './model-catalog.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The composer: an auto-growing field over one toolbar row — source pills on the
|
|
9
|
+
* left, mode tabs + model picker + a single send control on the right.
|
|
10
|
+
*
|
|
11
|
+
* Enter sends; Shift+Enter writes a newline. The send control is also the busy
|
|
12
|
+
* indicator, so there is exactly one control for "go" and one signal for "running".
|
|
13
|
+
*
|
|
14
|
+
* Presentational: every value and every effect is injected. It owns no query
|
|
15
|
+
* state and never calls a backend — mount it wherever the answer surface lives.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** What the composer sends. `chat` goes straight to the model; the rest ground
|
|
19
|
+
* the question on the live web (`SearchMode` is the wire's own vocabulary).
|
|
20
|
+
*
|
|
21
|
+
* `deep` is EXCLUDED rather than absent. The wire still names it — dropping it
|
|
22
|
+
* from `MODES` only stopped it being offered, it stayed a legal `Mode`, so any
|
|
23
|
+
* call site could still hold one and put the retired name back on the surface.
|
|
24
|
+
* Excluding it makes the collapse structural. Derived from `SearchMode` and not
|
|
25
|
+
* restated, so a mode this surface invents is still a type error, and the day
|
|
26
|
+
* the wire drops `deep` this narrows to nothing on its own. */
|
|
27
|
+
export type Mode = Exclude<SearchMode, 'deep'> | 'chat';
|
|
28
|
+
|
|
29
|
+
/** The modes, in the order they read as escalating effort. */
|
|
30
|
+
export const MODES: { id: Mode; label: string; hint: string }[] = [
|
|
31
|
+
{ id: 'chat', label: 'Chat', hint: 'Straight to the model' },
|
|
32
|
+
{ id: 'search', label: 'Search', hint: 'Fast grounded answer' },
|
|
33
|
+
{ id: 'news', label: 'News', hint: 'Recency-biased' },
|
|
34
|
+
// No 'deep'. It was research with the dials up — same system prompt, same
|
|
35
|
+
// models, same gate — so two names offered a choice that was really an
|
|
36
|
+
// intensity, and hid a 2x price behind an adjective. Cloud folded them into
|
|
37
|
+
// one research mode (apps/answer/mode.go) that always does the deeper pass;
|
|
38
|
+
// 'deep' still RESOLVES there, so a client that has not shipped this does not
|
|
39
|
+
// 400 — which is why dropping the tab is safe on its own.
|
|
40
|
+
{ id: 'research', label: 'Research', hint: 'Plans, reads sources, synthesizes' },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export const SOURCES = ['web', 'news', 'academic', 'github', 'reddit', 'x'];
|
|
44
|
+
|
|
45
|
+
export interface ComposerProps {
|
|
46
|
+
value: string;
|
|
47
|
+
onChange: (value: string) => void;
|
|
48
|
+
onSubmit: () => void;
|
|
49
|
+
mode: Mode;
|
|
50
|
+
setMode: (mode: Mode) => void;
|
|
51
|
+
sources: Set<string>;
|
|
52
|
+
toggleSource: (source: string) => void;
|
|
53
|
+
models: ModelGroup[];
|
|
54
|
+
model: ChatModel;
|
|
55
|
+
setModel: (model: ChatModel) => void;
|
|
56
|
+
busy: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function Composer({
|
|
60
|
+
value,
|
|
61
|
+
onChange,
|
|
62
|
+
onSubmit,
|
|
63
|
+
mode,
|
|
64
|
+
setMode,
|
|
65
|
+
sources,
|
|
66
|
+
toggleSource,
|
|
67
|
+
models,
|
|
68
|
+
model,
|
|
69
|
+
setModel,
|
|
70
|
+
busy,
|
|
71
|
+
}: ComposerProps) {
|
|
72
|
+
return (
|
|
73
|
+
<div className="ae-card">
|
|
74
|
+
{/* @hanzo/ui field — auto-grows by line count (rows is the floor), so the
|
|
75
|
+
DOM-measured resize effect the raw <textarea> needed is gone. Blends
|
|
76
|
+
into .ae-card with transparent bg / no border, matching .ae-input. */}
|
|
77
|
+
<Textarea
|
|
78
|
+
placeholder={mode === 'chat' ? 'Ask anything' : 'Type @ for sources or / for modes'}
|
|
79
|
+
value={value}
|
|
80
|
+
rows={1}
|
|
81
|
+
maxH={200}
|
|
82
|
+
bg="transparent"
|
|
83
|
+
borderWidth={0}
|
|
84
|
+
px={18}
|
|
85
|
+
fontSize={15}
|
|
86
|
+
onChangeText={onChange}
|
|
87
|
+
onKeyDown={(e) => {
|
|
88
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
onSubmit();
|
|
91
|
+
}
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
<div className="ae-card-row">
|
|
95
|
+
{/* The container stays in the row whatever the mode: it is the left half
|
|
96
|
+
of a space-between, so dropping it would slide the toolbar left.
|
|
97
|
+
Chat is ungrounded, so it offers no sources to pick. */}
|
|
98
|
+
<div className="ae-chips">
|
|
99
|
+
{mode !== 'chat' &&
|
|
100
|
+
SOURCES.map((s) => (
|
|
101
|
+
<button
|
|
102
|
+
key={s}
|
|
103
|
+
className={'ae-chip' + (sources.has(s) ? ' on' : '')}
|
|
104
|
+
onClick={() => toggleSource(s)}
|
|
105
|
+
title={`@${s}`}
|
|
106
|
+
>
|
|
107
|
+
@{s}
|
|
108
|
+
</button>
|
|
109
|
+
))}
|
|
110
|
+
</div>
|
|
111
|
+
<div className="ae-card-right">
|
|
112
|
+
<div className="ae-modes">
|
|
113
|
+
{MODES.map((m) => (
|
|
114
|
+
<button
|
|
115
|
+
key={m.id}
|
|
116
|
+
className={'ae-mode' + (mode === m.id ? ' on' : '')}
|
|
117
|
+
onClick={() => setMode(m.id)}
|
|
118
|
+
title={m.hint}
|
|
119
|
+
>
|
|
120
|
+
{m.label}
|
|
121
|
+
</button>
|
|
122
|
+
))}
|
|
123
|
+
</div>
|
|
124
|
+
<Models groups={models} current={model} onPick={setModel} />
|
|
125
|
+
{/* @hanzo/ui send control — `isLoading` is the built-in busy signal,
|
|
126
|
+
so the hand-rolled .ae-spinner is gone with the raw <button>. */}
|
|
127
|
+
<Button
|
|
128
|
+
size="icon"
|
|
129
|
+
rounded={999}
|
|
130
|
+
width={34}
|
|
131
|
+
height={34}
|
|
132
|
+
onPress={onSubmit}
|
|
133
|
+
disabled={busy || !value.trim()}
|
|
134
|
+
isLoading={busy}
|
|
135
|
+
aria-label="Search (Enter)"
|
|
136
|
+
>
|
|
137
|
+
{busy ? null : (
|
|
138
|
+
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
|
|
139
|
+
<path d="M3 13V3l10 5-10 5z" fill="currentColor" />
|
|
140
|
+
</svg>
|
|
141
|
+
)}
|
|
142
|
+
</Button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/** The Hanzo mark. Monochrome — it inherits colour from its parent. */
|
|
4
|
+
export function Mark({ size = 28 }: { size?: number }) {
|
|
5
|
+
return (
|
|
6
|
+
<svg viewBox="0 0 67 67" width={size} height={size} xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
7
|
+
<path d="M22.21 67V44.6369H0V67H22.21Z" fill="currentColor" />
|
|
8
|
+
<path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z" fill="currentColor" />
|
|
9
|
+
<path d="M22.21 0H0V22.3184H22.21V0Z" fill="currentColor" />
|
|
10
|
+
<path d="M66.7198 0H44.5098V22.3184H66.7198V0Z" fill="currentColor" />
|
|
11
|
+
<path d="M66.7198 67V44.6369H44.5098V67H66.7198Z" fill="currentColor" />
|
|
12
|
+
</svg>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { AUTO_MODEL, type ChatModel, type ModelGroup } from './model-catalog.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The model picker: a filterable menu over the grouped catalog, with Auto — the
|
|
6
|
+
* router — pinned at the top as the one entry that is always valid.
|
|
7
|
+
*
|
|
8
|
+
* Presentational: the catalog and the choice are both injected. It never fetches.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Tiers mirror @hanzo/plans (the pricing SoT); shown in the upgrade banner.
|
|
12
|
+
// Full plan detail lives at console.hanzo.ai/pricing.
|
|
13
|
+
const TIERS = [
|
|
14
|
+
{ name: 'Pro', price: '$20' },
|
|
15
|
+
{ name: 'Max', price: '$100' },
|
|
16
|
+
{ name: 'Ultra', price: '$200' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export interface ModelsProps {
|
|
20
|
+
groups: ModelGroup[];
|
|
21
|
+
current: ChatModel;
|
|
22
|
+
onPick: (model: ChatModel) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Models({ groups, current, onPick }: ModelsProps) {
|
|
26
|
+
const [open, setOpen] = useState(false);
|
|
27
|
+
const [filter, setFilter] = useState('');
|
|
28
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!open) return;
|
|
32
|
+
const onDoc = (e: MouseEvent) => {
|
|
33
|
+
if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
|
|
34
|
+
};
|
|
35
|
+
document.addEventListener('mousedown', onDoc);
|
|
36
|
+
return () => document.removeEventListener('mousedown', onDoc);
|
|
37
|
+
}, [open]);
|
|
38
|
+
|
|
39
|
+
const q = filter.trim().toLowerCase();
|
|
40
|
+
const shown = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
groups
|
|
43
|
+
.map((g) => ({
|
|
44
|
+
...g,
|
|
45
|
+
models: g.models.filter(
|
|
46
|
+
(m) => !q || m.name.toLowerCase().includes(q) || m.id.toLowerCase().includes(q),
|
|
47
|
+
),
|
|
48
|
+
}))
|
|
49
|
+
.filter((g) => g.models.length),
|
|
50
|
+
[groups, q],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="ae-picker" ref={ref}>
|
|
55
|
+
<button className="ae-picker-btn" onClick={() => setOpen((v) => !v)} title="Choose model">
|
|
56
|
+
<span className="ae-dot" />
|
|
57
|
+
{current.name}
|
|
58
|
+
<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true">
|
|
59
|
+
<path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" strokeWidth="1.5" />
|
|
60
|
+
</svg>
|
|
61
|
+
</button>
|
|
62
|
+
{open && (
|
|
63
|
+
<div className="ae-picker-menu">
|
|
64
|
+
<input
|
|
65
|
+
className="ae-picker-filter"
|
|
66
|
+
placeholder="Search models…"
|
|
67
|
+
value={filter}
|
|
68
|
+
autoFocus
|
|
69
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
70
|
+
/>
|
|
71
|
+
<div className="ae-picker-list">
|
|
72
|
+
<button
|
|
73
|
+
className={'ae-model-row' + (current.id === AUTO_MODEL.id ? ' active' : '')}
|
|
74
|
+
onClick={() => {
|
|
75
|
+
onPick(AUTO_MODEL);
|
|
76
|
+
setOpen(false);
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<span className="ae-model-name">Auto</span>
|
|
80
|
+
<span className="ae-model-desc">Routes to the best model</span>
|
|
81
|
+
</button>
|
|
82
|
+
{shown.map((g) => (
|
|
83
|
+
<div key={g.family} className="ae-model-group">
|
|
84
|
+
<div className="ae-model-group-label">{g.label}</div>
|
|
85
|
+
{g.models.map((m) => (
|
|
86
|
+
<button
|
|
87
|
+
key={m.id}
|
|
88
|
+
className={'ae-model-row' + (current.id === m.id ? ' active' : '')}
|
|
89
|
+
onClick={() => {
|
|
90
|
+
onPick(m);
|
|
91
|
+
setOpen(false);
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
<span className="ae-model-name">
|
|
95
|
+
{m.name}
|
|
96
|
+
{m.tier && <span className="ae-badge">{m.tier}</span>}
|
|
97
|
+
</span>
|
|
98
|
+
{m.description && <span className="ae-model-desc">{m.description}</span>}
|
|
99
|
+
</button>
|
|
100
|
+
))}
|
|
101
|
+
</div>
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
<a className="ae-plan-banner" href="https://console.hanzo.ai/pricing" target="_blank" rel="noreferrer">
|
|
105
|
+
<span>Unlock every model</span>
|
|
106
|
+
<span className="ae-plan-tiers">
|
|
107
|
+
{TIERS.map((t) => (
|
|
108
|
+
<span key={t.name} className="ae-plan-tier">
|
|
109
|
+
{t.name} <b>{t.price}</b>
|
|
110
|
+
</span>
|
|
111
|
+
))}
|
|
112
|
+
</span>
|
|
113
|
+
</a>
|
|
114
|
+
</div>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Mark } from './Mark.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The left rail: mark, new thread, links, sign-in.
|
|
6
|
+
*
|
|
7
|
+
* COLLAPSED IS AN ICON RAIL, NOT AN ABSENCE — the `collapsible="icon"` behaviour of
|
|
8
|
+
* @hanzo/ui primitives/sidebar. A collapsed rail still shows the brand and the way
|
|
9
|
+
* back; hiding it outright left the surface with no affordance at all.
|
|
10
|
+
*
|
|
11
|
+
* The labels are ALWAYS RENDERED and hidden in CSS, never branched on in JS. Opening
|
|
12
|
+
* on hover is a CSS state (`.ae-root.collapsed:hover`), so markup that only appears
|
|
13
|
+
* when `collapsed` is false could never be revealed by hovering — the rail would
|
|
14
|
+
* widen to show nothing. Presentational: every action is injected.
|
|
15
|
+
*/
|
|
16
|
+
export interface RailProps {
|
|
17
|
+
collapsed: boolean;
|
|
18
|
+
toggle: () => void;
|
|
19
|
+
newThread: () => void;
|
|
20
|
+
signIn: () => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function Rail({ collapsed, toggle, newThread, signIn }: RailProps) {
|
|
24
|
+
return (
|
|
25
|
+
<aside className="ae-sidebar">
|
|
26
|
+
<div className="ae-side-top">
|
|
27
|
+
<button className="ae-brand" onClick={newThread} title="Hanzo">
|
|
28
|
+
<Mark size={22} />
|
|
29
|
+
<span>Hanzo</span>
|
|
30
|
+
</button>
|
|
31
|
+
<button
|
|
32
|
+
className="ae-collapse"
|
|
33
|
+
onClick={toggle}
|
|
34
|
+
title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
|
35
|
+
aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
|
36
|
+
aria-expanded={!collapsed}
|
|
37
|
+
>
|
|
38
|
+
<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
|
|
39
|
+
<path d="M6 3v10M3 3h10v10H3z" fill="none" stroke="currentColor" strokeWidth="1.3" />
|
|
40
|
+
</svg>
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
<button className="ae-new" onClick={newThread} title="New thread">
|
|
44
|
+
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
|
|
45
|
+
<path d="M8 3v10M3 8h10" fill="none" stroke="currentColor" strokeWidth="1.5" />
|
|
46
|
+
</svg>
|
|
47
|
+
<span>New thread</span>
|
|
48
|
+
</button>
|
|
49
|
+
<nav className="ae-nav">
|
|
50
|
+
<a href="https://hanzo.chat" target="_blank" rel="noreferrer">Threads</a>
|
|
51
|
+
<a href="https://docs.hanzo.ai" target="_blank" rel="noreferrer">Docs</a>
|
|
52
|
+
<a href="https://hanzo.ai" target="_blank" rel="noreferrer">About</a>
|
|
53
|
+
</nav>
|
|
54
|
+
<div className="ae-side-bottom">
|
|
55
|
+
<button className="ae-signin" onClick={signIn} title="Sign in">
|
|
56
|
+
<svg viewBox="0 0 16 16" width="15" height="15" aria-hidden="true">
|
|
57
|
+
<path
|
|
58
|
+
d="M6 3H3v10h3M10 5l3 3-3 3M13 8H6"
|
|
59
|
+
fill="none"
|
|
60
|
+
stroke="currentColor"
|
|
61
|
+
strokeWidth="1.4"
|
|
62
|
+
/>
|
|
63
|
+
</svg>
|
|
64
|
+
<span className="ae-signin-label">Sign in — free to start</span>
|
|
65
|
+
</button>
|
|
66
|
+
</div>
|
|
67
|
+
</aside>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SearchSource } from '@hanzo/ai';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One cited source, numbered to match its marker in the answer body.
|
|
6
|
+
* Falls back to the raw URL when the host will not parse, and to a dot when the
|
|
7
|
+
* site serves no favicon — a citation always renders.
|
|
8
|
+
*/
|
|
9
|
+
export function Source({ source, index }: { source: SearchSource; index: number }) {
|
|
10
|
+
let host: string;
|
|
11
|
+
try {
|
|
12
|
+
host = new URL(source.url).hostname.replace(/^www\./, '');
|
|
13
|
+
} catch {
|
|
14
|
+
host = source.url;
|
|
15
|
+
}
|
|
16
|
+
return (
|
|
17
|
+
<a className="ae-source" href={source.url} target="_blank" rel="noreferrer" title={source.title}>
|
|
18
|
+
<span className="ae-source-head">
|
|
19
|
+
<span className="ae-source-idx">{index + 1}</span>
|
|
20
|
+
{source.favicon ? <img src={source.favicon} alt="" width="14" height="14" /> : <span className="ae-dot" />}
|
|
21
|
+
<span className="ae-source-host">{host}</span>
|
|
22
|
+
</span>
|
|
23
|
+
<span className="ae-source-title">{source.title}</span>
|
|
24
|
+
</a>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { NewsItem } from './news.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Top stories — the idle state of the answer surface. Renders nothing at all
|
|
6
|
+
* when the feed is empty, so a failed fetch leaves a clean page rather than an
|
|
7
|
+
* empty frame.
|
|
8
|
+
*/
|
|
9
|
+
export function Stories({ items, limit = 6 }: { items: NewsItem[]; limit?: number }) {
|
|
10
|
+
if (!items.length) return null;
|
|
11
|
+
return (
|
|
12
|
+
<div className="ae-news">
|
|
13
|
+
<div className="ae-news-head">Top stories</div>
|
|
14
|
+
<div className="ae-news-grid">
|
|
15
|
+
{items.slice(0, limit).map((n) => (
|
|
16
|
+
<a key={n.url} className="ae-news-item" href={n.url} target="_blank" rel="noreferrer">
|
|
17
|
+
<span className="ae-news-title">{n.title}</span>
|
|
18
|
+
<span className="ae-news-meta">
|
|
19
|
+
{n.source}
|
|
20
|
+
{typeof n.points === 'number' ? ` · ${n.points} pts` : ''}
|
|
21
|
+
</span>
|
|
22
|
+
</a>
|
|
23
|
+
))}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Widget } from './widget.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Renders a generative result widget.
|
|
6
|
+
*
|
|
7
|
+
* NAMED WidgetView, not Widget, because widget.ts sits beside it and macOS is
|
|
8
|
+
* case-insensitive: `./Widget.js` resolves to `widget.ts` there, so the schema
|
|
9
|
+
* module shadowed this one and the build failed on a missing export. Two modules
|
|
10
|
+
* in one directory differing only by case cannot both be imported.
|
|
11
|
+
*
|
|
12
|
+
* Presentational and total: every kind in the union has a branch, and every value
|
|
13
|
+
* arrives as a React child, so it is ESCAPED by construction. There is no
|
|
14
|
+
* dangerouslySetInnerHTML here and there must never be one — the content is written
|
|
15
|
+
* by a model that reads the open web, so treating any of it as markup hands whoever
|
|
16
|
+
* wrote that web page a path into this extension's origin.
|
|
17
|
+
*/
|
|
18
|
+
export function WidgetView({ widget }: { widget: Widget }) {
|
|
19
|
+
switch (widget.kind) {
|
|
20
|
+
case 'comparison':
|
|
21
|
+
return (
|
|
22
|
+
<section className="ae-widget ae-widget-comparison">
|
|
23
|
+
{widget.title && <h3 className="ae-widget-title">{widget.title}</h3>}
|
|
24
|
+
{/* Its own scroll container: a wide table must never make the PAGE
|
|
25
|
+
scroll sideways. */}
|
|
26
|
+
<div className="ae-widget-scroll">
|
|
27
|
+
<table className="ae-widget-table">
|
|
28
|
+
<thead>
|
|
29
|
+
<tr>
|
|
30
|
+
{widget.columns.map((c, i) => (
|
|
31
|
+
<th key={i} scope={i === 0 ? 'row' : 'col'}>
|
|
32
|
+
{c}
|
|
33
|
+
</th>
|
|
34
|
+
))}
|
|
35
|
+
</tr>
|
|
36
|
+
</thead>
|
|
37
|
+
<tbody>
|
|
38
|
+
{widget.rows.map((row, i) => (
|
|
39
|
+
<tr key={i}>
|
|
40
|
+
{row.map((cell, j) =>
|
|
41
|
+
j === 0 ? (
|
|
42
|
+
<th key={j} scope="row">
|
|
43
|
+
{cell}
|
|
44
|
+
</th>
|
|
45
|
+
) : (
|
|
46
|
+
<td key={j}>{cell}</td>
|
|
47
|
+
),
|
|
48
|
+
)}
|
|
49
|
+
</tr>
|
|
50
|
+
))}
|
|
51
|
+
</tbody>
|
|
52
|
+
</table>
|
|
53
|
+
</div>
|
|
54
|
+
</section>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
case 'steps':
|
|
58
|
+
return (
|
|
59
|
+
<section className="ae-widget ae-widget-steps">
|
|
60
|
+
{widget.title && <h3 className="ae-widget-title">{widget.title}</h3>}
|
|
61
|
+
<ol className="ae-widget-steplist">
|
|
62
|
+
{widget.steps.map((s, i) => (
|
|
63
|
+
<li key={i}>{s}</li>
|
|
64
|
+
))}
|
|
65
|
+
</ol>
|
|
66
|
+
</section>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
case 'stats':
|
|
70
|
+
return (
|
|
71
|
+
<section className="ae-widget ae-widget-stats">
|
|
72
|
+
{widget.title && <h3 className="ae-widget-title">{widget.title}</h3>}
|
|
73
|
+
<div className="ae-widget-statgrid">
|
|
74
|
+
{widget.stats.map((s, i) => (
|
|
75
|
+
<div className="ae-widget-stat" key={i}>
|
|
76
|
+
<span className="ae-widget-statvalue">{s.value}</span>
|
|
77
|
+
<span className="ae-widget-statlabel">{s.label}</span>
|
|
78
|
+
</div>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
</section>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
case 'timeline':
|
|
85
|
+
return (
|
|
86
|
+
<section className="ae-widget ae-widget-timeline">
|
|
87
|
+
{widget.title && <h3 className="ae-widget-title">{widget.title}</h3>}
|
|
88
|
+
<ol className="ae-widget-events">
|
|
89
|
+
{widget.events.map((e, i) => (
|
|
90
|
+
<li key={i}>
|
|
91
|
+
<span className="ae-widget-when">{e.when}</span>
|
|
92
|
+
<span className="ae-widget-what">{e.what}</span>
|
|
93
|
+
</li>
|
|
94
|
+
))}
|
|
95
|
+
</ol>
|
|
96
|
+
</section>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
case 'entity':
|
|
100
|
+
return (
|
|
101
|
+
<section className="ae-widget ae-widget-entity">
|
|
102
|
+
<h3 className="ae-widget-title">{widget.title}</h3>
|
|
103
|
+
{widget.subtitle && <p className="ae-widget-subtitle">{widget.subtitle}</p>}
|
|
104
|
+
<dl className="ae-widget-facts">
|
|
105
|
+
{widget.facts.map((f, i) => (
|
|
106
|
+
<React.Fragment key={i}>
|
|
107
|
+
<dt>{f.label}</dt>
|
|
108
|
+
<dd>{f.value}</dd>
|
|
109
|
+
</React.Fragment>
|
|
110
|
+
))}
|
|
111
|
+
</dl>
|
|
112
|
+
</section>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
case 'definition':
|
|
116
|
+
return (
|
|
117
|
+
<section className="ae-widget ae-widget-definition">
|
|
118
|
+
<h3 className="ae-widget-title">{widget.term}</h3>
|
|
119
|
+
<p className="ae-widget-meaning">{widget.meaning}</p>
|
|
120
|
+
{widget.example && <pre className="ae-widget-example">{widget.example}</pre>}
|
|
121
|
+
</section>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Renders every widget an answer produced, or nothing. */
|
|
127
|
+
export function Widgets({ widgets }: { widgets: Widget[] }) {
|
|
128
|
+
if (!widgets.length) return null;
|
|
129
|
+
return (
|
|
130
|
+
<div className="ae-widgets">
|
|
131
|
+
{widgets.map((w, i) => (
|
|
132
|
+
<WidgetView key={i} widget={w} />
|
|
133
|
+
))}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
package/src/manifest.json
CHANGED
|
@@ -54,6 +54,9 @@
|
|
|
54
54
|
"48": "icon48.png",
|
|
55
55
|
"128": "icon128.png"
|
|
56
56
|
},
|
|
57
|
+
"omnibox": {
|
|
58
|
+
"keyword": "hanzo"
|
|
59
|
+
},
|
|
57
60
|
"chrome_url_overrides": {
|
|
58
61
|
"newtab": "newtab.html"
|
|
59
62
|
},
|
|
@@ -61,7 +64,7 @@
|
|
|
61
64
|
"search_provider": {
|
|
62
65
|
"name": "Hanzo",
|
|
63
66
|
"keyword": "hanzo",
|
|
64
|
-
"search_url": "https://hanzo.chat
|
|
67
|
+
"search_url": "https://hanzo.chat/?q={searchTerms}",
|
|
65
68
|
"favicon_url": "https://hanzo.ai/favicon.ico",
|
|
66
69
|
"encoding": "UTF-8",
|
|
67
70
|
"is_default": true
|