hostlet 0.0.0-stage → 0.1.0-alpha.2
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/README.md +233 -2
- package/bin/hostlet.js +61 -0
- package/console/app/api.js +1223 -0
- package/console/app/boot.js +165 -0
- package/console/app/cards.js +222 -0
- package/console/app/compose-quote.js +127 -0
- package/console/app/config-form.js +727 -0
- package/console/app/document-drafts.js +62 -0
- package/console/app/document-tools.mjs +67 -0
- package/console/app/documents.js +106 -0
- package/console/app/pages.js +6483 -0
- package/console/app/plugins.js +509 -0
- package/console/app/preview-tools.js +172 -0
- package/console/app/reference-labels.js +118 -0
- package/console/app/selection.js +372 -0
- package/console/app/store.js +57 -0
- package/console/app/text-anchor.js +26 -0
- package/console/app/topic-local.js +322 -0
- package/console/app/topic-nav.js +414 -0
- package/console/app/topic-status.js +109 -0
- package/console/app/views.js +43 -0
- package/console/apple-touch-icon.png +0 -0
- package/console/avatars/agy.svg +34 -0
- package/console/avatars/alhena.svg +36 -0
- package/console/avatars/castor.svg +38 -0
- package/console/avatars/claude.svg +34 -0
- package/console/avatars/codex.svg +34 -0
- package/console/avatars/devin.svg +34 -0
- package/console/avatars/echo.svg +34 -0
- package/console/avatars/kimi.svg +33 -0
- package/console/avatars/opencode.svg +33 -0
- package/console/avatars/pinion.svg +34 -0
- package/console/avatars/sprocket.svg +34 -0
- package/console/avatars/vela.svg +44 -0
- package/console/avatars/wasat.svg +38 -0
- package/console/clients/agy.svg +1 -0
- package/console/clients/claude.svg +1 -0
- package/console/clients/codex.svg +1 -0
- package/console/clients/devin.svg +1 -0
- package/console/clients/kimi.svg +1 -0
- package/console/clients/opencode.svg +1 -0
- package/console/favicon.ico +0 -0
- package/console/favicon.svg +16 -0
- package/console/index.html +99 -0
- package/console/pdl/engine/README.md +13 -0
- package/console/pdl/engine/anchor.js +195 -0
- package/console/pdl/engine/core.js +1340 -0
- package/console/pdl/engine/frame.js +1252 -0
- package/console/pdl/engine/i18n.js +67 -0
- package/console/pdl/engine/pdl-check.js +102 -0
- package/console/pdl/engine/pdl-doc.js +353 -0
- package/console/pdl/engine/pdl-view.js +280 -0
- package/console/pdl/engine/pdl.js +1064 -0
- package/console/pdl/engine/platform.js +18 -0
- package/console/pdl/engine/proj.js +279 -0
- package/console/pdl/engine/theme.js +176 -0
- package/console/pdl/engine/tree.js +171 -0
- package/console/pdl/engine/units.js +546 -0
- package/console/pdl/library/README.md +28 -0
- package/console/pdl/library/blocks.js +1512 -0
- package/console/pdl/library/buttons.js +86 -0
- package/console/pdl/library/capsules.js +130 -0
- package/console/pdl/library/charts.js +287 -0
- package/console/pdl/library/code.js +98 -0
- package/console/pdl/library/css/base.css +12 -0
- package/console/pdl/library/css/blocks.css +98 -0
- package/console/pdl/library/css/capsules.css +42 -0
- package/console/pdl/library/css/catalog-page.css +24 -0
- package/console/pdl/library/css/chat.css +100 -0
- package/console/pdl/library/css/composer-top.css +145 -0
- package/console/pdl/library/css/controls.css +195 -0
- package/console/pdl/library/css/drag.css +29 -0
- package/console/pdl/library/css/edit-layout.css +93 -0
- package/console/pdl/library/css/floating-window.css +30 -0
- package/console/pdl/library/css/hover.css +50 -0
- package/console/pdl/library/css/label-search.css +37 -0
- package/console/pdl/library/css/layers.css +43 -0
- package/console/pdl/library/css/library-parts.css +33 -0
- package/console/pdl/library/css/library.css +117 -0
- package/console/pdl/library/css/member-select.css +34 -0
- package/console/pdl/library/css/message.css +72 -0
- package/console/pdl/library/css/page.css +104 -0
- package/console/pdl/library/css/parts.css +338 -0
- package/console/pdl/library/css/responsive.css +40 -0
- package/console/pdl/library/css/roles.css +28 -0
- package/console/pdl/library/css/rows.css +231 -0
- package/console/pdl/library/css/settings-rows.css +37 -0
- package/console/pdl/library/css/shell.css +59 -0
- package/console/pdl/library/css/stream.css +296 -0
- package/console/pdl/library/css/theme-calculator.css +18 -0
- package/console/pdl/library/css/thumb-choice.css +69 -0
- package/console/pdl/library/css/tweaks.css +16 -0
- package/console/pdl/library/css/widgets.css +211 -0
- package/console/pdl/library/css/workbench.css +59 -0
- package/console/pdl/library/feedback.js +83 -0
- package/console/pdl/library/floating-window.mjs +100 -0
- package/console/pdl/library/fold.js +238 -0
- package/console/pdl/library/format.js +53 -0
- package/console/pdl/library/frames.js +123 -0
- package/console/pdl/library/icons.js +165 -0
- package/console/pdl/library/identity.js +149 -0
- package/console/pdl/library/inputs.js +801 -0
- package/console/pdl/library/label-search.js +214 -0
- package/console/pdl/library/markdown-text.js +115 -0
- package/console/pdl/library/markdown.js +150 -0
- package/console/pdl/library/media-viewer.js +293 -0
- package/console/pdl/library/member-select.mjs +32 -0
- package/console/pdl/library/message.js +105 -0
- package/console/pdl/library/motion.js +56 -0
- package/console/pdl/library/overlays.js +165 -0
- package/console/pdl/library/page.js +142 -0
- package/console/pdl/library/plugin-form.js +154 -0
- package/console/pdl/library/registry.js +198 -0
- package/console/pdl/library/rows.js +523 -0
- package/console/pdl/library/shell.js +151 -0
- package/console/pdl/library/stream.js +58 -0
- package/console/pdl/library/tabs.js +259 -0
- package/console/pdl/library/theme-calculator.js +300 -0
- package/console/pdl/library/widgets.js +114 -0
- package/console/pdl/load-order.json +74 -0
- package/console/pdl/platform/README.md +3 -0
- package/console/pdl/platform/rich-markdown.mjs +17 -0
- package/console/pdl/platform/web-links.js +26 -0
- package/console/pdl/platform/web.js +80 -0
- package/console/sdk-browser/mentions.d.mts +16 -0
- package/console/sdk-browser/mentions.mjs +84 -0
- package/console/theme/assets.js +21 -0
- package/console/theme/theme.json +9417 -0
- package/console/theme/tokens.json +444 -0
- package/dist/core/a2a.d.ts +288 -0
- package/dist/core/a2a.js +2197 -0
- package/dist/core/address.d.ts +34 -0
- package/dist/core/address.js +33 -0
- package/dist/core/approval-inputs.d.ts +17 -0
- package/dist/core/approval-inputs.js +70 -0
- package/dist/core/archive.d.ts +19 -0
- package/dist/core/archive.js +135 -0
- package/dist/core/attachments.d.ts +17 -0
- package/dist/core/attachments.js +143 -0
- package/dist/core/blocked-handoffs.d.ts +132 -0
- package/dist/core/blocked-handoffs.js +349 -0
- package/dist/core/config-schema.d.ts +124 -0
- package/dist/core/config-schema.js +192 -0
- package/dist/core/config.d.ts +117 -0
- package/dist/core/config.js +638 -0
- package/dist/core/disk-usage.d.ts +26 -0
- package/dist/core/disk-usage.js +83 -0
- package/dist/core/documents.d.ts +9 -0
- package/dist/core/documents.js +48 -0
- package/dist/core/entry.d.ts +316 -0
- package/dist/core/entry.js +711 -0
- package/dist/core/home.d.ts +76 -0
- package/dist/core/home.js +449 -0
- package/dist/core/i18n.d.ts +36 -0
- package/dist/core/i18n.js +458 -0
- package/dist/core/instances.d.ts +224 -0
- package/dist/core/instances.js +1272 -0
- package/dist/core/members.d.ts +190 -0
- package/dist/core/members.js +358 -0
- package/dist/core/mentions.d.ts +12 -0
- package/dist/core/mentions.js +49 -0
- package/dist/core/messages.d.ts +876 -0
- package/dist/core/messages.js +916 -0
- package/dist/core/notices.d.ts +88 -0
- package/dist/core/notices.js +54 -0
- package/dist/core/ops.d.ts +117 -0
- package/dist/core/ops.js +146 -0
- package/dist/core/package.d.ts +2 -0
- package/dist/core/package.js +14 -0
- package/dist/core/parts.d.ts +25 -0
- package/dist/core/parts.js +119 -0
- package/dist/core/plugins/catalog.d.ts +14 -0
- package/dist/core/plugins/catalog.js +54 -0
- package/dist/core/plugins/external.d.ts +7 -0
- package/dist/core/plugins/external.js +921 -0
- package/dist/core/plugins/index.d.ts +5 -0
- package/dist/core/plugins/index.js +51 -0
- package/dist/core/plugins/npm.d.ts +12 -0
- package/dist/core/plugins/npm.js +99 -0
- package/dist/core/plugins/plugin-manifest.d.ts +12 -0
- package/dist/core/plugins/plugin-manifest.js +231 -0
- package/dist/core/push.d.ts +22 -0
- package/dist/core/push.js +63 -0
- package/dist/core/resource.d.ts +77 -0
- package/dist/core/resource.js +48 -0
- package/dist/core/spawn.d.ts +12 -0
- package/dist/core/spawn.js +30 -0
- package/dist/core/storage-inventory.d.ts +118 -0
- package/dist/core/storage-inventory.js +279 -0
- package/dist/core/storage.d.ts +45 -0
- package/dist/core/storage.js +602 -0
- package/dist/core/store.d.ts +15 -0
- package/dist/core/store.js +33 -0
- package/dist/core/topic-index.d.ts +19 -0
- package/dist/core/topic-index.js +70 -0
- package/dist/core/topic-ops.d.ts +139 -0
- package/dist/core/topic-ops.js +507 -0
- package/dist/core/topic-status.d.ts +32 -0
- package/dist/core/topic-status.js +105 -0
- package/dist/core/topics.d.ts +327 -0
- package/dist/core/topics.js +786 -0
- package/dist/core/turn-clients.d.ts +1 -0
- package/dist/core/turn-clients.js +5 -0
- package/dist/core/types.d.ts +2866 -0
- package/dist/core/types.js +166 -0
- package/dist/core/util.d.ts +10 -0
- package/dist/core/util.js +47 -0
- package/dist/main.d.ts +12 -0
- package/dist/main.js +82 -0
- package/dist/plugins/adapter-acp/index.d.ts +3 -0
- package/dist/plugins/adapter-acp/index.js +57 -0
- package/dist/plugins/adapter-acp/plugin.yaml +100 -0
- package/dist/plugins/adapter-agy/command.d.ts +9 -0
- package/dist/plugins/adapter-agy/command.js +34 -0
- package/dist/plugins/adapter-agy/index.d.ts +5 -0
- package/dist/plugins/adapter-agy/index.js +65 -0
- package/dist/plugins/adapter-agy/quota.d.ts +2 -0
- package/dist/plugins/adapter-agy/quota.js +155 -0
- package/dist/plugins/adapter-agy/terminal.d.ts +6 -0
- package/dist/plugins/adapter-agy/terminal.js +132 -0
- package/dist/plugins/adapter-agy/version.d.ts +9 -0
- package/dist/plugins/adapter-agy/version.js +17 -0
- package/dist/plugins/adapter-claude/index.d.ts +43 -0
- package/dist/plugins/adapter-claude/index.js +412 -0
- package/dist/plugins/adapter-claude/quota.d.ts +14 -0
- package/dist/plugins/adapter-claude/quota.js +103 -0
- package/dist/plugins/adapter-codex/index.d.ts +4 -0
- package/dist/plugins/adapter-codex/index.js +688 -0
- package/dist/plugins/adapter-codex/responses-model.d.ts +9 -0
- package/dist/plugins/adapter-codex/responses-model.js +82 -0
- package/dist/plugins/adapter-kimi/index.d.ts +4 -0
- package/dist/plugins/adapter-kimi/index.js +51 -0
- package/dist/plugins/adapter-kimi/quota.d.ts +3 -0
- package/dist/plugins/adapter-kimi/quota.js +171 -0
- package/dist/plugins/adapter-opencode/index.d.ts +12 -0
- package/dist/plugins/adapter-opencode/index.js +64 -0
- package/dist/plugins/annotations/console/cards.css +189 -0
- package/dist/plugins/annotations/console/cards.mjs +439 -0
- package/dist/plugins/annotations/console/pdl.json +52 -0
- package/dist/plugins/annotations/console/view.mjs +241 -0
- package/dist/plugins/annotations/console/window.mjs +219 -0
- package/dist/plugins/annotations/followups.d.ts +51 -0
- package/dist/plugins/annotations/followups.js +112 -0
- package/dist/plugins/annotations/index.d.ts +3 -0
- package/dist/plugins/annotations/index.js +298 -0
- package/dist/plugins/annotations/plugin.yaml +3 -0
- package/dist/plugins/ask-choice/index.d.ts +9 -0
- package/dist/plugins/ask-choice/index.js +24 -0
- package/dist/plugins/ask-choice/plugin.yaml +2 -0
- package/dist/plugins/background/index.d.ts +2 -0
- package/dist/plugins/background/index.js +398 -0
- package/dist/plugins/background/plugin.yaml +7 -0
- package/dist/plugins/builtin.json +37 -0
- package/dist/plugins/cards/console/pdl.json +516 -0
- package/dist/plugins/cards/console/view.mjs +67 -0
- package/dist/plugins/cards/index.d.ts +8 -0
- package/dist/plugins/cards/index.js +627 -0
- package/dist/plugins/cards/plugin.yaml +3 -0
- package/dist/plugins/console/browser.d.ts +2 -0
- package/dist/plugins/console/browser.js +115 -0
- package/dist/plugins/console/console/pdl.json +38 -0
- package/dist/plugins/console/console/view.mjs +26 -0
- package/dist/plugins/console/index.d.ts +4 -0
- package/dist/plugins/console/index.js +94 -0
- package/dist/plugins/console/picker.d.ts +2 -0
- package/dist/plugins/console/picker.js +48 -0
- package/dist/plugins/console/plugin.yaml +3 -0
- package/dist/plugins/console/topic-view.d.ts +3 -0
- package/dist/plugins/console/topic-view.js +388 -0
- package/dist/plugins/handoff/index.d.ts +2 -0
- package/dist/plugins/handoff/index.js +147 -0
- package/dist/plugins/handoff/plugin.yaml +8 -0
- package/dist/plugins/host-api/index.d.ts +7 -0
- package/dist/plugins/host-api/index.js +310 -0
- package/dist/plugins/host-api/plugin.yaml +2 -0
- package/dist/plugins/host-api/signing.d.ts +63 -0
- package/dist/plugins/host-api/signing.js +427 -0
- package/dist/plugins/host-api/skills/host-ops/SKILL.md +28 -0
- package/dist/plugins/host-api/skills/hostlet-plugin-dev/SKILL.md +38 -0
- package/dist/plugins/inbox/index.d.ts +15 -0
- package/dist/plugins/inbox/index.js +161 -0
- package/dist/plugins/inbox/plugin.yaml +2 -0
- package/dist/plugins/keys/account-directories.d.ts +18 -0
- package/dist/plugins/keys/account-directories.js +86 -0
- package/dist/plugins/keys/account-storage.d.ts +18 -0
- package/dist/plugins/keys/account-storage.js +112 -0
- package/dist/plugins/keys/console/pdl.json +710 -0
- package/dist/plugins/keys/console/view.mjs +619 -0
- package/dist/plugins/keys/index.d.ts +7 -0
- package/dist/plugins/keys/index.js +842 -0
- package/dist/plugins/keys/login-link.d.ts +2 -0
- package/dist/plugins/keys/login-link.js +15 -0
- package/dist/plugins/keys/plugin.yaml +3 -0
- package/dist/plugins/keys/quota-history.d.ts +91 -0
- package/dist/plugins/keys/quota-history.js +420 -0
- package/dist/plugins/mcp/console/pdl.json +412 -0
- package/dist/plugins/mcp/console/view.mjs +207 -0
- package/dist/plugins/mcp/index.d.ts +7 -0
- package/dist/plugins/mcp/index.js +494 -0
- package/dist/plugins/mcp/plugin.yaml +3 -0
- package/dist/plugins/member-health/index.d.ts +2 -0
- package/dist/plugins/member-health/index.js +478 -0
- package/dist/plugins/member-health/plugin.yaml +2 -0
- package/dist/plugins/memory/capabilities.d.ts +10 -0
- package/dist/plugins/memory/capabilities.js +70 -0
- package/dist/plugins/memory/console/pdl.json +459 -0
- package/dist/plugins/memory/console/view.mjs +254 -0
- package/dist/plugins/memory/corpus.d.ts +60 -0
- package/dist/plugins/memory/corpus.js +521 -0
- package/dist/plugins/memory/engines/fts-tree-diversity.d.ts +8 -0
- package/dist/plugins/memory/engines/fts-tree-diversity.js +49 -0
- package/dist/plugins/memory/engines/fts-tree-text.d.ts +12 -0
- package/dist/plugins/memory/engines/fts-tree-text.js +93 -0
- package/dist/plugins/memory/engines/fts-tree.d.ts +4 -0
- package/dist/plugins/memory/engines/fts-tree.js +387 -0
- package/dist/plugins/memory/engines/search.d.ts +9 -0
- package/dist/plugins/memory/engines/search.js +35 -0
- package/dist/plugins/memory/index.d.ts +3 -0
- package/dist/plugins/memory/index.js +465 -0
- package/dist/plugins/memory/notes.d.ts +22 -0
- package/dist/plugins/memory/notes.js +140 -0
- package/dist/plugins/memory/plugin.yaml +23 -0
- package/dist/plugins/model-profiles/index.d.ts +2 -0
- package/dist/plugins/model-profiles/index.js +919 -0
- package/dist/plugins/model-profiles/plugin.yaml +13 -0
- package/dist/plugins/model-profiles/review-source.d.ts +11 -0
- package/dist/plugins/model-profiles/review-source.js +640 -0
- package/dist/plugins/model-profiles/rules.d.ts +132 -0
- package/dist/plugins/model-profiles/rules.js +767 -0
- package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +60 -0
- package/dist/plugins/model-profiles/sources.d.ts +61 -0
- package/dist/plugins/model-profiles/sources.js +375 -0
- package/dist/plugins/model-profiles/storage.d.ts +104 -0
- package/dist/plugins/model-profiles/storage.js +352 -0
- package/dist/plugins/model-profiles/types.d.ts +187 -0
- package/dist/plugins/model-profiles/types.js +12 -0
- package/dist/plugins/model-profiles/wakeup.d.ts +29 -0
- package/dist/plugins/model-profiles/wakeup.js +390 -0
- package/dist/plugins/models/index.d.ts +2 -0
- package/dist/plugins/models/index.js +63 -0
- package/dist/plugins/models/plugin.yaml +8 -0
- package/dist/plugins/ops/collector.d.ts +22 -0
- package/dist/plugins/ops/collector.js +48 -0
- package/dist/plugins/ops/config.d.ts +11 -0
- package/dist/plugins/ops/config.js +13 -0
- package/dist/plugins/ops/console/pdl.json +676 -0
- package/dist/plugins/ops/console/view.mjs +700 -0
- package/dist/plugins/ops/index.d.ts +3 -0
- package/dist/plugins/ops/index.js +20 -0
- package/dist/plugins/ops/journal.d.ts +7 -0
- package/dist/plugins/ops/journal.js +109 -0
- package/dist/plugins/ops/metrics.d.ts +3 -0
- package/dist/plugins/ops/metrics.js +81 -0
- package/dist/plugins/ops/plugin.yaml +63 -0
- package/dist/plugins/ops/samples.d.ts +54 -0
- package/dist/plugins/ops/samples.js +100 -0
- package/dist/plugins/ops/trace.d.ts +3 -0
- package/dist/plugins/ops/trace.js +104 -0
- package/dist/plugins/ops/usage.d.ts +2 -0
- package/dist/plugins/ops/usage.js +152 -0
- package/dist/plugins/plans/acceptance.d.ts +284 -0
- package/dist/plugins/plans/acceptance.js +247 -0
- package/dist/plugins/plans/blocked.d.ts +25 -0
- package/dist/plugins/plans/blocked.js +66 -0
- package/dist/plugins/plans/console/pdl.json +639 -0
- package/dist/plugins/plans/console/view.d.mts +2 -0
- package/dist/plugins/plans/console/view.mjs +855 -0
- package/dist/plugins/plans/dependencies.d.ts +5 -0
- package/dist/plugins/plans/dependencies.js +21 -0
- package/dist/plugins/plans/index.d.ts +72 -0
- package/dist/plugins/plans/index.js +2057 -0
- package/dist/plugins/plans/plugin.yaml +44 -0
- package/dist/plugins/plans/progress.d.ts +82 -0
- package/dist/plugins/plans/progress.js +516 -0
- package/dist/plugins/prompt/index.d.ts +8 -0
- package/dist/plugins/prompt/index.js +361 -0
- package/dist/plugins/prompt/plugin.yaml +2 -0
- package/dist/plugins/recovery/console/pdl.json +50 -0
- package/dist/plugins/recovery/console/view.mjs +46 -0
- package/dist/plugins/recovery/index.d.ts +9 -0
- package/dist/plugins/recovery/index.js +454 -0
- package/dist/plugins/recovery/plugin.yaml +9 -0
- package/dist/plugins/recovery/probe.d.ts +11 -0
- package/dist/plugins/recovery/probe.js +128 -0
- package/dist/plugins/restart/console/pdl.json +112 -0
- package/dist/plugins/restart/console/view.mjs +85 -0
- package/dist/plugins/restart/index.d.ts +10 -0
- package/dist/plugins/restart/index.js +669 -0
- package/dist/plugins/restart/plugin.yaml +9 -0
- package/dist/plugins/restart/scope.d.ts +6 -0
- package/dist/plugins/restart/scope.js +44 -0
- package/dist/plugins/schedule/console/pdl.json +696 -0
- package/dist/plugins/schedule/console/view.mjs +398 -0
- package/dist/plugins/schedule/events.d.ts +76 -0
- package/dist/plugins/schedule/events.js +158 -0
- package/dist/plugins/schedule/index.d.ts +32 -0
- package/dist/plugins/schedule/index.js +1199 -0
- package/dist/plugins/schedule/plugin.yaml +26 -0
- package/dist/plugins/schedule/when.d.ts +14 -0
- package/dist/plugins/schedule/when.js +83 -0
- package/dist/plugins/sessions/console/pdl.json +259 -0
- package/dist/plugins/sessions/console/view.mjs +355 -0
- package/dist/plugins/sessions/index.d.ts +3 -0
- package/dist/plugins/sessions/index.js +126 -0
- package/dist/plugins/sessions/participants.d.ts +28 -0
- package/dist/plugins/sessions/participants.js +83 -0
- package/dist/plugins/sessions/plugin.yaml +3 -0
- package/dist/plugins/signals/console/pdl.json +802 -0
- package/dist/plugins/signals/console/view.mjs +284 -0
- package/dist/plugins/signals/content.d.ts +31 -0
- package/dist/plugins/signals/content.js +151 -0
- package/dist/plugins/signals/index.d.ts +2 -0
- package/dist/plugins/signals/index.js +601 -0
- package/dist/plugins/signals/plugin.yaml +32 -0
- package/dist/plugins/signals/skills/signal-sources/SKILL.md +27 -0
- package/dist/plugins/skills/console/pdl.json +254 -0
- package/dist/plugins/skills/console/view.mjs +204 -0
- package/dist/plugins/skills/index.d.ts +11 -0
- package/dist/plugins/skills/index.js +567 -0
- package/dist/plugins/skills/install.d.ts +69 -0
- package/dist/plugins/skills/install.js +265 -0
- package/dist/plugins/skills/plugin.yaml +24 -0
- package/dist/plugins/skills/safety-scan.d.ts +17 -0
- package/dist/plugins/skills/safety-scan.js +78 -0
- package/dist/plugins/skills/skills/skill-ops/SKILL.md +29 -0
- package/dist/plugins/terminal/console/pdl.json +115 -0
- package/dist/plugins/terminal/console/view.mjs +178 -0
- package/dist/plugins/terminal/index.d.ts +3 -0
- package/dist/plugins/terminal/index.js +204 -0
- package/dist/plugins/terminal/plugin.yaml +2 -0
- package/dist/plugins/tools/index.d.ts +3 -0
- package/dist/plugins/tools/index.js +458 -0
- package/dist/plugins/tools/plugin.yaml +2 -0
- package/dist/plugins/tools/token.d.ts +61 -0
- package/dist/plugins/tools/token.js +179 -0
- package/dist/plugins/topic-tools/index.d.ts +9 -0
- package/dist/plugins/topic-tools/index.js +29 -0
- package/dist/plugins/topic-tools/plugin.yaml +2 -0
- package/dist/plugins/topic-tools/skills/topic-tidy/SKILL.md +108 -0
- package/dist/plugins/works/console/pdl.json +120 -0
- package/dist/plugins/works/console/view.mjs +91 -0
- package/dist/plugins/works/document-words.d.ts +50 -0
- package/dist/plugins/works/document-words.js +27 -0
- package/dist/plugins/works/editors.d.ts +3 -0
- package/dist/plugins/works/editors.js +162 -0
- package/dist/plugins/works/events.d.ts +58 -0
- package/dist/plugins/works/events.js +82 -0
- package/dist/plugins/works/files.d.ts +23 -0
- package/dist/plugins/works/files.js +53 -0
- package/dist/plugins/works/index.d.ts +9 -0
- package/dist/plugins/works/index.js +1088 -0
- package/dist/plugins/works/plugin.yaml +9 -0
- package/dist/plugins/works/preview.d.ts +10 -0
- package/dist/plugins/works/preview.js +30 -0
- package/dist/plugins/works/project.d.ts +3 -0
- package/dist/plugins/works/project.js +245 -0
- package/dist/plugins/works/resource.d.ts +28 -0
- package/dist/plugins/works/resource.js +71 -0
- package/dist/plugins/works/retention.d.ts +36 -0
- package/dist/plugins/works/retention.js +295 -0
- package/dist/plugins/works/skills/works-ops/SKILL.md +14 -0
- package/dist/plugins/works/viewers.d.ts +13 -0
- package/dist/plugins/works/viewers.js +87 -0
- package/dist/plugins/works/web/anchors.js +94 -0
- package/dist/plugins/works/web/document-edit.js +245 -0
- package/dist/plugins/works/web/preview-bridge.js +142 -0
- package/dist/plugins/works/web/reading-position.js +74 -0
- package/dist/plugins/works/web/view.html +1118 -0
- package/dist/runtime/runtime.d.ts +210 -0
- package/dist/runtime/runtime.js +338 -0
- package/dist/sdk/adapter-kit.d.ts +1 -0
- package/dist/sdk/adapter-kit.js +1 -0
- package/dist/sdk/client.d.ts +163 -0
- package/dist/sdk/client.js +43 -0
- package/dist/sdk/contracts.d.ts +1263 -0
- package/dist/sdk/contracts.js +1 -0
- package/dist/sdk/index.d.ts +57 -0
- package/dist/sdk/index.js +27 -0
- package/dist/sdk/source-choice.d.ts +40 -0
- package/dist/sdk/source-choice.js +217 -0
- package/dist/sdk/topic-text.d.ts +5 -0
- package/dist/sdk/topic-text.js +26 -0
- package/dist/sdk/transport.d.ts +12 -0
- package/dist/sdk/transport.js +34 -0
- package/node_modules/@hostlet/adapter-kit/dist/acp.d.ts +88 -0
- package/node_modules/@hostlet/adapter-kit/dist/acp.js +674 -0
- package/node_modules/@hostlet/adapter-kit/dist/command.d.ts +18 -0
- package/node_modules/@hostlet/adapter-kit/dist/command.js +39 -0
- package/node_modules/@hostlet/adapter-kit/dist/index.d.ts +8 -0
- package/node_modules/@hostlet/adapter-kit/dist/index.js +6 -0
- package/node_modules/@hostlet/adapter-kit/dist/models.d.ts +29 -0
- package/node_modules/@hostlet/adapter-kit/dist/models.js +108 -0
- package/node_modules/@hostlet/adapter-kit/dist/quota.d.ts +3 -0
- package/node_modules/@hostlet/adapter-kit/dist/quota.js +4 -0
- package/node_modules/@hostlet/adapter-kit/dist/rpc.d.ts +29 -0
- package/node_modules/@hostlet/adapter-kit/dist/rpc.js +84 -0
- package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.d.ts +5 -0
- package/node_modules/@hostlet/adapter-kit/dist/upstream-failure.js +37 -0
- package/node_modules/@hostlet/adapter-kit/package.json +16 -0
- package/node_modules/@hostlet/platform/dist/desktop.d.ts +16 -0
- package/node_modules/@hostlet/platform/dist/desktop.js +276 -0
- package/node_modules/@hostlet/platform/dist/files.d.ts +24 -0
- package/node_modules/@hostlet/platform/dist/files.js +113 -0
- package/node_modules/@hostlet/platform/dist/index.d.ts +6 -0
- package/node_modules/@hostlet/platform/dist/index.js +4 -0
- package/node_modules/@hostlet/platform/dist/paths.d.ts +4 -0
- package/node_modules/@hostlet/platform/dist/paths.js +9 -0
- package/node_modules/@hostlet/platform/dist/process.d.ts +45 -0
- package/node_modules/@hostlet/platform/dist/process.js +297 -0
- package/node_modules/@hostlet/platform/package.json +14 -0
- package/package.json +60 -4
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { array, object } from "./ops.js";
|
|
2
|
+
const stringValue = { type: 'string' };
|
|
3
|
+
const numberValue = { type: 'number' };
|
|
4
|
+
const booleanValue = { type: 'boolean' };
|
|
5
|
+
const nullableString = { type: ['string', 'null'] };
|
|
6
|
+
const nullableNumber = { type: ['number', 'null'] };
|
|
7
|
+
const strings = array(stringValue);
|
|
8
|
+
const record = { type: 'object' };
|
|
9
|
+
/** A channel identity. Only members backed by an adapter have an instance. */
|
|
10
|
+
export const memberSchema = object({
|
|
11
|
+
id: stringValue, kind: { type: 'string', enum: ['agent', 'person', 'plugin'] }, name: stringValue, handle: stringValue,
|
|
12
|
+
adapter: stringValue, options: record, key: stringValue,
|
|
13
|
+
env: { type: 'object', additionalProperties: stringValue },
|
|
14
|
+
color: { ...object({ primary: stringValue }, ['primary']), type: ['string', 'object'] },
|
|
15
|
+
avatarPath: stringValue, enabled: booleanValue,
|
|
16
|
+
}, ['id', 'kind', 'name', 'handle', 'adapter', 'options', 'enabled']);
|
|
17
|
+
/** A working directory, which its descendants can use too. */
|
|
18
|
+
export const dirRefSchema = object({ refId: stringValue, path: stringValue, note: stringValue }, ['refId', 'path']);
|
|
19
|
+
/** Another topic this topic uses. Only the link and a note are stored. */
|
|
20
|
+
const linkedTopicRefSchema = object({ topicId: stringValue, note: stringValue }, ['topicId']);
|
|
21
|
+
export const topicRefSchema = {
|
|
22
|
+
...object({ ...dirRefSchema.properties, ...linkedTopicRefSchema.properties }),
|
|
23
|
+
oneOf: [{ required: dirRefSchema.required }, { required: linkedTopicRefSchema.required }],
|
|
24
|
+
};
|
|
25
|
+
export function isDirRef(ref) { return 'path' in ref; }
|
|
26
|
+
export function isTopicRef(ref) { return 'topicId' in ref; }
|
|
27
|
+
/** The main view and optional workbench that open with a topic. */
|
|
28
|
+
const topicViewSchema = object({
|
|
29
|
+
main: stringValue, panel: stringValue, tabs: strings, preset: stringValue,
|
|
30
|
+
args: { type: 'object', patternProperties: { '.*': { type: ['string', 'number', 'boolean'] } } },
|
|
31
|
+
}, ['main']);
|
|
32
|
+
/** One thing somebody wants done. A node of the tree with one channel and a folder of its own. */
|
|
33
|
+
export const topicSchema = object({
|
|
34
|
+
title: stringValue, parentId: nullableString, tags: strings, refs: array(topicRefSchema), pinned: booleanValue,
|
|
35
|
+
caps: { type: 'object', patternProperties: { '.*': booleanValue } },
|
|
36
|
+
view: { ...topicViewSchema, type: ['object', 'null'] },
|
|
37
|
+
/** The plugin that maintains this topic. Written only by the host, not by topic edits. */
|
|
38
|
+
plugin: stringValue,
|
|
39
|
+
/** Marks the host-maintained system container topic. Written only by the host, not by topic edits. */
|
|
40
|
+
system: { type: 'boolean', const: true },
|
|
41
|
+
/** A topic may limit which members are woken. An empty or absent list allows anyone. */
|
|
42
|
+
members: strings,
|
|
43
|
+
/** Who a message that names nobody is for when nobody has been talked to here yet. */
|
|
44
|
+
defaultMember: stringValue,
|
|
45
|
+
archivedAt: nullableNumber, deletedAt: nullableNumber,
|
|
46
|
+
/** Its folder stays the same when the topic moves in the tree. */
|
|
47
|
+
id: stringValue, dir: stringValue, createdAt: numberValue, lastActiveAt: numberValue,
|
|
48
|
+
}, ['id', 'title', 'parentId', 'tags', 'refs', 'pinned', 'caps', 'dir', 'createdAt', 'lastActiveAt', 'archivedAt', 'deletedAt']);
|
|
49
|
+
/** Who said something: a member, or the host itself. */
|
|
50
|
+
export const senderSchema = object({
|
|
51
|
+
kind: { type: 'string', enum: ['member', 'system'] }, id: stringValue,
|
|
52
|
+
}, ['kind', 'id']);
|
|
53
|
+
/** Whether something was done, and what is to be said about it. `unconfirmed`: it may or may not have been done. */
|
|
54
|
+
const cardResultSchema = object({ ok: booleanValue, text: stringValue, unconfirmed: booleanValue }, ['ok']);
|
|
55
|
+
/** An unfilled operation argument requested by a member, then described by the target declaration. */
|
|
56
|
+
const requestFields = {
|
|
57
|
+
path: { ...stringValue, description: '操作参数的 JSON Pointer,例如 /env 或 /updates/api.key' },
|
|
58
|
+
label: stringValue, description: stringValue, required: { type: 'boolean' },
|
|
59
|
+
};
|
|
60
|
+
export const fillRequestSchema = object(requestFields, ['path']);
|
|
61
|
+
const approvalInputSchema = object({
|
|
62
|
+
...requestFields, secret: { type: 'boolean' },
|
|
63
|
+
format: { type: 'string', enum: ['key-value-lines'] },
|
|
64
|
+
}, ['path', 'label', 'required', 'secret']);
|
|
65
|
+
/** One thing to approve, with optional facts and an exact payload to inspect. */
|
|
66
|
+
const cardItemSchema = object({
|
|
67
|
+
id: stringValue, title: stringValue, detail: stringValue, result: cardResultSchema, option: stringValue,
|
|
68
|
+
inputs: array(approvalInputSchema),
|
|
69
|
+
fields: array(object({ label: stringValue, value: stringValue, tone: { type: 'string', enum: ['warn'] } }, ['label', 'value'])),
|
|
70
|
+
code: object({ label: stringValue, text: stringValue }, ['label', 'text']),
|
|
71
|
+
}, ['id']);
|
|
72
|
+
/** A structured value a member gives with its vote, as the sender of the card declares it. */
|
|
73
|
+
export const signFieldSchema = object({
|
|
74
|
+
key: stringValue, label: stringValue, options: strings,
|
|
75
|
+
when: { type: 'string', enum: ['approve', 'reject', 'always'] }, required: booleanValue,
|
|
76
|
+
}, ['key', 'label', 'when']);
|
|
77
|
+
/** One member's vote on a card that members may sign, with the turn it was given in. */
|
|
78
|
+
const signatureSchema = object({
|
|
79
|
+
by: stringValue, at: numberValue, turnId: stringValue, approved: booleanValue, text: stringValue,
|
|
80
|
+
values: { type: 'object', additionalProperties: { type: 'string' } },
|
|
81
|
+
}, ['by', 'at', 'approved', 'text']);
|
|
82
|
+
/**
|
|
83
|
+
* Who besides the people a card asks may sign it, and how many votes settle it. Fixed once `openedAt` is set:
|
|
84
|
+
* `who` is invited, `need` approvals settle it, a dissent either blocks member settlement (`block`) or rejects it.
|
|
85
|
+
*/
|
|
86
|
+
const quorumSchema = object({
|
|
87
|
+
need: { type: 'integer' }, who: strings, openedAt: numberValue,
|
|
88
|
+
onReject: { type: 'string', enum: ['block', 'reject'] }, fields: array(signFieldSchema), blocked: stringValue,
|
|
89
|
+
}, ['need', 'who']);
|
|
90
|
+
/** What a person answered a card with; `via: 'quorum'` when members' signatures settled it. */
|
|
91
|
+
const cardAnswerSchema = object({
|
|
92
|
+
by: stringValue, at: numberValue, picked: strings, text: stringValue, approved: booleanValue, remember: booleanValue,
|
|
93
|
+
filled: { type: 'object', additionalProperties: strings },
|
|
94
|
+
via: { type: 'string', enum: ['owner', 'quorum'] }, signs: array(signatureSchema),
|
|
95
|
+
}, ['by', 'at']);
|
|
96
|
+
/** A question whose answer and outcome are kept on the same card. */
|
|
97
|
+
const cardSchema = object({
|
|
98
|
+
kind: stringValue, ask: stringValue, to: strings, title: stringValue, body: stringValue, by: stringValue, data: record,
|
|
99
|
+
options: array(object({ id: stringValue, label: stringValue, detail: stringValue, image: stringValue, open: stringValue }, ['id', 'label'])),
|
|
100
|
+
multi: booleanValue, other: booleanValue, items: array(cardItemSchema),
|
|
101
|
+
approve: stringValue, reject: stringValue, remember: stringValue, rev: { type: 'integer' },
|
|
102
|
+
state: { type: 'string', enum: ['pending', 'answered', 'closed'] },
|
|
103
|
+
answer: cardAnswerSchema, outcome: cardResultSchema, note: stringValue,
|
|
104
|
+
quorum: quorumSchema, signs: array(signatureSchema), expiresAt: numberValue,
|
|
105
|
+
}, ['kind', 'title', 'rev', 'state']);
|
|
106
|
+
const partSchema = {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: { type: { type: 'string', enum: ['text', 'thinking', 'tool', 'card', 'reference', 'excerpt'] } },
|
|
109
|
+
required: ['type'],
|
|
110
|
+
oneOf: [
|
|
111
|
+
object({ type: { type: 'string', enum: ['text', 'thinking'] }, text: stringValue }, ['type', 'text']),
|
|
112
|
+
object({
|
|
113
|
+
type: { type: 'string', enum: ['tool'] }, id: stringValue, name: stringValue, input: stringValue, output: stringValue,
|
|
114
|
+
status: { type: 'string', enum: ['running', 'done', 'failed'] }, agent: booleanValue,
|
|
115
|
+
}, ['type', 'id', 'name', 'status']),
|
|
116
|
+
object({ type: { type: 'string', enum: ['card'] }, ...cardSchema.properties }, ['type', ...cardSchema.required]),
|
|
117
|
+
object({
|
|
118
|
+
type: { type: 'string', enum: ['reference'] }, dir: { type: 'string', enum: ['in', 'out'] },
|
|
119
|
+
address: stringValue, title: stringValue, recipients: strings, summary: stringValue,
|
|
120
|
+
}, ['type', 'dir', 'address', 'title']),
|
|
121
|
+
object({
|
|
122
|
+
type: { type: 'string', enum: ['excerpt'] }, text: stringValue,
|
|
123
|
+
title: stringValue, author: stringValue, url: stringValue,
|
|
124
|
+
}, ['type', 'text']),
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
export const partsSchema = array(partSchema);
|
|
128
|
+
const messageStatusSchema = { type: 'string', enum: ['processing', 'completed', 'failed', 'canceled'] };
|
|
129
|
+
const replyTerminalSchema = object({
|
|
130
|
+
status: { type: 'string', enum: ['failed', 'canceled'] }, reason: nullableString,
|
|
131
|
+
}, ['status', 'reason']);
|
|
132
|
+
export const messageSchema = object({
|
|
133
|
+
id: stringValue, topicId: stringValue, seq: { type: ['integer', 'null'] },
|
|
134
|
+
from: senderSchema, to: strings, replyTo: nullableString, thread: nullableString, threadable: booleanValue, attachments: strings,
|
|
135
|
+
content: stringValue, parts: partsSchema,
|
|
136
|
+
visibility: { oneOf: [{ type: 'string', enum: ['all', 'shadow'] }, strings] },
|
|
137
|
+
status: { type: ['string', 'null'], enum: [...messageStatusSchema.enum, null] },
|
|
138
|
+
turnId: nullableString, retryOf: nullableString, note: nullableString, terminal: replyTerminalSchema, read: strings, createdAt: numberValue,
|
|
139
|
+
deletedAt: numberValue, deletedBy: stringValue,
|
|
140
|
+
}, ['id', 'topicId', 'seq', 'from', 'to', 'replyTo', 'thread', 'attachments', 'content', 'parts', 'status', 'turnId', 'retryOf', 'note', 'read', 'createdAt']);
|
|
141
|
+
export const usageSchema = object({
|
|
142
|
+
/** Total input in this report, including cache reads and writes. */
|
|
143
|
+
inputTokens: numberValue, outputTokens: numberValue,
|
|
144
|
+
cachedReadTokens: numberValue, cachedWriteTokens: numberValue,
|
|
145
|
+
/** The client's reported total, which may include thinking or cover the whole session. */
|
|
146
|
+
totalTokens: numberValue, contextUsed: numberValue, contextSize: numberValue,
|
|
147
|
+
});
|
|
148
|
+
const applyModeSchema = { type: 'string', enum: ['live', 'restart', 'new-session'] };
|
|
149
|
+
export const applyModesSchema = object({
|
|
150
|
+
tools: applyModeSchema, prompt: applyModeSchema, model: applyModeSchema, options: applyModeSchema,
|
|
151
|
+
}, ['tools', 'prompt', 'model', 'options']);
|
|
152
|
+
/** An adapter can report the same failure when opening a session as at turn end. */
|
|
153
|
+
export class TurnFailureError extends Error {
|
|
154
|
+
failure;
|
|
155
|
+
constructor(failure, cause) {
|
|
156
|
+
super(cause.message, { cause });
|
|
157
|
+
this.failure = failure;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** An adapter reports that a saved session no longer exists on the client and must be replaced. */
|
|
161
|
+
export class SessionGoneError extends Error {
|
|
162
|
+
constructor(message, options) {
|
|
163
|
+
super(message, options);
|
|
164
|
+
this.name = 'SessionGoneError';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Ids sort by creation time, so a list ordered by id is a list ordered by time. */
|
|
2
|
+
export declare function newId(prefix: string): string;
|
|
3
|
+
export declare function readJson<T>(file: string, fallback: T): T;
|
|
4
|
+
export declare function writeJson(file: string, value: unknown): string;
|
|
5
|
+
export declare function setLogWriter(write: (line: string) => void): () => void;
|
|
6
|
+
/** `terminal: false` keeps the line in the host log only, for a failure whose short form the caller prints itself. */
|
|
7
|
+
export declare function log(scope: string, message: string, extra?: unknown, options?: {
|
|
8
|
+
terminal?: boolean;
|
|
9
|
+
}): void;
|
|
10
|
+
export declare function errorText(error: unknown): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
import { inspect } from 'node:util';
|
|
5
|
+
/** Ids sort by creation time, so a list ordered by id is a list ordered by time. */
|
|
6
|
+
export function newId(prefix) {
|
|
7
|
+
return `${prefix}_${Date.now().toString(36)}${randomBytes(4).toString('hex')}`;
|
|
8
|
+
}
|
|
9
|
+
export function readJson(file, fallback) {
|
|
10
|
+
if (!existsSync(file))
|
|
11
|
+
return fallback;
|
|
12
|
+
return JSON.parse(readFileSync(file, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
export function writeJson(file, value) {
|
|
15
|
+
const text = `${JSON.stringify(value, null, 2)}\n`;
|
|
16
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
17
|
+
writeFileSync(file, text);
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
let writeLog;
|
|
21
|
+
const quiet = process.env.HOSTLET_LOG === 'silent';
|
|
22
|
+
export function setLogWriter(write) {
|
|
23
|
+
writeLog = write;
|
|
24
|
+
return () => { if (writeLog === write)
|
|
25
|
+
writeLog = undefined; };
|
|
26
|
+
}
|
|
27
|
+
/** `terminal: false` keeps the line in the host log only, for a failure whose short form the caller prints itself. */
|
|
28
|
+
export function log(scope, message, extra, options) {
|
|
29
|
+
const line = `${new Date().toISOString()} [${scope}] ${message}${extra === undefined ? '' : ` ${format(extra)}`}`;
|
|
30
|
+
if (!quiet && options?.terminal !== false)
|
|
31
|
+
console.log(line);
|
|
32
|
+
try {
|
|
33
|
+
writeLog?.(`${line}\n`);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error(`[storage] 写入宿主日志失败:${errorText(error)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function format(extra) {
|
|
40
|
+
// With a cause, Node's inspect prints both stacks and copes with cycles; the cause's own inspect hooks are not run.
|
|
41
|
+
if (extra instanceof Error)
|
|
42
|
+
return extra.cause === undefined ? extra.stack ?? extra.message : inspect(extra, { customInspect: false, depth: 4 });
|
|
43
|
+
return typeof extra === 'string' ? extra : JSON.stringify(extra);
|
|
44
|
+
}
|
|
45
|
+
export function errorText(error) {
|
|
46
|
+
return error instanceof Error ? error.message : String(error);
|
|
47
|
+
}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Runtime, type Plugin } from './runtime/runtime.ts';
|
|
2
|
+
import { type Home, type MigrationOptions } from './core/home.ts';
|
|
3
|
+
export interface Host {
|
|
4
|
+
runtime: Runtime;
|
|
5
|
+
home: Home;
|
|
6
|
+
url: string;
|
|
7
|
+
/** What did not come up: plugin files that could not be read, plugins that failed or still wait. */
|
|
8
|
+
problems: string[];
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/** Start the host: the core first, then the selected plugin packages. Dependencies decide the actual start order. */
|
|
12
|
+
export declare function startHost(argv?: readonly string[], extra?: Plugin[], migrationOptions?: MigrationOptions): Promise<Host>;
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { Runtime } from "./runtime/runtime.js";
|
|
4
|
+
import { a2aPlugin } from "./core/a2a.js";
|
|
5
|
+
import { configPlugin } from "./core/config.js";
|
|
6
|
+
import { entryPlugin } from "./core/entry.js";
|
|
7
|
+
import { prepareHome } from "./core/home.js";
|
|
8
|
+
import { i18nPlugin } from "./core/i18n.js";
|
|
9
|
+
import { instancesPlugin } from "./core/instances.js";
|
|
10
|
+
import { membersPlugin } from "./core/members.js";
|
|
11
|
+
import { messagesPlugin } from "./core/messages.js";
|
|
12
|
+
import { noticesPlugin } from "./core/notices.js";
|
|
13
|
+
import { pushPlugin } from "./core/push.js";
|
|
14
|
+
import { storagePlugin } from "./core/storage.js";
|
|
15
|
+
import { storePlugin } from "./core/store.js";
|
|
16
|
+
import { topicsPlugin } from "./core/topics.js";
|
|
17
|
+
import { errorText, log, setLogWriter } from "./core/util.js";
|
|
18
|
+
import { pluginPackages } from "./core/plugins/external.js";
|
|
19
|
+
/** The exit code that asks whoever started the host to start it again. `bin/hostlet.js` has the same number. */
|
|
20
|
+
const AGAIN = 75;
|
|
21
|
+
/** Start the host: the core first, then the selected plugin packages. Dependencies decide the actual start order. */
|
|
22
|
+
export async function startHost(argv = process.argv.slice(2), extra = [], migrationOptions) {
|
|
23
|
+
const home = await prepareHome(argv, migrationOptions);
|
|
24
|
+
const stopLogging = setLogWriter(home.storage.writeLog);
|
|
25
|
+
const runtime = new Runtime();
|
|
26
|
+
// While the core comes up, a failure goes to the host log in full and to the terminal once, as the error startHost throws.
|
|
27
|
+
let coreStarting = true;
|
|
28
|
+
runtime.onError = (where, error) => log('runtime', where, error, { terminal: !coreStarting });
|
|
29
|
+
const packages = pluginPackages(home, runtime);
|
|
30
|
+
const core = [
|
|
31
|
+
storePlugin(home), pushPlugin, entryPlugin(home), configPlugin(home), i18nPlugin, noticesPlugin(home), membersPlugin(home),
|
|
32
|
+
topicsPlugin(home), messagesPlugin, instancesPlugin(home), storagePlugin(home), a2aPlugin, packages.plugin,
|
|
33
|
+
];
|
|
34
|
+
for (const plugin of core)
|
|
35
|
+
await runtime.load(plugin);
|
|
36
|
+
coreStarting = false;
|
|
37
|
+
// A core part that did not come up leaves nothing to run on; say which and why instead of failing later on a missing service.
|
|
38
|
+
const broken = runtime.list().find((p) => p.state === 'failed');
|
|
39
|
+
if (broken) {
|
|
40
|
+
await runtime.shutdown(true).catch(() => { });
|
|
41
|
+
stopLogging();
|
|
42
|
+
throw new Error(`${broken.error ?? `${broken.name} did not start`}\n(details / 详细信息: ${join(home.root, 'logs', 'host.log')})`);
|
|
43
|
+
}
|
|
44
|
+
const problems = await packages.load(extra);
|
|
45
|
+
runtime.get('topics').purgeExpired();
|
|
46
|
+
await runtime.finishStart();
|
|
47
|
+
const failed = runtime.list().filter((p) => p.state === 'failed' || p.state === 'waiting');
|
|
48
|
+
for (const plugin of failed) {
|
|
49
|
+
log('host', `plugin ${plugin.name} is ${plugin.state}`, plugin.error ?? `waiting for ${plugin.waitingFor.join(', ')}`);
|
|
50
|
+
problems.push(`插件 ${plugin.name} 没起来:${plugin.error ?? `在等 ${plugin.waitingFor.join('、')}`}`);
|
|
51
|
+
}
|
|
52
|
+
return { runtime, home, url: runtime.get('entry').url, problems, stop: () => runtime.shutdown(true).finally(stopLogging) };
|
|
53
|
+
}
|
|
54
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
55
|
+
const host = await startHost().catch((error) => {
|
|
56
|
+
console.error(`hostlet could not start: ${errorText(error)}`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
});
|
|
59
|
+
// `--check`: only find out whether the code as it is now comes up, then leave. What is wrong is printed.
|
|
60
|
+
if (host.home.checkOnly) {
|
|
61
|
+
for (const problem of host.problems)
|
|
62
|
+
console.log(problem);
|
|
63
|
+
await host.stop();
|
|
64
|
+
process.exit(host.problems.length ? 1 : 0);
|
|
65
|
+
}
|
|
66
|
+
log('host', `hostlet is running at ${host.url} (data in ${host.home.root})`);
|
|
67
|
+
let stopping = false;
|
|
68
|
+
host.runtime._listen('host.restart', () => {
|
|
69
|
+
if (stopping)
|
|
70
|
+
return;
|
|
71
|
+
stopping = true;
|
|
72
|
+
void host.stop().then(() => process.exit(AGAIN));
|
|
73
|
+
});
|
|
74
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
75
|
+
process.on(signal, () => {
|
|
76
|
+
if (stopping)
|
|
77
|
+
process.exit(1);
|
|
78
|
+
stopping = true;
|
|
79
|
+
void host.stop().then(() => process.exit(0));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExternalPluginContext, Home, Plugin } from 'hostlet/sdk';
|
|
2
|
+
/** ACP clients the owner lists in settings, plus an always-available generic ACP client configured per member. */
|
|
3
|
+
export default function acpAdapterPlugin(home: Home, ext: ExternalPluginContext): Plugin;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { acpAdapter } from '@hostlet/adapter-kit';
|
|
2
|
+
import * as sdk from 'hostlet/sdk';
|
|
3
|
+
const GENERIC_ACP_ID = 'acp-generic';
|
|
4
|
+
const GENERIC_ACP_BASE = {
|
|
5
|
+
title: '通用 ACP',
|
|
6
|
+
memberTemplate: { name: 'ACP' },
|
|
7
|
+
command: '',
|
|
8
|
+
args: [],
|
|
9
|
+
};
|
|
10
|
+
function resolveGenericAcpId(home, pluginId, clients, memberAdapters) {
|
|
11
|
+
const clientIds = new Set(clients.map((client) => client.id));
|
|
12
|
+
const usedByMembers = new Set(memberAdapters.filter((id) => Boolean(id)));
|
|
13
|
+
const file = home.path('data', pluginId, 'generic.json');
|
|
14
|
+
const binding = sdk.readJson(file, undefined);
|
|
15
|
+
if (binding !== undefined && (typeof binding?.genericId !== 'string' || !binding.genericId.trim())) {
|
|
16
|
+
throw new Error(`Invalid generic ACP registration in ${file}`);
|
|
17
|
+
}
|
|
18
|
+
const saved = binding?.genericId;
|
|
19
|
+
if (saved && (!clientIds.has(saved) || usedByMembers.has(saved))) {
|
|
20
|
+
return saved;
|
|
21
|
+
}
|
|
22
|
+
const taken = new Set([...clientIds, ...usedByMembers]);
|
|
23
|
+
let next = GENERIC_ACP_ID;
|
|
24
|
+
let suffix = 2;
|
|
25
|
+
while (taken.has(next)) {
|
|
26
|
+
next = `${GENERIC_ACP_ID}-${suffix}`;
|
|
27
|
+
suffix++;
|
|
28
|
+
}
|
|
29
|
+
sdk.writeDocuments(home, [{ path: file, value: { genericId: next } }]);
|
|
30
|
+
return next;
|
|
31
|
+
}
|
|
32
|
+
/** ACP clients the owner lists in settings, plus an always-available generic ACP client configured per member. */
|
|
33
|
+
export default function acpAdapterPlugin(home, ext) {
|
|
34
|
+
return {
|
|
35
|
+
name: 'adapter-acp',
|
|
36
|
+
title: '其他 ACP 客户端',
|
|
37
|
+
about: '提供始终可选的通用 ACP 客户端,并继续注册你在设置里自己加的 ACP 客户端。随宿主来的 Kimi、opencode、Gemini 各是一个插件。',
|
|
38
|
+
group: '客户端',
|
|
39
|
+
caution: '关掉后,用它的成员正在跑的回合会跑完再结束实例,空闲实例立即结束;这些成员也收不到新消息了。',
|
|
40
|
+
needs: ['instances', 'members'],
|
|
41
|
+
start(ctx) {
|
|
42
|
+
const clients = ext.config.get('clients') ?? [];
|
|
43
|
+
const memberAdapters = ctx.get('members').list().map((member) => member.adapter);
|
|
44
|
+
const genericId = resolveGenericAcpId(home, ext.id, clients, memberAdapters);
|
|
45
|
+
ctx.effect(ctx.get('instances').registerAdapter(genericId, acpAdapter(sdk, { ...GENERIC_ACP_BASE, id: genericId })));
|
|
46
|
+
for (const client of clients) {
|
|
47
|
+
if (client.id === genericId) {
|
|
48
|
+
sdk.log(ext.id, `Custom client "${client.id}" uses the ID of an existing generic ACP member. Choose another client ID to register it.`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
ctx.effect(ctx.get('instances').registerAdapter(client.id, acpAdapter(sdk, { ...client, args: client.args ?? [] })));
|
|
52
|
+
}
|
|
53
|
+
ctx.on('config.changed', ({ scope }) => { if (scope === 'plugin:adapter-acp')
|
|
54
|
+
ext.reload(); });
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
pluginId: adapter-acp
|
|
2
|
+
name: 其他 ACP 客户端
|
|
3
|
+
description:
|
|
4
|
+
default: 你在设置里自己加的 ACP 客户端。随宿主来的 Kimi、opencode、Gemini 各是一个插件。
|
|
5
|
+
translations:
|
|
6
|
+
zh: 你在设置里自己加的 ACP 客户端。随宿主来的 Kimi、opencode、Gemini 各是一个插件。
|
|
7
|
+
en: Additional ACP clients you configure yourself. Kimi, opencode, and Gemini shipped with the host are separate plugins.
|
|
8
|
+
configuration:
|
|
9
|
+
- key: clients
|
|
10
|
+
kind: records
|
|
11
|
+
label:
|
|
12
|
+
default: 自定义 ACP 客户端
|
|
13
|
+
translations:
|
|
14
|
+
zh: 自定义 ACP 客户端
|
|
15
|
+
en: Custom ACP clients
|
|
16
|
+
description:
|
|
17
|
+
default: 另外的 ACP 客户端。每项填写 id、title、command、args,以及 append(回合进行中再发 prompt 是否并入当前轮——要实测过再写 true)。仅当客户端的 inputTokens 不含缓存读取和写入时,设 inputExcludesCache 为 true。
|
|
18
|
+
translations:
|
|
19
|
+
zh: 另外的 ACP 客户端。每项填写 id、title、command、args,以及 append(回合进行中再发 prompt 是否并入当前轮——要实测过再写 true)。仅当客户端的 inputTokens 不含缓存读取和写入时,设 inputExcludesCache 为 true。
|
|
20
|
+
en: Additional ACP clients. Each record has id, title, command, args, and append (whether a prompt sent during a turn joins it—set true only after verifying). Set inputExcludesCache only when the client's inputTokens exclude cache reads and writes.
|
|
21
|
+
default: []
|
|
22
|
+
recordFields:
|
|
23
|
+
- key: id
|
|
24
|
+
kind: string
|
|
25
|
+
label:
|
|
26
|
+
default: 适配器 ID
|
|
27
|
+
translations:
|
|
28
|
+
zh: 适配器 ID
|
|
29
|
+
en: Adapter ID
|
|
30
|
+
description:
|
|
31
|
+
default: 成员配置里引用的唯一适配器标识。
|
|
32
|
+
translations:
|
|
33
|
+
zh: 成员配置里引用的唯一适配器标识。
|
|
34
|
+
en: Unique adapter identifier used by member configuration.
|
|
35
|
+
required: true
|
|
36
|
+
- key: title
|
|
37
|
+
kind: string
|
|
38
|
+
label:
|
|
39
|
+
default: 显示名
|
|
40
|
+
translations:
|
|
41
|
+
zh: 显示名
|
|
42
|
+
en: Display name
|
|
43
|
+
description:
|
|
44
|
+
default: 控制台和成员选择里显示的名字。
|
|
45
|
+
translations:
|
|
46
|
+
zh: 控制台和成员选择里显示的名字。
|
|
47
|
+
en: Name shown in the console and member picker.
|
|
48
|
+
required: true
|
|
49
|
+
- key: command
|
|
50
|
+
kind: string
|
|
51
|
+
label:
|
|
52
|
+
default: 启动命令
|
|
53
|
+
translations:
|
|
54
|
+
zh: 启动命令
|
|
55
|
+
en: Start command
|
|
56
|
+
description:
|
|
57
|
+
default: 启动这个 ACP 客户端的可执行命令。
|
|
58
|
+
translations:
|
|
59
|
+
zh: 启动这个 ACP 客户端的可执行命令。
|
|
60
|
+
en: Executable command that starts this ACP client.
|
|
61
|
+
required: true
|
|
62
|
+
- key: args
|
|
63
|
+
kind: list
|
|
64
|
+
label:
|
|
65
|
+
default: 启动参数
|
|
66
|
+
translations:
|
|
67
|
+
zh: 启动参数
|
|
68
|
+
en: Start arguments
|
|
69
|
+
description:
|
|
70
|
+
default: 追加在启动命令后的参数列表。
|
|
71
|
+
translations:
|
|
72
|
+
zh: 追加在启动命令后的参数列表。
|
|
73
|
+
en: Arguments appended to the start command.
|
|
74
|
+
default: []
|
|
75
|
+
- key: append
|
|
76
|
+
kind: boolean
|
|
77
|
+
label:
|
|
78
|
+
default: 支持回合中追加
|
|
79
|
+
translations:
|
|
80
|
+
zh: 支持回合中追加
|
|
81
|
+
en: Supports appending during a turn
|
|
82
|
+
description:
|
|
83
|
+
default: 实测确认回合进行中再发 prompt 会并入当前轮时才开启。
|
|
84
|
+
translations:
|
|
85
|
+
zh: 实测确认回合进行中再发 prompt 会并入当前轮时才开启。
|
|
86
|
+
en: Enable only after verifying that prompts sent during a turn join the current turn.
|
|
87
|
+
default: false
|
|
88
|
+
- key: inputExcludesCache
|
|
89
|
+
kind: boolean
|
|
90
|
+
label:
|
|
91
|
+
default: inputTokens 不含缓存
|
|
92
|
+
translations:
|
|
93
|
+
zh: inputTokens 不含缓存
|
|
94
|
+
en: inputTokens excludes cache
|
|
95
|
+
description:
|
|
96
|
+
default: 仅当客户端报告的 inputTokens 不含缓存读取和写入时开启。
|
|
97
|
+
translations:
|
|
98
|
+
zh: 仅当客户端报告的 inputTokens 不含缓存读取和写入时开启。
|
|
99
|
+
en: Enable only when the client's reported inputTokens exclude cache reads and writes.
|
|
100
|
+
default: false
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TempDirectory } from 'hostlet/sdk';
|
|
2
|
+
export type AgyCommand = [string, ...string[]];
|
|
3
|
+
export declare const agyCommandTimeoutMs = 30000;
|
|
4
|
+
export declare function agyAccountArgs(env?: NodeJS.ProcessEnv): string[];
|
|
5
|
+
/** Wait for the pipes too: a launcher can exit before its children finish writing. */
|
|
6
|
+
export declare function runAgy([command, ...prefix]: AgyCommand, args: string[], timeoutMs: number, temp: TempDirectory, env?: NodeJS.ProcessEnv): Promise<{
|
|
7
|
+
code: number | null;
|
|
8
|
+
stdout: string;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { once } from 'node:events';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { startChild } from 'hostlet/sdk';
|
|
4
|
+
export const agyCommandTimeoutMs = 30_000;
|
|
5
|
+
// Native agy 1.x reads the directory flag even where it ignores GEMINI_HOME.
|
|
6
|
+
export function agyAccountArgs(env) {
|
|
7
|
+
return env?.GEMINI_HOME ? [`--gemini_dir=${env.GEMINI_HOME}`] : [];
|
|
8
|
+
}
|
|
9
|
+
/** Wait for the pipes too: a launcher can exit before its children finish writing. */
|
|
10
|
+
export async function runAgy([command, ...prefix], args, timeoutMs, temp, env) {
|
|
11
|
+
let child;
|
|
12
|
+
let timer;
|
|
13
|
+
try {
|
|
14
|
+
child = startChild(command, [...prefix, ...args], { cwd: tmpdir(), env: { ...env, FORCE_COLOR: '0' }, onLine() { } });
|
|
15
|
+
temp.track(child.pid);
|
|
16
|
+
const chunks = [];
|
|
17
|
+
child.proc.stdout.on('data', (chunk) => chunks.push(chunk));
|
|
18
|
+
const closed = once(child.proc, 'close');
|
|
19
|
+
child.proc.stdin.end();
|
|
20
|
+
const deadline = new Promise((_, reject) => {
|
|
21
|
+
timer = setTimeout(() => reject(new Error('Gemini 命令超时')), timeoutMs);
|
|
22
|
+
});
|
|
23
|
+
await Promise.race([closed, deadline]);
|
|
24
|
+
const { code } = await child.exited;
|
|
25
|
+
return { code, stdout: chunks.join('') };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
await child?.stop();
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
clearTimeout(timer);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Home } from 'hostlet/sdk';
|
|
2
|
+
import * as sdk from 'hostlet/sdk';
|
|
3
|
+
/** A prompt sent during an agy turn takes over its remaining output and final result (verified on 1.5.16 and 1.5.20). */
|
|
4
|
+
export declare const agyAdapterPlugin: (home: Home) => sdk.Plugin;
|
|
5
|
+
export default agyAdapterPlugin;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, join, resolve } from 'node:path';
|
|
3
|
+
import { acpClientPlugin } from '@hostlet/adapter-kit';
|
|
4
|
+
import * as sdk from 'hostlet/sdk';
|
|
5
|
+
import { agyAccountArgs } from "./command.js";
|
|
6
|
+
import { createAgyQuota } from "./quota.js";
|
|
7
|
+
import { configuredLog, watchAgyFailure } from "./terminal.js";
|
|
8
|
+
const AGY_CLEAN_AUTH_ENV = {
|
|
9
|
+
ANTIGRAVITY_GEMINI_DIR: undefined, ANTIGRAVITY_APP_DATA_DIR: undefined, ANTIGRAVITY_CONFIG_REL_DIR: undefined,
|
|
10
|
+
AGY_ADC_AUTH: undefined, GEMINI_API_KEY: undefined, GOOGLE_API_KEY: undefined,
|
|
11
|
+
AGY_LLM_GATEWAY_API_KEY: undefined, AGY_ACP_ENABLE_GATEWAY_AUTH: undefined, AGY_CDE_SEAMLESS_AUTH: undefined,
|
|
12
|
+
GOOGLE_APPLICATION_CREDENTIALS: undefined, GOOGLE_GENAI_USE_VERTEXAI: undefined,
|
|
13
|
+
};
|
|
14
|
+
/** A prompt sent during an agy turn takes over its remaining output and final result (verified on 1.5.16 and 1.5.20). */
|
|
15
|
+
export const agyAdapterPlugin = (home) => acpClientPlugin(sdk, {
|
|
16
|
+
id: 'agy', title: 'Gemini', command: 'agy', args: ['acp'],
|
|
17
|
+
quotaAccountEnv: ['HOME', 'USERPROFILE', 'GEMINI_HOME', 'AGY_CLI_FORCE_FILE_TOKEN_STORAGE', ...Object.keys(AGY_CLEAN_AUTH_ENV)],
|
|
18
|
+
append: 'supersede',
|
|
19
|
+
memberTemplate: { name: 'Pollux', color: { primary: '#2B3A8C' }, avatarPath: '/avatars/agy.svg', options: { handoffAt: 0.85 } },
|
|
20
|
+
icon: '/clients/agy.svg',
|
|
21
|
+
accountArgs: agyAccountArgs,
|
|
22
|
+
account: {
|
|
23
|
+
env: (dir) => ({
|
|
24
|
+
GEMINI_HOME: join(dir, '.gemini'), AGY_CLI_FORCE_FILE_TOKEN_STORAGE: '1',
|
|
25
|
+
...AGY_CLEAN_AUTH_ENV,
|
|
26
|
+
}),
|
|
27
|
+
credentialFile: (dir) => join(dir, '.gemini', 'antigravity-cli', 'antigravity-oauth-token'),
|
|
28
|
+
// Layout under GEMINI_HOME as agy 1.x writes it: conversations and per-conversation artifacts, and its own logs.
|
|
29
|
+
storage: () => [
|
|
30
|
+
{ path: '.gemini/antigravity-cli/conversations', kind: 'sessions' },
|
|
31
|
+
{ path: '.gemini/antigravity-cli/brain', kind: 'sessions' },
|
|
32
|
+
{ path: '.gemini/antigravity-cli/log', kind: 'log' },
|
|
33
|
+
],
|
|
34
|
+
login: (env) => ['agy', 'acp', '--login', ...agyAccountArgs(env)],
|
|
35
|
+
// The native CLI checks for a remote terminal before launching the OS opener; it still prints the full OAuth link.
|
|
36
|
+
loginBrowser: { endpoint: 'https://accounts.google.com/o/oauth2/auth', env: { SSH_TTY: 'hostlet' } },
|
|
37
|
+
},
|
|
38
|
+
inputExcludesCache: true,
|
|
39
|
+
quota: createAgyQuota(home.storage.temporary),
|
|
40
|
+
prepare({ command, cwd }) {
|
|
41
|
+
const [, ...args] = command;
|
|
42
|
+
const configured = configuredLog(args);
|
|
43
|
+
if (configured !== undefined) {
|
|
44
|
+
return configured ? { watchFailure: watchAgyFailure(resolve(cwd, configured), false) } : {};
|
|
45
|
+
}
|
|
46
|
+
const launchesAgy = args.includes('acp') && /^agy(?:\.exe|\.cmd)?$/i.test(basename(command[0]));
|
|
47
|
+
if (!launchesAgy || args.includes('--'))
|
|
48
|
+
return {};
|
|
49
|
+
const temp = home.storage.temporary('agy-acp');
|
|
50
|
+
const log = join(temp.path, 'acp.log');
|
|
51
|
+
try {
|
|
52
|
+
writeFileSync(log, '', { flag: 'wx', mode: 0o600 });
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
temp.release();
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
command: [...command, '--log-file', log],
|
|
60
|
+
temp,
|
|
61
|
+
watchFailure: watchAgyFailure(log, true),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
}, '通过 agy acp 接 Gemini(Antigravity 的命令行)。模型、思考强度和模式由客户端列出。支持向运行中的回合追加输入,最新请求接管该回合的后续输出与终态。');
|
|
65
|
+
export default agyAdapterPlugin;
|