@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,138 @@
|
|
|
1
|
+
import { english } from './say.js';
|
|
2
|
+
/** The top-level names a bare address may end in: the ones people paste. A file name (`index.html`, `README.md`, `main.rs`) is none of them. */
|
|
3
|
+
const TLDS = new Set('com org net io ai app dev co me xyz site shop store online tech design studio agency news blog edu gov info biz us uk ca de fr jp au nz in eu nl se no es it ch be pl br mx cn'.split(' '));
|
|
4
|
+
/** The verbs that ask for this with an address in the same sentence. */
|
|
5
|
+
const REDESIGN = /\b(re-?design|re-?build|re-?vamp|re-?style|re-?work|modernis[ez]e|refresh|critique|improve|review)\b/i;
|
|
6
|
+
/** A scheme-less address that names this computer: it carries a port, so the word `localhost` alone is not one. */
|
|
7
|
+
const LOCAL = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\]):\d{1,5}(?:[/?#]\S*)?$/i;
|
|
8
|
+
/** A bare name: labels, a top-level name people paste, an optional port and path. */
|
|
9
|
+
const BARE = /^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+([a-z]{2,24})(?::\d{1,5})?(?:[/?#]\S*)?$/i;
|
|
10
|
+
/** What a sentence hangs off the front of an address, and off its end, that is not part of it. */
|
|
11
|
+
const FRONT = /^[(<["'“‘]+/;
|
|
12
|
+
/** An address as written in a sentence: without the brackets, quotes and punctuation round it (a `)` that closes a `(` inside it stays). */
|
|
13
|
+
function bare(word) {
|
|
14
|
+
let text = word.trim().replace(FRONT, '');
|
|
15
|
+
for (;;) {
|
|
16
|
+
const last = text[text.length - 1];
|
|
17
|
+
const open = last === ')' && (text.match(/\(/g)?.length ?? 0) >= (text.match(/\)/g)?.length ?? 0);
|
|
18
|
+
if (!last || open || !'.,;:!?\'"”’>])'.includes(last))
|
|
19
|
+
return text;
|
|
20
|
+
text = text.slice(0, -1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** One word as an address, or null. A scheme is taken as written; a bare name must end in a name people paste. */
|
|
24
|
+
export function addressOf(word) {
|
|
25
|
+
const text = bare(word);
|
|
26
|
+
if (!text || text.length > 2048)
|
|
27
|
+
return null;
|
|
28
|
+
let full;
|
|
29
|
+
if (/^https?:\/\//i.test(text))
|
|
30
|
+
full = text;
|
|
31
|
+
else if (LOCAL.test(text))
|
|
32
|
+
full = `http://${text}`;
|
|
33
|
+
else {
|
|
34
|
+
const m = BARE.exec(text);
|
|
35
|
+
if (!m || !TLDS.has(m[1].toLowerCase()))
|
|
36
|
+
return null;
|
|
37
|
+
full = `https://${text}`;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const url = new URL(full);
|
|
41
|
+
if (!url.hostname || url.username || url.password)
|
|
42
|
+
return null;
|
|
43
|
+
if (!url.hostname.includes('.') && !url.hostname.includes(':') && url.hostname !== 'localhost')
|
|
44
|
+
return null;
|
|
45
|
+
return url.href;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The site an ask is about, or null when it is about none. An ask is a site's when it is an address alone, or has one
|
|
53
|
+
* address and asks to redesign, rebuild, restyle or critique: anything else is a message that happens to hold a link,
|
|
54
|
+
* and is sent as it is.
|
|
55
|
+
*/
|
|
56
|
+
export function urlOf(ask) {
|
|
57
|
+
const words = ask.trim().split(/\s+/).filter(Boolean);
|
|
58
|
+
if (!words.length)
|
|
59
|
+
return null;
|
|
60
|
+
const found = words.map((w) => ({ w, url: addressOf(w) })).filter((x) => x.url !== null);
|
|
61
|
+
if (words.length === 1)
|
|
62
|
+
return found[0] ? { url: found[0].url, note: '' } : null;
|
|
63
|
+
if (found.length !== 1)
|
|
64
|
+
return null;
|
|
65
|
+
const note = words.filter((w) => w !== found[0].w).join(' ');
|
|
66
|
+
return REDESIGN.test(note) ? { url: found[0].url, note } : null;
|
|
67
|
+
}
|
|
68
|
+
/** The site's own name: its host without `www.` and its top-level name (`blog.example.com` is `blog-example`). */
|
|
69
|
+
export function siteName(url) {
|
|
70
|
+
let host = '';
|
|
71
|
+
try {
|
|
72
|
+
host = new URL(url).hostname.toLowerCase();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return 'site';
|
|
76
|
+
}
|
|
77
|
+
host = host.replace(/^www\./, '').replace(/^\[|\]$/g, '');
|
|
78
|
+
if (host === 'localhost' || host.endsWith('.localhost') || /^[\d.]+$/.test(host) || host.includes(':'))
|
|
79
|
+
return 'localhost';
|
|
80
|
+
const labels = host.split('.');
|
|
81
|
+
if (labels.length > 1)
|
|
82
|
+
labels.pop();
|
|
83
|
+
if (labels.length > 1 && ['co', 'com', 'org', 'net', 'ac', 'gov', 'edu'].includes(labels[labels.length - 1]))
|
|
84
|
+
labels.pop();
|
|
85
|
+
return labels.join('-').replace(/[^a-z0-9-]+/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '') || 'site';
|
|
86
|
+
}
|
|
87
|
+
/** What the redesign's folder is called: `example-redesign`. */
|
|
88
|
+
export function folderName(url) {
|
|
89
|
+
return `${siteName(url)}-redesign`;
|
|
90
|
+
}
|
|
91
|
+
/** What a person reads for a site: its host, without `www.`. */
|
|
92
|
+
export function hostOf(url) {
|
|
93
|
+
try {
|
|
94
|
+
return new URL(url).host.replace(/^www\./, '');
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return url;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** What each saved file is, in the words the agent is told. */
|
|
101
|
+
function describe(file) {
|
|
102
|
+
if (file === 'text.md')
|
|
103
|
+
return 'the site’s address, its words in reading order, and the pictures it shows';
|
|
104
|
+
if (file === 'page.html')
|
|
105
|
+
return 'the page as the site sent it';
|
|
106
|
+
if (/^style-\d+\.css$/.test(file))
|
|
107
|
+
return 'one of its stylesheets';
|
|
108
|
+
if (/^screenshot\./.test(file))
|
|
109
|
+
return 'how the page looks';
|
|
110
|
+
return 'saved from the site';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* What the agent is told. It has no network and no browser: it reads the copy the host saved, answers with a plain
|
|
114
|
+
* critique, and writes the new site as static files into `redesign/`, which is already being shown.
|
|
115
|
+
*/
|
|
116
|
+
export function brief(saved, note = '') {
|
|
117
|
+
const what = saved.title && saved.title !== saved.url ? `${saved.url} (${saved.title})` : saved.url;
|
|
118
|
+
const lines = [
|
|
119
|
+
`Redesign the website ${what}.`,
|
|
120
|
+
'',
|
|
121
|
+
'The site is saved in this folder for you to read, so you need no network:',
|
|
122
|
+
...saved.files.map((f) => `- .hanzo/reference/${f}: ${describe(f)}`),
|
|
123
|
+
'',
|
|
124
|
+
'Do two things.',
|
|
125
|
+
'',
|
|
126
|
+
'1. Critique it. Begin your answer with a short critique in plain language: what works, what does not, and what you will change, across design, content and usability. Ten lines at most, no jargon.',
|
|
127
|
+
'2. Rebuild it. Build the redesigned site as plain static files in the folder `redesign/` here: `index.html`, with its CSS, any scripts and any images beside it, linked by relative paths. Keep the site’s own words and purpose. Improve the layout, type, colour, spacing and clarity, and make it work well on a phone. Pictures may be linked from their own addresses, as text.md lists them. Do not start a server and do not use the network: a live preview of `redesign/` is already open for the person and reloads by itself each time you save a file.',
|
|
128
|
+
];
|
|
129
|
+
if (note.trim())
|
|
130
|
+
lines.push('', `The person added: “${note.trim()}”`);
|
|
131
|
+
lines.push('', 'End by saying, in a sentence or two, what you changed and what to look at first.');
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
/** Why a step stopped, in the reader's words: the host's own plain refusals as they come, else this. */
|
|
135
|
+
export function stopped(e, say = english) {
|
|
136
|
+
const why = typeof e === 'string' ? e : e instanceof Error ? e.message : '';
|
|
137
|
+
return why || say('The redesign could not start. Try again.');
|
|
138
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Ask, type Spend } from './host.tsx';
|
|
3
|
+
/** What the spend costs, said after `what`. No price: the package knows none it could stand behind. */
|
|
4
|
+
export declare const USES: Record<Spend['uses'], string>;
|
|
5
|
+
/**
|
|
6
|
+
* `ask(question)` answers true only on a yes; spend only then. Draw `dialog`
|
|
7
|
+
* anywhere in the caller's tree (it is null under a host confirm).
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSpend(): {
|
|
10
|
+
ask: (a: Ask) => Promise<boolean>;
|
|
11
|
+
dialog: ReactNode;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The one question before a suspended cloud workspace is woken, from its Wake
|
|
15
|
+
* button or from anything that needs it running (a door, a preview, its dev
|
|
16
|
+
* server): `wake()` answers whether the person agreed (api/sandbox.ts `Wake`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function useWake(): {
|
|
19
|
+
wake: () => Promise<boolean>;
|
|
20
|
+
dialog: ReactNode;
|
|
21
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Asking before a press spends: a run that starts now, a task that runs itself,
|
|
4
|
+
* a bot that runs around the clock, a cloud computer woken. ONE way to ask: the
|
|
5
|
+
* host's `confirm` (host.tsx) when it has one, so a host with its own spend
|
|
6
|
+
* question (the Hanzo app's `useSpend`) is the only asker and the person is
|
|
7
|
+
* never asked twice; this package's one confirm (ask.tsx) only where the host
|
|
8
|
+
* gives none (its standalone page). What counts as a yes is question.ts's rule.
|
|
9
|
+
*/
|
|
10
|
+
import { phrase } from '@hanzo/i18n';
|
|
11
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
13
|
+
import { Confirm } from './ask.js';
|
|
14
|
+
import { useHosted } from './host.js';
|
|
15
|
+
import { asker } from './question.js';
|
|
16
|
+
/** What the spend costs, said after `what`. No price: the package knows none it could stand behind. */
|
|
17
|
+
export const USES = {
|
|
18
|
+
computer: phrase('It starts a cloud computer, which counts against your plan or your credits.'),
|
|
19
|
+
credits: phrase('It counts against your plan or your credits.'),
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `ask(question)` answers true only on a yes; spend only then. Draw `dialog`
|
|
23
|
+
* anywhere in the caller's tree (it is null under a host confirm).
|
|
24
|
+
*/
|
|
25
|
+
export function useSpend() {
|
|
26
|
+
const { t } = useI18n();
|
|
27
|
+
const confirm = useHosted()?.confirm;
|
|
28
|
+
const [shown, setShown] = useState(null);
|
|
29
|
+
const answer = useRef(null);
|
|
30
|
+
const settle = (yes) => {
|
|
31
|
+
const resolve = answer.current;
|
|
32
|
+
answer.current = null;
|
|
33
|
+
setShown(null);
|
|
34
|
+
resolve?.(yes);
|
|
35
|
+
};
|
|
36
|
+
// The host's confirm as it is now, so a host that hands a new function each render still gets one stable asker.
|
|
37
|
+
const theirs = useRef(confirm);
|
|
38
|
+
theirs.current = confirm;
|
|
39
|
+
const asked = useMemo(() => asker((spend) => {
|
|
40
|
+
const host = theirs.current;
|
|
41
|
+
if (host)
|
|
42
|
+
return host(spend);
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
// A newer question takes the dialog; the one it replaces is a no.
|
|
45
|
+
answer.current?.(false);
|
|
46
|
+
answer.current = resolve;
|
|
47
|
+
setShown(spend);
|
|
48
|
+
});
|
|
49
|
+
}), []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
asked.enter();
|
|
52
|
+
return () => {
|
|
53
|
+
asked.leave();
|
|
54
|
+
answer.current?.(false);
|
|
55
|
+
answer.current = null;
|
|
56
|
+
};
|
|
57
|
+
}, [asked]);
|
|
58
|
+
const dialog = confirm ? null : (_jsx(Confirm, { open: shown !== null, onOpenChange: (open) => !open && settle(false), title: shown?.title ?? '', says: shown ? `${shown.what} ${t(USES[shown.uses])}` : '', act: shown?.yes ?? '', danger: false, run: async () => settle(true) }));
|
|
59
|
+
return { ask: asked.ask, dialog };
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The one question before a suspended cloud workspace is woken, from its Wake
|
|
63
|
+
* button or from anything that needs it running (a door, a preview, its dev
|
|
64
|
+
* server): `wake()` answers whether the person agreed (api/sandbox.ts `Wake`).
|
|
65
|
+
*/
|
|
66
|
+
export function useWake() {
|
|
67
|
+
const { t } = useI18n();
|
|
68
|
+
const { ask, dialog } = useSpend();
|
|
69
|
+
// One function for the screen's life: effects that open a door or a preview hold it, and must not run again for it.
|
|
70
|
+
const words = useRef(t);
|
|
71
|
+
words.current = t;
|
|
72
|
+
const wake = useCallback(() => ask({
|
|
73
|
+
kind: 'machine',
|
|
74
|
+
title: words.current('Wake the cloud workspace?'),
|
|
75
|
+
what: words.current('This starts its cloud computer again, with its files as they were, until it is suspended or the run ends.'),
|
|
76
|
+
yes: words.current('Wake'),
|
|
77
|
+
uses: 'computer',
|
|
78
|
+
}), [ask]);
|
|
79
|
+
return { wake, dialog };
|
|
80
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Say } from '@hanzo/i18n/react';
|
|
2
|
+
import { type Allowance } from './api/billing.ts';
|
|
3
|
+
import type { Target } from './api/call.ts';
|
|
4
|
+
import { type Limits } from './api/limits.ts';
|
|
5
|
+
import { type Read } from './data.ts';
|
|
6
|
+
import { type Kind, type Label, type State } from './plan.ts';
|
|
7
|
+
export interface Standing {
|
|
8
|
+
kind: Kind;
|
|
9
|
+
/** What the account is on, as a title: the plan's name, Free, or Pay as you go. */
|
|
10
|
+
label: Label | null;
|
|
11
|
+
limits: Limits | null;
|
|
12
|
+
/** The free allowance, where the platform answered it. */
|
|
13
|
+
allowance: Allowance | null;
|
|
14
|
+
/** The prepaid balance in cents, or null where it could not be read. */
|
|
15
|
+
balance: number | null;
|
|
16
|
+
}
|
|
17
|
+
/** Every read at once. Rejects only when all of them were refused, with the first refusal. */
|
|
18
|
+
export declare function stand(t: Target): Promise<Standing>;
|
|
19
|
+
/** The standing for `t`, read when `enabled` (a menu that is open) and again when the org changes. */
|
|
20
|
+
export declare function useStanding(t: Target, enabled?: boolean): Read<Standing | null>;
|
|
21
|
+
/** One window of a plan as a menu lists it. */
|
|
22
|
+
export interface Row {
|
|
23
|
+
name: 'Session' | 'Today' | 'Month';
|
|
24
|
+
percent: number;
|
|
25
|
+
state: State;
|
|
26
|
+
/** `Resets 5:00 PM`, or '' where nothing is running yet. */
|
|
27
|
+
resets: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A plan's windows, shortest first: the session, the UTC day, and the month —
|
|
31
|
+
* the billing period of whichever class of model has used the most of it,
|
|
32
|
+
* because that is the one that stops a request first.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rows(l: Limits | null, now?: number, t?: Say): Row[];
|
|
35
|
+
/** The share of the free allowance left in its window, 0 to 100, or null where none bounds the account. */
|
|
36
|
+
export declare function left(a: Allowance | null): number | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where an account stands: which plan it is on, which meter it reads, and the
|
|
3
|
+
* reads behind it — the tier for the plan's name, the limits for its windows,
|
|
4
|
+
* the free allowance, and the prepaid balance. One read for every surface that
|
|
5
|
+
* shows a plan (the account menus, Usage, Billing), so they cannot disagree.
|
|
6
|
+
*
|
|
7
|
+
* Each read stands alone: one that fails leaves its part empty and the rest
|
|
8
|
+
* drawn. Only when none answers is the whole read an error.
|
|
9
|
+
*/
|
|
10
|
+
import { phrase } from '@hanzo/i18n';
|
|
11
|
+
import { allowance, balance, tier } from './api/billing.js';
|
|
12
|
+
import { limits } from './api/limits.js';
|
|
13
|
+
import { useRead } from './data.js';
|
|
14
|
+
import { kind, label, when } from './plan.js';
|
|
15
|
+
import { english } from './say.js';
|
|
16
|
+
const got = (r) => (r.status === 'fulfilled' ? r.value : null);
|
|
17
|
+
/** Every read at once. Rejects only when all of them were refused, with the first refusal. */
|
|
18
|
+
export async function stand(t) {
|
|
19
|
+
const all = await Promise.allSettled([tier(t), limits(t), allowance(t), balance(t)]);
|
|
20
|
+
if (all.every((r) => r.status === 'rejected'))
|
|
21
|
+
throw all[0].reason;
|
|
22
|
+
const [billed, used, free, money] = [got(all[0]), got(all[1]), got(all[2]), got(all[3])];
|
|
23
|
+
// Billing names what was bought; the limits name the rung the gate counts. A
|
|
24
|
+
// plan either one names is the plan.
|
|
25
|
+
const slug = billed?.plan || (used && used.plan !== 'free' ? used.plan : '');
|
|
26
|
+
const k = kind(slug, money, billed?.tier);
|
|
27
|
+
return {
|
|
28
|
+
kind: k,
|
|
29
|
+
label: k === 'plan' ? label(slug, billed?.tier, billed?.name) : k === 'free' ? { name: phrase('Free'), tag: '' } : { name: phrase('Pay as you go'), tag: '' },
|
|
30
|
+
limits: used,
|
|
31
|
+
allowance: free,
|
|
32
|
+
balance: money,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The standing for `t`, read when `enabled` (a menu that is open) and again when the org changes. */
|
|
36
|
+
export function useStanding(t, enabled = true) {
|
|
37
|
+
return useRead(enabled && t.token() ? () => stand(t) : null, null, [t, enabled]);
|
|
38
|
+
}
|
|
39
|
+
const RANK = { ok: 0, near: 1, limited: 2 };
|
|
40
|
+
/**
|
|
41
|
+
* A plan's windows, shortest first: the session, the UTC day, and the month —
|
|
42
|
+
* the billing period of whichever class of model has used the most of it,
|
|
43
|
+
* because that is the one that stops a request first.
|
|
44
|
+
*/
|
|
45
|
+
export function rows(l, now = Date.now(), t = english) {
|
|
46
|
+
if (!l)
|
|
47
|
+
return [];
|
|
48
|
+
const month = Object.values(l.classes).reduce((a, c) => (!c ? a : !a || c.percent > a.percent || (c.percent === a.percent && RANK[c.state] > RANK[a.state]) ? c : a), null);
|
|
49
|
+
const out = [];
|
|
50
|
+
const add = (name, w) => {
|
|
51
|
+
if (!w)
|
|
52
|
+
return;
|
|
53
|
+
const at = when(w.resets, now);
|
|
54
|
+
out.push({ name, percent: w.percent, state: w.state, resets: at ? t('Resets {time}', { time: at }) : '' });
|
|
55
|
+
};
|
|
56
|
+
add('Session', l.session);
|
|
57
|
+
add('Today', l.day);
|
|
58
|
+
add('Month', month);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** The share of the free allowance left in its window, 0 to 100, or null where none bounds the account. */
|
|
62
|
+
export function left(a) {
|
|
63
|
+
if (!a || a.limit <= 0)
|
|
64
|
+
return null;
|
|
65
|
+
return Math.max(0, 100 - Math.round((Math.min(a.used, a.limit) / a.limit) * 100));
|
|
66
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { Say } from '@hanzo/i18n/react';
|
|
2
|
+
import { type Automation, type Schedule, type Source } from './api/auto.ts';
|
|
3
|
+
import type { Target } from './api/call.ts';
|
|
4
|
+
import type { Spend } from './host.tsx';
|
|
5
|
+
import type { Conversation } from './api/conversations.ts';
|
|
6
|
+
import type { Item } from './api/library.ts';
|
|
7
|
+
import type { Session } from './api/sessions.ts';
|
|
8
|
+
import type { Issue } from './merge.ts';
|
|
9
|
+
export type Icon = 'github' | 'agent' | 'chat' | 'file' | 'task';
|
|
10
|
+
export declare const ICONS: readonly Icon[];
|
|
11
|
+
/**
|
|
12
|
+
* What pressing a row does, at once:
|
|
13
|
+
*
|
|
14
|
+
* open the thing it names: `to` is an app address (`/chat/<id>`,
|
|
15
|
+
* `/studio/c/<id>`), a builder path (`sess_…`, `-/automations/<id>`,
|
|
16
|
+
* `-/artifacts` with `item`), or another site's (a new tab)
|
|
17
|
+
* send a new chat, asked `prompt`
|
|
18
|
+
* task a new Dev run on `prompt`
|
|
19
|
+
* schedule a scheduled task, made and shown
|
|
20
|
+
*/
|
|
21
|
+
export type Act = {
|
|
22
|
+
kind: 'open';
|
|
23
|
+
to: string;
|
|
24
|
+
item?: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'send';
|
|
27
|
+
prompt: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'task';
|
|
30
|
+
prompt: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'schedule';
|
|
33
|
+
name: string;
|
|
34
|
+
prompt: string;
|
|
35
|
+
schedule: Schedule;
|
|
36
|
+
};
|
|
37
|
+
/** One row: one short action in plain words, and what pressing it does. */
|
|
38
|
+
export interface Suggestion {
|
|
39
|
+
/** Stable across generations: what it opens, or its words. */
|
|
40
|
+
id: string;
|
|
41
|
+
icon: Icon;
|
|
42
|
+
/** The action, a few plain words: "Review poster.png in Studio". */
|
|
43
|
+
title: string;
|
|
44
|
+
/** What the source says, a sentence or three: the hover card. */
|
|
45
|
+
summary: string;
|
|
46
|
+
act: Act;
|
|
47
|
+
}
|
|
48
|
+
/** One piece of the person's activity, as the model is shown it. */
|
|
49
|
+
export interface Input {
|
|
50
|
+
kind: 'conversation' | 'issue' | 'pull' | 'run' | 'automation' | 'file';
|
|
51
|
+
/** Its identity: an id, or its address. */
|
|
52
|
+
key: string;
|
|
53
|
+
title: string;
|
|
54
|
+
/** open or closed, a run's status, an automation's last result. */
|
|
55
|
+
state: string;
|
|
56
|
+
/** One line of detail: an issue's opening line, a run's repository, a schedule. */
|
|
57
|
+
text: string;
|
|
58
|
+
/** Its own https address, or ''. */
|
|
59
|
+
href: string;
|
|
60
|
+
/** Where opening it goes (`Act` open's `to`), or '' when nothing opens it. */
|
|
61
|
+
to: string;
|
|
62
|
+
/** A Library item's id, for an item the Library opens at. */
|
|
63
|
+
item?: string;
|
|
64
|
+
/** RFC 3339, or ''. */
|
|
65
|
+
updated: string;
|
|
66
|
+
}
|
|
67
|
+
/** What signup and Settings learned about the person: the seed when there is no activity. */
|
|
68
|
+
export interface Seed {
|
|
69
|
+
/** What Hanzo calls them. */
|
|
70
|
+
name?: string;
|
|
71
|
+
/** What best describes their work (Settings). */
|
|
72
|
+
work?: string;
|
|
73
|
+
/** The role chosen at signup (IAM `onboarding.role`). */
|
|
74
|
+
role?: string;
|
|
75
|
+
/** personal, team or enterprise (IAM `onboarding.use`). */
|
|
76
|
+
use?: string;
|
|
77
|
+
/** What every run is told about how they like to work. */
|
|
78
|
+
instructions?: string;
|
|
79
|
+
}
|
|
80
|
+
/** What the account keeps under `suggest`. */
|
|
81
|
+
export interface Kept {
|
|
82
|
+
/** RFC 3339: when the rows were made. */
|
|
83
|
+
at: string;
|
|
84
|
+
/** The fingerprint of the inputs they were made from. */
|
|
85
|
+
sig: string;
|
|
86
|
+
rows: Suggestion[];
|
|
87
|
+
/** Ids of the rows the person dismissed, newest first. */
|
|
88
|
+
dismissed: string[];
|
|
89
|
+
}
|
|
90
|
+
/** Hanzo's model the rows are asked of: it decodes under a strict JSON schema at api.hanzo.ai. */
|
|
91
|
+
export declare const MODEL = "zen5-flash";
|
|
92
|
+
/** At most this many rows. */
|
|
93
|
+
export declare const MOST = 3;
|
|
94
|
+
/** Rows this old are made again whatever happened. */
|
|
95
|
+
export declare const DAY: number;
|
|
96
|
+
/** Rows younger than this are kept even when the activity has moved. */
|
|
97
|
+
export declare const QUIET = 3600000;
|
|
98
|
+
/** How many dismissals are remembered. */
|
|
99
|
+
export declare const REMEMBER = 100;
|
|
100
|
+
/** How many of each source the model reads. */
|
|
101
|
+
export declare const TAKE: Record<Input['kind'], number>;
|
|
102
|
+
/** One line, at most `n` characters. */
|
|
103
|
+
export declare function line(v: unknown, n: number): string;
|
|
104
|
+
/** An https address, or ''. A row links to nothing else. */
|
|
105
|
+
export declare function https(v: unknown): string;
|
|
106
|
+
/** cyrb53: a 53-bit string hash, as 14 hex digits. A fingerprint, never a secret. */
|
|
107
|
+
export declare function hash(s: string): string;
|
|
108
|
+
/** What the sources answered, read by suggestions.tsx. */
|
|
109
|
+
export interface Activity {
|
|
110
|
+
conversations: Conversation[];
|
|
111
|
+
/** The org's issues and pull requests (GET /v1/task/board). */
|
|
112
|
+
issues: Issue[];
|
|
113
|
+
/** The org's Dev runs; only the person's own are read. */
|
|
114
|
+
runs: Session[];
|
|
115
|
+
automations: Automation[];
|
|
116
|
+
/** The person's own Library items. */
|
|
117
|
+
files: Item[];
|
|
118
|
+
/** The person as a run's `actor` names them: `<owner>/<sub>`. */
|
|
119
|
+
me: string;
|
|
120
|
+
}
|
|
121
|
+
/** The person's activity as inputs: their own runs only, each kind's newest `TAKE`. */
|
|
122
|
+
export declare function inputs(a: Activity): Input[];
|
|
123
|
+
/**
|
|
124
|
+
* The seed: what the account's preferences say (`callName`, `work`,
|
|
125
|
+
* `instructions` in /v1/pref) and what signup kept on the IAM user (`onboarding`
|
|
126
|
+
* in /v1/iam/preferences: the role picked, and personal, team or enterprise).
|
|
127
|
+
*/
|
|
128
|
+
export declare function seed(p: {
|
|
129
|
+
callName?: string;
|
|
130
|
+
work?: string;
|
|
131
|
+
instructions?: string;
|
|
132
|
+
}, iam: unknown): Seed;
|
|
133
|
+
/** Each kind's newest `TAKE`, newest first overall. */
|
|
134
|
+
export declare function pick(all: Input[]): Input[];
|
|
135
|
+
/**
|
|
136
|
+
* The fingerprint of what the rows are made from: each input's identity and
|
|
137
|
+
* state, and the seed. A new conversation, a closed issue or a finished run
|
|
138
|
+
* moves it; another turn in a conversation already read does not.
|
|
139
|
+
*/
|
|
140
|
+
export declare function sig(inputs: Input[], seed: Seed): string;
|
|
141
|
+
/** Whether rows kept at `kept` are to be made again, now that the inputs read as `now`. */
|
|
142
|
+
export declare function due(kept: Kept | null, fingerprint: string, now: number): boolean;
|
|
143
|
+
/** Whether anything newer could change kept rows yet: false while they are younger than `QUIET`. */
|
|
144
|
+
export declare function stale(kept: Kept | null, now: number): boolean;
|
|
145
|
+
/** The icon a row about `i` carries: GitHub's mark only for GitHub's own address. */
|
|
146
|
+
export declare function iconOf(i: Input): Icon;
|
|
147
|
+
/** What a row does, as the model names it. */
|
|
148
|
+
export declare const ACTIONS: readonly ['open', 'send', 'task', 'schedule'];
|
|
149
|
+
/** The answer's shape, decoded strictly by the model. */
|
|
150
|
+
export declare const SCHEMA: {
|
|
151
|
+
readonly type: 'object';
|
|
152
|
+
readonly additionalProperties: false;
|
|
153
|
+
readonly required: readonly ['rows'];
|
|
154
|
+
readonly properties: {
|
|
155
|
+
readonly rows: {
|
|
156
|
+
readonly type: 'array';
|
|
157
|
+
readonly maxItems: 3;
|
|
158
|
+
readonly items: {
|
|
159
|
+
readonly type: 'object';
|
|
160
|
+
readonly additionalProperties: false;
|
|
161
|
+
readonly required: readonly ['icon', 'title', 'summary', 'action', 'source', 'prompt', 'every'];
|
|
162
|
+
readonly properties: {
|
|
163
|
+
readonly icon: {
|
|
164
|
+
readonly type: 'string';
|
|
165
|
+
readonly enum: readonly Icon[];
|
|
166
|
+
};
|
|
167
|
+
readonly title: {
|
|
168
|
+
readonly type: 'string';
|
|
169
|
+
};
|
|
170
|
+
readonly summary: {
|
|
171
|
+
readonly type: 'string';
|
|
172
|
+
};
|
|
173
|
+
readonly action: {
|
|
174
|
+
readonly type: 'string';
|
|
175
|
+
readonly enum: readonly ["open", "send", "task", "schedule"];
|
|
176
|
+
};
|
|
177
|
+
readonly source: {
|
|
178
|
+
readonly type: 'string';
|
|
179
|
+
};
|
|
180
|
+
readonly prompt: {
|
|
181
|
+
readonly type: 'string';
|
|
182
|
+
};
|
|
183
|
+
readonly every: {
|
|
184
|
+
readonly type: 'string';
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/** The chat completion that asks for rows, or null when there is nothing to make them from. */
|
|
192
|
+
export declare function request(inputs: Input[], seed: Seed, skip: string[], now: Date): Record<string, unknown> | null;
|
|
193
|
+
/** `every` as a schedule, or null for words that are not one. */
|
|
194
|
+
export declare function every(v: string): Schedule | null;
|
|
195
|
+
/** The text of a chat completion's first choice, or ''. */
|
|
196
|
+
export declare function content(raw: unknown): string;
|
|
197
|
+
/** A row's id: what it opens, or its words. */
|
|
198
|
+
export declare const idOf: (to: string, title: string) => string;
|
|
199
|
+
/**
|
|
200
|
+
* The rows of a chat completion, validated: each with words and an action that
|
|
201
|
+
* binds (an open names an input's key; a send, a task or a schedule carries its
|
|
202
|
+
* prompt, and a schedule a time it reads), one row per thing, at most `MOST`.
|
|
203
|
+
* Anything else is dropped, never repaired.
|
|
204
|
+
*/
|
|
205
|
+
export declare function answer(raw: unknown, inputs: Input[]): Suggestion[];
|
|
206
|
+
/** The `suggest` key of the preference document, or undefined when it holds none. */
|
|
207
|
+
export declare function kept(raw: unknown): Kept | undefined;
|
|
208
|
+
/** The rows to draw: those not dismissed. */
|
|
209
|
+
export declare const shown: (k: Kept | null | undefined) => Suggestion[];
|
|
210
|
+
/**
|
|
211
|
+
* What Hanzo does, three ways in, each done at once: what fills the rows a
|
|
212
|
+
* person's activity and signup do not. The one copy here that is authored, so
|
|
213
|
+
* its words are marked (`phrase`) and drawn in the reader's language, the
|
|
214
|
+
* prompt too: it is sent as their message and shown as theirs.
|
|
215
|
+
*
|
|
216
|
+
* Dev's starter asks before it builds. A press names no project, no audience
|
|
217
|
+
* and no content, and a model handed "build a landing site for my project"
|
|
218
|
+
* with none of that invents all three: it built a Hanzo AI showcase nobody
|
|
219
|
+
* asked for (hanzo-inc/app#442). So the press starts the conversation about
|
|
220
|
+
* the page, and the build follows the answers.
|
|
221
|
+
*/
|
|
222
|
+
export declare const STARTERS: readonly Suggestion[];
|
|
223
|
+
/** Whether a row is a starter: authored, so drawn through `t`; every other row is the person's own words. */
|
|
224
|
+
export declare const starter: (r: Suggestion) => boolean;
|
|
225
|
+
/** The kept rows, filled to `MOST` with the starters not dismissed: never one lonely row. */
|
|
226
|
+
export declare const fill: (k: Kept | null | undefined) => Suggestion[];
|
|
227
|
+
/** `k` with `id` dismissed: remembered first, the oldest forgotten past `REMEMBER`. */
|
|
228
|
+
export declare function dismissed(k: Kept, id: string): Kept;
|
|
229
|
+
/** The addresses and titles of dismissed rows the model is told to skip. */
|
|
230
|
+
export declare function skip(k: Kept | null | undefined, inputs: Input[]): string[];
|
|
231
|
+
/**
|
|
232
|
+
* Make a `schedule` row's task: on, asking before it acts, and notifying its person. It runs, and spends, by itself
|
|
233
|
+
* from then, so the person is asked first through the host's confirm (host.tsx `Host.confirm`, the same function);
|
|
234
|
+
* on anything but a yes nothing is made and the answer is null.
|
|
235
|
+
*/
|
|
236
|
+
export declare function book(t: Target, act: Extract<Act, {
|
|
237
|
+
kind: 'schedule';
|
|
238
|
+
}>, source: Source, confirm: (spend: Spend) => Promise<boolean>, say?: Say): Promise<Automation | null>;
|