@hanzo/app 0.2.21 → 0.2.22

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/Chat.js CHANGED
@@ -512,6 +512,16 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
512
512
  const mind = useMind(target, anonymous ? "free" : limits?.plan);
513
513
  catalog.current = mind.models;
514
514
  const [chatPrefs, setChatPrefs] = useChatPreferences();
515
+ useEffect(() => {
516
+ const eff = chatPrefs.effort || "high";
517
+ if (eff === "low" || eff === "medium" || eff === "high") {
518
+ mind.pace(eff);
519
+ }
520
+ else if (eff === "xhigh" || eff === "max") {
521
+ mind.pace("high");
522
+ }
523
+ // eslint-disable-next-line react-hooks/exhaustive-deps
524
+ }, [chatPrefs.effort]);
515
525
  const ai = useAi();
516
526
  // In the app's frame the composer floats on the pane as a pane of its own.
517
527
  const framed = useContext(Framed);
package/dist/Setup.js CHANGED
@@ -14,11 +14,13 @@ import { useIam } from '@hanzo/iam/react';
14
14
  import { Check, Maximize2, Sparkles, X } from 'lucide-react';
15
15
  import { ProviderMark } from './ProviderMark.js';
16
16
  import { useKept } from './kept.js';
17
- import { api } from './lib/api.js';
17
+ import { api, CLIENT } from './lib/api.js';
18
+ import { answers } from './lib/host.js';
18
19
  import { scope } from './lib/session.js';
19
20
  import { enter } from './lib/destination.js';
20
21
  import { brand } from './where.js';
21
22
  import { GOOD } from './lib/mix.js';
23
+ const here = () => typeof window !== 'undefined' && answers(window.location.hostname);
22
24
  const LATER_KEY = 'hanzo.onboarding.later';
23
25
  const GITHUB_KEY = 'hanzo.onboarding.github';
24
26
  const SLACK_KEY = 'hanzo.onboarding.slack';
@@ -30,7 +32,7 @@ function SlackMark({ size = 18 }) {
30
32
  }
