@hanzo/app 0.2.60 → 0.2.62
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 +7 -13
- package/dist/Orgs.js +11 -21
- package/dist/Usage.js +3 -3
- package/dist/lib/session.d.ts +3 -5
- package/dist/lib/session.js +3 -6
- package/package.json +3 -3
package/dist/Chat.js
CHANGED
|
@@ -27,7 +27,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
27
27
|
// branch is gone. If the gateway refuses an anonymous free turn, that answer
|
|
28
28
|
// belongs in the thread where the reader can see it, not in a caption that
|
|
29
29
|
// pre-emptively refuses on the gateway's behalf.
|
|
30
|
-
import { useCallback,
|
|
30
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
31
31
|
import { isolate, phrase } from "@hanzo/i18n";
|
|
32
32
|
import { useI18n } from "@hanzo/i18n/react";
|
|
33
33
|
import { billed, detail, familyOf, planRequired, plainly, refused } from "./failure.js";
|
|
@@ -60,7 +60,7 @@ import { refused as worded, speech, useDictation, useTalk, useVoice } from "@han
|
|
|
60
60
|
import { Check, Clock, FileText, Ghost, Image as ImageMark, Library as LibraryMark, Paperclip, Sparkles, X } from "lucide-react";
|
|
61
61
|
import { FREE, ENSO } from "./lib/ai.js";
|
|
62
62
|
import { openThread, useOpen } from "./open.js";
|
|
63
|
-
import { Beside
|
|
63
|
+
import { Beside } from "./Shell.js";
|
|
64
64
|
import { SEED, look, useSections, useSites } from "./RightPane.js";
|
|
65
65
|
import { Share } from "./Share.js";
|
|
66
66
|
import { ConversationMenu, ThreadMore, useThreadList } from "./thread.js";
|
|
@@ -513,8 +513,6 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
513
513
|
// never resets Dev's.
|
|
514
514
|
const [chatPrefs, setChatPrefs] = useChatPreferences();
|
|
515
515
|
const ai = useAi();
|
|
516
|
-
// In the app's frame the composer floats on the pane as a pane of its own.
|
|
517
|
-
const framed = useContext(Framed);
|
|
518
516
|
const opened = useOpen();
|
|
519
517
|
const { thread: open, open: reopen, agents: room, openAgent, seat, emptied, aside, showAside, showSettings } = opened;
|
|
520
518
|
// What the conversation carries beside its words (@hanzo/build `useCarry`):
|
|
@@ -1402,9 +1400,11 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1402
1400
|
// (the defaults @hanzo/ui and @hanzo/build each call ASK), said here so both are the reader's.
|
|
1403
1401
|
label: t("Ask anything"),
|
|
1404
1402
|
placeholder: t("Type / for skills"),
|
|
1405
|
-
// At the thread's measure
|
|
1403
|
+
// At the thread's measure.
|
|
1406
1404
|
column: true,
|
|
1407
|
-
|
|
1405
|
+
// Private: the frame drops its ground and dashes its edge (@hanzo/ui ≥ 8.29.40); the
|
|
1406
|
+
// toggled ghost in the head and this frame are the whole of what says it.
|
|
1407
|
+
forgetful,
|
|
1408
1408
|
// A file or an image pasted into the field is held like a picked one;
|
|
1409
1409
|
// words paste as words.
|
|
1410
1410
|
field: {
|
|
@@ -1484,13 +1484,7 @@ function Thread({ placeholder = message(), initial, anonymous = false, heading,
|
|
|
1484
1484
|
onLanguage: speakIn,
|
|
1485
1485
|
talk,
|
|
1486
1486
|
// While nothing has been said: what is worth doing next.
|
|
1487
|
-
starters: said.length === 0
|
|
1488
|
-
? forgetful
|
|
1489
|
-
? (_jsxs(XStack, { items: "center", justify: "center", gap: "$2", py: "$2", px: "$3", rounded: "$3", bg: "var(--white-05)", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Ghost, { size: 14, strokeWidth: 1.75, color: "var(--primary)" }), _jsx(Text, { fontSize: "$2", color: "$soft", children: t("Private chat is active. Messages are temporary and won't be saved.") })] }))
|
|
1490
|
-
: !anonymous
|
|
1491
|
-
? _jsx(Suggestions, { rows: hints.rows, onAct: hint, onDismiss: hints.dismiss })
|
|
1492
|
-
: undefined
|
|
1493
|
-
: undefined,
|
|
1487
|
+
starters: said.length === 0 && !anonymous && !forgetful ? _jsx(Suggestions, { rows: hints.rows, onAct: hint, onDismiss: hints.dismiss }) : undefined,
|
|
1494
1488
|
};
|
|
1495
1489
|
return (_jsxs(YStack, { flex: 1, minH: 0, width: "100%", position: "relative", "data-slot": "chat-room",
|
|
1496
1490
|
// A LINK IN AN ANSWER OPENS IN A TAB beside the conversation when the tab
|
package/dist/Orgs.js
CHANGED
|
@@ -44,7 +44,7 @@ import { useHost } from './lib/hostname.js';
|
|
|
44
44
|
import { useHydrated } from './lib/hydrated.js';
|
|
45
45
|
import { api } from './lib/api.js';
|
|
46
46
|
import { usePersonal, useTier } from './lib/tier.js';
|
|
47
|
-
import { CHOOSE, ORG,
|
|
47
|
+
import { CHOOSE, ORG, assumed, bearer, hasSession, org, orgs as claimed, pick, renew, role, scope, superAdmin, support } from './lib/session.js';
|
|
48
48
|
import { matches, refusal, slugify } from './lib/orgname.js';
|
|
49
49
|
import { team as workspace } from './lib/host.js';
|
|
50
50
|
import { checkoutUrl, money } from './lib/pay.js';
|
|
@@ -86,7 +86,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
86
86
|
window.removeEventListener('storage', on);
|
|
87
87
|
};
|
|
88
88
|
}, [accessToken]);
|
|
89
|
-
const [picked, setPicked] = useState(false);
|
|
90
89
|
// The team being set up in this page. Once its name is taken the setup owns
|
|
91
90
|
// the screen until checkout, whatever `Orgs` reads of the new organization.
|
|
92
91
|
const [founding, setFounding] = useState(null);
|
|
@@ -107,14 +106,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
107
106
|
const supporting = Boolean(current) && assumed() === current;
|
|
108
107
|
const open = !asks || live || supporting;
|
|
109
108
|
const { client } = useAi();
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
try {
|
|
112
|
-
setPicked(Boolean(localStorage.getItem(PICKED)));
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
setPicked(true);
|
|
116
|
-
}
|
|
117
|
-
}, [accessToken]);
|
|
118
109
|
// Back from checkout: the plan may be live now.
|
|
119
110
|
useEffect(() => {
|
|
120
111
|
const back = () => {
|
|
@@ -137,7 +128,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
137
128
|
}, []);
|
|
138
129
|
const choose = useCallback((o) => {
|
|
139
130
|
pick(o);
|
|
140
|
-
setPicked(true);
|
|
141
131
|
setChoosing(false);
|
|
142
132
|
}, []);
|
|
143
133
|
// The organization a link arrives for. hanzo.ai opens the workspace at
|
|
@@ -156,11 +146,6 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
156
146
|
if (members.includes(asked))
|
|
157
147
|
choose(asked);
|
|
158
148
|
}, [door, hydrated, isLoading, isAuthenticated, members, choose]);
|
|
159
|
-
// One organization is not a choice.
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
if (members.length === 1 && !picked)
|
|
162
|
-
choose(members[0]);
|
|
163
|
-
}, [members, picked, choose]);
|
|
164
149
|
// The template chosen at creation, set up once the organization opens.
|
|
165
150
|
useEffect(() => {
|
|
166
151
|
if (!open || !client)
|
|
@@ -214,11 +199,17 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
214
199
|
return _jsx(Landing, { member: true });
|
|
215
200
|
return door ? _jsx(Start, { onFounded: setFounding, first: true }) : _jsx(Create, {});
|
|
216
201
|
}
|
|
217
|
-
|
|
202
|
+
// The organization this browser works in is the choice (session.ts `org`: the
|
|
203
|
+
// SDK's selection when the token names it, else the person's only one). Only a
|
|
204
|
+
// browser working in none of the person's is asked, so a sign-in goes straight
|
|
205
|
+
// to the room in the organization the person last worked in, and the account
|
|
206
|
+
// menu switches it (`choosing`).
|
|
207
|
+
if (!current)
|
|
218
208
|
return _jsx(Pick, { members: members, current: current, onPick: choose });
|
|
219
|
-
// Asked for over an open room, the room keeps its place under the chooser and closing it goes back
|
|
209
|
+
// Asked for over an open room, the room keeps its place under the chooser and closing it goes back;
|
|
210
|
+
// asked for from a plan's page (`swap`), the chooser stands alone, since that room is not open.
|
|
220
211
|
if (choosing)
|
|
221
|
-
return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Pick, { members: members, current: current, onPick: choose, onClose: () => setChoosing(false) })] });
|
|
212
|
+
return _jsxs(_Fragment, { children: [open ? _jsx(Held, { veiled: true, children: children }) : null, _jsx(Pick, { members: members, current: current, onPick: choose, onClose: () => setChoosing(false) })] });
|
|
222
213
|
if (open)
|
|
223
214
|
return forward ? _jsx(Forward, { to: forward }) : _jsx(_Fragment, { children: _jsx(Held, { veiled: false, children: children }) });
|
|
224
215
|
// IN THE WORKSPACE NOTHING OPENS WITHOUT A LIVE PLAN. Every branch here
|
|
@@ -231,7 +222,7 @@ export function Orgs({ children, front = false, forward, signup = false, }) {
|
|
|
231
222
|
return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Veil, {})] });
|
|
232
223
|
if (free && personal === null)
|
|
233
224
|
return _jsxs(_Fragment, { children: [_jsx(Held, { veiled: true, children: children }), _jsx(Veil, {})] });
|
|
234
|
-
const swap = () =>
|
|
225
|
+
const swap = () => setChoosing(true);
|
|
235
226
|
if (door) {
|
|
236
227
|
// A billing OUTAGE is ours; the plan is still the condition.
|
|
237
228
|
if (!tier)
|
|
@@ -450,7 +441,6 @@ function CreateDialog({ onClose }) {
|
|
|
450
441
|
try {
|
|
451
442
|
if (template)
|
|
452
443
|
localStorage.setItem(SETUP, template);
|
|
453
|
-
localStorage.setItem(PICKED, '1');
|
|
454
444
|
}
|
|
455
445
|
catch {
|
|
456
446
|
/* the next load re-derives both */
|
package/dist/Usage.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState, useSyncExternalStore } from 'react';
|
|
4
4
|
import { useI18n } from '@hanzo/i18n/react';
|
|
5
|
-
import {
|
|
6
|
-
import { Anchor, Button, Popover, PopoverContent, PopoverTrigger, Progress, Text, XStack, YStack } from '@hanzo/ui';
|
|
5
|
+
import { ArrowUpRight } from 'lucide-react';
|
|
6
|
+
import { Anchor, Button, Popover, PopoverContent, PopoverTrigger, Progress, SizableText, Text, XStack, YStack } from '@hanzo/ui';
|
|
7
7
|
import { ComposerStatusProvider } from '@hanzo/ui/chat';
|
|
8
8
|
import { UsageMeter } from '@hanzo/ui/product/UsageMeter';
|
|
9
9
|
import { label } from '@hanzo/build/plan';
|
|
@@ -87,7 +87,7 @@ export function UsageControl({ context, read }) {
|
|
|
87
87
|
const toggle = (on) => { setOpen(on); if (on && read)
|
|
88
88
|
read.reload(); };
|
|
89
89
|
const metric = (name, n) => _jsxs(XStack, { justify: "space-between", gap: "$3", children: [_jsx(Text, { fontSize: "$2", color: "$soft", children: name }), _jsx(Text, { fontSize: "$2", color: "$ink", fontVariant: ['tabular-nums'], children: integer(n) })] }, name);
|
|
90
|
-
return (_jsxs(Popover, { open: open, onOpenChange: toggle, placement: "top-end", children: [_jsx(PopoverTrigger, { asChild: true, children:
|
|
90
|
+
return (_jsxs(Popover, { open: open, onOpenChange: toggle, placement: "top-end", children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(XStack, { render: "button", type: 'button', items: "center", height: 28, px: 5, rounded: 8, bg: "transparent", hoverStyle: { bg: '$hover' }, transition: "quickest", cursor: "pointer", "$max-sm": { height: 36 }, "aria-label": t('Context, tokens and plan usage'), "data-slot": "composer-usage", children: _jsx(SizableText, { size: "$3", color: highest !== null && highest >= 95 ? '$bad' : '$soft', children: percent !== null ? `${percent}%` : highest !== null ? `${Math.round(highest)}%` : t('Usage') }) }) }), _jsx(PopoverContent, { solid: true, width: 360, maxW: "calc(100vw - 24px)", maxH: "min(680px, calc(100dvh - 100px))", overflowY: "auto", "aria-label": t('Context, tokens and plan usage'), "data-slot": "composer-usage-panel", children: _jsxs(YStack, { gap: "$4", minW: 0, children: [_jsxs(XStack, { justify: "space-between", items: "center", gap: "$3", children: [_jsx(Text, { fontSize: "$3", fontWeight: "600", color: "$ink", children: t('Usage') }), _jsxs(Button, { type: "button", size: "sm", variant: "link", onClick: () => { setOpen(false); showSettings('usage'); }, "data-slot": "composer-see-usage", children: [t('See all usage'), " ", _jsx(ArrowUpRight, { size: 13 })] })] }), context && estimate ? (_jsxs(YStack, { gap: "$2", "data-slot": "composer-context", children: [_jsxs(XStack, { justify: "space-between", gap: "$2", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", children: t('Context · estimated') }), _jsx(Text, { fontSize: "$1", color: "$soft", children: capacity ? t('{used} / {max} tokens', { used: integer(estimate.total), max: integer(capacity) }) : t('{used} tokens', { used: integer(estimate.total) }) })] }), percent !== null ? _jsx(Progress, { value: Math.min(100, percent), height: 5, "aria-label": t('Estimated context used'), indicatorColor: percent >= 90 ? '$bad' : '$good' }) : null, estimate.rows.filter((r) => r.tokens > 0).map((r) => metric(t(r.name), r.tokens)), _jsx(Text, { fontSize: "$1", color: "$soft", children: t('Text estimate; model tokenization and attachments can change the total.') }), !capacity ? _jsx(Text, { fontSize: "$1", color: "$soft", children: t('This model does not report a context capacity.') }) : null] })) : null, _jsxs(YStack, { gap: "$2", "data-slot": "composer-reported-tokens", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", children: t('Last response · reported tokens') }), tokens ? _jsxs(_Fragment, { children: [metric(t('Input'), tokens.input), metric(t('Output'), tokens.output), tokens.cached !== undefined ? metric(t('Cached input'), tokens.cached) : null, tokens.reasoning !== undefined ? metric(t('Reasoning'), tokens.reasoning) : null, metric(t('Total'), tokens.total)] }) : _jsx(Text, { fontSize: "$2", color: "$soft", children: t('No token counts reported for this conversation yet. See all usage for account totals.') })] }), _jsxs(YStack, { gap: "$2", "data-slot": "composer-account-usage", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", children: t('Account · last 30 days') }), aggregate?.data ? _jsxs(_Fragment, { children: [metric(t('Tokens'), aggregate.data.totals.tokens), metric(t('Input'), aggregate.data.totals.promptTokens), metric(t('Output'), aggregate.data.totals.completionTokens), metric(t('Requests'), aggregate.data.totals.requests)] }) : _jsx(Text, { fontSize: "$2", color: "$soft", children: aggregate?.error ?? t('Reading account usage…') })] }), _jsxs(YStack, { gap: "$2", "data-slot": "composer-plan-usage", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", children: title }), limits ? _jsx(UsageMeter, { limits: limits, size: "sm" }) : _jsx(Text, { fontSize: "$2", color: "$soft", children: t(answered ? 'Plan usage is unavailable. Try again.' : 'Reading plan usage…') }), answered && !limits ? _jsx(Button, { type: "button", size: "sm", variant: "link", onClick: usage.reload, children: t('Retry') }) : null] }), _jsxs(XStack, { gap: "$3", justify: "space-between", flexWrap: "wrap", children: [_jsx(Button, { asChild: true, size: "sm", children: _jsx(Anchor, { href: payPage('/cart'), "data-slot": "composer-upgrade", children: t('Upgrade plan') }) }), _jsx(Button, { asChild: true, size: "sm", variant: "outline", children: _jsx(Anchor, { href: payPage('/amount/card'), "data-slot": "composer-buy-credits", children: t('Buy credits') }) })] })] }) })] }));
|
|
91
91
|
}
|
|
92
92
|
/** Every shared composer in the app gets the same account usage entry. */
|
|
93
93
|
export function UsageProvider({ children }) {
|
package/dist/lib/session.d.ts
CHANGED
|
@@ -182,12 +182,10 @@ export declare function scope(): Record<string, string>;
|
|
|
182
182
|
export declare function renew(): void;
|
|
183
183
|
/** Fired on `window` when the organization this browser works in changes. */
|
|
184
184
|
export declare const ORG = "hanzo:org";
|
|
185
|
-
/** This person picked an organization in this browser. `own()` clears it with the person. */
|
|
186
|
-
export declare const PICKED = "hanzo:org:picked";
|
|
187
185
|
/**
|
|
188
|
-
* Work in this organization from now on: the SDK's selection,
|
|
189
|
-
*
|
|
190
|
-
*
|
|
186
|
+
* Work in this organization from now on: the SDK's selection, announced. A choice
|
|
187
|
+
* made anywhere (the shell's gate, the app's account menu) is the one `org()`
|
|
188
|
+
* answers, so the gate does not ask for it again.
|
|
191
189
|
*/
|
|
192
190
|
export declare function pick(o: string): void;
|
|
193
191
|
/** Fired on `window` to open the organization chooser over the room. */
|
package/dist/lib/session.js
CHANGED
|
@@ -453,17 +453,14 @@ export function renew() {
|
|
|
453
453
|
}
|
|
454
454
|
/** Fired on `window` when the organization this browser works in changes. */
|
|
455
455
|
export const ORG = 'hanzo:org';
|
|
456
|
-
/** This person picked an organization in this browser. `own()` clears it with the person. */
|
|
457
|
-
export const PICKED = 'hanzo:org:picked';
|
|
458
456
|
/**
|
|
459
|
-
* Work in this organization from now on: the SDK's selection,
|
|
460
|
-
*
|
|
461
|
-
*
|
|
457
|
+
* Work in this organization from now on: the SDK's selection, announced. A choice
|
|
458
|
+
* made anywhere (the shell's gate, the app's account menu) is the one `org()`
|
|
459
|
+
* answers, so the gate does not ask for it again.
|
|
462
460
|
*/
|
|
463
461
|
export function pick(o) {
|
|
464
462
|
try {
|
|
465
463
|
window.localStorage.setItem(`${PREFIX}current_org`, o);
|
|
466
|
-
window.localStorage.setItem(PICKED, '1');
|
|
467
464
|
}
|
|
468
465
|
catch {
|
|
469
466
|
/* the choice lives only in this page */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.62",
|
|
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",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@hanzo/logo": ">=1.0.26",
|
|
61
61
|
"@hanzo/studio": ">=0.1.0",
|
|
62
62
|
"@hanzo/tabs": ">=0.1.8",
|
|
63
|
-
"@hanzo/ui": ">=8.29.
|
|
63
|
+
"@hanzo/ui": ">=8.29.40",
|
|
64
64
|
"@hanzo/usage": ">=0.1.18",
|
|
65
65
|
"@hanzo/voice": ">=0.1.16",
|
|
66
66
|
"@hanzogui/shell": "^8.3.20",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@hanzo/logo": "1.0.26",
|
|
82
82
|
"@hanzo/studio": "0.1.0",
|
|
83
83
|
"@hanzo/tabs": "github:hanzo-inc/tabs",
|
|
84
|
-
"@hanzo/ui": "8.29.
|
|
84
|
+
"@hanzo/ui": "8.29.40",
|
|
85
85
|
"@hanzo/usage": "0.1.18",
|
|
86
86
|
"@hanzo/voice": "0.1.19",
|
|
87
87
|
"@hanzogui/config": "8.3.5",
|