@hanzo/app 0.3.53 → 0.3.55
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/Gate.js +1 -1
- package/dist/Home.js +16 -7
- package/dist/Shell.js +8 -2
- package/dist/Talk.js +1 -1
- package/dist/Work.js +15 -0
- package/dist/failed.d.ts +12 -0
- package/dist/failed.js +28 -0
- package/dist/half.d.ts +8 -0
- package/dist/half.js +14 -0
- package/dist/lib/api.js +6 -6
- package/dist/lib/betas.js +5 -1
- package/dist/lib/host.d.ts +14 -15
- package/dist/lib/host.js +20 -21
- package/dist/lib/oauth.d.ts +2 -2
- package/dist/lib/oauth.js +2 -2
- package/dist/lib/pay.d.ts +1 -1
- package/dist/lib/pay.js +1 -1
- package/dist/members.d.ts +35 -0
- package/dist/members.js +22 -0
- package/dist/roster.d.ts +7 -14
- package/dist/roster.js +18 -30
- package/dist/watch.d.ts +6 -0
- package/dist/watch.js +20 -0
- package/package.json +1 -1
package/dist/Gate.js
CHANGED
|
@@ -61,7 +61,7 @@ import { site, where } from './where.js';
|
|
|
61
61
|
const SETUP = 'hanzo:org:template';
|
|
62
62
|
/** Checkout for a plan, coming back to this page. */
|
|
63
63
|
function checkout(plan) {
|
|
64
|
-
const origin = typeof window !== 'undefined' ? window.location.origin : 'https://hanzo.
|
|
64
|
+
const origin = typeof window !== 'undefined' ? window.location.origin : 'https://hanzo.app';
|
|
65
65
|
const path = typeof window !== 'undefined' ? window.location.pathname : '/chat';
|
|
66
66
|
return checkoutUrl(plan.id, `${origin}${path}`);
|
|
67
67
|
}
|
package/dist/Home.js
CHANGED
|
@@ -30,6 +30,8 @@ import { useAi } from './lib/ai.js';
|
|
|
30
30
|
import { useHydrated } from './lib/hydrated.js';
|
|
31
31
|
import { useOpen } from './open.js';
|
|
32
32
|
import { plainly, say } from './failure.js';
|
|
33
|
+
import { failed } from './failed.js';
|
|
34
|
+
import { watch } from './watch.js';
|
|
33
35
|
import { Directory } from './Directory.js';
|
|
34
36
|
import { Bar } from './progress.js';
|
|
35
37
|
import { Card, Go, INK, Quiet, Row, SOFT, CHOSEN } from './card.js';
|
|
@@ -249,7 +251,7 @@ function Chats() {
|
|
|
249
251
|
*/
|
|
250
252
|
function Next({ onConnect }) {
|
|
251
253
|
const { t } = useI18n();
|
|
252
|
-
const { sessions } = useSessions({ limit: 100 });
|
|
254
|
+
const { sessions, error: unread, reload } = useSessions({ limit: 100 });
|
|
253
255
|
const { agents } = useAgents();
|
|
254
256
|
const { held } = useProjects();
|
|
255
257
|
const { held: connected } = useApps();
|
|
@@ -258,18 +260,25 @@ function Next({ onConnect }) {
|
|
|
258
260
|
const running = useMemo(() => safeSessions.filter((s) => s && s.status === 'running'), [safeSessions]);
|
|
259
261
|
const rows = useMemo(() => {
|
|
260
262
|
const out = [];
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
// The past 7 days' failures, a tree counted once (./failed): counting every
|
|
264
|
+
// error in the last 100 runs kept old failures on the card indefinitely. The
|
|
265
|
+
// row opens the newest of them on the Work board (./watch), not the board
|
|
266
|
+
// alone. A read that failed is not "nothing failed": it says so, and
|
|
267
|
+
// pressing the row reads the runs again.
|
|
268
|
+
const failing = failed(safeSessions);
|
|
269
|
+
if (unread)
|
|
270
|
+
out.push({ key: 'failed', say: say(unread, t('your runs'), 'read', t), press: reload });
|
|
271
|
+
else if (failing.length)
|
|
272
|
+
out.push({ key: 'failed', say: t('{n} failed in the past 7 days', { n: failing.length }), href: watch(failing[0].id) });
|
|
264
273
|
if (safeAgents.length === 0)
|
|
265
274
|
out.push({ key: 'agent', say: t('Hire your first agent'), href: '/work' });
|
|
266
275
|
if (held?.length === 0)
|
|
267
276
|
out.push({ key: 'ship', say: t('Ship your first project'), href: dev() });
|
|
268
277
|
if (connected && Array.isArray(connected) && !connected.some((a) => a?.connected))
|
|
269
|
-
out.push({ key: 'connect', say: t('Connect an app'), press:
|
|
278
|
+
out.push({ key: 'connect', say: t('Connect an app'), press: onConnect });
|
|
270
279
|
return out;
|
|
271
|
-
}, [safeSessions, safeAgents, held, connected, t]);
|
|
272
|
-
return (_jsxs(Card, { kind: "next", icon: _jsx(Bot, { size: 14, "aria-hidden": true }), title: t('Next'), children: [running.length ? (_jsx(YStack, { gap: "$2", children: running.slice(0, 2).map((s) => (_jsxs(YStack, { gap: "$1", children: [_jsx(Row, { href: "/work", children: s.title || s.agent || t('Run') }), _jsx(Bar, { run: s, label: false })] }, s.id))) })) : null, rows.length === 0 && running.length === 0 ? (_jsx(Quiet, { children: t('Nothing needs you.') })) : (_jsx(YStack, { gap: "$1", children: rows.slice(0, 3).map((r) => (_jsx(Row, { href: r.href, onPress: r.press
|
|
280
|
+
}, [safeSessions, unread, reload, safeAgents, held, connected, onConnect, t]);
|
|
281
|
+
return (_jsxs(Card, { kind: "next", icon: _jsx(Bot, { size: 14, "aria-hidden": true }), title: t('Next'), children: [running.length ? (_jsx(YStack, { gap: "$2", children: running.slice(0, 2).map((s) => (_jsxs(YStack, { gap: "$1", children: [_jsx(Row, { href: "/work", children: s.title || s.agent || t('Run') }), _jsx(Bar, { run: s, label: false })] }, s.id))) })) : null, rows.length === 0 && running.length === 0 ? (_jsx(Quiet, { children: t('Nothing needs you.') })) : (_jsx(YStack, { gap: "$1", children: rows.slice(0, 3).map((r) => (_jsx(Row, { href: r.href, onPress: r.press, children: r.say }, r.key))) }))] }));
|
|
273
282
|
}
|
|
274
283
|
/**
|
|
275
284
|
* The apps the org has connected.
|
package/dist/Shell.js
CHANGED
|
@@ -74,6 +74,7 @@ const HOME_INDICATOR = "env(safe-area-inset-bottom)";
|
|
|
74
74
|
import { invite } from "./lib/home.js";
|
|
75
75
|
import { reach } from "./lib/reach.js";
|
|
76
76
|
import { say } from "./failure.js";
|
|
77
|
+
import { half } from "./half.js";
|
|
77
78
|
import { Face } from "./cast.js";
|
|
78
79
|
import { useStarred, titleOf } from "./stars.js";
|
|
79
80
|
import { channelName } from "./network.js";
|
|
@@ -814,8 +815,13 @@ function Bots({ show, owner, filter = "", onPick, navigate, }) {
|
|
|
814
815
|
folk = [...folk].sort((a, b) => (a.displayName || a.name).localeCompare(b.displayName || b.name));
|
|
815
816
|
}
|
|
816
817
|
const empty = folk.length + shown.length === 0;
|
|
817
|
-
|
|
818
|
-
|
|
818
|
+
// Each half answers for its own read. IAM refuses the people read to a member
|
|
819
|
+
// who is not an org admin, so reporting either read's failure put "cannot open
|
|
820
|
+
// this org's roster" over agents that had loaded (half.ts).
|
|
821
|
+
const { loading: waiting, error: broke } = half(show, {
|
|
822
|
+
agents: { loading: agentsLoading, error: agentsWrong },
|
|
823
|
+
people: { loading: peopleLoading, error: peopleWrong },
|
|
824
|
+
});
|
|
819
825
|
const pick = async (file) => {
|
|
820
826
|
if (!file)
|
|
821
827
|
return;
|
package/dist/Talk.js
CHANGED
|
@@ -51,7 +51,7 @@ const mention = (draft, name) => `${draft && !/\s$/.test(draft) ? `${draft} ` :
|
|
|
51
51
|
export function Talk({ channel }) {
|
|
52
52
|
const { t, dir, locale } = useI18n();
|
|
53
53
|
const { messages, failed, send } = useMessages(channel.id, channel.space);
|
|
54
|
-
const { members, wrong } = useRoster();
|
|
54
|
+
const { members, wrong } = useRoster(channel.space);
|
|
55
55
|
const me = useMe();
|
|
56
56
|
const { aside, showAside } = useOpen();
|
|
57
57
|
const [draft, setDraft] = useState('');
|
package/dist/Work.js
CHANGED
|
@@ -15,6 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
16
16
|
import { useAi, useSession, useSessions } from '@hanzo/ai/react';
|
|
17
17
|
import { useOpen } from './open.js';
|
|
18
|
+
import { asked, KEY } from './watch.js';
|
|
18
19
|
import { AgentBoard, ChannelHeader, Pane, ProgressBlock, Steer, steps, } from '@hanzo/ui/agents';
|
|
19
20
|
import { Text, XStack, YStack } from '@hanzo/ui';
|
|
20
21
|
import { useIam } from '@hanzo/iam/react';
|
|
@@ -88,6 +89,20 @@ function Watching({ idle }) {
|
|
|
88
89
|
// and the list is re-read when the id changes so the new row is there to open.
|
|
89
90
|
const { session: open, openSession: setOpen } = useOpen();
|
|
90
91
|
const [trees, setTrees] = useState({});
|
|
92
|
+
// A run the address names opens on arrival: Home's "{n} failed" sends
|
|
93
|
+
// /work?session=<id> (./watch). The param is then dropped, the way Chat drops
|
|
94
|
+
// `?thread=`, so the address is the board's own again and a reload does not
|
|
95
|
+
// reopen a run the reader has moved on from.
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const url = new URL(window.location.href);
|
|
98
|
+
if (!url.searchParams.has(KEY))
|
|
99
|
+
return;
|
|
100
|
+
const id = asked(url.search);
|
|
101
|
+
url.searchParams.delete(KEY);
|
|
102
|
+
window.history.replaceState(null, '', `${url.pathname}${url.search}${url.hash}`);
|
|
103
|
+
if (id)
|
|
104
|
+
setOpen(id);
|
|
105
|
+
}, [setOpen]);
|
|
91
106
|
useEffect(() => {
|
|
92
107
|
if (open)
|
|
93
108
|
reload();
|
package/dist/failed.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Session } from '@hanzo/ai';
|
|
2
|
+
/** How long a failure stays on the card: the Recents menu's "Past 7 days". */
|
|
3
|
+
export declare const FRESH: number;
|
|
4
|
+
/**
|
|
5
|
+
* The failed runs worth the card, newest first.
|
|
6
|
+
*
|
|
7
|
+
* Only a tree's root counts: a sub-run that failed under a root is the root's
|
|
8
|
+
* business, and a root that failed is one failure however many of its sub-runs
|
|
9
|
+
* failed with it. A run with no time on it is left out, since nothing says it
|
|
10
|
+
* is recent.
|
|
11
|
+
*/
|
|
12
|
+
export declare function failed(sessions: readonly (Session | null | undefined)[], now?: number): Session[];
|
package/dist/failed.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The runs Home's Next card says failed: the ones that are still news. No React,
|
|
2
|
+
// so a spec reads it as it is.
|
|
3
|
+
//
|
|
4
|
+
// The card counted every run marked `error` among the org's last 100, with no
|
|
5
|
+
// window and a fan-out's sub-runs each counted on their own, so a failure stayed
|
|
6
|
+
// on the card ("14 failed", hanzo-inc/app issue 202) until a hundred newer runs pushed
|
|
7
|
+
// it off the page, however long ago it happened. A failure is news for the same
|
|
8
|
+
// 7 days the Recents menu calls "Past 7 days", and a tree is one run.
|
|
9
|
+
/** How long a failure stays on the card: the Recents menu's "Past 7 days". */
|
|
10
|
+
export const FRESH = 7 * 86_400_000;
|
|
11
|
+
/** When a run stopped: its end, else its last activity, else its start. */
|
|
12
|
+
const when = (s) => Date.parse(s.endedAt || s.updatedAt || s.createdAt || '');
|
|
13
|
+
/** The top of a tree: no parent, and the root it names, if any, is itself. */
|
|
14
|
+
const top = (s) => !s.parentSessionId && (!s.rootSessionId || s.rootSessionId === s.id);
|
|
15
|
+
/**
|
|
16
|
+
* The failed runs worth the card, newest first.
|
|
17
|
+
*
|
|
18
|
+
* Only a tree's root counts: a sub-run that failed under a root is the root's
|
|
19
|
+
* business, and a root that failed is one failure however many of its sub-runs
|
|
20
|
+
* failed with it. A run with no time on it is left out, since nothing says it
|
|
21
|
+
* is recent.
|
|
22
|
+
*/
|
|
23
|
+
export function failed(sessions, now = Date.now()) {
|
|
24
|
+
return sessions
|
|
25
|
+
.filter((s) => !!s && s.status === 'error' && top(s))
|
|
26
|
+
.filter((s) => now - when(s) <= FRESH)
|
|
27
|
+
.sort((a, b) => when(b) - when(a));
|
|
28
|
+
}
|
package/dist/half.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type Half = 'agents' | 'people';
|
|
2
|
+
/** One read's state, as `useAgents` and `usePeople` answer it. */
|
|
3
|
+
export interface Read {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}
|
|
7
|
+
/** The read the half `show` draws: the only one whose wait and failure it reports. */
|
|
8
|
+
export declare const half: (show: Half, reads: Record<Half, Read>) => Read;
|
package/dist/half.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Which read a half of the sidebar's roster answers for.
|
|
2
|
+
//
|
|
3
|
+
// The sidebar draws the roster as two halves, the org's people and its agents,
|
|
4
|
+
// from two reads that fail apart: the agents from `/v1/agents`, the people from
|
|
5
|
+
// IAM's SCIM directory. IAM lists an org's people to an org admin only (403
|
|
6
|
+
// "listing users requires org-admin"), so for an ordinary member the people read
|
|
7
|
+
// fails every time while the agents read answers.
|
|
8
|
+
//
|
|
9
|
+
// hanzo.bot/bots draws the agents half alone. It used to report whichever read
|
|
10
|
+
// had failed, so every member who is not an org admin read "This account cannot
|
|
11
|
+
// open this org's roster." over agents that had loaded (hanzo-inc/app issue 199).
|
|
12
|
+
// A half reports its own read and no other: its own wait, its own failure.
|
|
13
|
+
/** The read the half `show` draws: the only one whose wait and failure it reports. */
|
|
14
|
+
export const half = (show, reads) => reads[show];
|
package/dist/lib/api.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* production address was frozen into the bundle before a browser could say
|
|
20
20
|
* where it was. Called at request time it answers for the page that is open.
|
|
21
21
|
*/
|
|
22
|
-
import { devnet, guest, team } from './host.js';
|
|
22
|
+
import { apex, devnet, guest, team } from './host.js';
|
|
23
23
|
import { where } from '../where.js';
|
|
24
24
|
/**
|
|
25
25
|
* The devnet's gateway and identity. A page on a devnet host (`devnet()` in
|
|
@@ -41,11 +41,11 @@ export function api() {
|
|
|
41
41
|
return set.replace(/\/+$/, '');
|
|
42
42
|
if (typeof window !== 'undefined') {
|
|
43
43
|
const host = window.location.hostname;
|
|
44
|
-
// The shipped
|
|
45
|
-
// there the absolute address stands and no proxy is involved. hanzo.
|
|
46
|
-
// hanzo.bot and the Sites plane's `<slug>.hanzo.app` aliases
|
|
47
|
-
// export and are admitted the same way
|
|
48
|
-
if (host === 'hanzo.ai' || host.endsWith('.hanzo.ai') || team(host) || host === 'hanzo.bot' || guest(host))
|
|
44
|
+
// The shipped app is served from an origin the gateway already admits, so
|
|
45
|
+
// there the absolute address stands and no proxy is involved. hanzo.ai,
|
|
46
|
+
// hanzo.team, hanzo.bot and the Sites plane's `<slug>.hanzo.app` aliases
|
|
47
|
+
// serve this same export and are admitted the same way.
|
|
48
|
+
if (apex(host) || host === 'hanzo.ai' || host.endsWith('.hanzo.ai') || team(host) || host === 'hanzo.bot' || guest(host))
|
|
49
49
|
return 'https://api.hanzo.ai';
|
|
50
50
|
return window.location.origin;
|
|
51
51
|
}
|
package/dist/lib/betas.js
CHANGED
|
@@ -49,7 +49,9 @@ export const BETAS = [
|
|
|
49
49
|
{ id: 'search', name: 'Search', line: phrase('Keyword and meaning in one query'), group: 'Data', href: `${PLATFORM}/search` },
|
|
50
50
|
{ id: 'world', name: 'World', line: phrase('A live map of every model and AI workload'), group: 'Data', href: 'https://world.hanzo.ai' },
|
|
51
51
|
{ id: 'crawl', name: 'Crawl', line: phrase('Turn a website into clean Markdown'), group: 'Data', href: `${PLATFORM}/crawl` },
|
|
52
|
+
{ id: 'notebook', name: 'Notebook', line: phrase('Shared live Python, R and SQL notebooks connected to Hanzo Science agents'), group: 'Data', href: '/science?view=notebook' },
|
|
52
53
|
{ id: 'workspace', name: 'Google Workspace', line: phrase('Drive, Docs, Sheets, Gmail and Calendar for the assistant, read and write'), group: 'Data' },
|
|
54
|
+
{ id: 'science', name: 'Science', line: phrase('AI research workbench for multi-agent literature review, auditable figures and live notebooks'), group: 'Agents', href: '/science?workbench=1' },
|
|
53
55
|
{ id: 'flow', name: 'Flow', line: phrase('Visual node-graph canvas for agents, RAG pipelines and workflows'), group: 'Agents', href: '/flow' },
|
|
54
56
|
{ id: 'operative', name: 'Operative', line: phrase('A desktop in a container, driven by a model'), group: 'Agents' },
|
|
55
57
|
{ id: 'tasks', name: 'Tasks', line: phrase('Durable execution for long-running work'), group: 'Agents', href: `${PLATFORM}/tasks` },
|
|
@@ -92,9 +94,11 @@ export const opens = (id, flags, sudo, local = false) => {
|
|
|
92
94
|
return true;
|
|
93
95
|
if (local)
|
|
94
96
|
return true;
|
|
97
|
+
if ((id === 'science' || id === 'notebook') && hanzoAdmin())
|
|
98
|
+
return true;
|
|
95
99
|
if (id === 'studio' || id === 'flow')
|
|
96
100
|
return false;
|
|
97
|
-
return Boolean(sudo);
|
|
101
|
+
return Boolean(sudo || hanzoAdmin());
|
|
98
102
|
};
|
|
99
103
|
const ADMIN_BETA_ALL_KEY = 'hz_beta_admin_all';
|
|
100
104
|
const ADMIN_BETA_FLAG_PREFIX = 'hz_beta_admin_flag_';
|
package/dist/lib/host.d.ts
CHANGED
|
@@ -176,7 +176,7 @@ export declare function resume(): string;
|
|
|
176
176
|
* app added there lives on hanzo.team unless the apex names it above.
|
|
177
177
|
*/
|
|
178
178
|
export declare const APPS: readonly string[];
|
|
179
|
-
/** The
|
|
179
|
+
/** The app's host, where it is served and signs people in, and the workspace's apps are not. hanzo.ai is the signed-out site. */
|
|
180
180
|
export declare const APEX: readonly string[];
|
|
181
181
|
/** Whether a host is the apex. */
|
|
182
182
|
export declare const apex: (hostname: string) => boolean;
|
|
@@ -187,33 +187,32 @@ export declare function leaves(address: string): boolean;
|
|
|
187
187
|
export { APPS as ROOMS, leaves as room };
|
|
188
188
|
/**
|
|
189
189
|
* Where an address belongs when it is asked for on `hostname`: on a `guest`
|
|
190
|
-
*
|
|
190
|
+
* host, the same address on hanzo.app, because every app signs in and a guest
|
|
191
191
|
* host cannot; on the apex, the same app and query on the workspace; otherwise
|
|
192
192
|
* null. Home is the workspace's root, so /home?channel=x lands on /?channel=x.
|
|
193
193
|
*/
|
|
194
194
|
export declare const away: (hostname: string, address: string) => string | null;
|
|
195
|
-
/** Where a sign-in started on a `guest` host is finished. */
|
|
196
|
-
export declare const SIGNIN = "https://hanzo.
|
|
195
|
+
/** Where a sign-in started on a `guest` host is finished: the app's own host. */
|
|
196
|
+
export declare const SIGNIN = "https://hanzo.app";
|
|
197
197
|
/**
|
|
198
198
|
* The Hanzo App, to get: the page with Download, Install CLI and Open in web.
|
|
199
199
|
* It is this export's /app, served as the root of hanzo.app (universe
|
|
200
|
-
* static-sites `hanzo-app`), so it is linked by that address
|
|
201
|
-
* forwards there.
|
|
200
|
+
* static-sites `hanzo-app`), so it is linked by that address.
|
|
202
201
|
*/
|
|
203
202
|
export declare const GET = "https://hanzo.app";
|
|
204
203
|
/**
|
|
205
|
-
* The app, opened from another host: the chat at hanzo.
|
|
206
|
-
* is signed out is asked to sign in there, on hanzo.
|
|
204
|
+
* The app, opened from another host: the chat at hanzo.app/chat. A reader who
|
|
205
|
+
* is signed out is asked to sign in there, on hanzo.app's own page, and lands
|
|
207
206
|
* back in the chat.
|
|
208
207
|
*/
|
|
209
|
-
export declare const WEB = "https://hanzo.
|
|
208
|
+
export declare const WEB = "https://hanzo.app/chat";
|
|
210
209
|
/**
|
|
211
|
-
* Whether a host serves this export and signs nobody in: hanzo.
|
|
212
|
-
*
|
|
213
|
-
* at; and hanzo.chat, whose root is /forward.
|
|
214
|
-
* customers publish into and hanzo.chat is
|
|
215
|
-
*
|
|
216
|
-
* on hanzo.
|
|
210
|
+
* Whether a host serves this export and signs nobody in: hanzo.ai, the
|
|
211
|
+
* signed-out site, while it still serves this export; every `<slug>.hanzo.app`
|
|
212
|
+
* alias the Sites plane serves it at; and hanzo.chat, whose root is /forward.
|
|
213
|
+
* `<slug>.hanzo.app` is a namespace customers publish into and hanzo.chat is
|
|
214
|
+
* only an address for the chat, so no sign-in runs under any of them: every
|
|
215
|
+
* address that needs one is the same address on hanzo.app.
|
|
217
216
|
*/
|
|
218
217
|
export declare const guest: (hostname: string) => boolean;
|
|
219
218
|
/**
|
package/dist/lib/host.js
CHANGED
|
@@ -288,8 +288,8 @@ const KEPT = new Set(['/chat', '/chat/shared', '/dev']);
|
|
|
288
288
|
* app added there lives on hanzo.team unless the apex names it above.
|
|
289
289
|
*/
|
|
290
290
|
export const APPS = ROUTES.filter((path) => !KEPT.has(path) && path !== SETTINGS && !path.startsWith(`${SETTINGS}/`));
|
|
291
|
-
/** The
|
|
292
|
-
export const APEX = ['hanzo.
|
|
291
|
+
/** The app's host, where it is served and signs people in, and the workspace's apps are not. hanzo.ai is the signed-out site. */
|
|
292
|
+
export const APEX = ['hanzo.app'];
|
|
293
293
|
/** Whether a host is the apex. */
|
|
294
294
|
export const apex = (hostname) => APEX.includes(hostname);
|
|
295
295
|
/** Whether a host is the workspace's own, where every app asks for a paid plan. */
|
|
@@ -302,7 +302,7 @@ export function leaves(address) {
|
|
|
302
302
|
export { APPS as ROOMS, leaves as room };
|
|
303
303
|
/**
|
|
304
304
|
* Where an address belongs when it is asked for on `hostname`: on a `guest`
|
|
305
|
-
*
|
|
305
|
+
* host, the same address on hanzo.app, because every app signs in and a guest
|
|
306
306
|
* host cannot; on the apex, the same app and query on the workspace; otherwise
|
|
307
307
|
* null. Home is the workspace's root, so /home?channel=x lands on /?channel=x.
|
|
308
308
|
*/
|
|
@@ -314,30 +314,29 @@ export const away = (hostname, address) => {
|
|
|
314
314
|
const home = address.match(/^\/home\/?(?=[?#]|$)/);
|
|
315
315
|
return home ? `${WORKSPACE}/${address.slice(home[0].length)}` : `${WORKSPACE}${address}`;
|
|
316
316
|
};
|
|
317
|
-
/** Where a sign-in started on a `guest` host is finished. */
|
|
318
|
-
export const SIGNIN = 'https://hanzo.
|
|
317
|
+
/** Where a sign-in started on a `guest` host is finished: the app's own host. */
|
|
318
|
+
export const SIGNIN = 'https://hanzo.app';
|
|
319
319
|
/**
|
|
320
320
|
* The Hanzo App, to get: the page with Download, Install CLI and Open in web.
|
|
321
321
|
* It is this export's /app, served as the root of hanzo.app (universe
|
|
322
|
-
* static-sites `hanzo-app`), so it is linked by that address
|
|
323
|
-
* forwards there.
|
|
322
|
+
* static-sites `hanzo-app`), so it is linked by that address.
|
|
324
323
|
*/
|
|
325
324
|
export const GET = 'https://hanzo.app';
|
|
326
325
|
/**
|
|
327
|
-
* The app, opened from another host: the chat at hanzo.
|
|
328
|
-
* is signed out is asked to sign in there, on hanzo.
|
|
326
|
+
* The app, opened from another host: the chat at hanzo.app/chat. A reader who
|
|
327
|
+
* is signed out is asked to sign in there, on hanzo.app's own page, and lands
|
|
329
328
|
* back in the chat.
|
|
330
329
|
*/
|
|
331
330
|
export const WEB = `${SIGNIN}${CHAT}`;
|
|
332
331
|
/**
|
|
333
|
-
* Whether a host serves this export and signs nobody in: hanzo.
|
|
334
|
-
*
|
|
335
|
-
* at; and hanzo.chat, whose root is /forward.
|
|
336
|
-
* customers publish into and hanzo.chat is
|
|
337
|
-
*
|
|
338
|
-
* on hanzo.
|
|
332
|
+
* Whether a host serves this export and signs nobody in: hanzo.ai, the
|
|
333
|
+
* signed-out site, while it still serves this export; every `<slug>.hanzo.app`
|
|
334
|
+
* alias the Sites plane serves it at; and hanzo.chat, whose root is /forward.
|
|
335
|
+
* `<slug>.hanzo.app` is a namespace customers publish into and hanzo.chat is
|
|
336
|
+
* only an address for the chat, so no sign-in runs under any of them: every
|
|
337
|
+
* address that needs one is the same address on hanzo.app.
|
|
339
338
|
*/
|
|
340
|
-
export const guest = (hostname) => hostname === 'hanzo.
|
|
339
|
+
export const guest = (hostname) => hostname === 'hanzo.ai' || hostname === 'www.hanzo.ai' || hostname.endsWith('.hanzo.app') || hostname === 'hanzo.chat';
|
|
341
340
|
/** The devnet's hosts are one label under hanzo.ai ending in `-dev`: app-dev, api-dev, id-dev. */
|
|
342
341
|
const DEVNET = '-dev.hanzo.ai';
|
|
343
342
|
/**
|
|
@@ -357,16 +356,16 @@ export function devnet(hostname) {
|
|
|
357
356
|
}
|
|
358
357
|
/**
|
|
359
358
|
* The hosts that answer IAM's sign-in and sign-out calls on their own origin:
|
|
360
|
-
* hanzo.
|
|
361
|
-
*
|
|
362
|
-
* proxy.
|
|
359
|
+
* hanzo.app, where Hanzo signs in (its /v1 is the cloud API, universe
|
|
360
|
+
* hanzo-domains `v1-hanzo-app`), testnet's test.hanzo.ai, and the dev server's
|
|
361
|
+
* /v1 proxy.
|
|
363
362
|
*/
|
|
364
363
|
const ANSWERS = new Set([...APEX, 'test.hanzo.ai', 'localhost', '127.0.0.1']);
|
|
365
364
|
/**
|
|
366
365
|
* The hosts this export is served on that keep a session of their own and sign
|
|
367
|
-
* in on hanzo.
|
|
366
|
+
* in on hanzo.app: a person signed out there is sent to hanzo.app/login carrying
|
|
368
367
|
* the host's OWN authorize request (its callback, its PKCE challenge), which
|
|
369
|
-
* hanzo.
|
|
368
|
+
* hanzo.app's page finishes, and the code comes back to the host's
|
|
370
369
|
* /auth/callback. One sign-in page for Hanzo, and nobody types a credential on
|
|
371
370
|
* these hosts.
|
|
372
371
|
*/
|
package/dist/lib/oauth.d.ts
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* page). The opener also reads the popup's address itself once it is back on
|
|
17
17
|
* this origin, and closes it, so a popup that cannot close itself still does.
|
|
18
18
|
*/
|
|
19
|
-
/** The return page the connect names: hanzo.
|
|
20
|
-
export declare const RETURN = "https://hanzo.
|
|
19
|
+
/** The return page the connect names: hanzo.app's Settings → Integrations, registered with the API. */
|
|
20
|
+
export declare const RETURN = "https://hanzo.app/?at=-/settings/integrations";
|
|
21
21
|
/** The message, channel and storage key one answer travels by. */
|
|
22
22
|
export declare const RETURNED = "hanzo-oauth-return";
|
|
23
23
|
/** What the provider answered. */
|
package/dist/lib/oauth.js
CHANGED
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* page). The opener also reads the popup's address itself once it is back on
|
|
17
17
|
* this origin, and closes it, so a popup that cannot close itself still does.
|
|
18
18
|
*/
|
|
19
|
-
/** The return page the connect names: hanzo.
|
|
20
|
-
export const RETURN = 'https://hanzo.
|
|
19
|
+
/** The return page the connect names: hanzo.app's Settings → Integrations, registered with the API. */
|
|
20
|
+
export const RETURN = 'https://hanzo.app/?at=-/settings/integrations';
|
|
21
21
|
/** The message, channel and storage key one answer travels by. */
|
|
22
22
|
export const RETURNED = 'hanzo-oauth-return';
|
|
23
23
|
/** The answer a return page's query carries, or null when it carries none. */
|
package/dist/lib/pay.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* address. Absolute, because this export also serves cloud.hanzo.ai and
|
|
17
17
|
* hanzo.bot, and the checkout lives on hanzo.ai.
|
|
18
18
|
*/
|
|
19
|
-
export declare const BILLING_URL = "https://hanzo.
|
|
19
|
+
export declare const BILLING_URL = "https://hanzo.app/pay";
|
|
20
20
|
/**
|
|
21
21
|
* The devnet's checkout: the same /pay mount on the devnet's site host, which
|
|
22
22
|
* charges Square's sandbox through the devnet's cloud. A page on a devnet host
|
package/dist/lib/pay.js
CHANGED
|
@@ -18,7 +18,7 @@ import { org } from "./session.js";
|
|
|
18
18
|
* address. Absolute, because this export also serves cloud.hanzo.ai and
|
|
19
19
|
* hanzo.bot, and the checkout lives on hanzo.ai.
|
|
20
20
|
*/
|
|
21
|
-
export const BILLING_URL = "https://hanzo.
|
|
21
|
+
export const BILLING_URL = "https://hanzo.app/pay";
|
|
22
22
|
/**
|
|
23
23
|
* The devnet's checkout: the same /pay mount on the devnet's site host, which
|
|
24
24
|
* charges Square's sandbox through the devnet's cloud. A page on a devnet host
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The space roster's route. */
|
|
2
|
+
export declare const MEMBERS = "/v1/team/members";
|
|
3
|
+
/** One row of a space roster, as cloud answers it. */
|
|
4
|
+
export interface TeamMember {
|
|
5
|
+
/** The account uuid: a message's author, a channel member, a `<@id>` mention. */
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
/** One of the org's agents rather than a person. */
|
|
9
|
+
bot: boolean;
|
|
10
|
+
/** A blob id, readable at `/v1/team/files/{space}/avatar` with the reader's
|
|
11
|
+
* credential. Not a picture a `src` can draw, so it is not carried. */
|
|
12
|
+
avatar?: string;
|
|
13
|
+
role?: string;
|
|
14
|
+
/** False for a retired agent, which stays so its past messages keep an author. */
|
|
15
|
+
active?: boolean;
|
|
16
|
+
presence?: string;
|
|
17
|
+
personRef?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One member of the org: a person, or an agent standing in the channels. */
|
|
20
|
+
export interface Member {
|
|
21
|
+
/** The account a message names as its author. */
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
/** A saved picture, as a data URI. Absent where the source has none to draw. */
|
|
25
|
+
avatar?: string;
|
|
26
|
+
agent: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The members a roster answer names, in the order it gives (people, then
|
|
30
|
+
* agents). A row with no account names no author, so it is not a member; a row
|
|
31
|
+
* with no name is called by its account.
|
|
32
|
+
*/
|
|
33
|
+
export declare const membersOf: (body: {
|
|
34
|
+
members?: TeamMember[] | null;
|
|
35
|
+
} | null | undefined) => Member[];
|
package/dist/members.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Who a channel can name: the space roster, read once.
|
|
2
|
+
//
|
|
3
|
+
// `GET /v1/team/members?space=<space>` (hanzo-inc/cloud apps/team/members.go)
|
|
4
|
+
// answers the space's people and the org's agents in one list, each by the
|
|
5
|
+
// account uuid a message names as its author, and asks only that the reader be
|
|
6
|
+
// a member of the space.
|
|
7
|
+
//
|
|
8
|
+
// It replaced two reads joined with Promise.all, and both failed a signed-in
|
|
9
|
+
// reader (hanzo-inc/app issue 199):
|
|
10
|
+
// - `/v1/team/bots`, which cloud retired for `/v1/bot/members`, answers 404,
|
|
11
|
+
// so the pair failed for everyone.
|
|
12
|
+
// - `/v1/iam/users?owner=<org>` is listed to an org admin only, so a member
|
|
13
|
+
// read 403 even before that.
|
|
14
|
+
// A channel's Roster said "Could not read this org's roster." either way.
|
|
15
|
+
/** The space roster's route. */
|
|
16
|
+
export const MEMBERS = '/v1/team/members';
|
|
17
|
+
/**
|
|
18
|
+
* The members a roster answer names, in the order it gives (people, then
|
|
19
|
+
* agents). A row with no account names no author, so it is not a member; a row
|
|
20
|
+
* with no name is called by its account.
|
|
21
|
+
*/
|
|
22
|
+
export const membersOf = (body) => (body?.members ?? []).flatMap((one) => (one?.id ? [{ id: one.id, name: one.name || one.id, agent: Boolean(one.bot) }] : []));
|
package/dist/roster.d.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/** The account a message names as its author. */
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
/** A saved picture, as a data URI. People only; an agent wears initials. */
|
|
7
|
-
avatar?: string;
|
|
8
|
-
agent: boolean;
|
|
9
|
-
}
|
|
1
|
+
import { type Member } from './members.js';
|
|
2
|
+
export type { Member } from './members.js';
|
|
10
3
|
/**
|
|
11
|
-
* The
|
|
4
|
+
* The members of the space a channel stands in, or null while unknown.
|
|
12
5
|
*
|
|
13
|
-
* Needs a session and
|
|
14
|
-
*
|
|
15
|
-
* member here.
|
|
6
|
+
* Needs a session and the space: the roster is read per space and answers only
|
|
7
|
+
* a member of it. A service account carries no id and can author nothing, so it
|
|
8
|
+
* is not a member here.
|
|
16
9
|
*/
|
|
17
|
-
export declare function useRoster(): {
|
|
10
|
+
export declare function useRoster(space: string | undefined): {
|
|
18
11
|
members: Member[] | null;
|
|
19
12
|
wrong: unknown;
|
|
20
13
|
};
|
package/dist/roster.js
CHANGED
|
@@ -1,49 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
// Who is in
|
|
2
|
+
// Who is in a space, by account — the ONE place an author becomes a name.
|
|
3
3
|
//
|
|
4
4
|
// A message carries the team account that wrote it and nothing else: for a
|
|
5
5
|
// person that is their IAM user id (the OIDC `sub`, which team's account id
|
|
6
|
-
// equals), for an agent the
|
|
7
|
-
//
|
|
8
|
-
// the mention chips cannot disagree about what to call anybody.
|
|
6
|
+
// equals), for an agent the account team derives from its id. The space roster
|
|
7
|
+
// answers both in one list (members.ts), so the transcript, the roster column
|
|
8
|
+
// and the mention chips cannot disagree about what to call anybody.
|
|
9
9
|
import { useEffect, useState } from 'react';
|
|
10
|
-
import { useIam
|
|
10
|
+
import { useIam } from '@hanzo/iam/react';
|
|
11
11
|
import { useAi } from './lib/ai.js';
|
|
12
|
+
import { MEMBERS, membersOf } from './members.js';
|
|
12
13
|
/**
|
|
13
|
-
* The
|
|
14
|
+
* The members of the space a channel stands in, or null while unknown.
|
|
14
15
|
*
|
|
15
|
-
* Needs a session and
|
|
16
|
-
*
|
|
17
|
-
* member here.
|
|
16
|
+
* Needs a session and the space: the roster is read per space and answers only
|
|
17
|
+
* a member of it. A service account carries no id and can author nothing, so it
|
|
18
|
+
* is not a member here.
|
|
18
19
|
*/
|
|
19
|
-
export function useRoster() {
|
|
20
|
+
export function useRoster(space) {
|
|
20
21
|
const { client } = useAi();
|
|
21
22
|
const { isAuthenticated } = useIam();
|
|
22
|
-
const { currentOrgId } = useOrganizations();
|
|
23
23
|
const [members, setMembers] = useState(null);
|
|
24
24
|
const [wrong, setWrong] = useState(null);
|
|
25
25
|
useEffect(() => {
|
|
26
|
-
if (!client || !isAuthenticated || !
|
|
26
|
+
if (!client || !isAuthenticated || !space)
|
|
27
27
|
return;
|
|
28
28
|
let live = true;
|
|
29
29
|
const stop = new AbortController();
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
signal,
|
|
36
|
-
}),
|
|
37
|
-
])
|
|
38
|
-
.then(([people, bots]) => {
|
|
39
|
-
if (!live)
|
|
40
|
-
return;
|
|
41
|
-
setMembers([
|
|
42
|
-
...(people.users ?? []).flatMap((one) => one.id
|
|
43
|
-
? [{ id: one.id, name: one.displayName || one.name, avatar: one.avatar || undefined, agent: false }]
|
|
44
|
-
: []),
|
|
45
|
-
...(bots.bots ?? []).map((one) => ({ id: one.userId, name: one.name, agent: true })),
|
|
46
|
-
]);
|
|
30
|
+
client.http
|
|
31
|
+
.json({ path: MEMBERS, query: { space }, signal: stop.signal })
|
|
32
|
+
.then((body) => {
|
|
33
|
+
if (live)
|
|
34
|
+
setMembers(membersOf(body));
|
|
47
35
|
})
|
|
48
36
|
.catch((e) => {
|
|
49
37
|
if (live)
|
|
@@ -53,7 +41,7 @@ export function useRoster() {
|
|
|
53
41
|
live = false;
|
|
54
42
|
stop.abort();
|
|
55
43
|
};
|
|
56
|
-
}, [client, isAuthenticated,
|
|
44
|
+
}, [client, isAuthenticated, space]);
|
|
57
45
|
return { members, wrong };
|
|
58
46
|
}
|
|
59
47
|
/** The member an author id names, or undefined for one the roster lacks. */
|
package/dist/watch.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The query key Work reads a run from. */
|
|
2
|
+
export declare const KEY = "session";
|
|
3
|
+
/** The Work board, opened on one run; the board alone for anything that is not an id. */
|
|
4
|
+
export declare const watch: (id: string) => string;
|
|
5
|
+
/** The run an address asks Work to open, or null when it names none. */
|
|
6
|
+
export declare function asked(search: string): string | null;
|
package/dist/watch.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// One run on the Work board, as an address: where a line about a run sends the
|
|
2
|
+
// reader. No React, so a spec reads it as it is.
|
|
3
|
+
//
|
|
4
|
+
// Home's Next card says "{n} failed in the past 7 days". Linked to /work alone,
|
|
5
|
+
// it left the reader on a board of up to a hundred runs, old failures among
|
|
6
|
+
// them, to find the ones it meant (hanzo-inc/app issue 202). The address names
|
|
7
|
+
// the newest failure instead, and Work opens it on arrival, where its steps say
|
|
8
|
+
// what went wrong and Steer acts on it. What writes the address and what reads
|
|
9
|
+
// it live here together, so the two cannot drift apart.
|
|
10
|
+
/** The query key Work reads a run from. */
|
|
11
|
+
export const KEY = 'session';
|
|
12
|
+
/** An id-shaped token ("sess_" + 32 hex today), and nothing that could be a path. */
|
|
13
|
+
const ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
14
|
+
/** The Work board, opened on one run; the board alone for anything that is not an id. */
|
|
15
|
+
export const watch = (id) => (ID.test(id) ? `/work?${new URLSearchParams({ [KEY]: id })}` : '/work');
|
|
16
|
+
/** The run an address asks Work to open, or null when it names none. */
|
|
17
|
+
export function asked(search) {
|
|
18
|
+
const id = new URLSearchParams(search).get(KEY)?.trim();
|
|
19
|
+
return id && ID.test(id) ? id : null;
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.55",
|
|
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",
|