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,165 @@
|
|
|
1
|
+
/* Start: the theme pack comes from two JSON files, the data from the host, then the first screen opens. */
|
|
2
|
+
'use strict';
|
|
3
|
+
referenceLabelFallback = () => tc('host.reference.open');
|
|
4
|
+
MD_REF.label = function (href, text) {
|
|
5
|
+
const address = referenceLabelTarget(href, text);
|
|
6
|
+
return address ? { address, text: referenceLabelFallback() } : null;
|
|
7
|
+
};
|
|
8
|
+
OWN['reference-label'] = referenceLabelMount;
|
|
9
|
+
treeMatch(REFERENCE_LABEL_SELECTOR, referenceLabelMount);
|
|
10
|
+
THEME_PACKS = {
|
|
11
|
+
read: function () {
|
|
12
|
+
return Promise.all([fetch('/theme/tokens.json').then(function (r) { return r.json(); }), fetch('/theme/theme.json').then(function (r) { return r.json(); })])
|
|
13
|
+
.then(function (r) { return { id: 'default', name: 'hostlet', version: '1', contractVersion: '0.4.0', builtin: true, uses: [], components: {}, assets: {}, i18n: r[1].i18n, pdl: Object.assign({}, r[0], r[1].pdl) }; });
|
|
14
|
+
},
|
|
15
|
+
list: function () { return Promise.resolve([{ id: 'default', name: 'hostlet', version: '1', contractVersion: '0.4.0', builtin: true }]); }
|
|
16
|
+
};
|
|
17
|
+
let hlMentionSyntax;
|
|
18
|
+
onStart('data', hlLoadShared);
|
|
19
|
+
onStart('data', function () {
|
|
20
|
+
return import('/sdk-browser/mentions.mjs').then(function (syntax) { hlMentionSyntax = syntax; });
|
|
21
|
+
});
|
|
22
|
+
onStart('boot', function () {
|
|
23
|
+
applyThemeVals();
|
|
24
|
+
applyAssets();
|
|
25
|
+
hlListen();
|
|
26
|
+
openAddress(location.hash.slice(1), hlTakeViewerQuote());
|
|
27
|
+
});
|
|
28
|
+
/* Everything that can be referred to has an address, and it is what the address bar shows after `#`:
|
|
29
|
+
chat-<topic> a topic
|
|
30
|
+
chat-<topic>/<message> a message in it
|
|
31
|
+
chat-<topic>?turn=<id> an execution trace in it
|
|
32
|
+
chat-<topic>?preview=<url> a topic webpage or loopback service in its workbench
|
|
33
|
+
member-<id> a member's details
|
|
34
|
+
<route>/<item> an item in a plugin page that declares one
|
|
35
|
+
plugins/<name> one extension
|
|
36
|
+
trash the trash page
|
|
37
|
+
Going to one never opens another browser page. A notice, an inbox entry and a row of a section all
|
|
38
|
+
carry an address and nothing else; typing or pasting one in the address bar goes to the same place. */
|
|
39
|
+
function hlOpen(address, after) {
|
|
40
|
+
const t = String(address || '').replace(/^[^#]*#/, '');
|
|
41
|
+
const chat = /^chat-([^/?]+)(?:\/([^?]+))?(?:\?(source|turn|preview|job|tab)=([\w.%~-]+))?$/.exec(t);
|
|
42
|
+
if (chat) {
|
|
43
|
+
if (chat[3] === 'source') {
|
|
44
|
+
const source = hlSelectionFromAddress(chat[4]);
|
|
45
|
+
if (!source) { toast(tc('hl.boot.linkCannotOpen')); return false; }
|
|
46
|
+
hlOpenSelectionSource(chat[1], source, { after: after });
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
let opened = after;
|
|
50
|
+
if (chat[3] === 'turn') opened = function () { hlOpenTurnAddress(HL.topic, chat[4], after); };
|
|
51
|
+
if (chat[3] === 'job') opened = function () { hlOpenJobAddress(HL.topic, chat[4], after); };
|
|
52
|
+
if (chat[3] === 'tab') {
|
|
53
|
+
let tabId;
|
|
54
|
+
try { tabId = decodeURIComponent(chat[4]); } catch (e) { return false; }
|
|
55
|
+
opened = function () {
|
|
56
|
+
if (HL.topic && hlPanelViewAllowed(tabId) && tabId !== hlEffectiveMain()) ENGINE_PARTS.openTab('panel', tabId);
|
|
57
|
+
after?.();
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (chat[3] === 'preview') {
|
|
61
|
+
const url = URL.parse(new URLSearchParams('preview=' + chat[4]).get('preview'));
|
|
62
|
+
if (!url || !/^https?:$/.test(url.protocol) || webLinkTarget(url) !== 'preview') return false;
|
|
63
|
+
opened = function () { hlPreviewShow(url.href); after?.(); };
|
|
64
|
+
}
|
|
65
|
+
A.hlTopic({ id: chat[1], mid: chat[2], after: opened });
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
const member = /^member-([^/?]+)(\?edit)?$/.exec(t);
|
|
69
|
+
if (member) {
|
|
70
|
+
const finish = function () {
|
|
71
|
+
after?.();
|
|
72
|
+
if (member[2] && hlMember(member[1])) A.hlMemberEdit({ id: member[1] });
|
|
73
|
+
};
|
|
74
|
+
go('member-' + member[1], { address: true, after: (after || member[2]) && hlIdentity(member[1]) ? finish : undefined });
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const item = /^(plugins)\/(.+)$/.exec(t);
|
|
78
|
+
const detail = /^([^/]+)\/([^/]+)$/.exec(t), pluginRoute = detail && PLUG_ROUTES.get(detail[1]);
|
|
79
|
+
if (pluginRoute?.item) {
|
|
80
|
+
let id;
|
|
81
|
+
try { id = decodeURIComponent(detail[2]); } catch (e) { return false; }
|
|
82
|
+
/* Beside a conversation, an item address opens the workbench panel that owns it and locates it there. */
|
|
83
|
+
if (pluginRoute.panel && S.route === 'chat' && HL.topic) {
|
|
84
|
+
if (pluginRoute.panel !== hlEffectiveMain()) ENGINE_PARTS.openTab('panel', pluginRoute.panel);
|
|
85
|
+
hlPluginSelect(pluginRoute.panel, { item: id, after: after });
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
/* From a conversation, a global page in the same space keeps a way back to where it was opened. */
|
|
89
|
+
pagesOpen(detail[1], { p: id }, ACT_FROM, { address: true, exit: S.route === 'chat' && HL.topic && pluginRoute.space === space() ? 'back' : undefined, after: function () {
|
|
90
|
+
if (pluginRoute.panel) hlPluginSelect(pluginRoute.panel, { item: id, after: after });
|
|
91
|
+
else hlPluginRouteSelect(detail[1], { item: id, after: after });
|
|
92
|
+
} });
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
/* An item address whose route is not registered names the plugin only when that plugin is known. */
|
|
96
|
+
if (detail && !PAGES[detail[1]]) {
|
|
97
|
+
const name = detail[1], known = (HLP.plugins || []).some(function (p) { return p.name === name; });
|
|
98
|
+
if (known) toast(tc('hl.boot.pluginForLink', name), { label: tc('hl.boot.openPlugin'), act: 'hlGo', data: { a: 'plugins/' + name } });
|
|
99
|
+
else toast(tc('hl.boot.linkCannotOpen'));
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const viewItem = detail && PDL_PAGES[detail[1]]?.routeItem;
|
|
103
|
+
const route = item ? item[1] : viewItem ? detail[1] : t || startRoute();
|
|
104
|
+
if (!PAGES[route]) {
|
|
105
|
+
if ((HLP.plugins || []).some(function (p) { return p.name === route; })) { go(startRoute(), { address: true, after: after }); return true; }
|
|
106
|
+
toast(tc('hl.boot.pageMissing')); return false;
|
|
107
|
+
}
|
|
108
|
+
let name;
|
|
109
|
+
if (item || viewItem) {
|
|
110
|
+
try { name = decodeURIComponent(item ? item[2] : detail[2]); } catch (e) { toast(tc('hl.boot.linkCannotOpen')); return false; }
|
|
111
|
+
}
|
|
112
|
+
go(viewItem ? route + '-' + name : route, { address: true, after: function () {
|
|
113
|
+
if (viewItem) return after?.();
|
|
114
|
+
if (!item) return after?.();
|
|
115
|
+
const key = 'p:' + name;
|
|
116
|
+
if (!after) return A.hlExtPick({ k: key });
|
|
117
|
+
const nav = NAV.seq;
|
|
118
|
+
hlReload('settings').then(function () {
|
|
119
|
+
if (NAV.seq !== nav || S.route !== route) return;
|
|
120
|
+
const target = hlExtItems('plugins').find(function (row) { return row.key === key || row.name === name; });
|
|
121
|
+
if (target) A.hlExtPick({ k: target.key, after: after });
|
|
122
|
+
else toast(tc('hl.boot.linkCannotOpen'));
|
|
123
|
+
}, hlFail);
|
|
124
|
+
} });
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function hlOpenTurnAddress(topic, encoded, after) {
|
|
129
|
+
try {
|
|
130
|
+
const turnId = decodeURIComponent(encoded);
|
|
131
|
+
const [turn] = await hlFetch('GET', '/api/topics/' + topic.id + '/turns?detail=true&summary=true&turnId=' + encodeURIComponent(turnId));
|
|
132
|
+
if (HL.topic !== topic) return;
|
|
133
|
+
if (!turn) { toast(tc('hl.run.sessNoneShown')); return; }
|
|
134
|
+
(topic.runTurns ??= {})[turn.id] = turn;
|
|
135
|
+
A.hlRunTurnOpen({ mid: turn.replyId, turnId: turn.id, m: turn.memberId, s: hlRunSessionKey(turn.sessionId) });
|
|
136
|
+
after?.();
|
|
137
|
+
} catch (error) { if (HL.topic === topic) hlFail(error); }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function hlOpenJobAddress(topic, encoded, after) {
|
|
141
|
+
let jobId;
|
|
142
|
+
try { jobId = decodeURIComponent(encoded); } catch (e) { return; }
|
|
143
|
+
if (HL.topic !== topic) return;
|
|
144
|
+
if (HU.runSessionKey) { HU.runSessionKey = ''; HU.runSessionTopic = ''; }
|
|
145
|
+
hlRunShow();
|
|
146
|
+
await hlRunReadJobs();
|
|
147
|
+
if (HL.topic !== topic) return;
|
|
148
|
+
const row = document.querySelector('#hl-run-jobs [data-k="' + CSS.escape(jobId) + '"]');
|
|
149
|
+
if (row) {
|
|
150
|
+
row.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
151
|
+
row.classList.remove('is-hi');
|
|
152
|
+
void row.offsetWidth;
|
|
153
|
+
row.classList.add('is-hi');
|
|
154
|
+
}
|
|
155
|
+
after?.();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function openAddress(t, after) { if (!hlOpen(t, after)) go(startRoute(), { address: true }); }
|
|
159
|
+
window.addEventListener('hashchange', function (e) {
|
|
160
|
+
const t = location.hash.slice(1);
|
|
161
|
+
if (!t) return;
|
|
162
|
+
/* Commit the address with the page, after any leave check. */
|
|
163
|
+
history.replaceState(null, '', e.oldURL);
|
|
164
|
+
openAddress(t);
|
|
165
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/* Cards: a message that asks me something and is answered on the thing itself (a choice, an approval). The same card
|
|
2
|
+
is drawn in its topic and in the inbox, from the same message; what I pick or write before I confirm is kept here,
|
|
3
|
+
by the message's id, so it is the same draft in both places. Permission cards belong to a running reply and go
|
|
4
|
+
straight back to the adapter when answered. */
|
|
5
|
+
'use strict';
|
|
6
|
+
HL.cards = []; /* the cards that wait for my answer, in any topic */
|
|
7
|
+
const HLC = { draft: {}, busy: {}, follow: {} };
|
|
8
|
+
function hlCardOf(m) { const p = m && m.parts && m.parts[0]; return p && p.type === 'card' ? p : null; }
|
|
9
|
+
function hlCardKey(mid, ask) { return ask === undefined ? mid : mid + ':' + ask; }
|
|
10
|
+
function hlCardMsg(mid) { return HL.cards.find(function (m) { return m.id === mid; }) || (HL.topic && HL.topic.messages.find(function (m) { return m.id === mid; })) || null; }
|
|
11
|
+
function hlCardsSet(list) {
|
|
12
|
+
for (const old of HL.cards) {
|
|
13
|
+
const c = hlCardOf(old);
|
|
14
|
+
if (c?.items?.some((item) => item.inputs?.length) && !list?.some((m) => m.id === old.id && hlCardOf(m)?.rev === c.rev)) cfResetPrefix('card-input:' + old.id + ':');
|
|
15
|
+
}
|
|
16
|
+
HL.cards = hlVisibleMessages(list || []);
|
|
17
|
+
if (typeof hlInboxSync === 'function') hlInboxSync();
|
|
18
|
+
}
|
|
19
|
+
/* The inbox projects each waiting part of a source message under the same id and, in a reply, the ask id. */
|
|
20
|
+
function hlCardProject(m, c) {
|
|
21
|
+
const key = hlCardKey(m.id, c.ask);
|
|
22
|
+
const previous = HL.cards.find(function (one) { return one.id === m.id; });
|
|
23
|
+
if (c.items?.some((item) => item.inputs?.length) && (c.state !== 'pending' || (previous && hlCardOf(previous).rev !== c.rev))) cfResetPrefix('card-input:' + m.id + ':');
|
|
24
|
+
HL.cards = HL.cards.filter(function (x) { return hlCardKey(x.id, hlCardOf(x).ask) !== key; });
|
|
25
|
+
const waitingForOwner = (c.to || m.to).includes('owner') && (c.ask !== undefined || m.to.includes('owner'));
|
|
26
|
+
if (c.state === 'pending' && waitingForOwner) {
|
|
27
|
+
HL.cards.push({ ...m, to: c.to || m.to, parts: [c] });
|
|
28
|
+
HL.cards.sort(function (a, b) { return a.createdAt - b.createdAt; });
|
|
29
|
+
} else {
|
|
30
|
+
delete HLC.draft[key]; delete HLC.busy[key];
|
|
31
|
+
}
|
|
32
|
+
if (typeof hlInboxSync === 'function') hlInboxSync();
|
|
33
|
+
if (typeof hlStreamMarkDirty === 'function') hlStreamMarkDirty();
|
|
34
|
+
}
|
|
35
|
+
/* Each step owns its form. The channel and the inbox use the same in-memory draft for this revision. */
|
|
36
|
+
function hlCardForm(mid, rev, item) {
|
|
37
|
+
return { scope: 'card-input:' + mid + ':' + rev + ':' + item.id, commitMode: 'external',
|
|
38
|
+
fields: item.inputs.map(function (field, index) {
|
|
39
|
+
return { key: String(index), kind: field.format === 'key-value-lines' ? 'map' : field.secret ? 'secret' : 'string',
|
|
40
|
+
label: field.label, description: field.description, required: field.required };
|
|
41
|
+
}) };
|
|
42
|
+
}
|
|
43
|
+
/* Use complete processing snapshots only from the ordered event stream. The HTTP result can arrive
|
|
44
|
+
after later stream parts, just as an approval's result can arrive before the answer response. */
|
|
45
|
+
function hlCardPut(m) {
|
|
46
|
+
if (HL_DELETED.has(m.id)) return false;
|
|
47
|
+
const t = HL.topic?.id === m.topicId ? HL.topic : null;
|
|
48
|
+
if (m.status === 'processing' || m.seq === null) {
|
|
49
|
+
const turn = t?.live[m.id];
|
|
50
|
+
if (turn && turn.turnId === m.turnId) {
|
|
51
|
+
turn.parts = m.parts;
|
|
52
|
+
if (typeof hlStreamMarkDirty === 'function') hlStreamMarkDirty();
|
|
53
|
+
}
|
|
54
|
+
const asks = new Map(m.parts.filter(function (p) { return p.type === 'card' && p.ask !== undefined; }).map(function (p) { return [p.ask, p]; }));
|
|
55
|
+
if (!asks.size) return !!turn;
|
|
56
|
+
asks.forEach(function (ask) { hlCardProject(m, ask); });
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
const c = hlCardOf(m);
|
|
60
|
+
if (!c || c.ask !== undefined) return false;
|
|
61
|
+
const at = t ? t.messages.findIndex(function (x) { return x.id === m.id; }) : -1;
|
|
62
|
+
if (at >= 0) {
|
|
63
|
+
const was = t.messages[at];
|
|
64
|
+
if (hlCardOf(was)?.rev > c.rev) return false;
|
|
65
|
+
t.messages[at] = Object.assign({}, was, m);
|
|
66
|
+
}
|
|
67
|
+
hlCardProject(m, c);
|
|
68
|
+
hlCardFollow(m.id, c.outcome);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
function hlCardTitle(c) {
|
|
72
|
+
const raw = c.i18n ? tcText(c.i18n.title, c.title) : c.title;
|
|
73
|
+
if (!c.by) return raw;
|
|
74
|
+
const who = c.by === 'owner' ? HL.owner.name : (hlMember(c.by) || {}).name || c.by;
|
|
75
|
+
return tc('hl.card.askedBy', who, raw);
|
|
76
|
+
}
|
|
77
|
+
/* What a card's template is given. The kind's first word says how it is answered; the whole kind says how it is drawn
|
|
78
|
+
(a plugin may draw `approval.<name>` its own way; where nothing does, it is drawn as `approval`). */
|
|
79
|
+
function hlCardQuorum(c) {
|
|
80
|
+
const q = c?.quorum, pending = c?.state === 'pending', rawSigns = c?.signs || [];
|
|
81
|
+
const approvedCount = rawSigns.filter(function (one) { return one.approved; }).length;
|
|
82
|
+
const signedBy = new Set(rawSigns.map(function (one) { return one.by; }));
|
|
83
|
+
const waiters = pending && q && q.openedAt !== undefined && !q.blocked
|
|
84
|
+
? (q.who || []).filter(function (id) { return !signedBy.has(id); })
|
|
85
|
+
: [];
|
|
86
|
+
const waiting = waiters.length > 0;
|
|
87
|
+
const list = S.lang === 'en' ? ', ' : '、';
|
|
88
|
+
const waitKey = q && q.need > 1 ? 'hl.card.waitSignersProgress' : 'hl.card.waitSigners';
|
|
89
|
+
const nameOf = function (id) { return id === 'owner' ? HL.owner.name : (hlMember(id) || {}).name || id; };
|
|
90
|
+
return {
|
|
91
|
+
waiting: waiting, waiters: waiters, approvedCount: approvedCount, need: q ? q.need : 0,
|
|
92
|
+
single: waiting && q.need <= 1, multi: waiting && q.need > 1,
|
|
93
|
+
text: waiting ? tc(waitKey, waiters.map(nameOf).join(list), approvedCount, q.need) : ''
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function hlCard(m, c = hlCardOf(m)) {
|
|
97
|
+
if (!c) return null;
|
|
98
|
+
const permission = c.ask !== undefined, key = hlCardKey(m.id, c.ask);
|
|
99
|
+
const approval = c.kind.split('.')[0] === 'approval', pending = c.state === 'pending';
|
|
100
|
+
const to = c.to || m.to || [];
|
|
101
|
+
const mine = pending && (!permission || m.status === 'processing') && to.includes('owner'), a = c.answer, d = HLC.draft[key] || { picked: [], text: '' };
|
|
102
|
+
const name = function (id) { return id === 'owner' ? HL.owner.name : id === 'auto' && permission ? tc('hl.card.auto') : (hlMember(id) || {}).name || id; }, md = function (text) { return text ? mdHtml(text) : ''; };
|
|
103
|
+
const picked = a ? a.picked || [] : d.picked;
|
|
104
|
+
const title = hlCardTitle(c);
|
|
105
|
+
const body = c.i18n ? tcText(c.i18n.body, c.body) : c.body;
|
|
106
|
+
const options = c.i18n?.options ? (c.options || []).map(function (o) {
|
|
107
|
+
return { ...o, label: tcText(c.i18n.options[o.id], o.label) };
|
|
108
|
+
}) : (c.options || []);
|
|
109
|
+
const hasOptions = approval && options.length > 0;
|
|
110
|
+
const items = (c.items || []).filter(function (item) { return item.option === undefined || item.option === picked[0]; });
|
|
111
|
+
const exec = c.outcome || (items.length === 1 ? items[0].result : null);
|
|
112
|
+
const pic = function (o) {
|
|
113
|
+
if (!o.image) return null;
|
|
114
|
+
const src = '/api/cards/' + m.id + '/image/' + encodeURIComponent(o.id), name = o.image.split('/').pop();
|
|
115
|
+
return [{ name: name, src: src, act: 'plugin:cards/pic', args: { src: src, name: name } }];
|
|
116
|
+
};
|
|
117
|
+
const colon = S.lang === 'en' ? ': ' : ':';
|
|
118
|
+
const kinds = permission ? c.data.kinds : {};
|
|
119
|
+
const option = permission && a ? options.find(function (o) { return o.id === picked[0]; }) : null;
|
|
120
|
+
const approvedOption = approval && a && options.find(function (o) { return o.id === picked[0]; });
|
|
121
|
+
const decision = !a ? '' : approval ? (a.approved ? 'approved' : 'rejected')
|
|
122
|
+
: kinds[option?.id]?.startsWith('allow') ? 'approved' : kinds[option?.id]?.startsWith('reject') ? 'rejected' : '';
|
|
123
|
+
const responseText = permission || (approval && !hasOptions) ? '' : a?.text || '';
|
|
124
|
+
const note = permission ? option?.label : responseText ? '' : a?.text;
|
|
125
|
+
let said = '';
|
|
126
|
+
if (a && a.via === 'quorum') {
|
|
127
|
+
said = tc(a.approved ? 'hl.card.quorumApproved' : 'hl.card.quorumRejected');
|
|
128
|
+
} else if (a && decision) {
|
|
129
|
+
said = name(a.by) + tc('hl.card.' + decision) + (approvedOption ? ' · ' + approvedOption.label : '') + (a.remember && c.remember ? ' · ' + c.remember : '') + (note ? colon + note : '');
|
|
130
|
+
} else if (a) {
|
|
131
|
+
const labels = (a.picked || []).map(function (id) {
|
|
132
|
+
const label = options.find(function (x) { return x.id === id; })?.label ?? id;
|
|
133
|
+
return S.lang === 'en' ? '"' + label + '"' : '「' + label + '」';
|
|
134
|
+
}).join(S.lang === 'en' ? ', ' : '、');
|
|
135
|
+
said = name(a.by) + (labels ? tc('hl.card.picked') + labels : tc('hl.card.answered'));
|
|
136
|
+
}
|
|
137
|
+
const canWrite = mine && (approval || c.other !== false);
|
|
138
|
+
const q = c.quorum, list = S.lang === 'en' ? ', ' : '、';
|
|
139
|
+
const signs = (c.signs || []).map(function (one) {
|
|
140
|
+
const values = Object.entries(one.values || {}).map(function (pair) { return pair.join('='); }).join(list);
|
|
141
|
+
return { key: m.id + ':sign:' + one.by, text: name(one.by) + tc(one.approved ? 'hl.card.signYes' : 'hl.card.signNo') + colon + one.text + (values ? ' (' + values + ')' : ''), tone: one.approved ? 'ok' : 'danger' };
|
|
142
|
+
});
|
|
143
|
+
const qw = hlCardQuorum(c);
|
|
144
|
+
const quorumWaiting = qw.waiting;
|
|
145
|
+
const quorumNote = !q || quorumWaiting ? '' : tc('hl.card.quorum', qw.approvedCount, q.need)
|
|
146
|
+
+ (pending && q.blocked ? colon + q.blocked : '');
|
|
147
|
+
return {
|
|
148
|
+
mid: m.id, key: key, ask: c.ask, kind: c.kind, rev: c.rev, title: title, body: md(body), pending: pending, mine: mine, busy: !!HLC.busy[key],
|
|
149
|
+
multi: !!c.multi, cur: picked[0] || '', group: 'card-' + m.id,
|
|
150
|
+
options: options.map(function (o) {
|
|
151
|
+
const on = picked.indexOf(o.id) >= 0;
|
|
152
|
+
return {
|
|
153
|
+
id: o.id, label: o.label, primary: permission && kinds[o.id]?.startsWith('allow'),
|
|
154
|
+
one: [{ v: o.id, label: o.label, on: on }], detail: md(o.detail), pic: pic(o)
|
|
155
|
+
};
|
|
156
|
+
}),
|
|
157
|
+
items: items.map(function (it, i) {
|
|
158
|
+
return {
|
|
159
|
+
key: m.id + ':' + it.id, n: i + 1, title: !it.title ? '' : items.length === 1 ? it.title : (i + 1) + '. ' + it.title,
|
|
160
|
+
detail: md(it.detail),
|
|
161
|
+
fields: (it.fields || []).map(function (field) { return { label: field.label, value: field.value, warn: field.tone === 'warn' }; })
|
|
162
|
+
.concat(!pending && it.inputs ? it.inputs.map(function (field) {
|
|
163
|
+
return { label: field.label, value: tc(a?.filled?.[it.id]?.includes(field.path) ? 'hl.card.inputFilled' : 'hl.card.inputEmpty') };
|
|
164
|
+
}) : []),
|
|
165
|
+
form: mine && it.inputs?.length ? cfModel(hlCardForm(m.id, c.rev, it)) : null,
|
|
166
|
+
code: it.code ? {
|
|
167
|
+
...it.code, key: 'card-code:' + [key, it.id].map(encodeURIComponent).join(':').replaceAll('.', '%2E')
|
|
168
|
+
} : null
|
|
169
|
+
};
|
|
170
|
+
}),
|
|
171
|
+
results: items.length > 1 ? items.flatMap(function (it, i) {
|
|
172
|
+
const r = it.result;
|
|
173
|
+
return r || (hasOptions && c.outcome) ? [{
|
|
174
|
+
key: m.id + ':res:' + it.id,
|
|
175
|
+
text: (i + 1) + '. ' + it.title + ' — ' + tc(!r ? 'hl.card.notRun' : r.ok ? 'hl.card.ok' : 'hl.card.fail') + (r?.text ? colon + r.text : ''),
|
|
176
|
+
tone: !r ? 'info' : r.ok ? 'ok' : 'danger'
|
|
177
|
+
}] : [];
|
|
178
|
+
}) : [],
|
|
179
|
+
canWrite: canWrite, text: d.text, responseText: responseText,
|
|
180
|
+
inputId: 'hl-card-' + m.id, ph: approval ? tc('hl.card.phApproval') : (c.options || []).length ? tc('hl.card.phChoice') : tc('hl.card.phReply'),
|
|
181
|
+
canSend: mine && !approval && !permission, permission: mine && permission,
|
|
182
|
+
approve: quorumWaiting ? tc('hl.card.directApprove') : c.approve || tc('hl.card.approve'),
|
|
183
|
+
reject: quorumWaiting ? tc('hl.card.directReject') : c.reject || tc('hl.card.reject'),
|
|
184
|
+
approvePrimary: !quorumWaiting,
|
|
185
|
+
remember: approval && !hasOptions ? c.remember || '' : '', approval: mine && approval,
|
|
186
|
+
approveDisabled: !!HLC.busy[key] || (hasOptions && !picked.length),
|
|
187
|
+
waiting: pending && !mine && !quorumWaiting ? tc('hl.card.waiting', to.filter(function (id) { return (hlMember(id) || {}).kind !== 'agent'; }).map(name).join(list)) : '',
|
|
188
|
+
status: a ? decision || 'closed' : c.state === 'closed' ? 'withdrawn' : '', said: a ? said : c.state === 'closed' ? tc('hl.card.closedNoAnswer') + (c.note ? colon + c.note : '') : '',
|
|
189
|
+
signs: signs, quorumNote: quorumNote,
|
|
190
|
+
quorumWaitSingle: qw.single, quorumWaitMulti: qw.multi,
|
|
191
|
+
quorumWaiters: qw.waiters, quorumSigned: qw.approvedCount, quorumNeed: qw.need, quorumWaitText: qw.text,
|
|
192
|
+
outcome: exec ? tc(exec.unconfirmed ? 'hl.card.execUnconfirmed' : exec.ok ? 'hl.card.execOk' : 'hl.card.execFail') + (exec.text ? colon + exec.text : '') : '',
|
|
193
|
+
outcomeTone: exec ? (exec.unconfirmed ? 'warn' : exec.ok ? 'ok' : 'danger') : ''
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/* Both the POST and the final update must arrive on this page. Either can arrive first. */
|
|
197
|
+
function hlCardFollow(mid, outcome) {
|
|
198
|
+
const follow = HLC.follow[mid];
|
|
199
|
+
if (!follow) return;
|
|
200
|
+
if (outcome) follow.outcome = outcome;
|
|
201
|
+
if (!follow.accepted || !follow.outcome) return;
|
|
202
|
+
delete HLC.follow[mid];
|
|
203
|
+
if (follow.outcome.ok && follow.at === location.hash) A.hlGo({ a: follow.open });
|
|
204
|
+
}
|
|
205
|
+
function hlCardAnswer(mid, c, answer) {
|
|
206
|
+
if (!c) return;
|
|
207
|
+
const key = hlCardKey(mid, c.ask); if (HLC.busy[key]) return;
|
|
208
|
+
const open = answer.approved && c.options?.find(function (o) { return o.id === answer.picked?.[0]; })?.open;
|
|
209
|
+
if (open) HLC.follow[mid] = { open: open, at: location.hash };
|
|
210
|
+
HLC.busy[key] = true; if (typeof hlInboxSync === 'function') hlInboxSync(); if (typeof hlStreamMarkDirty === 'function') hlStreamMarkDirty(); render(true);
|
|
211
|
+
return hlFetch('POST', '/api/cards/' + mid + '/answer', Object.assign({ rev: c.rev, ask: c.ask }, answer)).then(function (now) {
|
|
212
|
+
const follow = HLC.follow[mid];
|
|
213
|
+
if (follow) follow.accepted = true;
|
|
214
|
+
if (c.ask === undefined) hlCardPut(now);
|
|
215
|
+
hlCardFollow(mid);
|
|
216
|
+
render(true);
|
|
217
|
+
}, function (error) {
|
|
218
|
+
delete HLC.follow[mid];
|
|
219
|
+
delete HLC.busy[key]; if (typeof hlInboxSync === 'function') hlInboxSync(); if (typeof hlStreamMarkDirty === 'function') hlStreamMarkDirty(); hlFail(error);
|
|
220
|
+
render(true);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* Quote a workbench item or a selection in the current topic's composer. */
|
|
2
|
+
'use strict';
|
|
3
|
+
/* A standalone viewer hands its quote to the console in the same browser tab. */
|
|
4
|
+
function hlTakeViewerQuote() {
|
|
5
|
+
try {
|
|
6
|
+
const key = 'hostlet.viewerQuote', value = sessionStorage.getItem(key);
|
|
7
|
+
if (!value) return;
|
|
8
|
+
sessionStorage.removeItem(key);
|
|
9
|
+
const ref = JSON.parse(value);
|
|
10
|
+
if (location.hash === '#chat-' + ref?.topicId) return function () { A.composeQuote(ref); };
|
|
11
|
+
} catch (error) {
|
|
12
|
+
console.debug('Viewer quote could not be read:', error.name);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function hlComposeRefs(id) { return HU.composeRefs[id] || []; }
|
|
16
|
+
function hlDropComposeRefs(topicId, ids) {
|
|
17
|
+
const kept = hlComposeRefs(topicId).filter(function (ref) { return !ids.includes(ref.id); });
|
|
18
|
+
if (kept.length) HU.composeRefs[topicId] = kept;
|
|
19
|
+
else delete HU.composeRefs[topicId];
|
|
20
|
+
}
|
|
21
|
+
function hlQuoteUrl(value) {
|
|
22
|
+
const url = value && URL.parse(value, location.origin);
|
|
23
|
+
return url && /^https?:$/.test(url.protocol) ? url.href : undefined;
|
|
24
|
+
}
|
|
25
|
+
function hlComposeBody(text, refs) {
|
|
26
|
+
/* Quoted handles are literal text. Only the words typed by the sender can call a member. */
|
|
27
|
+
const literal = function (value) {
|
|
28
|
+
return hlStripMentionMarks(value).replace(/(`[^`\n]*`)|(?<![\w`])@[a-z0-9_][\w.-]*/gi, function (match, code) { return code || '`' + match + '`'; });
|
|
29
|
+
};
|
|
30
|
+
const headers = refs.map(function (ref) {
|
|
31
|
+
const url = ref.href?.replace(/[()@]/g, function (c) { return '%' + c.charCodeAt(0).toString(16); });
|
|
32
|
+
const position = hlSelectionLocation(ref.source?.locator);
|
|
33
|
+
const caption = literal(ref.label) + (position ? ' · ' + position : '') + (url ? ' · [' + tc('hl.selection.source') + '](' + url + ')' : '');
|
|
34
|
+
const lines = ref.excerpt ? literal(ref.excerpt).split(/\r?\n/) : [];
|
|
35
|
+
return [caption, ...lines]
|
|
36
|
+
.map(function (line) { return line ? '> ' + line : '>'; }).join('\n');
|
|
37
|
+
});
|
|
38
|
+
return headers.concat(text || []).join('\n\n');
|
|
39
|
+
}
|
|
40
|
+
A.composeQuote = function (d) {
|
|
41
|
+
const id = HL.topic?.id, topic = id && hlTopic(id);
|
|
42
|
+
if (!topic || (d.topicId && d.topicId !== id) || topic.archivedAt != null || S.route !== 'chat'
|
|
43
|
+
|| !['item', 'selection', 'work', 'file'].includes(d.kind)) return;
|
|
44
|
+
const label = typeof d.label === 'string' && d.label.trim().replace(/\s+/g, ' ').slice(0, 160);
|
|
45
|
+
if (!label) return;
|
|
46
|
+
const excerpt = typeof d.excerpt === 'string' ? d.excerpt.trim().slice(0, 600) : '';
|
|
47
|
+
const url = hlQuoteUrl(d.source?.url);
|
|
48
|
+
let source = hlSelectionSource(d.source);
|
|
49
|
+
if (!source) {
|
|
50
|
+
const viewer = hlLocalWorkViewer(url);
|
|
51
|
+
const resource = viewer?.searchParams.get('resource');
|
|
52
|
+
if (resource) {
|
|
53
|
+
const { page, time } = d.source;
|
|
54
|
+
const locator = {};
|
|
55
|
+
if (Number.isInteger(page) && page > 0) locator.page = page;
|
|
56
|
+
if (Number.isFinite(time) && time >= 0) locator.time = time;
|
|
57
|
+
if (excerpt) locator.text = excerpt;
|
|
58
|
+
source = { resource: resource, locator: locator };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const sourceTopicId = d.sourceTopicId || id;
|
|
62
|
+
const href = source && source.surface !== 'frame' ? hlSelectionAddress(sourceTopicId, source) : url;
|
|
63
|
+
HU.composeRefs[id] = hlComposeRefs(id).concat({ id: PLATFORM.uuid(), kind: d.kind, label: label, excerpt: excerpt, source: source, href: href });
|
|
64
|
+
if (typeof hlDraftSchedule === 'function') hlDraftSchedule(HL.topic, HL.topic.text, { immediate: true });
|
|
65
|
+
render(true);
|
|
66
|
+
focusField(HL_COMPOSE_INPUT);
|
|
67
|
+
};
|
|
68
|
+
A.hlOpenComposeRef = function (d) {
|
|
69
|
+
const ref = HL.topic && hlComposeRefs(HL.topic.id).find(function (item) { return item.id === d.id; });
|
|
70
|
+
if (!ref) return;
|
|
71
|
+
if (ref.href) return ref.href.startsWith('#') ? hlOpen(ref.href) : A.openUrl({ url: ref.href });
|
|
72
|
+
dialog({ kind: 'hlSelectionSource', args: { excerpt: ref.excerpt } });
|
|
73
|
+
};
|
|
74
|
+
A.hlRemoveComposeRef = function (d) {
|
|
75
|
+
if (!HL.topic) return;
|
|
76
|
+
hlDropComposeRefs(HL.topic.id, [d.id]);
|
|
77
|
+
if (typeof hlDraftSchedule === 'function') hlDraftSchedule(HL.topic, HL.topic.text, { immediate: true });
|
|
78
|
+
render(true);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/* The frame library binds the message to its mounted source window. */
|
|
82
|
+
const hlFrameObservations = new WeakMap();
|
|
83
|
+
function hlFrameVisible(frame) {
|
|
84
|
+
return frame.isConnected && !frame.closest('[inert], [hidden]') && frame.getClientRects().length &&
|
|
85
|
+
getComputedStyle(frame).visibility === 'visible';
|
|
86
|
+
}
|
|
87
|
+
function hlFrameObserve(message, frame, origin, topicId) {
|
|
88
|
+
const url = URL.parse(frame.src), opaque = origin === 'null';
|
|
89
|
+
if ((!opaque && url?.origin !== origin) || typeof message.event !== 'string') return;
|
|
90
|
+
const target = url?.href || frame.dataset.frameKey;
|
|
91
|
+
if (!target) return;
|
|
92
|
+
const input = { surface: 'frame', target: target, event: message.event };
|
|
93
|
+
if (!opaque) Object.assign(input, { locator: message.locator, payload: message.payload });
|
|
94
|
+
const send = function () {
|
|
95
|
+
if (S.route !== 'chat' || HL.topic?.id !== topicId || !hlFrameVisible(frame) || URL.parse(frame.src)?.href !== url?.href) return;
|
|
96
|
+
hlFetch('POST', '/api/topics/' + encodeURIComponent(topicId) + '/works/events', input).catch(function (error) {
|
|
97
|
+
console.debug('Frame observation rejected:', error.message);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
if (message.event !== 'cursor' && message.event !== 'select') return send();
|
|
101
|
+
let pending = hlFrameObservations.get(frame);
|
|
102
|
+
if (!pending) hlFrameObservations.set(frame, pending = {});
|
|
103
|
+
clearTimeout(pending[message.event]);
|
|
104
|
+
pending[message.event] = setTimeout(send, 150);
|
|
105
|
+
}
|
|
106
|
+
A.hlFrameMessage = A.pluginFrameMessage = function (message, frame, event) {
|
|
107
|
+
if (message?.channel !== 'hostlet-frame/v1' || !HL.topic || S.route !== 'chat') return;
|
|
108
|
+
if (message.type === 'document.source' && event.origin === location.origin && URL.parse(frame.src)?.origin === location.origin) {
|
|
109
|
+
const source = hlSelectionSource({ resource: message.resource });
|
|
110
|
+
if (source?.resource) HL_DOCUMENT_FRAMES.set(frame, { topicId: message.topicId, resource: source.resource, url: frame.src });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (message.topicId && message.topicId !== HL.topic.id) return;
|
|
114
|
+
if (!hlFrameVisible(frame)) return;
|
|
115
|
+
if (message.type === 'works.observe') return hlFrameObserve(message, frame, event.origin, HL.topic.id);
|
|
116
|
+
if (event.origin !== location.origin || URL.parse(frame.src)?.origin !== location.origin) return;
|
|
117
|
+
if (message.type === 'compose.quote' && message.ref) {
|
|
118
|
+
A.composeQuote(Object.assign({}, message.ref, { source: Object.assign({}, message.ref.source, { url: frame.src }) }));
|
|
119
|
+
} else if (message.type === 'nav.link' && typeof message.href === 'string' && /^https?:\/\//i.test(message.href)) {
|
|
120
|
+
hlOpenWebLink(message.href);
|
|
121
|
+
} else if (message.type === 'nav.open') {
|
|
122
|
+
if (typeof message.href === 'string' && message.href.startsWith('#')) hlOpen(message.href);
|
|
123
|
+
else if (typeof message.href === 'string' && /^https?:\/\//i.test(message.href)) hlPreviewShow(message.href);
|
|
124
|
+
else if (typeof message.file === 'string') A.fileOpen({ v: message.file }, frame);
|
|
125
|
+
else if (message.args) A.openTopic(message.args);
|
|
126
|
+
}
|
|
127
|
+
};
|