@hanzo/dev 4.0.1 → 4.2.0
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/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +59 -0
- package/dist/builder/api/git.js +117 -0
- package/dist/builder/api/github.d.ts +230 -0
- package/dist/builder/api/github.js +373 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +639 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/github-sync.d.ts +70 -0
- package/dist/builder/github-sync.js +435 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +604 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +187 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* API keys: your keys for calling the Hanzo API from code, as many as you need —
|
|
4
|
+
* a secret key for a server, a publishable key for a page's source. Each is its
|
|
5
|
+
* own credential: creating one never touches another, and revoking one stops only
|
|
6
|
+
* that one. A secret key is shown once, when it is made. A limit narrows what a
|
|
7
|
+
* key reaches; it never reaches further than you do.
|
|
8
|
+
*
|
|
9
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a key's name, its
|
|
10
|
+
* prefix and its kind:name limits are drawn as given.
|
|
11
|
+
*/
|
|
12
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
13
|
+
import { phrase } from '@hanzo/i18n';
|
|
14
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
15
|
+
import { Button, Dialog, DialogContent, DialogTitle, Input } from '@hanzo/ui';
|
|
16
|
+
import { CopyButton } from '@hanzo/ui/product';
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import { told } from '../api/call.js';
|
|
19
|
+
import { keys, KINDS, limits, mint, revoke } from '../api/keys.js';
|
|
20
|
+
import { Confirm } from '../ask.js';
|
|
21
|
+
import { useRead } from '../data.js';
|
|
22
|
+
import { useHost, useTarget } from '../host.js';
|
|
23
|
+
import { Card, Field, Heading, Note, Once, Row, Soft } from './ui.js';
|
|
24
|
+
/** Each kind's words, whole, so a language says the kind its own way: its name, its create control and label, and the dialog's titles. */
|
|
25
|
+
const NAME = { secret: phrase('Secret key'), publishable: phrase('Publishable key') };
|
|
26
|
+
const CREATE = { secret: phrase('Create secret key'), publishable: phrase('Create publishable key') };
|
|
27
|
+
const CREATE_A = { secret: phrase('Create a secret key'), publishable: phrase('Create a publishable key') };
|
|
28
|
+
const NEW = { secret: phrase('Your new secret key'), publishable: phrase('Your new publishable key') };
|
|
29
|
+
/** The statuses IAM names besides active, as words; one it does not is drawn as given. */
|
|
30
|
+
const STATUS = { expired: phrase('Expired'), revoked: phrase('Revoked'), disabled: phrase('Disabled') };
|
|
31
|
+
/** The line under a key: its head, what it reaches, when it was made, and where it stands. */
|
|
32
|
+
function about(k, t) {
|
|
33
|
+
const when = k.created ? new Date(k.created) : null;
|
|
34
|
+
return [
|
|
35
|
+
k.type === 'secret' && k.prefix ? `${k.prefix}…` : '',
|
|
36
|
+
k.type === 'publishable' ? t('Publishable') : '',
|
|
37
|
+
k.limit.length ? t('Reaches {limits}', { limits: k.limit.join(', ') }) : t('Unrestricted'),
|
|
38
|
+
when && !Number.isNaN(when.getTime()) ? t('Created {date}', { date: when.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' }) }) : '',
|
|
39
|
+
k.status !== 'active' ? (STATUS[k.status] ? t(STATUS[k.status]) : k.status[0].toUpperCase() + k.status.slice(1)) : '',
|
|
40
|
+
]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.join(' · ');
|
|
43
|
+
}
|
|
44
|
+
export function Keys() {
|
|
45
|
+
const { t } = useI18n();
|
|
46
|
+
const host = useHost();
|
|
47
|
+
const target = useTarget();
|
|
48
|
+
const signed = Boolean(host.person);
|
|
49
|
+
const list = useRead(signed ? () => keys(target) : null, [], [target, signed]);
|
|
50
|
+
const [making, setMaking] = useState(null);
|
|
51
|
+
const [revoking, setRevoking] = useState(null);
|
|
52
|
+
const [note, setNote] = useState('');
|
|
53
|
+
if (!signed) {
|
|
54
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('API keys') }), _jsx(Soft, { children: t('Sign in to see your API keys.') })] }));
|
|
55
|
+
}
|
|
56
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('API keys'), detail: t('Your keys for calling {api} from code. Make one for each app; revoking one stops only that one.', { api: 'api.hanzo.ai' }) }), _jsx(XStack, { gap: "$2", children: KINDS.map((type) => (_jsx(Button, { size: "sm", variant: "outline", "aria-label": t(CREATE_A[type]), onPress: () => setMaking(type), children: t(CREATE[type]) }, type))) }), list.error ? (_jsx(Soft, { children: told(list.error, t) })) : list.loading && list.value.length === 0 ? (_jsx(Soft, { children: t('Reading your keys…') })) : list.value.length === 0 ? (_jsx(Soft, { children: t('No keys yet.') })) : (_jsx(Card, { children: list.value.map((k, i) => (_jsxs(YStack, { borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", opacity: k.status === 'active' ? 1 : 0.55, children: [_jsx(Row, { first: true, title: k.name || t(NAME[k.type]), detail: about(k, t), trailing: k.status === 'revoked' ? null : (_jsx(Button, { size: "sm", variant: "ghost", "aria-label": t('Revoke {name}', { name: k.name || k.id }), onPress: () => setRevoking(k), children: t('Revoke') })) }), k.type === 'publishable' && k.key ? (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", pb: "$2.5", children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, "aria-label": t('Publishable key'), style: { fontFamily: 'var(--f-mono, ui-monospace, monospace)' }, children: k.key }), _jsx(CopyButton, { value: k.key, label: t('Copy publishable key') })] })) : null] }, k.id))) })), _jsx(Note, { children: note }), _jsx(Making, { type: making, onClose: () => setMaking(null), onMade: (m) => {
|
|
57
|
+
setNote(t('{name} created', { name: m.name || t(NAME[m.type]) }));
|
|
58
|
+
list.reload();
|
|
59
|
+
} }), _jsx(Confirm, { open: revoking !== null, onOpenChange: (o) => !o && setRevoking(null), title: revoking?.name ? t('Revoke {name}?', { name: revoking.name }) : t('Revoke this key?'), says: t('It stops working within a minute, and anything using it is refused. Your other keys keep working.'), act: t('Revoke'),
|
|
60
|
+
// It acts only while it is open, which is while a key is chosen.
|
|
61
|
+
run: async () => {
|
|
62
|
+
await revoke(target, revoking.id);
|
|
63
|
+
setNote(t('{name} revoked', { name: revoking.name || t(NAME[revoking.type]) }));
|
|
64
|
+
list.reload();
|
|
65
|
+
} })] }));
|
|
66
|
+
}
|
|
67
|
+
/** Creating one key: a name and an optional limit, then the key itself, once. */
|
|
68
|
+
function Making({ type, onClose, onMade }) {
|
|
69
|
+
const { t } = useI18n();
|
|
70
|
+
const target = useTarget();
|
|
71
|
+
const [name, setName] = useState('');
|
|
72
|
+
const [limit, setLimit] = useState('');
|
|
73
|
+
const [made, setMade] = useState(null);
|
|
74
|
+
const [working, setWorking] = useState(false);
|
|
75
|
+
const [note, setNote] = useState('');
|
|
76
|
+
const close = () => {
|
|
77
|
+
if (working)
|
|
78
|
+
return;
|
|
79
|
+
setName('');
|
|
80
|
+
setLimit('');
|
|
81
|
+
setMade(null);
|
|
82
|
+
setNote('');
|
|
83
|
+
onClose();
|
|
84
|
+
};
|
|
85
|
+
// Pressed only in the open dialog, which is open only for a type.
|
|
86
|
+
const go = async (type) => {
|
|
87
|
+
setNote('');
|
|
88
|
+
let list;
|
|
89
|
+
try {
|
|
90
|
+
list = limits(limit);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
setNote(told(e, t));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
setWorking(true);
|
|
97
|
+
try {
|
|
98
|
+
const m = await mint(target, type, name, list);
|
|
99
|
+
setMade(m);
|
|
100
|
+
onMade(m);
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
setNote(told(e, t));
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
setWorking(false);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return (_jsx(Dialog, { open: type !== null, onOpenChange: (o) => !o && close(), children: _jsxs(DialogContent, { maxW: 480, showCloseButton: false, children: [_jsx(DialogTitle, { children: made ? t(NEW[made.type]) : type ? t(CREATE_A[type]) : '' }), made ? (_jsxs(YStack, { gap: "$3", children: [made.type === 'secret' ? (_jsx(Once, { value: made.key, label: t('Secret key'), copy: t('Copy secret key') })) : (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", style: { fontFamily: 'var(--f-mono, ui-monospace, monospace)', wordBreak: 'break-all' }, children: made.key }), _jsx(CopyButton, { value: made.key, label: t('Copy publishable key') })] })), made.limit.length ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('It reaches {limits} and nothing else.', { limits: made.limit.join(', ') }) })) : null, _jsx(XStack, { justify: "flex-end", children: _jsx(Button, { size: "sm", onPress: close, children: t('Done') }) })] })) : (_jsxs(YStack, { gap: "$3", children: [_jsx(Field, { label: t('Name'), hint: t('What it is for, so you can tell it from your other keys.'), children: _jsx(Input, { value: name, onChangeText: setName, placeholder: t('production'), "aria-label": t('Name') }) }), _jsx(Field, { label: t('Limit'), hint: t('Optional. What it may reach, as {form} — {examples}, {read} for read-only. Empty reaches whatever you do.', {
|
|
110
|
+
form: 'kind:name',
|
|
111
|
+
examples: 'model:zen5, project:acme, product:train',
|
|
112
|
+
read: 'read:*',
|
|
113
|
+
}), children: _jsx(Input, { value: limit, onChangeText: setLimit, placeholder: "model:zen5, project:acme", "aria-label": t('Limit'), autoCapitalize: "none" }) }), note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: close, children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: () => void go(type), children: t('Create') })] })] }))] }) }));
|
|
114
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Section } from '../route.ts';
|
|
2
|
+
export type Group = 'Settings' | 'Code' | 'Organization';
|
|
3
|
+
export declare const GROUPS: readonly Group[];
|
|
4
|
+
export declare const LIST: readonly {
|
|
5
|
+
id: Section;
|
|
6
|
+
label: string;
|
|
7
|
+
group: Group;
|
|
8
|
+
}[];
|
|
9
|
+
/** A part's label as a list draws it: none for the first part, or where the part's first row already says it (Code). */
|
|
10
|
+
export declare const heading: (g: Group) => string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sections of Settings, in the order the page lists them, by name and part
|
|
3
|
+
* alone: what a sidebar lists without loading the sections themselves
|
|
4
|
+
* (sections.tsx pairs each with its body).
|
|
5
|
+
*
|
|
6
|
+
* A part's id is its name, and every name is English, marked (`phrase`): a
|
|
7
|
+
* list draws each through `t`.
|
|
8
|
+
*/
|
|
9
|
+
import { phrase } from '@hanzo/i18n';
|
|
10
|
+
export const GROUPS = [phrase('Settings'), phrase('Code'), phrase('Organization')];
|
|
11
|
+
export const LIST = [
|
|
12
|
+
{ id: 'general', label: phrase('General'), group: 'Settings' },
|
|
13
|
+
{ id: 'account', label: phrase('Account'), group: 'Settings' },
|
|
14
|
+
{ id: 'privacy', label: phrase('Privacy'), group: 'Settings' },
|
|
15
|
+
{ id: 'billing', label: phrase('Billing'), group: 'Settings' },
|
|
16
|
+
{ id: 'usage', label: phrase('Usage'), group: 'Settings' },
|
|
17
|
+
{ id: 'capabilities', label: phrase('Capabilities'), group: 'Settings' },
|
|
18
|
+
{ id: 'memory', label: phrase('Memory'), group: 'Settings' },
|
|
19
|
+
{ id: 'code', label: phrase('Code'), group: 'Code' },
|
|
20
|
+
{ id: 'environments', label: phrase('Environments'), group: 'Code' },
|
|
21
|
+
{ id: 'machines', label: phrase('Machines'), group: 'Code' },
|
|
22
|
+
{ id: 'keys', label: phrase('API keys'), group: 'Code' },
|
|
23
|
+
{ id: 'members', label: phrase('Members'), group: 'Organization' },
|
|
24
|
+
{ id: 'integrations', label: phrase('Integrations'), group: 'Organization' },
|
|
25
|
+
{ id: 'notifications', label: phrase('Notifications'), group: 'Organization' },
|
|
26
|
+
];
|
|
27
|
+
/** A part's label as a list draws it: none for the first part, or where the part's first row already says it (Code). */
|
|
28
|
+
export const heading = (g) => (g === 'Settings' || LIST.find((e) => e.group === g)?.label === g ? '' : g);
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Machines: the organization's own computers a run can be sent to, beside the
|
|
4
|
+
* Hanzo sandbox. `hanzo link` run on a machine registers it under its hostname
|
|
5
|
+
* and keeps it online while it runs; one can also be registered here by hand.
|
|
6
|
+
* The member who linked a machine, or an org admin, renames it, drains it,
|
|
7
|
+
* mints its claim key or removes it. Under each, the folders its owner lets the
|
|
8
|
+
* web use, and on Hanzo Desktop a way to share one of this computer's
|
|
9
|
+
* (shared.tsx).
|
|
10
|
+
*
|
|
11
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a machine's name,
|
|
12
|
+
* hostname, id and hardware, and the commands to type, are drawn as given.
|
|
13
|
+
*/
|
|
14
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
15
|
+
import { phrase } from '@hanzo/i18n';
|
|
16
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
17
|
+
import { Activity, ChevronDown, ChevronUp, Cloud, Cpu, HardDrive, Info, Laptop, MoreHorizontal, Plus, Server, Terminal, Zap, } from '@hanzogui/lucide-icons-2';
|
|
18
|
+
import { Button, Dialog, DialogContent, DialogTitle, DropdownMenu, Input, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@hanzo/ui';
|
|
19
|
+
import { CopyButton } from '@hanzo/ui/product';
|
|
20
|
+
import { useEffect, useState } from 'react';
|
|
21
|
+
import { told } from '../api/call.js';
|
|
22
|
+
import { add, change, displayMachine, formatBytes, formatPercent, formatRelative, key, KINDS, machineKey, machines, remove, state, } from '../api/machines.js';
|
|
23
|
+
import { Confirm, Rename } from '../ask.js';
|
|
24
|
+
import { useRead } from '../data.js';
|
|
25
|
+
import { useDevMode } from '../dev-mode.js';
|
|
26
|
+
import { useHost, useLocal, useTarget } from '../host.js';
|
|
27
|
+
import { rename, useDeviceNames } from '../names.js';
|
|
28
|
+
import { Shared } from './shared.js';
|
|
29
|
+
import { Card, Field, Group, Heading, Note, Once, Row, Soft } from './ui.js';
|
|
30
|
+
/** What `hanzo link` needs, in the order it is typed on the machine. */
|
|
31
|
+
const LINK = ['hanzo login', 'hanzo link'].join('\n');
|
|
32
|
+
/** How often the list is read again, so a machine that comes up or goes quiet shows it: the agent's beat. */
|
|
33
|
+
const BEAT = 30_000;
|
|
34
|
+
/** The list before its first answer; every answer is a new array, even an empty one. */
|
|
35
|
+
const UNREAD = [];
|
|
36
|
+
/** A machine's status in a line, the platform's word or `not seen yet`, said in the reader's language; one it does not name, as given. */
|
|
37
|
+
const STATES = {
|
|
38
|
+
online: phrase('online'),
|
|
39
|
+
offline: phrase('offline'),
|
|
40
|
+
draining: phrase('draining'),
|
|
41
|
+
'not seen yet': phrase('not seen yet'),
|
|
42
|
+
'': phrase('unknown'),
|
|
43
|
+
};
|
|
44
|
+
/** What a machine is, as the platform names its kinds, said in the reader's language; one it does not name, as given. */
|
|
45
|
+
const KIND = { laptop: phrase('laptop'), gpu: phrase('gpu'), cloud: phrase('cloud'), cluster: phrase('cluster'), machine: phrase('machine') };
|
|
46
|
+
/** A status as a line says it. Code's place list says it the same way. */
|
|
47
|
+
export const said = (status, t) => (status in STATES ? t(STATES[status]) : status);
|
|
48
|
+
const kindOf = (kind, t) => (KIND[kind] ? t(KIND[kind]) : kind);
|
|
49
|
+
/** The line under a machine: what it is, where, how big, and what it is doing. */
|
|
50
|
+
function about(m, t) {
|
|
51
|
+
const load = m.running ? t('{n} running', { n: m.running }) : m.sessions ? t('{n} runs', { n: m.sessions }) : '';
|
|
52
|
+
return [said(state(m), t), kindOf(m.kind, t), m.host && m.host !== m.label ? m.host : '', m.capacity, load].filter(Boolean).join(' · ');
|
|
53
|
+
}
|
|
54
|
+
function Dot({ m }) {
|
|
55
|
+
const on = state(m) === 'online';
|
|
56
|
+
return (_jsx(YStack, { width: 8, height: 8, rounded: 999, shrink: 0, bg: on ? '$green10' : 'transparent', borderWidth: on ? 0 : 1, borderColor: m.status === 'draining' ? '$yellow10' : '$soft', "aria-hidden": true }));
|
|
57
|
+
}
|
|
58
|
+
function KindIcon({ kind, size = 16 }) {
|
|
59
|
+
switch (kind) {
|
|
60
|
+
case 'laptop':
|
|
61
|
+
return _jsx(Laptop, { size: size });
|
|
62
|
+
case 'gpu':
|
|
63
|
+
return _jsx(Cpu, { size: size });
|
|
64
|
+
case 'cloud':
|
|
65
|
+
return _jsx(Cloud, { size: size });
|
|
66
|
+
case 'cluster':
|
|
67
|
+
return _jsx(Server, { size: size });
|
|
68
|
+
default:
|
|
69
|
+
return _jsx(Terminal, { size: size });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function StatusBadge({ m }) {
|
|
73
|
+
const { t } = useI18n();
|
|
74
|
+
const s = state(m);
|
|
75
|
+
if (!s)
|
|
76
|
+
return null;
|
|
77
|
+
let color = '$soft';
|
|
78
|
+
let text = s;
|
|
79
|
+
if (s === 'online') {
|
|
80
|
+
color = '$green10';
|
|
81
|
+
text = t('Online');
|
|
82
|
+
}
|
|
83
|
+
else if (s === 'draining') {
|
|
84
|
+
color = '$yellow10';
|
|
85
|
+
text = t('Draining');
|
|
86
|
+
}
|
|
87
|
+
else if (s === 'not seen yet') {
|
|
88
|
+
color = '$blue10';
|
|
89
|
+
text = t('Not seen yet');
|
|
90
|
+
}
|
|
91
|
+
else if (s === 'offline') {
|
|
92
|
+
color = '$soft';
|
|
93
|
+
text = t('Offline');
|
|
94
|
+
}
|
|
95
|
+
return (_jsxs(XStack, { px: "$2", py: "$0.5", rounded: "$10", borderWidth: 1, borderColor: color, items: "center", gap: "$1.5", children: [_jsx(Dot, { m: m }), _jsx(SizableText, { size: "$1", color: color, fontWeight: "500", children: text })] }));
|
|
96
|
+
}
|
|
97
|
+
export function Machines() {
|
|
98
|
+
const { t } = useI18n();
|
|
99
|
+
const host = useHost();
|
|
100
|
+
const target = useTarget();
|
|
101
|
+
const signed = Boolean(host.person);
|
|
102
|
+
const names = useDeviceNames(signed ? target : null);
|
|
103
|
+
const [devMode] = useDevMode();
|
|
104
|
+
const list = useRead(signed ? () => machines(target) : null, UNREAD, [target, signed]);
|
|
105
|
+
const [adding, setAdding] = useState(false);
|
|
106
|
+
const [renaming, setRenaming] = useState(null);
|
|
107
|
+
const [removing, setRemoving] = useState(null);
|
|
108
|
+
const [keying, setKeying] = useState(null);
|
|
109
|
+
const [minted, setMinted] = useState(null);
|
|
110
|
+
const [expandedId, setExpandedId] = useState(null);
|
|
111
|
+
const [collapsedDevIds, setCollapsedDevIds] = useState({});
|
|
112
|
+
const [showAdvancedLink, setShowAdvancedLink] = useState(false);
|
|
113
|
+
const [note, setNote] = useState('');
|
|
114
|
+
// This computer's hostname, on a host that has the computer: its machine is the one registered under it.
|
|
115
|
+
const local = useLocal();
|
|
116
|
+
const [hostname, setHostname] = useState('');
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
let live = true;
|
|
119
|
+
void local?.host?.().then((h) => live && setHostname(h),
|
|
120
|
+
// A computer that cannot say its name is not found among the machines, and shares nothing from here.
|
|
121
|
+
() => { });
|
|
122
|
+
return () => {
|
|
123
|
+
live = false;
|
|
124
|
+
};
|
|
125
|
+
}, [local]);
|
|
126
|
+
// Read again on the agent's beat; "Reading machines…" stays for the first read only.
|
|
127
|
+
const again = list.reload;
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (!signed)
|
|
130
|
+
return;
|
|
131
|
+
const id = setInterval(again, BEAT);
|
|
132
|
+
return () => clearInterval(id);
|
|
133
|
+
}, [again, signed]);
|
|
134
|
+
if (!signed) {
|
|
135
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Machines') }), _jsx(Soft, { children: t('Sign in to see your linked computers.') })] }));
|
|
136
|
+
}
|
|
137
|
+
const drain = async (m, status) => {
|
|
138
|
+
setNote('');
|
|
139
|
+
try {
|
|
140
|
+
const display = displayMachine(m, { devMode, say: t, names });
|
|
141
|
+
await change(target, m.id, { status });
|
|
142
|
+
setNote(status === 'draining' ? t('{name} takes no new runs', { name: display.title }) : t('{name} takes runs again', { name: display.title }));
|
|
143
|
+
list.reload();
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
setNote(told(e, t));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Machines'), detail: devMode
|
|
150
|
+
? t('Your organization’s own computers. A run sent to one runs there instead of in the cloud workspace.')
|
|
151
|
+
: t('Connect your computer to run tasks locally in your Hanzo folder.') }), _jsxs(Group, { title: t('Link a machine'), detail: t('Run these on your computer. It stays connected while {command} runs.', { command: 'hanzo link' }), children: [_jsxs(XStack, { items: "flex-start", gap: "$2", px: "$3", py: "$2.5", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", "aria-label": t('Link commands'), 'data-i18n-ltr': '', fontFamily: "$mono", "$platform-web": { whiteSpace: 'pre-wrap' }, children: LINK }), _jsx(CopyButton, { value: LINK, label: t('Copy the commands') })] }), _jsxs(XStack, { items: "center", justify: "space-between", flexWrap: "wrap", gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsxs(Button, { size: "sm", variant: "ghost", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 14 }), " ", t('Register one by hand')] }), _jsxs(Button, { size: "sm", variant: "ghost", onPress: () => setShowAdvancedLink(!showAdvancedLink), children: [showAdvancedLink ? _jsx(ChevronUp, { size: 14 }) : _jsx(ChevronDown, { size: 14 }), showAdvancedLink ? t('Hide options') : t('Advanced options')] })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: devMode ? t('Supported: macOS, Linux, Windows, NVIDIA CUDA GPUs, Cloud VMs') : t('Works on macOS, Windows, and Linux') })] }), showAdvancedLink ? (_jsxs(YStack, { gap: "$2.5", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$raised", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: t('1. Background daemon (system service)') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Run worker continuously in the background without keeping a terminal open:') }), _jsxs(XStack, { items: "center", justify: "space-between", px: "$2.5", py: "$1.5", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$ink", 'data-i18n-ltr': '', fontFamily: "$mono", children: "hanzo code --serve" }), _jsx(CopyButton, { value: "hanzo code --serve", label: t('Copy daemon command') })] })] }), _jsxs(YStack, { gap: "$1", pt: "$1", children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: t('2. Install CLI from shell') }), _jsxs(XStack, { items: "center", justify: "space-between", px: "$2.5", py: "$1.5", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$ink", 'data-i18n-ltr': '', fontFamily: "$mono", children: "curl -fsSL https://hanzo.sh | sh" }), _jsx(CopyButton, { value: "curl -fsSL https://hanzo.sh | sh", label: t('Copy install command') })] })] })] })) : null] }), _jsxs(Group, { title: t('Linked'), children: [list.value === UNREAD ? (_jsx(Soft, { children: list.error ? told(list.error, t) : t('Loading devices…') })) : list.value.length === 0 ? (_jsxs(YStack, { gap: "$3", children: [_jsx(Soft, { children: t('No computer is linked yet.') }), _jsx(Card, { children: _jsxs(YStack, { p: "$4", gap: "$3", children: [_jsxs(XStack, { items: "center", gap: "$2.5", children: [_jsx(Server, { size: 20 }), _jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$3", color: "$ink", fontWeight: "600", children: t('Connect your computer') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Run tasks directly on your own computer in your Hanzo folder.') })] })] }), _jsxs(YStack, { gap: "$2", pt: "$1", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", width: 20, children: "1." }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Install Hanzo CLI: {command}', { command: _jsx(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", 'data-i18n-ltr': '', children: "curl -fsSL https://hanzo.sh | sh" }) }) })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", width: 20, children: "2." }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Sign in with your account: {command}', { command: _jsx(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", 'data-i18n-ltr': '', children: "hanzo login" }) }) })] }), _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", width: 20, children: "3." }), _jsx(SizableText, { size: "$2", color: "$ink", children: t('Link the machine: {command}', { command: _jsx(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", 'data-i18n-ltr': '', children: "hanzo link" }) }) })] })] }), _jsx(XStack, { pt: "$1", children: _jsxs(Button, { size: "sm", variant: "outline", onPress: () => setAdding(true), children: [_jsx(Plus, { size: 14 }), " ", t('Register one by hand')] }) })] }) })] })) : (_jsx(Card, { children: list.value.map((m, i) => {
|
|
152
|
+
const display = displayMachine(m, { devMode, say: t, names });
|
|
153
|
+
const showDetails = devMode ? !collapsedDevIds[m.id] : expandedId === m.id;
|
|
154
|
+
const toggleDetails = () => {
|
|
155
|
+
if (devMode) {
|
|
156
|
+
setCollapsedDevIds((prev) => ({ ...prev, [m.id]: !prev[m.id] }));
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
setExpandedId(expandedId === m.id ? null : m.id);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const calmDetail = [
|
|
163
|
+
said(state(m), t),
|
|
164
|
+
m.running ? t('{n} active', { n: m.running }) : m.sessions ? t('{n} runs', { n: m.sessions }) : '',
|
|
165
|
+
]
|
|
166
|
+
.filter(Boolean)
|
|
167
|
+
.join(' · ');
|
|
168
|
+
return (_jsxs(YStack, { borderTopWidth: i > 0 ? 1 : 0, borderColor: "$borderColor", children: [_jsx(Row, { first: i === 0, leading: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Dot, { m: m }), _jsx(KindIcon, { kind: m.kind, size: 16 })] }), title: display.title, detail: devMode ? about(m, t) : calmDetail, trailing: _jsxs(XStack, { items: "center", gap: "$2", children: [!devMode && display.detail ? (_jsx(TooltipProvider, { delay: 150, children: _jsxs(Tooltip, { placement: "top", offset: 6, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": display.detail, p: "$1", opacity: 0.75, children: _jsx(Info, { size: 14, color: "$soft" }) }) }), _jsx(TooltipContent, { maxW: 280, px: "$3", py: "$2", z: "var(--z-popover)", children: _jsx(SizableText, { fontFamily: "$body", size: "$1", color: "$ink", children: display.detail }) })] }) })) : null, _jsx(StatusBadge, { m: m }), m.serving ? (_jsx(XStack, { px: "$1.5", py: "$0.5", rounded: "$10", borderWidth: 1, borderColor: "$green10", children: _jsx(SizableText, { size: "$1", color: "$green10", children: t('Serving') }) })) : null, m.running > 0 ? (_jsxs(XStack, { px: "$1.5", py: "$0.5", rounded: "$10", bg: "$raised", items: "center", gap: "$1", children: [_jsx(Activity, { size: 12, color: "$green10" }), _jsx(SizableText, { size: "$1", color: "$ink", children: t('{n} active', { n: m.running }) })] })) : null, !devMode ? (_jsxs(Button, { size: "sm", variant: "ghost", onPress: toggleDetails, children: [showDetails ? _jsx(ChevronUp, { size: 13 }) : _jsx(ChevronDown, { size: 13 }), showDetails ? t('Hide details') : t('Advanced details')] })) : (_jsx(CopyButton, { value: `hanzo link --target ${m.id}`, label: t('Copy link command for {name}', { name: display.title }) })), _jsx(DropdownMenu, { trigger: _jsx(XStack, { render: "button", "aria-label": t('Actions for {name}', { name: display.title }), px: "$1.5", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(MoreHorizontal, { size: 16 }) }), items: [
|
|
169
|
+
{ key: 'details', label: showDetails ? t('Hide advanced details') : t('Advanced details'), onSelect: toggleDetails },
|
|
170
|
+
{ key: 'rename', label: t('Rename'), onSelect: () => setRenaming(m) },
|
|
171
|
+
...(devMode || showDetails
|
|
172
|
+
? [
|
|
173
|
+
m.status === 'draining'
|
|
174
|
+
? { key: 'online', label: t('Take runs again'), onSelect: () => void drain(m, 'online') }
|
|
175
|
+
: { key: 'drain', label: t('Drain'), description: t('Finish what it has, take nothing new'), onSelect: () => void drain(m, 'draining') },
|
|
176
|
+
{ key: 'key', label: t('Claim key'), onSelect: () => setKeying(m) },
|
|
177
|
+
]
|
|
178
|
+
: []),
|
|
179
|
+
{ type: 'separator' },
|
|
180
|
+
{ key: 'remove', label: t('Remove'), destructive: true, onSelect: () => setRemoving(m) },
|
|
181
|
+
] })] }) }), _jsx(Shared, { m: m, here: hostname !== '' && m.host === hostname, onChanged: list.reload }), showDetails ? (_jsxs(YStack, { px: "$4", pb: "$3", pt: "$1", gap: "$2.5", children: [m.spec ? (_jsxs(XStack, { flexWrap: "wrap", gap: "$2", items: "center", children: [m.spec.os ? (_jsxs(XStack, { px: "$2", py: "$1", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", children: [_jsx(Terminal, { size: 12 }), _jsxs(SizableText, { size: "$1", color: "$ink", children: [m.spec.os, m.spec.arch ? ` · ${m.spec.arch}` : ''] })] })) : null, m.spec.cpus ? (_jsxs(XStack, { px: "$2", py: "$1", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", children: [_jsx(Cpu, { size: 12 }), _jsx(SizableText, { size: "$1", color: "$ink", children: t('{n} cores', { n: m.spec.cpus }) })] })) : null, m.spec.memory ? (_jsxs(XStack, { px: "$2", py: "$1", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", children: [_jsx(HardDrive, { size: 12 }), _jsx(SizableText, { size: "$1", color: "$ink", children: t('{size} RAM', { size: formatBytes(m.spec.memory) }) })] })) : null, m.spec.gpus && m.spec.gpus.length > 0 ? (_jsxs(XStack, { px: "$2", py: "$1", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", items: "center", gap: "$1.5", children: [_jsx(Zap, { size: 12, color: "$yellow10" }), _jsx(SizableText, { size: "$1", color: "$ink", children: m.spec.gpus.map((g) => `${g.model || g.vendor || 'GPU'}${g.memory ? ` (${formatBytes(g.memory)})` : ''}`).join(', ') })] })) : null] })) : null, m.metrics && (m.metrics.cpuUtil || m.metrics.load1 || m.metrics.memUsed || m.metrics.gpuUtil) ? (_jsxs(XStack, { flexWrap: "wrap", gap: "$3", p: "$2.5", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", items: "center", children: [m.metrics.cpuUtil ? (_jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('CPU Utilization') }), _jsxs(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: [formatPercent(m.metrics.cpuUtil), " ", m.metrics.cpuTemp ? `· ${m.metrics.cpuTemp}°C` : ''] })] })) : m.metrics.load1 ? (_jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Load (1m, 5m, 15m)') }), _jsxs(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: [m.metrics.load1, ", ", m.metrics.load5 ?? 0, ", ", m.metrics.load15 ?? 0] })] })) : null, m.metrics.memUsed ? (_jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Memory') }), _jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: m.spec?.memory ? `${formatBytes(m.metrics.memUsed)} / ${formatBytes(m.spec.memory)}` : t('{size} used', { size: formatBytes(m.metrics.memUsed) }) })] })) : null, m.metrics.gpuUtil !== undefined && m.metrics.gpuUtil > 0 ? (_jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('GPU') }), _jsxs(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: [formatPercent(m.metrics.gpuUtil), " ", m.metrics.gpuTemp ? `· ${m.metrics.gpuTemp}°C` : '', " ", m.metrics.gpuPower ? `· ${m.metrics.gpuPower}W` : ''] })] })) : null, m.metrics.model ? (_jsxs(YStack, { gap: "$0.5", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Serving Model') }), _jsxs(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: [m.metrics.model, " ", m.metrics.decode ? `(${m.metrics.decode} tok/s)` : ''] })] })) : null] })) : null, _jsxs(XStack, { justify: "space-between", items: "center", flexWrap: "wrap", gap: "$2", pt: "$0.5", children: [_jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: t('ID: {id}', { id: m.id }) }), m.host ? (_jsx(SizableText, { size: "$1", color: "$soft", fontFamily: "$mono", children: m.host })) : null, m.seen ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Last heartbeat: {when}', { when: formatRelative(m.seen) }) })) : null] }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => setKeying(m), children: t('Claim key') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => void drain(m, m.status === 'draining' ? 'online' : 'draining'), children: m.status === 'draining' ? t('Take runs again') : t('Drain') }), _jsxs(XStack, { items: "center", gap: "$1", px: "$2", py: "$0.5", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", children: [_jsxs(SizableText, { size: "$1", color: "$ink", 'data-i18n-ltr': '', fontFamily: "$mono", children: ["hanzo run --target ", m.id] }), _jsx(CopyButton, { value: `hanzo run --target ${m.id}`, label: t('Copy run command for {name}', { name: display.title }) })] })] })] })] })) : null] }, m.id));
|
|
182
|
+
}) })), list.error && list.value !== UNREAD ? _jsx(Soft, { children: told(list.error, t) }) : null] }), _jsx(Note, { children: note }), _jsx(Adding, { open: adding, onOpenChange: setAdding, onAdded: (m) => {
|
|
183
|
+
setNote(t('{name} is registered', { name: m.label }));
|
|
184
|
+
list.reload();
|
|
185
|
+
} }), _jsx(Rename, { open: renaming !== null, onOpenChange: (o) => !o && setRenaming(null), title: t('Rename machine'), name: renaming ? displayMachine(renaming, { devMode, say: t, names }).title : '',
|
|
186
|
+
// Each dialog acts only while it is open, which is while its machine is chosen. The name is the person's, kept on
|
|
187
|
+
// their account (names.ts): the machine's own record is renamed back to its hostname by its next heartbeat.
|
|
188
|
+
run: async (label) => {
|
|
189
|
+
// Typed back to the name it has by default, it keeps no name of the person's.
|
|
190
|
+
const own = displayMachine(renaming, { devMode, say: t }).title;
|
|
191
|
+
await rename(machineKey(renaming), label === own ? '' : label, target);
|
|
192
|
+
setNote(t('Renamed to {name}', { name: label }));
|
|
193
|
+
} }), _jsx(Confirm, { open: removing !== null, onOpenChange: (o) => !o && setRemoving(null), title: removing ? t('Remove {name}?', { name: displayMachine(removing, { devMode, say: t, names }).title }) : t('Remove this machine?'), says: t('Runs can no longer be sent to it, and its claim key stops working. Linking it again registers it anew.'), act: t('Remove'), run: async () => {
|
|
194
|
+
await remove(target, removing.id);
|
|
195
|
+
setNote(t('{name} is removed', { name: displayMachine(removing, { devMode, say: t, names }).title }));
|
|
196
|
+
list.reload();
|
|
197
|
+
} }), _jsx(Confirm, { open: keying !== null, onOpenChange: (o) => !o && setKeying(null), title: keying ? t('Mint a claim key for {name}?', { name: displayMachine(keying, { devMode, say: t, names }).title }) : t('Mint a claim key for this machine?'), says: t('A key it had before stops working, so a runner using it stops getting runs until it has the new one. The new key is shown once.'), act: t('Mint key'), run: async () => {
|
|
198
|
+
const k = await key(target, keying.id);
|
|
199
|
+
setMinted({ machine: keying, key: k });
|
|
200
|
+
} }), _jsx(Dialog, { open: minted !== null, onOpenChange: (o) => !o && setMinted(null), children: _jsxs(DialogContent, { maxW: 480, showCloseButton: false, children: [_jsx(DialogTitle, { children: t('Claim key for {name}', { name: minted ? displayMachine(minted.machine, { devMode, say: t, names }).title : '' }) }), minted ? (_jsxs(YStack, { gap: "$3", children: [_jsx(Once, { value: minted.key, label: t('Claim key'), copy: t('Copy claim key'), children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('A runner on this machine sends it as {header} when it claims the runs sent here, at {route}.', {
|
|
201
|
+
header: 'X-Target-Key',
|
|
202
|
+
route: `POST /v1/agent/targets/${minted.machine.id}/claim`,
|
|
203
|
+
}) }) }), _jsxs(YStack, { gap: "$1", p: "$2.5", rounded: "$2", bg: "$raised", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$ink", fontWeight: "600", children: t('Start background worker with this key:') }), _jsxs(XStack, { items: "center", justify: "space-between", px: "$2", py: "$1", rounded: "$2", bg: "$raised", children: [_jsxs(SizableText, { size: "$1", color: "$ink", 'data-i18n-ltr': '', fontFamily: "$mono", children: ["export HANZO_TARGET_KEY=\"", minted.key, "\""] }), _jsx(CopyButton, { value: `export HANZO_TARGET_KEY="${minted.key}"\nhanzo code --serve --target ${minted.machine.id}`, label: t('Copy key command') })] })] })] })) : null, _jsx(XStack, { justify: "flex-end", pt: "$2", children: _jsx(Button, { size: "sm", onPress: () => setMinted(null), children: t('Done') }) })] }) })] }));
|
|
204
|
+
}
|
|
205
|
+
/** Registering a machine by hand: its name, what it is, and the hostname its runs report. */
|
|
206
|
+
function Adding({ open, onOpenChange, onAdded }) {
|
|
207
|
+
const { t } = useI18n();
|
|
208
|
+
const target = useTarget();
|
|
209
|
+
const [label, setLabel] = useState('');
|
|
210
|
+
const [kind, setKind] = useState('machine');
|
|
211
|
+
const [hostname, setHostname] = useState('');
|
|
212
|
+
const [capacity, setCapacity] = useState('');
|
|
213
|
+
const [working, setWorking] = useState(false);
|
|
214
|
+
const [note, setNote] = useState('');
|
|
215
|
+
const close = () => {
|
|
216
|
+
if (working)
|
|
217
|
+
return;
|
|
218
|
+
setLabel('');
|
|
219
|
+
setKind('machine');
|
|
220
|
+
setHostname('');
|
|
221
|
+
setCapacity('');
|
|
222
|
+
setNote('');
|
|
223
|
+
onOpenChange(false);
|
|
224
|
+
};
|
|
225
|
+
const save = async () => {
|
|
226
|
+
setWorking(true);
|
|
227
|
+
setNote('');
|
|
228
|
+
try {
|
|
229
|
+
const targetLabel = label.trim() || hostname.trim();
|
|
230
|
+
if (!targetLabel)
|
|
231
|
+
throw new Error(phrase('A machine needs a name or a hostname'));
|
|
232
|
+
const m = await add(target, { label: targetLabel, kind, host: hostname, capacity: capacity.trim() || undefined });
|
|
233
|
+
setWorking(false);
|
|
234
|
+
onAdded(m);
|
|
235
|
+
close();
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
setNote(told(e, t));
|
|
239
|
+
setWorking(false);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
return (_jsx(Dialog, { open: open, onOpenChange: (o) => !o && close(), children: _jsxs(DialogContent, { maxW: 460, showCloseButton: false, children: [_jsx(DialogTitle, { children: t('Register a machine') }), _jsxs(YStack, { gap: "$3", children: [_jsx(Field, { label: t('Name'), hint: t('Left empty, it takes the hostname.'), children: _jsx(Input, { value: label, onChangeText: setLabel, "aria-label": t('Machine name'), autoFocus: true }) }), _jsx(Field, { label: t('Kind'), children: _jsx(XStack, { flexWrap: "wrap", gap: "$1.5", role: "radiogroup", "aria-label": t('Kind'), children: KINDS.map((k) => (_jsxs(XStack, { render: "button", role: "radio", "aria-checked": k === kind, "aria-label": kindOf(k, t), onPress: () => setKind(k), px: "$2.5", py: "$1", rounded: "$10", borderWidth: 1, borderColor: k === kind ? '$ink' : '$borderColor', items: "center", gap: "$1.5", children: [_jsx(KindIcon, { kind: k, size: 14 }), _jsx(SizableText, { size: "$1", color: k === kind ? '$ink' : '$soft', children: kindOf(k, t) })] }, k))) }) }), _jsx(Field, { label: t('Hostname'), hint: t('Optional. What its runs report. {command}, signed in as you on a machine with this hostname, takes this row over.', { command: 'hanzo link' }), children: _jsx(Input, { value: hostname, onChangeText: setHostname, "aria-label": t('Hostname'), autoCapitalize: "none" }) }), _jsx(Field, { label: t('Capacity / Hardware'), hint: t('Optional human summary (e.g. {example}).', { example: '16 vCPU / 64G / 1× RTX 4090' }), children: _jsx(Input, { value: capacity, onChangeText: setCapacity, "aria-label": t('Capacity'), placeholder: t('e.g. {example}', { example: '16 vCPU / 64G / 1× RTX 4090' }) }) }), note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null, _jsxs(XStack, { gap: "$2", justify: "flex-end", children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: working, onPress: close, children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: () => void save(), children: t('Register') })] })] })] }) }));
|
|
243
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Members(): import("react").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Members: who is in the organization and in what role, and — for an org admin —
|
|
4
|
+
* who has been invited, inviting someone by email, and withdrawing an invitation.
|
|
5
|
+
* IAM holds both lists and decides who may read and write them.
|
|
6
|
+
*
|
|
7
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a person's name,
|
|
8
|
+
* address and id, an invitation's code and IAM's own state are drawn as given.
|
|
9
|
+
*/
|
|
10
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
11
|
+
import { phrase } from '@hanzo/i18n';
|
|
12
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
13
|
+
import { UserPlus } from '@hanzogui/lucide-icons-2';
|
|
14
|
+
import { Button, Input } from '@hanzo/ui';
|
|
15
|
+
import { useState } from 'react';
|
|
16
|
+
import { told } from '../api/call.js';
|
|
17
|
+
import { EMAIL, invitations, invite, revoke, roster } from '../api/members.js';
|
|
18
|
+
import { useRead } from '../data.js';
|
|
19
|
+
import { useHost, useTarget } from '../host.js';
|
|
20
|
+
import { Card, day, Group, Heading, Note, Row, Soft } from './ui.js';
|
|
21
|
+
/** A role by its name, English and marked (`phrase`), drawn through `t`. */
|
|
22
|
+
const ROLE = { owner: phrase('Owner'), admin: phrase('Admin'), member: phrase('Member') };
|
|
23
|
+
function Initial({ name }) {
|
|
24
|
+
return (_jsx(YStack, { width: 28, height: 28, rounded: 999, bg: "$raised", items: "center", justify: "center", shrink: 0, children: _jsx(SizableText, { size: "$2", color: "$ink", children: (name || '?').charAt(0).toUpperCase() }) }));
|
|
25
|
+
}
|
|
26
|
+
export function Members() {
|
|
27
|
+
const { t } = useI18n();
|
|
28
|
+
const host = useHost();
|
|
29
|
+
const target = useTarget();
|
|
30
|
+
const org = host.org ?? '';
|
|
31
|
+
const signed = Boolean(host.person && org);
|
|
32
|
+
const people = useRead(signed ? () => roster(target, org) : null, [], [target, org, signed]);
|
|
33
|
+
const asked = useRead(signed && host.admin ? () => invitations(target, org) : null, [], [target, org, signed, host.admin]);
|
|
34
|
+
const [email, setEmail] = useState('');
|
|
35
|
+
const [working, setWorking] = useState(false);
|
|
36
|
+
const [note, setNote] = useState('');
|
|
37
|
+
if (!signed) {
|
|
38
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Members') }), _jsx(Soft, { children: host.person ? t('Choose an organization to see its members.') : t('Sign in to see this organization’s members.') })] }));
|
|
39
|
+
}
|
|
40
|
+
const act = async (what, done, after) => {
|
|
41
|
+
setWorking(true);
|
|
42
|
+
setNote('');
|
|
43
|
+
try {
|
|
44
|
+
await what();
|
|
45
|
+
after();
|
|
46
|
+
setNote(done);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
setNote(told(e, t));
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setWorking(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const send = () => {
|
|
56
|
+
const address = email.trim();
|
|
57
|
+
// Invite is offered only once something is typed.
|
|
58
|
+
if (!EMAIL.test(address)) {
|
|
59
|
+
setNote(t('{email} is not an email address', { email: address }));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
void act(() => invite(target, org, address), t('{email} is invited. IAM sends no email: share the code with them.', { email: address }), () => {
|
|
63
|
+
setEmail('');
|
|
64
|
+
asked.reload();
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const open = asked.value.filter((i) => i.state === 'Active' && i.used < i.seats);
|
|
68
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Members'), detail: t('The people who can act in {org}, and the role each one holds.', { org }) }), _jsx(Group, { title: t('Members'), detail: people.value.length ? t('{n} in {org}', { n: people.value.length, org }) : undefined, children: people.error ? (_jsx(Soft, { children: told(people.error, t) })) : people.loading && !people.value.length ? (_jsx(Soft, { children: t('Reading members…') })) : people.value.length === 0 ? (_jsx(Card, { children: _jsx(Soft, { children: t('No one is on this organization’s roster yet.') }) })) : (_jsx(Card, { children: people.value.map((m, i) => (_jsx(Row, { first: i === 0, leading: _jsx(Initial, { name: m.name }), title: m.name, detail: [m.user, m.since ? t('since {day}', { day: day(m.since) }) : ''].filter(Boolean).join(' · '), trailing: _jsx(SizableText, { size: "$1", color: m.role === 'member' ? '$soft' : '$ink', children: t(ROLE[m.role]) }) }, m.user))) })) }), host.admin ? (_jsxs(Group, { title: t('Invitations'), detail: t('An invitation is a one-seat code for one address, redeemed when that person signs up.'), children: [_jsxs(Card, { children: [_jsxs(XStack, { gap: "$2", items: "center", px: "$3", py: "$3", flexWrap: "wrap", children: [_jsx(YStack, { flex: 1, minW: 200, children: _jsx(Input, { value: email, onChangeText: setEmail, placeholder: "name@company.com", "aria-label": t('Email to invite'), inputMode: "email", autoCapitalize: "none" }) }), _jsxs(Button, { size: "sm", disabled: working || !email.trim(), onPress: send, children: [_jsx(UserPlus, { size: 14 }), " ", t('Invite')] })] }), asked.error ? (_jsx(YStack, { borderTopWidth: 1, borderColor: "$borderColor", children: _jsx(Soft, { children: told(asked.error, t) }) })) : null, asked.value.map((i) => (_jsx(Row, { title: i.email || i.name, mono: !i.email, detail: [
|
|
69
|
+
i.code ? t('Code {code}', { code: i.code }) : '',
|
|
70
|
+
t('{used} of {seats} joined', { used: i.used, seats: i.seats }),
|
|
71
|
+
// IAM's own word for a state, as given; none at all is ours.
|
|
72
|
+
i.state !== 'Active' ? i.state.toLowerCase() || t('not redeemable') : '',
|
|
73
|
+
day(i.created) ? t('invited {day}', { day: day(i.created) }) : '',
|
|
74
|
+
]
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.join(' · '), trailing: _jsx(Button, { size: "sm", variant: "ghost", disabled: working, "aria-label": t('Revoke the invitation for {who}', { who: i.email || i.name }), onPress: () => void act(() => revoke(target, i), t('The invitation is withdrawn'), asked.reload), children: t('Revoke') }) }, i.name)))] }), !asked.loading && !asked.error && asked.value.length > 0 && open.length === 0 ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('Every invitation has been used or stopped.') })) : null] })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: t('An org admin invites people and sees the open invitations.') })), _jsx(Note, { children: note })] }));
|
|
77
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Memory(): import("react").JSX.Element;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Memory: what Hanzo remembers about the person in this organization, newest
|
|
4
|
+
* first. Each can be forgotten, and anything said in the box is remembered as
|
|
5
|
+
* written. The memories are the person's own; nobody else in the organization
|
|
6
|
+
* reads them.
|
|
7
|
+
*
|
|
8
|
+
* Its words are the reader's language (@hanzo/i18n `t`); a memory is drawn as
|
|
9
|
+
* it was said.
|
|
10
|
+
*/
|
|
11
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
12
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
13
|
+
import { Trash2 } from '@hanzogui/lucide-icons-2';
|
|
14
|
+
import { Button, Input } from '@hanzo/ui';
|
|
15
|
+
import { useState } from 'react';
|
|
16
|
+
import { told } from '../api/call.js';
|
|
17
|
+
import { forget, memories, remember } from '../api/memory.js';
|
|
18
|
+
import { useRead } from '../data.js';
|
|
19
|
+
import { useHost, useTarget } from '../host.js';
|
|
20
|
+
import { Card, Group, Heading, Note, Soft } from './ui.js';
|
|
21
|
+
/** A platform time as a date, or '' when it is not one. */
|
|
22
|
+
const day = (at) => {
|
|
23
|
+
const d = new Date(at);
|
|
24
|
+
return Number.isNaN(d.getTime()) ? '' : d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
|
25
|
+
};
|
|
26
|
+
export function Memory() {
|
|
27
|
+
const { t } = useI18n();
|
|
28
|
+
const host = useHost();
|
|
29
|
+
const target = useTarget();
|
|
30
|
+
const signed = Boolean(host.person);
|
|
31
|
+
const list = useRead(signed ? () => memories(target) : null, [], [target, signed]);
|
|
32
|
+
const [said, setSaid] = useState('');
|
|
33
|
+
const [busy, setBusy] = useState('');
|
|
34
|
+
const [note, setNote] = useState('');
|
|
35
|
+
if (!signed) {
|
|
36
|
+
return (_jsxs(YStack, { gap: "$5", children: [_jsx(Heading, { title: t('Memory') }), _jsx(Soft, { children: t('Sign in to see what Hanzo remembers.') })] }));
|
|
37
|
+
}
|
|
38
|
+
const act = async (what, run, done) => {
|
|
39
|
+
setBusy(what);
|
|
40
|
+
setNote('');
|
|
41
|
+
try {
|
|
42
|
+
await run();
|
|
43
|
+
list.reload();
|
|
44
|
+
setNote(done);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
setNote(told(e, t));
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setBusy('');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const keep = () => {
|
|
56
|
+
const words = said.trim();
|
|
57
|
+
if (!words)
|
|
58
|
+
return;
|
|
59
|
+
void act('remember', () => remember(target, words), t('Remembered')).then((took) => took && setSaid(''));
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs(YStack, { gap: "$6", children: [_jsx(Heading, { title: t('Memory'), detail: t('What Hanzo remembers about you here, to carry from one run to the next. Only you see it.') }), _jsx(Group, { title: t('Tell Hanzo what to remember or change'), children: _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(YStack, { flex: 1, minW: 0, children: _jsx(Input, { value: said, onChangeText: setSaid, onSubmitEditing: keep, "aria-label": t('Tell Hanzo what to remember or change'), placeholder: t('I prefer small pull requests, one change each.') }) }), _jsx(Button, { size: "sm", disabled: !said.trim() || busy !== '', onPress: keep, children: t('Remember') })] }) }), _jsx(Group, { title: t('What Hanzo remembers'), detail: list.value.length ? (list.value.length === 1 ? t('1 memory, newest first.') : t('{n} memories, newest first.', { n: list.value.length })) : undefined, children: list.error ? (_jsx(Soft, { children: told(list.error, t) })) : list.loading && !list.value.length ? (_jsx(Soft, { children: t('Reading memories…') })) : !list.value.length ? (_jsx(Soft, { children: t('Nothing yet. What you tell Hanzo to remember shows here.') })) : (_jsx(Card, { children: list.value.map((m, i) => (_jsxs(XStack, { items: "flex-start", gap: "$3", px: "$3", py: "$2.5", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: m.content }), _jsx(SizableText, { size: "$1", color: "$soft", children: [m.kind, day(m.updated)].filter(Boolean).join(' · ') })] }), _jsx(Button, { size: "icon-sm", variant: "ghost", "aria-label": t('Forget {memory}', { memory: m.content.slice(0, 60) }), disabled: busy !== '', onPress: () => void act(m.id, () => forget(target, m.id), t('Forgotten')), children: _jsx(Trash2, { size: 14 }) })] }, m.id))) })) }), _jsx(Note, { children: note })] }));
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Notifications(): import("react").JSX.Element;
|