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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export { createFileLock, interactiveShell, isNativeFileName, linkDirectory, listBrowsers, openBrowser, openNoFollow, pickDirectory, pickFiles, replaceFile, revealFile, writeExclusiveFile, } from '#platform';
|
|
2
|
+
export type { Browser } from '#platform';
|
|
3
|
+
export { address, addressLink, addressRules, topicLink } from '../core/address.ts';
|
|
4
|
+
export { archiveMetadata, archivePath, extractTarGz, stripArchiveRoot } from '../core/archive.ts';
|
|
5
|
+
export { dirVersion, fileVersion, measureEntry, measureTree } from '../core/disk-usage.ts';
|
|
6
|
+
export type { MeasuredEntry, TreeUsage } from '../core/disk-usage.ts';
|
|
7
|
+
export { writeDocuments } from '../core/documents.ts';
|
|
8
|
+
export { ArgsError, HttpError, HANDLED, operationErrorText, sendUserFile } from '../core/entry.ts';
|
|
9
|
+
export { defaultI18n, ljoin, ltext } from '../core/i18n.ts';
|
|
10
|
+
export { OWNER_ID } from '../core/members.ts';
|
|
11
|
+
export { referenceMark, withFiles } from '../core/messages.ts';
|
|
12
|
+
export { stripMentionMarks } from '../core/mentions.ts';
|
|
13
|
+
export { array, check, memberArgs, memberInput, object } from '../core/ops.ts';
|
|
14
|
+
export { fillRequestSchema } from '../core/types.ts';
|
|
15
|
+
export type { ApprovalInput, FillRequest, InputValues } from '../core/types.ts';
|
|
16
|
+
export { packageRoot } from '../core/package.ts';
|
|
17
|
+
export { EXCERPT_MARK, withExcerpts } from '../core/parts.ts';
|
|
18
|
+
export { inTopicArtifacts, locatorField, parseResource, refResource, resourceField, resourceWithin, topicPathResource, topicResource, validateLocator, workResource, } from '../core/resource.ts';
|
|
19
|
+
export { firstLine, firstLineSync, onPath, startChild } from '../core/spawn.ts';
|
|
20
|
+
export { requireTopic } from '../core/topics.ts';
|
|
21
|
+
export { SessionGoneError, TurnFailureError, isDirRef, isTopicRef } from '../core/types.ts';
|
|
22
|
+
export { errorText, log, newId, readJson, writeJson } from '../core/util.ts';
|
|
23
|
+
export { topicRefsText, topicText } from './topic-text.ts';
|
|
24
|
+
export { sourceChoiceOf, sourceChoices } from './source-choice.ts';
|
|
25
|
+
export type { A2A, LiveTurn, SettledUsage, TurnRecord } from '../core/a2a.ts';
|
|
26
|
+
export type { BlockedHandoff } from '../core/blocked-handoffs.ts';
|
|
27
|
+
export type { Config, ProjectedConfigField, ProjectedConfigGroup } from '../core/config.ts';
|
|
28
|
+
export type * from '../core/config-schema.ts';
|
|
29
|
+
export type { Caller, Entry, Op, PolicyEntry, PolicySource, PreparedOp, ResolvedSign, Sign, TopicErrorDetail } from '../core/entry.ts';
|
|
30
|
+
export type { Home } from '../core/home.ts';
|
|
31
|
+
export type { Lang, LText } from '../core/i18n.ts';
|
|
32
|
+
export type { ApplyDimension, Instances, PromptMetricsSummary, SessionEndInfo, SessionEndReason, SessionInitPluginMetric, StartFingerprints, StartInputMetrics } from '../core/instances.ts';
|
|
33
|
+
export type { Members, PluginDelivery, PluginMember, PluginMemberAttachment, PluginMemberRegistration, PluginMemberSend, PluginMemberReply } from '../core/members.ts';
|
|
34
|
+
export type { Messages, SavedAttachment } from '../core/messages.ts';
|
|
35
|
+
export { mentions } from '../../console/sdk-browser/mentions.mjs';
|
|
36
|
+
export type { MentionCandidate, MentionParse } from '../../console/sdk-browser/mentions.mjs';
|
|
37
|
+
export type { Notice, NoticeAction, NoticeField, Notices } from '../core/notices.ts';
|
|
38
|
+
export type { FromSchema, Schema } from '../core/ops.ts';
|
|
39
|
+
export type { Push } from '../core/push.ts';
|
|
40
|
+
export type { Locator, ResourceChange, ResourceLocation, ResourceRef } from '../core/resource.ts';
|
|
41
|
+
export type { Child } from '../core/spawn.ts';
|
|
42
|
+
export type { TempDirectory } from '../core/storage.ts';
|
|
43
|
+
export type { Store } from '../core/store.ts';
|
|
44
|
+
export type { Topics } from '../core/topics.ts';
|
|
45
|
+
export type { Adapter, ApiKey, AskOption, Card, CardItem, CardResult, ClientAccount, ClientAccountStorage, ClientAccountToken, ClientSession, ResolvedKey, Instance, InstanceContext, InstanceEvent, McpServer, Member, Message, Part, Quorum, QuotaContext, QuotaWindow, Sender, SignField, Signature, StartInput, Topic, TurnFailure, TurnInput, Usage, } from '../core/types.ts';
|
|
46
|
+
export type { Action, Ctx, Disposer, Events, Hooks, Plugin, Services, Span, SpanAttributes } from '../runtime/runtime.ts';
|
|
47
|
+
export type * from './contracts.ts';
|
|
48
|
+
export type { SourceConflict, SourceDecision, SourceDecisions, SourceState } from './source-choice.ts';
|
|
49
|
+
export { fileMime, sandboxUserContent } from '../core/entry.ts';
|
|
50
|
+
export { findMentions } from '../core/mentions.ts';
|
|
51
|
+
export { messageGist, relayBrief, visibleInTurn, visibleTo, withoutLeadingAttachments } from '../core/messages.ts';
|
|
52
|
+
export { encodedPath } from '../core/resource.ts';
|
|
53
|
+
export type { TurnSummary } from '../core/a2a.ts';
|
|
54
|
+
export type { InstanceInfo } from '../core/instances.ts';
|
|
55
|
+
export type { CardAnswer, DirRef } from '../core/types.ts';
|
|
56
|
+
export type { Runtime } from '../runtime/runtime.ts';
|
|
57
|
+
export * from './client.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { createFileLock, interactiveShell, isNativeFileName, linkDirectory, listBrowsers, openBrowser, openNoFollow, pickDirectory, pickFiles, replaceFile, revealFile, writeExclusiveFile, } from '#platform';
|
|
2
|
+
export { address, addressLink, addressRules, topicLink } from "../core/address.js";
|
|
3
|
+
export { archiveMetadata, archivePath, extractTarGz, stripArchiveRoot } from "../core/archive.js";
|
|
4
|
+
export { dirVersion, fileVersion, measureEntry, measureTree } from "../core/disk-usage.js";
|
|
5
|
+
export { writeDocuments } from "../core/documents.js";
|
|
6
|
+
export { ArgsError, HttpError, HANDLED, operationErrorText, sendUserFile } from "../core/entry.js";
|
|
7
|
+
export { defaultI18n, ljoin, ltext } from "../core/i18n.js";
|
|
8
|
+
export { OWNER_ID } from "../core/members.js";
|
|
9
|
+
export { referenceMark, withFiles } from "../core/messages.js";
|
|
10
|
+
export { stripMentionMarks } from "../core/mentions.js";
|
|
11
|
+
export { array, check, memberArgs, memberInput, object } from "../core/ops.js";
|
|
12
|
+
export { fillRequestSchema } from "../core/types.js";
|
|
13
|
+
export { packageRoot } from "../core/package.js";
|
|
14
|
+
export { EXCERPT_MARK, withExcerpts } from "../core/parts.js";
|
|
15
|
+
export { inTopicArtifacts, locatorField, parseResource, refResource, resourceField, resourceWithin, topicPathResource, topicResource, validateLocator, workResource, } from "../core/resource.js";
|
|
16
|
+
export { firstLine, firstLineSync, onPath, startChild } from "../core/spawn.js";
|
|
17
|
+
export { requireTopic } from "../core/topics.js";
|
|
18
|
+
export { SessionGoneError, TurnFailureError, isDirRef, isTopicRef } from "../core/types.js";
|
|
19
|
+
export { errorText, log, newId, readJson, writeJson } from "../core/util.js";
|
|
20
|
+
export { topicRefsText, topicText } from "./topic-text.js";
|
|
21
|
+
export { sourceChoiceOf, sourceChoices } from "./source-choice.js";
|
|
22
|
+
export { mentions } from '../../console/sdk-browser/mentions.mjs';
|
|
23
|
+
export { fileMime, sandboxUserContent } from "../core/entry.js";
|
|
24
|
+
export { findMentions } from "../core/mentions.js";
|
|
25
|
+
export { messageGist, relayBrief, visibleInTurn, visibleTo, withoutLeadingAttachments } from "../core/messages.js";
|
|
26
|
+
export { encodedPath } from "../core/resource.js";
|
|
27
|
+
export { createClient } from './client.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LText } from '../core/i18n.ts';
|
|
2
|
+
import type { Sender, Topic } from '../core/types.ts';
|
|
3
|
+
import type { Ctx } from '../runtime/runtime.ts';
|
|
4
|
+
import type { SourceChoice } from './contracts.ts';
|
|
5
|
+
export interface SourceConflict {
|
|
6
|
+
key: string;
|
|
7
|
+
kind: 'topic' | 'native';
|
|
8
|
+
name: string;
|
|
9
|
+
localPath: string;
|
|
10
|
+
upstream: string;
|
|
11
|
+
upstreamVersion: string;
|
|
12
|
+
choices: SourceChoice[];
|
|
13
|
+
title: LText;
|
|
14
|
+
body: LText;
|
|
15
|
+
}
|
|
16
|
+
export interface SourceDecision {
|
|
17
|
+
kind: SourceConflict['kind'];
|
|
18
|
+
choice: SourceChoice;
|
|
19
|
+
localPath: string;
|
|
20
|
+
upstream: string;
|
|
21
|
+
upstreamVersion: string;
|
|
22
|
+
at: number;
|
|
23
|
+
}
|
|
24
|
+
export type SourceDecisions = Record<string, SourceDecision>;
|
|
25
|
+
export interface SourceState<C extends SourceConflict> {
|
|
26
|
+
conflicts: C[];
|
|
27
|
+
decisions: SourceDecisions;
|
|
28
|
+
partial?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function sourceChoiceOf(conflict: SourceConflict, decisions: SourceDecisions): SourceChoice | null;
|
|
31
|
+
export declare function sourceChoices<C extends SourceConflict>(ctx: Ctx, spec: {
|
|
32
|
+
sender: Sender;
|
|
33
|
+
label: string;
|
|
34
|
+
read(topic: Topic): SourceState<C> | Promise<SourceState<C>>;
|
|
35
|
+
store(topic: Topic, decisions: SourceDecisions): void;
|
|
36
|
+
chosen(topic: Topic, conflict: C, choice: SourceChoice | null): void;
|
|
37
|
+
}): {
|
|
38
|
+
refresh(topic: Topic): Promise<SourceState<C>>;
|
|
39
|
+
choose(topic: Topic, key: string, choice: SourceChoice | null, upstreamVersion?: string): Promise<C>;
|
|
40
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { defaultI18n, ltext } from "../core/i18n.js";
|
|
3
|
+
import { HttpError } from "../core/entry.js";
|
|
4
|
+
export function sourceChoiceOf(conflict, decisions) {
|
|
5
|
+
const decision = Object.hasOwn(decisions, conflict.key) ? decisions[conflict.key] : undefined;
|
|
6
|
+
if (decision?.kind !== conflict.kind || decision.localPath !== conflict.localPath || decision.upstream !== conflict.upstream)
|
|
7
|
+
return null;
|
|
8
|
+
if (!conflict.choices.includes(decision.choice))
|
|
9
|
+
return null;
|
|
10
|
+
if (decision.choice === 'use-upstream')
|
|
11
|
+
return decision.choice;
|
|
12
|
+
return decision.upstreamVersion === conflict.upstreamVersion ? decision.choice : null;
|
|
13
|
+
}
|
|
14
|
+
const sameSender = (a, b) => a.kind === b.kind && a.id === b.id;
|
|
15
|
+
const cardData = (conflict) => ({
|
|
16
|
+
key: conflict.key,
|
|
17
|
+
kind: conflict.kind,
|
|
18
|
+
name: conflict.name,
|
|
19
|
+
localPath: conflict.localPath,
|
|
20
|
+
upstream: conflict.upstream,
|
|
21
|
+
upstreamVersion: conflict.upstreamVersion,
|
|
22
|
+
});
|
|
23
|
+
export function sourceChoices(ctx, spec) {
|
|
24
|
+
const cards = ctx.get('cards');
|
|
25
|
+
const topics = ctx.get('topics');
|
|
26
|
+
const labels = {
|
|
27
|
+
'keep-local': ltext('host.notice.source.keepLocal'),
|
|
28
|
+
'use-upstream': ltext('host.notice.source.useUpstream'),
|
|
29
|
+
};
|
|
30
|
+
const cardSpec = (conflict) => {
|
|
31
|
+
const options = conflict.choices.map((id) => ({ id, label: defaultI18n.render(labels[id]) }));
|
|
32
|
+
const i18n = {
|
|
33
|
+
title: conflict.title,
|
|
34
|
+
body: conflict.body,
|
|
35
|
+
options: Object.fromEntries(conflict.choices.map((id) => [id, labels[id]])),
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
title: defaultI18n.render(conflict.title),
|
|
39
|
+
body: defaultI18n.render(conflict.body),
|
|
40
|
+
i18n,
|
|
41
|
+
data: cardData(conflict),
|
|
42
|
+
options,
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const closePending = (topic, note) => {
|
|
46
|
+
for (const message of cards.pending({ topicId: topic.id, from: spec.sender }))
|
|
47
|
+
cards.close(message.id, note);
|
|
48
|
+
};
|
|
49
|
+
const syncCards = (topic, state) => {
|
|
50
|
+
if (!ctx.runtime.ready)
|
|
51
|
+
return;
|
|
52
|
+
if (topic.deletedAt || topic.archivedAt !== null) {
|
|
53
|
+
closePending(topic, topic.deletedAt ? '主题已删除' : '主题已归档');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const waiting = new Map();
|
|
57
|
+
for (const message of cards.pending({ topicId: topic.id, from: spec.sender })) {
|
|
58
|
+
const card = message.parts[0];
|
|
59
|
+
const key = card.data?.key;
|
|
60
|
+
waiting.set(typeof key === 'string' ? key : `\0${message.id}`, { message, card });
|
|
61
|
+
}
|
|
62
|
+
for (const conflict of state.conflicts) {
|
|
63
|
+
if (sourceChoiceOf(conflict, state.decisions))
|
|
64
|
+
continue;
|
|
65
|
+
const specForCard = cardSpec(conflict);
|
|
66
|
+
const previous = waiting.get(conflict.key);
|
|
67
|
+
if (!previous) {
|
|
68
|
+
cards.send({
|
|
69
|
+
topicId: topic.id, from: spec.sender,
|
|
70
|
+
card: { kind: 'choice', ...specForCard, other: false },
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else if (!isDeepStrictEqual(previous.card.i18n, specForCard.i18n)
|
|
74
|
+
|| !isDeepStrictEqual(previous.card.data, specForCard.data)
|
|
75
|
+
|| !isDeepStrictEqual(previous.card.options, specForCard.options)) {
|
|
76
|
+
cards.update(previous.message.id, specForCard);
|
|
77
|
+
}
|
|
78
|
+
waiting.delete(conflict.key);
|
|
79
|
+
}
|
|
80
|
+
if (state.partial)
|
|
81
|
+
return;
|
|
82
|
+
const active = new Set(state.conflicts.map((conflict) => conflict.key));
|
|
83
|
+
for (const [key, { message }] of waiting) {
|
|
84
|
+
cards.close(message.id, active.has(key) ? `已在 ${spec.label} 来源中处理` : `${spec.label} 来源冲突已消失`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const queues = new Map();
|
|
88
|
+
const queued = (topic, work) => {
|
|
89
|
+
const before = queues.get(topic.id) ?? Promise.resolve();
|
|
90
|
+
const run = before.catch(() => undefined).then(work);
|
|
91
|
+
const tail = run.then(() => undefined, () => undefined);
|
|
92
|
+
queues.set(topic.id, tail);
|
|
93
|
+
void tail.then(() => {
|
|
94
|
+
if (queues.get(topic.id) === tail)
|
|
95
|
+
queues.delete(topic.id);
|
|
96
|
+
});
|
|
97
|
+
return run;
|
|
98
|
+
};
|
|
99
|
+
const openTopic = (topic) => {
|
|
100
|
+
const current = topics.get(topic.id);
|
|
101
|
+
if (!current || current.deletedAt)
|
|
102
|
+
throw new HttpError(409, '主题已删除');
|
|
103
|
+
if (current.archivedAt !== null)
|
|
104
|
+
throw new HttpError(409, '主题已归档');
|
|
105
|
+
return current;
|
|
106
|
+
};
|
|
107
|
+
const decide = (topic, state, conflict, choice) => {
|
|
108
|
+
const current = openTopic(topic);
|
|
109
|
+
if (choice) {
|
|
110
|
+
const value = {
|
|
111
|
+
kind: conflict.kind, choice, localPath: conflict.localPath,
|
|
112
|
+
upstream: conflict.upstream, upstreamVersion: conflict.upstreamVersion, at: Date.now(),
|
|
113
|
+
};
|
|
114
|
+
Object.defineProperty(state.decisions, conflict.key, { value, enumerable: true, writable: true, configurable: true });
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
delete state.decisions[conflict.key];
|
|
118
|
+
}
|
|
119
|
+
spec.store(topic, state.decisions);
|
|
120
|
+
syncCards(current, state);
|
|
121
|
+
spec.chosen(topic, conflict, choice);
|
|
122
|
+
};
|
|
123
|
+
const refresh = (topic) => queued(topic, async () => {
|
|
124
|
+
const state = await spec.read(topic);
|
|
125
|
+
const current = topics.get(topic.id);
|
|
126
|
+
if (!current || current.deletedAt || current.archivedAt !== null) {
|
|
127
|
+
if (current)
|
|
128
|
+
syncCards(current, state);
|
|
129
|
+
return state;
|
|
130
|
+
}
|
|
131
|
+
if (!state.partial) {
|
|
132
|
+
const valid = new Set(state.conflicts.filter((conflict) => sourceChoiceOf(conflict, state.decisions)).map((conflict) => conflict.key));
|
|
133
|
+
const stale = Object.keys(state.decisions).filter((key) => !valid.has(key));
|
|
134
|
+
if (stale.length) {
|
|
135
|
+
openTopic(topic);
|
|
136
|
+
for (const key of stale)
|
|
137
|
+
delete state.decisions[key];
|
|
138
|
+
spec.store(topic, state.decisions);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
syncCards(current, state);
|
|
142
|
+
return state;
|
|
143
|
+
});
|
|
144
|
+
const choose = async (topic, key, choice, upstreamVersion) => {
|
|
145
|
+
if (topic.archivedAt !== null)
|
|
146
|
+
throw new HttpError(409, '主题已归档');
|
|
147
|
+
return queued(topic, async () => {
|
|
148
|
+
const state = await spec.read(topic);
|
|
149
|
+
const conflict = state.conflicts.find((item) => item.key === key);
|
|
150
|
+
if (!conflict)
|
|
151
|
+
throw new HttpError(404, `没有这个 ${spec.label} 来源冲突`);
|
|
152
|
+
if (choice && !conflict.choices.includes(choice)) {
|
|
153
|
+
throw new HttpError(400, '这一项只能保留本地:先移走客户端目录里的本地副本,才能改用上游');
|
|
154
|
+
}
|
|
155
|
+
if (choice === 'keep-local' && upstreamVersion && upstreamVersion !== conflict.upstreamVersion) {
|
|
156
|
+
throw new HttpError(409, `上游 ${spec.label} 已更新,请查看当前来源后再选`);
|
|
157
|
+
}
|
|
158
|
+
decide(topic, state, conflict, choice);
|
|
159
|
+
return conflict;
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
ctx.hook('cards.refresh', (message) => {
|
|
163
|
+
if (!sameSender(message.from, spec.sender))
|
|
164
|
+
return;
|
|
165
|
+
const topic = topics.get(message.topicId);
|
|
166
|
+
if (topic)
|
|
167
|
+
return refresh(topic).then(() => undefined);
|
|
168
|
+
});
|
|
169
|
+
ctx.on('card.answering', ({ message, accept }) => {
|
|
170
|
+
if (!sameSender(message.from, spec.sender))
|
|
171
|
+
return;
|
|
172
|
+
accept(async ({ message, card, answer }) => {
|
|
173
|
+
const topic = topics.get(message.topicId);
|
|
174
|
+
if (!topic || topic.deletedAt)
|
|
175
|
+
return { ok: false, text: `${spec.label} 来源冲突已消失` };
|
|
176
|
+
if (topic.archivedAt !== null)
|
|
177
|
+
throw new HttpError(409, '主题已归档');
|
|
178
|
+
return queued(topic, async () => {
|
|
179
|
+
const state = await spec.read(topic);
|
|
180
|
+
const shown = card.data;
|
|
181
|
+
const conflict = typeof shown?.key === 'string' ? state.conflicts.find((item) => item.key === shown.key) : undefined;
|
|
182
|
+
const decided = conflict && sourceChoiceOf(conflict, state.decisions);
|
|
183
|
+
if (!conflict || decided || !isDeepStrictEqual(shown, cardData(conflict))) {
|
|
184
|
+
syncCards(topics.get(topic.id) ?? topic, state);
|
|
185
|
+
return {
|
|
186
|
+
ok: false,
|
|
187
|
+
text: !conflict ? `${spec.label} 来源冲突已消失`
|
|
188
|
+
: decided ? `已在 ${spec.label} 来源中处理`
|
|
189
|
+
: `${spec.label} 来源已更新,请查看当前来源后再选`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const choice = answer.picked[0];
|
|
193
|
+
decide(topic, state, conflict, choice);
|
|
194
|
+
return { ok: true, text: choice === 'use-upstream' ? '已改用上游' : '已保留本地' };
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
ctx.on('topic.updated', ({ topic }) => {
|
|
199
|
+
if (!topic.deletedAt && topic.archivedAt === null)
|
|
200
|
+
return;
|
|
201
|
+
closePending(topic, topic.deletedAt ? '主题已删除' : '主题已归档');
|
|
202
|
+
});
|
|
203
|
+
const restore = async () => {
|
|
204
|
+
const waiting = new Set(cards.pending({ from: spec.sender }).map((message) => message.topicId));
|
|
205
|
+
for (const topicId of waiting) {
|
|
206
|
+
const topic = topics.get(topicId);
|
|
207
|
+
if (topic)
|
|
208
|
+
await refresh(topic);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
// On a cold start, wait for the plugins that supply upstream sources.
|
|
212
|
+
if (ctx.runtime.ready)
|
|
213
|
+
restore().catch((problem) => ctx.runtime.onError('source choices: restoring cards', problem));
|
|
214
|
+
else
|
|
215
|
+
ctx.hook('host.ready', restore);
|
|
216
|
+
return { refresh, choose };
|
|
217
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DescribedTopicRef, TopicAbout } from '../core/topics.ts';
|
|
2
|
+
/** These are read for each new turn, so a link or a summary can change while an instance stays open. */
|
|
3
|
+
export declare function topicRefsText(refs: DescribedTopicRef[]): string;
|
|
4
|
+
/** What a topic is, in words for a member: its description, summary, and any plugin-provided context blocks. */
|
|
5
|
+
export declare function topicText(about: TopicAbout, extras?: string[]): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const label = (ref) => `「${ref.title}」(${ref.topicId})${ref.archivedAt !== null ? '(已归档)' : ''}`;
|
|
2
|
+
/** These are read for each new turn, so a link or a summary can change while an instance stays open. */
|
|
3
|
+
export function topicRefsText(refs) {
|
|
4
|
+
if (!refs.length)
|
|
5
|
+
return '';
|
|
6
|
+
return ['引用的主题:', ...refs.map((ref) => `- ${label(ref)}${ref.note ? ` · ${ref.note}` : ''}${ref.summary ? `\n ${ref.summary.replace(/\r?\n/g, '\n ')}` : ''}`)].join('\n');
|
|
7
|
+
}
|
|
8
|
+
/** What a topic is, in words for a member: its description, summary, and any plugin-provided context blocks. */
|
|
9
|
+
export function topicText(about, extras = []) {
|
|
10
|
+
const { topic } = about;
|
|
11
|
+
const linked = topicRefsText(about.topicRefs);
|
|
12
|
+
const lines = [
|
|
13
|
+
`主题:「${about.path.map((p) => p.title).join(' › ')}」(编号 ${topic.id})${topic.tags.length ? `,标签 ${topic.tags.join('、')}` : ''}`,
|
|
14
|
+
`层级:第 ${about.level} 层(主题树最多 ${about.maxDepth} 层)`,
|
|
15
|
+
`主题目录:${topic.dir}`,
|
|
16
|
+
...(topic.archivedAt !== null ? ['状态:已归档(只读)'] : []),
|
|
17
|
+
...about.above.slice().reverse().map((t) => `上级主题「${t.title}」(${t.id}):${t.summary.split(/\r?\n/)[0].slice(0, 120) || '(没有摘要)'}\n 主题目录:${t.dir}`),
|
|
18
|
+
about.refs.length ? `引用的目录:${about.refs.map((r) => r.path).join('、')}` : '引用的目录:没有',
|
|
19
|
+
...(linked ? [linked] : []),
|
|
20
|
+
...(about.referencedBy.length ? [`被以下主题引用:${about.referencedBy.map(label).join('、')}`] : []),
|
|
21
|
+
about.children.length ? `子主题:${about.children.map((c) => `「${c.title}」(${c.id})`).join('、')}` : '子主题:没有',
|
|
22
|
+
`摘要:${about.summary.trim() || '(还没有)'}`,
|
|
23
|
+
...extras.map((part) => part.trim()).filter(Boolean),
|
|
24
|
+
];
|
|
25
|
+
return lines.join('\n');
|
|
26
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Caller } from '../core/entry.ts';
|
|
2
|
+
export interface InvokeTransport {
|
|
3
|
+
invoke(name: string, args: unknown, caller?: Caller): unknown;
|
|
4
|
+
caller?: Caller;
|
|
5
|
+
}
|
|
6
|
+
export interface HttpTransport {
|
|
7
|
+
url: string | URL;
|
|
8
|
+
origin?: string;
|
|
9
|
+
headers?: ConstructorParameters<typeof Headers>[0];
|
|
10
|
+
}
|
|
11
|
+
export type Transport = InvokeTransport | HttpTransport;
|
|
12
|
+
export declare function invoke(transport: Transport, name: string, method: string, pattern: string, args?: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export async function invoke(transport, name, method, pattern, args = {}) {
|
|
2
|
+
if ('invoke' in transport)
|
|
3
|
+
return (await transport.invoke(name, args, transport.caller)) ?? { ok: true };
|
|
4
|
+
const values = { ...args };
|
|
5
|
+
const path = pattern.replace(/:([^/]+)/g, (_part, field) => {
|
|
6
|
+
const value = values[field];
|
|
7
|
+
if (value === undefined)
|
|
8
|
+
throw new Error(`缺少 ${field}`);
|
|
9
|
+
delete values[field];
|
|
10
|
+
return encodeURIComponent(String(value));
|
|
11
|
+
});
|
|
12
|
+
const url = new URL(path, transport.url);
|
|
13
|
+
const headers = new Headers(transport.headers);
|
|
14
|
+
if (method !== 'GET' && method !== 'HEAD') {
|
|
15
|
+
headers.set('origin', transport.origin ?? headers.get('origin') ?? url.origin);
|
|
16
|
+
}
|
|
17
|
+
let body;
|
|
18
|
+
if (method === 'GET' || method === 'DELETE') {
|
|
19
|
+
for (const [field, value] of Object.entries(values)) {
|
|
20
|
+
if (value !== undefined)
|
|
21
|
+
url.searchParams.set(field, String(value));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
headers.set('content-type', 'application/json');
|
|
26
|
+
body = JSON.stringify(values);
|
|
27
|
+
}
|
|
28
|
+
const response = await fetch(url, { method, headers, body, redirect: 'manual' });
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
const result = await response.json().catch(() => undefined);
|
|
31
|
+
throw new Error(typeof result?.error === 'string' ? result.error : `HTTP ${response.status}`);
|
|
32
|
+
}
|
|
33
|
+
return response.json();
|
|
34
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Adapter, ApiKey, ClientSession, Plugin, QuotaContext, QuotaWindow, SessionGoneError, TempDirectory, TurnFailure } from 'hostlet/sdk';
|
|
2
|
+
import { commandLine } from './command.ts';
|
|
3
|
+
/** Host services stay with the calling adapter, including process-tree supervision and failure identity. */
|
|
4
|
+
type AcpHost = Pick<typeof import('hostlet/sdk'), 'startChild' | 'firstLine' | 'onPath' | 'TurnFailureError' | 'SessionGoneError' | 'errorText'>;
|
|
5
|
+
export type AcpCommand = ReturnType<typeof commandLine>;
|
|
6
|
+
export type WatchedFailure = string | {
|
|
7
|
+
error: string;
|
|
8
|
+
failure?: TurnFailure;
|
|
9
|
+
};
|
|
10
|
+
export type WatchFailure = (sessionId: string) => (() => WatchedFailure | undefined) | undefined;
|
|
11
|
+
export type AcpMeta = Record<string, unknown>;
|
|
12
|
+
export type TokenField = 'inputTokens' | 'outputTokens' | 'cachedReadTokens' | 'cachedWriteTokens';
|
|
13
|
+
/** How to start an ACP client, which capabilities it supports and how to read its protocol extensions. */
|
|
14
|
+
export interface AcpClient {
|
|
15
|
+
/** The adapter name members refer to. */
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
memberTemplate?: Adapter['memberTemplate'];
|
|
19
|
+
icon?: Adapter['icon'];
|
|
20
|
+
account?: Adapter['account'];
|
|
21
|
+
/** Managed-login flags, or a replacement argument list when the client needs flags in a particular position. */
|
|
22
|
+
accountArgs?: string[] | ((env: NodeJS.ProcessEnv, args: readonly string[]) => string[] | {
|
|
23
|
+
args: string[];
|
|
24
|
+
});
|
|
25
|
+
command: string;
|
|
26
|
+
args: string[];
|
|
27
|
+
/** A prompt can join the running turn. With `true`, the first reply ends the turn. With `supersede`, the newest request owns the result and replies carry usage deltas. */
|
|
28
|
+
append?: boolean | 'supersede';
|
|
29
|
+
/** The client counts cache reads and writes separately from inputTokens. The default is inclusive input. */
|
|
30
|
+
inputExcludesCache?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The client lists the sessions it has under a directory (`session/list`) and loads one that was made in another
|
|
33
|
+
* directory and outside the host (verified per client: ACP says nothing about where a session may be loaded).
|
|
34
|
+
*/
|
|
35
|
+
sessions?: boolean;
|
|
36
|
+
/** Extra facts from a session/list item's metadata, or false when this client cannot load the item. */
|
|
37
|
+
sessionMeta?(meta: AcpMeta): Pick<ClientSession, 'held'> | false;
|
|
38
|
+
/** An explanation of a session/load RPC error the client recognizes from its data. */
|
|
39
|
+
loadError?(data: AcpMeta): string | SessionGoneError | undefined;
|
|
40
|
+
/** A provider failure from this client's structured ACP error data. */
|
|
41
|
+
failure?(data: AcpMeta): TurnFailure | undefined;
|
|
42
|
+
/** A count from usage metadata when the corresponding standard field is absent. */
|
|
43
|
+
tokenFromMeta?(meta: AcpMeta, field: TokenField): unknown;
|
|
44
|
+
/** An optional, read-only account quota lookup supplied by this client. */
|
|
45
|
+
quota?(ctx?: QuotaContext): Promise<QuotaWindow[]>;
|
|
46
|
+
quotaAccountEnv?: Adapter['quotaAccountEnv'];
|
|
47
|
+
/**
|
|
48
|
+
* What this client needs before its process starts, beyond ACP: launch flags, environment variables and files.
|
|
49
|
+
* `system: true` says the client was given the member-level text here, so it is not put in front of the first turn.
|
|
50
|
+
* `model` is the explicit selection passed to the client by this setup, when it sets one.
|
|
51
|
+
*/
|
|
52
|
+
prepare?(setup: {
|
|
53
|
+
topicId: string;
|
|
54
|
+
memberId: string;
|
|
55
|
+
cwd: string;
|
|
56
|
+
command: AcpCommand;
|
|
57
|
+
systemPrompt?: string;
|
|
58
|
+
key?: ApiKey;
|
|
59
|
+
model?: string;
|
|
60
|
+
contextWindow?: number;
|
|
61
|
+
options: Record<string, unknown>;
|
|
62
|
+
}): {
|
|
63
|
+
command?: AcpCommand;
|
|
64
|
+
env?: NodeJS.ProcessEnv;
|
|
65
|
+
system?: boolean;
|
|
66
|
+
model?: string;
|
|
67
|
+
temp?: TempDirectory;
|
|
68
|
+
/** Called before each prompt. A client can confirm an execution failure even if it reports `end_turn`. */
|
|
69
|
+
watchFailure?: WatchFailure;
|
|
70
|
+
};
|
|
71
|
+
/** For a client that can run with an API key: the protocols it takes, and how a model's id is written as a value of its model option. `prepare` is handed the key, the model and its context window. */
|
|
72
|
+
/** Where this client looks for skills inside a working directory. */
|
|
73
|
+
skillsDir?: string;
|
|
74
|
+
keys?: {
|
|
75
|
+
protocols: ApiKey['protocol'][];
|
|
76
|
+
value?(id: string): string;
|
|
77
|
+
contextWindow?: boolean;
|
|
78
|
+
};
|
|
79
|
+
/** Optional context sizes from the local client's model catalog, keyed by its actual model option values. */
|
|
80
|
+
modelWindows?(env?: NodeJS.ProcessEnv): Promise<ReadonlyMap<string, number | undefined>>;
|
|
81
|
+
}
|
|
82
|
+
export declare function acpAdapter(host: AcpHost, client: AcpClient): Adapter;
|
|
83
|
+
/**
|
|
84
|
+
* One ACP client as its own plugin: the protocol code is shared, what differs per client (how it is started,
|
|
85
|
+
* what it does with input while it works) is stated where the client is declared, from what was measured.
|
|
86
|
+
*/
|
|
87
|
+
export declare function acpClientPlugin(host: AcpHost, client: AcpClient, about: string): Plugin;
|
|
88
|
+
export {};
|