@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,85 @@
|
|
|
1
|
+
/** One tab. A kind's id is the kind; a page's is minted. */
|
|
2
|
+
export interface Tab {
|
|
3
|
+
id: string;
|
|
4
|
+
kind: string;
|
|
5
|
+
title: string;
|
|
6
|
+
/** A page's address. */
|
|
7
|
+
url?: string;
|
|
8
|
+
/** A page's own bytes, rendered as `type`. */
|
|
9
|
+
body?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
/** The addresses a page came from, oldest first, and those Back stepped over, nearest first. */
|
|
12
|
+
back?: string[];
|
|
13
|
+
ahead?: string[];
|
|
14
|
+
/** Leads the strip, and closes only on purpose. */
|
|
15
|
+
pinned?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** The tabs in a scope, in order, and the chosen one. */
|
|
18
|
+
export interface Tabs {
|
|
19
|
+
tabs: Tab[];
|
|
20
|
+
at: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare const PAGE = "page";
|
|
23
|
+
/** A scope as kept, or null when nothing is: the surface's seed stands in. A bad entry is dropped. */
|
|
24
|
+
export declare function read(scope: string): Tabs | null;
|
|
25
|
+
/** A tab opened: a kind already open is chosen, a page already open on the same thing is chosen. */
|
|
26
|
+
export declare function opened(was: Tabs, tab: Omit<Tab, 'id'> & {
|
|
27
|
+
id?: string;
|
|
28
|
+
}): Tabs;
|
|
29
|
+
/** A tab shut: the one to its right is chosen, else the one to its left, as a browser does. */
|
|
30
|
+
export declare function shut(was: Tabs, id: string): Tabs;
|
|
31
|
+
/** A tab moved to `to`, the others closing up around it, and kept in its group: pinned or not. */
|
|
32
|
+
export declare function moved(was: Tabs, id: string, to: number): Tabs;
|
|
33
|
+
/** A tab pinned, or let go: it joins the end of the pinned tabs, or leads the rest. */
|
|
34
|
+
export declare function pinned(was: Tabs, id: string, on: boolean): Tabs;
|
|
35
|
+
/** Every tab closed but the pinned ones and those `keep` names; the chosen one stays if it is left. */
|
|
36
|
+
export declare function cleared(was: Tabs, keep?: (t: Tab) => boolean): Tabs;
|
|
37
|
+
export interface Deck extends Tabs {
|
|
38
|
+
open: (tab: Omit<Tab, 'id'> & {
|
|
39
|
+
id?: string;
|
|
40
|
+
}) => void;
|
|
41
|
+
pick: (id: string) => void;
|
|
42
|
+
shut: (id: string) => void;
|
|
43
|
+
move: (id: string, to: number) => void;
|
|
44
|
+
/** Pin a tab: it leads the strip and closes only on purpose. */
|
|
45
|
+
pin: (id: string) => void;
|
|
46
|
+
unpin: (id: string) => void;
|
|
47
|
+
/** Close every tab but the pinned ones and those `keep` names. */
|
|
48
|
+
clear: (keep?: (t: Tab) => boolean) => void;
|
|
49
|
+
/** Point a page somewhere else: where it was goes on its Back, and Forward is forgotten. */
|
|
50
|
+
go: (id: string, url: string) => void;
|
|
51
|
+
/** A page's Back and Forward. */
|
|
52
|
+
back: (id: string) => void;
|
|
53
|
+
forward: (id: string) => void;
|
|
54
|
+
/** A page's title, as what it shows calls itself. */
|
|
55
|
+
rename: (id: string, title: string) => void;
|
|
56
|
+
}
|
|
57
|
+
/** A page pointed at `url`, where it was on its Back. */
|
|
58
|
+
export declare function went(t: Tab, url: string): Tab;
|
|
59
|
+
/** A page one step back, or forward: the address it leaves goes the other way. */
|
|
60
|
+
export declare function stepped(t: Tab, way: 'back' | 'forward'): Tab;
|
|
61
|
+
/** A scope's tabs: as kept, else `seed`, and every change kept. */
|
|
62
|
+
export declare function useDeck(scope: string, seed: Tabs): Deck;
|
|
63
|
+
/** Whether the panel is open in `mode`, kept; `first` before anyone has said. */
|
|
64
|
+
export declare function useShown(mode: string, first: boolean): readonly [boolean, (open: boolean) => void];
|
|
65
|
+
/**
|
|
66
|
+
* Whether the panel is open: kept per mode where it is a column (`wide`), and
|
|
67
|
+
* for this page only where it is a sheet over everything — a phone opens on
|
|
68
|
+
* the conversation, never on a sheet it did not ask for.
|
|
69
|
+
*/
|
|
70
|
+
export declare function usePanel(mode: string, first: boolean, wide: boolean): readonly [boolean, (open: boolean) => void];
|
|
71
|
+
/**
|
|
72
|
+
* The panel's keys, from anywhere on the page but a field: Ctrl+Shift+B (⌘⇧B on
|
|
73
|
+
* a Mac), the tabs' own, and ⌘. / Ctrl+., which it had first.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useKey(toggle: () => void): void;
|
|
76
|
+
/** The host and path of an address: as much as a title can honestly be. */
|
|
77
|
+
export declare function name(url: string): string;
|
|
78
|
+
/** Where words typed in a page's bar are looked up. */
|
|
79
|
+
export declare const SEARCH = "https://duckduckgo.com/?q=";
|
|
80
|
+
/** Whether what was typed in a page's bar is an address rather than words to look up. */
|
|
81
|
+
export declare function located(typed: string): boolean;
|
|
82
|
+
/** What a page's bar opens for what was typed: the address, or a search for the words. */
|
|
83
|
+
export declare function destination(typed: string): string;
|
|
84
|
+
/** An address as typed, made one that opens: https for a host, http for this machine. */
|
|
85
|
+
export declare function address(typed: string): string;
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The side panel's tabs, once, for Chat and Dev: what is open, in what order,
|
|
3
|
+
* which one is chosen, and whether the panel is open at all — kept as it was
|
|
4
|
+
* left. The panel that draws them is `Panel` (panel.tsx).
|
|
5
|
+
*
|
|
6
|
+
* hanzo.side.<mode> whether the panel is open in Chat or in Dev
|
|
7
|
+
* hanzo.side.<scope> its tabs, their order, and the chosen one
|
|
8
|
+
*
|
|
9
|
+
* A tab is a KIND the surface offers (Artifacts, Preview, Files, Diff,
|
|
10
|
+
* Terminal, Sources, …), one of each, or a PAGE: an address, or the bytes of
|
|
11
|
+
* something an answer wrote, rendered. `+` opens a kind that is not open or a
|
|
12
|
+
* new page; a tab is dragged to reorder (Ctrl/⌘+Shift+←/→ from the keyboard)
|
|
13
|
+
* and shut with its cross (Delete). A page's own bytes are kept with it, so an
|
|
14
|
+
* artifact's tab survives a reload; an object URL does not and is not kept.
|
|
15
|
+
* A page keeps the addresses it went through (`back`, `ahead`), so its bar's
|
|
16
|
+
* Back and Forward walk them as a browser's do.
|
|
17
|
+
*
|
|
18
|
+
* A PINNED tab leads the strip and closes only on purpose: its own close (`shut`)
|
|
19
|
+
* takes it, and nothing that closes tabs in bulk (`clear`) does. Pinned tabs
|
|
20
|
+
* keep their order among themselves, the others theirs; a tab moved stays in
|
|
21
|
+
* its group.
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
25
|
+
export const PAGE = 'page';
|
|
26
|
+
/** Bytes kept with a page tab, at most: a page an answer wrote, not a dump. */
|
|
27
|
+
const KEEP = 200_000;
|
|
28
|
+
const where = (scope) => `hanzo.side.${scope}`;
|
|
29
|
+
function store() {
|
|
30
|
+
try {
|
|
31
|
+
return typeof window === 'undefined' ? null : window.localStorage;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// The scopes this document has read, so a switch back costs no parse.
|
|
38
|
+
const live = new Map();
|
|
39
|
+
const listeners = new Set();
|
|
40
|
+
const announce = () => {
|
|
41
|
+
for (const l of listeners)
|
|
42
|
+
l();
|
|
43
|
+
};
|
|
44
|
+
const subscribe = (l) => {
|
|
45
|
+
listeners.add(l);
|
|
46
|
+
return () => {
|
|
47
|
+
listeners.delete(l);
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const isTab = (t) => !!t && typeof t.id === 'string' && typeof t.kind === 'string' && typeof t.title === 'string';
|
|
51
|
+
/** A scope as kept, or null when nothing is: the surface's seed stands in. A bad entry is dropped. */
|
|
52
|
+
export function read(scope) {
|
|
53
|
+
if (live.has(scope))
|
|
54
|
+
return live.get(scope);
|
|
55
|
+
let held = null;
|
|
56
|
+
try {
|
|
57
|
+
const raw = store()?.getItem(where(scope));
|
|
58
|
+
if (raw) {
|
|
59
|
+
const v = JSON.parse(raw);
|
|
60
|
+
// An object URL dies with the document that minted it: a page holding only one is not kept.
|
|
61
|
+
const tabs = ranked((Array.isArray(v.tabs) ? v.tabs.filter(isTab) : []).filter((t) => t.kind !== PAGE || t.body !== undefined || !t.url?.startsWith('blob:')));
|
|
62
|
+
held = { tabs, at: tabs.some((t) => t.id === v.at) ? v.at : (tabs[0]?.id ?? null) };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
held = null;
|
|
67
|
+
}
|
|
68
|
+
live.set(scope, held);
|
|
69
|
+
return held;
|
|
70
|
+
}
|
|
71
|
+
function write(scope, next) {
|
|
72
|
+
live.set(scope, next);
|
|
73
|
+
try {
|
|
74
|
+
const kept = { ...next, tabs: next.tabs.map((t) => (t.body !== undefined && t.body.length > KEEP ? { ...t, body: undefined } : t)) };
|
|
75
|
+
store()?.setItem(where(scope), JSON.stringify(kept));
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// A browser that refuses storage keeps the tabs for this page.
|
|
79
|
+
}
|
|
80
|
+
announce();
|
|
81
|
+
}
|
|
82
|
+
/** Pinned tabs first, each group in the order it had. */
|
|
83
|
+
function ranked(tabs) {
|
|
84
|
+
return [...tabs.filter((t) => t.pinned), ...tabs.filter((t) => !t.pinned)];
|
|
85
|
+
}
|
|
86
|
+
let minted = 0;
|
|
87
|
+
const mint = () => `p${Date.now().toString(36)}${(minted++).toString(36)}`;
|
|
88
|
+
/** A tab opened: a kind already open is chosen, a page already open on the same thing is chosen. */
|
|
89
|
+
export function opened(was, tab) {
|
|
90
|
+
const same = was.tabs.find((t) => tab.kind === PAGE ? t.kind === PAGE && ((tab.url && t.url === tab.url) || (tab.body !== undefined && t.body === tab.body && t.title === tab.title)) : t.kind === tab.kind);
|
|
91
|
+
if (same)
|
|
92
|
+
return { ...was, at: same.id };
|
|
93
|
+
const id = tab.id ?? (tab.kind === PAGE ? mint() : tab.kind);
|
|
94
|
+
return { tabs: ranked([...was.tabs, { ...tab, id }]), at: id };
|
|
95
|
+
}
|
|
96
|
+
/** A tab shut: the one to its right is chosen, else the one to its left, as a browser does. */
|
|
97
|
+
export function shut(was, id) {
|
|
98
|
+
const gone = was.tabs.findIndex((t) => t.id === id);
|
|
99
|
+
if (gone < 0)
|
|
100
|
+
return was;
|
|
101
|
+
const tabs = was.tabs.filter((t) => t.id !== id);
|
|
102
|
+
if (was.at !== id)
|
|
103
|
+
return { ...was, tabs };
|
|
104
|
+
return { tabs, at: (tabs[gone] ?? tabs[gone - 1])?.id ?? null };
|
|
105
|
+
}
|
|
106
|
+
/** A tab moved to `to`, the others closing up around it, and kept in its group: pinned or not. */
|
|
107
|
+
export function moved(was, id, to) {
|
|
108
|
+
const from = was.tabs.findIndex((t) => t.id === id);
|
|
109
|
+
if (from < 0)
|
|
110
|
+
return was;
|
|
111
|
+
const tabs = was.tabs.slice();
|
|
112
|
+
const [tab] = tabs.splice(from, 1);
|
|
113
|
+
const pins = tabs.filter((t) => t.pinned).length;
|
|
114
|
+
const [low, high] = tab.pinned ? [0, pins] : [pins, tabs.length];
|
|
115
|
+
tabs.splice(Math.max(low, Math.min(high, to)), 0, tab);
|
|
116
|
+
return { ...was, tabs };
|
|
117
|
+
}
|
|
118
|
+
/** A tab pinned, or let go: it joins the end of the pinned tabs, or leads the rest. */
|
|
119
|
+
export function pinned(was, id, on) {
|
|
120
|
+
const tab = was.tabs.find((t) => t.id === id);
|
|
121
|
+
if (!tab || Boolean(tab.pinned) === on)
|
|
122
|
+
return was;
|
|
123
|
+
const rest = was.tabs.filter((t) => t.id !== id);
|
|
124
|
+
const pins = rest.filter((t) => t.pinned);
|
|
125
|
+
const others = rest.filter((t) => !t.pinned);
|
|
126
|
+
const plain = { ...tab };
|
|
127
|
+
delete plain.pinned;
|
|
128
|
+
return { ...was, tabs: on ? [...pins, { ...tab, pinned: true }, ...others] : [...pins, plain, ...others] };
|
|
129
|
+
}
|
|
130
|
+
/** Every tab closed but the pinned ones and those `keep` names; the chosen one stays if it is left. */
|
|
131
|
+
export function cleared(was, keep = () => false) {
|
|
132
|
+
const tabs = was.tabs.filter((t) => t.pinned || keep(t));
|
|
133
|
+
if (tabs.length === was.tabs.length)
|
|
134
|
+
return was;
|
|
135
|
+
return { tabs, at: tabs.some((t) => t.id === was.at) ? was.at : (tabs[0]?.id ?? null) };
|
|
136
|
+
}
|
|
137
|
+
/** How many addresses a page's Back keeps. */
|
|
138
|
+
const DEPTH = 50;
|
|
139
|
+
/** A page pointed at `url`, where it was on its Back. */
|
|
140
|
+
export function went(t, url) {
|
|
141
|
+
if (url === t.url)
|
|
142
|
+
return t;
|
|
143
|
+
const back = t.url ? [...(t.back ?? []), t.url].slice(-DEPTH) : (t.back ?? []);
|
|
144
|
+
return { ...t, url, title: name(url), body: undefined, type: undefined, back, ahead: [] };
|
|
145
|
+
}
|
|
146
|
+
/** A page one step back, or forward: the address it leaves goes the other way. */
|
|
147
|
+
export function stepped(t, way) {
|
|
148
|
+
const from = way === 'back' ? (t.back ?? []) : (t.ahead ?? []);
|
|
149
|
+
const url = way === 'back' ? from.at(-1) : from[0];
|
|
150
|
+
if (!url)
|
|
151
|
+
return t;
|
|
152
|
+
const rest = way === 'back' ? from.slice(0, -1) : from.slice(1);
|
|
153
|
+
const here = t.url ? [t.url] : [];
|
|
154
|
+
return way === 'back'
|
|
155
|
+
? { ...t, url, title: name(url), back: rest, ahead: [...here, ...(t.ahead ?? [])] }
|
|
156
|
+
: { ...t, url, title: name(url), ahead: rest, back: [...(t.back ?? []), ...here].slice(-DEPTH) };
|
|
157
|
+
}
|
|
158
|
+
/** A scope's tabs: as kept, else `seed`, and every change kept. */
|
|
159
|
+
export function useDeck(scope, seed) {
|
|
160
|
+
const kept = useSyncExternalStore(subscribe, () => read(scope), () => null);
|
|
161
|
+
const now = kept ?? seed;
|
|
162
|
+
const change = (f) => write(scope, f(read(scope) ?? seed));
|
|
163
|
+
return {
|
|
164
|
+
...now,
|
|
165
|
+
open: (tab) => change((was) => opened(was, tab)),
|
|
166
|
+
pick: (id) => change((was) => ({ ...was, at: id })),
|
|
167
|
+
shut: (id) => change((was) => shut(was, id)),
|
|
168
|
+
move: (id, to) => change((was) => moved(was, id, to)),
|
|
169
|
+
pin: (id) => change((was) => pinned(was, id, true)),
|
|
170
|
+
unpin: (id) => change((was) => pinned(was, id, false)),
|
|
171
|
+
clear: (keep) => change((was) => cleared(was, keep)),
|
|
172
|
+
go: (id, url) => change((was) => ({ ...was, tabs: was.tabs.map((t) => (t.id === id ? went(t, url) : t)) })),
|
|
173
|
+
back: (id) => change((was) => ({ ...was, tabs: was.tabs.map((t) => (t.id === id ? stepped(t, 'back') : t)) })),
|
|
174
|
+
forward: (id) => change((was) => ({ ...was, tabs: was.tabs.map((t) => (t.id === id ? stepped(t, 'forward') : t)) })),
|
|
175
|
+
rename: (id, title) => change((was) => ({ ...was, tabs: was.tabs.map((t) => (t.id === id && title && t.title !== title ? { ...t, title } : t)) })),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const shownKey = (mode) => where(`${mode}.open`);
|
|
179
|
+
const shownLive = new Map();
|
|
180
|
+
function shownOf(mode, first) {
|
|
181
|
+
if (shownLive.has(mode))
|
|
182
|
+
return shownLive.get(mode);
|
|
183
|
+
let v = first;
|
|
184
|
+
try {
|
|
185
|
+
const raw = store()?.getItem(shownKey(mode));
|
|
186
|
+
if (raw === '1' || raw === '0')
|
|
187
|
+
v = raw === '1';
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
v = first;
|
|
191
|
+
}
|
|
192
|
+
shownLive.set(mode, v);
|
|
193
|
+
return v;
|
|
194
|
+
}
|
|
195
|
+
/** Whether the panel is open in `mode`, kept; `first` before anyone has said. */
|
|
196
|
+
export function useShown(mode, first) {
|
|
197
|
+
const open = useSyncExternalStore(subscribe, () => shownOf(mode, first), () => first);
|
|
198
|
+
const set = (next) => {
|
|
199
|
+
shownLive.set(mode, next);
|
|
200
|
+
try {
|
|
201
|
+
store()?.setItem(shownKey(mode), next ? '1' : '0');
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// Kept for this page.
|
|
205
|
+
}
|
|
206
|
+
announce();
|
|
207
|
+
};
|
|
208
|
+
return [open, set];
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Whether the panel is open: kept per mode where it is a column (`wide`), and
|
|
212
|
+
* for this page only where it is a sheet over everything — a phone opens on
|
|
213
|
+
* the conversation, never on a sheet it did not ask for.
|
|
214
|
+
*/
|
|
215
|
+
export function usePanel(mode, first, wide) {
|
|
216
|
+
const [kept, keep] = useShown(mode, first);
|
|
217
|
+
const [sheet, setSheet] = useState(false);
|
|
218
|
+
return wide ? [kept, keep] : [sheet, setSheet];
|
|
219
|
+
}
|
|
220
|
+
/** Whether a key went to something the reader types in, where it is theirs. */
|
|
221
|
+
const typing = (e) => {
|
|
222
|
+
const el = e.target;
|
|
223
|
+
return !!el && (el.isContentEditable || el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT');
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* The panel's keys, from anywhere on the page but a field: Ctrl+Shift+B (⌘⇧B on
|
|
227
|
+
* a Mac), the tabs' own, and ⌘. / Ctrl+., which it had first.
|
|
228
|
+
*/
|
|
229
|
+
export function useKey(toggle) {
|
|
230
|
+
const now = useRef(toggle);
|
|
231
|
+
now.current = toggle;
|
|
232
|
+
useEffect(() => {
|
|
233
|
+
const press = (e) => {
|
|
234
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey || typing(e))
|
|
235
|
+
return;
|
|
236
|
+
const tabs = e.shiftKey && e.key.toLowerCase() === 'b';
|
|
237
|
+
const dot = !e.shiftKey && e.key === '.';
|
|
238
|
+
if (!tabs && !dot)
|
|
239
|
+
return;
|
|
240
|
+
e.preventDefault();
|
|
241
|
+
now.current();
|
|
242
|
+
};
|
|
243
|
+
window.addEventListener('keydown', press);
|
|
244
|
+
return () => window.removeEventListener('keydown', press);
|
|
245
|
+
}, []);
|
|
246
|
+
}
|
|
247
|
+
/** The host and path of an address: as much as a title can honestly be. */
|
|
248
|
+
export function name(url) {
|
|
249
|
+
try {
|
|
250
|
+
const u = new URL(url);
|
|
251
|
+
return u.host + (u.pathname === '/' ? '' : u.pathname);
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return url;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Where words typed in a page's bar are looked up. */
|
|
258
|
+
export const SEARCH = 'https://duckduckgo.com/?q=';
|
|
259
|
+
/** Whether what was typed in a page's bar is an address rather than words to look up. */
|
|
260
|
+
export function located(typed) {
|
|
261
|
+
const t = typed.trim();
|
|
262
|
+
if (!t || /\s/.test(t))
|
|
263
|
+
return false;
|
|
264
|
+
if (/^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?(\/|$)/i.test(t))
|
|
265
|
+
return true;
|
|
266
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(t) || /^(about|blob|data):/i.test(t))
|
|
267
|
+
return true;
|
|
268
|
+
return /^[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z]{2,}(:\d+)?(\/.*)?$/i.test(t);
|
|
269
|
+
}
|
|
270
|
+
/** What a page's bar opens for what was typed: the address, or a search for the words. */
|
|
271
|
+
export function destination(typed) {
|
|
272
|
+
const t = typed.trim();
|
|
273
|
+
if (!t)
|
|
274
|
+
return '';
|
|
275
|
+
return located(t) ? address(t) : SEARCH + encodeURIComponent(t);
|
|
276
|
+
}
|
|
277
|
+
/** An address as typed, made one that opens: https for a host, http for this machine. */
|
|
278
|
+
export function address(typed) {
|
|
279
|
+
const t = typed.trim();
|
|
280
|
+
if (!t)
|
|
281
|
+
return '';
|
|
282
|
+
// This machine first: `localhost:3000` reads as a scheme to the rule below.
|
|
283
|
+
if (/^(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/i.test(t))
|
|
284
|
+
return `http://${t}`;
|
|
285
|
+
if (/^[a-z][a-z0-9+.-]*:(?!\d)/i.test(t))
|
|
286
|
+
return t;
|
|
287
|
+
return `https://${t}`;
|
|
288
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A conversation in Dev (api/talk.ts): what the person said and what the agent
|
|
4
|
+
* answered, at one address however many turns it takes — the way Chat reads.
|
|
5
|
+
*
|
|
6
|
+
* Every send continues the same session. While a turn works, what is said is that
|
|
7
|
+
* turn's next input; once it has answered, the next turn. A build is never steered
|
|
8
|
+
* from here — the words are the conversation's, and a build is steered from its
|
|
9
|
+
* own page, which its card opens. The agent decides what a turn needs: an answer,
|
|
10
|
+
* a sandbox (leased on first use and kept for the conversation), or a coding run,
|
|
11
|
+
* whose outcome is said here when it ends. A question a turn asks — in Manual,
|
|
12
|
+
* whether a build may start — is answered on its card. The line under the
|
|
13
|
+
* transcript is what the turn is doing now, from its own progress. The mode pill
|
|
14
|
+
* is the conversation's: Plan, Auto or Manual, kept from the turn it is sent with.
|
|
15
|
+
*/
|
|
16
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
17
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
18
|
+
import { Steer } from '@hanzo/ui/agents';
|
|
19
|
+
import { Composer, measure } from '@hanzo/ui/chat';
|
|
20
|
+
import { useLimits } from '@hanzo/ui/product/useLimits';
|
|
21
|
+
import { useMemo, useState } from 'react';
|
|
22
|
+
import { DEV_MODES, MODES } from './gear.js';
|
|
23
|
+
import { Refusal } from './api/call.js';
|
|
24
|
+
import { limits as readLimits } from './api/models.js';
|
|
25
|
+
import { log, message, stop } from './api/sessions.js';
|
|
26
|
+
import { answer, now, say as talk } from './api/talk.js';
|
|
27
|
+
import { cards, merge, outcome } from './api/turn.js';
|
|
28
|
+
import { verdict } from './api/verdict.js';
|
|
29
|
+
import { useRead } from './data.js';
|
|
30
|
+
import { useHost, useTarget } from './host.js';
|
|
31
|
+
import { level, useMind } from './mind.js';
|
|
32
|
+
import { pane } from './pane.js';
|
|
33
|
+
import { speaker } from './reply.js';
|
|
34
|
+
import { path } from './route.js';
|
|
35
|
+
import { cleanErrorText } from './thread.js';
|
|
36
|
+
import { carrying, compose, pick } from './tools.js';
|
|
37
|
+
import { Transcript } from './transcript.js';
|
|
38
|
+
export function Talk({ id, state }) {
|
|
39
|
+
const { t: say } = useI18n();
|
|
40
|
+
const host = useHost();
|
|
41
|
+
const t = useTarget();
|
|
42
|
+
const signed = Boolean(host.person);
|
|
43
|
+
const { detail, record, status, refused } = state;
|
|
44
|
+
// The whole conversation from its first word: the detail carries the latest
|
|
45
|
+
// fifty events, and a turn that builds says many. Live frames are added to it.
|
|
46
|
+
const whole = useRead(signed ? () => log(t, id) : null, [], [t, id, signed]);
|
|
47
|
+
const events = useMemo(() => merge(whole.value, state.events), [whole.value, state.events]);
|
|
48
|
+
const [draft, setDraft] = useState('');
|
|
49
|
+
const [files, setFiles] = useState([]);
|
|
50
|
+
const [note, setNote] = useState('');
|
|
51
|
+
const [busy, setBusy] = useState(false);
|
|
52
|
+
const { limits } = useLimits(signed ? (signal) => readLimits(t, signal) : null, t);
|
|
53
|
+
const mind = useMind(t, limits?.plan, host.topUp);
|
|
54
|
+
const listen = useMemo(() => speaker(t), [t]);
|
|
55
|
+
const shown = useMemo(() => cards(events, '', say), [events, say]);
|
|
56
|
+
const terminalError = useMemo(() => outcome(events).status === 'error', [events]);
|
|
57
|
+
const working = status === 'running' && !terminalError;
|
|
58
|
+
const addFunds = () => (host.topUp ? host.topUp() : host.go(path({ kind: 'settings', section: 'billing' })));
|
|
59
|
+
const doing = useMemo(() => now(events), [events]);
|
|
60
|
+
// The conversation's mode, as it keeps it until the person picks another: what
|
|
61
|
+
// they pick is sent with what they say next, and kept for every turn after.
|
|
62
|
+
const [picked, setPicked] = useState(null);
|
|
63
|
+
const mode = picked ?? (DEV_MODES.includes(record?.mode) ? record?.mode : 'auto');
|
|
64
|
+
/** One act at a time; what it answers, or the reason it was refused, is the note. */
|
|
65
|
+
const act = async (work) => {
|
|
66
|
+
if (busy)
|
|
67
|
+
return;
|
|
68
|
+
setBusy(true);
|
|
69
|
+
setNote('');
|
|
70
|
+
try {
|
|
71
|
+
setNote(await work());
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
setNote(cleanErrorText(e.message));
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
setBusy(false);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const send = () => {
|
|
81
|
+
const words = compose(draft.trim(), files);
|
|
82
|
+
if (!words)
|
|
83
|
+
return;
|
|
84
|
+
const next = () => talk(t, { session: id, input: words, model: mind.model, effort: level(mind.effort), ...(picked ? { mode: picked } : {}) });
|
|
85
|
+
void act(async () => {
|
|
86
|
+
if (!working)
|
|
87
|
+
await next();
|
|
88
|
+
else
|
|
89
|
+
try {
|
|
90
|
+
await message(t, id, words);
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
// The turn answered as the words were sent: they are the next turn.
|
|
94
|
+
if (!(e instanceof Refusal) || e.status !== 409)
|
|
95
|
+
throw e;
|
|
96
|
+
await next();
|
|
97
|
+
}
|
|
98
|
+
setDraft('');
|
|
99
|
+
setFiles([]);
|
|
100
|
+
return '';
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const empty = (_jsx(SizableText, { size: "$2", color: "$soft", children: !signed ? say('Sign in to follow this conversation.') : detail.error ? say(detail.error.message) : detail.loading ? say('Reading this conversation…') : say('Thinking…') }));
|
|
104
|
+
return (_jsxs(YStack, { "data-slot": "talk", ...pane, display: "grid", gridTemplateRows: "auto minmax(0, 1fr) auto", width: "100%", height: "100%", minH: 0, minW: 0, children: [_jsx(XStack, { px: "$4", pt: "$3", pb: "$2", items: "center", minH: 44, style: { paddingInlineEnd: 'calc(16px + var(--hanzo-shell-top-right-inset, 0px))' }, children: _jsx(SizableText, { size: "$4", color: "$ink", numberOfLines: 1, children: record?.title || say('New conversation') }) }), _jsx(Transcript, { cards: shown, live: working, empty: empty, listen: signed ? listen : undefined, onVerdict: (v) => verdict(t, id, '', v), onRun: (session) => host.go(session), onAnswer: (question, label) => void act(async () => (await answer(t, id, question, label, true), '')), onAddFunds: addFunds }), _jsxs(YStack, { pb: "$3", pt: "$2", gap: "$2", children: [_jsxs(YStack, { ...measure, gap: "$2", children: [note || (signed && refused) ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || refused })) : null, working ? (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$10", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$2", color: "$soft", flex: 1, minW: 0, numberOfLines: 1, role: "status", children: doing || say('Thinking…') }), _jsx(Steer, { onCommand: (c) => {
|
|
105
|
+
if (c === 'stop')
|
|
106
|
+
void act(async () => (await stop(t, id), say('Stopped')));
|
|
107
|
+
}, withhold: ['pause', 'resume', ...(busy ? ['stop'] : [])] })] })) : null] }), _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: send, onStop: working ? () => void act(async () => (await stop(t, id), say('Stopped'))) : undefined, busy: working && !draft.trim(), ready: Boolean(draft.trim()), disabled: !signed || busy || !record, placeholder: !signed ? say('Sign in to reply') : working ? say('Add to what it is doing') : say('Reply'), label: say('Reply to this conversation'), plus: { upload: () => pick(files, setFiles, setNote, say) }, carried: carrying(files, setFiles), mind: signed && !working ? mind : null, mode: signed && !working ? { value: mode, set: (m) => setPicked(m), items: MODES.filter((m) => DEV_MODES.includes(m.id)) } : null })] })] }));
|
|
108
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Session } from './api/sessions.ts';
|
|
2
|
+
export declare const THREADS_KEY = "hanzo.dev.session.threads";
|
|
3
|
+
export declare const THREADS_EVENT = "hanzo:session-threads";
|
|
4
|
+
/** Map of child session id -> immediate previous (or root) session id in the same thread. */
|
|
5
|
+
export type ThreadLinks = Record<string, string>;
|
|
6
|
+
/** Statuses indicating a session turn has ended. */
|
|
7
|
+
export declare const TERMINAL_STATUSES: Set<string>;
|
|
8
|
+
/** Statuses indicating a session turn is actively executing (or queued/starting). */
|
|
9
|
+
export declare const ACTIVE_STATUSES: Set<string>;
|
|
10
|
+
/** Statuses indicating a session is still live (active or paused, or not yet reported). */
|
|
11
|
+
export declare const LIVE_STATUSES: Set<string>;
|
|
12
|
+
export declare const isSessionActive: (status: string) => boolean;
|
|
13
|
+
export declare const isSessionLive: (status: string) => boolean;
|
|
14
|
+
export declare const isSessionTerminal: (status: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the effective status from the session record and its narrated outcome event.
|
|
17
|
+
*
|
|
18
|
+
* Only a terminal outcome (`done`, `completed`, `error`, `stopped`, `followed`) or
|
|
19
|
+
* `paused` overrides a live record status; intermediate lifecycle events like
|
|
20
|
+
* `started` or `routed` keep the session live instead of flipping it to finished.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveSessionState(recordStatus: string, outcomeStatus: string): string;
|
|
23
|
+
/** Whether a server error indicates the target coding session is still running. */
|
|
24
|
+
export declare function isAlreadyRunningError(err: unknown): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Normalize error messages shown in the UI so server-redacted session IDs
|
|
27
|
+
* (`[REDACTED-TOKEN]`) are replaced with readable session language.
|
|
28
|
+
*/
|
|
29
|
+
export declare function cleanErrorText(message: string): string;
|
|
30
|
+
export declare function readThreadLinks(): ThreadLinks;
|
|
31
|
+
/** Follow parent pointers to the earliest root session id for `id` (cycle-safe). */
|
|
32
|
+
export declare function threadRoot(id: string, links?: ThreadLinks): string;
|
|
33
|
+
/**
|
|
34
|
+
* Record that `nextId` continues `previousId` inside the same thread.
|
|
35
|
+
* Returns the thread's root session id.
|
|
36
|
+
*/
|
|
37
|
+
export declare function linkThread(previousId: string, nextId: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Return the ordered chain of session IDs belonging to `id`'s thread (oldest to newest).
|
|
40
|
+
*/
|
|
41
|
+
export declare function threadChain(id: string, links?: ThreadLinks): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Discover thread chains from a list of server sessions (via `parent`, `root`,
|
|
44
|
+
* shared `agent/` branch, or shared sandbox) and merge them into the link map.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deriveThreadLinks(sessions: readonly Session[], base?: ThreadLinks): ThreadLinks;
|
|
47
|
+
/** Persist any newly discovered thread chains from a server session list. */
|
|
48
|
+
export declare function syncThreadsFromSessions(sessions: readonly Session[]): ThreadLinks;
|
|
49
|
+
/**
|
|
50
|
+
* Collapse chained follow-up turns into a single Recents row per thread:
|
|
51
|
+
* - Stable `id` = root session id
|
|
52
|
+
* - `title` = root session title (falling back to latest)
|
|
53
|
+
* - `status`, `updatedAt`, `endedAt`, `pr`, `branch`, `sandbox` = latest turn's values
|
|
54
|
+
* - Sorted newest activity first (`updatedAt || createdAt`)
|
|
55
|
+
*/
|
|
56
|
+
export declare function groupSessions(sessions: readonly Session[], links?: ThreadLinks): Session[];
|
|
57
|
+
/** Reactive subscription to persisted single-thread links. */
|
|
58
|
+
export declare function useThreadLinks(): ThreadLinks;
|
|
59
|
+
/** Test-only helper to reset in-memory thread links between unit tests. */
|
|
60
|
+
export declare function resetThreadLinks(): void;
|