@hanzo/dev 4.0.1 → 4.1.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 +31 -0
- package/dist/builder/api/git.js +47 -0
- package/dist/builder/api/github.d.ts +176 -0
- package/dist/builder/api/github.js +271 -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 +570 -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/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 +591 -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 +164 -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,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coming back from a provider's consent page.
|
|
3
|
+
*
|
|
4
|
+
* A connect names the page it starts on as its return (`here`). The platform
|
|
5
|
+
* keeps that address when it is a Hanzo app page, and its callback lands the
|
|
6
|
+
* person back on it with the answer in the query:
|
|
7
|
+
*
|
|
8
|
+
* ?complete=github&grant=<id> a GitHub connect to finish (POST /v1/provider/github/user/complete)
|
|
9
|
+
* ?connected=<provider>&account=<n> an organization's connector, connected
|
|
10
|
+
* ?error=<provider>&reason=<why> either, refused
|
|
11
|
+
*
|
|
12
|
+
* `useBack` reads that answer once, takes it off the address so a reload does
|
|
13
|
+
* not replay it, finishes a GitHub grant, and says what happened. GitHub
|
|
14
|
+
* connected either way is said on the window too (`changed`), so every surface
|
|
15
|
+
* showing GitHub reads it again, the Hanzo app's Quick setup among them.
|
|
16
|
+
*/
|
|
17
|
+
import { phrase } from '@hanzo/i18n';
|
|
18
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
19
|
+
import { useEffect } from 'react';
|
|
20
|
+
import { changed, complete } from './api/github.js';
|
|
21
|
+
/** The query keys a return carries its answer in. */
|
|
22
|
+
export const ANSWER = ['complete', 'grant', 'connected', 'account', 'error', 'reason'];
|
|
23
|
+
/** The answer a return carried in `search`, or null when it carried none. */
|
|
24
|
+
export function landed(search) {
|
|
25
|
+
const q = new URLSearchParams(search);
|
|
26
|
+
const error = q.get('error');
|
|
27
|
+
if (error)
|
|
28
|
+
return { kind: 'error', provider: error, reason: q.get('reason') ?? '' };
|
|
29
|
+
const grant = q.get('grant');
|
|
30
|
+
const done = q.get('complete');
|
|
31
|
+
if (done && grant)
|
|
32
|
+
return { kind: 'grant', provider: done, grant };
|
|
33
|
+
const connected = q.get('connected');
|
|
34
|
+
if (connected)
|
|
35
|
+
return { kind: 'connected', provider: connected, account: q.get('account') ?? '' };
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/** The decoded key of one `k=v` pair, or '' when it does not decode. */
|
|
39
|
+
function key(pair) {
|
|
40
|
+
try {
|
|
41
|
+
return decodeURIComponent(pair.split('=')[0].replace(/\+/g, ' '));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** `href` without the answer keys, every other pair exactly as written; `href` itself when it carries none. */
|
|
48
|
+
export function clean(href) {
|
|
49
|
+
const url = new URL(href);
|
|
50
|
+
const pairs = url.search.slice(1).split('&').filter(Boolean);
|
|
51
|
+
const kept = pairs.filter((p) => !ANSWER.includes(key(p)));
|
|
52
|
+
if (kept.length === pairs.length)
|
|
53
|
+
return href;
|
|
54
|
+
url.search = kept.length ? `?${kept.join('&')}` : '';
|
|
55
|
+
return url.href;
|
|
56
|
+
}
|
|
57
|
+
/** This page's address, as a connect's return. */
|
|
58
|
+
export function here() {
|
|
59
|
+
return clean(window.location.href);
|
|
60
|
+
}
|
|
61
|
+
const NAMES = { github: 'GitHub', slack: 'Slack' };
|
|
62
|
+
/** A provider id as people write it. */
|
|
63
|
+
export const named = (id) => NAMES[id] ?? (id ? id[0].toUpperCase() + id.slice(1) : phrase('The connection'));
|
|
64
|
+
/**
|
|
65
|
+
* Finish what a return carried, once a person is signed in: `say` gets the
|
|
66
|
+
* sentence, and `after` runs once something was connected. GitHub's own
|
|
67
|
+
* readers hear `changed` instead (api/github.ts `heard`).
|
|
68
|
+
*/
|
|
69
|
+
export function useBack(t, signed, say, after) {
|
|
70
|
+
const { t: words } = useI18n();
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (!signed)
|
|
73
|
+
return;
|
|
74
|
+
const l = landed(window.location.search);
|
|
75
|
+
if (!l)
|
|
76
|
+
return;
|
|
77
|
+
// Off the address first: a grant completes once, and a reload must not try again.
|
|
78
|
+
const next = clean(window.location.href);
|
|
79
|
+
window.history.replaceState(window.history.state, '', next);
|
|
80
|
+
if (l.kind === 'error') {
|
|
81
|
+
// The provider's own reason is said as it came; with none, ours.
|
|
82
|
+
say(l.reason ? `${words(named(l.provider))}: ${l.reason}` : words('{provider}: not connected', { provider: words(named(l.provider)) }));
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (l.kind === 'connected') {
|
|
86
|
+
say(l.account
|
|
87
|
+
? words('{provider} is connected as {account}', { provider: words(named(l.provider)), account: l.account })
|
|
88
|
+
: words('{provider} is connected', { provider: words(named(l.provider)) }));
|
|
89
|
+
// The org's App, installed on a GitHub account.
|
|
90
|
+
if (l.provider === 'github')
|
|
91
|
+
changed();
|
|
92
|
+
after?.();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (l.provider !== 'github')
|
|
96
|
+
return;
|
|
97
|
+
complete(t, l.grant).then((c) => {
|
|
98
|
+
say(c.connected ? words('Connected as @{login}', { login: c.login }) : words('GitHub did not connect; connect again'));
|
|
99
|
+
changed();
|
|
100
|
+
after?.();
|
|
101
|
+
}, (e) => say(e.message));
|
|
102
|
+
// Once per landing: the address is clean after the first run.
|
|
103
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
104
|
+
}, [signed]);
|
|
105
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Host } from './host.tsx';
|
|
2
|
+
/**
|
|
3
|
+
* The builder. Mount it under a gui root (`<Hanzo>`), in a box with a height.
|
|
4
|
+
*
|
|
5
|
+
* `rail={false}` leaves the left column to the host, which lists the builder's
|
|
6
|
+
* places and runs in its own rail with `DevSection`, and the ground to it too:
|
|
7
|
+
* the builder is then a pane of the host's, and paints no background of its own.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Builder({ host, rail }: {
|
|
10
|
+
host: Host;
|
|
11
|
+
rail?: boolean;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The builder: the rail, and whichever pane the address names.
|
|
4
|
+
*
|
|
5
|
+
* / New — the empty state, a composer over the codebase it works on
|
|
6
|
+
* /sess_… one run, live
|
|
7
|
+
* /-/automations scheduled tasks and what ran; /-/automations/<id> one, to edit and run
|
|
8
|
+
* /-/projects the org's repositories on the forge: a project is a repository
|
|
9
|
+
* /-/sync link repositories from GitHub onto the forge
|
|
10
|
+
* /-/issues the forge's issues
|
|
11
|
+
* /-/artifacts the Library: everything you made, in Chat, Dev and Studio
|
|
12
|
+
* /-/templates the public starters
|
|
13
|
+
* /-/customize skills, connectors, plugins and agents
|
|
14
|
+
* /<org>/<repo> a repository's workspace, in this same window
|
|
15
|
+
* /<slug> a deployed site's workspace
|
|
16
|
+
*
|
|
17
|
+
* The rail is the sessions rail every Hanzo surface shares: New, every one of
|
|
18
|
+
* the builder's places (nav.tsx), the org's coding runs newest first with a
|
|
19
|
+
* live status dot, and at the foot the offer of Hanzo in Slack and the account,
|
|
20
|
+
* whose menu opens Settings, Usage, the plans, help and logging out (foot.tsx).
|
|
21
|
+
* Its collapse is an explicit toggle kept per browser.
|
|
22
|
+
*
|
|
23
|
+
* A workspace takes the whole window — it has its own chat column, bar and
|
|
24
|
+
* panes — and its mark leads back here.
|
|
25
|
+
*
|
|
26
|
+
* A host with a rail of its own mounts `<Builder rail={false}>` and draws the
|
|
27
|
+
* builder's places (`nav`, nav.tsx) and runs in that rail (`useSessions`, or
|
|
28
|
+
* `DevSection`, section.tsx): one left column, never two.
|
|
29
|
+
*/
|
|
30
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
31
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
32
|
+
import { Menu, Search } from '@hanzogui/lucide-icons-2';
|
|
33
|
+
import { Button } from '@hanzo/ui';
|
|
34
|
+
import { SessionRail } from '@hanzo/ui/chat';
|
|
35
|
+
import { HanzoMark } from '@hanzo/ui/product';
|
|
36
|
+
import { useMemo, useState } from 'react';
|
|
37
|
+
import { safe } from './api/projects.js';
|
|
38
|
+
import { Profile } from './customize/agents.js';
|
|
39
|
+
import { Customize } from './customize/index.js';
|
|
40
|
+
import { Editor } from './automations.js';
|
|
41
|
+
import { useKept, useRecents } from './data.js';
|
|
42
|
+
import { Forge } from './forge.js';
|
|
43
|
+
import { HostProvider, useHost, useTarget } from './host.js';
|
|
44
|
+
import { Landing } from './landing.js';
|
|
45
|
+
import { nav, NEW } from './nav.js';
|
|
46
|
+
import { Look, PrefsProvider } from './prefs.js';
|
|
47
|
+
import { Project } from './project.js';
|
|
48
|
+
import { Plans } from './plans.js';
|
|
49
|
+
import { path, route } from './route.js';
|
|
50
|
+
import { Run } from './run.js';
|
|
51
|
+
import { dot } from './section.js';
|
|
52
|
+
import { Library } from './library.js';
|
|
53
|
+
import { Templates } from './shelf.js';
|
|
54
|
+
import { Find } from './find.js';
|
|
55
|
+
import { Slack, useWho, Who } from './foot.js';
|
|
56
|
+
import { Settings } from './settings/index.js';
|
|
57
|
+
function Shell() {
|
|
58
|
+
const { t: say } = useI18n();
|
|
59
|
+
const host = useHost();
|
|
60
|
+
const t = useTarget();
|
|
61
|
+
const r = route(host.path);
|
|
62
|
+
const recents = useRecents(t, Boolean(host.person));
|
|
63
|
+
const [collapsed, setCollapsed] = useKept('hanzo.build.rail', false);
|
|
64
|
+
const [drawer, setDrawer] = useState(false);
|
|
65
|
+
const [order, setOrder] = useState('newest');
|
|
66
|
+
const [finding, setFinding] = useState(false);
|
|
67
|
+
const who = useWho();
|
|
68
|
+
const [slack, setSlack] = useKept('hanzo.build.slack', false);
|
|
69
|
+
const go = (p) => {
|
|
70
|
+
setDrawer(false);
|
|
71
|
+
host.go(p);
|
|
72
|
+
};
|
|
73
|
+
const rows = useMemo(() => {
|
|
74
|
+
const list = recents.value.map((s) => ({ id: s.id, title: s.title || say('Untitled session'), status: dot(s) }));
|
|
75
|
+
if (order === 'running')
|
|
76
|
+
list.sort((a, b) => Number(b.status === 'running') - Number(a.status === 'running'));
|
|
77
|
+
return list;
|
|
78
|
+
}, [recents.value, order, say]);
|
|
79
|
+
// The top left, as on claude.ai: the builder's name, which leads to New, and under
|
|
80
|
+
// it the search that finds a session. The organization is the account's, so it is
|
|
81
|
+
// switched from the account menu at the foot. Beside the rail from md up, beside
|
|
82
|
+
// the drawer's button below it — one place at a time.
|
|
83
|
+
const name = _jsx(Name, { onPress: () => go('') });
|
|
84
|
+
// Every place in view, none behind a More; the rail's own New starts a session.
|
|
85
|
+
const links = nav(host, go, say)
|
|
86
|
+
.flatMap((g) => g.links)
|
|
87
|
+
.filter((l) => l.id !== NEW);
|
|
88
|
+
return (_jsxs(XStack, { flex: 1, minH: 0, minW: 0, bg: "$background", children: [_jsxs(YStack, { position: "relative", shrink: 0, children: [_jsx(SessionRail, { onNew: () => go(''), newLabel: say('New session'), searchLabel: say('Search sessions'), fresh: r.kind === 'new', links: links, recents: rows, active: r.kind === 'run' ? r.id : null, onOpen: (id) => go(id), onSort: () => setOrder(order === 'newest' ? 'running' : 'newest'), sortLabel: order === 'newest' ? say('Show running first') : say('Show newest first'), empty: _jsx(SizableText, { size: "$1", color: "$soft", px: "$2", children: !host.person ? say('Sign in to see your sessions.') : recents.error ? say(recents.error.message) : recents.loading ? say('Reading…') : say('No sessions yet.') }), notice: host.person && !slack ? (_jsx(Slack, { onOpen: () => go(path({ kind: 'settings', section: 'integrations' })), onDismiss: () => setSlack(true) })) : undefined, account: host.person
|
|
89
|
+
? {
|
|
90
|
+
// Who, and in which organization, as claude.ai says who and on which plan.
|
|
91
|
+
name: [host.person.name || host.person.email, host.org].filter(Boolean).join(' · '),
|
|
92
|
+
onPress: () => {
|
|
93
|
+
setDrawer(false);
|
|
94
|
+
who.toggle();
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
: { name: say('Sign in'), onPress: () => host.signIn?.() }, collapsed: collapsed, onCollapse: setCollapsed, mark: _jsx(Brand, { org: host.org, logo: host.logo }), pt: collapsed ? undefined : 92, open: drawer, onOpenChange: setDrawer, label: say('Sessions') }), collapsed ? null : (_jsxs(YStack, { position: "absolute", t: 10, l: 8, r: 8, z: 2, gap: "$2.5", "$max-md": { display: 'none' }, children: [_jsx(XStack, { px: "$2.5", children: name }), _jsxs(XStack, { render: "button", "aria-label": say('Search sessions'), onPress: () => setFinding(true), items: "center", gap: "$2", px: "$2.5", height: 34, rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", hoverStyle: { bg: '$hover' }, children: [_jsx(Search, { size: 15, color: "$soft" }), _jsx(SizableText, { size: "$2", color: "$soft", children: say('Search') })] })] })), host.person ? _jsx(Who, { open: who.open, onOpenChange: who.onOpenChange, narrow: collapsed }) : null] }), _jsxs(YStack, { flex: 1, minW: 0, minH: 0, position: "relative", children: [_jsxs(XStack, { height: 48, px: "$2", gap: "$2", items: "center", shrink: 0, $md: { display: 'none' }, children: [_jsx(Button, { variant: "ghost", size: "icon-sm", minW: 40, minH: 40, onPress: () => setDrawer(true), "aria-label": say('Open sessions'), children: _jsx(Menu, { size: 18 }) }), name, _jsx(XStack, { flex: 1 }), _jsx(Button, { variant: "ghost", size: "icon-sm", minW: 40, minH: 40, onPress: () => setFinding(true), "aria-label": say('Search sessions'), children: _jsx(Search, { size: 18 }) })] }), _jsx(Pane, { onStarted: () => recents.reload() })] }), _jsx(Find, { open: finding, onOpenChange: setFinding, recents: rows, onOpen: (id) => { setFinding(false); go(id); } })] }));
|
|
98
|
+
}
|
|
99
|
+
/** The wordmark: the product's name, as its host calls it, which leads to New. */
|
|
100
|
+
function Name({ onPress }) {
|
|
101
|
+
const { name } = useHost();
|
|
102
|
+
return (_jsx(XStack, { render: "button", "aria-label": name, items: "center", onPress: onPress, children: _jsx(SizableText, { size: "$5", fontWeight: "600", color: "$ink", numberOfLines: 1, children: name }) }));
|
|
103
|
+
}
|
|
104
|
+
/** Whichever pane the address names, beside a rail — the builder's or the host's. */
|
|
105
|
+
function Pane({ onStarted }) {
|
|
106
|
+
const host = useHost();
|
|
107
|
+
const r = route(host.path);
|
|
108
|
+
if (r.kind === 'run')
|
|
109
|
+
return _jsx(Run, { id: r.id }, r.id);
|
|
110
|
+
if (r.kind === 'settings')
|
|
111
|
+
return _jsx(Settings, { section: r.section });
|
|
112
|
+
if (r.kind === 'customize')
|
|
113
|
+
return _jsx(Customize, { tab: r.tab }, r.tab);
|
|
114
|
+
if (r.kind === 'agent')
|
|
115
|
+
return _jsx(Profile, { name: r.name }, r.name);
|
|
116
|
+
if (r.kind === 'automation')
|
|
117
|
+
return _jsx(Editor, { id: r.id }, r.id);
|
|
118
|
+
if (r.kind === 'screen') {
|
|
119
|
+
if (r.screen === 'artifacts')
|
|
120
|
+
return _jsx(Library, {});
|
|
121
|
+
if (r.screen === 'templates')
|
|
122
|
+
return _jsx(Templates, {});
|
|
123
|
+
if (r.screen === 'plans')
|
|
124
|
+
return _jsx(Plans, {});
|
|
125
|
+
return _jsx(Forge, { screen: r.screen }, r.screen);
|
|
126
|
+
}
|
|
127
|
+
return (_jsx(Landing, { onStarted: (id) => {
|
|
128
|
+
onStarted?.(id);
|
|
129
|
+
host.go(id);
|
|
130
|
+
} }));
|
|
131
|
+
}
|
|
132
|
+
/** The org's mark: the logo it chose; else the Hanzo mark for Hanzo or a personal account, and an organization's initial. */
|
|
133
|
+
function Brand({ org, logo }) {
|
|
134
|
+
const chosen = logo ? safe(logo) : '';
|
|
135
|
+
if (chosen)
|
|
136
|
+
return _jsx("img", { src: chosen, alt: "", width: 18, height: 18, style: { borderRadius: 4, objectFit: 'cover' } });
|
|
137
|
+
if (!org || org === 'hanzo')
|
|
138
|
+
return _jsx(HanzoMark, { size: 18 });
|
|
139
|
+
const letter = org.charAt(0).toUpperCase();
|
|
140
|
+
return (_jsx(XStack, { width: 18, height: 18, rounded: "$1", items: "center", justify: "center", bg: "$raised", "aria-hidden": true, children: _jsx(SizableText, { size: "$1", fontWeight: "600", color: "$ink", children: letter }) }));
|
|
141
|
+
}
|
|
142
|
+
function Screens({ rail }) {
|
|
143
|
+
const host = useHost();
|
|
144
|
+
const r = route(host.path);
|
|
145
|
+
if (r.kind === 'project')
|
|
146
|
+
return _jsx(Project, { at: { slug: r.slug } }, r.slug);
|
|
147
|
+
if (r.kind === 'repo')
|
|
148
|
+
return _jsx(Project, { at: { org: r.org, name: r.name } }, `${r.org}/${r.name}`);
|
|
149
|
+
if (!rail)
|
|
150
|
+
return _jsx(Pane, {});
|
|
151
|
+
return _jsx(Shell, {});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The builder. Mount it under a gui root (`<Hanzo>`), in a box with a height.
|
|
155
|
+
*
|
|
156
|
+
* `rail={false}` leaves the left column to the host, which lists the builder's
|
|
157
|
+
* places and runs in its own rail with `DevSection`, and the ground to it too:
|
|
158
|
+
* the builder is then a pane of the host's, and paints no background of its own.
|
|
159
|
+
*/
|
|
160
|
+
export function Builder({ host, rail = true }) {
|
|
161
|
+
return (_jsx(HostProvider, { host: host, children: _jsxs(PrefsProvider, { children: [_jsx(Look, {}), _jsx(YStack, { flex: 1, minH: 0, minW: 0, height: "100%", bg: rail ? '$background' : undefined, children: _jsx(Screens, { rail: rail }) })] }) }));
|
|
162
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Target } from './api/call.ts';
|
|
3
|
+
import { type GearState, type Mode } from './gear.ts';
|
|
4
|
+
import type { Composer, Prep, Turn } from './plugin.ts';
|
|
5
|
+
import type { Carried, Modes, Shelf } from '@hanzo/ui/chat';
|
|
6
|
+
/** What the surface lends the plugins: its draft, its files, its way about. */
|
|
7
|
+
export type Lent = Omit<Composer, 'target' | 'show'>;
|
|
8
|
+
export interface Carry {
|
|
9
|
+
gear: GearState;
|
|
10
|
+
skills: Shelf;
|
|
11
|
+
/** The design systems (Studio brands): attach one, or make one by chat. */
|
|
12
|
+
design: Shelf;
|
|
13
|
+
/** The plugins that run for this person (`@` lists the same). */
|
|
14
|
+
plugins: Shelf;
|
|
15
|
+
/** A dialog a plugin opened, for the surface to draw; null when none is. */
|
|
16
|
+
dialog: ReactNode;
|
|
17
|
+
/** Whether a plugin that prepares a message is on. */
|
|
18
|
+
preparing: boolean;
|
|
19
|
+
/** What the plugins that are on add to the message about to go. */
|
|
20
|
+
prep: (turn: Omit<Turn, 'design'>, signal: AbortSignal) => Promise<Prep>;
|
|
21
|
+
/** The chips after `+`: the skills on, Research, and Plan. */
|
|
22
|
+
on: Carried[];
|
|
23
|
+
/** The mode pill: this surface's modes, the conversation's choice among them. */
|
|
24
|
+
mode: Modes<Mode>;
|
|
25
|
+
/** Whether `what` may run: in Manual the person is asked (once, always in this conversation, or not); else yes. */
|
|
26
|
+
allow: (what: Asked) => Promise<boolean>;
|
|
27
|
+
/** The words the gear adds to every message, '' when none. */
|
|
28
|
+
text: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The words skills add to a message: each one's SKILL.md (the org's own before
|
|
32
|
+
* the brand's), at most `max` of each, or its name when no document answers.
|
|
33
|
+
* Chat carries the ones Hanzo chose for a single message the same way
|
|
34
|
+
* (hanzo-inc/app issue 314).
|
|
35
|
+
*/
|
|
36
|
+
export declare function skillsSaid(t: Target, skills: readonly string[], max?: number): Promise<string>;
|
|
37
|
+
/** What Manual asks about: a plugin, or a Dev run. `id` is what "always" remembers. */
|
|
38
|
+
export interface Asked {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
note: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The conversation `key` names (`''` for one not begun), for target `t`.
|
|
45
|
+
* `customize(tab)` opens Dev's Customize on that tab; `modes` are the ones this
|
|
46
|
+
* surface offers (a choice it does not offer reads as Auto).
|
|
47
|
+
*/
|
|
48
|
+
export declare function useCarry(t: Target, key: string, customize: (tab: 'skills') => void, lent: Lent, modes?: readonly Mode[]): Carry;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* What a message carries beside its words, assembled once for Chat and Dev:
|
|
4
|
+
* the conversation's gear (gear.ts) drawn as the `+` menu's shelves and the
|
|
5
|
+
* chips after `+`, and `text` — the words the gear adds to every message, read
|
|
6
|
+
* again whenever the gear changes.
|
|
7
|
+
*
|
|
8
|
+
* skills each picked skill's SKILL.md (the org's own, or the brand's
|
|
9
|
+
* catalogue document): the platform's completion takes no skills
|
|
10
|
+
* field, so the text rides the message
|
|
11
|
+
* memory what Hanzo remembers about the person (GET /v1/ai/memory/list):
|
|
12
|
+
* the platform injects none itself
|
|
13
|
+
* mode Plan: lay the plan out and wait; Auto says nothing; Manual
|
|
14
|
+
* asks the person before each plugin runs for a message (`Allow`)
|
|
15
|
+
*
|
|
16
|
+
* A shelf is offered only where its service answers; a surface adds its own
|
|
17
|
+
* (Chat its agents, Dev its devices) beside these.
|
|
18
|
+
*/
|
|
19
|
+
import { SizableText, XStack } from '@hanzo/gui';
|
|
20
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
21
|
+
import { BookOpen, ListChecks, Palette, ScrollText } from '@hanzogui/lucide-icons-2';
|
|
22
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogTitle } from '@hanzo/ui';
|
|
23
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
24
|
+
import { call, query, unwrap } from './api/call.js';
|
|
25
|
+
import { active, authored, brand as brandSkills, document, nameOf as skillOf } from './api/skills.js';
|
|
26
|
+
import { brand, brands } from './api/studio.js';
|
|
27
|
+
import { useRead } from './data.js';
|
|
28
|
+
import { said as designSaid } from './design.js';
|
|
29
|
+
import { DEV_MODES, MODES, useGear } from './gear.js';
|
|
30
|
+
import { active as lighted, prep, shelf as pluginShelf, usePlugins } from './plugins/index.js';
|
|
31
|
+
/** The most of each skill a message carries. */
|
|
32
|
+
const SKILL_MAX = 16_000;
|
|
33
|
+
/** The memories every message carries at most, newest first. */
|
|
34
|
+
const RECALL = 20;
|
|
35
|
+
/** What Hanzo remembers about the person, newest first, as lines. */
|
|
36
|
+
async function remembered(t) {
|
|
37
|
+
const rows = unwrap(await call(t, 'GET', `/v1/ai/memory/list${query({ limit: RECALL })}`));
|
|
38
|
+
return (Array.isArray(rows) ? rows : [])
|
|
39
|
+
.map((r) => (r && typeof r === 'object' ? String(r.content ?? '') : ''))
|
|
40
|
+
.filter(Boolean);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The words skills add to a message: each one's SKILL.md (the org's own before
|
|
44
|
+
* the brand's), at most `max` of each, or its name when no document answers.
|
|
45
|
+
* Chat carries the ones Hanzo chose for a single message the same way
|
|
46
|
+
* (hanzo-inc/app issue 314).
|
|
47
|
+
*/
|
|
48
|
+
export async function skillsSaid(t, skills, max = SKILL_MAX) {
|
|
49
|
+
if (!skills.length)
|
|
50
|
+
return '';
|
|
51
|
+
const own = t.token() ? await authored(t).catch(() => []) : [];
|
|
52
|
+
const parts = [];
|
|
53
|
+
for (const n of skills) {
|
|
54
|
+
const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
|
|
55
|
+
parts.push(body ? `Use the skill "${n}" where it applies:\n\n${body.slice(0, max)}` : `Use the "${n}" skill where it applies.`);
|
|
56
|
+
}
|
|
57
|
+
return parts.join('\n\n');
|
|
58
|
+
}
|
|
59
|
+
/** The words `skills`, `memory` and `mode` add to a message. */
|
|
60
|
+
async function said(t, skills, memory, mode, design) {
|
|
61
|
+
const parts = [];
|
|
62
|
+
if (design) {
|
|
63
|
+
const b = await brand(t, design).catch(() => null);
|
|
64
|
+
if (b?.name)
|
|
65
|
+
parts.push(designSaid(b));
|
|
66
|
+
}
|
|
67
|
+
const taught = await skillsSaid(t, skills);
|
|
68
|
+
if (taught)
|
|
69
|
+
parts.push(taught);
|
|
70
|
+
if (memory) {
|
|
71
|
+
const lines = await remembered(t).catch(() => []);
|
|
72
|
+
if (lines.length)
|
|
73
|
+
parts.push(`What you remember about the person:\n${lines.map((l) => `- ${l}`).join('\n')}`);
|
|
74
|
+
}
|
|
75
|
+
if (mode === 'plan')
|
|
76
|
+
parts.push('Plan mode: lay out the plan — the steps, what each changes and why — and stop. Change nothing and produce no final work until the person says go.');
|
|
77
|
+
return parts.join('\n\n');
|
|
78
|
+
}
|
|
79
|
+
/** Manual's pause: what is about to run, what it does, and the three answers. Closing it is a no. */
|
|
80
|
+
function Allow({ what, onAnswer }) {
|
|
81
|
+
const { t } = useI18n();
|
|
82
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (o) => !o && onAnswer('deny'), children: _jsxs(DialogContent, { maxW: 440, width: "100%", "data-slot": "allow", children: [_jsx(DialogTitle, { children: t('Allow {name}?', { name: t(what.name) }) }), _jsx(DialogDescription, { children: what.note ? `${t(what.note)}. ${t('Manual asks before each one runs.')}` : t('Manual asks before each one runs.') }), _jsxs(XStack, { justify: "flex-end", gap: "$2", pt: "$3", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "ghost", onPress: () => onAnswer('deny'), children: t('Deny') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => onAnswer('always'), children: _jsx(SizableText, { fontSize: 14, children: t('Always in this chat') }) }), _jsx(Button, { size: "sm", onPress: () => onAnswer('once'), children: t('Allow once') })] })] }) }));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The conversation `key` names (`''` for one not begun), for target `t`.
|
|
86
|
+
* `customize(tab)` opens Dev's Customize on that tab; `modes` are the ones this
|
|
87
|
+
* surface offers (a choice it does not offer reads as Auto).
|
|
88
|
+
*/
|
|
89
|
+
export function useCarry(t, key, customize, lent, modes = DEV_MODES) {
|
|
90
|
+
const { t: say } = useI18n();
|
|
91
|
+
const gear = useGear(t, key);
|
|
92
|
+
const [dialog, show] = useState(null);
|
|
93
|
+
// The composer a plugin acts on, read when it acts: the draft moves under it.
|
|
94
|
+
const lentNow = useRef(lent);
|
|
95
|
+
lentNow.current = lent;
|
|
96
|
+
const composer = useMemo(() => ({
|
|
97
|
+
target: t,
|
|
98
|
+
get draft() {
|
|
99
|
+
return lentNow.current.draft;
|
|
100
|
+
},
|
|
101
|
+
setDraft: (x) => lentNow.current.setDraft(x),
|
|
102
|
+
attach: (f) => lentNow.current.attach(f),
|
|
103
|
+
go: (h) => lentNow.current.go(h),
|
|
104
|
+
show,
|
|
105
|
+
}), [t]);
|
|
106
|
+
const found = usePlugins(t);
|
|
107
|
+
const signed = Boolean(t.token());
|
|
108
|
+
const list = useRead(async () => {
|
|
109
|
+
const [act, own, cat] = await Promise.all([
|
|
110
|
+
signed ? active(t).catch(() => []) : Promise.resolve([]),
|
|
111
|
+
signed ? authored(t).catch(() => []) : Promise.resolve([]),
|
|
112
|
+
brandSkills(t).catch(() => ({ skills: [], products: [] })),
|
|
113
|
+
]);
|
|
114
|
+
const localSkills = [];
|
|
115
|
+
try {
|
|
116
|
+
const raw = typeof localStorage !== 'undefined' ? localStorage.getItem('hanzo_enterprise_settings_v1:plugins') : null;
|
|
117
|
+
if (raw) {
|
|
118
|
+
const parsed = JSON.parse(raw);
|
|
119
|
+
if (Array.isArray(parsed?.skillsAndPlugins)) {
|
|
120
|
+
for (const item of parsed.skillsAndPlugins) {
|
|
121
|
+
if (item?.status === 'enabled' && typeof item?.name === 'string') {
|
|
122
|
+
localSkills.push(item.name);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// ignore
|
|
130
|
+
}
|
|
131
|
+
const standard = [
|
|
132
|
+
'code-review',
|
|
133
|
+
'simplify',
|
|
134
|
+
'security-review',
|
|
135
|
+
'bug-finder',
|
|
136
|
+
'test-writer',
|
|
137
|
+
'refactor',
|
|
138
|
+
'frontend-design',
|
|
139
|
+
'api-design',
|
|
140
|
+
'sql-optimizer',
|
|
141
|
+
'ui-port',
|
|
142
|
+
'app-port',
|
|
143
|
+
'hanzo-cloud',
|
|
144
|
+
'hanzo-base',
|
|
145
|
+
'hanzo-code',
|
|
146
|
+
'hanzo-dev',
|
|
147
|
+
'hanzo-cli',
|
|
148
|
+
'hanzo-commerce',
|
|
149
|
+
'hanzo-bot',
|
|
150
|
+
'hanzo-agent',
|
|
151
|
+
'hanzo-security-review',
|
|
152
|
+
'pdf-analysis',
|
|
153
|
+
'xlsx-modeling',
|
|
154
|
+
'pptx-deck-builder',
|
|
155
|
+
'docx-redline',
|
|
156
|
+
'scientific-research',
|
|
157
|
+
'mcp-builder',
|
|
158
|
+
'webapp-testing',
|
|
159
|
+
];
|
|
160
|
+
const seen = new Set();
|
|
161
|
+
const out = [];
|
|
162
|
+
for (const n of [
|
|
163
|
+
...act.map((s) => skillOf(s.name)),
|
|
164
|
+
...own.map((s) => s.name),
|
|
165
|
+
...localSkills,
|
|
166
|
+
...standard,
|
|
167
|
+
...(Array.isArray(cat?.skills) ? cat.skills.map((s) => s.name) : []),
|
|
168
|
+
]) {
|
|
169
|
+
const clean = typeof n === 'string' ? n.trim() : '';
|
|
170
|
+
if (clean && !seen.has(clean)) {
|
|
171
|
+
seen.add(clean);
|
|
172
|
+
out.push(clean);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
}, [], [t, signed]);
|
|
177
|
+
const names = list.value;
|
|
178
|
+
const { skills, research, memory, design } = gear.gear;
|
|
179
|
+
const mode = modes.includes(gear.gear.mode) ? gear.gear.mode : 'auto';
|
|
180
|
+
const shelf = {
|
|
181
|
+
rows: names.map((n) => ({ id: n, label: n, icon: _jsx(ScrollText, { size: 16 }), on: skills.includes(n) })),
|
|
182
|
+
pick: (id) => gear.toggle('skills', id),
|
|
183
|
+
loading: list.loading,
|
|
184
|
+
error: list.error ? say('The skills could not be read.') : null,
|
|
185
|
+
search: names.length > 8 ? say('Search skills') : undefined,
|
|
186
|
+
empty: say('No skills are on for this organization'),
|
|
187
|
+
manage: { label: say('Manage skills'), onPress: () => customize('skills') },
|
|
188
|
+
browse: { label: say('Browse skills'), onPress: () => customize('skills') },
|
|
189
|
+
};
|
|
190
|
+
const plugins = pluginShelf(found, gear, composer, say);
|
|
191
|
+
// The design systems: Studio's brands, the one store for them.
|
|
192
|
+
const kits = useRead(signed ? () => brands(t) : null, [], [t, signed, design]);
|
|
193
|
+
const named = kits.value.find((b) => b.id === design);
|
|
194
|
+
const designs = {
|
|
195
|
+
rows: kits.value.map((b) => {
|
|
196
|
+
return { id: b.id, label: b.name, note: [b.tokens['--primary'], b.tokens['--accent']].filter((x) => typeof x === 'string').join(' '), icon: _jsx(Palette, { size: 16 }), on: b.id === design };
|
|
197
|
+
}),
|
|
198
|
+
pick: (id) => gear.set({ design: design === id ? '' : id }),
|
|
199
|
+
loading: kits.loading,
|
|
200
|
+
error: kits.error ? say('The design systems could not be read.') : null,
|
|
201
|
+
empty: say('No design systems yet'),
|
|
202
|
+
create: {
|
|
203
|
+
label: say('Create design system'),
|
|
204
|
+
onPress: () => {
|
|
205
|
+
if (!gear.gear.plugins.includes('design'))
|
|
206
|
+
gear.toggle('plugins', 'design');
|
|
207
|
+
// The person's own words to finish, so in their language.
|
|
208
|
+
lentNow.current.setDraft(say('Make me a design system for '));
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
const lit = lighted(found.plugins, gear.gear);
|
|
213
|
+
const on = [
|
|
214
|
+
...skills.map((n) => ({ id: `skill:${n}`, label: n, icon: _jsx(ScrollText, { size: 14 }), onRemove: () => gear.toggle('skills', n) })),
|
|
215
|
+
...(research ? [{ id: 'research', label: say('Research'), icon: _jsx(BookOpen, { size: 14 }), onRemove: () => gear.set({ research: false }) }] : []),
|
|
216
|
+
...(mode === 'plan' ? [{ id: 'plan', label: say('Plan'), icon: _jsx(ListChecks, { size: 14 }), onRemove: () => gear.set({ mode: 'auto' }) }] : []),
|
|
217
|
+
...(design ? [{ id: 'design', label: named?.name ?? say('Design system'), icon: _jsx(Palette, { size: 14 }), onRemove: () => gear.set({ design: '' }) }] : []),
|
|
218
|
+
...lit
|
|
219
|
+
.filter((p) => p.id !== 'research')
|
|
220
|
+
.map((p) => ({ id: `plugin:${p.id}`, label: say(p.name), icon: p.icon, onRemove: () => gear.toggle('plugins', p.id) })),
|
|
221
|
+
];
|
|
222
|
+
const signedIn = Boolean(t.token());
|
|
223
|
+
const [text, setText] = useState('');
|
|
224
|
+
const asked = skills.join('\n');
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (!signedIn && !skills.length) {
|
|
227
|
+
setText(mode === 'plan' ? 'Plan mode: lay out the plan and stop until the person says go.' : '');
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
let live = true;
|
|
231
|
+
void said(t, skills, signedIn ? memory : false, mode, signedIn ? design : '').then((x) => live && setText(x));
|
|
232
|
+
return () => {
|
|
233
|
+
live = false;
|
|
234
|
+
};
|
|
235
|
+
// `skills` is read through `asked`, its contents.
|
|
236
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
237
|
+
}, [t, signedIn, asked, memory, mode, design]);
|
|
238
|
+
// Manual: what is about to run is asked of the person, unless allowed for the rest of the conversation.
|
|
239
|
+
const kept = useRef([]);
|
|
240
|
+
kept.current = gear.gear.allowed;
|
|
241
|
+
const allow = async (what) => {
|
|
242
|
+
if (mode !== 'manual' || kept.current.includes(what.id))
|
|
243
|
+
return true;
|
|
244
|
+
const v = await new Promise((done) => show(_jsx(Allow, { what: what, onAnswer: (x) => {
|
|
245
|
+
show(null);
|
|
246
|
+
done(x);
|
|
247
|
+
} })));
|
|
248
|
+
if (v === 'always') {
|
|
249
|
+
kept.current = [...kept.current, what.id];
|
|
250
|
+
gear.set({ allowed: kept.current });
|
|
251
|
+
}
|
|
252
|
+
return v !== 'deny';
|
|
253
|
+
};
|
|
254
|
+
return {
|
|
255
|
+
gear,
|
|
256
|
+
mode: { value: mode, set: (m) => gear.set({ mode: m }), items: MODES.filter((x) => modes.includes(x.id)) },
|
|
257
|
+
allow,
|
|
258
|
+
skills: shelf,
|
|
259
|
+
plugins,
|
|
260
|
+
dialog,
|
|
261
|
+
on,
|
|
262
|
+
text,
|
|
263
|
+
preparing: lit.length > 0,
|
|
264
|
+
design: designs,
|
|
265
|
+
// A design system a plugin made is attached at once, and the maker turns off: it made one.
|
|
266
|
+
prep: async (turn, signal) => {
|
|
267
|
+
// One plugin at a time, so each pause is its own question.
|
|
268
|
+
const denied = [];
|
|
269
|
+
for (const x of lit)
|
|
270
|
+
if (!signal.aborted && !(await allow({ id: x.id, name: x.name, note: x.note })))
|
|
271
|
+
denied.push(x.id);
|
|
272
|
+
const p = await prep(found.plugins, gear.gear, { ...turn, design }, composer, signal, denied, say);
|
|
273
|
+
if (p.design)
|
|
274
|
+
gear.set({ design: p.design, plugins: gear.gear.plugins.filter((x) => x !== 'design') });
|
|
275
|
+
return p;
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|