hostlet 0.0.0-stage → 0.1.0-alpha.1
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 +916 -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 +130 -0
- package/dist/plugins/model-profiles/rules.js +729 -0
- package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +59 -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 +84 -0
- package/dist/plugins/model-profiles/storage.js +315 -0
- package/dist/plugins/model-profiles/types.d.ts +179 -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 +455 -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 +270 -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,9 @@
|
|
|
1
|
+
export declare function responsesTracing(env?: NodeJS.ProcessEnv): string;
|
|
2
|
+
/** Collect only model evidence. Raw frames are consumed before they can enter the host's diagnostic tail. */
|
|
3
|
+
export declare class ResponsesModels {
|
|
4
|
+
private readonly observations;
|
|
5
|
+
private continuation?;
|
|
6
|
+
read(line: string): boolean;
|
|
7
|
+
private observe;
|
|
8
|
+
modelFor(thread: string, since: number, items: ReadonlySet<string>, allowThread?: boolean): string | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const sseTarget = 'codex_api::sse::responses';
|
|
2
|
+
const wsTarget = 'tungstenite::protocol';
|
|
3
|
+
const logHeader = /^\s*(\d{4}-\d{2}-\d{2}T\S+)\s+(?:TRACE|DEBUG|INFO|WARN|ERROR)\s+/;
|
|
4
|
+
const diagnostic = /\b(codex_api::sse::responses|tungstenite::protocol):\s*/;
|
|
5
|
+
const maxMultilineFrame = 1024 * 1024;
|
|
6
|
+
export function responsesTracing(env) {
|
|
7
|
+
const inherited = env && 'RUST_LOG' in env ? env.RUST_LOG : process.env.RUST_LOG;
|
|
8
|
+
return [inherited || 'error', sseTarget + '=trace', wsTarget + '=trace'].join(',');
|
|
9
|
+
}
|
|
10
|
+
/** Collect only model evidence. Raw frames are consumed before they can enter the host's diagnostic tail. */
|
|
11
|
+
export class ResponsesModels {
|
|
12
|
+
observations = new Map();
|
|
13
|
+
continuation;
|
|
14
|
+
read(line) {
|
|
15
|
+
const raw = line.includes('\x1b') ? line.replace(/\x1b\[[0-9;]*m/g, '') : line;
|
|
16
|
+
const header = logHeader.exec(raw);
|
|
17
|
+
if (!header) {
|
|
18
|
+
const frame = this.continuation;
|
|
19
|
+
if (!frame)
|
|
20
|
+
return false;
|
|
21
|
+
if (frame.data !== null) {
|
|
22
|
+
frame.data += '\n' + raw;
|
|
23
|
+
if (frame.data.length > maxMultilineFrame)
|
|
24
|
+
frame.data = null;
|
|
25
|
+
else if (raw.trimEnd().endsWith('}') && this.observe(frame.at, frame.data))
|
|
26
|
+
this.continuation = undefined;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
this.continuation = undefined;
|
|
31
|
+
const message = raw.slice(header[0].length);
|
|
32
|
+
const match = diagnostic.exec(message);
|
|
33
|
+
if (!match)
|
|
34
|
+
return false;
|
|
35
|
+
const marker = match[1] === sseTarget ? 'SSE event: ' : 'Received message ';
|
|
36
|
+
const payload = message.slice(match.index + match[0].length);
|
|
37
|
+
if (!payload.startsWith(marker))
|
|
38
|
+
return true;
|
|
39
|
+
const at = Date.parse(header[1]);
|
|
40
|
+
const data = payload.slice(marker.length).trimStart();
|
|
41
|
+
if (data.startsWith('{') && !this.observe(at, data)) {
|
|
42
|
+
this.continuation = { at, data: data.length > maxMultilineFrame ? null : data };
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
observe(at, data) {
|
|
47
|
+
let event;
|
|
48
|
+
try {
|
|
49
|
+
event = JSON.parse(data);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const response = event?.response;
|
|
55
|
+
if (!Number.isFinite(at) || typeof response?.id !== 'string' || !response.id
|
|
56
|
+
|| !['response.created', 'response.completed', 'response.failed', 'response.incomplete'].includes(event.type))
|
|
57
|
+
return true;
|
|
58
|
+
const saved = event.type === 'response.created' ? undefined : this.observations.get(response.id);
|
|
59
|
+
const model = (typeof response.model === 'string' && response.model.trim()) || saved?.model;
|
|
60
|
+
const thread = (typeof response.prompt_cache_key === 'string' && response.prompt_cache_key) || saved?.thread;
|
|
61
|
+
const items = Array.isArray(response.output)
|
|
62
|
+
? response.output.flatMap((item) => typeof item?.id === 'string' ? [item.id] : [])
|
|
63
|
+
: saved?.items;
|
|
64
|
+
this.observations.delete(response.id);
|
|
65
|
+
this.observations.set(response.id, { at, model, thread, items });
|
|
66
|
+
if (this.observations.size > 64)
|
|
67
|
+
this.observations.delete(this.observations.keys().next().value);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
modelFor(thread, since, items, allowThread = true) {
|
|
71
|
+
let byThread;
|
|
72
|
+
for (const observation of [...this.observations.values()].reverse()) {
|
|
73
|
+
if (!observation.model || observation.at < since || (observation.thread && observation.thread !== thread))
|
|
74
|
+
continue;
|
|
75
|
+
if (observation.items?.some((id) => items.has(id)))
|
|
76
|
+
return observation.model;
|
|
77
|
+
if (allowThread && observation.thread === thread)
|
|
78
|
+
byThread ??= observation.model;
|
|
79
|
+
}
|
|
80
|
+
return byThread;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as sdk from 'hostlet/sdk';
|
|
2
|
+
/** Kimi over ACP. Measured: a prompt sent while a turn runs is refused (-32600), and turns it starts by itself for its own background tasks never appear over ACP. */
|
|
3
|
+
export declare const kimiAdapterPlugin: sdk.Plugin;
|
|
4
|
+
export default kimiAdapterPlugin;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { acpClientPlugin, catalogOutput, windowTokens } from '@hostlet/adapter-kit';
|
|
3
|
+
import * as sdk from 'hostlet/sdk';
|
|
4
|
+
import { KIMI_COMMAND, kimiQuota } from "./quota.js";
|
|
5
|
+
/** Clears inherited Kimi auth variables for spawned child processes without touching host or system config. */
|
|
6
|
+
const KIMI_CLEAN_AUTH_ENV = {
|
|
7
|
+
KIMI_API_KEY: undefined,
|
|
8
|
+
KIMI_MODEL_API_KEY: undefined,
|
|
9
|
+
KIMI_MODEL_NAME: undefined,
|
|
10
|
+
KIMI_MODEL_PROVIDER_TYPE: undefined,
|
|
11
|
+
KIMI_MODEL_BASE_URL: undefined,
|
|
12
|
+
KIMI_MODEL_MAX_CONTEXT_SIZE: undefined,
|
|
13
|
+
MOONSHOT_API_KEY: undefined,
|
|
14
|
+
};
|
|
15
|
+
/** Kimi over ACP. Measured: a prompt sent while a turn runs is refused (-32600), and turns it starts by itself for its own background tasks never appear over ACP. */
|
|
16
|
+
export const kimiAdapterPlugin = acpClientPlugin(sdk, {
|
|
17
|
+
id: 'kimi', title: 'Kimi', command: KIMI_COMMAND, args: ['acp'], skillsDir: '.kimi-code/skills',
|
|
18
|
+
quotaAccountEnv: ['KIMI_CODE_HOME', 'HOME', 'USERPROFILE', 'KIMI_API_KEY', 'MOONSHOT_API_KEY',
|
|
19
|
+
'KIMI_MODEL_API_KEY', 'KIMI_MODEL_NAME', 'KIMI_MODEL_PROVIDER_TYPE', 'KIMI_MODEL_BASE_URL'],
|
|
20
|
+
memberTemplate: { name: 'Umbra', color: { primary: '#2B2140' }, avatarPath: '/avatars/kimi.svg', options: { handoffAt: 0.85 } },
|
|
21
|
+
icon: '/clients/kimi.svg',
|
|
22
|
+
account: {
|
|
23
|
+
env: (dir) => ({ ...KIMI_CLEAN_AUTH_ENV, KIMI_CODE_HOME: join(dir, '.kimi-code') }),
|
|
24
|
+
credentialFile: (dir) => join(dir, '.kimi-code', 'credentials', 'kimi-code.json'),
|
|
25
|
+
// Its own cache and logs under KIMI_CODE_HOME. Sessions are not offered: losing one is not known to read as a gone session here.
|
|
26
|
+
storage: () => [
|
|
27
|
+
{ path: '.kimi-code/cache', kind: 'cache' },
|
|
28
|
+
{ path: '.kimi-code/logs', kind: 'log' },
|
|
29
|
+
],
|
|
30
|
+
login: [KIMI_COMMAND, 'login'],
|
|
31
|
+
},
|
|
32
|
+
quota: kimiQuota,
|
|
33
|
+
// Kimi's documented way to run on a key without touching its config: the KIMI_MODEL_* variables make a
|
|
34
|
+
// provider for this process only. The model's name is required, and is what switches it on.
|
|
35
|
+
keys: { protocols: ['openai', 'anthropic'], contextWindow: true },
|
|
36
|
+
async modelWindows(env) {
|
|
37
|
+
const listing = JSON.parse(await catalogOutput(KIMI_COMMAND, ['provider', 'list', '--json'], env));
|
|
38
|
+
return new Map(Object.entries(listing.models).map(([alias, model]) => [alias, windowTokens(model.maxContextSize)]));
|
|
39
|
+
},
|
|
40
|
+
prepare({ key, model, contextWindow }) {
|
|
41
|
+
if (!key)
|
|
42
|
+
return {};
|
|
43
|
+
return { model, env: {
|
|
44
|
+
...KIMI_CLEAN_AUTH_ENV,
|
|
45
|
+
KIMI_MODEL_NAME: model, KIMI_MODEL_API_KEY: key.apiKey, KIMI_MODEL_PROVIDER_TYPE: key.protocol,
|
|
46
|
+
...(contextWindow === undefined ? {} : { KIMI_MODEL_MAX_CONTEXT_SIZE: String(contextWindow) }),
|
|
47
|
+
...(key.endpoint ? { KIMI_MODEL_BASE_URL: key.endpoint } : {}),
|
|
48
|
+
} };
|
|
49
|
+
},
|
|
50
|
+
}, '通过 kimi acp 接 Kimi。实测:它在回合进行中不收新输入(直接拒绝),所以新消息由宿主排队;它自带的后台任务通知不经 ACP 发出来,要等结果用平台的后台任务。用密钥时按它文档里的 KIMI_MODEL_* 变量给,不改它自己的配置。');
|
|
51
|
+
export default kimiAdapterPlugin;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { get } from 'node:http';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { json } from 'node:stream/consumers';
|
|
4
|
+
import { commandLine, quotaEnvironment } from '@hostlet/adapter-kit';
|
|
5
|
+
import { startChild } from 'hostlet/sdk';
|
|
6
|
+
export const KIMI_COMMAND = 'kimi';
|
|
7
|
+
const LOOPBACK = '127.0.0.1';
|
|
8
|
+
const MANAGED_PROVIDER = 'managed:kimi-code';
|
|
9
|
+
const WEB_TIMEOUT_MS = 12_000;
|
|
10
|
+
const KEY_TIMEOUT_MS = 8_000;
|
|
11
|
+
const windowKinds = new Map([
|
|
12
|
+
['monthTotal', '月度总额度'],
|
|
13
|
+
['monthCode', '月度代码额度'],
|
|
14
|
+
['limit7d', '7 天窗口'],
|
|
15
|
+
['limit5h', '5 小时窗口'],
|
|
16
|
+
].map(([id, label], order) => [id, { label, order }]));
|
|
17
|
+
const keyWindowNames = new Map([
|
|
18
|
+
['limit_5h', 'limit5h'],
|
|
19
|
+
['limit_7d', 'limit7d'],
|
|
20
|
+
['limit_month_total', 'monthTotal'],
|
|
21
|
+
['limit_month_code', 'monthCode'],
|
|
22
|
+
]);
|
|
23
|
+
function record(value) {
|
|
24
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value))
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function windowsOf(usages, keyFormat = false) {
|
|
28
|
+
return Object.entries(record(usages) ?? {}).flatMap(([name, raw]) => {
|
|
29
|
+
const entry = record(raw);
|
|
30
|
+
if (!entry)
|
|
31
|
+
return [];
|
|
32
|
+
const kind = windowKinds.get(keyFormat ? keyWindowNames.get(name) ?? name : name);
|
|
33
|
+
const ratio = entry[keyFormat ? 'used_ratio' : 'usedRatio'];
|
|
34
|
+
const usedRatio = keyFormat && typeof ratio === 'string' && ratio.trim() ? Number(ratio) : ratio;
|
|
35
|
+
const reset = entry[keyFormat ? 'reset_time' : 'resetAt'];
|
|
36
|
+
const resetsAt = typeof reset === 'string' ? Date.parse(reset) : NaN;
|
|
37
|
+
const window = { label: kind?.label ?? name };
|
|
38
|
+
if (typeof usedRatio === 'number' && Number.isFinite(usedRatio)) {
|
|
39
|
+
window.usedPercent = Math.min(100, Math.max(0, Math.round(usedRatio * 100)));
|
|
40
|
+
}
|
|
41
|
+
if (Number.isFinite(resetsAt))
|
|
42
|
+
window.resetsAt = resetsAt;
|
|
43
|
+
return [{ order: kind?.order ?? windowKinds.size, window }];
|
|
44
|
+
}).sort((a, b) => a.order - b.order).map(({ window }) => window);
|
|
45
|
+
}
|
|
46
|
+
const headersFor = (token) => ({ authorization: `Bearer ${token}`, accept: 'application/json' });
|
|
47
|
+
function keyUsageUrl(endpoint) {
|
|
48
|
+
const url = URL.parse(endpoint ?? '');
|
|
49
|
+
if (!url || (url.origin !== 'https://api.kimi.com' && url.origin !== 'https://api.kimi.ai'))
|
|
50
|
+
return;
|
|
51
|
+
if (url.username || url.password || url.search || url.hash)
|
|
52
|
+
return;
|
|
53
|
+
const path = url.pathname.replace(/\/+$/, '');
|
|
54
|
+
if (path === '/coding' || path === '/coding/v1')
|
|
55
|
+
return `${url.origin}/coding/v1/usages`;
|
|
56
|
+
}
|
|
57
|
+
async function queryKey(url, token) {
|
|
58
|
+
const signal = AbortSignal.timeout(KEY_TIMEOUT_MS);
|
|
59
|
+
let status;
|
|
60
|
+
let raw;
|
|
61
|
+
// Upstream bodies and network errors can echo the credential.
|
|
62
|
+
try {
|
|
63
|
+
const response = await fetch(url, { headers: headersFor(token), redirect: 'error', signal });
|
|
64
|
+
if (response.ok)
|
|
65
|
+
raw = await response.json();
|
|
66
|
+
else {
|
|
67
|
+
status = response.status;
|
|
68
|
+
await response.body?.cancel();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
throw new Error(signal.aborted ? 'Kimi 额度查询超时' : 'Kimi 额度查询请求失败');
|
|
73
|
+
}
|
|
74
|
+
if (status !== undefined)
|
|
75
|
+
throw new Error(`Kimi 额度查询失败(HTTP ${status})`);
|
|
76
|
+
return windowsOf(record(raw)?.usages, true);
|
|
77
|
+
}
|
|
78
|
+
async function webData(port, path, token, signal) {
|
|
79
|
+
let raw;
|
|
80
|
+
try {
|
|
81
|
+
const response = await new Promise((resolve, reject) => {
|
|
82
|
+
// A direct connection keeps the Web bearer on loopback even when the host uses an HTTP proxy.
|
|
83
|
+
get({ hostname: LOOPBACK, port, path: `/api/v1/${path}`, headers: headersFor(token), agent: false, signal }, resolve).once('error', reject);
|
|
84
|
+
});
|
|
85
|
+
if (response.statusCode === 200)
|
|
86
|
+
raw = await json(response);
|
|
87
|
+
else
|
|
88
|
+
response.destroy();
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new Error(signal.aborted ? 'Kimi 额度查询超时' : 'Kimi Web 额度接口请求失败');
|
|
92
|
+
}
|
|
93
|
+
const envelope = record(raw);
|
|
94
|
+
const data = record(envelope?.data);
|
|
95
|
+
if (envelope?.code !== 0 || !data)
|
|
96
|
+
throw new Error('Kimi Web 额度接口响应无效');
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
async function queryOAuth(command, prefix, model, env) {
|
|
100
|
+
const signal = AbortSignal.timeout(WEB_TIMEOUT_MS);
|
|
101
|
+
const ready = Promise.withResolvers();
|
|
102
|
+
const timedOut = () => ready.reject(new Error('Kimi Web 服务启动超时'));
|
|
103
|
+
let child;
|
|
104
|
+
try {
|
|
105
|
+
child = startChild(command, [...prefix, 'web', '--no-open', '--port', '0', '--host', LOOPBACK, '--log-level', 'silent'], {
|
|
106
|
+
cwd: tmpdir(),
|
|
107
|
+
env: { ...env, FORCE_COLOR: '0' },
|
|
108
|
+
onLine(line) {
|
|
109
|
+
// Use the actual port and credential from the documented startup banner.
|
|
110
|
+
const match = /^Local:\s+http:\/\/127\.0\.0\.1:([1-9]\d{0,4})\/#token=([A-Za-z0-9_-]+)$/.exec(line);
|
|
111
|
+
if (!match)
|
|
112
|
+
return;
|
|
113
|
+
const port = Number(match[1]);
|
|
114
|
+
if (port <= 65535)
|
|
115
|
+
ready.resolve({ port, token: match[2] });
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
throw new Error('无法启动 Kimi Web 服务');
|
|
121
|
+
}
|
|
122
|
+
signal.addEventListener('abort', timedOut, { once: true });
|
|
123
|
+
try {
|
|
124
|
+
const { port, token } = await Promise.race([
|
|
125
|
+
ready.promise,
|
|
126
|
+
child.exited.then(() => { throw new Error('Kimi Web 服务意外退出'); }),
|
|
127
|
+
]);
|
|
128
|
+
const read = (path) => webData(port, path, token, signal);
|
|
129
|
+
const [auth, config] = await Promise.all([read('auth'), read('config')]);
|
|
130
|
+
const provider = record(auth.managed_provider);
|
|
131
|
+
if (provider?.status !== 'authenticated' || provider.name !== MANAGED_PROVIDER)
|
|
132
|
+
return [];
|
|
133
|
+
const selectedModel = model || config.default_model;
|
|
134
|
+
if (typeof selectedModel !== 'string' || record(record(config.models)?.[selectedModel])?.provider !== MANAGED_PROVIDER)
|
|
135
|
+
return [];
|
|
136
|
+
const data = await read(`oauth/usage?${new URLSearchParams({ provider: MANAGED_PROVIDER })}`);
|
|
137
|
+
if (data.kind !== 'ok')
|
|
138
|
+
throw new Error('Kimi 账号额度查询失败');
|
|
139
|
+
return windowsOf(record(data.quota)?.usages);
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
signal.removeEventListener('abort', timedOut);
|
|
143
|
+
await child.stop();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const pending = new Map();
|
|
147
|
+
function share(target, query) {
|
|
148
|
+
const id = JSON.stringify(target);
|
|
149
|
+
const running = pending.get(id);
|
|
150
|
+
if (running)
|
|
151
|
+
return running;
|
|
152
|
+
const request = query().finally(() => pending.delete(id));
|
|
153
|
+
pending.set(id, request);
|
|
154
|
+
return request;
|
|
155
|
+
}
|
|
156
|
+
export function kimiQuota(ctx) {
|
|
157
|
+
if (ctx?.key) {
|
|
158
|
+
const { endpoint, apiKey } = ctx.key;
|
|
159
|
+
const url = keyUsageUrl(endpoint);
|
|
160
|
+
return url ? share(['key', url, apiKey], () => queryKey(url, apiKey)) : Promise.resolve([]);
|
|
161
|
+
}
|
|
162
|
+
const [command, ...args] = commandLine(ctx?.options?.command, KIMI_COMMAND);
|
|
163
|
+
if (args.length && args.at(-1) !== 'acp')
|
|
164
|
+
return Promise.resolve([]);
|
|
165
|
+
// A wrapper can select the account before handing off to the Kimi subcommand.
|
|
166
|
+
const prefix = args.slice(0, -1);
|
|
167
|
+
const model = String(ctx?.options?.model ?? '').trim();
|
|
168
|
+
const env = quotaEnvironment(ctx);
|
|
169
|
+
const fingerprint = JSON.stringify(Object.entries(env ?? {}).sort());
|
|
170
|
+
return share(['oauth', command, ...prefix, model, fingerprint], () => queryOAuth(command, prefix, model, env));
|
|
171
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Home } from 'hostlet/sdk';
|
|
2
|
+
import * as sdk from 'hostlet/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* opencode over ACP (measured with opencode 1.17.3). It takes MCP servers from `session/new` like the others.
|
|
5
|
+
* What is its own: the member-level text goes in through a config file — `OPENCODE_CONFIG` names an
|
|
6
|
+
* `opencode.json` whose `instructions` lists files to read, merged with the owner's own opencode config — so it
|
|
7
|
+
* is a real system instruction rather than text in front of the first message. One folder per instance,
|
|
8
|
+
* removed when the instance stops. Its default model can be one that answers nothing; the member's model option
|
|
9
|
+
* picks another. Appending during a turn has not been measured, so it is not declared.
|
|
10
|
+
*/
|
|
11
|
+
export declare function opencodeAdapterPlugin(home: Home): sdk.Plugin;
|
|
12
|
+
export default opencodeAdapterPlugin;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { acpClientPlugin, catalogOutput, windowTokens, upstreamCode } from '@hostlet/adapter-kit';
|
|
4
|
+
import * as sdk from 'hostlet/sdk';
|
|
5
|
+
/**
|
|
6
|
+
* opencode over ACP (measured with opencode 1.17.3). It takes MCP servers from `session/new` like the others.
|
|
7
|
+
* What is its own: the member-level text goes in through a config file — `OPENCODE_CONFIG` names an
|
|
8
|
+
* `opencode.json` whose `instructions` lists files to read, merged with the owner's own opencode config — so it
|
|
9
|
+
* is a real system instruction rather than text in front of the first message. One folder per instance,
|
|
10
|
+
* removed when the instance stops. Its default model can be one that answers nothing; the member's model option
|
|
11
|
+
* picks another. Appending during a turn has not been measured, so it is not declared.
|
|
12
|
+
*/
|
|
13
|
+
export function opencodeAdapterPlugin(home) {
|
|
14
|
+
return acpClientPlugin(sdk, {
|
|
15
|
+
id: 'opencode', title: 'opencode', command: 'opencode', args: ['acp'],
|
|
16
|
+
memberTemplate: { name: 'Tilde', color: { primary: '#3DD6D0' }, avatarPath: '/avatars/opencode.svg', options: { handoffAt: 0.85 } },
|
|
17
|
+
icon: '/clients/opencode.svg',
|
|
18
|
+
inputExcludesCache: true,
|
|
19
|
+
failure: (data) => upstreamCode(data.errorName),
|
|
20
|
+
async modelWindows() {
|
|
21
|
+
// The CLI prints each provider/model ID followed by one JSON object.
|
|
22
|
+
const entries = (await catalogOutput('opencode', ['models', '--verbose'])).split(/^(\S+\/\S+)\r?$/m);
|
|
23
|
+
if (entries.length === 1 && entries[0]?.trim())
|
|
24
|
+
throw new Error('OpenCode 未返回可识别的模型目录');
|
|
25
|
+
const windows = new Map();
|
|
26
|
+
for (let i = 1; i < entries.length; i += 2) {
|
|
27
|
+
const model = JSON.parse(entries[i + 1]);
|
|
28
|
+
windows.set(entries[i], windowTokens(model.limit?.context));
|
|
29
|
+
}
|
|
30
|
+
return windows;
|
|
31
|
+
},
|
|
32
|
+
// With an API key: a provider of its own in the config file (which SDK adapter speaks the key's protocol, the
|
|
33
|
+
// address, the key), holding the one model the member chose. Its model option then takes `hostlet/<model>`.
|
|
34
|
+
keys: { protocols: ['openai', 'openai-responses', 'anthropic', 'gemini'], value: (id) => `hostlet/${id}` },
|
|
35
|
+
// OpenCode takes context and output together. An explicit input limit also controls the usable budget.
|
|
36
|
+
prepare({ systemPrompt, key, model: chosen }) {
|
|
37
|
+
if (!systemPrompt && !key)
|
|
38
|
+
return {};
|
|
39
|
+
const temp = home.storage.temporary('opencode-config');
|
|
40
|
+
const system = join(temp.path, 'system.md');
|
|
41
|
+
const config = join(temp.path, 'opencode.json');
|
|
42
|
+
const model = (chosen ?? '').replace(/^hostlet\//, '');
|
|
43
|
+
const provider = key ? {
|
|
44
|
+
hostlet: {
|
|
45
|
+
npm: { openai: '@ai-sdk/openai-compatible', 'openai-responses': '@ai-sdk/openai', anthropic: '@ai-sdk/anthropic', gemini: '@ai-sdk/google' }[key.protocol], name: 'hostlet',
|
|
46
|
+
options: { apiKey: key.apiKey, ...(key.endpoint ? { baseURL: key.endpoint } : {}) },
|
|
47
|
+
models: model ? { [model]: { name: model } } : {},
|
|
48
|
+
},
|
|
49
|
+
} : undefined;
|
|
50
|
+
const configuredModel = key && model ? `hostlet/${model}` : undefined;
|
|
51
|
+
try {
|
|
52
|
+
if (systemPrompt)
|
|
53
|
+
writeFileSync(system, `${systemPrompt}\n`, { mode: 0o600 });
|
|
54
|
+
writeFileSync(config, `${JSON.stringify({ $schema: 'https://opencode.ai/config.json', ...(systemPrompt ? { instructions: [system] } : {}), ...(provider ? { provider, model: configuredModel } : {}) }, null, 2)}\n`, { mode: 0o600 });
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
temp.release();
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
return { model: configuredModel, env: { OPENCODE_CONFIG: config }, system: !!systemPrompt, temp };
|
|
61
|
+
},
|
|
62
|
+
}, '通过 opencode acp 接 opencode。系统提示经它自己的配置文件给(OPENCODE_CONFIG 指向一份带 instructions 的 opencode.json,和你自己的 opencode 配置合并)。它默认的模型可能什么都不回,在成员的「编辑」里选一个你有凭据的模型。回合进行中的追加没有实测过,新消息由宿主排队。');
|
|
63
|
+
}
|
|
64
|
+
export default opencodeAdapterPlugin;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
@import url('/pdl/library/css/floating-window.css');
|
|
2
|
+
@import url('/pdl/library/css/member-select.css');
|
|
3
|
+
|
|
4
|
+
.annotation-ui, [data-view="ws.annotations"] {
|
|
5
|
+
--an-bg: var(--bg-raised, #fff);
|
|
6
|
+
--an-field: var(--bg-page, #f7f5f1);
|
|
7
|
+
--an-ink: var(--fg, #282421);
|
|
8
|
+
--an-muted: var(--fg-muted, #716860);
|
|
9
|
+
--an-line: var(--line, #ddd6cd);
|
|
10
|
+
--an-accent: var(--accent, #175d85);
|
|
11
|
+
--an-active: var(--accent-soft, #e8f0f4);
|
|
12
|
+
color: var(--an-ink);
|
|
13
|
+
line-height: 1.45;
|
|
14
|
+
font-size: 13px;
|
|
15
|
+
}
|
|
16
|
+
.annotation-ui [hidden] { display: none; }
|
|
17
|
+
.annotation-window {
|
|
18
|
+
position: relative;
|
|
19
|
+
z-index: 2;
|
|
20
|
+
height: 0;
|
|
21
|
+
}
|
|
22
|
+
.annotation-window .annotation-launcher {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset-inline-end: 12px;
|
|
25
|
+
inset-block-start: 8px;
|
|
26
|
+
box-shadow: 0 1px 4px #21190f20;
|
|
27
|
+
}
|
|
28
|
+
.annotation-popover {
|
|
29
|
+
width: 23rem;
|
|
30
|
+
max-height: min(28rem, 70dvh);
|
|
31
|
+
padding: 0;
|
|
32
|
+
border: 1px solid var(--an-line);
|
|
33
|
+
border-radius: 12px;
|
|
34
|
+
background: var(--an-bg);
|
|
35
|
+
color: var(--an-ink);
|
|
36
|
+
box-shadow: 0 10px 34px #21190f29;
|
|
37
|
+
}
|
|
38
|
+
.annotation-window-head {
|
|
39
|
+
border-block-end: 1px solid var(--an-line);
|
|
40
|
+
padding: 5px 9px 5px 12px;
|
|
41
|
+
}
|
|
42
|
+
.annotation-window-body { padding: 9px 12px 12px; }
|
|
43
|
+
.annotation-inline .annotation-list { margin: 0; }
|
|
44
|
+
.annotation-detail .annotation-card,
|
|
45
|
+
.annotation-inline .annotation-card { padding: 0; border: 0; }
|
|
46
|
+
.annotation-inline .annotation-card + .annotation-card {
|
|
47
|
+
border-block-start: 1px solid var(--an-line);
|
|
48
|
+
border-radius: 0;
|
|
49
|
+
padding-block-start: 9px;
|
|
50
|
+
}
|
|
51
|
+
[data-view="ws.annotations"] .label-search { margin-block-end: var(--sp-s); }
|
|
52
|
+
.annotation-groups > section + section { margin-block-start: var(--sp-m); }
|
|
53
|
+
.annotation-summary .lr-title { flex: 0 1 30%; }
|
|
54
|
+
.annotation-summary .lr-line > :is(.annotation-excerpt, .annotation-preview) { flex: 1 1 0; }
|
|
55
|
+
.annotation-summary .annotation-excerpt { color: var(--an-muted); }
|
|
56
|
+
.annotation-update {
|
|
57
|
+
display: inline-block;
|
|
58
|
+
width: 6px;
|
|
59
|
+
height: 6px;
|
|
60
|
+
margin-inline-end: 5px;
|
|
61
|
+
vertical-align: .15em;
|
|
62
|
+
border-radius: 50%;
|
|
63
|
+
background: var(--an-accent);
|
|
64
|
+
}
|
|
65
|
+
.annotation-ui button:where(:not(.identity-select > button)) {
|
|
66
|
+
border: 1px solid var(--an-line);
|
|
67
|
+
border-radius: 6px;
|
|
68
|
+
background: var(--an-bg);
|
|
69
|
+
color: var(--an-ink);
|
|
70
|
+
font: inherit;
|
|
71
|
+
padding: 4px 8px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
}
|
|
74
|
+
.annotation-ui button:disabled { cursor: default; opacity: .65; }
|
|
75
|
+
.annotation-ui button:not(:disabled):hover {
|
|
76
|
+
background: var(--an-active);
|
|
77
|
+
color: var(--an-accent);
|
|
78
|
+
}
|
|
79
|
+
.annotation-ui .annotation-primary {
|
|
80
|
+
color: var(--an-accent);
|
|
81
|
+
background: var(--an-active);
|
|
82
|
+
}
|
|
83
|
+
.annotation-ui button.annotation-icon {
|
|
84
|
+
display: inline-grid;
|
|
85
|
+
place-items: center;
|
|
86
|
+
width: 27px;
|
|
87
|
+
height: 27px;
|
|
88
|
+
background: transparent;
|
|
89
|
+
border-color: transparent;
|
|
90
|
+
color: var(--an-muted);
|
|
91
|
+
padding: 0;
|
|
92
|
+
}
|
|
93
|
+
.annotation-hint {
|
|
94
|
+
margin: 8px 0;
|
|
95
|
+
color: var(--an-muted);
|
|
96
|
+
overflow-wrap: anywhere;
|
|
97
|
+
}
|
|
98
|
+
.annotation-hint:empty, .annotation-error:empty { display: none; }
|
|
99
|
+
.annotation-list { display: grid; gap: 9px; margin-block-start: 8px; }
|
|
100
|
+
.annotation-card {
|
|
101
|
+
min-width: 0;
|
|
102
|
+
padding: 10px;
|
|
103
|
+
border: 1px solid var(--an-line);
|
|
104
|
+
border-radius: 9px;
|
|
105
|
+
background: var(--an-bg);
|
|
106
|
+
overflow-wrap: anywhere;
|
|
107
|
+
}
|
|
108
|
+
.annotation-heading, .annotation-controls, .annotation-entry-meta {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
gap: 7px;
|
|
112
|
+
}
|
|
113
|
+
.annotation-heading { justify-content: space-between; }
|
|
114
|
+
.annotation-heading strong { min-width: 0; }
|
|
115
|
+
.annotation-decision {
|
|
116
|
+
color: var(--an-muted);
|
|
117
|
+
font-size: 11px;
|
|
118
|
+
}
|
|
119
|
+
.annotation-card > blockquote, .annotation-create blockquote {
|
|
120
|
+
margin: 8px 0;
|
|
121
|
+
padding: 4px 7px;
|
|
122
|
+
border-inline-start: 2px solid var(--an-accent);
|
|
123
|
+
background: var(--an-field);
|
|
124
|
+
color: var(--an-muted);
|
|
125
|
+
white-space: pre-wrap;
|
|
126
|
+
overflow-wrap: anywhere;
|
|
127
|
+
}
|
|
128
|
+
.annotation-meta, .annotation-entry-meta { color: var(--an-muted); font-size: 12px; }
|
|
129
|
+
.annotation-meta { flex-wrap: wrap; }
|
|
130
|
+
.annotation-meta a { color: var(--an-accent); }
|
|
131
|
+
.annotation-entries { list-style: none; padding: 0; margin: 8px 0; }
|
|
132
|
+
.annotation-entries > li + li { border-top: 1px solid var(--an-line); margin-top: 7px; padding-top: 7px; }
|
|
133
|
+
.annotation-entry-controls {
|
|
134
|
+
display: flex;
|
|
135
|
+
gap: 4px;
|
|
136
|
+
margin-inline-start: auto;
|
|
137
|
+
}
|
|
138
|
+
.annotation-history { margin: 4px 0; color: var(--an-muted); font-size: 12px; }
|
|
139
|
+
.annotation-history summary { cursor: pointer; }
|
|
140
|
+
.annotation-history > ol { padding-inline-start: 14px; list-style: none; }
|
|
141
|
+
.annotation-history > ol > li { margin: 5px 0; }
|
|
142
|
+
.annotation-body { margin-block-start: 4px; overflow-wrap: anywhere; }
|
|
143
|
+
.annotation-body .md > *, .annotation-body > pre { margin: 0; }
|
|
144
|
+
.annotation-body .md > * + * { margin-block-start: 4px; }
|
|
145
|
+
.annotation-body :is(ul, ol) { padding-inline-start: 1.5em; }
|
|
146
|
+
.annotation-body blockquote { padding-inline-start: 8px; border-inline-start: 2px solid var(--an-line); color: var(--an-muted); }
|
|
147
|
+
.annotation-body code { font-family: var(--font-mono, monospace); }
|
|
148
|
+
.annotation-body :not(pre) > code { padding: 0 3px; border-radius: 3px; background: var(--an-field); }
|
|
149
|
+
.annotation-body pre { padding: 6px 8px; border-radius: 5px; background: var(--an-field); overflow: auto; }
|
|
150
|
+
.annotation-body a { color: var(--an-accent); text-decoration: underline; }
|
|
151
|
+
.annotation-editor-buttons {
|
|
152
|
+
margin: 0;
|
|
153
|
+
border: 0;
|
|
154
|
+
padding: 0;
|
|
155
|
+
min-inline-size: 0;
|
|
156
|
+
flex-wrap: wrap;
|
|
157
|
+
}
|
|
158
|
+
.annotation-kind {
|
|
159
|
+
max-width: 100%;
|
|
160
|
+
border: 1px solid var(--an-line);
|
|
161
|
+
border-radius: 6px;
|
|
162
|
+
padding: 3px 5px;
|
|
163
|
+
background: var(--an-bg);
|
|
164
|
+
color: var(--an-ink);
|
|
165
|
+
font: inherit;
|
|
166
|
+
}
|
|
167
|
+
.annotation-editor .identity-select { margin-block: 0 6px; }
|
|
168
|
+
.annotation-editor textarea {
|
|
169
|
+
box-sizing: border-box;
|
|
170
|
+
width: 100%;
|
|
171
|
+
margin: 5px 0;
|
|
172
|
+
padding: 5px 7px;
|
|
173
|
+
color: var(--an-ink);
|
|
174
|
+
background: var(--an-field);
|
|
175
|
+
border: 1px solid var(--an-line);
|
|
176
|
+
border-radius: 6px;
|
|
177
|
+
font: inherit;
|
|
178
|
+
resize: vertical;
|
|
179
|
+
}
|
|
180
|
+
.annotation-error { color: var(--an-muted); margin: 5px 0; white-space: pre-wrap; }
|
|
181
|
+
.annotation-delivery:empty { display: none; }
|
|
182
|
+
.annotation-delivery { margin-top: 7px; color: var(--an-muted); font-size: 12px; }
|
|
183
|
+
.annotation-delivery-line { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
|
|
184
|
+
.annotation-delivery-line + .annotation-delivery-line { margin-block-start: 5px; }
|
|
185
|
+
.annotation-delivery-line .annotation-error { flex-basis: 100%; margin: 0; }
|
|
186
|
+
::highlight(annotation-anchors) {
|
|
187
|
+
background-color: color-mix(in srgb, var(--accent, #175d85) 9%, transparent);
|
|
188
|
+
text-decoration: underline dotted color-mix(in srgb, var(--accent, #175d85) 58%, transparent);
|
|
189
|
+
}
|