@hanzo/dev 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +59 -0
- package/dist/builder/api/git.js +117 -0
- package/dist/builder/api/github.d.ts +230 -0
- package/dist/builder/api/github.js +373 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +639 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/github-sync.d.ts +70 -0
- package/dist/builder/github-sync.js +435 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +604 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +187 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Say } from '@hanzo/i18n/react';
|
|
2
|
+
import { type Target } from './call.ts';
|
|
3
|
+
export type State = 'none' | 'proposed' | 'ready';
|
|
4
|
+
export interface Proposal {
|
|
5
|
+
install: string;
|
|
6
|
+
start: string;
|
|
7
|
+
/** Variables the agent found the codebase reads. Some may not be set yet. */
|
|
8
|
+
secrets: string[];
|
|
9
|
+
/** What the setup agent found and checked, in its own words. */
|
|
10
|
+
note: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Environment {
|
|
13
|
+
repo: string;
|
|
14
|
+
install: string;
|
|
15
|
+
start: string;
|
|
16
|
+
/** The names set on this codebase. Values are never answered. */
|
|
17
|
+
secrets: string[];
|
|
18
|
+
state: State;
|
|
19
|
+
/** The setup run that produced the proposal, or ''. */
|
|
20
|
+
session: string;
|
|
21
|
+
proposal: Proposal | null;
|
|
22
|
+
updated: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function environment(raw: unknown, repo?: string): Environment;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a codebase still waits to be set up: nothing proposed and nothing ever
|
|
27
|
+
* saved. Skip & save keeps an empty environment, which the platform answers as
|
|
28
|
+
* state `none` with the time it was saved (apps/environment `view`), so the
|
|
29
|
+
* time is what tells a choice made from one never made.
|
|
30
|
+
*/
|
|
31
|
+
export declare const unset: (e: Environment) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* What a refused save or setup run says to the person who pressed it: what is
|
|
34
|
+
* wrong and what to do, in the reader's words rather than the platform's, and
|
|
35
|
+
* in the language of the `t` handed (English without one).
|
|
36
|
+
*/
|
|
37
|
+
export declare function plain(e: unknown, repo: string, act: 'save' | 'start' | 'run', t?: Say): string;
|
|
38
|
+
export declare function environments(t: Target): Promise<Environment[]>;
|
|
39
|
+
export declare function read(t: Target, repo: string): Promise<Environment>;
|
|
40
|
+
export declare function save(t: Target, repo: string, scripts: {
|
|
41
|
+
install: string;
|
|
42
|
+
start: string;
|
|
43
|
+
}): Promise<Environment>;
|
|
44
|
+
export declare function forget(t: Target, repo: string): Promise<void>;
|
|
45
|
+
/** An environment variable name the run can export, and not one of its own. */
|
|
46
|
+
export declare const NAME: RegExp;
|
|
47
|
+
/** Why a secret name cannot be set, in the words of the `t` handed, or '' when it can. */
|
|
48
|
+
export declare function refuse(name: string, t?: Say): string;
|
|
49
|
+
export declare function setSecret(t: Target, repo: string, name: string, value: string): Promise<Environment>;
|
|
50
|
+
export declare function removeSecret(t: Target, repo: string, name: string): Promise<Environment>;
|
|
51
|
+
/**
|
|
52
|
+
* What a setup run is asked. The first line is the run's title, the steps are
|
|
53
|
+
* its checklist, and the platform puts its own instructions ahead of both.
|
|
54
|
+
*/
|
|
55
|
+
export declare const SETUP: string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A codebase's environment: what a run does to its checkout before the agent
|
|
3
|
+
* starts, and which secrets it exports.
|
|
4
|
+
*
|
|
5
|
+
* GET /v1/environment {data: [environment]}
|
|
6
|
+
* GET /v1/environment/{repo} one; a codebase with none answers state "none"
|
|
7
|
+
* PUT /v1/environment/{repo} save {install, start} (org admin)
|
|
8
|
+
* DELETE /v1/environment/{repo} forget it and its secrets (org admin)
|
|
9
|
+
* PUT /v1/environment/{repo}/secrets/{name} set one value (org admin)
|
|
10
|
+
* DELETE /v1/environment/{repo}/secrets/{name} remove one (org admin)
|
|
11
|
+
*
|
|
12
|
+
* A setup run is a coding run in mode `setup` (coding.ts): its agent explores the
|
|
13
|
+
* checkout, installs and checks what it finds, and the platform keeps its answer
|
|
14
|
+
* here as `proposal` until someone saves it. Secrets are names only; their values
|
|
15
|
+
* are sealed in KMS and reach the run's environment, never this record.
|
|
16
|
+
*/
|
|
17
|
+
import { phrase } from '@hanzo/i18n';
|
|
18
|
+
import { english } from '../say.js';
|
|
19
|
+
import { call, Refusal, seg, told } from './call.js';
|
|
20
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
21
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
22
|
+
const names = (v) => (Array.isArray(v) ? v.filter((n) => typeof n === 'string' && n !== '') : []);
|
|
23
|
+
const STATES = ['none', 'proposed', 'ready'];
|
|
24
|
+
export function environment(raw, repo = '') {
|
|
25
|
+
const o = obj(raw);
|
|
26
|
+
const p = o.proposal ? obj(o.proposal) : null;
|
|
27
|
+
const state = str(o.state);
|
|
28
|
+
return {
|
|
29
|
+
repo: str(o.repo) || repo,
|
|
30
|
+
install: str(o.install),
|
|
31
|
+
start: str(o.start),
|
|
32
|
+
secrets: names(o.secrets),
|
|
33
|
+
state: STATES.includes(state) ? state : 'none',
|
|
34
|
+
session: str(o.session),
|
|
35
|
+
proposal: p ? { install: str(p.install), start: str(p.start), secrets: names(p.secrets), note: str(p.note) } : null,
|
|
36
|
+
updated: str(o.updatedAt),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether a codebase still waits to be set up: nothing proposed and nothing ever
|
|
41
|
+
* saved. Skip & save keeps an empty environment, which the platform answers as
|
|
42
|
+
* state `none` with the time it was saved (apps/environment `view`), so the
|
|
43
|
+
* time is what tells a choice made from one never made.
|
|
44
|
+
*/
|
|
45
|
+
export const unset = (e) => e.state === 'none' && !e.updated;
|
|
46
|
+
/**
|
|
47
|
+
* What a refused save or setup run says to the person who pressed it: what is
|
|
48
|
+
* wrong and what to do, in the reader's words rather than the platform's, and
|
|
49
|
+
* in the language of the `t` handed (English without one).
|
|
50
|
+
*/
|
|
51
|
+
export function plain(e, repo, act, t = english) {
|
|
52
|
+
// This page's own refusals (a secret's name, an empty value) are already a reader's words.
|
|
53
|
+
if (e instanceof Error && !(e instanceof Refusal) && e.name === 'Error' && e.message)
|
|
54
|
+
return told(e, t);
|
|
55
|
+
if (e instanceof Refusal) {
|
|
56
|
+
const why = e.message;
|
|
57
|
+
if (e.status === 401)
|
|
58
|
+
return t('Your session ended. Sign in again, then try again.');
|
|
59
|
+
if (e.status === 403 && act === 'save')
|
|
60
|
+
return t('Only an organization admin saves an environment. Start the agent instead; an admin reviews what it proposes.');
|
|
61
|
+
if (e.status === 402)
|
|
62
|
+
return t('This run needs a plan with runs left. See Plans to change it.');
|
|
63
|
+
if (e.status === 403)
|
|
64
|
+
return t('This account cannot start a run on {repo}. Ask an organization admin for access.', { repo });
|
|
65
|
+
if (e.status === 429)
|
|
66
|
+
return t('Too many runs are going right now. Try again in a minute.');
|
|
67
|
+
if (e.status >= 500)
|
|
68
|
+
return act === 'save' ? t('The environment store is not answering right now. Try again shortly.') : t('The code workspace is not answering right now. Try again shortly.');
|
|
69
|
+
if (/no repository named|not one of this organization|is not a repository/.test(why))
|
|
70
|
+
return t('{repo} is not a repository this organization has on the forge. Choose one of its repositories.', { repo });
|
|
71
|
+
if (/no account on the forge|verify .* first|no forge identity/.test(why))
|
|
72
|
+
return t('Your forge account is not ready yet: sign in to the forge once, then try again.');
|
|
73
|
+
}
|
|
74
|
+
if (act === 'save')
|
|
75
|
+
return t('The environment for {repo} could not be saved. Try again.', { repo });
|
|
76
|
+
return act === 'start' ? t('The setup run on {repo} could not start. Try again.', { repo }) : t('The run on {repo} could not start. Try again.', { repo });
|
|
77
|
+
}
|
|
78
|
+
export async function environments(t) {
|
|
79
|
+
const r = await call(t, 'GET', '/v1/environment');
|
|
80
|
+
return (Array.isArray(r?.data) ? r.data : []).map((e) => environment(e)).filter((e) => e.repo);
|
|
81
|
+
}
|
|
82
|
+
export async function read(t, repo) {
|
|
83
|
+
return environment(await call(t, 'GET', `/v1/environment/${seg(repo)}`), repo);
|
|
84
|
+
}
|
|
85
|
+
export async function save(t, repo, scripts) {
|
|
86
|
+
return environment(await call(t, 'PUT', `/v1/environment/${seg(repo)}`, scripts), repo);
|
|
87
|
+
}
|
|
88
|
+
export async function forget(t, repo) {
|
|
89
|
+
await call(t, 'DELETE', `/v1/environment/${seg(repo)}`);
|
|
90
|
+
}
|
|
91
|
+
/** An environment variable name the run can export, and not one of its own. */
|
|
92
|
+
export const NAME = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
93
|
+
const RESERVED = ['PATH', 'HOME', 'USER', 'SHELL', 'PWD', 'HOSTNAME', 'IFS', 'ENV', 'BASH_ENV'];
|
|
94
|
+
/** Why a secret name cannot be set, in the words of the `t` handed, or '' when it can. */
|
|
95
|
+
export function refuse(name, t = english) {
|
|
96
|
+
if (!NAME.test(name))
|
|
97
|
+
return name ? t('{name} is not an environment variable name', { name }) : t('That is not an environment variable name');
|
|
98
|
+
const up = name.toUpperCase();
|
|
99
|
+
if (up.startsWith('HANZO_') || RESERVED.includes(up))
|
|
100
|
+
return t('{name} is reserved for the run itself', { name });
|
|
101
|
+
return '';
|
|
102
|
+
}
|
|
103
|
+
export async function setSecret(t, repo, name, value) {
|
|
104
|
+
const why = refuse(name);
|
|
105
|
+
if (why)
|
|
106
|
+
throw new Error(why);
|
|
107
|
+
if (!value)
|
|
108
|
+
throw new Error(phrase('A secret needs a value'));
|
|
109
|
+
return environment(await call(t, 'PUT', `/v1/environment/${seg(repo)}/secrets/${seg(name)}`, { value }), repo);
|
|
110
|
+
}
|
|
111
|
+
export async function removeSecret(t, repo, name) {
|
|
112
|
+
return environment(await call(t, 'DELETE', `/v1/environment/${seg(repo)}/secrets/${seg(name)}`), repo);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What a setup run is asked. The first line is the run's title, the steps are
|
|
116
|
+
* its checklist, and the platform puts its own instructions ahead of both.
|
|
117
|
+
*/
|
|
118
|
+
export const SETUP = [
|
|
119
|
+
'Set up the environment',
|
|
120
|
+
'',
|
|
121
|
+
'1. Understand the codebase: how it installs, builds, starts and tests.',
|
|
122
|
+
'2. Write the install script and the start command.',
|
|
123
|
+
'3. Run both in this fresh checkout.',
|
|
124
|
+
'4. Check that the build and the tests pass, and that the app answers if it is one.',
|
|
125
|
+
'5. Answer with what you checked and the environment.',
|
|
126
|
+
].join('\n');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const GALLERY = "https://gallery.hanzo.ai/templates.json";
|
|
2
|
+
export declare const KINDS: readonly ['site', 'agent'];
|
|
3
|
+
export type Kind = (typeof KINDS)[number];
|
|
4
|
+
/** Each kind's name, English and marked (`phrase`), drawn through `t`. */
|
|
5
|
+
export declare const KIND: Record<Kind, string>;
|
|
6
|
+
/** Where each kind is made. */
|
|
7
|
+
export type App = 'dev' | 'agents';
|
|
8
|
+
export declare const APP: Record<Kind, App>;
|
|
9
|
+
export interface Template {
|
|
10
|
+
slug: string;
|
|
11
|
+
name: string;
|
|
12
|
+
kind: Kind;
|
|
13
|
+
category: string;
|
|
14
|
+
description: string;
|
|
15
|
+
/** Its capture, an https address, or ''. */
|
|
16
|
+
preview: string;
|
|
17
|
+
/** An agent's instructions and model ('' the deployment's default); '' for a site. */
|
|
18
|
+
instructions: string;
|
|
19
|
+
model: string;
|
|
20
|
+
/** What a search reads, lower case. */
|
|
21
|
+
words: string;
|
|
22
|
+
}
|
|
23
|
+
/** What the screen says when the catalogue cannot be read, whatever the reason. */
|
|
24
|
+
export declare const UNREAD: string;
|
|
25
|
+
/** One row as the gallery serves it, or null for one this Library cannot offer. */
|
|
26
|
+
export declare function template(raw: unknown): Template | null;
|
|
27
|
+
/** The gallery's templates, in its order, each slug once. Any failure is `UNREAD`; an abort stays an abort. */
|
|
28
|
+
export declare function catalogue(init?: {
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}): Promise<Template[]>;
|
|
31
|
+
/** The templates of `kind` ('' every kind) holding every word of `q`. */
|
|
32
|
+
export declare function narrow(list: readonly Template[], kind: Kind | '', q: string): Template[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gallery: gallery.hanzo.ai's templates, read live from the one catalogue it
|
|
3
|
+
* publishes (hanzoai/gallery `scripts/gen-templates-json.mjs`).
|
|
4
|
+
*
|
|
5
|
+
* GET https://gallery.hanzo.ai/templates.json {version, templates: [row]}
|
|
6
|
+
*
|
|
7
|
+
* Reference content: no bearer, no org. A row is a starter kit — a repository
|
|
8
|
+
* with a capture of its page — and names no kind, so a row with a repository is
|
|
9
|
+
* a site. A row that names a kind is that kind; one this reader does not know,
|
|
10
|
+
* or one missing what its kind is made from, is left out.
|
|
11
|
+
*
|
|
12
|
+
* A site is made in Dev, as a copy of its repository (projects.ts `fork`); an
|
|
13
|
+
* agent in Customize › Agents, as the org's own (agents.ts `use`).
|
|
14
|
+
*/
|
|
15
|
+
import { phrase } from '@hanzo/i18n';
|
|
16
|
+
import { SLUG } from '../route.js';
|
|
17
|
+
export const GALLERY = 'https://gallery.hanzo.ai/templates.json';
|
|
18
|
+
export const KINDS = ['site', 'agent'];
|
|
19
|
+
/** Each kind's name, English and marked (`phrase`), drawn through `t`. */
|
|
20
|
+
export const KIND = { site: phrase('Site'), agent: phrase('Agent') };
|
|
21
|
+
export const APP = { site: 'dev', agent: 'agents' };
|
|
22
|
+
/** What the screen says when the catalogue cannot be read, whatever the reason. */
|
|
23
|
+
export const UNREAD = phrase('The gallery is not answering right now.');
|
|
24
|
+
const str = (v) => (typeof v === 'string' ? v.trim() : '');
|
|
25
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
26
|
+
const https = (v) => (/^https:\/\/\S+$/.test(str(v)) ? str(v) : '');
|
|
27
|
+
const strs = (v) => (Array.isArray(v) ? v.map(str).filter(Boolean) : []);
|
|
28
|
+
/** One row as the gallery serves it, or null for one this Library cannot offer. */
|
|
29
|
+
export function template(raw) {
|
|
30
|
+
const o = obj(raw);
|
|
31
|
+
const slug = str(o.slug);
|
|
32
|
+
if (!SLUG.test(slug))
|
|
33
|
+
return null;
|
|
34
|
+
// A row names its kind, or is a site by its repository.
|
|
35
|
+
const kind = (str(o.kind) || (https(o.repo) ? 'site' : ''));
|
|
36
|
+
if (!KINDS.includes(kind))
|
|
37
|
+
return null;
|
|
38
|
+
const instructions = kind === 'agent' ? str(o.instructions) : '';
|
|
39
|
+
if (kind === 'agent' && !instructions)
|
|
40
|
+
return null;
|
|
41
|
+
const name = str(o.displayName) || str(o.name) || slug;
|
|
42
|
+
const category = str(o.category);
|
|
43
|
+
const description = str(o.description);
|
|
44
|
+
return {
|
|
45
|
+
slug,
|
|
46
|
+
name,
|
|
47
|
+
kind,
|
|
48
|
+
category,
|
|
49
|
+
description,
|
|
50
|
+
preview: o.hasScreenshot === false ? '' : https(o.screenshotUrl),
|
|
51
|
+
instructions,
|
|
52
|
+
model: kind === 'agent' ? str(o.model) : '',
|
|
53
|
+
words: [name, slug, category, description, str(o.useCase), str(o.framework), ...strs(o.features), ...strs(o.intents)].join(' ').toLowerCase(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The gallery's templates, in its order, each slug once. Any failure is `UNREAD`; an abort stays an abort. */
|
|
57
|
+
export async function catalogue(init) {
|
|
58
|
+
let raw;
|
|
59
|
+
try {
|
|
60
|
+
const res = await fetch(GALLERY, { signal: init?.signal, cache: 'no-cache' });
|
|
61
|
+
if (!res.ok)
|
|
62
|
+
throw new Error(String(res.status));
|
|
63
|
+
raw = await res.json();
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if (init?.signal?.aborted)
|
|
67
|
+
throw e;
|
|
68
|
+
throw new Error(UNREAD);
|
|
69
|
+
}
|
|
70
|
+
const rows = obj(raw).templates;
|
|
71
|
+
if (!Array.isArray(rows))
|
|
72
|
+
throw new Error(UNREAD);
|
|
73
|
+
const out = new Map();
|
|
74
|
+
for (const r of rows) {
|
|
75
|
+
const x = template(r);
|
|
76
|
+
if (x && !out.has(x.slug))
|
|
77
|
+
out.set(x.slug, x);
|
|
78
|
+
}
|
|
79
|
+
return [...out.values()];
|
|
80
|
+
}
|
|
81
|
+
/** The templates of `kind` ('' every kind) holding every word of `q`. */
|
|
82
|
+
export function narrow(list, kind, q) {
|
|
83
|
+
const words = q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
84
|
+
return list.filter((x) => (!kind || x.kind === kind) && words.every((w) => x.words.includes(w)));
|
|
85
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A repository's files at one revision, and its outbound mirror targets,
|
|
3
|
+
* from the platform's native git.
|
|
4
|
+
*
|
|
5
|
+
* GET /v1/git/repos/{name}/tree?ref=&path= one directory, dirs first
|
|
6
|
+
* GET /v1/git/repos/{name}/blob?ref=&path= one file; binary is base64,
|
|
7
|
+
* past 1 MiB it is truncated with no content
|
|
8
|
+
* GET /v1/git/repos/{name}/targets outbound mirror targets
|
|
9
|
+
* POST /v1/git/repos/{name}/targets attach outbound GitHub mirror + initial sync push
|
|
10
|
+
* POST /v1/git/repos/{name}/link link an existing GitHub repo
|
|
11
|
+
*
|
|
12
|
+
* A run pushes its branch to the forge, not here, so a run's files are read
|
|
13
|
+
* through the run (changes.ts); these read a codebase as the platform holds it.
|
|
14
|
+
*/
|
|
15
|
+
import { type At } from '../address.ts';
|
|
16
|
+
import { type Target } from './call.ts';
|
|
17
|
+
export interface Entry {
|
|
18
|
+
name: string;
|
|
19
|
+
path: string;
|
|
20
|
+
dir: boolean;
|
|
21
|
+
size: number;
|
|
22
|
+
}
|
|
23
|
+
export interface Blob {
|
|
24
|
+
path: string;
|
|
25
|
+
/** Text, or '' when the file is binary or past the view cap. */
|
|
26
|
+
text: string;
|
|
27
|
+
binary: boolean;
|
|
28
|
+
truncated: boolean;
|
|
29
|
+
size: number;
|
|
30
|
+
}
|
|
31
|
+
/** An outbound mirror target attached to a Hanzo Git repository. */
|
|
32
|
+
export interface GitTarget {
|
|
33
|
+
id: string;
|
|
34
|
+
repo: string;
|
|
35
|
+
host: string;
|
|
36
|
+
url: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse a GitHub repository reference in any form GitHub hands out (`onGitHub`),
|
|
41
|
+
* or in `owner/repo` shorthand (e.g. `hanzoai/dev`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseGitHubRepo(input: string): At | null;
|
|
44
|
+
export declare function gitTarget(raw: unknown): GitTarget | null;
|
|
45
|
+
/** List outbound mirror targets for a Hanzo Git repository. */
|
|
46
|
+
export declare function listGitTargets(t: Target, name: string, signal?: AbortSignal): Promise<GitTarget[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Attach an outbound GitHub mirror target to a Hanzo Git repository,
|
|
49
|
+
* which also triggers an initial sync push.
|
|
50
|
+
*/
|
|
51
|
+
export declare function attachGitHubMirror(t: Target, name: string, url: string): Promise<GitTarget>;
|
|
52
|
+
/** Link an existing GitHub repository to a Hanzo Git repository. */
|
|
53
|
+
export declare function linkGitHubRepo(t: Target, name: string, source: string): Promise<void>;
|
|
54
|
+
export declare function tree(t: Target, repo: string, ref: string, path?: string): Promise<Entry[]>;
|
|
55
|
+
/** A tree answer's entries. A run's branch on the forge answers in the same shape. */
|
|
56
|
+
export declare function entries(raw: unknown): Entry[];
|
|
57
|
+
export declare function blob(t: Target, repo: string, ref: string, path: string): Promise<Blob>;
|
|
58
|
+
/** A blob answer. A run's branch on the forge answers in the same shape. */
|
|
59
|
+
export declare function file(raw: unknown, path: string): Blob;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A repository's files at one revision, and its outbound mirror targets,
|
|
3
|
+
* from the platform's native git.
|
|
4
|
+
*
|
|
5
|
+
* GET /v1/git/repos/{name}/tree?ref=&path= one directory, dirs first
|
|
6
|
+
* GET /v1/git/repos/{name}/blob?ref=&path= one file; binary is base64,
|
|
7
|
+
* past 1 MiB it is truncated with no content
|
|
8
|
+
* GET /v1/git/repos/{name}/targets outbound mirror targets
|
|
9
|
+
* POST /v1/git/repos/{name}/targets attach outbound GitHub mirror + initial sync push
|
|
10
|
+
* POST /v1/git/repos/{name}/link link an existing GitHub repo
|
|
11
|
+
*
|
|
12
|
+
* A run pushes its branch to the forge, not here, so a run's files are read
|
|
13
|
+
* through the run (changes.ts); these read a codebase as the platform holds it.
|
|
14
|
+
*/
|
|
15
|
+
import { ADDRESS, clone, onGitHub } from '../address.js';
|
|
16
|
+
import { call, query, seg } from './call.js';
|
|
17
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
18
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
19
|
+
/** GitHub owner/name shorthand segment. */
|
|
20
|
+
const GH_SEG = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
21
|
+
/**
|
|
22
|
+
* Parse a GitHub repository reference in any form GitHub hands out (`onGitHub`),
|
|
23
|
+
* or in `owner/repo` shorthand (e.g. `hanzoai/dev`).
|
|
24
|
+
*/
|
|
25
|
+
export function parseGitHubRepo(input) {
|
|
26
|
+
const s = input.trim();
|
|
27
|
+
if (!s)
|
|
28
|
+
return null;
|
|
29
|
+
const full = onGitHub(s);
|
|
30
|
+
if (full)
|
|
31
|
+
return full;
|
|
32
|
+
const cleaned = s.replace(/\/+$/, '').replace(/\.git$/i, '');
|
|
33
|
+
const parts = cleaned.split('/');
|
|
34
|
+
if (parts.length !== 2)
|
|
35
|
+
return null;
|
|
36
|
+
const [owner, name] = parts;
|
|
37
|
+
return owner && name && GH_SEG.test(owner) && GH_SEG.test(name) ? { owner, name } : null;
|
|
38
|
+
}
|
|
39
|
+
export function gitTarget(raw) {
|
|
40
|
+
const o = obj(raw);
|
|
41
|
+
const url = str(o.url);
|
|
42
|
+
if (!url)
|
|
43
|
+
return null;
|
|
44
|
+
return {
|
|
45
|
+
id: str(o.id),
|
|
46
|
+
repo: str(o.repo),
|
|
47
|
+
host: str(o.host),
|
|
48
|
+
url,
|
|
49
|
+
createdAt: str(o.createdAt),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** List outbound mirror targets for a Hanzo Git repository. */
|
|
53
|
+
export async function listGitTargets(t, name, signal) {
|
|
54
|
+
const raw = await call(t, 'GET', `/v1/git/repos/${seg(name)}/targets`, undefined, { signal });
|
|
55
|
+
const rows = Array.isArray(raw) ? raw : Array.isArray(obj(raw).data) ? obj(raw).data : [];
|
|
56
|
+
return rows.map(gitTarget).filter((x) => x !== null);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Attach an outbound GitHub mirror target to a Hanzo Git repository,
|
|
60
|
+
* which also triggers an initial sync push.
|
|
61
|
+
*/
|
|
62
|
+
export async function attachGitHubMirror(t, name, url) {
|
|
63
|
+
const at = parseGitHubRepo(url);
|
|
64
|
+
if (!at)
|
|
65
|
+
throw new Error(ADDRESS);
|
|
66
|
+
const cloneUrl = clone(at);
|
|
67
|
+
const raw = await call(t, 'POST', `/v1/git/repos/${seg(name)}/targets`, { url: cloneUrl });
|
|
68
|
+
return (gitTarget(raw) ?? {
|
|
69
|
+
id: '',
|
|
70
|
+
repo: name,
|
|
71
|
+
host: 'github.com',
|
|
72
|
+
url: cloneUrl,
|
|
73
|
+
createdAt: '',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Link an existing GitHub repository to a Hanzo Git repository. */
|
|
77
|
+
export async function linkGitHubRepo(t, name, source) {
|
|
78
|
+
const at = parseGitHubRepo(source);
|
|
79
|
+
if (!at)
|
|
80
|
+
throw new Error(ADDRESS);
|
|
81
|
+
await call(t, 'POST', `/v1/git/repos/${seg(name)}/link`, { source: clone(at) });
|
|
82
|
+
}
|
|
83
|
+
export async function tree(t, repo, ref, path = '') {
|
|
84
|
+
return entries(await call(t, 'GET', `/v1/git/repos/${seg(repo)}/tree${query({ ref, path })}`));
|
|
85
|
+
}
|
|
86
|
+
/** A tree answer's entries. A run's branch on the forge answers in the same shape. */
|
|
87
|
+
export function entries(raw) {
|
|
88
|
+
const o = (raw && typeof raw === 'object' ? raw : {});
|
|
89
|
+
const rows = Array.isArray(o.entries) ? o.entries : [];
|
|
90
|
+
return rows
|
|
91
|
+
.map((r) => {
|
|
92
|
+
const o = (r && typeof r === 'object' ? r : {});
|
|
93
|
+
return {
|
|
94
|
+
name: str(o.name),
|
|
95
|
+
path: str(o.path),
|
|
96
|
+
dir: o.type === 'tree',
|
|
97
|
+
size: typeof o.size === 'number' ? o.size : 0,
|
|
98
|
+
};
|
|
99
|
+
})
|
|
100
|
+
.filter((e) => e.path);
|
|
101
|
+
}
|
|
102
|
+
export async function blob(t, repo, ref, path) {
|
|
103
|
+
return file(await call(t, 'GET', `/v1/git/repos/${seg(repo)}/blob${query({ ref, path })}`), path);
|
|
104
|
+
}
|
|
105
|
+
/** A blob answer. A run's branch on the forge answers in the same shape. */
|
|
106
|
+
export function file(raw, path) {
|
|
107
|
+
const o = (raw && typeof raw === 'object' ? raw : {});
|
|
108
|
+
const binary = o.binary === true;
|
|
109
|
+
const truncated = o.truncated === true;
|
|
110
|
+
return {
|
|
111
|
+
path: str(o.path) || path,
|
|
112
|
+
text: binary || truncated ? '' : str(o.content),
|
|
113
|
+
binary,
|
|
114
|
+
truncated,
|
|
115
|
+
size: typeof o.size === 'number' ? o.size : 0,
|
|
116
|
+
};
|
|
117
|
+
}
|