@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,513 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Agents: the org's own — a model, instructions, the tools it may call, and
|
|
4
|
+
* what it may spend.
|
|
5
|
+
*
|
|
6
|
+
* Browse is every agent there is to start from: the host's default agents
|
|
7
|
+
* (`cast`) and personas (`personas`), by name and category. Use makes the org's own
|
|
8
|
+
* agent from one and opens it; nothing is added any other way, so an org starts
|
|
9
|
+
* with none. An agent is also made from scratch, from the person signed in
|
|
10
|
+
* (Clone yourself) or from anyone named. Yours lists the org's agents. Opening one is its profile page
|
|
11
|
+
* (`-/customize/agents/<name>`): its face, part, model, instructions, tools,
|
|
12
|
+
* budget and runs, edited in place, and only what changed is sent. An
|
|
13
|
+
* agent calls only the tools it names, and only those that are on for the org,
|
|
14
|
+
* so the choices are the tools that are on; "every tool" is whatever the
|
|
15
|
+
* fleet's MCP server serves when it runs. A budget is required: what it may
|
|
16
|
+
* spend each period, and in one run.
|
|
17
|
+
*
|
|
18
|
+
* Its words are the reader's language (@hanzo/i18n `t`); an agent's name,
|
|
19
|
+
* description, instructions, model and runs, and the categories the host and
|
|
20
|
+
* the platform give their templates, are drawn as given.
|
|
21
|
+
*/
|
|
22
|
+
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
23
|
+
import { phrase } from '@hanzo/i18n';
|
|
24
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
25
|
+
import { ArrowLeft, Upload, X } from '@hanzogui/lucide-icons-2';
|
|
26
|
+
import { Button, Input, Switch, Textarea } from '@hanzo/ui';
|
|
27
|
+
import { ModelPicker } from '@hanzo/ui/models';
|
|
28
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
29
|
+
import { RING } from '../pane.js';
|
|
30
|
+
import { agents, ALL, CAST_CAP, CAST_TASK, create, draft, EMPTY, micros, one, PERIODS, person, profile, remove, SCHEDULES, TRIGGERS, update, use } from '../api/agents.js';
|
|
31
|
+
import { models } from '../api/models.js';
|
|
32
|
+
import { tools } from '../api/tools.js';
|
|
33
|
+
import { useHost, useTarget } from '../host.js';
|
|
34
|
+
import { useSpend } from '../spend.js';
|
|
35
|
+
import { useFunds } from '../mind.js';
|
|
36
|
+
import { path } from '../route.js';
|
|
37
|
+
import { Drafted } from './drafted.js';
|
|
38
|
+
import { Inventory, Traits } from './inventory.js';
|
|
39
|
+
import { useLoad } from './load.js';
|
|
40
|
+
import { keep, kept, nature, score } from './ocean.js';
|
|
41
|
+
import { say } from './say.js';
|
|
42
|
+
import { Add, Choice, Empty, Failed, Field, FilterPills, Grid, Line, Mark, matches, Part, Sheet, Soft, useCount, Visitor } from './ui.js';
|
|
43
|
+
import { Confirm } from '../ask.js';
|
|
44
|
+
/** How many cards Browse draws at a time. */
|
|
45
|
+
const PAGE = 24;
|
|
46
|
+
const ANY = phrase('All');
|
|
47
|
+
const DOMAIN_DEFS = [
|
|
48
|
+
{ id: 'all', label: phrase('All') },
|
|
49
|
+
{ id: 'team', label: phrase('Core team') },
|
|
50
|
+
{ id: 'engineering', label: phrase('Engineering & science') },
|
|
51
|
+
{ id: 'business', label: phrase('Business & strategy') },
|
|
52
|
+
{ id: 'creative', label: phrase('Design & creative') },
|
|
53
|
+
{ id: 'thinking', label: phrase('Writing & thinking') },
|
|
54
|
+
];
|
|
55
|
+
const ENGINEERING_CATS = new Set([
|
|
56
|
+
'engineer', 'programmer', 'tech leader', 'cryptographer', 'scientist',
|
|
57
|
+
'mathematician', 'physicist', 'innovator', 'logician', 'architect',
|
|
58
|
+
]);
|
|
59
|
+
const BUSINESS_CATS = new Set([
|
|
60
|
+
'executive', 'leader', 'investor', 'economist', 'management',
|
|
61
|
+
'accountant', 'merchant', 'advertiser', 'jurist', 'diplomat', 'statesman',
|
|
62
|
+
]);
|
|
63
|
+
const CREATIVE_CATS = new Set([
|
|
64
|
+
'designer', 'artist', 'filmmaker', 'musician', 'composer',
|
|
65
|
+
'photographer', 'sculptor', 'choreographer', 'singer', 'comedian',
|
|
66
|
+
]);
|
|
67
|
+
function domainOf(c, isTeam) {
|
|
68
|
+
if (isTeam || c.category.toLowerCase() === 'team')
|
|
69
|
+
return 'team';
|
|
70
|
+
const cat = c.category.toLowerCase();
|
|
71
|
+
if (ENGINEERING_CATS.has(cat))
|
|
72
|
+
return 'engineering';
|
|
73
|
+
if (BUSINESS_CATS.has(cat))
|
|
74
|
+
return 'business';
|
|
75
|
+
if (CREATIVE_CATS.has(cat))
|
|
76
|
+
return 'creative';
|
|
77
|
+
return 'thinking';
|
|
78
|
+
}
|
|
79
|
+
const TRIGGER_LABELS = {
|
|
80
|
+
webhook: { title: phrase('Webhook & API events'), detail: phrase('Wake immediately when an inbound webhook or API event fires.') },
|
|
81
|
+
git: { title: phrase('Git, PR & CI events'), detail: phrase('React proactively to pushes, pull requests, and build failures.') },
|
|
82
|
+
channel: { title: phrase('Channel & message events'), detail: phrase('Listen and respond to Slack, Discord, Telegram, and team channels.') },
|
|
83
|
+
watch: { title: phrase('Proactive anomaly watch'), detail: phrase('Continuously monitor metrics, queues, and alerts 24/7.') },
|
|
84
|
+
};
|
|
85
|
+
const FAST_BOTS = new Set(['dev', 'cyber', 'sal', 'mark', 'rev', 'biz', 'su', 'data']);
|
|
86
|
+
const GIT_BOTS = new Set(['dev', 'cyber', 'sci', 'data', 'doc', 'lang']);
|
|
87
|
+
/** Any real agent preset configured to operate as a 24/7 autonomous, proactive, and event-driven bot. */
|
|
88
|
+
function asBot(c) {
|
|
89
|
+
const key = c.name.toLowerCase();
|
|
90
|
+
const schedule = c.schedule || (FAST_BOTS.has(key) ? '*/15 * * * *' : '0 9 * * 1-5');
|
|
91
|
+
const triggers = c.triggers?.length
|
|
92
|
+
? c.triggers
|
|
93
|
+
: GIT_BOTS.has(key)
|
|
94
|
+
? ['git', 'webhook', 'watch']
|
|
95
|
+
: ['channel', 'webhook', 'watch'];
|
|
96
|
+
return {
|
|
97
|
+
...c,
|
|
98
|
+
category: 'Bot',
|
|
99
|
+
executionMode: 'long-running',
|
|
100
|
+
schedule,
|
|
101
|
+
triggers,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** Categories as Browse offers them: the default agents' first, as listed, then the rest by how many each holds. */
|
|
105
|
+
export function kinds(first, rest) {
|
|
106
|
+
const lead = [...new Set(first.map((c) => c.category).filter((cat) => cat !== 'Bot'))];
|
|
107
|
+
const count = new Map();
|
|
108
|
+
for (const c of rest)
|
|
109
|
+
if (c.category !== 'Bot' && !lead.includes(c.category))
|
|
110
|
+
count.set(c.category, (count.get(c.category) ?? 0) + 1);
|
|
111
|
+
return [ANY, ...lead, ...[...count.keys()].sort((a, b) => count.get(b) - count.get(a) || a.localeCompare(b))];
|
|
112
|
+
}
|
|
113
|
+
const money = (m) => `$${(m / 1_000_000).toFixed(m % 10_000 ? 4 : 2).replace(/\.?0+$/, '')}`;
|
|
114
|
+
/** A category as Browse names it: All and people, in the reader's words; the rest are the host's, as given. */
|
|
115
|
+
const category = (c, t) => (c === ANY || c === 'Person' ? t(c) : c);
|
|
116
|
+
/**
|
|
117
|
+
* A budget's sentences by its period ('' where the agent names none): whole
|
|
118
|
+
* sentences, so a language says the period its own way.
|
|
119
|
+
*/
|
|
120
|
+
const SPENT = {
|
|
121
|
+
day: phrase('{spent} of {cap} this day'),
|
|
122
|
+
week: phrase('{spent} of {cap} this week'),
|
|
123
|
+
month: phrase('{spent} of {cap} this month'),
|
|
124
|
+
'': phrase('{spent} of {cap} this period'),
|
|
125
|
+
};
|
|
126
|
+
const BUDGET = {
|
|
127
|
+
day: phrase('{spent} of {cap} spent this day; at most {task} a run.'),
|
|
128
|
+
week: phrase('{spent} of {cap} spent this week; at most {task} a run.'),
|
|
129
|
+
month: phrase('{spent} of {cap} spent this month; at most {task} a run.'),
|
|
130
|
+
'': phrase('{spent} of {cap} spent this period; at most {task} a run.'),
|
|
131
|
+
};
|
|
132
|
+
/** What a 24/7 bot may spend, said before it is made: whole sentences by its period. */
|
|
133
|
+
const AROUND = {
|
|
134
|
+
day: phrase('{name} runs by itself around the clock, on its schedule and when its triggers fire, and may spend up to {cap} a day until you pause or delete it.'),
|
|
135
|
+
week: phrase('{name} runs by itself around the clock, on its schedule and when its triggers fire, and may spend up to {cap} a week until you pause or delete it.'),
|
|
136
|
+
month: phrase('{name} runs by itself around the clock, on its schedule and when its triggers fire, and may spend up to {cap} a month until you pause or delete it.'),
|
|
137
|
+
};
|
|
138
|
+
/** The question before a 24/7 bot is made, whichever way it is made: Add, Elect or the editor. */
|
|
139
|
+
const bot = (name, cap, period, t) => ({
|
|
140
|
+
kind: 'bot',
|
|
141
|
+
title: t('Start {name} running 24/7?', { name }),
|
|
142
|
+
what: t(AROUND[period], { name, cap: money(micros(cap)) }),
|
|
143
|
+
yes: t('Start bot'),
|
|
144
|
+
uses: 'credits',
|
|
145
|
+
});
|
|
146
|
+
const SO_FAR = {
|
|
147
|
+
day: phrase('Spent {spent} this day.'),
|
|
148
|
+
week: phrase('Spent {spent} this week.'),
|
|
149
|
+
month: phrase('Spent {spent} this month.'),
|
|
150
|
+
'': phrase('Spent {spent} this period.'),
|
|
151
|
+
};
|
|
152
|
+
const EACH = { day: phrase('Each day, USD'), week: phrase('Each week, USD'), month: phrase('Each month, USD') };
|
|
153
|
+
const PERIOD = { day: phrase('Day'), week: phrase('Week'), month: phrase('Month') };
|
|
154
|
+
const CARD = { rounded: '$4', borderWidth: 1, borderColor: '$borderColor', bg: '$panel' };
|
|
155
|
+
const CARD_HOVER = { borderColor: 'var(--border-strong)', bg: '$hover' };
|
|
156
|
+
/**
|
|
157
|
+
* Agent card: top row is [Avatar] [Name + short Role] [flex={1}] [+ Use], and
|
|
158
|
+
* the 2-line description spans full card width underneath so copy never crushes.
|
|
159
|
+
*/
|
|
160
|
+
function AgentCard({ title, role, detail, meta, mark, action, onOpen, }) {
|
|
161
|
+
const identity = (_jsxs(_Fragment, { children: [mark, _jsxs(YStack, { flex: 1, minW: 0, gap: "$0.5", children: [_jsx(SizableText, { size: "$3", color: "$ink", numberOfLines: 1, children: title }), role ? (_jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: role })) : null] })] }));
|
|
162
|
+
const footer = detail || meta ? (_jsxs(YStack, { width: "100%", minW: 0, gap: "$1.5", children: [detail ? (_jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 2, children: detail })) : null, meta ? (_jsx(SizableText, { size: "$1", color: "$hint", numberOfLines: 1, children: meta })) : null] })) : null;
|
|
163
|
+
if (onOpen && !action) {
|
|
164
|
+
return (_jsx(YStack, { role: "listitem", minW: 0, ...CARD, hoverStyle: CARD_HOVER, children: _jsxs(YStack, { render: "button", "aria-label": title, onPress: onOpen, width: "100%", minW: 0, p: "$4", gap: "$3", "$platform-web": { textAlign: 'start' }, focusVisibleStyle: RING, children: [_jsx(XStack, { items: "center", gap: "$3", width: "100%", minW: 0, children: identity }), footer] }) }));
|
|
165
|
+
}
|
|
166
|
+
return (_jsxs(YStack, { role: "listitem", gap: "$3", p: "$4", minW: 0, ...CARD, children: [_jsxs(XStack, { items: "center", gap: "$3", width: "100%", minW: 0, children: [onOpen ? (_jsx(XStack, { render: "button", "aria-label": title, onPress: onOpen, flex: 1, minW: 0, gap: "$3", items: "center", "$platform-web": { textAlign: 'start' }, focusVisibleStyle: RING, children: identity })) : (_jsx(XStack, { flex: 1, minW: 0, gap: "$3", items: "center", children: identity })), action] }), footer] }));
|
|
167
|
+
}
|
|
168
|
+
export function Agents({ view, q, adding, onAdding, onView, onCount, mode = 'agents' }) {
|
|
169
|
+
const { t } = useI18n();
|
|
170
|
+
const host = useHost();
|
|
171
|
+
const target = useTarget();
|
|
172
|
+
const signed = Boolean(host.person);
|
|
173
|
+
const browsing = view === 'discover';
|
|
174
|
+
const botsMode = mode === 'bots';
|
|
175
|
+
const spend = useSpend();
|
|
176
|
+
const mine = useLoad(signed ? () => agents(target) : null, [], [target, signed]);
|
|
177
|
+
const figures = useLoad(browsing && !botsMode && host.personas ? host.personas : null, [], [view, botsMode]);
|
|
178
|
+
const yoursList = useMemo(() => (botsMode ? mine.value.filter((a) => a.executionMode === 'long-running') : mine.value.filter((a) => a.executionMode !== 'long-running')), [mine.value, botsMode]);
|
|
179
|
+
useCount(yoursList.length, onCount);
|
|
180
|
+
const [note, setNote] = useState('');
|
|
181
|
+
const [domain, setDomain] = useState('all');
|
|
182
|
+
const [sortBy, setSortBy] = useState('recommended');
|
|
183
|
+
const [showSpecialists, setShowSpecialists] = useState(false);
|
|
184
|
+
const [more, setMore] = useState(PAGE);
|
|
185
|
+
const [using, setUsing] = useState(null);
|
|
186
|
+
const [scratch, setScratch] = useState(false);
|
|
187
|
+
const [making, setMaking] = useState(null);
|
|
188
|
+
const [electing, setElecting] = useState(null);
|
|
189
|
+
useEffect(() => setMore(PAGE), [q, domain, sortBy, botsMode]);
|
|
190
|
+
const allCast = host.cast ?? [];
|
|
191
|
+
const isBotCast = (c) => c.category === 'Bot' || c.executionMode === 'long-running';
|
|
192
|
+
const first = botsMode
|
|
193
|
+
? allCast.map(asBot)
|
|
194
|
+
: allCast.map((c) => (isBotCast(c) ? { ...c, category: 'Team', executionMode: undefined, schedule: undefined, triggers: undefined } : c));
|
|
195
|
+
const opened = (a) => host.go(path({ kind: 'agent', name: a.name }));
|
|
196
|
+
const take = async (c) => {
|
|
197
|
+
// Add in Bots makes one that runs around the clock on the default budget: asked first.
|
|
198
|
+
if (botsMode && !(await spend.ask(bot(c.title, CAST_CAP, 'month', t))))
|
|
199
|
+
return;
|
|
200
|
+
setUsing(c);
|
|
201
|
+
setNote('');
|
|
202
|
+
try {
|
|
203
|
+
opened(await use(target, c, window.location.href, botsMode
|
|
204
|
+
? {
|
|
205
|
+
executionMode: 'long-running',
|
|
206
|
+
schedule: c.schedule || '*/15 * * * *',
|
|
207
|
+
triggers: c.triggers?.length ? c.triggers : ['webhook', 'git', 'channel', 'watch'],
|
|
208
|
+
}
|
|
209
|
+
: undefined));
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
setNote(say(e, t));
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
setUsing(null);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
// Toggleable creation panel opened by `+ New agent` / `+ New bot` — closed by default when browsing so the grid starts immediately.
|
|
219
|
+
const creator = adding && signed ? (_jsxs(YStack, { gap: "$3", p: "$4", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(SizableText, { size: "$3", fontWeight: "500", color: "$ink", children: botsMode ? t('Create a new bot') : t('Create a new agent') }), _jsx(XStack, { render: "button", "aria-label": t('Close'), onPress: () => onAdding(false), width: 32, height: 32, items: "center", justify: "center", shrink: 0, focusVisibleStyle: RING, children: _jsx(X, { size: 15, color: "$soft" }) })] }), botsMode ? (_jsxs(_Fragment, { children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('Build a persistent 24/7 bot from scratch, or elect a preset to run on a schedule and event triggers.') }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", children: [_jsx(Button, { size: "sm", variant: "primary", onPress: () => {
|
|
220
|
+
onAdding(false);
|
|
221
|
+
setScratch(true);
|
|
222
|
+
}, children: t('Start from scratch') }), allCast.length ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => {
|
|
223
|
+
onAdding(false);
|
|
224
|
+
setElecting((first[0] ?? allCast[0]));
|
|
225
|
+
}, children: t('Elect 24/7 preset') })) : null] })] })) : (_jsxs(_Fragment, { children: [_jsx(Drafted, { onMade: opened }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", items: "center", pt: "$1", borderTopWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$1", color: "$soft", paddingInlineEnd: "$1", children: t('Or start another way') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => {
|
|
226
|
+
onAdding(false);
|
|
227
|
+
setScratch(true);
|
|
228
|
+
}, children: t('Start from scratch') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => {
|
|
229
|
+
onAdding(false);
|
|
230
|
+
setMaking('self');
|
|
231
|
+
}, children: t('Clone yourself') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => {
|
|
232
|
+
onAdding(false);
|
|
233
|
+
setMaking('person');
|
|
234
|
+
}, children: t('Create from a person') })] })] }))] })) : null;
|
|
235
|
+
const modals = (_jsxs(_Fragment, { children: [spend.dialog, scratch ? (_jsx(Editor, { defaultBot: botsMode, onClose: () => setScratch(false), onSaved: (a) => {
|
|
236
|
+
setScratch(false);
|
|
237
|
+
onAdding(false);
|
|
238
|
+
onView('yours');
|
|
239
|
+
mine.reload();
|
|
240
|
+
setNote(t('{name} is saved', { name: a.name }));
|
|
241
|
+
} })) : null, making ? _jsx(Person, { self: making === 'self', onClose: () => setMaking(null), onMade: opened }) : null, electing ? _jsx(Elect, { preset: electing, all: allCast, onClose: () => setElecting(null), onElected: opened }) : null] }));
|
|
242
|
+
if (browsing) {
|
|
243
|
+
const rest = botsMode ? [] : figures.value.filter((c) => !isBotCast(c));
|
|
244
|
+
const teamSet = new Set(first.map((c) => `${c.name}/${c.title}`));
|
|
245
|
+
const sortList = (list) => sortBy === 'az' ? [...list].sort((a, b) => a.title.localeCompare(b.title)) : [...list];
|
|
246
|
+
const queryText = q.trim();
|
|
247
|
+
const matchCast = (c) => matches(q, c.title, c.name, c.description, c.category, ...(c.after ?? []));
|
|
248
|
+
const teamFiltered = sortList(first.filter((c) => (botsMode || domain === 'all' || domain === 'team') && matchCast(c)));
|
|
249
|
+
const specialistsFiltered = sortList(rest.filter((c) => !botsMode &&
|
|
250
|
+
(domain === 'all' || domainOf(c, teamSet.has(`${c.name}/${c.title}`)) === domain) &&
|
|
251
|
+
matchCast(c)));
|
|
252
|
+
const card = (c, inCoreTeam = false) => {
|
|
253
|
+
const cat = botsMode ? t('Bot') : category(c.category, t);
|
|
254
|
+
const hideTeamLabel = inCoreTeam && !botsMode && c.category.toLowerCase() === 'team';
|
|
255
|
+
const role = hideTeamLabel
|
|
256
|
+
? c.after?.length
|
|
257
|
+
? t('after {names}', { names: c.after.join(', ') })
|
|
258
|
+
: undefined
|
|
259
|
+
: cat || undefined;
|
|
260
|
+
const detail = [
|
|
261
|
+
c.description === c.title || c.description === c.category ? '' : c.description,
|
|
262
|
+
!hideTeamLabel && c.after?.length ? t('after {names}', { names: c.after.join(', ') }) : '',
|
|
263
|
+
]
|
|
264
|
+
.filter(Boolean)
|
|
265
|
+
.join(' · ') || undefined;
|
|
266
|
+
const meta = botsMode
|
|
267
|
+
? [c.executionMode === 'long-running' ? t('24/7 · proactive · event-driven') : '', c.schedule].filter(Boolean).join(' · ') || undefined
|
|
268
|
+
: undefined;
|
|
269
|
+
return (_jsx(AgentCard, { title: c.title, role: role, detail: detail, meta: meta, mark: _jsx(Mark, { name: c.title, size: 40, logo: c.avatar }), onOpen: signed && botsMode ? () => setElecting(c) : undefined, action: signed ? (_jsxs(XStack, { items: "center", gap: "$1.5", shrink: 0, children: [botsMode ? (_jsx(XStack, { "$max-sm": { display: 'none' }, children: _jsx(Button, { size: "sm", variant: "ghost", disabled: using !== null, "aria-label": t('Elect {name} to run 24/7', { name: c.title }), onPress: () => setElecting(c), children: t('Configure 24/7') }) })) : null, _jsx(Add, { name: c.title, use: true, added: false, busy: using !== null, onPress: () => void take(c) })] })) : undefined }, `${c.category}/${c.name}/${c.title}`));
|
|
270
|
+
};
|
|
271
|
+
const domainCounts = {
|
|
272
|
+
all: first.length + rest.length,
|
|
273
|
+
team: first.length,
|
|
274
|
+
engineering: rest.filter((c) => domainOf(c, false) === 'engineering').length,
|
|
275
|
+
business: rest.filter((c) => domainOf(c, false) === 'business').length,
|
|
276
|
+
creative: rest.filter((c) => domainOf(c, false) === 'creative').length,
|
|
277
|
+
thinking: rest.filter((c) => domainOf(c, false) === 'thinking').length,
|
|
278
|
+
};
|
|
279
|
+
const domainOptions = DOMAIN_DEFS.filter((d) => d.id === 'all' || d.id === 'team' || domainCounts[d.id] > 0).map((d) => ({
|
|
280
|
+
id: d.id,
|
|
281
|
+
label: d.id === 'all' ? t(d.label) : `${t(d.label)}`,
|
|
282
|
+
}));
|
|
283
|
+
const hasAnyMatch = teamFiltered.length > 0 || specialistsFiltered.length > 0;
|
|
284
|
+
const showGroupedAll = !botsMode && domain === 'all' && !queryText;
|
|
285
|
+
const specialistsVisible = showGroupedAll ? showSpecialists : true;
|
|
286
|
+
return (_jsxs(YStack, { gap: "$4", children: [creator, !botsMode && domainOptions.length > 1 ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", flexWrap: "wrap", children: [_jsx(XStack, { grow: 1, shrink: 1, minW: 0, children: _jsx(FilterPills, { label: t('Category'), value: domain, options: domainOptions, onChange: (next) => setDomain(next), maxVisibleDesktop: 6, mobileLimit: 4 }) }), _jsx(XStack, { role: "radiogroup", "aria-label": t('Sort agents'), items: "center", gap: 2, p: 2, shrink: 0, children: [
|
|
287
|
+
{ id: 'recommended', label: t('Recommended') },
|
|
288
|
+
{ id: 'az', label: t('A–Z') },
|
|
289
|
+
].map((opt) => {
|
|
290
|
+
const active = sortBy === opt.id;
|
|
291
|
+
return (_jsx(XStack, { render: "button", role: "radio", "aria-checked": active, onPress: () => setSortBy(opt.id), px: "$2.5", py: "$1", minH: 28, focusVisibleStyle: RING, items: "center", justify: "center", children: _jsx(SizableText, { size: "$1", fontWeight: active ? '600' : '400', color: active ? '$ink' : '$soft', children: opt.label }) }, opt.id));
|
|
292
|
+
}) })] })) : null, _jsx(Line, { children: note }), !hasAnyMatch ? (figures.loading ? null : queryText ? (_jsx(Soft, { children: t(botsMode ? 'No bot matches “{q}”.' : 'No agent matches “{q}”.', { q: queryText }) })) : botsMode ? (_jsx(Soft, { children: t('Create a persistent 24/7 bot from scratch or elect any preset.') })) : (_jsx(Soft, { children: t('No agent matches “{q}”.', { q: queryText }) }))) : (_jsxs(YStack, { gap: "$5", children: [teamFiltered.length > 0 ? (_jsxs(YStack, { gap: "$3", children: [!botsMode ? (_jsxs(XStack, { items: "baseline", justify: "space-between", gap: "$2", children: [_jsx(SizableText, { render: "h2", size: "$4", color: "$ink", children: t('Core team') }), _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} ready-to-use specialists', { n: teamFiltered.length }) })] })) : null, _jsx(Grid, { label: botsMode ? t('Bots to start from') : t('Core team agents'), children: teamFiltered.map((c) => card(c, !botsMode)) })] })) : null, specialistsFiltered.length > 0 ? (_jsxs(YStack, { gap: "$3", pt: teamFiltered.length > 0 ? '$5' : 0, borderTopWidth: teamFiltered.length > 0 ? 1 : 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", flexWrap: "wrap", children: [_jsxs(YStack, { gap: "$1.5", flex: 1, minW: 200, children: [_jsx(SizableText, { render: "h2", size: "$4", color: "$ink", children: domain === 'all' ? t('Domain thinkers & personas') : t(DOMAIN_DEFS.find((d) => d.id === domain)?.label ?? 'Personas') }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('{n} curated personas across science, strategy, design, and writing', { n: specialistsFiltered.length }) })] }), showGroupedAll ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => setShowSpecialists((v) => !v), children: showSpecialists ? t('Hide personas') : t('Browse {n} personas', { n: specialistsFiltered.length }) })) : null] }), specialistsVisible ? (_jsxs(_Fragment, { children: [_jsx(Grid, { label: t('Domain thinkers & personas'), children: specialistsFiltered.slice(0, more).map((c) => card(c, false)) }), specialistsFiltered.length > more ? (_jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "outline", onPress: () => setMore(more + PAGE), children: t('Show more ({remaining} left)', { remaining: specialistsFiltered.length - more }) }) })) : null] })) : null] })) : null] })), figures.error ? _jsx(Failed, { error: figures.error, onRetry: figures.reload }) : figures.loading ? _jsx(Soft, { children: t('Loading…') }) : null, modals] }));
|
|
293
|
+
}
|
|
294
|
+
if (!signed) {
|
|
295
|
+
return _jsx(Visitor, { children: t(botsMode ? 'Sign in to see your bots.' : 'Sign in to see your agents.') });
|
|
296
|
+
}
|
|
297
|
+
const shown = yoursList.filter((a) => matches(q, a.name, a.description, a.model));
|
|
298
|
+
return (_jsxs(YStack, { gap: "$3", children: [creator, _jsx(Line, { children: note }), mine.error && !yoursList.length ? (_jsx(Failed, { error: mine.error, onRetry: mine.reload })) : mine.loading && !yoursList.length ? (_jsx(Soft, { children: t(botsMode ? 'Loading your bots…' : 'Loading your agents…') })) : !yoursList.length ? (_jsxs(Empty, { title: t(botsMode ? 'No bots yet' : 'No agents yet'), detail: t(botsMode ? 'Create a 24/7 bot from scratch or browse presets to start from.' : 'Create one with AI, from scratch, or browse agents to start from.'), children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => onView('discover'), children: t(botsMode ? 'Browse bots' : 'Browse agents') }), _jsx(Button, { size: "sm", onPress: () => onAdding(true), children: t(botsMode ? 'New bot' : 'New agent') })] })) : !shown.length ? (_jsx(Soft, { children: t(botsMode ? 'No bot of yours matches “{q}”.' : 'No agent of yours matches “{q}”.', { q: q.trim() }) })) : (_jsx(Grid, { label: t(botsMode ? 'Your bots' : 'Your agents'), children: shown.map((a) => (_jsx(AgentCard, { title: a.name, role: a.model || undefined, detail: a.description || t('No description.'), meta: [
|
|
299
|
+
a.executionMode === 'long-running' ? t('24/7') : '',
|
|
300
|
+
a.schedule || '',
|
|
301
|
+
a.runs === 1 ? t('1 run') : t('{n} runs', { n: a.runs }),
|
|
302
|
+
reach(a, t),
|
|
303
|
+
a.cap ? t(SPENT[a.period], { spent: money(a.spent), cap: money(a.cap) }) : '',
|
|
304
|
+
]
|
|
305
|
+
.filter(Boolean)
|
|
306
|
+
.join(' · '), mark: _jsx(Face, { agent: a, cast: host.cast ?? [] }), onOpen: () => opened(a) }, a.id || a.name))) })), modals] }));
|
|
307
|
+
}
|
|
308
|
+
/** Elect an agent or bot preset to run autonomously 24/7, proactively on a schedule, and event-driven. */
|
|
309
|
+
function Elect({ preset, all, onClose, onElected, }) {
|
|
310
|
+
const { t } = useI18n();
|
|
311
|
+
const target = useTarget();
|
|
312
|
+
const [picked, setPicked] = useState(preset);
|
|
313
|
+
const [autonomous, setAutonomous] = useState(true);
|
|
314
|
+
const [schedule, setSchedule] = useState(preset.schedule || '*/15 * * * *');
|
|
315
|
+
const [triggers, setTriggers] = useState(preset.triggers?.length ? preset.triggers : ['webhook', 'git', 'channel', 'watch']);
|
|
316
|
+
const [cap, setCap] = useState(CAST_CAP);
|
|
317
|
+
const [task, setTask] = useState(CAST_TASK);
|
|
318
|
+
const [period, setPeriod] = useState('month');
|
|
319
|
+
const [working, setWorking] = useState(false);
|
|
320
|
+
const [note, setNote] = useState('');
|
|
321
|
+
const spend = useSpend();
|
|
322
|
+
const selectPreset = (c) => {
|
|
323
|
+
setPicked(c);
|
|
324
|
+
setSchedule(c.schedule || '*/15 * * * *');
|
|
325
|
+
setTriggers(c.triggers?.length ? c.triggers : ['webhook', 'git', 'channel', 'watch']);
|
|
326
|
+
};
|
|
327
|
+
const toggleTrigger = (tr, yes) => {
|
|
328
|
+
setTriggers((prev) => (yes ? [...new Set([...prev, tr])] : prev.filter((x) => x !== tr)));
|
|
329
|
+
};
|
|
330
|
+
const save = async () => {
|
|
331
|
+
if (autonomous && !(await spend.ask(bot(picked.title, cap, period, t))))
|
|
332
|
+
return;
|
|
333
|
+
setWorking(true);
|
|
334
|
+
setNote('');
|
|
335
|
+
try {
|
|
336
|
+
const created = await use(target, picked, window.location.href, {
|
|
337
|
+
executionMode: autonomous ? 'long-running' : 'one-shot',
|
|
338
|
+
schedule: autonomous ? schedule.trim() || '*/15 * * * *' : undefined,
|
|
339
|
+
triggers: autonomous ? triggers : undefined,
|
|
340
|
+
cap,
|
|
341
|
+
task,
|
|
342
|
+
period,
|
|
343
|
+
});
|
|
344
|
+
onElected(created);
|
|
345
|
+
}
|
|
346
|
+
catch (e) {
|
|
347
|
+
setNote(say(e, t));
|
|
348
|
+
setWorking(false);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
return (_jsxs(Sheet, { title: t('Elect 24/7 autonomous preset'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [spend.dialog, _jsxs(XStack, { items: "center", gap: "$3", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(Mark, { name: picked.title, size: 44, logo: picked.avatar }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$3", color: "$ink", children: picked.title }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: picked.description || picked.category })] })] }), all.length > 1 ? (_jsx(Field, { label: t('Preset'), hint: t('Select any agent or bot preset to elect as an autonomous 24/7 worker.'), children: _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", maxH: 136, overflow: "scroll", p: "$1", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", rounded: "$3", children: all.map((c) => {
|
|
352
|
+
const active = c.name === picked.name && c.category === picked.category;
|
|
353
|
+
return (_jsx(Button, { size: "sm", variant: active ? 'outline' : 'ghost', "aria-pressed": active, onPress: () => selectPreset(c), children: c.title }, `${c.category}/${c.name}`));
|
|
354
|
+
}) }) })) : null, _jsxs(XStack, { items: "center", gap: "$3", p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Run autonomously 24/7') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Stays active continuously (long-running), waking proactively on its schedule and when events fire.') })] }), _jsx(Switch, { checked: autonomous, onCheckedChange: setAutonomous, "aria-label": t('Run autonomously 24/7') })] }), autonomous ? (_jsxs(_Fragment, { children: [_jsx(Field, { label: t('Proactive schedule'), hint: t('Choose how often this agent wakes proactively, or enter any 5-field cron expression.'), children: _jsxs(YStack, { gap: "$2", children: [_jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: SCHEDULES.map((s) => {
|
|
355
|
+
const active = schedule.trim() === s.cron;
|
|
356
|
+
return (_jsx(Button, { size: "sm", variant: "outline", "aria-pressed": active, onPress: () => setSchedule(s.cron), children: t(s.label) }, s.cron));
|
|
357
|
+
}) }), _jsx(Input, { value: schedule, onChangeText: setSchedule, placeholder: "*/15 * * * *", "aria-label": t('Proactive schedule') })] }) }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Event-driven triggers') }), _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", children: TRIGGERS.map((tr, i) => (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t(TRIGGER_LABELS[tr].title) }), _jsx(SizableText, { size: "$1", color: "$soft", children: t(TRIGGER_LABELS[tr].detail) })] }), _jsx(Switch, { checked: triggers.includes(tr), onCheckedChange: (v) => toggleTrigger(tr, v), "aria-label": t(TRIGGER_LABELS[tr].title) })] }, tr))) })] })] })) : null, _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Budget') }), _jsxs(XStack, { gap: "$3", flexWrap: "wrap", rowGap: "$2", items: "flex-end", children: [_jsxs(YStack, { gap: "$1", width: 140, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t(EACH[period]) }), _jsx(Input, { value: cap, onChangeText: setCap, placeholder: "10", "aria-label": t('Budget each period'), inputMode: "decimal" })] }), _jsxs(YStack, { gap: "$1", width: 140, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('One run, USD') }), _jsx(Input, { value: task, onChangeText: setTask, placeholder: "1", "aria-label": t('Budget for one run'), inputMode: "decimal" })] }), _jsx(Choice, { label: t('Period'), value: period, options: PERIODS.map((p) => ({ id: p, label: t(PERIOD[p]) })), onChange: (p) => setPeriod(p) })] })] }), _jsx(Line, { children: note }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(XStack, { flex: 1 }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", variant: "primary", disabled: working || (autonomous && !schedule.trim()), onPress: () => void save(), children: autonomous ? t('Elect and run 24/7') : t('Create') })] })] }));
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Clone yourself, or anyone named: a name, who they are, and writing of theirs,
|
|
361
|
+
* pasted or uploaded. Yourself also takes the Big Five questionnaire, kept in
|
|
362
|
+
* this browser as it is answered; its result seeds the instructions, which are
|
|
363
|
+
* shown to edit before the agent is made.
|
|
364
|
+
*/
|
|
365
|
+
function Person({ self, onClose, onMade }) {
|
|
366
|
+
const { t } = useI18n();
|
|
367
|
+
const host = useHost();
|
|
368
|
+
const target = useTarget();
|
|
369
|
+
const me = self ? host.person : null;
|
|
370
|
+
const who = me?.email || me?.name || '';
|
|
371
|
+
const [name, setName] = useState(me?.name ?? '');
|
|
372
|
+
const [about, setAbout] = useState('');
|
|
373
|
+
const [writing, setWriting] = useState('');
|
|
374
|
+
const [answers, setAnswers] = useState(() => kept(who));
|
|
375
|
+
const [taking, setTaking] = useState(false);
|
|
376
|
+
const [edited, setEdited] = useState(null);
|
|
377
|
+
const [working, setWorking] = useState(false);
|
|
378
|
+
const [note, setNote] = useState('');
|
|
379
|
+
const file = useRef(null);
|
|
380
|
+
const sheet = answers[answers.form];
|
|
381
|
+
const answered = sheet.filter(Boolean).length;
|
|
382
|
+
const result = self && answered === sheet.length ? score(answers.form, sheet) : null;
|
|
383
|
+
const cast = person(name, about, writing, me?.avatar, result ? nature(name.trim(), answers.form, result) : '');
|
|
384
|
+
const instructions = edited ?? cast.instructions;
|
|
385
|
+
const answer = (a) => {
|
|
386
|
+
setAnswers(a);
|
|
387
|
+
keep(who, a);
|
|
388
|
+
};
|
|
389
|
+
const read = async (files) => {
|
|
390
|
+
const texts = await Promise.all([...(files ?? [])].map((f) => f.text()));
|
|
391
|
+
setWriting((w) => [w.trim(), ...texts.map((x) => x.trim())].filter(Boolean).join('\n\n'));
|
|
392
|
+
};
|
|
393
|
+
const save = async () => {
|
|
394
|
+
setWorking(true);
|
|
395
|
+
setNote('');
|
|
396
|
+
try {
|
|
397
|
+
onMade(await use(target, { ...cast, instructions }, window.location.href));
|
|
398
|
+
}
|
|
399
|
+
catch (e) {
|
|
400
|
+
setNote(say(e, t));
|
|
401
|
+
setWorking(false);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
return (_jsx(Sheet, { title: self ? t('Clone yourself') : t('Create from a person'), open: true, onOpenChange: (o) => !o && onClose(), full: true, children: taking ? (_jsx(Inventory, { answers: answers, onChange: answer, onDone: () => setTaking(false) })) : (_jsxs(_Fragment, { children: [_jsx(Field, { label: t('Name'), children: _jsx(Input, { value: name, onChangeText: setName, "aria-label": t('Name') }) }), _jsx(Field, { label: t('Description'), children: _jsx(Textarea, { value: about, onChangeText: setAbout, "aria-label": t('Description'), rows: 3 }) }), self ? (_jsx(Field, { label: t('Personality'), children: _jsxs(YStack, { gap: "$3", children: [_jsx(Choice, { label: t('Questionnaire'), value: answers.form, options: [
|
|
405
|
+
{ id: 'short', label: t('50 statements') },
|
|
406
|
+
{ id: 'long', label: t('120 statements') },
|
|
407
|
+
], onChange: (form) => answer({ ...answers, form }) }), result ? _jsx(Traits, { form: answers.form, score: result }) : null, _jsx(XStack, { children: _jsx(Button, { size: "sm", variant: result ? 'ghost' : 'outline', onPress: () => setTaking(true), children: result ? t('Change answers') : answered ? t('Resume, {n} of {total}', { n: answered, total: sheet.length }) : t('Start') }) })] }) })) : null, _jsx(Field, { label: t('Writing'), children: _jsx(Textarea, { value: writing, onChangeText: setWriting, "aria-label": t('Writing'), rows: 6 }) }), _jsxs(XStack, { children: [_jsxs(Button, { size: "sm", variant: "ghost", onPress: () => file.current?.click(), children: [_jsx(Upload, { size: 14 }), " ", t('Upload')] }), _jsx("input", { ref: file, type: "file", multiple: true, accept: ".txt,.md,.markdown,.csv,.json,.html,text/*", hidden: true, "aria-label": t('Upload writing'), onChange: (e) => {
|
|
408
|
+
void read(e.currentTarget.files);
|
|
409
|
+
e.currentTarget.value = '';
|
|
410
|
+
} })] }), _jsx(Field, { label: t('Instructions'), children: _jsx(Textarea, { value: instructions, onChangeText: setEdited, "aria-label": t('Instructions'), rows: 8 }) }), _jsx(Line, { children: note }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsx(XStack, { flex: 1 }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working || !name.trim(), onPress: () => void save(), children: t('Create') })] })] })) }));
|
|
411
|
+
}
|
|
412
|
+
function reach(a, t) {
|
|
413
|
+
if (a.tools.includes(ALL))
|
|
414
|
+
return t('every tool');
|
|
415
|
+
return a.tools.length === 1 ? t('1 tool') : t('{n} tools', { n: a.tools.length });
|
|
416
|
+
}
|
|
417
|
+
/** An agent's face: its picture, the default agent's of its name, its emoji, or its initial. */
|
|
418
|
+
function Face({ agent: a, cast, size = 32 }) {
|
|
419
|
+
const avatar = a.avatar || cast.find((c) => c.name.toLowerCase() === a.name.toLowerCase())?.avatar;
|
|
420
|
+
return _jsx(Mark, { name: a.name, size: size, logo: avatar, icon: a.emoji ? _jsx(SizableText, { size: size > 40 ? '$8' : '$4', children: a.emoji }) : undefined });
|
|
421
|
+
}
|
|
422
|
+
/** One agent's page: who it is, what it runs on and reads, what it may call and spend, and what it has done. */
|
|
423
|
+
export function Profile({ name }) {
|
|
424
|
+
const { t } = useI18n();
|
|
425
|
+
const host = useHost();
|
|
426
|
+
const target = useTarget();
|
|
427
|
+
const got = useLoad(host.person ? () => profile(target, name) : null, null, [target, name]);
|
|
428
|
+
const [editing, setEditing] = useState(false);
|
|
429
|
+
const a = got.value?.agent;
|
|
430
|
+
const isBot = a?.executionMode === 'long-running';
|
|
431
|
+
const back = () => host.go(path({ kind: 'customize', tab: isBot ? 'bots' : 'agents' }));
|
|
432
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, overflow: "scroll", px: "$6", py: "$6", "$max-md": { px: '$4', py: '$4' }, children: [_jsxs(YStack, { width: "100%", maxW: 880, mx: "auto", gap: "$5", children: [_jsxs(XStack, { render: "button", onPress: back, items: "center", gap: "$1.5", self: "flex-start", cursor: "pointer", "aria-label": t(isBot ? 'Back to bots' : 'Back to agents'), children: [_jsx(ArrowLeft, { size: 14, color: "$soft", 'data-i18n-mirror': '' }), _jsx(SizableText, { size: "$2", color: "$soft", children: t(isBot ? 'Bots' : 'Agents') })] }), !host.person ? (_jsx(Visitor, { children: t('Sign in to see this agent.') })) : got.error && !a ? (_jsx(Failed, { error: got.error, onRetry: got.reload })) : !a ? (_jsx(Soft, { children: t('Loading the agent…') })) : (_jsxs(_Fragment, { children: [_jsxs(XStack, { items: "center", gap: "$4", children: [_jsx(Face, { agent: a, cast: host.cast ?? [], size: 64 }), _jsxs(YStack, { flex: 1, minW: 0, gap: "$1", children: [_jsx(SizableText, { render: "h1", size: "$7", color: "$ink", numberOfLines: 1, children: a.name }), _jsx(SizableText, { size: "$3", color: "$soft", children: a.description || t('No role written yet.') })] }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => setEditing(true), children: t('Edit') })] }), _jsx(Part, { title: t('Model'), detail: a.model || t('The deployment’s default') }), _jsx(Part, { title: t('Autonomous and event-driven'), detail: a.executionMode === 'long-running'
|
|
433
|
+
? [t('Runs autonomously 24/7'), a.schedule ? `${t('Schedule')}: ${a.schedule}` : '', a.triggers?.length ? `${t('Triggers')}: ${a.triggers.join(', ')}` : '']
|
|
434
|
+
.filter(Boolean)
|
|
435
|
+
.join(' · ')
|
|
436
|
+
: t('One-shot (on-demand). Edit to enable 24/7 proactive and event-driven execution.') }), _jsx(Part, { title: t('Instructions'), detail: a.instructions ? '' : t('None written: it runs on its model alone.'), children: a.instructions ? (_jsx(YStack, { p: "$3", rounded: "$3", borderWidth: 1, borderColor: "$borderColor", bg: "$panel", maxH: 320, overflow: "scroll", children: _jsx(SizableText, { size: "$2", color: "$ink", "$platform-web": { whiteSpace: 'pre-wrap' }, children: a.instructions }) })) : null }), _jsx(Part, { title: t('Tools'), detail: a.tools.includes(ALL) ? t('Every tool the fleet’s MCP server serves.') : a.tools.length ? a.tools.join(', ') : t('None: it calls no tool.') }), _jsx(Part, { title: t('Budget'), detail: a.cap ? t(BUDGET[a.period], { spent: money(a.spent), cap: money(a.cap), task: money(a.task) }) : t('No budget set.') }), _jsx(Part, { title: t('Runs'), detail: a.runs ? t('{runs} in all; the latest {n} below.', { runs: a.runs, n: Math.min(a.runs, got.value.runs.length) }) : t('It has not run yet.'), children: got.value.runs.map((r) => (_jsxs(XStack, { gap: "$3", py: "$2", borderTopWidth: 1, borderColor: "$borderColor", items: "flex-start", children: [_jsx(SizableText, { size: "$1", color: r.status === 'ok' ? '$soft' : '$bad', width: 44, shrink: 0, children: r.status === 'ok' ? t('ok') : t('failed') }), _jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, children: r.input || t('(no input)') }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 2, children: r.status === 'ok' ? r.output : r.error })] }), _jsx(SizableText, { size: "$1", color: "$soft", shrink: 0, children: [r.model, r.at ? new Date(r.at).toLocaleString() : ''].filter(Boolean).join(' · ') })] }, r.id))) })] }))] }), editing && a ? (_jsx(Editor, { agent: a, onClose: () => setEditing(false), onSaved: () => {
|
|
437
|
+
setEditing(false);
|
|
438
|
+
got.reload();
|
|
439
|
+
}, onDeleted: back })) : null] }));
|
|
440
|
+
}
|
|
441
|
+
/** Write a new agent, or change one; an existing agent is read whole first, for its instructions. */
|
|
442
|
+
function Editor({ agent, defaultBot = false, onClose, onSaved, onDeleted, }) {
|
|
443
|
+
const { t } = useI18n();
|
|
444
|
+
const host = useHost();
|
|
445
|
+
const target = useTarget();
|
|
446
|
+
const full = useLoad(agent ? () => one(target, agent.id || agent.name) : null, null, [target, agent?.id]);
|
|
447
|
+
const catalog = useLoad(() => models(target), [], [target]);
|
|
448
|
+
const funds = useFunds(target, host.topUp);
|
|
449
|
+
const on = useLoad(() => tools(target, { activated: true }), [], [target]);
|
|
450
|
+
const [d, setD] = useState(() => defaultBot
|
|
451
|
+
? { ...EMPTY, executionMode: 'long-running', schedule: '*/15 * * * *', triggers: ['webhook', 'git', 'channel', 'watch'] }
|
|
452
|
+
: EMPTY);
|
|
453
|
+
const [ready, setReady] = useState(!agent);
|
|
454
|
+
const [working, setWorking] = useState(false);
|
|
455
|
+
const [note, setNote] = useState('');
|
|
456
|
+
const [asking, setAsking] = useState(false);
|
|
457
|
+
const [find, setFind] = useState('');
|
|
458
|
+
const spend = useSpend();
|
|
459
|
+
useEffect(() => {
|
|
460
|
+
if (full.value) {
|
|
461
|
+
setD(draft(full.value));
|
|
462
|
+
setReady(true);
|
|
463
|
+
}
|
|
464
|
+
}, [full.value]);
|
|
465
|
+
const set = (p) => setD((x) => ({ ...x, ...p }));
|
|
466
|
+
const every = d.tools.includes(ALL);
|
|
467
|
+
// The tools that are on, and any the agent already names that are not.
|
|
468
|
+
const choices = useMemo(() => {
|
|
469
|
+
const listed = on.value.map((x) => ({ name: x.name, source: x.source, description: x.description }));
|
|
470
|
+
const seen = new Set(listed.map((x) => x.name));
|
|
471
|
+
const kept = d.tools.filter((n) => n !== ALL && !seen.has(n)).map((name) => ({ name, source: t('not on'), description: '' }));
|
|
472
|
+
return [...kept, ...listed];
|
|
473
|
+
}, [on.value, d.tools, t]);
|
|
474
|
+
const shownTools = choices.filter((x) => matches(find, x.name, x.source, x.description));
|
|
475
|
+
const save = async () => {
|
|
476
|
+
const was = full.value;
|
|
477
|
+
// Made, or turned, 24/7: it starts spending by itself, so it is asked first.
|
|
478
|
+
const around = d.executionMode === 'long-running' && was?.executionMode !== 'long-running';
|
|
479
|
+
if (around && !(await spend.ask(bot(d.name.trim() || t('This bot'), d.cap, d.period, t))))
|
|
480
|
+
return;
|
|
481
|
+
setWorking(true);
|
|
482
|
+
setNote('');
|
|
483
|
+
try {
|
|
484
|
+
const saved = agent && was ? await update(target, was, d) : await create(target, d);
|
|
485
|
+
onSaved(saved);
|
|
486
|
+
}
|
|
487
|
+
catch (e) {
|
|
488
|
+
setNote(say(e, t));
|
|
489
|
+
}
|
|
490
|
+
finally {
|
|
491
|
+
setWorking(false);
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
const pick = (name, yes) => set({ tools: yes ? [...d.tools, name] : d.tools.filter((n) => n !== name) });
|
|
495
|
+
return (_jsxs(Sheet, { title: agent ? agent.name : t(defaultBot ? 'New bot' : 'New agent'), open: true, onOpenChange: (o) => !o && onClose(), width: 680, children: [spend.dialog, agent && full.error && !full.value ? (_jsx(Failed, { error: full.error, onRetry: full.reload })) : !ready ? (_jsx(Soft, { children: t('Loading the agent…') })) : (_jsxs(_Fragment, { children: [_jsx(Field, { label: t('Name'), hint: agent ? t('An agent keeps its name.') : t('Letters, digits, . _ or -. Other agents call it as agent_<name>.'), children: _jsx(Input, { value: d.name, onChangeText: (v) => set({ name: v }), "aria-label": t('Name'), disabled: Boolean(agent), autoCapitalize: "none" }) }), _jsx(Field, { label: t('Description'), hint: t('The line another agent reads to decide whether to call this one.'), children: _jsx(Input, { value: d.description, onChangeText: (v) => set({ description: v }), placeholder: t('Answers questions about our codebase'), "aria-label": t('Description') }) }), _jsx(Field, { label: t('Model'), children: _jsxs(XStack, { items: "center", gap: "$2", flexWrap: "wrap", children: [_jsx(ModelPicker, { size: "sm", name: t('Model'), placeholder: t('The deployment’s default'), models: catalog.value, scope: "agent", funded: funds.funded, balance: funds.balance, onTopUp: funds.topUp, value: d.model || undefined, onChange: (id) => set({ model: id }), loading: catalog.loading, error: catalog.error ? say(catalog.error, t) : null }), d.model && !agent ? (_jsx(Button, { size: "sm", variant: "ghost", onPress: () => set({ model: '' }), children: t('Use the default') })) : null] }) }), _jsx(Field, { label: t('Instructions'), hint: t('The system prompt: what the model reads before every run.'), children: _jsx(Textarea, { value: d.instructions, onChangeText: (v) => set({ instructions: v }), placeholder: t('Be terse, and cite the file you read.'), "aria-label": t('Instructions'), rows: 8 }) }), _jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Tools') }), _jsx(SizableText, { size: "$1", color: "$soft", children: every
|
|
496
|
+
? t('Every tool the fleet’s MCP server serves when it runs.')
|
|
497
|
+
: d.tools.length
|
|
498
|
+
? t('{n} chosen. It can call only these.', { n: d.tools.length })
|
|
499
|
+
: t('None chosen: it can call no tool.') })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Every tool') }), _jsx(Switch, { checked: every, onCheckedChange: (v) => set({ tools: v ? [ALL] : [] }), "aria-label": t('Every tool') })] }), every ? null : (_jsxs(_Fragment, { children: [_jsx(Input, { value: find, onChangeText: setFind, placeholder: t('Find a tool…'), "aria-label": t('Find a tool') }), _jsx(YStack, { borderWidth: 1, borderColor: "$borderColor", rounded: "$3", maxH: 240, overflow: "scroll", children: on.loading && !on.value.length ? (_jsx(Soft, { children: t('Loading the tools that are on…') })) : on.error && !on.value.length ? (_jsx(Failed, { error: on.error, onRetry: on.reload })) : !shownTools.length ? (_jsx(Soft, { children: choices.length ? t('No tool matches.') : t('No tool is on for your organization yet. Add skills or connectors first.') })) : (shownTools.map((x, i) => (_jsxs(XStack, { items: "center", gap: "$3", px: "$3", py: "$2", borderTopWidth: i ? 1 : 0, borderColor: "$borderColor", children: [_jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", fontFamily: "$mono", numberOfLines: 1, children: x.name }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, children: [x.source, x.description].filter(Boolean).join(' · ') })] }), _jsx(Switch, { checked: d.tools.includes(x.name), onCheckedChange: (v) => pick(x.name, v), "aria-label": t('Use {name}', { name: x.name }) })] }, x.name)))) })] }))] }), _jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsxs(YStack, { flex: 1, minW: 0, children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Autonomous and event-driven (24/7)') }), _jsx(SizableText, { size: "$1", color: "$soft", children: d.executionMode === 'long-running'
|
|
500
|
+
? t('Runs autonomously 24/7 on its proactive schedule and event triggers.')
|
|
501
|
+
: t('One-shot (on-demand). Turn on to run autonomously 24/7.') })] }), _jsx(Switch, { checked: d.executionMode === 'long-running', onCheckedChange: (v) => set(v
|
|
502
|
+
? { executionMode: 'long-running', schedule: d.schedule || '*/15 * * * *', triggers: d.triggers?.length ? d.triggers : ['webhook', 'git', 'channel', 'watch'] }
|
|
503
|
+
: { executionMode: undefined, schedule: undefined, triggers: undefined }), "aria-label": t('Run autonomously 24/7') })] }), d.executionMode === 'long-running' ? (_jsxs(YStack, { gap: "$2", p: "$3", borderWidth: 1, borderColor: "$borderColor", rounded: "$3", children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('Proactive schedule (5-field cron)') }), _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: SCHEDULES.map((s) => {
|
|
504
|
+
const active = (d.schedule ?? '').trim() === s.cron;
|
|
505
|
+
return (_jsx(Button, { size: "sm", variant: "outline", "aria-pressed": active, onPress: () => set({ schedule: s.cron }), children: t(s.label) }, s.cron));
|
|
506
|
+
}) }), _jsx(Input, { value: d.schedule ?? '', onChangeText: (v) => set({ schedule: v }), placeholder: "*/15 * * * *", "aria-label": t('Proactive schedule') }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Event-driven triggers') }), _jsx(XStack, { gap: "$1.5", flexWrap: "wrap", children: TRIGGERS.map((tr) => {
|
|
507
|
+
const active = (d.triggers ?? []).includes(tr);
|
|
508
|
+
return (_jsx(Button, { size: "sm", variant: "outline", "aria-pressed": active, onPress: () => set({ triggers: active ? (d.triggers ?? []).filter((x) => x !== tr) : [...(d.triggers ?? []), tr] }), children: t(TRIGGER_LABELS[tr].title) }, tr));
|
|
509
|
+
}) })] })) : null] }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$ink", children: t('Budget') }), _jsxs(XStack, { gap: "$3", flexWrap: "wrap", rowGap: "$2", items: "flex-end", children: [_jsxs(YStack, { gap: "$1", width: 140, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t(EACH[d.period]) }), _jsx(Input, { value: d.cap, onChangeText: (v) => set({ cap: v }), placeholder: "10", "aria-label": t('Budget each period'), inputMode: "decimal" })] }), _jsxs(YStack, { gap: "$1", width: 140, children: [_jsx(SizableText, { size: "$1", color: "$soft", children: t('One run, USD') }), _jsx(Input, { value: d.task, onChangeText: (v) => set({ task: v }), placeholder: "1", "aria-label": t('Budget for one run'), inputMode: "decimal" })] }), _jsx(Choice, { label: t('Period'), value: d.period, options: PERIODS.map((p) => ({ id: p, label: t(PERIOD[p]) })), onChange: (p) => set({ period: p }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: [full.value && full.value.cap ? t(SO_FAR[full.value.period], { spent: money(full.value.spent) }) : '', t('A run stops at either limit.')].filter(Boolean).join(' ') })] }), _jsx(Line, { children: note }), _jsxs(XStack, { gap: "$2", items: "center", children: [agent && onDeleted ? (_jsx(Button, { size: "sm", variant: "ghost", onPress: () => setAsking(true), children: t('Delete') })) : null, _jsx(XStack, { flex: 1 }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onClose, children: t('Cancel') }), _jsx(Button, { size: "sm", disabled: working, onPress: () => void save(), children: agent ? t('Save') : t('Create') })] }), agent && onDeleted ? (_jsx(Confirm, { title: t('Delete {name}?', { name: agent.name }), act: t('Delete'), says: t('The agent and every run recorded against it are removed.'), open: asking, onOpenChange: setAsking, run: async () => {
|
|
510
|
+
await remove(target, agent.id || agent.name);
|
|
511
|
+
onDeleted();
|
|
512
|
+
} })) : null] }))] }));
|
|
513
|
+
}
|