@hanzo/dev 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +31 -0
- package/dist/builder/api/git.js +47 -0
- package/dist/builder/api/github.d.ts +176 -0
- package/dist/builder/api/github.js +271 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +570 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +591 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +164 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-thread session continuity, live-state resolution, and Recents grouping.
|
|
3
|
+
*
|
|
4
|
+
* A coding session can span multiple turns (follow-ups via `after` and mid-flight
|
|
5
|
+
* steers via `POST /v1/agent/coding/{id}/steer`). Each turn has its own backend
|
|
6
|
+
* session id, shares the thread's branch (`agent/<short>`) or sandbox, and
|
|
7
|
+
* belongs to ONE conversation thread for the person using Dev.
|
|
8
|
+
*
|
|
9
|
+
* This module keeps:
|
|
10
|
+
* - Accurate active/live/terminal status classification (so lifecycle events like
|
|
11
|
+
* `started`, `routed`, `starting`, `queued`, `resumed` never falsely mark an
|
|
12
|
+
* active session as finished),
|
|
13
|
+
* - Client-persisted thread links (`hanzo.dev.session.threads`) synchronized with
|
|
14
|
+
* server-observed `root`, `parent`, `branch`+`repo`, and `sandbox` chains,
|
|
15
|
+
* - Recents deduplication (`groupSessions`) so continuing a thread updates its
|
|
16
|
+
* single entry instead of spamming duplicate rows in the sidebar,
|
|
17
|
+
* - Clean error normalization so server-scrubbed `[REDACTED-TOKEN]` strings never
|
|
18
|
+
* leak into user-facing status banners.
|
|
19
|
+
*/
|
|
20
|
+
import { useSyncExternalStore } from 'react';
|
|
21
|
+
export const THREADS_KEY = 'hanzo.dev.session.threads';
|
|
22
|
+
export const THREADS_EVENT = 'hanzo:session-threads';
|
|
23
|
+
/** Statuses indicating a session turn has ended. */
|
|
24
|
+
export const TERMINAL_STATUSES = new Set(['done', 'completed', 'error', 'stopped', 'followed']);
|
|
25
|
+
/** Statuses indicating a session turn is actively executing (or queued/starting). */
|
|
26
|
+
export const ACTIVE_STATUSES = new Set(['running', 'starting', 'started', 'queued', 'routed', 'resumed']);
|
|
27
|
+
/** Statuses indicating a session is still live (active or paused, or not yet reported). */
|
|
28
|
+
export const LIVE_STATUSES = new Set(['running', 'starting', 'started', 'queued', 'routed', 'resumed', 'paused', '']);
|
|
29
|
+
export const isSessionActive = (status) => ACTIVE_STATUSES.has(status);
|
|
30
|
+
export const isSessionLive = (status) => LIVE_STATUSES.has(status);
|
|
31
|
+
export const isSessionTerminal = (status) => TERMINAL_STATUSES.has(status);
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the effective status from the session record and its narrated outcome event.
|
|
34
|
+
*
|
|
35
|
+
* Only a terminal outcome (`done`, `completed`, `error`, `stopped`, `followed`) or
|
|
36
|
+
* `paused` overrides a live record status; intermediate lifecycle events like
|
|
37
|
+
* `started` or `routed` keep the session live instead of flipping it to finished.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveSessionState(recordStatus, outcomeStatus) {
|
|
40
|
+
const rec = recordStatus || '';
|
|
41
|
+
const end = outcomeStatus || '';
|
|
42
|
+
if (end && (TERMINAL_STATUSES.has(end) || end === 'paused') && LIVE_STATUSES.has(rec))
|
|
43
|
+
return end;
|
|
44
|
+
return rec || end;
|
|
45
|
+
}
|
|
46
|
+
/** Whether a server error indicates the target coding session is still running. */
|
|
47
|
+
export function isAlreadyRunningError(err) {
|
|
48
|
+
const msg = err instanceof Error ? err.message : typeof err === 'string' ? err : '';
|
|
49
|
+
return /is running;\s*stop it or let it finish|already running|already being followed up/i.test(msg);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Normalize error messages shown in the UI so server-redacted session IDs
|
|
53
|
+
* (`[REDACTED-TOKEN]`) are replaced with readable session language.
|
|
54
|
+
*/
|
|
55
|
+
export function cleanErrorText(message) {
|
|
56
|
+
if (!message)
|
|
57
|
+
return '';
|
|
58
|
+
return message
|
|
59
|
+
.replace(/\bthe run \[REDACTED-TOKEN\]/gi, 'this session')
|
|
60
|
+
.replace(/\brun \[REDACTED-TOKEN\]/gi, 'this session')
|
|
61
|
+
.replace(/\[REDACTED-TOKEN\]/g, 'this session');
|
|
62
|
+
}
|
|
63
|
+
const NONE = {};
|
|
64
|
+
let held = { raw: null, links: NONE };
|
|
65
|
+
export function readThreadLinks() {
|
|
66
|
+
if (typeof window === 'undefined')
|
|
67
|
+
return held.links;
|
|
68
|
+
let raw = null;
|
|
69
|
+
try {
|
|
70
|
+
raw = window.localStorage.getItem(THREADS_KEY);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return held.links;
|
|
74
|
+
}
|
|
75
|
+
if (raw === held.raw)
|
|
76
|
+
return held.links;
|
|
77
|
+
let parsed = null;
|
|
78
|
+
try {
|
|
79
|
+
parsed = raw === null ? null : JSON.parse(raw);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
parsed = null;
|
|
83
|
+
}
|
|
84
|
+
const clean = {};
|
|
85
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
86
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
87
|
+
if (typeof k === 'string' && typeof v === 'string' && k && v && k !== v)
|
|
88
|
+
clean[k] = v;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
held = { raw, links: clean };
|
|
92
|
+
return held.links;
|
|
93
|
+
}
|
|
94
|
+
function writeThreadLinks(next) {
|
|
95
|
+
const raw = JSON.stringify(next);
|
|
96
|
+
held = { raw, links: next };
|
|
97
|
+
if (typeof window === 'undefined')
|
|
98
|
+
return;
|
|
99
|
+
try {
|
|
100
|
+
window.localStorage.setItem(THREADS_KEY, raw);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
/* kept in memory for this page */
|
|
104
|
+
}
|
|
105
|
+
window.dispatchEvent(new Event(THREADS_EVENT));
|
|
106
|
+
}
|
|
107
|
+
/** Follow parent pointers to the earliest root session id for `id` (cycle-safe). */
|
|
108
|
+
export function threadRoot(id, links = readThreadLinks()) {
|
|
109
|
+
let cur = id;
|
|
110
|
+
const seen = new Set([cur]);
|
|
111
|
+
while (links[cur] && !seen.has(links[cur])) {
|
|
112
|
+
cur = links[cur];
|
|
113
|
+
seen.add(cur);
|
|
114
|
+
}
|
|
115
|
+
return cur;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Record that `nextId` continues `previousId` inside the same thread.
|
|
119
|
+
* Returns the thread's root session id.
|
|
120
|
+
*/
|
|
121
|
+
export function linkThread(previousId, nextId) {
|
|
122
|
+
if (!previousId || !nextId || previousId === nextId)
|
|
123
|
+
return previousId || nextId;
|
|
124
|
+
const current = readThreadLinks();
|
|
125
|
+
// Prevent cycles if nextId is already an ancestor of previousId.
|
|
126
|
+
let ancestor = previousId;
|
|
127
|
+
const seen = new Set([ancestor]);
|
|
128
|
+
while (current[ancestor] && !seen.has(current[ancestor])) {
|
|
129
|
+
ancestor = current[ancestor];
|
|
130
|
+
if (ancestor === nextId)
|
|
131
|
+
return threadRoot(previousId, current);
|
|
132
|
+
seen.add(ancestor);
|
|
133
|
+
}
|
|
134
|
+
if (current[nextId] === previousId)
|
|
135
|
+
return threadRoot(previousId, current);
|
|
136
|
+
const next = { ...current, [nextId]: previousId };
|
|
137
|
+
writeThreadLinks(next);
|
|
138
|
+
return threadRoot(previousId, next);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Return the ordered chain of session IDs belonging to `id`'s thread (oldest to newest).
|
|
142
|
+
*/
|
|
143
|
+
export function threadChain(id, links = readThreadLinks()) {
|
|
144
|
+
if (!id)
|
|
145
|
+
return [];
|
|
146
|
+
const root = threadRoot(id, links);
|
|
147
|
+
const children = new Map();
|
|
148
|
+
for (const [child, parent] of Object.entries(links)) {
|
|
149
|
+
const list = children.get(parent) ?? [];
|
|
150
|
+
list.push(child);
|
|
151
|
+
children.set(parent, list);
|
|
152
|
+
}
|
|
153
|
+
const order = [];
|
|
154
|
+
const visited = new Set();
|
|
155
|
+
const walk = (node) => {
|
|
156
|
+
if (visited.has(node))
|
|
157
|
+
return;
|
|
158
|
+
visited.add(node);
|
|
159
|
+
order.push(node);
|
|
160
|
+
for (const child of children.get(node) ?? [])
|
|
161
|
+
walk(child);
|
|
162
|
+
};
|
|
163
|
+
walk(root);
|
|
164
|
+
if (!visited.has(id))
|
|
165
|
+
order.push(id);
|
|
166
|
+
return order;
|
|
167
|
+
}
|
|
168
|
+
/** Key identifying sessions that belong to the same coding workstream on the server. */
|
|
169
|
+
function workstreamKey(s) {
|
|
170
|
+
if (s.kind !== 'coding')
|
|
171
|
+
return '';
|
|
172
|
+
if (s.branch && s.branch.startsWith('agent/'))
|
|
173
|
+
return `branch:${s.repo.toLowerCase()}:${s.branch}`;
|
|
174
|
+
if (s.sandbox && !s.branch)
|
|
175
|
+
return `sandbox:${s.project.toLowerCase()}:${s.sandbox}`;
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Discover thread chains from a list of server sessions (via `parent`, `root`,
|
|
180
|
+
* shared `agent/` branch, or shared sandbox) and merge them into the link map.
|
|
181
|
+
*/
|
|
182
|
+
export function deriveThreadLinks(sessions, base = readThreadLinks()) {
|
|
183
|
+
const next = { ...base };
|
|
184
|
+
const byId = new Map(sessions.map((s) => [s.id, s]));
|
|
185
|
+
const oldestFirst = [...sessions].sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
186
|
+
// 1. Explicit server parent/root relationships.
|
|
187
|
+
for (const s of oldestFirst) {
|
|
188
|
+
const parent = s.parent || (s.root && s.root !== s.id ? s.root : '');
|
|
189
|
+
if (parent && parent !== s.id && (byId.has(parent) || s.parent)) {
|
|
190
|
+
if (!next[s.id])
|
|
191
|
+
next[s.id] = parent;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// 2. Chained coding runs sharing the same agent/ branch or repo-less sandbox.
|
|
195
|
+
const streams = new Map();
|
|
196
|
+
for (const s of oldestFirst) {
|
|
197
|
+
const key = workstreamKey(s);
|
|
198
|
+
if (!key)
|
|
199
|
+
continue;
|
|
200
|
+
const list = streams.get(key) ?? [];
|
|
201
|
+
list.push(s);
|
|
202
|
+
streams.set(key, list);
|
|
203
|
+
}
|
|
204
|
+
for (const group of streams.values()) {
|
|
205
|
+
if (group.length < 2)
|
|
206
|
+
continue;
|
|
207
|
+
for (let i = 1; i < group.length; i++) {
|
|
208
|
+
const prev = group[i - 1];
|
|
209
|
+
const cur = group[i];
|
|
210
|
+
if (!next[cur.id] && threadRoot(prev.id, next) !== cur.id) {
|
|
211
|
+
next[cur.id] = prev.id;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return next;
|
|
216
|
+
}
|
|
217
|
+
/** Persist any newly discovered thread chains from a server session list. */
|
|
218
|
+
export function syncThreadsFromSessions(sessions) {
|
|
219
|
+
const before = readThreadLinks();
|
|
220
|
+
const after = deriveThreadLinks(sessions, before);
|
|
221
|
+
let changed = false;
|
|
222
|
+
for (const [k, v] of Object.entries(after)) {
|
|
223
|
+
if (before[k] !== v) {
|
|
224
|
+
changed = true;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (changed)
|
|
229
|
+
writeThreadLinks(after);
|
|
230
|
+
return after;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Collapse chained follow-up turns into a single Recents row per thread:
|
|
234
|
+
* - Stable `id` = root session id
|
|
235
|
+
* - `title` = root session title (falling back to latest)
|
|
236
|
+
* - `status`, `updatedAt`, `endedAt`, `pr`, `branch`, `sandbox` = latest turn's values
|
|
237
|
+
* - Sorted newest activity first (`updatedAt || createdAt`)
|
|
238
|
+
*/
|
|
239
|
+
export function groupSessions(sessions, links = readThreadLinks()) {
|
|
240
|
+
if (sessions.length === 0)
|
|
241
|
+
return [];
|
|
242
|
+
const merged = deriveThreadLinks(sessions, links);
|
|
243
|
+
const groups = new Map();
|
|
244
|
+
for (const s of sessions) {
|
|
245
|
+
const root = threadRoot(s.id, merged);
|
|
246
|
+
const list = groups.get(root) ?? [];
|
|
247
|
+
list.push(s);
|
|
248
|
+
groups.set(root, list);
|
|
249
|
+
}
|
|
250
|
+
const out = [];
|
|
251
|
+
for (const members of groups.values()) {
|
|
252
|
+
members.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
253
|
+
const root = members[0];
|
|
254
|
+
const latest = members[members.length - 1];
|
|
255
|
+
const activityAt = latest.updatedAt || latest.createdAt || root.updatedAt || root.createdAt;
|
|
256
|
+
out.push({
|
|
257
|
+
...root,
|
|
258
|
+
status: latest.status || root.status,
|
|
259
|
+
title: root.title || latest.title,
|
|
260
|
+
branch: latest.branch || root.branch,
|
|
261
|
+
pr: latest.pr || root.pr,
|
|
262
|
+
sandbox: latest.sandbox || root.sandbox,
|
|
263
|
+
repo: latest.repo || root.repo,
|
|
264
|
+
project: latest.project || root.project,
|
|
265
|
+
updatedAt: activityAt,
|
|
266
|
+
endedAt: latest.endedAt,
|
|
267
|
+
events: members.reduce((sum, m) => sum + m.events, 0),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
out.sort((a, b) => (b.updatedAt || b.createdAt).localeCompare(a.updatedAt || a.createdAt));
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
function subscribe(changed) {
|
|
274
|
+
if (typeof window === 'undefined')
|
|
275
|
+
return () => { };
|
|
276
|
+
const other = (e) => {
|
|
277
|
+
if (e.key === THREADS_KEY || e.key === null)
|
|
278
|
+
changed();
|
|
279
|
+
};
|
|
280
|
+
window.addEventListener(THREADS_EVENT, changed);
|
|
281
|
+
window.addEventListener('storage', other);
|
|
282
|
+
return () => {
|
|
283
|
+
window.removeEventListener(THREADS_EVENT, changed);
|
|
284
|
+
window.removeEventListener('storage', other);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** Reactive subscription to persisted single-thread links. */
|
|
288
|
+
export function useThreadLinks() {
|
|
289
|
+
return useSyncExternalStore(subscribe, readThreadLinks, () => NONE);
|
|
290
|
+
}
|
|
291
|
+
/** Test-only helper to reset in-memory thread links between unit tests. */
|
|
292
|
+
export function resetThreadLinks() {
|
|
293
|
+
held = { raw: null, links: NONE };
|
|
294
|
+
if (typeof window !== 'undefined') {
|
|
295
|
+
try {
|
|
296
|
+
window.localStorage.removeItem(THREADS_KEY);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
/* ignore */
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files with an ask, for every composer the builder draws: they ride the
|
|
3
|
+
* prompt as text — nothing is uploaded anywhere else. The paperclip is the
|
|
4
|
+
* composer's (@hanzo/ui/chat); this reads what it picks and says what is held.
|
|
5
|
+
*/
|
|
6
|
+
import type { Say } from '@hanzo/i18n/react';
|
|
7
|
+
import type { Carried } from '@hanzo/ui/chat';
|
|
8
|
+
export interface Attached {
|
|
9
|
+
name: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}
|
|
12
|
+
/** The ask with its attachments appended as fenced text. */
|
|
13
|
+
export declare function compose(prompt: string, files: Attached[]): string;
|
|
14
|
+
/** Read `list` into `have`, within the caps; answers the new list and what was refused, in the language of `t`. */
|
|
15
|
+
export declare function read(have: Attached[], list: ArrayLike<File>, t?: Say): Promise<{
|
|
16
|
+
files: Attached[];
|
|
17
|
+
note: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Ask the browser for files and read them in, within the caps; the picker is minted per press. */
|
|
20
|
+
export declare function pick(have: Attached[], onFiles: (f: Attached[]) => void, onNote: (n: string) => void, t?: Say): void;
|
|
21
|
+
/** The attached files as what the composer carries: a removable chip each. */
|
|
22
|
+
export declare function carrying(files: Attached[], onFiles: (f: Attached[]) => void): Carried[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Paperclip } from '@hanzogui/lucide-icons-2';
|
|
3
|
+
import { english } from './say.js';
|
|
4
|
+
const EACH = 100_000;
|
|
5
|
+
const ALL = 200_000;
|
|
6
|
+
/** The ask with its attachments appended as fenced text. */
|
|
7
|
+
export function compose(prompt, files) {
|
|
8
|
+
if (!files.length)
|
|
9
|
+
return prompt;
|
|
10
|
+
return prompt + files.map((f) => `\n\n\`${f.name}\`:\n\`\`\`\n${f.text}\n\`\`\``).join('');
|
|
11
|
+
}
|
|
12
|
+
/** Read `list` into `have`, within the caps; answers the new list and what was refused, in the language of `t`. */
|
|
13
|
+
export async function read(have, list, t = english) {
|
|
14
|
+
const files = [...have];
|
|
15
|
+
let total = files.reduce((n, f) => n + f.text.length, 0);
|
|
16
|
+
let note = '';
|
|
17
|
+
for (const file of Array.from(list)) {
|
|
18
|
+
if (file.size > EACH) {
|
|
19
|
+
note = t('{file} is over 100 KB; attach a smaller file or point the run at the repository.', { file: file.name });
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const text = await file.text();
|
|
23
|
+
if (total + text.length > ALL) {
|
|
24
|
+
note = t('Attachments are capped at 200 KB in all.');
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
total += text.length;
|
|
28
|
+
files.push({ name: file.name, text });
|
|
29
|
+
}
|
|
30
|
+
return { files, note };
|
|
31
|
+
}
|
|
32
|
+
/** Ask the browser for files and read them in, within the caps; the picker is minted per press. */
|
|
33
|
+
export function pick(have, onFiles, onNote, t = english) {
|
|
34
|
+
if (typeof document === 'undefined')
|
|
35
|
+
return;
|
|
36
|
+
const ask = document.createElement('input');
|
|
37
|
+
ask.type = 'file';
|
|
38
|
+
ask.multiple = true;
|
|
39
|
+
ask.onchange = () => {
|
|
40
|
+
if (!ask.files?.length)
|
|
41
|
+
return;
|
|
42
|
+
void read(have, ask.files, t).then(({ files, note }) => {
|
|
43
|
+
onFiles(files);
|
|
44
|
+
onNote(note);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
ask.click();
|
|
48
|
+
}
|
|
49
|
+
/** The attached files as what the composer carries: a removable chip each. */
|
|
50
|
+
export function carrying(files, onFiles) {
|
|
51
|
+
return files.map((f) => ({ id: `file:${f.name}`, label: f.name, icon: _jsx(Paperclip, { size: 14 }), onRemove: () => onFiles(files.filter((x) => x !== f)) }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Verdict } from '@hanzo/ui/agents';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type Card } from './api/turn.ts';
|
|
4
|
+
import { type Artifact, type Listen } from './reply.tsx';
|
|
5
|
+
export interface QueuedMessage {
|
|
6
|
+
id: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export type TranscriptView = 'normal' | 'thinking' | 'verbose';
|
|
10
|
+
export declare function Transcript({ cards, live, empty, header, onApprove, approving, onVerdict, onOpen, onDiff, listen, end, view, queued, onSendQueued, onRun, onAnswer, onAddFunds, devMode, }: {
|
|
11
|
+
cards: Card[];
|
|
12
|
+
/** The run is still working: a card still running shows it; otherwise it was cut off. */
|
|
13
|
+
live: boolean;
|
|
14
|
+
empty: ReactNode;
|
|
15
|
+
header?: ReactNode;
|
|
16
|
+
/** Build what a plan says. Absent, a plan has no button. */
|
|
17
|
+
onApprove?: (plan: string) => void;
|
|
18
|
+
approving?: boolean;
|
|
19
|
+
/** Record a verdict on what the agent said; throws when it did not land. */
|
|
20
|
+
onVerdict: (v: Verdict) => Promise<void>;
|
|
21
|
+
/** Open what an answer wrote in the side panel. */
|
|
22
|
+
onOpen?: (a: Artifact) => void;
|
|
23
|
+
/** Open the run's diff in the side panel. */
|
|
24
|
+
onDiff?: () => void;
|
|
25
|
+
/** Read an answer aloud. */
|
|
26
|
+
listen?: Listen;
|
|
27
|
+
/** After the last card: how the run ended, when it ended on an error. */
|
|
28
|
+
end?: ReactNode;
|
|
29
|
+
/** How much of the agent's internal reasoning and tool output is unfolded by default. */
|
|
30
|
+
view?: TranscriptView;
|
|
31
|
+
/** Messages queued with Ctrl+Enter while the run works, waiting to be sent. */
|
|
32
|
+
queued?: QueuedMessage[];
|
|
33
|
+
/** Send a queued message immediately. */
|
|
34
|
+
onSendQueued?: (id: string) => void;
|
|
35
|
+
/** Open a coding run a conversation started, on its own page. */
|
|
36
|
+
onRun?: (session: string) => void;
|
|
37
|
+
/** Answer a question the run asked with one of its options. Absent, a question has no buttons. */
|
|
38
|
+
onAnswer?: (question: string, label: string) => void;
|
|
39
|
+
/** Recovery action when a run stops because the account is out of credit (#363/#364). */
|
|
40
|
+
onAddFunds?: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Draw every command, read, edit and step as its own card. Off, each run of
|
|
43
|
+
* them folds into one plain line that opens onto them (plain.ts), so the
|
|
44
|
+
* transcript reads as its result. Absent, the reader's Developer mode decides.
|
|
45
|
+
*/
|
|
46
|
+
devMode?: boolean;
|
|
47
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A run's transcript, drawn by what each part is (turn.ts `cards`): what the
|
|
4
|
+
* agent said as markdown, its reasoning folded, each command it ran as a card
|
|
5
|
+
* that opens onto its output, the files it changed, its plan as a checklist, the
|
|
6
|
+
* run's own steps, a plan run's plan with the button that builds it, and in a
|
|
7
|
+
* conversation the coding runs its turns started, each opening on its own page.
|
|
8
|
+
* What the agent said, and its plan, can be copied and judged, as a reply on
|
|
9
|
+
* claude.ai can: a thumb pressed again takes the verdict back.
|
|
10
|
+
*
|
|
11
|
+
* It follows the run to the bottom as it streams and stops when the reader
|
|
12
|
+
* scrolls up (Thread). Everything drawn is text.
|
|
13
|
+
*
|
|
14
|
+
* It reads as Chat reads: the same measure (`MEASURE`), the same turns and
|
|
15
|
+
* prose sizes, the same row under an answer (`Reply`: copy, listen, and open
|
|
16
|
+
* what it wrote in the side panel), the same caret while an answer streams and
|
|
17
|
+
* the same `Failure` when a run stops on an error. What only a run has — its
|
|
18
|
+
* commands, edits and steps — are cards of their own between the turns.
|
|
19
|
+
*/
|
|
20
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
21
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
22
|
+
import { GitBranch } from '@hanzogui/lucide-icons-2';
|
|
23
|
+
import { Button } from '@hanzo/ui';
|
|
24
|
+
import { Code, GAP, MEASURE, Message, Step, Thread } from '@hanzo/ui/chat';
|
|
25
|
+
import { useState } from 'react';
|
|
26
|
+
import { counted, edited, explored } from './api/cli.js';
|
|
27
|
+
import { needsFunds } from './api/turn.js';
|
|
28
|
+
import { useDevMode } from './dev-mode.js';
|
|
29
|
+
import { doing, fold, plainPath, ranOf, worked } from './plain.js';
|
|
30
|
+
import { Prose } from './prose.js';
|
|
31
|
+
import { artifacts, lead, Reply } from './reply.js';
|
|
32
|
+
/** A card's output, its tail: what a command said last is why it stopped. */
|
|
33
|
+
const TAIL = 6000;
|
|
34
|
+
const tail = (s) => (s.length > TAIL ? `…${s.slice(-TAIL)}` : s);
|
|
35
|
+
const mono = { fontFamily: 'var(--f-mono, ui-monospace, monospace)' };
|
|
36
|
+
/** What a thought is about: its first line, without the markdown that bolds it. */
|
|
37
|
+
const firstLine = (text) => text.trim().split('\n')[0].replace(/[*_#`]/g, '').slice(0, 120);
|
|
38
|
+
/** A user turn: a tight bubble holding only the text; Show more and Send now sit outside, below it. */
|
|
39
|
+
function UserSaid({ text, after }) {
|
|
40
|
+
const { t } = useI18n();
|
|
41
|
+
const [open, setOpen] = useState(false);
|
|
42
|
+
const long = text.length > 180 || text.includes('\n');
|
|
43
|
+
return (_jsxs(YStack, { width: "100%", items: "flex-end", gap: "$1", children: [_jsx(Message, { role: "user", children: _jsx(YStack, { ...(long && !open ? { maxHeight: 72, overflow: 'hidden' } : null), children: _jsx(Prose, { text: text }) }) }), long ? (_jsx(XStack, { render: "button", "aria-expanded": open, onPress: () => setOpen((v) => !v), self: "flex-start", px: "$2", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", color: "$soft", children: open ? t('Show less') : t('Show more') }) })) : null, after] }));
|
|
44
|
+
}
|
|
45
|
+
export function Transcript({ cards, live, empty, header, onApprove, approving = false, onVerdict, onOpen, onDiff, listen, end, view = 'normal', queued = [], onSendQueued, onRun, onAnswer, onAddFunds, devMode, }) {
|
|
46
|
+
const { t } = useI18n();
|
|
47
|
+
const [developer, setDeveloper] = useDevMode();
|
|
48
|
+
const dev = devMode ?? developer;
|
|
49
|
+
// A path a person reads off Developer mode is said in words (`~` is "your home folder").
|
|
50
|
+
const path = (p) => (dev ? p : plainPath(p, t));
|
|
51
|
+
// A card the run never finished is cut off once the run has ended, not still going.
|
|
52
|
+
const state = (ran) => (ran === 'running' && !live ? 'cancelled' : ran);
|
|
53
|
+
// The answer still arriving: the last thing the agent said while the run works.
|
|
54
|
+
const last = live ? [...cards].reverse().find((c) => c.kind === 'said' && c.who === 'agent')?.key : undefined;
|
|
55
|
+
const expandThink = view === 'thinking' || view === 'verbose';
|
|
56
|
+
const expandVerbose = view === 'verbose';
|
|
57
|
+
const draw = (c) => {
|
|
58
|
+
switch (c.kind) {
|
|
59
|
+
case 'said': {
|
|
60
|
+
if (c.who === 'person')
|
|
61
|
+
return _jsx(UserSaid, { text: c.text }, c.key);
|
|
62
|
+
const made = artifacts(c.text);
|
|
63
|
+
const first = lead(made);
|
|
64
|
+
return (_jsx(Message, { role: "assistant", busy: c.key === last, children: _jsxs(YStack, { gap: "$1", children: [_jsx(Prose, { text: c.text }), c.key === last ? null : (_jsx(Reply, { text: c.text, listen: listen, onRate: onVerdict, onOpen: first && onOpen ? () => onOpen(first) : undefined }))] }) }, c.key));
|
|
65
|
+
}
|
|
66
|
+
case 'think':
|
|
67
|
+
return (_jsx(Step, { name: t('Thought'), detail: firstLine(c.text), status: "done", defaultOpen: expandThink, "aria-label": t('Thought'), children: _jsx(Prose, { text: c.text }) }, `${c.key}:${view}`));
|
|
68
|
+
case 'todo':
|
|
69
|
+
return (_jsx(YStack, { gap: "$1", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Plan checklist'), children: c.items.map((x, i) => (_jsxs(XStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: x.done ? '$ink' : '$soft', children: x.done ? '✓' : '○' }), _jsx(SizableText, { flex: 1, size: "$2", color: x.done ? '$soft' : '$ink', children: x.text })] }, i))) }, c.key));
|
|
70
|
+
case 'shell':
|
|
71
|
+
// The CLI's words: Ran (Running while it works), the command as the shell got it, its output under it.
|
|
72
|
+
return (_jsx(Step, { name: state(c.ran) === 'running' ? t('Running') : t('Ran'), detail: c.command, status: state(c.ran), defaultOpen: expandVerbose, "aria-label": t('Command {command}', { command: c.command }), children: _jsx(Code, { language: "shell", value: c.output || t('(no output)'), children: c.output ? tail(c.output.replace(/\n+$/, '')) : t('(no output)') }) }, `${c.key}:${view}`));
|
|
73
|
+
case 'explore':
|
|
74
|
+
// The CLI's Explored block: one line an action, consecutive reads on one line (cli.ts explored).
|
|
75
|
+
return (_jsxs(YStack, { gap: "$1", "aria-label": state(c.ran) === 'running' ? t('Exploring') : t('Explored'), children: [_jsx(SizableText, { size: "$2", color: "$ink", fontWeight: "600", children: state(c.ran) === 'running' ? t('Exploring') : t('Explored') }), explored(c.calls).map((l, i) => (_jsxs(XStack, { gap: "$2", pl: "$3", children: [_jsx(SizableText, { size: "$2", color: "$soft", shrink: 0, children: t(l.title) }), _jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, overflowWrap: 'anywhere' }, children: path(l.text) })] }, i)))] }, c.key));
|
|
76
|
+
case 'edit':
|
|
77
|
+
// The CLI's patch header: Added / Deleted / Edited a file, or Edited N files, with the lines added and removed.
|
|
78
|
+
return (_jsx(Step, { name: !c.files.length ? t('Edited files') : c.files.length > 1 ? `Edited ${c.files.length} files` : edited(c.files).split(' ')[0], detail: !c.files.length ? '' : c.files.length > 1 ? edited(c.files).split(' ').slice(3).join(' ') : edited(c.files).split(' ').slice(1).join(' '), status: state(c.ran), defaultOpen: expandVerbose, "aria-label": c.files.length ? edited(c.files) : t('Edited files'), children: _jsxs(YStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$1", color: "$soft", style: { whiteSpace: 'pre-wrap' }, children: c.files.length ? c.files.map((f) => `${path(f.path)} ${counted(f)}`.trimEnd()).join('\n') : t('The agent named no files.') }), onDiff ? (_jsx(Button, { size: "sm", variant: "outline", onPress: onDiff, children: t('Open the diff') })) : null] }) }, `${c.key}:${view}`));
|
|
79
|
+
case 'step':
|
|
80
|
+
return (_jsx(Step, { name: t(c.name), detail: c.detail, status: state(c.ran), defaultOpen: c.name === 'Error' || expandVerbose, "aria-label": `${t(c.name)} ${c.detail}`.trim(), children: c.name === 'Error' ? (_jsxs(YStack, { gap: "$2", items: "flex-start", children: [_jsx(SizableText, { size: "$2", color: "$ink", style: { ...mono, whiteSpace: 'pre-wrap', overflowWrap: 'anywhere' }, children: c.output }), onAddFunds && needsFunds(c.output) ? (_jsx(Button, { size: "sm", variant: "primary", onPress: onAddFunds, children: t('Add funds') })) : null] })) : c.output.trim() ? (_jsx(Code, { language: "output", value: c.output, children: tail(c.output.replace(/\n+$/, '')) })) : undefined }, `${c.key}:${view}`));
|
|
81
|
+
case 'note': {
|
|
82
|
+
const noteText = t(c.text);
|
|
83
|
+
if (/^Pushed\s+/i.test(c.text) || /^Pushed\s+/i.test(noteText)) {
|
|
84
|
+
return (_jsx(XStack, { role: "note", self: "flex-start", children: _jsxs(XStack, { items: "center", gap: "$1.5", px: "$2.5", py: "$1", "$platform-web": { display: 'inline-flex' }, children: [_jsx(GitBranch, { size: 12, color: "$soft", shrink: 0, "aria-hidden": true }), _jsx(SizableText, { size: "$1", color: "$soft", children: noteText })] }) }, c.key));
|
|
85
|
+
}
|
|
86
|
+
if (c.funds && onAddFunds) {
|
|
87
|
+
return (_jsxs(YStack, { gap: "$2", items: "flex-start", role: "note", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: noteText }), _jsx(Button, { size: "sm", variant: "primary", onPress: onAddFunds, children: t('Add funds') })] }, c.key));
|
|
88
|
+
}
|
|
89
|
+
return (_jsx(SizableText, { size: "$1", color: "$soft", role: "note", children: noteText }, c.key));
|
|
90
|
+
}
|
|
91
|
+
case 'run':
|
|
92
|
+
return (_jsxs(XStack, { items: "center", gap: "$2", px: "$3", py: "$2", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Coding run'), children: [_jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", numberOfLines: 1, children: t('Coding run') }), onRun ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => onRun(c.session), children: t('Open the run') })) : null] }, c.key));
|
|
93
|
+
case 'ask':
|
|
94
|
+
return (_jsxs(YStack, { gap: "$2", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", "aria-label": t('Question'), children: [_jsx(Prose, { text: c.text }), c.answer ? (_jsx(SizableText, { size: "$2", color: "$soft", children: `✓ ${c.answer}` })) : (_jsx(XStack, { gap: "$2", flexWrap: "wrap", children: c.options.map((label) => (_jsx(Button, { size: "sm", variant: "outline", disabled: !onAnswer, onPress: () => onAnswer?.(c.question, label), children: label }, label))) }))] }, c.key));
|
|
95
|
+
case 'plan':
|
|
96
|
+
return (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", "aria-label": t('Plan'), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Plan') }), _jsx(Prose, { text: c.text }), _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(Reply, { text: c.text, listen: listen, onRate: onVerdict }), onApprove ? (_jsx(Button, { size: "sm", disabled: approving, onPress: () => onApprove(c.text), children: approving ? t('Starting the build…') : t('Approve and build') })) : null] })] }, c.key));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// The work between two things a person reads, as one line that opens onto it.
|
|
100
|
+
const work = (w) => {
|
|
101
|
+
const ran = ranOf(w.cards, state);
|
|
102
|
+
const now = [...w.cards].reverse().find((c) => 'ran' in c && state(c.ran) === 'running');
|
|
103
|
+
const name = ran === 'running' ? t('Working') : t('Worked');
|
|
104
|
+
const line = ran === 'running' ? doing(now ?? w.cards[w.cards.length - 1], t) : worked(w.cards, t);
|
|
105
|
+
return (_jsx(Step, { name: name, detail: line, status: ran, defaultOpen: expandVerbose, "aria-label": `${name} ${line}`.trim(), children: _jsxs(YStack, { gap: "$2", children: [w.cards.map(draw), _jsx(XStack, { render: "button", self: "flex-start", "aria-label": t('Turn on Developer mode'), onPress: () => setDeveloper(true), px: "$2", py: "$1", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('Always show each step: turn on Developer mode') }) })] }) }, `${w.key}:${view}`));
|
|
106
|
+
};
|
|
107
|
+
return (_jsxs(Thread, { gap: GAP, column: { maxW: MEASURE }, "aria-label": t('Transcript'), children: [header, cards.length === 0 && queued.length === 0 ? _jsx(YStack, { py: "$2", children: empty }) : null, dev ? cards.map(draw) : fold(cards).map((x) => (x.kind === 'work' ? work(x) : draw(x))), queued.map((q) => (_jsx(UserSaid, { text: q.text, after: onSendQueued ? (_jsx(XStack, { render: "button", "aria-label": t('Send now'), onPress: () => onSendQueued(q.id), px: "$2", py: "$0.5", children: _jsx(SizableText, { size: "$1", color: "$soft", children: t('Send now') }) })) : undefined }, q.id))), end] }));
|
|
108
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Speech } from '@hanzo/voice';
|
|
2
|
+
import type { Target } from './api/call.ts';
|
|
3
|
+
/** The platform's ear and voice for a target: dictation, talk and Listen all hear through it. */
|
|
4
|
+
export declare function useEar(t: Target): Speech;
|
|
5
|
+
/** The language this browser is set to, when it is one dictation offers; English otherwise. */
|
|
6
|
+
export declare function spoken(): string;
|
|
7
|
+
/** The person's saved language (Settings → General), else this browser's, else English. */
|
|
8
|
+
export declare function useSpoken(): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The language dictation listens in, and the platform's ear. The microphone
|
|
3
|
+
* itself is the composer's (@hanzo/ui/chat, @hanzo/voice): heard by the
|
|
4
|
+
* platform, never by a browser's built-in recognizer, which ships the audio to
|
|
5
|
+
* its vendor.
|
|
6
|
+
*/
|
|
7
|
+
import { LANGUAGES } from '@hanzo/ui/chat/pure';
|
|
8
|
+
import { speech } from '@hanzo/voice';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import { usePrefs } from './prefs.js';
|
|
11
|
+
/** The platform's ear and voice for a target: dictation, talk and Listen all hear through it. */
|
|
12
|
+
export function useEar(t) {
|
|
13
|
+
return useMemo(() => speech({ baseUrl: t.api, token: t.token, ...(t.org ? { org: t.org } : {}) }), [t]);
|
|
14
|
+
}
|
|
15
|
+
/** The language this browser is set to, when it is one dictation offers; English otherwise. */
|
|
16
|
+
export function spoken() {
|
|
17
|
+
const nav = typeof navigator !== 'undefined' ? navigator.language.split('-')[0] : 'en';
|
|
18
|
+
return LANGUAGES.some((l) => l.id === nav) ? nav : 'en';
|
|
19
|
+
}
|
|
20
|
+
/** The person's saved language (Settings → General), else this browser's, else English. */
|
|
21
|
+
export function useSpoken() {
|
|
22
|
+
const { prefs } = usePrefs();
|
|
23
|
+
return LANGUAGES.some((l) => l.id === prefs.language) ? prefs.language : spoken();
|
|
24
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as e, n as t } from "./messages-yqmY7G5x.js";
|
|
2
2
|
import { Tf as n, t as r } from "./utils-515nQ17G.js";
|
|
3
3
|
import { P as i } from "./keybindings-C5tK_GAk.js";
|
|
4
|
-
import { $ as a, E as o, Q as s, Y as c, k as l, l as u, o as d, s as f, u as p } from "./DiffCommentAnnotation-
|
|
4
|
+
import { $ as a, E as o, Q as s, Y as c, k as l, l as u, o as d, s as f, u as p } from "./DiffCommentAnnotation-BPTN_2a6.js";
|
|
5
5
|
import { $ as m, $t as h, A as g, At as _, B as v, Bt as y, C as b, Ct as x, D as S, Dt as C, E as w, Et as T, F as E, Ft as D, G as O, H as k, Ht as A, I as j, It as ee, J as M, Jt as N, K as P, Kt as F, L as I, Lt as L, M as te, Mt as R, Nt as ne, O as re, Ot as ie, Pt as ae, Q as oe, R as se, Rt as ce, S as le, T as ue, U as de, Ut as fe, V as pe, Vt as me, W as he, Wt as ge, X as _e, Xt as ve, Y as ye, Yt as be, Zt as xe, _ as Se, _t as Ce, at as we, b as Te, bt as Ee, c as De, cn as Oe, ct as ke, d as Ae, dt as je, en as Me, et as Ne, f as z, ft as Pe, g as B, gt as Fe, h as Ie, ht as Le, in as Re, it as ze, jt as Be, k as V, kt as Ve, lt as He, m as Ue, mt as We, nn as H, nt as Ge, o as Ke, on as qe, ot as Je, p as Ye, pt as Xe, q as Ze, qt as Qe, r as $e, rn as et, s as tt, sn as U, st as nt, t as rt, tn as it, tt as at, v as ot, vt as st, w as ct, wt as lt, x as ut, xt as dt, y as ft, yt as pt } from "./DiffWorkerPoolProvider-BwFR-Fc9.js";
|
|
6
6
|
import { A as W, B as mt, C as ht, E as gt, F as _t, I as vt, L as yt, O as bt, R as xt, T as St, _ as Ct, b as wt, d as Tt, f as Et, g as Dt, h as Ot, j as kt, k as At, l as jt, p as Mt, t as Nt, v as Pt, w as Ft, x as It, y as Lt, z as Rt } from "./diffRendering-tvIuzFsP.js";
|
|
7
7
|
import { i as zt } from "./themeResolver-n7YLSRSv.js";
|
package/dist/core.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { r as DevChatList, i as DevHome, d as DevProvider, t as DevPublish, s as DevStart, c as DevThreadList, o as DevWorkspace, l as focusComposer, u as focusThreadList, a as useDevOpen, n as useReplyModels } from "./embed-c030vUqM.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as e, n as t } from "./messages-yqmY7G5x.js";
|
|
2
2
|
import { n } from "./previewFailureMessages-BKpsSGX5.js";
|
|
3
|
-
import { t as r } from "./readBinaryPreview-
|
|
3
|
+
import { t as r } from "./readBinaryPreview-BAQ4fFjm.js";
|
|
4
4
|
// src/components/files/decodeImagePreview.ts
|
|
5
5
|
async function i(i, a, o) {
|
|
6
6
|
let s = new Worker(new URL(
|