@hanzo/app 0.2.57 → 0.2.59
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/App.js +1 -1
- package/dist/Board.js +37 -121
- package/dist/Boxes.js +12 -16
- package/dist/CalScheduler.js +40 -81
- package/dist/Chat.js +84 -78
- package/dist/Chrome.d.ts +2 -14
- package/dist/Chrome.js +7 -44
- package/dist/Column.js +6 -2
- package/dist/Contents.d.ts +1 -1
- package/dist/Contents.js +2 -1
- package/dist/Drive.js +100 -121
- package/dist/Inbox.js +7 -7
- package/dist/Market.js +10 -15
- package/dist/Meet.js +48 -78
- package/dist/Orgs.js +10 -9
- package/dist/Palette.d.ts +1 -1
- package/dist/Palette.js +2 -1
- package/dist/Rail.js +3 -3
- package/dist/Schedule.js +11 -15
- package/dist/Settings.d.ts +1 -1
- package/dist/SettingsPane.js +2 -2
- package/dist/Shared.js +11 -16
- package/dist/Shell.js +1 -1
- package/dist/Talk.js +4 -4
- package/dist/Terminals.js +1 -3
- package/dist/Top.js +1 -1
- package/dist/Usage.js +3 -3
- package/dist/WindowControls.js +3 -5
- package/dist/Work.js +28 -51
- package/dist/bots/Bots.js +73 -129
- package/dist/bots/runtime.js +41 -103
- package/dist/cast.d.ts +1 -1
- package/dist/cast.js +1 -1
- package/dist/failure.d.ts +1 -1
- package/dist/failure.js +1 -1
- package/dist/ground.d.ts +14 -0
- package/dist/ground.js +14 -0
- package/dist/lib/limits.d.ts +1 -1
- package/dist/lib/limits.js +1 -1
- package/dist/lib/org.d.ts +3 -3
- package/dist/lib/org.js +5 -4
- package/dist/lib/orgname.d.ts +1 -1
- package/dist/lib/orgname.js +1 -1
- package/dist/lib/pay.d.ts +2 -6
- package/dist/lib/pay.js +2 -15
- package/dist/lib/plans.d.ts +1 -1
- package/dist/lib/plans.js +1 -1
- package/dist/lib/tier.d.ts +2 -2
- package/dist/lib/tier.js +6 -6
- package/dist/look.js +8 -10
- package/dist/recent.d.ts +1 -1
- package/dist/recent.js +2 -1
- package/dist/say.d.ts +4 -0
- package/dist/say.js +7 -0
- package/dist/thread.js +1 -1
- package/package.json +3 -3
- package/assets/memoji/art.svg +0 -22
- package/assets/memoji/cyber.svg +0 -22
- package/assets/memoji/data.svg +0 -22
- package/assets/memoji/des.svg +0 -22
- package/assets/memoji/dev.svg +0 -22
- package/assets/memoji/doc.svg +0 -22
- package/assets/memoji/edu.svg +0 -22
- package/assets/memoji/fin.svg +0 -22
- package/assets/memoji/gov.svg +0 -22
- package/assets/memoji/huma.svg +0 -22
- package/assets/memoji/lang.svg +0 -22
- package/assets/memoji/law.svg +0 -22
- package/assets/memoji/mana.svg +0 -22
- package/assets/memoji/mark.svg +0 -22
- package/assets/memoji/mu.svg +0 -22
- package/assets/memoji/opera.svg +0 -22
- package/assets/memoji/rev.svg +0 -22
- package/assets/memoji/sal.svg +0 -22
- package/assets/memoji/sci.svg +0 -22
- package/assets/memoji/su.svg +0 -22
- package/assets/memoji/vi.svg +0 -22
- package/dist/TeamPreview.d.ts +0 -9
- package/dist/TeamPreview.js +0 -305
- package/dist/TeamStory.d.ts +0 -49
- package/dist/TeamStory.js +0 -67
- package/dist/preview.d.ts +0 -84
- package/dist/preview.js +0 -120
- package/dist/workday.d.ts +0 -247
- package/dist/workday.js +0 -642
package/dist/bots/runtime.js
CHANGED
|
@@ -26,46 +26,13 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
26
26
|
import { Play, Square, X } from 'lucide-react';
|
|
27
27
|
import { useOrganizations } from '@hanzo/iam/react';
|
|
28
28
|
import { useAi } from '../lib/ai.js';
|
|
29
|
-
import { useI18n } from '@hanzo/i18n/react';
|
|
30
29
|
import { say } from '../failure.js';
|
|
31
30
|
import { Input, Text, XStack, YStack } from '@hanzo/gui';
|
|
32
31
|
import { Picker } from '@hanzo/ui';
|
|
33
32
|
import { DIM, FAINT, GROUND, INK, LINE } from './ink.js';
|
|
34
33
|
import { BOXED, LABEL, OUT, PICK, TAB } from './kit.js';
|
|
35
|
-
import {
|
|
36
|
-
/** The platform's word for how a bot runs, as a person reads it. An unknown mode stays a token. */
|
|
37
|
-
function modeName(mode, t) {
|
|
38
|
-
if (mode === ALWAYS)
|
|
39
|
-
return t('long-running');
|
|
40
|
-
if (!mode || mode === ONCE)
|
|
41
|
-
return t('one-shot');
|
|
42
|
-
return mode;
|
|
43
|
-
}
|
|
44
|
-
/** A computer's status, in the reader's words. An unrecognized status stays a token. */
|
|
45
|
-
function boxStatus(status, t) {
|
|
46
|
-
switch (status) {
|
|
47
|
-
case 'running':
|
|
48
|
-
return t('running');
|
|
49
|
-
case 'pending':
|
|
50
|
-
return t('pending');
|
|
51
|
-
case 'error':
|
|
52
|
-
return t('error');
|
|
53
|
-
case 'unknown':
|
|
54
|
-
return t('unknown');
|
|
55
|
-
default:
|
|
56
|
-
return status;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/** Where a tool was published, and whether the org has turned it on. */
|
|
60
|
-
function toolFrom(from, ready, t) {
|
|
61
|
-
if (from === 'MCP')
|
|
62
|
-
return t(ready ? 'MCP' : 'MCP · not activated');
|
|
63
|
-
if (from === 'skill')
|
|
64
|
-
return t(ready ? 'skill' : 'skill · not activated');
|
|
65
|
-
return t(ready ? 'platform' : 'platform · not activated');
|
|
66
|
-
}
|
|
34
|
+
import { answer, answering, call, connectors as readConnectors, disk, grant, projects as readProjects, secrets as readSecrets, tools as readTools, vault, workOn, } from './api.js';
|
|
67
35
|
export function Runtime({ bot }) {
|
|
68
|
-
const { t, locale } = useI18n();
|
|
69
36
|
const { client } = useAi();
|
|
70
37
|
const { currentOrg } = useOrganizations();
|
|
71
38
|
const org = currentOrg?.displayName || currentOrg?.name || '';
|
|
@@ -82,46 +49,36 @@ export function Runtime({ bot }) {
|
|
|
82
49
|
const [repos, setRepos] = useState([]);
|
|
83
50
|
const [why, setWhy] = useState({});
|
|
84
51
|
const blame = useCallback((k, e, subject) => {
|
|
85
|
-
setWhy((w) => ({ ...w, [k]: say(e, subject
|
|
86
|
-
}, [
|
|
52
|
+
setWhy((w) => ({ ...w, [k]: say(e, subject) }));
|
|
53
|
+
}, []);
|
|
87
54
|
const survey = useCallback(async () => {
|
|
88
55
|
if (!client)
|
|
89
56
|
return;
|
|
90
57
|
await Promise.all([
|
|
91
|
-
client.machines.list().then(setMachines).catch((e) => blame('machine', e,
|
|
92
|
-
client.sandboxes.list({ project }).then(setBoxes).catch((e) => blame('box', e,
|
|
93
|
-
client.tools.mcp().then(setServers).catch((e) => blame('mcp', e,
|
|
94
|
-
client.tools.skills().then((s) => setSkills(s.tools ?? [])).catch((e) => blame('skill', e,
|
|
58
|
+
client.machines.list().then(setMachines).catch((e) => blame('machine', e, 'this org’s machines')),
|
|
59
|
+
client.sandboxes.list({ project }).then(setBoxes).catch((e) => blame('box', e, 'this bot’s computer')),
|
|
60
|
+
client.tools.mcp().then(setServers).catch((e) => blame('mcp', e, 'this org’s MCP servers')),
|
|
61
|
+
client.tools.skills().then((s) => setSkills(s.tools ?? [])).catch((e) => blame('skill', e, 'this org’s skills')),
|
|
95
62
|
client.tools.activation().then((a) => setActivated(a.enabled ?? [])).catch(() => setActivated([])),
|
|
96
|
-
readTools(client).then(setPublished).catch((e) => blame('served', e,
|
|
97
|
-
readConnectors(client).then(setLinks).catch((e) => blame('link', e,
|
|
98
|
-
client.channels.list().then(setRooms).catch((e) => blame('room', e,
|
|
99
|
-
readSecrets(client, vault(bot.name)).then(setKeys).catch((e) => blame('key', e,
|
|
100
|
-
readProjects(client).then(setRepos).catch((e) => blame('repo', e,
|
|
63
|
+
readTools(client).then(setPublished).catch((e) => blame('served', e, 'the platform’s tools')),
|
|
64
|
+
readConnectors(client).then(setLinks).catch((e) => blame('link', e, 'your connectors')),
|
|
65
|
+
client.channels.list().then(setRooms).catch((e) => blame('room', e, 'this org’s channels')),
|
|
66
|
+
readSecrets(client, vault(bot.name)).then(setKeys).catch((e) => blame('key', e, 'this bot’s secrets')),
|
|
67
|
+
readProjects(client).then(setRepos).catch((e) => blame('repo', e, 'this org’s repos')),
|
|
101
68
|
]);
|
|
102
|
-
}, [client, project, bot.name, blame
|
|
69
|
+
}, [client, project, bot.name, blame]);
|
|
103
70
|
useEffect(() => {
|
|
104
71
|
void survey();
|
|
105
72
|
}, [survey]);
|
|
106
|
-
return (_jsxs(YStack, { render: "aside", "aria-label":
|
|
107
|
-
? '{name} runs for {org} as {id}. Nothing on this panel crosses into another org.'
|
|
108
|
-
: '{name} runs for {org}. Nothing on this panel crosses into another org.', {
|
|
109
|
-
name: bot.name,
|
|
110
|
-
org: _jsx(Text, { color: INK, children: org || t('your org') }),
|
|
111
|
-
id: bot.serviceAccountId ?? '',
|
|
112
|
-
}) }), bot.schedule ? (_jsx(Line, { children: t(bot.executionMode ? 'Wakes on {schedule} ({mode}).' : 'Wakes on {schedule}.', {
|
|
113
|
-
schedule: _jsx(Text, { color: INK, children: bot.schedule }),
|
|
114
|
-
mode: modeName(bot.executionMode, t),
|
|
115
|
-
}) })) : null] }), _jsx(Machine, { bot: bot, machines: machines, why: why.machine }), _jsx(Computer, { bot: bot, box: boxes[0] ?? null, project: project, why: why.box, onChange: survey }), _jsx(Tools, { bot: bot, servers: servers, skills: skills, published: published, activated: activated, why: why.served ?? why.mcp ?? why.skill }), _jsx(Channels, { bot: bot, rooms: rooms, why: why.room }), _jsx(Code, { bot: bot, repos: repos, why: why.repo }), _jsx(Secrets, { bot: bot, keys: keys, why: why.key }), _jsx(Held, { links: links, why: why.link })] }));
|
|
73
|
+
return (_jsxs(YStack, { render: "aside", "aria-label": `${bot.name} runtime`, "data-hz": "runtime-pane", width: 360, shrink: 0, overflowY: "auto", borderLeftWidth: 1, borderColor: LINE, bg: GROUND, children: [_jsxs(Part, { title: "Runtime", children: [_jsxs(Line, { children: [bot.name, " runs for ", _jsx(Text, { color: INK, children: org || 'your org' }), bot.serviceAccountId ? ` as ${bot.serviceAccountId}` : '', ". Nothing on this panel crosses into another org."] }), bot.schedule ? (_jsxs(Line, { children: ["Wakes on ", _jsx(Text, { color: INK, children: bot.schedule }), bot.executionMode ? ` (${bot.executionMode})` : '', "."] })) : null] }), _jsx(Machine, { bot: bot, machines: machines, why: why.machine }), _jsx(Computer, { bot: bot, box: boxes[0] ?? null, project: project, why: why.box, onChange: survey }), _jsx(Tools, { bot: bot, servers: servers, skills: skills, published: published, activated: activated, why: why.served ?? why.mcp ?? why.skill }), _jsx(Channels, { bot: bot, rooms: rooms, why: why.room }), _jsx(Code, { bot: bot, repos: repos, why: why.repo }), _jsx(Secrets, { bot: bot, keys: keys, why: why.key }), _jsx(Held, { links: links, why: why.link })] }));
|
|
116
74
|
}
|
|
117
75
|
/** The machine this Bot runs on. The list is the org's; the binding is the Bot's. */
|
|
118
76
|
function Machine({ bot, machines, why }) {
|
|
119
|
-
const { t, locale } = useI18n();
|
|
120
77
|
const { client } = useAi();
|
|
121
78
|
const [bound, setBound] = useState(bot.computeRef ?? '');
|
|
122
79
|
const [failed, setFailed] = useState(null);
|
|
123
80
|
useEffect(() => setBound(bot.computeRef ?? ''), [bot.computeRef]);
|
|
124
|
-
return (_jsxs(Part, { title:
|
|
81
|
+
return (_jsxs(Part, { title: "Machine", children: [why ? _jsx(Line, { children: why }) : null, !why && machines.length === 0 ? (_jsx(Line, { children: "No machine is registered to this org, so this bot runs wherever the platform places it." })) : null, machines.length > 0 ? (_jsxs(Picker, { ...PICK, value: bound, "aria-label": "Machine", onChange: async (e) => {
|
|
125
82
|
const id = e.target.value;
|
|
126
83
|
setBound(id);
|
|
127
84
|
if (!client)
|
|
@@ -131,14 +88,9 @@ function Machine({ bot, machines, why }) {
|
|
|
131
88
|
setFailed(null);
|
|
132
89
|
}
|
|
133
90
|
catch (err) {
|
|
134
|
-
setFailed(say(err,
|
|
91
|
+
setFailed(say(err, 'this bot', 'save'));
|
|
135
92
|
}
|
|
136
|
-
}, children: [_jsx("option", { value: "", children:
|
|
137
|
-
? t('{name} — {status}', {
|
|
138
|
-
name: m.label || m.host || m.id,
|
|
139
|
-
status: m.status === 'online' ? t('online') : m.status,
|
|
140
|
-
})
|
|
141
|
-
: m.label || m.host || m.id }, m.id)))] })) : null, failed ? _jsx(Line, { children: failed }) : null] }));
|
|
93
|
+
}, children: [_jsx("option", { value: "", children: "Unbound" }), machines.map((m) => (_jsxs("option", { value: m.id, children: [m.label || m.host || m.id, m.status ? ` — ${m.status}` : ''] }, m.id)))] })) : null, failed ? _jsx(Line, { children: failed }) : null] }));
|
|
142
94
|
}
|
|
143
95
|
/**
|
|
144
96
|
* This Bot's computer.
|
|
@@ -155,7 +107,6 @@ function Machine({ bot, machines, why }) {
|
|
|
155
107
|
* what this section can honestly show until the pool comes back.
|
|
156
108
|
*/
|
|
157
109
|
function Computer({ bot, box, project, why, onChange, }) {
|
|
158
|
-
const { t, locale } = useI18n();
|
|
159
110
|
const { client } = useAi();
|
|
160
111
|
const [busy, setBusy] = useState(false);
|
|
161
112
|
const [failed, setFailed] = useState(null);
|
|
@@ -173,44 +124,38 @@ function Computer({ bot, box, project, why, onChange, }) {
|
|
|
173
124
|
catch (e) {
|
|
174
125
|
// The fleet's own words. A sandbox that will not start is the reader's
|
|
175
126
|
// situation and only the fleet knows why, so it is not translated away.
|
|
176
|
-
|
|
177
|
-
setFailed(t('{what}: {message}', { what, message }));
|
|
127
|
+
setFailed(`${what}: ${e instanceof Error ? e.message : String(e)}`);
|
|
178
128
|
}
|
|
179
129
|
finally {
|
|
180
130
|
setBusy(false);
|
|
181
131
|
}
|
|
182
|
-
}, [client, busy
|
|
183
|
-
const open = (kind) => attempt(
|
|
132
|
+
}, [client, busy]);
|
|
133
|
+
const open = (kind) => attempt(`Could not open the ${kind}`, async () => {
|
|
184
134
|
if (!client || !box)
|
|
185
135
|
return;
|
|
186
136
|
const g = await grant(client, box.id, kind);
|
|
187
137
|
if (!g.url)
|
|
188
|
-
throw new Error(
|
|
138
|
+
throw new Error('the platform minted no address');
|
|
189
139
|
setWindow({ kind, url: g.url });
|
|
190
140
|
});
|
|
191
|
-
return (_jsxs(Part, { title:
|
|
192
|
-
project: _jsx(Text, { render: "code", fontSize: "$1", color: INK, children: project }),
|
|
193
|
-
}) }), why ? _jsx(Line, { children: why }) : null, box ? (_jsxs(_Fragment, { children: [_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, "data-hz": "box", children: t('{class} · {status}', {
|
|
194
|
-
class: box.class ?? t('sandbox'),
|
|
195
|
-
status: box.status ? boxStatus(box.status, t) : t('unknown'),
|
|
196
|
-
}) }), _jsx(Text, { fontSize: "$1", color: FAINT, children: box.id.slice(0, 14) })] }), box.status === 'pending' ? (_jsx(Line, { children: t('Waiting for the fleet to place it. Nothing can be opened on it until it is running.') })) : null, box.status === 'error' ? _jsx(Line, { children: box.error || t('The fleet could not start it.') }) : null, _jsxs(XStack, { gap: 6, flexWrap: "wrap", children: [box.status === 'running' ? (_jsx(Text, { ...TAB, onClick: () => open('terminal'), disabled: busy, children: t('Terminal') })) : null, box.status === 'running' && box.class === 'desktop' ? (_jsx(Text, { ...TAB, onClick: () => open('screen'), disabled: busy, children: t('Screen') })) : null, _jsxs(Text, { ...TAB, disabled: busy, onClick: () => attempt(t('Could not stop it'), async () => {
|
|
141
|
+
return (_jsxs(Part, { title: "Computer", children: [_jsxs(Line, { children: ["Its own disk, ", _jsx(Text, { render: "code", fontSize: "$1", color: INK, children: project }), ". A lease on this project finds the same disk every time, so what this bot writes outlives the lease."] }), why ? _jsx(Line, { children: why }) : null, box ? (_jsxs(_Fragment, { children: [_jsxs(Row, { children: [_jsxs(Text, { fontSize: "$2", color: INK, "data-hz": "box", children: [box.class ?? 'sandbox', " \u00B7 ", box.status ?? 'unknown'] }), _jsx(Text, { fontSize: "$1", color: FAINT, children: box.id.slice(0, 14) })] }), box.status === 'pending' ? (_jsx(Line, { children: "Waiting for the fleet to place it. Nothing can be opened on it until it is running." })) : null, box.status === 'error' ? _jsx(Line, { children: box.error || 'The fleet could not start it.' }) : null, _jsxs(XStack, { gap: 6, flexWrap: "wrap", children: [box.status === 'running' ? (_jsx(Text, { ...TAB, onClick: () => open('terminal'), disabled: busy, children: "Terminal" })) : null, box.status === 'running' && box.class === 'desktop' ? (_jsx(Text, { ...TAB, onClick: () => open('screen'), disabled: busy, children: "Screen" })) : null, _jsxs(Text, { ...TAB, disabled: busy, onClick: () => attempt('Could not stop it', async () => {
|
|
197
142
|
await client.sandboxes.stop({ id: box.id });
|
|
198
|
-
}), children: [_jsx(Square, { size: 11, "aria-hidden": true }),
|
|
143
|
+
}), children: [_jsx(Square, { size: 11, "aria-hidden": true }), "Stop"] }), _jsxs(Text, { ...TAB, disabled: busy, onClick: () => attempt('Could not end the lease', async () => {
|
|
199
144
|
await client.sandboxes.end({ id: box.id });
|
|
200
145
|
setWindow(null);
|
|
201
146
|
await onChange();
|
|
202
|
-
}), children: [_jsx(X, { size: 11, "aria-hidden": true }),
|
|
147
|
+
}), children: [_jsx(X, { size: 11, "aria-hidden": true }), "End"] })] }), window ? (_jsx(YStack, { render: "iframe", src: window.url, title: `${bot.name} ${window.kind}`, width: "100%", height: 240, borderWidth: 1, borderColor: LINE, rounded: 8, bg: GROUND })) : null, _jsxs(XStack, { render: "form", onSubmit: (e) => {
|
|
203
148
|
e.preventDefault();
|
|
204
|
-
void attempt(
|
|
149
|
+
void attempt('Could not run it', async () => {
|
|
205
150
|
setRan(await client.sandboxes.run({ id: box.id, command }));
|
|
206
151
|
});
|
|
207
|
-
}, display: box.status === 'running' ? 'flex' : 'none', gap: 6, children: [_jsx(Input, { ...BOXED, flex: 1, minW: 0, value: command, onChange: (e) => setCommand(e.target.value), placeholder:
|
|
152
|
+
}, display: box.status === 'running' ? 'flex' : 'none', gap: 6, children: [_jsx(Input, { ...BOXED, flex: 1, minW: 0, value: command, onChange: (e) => setCommand(e.target.value), placeholder: "Command", "aria-label": "Command to run in this bot's computer" }), _jsxs(Text, { ...TAB, type: 'submit', disabled: busy || !command.trim(), children: [_jsx(Play, { size: 11, "aria-hidden": true }), "Run"] })] }), ran ? (_jsxs(Text, { ...OUT, children: [(ran.stdout ?? '') + (ran.stderr ?? ''), `\nexit ${ran.exitCode ?? 0}`] })) : null] })) : (_jsxs(_Fragment, { children: [_jsx(Line, { children: "No computer is leased. A lease is what a terminal, a screen and a command all hang off, so until one starts there is nothing here to open." }), _jsxs(XStack, { gap: 6, flexWrap: "wrap", children: [_jsx(Text, { ...TAB, "data-hz": "lease", disabled: busy, onClick: () => attempt('Could not lease a computer', async () => {
|
|
208
153
|
await client.sandboxes.lease({ class: 'dev', project });
|
|
209
154
|
await onChange();
|
|
210
|
-
}), children:
|
|
155
|
+
}), children: busy ? 'Leasing…' : 'Lease a computer' }), _jsx(Text, { ...TAB, "data-hz": "lease-desktop", disabled: busy, onClick: () => attempt('Could not lease a screen', async () => {
|
|
211
156
|
await client.sandboxes.lease({ class: 'desktop', project });
|
|
212
157
|
await onChange();
|
|
213
|
-
}), children:
|
|
158
|
+
}), children: busy ? 'Leasing…' : 'Lease a screen' })] })] })), failed ? _jsx(Line, { "data-hz": "computer-failed", children: failed }) : null] }));
|
|
214
159
|
}
|
|
215
160
|
/**
|
|
216
161
|
* What this Bot may call, and calling one.
|
|
@@ -235,7 +180,6 @@ function Computer({ bot, box, project, why, onChange, }) {
|
|
|
235
180
|
* the record.
|
|
236
181
|
*/
|
|
237
182
|
function Tools({ bot, servers, skills, published, activated, why, }) {
|
|
238
|
-
const { t, locale } = useI18n();
|
|
239
183
|
const { client } = useAi();
|
|
240
184
|
const [held, setHeld] = useState(bot.tools ?? []);
|
|
241
185
|
const [failed, setFailed] = useState(null);
|
|
@@ -246,7 +190,7 @@ function Tools({ bot, servers, skills, published, activated, why, }) {
|
|
|
246
190
|
useEffect(() => setHeld(bot.tools ?? []), [bot.tools, bot.name]);
|
|
247
191
|
useEffect(() => setPick((p) => (held.includes(p) ? p : (held[0] ?? ''))), [held]);
|
|
248
192
|
const offered = [
|
|
249
|
-
...published.map((
|
|
193
|
+
...published.map((t) => ({ name: t.name, from: 'platform', ready: true })),
|
|
250
194
|
...servers.map((s) => ({ name: s.name || s.id, from: 'MCP', ready: activated.includes(s.name || s.id) })),
|
|
251
195
|
...skills.map((s) => ({ name: s.name, from: 'skill', ready: activated.includes(s.name) })),
|
|
252
196
|
];
|
|
@@ -260,10 +204,10 @@ function Tools({ bot, servers, skills, published, activated, why, }) {
|
|
|
260
204
|
setFailed(null);
|
|
261
205
|
}
|
|
262
206
|
catch (e) {
|
|
263
|
-
setFailed(say(e,
|
|
207
|
+
setFailed(say(e, 'this bot', 'save'));
|
|
264
208
|
}
|
|
265
209
|
};
|
|
266
|
-
return (_jsxs(Part, { title:
|
|
210
|
+
return (_jsxs(Part, { title: "Tools", children: [why ? _jsx(Line, { children: why }) : null, offered.length === 0 && !why ? (_jsx(Line, { children: "Nothing publishes a tool for this org yet, so there is nothing to grant." })) : null, _jsx(YStack, { "data-hz": "tools", maxH: 200, overflowY: "auto", gap: 4, children: offered.map((t) => (_jsxs(XStack, { render: "label", items: "center", justify: "space-between", gap: 8, cursor: "pointer", children: [_jsx("input", { type: "checkbox", checked: held.includes(t.name), onChange: () => flip(t.name), "aria-label": t.name }), _jsx(Text, { flex: 1, fontSize: "$2", color: INK, children: t.name }), _jsx(Text, { fontSize: "$1", color: FAINT, children: t.ready ? t.from : `${t.from} · not activated` })] }, `${t.from}-${t.name}`))) }), held.length > 0 ? (_jsxs(YStack, { render: "form", onSubmit: async (e) => {
|
|
267
211
|
e.preventDefault();
|
|
268
212
|
if (!client || busy || !pick || !op.trim())
|
|
269
213
|
return;
|
|
@@ -277,7 +221,7 @@ function Tools({ bot, servers, skills, published, activated, why, }) {
|
|
|
277
221
|
finally {
|
|
278
222
|
setBusy(false);
|
|
279
223
|
}
|
|
280
|
-
}, gap: 6, children: [_jsx(Picker, { ...PICK, value: pick, onChange: (e) => setPick(e.target.value), "aria-label":
|
|
224
|
+
}, gap: 6, children: [_jsx(Picker, { ...PICK, value: pick, onChange: (e) => setPick(e.target.value), "aria-label": "Tool to call", children: held.map((h) => (_jsx("option", { value: h, children: h }, h))) }), _jsxs(XStack, { gap: 6, children: [_jsx(Input, { ...BOXED, flex: 1, minW: 0, "data-hz": "op", value: op, onChange: (e) => setOp(e.target.value), placeholder: "Operation", "aria-label": "Operation to run" }), _jsx(Text, { ...TAB, type: 'submit', "data-hz": "call", disabled: busy || !op.trim(), children: busy ? 'Calling…' : 'Call' })] })] })) : null, ran ? _jsx(Text, { ...OUT, "data-hz": "called", children: ran }) : null, failed ? _jsx(Line, { children: failed }) : null] }));
|
|
281
225
|
}
|
|
282
226
|
/**
|
|
283
227
|
* The rooms this Bot answers.
|
|
@@ -287,7 +231,6 @@ function Tools({ bot, servers, skills, published, activated, why, }) {
|
|
|
287
231
|
* Answer here moves that channel from whichever bot holds it to this one.
|
|
288
232
|
*/
|
|
289
233
|
function Channels({ bot, rooms, why }) {
|
|
290
|
-
const { t, locale } = useI18n();
|
|
291
234
|
const { client } = useAi();
|
|
292
235
|
const [bound, setBound] = useState({});
|
|
293
236
|
const [failed, setFailed] = useState(null);
|
|
@@ -307,9 +250,9 @@ function Channels({ bot, rooms, why }) {
|
|
|
307
250
|
useEffect(() => {
|
|
308
251
|
void read();
|
|
309
252
|
}, [read]);
|
|
310
|
-
return (_jsxs(Part, { title:
|
|
253
|
+
return (_jsxs(Part, { title: "Channels", children: [why ? _jsx(Line, { children: why }) : null, rooms.length === 0 && !why ? _jsx(Line, { children: "This org has no channels." }) : null, rooms.map((r) => {
|
|
311
254
|
const mine = bound[r.id] === bot.name;
|
|
312
|
-
return (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, children: r.id }), _jsxs(XStack, { items: "center", gap: 8, children: [_jsx(Text, { fontSize: "$1", color: FAINT, children: r.connected ? bound[r.id] ||
|
|
255
|
+
return (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, children: r.id }), _jsxs(XStack, { items: "center", gap: 8, children: [_jsx(Text, { fontSize: "$1", color: FAINT, children: r.connected ? bound[r.id] || 'unbound' : 'not connected' }), _jsx(Text, { ...TAB, opacity: mine ? 0.5 : 1, disabled: mine, onClick: async () => {
|
|
313
256
|
if (!client)
|
|
314
257
|
return;
|
|
315
258
|
try {
|
|
@@ -318,9 +261,9 @@ function Channels({ bot, rooms, why }) {
|
|
|
318
261
|
await read();
|
|
319
262
|
}
|
|
320
263
|
catch (e) {
|
|
321
|
-
setFailed(say(e,
|
|
264
|
+
setFailed(say(e, 'this channel', 'save'));
|
|
322
265
|
}
|
|
323
|
-
}, children:
|
|
266
|
+
}, children: mine ? 'Answers' : 'Answer' })] })] }, r.id));
|
|
324
267
|
}), failed ? _jsx(Line, { children: failed }) : null] }));
|
|
325
268
|
}
|
|
326
269
|
/**
|
|
@@ -332,7 +275,6 @@ function Channels({ bot, rooms, why }) {
|
|
|
332
275
|
* set is refused by the platform naming it, and the refusal is what is shown.
|
|
333
276
|
*/
|
|
334
277
|
function Code({ bot, repos, why }) {
|
|
335
|
-
const { t, locale } = useI18n();
|
|
336
278
|
const { client } = useAi();
|
|
337
279
|
const withRepo = repos.filter((p) => p.repo?.url);
|
|
338
280
|
const [repo, setRepo] = useState('');
|
|
@@ -343,7 +285,7 @@ function Code({ bot, repos, why }) {
|
|
|
343
285
|
if (!repo && withRepo[0])
|
|
344
286
|
setRepo(withRepo[0].slug);
|
|
345
287
|
}, [repo, withRepo]);
|
|
346
|
-
return (_jsxs(Part, { title:
|
|
288
|
+
return (_jsxs(Part, { title: "Code", children: [why ? _jsx(Line, { children: why }) : null, withRepo.length === 0 && !why ? (_jsx(Line, { children: "No project in this org names a repo, so there is nothing for this bot to work on." })) : (_jsxs(YStack, { render: "form", onSubmit: async (e) => {
|
|
347
289
|
e.preventDefault();
|
|
348
290
|
if (!client || busy || !repo || !task.trim())
|
|
349
291
|
return;
|
|
@@ -351,7 +293,7 @@ function Code({ bot, repos, why }) {
|
|
|
351
293
|
setSaid(null);
|
|
352
294
|
try {
|
|
353
295
|
const started = await workOn(client, { repo, prompt: task.trim(), agentRef: bot.name, project: repo });
|
|
354
|
-
setSaid(
|
|
296
|
+
setSaid(`Started ${started.sessionId || started.id || 'a run'} on ${repo}.`);
|
|
355
297
|
setTask('');
|
|
356
298
|
}
|
|
357
299
|
catch (err) {
|
|
@@ -360,14 +302,11 @@ function Code({ bot, repos, why }) {
|
|
|
360
302
|
finally {
|
|
361
303
|
setBusy(false);
|
|
362
304
|
}
|
|
363
|
-
}, gap: 6, children: [_jsx(Picker, { ...PICK, value: repo, onChange: (e) => setRepo(e.target.value), "aria-label":
|
|
305
|
+
}, gap: 6, children: [_jsx(Picker, { ...PICK, value: repo, onChange: (e) => setRepo(e.target.value), "aria-label": "Repo", children: withRepo.map((p) => (_jsx("option", { value: p.slug, children: p.slug }, p.id))) }), _jsx(Input, { ...BOXED, "data-hz": "task", value: task, onChange: (e) => setTask(e.target.value), placeholder: "What to change", "aria-label": "What to change" }), _jsx(Text, { ...TAB, type: 'submit', "data-hz": "code", self: "flex-start", disabled: busy || !task.trim(), children: busy ? 'Starting…' : 'Work on it' })] })), said ? _jsx(Line, { children: said }) : null] }));
|
|
364
306
|
}
|
|
365
307
|
/** The names under this Bot's KMS prefix. The values stay in KMS. */
|
|
366
308
|
function Secrets({ bot, keys, why }) {
|
|
367
|
-
|
|
368
|
-
return (_jsxs(Part, { title: t('Secrets'), children: [_jsx(Line, { children: t('Held under {path} in KMS. Names are readable here; values are not, by KMS and not by this screen.', {
|
|
369
|
-
path: _jsx(Text, { render: "code", fontSize: "$1", color: INK, children: vault(bot.name) }),
|
|
370
|
-
}) }), why ? _jsx(Line, { children: why }) : null, keys.length === 0 && !why ? _jsx(Line, { children: t('None yet.') }) : null, keys.map((k) => (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, children: k.name }), _jsx(Text, { fontSize: "$1", color: FAINT, children: k.env })] }, `${k.path}/${k.name}`)))] }));
|
|
309
|
+
return (_jsxs(Part, { title: "Secrets", children: [_jsxs(Line, { children: ["Held under ", _jsx(Text, { render: "code", fontSize: "$1", color: INK, children: vault(bot.name) }), " in KMS. Names are readable here; values are not, by KMS and not by this screen."] }), why ? _jsx(Line, { children: why }) : null, keys.length === 0 && !why ? _jsx(Line, { children: "None yet." }) : null, keys.map((k) => (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, children: k.name }), _jsx(Text, { fontSize: "$1", color: FAINT, children: k.env })] }, `${k.path}/${k.name}`)))] }));
|
|
371
310
|
}
|
|
372
311
|
/**
|
|
373
312
|
* The one thing that is NOT this Bot's.
|
|
@@ -378,8 +317,7 @@ function Secrets({ bot, keys, why }) {
|
|
|
378
317
|
* there is no switch to press.
|
|
379
318
|
*/
|
|
380
319
|
function Held({ links, why }) {
|
|
381
|
-
|
|
382
|
-
return (_jsxs(Part, { title: t('Your connectors'), children: [_jsx(Line, { children: t('Signed in by you, reachable by every bot in this org. The platform publishes no per-bot binding for a connector, so nothing here is scoped down to this one.') }), why ? _jsx(Line, { children: why }) : null, links.length === 0 && !why ? _jsx(Line, { children: t('None connected.') }) : null, links.map((l) => (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$1", color: DIM, children: l.label || l.provider }), _jsx(Text, { fontSize: "$1", color: FAINT, children: l.account })] }, l.id)))] }));
|
|
320
|
+
return (_jsxs(Part, { title: "Your connectors", children: [_jsx(Line, { children: "Signed in by you, reachable by every bot in this org. The platform publishes no per-bot binding for a connector, so nothing here is scoped down to this one." }), why ? _jsx(Line, { children: why }) : null, links.length === 0 && !why ? _jsx(Line, { children: "None connected." }) : null, links.map((l) => (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$1", color: DIM, children: l.label || l.provider }), _jsx(Text, { fontSize: "$1", color: FAINT, children: l.account })] }, l.id)))] }));
|
|
383
321
|
}
|
|
384
322
|
function Part({ title, children }) {
|
|
385
323
|
return (_jsxs(YStack, { render: "section", px: 16, py: 14, borderBottomWidth: 1, borderColor: LINE, gap: 8, children: [_jsx(Text, { ...LABEL, children: title }), children] }));
|
package/dist/cast.d.ts
CHANGED
package/dist/cast.js
CHANGED
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
// a person is never cast and shows their own picture or initials.
|
|
15
15
|
import { useEffect, useState } from 'react';
|
|
16
16
|
import { Text, Tooltip, TooltipContent, TooltipTrigger, View, XStack } from '@hanzo/ui';
|
|
17
|
-
import { english } from '
|
|
17
|
+
import { english } from './say.js';
|
|
18
18
|
import { member } from './team.js';
|
|
19
19
|
/** The named crew, keyed by the persona's @-handle. */
|
|
20
20
|
export const CAST = {
|
package/dist/failure.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Refusal } from '@hanzo/ui/product/limits';
|
|
2
|
-
import { type Say } from '
|
|
2
|
+
import { type Say } from './say.js';
|
|
3
3
|
/** Whether the store answered and the answer was no — exported so a surface can
|
|
4
4
|
* offer the way past a refusal rather than only describing it. */
|
|
5
5
|
export declare const refused: (error: unknown) => boolean;
|
package/dist/failure.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// would drift into three vocabularies for one event.
|
|
12
12
|
import { refusalOf } from '@hanzo/ui/product/limits';
|
|
13
13
|
import { told } from './lib/reach.js';
|
|
14
|
-
import { english } from '
|
|
14
|
+
import { english } from './say.js';
|
|
15
15
|
/**
|
|
16
16
|
* THE STATUS, WHERE THE FAILURE CARRIES ONE.
|
|
17
17
|
*
|
package/dist/ground.d.ts
CHANGED
|
@@ -25,6 +25,20 @@ export declare const pane: (fill?: string) => {
|
|
|
25
25
|
* are this high and stand on one line, so the marks in them share a centerline.
|
|
26
26
|
*/
|
|
27
27
|
export declare const BAND = 52;
|
|
28
|
+
/**
|
|
29
|
+
* The head row from a tablet up, px: one rail mark high (Rail `MARK`), so the
|
|
30
|
+
* rail's first mark stands at the pane's top edge and the sidebar's title row
|
|
31
|
+
* and the pane's head share its centre (owner, 2026-10-30: "align sidebar icons
|
|
32
|
+
* top, left, right"). A thumb's mark is 44 on a touch screen, and the rows grow
|
|
33
|
+
* with it (`TOUCH_HEAD`).
|
|
34
|
+
*/
|
|
35
|
+
export declare const HEAD = 36;
|
|
36
|
+
export declare const TOUCH_HEAD = 44;
|
|
37
|
+
/**
|
|
38
|
+
* A row INSIDE a pane is 2px shorter than the row it lines up with: the pane's
|
|
39
|
+
* 1px top edge sets its content 1px down, so its centre stays on the line.
|
|
40
|
+
*/
|
|
41
|
+
export declare const inPane: (row: number) => number;
|
|
28
42
|
/**
|
|
29
43
|
* THE FLOOR under the app's frame (app/_web.tsx, components/settings/Frame.tsx):
|
|
30
44
|
* design's top light falling off down the window over the faint lamps of
|
package/dist/ground.js
CHANGED
|
@@ -25,6 +25,20 @@ export const pane = (fill = 'var(--pane-fill)') => ({
|
|
|
25
25
|
* are this high and stand on one line, so the marks in them share a centerline.
|
|
26
26
|
*/
|
|
27
27
|
export const BAND = 52;
|
|
28
|
+
/**
|
|
29
|
+
* The head row from a tablet up, px: one rail mark high (Rail `MARK`), so the
|
|
30
|
+
* rail's first mark stands at the pane's top edge and the sidebar's title row
|
|
31
|
+
* and the pane's head share its centre (owner, 2026-10-30: "align sidebar icons
|
|
32
|
+
* top, left, right"). A thumb's mark is 44 on a touch screen, and the rows grow
|
|
33
|
+
* with it (`TOUCH_HEAD`).
|
|
34
|
+
*/
|
|
35
|
+
export const HEAD = 36;
|
|
36
|
+
export const TOUCH_HEAD = 44;
|
|
37
|
+
/**
|
|
38
|
+
* A row INSIDE a pane is 2px shorter than the row it lines up with: the pane's
|
|
39
|
+
* 1px top edge sets its content 1px down, so its centre stays on the line.
|
|
40
|
+
*/
|
|
41
|
+
export const inPane = (row) => row - 2;
|
|
28
42
|
/**
|
|
29
43
|
* THE FLOOR under the app's frame (app/_web.tsx, components/settings/Frame.tsx):
|
|
30
44
|
* design's top light falling off down the window over the faint lamps of
|
package/dist/lib/limits.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UseLimits } from '@hanzo/ui/product/useLimits';
|
|
2
2
|
import { paidPlan, type LimitAction, type LimitNotice } from '@hanzo/ui/product/limits';
|
|
3
|
-
import { type Say } from '
|
|
3
|
+
import { type Say } from '../say.js';
|
|
4
4
|
/** Reads the limits as whoever holds the bearer, in this browser's organization. */
|
|
5
5
|
export declare function readLimits(signal: AbortSignal): Promise<unknown>;
|
|
6
6
|
/**
|
package/dist/lib/limits.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { label, said, spent, ways, when } from '@hanzo/build/plan';
|
|
11
11
|
import { useLimits as useHeld } from '@hanzo/ui/product/useLimits';
|
|
12
12
|
import { paidPlan } from '@hanzo/ui/product/limits';
|
|
13
|
-
import { english } from '
|
|
13
|
+
import { english } from '../say.js';
|
|
14
14
|
import { api } from './api.js';
|
|
15
15
|
import { scope } from './session.js';
|
|
16
16
|
/** Reads the limits as whoever holds the bearer, in this browser's organization. */
|
package/dist/lib/org.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* do what: every request carries the reader's bearer and organization (`scope`),
|
|
16
16
|
* the server answers, and a refusal comes back as the server's own sentence.
|
|
17
17
|
*/
|
|
18
|
-
import { type Say } from '
|
|
18
|
+
import { type Say } from '../say.js';
|
|
19
19
|
/**
|
|
20
20
|
* A refusal, with the status it came under and the server's words. One this
|
|
21
21
|
* module words itself keeps its English source and arguments (`source`,
|
|
@@ -124,5 +124,5 @@ export interface Invoice {
|
|
|
124
124
|
paidAt?: string;
|
|
125
125
|
}
|
|
126
126
|
export declare function invoices(): Promise<Invoice[]>;
|
|
127
|
-
/** Whole cents as money
|
|
128
|
-
export declare function cents(n: number, currency?: string
|
|
127
|
+
/** Whole cents as money: `$1,234.56`. */
|
|
128
|
+
export declare function cents(n: number, currency?: string): string;
|
package/dist/lib/org.js
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* do what: every request carries the reader's bearer and organization (`scope`),
|
|
16
16
|
* the server answers, and a refusal comes back as the server's own sentence.
|
|
17
17
|
*/
|
|
18
|
-
import { phrase
|
|
18
|
+
import { phrase } from '@hanzo/i18n';
|
|
19
|
+
import { english } from '../say.js';
|
|
19
20
|
import { scope } from './session.js';
|
|
20
21
|
import { api } from './api.js';
|
|
21
22
|
import { list } from './list.js';
|
|
@@ -153,7 +154,7 @@ export async function methods() {
|
|
|
153
154
|
export async function invoices() {
|
|
154
155
|
return list((await ask('/v1/billing/invoices')).invoices);
|
|
155
156
|
}
|
|
156
|
-
/** Whole cents as money
|
|
157
|
-
export function cents(n, currency = 'usd'
|
|
158
|
-
return new Intl.NumberFormat(
|
|
157
|
+
/** Whole cents as money: `$1,234.56`. */
|
|
158
|
+
export function cents(n, currency = 'usd') {
|
|
159
|
+
return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency.toUpperCase() }).format(n / 100);
|
|
159
160
|
}
|
package/dist/lib/orgname.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* IAM's own onboarding does it (internal/oidc/onboard.go `slugifyOrg`), so the
|
|
9
9
|
* slug shown is the slug IAM makes of the same name.
|
|
10
10
|
*/
|
|
11
|
-
import { type Say } from '
|
|
11
|
+
import { type Say } from '../say.js';
|
|
12
12
|
/** The longest organization name IAM takes. */
|
|
13
13
|
export declare const LONGEST = 55;
|
|
14
14
|
/**
|
package/dist/lib/orgname.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* IAM's own onboarding does it (internal/oidc/onboard.go `slugifyOrg`), so the
|
|
9
9
|
* slug shown is the slug IAM makes of the same name.
|
|
10
10
|
*/
|
|
11
|
-
import { english } from '
|
|
11
|
+
import { english } from '../say.js';
|
|
12
12
|
/** The longest organization name IAM takes. */
|
|
13
13
|
export const LONGEST = 55;
|
|
14
14
|
/**
|
package/dist/lib/pay.d.ts
CHANGED
|
@@ -49,9 +49,5 @@ export declare function payPage(path?: string): string;
|
|
|
49
49
|
/** The pay address with its query, written in one place for both callers above. */
|
|
50
50
|
export declare function payUrl(path: string, query: Record<string, string | null | undefined>): string;
|
|
51
51
|
export declare const dollars: (n: number) => string;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
* locale uses that locale's currency format for USD, so grouping and the
|
|
55
|
-
* currency mark follow the language the reader chose.
|
|
56
|
-
*/
|
|
57
|
-
export declare const money: (n: number, locale?: string) => string;
|
|
52
|
+
/** Money as a sentence says it: whole dollars bare, anything else to the cent — $20, $16.67. */
|
|
53
|
+
export declare const money: (n: number) => string;
|
package/dist/lib/pay.js
CHANGED
|
@@ -67,18 +67,5 @@ export function payUrl(path, query) {
|
|
|
67
67
|
return `${at}${path}${s ? `?${s}` : ""}`;
|
|
68
68
|
}
|
|
69
69
|
export const dollars = (n) => `$${n.toFixed(2)}`;
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
* locale uses that locale's currency format for USD, so grouping and the
|
|
73
|
-
* currency mark follow the language the reader chose.
|
|
74
|
-
*/
|
|
75
|
-
export const money = (n, locale = "en-US") => {
|
|
76
|
-
if (locale === "en-US")
|
|
77
|
-
return Number.isInteger(n) ? `$${n.toLocaleString("en-US")}` : dollars(n);
|
|
78
|
-
return new Intl.NumberFormat(locale, {
|
|
79
|
-
style: "currency",
|
|
80
|
-
currency: "USD",
|
|
81
|
-
minimumFractionDigits: Number.isInteger(n) ? 0 : 2,
|
|
82
|
-
maximumFractionDigits: Number.isInteger(n) ? 0 : 2,
|
|
83
|
-
}).format(n);
|
|
84
|
-
};
|
|
70
|
+
/** Money as a sentence says it: whole dollars bare, anything else to the cent — $20, $16.67. */
|
|
71
|
+
export const money = (n) => (Number.isInteger(n) ? `$${n.toLocaleString("en-US")}` : dollars(n));
|
package/dist/lib/plans.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* read. No price in this repo is typed, and no plan's name: a slug is named by
|
|
30
30
|
* @hanzo/build's `label` (`max-20x` reads Max, with 20x beside it).
|
|
31
31
|
*/
|
|
32
|
-
import { type Say } from "
|
|
32
|
+
import { type Say } from "../say.js";
|
|
33
33
|
/** A row exactly as GET /v1/billing/plans returns it. */
|
|
34
34
|
export interface BillingPlan {
|
|
35
35
|
slug: string;
|
package/dist/lib/plans.js
CHANGED
|
@@ -33,7 +33,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
33
33
|
import { where } from "../where.js";
|
|
34
34
|
import { api } from "./api.js";
|
|
35
35
|
import { billing, checkoutUrl, dollars, money, payUrl } from "./pay.js";
|
|
36
|
-
import { english } from "
|
|
36
|
+
import { english } from "../say.js";
|
|
37
37
|
/**
|
|
38
38
|
* The checkout a plan's CTA opens.
|
|
39
39
|
*
|
package/dist/lib/tier.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Say } from '
|
|
1
|
+
import { type Say } from '../say.js';
|
|
2
2
|
/** The plan, as billing names it. */
|
|
3
3
|
export interface TierLimits {
|
|
4
4
|
name: string;
|
|
@@ -83,7 +83,7 @@ export declare function readSubscription(signal?: AbortSignal): Promise<Subscrip
|
|
|
83
83
|
* price is per seat, so it is the seats times it; a cancelled term ends rather
|
|
84
84
|
* than renews.
|
|
85
85
|
*/
|
|
86
|
-
export declare function renewal(s: Subscription, t?: Say
|
|
86
|
+
export declare function renewal(s: Subscription, t?: Say): string;
|
|
87
87
|
/** The live subscription, held: null while unknown, refused, or on no plan. */
|
|
88
88
|
export declare function useSubscription(enabled?: boolean, org?: string | null): Subscription | null;
|
|
89
89
|
/**
|
package/dist/lib/tier.js
CHANGED
|
@@ -26,11 +26,11 @@ import { api } from './api.js';
|
|
|
26
26
|
import { bearer, org, orgs, scope } from './session.js';
|
|
27
27
|
import { list } from './list.js';
|
|
28
28
|
import { money } from './pay.js';
|
|
29
|
-
import { english } from '
|
|
29
|
+
import { english } from '../say.js';
|
|
30
30
|
/** A period's end as a sentence states it — "Oct 30, 2026" — or '' for none. Periods end on UTC days. */
|
|
31
|
-
function date(iso
|
|
31
|
+
function date(iso) {
|
|
32
32
|
const t = iso ? Date.parse(iso) : NaN;
|
|
33
|
-
return Number.isNaN(t) ? '' : new Date(t).toLocaleDateString(
|
|
33
|
+
return Number.isNaN(t) ? '' : new Date(t).toLocaleDateString('en-US', { timeZone: 'UTC', year: 'numeric', month: 'short', day: 'numeric' });
|
|
34
34
|
}
|
|
35
35
|
/** An error that names the status, for `say()` to turn into a sentence. */
|
|
36
36
|
const refusal = (status, message) => Object.assign(new Error(message), { status });
|
|
@@ -92,9 +92,9 @@ export async function readSubscription(signal) {
|
|
|
92
92
|
* price is per seat, so it is the seats times it; a cancelled term ends rather
|
|
93
93
|
* than renews.
|
|
94
94
|
*/
|
|
95
|
-
export function renewal(s, t = english
|
|
96
|
-
const each = money((s.plan.price * Math.max(1, s.quantity || 1)) / 100
|
|
97
|
-
const when = date(s.currentPeriodEnd
|
|
95
|
+
export function renewal(s, t = english) {
|
|
96
|
+
const each = money((s.plan.price * Math.max(1, s.quantity || 1)) / 100);
|
|
97
|
+
const when = date(s.currentPeriodEnd);
|
|
98
98
|
const interval = s.plan.interval || 'month';
|
|
99
99
|
// A term the catalogue names other than a month or a year is drawn as it names it.
|
|
100
100
|
const price = interval === 'month' ? t('{price}/month', { price: each }) : interval === 'year' ? t('{price}/year', { price: each }) : `${each}/${interval}`;
|