31
33
  export function Setup() {
32
34
  const { t } = useI18n();
33
- const { isAuthenticated, accessToken } = useIam();
35
+ const { isAuthenticated, accessToken, sdk } = useIam();
34
36
  const [later, setLater] = useKept(LATER_KEY, false);
35
37
  const [step, setStep] = useKept(STEP_KEY, 1);
36
38
  const [githubDone, setGithubDone] = useKept(GITHUB_KEY, false);
@@ -41,7 +43,7 @@ export function Setup() {
41
43
  const [errorMsg, setErrorMsg] = useState(null);
42
44
  const [syncTurn, setSyncTurn] = useState(0);
43
45
  const signed = isAuthenticated && Boolean(accessToken);
44
- // Sync with remote integrations & connectors when authenticated or returning from OAuth tab/popup
46
+ // Sync with remote integrations, connectors & linked IAM accounts when authenticated or returning from OAuth tab/popup
45
47
  useEffect(() => {
46
48
  if (!signed)
47
49
  return;
@@ -54,7 +56,10 @@ export function Setup() {
54
56
  fetch(`${api()}/v1/integrations/connectors`, { headers: auth })
55
57
  .then((r) => (r.ok ? r.json() : null))
56
58
  .catch(() => null),
57
- ]).then(([integrationsData, connectorsData]) => {
59
+ fetch(`${api()}/v1/iam/linked-accounts`, { headers: auth })
60
+ .then((r) => (r.ok ? r.json() : null))
61
+ .catch(() => null),
62
+ ]).then(([integrationsData, connectorsData, linkedData]) => {
58
63
  if (!live)
59
64
  return;
60
65
  const providers = Array.isArray(integrationsData?.providers)
@@ -63,7 +68,10 @@ export function Setup() {
63
68
  const connectors = Array.isArray(connectorsData?.connectors)
64
69
  ? connectorsData.connectors
65
70
  : null;
66
- if (!providers && !connectors)
71
+ const linkedAccounts = Array.isArray(linkedData?.data)
72
+ ? linkedData.data
73
+ : null;
74
+ if (!providers && !connectors && !linkedAccounts)
67
75
  return;
68
76
  const connectedSet = new Set();
69
77
  if (providers) {
@@ -77,25 +85,24 @@ export function Setup() {
77
85
  connectedSet.add(String(c.provider));
78
86
  }
79
87
  }
88
+ if (linkedAccounts) {
89
+ for (const l of linkedAccounts) {
90
+ if (l.provider)
91
+ connectedSet.add(String(l.provider).toLowerCase());
92
+ }
93
+ }
80
94
  const hasGithub = connectedSet.has('github') || connectedSet.has('github-copilot');
81
95
  const hasSlack = connectedSet.has('slack');
82
96
  const hasGoogle = connectedSet.has('google') ||
83
97
  connectedSet.has('gmail') ||
84
98
  connectedSet.has('google-drive') ||
85
99
  connectedSet.has('google-calendar');
86
- if (providers) {
87
- setGithubDone(hasGithub);
88
- setSlackDone(hasSlack);
89
- setGoogleDone(hasGoogle);
90
- }
91
- else {
92
- if (hasGithub)
93
- setGithubDone(true);
94
- if (hasSlack)
95
- setSlackDone(true);
96
- if (hasGoogle)
97
- setGoogleDone(true);
98
- }
100
+ if (hasGithub)
101
+ setGithubDone(true);
102
+ if (hasSlack)
103
+ setSlackDone(true);
104
+ if (hasGoogle)
105
+ setGoogleDone(true);
99
106
  });
100
107
  return () => {
101
108
  live = false;
@@ -130,6 +137,58 @@ export function Setup() {
130
137
  }, [githubDone, slackDone, googleDone, step]);
131
138
  if (later && !modalOpen)
132
139
  return null;
140
+ const openOAuthPopup = (authorizeUrl, provider) => {
141
+ const popup = window.open(authorizeUrl, `hanzo-oauth-${provider}`, 'width=600,height=700');
142
+ if (!popup) {
143
+ window.open(authorizeUrl, '_blank', 'noopener,noreferrer');
144
+ }
145
+ else {
146
+ const timer = window.setInterval(() => {
147
+ if (popup.closed) {
148
+ window.clearInterval(timer);
149
+ setSyncTurn((n) => n + 1);
150
+ }
151
+ }, 1000);
152
+ }
153
+ };
154
+ const connectGoogleViaIam = async (onDone) => {
155
+ try {
156
+ const linkOrigin = here() && typeof window !== 'undefined' ? window.location.origin : api();
157
+ const returnUri = typeof window !== 'undefined' ? `${window.location.origin}/auth/callback` : 'https://hanzo.ai/auth/callback';
158
+ const linkRes = await fetch(`${linkOrigin}/v1/iam/link`, {
159
+ method: 'POST',
160
+ headers: { ...scope(), 'Content-Type': 'application/json' },
161
+ body: JSON.stringify({
162
+ provider: 'provider-google',
163
+ clientId: CLIENT,
164
+ returnUri,
165
+ }),
166
+ }).catch(() => null);
167
+ if (linkRes?.ok) {
168
+ const linkJson = (await linkRes.json().catch(() => null));
169
+ if (linkJson?.status === 'ok' && typeof linkJson.data === 'string' && linkJson.data) {
170
+ return linkJson.data;
171
+ }
172
+ if (linkJson?.msg && linkJson.msg.toLowerCase().includes('already connected')) {
173
+ onDone();
174
+ return 'done';
175
+ }
176
+ }
177
+ if (sdk && typeof sdk.getSigninUrl === 'function') {
178
+ const signinHref = await sdk.getSigninUrl({ additionalParams: { provider: 'provider-google' } });
179
+ const url = new URL(signinHref);
180
+ if (here() && typeof window !== 'undefined') {
181
+ url.protocol = window.location.protocol;
182
+ url.host = window.location.host;
183
+ }
184
+ return url.href;
185
+ }
186
+ }
187
+ catch {
188
+ // fall through
189
+ }
190
+ return null;
191
+ };
133
192
  const connectOAuthProvider = async (provider, label, onDone) => {
134
193
  if (!signed) {
135
194
  enter();
@@ -138,6 +197,15 @@ export function Setup() {
138
197
  setBusy(provider);
139
198
  setErrorMsg(null);
140
199
  try {
200
+ if (provider === 'google') {
201
+ const iamResult = await connectGoogleViaIam(onDone);
202
+ if (iamResult === 'done')
203
+ return;
204
+ if (iamResult) {
205
+ openOAuthPopup(iamResult, 'google');
206
+ return;
207
+ }
208
+ }
141
209
  const res = await fetch(`${api()}/v1/integrations/${provider}/connect`, {
142
210
  method: 'POST',
143
211
  headers: { ...scope(), 'Content-Type': 'application/json' },
@@ -160,18 +228,7 @@ export function Setup() {
160
228
  }
161
229
  const j = (await res.json());
162
230
  if (j.authorizeUrl) {
163
- const popup = window.open(j.authorizeUrl, `hanzo-oauth-${provider}`, 'width=600,height=700');
164
- if (!popup) {
165
- window.open(j.authorizeUrl, '_blank', 'noopener,noreferrer');
166
- }
167
- else {
168
- const timer = window.setInterval(() => {
169
- if (popup.closed) {
170
- window.clearInterval(timer);
171
- setSyncTurn((n) => n + 1);
172
- }
173
- }, 1000);
174
- }
231
+ openOAuthPopup(j.authorizeUrl, provider);
175
232
  }
176
233
  else if (j.connected) {
177
234
  onDone();
@@ -14,7 +14,7 @@ export interface ThinkingEffortProps {
14
14
  }
15
15
  /**
16
16
  * Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
17
- * - Subtle pill button: "Thinking effort ⌄"
17
+ * - Subtle pill button showing only the active effort level ("High ⌄")
18
18
  * - Segmented slider popover with discrete stop dots and smooth active fill
19
19
  * - Default level: "high" across all plans
20
20
  */
@@ -15,7 +15,7 @@ export const EFFORT_STEPS = [
15
15
  ];
16
16
  /**
17
17
  * Native iOS widget-style Thinking effort selector matching standard Safari mobile symmetry:
18
- * - Subtle pill button: "Thinking effort ⌄"
18
+ * - Subtle pill button showing only the active effort level ("High ⌄")
19
19
  * - Segmented slider popover with discrete stop dots and smooth active fill
20
20
  * - Default level: "high" across all plans
21
21
  */
@@ -65,7 +65,7 @@ export function ThinkingEffort({ effort = DEFAULT_EFFORT, onChange, disabled = f
65
65
  e.preventDefault();
66
66
  setOpen(true);
67
67
  }
68
- }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t('Thinking effort') }), _jsx(ChevronDown, { size: 12, color: "var(--soft, var(--muted-foreground))", "aria-hidden": true })] }) }), _jsx(PopoverContent, { solid: true, align: "end", p: "$3", width: 260, minW: 260, maxW: 260, items: "stretch", rounded: "$4", bg: "var(--pane-fill, var(--surface-card))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-15))", boxShadow: "var(--shadow-sheet-1)", backdropFilter: "var(--pane-blur, blur(24px) saturate(190%))", children: _jsxs(YStack, { gap: "$3", width: "100%", minW: 234, maxW: 234, self: "stretch", "data-slot": "thinking-effort-card", role: "dialog", "aria-label": t('Thinking effort'), children: [_jsxs(XStack, { items: "center", justify: "center", gap: "$1", cursor: "pointer", onClick: () => {
68
+ }, children: [_jsx(Text, { fontSize: "$2", fontWeight: "500", color: "$ink", children: t(current.label) }), _jsx(ChevronDown, { size: 12, color: "var(--soft, var(--muted-foreground))", "aria-hidden": true })] }) }), _jsx(PopoverContent, { solid: true, align: "end", p: "$3", width: 260, minW: 260, maxW: 260, items: "stretch", rounded: "$4", bg: "var(--pane-fill, var(--surface-card))", borderWidth: 1, borderColor: "var(--pane-edge, var(--white-15))", boxShadow: "var(--shadow-sheet-1)", backdropFilter: "var(--pane-blur, blur(24px) saturate(190%))", children: _jsxs(YStack, { gap: "$3", width: "100%", minW: 234, maxW: 234, self: "stretch", "data-slot": "thinking-effort-card", role: "dialog", "aria-label": t('Thinking effort'), children: [_jsxs(XStack, { items: "center", justify: "center", gap: "$1", cursor: "pointer", onClick: () => {
69
69
  if (disabled)
70
70
  return;
71
71
  const next = EFFORT_STEPS[(activeIndex + 1) % EFFORT_STEPS.length];
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
7
7
  import { DEFAULT_EFFORT, EFFORT_STEPS } from '../ThinkingEffort.js';
8
8
  const STORAGE_KEY = 'hanzo.chat.preferences';
9
9
  const EVENT_NAME = 'hanzo:chat:preferences';
10
- const EFFORT_SCHEMA_VERSION = 2;
10
+ const EFFORT_SCHEMA_VERSION = 3;
11
11
  const DEFAULT_PREFERENCES = {
12
12
  showModelSelector: false,
13
13
  allowThirdPartyModels: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/app",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",