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,427 @@
|
|
|
1
|
+
import { address, ArgsError, errorText, HttpError, log, OWNER_ID, readJson, writeDocuments, } from 'hostlet/sdk';
|
|
2
|
+
const cardOf = (message) => message.parts[0];
|
|
3
|
+
export const signData = (message) => cardOf(message).data?.sign;
|
|
4
|
+
const stepsOf = (card) => card.data?.steps;
|
|
5
|
+
/** The same value whatever order its keys were given in. */
|
|
6
|
+
const canonical = (value) => JSON.stringify(value, (_key, item) => (item && typeof item === 'object' && !Array.isArray(item)
|
|
7
|
+
? Object.fromEntries(Object.entries(item).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)))
|
|
8
|
+
: item));
|
|
9
|
+
/** A set of ids, same value however they were ordered or however often repeated. */
|
|
10
|
+
const setOf = (ids) => [...new Set(ids ?? [])].sort();
|
|
11
|
+
const clock = (at) => new Date(at).toLocaleString('zh-CN', { hour12: false });
|
|
12
|
+
/**
|
|
13
|
+
* Who besides the owner may approve, for operations whose effective policy allows co-signing. The owner can always
|
|
14
|
+
* answer and settles a card at once. Members are invited only when the owner has been quiet and the operation's wait
|
|
15
|
+
* has passed (or at once, when the operation names its signers); their votes are checked against the live policy and
|
|
16
|
+
* effective models (turn-reported > configured > latest reported) just before the card settles, blocking overlapping
|
|
17
|
+
* verified families and falling back to distinct members when either side has no verified families yet.
|
|
18
|
+
*/
|
|
19
|
+
export function signing(ctx, home, sender) {
|
|
20
|
+
const entry = ctx.get('entry');
|
|
21
|
+
const config = ctx.get('config');
|
|
22
|
+
const cards = ctx.get('cards');
|
|
23
|
+
const members = ctx.get('members');
|
|
24
|
+
const models = ctx.get('models');
|
|
25
|
+
const a2a = ctx.get('a2a');
|
|
26
|
+
const instances = ctx.get('instances');
|
|
27
|
+
const notices = ctx.get('notices');
|
|
28
|
+
const numberSetting = (key, fallback) => {
|
|
29
|
+
const value = config.get('settings', key);
|
|
30
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
|
|
31
|
+
};
|
|
32
|
+
const quietMs = () => numberSetting('approval.quiet', 30) * 60_000;
|
|
33
|
+
const cooldownMs = () => numberSetting('approval.cooldown', 360) * 60_000;
|
|
34
|
+
const expireMs = () => numberSetting('approval.expire', 24) * 3_600_000;
|
|
35
|
+
const name = (id) => members.get(id)?.name ?? id;
|
|
36
|
+
const file = home.path('plugins', 'host-api', 'signing.json');
|
|
37
|
+
const started = Date.now();
|
|
38
|
+
const state = home.checkOnly ? { cooldowns: {} } : readJson(file, { cooldowns: {} });
|
|
39
|
+
const save = () => {
|
|
40
|
+
if (!home.checkOnly)
|
|
41
|
+
writeDocuments(home, [{ path: file, value: state }]);
|
|
42
|
+
};
|
|
43
|
+
if (state.ownerActiveAt === undefined) {
|
|
44
|
+
state.ownerActiveAt = started;
|
|
45
|
+
save();
|
|
46
|
+
}
|
|
47
|
+
const declared = (opName) => entry.ops().ops.find((op) => op.name === opName);
|
|
48
|
+
const sharedFamilies = (a, b) => a.filter((one) => b.includes(one));
|
|
49
|
+
const familiesOf = (memberId, turnId) => models.familiesOf(models.effectiveModel(memberId, turnId));
|
|
50
|
+
const turnOf = (topicId, memberId) => (topicId ? a2a.live(topicId).find((turn) => turn.memberId === memberId)?.turnId : undefined);
|
|
51
|
+
const ours = () => cards.pending({ from: sender }).filter((message) => signData(message));
|
|
52
|
+
const keyOf = ({ op, args, subjects, targets }) => {
|
|
53
|
+
const affected = setOf(subjects);
|
|
54
|
+
const scope = setOf(targets);
|
|
55
|
+
return affected.length || scope.length
|
|
56
|
+
? `${op.name} ${canonical({ subjects: affected, targets: scope })}`
|
|
57
|
+
: `${op.name} ${canonical(args)}`;
|
|
58
|
+
};
|
|
59
|
+
const sameIds = (a, b) => {
|
|
60
|
+
const first = new Set(a ?? []);
|
|
61
|
+
const second = new Set(b ?? []);
|
|
62
|
+
return first.size === second.size && [...first].every((id) => second.has(id));
|
|
63
|
+
};
|
|
64
|
+
const expiring = new Set();
|
|
65
|
+
const expiredAt = (message) => cardOf(message).expiresAt;
|
|
66
|
+
const closeExpired = (message, now = Date.now()) => {
|
|
67
|
+
const at = expiredAt(message);
|
|
68
|
+
if (at === undefined || at > now)
|
|
69
|
+
return false;
|
|
70
|
+
expiring.add(message.id);
|
|
71
|
+
try {
|
|
72
|
+
cards.close(message.id, '会签卡已过期');
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
expiring.delete(message.id);
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
};
|
|
79
|
+
/** Re-resolve the operation's current reach, targets, subjects, grant and co-sign policy against what was asked. */
|
|
80
|
+
const liveScope = (message) => {
|
|
81
|
+
const card = cardOf(message);
|
|
82
|
+
const step = stepsOf(card)?.[0];
|
|
83
|
+
const data = signData(message);
|
|
84
|
+
if (!step)
|
|
85
|
+
return { reason: '这个操作已经不在了,等机主处理' };
|
|
86
|
+
const requester = card.by ? members.get(card.by) : undefined;
|
|
87
|
+
if (!requester || !requester.enabled)
|
|
88
|
+
return { reason: '提请的成员已不可用,等机主处理' };
|
|
89
|
+
let prepared;
|
|
90
|
+
try {
|
|
91
|
+
prepared = entry.prepare(step.op, step.args, { member: requester, topicId: message.topicId }, { resolved: true });
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return { reason: `当前条件已变化(${errorText(error)}),等机主处理` };
|
|
95
|
+
}
|
|
96
|
+
if (prepared.outside)
|
|
97
|
+
return { reason: '目标已超出发起者所在主题的直接操作范围,等机主处理' };
|
|
98
|
+
if ((step.targets || prepared.targets) && !sameIds(step.targets, prepared.targets)) {
|
|
99
|
+
return { reason: '受影响的主题范围已变化,等机主处理' };
|
|
100
|
+
}
|
|
101
|
+
if (!sameIds(data.subjects, prepared.subjects))
|
|
102
|
+
return { reason: '受影响的成员范围已变化,等机主处理' };
|
|
103
|
+
if ((prepared.op.grant || prepared.op.bind || step.grant !== undefined) && (prepared.binding ?? prepared.grant?.key ?? null) !== (step.grant ?? null)) {
|
|
104
|
+
return { reason: '批准的对象已变化,等机主处理' };
|
|
105
|
+
}
|
|
106
|
+
if (keyOf(prepared) !== data.key)
|
|
107
|
+
return { reason: '审批标的已变化,等机主处理' };
|
|
108
|
+
if (!prepared.sign)
|
|
109
|
+
return { reason: '会签已关闭,等机主处理' };
|
|
110
|
+
return { rule: prepared.sign, subjects: prepared.subjects ?? [] };
|
|
111
|
+
};
|
|
112
|
+
/** Members who may sign for this requester here, verified cross-family first, fewest busy first, and of as many families as there are. */
|
|
113
|
+
const candidates = (topicId, by, data, subjects, need) => {
|
|
114
|
+
const mine = familiesOf(by, data.turnId);
|
|
115
|
+
const busy = new Map();
|
|
116
|
+
for (const instance of instances.list())
|
|
117
|
+
if (instance.busy)
|
|
118
|
+
busy.set(instance.memberId, (busy.get(instance.memberId) ?? 0) + 1);
|
|
119
|
+
const pool = members.list()
|
|
120
|
+
.filter((member) => member.kind === 'agent' && member.enabled && member.id !== by && !subjects.includes(member.id) && a2a.worksIn(topicId, member.id))
|
|
121
|
+
.map((member) => ({ id: member.id, families: familiesOf(member.id, turnOf(topicId, member.id)), busy: busy.get(member.id) ?? 0 }))
|
|
122
|
+
.filter((one) => !sharedFamilies(one.families, mine).length)
|
|
123
|
+
.sort((a, b) => Number(b.families.length > 0) - Number(a.families.length > 0) || a.busy - b.busy);
|
|
124
|
+
const picked = [];
|
|
125
|
+
for (const one of pool)
|
|
126
|
+
if (picked.length < need && !picked.some((other) => sharedFamilies(other.families, one.families).length > 0))
|
|
127
|
+
picked.push(one);
|
|
128
|
+
for (const one of pool)
|
|
129
|
+
if (picked.length < need && !picked.includes(one))
|
|
130
|
+
picked.push(one);
|
|
131
|
+
return picked.length === need ? picked.map((one) => one.id) : [];
|
|
132
|
+
};
|
|
133
|
+
const namedProblem = (signers, topicId, by, data, need) => {
|
|
134
|
+
if (signers.length !== need)
|
|
135
|
+
return `要点名 ${need} 位签名人`;
|
|
136
|
+
if (new Set(signers).size !== signers.length)
|
|
137
|
+
return '点名的签名人不能重复';
|
|
138
|
+
const mine = familiesOf(by, data.turnId);
|
|
139
|
+
for (const id of signers) {
|
|
140
|
+
const member = members.get(id);
|
|
141
|
+
if (!member || member.kind !== 'agent' || !member.enabled)
|
|
142
|
+
return `${name(id)} 不是可用的成员`;
|
|
143
|
+
if (id === by || data.subjects?.includes(id))
|
|
144
|
+
return `${name(id)} 不能为这件事签名`;
|
|
145
|
+
if (!a2a.worksIn(topicId, id))
|
|
146
|
+
return `${name(id)} 不在这个主题的成员里`;
|
|
147
|
+
const families = familiesOf(id, turnOf(topicId, id));
|
|
148
|
+
const overlap = sharedFamilies(mine, families);
|
|
149
|
+
if (overlap.length)
|
|
150
|
+
return `${name(id)} 与你同属 ${overlap.join('、')} 系列,要点名其他系列的成员`;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* How a request is put to members, when its effective policy lets them sign: a card already waiting for the same
|
|
155
|
+
* thing, or the quorum and bookkeeping of a new one. Returns `undefined` when only the owner can approve it.
|
|
156
|
+
*/
|
|
157
|
+
const prepare = (request) => {
|
|
158
|
+
const { op, args, caller } = request;
|
|
159
|
+
const stale = op.stale?.(args);
|
|
160
|
+
if (stale)
|
|
161
|
+
throw new HttpError(409, `${stale},不用提请`);
|
|
162
|
+
const rule = request.sign;
|
|
163
|
+
if (!rule)
|
|
164
|
+
return undefined;
|
|
165
|
+
const key = keyOf(request);
|
|
166
|
+
const now = Date.now();
|
|
167
|
+
const until = state.cooldowns[key];
|
|
168
|
+
if (until && until > now)
|
|
169
|
+
throw new HttpError(409, `同一件事刚被拒绝过,冷却到 ${clock(until)} 之后才能再提请`);
|
|
170
|
+
for (const message of ours()) {
|
|
171
|
+
if (signData(message).key !== key)
|
|
172
|
+
continue;
|
|
173
|
+
if (closeExpired(message, now))
|
|
174
|
+
continue;
|
|
175
|
+
const step = stepsOf(cardOf(message))?.[0];
|
|
176
|
+
const gone = step ? declared(step.op)?.stale?.(step.args) : undefined;
|
|
177
|
+
if (gone) {
|
|
178
|
+
cards.close(message.id, `${gone},这张卡已失效`);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
return { existing: message.id };
|
|
182
|
+
}
|
|
183
|
+
const by = caller.member.id;
|
|
184
|
+
const topicId = caller.topicId;
|
|
185
|
+
const turnId = turnOf(topicId, by);
|
|
186
|
+
const expiresAt = now + expireMs();
|
|
187
|
+
const data = {
|
|
188
|
+
key, ...(turnId ? { turnId } : {}), ...(request.subjects?.length ? { subjects: request.subjects } : {}),
|
|
189
|
+
};
|
|
190
|
+
const quorum = { need: rule.members, who: [], onReject: rule.onReject, ...(rule.fields ? { fields: rule.fields } : {}) };
|
|
191
|
+
if (request.signers) {
|
|
192
|
+
const problem = namedProblem(request.signers, topicId, by, data, rule.members);
|
|
193
|
+
if (problem)
|
|
194
|
+
throw new ArgsError(problem);
|
|
195
|
+
return {
|
|
196
|
+
quorum: { ...quorum, who: request.signers, openedAt: now }, sign: data, inbox: rule.ownerInbox, expiresAt,
|
|
197
|
+
note: `机主可随时决定;已邀请 ${request.signers.map(name).join('、')} 签名`,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
data.opensAt = now + rule.wait * 60_000;
|
|
201
|
+
return {
|
|
202
|
+
quorum, sign: data, inbox: rule.ownerInbox, expiresAt,
|
|
203
|
+
note: `机主可随时决定。机主静默 ${quietMs() / 60_000} 分钟且卡发出 ${rule.wait} 分钟后,邀请 ${rule.members} 位其他系列的成员会签`,
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
/** Invite the signers of a card whose time has come; when it is not yet, when it will be. */
|
|
207
|
+
const open = (message) => {
|
|
208
|
+
if (closeExpired(message))
|
|
209
|
+
return;
|
|
210
|
+
const card = cardOf(message);
|
|
211
|
+
const step = stepsOf(card)?.[0];
|
|
212
|
+
const data = signData(message);
|
|
213
|
+
const op = step ? declared(step.op) : undefined;
|
|
214
|
+
const gone = op ? op.stale?.(step.args) : '这个操作已经不在了';
|
|
215
|
+
if (gone) {
|
|
216
|
+
cards.close(message.id, `${gone},这张卡已失效`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const live = liveScope(message);
|
|
220
|
+
const now = Date.now();
|
|
221
|
+
const quorum = card.quorum;
|
|
222
|
+
if ('reason' in live) {
|
|
223
|
+
cards.update(message.id, { quorum: { ...quorum, openedAt: now, blocked: live.reason } });
|
|
224
|
+
tell(message, 'blocked', `「${card.title}」未能开放成员会签:${live.reason}`);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
// The publicity period the rule in force now gives this call. If it is longer than the one recorded when the card
|
|
228
|
+
// was sent, hand back that period so the next tick writes it down and waits it out.
|
|
229
|
+
const opensAt = message.createdAt + live.rule.wait * 60_000;
|
|
230
|
+
const due = Math.max(opensAt, state.ownerActiveAt + quietMs());
|
|
231
|
+
if (due > now)
|
|
232
|
+
return opensAt;
|
|
233
|
+
const who = candidates(message.topicId, card.by, data, live.subjects, live.rule.members);
|
|
234
|
+
cards.update(message.id, {
|
|
235
|
+
quorum: { ...quorum, need: live.rule.members, who, openedAt: now, ...(who.length ? {} : { blocked: '没有足够的可签名成员,等机主处理' }) },
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
/** When the card may open to members: the publicity period recorded at send (or revised by `open`) plus the owner's quiet. */
|
|
239
|
+
const opensAtOf = (message) => {
|
|
240
|
+
const card = cardOf(message);
|
|
241
|
+
const data = signData(message);
|
|
242
|
+
if (!data || card.quorum?.openedAt !== undefined || data.opensAt === undefined)
|
|
243
|
+
return undefined;
|
|
244
|
+
return Math.max(data.opensAt, state.ownerActiveAt + quietMs());
|
|
245
|
+
};
|
|
246
|
+
let timer;
|
|
247
|
+
const tick = () => {
|
|
248
|
+
const now = Date.now();
|
|
249
|
+
for (const message of ours()) {
|
|
250
|
+
const data = signData(message);
|
|
251
|
+
try {
|
|
252
|
+
if (closeExpired(message, now)) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const opensAt = opensAtOf(message);
|
|
256
|
+
if (opensAt !== undefined && opensAt <= now) {
|
|
257
|
+
const later = open(message);
|
|
258
|
+
if (later !== undefined && later !== data.opensAt) {
|
|
259
|
+
cards.update(message.id, { data: { ...cardOf(message).data, sign: { ...data, opensAt: later } } });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
log('host-api', `the signing card ${message.id} could not be moved on`, error);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
arm();
|
|
268
|
+
};
|
|
269
|
+
const arm = () => {
|
|
270
|
+
clearTimeout(timer);
|
|
271
|
+
let next = Infinity;
|
|
272
|
+
for (const message of ours()) {
|
|
273
|
+
const expiresAt = expiredAt(message);
|
|
274
|
+
if (expiresAt !== undefined)
|
|
275
|
+
next = Math.min(next, expiresAt);
|
|
276
|
+
const opensAt = opensAtOf(message);
|
|
277
|
+
if (opensAt !== undefined)
|
|
278
|
+
next = Math.min(next, opensAt);
|
|
279
|
+
}
|
|
280
|
+
if (next === Infinity)
|
|
281
|
+
return;
|
|
282
|
+
timer = setTimeout(tick, Math.min(Math.max(0, next - Date.now()), 2 ** 31 - 1));
|
|
283
|
+
timer.unref();
|
|
284
|
+
};
|
|
285
|
+
ctx.effect(() => clearTimeout(timer));
|
|
286
|
+
/** Why members' votes cannot settle this card now, checked against the live policy and the turns they signed in. */
|
|
287
|
+
const refusal = (message, answer) => {
|
|
288
|
+
const at = expiredAt(message);
|
|
289
|
+
if (at !== undefined && at <= Date.now())
|
|
290
|
+
return '会签卡已过期';
|
|
291
|
+
const card = cardOf(message);
|
|
292
|
+
const data = signData(message);
|
|
293
|
+
const live = liveScope(message);
|
|
294
|
+
if ('reason' in live)
|
|
295
|
+
return live.reason;
|
|
296
|
+
const mine = familiesOf(card.by, data.turnId);
|
|
297
|
+
const signs = answer.signs ?? [];
|
|
298
|
+
let votes;
|
|
299
|
+
if (answer.approved) {
|
|
300
|
+
votes = signs.filter((one) => one.approved);
|
|
301
|
+
if (votes.length < live.rule.members)
|
|
302
|
+
return `会签现在要 ${live.rule.members} 票,等机主处理`;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
if (live.rule.onReject !== 'reject')
|
|
306
|
+
return '反对票不能直接拒绝,等机主处理';
|
|
307
|
+
votes = signs.filter((one) => !one.approved);
|
|
308
|
+
if (!votes.length)
|
|
309
|
+
return '没有有效的反对票,等机主处理';
|
|
310
|
+
}
|
|
311
|
+
for (const one of votes) {
|
|
312
|
+
if (!members.get(one.by)?.enabled)
|
|
313
|
+
return `${name(one.by)} 已停用,等机主处理`;
|
|
314
|
+
if (one.by === card.by || live.subjects.includes(one.by))
|
|
315
|
+
return `${name(one.by)} 不能为这件事签名,等机主处理`;
|
|
316
|
+
if (!a2a.worksIn(message.topicId, one.by))
|
|
317
|
+
return `${name(one.by)} 不在这个主题的成员里,等机主处理`;
|
|
318
|
+
const families = familiesOf(one.by, one.turnId);
|
|
319
|
+
const overlap = sharedFamilies(mine, families);
|
|
320
|
+
if (overlap.length)
|
|
321
|
+
return `${name(one.by)} 签名时与发起者同属 ${overlap.join('、')} 系列,等机主处理`;
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
const ownerInboxOff = (message) => {
|
|
325
|
+
const step = stepsOf(cardOf(message))?.[0];
|
|
326
|
+
const op = step ? declared(step.op) : undefined;
|
|
327
|
+
return op?.sign?.ownerInbox === false;
|
|
328
|
+
};
|
|
329
|
+
const tell = (message, key, text) => {
|
|
330
|
+
if (!ownerInboxOff(message))
|
|
331
|
+
notices.add({ from: sender, text, open: address.message(message.topicId, message.id), key: `host-api:${key}:${message.id}` });
|
|
332
|
+
};
|
|
333
|
+
const approvalMeta = (message) => {
|
|
334
|
+
const card = cardOf(message);
|
|
335
|
+
const step = stepsOf(card)?.[0];
|
|
336
|
+
if (!step || !card.by)
|
|
337
|
+
return undefined;
|
|
338
|
+
const turnId = card.data?.turnId ?? signData(message)?.turnId;
|
|
339
|
+
return { card: message.id, topicId: message.topicId, op: step.op, args: step.args, by: card.by, ...(turnId ? { turnId } : {}) };
|
|
340
|
+
};
|
|
341
|
+
ctx.on('config.changed', ({ scope, key }) => {
|
|
342
|
+
if (scope === 'settings' && (key === undefined || key.startsWith('approval.')))
|
|
343
|
+
arm();
|
|
344
|
+
});
|
|
345
|
+
ctx.on('message.appended', ({ message }) => {
|
|
346
|
+
if (message.from.kind === 'member' && message.from.id === OWNER_ID) {
|
|
347
|
+
state.ownerActiveAt = message.createdAt;
|
|
348
|
+
save();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
ctx.on('card.answered', ({ message, answer }) => {
|
|
352
|
+
if (answer.by === OWNER_ID) {
|
|
353
|
+
state.ownerActiveAt = answer.at;
|
|
354
|
+
save();
|
|
355
|
+
}
|
|
356
|
+
if (message.from.kind !== sender.kind || message.from.id !== sender.id)
|
|
357
|
+
return;
|
|
358
|
+
const data = signData(message);
|
|
359
|
+
if (data && !answer.approved) {
|
|
360
|
+
state.cooldowns = Object.fromEntries(Object.entries(state.cooldowns).filter(([, until]) => until > answer.at));
|
|
361
|
+
state.cooldowns[data.key] = answer.at + cooldownMs();
|
|
362
|
+
save();
|
|
363
|
+
}
|
|
364
|
+
const meta = approvalMeta(message);
|
|
365
|
+
if (meta) {
|
|
366
|
+
ctx.runtime.emit('approval.settled', {
|
|
367
|
+
...meta, resolution: answer.approved ? 'approved' : 'rejected', via: answer.via ?? 'owner', answer,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
arm();
|
|
371
|
+
});
|
|
372
|
+
ctx.on('card.closed', ({ message, note }) => {
|
|
373
|
+
if (message.from.kind !== sender.kind || message.from.id !== sender.id)
|
|
374
|
+
return;
|
|
375
|
+
const meta = approvalMeta(message);
|
|
376
|
+
if (meta) {
|
|
377
|
+
const at = expiredAt(message);
|
|
378
|
+
const expired = expiring.has(message.id) || (at !== undefined && at <= Date.now());
|
|
379
|
+
ctx.runtime.emit('approval.settled', {
|
|
380
|
+
...meta, resolution: expired ? 'expired' : 'withdrawn', ...(note ? { note } : {}),
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
arm();
|
|
384
|
+
});
|
|
385
|
+
ctx.on('card.signed', ({ message, card, signature }) => {
|
|
386
|
+
if (message.from.kind !== sender.kind || message.from.id !== sender.id || !card.quorum?.blocked)
|
|
387
|
+
return;
|
|
388
|
+
const text = !signature.approved && card.quorum.onReject !== 'reject'
|
|
389
|
+
? `${name(signature.by)} 反对「${card.title}」,成员会签已停止,等你裁决`
|
|
390
|
+
: `「${card.title}」成员会签未结算:${card.quorum.blocked}`;
|
|
391
|
+
tell(message, 'blocked', text);
|
|
392
|
+
});
|
|
393
|
+
// Approved before this start and never written about: it may or may not have been done. Say so once.
|
|
394
|
+
for (const message of cards.awaitingOutcome({ from: sender })) {
|
|
395
|
+
if (cardOf(message).answer.at >= started)
|
|
396
|
+
continue;
|
|
397
|
+
try {
|
|
398
|
+
cards.report(message.id, { outcome: { ok: false, unconfirmed: true, text: '执行期间宿主重启了,请核对后决定是否重新提请' } });
|
|
399
|
+
notices.add({ from: sender, text: `「${cardOf(message).title}」批准后宿主重启了,执行结果待确认`, open: address.message(message.topicId, message.id), key: `host-api:unconfirmed:${message.id}` });
|
|
400
|
+
}
|
|
401
|
+
catch (error) {
|
|
402
|
+
log('host-api', `the outcome of ${message.id} could not be marked unconfirmed`, errorText(error));
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
for (const message of ours()) {
|
|
406
|
+
try {
|
|
407
|
+
closeExpired(message, started);
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
log('host-api', `the expired signing card ${message.id} could not be closed`, error);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
arm();
|
|
414
|
+
return {
|
|
415
|
+
turnOf,
|
|
416
|
+
prepare,
|
|
417
|
+
arm,
|
|
418
|
+
refusal,
|
|
419
|
+
/** After members' votes settled it and it was carried out: the owner hears of it. */
|
|
420
|
+
settled(message, outcome) {
|
|
421
|
+
const answer = cardOf(message).answer;
|
|
422
|
+
if (answer.via !== 'quorum')
|
|
423
|
+
return;
|
|
424
|
+
tell(message, 'quorum', `${(answer.signs ?? []).filter((one) => one.approved).map((one) => name(one.by)).join('、')} 会签放行了「${cardOf(message).title}」:${outcome}`);
|
|
425
|
+
},
|
|
426
|
+
};
|
|
427
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: host-ops
|
|
3
|
+
description: 查或改宿主本身时用它:看有哪些插件、工具、配置项、注入点,日志和数据在哪,改了 hostlet 的代码之后重启宿主;删主题、撤销主题树的改动。讲 host_apis、host_api_info、host_invoke 三个工具怎么配合。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# host-ops
|
|
7
|
+
|
|
8
|
+
宿主自己能被要求做的事(控制台里人做的那些)是一份声明出来的接口,分组,名字是 `组.接口`,比如 `host.restart`。给成员的那一部分用 `hostlet` 工具组的三个工具调。
|
|
9
|
+
|
|
10
|
+
1. `host_apis` 看有哪些组,每组一句用途和组里的接口名;带 `group` 看这一组每个接口是干什么的。
|
|
11
|
+
2. `host_api_info` 看要用的那个接口的参数(`name` 写全:`host.restart`)。
|
|
12
|
+
3. `host_invoke` 调:`name`、`args`。参数不对时,退回来的话里带着这个接口的参数定义,照着改了再调,不用再查一遍。
|
|
13
|
+
|
|
14
|
+
带“(要批准)”的接口(成员、外部 MCP、skill 默认开关、插件开关、配置项这些影响全局的改动)照样用 `host_invoke` 调,多带一个 `why`,写一句话给人看为什么要做。每次提请都会在当前主题发一张独立的审批卡,人可以逐张批准或拒绝。调完可以接着做别的。人批准后,宿主执行该操作并把结果记在卡上。不批准时,卡上记答复和附言。答完的卡会交回仍启用的提请成员,叫醒它读结果和附言。
|
|
15
|
+
|
|
16
|
+
一张卡需要批准一组操作时,用 `host_invoke` 传 `title`、`why` 和 `options`。每个方案传 `label`、可选的 `detail` 和 `steps: [{ name, args }, …]`。机主批准一个方案,宿主按顺序执行,失败停在该步。空的 `steps` 表示保留原样。有操作的方案可填 `open`,全部成功后在本次作答的页面打开该站内地址。
|
|
17
|
+
|
|
18
|
+
要知道的:
|
|
19
|
+
|
|
20
|
+
- 你是以自己的身份、在当前主题里调的:宿主凭你的工具带的 token 认,不用也不能自己报身份。
|
|
21
|
+
- 清单里没有的操作请机主从控制台办理。操作有些参数须由机主提供时,`host_invoke` 只在 `args` 预填已知的公开参数,另传 `fill: [{ path: "/env", required: true }]` 请机主在审批卡补填。方案中的 `fill` 写在对应步骤。外部 MCP 的环境变量和请求头由机主在卡上输入并批准,编辑时将凭据设为可选,留空会保留已有值。
|
|
22
|
+
- 主题参数的可用范围见 `host_api_info`。摘要、能力开关等只作用于当前主题。`topics.update`、`topics.remove` 可直接改删你所在的主题和它下面的主题,移动目的地不限。`topics.ref_add` 可以为本题添加引用,为其他主题添加引用须获批。
|
|
23
|
+
- 安装、启用、停用插件或修改主题里的插件开关前,先向机主确认作用范围是全局,还是指定主题及其子主题。安装在宿主级完成,主题范围用 `topics.cap_set` 的 `plugin:<插件名>` 开关设置。填写 `on: null` 可恢复继承。
|
|
24
|
+
- 有的接口同时是工具(`host_api_info` 里会说,比如 `topics.update` 就是 `topic_update`):直接调那个工具。
|
|
25
|
+
- 用 `host.status` 查数据、暂存、缓存和日志的路径与期限,用 `host.storage` 按需查看磁盘占比、各类宿主数据和各主题的占用及可清理量(清理由机主在「设置 → 系统配置 → 存储空间」里确认)。用 shell 搜索 `paths.hostLog` 中的新日志,旧日志卷与它同目录,以 `host.log.` 开头。控制台报告以 `[console]` 标记。配置修改、成员增减和宿主启动等事件可用 `host.events` 查。
|
|
26
|
+
- 要重现控制台看到的:读的接口(GET)直接 `curl` 宿主的地址就行;全部接口的清单在 `GET /api/openapi.json`。改动的接口不要用 curl 调,那样宿主不知道是你。
|
|
27
|
+
- 改了宿主自己的代码(`src/core`、`src/runtime`、插件共用的代码)之后:`host_invoke`,`name` 是 `host.restart`,`args` 里带 `note`(重启后你要接着做什么)。它先试新代码起不起得来,起不来就不重启并把原因给你。调完把话说完、结束这一轮;起来后会在这个主题里叫你,不用再发起,也不用定时回来查。有没有重启在等、在等什么:`host.restart_status`。
|
|
28
|
+
- 只改了某个非核心插件自己的 `index.ts`:不用重启,`host_invoke` 调 `host.plugin_reload`,`args` 是 `{ "name": "插件名" }`,它停了再起、读新的代码,退回来的是它现在的状态。
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hostlet-plugin-dev
|
|
3
|
+
description: 为 Hostlet 开发或交付插件时使用,涵盖成员操作、随包使用 Skill、持久数据、安装依赖与 PDL 控件接线。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 开发 Hostlet 插件
|
|
7
|
+
|
|
8
|
+
## 让成员发现操作
|
|
9
|
+
|
|
10
|
+
在拥有业务行为的插件里用 `entry.op` 声明参数、执行和权限。成员可直接执行的操作用 `agent: true`,需要机主批准的操作用 `agent: 'approve'`,仅供机主调用的操作省略 `agent`。成员先用 `host_apis` 找操作组,再用 `host_api_info` 读目标操作的参数,最后调用 `host_invoke`。批准原因随 `why` 传入。只有高频且需要在工具列表里直达的操作,才在同一条声明上加 `tool: { server, name }`。
|
|
11
|
+
|
|
12
|
+
## 随包交付使用 Skill
|
|
13
|
+
|
|
14
|
+
给插件使用者的 Skill 放在包内 `skills/<name>/SKILL.md`,借 `ctx.hook('skills.dirs', () => join(ext.dir, 'skills'))` 提供目录。使用 Skill 从人的请求写起,说明先查什么、怎样推导参数、调用后如何读回结果。先读当前主题和它的引用仓库。例如处理 fork 的上游 PR,先核对当前工作树的 `origin` 与 `upstream`,从实际 PR 所在的远端确定仓库和编号,再按操作声明填参数。只在缺少会改变目标或权限范围的信息时追问。可参考宿主自带的 `signal-sources` Skill(源码位于 `src/plugins/signals/skills/signal-sources/SKILL.md`)。
|
|
15
|
+
|
|
16
|
+
## 包目录与持久目录
|
|
17
|
+
|
|
18
|
+
`ext.dir` 是安装包根目录,用于入口、静态资源和随包 Skill。覆盖安装会替换包目录。用工厂收到的 `home.path('data', ext.id)` 保存外部插件的 SQLite、同步状态等业务数据,写入前按需建立目录。配置仍由 `plugin.yaml` 声明并保存到 `plugins/<id>/settings.json`,密钥随宿主管理在 `secrets/<id>.json`,从 `ext.config` 和 `ext.secrets` 读取。保存配置后宿主不会重启插件:每次使用前现读的 key 自然生效;只在启动时读取的 key(连接、子进程参数、注册内容)要在 `start` 里监听 `config.changed`,scope 是 `plugin:<id>` 且 key 属于受影响项时调 `ext.reload()` 请宿主重启自己;插件运行时自己写入的 key 不要触发,避免重启循环。覆盖升级时核对业务记录。
|
|
19
|
+
|
|
20
|
+
## 声明插件主题
|
|
21
|
+
|
|
22
|
+
插件长期维护的主题在 `plugin.yaml` 声明 `topic: { title, summary, pinned?, view? }`;有自定义主视图时写 `view.main`,也可给面板和参数。启动时用 `ext.topic()` 取得主题,宿主会复用已绑定主题,或在首次创建时按需建出宿主维护的顶层「系统」容器主题(`system: true`,默认不置顶、无相关能力调用时不预建)并将插件主题默认建在「系统」下,不再默认铺在顶层。默认父主题与标题、摘要、置顶、视图一样只在创建时生效,用户后续可自由改名、移动或置顶;若「系统」主题在垃圾桶则重建并清旧标记,若已归档或处于最大层级放不下子主题则退回建在顶层并记宿主日志。主题的 `plugin` 与 `system` 标记只由宿主写入,插件不保存主题编号。不要绕过 `ext.topic()` 自行往顶层建主题,也不要按标题或视图猜主题。卸载时宿主只归档这个主题,重新安装会恢复卸载造成的归档,插件不用再处理。旧版本自存主题编号的插件,升级时由一次性停机脚本把绑定写入存量主题。
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 验安装后的依赖
|
|
26
|
+
|
|
27
|
+
外部插件可从 `hostlet/sdk` 引入类型和运行时工具。宿主会将运行时导入解析到当前进程的 SDK,和插件共用同一模块实例。插件依赖的宿主服务在 `needs` 声明,再用 `ctx.get` 使用。Node 内置模块和包内相对模块可直接解析。其余 npm 运行时依赖随安装包交付,例如构建时打包。没有此类依赖的插件可直接交付。用独立数据目录安装交付物并试启,确认入口和依赖都能解析。
|
|
28
|
+
|
|
29
|
+
## 绑定 PDL 控件
|
|
30
|
+
|
|
31
|
+
复用组件库的控件,以 PDL 声明布局。插件自己的图标和控件处理器用 `ui.key(name)` 生成 `plugin:<id>/` 命名空间下的键,组件库图标沿用库里的名称。分段选择和开关的 `act` 对应插件模块的 `actions`。选择框的 `change` 生成 `data-change`,对应插件模块的 `changes`。在隔离宿主实际切换选项,核对状态及条件字段的出现和消失。
|
|
32
|
+
|
|
33
|
+
列表块声明 `scroll: true` 时,从 `.vw-scroll` 到 `.page`、`.panel-body` 或 `.dialog-body` 的实体容器必须处在可收缩的 flex 纵列链上。不要在列表外包普通容器;自定义中间容器要有 `display: flex; flex-direction: column; min-height: 0`,列表自身用 `flex: 0 1 auto; min-height: 0`。外层含 `.vw-scroll` 时会锁成 `overflow: hidden`,断链会把列表底部裁掉且滚不到。组件库在窗口低于 540 像素时退回外层滚动,插件不用另写一套。验收时在正常窗口确认只有列表滚动、顶栏与搜索固定,再缩到矮窗口确认末行仍能到达。
|
|
34
|
+
|
|
35
|
+
界面结构遵循三条统一规范:
|
|
36
|
+
- **标题层级**:页面或分栏(`split`)顶层用 `head`(无 `variant`);页面内的各个小节统一用 `section`,不要把页面级 `head` 放进弹窗视图(`dlg.*` / `popup`)或 `box`、`section`、`disclosure`、`fold`、`dialog` 等子容器里,避免同页小节标题大小不一。
|
|
37
|
+
- **键值与设置**:只读状态键值直接用 `kv`(组件库默认套用与 `settings`/`list` 一致的分组底板 `--surf-group`,嵌在卡片、弹窗、展开行或折叠区时自动无底板,无须另做卡片样式);带交互控件的配置行用 `settings`。
|
|
38
|
+
- **说明性文字**:口径解释、操作引导和背景提示优先收进 `head.help`、`section.help`、`label.help` 或弹窗 `help`(`?` 悬停),避免在页面或弹窗正文里堆砌裸 `text(meta)` 说明段落。
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin, Runtime } from 'hostlet/sdk';
|
|
2
|
+
export declare function inboxFor(runtime: Runtime, memberId: string, topicId?: string): {
|
|
3
|
+
topicId: string;
|
|
4
|
+
messageId: string;
|
|
5
|
+
from: {
|
|
6
|
+
kind: "member" | "system";
|
|
7
|
+
id: string;
|
|
8
|
+
} & {};
|
|
9
|
+
mentioned: boolean;
|
|
10
|
+
excerpt: string;
|
|
11
|
+
content: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
}[];
|
|
14
|
+
declare const inboxPlugin: Plugin;
|
|
15
|
+
export default inboxPlugin;
|