@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,82 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
import { type Tool } from './tools.ts';
|
|
3
|
+
/** An org's own skill. */
|
|
4
|
+
export interface Skill {
|
|
5
|
+
/** Derived from the name, and what a delete addresses. */
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
/** The SKILL.md body. */
|
|
10
|
+
content: string;
|
|
11
|
+
/** When it was last written, Unix seconds. */
|
|
12
|
+
created: number;
|
|
13
|
+
/** The repository it was read from, or '' for one written here. */
|
|
14
|
+
source: string;
|
|
15
|
+
/** False when no admin wrote it, so no run carries it; true, or unsaid by an older platform. */
|
|
16
|
+
admitted: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** One skill of the brand's catalogue. */
|
|
19
|
+
export interface Entry {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
/** The product it belongs to. */
|
|
23
|
+
product: string;
|
|
24
|
+
/** The kinds of work (`roles.ts` WORK) the catalogue recommends it for. */
|
|
25
|
+
works: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface Catalogue {
|
|
28
|
+
skills: Entry[];
|
|
29
|
+
products: {
|
|
30
|
+
name: string;
|
|
31
|
+
count: number;
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
/** A skill's name: one lowercase path segment, as the handler takes it. */
|
|
35
|
+
export declare const NAME: RegExp;
|
|
36
|
+
/** The most SKILL.md the handler keeps. */
|
|
37
|
+
export declare const MAX: number;
|
|
38
|
+
/** The tool name a skill is switched on by. */
|
|
39
|
+
export declare const tool: (name: string) => string;
|
|
40
|
+
/** The skill a tool name switches, or '' when it is not a skill's. */
|
|
41
|
+
export declare const nameOf: (tool: string) => string;
|
|
42
|
+
export declare function skill(raw: unknown): Skill;
|
|
43
|
+
export declare function catalogue(raw: unknown): Catalogue;
|
|
44
|
+
/** The org's skills that are on, brand and own. */
|
|
45
|
+
export declare function active(t: Target): Promise<Tool[]>;
|
|
46
|
+
export declare function authored(t: Target): Promise<Skill[]>;
|
|
47
|
+
/** Why a skill cannot be written as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
48
|
+
export declare function refuse(s: {
|
|
49
|
+
name: string;
|
|
50
|
+
content: string;
|
|
51
|
+
}): string;
|
|
52
|
+
export declare function write(t: Target, s: {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
content: string;
|
|
56
|
+
}): Promise<Skill>;
|
|
57
|
+
export declare function remove(t: Target, id: string): Promise<void>;
|
|
58
|
+
export declare function brand(t: Target): Promise<Catalogue>;
|
|
59
|
+
/** One catalogue skill's SKILL.md. */
|
|
60
|
+
export declare function document(t: Target, name: string): Promise<string>;
|
|
61
|
+
/** One thing Kai picked for a message: a skill (`skill_<name>`) or a tool, how likely it applies, and what it does. */
|
|
62
|
+
export interface Detected {
|
|
63
|
+
/** The skill's own name for a skill (`code-review`), else the tool's. */
|
|
64
|
+
name: string;
|
|
65
|
+
skill: boolean;
|
|
66
|
+
/** Where it comes from: skill, mcp, connector, function, agent. */
|
|
67
|
+
source: string;
|
|
68
|
+
description: string;
|
|
69
|
+
/** 0 to 1. */
|
|
70
|
+
probability: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
|
|
74
|
+
* detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
|
|
75
|
+
* is switched on (`autoActivate` is left out), so a message carries what was
|
|
76
|
+
* picked for it and nothing more.
|
|
77
|
+
*/
|
|
78
|
+
export declare function detect(t: Target, prompt: string, opts?: {
|
|
79
|
+
maxSkills?: number;
|
|
80
|
+
maxTools?: number;
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
}): Promise<Detected[]>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills: what an agent knows how to do, as a SKILL.md it reads.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/tool/skills?activated=true {tools: [Tool]} the org's skills that are on, brand and own
|
|
5
|
+
* GET /v1/tool/skills/authored {skills: [skill]} the org's own, with their SKILL.md
|
|
6
|
+
* POST /v1/tool/skills {name, description, content} → 201 {skill}; the same name revises it
|
|
7
|
+
* DELETE /v1/tool/skills/{id} {deleted}
|
|
8
|
+
* GET /.well-known/agent-skills/index.json the brand's catalogue, public
|
|
9
|
+
* GET /.well-known/agent-skills/{name}/SKILL.md one of its documents, public
|
|
10
|
+
* POST /v1/tool/detect {prompt, maxSkills, maxTools} → {skills, tools} Kai's pick for one message
|
|
11
|
+
*
|
|
12
|
+
* A skill is on when its tool name, `skill_<name>`, is activated (tools.ts):
|
|
13
|
+
* that is how a catalogue skill is added to an org and how an org's own skill is
|
|
14
|
+
* switched off. The brand's skill wins a name an org's own skill also takes.
|
|
15
|
+
*/
|
|
16
|
+
import { phrase } from '@hanzo/i18n';
|
|
17
|
+
import { call, reason, Refusal, seg } from './call.js';
|
|
18
|
+
import { toolsOf } from './tools.js';
|
|
19
|
+
/** A skill's name: one lowercase path segment, as the handler takes it. */
|
|
20
|
+
export const NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
21
|
+
/** The most SKILL.md the handler keeps. */
|
|
22
|
+
export const MAX = 256 << 10;
|
|
23
|
+
/** The tool name a skill is switched on by. */
|
|
24
|
+
export const tool = (name) => `skill_${name}`;
|
|
25
|
+
/** The skill a tool name switches, or '' when it is not a skill's. */
|
|
26
|
+
export const nameOf = (tool) => (tool.startsWith('skill_') ? tool.slice('skill_'.length) : '');
|
|
27
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
28
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
29
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
30
|
+
const rows = (v) => (Array.isArray(v) ? v : []);
|
|
31
|
+
export function skill(raw) {
|
|
32
|
+
const o = obj(raw);
|
|
33
|
+
const name = str(o.name);
|
|
34
|
+
return {
|
|
35
|
+
id: str(o.id) || name,
|
|
36
|
+
name,
|
|
37
|
+
description: str(o.description),
|
|
38
|
+
content: str(o.content),
|
|
39
|
+
created: num(o.createdAt),
|
|
40
|
+
source: str(o.source),
|
|
41
|
+
admitted: o.admitted !== false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function catalogue(raw) {
|
|
45
|
+
const o = obj(raw);
|
|
46
|
+
return {
|
|
47
|
+
skills: rows(o.skills)
|
|
48
|
+
.map((r) => {
|
|
49
|
+
const e = obj(r);
|
|
50
|
+
return { name: str(e.name), description: str(e.description), product: str(e.service), works: rows(e.works).map(str).filter(Boolean) };
|
|
51
|
+
})
|
|
52
|
+
.filter((e) => e.name),
|
|
53
|
+
products: rows(o.products)
|
|
54
|
+
.map((r) => {
|
|
55
|
+
const p = obj(r);
|
|
56
|
+
return { name: str(p.name), count: num(p.skill_count) };
|
|
57
|
+
})
|
|
58
|
+
.filter((p) => p.name),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** The org's skills that are on, brand and own. */
|
|
62
|
+
export async function active(t) {
|
|
63
|
+
return toolsOf(await call(t, 'GET', '/v1/tool/skills?activated=true'));
|
|
64
|
+
}
|
|
65
|
+
export async function authored(t) {
|
|
66
|
+
return rows(obj(await call(t, 'GET', '/v1/tool/skills/authored')).skills).map(skill).filter((s) => s.name);
|
|
67
|
+
}
|
|
68
|
+
/** Why a skill cannot be written as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
69
|
+
export function refuse(s) {
|
|
70
|
+
if (!NAME.test(s.name))
|
|
71
|
+
return phrase('A name is one lowercase word: letters, digits, _ or -');
|
|
72
|
+
if (!s.content.trim())
|
|
73
|
+
return phrase('A skill needs its SKILL.md');
|
|
74
|
+
if (new TextEncoder().encode(s.content).length > MAX)
|
|
75
|
+
return phrase('A SKILL.md is at most 256 KB');
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
export async function write(t, s) {
|
|
79
|
+
const why = refuse(s);
|
|
80
|
+
if (why)
|
|
81
|
+
throw new Error(why);
|
|
82
|
+
return skill(obj(await call(t, 'POST', '/v1/tool/skills', { name: s.name, description: s.description, content: s.content })).skill);
|
|
83
|
+
}
|
|
84
|
+
export async function remove(t, id) {
|
|
85
|
+
await call(t, 'DELETE', `/v1/tool/skills/${seg(id)}`);
|
|
86
|
+
}
|
|
87
|
+
/** A public document of the brand's catalogue. It needs no bearer, so it sends none. */
|
|
88
|
+
async function open(t, path) {
|
|
89
|
+
const res = await fetch(`${t.api}/.well-known/agent-skills/${path}`);
|
|
90
|
+
if (!res.ok)
|
|
91
|
+
throw new Refusal(res.status, (await reason(res)) || `The catalogue answered ${res.status}`);
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
export async function brand(t) {
|
|
95
|
+
return catalogue(await (await open(t, 'index.json')).json());
|
|
96
|
+
}
|
|
97
|
+
/** One catalogue skill's SKILL.md. */
|
|
98
|
+
export async function document(t, name) {
|
|
99
|
+
return (await open(t, `${seg(name)}/SKILL.md`)).text();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
|
|
103
|
+
* detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
|
|
104
|
+
* is switched on (`autoActivate` is left out), so a message carries what was
|
|
105
|
+
* picked for it and nothing more.
|
|
106
|
+
*/
|
|
107
|
+
export async function detect(t, prompt, opts = {}) {
|
|
108
|
+
const raw = await call(t, 'POST', '/v1/tool/detect', { prompt, maxSkills: opts.maxSkills ?? 3, maxTools: opts.maxTools ?? 3 }, { signal: opts.signal });
|
|
109
|
+
const r = (raw && typeof raw === 'object' ? raw : {});
|
|
110
|
+
const read = (list, skill) => (Array.isArray(list) ? list : []).flatMap((x) => {
|
|
111
|
+
const o = (x && typeof x === 'object' ? x : {});
|
|
112
|
+
const tool = str(o.name);
|
|
113
|
+
const name = skill ? nameOf(tool) || tool : tool;
|
|
114
|
+
return name ? [{ name, skill, source: str(o.source), description: str(o.description), probability: num(o.probability) }] : [];
|
|
115
|
+
});
|
|
116
|
+
return [...read(r.skills, true), ...read(r.tools, false)];
|
|
117
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-Sent Events, read off a fetch body.
|
|
3
|
+
*
|
|
4
|
+
* `EventSource` cannot send an Authorization header, and the session stream
|
|
5
|
+
* refuses a request without a principal, so the stream is read as a plain
|
|
6
|
+
* response body and parsed here. The parser is pure: bytes in, frames and the
|
|
7
|
+
* unfinished tail out, so it is tested without a network.
|
|
8
|
+
*
|
|
9
|
+
* Per the spec a frame ends at a blank line; `event:` names it (default
|
|
10
|
+
* `message`), `data:` lines join with a newline, and a line starting `:` is a
|
|
11
|
+
* comment — the platform's 25-second `: ping` keep-alive.
|
|
12
|
+
*/
|
|
13
|
+
export interface Frame {
|
|
14
|
+
event: string;
|
|
15
|
+
data: string;
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
/** Split `buffer` into complete frames and the tail that has not ended yet. */
|
|
19
|
+
export declare function parse(buffer: string): {
|
|
20
|
+
frames: Frame[];
|
|
21
|
+
rest: string;
|
|
22
|
+
};
|
|
23
|
+
/** Read `body` to its end, calling `on` for each frame. */
|
|
24
|
+
export declare function read(body: ReadableStream<Uint8Array>, on: (f: Frame) => void, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-Sent Events, read off a fetch body.
|
|
3
|
+
*
|
|
4
|
+
* `EventSource` cannot send an Authorization header, and the session stream
|
|
5
|
+
* refuses a request without a principal, so the stream is read as a plain
|
|
6
|
+
* response body and parsed here. The parser is pure: bytes in, frames and the
|
|
7
|
+
* unfinished tail out, so it is tested without a network.
|
|
8
|
+
*
|
|
9
|
+
* Per the spec a frame ends at a blank line; `event:` names it (default
|
|
10
|
+
* `message`), `data:` lines join with a newline, and a line starting `:` is a
|
|
11
|
+
* comment — the platform's 25-second `: ping` keep-alive.
|
|
12
|
+
*/
|
|
13
|
+
/** Split `buffer` into complete frames and the tail that has not ended yet. */
|
|
14
|
+
export function parse(buffer) {
|
|
15
|
+
const text = buffer.replace(/\r\n?/g, '\n');
|
|
16
|
+
const frames = [];
|
|
17
|
+
let start = 0;
|
|
18
|
+
for (;;) {
|
|
19
|
+
const end = text.indexOf('\n\n', start);
|
|
20
|
+
if (end === -1)
|
|
21
|
+
break;
|
|
22
|
+
const block = text.slice(start, end);
|
|
23
|
+
start = end + 2;
|
|
24
|
+
let event = 'message';
|
|
25
|
+
let id = '';
|
|
26
|
+
const data = [];
|
|
27
|
+
for (const line of block.split('\n')) {
|
|
28
|
+
if (!line || line.startsWith(':'))
|
|
29
|
+
continue;
|
|
30
|
+
const colon = line.indexOf(':');
|
|
31
|
+
const field = colon === -1 ? line : line.slice(0, colon);
|
|
32
|
+
let value = colon === -1 ? '' : line.slice(colon + 1);
|
|
33
|
+
if (value.startsWith(' '))
|
|
34
|
+
value = value.slice(1);
|
|
35
|
+
if (field === 'event')
|
|
36
|
+
event = value;
|
|
37
|
+
else if (field === 'data')
|
|
38
|
+
data.push(value);
|
|
39
|
+
else if (field === 'id')
|
|
40
|
+
id = value;
|
|
41
|
+
}
|
|
42
|
+
if (data.length)
|
|
43
|
+
frames.push({ event, data: data.join('\n'), id });
|
|
44
|
+
}
|
|
45
|
+
return { frames, rest: text.slice(start) };
|
|
46
|
+
}
|
|
47
|
+
/** Read `body` to its end, calling `on` for each frame. */
|
|
48
|
+
export async function read(body, on, signal) {
|
|
49
|
+
const reader = body.getReader();
|
|
50
|
+
const decoder = new TextDecoder();
|
|
51
|
+
let rest = '';
|
|
52
|
+
const stop = () => void reader.cancel().catch(() => { });
|
|
53
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
54
|
+
try {
|
|
55
|
+
for (;;) {
|
|
56
|
+
const { value, done } = await reader.read();
|
|
57
|
+
if (done)
|
|
58
|
+
break;
|
|
59
|
+
const out = parse(rest + decoder.decode(value, { stream: true }));
|
|
60
|
+
rest = out.rest;
|
|
61
|
+
for (const f of out.frames)
|
|
62
|
+
on(f);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
signal?.removeEventListener('abort', stop);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
import { type Item } from './library.ts';
|
|
3
|
+
export interface Run {
|
|
4
|
+
id: string;
|
|
5
|
+
/** queued, running, succeeded, failed or cancelled. */
|
|
6
|
+
status: string;
|
|
7
|
+
title: string;
|
|
8
|
+
/** What the run's writing step said, when its product is words. */
|
|
9
|
+
text: string;
|
|
10
|
+
outputs: Item[];
|
|
11
|
+
/** Why it failed, in the platform's words, or ''. */
|
|
12
|
+
error: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Start {
|
|
15
|
+
template: string;
|
|
16
|
+
input: Record<string, unknown>;
|
|
17
|
+
title?: string;
|
|
18
|
+
parent?: string;
|
|
19
|
+
/** A brand (design system) the run reads as brand.* — its palette, type and voice. */
|
|
20
|
+
brand?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A design system: one of Studio's brands, the one store for them. Its tokens
|
|
24
|
+
* are CSS custom properties (--background, --primary, --font-sans, --radius-md,
|
|
25
|
+
* …, the form Studio's renderer reads), with `--component-*` and `--voice-*` as
|
|
26
|
+
* quoted lines a model follows (design.ts `tokensOf`).
|
|
27
|
+
*
|
|
28
|
+
* GET /v1/studio/brands {data: [brand]} the ones you may read
|
|
29
|
+
* GET /v1/studio/brands/{id} one
|
|
30
|
+
* POST /v1/studio/brands {name, tokens, shared?} → brand
|
|
31
|
+
*/
|
|
32
|
+
export interface Brand {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
tokens: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
export declare function brandOf(raw: unknown): Brand;
|
|
38
|
+
export declare function brands(t: Target, init?: {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}): Promise<Brand[]>;
|
|
41
|
+
export declare function brand(t: Target, id: string, init?: {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}): Promise<Brand>;
|
|
44
|
+
export declare function keepBrand(t: Target, b: {
|
|
45
|
+
name: string;
|
|
46
|
+
tokens: Record<string, unknown>;
|
|
47
|
+
}, signal?: AbortSignal): Promise<Brand>;
|
|
48
|
+
export declare function run(raw: unknown): Run;
|
|
49
|
+
/** A run that has ended, one way or the other. */
|
|
50
|
+
export declare const ended: (r: Run) => boolean;
|
|
51
|
+
/** The ids of the templates this org may run. */
|
|
52
|
+
export declare function templates(t: Target, init?: {
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
}): Promise<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Start a run and wait for it to end. Aborted, the run is cancelled so its
|
|
57
|
+
* reservation is released; a run that fails is thrown with its reason.
|
|
58
|
+
*/
|
|
59
|
+
export declare function make(t: Target, s: Start, signal?: AbortSignal): Promise<Run>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hanzo Studio: a creation is a run of a template, its files kept in the Library.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/studio/templates {data: [template]} the public catalog, then the org's own
|
|
5
|
+
* POST /v1/studio/runs {template, input, title?, parent?} → 201 run, queued
|
|
6
|
+
* GET /v1/studio/runs/{id} the run: status, text, outputs
|
|
7
|
+
* POST /v1/studio/runs/{id}/cancel stop it; what it reserved is released
|
|
8
|
+
*
|
|
9
|
+
* A run is priced and its estimate reserved against the org's wallet before it
|
|
10
|
+
* is queued (402 when the wallet cannot cover it). `parent` makes the run the
|
|
11
|
+
* next version of that one. Its outputs are Library items: their `url` is
|
|
12
|
+
* signed and expires, their `origin` is the app path that opens the run in
|
|
13
|
+
* Studio and does not.
|
|
14
|
+
*/
|
|
15
|
+
import { phrase } from '@hanzo/i18n';
|
|
16
|
+
import { call, Refusal, seg, Sentence } from './call.js';
|
|
17
|
+
import { item } from './library.js';
|
|
18
|
+
export function brandOf(raw) {
|
|
19
|
+
const o = obj(raw);
|
|
20
|
+
return { id: str(o.id), name: str(o.name), tokens: obj(o.tokens) };
|
|
21
|
+
}
|
|
22
|
+
export async function brands(t, init) {
|
|
23
|
+
const raw = obj(await call(t, 'GET', '/v1/studio/brands', undefined, init));
|
|
24
|
+
return (Array.isArray(raw.data) ? raw.data : []).map(brandOf).filter((b) => b.id);
|
|
25
|
+
}
|
|
26
|
+
export async function brand(t, id, init) {
|
|
27
|
+
return brandOf(await call(t, 'GET', `/v1/studio/brands/${seg(id)}`, undefined, init));
|
|
28
|
+
}
|
|
29
|
+
export async function keepBrand(t, b, signal) {
|
|
30
|
+
return brandOf(await call(t, 'POST', '/v1/studio/brands', { name: b.name, tokens: b.tokens }, { signal }));
|
|
31
|
+
}
|
|
32
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
33
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
34
|
+
export function run(raw) {
|
|
35
|
+
const o = obj(raw);
|
|
36
|
+
const e = obj(o.error);
|
|
37
|
+
return {
|
|
38
|
+
id: str(o.id),
|
|
39
|
+
status: str(o.status),
|
|
40
|
+
title: str(o.title),
|
|
41
|
+
text: str(o.text),
|
|
42
|
+
outputs: (Array.isArray(o.outputs) ? o.outputs : []).map(item).filter((x) => x !== null),
|
|
43
|
+
error: str(e.detail) || str(e.title),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** A run that has ended, one way or the other. */
|
|
47
|
+
export const ended = (r) => r.status !== 'queued' && r.status !== 'running' && r.status !== '';
|
|
48
|
+
/** The ids of the templates this org may run. */
|
|
49
|
+
export async function templates(t, init) {
|
|
50
|
+
const raw = obj(await call(t, 'GET', '/v1/studio/templates', undefined, init));
|
|
51
|
+
return (Array.isArray(raw.data) ? raw.data : []).map((x) => str(obj(x).id)).filter(Boolean);
|
|
52
|
+
}
|
|
53
|
+
/** How often a run is read while it works, and the longest it is waited for. */
|
|
54
|
+
const EVERY = 2_000;
|
|
55
|
+
const LONGEST = 5 * 60_000;
|
|
56
|
+
const pause = (ms, signal) => new Promise((done, fail) => {
|
|
57
|
+
const id = setTimeout(done, ms);
|
|
58
|
+
signal?.addEventListener('abort', () => {
|
|
59
|
+
clearTimeout(id);
|
|
60
|
+
fail(signal.reason);
|
|
61
|
+
}, { once: true });
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Start a run and wait for it to end. Aborted, the run is cancelled so its
|
|
65
|
+
* reservation is released; a run that fails is thrown with its reason.
|
|
66
|
+
*/
|
|
67
|
+
export async function make(t, s, signal) {
|
|
68
|
+
let r = run(await call(t, 'POST', '/v1/studio/runs', s, { signal }).catch((e) => {
|
|
69
|
+
throw e instanceof Refusal && e.status === 402 ? new Error(phrase('Your balance does not cover it. Add credit in Settings › Billing.')) : e;
|
|
70
|
+
}));
|
|
71
|
+
if (!r.id)
|
|
72
|
+
throw new Error(phrase('Studio started the run and named no id'));
|
|
73
|
+
const id = r.id;
|
|
74
|
+
const stop = () => void call(t, 'POST', `/v1/studio/runs/${seg(id)}/cancel`, {}).catch(() => undefined);
|
|
75
|
+
signal?.addEventListener('abort', stop, { once: true });
|
|
76
|
+
try {
|
|
77
|
+
const until = Date.now() + LONGEST;
|
|
78
|
+
while (!ended(r)) {
|
|
79
|
+
if (Date.now() > until)
|
|
80
|
+
throw new Error(phrase('Studio is still making it. It will be in your Library when it is done.'));
|
|
81
|
+
await pause(EVERY, signal);
|
|
82
|
+
r = run(await call(t, 'GET', `/v1/studio/runs/${seg(id)}`, undefined, { signal }));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
signal?.removeEventListener('abort', stop);
|
|
87
|
+
}
|
|
88
|
+
if (r.status !== 'succeeded')
|
|
89
|
+
throw r.error ? new Error(r.error) : new Sentence(phrase('Studio could not make it ({status})'), { status: r.status });
|
|
90
|
+
return r;
|
|
91
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
import type { Event, Session } from './sessions.ts';
|
|
3
|
+
/** The channel a conversation's session is on. */
|
|
4
|
+
export declare const TALK = "app";
|
|
5
|
+
/**
|
|
6
|
+
* Whether a session is a conversation, rather than one run. A conversation's runs
|
|
7
|
+
* are on its channel too — born in its tree, its person's alone — and are told
|
|
8
|
+
* from it by having a parent: the conversation is the root.
|
|
9
|
+
*/
|
|
10
|
+
export declare const talks: (s: Pick<Session, 'channel' | 'parent'> | null | undefined) => boolean;
|
|
11
|
+
export interface Say {
|
|
12
|
+
/** The conversation to continue. Absent starts one. */
|
|
13
|
+
session?: string;
|
|
14
|
+
/** What the person said. */
|
|
15
|
+
input: string;
|
|
16
|
+
/** The model, by the id GET /v1/models lists. */
|
|
17
|
+
model?: string;
|
|
18
|
+
/** The repository: its name in the org, or owner/name on GitHub. */
|
|
19
|
+
repo?: string;
|
|
20
|
+
/** The branch a coding run starts from. */
|
|
21
|
+
base?: string;
|
|
22
|
+
/** One of the org's machines. Absent is the sandbox. */
|
|
23
|
+
target?: string;
|
|
24
|
+
/** How the conversation's coding runs go: on their own, asked for first, or plans only. */
|
|
25
|
+
mode?: 'auto' | 'manual' | 'plan';
|
|
26
|
+
/** How hard a coding run thinks: low, medium or high. */
|
|
27
|
+
effort?: string;
|
|
28
|
+
/** The issue on `repo` a coding run resolves. */
|
|
29
|
+
issue?: number;
|
|
30
|
+
/** Out-of-band instructions (skills, memories) kept separate from `input`. */
|
|
31
|
+
instructions?: string;
|
|
32
|
+
/** Explicit alias for `instructions` forwarded to turns and coding runs. */
|
|
33
|
+
developerInstructions?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface Said {
|
|
36
|
+
/** The conversation: the same id on every turn. */
|
|
37
|
+
session: string;
|
|
38
|
+
/** This turn's run within it. */
|
|
39
|
+
run: string;
|
|
40
|
+
}
|
|
41
|
+
/** The request body: only what was said, with no empty values sent. */
|
|
42
|
+
export declare function body(s: Say): Record<string, string | number | boolean>;
|
|
43
|
+
/** Say one thing in a conversation: a new one without `session`, that one with it. */
|
|
44
|
+
export declare function say(t: Target, s: Say): Promise<Said>;
|
|
45
|
+
/** What a conversation's turn is doing now: its latest progress line, or ''. */
|
|
46
|
+
export declare function now(events: Pick<Event, 'kind' | 'payload' | 'seq'>[]): string;
|
|
47
|
+
/** Answer a question a session's run asked: an option pressed, or the person's own words. */
|
|
48
|
+
export declare function answer(t: Target, session: string, question: string, text: string, chosen: boolean): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev's conversation, as the platform keeps it (apps/agents talk.go): one
|
|
3
|
+
* session, every turn.
|
|
4
|
+
*
|
|
5
|
+
* POST /v1/agent/turns {session?, input, model?, effort?, repo?, base?, target?, mode?, issue?}
|
|
6
|
+
* → {sessionId, runId}
|
|
7
|
+
* POST /v1/agent/sessions/{id}/answer {question, text, chosen} answer what a turn asked
|
|
8
|
+
*
|
|
9
|
+
* The first thing said opens the conversation; everything said after continues
|
|
10
|
+
* the SAME session under a new run, once its last turn has answered — what is said
|
|
11
|
+
* while a turn still works is that turn's next input (sessions.ts `message`). The
|
|
12
|
+
* agent answers, and decides for itself when a turn needs a sandbox (leased on its
|
|
13
|
+
* first use, kept for the conversation) or a coding run (which carries on the
|
|
14
|
+
* conversation's last, in its sandbox and on its branch). A turn that only talks
|
|
15
|
+
* uses neither, and a turn ends when its answer does: a build it started is
|
|
16
|
+
* followed after, and its outcome is said into the conversation when it ends.
|
|
17
|
+
*
|
|
18
|
+
* The repository, branch, machine and mode are kept on the conversation from the
|
|
19
|
+
* first message: every coding run its turns start works on them, auto starts it,
|
|
20
|
+
* manual asks first (a question answered here), plan only reads and plans. The
|
|
21
|
+
* model and effort ride each turn. Between turns the session rests `paused`.
|
|
22
|
+
*/
|
|
23
|
+
import { phrase } from '@hanzo/i18n';
|
|
24
|
+
import { call, Refusal, seg } from './call.js';
|
|
25
|
+
import { decode } from './turn.js';
|
|
26
|
+
/** The channel a conversation's session is on. */
|
|
27
|
+
export const TALK = 'app';
|
|
28
|
+
/**
|
|
29
|
+
* Whether a session is a conversation, rather than one run. A conversation's runs
|
|
30
|
+
* are on its channel too — born in its tree, its person's alone — and are told
|
|
31
|
+
* from it by having a parent: the conversation is the root.
|
|
32
|
+
*/
|
|
33
|
+
export const talks = (s) => s?.channel === TALK && !s.parent;
|
|
34
|
+
/** The request body: only what was said, with no empty values sent. */
|
|
35
|
+
export function body(s) {
|
|
36
|
+
const out = { input: s.input.trim() };
|
|
37
|
+
for (const k of [
|
|
38
|
+
'session',
|
|
39
|
+
'model',
|
|
40
|
+
'effort',
|
|
41
|
+
'repo',
|
|
42
|
+
'base',
|
|
43
|
+
'target',
|
|
44
|
+
'mode',
|
|
45
|
+
'instructions',
|
|
46
|
+
'developerInstructions',
|
|
47
|
+
]) {
|
|
48
|
+
const v = s[k]?.trim();
|
|
49
|
+
if (v)
|
|
50
|
+
out[k] = v;
|
|
51
|
+
}
|
|
52
|
+
if (s.issue && Number.isInteger(s.issue) && s.issue > 0)
|
|
53
|
+
out.issue = s.issue;
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** Say one thing in a conversation: a new one without `session`, that one with it. */
|
|
57
|
+
export async function say(t, s) {
|
|
58
|
+
if (!s.input.trim())
|
|
59
|
+
throw new Refusal(400, phrase('Say something'));
|
|
60
|
+
const r = await call(t, 'POST', '/v1/agent/turns', body(s));
|
|
61
|
+
const session = typeof r?.sessionId === 'string' ? r.sessionId : '';
|
|
62
|
+
if (!session)
|
|
63
|
+
throw new Refusal(502, phrase('The conversation answered with no session'));
|
|
64
|
+
return { session, run: typeof r?.runId === 'string' ? r.runId : '' };
|
|
65
|
+
}
|
|
66
|
+
/** What a conversation's turn is doing now: its latest progress line, or ''. */
|
|
67
|
+
export function now(events) {
|
|
68
|
+
let doing = '';
|
|
69
|
+
for (const e of [...events].sort((a, b) => a.seq - b.seq)) {
|
|
70
|
+
const b = decode(e.payload);
|
|
71
|
+
if (e.kind === 'progress' && b && typeof b !== 'string' && typeof b.activity === 'string')
|
|
72
|
+
doing = b.activity;
|
|
73
|
+
}
|
|
74
|
+
return doing;
|
|
75
|
+
}
|
|
76
|
+
/** Answer a question a session's run asked: an option pressed, or the person's own words. */
|
|
77
|
+
export async function answer(t, session, question, text, chosen) {
|
|
78
|
+
if (!text.trim())
|
|
79
|
+
throw new Refusal(400, phrase('Say an answer'));
|
|
80
|
+
await call(t, 'POST', `/v1/agent/sessions/${seg(session)}/answer`, { question, text: text.trim(), chosen });
|
|
81
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org's tool plane: every tool it can reach, and which of them are on.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/tool?source=&activated=true {tools: [{name, source, description, activated, dispatchable}]}
|
|
5
|
+
* GET /v1/tool/activation {enabled: [name]}
|
|
6
|
+
* PUT /v1/tool/activation {activate: [name], deactivate: [name]} → {enabled: [name]}
|
|
7
|
+
*
|
|
8
|
+
* A tool is on per org. On is what puts a skill's SKILL.md in an agent's prompt
|
|
9
|
+
* and what lets an MCP server's tool be called; a tool that is off is listed and
|
|
10
|
+
* refused at call time. Any member of the org may switch one — the handler asks
|
|
11
|
+
* for the org and nothing more.
|
|
12
|
+
*/
|
|
13
|
+
import { type Target } from './call.ts';
|
|
14
|
+
export interface Tool {
|
|
15
|
+
/** The flat, fleet-wide name: `skill_<name>`, `<server id>_<tool>`, `agent_<name>`… */
|
|
16
|
+
name: string;
|
|
17
|
+
/** connector, function, zap-service, agent, skill or mcp. */
|
|
18
|
+
source: string;
|
|
19
|
+
description: string;
|
|
20
|
+
activated: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare const names: (v: unknown) => string[];
|
|
23
|
+
export declare function tool(raw: unknown): Tool;
|
|
24
|
+
/** The tools in one listing, whichever of the plane's two envelopes it came in. */
|
|
25
|
+
export declare function toolsOf(raw: unknown): Tool[];
|
|
26
|
+
/** Every tool the org reaches, narrowed to one source and to the ones that are on when asked. */
|
|
27
|
+
export declare function tools(t: Target, q?: {
|
|
28
|
+
source?: string;
|
|
29
|
+
activated?: boolean;
|
|
30
|
+
}): Promise<Tool[]>;
|
|
31
|
+
/** The names that are on. */
|
|
32
|
+
export declare function enabled(t: Target): Promise<string[]>;
|
|
33
|
+
/** Switch names on and off; answers every name that is on afterwards. */
|
|
34
|
+
export declare function toggle(t: Target, on: string[], off?: string[]): Promise<string[]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org's tool plane: every tool it can reach, and which of them are on.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/tool?source=&activated=true {tools: [{name, source, description, activated, dispatchable}]}
|
|
5
|
+
* GET /v1/tool/activation {enabled: [name]}
|
|
6
|
+
* PUT /v1/tool/activation {activate: [name], deactivate: [name]} → {enabled: [name]}
|
|
7
|
+
*
|
|
8
|
+
* A tool is on per org. On is what puts a skill's SKILL.md in an agent's prompt
|
|
9
|
+
* and what lets an MCP server's tool be called; a tool that is off is listed and
|
|
10
|
+
* refused at call time. Any member of the org may switch one — the handler asks
|
|
11
|
+
* for the org and nothing more.
|
|
12
|
+
*/
|
|
13
|
+
import { call, query } from './call.js';
|
|
14
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
15
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
16
|
+
export const names = (v) => (Array.isArray(v) ? v.filter((n) => typeof n === 'string' && n !== '') : []);
|
|
17
|
+
export function tool(raw) {
|
|
18
|
+
const o = obj(raw);
|
|
19
|
+
return { name: str(o.name), source: str(o.source), description: str(o.description), activated: o.activated === true };
|
|
20
|
+
}
|
|
21
|
+
/** The tools in one listing, whichever of the plane's two envelopes it came in. */
|
|
22
|
+
export function toolsOf(raw) {
|
|
23
|
+
const list = obj(raw).tools;
|
|
24
|
+
return (Array.isArray(list) ? list : []).map(tool).filter((x) => x.name);
|
|
25
|
+
}
|
|
26
|
+
/** Every tool the org reaches, narrowed to one source and to the ones that are on when asked. */
|
|
27
|
+
export async function tools(t, q = {}) {
|
|
28
|
+
return toolsOf(await call(t, 'GET', `/v1/tool${query({ source: q.source, activated: q.activated ? 'true' : undefined })}`));
|
|
29
|
+
}
|
|
30
|
+
/** The names that are on. */
|
|
31
|
+
export async function enabled(t) {
|
|
32
|
+
return names(obj(await call(t, 'GET', '/v1/tool/activation')).enabled);
|
|
33
|
+
}
|
|
34
|
+
/** Switch names on and off; answers every name that is on afterwards. */
|
|
35
|
+
export async function toggle(t, on, off = []) {
|
|
36
|
+
return names(obj(await call(t, 'PUT', '/v1/tool/activation', { activate: on, deactivate: off })).enabled);
|
|
37
|
+
}
|