@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,50 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Target } from './api/call.ts';
|
|
3
|
+
/** A fenced block an answer wrote out. */
|
|
4
|
+
export interface Artifact {
|
|
5
|
+
/** The name it was given, or what it is: `index.html`, `html block`. */
|
|
6
|
+
name: string;
|
|
7
|
+
body: string;
|
|
8
|
+
/** What a browser should take it as. */
|
|
9
|
+
mime: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RedoAction {
|
|
12
|
+
mode: 'retry' | 'think' | 'web' | 'prompt';
|
|
13
|
+
prompt?: string;
|
|
14
|
+
}
|
|
15
|
+
/** Every fenced block in `text`, in order. */
|
|
16
|
+
export declare function artifacts(text: string): Artifact[];
|
|
17
|
+
/** Whether a browser draws it as a page or a picture rather than as source. */
|
|
18
|
+
export declare const renders: (a: Artifact) => boolean;
|
|
19
|
+
/** The artifact worth opening first: the last page or picture, else the last block. */
|
|
20
|
+
export declare function lead(list: readonly Artifact[]): Artifact | null;
|
|
21
|
+
/** An address for an artifact's own bytes, typed so a browser renders it. */
|
|
22
|
+
export declare const blob: (a: Artifact) => string;
|
|
23
|
+
/** Markdown as a sentence a voice can read: code said as code, marks dropped. */
|
|
24
|
+
export declare function speakable(raw: string): string;
|
|
25
|
+
/** Reads `text` aloud, calls `done` when it stops for any reason, and answers the way to stop it. */
|
|
26
|
+
export type Listen = (text: string, done: () => void) => () => void;
|
|
27
|
+
/** A reader on the platform's voice (`/v1/audio/speech`), one reply at a time on the page. */
|
|
28
|
+
export declare function speaker(t: Target): Listen;
|
|
29
|
+
export type Vote = 'up' | 'down';
|
|
30
|
+
/** Show a verdict at once and send it; if sending fails, put the earlier one back, unless the person has voted again since (`last` counts the votes). */
|
|
31
|
+
export declare function rated(prev: Vote | null, next: Vote, send: ((vote: Vote) => void | Promise<void>) | undefined, set: (to: Vote | null) => void, last: {
|
|
32
|
+
n: number;
|
|
33
|
+
}): void;
|
|
34
|
+
/** Copy, Rate/Vote, Listen, Share, Redo, Branch and Open under an answer; `children` follow them. */
|
|
35
|
+
export declare function Reply({ text, title, listen, onOpen, onRedo, onBranch, onRate, timestamp, children, }: {
|
|
36
|
+
text: string;
|
|
37
|
+
title?: string;
|
|
38
|
+
listen?: Listen;
|
|
39
|
+
onOpen?: () => void;
|
|
40
|
+
onRedo?: (action: RedoAction) => void;
|
|
41
|
+
onBranch?: () => void;
|
|
42
|
+
onRate?: (vote: Vote) => void | Promise<void>;
|
|
43
|
+
timestamp?: string;
|
|
44
|
+
children?: ReactNode;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
/** Which model answered, where the gateway says it was not the one asked for or a router. */
|
|
47
|
+
export declare function Served(_props: {
|
|
48
|
+
served: string;
|
|
49
|
+
asked?: string;
|
|
50
|
+
}): null;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* What sits under an answer, the same in Chat and Dev: copy what was written,
|
|
4
|
+
* rate/vote, listen to it, share it, regenerate/redo it, branch in a new chat,
|
|
5
|
+
* and open what it made in the side panel. A surface adds its own after these.
|
|
6
|
+
*
|
|
7
|
+
* An answer's artifacts are its fenced blocks (`artifacts`): a page, a picture,
|
|
8
|
+
* a file it wrote out whole. One opens as a page tab in the side panel, rendered
|
|
9
|
+
* from its own bytes (`blob`).
|
|
10
|
+
*/
|
|
11
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
12
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
13
|
+
import { Dialog, DialogContent, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, Input, } from '@hanzo/ui';
|
|
14
|
+
import { ArrowUp, Check, Copy, Globe, Lightbulb, Link2, PanelRight, RefreshCw, Share, Square, ThumbsDown, ThumbsUp, Volume2, } from '@hanzogui/lucide-icons-2';
|
|
15
|
+
import { mouth, speech } from '@hanzo/voice';
|
|
16
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
17
|
+
import { copy as toClipboard } from './clipboard.js';
|
|
18
|
+
const FENCE = /```([^\n`]*)\n([\s\S]*?)```/g;
|
|
19
|
+
const MIME = {
|
|
20
|
+
html: 'text/html',
|
|
21
|
+
htm: 'text/html',
|
|
22
|
+
svg: 'image/svg+xml',
|
|
23
|
+
css: 'text/css',
|
|
24
|
+
csv: 'text/csv',
|
|
25
|
+
json: 'application/json',
|
|
26
|
+
md: 'text/markdown',
|
|
27
|
+
markdown: 'text/markdown',
|
|
28
|
+
txt: 'text/plain',
|
|
29
|
+
};
|
|
30
|
+
const suffix = (s) => {
|
|
31
|
+
const dot = s.lastIndexOf('.');
|
|
32
|
+
return dot > 0 ? s.slice(dot + 1).toLowerCase() : '';
|
|
33
|
+
};
|
|
34
|
+
/** An info string is a language, a file name (a dot, no spaces), or both (`html index.html`): the file name wins. */
|
|
35
|
+
const called = (info, n) => {
|
|
36
|
+
const words = info.trim().split(/\s+/).filter(Boolean);
|
|
37
|
+
const file = words.find((w) => w.includes('.') && suffix(w));
|
|
38
|
+
if (file)
|
|
39
|
+
return file;
|
|
40
|
+
return words[0] ? `${words[0]} block` : `Block ${n}`;
|
|
41
|
+
};
|
|
42
|
+
/** Every fenced block in `text`, in order. */
|
|
43
|
+
export function artifacts(text) {
|
|
44
|
+
const out = [];
|
|
45
|
+
let n = 0;
|
|
46
|
+
for (const [, info = '', body = ''] of text.matchAll(FENCE)) {
|
|
47
|
+
n += 1;
|
|
48
|
+
const name = called(info, n);
|
|
49
|
+
out.push({ name, body, mime: MIME[suffix(name) || info.trim().toLowerCase().split(/\s+/)[0] || ''] ?? 'text/plain' });
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
/** Whether a browser draws it as a page or a picture rather than as source. */
|
|
54
|
+
export const renders = (a) => a.mime === 'text/html' || a.mime === 'image/svg+xml';
|
|
55
|
+
/** The artifact worth opening first: the last page or picture, else the last block. */
|
|
56
|
+
export function lead(list) {
|
|
57
|
+
return [...list].reverse().find(renders) ?? list[list.length - 1] ?? null;
|
|
58
|
+
}
|
|
59
|
+
/** An address for an artifact's own bytes, typed so a browser renders it. */
|
|
60
|
+
export const blob = (a) => URL.createObjectURL(new Blob([a.body], { type: a.mime }));
|
|
61
|
+
/** Markdown as a sentence a voice can read: code said as code, marks dropped. */
|
|
62
|
+
export function speakable(raw) {
|
|
63
|
+
return raw
|
|
64
|
+
.replace(/```[\s\S]*?```/g, ' [code snippet] ')
|
|
65
|
+
.replace(/`([^`]+)`/g, '$1')
|
|
66
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
|
67
|
+
.replace(/^#{1,6}\s+/gm, '')
|
|
68
|
+
.replace(/[*_]{1,3}([^*_]+)[*_]{1,3}/g, '$1')
|
|
69
|
+
.replace(/^>\s+/gm, '')
|
|
70
|
+
.replace(/^[-*_]{3,}\s*$/gm, '')
|
|
71
|
+
.replace(/^[\s]*[-+*]\s+/gm, '')
|
|
72
|
+
.replace(/\n+/g, '. ')
|
|
73
|
+
.replace(/\s+/g, ' ')
|
|
74
|
+
.trim();
|
|
75
|
+
}
|
|
76
|
+
let hush = null;
|
|
77
|
+
/** A reader on the platform's voice (`/v1/audio/speech`), one reply at a time on the page. */
|
|
78
|
+
export function speaker(t) {
|
|
79
|
+
return (text, done) => {
|
|
80
|
+
hush?.();
|
|
81
|
+
const said = speakable(text);
|
|
82
|
+
if (!said) {
|
|
83
|
+
done();
|
|
84
|
+
return () => { };
|
|
85
|
+
}
|
|
86
|
+
const lips = mouth({ speech: speech({ baseUrl: t.api, token: t.token }) });
|
|
87
|
+
const stop = () => {
|
|
88
|
+
lips.hush();
|
|
89
|
+
if (hush === stop)
|
|
90
|
+
hush = null;
|
|
91
|
+
};
|
|
92
|
+
hush = stop;
|
|
93
|
+
lips.say(said).then(done, done);
|
|
94
|
+
return stop;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Show a verdict at once and send it; if sending fails, put the earlier one back, unless the person has voted again since (`last` counts the votes). */
|
|
98
|
+
export function rated(prev, next, send, set, last) {
|
|
99
|
+
const mine = ++last.n;
|
|
100
|
+
set(next);
|
|
101
|
+
if (!send)
|
|
102
|
+
return;
|
|
103
|
+
Promise.resolve()
|
|
104
|
+
.then(() => send(next))
|
|
105
|
+
.catch(() => {
|
|
106
|
+
if (last.n === mine)
|
|
107
|
+
set(prev);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/** One quiet control in the row. It rests dim and comes up under a pointer or focus. */
|
|
111
|
+
function Act({ label, onPress, children, lit = false, slot, }) {
|
|
112
|
+
return (_jsx(XStack, { render: "button", role: "button", "aria-label": label, "data-slot": slot, onPress: onPress, items: "center", justify: "center", gap: "$1", px: "$1.5", height: 28, minW: 28, rounded: "$2", cursor: "pointer", bg: lit ? '$hover' : 'transparent', opacity: lit ? 1 : 0.65, hoverStyle: { opacity: 1, bg: '$hover' }, focusStyle: { opacity: 1 }, children: children }));
|
|
113
|
+
}
|
|
114
|
+
/** Copy, Rate/Vote, Listen, Share, Redo, Branch and Open under an answer; `children` follow them. */
|
|
115
|
+
export function Reply({ text, title, listen, onOpen, onRedo, onBranch, onRate, timestamp, children, }) {
|
|
116
|
+
const { t: say } = useI18n();
|
|
117
|
+
const [took, setTook] = useState(false);
|
|
118
|
+
const [speaking, setSpeaking] = useState(false);
|
|
119
|
+
const [vote, setVote] = useState(null);
|
|
120
|
+
const votes = useRef({ n: 0 });
|
|
121
|
+
const [redoOpen, setRedoOpen] = useState(false);
|
|
122
|
+
const [shareOpen, setShareOpen] = useState(false);
|
|
123
|
+
const [shareCopied, setShareCopied] = useState(false);
|
|
124
|
+
const [redoPrompt, setRedoPrompt] = useState('');
|
|
125
|
+
const stop = useRef(null);
|
|
126
|
+
const stamp = useMemo(() => {
|
|
127
|
+
if (timestamp)
|
|
128
|
+
return timestamp;
|
|
129
|
+
try {
|
|
130
|
+
return new Intl.DateTimeFormat(undefined, {
|
|
131
|
+
month: 'short',
|
|
132
|
+
day: 'numeric',
|
|
133
|
+
year: 'numeric',
|
|
134
|
+
hour: 'numeric',
|
|
135
|
+
minute: '2-digit',
|
|
136
|
+
}).format(new Date());
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return 'Just now';
|
|
140
|
+
}
|
|
141
|
+
}, [timestamp]);
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!took)
|
|
144
|
+
return;
|
|
145
|
+
const t = setTimeout(() => setTook(false), 1400);
|
|
146
|
+
return () => clearTimeout(t);
|
|
147
|
+
}, [took]);
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (!shareCopied)
|
|
150
|
+
return;
|
|
151
|
+
const t = setTimeout(() => setShareCopied(false), 1600);
|
|
152
|
+
return () => clearTimeout(t);
|
|
153
|
+
}, [shareCopied]);
|
|
154
|
+
useEffect(() => () => stop.current?.(), []);
|
|
155
|
+
const shareUrl = useMemo(() => {
|
|
156
|
+
if (typeof window === 'undefined')
|
|
157
|
+
return 'https://hanzo.ai/chat';
|
|
158
|
+
return window.location.href;
|
|
159
|
+
}, [shareOpen]);
|
|
160
|
+
const triggerRedo = (payload) => {
|
|
161
|
+
setRedoOpen(false);
|
|
162
|
+
setRedoPrompt('');
|
|
163
|
+
onRedo?.(payload);
|
|
164
|
+
};
|
|
165
|
+
const rate = (next) => rated(vote, next, onRate, setVote, votes.current);
|
|
166
|
+
return (_jsxs(XStack, { "data-slot": "reply", ml: "$-1", items: "center", gap: "$1", flexWrap: "wrap", children: [_jsx(Act, { slot: "reply-copy", label: took ? say('Copied') : say('Copy this answer'), lit: took, onPress: () => void toClipboard(text).then((ok) => ok && setTook(true)), children: took ? _jsx(Check, { size: 15 }) : _jsx(Copy, { size: 15 }) }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Act, { slot: "reply-rate", label: say('Rate this response'), lit: vote !== null, children: vote === 'down' ? _jsx(ThumbsDown, { size: 15 }) : _jsx(ThumbsUp, { size: 15 }) }) }), _jsxs(DropdownMenuContent, { align: "start", minW: 176, "data-slot": "reply-rate-menu", children: [_jsx(DropdownMenuItem, { "data-slot": "reply-rate-up", onSelect: () => rate('up'), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(ThumbsUp, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Good response') })] }) }), _jsx(DropdownMenuItem, { "data-slot": "reply-rate-down", onSelect: () => rate('down'), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(ThumbsDown, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Bad response') })] }) })] })] }), listen ? (_jsx(Act, { slot: "reply-listen", label: speaking ? say('Stop reading') : say('Listen to this answer'), lit: speaking, onPress: () => {
|
|
167
|
+
if (speaking) {
|
|
168
|
+
stop.current?.();
|
|
169
|
+
setSpeaking(false);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
setSpeaking(true);
|
|
173
|
+
stop.current = listen(text, () => setSpeaking(false));
|
|
174
|
+
}, children: speaking ? _jsx(Square, { size: 14 }) : _jsx(Volume2, { size: 15 }) })) : null, _jsx(Act, { slot: "reply-share", label: say('Share message'), lit: shareOpen, onPress: () => setShareOpen(true), children: _jsx(Share, { size: 15 }) }), onRedo ? (_jsxs(DropdownMenu, { open: redoOpen, onOpenChange: setRedoOpen, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Act, { slot: "reply-redo", label: say('Regenerate response'), lit: redoOpen, children: _jsx(RefreshCw, { size: 15 }) }) }), _jsxs(DropdownMenuContent, { align: "start", minW: 232, "data-slot": "reply-redo-menu", children: [_jsxs(XStack, { items: "center", gap: "$1.5", px: "$2", py: "$1.5", children: [_jsx(Input, { "data-slot": "reply-redo-input", placeholder: say('Ask to change response'), value: redoPrompt, onChangeText: setRedoPrompt, onKeyDown: (e) => {
|
|
175
|
+
e.stopPropagation?.();
|
|
176
|
+
if (e.key === 'Enter' && redoPrompt.trim()) {
|
|
177
|
+
e.preventDefault?.();
|
|
178
|
+
triggerRedo({ mode: 'prompt', prompt: redoPrompt.trim() });
|
|
179
|
+
}
|
|
180
|
+
}, flex: 1, size: "sm" }), _jsx(Act, { label: say('Submit change'), lit: Boolean(redoPrompt.trim()), onPress: () => {
|
|
181
|
+
if (redoPrompt.trim()) {
|
|
182
|
+
triggerRedo({ mode: 'prompt', prompt: redoPrompt.trim() });
|
|
183
|
+
}
|
|
184
|
+
}, children: _jsx(ArrowUp, { size: 14 }) })] }), _jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { "data-slot": "redo-retry", onSelect: () => triggerRedo({ mode: 'retry' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(RefreshCw, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Try again') }), _jsx(SizableText, { size: "$2", color: "$hint", children: "\u00B7 Auto" })] }) }), _jsx(DropdownMenuItem, { "data-slot": "redo-think", onSelect: () => triggerRedo({ mode: 'think' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Lightbulb, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Think longer') })] }) }), _jsx(DropdownMenuItem, { "data-slot": "redo-web", onSelect: () => triggerRedo({ mode: 'web' }), children: _jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(Globe, { size: 15 }), _jsx(SizableText, { size: "$2", color: "$ink", children: say('Search the web') })] }) })] })] })) : null, onOpen ? (_jsxs(Act, { slot: "reply-open", label: say('Open in the side panel'), onPress: onOpen, children: [_jsx(PanelRight, { size: 14 }), _jsx(SizableText, { size: "$1", color: "$ink", children: say('Open') })] })) : null, children, _jsx(Dialog, { open: shareOpen, onOpenChange: setShareOpen, children: _jsxs(DialogContent, { maxW: 540, width: "100%", gap: "$3.5", "data-slot": "reply-share-modal", children: [_jsx(DialogTitle, { children: title || say('Conversation') }), _jsx(YStack, { p: "$3.5", rounded: "$4", bg: "$panel", borderWidth: 1, borderColor: "$borderColor", maxH: 220, overflow: "scroll", children: _jsx(SizableText, { size: "$2", color: "$ink", lineHeight: "$4", children: text }) }), _jsxs(XStack, { items: "flex-start", gap: "$2.5", children: [_jsx(Link2, { size: 16 }), _jsxs(YStack, { gap: "$0.5", flex: 1, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", children: say('Copy link to this run') }), _jsx(SizableText, { size: "$1", color: "$soft", children: say('Members of your workspace with access can open this link.') })] })] }), _jsxs(XStack, { items: "center", justify: "center", gap: "$5", pt: "$1", children: [_jsxs(YStack, { render: "button", role: "button", "data-slot": "share-copy-link", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => void toClipboard(shareUrl).then((ok) => ok && setShareCopied(true)), children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: shareCopied ? _jsx(Check, { size: 17 }) : _jsx(Link2, { size: 17 }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: shareCopied ? say('Copied!') : say('Copy link') })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-x", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
185
|
+
const snippet = text.length > 200 ? `${text.slice(0, 197)}...` : text;
|
|
186
|
+
window.open(`https://x.com/intent/tweet?text=${encodeURIComponent(snippet)}&url=${encodeURIComponent(shareUrl)}`, '_blank', 'noopener,noreferrer');
|
|
187
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "\uD835\uDD4F" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "X" })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-linkedin", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
188
|
+
window.open(`https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl)}`, '_blank', 'noopener,noreferrer');
|
|
189
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "in" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "LinkedIn" })] }), _jsxs(YStack, { render: "button", role: "button", "data-slot": "share-reddit", items: "center", gap: "$1.5", cursor: "pointer", onPress: () => {
|
|
190
|
+
window.open(`https://www.reddit.com/submit?url=${encodeURIComponent(shareUrl)}&title=${encodeURIComponent(title || 'Hanzo Chat')}`, '_blank', 'noopener,noreferrer');
|
|
191
|
+
}, children: [_jsx(XStack, { width: 44, height: 44, rounded: 999, bg: "$hover", items: "center", justify: "center", children: _jsx(SizableText, { size: "$3", fontWeight: "700", color: "$ink", children: "r/" }) }), _jsx(SizableText, { size: "$1", color: "$soft", children: "Reddit" })] })] })] }) })] }));
|
|
192
|
+
}
|
|
193
|
+
/** Which model answered, where the gateway says it was not the one asked for or a router. */
|
|
194
|
+
export function Served(_props) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Catalogue, Entry } from './api/skills.ts';
|
|
2
|
+
/** What a person may say they work on, each label English and marked (`phrase`), drawn through `t`. */
|
|
3
|
+
export declare const WORK: {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
/** The most skills one work recommends: a set small enough to read before it is added. */
|
|
8
|
+
export declare const MOST = 8;
|
|
9
|
+
/** The catalogue's skills that recommend themselves for `work`, in catalogue order, at most `MOST`. */
|
|
10
|
+
export declare function recommend(work: string | undefined, catalogue: Catalogue | null): Entry[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a person's work recommends: the skills the catalogue marks (`Entry.works`) for it, so a
|
|
3
|
+
* new person starts with the ones that matter to them switched on rather than a list of hundreds.
|
|
4
|
+
* The work is the account's own (Settings > Account, `Prefs.work`), one list for both.
|
|
5
|
+
*/
|
|
6
|
+
import { phrase } from '@hanzo/i18n';
|
|
7
|
+
/** What a person may say they work on, each label English and marked (`phrase`), drawn through `t`. */
|
|
8
|
+
export const WORK = [
|
|
9
|
+
{ id: 'director', label: phrase('Director or executive') },
|
|
10
|
+
{ id: 'engineering', label: phrase('Software engineering') },
|
|
11
|
+
{ id: 'data', label: phrase('Data science') },
|
|
12
|
+
{ id: 'design', label: phrase('Design') },
|
|
13
|
+
{ id: 'product', label: phrase('Product management') },
|
|
14
|
+
{ id: 'research', label: phrase('Research') },
|
|
15
|
+
{ id: 'writing', label: phrase('Writing') },
|
|
16
|
+
{ id: 'education', label: phrase('Education') },
|
|
17
|
+
{ id: 'operations', label: phrase('Operations') },
|
|
18
|
+
{ id: 'marketing', label: phrase('Marketing and sales') },
|
|
19
|
+
{ id: 'other', label: phrase('Something else') },
|
|
20
|
+
];
|
|
21
|
+
/** The most skills one work recommends: a set small enough to read before it is added. */
|
|
22
|
+
export const MOST = 8;
|
|
23
|
+
/** The catalogue's skills that recommend themselves for `work`, in catalogue order, at most `MOST`. */
|
|
24
|
+
export function recommend(work, catalogue) {
|
|
25
|
+
if (!work || !catalogue)
|
|
26
|
+
return [];
|
|
27
|
+
return catalogue.skills.filter((e) => e.works.includes(work)).slice(0, MOST);
|
|
28
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The builder's addresses, under whatever path the host mounts it at.
|
|
3
|
+
*
|
|
4
|
+
* '' the empty state: a new run
|
|
5
|
+
* sess_<32 hex> one run
|
|
6
|
+
* -/<screen> a builder screen
|
|
7
|
+
* -/artifacts/<kind> the Library narrowed to one kind (image, video, document, …)
|
|
8
|
+
* -/artifacts/new the Library, making something new from a gallery template
|
|
9
|
+
* -/automations/<id> one automation's editor and runs; `new` writes one
|
|
10
|
+
* -/settings[/<section>] a section of Settings
|
|
11
|
+
* -/customize[/<tab>] agents, skills, connectors and plugins: what the agent brings to a run
|
|
12
|
+
* -/customize/agents/<name> one agent's profile
|
|
13
|
+
* -/plans the plans an organization can be on
|
|
14
|
+
* <org>/<repo> a repository's workspace: a project is a repository on the forge
|
|
15
|
+
* <slug> a deployed site's workspace (Artifacts)
|
|
16
|
+
*
|
|
17
|
+
* Unambiguous by construction: a project slug is `^[a-z0-9]([a-z0-9-]{0,38}[a-z0-9])?$`,
|
|
18
|
+
* so it can hold neither the `_` a session id carries nor start with `-`, and a
|
|
19
|
+
* repository is the one address with two segments, each starting with a letter
|
|
20
|
+
* or a digit. Anything else is not an address here and reads as the empty state.
|
|
21
|
+
*
|
|
22
|
+
* A host whose address bar shows real paths writes a route with `href` and
|
|
23
|
+
* reads one back with `parse` (hanzo.ai/dev/<href>):
|
|
24
|
+
*
|
|
25
|
+
* '' New
|
|
26
|
+
* /run/<id> one run
|
|
27
|
+
* /projects/<org>/<repo> a repository's workspace
|
|
28
|
+
* /projects/<slug> a deployed site's workspace
|
|
29
|
+
* /machines · /environments the rail's own words for -/settings/machines and -/settings/environments
|
|
30
|
+
* /<rest> every other address, its `-/` dropped: /projects, /customize/connectors, /settings/usage
|
|
31
|
+
*/
|
|
32
|
+
export type Screen = 'artifacts' | 'templates' | 'projects' | 'issues' | 'automations' | 'sync' | 'mcp' | 'plans';
|
|
33
|
+
/** Settings, one section each. Every setting the builder has lives on this page, none elsewhere. */
|
|
34
|
+
export declare const SECTIONS: readonly ['general', 'account', 'privacy', 'billing', 'usage', 'capabilities', 'memory', 'code', 'environments', 'machines', 'keys', 'members', 'integrations', 'notifications'];
|
|
35
|
+
export type Section = (typeof SECTIONS)[number];
|
|
36
|
+
/** Customize, one tab each: what the agent brings to a run, yours and to discover. Agents first, then Bots. */
|
|
37
|
+
export declare const TABS: readonly ['agents', 'bots', 'skills', 'connectors', 'plugins'];
|
|
38
|
+
export type Tab = (typeof TABS)[number];
|
|
39
|
+
export type Route = {
|
|
40
|
+
kind: 'new';
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'run';
|
|
43
|
+
id: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'screen';
|
|
46
|
+
screen: Screen;
|
|
47
|
+
of?: Of;
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'settings';
|
|
50
|
+
section: Section;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'customize';
|
|
53
|
+
tab: Tab;
|
|
54
|
+
} | {
|
|
55
|
+
kind: 'agent';
|
|
56
|
+
name: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'project';
|
|
59
|
+
slug: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: 'repo';
|
|
62
|
+
org: string;
|
|
63
|
+
name: string;
|
|
64
|
+
} | {
|
|
65
|
+
kind: 'automation';
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
/** What the Library's address names: a kind it narrows to (api/library.ts KIND_IDS, plus `sites`), or `new`, its template picker. */
|
|
69
|
+
export declare const OF: readonly ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites', 'new'];
|
|
70
|
+
export type Of = (typeof OF)[number];
|
|
71
|
+
export declare const SESSION: RegExp;
|
|
72
|
+
export declare const SLUG: RegExp;
|
|
73
|
+
/** An organization or a repository name on the forge (api/codebases.ts `NAME`). */
|
|
74
|
+
export declare const NAME: RegExp;
|
|
75
|
+
/** An automation's id, or `new` for one not yet written. */
|
|
76
|
+
export declare const AUTOMATION: RegExp;
|
|
77
|
+
export declare function route(path: string): Route;
|
|
78
|
+
/** Every route that names no record, for a host that writes a page per address ahead of time. */
|
|
79
|
+
export declare const PLACES: readonly Route[];
|
|
80
|
+
/** A route as a real path under the host's mount: '' for New, `/run/<id>`, `/projects/<org>/<repo>`, `/projects/<slug>`, else its path without `-/`. */
|
|
81
|
+
export declare function href(r: Route): string;
|
|
82
|
+
/** The route a real path under the mount names — the inverse of `href`. A query or fragment is not part of it. */
|
|
83
|
+
export declare function parse(address: string): Route;
|
|
84
|
+
/** The path for a route — the inverse of `route`. */
|
|
85
|
+
export declare function path(r: Route): string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Settings, one section each. Every setting the builder has lives on this page, none elsewhere. */
|
|
2
|
+
export const SECTIONS = [
|
|
3
|
+
'general',
|
|
4
|
+
'account',
|
|
5
|
+
'privacy',
|
|
6
|
+
'billing',
|
|
7
|
+
'usage',
|
|
8
|
+
'capabilities',
|
|
9
|
+
'memory',
|
|
10
|
+
'code',
|
|
11
|
+
'environments',
|
|
12
|
+
'machines',
|
|
13
|
+
'keys',
|
|
14
|
+
'members',
|
|
15
|
+
'integrations',
|
|
16
|
+
'notifications',
|
|
17
|
+
];
|
|
18
|
+
/** Customize, one tab each: what the agent brings to a run, yours and to discover. Agents first, then Bots. */
|
|
19
|
+
export const TABS = ['agents', 'bots', 'skills', 'connectors', 'plugins'];
|
|
20
|
+
/** What the Library's address names: a kind it narrows to (api/library.ts KIND_IDS, plus `sites`), or `new`, its template picker. */
|
|
21
|
+
export const OF = ['image', 'video', 'audio', 'document', 'slides', 'type', 'model', 'code', 'file', 'sites', 'new'];
|
|
22
|
+
export const SESSION = /^sess_[0-9a-f]{32}$/;
|
|
23
|
+
export const SLUG = /^[a-z0-9]([a-z0-9-]{0,38}[a-z0-9])?$/;
|
|
24
|
+
/** An organization or a repository name on the forge (api/codebases.ts `NAME`). */
|
|
25
|
+
export const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
26
|
+
/** An automation's id, or `new` for one not yet written. */
|
|
27
|
+
export const AUTOMATION = /^(flow_[0-9a-f]{32}|new)$/;
|
|
28
|
+
const SCREENS = ['artifacts', 'templates', 'projects', 'issues', 'automations', 'sync', 'mcp', 'plans'];
|
|
29
|
+
export function route(path) {
|
|
30
|
+
const p = path.replace(/^\/+|\/+$/g, '');
|
|
31
|
+
if (SESSION.test(p))
|
|
32
|
+
return { kind: 'run', id: p };
|
|
33
|
+
if (p === '-/settings' || p.startsWith('-/settings/')) {
|
|
34
|
+
const section = (p.slice('-/settings/'.length) || 'general');
|
|
35
|
+
return SECTIONS.includes(section) ? { kind: 'settings', section } : { kind: 'new' };
|
|
36
|
+
}
|
|
37
|
+
if (p.startsWith('-/customize/agents/')) {
|
|
38
|
+
const name = p.slice('-/customize/agents/'.length);
|
|
39
|
+
return NAME.test(name) ? { kind: 'agent', name } : { kind: 'new' };
|
|
40
|
+
}
|
|
41
|
+
if (p === '-/customize' || p.startsWith('-/customize/')) {
|
|
42
|
+
const tab = (p.slice('-/customize/'.length) || 'agents');
|
|
43
|
+
return TABS.includes(tab) ? { kind: 'customize', tab } : { kind: 'new' };
|
|
44
|
+
}
|
|
45
|
+
if (p.startsWith('-/automations/')) {
|
|
46
|
+
const id = p.slice('-/automations/'.length);
|
|
47
|
+
return AUTOMATION.test(id) ? { kind: 'automation', id } : { kind: 'new' };
|
|
48
|
+
}
|
|
49
|
+
if (p.startsWith('-/artifacts/')) {
|
|
50
|
+
const of = p.slice('-/artifacts/'.length);
|
|
51
|
+
return OF.includes(of) ? { kind: 'screen', screen: 'artifacts', of } : { kind: 'new' };
|
|
52
|
+
}
|
|
53
|
+
if (p.startsWith('-/')) {
|
|
54
|
+
const s = p.slice(2);
|
|
55
|
+
return SCREENS.includes(s) ? { kind: 'screen', screen: s } : { kind: 'new' };
|
|
56
|
+
}
|
|
57
|
+
if (SLUG.test(p))
|
|
58
|
+
return { kind: 'project', slug: p };
|
|
59
|
+
const [org, name, ...rest] = p.split('/');
|
|
60
|
+
if (!rest.length && org && name && NAME.test(org) && NAME.test(name))
|
|
61
|
+
return { kind: 'repo', org, name };
|
|
62
|
+
return { kind: 'new' };
|
|
63
|
+
}
|
|
64
|
+
/** Every route that names no record, for a host that writes a page per address ahead of time. */
|
|
65
|
+
export const PLACES = [
|
|
66
|
+
{ kind: 'new' },
|
|
67
|
+
{ kind: 'automation', id: 'new' },
|
|
68
|
+
...SCREENS.map((screen) => ({ kind: 'screen', screen })),
|
|
69
|
+
...SECTIONS.map((section) => ({ kind: 'settings', section })),
|
|
70
|
+
...TABS.map((tab) => ({ kind: 'customize', tab })),
|
|
71
|
+
];
|
|
72
|
+
/** The places a real path names in the rail's words rather than the builder's: each rail row is a path of its own. */
|
|
73
|
+
const WORDS = new Map([
|
|
74
|
+
['-/settings/machines', 'machines'],
|
|
75
|
+
['-/settings/environments', 'environments'],
|
|
76
|
+
]);
|
|
77
|
+
const NAMES = new Map([...WORDS].map(([p, word]) => [word, p]));
|
|
78
|
+
/** A route as a real path under the host's mount: '' for New, `/run/<id>`, `/projects/<org>/<repo>`, `/projects/<slug>`, else its path without `-/`. */
|
|
79
|
+
export function href(r) {
|
|
80
|
+
if (r.kind === 'run')
|
|
81
|
+
return `/run/${r.id}`;
|
|
82
|
+
if (r.kind === 'repo')
|
|
83
|
+
return `/projects/${r.org}/${r.name}`;
|
|
84
|
+
if (r.kind === 'project')
|
|
85
|
+
return `/projects/${r.slug}`;
|
|
86
|
+
const p = path(r);
|
|
87
|
+
return p && `/${WORDS.get(p) ?? p.slice(2)}`;
|
|
88
|
+
}
|
|
89
|
+
/** The route a real path under the mount names — the inverse of `href`. A query or fragment is not part of it. */
|
|
90
|
+
export function parse(address) {
|
|
91
|
+
const p = address.split(/[?#]/)[0].replace(/^\/+|\/+$/g, '');
|
|
92
|
+
const [head, one, two, ...rest] = p.split('/');
|
|
93
|
+
if (head === 'run' || head === 'session' || head === 'sessions')
|
|
94
|
+
return one && !two && SESSION.test(one) ? { kind: 'run', id: one } : { kind: 'new' };
|
|
95
|
+
if (head === 'projects' && one) {
|
|
96
|
+
if (rest.length)
|
|
97
|
+
return { kind: 'new' };
|
|
98
|
+
if (two)
|
|
99
|
+
return NAME.test(one) && NAME.test(two) ? { kind: 'repo', org: one, name: two } : { kind: 'new' };
|
|
100
|
+
return SLUG.test(one) ? { kind: 'project', slug: one } : { kind: 'new' };
|
|
101
|
+
}
|
|
102
|
+
return p ? route(NAMES.get(p) ?? `-/${p}`) : { kind: 'new' };
|
|
103
|
+
}
|
|
104
|
+
/** The path for a route — the inverse of `route`. */
|
|
105
|
+
export function path(r) {
|
|
106
|
+
switch (r.kind) {
|
|
107
|
+
case 'new':
|
|
108
|
+
return '';
|
|
109
|
+
case 'run':
|
|
110
|
+
return r.id;
|
|
111
|
+
case 'screen':
|
|
112
|
+
return r.of ? `-/${r.screen}/${r.of}` : `-/${r.screen}`;
|
|
113
|
+
case 'settings':
|
|
114
|
+
return r.section === 'general' ? '-/settings' : `-/settings/${r.section}`;
|
|
115
|
+
case 'customize':
|
|
116
|
+
return r.tab === 'agents' ? '-/customize' : `-/customize/${r.tab}`;
|
|
117
|
+
case 'agent':
|
|
118
|
+
return `-/customize/agents/${r.name}`;
|
|
119
|
+
case 'project':
|
|
120
|
+
return r.slug;
|
|
121
|
+
case 'repo':
|
|
122
|
+
return `${r.org}/${r.name}`;
|
|
123
|
+
case 'automation':
|
|
124
|
+
return `-/automations/${r.id}`;
|
|
125
|
+
}
|
|
126
|
+
}
|