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,265 @@
|
|
|
1
|
+
import { closeSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
|
+
import { Readable } from 'node:stream';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import JSZip from 'jszip';
|
|
6
|
+
import { archiveMetadata, archivePath, array, extractTarGz, HttpError, object, stripArchiveRoot, } from 'hostlet/sdk';
|
|
7
|
+
export const INSTALL_BODY_LIMIT = 15 * 1024 * 1024;
|
|
8
|
+
const DOWNLOAD_LIMIT = 10 * 1024 * 1024;
|
|
9
|
+
const CONTENT_LIMIT = 32 * 1024 * 1024;
|
|
10
|
+
const ENTRY_LIMIT = 500;
|
|
11
|
+
const invalid = (message) => new HttpError(400, message);
|
|
12
|
+
const tooLarge = () => new HttpError(413, 'Skill 内容最多 32 MiB');
|
|
13
|
+
const tooMany = () => new HttpError(413, `Skill 最多包含 ${ENTRY_LIMIT} 个条目`);
|
|
14
|
+
const string = { type: 'string' };
|
|
15
|
+
const encoding = { ...string, enum: ['utf8', 'base64'] };
|
|
16
|
+
const payload = { content: string, encoding };
|
|
17
|
+
export const installSource = object({
|
|
18
|
+
kind: { ...string, enum: ['directory', 'url', 'upload'] },
|
|
19
|
+
path: { ...string, description: 'directory 来源的本地绝对路径' },
|
|
20
|
+
url: { ...string, description: 'url 来源的 HTTP、HTTPS 或 file:// 链接' },
|
|
21
|
+
filename: { ...string, description: 'upload 来源的 Markdown 或离线包文件名' },
|
|
22
|
+
...payload,
|
|
23
|
+
files: array(object({ path: string, ...payload }, ['path', 'content'])),
|
|
24
|
+
}, ['kind']);
|
|
25
|
+
function decoder({ content, encoding }) {
|
|
26
|
+
if (encoding !== 'base64')
|
|
27
|
+
return Buffer.from(content, 'utf8');
|
|
28
|
+
const bytes = Buffer.from(content, 'base64');
|
|
29
|
+
const canonical = bytes.toString('base64');
|
|
30
|
+
if (content !== canonical && content !== canonical.replace(/=+$/, ''))
|
|
31
|
+
throw invalid('Skill 文件的 base64 内容无效');
|
|
32
|
+
return bytes;
|
|
33
|
+
}
|
|
34
|
+
function budget() {
|
|
35
|
+
let entries = 0;
|
|
36
|
+
let bytes = 0;
|
|
37
|
+
return {
|
|
38
|
+
entry() { if (++entries > ENTRY_LIMIT)
|
|
39
|
+
throw tooMany(); },
|
|
40
|
+
add(size) { bytes += size; if (bytes > CONTENT_LIMIT)
|
|
41
|
+
throw tooLarge(); },
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function openFile(path, mode) {
|
|
45
|
+
try {
|
|
46
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
47
|
+
return openSync(path, 'wx', mode);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (['EEXIST', 'EISDIR', 'ENOTDIR'].includes(error.code ?? '')) {
|
|
51
|
+
throw invalid('Skill 中有重复或冲突的文件路径');
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function writeFile(path, content, mode = 0o644) {
|
|
57
|
+
const fd = openFile(path, mode);
|
|
58
|
+
try {
|
|
59
|
+
writeFileSync(fd, content);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
closeSync(fd);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function copyDirectory(from, to) {
|
|
66
|
+
const limit = budget();
|
|
67
|
+
function copy(dir, target) {
|
|
68
|
+
for (const { name } of readdirSync(dir, { withFileTypes: true })) {
|
|
69
|
+
const path = join(dir, name);
|
|
70
|
+
const dest = join(target, name);
|
|
71
|
+
const info = lstatSync(path);
|
|
72
|
+
limit.entry();
|
|
73
|
+
if (info.isDirectory()) {
|
|
74
|
+
mkdirSync(dest);
|
|
75
|
+
copy(path, dest);
|
|
76
|
+
}
|
|
77
|
+
else if (info.isFile()) {
|
|
78
|
+
limit.add(info.size);
|
|
79
|
+
writeFile(dest, readFileSync(path), 0o644 | (info.mode & 0o111));
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
throw invalid(`Skill 目录只支持普通文件和目录:${path}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
copy(from, to);
|
|
86
|
+
}
|
|
87
|
+
// JSZip normalizes paths before exposing entries. Check the stored paths and count first,
|
|
88
|
+
// including directory entries and duplicates that would be collapsed by normalization.
|
|
89
|
+
function zipEntryCount(bytes) {
|
|
90
|
+
const malformed = () => invalid('Skill ZIP 目录结构无效');
|
|
91
|
+
const end = bytes.lastIndexOf(Buffer.from([0x50, 0x4b, 0x05, 0x06]));
|
|
92
|
+
if (end < 0 || end + 22 > bytes.length || end + 22 + bytes.readUInt16LE(end + 20) !== bytes.length)
|
|
93
|
+
throw malformed();
|
|
94
|
+
const count = bytes.readUInt16LE(end + 10);
|
|
95
|
+
if (count > ENTRY_LIMIT)
|
|
96
|
+
throw tooMany();
|
|
97
|
+
let offset = bytes.readUInt32LE(end + 16);
|
|
98
|
+
const start = offset;
|
|
99
|
+
if (bytes.readUInt32LE(end + 4) !== 0 || bytes.readUInt16LE(end + 8) !== count ||
|
|
100
|
+
start + bytes.readUInt32LE(end + 12) !== end)
|
|
101
|
+
throw malformed();
|
|
102
|
+
for (let i = 0; i < count; i++) {
|
|
103
|
+
if (offset + 46 > end || bytes.readUInt32LE(offset) !== 0x02014b50)
|
|
104
|
+
throw malformed();
|
|
105
|
+
const nameSize = bytes.readUInt16LE(offset + 28);
|
|
106
|
+
const next = offset + 46 + nameSize + bytes.readUInt16LE(offset + 30) + bytes.readUInt16LE(offset + 32);
|
|
107
|
+
if (next > end)
|
|
108
|
+
throw malformed();
|
|
109
|
+
const name = bytes.subarray(offset + 46, offset + 46 + nameSize);
|
|
110
|
+
archivePath(name.toString('utf8'), invalid);
|
|
111
|
+
const local = bytes.readUInt32LE(offset + 42);
|
|
112
|
+
if (local + 30 + nameSize > start || bytes.readUInt32LE(local) !== 0x04034b50 ||
|
|
113
|
+
bytes.readUInt16LE(local + 26) !== nameSize || !name.equals(bytes.subarray(local + 30, local + 30 + nameSize)))
|
|
114
|
+
throw malformed();
|
|
115
|
+
offset = next;
|
|
116
|
+
}
|
|
117
|
+
if (offset !== end)
|
|
118
|
+
throw malformed();
|
|
119
|
+
return count;
|
|
120
|
+
}
|
|
121
|
+
async function extractZip(bytes, dir) {
|
|
122
|
+
const count = zipEntryCount(bytes);
|
|
123
|
+
const zip = await JSZip.loadAsync(bytes).catch(() => { throw invalid('无法读取 Skill ZIP 文件'); });
|
|
124
|
+
const files = Object.values(zip.files);
|
|
125
|
+
if (files.length !== count)
|
|
126
|
+
throw invalid('Skill ZIP 中有重复或冲突的文件路径');
|
|
127
|
+
const entries = files.map((file) => {
|
|
128
|
+
const parts = archivePath(file.unsafeOriginalName ?? file.name, invalid);
|
|
129
|
+
const mode = Number(file.unixPermissions);
|
|
130
|
+
const type = mode & 0o170000;
|
|
131
|
+
if (type && type !== (file.dir ? 0o040000 : 0o100000))
|
|
132
|
+
throw invalid('Skill ZIP 只支持普通文件和目录,不能包含链接或特殊文件');
|
|
133
|
+
if (!file.dir && !parts.length)
|
|
134
|
+
throw invalid('Skill ZIP 文件路径为空');
|
|
135
|
+
return { file, directory: file.dir, parts, mode };
|
|
136
|
+
}).filter(({ parts }) => parts.length && !archiveMetadata(parts));
|
|
137
|
+
const limit = budget();
|
|
138
|
+
for (const { file, parts, directory, mode } of stripArchiveRoot(entries)) {
|
|
139
|
+
const target = join(dir, ...parts);
|
|
140
|
+
if (directory) {
|
|
141
|
+
mkdirSync(target, { recursive: true });
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const fd = openFile(target, 0o644 | (mode & 0o111));
|
|
145
|
+
try {
|
|
146
|
+
for await (const chunk of new Readable().wrap(file.nodeStream('nodebuffer'))) {
|
|
147
|
+
limit.add(chunk.length);
|
|
148
|
+
writeFileSync(fd, chunk);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
closeSync(fd);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function format(path) {
|
|
157
|
+
if (/\.zip$/i.test(path))
|
|
158
|
+
return 'zip';
|
|
159
|
+
if (/\.(?:tgz|tar\.gz)$/i.test(path))
|
|
160
|
+
return 'tar';
|
|
161
|
+
if (/\.md$/i.test(path))
|
|
162
|
+
return 'markdown';
|
|
163
|
+
}
|
|
164
|
+
async function unpack(dir, bytes, type) {
|
|
165
|
+
if (bytes.length > CONTENT_LIMIT)
|
|
166
|
+
throw tooLarge();
|
|
167
|
+
if (type === 'markdown')
|
|
168
|
+
writeFile(join(dir, 'SKILL.md'), bytes);
|
|
169
|
+
else if (type === 'zip')
|
|
170
|
+
await extractZip(bytes, dir);
|
|
171
|
+
else if (type === 'tar')
|
|
172
|
+
await extractTarGz(bytes, dir, { label: 'Skill 离线包', maxOutput: CONTENT_LIMIT, maxEntries: ENTRY_LIMIT });
|
|
173
|
+
else
|
|
174
|
+
throw invalid('请选择 Markdown、.tgz、.tar.gz 或 .zip 文件');
|
|
175
|
+
}
|
|
176
|
+
async function download(url, dir) {
|
|
177
|
+
try {
|
|
178
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(15_000) });
|
|
179
|
+
if (!res.ok || Number(res.headers.get('content-length')) > DOWNLOAD_LIMIT) {
|
|
180
|
+
await res.body?.cancel();
|
|
181
|
+
if (!res.ok)
|
|
182
|
+
throw invalid(`下载 Skill 失败(HTTP ${res.status})`);
|
|
183
|
+
throw new HttpError(413, '下载的 Skill 最多 10 MiB');
|
|
184
|
+
}
|
|
185
|
+
const parts = [];
|
|
186
|
+
let size = 0;
|
|
187
|
+
for await (const chunk of res.body ?? []) {
|
|
188
|
+
size += chunk.byteLength;
|
|
189
|
+
if (size > DOWNLOAD_LIMIT)
|
|
190
|
+
throw new HttpError(413, '下载的 Skill 最多 10 MiB');
|
|
191
|
+
parts.push(Buffer.from(chunk));
|
|
192
|
+
}
|
|
193
|
+
const contentType = res.headers.get('content-type')?.split(';', 1)[0]?.trim().toLowerCase();
|
|
194
|
+
const type = format(new URL(res.url).pathname) ?? format(url.pathname)
|
|
195
|
+
?? (contentType === 'text/markdown' || contentType === 'text/plain' ? 'markdown' : undefined);
|
|
196
|
+
await unpack(dir, Buffer.concat(parts, size), type);
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (error instanceof HttpError)
|
|
200
|
+
throw error;
|
|
201
|
+
if (error instanceof Error && ['TimeoutError', 'AbortError'].includes(error.name))
|
|
202
|
+
throw invalid('下载 Skill 超时(15 秒)');
|
|
203
|
+
throw invalid(`无法下载或读取 Skill:${error.message}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** Copy one input into the empty staging directory. */
|
|
207
|
+
export async function stageSkill(source, dir) {
|
|
208
|
+
if (source.kind === 'directory') {
|
|
209
|
+
if (!source.path || !isAbsolute(source.path))
|
|
210
|
+
throw invalid('请选择本地 Skill 目录(绝对路径)');
|
|
211
|
+
const path = resolve(source.path);
|
|
212
|
+
if (!lstatSync(path, { throwIfNoEntry: false })?.isDirectory())
|
|
213
|
+
throw invalid('请选择实际存在的 Skill 目录');
|
|
214
|
+
copyDirectory(path, dir);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (source.kind === 'url') {
|
|
218
|
+
const url = URL.parse(source.url ?? '');
|
|
219
|
+
if (url?.protocol === 'http:' || url?.protocol === 'https:')
|
|
220
|
+
return download(url, dir);
|
|
221
|
+
if (url?.protocol !== 'file:')
|
|
222
|
+
throw invalid('Skill 链接须使用 HTTP、HTTPS 或 file://');
|
|
223
|
+
let path;
|
|
224
|
+
try {
|
|
225
|
+
path = resolve(fileURLToPath(url));
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
throw invalid('file:// 链接须指向本机上的文件或目录');
|
|
229
|
+
}
|
|
230
|
+
const info = lstatSync(path, { throwIfNoEntry: false });
|
|
231
|
+
if (info?.isDirectory())
|
|
232
|
+
copyDirectory(path, dir);
|
|
233
|
+
else if (info?.isFile()) {
|
|
234
|
+
if (info.size > CONTENT_LIMIT)
|
|
235
|
+
throw tooLarge();
|
|
236
|
+
await unpack(dir, readFileSync(path), format(path));
|
|
237
|
+
}
|
|
238
|
+
else
|
|
239
|
+
throw invalid('file:// 链接须指向普通文件或实际目录');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (source.files) {
|
|
243
|
+
if (!source.files.length || source.filename !== undefined || source.content !== undefined || source.encoding !== undefined) {
|
|
244
|
+
throw invalid('请上传一份文件或一组文件');
|
|
245
|
+
}
|
|
246
|
+
const limit = budget();
|
|
247
|
+
for (const file of source.files) {
|
|
248
|
+
limit.entry();
|
|
249
|
+
const path = archivePath(file.path, invalid);
|
|
250
|
+
if (!path.length)
|
|
251
|
+
throw invalid('Skill 文件路径为空');
|
|
252
|
+
const content = decoder(file);
|
|
253
|
+
limit.add(content.length);
|
|
254
|
+
writeFile(join(dir, ...path), content);
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const { filename, content } = source;
|
|
259
|
+
if (!filename || basename(filename) !== filename || content === undefined)
|
|
260
|
+
throw invalid('上传 Skill 时要提供文件名和内容');
|
|
261
|
+
const type = format(filename);
|
|
262
|
+
if ((type === 'tar' || type === 'zip') && source.encoding !== 'base64')
|
|
263
|
+
throw invalid('Skill 离线包须以 base64 上传');
|
|
264
|
+
await unpack(dir, decoder({ content, encoding: source.encoding }), type);
|
|
265
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
pluginId: skills
|
|
2
|
+
foundation: true
|
|
3
|
+
console: console/
|
|
4
|
+
name: Skill
|
|
5
|
+
description:
|
|
6
|
+
default: 每个带 SKILL.md 的文件夹是一个 skill:数据目录 skills/ 下的和插件自带的每个主题都有,某个主题目录 skills/ 下的只有它和它下面的主题有。成员的客户端自己会找的,链接进主题目录;不会找的,会话开头给一份清单,需要时用工具读全文。
|
|
7
|
+
translations:
|
|
8
|
+
zh: 每个带 SKILL.md 的文件夹是一个 skill:数据目录 skills/ 下的和插件自带的每个主题都有,某个主题目录 skills/ 下的只有它和它下面的主题有。成员的客户端自己会找的,链接进主题目录;不会找的,会话开头给一份清单,需要时用工具读全文。
|
|
9
|
+
en: "Every directory with SKILL.md is a skill: global and plugin skills are available everywhere, while topic skills apply to that topic and its descendants. Clients that discover skills receive links; others receive a list and read them with tools."
|
|
10
|
+
configuration:
|
|
11
|
+
- key: disabled
|
|
12
|
+
kind: list
|
|
13
|
+
label:
|
|
14
|
+
default: 新主题默认停用的 Skill
|
|
15
|
+
translations:
|
|
16
|
+
zh: 新主题默认停用的 Skill
|
|
17
|
+
en: Skills disabled by default in new topics
|
|
18
|
+
description:
|
|
19
|
+
default: 新主题默认不启用的 skill 的名字。每个主题可以在自己的「配置」里单独开关。
|
|
20
|
+
translations:
|
|
21
|
+
zh: 新主题默认不启用的 skill 的名字。每个主题可以在自己的「配置」里单独开关。
|
|
22
|
+
en: Names of skills disabled by default in new topics. Each topic can override them in its own configuration.
|
|
23
|
+
default: []
|
|
24
|
+
managedBy: skills.defaults_set
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Finding {
|
|
2
|
+
severity: 'high' | 'warn';
|
|
3
|
+
rule: string;
|
|
4
|
+
file: string;
|
|
5
|
+
line: number;
|
|
6
|
+
detail: string;
|
|
7
|
+
}
|
|
8
|
+
/** Inspect files as data. Each finding points to its line without quoting the scanned text. */
|
|
9
|
+
export declare function scanSkillFiles(files: Iterable<{
|
|
10
|
+
file: string;
|
|
11
|
+
bytes: Buffer;
|
|
12
|
+
}>): {
|
|
13
|
+
filesScanned: number;
|
|
14
|
+
findings: Finding[];
|
|
15
|
+
};
|
|
16
|
+
export declare function scanStagedSkill(dir: string): ReturnType<typeof scanSkillFiles>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join, relative, sep } from 'node:path';
|
|
3
|
+
function remoteExecution(line) {
|
|
4
|
+
const pipeline = line.split('|');
|
|
5
|
+
const pipesToInterpreter = pipeline.some((stage, index) => {
|
|
6
|
+
if (!/\b(?:curl|wget)\b|\bbase64\s+(?:-d|--decode)\b/i.test(stage))
|
|
7
|
+
return false;
|
|
8
|
+
return /^\s*(?:[^\s]+\/)?(?:sh|bash|zsh|node|python[\d.]*)\b/i.test(pipeline[index + 1] ?? '');
|
|
9
|
+
});
|
|
10
|
+
return pipesToInterpreter || /\b(?:iex|invoke-expression)\s*\(\s*(?:iwr|invoke-webrequest|irm|invoke-restmethod)\b/i.test(line)
|
|
11
|
+
|| /\b(?:powershell|pwsh)(?:\.exe)?\b[^;|]*\s-(?:enc|encodedcommand)\b/i.test(line);
|
|
12
|
+
}
|
|
13
|
+
function destructiveCommand(line) {
|
|
14
|
+
if (/\bmkfs\.[\w-]+|\bdd\s+[^;|]*\bof=\/dev\//.test(line))
|
|
15
|
+
return true;
|
|
16
|
+
const removal = /\brm\s+((?:--?[\w-]+\s+)+)([^;|]*)/.exec(line);
|
|
17
|
+
if (!removal)
|
|
18
|
+
return false;
|
|
19
|
+
const options = removal[1].trim().split(/\s+/);
|
|
20
|
+
return options.some((flag) => flag === '--recursive' || /^-[^-]*[rR]/.test(flag))
|
|
21
|
+
&& options.some((flag) => flag === '--force' || /^-[^-]*f/.test(flag))
|
|
22
|
+
&& /(?:^|\s)["']?(?:\/\*?|[~](?:\/\*?)?|\$(?:HOME|\{HOME\})(?:\/\*?)?)["']?(?=$|[\s`&])/.test(removal[2]);
|
|
23
|
+
}
|
|
24
|
+
function decode(file, bytes) {
|
|
25
|
+
if (bytes[0] === 0xff && bytes[1] === 0xfe)
|
|
26
|
+
return bytes.toString('utf16le');
|
|
27
|
+
if (bytes[0] === 0xfe && bytes[1] === 0xff)
|
|
28
|
+
return new TextDecoder('utf-16be', { ignoreBOM: true }).decode(bytes);
|
|
29
|
+
const textFile = /\.(?:md|markdown|mdx|txt|json|ya?ml|[cm]?[jt]sx?|[bz]?sh|ps1|bat|cmd|py|rb|pl|php|lua)$/i.test(file);
|
|
30
|
+
if (textFile || (bytes[0] === 35 && bytes[1] === 33) || !bytes.includes(0))
|
|
31
|
+
return bytes.toString('utf8');
|
|
32
|
+
}
|
|
33
|
+
/** Inspect files as data. Each finding points to its line without quoting the scanned text. */
|
|
34
|
+
export function scanSkillFiles(files) {
|
|
35
|
+
let filesScanned = 0;
|
|
36
|
+
const findings = [];
|
|
37
|
+
for (const { file, bytes } of files) {
|
|
38
|
+
const text = decode(file, bytes)?.replace(/^\uFEFF/, '');
|
|
39
|
+
if (text === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
filesScanned++;
|
|
42
|
+
const lines = text.split(/\r\n|\n|\r/);
|
|
43
|
+
const markdown = /\.(?:md|markdown|mdx)$/i.test(file);
|
|
44
|
+
const bufferDecode = lines.some((line) => /\bBuffer\.from\s*\([^;]*,\s*['"]base64['"]\s*\)/.test(line));
|
|
45
|
+
for (const [index, line] of lines.entries()) {
|
|
46
|
+
const high = (rule, detail) => findings.push({ severity: 'high', rule, file, line: index + 1, detail });
|
|
47
|
+
const warn = (rule, detail) => findings.push({ severity: 'warn', rule, file, line: index + 1, detail });
|
|
48
|
+
if (/[\u202A-\u202E\u2066-\u2069\u200B-\u200F\uFEFF]/u.test(line))
|
|
49
|
+
high('hidden-unicode', '包含双向文本控制或零宽字符');
|
|
50
|
+
if (remoteExecution(line))
|
|
51
|
+
high('remote-exec', '下载或解码后直接执行');
|
|
52
|
+
if (destructiveCommand(line))
|
|
53
|
+
high('destructive-command', '会删除系统或主目录内容,或直接写入设备');
|
|
54
|
+
if (/(?:~[\\/]|\$HOME[\\/])?\.hostlet[\\/]secrets\b|\bsecrets[\\/](?:mcp|keys)\.json\b/.test(line)) {
|
|
55
|
+
high('hostlet-secrets', '引用 Hostlet 密钥目录或文件');
|
|
56
|
+
}
|
|
57
|
+
if (/\beval\s*\(\s*atob\s*\(/.test(line) || (bufferDecode && /\b(?:eval|exec(?:File)?(?:Sync)?|spawn(?:Sync)?)\s*\(/.test(line))) {
|
|
58
|
+
high('obfuscated-exec', '解码内容后动态执行');
|
|
59
|
+
}
|
|
60
|
+
if (markdown && /\b(?:ignore\s+(?:all\s+)?(?:previous|prior)\s+instructions|disregard\s+(?:the\s+)?system\s+prompt)\b/i.test(line)) {
|
|
61
|
+
warn('prompt-override', '包含覆盖先前或系统指令的句式');
|
|
62
|
+
}
|
|
63
|
+
if (/~[\\/]\.ssh(?:[\\/]|\b)|~[\\/]\.aws[\\/]credentials\b|\/etc\/shadow\b/.test(line)) {
|
|
64
|
+
warn('sensitive-path', '引用常见的敏感凭证路径');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { filesScanned, findings };
|
|
69
|
+
}
|
|
70
|
+
export function scanStagedSkill(dir) {
|
|
71
|
+
function* files() {
|
|
72
|
+
const paths = readdirSync(dir, { recursive: true, withFileTypes: true })
|
|
73
|
+
.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)).sort();
|
|
74
|
+
for (const path of paths)
|
|
75
|
+
yield { file: relative(dir, path).split(sep).join('/'), bytes: readFileSync(path) };
|
|
76
|
+
}
|
|
77
|
+
return scanSkillFiles(files());
|
|
78
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-ops
|
|
3
|
+
description: 在 Hostlet 安装 Skill、处理同名来源、查看或停用主题可用的 Skill 时使用。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 管理 Skill
|
|
7
|
+
|
|
8
|
+
用 `host_api_info` 查看操作参数,再用 `host_invoke` 调用。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
先问用户要装到全局(`scope: "global"`),还是当前主题及子主题(`scope: "topic"`)。对话里代装时明确传范围。控制台的「安装 Skill」装到全局。
|
|
13
|
+
|
|
14
|
+
用 `skills.install` 安装上传文件、链接或本地目录。可先用 `skills.list` 查看同名来源。安装操作会列出目标位置已有的同名 Skill,以及会被盖过的上游同名 Skill。把具体来源告诉用户,等确认覆盖后再带 `replace: true` 调用。提请审批时带 `why` 说明原因。
|
|
15
|
+
|
|
16
|
+
## 同名覆盖与来源冲突
|
|
17
|
+
|
|
18
|
+
「内置」指插件自带的 Skill。「自定义」指全局目录或主题目录里的 Skill。默认从当前主题、各级上级主题、全局目录到插件依次查找同名项,最近的来源生效。
|
|
19
|
+
|
|
20
|
+
在当前主题调用 `skills.list`,用 `origin`、`layer`、`source` 说明生效来源,用 `shadowed` 列出被盖住的更远来源。用 `skills.conflicts` 核对冲突和已选的来源。
|
|
21
|
+
|
|
22
|
+
用户可在收件箱或对话的来源卡选「保留本地」或「改用上游」。代办时,先确认用户选哪一项,再用 `skills.conflict` 提交 `skills.conflicts` 返回的 `place` 和 `name`,以及 `choice: "keep-local"` 或 `choice: "use-upstream"`。保留本地时传这一版的 `upstreamVersion`,清除决定时传 `choice: null`。客户端发现目录的同名 Skill 卡片只提供「保留本地」;要改用上游,先由用户决定如何移走客户端自己的副本。
|
|
23
|
+
|
|
24
|
+
## 停用
|
|
25
|
+
|
|
26
|
+
用户说 Skill 太多时,先用 `topics.caps` 列出 `id` 以 `skill:` 开头且 `on` 为真的条目。标出本主题设置的(`own !== null`)和继承的(`own === null`),再问要停用哪些、范围是全局还是当前主题及子主题。
|
|
27
|
+
|
|
28
|
+
- 全局用 `skills.switch`,传 Skill 名称和 `action: "disable"`,带 `why` 提请审批。它修改全局默认开关。
|
|
29
|
+
- 当前主题及子主题用 `topics.cap_set`,传能力编号 `skill:<名称>` 和 `on: false`。要收回本主题设置并恢复继承时,传 `on: null`。
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"topicViews": [
|
|
3
|
+
{
|
|
4
|
+
"id": "terminal",
|
|
5
|
+
"view": "ws.terminal",
|
|
6
|
+
"title": "t:wsTerminal.s01",
|
|
7
|
+
"icon": "terminal",
|
|
8
|
+
"group": "code",
|
|
9
|
+
"about": "t:wsTerminal.s02",
|
|
10
|
+
"places": [
|
|
11
|
+
"main",
|
|
12
|
+
"panel"
|
|
13
|
+
],
|
|
14
|
+
"localPage": true,
|
|
15
|
+
"activeTopic": true
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"views": {
|
|
19
|
+
"ws.terminal": {
|
|
20
|
+
"vm": "plugin:terminal/hlTerminal",
|
|
21
|
+
"blocks": [
|
|
22
|
+
{
|
|
23
|
+
"type": "toolbar",
|
|
24
|
+
"items": [
|
|
25
|
+
{
|
|
26
|
+
"type": "status",
|
|
27
|
+
"text": "$.message",
|
|
28
|
+
"tone": "$.tone"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"type": "grow"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"type": "button",
|
|
35
|
+
"variant": "terminalOpen",
|
|
36
|
+
"iconOnly": true,
|
|
37
|
+
"icon": "power",
|
|
38
|
+
"label": "t:wsTerminal.open",
|
|
39
|
+
"tip": "t:wsTerminal.open",
|
|
40
|
+
"act": "plugin:terminal/hlTerminalOpen",
|
|
41
|
+
"when": "$.canOpen"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"type": "button",
|
|
45
|
+
"variant": "terminalOpen",
|
|
46
|
+
"iconOnly": true,
|
|
47
|
+
"icon": "power",
|
|
48
|
+
"label": "t:wsTerminal.attach",
|
|
49
|
+
"tip": "t:wsTerminal.attach",
|
|
50
|
+
"act": "plugin:terminal/hlTerminalAttach",
|
|
51
|
+
"when": "$.canAttach"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"type": "button",
|
|
55
|
+
"variant": "terminalClose",
|
|
56
|
+
"iconOnly": true,
|
|
57
|
+
"icon": "power",
|
|
58
|
+
"label": "t:wsTerminal.close",
|
|
59
|
+
"tip": "t:wsTerminal.close",
|
|
60
|
+
"act": "plugin:terminal/hlTerminalClose",
|
|
61
|
+
"when": "$.canClose"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"type": "component",
|
|
67
|
+
"use": "terminal",
|
|
68
|
+
"props": "$.screen",
|
|
69
|
+
"when": "$.screen"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"ns": "wsTerminal",
|
|
75
|
+
"i18n": {
|
|
76
|
+
"zh": {
|
|
77
|
+
"mine": "我的终端",
|
|
78
|
+
"checking": "正在连接终端…",
|
|
79
|
+
"opening": "正在启动终端…",
|
|
80
|
+
"connected": "已连接",
|
|
81
|
+
"empty": "已断开",
|
|
82
|
+
"closing": "正在结束终端…",
|
|
83
|
+
"ended": "已断开",
|
|
84
|
+
"exitCode": "已断开(退出码 {0})",
|
|
85
|
+
"signal": "已断开(信号 {0})",
|
|
86
|
+
"disconnected": "已断开",
|
|
87
|
+
"unavailable": "终端仅在本机控制台的活跃主题中启用",
|
|
88
|
+
"open": "打开终端",
|
|
89
|
+
"close": "结束终端",
|
|
90
|
+
"attach": "重新连接",
|
|
91
|
+
"assetsError": "终端样式加载失败",
|
|
92
|
+
"s01": "终端",
|
|
93
|
+
"s02": "在主题目录中打开本机终端"
|
|
94
|
+
},
|
|
95
|
+
"en": {
|
|
96
|
+
"mine": "My terminal",
|
|
97
|
+
"checking": "Connecting to terminal…",
|
|
98
|
+
"opening": "Starting terminal…",
|
|
99
|
+
"connected": "Connected",
|
|
100
|
+
"empty": "Disconnected",
|
|
101
|
+
"closing": "Closing terminal…",
|
|
102
|
+
"ended": "Disconnected",
|
|
103
|
+
"exitCode": "Disconnected (exit code {0})",
|
|
104
|
+
"signal": "Disconnected (signal {0})",
|
|
105
|
+
"disconnected": "Disconnected",
|
|
106
|
+
"unavailable": "Terminal is only enabled for active topics on localhost",
|
|
107
|
+
"open": "Open terminal",
|
|
108
|
+
"close": "Close terminal",
|
|
109
|
+
"attach": "Reconnect",
|
|
110
|
+
"assetsError": "Failed to load terminal assets",
|
|
111
|
+
"s01": "Terminal",
|
|
112
|
+
"s02": "Open a local terminal in the topic directory"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|