even-keel 0.2.4 → 0.3.0-rc.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/.claude-plugin/marketplace.json +16 -4
- package/.env.example +2 -2
- package/CHANGELOG.md +23 -0
- package/README.md +10 -8
- package/dist/src/account/aws.js +76 -0
- package/dist/src/account/azure.js +36 -0
- package/dist/src/account/cloud-errors.js +72 -0
- package/dist/src/account/cloud.js +335 -0
- package/dist/src/account/credit.js +49 -7
- package/dist/src/account/gcloud.js +71 -0
- package/dist/src/account/header-levels.js +3 -2
- package/dist/src/account/homes.js +49 -5
- package/dist/src/account/keycheck.js +57 -4
- package/dist/src/account/management.js +41 -0
- package/dist/src/account/model.js +41 -18
- package/dist/src/account/network.js +8 -3
- package/dist/src/account/service-defaults.js +12 -3
- package/dist/src/account/settingsGuard.js +92 -0
- package/dist/src/account/settingsGuardStrip.js +36 -0
- package/dist/src/account/settingsHook.js +15 -0
- package/dist/src/account/settingsLayer.js +190 -0
- package/dist/src/account/settingsUninstall.js +7 -0
- package/dist/src/account/share.js +23 -6
- package/dist/src/account/spend.js +155 -0
- package/dist/src/account/watcher.js +189 -24
- package/dist/src/agent/adapters.js +13 -2
- package/dist/src/agent/env.js +22 -7
- package/dist/src/agent/model-slots.js +32 -0
- package/dist/src/agent/process.js +32 -6
- package/dist/src/agent/projectRules.js +3 -2
- package/dist/src/agent/providers.js +18 -1
- package/dist/src/agent/scripted.js +319 -0
- package/dist/src/agent/windows.js +35 -3
- package/dist/src/badge/action.js +41 -0
- package/dist/src/badge/check.js +60 -0
- package/dist/src/badge/collect.js +174 -0
- package/dist/src/badge/dates.js +29 -0
- package/dist/src/badge/drawing.js +3 -0
- package/dist/src/badge/fonts.generated.js +11 -0
- package/dist/src/badge/model.js +9 -0
- package/dist/src/badge/privacy.js +151 -0
- package/dist/src/badge/push.js +117 -0
- package/dist/src/badge/render.js +490 -0
- package/dist/src/badge/settings.js +43 -0
- package/dist/src/badge/stats.js +31 -0
- package/dist/src/badge/status.js +57 -0
- package/dist/src/badge/text.js +52 -0
- package/dist/src/badge/theme.js +54 -0
- package/dist/src/badge/translate.js +162 -0
- package/dist/src/builtin/adapter.js +40 -0
- package/dist/src/builtin/control.js +179 -0
- package/dist/src/builtin/editor.js +117 -0
- package/dist/src/builtin/export-store.js +67 -0
- package/dist/src/builtin/export.js +202 -0
- package/dist/src/builtin/exporting.js +25 -0
- package/dist/src/builtin/files.js +155 -0
- package/dist/src/builtin/links.js +25 -0
- package/dist/src/builtin/model.js +59 -0
- package/dist/src/builtin/routes.js +108 -0
- package/dist/src/builtin/source.js +240 -0
- package/dist/src/builtin/store.js +520 -0
- package/dist/src/builtin/switch.js +77 -0
- package/dist/src/chain/answers.js +27 -0
- package/dist/src/chain/archive.js +0 -1
- package/dist/src/chain/dispatcher.js +105 -12
- package/dist/src/chain/fence.js +30 -0
- package/dist/src/chain/handover.js +27 -9
- package/dist/src/chain/launches.js +4 -4
- package/dist/src/chain/limitNotice.js +1 -1
- package/dist/src/chain/lists.js +42 -6
- package/dist/src/chain/log.js +3 -1
- package/dist/src/chain/maincheck.js +116 -10
- package/dist/src/chain/mainci.js +26 -7
- package/dist/src/chain/mainfix.js +12 -1
- package/dist/src/chain/milestone-sequence.js +40 -0
- package/dist/src/chain/milestones.js +3 -2
- package/dist/src/chain/order.js +20 -5
- package/dist/src/chain/overage.js +7 -2
- package/dist/src/chain/places.js +1 -1
- package/dist/src/chain/prompts.js +64 -6
- package/dist/src/chain/relay.js +35 -14
- package/dist/src/chain/reviews.js +8 -4
- package/dist/src/chain/rules.js +40 -11
- package/dist/src/chain/snapshots.js +2 -0
- package/dist/src/chain/start.js +21 -1
- package/dist/src/chain/store.js +16 -6
- package/dist/src/chain/unchanged.js +68 -5
- package/dist/src/ci/adapters.js +3 -1
- package/dist/src/ci/forgejo-profile.js +3 -24
- package/dist/src/ci/forgejo.js +2 -1
- package/dist/src/ci/github.js +10 -2
- package/dist/src/ci/gitlab.js +10 -3
- package/dist/src/ci/http.js +4 -0
- package/dist/src/ci/model.js +79 -6
- package/dist/src/ci/report.js +6 -3
- package/dist/src/ci/shared.js +9 -0
- package/dist/src/ci/verdict.js +18 -7
- package/dist/src/ci/watcher.js +95 -23
- package/dist/src/ci/wiring.js +15 -0
- package/dist/src/claude/adapter.js +34 -8
- package/dist/src/claude/cli.js +32 -8
- package/dist/src/claude/instructions.js +42 -7
- package/dist/src/claude/oauth.js +67 -0
- package/dist/src/claude/sdk/host.js +9 -4
- package/dist/src/claude/tree.js +45 -14
- package/dist/src/cli-check/run.js +3 -3
- package/dist/src/cli-check/support.js +4 -4
- package/dist/src/cli.js +54 -17
- package/dist/src/codex/adapter.js +2 -0
- package/dist/src/codex/cli.js +34 -18
- package/dist/src/codex/protection.js +17 -11
- package/dist/src/codex/rollout.js +9 -2
- package/dist/src/codex/turns.js +6 -3
- package/dist/src/codex/window.js +14 -0
- package/dist/src/config-form.js +63 -7
- package/dist/src/config-store.js +29 -7
- package/dist/src/config.js +45 -15
- package/dist/src/copilot/adapter.js +2 -0
- package/dist/src/copilot/cli.js +8 -11
- package/dist/src/copilot/home.js +1 -1
- package/dist/src/copilot/transcript.js +1 -2
- package/dist/src/demo/agent.js +97 -0
- package/dist/src/demo/model.js +6 -0
- package/dist/src/demo/scenario.js +139 -0
- package/dist/src/demo/service.js +161 -0
- package/dist/src/diagnostics/stop.js +16 -0
- package/dist/src/env-file.js +4 -0
- package/dist/src/error-reason.js +10 -0
- package/dist/src/event-log/log.js +97 -0
- package/dist/src/event-log/model.js +1 -0
- package/dist/src/event-log/page-events.js +71 -0
- package/dist/src/event-log/watch.js +236 -0
- package/dist/src/events.js +57 -1
- package/dist/src/forgejo/adapter.js +49 -0
- package/dist/src/forgejo/api.js +95 -0
- package/dist/src/forgejo/editor.js +196 -0
- package/dist/src/forgejo/model.js +90 -0
- package/dist/src/forgejo/profile.js +24 -0
- package/dist/src/forgejo/source.js +292 -0
- package/dist/src/forgejo/trust.js +45 -0
- package/dist/src/git/branches.js +88 -0
- package/dist/src/git/clone-progress.js +168 -0
- package/dist/src/git/remote-run.js +162 -0
- package/dist/src/git/run.js +6 -2
- package/dist/src/git/setup.js +4 -5
- package/dist/src/git/slot.js +9 -7
- package/dist/src/git/worktree.js +13 -10
- package/dist/src/github/adapter.js +1 -0
- package/dist/src/github/editor.js +214 -0
- package/dist/src/github/edits.js +31 -0
- package/dist/src/github/model.js +10 -4
- package/dist/src/github/source.js +66 -15
- package/dist/src/gitlab/adapter.js +1 -0
- package/dist/src/gitlab/api.js +4 -2
- package/dist/src/gitlab/editor.js +248 -0
- package/dist/src/gitlab/model.js +43 -4
- package/dist/src/gitlab/source.js +113 -22
- package/dist/src/guard.js +26 -10
- package/dist/src/hotkeys.js +51 -0
- package/dist/src/huly/adapter.js +1 -0
- package/dist/src/huly/collab.js +15 -0
- package/dist/src/huly/editor.js +241 -0
- package/dist/src/huly/marks.js +48 -0
- package/dist/src/huly/model.js +22 -5
- package/dist/src/huly/source.js +111 -48
- package/dist/src/intake/github.js +10 -0
- package/dist/src/intake/intake.js +41 -1
- package/dist/src/intake/model.js +8 -3
- package/dist/src/jira/adapter.js +1 -0
- package/dist/src/jira/api.js +28 -7
- package/dist/src/jira/editor.js +243 -0
- package/dist/src/jira/model.js +19 -5
- package/dist/src/jira/source.js +41 -9
- package/dist/src/jobs/model.js +1 -0
- package/dist/src/jobs/runner.js +236 -0
- package/dist/src/limits/chatgpt.js +11 -0
- package/dist/src/limits/copilot.js +51 -18
- package/dist/src/limits/model.js +62 -8
- package/dist/src/limits/overage-session.js +2 -2
- package/dist/src/limits/overage.js +8 -5
- package/dist/src/limits/reset.js +7 -0
- package/dist/src/limits/usage.js +60 -5
- package/dist/src/linear/adapter.js +1 -0
- package/dist/src/linear/editor.js +220 -0
- package/dist/src/linear/estimate.js +32 -0
- package/dist/src/linear/model.js +24 -3
- package/dist/src/linear/source.js +74 -21
- package/dist/src/main.js +53 -23
- package/dist/src/notice/en-advice.js +28 -0
- package/dist/src/notice/en-review.js +29 -0
- package/dist/src/notice/en-startup.js +21 -0
- package/dist/src/notice/en-values.js +47 -0
- package/dist/src/notice/en.js +265 -96
- package/dist/src/notice/kinds.js +26 -0
- package/dist/src/notice/notice.js +49 -6
- package/dist/src/npm-access.js +58 -0
- package/dist/src/opencode/adapter.js +4 -2
- package/dist/src/opencode/cli.js +34 -25
- package/dist/src/opencode/go.js +51 -0
- package/dist/src/opencode/home.js +41 -8
- package/dist/src/opencode/transcript.js +5 -5
- package/dist/src/opencode/usage.js +10 -4
- package/dist/src/opencode/window.js +54 -0
- package/dist/src/packages/check.js +11 -5
- package/dist/src/packages/gateway.js +76 -6
- package/dist/src/packages/launch.js +6 -3
- package/dist/src/packages/model.js +61 -2
- package/dist/src/packages/npm.js +55 -6
- package/dist/src/packages/plugins.js +23 -2
- package/dist/src/packages/service.js +104 -17
- package/dist/src/packages/settings.js +13 -0
- package/dist/src/packages/store.js +1 -1
- package/dist/src/paths.js +32 -0
- package/dist/src/profiles/control.js +1 -0
- package/dist/src/profiles/model.js +2 -2
- package/dist/src/profiles/oauth-error.js +1 -9
- package/dist/src/profiles/oauth-response.js +2 -0
- package/dist/src/profiles/service.js +46 -4
- package/dist/src/profiles/store.js +10 -5
- package/dist/src/projects/add.js +25 -2
- package/dist/src/projects/branch-control.js +86 -0
- package/dist/src/projects/branch-move.js +39 -0
- package/dist/src/projects/branch.js +13 -0
- package/dist/src/projects/check.js +80 -36
- package/dist/src/projects/creation.js +166 -0
- package/dist/src/projects/git-found.js +62 -0
- package/dist/src/projects/git-mode.js +116 -0
- package/dist/src/projects/own-folder.js +8 -0
- package/dist/src/projects/place.js +235 -0
- package/dist/src/projects/remote-branches.js +24 -0
- package/dist/src/projects/target-read.js +95 -0
- package/dist/src/projects/target.js +56 -0
- package/dist/src/review/events.js +1 -1
- package/dist/src/review/note.js +58 -0
- package/dist/src/review/open.js +3 -3
- package/dist/src/review/wiring.js +25 -3
- package/dist/src/secrets/catalog.js +4 -1
- package/dist/src/server-control.js +1 -0
- package/dist/src/server-guard.js +4 -0
- package/dist/src/server-request.js +88 -10
- package/dist/src/server-response.js +143 -0
- package/dist/src/server-security.js +16 -0
- package/dist/src/server.js +105 -117
- package/dist/src/service/account-packages.js +116 -0
- package/dist/src/service/accounts.js +109 -81
- package/dist/src/service/badge-private.js +62 -0
- package/dist/src/service/badge.js +203 -0
- package/dist/src/service/chain-prompts.js +87 -0
- package/dist/src/service/chain.js +120 -190
- package/dist/src/service/cleanup.js +114 -0
- package/dist/src/service/cli-check.js +1 -1
- package/dist/src/service/closing.js +57 -0
- package/dist/src/service/demo.js +46 -0
- package/dist/src/service/hosting.js +239 -18
- package/dist/src/service/install-check.js +78 -0
- package/dist/src/service/lifecycle.js +4 -7
- package/dist/src/service/stats.js +3 -3
- package/dist/src/service/trackers.js +27 -1
- package/dist/src/service/vocabulary.js +17 -0
- package/dist/src/service.js +215 -19
- package/dist/src/sessions/agents.js +10 -2
- package/dist/src/sessions/approvals.js +1 -1
- package/dist/src/sessions/ask.js +32 -6
- package/dist/src/sessions/boot.js +7 -0
- package/dist/src/sessions/chat.js +16 -4
- package/dist/src/sessions/commandPrompt.js +13 -6
- package/dist/src/sessions/history.js +2 -0
- package/dist/src/sessions/keepwarm.js +1 -1
- package/dist/src/sessions/launch.js +21 -25
- package/dist/src/sessions/lingering.js +30 -7
- package/dist/src/sessions/mail.js +7 -6
- package/dist/src/sessions/mailRelay.js +2 -2
- package/dist/src/sessions/mailbox.js +1 -1
- package/dist/src/sessions/monitor.js +47 -3
- package/dist/src/sessions/note.js +44 -19
- package/dist/src/sessions/permission.js +32 -10
- package/dist/src/sessions/protection.js +38 -14
- package/dist/src/sessions/rare.js +130 -0
- package/dist/src/sessions/runs-store.js +20 -0
- package/dist/src/sessions/runs.js +140 -0
- package/dist/src/sessions/tail.js +4 -0
- package/dist/src/sessions/transcript.js +64 -8
- package/dist/src/settings/defaults.js +1 -0
- package/dist/src/settings/registry.js +86 -24
- package/dist/src/settings/store.js +14 -5
- package/dist/src/setup.js +5 -0
- package/dist/src/shown-work.js +22 -0
- package/dist/src/state/settings.js +1 -0
- package/dist/src/stats/base-sql.js +7 -1
- package/dist/src/stats/checkpoint.js +8 -5
- package/dist/src/stats/model.js +1 -1
- package/dist/src/stats/reader.js +50 -25
- package/dist/src/stats/rules-reader.js +6 -2
- package/dist/src/stats/steps-reader.js +5 -0
- package/dist/src/stats/tally-schema.js +1 -1
- package/dist/src/storage/backup-model.js +3 -0
- package/dist/src/storage/backup-schedule.js +197 -0
- package/dist/src/storage/backup-worker.js +9 -0
- package/dist/src/storage/backup.js +141 -0
- package/dist/src/storage/browser-hotkeys.js +25 -0
- package/dist/src/storage/context-windows.js +39 -0
- package/dist/src/storage/copy.js +44 -13
- package/dist/src/storage/database.js +343 -4
- package/dist/src/storage/left-folders.js +16 -0
- package/dist/src/storage/migrations.js +98 -1
- package/dist/src/storage/owner.js +12 -7
- package/dist/src/storage/schema.js +1 -1
- package/dist/src/storage/startup.js +25 -0
- package/dist/src/storage/state-files.js +1 -1
- package/dist/src/storage/vacuum.js +29 -0
- package/dist/src/taskmcp/args.js +146 -0
- package/dist/src/taskmcp/calls.js +741 -0
- package/dist/src/taskmcp/downloads.js +87 -0
- package/dist/src/taskmcp/files.js +58 -0
- package/dist/src/taskmcp/retries.js +57 -0
- package/dist/src/taskmcp/server.js +81 -0
- package/dist/src/taskmcp/tools.js +128 -0
- package/dist/src/taskmcp/vocabulary.js +75 -0
- package/dist/src/tools/panel.js +41 -8
- package/dist/src/tools/sessionSettings.js +2 -1
- package/dist/src/tools/settings.js +16 -3
- package/dist/src/tracker/adapters.js +3 -1
- package/dist/src/tracker/card.js +16 -12
- package/dist/src/tracker/close.js +57 -0
- package/dist/src/tracker/closer.js +18 -15
- package/dist/src/tracker/closes.js +6 -0
- package/dist/src/tracker/control.js +32 -13
- package/dist/src/tracker/diagnostics.js +5 -2
- package/dist/src/tracker/editor.js +108 -0
- package/dist/src/tracker/export-target.js +30 -0
- package/dist/src/tracker/export.js +168 -0
- package/dist/src/tracker/health.js +5 -0
- package/dist/src/tracker/link.js +127 -24
- package/dist/src/tracker/markers.js +7 -0
- package/dist/src/tracker/model.js +0 -12
- package/dist/src/tracker/parents.js +8 -0
- package/dist/src/tracker/questions.js +24 -3
- package/dist/src/tracker/readers.js +19 -3
- package/dist/src/tracker/source.js +5 -0
- package/dist/src/tracker/start.js +61 -6
- package/dist/src/tracker/templates.js +102 -0
- package/dist/src/tracker/trackers.js +20 -10
- package/dist/src/updates/runner.js +1 -1
- package/dist/src/updates/settle.js +11 -3
- package/dist/src/updates/updater.js +4 -4
- package/dist/tally/src/builtin-tasks.js +45 -0
- package/dist/tally/src/catalogue.js +70 -0
- package/dist/tally/src/classify.js +1 -0
- package/dist/tally/src/collect.js +33 -10
- package/dist/tally/src/copilot.js +1 -0
- package/dist/tally/src/db-classify.js +46 -0
- package/dist/tally/src/db.js +66 -60
- package/dist/tally/src/migrations/10-rework-label.sql +73 -0
- package/dist/tally/src/migrations/11-catalogue-prices.sql +53 -0
- package/dist/tally/src/migrations/12-key-spends.sql +30 -0
- package/dist/tally/src/migrations/13-normal-spans.sql +110 -0
- package/dist/tally/src/migrations/14-model-families.sql +25 -0
- package/dist/tally/src/migrations/15-task-moves.sql +32 -0
- package/dist/tally/src/migrations.js +1 -1
- package/dist/tally/src/opencode.js +1 -0
- package/dist/tally/src/parse.js +3 -0
- package/dist/tally/src/rollout.js +2 -1
- package/dist/tally/src/rule-hook-size.js +2 -1
- package/dist/tally/src/rule-hook.js +3 -0
- package/dist/tally/src/task-moves.js +32 -0
- package/dist/web/assets/BadgeDialog-Dx2EERWr.js +1 -0
- package/dist/web/assets/BadgeDialog-W0giN4k2.css +1 -0
- package/dist/web/assets/DescriptionEditor-BL_6314d.js +216 -0
- package/dist/web/assets/ProjectPackages-D-Hqs0sG.js +1 -0
- package/dist/web/assets/Select-B5xZpiCG.js +1 -0
- package/dist/web/assets/Select-CYemy5Na.css +1 -0
- package/dist/web/assets/TaskCard-B9EJ_Qa2.js +2 -0
- package/dist/web/assets/TaskCard-BV2lQojC.css +1 -0
- package/dist/web/assets/TranscriptWindow-BN6jSpev.css +1 -0
- package/dist/web/assets/TranscriptWindow-E8DxggYC.js +4 -0
- package/dist/web/assets/accountParts-c2gPSGKK.js +3 -0
- package/dist/web/assets/accountParts-tFRVownp.css +1 -0
- package/dist/web/assets/blocks-B03KxlgQ.js +12 -0
- package/dist/web/assets/blocks-Dx3DACiG.css +1 -0
- package/dist/web/assets/cardDrafts-Cb5dNpJ3.js +12 -0
- package/dist/web/assets/cardDrafts-izWnctoh.css +1 -0
- package/dist/web/assets/cardSide-63fNWHHv.css +1 -0
- package/dist/web/assets/cardSide-CIGvmTwG.js +2 -0
- package/dist/web/assets/description-C-o9LBbp.css +1 -0
- package/dist/web/assets/feedLine-Buzox_AA.js +1 -0
- package/dist/web/assets/feedLine-CBjZXWwX.css +1 -0
- package/dist/web/assets/hooks-DdmIE6gF.js +1 -0
- package/dist/web/assets/index-CkYiatZt.css +1 -0
- package/dist/web/assets/index-DELgEMlH.js +25 -0
- package/dist/web/assets/lib-B8qNeB0X.css +1 -0
- package/dist/web/assets/lib-C1i2rKJZ.js +18 -0
- package/dist/web/assets/overview-B7iEgjQD.css +1 -0
- package/dist/web/assets/overview-D9PUjFeR.js +7 -0
- package/dist/web/assets/packageGroups-B34vA6-0.js +1 -0
- package/dist/web/assets/packages-Dld4uH9X.css +1 -0
- package/dist/web/assets/react-dom-vGPErQYp.js +1 -0
- package/dist/web/assets/rules-BVB-I2tg.js +1 -0
- package/dist/web/assets/rules-Bgil4ZBp.css +1 -0
- package/dist/web/assets/secret-CmK85pY6.js +1 -0
- package/dist/web/assets/secret-DldsC74x.css +1 -0
- package/dist/web/assets/useFileDrop-eZtIxL1H.js +1 -0
- package/dist/web/assets/useHeightGlide-BmtdsmN0.css +1 -0
- package/dist/web/assets/useHeightGlide-DQvvOoIL.js +3 -0
- package/dist/web/assets/useRowFocus-CwOoEmzD.js +1 -0
- package/dist/web/index.html +30 -9
- package/dist/web/theme.js +6 -0
- package/even-keel.config.example.json +5 -4
- package/package.json +21 -5
- package/plugins/agent-bridge/.claude-plugin/plugin.json +16 -0
- package/plugins/{checkpoint → agent-bridge}/README.md +20 -6
- package/plugins/agent-bridge/hooks/addressban.mjs +64 -0
- package/plugins/{checkpoint → agent-bridge}/hooks/checkpoint-mark.mjs +4 -3
- package/plugins/{checkpoint → agent-bridge}/hooks/evenkeel.mjs +28 -11
- package/plugins/agent-bridge/hooks/git-ban.mjs +31 -0
- package/plugins/agent-bridge/hooks/gitban.mjs +83 -0
- package/plugins/agent-bridge/hooks/handoff.mjs +20 -0
- package/plugins/{checkpoint → agent-bridge}/hooks/hooks.json +10 -0
- package/plugins/{checkpoint → agent-bridge}/hooks/mailbox.mjs +6 -3
- package/plugins/{checkpoint → agent-bridge}/hooks/nudges.mjs +11 -7
- package/plugins/{checkpoint/opencode/checkpoint.mjs → agent-bridge/opencode/agent-bridge.mjs} +15 -9
- package/plugins/forgejo/.claude-plugin/plugin.json +7 -0
- package/plugins/forgejo/.mcp.json +13 -0
- package/plugins/forgejo/README.md +23 -0
- package/plugins/forgejo/skills/task/SKILL.md +55 -0
- package/plugins/github/.claude-plugin/plugin.json +1 -1
- package/plugins/github/README.md +1 -1
- package/plugins/github/skills/task/SKILL.md +2 -2
- package/plugins/gitlab/.claude-plugin/plugin.json +1 -1
- package/plugins/gitlab/skills/task/SKILL.md +2 -2
- package/plugins/huly/.claude-plugin/plugin.json +1 -1
- package/plugins/huly/skills/task/SKILL.md +4 -4
- package/plugins/jira/.claude-plugin/plugin.json +1 -1
- package/plugins/jira/skills/task/SKILL.md +3 -3
- package/plugins/linear/.claude-plugin/plugin.json +1 -1
- package/plugins/linear/README.md +1 -1
- package/plugins/linear/skills/task/SKILL.md +3 -3
- package/plugins/tally/.claude-plugin/plugin.json +1 -1
- package/plugins/tally/skills/session-audit/SKILL.md +5 -5
- package/plugins/tasks/.claude-plugin/plugin.json +9 -0
- package/plugins/tasks/.mcp.json +8 -0
- package/plugins/tasks/README.md +42 -0
- package/plugins/tasks/hooks/calibration-context.mjs +45 -0
- package/plugins/tasks/hooks/calibration.mjs +92 -0
- package/plugins/tasks/hooks/check-service.mjs +15 -0
- package/plugins/tasks/hooks/hooks.json +28 -0
- package/plugins/tasks/hooks/service-check.mjs +34 -0
- package/plugins/tasks/hooks/show-calibration.mjs +19 -0
- package/plugins/tasks/opencode/tasks.mjs +28 -0
- package/plugins/tasks/skills/split/SKILL.md +29 -0
- package/plugins/tasks/skills/task/SKILL.md +61 -0
- package/service/EvenKeelTray.cs +4 -20
- package/service/install.sh +25 -2
- package/service/uninstall.ps1 +16 -0
- package/service/uninstall.sh +10 -0
- package/tally/tally.config.json +2 -0
- package/dist/web/assets/Loader-CRe-GCoI.js +0 -31
- package/dist/web/assets/Loader-DJJTBsaF.css +0 -1
- package/dist/web/assets/TaskCard-Br2QIllc.css +0 -1
- package/dist/web/assets/TaskCard-C2xeaHWD.js +0 -2
- package/dist/web/assets/TranscriptWindow-B9zsSmIg.css +0 -1
- package/dist/web/assets/TranscriptWindow-COL_WTrF.js +0 -4
- package/dist/web/assets/feedLine-D0lnFyBZ.js +0 -1
- package/dist/web/assets/index-DQje9Nfo.js +0 -25
- package/dist/web/assets/index-mDBlgk2Y.css +0 -1
- package/dist/web/assets/media-BlW-XXN0.js +0 -1
- package/dist/web/assets/media-DR8nAbPy.css +0 -1
- package/dist/web/assets/useModels-1oIk0mDX.css +0 -1
- package/dist/web/assets/useModels-DRW63oka.js +0 -15
- package/plugins/checkpoint/.claude-plugin/plugin.json +0 -9
- package/plugins/checkpoint/hooks/handoff.mjs +0 -9
- /package/plugins/{checkpoint → agent-bridge}/hooks/context-checkpoint.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/merge-check.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/merges.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/permission.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/schema-hint.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/standard-gate.mjs +0 -0
- /package/plugins/{checkpoint → agent-bridge}/hooks/standards.mjs +0 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { BADGE_FONTS } from './fonts.generated.js';
|
|
2
|
+
import { printed } from './dates.js';
|
|
3
|
+
import { escapeXml, fit, measure } from './text.js';
|
|
4
|
+
import { BADGE_THEMES, toolIcon } from './theme.js';
|
|
5
|
+
const WIDTH = 840;
|
|
6
|
+
const PAD = 32;
|
|
7
|
+
const INNER = WIDTH - PAD * 2;
|
|
8
|
+
const TOP = 20;
|
|
9
|
+
const STALE_MIN = 5;
|
|
10
|
+
const OFFLINE_MIN = 60;
|
|
11
|
+
const CHIP_HEIGHT = 26;
|
|
12
|
+
const CHIP_MIN = 86;
|
|
13
|
+
const CHIP_GAP = 8;
|
|
14
|
+
/** The row of close times under the chips. */
|
|
15
|
+
const DATE_ROW = 18;
|
|
16
|
+
const CARD_HEIGHT = 92;
|
|
17
|
+
const CARD_GAP = 12;
|
|
18
|
+
const TILE_WIDTH = 100;
|
|
19
|
+
const BAR_GAP = 3;
|
|
20
|
+
const LABEL_SPACING = 1.5;
|
|
21
|
+
const AGENT_TITLES = { claude: 'Claude Code', codex: 'Codex', opencode: 'OpenCode', copilot: 'GitHub Copilot' };
|
|
22
|
+
export function badgeMode(state, now) {
|
|
23
|
+
if (state === null)
|
|
24
|
+
return 'unpublished';
|
|
25
|
+
const age = ageMinutes(state.at, now);
|
|
26
|
+
if (age > OFFLINE_MIN)
|
|
27
|
+
return 'offline';
|
|
28
|
+
if (state.chain.state !== 'running')
|
|
29
|
+
return 'still';
|
|
30
|
+
return age > STALE_MIN ? 'stale' : 'live';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The badge of a project's chain as an SVG document: no script, no outside resource, animations in its own CSS. The
|
|
34
|
+
* layout follows the mockups of BTN-915: one task gets a large title with its agent under it, several share the rows.
|
|
35
|
+
*/
|
|
36
|
+
export function renderBadge(state, options) {
|
|
37
|
+
const theme = BADGE_THEMES[options.theme];
|
|
38
|
+
const mode = badgeMode(state, options.now);
|
|
39
|
+
const draw = new Drawing(theme, options.still !== true && (mode === 'live' || mode === 'stale'));
|
|
40
|
+
const header = headerOf(state, mode, theme, options.now);
|
|
41
|
+
let y = drawHeader(draw, header);
|
|
42
|
+
let height = y + 29;
|
|
43
|
+
if (state !== null) {
|
|
44
|
+
if (state.active.length === 0 && mode !== 'still')
|
|
45
|
+
y = drawLine(draw, nextLine(state.chain), y);
|
|
46
|
+
const single = state.active.length === 1;
|
|
47
|
+
state.active.forEach((task, index) => {
|
|
48
|
+
y = drawTask(draw, task, { mode, single, at: state.at, now: options.now }, y + (index > 0 ? 32 : single ? 43 : 41));
|
|
49
|
+
});
|
|
50
|
+
y = drawChain(draw, state, y);
|
|
51
|
+
height = drawPanels(draw, state, y) + 18;
|
|
52
|
+
}
|
|
53
|
+
height = Math.ceil(height);
|
|
54
|
+
const label = [state === null ? null : projectLabel(state), header.label, ...(state?.active ?? []).map(spoken)].filter((each) => each !== null).join('. ');
|
|
55
|
+
return [
|
|
56
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${WIDTH}" height="${height}" viewBox="0 0 ${WIDTH} ${height}" role="img" aria-label="${escapeXml(label)}">`,
|
|
57
|
+
`<title>${escapeXml(label)}</title>`,
|
|
58
|
+
`<style>${styles(options.fonts !== false)}</style>`,
|
|
59
|
+
`<rect x="0.5" y="0.5" width="${WIDTH - 1}" height="${height - 1}" rx="14" fill="${theme.bg}" stroke="${theme.border}"/>`,
|
|
60
|
+
...draw.parts,
|
|
61
|
+
'</svg>',
|
|
62
|
+
].join('\n');
|
|
63
|
+
}
|
|
64
|
+
class Drawing {
|
|
65
|
+
theme;
|
|
66
|
+
animated;
|
|
67
|
+
parts = [];
|
|
68
|
+
constructor(theme, animated) {
|
|
69
|
+
this.theme = theme;
|
|
70
|
+
this.animated = animated;
|
|
71
|
+
}
|
|
72
|
+
text(x, y, content, face, size, fill, extra = '') {
|
|
73
|
+
const weight = face === 'sans-bold' ? ' font-weight="600"' : '';
|
|
74
|
+
const family = face === 'mono' ? 'm' : 's';
|
|
75
|
+
this.parts.push(`<text x="${n(x)}" y="${n(y)}" class="${family}" font-size="${size}"${weight} fill="${fill}"${extra}>${escapeXml(content)}</text>`);
|
|
76
|
+
}
|
|
77
|
+
add(part) {
|
|
78
|
+
this.parts.push(part);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function headerOf(state, mode, theme, now) {
|
|
82
|
+
if (state === null)
|
|
83
|
+
return { label: 'NOT PUBLISHED YET', color: theme.fgMuted, dot: theme.idle, motion: null, subtitle: null, right: null };
|
|
84
|
+
const name = state.project.name === '' ? state.project.key : state.project.name;
|
|
85
|
+
const age = ageMinutes(state.at, now);
|
|
86
|
+
if (mode === 'offline')
|
|
87
|
+
return { label: `OFFLINE · last seen ${ago(age)}`, color: theme.fgMuted, dot: theme.idle, motion: null, subtitle: name, right: null };
|
|
88
|
+
const right = age < 1 ? 'updated just now' : `updated ${ago(age)}`;
|
|
89
|
+
if (mode === 'still') {
|
|
90
|
+
const { chain } = state;
|
|
91
|
+
const label = chain.state === 'paused' ? 'CHAIN PAUSED' : chain.state === 'stopped' ? 'CHAIN STOPPED' : chain.next === null ? 'IDLE' : `IDLE · next up: ${chain.next}`;
|
|
92
|
+
return { label, color: theme.fgMuted, dot: theme.idle, motion: null, subtitle: name, right };
|
|
93
|
+
}
|
|
94
|
+
const count = state.active.length;
|
|
95
|
+
const waiting = count > 0 && state.active.every((task) => task.state !== 'working');
|
|
96
|
+
const stale = mode === 'stale';
|
|
97
|
+
if (waiting) {
|
|
98
|
+
const limited = state.active.filter((task) => task.state === 'limit').length;
|
|
99
|
+
const subtitle = limited === count ? `${name} waits for the usage limit to reset`
|
|
100
|
+
: limited > 0 ? 'the agents wait for the usage limit and for the maintainer'
|
|
101
|
+
: count === 1 ? 'the agent asked the maintainer and waits for the answer'
|
|
102
|
+
: 'the agents asked the maintainer and wait for the answers';
|
|
103
|
+
return { label: 'WAITING', color: theme.waiting, dot: stale ? theme.idle : theme.waiting, motion: stale ? null : 'breathe', subtitle, right };
|
|
104
|
+
}
|
|
105
|
+
const subtitle = count === 0 ? name : `${name} is being built right now${count > 1 ? ` · ${count} tasks at once` : ''}`;
|
|
106
|
+
return { label: 'LIVE', color: theme.done, dot: stale ? theme.idle : theme.done, motion: stale ? null : 'ring', subtitle, right };
|
|
107
|
+
}
|
|
108
|
+
/** The header's line; returns its baseline. */
|
|
109
|
+
function drawHeader(draw, header) {
|
|
110
|
+
const { theme } = draw;
|
|
111
|
+
const cy = TOP + 14;
|
|
112
|
+
const base = cy + 5;
|
|
113
|
+
if (header.motion === 'ring' && draw.animated)
|
|
114
|
+
draw.add(`<circle cx="${PAD + 8}" cy="${cy}" r="5" fill="${header.dot}" class="ring"/>`);
|
|
115
|
+
draw.add(`<circle cx="${PAD + 8}" cy="${cy}" r="5" fill="${header.dot}"${header.motion === 'breathe' && draw.animated ? ' class="breathe"' : ''}/>`);
|
|
116
|
+
const right = header.right === null ? 0 : measure(header.right, 'sans', 12) + 16;
|
|
117
|
+
const labelX = PAD + 24;
|
|
118
|
+
const label = fit(header.label, 'sans-bold', 13, WIDTH - PAD - labelX - right - [...header.label].length * LABEL_SPACING);
|
|
119
|
+
draw.text(labelX, base, label, 'sans-bold', 13, header.color, ` letter-spacing="${LABEL_SPACING}"`);
|
|
120
|
+
if (header.subtitle !== null) {
|
|
121
|
+
const x = labelX + measure(label, 'sans-bold', 13) + [...label].length * LABEL_SPACING + 10;
|
|
122
|
+
const subtitle = fit(header.subtitle, 'sans', 13, WIDTH - PAD - right - x);
|
|
123
|
+
if (subtitle !== '')
|
|
124
|
+
draw.text(x, base, subtitle, 'sans', 13, theme.fgMuted);
|
|
125
|
+
}
|
|
126
|
+
if (header.right !== null)
|
|
127
|
+
draw.text(WIDTH - PAD, base, header.right, 'sans', 12, theme.fgMuted, ' text-anchor="end"');
|
|
128
|
+
return base;
|
|
129
|
+
}
|
|
130
|
+
function drawLine(draw, line, top) {
|
|
131
|
+
draw.text(PAD, top + 34, fit(line, 'sans', 13, INNER), 'sans', 13, draw.theme.fgMuted);
|
|
132
|
+
return top + 34;
|
|
133
|
+
}
|
|
134
|
+
function nextLine(chain) {
|
|
135
|
+
return chain.next === null ? 'no task in hand' : `no task in hand · next up: ${chain.next}`;
|
|
136
|
+
}
|
|
137
|
+
/** A task's title line and its bar, from the title's baseline; returns the bar's bottom. */
|
|
138
|
+
function drawTask(draw, task, layout, base) {
|
|
139
|
+
const { theme } = draw;
|
|
140
|
+
const { single } = layout;
|
|
141
|
+
const offline = layout.mode === 'offline';
|
|
142
|
+
let x = PAD;
|
|
143
|
+
if (offline) {
|
|
144
|
+
draw.text(x, base, 'was working on', 'sans', 13, theme.fgMuted);
|
|
145
|
+
x += measure('was working on', 'sans', 13) + 8;
|
|
146
|
+
}
|
|
147
|
+
const keySize = single ? 15 : 14;
|
|
148
|
+
draw.text(x, base, task.key, 'mono', keySize, theme.accent);
|
|
149
|
+
x += measure(task.key, 'mono', keySize) + (single ? 16 : 14);
|
|
150
|
+
const meta = metaOf(task, offline ? new Date(layout.at) : layout.now, single);
|
|
151
|
+
const metaWidth = single || meta === '' ? 0 : measure(meta, 'sans', 12) + 16;
|
|
152
|
+
const titleSize = single ? 18 : 16;
|
|
153
|
+
// No English title — the key alone: a word in its place would read as the task's title (BTN-974).
|
|
154
|
+
if (task.titleEn !== undefined)
|
|
155
|
+
draw.text(x, base, fit(task.titleEn, 'sans-bold', titleSize, WIDTH - PAD - x - metaWidth), 'sans-bold', titleSize, theme.fg);
|
|
156
|
+
if (meta !== '') {
|
|
157
|
+
if (single)
|
|
158
|
+
draw.text(x, base + 24, fit(meta, 'sans', 12.5, WIDTH - PAD - x), 'sans', 12.5, theme.fgMuted);
|
|
159
|
+
else
|
|
160
|
+
draw.text(WIDTH - PAD, base, meta, 'sans', 12, theme.fgMuted, ' text-anchor="end"');
|
|
161
|
+
}
|
|
162
|
+
const bar = single ? { top: base + 46, height: 30, size: 13 } : { top: base + 22, height: 26, size: 12.5 };
|
|
163
|
+
if (task.state === 'waiting')
|
|
164
|
+
drawWaiting(draw, task, bar, "waiting for the maintainer's answer");
|
|
165
|
+
else if (task.state === 'limit')
|
|
166
|
+
drawWaiting(draw, task, bar, limitLine(task, layout.now));
|
|
167
|
+
else
|
|
168
|
+
drawBar(draw, task, layout.mode, bar);
|
|
169
|
+
return bar.top + bar.height;
|
|
170
|
+
}
|
|
171
|
+
/** The reset is counted when the picture is shown; one that has passed or is not known is not named. */
|
|
172
|
+
function limitLine(task, now) {
|
|
173
|
+
const minutes = task.until === undefined ? NaN : (Date.parse(task.until) - now.getTime()) / 60_000;
|
|
174
|
+
return minutes > 0 ? `waiting for the usage limit · resets in ${duration(minutes)}` : 'waiting for the usage limit';
|
|
175
|
+
}
|
|
176
|
+
function textBase(bar) {
|
|
177
|
+
return bar.top + bar.height / 2 + bar.size * 0.36;
|
|
178
|
+
}
|
|
179
|
+
function drawWaiting(draw, task, bar, line) {
|
|
180
|
+
const { theme } = draw;
|
|
181
|
+
draw.add(`<rect x="${PAD + 0.5}" y="${bar.top + 0.5}" width="${INNER - 1}" height="${bar.height - 1}" rx="${bar.height === 30 ? 8 : 7}" fill="${theme.waiting}" fill-opacity="0.08" stroke="${theme.waiting}" stroke-opacity="0.5" stroke-dasharray="5 4"/>`);
|
|
182
|
+
const y = textBase(bar);
|
|
183
|
+
if (task.state === 'limit')
|
|
184
|
+
draw.add(pauseIcon(PAD + 17.5, bar.top + bar.height / 2, theme.waiting));
|
|
185
|
+
else
|
|
186
|
+
draw.text(PAD + 14, y, '?', 'sans-bold', bar.size, theme.waiting);
|
|
187
|
+
const label = contextLabel(task);
|
|
188
|
+
draw.text(PAD + 30, y, fit(line, 'mono', bar.size, INNER - 30 - (label === null ? 0 : measure(label, 'mono', 12) + 28) - 14), 'mono', bar.size, theme.warnFg);
|
|
189
|
+
drawContext(draw, task, theme.warnFg, y);
|
|
190
|
+
}
|
|
191
|
+
function drawBar(draw, task, mode, bar) {
|
|
192
|
+
const { theme } = draw;
|
|
193
|
+
const claude = task.agent !== undefined && task.agent.toLowerCase() === 'claude';
|
|
194
|
+
const fill = claude ? theme.claude : theme.working;
|
|
195
|
+
const ink = claude ? theme.warnFg : theme.otherFg;
|
|
196
|
+
const rx = bar.height === 30 ? 8 : 7;
|
|
197
|
+
const { top, height } = bar;
|
|
198
|
+
const parts = [`<rect x="${PAD + 0.5}" y="${top + 0.5}" width="${INNER - 1}" height="${height - 1}" rx="${rx}" fill="${theme.surface}" stroke="${theme.border}"/>`];
|
|
199
|
+
const context = contextOf(task);
|
|
200
|
+
if (context !== null && context > 0) {
|
|
201
|
+
const width = (INNER * context) / 100;
|
|
202
|
+
parts.push(`<clipPath id="bar-${n(top)}"><rect x="${PAD}" y="${top}" width="${INNER}" height="${height}" rx="${rx}"/></clipPath>`);
|
|
203
|
+
parts.push(`<rect x="${PAD}" y="${top}" width="${n(width)}" height="${height}" fill="${fill}" fill-opacity="0.22" clip-path="url(#bar-${n(top)})"/>`);
|
|
204
|
+
if (context < 100)
|
|
205
|
+
parts.push(`<rect x="${n(PAD + width - 1)}" y="${top}" width="2" height="${height}" fill="${ink}"${draw.animated ? ' class="glow"' : ' fill-opacity="0.4"'}/>`);
|
|
206
|
+
}
|
|
207
|
+
const action = task.action ?? null;
|
|
208
|
+
parts.push(`<g transform="translate(${PAD + 11} ${n(top + (height - 14) / 2)}) scale(0.875)" fill="none" stroke="${theme.accent}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">${toolIcon(action?.tool ?? '')}</g>`);
|
|
209
|
+
const label = contextLabel(task);
|
|
210
|
+
const right = label === null ? 0 : measure(label, 'mono', 12) + 28;
|
|
211
|
+
const text = action === null ? (task.action === undefined ? '' : 'thinking') : action.text;
|
|
212
|
+
const shown = fit(text, 'mono', bar.size, INNER - 30 - right - 14);
|
|
213
|
+
const y = textBase(bar);
|
|
214
|
+
draw.add(mode === 'offline' ? `<g opacity="0.5">${parts.join('')}` : parts.join(''));
|
|
215
|
+
if (shown !== '')
|
|
216
|
+
draw.text(PAD + 30, y, shown, 'mono', bar.size, ink);
|
|
217
|
+
if (draw.animated) {
|
|
218
|
+
const x = PAD + 30 + measure(shown, 'mono', bar.size) + (shown === '' ? 0 : 4);
|
|
219
|
+
draw.add(`<rect x="${n(x)}" y="${n(top + (height - bar.size - 1) / 2)}" width="${n(bar.size * 0.6)}" height="${bar.size + 1}" fill="${ink}" class="blink"/>`);
|
|
220
|
+
}
|
|
221
|
+
drawContext(draw, task, ink, y);
|
|
222
|
+
if (mode === 'offline')
|
|
223
|
+
draw.add('</g>');
|
|
224
|
+
}
|
|
225
|
+
function contextOf(task) {
|
|
226
|
+
return task.context === undefined ? null : Math.max(0, Math.min(100, Math.round(task.context)));
|
|
227
|
+
}
|
|
228
|
+
function contextLabel(task) {
|
|
229
|
+
const context = contextOf(task);
|
|
230
|
+
return context === null ? null : `context ${context}%`;
|
|
231
|
+
}
|
|
232
|
+
function drawContext(draw, task, ink, y) {
|
|
233
|
+
const context = contextOf(task);
|
|
234
|
+
if (context === null)
|
|
235
|
+
return;
|
|
236
|
+
draw.add(`<text x="${WIDTH - PAD - 14}" y="${n(y)}" class="m" font-size="12" text-anchor="end"><tspan fill="${draw.theme.fgMuted}">context </tspan><tspan fill="${ink}">${context}%</tspan></text>`);
|
|
237
|
+
}
|
|
238
|
+
function metaOf(task, now, single) {
|
|
239
|
+
const agent = task.agent === undefined ? null : agentTitle(task.agent);
|
|
240
|
+
const minutes = task.startedAt === undefined ? Infinity : ageMinutes(task.startedAt, now);
|
|
241
|
+
const time = minutes === Infinity ? null : single ? `started ${ago(minutes)}` : duration(minutes);
|
|
242
|
+
return [agent, task.model ?? null, time].filter((each) => each !== null && each !== '').join(' · ');
|
|
243
|
+
}
|
|
244
|
+
function agentTitle(agent) {
|
|
245
|
+
return AGENT_TITLES[agent.toLowerCase()] ?? `${agent.charAt(0).toUpperCase()}${agent.slice(1)}`;
|
|
246
|
+
}
|
|
247
|
+
/** A chip names a task of the project by its number, like the mockups; one of another project keeps its key. */
|
|
248
|
+
function chipLabel(key, project) {
|
|
249
|
+
return key.startsWith(`${project}-`) ? key.slice(project.length + 1) : key;
|
|
250
|
+
}
|
|
251
|
+
function chipContent(label, state) {
|
|
252
|
+
return (state === 'queued' ? 0 : 14) + measure(label, 'mono', 12);
|
|
253
|
+
}
|
|
254
|
+
function chipWidth(label, state) {
|
|
255
|
+
return Math.max(CHIP_MIN, chipContent(label, state) + 28);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The chips of the chain, from the bottom of what is above, a done one with the day and time the chain closed it under
|
|
259
|
+
* it (BTN-970); returns the row's bottom.
|
|
260
|
+
*/
|
|
261
|
+
function drawChain(draw, state, top) {
|
|
262
|
+
const { theme } = draw;
|
|
263
|
+
const { chain } = state;
|
|
264
|
+
if (chain.tasks === undefined || chain.tasks.length === 0)
|
|
265
|
+
return top;
|
|
266
|
+
const y = top + 22;
|
|
267
|
+
const base = y + 17;
|
|
268
|
+
const room = INNER;
|
|
269
|
+
const chips = chain.tasks.map((chip) => ({ ...chip, label: chipLabel(chip.key, state.project.key) }));
|
|
270
|
+
let more = 0;
|
|
271
|
+
const total = () => chips.reduce((sum, chip) => sum + chipWidth(chip.label, chip.state) + CHIP_GAP, 0) + (more > 0 ? measure(`+${more}`, 'mono', 12) + 8 : 0);
|
|
272
|
+
while (chips.length > 0 && total() > room) {
|
|
273
|
+
const firstDone = chips.findIndex((chip) => chip.state === 'done');
|
|
274
|
+
if (firstDone !== -1 && chips.filter((chip) => chip.state === 'done').length > 1)
|
|
275
|
+
chips.splice(firstDone, 1);
|
|
276
|
+
else {
|
|
277
|
+
chips.pop();
|
|
278
|
+
more++;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const asked = new Set(state.active.filter((task) => task.state !== 'working').map((task) => task.key));
|
|
282
|
+
let x = PAD;
|
|
283
|
+
let dated = false;
|
|
284
|
+
for (const chip of chips) {
|
|
285
|
+
const width = chipWidth(chip.label, chip.state);
|
|
286
|
+
const look = chipLook(theme, chip.state, asked.has(chip.key));
|
|
287
|
+
draw.add(`<rect x="${n(x + 0.5)}" y="${y + 0.5}" width="${n(width - 1)}" height="${CHIP_HEIGHT - 1}" rx="${CHIP_HEIGHT / 2}" ${look.box}/>`);
|
|
288
|
+
let at = x + (width - chipContent(chip.label, chip.state)) / 2;
|
|
289
|
+
if (chip.state !== 'queued') {
|
|
290
|
+
draw.add(chipIcon(chip.state, at + 4, y + CHIP_HEIGHT / 2, look.ink));
|
|
291
|
+
at += 14;
|
|
292
|
+
}
|
|
293
|
+
draw.text(at, base, chip.label, 'mono', 12, look.ink);
|
|
294
|
+
const closed = chip.state === 'done' && chip.doneAt !== undefined ? printed(chip.doneAt) : null;
|
|
295
|
+
if (closed !== null) {
|
|
296
|
+
dated = true;
|
|
297
|
+
const time = closed.time === null ? '' : `<tspan fill="${theme.done}" fill-opacity="0.9"> ${closed.time}</tspan>`;
|
|
298
|
+
draw.add(`<text x="${n(x + width / 2)}" y="${y + CHIP_HEIGHT + 15}" class="m" font-size="10.5" text-anchor="middle"><tspan fill="${theme.fgMuted}" fill-opacity="0.8">${closed.day}</tspan>${time}</text>`);
|
|
299
|
+
}
|
|
300
|
+
x += width + CHIP_GAP;
|
|
301
|
+
}
|
|
302
|
+
if (more > 0)
|
|
303
|
+
draw.text(x, base, `+${more}`, 'mono', 12, theme.fgMuted);
|
|
304
|
+
return y + CHIP_HEIGHT + (dated ? DATE_ROW : 0);
|
|
305
|
+
}
|
|
306
|
+
function chipLook(theme, state, asked) {
|
|
307
|
+
const plain = `fill="${theme.surfaceMuted}" stroke="${theme.border}"`;
|
|
308
|
+
if (state === 'done')
|
|
309
|
+
return { box: `fill="${theme.done}" fill-opacity="0.12" stroke="${theme.done}" stroke-opacity="0.45"`, ink: theme.done };
|
|
310
|
+
if (state === 'working')
|
|
311
|
+
return { box: `fill="${theme.working}" fill-opacity="0.14" stroke="${theme.accent}"`, ink: theme.accent };
|
|
312
|
+
if (state === 'waiting' || state === 'limit')
|
|
313
|
+
return { box: asked ? `fill="${theme.waiting}" fill-opacity="0.12" stroke="${theme.waiting}"` : plain, ink: theme.waiting };
|
|
314
|
+
return { box: plain, ink: theme.fgMuted };
|
|
315
|
+
}
|
|
316
|
+
function pauseIcon(cx, cy, color) {
|
|
317
|
+
return `<path d="M${n(cx - 2.5)} ${n(cy - 4)}v8 M${n(cx + 2.5)} ${n(cy - 4)}v8" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round"/>`;
|
|
318
|
+
}
|
|
319
|
+
function chipIcon(state, cx, cy, color) {
|
|
320
|
+
if (state === 'done')
|
|
321
|
+
return `<path d="M${n(cx - 4)} ${cy}l2.7 2.7 5-5.4" fill="none" stroke="${color}" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>`;
|
|
322
|
+
if (state === 'working')
|
|
323
|
+
return `<circle cx="${n(cx)}" cy="${cy}" r="3.5" fill="${color}"/>`;
|
|
324
|
+
if (state === 'limit')
|
|
325
|
+
return pauseIcon(cx, cy, color);
|
|
326
|
+
return `<text x="${n(cx)}" y="${cy + 4.5}" class="s" font-size="12" font-weight="600" fill="${color}" text-anchor="middle">?</text>`;
|
|
327
|
+
}
|
|
328
|
+
function tilesOf(stats) {
|
|
329
|
+
if (stats === undefined)
|
|
330
|
+
return [];
|
|
331
|
+
return [
|
|
332
|
+
stats.sessions === undefined ? null : { value: grouped(stats.sessions), label: stats.sessions === 1 ? 'session' : 'sessions', sub: 'last 30 days' },
|
|
333
|
+
stats.medianCost === undefined ? null : { value: `${usd(stats.medianCost)}*`, label: 'per task', sub: 'median' },
|
|
334
|
+
stats.medianMinutes === undefined ? null : { value: duration(stats.medianMinutes), label: 'per task', sub: 'median' },
|
|
335
|
+
].filter((each) => each !== null);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* The milestone's card and, right of it, the stats' card (BTN-970), from the bottom of what is above; returns their
|
|
339
|
+
* bottom. A card with nothing to show is not drawn, and the milestone's takes the room the stats' leaves.
|
|
340
|
+
*/
|
|
341
|
+
function drawPanels(draw, state, top) {
|
|
342
|
+
const { theme } = draw;
|
|
343
|
+
const milestone = state.milestone ?? null;
|
|
344
|
+
const tiles = tilesOf(state.stats);
|
|
345
|
+
if (milestone === null && tiles.length === 0)
|
|
346
|
+
return top;
|
|
347
|
+
const y = top + 18;
|
|
348
|
+
const statsWidth = tiles.length * TILE_WIDTH;
|
|
349
|
+
const card = (x, width) => draw.add(`<rect x="${x + 0.5}" y="${y + 0.5}" width="${width - 1}" height="${CARD_HEIGHT - 1}" rx="10" fill="${theme.surface}" stroke="${theme.border}"/>`);
|
|
350
|
+
if (milestone !== null) {
|
|
351
|
+
const width = INNER - (tiles.length === 0 ? 0 : statsWidth + CARD_GAP);
|
|
352
|
+
card(PAD, width);
|
|
353
|
+
drawMilestone(draw, milestone, PAD + 16, y, width - 32);
|
|
354
|
+
}
|
|
355
|
+
if (tiles.length === 0)
|
|
356
|
+
return y + CARD_HEIGHT;
|
|
357
|
+
const x = WIDTH - PAD - statsWidth;
|
|
358
|
+
card(x, statsWidth);
|
|
359
|
+
tiles.forEach((tile, index) => {
|
|
360
|
+
const cx = x + TILE_WIDTH * index + TILE_WIDTH / 2;
|
|
361
|
+
if (index > 0)
|
|
362
|
+
draw.add(`<rect x="${x + TILE_WIDTH * index}" y="${y + 18}" width="1" height="${CARD_HEIGHT - 36}" fill="${theme.border}"/>`);
|
|
363
|
+
const size = measure(tile.value, 'sans-bold', 19) > TILE_WIDTH - 12 ? 15 : 19;
|
|
364
|
+
draw.text(cx, y + 40, fit(tile.value, 'sans-bold', size, TILE_WIDTH - 8), 'sans-bold', size, theme.fg, ' text-anchor="middle"');
|
|
365
|
+
draw.text(cx, y + 59, tile.label, 'sans', 11.5, theme.fgMuted, ' text-anchor="middle"');
|
|
366
|
+
draw.text(cx, y + 74, tile.sub, 'sans', 10.5, theme.faint, ' text-anchor="middle"');
|
|
367
|
+
});
|
|
368
|
+
if (state.stats?.medianCost === undefined)
|
|
369
|
+
return y + CARD_HEIGHT;
|
|
370
|
+
draw.text(WIDTH - PAD, y + CARD_HEIGHT + 16, '* at API list prices', 'sans', 10.5, theme.faint, ' text-anchor="end"');
|
|
371
|
+
return y + CARD_HEIGHT + 16;
|
|
372
|
+
}
|
|
373
|
+
/** When the milestone is due: the forecast of the agent's part and the tracker's own date. The maintainer's part has none. */
|
|
374
|
+
function whenOf(milestone) {
|
|
375
|
+
const eta = milestone.eta === undefined ? null : printed(milestone.eta);
|
|
376
|
+
const forecast = milestone.queued === undefined ? null : milestone.queued <= 0 ? "agent's part done" : eta === null ? null : `agent's part ≈ ${eta.day}`;
|
|
377
|
+
return { forecast, target: (milestone.target === undefined ? null : printed(milestone.target))?.day ?? null };
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The milestone's card: its name, when it is due, the bar of its parts — done, queued for the agent and with the
|
|
381
|
+
* maintainer — and their legend. A part of no task has neither a piece of the bar nor a legend entry.
|
|
382
|
+
*/
|
|
383
|
+
function drawMilestone(draw, milestone, x, y, width) {
|
|
384
|
+
const { theme } = draw;
|
|
385
|
+
const base = y + 25;
|
|
386
|
+
const { forecast, target } = whenOf(milestone);
|
|
387
|
+
const targetLead = forecast === null ? 'target ' : ' · target ';
|
|
388
|
+
const whenWidth = (forecast === null ? 0 : measure(forecast, 'sans', 11.5)) + (target === null ? 0 : measure(`${targetLead}${target}`, 'sans', 11.5));
|
|
389
|
+
const room = width - (whenWidth === 0 ? 0 : whenWidth + 12);
|
|
390
|
+
const name = fit(milestone.name, 'sans-bold', 14, room);
|
|
391
|
+
draw.text(x, base, name, 'sans-bold', 14, theme.fg);
|
|
392
|
+
const after = measure(name, 'sans-bold', 14) + 8;
|
|
393
|
+
if (after + measure('next release', 'sans', 11.5) <= room)
|
|
394
|
+
draw.text(x + after, base, 'next release', 'sans', 11.5, theme.faint);
|
|
395
|
+
if (whenWidth > 0) {
|
|
396
|
+
const spans = [
|
|
397
|
+
forecast === null ? '' : `<tspan fill="${theme.fgMuted}">${escapeXml(forecast)}</tspan>`,
|
|
398
|
+
target === null ? '' : `<tspan fill="${theme.faint}">${targetLead}</tspan><tspan fill="${theme.fg}">${target}</tspan>`,
|
|
399
|
+
];
|
|
400
|
+
draw.add(`<text x="${n(x + width)}" y="${base}" class="s" font-size="11.5" text-anchor="end" xml:space="preserve">${spans.join('')}</text>`);
|
|
401
|
+
}
|
|
402
|
+
const split = milestone.queued !== undefined;
|
|
403
|
+
const queued = Math.max(0, Math.min(milestone.left, milestone.queued ?? 0));
|
|
404
|
+
const hatch = `fill="url(#ek-hold)" stroke="${theme.waiting}" stroke-opacity="0.6"`;
|
|
405
|
+
const parts = [
|
|
406
|
+
{ count: milestone.done, label: 'done', bar: `fill="${theme.done}" fill-opacity="0.85"` },
|
|
407
|
+
{ count: queued, label: 'queued for the agent', bar: `fill="${theme.working}" fill-opacity="0.9"` },
|
|
408
|
+
{ count: milestone.left - queued, label: split ? 'with the maintainer' : 'to go', bar: split ? hatch : `fill="${theme.idle}" fill-opacity="0.6"` },
|
|
409
|
+
].filter((part) => part.count > 0);
|
|
410
|
+
const barTop = y + 40;
|
|
411
|
+
const barHeight = 10;
|
|
412
|
+
draw.add(`<defs><pattern id="ek-hold" width="6" height="6" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="6" height="6" fill="${theme.waiting}" fill-opacity="0.1"/><rect width="2.2" height="6" fill="${theme.waiting}" fill-opacity="0.55"/></pattern><clipPath id="ek-parts"><rect x="${n(x)}" y="${barTop}" width="${n(width)}" height="${barHeight}" rx="5"/></clipPath></defs>`);
|
|
413
|
+
if (parts.length === 0)
|
|
414
|
+
draw.add(`<rect x="${n(x)}" y="${barTop}" width="${n(width)}" height="${barHeight}" rx="5" fill="${theme.surfaceMuted}"/>`);
|
|
415
|
+
const total = parts.reduce((sum, part) => sum + part.count, 0);
|
|
416
|
+
const usable = width - BAR_GAP * (parts.length - 1);
|
|
417
|
+
let at = x;
|
|
418
|
+
parts.forEach((part, index) => {
|
|
419
|
+
const piece = index === parts.length - 1 ? x + width - at : Math.max(6, (usable * part.count) / total);
|
|
420
|
+
draw.add(`<rect x="${n(at)}" y="${barTop}" width="${n(piece)}" height="${barHeight}" ${part.bar} clip-path="url(#ek-parts)"/>`);
|
|
421
|
+
at += piece + BAR_GAP;
|
|
422
|
+
});
|
|
423
|
+
const legend = barTop + barHeight + 22;
|
|
424
|
+
let lx = x;
|
|
425
|
+
for (const part of parts) {
|
|
426
|
+
const count = grouped(part.count);
|
|
427
|
+
draw.add(`<rect x="${n(lx)}" y="${legend - 9}" width="10" height="10" rx="3" ${part.bar}/>`);
|
|
428
|
+
draw.text(lx + 16, legend, count, 'mono', 12, theme.fg);
|
|
429
|
+
const labelX = lx + 16 + measure(count, 'mono', 12) + 5;
|
|
430
|
+
draw.text(labelX, legend, part.label, 'sans', 11.5, theme.fgMuted);
|
|
431
|
+
lx = labelX + measure(part.label, 'sans', 11.5) + 18;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function styles(fonts) {
|
|
435
|
+
const faces = fonts
|
|
436
|
+
? BADGE_FONTS.map((font) => `@font-face{font-family:ek-${font.family};font-weight:${font.weight};src:url(data:font/woff2;base64,${font.woff2}) format('woff2')}`).join('')
|
|
437
|
+
: '';
|
|
438
|
+
return [
|
|
439
|
+
faces,
|
|
440
|
+
'.s{font-family:ek-sans,system-ui,sans-serif}.m{font-family:ek-mono,ui-monospace,monospace}',
|
|
441
|
+
'@keyframes ek-ring{from{transform:scale(1);opacity:.6}to{transform:scale(2.6);opacity:0}}',
|
|
442
|
+
'@keyframes ek-breathe{0%,100%{opacity:1}50%{opacity:.35}}',
|
|
443
|
+
'@keyframes ek-blink{0%,49%{opacity:1}50%,100%{opacity:0}}',
|
|
444
|
+
'@keyframes ek-glow{0%,100%{opacity:.15}50%{opacity:.6}}',
|
|
445
|
+
'.ring{opacity:0;transform-box:fill-box;transform-origin:center;animation:ek-ring 2s ease-out infinite}',
|
|
446
|
+
'.breathe{animation:ek-breathe 4s ease-in-out infinite}',
|
|
447
|
+
'.blink{animation:ek-blink 1.1s step-end infinite}',
|
|
448
|
+
'.glow{animation:ek-glow 3s ease-in-out infinite}',
|
|
449
|
+
'@media (prefers-reduced-motion:reduce){*{animation:none!important}}',
|
|
450
|
+
].join('');
|
|
451
|
+
}
|
|
452
|
+
function projectLabel(state) {
|
|
453
|
+
const { key, name } = state.project;
|
|
454
|
+
return name === '' || name === key ? key : `${key} · ${name}`;
|
|
455
|
+
}
|
|
456
|
+
function spoken(task) {
|
|
457
|
+
const what = task.state === 'waiting' ? 'waits for an answer' : task.state === 'limit' ? 'waits for the usage limit' : 'in work';
|
|
458
|
+
return `${task.key}${task.titleEn === undefined ? '' : ` ${task.titleEn}`} ${what}`;
|
|
459
|
+
}
|
|
460
|
+
function ageMinutes(at, now) {
|
|
461
|
+
const ms = now.getTime() - Date.parse(at);
|
|
462
|
+
return Number.isNaN(ms) ? Infinity : Math.max(0, ms / 60_000);
|
|
463
|
+
}
|
|
464
|
+
function ago(minutes) {
|
|
465
|
+
if (minutes === Infinity)
|
|
466
|
+
return 'long ago';
|
|
467
|
+
if (minutes < 60)
|
|
468
|
+
return `${Math.floor(minutes)} min ago`;
|
|
469
|
+
const hours = Math.floor(minutes / 60);
|
|
470
|
+
return hours < 48 ? `${hours} h ago` : `${Math.floor(hours / 24)} d ago`;
|
|
471
|
+
}
|
|
472
|
+
function duration(minutes) {
|
|
473
|
+
if (minutes === Infinity)
|
|
474
|
+
return '';
|
|
475
|
+
const whole = Math.max(1, Math.round(minutes));
|
|
476
|
+
if (whole < 60)
|
|
477
|
+
return `${whole} min`;
|
|
478
|
+
const rest = whole % 60;
|
|
479
|
+
return rest === 0 ? `${whole / 60} h` : `${Math.floor(whole / 60)} h ${rest} min`;
|
|
480
|
+
}
|
|
481
|
+
function usd(value) {
|
|
482
|
+
return value >= 100 ? `$${Math.round(value)}` : `$${value.toFixed(2)}`;
|
|
483
|
+
}
|
|
484
|
+
function grouped(count) {
|
|
485
|
+
return String(count).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
486
|
+
}
|
|
487
|
+
/** A coordinate without float noise. */
|
|
488
|
+
function n(value) {
|
|
489
|
+
return String(Math.round(value * 10) / 10);
|
|
490
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { fail } from '../notice/notice.js';
|
|
2
|
+
import { BADGE_FIELDS, isBadgeField } from './model.js';
|
|
3
|
+
const SLUG = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/;
|
|
4
|
+
/**
|
|
5
|
+
* A project's `badge` setting as the config holds it (BTN-915): `null` — no badge. `fields` left out is every field
|
|
6
|
+
* (a hand-written config); the badge's dialog always writes them (BTN-917). An unknown field, a bad address or slug is
|
|
7
|
+
* `config.badge`.
|
|
8
|
+
*/
|
|
9
|
+
export function badgeSettingsOf(value, where) {
|
|
10
|
+
if (value === null)
|
|
11
|
+
return null;
|
|
12
|
+
if (typeof value !== 'object' || Array.isArray(value))
|
|
13
|
+
throw fail('config.badge', { where });
|
|
14
|
+
const { on, url, slug, fields } = value;
|
|
15
|
+
if (typeof on !== 'boolean' || typeof url !== 'string' || typeof slug !== 'string')
|
|
16
|
+
throw fail('config.badge', { where });
|
|
17
|
+
const address = url.trim();
|
|
18
|
+
if (address !== '' && !isHttp(address))
|
|
19
|
+
throw fail('config.badge', { where });
|
|
20
|
+
const name = slug.trim().toLowerCase();
|
|
21
|
+
if (name !== '' && !isBadgeSlug(name))
|
|
22
|
+
throw fail('config.badge', { where });
|
|
23
|
+
if (fields !== undefined && (!Array.isArray(fields) || !fields.every(isBadgeField)))
|
|
24
|
+
throw fail('config.badge', { where });
|
|
25
|
+
const picked = fields ?? [...BADGE_FIELDS];
|
|
26
|
+
return { on, url: address, slug: name, fields: BADGE_FIELDS.filter((field) => picked.includes(field)) };
|
|
27
|
+
}
|
|
28
|
+
/** The badge pushes: it is on and says where to. */
|
|
29
|
+
export function badgePushes(settings) {
|
|
30
|
+
return settings !== null && settings !== undefined && settings.on && settings.url !== '' && settings.slug !== '';
|
|
31
|
+
}
|
|
32
|
+
/** A project's name on the Worker: lower-case letters, digits and dashes, neither first nor last a dash. */
|
|
33
|
+
export const isBadgeSlug = (text) => SLUG.test(text);
|
|
34
|
+
/** The Worker's address: an http(s) URL. */
|
|
35
|
+
export function isHttp(text) {
|
|
36
|
+
try {
|
|
37
|
+
const url = new URL(text);
|
|
38
|
+
return url.protocol === 'https:' || url.protocol === 'http:';
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const DAY_MS = 86_400_000;
|
|
2
|
+
/** The badge counts the project's last 30 days, like the strip of its page. */
|
|
3
|
+
export const BADGE_STATS_DAYS = 30;
|
|
4
|
+
/** The last 30 local days of `tz` ending today, as `/stats` takes them. */
|
|
5
|
+
export function badgeStatsRange(now, tz) {
|
|
6
|
+
const to = new Intl.DateTimeFormat('en-CA', { timeZone: tz, year: 'numeric', month: '2-digit', day: '2-digit' }).format(now);
|
|
7
|
+
const from = new Date(Date.parse(`${to}T00:00:00Z`) - (BADGE_STATS_DAYS - 1) * DAY_MS).toISOString().slice(0, 10);
|
|
8
|
+
return { from, to };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The badge's numbers from the project's period: its sessions, and the median finished task — its cost at API list
|
|
12
|
+
* prices and its active minutes, each the median on its own.
|
|
13
|
+
*/
|
|
14
|
+
export function badgeStatsOf(period) {
|
|
15
|
+
const done = period.tasks.filter((row) => row.done === true);
|
|
16
|
+
const result = { sessions: period.current.sessions };
|
|
17
|
+
const cost = median(done.map((row) => row.priceEstimate ?? row.cost));
|
|
18
|
+
if (cost !== null)
|
|
19
|
+
result.medianCost = Math.round(cost * 100) / 100;
|
|
20
|
+
const minutes = median(done.flatMap((row) => (row.activeS === null ? [] : [row.activeS / 60])));
|
|
21
|
+
if (minutes !== null)
|
|
22
|
+
result.medianMinutes = Math.round(minutes);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function median(values) {
|
|
26
|
+
if (values.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
29
|
+
const middle = Math.floor(sorted.length / 2);
|
|
30
|
+
return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The agent's own status line for the README badge (BTN-932): the service asks for it in a hook's answer, the agent
|
|
3
|
+
* writes `status: …` next to its next tool call, and the transcript's fold takes it (`docs/badge.md`).
|
|
4
|
+
*/
|
|
5
|
+
/** A new status is asked for once the last one, or the last request, is this old. */
|
|
6
|
+
export const STATUS_ASK_MS = 2 * 60_000;
|
|
7
|
+
/** A status older than this gives way to the default action: the session stopped answering the requests. */
|
|
8
|
+
export const STATUS_FRESH_MS = 5 * 60_000;
|
|
9
|
+
const LIMIT = 60;
|
|
10
|
+
const MARK = '<even-keel-status-request>';
|
|
11
|
+
const LINE = /^[ \t]*status:[ \t]*(\S.*?)[ \t]*$/gim;
|
|
12
|
+
/** What a hook puts into the session's context; the mark is how the transcript knows the line was asked for. */
|
|
13
|
+
export function statusRequest() {
|
|
14
|
+
return `${MARK}In your next message, next to your next tool call, add one line \`status: …\` saying what you are doing right now: in English, up to ${LIMIT} characters, no names of people or companies, no paths and no addresses. Do not call a tool for it and do not answer this request in any other way.</even-keel-status-request>`;
|
|
15
|
+
}
|
|
16
|
+
/** Whether a hook's text holds the request. */
|
|
17
|
+
export function statusAsked(text) {
|
|
18
|
+
return text.includes(MARK);
|
|
19
|
+
}
|
|
20
|
+
/** The words of the text's last `status: …` line; `null` — it has none. */
|
|
21
|
+
export function statusLineIn(text) {
|
|
22
|
+
return [...text.matchAll(LINE)].at(-1)?.[1] ?? null;
|
|
23
|
+
}
|
|
24
|
+
/** The text without its `status: …` lines, as the chat shows it. */
|
|
25
|
+
export function withoutStatusLine(text) {
|
|
26
|
+
return text
|
|
27
|
+
.split('\n')
|
|
28
|
+
.filter((line) => statusLineIn(line) === null)
|
|
29
|
+
.join('\n')
|
|
30
|
+
.trim();
|
|
31
|
+
}
|
|
32
|
+
/** The line as the badge may draw it: flat, printable ASCII (the badge's fonts hold nothing else), cut to 60; else `null`. */
|
|
33
|
+
export function statusTextOf(line) {
|
|
34
|
+
const flat = line.replace(/\s+/g, ' ').trim();
|
|
35
|
+
if (flat === '' || !/^[\x20-\x7e]+$/.test(flat))
|
|
36
|
+
return null;
|
|
37
|
+
return flat.length > LIMIT ? `${flat.slice(0, LIMIT - 1).trimEnd()}…` : flat;
|
|
38
|
+
}
|
|
39
|
+
/** When each session was last asked, in memory: a restart asks again no sooner than the status in the transcript allows. */
|
|
40
|
+
export class StatusAsks {
|
|
41
|
+
askedAt = new Map();
|
|
42
|
+
/** Whether to ask the session now; a `true` counts as asked. */
|
|
43
|
+
due(sessionId, status, now) {
|
|
44
|
+
const written = status === null ? Number.NaN : Date.parse(status.at);
|
|
45
|
+
const last = Math.max(this.askedAt.get(sessionId) ?? -Infinity, Number.isNaN(written) ? -Infinity : written);
|
|
46
|
+
if (now - last < STATUS_ASK_MS)
|
|
47
|
+
return false;
|
|
48
|
+
this.askedAt.set(sessionId, now);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
/** Forgets the sessions that are gone. */
|
|
52
|
+
keep(live) {
|
|
53
|
+
for (const id of this.askedAt.keys())
|
|
54
|
+
if (!live.has(id))
|
|
55
|
+
this.askedAt.delete(id);
|
|
56
|
+
}
|
|
57
|
+
}
|