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,310 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { ArgsError, array, errorText, fillRequestSchema, HttpError, memberInput, object, operationErrorText, OWNER_ID } from 'hostlet/sdk';
|
|
3
|
+
import { signing } from "./signing.js";
|
|
4
|
+
const string = { type: 'string' };
|
|
5
|
+
const argsObject = { type: 'object', description: '操作的参数,形式与单独调用相同' };
|
|
6
|
+
const fill = array(fillRequestSchema);
|
|
7
|
+
const invokeInput = object({
|
|
8
|
+
name: string, args: argsObject, fill,
|
|
9
|
+
why: { ...string, description: '要批准时,写一句给人看的理由' },
|
|
10
|
+
title: { ...string, description: '提供 options 时,概括希望机主决定的事项' },
|
|
11
|
+
options: array(object({
|
|
12
|
+
label: string, detail: string,
|
|
13
|
+
steps: array(object({ name: string, args: argsObject, fill }, ['name'])),
|
|
14
|
+
open: { ...string, description: '此选项全部执行成功后在作答页面打开的 Hostlet 地址,例如 #chat-top_…' },
|
|
15
|
+
}, ['label', 'steps'])),
|
|
16
|
+
});
|
|
17
|
+
function approvalItem({ op, args, asked, note, inputs }, caller, why) {
|
|
18
|
+
const summary = op.approval?.(args, asked, caller) ?? {};
|
|
19
|
+
const target = summary.target?.trim() || note;
|
|
20
|
+
const impact = summary.impact?.trim();
|
|
21
|
+
const risk = [summary.risk?.trim(), target !== note && note].filter(Boolean).join('\n');
|
|
22
|
+
const fields = [];
|
|
23
|
+
if (why)
|
|
24
|
+
fields.push({ label: '理由', value: why });
|
|
25
|
+
if (target)
|
|
26
|
+
fields.push({ label: '目标', value: target });
|
|
27
|
+
if (impact)
|
|
28
|
+
fields.push({ label: '影响', value: impact });
|
|
29
|
+
if (risk)
|
|
30
|
+
fields.push({ label: '风险', value: risk, tone: 'warn' });
|
|
31
|
+
const title = summary.title?.trim() || `执行 ${op.name}`;
|
|
32
|
+
const code = { label: '操作参数(JSON)', text: JSON.stringify(asked, null, 2) };
|
|
33
|
+
return { title, fields, code, ...(inputs && { inputs }) };
|
|
34
|
+
}
|
|
35
|
+
function secretFields(schema, prefix = '') {
|
|
36
|
+
return Object.entries(schema.properties ?? {}).flatMap(([key, field]) => {
|
|
37
|
+
const path = prefix + '/' + key.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
38
|
+
return field.secret ? (field.type === 'string' ? [`${path} — ${field.description || key}`] : []) : secretFields(field, path);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** An operation that binds what it acts on always carries its snapshot, `null` when there was nothing to bind to. */
|
|
42
|
+
function approvalStep({ op, args, targets, grant, binding }) {
|
|
43
|
+
return { op: op.name, args, ...(targets ? { targets } : {}), ...(op.grant || op.bind ? { grant: binding ?? grant?.key ?? null } : {}) };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The host's own operations, for members: what the console does over HTTP is declared once (`entry.op`), and a
|
|
47
|
+
* member reaches the ones meant for it through three tools — which groups there are, what one operation takes,
|
|
48
|
+
* and calling it. The call goes to the same implementation the console's route does, as this member in its topic.
|
|
49
|
+
*/
|
|
50
|
+
export default function hostApiPlugin(home) {
|
|
51
|
+
return {
|
|
52
|
+
name: 'host-api',
|
|
53
|
+
title: '宿主接口',
|
|
54
|
+
about: '成员查和改宿主本身的入口:host_apis 看有哪些接口,host_api_info 看一个接口的参数,host_invoke 调。接口和控制台用的是同一份声明。',
|
|
55
|
+
group: '给成员的工具',
|
|
56
|
+
needs: ['entry', 'config', 'tools', 'cards', 'members', 'models', 'a2a', 'instances', 'notices'],
|
|
57
|
+
start(ctx) {
|
|
58
|
+
const { sender } = ctx.get('members').register(ctx, { name: '审批', handle: 'approval', icon: 'shieldCheck', color: { primary: '#626f9c' } });
|
|
59
|
+
const entry = ctx.get('entry');
|
|
60
|
+
const cards = ctx.get('cards');
|
|
61
|
+
const members = ctx.get('members');
|
|
62
|
+
const tools = ctx.get('tools');
|
|
63
|
+
const tool = (decl) => ctx.effect(tools.register('hostlet', { ...decl, plugin: 'host-api' }));
|
|
64
|
+
// Overrides in the host settings that do not take effect as written are said once, and again when they change.
|
|
65
|
+
const notices = ctx.get('notices');
|
|
66
|
+
const noticeKey = 'host-api.rules';
|
|
67
|
+
const reportOverrides = () => {
|
|
68
|
+
const ignored = entry.overrideProblems();
|
|
69
|
+
if (ignored.length)
|
|
70
|
+
notices.add({ key: noticeKey, from: sender, text: `审批例外里有 ${ignored.length} 条不生效:\n${ignored.join('\n')}` });
|
|
71
|
+
else
|
|
72
|
+
notices.removeKey(noticeKey);
|
|
73
|
+
};
|
|
74
|
+
reportOverrides();
|
|
75
|
+
ctx.on('config.changed', ({ scope, key }) => { if (scope === 'settings' && (key === undefined || key === 'approval.rules'))
|
|
76
|
+
reportOverrides(); });
|
|
77
|
+
const reason = (caller) => {
|
|
78
|
+
const why = typeof caller.why === 'string' ? caller.why.trim() : '';
|
|
79
|
+
if (!why)
|
|
80
|
+
throw new ArgsError('要人批准的操作要带 why,写一句给人看的理由');
|
|
81
|
+
return why;
|
|
82
|
+
};
|
|
83
|
+
const withdrawHint = '要发新卡取代自己之前还没答的卡时,先用 host_invoke 调 cards.withdraw 撤回旧卡。';
|
|
84
|
+
const receipt = (id) => `已提请审批(消息 ${id})。批准后宿主会自动执行。无论批准还是不批准,都会把审批卡结果交回给你。可以接着做别的。${withdrawHint}`;
|
|
85
|
+
const signer = signing(ctx, home, sender);
|
|
86
|
+
ctx.effect(entry.approver((request) => {
|
|
87
|
+
const { op, caller } = request;
|
|
88
|
+
const member = caller.member;
|
|
89
|
+
const topicId = caller.topicId;
|
|
90
|
+
const step = approvalStep(request);
|
|
91
|
+
const why = reason(caller);
|
|
92
|
+
const signed = signer.prepare(request);
|
|
93
|
+
if (signed && 'existing' in signed) {
|
|
94
|
+
return `同一件事已经有一张待签卡(消息 ${signed.existing}),不另发。要换内容,先用 host_invoke 调 cards.withdraw 撤回它再提请。`;
|
|
95
|
+
}
|
|
96
|
+
const { title, ...item } = approvalItem(request, caller, why);
|
|
97
|
+
const { fields } = item;
|
|
98
|
+
if (signed)
|
|
99
|
+
fields.push({ label: '会签', value: signed.note });
|
|
100
|
+
const standing = request.standing;
|
|
101
|
+
const turnId = signed?.sign.turnId ?? signer.turnOf(topicId, member.id);
|
|
102
|
+
const message = cards.send({
|
|
103
|
+
topicId, from: sender,
|
|
104
|
+
card: {
|
|
105
|
+
kind: 'approval', title, by: member.id,
|
|
106
|
+
items: [item],
|
|
107
|
+
approve: '批准并执行', reject: '不批准',
|
|
108
|
+
...(standing ? { remember: `以后都允许:${standing.label}` } : {}),
|
|
109
|
+
data: {
|
|
110
|
+
steps: [step],
|
|
111
|
+
...(standing ? { standing: { ...(standing.key === undefined ? {} : { key: standing.key }), label: standing.label } } : {}),
|
|
112
|
+
...(signed ? { sign: signed.sign } : {}),
|
|
113
|
+
...(turnId ? { turnId } : {}),
|
|
114
|
+
},
|
|
115
|
+
...(signed ? { quorum: signed.quorum, expiresAt: signed.expiresAt } : {}),
|
|
116
|
+
},
|
|
117
|
+
...(signed?.inbox === false ? { inbox: false } : {}),
|
|
118
|
+
});
|
|
119
|
+
if (signed)
|
|
120
|
+
signer.arm();
|
|
121
|
+
ctx.runtime.emit('approval.requested', {
|
|
122
|
+
card: message.id, topicId, op: op.name, args: step.args, by: member.id, ...(turnId ? { turnId } : {}),
|
|
123
|
+
});
|
|
124
|
+
return receipt(message.id);
|
|
125
|
+
}));
|
|
126
|
+
const selection = (card, answer) => {
|
|
127
|
+
const choice = answer.picked?.[0];
|
|
128
|
+
const steps = choice === undefined ? card.data.steps : card.data.options[choice];
|
|
129
|
+
return { steps, items: card.items.filter((item) => item.option === choice) };
|
|
130
|
+
};
|
|
131
|
+
const approvedCaller = (message, answer, member, step) => ({
|
|
132
|
+
member, topicId: message.topicId, approved: answer.via === 'quorum' ? `card:${message.id}` : answer.by,
|
|
133
|
+
approvalCard: message.id, approvedTargets: step.targets, ...(step.grant === undefined ? {} : { grant: step.grant }),
|
|
134
|
+
});
|
|
135
|
+
const submission = (item, inputs) => item.inputs?.length ? { fill: item.inputs, values: inputs?.[item.id] ?? {} } : undefined;
|
|
136
|
+
const completeApproval = async ({ message, card, answer }, inputs) => {
|
|
137
|
+
if (!answer.approved)
|
|
138
|
+
return;
|
|
139
|
+
const { steps, items } = selection(card, answer);
|
|
140
|
+
if (!steps.length)
|
|
141
|
+
return { ok: true, text: '未执行任何操作' };
|
|
142
|
+
const member = members.get(card.by);
|
|
143
|
+
if (!member)
|
|
144
|
+
return { ok: false, text: '提请的成员已经被移除' };
|
|
145
|
+
for (const [i, step] of steps.entries()) {
|
|
146
|
+
const { op, args } = step;
|
|
147
|
+
const item = items[i];
|
|
148
|
+
const { id } = item;
|
|
149
|
+
let result;
|
|
150
|
+
try {
|
|
151
|
+
await entry.invoke(op, args, approvedCaller(message, answer, member, step), submission(item, inputs));
|
|
152
|
+
result = { ok: true };
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
result = { ok: false, text: errorText(error) };
|
|
156
|
+
}
|
|
157
|
+
const outcome = !result.ok
|
|
158
|
+
? (steps.length === 1 ? result : { ok: false, text: `第 ${i + 1} 步「${items[i].title ?? step.op}」失败:${result.text}` })
|
|
159
|
+
: i + 1 === steps.length ? { ok: true, text: steps.length === 1 ? '已执行' : `已完成全部 ${steps.length} 步` } : undefined;
|
|
160
|
+
if (result.ok && outcome && answer.remember && answer.by === OWNER_ID) {
|
|
161
|
+
// Only the key shown on the card and checked just now is kept: nothing is worked out again afterwards.
|
|
162
|
+
const standing = card.data.standing;
|
|
163
|
+
if (standing) {
|
|
164
|
+
// The step ran either way; failing to keep the permission is said next to its result, not instead of it.
|
|
165
|
+
try {
|
|
166
|
+
entry.remember({ op, ...(standing.key === undefined ? {} : { key: standing.key }), label: standing.label, card: message.id });
|
|
167
|
+
outcome.text = `${outcome.text},以后${standing.label}不再需要批准(可在宿主设置的「审批例外」里撤回)`;
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
outcome.text = `${outcome.text}。以后都允许没有保存:${errorText(error)},下次仍需批准`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const written = cards.report(message.id, { results: { [id]: result }, outcome });
|
|
175
|
+
if (outcome)
|
|
176
|
+
signer.settled(written, outcome.ok ? outcome.text ?? '已执行' : `失败:${outcome.text}`);
|
|
177
|
+
if (!result.ok)
|
|
178
|
+
break;
|
|
179
|
+
const how = answer.via === 'quorum'
|
|
180
|
+
? `经 ${(answer.signs ?? []).filter((one) => one.approved).map((one) => members.get(one.by)?.name ?? one.by).join('、')} 会签`
|
|
181
|
+
: '经批准';
|
|
182
|
+
tools.recordEvent('approval', `${member.name} 提请的 ${op} ${how}执行了(审批卡 ${message.id})`);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
ctx.on('card.answering', ({ message, answer, accept, acceptInputs, refuse }) => {
|
|
186
|
+
if (message.from.kind !== sender.kind || message.from.id !== sender.id)
|
|
187
|
+
return;
|
|
188
|
+
if (acceptInputs) {
|
|
189
|
+
acceptInputs(ctx, (inputs) => {
|
|
190
|
+
const card = message.parts[0];
|
|
191
|
+
const member = members.get(card.by);
|
|
192
|
+
if (!member?.enabled)
|
|
193
|
+
throw new HttpError(409, '提请的成员已停用或移除');
|
|
194
|
+
const { steps, items } = selection(card, answer);
|
|
195
|
+
for (const [i, step] of steps.entries()) {
|
|
196
|
+
entry.prepare(step.op, step.args, approvedCaller(message, answer, member, step), submission(items[i], inputs));
|
|
197
|
+
}
|
|
198
|
+
return (answered) => completeApproval(answered, inputs);
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const refused = answer.via === 'quorum' ? signer.refusal(message, answer) : undefined;
|
|
203
|
+
if (refused && refuse)
|
|
204
|
+
refuse(refused);
|
|
205
|
+
else
|
|
206
|
+
accept(completeApproval);
|
|
207
|
+
});
|
|
208
|
+
/** What a member can call, by group, in the order declared. */
|
|
209
|
+
const open = (topicId) => {
|
|
210
|
+
const { groups, ops } = entry.ops(topicId);
|
|
211
|
+
return groups.map((group) => ({ ...group, ops: ops.filter((op) => op.agent && op.name.startsWith(`${group.name}.`)) })).filter((group) => group.ops.length);
|
|
212
|
+
};
|
|
213
|
+
/** The operation by its full name, when a member can call it; when it cannot, why, and what there is instead. */
|
|
214
|
+
const find = (name, topicId) => {
|
|
215
|
+
const groups = open(topicId);
|
|
216
|
+
const found = groups.flatMap((group) => group.ops).find((op) => op.name === name);
|
|
217
|
+
if (found)
|
|
218
|
+
return found;
|
|
219
|
+
const group = groups.find((one) => one.name === name.split('.')[0]);
|
|
220
|
+
const closed = entry.ops(topicId).ops.some((op) => op.name === name);
|
|
221
|
+
throw new Error(`${closed ? `${name} 不给成员直接调:请人在控制台里做` : `没有 ${name}`}。${group ? `${group.name} 这一组有:${group.ops.map((op) => op.name).join('、')}` : `名字是 组.接口(比如 host.restart),有这些组:${groups.map((one) => one.name).join('、')}`}`);
|
|
222
|
+
};
|
|
223
|
+
const alsoTool = (op) => (op.tool ? `它也是工具:${op.tool.server} 组的 ${op.tool.name},直接调那个就行。` : '');
|
|
224
|
+
const approvalMark = (op) => op.agent === 'approve' ? (entry.signPolicy(op.name) ? '(要批准,可由成员会签)' : '(要批准)') : '';
|
|
225
|
+
/** What a member needs to call one: its arguments as a member gives them (the topic it is done to is the member's own). */
|
|
226
|
+
const describe = (op) => {
|
|
227
|
+
const sign = entry.signPolicy(op.name);
|
|
228
|
+
return [
|
|
229
|
+
`${op.name} — ${op.about}`,
|
|
230
|
+
op.agent === 'approve' ? '要批准。调 host_invoke 时带上 why,写一句给人看的理由。' : '',
|
|
231
|
+
sign ? `机主可随时决定;机主一段时间没处理时,宿主会邀请 ${sign.members} 位其他模型系列的成员会签。` : '',
|
|
232
|
+
`参数(JSON Schema):${JSON.stringify(memberInput(op.input, op))}`,
|
|
233
|
+
...secretFields(op.input).map((field) => `可用 fill 请机主补填密钥:${field}`),
|
|
234
|
+
`控制台调的是:${op.http.join(' ')}`, alsoTool(op),
|
|
235
|
+
].filter(Boolean).join('\n');
|
|
236
|
+
};
|
|
237
|
+
tool({
|
|
238
|
+
name: 'host_apis',
|
|
239
|
+
description: '宿主自己有哪些接口可以调(查和改宿主本身和主题:现状、重启、插件、配置项、主题树……)。不带参数:每一组的用途和组里的接口名;带 group:这一组每个接口是干什么的。然后用 host_api_info 看参数,host_invoke 调。',
|
|
240
|
+
input: object({ group: { type: 'string', description: '组名,比如 host' } }),
|
|
241
|
+
run({ group }, { topicId }) {
|
|
242
|
+
const groups = open(topicId);
|
|
243
|
+
if (group === undefined)
|
|
244
|
+
return groups.map((one) => `${one.name} — ${one.about}\n ${one.ops.map((op) => `${op.name.slice(one.name.length + 1)}${approvalMark(op)}`).join(' · ')}`).join('\n') || '(现在没有给成员的接口)';
|
|
245
|
+
const found = groups.find((one) => one.name === group);
|
|
246
|
+
if (!found)
|
|
247
|
+
throw new Error(`没有 ${group} 这一组,有:${groups.map((one) => one.name).join('、')}`);
|
|
248
|
+
return `${found.name} — ${found.about}\n${found.ops.map((op) => `- ${op.name}${approvalMark(op)}:${op.about}${op.tool ? `(也是工具 ${op.tool.name})` : ''}`).join('\n')}`;
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
tool({
|
|
252
|
+
name: 'host_api_info',
|
|
253
|
+
description: '一个宿主接口的完整说明和参数。name 是 组.接口,比如 host.restart。',
|
|
254
|
+
input: object({ name: { type: 'string' } }, ['name']),
|
|
255
|
+
run: ({ name }, { topicId }) => describe(find(name, topicId)),
|
|
256
|
+
});
|
|
257
|
+
tool({
|
|
258
|
+
name: 'host_invoke',
|
|
259
|
+
description: `调一个宿主接口时传 name 和 args,要批准时带 why。机主补填的文本或密钥用 fill: [{path, label?, description?, required?}],如 /env。只填已知 args,机主在卡上补全后批准。方案用 title、why 和 options,每个选项的 steps 可各带 fill,空步骤表示保留原样。用 host_apis 查操作,用 host_api_info 查参数。调用始终沿用你在当前主题的身份。${withdrawHint}`,
|
|
260
|
+
input: invokeInput,
|
|
261
|
+
async run(input, caller) {
|
|
262
|
+
const { name, args, fill, why, title, options } = input;
|
|
263
|
+
if (options !== undefined) {
|
|
264
|
+
if (name !== undefined || args !== undefined || fill !== undefined)
|
|
265
|
+
throw new ArgsError('提请方案用 options,字段声明随具体步骤填写');
|
|
266
|
+
if (!title?.trim() || !options.length)
|
|
267
|
+
throw new ArgsError('提请方案需要标题(title)和选项(options)');
|
|
268
|
+
const requester = { ...caller, why };
|
|
269
|
+
const body = reason(requester);
|
|
270
|
+
const stepsByOption = {};
|
|
271
|
+
const items = [];
|
|
272
|
+
const offered = options.map(({ label, detail, steps, open }, index) => {
|
|
273
|
+
const id = String(index + 1);
|
|
274
|
+
stepsByOption[id] = steps.map(({ name: op, args, fill }) => {
|
|
275
|
+
const prepared = entry.prepare(op, args, requester, { fill });
|
|
276
|
+
if (prepared.op.signers)
|
|
277
|
+
throw new ArgsError(`${op} 指定了签名人,请单独提请`);
|
|
278
|
+
items.push({ ...approvalItem(prepared, requester), option: id });
|
|
279
|
+
return approvalStep(prepared);
|
|
280
|
+
});
|
|
281
|
+
return { id, label, detail, open: steps.length ? open : undefined };
|
|
282
|
+
});
|
|
283
|
+
if (!items.length)
|
|
284
|
+
throw new ArgsError('至少一个选项需要有操作');
|
|
285
|
+
const message = cards.send({
|
|
286
|
+
topicId: caller.topicId, from: sender,
|
|
287
|
+
card: { kind: 'approval', title, by: caller.member.id, body, options: offered, items, data: { options: stepsByOption } },
|
|
288
|
+
});
|
|
289
|
+
return receipt(message.id);
|
|
290
|
+
}
|
|
291
|
+
if (!name)
|
|
292
|
+
throw new ArgsError('缺少 name');
|
|
293
|
+
try {
|
|
294
|
+
return await entry.say(name, args ?? {}, { ...caller, why }, { fill });
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
// Said so that it need not ask again: no such name, what there is; wrong arguments, what it takes. Anything
|
|
298
|
+
// else (not for members, cannot be done now) is said by whoever refused.
|
|
299
|
+
const op = entry.ops(caller.topicId).ops.find((one) => one.name === name);
|
|
300
|
+
if (!op && !(error instanceof HttpError && error.status === 403))
|
|
301
|
+
find(name, caller.topicId);
|
|
302
|
+
throw op && error instanceof ArgsError ? new Error(`${operationErrorText(error)}\n${describe(op)}`) : error;
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
// Skills that ship with the host interface (host-ops, hostlet-plugin-dev) and go with it.
|
|
307
|
+
ctx.hook('skills.dirs', () => fileURLToPath(new URL('./skills', import.meta.url)));
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CardAnswer, Ctx, Home, Message, PreparedOp, Sender } from 'hostlet/sdk';
|
|
2
|
+
/** What the approval provider keeps on a card members may sign. */
|
|
3
|
+
export interface SignData {
|
|
4
|
+
/** What is approved: a second card for it is not sent, and a refusal cools it down. */
|
|
5
|
+
key: string;
|
|
6
|
+
/** The requester's turn when it asked: its model is what signers have to differ from. */
|
|
7
|
+
turnId?: string;
|
|
8
|
+
subjects?: string[];
|
|
9
|
+
/** When members may be invited, for a card whose signers the host picks. */
|
|
10
|
+
opensAt?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const signData: (message: Message) => SignData | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Who besides the owner may approve, for operations whose effective policy allows co-signing. The owner can always
|
|
15
|
+
* answer and settles a card at once. Members are invited only when the owner has been quiet and the operation's wait
|
|
16
|
+
* has passed (or at once, when the operation names its signers); their votes are checked against the live policy and
|
|
17
|
+
* effective models (turn-reported > configured > latest reported) just before the card settles, blocking overlapping
|
|
18
|
+
* verified families and falling back to distinct members when either side has no verified families yet.
|
|
19
|
+
*/
|
|
20
|
+
export declare function signing(ctx: Ctx, home: Home, sender: Sender): {
|
|
21
|
+
turnOf: (topicId: string | undefined, memberId: string) => string | undefined;
|
|
22
|
+
prepare: (request: PreparedOp & {
|
|
23
|
+
caller: {
|
|
24
|
+
member?: {
|
|
25
|
+
id: string;
|
|
26
|
+
};
|
|
27
|
+
topicId?: string;
|
|
28
|
+
};
|
|
29
|
+
}) => {
|
|
30
|
+
existing: string;
|
|
31
|
+
quorum?: undefined;
|
|
32
|
+
sign?: undefined;
|
|
33
|
+
inbox?: undefined;
|
|
34
|
+
expiresAt?: undefined;
|
|
35
|
+
note?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
quorum: {
|
|
38
|
+
need: number;
|
|
39
|
+
who: string[];
|
|
40
|
+
} & {
|
|
41
|
+
openedAt?: number | undefined;
|
|
42
|
+
onReject?: "block" | "reject" | undefined;
|
|
43
|
+
fields?: ({
|
|
44
|
+
key: string;
|
|
45
|
+
label: string;
|
|
46
|
+
when: "reject" | "approve" | "always";
|
|
47
|
+
} & {
|
|
48
|
+
options?: string[] | undefined;
|
|
49
|
+
required?: boolean | undefined;
|
|
50
|
+
})[] | undefined;
|
|
51
|
+
blocked?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
sign: SignData;
|
|
54
|
+
inbox: false | undefined;
|
|
55
|
+
expiresAt: number;
|
|
56
|
+
note: string;
|
|
57
|
+
existing?: undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
arm: () => void;
|
|
60
|
+
refusal: (message: Message, answer: CardAnswer) => string | undefined;
|
|
61
|
+
/** After members' votes settled it and it was carried out: the owner hears of it. */
|
|
62
|
+
settled(message: Message, outcome: string): void;
|
|
63
|
+
};
|