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,247 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { array, object } from 'hostlet/sdk';
|
|
5
|
+
/** Built-in plugin that serves the live console static files from disk. */
|
|
6
|
+
export const CONSOLE_PLUGIN = 'console';
|
|
7
|
+
const byName = (a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
8
|
+
/** Deterministic SHA-256 content digest of every regular file under a directory, independent of Git. */
|
|
9
|
+
export function directoryDigest(dir, length = 12) {
|
|
10
|
+
if (!existsSync(dir))
|
|
11
|
+
return undefined;
|
|
12
|
+
const hash = createHash('sha256');
|
|
13
|
+
let count = 0;
|
|
14
|
+
const walk = (current, prefix) => {
|
|
15
|
+
for (const ent of readdirSync(current, { withFileTypes: true }).sort(byName)) {
|
|
16
|
+
if (ent.name === '.DS_Store')
|
|
17
|
+
continue;
|
|
18
|
+
const rel = prefix ? `${prefix}/${ent.name}` : ent.name;
|
|
19
|
+
const full = join(current, ent.name);
|
|
20
|
+
if (ent.isDirectory())
|
|
21
|
+
walk(full, rel);
|
|
22
|
+
else if (ent.isFile()) {
|
|
23
|
+
const content = readFileSync(full);
|
|
24
|
+
hash.update(rel);
|
|
25
|
+
hash.update('\0');
|
|
26
|
+
hash.update(String(content.length));
|
|
27
|
+
hash.update('\0');
|
|
28
|
+
hash.update(content);
|
|
29
|
+
hash.update('\0');
|
|
30
|
+
count++;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
walk(dir, '');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
return count ? hash.digest('hex').slice(0, length) : undefined;
|
|
41
|
+
}
|
|
42
|
+
/** Combine the live console static assets digest with the loaded console plugin digest when available. */
|
|
43
|
+
export function consoleVersion(assetsHash, serverHash) {
|
|
44
|
+
if (!assetsHash)
|
|
45
|
+
return undefined;
|
|
46
|
+
return serverHash ? `console@${serverHash}+${assetsHash}` : `assets@${assetsHash}`;
|
|
47
|
+
}
|
|
48
|
+
/** Fallback digest for an external plans plugin that does not sit beside the host's console/ folder. */
|
|
49
|
+
export async function fetchConsoleAssetsDigest(baseUrl, length = 12) {
|
|
50
|
+
const signal = AbortSignal.timeout(3_000);
|
|
51
|
+
try {
|
|
52
|
+
const rootRes = await fetch(`${baseUrl}/`, { signal });
|
|
53
|
+
if (!rootRes.ok)
|
|
54
|
+
return undefined;
|
|
55
|
+
const html = await rootRes.text();
|
|
56
|
+
const paths = new Set(['/theme/theme.json']);
|
|
57
|
+
for (const match of html.matchAll(/\b(?:href|src)="(\/[^"?#]+)"/g))
|
|
58
|
+
paths.add(match[1]);
|
|
59
|
+
const ordered = [...paths].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
60
|
+
const fetched = await Promise.all(ordered.map(async (path) => {
|
|
61
|
+
const res = await fetch(`${baseUrl}${path}`, { signal });
|
|
62
|
+
return res.ok ? [path, Buffer.from(await res.arrayBuffer())] : undefined;
|
|
63
|
+
}));
|
|
64
|
+
const hash = createHash('sha256');
|
|
65
|
+
hash.update('/\0');
|
|
66
|
+
hash.update(html);
|
|
67
|
+
hash.update('\0');
|
|
68
|
+
for (const entry of fetched) {
|
|
69
|
+
if (!entry)
|
|
70
|
+
continue;
|
|
71
|
+
hash.update(entry[0]);
|
|
72
|
+
hash.update('\0');
|
|
73
|
+
hash.update(entry[1]);
|
|
74
|
+
hash.update('\0');
|
|
75
|
+
}
|
|
76
|
+
return hash.digest('hex').slice(0, length);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Acceptance items on a plan: what has to be seen to call it done, and who looks. `self` is ticked by whoever does the
|
|
84
|
+
* work (tests, builds), `member` by another member reproducing it, `owner` only by the owner (core flows, preferences,
|
|
85
|
+
* what needs the owner's own account). The flow through the whole feature is in the RFC's "主流程验收", not here.
|
|
86
|
+
*/
|
|
87
|
+
export const acceptanceBy = ['self', 'member', 'owner'];
|
|
88
|
+
export const acceptanceStates = ['pending', 'passed', 'failed'];
|
|
89
|
+
/** Where a check is made by default: this host, the target plugin's running version, or the host's code. */
|
|
90
|
+
export const runningFor = (running, target) => ({
|
|
91
|
+
host: running.host,
|
|
92
|
+
...(running.commit && target?.plugin !== CONSOLE_PLUGIN ? { commit: running.commit } : {}),
|
|
93
|
+
...(target?.plugin ? { component: target.plugin, ...(running.plugins[target.plugin] ? { plugin: running.plugins[target.plugin] } : {}) } : {}),
|
|
94
|
+
});
|
|
95
|
+
const text = { type: 'string' };
|
|
96
|
+
export const acceptanceInput = {
|
|
97
|
+
type: ['array', 'null'],
|
|
98
|
+
items: object({
|
|
99
|
+
id: { type: 'string', description: '已有验收项的编号;省略即新增' },
|
|
100
|
+
entry: { type: 'string', description: '入口:从哪里进去(页面、命令、主题)' },
|
|
101
|
+
action: { type: 'string', description: '动作:做什么' },
|
|
102
|
+
result: { type: 'string', description: '可观察的结果:应该看到什么' },
|
|
103
|
+
by: { type: 'string', enum: acceptanceBy, description: 'self 自验(测试、构建);member 由另一位成员验;owner 机主验(核心流程、偏好、只能用机主账号的那一步)' },
|
|
104
|
+
target: {
|
|
105
|
+
...object({
|
|
106
|
+
host: { type: 'string', description: '宿主地址(试用阶段只支持本宿主)' },
|
|
107
|
+
plugin: { type: 'string', description: '验的是这台宿主上的哪个插件(控制台前端静态资源/交互改动填 "console",按实际下发的静态资源版本判定,刷新浏览器即生效,无需重启宿主);省略即宿主自身核心代码(按启动提交判定)' },
|
|
108
|
+
}, ['host']),
|
|
109
|
+
description: '部署项的验收目标:目标宿主上实际在跑的版本才算数(console 按当前实际下发的控制台资源指纹判定,其他插件按当前运行的版本,省略 plugin 才按宿主启动提交判定)。省略即按受验的提交判断(构建、测试)',
|
|
110
|
+
},
|
|
111
|
+
}, ['entry', 'action', 'result', 'by']),
|
|
112
|
+
description: '整体设置这条规划的验收项(替换现有列表,按编号保留已验结果,传 null 清空)。有机主验时先通过其余项并用 waiting 声明等机主,结项验收卡由机主通过结项或退回;RFC 不带验收章节,交机主验收时另写临时验收声明(statement)。',
|
|
113
|
+
};
|
|
114
|
+
export const checkInput = {
|
|
115
|
+
...object({
|
|
116
|
+
id: { type: 'string', description: '验收项编号(acc_…)' },
|
|
117
|
+
state: { type: 'string', enum: acceptanceStates, description: 'passed 通过 / failed 未通过 / pending 退回待验' },
|
|
118
|
+
evidence: { type: 'array', items: text, description: '这一项的资料:消息、文件或截图地址,追加到已有资料' },
|
|
119
|
+
note: { type: 'string', description: '一句话:看到了什么' },
|
|
120
|
+
on: {
|
|
121
|
+
...object({ host: text, commit: text, plugin: text, component: text }, ['host']),
|
|
122
|
+
description: '实际在哪验、什么版本(宿主或构建,及其提交或插件版本);省略即本宿主当前运行的版本。部署项只有在目标宿主当前版本上通过才算数,别处的结果照实记成资料',
|
|
123
|
+
},
|
|
124
|
+
}, ['id', 'state']),
|
|
125
|
+
description: '记录一项验收的结果,宿主记下验收环境(宿主、提交、插件版本、时间、验收人)。机主验的项只有机主能记为通过;成员验的项要由跟进成员以外的成员验。',
|
|
126
|
+
};
|
|
127
|
+
export const acceptanceOutput = array(object({
|
|
128
|
+
id: text, entry: text, action: text, result: text,
|
|
129
|
+
by: { type: 'string', enum: acceptanceBy }, target: object({ host: text, plugin: text }, ['host']), state: { type: 'string', enum: acceptanceStates },
|
|
130
|
+
evidence: array(text),
|
|
131
|
+
checked: object({ by: text, at: { type: 'number' }, host: text, commit: text, plugin: text, component: text, note: text }, ['by', 'at', 'host']),
|
|
132
|
+
effective: { type: 'string', enum: acceptanceStates, description: '按验收目标判定后的有效状态:记为通过但不在目标宿主当前版本上的项为 pending' },
|
|
133
|
+
}, ['id', 'entry', 'action', 'result', 'by', 'state']));
|
|
134
|
+
/**
|
|
135
|
+
* The new list, keeping what was checked for items that stayed the same; a changed criterion goes back to pending (the
|
|
136
|
+
* caller notes it in the trail). A target can only be this host for now: it is the only running version that can be read.
|
|
137
|
+
*/
|
|
138
|
+
const sameTarget = (a, b) => a?.host === b?.host && a?.plugin === b?.plugin;
|
|
139
|
+
export function withAcceptance(current = [], items, newId, running) {
|
|
140
|
+
const changed = [];
|
|
141
|
+
const list = items.map((input) => {
|
|
142
|
+
const entry = input.entry.trim(), action = input.action.trim(), result = input.result.trim();
|
|
143
|
+
const host = input.target?.host.trim(), plugin = input.target?.plugin?.trim();
|
|
144
|
+
const target = host ? { host, ...(plugin ? { plugin } : {}) } : undefined;
|
|
145
|
+
if (!entry || !action || !result)
|
|
146
|
+
throw new Error('每项验收都要写入口、动作和可观察的结果');
|
|
147
|
+
if (target && running && target.host !== running.host)
|
|
148
|
+
throw new Error(`部署目标试用阶段只支持本宿主(${running.host})`);
|
|
149
|
+
if (target?.plugin && running && !(target.plugin in running.plugins))
|
|
150
|
+
throw new Error(`本宿主没有在运行的插件:${target.plugin}`);
|
|
151
|
+
const before = input.id ? current.find((item) => item.id === input.id) : undefined;
|
|
152
|
+
if (input.id && !before)
|
|
153
|
+
throw new Error(`没有这一项验收:${input.id}`);
|
|
154
|
+
const same = before && before.entry === entry && before.action === action && before.result === result && before.by === input.by && sameTarget(before.target, target);
|
|
155
|
+
if (same)
|
|
156
|
+
return before;
|
|
157
|
+
const item = { id: before?.id ?? newId(), entry, action, result, by: input.by, ...(target ? { target } : {}), state: 'pending',
|
|
158
|
+
...(before?.evidence?.length ? { evidence: before.evidence } : {}) };
|
|
159
|
+
if (before)
|
|
160
|
+
changed.push(item);
|
|
161
|
+
return item;
|
|
162
|
+
});
|
|
163
|
+
return { items: list, changed };
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* One item's result. The owner checks owner items; a member item is checked by a member other than the one following
|
|
167
|
+
* the plan (or the owner); a self item by anyone working on it.
|
|
168
|
+
*/
|
|
169
|
+
export function checkAcceptance(items, input, who, running, at = Date.now()) {
|
|
170
|
+
const before = items.find((item) => item.id === input.id);
|
|
171
|
+
if (!before)
|
|
172
|
+
throw new Error(`没有这一项验收:${input.id}`);
|
|
173
|
+
if (input.state === 'passed' && before.by === 'owner' && !who.owner)
|
|
174
|
+
throw new Error('机主验的项只有机主能记为通过');
|
|
175
|
+
if (input.state === 'passed' && before.by === 'member' && !who.owner && who.id === who.assignee)
|
|
176
|
+
throw new Error('成员验的项要由跟进成员以外的成员验');
|
|
177
|
+
const evidence = [...new Set([...(before.evidence ?? []), ...(input.evidence ?? []).map((one) => one.trim()).filter(Boolean)])];
|
|
178
|
+
const note = input.note?.trim();
|
|
179
|
+
const item = {
|
|
180
|
+
...before, state: input.state, ...(evidence.length ? { evidence } : {}),
|
|
181
|
+
...(input.state === 'pending' ? { checked: undefined } : { checked: { by: who.id, at, ...(input.on ?? runningFor(running, before.target)), ...(note ? { note } : {}) } }),
|
|
182
|
+
};
|
|
183
|
+
if (!item.checked)
|
|
184
|
+
delete item.checked;
|
|
185
|
+
return { items: items.map((one) => one.id === item.id ? item : one), item };
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Whether an item counts as passed: a deployment item counts when passed on its target host at the version that host
|
|
189
|
+
* runs now — or, for clean Git commit versions (host core or built-in plugins `host@<sha>`), at an ancestor commit
|
|
190
|
+
* already contained in the running clean commit. Passes from another host, dirty trees, rollbacks, diverged branches,
|
|
191
|
+
* stopped plugins, or updated external/console assets stay pending. Any item without a target counts when passed.
|
|
192
|
+
*/
|
|
193
|
+
const CLEAN_COMMIT = /^[0-9a-f]{7,40}$/;
|
|
194
|
+
const cleanCommit = (version, prefixed = false) => {
|
|
195
|
+
if (!version)
|
|
196
|
+
return undefined;
|
|
197
|
+
const raw = prefixed ? (version.startsWith('host@') ? version.slice(5) : undefined) : version;
|
|
198
|
+
return raw && CLEAN_COMMIT.test(raw) ? raw : undefined;
|
|
199
|
+
};
|
|
200
|
+
const matchesVersion = (checked, active, running, prefixed = false) => {
|
|
201
|
+
if (!checked || !active)
|
|
202
|
+
return false;
|
|
203
|
+
if (checked === active)
|
|
204
|
+
return true;
|
|
205
|
+
const older = cleanCommit(checked, prefixed), newer = cleanCommit(active, prefixed);
|
|
206
|
+
return !!older && !!newer && !!running.isAncestor?.(older, newer);
|
|
207
|
+
};
|
|
208
|
+
const current = (item, running) => {
|
|
209
|
+
const target = item.target, checked = item.checked;
|
|
210
|
+
if (!target)
|
|
211
|
+
return true;
|
|
212
|
+
if (!checked || target.host !== running.host || checked.host !== running.host)
|
|
213
|
+
return false;
|
|
214
|
+
// A plugin that is not running, or whose version cannot be known, cannot be verified: the item stays pending.
|
|
215
|
+
if (target.plugin)
|
|
216
|
+
return checked.component === target.plugin && matchesVersion(checked.plugin, running.plugins[target.plugin], running, true);
|
|
217
|
+
return matchesVersion(checked.commit, running.commit, running, false);
|
|
218
|
+
};
|
|
219
|
+
export const counts = (item, running) => item.state === 'passed' && current(item, running);
|
|
220
|
+
/** What an item stands at here: its state, except that a pass which does not count here is pending. */
|
|
221
|
+
export const effective = (item, running) => item.state === 'passed' && !counts(item, running) ? 'pending' : item.state;
|
|
222
|
+
export const unmet = (items = [], running) => items.filter((item) => running ? !counts(item, running) : item.state !== 'passed');
|
|
223
|
+
/**
|
|
224
|
+
* The owner's items are the owner's: a member may add items, but may not drop an owner item, change what it asks or
|
|
225
|
+
* who checks it.
|
|
226
|
+
*/
|
|
227
|
+
export function guardOwnerItems(before = [], after, owner) {
|
|
228
|
+
if (owner)
|
|
229
|
+
return;
|
|
230
|
+
for (const item of before.filter((one) => one.by === 'owner')) {
|
|
231
|
+
const kept = after.find((one) => one.id === item.id);
|
|
232
|
+
if (!kept || kept.by !== 'owner' || kept.entry !== item.entry || kept.action !== item.action || kept.result !== item.result || !sameTarget(kept.target, item.target)) {
|
|
233
|
+
throw new Error('机主验的项只有机主能删除或修改');
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Deployment items on this host whose pass was on another version than the target runs now (the plugin's version, or the
|
|
239
|
+
* host's code): they go back to pending, whoever checked them. Items without a target stay.
|
|
240
|
+
*/
|
|
241
|
+
export function staleChecks(items = [], running) {
|
|
242
|
+
return items.filter((item) => item.state === 'passed' && item.target?.host === running.host && item.checked?.host === running.host && !current(item, running));
|
|
243
|
+
}
|
|
244
|
+
const BY_LABEL = { self: '自验', member: '成员验', owner: '机主验' };
|
|
245
|
+
const STATE_LABEL = { pending: '待验', passed: '通过', failed: '未通过' };
|
|
246
|
+
export const targetText = (target) => `${target.host}${target.plugin ? ` 的 ${target.plugin}` : ''}`;
|
|
247
|
+
export const acceptanceLine = (item, running) => `[${BY_LABEL[item.by]}·${STATE_LABEL[running ? effective(item, running) : item.state]}] ${item.entry} → ${item.action} → ${item.result}${item.target ? `(在 ${targetText(item.target)} 当前版本上验)` : ''}(${item.id})`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BlockedHandoff, Ctx, Topic } from 'hostlet/sdk';
|
|
2
|
+
import type { Plan, Step } from './index.ts';
|
|
3
|
+
type Book = {
|
|
4
|
+
topic: Topic;
|
|
5
|
+
plan: Plan;
|
|
6
|
+
};
|
|
7
|
+
export type BlockedWait = {
|
|
8
|
+
fact: BlockedHandoff;
|
|
9
|
+
step: Step;
|
|
10
|
+
};
|
|
11
|
+
/** A floor can contain many revisions. Only a declaration about this particular rejected delivery can take it over. */
|
|
12
|
+
export declare function blockedPlanWaits(ctx: Ctx, books: () => Book[]): {
|
|
13
|
+
forWait: (plan: Plan) => BlockedWait | undefined;
|
|
14
|
+
forEvent: (event: {
|
|
15
|
+
id: string;
|
|
16
|
+
sourceTopicId: string;
|
|
17
|
+
}) => (Book & BlockedWait) | undefined;
|
|
18
|
+
resolve: ({ fact, step }: BlockedWait) => void;
|
|
19
|
+
};
|
|
20
|
+
/** A returned or escalated receipt goes to someone else. Only an addressed message in the original destination proves delivery. */
|
|
21
|
+
export declare function receivedHandoff(ctx: Ctx, fact: BlockedHandoff, memberId: string, receipt?: {
|
|
22
|
+
topicId: string;
|
|
23
|
+
messageId: string;
|
|
24
|
+
} | undefined): string | undefined;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { address } from 'hostlet/sdk';
|
|
2
|
+
import { planRefs } from "./dependencies.js";
|
|
3
|
+
import { requestTopic } from "./progress.js";
|
|
4
|
+
/** A floor can contain many revisions. Only a declaration about this particular rejected delivery can take it over. */
|
|
5
|
+
export function blockedPlanWaits(ctx, books) {
|
|
6
|
+
const messages = ctx.get('messages'), a2a = ctx.get('a2a');
|
|
7
|
+
const matches = (fact, plan, step) => {
|
|
8
|
+
if (!step.where || !step.waitingOn || !fact.blocked.includes(step.waitingOn)
|
|
9
|
+
|| fact.delivered.includes(step.waitingOn) || requestTopic(step.where) !== fact.sourceTopicId)
|
|
10
|
+
return false;
|
|
11
|
+
const request = messages.forMember(step.by).get(step.where.split('/')[1]);
|
|
12
|
+
if (!request || request.topicId !== fact.sourceTopicId)
|
|
13
|
+
return false;
|
|
14
|
+
if (fact.kind === 'reply')
|
|
15
|
+
return request.from.id === fact.from && request.id === fact.sourceMessageId;
|
|
16
|
+
// Tool sends have no published destination message. An explicit plan reference binds the same turn or quoted request.
|
|
17
|
+
return (step.by === fact.from || request.from.id === fact.from) && planRefs(fact.content).includes(plan.id)
|
|
18
|
+
&& (request.id === fact.sourceMessageId || fact.sourceIds?.includes(request.id)
|
|
19
|
+
|| !!fact.turnId && request.turnId === fact.turnId);
|
|
20
|
+
};
|
|
21
|
+
const forWait = (plan) => {
|
|
22
|
+
if (!plan.waiting)
|
|
23
|
+
return;
|
|
24
|
+
const step = plan.trail.findLast((s) => s.what === 'waiting');
|
|
25
|
+
const topicId = requestTopic(step?.where);
|
|
26
|
+
if (!step || !topicId)
|
|
27
|
+
return;
|
|
28
|
+
const fact = a2a.blockedHandoffs(topicId, step.by).findLast((h) => matches(h, plan, step));
|
|
29
|
+
return fact && { fact, step };
|
|
30
|
+
};
|
|
31
|
+
const forEvent = (event) => {
|
|
32
|
+
const candidates = [];
|
|
33
|
+
const reads = new Map();
|
|
34
|
+
for (const book of books()) {
|
|
35
|
+
for (const step of book.plan.trail.toReversed()) {
|
|
36
|
+
if (step.what !== 'waiting' || requestTopic(step.where) !== event.sourceTopicId)
|
|
37
|
+
continue;
|
|
38
|
+
if (!reads.has(step.by))
|
|
39
|
+
reads.set(step.by, a2a.blockedHandoffs(event.sourceTopicId, step.by).find((h) => h.id === event.id));
|
|
40
|
+
const fact = reads.get(step.by);
|
|
41
|
+
if (!fact || !matches(fact, book.plan, step))
|
|
42
|
+
continue;
|
|
43
|
+
candidates.push({ ...book, fact, step });
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// One message cannot decide between two plans that both claim the same delivery.
|
|
48
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
49
|
+
};
|
|
50
|
+
const resolve = ({ fact, step }) => {
|
|
51
|
+
a2a.resolveBlockedHandoff(fact.id, step.by, fact.remaining.length ? step.waitingOn : undefined);
|
|
52
|
+
};
|
|
53
|
+
return { forWait, forEvent, resolve };
|
|
54
|
+
}
|
|
55
|
+
/** A returned or escalated receipt goes to someone else. Only an addressed message in the original destination proves delivery. */
|
|
56
|
+
export function receivedHandoff(ctx, fact, memberId, receipt = fact.receipts?.[memberId] ?? fact.receipt) {
|
|
57
|
+
if (!receipt || receipt.topicId !== fact.topicId)
|
|
58
|
+
return;
|
|
59
|
+
const message = ctx.get('messages').forMember(memberId).get(receipt.messageId);
|
|
60
|
+
if (!message || message.topicId !== fact.topicId || !message.to.includes(memberId))
|
|
61
|
+
return;
|
|
62
|
+
// A person can explicitly quote this handoff on another floor. Only the transport's individual receipt proves that link.
|
|
63
|
+
if ((message.thread ?? undefined) !== fact.thread && fact.receipts?.[memberId]?.messageId !== message.id)
|
|
64
|
+
return;
|
|
65
|
+
return address.message(message.topicId, message.id);
|
|
66
|
+
}
|