@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,60 @@
|
|
|
1
|
+
import { type Target } from './api/call.ts';
|
|
2
|
+
/** What a run or a turn may do on its own: the permission mode. */
|
|
3
|
+
export type Mode = 'auto' | 'manual' | 'plan';
|
|
4
|
+
/**
|
|
5
|
+
* The modes, one line each. Chat offers Auto and Manual; Dev adds Plan. Manual
|
|
6
|
+
* is a real pause: before a plugin runs for a message (a search, a site read, a
|
|
7
|
+
* deck), the person allows it once, always in this conversation, or not, and a
|
|
8
|
+
* Dev run is asked for before it starts. Written in English and marked
|
|
9
|
+
* (`phrase`): the composer draws each word through `t`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const MODES: readonly {
|
|
12
|
+
id: Mode;
|
|
13
|
+
label: string;
|
|
14
|
+
note: string;
|
|
15
|
+
}[];
|
|
16
|
+
/** The modes each surface offers. */
|
|
17
|
+
export declare const CHAT_MODES: readonly Mode[];
|
|
18
|
+
export declare const DEV_MODES: readonly Mode[];
|
|
19
|
+
export interface Gear {
|
|
20
|
+
/** Skill names (`/v1/tool/skills`). */
|
|
21
|
+
skills: string[];
|
|
22
|
+
/** Connector ids (`/v1/tool/mcp/servers`). */
|
|
23
|
+
connectors: string[];
|
|
24
|
+
/** Plugin ids. */
|
|
25
|
+
plugins: string[];
|
|
26
|
+
/** A design system's id, or ''. */
|
|
27
|
+
design: string;
|
|
28
|
+
/** A machine's id, or '' for none (Chat) or the sandbox (Dev). */
|
|
29
|
+
device: string;
|
|
30
|
+
research: boolean;
|
|
31
|
+
memory: boolean;
|
|
32
|
+
mode: Mode;
|
|
33
|
+
/** In Manual, the plugins allowed for the rest of this conversation. */
|
|
34
|
+
allowed: string[];
|
|
35
|
+
}
|
|
36
|
+
export declare const BARE: Gear;
|
|
37
|
+
/** How many conversations keep a choice of their own: the document holds 16 KiB in all. */
|
|
38
|
+
export declare const KEEP = 30;
|
|
39
|
+
/** A stored value as a Gear, a field the reader does not know read as unset. */
|
|
40
|
+
export declare function gearOf(raw: unknown, base?: Gear): Gear;
|
|
41
|
+
/** `gears` with `key`'s entry first, cut to `KEEP`. */
|
|
42
|
+
export declare function shelve(gears: Record<string, Gear>, key: string, g: Gear): Record<string, Gear>;
|
|
43
|
+
export interface GearState {
|
|
44
|
+
gear: Gear;
|
|
45
|
+
/** Change this conversation's choice. */
|
|
46
|
+
set: (patch: Partial<Gear>) => void;
|
|
47
|
+
/** Add or take out one id of a list. */
|
|
48
|
+
toggle: (field: 'skills' | 'connectors' | 'plugins', id: string) => void;
|
|
49
|
+
/** Make this conversation's choice the person's default. */
|
|
50
|
+
keep: () => void;
|
|
51
|
+
/** Whether a save was refused, in the platform's words. */
|
|
52
|
+
error: string | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The gear of the conversation `key` names (`''` for one not begun: it reads and
|
|
56
|
+
* writes the default until it has an id). Signed out, it lives for the page.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useGear(t: Target, key?: string): GearState;
|
|
59
|
+
/** The dictation language the person keeps, null for Auto, and how to change it. */
|
|
60
|
+
export declare function useLanguage(t: Target): readonly [string | null, (id: string | null) => void];
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a conversation carries beside its words: the skills, connectors and
|
|
3
|
+
* plugins picked from the composer's `+`, the design system, the device, the
|
|
4
|
+
* Research and Memory switches and the mode. Chat and Dev keep it the same way.
|
|
5
|
+
*
|
|
6
|
+
* GET /v1/pref {prefs: {gear, gears}}
|
|
7
|
+
* PATCH /v1/pref {gear} — the person's default, what a new conversation opens with
|
|
8
|
+
* {gears: {<key>: Gear}} — each conversation's own, newest first, at most `KEEP`
|
|
9
|
+
*
|
|
10
|
+
* Both live in the account, so a choice follows the person to every device. A
|
|
11
|
+
* conversation that has none of its own reads the default; changing one writes
|
|
12
|
+
* that conversation's. A conversation not begun holds its choice on the page
|
|
13
|
+
* (`draft`) and hands it to the conversation once it has an id. What carries
|
|
14
|
+
* over to the next new conversation is only the switches (`STICKY`: Research,
|
|
15
|
+
* Memory, the mode); a skill or a plugin is picked for the conversation it was
|
|
16
|
+
* picked in.
|
|
17
|
+
*/
|
|
18
|
+
import { phrase } from '@hanzo/i18n';
|
|
19
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
20
|
+
import { call } from './api/call.js';
|
|
21
|
+
/**
|
|
22
|
+
* The modes, one line each. Chat offers Auto and Manual; Dev adds Plan. Manual
|
|
23
|
+
* is a real pause: before a plugin runs for a message (a search, a site read, a
|
|
24
|
+
* deck), the person allows it once, always in this conversation, or not, and a
|
|
25
|
+
* Dev run is asked for before it starts. Written in English and marked
|
|
26
|
+
* (`phrase`): the composer draws each word through `t`.
|
|
27
|
+
*/
|
|
28
|
+
export const MODES = [
|
|
29
|
+
{ id: 'auto', label: phrase('Auto'), note: phrase('Runs tools on its own; pauses only for anything risky.') },
|
|
30
|
+
{ id: 'manual', label: phrase('Manual'), note: phrase('Asks before each tool, connector or site it opens.') },
|
|
31
|
+
{ id: 'plan', label: phrase('Plan'), note: phrase('Writes the plan and waits for your go before changing anything.') },
|
|
32
|
+
];
|
|
33
|
+
/** The modes each surface offers. */
|
|
34
|
+
export const CHAT_MODES = ['auto', 'manual'];
|
|
35
|
+
export const DEV_MODES = ['auto', 'manual', 'plan'];
|
|
36
|
+
export const BARE = {
|
|
37
|
+
skills: [],
|
|
38
|
+
connectors: [],
|
|
39
|
+
plugins: [],
|
|
40
|
+
design: '',
|
|
41
|
+
device: '',
|
|
42
|
+
research: false,
|
|
43
|
+
memory: true,
|
|
44
|
+
mode: 'auto',
|
|
45
|
+
allowed: [],
|
|
46
|
+
};
|
|
47
|
+
/** What a new conversation carries over from the last: the switches, never a pick. */
|
|
48
|
+
const STICKY = ['research', 'memory', 'mode'];
|
|
49
|
+
const pick = (g) => ({ research: g.research, memory: g.memory, mode: g.mode });
|
|
50
|
+
/** How many conversations keep a choice of their own: the document holds 16 KiB in all. */
|
|
51
|
+
export const KEEP = 30;
|
|
52
|
+
const list = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string' && x !== '') : []);
|
|
53
|
+
const text = (v) => (typeof v === 'string' ? v : '');
|
|
54
|
+
/** A stored value as a Gear, a field the reader does not know read as unset. */
|
|
55
|
+
export function gearOf(raw, base = BARE) {
|
|
56
|
+
const o = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {};
|
|
57
|
+
return {
|
|
58
|
+
skills: 'skills' in o ? list(o.skills) : base.skills,
|
|
59
|
+
connectors: 'connectors' in o ? list(o.connectors) : base.connectors,
|
|
60
|
+
plugins: 'plugins' in o ? list(o.plugins) : base.plugins,
|
|
61
|
+
design: 'design' in o ? text(o.design) : base.design,
|
|
62
|
+
device: 'device' in o ? text(o.device) : base.device,
|
|
63
|
+
research: typeof o.research === 'boolean' ? o.research : base.research,
|
|
64
|
+
memory: typeof o.memory === 'boolean' ? o.memory : base.memory,
|
|
65
|
+
mode: MODES.some((m) => m.id === o.mode) ? o.mode : base.mode,
|
|
66
|
+
allowed: 'allowed' in o ? list(o.allowed) : base.allowed,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** `gears` with `key`'s entry first, cut to `KEEP`. */
|
|
70
|
+
export function shelve(gears, key, g) {
|
|
71
|
+
const out = { [key]: g };
|
|
72
|
+
for (const [k, v] of Object.entries(gears)) {
|
|
73
|
+
if (k === key)
|
|
74
|
+
continue;
|
|
75
|
+
if (Object.keys(out).length >= KEEP)
|
|
76
|
+
break;
|
|
77
|
+
out[k] = v;
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
let doc = { gear: BARE, gears: {}, draft: null, language: null };
|
|
82
|
+
let loaded = null;
|
|
83
|
+
const listeners = new Set();
|
|
84
|
+
const emit = () => listeners.forEach((f) => f());
|
|
85
|
+
const subscribe = (f) => {
|
|
86
|
+
listeners.add(f);
|
|
87
|
+
return () => listeners.delete(f);
|
|
88
|
+
};
|
|
89
|
+
function load(t) {
|
|
90
|
+
const id = `${t.api}|${t.org ?? ''}|${t.token() ? 1 : 0}`;
|
|
91
|
+
if (loaded === id || !t.token())
|
|
92
|
+
return;
|
|
93
|
+
loaded = id;
|
|
94
|
+
void call(t, 'GET', '/v1/pref')
|
|
95
|
+
.then((r) => {
|
|
96
|
+
const raw = r?.prefs ?? {};
|
|
97
|
+
const gear = gearOf(raw.gear);
|
|
98
|
+
const all = raw.gears && typeof raw.gears === 'object' ? raw.gears : {};
|
|
99
|
+
const language = typeof raw.language === 'string' && raw.language ? raw.language : null;
|
|
100
|
+
doc = { gear, gears: Object.fromEntries(Object.entries(all).map(([k, v]) => [k, gearOf(v, gear)])), draft: doc.draft, language };
|
|
101
|
+
emit();
|
|
102
|
+
})
|
|
103
|
+
.catch(() => {
|
|
104
|
+
loaded = null;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The gear of the conversation `key` names (`''` for one not begun: it reads and
|
|
109
|
+
* writes the default until it has an id). Signed out, it lives for the page.
|
|
110
|
+
*/
|
|
111
|
+
export function useGear(t, key = '') {
|
|
112
|
+
useEffect(() => load(t), [t]);
|
|
113
|
+
const now = useSyncExternalStore(subscribe, () => doc, () => doc);
|
|
114
|
+
const [error, setError] = useState(null);
|
|
115
|
+
// A conversation with no choice of its own starts from the switches alone.
|
|
116
|
+
const fresh = useMemo(() => ({ ...BARE, ...pick(now.gear) }), [now.gear]);
|
|
117
|
+
const gear = key ? (now.gears[key] ?? fresh) : (now.draft ?? fresh);
|
|
118
|
+
const save = useCallback((patch) => {
|
|
119
|
+
if (!t.token())
|
|
120
|
+
return;
|
|
121
|
+
call(t, 'PATCH', '/v1/pref', patch).then(() => setError(null), (e) => setError(e instanceof Error ? e.message : 'Your choice was not saved.'));
|
|
122
|
+
}, [t]);
|
|
123
|
+
// The conversation just begun takes what was picked before it had an id.
|
|
124
|
+
const was = useRef(key);
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
const from = was.current;
|
|
127
|
+
was.current = key;
|
|
128
|
+
if (from || !key || !doc.draft || doc.gears[key])
|
|
129
|
+
return;
|
|
130
|
+
doc = { ...doc, gears: shelve(doc.gears, key, doc.draft), draft: null };
|
|
131
|
+
emit();
|
|
132
|
+
save({ gears: doc.gears });
|
|
133
|
+
}, [key, save]);
|
|
134
|
+
const write = useCallback((g) => {
|
|
135
|
+
if (key) {
|
|
136
|
+
doc = { ...doc, gears: shelve(doc.gears, key, g) };
|
|
137
|
+
emit();
|
|
138
|
+
return save({ gears: doc.gears });
|
|
139
|
+
}
|
|
140
|
+
// Not begun: the page holds it; the switches become the default too.
|
|
141
|
+
const sticky = { ...doc.gear, ...pick(g) };
|
|
142
|
+
const moved = STICKY.some((k) => sticky[k] !== doc.gear[k]);
|
|
143
|
+
doc = { ...doc, draft: g, ...(moved ? { gear: sticky } : null) };
|
|
144
|
+
emit();
|
|
145
|
+
if (moved)
|
|
146
|
+
save({ gear: sticky });
|
|
147
|
+
}, [key, save]);
|
|
148
|
+
return useMemo(() => ({
|
|
149
|
+
gear,
|
|
150
|
+
error,
|
|
151
|
+
set: (patch) => write({ ...gear, ...patch }),
|
|
152
|
+
toggle: (field, id) => {
|
|
153
|
+
const has = gear[field].includes(id);
|
|
154
|
+
write({ ...gear, [field]: has ? gear[field].filter((x) => x !== id) : [...gear[field], id] });
|
|
155
|
+
},
|
|
156
|
+
keep: () => {
|
|
157
|
+
doc = { ...doc, gear };
|
|
158
|
+
emit();
|
|
159
|
+
if (t.token())
|
|
160
|
+
call(t, 'PATCH', '/v1/pref', { gear }).catch((e) => setError(e instanceof Error ? e.message : 'Not saved.'));
|
|
161
|
+
},
|
|
162
|
+
}), [gear, error, write, t]);
|
|
163
|
+
}
|
|
164
|
+
/** The dictation language the person keeps, null for Auto, and how to change it. */
|
|
165
|
+
export function useLanguage(t) {
|
|
166
|
+
useEffect(() => load(t), [t]);
|
|
167
|
+
const now = useSyncExternalStore(subscribe, () => doc, () => doc);
|
|
168
|
+
const set = useCallback((id) => {
|
|
169
|
+
const was = doc.language;
|
|
170
|
+
doc = { ...doc, language: id };
|
|
171
|
+
emit();
|
|
172
|
+
// A refused save takes the choice back, so what is shown is what is kept.
|
|
173
|
+
if (t.token())
|
|
174
|
+
call(t, 'PATCH', '/v1/pref', { language: id }).catch(() => {
|
|
175
|
+
doc = { ...doc, language: was };
|
|
176
|
+
emit();
|
|
177
|
+
});
|
|
178
|
+
}, [t]);
|
|
179
|
+
return [now.language, set];
|
|
180
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function Git({ session, title, live }: {
|
|
2
|
+
session: string;
|
|
3
|
+
title: string;
|
|
4
|
+
live: boolean;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* Merge for a run's pull request, shown while it is open: `POST …/merge` lands
|
|
8
|
+
* the run's branch in its base at the commit the forge holds now. One press is
|
|
9
|
+
* one merge — pressed again while it is out, nothing more is sent — and a
|
|
10
|
+
* refusal says the forge's reason. `onMerged` reads the run again, which is
|
|
11
|
+
* what closes the button: the pull request reads merged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Merge({ session, open, onMerged }: {
|
|
14
|
+
session: string;
|
|
15
|
+
open: boolean;
|
|
16
|
+
onMerged: () => void;
|
|
17
|
+
}): import("react").JSX.Element | null;
|
|
18
|
+
/** A unified diff's lines, coloured by what each does: the Git tab's, and a transcript's edit card's. */
|
|
19
|
+
export declare function Patch({ text }: {
|
|
20
|
+
text: string;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A run's Git tab: what it pushed, read from the forge. Diff is the net change
|
|
4
|
+
* from its base, Review is the pull request it opened and what reviewers said,
|
|
5
|
+
* with Merge while it is open, Commits is its branch's history since the base.
|
|
6
|
+
* While the run works it is read again every little while, because a run
|
|
7
|
+
* pushes when it finishes a step.
|
|
8
|
+
*
|
|
9
|
+
* Its words are the reader's language (@hanzo/i18n `t`); branches, paths,
|
|
10
|
+
* commit messages, a pull request's title and its reviews are drawn as given.
|
|
11
|
+
*/
|
|
12
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
13
|
+
import { phrase } from '@hanzo/i18n';
|
|
14
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
15
|
+
import { ChevronDown, ChevronRight } from '@hanzogui/lucide-icons-2';
|
|
16
|
+
import { Button } from '@hanzo/ui';
|
|
17
|
+
import { useEffect, useState } from 'react';
|
|
18
|
+
import { merge, read } from './api/changes.js';
|
|
19
|
+
import { useRead } from './data.js';
|
|
20
|
+
import { useHost, useTarget } from './host.js';
|
|
21
|
+
import { Out } from './out.js';
|
|
22
|
+
const NONE = { repo: '', base: '', head: '', commits: [], files: [], pull: null };
|
|
23
|
+
const AGAIN = 15_000;
|
|
24
|
+
const mono = { fontFamily: 'var(--f-mono, ui-monospace, monospace)', whiteSpace: 'pre' };
|
|
25
|
+
export function Git({ session, title, live }) {
|
|
26
|
+
const host = useHost();
|
|
27
|
+
const target = useTarget();
|
|
28
|
+
const { t } = useI18n();
|
|
29
|
+
const signed = Boolean(host.person);
|
|
30
|
+
const [view, setView] = useState('diff');
|
|
31
|
+
const got = useRead(signed ? () => read(target, session) : null, NONE, [target, session, signed, live]);
|
|
32
|
+
const { reload } = got;
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!live)
|
|
35
|
+
return;
|
|
36
|
+
const every = setInterval(reload, AGAIN);
|
|
37
|
+
return () => clearInterval(every);
|
|
38
|
+
}, [live, reload]);
|
|
39
|
+
const c = got.value;
|
|
40
|
+
const added = c.files.reduce((n, f) => n + f.additions, 0);
|
|
41
|
+
const removed = c.files.reduce((n, f) => n + f.deletions, 0);
|
|
42
|
+
return (_jsxs(YStack, { gap: "$3", children: [_jsxs(YStack, { gap: "$1", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: title }), c.head ? (_jsxs(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: [`${c.head} → ${c.base}`, c.files.length ? ` · ${c.files.length === 1 ? t('1 file') : t('{n} files', { n: c.files.length })} +${added} −${removed}` : ''] })) : null] }), _jsx(XStack, { gap: "$1", children: ['diff', 'review', 'commits'].map((v) => (_jsx(XStack, { render: "button", "aria-label": t(label(v)), onPress: () => setView(v), px: "$2.5", py: "$1", rounded: "$2", bg: view === v ? '$hover' : 'transparent', children: _jsx(SizableText, { size: "$2", color: view === v ? '$ink' : '$soft', children: t(label(v)) }) }, v))) }), !signed ? (_jsx(Soft, { children: t('Sign in to see what this run pushed.') })) : got.error ? (_jsx(Soft, { children: got.error.message })) : got.loading && !c.head ? (_jsx(Soft, { children: t('Reading the branch…') })) : view === 'diff' ? (c.files.length ? (_jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", overflow: "hidden", children: c.files.map((f, i) => (_jsx(File, { change: f, first: i === 0 }, f.path))) })) : (_jsx(Soft, { children: t('No pushed changes') }))) : view === 'review' ? (c.pull ? (_jsxs(YStack, { gap: "$3", children: [_jsxs(YStack, { gap: "$1.5", p: "$3", borderWidth: 1, borderColor: "$borderColor", rounded: "$3", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: `#${c.pull.number} ${c.pull.title}` }), _jsx(SizableText, { size: "$1", color: "$soft", children: c.pull.state === 'open'
|
|
43
|
+
? c.pull.mergeable === false
|
|
44
|
+
? t('Open · conflicts with its base')
|
|
45
|
+
: c.pull.mergeable
|
|
46
|
+
? t('Open · ready to merge')
|
|
47
|
+
: t('Open')
|
|
48
|
+
: c.pull.state === 'merged'
|
|
49
|
+
? t('Merged')
|
|
50
|
+
: t('Closed') }), c.pull.url.startsWith('https://') ? (_jsx(Out, { href: c.pull.url, label: t('Open pull request {pr}', { pr: `#${c.pull.number}` }), children: _jsx(SizableText, { size: "$1", color: "$ink", textDecorationLine: "underline", children: t('Open on the forge') }) })) : null, _jsx(Merge, { session: session, open: c.pull.state === 'open', onMerged: reload })] }), c.pull.reviews.length ? (c.pull.reviews.map((r, i) => (_jsxs(YStack, { gap: "$1", pb: "$2", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: [r.author || t('Someone'), verdict(r.state, t), when(r.at)].filter(Boolean).join(' · ') }), r.body ? (_jsx(SizableText, { size: "$2", color: "$ink", children: r.body })) : null] }, i)))) : (_jsx(Soft, { children: t('No reviews yet') }))] })) : (_jsx(Soft, { children: t('No pull request yet. The run opens one when it pushes its changes.') }))) : c.commits.length ? (_jsx(YStack, { children: c.commits.map((k) => (_jsxs(XStack, { gap: "$3", py: "$2", borderBottomWidth: 1, borderColor: "$borderColor", items: "baseline", children: [_jsx(SizableText, { size: "$1", color: "$soft", style: mono, children: k.sha.slice(0, 7) }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 2, children: k.message }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: [k.author, when(k.date)].filter(Boolean).join(' · ') })] })] }, k.sha))) })) : (_jsx(Soft, { children: t('No pushed commits') }))] }));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Merge for a run's pull request, shown while it is open: `POST …/merge` lands
|
|
54
|
+
* the run's branch in its base at the commit the forge holds now. One press is
|
|
55
|
+
* one merge — pressed again while it is out, nothing more is sent — and a
|
|
56
|
+
* refusal says the forge's reason. `onMerged` reads the run again, which is
|
|
57
|
+
* what closes the button: the pull request reads merged.
|
|
58
|
+
*/
|
|
59
|
+
export function Merge({ session, open, onMerged }) {
|
|
60
|
+
const target = useTarget();
|
|
61
|
+
const { t } = useI18n();
|
|
62
|
+
const [busy, setBusy] = useState(false);
|
|
63
|
+
const [note, setNote] = useState('');
|
|
64
|
+
const press = async () => {
|
|
65
|
+
if (busy)
|
|
66
|
+
return;
|
|
67
|
+
setBusy(true);
|
|
68
|
+
setNote('');
|
|
69
|
+
try {
|
|
70
|
+
const done = await merge(target, session);
|
|
71
|
+
setNote(done.base ? t('Merged into {branch}', { branch: done.base }) : t('Merged'));
|
|
72
|
+
onMerged();
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
setNote(e.message);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
setBusy(false);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
if (!open && !note)
|
|
82
|
+
return null;
|
|
83
|
+
return (_jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [open ? (_jsx(Button, { size: "sm", variant: "outline", "aria-busy": busy, onPress: () => void press(), children: busy ? t('Merging…') : t('Merge') })) : null, note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note })) : null] }));
|
|
84
|
+
}
|
|
85
|
+
function File({ change: f, first }) {
|
|
86
|
+
const { t } = useI18n();
|
|
87
|
+
const [open, setOpen] = useState(false);
|
|
88
|
+
const lines = f.patch ? f.patch.split('\n') : [];
|
|
89
|
+
return (_jsxs(YStack, { borderTopWidth: first ? 0 : 1, borderColor: "$borderColor", children: [_jsxs(XStack, { render: "button", "aria-label": open ? t('Hide {path}', { path: f.path }) : t('Show {path}', { path: f.path }), onPress: () => setOpen(!open), items: "center", gap: "$2", px: "$3", py: "$2", hoverStyle: { bg: '$hover' }, children: [open ? _jsx(ChevronDown, { size: 14 }) : _jsx(ChevronRight, { size: 14, 'data-i18n-mirror': '' }), _jsx(SizableText, { size: "$1", color: "$soft", width: 12, children: f.status[0].toUpperCase() }), _jsx(SizableText, { flex: 1, minW: 0, size: "$2", color: "$ink", numberOfLines: 1, text: "start", children: f.from ? `${f.from} → ${f.path}` : f.path }), _jsx(SizableText, { size: "$1", color: "$green10", children: `+${f.additions}` }), _jsx(SizableText, { size: "$1", color: "$red10", children: `−${f.deletions}` })] }), open ? (_jsxs(YStack, { px: "$3", pb: "$2", overflow: "scroll", children: [lines.length ? (_jsx(Patch, { text: f.patch })) : (_jsx(SizableText, { size: "$1", color: "$soft", children: f.truncated ? t('Too large to show here.') : t('Binary file') })), lines.length && f.truncated ? (_jsx(SizableText, { size: "$1", color: "$soft", children: t('The rest of this file’s change is too large to show here.') })) : null] })) : null] }));
|
|
90
|
+
}
|
|
91
|
+
/** A unified diff's lines, coloured by what each does: the Git tab's, and a transcript's edit card's. */
|
|
92
|
+
export function Patch({ text }) {
|
|
93
|
+
return (_jsx(_Fragment, { children: text.split('\n').map((l, i) => (_jsx(SizableText, { size: "$1", style: mono, color: l.startsWith('@@') ? '$soft' : l.startsWith('+') ? '$green10' : l.startsWith('-') ? '$red10' : '$ink', children: l || ' ' }, i))) }));
|
|
94
|
+
}
|
|
95
|
+
/** A view's name, marked (`phrase`): drawn through `t`. */
|
|
96
|
+
function label(v) {
|
|
97
|
+
return v === 'diff' ? phrase('Diff') : v === 'review' ? phrase('Review') : phrase('Commits');
|
|
98
|
+
}
|
|
99
|
+
/** What a reviewer did, in the reader's language; a state the forge names that is not one of these is drawn as given. */
|
|
100
|
+
function verdict(state, t) {
|
|
101
|
+
switch (state.toUpperCase()) {
|
|
102
|
+
case 'APPROVED':
|
|
103
|
+
return t('approved');
|
|
104
|
+
case 'REQUEST_CHANGES':
|
|
105
|
+
return t('asked for changes');
|
|
106
|
+
case 'COMMENT':
|
|
107
|
+
return t('commented');
|
|
108
|
+
default:
|
|
109
|
+
return state.toLowerCase() || t('reviewed');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function when(iso) {
|
|
113
|
+
const d = new Date(iso);
|
|
114
|
+
return Number.isNaN(d.getTime()) ? '' : d.toLocaleString();
|
|
115
|
+
}
|
|
116
|
+
function Soft({ children }) {
|
|
117
|
+
return (_jsx(YStack, { py: "$6", items: "center", children: _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: children }) }));
|
|
118
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The grip between two panes, one for every edge: the sidebar's, the side
|
|
3
|
+
* panel's, a run's chat against its work. The kit's Grip with its `inline` bar
|
|
4
|
+
* (drawn only while it is reached for), its band centred across the gutter and
|
|
5
|
+
* the bar halfway down it, so each edge looks and moves the same.
|
|
6
|
+
*
|
|
7
|
+
* side the edge the box it sits in is pinned to (Grip's): `left` for a
|
|
8
|
+
* sidebar, whose free edge is its right, `right` for an aside
|
|
9
|
+
* gap the gutter's width; the frame's `--pane-gap` by default
|
|
10
|
+
* inset the box's own border, px: an absolute place is measured inside it
|
|
11
|
+
*/
|
|
12
|
+
import { type GripProps } from '@hanzo/ui';
|
|
13
|
+
export type GutterProps = Omit<GripProps, 'bar'> & {
|
|
14
|
+
gap?: string | number;
|
|
15
|
+
inset?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function Gutter({ side, gap, inset, ...rest }: GutterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The grip between two panes, one for every edge: the sidebar's, the side
|
|
4
|
+
* panel's, a run's chat against its work. The kit's Grip with its `inline` bar
|
|
5
|
+
* (drawn only while it is reached for), its band centred across the gutter and
|
|
6
|
+
* the bar halfway down it, so each edge looks and moves the same.
|
|
7
|
+
*
|
|
8
|
+
* side the edge the box it sits in is pinned to (Grip's): `left` for a
|
|
9
|
+
* sidebar, whose free edge is its right, `right` for an aside
|
|
10
|
+
* gap the gutter's width; the frame's `--pane-gap` by default
|
|
11
|
+
* inset the box's own border, px: an absolute place is measured inside it
|
|
12
|
+
*/
|
|
13
|
+
import { Grip } from '@hanzo/ui';
|
|
14
|
+
import { gap as GAP } from './pane.js';
|
|
15
|
+
export function Gutter({ side, gap = GAP, inset = 0, ...rest }) {
|
|
16
|
+
const g = typeof gap === 'number' ? `${gap}px` : gap;
|
|
17
|
+
// A CSS length gui takes as written; its types name only tokens and numbers.
|
|
18
|
+
const band = `max(8px, ${g})`;
|
|
19
|
+
// The band's start, so its middle is the gutter's: half the gutter and half the band out from the edge.
|
|
20
|
+
const at = (w) => `calc(-1 * (${g} + ${w}) / 2 - ${inset}px)`;
|
|
21
|
+
const edge = side === 'left' ? 'r' : 'l';
|
|
22
|
+
return (_jsx(Grip, { side: side, bar: "inline", justify: "center", width: band, [edge]: at(band),
|
|
23
|
+
// A finger's band, centred on the same line.
|
|
24
|
+
$touchable: { width: 44, [edge]: at('44px') }, ...rest }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Chat's "Open in Dev" leaves in this tab's session storage for the New
|
|
3
|
+
* page to pick up: a prompt, and optionally some code to run it on. One key, one
|
|
4
|
+
* reader, so Chat and Dev cannot drift apart.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEV_HANDOFF = "hanzo.handoff.dev";
|
|
7
|
+
/** The draft the handoff makes, or '' for none; the handoff is consumed either way. */
|
|
8
|
+
export declare function takeHandoff(store: Pick<Storage, 'getItem' | 'removeItem'>): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What Chat's "Open in Dev" leaves in this tab's session storage for the New
|
|
3
|
+
* page to pick up: a prompt, and optionally some code to run it on. One key, one
|
|
4
|
+
* reader, so Chat and Dev cannot drift apart.
|
|
5
|
+
*/
|
|
6
|
+
export const DEV_HANDOFF = 'hanzo.handoff.dev';
|
|
7
|
+
/** The draft the handoff makes, or '' for none; the handoff is consumed either way. */
|
|
8
|
+
export function takeHandoff(store) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = store.getItem(DEV_HANDOFF);
|
|
11
|
+
if (!raw)
|
|
12
|
+
return '';
|
|
13
|
+
store.removeItem(DEV_HANDOFF);
|
|
14
|
+
const h = JSON.parse(raw);
|
|
15
|
+
const text = (v) => (typeof v === 'string' ? v.trim() : '');
|
|
16
|
+
const code = text(h.code);
|
|
17
|
+
return [text(h.prompt), code && `\`\`\`${text(h.language)}\n${code}\n\`\`\``].filter(Boolean).join('\n\n');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the builder needs from the page that mounts it.
|
|
3
|
+
*
|
|
4
|
+
* The builder is ONE component with several hosts: its own page (hanzo.build,
|
|
5
|
+
* which signs in through Hanzo IAM and routes with react-router) and the Hanzo
|
|
6
|
+
* app's Dev section (hanzo.ai/dev and hanzo.app/dev, which already have a
|
|
7
|
+
* session, a router and a rail). Everything that differs between them is here,
|
|
8
|
+
* as values, so no host forks the builder and the builder imports no host.
|
|
9
|
+
*/
|
|
10
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
11
|
+
import type { Cast } from './api/agents.ts';
|
|
12
|
+
import type { Target } from './api/call.ts';
|
|
13
|
+
import type { Theme } from './api/pref.ts';
|
|
14
|
+
import type { Local } from './local.ts';
|
|
15
|
+
import type { Site } from './site.ts';
|
|
16
|
+
export interface Person {
|
|
17
|
+
name: string;
|
|
18
|
+
email: string;
|
|
19
|
+
/** An https image, or '' for the initial. */
|
|
20
|
+
avatar: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A page tab's address, drawn by the host rather than in a frame: what the
|
|
24
|
+
* window can show of any site, where a browser page can frame only the sites
|
|
25
|
+
* that allow it. `onGo` is a move the page made itself (a link followed), and
|
|
26
|
+
* `onTitle` the title it gave itself.
|
|
27
|
+
*/
|
|
28
|
+
export type Browse = ComponentType<{
|
|
29
|
+
url: string;
|
|
30
|
+
title: string;
|
|
31
|
+
onGo: (url: string) => void;
|
|
32
|
+
onTitle?: (title: string) => void;
|
|
33
|
+
}>;
|
|
34
|
+
/** A page as the host's browser is asked about it: the tab, and what it shows. */
|
|
35
|
+
export interface Shown {
|
|
36
|
+
id: string;
|
|
37
|
+
url: string;
|
|
38
|
+
title: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What the host's browser can do to the page a tab shows, each the row of the
|
|
42
|
+
* same name in the tab's menu. A host draws only the rows it supplies, so the
|
|
43
|
+
* menu offers nothing the window cannot do; a browser page supplies none and
|
|
44
|
+
* draws what a page itself can (panel.tsx).
|
|
45
|
+
*/
|
|
46
|
+
export interface Browser {
|
|
47
|
+
find?: (page: Shown) => void;
|
|
48
|
+
print?: (page: Shown) => void;
|
|
49
|
+
/** Zoom the page to `percent` (100 is its own size). */
|
|
50
|
+
zoom?: (page: Shown, percent: number) => void;
|
|
51
|
+
devices?: (page: Shown) => void;
|
|
52
|
+
/** The page's pixels, as an image. */
|
|
53
|
+
capture?: (page: Shown) => Promise<Blob>;
|
|
54
|
+
/** What the reader has selected in the page. */
|
|
55
|
+
selection?: (page: Shown) => Promise<string>;
|
|
56
|
+
passwords?: () => void;
|
|
57
|
+
downloads?: () => void;
|
|
58
|
+
history?: () => void;
|
|
59
|
+
clear?: () => void;
|
|
60
|
+
settings?: () => void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* What kind of spend a press is: `task-run` one run of a scheduled task now,
|
|
64
|
+
* `task` a task switched on (or made on) to run by itself, `bot` a 24/7 bot
|
|
65
|
+
* made, `run` a coding run started, `machine` a suspended cloud computer woken,
|
|
66
|
+
* `publish` a site built and published (a template copied, a project published again).
|
|
67
|
+
*/
|
|
68
|
+
export type SpendKind = 'run' | 'task-run' | 'task' | 'bot' | 'machine' | 'publish';
|
|
69
|
+
/** What a press must say before it spends, already in the person's language. */
|
|
70
|
+
export interface Ask {
|
|
71
|
+
kind: SpendKind;
|
|
72
|
+
/** The question: "Run Monday summary now?" */
|
|
73
|
+
title: string;
|
|
74
|
+
/** What will start, one sentence. */
|
|
75
|
+
what: string;
|
|
76
|
+
/** The yes button's words: the act itself ("Run now"). */
|
|
77
|
+
yes: string;
|
|
78
|
+
/** `computer`: it starts a cloud computer. `credits`: it counts against the plan or credits and starts no computer. */
|
|
79
|
+
uses: 'computer' | 'credits';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A question as the host is asked it. `again` is the key a host may remember a "Don't ask again" under, or null to
|
|
83
|
+
* ask every time. It is `<kind>.<uses>` (`task-run.credits`, `run.computer`), so one yes covers only the same kind of
|
|
84
|
+
* spend on the same kind of thing. A host keeps nothing it is not given a key for. A 24/7 bot's is null by its TYPE:
|
|
85
|
+
* each has its own budget and period, so no yes is ever remembered for one.
|
|
86
|
+
*/
|
|
87
|
+
export type Spend = (Ask & {
|
|
88
|
+
kind: Exclude<SpendKind, 'bot'>;
|
|
89
|
+
again: string | null;
|
|
90
|
+
}) | (Ask & {
|
|
91
|
+
kind: 'bot';
|
|
92
|
+
again: null;
|
|
93
|
+
});
|
|
94
|
+
export interface Host {
|
|
95
|
+
/** The product's name, drawn at the top left: `Hanzo Build` on hanzo.build, `Hanzo` on hanzo.ai. */
|
|
96
|
+
name: string;
|
|
97
|
+
/** The platform origin, no trailing slash. */
|
|
98
|
+
api: string;
|
|
99
|
+
/** The signed-in person's bearer, or null. Read at call time, so a refresh is picked up. */
|
|
100
|
+
token: () => string | null;
|
|
101
|
+
/** The org every call is scoped to. */
|
|
102
|
+
org: string | null;
|
|
103
|
+
/** The org's own logo, an https address, when it has chosen one; its mark is drawn from it. */
|
|
104
|
+
logo?: string;
|
|
105
|
+
/** The organizations this person belongs to. The switcher lists these and no others. */
|
|
106
|
+
memberships?: readonly string[];
|
|
107
|
+
/** Stay on this page and scope every read to `org`. */
|
|
108
|
+
chooseOrg?: (org: string) => void;
|
|
109
|
+
/** The page's theme as last chosen, for a host that can change it. */
|
|
110
|
+
theme?: Theme;
|
|
111
|
+
/** Paint the page in `theme`. A host without it keeps its own, and Settings offers no choice. */
|
|
112
|
+
chooseTheme?: (theme: Theme) => void;
|
|
113
|
+
/** Who is signed in, or null. */
|
|
114
|
+
person: Person | null;
|
|
115
|
+
/** Whether the person administers `org` (its owner or an admin): they publish to main and change its money; anyone else opens a review and reads. */
|
|
116
|
+
admin: boolean;
|
|
117
|
+
/** The address under the mount, in route.ts's grammar: '' | a session id | `<org>/<repo>` | a slug | '-/projects' | '-/issues' | … */
|
|
118
|
+
path: string;
|
|
119
|
+
/** Move under the mount. */
|
|
120
|
+
go: (path: string, how?: {
|
|
121
|
+
replace?: boolean;
|
|
122
|
+
}) => void;
|
|
123
|
+
/** Where the builder links out. On hanzo.build these are addresses of this page. */
|
|
124
|
+
links: {
|
|
125
|
+
/** GitHub for this page: bringing repositories onto the forge. */
|
|
126
|
+
github: string;
|
|
127
|
+
/** Customize, an address of this host. */
|
|
128
|
+
customize: string;
|
|
129
|
+
/** Account settings, an address of this host. */
|
|
130
|
+
settings: string;
|
|
131
|
+
/** This host's home. On hanzo.build it is the page itself. */
|
|
132
|
+
home: string;
|
|
133
|
+
};
|
|
134
|
+
/** Open a host address in this window. hanzo.build keeps the window on its own origin. */
|
|
135
|
+
open: (href: string) => void;
|
|
136
|
+
/**
|
|
137
|
+
* Take the person to top the prepaid balance up, returning to this page with the
|
|
138
|
+
* model they chose (`?model=`) once paid. Another maker's models are paid from the
|
|
139
|
+
* balance on any plan, so a host that offers a top-up has them selectable on Free.
|
|
140
|
+
* Absent, they follow the plan as before.
|
|
141
|
+
*/
|
|
142
|
+
topUp?: (model?: string) => void;
|
|
143
|
+
signIn?: () => void;
|
|
144
|
+
signOut?: () => void;
|
|
145
|
+
/** A page tab's remote address, shown by the host (Hanzo Desktop: a native webview). Absent, a browser frames what it may. */
|
|
146
|
+
browse?: Browse;
|
|
147
|
+
/** What the host's browser does to a page, row by row in the tab's menu. */
|
|
148
|
+
browser?: Browser;
|
|
149
|
+
/** The host's sidebar lists Settings' sections and Customize's tabs, so the pages draw neither. */
|
|
150
|
+
sections?: boolean;
|
|
151
|
+
/** The default agents Customize › Agents offers to start from. Absent, none. */
|
|
152
|
+
cast?: readonly Cast[];
|
|
153
|
+
/** Every persona Customize › Agents offers to start from, read when Browse opens. Absent, none. */
|
|
154
|
+
personas?: () => Promise<readonly Cast[]>;
|
|
155
|
+
/**
|
|
156
|
+
* The folders of the computer the host runs on, and a run in one of them (local.ts): Hanzo Desktop has them, so New
|
|
157
|
+
* offers This computer with Auto picking the folder used last. A browser page has no folder of its own: absent.
|
|
158
|
+
*/
|
|
159
|
+
local?: Local;
|
|
160
|
+
/**
|
|
161
|
+
* Opening a site, saving a copy of it for the agent, and serving its redesign live in the person's browser (site.ts):
|
|
162
|
+
* Hanzo Desktop can, so New on This computer offers to redesign a site from its address. A browser page cannot: absent.
|
|
163
|
+
*/
|
|
164
|
+
site?: Site;
|
|
165
|
+
/**
|
|
166
|
+
* Asks the person before a press spends (spend.tsx), and answers whether they said yes. A host that gives it is the
|
|
167
|
+
* only asker: the builder draws no question of its own and spends only on `true`. Absent (this package's own page),
|
|
168
|
+
* the builder asks in its own dialog. A no, a throw, an answer after the asking screen has gone, or one a newer
|
|
169
|
+
* question on that screen superseded spends nothing; one left unanswered blocks nothing.
|
|
170
|
+
*/
|
|
171
|
+
confirm?: (spend: Spend) => Promise<boolean>;
|
|
172
|
+
}
|
|
173
|
+
export declare function HostProvider({ host, children }: {
|
|
174
|
+
host: Host;
|
|
175
|
+
children: ReactNode;
|
|
176
|
+
}): import("react").JSX.Element;
|
|
177
|
+
export declare function useHost(): Host;
|
|
178
|
+
/** The host, or null where none is mounted: a surface that may be drawn without one (the first run's card in Chat). */
|
|
179
|
+
export declare function useHosted(): Host | null;
|
|
180
|
+
/** The host's way of showing a page, where one is mounted and has one. The side panel is drawn without a host too (hanzo.team's rooms). */
|
|
181
|
+
export declare function useBrowse(): Browse | null;
|
|
182
|
+
/** The host's computer and its folders, where the host runs on one (Hanzo Desktop). */
|
|
183
|
+
export declare function useLocal(): Local | null;
|
|
184
|
+
/** The host's way of redesigning a site, where the host runs on a computer that can (Hanzo Desktop). */
|
|
185
|
+
export declare function useSite(): Site | null;
|
|
186
|
+
/** The host's browser, where one is mounted and has one. */
|
|
187
|
+
export declare function useBrowser(): Browser | null;
|
|
188
|
+
/** The call target for this host — stable while the host's api, token reader and org are. */
|
|
189
|
+
export declare function useTarget(): Target;
|